/**
  * 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']);
     }
 }
Beispiel #2
0
 /**
  * Generate admin toolbar links
  *
  */
 public function AdminLinks()
 {
     global $langmessage;
     $admin_links = $this->admin_links;
     $menu_permissions = \gp\admin\Tools::HasPermission('Admin_Menu');
     if ($menu_permissions) {
         //visibility
         $q = 'cmd=ToggleVisibility';
         $label = '<i class="fa fa-eye-slash"></i> ' . $langmessage['Visibility'] . ': ' . $langmessage['Private'];
         if (!$this->visibility) {
             $label = '<i class="fa fa-eye"></i> ' . $langmessage['Visibility'] . ': ' . $langmessage['Public'];
             $q .= '&visibility=private';
         }
         $attrs = array('title' => $label, 'data-cmd' => 'creq');
         $admin_links[] = \gp\tool::Link($this->title, $label, $q, $attrs);
     }
     // page options: less frequently used links that don't have to do with editing the content of the page
     $option_links = array();
     if ($menu_permissions) {
         $option_links[] = \gp\tool::Link($this->title, $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($this->gp_index), 'data-cmd="gpajax"');
         $option_links[] = \gp\tool::Link('Admin/Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), array('title' => $langmessage['current_layout'], 'data-cmd' => 'gpabox'));
     }
     if (\gp\admin\Tools::HasPermission('Admin_User')) {
         $option_links[] = \gp\tool::Link('Admin/Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), array('title' => $langmessage['permissions'], 'data-cmd' => 'gpabox'));
     }
     if (!empty($option_links)) {
         $admin_links[$langmessage['options']] = $option_links;
     }
     return $admin_links;
 }
Beispiel #3
0
 /**
  * Toggle the visibility of a page given by $index
  *
  */
 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']);
     }
     return \gp\admin\Tools::SavePagesPHP(true);
 }
Beispiel #4
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);
             }
         }
     }
 }
Beispiel #5
0
 public function NewDrag()
 {
     global $langmessage, $gp_index, $gp_titles;
     $this->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 (!\gp\tool\Files::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 (!self::SaveIndex($this->galleries)) {
         message($langmessage['OOPS'] . ' (Not Saved)');
         return false;
     }
     if (!\gp\admin\Tools::SavePagesPHP(true)) {
         return false;
     }
 }
Beispiel #6
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);
 }
