| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
|---|
| 4 | |
|---|
| 5 | global $template, $conf, $user; |
|---|
| 6 | |
|---|
| 7 | load_language('plugin.lang.php', AP_PATH); |
|---|
| 8 | |
|---|
| 9 | $ap_id = explode('additional_page/' , $_SERVER['REQUEST_URI']); |
|---|
| 10 | $ap_id = explode('&' , $ap_id[1]); |
|---|
| 11 | $ap_conf = explode ("," , $conf['additional_pages']); |
|---|
| 12 | |
|---|
| 13 | // R�cup�ration des donn�es de la page |
|---|
| 14 | $q = 'SELECT title , pos , text |
|---|
| 15 | FROM ' . ADD_PAGES_TABLE . ' |
|---|
| 16 | WHERE id = ' . $ap_id[0] . ';'; |
|---|
| 17 | $result = mysql_fetch_assoc(pwg_query($q)); |
|---|
| 18 | |
|---|
| 19 | if (empty($result)) |
|---|
| 20 | { |
|---|
| 21 | page_not_found('This page does not exist', 'index.php?'); |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | // Utilisateurs autoris�s |
|---|
| 25 | if (strpos($result['title'] , 'user_id=')) |
|---|
| 26 | { |
|---|
| 27 | $array = explode('/user_id=' , $result['title']); |
|---|
| 28 | $result['title'] = $array[0]; |
|---|
| 29 | $authorized_users = explode(',', $array[1]); |
|---|
| 30 | if (!is_admin() and $ap_conf[7] == 'on' and !in_array($user['status'], $authorized_users)) |
|---|
| 31 | { |
|---|
| 32 | page_not_found('User not allowed', 'index.php?'); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | // Groupe autoris� |
|---|
| 37 | if (strpos($result['title'] , 'group_id=')) |
|---|
| 38 | { |
|---|
| 39 | $array = explode('/group_id=' , $result['title']); |
|---|
| 40 | $result['title'] = $array[0]; |
|---|
| 41 | $authorized_groups = $array[1]; |
|---|
| 42 | |
|---|
| 43 | $q = 'SELECT * |
|---|
| 44 | FROM ' . USER_GROUP_TABLE . ' |
|---|
| 45 | WHERE user_id = ' . $user['id'] . ' AND group_id IN (' . $authorized_groups . ');'; |
|---|
| 46 | $array = mysql_fetch_array(pwg_query($q)); |
|---|
| 47 | if (!is_admin() and $ap_conf[6] == 'on' and empty($array)) |
|---|
| 48 | { |
|---|
| 49 | page_not_found('User not allowed', 'index.php?'); |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | // Envoi de la page |
|---|
| 54 | // Extended description |
|---|
| 55 | if (function_exists('get_extended_desc')) |
|---|
| 56 | add_event_handler('AP_render_content', 'get_extended_desc'); |
|---|
| 57 | |
|---|
| 58 | $template->assign(array( |
|---|
| 59 | 'TITLE' => trigger_event('AP_render_content', $result['title']), |
|---|
| 60 | 'PLUGIN_INDEX_CONTENT_BEGIN' => trigger_event('AP_render_content', $result['text']))); |
|---|
| 61 | if (isset($ap_conf[2]) and $ap_conf[2] == 'on') |
|---|
| 62 | { |
|---|
| 63 | $template->assign('PLUGIN_INDEX_ACTIONS' , ' |
|---|
| 64 | <li><a href="' . make_index_url() . '" title="' . l10n('return to homepage') . '"> |
|---|
| 65 | <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a> |
|---|
| 66 | </li>'); |
|---|
| 67 | } |
|---|
| 68 | if (is_admin()) |
|---|
| 69 | { |
|---|
| 70 | $template->assign('U_EDIT', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . AP_DIR . '%2Fadmin%2Fadd_page.php&edit=' . $ap_id[0]); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | $template->clear_assign(array('U_MODE_POSTED', 'U_MODE_CREATED')); |
|---|
| 74 | |
|---|
| 75 | ?> |
|---|