diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2fa7ce7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.ini diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..bec493d --- /dev/null +++ b/.htaccess @@ -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] diff --git a/SignUp.zip b/SignUp.zip new file mode 100644 index 0000000..02fa56b Binary files /dev/null and b/SignUp.zip differ diff --git a/SignUp.zip.sig b/SignUp.zip.sig new file mode 100644 index 0000000..f2f4886 Binary files /dev/null and b/SignUp.zip.sig differ diff --git a/config/.htaccess b/config/.htaccess new file mode 100644 index 0000000..281d5c3 --- /dev/null +++ b/config/.htaccess @@ -0,0 +1,2 @@ +order allow,deny +deny from all diff --git a/config/allowlogin.cnf b/config/allowlogin.cnf new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/config/allowlogin.cnf @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/config/allowsignup.cnf b/config/allowsignup.cnf new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/config/allowsignup.cnf @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..07f0df8 --- /dev/null +++ b/config/config.php @@ -0,0 +1,148 @@ +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(); diff --git a/config/cryptokey.cnf b/config/cryptokey.cnf new file mode 100644 index 0000000..d775f63 --- /dev/null +++ b/config/cryptokey.cnf @@ -0,0 +1 @@ +def00000b0c6c796affdb1dbc89821e277b7ddcc88fd99669ab04984330c574c049eea27a3d54d40d1033d7c4ce9b500e04517ff27bcce47a57c54aaba85681404edc32a \ No newline at end of file diff --git a/config/db.sql b/config/db.sql new file mode 100644 index 0000000..423682f --- /dev/null +++ b/config/db.sql @@ -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'); diff --git a/config/lang/hun.ini b/config/lang/hun.ini new file mode 100644 index 0000000..25ff1da --- /dev/null +++ b/config/lang/hun.ini @@ -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!" diff --git a/config/lib/defuse-crypto.phar b/config/lib/defuse-crypto.phar new file mode 100644 index 0000000..05e024c Binary files /dev/null and b/config/lib/defuse-crypto.phar differ diff --git a/config/lib/functions.php b/config/lib/functions.php new file mode 100644 index 0000000..c4e5793 --- /dev/null +++ b/config/lib/functions.php @@ -0,0 +1,270 @@ +,<"; + } + $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'); + +?> diff --git a/config/lib/loginManager/lmConfig.php b/config/lib/loginManager/lmConfig.php new file mode 100644 index 0000000..d8f8f89 --- /dev/null +++ b/config/lib/loginManager/lmConfig.php @@ -0,0 +1,82 @@ +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; + } +} + +?> diff --git a/config/lib/loginManager/lmHandler.php b/config/lib/loginManager/lmHandler.php new file mode 100644 index 0000000..43fbf32 --- /dev/null +++ b/config/lib/loginManager/lmHandler.php @@ -0,0 +1,14 @@ + diff --git a/config/lib/loginManager/lmPassword.php b/config/lib/loginManager/lmPassword.php new file mode 100644 index 0000000..660e4e4 --- /dev/null +++ b/config/lib/loginManager/lmPassword.php @@ -0,0 +1,14 @@ + diff --git a/config/lib/loginManager/lmStates.php b/config/lib/loginManager/lmStates.php new file mode 100644 index 0000000..8c509c3 --- /dev/null +++ b/config/lib/loginManager/lmStates.php @@ -0,0 +1,24 @@ + diff --git a/config/lib/loginManager/lmTwoFactor.php b/config/lib/loginManager/lmTwoFactor.php new file mode 100644 index 0000000..749e58a --- /dev/null +++ b/config/lib/loginManager/lmTwoFactor.php @@ -0,0 +1,14 @@ + diff --git a/config/lib/loginManager/lmUtils.php b/config/lib/loginManager/lmUtils.php new file mode 100644 index 0000000..f841de5 --- /dev/null +++ b/config/lib/loginManager/lmUtils.php @@ -0,0 +1,44 @@ +,<"; + $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; + } + } +} + +?> diff --git a/config/lib/loginManager/loginManager.php b/config/lib/loginManager/loginManager.php new file mode 100644 index 0000000..6851f27 --- /dev/null +++ b/config/lib/loginManager/loginManager.php @@ -0,0 +1,394 @@ + + * + */ + + +/* + * 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 "
config->getCaptchaSitekey()."\" data-theme=\"dark\">
"; + } + else{ + echo "
config->getCaptchaSitekey()."\">
"; + } + 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; + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..2810b56 --- /dev/null +++ b/index.php @@ -0,0 +1,194 @@ +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 "
"; + if(functions::isMessage()){ + foreach(functions::getMessageArray() as $m){ + echo "
"; + echo "

".$lang['message'][$m]."

"; + echo "
"; + } + echo "
"; + } + if(functions::isError()){ + foreach(functions::getErrorArray() as $m){ + echo "
"; + echo "

".$lang['error'][$m]."

"; + echo "
"; + } + echo "
"; + } + echo "
"; + + //clear messages + functions::clearError(); + functions::clearMessage(); + + //stop execution + die(); + } +} + +$oid=0; + +?> + + + + + <?php echo ($view==""?$lang['index']:$lang[$view])." :: ".$config['general']['title']." - ".$config['general']['org'] ?> + + + + + + + + + + + + + + + + + + + + + +

+
+
+
+ "; + echo "

".$lang['message'][$m]."

"; + echo "
"; + } + echo "
"; + } + if(functions::isError()){ + foreach(functions::getErrorArray() as $m){ + echo "
"; + echo "

".$lang['error'][$m]."

"; + echo "
"; + } + echo "
"; + } + ?> + + validateLogin()): ?> +
+
+
+
+ +
+ + + + + + + + + +
" required>
" required>
+
+ loginPrepare(); $lm->printCaptcha() ?> +
+ +
+
+
+
+
+ +
+
+