Beispiel #7
0
 /**
  * Plugin option links
  *
  */
 function OptionLinks($addon_key, $addon_config, $format = false)
 {
     global $langmessage, $gpLayouts;
     $list = array();
     if (!isset($addon_config['is_theme']) || !$addon_config['is_theme']) {
         //editable text
         if (isset($addon_config['editable_text']) && \gp\admin\Tools::HasPermission('Admin_Theme_Content')) {
             $list[] = \gp\tool::Link('Admin_Theme_Content/Text', $langmessage['editable_text'], 'cmd=AddonTextForm&addon=' . urlencode($addon_key), array('title' => urlencode($langmessage['editable_text']), 'data-cmd' => 'gpabox'));
         }
         //upgrade link
         if (isset($addon_config['upgrade_from'])) {
             $list[] = '<a href="?cmd=LocalInstall&source=' . rawurlencode($addon_config['upgrade_from']) . '" data-cmd="cnreq">' . $langmessage['upgrade'] . '</a>';
         }
         //uninstall
         $list[] = \gp\tool::Link('Admin/Addons', $langmessage['uninstall'], 'cmd=uninstall&addon=' . rawurlencode($addon_key), 'data-cmd="gpabox"');
         //version
         if (!empty($addon_config['version'])) {
             $list[] = '<a>' . $langmessage['Your_version'] . ' ' . $addon_config['version'] . '</a>';
         }
         //rating
         if (isset($addon_config['id']) && is_numeric($addon_config['id'])) {
             $id = $addon_config['id'];
             $rating = 5;
             if (isset($this->addonReviews[$id])) {
                 $rating = $this->addonReviews[$id]['rating'];
             }
             $label = $langmessage['rate_this_addon'] . ' ' . $this->ShowRating($id, $rating);
             $list[] = '<span>' . $label . '</span>';
         }
         echo $this->FormatList($list, $langmessage['options'], $format);
         return;
     }
     //show list of themes using these addons
     foreach ($gpLayouts as $layout_id => $layout_info) {
         if (!isset($layout_info['addon_key']) || $layout_info['addon_key'] !== $addon_key) {
             continue;
         }
         $item = '<span><span class="layout_color_id" style="background:' . $layout_info['color'] . '"></span> ';
         $item .= \gp\tool::Link('Admin_Theme_Content', $layout_info['label']);
         $item .= ' ( ';
         $item .= \gp\tool::Link('Admin_Theme_Content/Edit/' . $layout_id, $langmessage['edit']);
         $item .= ' )</span>';
         $list[] = $item;
     }
     echo $this->FormatList($list, $langmessage['layouts'], $format);
 }
 /**
  * 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;
 }
Beispiel #9
0
 public function Exported()
 {
     global $langmessage;
     if (count($this->exported) == 0) {
         return;
     }
     echo '<table class="bordered full_width">';
     echo '<tr><th>';
     echo $langmessage['Previous Exports'];
     echo '</th><th> &nbsp; </th><th>';
     echo $langmessage['File Size'];
     echo '</th><th>';
     echo $langmessage['options'];
     echo '</th></tr>';
     $total_size = 0;
     $total_count = 0;
     foreach ($this->exported as $file) {
         $info = $this->FileInfo($file);
         if (!$info) {
             continue;
         }
         $full_path = $this->export_dir . '/' . $file;
         echo '<tr><td>';
         echo str_replace(' ', '&nbsp;', $info['time']);
         echo '</td><td>';
         echo implode(', ', $info['exported']);
         echo '</td><td>';
         $size = filesize($full_path);
         echo \gp\admin\Tools::FormatBytes($size);
         echo ' ';
         echo $info['ext'];
         echo '</td><td>';
         echo '<a href="' . \gp\tool::GetDir('/data/_exports/' . $file) . '">' . $langmessage['Download'] . '</a>';
         echo '&nbsp;&nbsp;';
         if ($this->CanRevert($info['bits'])) {
             echo \gp\tool::Link('Admin/Port', $langmessage['Revert'], 'cmd=revert&archive=' . rawurlencode($file), '', $file);
         } else {
             echo $langmessage['Revert'];
         }
         echo '&nbsp;&nbsp;';
         echo \gp\tool::Link('Admin/Port', $langmessage['delete'], 'cmd=delete&file=' . rawurlencode($file), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_confirm'], 'class' => 'gpconfirm'), $file);
         echo '</td></tr>';
         $total_count++;
         $total_size += $size;
     }
     //totals
     echo '<tr><th>';
     echo $langmessage['Total'];
     echo ': ';
     echo $total_count;
     echo '</th><th>&nbsp;</th><th>';
     echo \gp\admin\Tools::FormatBytes($total_size);
     echo '</th><th>&nbsp;</th></tr>';
     echo '</table>';
 }
Beispiel #10
0
 /**
  * Create a new page from a user post
  *
  */
 public static function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage, $gpAdmin;
     //check title
     $title = $_POST['title'];
     $title = \gp\admin\Tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         msg($message);
         return false;
     }
     //multiple section types
     $type = $_POST['content_type'];
     if (strpos($type, '{') === 0) {
         $types = json_decode($type, true);
         if ($types) {
             $types += array('wrapper_class' => 'gpRow');
             $content = array();
             //wrapper section
             $section = \gp\tool\Editing::DefaultContent('wrapper_section');
             $section['contains_sections'] = count($types['types']);
             $section['attributes']['class'] = $types['wrapper_class'];
             $content[] = $section;
             //nested sections
             foreach ($types['types'] as $type) {
                 if (strpos($type, '.')) {
                     list($type, $class) = explode('.', $type, 2);
                 } else {
                     $class = '';
                 }
                 $section = \gp\tool\Editing::DefaultContent($type);
                 $section['attributes']['class'] .= ' ' . $class;
                 $content[] = $section;
             }
         }
         //single section type
     } else {
         $content = \gp\tool\Editing::DefaultContent($type, $_POST['title']);
         if ($content['content'] === false) {
             return false;
         }
     }
     //add to $gp_index first!
     $index = \gp\tool::NewFileIndex();
     $gp_index[$title] = $index;
     if (!\gp\tool\Files::NewTitle($title, $content, $type)) {
         msg($langmessage['OOPS'] . ' (cn1)');
         unset($gp_index[$title]);
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = \gp\admin\Tools::PostedLabel($_POST['title']);
     $new_titles[$index]['type'] = $type;
     $gp_titles += $new_titles;
     //add to users editing
     if ($gpAdmin['editing'] != 'all') {
         $gpAdmin['editing'] = rtrim($gpAdmin['editing'], ',') . ',' . $index . ',';
         $users = \gp\tool\Files::Get('_site/users');
         $users[$gpAdmin['username']]['editing'] = $gpAdmin['editing'];
         \gp\tool\Files::SaveData('_site/users', 'users', $users);
     }
     return $index;
 }
Beispiel #11
0
 /**
  * Save a new redirection
  *
  */
 function SaveRedir()
 {
     global $langmessage;
     if (!$this->CheckRedir()) {
         return false;
     }
     $source = \gp\admin\Tools::PostedSlug($_POST['source']);
     if (isset($this->error_data['redirects'][$source])) {
         message($langmessage['OOPS'] . ' (Redirect Already Set)');
         return false;
     }
     $this->error_data['redirects'][$source] = array();
     $this->error_data['redirects'][$source]['target'] = $_POST['target'];
     $this->error_data['redirects'][$source]['code'] = $_POST['code'];
     $this->error_data['redirects'][$source]['raw_source'] = $_POST['source'];
     return $this->SaveData_Message();
 }
