80 Commits

Author SHA1 Message Date
JoseluCross
de64484707 HotFix: Captcha 2018-10-27 09:32:54 +02:00
JoseluCross
a4ff90636f HotFix: Error repaired 2018-10-26 17:19:17 +02:00
JoseluCross
f3401a900d HotFix: HTTP errors 2018-10-26 16:49:27 +02:00
JoseluCross
d55f3e70d7 Merge branch 'master' of ssh://gitlab.com/CodeSolutionsProject/CodeShare 2018-10-26 16:43:08 +02:00
JoseluCross
1ef6ae4b7a ReCaptcha #10 2018-10-26 16:42:47 +02:00
5977f157be Update .gitignore 2018-10-25 23:57:26 +00:00
5fba4f41ce Delete slnx.sqlite-journal 2018-10-25 23:57:00 +00:00
55bef8ce98 Delete slnx.sqlite 2018-10-25 23:56:52 +00:00
2e4b9b9697 Delete ROLES 2018-10-25 23:55:03 +00:00
José Luis Garrido Labrador
5c66845c28 HotFix: Decline allow 2018-10-24 12:36:07 +02:00
José Luis Garrido Labrador
db1858772b Improve cookies disable: TODO 2018-10-23 16:37:27 +02:00
José Luis Garrido Labrador
b948e70c80 HotFix: Submit code need extlib ver if extlib 2018-10-23 13:33:31 +02:00
JoseluCross
ed6f78e95a Hot: Improve nav and header 2018-10-22 18:29:23 +02:00
José Luis Garrido Labrador
dc67844988 HotFix: improve mobile css 2018-10-22 12:01:06 +02:00
José Luis Garrido Labrador
721113a8ad HotFix: mobile scroll down 2018-10-22 11:54:50 +02:00
José Luis Garrido Labrador
3c3f58040d HotFix: mobile scroll down 2018-10-22 11:52:22 +02:00
José Luis Garrido Labrador
9c361fa69e Update TOS and PP 2018-10-22 11:52:08 +02:00
José Luis Garrido Labrador
27d4db2a2d HotFix: Description only en code page 2018-10-21 23:01:15 +02:00
José Luis Garrido Labrador
584c2ae58f HotFix: Other version not works 2018-10-21 22:54:34 +02:00
José Luis Garrido Labrador
cf2882a0f7 Repair cookies link 2018-10-21 22:33:02 +02:00
bd6b65d996 Adding Google Analytics 2018-10-21 22:12:30 +02:00
José Luis Garrido Labrador
564886a112 users to Users 2018-10-21 21:48:58 +02:00
José Luis Garrido Labrador
3176e54044 Domails repair 2018-10-21 21:45:26 +02:00
José Luis Garrido Labrador
4cb7fb7296 Domails repair 2018-10-21 21:42:51 +02:00
José Luis Garrido Labrador
0b89d4ee91 Register not validate 2018-10-21 21:26:09 +02:00
José Luis Garrido Labrador
714c840ab5 Remove CLI Server 2018-10-21 20:58:58 +02:00
José Luis Garrido Labrador
83b5dc7fd1 Debug false 2018-10-21 20:52:16 +02:00
José Luis Garrido Labrador
8518d3983d Beta add 2018-10-21 20:50:17 +02:00
José Luis Garrido Labrador
d1353bd1cf #13 and #18 finished and PreReleased launch 2018-10-21 20:48:35 +02:00
JoseluCross
cb7a16984b Restore password, need senmail 2018-10-18 20:19:30 +02:00
JoseluCross
8e5d88cd3f Improve #18, start #5 2018-10-17 17:03:16 +02:00
JoseluCross
c116289e13 Improve ajax for dynamic load of snippets 2018-10-17 17:02:55 +02:00
JoseluCross
b57cf63426 Update jQuery and start #18 2018-10-17 17:02:07 +02:00
JoseluCross
000a9be9b7 Improve ReHightlight performance, add create tables and start to restore password system 2018-10-16 17:06:35 +02:00
JoseluCross
18f58c4be8 Infinite scroll fixed 2018-10-11 23:44:49 +02:00
JoseluCross
85365b4247 Infinite scroll 2018-10-11 23:28:36 +02:00
JoseluCross
fd3d1c79c3 LoadDiff correctly #16 2018-10-11 22:36:11 +02:00
JoseluCross
60a218c4ad Repair loadOriginalAuthor() and migrate JKA Network name to Code Solutions Project 2018-10-11 19:45:53 +02:00
José Luis Garrido Labrador
be6caf9702 DBal migration completed #6 and #4 repaired 2018-10-11 15:39:11 +02:00
José Luis Garrido Labrador
dffbaacfbd #4 Done 2018-10-03 10:38:17 +02:00
JoseluCross
7cb682c146 #15 finished 2018-10-01 23:27:01 +02:00
JoseluCross
40e0291517 #14 2018-10-01 16:47:43 +02:00
JoseluCross
e796883167 #5 finished 2018-10-01 16:05:19 +02:00
JoseluCross
94d28dc292 #5 Finished 2018-09-30 12:13:14 +02:00
JoseluCross
a465ac6199 Merge 2018-09-30 10:42:10 +02:00
JoseluCross
c7ede8cb6e MI update 2018-09-30 10:39:03 +02:00
José Luis Garrido Labrador
4164a8a548 Merge branch 'master' of gitlab.com:CodeSolutionsProject/CodeShare 2018-09-29 13:11:13 +02:00
José Luis Garrido Labrador
ea067d8f15 \#5, TODO: Add codes and add sources and versions 2018-09-29 13:10:47 +02:00
José Luis Garrido Labrador
e4f05c6edd #6, TODO: Add codes and add sources and versions 2018-09-29 13:06:59 +02:00
José Luis Garrido Labrador
54b7c70adc Migrating to Silex 2018-09-21 13:18:46 +02:00
José Luis Garrido Labrador
aaa9a83eb2 repair search 2018-09-17 11:38:06 +02:00
JoseluCross
d71a111fe9 Add languages, categorized them, add rechaptcha 2018-09-16 13:04:58 +02:00
José Luis Garrido Labrador
6d2466b5b1 TOS Update to RGPD 2018-05-24 16:08:29 +02:00
José Luis Garrido Labrador
826fe3df0b Composer updated and 503 error added 2018-05-16 16:00:03 +02:00
aa35d5ce3b This echo was problematic in production 2017-12-29 12:49:04 +00:00
José Luis Garrido Labrador
87161a4713 Repaired #1 2017-12-16 16:54:04 +01:00
11c5478d27 Change cookies to session, first pass 2017-12-14 11:06:02 +01:00
JoseluCross
d4c22194c7 pass by reference in dbToTable 2017-10-31 00:24:56 +01:00
JoseluCross
3b1911f015 Enable Qozu to test 2017-10-30 23:37:07 +01:00
JoseluCross
b3b477fd53 Double-click select add 2017-10-30 23:25:29 +01:00
José Luis Garrido Labrador
e25666648d Cozu 2017-10-27 09:30:56 +02:00
José Luis Garrido Labrador
196f9b044d Add cozu preview 2017-10-27 09:28:06 +02:00
José Luis Garrido Labrador
00f7248a5b missing ? (404) 2017-10-27 09:15:53 +02:00
José Luis Garrido Labrador
ced34acc04 https all sites 2017-10-27 09:13:46 +02:00
JoseluCross
192cd15c3d Repair multiquery 2017-10-13 20:55:01 +02:00
JoseluCross
5006c7dfda Add EU cookies law and improve TOS and about 2017-10-13 20:07:27 +02:00
JoseluCross
9b544784f3 changes 2017-10-12 01:39:15 +02:00
JoseluCross
7c97ee47f0 query to multiquery 2017-10-05 00:59:21 +02:00
JoseluCross
1259b23d51 changes 2017-10-04 21:34:47 +02:00
JoseluCross
5a78ff3408 Create tables now in correct order 2017-10-04 20:49:20 +02:00
JoseluCross
521513331b Repair complete (go back) 2017-10-04 19:57:39 +02:00
JoseluCross
efc4769ba5 Pruebas 2017-10-04 19:24:33 +02:00
JoseluCross
343762d494 changes 2017-10-04 19:18:11 +02:00
JoseluCross
a5f9c3dc8f to __DIR__ 2017-10-04 19:16:24 +02:00
JoseluCross
9e26201ff9 add lab 2017-10-04 18:12:30 +02:00
JoseluCross
d826a1deeb responsive 2017-10-01 22:19:31 +02:00
JoseluCross
9b89aef9c2 dbwrapper now in composer 2017-09-22 01:23:43 +02:00
0fca1adf77 Update README.md 2017-09-19 18:36:46 +00:00
JoseluCross
9dba9ce277 git pushMerge branch 'master' of
gitlab.com:CodeSolutionsProject/CodeShare
2017-09-18 20:34:16 +02:00
JoseluCross
af5383d6d9 Add new comments and comment all deletion system 2017-09-18 20:34:06 +02:00
57 changed files with 3589 additions and 1003 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ project.json
*.db *.db
.idea/ .idea/
*.sql *.sql
vendor/ vendor/
.vs

View File

@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright 2017 JKA Network Copyright 2017 Code Solutions Project
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
### CodeShare ### CodeShare
##### JKA Network ##### Code Solutions Project
FEATURES FEATURES
------------------- -------------------
@@ -8,6 +8,7 @@ FEATURES
* Supports 39 languages between general programming (Java, C ...), scripting (Perl, Bash), web design (HTML...,Twig...,Sass...), data serialization (JSON,YAML...) and more * Supports 39 languages between general programming (Java, C ...), scripting (Perl, Bash), web design (HTML...,Twig...,Sass...), data serialization (JSON,YAML...) and more
* Follows material design guidelines * Follows material design guidelines
* Use bootstrap 3 by Twitter * Use bootstrap 3 by Twitter
* Upload in [codeshare.jkanetwork.com](http://codeshare.jkanetwork.com)
External OpenSource External OpenSource
------------------ ------------------

View File

@@ -1,5 +0,0 @@
<?php
require_once __DIR__ . '/src/app.php';
sendHTTPError(401);

View File

@@ -1,5 +0,0 @@
<?php
require_once __DIR__ . '/src/app.php';
sendHTTPError(403);

View File

@@ -1,5 +0,0 @@
<?php
require_once __DIR__ . '/src/app.php';
sendHTTPError(404);

View File

@@ -1,5 +0,0 @@
<?php
require_once __DIR__ . '/src/app.php';
sendHTTPError(500);

View File

@@ -1,8 +0,0 @@
<?php
require_once __DIR__ . '/src/app.php';
firstPage(true);

View File

@@ -0,0 +1,26 @@
.myAlert-top{
position: fixed;
top: 5px;
left:2%;
width: 96%;
}
.myAlert-bottom{
position: fixed;
bottom: 5px;
left:2%;
width: 96%;
}
div.fullscreen {
position: absolute;
width:100%;
height:960px;
top: 0;
left: 0;
background-color: lightblue;
}
.alert{
display: none;
}

View File

@@ -37,6 +37,17 @@ p{
margin: 0; margin: 0;
} }
sup, sub {
vertical-align: baseline;
position: relative;
top: -0.4em;
}
sub {
top: 0.4em;
}
.navbar { .navbar {
min-height: 0px !important; min-height: 0px !important;
} }
@@ -54,6 +65,10 @@ p{
background-color: #b2dbfb !important background-color: #b2dbfb !important
} }
.loginMessage {
display: none;
}
.codebox{ .codebox{
margin-top: 2em; margin-top: 2em;
margin-bottom: 2em; margin-bottom: 2em;
@@ -76,13 +91,17 @@ p{
margin-bottom: 30px; margin-bottom: 30px;
} }
.codeFilterCheckBox, .codeFilterButton{ .codeFilterCheckBox, .codeFilterButton, .codeFilterTitle{
margin: 0.2em 0; margin: 0.2em 0;
padding: 0; padding: 0;
width: 100px; width: 100px;
float: left; float: left;
} }
.codeFilterTitle {
font-weight: bold;
}
.codeFilterSearch { .codeFilterSearch {
margin-top: 1em; margin-top: 1em;
} }
@@ -136,11 +155,16 @@ p{
transform: rotate(180deg); transform: rotate(180deg);
} }
#filterBlock{ .sub-depth{
border-radius: 5px;
box-shadow: inset 0px 0px 5px rgba(119, 119, 119, 0.205);
}
#filterBlock, .filterBlock{
align-content: center; align-content: center;
width: 90%; width: 90%;
margin-left: 7%; margin-left: 5%;
margin-right: 3%; margin-right: 5%;
} }
#user{ #user{
@@ -164,6 +188,16 @@ p{
animation: spin 2s linear infinite; animation: spin 2s linear infinite;
} }
@media (min-width: 992px) {
.nopadding {
padding: 0%;
}
}
.nomargin {
margin: 0%;
}
@keyframes spin { @keyframes spin {
0% { transform: rotate(0deg); } 0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }

145
Source/assets/css/qozu.css Normal file
View File

@@ -0,0 +1,145 @@
/* QOZU standard CSS for comments, JKANetwork
Version 1.0.1
If your custom CSS doesn't work right, plase check that version is the lastest
*/
/* Some "CSS reset" needed, overrides web styles for Qozu */
.QOZU input {
display:inline !important;
}
/* Change font here to have your custom font rendered */
.QOZU {
font-family: Arial, Helvetica, sans-serif !important;
text-align: left !important;
}
/* Text sizes */
.QOZU h2{
font-size: 24px;
}
.QOZU h3{
font-size: 22px;
}
.QOZU p {
font-size: 14px;
}
.QOZU a {
cursor:pointer;
}
p.QOZU_foot {
font-size: 12px;
}
/* Input width for name/email/userinfo */
.QOZU input {
width: 200px;
}
#QOZU_sendEmail {
width: initial;
}
/* Comment div CSS */
.QOZU_com{
font-size: 14px;
padding: 0.5em;
border-top: 1px dotted grey;
}
/* Link color in comments */
.QOZU_com a{
color: #2196f3;
}
/* Sizes in comments */
.QOZU_com h4 {
font-size: 16px;
margin: 0em;
margin-top: 0.25em;
color:black;
}
/* For text in the comment */
.QOZU_txt {
margin-left: 1em;
color:black;
}
.QOZU_txt p , .QOZU_txt a{
color: black;
}
.QOZU_opts, .QOZU_opts a {
font-size:12px;
color:#444444;
margin-left:0.1em;
}
.QOZU_writebox textarea {
border: 2px solid #908f8f;
border-radius: 1em;
width: 90%;
max-width: 600px;
height: 80px;
padding: 1em;
resize: none;
overflow: auto;
overflow-wrap: break-word;
}
.QOZU_ans {
margin-left: 2em;
}
/* This is for the tags of admins and mods */
.QOZU_com .specialUser{
display: inline-block;
padding: 2px 4px;
font-size: 12px;
font-weight: bold;
line-height: 14px;
color: #fff;
text-shadow: 0 -1px 0 rgba(0,0,0,0.25);
white-space: nowrap;
vertical-align: baseline;
background-color: #999;
}
/* Buttons, first standard CSS */
.QOZU .btn {
display: inline-block !important;
text-align: center;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
padding: 5px 12px;
font-size: 14px;
line-height: 1.42857143;
border-radius: 4px;
}
/* Buttons, custom colours for every button */
.QOZU .btn-ok {
color: #fff;
background-color: #428bca;
}
.QOZU .btn-cancel {
color: #fff;
background-color: #428bca;
}
.QOZU .btn-cancelpeq {
color: #fff;
background-color: #005f93;
}
/* Other standard things for using CSS */
.QOZU .grey{
color: grey;
}
.QOZU .italic {
font-style: italic;
}
/* DEBUG, remove this in custom CSS
.QOZU_debug:before{
content: 'DEBUG:';
}
.QOZU_debug {
font-style: italic;
font-size: 10px;
}
*/

