/**
	* Gets a list of available export file types
	*
	* @return array An array of available file types in the format: filetype => type_details_array[]
	*/
	public static function GetExportFileTypeList()
	{
		$files = scandir(TYPE_ROOT);

		$types = array();

		foreach($files as $file) {
			if(!is_file(TYPE_ROOT . $file) || isc_substr($file, -3) != "php") {
				continue;
			}

			require_once TYPE_ROOT . $file;

			$file = isc_substr($file, 0, isc_strlen($file) - 4);
			/*
			$pos = isc_strrpos($file, ".");
			$typeName = isc_strtoupper(isc_substr($file, $pos + 1));
			*/
			$className = "ISC_ADMIN_EXPORTFILETYPE_" . strtoupper($file); //$typeName;
			if(!class_exists($className)) {
				continue;
			}

			$obj = new $className;
			if (!$obj->ignore) {
				$types[$file] = $obj->GetTypeDetails();
			}
		}

		return $types;
	}
 /**
  * Gets a list of available export methods
  *
  * @return array An array of details about available export methods. methodname => details[]
  */
 public static function GetExportMethodList()
 {
     $files = scandir(METHOD_ROOT);
     $methods = array();
     foreach ($files as $file) {
         if (!is_file(METHOD_ROOT . $file) || isc_substr($file, -3) != "php") {
             continue;
         }
         require_once METHOD_ROOT . $file;
         $file = isc_substr($file, 0, isc_strlen($file) - 4);
         $file = strtoupper($file);
         /*
         $pos = isc_strrpos($file, ".");
         $methodName = isc_strtoupper(isc_substr($file, $pos + 1));
         */
         $className = "ISC_ADMIN_EXPORTMETHOD_" . $file;
         //$methodName;
         if (!class_exists($className)) {
             continue;
         }
         $obj = new $className();
         $methods[$file] = $obj->GetMethodDetails();
     }
     return $methods;
 }
Example #3
0
		protected function _ConstructPostData($postData)
		{

			$billingDetails = $this->GetBillingDetails();

			$qbXML = new SimpleXMLElement('<?qbmsxml version="2.0"?><QBMSXML />');
			$signOnDesktop = $qbXML->addChild('SignonMsgsRq')->addChild('SignonDesktopRq');
			$signOnDesktop->addChild('ClientDateTime', date('Y-m-d\TH:i:s'));
			$signOnDesktop->addChild('ApplicationLogin', $this->GetValue('ApplicationLogin'));
			$signOnDesktop->addChild('ConnectionTicket', $this->GetValue('ConnectionTicket'));
			$signOnDesktop->addChild('Language', 'English');
			$signOnDesktop->addChild('AppID', $this->GetValue('AppID'));
			$signOnDesktop->addChild('AppVer', '1.0');

			$cardChargeRequest = $qbXML->addChild('QBMSXMLMsgsRq')->addChild('CustomerCreditCardChargeRq');
			$cardChargeRequest->addChild('TransRequestID', $this->GetCombinedOrderId());
			$cardChargeRequest->addChild('CreditCardNumber', $postData['ccno']);
			$cardChargeRequest->addChild('ExpirationMonth', $postData['ccexpm']);
			$cardChargeRequest->addChild('ExpirationYear', $postData['ccexpy']);
			$cardChargeRequest->addChild('IsECommerce', 'true');
			$cardChargeRequest->addChild('Amount', $this->GetGatewayAmount());
			$cardChargeRequest->addChild('NameOnCard', isc_substr($postData['name'], 0, 30));
			$cardChargeRequest->addChild('CreditCardAddress', isc_substr($billingDetails['ordbillstreet1'], 0, 30));
			$cardChargeRequest->addChild('CreditCardPostalCode', isc_substr($billingDetails['ordbillzip'], 0, 9));
			$cardChargeRequest->addChild('SalesTaxAmount', $this->GetTaxCost());
			$cardChargeRequest->addChild('CardSecurityCode', $postData['cccvd']);
			return $qbXML->asXML();
		}
Example #4
0
	/**
	* Cuts the provided string to the specified length, applying a suffix if necessary, using the store's current character set.
	*
	* Usage:
	* $str = 'alpha beta gamma';
	* $str = Store_String::rightTruncate($str, 10);
	* // $str === 'alpha b...';
	*
	* @param string $str
	* @param int $length
	* @param string $suffix
	* @return string
	*/
	public static function rightTruncate($str, $length, $suffix = '...')
	{
		$strLength = isc_strlen($str);
		if ($strLength <= $length) {
			return $str;
		}

		$suffixLength = isc_strlen($suffix);
		return isc_substr($str, 0, $length - $suffixLength) . $suffix;
	}
 public function SetPanelSettings()
 {
     $count = 0;
     $GLOBALS['SNIPPETS']['HomeSaleProducts'] = '';
     if (GetConfig('HomeNewProducts') == 0) {
         $this->DontDisplay = true;
         return;
     }
     if (GetConfig('EnableProductReviews') == 0) {
         $GLOBALS['HideProductRating'] = "display: none";
     }
     $query = "\n\t\t\t\tSELECT p.*, FLOOR(prodratingtotal/prodnumratings) AS prodavgrating, imageisthumb, imagefile, " . GetProdCustomerGroupPriceSQL() . "\n\t\t\t\tFROM [|PREFIX|]products p\n\t\t\t\tLEFT JOIN [|PREFIX|]product_images pi ON (p.productid=pi.imageprodid)\n\t\t\t\tWHERE p.prodsaleprice != 0 AND p.prodsaleprice < p.prodprice AND p.prodvisible='1' AND (imageisthumb=1 OR ISNULL(imageisthumb))\n\t\t\t\t" . GetProdCustomerGroupPermissionsSQL() . "\n\t\t\t\tORDER BY RAND()\n\t\t\t";
     $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, GetConfig('HomeNewProducts'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $GLOBALS['AlternateClass'] = '';
     while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if ($GLOBALS['AlternateClass'] == 'Odd') {
             $GLOBALS['AlternateClass'] = 'Even';
         } else {
             $GLOBALS['AlternateClass'] = 'Odd';
         }
         $GLOBALS['ProductCartQuantity'] = '';
         if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
             $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
         }
         $GLOBALS['ProductId'] = $row['productid'];
         $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
         $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
         // Determine the price of this product
         $originalPrice = CalcRealPrice(CalcProdCustomerGroupPrice($row, $row['prodprice']), 0, 0, $row['prodistaxable']);
         $GLOBALS['OriginalProductPrice'] = CurrencyConvertFormatPrice($originalPrice);
         $GLOBALS['ProductPrice'] = CalculateProductPrice($row);
         $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
         // Workout the product description
         $desc = strip_tags($row['proddesc']);
         if (isc_strlen($desc) < 120) {
             $GLOBALS['ProductSummary'] = $desc;
         } else {
             $GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
         }
         $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
         $GLOBALS['SNIPPETS']['HomeSaleProducts'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("HomeSaleProductsItem");
         if (!$GLOBALS['SNIPPETS']['HomeSaleProducts']) {
             $this->DontDisplay = true;
             return;
         }
     }
 }
Example #6
0
		public function SetPanelSettings()
		{
			$GLOBALS['ISC_CLASS_CATEGORY'] = GetClass('ISC_CATEGORY');

			// Should we hide the comparison button?
			if(GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() < 2) {
				$GLOBALS['HideCompareItems'] = "none";
			}

			// Load the products into the reference array
			$GLOBALS['ISC_CLASS_CATEGORY']->GetProducts($products);
			$GLOBALS['CategoryProductListing'] = "";

			if(GetConfig('ShowProductRating') == 0) {
				$GLOBALS['HideProductRating'] = "display: none";
			}

			$display_mode = ucfirst(GetConfig("CategoryDisplayMode"));
			if ($display_mode == "Grid") {
				$display_mode = "";
			}
			$GLOBALS['DisplayMode'] = $display_mode;

			if ($display_mode == "List") {
				if (GetConfig('ShowAddToCartLink') && $GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() > 0) {
					$GLOBALS['HideAddButton'] = '';
				} else {
					$GLOBALS['HideAddButton'] = 'none';
				}

				$GLOBALS['ListJS'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ListCheckForm");
			}

			$GLOBALS['CompareButton'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareButton" . $display_mode);

			if ($display_mode == "List" && $GLOBALS['ISC_CLASS_CATEGORY']->GetNumPages() > 1) {
				$GLOBALS['CompareButtonTop'] = $GLOBALS['CompareButton'];
			}

			$GLOBALS['AlternateClass'] = '';
			foreach($products as $row) {
				$this->setProductGlobals($row);

				// for list style
				if ($display_mode == "List") {
					// get a small chunk of the product description
					$desc = isc_substr(strip_tags($row['proddesc']), 0, 225);
					if (isc_strlen($row['proddesc']) > 225) {
						// trim the description back to the last period or space so words aren't cut off
						$period_pos = isc_strrpos($desc, ".");
						$space_pos = isc_strrpos($desc, " ");
						// find the character that we should trim back to. -1 on space pos for a space that follows a period, so we dont end up with 4 periods
						if ($space_pos - 1 > $period_pos) {
							$pos = $space_pos;
						}
						else {
							$pos = $period_pos;
						}
						$desc = isc_substr($desc, 0, $pos);
						$desc .= "...";
					}

					$GLOBALS['ProductDescription'] = $desc;

					$GLOBALS['AddToCartQty'] = "";

					if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
						if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired']) {
							$GLOBALS['AddToCartQty'] = '<a href="' . $GLOBALS["ProductURL"] . '">' . $GLOBALS['ProductAddText'] . "</a>";
						}
						else {
							$GLOBALS['CartItemId'] = $GLOBALS['ProductId'];
							// If we're using a cart quantity drop down, load that
							if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
								$GLOBALS['Quantity0'] = "selected=\"selected\"";
								$GLOBALS['QtyOptionZero'] = '<option %%GLOBAL_Quantity0%% value="0">Quantity</option>';
								$GLOBALS['QtySelectStyle'] = 'width: auto;';
								$GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
							// Otherwise, load the textbox
							} else {
								$GLOBALS['ProductQuantity'] = 0;
								$GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
							}
						}
					}
				} // for grid style
				else {
					$GLOBALS["CompareOnSubmit"] = "onsubmit=\"return compareProducts(config.CompareLink)\"";
				}

				$GLOBALS['CategoryProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryProductsItem" . $display_mode);
			}

			if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() == 0) {
				// There are no products in this category
				$GLOBALS['CategoryProductListing'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryNoProductsMessage");
				$GLOBALS['HideOtherProductsIn'] = 'none';

				$GLOBALS['ExtraCategoryClass'] = "Wide WideWithLeft";
				if($GLOBALS['SNIPPETS']['SubCategories'] != '') {
					$GLOBALS['CategoryProductListing'] = '';
				}
				$GLOBALS['HideRightColumn'] = "none";
			}
			else {
				$GLOBALS['HideOtherProductsIn'] = 'block';
				$GLOBALS['OtherProductsIn'] = sprintf(GetLang('OtherProductsIn'), $GLOBALS['ISC_CLASS_CATEGORY']->GetName());
			}
		}
 public function _StoreInsArtFileAndReturnId($FileName, $fname)
 {
     $dir = $fname;
     if (is_array($_FILES[$FileName]) && $_FILES[$FileName]['name'] != "") {
         // If it's an image, make sure it's a valid image type
         if (isc_strtolower(isc_substr($_FILES[$FileName]['name'], -3)) != "pdf") {
             return "";
         }
         if (!is_dir(sprintf("../%s", $dir))) {
             @mkdir("../" . $dir, 0777);
         }
         // Clean up the incoming file name a bit
         $_FILES[$FileName]['name'] = preg_replace("#[^\\w.]#i", "_", $_FILES[$FileName]['name']);
         $_FILES[$FileName]['name'] = preg_replace("#_{1,}#i", "_", $_FILES[$FileName]['name']);
         $randomFileName = GenRandFileName($_FILES[$FileName]['name']);
         $dest = realpath(ISC_BASE_PATH . "/" . $dir);
         $dest .= "/" . $randomFileName;
         if (move_uploaded_file($_FILES[$FileName]["tmp_name"], $dest)) {
             isc_chmod($dest, ISC_WRITEABLE_FILE_PERM);
             // The file was moved successfully
             return $randomFileName;
         } else {
             // Couldn't move the file, maybe the directory isn't writable?
             return "";
         }
     } else {
         // The file doesn't exist in the $_FILES array
         return "";
     }
 }
	protected function _GetMaxUploadSize()
	{
		$sizes = array(
			"upload_max_filesize" => ini_get("upload_max_filesize"),
			"post_max_size" => ini_get("post_max_size")
		);
		$max_size = -1;
		foreach($sizes as $size) {
			if (!$size) {
				continue;
			}
			$unit = isc_substr($size, -1);
			$size = isc_substr($size, 0, -1);
			switch(isc_strtolower($unit)) {
				case "g":
					$size *= 1024;
				case "m":
					$size *= 1024;
				case "k":
					$size *= 1024;
			}
			if($max_size == -1 || $size > $max_size) {
				$max_size = $size;
			}
		}
		if($max_size >= 1048576) {
			$max_size = floor($max_size/1048576)."MB";
		} else {
			$max_size = floor($max_size/1024)."KB";
		}
		return $max_size;
	}