Beispiel #12
0
 public function AddonPanel_Gadget($addon_key, $format)
 {
     global $langmessage, $config;
     $gadgets = \gp\admin\Tools::GetAddonComponents($config['gadgets'], $addon_key);
     $links = array();
     foreach ($gadgets as $name => $value) {
         $links[] = $this->GadgetLink($name);
     }
     $this->FormatList($links, $langmessage['gadgets'], $format);
 }
Beispiel #13
0
 /**
  * Generate a file with all of the combined content
  *
  */
 public static function GenerateFile($files, $type)
 {
     global $dataDir;
     //get etag
     $modified = $content_length = 0;
     $full_paths = array();
     foreach ($files as $file) {
         $full_path = self::CheckFile($file);
         if ($full_path === false) {
             continue;
         }
         self::FileStat_Static($full_path, $modified, $content_length);
         $full_paths[$file] = $full_path;
     }
     //check css imports
     if ($type == 'css') {
         $had_imported = false;
         $import_data = array();
         $imported_file = $dataDir . '/data/_cache/import_info.php';
         if (file_exists($imported_file)) {
             include_once $imported_file;
         }
         foreach ($full_paths as $file => $full_path) {
             if (!isset($import_data[$full_path])) {
                 continue;
             }
             $had_imported = true;
             foreach ($import_data[$full_path] as $imported_full) {
                 self::FileStat_Static($imported_full, $modified, $content_length);
             }
             unset($import_data[$full_path]);
         }
     }
     //check to see if file exists
     $etag = \gp\tool::GenEtag(json_encode($files), $modified, $content_length);
     $cache_relative = '/data/_cache/combined_' . $etag . '.' . $type;
     $cache_file = $dataDir . $cache_relative;
     if (file_exists($cache_file)) {
         // change modified time to extend cache
         if (time() - filemtime($cache_file) > 604800) {
             touch($cache_file);
         }
         return $cache_relative;
     }
     //create file
     if ($type == 'js') {
         ob_start();
         \gp\tool::jsStart();
         foreach ($full_paths as $full_path) {
             readfile($full_path);
             echo ";\n";
         }
         $combined_content = ob_get_clean();
     } else {
         $imports = $combined_content = '';
         $new_imported = array();
         foreach ($full_paths as $file => $full_path) {
             $temp = new \gp\tool\Output\CombineCss($file);
             $combined_content .= "\n/* " . $file . " */\n";
             $combined_content .= $temp->content;
             $imports .= $temp->imports;
             if (count($temp->imported)) {
                 $new_imported[$full_path] = $temp->imported;
             }
         }
         $combined_content = $imports . $combined_content;
         //save imported data
         if (count($new_imported) || $had_imported) {
             if (count($new_imported)) {
                 $import_data = $new_imported + $import_data;
             }
             \gp\tool\Files::SaveData($imported_file, 'import_data', $import_data);
         }
     }
     if (!\gp\tool\Files::Save($cache_file, $combined_content)) {
         return false;
     }
     \gp\admin\Tools::CleanCache();
     return $cache_relative;
 }
Beispiel #14
0
 /**
  * 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);
     }
 }
Beispiel #15
0
 /**
  * Assign a layout to the $title. Child pages without a layout assigned will inherit this setting
  * @param string $title
  */
 public function SetLayout()
 {
     global $gp_index, $gp_titles, $langmessage, $gpLayouts;
     $index = $_POST['index'];
     $title = \gp\tool::IndexToTitle($index);
     if (!$title) {
         msg($langmessage['OOPS']);
         return;
     }
     $this->title = $title;
     $layout = $_POST['layout'];
     if (!isset($gpLayouts[$layout])) {
         msg($langmessage['OOPS']);
         return;
     }
     if (!\gp\tool::verify_nonce('use_' . $layout)) {
         msg($langmessage['OOPS']);
         return;
     }
     //unset, then reset if needed
     unset($gp_titles[$index]['gpLayout']);
     $currentLayout = \gp\Page::OrConfig($index, 'gpLayout');
     if ($currentLayout != $layout) {
         $gp_titles[$index]['gpLayout'] = $layout;
     }
     return \gp\admin\Tools::SavePagesPHP(true, true);
 }
