diff --git a/assets/html/footer.twig b/assets/html/footer.twig index 5323bce..d5103f4 100755 --- a/assets/html/footer.twig +++ b/assets/html/footer.twig @@ -2,7 +2,7 @@
-

JKA Network © 2017-actualidad. Versión 0.1 Alpha

+

JKA Network © 2018. Versión {{version}}

Design by Bootstrapious

diff --git a/assets/html/login.twig b/assets/html/login.twig index 2aea7c7..0b2ea35 100755 --- a/assets/html/login.twig +++ b/assets/html/login.twig @@ -29,4 +29,5 @@
- \ No newline at end of file + +{% include 'footer.twig' %} \ No newline at end of file diff --git a/connect.php b/connect.php deleted file mode 100755 index 94f129e..0000000 --- a/connect.php +++ /dev/null @@ -1,38 +0,0 @@ -Please run updater.php to update before using page"); -} -?> \ No newline at end of file diff --git a/functions.php b/functions.php index 335d638..41074d3 100755 --- a/functions.php +++ b/functions.php @@ -1,9 +1,8 @@ 'DATABASE'); } /* This funtion returns the translated text of a type check */ -function textTypeChk($T_,$typeChk){ +function textTypeChk($typeChk){ + $T_ = loadLang(); $arr = array( '1' => $T_['PING_IP'], '2' => $T_['HTTP_CODE'], '3' => $T_['VISIT_COUNT'], '4' => $T_['DATABASE']); return $arr[$typeChk]; +} + +//This function is an alias to Twig render, with "standard args" added +function renderPage($page,$array){ + $T_ = loadLang(); //Load transactions + //Default params to send + $allarray = array( + 'version' => VERSION, + 'T_' => $T_, + ); + + foreach ($array as $key => $value) { + $allarray[$key] = $value; + } + require 'lib/loadTwig.php'; + echo $twig->render($page, $allarray); +} + +function loadLang(){ + //Translations + require __DIR__."/assets/translations/en.php"; //Ever first English, and then your lang (Database) + require __DIR__."/assets/translations/".LANG.".php"; + return $T_; } \ No newline at end of file diff --git a/index.php b/index.php index 93ad878..5191489 100755 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ text($incident['text']); $incs[$ID_N]['ID_N'] = $incident['ID_N']; } - -echo $twig->render('indexpage.twig', array('T_' => $T_, 'you' => $you, 'checks' => $chks, 'news' => $incs)); //Render + renderPage('indexpage.twig',array('you' => $you,'checks' => $chks, 'news' => $incs)); //Render ?> diff --git a/install.php b/install.php index 9001634..fa390bf 100755 --- a/install.php +++ b/install.php @@ -1,5 +1,6 @@ Please run updater.php to update before using page"); +} + diff --git a/login.php b/login.php index d20b87f..3b97877 100755 --- a/login.php +++ b/login.php @@ -1,10 +1,8 @@ render('login.twig'); + renderPage('login.twig'); } if (isset($_POST['nick'])){ $nick=$_POST['nick']; @@ -27,7 +25,7 @@ if (isset($_POST['nick'])){ $_SESSION['UserID'] = $resql['ID_U']; header('Location: panel.php'); }else{ - echo $twig->render('login.twig', array('status' => 'error')); + renderPage('login.twig', array('status' => 'error')); } } diff --git a/panel.php b/panel.php index 193b2dc..0166f8a 100755 --- a/panel.php +++ b/panel.php @@ -1,5 +1,5 @@ $emptygrp['name']); } - echo $twig->render('panel/p_checks.twig', array('T_' => $T_, 'mpage' => 'checks','you' => $you, 'checks' => $chks,'groups' => $groups,'emptygrp' => $emptyG)); + renderPage('panel/p_checks.twig',array('mpage' => 'checks','you' => $you, 'checks' => $chks,'groups' => $groups,'emptygrp' => $emptyG)); break; //Forms to add or edit a check (Not saving, only forms) @@ -65,17 +65,18 @@ switch($page){ foreach(arrayTypeChk() as $key => $value){ $tchecks[] = array( 'ID_TC' =>$key, - 'name' => textTypeChk($T_,$key) + 'name' => textTypeChk($key) ); } //En este if hago las diferencias entre add y edit, para no repetir código. if ($page == 'addcheck'){ - echo $twig->render('panel/p_addedit.twig', array('T_' => $T_, 'mpage' => 'checks', 'type' => 'new','groups' => $groups,'tchecks' => $tchecks)); + renderPage('panel/p_addedit.twig', array('mpage' => 'checks', 'type' => 'new','groups' => $groups,'tchecks' => $tchecks)); }elseif ($page == 'editcheck'){ $ID_C = (int)$_GET['ID_C']; //Check to edit $checkdata = dbw_query_fetch_array($db_conn,"SELECT * FROM CHECKS WHERE ID_C='$ID_C'"); //Checkdata - echo $twig->render('panel/p_addedit.twig', array('T_' => $T_, 'mpage' => 'checks', 'you' => $you, 'type' => 'edit','groups' => $groups,'tchecks' => $tchecks,'check' => $checkdata)); + + renderPage('panel/p_addedit.twig', array('mpage' => 'checks', 'you' => $you, 'type' => 'edit','groups' => $groups,'tchecks' => $tchecks,'check' => $checkdata)); } break; @@ -144,8 +145,7 @@ switch($page){ 'checks' => $countchk ); } - - echo $twig->render('panel/p_groups.twig', array('T_' => $T_, 'you' => $you, 'mpage' => 'groups', 'groups' => $groups)); + renderPage('panel/p_groups.twig', array('you' => $you, 'mpage' => 'groups', 'groups' => $groups)); break; case 'addgroup': @@ -186,8 +186,7 @@ switch($page){ ->text($result['text']); $news[$ID_N]['mdtext'] = $result['text']; //Raw text } - - echo $twig->render('panel/p_news.twig', array('T_' => $T_, 'you' => $you, 'mpage' => 'news', 'allnews' => $news)); + renderPage('panel/p_news.twig', array('you' => $you, 'mpage' => 'news', 'allnews' => $news)); break; case 'newnews': @@ -218,8 +217,7 @@ switch($page){ while ($syso = dbw_fetch_array($db_conn,$results)){ $sys[$syso['option']] = $syso['value']; } - - echo $twig->render('panel/p_settings.twig', array('T_' => $T_, 'you' => $you, 'mpage' => 'settings', 'sys' => $sys)); + renderPage('panel/p_settings.twig', array('you' => $you, 'mpage' => 'settings', 'sys' => $sys)); break; case 'users': @@ -233,8 +231,7 @@ switch($page){ 'fullrights' => $us['fullRights'] ); } - - echo $twig->render('panel/p_users.twig', array('T_' => $T_, 'mpage' => 'users', 'you' => $you, 'users' => $user)); + renderPage('panel/p_users.twig', array('mpage' => 'users', 'you' => $you, 'users' => $user)); break; case 'adduser': @@ -291,10 +288,10 @@ switch($page){ } } - $group = nameGroupFromIDG($db_conn,IDGFromIDC($db_conn,$ID_C)); + $group = nameGroupFromIDG(IDGFromIDC($ID_C)); $pagedata = array('cgood' => $cgood,'cbad' => $cbad,'name' => nameFromIDC($db_conn,$ID_C), 'group' => $group,'cant' => $cant,'fails' => $fails); - echo $twig->render('panel/p_viewhist.twig', array('T_' => $T_, 'mpage' => 'viewhist', 'you' => $you,'pagedata' => $pagedata)); + renderPage('panel/p_viewhist.twig', array('mpage' => 'viewhist', 'you' => $you,'pagedata' => $pagedata)); break; // Página principal @@ -310,8 +307,8 @@ switch($page){ while ($fail = dbw_fetch_array($db_conn,$failssql)){ //Create array $fails[] = array ( 'ID_C' => $fail['ID_C'], - 'name' => nameFromIDC($db_conn,$fail['ID_C']), - 'groupName' => nameGroupFromIDG($db_conn,IDGFromIDC($db_conn,$fail['ID_C'])), + 'name' => nameFromIDC($fail['ID_C']), + 'groupName' => nameGroupFromIDG(IDGFromIDC($fail['ID_C'])), 'typeCheck' => textTypeChk($T_,$fail['ID_TC']), 'errorText' => $fail['errorText'], 'date' => date('j/n/Y',$fail['timestamp']), @@ -322,7 +319,7 @@ switch($page){ $fails = array(); //Empty } - echo $twig->render('panel/p_index.twig', array('T_' => $T_, 'you' => $you, 'mpage' => 'index', 'data' => $data,'fails' => $fails)); //Render + renderPage('panel/p_index.twig', array('you' => $you, 'mpage' => 'index', 'data' => $data,'fails' => $fails)); //Render break; } diff --git a/updater.php b/updater.php deleted file mode 100644 index 2569774..0000000 --- a/updater.php +++ /dev/null @@ -1,31 +0,0 @@ -Updater of CheckServer"; -echo "

