includes/pageprocess.php
changeset 368 ed4f3ee072be
parent 345 4ccdfeee9a11
child 369 d0825e599853
equal deleted inserted replaced
367:ee4defc9321a 368:ed4f3ee072be
   671           $url = makeUrlNS($oldtarget[1], $oldtarget[0], 'redirect=no', true);
   671           $url = makeUrlNS($oldtarget[1], $oldtarget[0], 'redirect=no', true);
   672           $page_id_key = $paths->nslist[ $oldtarget[1] ] . $oldtarget[0];
   672           $page_id_key = $paths->nslist[ $oldtarget[1] ] . $oldtarget[0];
   673           $page_data = $paths->pages[$page_id_key];
   673           $page_data = $paths->pages[$page_id_key];
   674           $title = ( isset($page_data['name']) ) ? $page_data['name'] : $paths->nslist[$oldtarget[1]] . htmlspecialchars( str_replace('_', ' ', dirtify_page_id( $oldtarget[0] ) ) );
   674           $title = ( isset($page_data['name']) ) ? $page_data['name'] : $paths->nslist[$oldtarget[1]] . htmlspecialchars( str_replace('_', ' ', dirtify_page_id( $oldtarget[0] ) ) );
   675           $a = '<a href="' . $url . '">' . $title . '</a>';
   675           $a = '<a href="' . $url . '">' . $title . '</a>';
   676           echo '<small>(Redirected from ' . $a . ')<br /></small>';
   676           echo '<small>' . $lang->get('page_msg_redirected_from', array('from' => $a)) . '<br /></small>';
   677         }
   677         }
   678       }
   678       }
   679       display_page_headers();
   679       display_page_headers();
   680     }
   680     }
   681     
   681     
   682     if ( $this->revision_id )
   682     if ( $this->revision_id )
   683     {
   683     {
   684       echo '<div class="info-box" style="margin-left: 0; margin-top: 5px;"><b>Notice:</b><br />The page you are viewing was archived on '.enano_date('F d, Y \a\t h:i a', $this->revision_id).'.<br /><a href="'.makeUrlNS($this->namespace, $this->page_id).'" onclick="ajaxReset(); return false;">View current version</a>  |  <a href="'.makeUrlNS($this->namespace, $this->page_id, 'do=rollback&amp;id='.$this->revision_id).'" onclick="ajaxRollback(\''.$this->revision_id.'\')">Restore this version</a></div><br />';
   684       echo '<div class="info-box" style="margin-left: 0; margin-top: 5px;">
       
   685               <b>' . $lang->get('page_msg_archived_title') . '</b><br />
       
   686               ' . $lang->get('page_msg_archived_body', array(
       
   687                   'archive_date' => enano_date('F d, Y', $this->revision_id),
       
   688                   'archive_time' => enano_date('h:i a', $this->revision_id),
       
   689                   'current_link' => makeUrlNS($this->namespace, $this->page_id),
       
   690                   'restore_link' => makeUrlNS($this->namespace, $this->page_id, 'do=rollback&amp;id='.$this->revision_id),
       
   691                   'restore_onclick' => 'ajaxRollback(\''.$this->revision_id.'\'); return false;',
       
   692                 )) . '
       
   693             </div>
       
   694             <br />';
   685     }
   695     }
   686     
   696     
   687     if ( $redir_enabled )
   697     if ( $redir_enabled )
   688     {
   698     {
   689       echo $redir_html;
   699       echo $redir_html;
   946     // Main part of sidebar
   956     // Main part of sidebar
   947     //
   957     //
   948     
   958     
   949     // Basic user info
   959     // Basic user info
   950     
   960     
   951     echo '<tr><th class="subhead">All about ' . htmlspecialchars($target_username) . '</th></tr>';
   961     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_basics', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
   952     if ( $userdata['user_has_avatar'] == '1' )
   962     if ( $userdata['user_has_avatar'] == '1' )
   953     {
   963     {
   954       echo '<tr><td class="row1" style="text-align: center;"><img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $userdata['username'])) . '" src="' . make_avatar_url(intval($userdata['authoritative_uid']), $userdata['avatar_type']) . '" /></td></tr>';
   964       echo '<tr><td class="row1" style="text-align: center;"><img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $userdata['username'])) . '" src="' . make_avatar_url(intval($userdata['authoritative_uid']), $userdata['avatar_type']) . '" /></td></tr>';
   955     }
   965     }
   956     echo '<tr><td class="row3">Joined: ' . enano_date('F d, Y h:i a', $userdata['reg_time']) . '</td></tr>';
   966     echo '<tr><td class="row3">' . $lang->get('userpage_lbl_joined') . ' ' . enano_date('F d, Y h:i a', $userdata['reg_time']) . '</td></tr>';
   957     echo '<tr><td class="row1">Total comments: ' . $userdata['n_comments'] . '</td></tr>';
   967     echo '<tr><td class="row1">' . $lang->get('userpage_lbl_num_comments') . ' ' . $userdata['n_comments'] . '</td></tr>';
   958     
   968     
   959     if ( !empty($userdata['real_name']) )
   969     if ( !empty($userdata['real_name']) )
   960     {
   970     {
   961       echo '<tr><td class="row3">Real name: ' . $userdata['real_name'] . '</td></tr>';
   971       echo '<tr><td class="row3">' . $lang->get('userpage_lbl_real_name') . ' ' . $userdata['real_name'] . '</td></tr>';
   962     }
   972     }
   963     
   973     
   964     // Administer user button
   974     // Administer user button
   965     
   975     
   966     if ( $session->user_level >= USER_LEVEL_ADMIN )
   976     if ( $session->user_level >= USER_LEVEL_ADMIN )
   967     {
   977     {
   968       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;">Administer user</a></td></tr>';
   978       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>';
   969     }
   979     }
   970     
   980     
   971     // Comments
   981     // Comments
   972     
   982     
   973     echo '<tr><th class="subhead">' . htmlspecialchars($target_username) . '\'s latest comments</th></tr>';
   983     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_comments', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
   974     $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;');
   984     $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;');
   975     if ( !$q )
   985     if ( !$q )
   976       $db->_die();
   986       $db->_die();
   977     
   987     
   978     $comments = Array();
   988     $comments = Array();
   999     $class = 'row1';
  1009     $class = 'row1';
  1000     
  1010     
  1001     $tpl = '<tr>
  1011     $tpl = '<tr>
  1002               <td class="{CLASS}">
  1012               <td class="{CLASS}">
  1003                 <a href="{PAGE_LINK}" <!-- BEGINNOT page_exists -->class="wikilink-nonexistent"<!-- END page_exists -->>{PAGE}</a><br />
  1013                 <a href="{PAGE_LINK}" <!-- BEGINNOT page_exists -->class="wikilink-nonexistent"<!-- END page_exists -->>{PAGE}</a><br />
  1004                 <small>Posted {DATE}<br /></small>
  1014                 <small>{lang:userpage_comments_lbl_posted} {DATE}<br /></small>
  1005                 <b><a href="{COMMENT_LINK}">{SUBJECT}</a></b>
  1015                 <b><a href="{COMMENT_LINK}">{SUBJECT}</a></b>
  1006               </td>
  1016               </td>
  1007             </tr>';
  1017             </tr>';
  1008     $parser = $template->makeParserText($tpl);
  1018     $parser = $template->makeParserText($tpl);
  1009     
  1019     
  1038         echo $parser->run();
  1048         echo $parser->run();
  1039       }
  1049       }
  1040     }
  1050     }
  1041     else
  1051     else
  1042     {
  1052     {
  1043       echo '<tr><td class="' . $class . '">This user has not posted any comments.</td></tr>';
  1053       echo '<tr><td class="' . $class . '">' . $lang->get('userpage_msg_no_comments') . '</td></tr>';
  1044     }
  1054     }
  1045     echo '</table>';
  1055     echo '</table>';
  1046     
  1056     
  1047     echo '</div>';
  1057     echo '</div>';
  1048     echo '</td></tr>';
  1058     echo '</td></tr>';
  1091     // Main part of sidebar
  1101     // Main part of sidebar
  1092     //
  1102     //
  1093     
  1103     
  1094     // Contact information
  1104     // Contact information
  1095     
  1105     
  1096     echo '<tr><th class="subhead">Get in touch</th></tr>';
  1106     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_contact') . '</th></tr>';
  1097     
  1107     
  1098     $class = 'row3';
  1108     $class = 'row3';
  1099     
  1109     
  1100     if ( $userdata['email_public'] == 1 )
  1110     if ( $userdata['email_public'] == 1 )
  1101     {
  1111     {
  1102       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1112       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1103       $email_link = $email->encryptEmail($userdata['email']);
  1113       $email_link = $email->encryptEmail($userdata['email']);
  1104       echo '<tr><td class="'.$class.'">E-mail address: ' . $email_link . '</td></tr>';
  1114       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_email') . ' ' . $email_link . '</td></tr>';
  1105     }
  1115     }
  1106     
  1116     
  1107     $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1117     $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1108     if ( $session->user_logged_in )
  1118     if ( $session->user_logged_in )
  1109     {
  1119     {
  1110       echo '<tr><td class="'.$class.'">Send ' . htmlspecialchars($target_username) . ' a <a href="' . makeUrlNS('Special', 'PrivateMessages/Compose/to/' . $this->page_id, false, true) . '">Private Message</a>!</td></tr>';
  1120       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>';
  1111     }
  1121     }
  1112     else
  1122     else
  1113     {
  1123     {
  1114       echo '<tr><td class="'.$class.'">You could send ' . htmlspecialchars($target_username) . ' a private message if you were <a href="' . makeUrlNS('Special', 'Login/' . $paths->nslist[$this->namespace] . $this->page_id) . '">logged in</a>.</td></tr>';
  1124       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>';
  1115     }
  1125     }
  1116     
  1126     
  1117     if ( !empty($userdata['user_aim']) )
  1127     if ( !empty($userdata['user_aim']) )
  1118     {
  1128     {
  1119       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1129       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1120       echo '<tr><td class="'.$class.'">AIM: ' . $userdata['user_aim'] . '</td></tr>';
  1130       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_aim') . ' ' . $userdata['user_aim'] . '</td></tr>';
  1121     }
  1131     }
  1122     
  1132     
  1123     if ( !empty($userdata['user_yahoo']) )
  1133     if ( !empty($userdata['user_yahoo']) )
  1124     {
  1134     {
  1125       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1135       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1126       echo '<tr><td class="'.$class.'">Yahoo! IM: ' . $userdata['user_yahoo'] . '</td></tr>';
  1136       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_yim') . ' ' . $userdata['user_yahoo'] . '</td></tr>';
  1127     }
  1137     }
  1128     
  1138     
  1129     if ( !empty($userdata['user_msn']) )
  1139     if ( !empty($userdata['user_msn']) )
  1130     {
  1140     {
  1131       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1141       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1132       $email_link = $email->encryptEmail($userdata['user_msn']);
  1142       $email_link = $email->encryptEmail($userdata['user_msn']);
  1133       echo '<tr><td class="'.$class.'">WLM: ' . $email_link . '</td></tr>';
  1143       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_wlm') . ' ' . $email_link . '</td></tr>';
  1134     }
  1144     }
  1135     
  1145     
  1136     if ( !empty($userdata['user_xmpp']) )
  1146     if ( !empty($userdata['user_xmpp']) )
  1137     {
  1147     {
  1138       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1148       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1139       $email_link = $email->encryptEmail($userdata['user_xmpp']);
  1149       $email_link = $email->encryptEmail($userdata['user_xmpp']);
  1140       echo '<tr><td class="'.$class.'">XMPP/Jabber: ' . $email_link . '</td></tr>';
  1150       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_xmpp') . ' ' . $email_link . '</td></tr>';
  1141     }
  1151     }
  1142     
  1152     
  1143     // Real life
  1153     // Real life
  1144     
  1154     
  1145     echo '<tr><th class="subhead">' . htmlspecialchars($target_username) . ' in real life</th></tr>';
  1155     echo '<tr><th class="subhead">' . $lang->get('userpage_heading_real_life', array('username' => htmlspecialchars($target_username))) . '</th></tr>';
  1146     
  1156     
  1147     if ( !empty($userdata['user_location']) )
  1157     if ( !empty($userdata['user_location']) )
  1148     {
  1158     {
  1149       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1159       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1150       echo '<tr><td class="'.$class.'">Location: ' . $userdata['user_location'] . '</td></tr>';
  1160       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_location') . ' ' . $userdata['user_location'] . '</td></tr>';
  1151     }
  1161     }
  1152     
  1162     
  1153     if ( !empty($userdata['user_job']) )
  1163     if ( !empty($userdata['user_job']) )
  1154     {
  1164     {
  1155       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1165       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1156       echo '<tr><td class="'.$class.'">Job/occupation: ' . $userdata['user_job'] . '</td></tr>';
  1166       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_job') . ' ' . $userdata['user_job'] . '</td></tr>';
  1157     }
  1167     }
  1158     
  1168     
  1159     if ( !empty($userdata['user_hobbies']) )
  1169     if ( !empty($userdata['user_hobbies']) )
  1160     {
  1170     {
  1161       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1171       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1162       echo '<tr><td class="'.$class.'">Enjoys: ' . $userdata['user_hobbies'] . '</td></tr>';
  1172       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_lbl_hobbies') . ' ' . $userdata['user_hobbies'] . '</td></tr>';
  1163     }
  1173     }
  1164     
  1174     
  1165     if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
  1175     if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) )
  1166     {
  1176     {
  1167       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1177       $class = ( $class == 'row1' ) ? 'row3' : 'row1';
  1168       echo '<tr><td class="'.$class.'">' . htmlspecialchars($target_username) . ' hasn\'t posted any real-life contact information.</td></tr>';
  1178       echo '<tr><td class="'.$class.'">' . $lang->get('userpage_msg_no_contact_info', array('username' => htmlspecialchars($target_username))) . '</td></tr>';
  1169     }
  1179     }
  1170     
  1180     
  1171     $code = $plugins->setHook('userpage_sidebar_right');
  1181     $code = $plugins->setHook('userpage_sidebar_right');
  1172     foreach ( $code as $cmd )
  1182     foreach ( $code as $cmd )
  1173     {
  1183     {
  1179           
  1189           
  1180     echo '</tr></table>';
  1190     echo '</tr></table>';
  1181     
  1191     
  1182     else:
  1192     else:
  1183     
  1193     
  1184     echo '<p>Additional information: user "' . htmlspecialchars($target_username) . '" does not exist.</p>';
  1194     if ( !is_valid_ip($target_username) )
       
  1195     {
       
  1196       echo '<p>' . $lang->get('userpage_msg_user_not_exist', array('username' => htmlspecialchars($target_username))) . '</p>';
       
  1197     }
  1185     
  1198     
  1186     endif;
  1199     endif;
  1187     
  1200     
  1188     // if ( $send_headers )
  1201     // if ( $send_headers )
  1189     // {
  1202     // {