Beispiel #1
0
 * Copyright (c) pluck team
 * http://www.pluck-cms.org

 * Pluck is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly.
defined('IN_PLUCK') or exit('Access denied!');
//If we want to restore a page.
if ($var2 == 'page' && file_exists('data/trash/pages/' . $var1 . '.php')) {
    //We can't restore the page if there is a page with the same name.
    if (get_page_filename($var1) != false) {
        show_error($lang['trashcan']['same_page_name'], 1);
        redirect('?action=trashcan', 3);
    } else {
        $pages = read_dir_contents(PAGE_DIR, 'files');
        if ($pages == false) {
            $next_number = 1;
        } else {
            $next_number = count($pages) + 1;
        }
        rename('data/trash/pages/' . $var1 . '.php', PAGE_DIR . '/' . $next_number . '.' . $var1 . '.php');
        //Redirect.
        show_error($lang['trashcan']['restoring'], 3);
        redirect('?action=trashcan', 1);
    }
} elseif ($var2 == 'file' && file_exists('data/trash/files/' . $var1)) {
Beispiel #2
0
/**
 * Get the parents of a page. NOTE: does not check if pages actually exist.
 *
 * @since 4.7
 * @package all
 * @param string $seoname The seoname of the page.
 * @return array Seonames of parents, in an array. If $seoname doesn't have parents (if it is a top page), return FALSE.
 */
function get_page_parents($seoname)
{
    if (strpos($seoname, '/') !== false && file_exists(PAGE_DIR . '/' . get_page_filename($seoname))) {
        $parents = preg_split('|\\/|', $seoname);
        unset($parents[count($parents) - 1]);
        return $parents;
    } else {
        return false;
    }
}
Beispiel #3
0
     if ($pages) {
         foreach ($sub_pages as $sub_page) {
             foreach ($pages as $page) {
                 if ($page == str_replace(get_sub_page_dir(get_page_seoname($sub_page)) . '/', '', get_page_seoname($sub_page)) . '.php') {
                     show_error($lang['trashcan']['same_name'], 1);
                     redirect('?action=page', 2);
                     include_once 'data/inc/footer.php';
                     exit;
                 }
             }
             unset($page);
         }
     }
 }
 //Move the file.
 rename(PAGE_DIR . '/' . get_page_filename($var1), 'data/trash/pages/' . $newfile . '.php');
 //Then move the sub-pages, if any.
 if (isset($sub_pages)) {
     foreach ($sub_pages as $sub_page) {
         rename(PAGE_DIR . '/' . $sub_page, 'data/trash/pages/' . str_replace(get_sub_page_dir(get_page_seoname($sub_page)) . '/', '', get_page_seoname($sub_page)) . '.php');
     }
     //Delete the dir where the sub-pages were in.
     rmdir(PAGE_DIR . '/' . $var1);
 }
 //If it's a sub-page, we have to do a few things.
 if (strpos($var1, '/') !== false) {
     //Delete the dir, if there are no other pages.
     if (read_dir_contents(PAGE_DIR . '/' . get_sub_page_dir($var1), 'files') == false) {
         rmdir(PAGE_DIR . '/' . get_sub_page_dir($var1));
     } else {
         reorder_pages(PAGE_DIR . '/' . get_sub_page_dir($var1));
Beispiel #4
0
/**
 * Generates page menu. Only for internal use. For themes, use theme_menu().
 *
 * @since 4.7
 * @package site
 */
function theme_menu_data($block, $inline, $active_id, $level, $dir)
{
    //If specified directory does not exist, just return.
    if (!is_dir($dir)) {
        return;
    }
    $files = read_dir_contents($dir, 'files');
    if ($files) {
        //Sort the array.
        natcasesort($files);
        echo '<' . $block . '>';
        foreach ($files as $file) {
            include $dir . '/' . $file;
            $file = get_page_seoname($dir . '/' . $file);
            //Only display in menu if page isn't hidden by user.
            if (isset($hidden) && $hidden == 'no') {
                //Get parents of the currently displayed page
                $parents = get_page_parents(CURRENT_PAGE_SEONAME);
                //Strip parents from $file, but only if it's a sub page
                if (strpos($file, '/') !== false && file_exists(PAGE_DIR . '/' . get_page_filename($file))) {
                    $file_levels = preg_split('|\\/|', $file);
                    $file_stripped = $file_levels[count($file_levels) - 1];
                } else {
                    $file_stripped = $file;
                }
                //Show an active inline for current page...
                if ($active_id && CURRENT_PAGE_SEONAME == $file) {
                    echo '<' . $inline . ' class="' . $active_id . '" id="' . $active_id . '">';
                } elseif ($active_id && $parents && array_search($file_stripped, $parents) !== false) {
                    echo '<' . $inline . ' class="' . $active_id . '">';
                } else {
                    echo '<' . $inline . '>';
                }
                //Unset parents array
                unset($parents);
                //Display link
                echo '<a href="' . SITE_URL . '/' . PAGE_URL_PREFIX . $file . '" >' . $title . '</a>';
                preg_match_all('|\\/|', $file, $page_level);
                $page_level = count($page_level[0]);
                if ($level > $page_level && is_dir(PAGE_DIR . '/' . $file)) {
                    theme_menu_data($block, $inline, $active_id, $level, PAGE_DIR . '/' . $file);
                }
                echo '</' . $inline . '>';
            }
        }
        unset($file);
        echo '</' . $block . '>';
    }
}
Beispiel #5
0
 * Copyright (c) pluck team
 * http://www.pluck-cms.org

 * Pluck is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly.
defined('IN_PLUCK') or exit('Access denied!');
run_hook('admin_editpage_before');
//Include page information, if we're editing a page.
if (isset($_GET['page']) && file_exists(PAGE_DIR . '/' . get_page_filename($_GET['page']))) {
    require_once PAGE_DIR . '/' . get_page_filename($_GET['page']);
}
//If form is posted...
if (isset($_POST['save']) || isset($_POST['save_exit'])) {
    //Allow modules to add data to page
    $module_additional_data = null;
    run_hook('admin_save_page_afterpost', array(&$module_additional_data));
    if (!isset($_POST['hidden'])) {
        $_POST['hidden'] = 'yes';
    }
    //Save the page, but only if a title has been entered and it's seo url is not empty.
    if (!empty($_POST['title']) && seo_url($_POST['title'])) {
        if (!empty($_POST['seo_name']) && $_POST['seo_name'] != seo_url($_POST['title'])) {
            $title = array('title' => $_POST['title'], 'seo_name' => trim(str_replace(array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), '', $_POST['seo_name'])));
        } else {
            $title = $_POST['title'];
Beispiel #6
0
    function main($module_id, $mode)
    {
        global $db, $user, $auth, $template, $cache, $request;
        global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx, $k_config, $table_prefix, $cache;
        include_once $phpbb_root_path . 'ext/phpbbireland/portal/config/constants.' . $phpEx;
        if (!function_exists('obtain_k_config')) {
            include $phpbb_root_path . 'ext/phpbbireland/portal/includes/functions.' . $phpEx;
            $k_config = obtain_k_config();
        }
        $img_path = $phpbb_root_path . 'ext/phpbbireland/portal/images/block_images/block/';
        $img_path_acp = $phpbb_root_path . 'ext/phpbbireland/portal/adm/images/';
        $portal_js = $phpbb_root_path . 'ext/phpbbireland/portal/js/portal.js';
        $user->add_lang_ext('phpbbireland/portal', 'k_pages');
        $this->tpl_name = 'acp_pages';
        $this->page_title = $user->lang['ACP_PAGES'];
        add_form_key('pages');
        if (!class_exists('sgp_functions_admin')) {
            require $phpbb_root_path . 'ext/phpbbireland/portal/includes/sgp_functions_admin.' . $phpEx;
            $sgp_functions_admin = new sgp_functions_admin();
        }
        $mode = $request->variable('mode', '');
        $page_id = $request->variable('page_id', 0);
        $action = $request->variable('config', '');
        $tag_id = $request->variable('tag_id', '');
        $current_pages = array();
        $submit = false;
        if ($request->is_set_post('submit')) {
            if (!check_form_key('pages')) {
                $submit = false;
                $mode = '';
                trigger_error('FORM_INVALID');
            }
            $submit = true;
        }
        if ($tag_id != '') {
            $mode = 'add';
        }
        switch ($action) {
            case 'config':
                $template->assign_var('MESSAGE', $user->lang['SWITCHING']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=k_vars&amp;mode=config&amp;switch=k_pages"));
                break;
            default:
                break;
        }
        if ($submit && !check_form_key('pages')) {
            $submit = false;
            $mode = '';
            trigger_error($user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
        }
        if ($submit) {
            $mod_pages = $request->variable('k_mod_folders', '');
            // trap trailing commas in mod pages //
            if ($mod_pages && $mod_pages[strlen($mod_pages) - 1] == ',') {
                trigger_error($user->lang['TRAILING_COMMA'] . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage")), E_USER_WARNING);
            }
            //  We check to see  the mod folder exists, if not return... //
            $mod_pages = str_replace(' ', '', $mod_pages);
            // has mod folder been updated/modified //
            if (strcmp($mod_pages, $k_config['k_mod_folders'] != 0)) {
                $mods_folder_array = explode(',', $mod_pages);
                foreach ($mods_folder_array as $folder) {
                    $folder = trim($folder);
                    if (!file_exists($phpbb_root_path . $folder)) {
                        $submit = false;
                        $mod_pages = '';
                        trigger_error($user->lang['NO_MOD_FOLDER'] . $folder . adm_back_link(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage")), E_USER_WARNING);
                    }
                }
                $template->assign_vars(array('MESSAGE' => $user->lang['FOLDER_ADDED']));
            }
            $sgp_functions_admin->sgp_acp_set_config('k_mod_folders', $mod_pages);
        }
        $template->assign_vars(array('U_BACK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"), 'U_ADD' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=add"), 'U_MANAGE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"), 'S_OPT' => 'S_MANAGE', 'S_PAGE' => isset($k_config['k_landing_page']) ? $k_config['k_landing_page'] : 'portal', 'IMG_PATH_ACP' => $img_path_acp));
        switch ($mode) {
            case 'delete':
                $page_name = get_page_filename($page_id);
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . K_PAGES_TABLE . '
						WHERE page_id = ' . (int) $page_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_PAGES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . $user->lang['LINE'] . __LINE__);
                    }
                    $cache->destroy('sql', K_PAGES_TABLE);
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['REMOVING_PAGES'] . $page_name));
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"));
                    break;
                } else {
                    confirm_box(false, sprintf("%s (%s)", $user->lang['DELETE_FROM_LIST'], $page_name), build_hidden_fields(array('id' => $page_id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('MESSAGE', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"));
                break;
            case 'add':
                if ($submit) {
                    // drop extension
                    $tag_id = str_replace('.php', '', $tag_id);
                    // skip the spacer //
                    if ($tag_id == '..') {
                        $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => sprintf($user->lang['ERROR_PAGE'], $tag_id)));
                        meta_refresh(2, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"));
                        return;
                    }
                    if (in_array($tag_id, $current_pages)) {
                        break;
                    }
                    $sql_array = array('page_name' => $tag_id);
                    $db->sql_query('INSERT INTO ' . K_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                    meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"));
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['ADDING_PAGES']));
                    $cache->destroy('sql', K_PAGES_TABLE);
                    break;
                }
                break;
            case 'land':
                $page_name = get_page_filename($page_id);
                $sgp_functions_admin->sgp_acp_set_config('k_landing_page', $page_name, 1);
                $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['LANDING_PAGE_SET'] . ': ' . $page_name));
                $cache->destroy('k_config');
                $cache->destroy('sql', K_VARS_TABLE);
                meta_refresh(1, append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$module_id}&amp;mode=manage"));
                break;
            case 'config':
                break;
            case 'manage':
                get_all_available_files();
                get_pages_data();
                break;
            case 'default':
                break;
        }
        $template->assign_var('U_ACTION', $this->u_action);
    }
    function main($page_id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        include $phpbb_root_path . 'includes/sgp_functions.' . $phpEx;
        $user->add_lang('acp/k_pages');
        $this->tpl_name = 'acp_k_pages';
        $this->page_filename = 'ACP_PAGES';
        $form_key = 'acp_k_pages';
        add_form_key($form_key);
        //$s_hidden_fields = '';
        $mode = request_var('mode', '');
        $page_id = request_var('page_id', 0);
        $action = request_var('config', '');
        $tag_id = request_var('tag_id', '');
        $submit = isset($_POST['submit']) ? true : false;
        if ($tag_id != '') {
            $mode = 'add';
        }
        switch ($action) {
            case 'config':
                $template->assign_var('MESSAGE', $user->lang['SWITCHING']);
                meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_vars&amp;mode=config&amp;switch=k_pages");
                break;
            default:
                break;
        }
        if ($submit && !check_form_key($form_key)) {
            $submit = false;
            $mode = '';
            trigger_error($user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
        }
        $template->assign_vars(array('U_BACK' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&mode=manage", 'U_ADD' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=add", 'U_EDIT' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=edit" . '&amp;page_id=' . $page_id, 'U_DELETE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=delete" . '&amp;page_id=' . $page_id, 'U_MANAGE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=manage", 'S_OPT' => 'S_MANAGE'));
        switch ($mode) {
            case 'delete':
                $page_name = get_page_filename($page_id);
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . K_PAGES_TABLE . '
						WHERE page_id = ' . (int) $page_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_PAGES'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $cache->destroy('sql', K_PAGES_TABLE);
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['REMOVING_PAGES'] . $page_name));
                    meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=manage");
                    break;
                } else {
                    confirm_box(false, sprintf("%s (%s)", $user->lang['CONFIRM_DELETE'], $page_name), build_hidden_fields(array('id' => $page_id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('MESSAGE', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=manage");
                break;
            case 'add':
                if ($submit) {
                    // drop extension
                    $tag_id = str_replace('.php', '', $tag_id);
                    // skip the spacer //
                    if ($tag_id == '..') {
                        $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => sprintf($user->lang['ERROR_PAGE'], $tag_id)));
                        meta_refresh(3, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=manage");
                        return;
                    }
                    $sql_array = array('page_name' => $tag_id);
                    $db->sql_query('INSERT INTO ' . K_PAGES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                    meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_pages&amp;mode=manage");
                    $template->assign_vars(array('S_OPTION' => 'processing', 'MESSAGE' => $user->lang['ADDING_PAGES']));
                    $cache->destroy('sql', K_PAGES_TABLE);
                    break;
                }
                break;
            case 'config':
                break;
            case 'manage':
                get_all_available_files();
                get_pages_data();
                break;
            case 'default':
                break;
        }
        $template->assign_var('U_ACTION', $this->u_action);
    }
Beispiel #8
0
/**
 * Save a page with a lot of options.
 *
 * @since 4.7
 * @package admin
 * @param mixed $title if string - The title, if array title => The title, seo_name => The seo_name.
 * @param string $content The content.
 * @param string $hidden Should it be hidden ('yes' or 'no')?
 * @param string $subpage Specifies the parent page, if the saved page should be a sub page. Default to null.
 * @param string $description Description of the page. Defaults to null.
 * @param string $keywords Keywords of the page. Defaults to null.
 * @param array $module_additional_data Additional data variable, can be edited by modules through hooks (admin_save_page_module_additional_data). Defaults to null.
 * @param string $current_seoname Current seoname of the page, if we are editing a page. Defaults to null.
 * @return string Seoname of the saved page.
 */
function save_page($title, $content, $hidden, $subpage = null, $description = null, $keywords = null, $module_additional_data = null, $current_seoname = null)
{
    //Run a few hooks.
    run_hook('admin_save_page', array(&$title, &$content));
    run_hook('admin_save_page_meta', array(&$description, &$keywords));
    run_hook('admin_save_page_module_additional_data', array(&$module_additional_data));
    //Configure title and seo_name
    if (is_array($title)) {
        if (!empty($title['seo_name'])) {
            $seo_title = $title['seo_name'];
            $title = $title['title'];
        } else {
            $seo_title = seo_url($title['title']);
            $title = $title['title'];
        }
    } else {
        $seo_title = seo_url($title);
    }
    //Check if the seo url  is empty.
    if (empty($seo_title)) {
        return false;
    }
    //Check if a page already exists with the name.
    if ((!isset($current_seoname) || $current_seoname != $subpage . $seo_title) && get_page_filename($subpage . $seo_title) != false) {
        return false;
    }
    //Do we want to create a new page?
    if (!isset($current_seoname)) {
        //Check if we want a sub-page.
        if (!empty($subpage)) {
            //We need to make sure that the dir exists, and if not, create it.
            if (!file_exists(PAGE_DIR . '/' . rtrim($subpage, '/'))) {
                mkdir(PAGE_DIR . '/' . rtrim($subpage, '/'));
                chmod(PAGE_DIR . '/' . rtrim($subpage, '/'), 0777);
            }
            $pages = read_dir_contents(PAGE_DIR . '/' . rtrim($subpage, '/'), 'files');
        } else {
            $pages = read_dir_contents(PAGE_DIR, 'files');
        }
        //Are there any pages?
        if ($pages == false) {
            $number = 1;
        } else {
            $number = count($pages) + 1;
        }
        $newfile = $subpage . $number . '.' . $seo_title;
    } else {
        $filename = get_page_filename($current_seoname);
        //the old file name
        //Is it a sub-page, or do we want to make it one?
        if (strpos($current_seoname, '/') !== false || !empty($subpage)) {
            $page_name = explode('/', $subpage);
            $count = count($page_name);
            unset($page_name[$count]);
            $dir = get_sub_page_dir($current_seoname);
            $filename_array = str_replace($dir . '/', '', $filename);
            $filename_array = explode('.', $filename_array);
            $newfilename = implode('/', $page_name) . '/' . $filename_array[0] . '.' . $seo_title;
            $newdir = get_sub_page_dir($newfilename);
            //We need to make sure that the dir exists, and if not, create it.
            if (!file_exists(PAGE_DIR . '/' . $newdir)) {
                mkdir(PAGE_DIR . '/' . $newdir);
                chmod(PAGE_DIR . '/' . $newdir, 0777);
            }
            //If the name isn't the same as before, we have to find the correct number.
            if ($newfilename . '.php' != $filename) {
                //If the sub-folder is the same, use the same number as before.
                if ($dir . '/' == $newdir) {
                    $number = $filename_array[0];
                } else {
                    $pages = read_dir_contents(PAGE_DIR . '/' . $newdir, 'files');
                    if ($pages) {
                        $count = count($pages);
                        $number = $count + 1;
                    } else {
                        $number = 1;
                    }
                }
                $newfile = implode('/', $page_name) . $number . '.' . $seo_title;
            }
        } else {
            $filename_array = explode('.', $filename);
            $newfile = $filename_array[0] . '.' . $seo_title;
        }
    }
    //Save the title, content and hidden status.
    $data = '<?php' . "\n" . '$title = \'' . sanitize($title) . '\';' . "\n" . '$seoname = \'' . sanitize($seo_title) . '\';' . "\n" . '$content = \'' . sanitize($content, false) . '\';' . "\n" . '$hidden = \'' . $hidden . '\';';
    //Save the description and keywords, if any.
    if ($description != null) {
        $data .= "\n" . '$description = \'' . sanitize($description) . '\';';
    }
    if ($keywords != null) {
        $data .= "\n" . '$keywords = \'' . sanitize($keywords) . '\';';
    }
    //If modules have supplied additional data, save it.
    if ($module_additional_data != null && is_array($module_additional_data)) {
        foreach ($module_additional_data as $var => $value) {
            $data .= "\n" . '$' . $var . ' = \'' . $value . '\';';
        }
    }
    $data .= "\n" . '?>';
    //Save the file.
    save_file(PAGE_DIR . '/' . $newfile . '.php', $data);
    //Do a little cleanup if we are editing a page.
    if (isset($current_seoname)) {
        //Check if the title is different from what we started with.
        if ($newfile . '.php' != $filename) {
            //If there are sub-pages, rename the folder.
            if (file_exists(PAGE_DIR . '/' . get_page_seoname($filename))) {
                rename(PAGE_DIR . '/' . get_page_seoname($filename), PAGE_DIR . '/' . get_page_seoname($newfile . '.php'));
            }
            //Remove the old file.
            unlink(PAGE_DIR . '/' . $filename);
            //If there are no files in the old dir, delete it.
            if (isset($dir) && read_dir_contents(PAGE_DIR . '/' . $dir, 'files') == false) {
                rmdir(PAGE_DIR . '/' . $dir);
            } elseif (isset($dir)) {
                reorder_pages(PAGE_DIR . '/' . $dir);
            } else {
                reorder_pages(PAGE_DIR);
            }
        }
    }
    //Return the seoname.
    return get_page_seoname($newfile . '.php');
}
Beispiel #9
0
 * Pluck is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly.
defined('IN_PLUCK') or exit('Access denied!');
if (isset($_GET['file'])) {
    if (!empty($_GET['file']) && get_page_filename($_GET['file']) != false) {
        /**
         * Defines the filename of the current page. NOTE: is only defined if the requested page exists.
         */
        define('CURRENT_PAGE_FILENAME', get_page_filename($_GET['file']));
    }
    /**
     * Defines the seoname of the requested page. NOTE: is also defined if the requested page does not exist.
     */
    define('CURRENT_PAGE_SEONAME', $_GET['file']);
}
//Name of directory of current module.
if (isset($_GET['module'])) {
    define('CURRENT_MODULE_DIR', $_GET['module']);
}
//Name of current module page.
if (isset($_GET['page'])) {
    define('CURRENT_MODULE_PAGE', $_GET['page']);
}
//Page title.
Beispiel #10
0
 * This file is part of pluck, the easy content management system
 * Copyright (c) pluck team
 * http://www.pluck-cms.org

 * Pluck is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 
 * See docs/COPYING for the complete license.
*/
//Make sure the file isn't accessed directly.
defined('IN_PLUCK') or exit('Access denied!');
//Check if file exists.
if (file_exists(PAGE_DIR . '/' . get_page_filename($var1))) {
    $current_page_filename = get_page_filename($var1);
    if (strpos($current_page_filename, '/') !== false) {
        $patch = explode('/', $current_page_filename);
        $count = count($patch);
        $current_page_filename = $patch[$count - 1];
        unset($patch[$count - 1]);
        $patch = implode('/', $patch);
        $patch = '/' . $patch;
    } else {
        $patch = '';
    }
    $pages = read_dir_contents(PAGE_DIR . $patch, 'files');
    sort($pages, SORT_NUMERIC);
    //Find current page number, and the next page number and filename.
    foreach ($pages as $number => $page) {
        if ($current_page_filename == $page) {
Beispiel #11
0
/**
 * Checks if a module is included in a page.
 *
 * @since 4.7
 * @package all
 * @param string $module The module you want to check.
 * @param string $page_seoname The seoname of the page you want to check.
 * @return bool
 */
function module_is_included_in_page($module, $page_seoname)
{
    $page_filename = get_page_filename($page_seoname);
    if (is_file(PAGE_DIR . '/' . $page_filename)) {
        $content = '';
        include PAGE_DIR . '/' . $page_filename;
        if (preg_match('/\\{pluck show_module\\(' . $module . '(,[^)]*)?\\)\\}/', $content)) {
            return true;
        }
    }
    return false;
}