Пример #1
0
 function gp_html_output($text)
 {
     $this->gp_html_parse($text);
     $this->dom_array = gpPlugin::Filter('Html_Output', array($this->dom_array));
     $this->Clean();
     $this->Rebuild();
 }
Пример #2
0
 function __construct($text)
 {
     parent::__construct($text);
     $this->dom_array = gpPlugin::Filter('Html_Output', array($this->dom_array));
     $this->Clean();
     $this->Rebuild();
 }
Пример #3
0
 /**
  * Verify the user submitted form by checking anti-spam hooks and/or recaptcha if they exist
  * @static
  *
  */
 static function Check()
 {
     global $page, $langmessage, $config, $dataDir;
     // if hooks return false, stop
     if (!gpPlugin::Filter('AntiSpam_Check', array(true))) {
         return false;
     }
     // if recaptcha inactive, stop
     if (!gp_recaptcha::hasRecaptcha()) {
         return true;
     }
     //prevent undefined index warnings if there is a bot
     $_POST += array('recaptcha_challenge_field' => '', 'recaptcha_response_field' => '');
     //includeFile('thirdparty/recaptchalib.php');
     require_once $dataDir . '/include/thirdparty/recaptchalib.php';
     $resp = recaptcha_check_answer($config['recaptcha_private'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
     if (!$resp->is_valid) {
         message($langmessage['INCORRECT_CAPTCHA']);
         //if( common::LoggedIn() ){
         //	message($langmessage['recaptcha_said'],$resp->error);
         //}
         return false;
     }
     return true;
 }
Пример #4
0
 function RunScript()
 {
     global $gp_index, $langmessage, $page;
     $scriptinfo = special_display::GetScriptInfo($this->requested);
     if ($scriptinfo === false) {
         switch ($this->requested) {
             case 'Special_ExtraJS':
                 $this->ExtraJS();
                 //dies
         }
         $this->Error_404($this->title);
         return;
     }
     $this->gp_index = $gp_index[$this->requested];
     $this->label = common::GetLabel($this->requested);
     $this->TitleInfo = $scriptinfo;
     $menu_permissions = false;
     if (common::LoggedIn()) {
         $menu_permissions = admin_tools::HasPermission('Admin_Menu');
         if ($menu_permissions) {
             $page->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', ' name="gpajax" ');
             $page->admin_links[] = common::Link('Admin_Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), ' title="' . $langmessage['current_layout'] . '" name="gpabox"');
         }
         if (admin_tools::HasPermission('Admin_User')) {
             $page->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), ' title="' . $langmessage['permissions'] . '" name="gpabox" ');
         }
     }
     //allow addons to affect page actions and how a page is displayed
     $cmd = common::GetCommand();
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     if ($menu_permissions) {
         switch ($cmd) {
             // rename & details
             case 'renameform':
                 $this->RenameForm();
                 return;
             case 'renameit':
                 if ($this->RenameFile()) {
                     return;
                 }
                 break;
         }
     }
     $this->contentBuffer = special_display::ExecInfo($scriptinfo);
 }
Пример #5
0
 function HighlighterSettings()
 {
     $this->config = gpPlugin::GetConfig();
     $this->config += array('theme' => 'default');
     $this->themes = array('default' => 'Default', 'django' => 'Django', 'eclipse' => 'Eclipse', 'emacs' => 'Emacs', 'fadetogrey' => 'Fade to Grey', 'midnight' => 'Midnight', 'rdark' => 'RDark', 'none' => '[None]');
     $this->themes = gpPlugin::Filter('syntaxhighlighter_themes', array($this->themes));
     $cmd = common::GetCommand();
     switch ($cmd) {
         case 'save':
             $this->Save();
             break;
     }
     $this->ShowForm();
 }
Пример #6
0
 function RunScript()
 {
     global $gp_index, $langmessage, $page;
     $scriptinfo = special_display::GetScriptInfo($this->title);
     if ($scriptinfo === false) {
         switch ($this->title) {
             case 'Special_ExtraJS':
                 $this->ExtraJS();
                 //dies
         }
         $this->Error_404($this->title);
         return;
     }
     $this->gp_index = $gp_index[$this->title];
     $this->TitleInfo = $scriptinfo;
     if (!$this->CheckVisibility()) {
         return false;
     }
     //allow addons to affect page actions and how a page is displayed
     $cmd = common::GetCommand();
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     if (common::LoggedIn()) {
         $menu_permissions = admin_tools::HasPermission('Admin_Menu');
         if ($menu_permissions) {
             switch ($cmd) {
                 // rename & details
                 case 'renameform':
                     $this->RenameForm();
                     return;
                 case 'renameit':
                     if ($this->RenameFile()) {
                         return;
                     }
                     break;
                 case 'ToggleVisibility':
                     $this->ToggleVisibility();
                     break;
             }
         }
         $this->AdminLinks();
     }
     $this->contentBuffer = special_display::ExecInfo($scriptinfo);
 }
Пример #7
0
 /**
  * Verify the user submitted form by checking anti-spam hooks and/or recaptcha if they exist
  * @static
  *
  */
 static function Check()
 {
     global $page, $langmessage, $config, $dataDir;
     // if hooks return false, stop
     if (!gpPlugin::Filter('AntiSpam_Check', array(true))) {
         return false;
     }
     // if recaptcha inactive, stop
     if (!gp_recaptcha::hasRecaptcha()) {
         return true;
     }
     if (empty($_POST['g-recaptcha-response'])) {
         return false;
     }
     require_once $dataDir . '/include/thirdparty/recaptcha/autoload.php';
     if (!ini_get('allow_url_fopen')) {
         // allow_url_fopen = Off
         $recaptcha = new \ReCaptcha\ReCaptcha($config['recaptcha_private'], new \ReCaptcha\RequestMethod\SocketPost());
     } else {
         // allow_url_fopen = On
         $recaptcha = new \ReCaptcha\ReCaptcha($config['recaptcha_private']);
     }
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } else {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $ip);
     if (!$resp->isSuccess()) {
         //$error_codes = $resp->getErrorCodes();
         //error_log();
         msg($langmessage['INCORRECT_CAPTCHA']);
         return false;
     }
     return true;
 }
