@@ -1,41 +1,41 @@ |
||
| 1 | 1 | <?php |
| 2 | - function subFolder( $_dir = "./" ) { |
|
| 3 | - $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
| 2 | + function subFolder($_dir = "./") { |
|
| 3 | + $temp = fetchInSubFolder($_dir, function($_file) { |
|
| 4 | 4 | return true; |
| 5 | 5 | }); |
| 6 | 6 | return $temp; |
| 7 | 7 | } |
| 8 | - function subFolder_file( $_dir = "./" ) { |
|
| 9 | - $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
| 8 | + function subFolder_file($_dir = "./") { |
|
| 9 | + $temp = fetchInSubFolder($_dir, function($_file) { |
|
| 10 | 10 | return !is_dir($_file); |
| 11 | 11 | }); |
| 12 | 12 | return $temp; |
| 13 | 13 | } |
| 14 | - function subFolder_dir( $_dir = "./" ) { |
|
| 15 | - $temp = fetchInSubFolder($_dir, function( $_file ) { |
|
| 14 | + function subFolder_dir($_dir = "./") { |
|
| 15 | + $temp = fetchInSubFolder($_dir, function($_file) { |
|
| 16 | 16 | return !is_file($_file); |
| 17 | 17 | }); |
| 18 | 18 | return $temp; |
| 19 | 19 | } |
| 20 | - function fetchInSubFolder( $_dir = "./", $_function) { |
|
| 20 | + function fetchInSubFolder($_dir = "./", $_function) { |
|
| 21 | 21 | $temp = []; |
| 22 | 22 | if (is_dir($_dir)) { |
| 23 | 23 | if ($dirOpened = opendir($_dir)) { |
| 24 | 24 | while (($file = readdir($dirOpened)) !== false) |
| 25 | - if( ($file !='.')&&($file !='..') ) |
|
| 26 | - if($_function($file)) |
|
| 27 | - array_push($temp,$file); |
|
| 25 | + if (($file != '.') && ($file != '..')) |
|
| 26 | + if ($_function($file)) |
|
| 27 | + array_push($temp, $file); |
|
| 28 | 28 | closedir($dirOpened); |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | return $temp; |
| 32 | 32 | } |
| 33 | - function require_subfolder( $_dir = "./" ) { |
|
| 33 | + function require_subfolder($_dir = "./") { |
|
| 34 | 34 | $temp = subFolder_file($_dir); |
| 35 | 35 | foreach ($temp as $i) |
| 36 | 36 | jRequire($_dir."/".$i); |
| 37 | 37 | } |
| 38 | - function require_js( $_dir = "./" ) { |
|
| 38 | + function require_js($_dir = "./") { |
|
| 39 | 39 | $tempArray = []; |
| 40 | 40 | $temp = subFolder_file($_dir); |
| 41 | 41 | foreach ($temp as $i) |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - function getGitLog( $_dir = "./" ) { |
|
| 3 | - if(!file_exists($_dir)) return []; |
|
| 2 | + function getGitLog($_dir = "./") { |
|
| 3 | + if (!file_exists($_dir)) return []; |
|
| 4 | 4 | $currentDir = getcwd(); |
| 5 | 5 | chdir($_dir); |
| 6 | 6 | $git_history = []; |
| 7 | 7 | $git_logs = []; |
| 8 | - $gitPath = str_replace('\\', '/', exec("git rev-parse --show-toplevel")); |
|
| 9 | - $rootPath = str_replace('\\', '/', getcwd ()); |
|
| 10 | - if( $gitPath != $rootPath ) { |
|
| 8 | + $gitPath = str_replace('\\', '/', exec("git rev-parse --show-toplevel")); |
|
| 9 | + $rootPath = str_replace('\\', '/', getcwd()); |
|
| 10 | + if ($gitPath != $rootPath) { |
|
| 11 | 11 | chdir($currentDir); |
| 12 | 12 | return []; |
| 13 | 13 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $git_history[$last_hash]['date'] = date('d/m/Y H:i:s A', strtotime($date)); |
| 48 | 48 | } |
| 49 | 49 | else |
| 50 | - $git_history[$last_hash]['message'] .= $line ." "; |
|
| 50 | + $git_history[$last_hash]['message'] .= $line." "; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | chdir($currentDir); |
@@ -1,45 +1,45 @@ |
||
| 1 | 1 | <?php |
| 2 | - function requireComponent( $_path, $_local = true, $_stack = null ) { |
|
| 2 | + function requireComponent($_path, $_local = true, $_stack = null) { |
|
| 3 | 3 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 4 | - if(file_exists($path) && isPhp($path)) |
|
| 4 | + if (file_exists($path) && isPhp($path)) |
|
| 5 | 5 | jRequire($path, false, 0); |
| 6 | 6 | else |
| 7 | 7 | requireError($_path); |
| 8 | 8 | } |
| 9 | - function requireComponents( $_path, $_local = true, $_stack = null ) { |
|
| 9 | + function requireComponents($_path, $_local = true, $_stack = null) { |
|
| 10 | 10 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 11 | - if(file_exists($path)) { |
|
| 11 | + if (file_exists($path)) { |
|
| 12 | 12 | $files = subFolder_file($path); |
| 13 | 13 | foreach ($files as $i) { |
| 14 | - if(isPhp($path."/".$i)) |
|
| 14 | + if (isPhp($path."/".$i)) |
|
| 15 | 15 | requireComponent($path."/".$i, false, 0); |
| 16 | 16 | } |
| 17 | 17 | } else |
| 18 | 18 | requireError($_path); |
| 19 | 19 | } |
| 20 | - function requireError( $_path ) { |
|
| 20 | + function requireError($_path) { |
|
| 21 | 21 | global $jConfig; |
| 22 | - if( $jConfig->DEBUG == 1 ) |
|
| 22 | + if ($jConfig->DEBUG == 1) |
|
| 23 | 23 | echo "Error load ($_path)<br>"; |
| 24 | 24 | } |
| 25 | - function isPhp ( $_file ) { |
|
| 26 | - if(!is_file($_file)) return false; |
|
| 25 | + function isPhp($_file) { |
|
| 26 | + if (!is_file($_file)) return false; |
|
| 27 | 27 | $info = pathinfo($_file); |
| 28 | 28 | return ($info["extension"] == "php") || ($info["extension"] == "PHP"); |
| 29 | 29 | } |
| 30 | - function requireModules( $_path, $_local = true, $_stack = null ) { |
|
| 30 | + function requireModules($_path, $_local = true, $_stack = null) { |
|
| 31 | 31 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 32 | 32 | $subFolders = subFolder_dir($path); |
| 33 | 33 | foreach ($subFolders as $i) { |
| 34 | 34 | requireComponents($path."/".$i, false, 0); |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | - function jRequire( $_path, $_local = true, $_stack = null ) { |
|
| 37 | + function jRequire($_path, $_local = true, $_stack = null) { |
|
| 38 | 38 | $path = getJFolder($_path, $_local, debug_backtrace()); |
| 39 | - require_once( $path ); |
|
| 39 | + require_once($path); |
|
| 40 | 40 | } |
| 41 | - function getJFolder( $_path, $_local, $_stack ) { |
|
| 42 | - if($_local) { |
|
| 41 | + function getJFolder($_path, $_local, $_stack) { |
|
| 42 | + if ($_local) { |
|
| 43 | 43 | $stackInfo = $_stack; |
| 44 | 44 | $folder = dirname($stackInfo[0]["file"]); |
| 45 | 45 | $file = "$folder/$_path"; |
@@ -1,24 +1,24 @@ |
||
| 1 | 1 | <?php |
| 2 | - function q_query( $_database, $_query, $_error ) { |
|
| 3 | - return std_query( $_database, $_query, $_error, $temp ); |
|
| 2 | + function q_query($_database, $_query, $_error) { |
|
| 3 | + return std_query($_database, $_query, $_error, $temp); |
|
| 4 | 4 | } |
| 5 | - function c_query( $_query, $_error ) { |
|
| 5 | + function c_query($_query, $_error) { |
|
| 6 | 6 | global $connection; |
| 7 | - return q_query( $connection->database, $_query, $_error ); |
|
| 7 | + return q_query($connection->database, $_query, $_error); |
|
| 8 | 8 | } |
| 9 | - function b_query( $_query, $_error ) { |
|
| 9 | + function b_query($_query, $_error) { |
|
| 10 | 10 | global $connection; |
| 11 | 11 | $temp = 0; |
| 12 | - std_query( $connection->database, $_query, $_error, $temp ); |
|
| 12 | + std_query($connection->database, $_query, $_error, $temp); |
|
| 13 | 13 | return $temp; |
| 14 | 14 | } |
| 15 | - function c_insert( $_query, $_error ) { |
|
| 16 | - return b_query( $_query, $_error ); |
|
| 15 | + function c_insert($_query, $_error) { |
|
| 16 | + return b_query($_query, $_error); |
|
| 17 | 17 | } |
| 18 | - function std_query( $_database, $_query, $_error, &$_result ) { |
|
| 18 | + function std_query($_database, $_query, $_error, &$_result) { |
|
| 19 | 19 | $query = $_database->prepare($_query); |
| 20 | 20 | $_result = $query->execute(); |
| 21 | - if(!$_result) { |
|
| 21 | + if (!$_result) { |
|
| 22 | 22 | echo "$_query<br>"; |
| 23 | 23 | echo "something wrong: ".$_error; |
| 24 | 24 | var_dump($query->errorInfo()); |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | function minify_output($_buffer) { |
| 16 | - $search = array ( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s' ); |
|
| 17 | - $replace = array ( '>', '<', '\\1' ); |
|
| 18 | - if (preg_match("/\<html/i",$_buffer) == 1 && preg_match("/\<\/html\>/i",$_buffer) == 1) |
|
| 16 | + $search = array('/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s'); |
|
| 17 | + $replace = array('>', '<', '\\1'); |
|
| 18 | + if (preg_match("/\<html/i", $_buffer) == 1 && preg_match("/\<\/html\>/i", $_buffer) == 1) |
|
| 19 | 19 | $_buffer = preg_replace($search, $replace, utf8_decode($_buffer)); |
| 20 | 20 | return utf8_encode($_buffer); |
| 21 | 21 | } |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | - function htmlParser( $_str) { |
|
| 2 | + function htmlParser($_str) { |
|
| 3 | 3 | return htmlentities($_str, ENT_QUOTES | ENT_IGNORE, "UTF-8"); |
| 4 | 4 | } |
| 5 | 5 | ?> |
@@ -1,27 +1,27 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | function utf8ize($_array) { |
| 3 | - return travelStringArray($_array,"utf8_encode"); |
|
| 3 | + return travelStringArray($_array, "utf8_encode"); |
|
| 4 | 4 | } |
| 5 | 5 | function unutf8ize($_array) { |
| 6 | - return travelStringArray($_array,"utf8_decode"); |
|
| 6 | + return travelStringArray($_array, "utf8_decode"); |
|
| 7 | 7 | } |
| 8 | 8 | function arraySlash($_array) { |
| 9 | - return travelStringArray($_array,"addslashes"); |
|
| 9 | + return travelStringArray($_array, "addslashes"); |
|
| 10 | 10 | } |
| 11 | 11 | function arrayHtmlParser($_array) { |
| 12 | - return travelStringArray($_array,"htmlParser"); |
|
| 12 | + return travelStringArray($_array, "htmlParser"); |
|
| 13 | 13 | } |
| 14 | - function travelStringArray ( $_array, $_function ) { |
|
| 14 | + function travelStringArray($_array, $_function) { |
|
| 15 | 15 | if (is_array($_array)) { |
| 16 | 16 | foreach ($_array as $k => $v) { |
| 17 | 17 | $_array[$k] = travelStringArray($v, $_function); |
| 18 | 18 | } |
| 19 | - } else if (is_string ($_array)) { |
|
| 20 | - return call_user_func($_function,$_array); |
|
| 19 | + } else if (is_string($_array)) { |
|
| 20 | + return call_user_func($_function, $_array); |
|
| 21 | 21 | } |
| 22 | 22 | return $_array; |
| 23 | 23 | } |
| 24 | - function array_depth( $_array ) { |
|
| 24 | + function array_depth($_array) { |
|
| 25 | 25 | $maxDepth = 1; |
| 26 | 26 | foreach ($_array as $value) { |
| 27 | 27 | if (is_array($value)) { |
@@ -7,37 +7,37 @@ |
||
| 7 | 7 | public function __construct() { |
| 8 | 8 | parent::__construct(); |
| 9 | 9 | $this->pages = []; |
| 10 | - $this->defaultPage = ["Page404",[]]; |
|
| 10 | + $this->defaultPage = ["Page404", []]; |
|
| 11 | 11 | $this->currentPage = null; |
| 12 | 12 | $this->connection = null; |
| 13 | 13 | } |
| 14 | - public function addPage( $_page ) { |
|
| 14 | + public function addPage($_page) { |
|
| 15 | 15 | $label = ""; |
| 16 | 16 | $class = ""; |
| 17 | 17 | $param = []; |
| 18 | - if(is_array($_page)) { |
|
| 18 | + if (is_array($_page)) { |
|
| 19 | 19 | $label = $_page[0]; |
| 20 | 20 | $class = $_page[1]; |
| 21 | - if(isset($_page[2])) |
|
| 21 | + if (isset($_page[2])) |
|
| 22 | 22 | $param = $_page[2]; |
| 23 | 23 | } else { |
| 24 | 24 | $label = $_page; |
| 25 | 25 | $class = $_page; |
| 26 | 26 | } |
| 27 | - $this->pages[$label] = [$class,$param]; |
|
| 27 | + $this->pages[$label] = [$class, $param]; |
|
| 28 | 28 | } |
| 29 | - public function addPages( $_pages ) { |
|
| 29 | + public function addPages($_pages) { |
|
| 30 | 30 | foreach ($_pages as $i) |
| 31 | 31 | $this->addPage($i); |
| 32 | 32 | } |
| 33 | - public function fetchPage( $_label ) { |
|
| 33 | + public function fetchPage($_label) { |
|
| 34 | 34 | $temp = $this->defaultPage; |
| 35 | - if(isset($this->pages[$_label])) |
|
| 35 | + if (isset($this->pages[$_label])) |
|
| 36 | 36 | $temp = $this->pages[$_label]; |
| 37 | 37 | $this->currentPage = new $temp[0]($temp[1]); |
| 38 | 38 | return $this->currentPage; |
| 39 | 39 | } |
| 40 | - public function setDefaultPage( $_page ) { |
|
| 40 | + public function setDefaultPage($_page) { |
|
| 41 | 41 | $this->defaultPage = $_page; |
| 42 | 42 | } |
| 43 | 43 | public function draw() { |
@@ -4,16 +4,16 @@ discard block |
||
| 4 | 4 | parent::__construct(); |
| 5 | 5 | } |
| 6 | 6 | public function init() { |
| 7 | - $menu = c_query("SELECT * FROM menu WHERE flag_active = 1 ORDER BY `order`","Menu,getMenu,menu"); |
|
| 7 | + $menu = c_query("SELECT * FROM menu WHERE flag_active = 1 ORDER BY `order`", "Menu,getMenu,menu"); |
|
| 8 | 8 | $temp = []; |
| 9 | 9 | foreach ($menu as $i) { |
| 10 | 10 | $submenu = []; |
| 11 | - if($i["fk_menu"] == 0) { |
|
| 11 | + if ($i["fk_menu"] == 0) { |
|
| 12 | 12 | array_push($temp, array("label" => $i["label"], "link" => $i["link"], "submenu" => [])); |
| 13 | - $submenu = c_query("SELECT * FROM menu WHERE fk_menu = ".$i["pk_menu"],"Menu,getMenu,submenu"); |
|
| 14 | - if($submenu) |
|
| 13 | + $submenu = c_query("SELECT * FROM menu WHERE fk_menu = ".$i["pk_menu"], "Menu,getMenu,submenu"); |
|
| 14 | + if ($submenu) |
|
| 15 | 15 | foreach ($submenu as $j) |
| 16 | - array_push( $temp[count($temp)-1]["submenu"], array("label" => $j["label"], "link" => $j["link"], []) ); |
|
| 16 | + array_push($temp[count($temp) - 1]["submenu"], array("label" => $j["label"], "link" => $j["link"], [])); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | 19 | $this->data["menu"] = $temp; |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | $temp = ""; |
| 24 | 24 | $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; |
| 25 | 25 | foreach ($this->data["menu"] as $i) { |
| 26 | - if( is_array($i["submenu"]) && count($i["submenu"])<1) { |
|
| 26 | + if (is_array($i["submenu"]) && count($i["submenu"]) < 1) { |
|
| 27 | 27 | $temp .= '<li><a href="'.$i["link"].'">'.$i["label"].'</a></li>'; |
| 28 | 28 | } else { |
| 29 | - if($this->isSubString($actual_link,array_merge(array_column($i["submenu"], 'link'), array($i["link"])))) |
|
| 29 | + if ($this->isSubString($actual_link, array_merge(array_column($i["submenu"], 'link'), array($i["link"])))) |
|
| 30 | 30 | $temp .= '<li class="dropdown active">'; |
| 31 | 31 | else |
| 32 | 32 | $temp .= '<li class="dropdown">'; |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | return $temp; |
| 45 | 45 | } |
| 46 | - protected function isSubString( $_string, $_list) { |
|
| 46 | + protected function isSubString($_string, $_list) { |
|
| 47 | 47 | $success = false; |
| 48 | 48 | foreach ($_list as $i) |
| 49 | - if(strpos($_string,$i) !== false) |
|
| 49 | + if (strpos($_string, $i) !== false) |
|
| 50 | 50 | $success = true; |
| 51 | 51 | return $success; |
| 52 | 52 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $this->init(); |
| 55 | 55 | $temp = []; |
| 56 | 56 | $user = ""; |
| 57 | - if(!isset($_SESSION["username"])) |
|
| 58 | - $_SESSION["username"] ="guest"; |
|
| 57 | + if (!isset($_SESSION["username"])) |
|
| 58 | + $_SESSION["username"] = "guest"; |
|
| 59 | 59 | $user = $_SESSION["username"]; |
| 60 | 60 | $blackList = c_query( |
| 61 | 61 | "SELECT user.*,user_section.* |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | $success = true; |
| 71 | 71 | $k = $i["label"]; |
| 72 | 72 | foreach ($blackList as $j) |
| 73 | - if( $j["section"] == $k) |
|
| 73 | + if ($j["section"] == $k) |
|
| 74 | 74 | $success = false; |
| 75 | - if($success) |
|
| 76 | - array_push($temp,$i); |
|
| 75 | + if ($success) |
|
| 76 | + array_push($temp, $i); |
|
| 77 | 77 | } |
| 78 | 78 | $this->data["menu"] = $temp; |
| 79 | 79 | } |