/**
  *	Load up the customers and organize them based on the date when they registered.
  *	The "from" and "to" timestamps are passed in to determine between which dates
  *	we will retrieve the customers.
  */
 public function CustomerStatsByDateData()
 {
     if (isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) {
         $customers = array();
         $conversions = array();
         $from = (int) $_GET['from'];
         $to = (int) $_GET['to'];
         $x_counter = 0;
         $visitor_xml = "";
         $visitor_dates = array();
         $visitor_rows = array();
         $conversion_xml = "";
         // Create the first components of the XML block
         $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $xml .= "<chart>\n";
         $xml .= "\t<xaxis>\n";
         // Start by building the axis' on the chart based on the selected date range
         // Convert the from and to dates into days then substract "to" from "from" to
         // workout the number of days worth of data we need to chart
         $from_days = $from / 86400;
         $to_days = $to / 86400;
         $num_days = floor($to_days - $from_days) + 1;
         // How many days do we have to show data for? We will break up the data as follows:
         //		0-1 days (shown as hours on x axis)
         //		1-60 days (shown as days on x axis)
         //		61-182 days (shown as weeks on x axis)
         //		182-730 days (shown as months on x axis)
         //		730+ days (shown as years on x axis)
         $day_format = "g:00 A (jS M Y)";
         $week_format = "\\W\\k W";
         $month_format = "M Y";
         $year_format = "Y";
         if ($num_days <= 1) {
             // Get customers and show them for each hour
             $num_val = $num_days;
             if ($num_val == 0) {
                 $num_val = 1;
             }
             for ($i = 0; $i < $num_val * 25; $i++) {
                 $xml .= sprintf("\t\t<value xid=\"%s\">%s</value>\n", isc_date($day_format, $from + 3600 * $i), isc_date($day_format, $from + 3600 * $i));
                 $customers[isc_date($day_format, $from + 3600 * $i)] = 0;
             }
         } else {
             if ($num_days > 1 and $num_days <= 60) {
                 // Get customers and show them for each day
                 for ($i = 0; $i < $num_days; $i++) {
                     $xml .= sprintf("\t\t<value xid=\"%s\">%s</value>\n", isc_date(GetConfig('DisplayDateFormat'), $from + 86400 * $i), isc_date(GetConfig('DisplayDateFormat'), $from + 86400 * $i));
                     $customers[isc_date(GetConfig('DisplayDateFormat'), $from + 86400 * $i)] = 0;
                     $visitor_dates[] = array("format" => isc_date(GetConfig('DisplayDateFormat'), $from + 86400 * $i), "stamp" => $from + 86400 * $i);
                     // Track the conversion rate
                     $conversions[isc_date(GetConfig('DisplayDateFormat'), $from + 86400 * $i)] = 0;
                 }
             } else {
                 if ($num_days > 60 && $num_days <= 182) {
                     // Get customers and show them for each week
                     $num_weeks = ceil($num_days / 7);
                     for ($i = 0; $i < $num_weeks + 1; $i++) {
                         $extended_stamp = sprintf("%s -\n %s", isc_date(GetConfig('DisplayDateFormat'), $from + 604800 * $i), isc_date(GetConfig('DisplayDateFormat'), $from + (604800 * $i + 86400 * 7)));
                         $xml .= sprintf("\t\t<value xid=\"%s\">%s</value>\n", isc_date($week_format, $from + 604800 * $i), $extended_stamp);
                         $customers[isc_date($week_format, $from + 604800 * $i)] = 0;
                         $visitor_dates[] = array("format" => isc_date(GetConfig('DisplayDateFormat'), $from + 604800 * $i), "stamp" => $from + 604800 * $i);
                         // Track the conversion rate
                         $conversions[isc_date(GetConfig('DisplayDateFormat'), $from + 604800 * $i)] = 0;
                     }
                 } else {
                     if ($num_days > 182 and $num_days <= 730) {
                         // Get customers and show them for each month
                         $num_months = ceil($num_days / 31) + 1;
                         $from_month = isc_date("m", $from);
                         $from_year = isc_date("Y", $from);
                         for ($i = 0; $i < $num_months + 1; $i++) {
                             // Workout the timestamp for the first day of the month
                             $first_day_stamp = isc_mktime(0, 0, 0, $from_month + $i, 1, $from_year);
                             $output_format = isc_date($month_format, $first_day_stamp);
                             $xml .= sprintf("\t\t<value xid=\"%s\">%s</value>\n", $output_format, $output_format);
                             $customers[$output_format] = 0;
                             $visitor_dates[] = array("format" => $output_format, "stamp" => $first_day_stamp);
                             // Track the conversion rate
                             $conversions[$output_format] = 0;
                         }
                     } else {
                         if ($num_days > 730) {
                             // Get customers and show them for each year
                             $num_years = ceil($num_days / 365) + 1;
                             $from_year = isc_date("Y", $from);
                             for ($i = 0; $i < $num_years + 1; $i++) {
                                 // Workout the timestamp for the first day of the year
                                 $first_day_stamp = isc_mktime(0, 0, 0, 1, 1, $from_year + $i);
                                 $output_format = isc_date($year_format, $first_day_stamp);
                                 $xml .= sprintf("\t\t<value xid=\"%s\">%s</value>\n", $output_format, $output_format);
                                 $customers[isc_date($year_format, $from + 31536000 * $i)] = 0;
                                 $visitor_dates[] = array("format" => isc_date($year_format, $from + 31536000 * $i), "stamp" => $from + 31536000 * $i);
                                 // Track the conversion rate
                                 $conversions[isc_date($year_format, $from + 31536000 * $i)] = 0;
                             }
                         }
                     }
                 }
             }
         }
         $xml .= "\t</xaxis>\n";
         $xml .= "\t<graphs>\n";
         $xml .= "\t\t<graph gid=\"1\">\n";
         // Start the graph that shows number of customers
         if ($num_days <= 1) {
             // Get customers and show them for each hour
             $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to);
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             // Split the customers based on the day they came in
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 if (isset($customers[isc_date($day_format, $row['custdatejoined'])])) {
                     $customers[isc_date($day_format, $row['custdatejoined'])]++;
                 }
             }
             // We now have the customers in an array based on the date they joined,
             // so we can loop through them to create the first graph on the chart
             $x_counter = 0;
             foreach ($customers as $join_date => $join_count) {
                 $xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", $join_date, $join_count);
             }
         } else {
             if ($num_days > 1 and $num_days <= 60) {
                 // Get customers and show them for each day
                 $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to);
                 $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                 // Split the customers based on the day they came in
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     @$customers[isc_date(GetConfig('DisplayDateFormat'), $row['custdatejoined'])]++;
                 }
                 // We now have the customers in an array based on the date they joined,
                 // so we can loop through them to create the first graph on the chart
                 $x_counter = 0;
                 foreach ($customers as $join_date => $join_count) {
                     $xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", $join_date, $join_count);
                     $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0);
                 }
                 // Build the XML for number of unique visitors
                 $query = sprintf("select datestamp, numuniques from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $from, $to);
                 $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                     $visitor_rows[$row['datestamp']] = $row['numuniques'];
                 }
                 for ($i = 0; $i < count($visitor_dates); $i++) {
                     $date_format = $visitor_dates[$i]['format'];
                     $date_stamp = mktime(0, 0, 0, isc_date("m", $visitor_dates[$i]['stamp']), isc_date("d", $visitor_dates[$i]['stamp']), isc_date("Y", $visitor_dates[$i]['stamp']));
                     // Were there any visitors for this day?
                     if (isset($visitor_rows[$date_stamp])) {
                         $uniques = $visitor_rows[$date_stamp];
                     } else {
                         $uniques = 0;
                     }
                     $visitor_xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", $date_format, $uniques);
                     // Update the conversion array
                     $conversions[$date_format]['visitors'] = $uniques;
                     // Workout the conversion rate and add it to the XML
                     if ($conversions[$date_format]['visitors'] > 0) {
                         $conversion_rate = number_format($conversions[$date_format]['customers'] / $conversions[$date_format]['visitors'] * 100, 2);
                     } else {
                         // Avoid a divide by zero error
                         $conversion_rate = 0;
                     }
                     $conversion_xml .= sprintf("\t\t\t<value xid=\"%s\">%.2f</value>\n", $date_format, $conversion_rate);
                 }
             } else {
                 if ($num_days > 60 && $num_days <= 182) {
                     // Get customers and show them for each week
                     $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to);
                     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                     // Split the customers based on the week they came in
                     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                         $customers[isc_date($week_format, $row['custdatejoined'])]++;
                     }
                     // We now have the customers in an array based on the date t,
                     // so we can loop through them to create the first graph on the chart
                     $x_counter = 0;
                     foreach ($customers as $join_date => $join_count) {
                         $xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", $join_date, $join_count);
                         $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0);
                     }
                     // Loop through each week and calculate the number of visitors during that week
                     foreach ($visitor_dates as $visit_week) {
                         $week_starts = $visit_week['stamp'];
                         $week_ends = $week_starts + 3600 * 7;
                         $query = sprintf("select sum(numuniques) as total from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $week_starts, $week_ends);
                         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                         $visitor_xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", isc_date($week_format, $week_starts), $row['total']);
                         // Update the conversion array
                         $conversions[isc_date($week_format, $week_starts)]['visitors'] = $row['total'];
                         // Workout the conversion rate and add it to the XML
                         if ($conversions[isc_date($week_format, $week_starts)]['visitors'] > 0) {
                             $conversion_rate = number_format($conversions[isc_date($week_format, $week_starts)]['customers'] / $conversions[isc_date($week_format, $week_starts)]['visitors'] * 100, 2);
                         } else {
                             // Avoid a divide by zero error
                             $conversion_rate = 0;
                         }
                         $conversion_xml .= sprintf("\t\t\t<value xid=\"%s\">%.2f</value>\n", isc_date($week_format, $week_starts), $conversion_rate);
                     }
                 } else {
                     if ($num_days > 182 and $num_days <= 730) {
                         // Get customers and show them for each month
                         $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined<= '%s'", $from, $to);
                         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                         // Split the customers based on the week they came in
                         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                             $customers[isc_date($month_format, $row['custdatejoined'])]++;
                         }
                         // We now have the customers in an array based on the date they joined,
                         // so we can loop through them to create the first graph on the chart
                         $x_counter = 0;
                         foreach ($customers as $join_date => $join_count) {
                             $xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", $join_date, $join_count);
                             $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0);
                         }
                         // Loop through each month and calculate the number of visitors during that month
                         foreach ($visitor_dates as $visit_month) {
                             $month_starts = $visit_month['stamp'];
                             $month_ends = $month_starts + 2592000;
                             $query = sprintf("select sum(numuniques) as total from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $month_starts, $month_ends);
                             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                             $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                             $visitor_xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", isc_date($month_format, $month_starts), $row['total']);
                             // Update the conversion array
                             $conversions[isc_date($month_format, $month_starts)]['visitors'] = $row['total'];
                             // Workout the conversion rate and add it to the XML
                             if ($conversions[isc_date($month_format, $month_starts)]['visitors'] > 0) {
                                 $conversion_rate = number_format($conversions[isc_date($month_format, $month_starts)]['customers'] / $conversions[isc_date($month_format, $month_starts)]['visitors'] * 100, 2);
                             } else {
                                 // Avoid a divide by zero error
                                 $conversion_rate = 0;
                             }
                             $conversion_xml .= sprintf("\t\t\t<value xid=\"%s\">%.2f</value>\n", isc_date($month_format, $month_starts), $conversion_rate);
                         }
                     } else {
                         if ($num_days > 730) {
                             // Get customers and show them for each month
                             $query = sprintf("select custdatejoined from [|PREFIX|]customers where custdatejoined >= '%s' and custdatejoined <= '%s'", $from, $to);
                             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                             // Split the customers based on the week they came in
                             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                                 $customers[isc_date($year_format, $row['custdatejoined'])]++;
                             }
                             // We now have the customers in an array based on the date they registered
                             // so we can loop through them to create the first graph on the chart
                             $x_counter = 0;
                             foreach ($customers as $join_date => $join_count) {
                                 $xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", $join_date, $join_count);
                                 $conversions[$join_date] = array("customers" => $join_count, "visitors" => 0);
                             }
                             // Loop through each year and calculate the number of visitors during that year
                             foreach ($visitor_dates as $visit_year) {
                                 $year_starts = $visit_year['stamp'];
                                 $year_ends = $year_starts + 31536000;
                                 $query = sprintf("select sum(numuniques) as total from [|PREFIX|]unique_visitors where datestamp >= '%d' and datestamp <= '%d'", $year_starts, $year_ends);
                                 $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
                                 $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
                                 $visitor_xml .= sprintf("\t\t\t<value xid=\"%s\">%d</value>\n", isc_date($year_format, $year_starts), $row['total']);
                                 // Update the conversion array
                                 $conversions[isc_date($year_format, $year_starts)]['visitors'] = $row['total'];
                                 // Workout the conversion rate and add it to the XML
                                 if ($conversions[isc_date($year_format, $year_starts)]['visitors'] > 0) {
                                     $conversion_rate = number_format($conversions[isc_date($year_format, $year_starts)]['customers'] / $conversions[isc_date($year_format, $year_starts)]['visitors'] * 100, 2);
                                 } else {
                                     // Avoid a divide by zero error
                                     $conversion_rate = 0;
                                 }
                                 $conversion_xml .= sprintf("\t\t\t<value xid=\"%s\">%.2f</value>\n", isc_date($year_format, $year_starts), $conversion_rate);
                             }
                         }
                     }
                 }
             }
         }
         $xml .= "\t\t</graph>\n";
         // Only show visitor data if we're reporting on 2 or more days
         if ($num_days > 1) {
             $xml .= "\t\t<graph gid=\"2\">\n";
             $xml .= $visitor_xml;
             $xml .= "\t\t</graph>\n";
             $xml .= "\t\t<graph gid=\"3\">\n";
             $xml .= $conversion_xml;
             $xml .= "\t\t</graph>\n";
         }
         $xml .= "\t</graphs>\n";
         $xml .= "</chart>";
         // Send the XML back to the browser
         echo $xml;
     }
 }
		protected function _Validate($data = array())
		{
			if(empty($data)) {
				//if this is a control panel manual payment
				if(isset($_POST['paymentField'][$this->GetId()])) {
					$data=$_POST['paymentField'][$this->GetId()];
				//store front normal checkout
				} else {
					$data=$_POST;
				}
			}
			$validatedVariables = array();

			// Check for HTTPS if its required
			if(!strtolower($_SERVER['HTTPS']) == "on") {
				ob_end_clean();
				?>
					<script type="text/javascript">
						alert("<?php echo GetLang($this->_languagePrefix.'NoSSLError'); ?>");
						document.location.href="<?php echo $GLOBALS['ShopPath']; ?>/checkout.php?action=confirm_order";
					</script>
				<?php
				die();
			}

			//basic required credit card fields
			$requiredFields = array(
				"creditcard_cctype"		=> GetLang('CreditCardSelectCardType'),
				"creditcard_name"		=> GetLang('CreditCardEnterName'),
				"creditcard_ccno"		=> GetLang('CreditCardEnterCardNumber'),
				"creditcard_ccexpm"		=> GetLang('CreditCardEnterCreditCardMonth'),
				"creditcard_ccexpy"		=> GetLang('CreditCardEnterCreditCardYear'),
			);
			foreach($requiredFields as $field => $message) {
				if(!isset($data[$field]) || trim($data[$field]) == '') {
					$this->SetError($message);
					return false;
				}
			}

			//if CVV2 is required
			if($this->CardTypeRequiresCVV2($data['creditcard_cctype'])) {
				if(!isset($data['creditcard_cccvd']) || trim($data['creditcard_cccvd']) == '') {
					$this->SetError(GetLang('CreditCardEnterCardCode'));
					return false;
				}
			}

			//if issue date/number is required
			if($this->CardTypeRequiresIssueNoOrDate($data['creditcard_cctype'])) {
				//if issue number is invalid
				if((!isset($data['creditcard_issueno']) || !is_numeric($data['creditcard_issueno']))) {
					// and if issue date is invalid
					if(!isset($data['creditcard_issuedatem']) || !is_numeric($data['creditcard_issuedatem']) || !isset($data['creditcard_issuedatey']) || !is_numeric($data['creditcard_issuedatey'])) {

						$this->SetError(GetLang('CreditCardEnterIssueNoOrDate'));
						return false;
					}
				}
			}



			//if issue date is required
			if($this->CardTypeHasIssueDate($data['creditcard_cctype']) && $this->CardTypeRequiresIssueDate($_POST['creditcard_cctype'])) {
				if(!isset($data['creditcard_issuedatey']) || trim($data['creditcard_issuedatey']) == '') {
					$this->SetError(GetLang('CreditCardSelectCreditCardIssueYear'));
					return false;
				}
				if(!isset($data['creditcard_issuedatem']) || trim($data['creditcard_issuedatem']) == '') {
					$this->SetError(GetLang('CreditCardSelectCreditCardIssueMonth'));
					return false;
				}
			}

			//if issue No is required
			if($this->CardTypeHasIssueNo($data['creditcard_issueno']) && $this->CardTypeRequiresIssueNo($data['creditcard_cctype'])) {
				if(!isset($data['creditcard_issueno']) || trim($data['creditcard_issueno']) == '') {
					$this->SetError(GetLang('CreditCardSelectCreditCardIssueNo'));
					return false;
				}
			}

			//check if credit card expired.
			$currentMY = isc_mktime(0, 0, 0, isc_date('m')+1, 0, isc_date('y'));
			$cardMY = isc_mktime(0, 0, 0, $data['creditcard_ccexpm']+1, 0, $data['creditcard_ccexpy']);
			if ($currentMY > $cardMY) {
				$this->SetError(GetLang('CreditCardExpired'));
				return false;
			}

			$validatedVariables['cctype'] = $data['creditcard_cctype'];
			$validatedVariables['name'] = $data['creditcard_name'];
			$validatedVariables['ccno'] = $data['creditcard_ccno'];
			$validatedVariables['ccissueno'] = $data['creditcard_issueno'];
			$validatedVariables['ccissuedatem'] = $data['creditcard_issuedatem'];
			$validatedVariables['ccissuedatey'] = $data['creditcard_issuedatey'];
			$validatedVariables['cccvd'] = $data['creditcard_cccvd'];
			$validatedVariables['ccexpm'] = $data['creditcard_ccexpm'];
			$validatedVariables['ccexpy'] = $data['creditcard_ccexpy'];

			return $validatedVariables;
		}