Пример #8
0
 /**
  * Return the data for the requested menu, return the main menu if the requested menu doesn't exist
  * @param string $id String identifying the requested menu
  * @return array menu data
  */
 static function GetMenuArray($id)
 {
     global $dataDir, $gp_menu;
     $menu_file = $dataDir . '/data/_menus/' . $id . '.php';
     if (empty($id) || !gpFiles::Exists($menu_file)) {
         return gpPlugin::Filter('GetMenuArray', array($gp_menu));
     }
     $menu = gpFiles::Get('_menus/' . $id, 'menu');
     if (gpFiles::$last_version && version_compare(gpFiles::$last_version, '3.0b1', '<')) {
         $menu = gpOutput::FixMenu($menu);
     }
     return gpPlugin::Filter('GetMenuArray', array($menu));
 }
Пример #9
0
 function admin_menu_new()
 {
     global $langmessage, $page, $config;
     $page->ajaxReplace = array();
     $page->css_admin[] = '/include/css/admin_menu_new.css';
     $page->head_js[] = '/include/thirdparty/js/nestedSortable.js';
     $page->head_js[] = '/include/thirdparty/js/jquery_cookie.js';
     $page->head_js[] = '/include/js/admin_menu_new.js';
     $this->max_level_index = max(3, gp_max_menu_level - 1);
     $page->head_script .= 'var max_level_index = ' . $this->max_level_index . ';';
     $cmd = common::GetCommand();
     $this->avail_menus['gpmenu'] = $langmessage['Main Menu'];
     $this->avail_menus['all'] = $langmessage['All Pages'];
     $this->avail_menus['hidden'] = $langmessage['Not In Main Menu'];
     $this->avail_menus['nomenus'] = $langmessage['Not In Any Menus'];
     $this->avail_menus['search'] = $langmessage['search pages'];
     if (isset($config['menus'])) {
         foreach ($config['menus'] as $id => $menu_label) {
             $this->avail_menus[$id] = $menu_label;
         }
     }
     //early commands
     switch ($cmd) {
         case 'altmenu_create':
             $this->AltMenu_Create();
             break;
         case 'rm_menu':
             $this->AltMenu_Remove();
             break;
         case 'alt_menu_rename':
             $this->AltMenu_Rename();
             break;
     }
     //read cookie settings
     if (isset($_COOKIE['gp_menu_prefs'])) {
         parse_str($_COOKIE['gp_menu_prefs'], $this->cookie_settings);
     }
     $this->SetMenuID();
     $this->SetMenuArray();
     $this->SetCollapseSettings();
     $this->SetQueryInfo();
     $cmd_after = gpPlugin::Filter('MenuCommand', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     switch ($cmd) {
         case 'rename_menu_prompt':
             $this->RenameMenuPrompt();
             return;
             //menu creation
         //menu creation
         case 'newmenu':
             $this->NewMenu();
             return;
             //rename
         //rename
         case 'renameform':
             $this->RenameForm();
             //will die()
             return;
         case 'renameit':
             $this->RenameFile();
             break;
         case 'hide':
             $this->Hide();
             break;
         case 'drag':
             $this->SaveDrag();
             break;
         case 'trash_page':
         case 'trash':
             $this->MoveToTrash($cmd);
             break;
         case 'add_hidden':
             $this->AddHidden();
             return;
         case 'new_hidden':
             $this->NewHiddenFile();
             break;
         case 'new_redir':
             $this->NewHiddenFile_Redir();
             return;
         case 'copyit':
             $this->CopyPage();
             break;
         case 'copypage':
             $this->CopyForm();
             return;
             // Page Insertion
         // Page Insertion
         case 'insert_before':
         case 'insert_after':
         case 'insert_child':
             $this->InsertDialog($cmd);
             return;
         case 'restore':
             $this->RestoreFromTrash();
             break;
         case 'insert_from_hidden':
             $this->InsertFromHidden();
             break;
         case 'new_file':
             $this->NewFile();
             break;
             //layout
         //layout
         case 'layout':
         case 'uselayout':
         case 'restorelayout':
             includeFile('tool/Page_Layout.php');
             $page_layout = new page_layout($cmd, 'Admin_Menu', $this->query_string);
             if ($page_layout->result()) {
                 return;
             }
             break;
             //external links
         //external links
         case 'new_external':
             $this->NewExternal();
             break;
         case 'edit_external':
             $this->EditExternal();
             return;
         case 'save_external':
             $this->SaveExternal();
             break;
     }
     $this->ShowForm($cmd);
 }
Пример #10
0
 /**
  * Return formatted content for the $section_data
  * @return string
  *
  */
 static function SectionToContent($section_data, $section_num)
 {
     $section_data = gpPlugin::Filter('SectionToContent', array($section_data, $section_num));
     switch ($section_data['type']) {
         case 'text':
             return self::TextContent($section_data['content']);
         case 'include':
             return self::IncludeContent($section_data);
         case 'gallery':
             common::ShowingGallery();
             return $section_data['content'];
     }
     return $section_data['content'];
 }
Пример #11
0
 /**
  * Clean a string of html that may be used as file content
  *
  * @param string $text The string to be cleansed. Passed by reference
  */
 public static function CleanText(&$text)
 {
     includeFile('tool/editing.php');
     gp_edit::tidyFix($text);
     gpFiles::rmPHP($text);
     gpFiles::FixTags($text);
     $text = gpPlugin::Filter('CleanText', array($text));
 }
Пример #12
0
    return $args;
}
function rename_check($event, $args, $finder)
{
    $name = $args['name'];
    if (gp_restrict_uploads && !admin_uploaded::AllowedExtension($name)) {
        return false;
    }
    $args['name'] = $name;
    return $args;
}
function SaveFinderData($data)
{
    global $config;
    $config['finder_data'] = $data;
    admin_tools::SaveConfig();
}
function ReturnFinderData()
{
    global $config;
    if (isset($config['finder_data'])) {
        return $config['finder_data'];
    }
    return false;
}
$opts = array('debug' => gpdebug, 'saveData' => 'SaveFinderData', 'returnData' => 'ReturnFinderData', 'roots' => array(array('driver' => 'LocalFileSystem', 'path' => $dataDir . '/data/_uploaded/', 'URL' => common::GetDir('data/_uploaded'), 'accessControl' => 'access', 'tmbPath' => $dataDir . '/data/_elthumbs', 'tmbURL' => common::GetDir('data/_elthumbs'), 'separator' => '/', 'tmbBgColor' => 'transparent', 'copyOverwrite' => false, 'uploadOverwrite' => false, 'tmbPathMode' => gp_chmod_dir, 'dirMode' => gp_chmod_dir, 'fileMode' => gp_chmod_file)), 'bind' => array('duplicate upload rename rm paste resize' => array('admin_uploaded', 'FinderChange'), 'upload-before' => 'upload_check', 'rename-before' => 'rename_check'));
$opts = gpPlugin::Filter('FinderOptionsServer', array($opts));
gpSettingsOverride('finder_options_server', $opts);
// run Finder
$connector = new Finder($opts);
$connector->run();
Пример #13
0
 static function InlineEdit($section_data)
 {
     $section_data += array('type' => '', 'content' => '');
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($type) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
         case 'image':
             echo 'var gp_blank_img = ' . gpAjax::quote(common::GetDir('/include/imgs/blank.gif')) . ';';
             $scripts[] = '/include/js/jquery.auto_upload.js';
             $scripts[] = '/include/js/inline_edit/image_common.js';
             $scripts[] = '/include/js/inline_edit/image_edit.js';
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     self::SendScripts($scripts);
     //replace resized images with their originals
     if (isset($section_data['resized_imgs']) && is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }
Пример #14
0
 /**
  * Return a list of section types
  * @static
  */
 static function NewSections($checkboxes = false)
 {
     $types_with_imgs = array('text', 'image', 'gallery');
     $section_types = section_content::GetTypes();
     $links = array();
     foreach ($section_types as $type => $type_info) {
         $img = '';
         if (in_array($type, $types_with_imgs)) {
             $img = common::GetDir('/include/imgs/section-' . $type . '.png');
         }
         $links[] = array($type, $img);
     }
     $links[] = array(array('text.gpCol-6', 'image.gpCol-6'), common::GetDir('/include/imgs/section-combo-text-image.png'));
     $links[] = array(array('text.gpCol-6', 'gallery.gpCol-6'), common::GetDir('/include/imgs/section-combo-text-gallery.png'));
     //section combo: text & gallery
     $links = gpPlugin::Filter('NewSections', array($links));
     foreach ($links as $link) {
         $link += array('', '', 'gpRow');
         echo self::NewSectionLink($link[0], $link[1], $link[2], $checkboxes);
     }
 }
Пример #15
0
 function RunScript()
 {
     global $langmessage, $page;
     $cmd = common::GetCommand();
     //prevent overwriting the content to maintain overlay editin links
     //$page->ajaxReplace = array();
     if (!$this->SetVars()) {
         return;
     }
     $this->GetFile();
     //original alpha versions of 1.8 didn't maintain the file_type
     if (!isset($this->meta_data['file_type'])) {
         $this->ResetFileTypes();
     }
     //admin toolbar links
     $menu_permissions = admin_tools::HasPermission('Admin_Menu');
     $can_edit = admin_tools::CanEdit($this->gp_index);
     if ($menu_permissions) {
         $page->admin_links[] = common::Link($this->title, $langmessage['rename/details'], 'cmd=renameform', 'data-cmd="gpajax"');
         // Having the layout link here complicates things.. would need layout link for special pages
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['current_layout'], 'cmd=layout&from=page&index=' . urlencode($this->gp_index), array('title' => $langmessage['current_layout'], 'data-cmd' => 'gpabox'));
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['Copy'], 'cmd=copypage&redir=redir&index=' . urlencode($this->gp_index), array('title' => $langmessage['Copy'], 'data-cmd' => 'gpabox'));
     }
     if (admin_tools::HasPermission('Admin_User')) {
         $page->admin_links[] = common::Link('Admin_Users', $langmessage['permissions'], 'cmd=file_permissions&index=' . urlencode($this->gp_index), array('title' => $langmessage['permissions'], 'data-cmd' => 'gpabox'));
     }
     if ($can_edit) {
         $page->admin_links[] = common::Link($this->title, $langmessage['Revision History'], 'cmd=view_history', array('title' => $langmessage['Revision History'], 'data-cmd' => 'gpabox'));
     }
     if ($menu_permissions) {
         $page->admin_links[] = common::Link('Admin_Menu', $langmessage['delete_file'], 'cmd=trash_page&index=' . urlencode($this->gp_index), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_page'], 'class' => 'gpconfirm'));
     }
     //allow addons to effect page actions and how a page is displayed
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     //admin actions
     if ($menu_permissions) {
         switch ($cmd) {
             // rename & details
             case 'renameform':
                 $this->RenameForm();
                 return;
             case 'renameit':
                 if ($this->RenameFile()) {
                     return;
                 }
                 break;
         }
     }
     //file editing actions
     if ($can_edit) {
         switch ($cmd) {
             case 'rawcontent':
                 $this->RawContent();
                 break;
                 /* gallery editing */
             /* gallery editing */
             case 'gallery_folder':
             case 'gallery_images':
                 $this->GalleryImages();
                 return;
             case 'new_dir':
                 $this->contentBuffer = gp_edit::NewDirForm();
                 return;
                 /* inline editing */
             /* inline editing */
             case 'save':
             case 'preview':
             case 'inlineedit':
             case 'include_dialog':
                 $this->SectionEdit($cmd);
                 return;
                 /* Manage section */
             /* Manage section */
             case 'ManageSections':
                 $this->ManageSections();
                 //dies
             //dies
             case 'NewSectionContent':
                 $this->NewSectionContent();
                 return;
             case 'SaveSections':
                 $this->SaveSections();
                 return;
                 /* revision history */
             /* revision history */
             case 'view_revision':
                 $this->ViewRevision();
                 return;
             case 'use_revision':
                 $this->UseRevision();
                 break;
             case 'view_history':
                 $this->ViewHistory();
                 return;
         }
     }
     $this->contentBuffer = $this->GenerateContent_Admin();
 }
