Пример #1
0
    function adminCore()
    {
        define('PHP_SELF', dirname($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']));
        parent::kernel();
        if (file_exists(BASE_DIR . '/upgrade.php')) {
            if ($_GET['_ajax']) {
                $url = 'index.php';
                $output = <<<EOF
<script>
        var href = top.location.href;
        var pos = href.indexOf('#') + 1;
        window.location.href="{$url}"+(pos ? ('&return='+encodeURIComponent(href.substr(pos))) : '');
</script>
EOF;
                echo $output;
                exit;
            }
            $upgrade = $this->loadModel('system/upgrade');
            $upgrade->exec($_GET['act']);
        } elseif ($_GET['ctl'] == 'upgrade') {
            header('Location: index.php');
        } else {
            $this->run();
        }
    }
Пример #2
0
 function __construct()
 {
     error_reporting(E_ALL ^ E_NOTICE);
     if (isset($_POST['dbname'], $_POST['dbuser'], $_POST['dbhost'], $_POST['data'])) {
         $this->install_mode = 'service';
         if (file_exists('../config/install.lock')) {
             $this->service_install_res('false', 'Access denied by install.lock');
         }
         $_POST['uname'] = $_POST['dbuser'];
         $_POST['pwd'] = $_POST['dbpass'];
         $_POST['prefix'] = $_POST['prefix'] ? $_POST['prefix'] : 'sdb_';
         $_POST['use_demo'] = $_POST['data'] == 'true' ? true : false;
         $_POST['stimezone'] = $_POST['stimezone'] ? $_POST['stimezone'] : 8;
         parent::kernel();
         $this->service_install_mode();
     }
     if (file_exists('../config/install.lock')) {
         $this->responseCode('403');
         echo 'Access denied by install.lock';
         exit;
     } else {
         parent::kernel();
         $this->checkPerm();
         $this->run();
     }
 }
Пример #3
0
 function shopCore()
 {
     parent::kernel();
     if (isset($_GET['_test_rewrite'])) {
         echo '[*[' . md5($_GET['s']) . ']*]';
         exit;
     }
     if (defined('MODE_SWITCHER')) {
         $mode_switcher = MODE_SWITCHER;
         require_once PLUGIN_DIR . '/functions/' . $switcher . '.php';
         $switcher = new $mode_switcher();
         if (!$switcher->test()) {
             header('Content-type: text/html;charset=utf-8', true, 503);
             readfile(HOME_DIR . '/notice.html');
         }
     } elseif (file_exists(HOME_DIR . '/notice.html')) {
         header('Content-type: text/html;charset=utf-8', true, 503);
         readfile(HOME_DIR . '/notice.html');
         exit;
     }
     if (file_exists(BASE_DIR . '/upgrade.php')) {
         header('HTTP/1.1 503 Service Unavailable', true, 503);
         require CORE_DIR . '/func_ext.php';
         $smarty =& $this->loadModel('system/frontend');
         $smarty->display('shop:common/upgrade.html');
     } else {
         $this->run();
     }
 }
Пример #4
0
 function shop_api()
 {
     error_reporting(E_USER_ERROR | E_ERROR | E_USER_WARNING);
     $api_error = set_error_handler(array(&$this, "apiErrorHandle"));
     parent::kernel();
     $this->magic = get_magic_quotes_gpc();
     $method = (include CORE_DIR . '/api/include/api_link.php');
     $apiversion = $_POST['api_version'];
     if ($method[$_POST['act']][$_POST['api_version']]) {
         $callmethod = $method[$_POST['act']][$_POST['api_version']];
     } else {
         if ($method[$_POST['act']]) {
             if ($apiversion = $this->api_version_compare($method[$_POST['act']], $_POST['api_version'])) {
                 $callmethod = $method[$_POST['act']][$apiversion];
             }
         }
     }
     if (!$method[$_POST['act']]) {
         $this->error_handle('missing method');
     } else {
         if (!$method[$_POST['act']][$apiversion]['n_varify'] && !$this->verfy($_POST)) {
             $this->error_handle('veriy fail');
         } else {
             if ($ctl = $callmethod['ctl']) {
                 include CORE_DIR . '/' . dirname($ctl) . '/' . $apiversion . '/' . basename($ctl) . '.php';
                 $ctl = basename($ctl);
                 $action = new $ctl();
                 $callmethod = $method[$_POST['act']][$apiversion];
                 if ($_POST['return_data']) {
                     $action->data_format = strtolower($_POST['return_data']);
                 }
                 if (strpos(" " . $_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) {
                     $action->gzip = true;
                 }
                 $action->verify_data($_POST, $callmethod);
                 $action->{$callmethod}['act']($_POST);
             } else {
                 $this->error_handle('service error', 'serice not this method');
             }
         }
     }
     echo 't';
     exit;
     restore_error_handler();
 }
Пример #5
0
 function __construct()
 {
     parent::kernel();
     if (file_exists('../config/install.lock') && !in_array($_GET['step'], array('active', 'complete'))) {
         $this->service_install_res('false', 'Access denied by install.lock');
     }
     if (isset($_POST['dbname'], $_POST['dbuser'], $_POST['dbhost'], $_POST['data'])) {
         error_reporting(E_ALL ^ E_NOTICE);
         $this->install_mode = 'service';
         $_POST['uname'] = $_POST['dbuser'];
         $_POST['pwd'] = $_POST['dbpass'];
         $_POST['prefix'] = $_POST['prefix'] ? $_POST['prefix'] : 'sdb_';
         $_POST['use_demo'] = $_POST['data'] == 'true' ? true : false;
         $_POST['stimezone'] = $_POST['stimezone'] ? $_POST['stimezone'] : 8;
         $this->service_install_mode();
     }
     $this->checkPerm();
     $this->run();
 }
Пример #6
0
 public function shopCore()
 {
     parent::kernel();
     $this->db = $this->database();
     global $switcher;
     if (isset($_GET['_test_rewrite'])) {
         echo "[*[" . md5($_GET['s']) . "]*]";
         exit;
     } else {
         if (defined("MODE_SWITCHER")) {
             $mode_switcher = MODE_SWITCHER;
             require_once PLUGIN_DIR . "/functions/" . $switcher . ".php";
             $switcher = new $mode_switcher();
             if (!$switcher->test()) {
                 header("Content-type: text/html;charset=utf-8", true, 503);
                 readfile(HOME_DIR . "/notice.html");
             }
         } else {
             if (file_exists(HOME_DIR . "/notice.html")) {
                 header("Content-type: text/html;charset=utf-8", true, 503);
                 readfile(HOME_DIR . "/notice.html");
                 exit;
             }
         }
     }
     //        if (file_exists(BASE_DIR . "/upgrade.php")) {
     //            header("HTTP/1.1 503 Service Unavailable", true, 503);
     //            require(CORE_DIR . "/func_ext.php");
     //            $smarty =& $this->loadModel("system/frontend");
     //            $smarty->display("shop:common/upgrade.html");
     //        } else
     if ($_POST['api_url'] == "time_auth") {
         require CORE_INCLUDE_DIR . "/shop/core.time_auth.php";
         core_time_auth($this);
     } else {
         $this->run();
     }
 }
Пример #7
0
 function tools()
 {
     parent::kernel();
     $this->system =& $GLOBALS['system'];
     $this->db =& $this->system->database();
 }
Пример #8
0
 function crontab()
 {
     parent::kernel();
     $this->run();
 }
Пример #9
0
 function shop_api()
 {
     error_log(var_export($_REQUEST, 1), 3, dirname(__FILE__) . '/request.log');
     error_reporting(E_USER_ERROR | E_ERROR | E_USER_WARNING);
     set_error_handler(array(&$this, "apiErrorHandle"));
     parent::kernel();
     $this->magic = get_magic_quotes_gpc();
     if (!($apiAct = $_REQUEST['act'])) {
         $this->error_handle('missing method');
     }
     if (isset($_REQUEST['appname'])) {
         $appName = $_REQUEST['appname'];
     } elseif (strpos($apiAct, ':') > 0) {
         // request plugin api
         list($appName, $apiAct) = explode(':', $apiAct);
     } elseif (0 === strpos($apiAct, 'shopex_')) {
         // 照顾"商品助理"
         $appName = 'goodsassistant';
     }
     if ($appName) {
         $APIs = (include PLUGIN_DIR . "/app/{$appName}/api/api_link.php");
         include CORE_DIR . '/api/shop_api_object.php';
     } else {
         // request traditional api
         $APIs = (include CORE_DIR . '/api/include/api_link.php');
     }
     $APIs[$apiAct] || $this->error_handle('missing method');
     if (($apiVersion = $_REQUEST['api_version']) && $APIs[$apiAct][$apiVersion]) {
         $api = $APIs[$apiAct][$apiVersion];
     } else {
         $apiVersion = $this->api_version_compare($APIs[$apiAct]);
         $api = $APIs[$apiAct][$apiVersion];
     }
     if (!$APIs[$apiAct][$apiVersion]['n_varify'] && !$this->verify($_POST)) {
         $this->error_handle('veriy fail');
     }
     if (!$api || !($ctl = $api['ctl'])) {
         $this->error_handle('service error', 'service not this method');
     }
     if ($appName) {
         $appMgrMdl = $this->loadModel('system/appmgr');
         if (!($app = $appMgrMdl->load($appName)) || false === $app->is_active) {
             $this->error_handle('missing method');
         }
         include PLUGIN_DIR . "/app/{$appName}/api/{$apiVersion}/{$ctl}.php";
     } else {
         include CORE_DIR . '/' . dirname($ctl) . '/' . $apiVersion . '/' . basename($ctl) . '.php';
     }
     $ctl = basename($ctl);
     $act = $api['act'];
     if (!class_exists($ctl) || !($ctlObj = new $ctl()) || !method_exists($ctlObj, $act)) {
         $this->error_handle('service error', 'can not service');
     }
     if ($_REQUEST['return_data']) {
         // 返回数据格式 json xml
         $ctlObj->data_format = strtolower($_REQUEST['return_data']);
     }
     if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
         $ctlObj->gzip = true;
     }
     $ctlObj->verify_data($_POST, $api);
     $ctlObj->{$act}($_POST);
     restore_error_handler();
 }
Пример #10
0
 function shopdav()
 {
     parent::kernel();
     $this->run();
 }
Пример #11
0
 function adminCore()
 {
     define('PHP_SELF', dirname($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']));
     parent::kernel();
     if (file_exists(BASE_DIR . '/upgrade.php')) {
         $upgrade = $this->loadModel('system/upgrade');
         $upgrade->exec($_GET['act']);
     } elseif ($_POST['api_url'] == 'time_auth') {
         header("Content-type:text/html;charset=utf-8");
         $this->shopex_auth = $this->loadModel('service/certificate');
         if ($this->shopex_auth->check_api()) {
             require CORE_INCLUDE_DIR . '/shop/core.time_auth.php';
             core_time_auth($this);
             exit;
         }
     } else {
         define('__ADMIN__', 'admin');
         require 'adminPage.php';
         $mod = $_GET['ctl'] ? $_GET['ctl'] : 'default';
         $act = $_GET['act'] ? $_GET['act'] : 'index';
         $this->request = array('action' => array('controller' => $mod, 'method' => $act));
         $this->request['action']['ident'] = strtolower('admin:' . $this->request['action']['controller'] . ':' . $this->request['action']['method']);
         $this->db =& $this->database();
         $this->__session_start();
         if ($_POST['_DTYPE_DATE']) {
             foreach ($_POST['_DTYPE_DATE'] as $k) {
                 $_POST[$k] = empty($_POST[$k]) ? $_POST[$k] : strtotime($_POST[$k]);
                 //php4和php5对strtotime('')的行为不一致,所以加判断
             }
             $_POST['_DTYPE_DATE'] = null;
             unset($_POST['_DTYPE_DATE']);
         }
         if ($_POST['_DTYPE_BOOL']) {
             foreach ($_POST['_DTYPE_BOOL'] as $k) {
                 $_POST[$k] = $_POST[$k] != 'false';
             }
             $_POST['_DTYPE_BOOL'] = null;
             unset($_POST['_DTYPE_BOOL']);
         }
         if ($_POST['_DTYPE_TIME']) {
             foreach ($_POST['_DTYPE_TIME'] as $k) {
                 if ($_POST[$k]) {
                     $_POST[$k] = empty($_POST[$k]) ? $_POST[$k] : strtotime($_POST[$k]);
                     //php4和php5对strtotime('')的行为不一致,所以加判断
                     if (isset($_POST['_DTIME_']['H'][$k])) {
                         $_POST[$k] += $_POST['_DTIME_']['H'][$k] * 3600 + $_POST['_DTIME_']['M'][$k] * 60;
                     }
                 }
                 unset($_POST['_DTIME_']['H'][$k], $_POST['_DTIME_']['M'][$k]);
             }
             $_POST['_DTYPE_TIME'] = null;
             unset($_POST['_DTYPE_TIME']);
         }
         /*            foreach($_POST['_DTIME_']['H'] as $t=>$h){
                         $_POST[$k] .= $h.':'.$_POST['_DTIME_']['M'][$t];
                     }*/
         unset($_POST['_DTIME_']);
         $controller =& $this->getController($mod);
         $this->ctl =& $controller;
         if (!is_object($controller)) {
             $this->responseCode(404);
             exit;
         }
         if (!$this->callAction($controller, $act, $_GET['p'])) {
             $this->responseCode(404);
             exit;
         }
     }
 }