Example #3
0
		public function __construct()
		{

			// First up, which page are we on?
			$GLOBALS['Banners'] = array();
			$banners = array();
			$page = "";
			$page_type = "";

			if(isset($GLOBALS['ISC_CLASS_SEARCH'])) {
				$page_type = 'search_page';
			}
			else if(isset($GLOBALS['ISC_CLASS_BRANDS'])) {
				$page_type = 'brand_page';
			}
			else if(isset($GLOBALS['ISC_CLASS_CATEGORY'])) {
				$page_type = 'category_page';
			}
			else if(isset($GLOBALS['ISC_CLASS_INDEX'])) {
				$page_type = 'home_page';
			}

			// Save the page type globally so we can access it from the template engine
			$GLOBALS['PageType'] = $page_type;

			if($page_type != "") {
				$from_stamp = isc_mktime();
				$to_stamp = $from_stamp - 83699;
				$query = "
					SELECT
						*
					FROM
						[|PREFIX|]banners
					WHERE
						page = '" . $GLOBALS['ISC_CLASS_DB']->Quote($page_type) . "' AND
						status = 1 AND
						(
							(datefrom = 0 AND dateto = 0) OR
							(datefrom <= " . $from_stamp . " AND dateto >= " . $to_stamp . ")
						)
					ORDER BY
						RAND()";

				$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

				while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					array_push($banners, $row);
				}

				if($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
					foreach($banners as $banner) {
						if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
							$banner['content'] = str_replace($GLOBALS['ShopPathNormal'], $GLOBALS['ShopPathSSL'], $banner['content']);
						}

						$bannerContent = $banner['content'];
						// Wrap the banner in a div which can be styled
						$banner['content'] = sprintf("<div class='Block BlockContent banner_%s_%s'>%s</div>", $banner['page'], $banner['location'], $bannerContent);

						switch($page_type) {
							case "home_page":
								if(isset($GLOBALS['HomePromoControlScript']) && isset($GLOBALS['HomePromoOptimizerScriptTag']) && isset($GLOBALS['HomePromoOptimizerNoScriptTag'])) {
									$banner['content'] = sprintf($GLOBALS['HomePromoControlScript']
									."<div class='Block BlockContent banner_%s_%s'>".
										$GLOBALS['HomePromoOptimizerScriptTag']."
											%s
									".$GLOBALS['HomePromoOptimizerNoScriptTag']."
									</div>", $banner['page'], $banner['location'], $bannerContent);
								}
							case "search_page": {
								if($banner['location'] == "top" && !isset($GLOBALS['Banners']['top'])) {
									$GLOBALS['Banners']['top'] = $banner;
								}
								else if($banner['location'] == "bottom" && !isset($GLOBALS['Banners']['bottom'])) {
									$GLOBALS['Banners']['bottom'] = $banner;
								}
								break;
							}
							case "brand_page":
							case "category_page": {
								if($banner['location'] == "top" && !isset($GLOBALS['Banners'][$banner['catorbrandid']]['top'])) {
									$GLOBALS['Banners'][$banner['catorbrandid']]['top'] = $banner;
								}
								else if($banner['location'] == "bottom" && !isset($GLOBALS['Banners'][$banner['catorbrandid']]['bottom'])) {
									$GLOBALS['Banners'][$banner['catorbrandid']]['bottom'] = $banner;
								}
								break;
							}
						}
					}
				}
			}
		}