Example #9
0
	/**
	 * Generate a list of product fields for configurable products to be shown
	 * for a particular item in the cart based on the customer's configuration.
	 *
	 * @param array $productFields Array containing list of product fields for this product.
	 * @param int $cartItemId The ID of the item in the shopping cart.
	 */
	public function GetProductFieldDetails($productFields, $cartItemId)
	{
		// custom product fields on cart page
		$GLOBALS['HideCartProductFields'] = 'display:none;';
		$GLOBALS['CartProductFields'] = '';
		if(isset($productFields) && !empty($productFields) && is_array($productFields)) {
			$GLOBALS['HideCartProductFields'] = '';
			foreach($productFields as $filedId => $field) {

				switch ($field['type']) {
					//field is a file
					case 'file': {

						//file is an image, display the image
						$fieldValue = '<a target="_Blank" href="'.$GLOBALS['ShopPath'].'/viewfile.php?cartitem='.$cartItemId.'&prodfield='.$filedId.'">'.isc_html_escape($field['fileOriginalName']).'</a>';
						break;
					}
					//field is a checkbox
					case 'checkbox': {
						$fieldValue = GetLang('Checked');
						break;
					}
					//if field is a text area or short text display first
					default: {
						if(isc_strlen($field['value'])>50) {
							$fieldValue = isc_substr(isc_html_escape($field['value']), 0, 50)." ..";
						} else {
							$fieldValue = isc_html_escape($field['value']);
						}
					}
				}

				if(trim($fieldValue) != '') {
					$GLOBALS['CustomFieldName'] = isc_html_escape($field['name']);
					$GLOBALS['CustomFieldValue'] = $fieldValue;
					$GLOBALS['CartProductFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartProductFields");
				}
			}
		}
	}
Example #10
0
		private function EditDiscountStep1()
		{
			$GLOBALS['Title'] = GetLang('EditDiscount');
			$GLOBALS['Intro'] = GetLang('EditDiscountIntro');
			$GLOBALS['Enabled'] = 'checked="checked"';
			$GLOBALS['FormAction'] = "editDiscount2";
			$GLOBALS['DiscountTypes'] = '';
			$GLOBALS['Edit'] = 'display : none;';
			$GLOBALS['DiscountJavascriptValidation'] = '';
			$GLOBALS['DiscountEnabledCheck'] = 'checked="checked"';

			$rules = GetAvailableModules('rule', false, false, false);

			$GLOBALS['RuleList'] = '';

			$GLOBALS['MaxUses'] = '';
			$GLOBALS['DiscountExpiryFields'] = 'display : none';
			$GLOBALS['DiscountMaxUsesDisabled'] = 'readonly="readonly"';
			$GLOBALS['DiscountExpiryDateDisabled'] = 'readonly="readonly"';

			require_once(ISC_BASE_PATH.'/lib/api/discount.api.php');
			$discountAPI = new API_DISCOUNT();

			$discountId = (int) $_GET['discountId'];

			if ($discountAPI->DiscountExists($discountId)) {

				$discount = $this->GetDiscountData($discountId);
				$freeShippingMessageLocations = unserialize($discount['free_shipping_message_location']);
				$GLOBALS['DiscountId'] = $discountId;
				$GLOBALS['DiscountName'] = isc_html_escape($discount['discountname']);

				$module = explode('_',$discount['discountruletype']);

				if (isset($module[1])) {
					GetModuleById('rule', $ruleModule, $module[1]);
					if(!is_object($ruleModule)) {
						// Something really bad went wrong >_<
						exit;
					}
				}
				else {
					die('Can\'t find the module');
				}

				$cd = unserialize($discount['configdata']);

				if (!empty($cd)) {
					foreach ($cd as $var => $data) {

						if (isc_substr($var,0,5) == "varn_") {
							$data = FormatPrice($data, false, false);
						}

						$GLOBALS[$var] = $data;
					}
				}

				$ruleModule->initialize($discount);
				$ruleModule->initializeAdmin();

				$GLOBALS['RuleList'] = '';

				$GLOBALS['Vendor'] = '0';
				if(gzte11(ISC_HUGEPRINT)) {
					$GLOBALS['Vendor'] = 1;
				}

				foreach ($rules as $rule) {
					$rulesSorted[$rule['object']->getRuleType()][] = $rule;
				}

				$first = true;
				$GLOBALS['CurrentRule'] = 'null';

				foreach ($rulesSorted as $type => $ruleType) {

					if ($first) {
						$GLOBALS['RuleList'] .= '<h4 style="margin-top:5px; margin-bottom:5px;">'.$type.' '.GetLang('BasedRule').'</h4>';
					} else {
						$GLOBALS['RuleList'] .= '<h4 style="margin-bottom:5px;">'.$type.' '.GetLang('BasedRule').'</h4>';
					}
					$first = false;

					foreach ($ruleType as $rule) {

						$GLOBALS['RuleList'] .= '<label><input type="radio" class="discountRadio" onClick="UpdateModule(this.id,'.(int)$rule['object']->vendorSupport().')" name="RuleType" value="'.$rule['id'].'" ';
						if ($rule['id'] == $discount['discountruletype']) {
							$GLOBALS['RuleList'] .= ' checked="checked" ';
							$GLOBALS['CurrentRule'] = "'".$rule['id']."'";
						}

						$GLOBALS['RuleList'] .= 'id="'.$rule['id'].'"> ';

						if (!(int)$rule['object']->vendorSupport() && $GLOBALS['Vendor'] == 1) {
							$GLOBALS['RuleList'] .= '<span class="aside">'.$rule['object']->getDisplayName().'</span>';
						} else {
							$GLOBALS['RuleList'] .= '<span>'.$rule['object']->getDisplayName().'</span>';
						}

						$GLOBALS['RuleList'] .= '</input></label><br /><div id="ruleWrapper'.$rule['id'].'" class="ruleWrapper"';

						if ($rule['id'] != $discount['discountruletype'])
							$GLOBALS['RuleList'] .= 'style="display : none; "';

						$GLOBALS['RuleList'] .= '><img src="images/nodejoin.gif" style="vertical-align: middle; float:left; padding-right : 10px;" /><span class="ruleSettings" id="ruleSettings'.$rule['id'].'">';

						if ($rule['id'] == $discount['discountruletype'])
							$GLOBALS['RuleList'] .= $ruleModule->getTemplateClass()->render('module.'.$module[1].'.tpl');

						$GLOBALS['RuleList'] .= '</span><br /></div>';
						$GLOBALS['DiscountJavascriptValidation'] .= $rule['object']->getJavascriptValidation();

					}
				}

				$GLOBALS['DiscountMaxUses'] = isc_html_escape($discount['discountmaxuses']);

				if ($discount['discountexpiry'] != 0) {
					$GLOBALS['DiscountExpiryDate'] = date("m/d/Y", isc_html_escape($discount['discountexpiry']));
				} else {
					$GLOBALS['DiscountExpiryDate'] = '';
				}

				$GLOBALS['DiscountExpiryFields'] = 'display : none';
				$GLOBALS['DiscountMaxUsesDisabled'] = 'readonly="readonly"';
				$GLOBALS['DiscountDisabled'] = 'readonly="readonly"';

				if (!empty($GLOBALS['DiscountMaxUses']) || !empty($GLOBALS['DiscountExpiryDate'])) {
					$GLOBALS['DiscountExpiryCheck'] = 'checked="checked"';
					$GLOBALS['DiscountExpiryFields'] = '';
				}

				if (!empty($GLOBALS['DiscountMaxUses'])) {
					$GLOBALS['DiscountMaxUsesCheck'] = 'checked="checked"';
					$GLOBALS['DiscountMaxUsesDisabled'] = '';
				}
				if (!empty($GLOBALS['DiscountExpiryDate'])) {
					$GLOBALS['DiscountExpiryDateCheck'] = 'checked="checked"';
					$GLOBALS['DiscountExpiryDateDisabled'] = '';
				}

				$GLOBALS['DiscountEnabled'] = isc_html_escape($discount['discountenabled']);

				if (empty($GLOBALS['DiscountEnabled'])) {
					$GLOBALS['DiscountEnabledCheck'] = '';
				}

				$GLOBALS['DiscountCurrentUses'] = isc_html_escape($discount['discountcurrentuses']);

				$GLOBALS['MaxUses'] = (int) $discount['discountmaxuses'];
				if($GLOBALS['MaxUses'] > 0) {
					$GLOBALS['MaxUsesChecked'] = 'checked="checked"';
				}
				else {
					$GLOBALS['DiscountMaxUses'] = 1;
					$GLOBALS['MaxUsesHide'] = 'none';
				}
				$this->template->assign('freeShippingMessage', $discount['free_shipping_message']);
				$this->template->assign('freeShippingMessageLocations', $freeShippingMessageLocations);

				$this->template->display('discount.form.tpl');

			}
			else {
				// The discount doesn't exist
				if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Discounts)) {
					$this->ManageDiscounts(GetLang('DiscountDoesntExist'), MSG_ERROR);
				} else {
					$GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
				}
			}
		}
