Esempio n. 1
0
$curl->addRequestData('a', 'settings');
$ret = $curl->request('configuare.php');
$user_configs = array('base' => $ret['base'], 'define' => $ret['define']);
$db = $ret['db'];
$DB_PREFIX = $ret['define']['DB_PREFIX'];
$db['user'] = $this->input['dbuser'];
$db['pass'] = $_REQUEST['dbpass'];
if (!$appinfo['nodb']) {
    $link = @mysql_connect($db['host'], $db['user'], $db['pass']);
    if (!$link) {
        $message = '此数据库无法连接,请确认密码是否准确';
        $this->upgrade($message);
    }
    mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary", $link);
}
$socket = new hgSocket();
$con = $socket->connect($installinfo['host'], $installinfo['port']);
if (!intval($con)) {
    $message = '服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $installinfo['ip'] . ':' . $installinfo['port'] . '上';
    $socket->close();
    $this->upgrade($message);
}
$socket->close();
$curl->initPostData();
$curl->addRequestData('a', 'getapp_path');
$app_path = $curl->request('configuare.php');
$app_path .= '/';
$install_app = trim($this->input['app']);
$curl = new curl($this->product_server['host'] . ':' . $this->product_server['port'], '');
$curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
$curl->setSubmitType('get');
Esempio n. 2
0
 public function get_dir()
 {
     if (!$this->input['server_id'] || intval($this->input['server_id']) == -1) {
         $this->errorOutput('请选择一台服务器');
     }
     $dir = $this->input['dir'] ? $this->input['dir'] : '/';
     $sql = " SELECT * FROM " . DB_PREFIX . "server WHERE id = '" . intval($this->input['server_id']) . "'";
     $server = $this->db->query_first($sql);
     $cmd = array('action' => 'ls', 'para' => $dir, 'user' => $server['user'], 'pass' => hg_encript_str($server['password'], 0), 'charset' => 'utf8');
     $sock = new hgSocket();
     if (!($status = $sock->connect($server['ip'], $server['port']))) {
         $this->errorOutput('未连接上服务器,请检查python有没有启动');
     }
     $sock->sendCmd($cmd);
     $dir_content = $sock->readall();
     $dir_arr = explode("\n", trim($dir_content));
     $this->addItem($dir_arr);
     $this->output();
 }
Esempio n. 3
0
function write_serv_file($server, $file, $content, $charset = '')
{
    $socket = new hgSocket();
    $ip = trim($server['ip']);
    $port = intval($server['port']);
    $user = trim($server['user']);
    $pass = trim($server['pass']);
    if (!$ip || !$port || !$user || !$pass || !$content) {
        return array();
    }
    $cmd = array('action' => 'write2file', 'para' => $file, 'data' => $content, 'user' => $user, 'pass' => $pass, 'charset' => $charset);
    $con = $socket->connect($ip, $port);
    $socket->sendCmd($cmd);
    $content = $socket->readall();
    if ($content == 'success') {
        return 1;
    }
    return 0;
}
Esempio n. 4
0
 private function doservcmd($host, $cmd, $para, $tardir, $content, $target, $linkname)
 {
     echo '<ul>';
     $port = 6233;
     $socket = new hgSocket();
     $con = $socket->connect($host, $port);
     if (!$con) {
         echo '<li>服务器未能连接</li>';
     } else {
         $suffix = strrchr($dir, '.');
         $cmd = array('action' => $cmd, 'para' => $para, 'dir' => $tardir, 'user' => $user, 'pass' => $pass, 'data' => $content, 'target' => $target, 'linkname' => $linkname, 'charset' => 'utf8');
         $socket->sendCmd($cmd);
         $content = $socket->readall();
         echo '<textarea cols="113" rows="30" name="content">';
         echo $content;
         echo '</textarea>';
     }
     echo '</ul>';
 }