+
+ +
+ + + +
+ +
+
+ + + diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..810fce6 --- /dev/null +++ b/license.txt @@ -0,0 +1,621 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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 diff --git a/res/icon.png b/res/icon.png new file mode 100644 index 0000000..9977747 Binary files /dev/null and b/res/icon.png differ diff --git a/res/loading.gif b/res/loading.gif new file mode 100644 index 0000000..2929f58 Binary files /dev/null and b/res/loading.gif differ diff --git a/script/footable/footable.min.js b/script/footable/footable.min.js new file mode 100644 index 0000000..131c887 --- /dev/null +++ b/script/footable/footable.min.js @@ -0,0 +1,10 @@ +/* +* FooTable v3 - FooTable is a jQuery plugin that aims to make HTML tables on smaller devices look awesome. +* @version 3.1.4 +* @link http://fooplugins.com +* @copyright Steven Usher & Brad Vincent 2015 +* @license Released under the GPLv3 license. +*/ +!function(a,b){window.console=window.console||{log:function(){},error:function(){}},a.fn.footable=function(a,c){return a=a||{},this.filter("table").each(function(d,e){b.init(e,a,c)})};var c={events:[]};b.__debug__=JSON.parse(localStorage.getItem("footable_debug"))||!1,b.__debug_options__=JSON.parse(localStorage.getItem("footable_debug_options"))||c,b.debug=function(d,e){return b.is["boolean"](d)?(b.__debug__=d,void(b.__debug__?(localStorage.setItem("footable_debug",JSON.stringify(b.__debug__)),b.__debug_options__=a.extend(!0,{},c,e||{}),b.is.hash(e)&&localStorage.setItem("footable_debug_options",JSON.stringify(b.__debug_options__))):(localStorage.removeItem("footable_debug"),localStorage.removeItem("footable_debug_options")))):b.__debug__},b.get=function(b){return a(b).first().data("__FooTable__")},b.init=function(a,c,d){var e=b.get(a);return e instanceof b.Table&&e.destroy(),new b.Table(a,c,d)},b.getRow=function(b){var c=a(b).closest("tr");return c.hasClass("footable-detail-row")&&(c=c.prev()),c.data("__FooTableRow__")}}(jQuery,FooTable=window.FooTable||{}),function(a){var b=function(){return!0};a.arr={},a.arr.each=function(b,c){if(a.is.array(b)&&a.is.fn(c))for(var d=0,e=b.length;e>d&&c(b[d],d)!==!1;d++);},a.arr.get=function(b,c){var d=[];if(!a.is.array(b))return d;if(!a.is.fn(c))return b;for(var e=0,f=b.length;f>e;e++)c(b[e],e)&&d.push(b[e]);return d},a.arr.any=function(c,d){if(!a.is.array(c))return!1;d=a.is.fn(d)?d:b;for(var e=0,f=c.length;f>e;e++)if(d(c[e],e))return!0;return!1},a.arr.contains=function(b,c){if(!a.is.array(b)||a.is.undef(c))return!1;for(var d=0,e=b.length;e>d;d++)if(b[d]==c)return!0;return!1},a.arr.first=function(c,d){if(!a.is.array(c))return null;d=a.is.fn(d)?d:b;for(var e=0,f=c.length;f>e;e++)if(d(c[e],e))return c[e];return null},a.arr.map=function(b,c){var d=[],e=null;if(!a.is.array(b)||!a.is.fn(c))return d;for(var f=0,g=b.length;g>f;f++)null!=(e=c(b[f],f))&&d.push(e);return d},a.arr.remove=function(b,c){var d=[],e=[];if(!a.is.array(b)||!a.is.fn(c))return e;for(var f=0,g=b.length;g>f;f++)c(b[f],f,e)&&(d.push(f),e.push(b[f]));for(d.sort(function(a,b){return b-a}),f=0,g=d.length;g>f;f++){var h=d[f]-f;b.splice(h,1)}return e},a.arr["delete"]=function(b,c){var d=-1,e=null;if(!a.is.array(b)||a.is.undef(c))return e;for(var f=0,g=b.length;g>f;f++)if(b[f]==c){d=f,e=b[f];break}return-1!=d&&b.splice(d,1),e},a.arr.replace=function(a,b,c){var d=a.indexOf(b);-1!==d&&(a[d]=c)}}(FooTable),function(a){a.is={},a.is.type=function(a,b){return typeof a===b},a.is.defined=function(a){return"undefined"!=typeof a},a.is.undef=function(a){return"undefined"==typeof a},a.is.array=function(a){return"[object Array]"===Object.prototype.toString.call(a)},a.is.date=function(a){return"[object Date]"===Object.prototype.toString.call(a)&&!isNaN(a.getTime())},a.is["boolean"]=function(a){return"[object Boolean]"===Object.prototype.toString.call(a)},a.is.string=function(a){return"[object String]"===Object.prototype.toString.call(a)},a.is.number=function(a){return"[object Number]"===Object.prototype.toString.call(a)&&!isNaN(a)},a.is.fn=function(b){return a.is.defined(window)&&b===window.alert||"[object Function]"===Object.prototype.toString.call(b)},a.is.error=function(a){return"[object Error]"===Object.prototype.toString.call(a)},a.is.object=function(a){return"[object Object]"===Object.prototype.toString.call(a)},a.is.hash=function(b){return a.is.object(b)&&b.constructor===Object&&!b.nodeType&&!b.setInterval},a.is.element=function(a){return"object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName},a.is.promise=function(b){return a.is.object(b)&&a.is.fn(b.then)&&a.is.fn(b.promise)},a.is.jq=function(b){return a.is.defined(window.jQuery)&&b instanceof jQuery&&b.length>0},a.is.moment=function(b){return a.is.defined(window.moment)&&a.is.object(b)&&a.is["boolean"](b._isAMomentObject)},a.is.emptyObject=function(b){if(!a.is.hash(b))return!1;for(var c in b)if(b.hasOwnProperty(c))return!1;return!0},a.is.emptyArray=function(b){return a.is.array(b)?0===b.length:!0},a.is.emptyString=function(b){return a.is.string(b)?0===b.length:!0}}(FooTable),function(a){a.str={},a.str.contains=function(b,c,d){return a.is.emptyString(b)||a.is.emptyString(c)?!1:c.length<=b.length&&-1!==(d?b.toUpperCase().indexOf(c.toUpperCase()):b.indexOf(c))},a.str.containsExact=function(b,c,d){return a.is.emptyString(b)||a.is.emptyString(c)||c.length>b.length?!1:new RegExp("\\b"+a.str.escapeRegExp(c)+"\\b",d?"i":"").test(b)},a.str.containsWord=function(b,c,d){if(a.is.emptyString(b)||a.is.emptyString(c)||b.lengthf;f++)if(d?e[f].toUpperCase()==c.toUpperCase():e[f]==c)return!0;return!1},a.str.from=function(b,c){return a.is.emptyString(b)?b:a.str.contains(b,c)?b.substring(b.indexOf(c)+1):b},a.str.startsWith=function(b,c){return a.is.emptyString(b)?b==c:b.slice(0,c.length)==c},a.str.toCamelCase=function(b){return a.is.emptyString(b)?b:b.toUpperCase()===b?b.toLowerCase():b.replace(/^([A-Z])|[-\s_](\w)/g,function(b,c,d){return a.is.string(d)?d.toUpperCase():c.toLowerCase()})},a.str.random=function(b){return b=a.is.emptyString(b)?"":b,b+Math.random().toString(36).substr(2,9)},a.str.escapeRegExp=function(b){return a.is.emptyString(b)?b:b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}(FooTable),function(a){"use strict";function b(){}Object.create||(Object.create=function(){var b=function(){};return function(c){if(arguments.length>1)throw Error("Second argument not supported");if(!a.is.object(c))throw TypeError("Argument must be an object");b.prototype=c;var d=new b;return b.prototype=null,d}}());var c=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/;b.__extend__=function(b,d,e,f){b[d]=a.is.fn(f)&&c.test(e)?function(a,b){return function(){var a,c;return a=this._super,this._super=f,c=b.apply(this,arguments),this._super=a,c}}(d,e):e},b.extend=function(d,e){function f(b,d,e,f){b[d]=a.is.fn(f)&&c.test(e)?function(a,b,c){return function(){var a,d;return a=this._super,this._super=c,d=b.apply(this,arguments),this._super=a,d}}(d,e,f):e}var g=Array.prototype.slice.call(arguments);if(d=g.shift(),e=g.shift(),a.is.hash(d)){var h=Object.create(this.prototype),i=this.prototype;for(var j in d)"__ctor__"!==j&&f(h,j,d[j],i[j]);var k=a.is.fn(h.__ctor__)?h.__ctor__:function(){if(!a.is.fn(this.construct))throw new SyntaxError('FooTable class objects must be constructed with the "new" keyword.');this.construct.apply(this,arguments)};return h.construct=a.is.fn(h.construct)?h.construct:function(){},k.prototype=h,h.constructor=k,k.extend=b.extend,k}a.is.string(d)&&a.is.fn(e)&&f(this.prototype,d,e,this.prototype[d])},a.Class=b,a.ClassFactory=a.Class.extend({construct:function(){this.registered={}},contains:function(b){return a.is.defined(this.registered[b])},names:function(){var a,b=[];for(a in this.registered)this.registered.hasOwnProperty(a)&&b.push(a);return b},register:function(b,c,d){if(a.is.string(b)&&a.is.fn(c)){var e=this.registered[b];this.registered[b]={name:b,klass:c,priority:a.is.number(d)?d:a.is.defined(e)?e.priority:0}}},load:function(b,c,d){var e,f,g=this,h=Array.prototype.slice.call(arguments),i=[],j=[];b=h.shift()||{};for(e in g.registered)if(g.registered.hasOwnProperty(e)){var k=g.registered[e];b.hasOwnProperty(e)&&(f=b[e],a.is.string(f)&&(f=a.getFnPointer(b[e])),a.is.fn(f)&&(k={name:e,klass:f,priority:g.registered[e].priority})),i.push(k)}for(e in b)b.hasOwnProperty(e)&&!g.registered.hasOwnProperty(e)&&(f=b[e],a.is.string(f)&&(f=a.getFnPointer(b[e])),a.is.fn(f)&&i.push({name:e,klass:f,priority:0}));return i.sort(function(a,b){return b.priority-a.priority}),a.arr.each(i,function(b){a.is.fn(b.klass)&&j.push(g._make(b.klass,h))}),j},make:function(b,c,d){var e,f=this,g=Array.prototype.slice.call(arguments);return b=g.shift(),e=f.registered[b],a.is.fn(e.klass)?f._make(e.klass,g):null},_make:function(a,b){function c(){return a.apply(this,b)}return c.prototype=a.prototype,new c}})}(FooTable),function(a,b){b.css2json=function(c){if(b.is.emptyString(c))return{};for(var d,e,f,g={},h=c.split(";"),i=0,j=h.length;j>i;i++)b.is.emptyString(h[i])||(d=h[i].split(":"),b.is.emptyString(d[0])||b.is.emptyString(d[1])||(e=b.str.toCamelCase(a.trim(d[0])),f=a.trim(d[1]),g[e]=f));return g},b.getFnPointer=function(a){if(b.is.emptyString(a))return null;var c=window,d=a.split(".");return b.arr.each(d,function(a){c[a]&&(c=c[a])}),b.is.fn(c)?c:null},b.checkFnValue=function(a,c,d){function e(a,c,d){return b.is.fn(c)?function(){return c.apply(a,arguments)}:d}return d=b.is.fn(d)?d:null,b.is.fn(c)?e(a,c,d):b.is.type(c,"string")?e(a,b.getFnPointer(c),d):d}}(jQuery,FooTable),function(a,b){b.Cell=b.Class.extend({construct:function(a,b,c,d){this.ft=a,this.row=b,this.column=c,this.created=!1,this.define(d)},define:function(c){this.$el=b.is.element(c)||b.is.jq(c)?a(c):null,this.$detail=null;var d=b.is.hash(c)&&b.is.hash(c.options)&&b.is.defined(c.value);this.value=this.column.parser.call(this.column,b.is.jq(this.$el)?this.$el:d?c.value:c,this.ft.o),this.o=a.extend(!0,{classes:null,style:null},d?c.options:{}),this.classes=b.is.jq(this.$el)&&this.$el.attr("class")?this.$el.attr("class").match(/\S+/g):b.is.array(this.o.classes)?this.o.classes:b.is.string(this.o.classes)?this.o.classes.match(/\S+/g):[],this.style=b.is.jq(this.$el)&&this.$el.attr("style")?b.css2json(this.$el.attr("style")):b.is.hash(this.o.style)?this.o.style:b.is.string(this.o.style)?b.css2json(this.o.style):{}},$create:function(){this.created||((this.$el=b.is.jq(this.$el)?this.$el:a("")).data("value",this.value).contents().detach().end().append(this.format(this.value)),this._setClasses(this.$el),this._setStyle(this.$el),this.$detail=a("").addClass(this.row.classes.join(" ")).data("__FooTableCell__",this).append(a("")).append(a("")),this.created=!0)},collapse:function(){this.created&&(this.$detail.children("th").html(this.column.title),this.$el.clone().attr("id",this.$el.attr("id")?this.$el.attr("id")+"-detail":void 0).css("display","table-cell").html("").append(this.$el.contents().detach()).replaceAll(this.$detail.children("td").first()),b.is.jq(this.$detail.parent())||this.$detail.appendTo(this.row.$details.find(".footable-details > tbody")))},restore:function(){if(this.created){if(b.is.jq(this.$detail.parent())){var a=this.$detail.children("td").first();this.$el.attr("class",a.attr("class")).attr("style",a.attr("style")).css("display",this.column.hidden||!this.column.visible?"none":"table-cell").append(a.contents().detach())}this.$detail.detach()}},parse:function(){return this.column.parser.call(this.column,this.$el,this.ft.o)},format:function(a){return this.column.formatter.call(this.column,a,this.ft.o)},val:function(c,d){if(b.is.undef(c))return this.value;var e=this,f=b.is.hash(c)&&b.is.hash(c.options)&&b.is.defined(c.value);if(this.o=a.extend(!0,{classes:e.classes,style:e.style},f?c.options:{}),this.value=f?c.value:c,this.classes=b.is.array(this.o.classes)?this.o.classes:b.is.string(this.o.classes)?this.o.classes.match(/\S+/g):[],this.style=b.is.hash(this.o.style)?this.o.style:b.is.string(this.o.style)?b.css2json(this.o.style):{},this.created){this.$el.data("value",this.value).empty();var g=this.$detail.children("td").first().empty(),h=b.is.jq(this.$detail.parent())?g:this.$el;h.append(this.format(this.value)),this._setClasses(h),this._setStyle(h),(b.is["boolean"](d)?d:!0)&&this.row.draw()}},_setClasses:function(a){var c=!b.is.emptyArray(this.column.classes),d=!b.is.emptyArray(this.classes),e=null;a.removeAttr("class"),(c||d)&&(c&&d?e=this.classes.concat(this.column.classes).join(" "):c?e=this.column.classes.join(" "):d&&(e=this.classes.join(" ")),b.is.emptyString(e)||a.addClass(e))},_setStyle:function(c){var d=!b.is.emptyObject(this.column.style),e=!b.is.emptyObject(this.style),f=null;c.removeAttr("style"),(d||e)&&(d&&e?f=a.extend({},this.column.style,this.style):d?f=this.column.style:e&&(f=this.style),b.is.hash(f)&&c.css(f))}})}(jQuery,FooTable),function(a,b){b.Column=b.Class.extend({construct:function(a,c,d){this.ft=a,this.type=b.is.emptyString(d)?"text":d,this.virtual=b.is["boolean"](c.virtual)?c.virtual:!1,this.$el=b.is.jq(c.$el)?c.$el:null,this.index=b.is.number(c.index)?c.index:-1,this.define(c),this.$create()},define:function(a){this.hidden=b.is["boolean"](a.hidden)?a.hidden:!1,this.visible=b.is["boolean"](a.visible)?a.visible:!0,this.name=b.is.string(a.name)?a.name:null,null==this.name&&(this.name="col"+(a.index+1)),this.title=b.is.string(a.title)?a.title:null,!this.virtual&&null==this.title&&b.is.jq(this.$el)&&(this.title=this.$el.html()),null==this.title&&(this.title="Column "+(a.index+1)),this.style=b.is.hash(a.style)?a.style:b.is.string(a.style)?b.css2json(a.style):{},this.classes=b.is.array(a.classes)?a.classes:b.is.string(a.classes)?a.classes.match(/\S+/g):[],this.parser=b.checkFnValue(this,a.parser,this.parser),this.formatter=b.checkFnValue(this,a.formatter,this.formatter)},$create:function(){(this.$el=!this.virtual&&b.is.jq(this.$el)?this.$el:a("")).html(this.title).addClass(this.classes.join(" ")).css(this.style)},parser:function(c){if(b.is.element(c)||b.is.jq(c)){var d=a(c).data("value");return b.is.defined(d)?d:a(c).html()}return b.is.defined(c)&&null!=c?c+"":null},formatter:function(a){return null==a?"":a},createCell:function(a){var c=b.is.jq(a.$el)?a.$el.children("td,th").get(this.index):null,d=b.is.hash(a.value)?a.value[this.name]:null;return new b.Cell(this.ft,a,this,c||d)}}),b.columns=new b.ClassFactory,b.columns.register("text",b.Column)}(jQuery,FooTable),function(a,b){b.Component=b.Class.extend({construct:function(a,c){if(!(a instanceof b.Table))throw new TypeError("The instance parameter must be an instance of FooTable.Table.");this.ft=a,this.enabled=b.is["boolean"](c)?c:!1},preinit:function(a){},init:function(){},destroy:function(){},predraw:function(){},draw:function(){},postdraw:function(){}}),b.components=new b.ClassFactory}(jQuery,FooTable),function(a,b){b.Defaults=function(){this.stopPropagation=!1,this.on=null},b.defaults=new b.Defaults}(jQuery,FooTable),function(a,b){b.Row=b.Class.extend({construct:function(a,b,c){this.ft=a,this.columns=b,this.created=!1,this.define(c)},define:function(c){this.$el=b.is.element(c)||b.is.jq(c)?a(c):null,this.$toggle=a("",{"class":"footable-toggle fooicon fooicon-plus"});var d=b.is.hash(c),e=d&&b.is.hash(c.options)&&b.is.hash(c.value);this.value=d?e?c.value:c:null,this.o=a.extend(!0,{expanded:!1,classes:null,style:null},e?c.options:{}),this.expanded=b.is.jq(this.$el)?this.$el.data("expanded")||this.o.expanded:this.o.expanded,this.classes=b.is.jq(this.$el)&&this.$el.attr("class")?this.$el.attr("class").match(/\S+/g):b.is.array(this.o.classes)?this.o.classes:b.is.string(this.o.classes)?this.o.classes.match(/\S+/g):[],this.style=b.is.jq(this.$el)&&this.$el.attr("style")?b.css2json(this.$el.attr("style")):b.is.hash(this.o.style)?this.o.style:b.is.string(this.o.style)?b.css2json(this.o.style):{},this.cells=this.createCells();var f=this;f.value={},b.arr.each(f.cells,function(a){f.value[a.column.name]=a.val()})},$create:function(){if(!this.created){(this.$el=b.is.jq(this.$el)?this.$el:a("")).data("__FooTableRow__",this),this._setClasses(this.$el),this._setStyle(this.$el),"last"==this.ft.rows.toggleColumn&&this.$toggle.addClass("last-column"),this.$details=a("",{"class":"footable-detail-row"}).append(a("",{colspan:this.ft.columns.visibleColspan}).append(a("",{"class":"footable-details "+this.ft.classes.join(" ")}).append("")));var c=this;b.arr.each(c.cells,function(a){a.created||a.$create(),c.$el.append(a.$el)}),c.$el.off("click.ft.row").on("click.ft.row",{self:c},c._onToggle),this.created=!0}},createCells:function(){var a=this;return b.arr.map(a.columns,function(b){return b.createCell(a)})},val:function(c,d){var e=this;if(!b.is.hash(c))return b.is.hash(this.value)&&!b.is.emptyObject(this.value)||(this.value={},b.arr.each(this.cells,function(a){e.value[a.column.name]=a.val()})),this.value;this.collapse(!1);var f=b.is.hash(c),g=f&&b.is.hash(c.options)&&b.is.hash(c.value);if(this.o=a.extend(!0,{expanded:e.expanded,classes:e.classes,style:e.style},g?c.options:{}),this.expanded=this.o.expanded,this.classes=b.is.array(this.o.classes)?this.o.classes:b.is.string(this.o.classes)?this.o.classes.match(/\S+/g):[],this.style=b.is.hash(this.o.style)?this.o.style:b.is.string(this.o.style)?b.css2json(this.o.style):{},f)if(g&&(c=c.value),b.is.hash(this.value))for(var h in c)c.hasOwnProperty(h)&&(this.value[h]=c[h]);else this.value=c;else this.value=null;b.arr.each(this.cells,function(a){b.is.defined(e.value[a.column.name])&&a.val(e.value[a.column.name],!1)}),this.created&&(this._setClasses(this.$el),this._setStyle(this.$el),(b.is["boolean"](d)?d:!0)&&this.draw())},_setClasses:function(a){var c=!b.is.emptyArray(this.classes),d=null;a.removeAttr("class"),c&&(d=this.classes.join(" "),b.is.emptyString(d)||a.addClass(d))},_setStyle:function(a){var c=!b.is.emptyObject(this.style),d=null;a.removeAttr("style"),c&&(d=this.style,b.is.hash(d)&&a.css(d))},expand:function(){if(this.created){var a=this;a.ft.raise("expand.ft.row",[a]).then(function(){a.__hidden__=b.arr.map(a.cells,function(a){return a.column.hidden&&a.column.visible?a:null}),a.__hidden__.length>0&&(a.$details.insertAfter(a.$el).children("td").first().attr("colspan",a.ft.columns.visibleColspan),b.arr.each(a.__hidden__,function(a){a.collapse()})),a.$el.attr("data-expanded",!0),a.$toggle.removeClass("fooicon-plus").addClass("fooicon-minus"),a.expanded=!0})}},collapse:function(a){if(this.created){var c=this;c.ft.raise("collapse.ft.row",[c]).then(function(){b.arr.each(c.__hidden__,function(a){a.restore()}),c.$details.detach(),c.$el.removeAttr("data-expanded"),c.$toggle.removeClass("fooicon-minus").addClass("fooicon-plus"),(b.is["boolean"](a)?a:!0)&&(c.expanded=!1)})}},predraw:function(a){this.created&&(this.expanded&&this.collapse(!1),this.$toggle.detach(),a=b.is["boolean"](a)?a:!0,a&&this.$el.detach())},draw:function(a){this.created||this.$create(),b.is.jq(a)&&a.append(this.$el);var c=this;b.arr.each(c.cells,function(a){a.$el.css("display",a.column.hidden||!a.column.visible?"none":"table-cell"),c.ft.rows.showToggle&&c.ft.columns.hasHidden&&("first"==c.ft.rows.toggleColumn&&a.column.index==c.ft.columns.firstVisibleIndex||"last"==c.ft.rows.toggleColumn&&a.column.index==c.ft.columns.lastVisibleIndex)&&a.$el.prepend(c.$toggle),a.$el.add(a.column.$el).removeClass("footable-first-visible footable-last-visible"),a.column.index==c.ft.columns.firstVisibleIndex&&a.$el.add(a.column.$el).addClass("footable-first-visible"),a.column.index==c.ft.columns.lastVisibleIndex&&a.$el.add(a.column.$el).addClass("footable-last-visible")}),this.expanded&&this.expand()},toggle:function(){this.created&&this.ft.columns.hasHidden&&(this.expanded?this.collapse():this.expand())},_onToggle:function(b){var c=b.data.self;a(b.target).is(c.ft.rows.toggleSelector)&&c.toggle()}})}(jQuery,FooTable),function(a,b){b.instances=[],b.Table=b.Class.extend({construct:function(c,d,e){this._resizeTimeout=null,this.id=b.instances.push(this),this.initialized=!1,this.$el=(b.is.jq(c)?c:a(c)).first(),this.$loader=a("
",{"class":"footable-loader"}).append(a("",{"class":"fooicon fooicon-loader"})),this.o=a.extend(!0,{},b.defaults,d),this.data=this.$el.data()||{},this.classes=[],this.components=b.components.load(b.is.hash(this.data.components)?this.data.components:this.o.components,this),this.breakpoints=this.use(FooTable.Breakpoints),this.columns=this.use(FooTable.Columns),this.rows=this.use(FooTable.Rows),this._construct(e)},_construct:function(a){var c=this;this._preinit().then(function(){return c._init()}).always(function(d){return c.$el.show(),b.is.error(d)?void console.error("FooTable: unhandled error thrown during initialization.",d):c.raise("ready.ft.table").then(function(){b.is.fn(a)&&a.call(c,c)})})},_preinit:function(){var a=this;return this.raise("preinit.ft.table",[a.data]).then(function(){var c=(a.$el.attr("class")||"").match(/\S+/g)||[];a.o.ajax=b.checkFnValue(a,a.data.ajax,a.o.ajax),a.o.stopPropagation=b.is["boolean"](a.data.stopPropagation)?a.data.stopPropagation:a.o.stopPropagation;for(var d=0,e=c.length;e>d;d++)b.str.startsWith(c[d],"footable")||a.classes.push(c[d]);return a.$el.hide().after(a.$loader),a.execute(!1,!1,"preinit",a.data)})},_init:function(){var c=this;return c.raise("init.ft.table").then(function(){var d=c.$el.children("thead"),e=c.$el.children("tbody"),f=c.$el.children("tfoot");return c.$el.addClass("footable footable-"+c.id),b.is.hash(c.o.on)&&c.$el.on(c.o.on),0==f.length&&c.$el.append(f=a("
")),0==e.length&&c.$el.append(""),0==d.length&&c.$el.prepend(d=a("")),c.execute(!1,!0,"init").then(function(){return c.$el.data("__FooTable__",c),0==f.children("tr").length&&f.remove(),0==d.children("tr").length&&d.remove(),c.raise("postinit.ft.table").then(function(){return c.draw()}).always(function(){a(window).off("resize.ft"+c.id,c._onWindowResize).on("resize.ft"+c.id,{self:c},c._onWindowResize),c.initialized=!0})})})},destroy:function(){var c=this;return c.raise("destroy.ft.table").then(function(){return c.execute(!0,!0,"destroy").then(function(){c.$el.removeData("__FooTable__").removeClass("footable-"+c.id),b.is.hash(c.o.on)&&c.$el.off(c.o.on),a(window).off("resize.ft"+c.id,c._onWindowResize),c.initialized=!1})}).fail(function(a){b.is.error(a)&&console.error("FooTable: unhandled error thrown while destroying the plugin.",a)})},raise:function(c,d){var e=this,f=b.__debug__&&(b.is.emptyArray(b.__debug_options__.events)||b.arr.any(b.__debug_options__.events,function(a){return b.str.contains(c,a)}));return d=d||[],d.unshift(this),a.Deferred(function(b){var g=a.Event(c);1==e.o.stopPropagation&&e.$el.one(c,function(a){a.stopPropagation()}),f&&console.log("FooTable:"+c+": ",d),e.$el.trigger(g,d),g.isDefaultPrevented()?(f&&console.log('FooTable: default prevented for the "'+c+'" event.'),b.reject(g)):b.resolve(g)})},use:function(a){for(var b=0,c=this.components.length;c>b;b++)if(this.components[b]instanceof a)return this.components[b];return null},draw:function(){var a=this,c=a.$el.clone().insertBefore(a.$el);return a.$el.detach(),a.execute(!1,!0,"predraw").then(function(){return a.raise("predraw.ft.table").then(function(){return a.execute(!1,!0,"draw").then(function(){return a.raise("draw.ft.table").then(function(){return a.execute(!1,!0,"postdraw").then(function(){return a.raise("postdraw.ft.table")})})})})}).fail(function(a){b.is.error(a)&&console.error("FooTable: unhandled error thrown during a draw operation.",a)}).always(function(){c.replaceWith(a.$el),a.$loader.remove()})},execute:function(a,c,d,e,f){var g=this,h=Array.prototype.slice.call(arguments);a=h.shift(),c=h.shift();var i=c?b.arr.get(g.components,function(a){return a.enabled}):g.components.slice(0);return h.unshift(a?i.reverse():i),g._execute.apply(g,h)},_execute:function(c,d,e,f){if(!c||!c.length)return a.when();var g,h=this,i=Array.prototype.slice.call(arguments);return c=i.shift(),d=i.shift(),g=c.shift(),b.is.fn(g[d])?a.Deferred(function(a){try{var c=g[d].apply(g,i);if(b.is.promise(c))return c.then(a.resolve,a.reject);a.resolve(c)}catch(e){a.reject(e)}}).then(function(){return h._execute.apply(h,[c,d].concat(i))}):h._execute.apply(h,[c,d].concat(i))},_onWindowResize:function(a){var b=a.data.self;null!=b._resizeTimeout&&clearTimeout(b._resizeTimeout),b._resizeTimeout=setTimeout(function(){b._resizeTimeout=null,b.raise("resize.ft.table").then(function(){b.breakpoints.check()})},300)}})}(jQuery,FooTable),function(a,b){b.is.undef(window.moment)||(b.DateColumn=b.Column.extend({construct:function(a,c){this._super(a,c,"date"),this.formatString=b.is.string(c.formatString)?c.formatString:"MM-DD-YYYY"},parser:function(c){if(b.is.element(c)||b.is.jq(c)){var d=a(c).data("value");c=b.is.defined(d)?d:a(c).text(),b.is.string(c)&&(c=isNaN(c)?c:+c)}if(b.is.date(c))return moment(c);if(b.is.object(c)&&b.is["boolean"](c._isAMomentObject))return c;if(b.is.string(c)){if(isNaN(c))return moment(c,this.formatString);c=+c}return b.is.number(c)?moment(c):null},formatter:function(a){return b.is.object(a)&&b.is["boolean"](a._isAMomentObject)&&a.isValid()?a.format(this.formatString):""},filterValue:function(c){if((b.is.element(c)||b.is.jq(c))&&(c=a(c).data("filterValue")||a(c).text()),b.is.hash(c)&&b.is.hash(c.options)&&(b.is.string(c.options.filterValue)&&(c=c.options.filterValue),b.is.defined(c.value)&&(c=c.value)),b.is.object(c)&&b.is["boolean"](c._isAMomentObject))return c.format(this.formatString);if(b.is.string(c)){if(isNaN(c))return c;c=+c}return b.is.number(c)||b.is.date(c)?moment(c).format(this.formatString):b.is.defined(c)&&null!=c?c+"":""}}),b.columns.register("date",b.DateColumn))}(jQuery,FooTable),function(a,b){b.HTMLColumn=b.Column.extend({construct:function(a,b){this._super(a,b,"html")},parser:function(c){if(b.is.string(c)&&(c=a(a.trim(c))),b.is.element(c)&&(c=a(c)),b.is.jq(c)){var d=c.prop("tagName").toLowerCase();if("td"==d||"th"==d){var e=c.data("value");return b.is.defined(e)?e:c.contents()}return c}return null}}),b.columns.register("html",b.HTMLColumn)}(jQuery,FooTable),function(a,b){b.NumberColumn=b.Column.extend({construct:function(a,c){this._super(a,c,"number"),this.decimalSeparator=b.is.string(c.decimalSeparator)?c.decimalSeparator:".",this.thousandSeparator=b.is.string(c.thousandSeparator)?c.thousandSeparator:",",this.decimalSeparatorRegex=new RegExp(b.str.escapeRegExp(this.decimalSeparator),"g"),this.thousandSeparatorRegex=new RegExp(b.str.escapeRegExp(this.thousandSeparator),"g"),this.cleanRegex=new RegExp("[^0-9"+b.str.escapeRegExp(this.decimalSeparator)+"]","g")},parser:function(c){if(b.is.element(c)||b.is.jq(c)){var d=a(c).data("value");c=b.is.defined(d)?d:a(c).text().replace(this.cleanRegex,"")}return b.is.string(c)&&(c=c.replace(this.thousandSeparatorRegex,"").replace(this.decimalSeparatorRegex,"."),c=parseFloat(c)),b.is.number(c)?c:null},formatter:function(a){if(null==a)return"";var b=(a+"").split(".");return 2==b.length&&b[0].length>3&&(b[0]=b[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,this.thousandSeparator)),b.join(this.decimalSeparator)}}),b.columns.register("number",b.NumberColumn)}(jQuery,FooTable),function(a,b){b.Breakpoint=b.Class.extend({construct:function(a,b){this.name=a,this.width=b}})}(jQuery,FooTable),function(a,b){b.Breakpoints=b.Component.extend({construct:function(a){this._super(a,!0),this.o=a.o,this.current=null,this.array=[],this.cascade=this.o.cascade,this.useParentWidth=this.o.useParentWidth,this.hidden=null,this._classNames="",this.getWidth=b.checkFnValue(this,this.o.getWidth,this.getWidth)},preinit:function(a){var c=this;return this.ft.raise("preinit.ft.breakpoints",[a]).then(function(){c.cascade=b.is["boolean"](a.cascade)?a.cascade:c.cascade,c.o.breakpoints=b.is.hash(a.breakpoints)?a.breakpoints:c.o.breakpoints,c.getWidth=b.checkFnValue(c,a.getWidth,c.getWidth),null==c.o.breakpoints&&(c.o.breakpoints={xs:480,sm:768,md:992,lg:1200});for(var d in c.o.breakpoints)c.o.breakpoints.hasOwnProperty(d)&&(c.array.push(new b.Breakpoint(d,c.o.breakpoints[d])),c._classNames+="breakpoint-"+d+" ");c.array.sort(function(a,b){return b.width-a.width})})},init:function(){var a=this;return this.ft.raise("init.ft.breakpoints").then(function(){a.current=a.get()})},draw:function(){this.ft.$el.removeClass(this._classNames).addClass("breakpoint-"+this.current.name)},calculate:function(){for(var a,c=this,d=null,e=[],f=null,g=c.getWidth(),h=0,i=c.array.length;i>h;h++)a=c.array[h],(!d&&h==i-1||g>=a.width&&(f instanceof b.Breakpoint?gd;d++)if(this.cascade?b.str.containsWord(this.hidden,c[d]):c[d]==this.current.name)return!1;return!0},check:function(){var a=this,c=a.get();c instanceof b.Breakpoint&&c!=a.current&&a.ft.raise("before.ft.breakpoints",[a.current,c]).then(function(){var b=a.current;return a.current=c,a.ft.draw().then(function(){a.ft.raise("after.ft.breakpoints",[a.current,b])})})},get:function(a){return b.is.undef(a)?this.calculate():a instanceof b.Breakpoint?a:b.is.string(a)?b.arr.first(this.array,function(b){return b.name==a}):b.is.number(a)&&a>=0&&af&&(f=a.index)}),f++;for(var g,h,i=0;f>i;i++)g={},b.arr.each(c,function(a){return a.index==i?(g=a,!1):void 0}),h={},b.arr.each(d,function(a){return a.index==i?(h=a,!1):void 0}),e.push(a.extend(!0,{},g,h))}return e}var f,g,h=[],i=[],j=d.ft.$el.find("tr.footable-header, thead > tr:last:has([data-breakpoints]), tbody > tr:first:has([data-breakpoints]), thead > tr:last, tbody > tr:first").first();if(j.length>0){var k=j.parent().is("tbody")&&j.children().length==j.children("td").length;k||(d.$header=j.addClass("footable-header")),j.children("td,th").each(function(b,c){f=a(c),g=f.data(),g.index=b,g.$el=f,g.virtual=k,i.push(g)}),k&&(d.showHeader=!1)}b.is.array(d.o.columns)&&!b.is.emptyArray(d.o.columns)?(b.arr.each(d.o.columns,function(a,b){a.index=b,h.push(a)}),d.parseFinalize(c,e(h,i))):b.is.promise(d.o.columns)?d.o.columns.then(function(a){b.arr.each(a,function(a,b){a.index=b,h.push(a)}),d.parseFinalize(c,e(h,i))},function(a){c.reject(Error("Columns ajax request error: "+a.status+" ("+a.statusText+")"))}):d.parseFinalize(c,e(h,i))})},parseFinalize:function(a,c){var d,e=this,f=[];b.arr.each(c,function(a){(d=b.columns.contains(a.type)?b.columns.make(a.type,e.ft,a):new b.Column(e.ft,a))&&f.push(d)}),b.is.emptyArray(f)?a.reject(Error("No columns supplied.")):(f.sort(function(a,b){return a.index-b.index}),a.resolve(f))},preinit:function(a){var c=this;return c.ft.raise("preinit.ft.columns",[a]).then(function(){return c.parse(a).then(function(d){c.array=d,c.showHeader=b.is["boolean"](a.showHeader)?a.showHeader:c.showHeader})})},init:function(){var a=this;return this.ft.raise("init.ft.columns",[a.array]).then(function(){a.$create()})},destroy:function(){var a=this;this.ft.raise("destroy.ft.columns").then(function(){a._fromHTML||a.$header.remove()})},predraw:function(){var a=this,c=!0;a.visibleColspan=0,a.firstVisibleIndex=0,a.lastVisibleIndex=0,a.hasHidden=!1,b.arr.each(a.array,function(b){b.hidden=!a.ft.breakpoints.visible(b.breakpoints),!b.hidden&&b.visible&&(c&&(a.firstVisibleIndex=b.index,c=!1),a.lastVisibleIndex=b.index,a.visibleColspan++),b.hidden&&(a.hasHidden=!0)}),a.ft.$el.toggleClass("breakpoint",a.hasHidden)},draw:function(){b.arr.each(this.array,function(a){a.$el.css("display",a.hidden||!a.visible?"none":"table-cell")}),!this.showHeader&&b.is.jq(this.$header.parent())&&this.$header.detach()},$create:function(){var c=this;c.$header=b.is.jq(c.$header)?c.$header:a("",{"class":"footable-header" +}),c.$header.children("th,td").detach(),b.arr.each(c.array,function(a){c.$header.append(a.$el)}),c.showHeader&&!b.is.jq(c.$header.parent())&&c.ft.$el.children("thead").append(c.$header)},get:function(a){return a instanceof b.Column?a:b.is.string(a)?b.arr.first(this.array,function(b){return b.name==a}):b.is.number(a)?b.arr.first(this.array,function(b){return b.index==a}):b.is.fn(a)?b.arr.get(this.array,a):null},ensure:function(a){var c=this,d=[];return b.is.array(a)?(b.arr.each(a,function(a){d.push(c.get(a))}),d):d}}),b.components.register("columns",b.Columns,900)}(jQuery,FooTable),function(a){a.Defaults.prototype.columns=[],a.Defaults.prototype.showHeader=!0}(FooTable),function(a,b){b.Rows=b.Component.extend({construct:function(a){this._super(a,!0),this.o=a.o,this.array=[],this.all=[],this.showToggle=a.o.showToggle,this.toggleSelector=a.o.toggleSelector,this.toggleColumn=a.o.toggleColumn,this.emptyString=a.o.empty,this.expandFirst=a.o.expandFirst,this.expandAll=a.o.expandAll,this.$empty=null,this._fromHTML=b.is.emptyArray(a.o.rows)&&!b.is.promise(a.o.rows)},parse:function(){var c=this;return a.Deferred(function(a){var d=c.ft.$el.children("tbody").children("tr");b.is.array(c.o.rows)&&c.o.rows.length>0?c.parseFinalize(a,c.o.rows):b.is.promise(c.o.rows)?c.o.rows.then(function(b){c.parseFinalize(a,b)},function(b){a.reject(Error("Rows ajax request error: "+b.status+" ("+b.statusText+")"))}):b.is.jq(d)?(c.parseFinalize(a,d),d.detach()):c.parseFinalize(a,[])})},parseFinalize:function(c,d){var e=this,f=a.map(d,function(a){return new b.Row(e.ft,e.ft.columns.array,a)});c.resolve(f)},preinit:function(a){var c=this;return c.ft.raise("preinit.ft.rows",[a]).then(function(){return c.parse().then(function(d){c.all=d,c.array=c.all.slice(0),c.showToggle=b.is["boolean"](a.showToggle)?a.showToggle:c.showToggle,c.toggleSelector=b.is.string(a.toggleSelector)?a.toggleSelector:c.toggleSelector,c.toggleColumn=b.is.string(a.toggleColumn)?a.toggleColumn:c.toggleColumn,"first"!=c.toggleColumn&&"last"!=c.toggleColumn&&(c.toggleColumn="first"),c.emptyString=b.is.string(a.empty)?a.empty:c.emptyString,c.expandFirst=b.is["boolean"](a.expandFirst)?a.expandFirst:c.expandFirst,c.expandAll=b.is["boolean"](a.expandAll)?a.expandAll:c.expandAll})})},init:function(){var a=this;return a.ft.raise("init.ft.rows",[a.all]).then(function(){a.$create()})},destroy:function(){var a=this;this.ft.raise("destroy.ft.rows").then(function(){b.arr.each(a.array,function(b){b.predraw(!a._fromHTML)})})},predraw:function(){b.arr.each(this.array,function(a){a.predraw()}),this.array=this.all.slice(0)},$create:function(){this.$empty=a("",{"class":"footable-empty"}).append(a("",{"class":"footable-filtering"}).prependTo(d.ft.$el.children("thead")),d.$cell=a(""),this.ft.$el.append(b)),this.$row.appendTo(b),this.detached=!1}this.$cell.attr("colspan",this.ft.columns.visibleColspan),this._createLinks(),this._setVisible(this.current,this.current>this.previous),this._setNavigation(!0),this.$count.text(this.formattedCount)}},$create:function(){this._createdLinks=0;var b="footable-paging-center";switch(this.position){case"left":b="footable-paging-left";break;case"right":b="footable-paging-right"}this.ft.$el.addClass("footable-paging").addClass(b),this.$cell=a(""),this.ft.$el.append(c)),this.$row=a("",{"class":"footable-paging"}).append(this.$cell).appendTo(c),this.$pagination=a(""),b.ft.$el.append(d)),b.$row=a("",{"class":"footable-editing"}).append(b.$cell).appendTo(d)},$buttonShow:function(){return'"},$buttonHide:function(){return'"},$buttonAdd:function(){return' "},$buttonEdit:function(){return' "},$buttonDelete:function(){return'"},$buttonView:function(){return' "},$rowButtons:function(){return b.is.jq(this._$buttons)?this._$buttons.clone():(this._$buttons=a('
'),this.allowView&&this._$buttons.append(this.$buttonView()),this.allowEdit&&this._$buttons.append(this.$buttonEdit()),this.allowDelete&&this._$buttons.append(this.$buttonDelete()),this._$buttons)},draw:function(){this.$cell.attr("colspan",this.ft.columns.visibleColspan)},_onEditClick:function(c){c.preventDefault();var d=c.data.self,e=a(this).closest("tr").data("__FooTableRow__");e instanceof b.Row&&d.ft.raise("edit.ft.editing",[e]).then(function(){d.callbacks.editRow.call(d.ft,e)})},_onDeleteClick:function(c){c.preventDefault();var d=c.data.self,e=a(this).closest("tr").data("__FooTableRow__");e instanceof b.Row&&d.ft.raise("delete.ft.editing",[e]).then(function(){d.callbacks.deleteRow.call(d.ft,e)})},_onViewClick:function(c){c.preventDefault();var d=c.data.self,e=a(this).closest("tr").data("__FooTableRow__");e instanceof b.Row&&d.ft.raise("view.ft.editing",[e]).then(function(){d.callbacks.viewRow.call(d.ft,e)})},_onAddClick:function(a){a.preventDefault();var b=a.data.self;b.ft.raise("add.ft.editing").then(function(){b.callbacks.addRow.call(b.ft)})},_onShowClick:function(a){a.preventDefault();var b=a.data.self;b.ft.raise("show.ft.editing").then(function(){b.ft.$el.addClass("footable-editing-show"),b.column.visible=!0,b.ft.draw()})},_onHideClick:function(a){a.preventDefault();var b=a.data.self;b.ft.raise("hide.ft.editing").then(function(){b.ft.$el.removeClass("footable-editing-show"),b.column.visible=!1,b.ft.draw()})}}),b.components.register("editing",b.Editing,850)}(jQuery,FooTable),function(a,b){b.EditingColumn=b.Column.extend({construct:function(a,b,c){this._super(a,c,"editing"),this.editing=b},$create:function(){(this.$el=!this.virtual&&b.is.jq(this.$el)?this.$el:a("
"; + $html.=""; + $html.=""; + $html.="
").text(this.emptyString))},draw:function(){var a=this,c=a.ft.$el.children("tbody"),d=!0;a.array.length>0?(a.$empty.detach(),b.arr.each(a.array,function(b){(a.expandFirst&&d||a.expandAll)&&(b.expanded=!0,d=!1),b.draw(c)})):(a.$empty.children("td").attr("colspan",a.ft.columns.visibleColspan),c.append(a.$empty))},load:function(c,d){var e=this,f=a.map(c,function(a){return new b.Row(e.ft,e.ft.columns.array,a)});b.arr.each(this.array,function(a){a.predraw()}),this.all=(b.is["boolean"](d)?d:!1)?this.all.concat(f):f,this.array=this.all.slice(0),this.ft.draw()},expand:function(){b.arr.each(this.array,function(a){a.expand()})},collapse:function(){b.arr.each(this.array,function(a){a.collapse()})}}),b.components.register("rows",b.Rows,800)}(jQuery,FooTable),function(a){a.Defaults.prototype.rows=[],a.Defaults.prototype.empty="No results",a.Defaults.prototype.showToggle=!0,a.Defaults.prototype.toggleSelector="tr,td,.footable-toggle",a.Defaults.prototype.toggleColumn="first",a.Defaults.prototype.expandFirst=!1,a.Defaults.prototype.expandAll=!1}(FooTable),function(a){a.Table.prototype.loadRows=function(a,b){this.rows.load(a,b)}}(FooTable),function(a){a.Filter=a.Class.extend({construct:function(b,c,d,e,f,g,h){this.name=b,this.space=!a.is.string(e)||"OR"!=e&&"AND"!=e?"AND":e,this.connectors=a.is["boolean"](f)?f:!0,this.ignoreCase=a.is["boolean"](g)?g:!0,this.hidden=a.is["boolean"](h)?h:!1,this.query=c instanceof a.Query?c:new a.Query(c,this.space,this.connectors,this.ignoreCase),this.columns=d},match:function(b){return a.is.string(b)?(a.is.string(this.query)&&(this.query=new a.Query(this.query,this.space,this.connectors,this.ignoreCase)),this.query instanceof a.Query?this.query.match(b):!1):!1},matchRow:function(b){var c=this,d=a.arr.map(b.cells,function(b){return a.arr.contains(c.columns,b.column)?b.filterValue:null}).join(" ");return c.match(d)}})}(FooTable),function(a,b){b.Filtering=b.Component.extend({construct:function(a){this._super(a,a.o.filtering.enabled),this.filters=a.o.filtering.filters,this.delay=a.o.filtering.delay,this.min=a.o.filtering.min,this.space=a.o.filtering.space,this.connectors=a.o.filtering.connectors,this.ignoreCase=a.o.filtering.ignoreCase,this.exactMatch=a.o.filtering.exactMatch,this.placeholder=a.o.filtering.placeholder,this.dropdownTitle=a.o.filtering.dropdownTitle,this.position=a.o.filtering.position,this.$row=null,this.$cell=null,this.$dropdown=null,this.$input=null,this.$button=null,this._filterTimeout=null,this._exactRegExp=/^"(.*?)"$/},preinit:function(a){var c=this;return c.ft.raise("preinit.ft.filtering").then(function(){c.ft.$el.hasClass("footable-filtering")&&(c.enabled=!0),c.enabled=b.is["boolean"](a.filtering)?a.filtering:c.enabled,c.enabled&&(c.space=b.is.string(a.filterSpace)?a.filterSpace:c.space,c.min=b.is.number(a.filterMin)?a.filterMin:c.min,c.connectors=b.is["boolean"](a.filterConnectors)?a.filterConnectors:c.connectors,c.ignoreCase=b.is["boolean"](a.filterIgnoreCase)?a.filterIgnoreCase:c.ignoreCase,c.exactMatch=b.is["boolean"](a.filterExactMatch)?a.filterExactMatch:c.exactMatch,c.delay=b.is.number(a.filterDelay)?a.filterDelay:c.delay,c.placeholder=b.is.string(a.filterPlaceholder)?a.filterPlaceholder:c.placeholder,c.dropdownTitle=b.is.string(a.filterDropdownTitle)?a.filterDropdownTitle:c.dropdownTitle,c.filters=b.is.array(a.filterFilters)?c.ensure(a.filterFilters):c.ensure(c.filters),c.ft.$el.hasClass("footable-filtering-left")&&(c.position="left"),c.ft.$el.hasClass("footable-filtering-center")&&(c.position="center"),c.ft.$el.hasClass("footable-filtering-right")&&(c.position="right"),c.position=b.is.string(a.filterPosition)?a.filterPosition:c.position)},function(){c.enabled=!1})},init:function(){var a=this;return a.ft.raise("init.ft.filtering").then(function(){a.$create()},function(){a.enabled=!1})},destroy:function(){var a=this;return a.ft.raise("destroy.ft.filtering").then(function(){a.ft.$el.removeClass("footable-filtering").find("thead > tr.footable-filtering").remove()})},$create:function(){var c,d=this,e=a("
",{"class":"form-group footable-filtering-search"}).append(a("
").attr("colspan",d.ft.columns.visibleColspan).appendTo(d.$row),d.$form=a("
",{"class":"form-inline"}).append(e).appendTo(d.$cell),d.$input=a("",{type:"text","class":"form-control",placeholder:d.placeholder}),d.$button=a("
").attr("colspan",this.ft.columns.visibleColspan);var c=this.ft.$el.children("tfoot");0==c.length&&(c=a("
").attr("colspan",b.ft.columns.visibleColspan).append(b.$buttonShow()),b.allowAdd&&b.$cell.append(b.$buttonAdd()),b.$cell.append(b.$buttonHide()),b.alwaysShow&&b.ft.$el.addClass("footable-editing-always-show"),b.allowAdd||b.ft.$el.addClass("footable-editing-no-add"),b.allowEdit||b.ft.$el.addClass("footable-editing-no-edit"),b.allowDelete||b.ft.$el.addClass("footable-editing-no-delete"),b.allowView||b.ft.$el.addClass("footable-editing-no-view");var d=b.ft.$el.children("tfoot");0==d.length&&(d=a("
",{"class":"footable-editing"})).html(this.title)},parser:function(c){if(b.is.string(c)&&(c=a(a.trim(c))),b.is.element(c)&&(c=a(c)),b.is.jq(c)){var d=c.prop("tagName").toLowerCase();return"td"==d||"th"==d?c.data("value")||c.contents():c}return null},createCell:function(c){var d=this.editing.$rowButtons(),e=a("").append(d);return b.is.jq(c.$el)&&(0===this.index?e.prependTo(c.$el):e.insertAfter(c.$el.children().eq(this.index-1))),new b.Cell(this.ft,c,this,e||e.html())}}),b.columns.register("editing",b.EditingColumn)}(jQuery,FooTable),function(a,b){b.Defaults.prototype.editing={enabled:!1,pageToNew:!0,position:"right",alwaysShow:!1,addRow:function(){},editRow:function(a){},deleteRow:function(a){},viewRow:function(a){},showText:' Edit rows',hideText:"Cancel",addText:"New row",editText:'',deleteText:'',viewText:'',allowAdd:!0,allowEdit:!0,allowDelete:!0,allowView:!1,column:{classes:"footable-editing",name:"editing",title:"",filterable:!1,sortable:!1}}}(jQuery,FooTable),function(a,b){b.is.defined(b.Paging)&&(b.Paging.prototype.unpaged=[],b.Paging.extend("predraw",function(){this.unpaged=this.ft.rows.array.slice(0),this._super()}))}(jQuery,FooTable),function(a,b){b.Row.prototype.add=function(c){c=b.is["boolean"](c)?c:!0;var d=this;return a.Deferred(function(a){var b=d.ft.rows.all.push(d)-1;return c?d.ft.draw().then(function(){a.resolve(b)}):void a.resolve(b)})},b.Row.prototype["delete"]=function(c){c=b.is["boolean"](c)?c:!0;var d=this;return a.Deferred(function(a){var e=d.ft.rows.all.indexOf(d);return b.is.number(e)&&e>=0&&e=0&&e>b&&(f=this.ft.rows.all[b]),f instanceof FooTable.Row&&a.is.hash(c)&&f.val(c,d)},a.Rows.prototype["delete"]=function(b,c){var d=this.ft.rows.all.length,e=b;a.is.number(b)&&b>=0&&d>b&&(e=this.ft.rows.all[b]),e instanceof FooTable.Row&&e["delete"](c)}}(FooTable),function(a,b){var c=0,d=function(a){var b,c,d=2166136261;for(b=0,c=a.length;c>b;b++)d^=a.charCodeAt(b),d+=(d<<1)+(d<<4)+(d<<7)+(d<<8)+(d<<24);return d>>>0}(location.origin+location.pathname);b.State=b.Component.extend({construct:function(a){this._super(a,a.o.state.enabled),this._key="1",this.key=this._key+(b.is.string(a.o.state.key)?a.o.state.key:this._uid()),this.filtering=b.is["boolean"](a.o.state.filtering)?a.o.state.filtering:!0,this.paging=b.is["boolean"](a.o.state.paging)?a.o.state.paging:!0,this.sorting=b.is["boolean"](a.o.state.sorting)?a.o.state.sorting:!0},preinit:function(a){var c=this;this.ft.raise("preinit.ft.state",[a]).then(function(){c.enabled=b.is["boolean"](a.state)?a.state:c.enabled,c.enabled&&(c.key=c._key+(b.is.string(a.stateKey)?a.stateKey:c.key),c.filtering=b.is["boolean"](a.stateFiltering)?a.stateFiltering:c.filtering,c.paging=b.is["boolean"](a.statePaging)?a.statePaging:c.paging,c.sorting=b.is["boolean"](a.stateSorting)?a.stateSorting:c.sorting)},function(){c.enabled=!1})},get:function(a){return JSON.parse(localStorage.getItem(this.key+":"+a))},set:function(a,b){localStorage.setItem(this.key+":"+a,JSON.stringify(b))},remove:function(a){localStorage.removeItem(this.key+":"+a)},read:function(){this.ft.execute(!1,!0,"readState")},write:function(){this.ft.execute(!1,!0,"writeState")},clear:function(){this.ft.execute(!1,!0,"clearState")},_uid:function(){var a=this.ft.$el.attr("id");return d+"_"+(b.is.string(a)?a:++c)}}),b.components.register("state",b.State,700)}(jQuery,FooTable),function(a){a.Component.prototype.readState=function(){},a.Component.prototype.writeState=function(){},a.Component.prototype.clearState=function(){}}(FooTable),function(a){a.Defaults.prototype.state={enabled:!1,filtering:!0,paging:!0,sorting:!0,key:null}}(FooTable),function(a){a.Filtering&&(a.Filtering.prototype.readState=function(){if(this.ft.state.filtering){var b=this.ft.state.get("filtering");a.is.hash(b)&&!a.is.emptyArray(b.filters)&&(this.filters=this.ensure(b.filters))}},a.Filtering.prototype.writeState=function(){if(this.ft.state.filtering){var b=a.arr.map(this.filters,function(b){return{name:b.name,query:b.query instanceof a.Query?b.query.val():b.query,columns:a.arr.map(b.columns,function(a){return a.name}),hidden:b.hidden,space:b.space,connectors:b.connectors,ignoreCase:b.ignoreCase}});this.ft.state.set("filtering",{filters:b})}},a.Filtering.prototype.clearState=function(){this.ft.state.filtering&&this.ft.state.remove("filtering")})}(FooTable),function(a){a.Paging&&(a.Paging.prototype.readState=function(){if(this.ft.state.paging){var b=this.ft.state.get("paging");a.is.hash(b)&&(this.current=b.current,this.size=b.size)}},a.Paging.prototype.writeState=function(){this.ft.state.paging&&this.ft.state.set("paging",{current:this.current,size:this.size})},a.Paging.prototype.clearState=function(){this.ft.state.paging&&this.ft.state.remove("paging")})}(FooTable),function(a){a.Sorting&&(a.Sorting.prototype.readState=function(){if(this.ft.state.sorting){var b=this.ft.state.get("sorting");if(a.is.hash(b)){var c=this.ft.columns.get(b.column);c instanceof a.Column&&(this.column=c,this.column.direction=b.direction)}}},a.Sorting.prototype.writeState=function(){this.ft.state.sorting&&this.column instanceof a.Column&&this.ft.state.set("sorting",{column:this.column.name,direction:this.column.direction})},a.Sorting.prototype.clearState=function(){this.ft.state.sorting&&this.ft.state.remove("sorting")})}(FooTable),function(a){a.Table.extend("_construct",function(a){this.state=this.use(FooTable.State),this._super(a)}),a.Table.extend("_preinit",function(){var a=this;return a._super().then(function(){a.state.enabled&&a.state.read()})}),a.Table.extend("draw",function(){var a=this;return a._super().then(function(){a.state.enabled&&a.state.write()})})}(FooTable); \ No newline at end of file diff --git a/script/footable/footable.standalone.min.css b/script/footable/footable.standalone.min.css new file mode 100644 index 0000000..0ac5adf --- /dev/null +++ b/script/footable/footable.standalone.min.css @@ -0,0 +1 @@ +.footable .btn,.footable .caret{display:inline-block;vertical-align:middle}.footable-details.table,.footable-details.table *,.footable.table,.footable.table *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.footable-details.table th,.footable.table th{text-align:left}.footable-details.table,.footable.table{width:100%;max-width:100%;margin-bottom:20px}.footable-details.table>caption+thead>tr:first-child>td,.footable-details.table>caption+thead>tr:first-child>th,.footable-details.table>colgroup+thead>tr:first-child>td,.footable-details.table>colgroup+thead>tr:first-child>th,.footable-details.table>thead:first-child>tr:first-child>td,.footable-details.table>thead:first-child>tr:first-child>th,.footable.table>caption+thead>tr:first-child>td,.footable.table>caption+thead>tr:first-child>th,.footable.table>colgroup+thead>tr:first-child>td,.footable.table>colgroup+thead>tr:first-child>th,.footable.table>thead:first-child>tr:first-child>td,.footable.table>thead:first-child>tr:first-child>th{border-top:0}.footable-details.table>tbody>tr>td,.footable-details.table>tbody>tr>th,.footable-details.table>tfoot>tr>td,.footable-details.table>tfoot>tr>th,.footable-details.table>thead>tr>td,.footable-details.table>thead>tr>th,.footable.table>tbody>tr>td,.footable.table>tbody>tr>th,.footable.table>tfoot>tr>td,.footable.table>tfoot>tr>th,.footable.table>thead>tr>td,.footable.table>thead>tr>th{padding:8px;line-height:1.42857143;vertical-align:top;border-top:1px solid #ddd}.footable-details.table>thead>tr>td,.footable-details.table>thead>tr>th,.footable.table>thead>tr>td,.footable.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.footable-details.table-condensed>tbody>tr>td,.footable-details.table-condensed>tbody>tr>th,.footable-details.table-condensed>tfoot>tr>td,.footable-details.table-condensed>tfoot>tr>th,.footable-details.table-condensed>thead>tr>td,.footable-details.table-condensed>thead>tr>th,.footable.table-condensed>tbody>tr>td,.footable.table-condensed>tbody>tr>th,.footable.table-condensed>tfoot>tr>td,.footable.table-condensed>tfoot>tr>th,.footable.table-condensed>thead>tr>td,.footable.table-condensed>thead>tr>th{padding:5px}.footable-details.table-bordered,.footable-details.table-bordered>tbody>tr>td,.footable-details.table-bordered>tbody>tr>th,.footable-details.table-bordered>tfoot>tr>td,.footable-details.table-bordered>tfoot>tr>th,.footable-details.table-bordered>thead>tr>td,.footable-details.table-bordered>thead>tr>th,.footable.table-bordered,.footable.table-bordered>tbody>tr>td,.footable.table-bordered>tbody>tr>th,.footable.table-bordered>tfoot>tr>td,.footable.table-bordered>tfoot>tr>th,.footable.table-bordered>thead>tr>td,.footable.table-bordered>thead>tr>th{border:1px solid #ddd}.footable-details.table-bordered>thead>tr>td,.footable-details.table-bordered>thead>tr>th,.footable.table-bordered>thead>tr>td,.footable.table-bordered>thead>tr>th{border-bottom-width:2px}.footable-details.table-striped>tbody>tr:nth-child(odd),.footable.table-striped>tbody>tr:nth-child(odd){background-color:#f9f9f9}.footable-details.table-hover>tbody>tr:hover,.footable.table-hover>tbody>tr:hover{background-color:#f5f5f5}.footable .btn{padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-appearance:button;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px;overflow:visible;text-transform:none}.footable .btn.focus,.footable .btn:focus,.footable .btn:hover{color:#333;text-decoration:none}.footable .btn-default{color:#333;background-color:#fff;border-color:#ccc}.footable .btn-default.active,.footable .btn-default.focus,.footable .btn-default:active,.footable .btn-default:focus,.footable .btn-default:hover,.footable .open>.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}.footable .btn-primary{color:#fff;background-color:#337ab7;border-color:#2e6da4}.footable .btn-primary.active,.footable .btn-primary.focus,.footable .btn-primary:active,.footable .btn-primary:focus,.footable .btn-primary:hover,.footable .open>.dropdown-toggle.btn-primary{color:#fff;background-color:#286090;border-color:#204d74}.footable .btn-group,.footable .btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.footable .btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.footable .btn-group>.btn:first-child{margin-left:0}.footable .btn-group-vertical>.btn,.footable .btn-group>.btn{position:relative;float:left}.footable .btn-group-xs>.btn,.footable .btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.footable .btn-group-sm>.btn,.footable .btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.footable .btn-group-lg>.btn,.footable .btn-lg{padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.footable .caret{width:0;height:0;margin-left:2px;border-top:4px solid;border-right:4px solid transparent;border-left:4px solid transparent}.footable .btn .caret{margin-left:0}.form-group{margin-bottom:15px}.footable .form-control{display:block;width:100%;height:34px;padding:6px 12px;margin:0;font-family:inherit;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.footable .input-group{position:relative;display:table;border-collapse:separate}.footable .input-group .form-control{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.footable .input-group-btn{position:relative;font-size:0}.footable .input-group-addon,.footable .input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.footable .input-group .form-control,.footable .input-group-addon,.footable .input-group-btn{display:table-cell}.footable .input-group-btn:last-child>.btn,.footable .input-group-btn:last-child>.btn-group,.footable .input-group-btn>.btn+.btn{margin-left:-1px}.footable .input-group-btn>.btn{position:relative}.footable .input-group-btn>.btn:active,.footable .input-group-btn>.btn:focus,.footable .input-group-btn>.btn:hover{z-index:2}.footable .input-group .form-control:first-child,.footable .input-group-addon:first-child,.footable .input-group-btn:first-child>.btn,.footable .input-group-btn:first-child>.btn-group>.btn,.footable .input-group-btn:first-child>.dropdown-toggle,.footable .input-group-btn:last-child>.btn-group:not(:last-child)>.btn,.footable .input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.footable .input-group .form-control:last-child,.footable .input-group-addon:last-child,.footable .input-group-btn:first-child>.btn-group:not(:first-child)>.btn,.footable .input-group-btn:first-child>.btn:not(:first-child),.footable .input-group-btn:last-child>.btn,.footable .input-group-btn:last-child>.btn-group>.btn,.footable .input-group-btn:last-child>.dropdown-toggle{border-top-left-radius:0;border-bottom-left-radius:0}.footable .checkbox,.footable .radio{position:relative;display:block;margin-top:10px;margin-bottom:10px}.footable .checkbox label,.footable .radio label{max-width:100%;min-height:20px;padding-left:20px;margin-bottom:0;font-weight:400;cursor:pointer}.footable .checkbox input[type=checkbox],.footable .checkbox-inline input[type=checkbox],.footable .radio input[type=radio],.footable .radio-inline input[type=radio]{position:absolute;margin:4px 0 0 -20px;line-height:normal}.footable .dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;text-align:left;list-style:none;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175)}.footable .open>.dropdown-menu{display:block}.footable .dropdown-menu-right{right:0;left:auto}.footable .dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.footable .dropdown-menu>li>a:focus,.footable .dropdown-menu>li>a:hover{color:#262626;text-decoration:none;background-color:#f5f5f5}.footable .pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.footable .pagination>li{display:inline}.footable .pagination>li:first-child>a,.footable .pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-left-radius:4px}.footable .pagination>li>a,.footable .pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}.footable .pagination>li>a:focus,.footable .pagination>li>a:hover,.footable .pagination>li>span:focus,.footable .pagination>li>span:hover{color:#23527c;background-color:#eee;border-color:#ddd}.footable .pagination>.active>a,.footable .pagination>.active>a:focus,.footable .pagination>.active>a:hover,.footable .pagination>.active>span,.footable .pagination>.active>span:focus,.footable .pagination>.active>span:hover{z-index:2;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.footable .pagination>.disabled>a,.footable .pagination>.disabled>a:focus,.footable .pagination>.disabled>a:hover,.footable .pagination>.disabled>span,.footable .pagination>.disabled>span:focus,.footable .pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.footable .label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}.footable .label-default{background-color:#777}.footable-loader.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05)}.footable .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}table.footable-details,table.footable>thead>tr.footable-filtering>th div.form-group{margin-bottom:0}@media (min-width:768px){.footable .form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.footable .form-inline .form-control{display:inline-block;width:auto;vertical-align:middle}.footable .form-inline .input-group{display:inline-table;vertical-align:middle}.footable .form-inline .input-group .form-control,.footable .form-inline .input-group .input-group-addon,.footable .form-inline .input-group .input-group-btn{width:auto}.footable .form-inline .input-group>.form-control{width:100%}}table.footable,table.footable-details{position:relative;width:100%;border-spacing:0;border-collapse:collapse}table.footable-hide-fouc{display:none}table>tbody>tr>td>span.footable-toggle{margin-right:8px;opacity:.3}table>tbody>tr>td>span.footable-toggle.last-column{margin-left:8px;float:right}table.table-condensed>tbody>tr>td>span.footable-toggle{margin-right:5px}table.footable-details>tbody>tr>th:nth-child(1){min-width:40px;width:120px}table.footable-details>tbody>tr>td:nth-child(2){word-break:break-all}table.footable-details>tbody>tr:first-child>td,table.footable-details>tbody>tr:first-child>th,table.footable-details>tfoot>tr:first-child>td,table.footable-details>tfoot>tr:first-child>th,table.footable-details>thead>tr:first-child>td,table.footable-details>thead>tr:first-child>th{border-top-width:0}table.footable-details.table-bordered>tbody>tr:first-child>td,table.footable-details.table-bordered>tbody>tr:first-child>th,table.footable-details.table-bordered>tfoot>tr:first-child>td,table.footable-details.table-bordered>tfoot>tr:first-child>th,table.footable-details.table-bordered>thead>tr:first-child>td,table.footable-details.table-bordered>thead>tr:first-child>th{border-top-width:1px}div.footable-loader{vertical-align:middle;text-align:center;height:300px;position:relative}div.footable-loader>span.fooicon{display:inline-block;opacity:.3;font-size:30px;line-height:32px;width:32px;height:32px;margin-top:-16px;margin-left:-16px;position:absolute;top:50%;left:50%;-webkit-animation:fooicon-spin-r 2s infinite linear;animation:fooicon-spin-r 2s infinite linear}table.footable>tbody>tr.footable-empty>td{vertical-align:middle;text-align:center;font-size:30px}table.footable>tbody>tr>td,table.footable>tbody>tr>th{display:none}table.footable>tbody>tr.footable-detail-row>td,table.footable>tbody>tr.footable-detail-row>th,table.footable>tbody>tr.footable-empty>td,table.footable>tbody>tr.footable-empty>th{display:table-cell}@-webkit-keyframes fooicon-spin-r{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fooicon-spin-r{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fooicon{display:inline-block;font-size:inherit;font-family:FontAwesome!important;font-style:normal;font-weight:400;line-height:1;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.fooicon:after,.fooicon:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.fooicon-loader:before{content:"\f01e"}.fooicon-plus:before{content:"\f067"}.fooicon-minus:before{content:"\f068"}.fooicon-search:before{content:"\f002"}.fooicon-remove:before{content:"\f00d"}.fooicon-sort:before{content:"\f0dc"}.fooicon-sort-asc:before{content:"\f160"}.fooicon-sort-desc:before{content:"\f161"}.fooicon-pencil:before{content:"\f040"}.fooicon-trash:before{content:"\f1f8"}.fooicon-eye-close:before{content:"\f070"}.fooicon-flash:before{content:"\f0e7"}.fooicon-cog:before{content:"\f013"}.fooicon-stats:before{content:"\f080"}table.footable>thead>tr.footable-filtering>th{border-bottom-width:1px;font-weight:400}.footable-filtering-external.footable-filtering-right,table.footable.footable-filtering-right>thead>tr.footable-filtering>th,table.footable>thead>tr.footable-filtering>th{text-align:right}.footable-filtering-external.footable-filtering-left,table.footable.footable-filtering-left>thead>tr.footable-filtering>th{text-align:left}.footable-filtering-external.footable-filtering-center,.footable-paging-external.footable-paging-center,table.footable-paging-center>tfoot>tr.footable-paging>td,table.footable.footable-filtering-center>thead>tr.footable-filtering>th,table.footable>tfoot>tr.footable-paging>td{text-align:center}table.footable>thead>tr.footable-filtering>th div.form-group+div.form-group{margin-top:5px}table.footable>thead>tr.footable-filtering>th div.input-group{width:100%}.footable-filtering-external ul.dropdown-menu>li>a.checkbox,table.footable>thead>tr.footable-filtering>th ul.dropdown-menu>li>a.checkbox{margin:0;display:block;position:relative}.footable-filtering-external ul.dropdown-menu>li>a.checkbox>label,table.footable>thead>tr.footable-filtering>th ul.dropdown-menu>li>a.checkbox>label{display:block;padding-left:20px}.footable-filtering-external ul.dropdown-menu>li>a.checkbox input[type=checkbox],table.footable>thead>tr.footable-filtering>th ul.dropdown-menu>li>a.checkbox input[type=checkbox]{position:absolute;margin-left:-20px}@media (min-width:768px){table.footable>thead>tr.footable-filtering>th div.input-group{width:auto}table.footable>thead>tr.footable-filtering>th div.form-group{margin-left:2px;margin-right:2px}table.footable>thead>tr.footable-filtering>th div.form-group+div.form-group{margin-top:0}}table.footable>tbody>tr>td.footable-sortable,table.footable>tbody>tr>th.footable-sortable,table.footable>tfoot>tr>td.footable-sortable,table.footable>tfoot>tr>th.footable-sortable,table.footable>thead>tr>td.footable-sortable,table.footable>thead>tr>th.footable-sortable{position:relative;padding-right:30px;cursor:pointer}td.footable-sortable>span.fooicon,th.footable-sortable>span.fooicon{position:absolute;right:6px;top:50%;margin-top:-7px;opacity:0;transition:opacity .3s ease-in}td.footable-sortable.footable-asc>span.fooicon,td.footable-sortable.footable-desc>span.fooicon,td.footable-sortable:hover>span.fooicon,th.footable-sortable.footable-asc>span.fooicon,th.footable-sortable.footable-desc>span.fooicon,th.footable-sortable:hover>span.fooicon{opacity:1}table.footable-sorting-disabled td.footable-sortable.footable-asc>span.fooicon,table.footable-sorting-disabled td.footable-sortable.footable-desc>span.fooicon,table.footable-sorting-disabled td.footable-sortable:hover>span.fooicon,table.footable-sorting-disabled th.footable-sortable.footable-asc>span.fooicon,table.footable-sorting-disabled th.footable-sortable.footable-desc>span.fooicon,table.footable-sorting-disabled th.footable-sortable:hover>span.fooicon{opacity:0;visibility:hidden}.footable-paging-external ul.pagination,table.footable>tfoot>tr.footable-paging>td>ul.pagination{margin:10px 0 0}.footable-paging-external span.label,table.footable>tfoot>tr.footable-paging>td>span.label{display:inline-block;margin:0 0 10px;padding:4px 10px}.footable-paging-external.footable-paging-left,table.footable-paging-left>tfoot>tr.footable-paging>td{text-align:left}.footable-paging-external.footable-paging-right,table.footable-editing-right td.footable-editing,table.footable-editing-right tr.footable-editing,table.footable-paging-right>tfoot>tr.footable-paging>td{text-align:right}ul.pagination>li.footable-page{display:none}ul.pagination>li.footable-page.visible{display:inline}td.footable-editing{width:90px;max-width:90px}table.footable-editing-no-delete td.footable-editing,table.footable-editing-no-edit td.footable-editing,table.footable-editing-no-view td.footable-editing{width:70px;max-width:70px}table.footable-editing-no-delete.footable-editing-no-view td.footable-editing,table.footable-editing-no-edit.footable-editing-no-delete td.footable-editing,table.footable-editing-no-edit.footable-editing-no-view td.footable-editing{width:50px;max-width:50px}table.footable-editing-no-edit.footable-editing-no-delete.footable-editing-no-view td.footable-editing,table.footable-editing-no-edit.footable-editing-no-delete.footable-editing-no-view th.footable-editing{width:0;max-width:0;display:none!important}table.footable-editing-left td.footable-editing,table.footable-editing-left tr.footable-editing{text-align:left}table.footable-editing button.footable-add,table.footable-editing button.footable-hide,table.footable-editing-show button.footable-show,table.footable-editing.footable-editing-always-show button.footable-hide,table.footable-editing.footable-editing-always-show button.footable-show,table.footable-editing.footable-editing-always-show.footable-editing-no-add tr.footable-editing{display:none}table.footable-editing.footable-editing-always-show button.footable-add,table.footable-editing.footable-editing-show button.footable-add,table.footable-editing.footable-editing-show button.footable-hide{display:inline-block} \ No newline at end of file diff --git a/script/script.js b/script/script.js new file mode 100644 index 0000000..1f7cf8f --- /dev/null +++ b/script/script.js @@ -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(); + } + } + }); + +}); diff --git a/setup/.htaccess b/setup/.htaccess new file mode 100644 index 0000000..281d5c3 --- /dev/null +++ b/setup/.htaccess @@ -0,0 +1,2 @@ +order allow,deny +deny from all diff --git a/setup/001-generateKey.php b/setup/001-generateKey.php new file mode 100644 index 0000000..c759631 --- /dev/null +++ b/setup/001-generateKey.php @@ -0,0 +1,25 @@ +saveToAsciiSafeString()); +echo "Done! Proceed to step 2!"; +flush(); + +?> diff --git a/setup/002-createAdmin.php b/setup/002-createAdmin.php new file mode 100644 index 0000000..6481548 --- /dev/null +++ b/setup/002-createAdmin.php @@ -0,0 +1,39 @@ +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(); +} + +?> diff --git a/signupproj.geany b/signupproj.geany new file mode 100644 index 0000000..3d9eac9 --- /dev/null +++ b/signupproj.geany @@ -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 diff --git a/style.css b/style.css new file mode 100644 index 0000000..b4a4749 --- /dev/null +++ b/style.css @@ -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; +} diff --git a/style_mobile.css b/style_mobile.css new file mode 100644 index 0000000..a6e2280 --- /dev/null +++ b/style_mobile.css @@ -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; +} diff --git a/subs/.backend.php b/subs/.backend.php new file mode 100644 index 0000000..ffa58e1 --- /dev/null +++ b/subs/.backend.php @@ -0,0 +1,8 @@ + + +
+

+
diff --git a/subs/admin.backend.php b/subs/admin.backend.php new file mode 100644 index 0000000..4780f18 --- /dev/null +++ b/subs/admin.backend.php @@ -0,0 +1,44 @@ +=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"); + } + } + } +} diff --git a/subs/admin.php b/subs/admin.php new file mode 100644 index 0000000..1a0d0c5 --- /dev/null +++ b/subs/admin.php @@ -0,0 +1,74 @@ + + +
+

+
+
+ + +
+ +
+

+
+ id="o_" onchange="$('#master_switch_form').submit()"> + +
+
+
+

+
+ id="o_" onchange="$('#master_switch_form').submit()"> + +
+
+
+ +
+
+
+ +
+ + + + + + + + + + prepare("SELECT id, name, allow_signup FROM time_sequences ORDER BY id ASC"); + $sql->execute(); + while($row=$sql->fetch(PDO::FETCH_ASSOC)){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $oid++; + } + ?> + +
".$row['id']."".$row['name'].""; + echo "
"; + echo ""; + echo "
"; + echo ""; + echo ""; + echo "
"; + echo "
"; + echo "
+
+
+
diff --git a/subs/programs.backend.php b/subs/programs.backend.php new file mode 100644 index 0000000..5a5cf3d --- /dev/null +++ b/subs/programs.backend.php @@ -0,0 +1,299 @@ +=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(); +} diff --git a/subs/programs.php b/subs/programs.php new file mode 100644 index 0000000..63f3931 --- /dev/null +++ b/subs/programs.php @@ -0,0 +1,245 @@ + + +
+ =2): ?> +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
" required>
" required>
" required>
+
+
+
+
+
+
+
+
+
+
+
+ +
+ 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 "
"; + $oid++; + } + ?> +
" required min=1>
+
+
+ +
+
+
+
+
+
+
+
+ +
+ + + + + +
" required>
+
+
+ +
+
+
+
+ + + + + + + + + + prepare("SELECT id, name FROM time_sequences ORDER BY name ASC"); + $sql->execute(); + while($row=$sql->fetch(PDO::FETCH_ASSOC)){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
".$row['id']."".$row['name'].""; + echo ""; + echo "
+
+
+
+
+
+ +
+ + + + + + + + + +
+ +
+ +
" required>
+ prepare("SELECT id, name FROM time_sequences ORDER BY name ASC"); + $sql->execute(); + while($row=$sql->fetch(PDO::FETCH_ASSOC)){ + echo "
"; + $oid++; + } + ?> +
+
+
+ +
+
+
+
+ + + + + + + + + + + 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 ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
".$row['id']."".$row['time_sequence']."".$row['name'].""; + echo ""; + echo "
+
+
+
+ +

+
+ + + + + + + + + + + + + + + + + fetch(PDO::FETCH_ASSOC)){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + } + ?> + +
".$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'].""; + if($_SESSION['accesslevel']<1){ + if($row['cur_participants']<$row['max_participants']){ + echo ""; + } + else{ + echo "-"; + } + } + else if($_SESSION['accesslevel']>=2){ + echo ""; + } + else{ + echo "-"; + } + echo "
+
+ +
diff --git a/subs/timetable.backend.php b/subs/timetable.backend.php new file mode 100644 index 0000000..35b8f77 --- /dev/null +++ b/subs/timetable.backend.php @@ -0,0 +1,292 @@ +=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"; + $html.="
"; + $html.="

".$config['general']['title']."

"; + $html.="

".$config['general']['org']."

"; + $html.="
"; + $html.="

".$lang['name'].": ".$_SESSION['name']." | ".$lang['class'].": ".$_SESSION['class']." | ".$lang['studentprinted']."

"; + + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + + while($row=$msql->fetch(PDO::FETCH_ASSOC)){ + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + } + + $html.="
".$lang['timeblock']."".$lang['progname']."".$lang['instructor']."".$lang['signature']."
".$row['time_sequence']."
".$row['time_block']."
".$row['name']."".$row['instructor']."
"; + + $html.="
"; + + echo "
".$html."
"; + die(); + } + else{ + $html=""; + $second=false; + + while($row=$msql->fetch(PDO::FETCH_ASSOC)){ + //header + if(!$second){ + $html.=""; + } + //content + $html.=""; + $html.=""; + $html.=""; + + if($second){ + $html.="
"; + $html.="

".$config['general']['title']."

"; + $html.="

".$config['general']['org']."

"; + $html.="
"; + $html.="

".$lang['name'].": ".$row['name']." | ".$lang['class'].": ".$row['class']."

"; + + //programs + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + + //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.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + $html.=""; + } + + $html.="
".$lang['timeblock']."".$lang['progname']."".$lang['instructor']."".$lang['signature']."
".$row2['time_sequence']."
".$row2['time_block']."
".$row2['name']."".$row2['instructor']."
"; + $html.="
"; + } + + $second=!$second; + } + + echo "
".$html."
"; + die(); + } +} diff --git a/subs/timetable.php b/subs/timetable.php new file mode 100644 index 0000000..0351537 --- /dev/null +++ b/subs/timetable.php @@ -0,0 +1,186 @@ + + +
+ =2): ?> +
+
+
+ +
+

