Ejemplo n.º 1
0
 /**
  *  输出调试结果,debug用
  *
  */
 protected function debug($data = '')
 {
     if (DEBUG_MODE) {
         if (1 == DEBUG_MODE) {
             if (!is_string($data)) {
                 print_r($data);
             } else {
                 echo $data;
             }
             echo '<br />#----------------------------------------------------------------------------------------------------------------------------#<br />';
             echo hg_page_debug();
         } else {
             hg_mkdir(LOG_DIR);
             hg_debug_tofile($data, 1, LOG_DIR . 'debug.txt');
         }
     }
 }
Ejemplo n.º 2
0
 public function state_info()
 {
     $return = array();
     $runtime = $this->mRuntime['runstate'];
     $setruntime = $this->mSettime['runstate'] ? $this->mSettime['runstate'] : 43200;
     if (time() - $runtime > $setruntime) {
         $curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
         $curl->setSubmitType('post');
         $curl->setCurlTimeOut(5);
         $curl->setReturnFormat('json');
         $ret = $curl->request('applications.php');
         $instlled_apps = array();
         $app_stats = array();
         if (is_array($ret)) {
             foreach ($ret as $v) {
                 $start_time = microtime();
                 $result = $this->check_status($v);
                 $v['runtime'] = hg_page_debug($start_time);
                 $v['inited'] = $result[1]['define']['INITED_APP'];
                 $v['debuged'] = $result[1]['debuged'];
                 $v['http_code'] = $result[0]['http_code'];
                 $v['db'] = $result[1]['db'];
                 $v['dbconnected'] = $result[1]['dbconnected'];
                 $v['connect_time'] = $result[1]['connect_time'];
                 $v['ip'] = gethostbyname($v['host']);
                 $v['db']['ip'] = gethostbyname($v['db']['host']);
                 $v['api_dir'] = $result[1]['api_dir'];
                 $v['config_file_purview'] = $result[1]['config_file_purview'];
                 $v['data_file_purview'] = $result[1]['data_file_purview'];
                 $v['cache_file_purview'] = $result[1]['cache_file_purview'];
                 $v['freespace'] = $result[1]['freespace'];
                 $app_stats[$v['bundle']] = $v;
             }
         }
         if ($this->settings['App_livmedia']) {
             $curl = new curl($this->settings['App_livmedia']['host'], $this->settings['App_livmedia']['dir'] . 'admin/');
             $curl->setErrorReturn('');
             $curl->setCurlTimeOut(5);
             $curl->mAutoInput = false;
             $curl->initPostData();
             $curl->addRequestData('a', 'stats');
             $vod_status = $curl->request('vod.php');
             $vod_status = $vod_status[0];
         }
         $return['appstate'] = $app_stats;
         $return['vodstate'] = $vod_status;
         $this->mRuntime['runstate'] = time();
     }
     $runtime = $this->mRuntime['livedata'];
     $setruntime = $this->mSettime['livedata'] ? $this->mSettime['livedata'] : 7200;
     if (time() - $runtime > $setruntime && $this->settings['App_live']) {
         $curl = new curl($this->settings['App_live']['host'], $this->settings['App_live']['dir']);
         $curl->setErrorReturn('');
         $curl->setCurlTimeOut(5);
         $curl->mAutoInput = false;
         $curl->initPostData();
         $curl->addRequestData('a', 'show');
         $channel = $curl->request('channel.php');
         $channels = array();
         if ($channel) {
             foreach ($channel as $c) {
                 $channel_stream = array();
                 if ($c['channel_stream']) {
                     foreach ($c['channel_stream'] as $s) {
                         $channel_stream[] = $s['m3u8'];
                     }
                 }
                 $channels[] = array('name' => $c['name'], 'code' => $c['code'], 'is_audio' => $c['is_audio'], 'time_shift' => $c['time_shift'], 'status' => $c['status'], 'channel_stream' => $channel_stream);
             }
             $return['channel'] = $channels;
         }
         $this->mRuntime['livedata'] = time();
     }
     return $return;
 }