Example #11
0
	public function _GetBackupList()
	{
		$backups = array();

		if(!is_dir(ISC_BACKUP_DIRECTORY)) {
			isc_mkdir(ISC_BACKUP_DIRECTORY);
		}

		if(is_dir(ISC_BACKUP_DIRECTORY)) {
			$dh = opendir(ISC_BACKUP_DIRECTORY);
			if($dh) {
				while(($file = readdir($dh)) !== false) {
					if(isc_substr($file, 0, 6) == "backup") {
						$backups[$file] = array(
							"size" => filesize(ISC_BACKUP_DIRECTORY . $file),
							"mtime" => filemtime(ISC_BACKUP_DIRECTORY . $file)
						);
						if(!is_file(ISC_BACKUP_DIRECTORY . $file)) {
							$backups[$file]['directory'] = 1;
						}
					}
				}
			}
		}

		return $backups;
	}
Example #12
0
	public function buildXML()
	{
		if (isc_strtolower($this->spool["service"]) !== "add" && is_array($this->spoolReferenceData)) {
			$this->writeEscapedElement("ListID", $this->spoolReferenceData["ListID"]);
			$this->writeEscapedElement("EditSequence", $this->spoolReferenceData["EditSequence"]);
		}elseif(isc_strtolower($this->spool["service"]) !== "add"){
			$fullName = $this->spoolNodeData["FirstName"] . ' ' . $this->spoolNodeData["LastName"];
			$query = "SELECT * FROM [|PREFIX|]accountingref WHERE accountingreftype='customerguest' AND accountingrefvalue LIKE '%" . $GLOBALS["ISC_CLASS_DB"]->Quote($fullName) . "%' ORDER BY accoutingrefid DESC LIMIT 1";
			$result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
			if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
				$this->writeEscapedElement("ListID", @unserialize($row["ListID"]));
				$this->writeEscapedElement("EditSequence", @unserialize($row['EditSequence']));
			}
		}

		$this->buildCustomerGuestNameNode($name, $this->spoolNodeData["OrderID"]);

		$this->writeEscapedElement("Name", isc_substr($this->spoolNodeData["FirstName"] . ' ' . $this->spoolNodeData["LastName"], 0, 50));
		$this->writeEscapedElement("IsActive", "true");

		$customerTypeListId = $this->accounting->getCustomerParentTypeListId(true);

		if (!$customerTypeListId || trim($customerTypeListId) == '') {
				throw new QBException("Unable to find customer parent type reference for guest checkout in customerguest", $this->spool);
		}

		$this->xmlWriter->startElement("ParentRef");
		if (isc_strtolower($this->spool["service"]) == "add") {
			$this->writeEscapedElement("FullName", 'Cart Guest Checkout Customers');
		}else{
			$this->writeEscapedElement("ListID", $customerTypeListId);
		}
		$this->xmlWriter->endElement();


		/**
		 * Cannot be set if it is empty
		 */
		if ($this->spoolNodeData["FirstName"] !== '') {
			$this->writeEscapedElement("FirstName", isc_substr($this->spoolNodeData["FirstName"], 0, 25));
		}

		/**
		 * Same with this one
		 */
		if ($this->spoolNodeData["LastName"] !== '') {
			$this->writeEscapedElement("LastName", isc_substr($this->spoolNodeData["LastName"], 0, 25));
		}


		if (isset($this->spoolNodeData["ordbillphone"]) && $this->spoolNodeData["ordbillphone"] !== '') {
			$this->writeEscapedElement("Phone", $this->spoolNodeData["ordbillphone"]);
		} elseif (isset($this->spoolNodeData["Phone"]) && $this->spoolNodeData["Phone"] !== '') {
			$this->writeEscapedElement("Phone", $this->spoolNodeData["Phone"]);
		} else {
			$this->writeEscapedElement("Phone", '555-555-6666');
		}

		if (isset($this->spoolNodeData["ordbillemail"]) && $this->spoolNodeData["ordbillemail"] !== '') {
			$this->writeEscapedElement("Email", $this->spoolNodeData["ordbillemail"]);
		} elseif (isset($this->spoolNodeData["Email"]) && $this->spoolNodeData["Email"] !== '') {
			$this->writeEscapedElement("Email", $this->spoolNodeData["Email"]);
		} else {
			$this->writeEscapedElement("Email", '*****@*****.**');
		}

		return $this->buildOutput();
	}
Example #13
0
		/**
		* _ReplaceTokens
		* Replace the placeholder tokens with values from the database
		*
		* @param String $row The row from the CSV file
		* @param Array $Data A reference to the database row for the product
		* @return String
		*/
		private function _ReplaceTokens($Row, &$Data)
		{

			$tokens = $this->_GetTokens();

			foreach($this->_GetTokens() as $token => $val) {
				if(isset($Data[$val]) || $token == "{PRODLINK}" || $token == "{STORENAME}") {
					switch($token) {
						case "{PRODSUMMARY}": {
							$Data[$val] = $this->_Strip(strip_tags($Data[$val]));

							if(strlen($Data[$val]) > 32) {
								$Data[$val] = isc_substr($Data[$val], 0, 32) . "...";
							}

							$Data[$val] = trim($Data[$val]);
							$Data[$val] = str_replace("\n", "", $Data[$val]);
							$Data[$val] = str_replace("\r", "", $Data[$val]);
							$Data[$val] = str_replace("\t", " ", $Data[$val]);
							break;
						}
						case "{PRODPRICE}": {
							$price = getClass('ISC_TAX')->getPrice($Data[$val], $Data['tax_class_id'], getConfig('taxDefaultTaxDisplayProducts'));
							$Data[$val] = FormatPrice($price, false, true);
							break;
						}
						case "{PRODLINK}": {
							$Data[$val] = ProdLink($Data['prodname']);
							break;
						}
						case "{STORENAME}": {
							$Data[$val] = GetConfig("StoreName");
							break;
						}
					}

					// Replace the value from the row
					$Row = str_replace($token, $Data[$val], $Row);
				}
				else {
					// Replace the value with nothing
					$Row = str_replace($token, "", $Row);
				}
			}

			$Row = str_replace("{Campaign Name}", GetConfig('StoreName'), $Row);
			$Row = str_replace("{Ad Group Name}", $this->_Strip($Data['prodname']), $Row);
			$Row = str_replace("{Component Type}", "Ad", $Row);
			$Row = str_replace("{Component Status}", "On", $Row);
			$Row = str_replace("{Keyword}", "", $Row);
			$Row = str_replace("{Keyword Alt Text}", "", $Row);
			$Row = str_replace("{Keyword Custom URL}", "", $Row);
			$Row = str_replace("{Sponsored Search Bid (USD)}", "", $Row);
			$Row = str_replace("{Sponsored Search Bid Limit (USD)}", "", $Row);
			$Row = str_replace("{Sponsored Search Status}", "", $Row);
			$Row = str_replace("{Match Type}", "", $Row);
			$Row = str_replace("{Content Match Bid (USD)}", "", $Row);
			$Row = str_replace("{Content Match Bid Limit (USD)}", "", $Row);
			$Row = str_replace("{Content Match Status}", "", $Row);
			$Row = str_replace("{Ad Name}", $this->_BuildAdName($Data['prodname']), $Row);
			$Row = str_replace("{Watch List}", "", $Row);
			$Row = str_replace("{Campaign ID}", "", $Row);
			$Row = str_replace("{Campaign Description}", "", $Row);
			$Row = str_replace("{Campaign Start Date}", "", $Row);
			$Row = str_replace("{Campaign End Date}", "", $Row);
			$Row = str_replace("{Ad Group ID}", "", $Row);
			$Row = str_replace("{Ad Group: Optimize Ad Display}", "", $Row);
			$Row = str_replace("{Ad ID}", "", $Row);
			$Row = str_replace("{Keyword ID}", "", $Row);
			$Row = str_replace("{Checksum}", "", $Row);
			$Row = str_replace("{Error Message}", "", $Row);

			// Run one final trim
			$Row = trim($Row);

			// Return the row
			return $Row;
		}
