includes/dbal.php
changeset 91 8079b0288e8e
parent 73 0a74676a2f2f
child 128 01955bf53f96
equal deleted inserted replaced
90:9d29f7e101d6 91:8079b0288e8e
    81     }
    81     }
    82     header('HTTP/1.1 500 Internal Server Error');
    82     header('HTTP/1.1 500 Internal Server Error');
    83     $bt = $this->latest_query; // $this->sql_backtrace();
    83     $bt = $this->latest_query; // $this->sql_backtrace();
    84     $e = htmlspecialchars(mysql_error());
    84     $e = htmlspecialchars(mysql_error());
    85     if($e=='') $e='<none>';
    85     if($e=='') $e='<none>';
    86     if(defined('ENANO_CONFIG_FETCHED')) die_semicritical('Database error', '<h3>An error occurred during a database query.</h3><p>'.$t.'<br />Error returned by MySQL: '.$e.'<br />SQL Backtrace:</p><pre>'.$bt.'</pre>');
    86     $t = ( !empty($t) ) ? $t : '&lt;No error description provided&gt;';
    87     else                                   grinding_halt('Database error', '<h3>An error occurred during a database query.</h3><p>'.$t.'<br />Error returned by MySQL: '.$e.'<br />SQL Backtrace:</p><pre>'.$bt.'</pre>');
    87     global $email;
       
    88     $email_info = ( defined('ENANO_CONFIG_FETCHED') && is_object($email) ) ? ', at &lt;' . $email->jscode() . $email->encryptEmail(getConfig('contact_email')) . '&gt;' : '';
       
    89     $internal_text = '<h3>The site was unable to finish serving your request.</h3>
       
    90                       <p>We apologize for the inconveience, but an error occurred in the Enano database layer. Please report the full text of this page to the administrator of this site' . $email_info . '.</p>
       
    91                       <p>Description or location of error: '.$t.'<br />
       
    92                       Error returned by MySQL extension: ' . $e . '<br />
       
    93                       Most recent SQL query:</p>
       
    94                       <pre>'.$bt.'</pre>';
       
    95     if(defined('ENANO_CONFIG_FETCHED')) die_semicritical('Database error', $internal_text);
       
    96     else                                   grinding_halt('Database error', $internal_text);
    88     exit;
    97     exit;
    89   }
    98   }
    90   
    99   
    91   function die_json()
   100   function die_json()
    92   {
   101   {
    99   function get_error($t = '') {
   108   function get_error($t = '') {
   100     header('HTTP/1.1 500 Internal Server Error');
   109     header('HTTP/1.1 500 Internal Server Error');
   101     $bt = $this->sql_backtrace();
   110     $bt = $this->sql_backtrace();
   102     $e = htmlspecialchars(mysql_error());
   111     $e = htmlspecialchars(mysql_error());
   103     if($e=='') $e='&lt;none&gt;';
   112     if($e=='') $e='&lt;none&gt;';
   104     $text = '<h3>An error occurred during a database query.</h3><p>'.$t.'<br />Error returned by MySQL: '.$e.'<br />SQL Backtrace:</p><pre>'.$bt.'</pre>';
   113     global $email;
   105     return $text;
   114     $email_info = ( defined('ENANO_CONFIG_FETCHED') && is_object($email) ) ? ', at &lt;' . $email->jscode() . $email->encryptEmail(getConfig('contact_email')) . '&gt;' : '';
       
   115     $internal_text = '<h3>The site was unable to finish serving your request.</h3>
       
   116                       <p>We apologize for the inconveience, but an error occurred in the Enano database layer. Please report the full text of this page to the administrator of this site' . $email_info . '.</p>
       
   117                       <p>Description or location of error: '.$t.'<br />
       
   118                       Error returned by MySQL extension: ' . $e . '<br />
       
   119                       Most recent SQL query:</p>
       
   120                       <pre>'.$bt.'</pre>';
       
   121     return $internal_text;
   106   }
   122   }
   107   
   123   
   108   function connect() {
   124   function connect() {
   109     $this->enable_errorhandler();
   125     $this->enable_errorhandler();
   110     dc_here('dbal: trying to connect....');
   126     dc_here('dbal: trying to connect....');