示例#1
0
 /**
  * Save the posted configuration
  *
  */
 protected function SaveConfig()
 {
     global $config, $langmessage;
     $possible = $this->getPossible();
     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 (!\gp\admin\Tools::SaveConfig(true)) {
         return false;
     }
     if (isset($_GET['gpreq']) && $_GET['gpreq'] == 'json') {
         message($langmessage['SAVED'] . ' ' . $langmessage['REFRESH']);
     } else {
         message($langmessage['SAVED']);
     }
 }
示例#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;
     $special_indexes = array();
     $new_index = array();
     $new_titles = array();
     foreach ($gp_index as $title => $index) {
         $info = $gp_titles[$index];
         $type = \gp\tool::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 (!\gp\admin\Tools::SavePagesPHP()) {
         return;
     }
     $config['gpversion'] = '2.3.4';
     \gp\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 (\gp\tool\Files::Exists($menu_file)) {
                 $menu = \gp\tool\Output::GetMenuArray($key);
                 $menu = $this->FixMenu($menu, $special_indexes);
                 \gp\tool\Files::SaveData($menu_file, 'menu', $menu);
             }
         }
     }
 }
示例#3
0
 /**
  * Save the posted page as the homepage
  *
  */
 public function HomepageSave()
 {
     global $langmessage, $config, $gp_index, $gp_titles;
     $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) {
             msg($langmessage['OOPS']);
             return;
         }
     }
     $config['homepath_key'] = $homepage_key;
     $config['homepath'] = \gp\tool::IndexToTitle($config['homepath_key']);
     if (!\gp\admin\Tools::SaveConfig(true)) {
         return;
     }
     //update the display
     ob_start();
     $this->HomepageDisplay();
     $content = ob_get_clean();
     $this->page->ajaxReplace[] = array('inner', '.homepage_setting', $content);
 }
示例#4
0
function SaveFinderData($data)
{
    global $config;
    $config['finder_data'] = $data;
    \gp\admin\Tools::SaveConfig();
}
示例#5
0
 function GadgetVisibility($cmd)
 {
     global $config, $langmessage;
     $this->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 (!\gp\admin\Tools::SaveConfig(true)) {
         return;
     }
     $link = $this->GadgetLink($gadget);
     $this->page->ajaxReplace[] = array('replace', '.gadget_link_' . md5($gadget), $link);
 }
示例#6
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, $dataDir;
     if (!$this->FileSystem->connect()) {
         $this->msg($langmessage['OOPS'] . ': (not connected)');
         return false;
     }
     try {
         if (!$this->UnpackAndSort($this->core_package['file'])) {
             return false;
         }
     } catch (\Exception $e) {
         $this->msg($langmessage['error_unpacking'] . ' (no root)');
         return false;
     }
     $this->msg('Files Sorted');
     $config['updating_message'] = $langmessage['sorry_currently_updating'];
     if (!\gp\admin\Tools::SaveConfig()) {
         $this->msg($langmessage['error_updating_settings']);
         return false;
     }
     $replaced = $this->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;
 }
示例#7
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
  */
 public function connect()
 {
     global $config, $dataDir, $langmessage;
     $save_values = false;
     $connect_args = \gp\tool\Files::Get('_updates/connect', 'connect_args');
     if (!$connect_args || !isset($connect_args['ftp_user'])) {
         if (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 (!is_null($connected)) {
         return false;
     }
     //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 true;
     }
     $connection_file = $dataDir . '/data/_updates/connect.php';
     if (!\gp\tool\Files::SaveData($connection_file, 'connect_args', $connect_args)) {
         return true;
     }
     /*
      * 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']);
         \gp\admin\Tools::SaveConfig();
     }
     return true;
 }
示例#8
0
 /**
  * Save the config setting
  *
  */
 protected function SaveConfig()
 {
     global $config;
     if (\gp\admin\Tools::SaveConfig(true, true)) {
         return true;
     }
     if (is_array($this->config_before)) {
         $config = $this->config_before;
     }
     return false;
 }
示例#9
0
 /**
  * Remove an alternate menu from the configuration and delete the data file
  *
  */
 public function MenuRemove()
 {
     global $langmessage, $config, $dataDir;
     $menu_id =& $_POST['id'];
     if (!\gp\admin\Menu\Tools::IsAltMenu($menu_id)) {
         msg($langmessage['OOPS']);
         return;
     }
     $menu_file = $dataDir . '/data/_menus/' . $menu_id . '.php';
     unset($config['menus'][$menu_id]);
     unset($this->avail_menus[$menu_id]);
     \gp\admin\Tools::SaveConfig(true, true);
     //delete menu file
     $menu_file = $dataDir . '/data/_menus/' . $menu_id . '.php';
     if (\gp\tool\Files::Exists($menu_file)) {
         unlink($menu_file);
     }
 }
示例#10
0
 public static function NewFileNumber()
 {
     global $config;
     if (!isset($config['file_count'])) {
         $config['file_count'] = 0;
     }
     $config['file_count']++;
     \gp\admin\Tools::SaveConfig();
     return $config['file_count'];
 }
示例#11
0
 /**
  * Save the search option
  *
  */
 private function SearchOptionSave()
 {
     global $config;
     if (!isset($_GET['search_option'])) {
         return;
     }
     switch ($_GET['search_option']) {
         case 'version':
             unset($config['search_version']);
             break;
         case 'noversion':
             $config['search_version'] = false;
             break;
         default:
             return;
     }
     \gp\admin\Tools::SaveConfig();
 }