includes/pageutils.php
changeset 28 dd2edcdc6c03
parent 21 663fcf528726
child 29 e5484a9e0818
equal deleted inserted replaced
27:dd659f6ba891 28:dd2edcdc6c03
   611         if    ($r['action']=='prot')     echo 'Protected page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   611         if    ($r['action']=='prot')     echo 'Protected page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   612         elseif($r['action']=='unprot')   echo 'Unprotected page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   612         elseif($r['action']=='unprot')   echo 'Unprotected page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   613         elseif($r['action']=='semiprot') echo 'Semi-protected page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   613         elseif($r['action']=='semiprot') echo 'Semi-protected page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   614         elseif($r['action']=='rename')   echo 'Renamed page</td><td class="'.$cls.'">Old title: '.$r['edit_summary'];
   614         elseif($r['action']=='rename')   echo 'Renamed page</td><td class="'.$cls.'">Old title: '.$r['edit_summary'];
   615         elseif($r['action']=='create')   echo 'Created page</td><td class="'.$cls.'">';
   615         elseif($r['action']=='create')   echo 'Created page</td><td class="'.$cls.'">';
   616         elseif($r['action']=='delete')   echo 'Deleted page</td><td class="'.$cls.'">';
   616         elseif($r['action']=='delete')   echo 'Deleted page</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   617         elseif($r['action']=='reupload') echo 'Uploaded new file version</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   617         elseif($r['action']=='reupload') echo 'Uploaded new file version</td><td class="'.$cls.'">Reason: '.$r['edit_summary'];
   618         echo '</td>';
   618         echo '</td>';
   619         
   619         
   620         // Actions!
   620         // Actions!
   621         echo '<td class="'.$cls.'" style="text-align: center;"><a href="'.makeUrl($paths->nslist['Special'].'Contributions/'.$r['author']).'">View user contribs</a></td>';
   621         echo '<td class="'.$cls.'" style="text-align: center;"><a href="'.makeUrl($paths->nslist['Special'].'Contributions/'.$r['author']).'">View user contribs</a></td>';
  1251     return('The logs for this page have been cleared. A backup of this page has been added to the logs table so that this page can be restored in case of vandalism or spam later.');
  1251     return('The logs for this page have been cleared. A backup of this page has been added to the logs table so that this page can be restored in case of vandalism or spam later.');
  1252   }
  1252   }
  1253   
  1253   
  1254   /**
  1254   /**
  1255    * Deletes a page.
  1255    * Deletes a page.
  1256    * @param $page_id the condemned page ID
  1256    * @param string $page_id the condemned page ID
  1257    * @param $namespace the condemned namespace
  1257    * @param string $namespace the condemned namespace
       
  1258    * @param string The reason for deleting the page in question
  1258    * @return string
  1259    * @return string
  1259    */
  1260    */
  1260    
  1261    
  1261   function deletepage($page_id, $namespace)
  1262   function deletepage($page_id, $namespace, $reason)
  1262   {
  1263   {
  1263     global $db, $session, $paths, $template, $plugins; // Common objects
  1264     global $db, $session, $paths, $template, $plugins; // Common objects
  1264     $perms = $session->fetch_page_acl($page_id, $namespace);
  1265     $perms = $session->fetch_page_acl($page_id, $namespace);
  1265     if(!$perms->get_permissions('delete_page')) die('Administrative privileges are required to delete pages, you loser.');
  1266     $x = trim($reason);
  1266     $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,page_id,namespace,author) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'delete\', \''.$page_id.'\', \''.$namespace.'\', \''.$session->username.'\')');
  1267     if ( empty($x) )
       
  1268     {
       
  1269       return 'Invalid reason for deletion passed';
       
  1270     }
       
  1271     if(!$perms->get_permissions('delete_page')) return('Administrative privileges are required to delete pages, you loser.');
       
  1272     $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,page_id,namespace,author,edit_summary) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'delete\', \''.$page_id.'\', \''.$namespace.'\', \''.$session->username.'\', \'' . $db->escape(htmlspecialchars($reason)) . '\')');
  1267     if(!$e) $db->_die('The page log entry could not be inserted.');
  1273     if(!$e) $db->_die('The page log entry could not be inserted.');
  1268     $e = $db->sql_query('DELETE FROM '.table_prefix.'categories WHERE page_id=\''.$page_id.'\' AND namespace=\''.$namespace.'\'');
  1274     $e = $db->sql_query('DELETE FROM '.table_prefix.'categories WHERE page_id=\''.$page_id.'\' AND namespace=\''.$namespace.'\'');
  1269     if(!$e) $db->_die('The page categorization entries could not be deleted.');
  1275     if(!$e) $db->_die('The page categorization entries could not be deleted.');
  1270     $e = $db->sql_query('DELETE FROM '.table_prefix.'comments WHERE page_id=\''.$page_id.'\' AND namespace=\''.$namespace.'\'');
  1276     $e = $db->sql_query('DELETE FROM '.table_prefix.'comments WHERE page_id=\''.$page_id.'\' AND namespace=\''.$namespace.'\'');
  1271     if(!$e) $db->_die('The page comments could not be deleted.');
  1277     if(!$e) $db->_die('The page comments could not be deleted.');