includes/pageprocess.php
changeset 672 08a7875258b4
parent 621 68f8a9cc0a18
child 676 47413d71c2d9
equal deleted inserted replaced
671:267c9f93b51f 672:08a7875258b4
  1298   {
  1298   {
  1299     global $db, $session, $paths, $template, $plugins; // Common objects
  1299     global $db, $session, $paths, $template, $plugins; // Common objects
  1300     global $email;
  1300     global $email;
  1301     global $lang;
  1301     global $lang;
  1302     
  1302     
       
  1303     /**
       
  1304      * PLUGGING INTO USER PAGES
       
  1305      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
  1306      * Userpages are highly programmable and extendable using a number of
       
  1307      * hooks. These hooks are:
       
  1308      *
       
  1309      *   - userpage_sidebar_left
       
  1310      *   - userpage_sidebar_right
       
  1311      *   - userpage_tabs_links
       
  1312      *   - userpage_tabs_body
       
  1313      *
       
  1314      * You can add a variety of sections to user pages, including new tabs
       
  1315      * and new sections on the tables. To add a tab, attach to
       
  1316      * userpage_tabs_links and echo out:
       
  1317      *
       
  1318      *   <li><a href="#tab:YOURTABID">YOUR TAB TEXT</a></li>
       
  1319      *
       
  1320      * Then hook into userpage_tabs_body and echo out:
       
  1321      *
       
  1322      *   <div id="tab:YOURTABID">YOUR TAB CONTENT</div>
       
  1323      *
       
  1324      * The userpage javascript runtime will take care of everything else,
       
  1325      * meaning transitions, click events, etc. Currently it's not possible
       
  1326      * to add custom click events to tabs, but any DOM-related JS that needs
       
  1327      * to run in your tab can be run onload and the effects will be seen when
       
  1328      * your tab is clicked. YOURTABID should be lowercase alphanumeric and
       
  1329      * have a short prefix so as to assure that it remains specific to your
       
  1330      * plugin.
       
  1331      *
       
  1332      * To hook into the "profile" tab, use userpage_sidebar_{left,right}. Just
       
  1333      * echo out table cells as normal. The table on the left (the wide one) has
       
  1334      * four columns, and the one on the right has one column.
       
  1335      * 
       
  1336      * See plugins.php for a guide on creating and attaching to hooks.
       
  1337      */
       
  1338     
  1303     $page_urlname = dirtify_page_id($this->page_id);
  1339     $page_urlname = dirtify_page_id($this->page_id);
  1304     if ( $this->page_id == $paths->page_id && $this->namespace == $paths->namespace )
  1340     if ( $this->page_id == $paths->page_id && $this->namespace == $paths->namespace )
  1305     {
  1341     {
  1306       $page_name = ( isset($paths->cpage['name']) ) ? $paths->cpage['name'] : $this->page_id;
  1342       $page_name = ( isset($paths->cpage['name']) ) ? $paths->cpage['name'] : $this->page_id;
  1307     }
  1343     }
  1320     $target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username);
  1356     $target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username);
  1321     list($target_username) = explode('/', $target_username);
  1357     list($target_username) = explode('/', $target_username);
  1322     
  1358     
  1323     if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->page_exists )
  1359     if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->page_exists )
  1324     {
  1360     {
  1325       $page_name = $lang->get('userpage_page_title', array('username' => htmlspecialchars($target_username)));
  1361       $page_name = $lang->get('userpage_page_title', array('username' => $target_username));
  1326     }
  1362     }
  1327     else
  1363     else
  1328     {
  1364     {
  1329       // User has a custom title for their userpage
  1365       // User has a custom title for their userpage
  1330       $page_name = $paths->pages[ $paths->nslist[$this->namespace] . $this->page_id ]['name'];
  1366       $page_name = $paths->pages[ $paths->nslist[$this->namespace] . $this->page_id ]['name'];
  1365     {
  1401     {
  1366       $rank_data = $session->get_user_rank(intval($userdata['authoritative_uid']));
  1402       $rank_data = $session->get_user_rank(intval($userdata['authoritative_uid']));
  1367     }
  1403     }
  1368     else
  1404     else
  1369     {
  1405     {
       
  1406       // get the rank data for the anonymous user (placeholder basically)
  1370       $rank_data = $session->get_user_rank(1);
  1407       $rank_data = $session->get_user_rank(1);
  1371     }
  1408     }
       
  1409     
       
  1410     // add the userpage script to the header
       
  1411     $template->add_header('<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/userpage.js"></script>');
  1372     
  1412     
  1373     $this->header();
  1413     $this->header();
  1374     
  1414     
  1375     // if ( $send_headers )
  1415     // if ( $send_headers )
  1376     // {
  1416     // {
  1377     //  display_page_headers();
  1417     //  display_page_headers();
  1378     // }
  1418     // }
  1379    
  1419    
  1380     // Start left sidebar: basic user info, latest comments
       
  1381     
       
  1382     if ( $user_exists ):
       
  1383     
       
  1384     echo '<table border="0" cellspacing="4" cellpadding="0" style="width: 100%;">';
       
  1385     echo '<tr><td style="width: 150px;" valign="top">';
       
  1386     
       
  1387     echo '<div class="tblholder">
       
  1388             <table border="0" cellspacing="1" cellpadding="4">';
       
  1389     
       
  1390     //
  1420     //
  1391     // Main part of sidebar
  1421     // BASIC INFORMATION
       
  1422     // Presentation of username/rank/avatar/basic info
  1392     //
  1423     //
  1393     
  1424     
  1394     // Basic user info
  1425     if ( $user_exists )
  1395     
  1426     {
  1396     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_basics', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
  1427     
  1397     
  1428       ?>
  1398     echo '<tr><td class="row1" style="text-align: center;">';
  1429       <div id="userpage_wrap">
  1399     if ( $userdata['user_has_avatar'] == '1' )
  1430         <ul id="userpage_links">
  1400     {
  1431           <li><a href="#tab:profile"><?php echo $lang->get('userpage_tab_profile'); ?></a></li>
  1401       echo '<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']) . '" /><br />';
  1432           <li><a href="#tab:content"><?php echo $lang->get('userpage_tab_content'); ?></a></li>
  1402     }
  1433           <?php
  1403     // username
  1434           $code = $plugins->setHook('userpage_tabs_links');
  1404     echo '<big><span style="' . $rank_data['rank_style'] . '">' . htmlspecialchars($target_username) . '</span></big><br />';
  1435           foreach ( $code as $cmd )
  1405     // user title, if appropriate
  1436           {
  1406     if ( $rank_data['user_title'] )
  1437             eval($cmd);
  1407       echo htmlspecialchars($rank_data['user_title']) . '<br />';
  1438           }
  1408     // rank
  1439           ?>
  1409     echo htmlspecialchars($lang->get($rank_data['rank_title']));
  1440         </ul>
  1410     echo '</td></tr>';
  1441         
  1411     echo '<tr><td class="row3">' . $lang->get('userpage_lbl_joined') . ' ' . enano_date('F d, Y h:i a', $userdata['reg_time']) . '</td></tr>';
  1442         <div id="tab:profile">
  1412     echo '<tr><td class="row1">' . $lang->get('userpage_lbl_num_comments') . ' ' . $userdata['n_comments'] . '</td></tr>';
  1443       
  1413     
  1444       <?php
  1414     if ( !empty($userdata['real_name']) )
  1445       
  1415     {
  1446       echo '<table border="0" cellspacing="0" cellpadding="0">
  1416       echo '<tr><td class="row3">' . $lang->get('userpage_lbl_real_name') . ' ' . $userdata['real_name'] . '</td></tr>';
  1447               <tr>';
  1417     }
  1448                 
  1418     
  1449       echo '    <td valign="top">';
  1419     // Administer user button
  1450       
  1420     
  1451       echo '<div class="tblholder">
  1421     if ( $session->user_level >= USER_LEVEL_ADMIN )
  1452               <table border="0" cellspacing="1" cellpadding="4">';
  1422     {
  1453               
  1423       echo '<tr><td class="row1"><a href="' . makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'UserManager&src=get&user=' . urlencode($target_username), true) . '" onclick="ajaxAdminUser(\'' . addslashes($target_username) . '\'); return false;">' . $lang->get('userpage_btn_administer_user') . '</a></td></tr>';
  1454       // heading
  1424     }
  1455       echo '    <tr>
  1425     
  1456                   <th colspan="' . ( $session->user_level >= USER_LEVEL_ADMIN ? '3' : '4' ) . '">
  1426     // Comments
  1457                     ' . $lang->get('userpage_heading_basics', array('username' => htmlspecialchars($target_username))) . '
  1427     
  1458                   </th>
  1428     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_comments', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
  1459                   ' . (
  1429     $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 5;');
  1460                     $session->user_level >= USER_LEVEL_ADMIN ?
  1430     if ( !$q )
  1461                     '<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>'
  1431       $db->_die();
  1462                       : ''
  1432     
  1463                   ) . '
  1433     $comments = Array();
  1464                 </tr>';
  1434     $no_comments = false;
  1465                 
  1435     
  1466       // avi/rank/username
  1436     if ( $row = $db->fetchrow() )
  1467       echo '    <tr>
  1437     {
  1468                   <td class="row3" colspan="4">
  1438       do 
  1469                     ' . (
  1439       {
  1470                         $userdata['user_has_avatar'] == 1 ?
  1440         $row['time'] = enano_date('F d, Y', $row['time']);
  1471                         '<div style="float: left; margin-right: 10px;">
  1441         $comments[] = $row;
  1472                           <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']) . '" />
  1442       }
  1473                          </div>'
  1443       while ( $row = $db->fetchrow() );
  1474                         : ''
  1444     }
  1475                       ) . '
  1445     else
  1476                       <span style="font-size: x-large; ' . $rank_data['rank_style'] . '">' . htmlspecialchars($userdata['username']) . '</span>
  1446     {
  1477                       ' . ( !empty($rank_data['user_title']) ? '<br />' . htmlspecialchars($rank_data['user_title']) : '' ) . '
  1447       $no_comments = true;
  1478                       ' . ( !empty($rank_data['rank_title']) ? '<br />' . htmlspecialchars($lang->get($rank_data['rank_title'])) : '' ) . '
  1448     }
  1479                   </td>
  1449     
  1480                 </tr>';
  1450     echo '<tr><td class="row3">';
  1481                 
  1451     echo '<div style="border: 1px solid #000000; padding: 0px; margin: 0; max-height: 200px; clip: rect(0px,auto,auto,0px); overflow: auto; background-color: transparent;" class="tblholder">';
  1482       // join date & total comments
  1452     
  1483       echo '<tr>';
  1453     echo '<table border="0" cellspacing="1" cellpadding="4">';
  1484       echo '  <td class="row2" style="text-align: right; width: 25%;">
  1454     $class = 'row1';
  1485                 ' . $lang->get('userpage_lbl_joined') . '
  1455     
       
  1456     $tpl = '<tr>
       
  1457               <td class="{CLASS}">
       
  1458                 <a href="{PAGE_LINK}" <!-- BEGINNOT page_exists -->class="wikilink-nonexistent"<!-- END page_exists -->>{PAGE}</a><br />
       
  1459                 <small>{lang:userpage_comments_lbl_posted} {DATE}<br /></small>
       
  1460                 <b><a href="{COMMENT_LINK}">{SUBJECT}</a></b>
       
  1461               </td>
  1486               </td>
  1462             </tr>';
  1487               <td class="row1" style="text-align: left; width: 25%;">
  1463     $parser = $template->makeParserText($tpl);
  1488                 ' . enano_date('F d, Y h:i a', $userdata['reg_time']) . '
  1464     
  1489               </td>';
  1465     if ( count($comments) > 0 )
  1490       echo '  <td class="row2" style="text-align: right; width: 25%;">
  1466     {
  1491                 ' . $lang->get('userpage_lbl_num_comments') . '
  1467       foreach ( $comments as $comment )
  1492               </td>
  1468       {
  1493               <td class="row1" style="text-align: left; width: 25%;">
  1469         $c_page_id = $paths->nslist[ $comment['namespace'] ] . sanitize_page_id($comment['page_id']);
  1494                 ' . $userdata['n_comments'] . '
  1470         if ( isset($paths->pages[ $c_page_id ]) )
  1495               </td>';
       
  1496       echo '</tr>';
       
  1497       
       
  1498       // real name
       
  1499       if ( !empty($userdata['real_name']) )
       
  1500       {
       
  1501         echo '<tr>
       
  1502                 <td class="row2" style="text-align: right;">
       
  1503                   ' . $lang->get('userpage_lbl_real_name') . '
       
  1504                 </td>
       
  1505                 <td class="row1" colspan="3" style="text-align: left;">
       
  1506                   ' . htmlspecialchars($userdata['real_name']) . '
       
  1507                 </td>
       
  1508               </tr>';
       
  1509       }
       
  1510                 
       
  1511       // latest comments
       
  1512       
       
  1513       echo '<tr><th class="subhead" colspan="4">' . $lang->get('userpage_heading_comments', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
       
  1514       $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;');
       
  1515       if ( !$q )
       
  1516         $db->_die();
       
  1517       
       
  1518       $comments = Array();
       
  1519       $no_comments = false;
       
  1520       
       
  1521       if ( $row = $db->fetchrow() )
       
  1522       {
       
  1523         do 
  1471         {
  1524         {
  1472           $parser->assign_bool(array(
  1525           $row['time'] = enano_date('F d, Y', $row['time']);
  1473             'page_exists' => true
  1526           $comments[] = $row;
       
  1527         }
       
  1528         while ( $row = $db->fetchrow() );
       
  1529       }
       
  1530       else
       
  1531       {
       
  1532         $no_comments = true;
       
  1533       }
       
  1534       
       
  1535       echo '<tr><td class="row3" colspan="4">';
       
  1536       echo '<div style="border: 1px solid #000000; padding: 0px; width: 100%; clip: rect(0px,auto,auto,0px); overflow: auto; background-color: transparent;" class="tblholder">';
       
  1537       
       
  1538       echo '<table border="0" cellspacing="1" cellpadding="4" style="width: 200%;"><tr>';
       
  1539       $class = 'row1';
       
  1540       
       
  1541       $tpl = '  <td class="{CLASS}">
       
  1542                   <a href="{PAGE_LINK}" <!-- BEGINNOT page_exists -->class="wikilink-nonexistent"<!-- END page_exists -->>{PAGE}</a><br />
       
  1543                   <small>{lang:userpage_comments_lbl_posted} {DATE}<br /></small>
       
  1544                   <b><a href="{COMMENT_LINK}">{SUBJECT}</a></b>
       
  1545                 </td>';
       
  1546       $parser = $template->makeParserText($tpl);
       
  1547       
       
  1548       if ( count($comments) > 0 )
       
  1549       {
       
  1550         foreach ( $comments as $comment )
       
  1551         {
       
  1552           $c_page_id = $paths->nslist[ $comment['namespace'] ] . sanitize_page_id($comment['page_id']);
       
  1553           if ( isset($paths->pages[ $c_page_id ]) )
       
  1554           {
       
  1555             $parser->assign_bool(array(
       
  1556               'page_exists' => true
       
  1557               ));
       
  1558             $page_title = htmlspecialchars($paths->pages[ $c_page_id ]['name']);
       
  1559           }
       
  1560           else
       
  1561           {
       
  1562             $parser->assign_bool(array(
       
  1563               'page_exists' => false
       
  1564               ));
       
  1565             $page_title = htmlspecialchars(dirtify_page_id($c_page_id));
       
  1566           }
       
  1567           $parser->assign_vars(array(
       
  1568               'CLASS' => $class,
       
  1569               'PAGE_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id'])),
       
  1570               'PAGE' => $page_title,
       
  1571               'SUBJECT' => $comment['subject'],
       
  1572               'DATE' => $comment['time'],
       
  1573               'COMMENT_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id']), 'do=comments', true)
  1474             ));
  1574             ));
  1475           $page_title = htmlspecialchars($paths->pages[ $c_page_id ]['name']);
  1575           $class = ( $class == 'row3' ) ? 'row1' : 'row3';
       
  1576           echo $parser->run();
  1476         }
  1577         }
  1477         else
  1578       }
  1478         {
  1579       else
  1479           $parser->assign_bool(array(
  1580       {
  1480             'page_exists' => false
  1581         echo '<td class="' . $class . '">' . $lang->get('userpage_msg_no_comments') . '</td>';
  1481             ));
  1582       }
  1482           $page_title = htmlspecialchars(dirtify_page_id($c_page_id));
  1583       echo '</tr></table>';
  1483         }
  1584       
  1484         $parser->assign_vars(array(
  1585       echo '</div>';
  1485             'CLASS' => $class,
  1586       echo '</td></tr>';
  1486             'PAGE_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id'])),
  1587       
  1487             'PAGE' => $page_title,
  1588       $code = $plugins->setHook('userpage_sidebar_left');
  1488             'SUBJECT' => $comment['subject'],
  1589       foreach ( $code as $cmd )
  1489             'DATE' => $comment['time'],
  1590       {
  1490             'COMMENT_LINK' => makeUrlNS($comment['namespace'], sanitize_page_id($comment['page_id']), 'do=comments', true)
  1591         eval($cmd);
  1491           ));
  1592       }
  1492         $class = ( $class == 'row3' ) ? 'row1' : 'row3';
  1593               
  1493         echo $parser->run();
  1594       echo '  </table>
  1494       }
  1595             </div>';
  1495     }
  1596             
  1496     else
  1597       echo '</td>';
  1497     {
  1598       
  1498       echo '<tr><td class="' . $class . '">' . $lang->get('userpage_msg_no_comments') . '</td></tr>';
  1599       //
  1499     }
  1600       // CONTACT INFORMATION
  1500     echo '</table>';
  1601       //
  1501     
  1602       
  1502     echo '</div>';
  1603       echo '    <td valign="top" style="width: 150px; padding-left: 10px;">';
  1503     echo '</td></tr>';
  1604       
  1504     
  1605       echo '<div class="tblholder">
  1505     $code = $plugins->setHook('userpage_sidebar_left');
  1606               <table border="0" cellspacing="1" cellpadding="4">';
  1506     foreach ( $code as $cmd )
  1607       
  1507     {
  1608       //
  1508       eval($cmd);
  1609       // Main part of sidebar
  1509     }
  1610       //
  1510     
  1611       
  1511     echo '  </table>
  1612       // Contact information
  1512           </div>';
  1613       
  1513     
  1614       echo '<tr><th class="subhead">' . $lang->get('userpage_heading_contact') . '</th></tr>';
  1514     echo '</td><td valign="top" style="padding: 0 10px;">';
  1615       
  1515     
  1616       $class = 'row3';
  1516     else:
  1617       
  1517     
  1618       if ( $userdata['email_public'] == 1 )
  1518     // Nothing for now
  1619       {
  1519     
  1620         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1520     endif;
  1621         $email_link = $email->encryptEmail($userdata['email']);
       
  1622         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_email') . ' ' . $email_link . '</td></tr>';
       
  1623       }
       
  1624       
       
  1625       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1626       if ( $session->user_logged_in )
       
  1627       {
       
  1628         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>';
       
  1629       }
       
  1630       else
       
  1631       {
       
  1632         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>';
       
  1633       }
       
  1634       
       
  1635       if ( !empty($userdata['user_aim']) )
       
  1636       {
       
  1637         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1638         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_aim') . ' ' . $userdata['user_aim'] . '</td></tr>';
       
  1639       }
       
  1640       
       
  1641       if ( !empty($userdata['user_yahoo']) )
       
  1642       {
       
  1643         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1644         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_yim') . ' ' . $userdata['user_yahoo'] . '</td></tr>';
       
  1645       }
       
  1646       
       
  1647       if ( !empty($userdata['user_msn']) )
       
  1648       {
       
  1649         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1650         $email_link = $email->encryptEmail($userdata['user_msn']);
       
  1651         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_wlm') . ' ' . $email_link . '</td></tr>';
       
  1652       }
       
  1653       
       
  1654       if ( !empty($userdata['user_xmpp']) )
       
  1655       {
       
  1656         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1657         $email_link = $email->encryptEmail($userdata['user_xmpp']);
       
  1658         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_xmpp') . ' ' . $email_link . '</td></tr>';
       
  1659       }
       
  1660       
       
  1661       // Real life
       
  1662       
       
  1663       echo '<tr><th class="subhead">' . $lang->get('userpage_heading_real_life', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
       
  1664       
       
  1665       if ( !empty($userdata['user_location']) )
       
  1666       {
       
  1667         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1668         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_location') . ' ' . $userdata['user_location'] . '</td></tr>';
       
  1669       }
       
  1670       
       
  1671       if ( !empty($userdata['user_job']) )
       
  1672       {
       
  1673         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1674         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_job') . ' ' . $userdata['user_job'] . '</td></tr>';
       
  1675       }
       
  1676       
       
  1677       if ( !empty($userdata['user_hobbies']) )
       
  1678       {
       
  1679         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1680         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_hobbies') . ' ' . $userdata['user_hobbies'] . '</td></tr>';
       
  1681       }
       
  1682       
       
  1683       if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
       
  1684       {
       
  1685         $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1686         echo '<tr><td class="'.$class.'">' . $lang->get('userpage_msg_no_contact_info', array('username' => htmlspecialchars($target_username))) . '</td></tr>';
       
  1687       }
       
  1688       
       
  1689       $code = $plugins->setHook('userpage_sidebar_right');
       
  1690       foreach ( $code as $cmd )
       
  1691       {
       
  1692         eval($cmd);
       
  1693       }
       
  1694       
       
  1695       echo '  </table>
       
  1696             </div>';
       
  1697       echo '</td>';
       
  1698       
       
  1699       //
       
  1700       // End of profile
       
  1701       //
       
  1702       
       
  1703       echo '</tr></table>';
       
  1704       
       
  1705       echo '</div>'; // tab:profile
       
  1706     
       
  1707     }
  1521     
  1708     
  1522     // User's own content
  1709     // User's own content
  1523     
  1710     
  1524     $send_headers = $this->send_headers;
  1711     $send_headers = $this->send_headers;
  1525     $this->send_headers = false;
  1712     $this->send_headers = false;
  1526     
  1713     
       
  1714     echo '<span class="menuclear"></span>';
       
  1715     
       
  1716     echo '<div id="tab:content">';
       
  1717     
  1527     if ( $this->page_exists )
  1718     if ( $this->page_exists )
  1528     {
  1719     {
  1529       $this->render();
  1720       $this->render();
  1530     }
  1721     }
  1531     else
  1722     else
  1532     {
  1723     {
  1533       $this->err_page_not_existent(true);
  1724       $this->err_page_not_existent(true);
  1534     }
  1725     }
  1535     
  1726     
  1536     // Right sidebar
  1727     echo '</div>'; // tab:content
  1537     
  1728     
  1538     if ( $user_exists ):
  1729     $code = $plugins->setHook('userpage_tabs_body');
  1539     
  1730     foreach ( $code as $cmd )
  1540     echo '</td><td style="width: 150px;" valign="top">';
  1731     {
  1541     
  1732       eval($cmd);
  1542     echo '<div class="tblholder">
  1733     }
  1543             <table border="0" cellspacing="1" cellpadding="4">';
  1734     
  1544     
  1735     if ( $user_exists )
  1545     //
  1736     {
  1546     // Main part of sidebar
  1737       echo '</div>'; // userpage_wrap
  1547     //
       
  1548     
       
  1549     // Contact information
       
  1550     
       
  1551     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_contact') . '</th></tr>';
       
  1552     
       
  1553     $class = 'row3';
       
  1554     
       
  1555     if ( $userdata['email_public'] == 1 )
       
  1556     {
       
  1557       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1558       $email_link = $email->encryptEmail($userdata['email']);
       
  1559       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_email') . ' ' . $email_link . '</td></tr>';
       
  1560     }
       
  1561     
       
  1562     $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1563     if ( $session->user_logged_in )
       
  1564     {
       
  1565       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>';
       
  1566     }
  1738     }
  1567     else
  1739     else
  1568     {
  1740     {
  1569       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>';
  1741       if ( !is_valid_ip($target_username) )
  1570     }
  1742       {
  1571     
  1743         echo '<p>' . $lang->get('userpage_msg_user_not_exist', array('username' => htmlspecialchars($target_username))) . '</p>';
  1572     if ( !empty($userdata['user_aim']) )
  1744       }
  1573     {
  1745     }
  1574       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1575       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_aim') . ' ' . $userdata['user_aim'] . '</td></tr>';
       
  1576     }
       
  1577     
       
  1578     if ( !empty($userdata['user_yahoo']) )
       
  1579     {
       
  1580       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1581       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_yim') . ' ' . $userdata['user_yahoo'] . '</td></tr>';
       
  1582     }
       
  1583     
       
  1584     if ( !empty($userdata['user_msn']) )
       
  1585     {
       
  1586       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1587       $email_link = $email->encryptEmail($userdata['user_msn']);
       
  1588       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_wlm') . ' ' . $email_link . '</td></tr>';
       
  1589     }
       
  1590     
       
  1591     if ( !empty($userdata['user_xmpp']) )
       
  1592     {
       
  1593       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1594       $email_link = $email->encryptEmail($userdata['user_xmpp']);
       
  1595       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_xmpp') . ' ' . $email_link . '</td></tr>';
       
  1596     }
       
  1597     
       
  1598     // Real life
       
  1599     
       
  1600     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_real_life', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
       
  1601     
       
  1602     if ( !empty($userdata['user_location']) )
       
  1603     {
       
  1604       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1605       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_location') . ' ' . $userdata['user_location'] . '</td></tr>';
       
  1606     }
       
  1607     
       
  1608     if ( !empty($userdata['user_job']) )
       
  1609     {
       
  1610       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1611       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_job') . ' ' . $userdata['user_job'] . '</td></tr>';
       
  1612     }
       
  1613     
       
  1614     if ( !empty($userdata['user_hobbies']) )
       
  1615     {
       
  1616       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1617       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_hobbies') . ' ' . $userdata['user_hobbies'] . '</td></tr>';
       
  1618     }
       
  1619     
       
  1620     if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
       
  1621     {
       
  1622       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
       
  1623       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_msg_no_contact_info', array('username' => htmlspecialchars($target_username))) . '</td></tr>';
       
  1624     }
       
  1625     
       
  1626     $code = $plugins->setHook('userpage_sidebar_right');
       
  1627     foreach ( $code as $cmd )
       
  1628     {
       
  1629       eval($cmd);
       
  1630     }
       
  1631     
       
  1632     echo '  </table>
       
  1633           </div>';
       
  1634           
       
  1635     echo '</tr></table>';
       
  1636     
       
  1637     else:
       
  1638     
       
  1639     if ( !is_valid_ip($target_username) )
       
  1640     {
       
  1641       echo '<p>' . $lang->get('userpage_msg_user_not_exist', array('username' => htmlspecialchars($target_username))) . '</p>';
       
  1642     }
       
  1643     
       
  1644     endif;
       
  1645     
  1746     
  1646     // if ( $send_headers )
  1747     // if ( $send_headers )
  1647     // {
  1748     // {
  1648     //  display_page_footers();
  1749     //  display_page_footers();
  1649     // }
  1750     // }
  1821   function err_page_not_existent($userpage = false)
  1922   function err_page_not_existent($userpage = false)
  1822   {
  1923   {
  1823     global $db, $session, $paths, $template, $plugins; // Common objects
  1924     global $db, $session, $paths, $template, $plugins; // Common objects
  1824     global $lang;
  1925     global $lang;
  1825     
  1926     
  1826     header('HTTP/1.1 404 Not Found');
  1927     @header('HTTP/1.1 404 Not Found');
  1827     
  1928     
  1828     $this->header();
  1929     $this->header();
  1829     $this->do_breadcrumbs();
  1930     $this->do_breadcrumbs();
  1830     
  1931     
  1831     $msg = $paths->sysmsg('Page_not_found');
  1932     $msg = $paths->sysmsg('Page_not_found');
  1836     }
  1937     }
  1837     else
  1938     else
  1838     {
  1939     {
  1839       if ( $userpage )
  1940       if ( $userpage )
  1840       {
  1941       {
  1841         echo '<h3>' . $lang->get('page_msg_404_title') . '</h3>
  1942         echo '<h3>' . $lang->get('page_msg_404_title_userpage') . '</h3>
  1842                <p>' . $lang->get('page_msg_404_body_userpage');
  1943                <p>' . $lang->get('page_msg_404_body_userpage');
  1843       }
  1944       }
  1844       else
  1945       else
  1845       {
  1946       {
  1846         echo '<h3>' . $lang->get('page_msg_404_title') . '</h3>
  1947         echo '<h3>' . $lang->get('page_msg_404_title') . '</h3>