Exemplo n.º 1
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_config_action_sai()
 {
     $vars['sai'] = '';
     $vars['sai'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_config/tpl/config_tr.tpl'))->SERVERPATH(), array('id' => \SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_PROJECT, 'name' => '\\SYSTEM\\CONFIG\\config_ids::SYS_SAI_CONFIG_PROJECT', 'value' => \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_PROJECT)));
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_config/tpl/config_sai.tpl'))->SERVERPATH(), $vars);
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_config/tpl/config_database.tpl'))->SERVERPATH(), $vars);
 }
Exemplo n.º 2
0
 public static function isLang($lang)
 {
     if (!\in_array($lang, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS))) {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 public static function toString($json_array, $status = self::JSONRESULT_OK, $start_time = NULL)
 {
     if ($start_time == NULL) {
         $start_time = \SYSTEM\time::getStartTime();
     }
     $json = array();
     $json['querytime'] = round(microtime(true) - $start_time, 5);
     $json['status'] = $status;
     $json['result'] = $json_array;
     if (\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_RESULT) == \SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_RESULT_MSGPACK) {
         //send Header
         \SYSTEM\HEADER::JSON();
         if ($json = msgpack_pack($json)) {
             return $json;
         }
         throw new \SYSTEM\LOG\ERROR('MSGPack could not be encoded');
     } else {
         //send Header
         \SYSTEM\HEADER::JSON();
         if ($json = json_encode($json)) {
             return $json;
         }
         throw new \SYSTEM\LOG\ERROR('JSON could not be encoded');
     }
 }
 public static function lang_menu($endpoint = './api.php')
 {
     $result = '';
     $langs = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS);
     foreach ($langs as $lang) {
         $result .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_langswitcher/tpl/language.tpl'))->SERVERPATH(), array('lang' => $lang, 'endpoint' => $endpoint));
     }
     return $result;
 }
Exemplo n.º 5
0
 public function html($_escaped_fragment_ = NULL)
 {
     $vars = array();
     $vars['css'] = self::css();
     $vars['js'] = '';
     if (!$_escaped_fragment_) {
         $vars['js'] = self::js();
     }
     $vars['menu_languages'] = \SYSTEM\SAI\saimod_sys_langswitcher::lang_menu('./sai.php');
     $vars['menu_start'] = self::menu_start();
     $vars['menu_sys'] = self::menu_sys();
     $vars['menu_proj'] = self::menu_proj();
     $vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_SAI_DEFAULT), array('project' => \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_PROJECT), 'project_url' => \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL)));
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('page/tpl/sai.tpl'))->SERVERPATH(), $vars);
 }
