mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-14 00:51:33 +01:00
Migrating to Silex
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{% extends "base.twig" %}
|
||||
{% extends app.fronthtml~"/base.twig" %}
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row" style="text-align: center">
|
||||
|
||||
@@ -52,9 +52,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12 col-sm-12">
|
||||
<button type="submit" class="btn btn-success g-recaptcha btn-block"
|
||||
data-sitekey="6Lc7gXAUAAAAAJRaFo99vIkOUWckuGW8IOLtUxwZ"
|
||||
data-callback="YourOnSubmitFn">Submit</button>
|
||||
<button type="submit" class="btn btn-success btn-block">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -2,35 +2,35 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ page.title }}</title>
|
||||
<link type="text/css" rel="stylesheet" href="{{ path.css }}/bootstrap-paper.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ app.frontcss }}/bootstrap-paper.css"/>
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
|
||||
<link type="text/css" rel="stylesheet" href="{{ path.css }}/main.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ path.css }}/codeStyles/vs.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ app.frontcss }}/main.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ app.frontcss }}/codeStyles/vs.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
|
||||
{#<link rel="shortcut icon" href="{{ path.img }}favicon.ico" type="image/x-icon"/>#}
|
||||
{% block css %}{% endblock %}
|
||||
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="description" content="{{ page.description }}"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<script src="{{ path.js }}/highlight.pack.js"></script>
|
||||
<script src="{{ path.js }}/jquery-3.2.1.min.js"></script>
|
||||
<script src="{{ path.js }}/bootstrap.min.js"></script>
|
||||
<script src="{{ app.frontjs }}/highlight.pack.js"></script>
|
||||
<script src="{{ app.frontjs }}/jquery-3.2.1.min.js"></script>
|
||||
<script src="{{ app.frontjs }}/bootstrap.min.js"></script>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
<script src="{{ path.js }}/functions.js"></script>
|
||||
<script src="{{ app.frontjs }}/functions.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
{% include 'nav.twig' %}
|
||||
{% include 'header.twig' %}
|
||||
{% include app.fronthtml~'/nav.twig' %}
|
||||
{% include app.fronthtml~'/header.twig' %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
{% include "footer.twig" %}
|
||||
{% include app.fronthtml~"/footer.twig" %}
|
||||
|
||||
{% block js %}
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
{% endblock %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
|
||||
<script>
|
||||
window.addEventListener("load", function(){
|
||||
|
||||
56
Source/assets/html/baseOld.twig
Normal file
56
Source/assets/html/baseOld.twig
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ page.title }}</title>
|
||||
<link type="text/css" rel="stylesheet" href="{{ path.css }}/bootstrap-paper.css"/>
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
|
||||
<link type="text/css" rel="stylesheet" href="{{ path.css }}/main.css"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ path.css }}/codeStyles/vs.css"/>
|
||||
{#<link rel="shortcut icon" href="{{ path.img }}favicon.ico" type="image/x-icon"/>#}
|
||||
{% block css %}{% endblock %}
|
||||
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="description" content="{{ page.description }}"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<script src="{{ path.js }}/highlight.pack.js"></script>
|
||||
<script src="{{ path.js }}/jquery-3.2.1.min.js"></script>
|
||||
<script src="{{ path.js }}/bootstrap.min.js"></script>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
<script src="{{ path.js }}/functions.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
{% include 'nav.twig' %}
|
||||
{% include 'header.twig' %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
{% include "footer.twig" %}
|
||||
|
||||
{% block js %}
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
{% endblock %}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
|
||||
<script>
|
||||
window.addEventListener("load", function(){
|
||||
window.cookieconsent.initialise({
|
||||
"palette": {
|
||||
"popup": {
|
||||
"background": "#2196f3",
|
||||
"text": "#b2dbfb"
|
||||
},
|
||||
"button": {
|
||||
"background": "transparent",
|
||||
"text": "#b2dbfb",
|
||||
"border": "#b2dbfb"
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"href": "?page=tos#cookiePolicy",
|
||||
"message": "This website uses cookies to ensure you get the best experience on on our website. If you don't accept any cookie won't be install on your browser.",
|
||||
"dismiss": "I accept it"
|
||||
}
|
||||
})});
|
||||
</script>
|
||||
</body>
|
||||
@@ -1,9 +1,9 @@
|
||||
{% extends "base.twig" %}
|
||||
{% extends app.fronthtml~"/base.twig" %}
|
||||
{% block content %}
|
||||
<div id="ajaxPut">
|
||||
<div class="codebox">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
{% include "codebox.twig" %}
|
||||
{% include app.fronthtml~"/codebox.twig" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
@@ -81,6 +81,14 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col_full" id="lib">
|
||||
<label for="extlib">External Library:</label>
|
||||
<input type="text" name="extlib" id="extlib" {% if code.extlib != "" %}value="{{ code.extlib }}"{% endif %} placeholder="Name of library">
|
||||
</div>
|
||||
<div class="col_full" id="libVer">
|
||||
<label for="extlibver">Library version:</label>
|
||||
<input type="text" name="extlibver" id="extlibver" {% if code.extlib != "" %}value="{{ code.extlibver }}" required="required" {% endif %} placeholder="Library version">
|
||||
</div>
|
||||
<div class="col_full">
|
||||
<label for="code">Code:</label>
|
||||
<textarea style="width: 100%" rows="{{ code.rows }}" required="required" name="code" id="code"></textarea>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<table style="width: 100%; text-align:center">
|
||||
<tr>
|
||||
<th>
|
||||
<a href="?page=code&id={{ code.idc }}&lang={{ code.lang }}&version={{ code.version }}">{{ code.name }}</a>
|
||||
<a href="{{ path('code',{'idc': code.idc,'lang': code.lang,'version': code.version}) }}">{{ code.name }}</a>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Author:</strong> {{ code.nick }} <strong> Version: </strong>{{ code.version }} <strong>
|
||||
Lang: </strong>{{ code.lLang }}</td>
|
||||
</tr>
|
||||
{% if code.extlib is not null %}
|
||||
{% if code.extlib is defined %}
|
||||
<tr>
|
||||
<td>
|
||||
<strong>External library:</strong> {{ code.extlib }}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% extends "base.twig" %}
|
||||
{% extends app.fronthtml~"/base.twig" %}
|
||||
{% block content %}
|
||||
<div class="container justified" style="font-size: 12pt;">
|
||||
<h4 style="text-align: center">Documentation</h4>
|
||||
@@ -9,9 +9,9 @@
|
||||
<h4 class="docheader top10" id="how">How can I submit my own solution?</h4>
|
||||
<ol>
|
||||
<li><p>First, you need to <strong>sign up</strong> in CodeShare <a href="?page=register">(link)</a>, and then go to <a href="?page=add">submit page</a> to start.</p>
|
||||
<img src="{{ path.img }}/doc/submit.png" alt="submit"/></li>
|
||||
<img src="{{ app.frontimg }}/doc/submit.png" alt="submit"/></li>
|
||||
<li><p>Write the <strong>solution's name and description.</strong> Notice that in this input boxes you shouldn't type any reference of language they can be uploaded in multiple languages in the future, and there are a box for language.</p>
|
||||
<img src="{{ path.img }}/doc/name_des.png"/></li>
|
||||
<img src="{{ app.frontimg }}/doc/name_des.png"/></li>
|
||||
<li><p>Now select <strong>language</strong> to help other users to find it easily.</p></li>
|
||||
<li><p>If your solution use a <strong>external library</strong> you can add its name and its version in their own input boxes.</p></li>
|
||||
<li><p>After that, introduce the <strong>Input</strong> and <strong>Output</strong> examples with the following criteria:</p></li>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
{% endif %}
|
||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||
<div class="codebox">
|
||||
{% include "codebox.twig" %}
|
||||
{% include app.fronthtml~"/codebox.twig" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% extends "base.twig" %}
|
||||
{% extends app.fronthtml~"/base.twig" %}
|
||||
{% block content %}
|
||||
<h5 style="text-align:center">Last codes</h5>
|
||||
{% include "filter.twig" %}
|
||||
{% include app.fronthtml~"/filter.twig" %}
|
||||
<div id="ajaxPut">
|
||||
{% include "firstCodes.twig" %}
|
||||
{% include app.fronthtml~"/firstCodes.twig" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -32,7 +32,8 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-success">Submit</button>
|
||||
<button type="submit" class="btn btn-success g-recaptcha" data-sitekey="6Lc7gXAUAAAAAJRaFo99vIkOUWckuGW8IOLtUxwZ"
|
||||
data-callback="YourOnSubmitFn">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-offset-1 col-sm-12">
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
<div class="navbar-collapse collapse" id="nav" aria-expanded="false" style="height: 1px">
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li {% if page.page == "home" %}class="active"{% endif %}>
|
||||
<a href="index.php">Home</a>
|
||||
<a href="{{ path('home') }}">Home</a>
|
||||
</li>
|
||||
<li {% if page.page == "add" %}class="active"{% endif %}>
|
||||
<a href="?page=add">Submit code</a>
|
||||
</li>
|
||||
<li {% if page.page == "doc" %}class="active"{% endif %}>
|
||||
<a href="?page=doc">Documentation</a>
|
||||
<a href="{{ path('doc') }}">Documentation</a>
|
||||
</li>
|
||||
<li {% if page.page == "about" %}class="active"{% endif %}>
|
||||
<a href="?page=about">About</a>
|
||||
<a href="{{ path('about') }}">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"require": {
|
||||
"twig/twig": "^2.0",
|
||||
"jkanetwork/dbwrapper": "^1.4"
|
||||
"jkanetwork/dbwrapper": "^1.4",
|
||||
"symfony/flex": "^1.1",
|
||||
"symfony/twig-bridge": "^4.1",
|
||||
"silex/silex": "^2.3"
|
||||
}
|
||||
}
|
||||
|
||||
711
Source/composer.lock
generated
711
Source/composer.lock
generated
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c34d26c2711c26f871ff9ca8a4401104",
|
||||
"content-hash": "80eef0db968dff798db6ae8ac2157e65",
|
||||
"packages": [
|
||||
{
|
||||
"name": "jkanetwork/dbwrapper",
|
||||
@@ -48,6 +48,546 @@
|
||||
],
|
||||
"time": "2018-05-16T15:47:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pimple/pimple",
|
||||
"version": "v3.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silexphp/Pimple.git",
|
||||
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32",
|
||||
"reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Pimple": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Pimple, a simple Dependency Injection Container",
|
||||
"homepage": "http://pimple.sensiolabs.org",
|
||||
"keywords": [
|
||||
"container",
|
||||
"dependency injection"
|
||||
],
|
||||
"time": "2018-01-21T07:42:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/container.git",
|
||||
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
||||
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Container\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common Container Interface (PHP FIG PSR-11)",
|
||||
"homepage": "https://github.com/php-fig/container",
|
||||
"keywords": [
|
||||
"PSR-11",
|
||||
"container",
|
||||
"container-interface",
|
||||
"container-interop",
|
||||
"psr"
|
||||
],
|
||||
"time": "2017-02-14T16:28:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
||||
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "Psr/Log/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"keywords": [
|
||||
"log",
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2016-10-10T12:19:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "silex/silex",
|
||||
"version": "v2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/silexphp/Silex.git",
|
||||
"reference": "6bc31c1b8c4ef614a7115320fd2d3b958032f131"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/silexphp/Silex/zipball/6bc31c1b8c4ef614a7115320fd2d3b958032f131",
|
||||
"reference": "6bc31c1b8c4ef614a7115320fd2d3b958032f131",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"pimple/pimple": "^3.0",
|
||||
"symfony/event-dispatcher": "^4.0",
|
||||
"symfony/http-foundation": "^4.0",
|
||||
"symfony/http-kernel": "^4.0",
|
||||
"symfony/routing": "^4.0"
|
||||
},
|
||||
"replace": {
|
||||
"silex/api": "self.version",
|
||||
"silex/providers": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": "^2.2",
|
||||
"monolog/monolog": "^1.4.1",
|
||||
"swiftmailer/swiftmailer": "^5",
|
||||
"symfony/asset": "^4.0",
|
||||
"symfony/browser-kit": "^4.0",
|
||||
"symfony/config": "^4.0",
|
||||
"symfony/css-selector": "^4.0",
|
||||
"symfony/debug": "^4.0",
|
||||
"symfony/doctrine-bridge": "^4.0",
|
||||
"symfony/dom-crawler": "^4.0",
|
||||
"symfony/expression-language": "^4.0",
|
||||
"symfony/finder": "^4.0",
|
||||
"symfony/form": "^4.0",
|
||||
"symfony/intl": "^4.0",
|
||||
"symfony/monolog-bridge": "^4.0",
|
||||
"symfony/options-resolver": "^4.0",
|
||||
"symfony/phpunit-bridge": "^3.2",
|
||||
"symfony/process": "^4.0",
|
||||
"symfony/security": "^4.0",
|
||||
"symfony/serializer": "^4.0",
|
||||
"symfony/translation": "^4.0",
|
||||
"symfony/twig-bridge": "^4.0",
|
||||
"symfony/validator": "^4.0",
|
||||
"symfony/var-dumper": "^4.0",
|
||||
"symfony/web-link": "^4.0",
|
||||
"twig/twig": "^2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Silex\\": "src/Silex"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Igor Wiedler",
|
||||
"email": "igor@wiedler.ch"
|
||||
}
|
||||
],
|
||||
"description": "The PHP micro-framework based on the Symfony Components",
|
||||
"homepage": "http://silex.sensiolabs.org",
|
||||
"keywords": [
|
||||
"microframework"
|
||||
],
|
||||
"abandoned": "symfony/flex",
|
||||
"time": "2018-04-20T05:17:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/debug",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/debug.git",
|
||||
"reference": "47ead688f1f2877f3f14219670f52e4722ee7052"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/debug/zipball/47ead688f1f2877f3f14219670f52e4722ee7052",
|
||||
"reference": "47ead688f1f2877f3f14219670f52e4722ee7052",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"psr/log": "~1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/http-kernel": "<3.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/http-kernel": "~3.4|~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Debug\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Debug Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-08-03T11:13:38+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e",
|
||||
"reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<3.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/expression-language": "~3.4|~4.0",
|
||||
"symfony/stopwatch": "~3.4|~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-07-26T09:10:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/flex",
|
||||
"version": "v1.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/flex.git",
|
||||
"reference": "9fb60f232af0764d58002e7872acb43a74506d25"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/flex/zipball/9fb60f232af0764d58002e7872acb43a74506d25",
|
||||
"reference": "9fb60f232af0764d58002e7872acb43a74506d25",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-plugin-api": "^1.0",
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"composer/composer": "^1.0.2",
|
||||
"symfony/phpunit-bridge": "^3.2.8"
|
||||
},
|
||||
"type": "composer-plugin",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
},
|
||||
"class": "Symfony\\Flex\\Flex"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Flex\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien.potencier@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Composer plugin for Symfony",
|
||||
"time": "2018-09-03T08:17:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-foundation.git",
|
||||
"reference": "3a5c91e133b220bb882b3cd773ba91bf39989345"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/3a5c91e133b220bb882b3cd773ba91bf39989345",
|
||||
"reference": "3a5c91e133b220bb882b3cd773ba91bf39989345",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/polyfill-mbstring": "~1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"predis/predis": "~1.0",
|
||||
"symfony/expression-language": "~3.4|~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\HttpFoundation\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony HttpFoundation Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-08-27T17:47:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-kernel",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-kernel.git",
|
||||
"reference": "33de0a1ff2e1720096189e3ced682d7a4e8f5e35"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/33de0a1ff2e1720096189e3ced682d7a4e8f5e35",
|
||||
"reference": "33de0a1ff2e1720096189e3ced682d7a4e8f5e35",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/debug": "~3.4|~4.0",
|
||||
"symfony/event-dispatcher": "~4.1",
|
||||
"symfony/http-foundation": "^4.1.1",
|
||||
"symfony/polyfill-ctype": "~1.8"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<3.4",
|
||||
"symfony/dependency-injection": "<4.1",
|
||||
"symfony/var-dumper": "<4.1.1",
|
||||
"twig/twig": "<1.34|<2.4,>=2"
|
||||
},
|
||||
"provide": {
|
||||
"psr/log-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/cache": "~1.0",
|
||||
"symfony/browser-kit": "~3.4|~4.0",
|
||||
"symfony/config": "~3.4|~4.0",
|
||||
"symfony/console": "~3.4|~4.0",
|
||||
"symfony/css-selector": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "^4.1",
|
||||
"symfony/dom-crawler": "~3.4|~4.0",
|
||||
"symfony/expression-language": "~3.4|~4.0",
|
||||
"symfony/finder": "~3.4|~4.0",
|
||||
"symfony/process": "~3.4|~4.0",
|
||||
"symfony/routing": "~3.4|~4.0",
|
||||
"symfony/stopwatch": "~3.4|~4.0",
|
||||
"symfony/templating": "~3.4|~4.0",
|
||||
"symfony/translation": "~3.4|~4.0",
|
||||
"symfony/var-dumper": "^4.1.1"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/browser-kit": "",
|
||||
"symfony/config": "",
|
||||
"symfony/console": "",
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/var-dumper": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\HttpKernel\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony HttpKernel Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-08-28T06:17:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
"version": "v1.9.0",
|
||||
@@ -165,6 +705,173 @@
|
||||
],
|
||||
"time": "2018-08-06T14:22:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/routing",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/routing.git",
|
||||
"reference": "a5784c2ec4168018c87b38f0e4f39d2278499f51"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/routing/zipball/a5784c2ec4168018c87b38f0e4f39d2278499f51",
|
||||
"reference": "a5784c2ec4168018c87b38f0e4f39d2278499f51",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<3.4",
|
||||
"symfony/dependency-injection": "<3.4",
|
||||
"symfony/yaml": "<3.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/annotations": "~1.0",
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/expression-language": "~3.4|~4.0",
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/yaml": "~3.4|~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"doctrine/annotations": "For using the annotation loader",
|
||||
"symfony/config": "For using the all-in-one router or any loader",
|
||||
"symfony/dependency-injection": "For loading routes from a service",
|
||||
"symfony/expression-language": "For using expression matching",
|
||||
"symfony/http-foundation": "For using a Symfony Request object",
|
||||
"symfony/yaml": "For using the YAML loader"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Routing\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Routing Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"router",
|
||||
"routing",
|
||||
"uri",
|
||||
"url"
|
||||
],
|
||||
"time": "2018-08-03T07:58:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/twig-bridge",
|
||||
"version": "v4.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/twig-bridge.git",
|
||||
"reference": "550cd9cd3a106a3426bdb2bd9d2914a4937656d1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/twig-bridge/zipball/550cd9cd3a106a3426bdb2bd9d2914a4937656d1",
|
||||
"reference": "550cd9cd3a106a3426bdb2bd9d2914a4937656d1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"twig/twig": "^1.35|^2.4.4"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "<3.4",
|
||||
"symfony/form": "<4.1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/asset": "~3.4|~4.0",
|
||||
"symfony/console": "~3.4|~4.0",
|
||||
"symfony/dependency-injection": "~3.4|~4.0",
|
||||
"symfony/expression-language": "~3.4|~4.0",
|
||||
"symfony/finder": "~3.4|~4.0",
|
||||
"symfony/form": "^4.1.2",
|
||||
"symfony/http-foundation": "~3.4|~4.0",
|
||||
"symfony/http-kernel": "~3.4|~4.0",
|
||||
"symfony/polyfill-intl-icu": "~1.0",
|
||||
"symfony/routing": "~3.4|~4.0",
|
||||
"symfony/security": "~3.4|~4.0",
|
||||
"symfony/security-acl": "~2.8|~3.0",
|
||||
"symfony/stopwatch": "~3.4|~4.0",
|
||||
"symfony/templating": "~3.4|~4.0",
|
||||
"symfony/translation": "~3.4|~4.0",
|
||||
"symfony/var-dumper": "~3.4|~4.0",
|
||||
"symfony/web-link": "~3.4|~4.0",
|
||||
"symfony/workflow": "~3.4|~4.0",
|
||||
"symfony/yaml": "~3.4|~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/asset": "For using the AssetExtension",
|
||||
"symfony/expression-language": "For using the ExpressionExtension",
|
||||
"symfony/finder": "",
|
||||
"symfony/form": "For using the FormExtension",
|
||||
"symfony/http-kernel": "For using the HttpKernelExtension",
|
||||
"symfony/routing": "For using the RoutingExtension",
|
||||
"symfony/security": "For using the SecurityExtension",
|
||||
"symfony/stopwatch": "For using the StopwatchExtension",
|
||||
"symfony/templating": "For using the TwigEngine",
|
||||
"symfony/translation": "For using the TranslationExtension",
|
||||
"symfony/var-dumper": "For using the DumpExtension",
|
||||
"symfony/web-link": "For using the WebLinkExtension",
|
||||
"symfony/yaml": "For using the YamlExtension"
|
||||
},
|
||||
"type": "symfony-bridge",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Bridge\\Twig\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Twig Bridge",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2018-08-14T15:48:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v2.5.0",
|
||||
|
||||
3
Source/config/packages/dev/routing.yaml
Normal file
3
Source/config/packages/dev/routing.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
3
Source/config/packages/routing.yaml
Normal file
3
Source/config/packages/routing.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: ~
|
||||
3
Source/config/packages/test/routing.yaml
Normal file
3
Source/config/packages/test/routing.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
3
Source/config/routes.yaml
Normal file
3
Source/config/routes.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
#index:
|
||||
# path: /
|
||||
# controller: App\Controller\DefaultController::index
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/src/app.php';
|
||||
|
||||
run();
|
||||
|
||||
$filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
|
||||
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
|
||||
return false;
|
||||
}
|
||||
require_once __DIR__ . '/src/app.php';
|
||||
|
||||
$app->run();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Config
|
||||
*/
|
||||
public static function init(){
|
||||
if(!Config::initialized()) {
|
||||
$file = file_get_contents("data/project.json");
|
||||
$file = file_get_contents(__DIR__."/../data/project.json");
|
||||
Config::$config = json_decode($file, true);
|
||||
Config::$in=true;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class DB
|
||||
*/
|
||||
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')";
|
||||
$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')";
|
||||
$code = dbw_query($this->conn, $query);
|
||||
return $code;
|
||||
}
|
||||
@@ -286,7 +286,8 @@ class DB
|
||||
$version++;
|
||||
$modification = time();
|
||||
|
||||
$query = "INSERT INTO Sources (`IDC`,`Lang`,`Version`,`Modification`,`Code`,`UseExtLib`,`UseExtLibVer`,`IDU`) VALUES ('$IDC','$lang',$version,$modification,'$code','$lib','$libV','$IDU')";
|
||||
|
||||
$query = "INSERT INTO Sources (`IDC`,`Lang`,`Version`,`Modification`,`Code`,`UseExtLib`,`UseExtLibVer`,`IDU`) VALUES ('$IDC','$lang',$version,$modification,'$code','$lib','$libV','$IDU')";
|
||||
//echo $query . ';';
|
||||
dbw_query($this->conn, $query);
|
||||
return $version;
|
||||
@@ -324,8 +325,8 @@ class DB
|
||||
$arr = $this->loadAll($IDC, $lang, $this->getLastVersion($IDC, $lang));
|
||||
$codewrite = $arr["Code"];
|
||||
$version = 0;
|
||||
if ($code != $codewrite) {
|
||||
$version = $this->addSource($IDC, $lang, $_code, $IDU, $extlib, $extlibver);
|
||||
if ($_code != dbw_escape_string($this->conn,$codewrite)) {
|
||||
$version = $this->addSource($IDC, $lang, $_code, $IDU, $extlib, $extlibver,$codewrite);
|
||||
} else if ($extlib != $arr["UseExtLib"] || $extlibver != $arr["UseExtLibVer"]) {
|
||||
|
||||
$query = "UPDATE Sources SET `UseExtLib`='$extlib', `UseExtLibVer`='$extlibver' WHERE IDC=$IDC AND Lang='$arr[Lang]' AND Version=$arr[Version]";
|
||||
|
||||
@@ -3,8 +3,8 @@ if(isset($_COOKIE['cookieconsent_status'])) {
|
||||
session_start(); //Start session in app, before loading vars ($_SESSION)
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
//require_once __DIR__ . '/dbwrapper.php';
|
||||
require_once __DIR__ .'/../vendor/autoload.php';
|
||||
|
||||
require_once __DIR__ . '/Config.php';
|
||||
require 'functions.php';
|
||||
require 'DB.php';
|
||||
@@ -12,370 +12,97 @@ require 'dbToTable.php';
|
||||
require 'users.php';
|
||||
|
||||
|
||||
$path = array(
|
||||
"html" => "assets/html/",
|
||||
"css" => "assets/css/",
|
||||
"js" => "assets/js/",
|
||||
"img" => "assets/img/",
|
||||
);
|
||||
$app = new Silex\Application();
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
$app['debug'] = true;
|
||||
$app->register(new Silex\Provider\TwigServiceProvider(), array(
|
||||
'twig.path' => __DIR__.'/../',
|
||||
));
|
||||
|
||||
|
||||
$app['url'] = '/';
|
||||
|
||||
$app['front'] = $app['url'] . 'assets';
|
||||
$valores = array('js', 'img', 'css', 'fonts', 'html');
|
||||
foreach($valores as $asset){
|
||||
$app['front'.$asset] = $app['front'].'/'.$asset;
|
||||
}
|
||||
|
||||
$string = file_get_contents(__DIR__."/../data/supported.json");
|
||||
$supported = json_decode($string, true);
|
||||
$loader = new Twig_Loader_Filesystem($path['html']);
|
||||
$twig = new Twig_Environment($loader);
|
||||
$user = array();
|
||||
$db=null;
|
||||
$app["supported"] = json_decode($string, true);
|
||||
|
||||
$app['db']=null;
|
||||
try {
|
||||
$db = new DB();
|
||||
$app['db'] = new DB();
|
||||
}catch (Exception $ex){
|
||||
sendHTTPError(503);
|
||||
exit();
|
||||
}
|
||||
|
||||
function run(){
|
||||
global $user;
|
||||
if(isset($_SESSION['sessionID'])){
|
||||
global $db;
|
||||
if($db->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
|
||||
$user = $db->loadProfile($_SESSION['sessionID']);
|
||||
}
|
||||
}
|
||||
if (isset($_POST["search"])){
|
||||
firstPage(false,true);
|
||||
}
|
||||
else if ($_GET) {
|
||||
if ($_GET["page"]) {
|
||||
switch ($_GET["page"]) {
|
||||
case "code":
|
||||
codeViewer();
|
||||
break;
|
||||
case "index":
|
||||
firstPage();
|
||||
break;
|
||||
case "register":
|
||||
case "login":
|
||||
loginRegister($_GET['page']);
|
||||
break;
|
||||
case "logout":
|
||||
logout();
|
||||
header("Location: index.php");
|
||||
break;
|
||||
case "about":
|
||||
about();
|
||||
break;
|
||||
case "add":
|
||||
add();
|
||||
break;
|
||||
case "doc":
|
||||
doc();
|
||||
break;
|
||||
case "tos":
|
||||
tos();
|
||||
break;
|
||||
case "user":
|
||||
user();
|
||||
break;
|
||||
case "error":
|
||||
sendHTTPError($_GET['error']);
|
||||
/*case "del":
|
||||
deleteSource();*/
|
||||
break;
|
||||
default:
|
||||
sendHTTPError(404);
|
||||
}
|
||||
} else {
|
||||
sendHTTPError(404);
|
||||
}
|
||||
} else {
|
||||
//header("CodeShare");
|
||||
firstPage();
|
||||
}
|
||||
}
|
||||
$app->boot();
|
||||
|
||||
function sendHTTPError($code){
|
||||
global $twig, $path,$user;
|
||||
$page = array("title" => $code."");
|
||||
/* Basics */
|
||||
$app->get('/', function (Request $request) use($app) {
|
||||
|
||||
header($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;
|
||||
}
|
||||
|
||||
$error = array("number" => $code."","text"=>$text);
|
||||
echo $twig->render('error.twig',array("page" => $page, "path" => $path, "user" => $user,"error" => $error));
|
||||
}
|
||||
$query = $app['db']->loadLast();
|
||||
$last = lastToArray($app["db"],$query,$app['supported']);
|
||||
|
||||
/**
|
||||
* Index page
|
||||
*
|
||||
* @param bool $filter if filters are enabled (when ajax)
|
||||
* @param bool $globalSearch if filters are in nav-bar search box
|
||||
*/
|
||||
function firstPage($filter=false,$globalSearch=false){
|
||||
global $supported,$twig,$path,$user;
|
||||
global $db;
|
||||
//var_dump($_POST);
|
||||
if(!$filter and !$globalSearch) //Common index
|
||||
if(isset($_GET["p"])) //If page (not 0)
|
||||
$query = $db->loadLast($_GET["p"]);
|
||||
else
|
||||
$query = $db->loadLast();
|
||||
else
|
||||
$query = $db->loadFilter($_POST,$globalSearch);
|
||||
$last = lastToArray($db,$query,$supported);
|
||||
$page = array(
|
||||
"title" => "CodeShare",
|
||||
"description" => "Sharing your solution with all",
|
||||
"last" => $last,
|
||||
"supported" => $supported,
|
||||
"page" => "home",
|
||||
"grouped" => groupByCategory($supported)
|
||||
);
|
||||
if(!$filter)
|
||||
echo $twig->render("firstpage.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
else
|
||||
echo $twig->render("firstCodes.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
$db->close();
|
||||
}
|
||||
return $app['twig']->render($app['fronthtml'] . '/firstpage.twig' ,array(
|
||||
'page' => array('title' => "CodeShare",
|
||||
"description" => "Sharing your solutions with all",
|
||||
"last" => $last,
|
||||
"supported" => $app["supported"],
|
||||
"page" => "home",
|
||||
"grouped" => groupByCategory($app["supported"]))
|
||||
));
|
||||
})->bind('home');
|
||||
|
||||
function doc(){
|
||||
global $twig,$path,$user;
|
||||
$app->get('/doc', function (Request $request) use($app){
|
||||
$page = array(
|
||||
"title" => "Documentation",
|
||||
"description" => "All documentation about how to upload code in CodeShare",
|
||||
"page" => "doc"
|
||||
);
|
||||
echo $twig->render("doc.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
}
|
||||
return $app['twig']->render($app['fronthtml'].'/doc.twig', array("page" => $page));
|
||||
})->bind('doc');
|
||||
|
||||
function add(){
|
||||
global $twig,$path,$user,$supported;
|
||||
if(!isset($user['IDU'])){
|
||||
header("Location: ?page=login");
|
||||
}
|
||||
if(isset($_POST['name'])){
|
||||
$db=new DB();
|
||||
$extlib = isset($_POST['extlib']) ? $_POST['extlib'] : null;
|
||||
$extlibver = isset($_POST['extlibver']) ? $_POST['extlibver'] : null;
|
||||
$db->addOrModifyCodes(
|
||||
0,
|
||||
$_POST['name'],
|
||||
$_POST['description'],
|
||||
htmlentities($_POST['input']),
|
||||
htmlentities($_POST['output']),
|
||||
$_POST['lang'],
|
||||
htmlentities($_POST['code']),
|
||||
$user['IDU'],
|
||||
$extlib,
|
||||
$extlibver);
|
||||
//die();
|
||||
$idc=$db->getLastIDC();
|
||||
header("Location: ?page=code&id=$idc&lang=$_POST[lang]&version=1");
|
||||
}
|
||||
$page=array(
|
||||
"title" => "Add your own solution",
|
||||
"description" => "Share now your snippet",
|
||||
"page" => "add",
|
||||
);
|
||||
echo $twig->render("add.twig",array("page" => $page,"path" => $path, "user" => $user, "supported" => $supported));
|
||||
|
||||
}
|
||||
|
||||
function codeViewer(){
|
||||
global $supported,$twig,$path,$user;
|
||||
global $db;
|
||||
|
||||
if(isset($_POST['lang'])){
|
||||
$db->addSource($_GET['id'],$_POST['lang'],htmlentities($_POST['code']),$user["IDU"]);
|
||||
$db->close();
|
||||
header("Location: ?page=code&id=$_GET[id]&lang=$_POST[lang]&version=1");
|
||||
}else if(isset($_POST['name'])){
|
||||
$extlib = isset($_POST['extlib']) ? $_POST['extlib'] : null;
|
||||
$extlibver = isset($_POST['extlibver']) ? $_POST['extlibver'] : null;
|
||||
$version=$db->addOrModifyCodes(
|
||||
$_GET['id'],
|
||||
$_POST['name'],
|
||||
$_POST['description'],
|
||||
htmlentities($_POST['input']),
|
||||
htmlentities($_POST['output']),
|
||||
$_GET['lang'],
|
||||
htmlentities($_POST['code']),
|
||||
$user['IDU'],
|
||||
$extlib,
|
||||
$extlibver);
|
||||
//die();
|
||||
$db->close();
|
||||
if($version!=0){
|
||||
header("Location: ?page=code&id=$_GET[id]&lang=$_GET[lang]&version=$version");
|
||||
}else{
|
||||
header('Refresh:0');
|
||||
}
|
||||
}else if(isset($_POST['code'])){
|
||||
$version=$db->addSource($_GET['id'],$_GET['lang'],htmlentities($_POST['code']),$user['IDU'],$_POST['extlib'],$_POST['extlibver']);
|
||||
$db->close();
|
||||
header("Location: ?page=code&id=$_GET[id]&lang=$_GET[lang]&version=$version");
|
||||
}
|
||||
|
||||
if (!$_GET['lang'] || !$_GET['id']) {
|
||||
sendHTTPError(404);
|
||||
}elseif($_GET['version']){
|
||||
$array = $db->loadAll($_GET['id'],$_GET['lang'],$_GET['version']);
|
||||
if($array){
|
||||
$page = array(
|
||||
"title" => "$array[Name] by $array[nick]",
|
||||
"description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']][0],
|
||||
"otherV" => false,
|
||||
"otherI" => false,
|
||||
"existedLangs" => $db->loadLangs($_GET['id']),
|
||||
"original" => $db->loadOriginalAuthor($_GET['id']),
|
||||
);
|
||||
$code = allCodeToArray($array,$supported);
|
||||
if($array['Version']!=1){
|
||||
$page['otherV'] = true;
|
||||
}
|
||||
$diff = $db->loadDiff($_GET["id"],$_GET["lang"]);
|
||||
if (dbw_fetch_array($db->conn, $diff)) {
|
||||
$page['otherI'] = true;
|
||||
}
|
||||
dbw_query_goto($db->conn,$diff);
|
||||
$otherImplementation = otherImplementationToArray($db,$diff,$supported);
|
||||
echo $twig->render("code.twig", array(
|
||||
"page" => $page,
|
||||
"code" => $code,
|
||||
"otherImplementation" => $otherImplementation,
|
||||
"path" => $path,
|
||||
"user" => $user,
|
||||
"supported" => $supported,
|
||||
));
|
||||
}else{
|
||||
sendHTTPError(404);
|
||||
}
|
||||
}else{
|
||||
$query = $db->loadOtherVersion($_GET['id'], $_GET['lang']);
|
||||
$other = otherVersionToArray($db,$query,$supported);
|
||||
$name = $other[0]['name'];
|
||||
$page = array(
|
||||
"title" => "Other versions of $name",
|
||||
"description" => "All differents version of $name uploaded in CodeShare",
|
||||
"last" => $other,
|
||||
"page" => ""
|
||||
);
|
||||
echo $twig->render("otherVersion.twig",array(
|
||||
"page" => $page,
|
||||
"path" => $path,
|
||||
"user" => $user
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function loginRegister($default){
|
||||
global $twig,$path;
|
||||
|
||||
$bool=false;
|
||||
|
||||
$page = array(
|
||||
"title" => ucfirst($default),
|
||||
"description" => "Start now in CodeShare",
|
||||
"page" => $default,
|
||||
"state" => 0, //0=no logged, 1 login fail, 2 register fail, 3 all correct (render home)
|
||||
);
|
||||
|
||||
if(array_key_exists('email',$_POST) or array_key_exists('emailre',$_POST)){
|
||||
if($_POST["email"]){
|
||||
$bool=checklogin($_POST['email'],$_POST['pwd']);
|
||||
if(!$bool){
|
||||
$page['state']=1;
|
||||
}
|
||||
}else{
|
||||
$bool=register($_POST["emailre"],$_POST["pwdre"],$_POST["name"]);
|
||||
if(!$bool){
|
||||
$page['state']=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($bool) {
|
||||
header("Location: index.php");
|
||||
}else
|
||||
echo $twig->render("loginregister.twig", array("page" => $page, "path" => $path ));
|
||||
}
|
||||
|
||||
function about(){
|
||||
global $twig, $path, $user;
|
||||
$app->get('/about', function (Request $request) use($app){
|
||||
$page = array(
|
||||
"title" => "About CodeShare",
|
||||
"description" => "Developed by JKA Network's Team",
|
||||
"page" => "about",
|
||||
);
|
||||
echo $twig->render("about.twig",array("page" => $page, "path" => $path,"user" => $user));
|
||||
}
|
||||
return $app['twig']->render($app['fronthtml'].'/about.twig', array("page" => $page));
|
||||
})->bind('about');
|
||||
|
||||
function tos(){
|
||||
global $twig, $path, $user;
|
||||
/* Codes */
|
||||
$app->get('/code/{idc}/{lang}/{version}', function (Request $request, $idc, $lang, $version) use($app){
|
||||
|
||||
$array = $app['db']->loadAll($idc,$lang,$version);
|
||||
$page = array(
|
||||
"title" => "Terms of service",
|
||||
"description" => "Terms of services and privacy policies"
|
||||
"page" => 'code',
|
||||
"title" => "$array[Name] by $array[nick]",
|
||||
"description" => "$array[Name] by $array[nick] in ".$app['supported'][$lang][0],
|
||||
"otherV" => false,
|
||||
"otherI" => false,
|
||||
"existedLangs" => $app['db']->loadLangs($idc),
|
||||
"original" => $app['db']->loadOriginalAuthor($idc),
|
||||
);
|
||||
echo $twig->render("TOS.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
}
|
||||
|
||||
function user(){
|
||||
global $twig,$path,$user;
|
||||
|
||||
if($user['nick']) {
|
||||
$status=0;
|
||||
if(array_key_exists("passact",$_POST)){
|
||||
$passact = $_POST["passact"];
|
||||
$newpass = $_POST["newpass"];
|
||||
//echo "EEEEEOOO";
|
||||
global $db;
|
||||
if($db->checkPass($user['email'],$passact)){
|
||||
$status=1;
|
||||
$db->updatePass($user['IDU'],$newpass);
|
||||
}else
|
||||
$status=2;
|
||||
$db->close();
|
||||
}
|
||||
$page = array(
|
||||
"title" => "$user[nick]",
|
||||
"description" => "NOT RELEVANT",
|
||||
"status" => $status
|
||||
);
|
||||
echo $twig->render("user.twig",array("page"=>$page,"path"=>$path, "user"=>$user));
|
||||
}else{
|
||||
sendHTTPError(403);
|
||||
$code = allCodeToArray($array,$app['supported']);
|
||||
if($array['Version']!=1)
|
||||
$page['otherV'] = true;
|
||||
$diff = $app['db']->loadDiff($idc,$lang);
|
||||
if(dbw_fetch_array($app['db']->conn,$diff)){
|
||||
$page['otherI'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*function deleteSource(){
|
||||
global $user;
|
||||
if(array_key_exists('ROLE',$user)){
|
||||
if($user['ROLE']==3){
|
||||
$db = new DB();
|
||||
$db->deleteSource($_GET['id'],$_GET['lang'],$_GET['version']);
|
||||
$db->close();
|
||||
header('Location: index.php');
|
||||
}else
|
||||
sendHTTPError(403);
|
||||
}else{
|
||||
sendHTTPError(403);
|
||||
}
|
||||
}*/
|
||||
dbw_query_goto($app['db']->conn,$diff);
|
||||
$otherImplementation = otherImplementationToArray($app['db'],$diff,$app['supported']);
|
||||
return $app['twig']->render($app['fronthtml'].'/code.twig', array(
|
||||
"page" => $page,
|
||||
"code" => $code,
|
||||
"otherImplementation" => $otherImplementation,
|
||||
"supported" => $app['supported'],
|
||||
));
|
||||
})->bind('code');
|
||||
382
Source/src/appOld.php
Normal file
382
Source/src/appOld.php
Normal file
@@ -0,0 +1,382 @@
|
||||
<?php
|
||||
if(isset($_COOKIE['cookieconsent_status'])) {
|
||||
session_start(); //Start session in app, before loading vars ($_SESSION)
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
//require_once __DIR__ . '/dbwrapper.php';
|
||||
require_once __DIR__ . '/Config.php';
|
||||
require 'functions.php';
|
||||
require 'DB.php';
|
||||
require 'dbToTable.php';
|
||||
require 'users.php';
|
||||
|
||||
|
||||
$path = array(
|
||||
"html" => "assets/html/",
|
||||
"css" => "assets/css/",
|
||||
"js" => "assets/js/",
|
||||
"img" => "assets/img/",
|
||||
);
|
||||
$string = file_get_contents(__DIR__."/../data/supported.json");
|
||||
$supported = json_decode($string, true);
|
||||
$loader = new Twig_Loader_Filesystem($path['html']);
|
||||
$twig = new Twig_Environment($loader);
|
||||
$user = array();
|
||||
$db=null;
|
||||
try {
|
||||
$db = new DB();
|
||||
}catch (Exception $ex){
|
||||
sendHTTPError(503);
|
||||
exit();
|
||||
}
|
||||
|
||||
function run(){
|
||||
global $user;
|
||||
if(isset($_SESSION['sessionID'])){
|
||||
global $db;
|
||||
if($db->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
|
||||
$user = $db->loadProfile($_SESSION['sessionID']);
|
||||
}
|
||||
}
|
||||
if (isset($_POST["search"])){
|
||||
firstPage(false,true);
|
||||
}
|
||||
else if ($_GET) {
|
||||
if ($_GET["page"]) {
|
||||
switch ($_GET["page"]) {
|
||||
case "code":
|
||||
codeViewer();
|
||||
break;
|
||||
case "index":
|
||||
firstPage();
|
||||
break;
|
||||
case "register":
|
||||
case "login":
|
||||
loginRegister($_GET['page']);
|
||||
break;
|
||||
case "logout":
|
||||
logout();
|
||||
header("Location: index.php");
|
||||
break;
|
||||
case "about":
|
||||
about();
|
||||
break;
|
||||
case "add":
|
||||
add();
|
||||
break;
|
||||
case "doc":
|
||||
doc();
|
||||
break;
|
||||
case "tos":
|
||||
tos();
|
||||
break;
|
||||
case "user":
|
||||
user();
|
||||
break;
|
||||
case "error":
|
||||
sendHTTPError($_GET['error']);
|
||||
/*case "del":
|
||||
deleteSource();*/
|
||||
break;
|
||||
default:
|
||||
sendHTTPError(404);
|
||||
}
|
||||
} else {
|
||||
sendHTTPError(404);
|
||||
}
|
||||
} else {
|
||||
//header("CodeShare");
|
||||
firstPage();
|
||||
}
|
||||
}
|
||||
|
||||
function sendHTTPError($code){
|
||||
global $twig, $path,$user;
|
||||
$page = array("title" => $code."");
|
||||
|
||||
header($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;
|
||||
}
|
||||
|
||||
$error = array("number" => $code."","text"=>$text);
|
||||
echo $twig->render('error.twig',array("page" => $page, "path" => $path, "user" => $user,"error" => $error));
|
||||
}
|
||||
|
||||
/**
|
||||
* Index page
|
||||
*
|
||||
* @param bool $filter if filters are enabled (when ajax)
|
||||
* @param bool $globalSearch if filters are in nav-bar search box
|
||||
*/
|
||||
function firstPage($filter=false,$globalSearch=false){
|
||||
global $supported,$twig,$path,$user;
|
||||
global $db;
|
||||
//var_dump($_POST);
|
||||
if(!$filter and !$globalSearch) //Common index
|
||||
if(isset($_GET["p"])) //If page (not 0)
|
||||
$query = $db->loadLast($_GET["p"]);
|
||||
else
|
||||
$query = $db->loadLast();
|
||||
else
|
||||
$query = $db->loadFilter($_POST,$globalSearch);
|
||||
$last = lastToArray($db,$query,$supported);
|
||||
$page = array(
|
||||
"title" => "CodeShare",
|
||||
"description" => "Sharing your solution with all",
|
||||
"last" => $last,
|
||||
"supported" => $supported,
|
||||
"page" => "home",
|
||||
"grouped" => groupByCategory($supported)
|
||||
);
|
||||
if(!$filter)
|
||||
echo $twig->render("firstpage.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
else
|
||||
echo $twig->render("firstCodes.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
$db->close();
|
||||
}
|
||||
|
||||
function doc(){
|
||||
global $twig,$path,$user;
|
||||
$page = array(
|
||||
"title" => "Documentation",
|
||||
"description" => "All documentation about how to upload code in CodeShare",
|
||||
"page" => "doc"
|
||||
);
|
||||
echo $twig->render("doc.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
}
|
||||
|
||||
function add(){
|
||||
global $twig,$path,$user,$supported;
|
||||
if(!isset($user['IDU'])){
|
||||
header("Location: ?page=login");
|
||||
}
|
||||
if(isset($_POST['name'])){
|
||||
$db=new DB();
|
||||
$extlib = isset($_POST['extlib']) ? $_POST['extlib'] : null;
|
||||
$extlibver = isset($_POST['extlibver']) ? $_POST['extlibver'] : null;
|
||||
$db->addOrModifyCodes(
|
||||
0,
|
||||
$_POST['name'],
|
||||
$_POST['description'],
|
||||
htmlentities($_POST['input']),
|
||||
htmlentities($_POST['output']),
|
||||
$_POST['lang'],
|
||||
htmlentities($_POST['code']),
|
||||
$user['IDU'],
|
||||
$extlib,
|
||||
$extlibver);
|
||||
//die();
|
||||
$idc=$db->getLastIDC();
|
||||
header("Location: ?page=code&id=$idc&lang=$_POST[lang]&version=1");
|
||||
}
|
||||
$page=array(
|
||||
"title" => "Add your own solution",
|
||||
"description" => "Share now your snippet",
|
||||
"page" => "add",
|
||||
);
|
||||
echo $twig->render("add.twig",array("page" => $page,"path" => $path, "user" => $user, "supported" => $supported));
|
||||
|
||||
}
|
||||
|
||||
function codeViewer(){
|
||||
global $supported,$twig,$path,$user;
|
||||
global $db;
|
||||
|
||||
if(isset($_POST['lang'])){
|
||||
$extlib = isset($_POST['extlib']) ? $_POST['extlib'] : null;
|
||||
$extlibver = isset($_POST['extlibver']) ? $_POST['extlibver'] : null;
|
||||
$db->addSource($_GET['id'],$_POST['lang'],htmlentities($_POST['code']),$user["IDU"],$extlib,$extlibver);
|
||||
$db->close();
|
||||
header("Location: ?page=code&id=$_GET[id]&lang=$_POST[lang]&version=1");
|
||||
}else if(isset($_POST['name'])){
|
||||
$extlib = isset($_POST['extlib']) ? $_POST['extlib'] : null;
|
||||
$extlibver = isset($_POST['extlibver']) ? $_POST['extlibver'] : null;
|
||||
$version=$db->addOrModifyCodes(
|
||||
$_GET['id'],
|
||||
$_POST['name'],
|
||||
$_POST['description'],
|
||||
htmlentities($_POST['input']),
|
||||
htmlentities($_POST['output']),
|
||||
$_GET['lang'],
|
||||
htmlentities($_POST['code']),
|
||||
$user['IDU'],
|
||||
$extlib,
|
||||
$extlibver);
|
||||
//die();
|
||||
$db->close();
|
||||
if($version!=0){
|
||||
header("Location: ?page=code&id=$_GET[id]&lang=$_GET[lang]&version=$version");
|
||||
}else{
|
||||
header('Refresh:0');
|
||||
}
|
||||
}else if(isset($_POST['code'])){
|
||||
$version=$db->addSource($_GET['id'],$_GET['lang'],htmlentities($_POST['code']),$user['IDU'],$_POST['extlib'],$_POST['extlibver']);
|
||||
$db->close();
|
||||
header("Location: ?page=code&id=$_GET[id]&lang=$_GET[lang]&version=$version");
|
||||
}
|
||||
|
||||
if (!$_GET['lang'] || !$_GET['id']) {
|
||||
sendHTTPError(404);
|
||||
}elseif($_GET['version']){
|
||||
$array = $db->loadAll($_GET['id'],$_GET['lang'],$_GET['version']);
|
||||
if($array){
|
||||
$page = array(
|
||||
"title" => "$array[Name] by $array[nick]",
|
||||
"description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']][0],
|
||||
"otherV" => false,
|
||||
"otherI" => false,
|
||||
"existedLangs" => $db->loadLangs($_GET['id']),
|
||||
"original" => $db->loadOriginalAuthor($_GET['id']),
|
||||
);
|
||||
$code = allCodeToArray($array,$supported);
|
||||
if($array['Version']!=1){
|
||||
$page['otherV'] = true;
|
||||
}
|
||||
$diff = $db->loadDiff($_GET["id"],$_GET["lang"]);
|
||||
if (dbw_fetch_array($db->conn, $diff)) {
|
||||
$page['otherI'] = true;
|
||||
}
|
||||
dbw_query_goto($db->conn,$diff);
|
||||
$otherImplementation = otherImplementationToArray($db,$diff,$supported);
|
||||
echo $twig->render("code.twig", array(
|
||||
"page" => $page,
|
||||
"code" => $code,
|
||||
"otherImplementation" => $otherImplementation,
|
||||
"path" => $path,
|
||||
"user" => $user,
|
||||
"supported" => $supported,
|
||||
));
|
||||
}else{
|
||||
sendHTTPError(404);
|
||||
}
|
||||
}else{
|
||||
$query = $db->loadOtherVersion($_GET['id'], $_GET['lang']);
|
||||
$other = otherVersionToArray($db,$query,$supported);
|
||||
$name = $other[0]['name'];
|
||||
$page = array(
|
||||
"title" => "Other versions of $name",
|
||||
"description" => "All differents version of $name uploaded in CodeShare",
|
||||
"last" => $other,
|
||||
"page" => ""
|
||||
);
|
||||
echo $twig->render("otherVersion.twig",array(
|
||||
"page" => $page,
|
||||
"path" => $path,
|
||||
"user" => $user
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function loginRegister($default){
|
||||
global $twig,$path;
|
||||
|
||||
$bool=false;
|
||||
|
||||
$page = array(
|
||||
"title" => ucfirst($default),
|
||||
"description" => "Start now in CodeShare",
|
||||
"page" => $default,
|
||||
"state" => 0, //0=no logged, 1 login fail, 2 register fail, 3 all correct (render home)
|
||||
);
|
||||
|
||||
if(array_key_exists('email',$_POST) or array_key_exists('emailre',$_POST)){
|
||||
if($_POST["email"]){
|
||||
$bool=checklogin($_POST['email'],$_POST['pwd']);
|
||||
if(!$bool){
|
||||
$page['state']=1;
|
||||
}
|
||||
}else{
|
||||
$bool=register($_POST["emailre"],$_POST["pwdre"],$_POST["name"]);
|
||||
if(!$bool){
|
||||
$page['state']=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($bool) {
|
||||
header("Location: index.php");
|
||||
}else
|
||||
echo $twig->render("loginregister.twig", array("page" => $page, "path" => $path ));
|
||||
}
|
||||
|
||||
function about(){
|
||||
global $twig, $path, $user;
|
||||
$page = array(
|
||||
"title" => "About CodeShare",
|
||||
"description" => "Developed by JKA Network's Team",
|
||||
"page" => "about",
|
||||
);
|
||||
echo $twig->render("about.twig",array("page" => $page, "path" => $path,"user" => $user));
|
||||
}
|
||||
|
||||
function tos(){
|
||||
global $twig, $path, $user;
|
||||
$page = array(
|
||||
"title" => "Terms of service",
|
||||
"description" => "Terms of services and privacy policies"
|
||||
);
|
||||
echo $twig->render("TOS.twig",array("page" => $page, "path" => $path, "user" => $user));
|
||||
}
|
||||
|
||||
function user(){
|
||||
global $twig,$path,$user;
|
||||
|
||||
if($user['nick']) {
|
||||
$status=0;
|
||||
if(array_key_exists("passact",$_POST)){
|
||||
$passact = $_POST["passact"];
|
||||
$newpass = $_POST["newpass"];
|
||||
global $db;
|
||||
if($db->checkPass($user['email'],$passact)){
|
||||
$status=1;
|
||||
$db->updatePass($user['IDU'],$newpass);
|
||||
}else
|
||||
$status=2;
|
||||
$db->close();
|
||||
}
|
||||
$page = array(
|
||||
"title" => "$user[nick]",
|
||||
"description" => "NOT RELEVANT",
|
||||
"status" => $status
|
||||
);
|
||||
echo $twig->render("user.twig",array("page"=>$page,"path"=>$path, "user"=>$user));
|
||||
}else{
|
||||
sendHTTPError(403);
|
||||
}
|
||||
}
|
||||
|
||||
/*function deleteSource(){
|
||||
global $user;
|
||||
if(array_key_exists('ROLE',$user)){
|
||||
if($user['ROLE']==3){
|
||||
$db = new DB();
|
||||
$db->deleteSource($_GET['id'],$_GET['lang'],$_GET['version']);
|
||||
$db->close();
|
||||
header('Location: index.php');
|
||||
}else
|
||||
sendHTTPError(403);
|
||||
}else{
|
||||
sendHTTPError(403);
|
||||
}
|
||||
}*/
|
||||
@@ -11,7 +11,7 @@
|
||||
* Methods to get an array to send to twig
|
||||
*/
|
||||
|
||||
function lastToArray($db,&$query,&$supported){
|
||||
function lastToArray($db,&$query,$supported){
|
||||
$last = array();
|
||||
while($var = dbw_fetch_array($db->conn,$query)){
|
||||
$array = array
|
||||
@@ -29,7 +29,7 @@ function lastToArray($db,&$query,&$supported){
|
||||
return $last;
|
||||
}
|
||||
|
||||
function allCodeToArray(&$query,&$supported){
|
||||
function allCodeToArray(&$query,$supported){
|
||||
$code = array(
|
||||
"idc" => $query['IDC'],
|
||||
"lang" => $query['Lang'],
|
||||
@@ -50,7 +50,7 @@ function allCodeToArray(&$query,&$supported){
|
||||
|
||||
}
|
||||
|
||||
function otherImplementationToArray($db,&$query,&$supported){
|
||||
function otherImplementationToArray($db,&$query,$supported){
|
||||
$other = array();
|
||||
while($var = dbw_fetch_array($db->conn,$query)){
|
||||
$array = array
|
||||
|
||||
@@ -54,7 +54,7 @@ function ksonParse($path){
|
||||
/**
|
||||
* Group by $supported
|
||||
*/
|
||||
function groupByCategory(&$supported){
|
||||
function groupByCategory($supported){
|
||||
$grouped = Array();
|
||||
foreach($supported as $key => $val){
|
||||
if(!array_key_exists($val[1],$grouped)){
|
||||
|
||||
@@ -55,4 +55,14 @@ function register($email,$pass,$nick){
|
||||
*/
|
||||
function logout(){
|
||||
session_destroy(); //Logout
|
||||
}
|
||||
|
||||
function getUser($app){
|
||||
$user=null;
|
||||
if(isset($_SESSION['sessionID'])){
|
||||
if($app['db']->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
|
||||
$user = $db->loadProfile($_SESSION['sessionID']);
|
||||
}
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
Reference in New Issue
Block a user