View File

@@ -1,18 +1,145 @@
{% 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> <div class="col-lg-offset-2 col-md-offset-2 col-lg-8 col-md-8">
<h4 class="docheader top10">Definitions</h4> <h3 style="text-align: center" class="top10" id="tos">Terms of Service</h3>
<ul><li><p>Solution: Any code snippet and its enclosed information</p></li></ul> <p>
<h4 class="docheader top10">Privacy</h4> <strong>Last updated: (22/10/2018)</strong>
<p>All personal data bring to JKA Network in registration form are save under Spanish's law of data protection (LO 15/1999). </p>
You can claim your right through JKA Network email <a href="mailto:contacto@jkanetwork.com">contacto@jkanetwork.com</a> </p> <p>
<h4 class="docheader top10">About content upload to CodeShare</h4> Please read these Terms of Service ("Terms") carefully before using the CodeShare website (the "Service") operated by Code Solutions Project ("us", "we", or "our").
<p>All content which the user upload to CodeShare except his email, password or comments are ceded with their all rights to JKA Network and immediately JKA Network will prescind from with their rights on these putting them under the public domain<br> </p>
Only JKA Network can remove comment or solutions hosted in CodeShare</p> <p>
<h4 class="docheader top10">About user's account</h4> Your access to and use of the Service is conditioned on your acceptance of and compliance with these Terms. These Terms apply to all visitors, users and others who access or use the Service.
<p>The registered user in all moment can close their account but all data hosted in CodeShare will remain hosted. </p>
<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> <p><strong>By accessing or using the Service you agree to be bound by these Terms. If you disagree with any part of the terms then you may not access the Service.</strong></p>
<h4 class="top10">Definitions</h4>
<ul>
<li><p>Solution: Any code snippet and its enclosed information</p></li>
</ul>
<h4 class="top10">Termination</h4>
<p>
We may terminate or suspend access to our Service immediately, without prior notice or liability, for any reason whatsoever, including without limitation if you breach the Terms.
</p><p>
All provisions of the Terms which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability.
</p>
<h4 class="top10">About content upload to CodeShare</h4>
<p>Our Service allows you to post solutions.</p>
<p>All content which the user upload to CodeShare except his email, password or comments are ceded with their
all rights to Code Solutions Project and immediately Code Solutions Project will prescind from with their rights on these putting
them under the public domain<br>
Only Code Solutions Project can remove comment or solutions hosted in CodeShare</p>
<h4 class="top10">Changes</h4>
<p>We reserve the right, at our sole discretion, to modify or replace these Terms at any time.
If a revision is material we will try to provide at least 30 (change this) days' notice prior to
any new terms taking effect. What constitutes a material change will be determined at our sole discretion.</p>
{#PP#}
<h3 style="text-align: center" class="top10" id="pp">Privacy Policy</h3>
<p><strong>Last updated: (22/10/2018)</strong></p>
<p>
Please read these Privacy Policy ("PP") carefully before using the CodeShare website (the "Service") operated by Code Solutions Project ("us", "we", or "our").
</p>
<p>This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data.</p>
<p>We use your data to provide and improve the Service. By using the Service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, accessible from https://codeshare.jkanetwork.com</p>
<h4 class="top10">Information Collection and Use</h4>
<h5>Personal Data</h5>
<p>While using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data"). Personally identifiable information may include, but is not limited to:</p>
<ul>
<li>Email address</li><li>Cookies and Usage Data</li>
</ul>
<h5>Usage Data</h5>
<p>We may also collect information how the Service is accessed and used ("Usage Data"). This Usage Data may include information such as your computer's Internet Protocol address (e.g. IP address), browser type, browser version, the pages of our Service that you visit, the time and date of your visit, the time spent on those pages, unique device identifiers and other diagnostic data.</p>
<h4 class="top10">Use of Data</h4>
<p>Code Solutions Project uses the collected data for various purposes:</p>
<ul>
<li>To provide and maintain the Service</li>
<li>To notify you about changes to our Service</li>
<li>To allow you to participate in interactive features of our Service when you choose to do so</li>
<li>To provide customer care and support</li>
<li>To provide analysis or valuable information so that we can improve the Service</li>
<li>To monitor the usage of the Service</li>
<li>To detect, prevent and address technical issues</li>
</ul>
<h4 class="top10">Transfer Of Data</h4>
<p>Your information, including Personal Data, may be transferred to — and maintained on — computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ than those from your jurisdiction.</p>
<p>If you are located outside Spain and choose to provide information to us, please note that we transfer the data, including Personal Data, to Spain and process it there.</p>
<p>Your consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer.</p>
<p>Code Solutions Project will take all steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organization or a country unless there are adequate controls in place including the security of your data and other personal information.</p>
<h4 class="top10">About user's account</h4>
<p>You can close your account (Request it in <a href="mailto:contacto@jkanetwork.com">contacto@jkanetwork.com</a>)
but all solutions hosted by you in CodeShare will remain hosted.
<br>Code Solutions Project is reserved the right to ban the access to account of any user who engage <a
href="{{path('doc')}}#vandalism">vandalism</a></p>
<h4 class="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
block CodeShare cookies but you cannot log in because we cannot check if login was right.
<br>The differents cookies are:</p>
<table class="table table-striped table-hover" style="width: 50%">
<thead>
<tr class="active">
<th>Cookie name</th>
<th>Functions</th>
</tr>
</thead>
<tbody>
<tr class="active">
<td>PHPSESSID</td>
<td>Session identifier to server</td>
</tr>
<tr class="active">
<td>cookieconsent_status</td>
<td>Cookie alert visibility</td>
</tr>
<tr class="active">
<td>Google Analytics Cookies</td>
<td>Track your navigation on CodeShare</td>
</tr>
</tbody>
</table>
<h4 class="top10">Disclosure Of Data</h4>
<h5>Legal Requirements</h5>
<p>Code Solutions Project may disclose your Personal Data in the good faith belief that such action is necessary to:</p>
<ul>
<li>To comply with a legal obligation</li>
<li>To protect and defend the rights or property of Code Solutions Project</li>
<li>To prevent or investigate possible wrongdoing in connection with the Service</li>
<li>To protect the personal safety of users of the Service or the public</li>
<li>To protect against legal liability</li>
</ul>
<h4 class="top10">Security Of Data</h4>
<p>The security of your data is important to us, but remember that no method of transmission over the Internet, or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.</p>
<h4 class="top10">Service Providers</h4>
<p>We may employ third party companies and individuals to facilitate our Service ("Service Providers"), to provide the Service on our behalf, to perform Service-related services or to assist us in analyzing how our Service is used.</p>
<p>These third parties have access to your Personal Data only to perform these tasks on our behalf and are obligated not to disclose or use it for any other purpose.</p>
<h5>Analytics</h5>
<p>We may use third-party Service Providers to monitor and analyze the use of our Service.</p>
<ul>
<li>
<p><strong>Google Analytics</strong></p>
<p>Google Analytics is a web analytics service offered by Google that tracks and reports website traffic. Google uses the data collected to track and monitor the use of our Service. This data is shared with other Google services. Google may use the collected data to contextualize and personalize the ads of its own advertising network.</p>
<p>You can opt-out of having made your activity on the Service available to Google Analytics by installing the Google Analytics opt-out browser add-on. The add-on prevents the Google Analytics JavaScript (ga.js, analytics.js, and dc.js) from sharing information with Google Analytics about visits activity.</p> <p>For more information on the privacy practices of Google, please visit the Google Privacy & Terms web page: <a href="https://policies.google.com/privacy?hl=en">https://policies.google.com/privacy?hl=en</a></p>
</li>
</ul>
<h4 class="top10">Changes To This Privacy Policy</h4>
<p>We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.</p>
<p>We will let you know via email and/or a prominent notice on our Service, prior to the change becoming effective and update the "effective date" at the top of this Privacy Policy.</p>
<p>You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.</p>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -1,16 +1,20 @@
{% extends "base.twig" %} {% extends app.fronthtml~"/base.twig" %}
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class="row" style="text-align: center"> <div class="row" style="text-align: center">
<h4>About CodeShare</h4> <h4>About CodeShare</h4>
<div class="col-lg-12"> <div class="col-lg-12">
<h5>Source</h5>
<p>CodeShare is an open source platform licensed under Apache 2.0. All code are hosted in <a href="https://gitlab.com/CodeSolutionsProject/CodeShare">GitLab</a></p>
<h5>Developers</h5> <h5>Developers</h5>
<p>Developed by JKA Network's Team</p> <p>Developed by Code Solutions Project <a href="mailto:contacto@jkanetwork.com">&lt;contacto@jkanetwork.com&gt;</a></p>
<p>Maintenance by Jose Luis Garrido Labrador <a href="mailto:joselucross@jkanetwork.com">&lt;joselucross@jkanetwork.com&gt;</a></p>
<h5>Open source licenses</h5> <h5>Open source licenses</h5>
<p><a href="http://getbootstrap.com/"><strong>Bootstrap 3</strong> by Twitter - Licensed under MIT</a></p> <p><a href="http://getbootstrap.com/"><strong>Bootstrap 3</strong> by Twitter - Licensed under MIT</a></p>
<p><a href="https://bootswatch.com/"><strong>Paper theme to Boostrap 3</strong> by Bootswatch - Licensed under MIT</a></p> <p><a href="https://bootswatch.com/"><strong>Paper theme to Boostrap 3</strong> by Bootswatch - Licensed under MIT</a></p>
<p><a href="https://jquery.com/"><strong>jQuery 3.2.1</strong> by jQuery - Licensed under custom license</a></p> <p><a href="https://jquery.com/"><strong>jQuery</strong> by jQuery - Licensed under MIT</a></p>
<p><a href="https://highlightjs.org/"><strong>Highlight.js</strong> by Ivan Sagalev Licensed under BSD</a></p> <p><a href="https://highlightjs.org/"><strong>Highlight.js</strong> by Ivan Sagalev - Licensed under BSD</a></p>
<p><a href="https://cookieconsent.insites.com"><strong>Cookie Consent</strong> by Insites - Licensed under MIT</a></p>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,4 +1,4 @@
{% extends "base.twig" %} {% extends app.fronthtml~"/base.twig" %}
{% block content %} {% block content %}
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post">
<div class="form-group"> <div class="form-group">
@@ -19,7 +19,7 @@
<select id="lang" name="lang" required="required" class="form-control"> <select id="lang" name="lang" required="required" class="form-control">
<option value=""></option> <option value=""></option>
{% for key,value in supported %} {% for key,value in supported %}
<option value="{{ key }}">{{ value }}</option> <option value="{{ key }}">{{ value[0] }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
@@ -28,10 +28,10 @@
<label class="control-label col-sm-6" for="lang">Name of external library, if needed:</label> <label class="control-label col-sm-6" for="lang">Name of external library, if needed:</label>
<label class="control-label col-sm-6" for="lang">It needs a specific version of this library?:</label> <label class="control-label col-sm-6" for="lang">It needs a specific version of this library?:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="text" name="extlib" placeholder="Name of library"/> <input type="text" name="extlib" id="extlib" placeholder="Name of library"/>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="text" name="extlibver" placeholder="Version used, only if needed"/> <input type="text" name="extlibver" id="extlibver" placeholder="Version used, only if needed"/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -73,4 +73,25 @@
width: 100%; width: 100%;
} }
</style> </style>
{% endblock %}
{% block js %}
<script>
function verRequired() {
if(extlib.value=="")
extlibver.removeAttribute("required");
else
extlibver.setAttribute("required","required");
if(extlib2.value=="")
extlibver2.removeAttribute("required");
else
extlibver2.setAttribute("required","required");
}
extlib = document.getElementById("extlib");
extlibver=document.getElementById("extlibver");
extlib2 = document.getElementById("extlib2");
extlibver2=document.getElementById("extlibver2");
extlib.onkeyup=verRequired;
extlib2.onkeyup=verRequired;
</script>
{% endblock %} {% endblock %}

View File

@@ -2,32 +2,106 @@
<html> <html>
<head> <head>
<title>{{ page.title }}</title> <title>{{ page.title }}</title>
<link type="text/css" rel="stylesheet" href="{{ app.frontcss }}/bootstrap-paper.css"/>
<link type="text/css" rel="stylesheet" href="{{ path.css }}/bootstrap-paper.css"/>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"> <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="{{ app.frontcss }}/main.css"/>
<link type="text/css" rel="stylesheet" href="{{ path.css }}/codeStyles/vs.css"/> <link type="text/css" rel="stylesheet" href="{{ app.frontcss }}/alert.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.1.0/cookieconsent.min.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
{#<link rel="shortcut icon" href="{{ path.img }}favicon.ico" type="image/x-icon"/>#} {#<link rel="shortcut icon" href="{{ path.img }}favicon.ico" type="image/x-icon"/>#}
{% block css %}{% endblock %} {% block css %}{% endblock %}
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="description" content="{{ page.description }}"/> <meta name="description" content="{{ page.description }}"/>
<script src="{{ path.js }}/highlight.pack.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="{{ path.js }}/functions.js"></script> <script src="{{ app.frontjs }}/highlight.pack.js"></script>
<script src="{{ path.js }}/jquery-3.2.1.min.js"></script> <script src="{{ app.frontjs }}/jquery-3.2.1.min.js"></script>
<script src="{{ path.js }}/bootstrap.min.js"></script> <script src="{{ app.frontjs }}/jquery.form.min.js"></script>
<script src="{{ app.frontjs }}/bootstrap.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script src="{{ app.frontjs }}/functions.js"></script>
<script src="{{ app.frontjs }}/like.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-127852781-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-127852781-1');
</script>
<!-- End Google Analytics -->
</head> </head>
<body> <body>
{% include 'nav.twig' %} {% include app.fronthtml~'/nav.twig' %}
{% include 'header.twig' %} {% include app.fronthtml~'/header.twig' %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% include "footer.twig" %} <div class="myAlert-bottom alert alert-dismissible alert-danger">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Oh snap!</strong> Something wrong
</div>
{% include app.fronthtml~"/footer.twig" %}
{% block js %} {% block js %}
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
{% endblock %} {% endblock %}
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"onInitialise": function (status) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
</body> }
if (type == 'opt-out' && !didConsent) {
deleteCookies();
}
},
"onStatusChange": function(status, chosenBefore) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
// enable cookies
}
if (type == 'opt-out' && !didConsent) {
deleteCookies();
}
},
"onRevokeChoice": function() {
var type = this.options.type;
if (type == 'opt-in') {
// disable cookies
}
if (type == 'opt-out') {
// enable cookies
}
},
"palette": {
"popup": {
"background": "#2196f3",
"text": "#b2dbfb"
},
"button": {
"background": "transparent",
"text": "#b2dbfb",
"border": "#b2dbfb"
}
},
"type": "opt-out",
"content": {
"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 them",
"href": "{{ path('tos') }}#cookiePolicy"
}
})});
</script>
</body>

