='); } /* Check is xuanxuan client mode. */ if(checkXXDUA() && checkXXDVersion()) $runMode = 'xuanxuan'; define('RUN_MODE', $runMode); /* Load the framework. */ $routerFile = (RUN_MODE == 'api') ? '../framework/router.class.php' : '../framework/xuanxuan.class.php'; include $routerFile; include '../framework/control.class.php'; include '../framework/model.class.php'; include '../framework/helper.class.php'; /* Log the time and define the run mode. */ $startTime = getTime(); /* Clear cookies for api requests. */ if(RUN_MODE == 'api') $_COOKIE = array(); /* Run the app. */ if(RUN_MODE == 'api') $app = router::createApp('xxb', dirname(dirname(__FILE__))); if(RUN_MODE != 'api') $app = router::createApp('xxb', dirname(dirname(__FILE__)), 'xuanxuan'); /* Load common model. */ $common = $app->loadCommon(); /* Api mode need check entry and set default params. */ if(RUN_MODE == 'api') { $common->checkEntry(); $config->requestType = 'GET'; $config->default->view = 'json'; } /* Remove serverside cookies. */ header_remove('Set-Cookie'); /* Parse request. */ $result = $app->parseRequest(); if(RUN_MODE != 'api' && !$result) die; /* Check privilege of api. */ if(RUN_MODE == 'api') $common->checkPriv(); /* Load module. */ $app->loadModule(); /* Process api response. */ if(RUN_MODE == 'api') { $output = json_decode(ob_get_clean()); $data = new stdClass(); $data->status = isset($output->status) ? $output->status : $output->result; if(isset($output->message)) $data->message = $output->message; if(isset($output->data)) $data->data = json_decode($output->data); $output = json_encode($data); unset($_SESSION['entryCode']); unset($_SESSION['validEntry']); } /* Flush the buffer. */ echo helper::removeUTF8Bom(ob_get_clean());