Пример #16
0
 /**
  * Return true if an administrator is logged in
  * @return bool
  */
 static function LoggedIn()
 {
     global $gpAdmin;
     $loggedin = false;
     if (isset($gpAdmin) && is_array($gpAdmin)) {
         $loggedin = true;
     }
     return gpPlugin::Filter('LoggedIn', array($loggedin));
 }
Пример #17
0
 function InlineEdit($section_data)
 {
     global $dataDir, $dirPrefix;
     $section_data += array('type' => '', 'content' => '');
     header('Content-type: application/x-javascript');
     $type = $section_data['type'];
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     //$scripts[] = '/include/thirdparty/jquery_ui/jquery-ui.custom.min.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($section_data['type']) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     $scripts = array_unique($scripts);
     //send all scripts
     foreach ($scripts as $script) {
         //absolute paths don't need $dataDir
         $full_path = $script;
         if (strpos($script, $dataDir) !== 0) {
             //fix addon paths that use $addonRelativeCode
             if (!empty($dirPrefix) && strpos($script, $dirPrefix) === 0) {
                 $script = substr($script, strlen($dirPrefix));
             }
             $full_path = $dataDir . $script;
         }
         if (!file_exists($full_path)) {
             echo 'if(isadmin){alert("Admin Notice: The following file could not be found: \\n\\n' . addslashes($full_path) . '");}';
             continue;
         }
         echo ';';
         //echo "\n/**\n* $script\n*\n*/\n";
         readfile($full_path);
     }
     //replace resized images with their originals
     if (is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }
Пример #18
0
 function SaveSection()
 {
     global $page, $langmessage;
     //for ajax responses
     $page->ajaxReplace = array();
     //check
     $section =& $_POST['section'];
     if (!is_numeric($section)) {
         message($langmessage['OOPS'] . '(1)');
         return false;
     }
     if (!isset($this->file_sections[$section])) {
         message($langmessage['OOPS'] . '(1)');
         return false;
     }
     $type = $this->file_sections[$section]['type'];
     $save_this = false;
     switch ($type) {
         case 'text':
             $save_this = true;
             $this->SaveSection_Text($section);
             break;
         case 'gallery':
             $save_this = true;
             $this->SaveSection_Text($section);
             $this->GalleryEdited();
             break;
         case 'include':
             $save_this = $this->SaveSection_Include($section);
             break;
     }
     $save_this = gpPlugin::Filter('SaveSection', array($save_this, $section, $type));
     if ($save_this !== true) {
         message($langmessage['OOPS'] . '(2)');
         return false;
     }
     //save to _pages
     if (!$this->SaveThis()) {
         message($langmessage['OOPS'] . '(3)');
         return false;
     }
     $page->ajaxReplace[] = array('ck_saved', '', '');
     message($langmessage['SAVED']);
     return true;
 }
Пример #19
0
 /**
  * Return the name of the page being requested based on $_SERVER['REQUEST_URI']
  * May also redirect the request
  *
  * @return string The title to display based on the request uri
  *
  */
 function WhichPage()
 {
     global $config, $gp_internal_redir, $gp_menu;
     if (isset($gp_internal_redir)) {
         return $gp_internal_redir;
     }
     $path = common::CleanRequest($_SERVER['REQUEST_URI']);
     $pos = strpos($path, '?');
     if ($pos !== false) {
         $path = substr($path, 0, $pos);
     }
     $path = gpPlugin::Filter('WhichPage', array($path));
     //redirect if an "external link" is the first entry of the main menu
     if (empty($path) && isset($gp_menu[$config['homepath_key']])) {
         $homepath_info = $gp_menu[$config['homepath_key']];
         if (isset($homepath_info['url'])) {
             common::Redirect($homepath_info['url'], 302);
         }
     }
     if (empty($path)) {
         return $config['homepath'];
     }
     if (isset($config['homepath']) && $path == $config['homepath']) {
         common::Redirect(common::GetUrl(''));
     }
     return $path;
 }
Пример #20
0
 function SendMessage()
 {
     global $langmessage, $config, $gp_mailer;
     includeFile('tool/email_mailer.php');
     $headers = array();
     $_POST += array('subject' => '', 'contact_nonce' => '', 'message' => '');
     if (empty($_POST['message'])) {
         msg($langmessage['OOPS'] . '(Invalid Message)');
         return;
     }
     //check nonce
     if (!common::verify_nonce('contact_post', $_POST['contact_nonce'], true)) {
         msg($langmessage['OOPS'] . '(Invalid Nonce)');
         return;
     }
     if (!empty($_POST['contact_void'])) {
         msg($langmessage['OOPS'] . '(Robot Detected)');
         return;
     }
     //captcha
     if (!gp_recaptcha::Check()) {
         return;
     }
     if (!gpPlugin::Filter('contact_form_check', array(true))) {
         return;
     }
     //subject
     $_POST['subject'] = strip_tags($_POST['subject']);
     //message
     $tags = '<p><div><span><font><b><i><tt><em><i><a><strong><blockquote>';
     $message = nl2br(strip_tags($_POST['message'], $tags));
     //reply name
     if (!empty($_POST['email'])) {
         //check format
         if (!$this->ValidEmail($_POST['email'])) {
             msg($langmessage['invalid_email']);
             return false;
         }
         $replyName = str_replace(array("\r", "\n"), array(' '), $_POST['name']);
         $replyName = strip_tags($replyName);
         $replyName = htmlspecialchars($replyName);
         $gp_mailer->AddReplyTo($_POST['email'], $replyName);
         if (common::ConfigValue('from_use_user', false)) {
             $gp_mailer->SetFrom($_POST['email'], $replyName);
         }
     }
     //check for required values
     $require_email =& $config['require_email'];
     if (strpos($require_email, 'email') !== false) {
         if (empty($_POST['email'])) {
             $field = gpOutput::SelectText('your_email');
             msg($langmessage['OOPS_REQUIRED'], $field);
             return false;
         }
     }
     if (strpos($require_email, 'none') === false) {
         if (empty($_POST['subject'])) {
             $field = gpOutput::SelectText('subject');
             msg($langmessage['OOPS_REQUIRED'], $field);
             return false;
         }
         if (empty($message)) {
             $field = gpOutput::SelectText('message');
             msg($langmessage['OOPS_REQUIRED'], $field);
             return false;
         }
     }
     if ($gp_mailer->SendEmail($config['toemail'], $_POST['subject'], $message)) {
         msg($langmessage['message_sent']);
         return true;
     }
     msg($langmessage['OOPS'] . ' (Send Failed)');
     return false;
 }
Пример #21
0
 /**
  * Clean a slug posted by the user
  * @param string $slug The slug provided by the user
  * @return string
  * @since 2.4b5
  */
 static function PostedSlug($string, $from_label = false)
 {
     global $config;
     includeFile('tool/strings.php');
     $orig_string = $string;
     // Remove control characters
     $string = preg_replace('#[[:cntrl:]]#u', '', $string);
     // 	[\x00-\x1F\x7F]
     //illegal characters
     $string = str_replace(array('?', '*', ':', '|'), array('', '', '', ''), $string);
     //change known entities to their character equivalent
     $string = gp_strings::entity_unescape($string);
     //if it's from a label, remove any html
     if ($from_label) {
         $string = admin_tools::LabelHtml($string);
         $string = strip_tags($string);
         //after removing tags, unescape special characters
         $string = str_replace(array('&lt;', '&gt;', '&quot;', '&#39;', '&amp;'), array('<', '>', '"', "'", '&'), $string);
     }
     // # character after unescape for entities and unescape of special chacters when $from_label is true
     $string = str_replace('#', '', $string);
     //slashes
     $string = admin_tools::SlugSlashes($string);
     $string = str_replace(' ', $config['space_char'], $string);
     return gpPlugin::Filter('PostedSlug', array($string, $orig_string, $from_label));
 }
Пример #22
0
 /**
  * Return an array
  *
  */
 static function SectionFromPost(&$existing_section, $section_num, $title, $file_stats)
 {
     global $page, $gpAdmin;
     $section_before = $existing_section;
     $type = $existing_section['type'];
     $save_this = false;
     switch ($type) {
         case 'text':
             $save_this = true;
             self::SectionFromPost_Text($existing_section);
             break;
         case 'gallery':
             $save_this = true;
             self::SectionFromPost_Gallery($existing_section);
             break;
         case 'include':
             $save_this = self::SectionFromPost_Include($existing_section, $section_num, $title, $file_stats);
             break;
     }
     // Hack: SaveSection used $page->file_sections
     $page->file_sections[$section_num] = $existing_section;
     $save_this = gpPlugin::Filter('SaveSection', array($save_this, $section_num, $type));
     $existing_section = $page->file_sections[$section_num];
     if (!$save_this) {
         $page->file_sections[$section_num] = $existing_section = $section_before;
     }
     $page->file_sections[$section_num]['modified'] = time();
     $page->file_sections[$section_num]['modified_by'] = $gpAdmin['username'];
     return $save_this;
 }
Пример #23
0
 function RunScript()
 {
     if (!$this->SetVars()) {
         return;
     }
     //allow addons to effect page actions and how a page is displayed
     $cmd = common::GetCommand();
     $cmd_after = gpPlugin::Filter('PageRunScript', array($cmd));
     if ($cmd !== $cmd_after) {
         $cmd = $cmd_after;
         if ($cmd === 'return') {
             return;
         }
     }
     $this->GetFile();
     includeFile('tool/SectionContent.php');
     $this->contentBuffer = section_content::Render($this->file_sections, $this->title, $this->file_stats);
 }
Пример #24
0
 /**
  * Check the file extension agains $allowed_types
  *
  */
 static function AllowedExtension(&$file, $fix = true)
 {
     global $upload_extensions_allow, $upload_extensions_deny;
     static $allowed_types = false;
     $file = gpFiles::NoNull($file);
     if (!gp_restrict_uploads) {
         return true;
     }
     $parts = explode('.', $file);
     if (count($parts) < 2) {
         return true;
     }
     //build list of allowed extensions once
     if (!$allowed_types) {
         if (is_string($upload_extensions_deny) && strtolower($upload_extensions_deny) === 'all') {
             $allowed_types = array();
         } else {
             $allowed_types = array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tif', 'tiff', 'wav', 'wma', 'svg', 'aiff', 'asf', 'avi', 'fla', 'flv', 'm4v', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ogg', 'oga', 'ogv', 'opus', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'webm', 'wmv', '7z', 'bz', 'gz', 'gzip', 'rar', 'sdc', 'sitd', 'tar', 'tgz', 'zip', 'css', 'csv', 'doc', 'docx', 'htm', 'html', 'js', 'json', 'less', 'md', 'ods', 'odt', 'pdf', 'ppt', 'pptx', 'rtf', 'txt', 'sxc', 'sxw', 'vsd', 'xls', 'xlsx', 'xml');
         }
         if (is_array($upload_extensions_allow)) {
             $upload_extensions_allow = array_map('trim', $upload_extensions_allow);
             $upload_extensions_allow = array_map('strtolower', $upload_extensions_allow);
             $allowed_types = array_merge($allowed_types, $upload_extensions_allow);
         }
         if (is_array($upload_extensions_deny)) {
             $upload_extensions_allow = array_map('trim', $upload_extensions_allow);
             $upload_extensions_allow = array_map('strtolower', $upload_extensions_allow);
             $allowed_types = array_diff($allowed_types, $upload_extensions_deny);
         }
     }
     $allowed_types = gpPlugin::Filter('AllowedTypes', array($allowed_types));
     //make sure the extension is allowed
     $file_type = array_pop($parts);
     if (!in_array(strtolower($file_type), $allowed_types)) {
         return false;
     }
     if ($fix) {
         return implode('_', $parts) . '.' . $file_type;
     } else {
         return implode('.', $parts) . '.' . $file_type;
     }
 }
