示例#1
0
文件: main.php 项目: nukeplus/nuke
if ($request['mode'] != 'search') {
    $set_active_op = $request['mode'];
}
$xtpl = new XTemplate($op . '.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('REQUEST', $request);
$xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
$xtpl->assign('NV_LANG_VARIABLE', NV_LANG_VARIABLE);
$xtpl->assign('NV_LANG_DATA', NV_LANG_DATA);
$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
$xtpl->assign('MODULE_NAME', $module_name);
$NV_Http = new NukeViet\Http\Http($global_config, NV_TEMP_DIR);
$stored_cookies = nv_get_cookies();
// Debug
$args = array('headers' => array('Referer' => NUKEVIET_STORE_APIURL), 'cookies' => $stored_cookies, 'body' => $request);
$array = $NV_Http->post(NUKEVIET_STORE_APIURL, $args);
$cookies = $array['cookies'];
$array = !empty($array['body']) ? is_serialized_string($array['body']) ? unserialize($array['body']) : array() : array();
$error = '';
if (!empty(NukeViet\Http\Http::$error)) {
    $error = nv_http_get_lang(NukeViet\Http\Http::$error);
} elseif (empty($array['status']) or !isset($array['error']) or !isset($array['data']) or !isset($array['pagination']) or !is_array($array['error']) or !is_array($array['data']) or !is_array($array['pagination']) or !empty($array['error']) and (!isset($array['error']['level']) or empty($array['error']['message']))) {
    $error = $lang_global['error_valid_response'];
} elseif (!empty($array['error']['message'])) {
    $error = $array['error']['message'];
}
// Show error
if (!empty($error)) {
    $xtpl->assign('ERROR', $error);
    $xtpl->parse('main.error');
} elseif ($array['status'] == 'notlogin') {
示例#2
0
        echo $xtpl->text('complete');
    }
    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)) {
示例#3
0
/**
 * 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)) {
            $NV_Http = new NukeViet\Http\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(NukeViet\Http\Http::$error)) {
                $error = nv_http_get_lang(NukeViet\Http\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;
}