/** * Get a list of available addons * */ function GetAvailAddons() { global $dataDir; $addonPath = $dataDir . '/addons'; $installed_path = $dataDir . '/data/_addoncode'; if (!file_exists($addonPath)) { message('Warning: The /addons folder "<em>' . $addonPath . '</em>" does not exist on your server.'); return array(); } $folders = gpFiles::ReadDir($addonPath, 1); $versions = $avail = array(); foreach ($folders as $key => $value) { $fullPath = $addonPath . '/' . $key; $info = admin_addons_tool::GetAvailInstall($fullPath); if (!$info) { continue; } $info['upgrade_key'] = admin_addons_tool::UpgradePath($info); $avail[$key] = $info; if (isset($info['Addon_Version']) && isset($info['Addon_Unique_ID'])) { $id = $info['Addon_Unique_ID']; $version = $info['Addon_Version']; if (!isset($versions[$id])) { $versions[$id] = $version; continue; } if (version_compare($versions[$id], $version, '<')) { $versions[$id] = $version; } } } if (!gp_unique_addons) { return $avail; } //show only the most recent versions $temp = array(); foreach ($avail as $key => $info) { if (!isset($info['Addon_Version']) || !isset($info['Addon_Unique_ID'])) { $temp[$key] = $info; continue; } $id = $info['Addon_Unique_ID']; $version = $info['Addon_Version']; if (version_compare($versions[$id], $version, '>')) { continue; } $temp[$key] = $info; } return $temp; }
function GetAddonRateInfoTheme($dir) { global $dataDir, $langmessage; $dir = str_replace('\\', '/', $dir); $dir = str_replace('../', './', $dir); if (!file_exists($dir)) { $this->CanRate = false; $this->messages[] = $langmessage['OOPS']; return false; } $ini = admin_addons_tool::GetAvailInstall($dir); if ($ini === false) { $this->CanRate = false; $this->messages[] = 'This add-on does not have an ID assigned to it. The developer must update the install configuration.'; return false; } if (!isset($ini['Addon_Unique_ID'])) { $this->CanRate = false; $this->messages[] = 'This add-on does not have an ID assigned to it. The developer must update the install configuration.'; return false; } $this->addon_info['pass_arg'] = $dir; $this->addon_info['id'] = $ini['Addon_Unique_ID']; $this->addon_info['name'] = $ini['Addon_Name']; return true; }
/** * Return an array of available themes * @return array * */ function GetPossible() { global $dataDir, $dirPrefix; $themes = array(); $this->versions = array(); //local themes $dir = $dataDir . '/themes'; $layouts = gpFiles::readDir($dir, 1); foreach ($layouts as $name) { $full_dir = $dir . '/' . $name; $templateFile = $full_dir . '/template.php'; if (!file_exists($templateFile)) { continue; } $index = $name . '(local)'; $ini_info = admin_addons_tool::GetAvailInstall($full_dir); //check version $addon_id = $version = false; if (isset($ini_info['Addon_Version']) && isset($ini_info['Addon_Unique_ID'])) { $addon_id = $ini_info['Addon_Unique_ID']; $version = $ini_info['Addon_Version']; if (!isset($this->versions[$addon_id])) { $this->versions[$addon_id] = array('version' => $version, 'index' => $index); } elseif (version_compare($this->versions[$addon_id]['version'], $version, '<')) { $this->versions[$addon_id] = array('version' => $version, 'index' => $index); } } $themes[$index]['name'] = $name; if (isset($ini_info['Addon_Name'])) { $themes[$index]['name'] = $ini_info['Addon_Name']; } $themes[$index]['colors'] = $this->GetThemeColors($full_dir); $themes[$index]['folder'] = $name; $themes[$index]['is_addon'] = false; $themes[$index]['full_dir'] = $full_dir; $themes[$index]['rel'] = '/themes/' . $name; if ($version) { $themes[$index]['version'] = $ini_info['Addon_Version']; } if ($addon_id) { $themes[$index]['id'] = $ini_info['Addon_Unique_ID']; } } //downloaded themes $dir = $dataDir . '/data/_themes'; $layouts = gpFiles::readDir($dir, 1); asort($layouts); foreach ($layouts as $folder) { $full_dir = $dir . '/' . $folder; $templateFile = $full_dir . '/template.php'; if (!file_exists($templateFile)) { continue; } $ini_info = admin_addons_tool::GetAvailInstall($full_dir); $index = $ini_info['Addon_Name'] . '(remote)'; //check version $addon_id = $version = false; if (isset($ini_info['Addon_Version']) && isset($ini_info['Addon_Unique_ID'])) { $addon_id = $ini_info['Addon_Unique_ID']; $version = $ini_info['Addon_Version']; if (!isset($this->versions[$addon_id])) { $this->versions[$addon_id] = array('version' => $version, 'index' => $index); } elseif (version_compare($this->versions[$addon_id]['version'], $version, '<')) { $this->versions[$addon_id] = array('version' => $version, 'index' => $index); } } $themes[$index]['name'] = $ini_info['Addon_Name']; $themes[$index]['colors'] = $this->GetThemeColors($full_dir); $themes[$index]['folder'] = $folder; $themes[$index]['is_addon'] = true; $themes[$index]['full_dir'] = $full_dir; $themes[$index]['id'] = $ini_info['Addon_Unique_ID']; $themes[$index]['rel'] = '/data/_themes/' . $folder; if (isset($ini_info['Addon_Version'])) { $themes[$index]['version'] = $ini_info['Addon_Version']; } } if (!gp_unique_addons) { $this->possible = $themes; } else { //remove older versions $this->possible = array(); foreach ($themes as $index => $info) { if (!isset($info['id']) || !isset($info['version'])) { $this->possible[$index] = $info; continue; } if (version_compare($this->versions[$info['id']]['version'], $info['version'], '>')) { continue; } $this->possible[$index] = $info; } uksort($this->possible, 'strnatcasecmp'); } }
function DoRemoteCheck2() { global $config, $dataDir; $path = common::IdUrl(); //add any locally available themes with addon ids includeFile('admin/admin_addons_tool.php'); $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'; if (!file_exists($templateFile)) { continue; } $ini_info = admin_addons_tool::GetAvailInstall($full_dir); 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 from gpEasy $result = gpRemoteGet::Get_Successful($path); if (!$result) { return false; } //zipped data possible as of gpEasy 4.1 if (function_exists('gzinflate')) { $temp = gzinflate($result); if ($temp) { $result = $temp; } } $array = json_decode($result, true); //json as of gpEasy 4.1 if (!is_array($array) || count($array) < 1) { return false; } $this->update_data['packages'] = array(); $core_version = false; foreach ($array as $info) { $id =& $info['id']; if (!is_numeric($id)) { continue; } if (!isset($info['type'])) { continue; } if ($info['type'] == 'core') { $id = 'core'; $core_version = $info['version']; } $this->update_data['packages'][$id] = $info; } return true; }