protected function doClean($values)
	{
		$username = isset($values[$this->getOption('username')])?$values[$this->getOption('username')]:null;
		$password = isset($values[$this->getOption('password')])?$values[$this->getOption('password')]:null;
		
		if(($username != OptionPeer::retrieveOption('ADMIN_USERNAME')) || (md5($password) != OptionPeer::retrieveOption('ADMIN_PASSWORD'))) 
			throw new sfValidatorError($this,'invalid');
		
		// login user
		sfContext::getInstance()->getUser()->signIn();
		return $values;
	}
 /**
  * Configure Options Form
  */
 public function configure()
 {
     $this->setWidgets(array('TIMEZONE' => new sfWidgetFormSelect(array('choices' => call_user_func(array('Timezone', 'getTimezones')))), 'MAILFROM_NAME' => new sfWidgetFormInput(), 'MAILFROM_EMAIL' => new sfWidgetFormInput(), 'ADMIN_EMAIL' => new sfWidgetFormInput(), 'CURRENCY_FORMAT' => new sfWidgetFormInput(), 'INVITE_AGE' => new sfWidgetFormInput(), 'BONUS_MAX_CREDIT' => new sfWidgetFormInput(), 'BONUS_INIT_CREDIT' => new sfWidgetFormInput(), 'BONUS_INVITE_CREDIT' => new sfWidgetFormInput(), 'BONUS_ACCEPT_CREDIT' => new sfWidgetFormInput(), 'BONUS_DAYS_PER_CREDIT' => new sfWidgetFormInput(), 'BUY_MAX_YEARS' => new sfWidgetFormInput(), 'BUY_PRICE' => new sfWidgetFormInput(), 'BUY_ORDER_OFFSET' => new sfWidgetFormInput(), 'BUY_NEW_ORDER_LIFETIME' => new sfWidgetFormInput(), 'BUY_EXPIRE_ALERTS' => new sfWidgetFormInput(), 'BUY_DELETE_AFTER' => new sfWidgetFormInput(), 'PAYPAL_ACCOUNT' => new sfWidgetFormInput(), 'PAYPAL_MODE' => new sfWidgetFormSelect(array('choices' => array('S' => 'Sandbox', 'L' => 'Live'))), 'ADMIN_USERNAME' => new sfWidgetFormInput(), 'ADMIN_PASSWORD' => new sfWidgetFormInputPassword(), 'ADMIN_PASSWORD_CONF' => new sfWidgetFormInputPassword(), 'ARTICLE_DISPLAY' => new sfWidgetFormInput(), 'JOTAG_MIN_SIZE' => new sfWidgetFormInput(), 'JOTAG_MAX_SIZE' => new sfWidgetFormInput()));
     $this->setValidators(array('TIMEZONE' => new sfValidatorChoice(array('choices' => array_keys(call_user_func(array('Timezone', 'getTimezones')))), array('invalid' => 'Invalid timezone')), 'MAILFROM_NAME' => new sfValidatorString(array('required' => false)), 'MAILFROM_EMAIL' => new sfValidatorEmail(array('required' => true), array('required' => 'Please enter the email', 'invalid' => 'Invalid email')), 'ADMIN_EMAIL' => new sfValidatorEmail(array('required' => true), array('required' => 'Please enter administration email', 'invalid' => 'Invalid email')), 'CURRENCY_FORMAT' => new sfValidatorString(array('required' => true), array('required' => 'Please enter the currency format')), 'INVITE_AGE' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the invite expiration age', 'invalid' => 'Invalid number')), 'JOTAG_MIN_SIZE' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the minimum size of a JoTAG', 'invalid' => 'Invalid number')), 'JOTAG_MAX_SIZE' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the maximum size of a JoTAG', 'invalid' => 'Invalid number')), 'BONUS_MAX_CREDIT' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the maximum credits', 'invalid' => 'Invalid number')), 'BONUS_INIT_CREDIT' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the initial credits', 'invalid' => 'Invalid number')), 'BONUS_INVITE_CREDIT' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the invited credits', 'invalid' => 'Invalid number')), 'BONUS_ACCEPT_CREDIT' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the acceptance credits', 'invalid' => 'Invalid number')), 'BONUS_DAYS_PER_CREDIT' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the days per credit', 'invalid' => 'Invalid number')), 'BUY_MAX_YEARS' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the max years', 'invalid' => 'Invalid number')), 'BUY_PRICE' => new sfValidatorNumber(array('required' => true), array('required' => 'Please enter the price', 'invalid' => 'Invalid number')), 'BUY_ORDER_OFFSET' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the order number offset', 'invalid' => 'Invalid number')), 'BUY_NEW_ORDER_LIFETIME' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the NEW order lifetime', 'invalid' => 'Invalid number')), 'BUY_EXPIRE_ALERTS' => new sfValidatorString(array('required' => true), array('required' => 'Please enter the expiration alerts')), 'BUY_DELETE_AFTER' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the number of days', 'invalid' => 'Invalid number')), 'PAYPAL_ACCOUNT' => new sfValidatorEmail(array('required' => false), array('invalid' => 'Invalid account')), 'PAYPAL_MODE' => new sfValidatorChoice(array('required' => true, 'choices' => array('S', 'L'))), 'ADMIN_USERNAME' => new sfValidatorRegex(array('required' => true, 'pattern' => '/^[a-zA-Z0-9_]*$/'), array('required' => 'Please enter admin username', 'invalid' => 'Invalid username')), 'ADMIN_PASSWORD' => new sfValidatorString(array('required' => false, 'min_length' => 5, 'max_length' => 10), array('min_length' => 'Password must have at least %min_length% chars', 'max_length' => 'Password must not have more than %max_length% chars')), 'ADMIN_PASSWORD_CONF' => new sfValidatorPass(), 'ARTICLE_DISPLAY' => new sfValidatorInteger(array('required' => true), array('required' => 'Please enter the number of articles to display', 'invalid' => 'Invalid number'))));
     $this->widgetSchema->setLabels(array('TIMEZONE' => 'Timezone', 'MAILFROM_NAME' => 'Default From Email Name', 'MAILFROM_EMAIL' => 'Default From Email Address', 'ADMIN_EMAIL' => 'Administration Email Address', 'CURRENCY_FORMAT' => 'Currency Format', 'INVITE_AGE' => 'Expiration age', 'BONUS_MAX_CREDIT' => 'Maximum Credits', 'BONUS_INIT_CREDIT' => 'Initial Credits', 'BONUS_INVITE_CREDIT' => 'Invited Credits', 'BONUS_ACCEPT_CREDIT' => 'Acceptance Credits', 'BONUS_DAYS_PER_CREDIT' => 'Days Per Credit', 'BUY_MAX_YEARS' => 'Max Years', 'BUY_PRICE' => 'Price', 'BUY_ORDER_OFFSET' => 'Order number offset', 'BUY_NEW_ORDER_LIFETIME' => 'New Order Lifetime', 'BUY_EXPIRE_ALERTS' => 'Expiration Alerts', 'BUY_DELETE_AFTER' => 'Delete JoTAG after', 'PAYPAL_ACCOUNT' => 'Account', 'PAYPAL_MODE' => 'Mode', 'ADMIN_USERNAME' => 'Username', 'ADMIN_PASSWORD' => 'Password', 'ADMIN_PASSWORD_CONF' => 'Confirm Password', 'ARTICLE_DISPLAY' => 'Number of Articles', 'JOTAG_MIN_SIZE' => 'Minimum Size', 'JOTAG_MAX_SIZE' => 'Maximum Size'));
     $this->widgetSchema->setHelps(array('ADMIN_EMAIL' => 'Email address where internal error emails will be sent to', 'CURRENCY_FORMAT' => 'sprintf format', 'INVITE_AGE' => 'How many days an invite is valid', 'BONUS_MAX_CREDIT' => 'Maximum number of credits a user can earn', 'BONUS_INIT_CREDIT' => 'Initial credits for a new account', 'BONUS_INVITE_CREDIT' => 'Initial credits for an new account, created from an invite', 'BONUS_ACCEPT_CREDIT' => 'Number of credits an user receives when an invite is accepted', 'BONUS_DAYS_PER_CREDIT' => 'Number of DAYS each credit represents', 'BUY_NEW_ORDER_LIFETIME' => 'Delete NEW (non-paid) orders after X SECONDS', 'BUY_EXPIRE_ALERTS' => 'Expiration alert triggers, ex: 10, 5, 0, -5, -10', 'BUY_DELETE_AFTER' => 'Delete a JoTAG from user account if expired for more than X days', 'ADMIN_USERNAME' => 'Letters, numbers and _ only', 'ADMIN_PASSWORD' => 'Leave blank to keep current password', 'ADMIN_PASSWORD_CONF' => 'Confirm Password', 'ARTICLE_DISPLAY' => 'Number of articles to display in homepage'));
     $this->widgetSchema->setNameFormat('option[%s]');
     $this->getWidgetSchema()->setFormFormatterName('div');
     $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
     // post validator
     $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(new sfValidatorSchemaCompare('ADMIN_PASSWORD_CONF', sfValidatorSchemaCompare::EQUAL, 'ADMIN_PASSWORD', array(), array('invalid' => 'Password does not match')))));
     // set default values
     foreach ($this->getWidgetSchema()->getFields() as $name => $obj) {
         $this->setDefault($name, OptionPeer::retrieveOption($name));
     }
 }
