Example #1
0
function remote_install()
{
    global $family;
    $token = '';
    $pars = array();
    $pars['host'] = $_SERVER['HTTP_HOST'];
    $pars['version'] = '0.7';
    $pars['release'] = '';
    $pars['type'] = 'install';
    $pars['product'] = '';
    $url = 'http://v2.addons.we7.cc/gateway.php';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $pars);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADERFUNCTION, '__remote_install_headers');
    $content = curl_exec($ch);
    curl_close($ch);
    $sign = __remote_install_headers();
    $ret = array();
    if (empty($content)) {
        return showerror(-1, '获取安装信息失败,可能是由于网络不稳定,请重试。');
    }
    $ret = unserialize($content);
    if ($sign != md5($ret['data'] . $token)) {
        return showerror(-1, '发生错误: 数据校验失败,可能是传输过程中网络不稳定导致,请重试。');
    }
    $ret['data'] = unserialize($ret['data']);
    return $ret['data'];
}
Example #2
0
function remote_install()
{
    global $family;
    $token = '';
    $pars = array();
    $pars['host'] = $_SERVER['HTTP_HOST'];
    $pars['version'] = '';
    $pars['release'] = '';
    $url = 'http://addons.we7.cc/gateway.php';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $pars);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADERFUNCTION, '__remote_install_headers');
    $content = curl_exec($ch);
    curl_close($ch);
    $sign = __remote_install_headers();
    $ret = array();
    if ($content) {
        $obj = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA);
        $ret['version'] = strval($obj->version);
        $ret['release'] = strval($obj->release);
        $ret['family'] = strval($obj->family);
        $ret['announcement'] = strval($obj->announcement);
        $ret['error'] = strval($obj->error);
        if (empty($ret['error']) && $sign == md5($content . $token)) {
            if ($obj->scripts) {
                $ret['scripts'] = array();
                foreach ($obj->scripts->script as $schema) {
                    $attr = $schema->attributes();
                    $v = strval($attr['version']);
                    $r = strval($attr['release']);
                    $c = strval($schema);
                    $ret['scripts'][] = array('version' => $v, 'release' => $r, 'content' => $c);
                }
            }
            if ($obj->attachments) {
                $ret['attachments'] = array();
                foreach ($obj->attachments->file as $file) {
                    $attr = $file->attributes();
                    $path = strval($attr['path']);
                    $sum = strval($attr['checksum']);
                    $entry = IA_ROOT . $path;
                    if (!is_file($entry) || md5_file($entry) != $sum) {
                        $ret['attachments'][] = $path;
                    }
                }
            }
        }
    }
    return $ret;
}