Example #1
0
 /**
  * Determine if the installation should be allowed to process remote installations
  *
  */
 static function CanRemoteInstall()
 {
     static $bit;
     if (isset($bit)) {
         return $bit;
     }
     if (!gp_remote_themes && !gp_remote_plugins) {
         return $bit = 0;
     }
     if (!function_exists('gzinflate')) {
         return $bit = 0;
     }
     includeFile('tool/RemoteGet.php');
     if (!gpRemoteGet::Test()) {
         return $bit = 0;
     }
     if (gp_remote_themes) {
         $bit = 1;
     }
     if (gp_remote_plugins) {
         $bit += 2;
     }
     return $bit;
 }
 /**
  * Get addon data from gpEasy.com and display to user
  *
  */
 function RemoteBrowse()
 {
     global $langmessage, $config, $dataDir, $gpversion;
     //search options
     if (isset($_GET['search_option'])) {
         $save = true;
         switch ($_GET['search_option']) {
             case 'version':
                 unset($config['search_version']);
                 break;
             case 'noversion':
                 $config['search_version'] = false;
                 break;
             default:
                 $save = false;
                 break;
         }
         if ($save) {
             admin_tools::SaveConfig();
         }
     }
     //make a list of installed addon id's
     $this->installed_ids = array();
     if (isset($config['addons']) && is_array($config['addons'])) {
         foreach ($config['addons'] as $addon_info) {
             if (isset($addon_info['id'])) {
                 $this->installed_ids[] = $addon_info['id'];
             }
         }
     }
     includeFile('tool/RemoteGet.php');
     $orderby = array();
     $orderby['rating_score'] = $langmessage['Highest Rated'];
     $orderby['downloads'] = $langmessage['Most Downloaded'];
     $orderby['modified'] = $langmessage['Recently Updated'];
     $orderby['created'] = $langmessage['Newest'];
     $_GET += array('q' => '');
     $this->searchPage = 0;
     if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) {
         $this->searchPage = $_REQUEST['page'];
     }
     $this->searchQuery = 'cmd=remote';
     //version specific search
     $search_version = false;
     if (!isset($config['search_version']) || $config['search_version']) {
         $this->searchQuery .= '&ug=' . rawurlencode($gpversion);
         $search_version = true;
     }
     if (!empty($_GET['q'])) {
         $this->searchQuery .= '&q=' . rawurlencode($_GET['q']);
     }
     if (isset($_GET['order']) && isset($orderby[$_GET['order']])) {
         $this->searchOrder = $_GET['order'];
         $this->searchQuery .= '&order=' . rawurlencode($_GET['order']);
     } else {
         reset($orderby);
         $this->searchOrder = key($orderby);
     }
     $slug = 'Special_Addon_Plugins';
     if ($this->config_index == 'themes') {
         $slug = 'Special_Addon_Themes';
     }
     $src = $GLOBALS['addonBrowsePath'] . '/' . $slug . '?' . $this->searchQuery . '&page=' . $this->searchPage;
     //check cache
     $cache_file = $dataDir . '/data/_remote/' . sha1($src) . '.txt';
     $use_cache = false;
     if (file_exists($cache_file) && filemtime($cache_file) + 26100 > time()) {
         $result = file_get_contents($cache_file);
         $use_cache = true;
     } else {
         $result = gpRemoteGet::Get_Successful($src);
     }
     if (!$result) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f1)</p>';
         return;
     }
     if (strpos($result, 'a:') !== 0) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f2)</p>';
         return;
     }
     $data = unserialize($result);
     if (count($data) == 0) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f3)</p>';
         return;
     }
     //save the cache
     if (!$use_cache) {
         gpFiles::Save($cache_file, $result);
     }
     $this->searchMax = $data['max'];
     if (isset($data['per_page']) && $data['per_page']) {
         $this->searchPerPage = $data['per_page'];
     } else {
         $this->searchPerPage = count($data['rows']);
     }
     $this->searchOffset = $this->searchPage * $this->searchPerPage;
     $this->FindForm();
     echo '<h2 class="hmargin">';
     echo common::Link($this->browser_path, $this->manage_label);
     echo ' <span>|</span> ';
     if (!empty($_GET['q'])) {
         echo common::Link($this->browser_path, $this->find_label, 'cmd=remote');
         echo ' &#187; ';
         echo htmlspecialchars($_GET['q']);
     } else {
         echo $this->find_label;
     }
     echo '</h2>';
     echo '<div class="gp_search_options">';
     $this->SearchNavLinks();
     echo '<div class="search_order">';
     foreach ($orderby as $key => $label) {
         if ($key === $this->searchOrder) {
             echo '<span>' . $label . '</span>';
         } else {
             echo common::Link($this->browser_path, $label, $this->searchQuery . '&order=' . $key);
         }
     }
     echo '</div></div>';
     echo '<table class="bordered full_width">';
     echo '<tr><th></th><th>' . $langmessage['name'] . '</th><th>' . $langmessage['version'] . '</th><th>' . $langmessage['Statistics'] . '</th><th>' . $langmessage['description'] . '</th></tr>';
     $i = 0;
     if (count($data['rows'])) {
         foreach ($data['rows'] as $row) {
             echo '<tr class="' . ($i % 2 ? 'even' : '') . '">';
             echo '<td>';
             $this->DetailLink($row, '<img src="' . $row['icon'] . '" height="100" width="100" alt=""/>', '', ' class="shot"');
             echo '</td>';
             echo '<td class="nowrap">';
             echo '<b>' . $row['name'] . '</b>';
             echo '<br/>';
             $this->DetailLink($row);
             echo ' | ';
             $this->InstallLink($row);
             echo '</td><td>';
             echo $row['version'];
             echo '</td><td class="nowrap">';
             echo sprintf($langmessage['_downloads'], number_format($row['downloads']));
             echo '<br/>';
             $this->CurrentRating($row['rating_weighted']);
             echo '<br/>';
             echo $row['rating_count'] . ' ratings';
             echo '</td><td>';
             echo $row['short_description'];
             //echo showArray($row);
             echo '</td></tr>';
             $i++;
         }
         echo '</table>';
         $this->SearchNavLinks();
     } else {
         echo '</table>';
         echo '<p>' . $langmessage['Sorry, nothing matched'] . '</p>';
     }
     echo '<h3>Search Options</h3>';
     echo '<ul>';
     echo '<li>Limit results to addons that are compatible with your version of gpEasy (' . $gpversion . ') &nbsp; ';
     if ($search_version) {
         echo '<b>' . $langmessage['On'] . '</b> &nbsp; ';
         echo common::Link($this->browser_path, $langmessage['Off'], $this->searchQuery . '&search_option=noversion', ' name="gpajax"');
     } else {
         echo common::Link($this->browser_path, $langmessage['On'], $this->searchQuery . '&search_option=version', ' name="gpajax"');
         echo ' &nbsp;  <b>' . $langmessage['Off'] . '</b>';
     }
     echo '</li>';
     echo '</ul>';
 }
