Beispiel #1
0
 /**
  * Setup host, port, login and password.
  * @param string $host
  * @param integer $port
  * @param string $username
  * @param string $password
  */
 public function __construct($host = NULL, $port = NULL, $username = NULL, $password = NULL)
 {
     // include PEAR Mail:: if possible...
     // a hack of a production environment on Onebit servers
     if (Fari_ApplicationEnvironment::isProduction()) {
         set_include_path(BASEPATH . '/application/3rdparty/pear:' . get_include_path());
         include 'Mail.php';
         include 'Mail/mime.php';
         include 'SMTP.php';
     } else {
         try {
             // get include paths
             $paths = explode(':/', get_include_path());
             foreach ($paths as $path) {
                 // 'fix' directory
                 if (substr($path, 0, 1) == '.') {
                     // this directory
                     $path = '';
                 } else {
                     // directory from the root
                     $path = "/{$path}/";
                 }
                 // can we call PEAR Mail:: ?
                 if (file_exists("{$path}Mail.php") && file_exists("{$path}Mail/mime.php")) {
                     // include
                     require_once "{$path}Mail.php";
                     require_once "{$path}Mail/mime.php";
                     // switch
                     $found = TRUE;
                     // we are done here
                     break;
                 }
             }
             if ($found !== TRUE) {
                 throw new Fari_Exception("PEAR Mail:: has not been found");
             }
         } catch (Fari_Exception $exception) {
             $exception->fire();
         }
     }
     // setup the connection details
     $this->setConnection($host, $port, $username, $password);
 }
 /**
  * Display Error or an Exception.
  * @param string $type PHP Error or Fari Exception
  * @param string $file File where the error was thrown
  * @param string $line Line on which the error was thrown
  * @param string $message Message of the error
  */
 public static function display($type, $file, $line, $message, $trace = NULL)
 {
     // clean output
     ob_end_clean();
     // are we on a production server?
     if (Fari_ApplicationEnvironment::isProduction()) {
         self::productionMessage($message);
     }
     // an Ajax request, display a lightweight message
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         die("Fari Exception on line {$line} in \"{$file}\": {$message}");
     }
     // 'build' the header
     self::showHeader();
     // output the message to the user
     echo '<div id="message"><h1>' . $type . '</h1><br />' . $message . '</div>';
     // output information about the file
     echo '<div id="file">File: <b>' . $file . '</b> Line: <b>' . $line . '</b></div>';
     // show the source
     self::showErrorSource($file, $line);
     // show trace if present
     if (!empty($trace)) {
         self::showErrorTrace($trace);
     }
     // show declared classes
     self::showDeclaredClasses();
     // close the whole page properly
     echo '</body></html>';
     // end the misery...
     die;
 }