Beispiel #16
0
 /**
  * Show files in the cache
  *
  */
 protected function ShowFiles()
 {
     global $langmessage;
     $this->page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js';
     $this->page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});';
     if (!$this->all_files) {
         return;
     }
     echo '<p>';
     echo \gp\tool::Link('Admin/Cache', 'Empty Cache', 'cmd=EmptyResourceCache', array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => 'Empty the resource cache?'));
     echo '</p>';
     echo '<table class="bordered tablesorter full_width">';
     echo '<thead>';
     echo '<tr><th>';
     echo $langmessage['file_name'];
     echo '</th><th>';
     echo $langmessage['File Size'];
     echo '</th><th>';
     echo 'Touched';
     echo '</th><th>';
     echo $langmessage['options'];
     echo '</th></tr>';
     echo '</thead>';
     $total_size = 0;
     echo '<tbody>';
     foreach ($this->all_files as $file) {
         $full = $this->cache_dir . '/' . $file;
         echo '<tr><td>';
         echo '<a href="?cmd=ViewFile&amp;file=' . rawurlencode($file) . '">';
         echo $file;
         echo '</a>';
         echo '</td><td>';
         $size = filesize($full);
         echo '<span style="display:none">' . $size . '</span>';
         echo \gp\admin\Tools::FormatBytes($size);
         $total_size += $size;
         echo '</td><td>';
         $elapsed = \gp\admin\Tools::Elapsed(time() - filemtime($full));
         echo sprintf($langmessage['_ago'], $elapsed);
         echo '</td><td>';
         echo \gp\tool::Link('Admin/Cache', $langmessage['delete'], 'cmd=DeleteFile&amp;file=' . rawurlencode($file), array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $langmessage['delete_confirm']));
         echo '</tr>';
     }
     echo '</tbody>';
     //totals
     echo '<tfoot>';
     echo '<tr><td>';
     echo number_format(count($this->all_files)) . ' Files';
     echo '</td><td>';
     echo \gp\admin\Tools::FormatBytes($total_size);
     echo '</td><td>';
     echo '</tr>';
     echo '</table>';
 }
Beispiel #17
0
 /**
  * Get the remote package
  *
  */
 public function GetRemote()
 {
     global $langmessage, $dataDir;
     // check values
     if (empty($this->type) || empty($this->id) || !is_numeric($this->id)) {
         $this->message($langmessage['OOPS'] . ' (Invalid Request)');
         return false;
     }
     // download url
     $download_url = \gp\admin\Tools::RemoteUrl($this->type);
     // allowed to remote install?
     if ($download_url === false) {
         $this->message($langmessage['OOPS'] . ' (Can\'t remote install ' . $this->type . ')');
         return false;
     }
     $download_url .= '?cmd=install&id=' . rawurlencode($this->id);
     // purchase order id
     if (is_null($this->order)) {
         $this->order = $this->GetOrder($this->id);
     }
     if (!is_null($this->order)) {
         $download_url .= '&order=' . rawurlencode($this->order);
     }
     // able to remote install?
     if (!\gp\admin\Tools::CanRemoteInstall()) {
         $this->message($langmessage['OOPS'] . ' (Can\'t remote install)');
         return false;
     }
     // get package from remote
     $full_result = \gp\tool\RemoteGet::Get($download_url);
     if ((int) $full_result['response']['code'] < 200 && (int) $full_result['response']['code'] >= 300) {
         $this->message($langmessage['download_failed'] . ' (1)');
         return false;
     }
     // download failed and a message was sent
     if (isset($full_result['headers']['x-error'])) {
         $this->message(htmlspecialchars($full_result['headers']['x-error']));
         $this->message(sprintf($langmessage['download_failed_xerror'], 'href="' . self::DetailUrl($_POST['type'], $_POST['id']) . '" data-cmd="remote"'));
         return false;
     }
     $result = $full_result['body'];
     $md5 =& $full_result['headers']['x-md5'];
     //check md5
     $package_md5 = md5($result);
     if ($package_md5 != $md5) {
         $this->message($langmessage['download_failed_md5'] . ' <br/> (Package Checksum ' . $package_md5 . ' != Expected Checksum ' . $md5 . ')');
         return false;
     }
     //save contents
     $tempfile = $dataDir . \gp\tool\FileSystem::TempFile('/data/_temp/addon', '.zip');
     if (!\gp\tool\Files::Save($tempfile, $result)) {
         $this->message($langmessage['download_failed'] . ' (Package not saved)');
         return false;
     }
     $this->source = $this->TempFile();
     $success = $this->ExtractArchive($tempfile);
     unlink($tempfile);
     return $success;
 }
Beispiel #18
0
 public static function RunOut()
 {
     global $page;
     $page->RunScript();
     //prepare the admin content
     if (\gp\tool::LoggedIn()) {
         \gp\admin\Tools::AdminHtml();
     }
     //decide how to send the content
     self::Prep();
     switch (\gp\tool::RequestType()) {
         // <a data-cmd="admin_box">
         case 'flush':
             self::Flush();
             break;
             // remote request
             // file browser
         // remote request
         // file browser
         case 'body':
             \gp\tool::CheckTheme();
             self::BodyAsHTML();
             break;
         case 'admin':
             self::AdminHtml();
             break;
             // <a data-cmd="gpajax">
             // <a data-cmd="gpabox">
             // <input data-cmd="gpabox">
         // <a data-cmd="gpajax">
         // <a data-cmd="gpabox">
         // <input data-cmd="gpabox">
         case 'json':
             \gp\tool::CheckTheme();
             \gp\tool\Output\Ajax::Response();
             break;
         case 'content':
             self::Content();
             break;
         default:
             \gp\tool::CheckTheme();
             self::Template();
             break;
     }
     // if logged in, don't send 304 response
     if (\gp\tool::LoggedIn()) {
         //empty edit links if there isn't a layout
         if (!$page->gpLayout) {
             self::$editlinks = '';
         }
         return;
     }
     // attempt to send 304 response
     if ($page->fileModTime > 0) {
         global $wbMessageBuffer;
         $len = strlen(self::$head_content) + strlen(self::$head_js) + ob_get_length();
         if (count($wbMessageBuffer)) {
             $len += strlen(json_encode($wbMessageBuffer));
         }
         \gp\tool::Send304(\gp\tool::GenEtag($page->fileModTime, $len));
     }
 }
Beispiel #19
0
 public function GetSection(&$section_num)
 {
     global $langmessage;
     if (!isset($this->file_sections[$section_num])) {
         trigger_error('invalid section number');
         return;
     }
     $curr_section_num = $section_num;
     $section_num++;
     $content = '';
     $section_data = $this->file_sections[$curr_section_num];
     //make sure section_data is an array
     $type = gettype($section_data);
     if ($type !== 'array') {
         trigger_error('$section_data is ' . $type . '. Array expected');
         return;
     }
     $section_data += array('attributes' => array(), 'type' => 'text');
     $section_data['attributes'] += array('class' => '');
     $orig_attrs = $section_data['attributes'];
     $section_data['attributes']['data-gp-section'] = $curr_section_num;
     $section_types = \gp\tool\Output\Sections::GetTypes();
     if (\gp\tool\Output::ShowEditLink() && \gp\admin\Tools::CanEdit($this->gp_index)) {
         if (isset($section_types[$section_data['type']])) {
             $title_attr = $section_types[$section_data['type']]['label'];
         } else {
             $title_attr = sprintf($langmessage['Section %s'], $curr_section_num + 1);
         }
         $attrs = array('title' => $title_attr, 'data-cmd' => 'inline_edit_generic', 'data-arg' => $section_data['type'] . '_inline_edit');
         $link = \gp\tool\Output::EditAreaLink($edit_index, $this->title, $langmessage['edit'], 'section=' . $curr_section_num, $attrs);
         $section_data['attributes']['data-gp-area-id'] = $edit_index;
         //section control links
         if ($section_data['type'] != 'wrapper_section') {
             ob_start();
             echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">';
             echo $link;
             echo \gp\tool::Link($this->title, $langmessage['Manage Sections'], 'cmd=ManageSections', array('class' => 'manage_sections', 'data-cmd' => 'inline_edit_generic', 'data-arg' => 'manage_sections'));
             echo '<span class="gp_separator"></span>';
             echo \gp\tool::Link($this->title, $langmessage['rename/details'], 'cmd=renameform&index=' . urlencode($this->gp_index), 'data-cmd="gpajax"');
             echo \gp\tool::Link($this->title, $langmessage['Revision History'], 'cmd=ViewHistory', array('data-cmd' => 'gpabox'));
             echo '<span class="gp_separator"></span>';
             echo \gp\tool::Link('Admin/Menu', $langmessage['file_manager']);
             echo '</span>';
             \gp\tool\Output::$editlinks .= ob_get_clean();
         }
         $section_data['attributes']['id'] = 'ExtraEditArea' . $edit_index;
     }
     $content .= $this->SectionNode($section_data, $orig_attrs);
     if ($section_data['type'] == 'wrapper_section') {
         for ($cc = 0; $cc < $section_data['contains_sections']; $cc++) {
             $content .= $this->GetSection($section_num);
         }
     } else {
         \gp\tool\Output::$nested_edit = true;
         $content .= \gp\tool\Output\Sections::RenderSection($section_data, $curr_section_num, $this->title, $this->file_stats);
         \gp\tool\Output::$nested_edit = false;
     }
     if (!isset($section_data['nodeName'])) {
         $content .= '<div class="gpclear"></div>';
         $content .= '</div>';
     } else {
         $content .= \gp\tool\Output\Sections::EndTag($section_data['nodeName']);
     }
     return $content;
 }
Beispiel #20
0
 /**
  * Notify the admin if there have been any fatal errors
  *
  */
 public static function FatalNotices()
 {
     global $dataDir, $page;
     if (!\gp\admin\Tools::HasPermission('Admin_Errors')) {
         return;
     }
     if (is_object($page) && property_exists($page, 'requested') && strpos($page->requested, 'Admin/Errors') !== false) {
         return;
     }
     $dir = $dataDir . '/data/_site';
     $files = scandir($dir);
     $has_fatal = false;
     foreach ($files as $file) {
         if (strpos($file, 'fatal_') === false) {
             continue;
         }
         $has_fatal = true;
     }
     if (!$has_fatal) {
         return;
     }
     $msg = 'Warning: One or more components have caused fatal errors and have been disabled. ' . \gp\tool::Link('Admin/Errors', 'More Information', '', 'style="white-space:nowrap"') . ' &nbsp; ' . \gp\tool::Link($page->title, 'Clear All Errors', 'cmd=ClearErrors', '', 'ClearErrors');
     //cannot be creq
     msg($msg);
 }
