Esempio n. 1
0
$action = $_REQUEST['action'];
if (!$_REQUEST['file'] || !$_REQUEST['id']) {
    header('Location:./index.php');
}
$server = $servers[$_REQUEST['id']];
if (!$server) {
    header('Location:./index.php');
}
$file = $Cfg['servertype'][$server['type']]['conf'][$_REQUEST['file']];
if (!$file) {
    header('Location:./index.php');
}
$sock = new hgSocket();
switch ($action) {
    case 'df':
        $configs = hg_run_cmd($sock, $server, 'df');
        $doaction = 'babbaa';
        include 'tpl/man.tpl.php';
        break;
    case 'getfile':
        $configs = get_serv_file($sock, $server, $file);
        $doaction = 'dowritefile';
        include 'tpl/man.tpl.php';
        break;
    case 'dowritefile':
        $configs = write_serv_file($sock, $server, $file, $_REQUEST['content']);
        header('Location:./man.php?action=getfile&id=' . $_REQUEST['id'] . '&file=' . $_REQUEST['file']);
        break;
    default:
        $configs = 'No specify file';
        include 'tpl/man.tpl.php';
Esempio n. 2
0
$match = preg_match('/^[0-9]+\\.[0-9]+\\.[0-9]+$/is', $apiversion);
if (!$match) {
    $apiversion = '';
}
if ($apiversion < $appinfo['version']) {
    $message = '接口程序更新失败,请重试.<!-- ' . $program_url . ' -->';
    $this->upgrade($message);
}
$curl->initPostData();
$curl->addRequestData('js', 1);
$curl->addRequestData('app', $install_app);
$program_url = $curl->request('check_version.php');
$m2oserv = array('ip' => $this->settings['mcphost'], 'port' => 6233);
$m2oscriptdir = realpath('./') . '/res/scripts/app_' . $install_app . '/';
if (!$this->input['havemat']) {
    hg_run_cmd($m2oserv, 'download', $program_url, $m2oscriptdir);
}
$scriptversion = @file_get_contents($m2oscriptdir . 'version');
$match = preg_match('/^[0-9]+\\.[0-9]+\\.[0-9]+$/is', $scriptversion);
if (!$match) {
    $scriptversion = '';
}
if ($scriptversion < $appinfo['version']) {
    $message = '接口图片和js等资源程序更新失败,请重试.<!-- ' . $program_url . ' -->';
    $this->upgrade($message);
}
hg_flushMsg('应用程序包下载完成');
//插入应用和模块
$menu = array();
$applications = $modules = array();
if ($m2odata) {
Esempio n. 3
0
function step7()
{
    $user_name = trim($_REQUEST['user_name']);
    $password = trim($_REQUEST['password']);
    $confirmpassword = trim($_REQUEST['confirmpassword']);
    if (!$user_name) {
        $message = '请设置用户名';
        step6($message);
    }
    if (!$password || $confirmpassword != $password) {
        $message = '未设置密码或两次密码不一致';
        step6($message);
    }
    $app = file_get_contents(CACHE_DIR . 'app.tmp');
    $app = json_decode($app, 1);
    $db = file_get_contents(CACHE_DIR . 'db.tmp');
    $db = json_decode($db, 1);
    $auth = @file_get_contents(CACHE_DIR . 'auth.tmp');
    $auth = json_decode($auth, 1);
    $socket = new hgSocket();
    $con = $socket->connect($app['ip'], $app['port']);
    if (!intval($con)) {
        step6('安装无法完成,服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $app['ip'] . ':' . $app['port'] . '上');
    }
    $socket->close();
    $password = md5($password);
    $content = get_serv_file($app, $app['dir'] . 'conf/config.php');
    $string = "\$gGlobalConfig['admin_user'] = array(\n'{$user_name}'     => '{$password}',\n);";
    $content = preg_replace("/\\?>/is", "\n{$string}\n?>", $content);
    write_serv_file($app, $app['dir'] . 'conf/config.php', $content, 'utf8');
    hg_run_cmd($app, 'runcmd', 'chmod -Rf 777 ' . $app['dir'] . 'cache/ ' . $app['dir'] . 'conf/config.php');
    if ($db) {
        $pass = hg_encript_str($db['pass'], false, $auth['appkey']);
        $link = mysql_connect($db['host'], $db['user'], $pass);
        mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary", $link);
        mysql_select_db($db['database'], $link);
        $db_data = json_encode($db);
        $app_data = json_encode($app);
        $sql = 'INSERT INTO ' . $db['dbprefix'] . "server (name, brief, ip, outip, type, more_data,create_time) VALUES \n\t\t\t\t('app数据库服务器', '', '{$db['host']}', '', 'db', '{$db_data}', " . time() . ");\n\t\t\t\t";
        mysql_query($sql, $link);
        $sql = 'INSERT INTO ' . $db['dbprefix'] . "server (name, brief, ip, outip, type, more_data,create_time) VALUES \n\t\t\t\t('app服务器', '', '{$app['ip']}', '{$app['outip']}', 'app', '{$app_data}', " . time() . ");\n\t\t\t\t";
        mysql_query($sql, $link);
        $server_id = mysql_insert_id();
        $sql = 'INSERT INTO ' . $db['dbprefix'] . "server_domain (server_id, domain, dir, create_time) VALUES \n\t\t\t\t('{$server_id}', '{$app['domain']}', '{$app['dir']}', " . time() . ");\n\t\t\t\t";
        mysql_query($sql, $link);
    }
    $appstore = new curl('appstore.hogesoft.com:233', '');
    $appstore->mAutoInput = false;
    $appstore->setClient(CUSTOM_APPID, CUSTOM_APPKEY);
    $appstore->initPostData();
    $appstore->addRequestData('a', 'installed');
    $appstore->addRequestData('app', 'livworkbench');
    $appstore->request('index.php');
    header('Location:' . '?action=complete');
}
Esempio n. 4
0
                $para = 'http://' . $Cfg['upgradeServer']['host'] . ':' . $Cfg['upgradeServer']['port'] . '/' . $ret['zip'];
                hg_run_cmd($v, 'download', $para, $app['dir']);
                hg_run_cmd($v, 'mkdirs', $app['dir'] . 'uploads/');
                hg_run_cmd($v, 'mkdirs', $app['uploaddir']);
                hg_run_cmd($v, 'mkdirs', $app['targetdir']);
                hg_run_cmd($v, 'runcmd', 'chmod -Rf 777 ' . $app['dir'] . 'uploads/ ' . $app['uploaddir'] . ' ' . $app['targetdir']);
                $content = '<?xml version="1.0"?>
<!-- http://www.adobe.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>';
                write_serv_file($v, $app['uploaddir'] . '/crossdomain.xml', $content, 'utf8');
                write_serv_file($v, $app['targetdir'] . '/crossdomain.xml', $content, 'utf8');
                hg_run_cmd($v, 'mkdirs', $apidir . 'cache/');
                hg_run_cmd($v, 'mkdirs', $apidir . 'data/');
                hg_run_cmd($v, 'runcmd', 'chmod -Rf 777 ' . $apidir . 'cache/ ' . $apidir . 'data/');
            }
            hg_flushMsg('软件包获取完成');
        }
        hg_flushMsg('上传程序下载完成');
    }
    echo '  <div align="center">
		<input type="button" name="s" value=" 下一步 " style="width:100px;height:40px;color:#fff;font-size:16px;margin-top:20px;" onclick="document.location.href=\'index.php?action=install5\'" />
	  </div>';
    include 'tpl/foot.tpl.php';
}
//申请授权
if ($action == 'install5') {
    $license = @(include './db/license.php');
    if ($license) {
        header('Location:index.php?action=install6');
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
 function __construct()
 {
     global $gTpl;
     parent::__construct();
     $this->tpl = $gTpl;
     if ($this->user['group_type'] > MAX_ADMIN_TYPE && $this->settings['upgrading']['open'] && SCRIPT_NAME != 'login') {
         $this->tpl->setTemplateTitle('系统升级中...');
         $this->tpl->addVar('message', $this->settings['upgrading']['message']);
         $endtime = strtotime($this->settings['upgrading']['endtime']);
         if ($endtime < TIMENOW) {
             $endtime = TIMENOW + 21600;
         }
         $format_endtime = date('Y-m-d H:i', $endtime);
         $this->tpl->addVar('format_endtime', $format_endtime);
         $this->tpl->addVar('endtime', $endtime);
         $this->tpl->outTemplate('upgrading');
     }
     if (defined('INITED_APP') && !INITED_APP) {
         $file = 'conf/init.data';
         if (is_file($file)) {
             $content = file_get_contents($file);
             if ($content) {
                 $this->db = hg_checkDB();
                 preg_match_all('/INSERT\\s+INTO\\s+(.*?)\\(.*?\\)\\s*;;/is', $content, $match);
                 $insertsql = $match[0];
                 if ($insertsql) {
                     $this->db->mErrorExit = false;
                     foreach ($insertsql as $sql) {
                         $sql = preg_replace('/INSERT\\s+INTO\\s+([`]{0,1})liv_/is', 'INSERT INTO \\1' . DB_PREFIX, $sql);
                         $this->db->query($sql);
                     }
                     $this->db->mErrorExit = true;
                 }
             }
         }
         if (!is_writeable('conf/config.php')) {
             if ($this->settings['mcphost']) {
                 $m2oserver = array('ip' => $this->settings['mcphost'], 'port' => 6233);
                 hg_run_cmd($m2oserver, 'runcmd', 'chmod -Rf 777 ' . realpath('conf/config.php'));
             }
         }
         $content = @file_get_contents('conf/config.php');
         $content = preg_replace("/define\\('INITED_APP',\\s*.*?\\);/is", "define('INITED_APP', true);", $content);
         @file_put_contents('conf/config.php', $content);
     } elseif (!defined('INITED_APP')) {
         if (is_writeable('conf/config.php')) {
             $content = @file_get_contents('conf/config.php');
             $content = preg_replace("/\\?>/is", "\ndefine('INITED_APP', true);\n?>", $content);
             @file_put_contents('conf/config.php', $content);
         }
     }
     $this->check_lang();
     $this->load_lang('global');
     if (!$this->input['referto']) {
         $this->input['referto'] = str_replace('&a=form', '', $_SERVER['REQUEST_URI']);
         //$this->input['referto'] = REFERRER;
     }
     $dialog = array('id' => 'livwindialog');
     //$_SERVER['HTTP_CHANNEL'] = 'hnws';
     if ($_SERVER['CHANNEL_CODE']) {
         $this->input['infrm'] = 1;
         if ($this->settings['App_live']) {
             //获取频道信息
             ///*
             include_once ROOT_PATH . 'lib/class/curl.class.php';
             $mLive = new curl($this->settings['App_live']['host'], $this->settings['App_live']['dir']);
             $mLive->initPostData();
             $mLive->addRequestData('a', 'show');
             $mLive->addRequestData('channel_code', $_SERVER['CHANNEL_CODE']);
             $ret_channel = $mLive->request('channel.php');
             $this->channel = $ret_channel[0];
             $this->input['channel_id'] = $this->channel['id'];
             $reffer = 'run.php?mid=' . $this->settings['App_interactive']['mid'][$this->user['group_type']] . '&channel_id=' . $this->input['channel_id'];
             $this->tpl->setTemplateTitle($this->channel['channel']['name'] . '直播互动平台');
             //*/
         }
     } else {
         $this->check_nav();
         if (defined('CUSTOM_NAME')) {
             $meta_title = CUSTOM_NAME . $this->settings['name'];
         } else {
             $meta_title = $this->settings['name'];
         }
         $this->tpl->setTemplateTitle($meta_title);
     }
     $this->tpl->addVar('dialog', $dialog);
     //弹出框
     $this->tpl->addVar('_INPUT', $this->input);
     $this->tpl->addVar('_user', $this->user);
     $this->tpl->addVar('_settings', $this->settings);
 }
Esempio n. 7
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. 8
0
            $confile = $confile . '/conf/config.php';
            $content = get_serv_file($v, $confile);
            $match = preg_match("/define\\('PUBLISH_SET_ID',\\s*.*?\\s*\\);/is", $content);
            if ($match) {
                $appcurl->setReturnFormat('json');
                $appcurl->initPostData();
                $appcurl->addRequestData('a', 'create_publish_table');
                $appcurl->addRequestData('apihost', $v['host']);
                $appcurl->addRequestData('apidir', $v['dir']);
                $planret = $appcurl->request('configuare.php');
                $planret = $planret['ret'];
                if ($planret) {
                    $content = preg_replace("/define\\('PUBLISH_SET_ID',\\s*.*?\\s*\\);/is", "define('PUBLISH_SET_ID', '{$planret[1]}');", $content);
                    $content = preg_replace("/define\\('PUBLISH_SET_SECOND_ID',\\s*.*?\\s*\\);/is", "define('PUBLISH_SET_SECOND_ID', '{$planret[2]}');", $content);
                }
                write_serv_file($v, $confile, $content, 'utf8');
                hg_run_cmd($app, 'runcmd', 'chmod -Rf 777 ' . $confile);
            }
        }
    }
    //发布计划创建
}
if ($appinfo['sourceapp']['app_uniqueid']) {
    $url = '?a=install&app=' . $appinfo['sourceapp']['app_uniqueid'];
} else {
    $url = '?app=' . $install_app;
}
if ($install_app == 'auth') {
    $url = 'login.php?a=logout';
}
hg_flushMsg('应用安装成功', $url);
Esempio n. 9
0
 public function sync_js($message = '')
 {
     chdir('res/scripts/');
     $zip = 'zip -r ' . ROOT_PATH . 'cache/js.zip common.js global.js common/';
     exec($zip);
     if (!is_file(ROOT_PATH . 'cache/js.zip')) {
         echo 'zip 文件到cache目录失败';
         exit;
     }
     $curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
     $curl->setSubmitType('post');
     $curl->setReturnFormat('json');
     $ret = $curl->request('applications.php');
     $app = array('ip' => $this->settings['mcphost'], 'port' => 6233);
     $socket = new hgSocket();
     $con = $socket->connect($app['ip'], $app['port']);
     if (!intval($con)) {
         echo '服务器无法连接,请确认服务器ip是否正确或服务程序hogeMonitor.py是否监听在' . $app['ip'] . ':' . $app['port'] . '上';
         $socket->close();
         exit;
     }
     $socket->close();
     $host = $_SERVER['HTTP_HOST'];
     $dir = $_SERVER['SCRIPT_NAME'];
     $dir = explode('/', $dir);
     unset($dir[count($dir) - 1]);
     $url = 'http://' . $host;
     if ($dir) {
         $url .= implode('/', $dir);
     }
     $url .= '/cache/js.zip';
     if (is_array($ret)) {
         foreach ($ret as $v) {
             $app_path = ROOT_PATH . 'res/scripts/app_' . $v['bundle'] . '/';
             hg_run_cmd($app, 'download', $url, $app_path);
             echo $app_path . '已更新<br />';
         }
     }
     @unlink(ROOT_PATH . 'cache/js.zip');
 }