function theme_body($p_page_data) { if (false === $p_page_data) { # @@@ Handle not indexed (and auto index off) return; } global $g_note_add_page, $s_add_note_link, $s_manage, $s_admin, $g_web_directory, $g_theme; $t_notes = $p_page_data['notes']; $t_page = $p_page_data['page']; $t_page_id = $p_page_data['id']; $t_images_base = $g_web_directory . 'themes/' . $g_theme . '/images/'; $add_picture = $t_images_base . 'notes_add.gif'; $help_picture = $t_images_base . 'notes_about.gif'; $prev_picture = $t_images_base . 'caret_left.gif'; $next_picture = $t_images_base . 'caret_right.gif'; if (false === $p_page_data['preview']) { $t_link_start = "<a href=\"{$g_note_add_page}?f_page_id={$t_page_id}\">"; $t_link_end = '</a>'; } else { $t_link_start = $t_link_end = ''; } # # HEADER # echo <<<EOT \t\t<div class="phpnet"> \t\t<table summary="" cellpadding="4" cellspacing="0"> \t\t\t<tr class="dark"> \t\t\t\t<td><small>User Contributed Notes</small><br /><strong>{$t_page}</strong></td> \t\t\t\t<td align="right"> \t\t\t\t\t{$t_link_start}<img src="{$add_picture}" width="13" height="13" alt="Add Notes" />{$t_link_end} \t\t\t\t\t<img src="{$help_picture}" width="13" height="13" alt="About Notes" /> \t\t\t\t</td> \t\t\t</tr> EOT; # # NOTES # if (0 === count($t_notes)) { echo <<<EOT \t\t\t<tr class="light"> \t\t\t\t<td colspan="2">There are no user contributed notes for this page.</td> \t\t\t</tr> EOT; } else { for ($i = 0; $i < count($t_notes); $i++) { $t_moderation = ''; $t_note_info = $t_notes[$i]; if (false === $p_page_data['preview']) { if (access_check_action(ACTION_NOTES_MODERATE)) { $t_url = $p_page_data['url']; $t_moderation = ''; if ($t_note_info['visible'] != NOTE_VISIBLE_ACCEPTED) { $t_moderation .= link_note_action($t_note_info['id'], 'accept', $t_url, access_check_action(ACTION_NOTES_MODERATE_ACCEPT)) . ' '; } if ($t_note_info['visible'] != NOTE_VISIBLE_PENDING) { $t_moderation .= link_note_action($t_note_info['id'], 'queue', $t_url, access_check_action(ACTION_NOTES_MODERATE_QUEUE)) . ' '; } if ($t_note_info['visible'] != NOTE_VISIBLE_DECLINED) { $t_moderation .= link_note_action($t_note_info['id'], 'decline', $t_url, access_check_action(ACTION_NOTES_MODERATE_DECLINE)) . ' '; } if ($t_note_info['visible'] != NOTE_VISIBLE_ARCHIVED) { $t_moderation .= link_note_action($t_note_info['id'], 'archive', $t_url, access_check_action(ACTION_NOTES_MODERATE_ARCHIVE)) . ' '; } $t_moderation .= link_note_action($t_note_info['id'], 'edit', $t_url, access_check_action(ACTION_NOTES_EDIT)); if ($t_note_info['visible'] != NOTE_VISIBLE_DELETED) { $t_moderation .= link_note_action($t_note_info['id'], 'delete', $t_url, access_check_action(ACTION_NOTES_MODERATE_DELETE)); } } } if (isset($t_note_info['id']) && $t_note_info['id'] != 0) { $t_id = (int) $t_note_info['id']; $t_visibility = ''; if (NOTE_VISIBLE_ACCEPTED != $t_note_info['visible']) { $t_visibility = '(' . note_get_visibility_str($t_note_info['visible']) . ') - '; } $t_id_view = "<tt>{$t_visibility}#{$t_id}<br />{$t_moderation}</tt>"; $t_id_bookmark = "<a name=\"{$t_id}\"></a>"; } else { $t_id_view = ' '; $t_id_bookmark = ''; } if (isset($t_note_info['email'])) { $t_email = $t_note_info['email']; } else { $t_email = ''; } if (isset($t_note_info['date'])) { # 06-Feb-2002 02:28 $t_date = date('d-M-Y G:i', $t_note_info['date']); } else { $t_date = ''; } if (isset($t_note_info['note'])) { $t_note = nl2br('<tt>' . $t_note_info['note'] . '</tt>'); } else { $t_note = ' '; } echo <<<EOT \t\t\t\t<tr class="light"> \t\t\t\t\t<td colspan="2"> \t\t\t\t\t\t{$t_id_bookmark} \t\t\t\t\t\t<table summary="" cellpadding="2" cellspacing="0"> \t\t\t\t\t\t\t<tr class="light"> \t\t\t\t\t\t\t\t<td><strong>{$t_email}</strong><br />{$t_date}</td> \t\t\t\t\t\t\t\t<td align="right">{$t_id_view}</td> \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t<tr class="lighter"> \t\t\t\t\t\t\t\t<td colspan="2">{$t_note}</td> \t\t\t\t\t\t\t</tr> \t\t\t\t\t\t</table> \t\t\t\t\t</td> \t\t\t\t</tr> EOT; } } # # FOOTER # if (empty($p_page_data['prev_page'])) { $t_prev_text = ''; } else { $t_prev_text = "<img src=\"{$prev_picture}\" width=\"11\" height=\"7\" alt=\"" . $p_page_data['prev_page'] . "\" />" . link_create($p_page_data['prev_url'], $p_page_data['prev_page'], true, '', ''); } if (empty($p_page_data['next_page'])) { $t_next_text = ''; } else { $t_next_text = link_create($p_page_data['next_url'], $p_page_data['next_page'], true, '', '') . "<img src=\"{$next_picture}\" width=\"11\" height=\"7\" alt=\"" . $p_page_data['next_page'] . "\" />"; } if (empty($t_prev_text) && empty($t_next_text)) { $t_navigation_row = ''; } else { $t_navigation_row = "<tr><td>{$t_prev_text}</td><td align=\"right\">{$t_next_text}</td></tr>"; } if (false === $p_page_data['preview']) { $t_link_start = "<a href=\"{$g_note_add_page}?f_page_id={$t_page_id}\">"; $t_link_end = '</a>'; } else { $t_link_start = $t_link_end = ''; } if (0 !== count($t_notes)) { echo <<<EOT \t\t\t<tr class="dark"> \t\t\t\t<td colspan="2" align="right"> \t\t\t\t{$t_link_start}<img src="{$add_picture}" width="13" height="13" alt="Add Notes" />{$t_link_end} \t\t\t\t<img src="{$help_picture}" width="13" height="13" alt="About Notes" /> \t\t\t\t</td> \t\t\t</tr> EOT; } if (false === $p_page_data['preview']) { # Tue, 17 Sep 2002 $t_last_updated = date('D, d M Y - G:i:s', $p_page_data['last_updated']); echo <<<EOT \t\t\t<tr class="dark"><td colspan="2"> \t\t\t\t<table class="light" cellpadding="0" cellspacing="4"> \t\t\t\t\t{$t_navigation_row} \t\t\t\t\t<tr><td align="right" colspan="2"><small>Last updated: {$t_last_updated}</small></td></tr> \t\t\t\t</table> \t\t\t</td></tr> EOT; } echo '</table></div>'; if (false === $p_page_data['preview'] && access_is_logged_in()) { echo '<div class="pwn">'; print_admin_menu(); echo '</div>'; } }
function access_ensure_check_action($p_action, $p_url = null) { if (access_check_action($p_action)) { return; } access_denied($p_url); }
function print_admin_menu($p_add_space = true) { global $g_logout, $g_admin_index_files, $g_admin_change_password, $g_admin_manage_notes, $g_admin_manage_users, $s_logout_link, $s_index_files, $s_change_password, $s_manage_notes, $s_manage_users, $g_user_home_page; $queue_count = note_queue_count(); echo '<div class="menu">.: '; echo "<a title=\"Go to your home page\" href=\"{$g_user_home_page}\">Home</a> :: "; #if ( access_check_action( ACTION_PAGES_MANAGE ) ) { # echo "<a title=\"Add or remove pages\" href=\"$g_admin_index_files\">$s_index_files</a> :: "; #} if (access_check_action(ACTION_NOTES_MODERATE)) { echo "<a title=\"Moderate notes\" href=\"{$g_admin_manage_notes}\">{$s_manage_notes}</a> [{$queue_count}] :: "; } if (access_check_action(ACTION_USERS_MANAGE)) { echo "<a title=\"View/edit user information\" href=\"{$g_admin_manage_users}\">{$s_manage_users}</a> :: "; } $row = user_get_info(user_where_current()); extract($row, EXTR_PREFIX_ALL, 'v'); if (1 == $v_protected) { $t_action = ACTION_USERS_EDIT_OWN_PROTECTED; } else { $t_action = ACTION_USERS_EDIT_OWN; } if (access_check_action($t_action)) { echo "<a title=\"Change your own password\" href=\"{$g_admin_change_password}\">{$s_change_password}</a> :: "; } echo <<<EOT \t\t<a title="Logout from phpWebNotes" href="{$g_logout}">{$s_logout_link}</a> :. \t\t</div> EOT; }
function note_get_all_visible($p_page_id) { $notes = array(); $t_page_info = page_get_info(page_where_id_equals($p_page_id)); if (false === $t_page_info) { return false; } $c_page_id = db_prepare_int($p_page_id); $query = "SELECT *, UNIX_TIMESTAMP(date_submitted) as date_submitted\r\n\t\t\t\tFROM " . config_get('phpWN_note_table') . "\r\n\t\t\t\tWHERE page_id={$c_page_id}\r\n\t\t\t\tORDER BY date_submitted " . config_get('note_order'); $result = db_query($query); while ($row = db_fetch_array($result)) { extract($row, EXTR_PREFIX_ALL, 'v'); if (NOTE_VISIBLE_PENDING == $v_visible && access_check_action(ACTION_NOTES_VIEW_PENDING) === false) { continue; } if (NOTE_VISIBLE_ACCEPTED == $v_visible && access_check_action(ACTION_NOTES_VIEW_ACCEPTED) === false) { continue; } if (NOTE_VISIBLE_DECLINED == $v_visible && access_check_action(ACTION_NOTES_VIEW_DECLINED) === false) { continue; } if (NOTE_VISIBLE_ARCHIVED == $v_visible && access_check_action(ACTION_NOTES_VIEW_ARCHIVED) === false) { continue; } if (NOTE_VISIBLE_DELETED == $v_visible && access_check_action(ACTION_NOTES_VIEW_DELETED) === false) { continue; } $info['visible'] = $v_visible; $info['id'] = $v_id; $info['email'] = string_prepare_note_for_viewing($v_email, $t_page_info['url']); $info['note'] = string_prepare_note_for_viewing($v_note, $t_page_info['url']); $info['date'] = $v_date_submitted; $notes[] = $info; } return $notes; }