function SaveConfig()
 {
     global $config, $langmessage;
     $possible = $this->variables;
     foreach ($possible as $key => $curr_possible) {
         if ($curr_possible == 'boolean') {
             if (isset($_POST[$key]) && $_POST[$key] == 'true') {
                 $config[$key] = true;
             } else {
                 $config[$key] = false;
             }
         } elseif ($curr_possible == 'integer') {
             if (isset($_POST[$key]) && is_numeric($_POST[$key])) {
                 $config[$key] = $_POST[$key];
             }
         } elseif (isset($_POST[$key])) {
             $config[$key] = $_POST[$key];
         }
     }
     $config['history_limit'] = min($config['history_limit'], gp_backup_limit);
     if (!admin_tools::SaveConfig()) {
         message($langmessage['OOPS']);
         return false;
     }
     if (isset($_GET['gpreq']) && $_GET['gpreq'] == 'json') {
         message($langmessage['SAVED'] . ' ' . $langmessage['REFRESH']);
     } else {
         message($langmessage['SAVED']);
     }
 }
Beispiel #2
0
 /**
  * Update the gp_index, gp_titles and menus so that special pages can be renamed
  *
  */
 function Upgrade_234()
 {
     global $gp_index, $gp_titles, $gp_menu, $config, $dataDir;
     includeFile('tool/gpOutput.php');
     $special_indexes = array();
     $new_index = array();
     $new_titles = array();
     foreach ($gp_index as $title => $index) {
         $info = $gp_titles[$index];
         $type = common::SpecialOrAdmin($title);
         if ($type === 'special') {
             $special_indexes[$index] = strtolower($title);
             $index = strtolower($title);
             $info['type'] = 'special';
             //some older versions didn't maintain this value well
         }
         $new_index[$title] = $index;
         $new_titles[$index] = $info;
     }
     $gp_titles = $new_titles;
     $gp_index = $new_index;
     //update gp_menu
     $gp_menu = $this->FixMenu($gp_menu, $special_indexes);
     //save pages
     if (!admin_tools::SavePagesPHP()) {
         return;
     }
     $config['gpversion'] = '2.3.4';
     admin_tools::SaveConfig();
     //update alt menus
     if (isset($config['menus']) && is_array($config['menus'])) {
         foreach ($config['menus'] as $key => $value) {
             $menu_file = $dataDir . '/data/_menus/' . $key . '.php';
             if (gpFiles::Exists($menu_file)) {
                 $menu = gpOutput::GetMenuArray($key);
                 $menu = $this->FixMenu($menu, $special_indexes);
                 gpFiles::SaveData($menu_file, 'menu', $menu);
             }
         }
     }
 }
 function SaveText()
 {
     global $config, $langmessage, $page;
     if (!isset($_POST['key'])) {
         message($langmessage['OOPS'] . ' (0)');
         return;
     }
     if (!isset($_POST['value'])) {
         message($langmessage['OOPS'] . ' (1)');
         return;
     }
     $default = $key = $_POST['key'];
     if (isset($langmessage[$key])) {
         $default = $langmessage[$key];
     }
     $config['customlang'][$key] = $value = htmlspecialchars($_POST['value']);
     if ($value === $default || htmlspecialchars($default) == $value) {
         unset($config['customlang'][$key]);
     }
     if (admin_tools::SaveConfig()) {
         message($langmessage['SAVED']);
     } else {
         message($langmessage['OOPS'] . ' (s1)');
     }
     $this->ReturnHeader();
 }
 /**
  * Get addon data from gpEasy.com and display to user
  *
  */
 function RemoteBrowse()
 {
     global $langmessage, $config, $dataDir, $gpversion;
     //search options
     if (isset($_GET['search_option'])) {
         $save = true;
         switch ($_GET['search_option']) {
             case 'version':
                 unset($config['search_version']);
                 break;
             case 'noversion':
                 $config['search_version'] = false;
                 break;
             default:
                 $save = false;
                 break;
         }
         if ($save) {
             admin_tools::SaveConfig();
         }
     }
     //make a list of installed addon id's
     $this->installed_ids = array();
     if (isset($config['addons']) && is_array($config['addons'])) {
         foreach ($config['addons'] as $addon_info) {
             if (isset($addon_info['id'])) {
                 $this->installed_ids[] = $addon_info['id'];
             }
         }
     }
     includeFile('tool/RemoteGet.php');
     $orderby = array();
     $orderby['rating_score'] = $langmessage['Highest Rated'];
     $orderby['downloads'] = $langmessage['Most Downloaded'];
     $orderby['modified'] = $langmessage['Recently Updated'];
     $orderby['created'] = $langmessage['Newest'];
     $_GET += array('q' => '');
     $this->searchPage = 0;
     if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) {
         $this->searchPage = $_REQUEST['page'];
     }
     $this->searchQuery = 'cmd=remote';
     //version specific search
     $search_version = false;
     if (!isset($config['search_version']) || $config['search_version']) {
         $this->searchQuery .= '&ug=' . rawurlencode($gpversion);
         $search_version = true;
     }
     if (!empty($_GET['q'])) {
         $this->searchQuery .= '&q=' . rawurlencode($_GET['q']);
     }
     if (isset($_GET['order']) && isset($orderby[$_GET['order']])) {
         $this->searchOrder = $_GET['order'];
         $this->searchQuery .= '&order=' . rawurlencode($_GET['order']);
     } else {
         reset($orderby);
         $this->searchOrder = key($orderby);
     }
     $slug = 'Special_Addon_Plugins';
     if ($this->config_index == 'themes') {
         $slug = 'Special_Addon_Themes';
     }
     $src = $GLOBALS['addonBrowsePath'] . '/' . $slug . '?' . $this->searchQuery . '&page=' . $this->searchPage;
     //check cache
     $cache_file = $dataDir . '/data/_remote/' . sha1($src) . '.txt';
     $use_cache = false;
     if (file_exists($cache_file) && filemtime($cache_file) + 26100 > time()) {
         $result = file_get_contents($cache_file);
         $use_cache = true;
     } else {
         $result = gpRemoteGet::Get_Successful($src);
     }
     if (!$result) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f1)</p>';
         return;
     }
     if (strpos($result, 'a:') !== 0) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f2)</p>';
         return;
     }
     $data = unserialize($result);
     if (count($data) == 0) {
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (f3)</p>';
         return;
     }
     //save the cache
     if (!$use_cache) {
         gpFiles::Save($cache_file, $result);
     }
     $this->searchMax = $data['max'];
     if (isset($data['per_page']) && $data['per_page']) {
         $this->searchPerPage = $data['per_page'];
     } else {
         $this->searchPerPage = count($data['rows']);
     }
     $this->searchOffset = $this->searchPage * $this->searchPerPage;
     $this->FindForm();
     echo '<h2 class="hmargin">';
     echo common::Link($this->browser_path, $this->manage_label);
     echo ' <span>|</span> ';
     if (!empty($_GET['q'])) {
         echo common::Link($this->browser_path, $this->find_label, 'cmd=remote');
         echo ' &#187; ';
         echo htmlspecialchars($_GET['q']);
     } else {
         echo $this->find_label;
     }
     echo '</h2>';
     echo '<div class="gp_search_options">';
     $this->SearchNavLinks();
     echo '<div class="search_order">';
     foreach ($orderby as $key => $label) {
         if ($key === $this->searchOrder) {
             echo '<span>' . $label . '</span>';
         } else {
             echo common::Link($this->browser_path, $label, $this->searchQuery . '&order=' . $key);
         }
     }
     echo '</div></div>';
     echo '<table class="bordered full_width">';
     echo '<tr><th></th><th>' . $langmessage['name'] . '</th><th>' . $langmessage['version'] . '</th><th>' . $langmessage['Statistics'] . '</th><th>' . $langmessage['description'] . '</th></tr>';
     $i = 0;
     if (count($data['rows'])) {
         foreach ($data['rows'] as $row) {
             echo '<tr class="' . ($i % 2 ? 'even' : '') . '">';
             echo '<td>';
             $this->DetailLink($row, '<img src="' . $row['icon'] . '" height="100" width="100" alt=""/>', '', ' class="shot"');
             echo '</td>';
             echo '<td class="nowrap">';
             echo '<b>' . $row['name'] . '</b>';
             echo '<br/>';
             $this->DetailLink($row);
             echo ' | ';
             $this->InstallLink($row);
             echo '</td><td>';
             echo $row['version'];
             echo '</td><td class="nowrap">';
             echo sprintf($langmessage['_downloads'], number_format($row['downloads']));
             echo '<br/>';
             $this->CurrentRating($row['rating_weighted']);
             echo '<br/>';
             echo $row['rating_count'] . ' ratings';
             echo '</td><td>';
             echo $row['short_description'];
             //echo showArray($row);
             echo '</td></tr>';
             $i++;
         }
         echo '</table>';
         $this->SearchNavLinks();
     } else {
         echo '</table>';
         echo '<p>' . $langmessage['Sorry, nothing matched'] . '</p>';
     }
     echo '<h3>Search Options</h3>';
     echo '<ul>';
     echo '<li>Limit results to addons that are compatible with your version of gpEasy (' . $gpversion . ') &nbsp; ';
     if ($search_version) {
         echo '<b>' . $langmessage['On'] . '</b> &nbsp; ';
         echo common::Link($this->browser_path, $langmessage['Off'], $this->searchQuery . '&search_option=noversion', ' name="gpajax"');
     } else {
         echo common::Link($this->browser_path, $langmessage['On'], $this->searchQuery . '&search_option=version', ' name="gpajax"');
         echo ' &nbsp;  <b>' . $langmessage['Off'] . '</b>';
     }
     echo '</li>';
     echo '</ul>';
 }
