From c74e2ab49ee08101b38b3904a49037fcd6f9403c Mon Sep 17 00:00:00 2001 From: patdenice Date: Sun, 23 Nov 2008 17:23:57 +0000 Subject: - Add home and identification buttons after installation. - Use fetchRemote function for remote site actions. - Corrections in fetchRemote fnction. - Move PLUGIN_PICTURE_BEFORE in picture.tpl. git-svn-id: http://piwigo.org/svn/trunk@2902 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/functions.php | 18 +++++++++++++++++- admin/site_manager.php | 6 ++++-- admin/site_reader_remote.php | 5 ++--- admin/template/goto/install.tpl | 6 ++++++ 4 files changed, 29 insertions(+), 6 deletions(-) (limited to 'admin') diff --git a/admin/include/functions.php b/admin/include/functions.php index a8193d3af..fc11101fc 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1948,6 +1948,21 @@ function cat_admin_access($category_id) */ function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0) { + // Try to retrieve data from local file? + if (!url_is_remote($src)) + { + $content = @file_get_contents($src); + if ($content !== false) + { + is_resource($dest) ? @fwrite($dest, $content) : $dest = $content; + return true; + } + else + { + return false; + } + } + // After 3 redirections, return false if ($step > 3) return false; @@ -1964,8 +1979,9 @@ function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0) @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = @curl_exec($ch); $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE); + $status = @curl_getinfo($ch, CURLINFO_HTTP_CODE); @curl_close($ch); - if ($content !== false) + if ($content !== false and $status >= 200 and $status < 400) { if (preg_match('/Location:\s+?(.+)/', substr($content, 0, $header_length), $m)) { diff --git a/admin/site_manager.php b/admin/site_manager.php index b965b26e8..ea7f060cd 100644 --- a/admin/site_manager.php +++ b/admin/site_manager.php @@ -44,8 +44,9 @@ function remote_output($url) { global $template, $page; - if($lines = @file($url)) + if (fetchRemote($url, $result)) { + $lines = explode("\r\n", $result); // cleaning lines from HTML tags foreach ($lines as $line) { @@ -112,8 +113,9 @@ SELECT COUNT(id) AS count $clf_url = $url.'create_listing_file.php'; $clf_url.= '?action=test'; $clf_url.= '&version='.PHPWG_VERSION; - if ( ($lines = @file($clf_url)) !== false) + if (fetchRemote($clf_url, $result)) { + $lines = explode("\r\n", $result); $first_line = strip_tags($lines[0]); if (!preg_match('/^PWG-INFO-2:/', $first_line)) { diff --git a/admin/site_reader_remote.php b/admin/site_reader_remote.php index 31ae3e792..5c350acf8 100644 --- a/admin/site_reader_remote.php +++ b/admin/site_reader_remote.php @@ -48,7 +48,7 @@ function RemoteSiteReader($url, $listing_url) if (!isset($listing_url)) { - $this->listing_url = $this->site_url.'/listing.xml'; + $this->listing_url = $this->site_url.'listing.xml'; } else { @@ -65,11 +65,10 @@ function open() { global $errors; - if (@fopen($this->listing_url, 'r')) + if ($xml_content = getXmlCode($this->listing_url)) { $this->site_dirs = array(); $this->site_files = array(); - $xml_content = getXmlCode($this->listing_url); $info_xml_element = getChild($xml_content, 'informations'); if (getAttribute($info_xml_element , 'phpwg_version') != PHPWG_VERSION) { diff --git a/admin/template/goto/install.tpl b/admin/template/goto/install.tpl index a0e8eff6f..bea5cddb4 100644 --- a/admin/template/goto/install.tpl +++ b/admin/template/goto/install.tpl @@ -145,6 +145,12 @@ TD { +{else} +

+
+ + +

{/if} {* content *}
{$L_INSTALL_HELP}
-- cgit v1.2.3