Example #3
0
 /**
  * attempt to create an htaccess file
  * .htaccess creation only works for base_installations because of the $dirPrefix variable
  * 		This is for the rewrite_rule and TestResponse() which uses AbsoluteUrl()
  *
  * @access public
  * @static
  * @since 1.7
  *
  * @param string $destination The root path of the installation
  * @param array $config Current installation configuration
  */
 static function InstallHtaccess($destination, $config)
 {
     global $install_ftp_connection, $dirPrefix;
     includeFile('admin/admin_permalinks.php');
     //only proceed with save if we can test the results
     if (!gpRemoteGet::Test()) {
         return;
     }
     $GLOBALS['config']['homepath'] = false;
     //to prevent a warning from absoluteUrl()
     $file = $destination . '/.htaccess';
     $original_contents = false;
     if (file_exists($file)) {
         $original_contents = file_get_contents($file);
     }
     $contents = admin_permalinks::Rewrite_Rules(true, $dirPrefix, $original_contents);
     if (!isset($config['useftp'])) {
         //echo 'not using ftp';
         $fp = @fopen($file, 'wb');
         if (!$fp) {
             return;
         }
         @fwrite($fp, $contents);
         fclose($fp);
         @chmod($file, 0666);
         //return .htaccess to original state
         if (!admin_permalinks::TestResponse()) {
             if ($original_contents === false) {
                 unlink($file);
             } else {
                 $fp = @fopen($file, 'wb');
                 if ($fp) {
                     @fwrite($fp, $original_contents);
                     fclose($fp);
                 }
             }
         }
         return;
     }
     //using ftp
     $file = $config['ftp_root'] . '/.htaccess';
     $temp = tmpfile();
     if (!$temp) {
         return false;
     }
     fwrite($temp, $contents);
     fseek($temp, 0);
     //Skip back to the start of the file being written to
     @ftp_fput($install_ftp_connection, $file, $temp, FTP_ASCII);
     fclose($temp);
     //return .htaccess to original state
     if (!admin_permalinks::TestResponse()) {
         if ($original_contents === false) {
             @ftp_delete($install_ftp_connection, $file);
         } else {
             $temp = tmpfile();
             fwrite($temp, $original_contents);
             fseek($temp, 0);
             @ftp_fput($install_ftp_connection, $file, $temp, FTP_ASCII);
             fclose($temp);
         }
     }
 }
 /**
  * Get addon data from gpEasy.com and display to user
  *
  */
 function RemoteBrowse()
 {
     global $langmessage, $config, $dataDir;
     //search options
     if (isset($_GET['search_option'])) {
         $save = true;
         switch ($_GET['search_option']) {
             case 'version':
                 unset($config['search_version']);
                 break;
             case 'noversion':
                 $config['search_version'] = false;
                 break;
             default:
                 $save = false;
                 break;
         }
         if ($save) {
             admin_tools::SaveConfig();
         }
     }
     //make a list of installed addon id's
     $this->installed_ids = array();
     if (isset($config['addons']) && is_array($config['addons'])) {
         foreach ($config['addons'] as $addon_info) {
             if (isset($addon_info['id'])) {
                 $this->installed_ids[] = $addon_info['id'];
             }
         }
     }
     includeFile('tool/RemoteGet.php');
     //search settings
     $this->searchUrl = $this->path_remote;
     $this->searchOrderOptions['rating_score'] = $langmessage['Highest Rated'];
     $this->searchOrderOptions['downloads'] = $langmessage['Most Downloaded'];
     $this->searchOrderOptions['modified'] = $langmessage['Recently Updated'];
     $this->searchOrderOptions['created'] = $langmessage['Newest'];
     $_GET += array('q' => '');
     if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) {
         $this->searchPage = $_REQUEST['page'];
     }
     //version specific search
     $search_version = false;
     if (!isset($config['search_version']) || $config['search_version']) {
         $this->searchQuery .= '&ug=' . rawurlencode(gpversion);
         $search_version = true;
     }
     if (!empty($_GET['q'])) {
         $this->searchQuery .= '&q=' . rawurlencode($_GET['q']);
     }
     $this->SearchOrder();
     $slug = 'Plugins';
     if ($this->config_index == 'themes') {
         $slug = 'Themes';
     }
     $src = addon_browse_path . '/' . $slug . '?cmd=remote&format=json&' . $this->searchQuery . '&page=' . $this->searchPage;
     // format=json added 4.6b3
     //check cache
     $cache_file = $dataDir . '/data/_remote/' . sha1($src) . '.txt';
     $use_cache = false;
     if (file_exists($cache_file) && filemtime($cache_file) + 26100 > time()) {
         $result = file_get_contents($cache_file);
         $use_cache = true;
     } else {
         $result = gpRemoteGet::Get_Successful($src);
     }
     //no response
     if (!$result) {
         if ($use_cache) {
             unlink($cache_file);
         }
         echo '<p>' . gpRemoteGet::Debug('Sorry, data not fetched') . '</p>';
         return;
     }
     //serialized or json (serialized data may be cached)
     if (strpos($result, 'a:') === 0) {
         $data = unserialize($result);
     } elseif (strpos($result, '{') === 0) {
         $data = json_decode($result, true);
     } else {
         if ($use_cache) {
             unlink($cache_file);
         }
         $debug = array();
         $debug['Two'] = substr($result, 0, 2);
         $debug['Twotr'] = substr(trim($result), 0, 2);
         echo '<p>' . gpRemoteGet::Debug('Sorry, data not fetched', $debug) . '</p>';
         return;
     }
     //not unserialized?
     if (!is_array($data) || count($data) == 0) {
         if ($use_cache) {
             unlink($cache_file);
         }
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (F3)</p>';
         return;
     }
     //save the cache
     if (!$use_cache) {
         gpFiles::Save($cache_file, $result);
     }
     $this->searchMax = $data['max'];
     if (isset($data['per_page']) && $data['per_page']) {
         $this->searchPerPage = $data['per_page'];
     } else {
         $this->searchPerPage = count($data['rows']);
     }
     $this->ShowHeader();
     $this->SearchOptions();
     echo '<table class="bordered full_width">';
     echo '<tr><th></th><th>' . $langmessage['name'] . '</th><th>' . $langmessage['version'] . '</th><th>' . $langmessage['Statistics'] . '</th><th>' . $langmessage['description'] . '</th></tr>';
     $i = 0;
     if (count($data['rows'])) {
         foreach ($data['rows'] as $row) {
             echo '<tr class="' . ($i % 2 ? 'even' : '') . '">';
             echo '<td>';
             echo $this->DetailLink($row['type'], $row['id'], '<img src="' . $row['icon'] . '" height="100" width="100" alt=""/>', '', ' class="shot"');
             echo '</td>';
             echo '<td class="nowrap">';
             echo '<b>' . $row['name'] . '</b>';
             echo '<br/>';
             echo $this->DetailLink($row['type'], $row['id']);
             echo ' | ';
             $this->InstallLink($row);
             echo '</td><td>';
             echo $row['version'];
             echo '</td><td class="nowrap">';
             echo sprintf($langmessage['_downloads'], number_format($row['downloads']));
             echo '<br/>';
             $this->CurrentRating($row['rating_weighted']);
             echo '<br/>';
             echo $row['rating_count'] . ' ratings';
             echo '</td><td>';
             echo $row['short_description'];
             echo '</td></tr>';
             $i++;
         }
         echo '</table>';
         $this->SearchNavLinks();
     } else {
         echo '</table>';
         echo '<p>' . $langmessage['Sorry, nothing matched'] . '</p>';
     }
     echo '<h3>Search Options</h3>';
     echo '<ul>';
     echo '<li>Limit results to addons that are compatible with your version of gpEasy (' . gpversion . ') &nbsp; ';
     if ($search_version) {
         echo '<b>' . $langmessage['On'] . '</b> &nbsp; ';
         echo common::Link($this->searchUrl, $langmessage['Off'], $this->searchQuery . '&search_option=noversion', ' data-cmd="gpajax"');
     } else {
         echo common::Link($this->searchUrl, $langmessage['On'], $this->searchQuery . '&search_option=version', ' data-cmd="gpajax"');
         echo ' &nbsp;  <b>' . $langmessage['Off'] . '</b>';
     }
     echo '</li>';
     echo '</ul>';
 }
