Store in GIT

This commit is contained in:
2026-06-17 15:42:16 +02:00
parent 9950ec87ac
commit 90f27d4516
47 changed files with 19559 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
require("../../../inc/connect.php");
$project = $_POST['project'];
//Find all files
$query = "SELECT `id`, `name` FROM `file` WHERE `project-id`=$project";
$result = ExecQuery($query);
//No option
echo "<option value='0'>None</option>";
while($row = $result->fetch_assoc())
{
echo "<option value='" . $row['id'] . "'>" . $row['name'] . "</option>";
}
?>
+20
View File
@@ -0,0 +1,20 @@
<?php
require("../../../inc/connect.php");
$uid = $_POST['uid'];
if($uid == "")
{
echo "false";
exit;
}
$query = "SELECT `id` FROM `project` WHERE `uid` = '$uid'";
$result = ExecQuery($query);
if($result->num_rows > 0)
echo "false";
else
echo "true";
?>
+31
View File
@@ -0,0 +1,31 @@
<?php
require("../../../inc/connect.php");
$handle = fopen("ip.txt", "r");
if($handle)
{
$stmt = $mysqli->prepare("DELETE FROM `view` WHERE `ip`=?");
$stmt->bind_param("s", $ip);
$stmt2 = $mysqli->prepare("DELETE FROM `download` WHERE `ip`=?");
$stmt2->bind_param("s", $ip);
while(($line = fgets($handle)) !== false)
{
$ip = trim($line);
if(substr($ip,0,1) == "#")
continue;
if($ip != "")
{
$stmt->execute();
$stmt2->execute();
}
}
fclose($handle);
$stmt->close();
$stmt2->close();
}
?>
File diff suppressed because it is too large Load Diff
+21
View File
@@ -0,0 +1,21 @@
<?php
require("../../inc/connect.php");
$name = $_POST['name'];
$uid = $_POST['uid'];
$language = $_POST['language'];
$date = $_POST['date'];
$grade = $_POST['grade'];
$body = $_POST['body'];
$grade = str_replace(",", ".", $grade);
$body = str_replace("\n", "<br/>", $body);
$stmt = $mysqli->prepare("INSERT INTO `project` (`name`, `uid`, `language`, `date`, `grade`, `body`) VALUES (?,?,?,?,?,?) ");
$stmt->bind_param("ssssds", $name, $uid, $language, $date, $grade, $body);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>
+13
View File
@@ -0,0 +1,13 @@
<?php
require("../../inc/connect.php");
$project = $_POST['project'];
$code = $_POST['code'];
$stmt = $mysqli->prepare("UPDATE `project` SET `code`=? WHERE `id`=?");
$stmt->bind_param("ii", $code, $project);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
require("../../inc/connect.php");
$relative_dir = "../../";
$name = $_POST['name'];
$project = $_POST['project'];
$uid = $_POST['uid'];
$filename = basename($_FILES["file"]["name"]);
//Get the directory name
$query = "SELECT `uid` FROM project WHERE `id`=$project";
$temp = ExecQuery($query);
$result = $temp->fetch_assoc();
$dir = $relative_dir . "download/" . $result['uid'];
$target_file = $dir . "/" . $filename;
//Create the directory
if (! file_exists($dir)) {
mkdir($dir, 0755, true);
}
$extension = pathinfo($target_file,PATHINFO_EXTENSION);
//Try to move the file
if (! move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
header("Location: /ptf-admin/add?success=false");
exit;
}
//Update the database
$stmt = $mysqli->prepare("INSERT INTO file (`name`, `uid`, `file`, `project-id`) VALUES (?,?,?,?)");
$stmt->bind_param("sssi", $name, $uid, $filename, $project);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>
+13
View File
@@ -0,0 +1,13 @@
<?php
require("../../inc/connect.php");
$project = $_POST['project'];
$git = $_POST['git'];
$stmt = $mysqli->prepare("UPDATE `project` SET `git`=? WHERE `id`=?");
$stmt->bind_param("si", $git, $project);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>
+68
View File
@@ -0,0 +1,68 @@
<?php
require("../../inc/connect.php");
$relative_dir = "../../";
$name = $_POST['name'];
$project = $_POST['project'];
$filetype = $_POST['type'];
$filename = basename($_FILES["file"]["name"]);
//Get the directory name
$query = "SELECT `uid` FROM project WHERE `id`=$project";
$temp = ExecQuery($query);
$result = $temp->fetch_assoc();
$dir = $relative_dir . "media/" . $result['uid'];
$target_file = $dir . "/" . $filename;
//Create the directory
if (! file_exists($dir)) {
mkdir($dir, 0755, true);
}
$extension = pathinfo($target_file,PATHINFO_EXTENSION);
// Allow certain file formats
$allowUpload = true;
if($filetype == "image")
{
if (! in_array($extension, array("jpg", "jpeg", "png", "gif"))) {
$allowUpload = false;
}
}
if($filetype == "video")
{
//if (! in_array(array("mp4"), $extension)) {
if($extension != "mp4"){
$allowUpload = false;
}
}
if($filetype == "audio")
{
//if (! in_array(array("mp3"), $extension)) {
if($extension != "mp3"){
$allowUpload = false;
}
}
//Check if upload is allowed
if(! $allowUpload)
{
header("Location: /ptf-admin/add?success=false");
exit;
}
//Try to move the file
if (! move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
header("Location: /ptf-admin/add?success=false");
exit;
}
//Update the database
$stmt = $mysqli->prepare("INSERT INTO media (`name`, `type`, `file`, `project-id`) VALUES (?,?,?,?)");
$stmt->bind_param("sssi", $name, $filetype, $filename, $project);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>
+23
View File
@@ -0,0 +1,23 @@
<?php
require("../../inc/connect.php");
$project = $_POST['project'];
$tag = $_POST['tag'];
$query = "SELECT `id` FROM `tagged` WHERE `tag-id`=$tag AND `project-id`=$project";
$result = ExecQuery($query);
if($result->num_rows > 0)
{
header("Location: /ptf-admin/add?success=false");
exit;
}
$stmt = $mysqli->prepare("INSERT INTO tagged (`project-id`, `tag-id`) VALUES (?,?)");
$stmt->bind_param("ii", $project, $tag);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>
+13
View File
@@ -0,0 +1,13 @@
<?php
require("../../inc/connect.php");
$name = $_POST['name'];
$stmt = $mysqli->prepare("INSERT INTO tag (`name`) VALUES (?)");
$stmt->bind_param("s", $name);
$stmt->execute();
$stmt->close();
header("Location: /ptf-admin/add?success=true");
?>