Example #14
0
	/**
	 * Write an XML node element with raw value
	 *
	 * Method will write an XML node element WITHOUT encoding the value. PLEASE BE CAREFULL!!!
	 *
	 * @access protected
	 * @param string $name The XML node name
	 * @param string $value The XML node value
	 * @param int $maxLength The optional maximum length of the value. Default is 0 (unlimited)
	 * @return bool TRUE if the node was created, FALSE on error
	 */
	protected function writeRawElement($name, $value, $maxLength=0)
	{
		if (trim($name) == "") {
			return false;
		}

		if ($maxLength > 0) {
			$value = isc_substr($value, 0, $maxLength);
		}

		$this->xmlWriter->startElement($name);
		$this->xmlWriter->writeRaw($value);
		$this->xmlWriter->endElement();

		return true;
	}
	public function buildXML()
	{
		if (isc_strtolower($this->spool["service"]) == "edit" && is_array($this->spoolReferenceData)) {
			$this->writeEscapedElement("ListID", $this->spoolReferenceData["ListID"]);
			$this->writeEscapedElement("EditSequence", $this->spoolReferenceData["EditSequence"]);
		}

		$this->buildProductVariationNameNode($this->spoolNodeData["prodname"], $this->spoolNodeData["combinationid"]);
		$this->writeEscapedElement("IsActive", "true");

		/**
		 * Set the product variation parent. Only do this for adding (want to edit the least amount as possible)
		 */
		if (isc_strtolower($this->spool["service"]) == "add") {
			$productTypeListId = $this->accounting->getProductParentTypeListId(true);

			if (!$productTypeListId || trim($productTypeListId) == '') {
				throw new QBException("Unable to find product parent type reference for product variation in productvariation", $this->spool);
			}

			$this->xmlWriter->startElement("ParentRef");
			$this->writeEscapedElement("ListID", $productTypeListId);
			$this->xmlWriter->endElement();
		}

		if ($this->compareClientVersion("7.0") && isset($this->spoolNodeData["vcsku"]) && $this->spoolNodeData["vcsku"] !== "") {
			$this->writeEscapedElement("ManufacturerPartNumber", $this->spoolNodeData["vcsku"]);
		}

		/**
		 * OK, different tag names for different versions for different countries. Good times, good times
		 */
		if ($this->compareClientCountry("uk") || $this->compareClientCountry("ca")) {
			if ($this->compareClientVersion("3.0")) {
				$this->xmlWriter->startElement("TaxCodeForSaleRef");
			} else {
				$this->xmlWriter->startElement("TaxCodeRef");
			}
		} else {
			$this->xmlWriter->startElement("SalesTaxCodeRef");
		}

		$this->writeEscapedElement("FullName", "NON");
		$this->xmlWriter->endElement();

		$this->writeEscapedElement("SalesDesc", isc_substr($this->spoolNodeData["prodvariationname"], 0, 4095));
		$prodPrice = CalcProductVariationPrice($this->spoolNodeData["prodprice"], $this->spoolNodeData["vcpricediff"], $this->spoolNodeData["vcprice"]);
		$this->writeEscapedElement("SalesPrice", number_format($prodPrice, 2, ".", ""));

		/**
		 * We can only set this for the add process as the mod process is only available in versions 7.0 and above
		 */
		if (isc_strtolower($this->spool["service"]) == "add" || $this->compareClientVersion("7.0")) {

			$incomeAccountListId = $this->accounting->getAccountListId("income");

			if (trim($incomeAccountListId) == '') {
				throw new QBException("Cannot find the income account ListID for product variation ID: " . $this->spoolNodeData["combinationid"], $this->spool);
			}

			$this->xmlWriter->startElement("IncomeAccountRef");
			$this->writeEscapedElement("ListID", $incomeAccountListId);
			$this->xmlWriter->endElement();
		}

		if (isset($this->spoolNodeData["prodcostprice"]) && $this->spoolNodeData["prodcostprice"] > 0) {
			$this->writeEscapedElement("PurchaseDesc", isc_substr($this->spoolNodeData["prodvariationname"], 0, 4095));
			$this->writeEscapedElement("PurchaseCost", number_format($this->spoolNodeData["prodcostprice"], 2, ".", ""));
		}

		$cogsAccountListId = $this->accounting->getAccountListId("costofgoodssold");

		if (trim($cogsAccountListId) == '') {
			throw new QBException("Cannot find the cogs account ListID for product variation ID: " . $this->spoolNodeData["combinationid"], $this->spool);
		}

		$this->xmlWriter->startElement("COGSAccountRef");
		$this->writeEscapedElement("ListID", $cogsAccountListId);
		$this->xmlWriter->endElement();

		$fixedAccountListId = $this->accounting->getAccountListId("fixedasset");

		if (trim($fixedAccountListId) == '') {
			throw new QBException("Cannot find the fixed account ListID for product ID: " . $this->spoolNodeData["combinationid"], $this->spool);
		}

		$this->xmlWriter->startElement("AssetAccountRef");
		$this->writeEscapedElement("ListID", $fixedAccountListId);
		$this->xmlWriter->endElement();

		/**
		 * Only do this is we are a new product OR if we are handling the inventory levels
		 */
		if (isc_strtolower($this->spool["service"]) == "add" || $this->accounting->getValue("invlevels") == ACCOUNTING_QUICKBOOKS_TYPE_SHOPPINGCART) {
			$this->writeEscapedElement("ReorderPoint", (int)$this->spoolNodeData["vclowstock"]);
		}

		if ($this->compareClientCountry("uk") && $this->compareClientVersion("2.0")) {
			if (GetConfig("PricesIncludeTax")) {
				$this->writeEscapedElement("AmountIncludesVAT", "1");
			} else {
				$this->writeEscapedElement("AmountIncludesVAT", "0");
			}
		}

		return $this->buildOutput();
	}
		/**
		 * Return a list of any manual payment fields that should be shown when creating/editing
		 * an order via the control panel, if any.
		 *
		 * @param array An array containing the details of existing values, if any.
		 * @return array An array of manual payment fields.
		 */
		public function GetManualPaymentFields($existingOrder=array())
		{
			$monthOptions = '';
			$issueMonthOptions = '<option value="">&nbsp;</option>';
			for($i = 1; $i <= 12; $i++) {
				$stamp = mktime(0, 0, 0, $i, 15, date("Y"));
				$i = str_pad($i, 2, "0", STR_PAD_LEFT);

				$monthOptions .= '<option value="'.$i.'">'.date('M', $stamp).'</option>';

				$issueMonthOptions .= '<option value="'.$i.'">'.date('M', $stamp).'</option>';
			}

			$yearOptions = '';
			for($i = date("Y"); $i <= date("Y")+10; $i++) {
				$value = isc_substr($i, 2, 2);
				$yearOptions .= '<option value="'.$value.'">'.$i.'</option>';
			}

			$issueYearOptions = '<option value="">&nbsp;</option>';
			for($i = date("Y"); $i > date("Y")-5; --$i) {
				$value = isc_substr($i, 2, 2);
				$issueYearOptions .= '<option value="'.$value.'">'.$i.'</option>';
			}

			$cardOptions = $this->_GetCCTypes();
			return array(
				'creditcard_name' => array(
					'type' => 'text',
					'title' => GetLang('CCManualCardHoldersName'),
					'value' => '',
					'required' => true
				),
				'creditcard_cctype' => array(
					'type' => 'select',
					'title' => GetLang('CCManualCreditCardType'),
					'options' => $cardOptions,
					'onchange' => "PaymentValidation_" . $this->GetId() . ".updateCreditCardType()",
					'required' => true
				),
				'creditcard_ccno' => array(
					'type' => 'text',
					'title' => GetLang('CCManualCreditCardNo'),
					'value' => '',
					'required' => true
				),
				'creditcard_cccvd' => array(
					'type' => 'text',
					'title' => GetLang('CCManualCreditCardCCV2'),
					'value' => '',
					'required' => true,
					'class' => 'Field50',
				),
				'creditcard_ccexp' => array(
					'type' => 'html',
					'title' => GetLang('CCManualExpirationDate'),
					'html' => '
						<select name="paymentField[' . $this->GetId() . '][creditcard_ccexpm]">'.$monthOptions.'</select>
						&nbsp;
						<select name="paymentField[' . $this->GetId() . '][creditcard_ccexpy]">'.$yearOptions.'</select>
					',
					'required' => true
				),
				'creditcard_issueno' => array(
					'type' => 'text',
					'title' => GetLang('CCManualCreditCardIssueNo'),
					'value' => '',
					'required' => true
				),
				'creditcard_issuedate' => array(
					'type' => 'html',
					'title' => GetLang('CCManualIssueDate'),
					'html' => '
						<select name="paymentField[' . $this->GetId() . '][creditcard_issuedatem]">'.$issueMonthOptions.'</select>
						&nbsp;
						<select name="paymentField[' . $this->GetId() . '][creditcard_issuedatey]">'.$issueYearOptions.'</select>
					',
					'required' => true
				)
			);
		}
Example #17
0
	public function setProductGlobals($row)
	{
		if($GLOBALS['AlternateClass'] == 'Odd') {
			$GLOBALS['AlternateClass'] = 'Even';
		}
		else {
			$GLOBALS['AlternateClass'] = 'Odd';
		}

		$GLOBALS['ProductCartQuantity'] = '';
		if(isset($GLOBALS['CartQuantity'.$row['productid']])) {
			$GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$row['productid']];
		}

		$GLOBALS['ProductId'] = (int)$row['productid'];
		$GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
		$GLOBALS['ProductLink'] = ProdLink($row['prodname']);
		$GLOBALS['ProductRating'] = (int)$row['prodavgrating'];

		// Determine the price of this product
		$GLOBALS['ProductPrice'] = '';
		if (GetConfig('ShowProductPrice') && !$row['prodhideprice']) {
			$GLOBALS['ProductPrice'] = formatProductCatalogPrice($row);
		}

		// Workout the product description
		$desc = strip_tags($row['proddesc']);

		if (isc_strlen($desc) < 120) {
			$GLOBALS['ProductSummary'] = $desc;
		} else {
			$GLOBALS['ProductSummary'] = isc_substr($desc, 0, 120) . "...";
		}

		$GLOBALS['ProductThumb'] = ImageThumb($row, ProdLink($row['prodname']));
		$GLOBALS['ProductDate'] = isc_date(GetConfig('DisplayDateFormat'), $row['proddateadded']);

		$GLOBALS['ProductPreOrder'] = false;
		$GLOBALS['ProductReleaseDate'] = '';
		$GLOBALS['HideProductReleaseDate'] = 'display:none';

		if ($row['prodpreorder']) {
			$GLOBALS['ProductPreOrder'] = true;
			if ($row['prodreleasedate'] && $row['prodreleasedateremove'] && time() >= (int)$row['prodreleasedate']) {
				$GLOBALS['ProductPreOrder'] = false;
			} else if ($row['prodreleasedate']) {
				$GLOBALS['ProductReleaseDate'] = GetLang('ProductListReleaseDate', array('releasedate' => isc_date(GetConfig('DisplayDateFormat'), (int)$row['prodreleasedate'])));
				$GLOBALS['HideProductReleaseDate'] = '';
			}
		}

		if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired'] == 1) {
			$GLOBALS['ProductURL'] = ProdLink($row['prodname']);
			$GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
		} else {
			$GLOBALS['ProductURL'] = CartLink($row['productid']);
			if ($GLOBALS['ProductPreOrder']) {
				$GLOBALS['ProductAddText'] = GetLang('ProductPreOrderCartLink');
			} else {
				$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
			}
		}

		if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
			$GLOBALS['HideActionAdd'] = '';
		} else {
			$GLOBALS['HideActionAdd'] = 'none';
		}


		$GLOBALS['HideProductVendorName'] = 'display: none';
		$GLOBALS['ProductVendor'] = '';
		if(GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
			$vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
			if(isset($vendorCache[$row['prodvendorid']])) {
				$GLOBALS['ProductVendor'] = '<a href="'.VendorLink($vendorCache[$row['prodvendorid']]).'">'.isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']).'</a>';
				$GLOBALS['HideProductVendorName'] = '';
			}
		}
	}
