/** * 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; }
/** * Delete a remote theme * */ public function DeleteTheme() { global $langmessage, $dataDir, $gpLayouts, $config; $config_before = $config; $gpLayoutsBefore = $gpLayouts; $theme_folder_name =& $_POST['folder']; $theme_folder = $dataDir . '/data/_themes/' . $theme_folder_name; if (empty($theme_folder_name) || !ctype_alnum($theme_folder_name)) { message($langmessage['OOPS'] . ' (Invalid Request)'); return false; } $order = false; if (isset($config['themes'][$theme_folder_name]['order'])) { $order = $config['themes'][$theme_folder_name]['order']; } if (!$this->CanDeleteTheme($theme_folder_name, $message)) { message($message); return false; } //remove layouts $rm_addon = false; foreach ($gpLayouts as $layout_id => $layout_info) { if (!isset($layout_info['is_addon']) || !$layout_info['is_addon']) { continue; } $layout_folder = dirname($layout_info['theme']); if ($layout_folder != $theme_folder_name) { continue; } if (array_key_exists('addon_key', $layout_info)) { $rm_addon = $layout_info['addon_key']; } $this->RmLayoutPrep($layout_id); unset($gpLayouts[$layout_id]); } //remove from settings unset($config['themes'][$theme_folder_name]); if ($rm_addon) { $installer = new \gp\admin\Addon\Installer(); if (!$installer->Uninstall($rm_addon)) { $gpLayouts = $gpLayoutsBefore; } $installer->OutputMessages(); } else { if (!\gp\admin\Tools::SaveAllConfig()) { $config = $config_before; $gpLayouts = $gpLayoutsBefore; message($langmessage['OOPS'] . ' (s1)'); return false; } message($langmessage['SAVED']); if ($order) { $img_path = \gp\tool::IdUrl('ci'); \gp\tool::IdReq($img_path); } } //delete the folder if it hasn't already been deleted by addon installer $dir = $dataDir . '/data/_themes/' . $theme_folder_name; if (file_exists($dir)) { \gp\tool\Files::RmAll($dir); } }
/** * Run through the installation process * */ public function InstallSteps() { global $dataDir, $langmessage; $this->GetAddonData(); // addonHistory $this->Init_PT(); // $this->config //get from remote if ($this->remote_install && !$this->GetRemote()) { return false; } //check ini contents if (!$this->CheckIni()) { return false; } $this->SetDestination(); $this->DataFolder(); $this->IniContents(); if (!$this->PrepConfig()) { return false; } if (!$this->CheckFile()) { return false; } //hooks if (!$this->Hooks()) { return false; } //layout if (!$this->Layout()) { return false; } //move new addon folder into place if (!$this->FinalizeFolder()) { return false; } if (!$this->FinalizeConfig()) { return false; } // Save if (!\gp\admin\Tools::SaveAllConfig()) { $this->message($langmessage['OOPS'] . ' (Configuration not saved)'); return false; } if (!is_null($this->order)) { $img_path = \gp\tool::IdUrl('ci'); \gp\tool::IdReq($img_path); } $this->UpdateHistory(); return true; }
public static function CheckStatus() { switch (self::$update_status) { case 'embedcheck': $img_path = \gp\tool::GetUrl('Admin', 'cmd=embededcheck'); \gp\tool::IdReq($img_path); break; case 'checkincompat': $img_path = \gp\tool::IdUrl('ci'); //check in \gp\tool::IdReq($img_path); break; } }