public function update()
 {
     $id = intval($this->input['id'] ? $this->input['id'] : 0);
     $info = array('name' => trim($this->input['name']) ? trim($this->input['name']) : '', 'host' => trim($this->input['host']) ? trim($this->input['host']) : '', 'port' => intval($this->input['port']) ? intval($this->input['port']) : 0, 'is_open' => intval($this->input['is_open']) ? intval($this->input['is_open']) : 0, 'update_time' => TIMENOW);
     if (empty($id)) {
         $this->errorOutput('请传入更新的服务器ID');
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "time_shift_server WHERE id=" . $id;
     $f = $this->db->query_first($sql);
     if (empty($f)) {
         $this->errorOutput('此服务配置已不存在');
     }
     if (empty($info['name'])) {
         $this->errorOutput('请传入服务器名');
     }
     if (empty($info['host'])) {
         $this->errorOutput('请传入服务器host');
     }
     $time_shift_server = array('protocol' => 'http://', 'host' => $info['host'], 'port' => $info['port']);
     $server_url = $time_shift_server['protocol'] . $time_shift_server['host'] . ($time_shift_server['port'] ? ':' . $time_shift_server['port'] : '');
     if (!check_shift_server($server_url)) {
         $this->errorOutput('连不上服务器,请检查主机与端口是否正确');
     }
     //此处更新时移服务器上面的目录配置
     $this->update_time_shift_server_dir($time_shift_server);
     $ret = $this->obj->update($id, $info);
     if (empty($ret)) {
         $this->errorOutput('数据更新有误!');
     }
     $this->addLogs('更新时移服务配置', $f, $ret, $ret['name']);
     $this->addItem($ret);
     $this->output();
 }
Example #2
0
 public function show($condition = '', $orderby = '', $data_limit = '')
 {
     $sql = "SELECT * FROM " . DB_PREFIX . "time_shift_server WHERE 1 " . $condition . $orderby . $data_limit;
     $q = $this->db->query($sql);
     $info = array();
     while ($row = $this->db->fetch_array($q)) {
         $row['url'] = 'http://' . $row['host'] . ($row['port'] ? ':' . $row['port'] : '');
         $row['isSuccess'] = check_shift_server($row['url']);
         //获取版本号
         $version = $this->get_version($row['url'] . '/?action=GET_VERSION');
         $version['version'] ? $row['version'] = $version['version'] : ($row['version'] = '未获取版本号');
         $info[] = $row;
     }
     return $info;
 }
Example #3
0
 private function get_time_shift_server()
 {
     //查询出数据库中打开的服务器
     $sql = " SELECT * FROM " . DB_PREFIX . "time_shift_server WHERE is_open = 1";
     $q = $this->db->query($sql);
     $server = array();
     while ($r = $this->db->fetch_array($q)) {
         $url = 'http://' . $r['host'] . ($r['port'] ? ':' . $r['port'] : '');
         if (check_shift_server($url)) {
             $server[$r['id']] = $r;
         }
     }
     return $server;
 }