Example #18
0
		/**
		 * Return a list of any manual payment fields that should be shown when creating/editing
		 * an order via the control panel, if any.
		 *
		 * @param array An array containing the details of existing values, if any.
		 * @return array An array of manual payment fields.
		 */
		public function GetManualPaymentFields($existingOrder=array())
		{
			$monthOptions = '';
			for($i = 1; $i <= 12; $i++) {
				$stamp = mktime(0, 0, 0, $i, 15, date("Y"));
				$i = str_pad($i, 2, "0", STR_PAD_LEFT);

				$monthOptions .= '<option value="'.$i.'">'.date('M', $stamp).'</option>';
			}

			$yearOptions = '';
			for($i = date("Y"); $i <= date("Y")+10; $i++) {
				$value = isc_substr($i, 2, 2);
				$yearOptions .= '<option value="'.$value.'">'.$i.'</option>';
			}

			$fields = array(
				'eway_name' => array(
					'type' => 'text',
					'title' => GetLang('CCManualCardHoldersName'),
					'value' => '',
					'required' => true
				),
				'eway_ccno' => array(
					'type' => 'text',
					'title' => GetLang('CCManualCreditCardNo'),
					'value' => '',
					'required' => true
				),
				'eway_ccexp' => array(
					'type' => 'html',
					'title' => GetLang('CCManualExpirationDate'),
					'html' => '
						<select name="paymentField[' . $this->GetId() . '][eway_ccexpm]">'.$monthOptions.'</select>
						&nbsp;
						<select name="paymentField[' . $this->GetId() . '][eway_ccexpy]">'.$yearOptions.'</select>
					',
					'required' => true
				)
			);

			if ($this->GetValue("requirecvn") == 'YES') {
				$cvvfield = array(
					'eway_cvn' => array(
						'type' => 'text',
						'title' => GetLang('CCManualCreditCardCCV2'),
						'value' => '',
						'required' => true,
						'class' => 'Field50',
					)
				);

				$keys = array_keys($fields);
				array_splice($keys, 2, 0, array_keys($cvvfield));
				array_splice($fields, 2, 0, $cvvfield);
				$fields = array_combine($keys, $fields);
			}

			return $fields;
		}
Example #19
0
    /**
     * Generate an individual row for the order items table.
     *
     * @param string The unique identifier for this row.
     * @param array Array of details about the product for this row.
     * @param boolean Set to true to hide this row by default.
     * @return string The generated HTML row for this item.
     */
    public function GenerateOrderItemRow($rowId, $product = array(), $hidden = false, $resetPrices = false)
    {
        static $first = true;
        static $publicWrappingOptions = null;
        if ($hidden == true) {
            $GLOBALS['HideRow'] = 'display: none';
        } else {
            $GLOBALS['HideRow'] = '';
        }
        //2011-9-13 alandy add shipping data show.
        $GLOBALS['ShippingdataRow'] = '';
        if (is_null($publicWrappingOptions)) {
            $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
            if (empty($wrappingOptions)) {
                $publicWrappingOptions = false;
            } else {
                $publicWrappingOptions = true;
            }
        }
        if ($first != true) {
            $GLOBALS['HideInsertTip'] = 'display: none';
        }
        $first = false;
        if (empty($product)) {
            $GLOBALS['CartItemId'] = $rowId;
            $GLOBALS['ProductCode'] = '';
            $GLOBALS['vendorprefix'] = '';
            $GLOBALS['shippingDate'] = '';
            $GLOBALS['isshippingDate'] = '';
            $GLOBALS['trackingNumber'] = '';
            $GLOBALS['ProductId'] = 0;
            $GLOBALS['ProductName'] = '';
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['HideProductVariation'] = 'display: none;';
            $GLOBALS['ProductPrice'] = FormatPrice(0, false, false, true);
            $GLOBALS['ProductQuantity'] = 1;
            $GLOBALS['ProductTotal'] = FormatPrice(0);
            $GLOBALS['HideEventDate'] = 'display : none;';
            $GLOBALS['EventDate'] = '';
            $GLOBALS['ShippingdataRow'] = '';
            $GLOBALS['ResetPrice'] = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Reset_Price) ? "<input {$GLOBALS['ResetChecked']} value=\"{$GLOBALS['ResetStatus']}\" type='checkbox' name='cartItem[{$rowId}][resetPrice]' onclick='ResetPrice(this)'/>&nbsp;reset price" : '';
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
        $GLOBALS['CartItemId'] = $rowId;
        //isc_html_escape($product['cartitemid']);
        // If the item in the cart is a gift certificate, we need to show a special type of row
        if (isset($product['type']) && $product['type'] == "giftcertificate") {
            $GLOBALS['ProductCode'] = GetLang('NA');
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductPrice'] = FormatPrice($product['product_price']);
            $GLOBALS['ProductTotal'] = FormatPrice($product['product_price'] * $product['quantity']);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItemGiftCertificate');
        } else {
            require_once ISC_BASE_PATH . '/lib/discountcalcs.php';
            /**********************************************************************
            				Code altered by Mayank Jaitly on 05 July 2010
            			/**********************************************************************/
            $GLOBALS['YMMYearTemp'] = $product['year'];
            $GLOBALS['YMMMakeTemp'] = $product['make'];
            $GLOBALS['YMMModelTemp'] = $product['model'];
            $GLOBALS['YMMbedsizeTemp'] = $product['bedsize'];
            $GLOBALS['YMMcabsizeTemp'] = $product['cabsize'];
            $GLOBALS['ProductId'] = $product['product_id'];
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductCode'] = $product['product_code'];
            $GLOBALS['vendorprefix'] = $product['vendorprefix'] . '-';
            $GLOBALS['shippingDate'] = $product['shippingDate'];
            $GLOBALS['isshippingDate'] = $product['isshippingDate'];
            $GLOBALS['trackingNumber'] = $product['trackingNumber'];
            //alandy 2011-9-13 modify shipping date.
            if (isset($GLOBALS['isshippingDate']) && $GLOBALS['isshippingDate'] != '01/01/1900' && !empty($GLOBALS['shippingDate'])) {
                $GLOBALS['ShippingdataRow'] = "<div><div style='float:left; width:180px;'>" . $GLOBALS['shippingDate'] . "</div><div style='float:left; width:400px; word-break:break-all; word-wrap:break-word;'>" . $GLOBALS['trackingNumber'] . "</div></div>";
            }
            // Don't use the discount price here as we'll be showing the coupon codes
            // down below in the summary table
            $productPrice = isset($product['discount_price']) && $product['discount_price'] < $product['product_price'] ? $product['discount_price'] : $product['product_price'];
            //20110503 alandy add resetprice.
            if ($resetPrices) {
                $GLOBALS['PriceReadonly'] = '';
                $GLOBALS['ResetChecked'] = 'checked';
                $GLOBALS['ResetStatus'] = '1';
            } else {
                $GLOBALS['PriceReadonly'] = 'readonly class="Field50 ItemPrice ReadonlyText"';
                $GLOBALS['ResetChecked'] = '';
                $GLOBALS['ResetStatus'] = '0';
            }
            $GLOBALS['ProductPrice'] = FormatPrice($productPrice, false, false, true);
            $GLOBALS['ProductTotal'] = FormatPrice($productPrice * $product['quantity']);
            // Initialize the configurable product fields
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['ProductFields'] = '';
            if (!empty($product['product_fields']) && is_array($product['product_fields'])) {
                $GLOBALS['HideProductFields'] = '';
                foreach ($product['product_fields'] as $fieldId => $field) {
                    switch ($field['fieldType']) {
                        case 'file':
                            if (isset($field['fieldExisting'])) {
                                $fileDirectory = 'configured_products';
                            } else {
                                $fileDirectory = 'configured_products_tmp';
                            }
                            $fieldValue = '<a href="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $fileDirectory . '/' . $field['fileName'] . '" target="_blank">' . isc_html_escape($field['fileOriginName']) . '</a>';
                            break;
                        case 'checkbox':
                            $fieldValue = GetLang('Checked');
                            break;
                        default:
                            if (isc_strlen($field['fieldValue']) > 50) {
                                $field['fieldValue'] = isc_substr($field['fieldValue'], 0, 50) . " ..";
                            }
                            $fieldValue = isc_html_escape($field['fieldValue']);
                            // browser is decoding the entities in the ajax response which prevents the row from loading so we need to double encode
                            if (isset($_REQUEST['ajaxFormUpload'])) {
                                $fieldValue = isc_html_escape($fieldValue);
                            }
                    }
                    if (!trim($fieldValue)) {
                        continue;
                    }
                    $GLOBALS['ProductFields'] .= '
							<dt>' . isc_html_escape($field['fieldName']) . ':</dt>
							<dd>' . $fieldValue . '</dd>
						';
                }
            }
            // Can this item be wrapped?
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            if ($product['data']['prodtype'] == PT_PHYSICAL && @$product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                $GLOBALS['HideWrappingOptions'] = '';
                if (isset($product['wrapping'])) {
                    $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                    $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                    $GLOBALS['HideGiftWrappingEdit'] = '';
                    $GLOBALS['HideGiftWrappingPrice'] = '';
                    $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                } else {
                    $GLOBALS['GiftWrappingName'] = '';
                    $GLOBALS['HideGiftWrappingAdd'] = '';
                    $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
                    $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
                    $GLOBALS['GiftWrappingPrice'] = '';
                }
            }
            // Is this product a variation?
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['HideProductVariation'] = 'display: none';
            if (isset($product['options']) && !empty($product['options'])) {
                $comma = '';
                $GLOBALS['HideProductVariation'] = '';
                foreach ($product['options'] as $name => $value) {
                    if (!trim($name) || !trim($value)) {
                        continue;
                    }
                    $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ' / ';
                }
            } else {
                if (isset($product['data']['prodvariationid']) && $product['data']['prodvariationid'] > 0) {
                    $GLOBALS['HideProductVariation'] = '';
                    $GLOBALS['ProductOptions'] = GetLang('xNone');
                }
            }
            if (isset($product['data']['prodeventdaterequired']) && $product['data']['prodeventdaterequired']) {
                $GLOBALS['HideEventDate'] = '';
                $GLOBALS['EventDate'] = '<dl><dt>' . $product['data']['prodeventdatefieldname'] . ': </dt><dd>' . isc_date('jS M Y', $product['event_date']) . '</dd></dl>';
            } else {
                $GLOBALS['HideEventDate'] = 'display : none;';
                $GLOBALS['EventDate'] = '';
            }
            $GLOBALS['ResetPrice'] = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Reset_Price) ? "<input {$GLOBALS['ResetChecked']} value=\"{$GLOBALS['ResetStatus']}\" type='checkbox' name='cartItem[{$GLOBALS['CartItemId']}][resetPrice]' onclick='ResetPrice(this)'/>&nbsp;reset price" : '';
            $this->setOtherinfo($product['data'], true);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
    }
