Import later changes

This commit is contained in:
Fándly Gergő
2019-08-10 15:39:07 +03:00
parent d24a3edef4
commit caeaf3d8ef
10 changed files with 163 additions and 18 deletions

View File

@ -24,14 +24,15 @@
**/
if(isset($_GET['getprojects'])){
$sql=$db->prepare("SELECT p.id, p.name, p.description, u.username, p.path, p.repo, p.status, p.image FROM projects AS p INNER JOIN users AS u ON (u.id=p.owner) ORDER BY id DESC");
$sql=$db->prepare("SELECT p.id, p.name, p.description, u.fullname AS owner, p.path, p.repo, p.status, p.image FROM projects AS p INNER JOIN users AS u ON (u.id=p.owner) ORDER BY p.name ASC");
$sql->execute();
$projects=array();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
array_push($projects, json_encode($projects));
array_push($projects, json_encode($row));
}
echo json_encode($projects);
die();
}

View File

@ -1,7 +1,7 @@
<?php
/**
* /subs/parts/userarea.php
* @version 1.2
* @version 1.3
* @desc Users area and admin console
* @author Fándly Gergő Zoltán (gergo@systemtest.tk, systemtest.tk)
* @copy 2018 Fándly Gergő Zoltán
@ -99,11 +99,11 @@ $lm->loginPrepare();
<?php if($_SESSION['accesslevel']>=1): ?>
<button type="button" onclick="window.location='/userarea/blog'"><?php echo $lang['blog'] ?></button>
<?php endif; if($_SESSION['accesslevel']>=2): ?>
<button type="button" onclick="window.location='/userarea/projects'"><?php echo $lang['projects'] ?></button>
<button type="button" onclick="window.location='/userarea/orders'"><?php echo $lang['orders'] ?></button>
<button type="button" onclick="window.location='/userarea/messages'"><?php echo $lang['messages'] ?></button>
<?php endif; if($_SESSION['accesslevel']>=3): ?>
<button type="button" onclick="window.location='/userarea/news'"><?php echo $lang['news'] ?></button>
<button type="button" onclick="window.location='/userarea/projects'"><?php echo $lang['projects'] ?></button>
<button type="button" onclick="window.location='/userarea/admin'"><?php echo $lang['adminarea'] ?></button>
<?php endif ?>
<button type="button" onclick="window.location='/userarea/profile'"><?php echo $lang['profile'] ?></button>

View File

@ -41,7 +41,7 @@ else{
}
if($sub!=""){
if($sub!="fileshare" && $sub!="blog" && $sub!="projects" && $sub!="orders" && $sub!="messages" && $sub!="news" && $sub!="admin" && $sub!="profile"){
if($sub!="fileshare" && $sub!="blog" && $sub!="orders" && $sub!="messages" && $sub!="news" && $sub!="projects" && $sub!="admin" && $sub!="profile"){
functions::setError(500);
header("Location: /userarea");
}
@ -49,11 +49,11 @@ else{
functions::setError(500);
header("Location: /userarea");
}
if(($sub=="projects" || $sub=="orders" || $sub=="messages") && $_SESSION['accesslevel']<2){
if(($sub=="orders" || $sub=="messages") && $_SESSION['accesslevel']<2){
functions::setError(500);
header("Location: /userarea");
}
if(($sub=="news" || $sub=="admin") && $_SESSION['accesslevel']<3){
if(($sub=="news" || $sub=="projects" || $sub=="admin") && $_SESSION['accesslevel']<3){
functions::setError(500);
header("Location: /userarea");
}
@ -706,5 +706,66 @@ else{
}
}
}
}
/*
* PROJECTS
*/
//get a project by id
if(isset($_GET['projects_get'])){
$sql=$db->prepare("SELECT p.id, p.name, p.description, u.fullname AS owner, p.path, p.repo, p.status, p.image FROM projects AS p INNER JOIN users AS u ON (u.id=p.owner) WHERE p.id=:id");
$sql->execute(array(":id"=>$_GET['projects_get']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
echo json_encode($res);
die();
}
//save project
if(isset($_POST['project_id']) && isset($_POST['project_name']) && isset($_POST['project_desc']) && isset($_POST['project_path']) && isset($_POST['project_repo']) && isset($_POST['project_status']) && isset($_POST['project_image'])){
if($_POST['project_id']=="new"){
$sql=$db->prepare("INSERT INTO projects (name, description, owner, path, repo, status, image) VALUES (:name, :desc, :owner, :path, :repo, :status, :image)");
$sql->execute(array(":name"=>$_POST['project_name'], ":desc"=>$_POST['project_desc'], ":owner"=>$_SESSION['id'], ":path"=>$_POST['project_path'], ":repo"=>$_POST['project_repo'], ":status"=>$_POST['project_status'], ":image"=>$_POST['project_image']));
$res=$sql->rowCount();
if($res<1){
functions::setError(6);
echo "err";
}
else{
functions::setMessage(15);
echo "ok";
}
}
else{
$sql=$db->prepare("UPDATE projects SET name=:name, description=:desc, path=:path, repo=:repo, status=:status, image=:image WHERE id=:id");
$sql->execute(array(":name"=>$_POST['project_name'], ":desc"=>$_POST['project_desc'], ":path"=>$_POST['project_path'], ":repo"=>$_POST['project_repo'], ":status"=>$_POST['project_status'], ":image"=>$_POST['project_image'], ":id"=>$_POST['project_id']));
$res=$sql->rowCount();
if($res<1){
functions::setError(6);
echo "err";
}
else{
functions::setMessage(4);
echo "ok";
}
}
}
//delete project
if(isset($_POST['project_delete'])){
$sql=$db->prepare("DELETE FROM projects WHERE id=:id");
$sql->execute(array(":id"=>$_POST['project_delete']));
$res=$sql->rowCount();
if($res<1){
functions::setError(6);
echo "err";
}
else{
functions::setMessage(5);
echo "ok";
}
}
}