Esempio n. 1
0
/**
 * The default exception handler
 *
 * @param object $oException The exception object
 * @return void
 */
function ppi_exception_handler($oException)
{
    if (!$oException instanceof Exception) {
        return false;
    }
    $error = array();
    foreach (array('code', 'message', 'file', 'line', 'traceString') as $field) {
        $fieldName = "_{$field}";
        if (!property_exists($oException, $fieldName)) {
            continue;
        }
        if ($field == 'traceString') {
            $error['backtrace'] = $oException->{$fieldName};
        } else {
            $error[$field] = $oException->{$fieldName};
        }
    }
    try {
        if (!PPI_Registry::getInstance()->exists('PPI_Config')) {
            $oException->show_exceptioned_error($error);
            return;
        }
        $oConfig = PPI_Helper::getConfig();
        $error['sql'] = PPI_Helper::getRegistry()->get('PPI_Model::PPI_Model_Queries', array());
        // email the error with the backtrace information to the developer
        if (!isset($oConfig->system->log_errors) || $oConfig->system->log_errors != false) {
            // get the email contents
            $emailContent = $oException instanceof PPI_Exception ? $oException->getErrorForEmail($error) : '';
            $oLog = new PPI_Model_Log();
            $oLog->addExceptionLog(array('code' => $oException->_code, 'message' => $oException->_message, 'file' => $oException->_file, 'line' => $oException->_line, 'backtrace' => $error['backtrace'], 'post' => serialize($_POST), 'cookie' => serialize($_COOKIE), 'get' => serialize($_GET), 'session' => serialize($_SESSION), 'content' => $emailContent));
            if ($oConfig->system->email_errors) {
                //@mail($oConfig->system->developer_email, 'PHP Exception For '.getHostname(), $emailContent);
                //include CORECLASSPATH.'mail.php';
                //$mail = new Mail();
                //$mail->send();
            }
            // write the error to the php error log
            writeErrorToLog($error['message'] . ' in file: ' . $error['file'] . ' on line: ' . $error['line']);
            $oException->show_exceptioned_error($error);
        }
    } catch (PPI_Exception $e) {
        writeErrorToLog($e->getMessage());
    } catch (Exception $e) {
        writeErrorToLog($e->getMessage());
    } catch (PDOException $e) {
        writeErrorToLog($e->getMessage());
    }
    $oException->show_exceptioned_error($error);
    // @todo This should go to an internal error page which doesn't use framework components and show the error code
    //	ppi_show_exceptioned_error($error);
}
Esempio n. 2
0
 function sendMail()
 {
     // check required properties (to,from,subject,[body](warning(maybe))
     if (is_array($this->_recipient) && count($this->_recipient) < 1) {
         throw new PPI_Exception('Unable to send email: No recipient specified');
     } elseif (is_string($this->_recipient) && $this->_recipient == '') {
         throw new PPI_Exception('Unable to send email: No recipient specified');
     }
     if ($this->_sender == '') {
         throw new PPI_Exception('Unable to send email: No sender specified');
     }
     if ($this->_subject == '') {
         throw new PPI_Exception('Unable to send email: No subject specified');
     }
     $this->setHeaders();
     $this->replaceData();
     // send the mail(s)
     if (is_array($this->_recipient)) {
         foreach ($this->_recipient as $to) {
             $ret = mail($to, $this->_subject, $this->_body, $this->_headers);
         }
     } else {
         $ret = mail($this->_recipient, $this->_subject, $this->_body, $this->_headers);
     }
     // this needs tested on the live server so mail() can work.
     // log the mail send - this is a bug, it will try to insert to ppi_email_templates - this should insert to email_log instead.
     $oLog = new PPI_Model_Log();
     $oLog->addEmailLog($logData);
 }
Esempio n. 3
0
 /**
  * Email log list
  *
  */
 protected function elList()
 {
     $oLog = new PPI_Model_Log();
     $logs = $oLog->getEmailLogs();
     $this->adminLoad('admin/emaillog_list', array('logs' => $logs, 'leftMenu' => true, 'pageTitle' => 'Configuration'));
 }