Example #20
0
function LoadEmailOrderProductFields($fields)
{
	$productFields = '';

	//each configurable field customer submited
	foreach($fields as $row) {

		$fieldValue = '-';
		$fieldName = $row['fieldname'];
		switch($row['fieldtype']) {
			case 'file': {
				//file is an image, display the image
				if (preg_match('/image/', $row['filetype'])) {
					$fieldValue = "<img width='50' src ='".$GLOBALS['ShopPath']."/viewfile.php?orderprodfield=".$row['orderfieldid']."' />";
				}
				//file other than image, display the file name
				else {
					$fieldValue = isc_html_escape($row['originalfilename']);
				}
				break;
			}
			default: {
				if(isc_strlen($row['textcontents'])>50) {
					$fieldValue = isc_html_escape(isc_substr($row['textcontents'], 0, 50))." ..";
				} else {
					$fieldValue = isc_html_escape($row['textcontents']);
				}
				break;
			}
		}

		if($fieldValue!='') {
			$productFields .= "<tr><td>".isc_html_escape($fieldName).":</td>";
			$productFields .= "<td>".$fieldValue."</td></tr>";
		}
	}

	return $productFields;
}
Example #21
0
 private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms = array())
 {
     $this->_SetFeedDetails();
     $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int) GetConfig('RSSCacheTime') * 60);
     $channel = array("title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath']);
     $feed->SetChannel($channel);
     // The magical Interspire Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function
     $searchterms = BuildProductSearchTerms($searchTerms);
     $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder);
     // Run the query
     $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int) GetConfig('RSSItemsLimit'));
     $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
     while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         if (isc_strlen($product['proddesc']) > 300) {
             $product['proddesc'] = isc_substr($product['proddesc'], 0, 298) . "..";
         }
         if ($product['imagefile']) {
             $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", ImageThumb($product['imagefile'], ProdLink($product['prodname'])), $product['proddesc']);
         }
         // Determine the price of this product
         $price = CalculateProductPrice($product);
         $price = GetLang('Price') . ": " . $price;
         if (GetConfig('ShowProductRating')) {
             $ratingImage = $GLOBALS['TPL_PATH'] . '/images/IcoRating' . (int) $product['prodavgrating'] . '.gif';
             $ratingImage = '<img src="' . $ratingImage . '" alt="" />';
         } else {
             $ratingImage = '';
         }
         $product['proddesc'] .= '<p><strong>' . $price . '</strong> ' . $ratingImage . '</p>';
         // Add the item to the feed
         $item = array("title" => $product['prodname'], "description" => $product['proddesc'], "link" => ProdLink($product['prodname']), "date" => $product['proddateadded']);
         $feed->AddItem($item);
     }
     // Send the feed to the browser
     $feed->OutputFeed();
 }
Example #22
0
	/**
	 * Check if a ENUM option exists within a column
	 *
	 * @param $table The table with the column we are checking for
	 * @param $column The ENUM column to check for
	 * @param $option The ENUM option to check for
	 *
	 * @return boolean TRUE If the ENUM option exists, FALSE if not
	 */
	public function EnumExists($table, $column, $option)
	{
		$setup = $this->ColumnExists($table, $column, true);

		if ($option == '' || !is_array($setup)) {
			return false;
		}

		$type = isc_substr(trim($setup['Type']), 0, 4);

		if (isc_strtolower($type) !== 'enum') {
			return false;
		}

		$options = isc_substr(trim($setup['Type']), 6, -2);
		$options = explode("','", $options);
		$options = array_map('trim', $options);

		return in_array($option, $options);
	}
Example #23
0
 public function GetProductFieldDetails($productFields, $cartItemId)
 {
     // custom product fields on cart page
     $GLOBALS['HideCartProductFields'] = 'display:none;';
     $GLOBALS['CartProductFields'] = '';
     if (isset($productFields) && !empty($productFields) && is_array($productFields)) {
         $GLOBALS['HideCartProductFields'] = '';
         foreach ($productFields as $filedId => $field) {
             switch ($field['fieldType']) {
                 //field is a file
                 case 'file':
                     //file is an image, display the image
                     $fieldValue = '<a target="_Blank" href="' . $GLOBALS['ShopPath'] . '/viewfile.php?cartitem=' . $cartItemId . '&prodfield=' . $filedId . '">' . isc_html_escape($field['fileOriginName']) . '</a>';
                     break;
                     //field is a checkbox
                 //field is a checkbox
                 case 'checkbox':
                     $fieldValue = GetLang('Checked');
                     break;
                     //if field is a text area or short text display first
                 //if field is a text area or short text display first
                 default:
                     if (isc_strlen($field['fieldValue']) > 50) {
                         $fieldValue = isc_substr(isc_html_escape($field['fieldValue']), 0, 50) . " ..";
                     } else {
                         $fieldValue = isc_html_escape($field['fieldValue']);
                     }
             }
             if (trim($fieldValue) != '') {
                 $GLOBALS['CartProductFields'] .= '<dt> <img style="vertical-align: middle;" src="' . $GLOBALS['TPL_PATH'] . '/images/NodeJoin.gif" /> ' . isc_html_escape($field['fieldName']) . ':</dt>';
                 $GLOBALS['CartProductFields'] .= '<dd>' . $fieldValue . '</dd>';
             }
         }
     }
 }
Example #24
0
	public function IsWindowsServer()
	{
		if(isc_substr(isc_strtolower(PHP_OS), 0, 3) == 'win') {
			return true;
		}
		else {
			return false;
		}
	}
 /**
  * Imports an actual product record in to the database.
  *
  * @param array Array of record data
  */
 protected function _ImportRecord($record)
 {
     if (!$record['custconemail']) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportCustomersMissingEmail');
         return;
     }
     if (!is_email_address($record['custconemail'])) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportCustomersInvalidEmail');
         return;
     }
     $fillin = array('custconcompany', 'custconfirstname', 'custconlastname', 'custconphone');
     foreach ($fillin as $fillkey) {
         if (!isset($record[$fillkey])) {
             $record[$fillkey] = '';
         }
     }
     // Is there an existing customer with the same email?
     $customerId = 0;
     $existingFormSessionId = 0;
     $query = sprintf("select customerid from [|PREFIX|]customers where lower(custconemail)='%s'", $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($record['custconemail'])));
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) {
         // Overriding existing products, set the product id
         if (isset($this->ImportSession['OverrideDuplicates']) && $this->ImportSession['OverrideDuplicates'] == 1) {
             $customerId = $row['customerid'];
             $this->ImportSession['Results']['Updates'][] = $record['custconfirstname'] . " " . $record['custconlastname'] . " (" . $record['custconemail'] . ")";
         } else {
             $this->ImportSession['Results']['Duplicates'][] = $record['custconfirstname'] . " " . $record['custconlastname'] . " (" . $record['custconemail'] . ")";
             return;
         }
         if (isId($row['custformsessionid'])) {
             $existingFormSessionId = $row['custformsessionid'];
         }
     }
     $customerData = array('company' => $record['custconcompany'], 'firstname' => $record['custconfirstname'], 'lastname' => $record['custconlastname'], 'email' => $record['custconemail'], 'phone' => $record['custconphone']);
     if (isset($record['custpassword']) && $record['custpassword'] !== '') {
         $customerData['password'] = $record['custpassword'];
     }
     if (isset($record['custstorecredit'])) {
         $customerData['storecredit'] = DefaultPriceFormat($record['custstorecredit']);
     }
     if (isId($customerId)) {
         $customerData['customerid'] = $customerId;
     }
     // Are we placing the customer in a customer group?
     $groupId = 0;
     if (!empty($record['custgroup'])) {
         static $customerGroups;
         $groupName = strtolower($record['custgroup']);
         if (isset($customerGroups[$groupName])) {
             $groupId = $customerGroups[$groupName];
         } else {
             $query = "\n\t\t\t\t\tSELECT customergroupid\n\t\t\t\t\tFROM [|PREFIX|]customer_groups\n\t\t\t\t\tWHERE LOWER(groupname)='" . $GLOBALS['ISC_CLASS_DB']->Quote($groupName) . "'\n\t\t\t\t";
             $groupId = $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'customergroupid');
             // Customer group doesn't exist, create it
             if (!$groupId) {
                 $newGroup = array('name' => $record['custgroup'], 'discount' => 0, 'isdefault' => 0, 'categoryaccesstype' => 'all');
                 $entity = new ISC_ENTITY_CUSTOMERGROUP();
                 $groupId = $entity->add($newGroup);
             }
             if ($groupId) {
                 $customerGroups[$groupName] = $groupId;
             }
         }
     }
     $customerData['customergroupid'] = $groupId;
     // Do we have a shipping address?
     $shippingData = array();
     if (isset($record['shipfullname']) || isset($record['shipfirstname']) || isset($record['shipaddress1']) || isset($record['shipaddress2']) || isset($record['shipcity']) || isset($record['shipstate']) || isset($record['shipzip']) || isset($record['shipcountry'])) {
         $fillin = array('shipaddress1', 'shipaddress2', 'shipcity', 'shipstate', 'shipzip', 'shipcountry');
         foreach ($fillin as $fillkey) {
             if (!isset($record[$fillkey])) {
                 $record[$fillkey] = '';
             }
         }
         $shippingData['shipfirstname'] = '';
         $shippingData['shiplastname'] = '';
         $shippingData['shipaddress1'] = $record['shipaddress1'];
         $shippingData['shipaddress2'] = $record['shipaddress2'];
         $shippingData['shipcity'] = $record['shipcity'];
         $shippingData['shipstate'] = $record['shipstate'];
         $shippingData['shipzip'] = $record['shipzip'];
         $shippingData['shipcountry'] = $record['shipcountry'];
         $shippingData['shipstateid'] = 0;
         $shippingData['shipcountryid'] = 0;
         $shippingData['shipdestination'] = '';
         // Find the country and state
         $shippingData['shipcountryid'] = (int) GetCountryByName($record['shipcountry']);
         if (!$shippingData['shipcountryid']) {
             $shippingData['shipcountryid'] = (int) GetCountryIdByISO2($record['shipcountry']);
         }
         // Still nothing? 0 for the shipping country ID
         if (!$shippingData['shipcountryid']) {
             $shippingData['shipcountryid'] = 0;
         }
         if (isset($record['shipstate'])) {
             $shippingData['shipstateid'] = GetStateByName($record['shipstate'], $shippingData['shipcountryid']);
         }
         // Still nothing? 0 for the shipping state ID
         if (!$shippingData['shipstateid']) {
             $shippingData['shipstateid'] = 0;
         }
         if (!isset($record['shipfullname']) || $record['shipfullname'] == "") {
             if (isset($record['shipfirstname']) && $record['shipfirstname'] != '') {
                 $shippingData['shipfirstname'] = $record['shipfirstname'];
             } else {
                 $shippingData['shipfirstname'] = $customerData['firstname'];
             }
             if (isset($record['shiplastname']) && $record['shiplastname'] != '') {
                 $shippingData['shiplastname'] = $record['shiplastname'];
             } else {
                 $shippingData['shiplastname'] = $customerData['lastname'];
             }
         }
         if (!isset($record['shipphone']) && isset($record['custconphone'])) {
             $shippingData['shipphone'] = $record['custconphone'];
         } else {
             $shippingData['shipphone'] = $record['shipphone'];
         }
         /**
          * Handle any of the address custom fields that we might have
          */
         if (!empty($this->customFields) && array_key_exists('custom', $record)) {
             $shippingData['shipformsessionid'] = $this->_importCustomFormfields(FORMFIELDS_FORM_ADDRESS, $record['custom']);
             if (!isId($shippingData['shipformsessionid'])) {
                 unset($shippingData['shipformsessionid']);
             }
         }
     }
     /**
      * Handle any of the customer custom fields that we might have
      */
     if (!empty($this->customFields) && array_key_exists('custom', $record)) {
         $formSessionId = $this->_importCustomFormfields(FORMFIELDS_FORM_ACCOUNT, $record['custom'], $existingFormSessionId);
         if (isId($formSessionId)) {
             $customerData['custformsessionid'] = $formSessionId;
         }
     }
     $customerData['is_import'] = true;
     $customerEntity = new ISC_ENTITY_CUSTOMER();
     // New customer, insert in to DB
     if ($customerId == 0) {
         // Set a temporary password, retrievable later via lost password function
         if (!isset($customerData['password']) || $customerData['password'] == '') {
             $customerData['password'] = isc_substr(uniqid(rand(), true), 0, 10);
         }
         $customerData['token'] = GenerateCustomerToken();
         $customerData['shipping_address'] = $shippingData;
         $rtn = $customerEntity->add($customerData);
         ++$this->ImportSession['Results']['SuccessCount'];
     } else {
         if (count($shippingData) > 0) {
             $query = sprintf("select shipid from [|PREFIX|]shipping_addresses where shipcustomerid='%d' and lower(shipaddress1)='%s' and lower(shipaddress2)='%s' and lower(shipcity)='%s' and lower(shipstate)='%s' and lower(shipcountry)='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($customerId), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipaddress1']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipaddress2']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipcity']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipstate']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipcountry']));
             $Result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             $row = $GLOBALS['ISC_CLASS_DB']->Fetch($Result);
             // Address doesn't exist, we insert it
             if (!$row['shipid']) {
                 $customerData['shipping_address'] = $shippingData;
             }
         }
         $rtn = $customerEntity->edit($customerData);
     }
 }