+ + + + + + + + + + + + + +
+ +
".$lang['orthis']." ".$lang['class'].": " ?> + +
+ +
+
+
+ +
+
+
+
+
+ +

+
+ + + + + + + + + + + + + + + fetch(PDO::FETCH_ASSOC)){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
".$row['id']."".$row['name']."".$row['description']."".$row['instructor']."".$row['location']."".$row['time_sequence']."/".$row['time_block']."
+ =1): ?> + + + + + + + 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 ""; + array_push($tbs, $row['id']); + } + ?> + + + + fetch(PDO::FETCH_ASSOC)){ + echo ""; + echo ""; + echo ""; + echo ""; + $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 ""; + $i++; + } + echo ""; + $i++; + } + for(;$i-"; + } + echo ""; + } + ?> + +
".$row['time_sequence']."
".$row['time_block']."
".$row['id']."".$row['name']."".$row['class']."-"; + echo $row2['name']; + if($_SESSION['accesslevel']>=2){ + echo ""; + } + echo "
+ +
+ + =2 && $config['general']['programs_needed']!=0): ?> +
+

+ + + + + + + + + + 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 ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
".$row['id']."".$row['name']."".$row['class']."".$row['progcount']."
+ +
diff --git a/subs/timetable_programs.backend.php b/subs/timetable_programs.backend.php new file mode 100644 index 0000000..049fddc --- /dev/null +++ b/subs/timetable_programs.backend.php @@ -0,0 +1,13 @@ + + +
+

