Add new comments and comment all deletion system

This commit is contained in:
JoseluCross
2017-09-18 20:34:06 +02:00
parent 5531725cfe
commit af5383d6d9
5 changed files with 42 additions and 6 deletions

View File

@@ -21,9 +21,9 @@
{% endif %} {% endif %}
<div class="col-md-3"></div> <div class="col-md-3"></div>
</div> </div>
{% if user.ROLE == 3 %} {#{% if user.ROLE == 3 %}
<a href="?page=del&id={{ code.idc }}&lang={{ code.lang }}&version={{ code.version }}" class="btn btn-danger">Delete source</a> <a href="?page=del&id={{ code.idc }}&lang={{ code.lang }}&version={{ code.version }}" class="btn btn-danger">Delete source</a>
{% endif %} {% endif %}#}
{% if page.otherV %} {% if page.otherV %}
<div style='text-align: center; font-size: 22px; '><a href='?page=code&id={{ code.idc }}&lang={{ code.lang }}'>View version's history</a></div> <div style='text-align: center; font-size: 22px; '><a href='?page=code&id={{ code.idc }}&lang={{ code.lang }}'>View version's history</a></div>
{% endif %} {% endif %}

View File

@@ -65,8 +65,8 @@ function run(){
case "user": case "user":
user(); user();
break; break;
case "del": /*case "del":
deleteSource(); deleteSource();*/
break; break;
default: default:
sendHTTPError(404); sendHTTPError(404);
@@ -343,7 +343,7 @@ function user(){
} }
} }
function deleteSource(){ /*function deleteSource(){
global $user; global $user;
if(array_key_exists('ROLE',$user)){ if(array_key_exists('ROLE',$user)){
if($user['ROLE']==3){ if($user['ROLE']==3){
@@ -356,4 +356,4 @@ function deleteSource(){
}else{ }else{
sendHTTPError(403); sendHTTPError(403);
} }
} }*/

View File

@@ -6,6 +6,11 @@
* Time: 11:42 * Time: 11:42
*/ */
/*
* Methods to get an array to send to twig
*/
function lastToArray($db,$query,$supported){ function lastToArray($db,$query,$supported){
$last = array(); $last = array();
while($var = dbw_fetch_array($db->conn,$query)){ while($var = dbw_fetch_array($db->conn,$query)){

View File

@@ -5,6 +5,13 @@
* Date: 6/07/17 * Date: 6/07/17
* Time: 11:56 * Time: 11:56
*/ */
/**
* Generate a RandomString
*
* @param $length length of string
* @return string string generated
*/
function RandomString($length) function RandomString($length)
{ {
//https://phpes.wordpress.com/2007/06/12/generador-de-una-cadena-aleatoria/ //https://phpes.wordpress.com/2007/06/12/generador-de-una-cadena-aleatoria/
@@ -23,6 +30,12 @@ function RandomString($length)
return $rstr; return $rstr;
} }
/**
* Parse a file from Keys system object notation (KSON) to Mapped array
*
* @param $path path to file
* @return array array from kson
*/
function ksonParse($path){ function ksonParse($path){
$file = fopen($path,"r"); $file = fopen($path,"r");
$array = []; $array = [];

View File

@@ -6,6 +6,13 @@
* Time: 19:06 * Time: 19:06
*/ */
/**
* Check if login is correct
*
* @param $email user's input email
* @param $pass user's input password
* @return bool true if email-password combination is correct, false if not
*/
function checklogin($email,$pass){ function checklogin($email,$pass){
$db = new DB(); $db = new DB();
$bool = $db->checkPass($email,$pass); $bool = $db->checkPass($email,$pass);
@@ -22,6 +29,14 @@ function checklogin($email,$pass){
return false; return false;
} }
/**
* Register a new user in platform
*
* @param $email new user's email
* @param $pass new user's password
* @param $nick new user's nickname
* @return bool true if email never exists before, else false
*/
function register($email,$pass,$nick){ function register($email,$pass,$nick){
$db = new DB(); $db = new DB();
$bool = $db->register($email,$pass,$nick); $bool = $db->register($email,$pass,$nick);
@@ -35,6 +50,9 @@ function register($email,$pass,$nick){
} }
/**
* Logout user
*/
function logout(){ function logout(){
setcookie("token","",time()-3600); setcookie("token","",time()-3600);
setcookie("sessionID",0,time()-3600); setcookie("sessionID",0,time()-3600);