From c9d498a5956a717924dcf96a6464ac119958636b Mon Sep 17 00:00:00 2001 From: rylon Date: Sun, 21 Apr 2013 17:27:57 +0200 Subject: [PATCH] updates system --- dbd/autoload.inc.php | 7 - dbd/db/system.php | 9 - dbd/tbl/APITable.php | 19 -- dbd/tbl/PAGETable.php | 19 -- dbd/tbl/UserRightsTable.php | 11 -- dbd/tbl/UserTable.php | 14 -- system/api/Api.php | 97 +++++----- system/api/apiloginclass.php | 15 +- system/cache/cache.php | 45 +++++ system/db/Query.php | 7 - system/db/QueryString.php | 14 -- system/db/connection/Connection.php | 40 ++++ system/db/connection/ConnectionAMQP.php | 64 +++++++ system/db/connection/ConnectionAbstr.php | 28 +++ .../ConnectionMYS.php} | 67 ++----- system/db/connection/ConnectionPG.php | 54 ++++++ system/db/dbinfo/DBInfo.php | 13 ++ system/db/dbinfo/DBInfoAMQP.php | 19 ++ system/db/dbinfo/DBInfoMYS.php | 19 ++ system/db/{DBInfo.php => dbinfo/DBInfoPG.php} | 11 +- system/db/{ => result}/Result.php | 0 system/db/result/ResultAMQP.php | 37 ++++ system/db/{ => result}/ResultMysqli.php | 0 .../db/{ => result}/ResultMysqliPrepare.php | 0 system/db/result/ResultPostgres.php | 37 ++++ system/dbd/autoload.inc.php | 9 + system/dbd/db/systemPostgres.php | 7 + system/dbd/tbl/APITable.php | 19 ++ system/dbd/tbl/PAGETable.php | 19 ++ system/dbd/tbl/UserLoginsTable.php | 14 ++ system/dbd/tbl/UserRightsTable.php | 11 ++ system/dbd/tbl/UserTable.php | 18 ++ {dbd => system/dbd}/tbl/locale_string.php | 7 +- system/log/LOG.php | 96 ++++++++++ system/log/error_handler/error_handler.php | 10 + .../error_handler/error_handler_dbwriter.php | 22 +++ .../error_handler_jsonoutput.php | 15 ++ system/log/exceptions/DEPRECATED.php | 10 + system/log/exceptions/ERROR.php | 10 + system/log/exceptions/INFO.php | 11 ++ system/log/exceptions/TranslatableError.php | 17 ++ system/log/exceptions/WARNING.php | 10 + system/log/exceptions_shortcut/DEPRECATED.php | 2 + system/log/exceptions_shortcut/ERROR.php | 2 + system/log/exceptions_shortcut/INFO.php | 3 + system/log/exceptions_shortcut/WARNING.php | 2 + .../log/register_errorhandler_jsonoutput.php | 2 + system/log/register_exception_shortcut.php | 2 + system/log/register_result_shortcut.php | 2 + system/log/result/AbstractResult.php | 15 ++ system/log/result/JsonResult.php | 42 +++++ system/log/result_shortcut/JsonResult.php | 3 + system/page/PageApi.php | 50 ++--- system/page/PageClass.php | 3 +- system/sai/{sai => }/SaiModule.php | 0 system/sai/index.php | 1 + system/sai/sai/SaiApi.php | 12 -- system/sai/sai/autoload.inc.php | 3 +- .../badge_creator}/badgecreator.js | 0 .../badge_creator/badgecreator.tpl} | 3 +- .../saimod_dasense_badge_creator.php | 15 ++ .../modules/saimod_dasense_badge_creator.php | 10 - system/sai/sai/modules/saimod_sys_api.php | 2 +- .../sai/sai/page/action_test/action_test.php | 9 - .../{carousel.html => carousel.tpl} | 10 +- .../page/default_page/default_developer.php | 20 -- .../sai/page/default_page/default_page.php | 21 ++- system/sai/sai/page/default_page/js/index.js | 4 +- system/sai/sai/page/login_page/login.tpl | 17 ++ system/sai/sai/page/login_page/login_page.php | 19 ++ system/sai/saigui.php | 19 +- system/security/Security.php | 174 +++++++++++------- system/system/locale.php | 21 ++- .../register_system_autoload_classes.php | 18 +- system/system/time.php | 21 +++ 75 files changed, 1076 insertions(+), 402 deletions(-) delete mode 100644 dbd/autoload.inc.php delete mode 100644 dbd/db/system.php delete mode 100644 dbd/tbl/APITable.php delete mode 100644 dbd/tbl/PAGETable.php delete mode 100644 dbd/tbl/UserRightsTable.php delete mode 100644 dbd/tbl/UserTable.php create mode 100644 system/cache/cache.php delete mode 100644 system/db/Query.php delete mode 100644 system/db/QueryString.php create mode 100644 system/db/connection/Connection.php create mode 100644 system/db/connection/ConnectionAMQP.php create mode 100644 system/db/connection/ConnectionAbstr.php rename system/db/{Connection.php => connection/ConnectionMYS.php} (58%) create mode 100644 system/db/connection/ConnectionPG.php create mode 100644 system/db/dbinfo/DBInfo.php create mode 100644 system/db/dbinfo/DBInfoAMQP.php create mode 100644 system/db/dbinfo/DBInfoMYS.php rename system/db/{DBInfo.php => dbinfo/DBInfoPG.php} (77%) rename system/db/{ => result}/Result.php (100%) create mode 100644 system/db/result/ResultAMQP.php rename system/db/{ => result}/ResultMysqli.php (100%) rename system/db/{ => result}/ResultMysqliPrepare.php (100%) create mode 100644 system/db/result/ResultPostgres.php create mode 100644 system/dbd/autoload.inc.php create mode 100644 system/dbd/db/systemPostgres.php create mode 100644 system/dbd/tbl/APITable.php create mode 100644 system/dbd/tbl/PAGETable.php create mode 100644 system/dbd/tbl/UserLoginsTable.php create mode 100644 system/dbd/tbl/UserRightsTable.php create mode 100644 system/dbd/tbl/UserTable.php rename {dbd => system/dbd}/tbl/locale_string.php (89%) create mode 100644 system/log/LOG.php create mode 100644 system/log/error_handler/error_handler.php create mode 100644 system/log/error_handler/error_handler_dbwriter.php create mode 100644 system/log/error_handler/error_handler_jsonoutput.php create mode 100644 system/log/exceptions/DEPRECATED.php create mode 100644 system/log/exceptions/ERROR.php create mode 100644 system/log/exceptions/INFO.php create mode 100644 system/log/exceptions/TranslatableError.php create mode 100644 system/log/exceptions/WARNING.php create mode 100644 system/log/exceptions_shortcut/DEPRECATED.php create mode 100644 system/log/exceptions_shortcut/ERROR.php create mode 100644 system/log/exceptions_shortcut/INFO.php create mode 100644 system/log/exceptions_shortcut/WARNING.php create mode 100644 system/log/register_errorhandler_jsonoutput.php create mode 100644 system/log/register_exception_shortcut.php create mode 100644 system/log/register_result_shortcut.php create mode 100644 system/log/result/AbstractResult.php create mode 100644 system/log/result/JsonResult.php create mode 100644 system/log/result_shortcut/JsonResult.php rename system/sai/{sai => }/SaiModule.php (100%) delete mode 100644 system/sai/sai/SaiApi.php rename system/sai/sai/{page/default_page/js => modules/badge_creator}/badgecreator.js (100%) rename system/sai/sai/{page/default_page/modules/badgecreator/main.html => modules/badge_creator/badgecreator.tpl} (95%) create mode 100644 system/sai/sai/modules/badge_creator/saimod_dasense_badge_creator.php delete mode 100644 system/sai/sai/modules/saimod_dasense_badge_creator.php delete mode 100644 system/sai/sai/page/action_test/action_test.php rename system/sai/sai/page/default_page/{carousel.html => carousel.tpl} (72%) delete mode 100644 system/sai/sai/page/default_page/default_developer.php create mode 100644 system/sai/sai/page/login_page/login.tpl create mode 100644 system/sai/sai/page/login_page/login_page.php create mode 100644 system/system/time.php diff --git a/dbd/autoload.inc.php b/dbd/autoload.inc.php deleted file mode 100644 index 260faee..0000000 --- a/dbd/autoload.inc.php +++ /dev/null @@ -1,7 +0,0 @@ -registerFolder(dirname(__FILE__).'/db/','DBD'); -$autoload->registerFolder(dirname(__FILE__).'/tbl/','DBD'); -$autoload->registerFolder(dirname(__FILE__).'/tbl/analysis/','DBD\ANALYSIS'); \ No newline at end of file diff --git a/dbd/db/system.php b/dbd/db/system.php deleted file mode 100644 index aae5f19..0000000 --- a/dbd/db/system.php +++ /dev/null @@ -1,9 +0,0 @@ -m_dbinfo instanceof \SYSTEM\DB\DBInfo){ - $tree = self::getApiTree();} - else { + $tree = self::getApiTree(); + if(!is_array($tree)){ + throw new \SYSTEM\LOG\ERROR("Database Tree for Api empty - cannot proced!");} + } else { if(!is_array($this->m_dbinfo)){ - throw new Exception('No Connectioninfo and no call table given to the api');} + throw new \SYSTEM\LOG\ERROR('No Connectioninfo and no call table given to the api');} $tree = $this->m_dbinfo; - } - - //print_r($tree); - if(!is_array($tree)){ - throw new \Exception("Database Tree for Api empty - cannot proced!");} + } //Commands $commands = array(); $parentid = -1; - foreach($tree as $item){ - if( $item[\DBD\APITable::FIELD_FLAG] == \DBD\APITable::VALUE_FLAG_COMMAND && - $item[\DBD\APITable::FIELD_PARENTID] == $parentid && - isset($call[$item[\DBD\APITable::FIELD_NAME]])){ - - if( isset($item[\DBD\APITable::FIELD_PARENTVALUE]) && - $commands[count($commands)-1][1] != $item[\DBD\APITable::FIELD_PARENTVALUE]){ - continue;} - $commands[] = array($item,$call[$item[\DBD\APITable::FIELD_NAME]]); - $parentid = $item[\DBD\APITable::FIELD_ID]; + + foreach($tree as $item){ + if( intval($item[\DBD\SYSTEM\APITable::FIELD_FLAG]) == \DBD\SYSTEM\APITable::VALUE_FLAG_COMMAND && + intval($item[\DBD\SYSTEM\APITable::FIELD_PARENTID]) == $parentid && + isset($call[$item[\DBD\SYSTEM\APITable::FIELD_NAME]])){ + + if( isset($item[\DBD\SYSTEM\APITable::FIELD_PARENTVALUE]) && + $commands[count($commands)-1][1] != $item[\DBD\SYSTEM\APITable::FIELD_PARENTVALUE]){ + continue; + } + + $commands[] = array($item,$call[$item[\DBD\SYSTEM\APITable::FIELD_NAME]]); + $parentid = intval($item[\DBD\SYSTEM\APITable::FIELD_ID]); } } - + //Parameters $parameters = array(); $lastCommand = $commands[count($commands)-1][0]; foreach($tree as $item){ - if( $item[\DBD\APITable::FIELD_FLAG] == \DBD\APITable::VALUE_FLAG_PARAM && - $item[\DBD\APITable::FIELD_PARENTID] == $lastCommand[\DBD\APITable::FIELD_ID]){ + if( intval($item[\DBD\SYSTEM\APITable::FIELD_FLAG]) == \DBD\SYSTEM\APITable::VALUE_FLAG_PARAM && + intval($item[\DBD\SYSTEM\APITable::FIELD_PARENTID]) == $lastCommand[\DBD\SYSTEM\APITable::FIELD_ID]){ - if( isset($item[\DBD\APITable::FIELD_PARENTVALUE]) && - $commands[count($commands)-1][1] != $item[\DBD\APITable::FIELD_PARENTVALUE]){ + if( isset($item[\DBD\SYSTEM\APITable::FIELD_PARENTVALUE]) && + $commands[count($commands)-1][1] != $item[\DBD\SYSTEM\APITable::FIELD_PARENTVALUE]){ continue;} - if(!isset($call[$item[\DBD\APITable::FIELD_NAME]])){ - throw new \Exception('Parameter missing: '.$item[\DBD\APITable::FIELD_NAME]);} + if(!isset($call[$item[\DBD\SYSTEM\APITable::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter missing: '.$item[\DBD\SYSTEM\APITable::FIELD_NAME]);} - if( !method_exists($this->m_verifyclass, $item[\DBD\APITable::FIELD_ALLOWEDVALUES]) || - !$this->m_verifyclass->$item[\DBD\APITable::FIELD_ALLOWEDVALUES]($call[$item[\DBD\APITable::FIELD_NAME]])){ - throw new \Exception('Parameter type missmacht or Missing Verifier. Param: '.$item[\DBD\APITable::FIELD_NAME].' Verifier: '.$item[\DBD\APITable::FIELD_ALLOWEDVALUES]);} + if( !method_exists($this->m_verifyclass, $item[\DBD\SYSTEM\APITable::FIELD_ALLOWEDVALUES]) || + !$this->m_verifyclass->$item[\DBD\SYSTEM\APITable::FIELD_ALLOWEDVALUES]($call[$item[\DBD\SYSTEM\APITable::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\DBD\SYSTEM\APITable::FIELD_NAME].' Verifier: '.$item[\DBD\SYSTEM\APITable::FIELD_ALLOWEDVALUES]);} - $parameters[] = array($item, $call[$item[\DBD\APITable::FIELD_NAME]]); + $parameters[] = array($item, $call[$item[\DBD\SYSTEM\APITable::FIELD_NAME]]); } - } - - //Check - /*echo "
";
-        print_r($commands);
-        echo "
"; - echo "
---
"; - print_r($parameters); - echo "
---
"; - print_r($call); - echo "
---
"; - echo count($call).'-'.count($parameters).'-'.count($commands);*/ - if(count($call) != count($parameters) + count($commands)){ - throw new \Exception("Unhandled or misshandled parameters - api query is invalid");} + } + if(count($call) != (count($parameters) + count($commands)) ){ + throw new \SYSTEM\LOG\ERROR('Unhandled or misshandled parameters - api query is invalid');} //Function Name $command_call = ""; foreach($commands as $com){ if(!\preg_match('^[0-9A-Za-z_]+$^', $com[1])){ - throw new \Exception("Call Command can only have letters!");} + throw new \SYSTEM\LOG\ERROR('Call Command can only have letters!');} - if($com[0][\DBD\APITable::FIELD_ALLOWEDVALUES] == 'FLAG'){ - $command_call .= '_flag_'.$com[0][\DBD\APITable::FIELD_NAME]; + if($com[0][\DBD\SYSTEM\APITable::FIELD_ALLOWEDVALUES] == 'FLAG'){ + $command_call .= '_flag_'.$com[0][\DBD\SYSTEM\APITable::FIELD_NAME]; } else { - $command_call .= '_'.$com[0][\DBD\APITable::FIELD_NAME].'_'.\strtolower($com[1]);} + $command_call .= '_'.$com[0][\DBD\SYSTEM\APITable::FIELD_NAME].'_'.\strtolower($com[1]);} } $command_call = substr($command_call, 1); @@ -143,7 +130,7 @@ class Api { $parameter_call[] = $param[1];} if(!\method_exists($this->m_apiclass, $command_call)){ - throw new \Exception("API call is not implemented in API: ".$command_call);} + throw new \SYSTEM\LOG\ERROR("API call is not implemented in API: ".$command_call);} //Call Function return \call_user_func_array(array($this->m_apiclass,$command_call),$parameter_call); @@ -152,11 +139,11 @@ class Api { private function getApiTree(){ $con = new \SYSTEM\DB\Connection($this->m_dbinfo); - $res = $con->query("SELECT * FROM ".\DBD\APITable::NAME." ORDER BY ".\DBD\APITable::FIELD_ID); + $res = $con->query('SELECT * FROM '.\DBD\SYSTEM\APITable::NAME.' ORDER BY "'.\DBD\SYSTEM\APITable::FIELD_ID.'"'); unset($con); if(!$res){ - throw new \Exception("Sql Error ".mysqli_error());} + throw new \SYSTEM\LOG\ERROR('Database Error '.pg_last_error($con));} $result = array(); while($row = $res->next()){ diff --git a/system/api/apiloginclass.php b/system/api/apiloginclass.php index d6066b7..80d7bf8 100644 --- a/system/api/apiloginclass.php +++ b/system/api/apiloginclass.php @@ -2,10 +2,7 @@ namespace SYSTEM\API; -abstract class apiloginclass extends \SYSTEM\API\apiclass { - - protected abstract static function getUserDBInfo(); - +class apiloginclass extends \SYSTEM\API\apiclass { /* INSERT INTO `APICalls` (`ID`, `Flag`, `ParentID`, `ParentValue`, `Name`, `AllowedValues`) VALUES (0, 0, -1, NULL, 'call', NULL); INSERT INTO `APICalls` (`ID`, `Flag`, `ParentID`, `ParentValue`, `Name`, `AllowedValues`) VALUES (60, 0, 0, 'account', 'action', NULL); @@ -22,14 +19,14 @@ abstract class apiloginclass extends \SYSTEM\API\apiclass { INSERT INTO `APICalls` (`ID`, `Flag`, `ParentID`, `ParentValue`, `Name`, `AllowedValues`) VALUES (68, 1, 60, 'create', 'hashed', 'ALL'); */ - public static function call_account_action_login($username, $password, $hashed){ - return \SYSTEM\SECURITY\Security::login(static::getUserDBInfo(), $username, $password, $hashed);} + public static function call_account_action_login($username, $password_sha, $password_md5){ + return \SYSTEM\SECURITY\Security::login(new \DBD\SYSTEM\systemPostgres(), $username, $password_sha, $password_md5);} public static function call_account_action_logout(){ return \SYSTEM\SECURITY\Security::logout();} public static function call_account_action_isloggedin(){ return \SYSTEM\SECURITY\Security::isLoggedIn();} public static function call_account_action_check($rightid){ - return \SYSTEM\SECURITY\Security::check(static::getUserDBInfo(),$rightid);} - public static function call_account_action_create($username, $password, $email, $hashed){ - return \SYSTEM\SECURITY\Security::create(static::getUserDBInfo(), $username, $password, $email, $hashed);} + return \SYSTEM\SECURITY\Security::check(new \DBD\SYSTEM\systemPostgres(),$rightid);} + public static function call_account_action_create($username, $password_sha, $email, $locale){ + return \SYSTEM\SECURITY\Security::create(new \DBD\SYSTEM\systemPostgres(), $username, $password_sha, $email, $locale);} } \ No newline at end of file diff --git a/system/cache/cache.php b/system/cache/cache.php new file mode 100644 index 0000000..b704cb2 --- /dev/null +++ b/system/cache/cache.php @@ -0,0 +1,45 @@ +prepare( 'checkCache', + 'SELECT "data" FROM system.cache'. + ' WHERE "CacheID" = $1 AND'. + ' "Ident" = $2;', + array($cache_id,$ident)); + if(!($result = $res->next())){ + return NULL;} + + return pg_unescape_bytea($result['data']); + } + + public static function put(\SYSTEM\DB\DBInfo $dbinfo, $cache_id, $ident, $data, $fail_on_exist = false){ + if((self::get($dbinfo,$cache_id,$ident) != NULL)){ + if($fail_on_exist){ + return false;} + self::del($dbinfo, $cache_id, $ident); + } + + $con = new \SYSTEM\DB\Connection($dbinfo); + $res = $con->prepare( 'insertCache', + 'INSERT INTO system.cache ("CacheID", "Ident", "data")'. + ' VALUES ($1,$2,$3);', + array($cache_id,$ident,pg_escape_bytea($data))); + return $res->next() ? $data : NULL; + } + + public static function del(\SYSTEM\DB\DBInfo $dbinfo, $cache_id, $ident){ + $con = new \SYSTEM\DB\Connection($dbinfo); + $res = $con->prepare( 'deleteCache', + 'DELETE FROM system.cache'. + ' WHERE "CacheID" = $1 AND'. + ' "Ident" = $2;', + array($cache_id,$ident)); + + return $res->next() ? true : false; + } +} \ No newline at end of file diff --git a/system/db/Query.php b/system/db/Query.php deleted file mode 100644 index 29fe5a6..0000000 --- a/system/db/Query.php +++ /dev/null @@ -1,7 +0,0 @@ -sqlstr = $string;} - - public function getSQL(){ - return $this->sqlstr;} -} \ No newline at end of file diff --git a/system/db/connection/Connection.php b/system/db/connection/Connection.php new file mode 100644 index 0000000..8dd21ce --- /dev/null +++ b/system/db/connection/Connection.php @@ -0,0 +1,40 @@ +dbinfo = $dbinfo; + + if($dbinfo instanceof \SYSTEM\DB\DBInfoPG){ + $this->connection = new \SYSTEM\DB\ConnectionPG($dbinfo); + } else if ($dbinfo instanceof \SYSTEM\DB\DBInfoMYS){ + $this->connection = new \SYSTEM\DB\ConnectionMYS($dbinfo); + } else if ($dbinfo instanceof \SYSTEM\DB\DBInfoAMQP){ + $this->connection = new \SYSTEM\DB\ConnectionAMQP($dbinfo); + } else { + throw new \Exception('Could not understand Database Settings. Check ur Database Settings');} + } + + //Destruct connection object. + public function __destruct(){ + unset($this->connection);} + + //Query connected Database with prepared statements, $stmt = sql string with ?; $values = array of values + public function prepare($stmtName, $stmt, $values){ + return $this->connection->prepare($stmtName, $stmt, $values);} + + //Close Connection + public function close(){ + return $this->connection->close();} + + //Query connected Database + public function query($query){ + return $this->connection->query($query);} +} \ No newline at end of file diff --git a/system/db/connection/ConnectionAMQP.php b/system/db/connection/ConnectionAMQP.php new file mode 100644 index 0000000..41aef29 --- /dev/null +++ b/system/db/connection/ConnectionAMQP.php @@ -0,0 +1,64 @@ +connection = new \AMQPConnection( + array( + 'host' => $dbinfo->m_host, + 'vhost' => $dbinfo->m_database, + 'port' => $dbinfo->m_port, + 'login' => $dbinfo->m_user, + 'password' => $dbinfo->m_password + )); + + $this->connection->connect(); + + if(!$this->connection || !$this->connection->isConnected()){ + throw new \SYSTEM\LOG\ERROR('Cannot connect to the amqp queue!');} + } + + public function send($msg){ + $channel = new \AMQPChannel($this->connection); + $exchange = new \AMQPExchange($channel); + $exchange->setFlags(AMQP_DURABLE); + $exchange->setName('exchange2'); + $exchange->setType('direct'); + $exchange->declare(); + + $queue = new \AMQPQueue($channel); + $queue->setName('series'); + $queue->setFlags(AMQP_DURABLE | AMQP_AUTODELETE); + $queue->declare(); + $queue->bind('exchange2','series'); + + $channel->startTransaction(); + $message = $exchange->publish(json_encode($msg), 'series', AMQP_MANDATORY, + array('content_type' => 'application/json', + 'delivery_mode' => 2)); + $channel->commitTransaction(); + + if(!$message) { + throw new \SYSTEM\LOG\ERROR("Error: Message '".$message."' was not sent to queue.!"); + } + } + + public function __destruct(){ + $this->close(); + } + + public function close(){ + if (!$this->connection->disconnect()) { + throw new Exception("Could not disconnect !"); + } + } + + public function query($query){ } + + public function prepare($stmtName, $stmt, $values){} + +} \ No newline at end of file diff --git a/system/db/connection/ConnectionAbstr.php b/system/db/connection/ConnectionAbstr.php new file mode 100644 index 0000000..258bc8d --- /dev/null +++ b/system/db/connection/ConnectionAbstr.php @@ -0,0 +1,28 @@ +dbinfo = $dbinfo; - public function __construct(DBInfo $dbinfo, $new_link = false, $client_flag = 0){ - $this->dbinfo = $dbinfo; - $this->connection = mysqli_connect($dbinfo->m_host, $dbinfo->m_user, $dbinfo->m_password, $new_link, $client_flag); - - if(!$this->connection){ + if(!$this->connection){ throw new \Exception('Could not connect to Database. Check ur Database Settings');} - + if(!mysqli_select_db($this->connection, $dbinfo->m_database)){ mysqli_close($this->connection); throw new \Exception('Could not select Database. Check ur Database Settings: '.mysqli_error($this->connection));} } - public function __destruct(){ + public function __destruct(){ $this->close();} - - private static function getPrepareValueType($value){ - if(is_double($value)){ - return 'd';} - if(is_integer($value)){ - return 'i';} - if(is_string($value)){ - return 's';} - - //blob - return 'b'; - } - - //stmt = sql string with ? - //values = array of values - public function prepare($stmt, $values){ + public function prepare($stmtName, $stmt, $values){ $prepStmt = \mysqli_prepare($this->connection, $stmt); if(!$prepStmt){ throw new \Exception('Prepared Statement prepare fail: '. \mysqli_error($this->connection));} - + $types = ''; $binds = array($prepStmt,null); for($i =0; $i < \count($values);$i++){ $types .= self::getPrepareValueType($values[$i]); $binds[] = &$values[$i]; - } - $binds[1] = $types; + } + $binds[1] = $types; \call_user_func_array('mysqli_stmt_bind_param', $binds); - + if(!mysqli_stmt_execute($prepStmt)){ throw new \Exception("Could not execute prepare statement: ". \mysqli_stmt_error($prepStmt));} - + return new ResultMysqliPrepare($prepStmt); } - - public function close(){ + + public function close(){ return mysqli_close($this->connection);} - public function query($query){ - $_query = NULL; - if(\is_string($query)){ - $_query = new QueryString($query); - } elseif($query instanceof Query) { - $_query = $query; - } else { - throw new \Exception('Could not understand given Query: '.$query); - } - - $result = mysqli_query($this->connection, $_query->getSQL()); - + public function query($query){ + $result = mysqli_query($this->connection, $query); if(!$result){ throw new \Exception('Could not query Database. Check ur Query Syntax or required Rights: '.mysqli_error($this->connection));} - + if($result === TRUE){ return TRUE;} return new ResultMysqli($result); } -} +} \ No newline at end of file diff --git a/system/db/connection/ConnectionPG.php b/system/db/connection/ConnectionPG.php new file mode 100644 index 0000000..3b0130b --- /dev/null +++ b/system/db/connection/ConnectionPG.php @@ -0,0 +1,54 @@ +dbinfo = $dbinfo; + + $this->connection = pg_connect("host=".$dbinfo->m_host." port=".$dbinfo->m_port." dbname=".$dbinfo->m_database." + user=".$dbinfo->m_user." password=".$dbinfo->m_password.""); + if(!$this->connection){ + throw new \SYSTEM\LOG\ERROR('Could not connect to Database. Check ur Database Settings');} + } + + public function __destruct(){} + + public function prepare($stmtName, $stmt, $values){ + $result = pg_query_params($this->connection, 'SELECT name FROM pg_prepared_statements WHERE name = $1', array($stmtName)); + //var_dump($stmt); + //var_dump($values); + if (pg_num_rows($result) == 0) { + $result = \pg_prepare($this->connection, $stmtName, $stmt); + } + + if(!$result) + throw new \SYSTEM\LOG\ERROR('Prepared Statement prepare fail: '. \pg_last_error($this->connection)); + + $result = \pg_execute($this->connection, $stmtName, $values); + + if(!$result) + throw new \SYSTEM\LOG\ERROR("Could not execute prepare statement: ". \pg_last_error($this->connection)); + + return new ResultPostgres($result); + } + + public function close(){ + return pg_close($this->connection);} + + public function query($query){ + $result = pg_query($this->connection, $query); + if(!$result){ + throw new \SYSTEM\LOG\ERROR('Could not query Database. Check ur Query Syntax or required Rights: '.pg_last_error($this->connection));} + + if($result === TRUE){ + return TRUE;} + + return new ResultPostgres($result); + } + +} \ No newline at end of file diff --git a/system/db/dbinfo/DBInfo.php b/system/db/dbinfo/DBInfo.php new file mode 100644 index 0000000..326ab1e --- /dev/null +++ b/system/db/dbinfo/DBInfo.php @@ -0,0 +1,13 @@ +m_database = $vhost; + $this->m_user = $user; + $this->m_password = $password; + $this->m_host = $host; + $this->m_port = $port; + + if( $this->m_database == null || + $this->m_user == null || + $this->m_password == null || + $this->m_host == null){ + throw new \Exception("AMQP Connection Info not correct, vhost, user, password or host are null");} + } +} \ No newline at end of file diff --git a/system/db/dbinfo/DBInfoMYS.php b/system/db/dbinfo/DBInfoMYS.php new file mode 100644 index 0000000..a7e3580 --- /dev/null +++ b/system/db/dbinfo/DBInfoMYS.php @@ -0,0 +1,19 @@ +m_database = $database; + $this->m_user = $user; + $this->m_password = $password; + $this->m_host = $host; + $this->m_port = $port; + + if( $this->m_database == null || + $this->m_user == null || + $this->m_password == null || + $this->m_host == null){ + throw new \Exception("DBInfo not correct, database, user, password or host are null");} + } +} \ No newline at end of file diff --git a/system/db/DBInfo.php b/system/db/dbinfo/DBInfoPG.php similarity index 77% rename from system/db/DBInfo.php rename to system/db/dbinfo/DBInfoPG.php index 105bf81..1201904 100644 --- a/system/db/DBInfo.php +++ b/system/db/dbinfo/DBInfoPG.php @@ -1,18 +1,14 @@ m_database = $database; $this->m_user = $user; $this->m_password = $password; $this->m_host = $host; + $this->m_port = $port; if( $this->m_database == null || $this->m_user == null || @@ -20,5 +16,4 @@ class DBInfo { $this->m_host == null){ throw new \Exception("DBInfo not correct, database, user, password or host are null");} } - } \ No newline at end of file diff --git a/system/db/Result.php b/system/db/result/Result.php similarity index 100% rename from system/db/Result.php rename to system/db/result/Result.php diff --git a/system/db/result/ResultAMQP.php b/system/db/result/ResultAMQP.php new file mode 100644 index 0000000..5f29384 --- /dev/null +++ b/system/db/result/ResultAMQP.php @@ -0,0 +1,37 @@ +res = $res;} + + public function __destruct(){ + $this->close();} + + public function close(){ + pg_free_result($this->res);} + + public function count(){ + return pg_num_rows($this->res);} + + public function affectedRows(){ + throw new \SYSTEM\LOG\ERROR("Not Supported!");} + + public function next($object = false, $result_type = MYSQL_BOTH){ + if($object){ + $this->current = pg_fetch_object($this->res); + } else { + $this->current = pg_fetch_assoc($this->res); + } + return $this->current; + } + + public function seek($row_number){ + return pg_data_seek($this->res,$row_number);} +} \ No newline at end of file diff --git a/system/db/ResultMysqli.php b/system/db/result/ResultMysqli.php similarity index 100% rename from system/db/ResultMysqli.php rename to system/db/result/ResultMysqli.php diff --git a/system/db/ResultMysqliPrepare.php b/system/db/result/ResultMysqliPrepare.php similarity index 100% rename from system/db/ResultMysqliPrepare.php rename to system/db/result/ResultMysqliPrepare.php diff --git a/system/db/result/ResultPostgres.php b/system/db/result/ResultPostgres.php new file mode 100644 index 0000000..4a3adbb --- /dev/null +++ b/system/db/result/ResultPostgres.php @@ -0,0 +1,37 @@ +res = $res;} + + public function __destruct(){ + $this->close();} + + public function close(){ + pg_free_result($this->res);} + + public function count(){ + return pg_num_rows($this->res);} + + public function affectedRows(){ + return pg_affected_rows($this->res);} + + public function next($object = false, $result_type = MYSQL_BOTH){ + if($object){ + $this->current = pg_fetch_object($this->res); + } else { + $this->current = pg_fetch_assoc($this->res); + } + return $this->current; + } + + public function seek($row_number){ + return pg_data_seek($this->res,$row_number);} +} \ No newline at end of file diff --git a/system/dbd/autoload.inc.php b/system/dbd/autoload.inc.php new file mode 100644 index 0000000..d031fe7 --- /dev/null +++ b/system/dbd/autoload.inc.php @@ -0,0 +1,9 @@ +registerFolder(dirname(__FILE__).'/db/','DBD'); +$autoload->registerFolder(dirname(__FILE__).'/tbl/system/','DBD\SYSTEM'); +//$autoload->registerFolder(dirname(__FILE__).'/tbl/definitions/','DBD\DEFINITIONS'); +//$autoload->registerFolder(dirname(__FILE__).'/tbl/data/','DBD\DATA'); +//$autoload->registerFolder(dirname(__FILE__).'/tbl/data_processed/','DBD\DATA_PROCESSED'); \ No newline at end of file diff --git a/system/dbd/db/systemPostgres.php b/system/dbd/db/systemPostgres.php new file mode 100644 index 0000000..2e100ac --- /dev/null +++ b/system/dbd/db/systemPostgres.php @@ -0,0 +1,7 @@ +handlers[] = $handler; + + set_error_handler('\SYSTEM\LOG\LOG::__error_handler'); + set_exception_handler('\SYSTEM\LOG\LOG::__exception_handler'); + } + + private function call_handlers(\Exception $E, $errno, $thrown = false){ + foreach($this->handlers as $handler){ + if( ((call_user_func(array($handler,'MASK')) & $errno)) && + call_user_func_array(array($handler,'CALL'),array($E,$errno, $thrown))){ + return true; + } + } + return false; + } + +//Static + //Exceptions + public static function __exception_handler(\Exception $E, $thrown = true){ + if($E instanceof \SYSTEM\LOG\ERROR) { return self::LOG_EXCEPTION($E, E_USER_ERROR, $thrown);} //Dies + if($E instanceof \SYSTEM\LOG\WARNING) { return self::LOG_EXCEPTION($E, E_USER_WARNING, $thrown);} //Continues + if($E instanceof \SYSTEM\LOG\INFO) { return self::LOG_EXCEPTION($E, E_NOTICE, $thrown);} //Continues + if($E instanceof \SYSTEM\LOG\DEPRECATED){ return self::LOG_EXCEPTION($E, E_USER_DEPRECATED, $thrown);} //Continues + self::LOG_EXCEPTION($E, E_USER_ERROR, $thrown); //Dies + } + + //Triggers error, if not handled by registered Handlers(double check -> but only this way we can keep the original Exception class) + protected static function LOG_EXCEPTION(\Exception $E,$errno = E_USER_ERROR, $thrown = false){ + self::__error_handler_e($E, $errno, $thrown);} + + //Errors + public static function __error_handler($errno, $errstr, $errfile, $errline){ + $e = new \SYSTEM\LOG\ERROR($errstr,$errno); + return self::__error_handler_e($e ,$errno, true);} + public static function __error_handler_e(\Exception $E, $errno, $thrown){ + switch ($errno) { + //Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted. + case E_ERROR: return self::_DIE($E,$errno,true); + //Run-time warnings (non-fatal errors). Execution of the script is not halted. + case E_WARNING: return self::_CONTINUE($E,$errno,true); + //Compile-time parse errors. Parse errors should only be generated by the parser. + case E_PARSE: return self::_DIE($E,$errno,true); + //Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. + case E_NOTICE: return self::_CONTINUE($E,$errno,false | $thrown); + //Fatal errors that occur during PHP's initial startup. This is like an E_ERROR, except it is generated by the core of PHP. + case E_CORE_ERROR: return self::_DIE($E,$errno,true); + //Warnings (non-fatal errors) that occur during PHP's initial startup. This is like an E_WARNING, except it is generated by the core of PHP. + case E_CORE_WARNING: return self::_CONTINUE($E,$errno,true); + //Fatal compile-time errors. This is like an E_ERROR, except it is generated by the Zend Scripting Engine. + case E_COMPILE_ERROR: return self::_DIE($E,$errno,true); + //Compile-time warnings (non-fatal errors). This is like an E_WARNING, except it is generated by the Zend Scripting Engine. + case E_COMPILE_WARNING: return self::_CONTINUE($E,$errno,true); + //User-generated error message. This is like an E_ERROR, except it is generated in PHP code by using the PHP function trigger_error(). + case E_USER_ERROR: return self::_DIE($E,$errno,false | $thrown); + //User-generated warning message. This is like an E_WARNING, except it is generated in PHP code by using the PHP function trigger_error(). + case E_USER_WARNING: return self::_CONTINUE($E,$errno,false | $thrown); + //Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. Since PHP 5 but not included in E_ALL until PHP 5.4.0 rated in PHP code by using the PHP function trigger_error(). + case E_STRICT: return self::_CONTINUE($E,$errno,true); + //Catchable fatal error. It indicates that a probably dangerous error occurred, but did not leave the Engine in an unstable state. If the error is not caught by a user defined handle (see also set_error_handler()), the application aborts as it was an E_ERROR. Since PHP 5.2.0 + case E_RECOVERABLE_ERROR: return self::_CONTINUE($E,$errno,true); + //Run-time notices. Enable this to receive warnings about code that will not work in future versions. Since PHP 5.3.0 + case E_DEPRECATED: return self::_CONTINUE($E,$errno,true); + //User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error(). Since PHP 5.3.0 + case E_USER_DEPRECATED: return self::_CONTINUE($E,$errno,false | $thrown); + default: return false; //Not handled Error use std php handler + } + } + + private static function _DIE(\Exception $E, $errno, $thrown = false){ + if(self::getInstance()->call_handlers($E, $errno, $thrown)){die();}} + private static function _CONTINUE(\Exception $E, $errno, $thrown = false){ + return self::getInstance()->call_handlers($E, $errno, $thrown);} +} \ No newline at end of file diff --git a/system/log/error_handler/error_handler.php b/system/log/error_handler/error_handler.php new file mode 100644 index 0000000..20b68b2 --- /dev/null +++ b/system/log/error_handler/error_handler.php @@ -0,0 +1,10 @@ +prepare( 'sysLogStmt', 'INSERT INTO system.sys_log '. + '(class, message, code, file, line, trace, ip, querytime) '. + 'VALUES ($1, $2, $3, $4, $5, $6, $7, $8);', + array( get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(), + getenv('REMOTE_ADDR'),round(microtime(true) - \SYSTEM\time::getStartTime(),5))); + } catch (\Exception $E){} //Error -> Ignore + + return false; //We just log and do not handle the error! + } + + abstract protected static function getDBInfo(); +} \ No newline at end of file diff --git a/system/log/error_handler/error_handler_jsonoutput.php b/system/log/error_handler/error_handler_jsonoutput.php new file mode 100644 index 0000000..dbc4ed9 --- /dev/null +++ b/system/log/error_handler/error_handler_jsonoutput.php @@ -0,0 +1,15 @@ + multiple headers are sent + } + } +} \ No newline at end of file diff --git a/system/log/exceptions/DEPRECATED.php b/system/log/exceptions/DEPRECATED.php new file mode 100644 index 0000000..d6bc9e7 --- /dev/null +++ b/system/log/exceptions/DEPRECATED.php @@ -0,0 +1,10 @@ +registerHandler('\SYSTEM\LOG\error_handler_jsonoutput'); \ No newline at end of file diff --git a/system/log/register_exception_shortcut.php b/system/log/register_exception_shortcut.php new file mode 100644 index 0000000..8f8593c --- /dev/null +++ b/system/log/register_exception_shortcut.php @@ -0,0 +1,2 @@ +registerFolder(dirname(__FILE__).'/exceptions_shortcut',''); \ No newline at end of file diff --git a/system/log/register_result_shortcut.php b/system/log/register_result_shortcut.php new file mode 100644 index 0000000..88667c2 --- /dev/null +++ b/system/log/register_result_shortcut.php @@ -0,0 +1,2 @@ +registerFolder(dirname(__FILE__).'/result_shortcut',''); \ No newline at end of file diff --git a/system/log/result/AbstractResult.php b/system/log/result/AbstractResult.php new file mode 100644 index 0000000..e177863 --- /dev/null +++ b/system/log/result/AbstractResult.php @@ -0,0 +1,15 @@ +getMessage()); + $error['code'] = $e->getCode(); + $error['file'] = $e->getFile(); + $error['line'] = $e->getLine(); + $error['trace'] = array_slice(explode('#', $e->getTraceAsString()), 1, -1);; + + return self::toString($error, self::JSONRESULT_ERROR); + } + + //Returns OK status + public static function ok(){ + return self::toString(array());} +} \ No newline at end of file diff --git a/system/log/result_shortcut/JsonResult.php b/system/log/result_shortcut/JsonResult.php new file mode 100644 index 0000000..30dabf6 --- /dev/null +++ b/system/log/result_shortcut/JsonResult.php @@ -0,0 +1,3 @@ +m_dbinfo)){ - throw new Exception('No Connectioninfo and no call table given to the api');} + throw new \SYSTEM\LOG\ERROR('No Connectioninfo and no call table given to the api');} $tree = $this->m_dbinfo; } @@ -50,15 +50,15 @@ class PageApi { $commands = array(); $parentid = -1; foreach($tree as $item){ - if( $item[\DBD\PAGETable::FIELD_FLAG] == \DBD\PAGETable::VALUE_FLAG_COMMAND && - $item[\DBD\PAGETable::FIELD_PARENTID] == $parentid && - isset($call[$item[\DBD\PAGETable::FIELD_NAME]])){ + if( $item[\DBD\SYSTEM\PAGETable::FIELD_FLAG] == \DBD\SYSTEM\PAGETable::VALUE_FLAG_COMMAND && + $item[\DBD\SYSTEM\PAGETable::FIELD_PARENTID] == $parentid && + isset($call[$item[\DBD\SYSTEM\PAGETable::FIELD_NAME]])){ - if( isset($item[\DBD\PAGETable::FIELD_PARENTVALUE]) && - $commands[count($commands)-1][1] != $item[\DBD\PAGETable::FIELD_PARENTVALUE]){ + if( isset($item[\DBD\SYSTEM\PAGETable::FIELD_PARENTVALUE]) && + $commands[count($commands)-1][1] != $item[\DBD\SYSTEM\PAGETable::FIELD_PARENTVALUE]){ continue;} - $commands[] = array($item,$call[$item[\DBD\PAGETable::FIELD_NAME]]); - $parentid = $item[\DBD\PAGETable::FIELD_ID]; + $commands[] = array($item,$call[$item[\DBD\SYSTEM\PAGETable::FIELD_NAME]]); + $parentid = $item[\DBD\SYSTEM\PAGETable::FIELD_ID]; } } @@ -68,34 +68,34 @@ class PageApi { if(count($commands) > 0){ $lastCommand = $commands[count($commands) -1 ][0]; foreach($tree as $item){ - if( $item[\DBD\PAGETable::FIELD_FLAG] == \DBD\PAGETable::VALUE_FLAG_PARAM && - $item[\DBD\PAGETable::FIELD_PARENTID] == $lastCommand[\DBD\PAGETable::FIELD_ID]){ + if( $item[\DBD\SYSTEM\PAGETable::FIELD_FLAG] == \DBD\SYSTEM\PAGETable::VALUE_FLAG_PARAM && + $item[\DBD\SYSTEM\PAGETable::FIELD_PARENTID] == $lastCommand[\DBD\SYSTEM\PAGETable::FIELD_ID]){ - if( isset($item[\DBD\PAGETable::FIELD_PARENTVALUE]) && - $commands[count($commands)-1][1] != $item[\DBD\PAGETable::FIELD_PARENTVALUE]){ + if( isset($item[\DBD\SYSTEM\PAGETable::FIELD_PARENTVALUE]) && + $commands[count($commands)-1][1] != $item[\DBD\SYSTEM\PAGETable::FIELD_PARENTVALUE]){ continue;} - if(!isset($call[$item[\DBD\PAGETable::FIELD_NAME]])){ - throw new \Exception('Parameter missing: '.$item[\DBD\PAGETable::FIELD_NAME]);} + if(!isset($call[$item[\DBD\SYSTEM\PAGETable::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter missing: '.$item[\DBD\SYSTEM\PAGETable::FIELD_NAME]);} - if( !method_exists($this->m_verifyclass, $item[\DBD\PAGETable::FIELD_ALLOWEDVALUES]) || - !$this->m_verifyclass->$item[\DBD\PAGETable::FIELD_ALLOWEDVALUES]($call[$item[\DBD\PAGETable::FIELD_NAME]])){ - throw new \Exception('Parameter type missmacht or Missing Verifier. Param: '.$item[\DBD\PAGETable::FIELD_NAME].' Verifier: '.$item[\DBD\PAGETable::FIELD_ALLOWEDVALUES]);} + if( !method_exists($this->m_verifyclass, $item[\DBD\SYSTEM\PAGETable::FIELD_ALLOWEDVALUES]) || + !$this->m_verifyclass->$item[\DBD\SYSTEM\PAGETable::FIELD_ALLOWEDVALUES]($call[$item[\DBD\SYSTEM\PAGETable::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\DBD\SYSTEM\PAGETable::FIELD_NAME].' Verifier: '.$item[\DBD\SYSTEM\PAGETable::FIELD_ALLOWEDVALUES]);} - $parameters[] = array($item, $call[$item[\DBD\PAGETable::FIELD_NAME]]); + $parameters[] = array($item, $call[$item[\DBD\SYSTEM\PAGETable::FIELD_NAME]]); } } //Function Name foreach($commands as $com){ if(!\preg_match('^[0-9A-Za-z_]+$^', $com[1])){ - throw new \Exception("Call Command can only have letters!");} + throw new \SYSTEM\LOG\ERROR("Call Command can only have letters!");} - if($com[0][\DBD\PAGETable::FIELD_ALLOWEDVALUES] == 'FLAG'){ - $command_call .= '_flag_'.$com[0][\DBD\PAGETable::FIELD_NAME]; + if($com[0][\DBD\SYSTEM\PAGETable::FIELD_ALLOWEDVALUES] == 'FLAG'){ + $command_call .= '_flag_'.$com[0][\DBD\SYSTEM\PAGETable::FIELD_NAME]; } else { - $command_call .= '_'.$com[0][\DBD\PAGETable::FIELD_NAME].'_'.\strtolower($com[1]);} + $command_call .= '_'.$com[0][\DBD\SYSTEM\PAGETable::FIELD_NAME].'_'.\strtolower($com[1]);} } $command_call = substr($command_call, 1); } @@ -110,7 +110,7 @@ class PageApi { } if(!\method_exists($this->m_pageclass, $command_call)){ - throw new \Exception("Page call is not implemented in PageApi: ".$command_call);} + throw new \SYSTEM\LOG\ERROR("Page call is not implemented in PageApi: ".$command_call);} //Call Function return \call_user_func_array(array($this->m_pageclass,$command_call),$parameter_call); @@ -119,10 +119,10 @@ class PageApi { private function getPageTree(){ $con = new \SYSTEM\DB\Connection($this->m_dbinfo); - $res = $con->query("SELECT * FROM ".\DBD\PAGETable::NAME." ORDER BY ".\DBD\PAGETable::FIELD_ID); + $res = $con->query('SELECT * FROM '.\DBD\SYSTEM\PAGETable::NAME.' ORDER BY "'.\DBD\SYSTEM\PAGETable::FIELD_ID.'"'); if(!$res){ - throw new \Exception("Sql Error ".mysqli_error());} + throw new \SYSTEM\LOG\ERROR("Database Error ". pg_last_error());} $result = array(); while($row = $res->next()){ diff --git a/system/page/PageClass.php b/system/page/PageClass.php index dc75a6f..61f39fa 100644 --- a/system/page/PageClass.php +++ b/system/page/PageClass.php @@ -3,5 +3,6 @@ namespace SYSTEM\PAGE; abstract class PageClass { - public abstract static function default_page(); + public static function default_page(){ + throw new RuntimeException("Unimplemented");} } \ No newline at end of file diff --git a/system/sai/sai/SaiModule.php b/system/sai/SaiModule.php similarity index 100% rename from system/sai/sai/SaiModule.php rename to system/sai/SaiModule.php diff --git a/system/sai/index.php b/system/sai/index.php index 12cf720..c1143f8 100644 --- a/system/sai/index.php +++ b/system/sai/index.php @@ -3,6 +3,7 @@ require_once 'saigui.php'; //TODO database +new \SYSTEM\LOG\DEPRECATED("database"); $sai = new \SYSTEM\SAI\saigui(/*new \DBD\system()*/ new \DBD\dasenseuser()); echo $sai->html(); \ No newline at end of file diff --git a/system/sai/sai/SaiApi.php b/system/sai/sai/SaiApi.php deleted file mode 100644 index aa04644..0000000 --- a/system/sai/sai/SaiApi.php +++ /dev/null @@ -1,12 +0,0 @@ -registerFolder(dirname(__FILE__),'SYSTEM\SAI'); $autoload->registerFolder(dirname(__FILE__).'/page','SYSTEM\SAI'); -$autoload->registerFolder(dirname(__FILE__).'/page/action_test','SYSTEM\SAI'); $autoload->registerFolder(dirname(__FILE__).'/page/default_page','SYSTEM\SAI'); +$autoload->registerFolder(dirname(__FILE__).'/page/login_page','SYSTEM\SAI'); $autoload->registerFolder(dirname(__FILE__).'/modules','SYSTEM\SAI'); +$autoload->registerFolder(dirname(__FILE__).'/modules/badge_creator','SYSTEM\SAI'); require_once dirname(__FILE__).'/modules/register_modules.php'; \ No newline at end of file diff --git a/system/sai/sai/page/default_page/js/badgecreator.js b/system/sai/sai/modules/badge_creator/badgecreator.js similarity index 100% rename from system/sai/sai/page/default_page/js/badgecreator.js rename to system/sai/sai/modules/badge_creator/badgecreator.js diff --git a/system/sai/sai/page/default_page/modules/badgecreator/main.html b/system/sai/sai/modules/badge_creator/badgecreator.tpl similarity index 95% rename from system/sai/sai/page/default_page/modules/badgecreator/main.html rename to system/sai/sai/modules/badge_creator/badgecreator.tpl index d1da3d7..37efd44 100644 --- a/system/sai/sai/page/default_page/modules/badgecreator/main.html +++ b/system/sai/sai/modules/badge_creator/badgecreator.tpl @@ -122,8 +122,7 @@ - - + ${js} diff --git a/system/sai/sai/modules/badge_creator/saimod_dasense_badge_creator.php b/system/sai/sai/modules/badge_creator/saimod_dasense_badge_creator.php new file mode 100644 index 0000000..30fdbf8 --- /dev/null +++ b/system/sai/sai/modules/badge_creator/saimod_dasense_badge_creator.php @@ -0,0 +1,15 @@ +'. + '';} + public static function html_css(){return '';} + public static function html_content(){ + return \SYSTEM\PAGE\replace::replaceFile( \SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'sai/modules/badge_creator/badgecreator.tpl'), + array( 'js' => self::html_js()));} + public static function html_li_menu(){return '
  • Badge Creator
  • ';} +} \ No newline at end of file diff --git a/system/sai/sai/modules/saimod_dasense_badge_creator.php b/system/sai/sai/modules/saimod_dasense_badge_creator.php deleted file mode 100644 index eca192b..0000000 --- a/system/sai/sai/modules/saimod_dasense_badge_creator.php +++ /dev/null @@ -1,10 +0,0 @@ -Badge Creator';} -} \ No newline at end of file diff --git a/system/sai/sai/modules/saimod_sys_api.php b/system/sai/sai/modules/saimod_sys_api.php index e1895ee..65d673a 100644 --- a/system/sai/sai/modules/saimod_sys_api.php +++ b/system/sai/sai/modules/saimod_sys_api.php @@ -91,5 +91,5 @@ class saimod_sys_api extends \SYSTEM\SAI\SaiModule { return $result; } - public static function html_li_menu(){return '
  • SYS API
  • ';} + public static function html_li_menu(){return '
  • SYS API
  • ';} } \ No newline at end of file diff --git a/system/sai/sai/page/action_test/action_test.php b/system/sai/sai/page/action_test/action_test.php deleted file mode 100644 index 7e510d2..0000000 --- a/system/sai/sai/page/action_test/action_test.php +++ /dev/null @@ -1,9 +0,0 @@ -