Beispiel #21
0
 private static function RenameFileWorker($title)
 {
     global $langmessage, $dataDir, $gp_index;
     //use new_label or new_title
     if (isset($_POST['new_title'])) {
         $new_title = \gp\admin\Tools::PostedSlug($_POST['new_title']);
     } else {
         $new_title = \gp\admin\Tools::LabelToSlug($_POST['new_label']);
     }
     //title unchanged
     if ($new_title == $title) {
         return $title;
     }
     $special_file = false;
     if (\gp\tool::SpecialOrAdmin($title) !== false) {
         $special_file = true;
     }
     if (!\gp\admin\Tools::CheckTitle($new_title, $message)) {
         msg($message);
         return false;
     }
     $old_gp_index = $gp_index;
     //re-index: make the new title point to the same data index
     $old_file = \gp\tool\Files::PageFile($title);
     $file_index = $gp_index[$title];
     unset($gp_index[$title]);
     $gp_index[$new_title] = $file_index;
     //rename the php file
     if (!$special_file) {
         $new_file = \gp\tool\Files::PageFile($new_title);
         //if the file being renamed doesn't use the index naming convention, then we'll still need to rename it
         if ($new_file != $old_file) {
             $new_dir = dirname($new_file);
             $old_dir = dirname($old_file);
             if (!\gp\tool\Files::Rename($old_dir, $new_dir)) {
                 msg($langmessage['OOPS'] . ' (N3)');
                 $gp_index = $old_gp_index;
                 return false;
             }
         }
         //gallery rename
         \gp\special\Galleries::RenamedGallery($title, $new_title);
     }
     //create a 301 redirect
     if (isset($_POST['add_redirect']) && $_POST['add_redirect'] == 'add') {
         \gp\admin\Settings\Missing::AddRedirect($title, $new_title);
     }
     \gp\tool\Plugins::Action('RenameFileDone', array($file_index, $title, $new_title));
     return $new_title;
 }
Beispiel #22
0
 public function GenerateOutput()
 {
     global $langmessage;
     \gp\tool::ShowingGallery();
     echo '<h2>';
     echo \gp\tool\Output::ReturnText('galleries');
     echo '</h2>';
     $wrap = \gp\admin\Tools::CanEdit($this->page->gp_index);
     if ($wrap) {
         echo \gp\tool\Output::EditAreaLink($edit_index, 'Admin/Galleries', $langmessage['edit']);
         echo '<div class="editable_area cf" id="ExtraEditArea' . $edit_index . '">';
         // class="edit_area" added by javascript
     }
     $image_text = \gp\tool\Output::ReturnText('image');
     $images_text = \gp\tool\Output::ReturnText('images');
     $list = '';
     $shown = 0;
     foreach ($this->galleries as $title => $info) {
         //page is hidden
         if (!$this->GalleryVisible($title, $info)) {
             continue;
         }
         $count = '';
         if (is_array($info)) {
             $icon = $info['icon'];
             if ($info['count'] == 1) {
                 $count = $info['count'] . ' ' . \gp\tool\Output::ReturnText('image');
             } elseif ($info['count'] > 1) {
                 $count = $info['count'] . ' ' . \gp\tool\Output::ReturnText('images');
             }
         } else {
             $icon = $info;
         }
         if (empty($icon)) {
             continue;
         }
         $icon = rawurldecode($icon);
         //prevent double encoding
         if (strpos($icon, '/thumbnails/') === false) {
             $thumbPath = \gp\tool::GetDir('/data/_uploaded/image/thumbnails' . $icon . '.jpg');
         } else {
             $thumbPath = \gp\tool::GetDir('/data/_uploaded' . $icon);
         }
         $label = \gp\tool::GetLabel($title);
         $title_attr = ' title="' . \gp\tool::GetBrowserTitle($title) . '"';
         $label_img = ' <img src="' . $thumbPath . '" alt=""/>';
         $list .= '<li>' . \gp\tool::Link($title, $label_img, '', $title_attr) . '<div>' . \gp\tool::Link($title, $label, '', $title_attr) . '<p>' . $count . '</p>' . '</div>' . '</li>';
     }
     if (!empty($list)) {
         echo '<ul class="gp_gallery gp_galleries">';
         echo $list;
         echo '</ul>';
     }
     if ($wrap) {
         echo '</div>';
     }
     $this->PostSave();
 }
Beispiel #23
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;
 }