echo $payment->getReference();
?>
<br/> 
Jotag: <?php 
echo $payment->getTag() ? $payment->getTag()->getJotag() : $payment->getJotag();
?>
<br/> 
Duration: <?php 
echo $payment->getDuration();
?>
 <?php 
echo PaymentPeer::getYearString($payment->getDuration(), false);
?>
<br/>
Order Total: <?php 
echo sprintf(OptionPeer::retrieveOption('CURRENCY_FORMAT'), $payment->getAmount());
?>
<br/> 
User: <?php 
echo $payment->getUser();
?>
<br/>
User Email: <?php 
echo $payment->getUser()->getPrimaryEmail();
?>
<br/> 
Reason: <?php 
if ($reason == 'CANCELLED') {
    ?>
 Tried to process a cancelled order, please verify payment on PayPal<?php 
} elseif ($reason == 'AMMOUNT') {
 public function executeUpdateCredit($request)
 {
     $user = $this->getUser()->getSubscriber();
     $user->setCredits(OptionPeer::retrieveOption('BONUS_INVITE_CREDIT'));
     $user->save();
 }
Beispiel #5
0
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
// load URL helper
sfLoader::loadHelpers('Url');
sfConfig::set('sf_relative_url_root', sfConfig::get('app_general_base_url'));
$c = new Criteria();
$expiration_age = OptionPeer::retrieveOption('BUY_DELETE_AFTER') * 24 * 3600;
$c->add(TagPeer::VALID_UNTIL, time() - $expiration_age, Criteria::LESS_EQUAL);
$c->add(TagPeer::STATUS, TagPeer::ST_EXPIRED);
$c->add(TagPeer::IS_PRIMARY, false);
$tags = TagPeer::doSelect($c);
if ($tags) {
    foreach ($tags as $tag) {
        $interesteds = $tag->getInteresteds();
        $jotag = $tag->getJotag();
        $tag->deleteFromUser();
        Mailer::sendEmail($tag->getUser()->getPrimaryEmail(), 'deletedJotag', array('jotag' => $tag, 'jotag_name' => $jotag), $tag->getUser()->getPreferedLanguage());
        if ($interesteds) {
            foreach ($interesteds as $interested) {
                // notify interested users that this jotag is available again
                Mailer::sendEmail($interested->getUser()->getPrimaryEmail(), 'interestNotifyInterested', array('user' => $interested->getUser(), 'jotag' => $interested->getJotag()), $interested->getUser()->getPreferedLanguage());
            }
			<?php 
    } else {
        ?>
				<?php 
        echo __("Your credits was successfully redeemed. Your new JoTAG (%jotag%) is already available on your account", array("%jotag%" => $jotag->getJotag()));
        ?>
			<?php 
    }
    ?>
		</div>
		<?php 
    if ($user->canReceiveCredits()) {
        ?>
			<p align="center">
				<b><?php 
        echo __("Tell your friends about your personalized JoTAG and we will expand duration of your new JoTAG in %count% days for each friend that signs up!", array("%count%" => OptionPeer::retrieveOption('BONUS_ACCEPT_CREDIT') * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT')));
        ?>
</b><br/><br/>
				<?php 
        echo button_to(__('Invite friends'), '@invite');
        ?>
 <?php 
        echo button_to(__('Not now'), '@account');
        ?>
			</p>
		<?php 
    } else {
        ?>
			<p align="center"><?php 
        echo button_to(__('Return to My Account'), '@account');
        ?>
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
$c = new Criteria();
$expiration_age = OptionPeer::retrieveOption('INVITE_AGE') * 24 * 3600;
$c->add(InvitePeer::CREATED_AT, time() - $expiration_age, Criteria::LESS_EQUAL);
InvitePeer::doDelete($c);
Dear <?php 
echo $owner;
?>
,
Your invite was accepted by <?php 
echo $user;
?>
!
<?php 
if ($credits) {
    ?>
You received <?php 
    echo $credits * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT');
    ?>
 free days in credits!
<?php 
}
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
$c = new Criteria();
$expiration_age = OptionPeer::retrieveOption('BUY_NEW_ORDER_LIFETIME');
$c->add(PaymentPeer::CREATED_AT, time() - $expiration_age, Criteria::LESS_EQUAL);
$c->add(PaymentPeer::STATUS, PaymentPeer::ST_NEW);
$payments = PaymentPeer::doSelect($c);
if ($payments) {
    foreach ((array) $payments as $payment) {
        $payment->setStatus(PaymentPeer::ST_CANCELLED);
        $payment->save();
    }
}
echo __("Password");
?>
:</strong><span>*******</span><span class="actions"><?php 
echo link_to(__('change password'), '@password');
?>
</span></p>
						
				</div>
				<div class="section">
					<h2>Jotags</h2>
					
					<?php 
if ($user->getCredits()) {
    ?>
						<div class="notification"><?php 
    echo __("You have %count% days in credits to get a free JoTAG.", array("%count%" => $user->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT')));
    ?>
 <?php 
    echo link_to(__('Get it Now!'), '@buy');
    ?>
</div> 
					<?php 
}
?>

					<?php 
foreach ($user->getValidTags() as $jotag) {
    ?>
						<p>
							<strong><?php 
    echo esc_entities($jotag->getJotag());
Beispiel #11
0
<?php

if (@$email["first_name"] || @$email["last_name"]) {
    ?>
Dear <?php 
    echo trim($email["first_name"] . " " . $email["last_name"]);
    ?>
,<?php 
}
?>

You were invited joint JoTAG by your friend <?php 
echo $user;
?>
! Click the following link and complete your registration and receive <?php 
echo OptionPeer::retrieveOption('BONUS_INVITE_CREDIT') * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT');
?>
 free days to get a personalized JoTAG:
<?php 
echo url_for('@signup_invite?invite_id=' . $invite->getId(), true);
?>

<?php 
if ($invite->getInviteTagsJoinTag()) {
    ?>

<?php 
    echo $user;
    ?>
's JoTAGs:
<?php 
<p>Dear <?php 
echo $user;
?>
,</p>
<p>Welcome to JoTAG. Please confirm you account clicking on the following link:</p>
<p><?php 
echo link_to(url_for('@confirm_email?confirm_code=' . $email->getConfirmCode(), true), '@confirm_email?confirm_code=' . $email->getConfirmCode(), array("absolute" => true));
?>
</p>
<?php 
if ($user->getCredits()) {
    ?>
	<p>You have <?php 
    echo $user->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT');
    ?>
 free days to get a personalized JoTAG</p> 
<?php 
}
 public function executeIPN($request)
 {
     // rebuild post parameters to send back to paypal
     $req = "";
     foreach ($_POST as $var => $value) {
         $req .= "&{$var}=" . urlencode(stripslashes($value));
     }
     // get transaction info
     $paymentStatus = $request->getParameter('payment_status');
     $transNum = $request->getParameter('txn_id');
     $type = $request->getParameter('custom');
     $paymentId = $request->getParameter('invoice');
     $totalAmount = $request->getParameter('mc_gross');
     $test_ipn = $request->getParameter('test_ipn');
     if ($test_ipn && OptionPeer::retrieveOption('PAYPAL_MODE') == 'L') {
         die('fail');
     }
     // we are NOT in sandbox
     // send back to paypal
     $ch = @curl_init();
     @curl_setopt($ch, CURLOPT_POST, 1);
     @curl_setopt($ch, CURLOPT_URL, OptionPeer::retrieveOption('PAYPAL_MODE') != 'L' ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr");
     @curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate" . $req);
     @curl_setopt($ch, CURLOPT_TIMEOUT, 20);
     @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $result = @curl_exec($ch);
     @curl_close($ch);
     if ($result != "VERIFIED") {
         //can't verify the POST information, most likely fraudulent so exit.
         die('fail');
     }
     // locate payment
     $payment = PaymentPeer::getFromField(PaymentPeer::ID, $paymentId);
     if (!$payment || !in_array($payment->getStatus(), array(PaymentPeer::ST_NEW, PaymentPeer::ST_PENDING))) {
         // tried to process an already paid order, or a cancelled one.. if not paid, alert
         // staff
         if ($payment && $payment->getStatus() != PaymentPeer::ST_PAID) {
             Mailer::sendEmail(OptionPeer::retrieveOption('ADMIN_EMAIL'), 'paymentError', array('payment' => $payment, 'reason' => 'CANCELLED'));
         }
         die('fail');
     }
     // check if transNum is UNIQUE
     $c = new Criteria();
     $c->add(PaymentPeer::REFERENCE, $transNum);
     $c->add(PaymentPeer::METHOD, PaymentPeer::PT_PAYPAL);
     $p = PaymentPeer::doSelectOne($c);
     if ($p && $p->getId() != $payment->getId()) {
         die('fail');
     }
     // duplicated transaction
     $payment->setMethod(PaymentPeer::PT_PAYPAL);
     $payment->setReference($transNum);
     //    if($type == "RENEW") $payment->setType(PaymentPeer::PT_RENEW);
     //    else $payment->setType(PaymentPeer::PT_NEW);
     switch ($paymentStatus) {
         case "Completed":
             // check if value matches
             if ((double) $payment->getAmount() != (double) $totalAmount) {
                 $payment->setStatus(PaymentPeer::ST_ERROR_NOTIFY);
                 $payment->save();
             } else {
                 if (!$payment->getTag()) {
                     $jotag = new Tag();
                     $jotag->setJotag($payment->getJotag());
                     $jotag->setStatus(TagPeer::ST_NEW);
                     $jotag->setUser($payment->getUser());
                     $jotag->setIsPrimary(false);
                 } else {
                     $jotag = $payment->getTag();
                 }
                 // calculate new expiration date
                 $jotag->setValidUntil($jotag->calcNewDate($payment->getDuration()));
                 // try to save new jotag
                 try {
                     $jotag->setStatus(TagPeer::ST_ACTIVE);
                     $jotag->save();
                 } catch (PropelException $e) {
                     // failed to save  jotag, probably due to duplicated jotag (race condition)
                     // we must mark it as ERROR and contact user
                     $payment->setStatus(PaymentPeer::ST_ERROR_NOTIFY);
                     $jotag = null;
                 }
                 if ($jotag) {
                     // everything OK
                     $payment->setTag($jotag);
                     $payment->setJotag('');
                     $payment->setStatus(PaymentPeer::ST_PAID);
                     // remove from interest list
                     $payment->getUser()->delInterest($jotag->getJotag());
                 }
                 $payment->save();
             }
             // send emails
             if ($payment->getStatus() == PaymentPeer::ST_PAID) {
                 // payment processed, notify customer
                 Mailer::sendEmail($payment->getUser()->getPrimaryEmail(), 'paymentConfirmation', array('payment' => $payment), $payment->getUser()->getPreferedLanguage());
             } else {
                 // payment processed, but there was an error creating/updating JoTAG, notify merchant
                 $reason = (double) $payment->getAmount() != (double) $totalAmount ? 'AMMOUNT' : 'DBERROR';
                 Mailer::sendEmail(OptionPeer::retrieveOption('ADMIN_EMAIL'), 'paymentError', array('payment' => $payment, 'reason' => $reason));
             }
             break;
         case "Pending":
             $payment->setStatus(PaymentPeer::ST_PENDING);
             $payment->save();
             break;
         case "Failed":
             $payment->setStatus(PaymentPeer::ST_FAILED);
             $payment->save();
             break;
     }
     return sfView::HEADER_ONLY;
 }
Beispiel #14
0
?>
</b></p>
		<?php 
if (TagPeer::isAvailable($search_jotag)) {
    ?>
			<?php 
    if ($sf_user->isAuthenticated()) {
        ?>
				<p><b><?php 
        echo __("This JoTAG can be yours! Just click <a href=\"%link%\">here</a> to get it for you.", array("%link%" => url_for('@buy_step2?jotag=' . $sf_request->getParameter('search'))));
        ?>
				<?php 
        if ($sf_user->getSubscriber()->getCredits()) {
            ?>
					<?php 
            echo __("You can have this JoTAG for %count% days for free.", array("%count%" => $sf_user->getSubscriber()->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT')));
            ?>
				<?php 
        } else {
            ?>
 
				<?php 
        }
        ?>
				</b></p>
			<?php 
    } else {
        ?>
				<p><b><?php 
        echo __("This JoTAG can be yours! Just click <a href=\"%link%\">here</a> to signup.", array("%link%" => url_for('@signup')));
        ?>
    ?>
 days.</p>
<p>Renew your JoTAG today, clicking <?php 
    echo link_to('here', url_for('@buy_step2?jotag=' . $jotag->getJotag(), true));
    ?>
</p>
<?php 
} else {
    ?>
<p>Your personalized JoTAG - <?php 
    echo $jotag->getJotag();
    ?>
 - expired <?php 
    echo abs($days);
    ?>
 ago.</p>
<p>Don't lose your JoTAG, click <?php 
    echo link_to('here', url_for('@buy_step2?jotag=' . $jotag->getJotag(), true));
    ?>
 to renew it now!</p>
<p>If you don't want to receive this email anymore, just click <?php 
    echo link_to('here', url_for('@cancel_jotag?jotag=' . $jotag->getJotag(), true));
    ?>
</p>
<br/>
<p><i>PS: You JoTAG will be made available to all users <?php 
    echo OptionPeer::retrieveOption('BUY_DELETE_AFTER');
    ?>
 days after expiration date!</i></p>
<?php 
}
sfLoader::loadHelpers('Url');
sfConfig::set('sf_relative_url_root', sfConfig::get('app_general_base_url'));
// set expired tags as EXPIRED
$con = Propel::getConnection(TagPeer::DATABASE_NAME);
try {
    $con->begin();
    $query = sprintf("UPDATE %s SET %s = %d WHERE %s <= ? AND %s = %d AND %s = 0", TagPeer::TABLE_NAME, TagPeer::STATUS, TagPeer::ST_EXPIRED, TagPeer::VALID_UNTIL, TagPeer::STATUS, TagPeer::ST_ACTIVE, TagPeer::IS_PRIMARY);
    $stmt = $con->prepareStatement($query);
    $stmt->setString(1, strftime("%Y-%m-%d 00:00:00"));
    $stmt->executeQuery();
    $con->commit();
} catch (Exception $e) {
    $con->rollback();
    throw $e;
}
$alert_days = explode(",", OptionPeer::retrieveOption('BUY_EXPIRE_ALERTS'));
$today = getdate();
foreach ($alert_days as $day) {
    // build range
    $start = strftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, $today['mon'], $today['mday'] + $day, $today['year']));
    $end = strftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, $today['mon'], $today['mday'] + $day + 1, $today['year']));
    // fetch jotags
    $c = new Criteria();
    $c->add(TagPeer::IS_PRIMARY, false);
    if ($day > 0) {
        $c->add(TagPeer::STATUS, TagPeer::ST_ACTIVE);
    } else {
        $c->add(TagPeer::STATUS, TagPeer::ST_EXPIRED);
    }
    $c->add(TagPeer::VALID_UNTIL, $start, Criteria::GREATER_EQUAL);
    $c->addAnd(TagPeer::VALID_UNTIL, $end, Criteria::LESS_THAN);
		  	</tr>
		    <tr>
		      <td colspan="2">
				<form id="frmSend2PayPal" action="<?php 
    if (OptionPeer::retrieveOption('PAYPAL_MODE') != 'L') {
        ?>
https://www.sandbox.paypal.com/cgi-bin/webscr<?php 
    } else {
        ?>
https://www.paypal.com/cgi-bin/webscr<?php 
    }
    ?>
" method="post" id="frmPaypal">
					<input type="hidden" name="cmd" value="_xclick" />
					<input type="hidden" name="business" value="<?php 
    echo OptionPeer::retrieveOption('PAYPAL_ACCOUNT');
    ?>
" />
					<?php 
    if ($jotag_object) {
        ?>
						<input type="hidden" name="custom" value="RENEW" />
						<input type="hidden" name="item_name" value="<?php 
        echo format_number_choice("[1]Personalized JoTAG - Extra %count% year|[1,+Inf]Personalized JoTAG - Extra %count% years", array("%count%" => $payment->getDuration()), $form["duration"]->getValue());
        ?>
 (<?php 
        echo $payment->getTag()->getJotag();
        ?>
)" />
					<?php 
    } else {
<?php

require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
// initialize instance
sfContext::createInstance($configuration);
// set default TIMEZONE
$tz = OptionPeer::retrieveOption('TIMEZONE');
if ($tz) {
    date_default_timezone_set($tz);
}
// load URL helper
sfLoader::loadHelpers('Url');
sfConfig::set('sf_relative_url_root', sfConfig::get('app_general_base_url'));
// get last time it was executed
$last_run = OptionPeer::retrieveOption("NOTIFY_TAG_CHANGES_LAST_RUN");
$this_run = time();
OptionPeer::updateOption("NOTIFY_TAG_CHANGES_LAST_RUN", $this_run);
if (!$last_run) {
    exit;
}
// this is the very first time we run, just mark last run time
// convert to SQL standard
$last_run_sql = date('Y-m-d H:i:s', $last_run);
$this_run_sql = date('Y-m-d H:i:s', $this_run);
// get all changed info
$changed_objects = array();
foreach (ContactPeer::$CONTACT_CLASSES as $class) {
    // build criteria
    $c = new Criteria();
    $c->add(eval("return {$class}Peer::UPDATED_AT;"), $last_run_sql, Criteria::GREATER_THAN);