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 ''; + echo ''; + echo ''; + + if ( !empty($userdata['real_name']) ) + { + echo ''; + } + + // Comments + + echo ''; + $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 '
All about ' . htmlspecialchars($target_username) . '
Joined: ' . date('F d, Y h:i a', $userdata['reg_time']) . '
Total comments: ' . $userdata['n_comments'] . '
Real name: ' . htmlspecialchars($userdata['real_name']) . '
' . htmlspecialchars($target_username) . '\'s latest comments
'; + echo '
'; + + echo ''; + $class = 'row1'; + + $tpl = ' + + '; + $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 ''; + } + echo '
+ class="wikilink-nonexistent">{PAGE}
+ Posted {DATE}
+ {SUBJECT} +
This user has not posted any comments.
'; + + 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 ''; + + $class = 'row3'; + + if ( $userdata['email_public'] == 1 ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + global $email; + $email_link = $email->encryptEmail($userdata['email']); + echo ''; + } + + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + if ( $session->user_logged_in ) + { + echo ''; + } + else + { + echo ''; + } + + if ( !empty($userdata['user_aim']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + echo ''; + } + + if ( !empty($userdata['user_yahoo']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + echo ''; + } + + if ( !empty($userdata['user_msn']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + $email_link = $email->encryptEmail($userdata['user_msn']); + echo ''; + } + + if ( !empty($userdata['user_xmpp']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + $email_link = $email->encryptEmail($userdata['user_xmpp']); + echo ''; + } + + // Real life + + echo ''; + + if ( !empty($userdata['user_location']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + echo ''; + } + + if ( !empty($userdata['user_job']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + echo ''; + } + + if ( !empty($userdata['user_hobbies']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + echo ''; + } + echo '
Get in touch
E-mail address: ' . $email_link . '
Send ' . htmlspecialchars($target_username) . ' a Private Message!
You could send ' . htmlspecialchars($target_username) . ' a private message if you were logged in.
AIM: ' . htmlspecialchars($userdata['user_aim']) . '
Yahoo! IM: ' . htmlspecialchars($userdata['user_yahoo']) . '
WLM: ' . $email_link . '
XMPP/Jabber: ' . $email_link . '
' . htmlspecialchars($target_username) . ' in real life
Location: ' . htmlspecialchars($userdata['user_location']) . '
Job/occupation: ' . htmlspecialchars($userdata['user_job']) . '
Enjoys: ' . htmlspecialchars($userdata['user_hobbies']) . '
'; 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.';