Beispiel #5
0
 /**
  * Save config.php and pages.php
  *
  */
 static function SaveAllConfig()
 {
     if (!admin_tools::SaveConfig()) {
         return false;
     }
     if (!admin_tools::SavePagesPHP()) {
         return false;
     }
     return true;
 }
Beispiel #6
0
 function GadgetVisibility($addon, $cmd)
 {
     global $config, $langmessage;
     $gadget = $_GET['gadget'];
     if (!isset($config['gadgets']) || !is_array($config['gadgets']) || !isset($config['gadgets'][$gadget])) {
         message($langmessage['OOPS']);
         return;
     }
     $gadgetInfo =& $config['gadgets'][$gadget];
     switch ($cmd) {
         case 'enable':
             unset($gadgetInfo['disabled']);
             break;
         case 'disable':
             $gadgetInfo['disabled'] = true;
             break;
     }
     if (!admin_tools::SaveConfig()) {
         message($langmessage['OOPS']);
     }
 }
Beispiel #7
0
 function AltMenu_Remove()
 {
     global $langmessage, $config, $dataDir;
     $menu_id =& $_POST['id'];
     if (!$this->IsAltMenu($menu_id)) {
         message($langmessage['OOPS']);
         return;
     }
     $menu_file = $dataDir . '/data/_menus/' . $menu_id . '.php';
     unset($config['menus'][$menu_id]);
     unset($this->avail_menus[$menu_id]);
     if (!admin_tools::SaveConfig()) {
         message($langmessage['OOPS']);
     }
     message($langmessage['SAVED']);
     //delete menu file
     $menu_file = $dataDir . '/data/_menus/' . $menu_id . '.php';
     if (file_exists($menu_file)) {
         unlink($menu_file);
     }
 }
 /**
  * Get addon data from gpEasy.com and display to user
  *
  */
 function RemoteBrowse()
 {
     global $langmessage, $config, $dataDir;
     //search options
     if (isset($_GET['search_option'])) {
         $save = true;
         switch ($_GET['search_option']) {
             case 'version':
                 unset($config['search_version']);
                 break;
             case 'noversion':
                 $config['search_version'] = false;
                 break;
             default:
                 $save = false;
                 break;
         }
         if ($save) {
             admin_tools::SaveConfig();
         }
     }
     //make a list of installed addon id's
     $this->installed_ids = array();
     if (isset($config['addons']) && is_array($config['addons'])) {
         foreach ($config['addons'] as $addon_info) {
             if (isset($addon_info['id'])) {
                 $this->installed_ids[] = $addon_info['id'];
             }
         }
     }
     includeFile('tool/RemoteGet.php');
     //search settings
     $this->searchUrl = $this->path_remote;
     $this->searchOrderOptions['rating_score'] = $langmessage['Highest Rated'];
     $this->searchOrderOptions['downloads'] = $langmessage['Most Downloaded'];
     $this->searchOrderOptions['modified'] = $langmessage['Recently Updated'];
     $this->searchOrderOptions['created'] = $langmessage['Newest'];
     $_GET += array('q' => '');
     if (isset($_REQUEST['page']) && ctype_digit($_REQUEST['page'])) {
         $this->searchPage = $_REQUEST['page'];
     }
     //version specific search
     $search_version = false;
     if (!isset($config['search_version']) || $config['search_version']) {
         $this->searchQuery .= '&ug=' . rawurlencode(gpversion);
         $search_version = true;
     }
     if (!empty($_GET['q'])) {
         $this->searchQuery .= '&q=' . rawurlencode($_GET['q']);
     }
     $this->SearchOrder();
     $slug = 'Plugins';
     if ($this->config_index == 'themes') {
         $slug = 'Themes';
     }
     $src = addon_browse_path . '/' . $slug . '?cmd=remote&format=json&' . $this->searchQuery . '&page=' . $this->searchPage;
     // format=json added 4.6b3
     //check cache
     $cache_file = $dataDir . '/data/_remote/' . sha1($src) . '.txt';
     $use_cache = false;
     if (file_exists($cache_file) && filemtime($cache_file) + 26100 > time()) {
         $result = file_get_contents($cache_file);
         $use_cache = true;
     } else {
         $result = gpRemoteGet::Get_Successful($src);
     }
     //no response
     if (!$result) {
         if ($use_cache) {
             unlink($cache_file);
         }
         echo '<p>' . gpRemoteGet::Debug('Sorry, data not fetched') . '</p>';
         return;
     }
     //serialized or json (serialized data may be cached)
     if (strpos($result, 'a:') === 0) {
         $data = unserialize($result);
     } elseif (strpos($result, '{') === 0) {
         $data = json_decode($result, true);
     } else {
         if ($use_cache) {
             unlink($cache_file);
         }
         $debug = array();
         $debug['Two'] = substr($result, 0, 2);
         $debug['Twotr'] = substr(trim($result), 0, 2);
         echo '<p>' . gpRemoteGet::Debug('Sorry, data not fetched', $debug) . '</p>';
         return;
     }
     //not unserialized?
     if (!is_array($data) || count($data) == 0) {
         if ($use_cache) {
             unlink($cache_file);
         }
         echo '<p>' . $langmessage['Sorry, data not fetched'] . ' (F3)</p>';
         return;
     }
     //save the cache
     if (!$use_cache) {
         gpFiles::Save($cache_file, $result);
     }
     $this->searchMax = $data['max'];
     if (isset($data['per_page']) && $data['per_page']) {
         $this->searchPerPage = $data['per_page'];
     } else {
         $this->searchPerPage = count($data['rows']);
     }
     $this->ShowHeader();
     $this->SearchOptions();
     echo '<table class="bordered full_width">';
     echo '<tr><th></th><th>' . $langmessage['name'] . '</th><th>' . $langmessage['version'] . '</th><th>' . $langmessage['Statistics'] . '</th><th>' . $langmessage['description'] . '</th></tr>';
     $i = 0;
     if (count($data['rows'])) {
         foreach ($data['rows'] as $row) {
             echo '<tr class="' . ($i % 2 ? 'even' : '') . '">';
             echo '<td>';
             echo $this->DetailLink($row['type'], $row['id'], '<img src="' . $row['icon'] . '" height="100" width="100" alt=""/>', '', ' class="shot"');
             echo '</td>';
             echo '<td class="nowrap">';
             echo '<b>' . $row['name'] . '</b>';
             echo '<br/>';
             echo $this->DetailLink($row['type'], $row['id']);
             echo ' | ';
             $this->InstallLink($row);
             echo '</td><td>';
             echo $row['version'];
             echo '</td><td class="nowrap">';
             echo sprintf($langmessage['_downloads'], number_format($row['downloads']));
             echo '<br/>';
             $this->CurrentRating($row['rating_weighted']);
             echo '<br/>';
             echo $row['rating_count'] . ' ratings';
             echo '</td><td>';
             echo $row['short_description'];
             echo '</td></tr>';
             $i++;
         }
         echo '</table>';
         $this->SearchNavLinks();
     } else {
         echo '</table>';
         echo '<p>' . $langmessage['Sorry, nothing matched'] . '</p>';
     }
     echo '<h3>Search Options</h3>';
     echo '<ul>';
     echo '<li>Limit results to addons that are compatible with your version of gpEasy (' . gpversion . ') &nbsp; ';
     if ($search_version) {
         echo '<b>' . $langmessage['On'] . '</b> &nbsp; ';
         echo common::Link($this->searchUrl, $langmessage['Off'], $this->searchQuery . '&search_option=noversion', ' data-cmd="gpajax"');
     } else {
         echo common::Link($this->searchUrl, $langmessage['On'], $this->searchQuery . '&search_option=version', ' data-cmd="gpajax"');
         echo ' &nbsp;  <b>' . $langmessage['Off'] . '</b>';
     }
     echo '</li>';
     echo '</ul>';
 }
