Exemplo n.º 1
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');
     }
 }
Exemplo n.º 2
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_cron()
 {
     $vars['content'] = '';
     $vars['last_visit'] = \SYSTEM\time::time_ago_string(strtotime(\SYSTEM\CRON\cron::last_visit()));
     $res = \SYSTEM\SQL\SYS_SAIMOD_CRON::QQ();
     $i = 0;
     while ($r = $res->next()) {
         $r['selected_0'] = $r['selected_1'] = $r['selected_2'] = $r['selected_3'] = '';
         $r['next'] = date('Y-m-d H:i:s', \SYSTEM\CRON\cron::next($r['class']));
         $r['selected_' . $r['status']] = 'selected';
         $r['i'] = $i++;
         $vars['content'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_cron/tpl/list_entry.tpl'))->SERVERPATH(), $r);
     }
     $vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_SAI_CRON), \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_TIME));
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_cron/tpl/tabs.tpl'))->SERVERPATH(), $vars);
 }
 public static function CALL(\Exception $E, $thrown)
 {
     try {
         if (\property_exists(get_class($E), 'logged') && $E->logged) {
             return false;
         }
         //alrdy logged(this prevents proper thrown value for every system exception)
         $result = \SYSTEM\SQL\SYS_LOG_INSERT::QI(array(get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(), getenv('REMOTE_ADDR'), round(microtime(true) - \SYSTEM\time::getStartTime(), 5), $_SERVER["SERVER_NAME"], $_SERVER["SERVER_PORT"], $_SERVER['REQUEST_URI'], serialize($_POST), array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null, array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null, ($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0));
         if (\property_exists(get_class($E), 'logged')) {
             $E->logged = true;
         }
         //we just did log
     } catch (\Exception $E) {
         //Dump the Error
         echo \SYSTEM\LOG\JsonResult::toString((array) $E);
         return false;
     }
     //Error -> Ignore
     return false;
     //We just log and do not handle the error!
 }
Exemplo n.º 4
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_filter($filter = "%", $search = "%", $page = 0)
 {
     $filter = str_replace('\\', '\\\\', $filter);
     $count = \SYSTEM\SQL\SYS_SAIMOD_LOG_FILTER_COUNT::Q1(array($filter, $search, $search, $search))['count'];
     $vars = array();
     $vars['filter'] = $filter;
     $vars['search'] = $search;
     $vars['page'] = $page;
     $res = \SYSTEM\SQL\SYS_SAIMOD_LOG_FILTER::QQ(array($filter, $search, $search, $search));
     $vars['table'] = '';
     $count_filtered = 0;
     $res->seek(100 * $page);
     while (($r = $res->next()) && $count_filtered < 100) {
         $r['class_row'] = self::tablerow_class($r['class']);
         $r['time'] = \SYSTEM\time::time_ago_string(strtotime($r['time']));
         $r['message'] = htmlspecialchars(substr($r['message'], 0, 255));
         $r['request_uri'] = htmlspecialchars($r['request_uri']);
         $vars['table'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_log/tpl/saimod_sys_log_table_row.tpl'))->SERVERPATH(), $r);
         $count_filtered++;
     }
     $vars['pagination'] = '';
     $vars['page_last'] = ceil($count / 100) - 1;
     for ($i = 0; $i < ceil($count / 100); $i++) {
         $data = array('page' => $i, 'search' => $search, 'filter' => $filter, 'active' => $i == $page ? 'active' : '');
         $vars['pagination'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_log/tpl/saimod_sys_log_pagination.tpl'))->SERVERPATH(), $data);
     }
     $vars['count'] = $count_filtered . '/' . $count;
     $vars['error_filter'] = '';
     $res = \SYSTEM\SQL\SYS_SAIMOD_LOG_FILTERS::QQ();
     while ($row = $res->next()) {
         $data = array('active' => $filter == $row['class'] ? 'active' : '', 'filter' => $row['class'], 'search' => $search);
         $vars['error_filter'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_log/tpl/saimod_sys_log_error_filter.tpl'))->SERVERPATH(), $data);
     }
     $vars['active'] = $filter == '%' ? 'active' : '';
     $vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_SAI_LOG));
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_log/tpl/saimod_sys_log_filter.tpl'))->SERVERPATH(), $vars);
 }
Exemplo n.º 5
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_security_action_users($filter = "all", $search = "%", $page = 0)
 {
     $count = $filter == "all" ? \SYSTEM\SQL\SYS_SAIMOD_SECURITY_USER_COUNT::Q1(array($search, $search))['count'] : \SYSTEM\SQL\SYS_SAIMOD_SECURITY_USER_COUNT_FILTER::Q1(array($search, $search, $filter))['count'];
     $vars = array();
     $vars['filter'] = $filter;
     $vars['search'] = $search;
     $vars['page'] = $page;
     $vars['table'] = '';
     $res = $filter == "all" ? \SYSTEM\SQL\SYS_SAIMOD_SECURITY_USERS::QQ(array($search, $search)) : \SYSTEM\SQL\SYS_SAIMOD_SECURITY_USERS_FILTER::QQ(array($search, $search, $filter));
     $count_filtered = 0;
     $res->seek(100 * $page);
     while (($r = $res->next()) && $count_filtered < 100) {
         $r['class'] = self::tablerow_class($r['last_active']);
         $r['time_elapsed'] = \SYSTEM\time::time_ago_string($r['last_active']);
         $vars['table'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_security/tpl/saimod_sys_security_user.tpl'))->SERVERPATH(), $r);
         $count_filtered++;
     }
     $vars['pagination'] = '';
     $vars['page_last'] = ceil($count / 100) - 1;
     for ($i = 0; $i < ceil($count / 100); $i++) {
         $data = array('page' => $i, 'search' => $search, 'filter' => $filter, 'active' => $i == $page ? 'active' : '');
         $vars['pagination'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_security/tpl/saimod_sys_security_pagination.tpl'))->SERVERPATH(), $data);
     }
     $vars['count'] = $count_filtered . '/' . $count;
     $vars['right_filter'] = '';
     $res = \SYSTEM\SQL\SYS_SAIMOD_SECURITY_RIGHTS::QQ();
     while ($row = $res->next()) {
         $data = array('active' => $filter == $row['ID'] ? 'active' : '', 'filter' => $row['ID'], 'search' => $search, 'name' => $row['name']);
         $vars['right_filter'] .= \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_security/tpl/saimod_sys_security_right_filter.tpl'))->SERVERPATH(), $data);
     }
     $vars['active'] = $filter == 'all' ? 'active' : '';
     $vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\SQL\system_text::TAG_SAI_SECURITY));
     return \SYSTEM\PAGE\replace::replaceFile((new \SYSTEM\PSAI('modules/saimod_sys_security/tpl/saimod_sys_security_users.tpl'))->SERVERPATH(), $vars);
 }
Exemplo n.º 6
0
 public static function _start_time()
 {
     \SYSTEM\time::start();
 }
Exemplo n.º 7
0
 public static function exception(\Exception $E, $thrown, $type = \SYSTEM\SQL\system_todo::FIELD_TYPE_EXCEPTION)
 {
     try {
         if (\property_exists(get_class($E), 'todo_logged') && $E->todo_logged) {
             return false;
         }
         //alrdy logged(this prevents proper thrown value for every system exception)
         \SYSTEM\SQL\SYS_SAIMOD_TODO_EXCEPTION_INSERT::Q1(array(get_class($E), $E->getMessage(), $E->getCode(), $E->getFile(), $E->getLine(), $E->getTraceAsString(), getenv('REMOTE_ADDR'), round(microtime(true) - \SYSTEM\time::getStartTime(), 5), date('Y-m-d H:i:s', microtime(true)), $_SERVER["SERVER_NAME"], $_SERVER["SERVER_PORT"], $_SERVER['REQUEST_URI'], serialize($_POST), array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : null, array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : null, ($user = \SYSTEM\SECURITY\Security::getUser()) ? $user->id : null, $thrown ? 1 : 0, $E->getMessage(), $type));
         if (\property_exists(get_class($E), 'logged')) {
             $E->todo_logged = true;
         }
         //we just did log
     } catch (\Exception $E) {
         return false;
     }
     //Error -> Ignore
     return false;
     //We just log and do not handle the error!
 }