includes/pageutils.php
changeset 213 1316404e4ea8
parent 204 473cc747022a
child 214 a6ed8b6cdbe1
equal deleted inserted replaced
212:30b857a6b811 213:1316404e4ea8
   519    */
   519    */
   520   
   520   
   521   function histlist($page_id, $namespace)
   521   function histlist($page_id, $namespace)
   522   {
   522   {
   523     global $db, $session, $paths, $template, $plugins; // Common objects
   523     global $db, $session, $paths, $template, $plugins; // Common objects
       
   524     global $lang;
   524     
   525     
   525     if(!$session->get_permissions('history_view'))
   526     if(!$session->get_permissions('history_view'))
   526       return 'Access denied';
   527       return 'Access denied';
   527     
   528     
   528     ob_start();
   529     ob_start();
   531     $wiki = ( ( $paths->pages[$pname]['wiki_mode'] == 2 && getConfig('wiki_mode') == '1') || $paths->pages[$pname]['wiki_mode'] == 1) ? true : false;
   532     $wiki = ( ( $paths->pages[$pname]['wiki_mode'] == 2 && getConfig('wiki_mode') == '1') || $paths->pages[$pname]['wiki_mode'] == 1) ? true : false;
   532     $prot = ( ( $paths->pages[$pname]['protected'] == 2 && $session->user_logged_in && $session->reg_time + 60*60*24*4 < time() ) || $paths->pages[$pname]['protected'] == 1) ? true : false;
   533     $prot = ( ( $paths->pages[$pname]['protected'] == 2 && $session->user_logged_in && $session->reg_time + 60*60*24*4 < time() ) || $paths->pages[$pname]['protected'] == 1) ? true : false;
   533     
   534     
   534     $q = 'SELECT time_id,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action=\'edit\' AND page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' ORDER BY time_id DESC;';
   535     $q = 'SELECT time_id,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action=\'edit\' AND page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' ORDER BY time_id DESC;';
   535     if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
   536     if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
   536     echo 'History of edits and actions<h3>Edits:</h3>';
   537     echo $lang->get('history_page_subtitle') . '
       
   538           <h3>' . $lang->get('history_heading_edits') . '</h3>';
   537     $numrows = $db->numrows();
   539     $numrows = $db->numrows();
   538     if($numrows < 1) echo 'No history entries in this category.';
   540     if ( $numrows < 1 )
       
   541     {
       
   542       echo $lang->get('history_no_entries');
       
   543     }
   539     else
   544     else
   540     {
   545     {
   541       
       
   542       echo '<form action="'.makeUrlNS($namespace, $page_id, 'do=diff').'" onsubmit="ajaxHistDiff(); return false;" method="get">
   546       echo '<form action="'.makeUrlNS($namespace, $page_id, 'do=diff').'" onsubmit="ajaxHistDiff(); return false;" method="get">
   543             <input type="submit" value="Compare selected revisions" />
   547             <input type="submit" value="' . $lang->get('history_btn_compare') . '" />
   544             ' . ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars($paths->nslist[$namespace] . $page_id) . '" />' : '' ) . '
   548             ' . ( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars($paths->nslist[$namespace] . $page_id) . '" />' : '' ) . '
   545             ' . ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : '') . '
   549             ' . ( $session->sid_super ? '<input type="hidden" name="auth"  value="' . $session->sid_super . '" />' : '') . '
   546             <input type="hidden" name="do" value="diff" />
   550             <input type="hidden" name="do" value="diff" />
   547             <br /><span>&nbsp;</span>
   551             <br /><span>&nbsp;</span>
   548             <div class="tblholder">
   552             <div class="tblholder">
   549             <table border="0" width="100%" cellspacing="1" cellpadding="4">
   553             <table border="0" width="100%" cellspacing="1" cellpadding="4">
   550             <tr>
   554             <tr>
   551               <th colspan="2">Diff</th>
   555               <th colspan="2">' . $lang->get('history_col_diff') . '</th>
   552               <th>Date/time</th>
   556               <th>' . $lang->get('history_col_datetime') . '</th>
   553               <th>User</th>
   557               <th>' . $lang->get('history_col_user') . '</th>
   554               <th>Edit summary</th>
   558               <th>' . $lang->get('history_col_summary') . '</th>
   555               <th>Minor</th>
   559               <th>' . $lang->get('history_col_minor') . '</th>
   556               <th colspan="3">Actions</th>
   560               <th colspan="3">' . $lang->get('history_col_actions') . '</th>
   557             </tr>'."\n"."\n";
   561             </tr>'."\n"."\n";
   558       $cls = 'row2';
   562       $cls = 'row2';
   559       $ticker = 0;
   563       $ticker = 0;
   560       
   564       
   561       while($r = $db->fetchrow()) {
   565       while ( $r = $db->fetchrow() )
       
   566       {
   562         
   567         
   563         $ticker++;
   568         $ticker++;
   564         
   569         
   565         if($cls == 'row2') $cls = 'row1';
   570         if($cls == 'row2') $cls = 'row1';
   566         else $cls = 'row2';
   571         else $cls = 'row2';
   590         echo '<td class="' . $cls . '">' . $r['date_string'] . '</td class="' . $cls . '">'."\n";
   595         echo '<td class="' . $cls . '">' . $r['date_string'] . '</td class="' . $cls . '">'."\n";
   591         
   596         
   592         // User
   597         // User
   593         if ( $session->get_permissions('mod_misc') && is_valid_ip($r['author']) )
   598         if ( $session->get_permissions('mod_misc') && is_valid_ip($r['author']) )
   594         {
   599         {
   595           $rc = ' style="cursor: pointer;" title="Click cell background for reverse DNS info" onclick="ajaxReverseDNS(this, \'' . $r['author'] . '\');"';
   600           $rc = ' style="cursor: pointer;" title="' . $lang->get('history_tip_rdns') . '" onclick="ajaxReverseDNS(this, \'' . $r['author'] . '\');"';
   596         }
   601         }
   597         else
   602         else
   598         {
   603         {
   599           $rc = '';
   604           $rc = '';
   600         }
   605         }
   604           echo 'class="wikilink-nonexistent"';
   609           echo 'class="wikilink-nonexistent"';
   605         }
   610         }
   606         echo '>' . $r['author'] . '</a></td class="' . $cls . '">'."\n";
   611         echo '>' . $r['author'] . '</a></td class="' . $cls . '">'."\n";
   607         
   612         
   608         // Edit summary
   613         // Edit summary
       
   614         if ( $r['edit_summary'] == 'Automatic backup created when logs were purged' )
       
   615         {
       
   616           $r['edit_summary'] = $lang->get('history_summary_clearlogs');
       
   617         }
   609         echo '<td class="' . $cls . '">' . $r['edit_summary'] . '</td>'."\n";
   618         echo '<td class="' . $cls . '">' . $r['edit_summary'] . '</td>'."\n";
   610         
   619         
   611         // Minor edit
   620         // Minor edit
   612         echo '<td class="' . $cls . '" style="text-align: center;">'. (( $r['minor_edit'] ) ? 'M' : '' ) .'</td>'."\n";
   621         echo '<td class="' . $cls . '" style="text-align: center;">'. (( $r['minor_edit'] ) ? 'M' : '' ) .'</td>'."\n";
   613         
   622         
   614         // Actions!
   623         // Actions!
   615         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrlNS($namespace, $page_id, 'oldid=' . $r['time_id']) . '" onclick="ajaxHistView(\'' . $r['time_id'] . '\'); return false;">View revision</a></td>'."\n";
   624         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrlNS($namespace, $page_id, 'oldid=' . $r['time_id']) . '" onclick="ajaxHistView(\'' . $r['time_id'] . '\'); return false;">' . $lang->get('history_action_view') . '</a></td>'."\n";
   616         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrl($paths->nslist['Special'].'Contributions/' . $r['author']) . '">View user contribs</a></td>'."\n";
   625         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrl($paths->nslist['Special'].'Contributions/' . $r['author']) . '">' . $lang->get('history_action_contrib') . '</a></td>'."\n";
   617         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrlNS($namespace, $page_id, 'do=rollback&amp;id=' . $r['time_id']) . '" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">Revert to this revision</a></td>'."\n";
   626         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrlNS($namespace, $page_id, 'do=rollback&amp;id=' . $r['time_id']) . '" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">' . $lang->get('history_action_restore') . '</a></td>'."\n";
   618         
   627         
   619         echo '</tr>'."\n"."\n";
   628         echo '</tr>'."\n"."\n";
   620         
   629         
   621       }
   630       }
   622       echo '</table>
   631       echo '</table>
   623             </div>
   632             </div>
   624             <br />
   633             <br />
   625             <input type="hidden" name="do" value="diff" />
   634             <input type="hidden" name="do" value="diff" />
   626             <input type="submit" value="Compare selected revisions" />
   635             <input type="submit" value="' . $lang->get('history_btn_compare') . '" />
   627             </form>
   636             </form>
   628             <script type="text/javascript">if ( !KILL_SWITCH ) { buildDiffList(); }</script>';
   637             <script type="text/javascript">if ( !KILL_SWITCH ) { buildDiffList(); }</script>';
   629     }
   638     }
   630     $db->free_result();
   639     $db->free_result();
   631     echo '<h3>Other changes:</h3>';
   640     echo '<h3>' . $lang->get('history_heading_other') . '</h3>';
   632     $q = 'SELECT time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action!=\'edit\' AND page_id=\'' . $paths->cpage['urlname_nons'] . '\' AND namespace=\'' . $paths->namespace . '\' ORDER BY time_id DESC;';
   641     $q = 'SELECT time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action!=\'edit\' AND page_id=\'' . $paths->cpage['urlname_nons'] . '\' AND namespace=\'' . $paths->namespace . '\' ORDER BY time_id DESC;';
   633     if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
   642     if ( !$db->sql_query($q) )
   634     if($db->numrows() < 1) echo 'No history entries in this category.';
   643     {
   635     else {
   644       $db->_die('The history data for the page "' . htmlspecialchars($paths->cpage['name']) . '" could not be selected.');
       
   645     }
       
   646     if ( $db->numrows() < 1 )
       
   647     {
       
   648       echo $lang->get('history_no_entries');
       
   649     }
       
   650     else
       
   651     {
   636       
   652       
   637       echo '<div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4"><tr><th>Date/time</th><th>User</th><th>Minor</th><th>Action taken</th><th>Extra info</th><th colspan="2"></th></tr>';
   653       echo '<div class="tblholder">
       
   654               <table border="0" width="100%" cellspacing="1" cellpadding="4"><tr>
       
   655                 <th>' . $lang->get('history_col_datetime') . '</th>
       
   656                 <th>' . $lang->get('history_col_user') . '</th>
       
   657                 <th>' . $lang->get('history_col_minor') . '</th>
       
   658                 <th>' . $lang->get('history_col_action_taken') . '</th>
       
   659                 <th>' . $lang->get('history_col_extra') . '</th>
       
   660                 <th colspan="2"></th>
       
   661               </tr>';
   638       $cls = 'row2';
   662       $cls = 'row2';
   639       while($r = $db->fetchrow()) {
   663       while($r = $db->fetchrow()) {
   640         
   664         
   641         if($cls == 'row2') $cls = 'row1';
   665         if($cls == 'row2') $cls = 'row1';
   642         else $cls = 'row2';
   666         else $cls = 'row2';
   656         echo '<td class="' . $cls . '" style="text-align: center;">'. (( $r['minor_edit'] ) ? 'M' : '' ) .'</td>';
   680         echo '<td class="' . $cls . '" style="text-align: center;">'. (( $r['minor_edit'] ) ? 'M' : '' ) .'</td>';
   657         
   681         
   658         // Action taken
   682         // Action taken
   659         echo '<td class="' . $cls . '">';
   683         echo '<td class="' . $cls . '">';
   660         // Some of these are sanitized at insert-time. Others follow the newer Enano policy of stripping HTML at runtime.
   684         // Some of these are sanitized at insert-time. Others follow the newer Enano policy of stripping HTML at runtime.
   661         if    ($r['action']=='prot')     echo 'Protected page</td><td class="' . $cls . '">Reason: ' . $r['edit_summary'];
   685         if    ($r['action']=='prot')     echo $lang->get('history_log_protect') . '</td><td class="' . $cls . '">' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary'];
   662         elseif($r['action']=='unprot')   echo 'Unprotected page</td><td class="' . $cls . '">Reason: ' . $r['edit_summary'];
   686         elseif($r['action']=='unprot')   echo $lang->get('history_log_unprotect') . '</td><td class="' . $cls . '">' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary'];
   663         elseif($r['action']=='semiprot') echo 'Semi-protected page</td><td class="' . $cls . '">Reason: ' . $r['edit_summary'];
   687         elseif($r['action']=='semiprot') echo $lang->get('history_log_semiprotect') . '</td><td class="' . $cls . '">' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary'];
   664         elseif($r['action']=='rename')   echo 'Renamed page</td><td class="' . $cls . '">Old title: '.htmlspecialchars($r['edit_summary']);
   688         elseif($r['action']=='rename')   echo $lang->get('history_log_rename') . '</td><td class="' . $cls . '">' . $lang->get('history_extra_oldtitle') . ' '.htmlspecialchars($r['edit_summary']);
   665         elseif($r['action']=='create')   echo 'Created page</td><td class="' . $cls . '">';
   689         elseif($r['action']=='create')   echo $lang->get('history_log_create') . '</td><td class="' . $cls . '">';
   666         elseif($r['action']=='delete')   echo 'Deleted page</td><td class="' . $cls . '">Reason: ' . $r['edit_summary'];
   690         elseif($r['action']=='delete')   echo $lang->get('history_log_delete') . '</td><td class="' . $cls . '">' . $lang->get('history_extra_reason') . ' ' . $r['edit_summary'];
   667         elseif($r['action']=='reupload') echo 'Uploaded new file version</td><td class="' . $cls . '">Reason: '.htmlspecialchars($r['edit_summary']);
   691         elseif($r['action']=='reupload') echo $lang->get('history_log_uploadnew') . '</td><td class="' . $cls . '">' . $lang->get('history_extra_reason') . ' '.htmlspecialchars($r['edit_summary']);
   668         echo '</td>';
   692         echo '</td>';
   669         
   693         
   670         // Actions!
   694         // Actions!
   671         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrl($paths->nslist['Special'].'Contributions/' . $r['author']) . '">View user contribs</a></td>';
   695         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrl($paths->nslist['Special'].'Contributions/' . $r['author']) . '">' . $lang->get('history_action_contrib') . '</a></td>';
   672         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrlNS($namespace, $page_id, 'do=rollback&amp;id=' . $r['time_id']) . '" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">Revert action</a></td>';
   696         echo '<td class="' . $cls . '" style="text-align: center;"><a href="'.makeUrlNS($namespace, $page_id, 'do=rollback&amp;id=' . $r['time_id']) . '" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">' . $lang->get('history_action_revert') . '</a></td>';
   673         
       
   674         //echo '(<a href="#" onclick="ajaxRollback(\'' . $r['time_id'] . '\'); return false;">rollback</a>) <i>' . $r['date_string'] . '</i> ' . $r['author'] . ' (<a href="'.makeUrl($paths->nslist['User'].$r['author']).'">Userpage</a>, <a href="'.makeUrl($paths->nslist['Special'].'Contributions/' . $r['author']) . '">Contrib</a>): ';
       
   675         
       
   676         if($r['minor_edit']) echo '<b> - minor edit</b>';
       
   677         echo '<br />';
       
   678         
   697         
   679         echo '</tr>';
   698         echo '</tr>';
   680       }
   699       }
   681       echo '</table></div>';
   700       echo '</table></div>';
   682     }
   701     }
   895    */
   914    */
   896    
   915    
   897   function comments_raw($page_id, $namespace, $action = false, $flags = Array(), $_ob = '')
   916   function comments_raw($page_id, $namespace, $action = false, $flags = Array(), $_ob = '')
   898   {
   917   {
   899     global $db, $session, $paths, $template, $plugins; // Common objects
   918     global $db, $session, $paths, $template, $plugins; // Common objects
       
   919     global $lang;
   900     
   920     
   901     $pname = $paths->nslist[$namespace] . $page_id;
   921     $pname = $paths->nslist[$namespace] . $page_id;
   902     
   922     
   903     ob_start();
   923     ob_start();
   904     
   924     
   935         $db->free_result();
   955         $db->free_result();
   936         $a = ( $r['approved'] ) ? '0' : '1';
   956         $a = ( $r['approved'] ) ? '0' : '1';
   937         $q = 'UPDATE ' . table_prefix.'comments SET approved=' . $a . ' WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' AND ' . $where . ';';
   957         $q = 'UPDATE ' . table_prefix.'comments SET approved=' . $a . ' WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\' AND ' . $where . ';';
   938         $e=$db->sql_query($q);
   958         $e=$db->sql_query($q);
   939         if(!$e) die('alert(unesape(\''.rawurlencode('Error during query: '.mysql_error().'\n\nQuery:\n' . $q) . '\'));');
   959         if(!$e) die('alert(unesape(\''.rawurlencode('Error during query: '.mysql_error().'\n\nQuery:\n' . $q) . '\'));');
   940         if($a=='1') $v = 'Unapprove';
   960         if($a=='1') $v = $lang->get('comment_btn_mod_unapprove');
   941         else $v = 'Approve';
   961         else $v = $lang->get('comment_btn_mod_approve');
   942         echo 'document.getElementById("mdgApproveLink'.intval($_GET['id']).'").innerHTML="' . $v . '";';
   962         echo 'document.getElementById("mdgApproveLink'.intval($_GET['id']).'").innerHTML="' . $v . '";';
   943         break;
   963         break;
   944       }
   964       }
   945     }
   965     }
   946     
   966     
   964                   LEFT JOIN ' . table_prefix.'users AS u
   984                   LEFT JOIN ' . table_prefix.'users AS u
   965                     ON c.user_id=u.user_id
   985                     ON c.user_id=u.user_id
   966                   WHERE page_id=\'' . $page_id . '\'
   986                   WHERE page_id=\'' . $page_id . '\'
   967                   AND namespace=\'' . $namespace . '\' ORDER BY c.time ASC;');
   987                   AND namespace=\'' . $namespace . '\' ORDER BY c.time ASC;');
   968     if(!$lq) _die('The comment text data could not be selected. '.mysql_error());
   988     if(!$lq) _die('The comment text data could not be selected. '.mysql_error());
   969     $_ob .= '<h3>Article Comments</h3>';
   989     $_ob .= '<h3>' . $lang->get('comment_heading') . '</h3>';
       
   990     
   970     $n = ( $session->get_permissions('mod_comments')) ? $db->numrows() : $num_app;
   991     $n = ( $session->get_permissions('mod_comments')) ? $db->numrows() : $num_app;
   971     if($n==1) $s = 'is ' . $n . ' comment'; else $s = 'are ' . $n . ' comments';
   992     
   972     if($n < 1)
   993     $subst = array(
   973     {
   994         'num_comments' => $n,
   974       $_ob .= '<p>There are currently no comments on this '.strtolower($namespace).'';
   995         'page_type' => '&lt;FIXME&gt; whatever'
   975       if($namespace != 'Article') $_ob .= ' page';
   996       );
   976       $_ob .= '.</p>';
   997     
   977     } else $_ob .= '<p>There ' . $s . ' on this article.';
   998     $_ob .= '<p>';
   978     if($session->get_permissions('mod_comments') && $num_unapp > 0) $_ob .= ' <span style="color: #D84308">' . $num_unapp . ' of those are unapproved.</span>';
   999     $_ob .= ( $n == 0 ) ? $lang->get('comment_msg_count_zero', $subst) : ( $n == 1 ? $lang->get('comment_msg_count_one', $subst) : $lang->get('comment_msg_count_plural', $subst) );
   979     elseif(!$session->get_permissions('mod_comments') && $num_unapp > 0) { $u = ($num_unapp == 1) ? "is $num_unapp comment" : "are $num_unapp comments"; $_ob .= ' However, there ' . $u . ' awating approval.'; }
  1000     
       
  1001     if ( $session->get_permissions('mod_comments') && $num_unapp > 0 )
       
  1002     {
       
  1003       $_ob .= ' <span style="color: #D84308">' . $lang->get('comment_msg_count_unapp_mod', array( 'num_unapp' => $num_unapp )) . '</span>';
       
  1004     }
       
  1005     else if ( !$session->get_permissions('mod_comments') && $num_unapp > 0 )
       
  1006     {
       
  1007       $ls = ( $num_unapp == 1 ) ? 'comment_msg_count_unapp_one' : 'comment_msg_count_unapp_plural';
       
  1008       $_ob .= ' <span>' . $lang->get($ls, array( 'num_unapp' => $num_unapp )) . '</span>';
       
  1009     }
   980     $_ob .= '</p>';
  1010     $_ob .= '</p>';
   981     $list = 'list = { ';
  1011     $list = 'list = { ';
   982     // _die(htmlspecialchars($ttext));
  1012     // _die(htmlspecialchars($ttext));
   983     $i = -1;
  1013     $i = -1;
   984     while($row = $db->fetchrow($lq))
  1014     while ( $row = $db->fetchrow($lq) )
   985     {
  1015     {
   986       $i++;
  1016       $i++;
   987       $strings = Array();
  1017       $strings = Array();
   988       $bool = Array();
  1018       $bool = Array();
   989       if ( $session->get_permissions('mod_comments') || $row['approved'] )
  1019       if ( $session->get_permissions('mod_comments') || $row['approved'] )
   993         // Comment ID (used in the Javascript apps)
  1023         // Comment ID (used in the Javascript apps)
   994         $strings['ID'] = (string)$i;
  1024         $strings['ID'] = (string)$i;
   995         
  1025         
   996         // Determine the name, and whether to link to the user page or not
  1026         // Determine the name, and whether to link to the user page or not
   997         $name = '';
  1027         $name = '';
   998         if($row['user_id'] > 0) $name .= '<a href="'.makeUrlNS('User', str_replace(' ', '_', $row['name'])).'">';
  1028         if($row['user_id'] > 1) $name .= '<a href="'.makeUrlNS('User', str_replace(' ', '_', $row['name'])).'">';
   999         $name .= $row['name'];
  1029         $name .= $row['name'];
  1000         if($row['user_id'] > 0) $name .= '</a>';
  1030         if($row['user_id'] > 1) $name .= '</a>';
  1001         $strings['NAME'] = $name; unset($name);
  1031         $strings['NAME'] = $name; unset($name);
  1002         
  1032         
  1003         // Subject
  1033         // Subject
  1004         $s = $row['subject'];
  1034         $s = $row['subject'];
  1005         if(!$row['approved']) $s .= ' <span style="color: #D84308">(Unapproved)</span>';
  1035         if(!$row['approved']) $s .= ' <span style="color: #D84308">' . $lang->get('comment_msg_note_unapp') . '</span>';
  1006         $strings['SUBJECT'] = $s;
  1036         $strings['SUBJECT'] = $s;
  1007         
  1037         
  1008         // Date and time
  1038         // Date and time
  1009         $strings['DATETIME'] = date('F d, Y h:i a', $row['time']);
  1039         $strings['DATETIME'] = date('F d, Y h:i a', $row['time']);
  1010         
  1040         
  1011         // User level
  1041         // User level
  1012         switch($row['user_level'])
  1042         switch($row['user_level'])
  1013         {
  1043         {
  1014           default:
  1044           default:
  1015           case USER_LEVEL_GUEST:
  1045           case USER_LEVEL_GUEST:
  1016             $l = 'Guest';
  1046             $l = $lang->get('user_type_guest');
  1017             break;
  1047             break;
  1018           case USER_LEVEL_MEMBER:
  1048           case USER_LEVEL_MEMBER:
  1019             $l = 'Member';
  1049           case USER_LEVEL_CHPREF:
       
  1050             $l = $lang->get('user_type_member');
  1020             break;
  1051             break;
  1021           case USER_LEVEL_MOD:
  1052           case USER_LEVEL_MOD:
  1022             $l = 'Moderator';
  1053             $l = $lang->get('user_type_mod');
  1023             break;
  1054             break;
  1024           case USER_LEVEL_ADMIN:
  1055           case USER_LEVEL_ADMIN:
  1025             $l = 'Administrator';
  1056             $l = $lang->get('user_type_admin');
  1026             break;
  1057             break;
  1027         }
  1058         }
  1028         $strings['USER_LEVEL'] = $l; unset($l);
  1059         $strings['USER_LEVEL'] = $l; unset($l);
  1029         
  1060         
  1030         // The actual comment data
  1061         // The actual comment data
  1031         $strings['DATA'] = RenderMan::render($row['comment_data']);
  1062         $strings['DATA'] = RenderMan::render($row['comment_data']);
  1032         
  1063         
  1033         if($session->get_permissions('edit_comments'))
  1064         if($session->get_permissions('edit_comments'))
  1034         {
  1065         {
  1035           // Edit link
  1066           // Edit link
  1036           $strings['EDIT_LINK'] = '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=editcomment&amp;id=' . $row['comment_id']) . '" id="editbtn_' . $i . '">edit</a>';
  1067           $strings['EDIT_LINK'] = '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=editcomment&amp;id=' . $row['comment_id']) . '" id="editbtn_' . $i . '">' . $lang->get('comment_btn_edit') . '</a>';
  1037         
  1068         
  1038           // Delete link
  1069           // Delete link
  1039           $strings['DELETE_LINK'] = '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=deletecomment&amp;id=' . $row['comment_id']) . '">delete</a>';
  1070           $strings['DELETE_LINK'] = '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=deletecomment&amp;id=' . $row['comment_id']) . '">' . $lang->get('comment_btn_delete') . '</a>';
  1040         }
  1071         }
  1041         else
  1072         else
  1042         {
  1073         {
  1043           // Edit link
  1074           // Edit link
  1044           $strings['EDIT_LINK'] = '';
  1075           $strings['EDIT_LINK'] = '';
  1046           // Delete link
  1077           // Delete link
  1047           $strings['DELETE_LINK'] = '';
  1078           $strings['DELETE_LINK'] = '';
  1048         }
  1079         }
  1049         
  1080         
  1050         // Send PM link
  1081         // Send PM link
  1051         $strings['SEND_PM_LINK'] = ( $session->user_logged_in && $row['user_id'] > 0 ) ? '<a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/To/' . $row['name']) . '">Send private message</a><br />' : '';
  1082         $strings['SEND_PM_LINK'] = ( $session->user_logged_in && $row['user_id'] > 1 ) ? '<a href="'.makeUrlNS('Special', 'PrivateMessages/Compose/To/' . $row['name']) . '">' . $lang->get('comment_btn_send_privmsg') . '</a><br />' : '';
  1052         
  1083         
  1053         // Add Buddy link
  1084         // Add Buddy link
  1054         $strings['ADD_BUDDY_LINK'] = ( $session->user_logged_in && $row['user_id'] > 0 ) ? '<a href="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' . $row['name']) . '">Add to buddy list</a>' : '';
  1085         $strings['ADD_BUDDY_LINK'] = ( $session->user_logged_in && $row['user_id'] > 1 ) ? '<a href="'.makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' . $row['name']) . '">' . $lang->get('comment_btn_add_buddy') . '</a>' : '';
  1055         
  1086         
  1056         // Mod links
  1087         // Mod links
  1057         $applink = '';
  1088         $applink = '';
  1058         $applink .= '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=admin&amp;action=approve&amp;id=' . $row['comment_id']) . '" id="mdgApproveLink' . $i . '">';
  1089         $applink .= '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=admin&amp;action=approve&amp;id=' . $row['comment_id']) . '" id="mdgApproveLink' . $i . '">';
  1059         if($row['approved']) $applink .= 'Unapprove';
  1090         if($row['approved']) $applink .= $lang->get('comment_btn_mod_unapprove');
  1060         else $applink .= 'Approve';
  1091         else $applink .= $lang->get('comment_btn_mod_approve');
  1061         $applink .= '</a>';
  1092         $applink .= '</a>';
  1062         $strings['MOD_APPROVE_LINK'] = $applink; unset($applink);
  1093         $strings['MOD_APPROVE_LINK'] = $applink; unset($applink);
  1063         $strings['MOD_DELETE_LINK'] = '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=admin&amp;action=delete&amp;id=' . $row['comment_id']) . '">Delete</a>';
  1094         $strings['MOD_DELETE_LINK'] = '<a href="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=admin&amp;action=delete&amp;id=' . $row['comment_id']) . '">' . $lang->get('comment_btn_mod_delete') . '</a>';
  1064         
  1095         
  1065         // Signature
  1096         // Signature
  1066         $strings['SIGNATURE'] = '';
  1097         $strings['SIGNATURE'] = '';
  1067         if($row['signature'] != '') $strings['SIGNATURE'] = RenderMan::render($row['signature']);
  1098         if($row['signature'] != '') $strings['SIGNATURE'] = RenderMan::render($row['signature']);
  1068         
  1099         
  1076         $_ob .= $tpl->run();
  1107         $_ob .= $tpl->run();
  1077       }
  1108       }
  1078     }
  1109     }
  1079     if(getConfig('comments_need_login') != '2' || $session->user_logged_in)
  1110     if(getConfig('comments_need_login') != '2' || $session->user_logged_in)
  1080     {
  1111     {
  1081       if(!$session->get_permissions('post_comments'))
  1112       if($session->get_permissions('post_comments'))
  1082       {
  1113       {
  1083         $_ob .= '<h3>Got something to say?</h3><p>Access to post comments on this page is denied.</p>';
  1114         $_ob .= '<h3>' . $lang->get('comment_postform_title') . '</h3>';
  1084       }
  1115         $_ob .= $lang->get('comment_postform_blurb');
  1085       else
  1116         if(getConfig('approve_comments')=='1') $_ob .= ' ' . $lang->get('comment_postform_blurb_unapp');
  1086       {
  1117         if(getConfig('comments_need_login') == '1' && !$session->user_logged_in)
  1087         $_ob .= '<h3>Got something to say?</h3>If you have comments or suggestions on this article, you can shout it out here.';
  1118         {
  1088         if(getConfig('approve_comments')=='1') $_ob .= '  Before your comment will be visible to the public, a moderator will have to approve it.';
  1119           $_ob .= ' ' . $lang->get('comment_postform_blurb_captcha');
  1089         if(getConfig('comments_need_login') == '1' && !$session->user_logged_in) $_ob .= ' Because you are not logged in, you will need to enter a visual confirmation before your comment will be posted.';
  1120         }
  1090         $sn = $session->user_logged_in ? $session->username . '<input name="name" id="mdgScreenName" type="hidden" value="' . $session->username . '" />' : '<input name="name" id="mdgScreenName" type="text" size="35" />';
  1121         $sn = $session->user_logged_in ? $session->username . '<input name="name" id="mdgScreenName" type="hidden" value="' . $session->username . '" />' : '<input name="name" id="mdgScreenName" type="text" size="35" />';
  1091         $_ob .= '  <a href="#" id="mdgCommentFormLink" style="display: none;" onclick="document.getElementById(\'mdgCommentForm\').style.display=\'block\';this.style.display=\'none\';return false;">Leave a comment...</a>
  1122         $_ob .= '  <a href="#" id="mdgCommentFormLink" style="display: none;" onclick="document.getElementById(\'mdgCommentForm\').style.display=\'block\';this.style.display=\'none\';return false;">' . $lang->get('comment_postform_blurb_link') . '</a>
  1092         <div id="mdgCommentForm">
  1123         <div id="mdgCommentForm">
  1093         <h3>Comment form</h3>
       
  1094         <form action="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=postcomment').'" method="post" style="margin-left: 1em">
  1124         <form action="'.makeUrlNS($namespace, $page_id, 'do=comments&amp;sub=postcomment').'" method="post" style="margin-left: 1em">
  1095         <table border="0">
  1125         <table border="0">
  1096         <tr><td>Your name or screen name:</td><td>' . $sn . '</td></tr>
  1126         <tr><td>' . $lang->get('comment_postform_field_name') . '</td><td>' . $sn . '</td></tr>
  1097         <tr><td>Comment subject:</td><td><input name="subj" id="mdgSubject" type="text" size="35" /></td></tr>';
  1127         <tr><td>' . $lang->get('comment_postform_field_subject') . '</td><td><input name="subj" id="mdgSubject" type="text" size="35" /></td></tr>';
  1098         if(getConfig('comments_need_login') == '1' && !$session->user_logged_in)
  1128         if(getConfig('comments_need_login') == '1' && !$session->user_logged_in)
  1099         {
  1129         {
  1100           $session->kill_captcha();
  1130           $session->kill_captcha();
  1101           $captcha = $session->make_captcha();
  1131           $captcha = $session->make_captcha();
  1102           $_ob .= '<tr><td>Visual confirmation:<br /><small>Please enter the code you see on the right.</small></td><td><img src="'.makeUrlNS('Special', 'Captcha/' . $captcha) . '" alt="Visual confirmation" style="cursor: pointer;" onclick="this.src = \''.makeUrlNS("Special", "Captcha/".$captcha).'/\'+Math.floor(Math.random() * 100000);" /><input name="captcha_id" id="mdgCaptchaID" type="hidden" value="' . $captcha . '" /><br />Code: <input name="captcha_input" id="mdgCaptchaInput" type="text" size="10" /><br /><small><script type="text/javascript">document.write("If you can\'t read the code, click on the image to generate a new one.");</script><noscript>If you can\'t read the code, please refresh this page to generate a new one.</noscript></small></td></tr>';
  1132           $_ob .= '<tr><td>' . $lang->get('comment_postform_field_captcha_title') . '<br /><small>' . $lang->get('comment_postform_field_captcha_blurb') . '</small></td><td><img src="'.makeUrlNS('Special', 'Captcha/' . $captcha) . '" alt="Visual confirmation" style="cursor: pointer;" onclick="this.src = \''.makeUrlNS("Special", "Captcha/".$captcha).'/\'+Math.floor(Math.random() * 100000);" /><input name="captcha_id" id="mdgCaptchaID" type="hidden" value="' . $captcha . '" /><br />' . $lang->get('comment_postform_field_captcha_label') . ' <input name="captcha_input" id="mdgCaptchaInput" type="text" size="10" /><br /><small><script type="text/javascript">document.write("' . $lang->get('comment_postform_field_captcha_cantread_js') . '");</script><noscript>' . $lang->get('comment_postform_field_captcha_cantread_nojs') . '</noscript></small></td></tr>';
  1103         }
  1133         }
  1104         $_ob .= '
  1134         $_ob .= '
  1105         <tr><td valign="top">Comment text:<br />(most HTML will be stripped)</td><td><textarea name="text" id="mdgCommentArea" rows="10" cols="40"></textarea></td></tr>
  1135         <tr><td valign="top">' . $lang->get('comment_postform_field_comment') . '</td><td><textarea name="text" id="mdgCommentArea" rows="10" cols="40"></textarea></td></tr>
  1106         <tr><td colspan="2" style="text-align: center;"><input type="submit" value="Submit Comment" /></td></tr>
  1136         <tr><td colspan="2" style="text-align: center;"><input type="submit" value="' . $lang->get('comment_postform_btn_submit') . '" /></td></tr>
  1107         </table>
  1137         </table>
  1108         </form>
  1138         </form>
  1109         </div>';
  1139         </div>';
  1110       }
  1140       }
  1111     } else {
  1141     } else {
  1816    */
  1846    */
  1817    
  1847    
  1818   function pagediff($page_id, $namespace, $id1, $id2)
  1848   function pagediff($page_id, $namespace, $id1, $id2)
  1819   {
  1849   {
  1820     global $db, $session, $paths, $template, $plugins; // Common objects
  1850     global $db, $session, $paths, $template, $plugins; // Common objects
       
  1851     global $lang;
  1821     if(!$session->get_permissions('history_view'))
  1852     if(!$session->get_permissions('history_view'))
  1822       return 'Access denied';
  1853       return 'Access denied';
  1823     if(!preg_match('#^([0-9]+)$#', (string)$id1) ||
  1854     if(!preg_match('#^([0-9]+)$#', (string)$id1) ||
  1824        !preg_match('#^([0-9]+)$#', (string)$id2  )) return 'SQL injection attempt';
  1855        !preg_match('#^([0-9]+)$#', (string)$id2  )) return 'SQL injection attempt';
  1825     // OK we made it through security
  1856     // OK we made it through security
  1834     $text1 = $row1['page_text'];
  1865     $text1 = $row1['page_text'];
  1835     $text2 = $row2['page_text'];
  1866     $text2 = $row2['page_text'];
  1836     $time1 = date('F d, Y h:i a', $id1);
  1867     $time1 = date('F d, Y h:i a', $id1);
  1837     $time2 = date('F d, Y h:i a', $id2);
  1868     $time2 = date('F d, Y h:i a', $id2);
  1838     $_ob = "
  1869     $_ob = "
  1839     <p>Comparing revisions: {$time1} &rarr; {$time2}</p>
  1870     <p>" . $lang->get('history_lbl_comparingrevisions') . " {$time1} &rarr; {$time2}</p>
  1840     ";
  1871     ";
  1841     // Free some memory
  1872     // Free some memory
  1842     unset($row1, $row2, $q1, $q2);
  1873     unset($row1, $row2, $q1, $q2);
  1843     
  1874     
  1844     $_ob .= RenderMan::diff($text1, $text2);
  1875     $_ob .= RenderMan::diff($text1, $text2);