Пример #25
0
 function GetExtra($name = 'Side_Menu', $info = array())
 {
     global $dataDir, $langmessage;
     $name = str_replace(' ', '_', $name);
     $extra_content = '';
     $file = $dataDir . '/data/_extra/' . $name . '.php';
     if (file_exists($file)) {
         ob_start();
         include $file;
         $extra_content = ob_get_clean();
     }
     $extra_content = gpPlugin::Filter('GetExtra', array($extra_content, $name));
     $wrap = gpOutput::ShowEditLink('Admin_Extra');
     if ($wrap) {
         $edit_link = gpOutput::EditAreaLink($edit_index, 'Admin_Extra', $langmessage['edit'], 'cmd=edit&file=' . $name, ' title="' . $name . '" name="inline_edit_generic" ');
         echo '<span class="nodisplay" id="ExtraEditLnks' . $edit_index . '">';
         echo $edit_link;
         echo common::Link('Admin_Extra', $langmessage['theme_content'], '', ' class="nodisplay"');
         //echo gpOutput::ArrangeLinks($info);
         echo '</span>';
         echo '<div class="editable_area" id="ExtraEditArea' . $edit_index . '">';
         // class="edit_area" added by javascript
         echo $extra_content;
         echo '</div>';
     } else {
         echo $extra_content;
     }
 }
