Vous n'avez pas le niveau requis -> module cours [Réglé]
Visiteur
Boosteur Inactif
J'ai développé, sur la base du module articles, un module dont le nom est cours.
Mais je rencontre un problème : les visiteurs n'y ont pas accès. Pourtant, du côté admin, l'accès visiteur est validé pour ce module.
Je ne vois pas d'où ça peut venir.
Voici ma page en question :
cours.php
Code PHP :
<?php /*################################################## * cours.php * ------------------- * begin : January 31 09 * copyright : (C) 2009 Age * email : age.topjeupc@laposte.net * * ################################################### * * This program 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 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * 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'); require_once('../cours/cours_begin.php'); require_once('../kernel/header.php'); $page = retrieve(GET, 'p', 1, TUNSIGNED_INT); $cat = retrieve(GET, 'cat', 0); if (!empty($idart) && isset($_GET['cat']) ) { //Niveau d'autorisation de la catégorie if (!isset($CAT_COURS[$idartcat]) || !$User->check_auth($CAT_COURS[$idartcat]['auth'], READ_CAT_COURS) || $CAT_COURS[$idartcat]['aprob'] == 0) $Errorh->handler('e_auth', E_USER_REDIRECT); if (empty($cours['id'])) $Errorh->handler('e_unexist_cours', E_USER_REDIRECT); $Template->set_filenames(array('cours'=> 'cours/cours.tpl')); //MAJ du compteur. $Sql->query_inject("UPDATE " . LOW_PRIORITY . " " . PREFIX . "cours SET views = views + 1 WHERE id = " . $idart, __LINE__, __FILE__); if ($User->check_level(ADMIN_LEVEL)) { $java = '<script type="text/javascript"> <!-- function Confirm_del_cours() { return confirm("' . $LANG['alert_delete_cours'] . '"); } --> </script>'; $edit = ' <a href="../cours/admin_cours' . url('.php?id=' . $cours['id']) . '" title="' . $LANG['edit'] . '"><img src="../templates/' . get_utheme() . '/images/' . get_ulang() . '/edit.png" class="valign_middle" alt="' . $LANG['edit'] . '" /></a>'; $del = ' <a href="../cours/admin_cours.php?delete=1&id=' . $cours['id'] . '" title="' . $LANG['delete'] . '" onclick="javascript:return Confirm_del_cours();"><img src="../templates/' . get_utheme() . '/images/' . get_ulang() . '/delete.png" class="valign_middle" alt="' . $LANG['delete'] . '" /></a>'; $Template->assign_vars(array( 'JAVA' => $java, 'EDIT' => $edit, 'DEL' => $del )); } //On crée une pagination si il y plus d'une page. include_once('../kernel/framework/util/pagination.class.php'); $Pagination = new Pagination(); //Si l'cours ne commence pas par une page on l'ajoute. if (substr(trim($cours['contents']), 0, 6) != '[page]') $cours['contents'] = ' [page] [/page]' . $cours['contents']; else $cours['contents'] = ' ' . $cours['contents']; //Pagination des cours. $array_contents = preg_split('`[page][^[]+[/page](.*)`Us', $cours['contents'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); //Récupération de la liste des pages. preg_match_all('`[page]([^[]+)[/page]`U', $cours['contents'], $array_page); $page_list = '<option value="1">' . $LANG['select_page'] . '</option>'; $page_list .= '<option value="1"></option>'; $i = 1; foreach ($array_page[1] as $page_name) { if ($page_name != ' ') { $selected = ($i == $page) ? 'selected="selected"' : ''; $page_list .= '<option value="' . $i++ . '"' . $selected . '>' . $page_name . '</option>'; } } //Nombre de pages $nbr_page = count($array_page[1]); $nbr_page = !empty($nbr_page) ? $nbr_page : 1; // Gestion de la difficulté du cours $req_stars = $Sql->query_while("SELECT id, difficult, views FROM ".PREFIX."cours WHERE id='".$_GET['id']."'", __LINE__, __FILE__); while( $row_stars = $Sql->fetch_assoc($req_stars) ) { $stars_yellow = $row_stars['difficult']; } $stars_gris = 5 - $stars_yellow; $listestars = ''; // Génération de la liste des étoiles if( $stars_yellow > 0 ) { // Etoiles jaunes for( $i = 1 ; $i <= $stars_yellow ; $i++ ) { $listestars .= "<img src="../cours/images/stars.png" alt="star" />"; } //Etoiles grises for( $i = 1 ; $i <= $stars_gris ; $i++ ) { $listestars .= '<img src="../cours/images/stars0.png" alt="star" />'; } } else { for( $i = 1 ; $i > $stars_gris ; $i++ ) { $listestars .= '<img src="../cours/images/stars0.png" alt="star" />'; } } //Affichage notation include_once('../kernel/framework/content/note.class.php'); $Note = new Note('cours', $idart, url('cours.php?cat=' . $idartcat . '&id=' . $idart, 'cours-' . $idartcat . '-' . $idart . '.php'), $CONFIG_COURS['note_max'], '', NOTE_DISPLAY_NOTE); $Template->assign_vars(array( 'C_DISPLAY_COURS' => true, 'IDART' => $cours['id'], 'LUNBFOIS' => $cours['views'] + 1, 'IDCAT' => $idartcat, 'NAME' => $cours['title'], 'PSEUDO' => $Sql->query("SELECT login FROM " . DB_TABLE_MEMBER . " WHERE user_id = '" . $cours['user_id'] . "'", __LINE__, __FILE__), 'CONTENTS' => isset($array_contents[$page]) ? second_parse($array_contents[$page]) : '', 'CAT' => $CAT_COURS[$idartcat]['name'], 'DATE' => gmdate_format('date_format_short', $cours['timestamp']), 'PAGES_LIST' => $page_list, 'PAGINATION_COURS' => $Pagination->display('cours' . url('.php?cat=' . $idartcat . '&id='. $idart . '&p=%d', '-' . $idartcat . '-'. $idart . '-%d+' . url_encode_rewrite($cours['title']) . '.php'), $nbr_page, 'p', 1, 3, 11, NO_PREVIOUS_NEXT_LINKS), 'PAGE_NAME' => (isset($array_page[1][($page-1)]) && $array_page[1][($page-1)] != ' ') ? $array_page[1][($page-1)] : '', 'PAGE_PREVIOUS_COURS' => ($page > 1 && $page <= $nbr_page && $nbr_page > 1) ? '<a href="' . url('cours.php?cat=' . $idartcat . '&id=' . $idart . '&p=' . ($page - 1), 'cours-' . $idartcat . '-' . $idart . '-' . ($page - 1) . '+' . url_encode_rewrite($cours['title']) . '.php') . '">« ' . $LANG['previous_page'] . '</a> ' . $array_page[1][($page-2)] : '', 'PAGE_NEXT_COURS' => ($page > 0 && $page < $nbr_page && $nbr_page > 1) ? '<a href="' . url('cours.php?cat=' . $idartcat . '&id=' . $idart . '&p=' . ($page + 1), 'cours-' . $idartcat . '-' . $idart . '-' . ($page + 1) . '+' . url_encode_rewrite($cours['title']) . '.php') . '">' . $LANG['next_page'] . ' »</a> ' . $array_page[1][$page] : '', 'COM' => com_display_link($cours['nbr_com'], '../cours/cours' . url('.php?cat=' . $idartcat . '&id=' . $idart . '&com=0', '-' . $idartcat . '-' . $idart . '+' . url_encode_rewrite($cours['title']) . '.php?com=0'), $cours['id'], 'cours'), 'KERNEL_NOTATION' => $Note->display_form(), 'U_USER_ID' => url('.php?id=' . $cours['user_id'], '-' . $cours['user_id'] . '.php'), 'U_ONCHANGE_COURS' => "'" . url('cours.php?cat=' . $idartcat . '&id=' . $idart . '&p=' + this.options[this.selectedIndex].value', 'cours-' . $idartcat . '-' . $idart . '-'+ this.options[this.selectedIndex].value + '+' . url_encode_rewrite($cours['title']) . '.php' . "'"), 'L_SUMMARY' => $LANG['summary'], 'L_SUBMIT' => $LANG['submit'], 'L_WRITTEN' => $LANG['written_by'], 'L_ON' => $LANG['on'], 'L_PRINTABLE_VERSION' => $LANG['printable_version'], 'U_PRINT_COURS' => url('print.php?id=' . $idart), 'DIFFICULT' => $LANG['difficult'], 'READ_NB' => $LANG['read_nb'], 'FOIS' => $LANG['fois'], 'LISTESTARS' => $listestars )); //Affichage commentaires. if (isset($_GET['com'])) { $Template->assign_vars(array( 'COMMENTS' => display_comments('cours', $idart, url('cours.php?cat=' . $idartcat . '&id=' . $idart . '&com=%s', 'cours-' . $idartcat . '-' . $idart . '.php?com=%s')) )); } $Template->pparse('cours'); } else { $Template->set_filenames(array( 'cours_cat'=> 'cours/cours_cat.tpl' )); if ($idartcat > 0) { if (!isset($CAT_COURS[$idartcat]) || $CAT_COURS[$idartcat]['aprob'] == 0) $Errorh->handler('e_auth', E_USER_REDIRECT); $cat_links = ''; foreach ($CAT_COURS as $id => $array_info_cat) { if ($CAT_COURS[$idartcat]['id_left'] >= $array_info_cat['id_left'] && $CAT_COURS[$idartcat]['id_right'] <= $array_info_cat['id_right'] && $array_info_cat['level'] <= $CAT_COURS[$idartcat]['level']) $cat_links .= ' <a href="cours' . url('.php?cat=' . $id, '-' . $id . '.php') . '">' . $array_info_cat['name'] . '</a> »'; } $clause_cat = " WHERE ac.id_left > '" . $CAT_COURS[$idartcat]['id_left'] . "' AND ac.id_right < '" . $CAT_COURS[$idartcat]['id_right'] . "' AND ac.level = '" . ($CAT_COURS[$idartcat]['level'] + 1) . "' AND ac.aprob = 1"; } else //Racine. { $cat_links = ''; $clause_cat = " WHERE ac.level = '0' AND ac.aprob = 1"; } //Niveau d'autorisation de la catégorie if (!$User->check_auth($CAT_COURS[$idartcat]['auth'], READ_CAT_COURS)) $Errorh->handler('e_auth', E_USER_REDIRECT); $nbr_cours = $Sql->query("SELECT COUNT(*) FROM " . PREFIX . "cours WHERE visible = 1 AND idcat = '" . $idartcat . "'", __LINE__, __FILE__); $total_cat = $Sql->query("SELECT COUNT(*) FROM " . PREFIX . "cours_cats ac " . $clause_cat, __LINE__, __FILE__); $rewrite_title = url_encode_rewrite($CAT_COURS[$idartcat]['name']); //Colonnes des catégories. $nbr_column_cats = ($total_cat > $CONFIG_COURS['nbr_column']) ? $CONFIG_COURS['nbr_column'] : $total_cat; $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1; $column_width_cats = floor(100/$nbr_column_cats); $is_admin = $User->check_level(ADMIN_LEVEL) ? true : false; $Template->assign_vars(array( 'COLUMN_WIDTH_CAT' => $column_width_cats, 'ADD_COURS' => $is_admin ? (!empty($idartcat) ? '» ' : '') . '<a href="admin_cours_add.php"><img src="../templates/' . get_utheme() . '/images/' . get_ulang() . '/add.png" alt="" class="valign_middle" /></a>' : '', 'L_COURS' => $LANG['cours'], 'L_DIFFI' => $LANG['difficult'], 'L_VIEW' => $LANG['views'], 'L_NOTE' => $LANG['note'], 'L_COM' => $LANG['com'], 'L_TOTAL_COURS' => ($nbr_cours > 0) ? sprintf($LANG['nbr_cours_info'], $nbr_cours) : '', 'L_NO_COURS' => ($nbr_cours == 0) ? $LANG['none_cours'] : '', 'L_COURS_INDEX' => $LANG['title_cours'], 'L_CATEGORIES' => ($CAT_COURS[$idartcat]['level'] >= 0) ? $LANG['sub_categories'] : $LANG['categories'], 'U_COURS_CAT_LINKS' => trim($cat_links, ' »'), 'U_COURS_ALPHA_TOP' => url('.php?sort=alpha&mode=desc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=alpha&mode=desc'), 'U_COURS_ALPHA_BOTTOM' => url('.php?sort=alpha&mode=asc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=alpha&mode=asc'), 'U_COURS_DATE_TOP' => url('.php?sort=date&mode=desc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=date&mode=desc'), 'U_COURS_DATE_BOTTOM' => url('.php?sort=date&mode=asc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=date&mode=asc'), 'U_COURS_VIEW_TOP' => url('.php?sort=view&mode=desc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=view&mode=desc'), 'U_COURS_VIEW_BOTTOM' => url('.php?sort=view&mode=asc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=view&mode=asc'), 'U_COURS_NOTE_TOP' => url('.php?sort=note&mode=desc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=note&mode=desc'), 'U_COURS_NOTE_BOTTOM' => url('.php?sort=note&mode=asc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=note&mode=asc'), 'U_COURS_COM_TOP' => url('.php?sort=com&mode=desc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=com&mode=desc'), 'U_COURS_COM_BOTTOM' => url('.php?sort=com&mode=asc&cat=' . $idartcat, '-' . $idartcat . '+' . $rewrite_title . '.php?sort=com&mode=asc') )); $get_sort = retrieve(GET, 'sort', ''); switch ($get_sort) { case 'alpha' : $sort = 'title'; break; case 'date' : $sort = 'timestamp'; break; case 'view' : $sort = 'views'; break; case 'note' : $sort = 'note/' . $CONFIG_COURS['note_max']; break; case 'com' : $sort = 'nbr_com'; break; default : $sort = 'id'; } $get_mode = retrieve(GET, 'mode', ''); $mode = ($get_mode == 'asc') ? 'ASC' : 'DESC'; $unget = (!empty($get_sort) && !empty($mode)) ? '?sort=' . $get_sort . '&mode=' . $get_mode : ''; //On crée une pagination si le nombre de fichiers est trop important. include_once('../kernel/framework/util/pagination.class.php'); $Pagination = new Pagination(); //Catégories non autorisées. $unauth_cats_sql = array(); foreach ($CAT_COURS as $id => $key) { if (!$User->check_auth($CAT_COURS[$id]['auth'], READ_CAT_COURS)) $unauth_cats_sql[] = $id; } $nbr_unauth_cats = count($unauth_cats_sql); $clause_unauth_cats = ($nbr_unauth_cats > 0) ? " AND ac.id NOT IN (" . implode(', ', $unauth_cats_sql) . ")" : ''; ##### Catégories disponibles ##### if ($total_cat > 0) { $Template->assign_vars(array( 'C_COURS_CAT' => true, 'PAGINATION_CAT' => $Pagination->display('cours' . url('.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $idartcat . '&pcat=%d', '-' . $idartcat . '-0+' . $rewrite_title . '.php?pcat=%d' . $unget), $total_cat , 'pcat', $CONFIG_COURS['nbr_cat_max'], 3), 'EDIT_CAT' => $is_admin ? '<a href="admin_cours_cat.php"><img class="valign_middle" src="../templates/' . get_utheme() . '/images/' . get_ulang() . '/edit.png" alt="" /></a>' : '' )); $max_cat = $Sql->query("SELECT MAX(id_left) FROM " . PREFIX . "cours_cats", __LINE__, __FILE__); $list_cats_js = ''; $array_js = ''; $i = 0; $result = $Sql->query_while("SELECT id, id_left, id_right, level, name, contents, icon FROM " . PREFIX . "cours_cats ORDER BY id_left", __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { //On assigne les variables pour le POST en précisant l'idurl. $Template->assign_block_vars('list', array( 'I' => $i, 'ID' => $row['id'], 'NAME' => $row['name'], 'DESC' => $row['contents'], 'INDENT' => ($row['level'] + 1) * 40, //Indentation des sous catégories. 'ICON' => $row['icon'], 'U_COURS_VARS' => url('.php?cat=' . $row['id'], '-' . $row['id'] . '+' . url_encode_rewrite($row['name']) . '.php') )); $list_cats_js .= $row['id'] . ', '; $array_js .= 'array_cats[' . $row['id'] . '] = new Array();' . "n"; $array_js .= 'array_cats[' . $row['id'] . ']['id'] = ' . $row['id'] . ";n"; $array_js .= 'array_cats[' . $row['id'] . ']['id_left'] = ' . $row['id_left'] . ";n"; $array_js .= 'array_cats[' . $row['id'] . ']['id_right'] = ' . $row['id_right'] . ";n"; $array_js .= 'array_cats[' . $row['id'] . ']['i'] = ' . $i . ";n"; $i++; } $Sql->query_close($result); $Template->assign_vars(array( 'LIST_CATS' => trim($list_cats_js, ', '), 'ARRAY_JS' => $array_js, 'L_ROOT' => $LANG['root'], 'ID_END' => ($i - 1) )); } ##### Affichage des cours ##### if ($nbr_cours > 0) { $Template->assign_vars(array( 'C_COURS_LINK' => true, 'PAGINATION' => $Pagination->display('cours' . url('.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $idartcat . '&p=%d', '-' . $idartcat . '-0-%d+' . $rewrite_title . '.php' . $unget), $nbr_cours , 'p', $CONFIG_COURS['nbr_cours_max'], 3), 'CAT' => $CAT_COURS[$idartcat]['name'], 'EDIT' => ($is_admin && !empty($idartcat)) ? '<a href="admin_cours_cat.php?id=' . $idartcat . '"><img class="valign_middle" src="../templates/' . get_utheme() . '/images/' . get_ulang() . '/edit.png" alt="" /></a>' : '' )); include_once('../kernel/framework/content/note.class.php'); $Note = new Note(null, null, null, null, '', NOTE_NO_CONSTRUCT); $result = $Sql->query_while("SELECT id, title, icon, timestamp, views, note, nbrnote, nbr_com, difficult FROM " . PREFIX . "cours WHERE visible = 1 AND idcat = '" . $idartcat . "' ORDER BY title ASC" . $Sql->limit($Pagination->get_first_msg($CONFIG_COURS['nbr_cours_max'], 'p'), $CONFIG_COURS['nbr_cours_max']), __LINE__, __FILE__); while ($row = $Sql->fetch_assoc($result)) { $stars_yellow = $row['difficult']; $stars_gris = 5 - $stars_yellow; $listestars = ''; // Génération de la liste des étoiles if( $row['difficult'] > 0 ) { // Etoiles jaunes for( $i = 1 ; $i <= $stars_yellow ; $i++ ) { $listestars .= '<img src="../cours/images/stars.png" alt="star" />'; } //Etoiles grises for( $i = 1 ; $i <= $stars_gris ; $i++ ) { $listestars .= '<img src="../cours/images/stars0.png" alt="star" />'; } } elseif($row['difficult'] <= 0 or empty($row['difficult'])) { for( $i = 1 ; $i > $stars_gris ; $i++ ) { $listestars .= '<img src="../cours/images/stars0.png" alt="star" />'; } } else { for( $i = 1 ; $i > $stars_gris ; $i++ ) { $listestars .= '<img src="../cours/images/stars0.png" alt="star" />'; } } // On génère la liste des note $stars_yellow = $row['note']; $stars_gris = $CONFIG_COURS['note_max'] - $stars_yellow; $listenote = ''; if($row['nbrnote'] > 0) { // Etoiles jaunes for( $i = 1 ; $i <= $stars_yellow ; $i++ ) { $listenote .= '<img src="../cours/images/stars.png" alt="star" />'; } //Etoiles grises for( $i = 1 ; $i <= $stars_gris ; $i++ ) { $listenote .= '<img src="../cours/images/stars0.png" alt="star" />'; } } else { $listenote = '<em>'.$LANG['no_note'].'</em>'; } //On reccourci le lien si il est trop long. $fichier = (strlen($row['title']) > 45 ) ? substr(html_entity_decode($row['title']), 0, 45) . '...' : $row['title']; $Template->assign_block_vars('cours', array( 'NAME' => $fichier, 'ICON' => !empty($row['icon']) ? '<a href="cours' . url('.php?id=' . $row['id'] . '&cat=' . $idartcat, '-' . $idartcat . '-' . $row['id'] . '+' . url_encode_rewrite($fichier) . '.php') . '"><img src="' . $row['icon'] . '" alt="" class="valign_middle" /></a>' : '', 'CAT' => $CAT_COURS[$idartcat]['name'], 'DIFFUCULTE' =>$listestars, 'COMPT' => $row['views'], 'NOTE' => $listenote, 'COM' => $row['nbr_com'], 'U_COURS_LINK' => url('.php?id=' . $row['id'] . '&cat=' . $idartcat, '-' . $idartcat . '-' . $row['id'] . '+' . url_encode_rewrite($fichier) . '.php') )); } $Sql->query_close($result); } $Template->pparse('cours_cat'); } require_once('../kernel/footer.php'); ?>
Merci d'avance à ceux qui pourront me sortir de ce pétrin.
ben.popeye Membre non connecté
-
Modérateur
- Voir le profil du membre ben.popeye
- Inscrit le : 04/08/2005
- Site internet
- Groupes :
-
Equipe Historique
La solution, c'est de mettre
exit;dans ton code en partant des premières lignes et en descendant dans ton code, tu essaies à chaque fois et tu le descends tant que tu n'es pas redirigé Tu pourrais ainsi identifier quelle ligne te jette l'erreur.
Un problème, une question ? Cherchez dans la FAQ ou la documentation. Si vous ne trouvez pas la réponse, demandez du support sur le forum.
Bjarne Stroustrup, inventeur du C++ :"There are two ways to write error-free programs; only the third works."
Visiteur
Boosteur Inactif
Merci cquand même ^^
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie