コード例 #1
0
ファイル: files.php プロジェクト: webcraftmedia/system
 public static function get($cat = null, $id = null, $returnasjson = false)
 {
     if (!$cat) {
         return $returnasjson ? \SYSTEM\LOG\JsonResult::toString(self::$folders) : self::$folders;
     }
     if (!array_key_exists($cat, self::$folders)) {
         throw new \SYSTEM\LOG\ERROR("No matching Cat '" . $cat . "' found.");
     }
     $folder = self::getFolder(self::$folders[$cat]);
     if ($id == null) {
         return $returnasjson ? \SYSTEM\LOG\JsonResult::toString($folder) : $folder;
     }
     if (!in_array($id, $folder)) {
         throw new \SYSTEM\LOG\ERROR("No matching ID '" . $id . "' found.");
     }
     $ext = pathinfo(self::$folders[$cat] . $id);
     $ext = strtoupper(array_key_exists('extension', $ext) ? $ext['extension'] : '');
     if (\SYSTEM\HEADER::available($ext)) {
         call_user_func('\\SYSTEM\\HEADER::' . $ext);
     } else {
         \SYSTEM\HEADER::FILE($id);
     }
     //Allow Caching for all files
     header('Cache-Control: public;');
     if (!self::file_get_contents_chunked(self::$folders[$cat] . $id, 4096, function ($chunk, &$handle, $iteration) {
         echo $chunk;
     })) {
         throw new \SYSTEM\LOG\ERROR("Could not transfere File.");
     }
     return;
 }
コード例 #2
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_files_action_upload($cat)
 {
     if (!\SYSTEM\FILES\files::put($cat, basename($_FILES['datei_' . $cat]['name']), $_FILES['datei_' . $cat]['tmp_name'])) {
         throw new \SYSTEM\LOG\ERROR("upload problem");
     }
     return \SYSTEM\LOG\JsonResult::ok();
 }
コード例 #3
0
 public static function sai_mod__system_sai_saimod_sys_cron_action_del($cls)
 {
     if (!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON)) {
         throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");
     }
     \SYSTEM\SQL\SYS_SAIMOD_CRON_DEL::QI(array($cls));
     return \SYSTEM\LOG\JsonResult::ok();
 }
コード例 #4
0
 public static function sai_mod__system_sai_saimod_sys_api_action_deletecall($ID, $group)
 {
     if (!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_API)) {
         throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");
     }
     \SYSTEM\SQL\SYS_SAIMOD_API_DEL::QI(array($ID, $group));
     return \SYSTEM\LOG\JsonResult::ok();
 }
コード例 #5
0
ファイル: setup.php プロジェクト: webcraftmedia/system
 public static function install()
 {
     $result = array();
     foreach (self::$qis as $qi) {
         $result[] = array($qi, \call_user_func(array($qi, 'QI')));
     }
     return \SYSTEM\LOG\JsonResult::toString($result);
 }
コード例 #6
0
 public static function CALL(\Exception $E, $thrown)
 {
     if ($thrown) {
         try {
             echo \SYSTEM\LOG\JsonResult::error($E);
         } catch (\Exception $E) {
         }
         //Error -> Ignore
         return die;
         //die is required cuz else some fatals cant be catched properly
     }
 }
コード例 #7
0
 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!
 }
コード例 #8
0
ファイル: cron.php プロジェクト: webcraftmedia/system
 public static function run()
 {
     $crons = \SYSTEM\SQL\SYS_CRON_LIST::QQ();
     while ($cron = $crons->next()) {
         //check module
         if (!self::check($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS])) {
             self::status($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], \SYSTEM\CRON\cronstatus::CRON_STATUS_FAIL_CLASS);
             continue;
         }
         //time to execute?
         if (!\SYSTEM\CRON\crontime::check_now(strtotime($cron[\SYSTEM\SQL\system_cron::FIELD_LAST_RUN]), $cron[\SYSTEM\SQL\system_cron::FIELD_MIN], $cron[\SYSTEM\SQL\system_cron::FIELD_HOUR], $cron[\SYSTEM\SQL\system_cron::FIELD_DAY], $cron[\SYSTEM\SQL\system_cron::FIELD_DAY_WEEK], $cron[\SYSTEM\SQL\system_cron::FIELD_MONTH])) {
             continue;
         }
         //Status is ok?
         if ($cron[\SYSTEM\SQL\system_cron::FIELD_STATUS] != \SYSTEM\CRON\cronstatus::CRON_STATUS_SUCCESFULLY) {
             new \SYSTEM\LOG\CRON('Cron for Class ' . $cron[\SYSTEM\SQL\system_cron::FIELD_CLASS] . ' could not execute cuz Status aint good: ' . \SYSTEM\CRON\cronstatus::text($cron[\SYSTEM\SQL\system_cron::FIELD_STATUS]));
             continue;
         }
         //set running
         self::status($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], \SYSTEM\CRON\cronstatus::CRON_STATUS_RUNNING);
         self::status($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], call_user_func(array($cron[\SYSTEM\SQL\system_cron::FIELD_CLASS], 'run')));
     }
     return \SYSTEM\LOG\JsonResult::ok();
 }
