Example #1
0
 /**
  * Unregisters Tuffy's error, exception, and shutdown handlers, with
  * some caveats. Since shutdown functions are not unregisterable, all it
  * does for handleShutdown is set a flag that causes it to return. And
  * for the error and exception functions, properly unregistering them
  * is contingent on them being the actual exception handlers at call time.
  */
 public static function unregisterHandlers()
 {
     self::$_handlersActive = FALSE;
     restore_exception_handler();
     restore_error_handler();
 }
 /**
  * Executes the statement.
  *
  * @param array $params Parameters to bind before executing the statement.
  * You can use this to simplify running several sequential inserts.
  */
 public function execute($params = NULL)
 {
     $debug = Tuffy::setting('debug');
     if ($params) {
         $this->bind($params);
     }
     if ($debug) {
         ob_start();
         $this->debugDumpParams();
         $idx = Tuffy::debug("Query", ob_get_clean());
     }
     parent::execute();
     if ($debug) {
         Tuffy_Debug::completeEvent($idx);
     }
 }
Example #3
0
 /**
  * Redirects to another page and exits. This includes a brief HTML message
  * explaining to where the redirect goes. It also saves the debug log
  * for this request in the session, if both the debug log and sessions
  * are enabled.
  *
  * @param string $target The URL to redirect to. This is passed through
  * Tuffy::expand_url.
  * @param string $code The HTTP status line (e.g. "303 See Other").
  */
 public static function redirect($target, $code = '303 See Other')
 {
     $dest = self::url($target);
     if (self::setting('debug') && self::setting('useSessions')) {
         Tuffy::debug("Redirecting", $dest);
         Tuffy_Debug::saveLogInSession();
     }
     header('HTTP/1.1 ' . $code);
     header('Location: ' . $dest);
     echo "<!doctype html>\n";
     echo "<p>Redirecting you to <a href=\"{$dest}\">{$dest}</a>.</p>";
     self::exitScript();
 }
Example #4
0
if (isset($GLOBALS['tuffySettings']) && is_array($GLOBALS['tuffySettings'])) {
    Tuffy::configure($GLOBALS['tuffySettings']);
}
if (!Tuffy::setting('appName')) {
    die("You must define the appName setting.");
}
// 6. Configure the environment.
$tuffyTimezone = Tuffy::setting('timezone');
if ($tuffyTimezone !== NULL) {
    date_default_timezone_set(Tuffy::setting('timezone'));
}
unset($tuffyTimezone);
if (Tuffy::setting('useSessions')) {
    session_start();
    if (Tuffy::setting('debug')) {
        Tuffy_Debug::restoreLogFromSession();
        Tuffy::debug("Session " . session_id(), $_SESSION);
    }
}
if ($libraryPath = Tuffy::setting('libraryPath')) {
    $tuffyAppLoader = new Tuffy_Loader(Tuffy::setting('appName'), Tuffy_Util::interpretPath($libraryPath));
    $tuffyAppLoader->register();
}
unset($libraryPath);
foreach (Tuffy::setting('initializers', array()) as $init) {
    call_user_func($init);
}
// 7. Here are a couple of completely non-namespaced utility functions
// that are just too useful not to have.
/**
 * If the $key exists in $array, returns the value stored therein. Otherwise,