<commit_before><?php

/**
 * Show modified exceptions.
 *
 * @link http://github.com/marcoraddatz/candyCMS
 * @author <NAME> <http://marcoraddatz.com>
 * @license MIT
 * @since 1.0
 *
 */

namespace CandyCMS\Core\Helpers;

use CandyCMS\Core\Controllers\Mails;

class AdvancedException extends \Exception {

  /**
   * Report errors to our log and send a mail to the admin.
   *
   * @static
   * @access public
   * @param type $sMessage
   *
   */
  public static function reportBoth($sMessage) {
    AdvancedException::writeLog($sMessage);

    if (WEBSITE_MODE == 'production' || WEBSITE_MODE == 'staging')
      AdvancedException::sendAdminMail($sMessage);
  }

  /**
   * Send an email to an administrator when an error occurs.
   *
   * @static
   * @access public
   * @return boolean mail status
   *
   */
  public static function sendAdminMail($sMessage) {
    $sMessage = date('Y-m-d Hi', time()) . ' - ' . $sMessage;

    $sClass = \CandyCMS\Core\Controllers\Main::__autoload('Mails', true);
    $oMails = new $sClass(null, null);

    return $oMails->create('Exception',
            $sMessage,
            '',
            WEBSITE_MAIL,
            '',
            WEBSITE_MAIL_NOREPLY,
            '',
            false);
  }

  /**
   * Write down an error message to own log.
   *
   * @static
   * @access public
   *
   */
  public static function writeLog($sMessage) {<commit_msg>bugfix, sending admin mails did not work from advancedException helper<commit_after><?php

/**
 * Show modified exceptions.
 *
 * @link http://github.com/marcoraddatz/candyCMS
 * @author <NAME> <http://marcoraddatz.com>
 * @license MIT
 * @since 1.0
 *
 */

namespace CandyCMS\Core\Helpers;

use CandyCMS\Core\Controllers\Mails;

class AdvancedException extends \Exception {

  /**
   * Report errors to our log and send a mail to the admin.
   *
   * @static
   * @access public
   * @param type $sMessage
   *
   */
  public static function reportBoth($sMessage) {
    AdvancedException::writeLog($sMessage);

    if (WEBSITE_MODE == 'production' || WEBSITE_MODE == 'staging')
      AdvancedException::sendAdminMail($sMessage);
  }

  /**
   * Send an email to an administrator when an error occurs.
   *
   * @static
   * @access public
   * @return boolean mail status
   *
   */
  public static function sendAdminMail($sMessage) {
    $sMessage = date('Y-m-d Hi', time()) . ' - ' . $sMessage;

    $sClass = \CandyCMS\Core\Controllers\Main::__autoload('Mails', true);
    $oMails = new $sClass();

    return $oMails->create('Exception',
            $sMessage,
            '',
            WEBSITE_MAIL,
            '',
            WEBSITE_MAIL_NOREPLY,
            '',
            false);
  }

  /**
   * Write down an error message to own log.
   *
   * @static
   * @access public
   *
   */
  public static function writeLog($sMessage) {
{'fraction_non_alphanumeric': 0.13295814280689414, 'fraction_numerical': 0.0014069644741470278, 'mean_word_length': 2.515451174289246, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5393230', 'n_tokens_mistral': 926, 'n_tokens_neox': 923, 'n_words': 216}