Esempio n. 1
0
 /**
  * Confirm getting the url retreives the current installation
  *
  */
 public static function ConfirmGet($url, $check_redirect = true)
 {
     global $config;
     $result = \gp\tool\RemoteGet::Get_Successful($url);
     if (!$result) {
         return false;
     }
     if (isset($config['gpuniq'])) {
         $mdu_check = substr(md5($config['gpuniq']), 0, 20);
         if (strpos($result, $mdu_check) === false) {
             return false;
         }
     }
     //if redirected, make sure it's on the same host
     if ($check_redirect && \gp\tool\RemoteGet::$redirected) {
         $redirect_a = parse_url(\gp\tool\RemoteGet::$redirected);
         $req_a = parse_url($url);
         if ($redirect_a['host'] !== $req_a['host']) {
             return false;
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Download the source code
  *
  */
 function DownloadSource()
 {
     global $langmessage, $dataDir;
     $this->msg('Downloading version ' . $this->core_package['version'] . ' from ' . CMS_READABLE_DOMAIN . '.');
     /* for testing
      * $download = 'http://gpeasy.loc/x_gpEasy.zip';
      */
     $download = addon_browse_path . '/Special_gpEasy?cmd=download';
     $contents = \gp\tool\RemoteGet::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
     $temp_file = $dataDir . \gp\tool\FileSystem::TempFile('/data/_temp/update', '.zip');
     if (!\gp\tool\Files::Save($temp_file, $contents)) {
         $this->msg($langmessage['download_failed'] . ' (2)');
         return false;
     }
     $this->core_package['file'] = $temp_file;
     return true;
 }
Esempio n. 3
0
 /**
  * Get cached data or fetch new response from server and cache it
  *
  */
 public function RemoteBrowseResponse($src)
 {
     global $dataDir, $langmessage;
     $cache_file = $dataDir . '/data/_remote/' . sha1($src) . '.txt';
     $cache_used = false;
     //check cache
     if (file_exists($cache_file) && filemtime($cache_file) + 26100 > time()) {
         $result = file_get_contents($cache_file);
         $cache_used = true;
     } else {
         $result = \gp\tool\RemoteGet::Get_Successful($src);
     }
     $data = $this->ParseResponse($result);
     if ($data === false) {
         return false;
     }
     //not unserialized?
     if (count($data) == 0) {
         echo '<p>';
         echo $langmessage['search_no_results'];
         echo '</p>';
         return false;
     }
     //save the cache
     if (!$cache_used) {
         \gp\tool\Files::Save($cache_file, $result);
     }
     return $data;
 }