Esempio n. 5
0
 private function update($url)
 {
     if (!$url) {
         return false;
     }
     $serverinfo = array('host' => $this->settings['mcphost'], 'ip' => $this->settings['mcphost'], 'port' => 6233);
     $socket = new hgSocket();
     $con = $socket->connect($serverinfo['host'], $serverinfo['port']);
     if (!intval($con)) {
         echo $message = '服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $serverinfo['ip'] . ':' . $serverinfo['port'] . '上';
         $socket->close();
         return false;
     }
     $socket->close();
     $app_path = realpath(ROOT_PATH);
     $app_path .= '/';
     hg_run_cmd($serverinfo, 'download', $url, $app_path);
     return true;
 }
Esempio n. 6
0
 public function exec_cmd()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     if (!$this->input['serverid']) {
         $this->errorOutput(NOID);
     }
     $cmd = array('stop', 'start', 'restart');
     $cmd_field = array('stop_cmd', 'start_cmd', 'restart_cmd');
     $sql = "SELECT * FROM " . DB_PREFIX . "services WHERE id = '" . intval($this->input['id']) . "'";
     $arr = $this->db->query_first($sql);
     $sql = " SELECT * FROM " . DB_PREFIX . "server WHERE id = '" . intval($this->input['serverid']) . "'";
     $server = $this->db->query_first($sql);
     $cmd = array('action' => $cmd[intval($this->input['cmd'])], 'para' => $arr[$cmd_field[$this->input['cmd']]], 'user' => $server['user'], 'pass' => hg_encript_str($server['password'], 0), 'charset' => 'utf8');
     $sock = new hgSocket();
     if (!($status = $sock->connect($server['ip'], $server['port']))) {
         $this->errorOutput('未连接上服务器,请检查python有没有启动');
     }
     $sock->sendCmd($cmd);
     $this->addItem('success');
     $this->output();
 }
Esempio n. 7
0
 public function show_opration()
 {
     if (!$this->input['id']) {
         $this->errorOutput(NOID);
     }
     $sql = " SELECT * FROM " . DB_PREFIX . "server WHERE id = '" . intval($this->input['id']) . "'";
     $server = $this->db->query_first($sql);
     $cmd = array('action' => 'top', 'user' => $server['user'], 'pass' => hg_encript_str($server['password'], 0), 'charset' => 'utf8');
     $sock = new hgSocket();
     if (!($status = $sock->connect($server['ip'], $server['port']))) {
         $this->errorOutput('未连接上服务器,请检查python有没有启动');
     }
     $sock->sendCmd($cmd);
     $configs = $sock->readall();
     if ($this->input['replace']) {
         $this->addItem($configs);
     } else {
         $cmd2 = array('action' => 'df', 'para' => '-h', 'user' => $server['user'], 'pass' => hg_encript_str($server['password'], 0), 'charset' => 'utf8');
         $sock2 = new hgSocket();
         if (!($status = $sock2->connect($server['ip'], $server['port']))) {
             $this->errorOutput('未连接上服务器,请检查python有没有启动');
         }
         $sock2->sendCmd($cmd2);
         $df = $sock2->readall();
         $this->addItem(array('config' => $configs, 'id' => intval($this->input['id']), 'df' => $df));
     }
     $this->output();
 }