Example #4
0
		/**
		* ProcessPaymentForm
		* Process and validate input from a payment form for this particular
		* gateway.
		*
		* @return boolean True if valid details and payment has been processed. False if not.
		*/
		public function ProcessPaymentForm($dataSource = array())
		{
			if (empty($dataSource)) {
				$dataSource = $_POST;
			}

			$billfirstname = "";
			$billlastname = "";
			$cccode = "";
			$error = false;

			$requiredFields = array(
				"PayflowPro_name"		=> GetLang('PayflowProEnterName'),
				"PayflowPro_ccno"		=> GetLang('PayflowProEnterCardNumber'),
				"PayflowPro_ccexpm"		=> GetLang('PayflowProEnterCreditCardMonth'),
				"PayflowPro_ccexpy"		=> GetLang('PayflowProEnterCreditCardYear'),
			);

			$requireCVV2 = $this->GetValue("PayflowProEnterCVV2Number");
			if($requireCVV2 == "YES") {
				$requiredFields['PayflowPro_cccode'] = GetLang('PayflowProCreditCardCCV2');
				$cccode = $dataSource['PayflowPro_cccode'];
			}

			foreach($requiredFields as $field => $message) {
				if(!isset($dataSource[$field]) || trim($dataSource[$field]) == '') {
					$this->SetError($message);
					return false;
				}
			}
			$currentMY = isc_mktime(0, 0, 0, isc_date('m')+1, 0, isc_date('y'));
			$cardMY = isc_mktime(0, 0, 0, $dataSource['PayflowPro_ccexpm']+1, 0, $dataSource['PayflowPro_ccexpy']);
			if ($currentMY > $cardMY) {
				$this->SetError(GetLang('PayflowProCreditCardExpired').isc_date('m/y', $currentMY)." - ".isc_date('m/y', $cardMY));
				return false;
			}

			if(!isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
				// Invalid payflow response
				$this->SetError(GetLang('PayflowProInvalidOrder'));
				return false;
			}

			$ccname = $dataSource['PayflowPro_name'];
			$ccnum = $dataSource['PayflowPro_ccno'];
			$ccexpm = $dataSource['PayflowPro_ccexpm'];
			$ccexpy = $dataSource['PayflowPro_ccexpy'];
			$ccexp = sprintf("%s%s", $ccexpm, $ccexpy);

			$query = "Select currencycode from [|PREFIX|]currencies Where currencyid = '".$GLOBALS['ISC_CLASS_DB']->Quote(GetConfig('DefaultCurrencyID'))."'";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			$currency = $GLOBALS['ISC_CLASS_DB']->FetchOne($result);

			$orders = $this->GetOrders();
			$orderIds = '#'.implode(', #', array_keys($orders));


			// Load the paypal vendor ID
			$vendorid = $this->GetValue('vendorid');

			// Load the paypal partner ID
			$partnerid = $this->GetValue('partnerid');

			// Load the paypal partner ID
			$userid = $this->GetValue('userid');

			// Load the paypal password
			$password = $this->GetValue('password');

			// Is payflow setup in test or live mode?
			$testmode = $this->GetValue('testmode');

			// Load the paypal transaction Type
			$transactionType = $this->GetValue('transactiontype');

			if($testmode == 'YES') {
				$payflowprourl = 'https://pilot-payflowpro.paypal.com';
			}
			else {
				$payflowprourl = 'https://payflowpro.paypal.com';
			}

			$custip = GetIP();

			$orderdesc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']);

			$billingDetails = $this->GetBillingDetails();

			// Arrange the data into name/value pairs ready to send
			$pp_values = array (
				'USER'		=> $userid,
				'VENDOR'	=> $vendorid,
				'PARTNER'	=> $partnerid,
				'PWD'		=> $password,
				'TENDER'	=> 'C',  // C - Direct Payment using credit card
				'TRXTYPE'	=> $transactionType,  // A - Authorization, S - Sale
				'ACCT'		=> $ccnum,
				'CVV2'		=> $cccode,
				'EXPDATE'	=> $ccexp,
				'AMT'		=> number_format($this->GetGatewayAmount(), 2),
				'CURRENCY'	=> $currency,
				'FIRSTNAME'	=> $billingDetails['ordbillfirstname'],
				'LASTNAME'	=> $billingDetails['ordbilllastname'],
				'STREET'	=> trim($billingDetails['ordbillstreet1'] . " " . $billingDetails['ordbillstreet2']),
				'CITY'		=> $billingDetails['ordbillsuburb'],
				'STATE'		=> $billingDetails['ordbillstate'],
				'ZIP'		=> $billingDetails['ordbillzip'],
				'COUNTRY'	=> $billingDetails['ordbillcountry'],
				'EMAIL'		=> $billingDetails['ordbillemail'],
				'CUSTIP'	=> $custip,
				'INVNUM'	=> $orderIds,
				'ORDERDESC'	=> $orderdesc,
				'VERBOSITY'	=> 'MEDIUM'
			);

			$paypal_query = '';
			foreach ($pp_values as $key => $value) {
				if ($key == 'USER') {
					  $paypal_query .= $key.'['.strlen($value).']='.$value;
				} else {
					  $paypal_query .= '&'.$key.'['.strlen($value).']='.$value;
				}
			}

			// send the request
			$nvpArray = $this->SendData($orderIds, $payflowprourl, $paypal_query);

			$responseCode = isc_html_escape($nvpArray['RESULT']);
			$responseMsg = isc_html_escape($nvpArray['RESPMSG']);
			$transactionId = 0;

			// Load the paypal transaction Type
			$transactionType = $this->GetValue('transactiontype');
			if($transactionType == 'A') {
				$fullTransType = 'authorized';
			} elseif ($transactionType == 'S') {
				$fullTransType = 'captured';
			}


			if (isset($nvpArray['PNREF'])) {
				$transactionId = isc_html_escape($nvpArray['PNREF']);
			}
			$success = true;
			$message = '';
			if ($responseCode == 0) {
				if (isset($nvpArray['AVSADDR']) && $nvpArray['AVSADDR'] != "Y") {
					$message = GetLang('AVSCheckFailed');
				}
				if (isset($nvpArray['AVSZIP']) && $nvpArray['AVSZIP'] != "Y") {
					$message = GetLang('AVSCheckFailed');
				}
				if (isset($nvpArray['CVV2MATCH']) && $nvpArray['CVV2MATCH'] != "Y") {
					$message = GetLang('CVV2CheckFailed');
				}
			} else {
				$success = false;
			}


			$orders = $this->GetOrders();
			$order = current($orders);
			$orderIds = '#'.implode(', #', array_keys($orders));

			if ($success == true) {
				$payflowProSuccess = sprintf(GetLang('PayflowProSuccess'), $orderIds, $transactionId, $responseCode, $responseMsg." ".$message);
				$GLOBALS['ISC_CLASS_LOG']->LogSystemSuccess(array('payment',  $this->GetName()), $payflowProSuccess, $message);

				$this->SetPaymentStatus(PAYMENT_STATUS_PAID);

				$updatedOrder = array(
					'ordpayproviderid' => $transactionId,
					'ordpaymentstatus' => $fullTransType,
				);

				if($message != '') {
					$extraInfo = $order['extrainfo'];
					//store the message in database
					$paymentMessage = array(
						"payment_message" => $message,
						"cardtype" => Store_CreditCard::getCardType($ccnum),
					);

					// Is there any existing extra info for the pending order?
					if($order['extrainfo'] != "") {
						$extraArray = @unserialize($order['extrainfo']);
						if(is_array($extraArray)) {
							$extraInfo = serialize(@array_merge($extraArray, $paymentMessage));
						}
					}
					else {
						$extraInfo = serialize($paymentMessage);
					}

					$updatedOrder['extrainfo'] = $extraInfo;
				}else{
					$extraInfo = $order['extrainfo'];
					//store the card type in database
					$paymentMessage = array(
						"cardtype" => Store_CreditCard::getCardType($ccnum),
					);
					if($order['extrainfo'] != "") {
						$extraArray = @unserialize($order['extrainfo']);
						if(is_array($extraArray)) {
							$extraInfo = serialize(@array_merge($extraArray, $paymentMessage));
						}
					}
					else {
						$extraInfo = serialize($paymentMessage);
					}

					$updatedOrder['extrainfo'] = $extraInfo;
				}

				$this->UpdateOrders($updatedOrder);

				return true;
			} else {

				// Status was declined or error, show the response message as an error
				$payflowError = sprintf(GetLang('PayflowProError'), $orderIds, $transactionId, $responseCode, $responseMsg);
				switch ($responseCode) {

					case 12: // incorrect card number or expiry date
					case 23: // Invalid account number
					case 24: // Invalid expiration date
					case 50: // Insufficient funds available
						$PendingOrder['paymentstatus'] = 3;
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $payflowError);
						$this->RedirectToOrderConfirmation(GetLang('PayflowProDeclinedRedirect'));
						return true;
					case 13: // referral
						$PendingOrder['paymentstatus'] = 2;
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $payflowError);
						return true;
					default: // a system error or duplicate transactions
						$GLOBALS['ISC_CLASS_LOG']->LogSystemError(array('payment', $this->GetName()), $payflowError);
						return false;
				}
			}

			return false;
		}
 /**
  * ProcessPaymentForm
  * Process and validate input from a payment form for this particular
  * gateway.
  *
  * @return boolean True if valid details and payment has been processed. False if not.
  */
 public function ProcessPaymentForm()
 {
     $billfirstname = "";
     $billlastname = "";
     $error = false;
     $requiredFields = array("PayflowPro_name" => GetLang('PayflowProEnterName'), "PayflowPro_ccno" => GetLang('PayflowProEnterCardNumber'), "PayflowPro_ccaddress" => GetLang('PayflowProEnterBillingAddress'), "PayflowPro_ccexpm" => GetLang('PayflowProEnterCreditCardMonth'), "PayflowPro_ccexpy" => GetLang('PayflowProEnterCreditCardYear'), "PayflowPro_zip" => GetLang('PayflowProEnterPostcode'), "PayflowPro_cccity" => GetLang('PayflowProEnterCity'), "PayflowPro_ccstate" => GetLang('PayflowProEnterState'), "PayflowPro_country" => GetLang('PayflowProEnterCountry'));
     $requireCVV2 = $this->GetValue("PayflowProEnterCVV2Number");
     if ($requireCVV2 == "YES") {
         $requiredFields['PayflowPro_cccode'] = GetLang('PayflowProCreditCardCCV2');
     }
     foreach ($requiredFields as $field => $message) {
         if (!isset($_POST[$field]) || trim($_POST[$field]) == '') {
             $this->SetError($message);
             return false;
         }
     }
     $currentMY = isc_mktime(0, 0, 0, isc_date('m') + 1, 0, isc_date('y'));
     $cardMY = isc_mktime(0, 0, 0, $_POST['PayflowPro_ccexpm'] + 1, 0, $_POST['PayflowPro_ccexpy']);
     if ($currentMY > $cardMY) {
         $this->SetError(GetLang('PayflowProCreditCardExpired') . isc_date('m/y', $currentMY) . " - " . isc_date('m/y', $cardMY));
         return false;
     }
     if (isset($_COOKIE['SHOP_ORDER_TOKEN'])) {
         $ccname = $_POST['PayflowPro_name'];
         $ccnum = $_POST['PayflowPro_ccno'];
         $ccaddress = $_POST['PayflowPro_ccaddress'];
         $cccity = $_POST['PayflowPro_cccity'];
         $ccstate = $_POST['PayflowPro_ccstate'];
         $ccexpm = $_POST['PayflowPro_ccexpm'];
         $ccexpy = $_POST['PayflowPro_ccexpy'];
         $ccexp = sprintf("%s%s", $ccexpm, $ccexpy);
         $cczip = $_POST['PayflowPro_zip'];
         $cccode = $_POST['PayflowPro_cccode'];
         $cccountry = $_POST['PayflowPro_country'];
         $query = "Select currencycode from [|PREFIX|]currencies Where currencyid = '" . $GLOBALS['ISC_CLASS_DB']->Quote(GetConfig('DefaultCurrencyID')) . "'";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $currency = $GLOBALS['ISC_CLASS_DB']->FetchOne($result);
         // Split the billing name up into firstname and last name
         $billdetails = explode(" ", $ccname);
         for ($i = 0; $i < count($billdetails) - 1; $i++) {
             $billfirstname .= $billdetails[$i] . " ";
         }
         $billfirstname = trim($billfirstname);
         $billlastname = $billdetails[count($billdetails) - 1];
         $orders = $this->GetOrders();
         $orderIds = '#' . implode(', #', array_keys($orders));
         // Load the paypal vendor ID
         $vendorid = $this->GetValue('vendorid');
         // Load the paypal partner ID
         $partnerid = $this->GetValue('partnerid');
         // Load the paypal partner ID
         $userid = $this->GetValue('userid');
         // Load the paypal password
         $password = $this->GetValue('password');
         // Is payflow setup in test or live mode?
         $testmode = $this->GetValue('testmode');
         // Load the paypal transaction Type
         $transactionType = $this->GetValue('transactiontype');
         if ($testmode == 'YES') {
             $payflowprourl = 'https://pilot-payflowpro.paypal.com';
         } else {
             $payflowprourl = 'https://payflowpro.paypal.com';
         }
         $custip = GetIP();
         $orderdesc = sprintf(GetLang('YourOrderFrom'), $GLOBALS['StoreName']);
         // Fetch the customer details
         $query = sprintf("SELECT * FROM [|PREFIX|]customers WHERE customerid='" . $GLOBALS['ISC_CLASS_DB']->Quote($this->GetCustomerId()) . "'");
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $customer = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         // Arrange the data into name/value pairs ready to send
         $pp_values = array('USER' => $userid, 'VENDOR' => $vendorid, 'PARTNER' => $partnerid, 'PWD' => $password, 'TENDER' => 'C', 'TRXTYPE' => $transactionType, 'ACCT' => $ccnum, 'CVV2' => $cccode, 'EXPDATE' => $ccexp, 'AMT' => number_format($this->GetGatewayAmount(), 2), 'CURRENCY' => $currency, 'FIRSTNAME' => $billfirstname, 'LASTNAME' => $billlastname, 'STREET' => $ccaddress, 'CITY' => $cccity, 'STATE' => $ccstate, 'ZIP' => $cczip, 'COUNTRY' => GetCountryISO2ById($cccountry), 'EMAIL' => $customer['custconemail'], 'CUSTIP' => $custip, 'INVNUM' => $orderIds, 'ORDERDESC' => $orderdesc, 'VERBOSITY' => 'MEDIUM');
         $paypal_query = '';
         foreach ($pp_values as $key => $value) {
             if ($key == 'USER') {
                 $paypal_query .= $key . '[' . strlen($value) . ']=' . $value;
             } else {
                 $paypal_query .= '&' . $key . '[' . strlen($value) . ']=' . $value;
             }
         }
         $nvpArray = $this->SendData($orderIds, $payflowprourl, $paypal_query);
         $_SESSION['PayflowResponse'] = $nvpArray;
         ob_end_clean();
         $token = md5(GetConfig('EncryptionToken') . $_COOKIE['SHOP_ORDER_TOKEN']);
         header(sprintf("Location:%s/finishorder.php?o=%s", $GLOBALS['ShopPathSSL'], $token));
     } else {
         // Invalid payflow response
         $this->SetError(GetLang('PayflowProInvalidOrder'));
         return false;
     }
 }