Beispiel #9
0
 public static function NewFileNumber()
 {
     global $config;
     includeFile('admin/admin_tools.php');
     if (!isset($config['file_count'])) {
         $config['file_count'] = 0;
     }
     $config['file_count']++;
     admin_tools::SaveConfig();
     return $config['file_count'];
 }
 /**
  * Save the posted page as the homepage
  *
  */
 function HomepageSave()
 {
     global $langmessage, $config, $gp_index, $gp_titles, $page;
     $homepage = $_POST['homepage'];
     $homepage_key = false;
     if (isset($gp_index[$homepage])) {
         $homepage_key = $gp_index[$homepage];
     } else {
         foreach ($gp_titles as $index => $title) {
             if ($title['label'] === $homepage) {
                 $homepage_key = $index;
                 break;
             }
         }
         if (!$homepage_key) {
             message($langmessage['OOPS']);
             return;
         }
     }
     $config['homepath_key'] = $homepage_key;
     $config['homepath'] = common::IndexToTitle($config['homepath_key']);
     if (!admin_tools::SaveConfig()) {
         message($langmessage['OOPS']);
         return;
     }
     //update the display
     ob_start();
     $this->HomepageDisplay();
     $content = ob_get_clean();
     $page->ajaxReplace[] = array('inner', '.homepage_setting', $content);
 }
