Dump from SVN

This commit is contained in:
Fándly Gergő
2019-08-08 16:58:29 +03:00
parent 712dbfbe28
commit 310f1b2438
71 changed files with 6883 additions and 0 deletions

2
subs/part/.htaccess Normal file
View File

@ -0,0 +1,2 @@
Order allow,deny
Deny from all

29
subs/part/.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/**
* /subs/part/.php
* @version 1.0
* @desc Users index part
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div class="center">
<p><?php echo $lang['index_content'] ?></p>
</div>

24
subs/part/_backend.php Normal file
View File

@ -0,0 +1,24 @@
<?php
/**
* /subs/part/_backend.php
* @version 1.0
* @desc backend for index
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/

109
subs/part/admin.php Normal file
View File

@ -0,0 +1,109 @@
<?php
/**
* /subs/admin.php
* @version 1.4
* @desc Admin tools
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div class="selfcenter">
<!-- import users -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_import_content', '#dd_import_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_import_img">
<span><?php echo $lang['importUsers'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_import_content">
<form method="POST" class="ajaxform" id="dd_import_form" onsubmit="adminImportUsers()">
<p><?php echo $lang['importnotes'] ?></p>
<input type="file" name="csv" id="csvFile" accept="text/csv" required>
<hr>
<button type="submit" form="dd_import_form"><?php echo $lang['ok'] ?></button>
</form>
<div id="statuses">
<div id="status_fileTooBig" style="display: none">
<img class="icon" src="./res/remove.png" alt="error">
<span><?php echo $lang['error'][11] ?></span>
</div>
<div id="status_uploading" style="display: none">
<p><?php echo $lang['uploading']."..." ?></p>
<div class="progressbar" id="uploadStatus" style="width: 90%; margin: auto">
<div style="width: 0%">
<span>0%</span>
</div>
</div>
</div>
<div id="status_uploadError" style="display: none">
<img class="icon" src="./res/remove.png" alt="error">
<span><?php echo $lang['error'][12] ?></span>
</div>
<div id="status_processing" style="display: none">
<p><?php echo $lang['processing']."..." ?></p>
<div class="progressbar" id="processStatus" style="width: 90%; margin: auto">
<div style="width: 0%">
<span>0%</span>
</div>
</div>
</div>
<div id="status_done" style="display: none">
<p><?php echo $lang['importdone'] ?></p>
</div>
</div>
</div>
</div>
<hr class="placeholder">
<!-- database stats -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_dbsize_content', '#dd_dbsize_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_dbsize_img">
<span><?php echo $lang['dbsize'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_dbsize_content">
<table class="table">
<thead>
<tr>
<th><?php echo $lang['dbname'] ?></th>
<th><?php echo $lang['size'] ?></th>
</tr>
</thead>
<tbody>
<?php
$sql=$db->prepare("SELECT table_schema AS dbname, ROUND(SUM(data_length+index_length)/1024/1024, 2) AS size FROM information_schema.tables GROUP BY table_schema");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['dbname']."</td>
<td>".$row['size']." MB</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
</div>

181
subs/part/admin_backend.php Normal file
View File

@ -0,0 +1,181 @@
<?php
/**
* /subs/admin_backend.php
* @version 1.6
* @desc backend for admin tools
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
//import/step1: upload file to server
if(isset($_FILES['import_file'])){
//time limit of 2 min
set_time_limit(120);
//get file size and compare it if JS has sucked
$size=$_FILES['import_file']['size'];
if($size>10000000){
functions::setError(11);
echo "error";
}
else{
//get temp file to hold it
$target=tempnam(sys_get_temp_dir(), "resmanImp_");
//move file
if(!move_uploaded_file($_FILES['import_file']['tmp_name'], $target)){
//something's wrong here
functions::setError(13);
echo "error";
}
else{
//count lines
$lines=0;
$file=fopen($target, "r");
while(!feof($file)){
$line=fgets($file);
$lines++;
}
fclose($file);
//prepare session to track everything
$progress=array("total_lines"=>$lines, "lines_processed"=>0);
if(isset($_SESSION['progress'])){
$_SESSION['progress'][$target]=$progress;
}
else{
$_SESSION['progress']=array();
$_SESSION['progress'][$target]=$progress;
}
//echo file name (which is process identifier as well) to be able to track it
echo $target;
}
}
}
//import/step2: start file procession
if(isset($_POST['process_file'])){
//insert multiple records with the same query
$rowPerQuery=40;
//set a looong time limit (20 min)
set_time_limit(1200);
//don't stop execution even if the connection drops
ignore_user_abort(true);
//open file
$file=fopen($_POST['process_file'], "r");
//a simple counter
$rowProcessed=0;
//build query string
$querystr="INSERT INTO users (username, fullname, accesslevel, class, password) VALUES";
for($i=0; $i<$rowPerQuery; $i++){
$querystr.=" (?, ?, ?, ?, ?), ";
}
$querystr=rtrim($querystr, ", ");
//buffer to hold before insert
$buffer=array();
$rowBuffered=0;
//prepare SQL query
$sql=$db->prepare($querystr);
while($data=fgetcsv($file, 1000, ",")){
if(count($data)!=5){
continue;
}
else{
//add row to buffer
array_push($buffer, $data[0], $data[1], $data[2], $data[3], $data[4]);
$rowBuffered++;
//if needed, execute query
if($rowBuffered==$rowPerQuery){
$sql->execute($buffer);
$buffer=array();
$rowBuffered=0;
}
}
//update counter
$rowProcessed++;
//update status and close session to release write protect
if(session_status()==PHP_SESSION_NONE){
session_start();
}
$_SESSION['progress'][$_POST['process_file']]['lines_processed']=$rowProcessed;
session_write_close();
}
//if something remained in buffer
if($rowBuffered!=0){
//build new query for the remained records
$querystr="INSERT INTO users (username, fullname, accesslevel, class, password) VALUES";
for($i=0; $i<$rowBuffered; $i++){
$querystr.=" (?, ?, ?, ?, ?), ";
}
$querystr=rtrim($querystr, ", ");
$sql=$db->prepare($querystr);
//execute everything left over
$sql->execute($buffer);
}
//close, delete file and die (I leave the session there intentionally. I hope nobody will spam the session with 1 record imports lol)
fclose($file);
unlink($_POST['process_file']);
//some bogus stuff that actually fixes the ERR_RESPONSE_HEADERS_TOO_BIG error, because PHP wants to send a ton of set-cookie headers
header_remove("Set-Cookie");
die();
}
//import/step3: check status
if(isset($_GET['import_progress'])){
if(!isset($_SESSION['progress'][$_GET['import_progress']])){
//if it does not exist, echo 0
echo "error";
}
else{
$status=$_SESSION['progress'][$_GET['import_progress']];
//calculate percent
$percent=round($status['lines_processed']*100/$status['total_lines'], 1);
//print percent
echo $percent."%";
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

56
subs/part/classes.php Normal file
View File

@ -0,0 +1,56 @@
<?php
/**
* /subs/classes.php
* @version 1.0
* @desc classes
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="classesDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="classesFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="classesFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<hr class="placeholder">
<!-- list -->
<div class="selfcenter" id="list">
<!-- list goes here -->
</div>
</div>

View File

@ -0,0 +1,96 @@
<?php
/**
* /subs/classes_backend.php
* @version 1.2
* @desc backend for classes
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE id<>1 and class<>''";
$filter_array=array();
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (class LIKE ? or username LIKE ? or fullname LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
}
$sql=$db->prepare("SELECT fullname, accesslevel, class FROM users ".$filter." ORDER BY class ASC, accesslevel DESC, fullname ASC");
$sql->execute($filter_array);
//echo table(s)
$first=true;
$rid=0;
$curClass="";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
if($curClass!=$row['class']){
$curClass=$row['class'];
if(!$first){
echo "
</tbody>
</table>
<hr class=\"placeholder\">
";
}
if($first){
$first=false;
}
$rid=1;
echo "
<div class=\"center\">
<h2>".$curClass."</h2>
</div>
<hr>
<table class=\"table\">
<thead>
<tr>
<th>".$lang['rowid']."</td>
<th>".$lang['fullname']."</td>
<th data-breakpoints=\"xs sm\">".$lang['role']."</td>
</tr>
</thead>
<tbody>
";
}
echo "
<tr>
<td>".$rid."</td>
<td>".$row['fullname']."</td>
<td>".($row['accesslevel']>0?$lang['headteacher']:$lang['student'])."</td>
</tr>
";
$rid++;
}
echo "
</tbody>
</table>
";
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

218
subs/part/contests.php Normal file
View File

@ -0,0 +1,218 @@
<?php
/**
* /subs/contests.php
* @version 1.0
* @desc Contests menu
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
$oid=0;
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="contestsDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="contestsFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<p><?php echo $lang['subject'].":" ?></p>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<input type=\"checkbox\" name=\"f_subject[]\" id=\"o_".$oid."\" value=\"".$row['id']."\">";
echo "<label for=\"o_".$oid."\">".$row['name_1']." / ".$row['name_2']."</label>";
echo "<br>";
$oid++;
}
?>
<hr>
<p><?php echo $lang['ministry_support'].":" ?></p>
<?php
for($i=0; $i<3; $i++){
echo "<input type=\"checkbox\" name=\"f_ministry[]\" id=\"o_".$oid."\" value=\"".$i."\">";
echo "<label for=\"o_".$oid."\">".$lang['ministry_'.$i]."</label>";
echo "<br>";
$oid++;
}
?>
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="contestsFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- new -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_new">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_new_content', '#dd_new_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_new_img">
<span><?php echo $lang['new'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_new_content">
<form method="POST" class="ajaxform" id="dd_new_form" onsubmit="contestsNew()">
<input type="hidden" name="new">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['subject'].": " ?></td>
<td>
<select name="subject" required>
<option value="-1" selected disabled><?php echo $lang['nothing'] ?></option>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['id']."\">".$row['name_1']." / ".$row['name_2']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><?php echo $lang['description'].": " ?></td>
<td><textarea name="description" placeholder="<?php echo $lang['description']."..." ?>" cols=50 rows=5></textarea></td>
</tr>
<tr>
<td><?php echo $lang['ministry_support'].": "?></td>
<td>
<?php
for($i=0; $i<3; $i++){
echo "<input type=\"radio\" name=\"ministry_support\" id=\"o_".$oid."\" value=\"".$i."\" required>";
echo "<label for=\"o_".$oid."\">".$lang['ministry_'.$i]."</label>";
echo "<br>";
$oid++;
}
?>
</td>
</tr>
<tr>
<td><?php echo $lang['ministry_place'].": " ?></td>
<td><input type="number" name="ministry_place" placeholder="<?php echo $lang['ministry_place']."..." ?>" min=0></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_new_form"><?php echo $lang['ok'] ?></button>
<button type="reset" form="dd_new_form" onclick="toggleDropdown('#dd_new_content', '#dd_new_img')"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- edit -->
<div class="dropdown selfcenter" style="width: 95%; display: none" id="dd_edit">
<div class="dropdown header">
<span><?php echo $lang['edit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<form method="POST" class="ajaxform" id="dd_edit_form" onsubmit="contestsSubmitEdit()">
<input type="hidden" name="edit">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['subject'].": " ?></td>
<td>
<select name="subject" required>
<option value="-1" selected disabled><?php echo $lang['nothing'] ?></option>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['id']."\">".$row['name_1']." / ".$row['name_2']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><?php echo $lang['description'].": " ?></td>
<td><textarea name="description" placeholder="<?php echo $lang['description']."..." ?>" cols=50 rows=5></textarea></td>
</tr>
<tr>
<td><?php echo $lang['ministry_support'].": "?></td>
<td>
<?php
for($i=0; $i<3; $i++){
echo "<input type=\"radio\" name=\"ministry_support\" id=\"o_".$oid."\" value=\"".$i."\" required>";
echo "<label for=\"o_".$oid."\">".$lang['ministry_'.$i]."</label>";
echo "<br>";
$oid++;
}
?>
</td>
</tr>
<tr>
<td><?php echo $lang['ministry_place'].": " ?></td>
<td><input type="number" name="ministry_place" placeholder="<?php echo $lang['ministry_place']."..." ?>" min=0></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_edit_form"><?php echo $lang['ok'] ?></button>
<button type="button" onclick="contestsCancelEdit()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- list -->
<div id="listHolder">
<select id="schoolyear" onchange="contestsFilterApply()">
<?php
$sql=$db->prepare("SELECT DISTINCT schoolyear FROM contests WHERE schoolyear<>:current ORDER BY schoolyear ASC");
$sql->execute(array(":current"=>$schoolyear));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['schoolyear']."\">".$row['schoolyear']."</option>";
}
echo "<option value=\"".$schoolyear."\" selected>".$schoolyear."</option>";
?>
</select>
<div id="list" class="selfcenter">
<!-- list goes here -->
</div>
</div>
</div>

View File

@ -0,0 +1,177 @@
<?php
/**
* /subs/contests_backend.php
* @version 1.0
* @desc backend for contests
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE c.id<>0 and c.schoolyear=?";
$filter_array=array($_GET['list']);
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (c.name_1 LIKE ? or c.name_2 LIKE ? or s.name_1 LIKE ? or s.name_2 LIKE ? or c.description LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
if(isset($_POST['f_subject'])){
for($i=0; $i<count($_POST['f_subject']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="c.subject=?";
array_push($filter_array, $_POST['f_subject'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_ministry'])){
for($i=0; $i<count($_POST['f_ministry']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="c.ministry_support=?";
array_push($filter_array, $_POST['f_ministry'][$i]);
}
$filter.=")";
}
}
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2, c.description, c.ministry_support, c.ministry_place FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) ".$filter." ORDER BY c.name_1 ASC, c.name_2 ASC");
$sql->execute($filter_array);
echo "
<table class=\"table\">
<thead>
<tr>
<th data-breakpoints=\"xs sm md\">".$lang['id']."</th>
<th>".$lang['name_1']."</th>
<th>".$lang['name_2']."</th>
<th data-breakpoints=\"xs sm\">".$lang['subject_1']."</th>
<th data-breakpoints=\"xs sm\">".$lang['subject_2']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['description']."</th>
<th data-breakpoints=\"xs sm\">".$lang['ministry_support']."</th>
<th data-breakpoints=\"xs sm\">".$lang['ministry_place']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['tools']."</th>
</tr>
</thead>
<tbody>
";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['name_1']."</td>
<td>".$row['name_2']."</td>
<td>".$row['subject_1']."</td>
<td>".$row['subject_2']."</td>
<td>".str_replace(array("\n"), array("<br>"), $row['description'])."</td>
<td>".$lang['ministry_'.$row['ministry_support']]."</td>
<td>".($row['ministry_support']>0?$row['ministry_place']:"-")."</td>
<td>
<button type=\"button\" onclick=\"contestsEdit(".$row['id'].")\">".$lang['edit']."</button>
<button type=\"button\" onclick=\"contestsDelete(".$row['id'].", this)\">".$lang['delete']."</button>
</td>
</tr>
";
}
echo "
</tbody>
</table>
";
}
if(isset($_POST['new'])){
$sql=$db->prepare("SELECT COUNT(id) AS count FROM contests WHERE name_1=:name_1 or name_2=:name_2");
$sql->execute(array(":name_1"=>$_POST['name_1'], ":name_2"=>$_POST['name_2']));
$row=$sql->fetch(PDO::FETCH_ASSOC);
if($row['count']>0){
functions::setError(8);
}
else{
$sql=$db->prepare("INSERT INTO contests (name_1, name_2, subject, description, ministry_support, ministry_place, schoolyear) VALUES (:n1, :n2, :subj, :desc, :ms, :mp, :sy)");
$sql->execute(array(":n1"=>$_POST['name_1'], ":n2"=>$_POST['name_2'], ":subj"=>$_POST['subject'], ":desc"=>$_POST['description'], ":ms"=>$_POST['ministry_support'], ":mp"=>$_POST['ministry_place'], ":sy"=>$schoolyear));
$res=$sql->rowCount();
if($res<1){
functions::setError(4);
}
else{
functions::setMessage(3);
}
}
}
if(isset($_POST['delete'])){
$sql=$db->prepare("DELETE FROM contests WHERE id=:id");
$sql->execute(array(":id"=>$_POST['delete']));
$res=$sql->rowCount();
if($res<1){
functions::setError(4);
}
else{
functions::setMessage(4);
}
}
if(isset($_GET['getdata'])){
$sql=$db->prepare("SELECT COUNT(id) AS count, id, name_1, name_2, subject, description, ministry_support, ministry_place FROM contests WHERE id=:id");
$sql->execute(array(":id"=>$_GET['getdata']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
echo json_encode($res);
}
}
if(isset($_POST['edit'])){
$sql=$db->prepare("SELECT COUNT(id) AS count FROM contests WHERE id=:id");
$sql->execute(array(":id"=>$_POST['edit']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
$sql=$db->prepare("UPDATE contests SET name_1=:n1, name_2=:n2, subject=:subj, description=:desc, ministry_support=:ms, ministry_place=:mp WHERE id=:id");
$sql->execute(array(":n1"=>$_POST['name_1'], ":n2"=>$_POST['name_2'], ":subj"=>$_POST['subject'], ":desc"=>$_POST['description'], ":ms"=>$_POST['ministry_support'], ":mp"=>$_POST['ministry_place'], ":id"=>$_POST['edit']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(5);
}
else{
functions::setError(4);
}
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

112
subs/part/phases.php Normal file
View File

@ -0,0 +1,112 @@
<?php
/**
* /subs/phases.php
* @version 1.0
* @desc phases menu
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="phasesDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="phasesFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="phasesFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<?php if($_SESSION['accesslevel']>=3): ?>
<!-- new FOR elevated -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_new">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_new_content', '#dd_new_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_new_img">
<span><?php echo $lang['new'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_new_content">
<form method="POST" class="ajaxform" id="dd_new_form" onsubmit="phasesNew()">
<input type="hidden" name="new">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_new_form"><?php echo $lang['ok'] ?></button>
<button type="reset" form="dd_new_form" onclick="toggleDropdown('#dd_new_content', '#dd_new_img')"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- edit -->
<div class="dropdown selfcenter" style="width: 95%; display: none" id="dd_edit">
<div class="dropdown header">
<span><?php echo $lang['edit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<form method="POST" class="ajaxform" id="dd_edit_form" onsubmit="phasesSubmitEdit()">
<input type="hidden" name="edit">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_edit_form"><?php echo $lang['ok'] ?></button>
<button type="button" onclick="phasesCancelEdit()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<?php endif ?>
<hr class="placeholder">
<!-- list -->
<div id="list" class="selfcenter">
<!-- list goes here -->
</div>
</div>

View File

@ -0,0 +1,157 @@
<?php
/**
* /subs/phases_backend.php
* @version 1.0
* @desc backend for phases
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE id<>0";
$filter_array=array();
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (name_1 LIKE ? or name_2 LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
}
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ".$filter." ORDER BY name_1 ASC, name_2 ASC");
$sql->execute($filter_array);
echo "
<table class=\"table\">
<thead>
<tr>
<th data-breakpoints=\"xs sm md\">".$lang['id']."</th>
<th>".$lang['name_1']."</th>
<th>".$lang['name_2']."</th>
".($_SESSION['accesslevel']>=3?"<th data-breakpoints=\"xs sm\">".$lang['tools']."</th>":"")."
</tr>
</thead>
<tbody>
";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['name_1']."</td>
<td>".$row['name_2']."</td>
".($_SESSION['accesslevel']>=3?"<td>
<button type=\"button\" onclick=\"phasesEdit(".$row['id'].")\">".$lang['edit']."</button>
<button type=\"button\" onclick=\"phasesDelete(".$row['id'].", this)\">".$lang['delete']."</button>
</td>":"")."
</tr>
";
}
echo "
</tbody>
</table>
";
}
if(isset($_POST['new'])){
if($_SESSION['accesslevel']<3){
functions::setError(401);
}
else{
$sql=$db->prepare("SELECT COUNT(id) AS count FROM phases WHERE name_1=:n1 or name_2=:n2");
$sql->execute(array(":n1"=>$_POST['name_1'], ":n2"=>$_POST['name_2']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']>0){
functions::setError(9);
}
else{
$sql=$db->prepare("INSERT INTO phases (name_1, name_2) VALUES (:n1, :n2)");
$sql->execute(array(":n1"=>$_POST['name_1'], ":n2"=>$_POST['name_2']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(3);
}
else{
functions::setError(4);
}
}
}
}
if(isset($_POST['delete'])){
if($_SESSION['accesslevel']<3){
functions::setError(401);
}
else{
$sql=$db->prepare("DELETE FROM phases WHERE id=:id");
$sql->execute(array(":id"=>$_POST['delete']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(4);
}
else{
functions::setError(4);
}
}
}
if(isset($_GET['getdata'])){
$sql=$db->prepare("SELECT COUNT(id) AS count, id, name_1, name_2 FROM phases WHERE id=:id");
$sql->execute(array(":id"=>$_GET['getdata']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
echo json_encode($res);
}
}
if(isset($_POST['edit'])){
if($_SESSION['accesslevel']<3){
functions::setError(401);
}
else{
$sql=$db->prepare("SELECT COUNT(id) AS count FROM phases WHERE id=:id");
$sql->execute(array(":id"=>$_POST['edit']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
$sql=$db->prepare("UPDATE phases SET name_1=:n1, name_2=:n2 WHERE id=:id");
$sql->execute(array(":n1"=>$_POST['name_1'], ":n2"=>$_POST['name_2'], ":id"=>$_POST['edit']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(5);
}
else{
functions::setError(4);
}
}
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

75
subs/part/profile.php Normal file
View File

@ -0,0 +1,75 @@
<?php
/**
* /subs/profile.php
* @version 1.0
* @desc profile menu
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div class="selfcenter">
<p><?php echo $lang['needlogout'] ?></p>
<hr class="palceholder">
<table class="selfcenter">
<tr>
<td><?php echo $lang['id'].": " ?></td>
<td><?php echo $_SESSION['id'] ?></td>
</tr>
<tr>
<td><?php echo $lang['username'].": " ?></td>
<td><?php echo $_SESSION['username'] ?></td>
</tr>
<tr>
<td><?php echo $lang['fullname'].": " ?></td>
<td><?php echo $_SESSION['fullname'] ?></td>
</tr>
<tr>
<td><?php echo $lang['accesslevel'].": " ?></td>
<td><?php echo $_SESSION['accesslevel'] ?></td>
</tr>
<tr>
<td><?php echo $lang['class'].": " ?></td>
<td><?php echo $_SESSION['class'] ?></td>
</tr>
<tr>
<td><?php echo $lang['perm_message'].": " ?></td>
<td><?php echo $_SESSION['perm_message']?$lang['ryes']:$lang['rno'] ?></td>
</tr>
</table>
<hr>
<hr class="placeholder">
<form method="POST" class="ajaxform center" id="editpasswd" autocomplete="off" onsubmit="profileSetNewPassword()">
<p><?php echo $lang['editpasswd'] ?></p>
<table class="selfcenter">
<tr>
<td><?php echo $lang['password'].": " ?></td>
<td><input type="password" name="password" placeholder="<?php echo $lang['password']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['password_confirm'].": " ?></td>
<td><input type="password" name="password_confirm" placeholder="<?php echo $lang['password_confirm']."..." ?>" required></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="editpasswd"><?php echo $lang['ok'] ?></button>
</form>
</div>

View File

@ -0,0 +1,49 @@
<?php
/**
* /subs/profile_backend.php
* @version 1.0
* @desc backend for profile
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_POST['password']) && isset($_POST['password_confirm'])){
if($_POST['password']!=$_POST['password_confirm']){
functions::setError(10);
}
else{
$sql=$db->prepare("UPDATE users SET password=:passwd WHERE id=:id");
$sql->execute(array(":passwd"=>PasswordStorage::create_hash($_POST['password']), ":id"=>$_SESSION['id']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(6);
}
else{
functions::setError(4);
}
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

631
subs/part/register.php Normal file
View File

@ -0,0 +1,631 @@
<?php
/**
* /subs/register.php
* @version 1.1
* @desc register menu -> the core
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
$oid=0;
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="registerDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="registerFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<p><?php echo $lang['student'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#studentSearch')">
<ul id="studentSearch">
<?php
$sql=$db->prepare("SELECT id, fullname, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_student[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['fullname']." (".$row['class'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<hr>
<p><?php echo $lang['contest'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#contestSearch')">
<ul id="contestSearch">
<?php
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2, c.schoolyear FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) ORDER BY c.schoolyear DESC, s.name_1 ASC, s.name_2 ASC, c.name_1 ASC, c.name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_contest[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['schoolyear']." - ".$row['name_1'].", ".$row['name_2']." (".$row['subject_1'].", ".$row['subject_2'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<hr>
<p><?php echo $lang['phase'].":" ?></p>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<input type=\"checkbox\" name=\"f_phase[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']."</label>
<br>
";
$oid++;
}
?>
<hr>
<p><?php echo $lang['teacher'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#teacherSearch')">
<ul id="teacherSearch">
<?php
$sql=$db->prepare("SELECT id, fullname FROM users WHERE id<>0 and accesslevel>0 ORDER BY fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_teacher[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['fullname']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="registerFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- new -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_new">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_new_content', '#dd_new_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_new_img">
<span><?php echo $lang['new'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_new_content">
<form method="POST" class="ajaxform" id="dd_new_form" onsubmit="registerNew()">
<input type="hidden" name="new">
<table>
<tr>
<td><?php echo $lang['student'].": " ?></td>
<td>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#studentSearchNew')">
<ul id="studentSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"student\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']." (".$row['class'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['contest'].": " ?></td>
<td>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#contestSearchNew')">
<ul id="contestSearchNew">
<?php
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2 FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) WHERE c.schoolyear=:sy ORDER BY s.name_1 ASC, s.name_2 ASC, c.name_1 ASC, c.name_2 ASC");
$sql->execute(array(":sy"=>$schoolyear));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"contest\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']." (".$row['subject_1'].", ".$row['subject_2'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['phase'].": " ?></td>
<td>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<input type=\"radio\" name=\"phase\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']."</label>
<br>
";
$oid++;
}
?>
</td>
</tr>
<tr>
<td><?php echo $lang['teacher'].": " ?></td>
<td>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#teacherSearchNew')">
<ul id="teacherSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname FROM users WHERE id<>0 and accesslevel>0 ORDER BY fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"teacher\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['place'].": " ?></td>
<td>
<?php
for($i=-3; $i<0; $i++){
echo "
<input type=\"radio\" name=\"place\" value=\"".$i."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$lang['places'][$i]."</label>
<br>
";
$oid++;
}
?>
<input type="radio" name="place" value="0" id="o_<?php echo $oid ?>" required>
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['custom'] ?></label>
<br>
<div id="registerCustomPlaceNew" style="display: none">
<span><?php echo $lang['custom'].": "?></span>
<input type="number" name="place_c" placeholder="<?php echo $lang['place']."..." ?>" min=1>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['mention'].": " ?></td>
<td><textarea name="mention" cols="50" rows="5" placeholder="<?php echo $lang['mention']."..." ?>"></textarea></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_new_form"><?php echo $lang['ok'] ?></button>
<button type="reset" form="dd_new_form" onclick="toggleDropdown('#dd_new_content', '#dd_new_img')"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- Export -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_export">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_export_content', '#dd_export_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_export_img">
<span><?php echo $lang['export'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_export_content">
<form method="POST" class="ajaxform" id="dd_export_form" onsubmit="registerExport()">
<h3><?php echo $lang['exportcolumn'].":" ?></h3>
<ul style="list-style: none">
<li>
<input type="checkbox" name="export[]" value="id" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['id'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="student" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['student'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="class" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['class'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="subject_1" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['subject_1'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="subject_2" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['subject_2'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="contest_1" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['contest_1'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="contest_2" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['contest_2'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="contest_desc" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['contest_desc'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="ministry_support" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['ministry_support'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="ministry_place" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['ministry_place'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="phase_1" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['phase_1'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="phase_2" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['phase_2'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="teacher" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['teacher'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="place" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['place'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="mention" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['mention'] ?></label>
</li>
<li>
<input type="checkbox" name="export[]" value="schoolyear" id="o_<?php echo $oid ?>">
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['schoolyear'] ?></label>
</li>
</ul>
<hr>
<h3><?php echo $lang['filter'].":" ?></h3>
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<p><?php echo $lang['student'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#studentSearch')">
<ul id="studentSearch">
<?php
$sql=$db->prepare("SELECT id, fullname, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_student[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['fullname']." (".$row['class'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<hr>
<p><?php echo $lang['contest'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#contestSearch')">
<ul id="contestSearch">
<?php
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2, c.schoolyear FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) ORDER BY c.schoolyear ASC, s.name_1 ASC, s.name_2 ASC, c.name_1 ASC, c.name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_contest[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['schoolyear']." - ".$row['name_1'].", ".$row['name_2']." (".$row['subject_1'].", ".$row['subject_2'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<hr>
<p><?php echo $lang['phase'].":" ?></p>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<input type=\"checkbox\" name=\"f_phase[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']."</label>
<br>
";
$oid++;
}
?>
<hr>
<p><?php echo $lang['teacher'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#teacherSearch')">
<ul id="teacherSearch">
<?php
$sql=$db->prepare("SELECT id, fullname FROM users WHERE id<>0 and accesslevel>0 ORDER BY fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_teacher[]\" value=\"".$row['id']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['fullname']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<hr>
<p><?php echo $lang['schoolyear'].":" ?></p>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#schoolyearSearch')">
<ul id="schoolyearSearch">
<?php
$sql=$db->prepare("SELECT DISTINCT schoolyear FROM register ORDER BY schoolyear ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"checkbox\" name=\"f_schoolyear[]\" value=\"".$row['schoolyear']."\" id=\"o_".$oid."\">
<label for=\"o_".$oid."\">".$row['schoolyear']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="submit" form="dd_export_form"><?php echo $lang['export'] ?></button>
<div id="export_progress" style="display: none">
<br>
<br>
<img class="icon" src="./res/loading.gif" alt="loading">
<span><?php echo $lang['preparing_download'] ?></span>
</div>
<div id="export_ready" style="display: none">
<br>
<br>
<span><?php echo $lang['download_ready'] ?></span>
<br>
<input type="hidden" id="download_file">
<button type="button" onclick="registerExportDownload()"><?php echo $lang['download'] ?></button>
</div>
</form>
</div>
</div>
<hr class="placeholder"
<!-- edit -->
<div class="dropdown selfcenter" style="width: 95%; display: none" id="dd_edit">
<div class="dropdown header">
<span><?php echo $lang['edit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<form method="POST" class="ajaxform" id="dd_edit_form" onsubmit="registerSubmitEdit()">
<input type="hidden" name="edit">
<table>
<tr>
<td><?php echo $lang['student'].": " ?></td>
<td>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#studentSearchNew')">
<ul id="studentSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"student\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']." (".$row['class'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['contest'].": " ?></td>
<td>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#contestSearchNew')">
<ul id="contestSearchNew">
<?php
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2 FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) ORDER BY s.name_1 ASC, s.name_2 ASC, c.name_1 ASC, c.name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"contest\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']." (".$row['subject_1'].", ".$row['subject_2'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['phase'].": " ?></td>
<td>
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<input type=\"radio\" name=\"phase\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']."</label>
<br>
";
$oid++;
}
?>
</td>
</tr>
<tr>
<td><?php echo $lang['teacher'].": " ?></td>
<td>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#teacherSearchNew')">
<ul id="teacherSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname FROM users WHERE id<>0 and accesslevel>0 ORDER BY fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"teacher\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['place'].": " ?></td>
<td>
<?php
for($i=-3; $i<0; $i++){
echo "
<input type=\"radio\" name=\"place\" value=\"".$i."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$lang['places'][$i]."</label>
<br>
";
$oid++;
}
?>
<input type="radio" name="place" value="0" id="o_<?php echo $oid ?>" required>
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['custom'] ?></label>
<br>
<div id="registerCustomPlaceEdit" style="display: none">
<span><?php echo $lang['custom'].": "?></span>
<input type="number" name="place_c" placeholder="<?php echo $lang['place']."..." ?>" min=1>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['mention'].": " ?></td>
<td><textarea name="mention" cols="50" rows="5" placeholder="<?php echo $lang['mention']."..." ?>"></textarea></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_edit_form"><?php echo $lang['ok'] ?></button>
<button type="button" onclick="registerCancelEdit()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<!-- submit new -->
<div class="dropdown selfcenter" style="width: 95%; display: none" id="dd_newSubmit">
<div class="dropdown header">
<span><?php echo $lang['newSubmit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<p><?php echo $lang['do_before_new_record'] ?></p>
<p><?php echo $lang['prev_found'].":" ?></p>
<table id="newSubmitPrevContent" style="text-align: left">
<thead>
<th><?php echo $lang['id'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['phase_1'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['phase_2'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['teacher'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['place'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['mention'] ?></th>
<th><?php echo $lang['tools'] ?></th>
</thead>
<tbody>
<!-- previous records -->
</tbody>
</table>
<hr>
<form method="POST" class="ajaxform" id="dd_newSubmit_form" onsubmit="registerNewSubmit()">
<input type="hidden" name="newSubmit">
<button type="submit"><?php echo $lang['finalize'] ?></button>
<button type="button" onclick="registerNewCancel()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- list -->
<div id="listHolder">
<select id="schoolyear" onchange="registerLoadList()">
<?php
$sql=$db->prepare("SELECT DISTINCT schoolyear FROM register WHERE schoolyear<>:current ORDER BY schoolyear ASC");
$sql->execute(array(":current"=>$schoolyear));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<option value=\"".$row['schoolyear']."\">".$row['schoolyear']."</option>";
}
echo "<option value=\"".$schoolyear."\" selected>".$schoolyear."</option>";
?>
</select>
<div id="list" class="selfcenter">
<!-- list goes here -->
</div>
</div>
</div>

View File

@ -0,0 +1,382 @@
<?php
/**
* /subs/register_backend.php
* @version 1.5
* @desc backend for register
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE r.id<>0 and r.schoolyear=?";
$filter_array=array($_GET['list']);
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (s.fullname LIKE ? or c.name_1 LIKE ? or c.name_2 LIKE ? or p.name_1 LIKE ? or p.name_2 LIKE ? or t.fullname LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
if(isset($_POST['f_student'])){
for($i=0; $i<count($_POST['f_student']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.student=?";
array_push($filter_array, $_POST['f_student'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_contest'])){
for($i=0; $i<count($_POST['f_contest']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.contest=?";
array_push($filter_array, $_POST['f_contest'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_phase'])){
for($i=0; $i<count($_POST['f_phase']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.phase=?";
array_push($filter_array, $_POST['f_phase'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_teacher'])){
for($i=0; $i<count($_POST['f_teacher']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.teacher=?";
array_push($filter_array, $_POST['f_teacher'][$i]);
}
$filter.=")";
}
}
$sql=$db->prepare("SELECT r.id, s.fullname AS student, s.class AS class, sb.name_1 AS subject_1, sb.name_2 AS subject_2, c.name_1 AS contest_1, c.name_2 AS contest_2, c.description AS contest_desc, c.ministry_support, c.ministry_place, p.name_1 AS phase_1, p.name_2 AS phase_2, t.fullname AS teacher, r.place, r.mention FROM register AS r INNER JOIN users AS s ON (s.id=r.student) INNER JOIN contests AS c ON (c.id=r.contest) INNER JOIN subjects AS sb ON (sb.id=c.subject) INNER JOIN phases AS p ON (p.id=r.phase) INNER JOIN users AS t ON (t.id=r.teacher) ".$filter." ORDER BY id ASC");
$sql->execute($filter_array);
echo "
<table class=\"table\">
<thead>
<tr>
<th data-breakpoints=\"xs sm md\">".$lang['id']."</th>
<th>".$lang['student']."</th>
<th>".$lang['class']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['subject_1']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['subject_2']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['contest_1']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['contest_2']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['contest_desc']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['ministry_support']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['ministry_place']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['phase_1']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['phase_2']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['teacher']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['place']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['mention']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['tools']."</th>
</tr>
</thead>
<tbody>
";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['student']."</td>
<td>".$row['class']."</td>
<td>".$row['subject_1']."</td>
<td>".$row['subject_2']."</td>
<td>".$row['contest_1']."</td>
<td>".$row['contest_2']."</td>
<td>".$row['contest_desc']."</td>
<td>".$lang['ministry_'.$row['ministry_support']]."</td>
<td>".($row['ministry_support']==0?"":$row['ministry_place'])."</td>
<td>".$row['phase_1']."</td>
<td>".$row['phase_2']."</td>
<td>".$row['teacher']."</td>
<td>".($row['place']<0?$lang['places'][$row['place']]:$row['place'])."</td>
<td>".str_replace(array("\n"), array("<br>"), $row['mention'])."</td>
<td>
<button type=\"button\" onclick=\"registerEdit(".$row['id'].")\">".$lang['edit']."</button>
<button type=\"button\" onclick=\"registerDelete(".$row['id'].", this)\">".$lang['delete']."</button>
</td>
</tr>
";
}
}
if(isset($_POST['delete'])){
$sql=$db->prepare("DELETE FROM register WHERE id=:id");
$sql->execute(array(":id"=>$_POST['delete']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(4);
}
else{
functions::setError(4);
}
}
if(isset($_POST['new'])){
$new=array("student"=>$_POST['student'], "contest"=>$_POST['contest'], "phase"=>$_POST['phase'], "teacher"=>$_POST['teacher'], "place"=>($_POST['place']<0?$_POST['place']:$_POST['place_c']), "mention"=>$_POST['mention']);
$sql=$db->prepare("SELECT r.id, p.name_1 AS phase_1, p.name_2 AS phase_2, t.fullname AS teacher, r.place, r.mention FROM register AS r INNER JOIN users AS s ON (s.id=r.student) INNER JOIN phases AS p ON (p.id=r.phase) INNER JOIN users AS t ON (t.id=r.teacher) WHERE r.student=:stud and r.contest=:cont ORDER BY r.id ASC");
$sql->execute(array(":stud"=>$_POST['student'], ":cont"=>$_POST['contest']));
$found="";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
$found.="
<tr>
<td>".$row['id']."</td>
<td>".$row['phase_1']."</td>
<td>".$row['phase_2']."</td>
<td>".$row['teacher']."</td>
<td>".($row['place']<0?$lang['places'][$row['place']]:$row['place'])."</td>
<td>".str_replace(array("\n"), array("<br>"), $row['mention'])."</td>
<td><button type=\"button\" onclick=\"registerDelete(".$row['id'].", this)\">".$lang['delete']."</button></td>
</tr>
";
}
$exp=array("params"=>$new, "prev"=>$found);
echo json_encode($exp);
}
if(isset($_POST['newSubmit'])){
$data=json_decode($_POST['newSubmit']);
$sql=$db->prepare("INSERT INTO register (student, contest, phase, teacher, place, mention, schoolyear) VALUES (:stud, :cont, :phase, :teacher, :place, :mention, :sy)");
$sql->execute(array(":stud"=>$data->student, ":cont"=>$data->contest, ":phase"=>$data->phase, ":teacher"=>$data->teacher, ":place"=>$data->place, ":mention"=>$data->mention, ":sy"=>$schoolyear));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(3);
}
else{
functions::setError(4);
}
}
if(isset($_GET['getdata'])){
$sql=$db->prepare("SELECT COUNT(id) AS count, id, student, contest, phase, teacher, place, mention FROM register WHERE id=:id");
$sql->execute(array(":id"=>$_GET['getdata']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
echo json_encode($res);
}
}
if(isset($_POST['edit'])){
$sql=$db->prepare("SELECT COUNT(id) AS count FROM register WHERE id=:id");
$sql->execute(array(":id"=>$_POST['edit']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
$sql=$db->prepare("UPDATE register SET student=:stud, contest=:cont, phase=:phase, teacher=:teacher, place=:place, mention=:mention WHERE id=:id");
$sql->execute(array(":stud"=>$_POST['student'], ":cont"=>$_POST['contest'], ":phase"=>$_POST['phase'], ":teacher"=>$_POST['teacher'], ":place"=>($_POST['place']<0?$_POST['place']:$_POST['place_c']), ":mention"=>$_POST['mention'], ":id"=>$_POST['edit']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(5);
}
else{
functions::setError(4);
}
}
}
if(isset($_POST['export'])){
//allow to run for a long time since this is a long process. 10 minute is more than enough
set_time_limit(600);
$filter="WHERE r.id<>0";
$filter_array=array();
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (s.fullname LIKE ? or c.name_1 LIKE ? or c.name_2 LIKE ? or p.name_1 LIKE ? or p.name_2 LIKE ? or t.fullname LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
if(isset($_POST['f_student'])){
for($i=0; $i<count($_POST['f_student']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.student=?";
array_push($filter_array, $_POST['f_student'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_contest'])){
for($i=0; $i<count($_POST['f_contest']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.contest=?";
array_push($filter_array, $_POST['f_contest'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_phase'])){
for($i=0; $i<count($_POST['f_phase']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.phase=?";
array_push($filter_array, $_POST['f_phase'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_teacher'])){
for($i=0; $i<count($_POST['f_teacher']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.teacher=?";
array_push($filter_array, $_POST['f_teacher'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_schoolyear'])){
for($i=0; $i<count($_POST['f_schoolyear']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="r.schoolyear=?";
array_push($filter_array, $_POST['f_schoolyear'][$i]);
}
$filter.=")";
}
}
$sql=$db->prepare("SELECT r.id, s.fullname AS student, s.class AS class, sb.name_1 AS subject_1, sb.name_2 AS subject_2, c.name_1 AS contest_1, c.name_2 AS contest_2, c.description AS contest_desc, c.ministry_support, c.ministry_place, p.name_1 AS phase_1, p.name_2 AS phase_2, t.fullname AS teacher, r.place, r.mention, r.schoolyear FROM register AS r INNER JOIN users AS s ON (s.id=r.student) INNER JOIN contests AS c ON (c.id=r.contest) INNER JOIN subjects AS sb ON (sb.id=c.subject) INNER JOIN phases AS p ON (p.id=r.phase) INNER JOIN users AS t ON (t.id=r.teacher) ".$filter." ORDER BY r.schoolyear ASC, subject_1 ASC, contest_1 ASC, student ASC");
$sql->execute($filter_array);
//setting up file
$exp=$BOM;
$exp.="\"".strtr($config['general']['title'], array("\""=>"\"\""))."\"\n";
$exp.="\"".strtr($config['general']['org'], array("\""=>"\"\""))."\"\n";
$exp.="\"".strtr($lang['exported'], array("\""=>"\"\"")).": ".date("Y-m-d H:i:s")."\"\n\n";
//build header
$header="";
foreach($_POST['export'] as $e){
$header.="\"".strtr($lang[$e], array("\"", "\"\""))."\",";
}
$header=rtrim($header, ",");
$exp.=$header."\n";
//build content
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
$push="";
foreach($_POST['export'] as $e){
if($e=="ministry_support"){
$push.="\"".strtr($lang['ministry_'.$row['ministry_support']], array("\""=>"\"\""))."\",";
}
else if($e=="ministry_place"){
$push.="\"".strtr($row['ministry_support']==0?"":$row['ministry_place'], array("\""=>"\"\""))."\",";
}
else if($e=="place"){
$push.="\"".strtr($row['place']<0?$lang['places'][$row['place']]:$row['place'], array("\""=>"\"\""))."\",";
}
else{
$push.="\"".strtr($row[$e], array("\""=>"\"\""))."\",";
}
}
$push=rtrim($push, ",");
$exp.=$push."\n";
}
//save it to a temporary file
$file=tempnam(sys_get_temp_dir(), "resmanExp_");
file_put_contents($file, $exp);
//return file name for download
echo $file;
}
if(isset($_GET['expdownload'])){
if(!file_exists($_GET['expdownload'])){
functions::setError(404);
header("Location: ".$_SERVER['HTTP_REFERER']);
}
else{
//download exported file
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename='".$config['general']['title']."_export_".date("Y-m-d H-i-s").".csv'");
readfile($_GET['expdownload']);
unlink($_GET['expdownload']);
die();
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

112
subs/part/subjects.php Normal file
View File

@ -0,0 +1,112 @@
<?php
/**
* /subs/subjects.php
* @version 1.2
* @desc Subjects menu
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="subjectsDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="subjectsFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="subjectsFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<?php if($_SESSION['accesslevel']>=3): ?>
<!-- new subject (for elevated users) -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_new">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_new_content', '#dd_new_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_new_img">
<span><?php echo $lang['new'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_new_content">
<form method="POST" class="ajaxform" id="dd_new_form" onsubmit="subjectsNew()">
<input type="hidden" name="new">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_new_form"><?php echo $lang['ok'] ?></button>
<button type="reset" form="dd_new_form" onclick="toggleDropdown('#dd_new_content', '#dd_new_img')"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- edit -->
<div class="dropdown selfcenter" style="width: 95%; display: none" id="dd_edit">
<div class="dropdown header">
<span><?php echo $lang['edit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<form method="POST" class="ajaxform" id="dd_edit_form" onsubmit="subjectsSubmitEdit()">
<input type="hidden" name="edit">
<table>
<tr>
<td><?php echo $lang['name_1'].": " ?></td>
<td><input type="text" name="name_1" placeholder="<?php echo $lang['name_1']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['name_2'].": " ?></td>
<td><input type="text" name="name_2" placeholder="<?php echo $lang['name_2']."..." ?>" required></td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_edit_form"><?php echo $lang['ok'] ?></button>
<button type="button" onclick="subjectsCancelEdit()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<?php endif ?>
<hr class="placeholder">
<!-- list -->
<div id="list" class="selfcenter">
<!-- list goes here -->
</div>
</div>

View File

@ -0,0 +1,139 @@
<?php
/**
* /subs/subjects_backend.php
* @version 1.1
* @desc backend for subjects
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE id<>0";
$filter_array=array();
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
$filter.=" and (name_1 LIKE ? or name_2 LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
$sql=$db->prepare("SELECT id, name_1, name_2 FROM subjects ".$filter." ORDER BY name_1 ASC, name_2 ASC");
$sql->execute($filter_array);
//print list
echo "
<table class=\"table\">
<thead>
<tr>
<th>".$lang['id']."</th>
<th>".$lang['name_1']."</th>
<th>".$lang['name_2']."</th>
".($_SESSION['accesslevel']>=3?"<th>".$lang['tools']."</th>":"")."
</tr>
</thead>
<tbody>
";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['name_1']."</td>
<td>".$row['name_2']."</td>
".($_SESSION['accesslevel']>=3?"<td>
<button type=\"button\" onclick=\"subjectsEdit(".$row['id'].")\">".$lang['edit']."</button>
<button type=\"button\" onclick=\"subjectsDelete(".$row['id'].", this)\">".$lang['delete']."</button>
</td>":"")."
</tr>
";
}
}
if(isset($_POST['new'])){
$sql=$db->prepare("SELECT count(id) AS count FROM subjects WHERE name_1=:name_1 or name_2=:name_2");
$sql->execute(array(":name_1"=>$_POST['name_1'], ":name_2" =>$_POST['name_2']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']>0){
functions::setError(7);
}
else{
$sql=$db->prepare("INSERT INTO subjects (name_1, name_2) VALUES (:name_1, :name_2)");
$sql->execute(array(":name_1"=>$_POST['name_1'], ":name_2"=>$_POST['name_2']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(3);
}
else{
functions::setError(4);
}
}
}
if(isset($_POST['delete'])){
$sql=$db->prepare("DELETE FROM subjects WHERE id=:id");
$sql->execute(array(":id"=>$_POST['delete']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(4);
}
else{
functions::setError(4);
}
}
if(isset($_GET['getdata'])){
$sql=$db->prepare("SELECT COUNT(id) AS count, id, name_1, name_2 FROM subjects WHERE id=:id");
$sql->execute(array(":id"=>$_GET['getdata']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
echo json_encode($res);
}
}
if(isset($_POST['edit'])){
$sql=$db->prepare("SELECT COUNT(id) AS count FROM subjects WHERE id=:id");
$sql->execute(array(":id"=>$_POST['edit']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
$sql=$db->prepare("UPDATE subjects SET name_1=:name_1, name_2=:name_2 WHERE id=:id");
$sql->execute(array(":name_1"=>$_POST['name_1'], ":name_2"=>$_POST['name_2'], ":id"=>$_POST['edit']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(5);
}
else{
functions::setError(4);
}
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

189
subs/part/users.php Normal file
View File

@ -0,0 +1,189 @@
<?php
/**
* /subs/users.php
* @version 2.0
* @desc users editor
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
$oid=0;
?>
<div class="selfcenter">
<!-- language for jquery -->
<span id="usersDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<!-- filter -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_filter">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_filter_content', '#dd_filter_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_filter_img">
<span><?php echo $lang['filter'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_filter_content">
<form method="POST" class="ajaxform" id="dd_filter_form" onsubmit="usersFilterApply()">
<input type="hidden" name="filter">
<p><?php echo $lang['search'].":" ?></p>
<input type="text" name="f_search" placeholder="<?php echo $lang['search']."..." ?>">
<hr>
<p><?php echo $lang['class'].":" ?></p>
<?php
$sql=$db->prepare("SELECT DISTINCT class FROM users ORDER BY class ASC");
$sql->execute();
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<input type=\"checkbox\" name=\"f_class[]\" id=\"o_".$oid."\" value=\"".$res['class']."\">";
echo "<label for=\"o_".$oid."\">".($res['class']!=""?$res['class']:"<<".$lang['empty'].">>")."</label>";
echo "<br>";
$oid++;
}
?>
<hr>
<p><?php echo $lang['accesslevel'].":" ?></p>
<?php
$sql=$db->prepare("SELECT DISTINCT accesslevel FROM users ORDER BY accesslevel ASC");
$sql->execute();
while($res=$sql->fetch(PDO::FETCH_ASSOC)){
echo "<input type=\"checkbox\" name=\"f_accesslevel[]\" id=\"o_".$oid."\" value=\"".$res['accesslevel']."\">";
echo "<label for=\"o_".$oid."\">".$res['accesslevel']."</label>";
echo "<br>";
$oid++;
}
?>
<hr>
<button type="submit" form="dd_filter_form"><?php echo $lang['apply'] ?></button>
<button type="button" onclick="usersFilterReset()"><?php echo $lang['reset'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- new -->
<div class="dropdown selfcenter" style="width: 95%" id="dd_new">
<div class="dropdown header">
<a onclick="toggleDropdown('#dd_new_content', '#dd_new_img')">
<img class="icon" src="./res/plus.png" alt="plusminus" id="dd_new_img">
<span><?php echo $lang['new'] ?></span>
</a>
</div>
<div class="dropdown content" id="dd_new_content">
<form method="POST" class="ajaxform" id="dd_new_form" onsubmit="usersNew()" autocomplete="off">
<input type="hidden" name="new">
<table>
<tr>
<td><?php echo $lang['username'].": " ?></td>
<td><input type="text" name="username" placeholder="<?php echo $lang['username']."..." ?>"></td>
</tr>
<tr>
<td><?php echo $lang['fullname'].": " ?></td>
<td><input type="text" name="fullname" placeholder="<?php echo $lang['fullname']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['accesslevel'].": " ?></td>
<td><input type="number" name="accesslevel" placeholder="<?php echo $lang['accesslevel']."..." ?>" value=0 min=0 max=4 required></td>
</tr>
<tr>
<td>
<span><?php echo $lang['class'].": " ?></span>
<br>
<span style="font-size: 0.8em"><?php echo $lang['classformat'] ?></span>
</td>
<td><input type="text" name="class" placeholder="<?php echo $lang['class']."..." ?>"></td>
</tr>
<tr>
<td>
<span><?php echo $lang['password'].": " ?></span>
<br>
<span style="font-size: 0.8em"><?php echo $lang['passwordhint'] ?></span>
</td>
<td><input type="text" name="password" placeholder="<?php echo $lang['password']."..." ?>"></td>
</tr>
<tr>
<td><?php echo $lang['perm_message'].": " ?></td>
<td>
<div class="checkbox">
<input type="checkbox" name="perm_message" id="o_<?php echo $oid ?>" checked>
<label for="o_<?php echo $oid; $oid++ ?>"></label>
</div>
</td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_new_form"><?php echo $lang['ok'] ?></button>
<button type="reset" form="dd_new_form" onclick="toggleDropdown('#dd_new_content', '#dd_new_img')"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- edit -->
<div class="dropdown selfcenter" id="dd_edit" style="width: 95%; display: none" id="dd_edit">
<div class="dropdown header">
<span><?php echo $lang['edit'] ?></span>
</div>
<div class="dropdown content" style="display: block">
<form method="POST" class="ajaxform" id="dd_edit_form" onsubmit="usersSubmitEdit()" autocomplete="off">
<input type="hidden" name="edit">
<table>
<tr>
<td><?php echo $lang['username'].": " ?></td>
<td><input type="text" name="username" placeholder="<?php echo $lang['username']."..." ?>"></td>
</tr>
<tr>
<td><?php echo $lang['fullname'].": " ?></td>
<td><input type="text" name="fullname" placeholder="<?php echo $lang['fullname']."..." ?>" required></td>
</tr>
<tr>
<td><?php echo $lang['accesslevel'].": " ?></td>
<td><input type="number" name="accesslevel" placeholder="<?php echo $lang['accesslevel']."..." ?>" value=0 min=0 max=4 required></td>
</tr>
<tr>
<td><?php echo $lang['class'].": " ?></td>
<td><input type="text" name="class" placeholder="<?php echo $lang['class']."..." ?>"></td>
</tr>
<tr>
<td>
<span><?php echo $lang['password'].": " ?></span>
<br>
<span style="font-size: 0.8em"><?php echo $lang['passwordhintedit'] ?></span>
</td>
<td><input type="text" name="password" placeholder="<?php echo $lang['password']."..." ?>"></td>
</tr>
<tr>
<td><?php echo $lang['perm_message'].": " ?></td>
<td>
<div class="checkbox">
<input type="checkbox" name="perm_message" id="o_<?php echo $oid ?>" checked>
<label for="o_<?php echo $oid; $oid++ ?>"></label>
</div>
</td>
</tr>
</table>
<br>
<br>
<button type="submit" form="dd_edit_form"><?php echo $lang['ok'] ?></button>
<button type="button" onclick="usersCancelEdit()"><?php echo $lang['cancel'] ?></button>
</form>
</div>
</div>
<hr class="placeholder">
<!-- list -->
<div class="selfcenter" id="list">
<!-- list goes here -->
</div>
</div>

206
subs/part/users_backend.php Normal file
View File

@ -0,0 +1,206 @@
<?php
/**
* /subs/part/users_backend.php
* @version 2.1
* @desc users backend
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
try{
if(isset($_GET['list'])){
$filter="WHERE id<>1";
$filter_array=array();
if(isset($_POST['filter'])){
if(isset($_POST['f_search'])){
if($_POST['f_search']!=""){
$filter.=" and (username LIKE ? or fullname LIKE ? or class LIKE ?)";
array_push($filter_array, "%".$_POST['f_search']."%", "%".$_POST['f_search']."%", "%".$_POST['f_search']."%");
}
}
if(isset($_POST['f_class'])){
for($i=0; $i<count($_POST['f_class']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="class=?";
array_push($filter_array, $_POST['f_class'][$i]);
}
$filter.=")";
}
if(isset($_POST['f_accesslevel'])){
for($i=0; $i<count($_POST['f_accesslevel']); $i++){
if($i==0){
$filter.=" and (";
}
else{
$filter.=" or ";
}
$filter.="accesslevel=?";
array_push($filter_array, $_POST['f_accesslevel'][$i]);
}
$filter.=")";
}
}
$sql=$db->prepare("SELECT id, username, fullname, accesslevel, class, perm_message FROM users ".$filter." ORDER BY class ASC, fullname ASC, accesslevel ASC");
$sql->execute($filter_array);
echo "
<table class=\"table\">
<thead>
<tr>
<th data-breakpoints=\"xs sm md\">".$lang['id']."</th>
<th data-breakpoints=\"xs sm\">".$lang['username']."</th>
<th>".$lang['fullname']."</th>
<th data-breakpoints=\"xs sm\">".$lang['accesslevel']."</th>
<th>".$lang['class']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['perm_message']."</th>
<th data-breakpoints=\"xs sm md\">".$lang['tools']."</th>
</tr>
</thead>
<tbody>
";
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['username']."</td>
<td>".$row['fullname']."</td>
<td>".$row['accesslevel']."</td>
<td>".$row['class']."</td>
<td>".($row['perm_message']?$lang['ryes']:$lang['rno'])."</td>
<td>
<button type=\"button\" onclick=\"usersEdit(".$row['id'].")\">".$lang['edit']."</button>
<button type=\"button\" onclick=\"usersDelete(".$row['id'].", this)\">".$lang['delete']."</button>
</td>
</tr>
";
}
echo "
</tbody>
</table>
";
}
if(isset($_POST['new'])){
if($_POST['username']!=""){
$sql=$db->prepare("SELECT COUNT(id) AS count FROM users WHERE username=:uname");
$sql->execute(array(":uname"=>$_POST['username']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']>0){
functions::setError(5);
}
}
$password;
if($_POST['password']=="0"){
$password=functions::randomString(6);
}
else{
$password=$_POST['password'];
}
$pm=isset($_POST['perm_message']);
$sql=$db->prepare("INSERT INTO users (username, fullname, accesslevel, class, password, perm_message) VALUES (:uname, :fname, :al, :class, :passwd, :pm)");
$sql->execute(array(":uname"=>$_POST['username'], ":fname"=>$_POST['fullname'], ":al"=>$_POST['accesslevel'], ":class"=>$_POST['class'], ":passwd"=>PasswordStorage::create_hash($_POST['password']), ":pm"=>$pm));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(3);
}
else{
functions::setError(4);
}
}
if(isset($_GET['getdata'])){
$sql=$db->prepare("SELECT COUNT(id) AS count, id, username, fullname, accesslevel, class, perm_message FROM users WHERE id=:id");
$sql->execute(array(":id"=>$_GET['getdata']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
if($res['count']<1){
functions::setError(6);
}
else{
echo json_encode($res);
}
}
if(isset($_POST['edit'])){
$sql=$db->prepare("SELECT COUNT(id) AS count FROM users WHERE id=:id");
$sql->execute(array(":id"=>$_POST['edit']));
$res=$sql->fetch(PDO::FETCH_ASSOC);
$pm=isset($_POST['perm_message']);
if($res['count']<1){
functions::setError(6);
}
else{
$sql=$db->prepare("UPDATE users SET username=:uname, fullname=:fname, accesslevel=:al, class=:class, perm_message=:pm WHERE id=:id");
$sql->execute(array(":uname"=>$_POST['username'], ":fname"=>$_POST['fullname'], ":al"=>$_POST['accesslevel'], ":class"=>$_POST['class'], ":pm"=>$pm, ":id"=>$_POST['edit']));
$res1=$sql->rowCount();
//check if password needs update
if($_POST['password']==""){
$res2=true;
}
else{
$password;
if($_POST['password']=="0"){
$password=functions::randomString(6);
}
else{
$password=$_POST['password'];
}
$sql=$db->prepare("UPDATE users SET password=:passwd WHERE id=:id");
$sql->execute(array(":passwd"=>PasswordStorage::create_hash($password), ":id"=>$_POST['edit']));
$res2=$sql->rowCount();
}
if($res1 && $res2){
functions::setMessage(5);
}
else{
functions::setError(4);
}
}
}
if(isset($_POST['delete'])){
$sql=$db->prepare("DELETE FROM users WHERE id=:id");
$sql->execute(array(":id"=>$_POST['delete']));
$res=$sql->rowCount();
if($res>0){
functions::setMessage(4);
}
else{
functions::setError(4);
}
}
}
catch(Exception $e){
functions::setError(500);
error_log($e);
}

242
subs/part/wizard.php Normal file
View File

@ -0,0 +1,242 @@
<?php
/**
* /subs/wizard.php
* @version 1.1
* @desc wizard for easy data input
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
$oid=0;
?>
<div class="selfcenter">
<!-- language, config -->
<span id="wizardDeleteConfirm" style="display: none"><?php echo $lang['delete_confirm'] ?></span>
<span id="wizardCurrentId" style="display: none"><?php echo $_SESSION['id'] ?></span>
<!-- instructions -->
<p><?php echo $lang['wizinst'] ?></p>
<!-- steps -->
<div id="steps">
<form method="POST" class="ajaxform" id="wizform" autocomplete="off">
<input type="hidden" name="new">
<!-- step1/student -->
<div id="step1" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">1</span>
<span><?php echo $lang['wiz_step1'] ?></span>
</div>
<div class="dropdown content" id="step1_content" style="display: block">
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#studentSearchNew')">
<ul id="studentSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"student\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']." (".$row['class'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step2/contest -->
<div id="step2" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">2</span>
<span><?php echo $lang['wiz_step2'] ?></span>
</div>
<div class="dropdown content" id="step2_content">
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..." ?>" onkeyup="search(this, '#contestSearchNew')">
<ul id="contestSearchNew">
<?php
$sql=$db->prepare("SELECT c.id, c.name_1, c.name_2, s.name_1 AS subject_1, s.name_2 AS subject_2 FROM contests AS c INNER JOIN subjects AS s ON (s.id=c.subject) WHERE c.schoolyear=:sy ORDER BY s.name_1 ASC, s.name_2 ASC, c.name_1 ASC, c.name_2 ASC");
$sql->execute(array(":sy"=>$schoolyear));
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"contest\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']." (".$row['subject_1'].", ".$row['subject_2'].")</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step3/phase -->
<div id="step3" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">3</span>
<span><?php echo $lang['wiz_step3'] ?></span>
</div>
<div class="dropdown content" id="step3_content">
<?php
$sql=$db->prepare("SELECT id, name_1, name_2 FROM phases ORDER BY name_1 ASC, name_2 ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<input type=\"radio\" name=\"phase\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['name_1'].", ".$row['name_2']."</label>
<br>
";
$oid++;
}
?>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step4/teacher -->
<div id="step4" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">4</span>
<span><?php echo $lang['wiz_step4'] ?></span>
</div>
<div class="dropdown content" id="step4_content">
<button type="button" onclick="wizardSelectMeAsTeacher()"><?php echo $lang['selectme'] ?></button>
<br>
<br>
<div class="searchbox">
<input type="text" form="" placeholder="<?php echo $lang['search']."..."?>" onkeyup="search(this, '#teacherSearchNew')">
<ul id="teacherSearchNew">
<?php
$sql=$db->prepare("SELECT id, fullname FROM users WHERE id<>0 and accesslevel>0 ORDER BY fullname ASC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<li>
<input type=\"radio\" name=\"teacher\" value=\"".$row['id']."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$row['fullname']."</label>
</li>
";
$oid++;
}
?>
</ul>
</div>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step5/place -->
<div id="step5" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">5</span>
<span><?php echo $lang['wiz_step5'] ?></span>
</div>
<div class="dropdown content" id="step5_content">
<?php
for($i=-3; $i<0; $i++){
echo "
<input type=\"radio\" name=\"place\" value=\"".$i."\" id=\"o_".$oid."\" required>
<label for=\"o_".$oid."\">".$lang['places'][$i]."</label>
<br>
";
$oid++;
}
?>
<input type="radio" name="place" value="0" id="o_<?php echo $oid ?>" required>
<label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['custom'] ?></label>
<br>
<div id="registerCustomPlaceNew" style="display: none">
<span><?php echo $lang['custom'].": "?></span>
<input type="number" name="place_c" placeholder="<?php echo $lang['place']."..." ?>" min=1>
</div>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardNextStep(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
<br>
<!-- step6/mention -->
<div id="step6" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">6</span>
<span><?php echo $lang['wiz_step6'] ?></span>
</div>
<div class="dropdown content" id="step6_content">
<textarea name="mention" cols="50" rows="5" placeholder="<?php echo $lang['mention']."..." ?>"></textarea>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardLoadPrevRecords(this)" style="float: right"><?php echo $lang['proceed'] ?></button>
</div>
</div>
</form>
<br>
<!-- step7/finalize -->
<div id="step7" class="dropdown selfcenter" style="width: 95%">
<div class="dropdown header">
<span class="number">7</span>
<span><?php echo $lang['wiz_step7'] ?></span>
</div>
<div class="dropdown content" id="step7_content">
<input type="hidden" name="recordParams">
<p><?php echo $lang['do_before_new_record'] ?></p>
<p><?php echo $lang['prev_found'].":" ?></p>
<table id="wizardPrevContent" style="text-align: left">
<thead>
<th><?php echo $lang['id'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['phase_1'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['phase_2'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['teacher'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['place'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['mention'] ?></th>
<th><?php echo $lang['tools'] ?></th>
</thead>
<tbody>
<!-- previous records -->
</tbody>
</table>
<br>
<br>
<button type="button" onclick="wizardPrevStep(this)" style="float: left"><?php echo $lang['back'] ?></button>
<button type="button" onclick="wizardSubmitRecord()" style="float: right"><?php echo $lang['finalize'] ?></button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,26 @@
<?php
/**
* /subs/part/wizard_backend.php
* @version 1.0
* @desc backend for easy wizard like data input
* @author Fándly Gergő Zoltán (fandlygergo@gmail.hu, systemtest.tk)
* @copy 2017 Fándly Gergő Zoltán
* License:
Result Manager for managing results of students in bilingual school systems.
Copyright (C) 2017 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
//wizard is just an other frontend for the register. So no backend here