Example #5
0
 /**
  * Determine if the installation should be allowed to process remote installations
  *
  */
 function CanRemoteInstall()
 {
     static $bool;
     if (isset($bool)) {
         return $bool;
     }
     includeFile('tool/RemoteGet.php');
     $bool = true;
     if (!gpRemoteGet::Test()) {
         $bool = false;
     }
     //used by pclzip
     if (!function_exists('gzinflate')) {
         $bool = false;
     }
     if (defined('gp_remote_addons') && gp_remote_addons === false) {
         $bool = false;
     }
     return $bool;
 }
Example #6
0
 /**
  * Handle a redirect response
  *
  */
 static function Redirect($headers, $r, $arrURL)
 {
     if ($r['redirection']-- < 0) {
         trigger_error('Too many redirects');
         return false;
     }
     //check location for releative value
     $location = $headers['headers']['location'];
     if (is_array($location)) {
         $location = array_pop($location);
     }
     if ($location[0] == '/') {
         $location = $arrURL['scheme'] . '://' . $arrURL['host'] . $location;
     }
     self::$redirected = $location;
     return gpRemoteGet::_get($location, $r);
 }
Example #7
0
 /**
  * Download the source code from gpeasy
  *
  */
 function DownloadSource()
 {
     global $langmessage;
     $this->msg('Downloading version ' . $this->core_package['version'] . ' from gpEasy.com.');
     /* for testing
      * $download = 'http://test.gpeasy.com/gpEasy_test.zip';
      * $download = 'http://gpeasy.loc/x_gpEasy.zip';
      */
     $download = addon_browse_path . '/Special_gpEasy?cmd=download';
     $contents = gpRemoteGet::Get_Successful($download);
     if (!$contents || empty($contents)) {
         $this->msg($langmessage['download_failed'] . '(1)');
         return false;
     }
     $this->msg($langmessage['package_downloaded']);
     $md5 = md5($contents);
     if ($md5 != $this->core_package['md5']) {
         $this->msg($langmessage['download_failed_md5'] . '<br/>Downloaded Checksum (' . $md5 . ') != Expected Checksum (' . $this->core_package['md5'] . ')');
         return false;
     }
     $this->msg($langmessage['download_verified']);
     //save contents
     $tempfile = $this->tempfile();
     if (!gpFiles::Save($tempfile, $contents)) {
         $this->msg($langmessage['download_failed'] . ' (2)');
         return false;
     }
     $this->core_package['file'] = $tempfile;
     return true;
 }
 /**
  * Try to fetch a response using RemoteGet to see if we're getting a 500 error
  *
  * @access public
  * @static
  * @since 1.7
  *
  * @return boolean
  */
 static function TestResponse()
 {
     //get url, force gp_rewrite to $new_gp_rewrite
     $rewrite_before = $_SERVER['gp_rewrite'];
     $_SERVER['gp_rewrite'] = true;
     common::SetLinkPrefix();
     $abs_url = common::AbsoluteUrl('Site_Map', '', true, false);
     $_SERVER['gp_rewrite'] = $rewrite_before;
     common::SetLinkPrefix();
     $result = gpRemoteGet::Get_Successful($abs_url);
     if (!$result) {
         return false;
     }
     return true;
 }