View File

@@ -1,9 +1,9 @@
{% extends "base.twig" %} {% extends app.fronthtml~"/base.twig" %}
{% block content %} {% block content %}
<div id="ajaxPut"> <div id="ajaxPut">
<div class="codebox"> <div class="codebox">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <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> </div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
@@ -21,26 +21,29 @@
{% 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='{{ 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>#}
{% if page.otherI or user.nick is defined %}
<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>
</div> </div>
{% endif %}
{% if page.otherI %} {% if page.otherI %}
{% for i in otherImplementation %} {% for i in otherImplementation %}
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12" style='text-align: center;'> <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12" style='text-align: center;'>
<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>
@@ -75,11 +78,19 @@
<option value=""></option> <option value=""></option>
{% for key,value in supported %} {% for key,value in supported %}
{% if key not in page.existedLangs %} {% if key not in page.existedLangs %}
<option value="{{ key }}"> {{ value }} </option> <option value="{{ key }}"> {{ value[0] }} </option>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="col_full" id="lib">
<label for="extlib">External Library:</label>
<input type="text" name="extlib" id="extlib2" {% 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="extlibver2" {% if code.extlib != "" %}value="{{ code.extlibver }}" required="required" {% endif %} placeholder="Library version">
</div>
<div class="col_full"> <div class="col_full">
<label for="code">Code:</label> <label for="code">Code:</label>
<textarea style="width: 100%" rows="{{ code.rows }}" required="required" name="code" id="code"></textarea> <textarea style="width: 100%" rows="{{ code.rows }}" required="required" name="code" id="code"></textarea>
@@ -99,7 +110,7 @@
</div> </div>
{% endif %} {% endif %}
{% if user.nick is defined and user.IDU == code.idu%} {% if user.nick is defined and user.IDU == code.idu %}
<div id="modify" class="modal fade" role="dialog" aria-labelledby="modify" <div id="modify" class="modal fade" role="dialog" aria-labelledby="modify"
aria-hidden="true"> aria-hidden="true">
<div class="vertical-alignment-helper"> <div class="vertical-alignment-helper">
@@ -130,11 +141,11 @@
{% endif %} {% endif %}
<div class="col_full" id="lib"> <div class="col_full" id="lib">
<label for="extlib">External Library</label> <label for="extlib">External Library</label>
<input type="text" name="extlib" id="extlib" {% if code.extlib is not null %}value="{{ code.extlib }}"{% endif %} placeholder="Name of library"> <input type="text" name="extlib" id="extlib" {% if code.extlib != "" %}value="{{ code.extlib }}"{% endif %} placeholder="Name of library">
</div> </div>
<div class="col_full" id="libVer"> <div class="col_full" id="libVer">
<label for="extlibver">Library version</label> <label for="extlibver">Library version</label>
<input type="text" name="extlibver" id="extlibver" {% if code.extlib is not null %}value="{{ code.extlibver }}" required="required"{% endif %} placeholder="Library version"> <input type="text" name="extlibver" id="extlibver" {% if code.extlib != "" %}value="{{ code.extlibver }}" required="required" {% endif %} placeholder="Library version">
</div> </div>
<div class="col_full"> <div class="col_full">
<label for="code">Code:</label> <label for="code">Code:</label>
@@ -160,16 +171,23 @@
{% block js %} {% block js %}
<script>hljs.initHighlightingOnLoad();</script> <script>hljs.initHighlightingOnLoad();</script>
<script> <script>
function verRequired() { function verRequired() {
extlibver=document.getElementById("extlibver");
if(extlib.value=="") if(extlib.value=="")
extlibver.removeAttribute("required"); extlibver.removeAttribute("required");
else else
extlibver.setAttribute("required","required"); extlibver.setAttribute("required","required");
if(extlib2.value=="")
extlibver2.removeAttribute("required");
else
extlibver2.setAttribute("required","required");
} }
var extlib = document.getElementById("extlib"); extlib = document.getElementById("extlib");
extlibver=document.getElementById("extlibver");
extlib2 = document.getElementById("extlib2");
extlibver2=document.getElementById("extlibver2");
extlib.onkeyup=verRequired; extlib.onkeyup=verRequired;
extlib2.onkeyup=verRequired;
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -1,35 +1,45 @@
<table style="width: 100%; text-align:center"> <div class="container-fluid" style="width: 100%; text-align:center">
<tr> <div class="row">
<th> <div class="col-lg-offset-2 col-md-offset-2 col-lg-8 col-md-8 col-sm-8 col-xs-8">
<a href="?page=code&id={{ code.idc }}&lang={{ code.lang }}&version={{ code.version }}">{{ code.name }}</a> <h5><a href="{{ path('code',{'idc': code.idc,'lang': code.lang,'version': code.version}) }}">{{ code.name }}</a></h5>
</th> </div>
</tr> <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4" style="text-align: right">
<tr> <h4>
<td><strong>Author:</strong>&nbsp{{ code.nick }} <strong> Version: </strong>{{ code.version }} <strong> <a href="javascript:;" onclick="likeAndSave('l',{{ code.idc }},'{{ code.lang }}'{% if user.nick is defined %},'{{ user.nick }}'{% endif %})"
Lang: </strong>{{ code.lLang }}</td> data-toggle="tooltip" data-placement="top" title="" data-original-title="Like">
</tr> <i class="{% if code.like == 1 %}fas{% else %}far{% endif %} fa-heart" id="l-{{ code.idc }}-{{ code.lang|raw }}" style="padding-right: 0.05em;"></i>
{% if code.extlib is not null %} </a>
<tr> <a href="javascript:;" onclick="likeAndSave('s',{{ code.idc }},'{{ code.lang }}'{% if user.nick is defined %},'{{ user.nick }}'{% endif %})"
<td> data-toggle="tooltip" data-placement="top" title="" data-original-title="Save">
<strong>External library:</strong>&nbsp{{ code.extlib }} <i class="{% if code.save == 1 %}fas{% else %}far{% endif %} fa-bookmark" id="s-{{ code.idc }}-{{ code.lang }}"></i>
{% if code.extlibver is not null %} </a>
<strong> Version used: </strong>{{ code.extlibver }} </h4>
</div>
</div>
{% if page.page!="home"%}
{% if code.extlib is defined and code.extlib != "" %}
<div class="row">
<strong>External library:</strong>&nbsp{{ code.extlib }}
{% if code.extlibver is not null %}
<strong> Version used: </strong>{{ code.extlibver }}
{% endif %}
<div/>
</div>
{% endif %} {% endif %}
</td>
</tr>
{% endif %} {% endif %}
<tr> <div class="row">
<th colspan="6">Description</th> <div class="col-lg-offset-3 col-md-offset-3 col-sm-offset-3 col-xs-offset-3 col-lg-6 col-md-6 col-sm-6 col-xs-6">
</tr> {% if page.page=="code"%}<strong>Description:</strong> {{ code.description }}{% endif %}
<tr> </div>
<td colspan="6">{{ code.description }}</td>
</tr> </div>
<tr> <div class="row">
<th colspan="6">Code</th> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="text-align: left"><strong>{{ code.lLang }}</strong></div>
</tr> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="text-align: right"><strong>{{ code.nick }}</strong></div>
<tr> </div>
<td colspan="6"> <div class="row">
<pre><code class='{{ code.lang }} codeto'>{{ code.code }}</code></pre> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
</td> <pre class="highlight"><code class='{{ code.lang }} codeto toHightlight'>{{ code.code }}</code></pre>
</tr> </div>
</table> </div>
</div>

View File

@@ -0,0 +1,48 @@
{#<table style="width: 100%; text-align:center">
<tr>
<th>
<h4><a href="{{ path('code',{'idc': code.idc,'lang': code.lang,'version': code.version}) }}">{{ code.name }}</a></h4>
</th>
</tr>
<tr>
<td><strong>Author:</strong>&nbsp{{ code.nick }} <strong> Version: </strong>{{ code.version }} <strong>
Lang: </strong>{{ code.lLang }}</td>
</tr>
<tr>
<td colspan="6">
<pre class="highlight"><code class='{{ code.lang }} codeto toHightlight'>{{ code.code }}</code></pre>
</td>
</tr>
</table>#}
<div class="container-fluid" style="width: 100%; text-align:center">
<div class="row">
<div class="col-lg-12"><h5><a href="{{ path('code',{'idc': code.idc,'lang': code.lang,'version': code.version}) }}">{{ code.name }}</a></h5></div>
</div>
<div class="row">
<div class="col-lg-12"></div>
</div>
{% if page.page!=home%}
{% if code.extlib is defined and code.extlib != "" %}
<div class="row">
<strong>External library:</strong>&nbsp{{ code.extlib }}
{% if code.extlibver is not null %}
<strong> Version used: </strong>{{ code.extlibver }}
{% endif %}
<div/>
</div>
{% endif %}
<div class="row">
<strong>Description:</strong> {{ code.description }}
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="text-align: left"><strong>{{ code.lLang }}</strong></div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="text-align: right"><strong>{{ code.nick }}</strong></div>
</div>
{% endif %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<pre class="highlight"><code class='{{ code.lang }} codeto toHightlight'>{{ code.code }}</code></pre>
</div>
</div>
</div>

View File

@@ -1,17 +1,17 @@
{% 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">Documentation</h4> <h4 style="text-align: center">Documentation</h4>
<h4 class="docheader top10" id="what">What is CodeShare?</h4> <h4 class="docheader top10" id="what">What is CodeShare?</h4>
<p><strong>CodeShare</strong> is a platform where everybody can share implementations of common problems of computer programming. Developed by <strong>JKA Network</strong>, a Spanish's association that promotes the free culture.</p> <p><strong>CodeShare</strong> is a platform where everybody can share implementations of common problems of computer programming. Developed by <strong>Code Solutions Project</strong>, a Spanish's association that promotes the free culture.</p>
<h4 class="docheader top10" id="who">Who can use CodeShare?</h4> <h4 class="docheader top10" id="who">Who can use CodeShare?</h4>
<p><strong>Everybody can copy and distribute any code posted in this platform</strong>, and sign up and share their own solutions or post new implementations of solutions already hosted. As a warning, if someone engage vandalism (see <a href="#vandalism">vandalism in CodeShare</a>) they will be banned from publishing or editing any code, and in serious cases, ban their account permanentely. However, they will not be restricted form services of unregistered users.</p> <p><strong>Everybody can copy and distribute any code posted in this platform</strong>, and sign up and share their own solutions or post new implementations of solutions already hosted. As a warning, if someone engage vandalism (see <a href="#vandalism">vandalism in CodeShare</a>) they will be banned from publishing or editing any code, and in serious cases, ban their account permanentely. However, they will not be restricted form services of unregistered users.</p>
<h4 class="docheader top10" id="how">How can I submit my own solution?</h4> <h4 class="docheader top10" id="how">How can I submit my own solution?</h4>
<ol> <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> <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> <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>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>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> <li><p>After that, introduce the <strong>Input</strong> and <strong>Output</strong> examples with the following criteria:</p></li>

View File

@@ -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 }}

View File

@@ -1,16 +1,28 @@
<div style="text-align: center; margin-top:10px; "><button class="btn btn-default" onclick="mostrar('filterBlock')">Filters</button></div> <div style="text-align: center; margin-top:10px; "><button class="btn btn-default" onclick="mostrar('filterBlock')">Filters</button></div>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="filterBlock" style="display: none;"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="filterBlock" style="display: none;">
<div class="container-fluid">
{% for key,value in page.supported %}
<div class='codeFilterCheckBox'><input type='checkbox' class='codeFilterCheckBoxInput' checked='true' value='{{ key }}' onclick="getAjax()"> {{ value }}</div>
{% endfor %}
<div class='codeFilterCheckBox'><button type='button' class='codeFilterCheckBoxInput btn btn-default btn-sm' onclick="unselectAll()">Unselect all</button></div>
<div class="container"></div>
<div class="row"> <div class="row">
<div class="codeFilterSearch col-md-11"> {% for key,value in page.grouped %}
<input type="text" class="codeFilterSearchInput" id="search" name="search" placeholder="Code's name or description" onkeyup="getAjax()"> <div class="col-lg-{{ value[1] }} col-md-{{ value[1] }} nopadding" style="{% if loop.first %}padding-left:15px {% elseif loop.last %}padding-right:15px{% endif %}">
<div class="row nomargin">
<div class='codeFilterCheckBox codeFilterTitle'>{{ key }}</div>
</div>
<div class="row nomargin">
{% for lang in value[0] %}
<div class='codeFilterCheckBox'><input type='checkbox' class='codeFilterCheckBoxInput' checked='true' value='{{ lang[0] }}' onclick="getAjax(true)"> {{ lang[1] }}</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
<div class="row nomargin">
<div class='codeFilterCheckBox'><button type='button' class='codeFilterCheckBoxInput btn btn-default btn-sm' onclick="unselectAll()">Unselect all</button></div>
</div>
<div class="row">
<div class="codeFilterSearch col-md-12">
<input type="text" class="codeFilterSearchInput" id="search" name="search" placeholder="Code's name or description" onkeyup="getAjax(true)">
</div> </div>
{#<div class="codeFilterButton col-md-4"><button class="btn btn-default" onclick="getAjax()">Filter</button></div>#} {#<div class="codeFilterButton col-md-4"><button class="btn btn-default" onclick="getAjax()">Filter</button></div>#}
</div> </div>
</div>
</div> </div>

View File

@@ -1,5 +1,10 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
{% if page.last is empty %}
<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='text-align: center'>
<h3 id='end'>No more code to load</h3>
</div>
{% endif %}
{% for code in page.last %} {% for code in page.last %}
{% if loop.index0 is divisible by(2) %} {% if loop.index0 is divisible by(2) %}
</div> </div>
@@ -7,7 +12,7 @@
{% endif %} {% endif %}
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="codebox"> <div class="codebox">
{% include "codebox.twig" %} {% include app.fronthtml~"/codebox.twig" %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View File

@@ -1,8 +1,8 @@
{% extends "base.twig" %} {% extends app.fronthtml~"/base.twig" %}
{% block content %} {% block content %}
<h5 style="text-align:center">Last codes</h5> <h5 style="text-align:center">Last codes</h5>
{% include "filter.twig" %} {% include app.fronthtml~"/filter.twig" %}
<div id="ajaxPut"> <div id="ajaxPut">
{% include "firstCodes.twig" %} {% include app.fronthtml~"/firstCodes.twig" %}
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -1,17 +1,28 @@
<footer> <footer class="container-fluid">
<p><span class="copyleft">&copy;</span> JKA Network 2017</p> <div class="row">
<p xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#"> <p class="col-lg-12"><span class="copyleft">&copy;</span> Code Solutions Project 2017-{{ "now"|date("Y") }}</p>
<a rel="license" </div>
href="http://creativecommons.org/publicdomain/zero/1.0/"> <div class="row">
<img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" /> <p xmlns:dct="https://purl.org/dc/terms/" xmlns:vcard="https://www.w3.org/2001/vcard-rdf/3.0#" class="col-lg-12">
</a> <a rel="license"
<br /> href="https://creativecommons.org/publicdomain/zero/1.0/">
<span resource="[_:publisher]" rel="dct:publisher"> <img src="https://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
<span property="dct:title">JKA Network</span></span> </a>
makes all the content hosted in CodeShare, included uploaded content, go to the public domain as far as the law allows it. <br />
<br> <span resource="[_:publisher]" rel="dct:publisher">
This work is published from: <span property="dct:title">Code Solutions Project</span></span>
<span property="vcard:Country" datatype="dct:ISO3166" makes all the content hosted in CodeShare, included uploaded content, go to the public domain as far as the law allows it.
content="ES" about="[_:publisher]">Spain</span>. <br>
</p> This work is published from:
<span property="vcard:Country" datatype="dct:ISO3166"
content="ES" about="[_:publisher]">Spain</span>.
</p>
</div>
<div class="row">
<p class="col-lg-offset-4 col-md-offset-4 col-sm-offset-4 col-xs-offset-4 col-lg-4 col-md-4 col-sm-4 col-xs-4">
<a href="{{ path('tos') }}#tos">Terms of Service</a>&emsp;
<a href="{{ path('tos') }}#pp">Privacy Policy</a>
</p>
<p class="col-lg-4 col-md-4 col-sm-4 col-xs-4"></p>
</div>
</footer> </footer>

View File

@@ -1,4 +1,5 @@
<header> <header>
<h2><a href="index.php" style="color: #333">CodeShare<sup>Beta</sup></a></h2> <h2><sub style="visibility: hidden;">Beta</sub><a href="{{ path('home') }}" style="color: #333">CodeShare</a><sup>Beta</sup></h2>
<h5>by <a href="https://csp.jkanetwork.com" style="color: #333">Code Solutions Project</a></h5>
<h4>Simple solutions for common problems</h4> <h4>Simple solutions for common problems</h4>
</header> </header>

View File

@@ -1,16 +1,23 @@
{% extends "base.twig" %} {% extends app.fronthtml~"/base.twig" %}
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class="col-sm-12"> <div class="row">
{% if page.state == 1 %} <div class="col-sm-12">
<p class="text-danger">Bad credentials</p> <p class="text-primary">Cookies must be available and accepted to login and register</p>
{% elseif page.state == 2 %} </div>
<p class="text-danger">Email already exits</p> </div>
{% endif %} <div class="row">
</div> <div class="col-sm-12">
<p class="text-danger loginMessage" id="BAD_CREDENTIAL">Bad credentials</p>
<p class="text-danger loginMessage" id="POST_ERROR">Error during sign-up, check your data</p>
<p class="text-danger loginMessage" id="MAIL_IN_USE">The e-mail is currently in use</p>
<p class="text-danger loginMessage" id="NICK_IN_USE">The nickname is currently in use</p>
<p class="text-danger loginMessage" id="CONFIRM_MAIL">Please, confirm your email before</p>
</div>
</div>
</div> </div>
<div id="login"> <div id="login">
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post" id="loginForm">
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label> <label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10"> <div class="col-sm-10">
@@ -24,9 +31,10 @@
</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-8">
<button type="submit" class="btn btn-success">Submit</button> <button type="submit" class="btn btn-success">Submit</button>
</div> </div>
<div><a class="text-info" href="{{ path('restore') }}">Restore Password</a> </div>
</div> </div>
<div class="col-sm-offset-1 col-sm-12"> <div class="col-sm-offset-1 col-sm-12">
<button onclick="nowRegister()" id="registerbtn" class="btn btn-primary">Don't have an account yet? Sing up</button> <button onclick="nowRegister()" id="registerbtn" class="btn btn-primary">Don't have an account yet? Sing up</button>
@@ -34,7 +42,7 @@
</form> </form>
</div> </div>
<div id="register" style="display:none;"> <div id="register" style="display:none;">
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post" id="regForm">
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="emailre">Email:</label> <label class="control-label col-sm-2" for="emailre">Email:</label>
<div class="col-sm-10"> <div class="col-sm-10">
@@ -62,15 +70,19 @@
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="name">Nickname:</label> <label class="control-label col-sm-2" for="name">Nickname:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" required="required" name="name" id="pwdre-re" placeholder="Enter your nickname for public identification"> <input type="text" class="form-control" required="required" name="nick" id="nick" placeholder="Enter your nickname for public identification">
</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">
<label class="control-label col-sm-2" for="captcha"></label>
<div class="col-sm-10 g-recaptcha" data-sitekey="6Ld-C3cUAAAAADjyFgwdcVuLJqfCr0F3s2p1mE86"></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">Submit</button> <button type="submit" class="btn btn-success">Submit</button>
@@ -87,6 +99,28 @@
{% block js %} {% block js %}
<script> <script>
doneFun = function(data){
console.log(data);
if (data == 'redirect'){
window.location.href = '{{path('home')}}';
}
var todos = $(".text-danger").each(function (){
$(this).css("display","none");
});
$("#"+data).css('display',"block");
};
$(document).ready(function() {
var options = {success: doneFun,
url: '{{ path("login")}}',
beforeSubmit: function(arr, $form, options){
console.log(arr);
}} ;
$("#regForm").ajaxForm(options);
$("#loginForm").ajaxForm(options);
});
function checkPassword() { function checkPassword() {
if ($('#pwdre').val() != $("#pwdre-re").val()) { if ($('#pwdre').val() != $("#pwdre-re").val()) {
$("#pwdre-re")[0].setCustomValidity('Password do not match'); $("#pwdre-re")[0].setCustomValidity('Password do not match');
@@ -118,7 +152,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 %}

View File

@@ -11,40 +11,40 @@
<div class="navbar-collapse collapse" id="nav" aria-expanded="false" style="height: 1px"> <div class="navbar-collapse collapse" id="nav" aria-expanded="false" style="height: 1px">
<ul class="nav navbar-nav navbar-left"> <ul class="nav navbar-nav navbar-left">
<li {% if page.page == "home" %}class="active"{% endif %}> <li {% if page.page == "home" %}class="active"{% endif %}>
<a href="index.php">Home</a> <a href="{{ path('home') }}">Home</a>
</li> </li>
<li {% if page.page == "add" %}class="active"{% endif %}> <li {% if page.page == "add" %}class="active"{% endif %}>
<a href="?page=add">Submit code</a> <a href="{{ path('add') }}" style="color: white;" class="text-uppercase">Submit code</a>
</li> </li>
<li {% if page.page == "doc" %}class="active"{% endif %}> <li {% if page.page == "doc" %}class="active"{% endif %}>
<a href="?page=doc">Documentation</a> <a href="{{ path('doc') }}">Documentation</a>
</li> </li>
<li {% if page.page == "about" %}class="active"{% endif %}> <li {% if page.page == "about" %}class="active"{% endif %}>
<a href="?page=about">About</a> <a href="{{ path('about') }}">About</a>
</li> </li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <li>
<form class="nav navbar-nav navbar-form navbar-left" method="post"> <form class="nav navbar-nav navbar-form navbar-left" method="post">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control" name="search" placeholder="Search"> <input type="text" class="form-control" name="globalSearch" placeholder="Search">
</div> </div>
<button type="submit" class="btn btn-primary btn-sm">Submit</button> <button type="submit" class="btn btn-primary btn-sm">Search</button>
</form> </form>
</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>

View File

@@ -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 %}

View File

@@ -0,0 +1,35 @@
{% extends app.fronthtml~"/base.twig" %}
{% block content %}
<div id="register" style="">
<form class="form-horizontal" method="post" id="restore">
<div class="form-group">
<label class="control-label"><strong>Restore your password</strong></label>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="emailre">Email:</label>
<div class="col-sm-10">
<input class="form-control" required="required" name="emailre" id="emailre" placeholder="Enter email" type="email">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Send me an email</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
var options = {success: function(data){
window.location.href = '{{path('home')}}';
},
url: '{{ path("restore")}}',
} ;
$("#restore").ajaxForm(options);
});
</script>
{% endblock %}

View File

@@ -0,0 +1,78 @@
{% extends app.fronthtml~"/base.twig" %}
{% block content %}
<div class="container">
<div class="row">
<div class="col-sm-12">
<p class="text-danger loginMessage" id="BAD_EMAIL">Email is not associated to this nick</p>
<p class="text-danger loginMessage" id="NO_MATCH">Passwords not match</p>
</div>
</div>
</div>
<div id="register" style="">
<form class="form-horizontal" method="post" id="restore">
<div class="form-group">
<label class="control-label"><strong>Restore your password {{ page.nick }}</strong></label>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="emailre">Email:</label>
<div class="col-sm-10">
<input class="form-control" required="required" name="emailre" id="emailre" placeholder="Enter email" type="email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwdre">Password:</label>
<div class="col-sm-10">
<input class="form-control" required="required" name="pwdre" id="pwdre" placeholder="Enter password" type="password">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwdre-re">Repeat password:</label>
<div class="col-sm-10">
<input class="form-control" required="required" name="pwdre-re" id="pwdre-re" placeholder="Repeat password" type="password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
{% endblock %}
{% block js %}
<script>
doneFun = function(data){
console.log(data);
if (data == 'UPDATE'){
window.location.href = '{{path('home')}}';
}
var todos = $(".text-danger").each(function (){
$(this).css("display","none");
});
$("#"+data).css('display',"block");
};
$(document).ready(function() {
var options = {success: doneFun,
url: '{{ path("restorePass", {'nick': page.nick, 'token': page.token, 'timestamp': page.timestamp })}}',
beforeSubmit: function(arr, $form, options){
console.log(arr);
}} ;
$("#restore").ajaxForm(options);
});
function checkPassword() {
if ($('#pwdre').val() != $("#pwdre-re").val()) {
$("#pwdre-re")[0].setCustomValidity('Password do not match');
} else {
$("#pwdre-re")[0].setCustomValidity('');
}
//console.log($('#pwdre').val());
}
document.getElementById("pwdre").onchange = checkPassword;
document.getElementById("pwdre-re").onchange = checkPassword;
</script>
{% endblock %}

View File

@@ -0,0 +1,16 @@
<div class="container">
<div class="row">
<h5 class="col-sm-offset-1">Saved codes</h5>
</div>
<div class="row">
<div class="col-sm-offset-1">
<ul class="list-group">
{% for s in saved %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<a href="{{ path('code',{'idc': s.idc,'lang': s.lang,'version': s.version}) }}">{{ s.name }} on {{ s.lLang }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>

View File

@@ -1,52 +1,79 @@
{% 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">
<div class="row"> <div class="row">
<p class="col-md-1"><strong>Nickname</strong></p> <ul class="nav nav-tabs" role="tablist">
<p class="col-md-11">{{ user.nick }}</p> <li class="nav-item">
</div> <a class="navbar-link active" href="#data" role="tab" data-toggle="tab">My information</a>
<div class="row"> </li>
<p class="col-md-1"><strong>Email</strong></p> <li class="nav-item">
<p class="col-md-11">{{ user.email }}</p> <a class="navbar-link" href="#saved" role="tab" data-toggle="tab">Saved codes</a>
</div> </li>
<hr/> <li class="nav-item">
</div> <a class="navbar-link" href="#password" role="tab" data-toggle="tab">Change password</a>
<div class="container"> </li>
{% if page.status == 1 %} </ul>
<p class="text-success">Password updated successfully</p> <div class="tab-content">
{% elseif page.status == 2 %} <div role="tabpanel" class="tab-pane fade in active" id="data">
<p class="text-danger">Old password incorrect</p> <div class="container">
{% endif %} <div class="row">
<div class="row"> <h5 class="col-sm-offset-1">My information</h5>
<h5 class="col-sm-offset-1">Change password</h5> </div>
</div> <div class="row">
<div class="row"> <p class="col-md-1 col-sm-offset-1"><strong>Nickname</strong></p>
<form class="form-horizontal" method="post"> <p class="col-md-10">{{ user.nick }}</p>
<div class="form-group"> </div>
<label class="control-label col-sm-2" for="passact">Current password:</label> <div class="row">
<div class="col-sm-10"> <p class="col-md-1 col-sm-offset-1"><strong>Email</strong></p>
<input type="password" class="form-control" required="required" name="passact" id="passact" placeholder="Current password"> <p class="col-md-10">{{ user.email }}</p>
</div>
<hr/>
</div> </div>
</div> </div>
<div class="form-group"> <div role="tabpanel" class="tab-pane fade" id="saved">
<label class="control-label col-sm-2" for="newpass">New password:</label> {% include app.fronthtml~'/saved.twig' %}
<div class="col-sm-10"> </div>
<input type="password" class="form-control" required="required" name="newpass" id="newpass" onchange="onPasswordChange()" placeholder="New password"> <div role="tabpanel" class="tab-pane fade" id="password">
<div class="container">
{% if page.status == 1 %}
<p class="text-success">Password updated successfully</p>
{% elseif page.status == 2 %}
<p class="text-danger">Old password incorrect</p>
{% endif %}
<div class="row">
<h5 class="col-sm-offset-1">Change password</h5>
</div>
<div class="row">
<form class="form-horizontal" method="post">
<div class="form-group">
<label class="control-label col-sm-2" for="passact">Current password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" required="required" name="passact" id="passact" placeholder="Current password">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="newpass">New password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" required="required" name="newpass" id="newpass" onchange="onPasswordChange()" placeholder="New password">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="newpass-re">Repeat new password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" required="required" name="newpass-re" id="newpass-re" onchange="onPasswordChange()" placeholder="Repear new password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div>
</div> </div>
</div> </div>
<div class="form-group"> </div>
<label class="control-label col-sm-2" for="newpass-re">Repeat new password:</label>
<div class="col-sm-10">
<input type="password" class="form-control" required="required" name="newpass-re" id="newpass-re" onchange="onPasswordChange()" placeholder="Repear new password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</form>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -5,31 +5,49 @@ function doAjax(postValue) {
// Preparar la funcion de respuesta // Preparar la funcion de respuesta
conexion.onreadystatechange = ajaxresponse; //Cuando el ajax sea procesado y suceda algo, se ejecuta esta funcion conexion.onreadystatechange = ajaxresponse; //Cuando el ajax sea procesado y suceda algo, se ejecuta esta funcion
// Realizar peticion HTTP // Realizar peticion HTTP
conexion.open('POST', 'ajax.php'); conexion.open('POST', '/');
conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
conexion.send(postValue); //Las variables a mandar, en este caso POST conexion.send(postValue); //Las variables a mandar, en este caso POST
} }
newFilter=false;
function ajaxresponse(){ function ajaxresponse(){
if(conexion.readyState == 4){ //Esto es para que cambie cuando haya respuesta, que no es en todos los momentos if(conexion.readyState == 4){ //Esto es para que cambie cuando haya respuesta, que no es en todos los momentos
document.getElementById('ajaxPut').innerHTML = conexion.responseText; //Pondra todo lo devuelto por "file" (Que sera un php que de //echos dependiendo de lo enviado) en un div o++;
} var ajaxPut = document.getElementById('ajaxPut');
if(newFilter){
newFilter=false;
ajaxPut.innerHTML = conexion.responseText; //Pondra todo lo devuelto por "file" (Que sera un php que de //echos dependiendo de lo enviado) en un div
}else{
if($("#end").length == 0)
ajaxPut.innerHTML = ajaxPut.innerHTML+conexion.responseText;
}
}
reHightlight(); reHightlight();
} }
function reHightlight(){ function reHightlight(){
var codebox = document.getElementsByClassName("codeto"); var codebox = document.getElementsByClassName("toHightlight");
for(var i=0;i<codebox.length;++i){ for(var i=0;i<codebox.length;++i){
hljs.highlightBlock(codebox[i]); hljs.highlightBlock(codebox[i]);
} }
for(var i=0;i<codebox.length;++i){
codebox[i].classList.remove('toHightlight');
}
} }
function mostrar(div) { function mostrar(div) {
obj = document.getElementById(div); obj = document.getElementById(div);
obj.style.display = (obj.style.display == 'none') ? 'block' : 'none'; $(obj).slideToggle();
//obj.style.display = (obj.style.display == 'none') ? 'block' : 'none';
} }
function getAjax() { function getAjax(reset=false) {
if(reset){
resetFilter();
}
if(!newFilter && $("#end").length!=0){
return;
}
var checkboxes = document.getElementsByClassName("codeFilterCheckBoxInput"); var checkboxes = document.getElementsByClassName("codeFilterCheckBoxInput");
var i; var i;
var count = false; var count = false;
@@ -46,6 +64,7 @@ function getAjax() {
} }
if(document.getElementById("search").value!="") if(document.getElementById("search").value!="")
send = send+"&search="+document.getElementById("search").value; send = send+"&search="+document.getElementById("search").value;
send = send+"&o="+o;
doAjax(send); doAjax(send);
} }
@@ -84,13 +103,6 @@ function borrarCookie(clave){
crearCookie(clave,"",-1); crearCookie(clave,"",-1);
} }
function desloguearse(){
borrarCookie("logueado");
borrarCookie("usuario");
borrarCookie("token");
location.reload(true);
}
function unselectAll() { function unselectAll() {
var checkboxes = document.getElementsByClassName("codeFilterCheckBoxInput"); var checkboxes = document.getElementsByClassName("codeFilterCheckBoxInput");
var i; var i;
@@ -102,7 +114,7 @@ function unselectAll() {
checkboxes[i].innerHTML = "Select all"; checkboxes[i].innerHTML = "Select all";
} }
} }
getAjax(); getAjax(true);
} }
function selectAll() { function selectAll() {
@@ -116,5 +128,61 @@ function selectAll() {
checkboxes[i].innerHTML = "Unselect all"; checkboxes[i].innerHTML = "Unselect all";
} }
} }
getAjax(); getAjax(true);
}
function resetOffset(){
o=0;
}
function resetFilter(){
newFilter=true;
resetOffset();
}
o=1;
$(document.body).on('touchmove', onScroll);
$(window).on('scroll', onScroll);
function onScroll() {
if (Math.ceil($(window).scrollTop() + $(window).height()) == Math.ceil($(document).height())) {
getAjax();
}
}
//From https://stackoverflow.com/questions/35297919/javascript-select-all-text-inside-a-pre-code-block-on-double-click
window.onload = function(){
if(!comprobarCookie('cookieconsent_status') || obtenerCookie('cookieconsent_status')=='deny'){
deleteCookies();
}
document.body.addEventListener('dblclick', function(e){
var target = e.target || e.srcElement;
if (target.className.indexOf("highlight") !== -1 || target.parentNode.className.indexOf("highlight") !== -1){
var range, selection;
if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(target);
range.select();
} else if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(target);
selection.removeAllRanges();
selection.addRange(range);
}
e.stopPropagation();
}
});
};
function deleteCookies() {
var theCookies = document.cookie.split(';');
for (var i = 0 ; i < theCookies.length; i++) {
document.cookie = theCookies[i].split('=')[0] + '=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

11
Source/assets/js/jquery.form.min.js vendored Normal file

File diff suppressed because one or more lines are too long

69
Source/assets/js/like.js Normal file
View File

@@ -0,0 +1,69 @@
function likeAndSave(m,c,l,i=null){
var b=$('#'+m+"-"+c+"-"+l);
var data = {};
switch (m) {
case 'l':
if(b.hasClass('fas')){
data.mode = "unvote";
data.before = 'fas';
data.after = 'far';
}else{
data.mode = "vote";
data.before = 'far';
data.after = 'fas';
}
break;
case 's':
if(b.hasClass('fas')){
data.mode = "unsave";
data.before = 'fas';
data.after = 'far';
}else{
data.mode = "save";
data.before = 'far';
data.after = 'fas';
}
break;
}
if (i==null){
window.location.replace('/login')
}
data.idc=c;
data.lang=l;
$.ajax({
url: '/vote-save',
type: 'POST',
contentType: "application/json",
data: JSON.stringify(data),
traditional: true,
success: function(result) {
console.log(result);
if (result == 0){
b.addClass(data.after);
b.removeClass(data.before);
}
else
myAlertBottom();
},
error: function (result) {
myAlertBottom();
}
});
}
function myAlertTop(){
$(".myAlert-top").fadeToggle();
setTimeout(function(){
$(".myAlert-top").fadeToggle();
}, 2000);
}
function myAlertBottom(){
$(".myAlert-bottom").fadeToggle();
setTimeout(function(){
$(".myAlert-bottom").fadeToggle();
}, 2000);
}

View File

@@ -1,5 +1,10 @@
{ {
"require": { "require": {
"twig/twig": "^2.0" "twig/twig": "^2.0",
"jkanetwork/dbwrapper": "^1.4",
"symfony/flex": "^1.1",
"symfony/twig-bridge": "3.0.4",
"silex/silex": "~1.3",
"doctrine/dbal": "^2.5"
} }
} }

1002
Source/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
framework:
router:
strict_requirements: true

View File

@@ -0,0 +1,3 @@
framework:
router:
strict_requirements: ~

View File

@@ -0,0 +1,3 @@
framework:
router:
strict_requirements: true

View File

@@ -0,0 +1,3 @@
#index:
# path: /
# controller: App\Controller\DefaultController::index

View File

@@ -2,7 +2,7 @@
"lang": "en", "lang": "en",
"project": "CodeShare", "project": "CodeShare",
"master": "Code Solutions Project", "master": "Code Solutions Project",
"company": "JKA Network", "company": "Code Solutions Project",
"database": { "database": {
"SGBD": "mysql", "SGBD": "mysql",
"path": "localhost", "path": "localhost",

View File

@@ -0,0 +1 @@
{"ada": ["Ada", "Programming"], "apache": ["Apache", "Config"], "arduino": ["Arduino", "Programming"], "bash": ["Bash", "Script"], "basic": ["Basic", "Programming"], "bat": ["Batch", "Script"], "clojure": ["Clojure", "Programming"], "cmake": ["CMake", "Config"], "cs": ["C#", "Programming"], "cpp": ["C/C++", "Programming"], "css": ["CSS", "Markup"], "coffescript": ["CoffeScript", "Programming"], "dart": ["Dart", "Programming"], "delphi": ["Delphi", "Programming"], "dockerfile": ["Docker", "Config"], "fortran": ["Fortran", "Programming"], "fsharp": ["F#", "Programming"], "go": ["Go", "Programming"], "groovy": ["Groovy", "Programming"], "haskell": ["Haskell", "Programming"], "xml": ["HTML/XML", "Markup"], "ini": ["Ini", "Config"], "json": ["JSON", "Data"], "java": ["Java", "Programming"], "javascript": ["JavaScript", "Programming"], "kotlin": ["Kotlin", "Programming"], "less": ["Less", "Markup"], "lua": ["Lua", "Programming"], "lisp": ["Lisp", "Programming"], "makefile": ["Makefile", "Config"], "markdown": ["Markdown", "Markup"], "matlab": ["Matlab", "Mathematics"], "maxima": ["Maxima", "Mathematics"], "nginx": ["Nginx", "Config"], "objectivec": ["Objective-C", "Programming"], "php": ["PHP", "Programming"], "perl": ["Perl", "Programming"], "powershell": ["PowerShell", "Script"], "prolog": ["Prolog", "Programming"], "python": ["Python", "Programming"], "r": ["R", "Mathematics"], "ruby": ["Ruby", "Programming"], "rust": ["Rust", "Programming"], "scss": ["Sass", "Markup"], "scala": ["Scala", "Programming"], "smalltalk": ["Samlltalk", "Programming"], "sql": ["SQL", "Data"], "swift": ["Swift", "Programming"], "twig": ["Twig", "Markup"], "typescript": ["TypeScript", "Programming"], "vbnet": ["VB.Net", "Programming"], "yaml": ["YAML", "Data"]}

View File

@@ -1,39 +1,52 @@
ada:Ada ada:Ada:Programming
arduino:Arduino apache:Apache:Config
bash:Bash arduino:Arduino:Programming
basic:Basic bash:Bash:Script
cs:C# basic:Basic:Programming
cpp:C/C++ bat:Batch:Script
css:CSS clojure:Clojure:Programming
coffescript:CoffeScript cmake:CMake:Config
dart:Dart cs:C#:Programming
delphi:Delphi cpp:C/C++:Programming
fortran:Fortran css:CSS:Markup
go:Go coffescript:CoffeScript:Programming
groovy:Groovy dart:Dart:Programming
haskell:Haskell delphi:Delphi:Programming
xml:HTML/XML dockerfile:Docker:Config
json:JSON fortran:Fortran:Programming
java:Java fsharp:F#:Programming
javascript:JavaScript go:Go:Programming
kotlin:Kotlin groovy:Groovy:Programming
less:Less haskell:Haskell:Programming
lua:Lua xml:HTML/XML:Markup
markdown:Markdown Ini:ini:Config
objectivec:Objective-C json:JSON:Data interchange
php:PHP java:Java:Programming
perl:Perl javascript:JavaScript:Programming
powershell:PowerShell kotlin:Kotlin:Programming
python:Python less:Less:Markup
r:R lua:Lua:Programming
ruby:Ruby lisp:Lisp:Programming
rust:Rust makefile:Makefile:Config
scss:Sass markdown:Markdown:Markup
scala:Scala matlab:Matlab:Mathematics
smalltalk:Samlltalk maxima:Maxima:Mathematics
sql:SQL nginx:Nginx:Config
swift:Swift objectivec:Objective-C:Programming
twig:Twig php:PHP:Programming
typescript:TypeScript perl:Perl:Programming
vbnet:VB.Net powershell:PowerShell:Script
yaml:YAML prolog:Prolog:Programming
python:Python:Programming
r:R:Mathematics
ruby:Ruby:Programming
rust:Rust:Programming
scss:Sass:Markup
scala:Scala:Programming
smalltalk:Samlltalk:Programming
sql:SQL:Data
swift:Swift:Programming
twig:Twig:Markup
typescript:TypeScript:Programming
vbnet:VB.Net:Programming
yaml:YAML:Data

View File

@@ -1,5 +0,0 @@
User's roles
0: Normal user
1: Normal user with ban
2: Moderator
3: Administrator

View File

@@ -1,8 +1,10 @@
<?php <?php
require_once __DIR__ . '/src/app.php'; $filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
if (php_sapi_name() === 'cli-server' && is_file($filename)) {
run(); return false;
}
require_once __DIR__ . '/src/app.php';
$app->run();

View File

@@ -16,7 +16,7 @@ class Config
*/ */
public static function init(){ public static function init(){
if(!Config::initialized()) { 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::$config = json_decode($file, true);
Config::$in=true; Config::$in=true;
} }
@@ -65,7 +65,7 @@ class Config
} }
/** /**
* Get the company, usually "JKA Network" * Get the company, usually "Code Solutions Project"
* *
* @return string whit company * @return string whit company
*/ */
@@ -84,7 +84,19 @@ class Config
if(!Config::initialized()) if(!Config::initialized())
Config::init(); Config::init();
$DB = Config::$config["database"]; $DB = Config::$config["database"];
return dbw_connect($DB["SGBD"],$DB["path"],$DB["db"],$DB["user"],$DB["password"]); return dbw_connect($DB["SGBD"], $DB["path"], $DB["db"], $DB["user"], $DB["password"]);
}
public static function getDBalConexion(){
if(!Config::initialized())
Config::init();
$DB = Config::$config["database"];
return array(
'dbname' => $DB['db'],
'user' => $DB['user'],
'password' => $DB['password'],
'host' => $DB['path'],
'driver' => "pdo_".$DB['SGBD']);
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@@ -1,91 +1,252 @@
<?php <?php
if(isset($_COOKIE['cookieconsent_status']) and $_COOKIE['cookieconsent_status']!="deny") {
session_start(); //Start session in app, before loading vars ($_SESSION)
}
require_once __DIR__ .'/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/dbwrapper.php';
require_once __DIR__ . '/Config.php'; require_once __DIR__ . '/Config.php';
require 'functions.php'; require 'functions.php';
require 'domails.php';
require 'DB.php'; require 'DB.php';
require 'dbToTable.php'; require 'dbToTable.php';
require 'users.php'; require 'users.php';
$path = array(
"html" => "assets/html/",
"css" => "assets/css/",
"js" => "assets/js/",
"img" => "assets/img/",
);
$supported = ksonParse('data/supported.kson');
$loader = new Twig_Loader_Filesystem($path['html']);
$twig = new Twig_Environment($loader);
$user = array();
function run(){ $app = new Silex\Application();
global $user;
if(isset($_COOKIE['sessionID'])){ use Symfony\Component\HttpFoundation\Request;
$db = new DB(); use Symfony\Component\HttpFoundation\Response;
if($db->checkCookie($_COOKIE['sessionID'],$_COOKIE['token'])){
$user = $db->loadProfile($_COOKIE['sessionID']); $app['debug'] = false;
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$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");
$app["supported"] = json_decode($string, true);
$app->register(new Silex\Provider\DoctrineServiceProvider(), array(
'db.options' => Config::getDBalConexion()
));
$app['data'] = new DB($app['db']);
/* Security */
$app['security.role_hierarchy'] = array(
'ROLE_DELETE' => array('ROLE_COMMON'),
'ROLE_COMMON' => array('ROLE_USER'),
);
/* End Security */
$app->boot();
/* Basics */
$app->get('/', function (Request $request) use($app) {
$user = getUser($app);
$idu=0;
if($user != null){
$idu=$app['data']->loadIDU($user['nick'],'nick');
}
$ajax=false;
if($request->getMethod()=="POST"){
if($request->get('globalSearch')!=null){
$data = array('search'=>$request->get('globalSearch'));
$type=true;
}else{
$data = $request->request->all();
$type=false;
$ajax=true;
} }
$last = $app['data']->loadFilter($data,$type);
$last = lastToArray($last,$app['supported'],$app['data'],$idu);
}else{
$query = $app['data']->loadLast();
$last = lastToArray($query,$app['supported'],$app['data'],$idu);
} }
if (isset($_POST["search"])){ $page = array( 'title' => "CodeShare",
//echo $_POST["search"]; "description" => "Sharing your solutions with all",
//die(); "last" => $last,
firstPage(false,true); "supported" => $app["supported"],
"page" => "home",
"grouped" => groupByCategory($app["supported"]));
if($ajax){
return $app['twig']->render($app['fronthtml'] . '/firstCodes.twig' ,array(
"page" => $page,
'user' => $user
));
}else{
return $app['twig']->render($app['fronthtml'] . '/firstpage.twig' ,array(
"page" => $page,
'user' => $user
));
} }
else if ($_GET) { })->bind('home')->method('GET|POST');
if ($_GET["page"]) {
switch ($_GET["page"]) {
case "code": $app->get('/doc', function (Request $request) use($app){
codeViewer();
break; $user = getUser($app);
case "index": $page = array(
firstPage(); "title" => "Documentation",
break; "description" => "All documentation about how to upload code in CodeShare",
case "register": "page" => "doc",
case "login": );
loginRegister($_GET['page']); return $app['twig']->render($app['fronthtml'].'/doc.twig', array("page" => $page, "user" => $user));
break; })->bind('doc');
case "logout":
logout(); $app->get('/about', function (Request $request) use($app){
header("Location: index.php");
break; $user = getUser($app);
case "about": $page = array(
about(); "title" => "About CodeShare",
break; "description" => "Developed by Code Solutions Project's Team",
case "add": "page" => "about",
add(); );
break; return $app['twig']->render($app['fronthtml'].'/about.twig', array("page" => $page,'user'=>$user));
case "doc": })->bind('about');
doc();
break; /* User */
case "tos": $app->get('/tos',function(Request $request) use($app){
tos();
break; $user = getUser($app);
case "user": $page = array(
user(); "title" => "Terms of service",
break; "description" => "Terms of services and privacy policies",
case "del": "page" => ""
deleteSource(); );
break;
default: return $app['twig']->render($app['fronthtml'].'/TOS.twig', array("page" => $page, "user" => $user));
sendHTTPError(404); })->bind('tos');
$app->get('/login', function(Request $request) use ($app){
$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){
$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=''){
global $app;
if($state!=''){
return $state;
}
$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','BAD_CREDENTIAL');
case 1:
$result = checklogin($request->get('email'),$request->get('pwd'),$app['data']);
if($result==''){
return 'redirect';
}else if($result=='VALIDATE'){
return loginRegister('login','CONFIRM_MAIL');
}else{
return loginRegister("login",'BAD_CREDENTIAL');
} }
} else { case 2:
sendHTTPError(404); $captcha = checkCaptcha($request->get("g-recaptcha-response"));
} if(!$captcha){
} else { return "CAPTCHA_FAIL";
//header("CodeShare"); }
firstPage();
$state = register($request->get('emailre'),$request->get('emailre-re'),
$request->get('pwdre'), $request->get('pwdre-re'),$request->get('nick'),$app['data']);
if ($state == '')
return 'redirect';
else
return loginRegister("sing-up",$state);
} }
} }
function sendHTTPError($code){ $app->get('logout',function(Request $request) use ($app){
global $twig, $path,$user; logout();
$page = array("title" => $code.""); return $app->redirect($app['url_generator']->generate('home'));
})->bind('logout');
header($code.""); $app->get('/user', function(Request $request) use ($app){
$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['data']->checkPass($user['email'],$passact) && $newpass == $newpassre){
$status=1;
$app['data']->updatePass($user['IDU'],$newpass);
}else
$status=2;
}
$page = array(
"page" => "user",
"title" => "$user[nick]",
"description" => "NOT RELEVANT",
"status" => $status
);
$saved = $app['data']->allSaves($app['data']->loadIDU($user['nick'],'nick'));
return $app['twig']->render($app['fronthtml']."/user.twig",array("page"=>$page,"user"=>$user,"saved"=>savedToArray($saved,$app['supported'])));
})->bind('user')->method('GET|POST');
/* Error Codes */
function HTTPError($code){
switch($code){ switch($code){
case 400:
$text = "Bad Request";
break;
case 401: case 401:
$text = "Unauthorized user"; $text = "Unauthorized user";
break; break;
@@ -95,6 +256,12 @@ function sendHTTPError($code){
case 404: case 404:
$text = "Page not found"; $text = "Page not found";
break; break;
case 408:
$text = "Time out";
break;
case 503:
$text = "Database unavailable";
break;
case 500: case 500:
$text = "Internal server error"; $text = "Internal server error";
break; break;
@@ -103,257 +270,267 @@ function sendHTTPError($code){
$code = "Internal error"; $code = "Internal error";
break; break;
} }
return array("text"=>$text,"number"=>$code);
$error = array("number" => $code."","text"=>$text);
echo $twig->render('error.twig',array("page" => $page, "path" => $path, "user" => $user,"error" => $error));
} }
function firstPage($filter=false,$globalSearch=false){ $app->error(function (\Exception $e,$request) use ($app) {
global $supported,$twig,$path,$user; $user = null;
$db = new DB(); try{
if(!$filter and !$globalSearch) $user = getUser($app);
if(isset($_GET["p"])) }catch(Throwable $ex){
$query = $db->loadLast($_GET["p"]); //Nothing
}
if ($app['debug']) {
return;
}else {
$code=500;
if($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException)
$error = HTTPError($e->getStatusCode());
}
return $app['twig']->render($app['fronthtml'].'/error.twig', Array(
'page' => array("title"=>$code),
'error' => $error,
'user' => $user,
));
});
/* Codes */
$app->get('/code/{lang}-{idc}-{version}', function (Request $request, $lang, $idc, $version) use($app){
$user = getUser($app);
$array = $app['data']->loadAll($idc,$lang,$version);
if(!$array){
$app->abort('404');
}
if($request->getMethod()=='POST'){
return updateCode($request,$idc,$lang,$version,$user);
}
$page = array(
"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['data']->loadLangs($idc),
"original" => $app['data']->loadOriginalAuthor($idc),
);
$idu=0;
if($user != null){
$idu=$app['data']->loadIDU($user['nick'],'nick');
}
$code = allCodeToArray($array,$app['supported'],$app['data'],$idu);
if($array['Version']!=1)
$page['otherV'] = true;
$diff = $app['data']->loadDiff($idc,$lang);
if(count($diff)>=1){
$page['otherI'] = true;
}
$otherImplementation = otherImplementationToArray($diff,$app['supported']);
return $app['twig']->render($app['fronthtml'].'/code.twig', array(
"page" => $page,
"code" => $code,
"otherImplementation" => $otherImplementation,
"supported" => $app['supported'],
"user" => $user
));
})->bind('code')->method('GET|POST');
function updateCode(Request $request,$idc,$lang,$version,$user){
global $app;
$lang2 = $request->request->all()['lang'];
$extlib = $request->get('extlib');
$extlibver = $request->get('extlibver');
if($extlibver == null and $extlib != null)
$app->abort(400);
$code = htmlentities($request->get('code'));
if ($code == null or $lang == null)
$app->abort(400);
if($lang2 != null){
$app['data']->addSource($idc,$lang2,$code,$user['IDU'],$extlib,$extlibver);
return $app->redirect($app['url_generator']->generate('code',array("idc"=>$idc,"version"=>1,"lang"=>$lang2)));
}else{
$name = $request->get("name");
$description = $request->get("description");
$input = htmlentities($request->get("input"));
$output = htmlentities($request->get("output"));
if($name == null || $description == null || $input == null ||$output == null)
$app->abort(400);
$version2 = $app['data']->addOrModifyCodes($idc,$name,$description,$input,$output,$lang,$code,$user['IDU'],$extlibver,$extlibver);
if($version2!=0)
return $app->redirect($app['url_generator']->generate('code',array("idc"=>$idc,"version"=>$version2,"lang"=>$lang)));
else else
$query = $db->loadLast(); return $app->redirect($app['url_generator']->generate('code',array("idc"=>$idc,"version"=>$version,"lang"=>$lang)));
else
$query = $db->loadFilter($_POST);;
$last = lastToArray($db,$query,$supported);
$page = array(
"title" => "CodeShare",
"description" => "Sharing your solution with all",
"last" => $last,
"supported" => $supported,
"page" => "home"
);
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(!$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(){ $app->get('/code/{lang}-{idc}', function(Request $request, $lang, $idc) use($app){
global $supported,$twig,$path,$user;
$db = new DB();
if(isset($_POST['lang'])){ $user = getUser($app);
$db->addSource($_GET['id'],$_POST['lang'],htmlentities($_POST['code']),$user["IDU"]); $idu=0;
$db->close(); if($user != null){
header("Location: ?page=code&id=$_GET[id]&lang=$_POST[lang]&version=1"); $idu=$app['data']->loadIDU($user['nick'],'nick');
}else if(isset($_POST['name'])){ }
$extlib = isset($_POST['extlib']) ? $_POST['extlib'] : null;
$extlibver = isset($_POST['extlibver']) ? $_POST['extlibver'] : null; $array = $app['data']->loadOtherVersion($idc,$lang);
$version=$db->addOrModifyCodes( $other = otherVersionToArray($array,$app['supported'],$app['data'],$idu);
$_GET['id'], $name = $other[0]['name'];
$_POST['name'],
$_POST['description'], $page = array(
htmlentities($_POST['input']), "title" => "Other versions of $name",
htmlentities($_POST['output']), "description" => "All differents version of $name uploaded in CodeShare",
$_GET['lang'], "last" => $other,
htmlentities($_POST['code']), "page" => ""
$user['IDU'], );
$extlib, return $app['twig']->render($app['fronthtml'].'/otherVersion.twig', array(
$extlibver); "page" => $page, "user" => $user
//die(); ));
$db->close(); })->bind('codeVer');
if($version!=0){
header("Location: ?page=code&id=$_GET[id]&lang=$_GET[lang]&version=$version"); $app->get('/add', function(Request $request) use($app){
$user = getUser($app);
if ($user == null)
return $app->redirect($app['url_generator']->generate('login'));
if($request->getMethod()=="POST"){
$extlib = $request->get('extlib');
$extlibver = $request->get('extlibver');
if($extlib == null or $extlibver != null){
$name = $request->get('name');
$description = $request->get('description');
$input = htmlentities($request->get('input'));
$output = htmlentities($request->get('output'));
$lang = $request->get('lang');
$code = htmlentities($request->get('code'));
if($name == null || $description == null || $input == null ||
$output == null || $lang == null || $code == null){
$app->abort(400);
}
else{
$idc = $app['data']->addOrModifyCodes(
0,
$name,
$description,
$input,
$output,
$lang,
$code,
$user['IDU'],
$extlib,
$extlibver
);
return $app->redirect($app['url_generator']->generate('code',array(
"lang"=>$lang,"idc"=>$idc, "version"=>1
)));
}
}else{ }else{
header('Refresh:0'); $app->abort(400);
} }
}else if(isset($_POST['code'])){ }else{
$version=$db->addSource($_GET['id'],$_GET['lang'],htmlentities($_POST['code']),$user['IDU'],$_POST['extlib'],$_POST['extlibver']); $page=array(
$db->close(); "title" => "Add your own solution",
header("Location: ?page=code&id=$_GET[id]&lang=$_GET[lang]&version=$version"); "description" => "Share now your snippet",
"page" => "add",
);
return $app['twig']->render($app['fronthtml']."/add.twig", array("page" => $page, "user"=>$user, "supported" => $app["supported"]));
} }
})->bind('add')->method('GET|POST');
if (!$_GET['lang'] || !$_GET['id']) { $app->get('/restore', function(Request $request) use($app){
sendHTTPError(404);
}elseif($_GET['version']){ if($request->getMethod()=="POST"){
$array = $db->loadAll($_GET['id'],$_GET['lang'],$_GET['version']); $parts = $app['data']->createRestoreToken($request->get('emailre'));
if($array){ $parts = explode("-", $parts);
$token = $parts[0];
$timestamp = $parts[1];
restorePassword(
$request->get('emailre'),
$app['data']->loadProfile($app['data']->loadIDU($request->get('emailre')))['nick'],
$token,
$timestamp
);
return "UPDATE";
}
$page = array("title"=>"Restore your password",
"description"=>"None",
"page" =>"None");
return $app['twig']->render($app['fronthtml']."/restore.twig",array("page" => $page));
})->bind('restore')->method('GET|POST');
$app->get('/restore/{nick}/{token}-{timestamp}', function(Request $request, $nick, $token, $timestamp) use($app){
$time = 3600; //An hour
$now = time();
if($now - $timestamp > $time){
$app->abort(408);
}else{
if(!$app['data']->checkRestoreToken($nick,$token,$timestamp))
$app->abort(401);
if($request->getMethod()=='POST'){
$pass = $request->get('pwdre');
$passre = $request->get('pwdre-re');
if($pass != $passre){
return "NO_MATCH";
}
else{
$idu = $app['data']->loadIDU($request->get('emailre'));
$iduC = $app['data']->loadIDU($nick,'nick');
if($idu != $iduC)
return "BAD_EMAIL";
$app['data']->updatePass($idu,$pass);
}
$app['data']->setToken($idu,"");
return "UPDATE";
}else{
$page = array( $page = array(
"title" => "$array[Name] by $array[nick]", "title" => "Restore your password",
"description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']], "description" => "Page to restore your password",
"otherV" => false, "page" => "NONE",
"otherI" => false, "nick" => $nick,
"existedLangs" => $db->loadLangs($_GET['id']), "token" => $token,
"original" => $db->loadOriginalAuthor($_GET['id']), "timestamp" => $timestamp,
); );
$code = allCodeToArray($array,$supported); return $app['twig']->render($app['fronthtml']."/restorePass.twig",array("page" => $page));
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;
}
} }
} }
})->bind('restorePass')->method('GET|POST');
if($bool) { $app->get('/confirm/{nick}-{token}', function(Request $request, $nick, $token) use($app){
header("Location: index.php"); $idu=$app['data']->loadIDU($nick,'nick');
}else $res = $app['data']->checkConfirmToken($idu,$token);
echo $twig->render("loginregister.twig", array("page" => $page, "path" => $path )); if($res)
} $app['data']->setRole($idu);
else
$app->abort(401);
return $app->redirect($app['url_generator']->generate('login'));
})->bind('confirm');
function about(){ /* Votes and saves */
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(){ $app->post('/vote-save',function(Request $request) use($app){
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(){ $user = getUser($app);
global $twig,$path,$user; if ($user == null)
return 1;
if($user['nick']) { $data = str_replace('&quot;','"',$request->getContent());
$status=0; $data = json_decode($data,true);
if(array_key_exists("passact",$_POST)){ $idu = $app['data']->loadIDU($user['nick'],'nick');
$passact = $_POST["passact"]; switch($data['mode']){
$newpass = $_POST["newpass"]; case "vote":
//echo "EEEEEOOO"; return $app['data']->vote($idu,$data['idc'],$data['lang']);
$db = new DB(); case "unvote":
if($db->checkPass($user['email'],$passact)){ return $app['data']->unvote($idu,$data['idc'],$data['lang']);
$status=1; case "save":
$db->updatePass($user['IDU'],$newpass); return $app['data']->save($idu,$data['idc'],$data['lang']);
}else case "unsave":
$status=2; return $app['data']->unsave($idu,$data['idc'],$data['lang']);
$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);
} }
} return 1;
function deleteSource(){ })->bind('vote-save');
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);
}
}

View File

@@ -6,25 +6,45 @@
* Time: 11:42 * Time: 11:42
*/ */
function lastToArray($db,$query,$supported){
/*
* Methods to get an array to send to twig
*/
function lastToArray(&$query,$supported,$db,$idu=0){
$last = array(); $last = array();
while($var = dbw_fetch_array($db->conn,$query)){ $list = $query->fetchAll();
foreach($list as $var){
$like=0;
$save=0;
if($idu!=0){
$like = $db->iVote($idu,$var['IDC'],$var['Lang']);
$save = $db->iSave($idu,$var['IDC'],$var['Lang']);
}
$array = array $array = array
( "idc" => $var["IDC"], ( "idc" => $var["IDC"],
"lang" => $var["Lang"], "lang" => $var["Lang"],
"version" => $var["Version"], "version" => $var["Version"],
"name" => $var["Name"], "name" => $var["Name"],
"nick" => $var["nick"], "nick" => $var["nick"],
"lLang" => $supported[$var["Lang"]], "lLang" => $supported[$var["Lang"]][0],
"description" => $var["Description"], "description" => $var["Description"],
"code" => html_entity_decode($var["Code"]), "code" => html_entity_decode($var["Code"]),
"like" => $like,
"save" => $save
); );
array_push($last,$array); array_push($last,$array);
} }
return $last; return $last;
} }
function allCodeToArray($query,$supported){ function allCodeToArray(&$query,$supported,$db,$idu=0){
$like=0;
$save=0;
if($idu!=0){
$like = $db->iVote($idu,$query['IDC'],$query['Lang']);
$save = $db->iSave($idu,$query['IDC'],$query['Lang']);
}
$code = array( $code = array(
"idc" => $query['IDC'], "idc" => $query['IDC'],
"lang" => $query['Lang'], "lang" => $query['Lang'],
@@ -32,7 +52,7 @@ function allCodeToArray($query,$supported){
"name" => $query['Name'], "name" => $query['Name'],
"nick" => $query['nick'], "nick" => $query['nick'],
"idu" => $query['IDU'], "idu" => $query['IDU'],
"lLang" => $supported[$query['Lang']], "lLang" => $supported[$query['Lang']][0],
"description" => $query['Description'], "description" => $query['Description'],
"code" => html_entity_decode($query['Code']), "code" => html_entity_decode($query['Code']),
"input" => html_entity_decode($query['Input']), "input" => html_entity_decode($query['Input']),
@@ -40,18 +60,20 @@ function allCodeToArray($query,$supported){
"rows" => substr_count($query['Code'],"\n"), "rows" => substr_count($query['Code'],"\n"),
"extlib" => $query['UseExtLib'], "extlib" => $query['UseExtLib'],
"extlibver" => $query['UseExtLibVer'], "extlibver" => $query['UseExtLibVer'],
"like" => $like,
"save" => $save
); );
return $code; return $code;
} }
function otherImplementationToArray($db,$query,$supported){ function otherImplementationToArray(&$query,$supported){
$other = array(); $other = array();
while($var = dbw_fetch_array($db->conn,$query)){ foreach($query as $var){
$array = array $array = array
( "lang" => $var["Lang"], ( "lang" => $var["Lang"],
"version" => $var["Version"], "version" => $var["Version"],
"lLang" => $supported[$var["Lang"]], "lLang" => $supported[$var["Lang"]][0],
"code" => html_entity_decode($var["Code"]), "code" => html_entity_decode($var["Code"]),
); );
array_push($other,$array); array_push($other,$array);
@@ -59,6 +81,22 @@ function otherImplementationToArray($db,$query,$supported){
return $other; return $other;
} }
function otherVersionToArray($db,$query,$supported){ function savedToArray($query,$supported){
return lastToArray($db,$query,$supported); $saved = array();
foreach($query as $var){
$array = array
(
"idc" => $var['IDC'],
"lang" => $var['Lang'],
"version" => $var['Version'],
"lLang" => $supported[$var["Lang"]][0],
"name" => $var['Name']
);
array_push($saved,$array);
}
return $saved;
}
function otherVersionToArray(&$query,$supported,$db,$idu){
return lastToArray($query,$supported,$db,$idu);
} }

View File

@@ -1,235 +0,0 @@
<?php
/* DBWrapper.php - Version 1.4
This script is a simple wrapper for SQLite3, MySQL and PgSQL,
for make possible to use different BD systems without changing the functions.
For use, in dbw_connect you have to specify type of database (see below)
Avaiable functions:
dbw_connect ($tdb,$server,$database,$user,$password) -> some values are optional,
except $tdb and $server. $server is location in SQLite3
dbw_close ($conn) -> Closes connection
dbw_query ($conn,$query) -> Does a query
dbw_multi_query($conn,$multiquery) -> This does a multiquery without returning nothing.
Its used for load from a file/script
dbw_query_fetch_array ($conn,$query[,$typearray]) -> This do a query and fetch array, all in one function
($typearray optional, see below)
--After here, this functions works with result of a query--
dbw_fetch_array ($conn,$result[,$typearray]) -> Fetch a row. ($typearray optional, see below)
dbw_escape_string($conn,$string) -> Escapes conflictive chars for inserting into database
dbw_fetch_row and dbw_fetch_assoc ($conn,$result) -> Wrappers of dbw_fetch_array with row or assoc arguments
dbw_query_goto($conn,$result[,$row]) -> Goto X result of a query. If row is not specified, will be first row, 0
dbw_num_rows($conn,$result) -> Return number of results of a query
--This doesnt need a query--
dbw_last_id($conn) -> Returns last insert ID
dbw_insert_id($conn) -> Alias of dbw_last_id
$tdb (Type of database) can be:
-mysql/mysqli -> MySQL or MariaDB
-sqlite/sqlite3 -> Sqlite3
-PostgreSQL/PgSQL/pg -> PostgreSQL
$conn is the connection stablished in dbw_connect (ie. $conn = dbw_connect('sqlite','file.sqlite'))
$typearray is the form of array is returned, and not writed is default:
-ASSOC -> Associative indexes
-NUM -> Numeric indexes
-BOTH -> (Default) Both types of indexes
*/
/** Connect with database */
function dbw_connect($tdb,$server,$database=NULL,$user = NULL,$password=NULL){
switch ($tdb){
case "mysql":
case "mysqli":
$return[0] = mysqli_connect($server,$user,$password,$database) or die("Error de conexion");
$return[1] = "mysqli"; //Return standard mysqli for other funcs.
break;
case "sqlite":
case "sqlite3":
$return[0] = new SQLite3($server);
if (!$return[0]) die ("Error de conexion");
$return[1] = "sqlite"; //Return standard SQLite3 for other funcs.
break;
case "PostgreSQL":
case "pg":
case "PgSQL":
$return[0] = pg_connect("host=$server dbname=$database user=$user password=$password") or die ('Error de conexion: ' . pg_last_error());
$return[1] = "PgSQL"; //Return standard PgSQL for other funcs.
break;
default:
return false;
break;
}
return $return;
}
/** Escapes conflictive chars for inserting into database */
function dbw_escape_string($conn,$string){
switch ($conn[1]){
case "mysqli":
return mysqli_escape_string($conn[0],$string);
case "sqlite":
return SQLite3::escapeString($string);
case "PgSQL":
return pg_escape_string($string);
}
}
/** Make query */
function dbw_query($conn,$query){
switch ($conn[1]){
case "mysqli":
return mysqli_query($conn[0],$query);
break;
case "sqlite":
return $conn[0]->query($query);
break;
case "PgSQL":
return pg_query($query); //Last error (pg_last_error()) not implemented
break;
default:
return false;
break;
}
}
/** Fetch array from query */
function dbw_fetch_array($conn,$result,$typearray = NULL){
if ($result == false || $result == NULL){return false;}
switch ($conn[1]){
case "mysqli":
if ($typearray == NULL || $typearray == "BOTH"){return mysqli_fetch_array($result);}
if ($typearray == "ASSOC"){return mysqli_fetch_array($result,MYSQLI_ASSOC);}
if ($typearray == "NUM"){return mysqli_fetch_array($result,MYSQLI_NUM);}
break;
case "sqlite":
if ($typearray == NULL || $typearray == "BOTH"){return $result->fetchArray();}
if ($typearray == "ASSOC"){return $result->fetchArray(SQLITE3_ASSOC);}
if ($typearray == "NUM"){return $result->fetchArray(SQLITE3_NUM);}
break;
case "PgSQL":
if ($typearray == NULL || $typearray == "BOTH"){return pg_fetch_array($result);}
if ($typearray == "ASSOC"){return pg_fetch_array($result,NULL,PGSQL_ASSOC);}
if ($typearray == "NUM"){return pg_fetch_array($result,NULL,PGSQL_NUM);}
break;
default:
return false;
break;
}
}
/** Make query and fetch array */
function dbw_query_fetch_array($conn,$query){
switch ($conn[1]){
case "mysqli":
$query = mysqli_query($conn[0],$query);
if ($query == false || $query == NULL){return false;}
return mysqli_fetch_array($query);
break;
case "sqlite":
$query = $conn[0]->query($query);
if ($query == false || $query == NULL){return false;}
return $query->fetchArray();
break;
case "PgSQL":
$query = pg_query($query);
if ($query == false || $query == NULL){return false;}
return pg_fetch_array($query); //Last error (pg_last_error()) not implemented
break;
}
}
/** Goes a query to $row. $row starts in 0 as first row as if not specified */
function dbw_query_goto($conn,$result,$row = 0){
switch ($conn[1]){
case "mysqli":
mysqli_data_seek($result,$row);
break;
case "sqlite":
$result->reset();
$count = 0;
while ($count != $row){
$result->fetchArray();
}
break;
case "PgSQL":
pg_result_seek($result, $row);
break;
}
}
/** Does multiple querys in one command */
function dbw_multi_query($conn,$query){
switch ($conn[1]){
case "mysqli":
mysqli_multi_query($conn[0],$query);
break;
case "sqlite":
$conn[0]->exec($query);
break;
case "PgSQL":
die ("No soportado aun"); // TODO
break;
}
}
/** Returns the lastest Insert ID */
function dbw_last_id($conn){
switch ($conn[1]){
case "mysqli":
return mysqli_insert_id($conn[0]);
break;
case "sqlite":
return $conn[0]->lastInsertRowID();
break;
case "PgSQL":
return pg_fetch_array(pg_query("SELECT lastval();"))[0];
break;
}
}
/** Returns number of results */
function dbw_num_rows($conn,$result){
switch ($conn[1]){
case "mysqli":
return mysqli_num_rows($result);
break;
case "sqlite":
die ("No soportado aun"); // TODO
break;
case "PgSQL":
die ("No soportado aun"); // TODO
break;
}
}
/** Close connection */
function dbw_close($conn){
switch ($conn[1]){
case "mysqli":
mysqli_close($conn[0]);
break;
case "sqlite":
$conn[0]->close();
break;
case "PgSQL":
pg_close($conn[0]);
break;
}
}
/** Some internal wrappers for functions that are equal to other with arguments */
function dbw_fetch_assoc($conn,$result){return dbw_fetch_array($conn,$result,"ASSOC");}
function dbw_fetch_row($conn,$result){return dbw_fetch_array($conn,$result,"NUM");}
function dbw_insert_id($conn){return dbw_last_id($conn);}
?>

28
Source/src/domails.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
function newUser($email,$nick,$token){
global $app;
$header = "From: CodeShare <contacto@jkanetwork.com>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=UTF-8";
$to = $email;
$url = $app['url_generator']->generate('confirm',array('nick'=>$nick,'token'=>$token));
$correo = "<p>Wellcome $nick to CodeShare, the distribution platform for code fragments</p>
<p>To confirm your account please, click in the next link: <a href='https://codeshare.jkanetwork.com$url'>https://codeshare.jkanetwork.com$url</a></p>";
mail($to,"Confirm account to $nick",$correo,$header);
}
function restorePassword($email,$nick,$token,$timestamp){
global $app;
$header = "From: CodeShare <contacto@jkanetwork.com>\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=UTF-8";
$to = $email;
$url = $app['url_generator']->generate('restorePass',array('nick'=>$nick,'token'=>$token,'timestamp' => $timestamp));
$correo = "<p>Someone requested that the password be reset for you</p>
<p>If this was a mistake, just ignore this email and nothing will happen.</p>
<p>To restore your password please, click in the next link: <a href='https://codeshare.jkanetwork.com$url'>https://codeshare.jkanetwork.com$url</a></p>";
mail($to,"Restore password to $nick",$correo,$header);
}

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 = [];
@@ -36,4 +49,51 @@ function ksonParse($path){
}else{ }else{
die('<h3>Error, kson file not exist</h3>'); die('<h3>Error, kson file not exist</h3>');
} }
}
/**
* Group by $supported
*/
function groupByCategory($supported){
$grouped = Array();
foreach($supported as $key => $val){
if(!array_key_exists($val[1],$grouped)){
switch($val[1]){
case "Programming":
$num=5;
break;
case "Config":
case "Markup":
$num=2;
break;
case "Script":
case "Data":
case "Mathematics":
$num=1;
break;
}
$grouped[$val[1]] = Array(Array(),$num);
}
array_push($grouped[$val[1]][0],[$key,$val[0]]);
}
return $grouped;
}
function checkCaptcha($response){
$url = "https://www.google.com/recaptcha/api/siteverify";
//$post = 'secret='.'6Ld-C3cUAAAAAC6NhPw-rn4LsdM2PjKg255H6j0o&response='. $response;
$post = array('secret' => "6Ld-C3cUAAAAAC6NhPw-rn4LsdM2PjKg255H6j0o",
'response' => $response);
$options = array(
'http' => array(
"header" => "Content-type: application/x-www-form-urlencoded\r\n",
"method" => 'POST',
'content'=> http_build_query($post)
)
);
$context = stream_context_create($options);
$response = file_get_contents($url,false,$context);
return json_decode($response,true)["success"];
} }

View File

@@ -6,36 +6,74 @@
* Time: 19:06 * Time: 19:06
*/ */
function checklogin($email,$pass){ function checkInfo($request){
$db = new DB(); $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
*
* @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,DB $db){
$bool = $db->checkPass($email,$pass); $bool = $db->checkPass($email,$pass);
if($bool){ if($bool){
$idu = $db->loadIDU($email); $idu = $db->loadIDU($email);
$ROLE = $db->loadProfile($idu)['ROLE'];
if($ROLE==0)
return 'VALIDATE';
$token = RandomString(50); $token = RandomString(50);
$db->setToken($idu,$token); $db->setToken($idu,$token);
setcookie("token",$token); $_SESSION['token'] = $token;
setcookie("sessionID",$idu); $_SESSION['sessionID'] =$idu;
$db->close(); return '';
return true;
} }
$db->close(); return 'BAD';
return false;
} }
function register($email,$pass,$nick){ /**
$db = new DB(); * Register a new user in platform
$bool = $db->register($email,$pass,$nick); *
if($bool) { * @param $email new user's email
$db->close(); * @param $pass new user's password
return checklogin($email, $pass); * @param $nick new user's nickname
* @return bool true if email never exists before, else false
*/
function register($email,$emailre,$pass,$passre,$nick,$db){
if($emailre != $email || $pass != $passre)
return 'POST_ERROR';
$state = $db->register($email,$pass,$nick);
if($state == 'CORRECT') {
return "";
}else { }else {
$db->close(); return $state;
return false;
} }
} }
/**
* Logout user
*/
function logout(){ function logout(){
setcookie("token","",time()-3600); session_destroy(); //Logout
setcookie("sessionID",0,time()-3600); }
function getUser($app){
$user=null;
if(isset($_SESSION['sessionID'])){
if($app['data']->checkCookie($_SESSION['sessionID'],$_SESSION['token'])){
$user = $app['data']->loadProfile($_SESSION['sessionID']);
}
}
return $user;
} }

7
lab.yml Normal file
View File

@@ -0,0 +1,7 @@
root: /Source
config: data/
company: Code Solutions Project
database:
type: mysql
name: codeshare
lang: en