Beispiel #11
0
 function GadgetVisibility($cmd)
 {
     global $config, $langmessage, $page;
     $page->ajaxReplace = array();
     $gadget = $_GET['gadget'];
     if (!isset($config['gadgets']) || !is_array($config['gadgets']) || !isset($config['gadgets'][$gadget])) {
         message($langmessage['OOPS'] . ' (Invalid Gadget)');
         return;
     }
     $gadgetInfo =& $config['gadgets'][$gadget];
     switch ($cmd) {
         case 'enable':
             unset($gadgetInfo['disabled']);
             break;
         case 'disable':
             $gadgetInfo['disabled'] = true;
             break;
     }
     if (!admin_tools::SaveConfig()) {
         message($langmessage['OOPS'] . ' (Not Saved)');
         return;
     }
     $link = $this->GadgetLink($gadget);
     $page->ajaxReplace[] = array('replace', '.gadget_link_' . $gadget, $link);
 }
Beispiel #12
0
 /**
  * Connect to ftp server using either Post or saved values
  * Connection values will not be kept in $config in case they're being used for a system revert which will replace the config.php file
  * Also handle moving ftp connection values from $config to a sep
  *
  * @return bool true if connected, error message otherwise
  */
 function connect()
 {
     global $config, $dataDir, $langmessage;
     $save_values = false;
     $connect_args = gpFiles::Get('_updates/connect', 'connect_args');
     if (!$connect_args || !isset($connect_args['ftp_user']) && isset($config['ftp_user'])) {
         $connect_args['ftp_user'] = $config['ftp_user'];
         $connect_args['ftp_server'] = $config['ftp_server'];
         $connect_args['ftp_pass'] = $config['ftp_pass'];
         $connect_args['ftp_root'] = $config['ftp_root'];
         $save_values = true;
     }
     if (isset($_POST['ftp_pass'])) {
         $connect_args = $_POST;
         $save_values = true;
     }
     $connect_args = $this->get_connect_vars($connect_args);
     $connected = $this->connect_handler($connect_args);
     if ($connected !== true) {
         return $connected;
     }
     //get the ftp_root
     if (empty($connect_args['ftp_root']) || $save_values) {
         $this->ftp_root = $this->get_base_dir();
         if (!$this->ftp_root) {
             return $langmessage['couldnt_connect'] . ' (Couldn\'t find root)';
         }
         $connect_args['ftp_root'] = $this->ftp_root;
         $save_values = true;
     } else {
         $this->ftp_root = $connect_args['ftp_root'];
     }
     //save ftp info
     if (!$save_values) {
         return $connected;
     }
     $connection_file = $dataDir . '/data/_updates/connect.php';
     if (!gpFiles::SaveData($connection_file, 'connect_args', $connect_args)) {
         return $connected;
     }
     /*
      * Remove from $config if it's not a safe mode installation
      */
     if (!isset($config['useftp']) && isset($config['ftp_user'])) {
         unset($config['ftp_user']);
         unset($config['ftp_server']);
         unset($config['ftp_pass']);
         unset($config['ftp_root']);
         admin_tools::SaveConfig();
     }
     return $connected;
 }