Beispiel #24
0
 /**
  * Return javascript code to be used with autocomplete (jquery ui)
  *
  */
 public static function AutoCompleteValues($GetUrl = true, $options = array())
 {
     global $gp_index;
     $options += array('admin_vals' => true, 'var_name' => 'gptitles');
     //internal link array
     $array = array();
     foreach ($gp_index as $slug => $id) {
         $label = \gp\tool::GetLabel($slug);
         $label = str_replace(array('&lt;', '&gt;', '&quot;', '&#39;', '&amp;'), array('<', '>', '"', "'", '&'), $label);
         if ($GetUrl) {
             $slug = \gp\tool::GetUrl($slug, '', false);
             $slug = rawurldecode($slug);
         }
         $array[] = array($label, $slug);
     }
     if ($options['admin_vals'] && class_exists('admin_tools')) {
         $scripts = \gp\admin\Tools::AdminScripts();
         foreach ($scripts as $url => $info) {
             if (!isset($info['label'])) {
                 continue;
             }
             if ($GetUrl) {
                 $url = \gp\tool::GetUrl($url, '', false);
                 $url = rawurldecode($url);
             }
             $array[] = array($info['label'], $url);
         }
     }
     $code = json_encode($array);
     if ($options['var_name']) {
         $code = 'var ' . $options['var_name'] . ' = ' . $code . ';';
     }
     return $code;
 }
Beispiel #25
0
function SaveFinderData($data)
{
    global $config;
    $config['finder_data'] = $data;
    \gp\admin\Tools::SaveConfig();
}
Beispiel #26
0
 public function GetUsers()
 {
     $this->users = \gp\tool\Files::Get('_site/users');
     //fix the editing value
     foreach ($this->users as $username => $userinfo) {
         $userinfo += array('granted' => '');
         \gp\admin\Tools::EditingValue($userinfo);
         $this->users[$username] = $userinfo;
     }
 }
