function GetContent() { $this->GetGpxContent(); if (!empty($this->non_admin_content)) { echo '<div class="filetype-text cf">'; //echo '<div id="gpx_content" class="filetype-text">'; //id="gpx_content" conflicts with admin content echo $this->non_admin_content; echo '</div>'; } echo '<div id="gpAfterContent">'; gpOutput::Get('AfterContent'); gpPlugin::Action('GetContent_After'); echo '</div>'; }
/** * Edit layout properties * Layout Identification * Content Arrangement * Gadget Visibility * */ function EditLayout($layout, $cmd) { global $page, $gpLayouts, $langmessage, $config; $GLOBALS['GP_ARRANGE_CONTENT'] = true; $page->head_js[] = '/include/js/inline_edit/inline_editing.js'; $this->curr_layout = $layout; $this->SetLayoutArray(); $page->SetTheme($layout); $this->LoremIpsum(); gpOutput::TemplateSettings(); gpPlugin::Action('edit_layout_cmd', array($layout)); switch ($cmd) { /** * Inline image editing * */ case 'inlineedit': $this->InlineEdit(); return; case 'gallery_folder': case 'gallery_images': $this->GalleryImages(); return; case 'image_editor': includeFile('tool/editing.php'); gp_edit::ImageEditor($this->curr_layout); return; case 'save_inline': $this->SaveHeaderImage(); return; case 'theme_images': $this->ShowThemeImages(); return; case 'drag_area': $this->Drag(); break; //insert //insert case 'insert': $this->SelectContent(); return; case 'addcontent': $this->AddContent(); break; //remove //remove case 'rm_area': $this->RemoveArea(); break; } if ($this->LayoutCommands($cmd)) { return; } //control what is displayed switch ($cmd) { //show the layout (displayed within an iframe) case 'save_css': case 'preview_css': case 'addcontent': case 'rm_area': case 'drag_area': case 'in_iframe': $this->ShowInIframe($cmd); return; } $layout_info = common::LayoutInfo($layout, false); $handlers_count = 0; if (isset($layout_info['handlers']) && is_array($layout_info['handlers'])) { foreach ($layout_info['handlers'] as $val) { $int = count($val); if ($int === 0) { $handlers_count++; } $handlers_count += $int; } } $page->label = $langmessage['layouts'] . ' » ' . $layout_info['label']; $_REQUEST += array('gpreq' => 'body'); //force showing only the body as a complete html document $page->get_theme_css = false; ob_start(); $this->LayoutEditor($layout, $layout_info); $page->admin_html = ob_get_clean(); }
function GetContent() { $this->GetGpxContent(); echo '<div id="gpAfterContent">'; gpOutput::Get('AfterContent'); gpPlugin::Action('GetContent_After'); echo '</div>'; }
function SearchDisplay() { global $langmessage, $gpLayouts, $gp_index, $gp_menu; $Inherit_Info = admin_menu_tools::Inheritance_Info(); switch ($this->curr_menu_id) { case 'search': $show_list = $this->GetSearchList(); break; case 'all': $show_list = array_keys($gp_index); break; case 'hidden': $show_list = $this->GetAvailable(); break; case 'nomenus': $show_list = $this->GetNoMenus(); break; } $show_list = array_values($show_list); //to reset the keys $show_list = array_reverse($show_list); //show newest first $max = count($show_list); while ($this->search_page * $this->search_max_per_page > $max) { $this->search_page--; } $start = $this->search_page * $this->search_max_per_page; $stop = min(($this->search_page + 1) * $this->search_max_per_page, $max); ob_start(); echo '<div class="gp_search_links">'; echo '<span class="showing">'; echo sprintf($langmessage['SHOWING'], $start + 1, $stop, $max); echo '</span>'; if ($start !== 0 || $stop < $max) { for ($i = 0; $i * $this->search_max_per_page < $max; $i++) { $class = ''; if ($i == $this->search_page) { $class = ' class="current"'; } echo $this->Link('Admin_Menu', $i + 1, 'page=' . $i, 'name="gpajax"' . $class); } } echo $this->Link('Admin_Menu', $langmessage['create_new_file'], 'cmd=add_hidden', ' title="' . $langmessage['create_new_file'] . '" name="gpajax"'); echo '</div>'; $links = ob_get_clean(); echo $links; echo '<table class="bordered">'; echo '<thead>'; echo '<tr><th>'; echo $langmessage['file_name']; echo '</th><th>'; echo $langmessage['Child Pages']; echo '</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; if (count($show_list) > 0) { for ($i = $start; $i < $stop; $i++) { $title = $show_list[$i]; $title_index = $gp_index[$title]; echo '<tr><td>'; $label = common::GetLabel($title); echo common::Link($title, common::LabelSpecialChars($label)); //area only display on mouseover echo '<div>'; echo '<b>Options:</b>'; $img = '<span class="menu_icon page_edit_icon"></span>'; echo $this->Link('Admin_Menu', $img . $langmessage['rename/details'], 'cmd=renameform&title=' . urlencode($title), ' title="' . $langmessage['rename/details'] . '" name="gpajax" '); $img = '<span class="menu_icon copy_icon"></span>'; echo $this->Link('Admin_Menu', $img . $langmessage['Copy'], 'cmd=copypage&title=' . urlencode($title), ' title="' . $langmessage['Copy'] . '" name="gpabox"'); $layout = admin_menu_tools::CurrentLayout($title_index); $layout_info = $gpLayouts[$layout]; $img = '<span style="background-color:' . $layout_info['color'] . ';" class="layout_icon"></span>'; echo $this->Link('Admin_Menu', $img . $layout_info['label'], 'cmd=layout&index=' . urlencode($title_index), ' title="' . $langmessage['layout'] . '" name="gpabox"'); $is_special = common::SpecialOrAdmin($title); if (!$is_special) { $img = '<span class="menu_icon bin_icon"></span>'; echo $this->Link('Admin_Menu', $img . $langmessage['delete'], 'cmd=trash&index=' . urlencode($title_index), ' title="' . $langmessage['delete_page'] . '" name="menupost" class="gpconfirm" '); } gpPlugin::Action('MenuPageOptions', array($title, $title_index, false, $layout_info)); //stats echo '<br/>'; echo '<b>' . $langmessage['Page Info'] . ':</b>'; $this->FileStats($title_index, $title, $is_special); echo '</div>'; echo '</td><td>'; if (isset($Inherit_Info[$title_index]) && isset($Inherit_Info[$title_index]['children'])) { echo $Inherit_Info[$title_index]['children']; } elseif (isset($gp_menu[$title_index])) { echo '0'; } else { echo $langmessage['Not In Main Menu']; } echo '</td></tr>'; } } echo '</tbody>'; echo '</table>'; if (count($show_list) == 0) { echo '<p>'; echo $langmessage['Empty']; echo '</p>'; } echo '<br/>'; echo $links; }
/** * Outputs the sitemap link, admin login/logout link, powered by link, admin html and messages * @static */ static function GetAdminLink() { global $config, $langmessage, $page; if (!isset($config['showsitemap']) || $config['showsitemap']) { echo ' <span class="sitemap_link">'; echo common::Link('Special_Site_Map', $langmessage['site_map']); echo '</span>'; } if (!isset($config['showlogin']) || $config['showlogin']) { echo ' <span class="login_link">'; if (common::LoggedIn()) { echo common::Link($page->title, $langmessage['logout'], 'cmd=logout', array('data-cmd' => 'creq', 'rel' => 'nofollow')); } else { echo common::Link('Admin', $langmessage['login'], 'file=' . rawurlencode($page->title), ' rel="nofollow" data-cmd="login"'); } echo '</span>'; } if (!isset($config['showgplink']) || $config['showgplink']) { echo ' <span id="powered_by_link">'; echo 'Powered by <a href="http://gpEasy.com" title="A Free and Easy CMS in PHP" target="_blank">gp|Easy CMS</a>'; echo '</span>'; } gpPlugin::Action('GetAdminLink'); echo GetMessages(); //global $gpLayouts; //echo pre($gpLayouts); //$included = get_included_files(); //echo pre($included); }
/** * Edit layout properties * Layout Identification * Content Arrangement * Gadget Visibility * */ function EditLayout($layout, $cmd) { global $page, $gpLayouts, $langmessage, $config; if (!isset($gpLayouts[$layout])) { message($langmessage['OOPS'] . ' (Invalid Layout)'); return false; } $GLOBALS['GP_ARRANGE_CONTENT'] = true; $page->head .= "\n" . '<script type="text/javascript">var gpLayouts=true;</script>'; $page->head_js[] = '/include/js/inline_edit/inline_editing.js'; $page->show_admin_content = false; $this->curr_layout = $layout; $page->SetTheme($layout); $this->LoremIpsum(); gpOutput::TemplateSettings(); gpPlugin::Action('edit_layout_cmd', array($layout)); switch ($cmd) { case 'save_css': $this->SaveCSS(); break; case 'css': $this->EditCSS(); break; case 'makedefault': $this->MakeDefault($layout); break; case 'change_layout_color': $this->ChangeLayoutColor($layout); break; case 'css_preferences': $this->CSSPreferences($layout); break; case 'rmgadget': $this->RmGadget($layout); break; case 'layout_details': $this->LayoutDetails(); break; case 'restore_drag': case 'restore': $this->Restore($layout); break; case 'drag': $this->Drag(); break; //insert //insert case 'insert': $this->SelectContent(); return true; case 'addcontent': $this->AddContent(); break; //remove //remove case 'rm': $this->RemoveArea(); break; } $layout_info = common::LayoutInfo($layout); $handlers_count = 0; if (isset($layout_info['handlers']) && is_array($layout_info['handlers'])) { foreach ($layout_info['handlers'] as $val) { $int = count($val); if ($int === 0) { $handlers_count++; } $handlers_count += $int; } } $page->label = $langmessage['layouts'] . ' » ' . $layout_info['label']; //display options switch ($cmd) { case 'makedefault': case 'details': $this->ShowDetails($layout, $layout_info, $handlers_count); return true; } $this->PrepareCSS(); $this->Toolbar($layout, $layout_info); return true; }
function RunQuery() { if (!empty($_REQUEST['q'])) { $this->SearchPattern(); $this->SearchPages(); gpPlugin::Action('Search', array($this)); } $this->ShowResults(); }
function GenerateContent_Admin() { //add to all pages in case a user adds a gallery gpPlugin::Action('GenerateContent_Admin'); common::ShowingGallery(); $content = ''; $sections_count = count($this->file_sections); $section_num = 0; do { $content .= $this->GetSection($section_num); } while ($section_num < $sections_count); return $content; }
static function RenameFileWorker($title) { global $langmessage, $dataDir, $gp_index; //use new_label or new_title if (isset($_POST['new_title'])) { $new_title = admin_tools::PostedSlug($_POST['new_title']); } else { $new_title = admin_tools::LabelToSlug($_POST['new_label']); } //title unchanged if ($new_title == $title) { return $title; } $special_file = false; if (common::SpecialOrAdmin($title)) { $special_file = true; } if (!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 = gpFiles::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 = gpFiles::PageFile($new_title); //we don't have to rename files if we're using the index naming convention. See gpFiles::PageFile() for more info if ($new_file == $old_file) { //if the file being renamed doesn't use the index naming convention, then we'll still need to rename it } elseif (!rename($old_file, $new_file)) { msg($langmessage['OOPS'] . ' (N3)'); $gp_index = $old_gp_index; return false; } //gallery rename includeFile('special/special_galleries.php'); special_galleries::RenamedGallery($title, $new_title); } //create a 301 redirect if (isset($_POST['add_redirect']) && $_POST['add_redirect'] == 'add') { includeFile('admin/admin_missing.php'); admin_missing::AddRedirect($title, $new_title); } gpPlugin::Action('RenameFileDone', array($file_index, $title, $new_title)); return $new_title; }
/** * Generate and output the <head> portion of the html document * */ function GetHead() { global $gp_random; gpPlugin::Action('GetHead'); gpOutput::PrepGadgetContent(); echo '<!-- get_head_placeholder ' . $gp_random . ' -->'; }
/** * Move To Trash * Hide special pages * */ function MoveToTrash($cmd) { global $gp_titles, $gp_index, $langmessage, $gp_menu; includeFile('admin/admin_trash.php'); admin_trash::PrepFolder(); $this->CacheSettings(); $_POST += array('index' => ''); $indexes = explode(',', $_POST['index']); $trash_data = array(); foreach ($indexes as $index) { $title = common::IndexToTitle($index); // Create file in trash if ($title) { if (!admin_trash::MoveToTrash_File($title, $index, $trash_data)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } } // Remove from menu if (isset($gp_menu[$index])) { if (count($gp_menu) == 1) { continue; } if (!$this->RmFromMenu($index, false)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } } unset($gp_titles[$index]); unset($gp_index[$title]); } $this->ResetHomepage(); if (!admin_trash::ModTrashData($trash_data, null)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } if (!admin_tools::SaveAllConfig()) { $this->RestoreSettings(); return false; } if ($cmd == 'trash_page') { $link = common::GetUrl('Admin_Trash'); message(sprintf($langmessage['MOVED_TO_TRASH'], $link)); } //finally, delete the files in /_pages foreach ($indexes as $index) { $title = common::IndexToTitle($index); if (!$title) { continue; } $file = gpFiles::PageFile($title); if (gpFiles::Exists($file)) { unlink($file); } } gpPlugin::Action('MenuPageTrashed', array($indexes)); return true; }
function GenerateContent_Admin() { global $langmessage, $GP_NESTED_EDIT; //add to all pages in case a user adds a gallery gpPlugin::Action('GenerateContent_Admin'); common::ShowingGallery(); $content = ''; $section_num = 0; foreach ($this->file_sections as $section_key => $section_data) { $content .= "\n"; $type = isset($section_data['type']) ? $section_data['type'] : 'text'; if (gpOutput::ShowEditLink() && admin_tools::CanEdit($this->gp_index)) { $link_name = 'inline_edit_generic'; $link_rel = $type . '_inline_edit'; $title_attr = sprintf($langmessage['Section %s'], $section_key + 1); $link = gpOutput::EditAreaLink($edit_index, $this->title, $langmessage['edit'], 'section=' . $section_key, ' title="' . $title_attr . '" name="' . $link_name . '" rel="' . $link_rel . '"'); //section control links $content .= '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">'; $content .= $link; if ($section_num > 0) { $content .= common::Link($this->title, $langmessage['move_up'], 'cmd=move_up§ion=' . $section_key, ' name="creq"', 'move_up' . $section_key); } $content .= common::Link($this->title, $langmessage['New Section'], 'cmd=new_section§ion=' . $section_key, ' name="gpabox"'); $q = 'cmd=add_section©=copy§ion=' . $section_key . '&last_mod=' . rawurlencode($this->fileModTime); $content .= common::Link($this->title, $langmessage['Copy'], $q, ' name="creq"'); //remove section link if (count($this->file_sections) > 1) { $title_attr = $langmessage['rm_section_confirm']; if ($type != 'include') { $title_attr .= "\n\n" . $langmessage['rm_section_confirm_deleting']; } $content .= common::Link($this->title, $langmessage['Remove Section'], 'cmd=rm_section§ion=' . $section_key . '&total=' . count($this->file_sections), ' title="' . $title_attr . '" name="creq" class="gpconfirm"'); } $content .= '</span>'; $content .= '<div class="editable_area GPAREA filetype-' . $type . '" id="ExtraEditArea' . $edit_index . '">'; // class="edit_area" added by javascript } else { $content .= '<div class="GPAREA filetype-' . $type . '">'; } $GP_NESTED_EDIT = true; $content .= $this->SectionToContent($section_data, $section_num); $GP_NESTED_EDIT = false; $content .= '<div class="gpclear"></div>'; $content .= '</div>'; $section_num++; } return $content; }
function ShowForm() { global $page, $langmessage, $config; $attr = ''; if ($this->sent) { $attr = ' readonly="readonly" '; } $_GET += array('name' => '', 'email' => '', 'subject' => '', 'message' => ''); $_POST += array('name' => $_GET['name'], 'email' => $_GET['email'], 'subject' => $_GET['subject'], 'message' => $_GET['message']); $require_email =& $config['require_email']; echo '<form class="contactform" action="' . common::GetUrl($page->title) . '" method="post">'; //nonce fields echo '<div style="display:none !important">'; echo '<input type="hidden" name="contact_nonce" value="' . htmlspecialchars(common::new_nonce('contact_post', true)) . '" />'; echo '<input type="text" name="contact_void" value="" />'; echo '</div>'; echo '<label for="contact_name"><span class="title">'; echo gpOutput::ReturnText('your_name'); echo '</span><input id="contact_name" class="input text" type="text" name="name" value="' . htmlspecialchars($_POST['name']) . '" ' . $attr . ' />'; echo '</label>'; echo '<label for="contact_email"><span class="title">'; echo gpOutput::ReturnText('your_email'); if (strpos($require_email, 'email') !== false) { echo '*'; } echo '</span><input id="contact_email" class="input text" type="text" name="email" value="' . htmlspecialchars($_POST['email']) . '" ' . $attr . '/>'; echo '</label>'; echo '<label for="contact_subject"><span class="title">'; echo gpOutput::ReturnText('subject'); if (strpos($require_email, 'none') === false) { echo '*'; } echo '</span><input id="contact_subject" class="input text" type="text" name="subject" value="' . htmlspecialchars($_POST['subject']) . '" ' . $attr . '/>'; echo '</label>'; echo '<label for="contact_message">'; echo gpOutput::ReturnText('message'); if (strpos($require_email, 'none') === false) { echo '*'; } echo '</label>'; echo '<textarea id="contact_message" name="message" ' . $attr . ' rows="10" cols="10">'; echo htmlspecialchars($_POST['message']); echo '</textarea>'; gpPlugin::Action('contact_form_pre_captcha'); if (!$this->sent && gp_recaptcha::isActive()) { echo '<div class="captchaForm">'; echo gpOutput::ReturnText('captcha'); gp_recaptcha::Form(); echo '</div>'; } if ($this->sent) { echo gpOutput::ReturnText('message_sent', '%s', 'message_sent'); } else { echo '<input type="hidden" name="cmd" value="gp_send_message" />'; $key = 'send_message'; $text = gpOutput::SelectText($key); if (gpOutput::ShowEditLink('Admin_Theme_Content')) { $query = 'cmd=edittext&key=' . urlencode($key); echo gpOutput::EditAreaLink($edit_index, 'Admin_Theme_Content', $langmessage['edit'], $query, ' title="' . $key . '" data-cmd="gpabox" '); echo '<input type="submit" class="submit editable_area" id="ExtraEditArea' . $edit_index . '" name="aaa" value="' . $text . '" />'; } else { echo '<input type="submit" class="submit" name="aaa" value="' . $text . '" />'; } } echo '</form>'; }
/** * Performs actions after changes are made to files in elFinder * */ static function FinderChange($cmd, $result, $args, $elfinder) { global $dataDir, $config; includeFile('image.php'); gp_resized::SetIndex(); $base_dir = $dataDir . '/data/_uploaded'; $thumb_dir = $dataDir . '/data/_uploaded/image/thumbnails'; admin_uploaded::SetRealPath($result, $elfinder); switch ($cmd) { case 'rename': admin_uploaded::RenameResized($result['removed'][0], $result['added'][0]); break; case 'rm': admin_uploaded::RemoveResized($result['removed']); break; case 'paste': admin_uploaded::MoveResized($result['removed'], $result['added']); break; //check the image size //check the image size case 'upload': admin_uploaded::MaxSize($result['added']); break; } //removed files first // - Remove associated thumbnail if (isset($result['removed']) && count($result['removed']) > 0) { foreach ($result['removed'] as $removed) { $removed_path = $removed['realpath']; $thumb_path = str_replace($base_dir, $thumb_dir, $removed_path) . '.jpg'; if (file_exists($thumb_path)) { unlink($thumb_path); } } } //addded files if (isset($result['added']) && count($result['added']) > 0) { foreach ($result['added'] as $added) { $added_path = $added['realpath']; $thumb_path = str_replace($base_dir, $thumb_dir, $added_path) . '.jpg'; gpFiles::CheckDir($thumb_dir); thumbnail::createSquare($added_path, $thumb_path, $config['maxthumbsize']); gpPlugin::Action('FileUploaded', $added_path); } } //changed files (resized) if (isset($result['changed']) && count($result['changed']) > 0) { foreach ($result['changed'] as $changed) { $changed_path = $changed['realpath']; $thumb_path = str_replace($base_dir, $thumb_dir, $changed_path) . '.jpg'; gpFiles::CheckDir($thumb_dir); thumbnail::createSquare($changed_path, $thumb_path, $config['maxthumbsize']); } } gp_resized::SaveIndex(); //debug /* $log_file = $dataDir.'/data/_temp/finder_log-all_vars.txt'; $data = get_defined_vars(); $content = print_r($data,true); gpFiles::Save($log_file,$content); */ }
/** * Performs actions after changes are made to files in finder * */ static function FinderChange($cmd, $result, $args, $finder) { global $dataDir, $config; includeFile('image.php'); gp_resized::SetIndex(); $base_dir = $dataDir . '/data/_uploaded'; $thumb_dir = $dataDir . '/data/_uploaded/image/thumbnails'; admin_uploaded::SetRealPath($result, $finder); switch ($cmd) { case 'rename': admin_uploaded::RenameResized($result['removed'][0], $result['added'][0]); break; case 'rm': admin_uploaded::RemoveResized($result['removed']); break; case 'paste': admin_uploaded::MoveResized($result['removed'], $result['added']); break; //check the image size //check the image size case 'upload': admin_uploaded::MaxSize($result['added']); break; } //removed files first // - Remove associated thumbnail if (isset($result['removed']) && count($result['removed']) > 0) { foreach ($result['removed'] as $removed) { $removed_path = $removed['realpath']; gpPlugin::Action('FileDeleted', $removed_path); $thumb_path = str_replace($base_dir, $thumb_dir, $removed_path); if (file_exists($thumb_path)) { if (is_dir($thumb_path)) { gpFiles::RmAll($thumb_path); } else { unlink($thumb_path); } continue; } $thumb_path = str_replace($base_dir, $thumb_dir, $removed_path) . '.jpg'; if (file_exists($thumb_path)) { unlink($thumb_path); } } } //addded files if (isset($result['added']) && count($result['added']) > 0) { foreach ($result['added'] as $added) { gpPlugin::Action('FileUploaded', $added['realpath']); self::CreateThumbnail($added['realpath']); } } //changed files (resized) if (isset($result['changed']) && count($result['changed']) > 0) { foreach ($result['changed'] as $changed) { gpPlugin::Action('FileChanged', $changed['realpath']); self::CreateThumbnail($changed['realpath']); } } gp_resized::SaveIndex(); //debug /* $log_file = $dataDir.'/data/_temp/finder_log-'.time().'.txt'; $data = get_defined_vars(); $content = print_r($data,true).'<hr/>'; $fp = fopen($log_file,'a'); fwrite($fp,$content); */ }
/** * Move To Trash * Hide special pages * */ function MoveToTrash($cmd) { global $gp_titles, $gp_index, $langmessage, $gp_menu, $config, $dataDir; includeFile('admin/admin_trash.php'); $this->CacheSettings(); $_POST += array('index' => ''); $indexes = explode(',', $_POST['index']); $trash_data = array(); $delete_files = array(); foreach ($indexes as $index) { $title = common::IndexToTitle($index); // Create file in trash if ($title) { if (!admin_trash::MoveToTrash_File($title, $index, $trash_data)) { msg($langmessage['OOPS'] . ' (Not Moved)'); $this->RestoreSettings(); return false; } } // Remove from menu if (isset($gp_menu[$index])) { if (count($gp_menu) == 1) { continue; } if (!$this->RmFromMenu($index, false)) { msg($langmessage['OOPS']); $this->RestoreSettings(); return false; } } unset($gp_titles[$index]); unset($gp_index[$title]); } $this->ResetHomepage(); if (!admin_tools::SaveAllConfig()) { $this->RestoreSettings(); return false; } $link = common::GetUrl('Admin_Trash'); msg(sprintf($langmessage['MOVED_TO_TRASH'], $link)); gpPlugin::Action('MenuPageTrashed', array($indexes)); return true; }