plugins/SpecialUserFuncs.php
changeset 81 d7fc25acd3f3
parent 60 71b50f8c8f85
child 85 7c68a18a27be
equal deleted inserted replaced
80:cb7dde69c301 81:d7fc25acd3f3
   575   }
   575   }
   576   elseif(!$user && !isset($_GET['user']))
   576   elseif(!$user && !isset($_GET['user']))
   577   {
   577   {
   578     echo 'No user selected!';
   578     echo 'No user selected!';
   579     $template->footer();
   579     $template->footer();
   580     $db->close();
   580     return;
   581     exit;
       
   582   }
   581   }
   583   
   582   
   584   $user = $db->escape($user);
   583   $user = $db->escape($user);
   585   
   584   
   586   $q = 'SELECT time_id,date_string,page_id,namespace,author,edit_summary,minor_edit,page_id,namespace FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND action=\'edit\' ORDER BY time_id DESC;';
   585   $q = 'SELECT time_id,date_string,page_id,namespace,author,edit_summary,minor_edit,page_id,namespace FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND action=\'edit\' ORDER BY time_id DESC;';
   587   if(!$db->sql_query($q)) $db->_die('The history data for the page "'.$paths->cpage['name'].'" could not be selected.');
   586   if(!$db->sql_query($q)) $db->_die('The history data for the page "'.$paths->cpage['name'].'" could not be selected.');
   588   echo 'History of edits and actions<h3>Edits:</h3>';
   587   echo 'History of edits and actions<h3>Edits:</h3>';
   589   if($db->numrows() < 1) echo 'No history entries in this category.';
   588   if($db->numrows() < 1) echo 'No history entries in this category.';
   590   while($r = $db->fetchrow()) {    
   589   while($r = $db->fetchrow())
   591     echo '<a href="#" onclick="ajaxHistView(\''.$r['time_id'].'\', \''.$paths->nslist[$r['namespace']].$r['page_id'].'\'); return false;"><i>'.$r['date_string'].'</i></a> (<a href="#" onclick="ajaxRollback(\''.$r['time_id'].'\'); return false;">revert</a>) <a href="'.makeUrl($paths->nslist[$r['namespace']].$r['page_id']).'">'.$paths->nslist[$r['namespace']].$r['page_id'].'</a>: '.$r['edit_summary'];
   590   {
       
   591     $title = get_page_title($r['page_id'], $r['namespace']);    
       
   592     echo '<a href="' . makeUrlNS($r['namespace'], $r['page_id'], "oldid={$r['time_id']}", true) . '" onclick="ajaxHistView(\''.$r['time_id'].'\', \''.$paths->nslist[$r['namespace']].$r['page_id'].'\'); return false;"><i>'.$r['date_string'].'</i></a> (<a href="#" onclick="ajaxRollback(\''.$r['time_id'].'\'); return false;">revert to</a>) <a href="'.makeUrl($paths->nslist[$r['namespace']].$r['page_id']).'">'.htmlspecialchars($title).'</a>: '.$r['edit_summary'];
   592     if($r['minor_edit']) echo '<b> - minor edit</b>';
   593     if($r['minor_edit']) echo '<b> - minor edit</b>';
   593     echo '<br />';
   594     echo '<br />';
   594   }
   595   }
   595   $db->free_result();
   596   $db->free_result();
   596   echo '<h3>Other changes:</h3>';
   597   echo '<h3>Other changes:</h3>';
   597   $q = 'SELECT log_type,time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit,page_id,namespace FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND action!=\'edit\' ORDER BY time_id DESC;';
   598   $q = 'SELECT log_type,time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit,page_id,namespace FROM '.table_prefix.'logs WHERE author=\''.$user.'\' AND action!=\'edit\' ORDER BY time_id DESC;';
   598   if(!$db->sql_query($q)) $db->_die('The history data for the page "'.$paths->cpage['name'].'" could not be selected.');
   599   if(!$db->sql_query($q)) $db->_die('The history data for the page "'.$paths->cpage['name'].'" could not be selected.');
   599   if($db->numrows() < 1) echo 'No history entries in this category.';
   600   if($db->numrows() < 1) echo 'No history entries in this category.';
   600   while($r = $db->fetchrow()) {
   601   while($r = $db->fetchrow()) 
   601     if($r['log_type']=='page') {
   602   {
   602     echo '(<a href="#" onclick="ajaxRollback(\''.$r['time_id'].'\'); return false;">rollback</a>) <i>'.$r['date_string'].'</i> <a href="'.makeUrl($paths->nslist[$r['namespace']].$r['page_id']).'">'.$paths->nslist[$r['namespace']].$r['page_id'].'</a>: ';
   603     if ( $r['log_type'] == 'page' )
   603     if($r['action']=='prot') echo 'Protected page; reason: '.$r['edit_summary'];
   604     {
   604     elseif($r['action']=='unprot') echo 'Unprotected page; reason: '.$r['edit_summary'];
   605       $title = get_page_title($r['page_id'], $r['namespace']);
   605     elseif($r['action']=='rename') echo 'Renamed page; old title was: '.$r['edit_summary'];
   606       echo '(<a href="#" onclick="ajaxRollback(\''.$r['time_id'].'\'); return false;">rollback</a>) <i>'.$r['date_string'].'</i> <a href="'.makeUrl($paths->nslist[$r['namespace']].$r['page_id']).'">'.htmlspecialchars($title).'</a>: ';
   606     elseif($r['action']=='create') echo 'Created page';
   607       if      ( $r['action'] == 'prot'   ) echo 'Protected page; reason: '.$r['edit_summary'];
   607     elseif($r['action']=='delete') echo 'Deleted page';
   608       else if ( $r['action'] == 'unprot' ) echo 'Unprotected page; reason: '.$r['edit_summary'];
   608     if($r['minor_edit']) echo '<b> - minor edit</b>';
   609       else if ( $r['action'] == 'rename' ) echo 'Renamed page; old title was: '.htmlspecialchars($r['edit_summary']);
   609     echo '<br />';
   610       else if ( $r['action'] == 'create' ) echo 'Created page';
   610     } elseif($r['log_type']=='security') {
   611       else if ( $r['action'] == 'delete' ) echo 'Deleted page';
       
   612       if ( $r['minor_edit'] ) echo '<b> - minor edit</b>';
       
   613       echo '<br />';
       
   614     }
       
   615     else if($r['log_type']=='security') 
       
   616     {
   611       // Not implemented, and when it is, it won't be public
   617       // Not implemented, and when it is, it won't be public
   612     }
   618     }
   613   }
   619   }
   614   $db->free_result();
   620   $db->free_result();
   615   $template->footer();
   621   $template->footer();
   619 {
   625 {
   620   global $db, $session, $paths, $template, $plugins; // Common objects
   626   global $db, $session, $paths, $template, $plugins; // Common objects
   621   if(!$session->user_logged_in) die_friendly('Access denied', '<p>You must be logged in to change your style. Spoofer.</p>');
   627   if(!$session->user_logged_in) die_friendly('Access denied', '<p>You must be logged in to change your style. Spoofer.</p>');
   622   if(isset($_POST['theme']) && isset($_POST['style']) && isset($_POST['return_to']))
   628   if(isset($_POST['theme']) && isset($_POST['style']) && isset($_POST['return_to']))
   623   {
   629   {
       
   630     if ( !preg_match('/^([a-z0-9_-]+)$/i', $_POST['theme']) )
       
   631       die('Hacking attempt');
       
   632     if ( !preg_match('/^([a-z0-9_-]+)$/i', $_POST['style']) )
       
   633       die('Hacking attempt');
   624     $d = ENANO_ROOT . '/themes/' . $_POST['theme'];
   634     $d = ENANO_ROOT . '/themes/' . $_POST['theme'];
   625     $f = ENANO_ROOT . '/themes/' . $_POST['theme'] . '/css/' . $_POST['style'] . '.css';
   635     $f = ENANO_ROOT . '/themes/' . $_POST['theme'] . '/css/' . $_POST['style'] . '.css';
   626     if(!file_exists($d) || !is_dir($d)) die('The directory "'.$d.'" does not exist.');
   636     if(!file_exists($d) || !is_dir($d)) die('The directory "'.$d.'" does not exist.');
   627     if(!file_exists($f)) die('The file "'.$f.'" does not exist.');
   637     if(!file_exists($f)) die('The file "'.$f.'" does not exist.');
   628     $d = $db->escape($_POST['theme']);
   638     $d = $db->escape($_POST['theme']);