Beispiel #13
0
 /**
  * Replace the /include, /themes and /addons folders
  * Start by creating the new folders with the new content
  * Then replace the existing directories with the new directories
  *
  */
 function UnpackAndReplace()
 {
     global $langmessage, $config, $gp_filesystem, $dataDir;
     if ($gp_filesystem->connect() !== true) {
         $this->msg($langmessage['OOPS'] . ': (not connected)');
         return false;
     }
     if (!$this->UnpackAndSort($this->core_package['file'])) {
         return false;
     }
     $this->msg('Files Sorted');
     $config['updating_message'] = $langmessage['sorry_currently_updating'];
     if (!admin_tools::SaveConfig()) {
         $this->msg($langmessage['error_updating_settings']);
         return false;
     }
     $replaced = $gp_filesystem->ReplaceDirs($this->replace_dirs, $this->extra_dirs);
     if ($replaced !== true) {
         $this->msg($langmessage['error_unpacking'] . ' ' . $replaced);
         $this->RemoveUpdateMessage();
         return false;
     }
     $this->msg($langmessage['copied_new_files']);
     $this->RemoveUpdateMessage();
     return true;
 }
Beispiel #14
0
 function SaveFTPInformation()
 {
     global $config, $langmessage;
     $_POST += array('ftp_server' => '', 'ftp_user' => '', 'ftp_pass' => '');
     //try to connect and login if ftp_server is not empty
     if (!empty($_POST['ftp_server'])) {
         $conn_id = @ftp_connect($_POST['ftp_server'], 21, 6);
         if (!$conn_id) {
             message('Oops, could not connect using ftp_connect() for server <i>' . htmlspecialchars($_POST['ftp_server']) . '</i>');
             return false;
         }
         ob_start();
         $login_result = @ftp_login($conn_id, $_POST['ftp_user'], $_POST['ftp_pass']);
         if (!$login_result) {
             message('Oops, could not login using ftp_login() for server <i>' . $_POST['ftp_server'] . '</i> and user <i>' . $_POST['ftp_user'] . '</i>');
             @ftp_close($conn_id);
             ob_end_clean();
             return false;
         }
         @ftp_close($conn_id);
         ob_end_clean();
     }
     $config['ftp_user'] = $_POST['ftp_user'];
     $config['ftp_server'] = $_POST['ftp_server'];
     $config['ftp_pass'] = $_POST['ftp_pass'];
     if (!admin_tools::SaveConfig()) {
         message('Oops, there was an error saving your ftp information.');
         return false;
     }
     return true;
 }
Beispiel #15
0
function SaveFinderData($data)
{
    global $config;
    $config['finder_data'] = $data;
    admin_tools::SaveConfig();
}