/** * Update available package information * */ function DoRemoteCheck2() { global $config, $dataDir; $path = \gp\tool::IdUrl(); //add any locally available themes with addon ids $dir = $dataDir . '/themes'; $themes = scandir($dir); $theme_ids = array(); foreach ($themes as $name) { if ($name == '.' || $name == '..') { continue; } $full_dir = $dir . '/' . $name; $templateFile = $full_dir . '/template.php'; $ini_file = $full_dir . '/Addon.ini'; if (!file_exists($templateFile)) { continue; } $ini_info = array(); if (file_exists($ini_file)) { $ini_info = \gp\tool\Ini::ParseFile($ini_file); } if (isset($ini_info['Addon_Unique_ID'])) { $theme_ids[] = $ini_info['Addon_Unique_ID']; } } $theme_ids = array_unique($theme_ids); if (count($theme_ids)) { $path .= '&th=' . implode('-', $theme_ids); } //get data $result = \gp\tool\RemoteGet::Get_Successful($path); if (!$result) { $this->msg(\gp\tool\RemoteGet::Debug('Sorry, data not fetched')); return false; } //zipped data possible since 4.1 /* if( function_exists('gzinflate') ){ $temp = gzinflate($result); if( $temp ){ $result = $temp; } } */ $result = trim($result); $array = json_decode($result, true); //json since 4.1 if (!is_array($array)) { $debug = array(); $debug['Type'] = gettype($array); $debug['json_last_error'] = json_last_error(); $debug['Two'] = substr($result, 0, 20); $this->msg(\gp\tool\RemoteGet::Debug('Sorry, data not fetched', $debug)); return false; } if (!$array) { $debug = array(); $debug['Count'] = count($array); $debug['Two'] = substr($result, 0, 20); $this->msg(\gp\tool\RemoteGet::Debug('Sorry, data not fetched', $debug)); return false; } $this->update_data['packages'] = array(); foreach ($array as $info) { $id =& $info['id']; if (!is_numeric($id)) { continue; } if (!isset($info['type'])) { continue; } if ($info['type'] == 'core') { $id = 'core'; } $this->update_data['packages'][$id] = $info; } if (isset($this->update_data['packages']['core'])) { $this->core_package = $this->update_data['packages']['core']; } return true; }
/** * Convert the response string to an array * Serialized or json (serialized data may be cached) * */ protected function ParseResponse($result) { //no response if (!$result) { echo '<p>' . \gp\tool\RemoteGet::Debug('Sorry, data not fetched') . '</p>'; return false; } $data = false; if (strpos($result, 'a:') === 0) { $data = unserialize($result); } elseif (strpos($result, '{') === 0) { $data = json_decode($result, true); } if (!is_array($data)) { $debug = array(); $debug['Two'] = substr($result, 0, 2); $debug['Twotr'] = substr(trim($result), 0, 2); echo '<p>' . \gp\tool\RemoteGet::Debug('Sorry, data not fetched', $debug) . '</p>'; } return $data; }