/**
  * CompleteCondition constructor.
  */
 public function __construct()
 {
     /**
      * assume everything is NOT ok
      */
     $isOk = false;
     /**
      * support variable number of arguments for future use
      */
     $args = func_get_args();
     switch (func_num_args()) {
         case 0:
             /**
              * init the time to the maximum possible
              * int for this php build, should be enough
              * to always consider the condition not satisfied
              */
             $this->_param = PHP_INT_MAX;
             $isOk = true;
             break;
         case 1:
             /**
              * args[0] is the time the user wants to set
              */
             $isOk = $this->setIntParam($args[0]);
             break;
         default:
             /**
              * by default, some error has occoured
              */
             $isOk = false;
             break;
     }
     /**
      * handle the error some way...
      */
     if (!$isOk) {
         /**
          * wrong number of arguments, let's take some action:
          * first: log the error. this shall go to log/trace.log file
          */
         ADAFileLogger::log(__CLASS__ . '::' . __METHOD__ . ' WRONG NUMBER OR TYPE OF PARAMETERS');
         /**
          * third: raise an ADA_Error if wrong number of arguments
          * see config_errors.inc.php line 167 and following.
          * depending on the erorr phase / severity something will happen...
          */
         new ADA_Error(NULL, NULL, __METHOD__, AMA_ERR_WRONG_ARGUMENTS, ADA_ERROR_SEVERITY_NONE);
         /**
          * third throw an exception to be catched by the caller
          */
         throw new Exception('Fatal Error: could not instantiate ' . __CLASS__, AMA_ERR_WRONG_ARGUMENTS);
     }
 }
Example #2
0
 /**
  * handles logging of error messages
  * 
  * @param $text	the message to log
  * @return void
  */
 public static function log_error($text)
 {
     /*
      * Always log errors.
      */
     //if(ADA_LOGGING_LEVEL & ADA_LOG_ERROR) {
     switch (ADA_LOG_ERROR_SELECTED_LOGGER) {
         case ADA_LOGGER_SCREEN_LOG:
             ADAScreenLogger::log_error($text);
             break;
         case ADA_LOGGER_FILE_LOG:
             ADAFileLogger::log_error($text, ADA_LOG_ERROR_FILE_LOG_OUTPUT_FILE);
             break;
         case ADA_LOGGER_NULL_LOG:
         default:
     }
     //}
 }
Example #3
0
                $userFullName = '';
                if (!AMA_DB::isError($userInfo)) {
                    // performs user substitutions
                    $HTMLText = str_replace(array("{name}", "{lastname}", "{e-mail}"), array($userInfo['nome'], $userInfo['cognome'], $userInfo['email']), $HTMLModelText);
                    $PLAINText = str_replace(array("{name}", "{lastname}", "{e-mail}"), array($userInfo['nome'], $userInfo['cognome'], $userInfo['email']), $PLAINModelText);
                    $userFullName = ucwords(strtolower($userInfo['nome'] . ' ' . $userInfo['cognome']));
                } else {
                    $HTMLText = $HTMLModelText;
                    $PLAINText = $PLAINModelText;
                    $userFullName = '';
                }
                // $recipient[1] is the email in the current run loop
                $phpmailer->AddAddress($recipient[1], $userFullName);
                $phpmailer->Body = $HTMLText;
                $phpmailer->AltBody = $PLAINText;
                $phpmailer->Send();
                $phpmailer->ClearAllRecipients();
                if ($num < count($recipients) - 1) {
                    ADAFileLogger::log('goin to sleep...', $logFile);
                    usleep($sleepTime);
                    ADAFileLogger::log('...got woken up', $logFile);
                }
            }
            $res = $dh->set_history_status($history_id, MODULES_NEWSLETTER_HISTORY_STATUS_SENT);
            if (AMA_DB::isError($res)) {
                ADAFileLogger::log(print_r($res, true), $logFile);
            }
            ADAFileLogger::log('Done... OK!', $logFile);
        }
    }
}
 /**
  * logs a message in the log file defined in the logFile private property.
  *
  * @param string $text the message to be logged
  *
  * @return unknown_type
  *
  * @access private
  */
 private function _logMessage($text)
 {
     // the file must exists, otherwise logger won't log
     if (!is_file($this->_logFile)) {
         touch($this->_logFile);
     }
     ADAFileLogger::log($text, $this->_logFile);
 }
Example #5
0
 /**
  * Handle this error
  *
  * @return void
  */
 public function handleError()
 {
     $action = $this->getAction();
     /**
      * Non chiamare translateFN sul messaggio di errore.
      */
     /**
      * Error logging
      */
     if ($action & ADA_ERROR_LOG_TO_FILE) {
         ADALogger::log('ADA ERROR LOG TO FILE');
         ADAFileLogger::log_error($this->asTextToLogInFile());
     }
     if ($action & ADA_ERROR_LOG_TO_HTML_COMMENT) {
         ADALogger::log('ADA ERROR LOG TO HTML COMMENT');
     }
     if ($action & ADA_ERROR_LOG_TO_HTML) {
         ADAScreenLogger::log_error($this->asTextToLogInHTML());
     }
     if ($action & ADA_ERROR_LOG_TO_EMAIL) {
         ADALogger::log('ADA ERROR LOG TO EMAIL');
         // TODO: log via email
         /*
          * Richiamare classe mailer per il log, passando come contenuto
          * $this->asTextToLogInFile()
          */
     }
     if ($action & ADA_ERROR_LOG_TO_DB) {
         ADALogger::log('ADA ERROR LOG TO DB');
         // TODO: log su database
         /*
          * Richiamare classe MultiPort per il log su tabella DB passando
          * come argomento $this->asArrayToLogInDB()
          */
     }
     /**
      * Redirect user
      */
     if (is_null($this->redirectTo)) {
         if ($action & ADA_ERROR_REDIRECT_TO_LOGIN) {
             // FIXME: login location == index?
             header('Location:' . HTTP_ROOT_DIR);
             exit;
         }
         if ($action & ADA_ERROR_REDIRECT_TO_HOMEPAGE) {
             $sess_userObj = $_SESSION['sess_userObj'];
             if ($sess_userObj instanceof ADALoggableUser) {
                 header('Location:' . $sess_userObj->getHomePage());
                 exit;
             } else {
                 header('Location:' . HTTP_ROOT_DIR);
                 exit;
             }
         }
         if ($action & ADA_ERROR_REDIRECT_TO_ERROR_PAGE) {
             header('Location:' . HTTP_ROOT_DIR . '/error.php');
             exit;
         }
     } else {
         /*
          * Controlliamo se il programmatore ha specificato un indirizzo commpleto
          * contenente HTTP_ROOT_DIR, altrimenti lo appende.
          */
         if (strncmp(HTTP_ROOT_DIR, $this->redirectTo, sizeof(HTTP_ROOT_DIR)) == 0) {
             header('Location: ' . $this->redirectTo);
             exit;
         }
         header('Location:' . HTTP_ROOT_DIR . '/' . $this->redirectTo);
         exit;
     }
 }