/** * Toggle the visibility of a page * */ static function Toggle($index, $visibility = '') { global $gp_titles, $langmessage; if (!isset($gp_titles[$index])) { msg($langmessage['OOPS'] . ' (Invalid Request)'); return false; } if ($visibility == 'private') { $gp_titles[$index]['vis'] = 'private'; } else { unset($gp_titles[$index]['vis']); } if (!\admin_tools::SavePagesPHP()) { msg($langmessage['OOPS'] . ' (VT1)'); return false; } return true; }
/** * 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 SetImage($img_rel, $width, $height) { global $gpLayouts, $langmessage, $page; $save_info = array(); $save_info['img_rel'] = $img_rel; $save_info['width'] = $width; $save_info['height'] = $height; $container = $_REQUEST['container']; //$gpLayouts[$this->curr_layout]['images'] = array(); //prevents shuffle - REMOVED to allow images per container to be saved. $gpLayouts[$this->curr_layout]['images'][$container] = array(); //prevents shuffle $gpLayouts[$this->curr_layout]['images'][$container][] = $save_info; if (!admin_tools::SavePagesPHP()) { message($langmessage['OOPS'] . ' (Data not saved)'); return false; } $page->ajaxReplace[] = array('ck_saved', '', ''); return true; }
/** * Save config.php and pages.php * */ static function SaveAllConfig() { if (!admin_tools::SaveConfig()) { return false; } if (!admin_tools::SavePagesPHP()) { return false; } return true; }
/** * Perform a page copy * */ function CopyPage() { global $gp_index, $gp_titles, $page, $langmessage; //existing page info $from_title = $_POST['from_title']; if (!isset($gp_index[$from_title])) { message($langmessage['OOPS_TITLE']); return false; } $from_index = $gp_index[$from_title]; $info = $gp_titles[$from_index]; //check the new title $title = $_POST['title']; $title = admin_tools::CheckPostedNewPage($title, $message); if ($title === false) { message($message); return false; } //get the existing content $from_file = gpFiles::PageFile($from_title); $contents = file_get_contents($from_file); //add to $gp_index first! $index = common::NewFileIndex(); $gp_index[$title] = $index; $file = gpFiles::PageFile($title); if (!gpFiles::Save($file, $contents)) { message($langmessage['OOPS'] . ' (File not saved)'); return false; } //add to gp_titles $new_titles = array(); $new_titles[$index]['label'] = admin_tools::PostedLabel($_POST['title']); $new_titles[$index]['type'] = $info['type']; $gp_titles += $new_titles; if (!admin_tools::SavePagesPHP()) { message($langmessage['OOPS'] . ' (CP2)'); return false; } message($langmessage['SAVED']); if (isset($_REQUEST['redir'])) { $url = common::AbsoluteUrl($title, '', true, false); $page->ajaxReplace[] = array('eval', '', 'window.setTimeout(function(){window.location="' . $url . '"},15000);'); message(sprintf($langmessage['will_redirect'], common::Link_Page($title))); } return $index; }
/** * Assign a layout to the $title. Child pages without a layout assigned will inherit this setting * @param string $title */ function SetLayout() { global $gp_index, $gp_titles, $langmessage, $gpLayouts; $index = $_POST['index']; $title = common::IndexToTitle($index); if (!$title) { message($langmessage['OOPS']); return; } $this->title = $title; $layout = $_POST['layout']; if (!isset($gpLayouts[$layout])) { message($langmessage['OOPS']); return; } if (!common::verify_nonce('use_' . $layout)) { message($langmessage['OOPS']); return; } //unset, then reset if needed unset($gp_titles[$index]['gpLayout']); $currentLayout = display::OrConfig($index, 'gpLayout'); if ($currentLayout != $layout) { $gp_titles[$index]['gpLayout'] = $layout; } if (!admin_tools::SavePagesPHP()) { message($langmessage['OOPS'] . '(3)'); return false; } message($langmessage['SAVED']); }
function SaveHandlersNew($handlers, $layout = false) { global $config, $page, $langmessage, $gpLayouts; //make sure the keys are sequential foreach ($handlers as $container => $container_info) { if (is_array($container_info)) { $handlers[$container] = array_values($container_info); } } if ($layout == false) { $layout = $this->curr_layout; } if (!isset($gpLayouts[$layout])) { message($langmessage['OOPS']); return false; } $gpLayoutsBefore = $gpLayouts; if (count($handlers) === 0) { unset($gpLayouts[$layout]['handlers']); } else { $gpLayouts[$layout]['handlers'] = $handlers; } if (admin_tools::SavePagesPHP()) { message($langmessage['SAVED']); } else { $gpLayouts = $gpLayoutsBefore; message($langmessage['OOPS'] . ' (s1)'); } }
static function RenameFile($title) { global $langmessage, $page, $gp_index, $gp_titles; //change the title $title = gp_rename::RenameFileWorker($title); if ($title === false) { return false; } if (!isset($gp_index[$title])) { msg($langmessage['OOPS']); return false; } $id = $gp_index[$title]; $title_info =& $gp_titles[$id]; //change the label $title_info['label'] = admin_tools::PostedLabel($_POST['new_label']); if (isset($title_info['lang_index'])) { unset($title_info['lang_index']); } //change the browser title $auto_browser_title = strip_tags($title_info['label']); $custom_browser_title = false; if (isset($_POST['browser_title'])) { $browser_title = $_POST['browser_title']; $browser_title = htmlspecialchars($browser_title); if ($browser_title != $auto_browser_title) { $title_info['browser_title'] = trim($browser_title); $custom_browser_title = true; } } if (!$custom_browser_title) { unset($title_info['browser_title']); } //keywords if (isset($_POST['keywords'])) { $title_info['keywords'] = htmlspecialchars($_POST['keywords']); if (empty($title_info['keywords'])) { unset($title_info['keywords']); } } //description if (isset($_POST['description'])) { $title_info['description'] = htmlspecialchars($_POST['description']); if (empty($title_info['description'])) { unset($title_info['description']); } } //robots $title_info['rel'] = ''; if (isset($_POST['nofollow'])) { $title_info['rel'] = 'nofollow'; } if (isset($_POST['noindex'])) { $title_info['rel'] .= ',noindex'; } $title_info['rel'] = trim($title_info['rel'], ','); if (empty($title_info['rel'])) { unset($title_info['rel']); } if (!admin_tools::SavePagesPHP()) { msg($langmessage['OOPS'] . ' (R1)'); return false; } msg($langmessage['SAVED']); return $title; }
/** * Update layout information if needed * */ static function LayoutInfo() { global $page, $gpLayouts, $get_all_gadgets_called; if (!gpOutput::$template_included) { return; } if (common::RequestType() != 'template') { return; } $layout = $page->gpLayout; if (!isset($gpLayouts[$layout])) { return; } $layout_info =& $gpLayouts[$layout]; //template.php file not modified $template_file = realpath($page->theme_dir . '/template.php'); $template_mod = filemtime($template_file); if (isset($layout_info['template_mod']) && $layout_info['template_mod'] >= $template_mod) { return; } $contents = ob_get_contents(); //charset if (strpos($contents, 'charset=') !== false) { return; } //get just the head of the buffer to see if we need to add charset $pos = strpos($contents, '</head'); unset($layout_info['doctype']); if ($pos > 0) { $head = substr($contents, 0, $pos); $layout_info['doctype'] = self::DoctypeMeta($head); } $layout_info['all_gadgets'] = $get_all_gadgets_called; //save $layout_info['template_mod'] = $template_mod; admin_tools::SavePagesPHP(); }
/** * Recalculate the file_type string for this file * Updates $this->meta_data and $gp_titles * */ function ResetFileTypes($save = true) { global $gp_titles; $original_types = array(); if (isset($this->meta_data['file_type'])) { $original_types = explode(',', $this->meta_data['file_type']); } $new_types = array(); foreach ($this->file_sections as $section) { $new_types[] = $section['type']; } $new_types = array_unique($new_types); $new_types = array_diff($new_types, array('')); sort($new_types); $new_types = implode(',', $new_types); $this->meta_data['file_type'] = $new_types; if (!isset($gp_titles[$this->gp_index])) { return; } $gp_titles[$this->gp_index]['type'] = $new_types; admin_tools::SavePagesPHP(); if ($save) { $this->SaveThis(); } }
/** * Save whether or not the template is using GetAllGadgets() * */ function AllGadgetSetting() { global $get_all_gadgets_called, $page, $gpLayouts; if (!common::LoggedIn()) { return; } $layout = $page->gpLayout; if (!isset($gpLayouts[$layout])) { return; } $layout_info =& $gpLayouts[$layout]; $current_setting = true; if (isset($layout_info['all_gadgets']) && !$layout_info['all_gadgets']) { $current_setting = false; } if ($current_setting == $get_all_gadgets_called) { return; } $layout_info['all_gadgets'] = $get_all_gadgets_called; admin_tools::SavePagesPHP(); }
/** * Remove files from the trash by restoring them to $gp_titles and $gp_index * */ function RestoreNew() { global $langmessage, $gp_titles, $gp_index; if (empty($_POST['title']) || !is_array($_POST['title'])) { message($langmessage['OOPS'] . ' (No Titles)'); return; } $titles = $_POST['title']; $this->RestoreTitles($titles); if (count($titles) == 0) { message($langmessage['OOPS'] . ' (R1)'); return false; } if (!admin_tools::SavePagesPHP()) { message($langmessage['OOPS'] . ' (R4)'); return false; } admin_trash::ModTrashData(null, $titles); $show_titles = array(); foreach ($titles as $title => $null) { $show_titles[] = htmlspecialchars($title); } $title_string = implode(', ', $show_titles); $link = common::GetUrl('Admin_Menu'); $message = sprintf($langmessage['file_restored'], $title_string, $link); message($message); }
/** * Save pages * * @param array $titles * @return bool */ protected function SaveNew($titles) { global $langmessage; //menu modification if (isset($_POST['insert_where']) && isset($_POST['insert_how'])) { if (!$this->MenuInsert($titles, $_POST['insert_where'], $_POST['insert_how'])) { msg($langmessage['OOPS'] . ' (Insert Failed)'); return false; } if (!$this->SaveMenu(true)) { msg($langmessage['OOPS'] . ' (Menu Not Saved)'); return false; } return true; } if (!admin_tools::SavePagesPHP()) { msg($langmessage['OOPS'] . ' (Page index not saved)'); return false; } return true; }
/** * Remove files from the trash by restoring them to $gp_titles and $gp_index * */ function RestoreDeleted() { global $langmessage, $gp_titles, $gp_index; if (empty($_POST['titles']) || !is_array($_POST['titles'])) { message($langmessage['OOPS'] . ' (No Titles)'); return; } $titles = $_POST['titles']; admin_trash::RestoreTitles($titles); if (!$titles) { message($langmessage['OOPS'] . ' (R1)'); return false; } if (!admin_tools::SavePagesPHP()) { message($langmessage['OOPS'] . ' (R4)'); return false; } admin_trash::ModTrashData(null, $titles); $show_titles = array(); foreach ($titles as $trash_index => $info) { $show_titles[] = common::Link($info['title'], $info['title']); unset($this->trash_files[$trash_index]); } $title_string = implode(', ', $show_titles); $link = common::GetUrl('Admin_Menu'); $message = sprintf($langmessage['file_restored'], $title_string, $link); message($message); }
public function NewDrag() { global $page, $langmessage, $gp_index, $gp_titles; $page->ajaxReplace = array(); //get the title of the gallery that was moved $dragging = $_POST['title']; if (!isset($this->galleries[$dragging])) { message($langmessage['OOPS'] . ' (Title not in gallery list)'); return false; } $index = $gp_index[$dragging]; $info = $this->galleries[$dragging]; unset($this->galleries[$dragging]); //set visibility if (isset($_POST['active'])) { $info['visibility'] = 'show'; unset($gp_titles[$index]['vis']); } else { $info['visibility'] = 'hide'; } //place before the element represented by $_POST['next'] if it's set if (isset($_POST['next'])) { $next = $_POST['next']; if (!isset($this->galleries[$next])) { message($langmessage['OOPS'] . ' (Next not found)'); return false; } if (!gpFiles::ArrayInsert($next, $dragging, $info, $this->galleries)) { message($langmessage['OOPS'] . ' (Insert Failed)'); return false; } //place at the end } else { $this->galleries[$dragging] = $info; } //save it if (!special_galleries::SaveIndex($this->galleries)) { message($langmessage['OOPS'] . ' (Not Saved)'); return false; } if (!admin_tools::SavePagesPHP()) { message($langmessage['OOPS'] . ' (Not Saved)'); return false; } }