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

@ -1,4 +1,5 @@
RewriteEngine on
RewriteRule ^([a-zA-Z_]+)\/((config|proj|res|script|style|subs|uploads)\/([a-zA-Z_.\/]+)?)$ /$2 [L,R]
RewriteRule ^(config|mailer|proj|res|script|style|subs|uploads|websvn)\/?(.)+?$ - [L]
RewriteRule ^(proj)(\/(.)+?)?$ - [L]
RewriteRule ^([a-zA-Z_]+)\/((config|proj|res|script|style|subs|uploads)(\/([a-zA-Z_.\/]+)?)?)$ /$2 [L,R]
RewriteRule ^(config|proj|res|script|style|subs|uploads)(\/(.)+?)?$ - [L]
RewriteRule ^([a-zA-Z_]+)(\/([a-zA-Z0-9_:]+))?\/?$ index.php?view=$1&sub=$3 [L,QSA]

View File

@ -71,7 +71,7 @@ CREATE TABLE `projects` (
`path` varchar(125) NOT NULL default '',
`repo` varchar(125) NOT NULL default '',
`status` varchar(65) NOT NULL default '',
`image` text NOT NULL default '',
`image` varchar(125) NOT NULL default '',
PRIMARY KEY (`id`),
FOREIGN KEY (`owner`) REFERENCES users(`id`) ON DELETE CASCADE
) CHARACTER SET utf8 COLLATE utf8_general_ci;

View File

@ -114,6 +114,7 @@ projectlist="Project list"
description="Description"
path="Path"
repository="Repository"
image="Image"
;Errors
error[1]="Wrong username or password!"
@ -146,3 +147,4 @@ message[11]="Shipping information successfully deleted."
message[12]="Your profile has been deleted successfully. You won't be able to log in anymore. This process is irreversible."
message[13]="Request submitted successfully. Please be patient!"
message[14]="That's done, bro!"
message[15]="Project successfully created."

View File

@ -114,6 +114,7 @@ projectlist="Projekt lista"
description="Leírás"
path="Útvonal"
repository="Repó"
image="Kép"
;Errors
error[1]="Hibás felhasználónév vagy jelszó!"
@ -146,3 +147,4 @@ message[11]="Kiszállítási cím sikeresen törölve."
message[12]="A profilod sikeresen törölve. Többször nem tudsz majd belépni. Ez visszafordíthatatlan."
message[13]="Kérés sikeresen létrehozva. Kérlek légy türelemmel!"
message[14]="Kész van!"
message[15]="Projeck sikeresen létrehozva."

View File

@ -28,16 +28,19 @@ function loadProjects(){
type: "GET",
data: {"load":"projects", "backend":true, "getprojects":true},
success: function(response){
console.log(response);
var projects=(response instanceof Object)?response:JSON.parse(response);
$.each(projects, function(i, val){
var cur=(val instanceof Object)?val:JSON.parse(val);
var el=$("<div class=\"tile\"></div>");
var content="<h2>"+cur.name+"</h2><hr class=\"separator\">";
content+="<div class=\"imgholder\"><img src=\""+val.image+"\"></div>";
var el=$("<div class=\"tile\"></div>");
var content="<h2>"+cur.name+"</h2><hr class=\"separator\">";
content+="<div class=\"imgholder\"><img src=\""+cur.image+"\" alt=\"project image\"></div>";
content+="<div class=\"fadeout\" style=\"height: 10em\"><p>"+cur.description+"</p></div><br>";
content+="<button type=\"button\" style=\"float: left\" onclick=\"window.location='"+cur.path+"'\">"+$("#langView").text()+"</button><button type=\"button\" style=\"float: right\" onclick=\"window.location='"+cur.repo+"'\">"+$("#langSource").text()+"</button>";
content+="<p style=\"clear: both; font-size: 0.7em\">status: "+cur.status+", by: "+cur.owner+"</p>";
el.html(content);
el.hide().appendTo("#projects").slideDown();
});

View File

@ -722,3 +722,77 @@ function requestProfileData(){
});
}
}
/*
* Projects
*/
function projectsNew(){
$("#projectEditor")[0].reset();
$("#editor").slideDown();
$("#project_id").val("new");
}
function projectsSave(){
$.ajax({
url: "/subs/loader.php?load=userarea&backend",
type: "POST",
data: $("#projectEditor").serialize(),
success: function(response){
loadMessage();
if(response!="err"){
$("#editor").slideUp(function(){
$("#projectEditor")[0].reset();
});
}
}
});
}
function projectsEditCancel(){
$("#editor").slideUp(function(){
$("#projectEditor")[0].reset();
});
}
function projectsEdit(id){
$.ajax({
url: "/subs/loader.php",
type: "GET",
data: {"load": "userarea", "backend": true, "projects_get": id},
success: function(response){
loadMessage();
if(response!="err"){
var cur=(response instanceof Object)?response:JSON.parse(response);
$("#project_id").val(cur.id);
$("[name=project_name").val(cur.name);
$("[name=project_desc").val(cur.description);
$("[name=project_path").val(cur.path);
$("[name=project_repo").val(cur.repo);
$("[name=project_status").val(cur.status);
$("[name=project_image").val(cur.image);
$("#editor").slideDown();
}
}
});
}
function projectsDelete(id, el){
if(confirm($("#langSure").text())){
$.ajax({
url: "/subs/loader.php?load=userarea&backend",
type: "POST",
data: {"projects_delete": id},
success: function(response){
loadMessage();
if(response=="ok"){
$(this).parent("td").parent("tr").css("background", "red").fadeOut(function(){
$(this).remove();
});
}
}
});
}
}

View File

@ -293,6 +293,7 @@ div.tileset div.tile{
div.tile .imgholder{
width: 90%;
height: 9em;
margin: auto;
}
div.tile img{

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";
}
}
}