Example #9
0
 function Options_htaccess($site)
 {
     global $langmessage;
     includeFile('admin/admin_permalinks.php');
     if (!gpRemoteGet::Test()) {
         return;
     }
     $site_info = $this->siteData['sites'][$site];
     $site_url = $site_info['url'];
     $site_uniq = false;
     if (isset($site_info['gpuniq'])) {
         $site_uniq = $site_info['gpuniq'];
     }
     $file_path = $site . '/.htaccess';
     if (file_exists($file_path)) {
         $original_contents = $contents = file_get_contents($file_path);
     }
     if (!isset($_POST['hide_index'])) {
         $to_hide_index = false;
         unset($this->siteData['sites'][$site]['hide_index']);
         $prefix = '';
     } else {
         if (empty($site_url)) {
             message('A valid site url is required to hide index.php');
             return false;
         }
         $array = @parse_url($site_url);
         $prefix =& $array['path'];
         $to_hide_index = $this->siteData['sites'][$site]['hide_index'] = true;
     }
     //add the gpeasy rules
     admin_permalinks::StripRules($contents);
     $contents .= admin_permalinks::Rewrite_Rules($to_hide_index, $prefix, $site_uniq);
     if (!gpFiles::Save($file_path, $contents)) {
         message($langmessage['OOPS'] . ' (Couldn\'t save .htaccess)');
         return false;
     }
     //check for valid response when hiding index.php
     if ($to_hide_index) {
         $check_url = $site_url . '/Special_Site_Map';
         $result = gpRemoteGet::Get_Successful($check_url);
         if (!$result) {
             message('Did not recieve valid response when fetching url without index.php: ' . htmlspecialchars($check_url));
             gpFiles::Save($file_path, $original_contents);
             return false;
         }
     }
     return true;
 }