Connecting to database

"; -require_once 'lib/dbwrapper.php'; -$db_file = __DIR__."/sqlite.db3"; -if (!is_file($db_file)){ //Go to install if not. - header("Location: install.php"); - die(); -} -$db_conn = dbw_connect("sqlite",$db_file); //Database - -$version = dbw_query_fetch_array($db_conn,"SELECT value FROM SYS WHERE option = 'version'")[0]; -echo "

Your version: ".$version; -echo "

Updating to lastest

"; -switch ($version){ - case '0.9': - echo "

0.9->0.9.1

"; - dbw_query($db_conn,"DELETE FROM SYS WHERE option='maxChecksSave'"); - dbw_query($db_conn,"INSERT INTO SYS VALUES('maxTimeSave',14)"); - //Can not delete USERS.SessionID because sqlite3 not supports it, but doesn't do any harm. - dbw_query($db_conn,"UPDATE SYS SET value='0.9.1' WHERE option='version'"); - case '0.9.1': //No db updates - echo "

0.9.1->0.9.2

"; - dbw_query($db_conn,"UPDATE SYS SET value='0.9.2' WHERE option='version'"); - case '0.9.2': - echo "0.9.2-Lastest"; - echo "

Updated to lastest. Close this and go to index

"; - //Remove files on a good update - unlink('updater.php'); - unlink('installer.php'); -} \ No newline at end of file