diff -r 663fcf528726 -r d0314575e2f0 includes/pageprocess.php
--- a/includes/pageprocess.php Tue Jun 26 17:28:18 2007 -0400
+++ b/includes/pageprocess.php Tue Jun 26 20:48:44 2007 -0400
@@ -464,15 +464,17 @@
$page_name = ( isset($paths->pages[$this->page_id]) ) ? $paths->pages[$this->page_id]['name'] : $this->page_id;
}
- if ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) )
+ $target_username = strtr($page_name,
+ Array(
+ '_' => ' ',
+ '<' => '<',
+ '>' => '>'
+ ));
+
+ $target_username = preg_replace('/^' . preg_quote($paths->nslist['User']) . '/', '', $target_username);
+
+ if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->page_exists )
{
- $target_username = strtr($page_name,
- Array(
- '_' => ' ',
- '<' => '<',
- '>' => '>'
- ));
- $target_username = preg_replace('/^' . preg_quote($paths->nslist['User']) . '/', '', $target_username);
$page_name = "$target_username's user page";
}
else
@@ -483,27 +485,155 @@
$template->tpl_strings['PAGE_NAME'] = htmlspecialchars($page_name);
+ $q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, x.*, COUNT(c.comment_id) AS n_comments
+ FROM '.table_prefix.'users u
+ LEFT JOIN '.table_prefix.'users_extra AS x
+ ON ( u.user_id = x.user_id OR x.user_id IS NULL )
+ LEFT JOIN '.table_prefix.'comments AS c
+ ON ( ( c.user_id=u.user_id AND c.approved=1 ) OR ( c.comment_id IS NULL AND c.approved IS NULL ) )
+ WHERE u.username=\'' . $db->escape($target_username) . '\'
+ GROUP BY u.user_id;');
+ if ( !$q )
+ $db->_die();
+
+ $user_exists = true;
+
+ if ( $db->numrows() < 1 )
+ {
+ $user_exists = false;
+ }
+ else
+ {
+ $userdata = $db->fetchrow();
+ if ( $userdata['authoritative_uid'] == 1 )
+ {
+ // Hide data for anonymous user
+ $user_exists = false;
+ unset($userdata);
+ }
+ }
+
$this->header();
// if ( $send_headers )
// {
- display_page_headers();
+ // display_page_headers();
// }
// Start left sidebar: basic user info, latest comments
+ if ( $user_exists ):
+
echo '
';
- echo '';
+ echo ' |
';
echo '
';
+ //
// Main part of sidebar
+ //
+
+ // Basic user info
+
+ echo 'All about ' . htmlspecialchars($target_username) . ' | ';
+ echo 'Joined: ' . date('F d, Y h:i a', $userdata['reg_time']) . ' | ';
+ echo 'Total comments: ' . $userdata['n_comments'] . ' | ';
+
+ if ( !empty($userdata['real_name']) )
+ {
+ echo 'Real name: ' . htmlspecialchars($userdata['real_name']) . ' | ';
+ }
+
+ // Comments
+
+ echo '' . htmlspecialchars($target_username) . '\'s latest comments | ';
+ $q = $db->sql_query('SELECT page_id, namespace, subject, time FROM '.table_prefix.'comments WHERE name=\'' . $db->escape($target_username) . '\' AND approved=1 ORDER BY time DESC LIMIT 5;');
+ if ( !$q )
+ $db->_die();
+
+ $comments = Array();
+ $no_comments = false;
+
+ if ( $row = $db->fetchrow() )
+ {
+ do
+ {
+ $row['time'] = date('F d, Y', $row['time']);
+ $comments[] = $row;
+ }
+ while ( $row = $db->fetchrow() );
+ }
+ else
+ {
+ $no_comments = true;
+ }
+
+ echo '';
+ echo '';
+
+ echo ' ';
+ $class = 'row1';
+
+ $tpl = '
+
+ class="wikilink-nonexistent">{PAGE}
+ Posted {DATE}
+ {SUBJECT}
+ |
+ ';
+ $parser = $template->makeParserText($tpl);
+
+ if ( count($comments) > 0 )
+ {
+ foreach ( $comments as $comment )
+ {
+ $c_page_id = $paths->nslist[ $comment['namespace'] ] . sanitize_page_id($comment['page_id']);
+ if ( isset($paths->pages[ $c_page_id ]) )
+ {
+ $parser->assign_bool(array(
+ 'page_exists' => true
+ ));
+ $page_title = $paths->pages[ $c_page_id ]['name'];
+ }
+ else
+ {
+ $parser->assign_bool(array(
+ 'page_exists' => false
+ ));
+ $page_title = htmlspecialchars(dirtify_page_id($c_page_id));
+ }
+ $parser->assign_vars(array(
+ 'CLASS' => $class,
+ 'PAGE_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id'])),
+ 'PAGE' => $page_title,
+ 'SUBJECT' => $comment['subject'],
+ 'DATE' => $comment['time'],
+ 'COMMENT_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id']), 'do=comments', true)
+ ));
+ $class = ( $class == 'row3' ) ? 'row1' : 'row3';
+ echo $parser->run();
+ }
+ }
+ else
+ {
+ echo 'This user has not posted any comments. | ';
+ }
+ echo ' ';
+
+ echo ' ';
+ echo ' | ';
echo '
';
- echo ' | ';
+ echo ' | ';
+
+ else:
+
+ // Nothing for now
+
+ endif;
// User's own content
@@ -516,26 +646,108 @@
}
else
{
- $this->err_page_not_existent();
+ $this->err_page_not_existent(true);
}
// Right sidebar
- echo ' | ';
+ if ( $user_exists ):
+
+ echo ' | ';
echo '
';
+ //
// Main part of sidebar
-
+ //
+
+ // Contact information
+
+ echo 'Get in touch | ';
+
+ $class = 'row3';
+
+ if ( $userdata['email_public'] == 1 )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ global $email;
+ $email_link = $email->encryptEmail($userdata['email']);
+ echo 'E-mail address: ' . $email_link . ' | ';
+ }
+
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ if ( $session->user_logged_in )
+ {
+ echo 'Send ' . htmlspecialchars($target_username) . ' a Private Message! | ';
+ }
+ else
+ {
+ echo 'You could send ' . htmlspecialchars($target_username) . ' a private message if you were logged in. | ';
+ }
+
+ if ( !empty($userdata['user_aim']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ echo 'AIM: ' . htmlspecialchars($userdata['user_aim']) . ' | ';
+ }
+
+ if ( !empty($userdata['user_yahoo']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ echo 'Yahoo! IM: ' . htmlspecialchars($userdata['user_yahoo']) . ' | ';
+ }
+
+ if ( !empty($userdata['user_msn']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ $email_link = $email->encryptEmail($userdata['user_msn']);
+ echo 'WLM: ' . $email_link . ' | ';
+ }
+
+ if ( !empty($userdata['user_xmpp']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ $email_link = $email->encryptEmail($userdata['user_xmpp']);
+ echo 'XMPP/Jabber: ' . $email_link . ' | ';
+ }
+
+ // Real life
+
+ echo '' . htmlspecialchars($target_username) . ' in real life | ';
+
+ if ( !empty($userdata['user_location']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ echo 'Location: ' . htmlspecialchars($userdata['user_location']) . ' | ';
+ }
+
+ if ( !empty($userdata['user_job']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ echo 'Job/occupation: ' . htmlspecialchars($userdata['user_job']) . ' | ';
+ }
+
+ if ( !empty($userdata['user_hobbies']) )
+ {
+ $class = ( $class == 'row1' ) ? 'row3' : 'row1';
+ echo 'Enjoys: ' . htmlspecialchars($userdata['user_hobbies']) . ' | ';
+ }
+
echo '
';
echo ' |
';
+ else:
+
+ echo 'Additional information: user "' . htmlspecialchars($target_username) . '" does not exist.
';
+
+ endif;
+
// if ( $send_headers )
// {
- display_page_footers();
+ // display_page_footers();
// }
$this->send_headers = $send_headers;
@@ -601,14 +813,22 @@
* @access private
*/
- function err_page_not_existent()
+ function err_page_not_existent($userpage = false)
{
global $db, $session, $paths, $template, $plugins; // Common objects
$this->header();
header('HTTP/1.1 404 Not Found');
- echo 'There is no page with this title yet.
- You have requested a page that doesn\'t exist yet.';
+ if ( $userpage )
+ {
+ echo '
There is no page with this title yet.
+ This user has not created his or her user page yet.';
+ }
+ else
+ {
+ echo '
There is no page with this title yet.
+ You have requested a page that doesn\'t exist yet.';
+ }
if ( $session->get_permissions('create_page') )
{
echo ' You can create this page, or return to the homepage.';