Beispiel #27
0
 public function TrashRow($trash_index, $info, $show_orphaned = false)
 {
     global $langmessage;
     $class = '';
     if (isset($info['orphaned'])) {
         $class = 'orphaned';
     }
     //title
     echo '<tr class="' . $class . '"><td>';
     echo '<label style="display:block;">';
     echo '<input type="checkbox" name="titles[]" value="' . htmlspecialchars($trash_index) . '" />';
     echo ' &nbsp; ';
     if (isset($info['orphaned'])) {
         echo '(Orphaned) &nbsp; ';
     }
     echo \gp\tool::Link('Admin/Trash/' . $trash_index, str_replace('_', ' ', $info['title']));
     echo '</label>';
     //time
     echo '</td><td>';
     if (!empty($info['time'])) {
         $elapsed = \gp\admin\Tools::Elapsed(time() - $info['time']);
         echo sprintf($langmessage['_ago'], $elapsed);
     }
     echo '</td><td>';
     if (isset($info['type'])) {
         $this->TitleTypes($info['type']);
     }
     echo '</td><td>';
     if (\gp\admin\Tools::CheckPostedNewPage($info['title'], $msg)) {
         echo \gp\tool::Link('Admin/Trash', $langmessage['restore'], 'cmd=RestoreDeleted&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'postlink'));
     } else {
         echo '<span>' . $langmessage['restore'] . '</span>';
     }
     echo ' &nbsp; ';
     echo \gp\tool::Link('Admin/Trash', $langmessage['delete'], 'cmd=DeleteFromTrash&titles[]=' . rawurlencode($trash_index), array('data-cmd' => 'postlink'));
     echo '</td></tr>';
 }
Beispiel #28
0
 /**
  * Output html for the menu editing options displayed for selected titles
  *
  */
 public function MenuSkeleton()
 {
     global $langmessage;
     //page options
     echo '<b>' . $langmessage['page_options'] . '</b>';
     echo '<span>';
     $img = '<i class="menu_icon fa fa-pencil"></i>';
     echo '<a href="[url]" class="view_edit_link not_multiple">' . $img . htmlspecialchars($langmessage['view/edit_page']) . '</a>';
     $img = '<i class="menu_icon fa fa-gears"></i>';
     $attrs = array('title' => $langmessage['rename/details'], 'data-cmd' => 'gpajax', 'class' => 'not_multiple');
     echo $this->Link('Admin/Menu/Ajax', $img . $langmessage['rename/details'], 'cmd=renameform&index=[key]', $attrs);
     $img = '<i class="fa fa-eye-slash menu_icon"></i>';
     $q = 'cmd=ToggleVisibility&index=[key]';
     $label = $langmessage['Visibility'] . ': ' . $langmessage['Private'];
     $attrs = array('title' => $label, 'data-cmd' => 'gpajax', 'class' => 'vis_private');
     echo $this->Link('Admin/Menu/Ajax', $img . $label, $q, $attrs);
     $img = '<i class="fa fa-eye menu_icon"></i>';
     $label = $langmessage['Visibility'] . ': ' . $langmessage['Public'];
     $attrs = array('title' => $label, 'data-cmd' => 'gpajax', 'class' => 'vis_public not_multiple');
     $q .= '&visibility=private';
     echo $this->Link('Admin/Menu/Ajax', $img . $label, $q, $attrs);
     echo '<a href="[url]?cmd=ViewHistory" class="view_edit_link not_multiple not_special" data-cmd="gpabox"><i class="fa fa-history menu_icon"></i>' . htmlspecialchars($langmessage['Revision History']) . '</a>';
     $img = '<i class="menu_icon fa fa-files-o"></i>';
     $attrs = array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox', 'class' => 'not_multiple not_special');
     echo $this->Link('Admin/Menu/Ajax', $img . $langmessage['Copy'], 'cmd=CopyForm&index=[key]', $attrs);
     if (\gp\admin\Tools::HasPermission('Admin_User')) {
         $img = '<i class="menu_icon fa fa-user"></i>';
         $attrs = array('title' => $langmessage['permissions'], 'data-cmd' => 'gpabox');
         echo $this->Link('Admin/Users', $img . $langmessage['permissions'], 'cmd=file_permissions&index=[key]', $attrs);
     }
     $img = '<i class="menu_icon fa fa-scissors"></i>';
     $attrs = array('title' => $langmessage['rm_from_menu'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm');
     echo $this->Link('Admin/Menu/Ajax', $img . $langmessage['rm_from_menu'], 'cmd=hide&index=[key]', $attrs);
     $img = '<i class="menu_icon fa fa-trash"></i>';
     $attrs = array('title' => $langmessage['delete_page'], 'data-cmd' => 'postlink', 'class' => 'gpconfirm not_special');
     echo $this->Link('Admin/Menu/Ajax', $img . $langmessage['delete'], 'cmd=MoveToTrash&index=[key]', $attrs);
     echo '[opts]';
     //replaced with the contents of \gp\tool\Plugins::Action('MenuPageOptions',array($title,$menu_key,$menu_value,$layout_info));
     echo '</span>';
     //layout
     if ($this->is_main_menu) {
         echo '<div class="not_multiple">';
         echo '<b>' . $langmessage['layout'] . '</b>';
         echo '<span>';
         //has_layout
         $img = '<span class="layout_icon"></span>';
         echo $this->Link('Admin/Menu', $img . '[layout_label]', 'cmd=layout&index=[key]', ' title="' . $langmessage['layout'] . '" data-cmd="gpabox" class="has_layout"');
         $img = '<i class="menu_icon fa fa-undo"></i>';
         echo $this->Link('Admin/Menu', $img . $langmessage['restore'], 'cmd=restorelayout&index=[key]', array('data-cmd' => 'postlink', 'title' => $langmessage['restore'], 'class' => 'has_layout'), 'restore');
         //no_layout
         $img = '<span class="layout_icon"></span>';
         echo $this->Link('Admin/Menu', $img . '[layout_label]', 'cmd=layout&index=[key]', ' title="' . $langmessage['layout'] . '" data-cmd="gpabox" class="no_layout"');
         echo '</span>';
         echo '</div>';
     }
     $this->InsertLinks();
     //file stats
     echo '<div>';
     echo '<b>' . $langmessage['Page Info'] . '</b>';
     echo '<span>';
     echo '<a class="not_multiple">' . $langmessage['Slug/URL'] . ': [title]</a>';
     echo '<a class="not_multiple">' . $langmessage['Content Type'] . ': [types]</a>';
     echo '<a class="not_special only_multiple">' . sprintf($langmessage['%s Pages'], '[files]') . '</a>';
     echo '<a class="not_special">' . $langmessage['File Size'] . ': [size]</a>';
     echo '<a class="not_special not_multiple">' . $langmessage['Modified'] . ': [mtime]</a>';
     echo '<a class="not_multiple">Data Index: [key]</a>';
     echo '</span>';
     echo '</div>';
 }
Beispiel #29
0
 /**
  * Show the default admin page
  *
  */
 private function AdminPanel()
 {
     global $langmessage;
     $cmd = \gp\tool::GetCommand();
     switch ($cmd) {
         case 'embededcheck':
             new \gp\admin\Update('embededcheck');
             return;
         case 'autocomplete-titles':
             $opts = array('var_name' => false);
             echo \gp\tool\Editing::AutoCompleteValues(false, $opts);
             die;
     }
     $this->head_js[] = '/include/js/auto_width.js';
     echo '<h2>' . $langmessage['administration'] . '</h2>';
     echo '<div id="adminlinks2">';
     \gp\admin\Tools::AdminPanelLinks(false);
     echo '</div>';
 }
Beispiel #30
0
 /**
  * Add the admin toolbar content to the ajax response
  *
  */
 static function AdminToolbar()
 {
     global $page;
     if (!isset($_REQUEST['gpreq_toolbar'])) {
         return;
     }
     ob_start();
     \gp\admin\Tools::AdminToolbar();
     $toolbar = ob_get_clean();
     if (empty($toolbar)) {
         return;
     }
     $page->ajaxReplace[] = array('replace', '#admincontent_panel', $toolbar);
 }