Example #1
0
 public function update()
 {
     Log::Write(serialize($_POST));
     $result = posi_update(json_decode($_POST['posi'], true));
     if ($result) {
         return array('result' => 1, 'content' => '');
     } else {
         return array('result' => 0, 'content' => '无权限写入数据本地配置文件');
     }
 }
Example #2
0
 /**
  *  请求 POST
  * @return type
  */
 private function request()
 {
     $ret = '';
     $ispost = FALSE;
     if (!YApp::getConfig('YUC_CODE_IS_LOCAL')) {
         $ispost = TRUE;
         $client_back = $this->doPost();
         $cfg = $client_back['content'];
         $c_status = $client_back['status'];
         YLog::Write(var_export($cfg, TRUE), YLog::DEBUG);
     } else {
         YucMonitor::report("REPORT_0001");
         $cfg['result']['code'] = 'O_CODELOCAL_001';
         $cfg['result']['details'] = '强制被本地化处理!';
         YLog::Write('强制本地化验证码', YLog::DEBUG);
     }
     if (!YApp::getConfig('YUC_CODE_IS_LOCAL') && $c_status == 200 && is_array($cfg) && isset($cfg['service']['type']) && $cfg['service']['type'] == 1) {
         YLog::Write('远程响应正常,开始处理远程服务!', YLog::DEBUG);
         $this->_comparam->createdFromArray($cfg['config']);
         $this->_comparam->createdFromArray($cfg['picserver']);
         $this->_comparam->createdFromArray($cfg['session']);
         $this->_comparam->createdFromArray($cfg['position']);
         $this->_comparam->set('request_type', 1);
         $this->_comparam->set('result', returnJSON($cfg['result']));
         if (isset($cfg["reject"])) {
             $ret .= $this->_comparam->createdJsVar(json_decode($cfg["reject"]));
         }
         $ret .= $cfg["js"]["extra"];
         //远程和本地通信缓存交互
         if ($cfg['js']['cached'] === 1) {
             YLog::Write('加载本地缓存 JS Code', YLog::DEBUG);
             $ret .= $this->_local->getCachedJsCode();
         } else {
             YLog::Write('加载远程 JS Code', YLog::DEBUG);
             $ret .= $cfg['js']['jscode'];
             $this->_local->setCachedJsCode($cfg['js']['jscode']);
         }
         posi_update($cfg['update_posi']);
         //更新广告位信息
     } else {
         if ($ispost && $c_status != 200) {
             YucMonitor::report("REPORT_0002");
             YLog::Write('远程响应出现异常,开始本地服务!', YLog::DEBUG);
         } else {
             if (isset($cfg['service']['type']) && $cfg['service']['type'] == 1) {
                 YLog::Write('远程切换服务,开始本地服务!', YLog::DEBUG);
             } else {
                 YucMonitor::report("REPORT_0003");
                 YLog::Write('其它原因导致,开始本地服务!', YLog::DEBUG);
             }
         }
         $this->_comparam->set('imgsrc', '');
         $this->_comparam->set('request_type', 0);
         $this->_comparam->set('ssid', returnJSON($this->_local->getCreatedSsid()));
         $this->_comparam->set('posiid', returnJSON($this->_local->getPosiIdTeam()));
         $this->_comparam->set('show_type', returnJSON($this->_local->getShowType()));
         $this->_comparam->set('result', returnJSON($cfg['result']));
         $ret .= $this->loadJs('server.js');
         $ret .= $this->_comparam->createdJsVar(array('ssid', 'show_type', 'posiid', 'result'));
         $ret .= $this->loadJs('loadImg.js');
     }
     return $ret;
 }