Skip to content
Snippets Groups Projects
Commit 8071e732 authored by Husnulzaki Wibisono Haryadi's avatar Husnulzaki Wibisono Haryadi
Browse files
parents c011f8d1 7dbc74e2
No related merge requests found
...@@ -42,9 +42,9 @@ stages: ...@@ -42,9 +42,9 @@ stages:
cs: cs:
stage: stage:
codesmell--error-severity=1 --warning-severity=8 --extensions=php codesmell
script: script:
- vendor/bin/phpcs - vendor/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php
# Run our tests # Run our tests
# If Xdebug was installed you can generate a coverage report and see code coverage metrics. # If Xdebug was installed you can generate a coverage report and see code coverage metrics.
......
...@@ -33,5 +33,6 @@ $stmt = $conn->prepare( ...@@ -33,5 +33,6 @@ $stmt = $conn->prepare(
$stmt->bind_param("sssss", $nama_kegiatan, $target_peserta, $deskripsi_acara, $tanggal_kegiatan, $lokasi_kegiatan); $stmt->bind_param("sssss", $nama_kegiatan, $target_peserta, $deskripsi_acara, $tanggal_kegiatan, $lokasi_kegiatan);
$stmt->execute(); $stmt->execute();
$stmt->close(); $stmt->close();
$conn->close();
echo 'Sukses, kegiatan ' . $nama_kegiatan . ' berhasil ditambahkan.'; echo 'Sukses, kegiatan ' . $nama_kegiatan . ' berhasil ditambahkan.';
...@@ -50,12 +50,11 @@ if ($_POST["isVideo"] == 1) { ...@@ -50,12 +50,11 @@ if ($_POST["isVideo"] == 1) {
$target = $target_dir . uniqid() . "." .$imageFileType; $target = $target_dir . uniqid() . "." .$imageFileType;
if (move_uploaded_file($_FILES["videofile"]["tmp_name"], $target)) { if (move_uploaded_file($_FILES["videofile"]["tmp_name"], $target)) {
// proses file // proses file
echo "The file ". basename($_FILES["videofile"]["name"]). echo "File video ". basename($_FILES["videofile"]["name"]).
" has been uploaded.\n"; " berhasil diupload.\n";
$videoAddr = "http://pplk2a.if.itb.ac.id/ppl/" . $target; $videoAddr = "http://pplk2a.if.itb.ac.id/ppl/" . $target;
echo $videoAddr;
} else { } else {
echo "Sorry, there was an error PDF uploading your file because " .$_FILES["file"]["error"] ; echo "Sorry, there was an error PDF uploading your file ";
exit(); exit();
} }
} }
...@@ -89,20 +88,22 @@ if ($_POST["isPDF"] == 1) { ...@@ -89,20 +88,22 @@ if ($_POST["isPDF"] == 1) {
// do upload logic here // do upload logic here
} else { } else {
echo 'Upload directory is not writable, or does not exist.'; echo 'Upload directory is not writable, or does not exist.';
exit();
} }
// Check if $uploadOk is set to 0 by an error // Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) { if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded."; echo "Sorry, your file was not uploaded.";
exit();
// if everything is ok, try to upload file // if everything is ok, try to upload file
} else { } else {
$target = $target_dir . uniqid() . "." .$imageFileType; $target = $target_dir . uniqid() . "." .$imageFileType;
if (move_uploaded_file($_FILES["pdffile"]["tmp_name"], $target)) { if (move_uploaded_file($_FILES["pdffile"]["tmp_name"], $target)) {
// proses file // proses file
echo "The file ". basename($_FILES["pdffile"]["name"]). " has been uploaded.\n"; echo "File PDF ". basename($_FILES["pdffile"]["name"]). " berhasil diupload.\n";
$pdfAddr = "http://pplk2a.if.itb.ac.id/ppl/" . $target; $pdfAddr = "http://pplk2a.if.itb.ac.id/ppl/" . $target;
echo $pdfAddr; echo $pdfAddr;
} else { } else {
echo "Sorry, there was an error PDF uploading your file because " .$_FILES["file"]["error"] ; echo "Sorry, there was an error PDF uploading your file because" ;
exit(); exit();
} }
} }
......
...@@ -62,12 +62,11 @@ if ($_POST["isUpload"] == 1) { ...@@ -62,12 +62,11 @@ if ($_POST["isUpload"] == 1) {
$target = $target_dir . uniqid() . "." .$imageFileType; $target = $target_dir . uniqid() . "." .$imageFileType;
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target)) { if (move_uploaded_file($_FILES["file"]["tmp_name"], $target)) {
// proses file // proses file
echo "The file ". basename($_FILES["file"]["name"]). echo "File gambar ". basename($_FILES["file"]["name"]).
" has been uploaded.\n"; " berhasil diupload.\n";
$fileAddr = "http://pplk2a.if.itb.ac.id/ppl/" . $target; $fileAddr = "http://pplk2a.if.itb.ac.id/ppl/" . $target;
echo $fileAddr;
} else { } else {
echo "Sorry, there was an error PDF uploading your file because " .$_FILES["file"]["error"] ; echo "Sorry, there was an error PDF uploading your file ";
exit(); exit();
} }
} }
...@@ -98,4 +97,4 @@ $row = $stmt->fetch_assoc(); ...@@ -98,4 +97,4 @@ $row = $stmt->fetch_assoc();
$conn->close(); $conn->close();
\pmotraining\FirebaseNotif::sendNotif("Ada pengumuman baru", $judul, 0, $row["max"]); \pmotraining\FirebaseNotif::sendNotif("Ada pengumuman baru", $judul, 0, $row["max"]);
echo 'Sukses, pengumuman ' . $judul . ' berhasil ditambahkan.' . $row["max"]; echo 'Sukses, pengumuman ' . $judul . ' berhasil ditambahkan.';
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
* @link http://pear.php.net/package/komunitas-pmo * @link http://pear.php.net/package/komunitas-pmo
*/ */
ini_set('display_errors', 'on');
require 'dbConnect.php'; require 'dbConnect.php';
// Manage data // Manage data
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
*/ */
require 'dbConnect.php'; require 'dbConnect.php';
header('Content-Type: application/json');
$stmt = $conn->query("SELECT DISTINCT `topik` FROM `materi`"); $stmt = $conn->query("SELECT DISTINCT `topik` FROM `materi`");
$count = $stmt->num_rows; $count = $stmt->num_rows;
...@@ -19,5 +20,5 @@ while ($row = $stmt->fetch_assoc()) { ...@@ -19,5 +20,5 @@ while ($row = $stmt->fetch_assoc()) {
$res[] = $row["topik"]; $res[] = $row["topik"];
} }
echo json_encode($res); echo json_encode($res);
header('Content-Type: application/json');
$conn->close(); $conn->close();
...@@ -34,7 +34,6 @@ if (strtotime($lastBuild) < strtotime($rssLastBuild)) { ...@@ -34,7 +34,6 @@ if (strtotime($lastBuild) < strtotime($rssLastBuild)) {
$sql = "SELECT * FROM `berita` WHERE `judul` like '%" . $judul . "%'"; $sql = "SELECT * FROM `berita` WHERE `judul` like '%" . $judul . "%'";
$stmt = $conn->query($sql); $stmt = $conn->query($sql);
$numRows = $stmt->num_rows; $numRows = $stmt->num_rows;
echo ($sql);
$stmt->close(); $stmt->close();
if ($numRows == 0) { if ($numRows == 0) {
$stmt2 = $conn->prepare( $stmt2 = $conn->prepare(
...@@ -87,7 +86,7 @@ if (strtotime($lastBuild) < strtotime($rssLastBuild)) { ...@@ -87,7 +86,7 @@ if (strtotime($lastBuild) < strtotime($rssLastBuild)) {
} }
// update // update
file_put_contents("lastNewsUpdate.txt", $rssLastBuild); file_put_contents("lastNewsUpdate.txt", $rssLastBuild);
sendNotif("Ada berita baru", "Klik untuk membuka"); \pmotraining\FirebaseNotif::sendNotif("Ada berita baru", "Klik untuk membuka", 1, 0);
} }
// closing // closing
$conn->close(); $conn->close();
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment