public function format($event)
 {
     switch ($event['priorityName']) {
         case 'ERR':
             $errorType = 'Error';
             $colour = 'red';
             break;
         case 'WARN':
             $errorType = 'Warning';
             $colour = 'orange';
             break;
         case 'NOTICE':
             $errorType = 'Notice';
             $colour = 'grey';
             break;
     }
     if (!is_array($event['message'])) {
         return false;
     }
     $errno = $event['message']['errno'];
     $errstr = $event['message']['errstr'];
     $errfile = $event['message']['errfile'];
     $errline = $event['message']['errline'];
     $errcontext = $event['message']['errcontext'];
     $data = '';
     $data .= '<style type="text/css">html, body, table {font-family: sans-serif; font-size: 12px;}</style>';
     $data .= "<div style=\"border: 5px {$colour} solid;\">\n";
     $data .= "<p style=\"color: white; background-color: {$colour}; margin: 0\">" . "[{$errorType}] {$errstr}<br />{$errfile}:{$errline}\n<br />\n<br />\n</p>\n";
     // Get a backtrace, filtering out debug method calls
     $data .= SS_Backtrace::backtrace(true, false, array('SS_LogErrorEmailFormatter->format', 'SS_LogEmailWriter->_write'));
     // Compile extra data
     $blacklist = array('message', 'timestamp', 'priority', 'priorityName');
     $extras = array_diff_key($event, array_combine($blacklist, $blacklist));
     if ($extras) {
         $data .= "<h3>Details</h3>\n";
         $data .= "<table class=\"extras\">\n";
         foreach ($extras as $k => $v) {
             if (is_array($v)) {
                 $v = var_export($v, true);
             }
             $data .= sprintf("<tr><td><strong>%s</strong></td><td><pre>%s</pre></td></tr>\n", $k, $v);
         }
         $data .= "</table>\n";
     }
     $data .= "</div>\n";
     $relfile = Director::makeRelative($errfile);
     if ($relfile && $relfile[0] == '/') {
         $relfile = substr($relfile, 1);
     }
     $host = @$_SERVER['HTTP_HOST'];
     $uri = @$_SERVER['REQUEST_URI'];
     $subject = "[{$errorType}] in {$relfile}:{$errline} (http://{$host}{$uri})";
     return array('subject' => $subject, 'data' => $data);
 }
 public function format($event)
 {
     switch ($event['priorityName']) {
         case 'ERR':
             $errorType = 'Error';
             $colour = 'red';
             break;
         case 'WARN':
             $errorType = 'Warning';
             $colour = 'orange';
             break;
         case 'NOTICE':
             $errorType = 'Notice';
             $colour = 'grey';
             break;
     }
     if (!is_array($event['message'])) {
         return false;
     }
     $errno = $event['message']['errno'];
     $errstr = $event['message']['errstr'];
     $errfile = $event['message']['errfile'];
     $errline = $event['message']['errline'];
     $errcontext = $event['message']['errcontext'];
     $ref = @$_SERVER['HTTP_REFERER'];
     if (empty($ref)) {
         $ref = 'N/A';
     }
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } else {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $data = "<div style=\"border: 5px {$colour} solid\">\n";
     $data .= "<p style=\"color: white; background-color: {$colour}; margin: 0\">HTTP_REFERER :{$ref} - CLIENT_IP : {$ip}  <br/>{$errorType}: {$errstr}<br/> At line {$errline} in {$errfile}\n<br />\n<br />\n</p>\n";
     // Get a backtrace, filtering out debug method calls
     $data .= SS_Backtrace::backtrace(true, false, array('SS_LogErrorEmailFormatter->format', 'SS_LogEmailWriter->_write'));
     $data .= "</div>\n";
     $relfile = Director::makeRelative($errfile);
     if ($relfile[0] == '/') {
         $relfile = substr($relfile, 1);
     }
     $subject = "{$errorType} at {$relfile} line {$errline} (http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']})";
     return array('subject' => $subject, 'data' => $data);
 }
 /**
  * Get the alfresco seamistrepository connector. 
  * 
  * This is used by this object directly, but also 
  * via AlfrescoContentItems via composition
  * 
  * @return SeaMistRepository
  */
 public function getRemoteRepository()
 {
     // For the first batch, just get all the immediate children of the
     // top level
     $repo = SeaMist::getInstance()->getRepository('Alfresco', $this->ID);
     if (!$repo->isConnected() && $this->ApiUrl) {
         $config = array('apiUrl' => $this->ApiUrl, 'username' => $this->Username, 'password' => $this->Password);
         try {
             $repo->connect($config);
         } catch (Zend_Uri_Exception $zue) {
             error_log("Failed connecting to repository: " . $zue->getMessage() . "\n" . SS_Backtrace::backtrace(true));
         } catch (FailedRequestException $fre) {
             error_log("Failed request: " . $fre->getMessage());
         }
     }
     return $repo;
 }
 /**
  * Get the Cmis seamistrepository connector.
  * 
  * This is used by this object directly, but also 
  * via CmisContentItems via composition
  * 
  * @return SeaMistRepository
  */
 public function getRemoteRepository()
 {
     // For the first batch, just get all the immediate children of the
     // top level
     if (!$this->RepositoryType) {
         return null;
     }
     $repo = SeaMist::getInstance()->getRepository($this->RepositoryType, $this->ID);
     if (!$repo->isConnected() && $this->RepositoryInfoUrl) {
         try {
             $repo->connect($this->RepositoryInfoUrl, $this->RootNodeUrl, $this->Username, $this->Password);
         } catch (Zend_Uri_Exception $zue) {
             error_log("Failed connecting to repository: " . $zue->getMessage() . "\n" . SS_Backtrace::backtrace(true));
         } catch (FailedRequestException $fre) {
             error_log("Failed request: " . $fre->getMessage());
         }
     }
     return $repo;
 }
Example #5
0
 /**
  * Set the environment type of the current site.
  *
  * Typically, a SilverStripe site have a number of environments: 
  *  - development environments, such a copy on your local machine.
  *  - test sites, such as the one you show the client before going live.
  *  - the live site itself.
  * 
  * The behaviour of these environments often varies slightly.  For example, development sites may have errors dumped to the screen,
  * and order confirmation emails might be sent to the developer instead of the client.
  * 
  * To help with this, Sapphire support the notion of an environment type.  The environment type can be dev, test, or live.
  * 
  * You can set it explicitly with Director::set_environment_tpye().  Or you can use {@link Director::set_dev_servers()} and {@link Director::set_test_servers()}
  * to set it implicitly, based on the value of $_SERVER['HTTP_HOST'].  If the HTTP_HOST value is one of the servers listed, then
  * the environment type will be test or dev.  Otherwise, the environment type will be live.
  *
  * Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev
  * mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back.
  * 
  * Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and then push the site into test
  * mode for the remainder of the session. Putting ?isTest=0 onto the URL can turn it back.
  * 
  * Generally speaking, these methods will be called from your _config.php file.
  * 
  * Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and
  * {@link Director::isLive()}.
  * 
  * @param $et string The environment type: dev, test, or live.
  */
 static function set_environment_type($et)
 {
     if ($et != 'dev' && $et != 'test' && $et != 'live') {
         SS_Backtrace::backtrace();
         user_error("Director::set_environment_type passed '{$et}'.  It should be passed dev, test, or live", E_USER_WARNING);
     } else {
         self::$environment_type = $et;
     }
 }
Example #6
0
 /**
  * @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()}
  */
 static function backtrace($returnVal = false, $ignoreAjax = false)
 {
     Deprecation::notice('2.5', 'Use SS_Backtrace::backtrace instead.');
     return SS_Backtrace::backtrace($returnVal, $ignoreAjax);
 }
Example #7
0
 /**
  * @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()}
  */
 static function backtrace($returnVal = false, $ignoreAjax = false)
 {
     user_error('Debug::backtrace() is deprecated. Please use SS_Backtrace::backtrace() instead', E_USER_NOTICE);
     return SS_Backtrace::backtrace($returnVal, $ignoreAjax);
 }