示例#1
0
 private function Unser_Inner()
 {
     $orig_line = array_shift($this->Lines);
     if ($orig_line == "") {
         return null;
     }
     $type = $orig_line[0];
     $line = substr($orig_line, 2);
     if ($type == 'k' || $type == 'f' || $type == 'v') {
         $type = $line[0];
         $line = substr($line, 2);
     }
     try {
         switch ($type) {
             case 's':
                 return str_replace("\\n", "\n", $line);
             case 'i':
                 return intval($line);
             case 'a':
                 $res = array();
                 for ($i = 0; $i < $line; $i++) {
                     $key = $this->Unser_Inner();
                     $res[$key] = $this->Unser_Inner();
                 }
                 return $res;
             case 'd':
                 if (!$line) {
                     return null;
                 }
                 return new DateTime($line);
             case 'x':
                 if (!$line) {
                     return null;
                 }
                 return new DateTimeEx($line);
             case 'y':
                 return new WdfReflector($line);
             case 'z':
                 return simplexml_load_string(stripcslashes($line));
             case 'o':
                 list($id, $len, $type, $alias) = explode(':', $line);
                 $datasource = $alias ? model_datasource($alias) : null;
                 $this->Stack[$id] = new $type($datasource);
                 for ($i = 0; $i < $len; $i++) {
                     $field = $this->Unser_Inner();
                     if ($field == "") {
                         continue;
                     }
                     $this->Stack[$id]->{$field} = $this->Unser_Inner();
                 }
                 if (system_method_exists($this->Stack[$id], '__wakeup')) {
                     $this->Stack[$id]->__wakeup();
                 }
                 return $this->Stack[$id];
             case 'r':
                 if (!isset($this->Stack[intval($line)])) {
                     WdfException::Raise("Trying to reference unknown object.");
                 }
                 if ($this->Stack[intval($line)] instanceof DataSource) {
                     return model_datasource($this->Stack[intval($line)]->_storage_id);
                 }
                 return $this->Stack[intval($line)];
             case 'm':
                 return model_datasource($line);
             case 'n':
                 return null;
             case 'f':
                 return floatval($line);
             case 'b':
                 return $line == 1;
             default:
                 WdfException::Raise("Unserialize found unknown datatype '{$type}'. Line was {$orig_line}");
         }
     } catch (Exception $ex) {
         WdfException::Log($ex);
         return null;
     }
 }
示例#2
0
 protected function __fqFields(&$property)
 {
     if (!$property) {
         return;
     }
     if (!is_array($property)) {
         $property->__fqFields($this->_knownmodels);
     } else {
         foreach ($property as &$p) {
             if (system_method_exists($p, '__fqFields')) {
                 $p->__fqFields($this->_knownmodels);
             }
         }
     }
 }
示例#3
0
/**
 * Executes the current request.
 * 
 * This is the second of two essential functions.
 * It runs the actual execution. If fact it is the only place where you will
 * find an `echo` in the ScavixWDF code.
 * @return void
 */