Пример #26
0
 /**
  * Return an array
  *
  */
 static function SectionFromPost(&$existing_section, $section_num, $title, $file_stats)
 {
     global $page, $gpAdmin;
     $section_before = $existing_section;
     $type = $existing_section['type'];
     $save_this = false;
     switch ($type) {
         case 'text':
             $save_this = true;
             self::SectionFromPost_Text($existing_section);
             break;
         case 'gallery':
             $save_this = true;
             self::SectionFromPost_Gallery($existing_section);
             break;
         case 'include':
             $save_this = self::SectionFromPost_Include($existing_section, $section_num, $title, $file_stats);
             break;
         case 'image':
             $save_this = self::SectionFromPost_Imagme($existing_section);
             break;
     }
     //make sure $existing_section is still an array
     $type_check = gettype($existing_section);
     if ($type_check !== 'array') {
         trigger_error('$existing_section is ' . $type_check . '. Array expected');
         return false;
     }
     // Hack: SaveSection used $page->file_sections
     $page->file_sections[$section_num] = $existing_section;
     $save_this = gpPlugin::Filter('SaveSection', array($save_this, $section_num, $type));
     $existing_section = $page->file_sections[$section_num];
     if (!$save_this) {
         $page->file_sections[$section_num] = $existing_section = $section_before;
     }
     $page->file_sections[$section_num]['modified'] = time();
     $page->file_sections[$section_num]['modified_by'] = $gpAdmin['username'];
     return $save_this;
 }