Dump everything from SVN
This commit is contained in:
parent
7391f609d6
commit
bcf29a3d4f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
config.ini
|
3
.htaccess
Normal file
3
.htaccess
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
RewriteEngine on
|
||||||
|
RewriteRule ^(config|res|script|setup)($|/) - [L]
|
||||||
|
RewriteRule ^([a-zA-Z_]+)(\/([a-zA-Z0-9_]))?$ index.php?view=$1 [L,QSA]
|
BIN
SignUp.zip
Normal file
BIN
SignUp.zip
Normal file
Binary file not shown.
BIN
SignUp.zip.sig
Normal file
BIN
SignUp.zip.sig
Normal file
Binary file not shown.
2
config/.htaccess
Normal file
2
config/.htaccess
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
order allow,deny
|
||||||
|
deny from all
|
1
config/allowlogin.cnf
Normal file
1
config/allowlogin.cnf
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
1
config/allowsignup.cnf
Normal file
1
config/allowsignup.cnf
Normal file
@ -0,0 +1 @@
|
|||||||
|
1
|
148
config/config.php
Normal file
148
config/config.php
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /config/config.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc configuration file
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Includes
|
||||||
|
*/
|
||||||
|
require_once("lib/loginManager/loginManager.php");
|
||||||
|
require_once("lib/defuse-crypto.phar");
|
||||||
|
require_once("lib/functions.php");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load in config files
|
||||||
|
*/
|
||||||
|
$config=parse_ini_file("config.ini", true);
|
||||||
|
$config['cryptokey']=file_get_contents("cryptokey.cnf", true);
|
||||||
|
$config['allowlogin']=file_get_contents("allowlogin.cnf", true)=="1"?true:false;
|
||||||
|
$config['allowsignup']=file_get_contents("allowsignup.cnf", true)=="1"?true:false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* regionalization
|
||||||
|
*/
|
||||||
|
date_default_timezone_set($config['general']['timezone']);
|
||||||
|
mb_internal_encoding("UTF-8");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load language file
|
||||||
|
*/
|
||||||
|
$lang=parse_ini_file("lang/".$config['language']['use']);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up database
|
||||||
|
*/
|
||||||
|
$db=new PDO($config['database']['type'].":host=".$config['database']['host'].";dbname=".$config['database']['name'].";charset=utf8", $config['database']['user'], $config['database']['password']);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load Crypto key
|
||||||
|
*/
|
||||||
|
$crypto=\Defuse\Crypto\Key::loadFromAsciiSafeString($config['cryptokey']);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Byte Order Mark for exports
|
||||||
|
*/
|
||||||
|
$BOM=chr(239).chr(187).chr(191);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DEBUG
|
||||||
|
*/
|
||||||
|
if($config['general']['debug']){
|
||||||
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
ini_set("display_errors", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Versioning
|
||||||
|
*/
|
||||||
|
const VERSION="2.0";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up loginManager
|
||||||
|
*/
|
||||||
|
//build needed classes
|
||||||
|
class handler implements lmHandler{
|
||||||
|
public function handle($state, $target=0){
|
||||||
|
global $db;
|
||||||
|
switch($state){
|
||||||
|
case lmStates::LOGIN_FAILED:
|
||||||
|
functions::setError(1);
|
||||||
|
header("Location: ".explode("?", $_SERVER['REQUEST_URI'])[0]);
|
||||||
|
break;
|
||||||
|
case lmStates::LOGIN_OK:
|
||||||
|
$sql=$db->prepare("SELECT id, name, class, accesslevel, except_signup FROM users WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$target));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$_SESSION['id']=$res['id'];
|
||||||
|
$_SESSION['name']=$res['name'];
|
||||||
|
$_SESSION['class']=$res['class'];
|
||||||
|
$_SESSION['accesslevel']=$res['accesslevel'];
|
||||||
|
$_SESSION['except_signup']=$res['except_signup'];
|
||||||
|
|
||||||
|
header("Location: ".explode("?", $_SERVER['REQUEST_URI'])[0]);
|
||||||
|
break;
|
||||||
|
case lmStates::CAPTCHA_FAILED:
|
||||||
|
functions::setError(2);
|
||||||
|
header("Location: ".explode("?", $_SERVER['REQUEST_URI'])[0]);
|
||||||
|
break;
|
||||||
|
case lmStates::BANNED:
|
||||||
|
functions::setError(3);
|
||||||
|
header("Location: ".explode("?", $_SERVER['REQUEST_URI'])[0]);
|
||||||
|
break;
|
||||||
|
case lmStates::FORGET_DONE:
|
||||||
|
functions::setMessage(1);
|
||||||
|
header("Location: ".explode("?", $_SERVER['REQUEST_URI'])[0]);
|
||||||
|
break;
|
||||||
|
case lmStates::LOGOUT_DONE:
|
||||||
|
functions::setMessage(2);
|
||||||
|
header("Location: ".explode("?", $_SERVER['REQUEST_URI'])[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class password implements lmPassword{
|
||||||
|
public function verifyPassword($cleartext, $database){
|
||||||
|
global $crypto;
|
||||||
|
|
||||||
|
if($database==""){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($cleartext==\Defuse\Crypto\Crypto::decrypt($database, $crypto)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class twoFactor implements lmTwoFactor{
|
||||||
|
public function secondFactor($uid){
|
||||||
|
global $config, $db;
|
||||||
|
$sql=$db->prepare("SELECT accesslevel, except_login FROM users WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$uid));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if(($config['allowlogin']=="1" || $res['accesslevel']>0 || $res['except_login']==1) && $res['except_login']!=2){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setError(4);
|
||||||
|
header("Location: ./");
|
||||||
|
die();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//build the class
|
||||||
|
$lm=new loginManager(new lmConfig($db, $config['login']['session_lifetime'], $config['login']['captcha_enable'], $config['login']['captcha_after'], $config['login']['captcha_sitekey'], $config['login']['captcha_secretkey'], $config['login']['ban_enable'], $config['login']['ban_after'], $config['login']['ban_time'], $config['login']['look'], $config['login']['remember_enable'], $config['login']['remember_time'], lmStates::AUTH_ID), new handler(), new password(), new twoFactor());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* init LM
|
||||||
|
*/
|
||||||
|
$lm->init();
|
1
config/cryptokey.cnf
Normal file
1
config/cryptokey.cnf
Normal file
@ -0,0 +1 @@
|
|||||||
|
def00000b0c6c796affdb1dbc89821e277b7ddcc88fd99669ab04984330c574c049eea27a3d54d40d1033d7c4ce9b500e04517ff27bcce47a57c54aaba85681404edc32a
|
89
config/db.sql
Normal file
89
config/db.sql
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* /config/db.sql
|
||||||
|
* @version 1.0
|
||||||
|
* @desc SQL set up file
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `users`, `login_history`, `login_bans`, `time_sequences`, `time_blocks`, `programs`, `registrations`, `registration_log`;
|
||||||
|
|
||||||
|
CREATE TABLE `users`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`name` varchar(65) NOT NULL default '',
|
||||||
|
`class` varchar(10) NOT NULL default '', /* format: ddC (ex: 05D) */
|
||||||
|
`accesslevel` tinyint(1) UNSIGNED NOT NULL default 0, /* 0:student; 1:head teacher; 2:manager; 3:administrator */
|
||||||
|
`password` varchar(255) NOT NULL default '',
|
||||||
|
`except_login` tinyint(1) UNSIGNED NOT NULL default 0, /* 0:no change; 1:always allow login; 2:never allow login - only takes effect for students */
|
||||||
|
`except_signup` tinyint(1) UNSIGNED NOT NULL default 0, /* 0:no change; 1:always allow sign up; 2:never allow sign up - only takes effect for students */
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `login_history`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`user` int(4) UNSIGNED NOT NULL default 1, /* id of nouser */
|
||||||
|
`date` timestamp NOT NULL default current_timestamp,
|
||||||
|
`ip` varchar(45) NOT NULL default '0.0.0.0',
|
||||||
|
`auth_token` varchar(65) NOT NULL default '',
|
||||||
|
`user_agent` varchar(500) NOT NULL default '',
|
||||||
|
`success` tinyint(1) NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`user`) REFERENCES users(`id`) ON DELETE CASCADE
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `login_bans`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`ip` varchar(45) NOT NULL default '0.0.0.0',
|
||||||
|
`until` timestamp NOT NULL default current_timestamp,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `time_sequences`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`name` varchar(65) NOT NULL default '', /* ex: monday, tuesday, 1st week, etc */
|
||||||
|
`allow_signup` tinyint(1) UNSIGNED NOT NULL default 1, /* 0:forbid; 1:allow */
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `time_blocks`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`name` varchar(65) NOT NULL default '', /* ex: 9-10, 8:00, etc */
|
||||||
|
`sequence` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`sequence`) REFERENCES time_sequences(`id`) ON DELETE CASCADE
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `programs`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`name` varchar(65) NOT NULL default '',
|
||||||
|
`description` text NOT NULL default '', /* as long, as wished! */
|
||||||
|
`instructor` varchar(150) NOT NULL default '',
|
||||||
|
`location` varchar(150) NOT NULL default '',
|
||||||
|
`category` tinyint(1) UNSIGNED NOT NULL default 0, /* 0:0th class; 1:1-2th class; 2:3-4th class; 3:5-6th class; 4:7-8th class; 5:9-10th class 6:11-12th class; 10:0-4th class; 11:5-8th class; 12:9-12th class; 20:0-12th class */
|
||||||
|
`time_block` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
`max_participants` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`time_block`) REFERENCES time_blocks(`id`) ON DELETE NO ACTION
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `registrations`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`user` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
`program` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`user`) REFERENCES users(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`program`) REFERENCES programs(`id`) ON DELETE CASCADE
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `registration_log`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`user` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
`date` timestamp NOT NULL default current_timestamp,
|
||||||
|
`action` tinyint(1) UNSIGNED NOT NULL default 0, /* 0:unsibscribe; 1:subscribe; 10:admin deleted; 11:admin added */
|
||||||
|
`program` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`user`) REFERENCES users(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`program`) REFERENCES programs(`id`) ON DELETE CASCADE
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
INSERT INTO users (`id`, `name`) VALUES (1, 'nouser');
|
125
config/lang/hun.ini
Normal file
125
config/lang/hun.ini
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
; /config/lang/hun.ini
|
||||||
|
; hungarian language file
|
||||||
|
|
||||||
|
index="Kezdőlap"
|
||||||
|
programs="Programok"
|
||||||
|
timetable="Órarend"
|
||||||
|
timetable_programs="Órarend programok szerint"
|
||||||
|
studentcard="Ellenőrző"
|
||||||
|
users="Felhasználók"
|
||||||
|
admin="Adminisztrátori eszközök"
|
||||||
|
logout="Kijelentkezés"
|
||||||
|
|
||||||
|
cookie_message="Oldalunk sütiket használ a megfelelő működés biztosításához."
|
||||||
|
cookie_dismiss="Elfogadom!"
|
||||||
|
login="Bejelentkezés"
|
||||||
|
id="Azonosító"
|
||||||
|
uid="Felhasználó azonosító"
|
||||||
|
password="Jelszó"
|
||||||
|
ok="Mehet!"
|
||||||
|
index_content="Ide kerül majd valami, ha minden igaz. Vagy lehet mégse."
|
||||||
|
name="Név"
|
||||||
|
class="Osztály"
|
||||||
|
programs_content="Programok listája"
|
||||||
|
description="Leírás"
|
||||||
|
instructor="Tanár"
|
||||||
|
category="Kategória"
|
||||||
|
timesequence="Nap"
|
||||||
|
timeblock="Időintervallum"
|
||||||
|
maxpart="Maximum résztvevők"
|
||||||
|
curpart="Résztvevők száma"
|
||||||
|
subscribe="Feliratkozás"
|
||||||
|
actions="Műveletek"
|
||||||
|
edit="Szerkesztés"
|
||||||
|
delete="Törlés"
|
||||||
|
qdelete="Biztosan le szeretné törölni ezt az adatelemet?"
|
||||||
|
unsubscribe="Leiratkozás"
|
||||||
|
qunsubscribe="Biztosan le szeretnél iratkozni erre a programról?"
|
||||||
|
new="Létrehozás"
|
||||||
|
newprogram="Új program létrehozása"
|
||||||
|
newtimesequence="Új nap hozzáadása"
|
||||||
|
newtimeblock="Új időblokk hozzáadása"
|
||||||
|
location="Helyszín"
|
||||||
|
editprogram="Program szerkesztése"
|
||||||
|
edittimesequence="Nap szerkesztése"
|
||||||
|
forceadd="Program manuális hozzáadása"
|
||||||
|
forceadddisc="Használat előtt kérem nézze meg, hogy az adott diáknak van e már programja arra az időpontra, ha igen, elősször törölje azt!"
|
||||||
|
pid="Program azonosító"
|
||||||
|
pleaseselect="Kérem válasszon!"
|
||||||
|
user="Diák"
|
||||||
|
program="Program"
|
||||||
|
export="Exportálás CSV-be"
|
||||||
|
notcomplete="Nem teljes feliratkozások"
|
||||||
|
progcount="Programok száma"
|
||||||
|
num="Sorszám"
|
||||||
|
print="Nyomtatás"
|
||||||
|
progname="Program neve"
|
||||||
|
signature="Aláírás"
|
||||||
|
studentprinted="Diák nyomtatta"
|
||||||
|
newuser="Új felhasználó létrehozása"
|
||||||
|
accesslevel="Jogszint"
|
||||||
|
except_login="Bejelentkezés kivételezés"
|
||||||
|
except_signup="Feliratkozás kivételezés"
|
||||||
|
qnewpassword="Adjon meg egy új jelszavat! random:"
|
||||||
|
newpassword="Új jelszó"
|
||||||
|
qexceptlogin="Bejelentkezési kivételezés. 0-alap beállítás, 1-mindig engedje belépni, 2-sose engedje belépni"
|
||||||
|
qexceptsignup="Feliratkozási kivételezés. 0-alap beállítás, 1-mindig engedje feliratkozni, 2-sose engedje feliratkozni"
|
||||||
|
newpassword4all="Új jelszó generálása minden diáknak és osztályfőnöknek"
|
||||||
|
resetall="Minden kivételezés visszaállítása alapértelmezettre"
|
||||||
|
allow_login="Bejelentkezés engedélyezése"
|
||||||
|
allow_signup="Feliratkozás engedélyezése"
|
||||||
|
positive="Igen"
|
||||||
|
negative="Nem"
|
||||||
|
current="Jelenleg"
|
||||||
|
allow_signup_timesequence="Feliratkozás engedélyezése"
|
||||||
|
toggle="Átállítás"
|
||||||
|
time_block_disclaimer="Kérem használja az ÓÓ:PP formátumot a megfelelő rendezés érdekében!"
|
||||||
|
orthis="vagy"
|
||||||
|
qproceed="Biztosan végre szeretné hajtani ezt a műveletet?"
|
||||||
|
masterswitch="Főkapcsolók"
|
||||||
|
|
||||||
|
|
||||||
|
;accesslevels
|
||||||
|
al[0]="Diák"
|
||||||
|
al[1]="Osztályfőnök"
|
||||||
|
al[2]="Manager"
|
||||||
|
al[3]="Adminisztrátor"
|
||||||
|
|
||||||
|
|
||||||
|
;categories
|
||||||
|
cat[100]="Rejtett"
|
||||||
|
cat[0]="0. osztály"
|
||||||
|
cat[1]="1-2. osztály"
|
||||||
|
cat[2]="3-4. osztály"
|
||||||
|
cat[3]="5-6. osztály"
|
||||||
|
cat[4]="7-8. osztály"
|
||||||
|
cat[5]="9-10. osztály"
|
||||||
|
cat[6]="11-12. osztály"
|
||||||
|
cat[10]="0-4. osztály"
|
||||||
|
cat[11]="5-8. osztály"
|
||||||
|
cat[12]="9-12. osztály"
|
||||||
|
cat[20]="0-12. osztály"
|
||||||
|
|
||||||
|
;errors
|
||||||
|
error[1]="Hibás felhasználónév vagy jelszó! Ha elfelejtetted jelszavadat, keresd az osztályfőnöködet!"
|
||||||
|
error[2]="Hibásan töltötted ki a Captcha-t!"
|
||||||
|
error[3]="Az oldal ideiglenesen kitiltott a túl sok hibás bejelentkezési kísérlet miatt erről az IP címről"
|
||||||
|
error[4]="A bejelentkezés le van tiltva."
|
||||||
|
error[5]="Már létezik egy elem ezzel a névvel."
|
||||||
|
error[6]="A művelet nem lett sikeres. Kérem próbálja újra!"
|
||||||
|
error[7]="Nem található semmi a kért azonosítóval."
|
||||||
|
error[8]="Erre a programra már nincs több hely. Kérlek keress egy másikat!"
|
||||||
|
error[9]="Erre az időpontra már van egy programod. Válassz másikat, vagy iratkozz le az előbbiről!"
|
||||||
|
error[10]="Ez a program nem a te kategóriád számára van! Ide amúgy sem juthatsz el legálisan, szóval kérlek ne keress exploit-ot. Úgysem fogsz találni."
|
||||||
|
error[11]="A jelentkezés jelenleg nem engedélyezett!"
|
||||||
|
error[12]="A diáknak már van erre az időpontra egy programja. Előbb törölje azt!"
|
||||||
|
error[13]="A feliratkozás nem módosítható ennél a programnál."
|
||||||
|
|
||||||
|
;messages
|
||||||
|
message[1]="Felhasználó elfelejtve!"
|
||||||
|
message[2]="Sikeresen kijelentkeztél!"
|
||||||
|
message[3]="Adat sikeresen hozzáadva!"
|
||||||
|
message[4]="Adat sikeresen törölve!"
|
||||||
|
message[5]="Sikeresen feliratkoztál a programra!"
|
||||||
|
message[6]="Sikeresen leiratkoztál a programról!"
|
||||||
|
message[7]="Művelet sikeresen végrehajtva!"
|
BIN
config/lib/defuse-crypto.phar
Normal file
BIN
config/lib/defuse-crypto.phar
Normal file
Binary file not shown.
270
config/lib/functions.php
Normal file
270
config/lib/functions.php
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* functions.php
|
||||||
|
* @version 2.3
|
||||||
|
* @desc General issued php function library for me
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
class functions{
|
||||||
|
const STR_SAME=0;
|
||||||
|
const STR_LOWERCASE=1;
|
||||||
|
const STR_RACCENT=2;
|
||||||
|
const STR_RACCLOW=3;
|
||||||
|
const RAND_SMALL=0;
|
||||||
|
const RAND_LARGE=1;
|
||||||
|
const RAND_SPEC=2;
|
||||||
|
const COOKIE_LIFETIME=3;
|
||||||
|
|
||||||
|
public static function setError($code){
|
||||||
|
global $errcode;
|
||||||
|
if(isset($errcode)){
|
||||||
|
array_push($errcode, $code);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$errcode=array($code);
|
||||||
|
}
|
||||||
|
setcookie("errcode", serialize($errcode), time()+functions::COOKIE_LIFETIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isError(){
|
||||||
|
global $errcode;
|
||||||
|
if(isset($errcode) || isset($_COOKIE['errcode'])){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getErrorArray(){
|
||||||
|
global $errcode;
|
||||||
|
if(functions::isError()){
|
||||||
|
if(isset($errcode)){
|
||||||
|
return $errcode;
|
||||||
|
}
|
||||||
|
if(isset($_COOKIE['errcode'])){
|
||||||
|
return unserialize($_COOKIE['errcode']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setMessage($code){
|
||||||
|
global $msgcode;
|
||||||
|
if(isset($msgcode)){
|
||||||
|
array_push($msgcode, $code);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$msgcode=array($code);
|
||||||
|
}
|
||||||
|
setcookie("msgcode", serialize($msgcode), time()+functions::COOKIE_LIFETIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isMessage(){
|
||||||
|
global $msgcode;
|
||||||
|
if(isset($msgcode) || isset($_COOKIE['msgcode'])){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getMessageArray(){
|
||||||
|
global $msgcode;
|
||||||
|
if(functions::isMessage()){
|
||||||
|
if(isset($msgcode)){
|
||||||
|
return $msgcode;
|
||||||
|
}
|
||||||
|
if(isset($_COOKIE['msgcode'])){
|
||||||
|
return unserialize($_COOKIE['msgcode']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clearError(){
|
||||||
|
global $errcode;
|
||||||
|
if(isset($errcode)){
|
||||||
|
unset($errcode);
|
||||||
|
}
|
||||||
|
setcookie("errcode", null, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function clearMessage(){
|
||||||
|
global $msgcode;
|
||||||
|
if(isset($msgcode)){
|
||||||
|
unset($msgcode);
|
||||||
|
}
|
||||||
|
setcookie("msgcode", null, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function randomString($length, $char=functions::RAND_SMALL){
|
||||||
|
if($char==0){
|
||||||
|
$charset="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
|
}
|
||||||
|
else if($char==1){
|
||||||
|
$charset="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
}
|
||||||
|
else if($char==2){
|
||||||
|
$charset="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_-=+\?/.>,<";
|
||||||
|
}
|
||||||
|
$charsetlength=strlen($charset);
|
||||||
|
$string="";
|
||||||
|
for($i=0; $i<$length; $i++){
|
||||||
|
$string=$string . $charset[rand(0, $charsetlength-1)];
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get_string_between($string, $start, $end){
|
||||||
|
$string=' ' . $string;
|
||||||
|
$ini=strpos($string, $start);
|
||||||
|
if($ini==0) return '';
|
||||||
|
$ini+=strlen($start);
|
||||||
|
$len=strpos($string, $end, $ini) - $ini;
|
||||||
|
return substr($string, $ini, $len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function process_string($str, $dep){
|
||||||
|
global $functions_accent_convert;
|
||||||
|
switch($dep){
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
return $str;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
return strtolower($str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
return strtr($str, $functions_accent_convert);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
return strtolower(strtr($str, $functions_accent_convert));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function validate_captcha($secretkey, $response){
|
||||||
|
$verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$response);
|
||||||
|
$data=json_decode($verify);
|
||||||
|
if($data->success){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$functions_accent_convert=array(
|
||||||
|
// Decompositions for Latin-1 Supplement
|
||||||
|
chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
|
||||||
|
chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
|
||||||
|
chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
|
||||||
|
chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
|
||||||
|
chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
|
||||||
|
chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
|
||||||
|
chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
|
||||||
|
chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
|
||||||
|
chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
|
||||||
|
chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
|
||||||
|
chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
|
||||||
|
chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
|
||||||
|
chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
|
||||||
|
chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
|
||||||
|
chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
|
||||||
|
chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
|
||||||
|
chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
|
||||||
|
chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
|
||||||
|
chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
|
||||||
|
chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
|
||||||
|
chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
|
||||||
|
chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
|
||||||
|
chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
|
||||||
|
chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
|
||||||
|
chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
|
||||||
|
chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
|
||||||
|
chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
|
||||||
|
chr(195).chr(191) => 'y',
|
||||||
|
// Decompositions for Latin Extended-A
|
||||||
|
chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
|
||||||
|
chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
|
||||||
|
chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
|
||||||
|
chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
|
||||||
|
chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
|
||||||
|
chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
|
||||||
|
chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
|
||||||
|
chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
|
||||||
|
chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
|
||||||
|
chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
|
||||||
|
chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
|
||||||
|
chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
|
||||||
|
chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
|
||||||
|
chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
|
||||||
|
chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
|
||||||
|
chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
|
||||||
|
chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
|
||||||
|
chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
|
||||||
|
chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
|
||||||
|
chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
|
||||||
|
chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
|
||||||
|
chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
|
||||||
|
chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
|
||||||
|
chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
|
||||||
|
chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
|
||||||
|
chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
|
||||||
|
chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
|
||||||
|
chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
|
||||||
|
chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
|
||||||
|
chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
|
||||||
|
chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
|
||||||
|
chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
|
||||||
|
chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
|
||||||
|
chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
|
||||||
|
chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
|
||||||
|
chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
|
||||||
|
chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
|
||||||
|
chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
|
||||||
|
chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
|
||||||
|
chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
|
||||||
|
chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
|
||||||
|
chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
|
||||||
|
chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
|
||||||
|
chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
|
||||||
|
chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
|
||||||
|
chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
|
||||||
|
chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
|
||||||
|
chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
|
||||||
|
chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
|
||||||
|
chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
|
||||||
|
chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
|
||||||
|
chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
|
||||||
|
chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
|
||||||
|
chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
|
||||||
|
chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
|
||||||
|
chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
|
||||||
|
chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
|
||||||
|
chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
|
||||||
|
chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
|
||||||
|
chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
|
||||||
|
chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
|
||||||
|
chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
|
||||||
|
chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
|
||||||
|
chr(197).chr(190) => 'z', chr(197).chr(191) => 's');
|
||||||
|
|
||||||
|
?>
|
82
config/lib/loginManager/lmConfig.php
Normal file
82
config/lib/loginManager/lmConfig.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/lmConfig.php
|
||||||
|
* @version 1.3
|
||||||
|
* @desc config class
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
class lmConfig{
|
||||||
|
public function __construct($_pdo, $_session_lifetime, $_captcha_enable, $_captcha_after, $_captcha_sitekey, $_captcha_secretkey, $_ban_enable, $_ban_after, $_ban_time, $_look, $_remember_enable, $_remember_time, $_auth_type){
|
||||||
|
$this->pdo=$_pdo;
|
||||||
|
$this->session_lifetime=$_session_lifetime;
|
||||||
|
$this->captcha_enable=$_captcha_enable;
|
||||||
|
$this->captcha_after=$_captcha_after;
|
||||||
|
$this->captcha_sitekey=$_captcha_sitekey;
|
||||||
|
$this->captcha_secretkey=$_captcha_secretkey;
|
||||||
|
$this->ban_enable=$_ban_enable;
|
||||||
|
$this->ban_after=$_ban_after;
|
||||||
|
$this->ban_time=$_ban_time;
|
||||||
|
$this->look=$_look;
|
||||||
|
$this->remember_enable=$_remember_enable;
|
||||||
|
$this->remember_time=$_remember_time;
|
||||||
|
$this->auth_type=$_auth_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private $pdo;
|
||||||
|
private $session_lifetime;
|
||||||
|
private $captcha_enable;
|
||||||
|
private $captcha_after;
|
||||||
|
private $captcha_sitekey;
|
||||||
|
private $captcha_secretkey;
|
||||||
|
private $ban_enable;
|
||||||
|
private $ban_after;
|
||||||
|
private $ban_time;
|
||||||
|
private $look;
|
||||||
|
private $remember_enable; //NOT SAFE AT ALL!!!
|
||||||
|
private $remember_time;
|
||||||
|
private $auth_type;
|
||||||
|
|
||||||
|
public function getPDO(){
|
||||||
|
return $this->pdo;
|
||||||
|
}
|
||||||
|
public function getSessionLifetime(){
|
||||||
|
return $this->session_lifetime;
|
||||||
|
}
|
||||||
|
public function isCaptchaEnabled(){
|
||||||
|
return $this->captcha_enable;
|
||||||
|
}
|
||||||
|
public function getCaptchaAfter(){
|
||||||
|
return $this->captcha_after;
|
||||||
|
}
|
||||||
|
public function getCaptchaSitekey(){
|
||||||
|
return $this->captcha_sitekey;
|
||||||
|
}
|
||||||
|
public function getCaptchaSecretkey(){
|
||||||
|
return $this->captcha_secretkey;
|
||||||
|
}
|
||||||
|
public function isBanEnabled(){
|
||||||
|
return $this->ban_enable;
|
||||||
|
}
|
||||||
|
public function getBanAfter(){
|
||||||
|
return $this->ban_after;
|
||||||
|
}
|
||||||
|
public function getBanTime(){
|
||||||
|
return $this->ban_time;
|
||||||
|
}
|
||||||
|
public function getLook(){
|
||||||
|
return $this->look;
|
||||||
|
}
|
||||||
|
public function isRememberEnabled(){
|
||||||
|
return $this->remember_enable;
|
||||||
|
}
|
||||||
|
public function getRememberTime(){
|
||||||
|
return $this->remember_time;
|
||||||
|
}
|
||||||
|
public function getAuthType(){
|
||||||
|
return $this->auth_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
14
config/lib/loginManager/lmHandler.php
Normal file
14
config/lib/loginManager/lmHandler.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/lmHandler.php
|
||||||
|
* @version 1.1
|
||||||
|
* @desc Event handler for login manager
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface lmHandler{
|
||||||
|
public function handle($state, $target=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
14
config/lib/loginManager/lmPassword.php
Normal file
14
config/lib/loginManager/lmPassword.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/lmPassword.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc interface for function verifying password
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface lmPassword{
|
||||||
|
public function verifyPassword($cleartext, $database);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
24
config/lib/loginManager/lmStates.php
Normal file
24
config/lib/loginManager/lmStates.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/lmStates.php
|
||||||
|
* @version 1.2
|
||||||
|
* @desc States of login manager
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
class lmStates{
|
||||||
|
const LOGIN_FAILED=0;
|
||||||
|
const LOGIN_OK=1;
|
||||||
|
const CAPTCHA_FAILED=2;
|
||||||
|
const BANNED=3;
|
||||||
|
const FORGET_DONE=4;
|
||||||
|
const LOGOUT_DONE=5;
|
||||||
|
|
||||||
|
const AUTH_ID=10;
|
||||||
|
const AUTH_UNAME=11;
|
||||||
|
|
||||||
|
const NOUSER=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
14
config/lib/loginManager/lmTwoFactor.php
Normal file
14
config/lib/loginManager/lmTwoFactor.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/lmTwoFactor.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc second factor auth to LM
|
||||||
|
* @author Fándly Gergő Zoltán 2017
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface lmTwoFactor{
|
||||||
|
public function secondFactor($uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
44
config/lib/loginManager/lmUtils.php
Normal file
44
config/lib/loginManager/lmUtils.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/lmUtils.php
|
||||||
|
* @desc utilities for correct functioning
|
||||||
|
* @version 1.0
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
class lmUtils{
|
||||||
|
/**
|
||||||
|
* generate a random string with special character
|
||||||
|
* @param int $length length of the requested string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function randomString($length){
|
||||||
|
$charset="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_-=+\?/.>,<";
|
||||||
|
$charsetLength=strlen($charset);
|
||||||
|
$string="";
|
||||||
|
for($i=0; $i<$length; $i++){
|
||||||
|
$string.=$charset[rand(0, $charsetLength-1)];
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validate google ReCaptcha
|
||||||
|
* @param string $secretkey secret key to captcha API
|
||||||
|
* @param string $response response of API
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function validateCaptcha($secretkey, $response){
|
||||||
|
$verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$response);
|
||||||
|
$data=json_decode($verify);
|
||||||
|
if($data->success){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
394
config/lib/loginManager/loginManager.php
Normal file
394
config/lib/loginManager/loginManager.php
Normal file
@ -0,0 +1,394 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* loginManager/loginManager.php
|
||||||
|
* @version 1.1
|
||||||
|
* @desc Easily manage authentication to your system
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NEEDED Database structure:
|
||||||
|
*
|
||||||
|
<?sql
|
||||||
|
CREATE TABLE `users`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`username` varchar(65) NOT NULL default '', /* optional
|
||||||
|
`password` varchar(255) NOT NULL default '',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `login_history`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`user` int(4) UNSIGNED NOT NULL default 1, /* id of nouser
|
||||||
|
`date` timestamp NOT NULL default current_timestamp,
|
||||||
|
`ip` varchar(45) NOT NULL default '0.0.0.0',
|
||||||
|
`auth_token` varchar(65) NOT NULL default '',
|
||||||
|
`user_agent` varchar(500) NOT NULL default '',
|
||||||
|
`success` tinyint(1) NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`user`) REFERENCES users(`id`) ON DELETE CASCADE
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `login_remember` (
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`user` int(4) UNSIGNED NOT NULL default 0,
|
||||||
|
`remember_token` varchar(65) NOT NULL default '',
|
||||||
|
`until` timestamp NOT NULL default current_timestamp,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`user`) REFERENCES users(`id`) ON DELETE CASCADE
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
CREATE TABLE `login_bans`(
|
||||||
|
`id` int(4) UNSIGNED NOT NULL auto_increment,
|
||||||
|
`ip` varchar(45) NOT NULL default '0.0.0.0',
|
||||||
|
`until` timestamp NOT NULL default current_timestamp,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) CHARACTER SET utf8 COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
INSERT INTO users (`id`, `username`) VALUES (1, 'nouser');
|
||||||
|
?>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Includes
|
||||||
|
*/
|
||||||
|
require("lmStates.php");
|
||||||
|
require("lmConfig.php");
|
||||||
|
require("lmHandler.php");
|
||||||
|
require("lmPassword.php");
|
||||||
|
require("lmTwoFactor.php");
|
||||||
|
require("lmUtils.php");
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class
|
||||||
|
*/
|
||||||
|
class loginManager{
|
||||||
|
//constructor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* building...
|
||||||
|
* @param lmConfig $_config configuration for login Manager
|
||||||
|
* @param lmHandler $_eventHandler handler of events
|
||||||
|
* @param lmPassword $_passwordEngine engine for verifying passwords
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($_config, $_eventHandler, $_passwordEngine, $_twoFactor){
|
||||||
|
$this->config=$_config;
|
||||||
|
$this->eventHandler=$_eventHandler;
|
||||||
|
$this->passwordEngine=$_passwordEngine;
|
||||||
|
$this->twoFactor=$_twoFactor;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//settings
|
||||||
|
|
||||||
|
private $config;
|
||||||
|
private $eventHandler;
|
||||||
|
private $passwordEngine;
|
||||||
|
private $twoFactor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//frontend functions
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize session and set its lifetime
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function init(){
|
||||||
|
session_set_cookie_params($this->config->getSessionLifetime());
|
||||||
|
return session_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prepare for login. Run this on the top of your login page!
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function loginPrepare(){
|
||||||
|
$this->passFailedAttempts();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lets start here!
|
||||||
|
* @param int/string @identifier id or username of user
|
||||||
|
* @param string @password cleartext password from input
|
||||||
|
* @param bool $remember save user fot further use
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function login($identifier, $password, $remember=false){
|
||||||
|
global $lm_force_captcha;
|
||||||
|
|
||||||
|
if($this->passFailedAttempts()){ //not banned
|
||||||
|
if(isset($lm_force_captcha)){ //check captcha
|
||||||
|
if(!isset($_POST['g-recaptcha-response'])){
|
||||||
|
$captcha_failed=true;
|
||||||
|
$this->addLoginHistory(lmStates::NOUSER, lmStates::LOGIN_FAILED);
|
||||||
|
$this->eventHandler->handle(lmStates::CAPTCHA_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(!lmUtils::validateCaptcha($this->config->getCaptchaSecretkey(), $_POST['g-recaptcha-response'])){
|
||||||
|
$captcha_failed=true;
|
||||||
|
$this->addLoginHistory(lmStates::NOUSER, lmStates::LOGIN_FAILED);
|
||||||
|
$this->eventHandler->handle(lmStates::CAPTCHA_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($captcha_failed)){
|
||||||
|
if($this->config->isRememberEnabled()){ //check if remembering is enabled
|
||||||
|
if($this->isRememberingUser() && $this->twoFactor->secondFactor($this->isRememberingUser())){ //remembering.
|
||||||
|
$this->permitLogin($this->isRememberingUser()); //good to go!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//proceed with normal login
|
||||||
|
if($this->config->getAuthType()==lmStates::AUTH_UNAME){ //username based authentication
|
||||||
|
$sql=$this->config->getPDO()->prepare("SELECT COUNT(id) AS count, id, password FROM users WHERE username=:identifier");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$this->config->getPDO()->prepare("SELECT COUNT(id) AS count, id, password FROM users WHERE id=:identifier");
|
||||||
|
}
|
||||||
|
$sql->execute(array(":identifier"=>$identifier));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']==0){ //user not existing
|
||||||
|
$this->addLoginHistory(lmStates::NOUSER, lmStates::LOGIN_FAILED);
|
||||||
|
$this->eventHandler->handle(lmStates::LOGIN_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if($this->passwordEngine->verifyPassword($password, $res['password']) && $this->twoFactor->secondFactor($res['id'])){
|
||||||
|
if($this->config->isRememberEnabled()){ //remember... if he wants to be insecure
|
||||||
|
if($remember){
|
||||||
|
$this->rememberUser($res['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->permitLogin($res['id']); //good to go!
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->addLoginHistory($res['id'], lmStates::LOGIN_FAILED);
|
||||||
|
$this->eventHandler->handle(lmStates::LOGIN_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* finish it up!
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function logout(){
|
||||||
|
$_SESSION=array();
|
||||||
|
session_destroy();
|
||||||
|
setcookie("lm_login_random", NULL, -1);
|
||||||
|
$this->eventHandler->handle(lmStates::LOGOUT_DONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* just some formal checking
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function validateLogin(){
|
||||||
|
if(!isset($_SESSION['lm_id'])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$this->config->getPDO()->prepare("SELECT auth_token FROM login_history WHERE user=:id and success=1 ORDER BY id DESC LIMIT 1");
|
||||||
|
$sql->execute(array(":id"=>$_SESSION['lm_id']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['auth_token']==$this->getSessionKey()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$this->addLoginHistory(lmStates::NOUSER, lmStates::LOGIN_FAILED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* do i know you?
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function isRememberingUser(){
|
||||||
|
if(!$this->config->isRememberEnabled()){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_null($this->getRememberKey())){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$this->config->getPDO()->prepare("SELECT COUNT(id) AS count, user FROM login_remember WHERE remember_token=:token and until>:until");
|
||||||
|
$sql->execute(array(":token"=>$this->getRememberKey(), ":until"=>date("Y-m-d H:i:s")));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']!=1){
|
||||||
|
addLoginHistory(lmStates::NOUSER, lmStates::LOGIN_FAILED);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $res['user'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* i don't know you anymore!
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function forgetUser(){
|
||||||
|
$sql=$this->config->getPDO()->prepare("UPDATE login_remember SET until=0 WHERE remember_token=:token");
|
||||||
|
$sql->execute(array(":token"=>$this->getRememberKey()));
|
||||||
|
|
||||||
|
setcookie("lm_login_remember", NULL, -1);
|
||||||
|
|
||||||
|
$this->eventHandler->handle(lmStates::FORGET_DONE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print captcha html code if needed
|
||||||
|
* @param bool $dark use the dark theme, default false
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function printCaptcha($dark=false){
|
||||||
|
if($this->config->isCaptchaEnabled()){
|
||||||
|
global $lm_force_captcha;
|
||||||
|
if(isset($lm_force_captcha)){
|
||||||
|
if($dark){
|
||||||
|
echo "<div class=\"g-recaptcha\" data-sitekey=\"".$this->config->getCaptchaSitekey()."\" data-theme=\"dark\"></div>";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "<div class=\"g-recaptcha\" data-sitekey=\"".$this->config->getCaptchaSitekey()."\"></div>";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//backend functions
|
||||||
|
|
||||||
|
protected function generateSessionKey(){
|
||||||
|
$random=lmUtils::randomString(32);
|
||||||
|
setcookie("lm_login_random", $random, time()+$this->config->getSessionLifetime());
|
||||||
|
$hash=hash("sha256", $_SERVER['REMOTE_ADDR']."***".$_SERVER['HTTP_USER_AGENT']."***".$random);
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSessionKey(){
|
||||||
|
if(!isset($_COOKIE['lm_login_random'])){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$hash=hash("sha256", $_SERVER['REMOTE_ADDR']."***".$_SERVER['HTTP_USER_AGENT']."***".$_COOKIE['lm_login_random']);
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function passFailedAttempts(){
|
||||||
|
//check if no limitations are enabled
|
||||||
|
if(!$this->config->isCaptchaEnabled() && !$this->config->isBanEnabled()){
|
||||||
|
return true; //nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if is already banned
|
||||||
|
if($this->config->isBanEnabled()){
|
||||||
|
$sql=$this->config->getPDO()->prepare("SELECT COUNT(id) AS count FROM login_bans WHERE id=:ip and until>:until");
|
||||||
|
$sql->execute(array(":ip"=>$_SERVER['REMOTE_ADDR'], ":until"=>date("Y-m-d H:i:s")));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']!=0){
|
||||||
|
$this->eventHandler->handle(lmStates::BANNED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//count failed attempts
|
||||||
|
$sql=$this->config->getPDO()->prepare("SELECT COUNT(id) AS count FROM login_history WHERE ip=:ip and date>:date and success=0");
|
||||||
|
$sql->execute(array(":ip"=>$_SERVER['REMOTE_ADDR'], ":date"=>date("Y-m-d H:i:s", time()-$this->config->getLook())));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
//force captcha if case
|
||||||
|
if($res['count']>=$this->config->getCaptchaAfter() && $this->config->isCaptchaEnabled()){
|
||||||
|
global $lm_force_captcha;
|
||||||
|
$lm_force_captcha=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//bann if case
|
||||||
|
if($res['count']>=$this->config->getBanAfter() && $this->config->isBanEnabled()){
|
||||||
|
$sql=$this->config->getPDO()->prepare("INSERT INTO login_bans (ip, until) VALUES (:ip, :until)");
|
||||||
|
$sql->execute(array(":ip"=>$_SERVER['REMOTE_ADDR'], ":until"=>date("Y-m-d H:i:s", time()+$config->getBanTime())));
|
||||||
|
global $lm_banned;
|
||||||
|
$lm_banned=true;
|
||||||
|
$this->eventHandler->handle(lmStates::BANNED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addLoginHistory($uid, $success=lmStates::LOGIN_FAILED, $token=""){
|
||||||
|
$sql=$this->config->getPDO()->prepare("INSERT INTO login_history (user, date, ip, auth_token, user_agent, success) VALUES (:user, :date, :ip, :auth_token, :user_agent, :success)");
|
||||||
|
$sql->execute(array(":user"=>$uid, ":date"=>date("Y-m-d H:i:s"), ":ip"=>$_SERVER['REMOTE_ADDR'], ":auth_token"=>$token, ":user_agent"=>$_SERVER['HTTP_USER_AGENT'], ":success"=>$success));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function permitLogin($uid){
|
||||||
|
$token=$this->generateSessionKey();
|
||||||
|
$this->addLoginHistory($uid, lmStates::LOGIN_OK, $token);
|
||||||
|
|
||||||
|
$_SESSION=array();
|
||||||
|
$_SESSION['lm_id']=$uid;
|
||||||
|
|
||||||
|
$this->eventHandler->handle(lmStates::LOGIN_OK, $uid);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//functions for remembering
|
||||||
|
protected function generateRememberKey(){
|
||||||
|
$random=lmUtils::randomString(32);
|
||||||
|
setcookie("lm_login_remember", $random, time()+(86000*$config->getRememberTime()));
|
||||||
|
$hash=hash("sha256", $_SERVER['REMOTE_ADDR']."***".$_SERVER['HTTP_USER_AGENT']."***".$random);
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getRememberKey(){
|
||||||
|
if(!isset($_COOKIE['lm_login_remember'])){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$hash=hash("sha256", $_SERVER['REMOTE_ADDR']."***".$_SERVER['HTTP_USER_AGENT']."***".$random);
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function rememberUser($uid){
|
||||||
|
$sql=$this->config->getPDO()->prepare("INSERT INTO login_remember (user, remember_token, until) VALUES (:user, :token, :until)");
|
||||||
|
$sql->execute(array(":user"=>$uid, ":token"=>generateRememberKey(), ":until"=>date("Y-m-d H:i:s", time()+(86400*$config->getRememberTime()))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
194
index.php
Normal file
194
index.php
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /index.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc Kind a main index file for stuffs like login form
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once("config/config.php");
|
||||||
|
|
||||||
|
$view="";
|
||||||
|
|
||||||
|
if(!$lm->validateLogin()){
|
||||||
|
if(isset($_POST['uname']) && isset($_POST['passwd'])){
|
||||||
|
$lm->login($_POST['uname'], $_POST['passwd']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(isset($_GET['logout'])){
|
||||||
|
$lm->logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['view'])){
|
||||||
|
$view=$_GET['view'];
|
||||||
|
|
||||||
|
if($view!="programs" && $view!="timetable" && $view!="timetable_programs" && $view!="users" && $view!="admin"){
|
||||||
|
header("Location: ./");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($view=="timetable_programs" && $_SESSION['accesslevel']<1){
|
||||||
|
$view="";
|
||||||
|
}
|
||||||
|
else if($view=="users" && $_SESSION['accesslevel']<2){
|
||||||
|
$view="";
|
||||||
|
}
|
||||||
|
else if($view=="admin" && $_SESSION['accesslevel']<3){
|
||||||
|
$view="";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$view="";
|
||||||
|
}
|
||||||
|
|
||||||
|
//include sub
|
||||||
|
include("subs/".$view.".backend.php");
|
||||||
|
|
||||||
|
//if just the backend was requested, stop here
|
||||||
|
if(isset($_GET['backend'])){
|
||||||
|
//echo messages
|
||||||
|
echo "<center>";
|
||||||
|
if(functions::isMessage()){
|
||||||
|
foreach(functions::getMessageArray() as $m){
|
||||||
|
echo "<div class=\"message\">";
|
||||||
|
echo "<p>".$lang['message'][$m]."</p>";
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
echo "<hr class=\"placeholder\">";
|
||||||
|
}
|
||||||
|
if(functions::isError()){
|
||||||
|
foreach(functions::getErrorArray() as $m){
|
||||||
|
echo "<div class=\"message error\">";
|
||||||
|
echo "<p>".$lang['error'][$m]."</p>";
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
echo "<hr class=\"placeholder\">";
|
||||||
|
}
|
||||||
|
echo "</center>";
|
||||||
|
|
||||||
|
//clear messages
|
||||||
|
functions::clearError();
|
||||||
|
functions::clearMessage();
|
||||||
|
|
||||||
|
//stop execution
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$oid=0;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title><?php echo ($view==""?$lang['index']:$lang[$view])." :: ".$config['general']['title']." - ".$config['general']['org'] ?></title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<!-- styleseets, icons -->
|
||||||
|
<link rel="stylesheet" href="./style.css">
|
||||||
|
<link rel="stylesheet" media="screen and (max-width: 1024px)" href="./style_mobile.css">
|
||||||
|
<link rel="icon" href="./res/icon.png">
|
||||||
|
<!-- cookieconsent -->
|
||||||
|
<script>
|
||||||
|
window.cookieconsent_options={
|
||||||
|
message: '<?php echo $lang['cookie_message'] ?>',
|
||||||
|
dismiss: '<?php echo $lang['cookie_dismiss'] ?>',
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>
|
||||||
|
<!-- recaptcha -->
|
||||||
|
<script src="//www.google.com/recaptcha/api.js"></script>
|
||||||
|
<!-- footable for fancy table -->
|
||||||
|
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||||
|
<script src="./script/footable/footable.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="./script/footable/footable.standalone.min.css">
|
||||||
|
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
<!-- personal script -->
|
||||||
|
<script src="./script/script.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="loadingOverlay" class="overlay loading" style="display: none">
|
||||||
|
<img src="./res/loading.gif" alt="loading...">
|
||||||
|
</div>
|
||||||
|
<div id="messageOverlay" class="overlay messages" style="display: none" onclick="disposeMessageOverlay()"></div>
|
||||||
|
<h1 class="title"><?php echo $config['general']['title']." - ".$config['general']['org'] ?></h1>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<center>
|
||||||
|
<div id="message_container">
|
||||||
|
<?php
|
||||||
|
if(functions::isMessage()){
|
||||||
|
foreach(functions::getMessageArray() as $m){
|
||||||
|
echo "<div class=\"message\">";
|
||||||
|
echo "<p>".$lang['message'][$m]."</p>";
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
echo "<hr class=\"placeholder\">";
|
||||||
|
}
|
||||||
|
if(functions::isError()){
|
||||||
|
foreach(functions::getErrorArray() as $m){
|
||||||
|
echo "<div class=\"message error\">";
|
||||||
|
echo "<p>".$lang['error'][$m]."</p>";
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
echo "<hr class=\"placeholder\">";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php if(!$lm->validateLogin()): ?>
|
||||||
|
<div id="login_area">
|
||||||
|
<center>
|
||||||
|
<form method="POST" action="" id="login">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['login'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['id'].": " ?></td>
|
||||||
|
<td><input type="text" name="uname" placeholder="<?php echo $lang['id']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['password'].": " ?></td>
|
||||||
|
<td><input type="password" name="passwd" placeholder="<?php echo $lang['password']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<?php $lm->loginPrepare(); $lm->printCaptcha() ?>
|
||||||
|
<br>
|
||||||
|
<button type="submit" form="login"><?php echo $lang['ok'] ?></button>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div id="users_area">
|
||||||
|
<div id="profile">
|
||||||
|
<p><?php echo $lang['id'].": ".$_SESSION['id']." | ".$lang['name'].": ".$_SESSION['name']." | ".$lang['class'].": ".$_SESSION['class'] ?></p>
|
||||||
|
</div>
|
||||||
|
<div id="menu">
|
||||||
|
<ul class="menu">
|
||||||
|
<a href="./"><li><?php echo $lang['index'] ?></li></a>
|
||||||
|
<a href="./programs"><li><?php echo $lang['programs'] ?></li></a>
|
||||||
|
<a href="./timetable"><li><?php echo $lang['timetable'] ?></li></a>
|
||||||
|
<?php if($_SESSION['accesslevel']>=1): ?><a href="./timetable_programs"><li><?php echo $lang['timetable_programs'] ?></li></a><?php endif ?>
|
||||||
|
<a href="./timetable?studentcard"><li><?php echo $lang['studentcard'] ?></li></a>
|
||||||
|
<?php if($_SESSION['accesslevel']>=2): ?><a href="./users"><li><?php echo $lang['users'] ?></li></a><?php endif ?>
|
||||||
|
<?php if($_SESSION['accesslevel']>=3): ?><a href="./admin"><li><?php echo $lang['admin'] ?></li></a><?php endif ?>
|
||||||
|
<a href="./?logout"><li><?php echo $lang['logout'] ?></li></a>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<!-- include -->
|
||||||
|
<?php include("subs/".$view.".php") ?>
|
||||||
|
<!-- end -->
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
</center>
|
||||||
|
<hr class="placeholder" style="height: 500px">
|
||||||
|
</body>
|
||||||
|
<footer>
|
||||||
|
<p><?php echo "© ".$config['general']['org']." ".date("Y") ?></p>
|
||||||
|
<p>Powered by: SignUP<br>version: <?php echo VERSION ?><br>Created by: Fándly Gergő<br><a href="//systemtest.tk">systemtest.tk</a></p>
|
||||||
|
</footer>
|
||||||
|
</html>
|
621
license.txt
Normal file
621
license.txt
Normal file
@ -0,0 +1,621 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
BIN
res/icon.png
Normal file
BIN
res/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
res/loading.gif
Normal file
BIN
res/loading.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
10
script/footable/footable.min.js
vendored
Normal file
10
script/footable/footable.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
script/footable/footable.standalone.min.css
vendored
Normal file
1
script/footable/footable.standalone.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
109
script/script.js
Normal file
109
script/script.js
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/**
|
||||||
|
* /script/script.js
|
||||||
|
* @version 2.0
|
||||||
|
* @desc Javascript for ajax and for fancy tables
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
function ask(q, togo){
|
||||||
|
if(confirm(q)){
|
||||||
|
window.location=togo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prompt_go(question, value, todo){
|
||||||
|
var reply=prompt(question, value);
|
||||||
|
if(reply){
|
||||||
|
window.location=todo+reply;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function disposeMessageOverlay(){
|
||||||
|
$("#messageOverlay").html("");
|
||||||
|
$("#messageOverlay").css("display", "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery(function($){
|
||||||
|
|
||||||
|
//loading overlay
|
||||||
|
$(document).ajaxStart(function(){
|
||||||
|
$("#loadingOverlay").css("display", "block");
|
||||||
|
});
|
||||||
|
$(document).ajaxComplete(function(){
|
||||||
|
$("#loadingOverlay").css("display", "none");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//footable
|
||||||
|
$(".table").footable();
|
||||||
|
|
||||||
|
|
||||||
|
//handle response
|
||||||
|
function setResponse(response){
|
||||||
|
$("#messageOverlay").html(response);
|
||||||
|
$("#messageOverlay").css("display", "block");
|
||||||
|
setTimeout(function(){
|
||||||
|
$("#messageOverlay").html("");
|
||||||
|
$("#messageOverlay").css("display", "none");
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//handle form submits
|
||||||
|
$(".ajaxform").submit(function(e){
|
||||||
|
e.preventDefault(); //turn off default handler
|
||||||
|
|
||||||
|
//run ajax request
|
||||||
|
$.ajax({
|
||||||
|
url: e.target.action+"?backend",
|
||||||
|
type: e.target.method,
|
||||||
|
data: $(this).serialize(),
|
||||||
|
success: function(response){
|
||||||
|
setResponse(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//reset form if data-noreset not specified
|
||||||
|
if($(this).data("noreset")==undefined){
|
||||||
|
e.target.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//handle button presses
|
||||||
|
$(document).on("click", ".ajaxbutton", function(e){
|
||||||
|
e.preventDefault(); //turn off default handler
|
||||||
|
|
||||||
|
if($(this).data("confirm")==undefined || confirm($(this).data("confirm"))){ //check if confirmation needed
|
||||||
|
//prompt for input if needed
|
||||||
|
var reply="";
|
||||||
|
if($(this).data("prompt")!=undefined){
|
||||||
|
reply=prompt($(this).data("prompt"), '');
|
||||||
|
}
|
||||||
|
|
||||||
|
//build target url
|
||||||
|
var targetUrl=$(this).data("url")+reply;
|
||||||
|
if(targetUrl.indexOf("?")){
|
||||||
|
targetUrl+="&backend";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
targetUrl+="?backend";
|
||||||
|
}
|
||||||
|
|
||||||
|
//run ajax request
|
||||||
|
$.ajax({
|
||||||
|
url: targetUrl,
|
||||||
|
type: "GET",
|
||||||
|
success: function(response){
|
||||||
|
setResponse(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//delete caller button if data-kepp not specified
|
||||||
|
if($(this).data("keep")==undefined){
|
||||||
|
$(this).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
2
setup/.htaccess
Normal file
2
setup/.htaccess
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
order allow,deny
|
||||||
|
deny from all
|
25
setup/001-generateKey.php
Normal file
25
setup/001-generateKey.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /setup/001-generateKey.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc Generate Crypto key
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
header("Content-type: text/plain; charset=UTF-8");
|
||||||
|
|
||||||
|
require_once("../config/lib/defuse-crypto.phar");
|
||||||
|
|
||||||
|
echo "Generating key...\n";
|
||||||
|
flush();
|
||||||
|
$key=\Defuse\Crypto\Key::createNewRandomKey();
|
||||||
|
echo "Key generated!\n";
|
||||||
|
flush();
|
||||||
|
echo "Writeing to file...\n";
|
||||||
|
flush();
|
||||||
|
file_put_contents("../config/cryptokey.cnf", $key->saveToAsciiSafeString());
|
||||||
|
echo "Done! Proceed to step 2!";
|
||||||
|
flush();
|
||||||
|
|
||||||
|
?>
|
39
setup/002-createAdmin.php
Normal file
39
setup/002-createAdmin.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /setup/002-createAdmin.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc Create an admin account with login credintials
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
header("Content-type: text/plain; charset=UTF-8");
|
||||||
|
require_once("../config/config.php");
|
||||||
|
|
||||||
|
if(!isset($_GET['password'])){
|
||||||
|
echo "Plese set a password with GET 'password'!";
|
||||||
|
flush();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "Generating password...\n";
|
||||||
|
flush();
|
||||||
|
$passwd=$_GET['password'];
|
||||||
|
echo "Password generated!\n";
|
||||||
|
flush();
|
||||||
|
echo "Encrypting password...\n";
|
||||||
|
flush();
|
||||||
|
$enc=\Defuse\Crypto\Crypto::encrypt($passwd, $crypto);
|
||||||
|
echo "Encription done!\n";
|
||||||
|
echo "Populating database...\n";
|
||||||
|
$sql=$db->prepare("INSERT INTO users (name, accesslevel, password) VALUES (:name, :accesslevel, :password)");
|
||||||
|
$sql->execute(array(":name"=>"Admin", ":accesslevel"=>3, ":password"=>$enc));
|
||||||
|
$id=$db->lastInsertId();
|
||||||
|
echo "Done!\n\n";
|
||||||
|
flush();
|
||||||
|
echo "Credintials:\n>username: ".$id."\n>password: ".$passwd;
|
||||||
|
flush();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
67
signupproj.geany
Normal file
67
signupproj.geany
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
[editor]
|
||||||
|
line_wrapping=false
|
||||||
|
line_break_column=72
|
||||||
|
auto_continue_multiline=true
|
||||||
|
|
||||||
|
[file_prefs]
|
||||||
|
final_new_line=true
|
||||||
|
ensure_convert_new_lines=false
|
||||||
|
strip_trailing_spaces=false
|
||||||
|
replace_tabs=false
|
||||||
|
|
||||||
|
[indentation]
|
||||||
|
indent_width=4
|
||||||
|
indent_type=0
|
||||||
|
indent_hard_tab_width=8
|
||||||
|
detect_indent=false
|
||||||
|
detect_indent_width=false
|
||||||
|
indent_mode=2
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name=SignUp
|
||||||
|
base_path=H:\\Munkák\\signup
|
||||||
|
description=
|
||||||
|
|
||||||
|
[long line marker]
|
||||||
|
long_line_behaviour=1
|
||||||
|
long_line_column=72
|
||||||
|
|
||||||
|
[files]
|
||||||
|
current_page=35
|
||||||
|
FILE_NAME_0=4099;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5CloginManager.php;0;4
|
||||||
|
FILE_NAME_1=288;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5ClmStates.php;0;4
|
||||||
|
FILE_NAME_2=207;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5ClmHandler.php;0;4
|
||||||
|
FILE_NAME_3=469;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5ClmConfig.php;0;4
|
||||||
|
FILE_NAME_4=1266;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5ClmUtils.php;0;4
|
||||||
|
FILE_NAME_5=220;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5ClmPassword.php;0;4
|
||||||
|
FILE_NAME_6=210;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5CloginManager%5ClmTwoFactor.php;0;4
|
||||||
|
FILE_NAME_7=1458;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Cconfig.php;0;4
|
||||||
|
FILE_NAME_8=592;Conf;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Cconfig.ini;0;4
|
||||||
|
FILE_NAME_9=435;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clib%5Cfunctions.php;0;4
|
||||||
|
FILE_NAME_10=136;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Ccryptokey.cnf;0;4
|
||||||
|
FILE_NAME_11=1;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Callowsignup.cnf;0;4
|
||||||
|
FILE_NAME_12=1;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Callowlogin.cnf;0;4
|
||||||
|
FILE_NAME_13=492;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csetup%5C001-generateKey.php;0;4
|
||||||
|
FILE_NAME_14=495;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csetup%5C002-createAdmin.php;0;4
|
||||||
|
FILE_NAME_15=33;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csetup%5C.htaccess;0;4
|
||||||
|
FILE_NAME_16=35;CSS;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cstyle.css;0;4
|
||||||
|
FILE_NAME_17=180;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cindex.php;0;4
|
||||||
|
FILE_NAME_18=113;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5C.htaccess;0;4
|
||||||
|
FILE_NAME_19=209;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5C.php;0;4
|
||||||
|
FILE_NAME_20=209;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5C.backend.php;0;4
|
||||||
|
FILE_NAME_21=11959;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Cprograms.backend.php;0;4
|
||||||
|
FILE_NAME_22=2742;SQL;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Cdb.sql;0;4
|
||||||
|
FILE_NAME_23=93;Javascript;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cscript%5Cscript.js;0;4
|
||||||
|
FILE_NAME_24=42;CSS;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cstyle_mobile.css;0;4
|
||||||
|
FILE_NAME_25=31;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5C.htaccess;0;4
|
||||||
|
FILE_NAME_26=13449;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Cprograms.php;0;4
|
||||||
|
FILE_NAME_27=4068;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Ctimetable.php;0;4
|
||||||
|
FILE_NAME_28=6651;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Ctimetable.backend.php;0;4
|
||||||
|
FILE_NAME_29=2576;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Ctimetable_programs.php;0;4
|
||||||
|
FILE_NAME_30=257;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Ctimetable_programs.backend.php;0;4
|
||||||
|
FILE_NAME_31=2425;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Cusers.php;0;4
|
||||||
|
FILE_NAME_32=4439;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Cusers.backend.php;0;4
|
||||||
|
FILE_NAME_33=31;None;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5C.htaccess;0;4
|
||||||
|
FILE_NAME_34=2881;Conf;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Cconfig%5Clang%5Chun.ini;0;4
|
||||||
|
FILE_NAME_35=1628;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Cadmin.php;0;4
|
||||||
|
FILE_NAME_36=170;PHP;0;EUTF-8;0;1;0;H%3A%5CMunkák%5Csignup%5Csubs%5Cadmin.backend.php;0;4
|
191
style.css
Normal file
191
style.css
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
/**
|
||||||
|
* /style.css
|
||||||
|
* @version 1.2
|
||||||
|
* @desc fancy css
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
h1.title{
|
||||||
|
text-align: left;
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
margin: auto;
|
||||||
|
padding: 0.3em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
button{
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
padding: 1em;
|
||||||
|
border-radius: 0.5em;
|
||||||
|
}
|
||||||
|
button:hover{
|
||||||
|
background: rgba(31,73,125,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset{
|
||||||
|
border: 5px solid rgba(31,73,125,0.8);
|
||||||
|
background: rgb(220,220,220);
|
||||||
|
border-radius: 1em;
|
||||||
|
padding: 2em;
|
||||||
|
width: 60%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
fieldset legend{
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
padding: 0.3em;
|
||||||
|
font-size: 2em;
|
||||||
|
border-radius: 0.5em;
|
||||||
|
box-shadow: 0 0 0 5px rgb(220,220,220);
|
||||||
|
text-align:left;
|
||||||
|
margin-left: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer{
|
||||||
|
background: rgb(200,200,200);
|
||||||
|
border-radius: 1em;
|
||||||
|
width: 80%;
|
||||||
|
margin: auto;
|
||||||
|
font-size: 0.8em;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr.placeholder{
|
||||||
|
border: none;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input{
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid solid rgba(31,73,125,0.8);
|
||||||
|
}
|
||||||
|
textarea{
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid solid rgba(31,73,125,0.8);
|
||||||
|
}
|
||||||
|
select{
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid solid rgba(31,73,125,0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
div.message{
|
||||||
|
width: 50%;
|
||||||
|
padding: 1em;
|
||||||
|
border: 2px solid rgb(60, 255, 60);
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
background: rgba(0, 255, 0, 0.8);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
div.message.error{
|
||||||
|
border: 2px solid rgb(255, 60, 60);
|
||||||
|
background: rgba(255, 0, 0, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.menu{
|
||||||
|
list-style:none;
|
||||||
|
margin: 0;
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
ul.menu li{
|
||||||
|
display: block;
|
||||||
|
padding: 1em;
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
}
|
||||||
|
ul.menu li:hover{
|
||||||
|
background: rgba(31,73,125,1);
|
||||||
|
}
|
||||||
|
ul.menu a{
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
td{
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.password{
|
||||||
|
background: rgb(0,0,0);
|
||||||
|
font-family: Courier New;
|
||||||
|
}
|
||||||
|
span.password:hover{
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.overlay{
|
||||||
|
position: fixed;
|
||||||
|
display: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
div.overlay.loading{
|
||||||
|
background: rgba(0,0,0,0.7);
|
||||||
|
}
|
||||||
|
div.overlay.loading img{
|
||||||
|
position: fixed;
|
||||||
|
max-width: 50%;
|
||||||
|
max-height: 50%;
|
||||||
|
top: 30%;
|
||||||
|
left: 40%;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
div.overlay.messages{
|
||||||
|
height: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the world's fanciest checkbox */
|
||||||
|
div.checkbox{
|
||||||
|
width: 7em;
|
||||||
|
height: 2.5em;
|
||||||
|
background: rgb(140, 140, 140);
|
||||||
|
border-radius: 1.5em;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
div.checkbox:before{
|
||||||
|
content: 'On';
|
||||||
|
position: absolute;
|
||||||
|
top: 30%;
|
||||||
|
left: 15%;
|
||||||
|
color: rgb(35, 200, 40);
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
div.checkbox:after{
|
||||||
|
content: 'Off';
|
||||||
|
position: absolute;
|
||||||
|
top: 30%;
|
||||||
|
right: 15%;
|
||||||
|
color: rgb(15, 15, 15);
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
div.checkbox label{
|
||||||
|
display: block;
|
||||||
|
width: 45%;
|
||||||
|
height: 55%;
|
||||||
|
border-radius: 1.5em;
|
||||||
|
transition: 0.5s;
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
top: 22.5%;
|
||||||
|
left: 10%;
|
||||||
|
z-index: 1;
|
||||||
|
background: rgb(220, 220, 220);
|
||||||
|
}
|
||||||
|
div.checkbox input[type=checkbox]:checked + label{
|
||||||
|
left: 45%;
|
||||||
|
background: rgb(35, 200, 40);
|
||||||
|
}
|
||||||
|
div.checkbox input[type=checkbox]{
|
||||||
|
display: none;
|
||||||
|
}
|
221
style_mobile.css
Normal file
221
style_mobile.css
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
/**
|
||||||
|
* /style_mobile.css
|
||||||
|
* @version 1.2
|
||||||
|
* @desc fancy css even for mobile devices!
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
h1.title{
|
||||||
|
text-align: left;
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
margin: auto;
|
||||||
|
padding: 0.3em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
button{
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
padding: 1em;
|
||||||
|
border-radius: 0.5em;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
|
button:hover{
|
||||||
|
background: rgba(31,73,125,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
form{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
fieldset{
|
||||||
|
border: 5px solid rgba(31,73,125,0.8);
|
||||||
|
background: rgb(220,220,220);
|
||||||
|
border-radius: 1em;
|
||||||
|
padding: 2em;
|
||||||
|
width: 90%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
fieldset legend{
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
padding: 0.3em;
|
||||||
|
font-size: 2em;
|
||||||
|
border-radius: 0.5em;
|
||||||
|
box-shadow: 0 0 0 5px rgb(220,220,220);
|
||||||
|
text-align:left;
|
||||||
|
margin-left: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer{
|
||||||
|
background: rgb(200,200,200);
|
||||||
|
border-radius: 1em;
|
||||||
|
width: 90%;
|
||||||
|
margin: auto;
|
||||||
|
font-size: 0.8em;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr.placeholder{
|
||||||
|
border: none;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input{
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid solid rgba(31,73,125,0.8);
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
textarea{
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid solid rgba(31,73,125,0.8);
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
select{
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 0.5em;
|
||||||
|
border: 1px solid solid rgba(31,73,125,0.8);
|
||||||
|
font-size: 1.5em;
|
||||||
|
max-width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.message{
|
||||||
|
width: 90%;
|
||||||
|
padding: 1em;
|
||||||
|
border: 2px solid rgb(60, 255, 60);
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
margin-bottom: 1.5em;
|
||||||
|
background: rgba(0, 255, 0, 0.5);
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
div.message.error{
|
||||||
|
border: 2px solid rgb(255, 60, 60);
|
||||||
|
background: rgba(255, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.menu{
|
||||||
|
list-style:none;
|
||||||
|
margin: 0;
|
||||||
|
background: rgba(31,73,125,0.8);
|
||||||
|
display: flex;
|
||||||
|
justify-content: stretch;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
font-size: 2em;
|
||||||
|
}
|
||||||
|
ul.menu li{
|
||||||
|
display: block;
|
||||||
|
padding: 1em;
|
||||||
|
color: rgb(255,255,255);
|
||||||
|
width; 95%;
|
||||||
|
}
|
||||||
|
ul.menu li:hover{
|
||||||
|
background: rgba(31,73,125,1);
|
||||||
|
}
|
||||||
|
ul.menu a{
|
||||||
|
text-decoration: none;
|
||||||
|
width: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
td{
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.password{
|
||||||
|
background: rgb(0,0,0);
|
||||||
|
font-family: Courier New;
|
||||||
|
}
|
||||||
|
span.password:hover{
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
table:not(.table) td{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
label{
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table{
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
p{
|
||||||
|
font-size: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.overlay{
|
||||||
|
position: fixed;
|
||||||
|
display: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
div.overlay.loading{
|
||||||
|
background: rgba(0,0,0,0.7);
|
||||||
|
}
|
||||||
|
div.overlay.loading img{
|
||||||
|
position: fixed;
|
||||||
|
max-width: 50%;
|
||||||
|
max-height: 50%;
|
||||||
|
top: 30%;
|
||||||
|
left: 40%;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
div.overlay.messages{
|
||||||
|
height: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* the world's fanciest checkbox */
|
||||||
|
div.checkbox{
|
||||||
|
width: 7em;
|
||||||
|
height: 2.5em;
|
||||||
|
background: rgb(140, 140, 140);
|
||||||
|
border-radius: 1.5em;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
div.checkbox:before{
|
||||||
|
content: 'On';
|
||||||
|
position: absolute;
|
||||||
|
top: 30%;
|
||||||
|
left: 15%;
|
||||||
|
color: rgb(35, 200, 40);
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
div.checkbox:after{
|
||||||
|
content: 'Off';
|
||||||
|
position: absolute;
|
||||||
|
top: 30%;
|
||||||
|
right: 15%;
|
||||||
|
color: rgb(15, 15, 15);
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
div.checkbox label{
|
||||||
|
display: block;
|
||||||
|
width: 45%;
|
||||||
|
height: 55%;
|
||||||
|
border-radius: 1.5em;
|
||||||
|
transition: 0.5s;
|
||||||
|
cursor: pointer;
|
||||||
|
position: absolute;
|
||||||
|
top: 22.5%;
|
||||||
|
left: 10%;
|
||||||
|
z-index: 1;
|
||||||
|
background: rgb(220, 220, 220);
|
||||||
|
}
|
||||||
|
div.checkbox input[type=checkbox]:checked + label{
|
||||||
|
left: 45%;
|
||||||
|
background: rgb(35, 200, 40);
|
||||||
|
}
|
||||||
|
div.checkbox input[type=checkbox]{
|
||||||
|
display: none;
|
||||||
|
}
|
8
subs/.backend.php
Normal file
8
subs/.backend.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/.backend.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc backend of index. nothing, i mean NOTHING here. Just to keep integrity
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
2
subs/.htaccess
Normal file
2
subs/.htaccess
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
order allow,deny
|
||||||
|
deny from all
|
14
subs/.php
Normal file
14
subs/.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc index
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<p><?php echo $lang['index_content'] ?></p>
|
||||||
|
</div>
|
44
subs/admin.backend.php
Normal file
44
subs/admin.backend.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/admin.backend.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc backend for admin site
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']>=3){
|
||||||
|
if(isset($_POST['ms_post'])){
|
||||||
|
if(!file_put_contents("./config/allowlogin.cnf", (isset($_POST['allow_login'])?1:0)) || !file_put_contents("./config/allowsignup.cnf", (isset($_POST['allow_signup'])?1:0))){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./admin");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./admin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['set_tsas_id'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM time_sequences WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_POST['set_tsas_id']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if($res['count']<1){
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./admin");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("UPDATE time_sequences SET allow_signup=:as WHERE id=:id");
|
||||||
|
$sql->execute(array(":as"=>(isset($_POST['set_tsas'])?1:0), ":id"=>$_POST['set_tsas_id']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./admin");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./admin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
subs/admin.php
Normal file
74
subs/admin.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/admin.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc administrator area
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<h2><?php echo $lang['admin'] ?></h2>
|
||||||
|
<br>
|
||||||
|
<div id="master_switch">
|
||||||
|
<form class="ajaxform" data-noreset="1" method="POST" action="" id="master_switch_form">
|
||||||
|
<input type="hidden" name="ms_post">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['masterswitch'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<p><?php echo $lang['allow_login'] ?></p>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input type="checkbox" name="allow_login" <?php if($config['allowlogin']) echo "checked" ?> id="o_<?php echo $oid ?>" onchange="$('#master_switch_form').submit()">
|
||||||
|
<label for="o_<?php echo $oid; $oid++ ?>"></label>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<p><?php echo $lang['allow_signup'] ?></p>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input type="checkbox" name="allow_signup" <?php if($config['allowsignup']) echo "checked" ?> id="o_<?php echo $oid ?>" onchange="$('#master_switch_form').submit()">
|
||||||
|
<label for="o_<?php echo $oid; $oid++ ?>"></label>
|
||||||
|
</div>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['allow_signup_timesequence'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td data-breakpoints="xs"><?php echo $lang['id'] ?></td>
|
||||||
|
<td><?php echo $lang['timesequence'] ?></td>
|
||||||
|
<td data-breakpoints="xs sm"><?php echo $lang['actions'] ?></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT id, name, allow_signup FROM time_sequences ORDER BY id ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>";
|
||||||
|
echo "<form class=\"ajaxform\" data-noreset=\"1\" method=\"POST\" action=\"\" id=\"f_".$oid."\">";
|
||||||
|
echo "<input type=\"hidden\" name=\"set_tsas_id\" value=\"".$row['id']."\">";
|
||||||
|
echo "<div class=\"checkbox\">";
|
||||||
|
echo "<input type=\"checkbox\" name=\"set_tsas\" ".($row['allow_signup']==1?"checked":"")." id=\"o_".$oid."\" onchange=\"$('#f_".$oid."').submit()\">";
|
||||||
|
echo "<label for=\"o_".$oid."\"></label>";
|
||||||
|
echo "</div>";
|
||||||
|
echo "</form>";
|
||||||
|
echo "</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
$oid++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
299
subs/programs.backend.php
Normal file
299
subs/programs.backend.php
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/programs.backend.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc backend for programs
|
||||||
|
* @author Fándly Gergő Zoltán 2017
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
//cat decider
|
||||||
|
$where="";
|
||||||
|
if($_SESSION['accesslevel']<2){
|
||||||
|
preg_match("/[0-9]+/", $_SESSION['class'], $match);
|
||||||
|
$class=$match[0];
|
||||||
|
if($class==0){
|
||||||
|
$cat1=0;
|
||||||
|
$cat2=10;
|
||||||
|
}
|
||||||
|
else if($class==1 || $class==2){
|
||||||
|
$cat1=1;
|
||||||
|
$cat2=10;
|
||||||
|
}
|
||||||
|
else if($class==3 || $class==4){
|
||||||
|
$cat1=2;
|
||||||
|
$cat2=10;
|
||||||
|
}
|
||||||
|
else if($class==5 || $class==6){
|
||||||
|
$cat1=3;
|
||||||
|
$cat2=11;
|
||||||
|
}
|
||||||
|
else if($class==7 || $class==8){
|
||||||
|
$cat1=4;
|
||||||
|
$cat2=11;
|
||||||
|
}
|
||||||
|
else if($class==9 || $class==10){
|
||||||
|
$cat1=5;
|
||||||
|
$cat2=12;
|
||||||
|
}
|
||||||
|
else if($class==11 || $class==12){
|
||||||
|
$cat1=6;
|
||||||
|
$cat2=12;
|
||||||
|
}
|
||||||
|
$cat3=20;
|
||||||
|
$where="WHERE ts.allow_signup=1 and (p.category=".$cat1." or p.category=".$cat2." or p.category=".$cat3.")";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']>=2){ //just for elevated users
|
||||||
|
/*
|
||||||
|
* Add new entries
|
||||||
|
*/
|
||||||
|
if(isset($_POST['nts_name'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM time_sequences WHERE name=:name");
|
||||||
|
$sql->execute(array(":name"=>$_POST['nts_name']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']>0){
|
||||||
|
functions::setError(5);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("INSERT INTO time_sequences (name) VALUES (:name)");
|
||||||
|
$sql->execute(array(":name"=>$_POST['nts_name']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(3);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_POST['ntb_name']) && isset($_POST['ntb_timesequence'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM time_blocks WHERE name=:name and sequence=:seq");
|
||||||
|
$sql->execute(array(":name"=>$_POST['ntb_name'], ":seq"=>$_POST['ntb_timesequence']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']>0){
|
||||||
|
functions::setError(5);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("INSERT INTO time_blocks (name, sequence) VALUES (:name, :seq)");
|
||||||
|
$sql->execute(array(":name"=>$_POST['ntb_name'], ":seq"=>$_POST['ntb_timesequence']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(3);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_POST['n_name']) && isset($_POST['n_description']) && isset($_POST['n_instructor']) && isset($_POST['n_location']) && isset($_POST['n_category']) && isset($_POST['n_timeblock']) && isset($_POST['n_maxpart'])){
|
||||||
|
$sql=$db->prepare("INSERT INTO programs (name, description, instructor, location, category, time_block, max_participants) VALUES (:name, :desc, :inst, :loc, :cat, :tb, :maxpart)");
|
||||||
|
$sql->execute(array(":name"=>$_POST['n_name'], ":desc"=>$_POST['n_description'], ":inst"=>$_POST['n_instructor'], ":loc"=>$_POST['n_location'], ":cat"=>$_POST['n_category'], ":tb"=>$_POST['n_timeblock'], ":maxpart"=>$_POST['n_maxpart']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(3);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* delete entry
|
||||||
|
*/
|
||||||
|
if(isset($_GET['ts_delete'])){
|
||||||
|
$sql=$db->prepare("DELETE FROM time_sequences WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['ts_delete']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(4);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['tb_delete'])){
|
||||||
|
$sql=$db->prepare("DELETE FROM time_blocks WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['tb_delete']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(4);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['delete'])){
|
||||||
|
$sql=$db->prepare("DELETE FROM programs WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['delete']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(4);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Subscribe/unsubscribe
|
||||||
|
*/
|
||||||
|
if($_SESSION['accesslevel']==0){ //only they need it
|
||||||
|
if(isset($_GET['sub'])){
|
||||||
|
if((!$config['allowsignup'] && $_SESSION['except_signup']!=1) || $_SESSION['except_signup']==2){ //check if signup allowed
|
||||||
|
functions::setError(11);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(p.id) AS count, p.category, p.time_block, p.max_participants, (SELECT COUNT(r.id) FROM registrations AS r WHERE r.program=p.id) AS cur_participants, ts.allow_signup FROM programs AS p INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) WHERE p.id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['sub']));
|
||||||
|
$prog=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($prog['count']<1){ //check if exists
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if($prog['cur_participants']>=$prog['max_participants']){ //check if not full
|
||||||
|
functions::setError(8);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(r.id) AS count FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) WHERE r.user=:uid and p.time_block=:tb");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":tb"=>$prog['time_block']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']>0){ //check if not occupied on that time
|
||||||
|
functions::setError(9);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if($prog['category']!=$cat1 && $prog['category']!=$cat2 && $prog['category']!=$cat3){ //check if category coresponds
|
||||||
|
functions::setError(10);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if($prog['allow_signup']!=1){ //check if it is actually possible to sign up to this
|
||||||
|
functions::setError(13);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//subscribe
|
||||||
|
$sql=$db->prepare("INSERT INTO registrations(user, program) VALUES (:uid, :pid)");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":pid"=>$_GET['sub']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//add to history
|
||||||
|
$sql=$db->prepare("INSERT INTO registration_log (user, date, action, program) VALUES (:uid, :date, :act, :pid)");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":date"=>date("Y-m-d H:i:s"), ":act"=>1, ":pid"=>$_GET['sub']));
|
||||||
|
functions::setMessage(5);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['unsub'])){
|
||||||
|
if((!$config['allowsignup'] && $_SESSION['except_signup']!=1) || $_SESSION['except_signup']==2){ //check if signup allowed
|
||||||
|
functions::setError(11);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM registrations WHERE user=:uid and program=:pid");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":pid"=>$_GET['unsub']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']<1){ //check if signed up
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT ts.allow_signup FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) WHERE user=:uid and program=:pid");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":pid"=>$_GET['unsub']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if($res['allow_signup']!=1){ //check if signup/down allowed
|
||||||
|
functions::setError(13);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//unsubscribe
|
||||||
|
$sql=$db->prepare("DELETE FROM registrations WHERE user=:uid and program=:pid");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":pid"=>$_GET['unsub']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//add to history
|
||||||
|
$sql=$db->prepare("INSERT INTO registration_log (user, date, action, program) VALUES (:uid, :date, :act, :pid)");
|
||||||
|
$sql->execute(array(":uid"=>$_SESSION['id'], ":date"=>date("Y-m-d H:i:s"), ":act"=>0, ":pid"=>$_GET['unsub']));
|
||||||
|
functions::setMessage(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./programs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main query
|
||||||
|
*/
|
||||||
|
$msql=$db->prepare("SELECT p.id, p.name, p.description, p.instructor, p.location, p.category, tb.name AS time_block, ts.name AS time_sequence, p.max_participants, (SELECT COUNT(r.id) FROM registrations AS r WHERE r.program=p.id) AS cur_participants FROM programs AS p INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ".$where." GROUP BY(p.id) ORDER BY p.name ASC");
|
||||||
|
$msql->execute();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EXPORT
|
||||||
|
*/
|
||||||
|
if(isset($_GET['export'])){
|
||||||
|
$csv=$BOM;
|
||||||
|
$csv.=$config['general']['org']."\n".$config['general']['title']."\n\n";
|
||||||
|
$csv.=$lang['id'].";".$lang['name'].";".$lang['description'].";".$lang['instructor'].";".$lang['location'].";".$lang['category'].";".$lang['timeblock'].";".$lang['maxpart'].";".$lang['curpart']."\n";
|
||||||
|
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
$csv.=$row['id'].";".$row['name'].";".$row['description'].";".$row['instructor'].";".$row['location'].";".$lang['cat'][$row['category']].";".$row['time_sequence']."/".$row['time_block'].";".$row['max_participants'].";".$row['cur_participants']."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//print
|
||||||
|
header("Content-type: application/octet-stream");
|
||||||
|
//header("Content-length: ".mb_strlen($csv));
|
||||||
|
header("Content-disposition: attachment; filename='".$config['general']['title']."_programs_export_".date("Y-m-d H-i-s").".csv'");
|
||||||
|
echo $csv;
|
||||||
|
die();
|
||||||
|
}
|
245
subs/programs.php
Normal file
245
subs/programs.php
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/programs.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc programs
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
$oid=0;
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<?php if($_SESSION['accesslevel']>=2): ?>
|
||||||
|
<div id="admintools">
|
||||||
|
<div id="tool_newprogram">
|
||||||
|
<form class="ajaxform" method="POST" action="" id="newprogram">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['newprogram'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['name'].": " ?></td>
|
||||||
|
<td><input type="text" name="n_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['description'].": " ?></td>
|
||||||
|
<td><textarea name="n_description" placeholder="<?php echo $lang['description']."..." ?>" rows=10 cols=40></textarea></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['instructor'].": " ?></td>
|
||||||
|
<td><input type="text" name="n_instructor" placeholder="<?php echo $lang['instructor']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['location'].": " ?></td>
|
||||||
|
<td><input type="text" name="n_location" placeholder="<?php echo $lang['location']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['category'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="n_category" value="100" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][100] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="0" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][0] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="1" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][1] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="2" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][2] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="3" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][3] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="4" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][4] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="5" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][5] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="6" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][6] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="10" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][10] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="11" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][11] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="12" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][12] ?></label><br>
|
||||||
|
<input type="radio" name="n_category" value="20" id="o_<?php echo $oid ?>" required><label for="o_<?php echo $oid; $oid++ ?>"><?php echo $lang['cat'][20] ?></label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['timeblock'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT tb.id, ts.name AS ts_name, tb.name AS tb_name FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence)");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<input type=\"radio\" name=\"n_timeblock\" value=\"".$row['id']."\" id=\"o_".$oid."\" required><label for=\"o_".$oid."\">".$row['ts_name']."/".$row['tb_name']."</label><br>";
|
||||||
|
$oid++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['maxpart'].": " ?></td>
|
||||||
|
<td><input type="number" name="n_maxpart" placeholder="<?php echo $lang['maxpart']."..." ?>" required min=1></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button type="submit" form="newprogram"><?php echo $lang['ok'] ?></button>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div id="tool_newtimesequence">
|
||||||
|
<form class="ajaxform" method="POST" action="" id="newtimesequence" autocomplete="off">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['newtimesequence'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['name'].": " ?></td>
|
||||||
|
<td><input type="text" name="nts_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button type="submit" form="newtimesequence"><?php echo $lang['ok'] ?></button>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
<table class="table" id="ts_table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php echo $lang['id'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th><?php echo $lang['actions'] ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT id, name FROM time_sequences ORDER BY name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>";
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./programs?ts_delete=".$row['id']."\">".$lang['delete']."</button>";
|
||||||
|
echo "</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div id="tool_newtimeblock">
|
||||||
|
<form class="ajaxform" method="POST" action="" id="newtimeblock" autocomplete="off">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['newtimeblock'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<?php echo $lang['name'].": " ?>
|
||||||
|
<br>
|
||||||
|
<span style="font-size: 0.8em"><?php echo $lang['time_block_disclaimer'] ?></span>
|
||||||
|
</td>
|
||||||
|
<td><input type="text" name="ntb_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['timesequence'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT id, name FROM time_sequences ORDER BY name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<input type=\"radio\" name=\"ntb_timesequence\" value=\"".$row['id']."\" id=\"o_".$oid."\" required><label for=\"o_".$oid."\">".$row['name']."</label><br>";
|
||||||
|
$oid++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button type="submit" form="newtimeblock"><?php echo $lang['ok'] ?></button>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
<table class="table" id="tb_table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php echo $lang['id'] ?></th>
|
||||||
|
<th><?php echo $lang['timesequence'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th><?php echo $lang['actions'] ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT tb.id, tb.name, ts.name AS time_sequence FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.name ASC, tb.name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['time_sequence']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>";
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./programs?tb_delete=".$row['id']."\">".$lang['delete']."</button>";
|
||||||
|
echo "</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<?php endif ?>
|
||||||
|
<h2><?php echo $lang['programs_content'] ?></h2>
|
||||||
|
<br>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['id'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm md"><?php echo $lang['description'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['instructor'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['location'] ?></th>
|
||||||
|
<th data-breakpoints="xs"><?php echo $lang['category'] ?></th>
|
||||||
|
<th><?php echo $lang['timeblock'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['maxpart'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['curpart'] ?></th>
|
||||||
|
<th data-breakpoints="xs"><?php echo $lang['actions'] ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>".$row['description']."</td>";
|
||||||
|
echo "<td>".$row['instructor']."</td>";
|
||||||
|
echo "<td>".$row['location']."</td>";
|
||||||
|
echo "<td>".$lang['cat'][$row['category']]."</td>";
|
||||||
|
echo "<td>".$row['time_sequence']."/".$row['time_block']."</td>";
|
||||||
|
echo "<td>".$row['max_participants']."</td>";
|
||||||
|
echo "<td>".$row['cur_participants']."</td>";
|
||||||
|
|
||||||
|
echo "<td>";
|
||||||
|
if($_SESSION['accesslevel']<1){
|
||||||
|
if($row['cur_participants']<$row['max_participants']){
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-url=\"./programs?sub=".$row['id']."\">".$lang['subscribe']."</button>";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($_SESSION['accesslevel']>=2){
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./programs?delete=".$row['id']."\">".$lang['delete']."</button>";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "-";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<button type="button" onclick="window.location='./programs?export'"><?php echo $lang['export'] ?></button>
|
||||||
|
</div>
|
292
subs/timetable.backend.php
Normal file
292
subs/timetable.backend.php
Normal file
@ -0,0 +1,292 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/timetable.backend.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc Timetable sub backend
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']>=2){
|
||||||
|
if(isset($_GET['delete'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count, user, program FROM registrations WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['delete']));
|
||||||
|
$reg=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($reg['count']<1){
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("DELETE FROM registrations WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['delete']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//keep history integrity
|
||||||
|
$sql=$db->prepare("INSERT INTO registration_log (user, date, action, program) VALUES (:uid, :date, :act, :pid)");
|
||||||
|
$sql->execute(array(":uid"=>$reg['user'], ":date"=>date("Y-m-d H:i:s"), ":act"=>10, ":pid"=>$reg['program']));
|
||||||
|
|
||||||
|
functions::setMessage(4);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//force add
|
||||||
|
if(isset($_POST['fa_user']) && isset($_POST['fa_program'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM users WHERE id=:uid");
|
||||||
|
$sql->execute(array(":uid"=>$_POST['fa_user']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']<1){ //check if user exists
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count, time_block FROM programs WHERE id=:pid");
|
||||||
|
$sql->execute(array(":pid"=>$_POST['fa_program']));
|
||||||
|
$prog=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($prog['count']<1){ //check if program exists
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(r.id) AS count FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) WHERE r.user=:uid and p.time_block=:tb");
|
||||||
|
$sql->execute(array(":uid"=>$_POST['fa_user'], ":tb"=>$prog['time_block']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']>0){ //check if not occupied
|
||||||
|
functions::setError(12);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{ //do this!
|
||||||
|
$sql=$db->prepare("INSERT INTO registrations (user, program) VALUES (:uid, :pid)");
|
||||||
|
$sql->execute(array(":uid"=>$_POST['fa_user'], ":pid"=>$_POST['fa_program']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){ //check insert failure
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//keep history integrity
|
||||||
|
$sql=$db->prepare("INSERT INTO registration_log (user, date, action, program) VALUES (:uid, :date, :act, :pid)");
|
||||||
|
$sql->execute(array(":uid"=>$_POST['fa_user'], ":date"=>date("Y-m-d H:i:s"), ":act"=>11, ":pid"=>$_POST['fa_program']));
|
||||||
|
|
||||||
|
functions::setMessage(3);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_POST['fa_class']) && isset($_POST['fa_program'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM users WHERE class=:c");
|
||||||
|
$sql->execute(array(":c"=>$_POST['fa_class']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']<1){ //check if class exists
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count, time_block FROM programs WHERE id=:pid");
|
||||||
|
$sql->execute(array(":pid"=>$_POST['fa_program']));
|
||||||
|
$prog=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($prog['count']<1){ //check if program exists
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("SELECT COUNT(r.id) AS count, r.id FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN users AS u ON (u.id=r.user) WHERE u.class=:c and u.accesslevel=0 and p.time_block=:tb");
|
||||||
|
$sql->execute(array(":c"=>$_POST['fa_class'], ":tb"=>$prog['time_block']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']>0){ //check if not occupied
|
||||||
|
functions::setError(12);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{ //do this!
|
||||||
|
$sql=$db->prepare("INSERT INTO registrations (user, program) SELECT id, :pid FROM users WHERE class=:c and accesslevel=0");
|
||||||
|
$sql->execute(array(":c"=>$_POST['fa_class'], ":pid"=>$_POST['fa_program']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){ //check insert failure
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//keep history integrity
|
||||||
|
$sql=$db->prepare("INSERT INTO registration_log (user, date, action, program) SELECT id, :date, :act, :pid FROM users WHERE class=:c and accesslevel=0");
|
||||||
|
$sql->execute(array(":c"=>$_POST['fa_class'], ":date"=>date("Y-m-d H:i:s"), ":act"=>11, ":pid"=>$_POST['fa_program']));
|
||||||
|
|
||||||
|
functions::setMessage(3);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./timetable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$msql=$db->prepare("SELECT id, name, class FROM users WHERE id<>1 and accesslevel=0 ORDER BY class ASC, name ASC");
|
||||||
|
$msql->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']==1){
|
||||||
|
$msql=$db->prepare("SELECT id, name, class FROM users WHERE id<>1 and accesslevel=0 and class=:class ORDER BY name ASC");
|
||||||
|
$msql->execute(array(":class"=>$_SESSION['class']));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']<1){
|
||||||
|
$msql=$db->prepare("SELECT p.id, p.name, p.description, p.instructor, p.location, tb.name AS time_block, ts.name AS time_sequence FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) WHERE r.user=:uid ORDER BY ts.id ASC, tb.name ASC, p.name ASC");
|
||||||
|
$msql->execute(array(":uid"=>$_SESSION['id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EXPORT
|
||||||
|
*/
|
||||||
|
if(isset($_GET['export']) && $_SESSION['accesslevel']>=1){
|
||||||
|
$csv=$BOM;
|
||||||
|
$csv.=$config['general']['org']."\n".$config['general']['title']."\n\n";
|
||||||
|
|
||||||
|
$prog="";
|
||||||
|
$sql=$db->prepare("SELECT tb.id, ts.name AS time_sequence, tb.name AS time_block FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.id ASC, tb.name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
$tbs=array();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
$prog.=$row['time_sequence']."/".$row['time_block'].";";
|
||||||
|
array_push($tbs, $row['id']);
|
||||||
|
}
|
||||||
|
$prog=rtrim($prog, ";");
|
||||||
|
|
||||||
|
$csv.=$lang['uid'].";".$lang['name'].";".$lang['class'].";".$prog."\n";
|
||||||
|
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
$i=0;
|
||||||
|
$prog="";
|
||||||
|
$sql=$db->prepare("SELECT r.id AS regid, tb.id AS time_block, p.name FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) WHERE r.user=:uid ORDER BY tb.sequence ASC, tb.name ASC");
|
||||||
|
$sql->execute(array(":uid"=>$row['id']));
|
||||||
|
while($row2=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
while($row2['time_block']!=$tbs[$i]){
|
||||||
|
$prog.="-;";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$prog.=$row2['name'].";";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
for(;$i<count($tbs); $i++){
|
||||||
|
$prog.="-;";
|
||||||
|
}
|
||||||
|
$prog=rtrim($prog, ";");
|
||||||
|
|
||||||
|
$csv.=$row['id'].";".$row['name'].";".$row['class'].";".$prog."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//print
|
||||||
|
header("Content-type: application/octet-stream");
|
||||||
|
//header("Content-length: ".mb_strlen($csv));
|
||||||
|
header("Content-disposition: attachment; filename='".$config['general']['title']."_timetable_export_".date("Y-m-d H-i-s").".csv'");
|
||||||
|
echo $csv;
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PRINT STUDENT CARD
|
||||||
|
*/
|
||||||
|
if(isset($_GET['studentcard'])){
|
||||||
|
if($_SESSION['accesslevel']<1){
|
||||||
|
$html="";
|
||||||
|
$html.="<table style=\"page-break-after: always; page-break-inside: avoid; height: 100%; width: 100%; text-align: center; border-spacing: 0.4em\">";
|
||||||
|
$html.="<tr>";
|
||||||
|
$html.="<td style=\"padding: 1em; border: 1px solid rgb(0,0,0); height: 45%; vertical-align: top\">";
|
||||||
|
$html.="<h3>".$config['general']['title']."</h3>";
|
||||||
|
$html.="<h3><i>".$config['general']['org']."</i></h3>";
|
||||||
|
$html.="<hr>";
|
||||||
|
$html.="<p>".$lang['name'].": ".$_SESSION['name']." | ".$lang['class'].": ".$_SESSION['class']." | ".$lang['studentprinted']."</p>";
|
||||||
|
|
||||||
|
$html.="<table style=\"width: 95%; font-size: 0.9em\" border=\"1\">";
|
||||||
|
$html.="<tr>";
|
||||||
|
$html.="<th>".$lang['timeblock']."</th>";
|
||||||
|
$html.="<th>".$lang['progname']."</th>";
|
||||||
|
$html.="<th>".$lang['instructor']."</th>";
|
||||||
|
$html.="<th>".$lang['signature']."</th>";
|
||||||
|
$html.="</tr>";
|
||||||
|
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
$html.="<tr>";
|
||||||
|
$html.="<td>".$row['time_sequence']."<br>".$row['time_block']."</td>";
|
||||||
|
$html.="<td>".$row['name']."</td>";
|
||||||
|
$html.="<td>".$row['instructor']."</td>";
|
||||||
|
$html.="<td></td>";
|
||||||
|
$html.="</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$html.="</table>";
|
||||||
|
|
||||||
|
$html.="</td>";
|
||||||
|
$html.="</tr>";
|
||||||
|
$html.="</table>";
|
||||||
|
|
||||||
|
echo "<html><body><center>".$html."</center><script>window.print()</script></body></html>";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$html="";
|
||||||
|
$second=false;
|
||||||
|
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
//header
|
||||||
|
if(!$second){
|
||||||
|
$html.="<table style=\"page-break-after: always; page-break-inside: avoid; height: 100%; width: 100%; text-align: center; border-spacing: 0.4em\">";
|
||||||
|
}
|
||||||
|
//content
|
||||||
|
$html.="<tr>";
|
||||||
|
$html.="<td style=\"padding: 1em; border: 1px solid rgb(0,0,0); height: 45%; vertical-align: top\">";
|
||||||
|
$html.="<h3>".$config['general']['title']."</h3>";
|
||||||
|
$html.="<h3><i>".$config['general']['org']."</i></h3>";
|
||||||
|
$html.="<hr>";
|
||||||
|
$html.="<p>".$lang['name'].": ".$row['name']." | ".$lang['class'].": ".$row['class']."</p>";
|
||||||
|
|
||||||
|
//programs
|
||||||
|
$html.="<table style=\"width: 95%; font-size: 0.9em\" border=\"1\">";
|
||||||
|
$html.="<tr>";
|
||||||
|
$html.="<th>".$lang['timeblock']."</th>";
|
||||||
|
$html.="<th>".$lang['progname']."</th>";
|
||||||
|
$html.="<th>".$lang['instructor']."</th>";
|
||||||
|
$html.="<th>".$lang['signature']."</th>";
|
||||||
|
$html.="</tr>";
|
||||||
|
|
||||||
|
//subquerry
|
||||||
|
$sql=$db->prepare("SELECT tb.name AS time_block, ts.name AS time_sequence, p.instructor, p.name FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) WHERE r.user=:uid ORDER BY ts.id ASC, tb.name ASC");
|
||||||
|
$sql->execute(array(":uid"=>$row['id']));
|
||||||
|
while($row2=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
$html.="<tr>";
|
||||||
|
$html.="<td>".$row2['time_sequence']."<br>".$row2['time_block']."</td>";
|
||||||
|
$html.="<td>".$row2['name']."</td>";
|
||||||
|
$html.="<td>".$row2['instructor']."</td>";
|
||||||
|
$html.="<td></td>";
|
||||||
|
$html.="</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$html.="</table>";
|
||||||
|
$html.="</td>";
|
||||||
|
$html.="</tr>";
|
||||||
|
|
||||||
|
if($second){
|
||||||
|
$html.="</table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$second=!$second;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<html><body><center>".$html."</center><script>window.print()</script></body></html>";
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
186
subs/timetable.php
Normal file
186
subs/timetable.php
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/timetable.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc Timetable sub
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<?php if($_SESSION['accesslevel']>=2): ?>
|
||||||
|
<div id="forceadddiv">
|
||||||
|
<form class="ajaxform" method="POST" action="" id="forceadd" autocomplete="off">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['forceadd'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<p><?php echo $lang['forceadddisc'] ?></p>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['user'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<select name="fa_user" required>
|
||||||
|
<option value="-1" selected disabled><?php echo $lang['pleaseselect'] ?></option>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT id, name, class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC, name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<option value=\"".$row['id']."\">".$row['class']." :: ".$row['name']."</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo "<b>".$lang['orthis']."</b> ".$lang['class'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<select name="fa_class">
|
||||||
|
<option value="-1" selected disabled><?php echo $lang['pleaseselect'] ?></option>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT DISTINCT class FROM users WHERE accesslevel=0 and id<>1 ORDER BY class ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<option value=\"".$row['class']."\">".$row['class']."</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['program'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<select name="fa_program" required>
|
||||||
|
<option value="-1" selected disabled><?php echo $lang['pleaseselect'] ?></option>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT p.id, p.name, ts.name AS time_sequence, tb.name AS time_block FROM programs AS p INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.id ASC, tb.name ASC, p.name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<option value=\"".$row['id']."\">".$row['time_sequence']."/".$row['time_block']." :: ".$row['name']."</option>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button type="submit" form="forceadd"><?php echo $lang['ok'] ?></button>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<?php endif ?>
|
||||||
|
<h2><?php echo $lang['timetable'] ?></h2>
|
||||||
|
<br>
|
||||||
|
<?php if($_SESSION['accesslevel']<1): ?>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['id'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm md"><?php echo $lang['description'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['instructor'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['location'] ?></th>
|
||||||
|
<th><?php echo $lang['timeblock'] ?></th>
|
||||||
|
<th data-breakpoints="xs"><?php echo $lang['actions'] ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>".$row['description']."</td>";
|
||||||
|
echo "<td>".$row['instructor']."</td>";
|
||||||
|
echo "<td>".$row['location']."</td>";
|
||||||
|
echo "<td>".$row['time_sequence']."/".$row['time_block']."</td>";
|
||||||
|
echo "<td><button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qunsubscribe']."\" data-url=\"./programs?unsub=".$row['id']."\">".$lang['unsubscribe']."</button></td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php elseif($_SESSION['accesslevel']>=1): ?>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['uid'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th><?php echo $lang['class'] ?></th>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT tb.id, ts.name AS time_sequence, tb.name AS time_block FROM time_blocks AS tb INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY ts.id ASC, tb.name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
$tbs=array();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<th data-breakpoints=\"xs sm\">".$row['time_sequence']."<br>".$row['time_block']."</th>";
|
||||||
|
array_push($tbs, $row['id']);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>".$row['class']."</td>";
|
||||||
|
$i=0;
|
||||||
|
$sql=$db->prepare("SELECT r.id AS regid, tb.id AS time_block, p.name FROM registrations AS r INNER JOIN programs AS p ON (p.id=r.program) INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) WHERE r.user=:uid ORDER BY tb.sequence ASC, tb.name ASC");
|
||||||
|
$sql->execute(array(":uid"=>$row['id']));
|
||||||
|
while($row2=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
while($row2['time_block']!=$tbs[$i]){
|
||||||
|
echo "<td>-</td>";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
echo "<td>";
|
||||||
|
echo $row2['name'];
|
||||||
|
if($_SESSION['accesslevel']>=2){
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./timetable?delete=".$row2['regid']."\">".$lang['delete']."</button>";
|
||||||
|
}
|
||||||
|
echo "</td>";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
for(;$i<count($tbs); $i++){
|
||||||
|
echo "<td>-</td>";
|
||||||
|
}
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php endif ?>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<button type="button" onclick="window.location='./timetable?export'"><?php echo $lang['export'] ?></button>
|
||||||
|
<?php if($_SESSION['accesslevel']>=2 && $config['general']['programs_needed']!=0): ?>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<h2><?php echo $lang['notcomplete'] ?></h2>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['uid'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th><?php echo $lang['progcount'] ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT u.id, u.name, u.class, (SELECT COUNT(r.id) AS count FROM registrations AS r WHERE r.user=u.id) AS progcount FROM users AS u WHERE u.accesslevel=0 and u.id<>1 and (SELECT COUNT(r.id) AS count FROM registrations AS r WHERE r.user=u.id)<:pc GROUP BY (u.id)");
|
||||||
|
$sql->execute(array(":pc"=>$config['general']['programs_needed']));
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>".$row['class']."</td>";
|
||||||
|
echo "<td>".$row['progcount']."</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
13
subs/timetable_programs.backend.php
Normal file
13
subs/timetable_programs.backend.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/timetable_programs.backend.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc timetable based on programs backend
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
$whereand="";
|
||||||
|
if($_SESSION['accesslevel']<2){
|
||||||
|
$whereand="and u.class='".$_SESSION['class']."' ";
|
||||||
|
}
|
78
subs/timetable_programs.php
Normal file
78
subs/timetable_programs.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/timetable_programs.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc timetable based on programs
|
||||||
|
* @author Fándly Gergő Zoltán 2017
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<h2><?php echo $lang['timetable_programs'] ?></h2>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<div id="printarea" style="width: 100%">
|
||||||
|
<center>
|
||||||
|
<div id="programs">
|
||||||
|
<?php
|
||||||
|
$sql=$db->prepare("SELECT p.id, p.name, p.instructor, p.location, ts.name AS time_sequence, tb.name AS time_block FROM programs AS p INNER JOIN time_blocks AS tb ON (tb.id=p.time_block) INNER JOIN time_sequences AS ts ON (ts.id=tb.sequence) ORDER BY p.name ASC, ts.id ASC, tb.name ASC");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<div style=\"page-break-after: always; page-break-inside: avoid; margin-bottom: 5em\">";
|
||||||
|
echo "<h3>".$row['name']."</h3>";
|
||||||
|
echo "<hr>";
|
||||||
|
echo "<p style=\"font-size: 0.8em\">".$lang['instructor'].": ".$row['instructor']." | ".$lang['location'].": ".$row['location']." | ".$lang['timeblock'].": ".$row['time_sequence']."/".$row['time_block']."</p>";
|
||||||
|
echo "<br>";
|
||||||
|
echo "<table class=\"table\">";
|
||||||
|
echo "<thead>";
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<th data-breakpoints=\"xs sm\">".$lang['num']."</th>";
|
||||||
|
echo "<th>".$lang['name']."</th>";
|
||||||
|
echo "<th>".$lang['class']."</th>";
|
||||||
|
echo "</tr>";
|
||||||
|
echo "</thead>";
|
||||||
|
echo "<tbody>";
|
||||||
|
|
||||||
|
$num=1;
|
||||||
|
$sql2=$db->prepare("SELECT u.name, u.class FROM registrations AS r INNER JOIN users AS u ON (u.id=r.user) WHERE r.program=:pid ".$whereand." ORDER BY u.name ASC");
|
||||||
|
$sql2->execute(array(":pid"=>$row['id']));
|
||||||
|
while($row2=$sql2->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$num."</td>";
|
||||||
|
echo "<td>".$row2['name']."</td>";
|
||||||
|
echo "<td>".$row2['class']."</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "</tbody>";
|
||||||
|
echo "</table>";
|
||||||
|
echo "</div>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</center>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<button type="button" onclick="window.location='./timetable_programs?print'"><?php echo $lang['print'] ?></button>
|
||||||
|
<?php if(isset($_GET['print'])): ?>
|
||||||
|
<style id="print">
|
||||||
|
body *{
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
#printarea{
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
#printarea, #printarea *{
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
setTimeout(function(){
|
||||||
|
window.print();
|
||||||
|
}, 2000);
|
||||||
|
</script>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
144
subs/users.backend.php
Normal file
144
subs/users.backend.php
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/users.backend.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc backend for users managemant
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']>=3){
|
||||||
|
if(isset($_POST['n_name']) && isset($_POST['n_class']) && isset($_POST['n_al']) && isset($_POST['n_password'])){
|
||||||
|
$sql=$db->prepare("INSERT INTO users (name, class, accesslevel, password) VALUES (:name, :class, :al, :passwd)");
|
||||||
|
$sql->execute(array(":name"=>$_POST['n_name'], ":class"=>$_POST['n_class'], ":al"=>$_POST['n_al'], ":passwd"=>\Defuse\Crypto\Crypto::encrypt($_POST['n_password'], $crypto)));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(3);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['all'])){
|
||||||
|
set_time_limit(120);
|
||||||
|
if($_GET['all']=="passwd"){
|
||||||
|
$sql=$db->prepare("SELECT id FROM users WHERE id<>1 and accesslevel<2");
|
||||||
|
$sql->execute();
|
||||||
|
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
$sql2=$db->prepare("UPDATE users SET password=:passwd WHERE id=:id");
|
||||||
|
$sql2->execute(array(":passwd"=>\Defuse\Crypto\Crypto::encrypt(functions::randomString(6, functions::RAND_SMALL), $crypto), ":id"=>$row['id']));
|
||||||
|
}
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else if($_GET['all']=="reset"){
|
||||||
|
$sql=$db->prepare("UPDATE users SET except_login=0, except_signup=0 WHERE id<>1");
|
||||||
|
$sql->execute();
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['delete'])){
|
||||||
|
$sql=$db->prepare("SELECT COUNT(id) AS count FROM users WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['delete']));
|
||||||
|
$res=$sql->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if($res['count']<1){
|
||||||
|
functions::setError(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$sql=$db->prepare("DELETE FROM users WHERE id=:id");
|
||||||
|
$sql->execute(array(":id"=>$_GET['delete']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(4);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['np_uid']) && isset($_GET['np_passwd'])){
|
||||||
|
$sql=$db->prepare("UPDATE users SET password=:passwd WHERE id=:uid");
|
||||||
|
$sql->execute(array(":passwd"=>\Defuse\Crypto\Crypto::encrypt($_GET['np_passwd'], $crypto), ":uid"=>$_GET['np_uid']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['el_uid']) && isset($_GET['el_param'])){
|
||||||
|
$sql=$db->prepare("UPDATE users SET except_login=:el WHERE id=:uid");
|
||||||
|
$sql->execute(array(":el"=>$_GET['el_param'], ":uid"=>$_GET['el_uid']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($_GET['es_uid']) && isset($_GET['es_param'])){
|
||||||
|
$sql=$db->prepare("UPDATE users SET except_signup=:es WHERE id=:uid");
|
||||||
|
$sql->execute(array(":es"=>$_GET['es_param'], ":uid"=>$_GET['es_uid']));
|
||||||
|
$res=$sql->rowCount();
|
||||||
|
|
||||||
|
if($res<1){
|
||||||
|
functions::setError(6);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
functions::setMessage(7);
|
||||||
|
if(!isset($_GET['backend'])) header("Location: ./users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$msql=$db->prepare("SELECT id, name, class, accesslevel, password, except_login, except_signup FROM users WHERE id<>1 ORDER BY class ASC, accesslevel DESC, name ASC");
|
||||||
|
$msql->execute();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Export
|
||||||
|
*/
|
||||||
|
if(isset($_GET['export'])){
|
||||||
|
$csv=$BOM;
|
||||||
|
$csv.=$config['general']['org']."\n".$config['general']['title']."\n\n";
|
||||||
|
|
||||||
|
if($_SESSION['accesslevel']==2){
|
||||||
|
$csv.=$lang['id'].";".$lang['name'].";".$lang['class'].";".$lang['accesslevel']."\n";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$csv.=$lang['id'].";".$lang['name'].";".$lang['class'].";".$lang['accesslevel'].";".$lang['password'].";".$lang['except_login'].";".$lang['except_signup']."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
if($_SESSION['accesslevel']==2){
|
||||||
|
$csv.=$row['id'].";".$row['name'].";".$row['class'].";".$lang['al'][$row['accesslevel']]."\n";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$csv.=$row['id'].";".$row['name'].";".$row['class'].";".$lang['al'][$row['accesslevel']].";".\Defuse\Crypto\Crypto::decrypt($row['password'], $crypto).";".$row['except_login'].";".$row['except_signup']."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//print
|
||||||
|
header("Content-type: application/octet-stream");
|
||||||
|
//header("Content-length: ".mb_strlen($csv));
|
||||||
|
header("Content-disposition: attachment; filename='".$config['general']['title']."_users_export_".date("Y-m-d H-i-s").".csv'");
|
||||||
|
echo $csv;
|
||||||
|
die();
|
||||||
|
}
|
99
subs/users.php
Normal file
99
subs/users.php
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* /subs/users.php
|
||||||
|
* @version 1.0
|
||||||
|
* @desc user managemant
|
||||||
|
* @author Fándly Gergő Zoltán
|
||||||
|
* @copy 2017 Fándly Gergő Zoltán
|
||||||
|
*/
|
||||||
|
|
||||||
|
$oid=0;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<?php if($_SESSION['accesslevel']>=3): ?>
|
||||||
|
<div id="newdiv">
|
||||||
|
<form class="ajaxform" method="POST" action="" id="new" autocomplete="off">
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php echo $lang['newuser'] ?></legend>
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['name'].": " ?></td>
|
||||||
|
<td><input type="text" name="n_name" placeholder="<?php echo $lang['name']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['class'].": " ?></td>
|
||||||
|
<td><input type="text" name="n_class" placeholder="<?php echo $lang['class']."..." ?>"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['accesslevel'].": " ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
for($i=0; $i<=3; $i++){
|
||||||
|
echo "<input type=\"radio\" name=\"n_al\" value=\"".$i."\" id=\"o_".$oid."\"><label for=\"o_".$oid."\">".$lang['al'][$i]."</label><br>";
|
||||||
|
$oid++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $lang['password'].": " ?></td>
|
||||||
|
<td><input type="text" name="n_password" placeholder="<?php echo $lang['password']."..." ?>" required></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<button type="submit" form="new"><?php echo $lang['ok'] ?></button>
|
||||||
|
</center>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<div id="utils">
|
||||||
|
<button class="ajaxbutton" type="button" data-keep="1" data-confirm="<?php echo $lang['qproceed'] ?>" data-url="./users?all=passwd"><?php echo $lang['newpassword4all'] ?></button>
|
||||||
|
<button class="ajaxbutton" type="button" data-keep="\" data-confirm="<?php echo $lang['qproceed'] ?>" data-url="./users?all=reset"><?php echo $lang['resetall'] ?></button>
|
||||||
|
</div>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<?php endif ?>
|
||||||
|
<h2><?php echo $lang['users'] ?></h2>
|
||||||
|
<br>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['id'] ?></th>
|
||||||
|
<th><?php echo $lang['name'] ?></th>
|
||||||
|
<th><?php echo $lang['class'] ?></th>
|
||||||
|
<th data-breakpoints="xs sm"><?php echo $lang['accesslevel'] ?></th>
|
||||||
|
<?php if($_SESSION['accesslevel']>=3): ?><th data-breakpoints="xs sm md"><?php echo $lang['password'] ?></th><?php endif ?>
|
||||||
|
<?php if($_SESSION['accesslevel']>=3): ?><th data-breakpoints="xs sm md"><?php echo $lang['except_login'] ?></th><?php endif ?>
|
||||||
|
<?php if($_SESSION['accesslevel']>=3): ?><th data-breakpoints="xs sm md"><?php echo $lang['except_signup'] ?></th><?php endif ?>
|
||||||
|
<?php if($_SESSION['accesslevel']>=3): ?><th data-breakpoints="xs sm"><?php echo $lang['actions'] ?></th><?php endif ?>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while($row=$msql->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>".$row['id']."</td>";
|
||||||
|
echo "<td>".$row['name']."</td>";
|
||||||
|
echo "<td>".$row['class']."</td>";
|
||||||
|
echo "<td>".$lang['al'][$row['accesslevel']]."</td>";
|
||||||
|
if($_SESSION['accesslevel']>=3){
|
||||||
|
echo "<td><span class=\"password\">".\Defuse\Crypto\Crypto::decrypt($row['password'], $crypto)."</span></td>";
|
||||||
|
echo "<td>".$row['except_login']."</td>";
|
||||||
|
echo "<td>".$row['except_signup']."</td>";
|
||||||
|
echo "<td>";
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-confirm=\"".$lang['qdelete']."\" data-url=\"./users?delete=".$row['id']."\">".$lang['delete']."</button>";
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-keep=\"1\" data-prompt=\"".$lang['qnewpassword'].functions::randomString(6, functions::RAND_SMALL)."\" data-url=\"./users?np_uid=".$row['id']."&np_passwd=\">".$lang['newpassword']."</button>";
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-keep=\"1\" data-prompt=\"".$lang['qexceptlogin']."\" data-url=\"./users?el_uid=".$row['id']."&el_param=\">".$lang['except_login']."</button>";
|
||||||
|
echo "<button class=\"ajaxbutton\" type=\"button\" data-keep=\"1\" data-prompt=\"".$lang['qexceptsignup']."\" data-url=\"./users?es_uid=".$row['id']."&es_param=\">".$lang['except_signup']."</button>";
|
||||||
|
}
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<hr class="placeholder">
|
||||||
|
<button type="button" onclick="window.location='./users?export'"><?php echo $lang['export'] ?></button>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user