Exemplo n.º 1
0
 /**
  * @param TikiDb $db
  * @param $query
  * @param $values
  * @param $result
  */
 function handle(TikiDb $db, $query, $values, $result)
 {
     global $smarty, $prefs;
     $msg = $db->getErrorMessage();
     $q = $query;
     if (is_array($values)) {
         foreach ($values as $v) {
             if (is_null($v)) {
                 $v = 'NULL';
             } else {
                 $v = "'" . addslashes($v) . "'";
             }
             $pos = strpos($q, '?');
             if ($pos !== false) {
                 $q = substr($q, 0, $pos) . "{$v}" . substr($q, $pos + 1);
             }
         }
     }
     if (function_exists('xdebug_get_function_stack')) {
         /**
          * @param $stack
          * @return string
          */
         function mydumpstack($stack)
         {
             $o = '';
             foreach ($stack as $line) {
                 $o .= '* ' . $line['file'] . " : " . $line['line'] . " -> " . $line['function'] . "(" . var_export($line['params'], true) . ")<br />";
             }
             return $o;
         }
         $stacktrace = mydumpstack(xdebug_get_function_stack());
     } else {
         $stacktrace = false;
     }
     require_once 'installer/installlib.php';
     $installer = new Installer();
     require_once 'tiki-setup.php';
     $smarty->assign('msg', $msg);
     $smarty->assign('base_query', $query);
     $smarty->assign('values', $values);
     $smarty->assign('built_query', $q);
     $smarty->assign('stacktrace', $stacktrace);
     $smarty->assign('requires_update', $installer->requiresUpdate());
     header("Cache-Control: no-cache, pre-check=0, post-check=0");
     $smarty->display('database-connection-error.tpl');
     $this->log($msg . ' - ' . $q);
     die;
 }
Exemplo n.º 2
0
 /**
  * @param TikiDb $db
  * @param $query
  * @param $values
  * @param $result
  */
 function handle(TikiDb $db, $query, $values, $result)
 {
     global $prefs;
     $smarty = TikiLib::lib('smarty');
     $msg = $db->getErrorMessage();
     $q = $query;
     if (is_array($values)) {
         foreach ($values as $v) {
             if (is_null($v)) {
                 $v = 'NULL';
             } else {
                 $v = "'" . addslashes($v) . "'";
             }
             $pos = strpos($q, '?');
             if ($pos !== false) {
                 $q = substr($q, 0, $pos) . "{$v}" . substr($q, $pos + 1);
             }
         }
     }
     if (function_exists('xdebug_get_function_stack')) {
         $stacktrace = mydumpstack(xdebug_get_function_stack());
     } else {
         $stacktrace = false;
     }
     require_once 'installer/installlib.php';
     $installer = new Installer();
     require_once 'tiki-setup.php';
     $smarty->assign('msg', $msg);
     $smarty->assign('base_query', $query);
     $smarty->assign('values', $values);
     $smarty->assign('built_query', $q);
     $smarty->assign('stacktrace', $stacktrace);
     $smarty->assign('requires_update', $installer->requiresUpdate());
     header("Cache-Control: no-cache, pre-check=0, post-check=0");
     $smarty->display('database-connection-error.tpl');
     $this->log($msg . ' - ' . $q);
     die;
 }