mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-14 17:11:34 +01:00
\#5, TODO: Add codes and add sources and versions
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{% extends "base.twig" %}
|
{% extends app.fronthtml~"/base.twig" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container justified" style="font-size: 12pt">
|
<div class="container justified" style="font-size: 12pt">
|
||||||
<h4 style="text-align: center">Terms of service</h4>
|
<h4 style="text-align: center">Terms of service</h4>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<p>The registered user in all moment can close their account but all data hosted in CodeShare will remain
|
<p>The registered user in all moment can close their account but all data hosted in CodeShare will remain
|
||||||
hosted.
|
hosted.
|
||||||
<br>JKA Network is reserved the right to ban the access to account of any user who engage <a
|
<br>JKA Network is reserved the right to ban the access to account of any user who engage <a
|
||||||
href="index.php?page=doc#vandalism">vandalism</a></p>
|
href="{{path('doc')}}#vandalism">vandalism</a></p>
|
||||||
<h4 class="docheader top10" id="cookiePolicy">Cookie policiy</h4>
|
<h4 class="docheader top10" id="cookiePolicy">Cookie policiy</h4>
|
||||||
<p>In CodeShare are used two differents cookies, one for session system and other for cookies' consent. You can
|
<p>In CodeShare are used two differents cookies, one for session system and other for cookies' consent. You can
|
||||||
block CodeShare cookies but you cannot log in because we cannot check if login was right.
|
block CodeShare cookies but you cannot log in because we cannot check if login was right.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<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='{{ path('codeVer',{'idc': code.idc,'lang': code.lang}) }}'>View version's history</a></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{#<div id='QOZU_box'>Se necesita tener JavaScript habilitado para poder ver los comentarios de la web.</div>#}
|
{#<div id='QOZU_box'>Se necesita tener JavaScript habilitado para poder ver los comentarios de la web.</div>#}
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="text-align:center;"><h3>Other implementations</h3>
|
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="text-align:center;"><h3>Other implementations</h3>
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<a href="?page=code&id={{ code.idc }}&lang={{ i.lang }}&version={{ i.version }}">Link</a>
|
<a href="{{ path('code',{'idc': code.idc,'lang': i.lang,'version': i.version}) }}">{{i.lLang}}</a>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
{#<tr>
|
||||||
<td><strong>Lang: </strong>{{ i.lLang }}</td>
|
<td><strong>Version: </strong>{{ i.version }}</td>
|
||||||
</tr>
|
</tr>#}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<pre><code class='{{ i.lang }}'>{{ i.code }}</code></pre>
|
<pre><code class='{{ i.lang }}'>{{ i.code }}</code></pre>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends "base.twig" %}
|
{% extends app.fronthtml~"/base.twig" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class='center'>
|
<div class='center'>
|
||||||
<h1>{{ error.number }} - {{ error.text }}
|
<h1>{{ error.number }} - {{ error.text }}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends "base.twig" %}
|
{% extends app.fronthtml~"/base.twig" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
{% if page.state == 1 %}
|
{% if page.state == 1 %}
|
||||||
<p class="text-danger">Bad credentials</p>
|
<p class="text-danger">Bad credentials</p>
|
||||||
{% elseif page.state == 2 %}
|
{% elseif page.state == 2 %}
|
||||||
<p class="text-danger">Email already exits</p>
|
<p class="text-danger">Error during sign-up, check your data</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -32,8 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<button type="submit" class="btn btn-success g-recaptcha" data-sitekey="6Lc7gXAUAAAAAJRaFo99vIkOUWckuGW8IOLtUxwZ"
|
<button type="submit" class="btn btn-success">Submit</button>
|
||||||
data-callback="YourOnSubmitFn">Submit</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-offset-1 col-sm-12">
|
<div class="col-sm-offset-1 col-sm-12">
|
||||||
@@ -74,16 +73,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-sm-3" for="tos">You agree to our <a href="?page=tos">Terms of service</a></label>
|
<label class="control-label col-sm-3" for="tos">You agree to our <a href="{{path('tos')}}">Terms of service</a></label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input type="checkbox" required="required" name="tos" id="tos">
|
<input type="checkbox" required="required" name="tos" id="tos">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<button type="submit" class="btn btn-success g-recaptcha"
|
<button type="submit" class="btn btn-success">Submit</button>
|
||||||
data-sitekey="6Lc7gXAUAAAAAJRaFo99vIkOUWckuGW8IOLtUxwZ"
|
|
||||||
data-callback="YourOnSubmitFn">Submit</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-offset-1 col-sm-12">
|
<div class="col-sm-offset-1 col-sm-12">
|
||||||
@@ -128,7 +125,7 @@
|
|||||||
document.getElementById("emailre").onchange = checkEmail;
|
document.getElementById("emailre").onchange = checkEmail;
|
||||||
document.getElementById("emailre-re").onchange = checkEmail;
|
document.getElementById("emailre-re").onchange = checkEmail;
|
||||||
|
|
||||||
{% if page.page == "register" or page.state == 2 %}
|
{% if page.page == "sign-up" or page.state == 2 %}
|
||||||
nowRegister();
|
nowRegister();
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -34,17 +34,17 @@
|
|||||||
</li>
|
</li>
|
||||||
{% if user.nick is defined %}
|
{% if user.nick is defined %}
|
||||||
<li {% if page.page == "user" %}class="active"{% endif %}>
|
<li {% if page.page == "user" %}class="active"{% endif %}>
|
||||||
<a href="?page=user">{{ user.nick }}</a>
|
<a href="{{path('user')}}">{{ user.nick }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="?page=logout">Log out</a>
|
<a href="{{ path('logout')}}">Log out</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li {% if page.page == "login" %}class="active"{% endif %}>
|
<li {% if page.page == "login" %}class="active"{% endif %}>
|
||||||
<a href="?page=login">Log in</a>
|
<a href="{{ path('login') }}">Log in</a>
|
||||||
</li>
|
</li>
|
||||||
<li {% if page.page == "register" %}class="active"{% endif %}>
|
<li {% if page.page == "register" %}class="active"{% endif %}>
|
||||||
<a href="?page=register">Register</a>
|
<a href="{{ path('register') }}">Register</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends "base.twig" %}
|
{% extends app.fronthtml~"/base.twig" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "firstCodes.twig" %}
|
{% include app.fronthtml~"/firstCodes.twig" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{% extends "base.twig" %}
|
{% extends app.fronthtml~"/base.twig" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h4 style="text-align: center" xmlns="http://www.w3.org/1999/html">{{ user.nick }}</h4>
|
<h4 style="text-align: center" xmlns="http://www.w3.org/1999/html">{{ user.nick }}</h4>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ class DB
|
|||||||
*/
|
*/
|
||||||
public function loadDiff($id, $lang)
|
public function loadDiff($id, $lang)
|
||||||
{
|
{
|
||||||
$query = "SELECT Lang,Code,Version FROM Sources NATURAL JOIN Codes WHERE IDC=$id AND Lang<>'$lang' AND Version = (SELECT MAX(Version) FROM Sources NATURAL JOIN Codes WHERE IDC=$id AND Lang<>'$lang')";
|
$lang=dbw_escape_string($this->conn,$lang);
|
||||||
|
$query = "SELECT Lang,Code,Version FROM Sources WHERE IDC=$id AND Lang<>'$lang' AND Version = (SELECT MAX(Version) FROM Sources WHERE IDC=$id AND Lang='$lang')";
|
||||||
$code = dbw_query($this->conn, $query);
|
$code = dbw_query($this->conn, $query);
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
@@ -459,7 +460,7 @@ class DB
|
|||||||
*/
|
*/
|
||||||
public function updatePass($idu, $pass)
|
public function updatePass($idu, $pass)
|
||||||
{
|
{
|
||||||
$query = "UPDATE Users SET password='" . hash('sha256', $pass) . "' WHERE IDU='$idu'";
|
$query = "UPDATE Users SET pass='" . hash('sha256', $pass) . "' WHERE IDU='$idu'";
|
||||||
dbw_query($this->conn, $query);
|
dbw_query($this->conn, $query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,17 +35,29 @@ $string = file_get_contents(__DIR__."/../data/supported.json");
|
|||||||
$app["supported"] = json_decode($string, true);
|
$app["supported"] = json_decode($string, true);
|
||||||
|
|
||||||
$app['db']=null;
|
$app['db']=null;
|
||||||
try {
|
function connectDB(){
|
||||||
$app['db'] = new DB();
|
global $app;
|
||||||
}catch (Exception $ex){
|
try {
|
||||||
exit();
|
$app['db'] = new DB();
|
||||||
|
}catch (Exception $ex){
|
||||||
|
$app->abort('503','ERROR en la Base de Datos');
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Security */
|
||||||
|
$app['security.role_hierarchy'] = array(
|
||||||
|
'ROLE_DELETE' => array('ROLE_COMMON'),
|
||||||
|
'ROLE_COMMON' => array('ROLE_USER'),
|
||||||
|
);
|
||||||
|
/* End Security */
|
||||||
|
|
||||||
$app->boot();
|
$app->boot();
|
||||||
|
|
||||||
/* Basics */
|
/* Basics */
|
||||||
$app->get('/', function (Request $request) use($app) {
|
$app->get('/', function (Request $request) use($app) {
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
$query = $app['db']->loadLast();
|
$query = $app['db']->loadLast();
|
||||||
$last = lastToArray($app["db"],$query,$app['supported']);
|
$last = lastToArray($app["db"],$query,$app['supported']);
|
||||||
|
|
||||||
@@ -55,32 +67,42 @@ $app->get('/', function (Request $request) use($app) {
|
|||||||
"last" => $last,
|
"last" => $last,
|
||||||
"supported" => $app["supported"],
|
"supported" => $app["supported"],
|
||||||
"page" => "home",
|
"page" => "home",
|
||||||
"grouped" => groupByCategory($app["supported"]))
|
"grouped" => groupByCategory($app["supported"])),
|
||||||
|
'user' => $user
|
||||||
));
|
));
|
||||||
})->bind('home');
|
})->bind('home');
|
||||||
|
|
||||||
$app->get('/doc', function (Request $request) use($app){
|
$app->get('/doc', function (Request $request) use($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
$page = array(
|
$page = array(
|
||||||
"title" => "Documentation",
|
"title" => "Documentation",
|
||||||
"description" => "All documentation about how to upload code in CodeShare",
|
"description" => "All documentation about how to upload code in CodeShare",
|
||||||
"page" => "doc"
|
"page" => "doc",
|
||||||
);
|
);
|
||||||
return $app['twig']->render($app['fronthtml'].'/doc.twig', array("page" => $page));
|
return $app['twig']->render($app['fronthtml'].'/doc.twig', array("page" => $page, "user" => $user));
|
||||||
})->bind('doc');
|
})->bind('doc');
|
||||||
|
|
||||||
$app->get('/about', function (Request $request) use($app){
|
$app->get('/about', function (Request $request) use($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
$page = array(
|
$page = array(
|
||||||
"title" => "About CodeShare",
|
"title" => "About CodeShare",
|
||||||
"description" => "Developed by JKA Network's Team",
|
"description" => "Developed by JKA Network's Team",
|
||||||
"page" => "about",
|
"page" => "about",
|
||||||
);
|
);
|
||||||
return $app['twig']->render($app['fronthtml'].'/about.twig', array("page" => $page));
|
return $app['twig']->render($app['fronthtml'].'/about.twig', array("page" => $page,'user'=>$user));
|
||||||
})->bind('about');
|
})->bind('about');
|
||||||
|
|
||||||
/* Codes */
|
/* Codes */
|
||||||
$app->get('/code/{idc}/{lang}/{version}', function (Request $request, $idc, $lang, $version) use($app){
|
$app->get('/code/{lang}-{idc}-{version}', function (Request $request, $lang, $idc, $version) use($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
|
|
||||||
$array = $app['db']->loadAll($idc,$lang,$version);
|
$array = $app['db']->loadAll($idc,$lang,$version);
|
||||||
|
if(!$array){
|
||||||
|
$app->abort('404');
|
||||||
|
}
|
||||||
$page = array(
|
$page = array(
|
||||||
"page" => 'code',
|
"page" => 'code',
|
||||||
"title" => "$array[Name] by $array[nick]",
|
"title" => "$array[Name] by $array[nick]",
|
||||||
@@ -104,5 +126,186 @@ $app->get('/code/{idc}/{lang}/{version}', function (Request $request, $idc, $lan
|
|||||||
"code" => $code,
|
"code" => $code,
|
||||||
"otherImplementation" => $otherImplementation,
|
"otherImplementation" => $otherImplementation,
|
||||||
"supported" => $app['supported'],
|
"supported" => $app['supported'],
|
||||||
|
"user" => $user
|
||||||
));
|
));
|
||||||
})->bind('code');
|
})->bind('code');
|
||||||
|
|
||||||
|
$app->get('/code/{lang}-{idc}', function(Request $request, $lang, $idc) use($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
|
|
||||||
|
$array = $app['db']->loadOtherVersion($idc,$lang);
|
||||||
|
$other = otherVersionToArray($app['db'],$array,$app['supported']);
|
||||||
|
$name = $other[0]['name'];
|
||||||
|
|
||||||
|
$page = array(
|
||||||
|
"title" => "Other versions of $name",
|
||||||
|
"description" => "All differents version of $name uploaded in CodeShare",
|
||||||
|
"last" => $other,
|
||||||
|
"page" => ""
|
||||||
|
);
|
||||||
|
return $app['twig']->render($app['fronthtml'].'/otherVersion.twig', array(
|
||||||
|
"page" => $page, "user" => $user
|
||||||
|
));
|
||||||
|
})->bind('codeVer');
|
||||||
|
|
||||||
|
/* User */
|
||||||
|
$app->get('/tos',function(Request $request) use($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
|
$page = array(
|
||||||
|
"title" => "Terms of service",
|
||||||
|
"description" => "Terms of services and privacy policies",
|
||||||
|
"page" => ""
|
||||||
|
);
|
||||||
|
|
||||||
|
return $app['twig']->render($app['fronthtml'].'/TOS.twig', array("page" => $page, "user" => $user));
|
||||||
|
})->bind('tos');
|
||||||
|
|
||||||
|
$app->get('/login', function(Request $request) use ($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
|
if($user != null){
|
||||||
|
return $app->redirect($app["url_generator"]->generate('home'));
|
||||||
|
}
|
||||||
|
if ($request->getMethod() == 'GET'){
|
||||||
|
return loginRegister('login');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$state = checkInfo($request);
|
||||||
|
return loginOrRegister($state,$request);
|
||||||
|
}
|
||||||
|
|
||||||
|
})->bind('login')->method('GET|POST');
|
||||||
|
|
||||||
|
$app->get('/signup', function(Request $request) use ($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
|
if($user != null){
|
||||||
|
return $app->redirect($app["url_generator"]->generate('home'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->getMethod() == 'GET'){
|
||||||
|
return loginRegister('sign-up');
|
||||||
|
}else{
|
||||||
|
$state = checkInfo($request);
|
||||||
|
return loginOrRegister($state,$request);
|
||||||
|
}
|
||||||
|
|
||||||
|
})->bind('register')->method('GET|POST');
|
||||||
|
|
||||||
|
function loginRegister($default,$state=0){
|
||||||
|
global $app;
|
||||||
|
|
||||||
|
$page = array(
|
||||||
|
"title" => ucfirst($default),
|
||||||
|
"description" => "Start now in CodeShare",
|
||||||
|
"page" => "$default",
|
||||||
|
"state" => $state, //0=no logged, 1 login fail, 2 register fail, 3 all correct (render home)
|
||||||
|
);
|
||||||
|
return $app['twig']->render($app['fronthtml']."/loginregister.twig", array("page" => $page));
|
||||||
|
}
|
||||||
|
|
||||||
|
function loginOrRegister($state,$request){
|
||||||
|
global $app;
|
||||||
|
|
||||||
|
switch ($state){
|
||||||
|
case 3:
|
||||||
|
return loginRegister('login',1);
|
||||||
|
case 1:
|
||||||
|
if(checklogin($request->get('email'),$request->get('pwd'))){
|
||||||
|
return $app->redirect($app["url_generator"]->generate('home'));
|
||||||
|
}else{
|
||||||
|
return loginRegister("login",1);
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if(register($request->get('emailre'),$request->get('emailre-re'),
|
||||||
|
$request->get('pwdre'), $request->get('pwdre-re'),$request->get('nick'))){
|
||||||
|
return $app->redirect($app["url_generator"]->generate('home'));
|
||||||
|
}else{
|
||||||
|
return loginRegister("sing-up",2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$app->get('logout',function(Request $request) use ($app){
|
||||||
|
logout();
|
||||||
|
return $app->redirect($app['url_generator']->generate('home'));
|
||||||
|
})->bind('logout');
|
||||||
|
|
||||||
|
$app->get('/user', function(Request $request) use ($app){
|
||||||
|
connectDB();
|
||||||
|
$user = getUser($app);
|
||||||
|
if($user == null)
|
||||||
|
$app->abort('403');
|
||||||
|
|
||||||
|
$status = 0;
|
||||||
|
if($request->getMethod() == 'POST'){
|
||||||
|
$passact = $request->get("passact");
|
||||||
|
$newpass = $request->get("newpass");
|
||||||
|
$newpassre = $request->get("newpass-re");
|
||||||
|
if($app['db']->checkPass($user['email'],$passact) && $newpass == $newpassre){
|
||||||
|
$status=1;
|
||||||
|
$app['db']->updatePass($user['IDU'],$newpass);
|
||||||
|
}else
|
||||||
|
$status=2;
|
||||||
|
$app['db']->close();
|
||||||
|
}
|
||||||
|
$page = array(
|
||||||
|
"page" => "user",
|
||||||
|
"title" => "$user[nick]",
|
||||||
|
"description" => "NOT RELEVANT",
|
||||||
|
"status" => $status
|
||||||
|
);
|
||||||
|
return $app['twig']->render($app['fronthtml']."/user.twig",array("page"=>$page,"user"=>$user));
|
||||||
|
|
||||||
|
})->bind('user')->method('GET|POST');
|
||||||
|
|
||||||
|
/* Error Codes */
|
||||||
|
function HTTPError($code){
|
||||||
|
switch($code){
|
||||||
|
case 401:
|
||||||
|
$text = "Unauthorized user";
|
||||||
|
break;
|
||||||
|
case 403:
|
||||||
|
$text = "Forbidden page";
|
||||||
|
break;
|
||||||
|
case 404:
|
||||||
|
$text = "Page not found";
|
||||||
|
break;
|
||||||
|
case 503:
|
||||||
|
$text = "Database unavailable";
|
||||||
|
break;
|
||||||
|
case 500:
|
||||||
|
$text = "Internal server error";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$text = "Please, return to home page";
|
||||||
|
$code = "Internal error";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return array("text"=>$text,"number"=>$code);
|
||||||
|
}
|
||||||
|
|
||||||
|
$app->error(function (\Exception $e,$request, $code) use ($app) {
|
||||||
|
$user = null;
|
||||||
|
try{
|
||||||
|
$user = getUser($app);
|
||||||
|
}catch(Throwable $ex){
|
||||||
|
//Nothing
|
||||||
|
}
|
||||||
|
if ($app['debug']) {
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$error = HTTPError($code);
|
||||||
|
return $app['twig']->render($app['fronthtml'].'/error.twig', Array(
|
||||||
|
'page' => array("title"=>$code),
|
||||||
|
'error' => $error,
|
||||||
|
'user' => $user,
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,6 @@ function otherImplementationToArray($db,&$query,$supported){
|
|||||||
return $other;
|
return $other;
|
||||||
}
|
}
|
||||||
|
|
||||||
function otherVersionToArray($db,&$query,&$supported){
|
function otherVersionToArray($db,$query,$supported){
|
||||||
return lastToArray($db,$query,$supported);
|
return lastToArray($db,$query,$supported);
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,17 @@
|
|||||||
* Time: 19:06
|
* Time: 19:06
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function checkInfo($request){
|
||||||
|
$email = $request->get('email');
|
||||||
|
$emailre = $request->get('emailre');
|
||||||
|
if ($email != null)
|
||||||
|
return 1;
|
||||||
|
else if ($emailre != null)
|
||||||
|
return 2;
|
||||||
|
else
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if login is correct
|
* Check if login is correct
|
||||||
*
|
*
|
||||||
@@ -37,8 +48,10 @@ function checklogin($email,$pass){
|
|||||||
* @param $nick new user's nickname
|
* @param $nick new user's nickname
|
||||||
* @return bool true if email never exists before, else false
|
* @return bool true if email never exists before, else false
|
||||||
*/
|
*/
|
||||||
function register($email,$pass,$nick){
|
function register($email,$emailre,$pass,$passre,$nick){
|
||||||
$db = new DB();
|
$db = new DB();
|
||||||
|
if($emailre != $email || $pass != $passre)
|
||||||
|
return false;
|
||||||
$bool = $db->register($email,$pass,$nick);
|
$bool = $db->register($email,$pass,$nick);
|
||||||
if($bool) {
|
if($bool) {
|
||||||
$db->close();
|
$db->close();
|
||||||
@@ -61,7 +74,7 @@ function getUser($app){
|
|||||||
$user=null;
|
$user=null;
|
||||||
if(isset($_SESSION['sessionID'])){
|
if(isset($_SESSION['sessionID'])){
|
||||||
if($app['db']->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
|
if($app['db']->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
|
||||||
$user = $db->loadProfile($_SESSION['sessionID']);
|
$user = $app['db']->loadProfile($_SESSION['sessionID']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $user;
|
return $user;
|
||||||
|
|||||||
Reference in New Issue
Block a user