function s_ajax_page_on_init()
 {
     if (!InPOST('__s_ajax_method')) {
         return;
     }
     $aj_method = _POST('__s_ajax_method');
     if (array_key_exists(AJ_INIT, $this->_events)) {
         foreach ($this->_events[AJ_INIT] as $method) {
             $res = call_user_func(array($this, $method), $aj_method);
             if ($this->_flow != PAGE_FLOW_NORMAL) {
                 if (isset($res)) {
                     echo "fail:{$res}";
                 }
                 $this->s_ajax_page_save_log();
                 return;
             }
         }
     }
     $this->_flow = PAGE_FLOW_BREAK;
     $method = "aj_{$aj_method}";
     if (!method_exists($this, $method)) {
         echo "fail:method {$method} not found";
         $this->s_ajax_page_save_log();
         return;
     }
     $args_array = SJson::deserialize(_POST('__s_ajax_args'));
     if (!is_array($args_array)) {
         echo "fail:fail to deserialize arguments";
         $this->s_ajax_page_save_log();
         return;
     }
     try {
         $res = call_user_func_array(array($this, $method), $args_array);
     } catch (Exception $ex) {
         echo 'fail:', $ex->getMessage();
         $this->s_ajax_page_save_log();
         return;
     }
     echo 'succ:';
     if (isset($res)) {
         echo SJson::serialize($res);
     }
     $this->s_ajax_page_save_log();
     exit;
 }
Ejemplo n.º 2
0
 public function handle_ajax($obj)
 {
     if (!InPOST('__s_ajax_method')) {
         return false;
     }
     $method = 'aj_' . _POST('__s_ajax_method');
     if (!method_exists($obj, $method)) {
         echo "fail:method {$method} not found";
         return true;
     }
     $args_array = SJson::deserialize(_POST('__s_ajax_args'));
     if (!is_array($args_array)) {
         echo "fail:fail to deserialize arguments";
         return true;
     }
     try {
         $res = call_user_func_array(array($obj, $method), $args_array);
     } catch (Exception $ex) {
         echo 'fail:', $ex->getMessage();
         return true;
     }
     echo 'succ:';
     if (isset($res)) {
         echo SJson::serialize($res);
     }
     return true;
 }
 function Process()
 {
     if (InPOST('upload')) {
         if ($this->HaxorCheck()) {
             return;
         }
         if (!$this->ErrorCheck()) {
             if ($this->TryToUploadFile()) {
                 $this->UploadComplete();
                 return;
             }
         }
     }
     $this->Render();
 }
function _POST($k, $def = "")
{
    return InPOST($k) ? $_POST[$k] : $def;
}