Example #1
0
 /**
  * Get a list of available addons
  *
  */
 function GetAvailAddons()
 {
     global $dataDir;
     $addonPath = $dataDir . '/addons';
     if (!file_exists($addonPath)) {
         message('Warning: The /addons folder "<em>' . $addonPath . '</em>" does not exist on your server.');
         return array();
     }
     $installed_path = $dataDir . '/data/_addoncode';
     $folders = gpFiles::ReadDir($addonPath, 1);
     $versions = array();
     $avail = array();
     foreach ($folders as $value) {
         $fullPath = $addonPath . '/' . $value;
         $info = $this->GetAvailInstall($fullPath);
         if (!$info) {
             continue;
         }
         $info['upgrade_key'] = admin_addons_tool::UpgradePath($info);
         $avail[$value] = $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 admin_theme_content()
 {
     global $page, $config, $gpLayouts, $langmessage;
     $this->find_label = $langmessage['Find Themes'];
     $this->manage_label = $langmessage['Manage Layouts'];
     //message('request: '.showArray($_REQUEST));
     $page->head_js[] = '/include/js/theme_content.js';
     $page->head_js[] = '/include/js/dragdrop.js';
     $page->css_admin[] = '/include/css/theme_content.css';
     $page->css_admin[] = '/include/css/addons.css';
     $this->curr_layout = $config['gpLayout'];
     $this->SetLayoutArray();
     $cmd = common::GetCommand();
     //layout requests
     if (strpos($page->requested, '/')) {
         $parts = explode('/', $page->requested);
         $layout_part = $parts[1];
         if (isset($gpLayouts[$layout_part]) && $this->EditLayout($layout_part, $cmd)) {
             return;
         }
     }
     switch ($cmd) {
         case 'remote':
             $this->RemoteBrowse();
             return;
             //remote themes
         //remote themes
         case 'remote_install':
         case 'remote_install2':
         case 'remote_install3':
             $this->RemoteInstallMain($cmd);
             return;
         case 'deletetheme':
             $this->DeleteTheme();
             return;
         case 'delete_theme_confirmed':
             $this->DeleteThemeConfirmed();
             break;
             //adminlayout
         //adminlayout
         case 'adminlayout':
             $this->AdminLayout();
             return;
             //theme ratings
         //theme ratings
         case 'Update Review':
         case 'Send Review':
         case 'rate':
             includeFile('admin/admin_addons_tool.php');
             $rating = new admin_addons_tool();
             $rating->admin_addon_rating('theme', 'Admin_Theme_Content');
             if ($rating->ShowRatingText) {
                 return;
             }
             break;
             //new layouts
         //new layouts
         case 'preview':
             if ($this->PreviewTheme()) {
                 return;
             }
             break;
         case 'newlayout':
             $this->NewLayoutPrompt();
             return;
         case 'addlayout':
             $this->NewLayout();
             break;
             //copy
         //copy
         case 'copy':
             $this->CopyLayoutPrompt();
             return;
         case 'copylayout':
             $this->CopyLayout();
             break;
             //editing layouts without a layout id
         //editing layouts without a layout id
         case 'restore_drag':
         case 'addcontent':
         case 'drag':
         case 'editlayout':
             //linked from install page
         //linked from install page
         case 'rm':
         case 'insert':
         case 'details':
             if ($this->EditLayout($this->curr_layout, $cmd)) {
                 return;
             }
             break;
         case 'rmgadget':
             $this->RmGadget($_REQUEST['layout']);
             break;
         case 'restore':
             $this->Restore($_REQUEST['layout']);
             break;
         case 'change_layout_color':
             $this->ChangeLayoutColor($_REQUEST['layout'], false);
             break;
         case 'css_preferences':
             $this->CSSPreferences($_REQUEST['layout'], false);
             break;
             //layout options
         //layout options
         case 'makedefault':
             $this->MakeDefault($_GET['layout_id']);
             break;
         case 'deletelayout':
             $this->DeleteLayoutConfirmed();
             break;
         case 'layout_details':
             $this->LayoutDetails();
             break;
             //links
         //links
         case 'editlinks':
         case 'editcustom':
             $this->SelectLinks();
             return;
         case 'savelinks':
             $this->SaveLinks();
             break;
             //text
         //text
         case 'edittext':
             $this->EditText();
             return;
         case 'savetext':
             $this->SaveText();
             break;
         case 'saveaddontext':
             $this->SaveAddonText();
             break;
         case 'addontext':
             $this->AddonText();
             return;
     }
     //message(showArray($_GET));
     $this->Show();
 }
 /**
  * Run through the installation process
  *
  */
 function InstallSteps()
 {
     global $dataDir;
     $this->GetAddonData();
     // addonHistory
     $this->Init_PT();
     // $this->config
     //get from remote
     if ($this->remote_install && !$this->GetRemote()) {
         return false;
     }
     //check ini contents
     $this->display_name = basename($this->source);
     if (!$this->GetINI($this->source, $error)) {
         //local themes don't need addon.ini files
         if (empty($this->new_layout)) {
             $this->message($error);
             return false;
         }
     }
     // upgrade/destination
     $this->upgrade_key = $this->config_key = admin_addons_tool::UpgradePath($this->ini_contents, $this->config_index);
     if ($this->remote_install) {
         if ($this->config_key) {
             $this->dest = $this->addon_folder . '/' . $this->config_key;
         } else {
             $this->dest = $this->TempFile();
         }
     } else {
         $this->dest = $this->source;
     }
     $this->dest_name = basename($this->dest);
     if (!$this->config_key) {
         $this->config_key = $this->dest_name;
     }
     //the data folder will not always be the same as the addon folder
     if (isset($this->config[$this->config_key]['data_folder'])) {
         $this->data_folder = $this->config[$this->config_key]['data_folder'];
     } elseif ($this->upgrade_key && file_exists($dataDir . '/data/_addondata/' . $this->upgrade_key)) {
         $this->data_folder = $this->upgrade_key;
     } else {
         $this->data_folder = $this->dest_name;
     }
     $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 (!admin_tools::SaveAllConfig()) {
         $this->message($langmessage['OOPS'] . ' (Configuration not saved)');
         return false;
     }
     if ($this->order) {
         $img_path = common::IdUrl('ci');
         common::IdReq($img_path);
     }
     $this->UpdateHistory();
     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');
     }
 }
Example #5
0
 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;
 }