function system_execute()
{
    session_sanitize();
    execute_hooks(HOOK_POST_INITSESSION);
    // respond to PING requests that are sended to keep the session alive
    if (Args::request('ping', false)) {
        session_keep_alive();
        execute_hooks(HOOK_PING_RECIEVED);
        die("PONG");
    }
    // respond to DEBUG requests
    if ($GLOBALS['CONFIG']['system']['ajax_debug_argument']) {
        $data = Args::request($GLOBALS['CONFIG']['system']['ajax_debug_argument'], false);
        if ($data) {
            logging_add_category("JS");
            $data = json_decode($data, true);
            if (is_array($data) && count($data) > 0) {
                log_write(Args::request('sev', ''), array_shift($data), $data);
            } else {
                log_write(Args::request('sev', ''), $data);
            }
            die('"OK"');
        }
    }
    Args::strip_tags();
    global $current_controller, $current_event;
    list($current_controller, $current_event) = system_parse_request_path();
    $current_controller = system_instanciate_controller($current_controller);
    if (!(system_method_exists($current_controller, $current_event) || system_method_exists($current_controller, '__method_exists') && $current_controller->__method_exists($current_event))) {
        $current_event = cfg_get('system', 'default_event');
    }
    if (!isset($GLOBALS['wdf_route'])) {
        $GLOBALS['wdf_route'] = array($current_controller, $current_event);
    }
    if (system_method_exists($current_controller, $current_event) || system_method_exists($current_controller, '__method_exists') && $current_controller->__method_exists($current_event)) {
        $content = system_invoke_request($current_controller, $current_event, HOOK_PRE_EXECUTE);
    } else {
        $content = '';
    }
    execute_hooks(HOOK_POST_EXECUTE);
    @set_time_limit(ini_get('max_execution_time'));
    system_exit($content, false);
}
 /**
  * @internal Checks if this class implements a method.
  * @param string $name name of the Method
  * @return bool true|false
  */
 public function __method_exists($name)
 {
     if (system_method_exists($this, $name)) {
         return true;
     }
     foreach ($this->_extender as &$ex) {
         if (system_method_exists($ex, $name)) {
             return true;
         }
     }
     return false;
 }
示例#5
0
 function __initialize($title = "", $body_class = false)
 {
     global $CONFIG;
     // sometimes state-/UI-less sites (like APIs) trickout the AJAX detection by setting this.
     // as we need UI this must be reset here
     unset($GLOBALS['result_of_system_is_ajax_call']);
     header("Content-Type: text/html; charset=utf-8");
     // overwrite previously set header to ensure we deliver HTML
     unset($CONFIG["use_compiled_js"]);
     unset($CONFIG["use_compiled_css"]);
     if (current_event(true) != 'login' && (!isset($_SESSION['admin_handler_username']) || !isset($_SESSION['admin_handler_password']) || $_SESSION['admin_handler_username'] != $CONFIG['system']['admin']['username'] || $_SESSION['admin_handler_password'] != $CONFIG['system']['admin']['password'])) {
         log_debug(current_event(true));
         log_debug($_SESSION['admin_handler_username']);
         log_debug($_SESSION['admin_handler_password']);
         redirect('sysadmin', 'login');
     }
     parent::__initialize("SysAdmin - {$title}", 'sysadmin');
     $this->_translate = false;
     if (current_event(true) != 'login') {
         $nav = parent::content(new Control('div'));
         $nav->class = "navigation";
         foreach ($CONFIG['system']['admin']['actions'] as $label => $def) {
             if (!class_exists(fq_class_name($def[0]))) {
                 continue;
             }
             $nav->content(new Anchor(buildQuery($def[0], $def[1]), $label));
         }
         $nav->content(new Anchor(buildQuery('sysadmin', 'cache'), 'Cache'));
         $nav->content(new Anchor(buildQuery('sysadmin', 'phpinfo'), 'PHP info'));
         $nav->content(new Anchor(buildQuery('translationadmin', 'newstrings'), 'Translations'));
         $nav->content(new Anchor(buildQuery('sysadmin', 'testing'), 'Testing'));
         $nav->content(new Anchor(buildQuery('', ''), 'Back to app'));
         $nav->content(new Anchor(buildQuery('sysadmin', 'logout'), 'Logout', 'logout'));
         $this->_subnav = parent::content(new Control('div'));
     }
     $this->_contentdiv = parent::content(new Control('div'))->addClass('content');
     $copylink = new Anchor('http://www.scavix.com', '&#169; 2012-' . date('Y') . ' Scavix&#174; Software Ltd. &amp; Co. KG');
     $copylink->target = '_blank';
     $footer = parent::content(new Control('div'))->addClass('footer');
     $footer->content("<br class='clearer'/>");
     $footer->content($copylink);
     if (current_event() == strtolower($CONFIG['system']['default_event']) && !system_method_exists($this, current_event())) {
         redirect('sysadmin', 'index');
     }
 }