Exemplo n.º 6
0
 public static function run()
 {
     //find oldest value
     $oldest = \SYSTEM\SQL\SYS_LOG_OLDEST::Q1();
     list($now_month, $now_year) = preg_split("/ /", date("m Y"));
     //All fine -> abort
     if ($oldest['year'] >= $now_year && $oldest['month'] >= $now_month) {
         return cronstatus::CRON_STATUS_SUCCESFULLY;
     }
     //create folder if required
     if (!file_exists(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CRON_LOG2SQLITE_PATH))) {
         mkdir(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CRON_LOG2SQLITE_PATH), 0777, true);
     }
     $filename = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CRON_LOG2SQLITE_PATH) . $oldest['year'] . '.' . $oldest['month'] . '.db';
     //extract whole month to file
     $con = new \SYSTEM\DB\Connection(new \SYSTEM\DB\DBInfoSQLite($filename));
     //create table
     $con->query('CREATE TABLE IF NOT EXISTS `system_log` (' . ' `ID` INT(10) NOT NULL,' . ' `class` TEXT NOT NULL,' . ' `message` TEXT NOT NULL,' . ' `code` INT(11) NOT NULL,' . ' `file` TEXT NOT NULL,' . ' `line` INT(11) NOT NULL,' . ' `trace` TEXT NOT NULL,' . ' `ip` TEXT NOT NULL,' . ' `querytime` DOUBLE NOT NULL,' . ' `time` DATETIME NOT NULL,' . ' `server_name` CHAR(255) NOT NULL,' . ' `server_port` INT(10) NOT NULL,' . ' `request_uri` CHAR(255) NOT NULL,' . ' `post` TEXT NOT NULL,' . ' `http_referer` CHAR(255) NULL DEFAULT NULL,' . ' `http_user_agent` TEXT NOT NULL,' . ' `user` INT(11) NULL DEFAULT NULL,' . ' `thrown` BIT(1) NOT NULL,' . ' PRIMARY KEY (`ID`)' . ');');
     //write data as trasaction
     $con->exec('begin transaction');
     set_time_limit(30);
     $res = \SYSTEM\SQL\SYS_LOG_MONTH::QQ(array($oldest['month'], $oldest['year']));
     while ($row = $res->next()) {
         set_time_limit(30);
         $row['time'] = array_key_exists('time_pg', $row) ? date("Y-m-d H:i:s", $row['time_pg']) : $row['time'];
         if (!$con->exec('INSERT OR IGNORE INTO ' . \SYSTEM\SQL\system_log::NAME_MYS . '(`ID`, `class`, `message`, `code`, `file`, `line`, `trace`, `ip`, `querytime`, `time`,' . ' `server_name`, `server_port`, `request_uri`, `post`,' . ' `http_referer`, `http_user_agent`, `user`, `thrown`)' . 'VALUES (' . $row['ID'] . ', \'' . \SQLite3::escapeString($row['class']) . '\', \'' . \SQLite3::escapeString($row['message']) . '\', ' . $row['code'] . ', \'' . \SQLite3::escapeString($row['file']) . '\', ' . $row['line'] . ', \'' . \SQLite3::escapeString($row['trace']) . '\', \'' . $row['ip'] . '\', ' . $row['querytime'] . ', \'' . $row['time'] . '\', \'' . \SQLite3::escapeString($row['server_name']) . '\', ' . ($row['server_port'] ? $row['server_port'] : 'NULL') . ', \'' . \SQLite3::escapeString($row['request_uri']) . '\', \'' . \SQLite3::escapeString($row['post']) . '\', \'' . \SQLite3::escapeString($row['http_referer']) . '\', \'' . \SQLite3::escapeString($row['http_user_agent']) . '\', ' . ($row['user'] ? $row['user'] : '******') . ',' . true . ');')) {
             new \SYSTEM\LOG\ERROR('failed to insert into log archiev');
             return cronstatus::CRON_STATUS_FAIL;
         }
         //Delete single
         if (!\SYSTEM\SQL\SYS_LOG_DEL::QI(array($row['ID']))) {
             new \SYSTEM\LOG\ERROR('failed to delete log entries');
             return cronstatus::CRON_STATUS_FAIL;
         }
     }
     set_time_limit(30);
     if (!$con->exec('end transaction')) {
         new \SYSTEM\LOG\ERROR('failed to insert into log archiev');
         return cronstatus::CRON_STATUS_FAIL;
     }
     return cronstatus::CRON_STATUS_SUCCESFULLY;
 }
Exemplo n.º 7
0
 public static function getGitInfo()
 {
     \LIB\lib_git::php();
     $result = array('git_project' => '', 'git_system' => '');
     try {
         $repo = \GIT\Git::open(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEPATH));
         $result['git_project'] = '<a href="http://www.mojotrollz.eu/git/hosting/commit/' . $repo->run('rev-parse HEAD') . '" target="_blank">' . $repo->run('rev-parse --short HEAD') . '</a><br/>';
         $result['git_project'] .= $repo->run('log -1 --pretty=%B');
     } catch (\Exception $ex) {
         $result['git_project'] = $ex->getMessage();
     }
     try {
         $repo = \GIT\Git::open(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEPATH) . \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_SYSTEMPATHREL));
         $result['git_system'] .= '<li>';
         $result['git_system'] = '<a href="http://www.mojotrollz.eu/git/system/commit/' . $repo->run('rev-parse HEAD') . '" target="_blank">' . $repo->run('rev-parse --short HEAD') . '</a><br/>';
         $result['git_system'] .= $repo->run('log -1 --pretty=%B');
     } catch (\Exception $ex) {
         $result['git_system'] = $ex->getMessage();
     }
     return $result;
 }
