Changeset 2484


Ignore:
Timestamp:
Aug 23, 2008, 3:18:13 AM (16 years ago)
Author:
rvelices
Message:

merge r2483 from branch 1.7

  • security fix : when confquestion_mark_in_urls=true , $_SERVERPATH_INFO was not sanitized against sql injection
  • mysql errors are now dumped using trigger_error instead of echo and die -> allow admins to see later on if someone tries funny stuff
Location:
trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/common.inc.php

    r2479 r2484  
    9999  }
    100100}
     101if ( !empty($_SERVER["PATH_INFO"]) )
     102{
     103  $_SERVER["PATH_INFO"] = addslashes($_SERVER["PATH_INFO"]);
     104}
    101105
    102106//
     
    139143
    140144// Database connection
    141 mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
    142 or die ( "Could not connect to database server" );
    143 mysql_select_db( $cfgBase )
    144 or die ( "Could not connect to database" );
     145@mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) or my_error( 'mysql_connect', true );
     146@mysql_select_db( $cfgBase ) or my_error( 'mysql_select_db', true );
    145147
    146148defined('PWG_CHARSET') and defined('DB_CHARSET')
  • trunk/include/functions.inc.php

    r2479 r2484  
    597597
    598598  $start = get_moment();
    599   $result = mysql_query($query) or my_error($query."\n");
     599  ($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
    600600
    601601  $time = get_moment() - $start;
     
    906906// my_error returns (or send to standard output) the message concerning the
    907907// error occured for the last mysql query.
    908 function my_error($header)
    909 {
    910   global $conf;
    911 
    912   $error = '<pre>';
    913   $error.= $header;
    914   $error.= '[mysql error '.mysql_errno().'] ';
    915   $error.= mysql_error();
    916   $error.= '</pre>';
    917 
    918   if ($conf['die_on_sql_error'])
    919   {
    920     die($error);
    921   }
    922   else
    923   {
    924     echo $error;
    925   }
    926 }
     908
     909function my_error($header, $die)
     910{
     911  $error = $header;
     912  $error.= "\n[mysql error ".mysql_errno().'] '.mysql_error()."\n";
     913
     914  if (function_exists('debug_backtrace'))
     915  {
     916    $bt = debug_backtrace();
     917    for ($i=0; $i<count($bt); $i++)
     918    {
     919      $error .= "#$i\t".@$bt[$i]['function']." ".@$bt[$i]['file']."(".@@$bt[$i]['line'].")\n";
     920    }
     921  }
     922
     923  if ($die)
     924  {
     925    @set_status_header(500);
     926    echo( str_repeat( ' ', 300)."\n"); //IE doesn't error output if below a size
     927  }
     928  echo("<pre>");
     929  trigger_error($error, $die ? E_USER_ERROR : E_USER_WARNING);
     930  !$die || die($error); // just in case the handler didnt die
     931  echo("</pre>");
     932}
     933
    927934
    928935/**
Note: See TracChangeset for help on using the changeset viewer.