includes/namespaces/user.php
changeset 1227 bdac73ed481e
parent 1147 7ddd475bc661
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
    11  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    11  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    12  */
    12  */
    13 
    13 
    14 class Namespace_User extends Namespace_Default
    14 class Namespace_User extends Namespace_Default
    15 {
    15 {
    16   public function __construct($page_id, $namespace, $revision_id = 0)
    16 	public function __construct($page_id, $namespace, $revision_id = 0)
    17   {
    17 	{
    18     global $db, $session, $paths, $template, $plugins; // Common objects
    18 		global $db, $session, $paths, $template, $plugins; // Common objects
    19     global $lang;
    19 		global $lang;
    20     
    20 		
    21     parent::__construct($page_id, $namespace, $revision_id);
    21 		parent::__construct($page_id, $namespace, $revision_id);
    22     
    22 		
    23     if ( ( $this->title == str_replace('_', ' ', $this->page_id) || $this->title == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->exists )
    23 		if ( ( $this->title == str_replace('_', ' ', $this->page_id) || $this->title == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->exists )
    24     {
    24 		{
    25       $this->title = $lang->get('userpage_page_title', array('username' => str_replace('_', ' ', dirtify_page_id($this->page_id))));
    25 			$this->title = $lang->get('userpage_page_title', array('username' => str_replace('_', ' ', dirtify_page_id($this->page_id))));
    26       $this->cdata['name'] = $this->title;
    26 			$this->cdata['name'] = $this->title;
    27     }
    27 		}
    28     
    28 		
    29   }
    29 	}
    30   
    30 	
    31   public function send()
    31 	public function send()
    32   {
    32 	{
    33     global $db, $session, $paths, $template, $plugins; // Common objects
    33 		global $db, $session, $paths, $template, $plugins; // Common objects
    34     global $email;
    34 		global $email;
    35     global $lang, $output;
    35 		global $lang, $output;
    36     
    36 		
    37     /**
    37 		/**
    38      * PLUGGING INTO USER PAGES
    38  		* PLUGGING INTO USER PAGES
    39      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    39  		* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    40      * Userpages are highly programmable and extendable using a number of
    40  		* Userpages are highly programmable and extendable using a number of
    41      * hooks. These hooks are:
    41  		* hooks. These hooks are:
    42      *
    42  		*
    43      *   - userpage_sidebar_left
    43  		*   - userpage_sidebar_left
    44      *   - userpage_sidebar_right
    44  		*   - userpage_sidebar_right
    45      *   - userpage_tabs_links
    45  		*   - userpage_tabs_links
    46      *   - userpage_tabs_body
    46  		*   - userpage_tabs_body
    47      *
    47  		*
    48      * You can add a variety of sections to user pages, including new tabs
    48  		* You can add a variety of sections to user pages, including new tabs
    49      * and new sections on the tables. To add a tab, attach to
    49  		* and new sections on the tables. To add a tab, attach to
    50      * userpage_tabs_links and echo out:
    50  		* userpage_tabs_links and echo out:
    51      *
    51  		*
    52      *   <li><a href="#tab:YOURTABID">YOUR TAB TEXT</a></li>
    52  		*   <li><a href="#tab:YOURTABID">YOUR TAB TEXT</a></li>
    53      *
    53  		*
    54      * Then hook into userpage_tabs_body and echo out:
    54  		* Then hook into userpage_tabs_body and echo out:
    55      *
    55  		*
    56      *   <div id="tab:YOURTABID">YOUR TAB CONTENT</div>
    56  		*   <div id="tab:YOURTABID">YOUR TAB CONTENT</div>
    57      *
    57  		*
    58      * The userpage javascript runtime will take care of everything else,
    58  		* The userpage javascript runtime will take care of everything else,
    59      * meaning transitions, click events, etc. Currently it's not possible
    59  		* meaning transitions, click events, etc. Currently it's not possible
    60      * to add custom click events to tabs, but any DOM-related JS that needs
    60  		* to add custom click events to tabs, but any DOM-related JS that needs
    61      * to run in your tab can be run onload and the effects will be seen when
    61  		* to run in your tab can be run onload and the effects will be seen when
    62      * your tab is clicked. YOURTABID should be lowercase alphanumeric and
    62  		* your tab is clicked. YOURTABID should be lowercase alphanumeric and
    63      * have a short prefix so as to assure that it remains specific to your
    63  		* have a short prefix so as to assure that it remains specific to your
    64      * plugin.
    64  		* plugin.
    65      *
    65  		*
    66      * To hook into the "profile" tab, use userpage_sidebar_{left,right}. Just
    66  		* To hook into the "profile" tab, use userpage_sidebar_{left,right}. Just
    67      * echo out table cells as normal. The table on the left (the wide one) has
    67  		* echo out table cells as normal. The table on the left (the wide one) has
    68      * four columns, and the one on the right has one column.
    68  		* four columns, and the one on the right has one column.
    69      * 
    69  		* 
    70      * See plugins.php for a guide on creating and attaching to hooks.
    70  		* See plugins.php for a guide on creating and attaching to hooks.
    71      */
    71  		*/
    72      
    72  		
    73     $page_urlname = dirtify_page_id($this->page_id);
    73 		$page_urlname = dirtify_page_id($this->page_id);
    74     
    74 		
    75     $target_username = strtr($page_urlname, 
    75 		$target_username = strtr($page_urlname, 
    76       Array(
    76 			Array(
    77         '_' => ' ',
    77 				'_' => ' ',
    78         '<' => '&lt;',
    78 				'<' => '&lt;',
    79         '>' => '&gt;'
    79 				'>' => '&gt;'
    80         ));
    80 				));
    81     
    81 		
    82     $target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username);
    82 		$target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username);
    83     list($target_username) = explode('/', $target_username);
    83 		list($target_username) = explode('/', $target_username);
    84     
    84 		
    85     $ux_columns = $db->columns_in(table_prefix . 'users_extra');
    85 		$ux_columns = $db->columns_in(table_prefix . 'users_extra');
    86     
    86 		
    87     $output->set_title($this->title);
    87 		$output->set_title($this->title);
    88     $q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.*, COUNT(c.comment_id) AS n_comments
    88 		$q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.*, COUNT(c.comment_id) AS n_comments
    89                            FROM '.table_prefix.'users u
    89  													FROM '.table_prefix.'users u
    90                            LEFT JOIN '.table_prefix.'users_extra AS x
    90  													LEFT JOIN '.table_prefix.'users_extra AS x
    91                              ON ( u.user_id = x.user_id OR x.user_id IS NULL ) 
    91  														ON ( u.user_id = x.user_id OR x.user_id IS NULL ) 
    92                            LEFT JOIN '.table_prefix.'comments AS c
    92  													LEFT JOIN '.table_prefix.'comments AS c
    93                              ON ( ( c.user_id=u.user_id AND c.name=u.username AND c.approved=1 ) OR ( c.comment_id IS NULL AND c.approved IS NULL ) )
    93  														ON ( ( c.user_id=u.user_id AND c.name=u.username AND c.approved=1 ) OR ( c.comment_id IS NULL AND c.approved IS NULL ) )
    94                            WHERE u.username=\'' . $db->escape($target_username) . '\'
    94  													WHERE u.username=\'' . $db->escape($target_username) . '\'
    95                            GROUP BY u.username, u.user_id, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.' . implode(', x.', $ux_columns) . ';');
    95  													GROUP BY u.username, u.user_id, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.' . implode(', x.', $ux_columns) . ';');
    96     if ( !$q )
    96 		if ( !$q )
    97       $db->_die();
    97 			$db->_die();
    98     
    98 		
    99     $user_exists = true;
    99 		$user_exists = true;
   100     
   100 		
   101     if ( $db->numrows() < 1 )
   101 		if ( $db->numrows() < 1 )
   102     {
   102 		{
   103       $user_exists = false;
   103 			$user_exists = false;
   104     }
   104 		}
   105     else
   105 		else
   106     {
   106 		{
   107       $userdata = $db->fetchrow();
   107 			$userdata = $db->fetchrow();
   108       if ( $userdata['authoritative_uid'] == 1 )
   108 			if ( $userdata['authoritative_uid'] == 1 )
   109       {
   109 			{
   110         // Hide data for anonymous user
   110 				// Hide data for anonymous user
   111         $user_exists = false;
   111 				$user_exists = false;
   112         unset($userdata);
   112 				unset($userdata);
   113       }
   113 			}
   114     }
   114 		}
   115     
   115 		
   116     // get the user's rank
   116 		// get the user's rank
   117     if ( $user_exists )
   117 		if ( $user_exists )
   118     {
   118 		{
   119       $rank_data = $session->get_user_rank(intval($userdata['authoritative_uid']));
   119 			$rank_data = $session->get_user_rank(intval($userdata['authoritative_uid']));
   120     }
   120 		}
   121     else
   121 		else
   122     {
   122 		{
   123       // get the rank data for the anonymous user (placeholder basically)
   123 			// get the rank data for the anonymous user (placeholder basically)
   124       $rank_data = $session->get_user_rank(1);
   124 			$rank_data = $session->get_user_rank(1);
   125     }
   125 		}
   126     
   126 		
   127     // add the userpage script to the header
   127 		// add the userpage script to the header
   128     $template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/userpage.js"></script>');
   128 		$template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/userpage.js"></script>');
   129     
   129 		
   130     $output->header();
   130 		$output->header();
   131     
   131 		
   132     // if ( $send_headers )
   132 		// if ( $send_headers )
   133     // {
   133 		// {
   134     //  display_page_headers();
   134 		//  display_page_headers();
   135     // }
   135 		// }
   136    
   136  	
   137     //
   137 		//
   138     // BASIC INFORMATION
   138 		// BASIC INFORMATION
   139     // Presentation of username/rank/avatar/basic info
   139 		// Presentation of username/rank/avatar/basic info
   140     //
   140 		//
   141     
   141 		
   142     if ( $user_exists )
   142 		if ( $user_exists )
   143     {
   143 		{
   144     
   144 		
   145       ?>
   145 			?>
   146       <div id="userpage_wrap">
   146 			<div id="userpage_wrap">
   147         <ul id="userpage_links">
   147 				<ul id="userpage_links">
   148           <li><a href="#tab:profile"><?php echo $lang->get('userpage_tab_profile'); ?></a></li>
   148 					<li><a href="#tab:profile"><?php echo $lang->get('userpage_tab_profile'); ?></a></li>
   149           <li><a href="#tab:content"><?php echo $lang->get('userpage_tab_content'); ?></a></li>
   149 					<li><a href="#tab:content"><?php echo $lang->get('userpage_tab_content'); ?></a></li>
   150           <?php
   150 					<?php
   151           $code = $plugins->setHook('userpage_tabs_links');
   151 					$code = $plugins->setHook('userpage_tabs_links');
   152           foreach ( $code as $cmd )
   152 					foreach ( $code as $cmd )
   153           {
   153 					{
   154             eval($cmd);
   154 						eval($cmd);
   155           }
   155 					}
   156           ?>
   156 					?>
   157         </ul>
   157 				</ul>
   158         
   158 				
   159         <div id="tab:profile">
   159 				<div id="tab:profile">
   160       
   160 			
   161       <?php
   161 			<?php
   162       
   162 			
   163       echo '<table border="0" cellspacing="0" cellpadding="0">
   163 			echo '<table border="0" cellspacing="0" cellpadding="0">
   164               <tr>';
   164 							<tr>';
   165                 
   165 								
   166       echo '    <td valign="top">';
   166 			echo '    <td valign="top">';
   167       
   167 			
   168       echo '<div class="tblholder">
   168 			echo '<div class="tblholder">
   169               <table border="0" cellspacing="1" cellpadding="4">';
   169 							<table border="0" cellspacing="1" cellpadding="4">';
   170               
   170 							
   171       // heading
   171 			// heading
   172       echo '    <tr>
   172 			echo '    <tr>
   173                   <th colspan="' . ( $session->user_level >= USER_LEVEL_ADMIN ? '3' : '4' ) . '">
   173 									<th colspan="' . ( $session->user_level >= USER_LEVEL_ADMIN ? '3' : '4' ) . '">
   174                     ' . $lang->get('userpage_heading_basics', array('username' => htmlspecialchars($target_username))) . '
   174 										' . $lang->get('userpage_heading_basics', array('username' => htmlspecialchars($target_username))) . '
   175                   </th>
   175 									</th>
   176                   ' . (
   176 									' . (
   177                     $session->user_level >= USER_LEVEL_ADMIN ?
   177 										$session->user_level >= USER_LEVEL_ADMIN ?
   178                     '<th class="subhead" style="width: 25%;"><a href="' . makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'UserManager&src=get&user=' . urlencode($target_username), true) . '" onclick="ajaxAdminUser(\'' . addslashes($target_username) . '\'); return false;">&raquo; ' . $lang->get('userpage_btn_administer_user') . '</a></th>'
   178 										'<th class="subhead" style="width: 25%;"><a href="' . makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'UserManager&src=get&user=' . urlencode($target_username), true) . '" onclick="ajaxAdminUser(\'' . addslashes($target_username) . '\'); return false;">&raquo; ' . $lang->get('userpage_btn_administer_user') . '</a></th>'
   179                       : ''
   179 											: ''
   180                   ) . '
   180 									) . '
   181                 </tr>';
   181 								</tr>';
   182                 
   182 								
   183       // avi/rank/username
   183 			// avi/rank/username
   184       echo '    <tr>
   184 			echo '    <tr>
   185                   <td class="row3" colspan="4">
   185 									<td class="row3" colspan="4">
   186                     ' . (
   186 										' . (
   187                         $userdata['user_has_avatar'] == 1 ?
   187 												$userdata['user_has_avatar'] == 1 ?
   188                         '<div style="float: left; margin-right: 10px;">
   188 												'<div style="float: left; margin-right: 10px;">
   189                           <img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $userdata['username'])) . '" src="' . make_avatar_url(intval($userdata['authoritative_uid']), $userdata['avatar_type'], $userdata['email']) . '" />
   189 													<img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $userdata['username'])) . '" src="' . make_avatar_url(intval($userdata['authoritative_uid']), $userdata['avatar_type'], $userdata['email']) . '" />
   190                          </div>'
   190  												</div>'
   191                         : ''
   191 												: ''
   192                       ) . '
   192 											) . '
   193                       <span style="font-size: x-large; ' . $rank_data['rank_style'] . '">' . htmlspecialchars($userdata['username']) . '</span>
   193 											<span style="font-size: x-large; ' . $rank_data['rank_style'] . '">' . htmlspecialchars($userdata['username']) . '</span>
   194                       ' . ( !empty($rank_data['user_title']) ? '<br />' . htmlspecialchars($rank_data['user_title']) : '' ) . '
   194 											' . ( !empty($rank_data['user_title']) ? '<br />' . htmlspecialchars($rank_data['user_title']) : '' ) . '
   195                       ' . ( !empty($rank_data['rank_title']) ? '<br />' . htmlspecialchars($lang->get($rank_data['rank_title'])) : '' ) . '
   195 											' . ( !empty($rank_data['rank_title']) ? '<br />' . htmlspecialchars($lang->get($rank_data['rank_title'])) : '' ) . '
   196                   </td>
   196 									</td>
   197                 </tr>';
   197 								</tr>';
   198                 
   198 								
   199       // join date & total comments
   199 			// join date & total comments
   200       echo '<tr>';
   200 			echo '<tr>';
   201       echo '  <td class="row2" style="text-align: right; width: 25%;">
   201 			echo '  <td class="row2" style="text-align: right; width: 25%;">
   202                 ' . $lang->get('userpage_lbl_joined') . '
   202 								' . $lang->get('userpage_lbl_joined') . '
   203               </td>
   203 							</td>
   204               <td class="row1" style="text-align: left; width: 25%;">
   204 							<td class="row1" style="text-align: left; width: 25%;">
   205                 ' . enano_date(ED_DATE | ED_TIME, $userdata['reg_time']) . '
   205 								' . enano_date(ED_DATE | ED_TIME, $userdata['reg_time']) . '
   206               </td>';
   206 							</td>';
   207       echo '  <td class="row2" style="text-align: right; width: 25%;">
   207 			echo '  <td class="row2" style="text-align: right; width: 25%;">
   208                 ' . $lang->get('userpage_lbl_num_comments') . '
   208 								' . $lang->get('userpage_lbl_num_comments') . '
   209               </td>
   209 							</td>
   210               <td class="row1" style="text-align: left; width: 25%;">
   210 							<td class="row1" style="text-align: left; width: 25%;">
   211                 ' . $userdata['n_comments'] . '
   211 								' . $userdata['n_comments'] . '
   212               </td>';
   212 							</td>';
   213       echo '</tr>';
   213 			echo '</tr>';
   214       
   214 			
   215       // real name
   215 			// real name
   216       if ( !empty($userdata['real_name']) )
   216 			if ( !empty($userdata['real_name']) )
   217       {
   217 			{
   218         echo '<tr>
   218 				echo '<tr>
   219                 <td class="row2" style="text-align: right;">
   219 								<td class="row2" style="text-align: right;">
   220                   ' . $lang->get('userpage_lbl_real_name') . '
   220 									' . $lang->get('userpage_lbl_real_name') . '
   221                 </td>
   221 								</td>
   222                 <td class="row1" colspan="3" style="text-align: left;">
   222 								<td class="row1" colspan="3" style="text-align: left;">
   223                   ' . htmlspecialchars($userdata['real_name']) . '
   223 									' . htmlspecialchars($userdata['real_name']) . '
   224                 </td>
   224 								</td>
   225               </tr>';
   225 							</tr>';
   226       }
   226 			}
   227                 
   227 								
   228       // latest comments
   228 			// latest comments
   229       
   229 			
   230       echo '<tr><th class="subhead" colspan="4">' . $lang->get('userpage_heading_comments', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
   230 			echo '<tr><th class="subhead" colspan="4">' . $lang->get('userpage_heading_comments', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
   231       $q = $db->sql_query('SELECT page_id, namespace, subject, time FROM '.table_prefix.'comments WHERE name=\'' . $db->escape($target_username) . '\' AND user_id=' . $userdata['authoritative_uid'] . ' AND approved=1 ORDER BY time DESC LIMIT 7;');
   231 			$q = $db->sql_query('SELECT page_id, namespace, subject, time FROM '.table_prefix.'comments WHERE name=\'' . $db->escape($target_username) . '\' AND user_id=' . $userdata['authoritative_uid'] . ' AND approved=1 ORDER BY time DESC LIMIT 7;');
   232       if ( !$q )
   232 			if ( !$q )
   233         $db->_die();
   233 				$db->_die();
   234       
   234 			
   235       $comments = Array();
   235 			$comments = Array();
   236       $no_comments = false;
   236 			$no_comments = false;
   237       
   237 			
   238       if ( $row = $db->fetchrow() )
   238 			if ( $row = $db->fetchrow() )
   239       {
   239 			{
   240         do 
   240 				do 
   241         {
   241 				{
   242           $row['time'] = enano_date(ED_DATE, $row['time']);
   242 					$row['time'] = enano_date(ED_DATE, $row['time']);
   243           $comments[] = $row;
   243 					$comments[] = $row;
   244         }
   244 				}
   245         while ( $row = $db->fetchrow() );
   245 				while ( $row = $db->fetchrow() );
   246       }
   246 			}
   247       else
   247 			else
   248       {
   248 			{
   249         $no_comments = true;
   249 				$no_comments = true;
   250       }
   250 			}
   251       
   251 			
   252       echo '<tr><td class="row3" colspan="4">';
   252 			echo '<tr><td class="row3" colspan="4">';
   253       echo '<div style="border: 1px solid #000000; padding: 0px; width: 100%; clip: rect(0px,auto,auto,0px); overflow: auto; background-color: transparent;" class="tblholder">';
   253 			echo '<div style="border: 1px solid #000000; padding: 0px; width: 100%; clip: rect(0px,auto,auto,0px); overflow: auto; background-color: transparent;" class="tblholder">';
   254       
   254 			
   255       echo '<table border="0" cellspacing="1" cellpadding="4" style="width: 200%;"><tr>';
   255 			echo '<table border="0" cellspacing="1" cellpadding="4" style="width: 200%;"><tr>';
   256       $class = 'row1';
   256 			$class = 'row1';
   257       
   257 			
   258       $tpl = '  <td class="{CLASS}">
   258 			$tpl = '  <td class="{CLASS}">
   259                   <a href="{PAGE_LINK}" <!-- BEGINNOT page_exists -->class="wikilink-nonexistent"<!-- END page_exists -->>{PAGE}</a><br />
   259 									<a href="{PAGE_LINK}" <!-- BEGINNOT page_exists -->class="wikilink-nonexistent"<!-- END page_exists -->>{PAGE}</a><br />
   260                   <small>{lang:userpage_comments_lbl_posted} {DATE}<br /></small>
   260 									<small>{lang:userpage_comments_lbl_posted} {DATE}<br /></small>
   261                   <b><a href="{COMMENT_LINK}">{SUBJECT}</a></b>
   261 									<b><a href="{COMMENT_LINK}">{SUBJECT}</a></b>
   262                 </td>';
   262 								</td>';
   263       $parser = $template->makeParserText($tpl);
   263 			$parser = $template->makeParserText($tpl);
   264       
   264 			
   265       if ( count($comments) > 0 )
   265 			if ( count($comments) > 0 )
   266       {
   266 			{
   267         foreach ( $comments as $comment )
   267 				foreach ( $comments as $comment )
   268         {
   268 				{
   269           $c_page_id = $paths->nslist[ $comment['namespace'] ] . sanitize_page_id($comment['page_id']);
   269 					$c_page_id = $paths->nslist[ $comment['namespace'] ] . sanitize_page_id($comment['page_id']);
   270           if ( isPage($c_page_id) )
   270 					if ( isPage($c_page_id) )
   271           {
   271 					{
   272             $parser->assign_bool(array(
   272 						$parser->assign_bool(array(
   273               'page_exists' => true
   273 							'page_exists' => true
   274               ));
   274 							));
   275             $page_title = get_page_title($c_page_id);
   275 						$page_title = get_page_title($c_page_id);
   276           }
   276 					}
   277           else
   277 					else
   278           {
   278 					{
   279             $parser->assign_bool(array(
   279 						$parser->assign_bool(array(
   280               'page_exists' => false
   280 							'page_exists' => false
   281               ));
   281 							));
   282             $page_title = htmlspecialchars(dirtify_page_id($c_page_id));
   282 						$page_title = htmlspecialchars(dirtify_page_id($c_page_id));
   283           }
   283 					}
   284           $parser->assign_vars(array(
   284 					$parser->assign_vars(array(
   285               'CLASS' => $class,
   285 							'CLASS' => $class,
   286               'PAGE_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id'])),
   286 							'PAGE_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id'])),
   287               'PAGE' => $page_title,
   287 							'PAGE' => $page_title,
   288               'SUBJECT' => $comment['subject'],
   288 							'SUBJECT' => $comment['subject'],
   289               'DATE' => $comment['time'],
   289 							'DATE' => $comment['time'],
   290               'COMMENT_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id']), 'do=comments', true)
   290 							'COMMENT_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id']), 'do=comments', true)
   291             ));
   291 						));
   292           $class = ( $class == 'row3' ) ? 'row1' : 'row3';
   292 					$class = ( $class == 'row3' ) ? 'row1' : 'row3';
   293           echo $parser->run();
   293 					echo $parser->run();
   294         }
   294 				}
   295       }
   295 			}
   296       else
   296 			else
   297       {
   297 			{
   298         echo '<td class="' . $class . '">' . $lang->get('userpage_msg_no_comments') . '</td>';
   298 				echo '<td class="' . $class . '">' . $lang->get('userpage_msg_no_comments') . '</td>';
   299       }
   299 			}
   300       echo '</tr></table>';
   300 			echo '</tr></table>';
   301       
   301 			
   302       echo '</div>';
   302 			echo '</div>';
   303       echo '</td></tr>';
   303 			echo '</td></tr>';
   304       
   304 			
   305       $code = $plugins->setHook('userpage_sidebar_left');
   305 			$code = $plugins->setHook('userpage_sidebar_left');
   306       foreach ( $code as $cmd )
   306 			foreach ( $code as $cmd )
   307       {
   307 			{
   308         eval($cmd);
   308 				eval($cmd);
   309       }
   309 			}
   310               
   310 							
   311       echo '  </table>
   311 			echo '  </table>
   312             </div>';
   312 						</div>';
   313             
   313 						
   314       echo '</td>';
   314 			echo '</td>';
   315       
   315 			
   316       //
   316 			//
   317       // CONTACT INFORMATION
   317 			// CONTACT INFORMATION
   318       //
   318 			//
   319       
   319 			
   320       echo '    <td valign="top" style="width: 150px; padding-left: 10px;">';
   320 			echo '    <td valign="top" style="width: 150px; padding-left: 10px;">';
   321       
   321 			
   322       echo '<div class="tblholder">
   322 			echo '<div class="tblholder">
   323               <table border="0" cellspacing="1" cellpadding="4">';
   323 							<table border="0" cellspacing="1" cellpadding="4">';
   324       
   324 			
   325       //
   325 			//
   326       // Main part of sidebar
   326 			// Main part of sidebar
   327       //
   327 			//
   328       
   328 			
   329       // Contact information
   329 			// Contact information
   330       
   330 			
   331       echo '<tr><th class="subhead">' . $lang->get('userpage_heading_contact') . '</th></tr>';
   331 			echo '<tr><th class="subhead">' . $lang->get('userpage_heading_contact') . '</th></tr>';
   332       
   332 			
   333       $class = 'row3';
   333 			$class = 'row3';
   334       
   334 			
   335       if ( $userdata['email_public'] == 1 )
   335 			if ( $userdata['email_public'] == 1 )
   336       {
   336 			{
   337         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   337 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   338         $email_link = $email->encryptEmail($userdata['email']);
   338 				$email_link = $email->encryptEmail($userdata['email']);
   339         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_email') . ' ' . $email_link . '</td></tr>';
   339 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_email') . ' ' . $email_link . '</td></tr>';
   340       }
   340 			}
   341       
   341 			
   342       if ( !empty($userdata['user_homepage']) )
   342 			if ( !empty($userdata['user_homepage']) )
   343       {
   343 			{
   344         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   344 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   345         echo '<tr><td class="' . $class . '">' . $lang->get('userpage_lbl_homepage') . '<br /><a href="' . $userdata['user_homepage'] . '">' . $userdata['user_homepage'] . '</a></td></tr>';
   345 				echo '<tr><td class="' . $class . '">' . $lang->get('userpage_lbl_homepage') . '<br /><a href="' . $userdata['user_homepage'] . '">' . $userdata['user_homepage'] . '</a></td></tr>';
   346       }
   346 			}
   347       
   347 			
   348       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   348 			$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   349       if ( $session->user_logged_in )
   349 			if ( $session->user_logged_in )
   350       {
   350 			{
   351         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_btn_send_pm', array('username' => htmlspecialchars($target_username), 'pm_link' => makeUrlNS('Special', 'PrivateMessages/Compose/to/' . $this->page_id, false, true))) . '</td></tr>';
   351 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_btn_send_pm', array('username' => htmlspecialchars($target_username), 'pm_link' => makeUrlNS('Special', 'PrivateMessages/Compose/to/' . $this->page_id, false, true))) . '</td></tr>';
   352       }
   352 			}
   353       else
   353 			else
   354       {
   354 			{
   355         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_btn_send_pm_guest', array('username' => htmlspecialchars($target_username), 'login_flags' => 'href="' . makeUrlNS('Special', 'Login/' . $paths->nslist[$this->namespace] . $this->page_id) . '" onclick="ajaxStartLogin(); return false;"')) . '</td></tr>';
   355 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_btn_send_pm_guest', array('username' => htmlspecialchars($target_username), 'login_flags' => 'href="' . makeUrlNS('Special', 'Login/' . $paths->nslist[$this->namespace] . $this->page_id) . '" onclick="ajaxStartLogin(); return false;"')) . '</td></tr>';
   356       }
   356 			}
   357       
   357 			
   358       if ( !empty($userdata['user_aim']) )
   358 			if ( !empty($userdata['user_aim']) )
   359       {
   359 			{
   360         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   360 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   361         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_aim') . ' ' . $userdata['user_aim'] . '</td></tr>';
   361 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_aim') . ' ' . $userdata['user_aim'] . '</td></tr>';
   362       }
   362 			}
   363       
   363 			
   364       if ( !empty($userdata['user_yahoo']) )
   364 			if ( !empty($userdata['user_yahoo']) )
   365       {
   365 			{
   366         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   366 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   367         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_yim') . ' ' . $userdata['user_yahoo'] . '</td></tr>';
   367 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_yim') . ' ' . $userdata['user_yahoo'] . '</td></tr>';
   368       }
   368 			}
   369       
   369 			
   370       if ( !empty($userdata['user_msn']) )
   370 			if ( !empty($userdata['user_msn']) )
   371       {
   371 			{
   372         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   372 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   373         $email_link = $email->encryptEmail($userdata['user_msn']);
   373 				$email_link = $email->encryptEmail($userdata['user_msn']);
   374         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_wlm') . ' ' . $email_link . '</td></tr>';
   374 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_wlm') . ' ' . $email_link . '</td></tr>';
   375       }
   375 			}
   376       
   376 			
   377       if ( !empty($userdata['user_xmpp']) )
   377 			if ( !empty($userdata['user_xmpp']) )
   378       {
   378 			{
   379         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   379 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   380         $email_link = $email->encryptEmail($userdata['user_xmpp']);
   380 				$email_link = $email->encryptEmail($userdata['user_xmpp']);
   381         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_xmpp') . ' ' . $email_link . '</td></tr>';
   381 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_xmpp') . ' ' . $email_link . '</td></tr>';
   382       }
   382 			}
   383       
   383 			
   384       // Real life
   384 			// Real life
   385       
   385 			
   386       echo '<tr><th class="subhead">' . $lang->get('userpage_heading_real_life', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
   386 			echo '<tr><th class="subhead">' . $lang->get('userpage_heading_real_life', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
   387       
   387 			
   388       if ( !empty($userdata['user_location']) )
   388 			if ( !empty($userdata['user_location']) )
   389       {
   389 			{
   390         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   390 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   391         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_location') . ' ' . $userdata['user_location'] . '</td></tr>';
   391 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_location') . ' ' . $userdata['user_location'] . '</td></tr>';
   392       }
   392 			}
   393       
   393 			
   394       if ( !empty($userdata['user_job']) )
   394 			if ( !empty($userdata['user_job']) )
   395       {
   395 			{
   396         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   396 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   397         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_job') . ' ' . $userdata['user_job'] . '</td></tr>';
   397 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_job') . ' ' . $userdata['user_job'] . '</td></tr>';
   398       }
   398 			}
   399       
   399 			
   400       if ( !empty($userdata['user_hobbies']) )
   400 			if ( !empty($userdata['user_hobbies']) )
   401       {
   401 			{
   402         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   402 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   403         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_hobbies') . ' ' . $userdata['user_hobbies'] . '</td></tr>';
   403 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_hobbies') . ' ' . $userdata['user_hobbies'] . '</td></tr>';
   404       }
   404 			}
   405       
   405 			
   406       if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
   406 			if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
   407       {
   407 			{
   408         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
   408 				$class = ( $class == 'row1' ) ? 'row3' : 'row1';
   409         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_msg_no_contact_info', array('username' => htmlspecialchars($target_username))) . '</td></tr>';
   409 				echo '<tr><td class="'.$class.'">' . $lang->get('userpage_msg_no_contact_info', array('username' => htmlspecialchars($target_username))) . '</td></tr>';
   410       }
   410 			}
   411       
   411 			
   412       $code = $plugins->setHook('userpage_sidebar_right');
   412 			$code = $plugins->setHook('userpage_sidebar_right');
   413       foreach ( $code as $cmd )
   413 			foreach ( $code as $cmd )
   414       {
   414 			{
   415         eval($cmd);
   415 				eval($cmd);
   416       }
   416 			}
   417       
   417 			
   418       echo '  </table>
   418 			echo '  </table>
   419             </div>';
   419 						</div>';
   420       echo '</td>';
   420 			echo '</td>';
   421       
   421 			
   422       //
   422 			//
   423       // End of profile
   423 			// End of profile
   424       //
   424 			//
   425       
   425 			
   426       echo '</tr></table>';
   426 			echo '</tr></table>';
   427       
   427 			
   428       echo '</div>'; // tab:profile
   428 			echo '</div>'; // tab:profile
   429     
   429 		
   430     }
   430 		}
   431     
   431 		
   432     // User's own content
   432 		// User's own content
   433     
   433 		
   434     echo '<span class="menuclear"></span>';
   434 		echo '<span class="menuclear"></span>';
   435     
   435 		
   436     echo '<div id="tab:content">';
   436 		echo '<div id="tab:content">';
   437     
   437 		
   438     if ( $this->exists )
   438 		if ( $this->exists )
   439     {
   439 		{
   440       $this->send_from_db(true, false);
   440 			$this->send_from_db(true, false);
   441     }
   441 		}
   442     else
   442 		else
   443     {
   443 		{
   444       $this->error_404();
   444 			$this->error_404();
   445     }
   445 		}
   446     
   446 		
   447     echo '</div>'; // tab:content
   447 		echo '</div>'; // tab:content
   448     
   448 		
   449     $code = $plugins->setHook('userpage_tabs_body');
   449 		$code = $plugins->setHook('userpage_tabs_body');
   450     foreach ( $code as $cmd )
   450 		foreach ( $code as $cmd )
   451     {
   451 		{
   452       eval($cmd);
   452 			eval($cmd);
   453     }
   453 		}
   454     
   454 		
   455     if ( $user_exists )
   455 		if ( $user_exists )
   456     {
   456 		{
   457       echo '</div>'; // userpage_wrap
   457 			echo '</div>'; // userpage_wrap
   458     }
   458 		}
   459     else
   459 		else
   460     {
   460 		{
   461       if ( !is_valid_ip($target_username) )
   461 			if ( !is_valid_ip($target_username) )
   462       {
   462 			{
   463         echo '<p>' . $lang->get('userpage_msg_user_not_exist', array('username' => htmlspecialchars($target_username))) . '</p>';
   463 				echo '<p>' . $lang->get('userpage_msg_user_not_exist', array('username' => htmlspecialchars($target_username))) . '</p>';
   464       }
   464 			}
   465     }
   465 		}
   466     
   466 		
   467     // if ( $send_headers )
   467 		// if ( $send_headers )
   468     // {
   468 		// {
   469     //  display_page_footers();
   469 		//  display_page_footers();
   470     // }
   470 		// }
   471     
   471 		
   472     $output->footer();
   472 		$output->footer();
   473   }
   473 	}
   474 }
   474 }
   475 
   475