Ejemplo n.º 1
0
 public function get_search_request($args)
 {
     $search = $args['search'];
     $weight = isset($args['weight']) && is_numeric($args['weight']) ? $args['weight'] : 1;
     require_once PATH_TO_ROOT . '/pages/pages_defines.php';
     $categories = PagesCategoriesCache::load()->get_categories();
     $unauth_cats = '';
     if (!AppContext::get_current_user()->check_auth(PagesConfig::load()->get_authorizations(), READ_PAGE)) {
         $unauth_cats .= '0,';
     }
     foreach ($categories as $id => $cat) {
         if (!AppContext::get_current_user()->check_auth($cat['auth'], READ_PAGE)) {
             $unauth_cats .= $id . ',';
         }
     }
     $unauth_cats = !empty($unauth_cats) ? " AND p.id_cat NOT IN (" . trim($unauth_cats, ',') . ")" : '';
     $results = array();
     $result = PersistenceContext::get_querier()->select("SELECT " . $args['id_search'] . " AS `id_search`,\r\n\t\tp.id AS `id_content`,\r\n\t\tp.title AS `title`,\r\n\t\t( 2 * FT_SEARCH_RELEVANCE(p.title, '" . $args['search'] . "') + FT_SEARCH_RELEVANCE(p.contents, '" . $args['search'] . "') ) / 3 * " . $weight . " AS `relevance`,\r\n\t\tCONCAT('" . PATH_TO_ROOT . "/pages/pages.php?title=',p.encoded_title) AS `link`,\r\n\t\tp.auth AS `auth`\r\n\t\tFROM " . PREFIX . "pages p\r\n\t\tWHERE ( FT_SEARCH(title, '" . $args['search'] . "') OR FT_SEARCH(contents, '" . $args['search'] . "') )" . $unauth_cats . "\r\n\t\tLIMIT 100 OFFSET 0");
     while ($row = $result->fetch()) {
         if (!empty($row['auth'])) {
             $auth = unserialize($row['auth']);
             if (!AppContext::get_current_user()->check_auth($auth, READ_PAGE)) {
                 unset($row['auth']);
                 array_push($results, $row);
             }
         } else {
             unset($row['auth']);
             array_push($results, $row);
         }
     }
     $result->dispose();
     return $results;
 }