Example #26
0
		public function LoadOrderProductFieldRow($fields, $fullView = false)
		{
			if(empty($fields)) {
				return '' ;
			}
			$productFields = '';

			//each configurable field customer submited
			foreach($fields as $row) {

				if (empty($row['textcontents']) && empty($row['filename'])) {
					continue;
				}

				$fieldValue = '-';
				$fieldName = $row['fieldname'];
				switch($row['fieldtype']) {
					case 'file': {
						$fieldValue = '<a href="'.GetConfig('ShopPath').'/'.GetConfig('ImageDirectory').'/configured_products/'.urlencode($row['originalfilename']).'">'.isc_html_escape($row['originalfilename']).'</a>';
						break;
					}
					default: {
						if(isc_strlen($row['textcontents'])>50 && !$fullView) {
							$fieldValue = isc_html_escape(isc_substr($row['textcontents'], 0, 50))." ..";
						} else {
							$fieldValue = isc_html_escape($row['textcontents']);
						}
						break;
					}
				}

				$productFields .= "<dt>".isc_html_escape($fieldName).":</dt>";
				$productFields .= "<dd>".$fieldValue."</dd>";
			}

			return $productFields;
		}
 private function SaveQValueAssociationImage()
 {
     if (!array_key_exists('associationimage', $_FILES) || $_FILES['associationimage']['error'] !== 0 || strtolower(substr($_FILES['associationimage']['type'], 0, 6)) !== 'image/') {
         return false;
     }
     // Attempt to set the memory limit
     setImageFileMemLimit($_FILES['associationimage']['tmp_name']);
     // Generate the destination path
     $randomDir = strtolower(chr(rand(65, 90)));
     $destPath = realpath(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory'));
     if (!is_dir($destPath . '/' . $randomDir)) {
         if (!@mkdir($destPath . '/' . $randomDir, 0777)) {
             $randomDir = '';
         }
     }
     $destFile = GenRandFileName($_FILES['associationimage']['name'], 'category');
     $destPath = $destPath . '/' . $randomDir . '/' . $destFile;
     $returnPath = $randomDir . '/' . $destFile;
     $tmp = explode('.', $_FILES['associationimage']['name']);
     $ext = strtolower($tmp[count($tmp) - 1]);
     if ($ext == 'jpg') {
         $srcImg = imagecreatefromjpeg($_FILES['associationimage']['tmp_name']);
     } else {
         if ($ext == 'gif') {
             $srcImg = imagecreatefromgif($_FILES['associationimage']['tmp_name']);
             if (!function_exists('imagegif')) {
                 $gifHack = 1;
             }
         } else {
             $srcImg = imagecreatefrompng($_FILES['associationimage']['tmp_name']);
         }
     }
     $srcWidth = imagesx($srcImg);
     $srcHeight = imagesy($srcImg);
     $widthLimit = GetConfig('BrandImageWidth');
     $heightLimit = GetConfig('BrandImageHeight');
     // If the image is small enough, simply move it and leave it as is
     if ($srcWidth <= $widthLimit && $srcHeight <= $heightLimit) {
         imagedestroy($srcImg);
         move_uploaded_file($_FILES['associationimage']['tmp_name'], $destPath);
         return $returnPath;
     }
     // Otherwise, the image needs to be resized
     $attribs = getimagesize($_FILES['associationimage']['tmp_name']);
     $width = $attribs[0];
     $height = $attribs[1];
     if ($width > $widthLimit) {
         $height = ceil($widthLimit / $width * $height);
         $width = $widthLimit;
     }
     if ($height > $heightLimit) {
         $width = ceil($heightLimit / $height * $width);
         $height = $heightLimit;
     }
     $dstImg = imagecreatetruecolor($width, $height);
     if ($ext == "gif" && !isset($gifHack)) {
         $colorTransparent = imagecolortransparent($srcImg);
         imagepalettecopy($srcImg, $dstImg);
         imagecolortransparent($dstImg, $colorTransparent);
         imagetruecolortopalette($dstImg, true, 256);
     } else {
         if ($ext == "png") {
             ImageColorTransparent($dstImg, ImageColorAllocate($dstImg, 0, 0, 0));
             ImageAlphaBlending($dstImg, false);
         }
     }
     imagecopyresampled($dstImg, $srcImg, 0, 0, 0, 0, $width, $height, $srcWidth, $srcHeight);
     if ($ext == "jpg") {
         imagejpeg($dstImg, $destPath, 100);
     } else {
         if ($ext == "gif") {
             if (isset($gifHack) && $gifHack == true) {
                 $thumbFile = isc_substr($destPath, 0, -3) . "jpg";
                 imagejpeg($dstImg, $destPath, 100);
             } else {
                 imagegif($dstImg, $destPath);
             }
         } else {
             imagepng($dstImg, $destPath);
         }
     }
     @imagedestroy($dstImg);
     @imagedestroy($srcImg);
     @unlink($_FILES['associationimage']['tmp_name']);
     // Change the permissions on the thumbnail file
     isc_chmod($returnPath, ISC_WRITEABLE_FILE_PERM);
     return $returnPath;
 }
    /**
     * Generate an individual row for the order items table.
     *
     * @param string The unique identifier for this row.
     * @param array Array of details about the product for this row.
     * @param boolean Set to true to hide this row by default.
     * @return string The generated HTML row for this item.
     */
    public function GenerateOrderItemRow($rowId, $product = array(), $hidden = false)
    {
        static $first = true;
        static $publicWrappingOptions = null;
        if ($hidden == true) {
            $GLOBALS['HideRow'] = 'display: none';
        } else {
            $GLOBALS['HideRow'] = '';
        }
        if (is_null($publicWrappingOptions)) {
            $wrappingOptions = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('GiftWrapping');
            if (empty($wrappingOptions)) {
                $publicWrappingOptions = false;
            } else {
                $publicWrappingOptions = true;
            }
        }
        if ($first != true) {
            $GLOBALS['HideInsertTip'] = 'display: none';
        }
        $first = false;
        if (empty($product)) {
            $GLOBALS['CartItemId'] = $rowId;
            $GLOBALS['ProductCode'] = '';
            $GLOBALS['ProductId'] = 0;
            $GLOBALS['ProductName'] = '';
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['HideProductVariation'] = 'display: none;';
            $GLOBALS['ProductPrice'] = FormatPrice(0, false, false, true);
            $GLOBALS['ProductQuantity'] = 1;
            $GLOBALS['ProductTotal'] = FormatPrice(0);
            $GLOBALS['HideEventDate'] = 'display : none;';
            $GLOBALS['EventDate'] = '';
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
        $GLOBALS['CartItemId'] = $rowId;
        //isc_html_escape($product['cartitemid']);
        // If the item in the cart is a gift certificate, we need to show a special type of row
        if (isset($product['type']) && $product['type'] == "giftcertificate") {
            $GLOBALS['ProductCode'] = GetLang('NA');
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductPrice'] = FormatPrice($product['product_price']);
            $GLOBALS['ProductTotal'] = FormatPrice($product['product_price'] * $product['quantity']);
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItemGiftCertificate');
        } else {
            $GLOBALS['ProductId'] = $product['product_id'];
            $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
            $GLOBALS['ProductQuantity'] = (int) $product['quantity'];
            $GLOBALS['ProductCode'] = $product['product_code'];
            // Don't use the discount price here as we'll be showing the coupon codes
            // down below in the summary table
            $productPrice = $product['product_price'];
            $GLOBALS['ProductPrice'] = FormatPrice($productPrice, false, false, true);
            $GLOBALS['ProductTotal'] = FormatPrice($productPrice * $product['quantity']);
            // Initialize the configurable product fields
            $GLOBALS['HideProductFields'] = 'display: none;';
            $GLOBALS['ProductFields'] = '';
            if (!empty($product['product_fields']) && is_array($product['product_fields'])) {
                $GLOBALS['HideProductFields'] = '';
                foreach ($product['product_fields'] as $fieldId => $field) {
                    switch ($field['fieldType']) {
                        case 'file':
                            if (isset($field['fieldExisting'])) {
                                $fileDirectory = 'configured_products';
                            } else {
                                $fileDirectory = 'configured_products_tmp';
                            }
                            $fieldValue = '<a href="' . GetConfig('ShopPath') . '/' . GetConfig('ImageDirectory') . '/' . $fileDirectory . '/' . $field['fileName'] . '" target="_blank">' . isc_html_escape($field['fileOriginName']) . '</a>';
                            break;
                        case 'checkbox':
                            $fieldValue = GetLang('Checked');
                            break;
                        default:
                            if (isc_strlen($field['fieldValue']) > 50) {
                                $field['fieldValue'] = isc_substr($field['fieldValue'], 0, 50) . " ..";
                            }
                            $fieldValue = isc_html_escape($field['fieldValue']);
                            // browser is decoding the entities in the ajax response which prevents the row from loading so we need to double encode
                            if (isset($_REQUEST['ajaxFormUpload'])) {
                                $fieldValue = isc_html_escape($fieldValue);
                            }
                    }
                    if (!trim($fieldValue)) {
                        continue;
                    }
                    $GLOBALS['ProductFields'] .= '
							<dt>' . isc_html_escape($field['fieldName']) . ':</dt>
							<dd>' . $fieldValue . '</dd>
						';
                }
            }
            // Can this item be wrapped?
            $GLOBALS['HideWrappingOptions'] = 'display: none';
            if ($product['data']['prodtype'] == PT_PHYSICAL && @$product['data']['prodwrapoptions'] != -1 && $publicWrappingOptions == true) {
                $GLOBALS['HideWrappingOptions'] = '';
                if (isset($product['wrapping'])) {
                    $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                    $GLOBALS['HideGiftWrappingAdd'] = 'display: none';
                    $GLOBALS['HideGiftWrappingEdit'] = '';
                    $GLOBALS['HideGiftWrappingPrice'] = '';
                    $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($product['wrapping']['wrapprice']);
                } else {
                    $GLOBALS['GiftWrappingName'] = '';
                    $GLOBALS['HideGiftWrappingAdd'] = '';
                    $GLOBALS['HideGiftWrappingEdit'] = 'display: none';
                    $GLOBALS['HideGiftWrappingPrice'] = 'display: none';
                    $GLOBALS['GiftWrappingPrice'] = '';
                }
            }
            // Is this product a variation?
            $GLOBALS['ProductOptions'] = '';
            $GLOBALS['HideProductVariation'] = 'display: none';
            if (isset($product['options']) && !empty($product['options'])) {
                $comma = '';
                $GLOBALS['HideProductVariation'] = '';
                foreach ($product['options'] as $name => $value) {
                    if (!trim($name) || !trim($value)) {
                        continue;
                    }
                    $GLOBALS['ProductOptions'] .= $comma . isc_html_escape($name) . ": " . isc_html_escape($value);
                    $comma = ' / ';
                }
            } else {
                if (isset($product['data']['prodvariationid']) && $product['data']['prodvariationid'] > 0) {
                    $GLOBALS['HideProductVariation'] = '';
                    $GLOBALS['ProductOptions'] = GetLang('xNone');
                }
            }
            if (isset($product['data']['prodeventdaterequired']) && $product['data']['prodeventdaterequired']) {
                $GLOBALS['HideEventDate'] = '';
                $GLOBALS['EventDate'] = '<dl><dt>' . $product['data']['prodeventdatefieldname'] . ': </dt><dd>' . isc_date('jS M Y', $product['event_date']) . '</dd></dl>';
            } else {
                $GLOBALS['HideEventDate'] = 'display : none;';
                $GLOBALS['EventDate'] = '';
            }
            return $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('OrderItem');
        }
    }
Example #29
0
/**
 * Generate a thumbnail version of a particular image.
 *
 * @param string The file system path of the image to create a thumbnail of.
 * @param string The file system path of the name/location to save the thumbnail.
 * @param int The maximum width of the image.
 * @param boolean If the image is small enough, copy it to destLocation, otherwise just return.
 */
function GenerateThumbnail($sourceLocation, $destLocation, $maxWidth, $maxHeight = null)
{
    if (is_null($maxHeight)) {
        $maxHeight = $maxWidth;
    }
    if ($sourceLocation == '' || !file_exists($sourceLocation)) {
        return false;
    } else {
        if (!is_dir(dirname($destLocation)) || !is_writable(dirname($destLocation))) {
            return false;
        }
    }
    // A list of thumbnails too
    $tmp = explode(".", $sourceLocation);
    $ext = isc_strtolower($tmp[count($tmp) - 1]);
    $attribs = @getimagesize($sourceLocation);
    $srcWidth = $attribs[0];
    $srcHeight = $attribs[1];
    if (!is_array($attribs)) {
        return false;
    }
    // Check if we have enough available memory to create this image - if we don't, attempt to bump it up
    SetImageFileMemLimit($sourceLocation);
    if ($ext == "jpg") {
        $srcImg = @imagecreatefromjpeg($sourceLocation);
    } else {
        if ($ext == "gif") {
            $srcImg = @imagecreatefromgif($sourceLocation);
            if (!function_exists("imagegif")) {
                $gifHack = 1;
            }
        } else {
            $srcImg = @imagecreatefrompng($sourceLocation);
        }
    }
    if (!$srcImg) {
        return false;
    }
    // This image dimensions. Simply copy and return
    if ($srcWidth <= $maxWidth && $srcHeight <= $maxHeight) {
        @imagedestroy($srcImg);
        if ($sourceLocation != $destLocation && copy($sourceLocation, $destLocation)) {
            return true;
        }
    }
    // Make sure the thumb has a constant height
    $width = $srcWidth;
    $thumbWidth = $srcWidth;
    $height = $srcHeight;
    $thumbHeight = $srcHeight;
    if ($width > $maxWidth) {
        $thumbWidth = $maxWidth;
        $thumbHeight = $maxWidth / $srcWidth * $srcHeight;
    } else {
        $thumbHeight = $maxHeight;
        $thumbWidth = $maxHeight / $srcHeight * $srcWidth;
    }
    $thumbImage = @imagecreatetruecolor($thumbWidth, $thumbHeight);
    if ($ext == "gif" && !isset($gifHack)) {
        $colorTransparent = @imagecolortransparent($srcImg);
        @imagepalettecopy($srcImg, $thumbImage);
        @imagecolortransparent($thumbImage, $colorTransparent);
        @imagetruecolortopalette($thumbImage, true, 256);
    } else {
        if ($ext == "png") {
            @ImageColorTransparent($thumbImage, @ImageColorAllocate($thumbImage, 0, 0, 0));
            @ImageAlphaBlending($thumbImage, false);
        }
    }
    @imagecopyresampled($thumbImage, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $srcWidth, $srcHeight);
    if ($ext == "jpg") {
        @imagejpeg($thumbImage, $destLocation, 100);
    } else {
        if ($ext == "gif") {
            if (isset($gifHack) && $gifHack == true) {
                $thumbFile = isc_substr($thumbFile, 0, -3) . "jpg";
                @imagejpeg($thumbImage, $destLocation, 100);
            } else {
                @imagegif($thumbImage, $destLocation);
            }
        } else {
            @imagepng($thumbImage, $destLocation);
        }
    }
    @imagedestroy($thumbImage);
    @imagedestroy($srcImg);
    // Change the permissions on the thumbnail file
    isc_chmod($destLocation, ISC_WRITEABLE_FILE_PERM);
    return true;
}
 /**
  * Display the configurable product fields in order's quick view
  *
  * @param int $orderProdId Order product item id
  * @param int $orderId order id
  * @return void
  **/
 private function GetOrderProductsFieldsRow($fields)
 {
     if (empty($fields)) {
         return '';
     }
     $productFields = '';
     $productFields .= "<tr><td height='18' class='text' colspan='2'><div style='padding-left: 20px;'><strong>" . GetLang('ConfigurableFields') . ":</strong><br /><dl class='HorizontalFormContainer'>";
     foreach ($fields as $field) {
         $fieldValue = '';
         $fieldName = $field['fieldname'];
         switch ($field['fieldtype']) {
             // the field is a file, add a link to the file name
             case 'file':
                 $fieldValue = "<a target='_blank' href='" . $GLOBALS['ShopPath'] . "/viewfile.php?orderprodfield=" . $field['orderfieldid'] . "' >" . isc_html_escape($field['originalfilename']) . "</a>";
                 break;
             case 'checkbox':
                 $fieldValue = GetLang('Checked');
                 break;
             default:
                 if (isc_strlen($field['textcontents']) > 50) {
                     $fieldValue = isc_html_escape(isc_substr($field['textcontents'], 0, 50)) . " <a href='#' onclick='Order.LoadOrderProductFieldData(" . $field['orderid'] . "); return false;'><i> " . GetLang('More') . "</i></a>";
                 } else {
                     $fieldValue = isc_html_escape($field['textcontents']);
                 }
                 break;
         }
         if ($fieldValue != '') {
             $productFields .= "<dt>" . isc_html_escape($fieldName) . ":</dt>";
             $productFields .= "<dd>" . $fieldValue . "</dd>";
         }
     }
     $productFields .= "</dl></div></td></tr>";
     return $productFields;
 }