Example #10
0
 function DownloadSource(&$package)
 {
     global $langmessage, $addonBrowsePath;
     /* for testing
      * $download = 'http://test.gpeasy.com/gpEasy_test.zip';
      * $download = 'http://gpeasy.loc/rocky/x_gpEasy_test.zip';
      */
     $download = $addonBrowsePath . '/Special_gpEasy?cmd=download&version=' . urlencode($package['version']) . '&file=' . urlencode($package['zip']);
     echo '<li>Downloading version ' . $package['version'] . ' from gpEasy.com.</li>';
     $contents = gpRemoteGet::Get_Successful($download);
     if (!$contents || empty($contents)) {
         echo '<li>' . $langmessage['download_failed'] . ' (1)</li>';
         return false;
     }
     echo '<li>' . $langmessage['package_downloaded'] . '</li>';
     $md5 = md5($contents);
     if ($md5 != $package['md5']) {
         echo '<li>' . $langmessage['download_failed_md5'];
         echo '<br/>Downloaded Checksum (' . $md5 . ') != Expected Checksum (' . $package['md5'] . ')';
         echo '</li>';
         return false;
     }
     echo '<li>' . $langmessage['download_verified'] . '</li>';
     //save contents
     $tempfile = $this->tempfile();
     if (!gpFiles::Save($tempfile, $contents)) {
         message($langmessage['download_failed'] . ' (2)');
         return false;
     }
     $package['file'] = $tempfile;
     return true;
 }
 /**
  * Get the remote package
  *
  */
 function GetRemote()
 {
     global $langmessage;
     includeFile('tool/RemoteGet.php');
     // check values
     if (empty($this->type) || empty($this->id) || !is_numeric($this->id)) {
         $this->message($langmessage['OOPS'] . ' (Invalid Request)');
         return false;
     }
     // allowed to remote install?
     switch ($this->type) {
         case 'plugin':
             if (!gp_remote_plugins) {
                 $this->message($langmessage['OOPS'] . ' (Can\'t remote install plugins)');
                 return false;
             }
             break;
         case 'theme':
             if (!gp_remote_themes) {
                 $this->message($langmessage['OOPS'] . ' (Can\'t remote install themes)');
                 return false;
             }
             break;
         default:
             $this->message($langmessage['OOPS'] . ' (Invalid Type)');
             return false;
     }
     // able to remote install?
     if (!admin_tools::CanRemoteInstall()) {
         $this->message($langmessage['OOPS'] . ' (Can\'t remote install)');
         return false;
     }
     // download
     $download_link = addon_browse_path;
     if ($this->type == 'theme') {
         $download_link .= '/Themes';
     } else {
         $download_link .= '/Plugins';
     }
     $download_link .= '?cmd=install&id=' . rawurlencode($this->id);
     // purchase order id
     if (!$this->order) {
         $this->order = $this->GetOrder($this->id);
     }
     if ($this->order) {
         $download_link .= '&order=' . rawurlencode($this->order);
     }
     // get package from remote
     $full_result = gpRemoteGet::Get($download_link);
     if ((int) $full_result['response']['code'] < 200 && (int) $full_result['response']['code'] >= 300) {
         $this->message($langmessage['download_failed'] . ' (1)');
         return false;
     }
     // download failed and a message was sent
     if (isset($full_result['headers']['x-error'])) {
         $this->message(htmlspecialchars($full_result['headers']['x-error']));
         $this->message(sprintf($langmessage['download_failed_xerror'], 'href="' . $this->DetailUrl($_POST['type'], $_POST['id']) . '" data-cmd="remote"'));
         return false;
     }
     $result = $full_result['body'];
     $md5 =& $full_result['headers']['x-md5'];
     //check md5
     $package_md5 = md5($result);
     if ($package_md5 != $md5) {
         $this->message($langmessage['download_failed_md5'] . ' <br/> (Package Checksum ' . $package_md5 . ' != Expected Checksum ' . $md5 . ')');
         return false;
     }
     //save contents
     $tempfile = $this->TempFile('.zip');
     if (!gpFiles::Save($tempfile, $result)) {
         $this->message($langmessage['download_failed'] . ' (Package not saved)');
         return false;
     }
     $this->source = $this->TempFile();
     $success = $this->ExtractArchive($this->source, $tempfile);
     unlink($tempfile);
     return $success;
 }
Example #12
0
 /**
  * Determine if we will be able tot test the results
  *
  */
 public function CanTestRules()
 {
     if (!gpRemoteGet::Test()) {
         return false;
     }
     if (!$this->FileSystem || !$this->FileSystem->ConnectOrPrompt('Admin_Permalinks')) {
         return false;
     }
     return true;
 }
Example #13
0
 /**
  * Handle a redirect response
  *
  */
 function Redirect($headers, $r, $arrURL)
 {
     if ($r['redirection']-- < 0) {
         trigger_error('Too many redirects');
         return false;
     }
     //check location for releative value
     $location = $headers['headers']['location'];
     if ($location[0] == '/') {
         $location = $arrURL['scheme'] . '://' . $arrURL['host'] . $location;
     }
     return gpRemoteGet::Get($location, $r);
 }