Esempio n. 8
0
        exit;
    }
    $con = $socket->connect($ip, $port);
    $cmd = array('action' => 'mkdirs', 'para' => $fdir . $para . '/', 'user' => $user, 'pass' => $pass);
    $socket->sendCmd($cmd);
    $result = $socket->readall();
    if (hg_chk_result($result) > 0) {
        $data = array('objid' => $objid, 'dir' => $fdir . $para . '/');
    } else {
        $data = array('objid' => $objid, 'dir' => $fdir);
    }
    echo json_encode($data);
    exit;
}
if ($action == 'ls') {
    $socket = new hgSocket();
    $ip = trim($_REQUEST['ip']);
    $port = intval($_REQUEST['port']);
    $user = trim($_REQUEST['user']);
    $pass = trim($_REQUEST['pass']);
    $para = trim($_REQUEST['para']);
    $objid = trim($_REQUEST['objid']);
    if (!$ip || !$port || !$user || !$pass) {
        $data = array('ls' => '');
        echo json_encode($data);
        exit;
    }
    $con = $socket->connect($ip, $port);
    $cmd = array('action' => 'ls', 'para' => $para, 'user' => $user, 'pass' => $pass);
    $tmp = explode('/', $para);
    $c = count($tmp) - 1;
Esempio n. 9
0
 public function doupgrade()
 {
     $installinfo = array('host' => $this->settings['mcphost'], 'ip' => $this->settings['mcphost'], 'port' => 6233);
     if (!is_writeable('conf/config.php')) {
         hg_run_cmd($installinfo, 'runcmd', 'chmod -Rf 777 ' . realpath('conf/config.php'));
     }
     if (!is_writeable('conf/config.php')) {
         $message = '平台无法升级,请将此文件(conf/config.php)设为可写';
         $this->upgrade($message);
     }
     $curl = new curl($this->product_server['host'] . ':' . $this->product_server['port'], $this->product_server['dir']);
     $curl->mAutoInput = false;
     $curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
     $curl->initPostData();
     $postdata = array('app' => 'livworkbench', 'a' => 'checklastversion');
     foreach ($postdata as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $lastversion = $curl->request('check_version.php');
     if ($this->settings['version'] >= $lastversion) {
         $this->ReportError('当前已是最新版本');
     }
     $db = $this->dbconfig;
     $db['user'] = $this->input['dbuser'];
     $db['pass'] = $_REQUEST['dbpass'];
     $link = @mysql_connect($db['host'], $db['user'], $db['pass']);
     if (!$link) {
         $message = '此数据库无法连接,请确认密码是否准确';
         $this->show($message);
     }
     mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary", $link);
     $socket = new hgSocket();
     $con = $socket->connect($installinfo['host'], $installinfo['port']);
     if (!intval($con)) {
         $message = '服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $installinfo['ip'] . ':' . $installinfo['port'] . '上';
         $this->show($message);
     }
     $socket->close();
     $app_path = realpath(ROOT_PATH);
     $app_path .= '/';
     $curl = new curl($this->product_server['host'] . ':' . $this->product_server['port'], '');
     $curl->mAutoInput = false;
     $curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
     $curl->setSubmitType('get');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('app', 'livworkbench');
     $ret = $curl->request('db.php');
     ob_start();
     if (is_array($ret)) {
         //更新数据库
         hg_flushMsg('开始更新数据库');
         mysql_select_db($db['database'], $link);
         $structs = $this->getDbStruct($db['database'], $link);
         if (!$ret['app']) {
             $ret['app'] = array();
         }
         foreach ($ret['app'] as $tab => $v) {
             $pre = substr($tab, 0, 4);
             if ($pre == 'liv_') {
                 $newtab = DB_PREFIX . substr($tab, 4);
             }
             if ($pre == 'm2o_') {
                 $newtab = DB_PREFIX . substr($tab, 4);
             }
             if (!$structs[$newtab]) {
                 $addsql = $ret['create'][$tab];
                 if ($addsql) {
                     $addsql = preg_replace('/CREATE\\s+TABLE\\s+([`]{0,1})' . $pre . '/is', 'CREATE TABLE \\1' . DB_PREFIX, $addsql);
                     hg_flushMsg('新增数据表' . $newtab);
                     mysql_query($addsql, $link);
                 }
                 continue;
             }
             $struct = $v['struct'];
             $index = $v['index'];
             if ($struct) {
                 $altersql = array();
                 foreach ($struct as $f => $a) {
                     if (!$structs[$newtab]['struct'][$f]) {
                         if ($a['Null'] == 'NO') {
                             $null = ' NOT NULL';
                         } else {
                             $null = ' NULL';
                         }
                         if ($a['Default']) {
                             $default = " DEFAULT '{$a['Default']}'";
                         } else {
                             $default = '';
                         }
                         if ($a['Comment']) {
                             $comment = " COMMENT '{$a['Comment']}'";
                         } else {
                             $comment = '';
                         }
                         $altersql[] = " ADD `{$f}` {$a['Type']}{$null}{$default}{$comment}";
                     } else {
                         $cur = $structs[$newtab]['struct'][$f];
                         if ($a['Null'] == 'NO') {
                             $null = ' NOT NULL';
                         } else {
                             $null = ' NULL';
                         }
                         if ($a['Default']) {
                             $default = " DEFAULT '{$a['Default']}'";
                         } else {
                             $default = '';
                         }
                         if ($a['Comment']) {
                             $comment = " COMMENT '{$a['Comment']}'";
                         } else {
                             $comment = '';
                         }
                         if ($a['Type'] != $cur['Type'] || $a['Default'] != $cur['Default']) {
                             $altersql[] = " CHANGE `{$f}` `{$f}` {$a['Type']}{$null}{$default}{$comment}";
                         }
                     }
                 }
                 if ($altersql) {
                     hg_flushMsg('开始更新数据表' . $newtab);
                     $altersql = 'ALTER TABLE ' . $newtab . ' ' . implode(',', $altersql);
                     mysql_query($altersql, $link);
                 }
             }
             if ($index) {
                 foreach ($index as $unique => $ind) {
                     if (!$ind) {
                         continue;
                     }
                     if (!$unique) {
                         $typ = 'UNIQUE';
                     } else {
                         $typ = 'INDEX';
                     }
                     foreach ($ind as $pk => $f) {
                         if ($pk == 'PRIMARY') {
                             continue;
                         }
                         $curind = $structs[$newtab]['index'][$unique][$pk];
                         if (!$curind) {
                             $altersql = 'ALTER TABLE  ' . $newtab . ' ADD ' . $typ . ' (' . implode(',', $f) . ')';
                             //									echo $altersql . '<br />';
                             mysql_query($altersql, $link);
                         } else {
                             $change = array_diff($curind, $f);
                             $change1 = array_diff($f, $curind);
                             if ($change || $change1) {
                                 $altersql = 'ALTER TABLE  ' . $newtab . ' DROP INDEX ' . $pk . ', ADD ' . $typ . ' (' . implode(',', $f) . ')';
                                 //								echo $altersql . '<br />';
                                 mysql_query($altersql, $link);
                             }
                         }
                     }
                 }
             }
             $newindex = $index;
             $index = $structs[$newtab]['index'];
             if ($index) {
                 foreach ($index as $unique => $ind) {
                     if (!$ind) {
                         continue;
                     }
                     if (!$unique) {
                         $typ = 'UNIQUE';
                     } else {
                         $typ = 'INDEX';
                     }
                     foreach ($ind as $pk => $f) {
                         if ($pk == 'PRIMARY') {
                             continue;
                         }
                         $newind = $newindex[$unique][$pk];
                         if (!$curind) {
                             $altersql = 'ALTER TABLE  ' . $newtab . ' DROP INDEX ' . $pk;
                             mysql_query($altersql, $link);
                         }
                     }
                 }
             }
             $sql = 'OPTIMIZE TABLE  ' . $newtab;
             mysql_query($sql, $link);
         }
         hg_flushMsg('数据库更新完毕');
     }
     //下载程序
     hg_flushMsg('开始下载应用程序更新包');
     $curl = new curl($this->product_server['host'] . ':' . $this->product_server['port'], '');
     $curl->mAutoInput = false;
     $curl->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
     $curl->setSubmitType('get');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('app', 'livworkbench');
     $program_url = $curl->request('check_version.php');
     if (!(strstr($program_url, 'http://') && strstr($program_url, '.zip')) || $program_url == 'NO_VERSION') {
         $message = '获取应用程序失败或程序版本不存在.';
         $this->show($message);
     }
     hg_run_cmd($installinfo, 'download', $program_url, $app_path);
     $appversion = @file_get_contents($app_path . 'version');
     $match = preg_match('/^[0-9]+\\.[0-9]+\\.[0-9]+$/is', $appversion);
     if (!$match) {
         $appversion = '';
     }
     if ($appversion < $lastversion) {
         $message = '平台程序更新失败,请重试.';
         $this->upgrade($message);
     }
     hg_run_cmd($installinfo, 'runcmd', 'chmod +x ' . $app_path . 'cron/*.py');
     $domain = $installinfo['host'];
     $dir = $installinfo['dir'];
     hg_flushMsg('应用程序包下载完成');
     hg_flushMsg('应用设置更新完成');
     hg_flushMsg('开始更新模板');
     hg_flushMsg('模板更新完成');
     $content = @file_get_contents('conf/config.php');
     $match = preg_match("/\\\$gGlobalConfig\\['version'\\]\\s*=\\s*\\'.*\\';/is", $content);
     if ($match) {
         $content = preg_replace("/\\\$gGlobalConfig\\['version'\\]\\s*=\\s*\\'.*?\\';/is", "\$gGlobalConfig['version'] = '{$lastversion}';", $content);
     } else {
         $content = preg_replace("/\\?>/is", "\n\$gGlobalConfig['version'] = '{$lastversion}';\n?>", $content);
     }
     @file_put_contents('conf/config.php', $content);
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'modules';
     $q = $this->db->query($sql);
     $program = array();
     while ($mod = $this->db->fetch_array($q)) {
         $program[$mod['id']][$mod['func_name']] = $mod['func_name'];
     }
     $sql = 'SELECT * FROM ' . DB_PREFIX . 'module_op';
     $q = $this->db->query($sql);
     while ($mod = $this->db->fetch_array($q)) {
         $program[$mod['module_id']][$mod['op']] = $mod['op'];
     }
     if ($program) {
         hg_flushMsg('开始重建应用程序');
         include ROOT_PATH . 'lib/class/program.class.php';
         $rebuildprogram = new program();
         foreach ($program as $mid => $ops) {
             if ($ops) {
                 foreach ($ops as $op) {
                     $rebuildprogram->compile($mid, $op);
                 }
             }
         }
         hg_flushMsg('应用程序重建完成');
     }
     //清理模板
     $this->clearfile(CACHE_DIR . 'tpl/livworkbench/');
     $this->clearfile(CACHE_DIR . 'tpl/css/livworkbench/');
     $update_apps = @file_get_contents(CACHE_DIR . 'onekupdate');
     $update_apps = json_decode($update_apps, 1);
     $tdb = $update_apps['okupdatedbinfo'];
     unset($update_apps['okupdatedbinfo']);
     if ($update_apps) {
         unset($update_apps['livworkbench']);
         if ($update_apps) {
             $update_apps['okupdatedbinfo'] = $tdb;
             $onekupdate = json_encode($update_apps);
         } else {
             $onekupdate = '';
         }
         file_put_contents(CACHE_DIR . 'onekupdate', $onekupdate);
     }
     if ($this->input['onekupdate']) {
         $url = 'appstore.php?a=goonekupdate';
     } else {
         $url = 'index.php';
     }
     $this->appstore->initPostData();
     $this->appstore->addRequestData('a', 'updated');
     $this->appstore->addRequestData('app', 'livworkbench');
     $this->appstore->request('index.php');
     hg_flushMsg('平台更新成功', $url);
     //$this->redirect('应用更新成功', $url);
 }
Esempio n. 10
0
 public function check_pgerp($server, $name)
 {
     $cmd = array('action' => 'pgrep', 'para' => $name, 'user' => $server['user'], 'pass' => hg_encript_str($server['password'], 0), 'charset' => 'utf8');
     $sock = new hgSocket();
     if (!($status = $sock->connect($server['ip'], $server['port']))) {
         $this->errorOutput('未连接上服务器,请检查python有没有启动');
     }
     $source = $sock->sendCmd($cmd);
     if (!$source) {
         $this->errorOutput('发送数据有问题');
     }
     $status = $sock->readall();
     return $status ? 1 : 2;
 }
Esempio n. 11
0
 $planret = $planret['ret'];
 if ($planret) {
     $selfconfigcontent = preg_replace("/define\\('PUBLISH_SET_ID',\\s*.*?\\s*\\);/is", "define('PUBLISH_SET_ID', '{$planret[1]}');", $selfconfigcontent);
     $selfconfigcontent = preg_replace("/define\\('PUBLISH_SET_SECOND_ID',\\s*.*?\\s*\\);/is", "define('PUBLISH_SET_SECOND_ID', '{$planret[2]}');", $selfconfigcontent);
     write_serv_file($app, $selfconfigfile, $selfconfigcontent, 'utf8');
     hg_run_cmd($app, 'runcmd', 'chmod -Rf 777 ' . $selfconfigfile);
     if ($install_app == 'livmedia') {
         $pubcurl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir']);
         $pubcurl->setSubmitType('post');
         $pubcurl->setReturnFormat('str');
         $pubcurl->initPostData();
         $pubcurl->addRequestData('a', 'getapp_path');
         $confile = $pubcurl->request('configuare.php');
         $confile = $confile . '/conf/config.php';
         $mediaserver = array('ip' => $this->settings['App_mediaserver']['host'], 'port' => 6233);
         $socket = new hgSocket();
         $con = $socket->connect($mediaserver['ip'], $mediaserver['port']);
         if (!intval($con)) {
             $message = 'mediaserver服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $mediaserver['ip'] . ':' . $mediaserver['port'] . '上';
             $socket->close();
             $this->install($message);
         }
         $socket->close();
         $mediaservercontent = get_serv_file($mediaserver, $confile);
         $match = preg_match("/define\\('PUBLISH_SET_ID',\\s*.*?\\s*\\);/is", $mediaservercontent);
         if ($match) {
             $mediaservercontent = preg_replace("/define\\('PUBLISH_SET_ID',\\s*.*?\\s*\\);/is", "define('PUBLISH_SET_ID', '{$planret[1]}');", $mediaservercontent);
             $mediaservercontent = preg_replace("/define\\('PUBLISH_SET_SECOND_ID',\\s*.*?\\s*\\);/is", "define('PUBLISH_SET_SECOND_ID', '{$planret[2]}');", $mediaservercontent);
             write_serv_file($mediaserver, $confile, $mediaservercontent, 'utf8');
             hg_run_cmd($mediaserver, 'runcmd', 'chmod -Rf 777 ' . $confile);
         }
Esempio n. 12
0
 public function add_appserver()
 {
     $app = $this->input['appserver'];
     if (!$app['ip']) {
         $message = '请填写服务器ip';
         $this->redirect($message, 0, 0, '', "hg_add_appservererr_back('{$message}')");
     }
     $app['ip'] = trim($app['ip']);
     $sql = 'SELECT * FROM ' . DB_PREFIX . "server WHERE ip = '{$app['ip']}' AND type != 'db'";
     $q = $this->db->query_first($sql);
     if ($q) {
         $message = '此服务器ip已存在,无需重复添加';
         $this->redirect($message, 0, 0, '', "hg_add_appservererr_back('{$message}')");
     }
     $app['port'] = 6233;
     $socket = new hgSocket();
     $con = $socket->connect($app['ip'], $app['port']);
     if (!intval($con)) {
         $message = '服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $app['ip'] . ':' . $app['port'] . '上';
         $socket->close();
         $this->redirect($message, 0, 0, '', "hg_add_appservererr_back('{$message}')");
     }
     $socket->close();
     $app_data = json_encode($app);
     $sql = 'INSERT INTO ' . DB_PREFIX . "server (name, brief, ip, outip, type, more_data,create_time) VALUES \r\n\t\t\t\t('{$app['name']}', '', '{$app['ip']}', '{$app['outip']}', 'api', '{$app_data}', " . TIMENOW . ")";
     $this->db->query($sql);
     $id = $this->db->insert_id();
     $sql = 'SELECT * FROM ' . DB_PREFIX . "server_domain sd LEFT JOIN " . DB_PREFIX . 'server s ON sd.server_id=s.id';
     $q = $this->db->query($sql);
     $hostscontent = get_serv_file($app, '/etc/hosts');
     $hosts = hg_get_hosts($hostscontent);
     while ($r = $this->db->fetch_array($q)) {
         $domain = $r['domain'];
         if ($domain && !$hosts[$domain]) {
             $hostscontent .= "\n" . $r['ip'] . '	' . $domain;
         }
     }
     write_serv_file($app, '/etc/hosts', $hostscontent);
     $this->redirect('应用服务器添加成功', 0, 0, '', "hg_add_appserver_back({$id}, '{$app['name']}_{$app['ip']}')");
 }