Example #6
0
 /**
  * Get a list of available addons
  *
  */
 function GetAvailAddons()
 {
     global $dataDir;
     $addonPath = $dataDir . '/addons';
     if (!file_exists($addonPath)) {
         message('Warning: The /addons folder "<em>' . $addonPath . '</em>" does not exist on your server.');
         return array();
     }
     $installed_path = $dataDir . '/data/_addoncode';
     $folders = gpFiles::ReadDir($addonPath, 1);
     $versions = array();
     $avail = array();
     foreach ($folders as $value) {
         $fullPath = $addonPath . '/' . $value;
         $info = $this->GetAvailInstall($fullPath);
         if (!$info) {
             continue;
         }
         $info['upgrade_key'] = admin_addons_tool::UpgradePath($info);
         $avail[$value] = $info;
         if (isset($info['Addon_Version']) && isset($info['Addon_Unique_ID'])) {
             $id = $info['Addon_Unique_ID'];
             if (!isset($versions[$id])) {
                 $versions[$id] = $info['Addon_Version'];
             } elseif (version_compare($versions[$id], $info['Addon_Version'], '<')) {
                 $versions[$id] = $info['Addon_Version'];
                 continue;
             }
         }
         if (!$info['upgrade_key']) {
             $this->avail_count++;
         }
     }
     if (gp_unique_addons) {
         $avail = self::FilterUnique($avail, $versions);
     }
     return $avail;
 }
Example #7
0
 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;
 }