includes/pageutils.php
changeset 800 9cdfe82c56cd
parent 749 ea3045a3bcbd
child 801 eb8b23f11744
equal deleted inserted replaced
799:4629ad98ee88 800:9cdfe82c56cd
   321     return('good');
   321     return('good');
   322   }
   322   }
   323   
   323   
   324   /**
   324   /**
   325    * Generates an HTML table with history information in it.
   325    * Generates an HTML table with history information in it.
   326    * @param $page_id the page ID
   326    * @param string the page ID
   327    * @param $namespace the namespace
   327    * @param string the namespace
       
   328    * @param string page password
   328    * @return string
   329    * @return string
   329    */
   330    */
   330   
   331   
   331   public static function histlist($page_id, $namespace)
   332   public static function histlist($page_id, $namespace, $password = false)
   332   {
   333   {
   333     global $db, $session, $paths, $template, $plugins; // Common objects
   334     global $db, $session, $paths, $template, $plugins; // Common objects
   334     global $lang;
   335     global $lang;
   335     
   336     
   336     if(!$session->get_permissions('history_view'))
   337     if(!$session->get_permissions('history_view'))
   337       return 'Access denied';
   338       return 'Access denied';
   338     
   339     
   339     ob_start();
   340     ob_start();
   340     
   341     
   341     $pname = $paths->nslist[$namespace] . $page_id;
   342     $pname = $paths->nslist[$namespace] . $page_id;
       
   343     
       
   344     if ( !isPage($pname) )
       
   345     {
       
   346       return 'DNE';
       
   347     }
       
   348     
       
   349     if ( isset($paths->pages[$pname]['password']) )
       
   350     {
       
   351       $password_exists = ( !empty($paths->pages[$pname]['password']) && $paths->pages[$pname]['password'] !== sha1('') );
       
   352       if ( $password_exists && $password !== $paths->pages[$pname]['password'] )
       
   353       {
       
   354         return '<p>' . $lang->get('history_err_wrong_password') . '</p>';
       
   355       }
       
   356     }
       
   357     
   342     $wiki = ( ( $paths->pages[$pname]['wiki_mode'] == 2 && getConfig('wiki_mode') == '1') || $paths->pages[$pname]['wiki_mode'] == 1) ? true : false;
   358     $wiki = ( ( $paths->pages[$pname]['wiki_mode'] == 2 && getConfig('wiki_mode') == '1') || $paths->pages[$pname]['wiki_mode'] == 1) ? true : false;
   343     $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;
   359     $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;
   344     
   360     
   345     $q = 'SELECT log_id,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 . '\' AND is_draft != 1 ORDER BY time_id DESC;';
   361     $q = 'SELECT log_id,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 . '\' AND is_draft != 1 ORDER BY time_id DESC;';
   346     if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
   362     if(!$db->sql_query($q)) $db->_die('The history data for the page "' . $paths->cpage['name'] . '" could not be selected.');
  1489    */
  1505    */
  1490   
  1506   
  1491   public static function setpass($page_id, $namespace, $pass)
  1507   public static function setpass($page_id, $namespace, $pass)
  1492   {
  1508   {
  1493     global $db, $session, $paths, $template, $plugins; // Common objects
  1509     global $db, $session, $paths, $template, $plugins; // Common objects
  1494     global $lang;
  1510     global $lang, $cache;
  1495     // Determine permissions
  1511     // Determine permissions
  1496     if($paths->pages[$paths->nslist[$namespace].$page_id]['password'] != '')
  1512     if($paths->pages[$paths->nslist[$namespace].$page_id]['password'] != '')
  1497       $a = $session->get_permissions('password_reset');
  1513       $a = $session->get_permissions('password_reset');
  1498     else
  1514     else
  1499       $a = $session->get_permissions('password_set');
  1515       $a = $session->get_permissions('password_set');
  1511     $e = $db->sql_query('UPDATE ' . table_prefix.'pages SET password=\'' . $p . '\' WHERE urlname=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\';');
  1527     $e = $db->sql_query('UPDATE ' . table_prefix.'pages SET password=\'' . $p . '\' WHERE urlname=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\';');
  1512     if ( !$e )
  1528     if ( !$e )
  1513     {
  1529     {
  1514       die('PageUtils::setpass(): Error during update query: '.$db->get_error()."\n\nSQL Backtrace:\n".$db->sql_backtrace());
  1530       die('PageUtils::setpass(): Error during update query: '.$db->get_error()."\n\nSQL Backtrace:\n".$db->sql_backtrace());
  1515     }
  1531     }
       
  1532     $cache->purge('page_meta');
  1516     // Is the new password blank?
  1533     // Is the new password blank?
  1517     if ( $p == '' )
  1534     if ( $p == '' )
  1518     {
  1535     {
  1519       return $lang->get('ajax_password_disable_success');
  1536       return $lang->get('ajax_password_disable_success');
  1520     }
  1537     }