Example #6
0
	/**
	 * Enabled
	 *
	 * Checks the rule maxuses and expiry date to see if it's valid
	 *
	 * @access public
	 * @return bool enabled
	 */
	public function enabled()
	{

		if ($this->maxuses != 0 && $this->uses >= $this->maxuses) {
			return false;
		}
		// We add 86399 to the expiry because the expiry is stored as the start of the day
		// 86399 adds 23 hours and 59 minutes and 59 seconds to the expiry date
		if ($this->expiry != 0 && isc_mktime() > ($this->expiry + 86399)) {
			return false;
		}

		return $this->enabled;
	}
Example #7
0
	/**
	 * Check if the coupon already expired
	 *
	 * @param integer $couponExpires The integer that indicate the timestamp of the coupon
	 * @return boolean Return true if the coupon already expired.
	 */
	public function isCouponExpired($couponExpires)
	{
		// If the coupon has expired, it can't be used
		if ($couponExpires != 0) {
			// coupon expires at 23:59:59 of the day
			$expires = $couponExpires + 86399;

			if (isc_mktime() > $expires) {
				return true;
			}
		}
		return false;
	}
Example #8
0
 /**
  * Show the dashboard page.
  */
 public function ShowDashboard()
 {
     // Check if there are one or more checkout methods enabled that aren't setup
     $enabledCheckoutMethods = preg_split('/[,\\s]+/s', GetConfig('CheckoutMethods'), -1, PREG_SPLIT_NO_EMPTY);
     $numSetupMethods = 0;
     if (!empty($enabledCheckoutMethods)) {
         $query = "\n\t\t\t\tSELECT count(*)\n\t\t\t\tFROM [|PREFIX|]module_vars\n\t\t\t\tWHERE modulename IN ('" . implode("','", $GLOBALS['ISC_CLASS_DB']->Quote($enabledCheckoutMethods)) . "')\n\t\t\t\tAND variablename='is_setup'\n\t\t\t\tAND variableval='1'\n\t\t\t";
         $numSetupMethods = $GLOBALS['ISC_CLASS_DB']->FetchOne($query);
     }
     if (!empty($enabledCheckoutMethods) && $numSetupMethods == 0) {
         FlashMessage(GetLang('CheckoutNotSetup'), MSG_ERROR);
     }
     // Are there any messages to be shown on the home page?
     $this->template->Assign('Messages', GetFlashMessageBoxes());
     // Fetch the store statistics
     $overviewStatistics = $this->GenerateStoreOverview();
     $statsList = '';
     $i = 0;
     $statsCount = count($overviewStatistics);
     foreach ($overviewStatistics as $statistic) {
         ++$i;
         $this->template->Assign('Count', $statistic['count']);
         $this->template->Assign('Label', $statistic['label']);
         $this->template->Assign('Link', $statistic['link']);
         if ($statsCount == $i) {
             $this->template->Assign('Class', 'Last');
         }
         $statsList .= $this->template->GetSnippet('DashboardAtGlanceItem');
     }
     $this->template->assign('AtGlanceItems', $statsList);
     if (empty($statsList)) {
         $this->template->Assign('HideAtAGlance', 'display: none');
     }
     $gettingStarted = $this->GenerateGettingStartedSteps();
     // If getting started is disabled or isn't supported, hide the toggle links
     if ($gettingStarted === false) {
         $this->template->Assign('HideToggleGettingStartedAtGlance', 'display: none');
     } else {
         $this->template->Assign('GettingStartedSteps', $gettingStarted['steps']);
     }
     // Getting started shouldn't be enabled, or is completed. Show the at a glance by default
     if ($gettingStarted === false || $gettingStarted['hasIncomplete'] == false) {
         $this->template->Assign('HideGettingStarted', 'display: none');
     } else {
         $this->template->Assign('HideOverview', 'display: none');
     }
     // Have we toggled to a specific tab?
     if ($gettingStarted !== false && isset($_COOKIE['DashboardMode'])) {
         switch ($_COOKIE['DashboardMode']) {
             case 'gettingstarted':
                 $this->template->Assign('HideGettingStarted', '');
                 $this->template->Assign('HideOverview', 'display: none');
                 break;
             default:
                 $this->template->Assign('HideGettingStarted', 'display: none');
                 $this->template->Assign('HideOverview', '');
         }
     }
     // Is the "Learn more about using?" disabled? If so, hide it
     if (GetConfig('HideLearnMoreAboutUsing')) {
         $GLOBALS['DisableLearnMoreAboutUsing'] = 'display: none';
     } else {
         $this->template->Assign('LearnMoreAboutUsing1Url', GetConfig('LearnMoreAboutUsing1Url'));
         $this->template->Assign('LearnMoreAboutUsing1Class', GetConfig('LearnMoreAboutUsing1Class'));
         $this->template->Assign('LearnMoreAboutUsing1Title', GetConfig('LearnMoreAboutUsing1Title'));
         $this->template->Assign('LearnMoreAboutUsing2Url', GetConfig('LearnMoreAboutUsing2Url'));
         $this->template->Assign('LearnMoreAboutUsing2Class', GetConfig('LearnMoreAboutUsing2Class'));
         $this->template->Assign('LearnMoreAboutUsing2Title', GetConfig('LearnMoreAboutUsing2Title'));
     }
     // Load up current notifications and assign them if supported
     $currentNotifications = $this->GetCurrentNotifications();
     if (empty($currentNotifications)) {
         $this->template->Assign('HideNotificationsList', 'display: none');
     } else {
         $this->template->Assign('NotificationsList', $currentNotifications);
     }
     // Load in the list of recent orders and set up the status indicators for the selected value
     $recentOrders = $this->LoadRecentOrders();
     if ($recentOrders !== false) {
         if (isset($_COOKIE['DashboardRecentOrdersStatus'])) {
             $selectedItem = ucfirst($_COOKIE['DashboardRecentOrdersStatus']);
         } else {
             $selectedItem = 'Recent';
         }
         $this->template->Assign('RecentOrdersActive' . $selectedItem . 'Class', 'Active');
         $this->template->Assign('RecentOrdersList', $recentOrders);
     }
     if ($recentOrders == false) {
         $this->template->Assign('HideRecentOrders', 'display: none');
     }
     // Calculate the performance indicator statistics
     $performanceIndicators = $this->GeneratePerformanceIndicatorsTable();
     if ($performanceIndicators) {
         if (isset($_COOKIE['DashboardPerformanceIndicatorsPeriod'])) {
             $selectedItem = ucfirst($_COOKIE['DashboardPerformanceIndicatorsPeriod']);
         } else {
             $selectedItem = 'Week';
         }
         $this->template->Assign('PerformanceIndicatorsActive' . $selectedItem, 'Active');
         $this->template->Assign('PerformanceIndicatorsTable', $performanceIndicators);
     } else {
         $this->template->Assign('HidePerformanceIndicators', 'display: none');
     }
     // Generate the breakdown graph for orders and assign it, if supported.
     $orderGraph = $this->GenerateOrderBreakdownGraph();
     if ($orderGraph) {
         $this->template->Assign('DashboardBreakdownGraph', $orderGraph);
     } else {
         $this->template->Assign('HideDashboardBreakdownGraph', 'display: none');
     }
     $versionCheckSetup = $this->SetupVersionCheck();
     $this->template->Assign('VersionCheckMessage', $versionCheckSetup);
     // Hide popular help articles if they're disabled
     if (!GetConfig('LoadPopularHelpArticles')) {
         $this->template->Assign('HidePopularHelpArticles', 'display: none');
     } else {
         $this->template->Assign('ViewKnowledgeBaseLink', GetConfig('ViewKnowledgeBaseLink'));
         if (GetConfig('SearchKnowledgeBaseUrl') == '') {
             $this->template->Assign('HideSearchKnowledgeBase', 'display: none');
         } else {
             $this->template->Assign('SearchKnowledgeBaseUrl', GetConfig('SearchKnowledgeBaseUrl'));
         }
     }
     // Do we have permission to manage orders?
     if (!$this->auth->HasPermission(AUTH_Manage_Orders)) {
         $this->template->Assign('HideManageOrdersLink', 'display: none');
     }
     // Do we have permission to create products?
     if (!$this->auth->HasPermission(AUTH_Create_Product)) {
         $this->template->Assign('HideAddProductLink', 'display: none');
     }
     // Are they running an expiring trial?
     $l = spr1ntf(GetConfig(B('c2VydmVyU3RhbXA=')));
     if ($l['expires'] != '') {
         $d = preg_match('#^(\\d{4})(\\d\\d)(\\d\\d)$#', $l['expires'], $matches);
         $s = mktime(23, 59, 59, $matches[2], $matches[3], $matches[1]);
         $n = isc_mktime();
         $day = floor(($s - $n) / 86400);
         if ($day == 0) {
             $day = 1;
         }
         if ($day > 0) {
             $this->template->Assign('TrialExpiryDetails', sprintf(GetLang('TrialExpiresInXDays'), $day));
             $this->template->Assign('TrialExpiryMessage', $this->template->GetSnippet('DashboardTrialExpiryMessage'));
         }
     }
     $this->engine->stylesheets[] = 'Styles/dashboard.css';
     $this->engine->PrintHeader();
     $this->template->SetTemplate('home');
     // Do we need to re-generate the cache for this page?
     if (cache_time("class.engine.php") > 0) {
         regenerate_cache("class.engine.php");
     }
     $this->template->ParseTemplate();
     $this->engine->PrintFooter();
 }