本文整理汇总了PHP中get_remote_file函数 的典型用法代码示例。如果您正苦于以下问题:PHP get_remote_file函数的具体用法?PHP get_remote_file怎么用?PHP get_remote_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_remote_file函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('install');
$this->tpl_name = 'acp_update';
$this->page_title = 'ACP_VERSION_CHECK';
// Get current and latest version
$errstr = '';
$errno = 0;
$info = get_remote_file('www.phpbb.com', '/updatecheck', defined('PHPBB_QA') ? '30x_qa.txt' : '30x.txt', $errstr, $errno);
if ($info === false) {
trigger_error($errstr, E_USER_WARNING);
}
$info = explode("\n", $info);
$latest_version = trim($info[0]);
$announcement_url = trim($info[1]);
$update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update');
// Determine automatic update...
$sql = 'SELECT config_value
FROM ' . CONFIG_TABLE . "\n\t\t\tWHERE config_name = 'version_update_from'";
$result = $db->sql_query($sql);
$version_update_from = (string) $db->sql_fetchfield('config_value');
$db->sql_freeresult($result);
$current_version = !empty($version_update_from) ? $version_update_from : $config['version'];
$up_to_date_automatic = version_compare(str_replace('rc', 'RC', strtolower($current_version)), str_replace('rc', 'RC', strtolower($latest_version)), '<') ? false : true;
$up_to_date = version_compare(str_replace('rc', 'RC', strtolower($config['version'])), str_replace('rc', 'RC', strtolower($latest_version)), '<') ? false : true;
$template->assign_vars(array('S_UP_TO_DATE' => $up_to_date, 'S_UP_TO_DATE_AUTO' => $up_to_date_automatic, 'S_VERSION_CHECK' => true, 'U_ACTION' => $this->u_action, 'LATEST_VERSION' => $latest_version, 'CURRENT_VERSION' => $config['version'], 'AUTO_VERSION' => $version_update_from, 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link)));
}
开发者ID:jvinhit, 项目名称:php, 代码行数:29, 代码来源:acp_update.php
示例2: main
function main($id, $mode)
{
global $user, $template;
global $phpbb_admin_path, $phpEx;
$phpbb_root_path = '';
// mpv fix?
$phpEx = '';
// mpv fix?
$this->tpl_name = 'acp_version_check';
$this->page_title = 'ACP_MOD_VERSION_CHECK';
// load version files
$class_functions = array();
$mod_directory = $phpbb_admin_path . 'mods/';
$dh = @opendir($mod_directory);
if (!$dh) {
trigger_error('NO_ACCESS_MODS_DIRECTORY');
}
while (($file = readdir($dh)) !== false) {
if (preg_match('/^(.+)_version.' . $phpEx . '$/', $file)) {
include $phpbb_root_path . $mod_directory . $file . $phpEx;
$class_name = substr($file, 0, -(strlen($phpEx) + 1));
$class_functions[] = call_user_func(array($class_name, 'version'));
}
}
closedir($dh);
foreach ($class_functions as $var) {
// Get current and latest version
$errstr = '';
$errno = 0;
$mod_version = $user->lang['NO_INFO'];
$data = array('title' => $var['title'], 'description' => $user->lang['NO_INFO'], 'download' => $user->lang['NO_INFO'], 'announcement' => $user->lang['NO_INFO']);
$file = get_remote_file($var['file'][0], '/' . $var['file'][1], $var['file'][2], $errstr, $errno);
if ($file) {
if (version_compare(PHP_VERSION, '5.0.0', '<')) {
$row = array();
$data_array = $this->setup_array($file);
$row = $data_array['mods'][$var['tag']];
$mod_version = $row['mod_version'];
$mod_version = $mod_version['major'] . '.' . $mod_version['minor'] . '.' . $mod_version['revision'] . $mod_version['release'];
$data = array('title' => $row['title'], 'description' => $row['description'], 'download' => $row['download'], 'announcement' => $row['announcement']);
} else {
// let's not stop the page from loading if a mod author messed up their mod check file
// also take care of one of the easiest ways to mess up an xml file: "&"
$mod = @simplexml_load_string(str_replace('&', '&', $file));
if (isset($mod->{$var}['tag'])) {
$row = $mod->{$var}['tag'];
$mod_version = $row->mod_version->major . '.' . $row->mod_version->minor . '.' . $row->mod_version->revision . $row->mod_version->release;
$data = array('title' => $row->title, 'description' => $row->description, 'download' => $row->download, 'announcement' => $row->announcement);
}
}
}
// remove spaces from the version in the mod file stored locally
$version = str_replace(' ', '', $var['version']);
$version_compare = version_compare($version, $mod_version, '<') ? false : true;
$template->assign_block_vars('mods', array('ANNOUNCEMENT' => $data['announcement'], 'AUTHOR' => $var['author'], 'CURRENT_VERSION' => $version, 'DESCRIPTION' => $data['description'], 'DOWNLOAD' => $data['download'], 'LATEST_VERSION' => $mod_version, 'TITLE' => $data['title'], 'UP_TO_DATE' => sprintf(!$version_compare ? $user->lang['NOT_UP_TO_DATE'] : $user->lang['UP_TO_DATE'], $data['title']), 'S_UP_TO_DATE' => $version_compare, 'U_AUTHOR' => 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&un=' . $var['author']));
}
}
开发者ID:phpbbireland, 项目名称:stargate-portal, 代码行数:57, 代码来源:acp_k_version_check.php
示例3: __construct
public function __construct()
{
global $db, $template, $user;
global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config;
if ($qi_config['version_check']) {
// we use this for get_remote_file()
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
// Get current and latest version
$errstr = '';
$errno = 0;
$info = get_remote_file('phpbbmodders.net', '/files/updatecheck', 'quickinstall.txt', $errstr, $errno);
if ($info !== false) {
list($latest_version, $announcement_url) = explode("\n", $info);
$up_to_date = version_compare(str_replace('rc', 'RC', strtolower($qi_config['qi_version'])), str_replace('rc', 'RC', strtolower($latest_version)), '<') ? false : true;
$template->assign_vars(array('UP_TO_DATE' => $up_to_date, 'L_UPDATE' => sprintf($user->lang['UPDATE_TO'], $announcement_url, $latest_version)));
}
}
$changelog_file = $quickinstall_path . 'changelog.xml';
if ($use_changelog = file_exists($changelog_file)) {
// let's get the changelog :)
$automod_path = '';
if (file_exists($quickinstall_path . 'sources/automod/includes')) {
// Let's assume they copied the contents.
$automod_path = $quickinstall_path . 'sources/automod/';
} else {
if (file_exists($quickinstall_path . 'sources/automod/root/includes')) {
// They copied to complete root to automod instead of its contents.
$automod_path = $quickinstall_path . 'sources/automod/root/';
} else {
if (file_exists($quickinstall_path . 'sources/automod/upload/includes')) {
// They copied to complete upload directory to automod instead of its contents.
$automod_path = $quickinstall_path . 'sources/automod/upload/';
} else {
trigger_error($user->lang['NO_AUTOMOD']);
}
}
}
include $automod_path . 'includes/mod_parser.' . $phpEx;
$xml_parser = new xml_array();
$data = $xml_parser->parse($changelog_file, file_get_contents($changelog_file));
foreach ($data[0]['children']['ENTRY'] as &$entry) {
list($year, $month, $day) = explode('-', $entry['children']['DATE'][0]['data']);
$template->assign_block_vars('history', array('DATE' => qi::format_date(mktime(null, null, null, intval($month), intval($day), intval($year)), 'Y-m-d'), 'VERSION' => $entry['children']['VERSION'][0]['data']));
foreach ($entry['children']['CHANGELOG'][0]['children']['CHANGE'] as &$change) {
$template->assign_block_vars('history.changelog', array('CHANGE' => htmlspecialchars($change['data'])));
}
}
}
$template->assign_vars(array('S_IN_INSTALL' => false, 'S_IN_SETTINGS' => false, 'S_ALLOW_VERSION_CHECK' => $qi_config['version_check'], 'S_ALLOW_CHANGELOG' => $use_changelog, 'PAGE_MAIN' => false));
// Output page
qi::page_header($user->lang['QI_ABOUT'], $user->lang['QI_ABOUT_ABOUT']);
$template->set_filenames(array('body' => 'about_body.html'));
qi::page_footer();
}
开发者ID:Gfksx, 项目名称:quickinstall, 代码行数:54, 代码来源:qi_about.php
示例4: scrape
function scrape($url, $infohash = '')
{
global $TABLE_PREFIX;
if (isset($url)) {
$extannunce = str_replace('announce', 'scrape', urldecode($url));
if ($infohash != '') {
$ihash = array();
$ihash = explode('\',\'', $infohash);
$info_hash = '';
foreach ($ihash as $myihash) {
$info_hash .= '&info_hash=' . escapeURL($myihash);
}
$info_hash = substr($info_hash, 1);
$stream = get_remote_file($extannunce . '?' . $info_hash);
} else {
$stream = get_remote_file($extannunce);
}
$stream = trim(stristr($stream, 'd5:files'));
if (strpos($stream, 'd5:files') === false) {
$ret = do_sqlquery('UPDATE ' . $TABLE_PREFIX . 'files SET lastupdate=NOW() WHERE announce_url="' . $url . '"' . ($infohash == '' ? '' : ' AND info_hash IN ("' . $infohash . '")'));
write_log('FAILED update external torrent ' . ($infohash == '' ? '' : '(infohash: ' . $infohash . ')') . ' from ' . $url . ' tracker (not connectable)', '');
return;
}
$array = BDecode($stream);
if (!isset($array) || $array == false || !isset($array['files'])) {
$ret = do_sqlquery('UPDATE ' . $TABLE_PREFIX . 'files SET lastupdate=NOW() WHERE announce_url="' . $url . '"' . ($infohash == '' ? '' : ' AND info_hash IN ("' . $infohash . '")'));
write_log('FAILED update external torrent ' . ($infohash == '' ? '' : '(infohash: ' . $infohash . ')') . ' from ' . $url . ' tracker (not bencode data)', '');
return;
}
$files = $array['files'];
if (!is_array($files)) {
$ret = do_sqlquery('UPDATE ' . $TABLE_PREFIX . 'files SET lastupdate=NOW() WHERE announce_url="' . $url . '"' . ($infohash = '' ? '' : ' AND info_hash IN ("' . $infohash . '")'));
write_log('FAILED update external torrent ' . ($infohash == '' ? '' : '(infohash: ' . $infohash . ')') . ' from ' . $url . ' tracker (probably deleted torrent(s))', '');
return;
}
foreach ($files as $hash => $data) {
$seeders = $data['complete'];
$leechers = $data['incomplete'];
$completed = isset($data['downloaded']) ? $data['downloaded'] : 0;
$torrenthash = bin2hex(stripslashes($hash));
$ret = do_sqlquery('UPDATE ' . $TABLE_PREFIX . 'files SET lastupdate=NOW(), lastsuccess=NOW(), seeds=' . $seeders . ', leechers=' . $leechers . ', finished=' . $completed . ' WHERE announce_url = "' . $url . '"' . ($hash == '' ? '' : ' AND info_hash="' . $torrenthash . '";'));
if (mysql_affected_rows() == 1) {
write_log('SUCCESS update external torrent from ' . $url . ' tracker (infohash: ' . $torrenthash . ')', '');
}
}
}
}
开发者ID:wilian32, 项目名称:xbtit, 代码行数:47, 代码来源:getscrape.php
示例5: test_version_phpbb_com
public function test_version_phpbb_com()
{
$hostname = 'version.phpbb.com';
if (!phpbb_checkdnsrr($hostname, 'A')) {
$this->markTestSkipped(sprintf('Could not find a DNS record for hostname %s. ' . 'Assuming network is down.', $hostname));
}
$errstr = $errno = null;
$file = get_remote_file($hostname, '/phpbb', '30x.txt', $errstr, $errno);
$this->assertNotEquals(0, strlen($file), 'Failed asserting that the response is not empty.');
$this->assertSame('', $errstr, 'Failed asserting that the error string is empty.');
$this->assertSame(0, $errno, 'Failed asserting that the error number is 0 (i.e. no error occurred).');
$lines = explode("\n", $file);
$this->assertGreaterThanOrEqual(2, sizeof($lines), 'Failed asserting that the version file has at least two lines.');
$this->assertStringStartsWith('3.', $lines[0], "Failed asserting that the first line of the version file starts with '3.'");
$this->assertNotSame(false, filter_var($lines[1], FILTER_VALIDATE_URL), 'Failed asserting that the second line of the version file is a valid URL.');
$this->assertContains('http', $lines[1]);
$this->assertContains('phpbb.com', $lines[1], '', true);
}
开发者ID:josh-js, 项目名称:phpbb, 代码行数:18, 代码来源:get_remote_file_test.php
示例6: check
/**
* A copy of Handyman` s MOD version check, to view it on the gallery overview
*/
public static function check($return_version = false)
{
global $user, $template;
global $phpbb_admin_path, $phpEx;
if (!function_exists('get_remote_file')) {
global $phpbb_root_path;
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
if (!$phpbb_admin_path || !is_dir($phpbb_admin_path)) {
global $phpbb_root_path;
$phpbb_admin_path = $phpbb_root_path . 'adm/';
}
// load version files
$class_functions = array();
include $phpbb_admin_path . 'mods/phpbb_gallery_version.' . $phpEx;
$class_name = 'phpbb_gallery_version';
$var = call_user_func(array($class_name, 'version'));
// Get current and latest version
$errstr = '';
$errno = 0;
$mod_version = '0.0.0';
if (!$return_version) {
$mod_version = $user->lang['NO_INFO'];
$data = array('title' => $var['title'], 'description' => $user->lang['NO_INFO'], 'download' => $user->lang['NO_INFO'], 'announcement' => $user->lang['NO_INFO']);
}
$file = get_remote_file($var['file'][0], '/' . $var['file'][1], $var['file'][2], $errstr, $errno);
if ($file) {
// let's not stop the page from loading if a mod author messed up their mod check file
// also take care of one of the easiest ways to mess up an xml file: "&"
$mod = @simplexml_load_string(str_replace('&', '&', $file));
if (isset($mod->{$var}['tag'])) {
$row = $mod->{$var}['tag'];
$mod_version = $row->mod_version->major . '.' . $row->mod_version->minor . '.' . $row->mod_version->revision . $row->mod_version->release;
$data = array('title' => $row->title, 'description' => $row->description, 'download' => $row->download, 'announcement' => $row->announcement);
}
}
// remove spaces from the version in the mod file stored locally
$version = str_replace(' ', '', $var['version']);
if ($return_version) {
return $mod_version;
}
$version_compare = version_compare($version, $mod_version, '<') ? false : true;
$template->assign_block_vars('mods', array('ANNOUNCEMENT' => $data['announcement'], 'AUTHOR' => $var['author'], 'CURRENT_VERSION' => $version, 'DESCRIPTION' => $data['description'], 'DOWNLOAD' => $data['download'], 'LATEST_VERSION' => $mod_version, 'TITLE' => $data['title'], 'UP_TO_DATE' => sprintf(!$version_compare ? $user->lang['NOT_UP_TO_DATE'] : $user->lang['UP_TO_DATE'], $data['title']), 'S_UP_TO_DATE' => $version_compare, 'U_AUTHOR' => 'http://www.phpbb.com/community/memberlist.php?mode=viewprofile&un=' . $var['author']));
}
开发者ID:phpbbgallery, 项目名称:phpbb-gallery, 代码行数:47, 代码来源:modversioncheck.php
示例7: check_version
public function check_version()
{
global $db, $template;
$url = 'phpbbireland.com';
$sub = 'kiss2/updates';
$file = 'portal.xml';
$errstr = '';
$errno = 0;
$data = array();
$data_read = get_remote_file($url, '/' . $sub, $file, $errstr, $errno);
$mod = @simplexml_load_string(str_replace('&', '&', $data_read));
if (isset($mod->version_check)) {
$row = $mod->version_check;
$version = $row->version->major[0] . '.' . $row->version->minor[0] . '.' . $row->version->revision[0];
$data = array('title' => $row->title[0], 'description' => $row->description[0], 'download' => $row->download, 'announcement' => $row->announcement, 'version' => $version);
return $data;
}
return null;
}
开发者ID:phpbbireland, 项目名称:portal, 代码行数:19, 代码来源:config_module.php
示例8: fetch_gravatar
public function fetch_gravatar()
{
$gravatar_url = $this->generate_gravatar_url();
$gravatar_data = get_remote_file($gravatar_url, 10, FALSE, 2);
if (!empty($gravatar_data) && !empty($gravatar_data['content'])) {
try {
$tmpfname = tempnam("/tmp", "GRAVATAR-" . md5($this->get_user_email()));
$handle = @fopen($tmpfname, "w");
if ($handle !== FALSE) {
fwrite($handle, $gravatar_data['content']);
fclose($handle);
$this->save_gravatar($tmpfname);
} else {
throw new Exception("Fancy_gravatar: can not open temporary file for writing.");
}
} catch (Exception $exception) {
if (!empty($tmpfname) && file_exists($tmpfname)) {
unlink($tmpfname);
}
}
}
}
开发者ID:mdb-webdev, 项目名称:Fancy-Extensions, 代码行数:22, 代码来源:fancy_gravatar.inc.php
示例9: shareon_version_compare
/**
* Obtains the latest version information
* @param string $current_version version information
* @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours).
*
* @return bool false on failure.
**/
function shareon_version_compare($current_version = '', $version_up_to_date = true, $ttl = 86400)
{
global $cache, $template;
$info = $cache->get('shareon_versioncheck');
if ($info === false) {
$errstr = '';
$errno = 0;
$info = get_remote_file('www.suportephpbb.com.br', '/shareon', 'shareon.txt', $errstr, $errno);
if ($info === false) {
$template->assign_var('S_VERSIONCHECK_FAIL', true);
$cache->destroy('shareon_versioncheck');
}
}
if ($info !== false) {
$cache->put('shareon_versioncheck', $info, $ttl);
$latest_version_info = explode("\n", $info);
$latest_version = strtolower(trim($latest_version_info[0]));
$current_version = strtolower(trim($current_version));
$version_up_to_date = version_compare($current_version, $latest_version, '<') ? false : true;
$template->assign_vars(array('U_VERSIONCHECK' => $version_up_to_date ? false : $latest_version_info[1], 'S_VERSIONOLD' => $current_version, 'S_VERSIONNEW' => $version_up_to_date ? false : $latest_version_info[0]));
}
return $version_up_to_date;
}
开发者ID:Galixte, 项目名称:share-on, 代码行数:30, 代码来源:acp_shareon.php
示例10: get_file
/**
* Get remote file
*/
function get_file($mode)
{
global $user, $db;
$errstr = '';
$errno = 0;
switch ($mode) {
case 'version_info':
global $phpbb_root_path, $phpEx;
$info = get_remote_file('www.phpbbgarage.com', '/updatecheck', '30x.txt', $errstr, $errno);
if ($info !== false) {
$info = explode("\n", $info);
$info = trim($info[0]);
}
if ($this->test_update !== false) {
$info = $this->test_update;
}
// If info is false the fsockopen function may not be working. Instead get the latest version from our update file (and pray it is up-to-date)
if ($info === false) {
$update_info = array();
include $phpbb_root_path . 'garage/install/update/index.php';
$info = empty($update_info) || !is_array($update_info) ? false : $update_info;
if ($info !== false) {
$info = !empty($info['version']['to']) ? trim($info['version']['to']) : false;
}
}
break;
case 'install_info':
global $phpbb_root_path, $phpEx;
$install_info = array();
include $phpbb_root_path . 'garage/install/install/index.php';
//Handle the installed & supported style themes
$sql = 'SELECT *
FROM ' . STYLES_THEME_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
//Check For Imageset Data To Load
if (file_exists($phpbb_root_path . "garage/install/install/styles/{$row['theme_path']}/theme/index." . $phpEx)) {
$theme_info = array();
include $phpbb_root_path . "garage/install/install/styles/{$row['theme_path']}/theme/index." . $phpEx;
$install_info['files'] = array_merge($install_info['files'], $theme_info['files']);
}
}
$db->sql_freeresult($result);
//Handle the installed & supported style template
$sql = 'SELECT *
FROM ' . STYLES_TEMPLATE_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
//Check For Imageset Data To Load
if (file_exists($phpbb_root_path . "garage/install/install/styles/{$row['template_path']}/template/index." . $phpEx)) {
$template_info = array();
include $phpbb_root_path . "garage/install/install/styles/{$row['template_path']}/template/index." . $phpEx;
$install_info['files'] = array_merge($install_info['files'], $template_info['files']);
}
}
$db->sql_freeresult($result);
//Handle the installed & supported style imagesets
$sql = 'SELECT *
FROM ' . STYLES_IMAGESET_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
//Check For Imageset Data To Load
if (file_exists($phpbb_root_path . "garage/install/install/styles/{$row['imageset_name']}/imageset/index." . $phpEx)) {
$imageset_info = array();
include $phpbb_root_path . "garage/install/install/styles/{$row['imageset_name']}/imageset/index." . $phpEx;
$install_info['files'] = array_merge($install_info['files'], $imageset_info['files']);
}
//Check For All Installed Languages
$sql = 'SELECT *
FROM ' . LANG_TABLE;
$lresult = $db->sql_query($sql);
while ($lrow = $db->sql_fetchrow($lresult)) {
//Check For Imageset Data To Load
if (file_exists($phpbb_root_path . "garage/install/install/styles/{$row['imageset_name']}/imageset/{$lrow['lang_dir']}/index." . $phpEx)) {
$imageset_info = array();
include $phpbb_root_path . "garage/install/install/styles/{$row['imageset_name']}/imageset/{$lrow['lang_dir']}/index." . $phpEx;
$install_info['files'] = array_merge($install_info['files'], $imageset_info['files']);
}
}
$db->sql_freeresult($lresult);
}
$db->sql_freeresult($result);
$info = empty($install_info) || !is_array($install_info) ? false : $install_info;
$errstr = $info === false ? $user->lang['WRONG_INFO_FILE_FORMAT'] : '';
if ($info !== false) {
// Adjust the update info file to hold some specific style-related information
$info['custom'] = array();
/*
// Get custom installed styles...
$sql = 'SELECT template_name, template_path
FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')";
$result = $db->sql_query($sql);
$templates = array();
while ($row = $db->sql_fetchrow($result))
{
//.........这里部分代码省略.........
开发者ID:poyntesm, 项目名称:phpbbgarage, 代码行数:101, 代码来源:install_install.php
示例11: get_remote_file
function get_remote_file($url, $timeout, $head_only = false, $max_redirects = 10)
{
$result = null;
$parsed_url = parse_url($url);
$allow_url_fopen = strtolower(@ini_get('allow_url_fopen'));
// Quite unlikely that this will be allowed on a shared host, but it can't hurt
if (function_exists('ini_set')) {
@ini_set('default_socket_timeout', $timeout);
}
// If we have cURL, we might as well use it
if (function_exists('curl_init')) {
// Setup the transfer
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, $head_only);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, 'PunBB');
// Grab the page
$content = @curl_exec($ch);
$responce_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Process 301/302 redirect
if ($content !== false && ($responce_code == '301' || $responce_code == '302') && $max_redirects > 0) {
$headers = explode("\r\n", trim($content));
foreach ($headers as $header) {
if (substr($header, 0, 10) == 'Location: ') {
$responce = get_remote_file(substr($header, 10), $timeout, $head_only, $max_redirects - 1);
if ($responce !== null) {
$responce['headers'] = array_merge($headers, $responce['headers']);
}
return $responce;
}
}
}
// Ignore everything except a 200 response code
if ($content !== false && $responce_code == '200') {
if ($head_only) {
$result['headers'] = explode("\r\n", str_replace("\r\n\r\n", "\r\n", trim($content)));
} else {
preg_match('#HTTP/1.[01] 200 OK#', $content, $match, PREG_OFFSET_CAPTURE);
$last_content = substr($content, $match[0][1]);
$content_start = strpos($last_content, "\r\n\r\n");
if ($content_start !== false) {
$result['headers'] = explode("\r\n", str_replace("\r\n\r\n", "\r\n", substr($content, 0, $match[0][1] + $content_start)));
$result['content'] = substr($last_content, $content_start + 4);
}
}
}
} else {
if (function_exists('fsockopen')) {
$remote = @fsockopen($parsed_url['host'], !empty($parsed_url['port']) ? intval($parsed_url['port']) : 80, $errno, $errstr, $timeout);
if ($remote) {
// Send a standard HTTP 1.0 request for the page
fwrite($remote, ($head_only ? 'HEAD' : 'GET') . ' ' . (!empty($parsed_url['path']) ? $parsed_url['path'] : '/') . (!empty($parsed_url['query']) ? '?' . $parsed_url['query'] : '') . ' HTTP/1.0' . "\r\n");
fwrite($remote, 'Host: ' . $parsed_url['host'] . "\r\n");
fwrite($remote, 'User-Agent: PunBB' . "\r\n");
fwrite($remote, 'Connection: Close' . "\r\n\r\n");
stream_set_timeout($remote, $timeout);
$stream_meta = stream_get_meta_data($remote);
// Fetch the response 1024 bytes at a time and watch out for a timeout
$content = false;
while (!feof($remote) && !$stream_meta['timed_out']) {
$content .= fgets($remote, 1024);
$stream_meta = stream_get_meta_data($remote);
}
fclose($remote);
// Process 301/302 redirect
if ($content !== false && $max_redirects > 0 && preg_match('#^HTTP/1.[01] 30[12]#', $content)) {
$headers = explode("\r\n", trim($content));
foreach ($headers as $header) {
if (substr($header, 0, 10) == 'Location: ') {
$responce = get_remote_file(substr($header, 10), $timeout, $head_only, $max_redirects - 1);
if ($responce !== null) {
$responce['headers'] = array_merge($headers, $responce['headers']);
}
return $responce;
}
}
}
// Ignore everything except a 200 response code
if ($content !== false && preg_match('#^HTTP/1.[01] 200 OK#', $content)) {
if ($head_only) {
$result['headers'] = explode("\r\n", trim($content));
} else {
$content_start = strpos($content, "\r\n\r\n");
if ($content_start !== false) {
$result['headers'] = explode("\r\n", substr($content, 0, $content_start));
$result['content'] = substr($content, $content_start + 4);
}
}
}
}
} else {
if (in_array($allow_url_fopen, array('on', 'true', '1'))) {
// PHP5's version of file_get_contents() supports stream options
if (version_compare(PHP_VERSION, '5.0.0', '>=')) {
// Setup a stream context
//.........这里部分代码省略.........
开发者ID:torepublicStartpageCode, 项目名称:torepublic2, 代码行数:101, 代码来源:functions.php
示例12: message
message($lang_admin_ext['No XML support']);
}
$section = isset($_GET['section']) ? $_GET['section'] : null;
// Install an extension
if (isset($_GET['install']) || isset($_GET['install_hotfix'])) {
($hook = get_hook('aex_install_selected')) ? eval($hook) : null;
// User pressed the cancel button
if (isset($_POST['install_cancel'])) {
redirect(forum_link(isset($_GET['install']) ? $forum_url['admin_extensions_manage'] : $forum_url['admin_extensions_hotfixes']), $lang_admin_common['Cancel redirect']);
}
$id = preg_replace('/[^0-9a-z_]/', '', isset($_GET['install']) ? $_GET['install'] : $_GET['install_hotfix']);
// Load manifest (either locally or from punbb.informer.com updates service)
if (isset($_GET['install'])) {
$manifest = is_readable(FORUM_ROOT . 'extensions/' . $id . '/manifest.xml') ? file_get_contents(FORUM_ROOT . 'extensions/' . $id . '/manifest.xml') : false;
} else {
$remote_file = get_remote_file('http://punbb.informer.com/update/manifest/' . $id . '.xml', 16);
if (!empty($remote_file['content'])) {
$manifest = $remote_file['content'];
}
}
// Parse manifest.xml into an array and validate it
$ext_data = xml_to_array($manifest);
$errors = validate_manifest($ext_data, $id);
if (!empty($errors)) {
message(isset($_GET['install']) ? $lang_common['Bad request'] : $lang_admin_ext['Hotfix download failed']);
}
// Get core amd major versions
if (!defined('FORUM_DISABLE_EXTENSIONS_VERSION_CHECK')) {
list($forum_version_core, $forum_version_major) = explode('.', clean_version($forum_config['o_cur_version']));
list($extension_maxtestedon_version_core, $extension_maxtestedon_version_major) = explode('.', clean_version($ext_data['extension']['maxtestedon']));
if (version_compare($forum_version_core . '.' . $forum_version_major, $extension_maxtestedon_version_core . '.' . $extension_maxtestedon_version_major, '>')) {
开发者ID:torepublicStartpageCode, 项目名称:torepublic2, 代码行数:31, 代码来源:extensions.php
示例13: obtain_latest_version_info
/**
* Obtains the latest version information
*
* @param bool $force_update Ignores cached data. Defaults to false.
* @param bool $warn_fail Trigger a warning if obtaining the latest version information fails. Defaults to false.
* @param int $ttl Cache version information for $ttl seconds. Defaults to 86400 (24 hours).
*
* @return string | false Version info on success, false on failure.
*/
function obtain_latest_version_info($force_update = false, $warn_fail = false, $ttl = 86400)
{
global $cache;
$info = $cache->get('versioncheck');
if ($info === false || $force_update) {
$errstr = '';
$errno = 0;
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
global $config;
$url = 'www.phpbb-seo.com';
$dir = (strpos($config['default_lang'], 'fr') !== false ? '/fr' : '/en') . '/updatecheck';
$info = get_remote_file($url, $dir, defined('PHPBB_SEO_QA') ? 'test_30x.txt' : 'premod_30x.txt', $errstr, $errno);
//$info = get_remote_file('version.phpbb.com', '/phpbb',
// ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);
// www.phpBB-SEO.com SEO TOOLKIT END
if ($info === false) {
$cache->destroy('versioncheck');
if ($warn_fail) {
trigger_error($errstr, E_USER_WARNING);
}
return false;
}
$cache->put('versioncheck', $info, $ttl);
}
return $info;
}
开发者ID:Ibrahim-Abdelkader, 项目名称:phpbb3, 代码行数:35, 代码来源:functions_admin.php
示例14: main
function main($id, $mode)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang(array('acp/board', 'acp/mods/ajax_shoutbox'));
require $phpbb_root_path . 'includes/functions_shoutbox.' . $phpEx;
$action = request_var('action', '');
$submit = isset($_POST['submit']) ? true : false;
$form_key = 'acp_shoutbox';
add_form_key($form_key);
$this->tpl_name = 'acp_shoutbox';
/**
* Validation types are:
* string, int, bool,
* script_path (absolute path in url - beginning with / and no trailing slash),
* rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
*/
switch ($mode) {
case 'settings':
$this->tpl_name = 'acp_board';
$display_vars = array('title' => 'ACP_SHOUTBOX_SETTINGS', 'vars' => array('legend1' => 'GENERAL_SETTINGS', 'as_prune' => array('lang' => 'AS_PRUNE_TIME', 'validate' => 'int', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['HOURS']), 'as_max_posts' => array('lang' => 'AS_MAX_POSTS', 'validate' => 'int', 'type' => 'text:3:10', 'explain' => true), 'as_flood_interval' => array('lang' => 'AS_FLOOD_INTERVAL', 'validate' => 'int', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'as_ie_nr' => array('lang' => 'AS_IE_NR', 'validate' => 'int', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['MESSAGES']), 'as_non_ie_nr' => array('lang' => 'AS_NON_IE_NR', 'validate' => 'int', 'type' => 'text:3:10', 'explain' => true, 'append' => ' ' . $user->lang['MESSAGES'])));
break;
case 'overview':
$this->page_title = 'ACP_SHOUTBOX_OVERVIEW';
$action = request_var('action', '');
if ($action) {
if (!confirm_box(true)) {
switch ($action) {
default:
$confirm = true;
$confirm_lang = 'CONFIRM_OPERATION';
}
if ($confirm) {
confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action)));
}
} else {
switch ($action) {
case 'purge':
$sql = 'DELETE FROM ' . SHOUTBOX_TABLE;
$db->sql_query($sql);
add_log('admin', 'LOG_PURGE_SHOUTBOX');
break;
}
}
}
// Get current and latest version
$errstr = '';
$errno = 0;
$info = get_remote_file('www.paulscripts.nl', '/', 'shoutbox.txt', $errstr, $errno);
if ($info !== false) {
$info = explode("\n", $info);
$latest_version = trim($info[0]);
$up_to_date = version_compare(str_replace('rc', 'RC', strtolower(VERSION)), str_replace('rc', 'RC', strtolower($latest_version)), '<') ? false : true;
if (!$up_to_date) {
$template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['NEW_VERSION'], VERSION, $latest_version, trim($info[1]))));
}
} else {
$template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['UNABLE_CONNECT'], $errstr)));
}
$sql = 'SELECT COUNT(shout_id) as total FROM ' . SHOUTBOX_TABLE;
$result = $db->sql_query($sql);
$total_posts = $db->sql_fetchfield('total', $result);
$template->assign_vars(array('TOTAL_POSTS' => $total_posts, 'AS_VERSION' => VERSION, 'U_ACTION' => append_sid($this->u_action)));
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
if ($mode == 'settings') {
if (isset($display_vars['lang'])) {
$user->add_lang($display_vars['lang']);
}
$this->new_config = $config;
$cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key)) {
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error)) {
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $config_name => $null) {
if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
continue;
}
$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
if ($submit) {
set_config($config_name, $config_value);
}
}
if ($submit) {
add_log('admin', 'LOG_AS_CONFIG_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_board';
$this->page_title = $display_vars['title'];
//.........这里部分代码省略.........
开发者ID:paul999, 项目名称:ajax-shoutbox, 代码行数:101, 代码来源:acp_shoutbox.php
示例15: get_file
/**
* Get remote file
*/
function get_file($mode)
{
global $user, $db;
$errstr = '';
$errno = 0;
switch ($mode)
{
case 'version_info':
global $phpbb_root_path, $phpEx;
$info = get_remote_file('www.phpbb.com', '/updatecheck', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno);
if ($info !== false)
{
$info = explode("\n", $info);
$info = trim($info[0]);
}
if ($this->test_update !== false)
{
$info = $this->test_update;
}
// If info is false the fsockopen function may not be working. Instead get the latest version from our update file (and pray it is up-to-date)
if ($info === false)
{
$update_info = array();
include($phpbb_root_path . 'install/update/index.php');
$info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
if ($info !== false)
{
$info = (!empty($info['version']['to'])) ? trim($info['version']['to']) : false;
}
}
break;
case 'update_info':
global $phpbb_root_path, $phpEx;
$update_info = array();
include($phpbb_root_path . 'install/update/index.php');
$info = (empty($update_info) || !is_array($update_info)) ? false : $update_info;
$errstr = ($info === false) ? $user->lang['WRONG_INFO_FILE_FORMAT'] : '';
if ($info !== false)
{
// Adjust the update info file to hold some specific style-related information
$info['custom'] = array();
/*
// Get custom installed styles...
$sql = 'SELECT template_name, template_path
FROM ' . STYLES_TEMPLATE_TABLE . "
WHERE LOWER(template_name) NOT IN ('subsilver2', 'prosilver')";
$result = $db->sql_query($sql);
$templates = array();
while ($row = $db->sql_fetchrow($result))
{
$templates[] = $row;
}
$db->sql_freeresult($result);
if (sizeof($templates))
{
foreach ($info['files'] as $filename)
{
// Template update?
if (strpos(strtolower($filename), 'styles/prosilver/template/') === 0)
{
foreach ($templates as $row)
{
$info['custom'][$filename][] = str_replace('/prosilver/', '/' . $row['template_path'] . '/', $filename);
}
}
}
}
*/
}
break;
default:
trigger_error('Mode for getting remote file not specified', E_USER_ERROR);
break;
}
if ($info === false)
{
trigger_error($errstr, E_USER_ERROR);
}
return $info;
}
开发者ID:BackupTheBerlios, 项目名称:phpbb-hu-svn, 代码行数:98, 代码来源:install_update.php
代码如下//ex11_4_word_transform.cpp:定义控制台应用程序的入口点。//#includeamp;qu
阅读:918| 2022-07-18
PacktPublishing/Python-Machine-Learning-Second-Edition: Python Machine Learning
阅读:975| 2022-08-18
一、通过url传递参数,但由于navigateTo无法跳转到导航页,所以无法往导航页传递参数
阅读:538| 2022-07-18
armancodv/building-energy-model-matlab: It is a small software which is develope
阅读:1167| 2022-08-17
win7系统电脑使用过程中有不少朋友表示遇到过win7系统USB驱动器RAM的状况,当出现win7
阅读:891| 2022-11-06
使用Excel最好用Comobj方式,它能够达到完全控制excel的目的。不过这种方式在Delphi中
阅读:557| 2022-07-18
elipapa/markdown-cv: a simple template to write your CV in a readable markdown f
阅读:514| 2022-08-17
tboronczyk/localization-middleware: PSR-15 middleware to assist primarily with l
阅读:521| 2022-08-16
Improper input validation vulnerability in Space of Cybozu Garoon 4.0.0 to 5.5.1
阅读:927| 2022-07-08
Call Me Maybe 中英字幕 对于加拿大歌手卡莉·蕾·吉普森很多人有些陌生,她隶属于贾
阅读:632| 2022-11-06
请发表评论