Exemplo n.º 8
0
 public static function getURL($cat, $id = null)
 {
     return \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL) . 'api.php?call=files&cat=' . $cat . '&id=' . $id;
 }
Exemplo n.º 9
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_stats_name_basic_querytime($filter, $db)
 {
     $result = array();
     if (!$db) {
         $result = \SYSTEM\SQL\SYS_SAIMOD_LOG_BASIC_QUERYTIME::QA(array($filter));
     } else {
         $con = new \SYSTEM\DB\Connection(new \SYSTEM\DB\DBInfoSQLite(\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CRON_LOG2SQLITE_PATH) . $db));
         $res = $con->prepare('basic_querytime', 'SELECT datetime(strftime("%s",' . \SYSTEM\SQL\system_log::FIELD_TIME . ') - strftime("%s",' . \SYSTEM\SQL\system_log::FIELD_TIME . ')%:filter,"unixepoch", "localtime")  as day,' . 'count(*) as count,' . 'avg(' . \SYSTEM\SQL\system_log::FIELD_QUERYTIME . ') as querytime_avg,' . 'max(' . \SYSTEM\SQL\system_log::FIELD_QUERYTIME . ') as querytime_max,' . 'min(' . \SYSTEM\SQL\system_log::FIELD_QUERYTIME . ') as querytime_min' . ' FROM ' . \SYSTEM\SQL\system_log::NAME_MYS . ' GROUP BY day' . ' ORDER BY day DESC' . ' LIMIT 30;', array(':filter' => $filter));
         while ($row = $res->next()) {
             $result[] = $row;
         }
     }
     return \SYSTEM\LOG\JsonResult::toString($result);
 }
Exemplo n.º 10
0
 protected static function startSession()
 {
     if (!isset($_SESSION) && !headers_sent()) {
         \session_start();
     }
     //respect locale from db if not set(right place here?)
     if (isset($_SESSION[\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL)]) && $_SESSION[\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL)] instanceof User) {
         $_SESSION['values'][\SYSTEM\locale::SESSION_KEY] = $_SESSION[\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL)]->locale;
     }
 }
Exemplo n.º 11
0
 public function __construct($subpath = '')
 {
     parent::__construct(new \SYSTEM\PROOT(), \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_SYSTEMPATHREL), $subpath);
 }
Exemplo n.º 12
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_edittext($id, $lang)
 {
     $langs = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS);
     $vars = \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_SAI_TEXT);
     $vars['tabopts'] = '';
     foreach ($langs as $l) {
         $vars2 = array();
         $vars2['id'] = $id;
         $vars2['lang'] = $l;
         $vars2['default'] = $l == $lang ? 'menu_lang_default' : '';
         $vars['tabopts'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_text/tpl/tabopt2.tpl'))->SERVERPATH(), $vars2);
     }
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_text/tpl/saimod_sys_text_edit_langs.tpl'))->SERVERPATH(), $vars);
 }
Exemplo n.º 13
0
 public static function get_adv($id, $lang = NULL, $fallback = true)
 {
     if ($lang == NULL) {
         $lang = \SYSTEM\locale::get();
     }
     if (!\SYSTEM\locale::isLang($lang)) {
         throw new \Exception("The requested language is not supported: " . $lang);
     }
     $res = \SYSTEM\SQL\SYS_TEXT_GET_ID_ADV::Q1(array($id, $lang));
     if ($fallback && !$res && $lang != \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG)) {
         new \SYSTEM\LOG\WARNING('Text with id: ' . $id . ' not found for lang: ' . $lang . ' - fallback to default lang.');
         return self::get_adv($id, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG));
     }
     return $res;
 }
Exemplo n.º 14
0
 public static function include_ResultShortcut()
 {
     require_once \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_SYSTEMPATHREL) . '/log/register_result_shortcut.php';
 }