Ejemplo n.º 3
0
 /**
  * 输出结果
  *
  */
 protected function output()
 {
     //$this->header(200);
     if ('xml' == $this->mType) {
         $content_type = 'Content-Type:text/' . $this->mType . '; charset=' . $this->mCharset;
         $this->mData = $this->xmlClean($this->mData);
         $output = '<?xml version="1.0" encoding="' . $this->mCharset . '"?>';
         $output .= '<' . $this->mRootNode . '>';
         $output .= $this->mData;
         if (DEBUG_MODE) {
             $output .= '<Debug>' . hg_page_debug() . '</Debug>';
         }
         $output .= '</' . $this->mRootNode . '>';
     } else {
         $content_type = 'Content-Type:text/plain';
         if (count($this->mData) == 1) {
             //$this->mData = $this->mData[0];
         }
         if ($this->input['ikey']) {
             $data[$this->input['ikey']] = $this->mData;
         } else {
             $data = $this->mData;
         }
         $output = json_encode($data);
     }
     if (!$this->input['callback']) {
         header($content_type);
         echo $output;
     } else {
         header('Content-Type: text/javascript');
         echo $this->input['callback'] . '(' . $output . ');';
     }
     exit;
 }
Ejemplo n.º 4
0
 public function show()
 {
     include ROOT_DIR . 'lib/class/cron.class.php';
     $crond = new crond();
     if ($this->settings['croncmd']) {
         $crond->setCronCmd($this->settings['croncmd']);
     }
     $cron_status = $crond->isRun();
     $curl = new curl($this->settings['verify_custom_api']['host'], $this->settings['verify_custom_api']['dir']);
     $curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
     $curl->setToken('');
     $curl->setCurlTimeOut(5);
     $curl->setErrorReturn('');
     $curl->mAutoInput = false;
     $curl->initPostData();
     $postdata = array('a' => 'get_user_info');
     foreach ($postdata as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $license = $curl->request('get_access_token.php');
     if (!$license) {
         $this->ReportError('未获取到授权信息,请确认服务器网络正常或联系软件提供商');
     }
     if ($license['ErrorCode'] == 'APP_AUTH_EXPIRED') {
         $this->ReportError('授权已到期,请联系软件提供商');
     }
     $license = $license[0];
     if ($license['appid']) {
         $license['expire'] = date('Y-m-d', $license['expire_time']);
         $license['leftday'] = intval(($license['expire_time'] - TIMENOW) / 86400);
         $this->tpl->addVar('license', $license);
     }
     $curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
     $curl->setSubmitType('post');
     $curl->setCurlTimeOut(5);
     $curl->setReturnFormat('json');
     $ret = $curl->request('applications.php');
     $instlled_apps = array();
     $app_stats = array();
     if (is_array($ret)) {
         foreach ($ret as $v) {
             $start_time = microtime();
             $result = $this->check_status($v);
             $v['runtime'] = hg_page_debug($start_time);
             $v['inited'] = $result[1]['define']['INITED_APP'];
             $v['debuged'] = $result[1]['debuged'];
             $v['http_code'] = $result[0]['http_code'];
             $v['db'] = $result[1]['db'];
             $v['dbconnected'] = $result[1]['dbconnected'];
             $v['connect_time'] = $result[1]['connect_time'];
             $v['ip'] = gethostbyname($v['host']);
             $v['db']['ip'] = gethostbyname($v['db']['host']);
             $v['api_dir'] = $result[1]['api_dir'];
             $v['config_file_purview'] = $result[1]['config_file_purview'];
             $v['data_file_purview'] = $result[1]['data_file_purview'];
             $v['cache_file_purview'] = $result[1]['cache_file_purview'];
             $v['freespace'] = $result[1]['freespace'];
             if ($v['bundle'] == $_GET['b']) {
                 print_r($v);
                 exit;
             }
             $app_stats[$v['bundle']] = $v;
         }
     }
     if ($this->settings['App_livmedia']) {
         $curl = new curl($this->settings['App_livmedia']['host'], $this->settings['App_livmedia']['dir'] . 'admin/');
         $curl->setErrorReturn('');
         $curl->setCurlTimeOut(30);
         $curl->mAutoInput = false;
         $curl->initPostData();
         $curl->addRequestData('a', 'stats');
         $vod_status = $curl->request('vod.php');
         $vod_status = $vod_status[0];
     }
     $this->tpl->addVar('app_stats', $app_stats);
     $this->tpl->addVar('vod_status', $vod_status);
     $this->tpl->addVar('cron_status', $cron_status);
     $this->tpl->outTemplate('stats');
 }