Ejemplo n.º 2
0
 function get_feeds_list()
 {
     global $LANG;
     require_once PATH_TO_ROOT . '/pages/pages_functions.php';
     $cats_tree = new FeedsCat('pages', 0, $LANG['root']);
     $categories = PagesCategoriesCache::load()->get_categories();
     build_pages_cat_children($cats_tree, array_values($categories));
     $feeds = new FeedsList();
     $feeds->add_feed($cats_tree, Feed::DEFAULT_FEED_NAME);
     return $feeds;
 }
 private function get_view()
 {
     global $Bread_crumb, $LANG, $pages;
     $pages_config = PagesConfig::load();
     //Configuration des authorisations
     $config_authorizations = $pages_config->get_authorizations();
     require_once PATH_TO_ROOT . '/pages/pages_begin.php';
     $tpl = new FileTemplate('pages/index.tpl');
     $num_pages = PersistenceContext::get_querier()->count(PREFIX . "pages", 'WHERE redirect = 0');
     $num_coms = CommentsService::get_number_and_lang_comments('pages', $pages['id']);
     $tpl->put_all(array('NUM_PAGES' => sprintf($LANG['pages_num_pages'], $num_pages), 'NUM_COMS' => sprintf($LANG['pages_num_coms'], $num_coms, $num_pages > 0 ? $num_coms / $num_pages : 0), 'L_EXPLAIN_PAGES' => $LANG['pages_explain'], 'L_STATS' => $LANG['pages_stats']));
     //Liste des dossiers de la racine
     $root = '';
     foreach (PagesCategoriesCache::load()->get_categories() as $key => $cat) {
         if ($cat['id_parent'] == 0) {
             //Autorisation particulière ?
             $special_auth = !empty($cat['auth']);
             //Vérification de l'autorisation d'éditer la page
             if ($special_auth && AppContext::get_current_user()->check_auth($cat['auth'], READ_PAGE) || !$special_auth && AppContext::get_current_user()->check_auth($config_authorizations, READ_PAGE)) {
                 $root .= '<li><a href="javascript:open_cat(' . $key . '); show_pages_cat_contents(' . $cat['id_parent'] . ', 0);"><i class="fa fa-folder"></i>' . stripslashes($cat['title']) . '</a></li>';
             }
         }
     }
     //Liste des fichiers de la racine
     $result = PersistenceContext::get_querier()->select("SELECT title, id, encoded_title, auth\r\n\t\t\tFROM " . PREFIX . "pages\r\n\t\t\tWHERE id_cat = 0 AND is_cat = 0\r\n\t\t\tORDER BY is_cat DESC, title ASC");
     while ($row = $result->fetch()) {
         //Autorisation particulière ?
         $special_auth = !empty($row['auth']);
         $array_auth = unserialize($row['auth']);
         //Vérification de l'autorisation d'éditer la page
         if ($special_auth && AppContext::get_current_user()->check_auth($array_auth, READ_PAGE) || !$special_auth && AppContext::get_current_user()->check_auth($config_authorizations, READ_PAGE)) {
             $root .= '<li><a href="' . PagesUrlBuilder::get_link_item($row['encoded_title']) . '"><i class="fa fa-file"></i>' . stripslashes($row['title']) . '</a></li>';
         }
     }
     $result->dispose();
     $tpl->put_all(array('TITLE' => $LANG['pages'], 'L_ROOT' => $LANG['pages_root'], 'ROOT_CONTENTS' => $root, 'L_CATS' => $LANG['pages_cats_tree'], 'L_EXPLORER' => $LANG['pages_explorer'], 'SELECTED_CAT' => 0, 'CAT_0' => 'selected', 'CAT_LIST' => ''));
     $contents = '';
     $result = PersistenceContext::get_querier()->select("SELECT c.id, p.title, p.encoded_title\r\n\t\tFROM " . PREFIX . "pages_cats c\r\n\t\tLEFT JOIN " . PREFIX . "pages p ON p.id = c.id_page\r\n\t\tWHERE c.id_parent = 0\r\n\t\tORDER BY p.title ASC");
     while ($row = $result->fetch()) {
         $sub_cats_number = PersistenceContext::get_querier()->count(PREFIX . "pages_cats", 'WHERE id_parent=:id_parent', array('id_parent' => $row['id']));
         if ($sub_cats_number > 0) {
             $tpl->assign_block_vars('list', array('DIRECTORY' => '<li class="sub"><a class="parent" href="javascript:show_pages_cat_contents(' . $row['id'] . ', 0);"><i class="fa fa-plus-square-o" id="img2_' . $row['id'] . '"></i><i class="fa fa-folder" id ="img_' . $row['id'] . '"></i></a><a id="class_' . $row['id'] . '" href="javascript:open_cat(' . $row['id'] . ');">' . stripslashes($row['title']) . '</a><span id="cat_' . $row['id'] . '"></li>'));
         } else {
             $tpl->assign_block_vars('list', array('DIRECTORY' => '<li class="sub"><a id="class_' . $row['id'] . '" href="javascript:open_cat(' . $row['id'] . ');"><i class="fa fa-folder"></i>' . stripslashes($row['title']) . '</a><span id="cat_' . $row['id'] . '"></span></li>'));
         }
     }
     $result->dispose();
     return $tpl;
 }
 private function create_module_map_sections($id_cat, $auth_mode)
 {
     global $LANG;
     $pages_config = PagesConfig::load();
     $categories_cache = PagesCategoriesCache::load();
     $categories = $categories_cache->get_categories();
     //Configuration des authorisations
     $config_authorizations = $pages_config->get_authorizations();
     $this_category = new SitemapLink($categories[$id_cat]['title'], new Url('/pages/' . url('pages.php?title=' . Url::encode_rewrite($categories[$id_cat]['title']), Url::encode_rewrite($categories[$id_cat]['title']))));
     $category = new SitemapSection($this_category);
     $i = 0;
     $keys = array_keys($categories);
     $num_cats = $categories_cache->get_number_categories();
     $properties = array();
     for ($j = 0; $j < $num_cats; $j++) {
         $id = $keys[$j];
         $properties = $categories[$id];
         if ($auth_mode == Sitemap::AUTH_PUBLIC) {
             $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $properties['auth'], READ_PAGE) : Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $config_authorizations, READ_PAGE);
         } elseif ($auth_mode == Sitemap::AUTH_USER) {
             if (AppContext::get_current_user()->get_level() == User::ADMIN_LEVEL) {
                 $this_auth = true;
             } else {
                 $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, AppContext::get_current_user()->get_level(), $properties['auth'], READ_PAGE) : Authorizations::check_auth(RANK_TYPE, AppContext::get_current_user()->get_level(), $config_authorizations, READ_PAGE);
             }
         }
         if ($this_auth && $id != 0 && $properties['id_parent'] == $id_cat) {
             $category->add($this->create_module_map_sections($id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $category = $this_category;
     }
     return $category;
 }
Ejemplo n.º 5
0
require_once '../kernel/begin.php';
AppContext::get_session()->no_session_location();
//Permet de ne pas mettre jour la page dans la session.
require_once '../pages/pages_begin.php';
require_once '../kernel/header_no_display.php';
$request = AppContext::get_request();
$id_cat = $request->get_postint('id_cat', 0);
$select_cat = $request->get_getint('select_cat', 0);
$selected_cat = $request->get_postint('selected_cat', 0);
$display_select_link = $request->get_getint('display_select_link', 0);
$open_cat = $request->get_postint('open_cat', 0);
$root = $request->get_getint('root', 0);
//Configuration des authorisations
$config_authorizations = $pages_config->get_authorizations();
$categories = PagesCategoriesCache::load()->get_categories();
//Listage des répertoires dont le répertoire parent est connu
if ($id_cat != 0) {
    echo '<ul>';
    //On sélectionne les répetoires dont l'id parent est connu
    $result = PersistenceContext::get_querier()->select("SELECT c.id, p.title, p.encoded_title, p.auth\n\tFROM " . PREFIX . "pages_cats c\n\tLEFT JOIN " . PREFIX . "pages p ON p.id = c.id_page\n\tWHERE c.id_parent = :id\n\tORDER BY title ASC", array('id' => $id_cat));
    while ($row = $result->fetch()) {
        //Autorisation particulière ?
        $special_auth = !empty($row['auth']);
        //Vérification de l'autorisation d'éditer la page
        if ($special_auth && AppContext::get_current_user()->check_auth($row['auth'], READ_PAGE) || !$special_auth && AppContext::get_current_user()->check_auth($config_authorizations, READ_PAGE)) {
            //On compte le nombre de catégories présentes pour savoir si on donne la possibilité de faire un sous dossier
            $sub_cats_number = PersistenceContext::get_querier()->count(PREFIX . "pages_cats", 'WHERE id_parent=:id_parent', array('id_parent' => $row['id']));
            //Si cette catégorie contient des sous catégories, on propose de voir son contenu
            if ($sub_cats_number > 0) {
                echo '<li class="sub"><a class="parent" href="javascript:show_pages_cat_contents(' . $row['id'] . ', ' . ($display_select_link != 0 ? 1 : 0) . ');"><i class="fa fa-plus-square-o" id="img2_' . $row['id'] . '"></i><i class="fa fa-folder" id="img_' . $row['id'] . '"></i></a><a id="class_' . $row['id'] . '" href="javascript:' . ($display_select_link != 0 ? 'select_cat' : 'open_cat') . '(' . $row['id'] . ');">' . stripslashes($row['title']) . '</a><span id="cat_' . $row['id'] . '"></span></li>';
Ejemplo n.º 6
0
            if (!AppContext::get_current_user()->check_auth($config_authorizations, EDIT_PAGE)) {
                AppContext::get_response()->redirect(HOST . DIR . url('/pages/pages.php?error=e_auth', '', '&'));
            }
            $encoded_title = Url::encode_rewrite($title);
            $is_already_page = PersistenceContext::get_querier()->count(PREFIX . "pages", 'WHERE encoded_title=:encoded_title', array('encoded_title' => $encoded_title));
            //Si l'article n'existe pas déjà, on enregistre
            if ($is_already_page == 0) {
                $result = PersistenceContext::get_querier()->insert(PREFIX . 'pages', array('title' => $title, 'encoded_title' => $encoded_title, 'contents' => pages_parse($contents), 'user_id' => AppContext::get_current_user()->get_id(), 'count_hits' => $count_hits, 'activ_com' => $enable_com, 'timestamp' => time(), 'auth' => $page_auth, 'is_cat' => $is_cat, 'id_cat' => $id_cat, 'display_print_link' => $display_print_link));
                //Si c'est une catégorie
                if ($is_cat > 0) {
                    $last_id_page = $result->get_last_inserted_id();
                    $result = PersistenceContext::get_querier()->insert(PREFIX . 'pages_cats', array('id_parent' => $id_cat, 'id_page' => $last_id_page));
                    $last_id_pages_cat = $result->get_last_inserted_id();
                    PersistenceContext::get_querier()->update(PREFIX . 'pages', array('id_cat' => $last_id_pages_cat), 'WHERE id = :id', array('id' => $last_id_page));
                    //Régénération du cache
                    PagesCategoriesCache::invalidate();
                }
                //On redirige vers la page mise à jour
                AppContext::get_response()->redirect('/pages/' . url('pages.php?title=' . $encoded_title, $encoded_title, '&'));
            } else {
                $error = 'page_already_exists';
            }
        }
    } else {
        $error = 'preview';
    }
} elseif ($del_article > 0) {
    //Vérification de la validité du jeton
    AppContext::get_session()->csrf_get_protect();
    try {
        $page_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'pages', array('id', 'title', 'encoded_title', 'contents', 'auth', 'count_hits', 'activ_com', 'id_cat', 'is_cat', 'display_print_link'), 'WHERE id = :id', array('id' => $del_article));
Ejemplo n.º 7
0
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*
 ###################################################*/
require_once '../kernel/begin.php';
$encoded_title = retrieve(GET, 'title', '');
$id_com = retrieve(GET, 'id', 0);
include_once 'pages_begin.php';
include_once 'pages_functions.php';
//Configuration des authorisations
$config_authorizations = $pages_config->get_authorizations();
$categories_cache = PagesCategoriesCache::load();
$db_querier = PersistenceContext::get_querier();
//Requêtes préliminaires utiles par la suite
if (!empty($encoded_title)) {
    try {
        $page_infos = $db_querier->select_single_row(PREFIX . 'pages', array('id', 'title', 'auth', 'is_cat', 'id_cat', 'hits', 'count_hits', 'activ_com', 'redirect', 'contents', 'display_print_link'), 'WHERE encoded_title = :encoded_title', array('encoded_title' => $encoded_title));
    } catch (RowNotFoundException $e) {
        $error_controller = PHPBoostErrors::unexisting_page();
        DispatchManager::redirect($error_controller);
    }
    $num_rows = !empty($page_infos['title']) ? 1 : 0;
    if ($page_infos['redirect'] > 0) {
        $redirect_title = stripslashes($page_infos['title']);
        $redirect_id = $page_infos['id'];
        try {
            $page_infos = $db_querier->select_single_row(PREFIX . 'pages', array('id', 'title', 'auth', 'is_cat', 'id_cat', 'hits', 'count_hits', 'activ_com', 'redirect', 'contents', 'display_print_link'), 'WHERE id = :id', array('id' => $page_infos['redirect']));
Ejemplo n.º 8
0
function pages_find_subcats(&$array, $id_cat)
{
    //On parcourt les catégories et on détermine les catégories filles
    foreach (PagesCategoriesCache::load()->get_categories() as $key => $cat) {
        if ($value['id_parent'] == $id_cat) {
            $array[] = $key;
            //On rappelle la fonction pour la catégorie fille
            pages_find_subcats($array, $key);
        }
    }
}
Ejemplo n.º 9
0
 *
 ###################################################*/
require_once '../kernel/begin.php';
require_once '../pages/pages_begin.php';
define('TITLE', $LANG['pages_explorer']);
$cat = retrieve(GET, 'cat', 0);
$Bread_crumb->add($LANG['pages'], url('pages.php'));
$Bread_crumb->add($LANG['pages_explorer'], url('explorer.php'));
require_once '../kernel/header.php';
//Configuration des authorisations
$config_authorizations = $pages_config->get_authorizations();
$tpl = new FileTemplate('pages/explorer.tpl');
$module_data_path = $tpl->get_pictures_data_path();
//Liste des dossiers de la racine
$root = '';
foreach (PagesCategoriesCache::load()->get_categories() as $key => $cat) {
    if ($cat['id_parent'] == 0) {
        //Autorisation particulière ?
        $special_auth = !empty($cat['auth']);
        //Vérification de l'autorisation d'éditer la page
        if ($special_auth && AppContext::get_current_user()->check_auth($cat['auth'], READ_PAGE) || !$special_auth && AppContext::get_current_user()->check_auth($config_authorizations, READ_PAGE)) {
            $root .= '<li><a href="javascript:open_cat(' . $key . '); show_pages_cat_contents(' . $cat['id_parent'] . ', 0);"><i class="fa fa-folder"></i>' . stripslashes($cat['title']) . '</a></li>';
        }
    }
}
//Liste des fichiers de la racine
$result = PersistenceContext::get_querier()->select("SELECT title, id, encoded_title, auth\n\tFROM " . PREFIX . "pages\n\tWHERE id_cat = 0 AND is_cat = 0\n\tORDER BY is_cat DESC, title ASC");
while ($row = $result->fetch()) {
    //Autorisation particulière ?
    $special_auth = !empty($row['auth']);
    $array_auth = unserialize($row['auth']);