コード例 #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);
 }
コード例 #10
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_cache_action_clear()
 {
     return \SYSTEM\SQL\SYS_SAIMOD_CACHE_CLEAR::QI() ? \SYSTEM\LOG\JsonResult::ok() : \SYSTEM\LOG\JsonResult::fail();
 }
コード例 #11
0
 public static function sai_mod__SYSTEM_SAI_saimod_sys_text_action_delete($id, $lang = null)
 {
     return \SYSTEM\PAGE\text::delete($id, $lang) ? \SYSTEM\LOG\JsonResult::ok() : \SYSTEM\LOG\JsonResult::fail();
 }
コード例 #12
0
 public static function report($message, $data)
 {
     $_POST = $data;
     //save data in post
     self::exception(new \Exception($message), false, \SYSTEM\SQL\system_todo::FIELD_TYPE_REPORT);
     return \SYSTEM\LOG\JsonResult::ok();
 }
コード例 #13
0
ファイル: api_system.php プロジェクト: webcraftmedia/system
 public static function call_text($request, $lang)
 {
     return \SYSTEM\LOG\JsonResult::toString(\SYSTEM\locale::getStrings($request, $lang));
 }
コード例 #14
0
ファイル: State.php プロジェクト: webcraftmedia/system
 public static function get($group, $state, $returnasjson = true)
 {
     //seperate state from vars
     $state_vars = \explode(';', $state);
     //parse substates
     $state_all = \explode('(', $state_vars[0]);
     $state_name = $state_all[0];
     $substate = substr($state_vars[0], strlen($state_name));
     $substate = self::parse_substate($substate);
     //vars
     $vars = array();
     for ($i = 1; $i < count($state_vars); $i++) {
         $var = \explode('.', $state_vars[$i]);
         $vars[$var[0]] = $var[1];
     }
     $result = array();
     $res = \SYSTEM\SQL\SYS_PAGE_GROUP::QQ(array($group, $state_name));
     while ($row = $res->next()) {
         if (!self::is_loaded($row, $substate, $state_name, $row['parent_id'])) {
             continue;
         }
         if ($row['login'] == 1 && !\SYSTEM\SECURITY\Security::isLoggedIn() || $row['login'] == 2 && \SYSTEM\SECURITY\Security::isLoggedIn()) {
             continue;
         }
         $row['url'] = \SYSTEM\PAGE\replace::replace($row['url'], $vars);
         $row['url'] = \SYSTEM\PAGE\replace::clean($row['url']);
         //clean url of empty variables
         //$row['url'] = preg_replace('/&.*?=(&|$)/', '&', $row['url']);
         $row['url'] = preg_replace('/[^=&]+=(&|$)/', '&', $row['url']);
         $row['url'] = preg_replace('/&&$/', '', $row['url']);
         $row['css'] = $row['js'] = array();
         if (\class_exists($row['php_class']) && \method_exists($row['php_class'], 'css') && \is_callable($row['php_class'] . '::css')) {
             $row['css'] = array_merge($row['css'], \call_user_func($row['php_class'] . '::css'));
         }
         $row['css'] = count($row['css']) > 0 ? array(\SYSTEM\CACHE\cache_css::url($row['css'])) : array();
         if (\class_exists($row['php_class']) && \method_exists($row['php_class'], 'scss') && \is_callable($row['php_class'] . '::scss')) {
             $scss = \call_user_func($row['php_class'] . '::scss');
             foreach ($scss as $s) {
                 $row['css'][] = \SYSTEM\CACHE\cache_scss::url($s);
             }
         }
         if (\class_exists($row['php_class']) && \method_exists($row['php_class'], 'js') && \is_callable($row['php_class'] . '::js')) {
             $row['js'] = array_merge($row['js'], \call_user_func($row['php_class'] . '::js'));
         }
         $row['js'] = count($row['js']) > 0 ? array(\SYSTEM\CACHE\cache_js::url($row['js'])) : array();
         unset($row['php_class']);
         $skip = false;
         for ($i = 0; $i < count($result); $i++) {
             if ($result[$i]['div'] == $row['div']) {
                 $skip = true;
                 if ($row['type'] == 1) {
                     $result[$i] = $row;
                 }
                 break;
             }
         }
         if (!$skip) {
             $result[] = $row;
         }
     }
     return $returnasjson ? \SYSTEM\LOG\JsonResult::toString($result) : $result;
 }