コード例 #1
0
ファイル: admin_functions.php プロジェクト: lzhao18/nukeviet
/**
 * nv_getExtVersion()
 *
 * @param integer $updatetime
 * @return
 */
function nv_getExtVersion($updatetime = 3600)
{
    global $global_config, $lang_global, $db, $db_config;
    $my_file = NV_ROOTDIR . '/' . NV_CACHEDIR . '/extensions.version.' . NV_LANG_INTERFACE . '.xml';
    $xmlcontent = false;
    $p = NV_CURRENTTIME - $updatetime;
    if (file_exists($my_file) and @filemtime($my_file) > $p) {
        $xmlcontent = simplexml_load_file($my_file);
    } else {
        // Lấy các ứng dụng của hệ thống
        $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_setup_extensions WHERE title=basename ORDER BY title ASC';
        $result = $db->query($sql);
        $array = $array_ext_ids = array();
        while ($row = $result->fetch()) {
            $row['version'] = explode(' ', $row['version']);
            $array[$row['title']] = array('id' => $row['id'], 'type' => $row['type'], 'name' => $row['title'], 'current_version' => trim($row['version'][0]), 'current_release' => trim($row['version'][1]), 'remote_version' => '', 'remote_release' => 0, 'updateable' => array(), 'author' => $row['author'], 'license' => '', 'mode' => $row['is_sys'] ? 'sys' : 'other', 'message' => $row['note'], 'link' => '', 'support' => '', 'origin' => false);
            if (!empty($row['id'])) {
                $array_ext_ids[] = $row['id'];
            }
        }
        if (!empty($array_ext_ids)) {
            include NV_ROOTDIR . '/includes/class/http.class.php';
            $NV_Http = new NV_Http($global_config, NV_TEMP_DIR);
            $args = array('headers' => array('Referer' => NUKEVIET_STORE_APIURL), 'body' => array('lang' > NV_LANG_INTERFACE, 'basever' => $global_config['version'], 'mode' => 'checkextver', 'ids' => implode(',', $array_ext_ids)));
            $apidata = $NV_Http->post(NUKEVIET_STORE_APIURL, $args);
            $apidata = !empty($apidata['body']) ? @unserialize($apidata['body']) : array();
            $error = '';
            if (!empty(NV_Http::$error)) {
                $error = nv_http_get_lang(NV_Http::$error);
            } elseif (!isset($apidata['error']) or !isset($apidata['data']) or !isset($apidata['pagination']) or !is_array($apidata['error']) or !is_array($apidata['data']) or !is_array($apidata['pagination']) or !empty($apidata['error']) and (!isset($apidata['error']['level']) or empty($apidata['error']['message']))) {
                $error = $lang_global['error_valid_response'];
            } elseif (!empty($apidata['error']['message'])) {
                $error = $apidata['error']['message'];
            }
            if (!empty($error)) {
                return $error;
            }
            $apidata = $apidata['data'];
            $content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cms>\n";
            // Xử lý dữ liệu
            foreach ($array as $row) {
                if (isset($apidata[$row['id']])) {
                    $row['remote_version'] = $apidata[$row['id']]['lastest_version'];
                    $row['remote_release'] = $apidata[$row['id']]['lastest_release'];
                    $row['updateable'] = $apidata[$row['id']]['updateable'];
                    if (empty($row['author'])) {
                        $row['author'] = $apidata[$row['id']]['author'];
                    }
                    $row['license'] = $apidata[$row['id']]['license'];
                    $row['message'] = $apidata[$row['id']]['note'];
                    $row['link'] = $apidata[$row['id']]['link'];
                    $row['support'] = $apidata[$row['id']]['support'];
                    $row['origin'] = true;
                }
                $content .= "\t<extension>\n";
                $content .= "\t\t<id><![CDATA[" . $row['id'] . "]]></id>\n";
                $content .= "\t\t<type><![CDATA[" . $row['type'] . "]]></type>\n";
                $content .= "\t\t<name><![CDATA[" . $row['name'] . "]]></name>\n";
                $content .= "\t\t<version><![CDATA[" . $row['current_version'] . "]]></version>\n";
                $content .= "\t\t<date><![CDATA[" . gmdate("D, d M Y H:i:s", $row['current_release']) . " GMT]]></date>\n";
                $content .= "\t\t<new_version><![CDATA[" . $row['remote_version'] . "]]></new_version>\n";
                $content .= "\t\t<new_date><![CDATA[" . ($row['remote_release'] ? gmdate("D, d M Y H:i:s", $row['current_release']) . " GMT" : "") . "]]></new_date>\n";
                $content .= "\t\t<author><![CDATA[" . $row['author'] . "]]></author>\n";
                $content .= "\t\t<license><![CDATA[" . $row['license'] . "]]></license>\n";
                $content .= "\t\t<mode><![CDATA[" . $row['mode'] . "]]></mode>\n";
                $content .= "\t\t<message><![CDATA[" . $row['message'] . "]]></message>\n";
                $content .= "\t\t<link><![CDATA[" . $row['link'] . "]]></link>\n";
                $content .= "\t\t<support><![CDATA[" . $row['support'] . "]]></support>\n";
                $content .= "\t\t<updateable>\n";
                if (!empty($row['updateable'])) {
                    $content .= "\t\t\t<upds>\n";
                    foreach ($row['updateable'] as $updateable) {
                        $content .= "\t\t\t\t<upd>\n";
                        $content .= "\t\t\t\t\t<upd_fid><![CDATA[" . $updateable['fid'] . "]]></upd_fid>\n";
                        $content .= "\t\t\t\t\t<upd_old><![CDATA[" . $updateable['old_ver'] . "]]></upd_old>\n";
                        $content .= "\t\t\t\t\t<upd_new><![CDATA[" . $updateable['new_ver'] . "]]></upd_new>\n";
                        $content .= "\t\t\t\t</upd>\n";
                    }
                    $content .= "\t\t\t</upds>\n";
                    unset($updateable);
                }
                $content .= "\t\t</updateable>\n";
                $content .= "\t\t<origin><![CDATA[" . ($row['origin'] === true ? 'true' : 'false') . "]]></origin>\n";
                $content .= "\t</extension>\n";
            }
            $content .= "</cms>";
            $xmlcontent = simplexml_load_string($content);
            if ($xmlcontent !== false) {
                file_put_contents($my_file, $content);
            }
        }
    }
    return $xmlcontent;
}
コード例 #2
0
ファイル: getupdate.php プロジェクト: nukeviet/nukeviet
    die;
}
if ($nv_Request->get_title('checksess', 'get', '') == md5('download' . $version . $package . NV_CHECK_SESSION)) {
    $xtpl = new XTemplate('getupdate.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
    $xtpl->assign('LANG', $lang_module);
    $NV_Http = new NukeViet\Http\Http($global_config, NV_TEMP_DIR);
    $filename = NV_TEMPNAM_PREFIX . 'sysupd_' . NV_CHECK_SESSION . '.zip';
    // Debug
    $args = array('headers' => array('Referer' => NUKEVIET_STORE_APIURL), 'stream' => true, 'filename' => NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename, 'body' => array('lang' => NV_LANG_INTERFACE, 'basever' => $global_config['version'], 'mode' => 'getsysupd', 'version' => $version, 'package' => $package), 'timeout' => 0);
    // Delete temp file if exists
    if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename)) {
        @nv_deletefile(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename);
    }
    $apidata = $NV_Http->post(NUKEVIET_STORE_APIURL, $args);
    if (!empty(NukeViet\Http\Http::$error)) {
        $error = nv_http_get_lang(NukeViet\Http\Http::$error);
    } elseif (empty($apidata['filename']) or !file_exists($apidata['filename'])) {
        $error = $lang_module['get_update_error_file_download'];
    }
    if (!empty($error)) {
        $xtpl->assign('ERROR', $error);
        $xtpl->parse('error');
        echo $xtpl->text('error');
    } else {
        $zip = new PclZip(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename);
        $ziplistContent = $zip->listContent();
        // Not exists (can not download)
        $warning = 2;
        if (!empty($ziplistContent)) {
            // Package ok
            $warning = 0;
コード例 #3
0
ファイル: download.php プロジェクト: lzhao18/nukeviet
} else {
    $array = array();
}
$request = array();
$request['id'] = isset($array['id']) ? intval($array['id']) : 0;
$request['fid'] = isset($array['compatible']['id']) ? intval($array['compatible']['id']) : 0;
// Fixed request
$request['lang'] = NV_LANG_INTERFACE;
$request['basever'] = $global_config['version'];
$request['mode'] = 'download';
if (empty($request['id']) or empty($request['fid']) or !isset($array['tid'])) {
    $contents = "ERR|" . $lang_module['download_error_preparam'];
} else {
    $filename = NV_TEMPNAM_PREFIX . 'auto_' . md5($global_config['sitekey'] . session_id()) . '.zip';
    require NV_ROOTDIR . '/includes/class/http.class.php';
    $NV_Http = new NV_Http($global_config, NV_TEMP_DIR);
    $args = array('headers' => array('Referer' => NUKEVIET_STORE_APIURL), 'stream' => true, 'filename' => NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename, 'body' => $request);
    // Delete temp file if exists
    if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename)) {
        @nv_deletefile(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename);
    }
    $array = $NV_Http->post(NUKEVIET_STORE_APIURL, $args);
    if (!empty(NV_Http::$error)) {
        $contents = "ERR|" . nv_http_get_lang(NV_Http::$error);
    } elseif (empty($array['filename']) or !file_exists($array['filename'])) {
        $contents = "ERR|" . $lang_module['download_error_save'];
    } else {
        $contents = 'OK|' . $filename;
    }
}
echo $contents;
コード例 #4
0
ファイル: getupdate.php プロジェクト: lzhao18/nukeviet
}
if ($nv_Request->get_title('checksess', 'get', '') == md5('download' . $version . $global_config['sitekey'] . session_id())) {
    $xtpl = new XTemplate('getupdate.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
    $xtpl->assign('LANG', $lang_module);
    require NV_ROOTDIR . '/includes/class/http.class.php';
    $NV_Http = new NV_Http($global_config, NV_TEMP_DIR);
    $filename = NV_TEMPNAM_PREFIX . 'sysupd_' . md5($global_config['sitekey'] . session_id()) . '.zip';
    // Debug
    $args = array('headers' => array('Referer' => NUKEVIET_STORE_APIURL), 'stream' => true, 'filename' => NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename, 'body' => array('lang' => NV_LANG_INTERFACE, 'basever' => $global_config['version'], 'mode' => 'getsysupd', 'version' => $version));
    // Delete temp file if exists
    if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename)) {
        @nv_deletefile(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename);
    }
    $apidata = $NV_Http->post(NUKEVIET_STORE_APIURL, $args);
    if (!empty(NV_Http::$error)) {
        $error = nv_http_get_lang(NV_Http::$error);
    } elseif (empty($apidata['filename']) or !file_exists($apidata['filename'])) {
        $error = $lang_module['get_update_error_file_download'];
    }
    if (!empty($error)) {
        $xtpl->assign('ERROR', $error);
        $xtpl->parse('error');
        echo $xtpl->text('error');
    } else {
        require_once NV_ROOTDIR . '/includes/class/pclzip.class.php';
        $zip = new PclZip(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename);
        $ziplistContent = $zip->listContent();
        $warning = false;
        // Check security
        foreach ($ziplistContent as $zipContent) {
            if (!preg_match("/^install\\//is", $zipContent['filename'])) {
コード例 #5
0
ファイル: download.php プロジェクト: nukeviet/nukeviet
    $array = @unserialize($array);
} else {
    $array = array();
}
$request = array();
$request['id'] = isset($array['id']) ? intval($array['id']) : 0;
$request['fid'] = isset($array['compatible']['id']) ? intval($array['compatible']['id']) : 0;
// Fixed request
$request['lang'] = NV_LANG_INTERFACE;
$request['basever'] = $global_config['version'];
$request['mode'] = 'download';
if (empty($request['id']) or empty($request['fid']) or !isset($array['tid'])) {
    $contents = "ERR|" . $lang_module['download_error_preparam'];
} else {
    $filename = NV_TEMPNAM_PREFIX . 'auto_' . NV_CHECK_SESSION . '.zip';
    $NV_Http = new NukeViet\Http\Http($global_config, NV_TEMP_DIR);
    $args = array('headers' => array('Referer' => NUKEVIET_STORE_APIURL), 'stream' => true, 'filename' => NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename, 'body' => $request, 'timeout' => 0);
    // Delete temp file if exists
    if (file_exists(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename)) {
        @nv_deletefile(NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . $filename);
    }
    $array = $NV_Http->post(NUKEVIET_STORE_APIURL, $args);
    if (!empty(NukeViet\Http\Http::$error)) {
        $contents = "ERR|" . nv_http_get_lang(NukeViet\Http\Http::$error);
    } elseif (empty($array['filename']) or !file_exists($array['filename']) or filesize($array['filename']) <= 0) {
        $contents = "ERR|" . $lang_module['download_error_save'];
    } else {
        $contents = 'OK|' . $filename;
    }
}
echo $contents;