Example #1
0
/**
 * Add additional info to the cron log. Which module is running
 * at what time. Note: NOT USED
 * @param string $name name of the module running
 */
function cron_message($name)
{
    // Log to cron.log
    $date = date::getDateNow(array('hms' => 1));
    $mes = $date . PHP_EOL;
    $mes .= "RUNNING: {$name}" . PHP_EOL;
    echo $mes;
}
Example #2
0
 /**
  * 
  * @param imap $imap 
  * @param type $x
  */
 public function parseMessage($imap, $x)
 {
     $imap->mail->noop();
     try {
         $message = $imap->mail->getMessage($x);
     } catch (Exception $e) {
         log::error($e->getMessage());
         return false;
     }
     $imap->mail->noop();
     $parts = $imap->getAllParts($message);
     // check for valid message/delivery-status'
     if (!isset($parts['message/delivery-status'][0])) {
         log::debug("No delivery status");
         return false;
     } else {
         $delivery_status = $parts['message/delivery-status'][0];
     }
     $email = self::getBounceEmail($delivery_status);
     if ($email) {
         log::error("Found email in message: {$email}");
         $bean = rb::getBean('mailerbounce');
         $bean->deleted = 0;
         // get bounce code e.g 4.4.2 hotmail
         $bounce_code = trim(self::getBounceCode($delivery_status));
         if ($bounce_code) {
             $bounce_ary = explode('.', $bounce_code);
             $bean->major = $bounce_ary[0];
             $bean->minor = $bounce_ary[1];
             $bean->part = $bounce_ary[2];
             $bean->bouncecode = $bounce_code;
         } else {
             $bean->bouncecode = null;
         }
         $bean->email = $email;
         $bean->bouncedate = date::getDateNow(array('hms' => true));
         $bean->message = $delivery_status;
         $bean->returnpath = $message->getHeader('return-path', 'string');
         R::store($bean);
         log::debug("Stored user with email: {$email}. {$bounce_code}" . PHP_EOL);
     } else {
         log::error("Did not get a mail from message: " . $delivery_status);
     }
     return true;
 }
Example #3
0
 /**
  * sets a system cookie. 
  * @param int $user_id
  * @return boolean $res true on success and false on failure. 
  */
 public static function setSystemCookie($user_id)
 {
     $uniqid = random::md5();
     self::setCookie('system_cookie', $uniqid);
     $db = new db();
     // place cookie in system cookie table
     // last login is auto updated
     $values = array('account_id' => $user_id, 'cookie_id' => $uniqid, 'last_login' => date::getDateNow(array('hms' => true)));
     return $db->insert('system_cookie', $values);
 }
Example #4
0
 /**
  * method that creates birthday dropdown
  * access of the submitted data can be found in the _POST['birth_day'],
  * $_POST['birth_month'], $_POST['birth_year']
  * @param string $name name of the form element
  * @param array $init the init array 
  * @return array $ary array with select elements in array ('day', 'month', 'year')
  */
 public static function birthdayDropdown($name = 'birth', $init = array())
 {
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = array('id' => $i, 'value' => $i);
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = array('id' => $i, 'value' => dateGetMonthName($i));
     }
     $currentYear = date::getCurrentYear();
     $goBack = 120;
     //for ($i = $goBack; $goBack < $currentYear;  $currentYear-- ) {
     while ($goBack) {
         $years[$currentYear] = array('id' => $currentYear, 'value' => $currentYear);
         $currentYear--;
         $goBack--;
     }
     $day = html::selectClean('birth_day', $days, 'id', 'value');
     $month = html::selectClean('birth_month', $months, 'id', 'value');
     $year = html::selectClean('birth_year', $years, 'id', 'value');
     $ret = array('day' => $day, 'month' => $month, 'year' => $year, 'day_options' => $days, 'month_options' => $months, 'year_options' => $years);
     return $ret;
 }
Example #5
0
 /**
  * add or subtract days from timestamp (SQL like)
  * @param int $days e.g. 10 or -10
  * @param string $from e.g. 2013-10-10. Default to now
  * @return string $stamp e.g. 2013-10-20
  */
 public static function daysToTimestamp($days, $from = null)
 {
     if (!$from) {
         $from = date::getDateNow();
     }
     $date = strtotime("{$from} {$days} days");
     $date = date("Y-m-d", $date);
     return $date;
 }