+
+
+
+
+ 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 "
"; + echo "

".$row['name']."

"; + echo "
"; + echo "

".$lang['instructor'].": ".$row['instructor']." | ".$lang['location'].": ".$row['location']." | ".$lang['timeblock'].": ".$row['time_sequence']."/".$row['time_block']."

"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $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 ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + echo ""; + echo "
".$lang['num']."".$lang['name']."".$lang['class']."
".$num."".$row2['name']."".$row2['class']."
"; + echo "
"; + } + ?> +
+
+
+
+ + + + + +
diff --git a/subs/users.backend.php b/subs/users.backend.php new file mode 100644 index 0000000..dd1072a --- /dev/null +++ b/subs/users.backend.php @@ -0,0 +1,144 @@ +=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(); +} diff --git a/subs/users.php b/subs/users.php new file mode 100644 index 0000000..6ff6a53 --- /dev/null +++ b/subs/users.php @@ -0,0 +1,99 @@ + + +
+ =3): ?> +
+
+
+ +
+ + + + + + + + + + + + + + + + + +
" required>
">
+
"; + $oid++; + } + ?> +
" required>
+
+
+ +
+
+
+
+
+
+ + +
+
+ +

+
+ + + + + + + + =3): ?> + =3): ?> + =3): ?> + =3): ?> + + + + fetch(PDO::FETCH_ASSOC)){ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + if($_SESSION['accesslevel']>=3){ + echo ""; + echo ""; + echo ""; + echo ""; + } + ?> + +
".$row['id']."".$row['name']."".$row['class']."".$lang['al'][$row['accesslevel']]."".\Defuse\Crypto\Crypto::decrypt($row['password'], $crypto)."".$row['except_login']."".$row['except_signup'].""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
+
+ +