コード例 #1
0
	/**
	* 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;
	}
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
ファイル: download.php プロジェクト: nirvana-info/old_bak
/**
* Forces content to be downloaded
*
* @param mixed $filename The name of the file to use when downloading the content
* @param string $data The content to download
* @param string $mimetype The mime type to use. Defaults to detecting the type based on file extension.
*/
function DownloadContent($filename, $data, $mimetype = "")
{
    SetDownloadHeaders($filename, isc_strlen($data), $mimetype);
    // output data
    echo $data;
    exit;
}
コード例 #4
0
ファイル: String.php プロジェクト: hungnv0789/vhtm
	/**
	* 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;
	}
コード例 #5
0
 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;
         }
     }
 }
コード例 #6
0
ファイル: class.customers.php プロジェクト: hungnv0789/vhtm
		public function BuildWhereFromVars($array)
		{
			$queryWhere = "";
			$queryJoin = "";
			$queryHaving = "";

			// Is this a custom search?
			if(!empty($array['searchId'])) {
				$this->_customSearch = $GLOBALS['ISC_CLASS_ADMIN_CUSTOMSEARCH']->LoadSearch($array['searchId']);
				$array = array_merge($array, (array)$this->_customSearch['searchvars']);
			}

			if (isset($array['searchQuery']) && $array['searchQuery'] != "") {
				// PostgreSQL is case sensitive for likes, so all matches are done in lower case
				$search_query = $GLOBALS['ISC_CLASS_DB']->Quote(trim($array['searchQuery']));
				$queryWhere .= "
					AND (
						customerid = '" . $search_query . "' OR
						custconfirstname LIKE '%" . $search_query . "%' OR
						custconlastname LIKE '%" . $search_query . "%' OR
						custconemail LIKE '%" . $search_query . "%' OR
						CONCAT(custconfirstname, ' ', custconlastname) LIKE '%" . $search_query . "%' OR
						custconcompany LIKE '%" . $search_query . "%'
					)";
			}

			if (isset($array['letter']) && $array['letter'] != '') {
				$letter = chr(ord($array['letter']));
				if ($array['letter'] == '0-9') {
					$queryWhere .= " AND custconlastname NOT REGEXP('^[a-zA-Z]')";
				}
				else if (isc_strlen($letter) == 1) {
					$queryWhere .= " AND custconlastname LIKE '".$GLOBALS['ISC_CLASS_DB']->Quote($letter)."%'";
				}
			}

			if (isset($array['phone']) && $array['phone'] != "") {
				$phone = $GLOBALS['ISC_CLASS_DB']->Quote(trim($array['phone']));
				$queryWhere .= sprintf(" AND custconphone LIKE '%%%s%%'", $phone);
			}

			if (isset($array['idFrom']) && $array['idFrom'] != "") {
				$id_from = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['idFrom']);
				$queryWhere .= sprintf(" AND customerid >= '%d'", $id_from);
			}
			if (isset($array['idTo']) && $array['idTo']) {
				$id_to = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['idTo']);
				$queryWhere .= sprintf(" AND customerid <= '%d'", $id_to);
			}

			// limit by number of orders
			if (!empty($array['ordersFrom'])) {
				$orders_from = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['ordersFrom']);
				$queryHaving .= sprintf(" AND numorders >= '%d'", $orders_from);
			}

			if (!empty($array['ordersTo'])) {
				$orders_to = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['ordersTo']);
				$queryHaving .= sprintf(" AND numorders <= '%d'", $orders_to);
			}

			if (isset($array['storeCreditFrom']) && $array['storeCreditFrom'] != "") {
				$credit_from = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['storeCreditFrom']);
				$queryWhere .= sprintf(" AND custstorecredit >= '%d'", $credit_from);
			}

			if (isset($array['storeCreditTo']) && $array['storeCreditTo'] != "") {
				$credit_to = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['storeCreditTo']);
				$queryWhere .= sprintf(" AND custstorecredit <= '%d'", $credit_to);
			}

			// Limit results to a particular join date range
			if (isset($array['dateRange']) && $array['dateRange'] != "") {
				$range = $array['dateRange'];
				switch($range) {
					// Registrations within the last day
					case "today":
						$from_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
						break;
					// Registrations received in the last 2 days
					case "yesterday":
						$from_stamp = mktime(0, 0, 0, isc_date("m"), date("d")-1, isc_date("Y"));
						$to_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d")-1, isc_date("Y"));
						break;
					// Registrations received in the last 24 hours
					case "day":
						$from_stamp = time()-60*60*24;
						break;
					// Registrations received in the last 7 days
					case "week":
						$from_stamp = time()-60*60*24*7;
						break;
					// Registrations received in the last 30 days
					case "month":
						$from_stamp = time()-60*60*24*30;
						break;
					// Registrations received this month
					case "this_month":
						$from_stamp = mktime(0, 0, 0, isc_date("m"), 1, isc_date("Y"));
						break;
					// Orders received this year
					case "this_year":
						$from_stamp = mktime(0, 0, 0, 1, 1, isc_date("Y"));
						break;
					// Custom date
					default:
						if (isset($array['fromDate']) && $array['fromDate'] != "") {
							$from_date = $array['fromDate'];
							$from_data = explode("/", $from_date);
							$from_stamp = mktime(0, 0, 0, $from_data[0], $from_data[1], $from_data[2]);
						}
						if (isset($array['toDate']) && $array['toDate'] != "") {
							$to_date = $array['toDate'];
							$to_data = explode("/", $to_date);
							$to_stamp = mktime(0, 0, 0, $to_data[0], $to_data[1], $to_data[2]);
						}
				}

				if (isset($from_stamp)) {
					$queryWhere .= sprintf(" AND custdatejoined >= '%d'", $from_stamp);
				}
				if (isset($to_stamp)) {
					$queryWhere .= sprintf(" AND custdatejoined <= '%d'", $to_stamp);
				}
			}

			if (isset($array['custGroupId']) && is_numeric($array['custGroupId'])) {
				$custGroupId = (int)$array['custGroupId'];

				// is this group the default group? we should then search for customers with a groupid of 0 as well
				$groupQuery = 'SELECT * FROM [|PREFIX|]customer_groups WHERE customergroupid = ' . $custGroupId . ' AND isdefault = 1';
				$groupRes = $this->db->Query($groupQuery);
				if ($this->db->CountResult($groupRes)) {
					$queryWhere .= ' AND (custgroupid = ' . $custGroupId . ' OR custgroupid = 0)';
				}
				else {
					$queryWhere .= ' AND custgroupid = ' . $custGroupId;
				}
			}

			// Search for users with a particular shipping country & state
			if (isset($array['country']) && $array['country'] != "") {
				$country = $GLOBALS['ISC_CLASS_DB']->Quote((int)$array['country']);

				$queryJoin .= " LEFT JOIN [|PREFIX|]shipping_addresses ON shipcustomerid = customerid";
				$queryWhere .= sprintf(" AND shipcountryid='%s'", $country);

				$state = '';
				if (isset($array['state']) && $array['state'] != "") {
					$state = GetStateById($array['state']);
				}
				else if (isset($array['state_1']) && $array['state_1'] != "") {
					$state = $array['state_1'];
				}

				// Searching by state too
				if ($state != '') {
					$queryWhere .= " AND shipstate='".$GLOBALS['ISC_CLASS_DB']->Quote($state)."'";
				}
			}

			return array("query" => $queryWhere, "join" => $queryJoin, "having" => $queryHaving);
		}
コード例 #7
0
 public function BuildWhereFromVars($array)
 {
     $queryWhere = "";
     if (isset($array['searchQuery']) && $array['searchQuery'] != "") {
         // PostgreSQL is case sensitive for likes, so all matches are done in lower case
         $search_query = $GLOBALS['ISC_CLASS_DB']->Quote(trim(isc_strtolower($array['searchQuery'])));
         $queryWhere .= "\n\t\t\t\t\tAND (\n\t\t\t\t\t\tcustomerid = '" . $search_query . "' OR\n\t\t\t\t\t\tLOWER(custconfirstname) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(custconlastname) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(custconemail) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(CONCAT(custconfirstname, ' ', custconlastname)) LIKE '%" . $search_query . "%' OR\n\t\t\t\t\t\tLOWER(custconcompany) LIKE '%" . $search_query . "%'\n\t\t\t\t\t)";
     }
     if (isset($array['letter']) && $array['letter'] != '') {
         $letter = chr(ord($array['letter']));
         if ($array['letter'] == '0-9') {
             $queryWhere .= " AND custconlastname NOT REGEXP('^[a-zA-Z]')";
         } else {
             if (isc_strlen($letter) == 1) {
                 $queryWhere .= " AND custconlastname LIKE '" . $GLOBALS['ISC_CLASS_DB']->Quote($letter) . "%'";
             }
         }
     }
     if (isset($array['phone']) && $array['phone'] != "") {
         $phone = $GLOBALS['ISC_CLASS_DB']->Quote(trim($array['phone']));
         $queryWhere .= sprintf(" AND custconphone LIKE '%%%s%%'", $phone);
     }
     if (isset($array['idFrom']) && $array['idFrom'] != "") {
         $id_from = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['idFrom']);
         $queryWhere .= sprintf(" AND customerid >= '%d'", $id_from);
     }
     if (isset($array['idTo']) && $array['idTo']) {
         $id_to = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['idTo']);
         $queryWhere .= sprintf(" AND customerid <= '%d'", $id_to);
     }
     if (isset($array['storeCreditFrom']) && $array['storeCreditFrom'] != "") {
         $credit_from = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['storeCreditFrom']);
         $queryWhere .= sprintf(" AND custstorecredit >= '%d'", $credit_from);
     }
     if (isset($array['storeCreditTo']) && $array['storeCreditTo'] != "") {
         $credit_to = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['storeCreditTo']);
         $queryWhere .= sprintf(" AND custstorecredit <= '%d'", $credit_to);
     }
     // Limit results to a particular join date range
     if (isset($array['dateRange']) && $array['dateRange'] != "") {
         $range = $array['dateRange'];
         switch ($range) {
             // Registrations within the last day
             case "today":
                 $from_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
                 break;
                 // Registrations received in the last 2 days
             // Registrations received in the last 2 days
             case "yesterday":
                 $from_stamp = mktime(0, 0, 0, isc_date("m"), date("d") - 1, isc_date("Y"));
                 $to_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d") - 1, isc_date("Y"));
                 break;
                 // Registrations received in the last 24 hours
             // Registrations received in the last 24 hours
             case "day":
                 $from_stamp = time() - 60 * 60 * 24;
                 break;
                 // Registrations received in the last 7 days
             // Registrations received in the last 7 days
             case "week":
                 $from_stamp = time() - 60 * 60 * 24 * 7;
                 break;
                 // Registrations received in the last 30 days
             // Registrations received in the last 30 days
             case "month":
                 $from_stamp = time() - 60 * 60 * 24 * 30;
                 break;
                 // Registrations received this month
             // Registrations received this month
             case "this_month":
                 $from_stamp = mktime(0, 0, 0, isc_date("m"), 1, isc_date("Y"));
                 break;
                 // Orders received this year
             // Orders received this year
             case "this_year":
                 $from_stamp = mktime(0, 0, 0, 1, 1, isc_date("Y"));
                 break;
                 // Custom date
             // Custom date
             default:
                 if (isset($array['fromDate']) && $array['fromDate'] != "") {
                     $from_date = $array['fromDate'];
                     $from_data = explode("/", $from_date);
                     $from_stamp = mktime(0, 0, 0, $from_data[0], $from_data[1], $from_data[2]);
                 }
                 if (isset($array['toDate']) && $array['toDate'] != "") {
                     $to_date = $array['toDate'];
                     $to_data = explode("/", $to_date);
                     $to_stamp = mktime(0, 0, 0, $to_data[0], $to_data[1], $to_data[2]);
                 }
         }
         if (isset($from_stamp)) {
             $queryWhere .= sprintf(" AND custdatejoined >= '%d'", $from_stamp);
         }
         if (isset($to_stamp)) {
             $queryWhere .= sprintf(" AND custdatejoined <= '%d'", $to_stamp);
         }
     }
     if (isset($array['custGroupId']) && is_numeric($array['custGroupId'])) {
         $custGroupId = (int) $array['custGroupId'];
         $queryWhere .= sprintf(" AND custgroupid='%d' ", $custGroupId);
     }
     $joinQuery = '';
     // Search for users with a particular shipping country & state
     if (isset($array['country']) && $array['country'] != "") {
         $country = $GLOBALS['ISC_CLASS_DB']->Quote((int) $array['country']);
         $joinQuery = sprintf(" LEFT JOIN [|PREFIX|]shipping_addresses ON (shipcustomerid=customerid)");
         $queryWhere .= sprintf(" AND shipcountryid='%s'", $country);
         $state = '';
         if (isset($array['state']) && $array['state'] != "") {
             $state = GetStateById($array['state']);
         } else {
             if (isset($array['state_1']) && $array['state_1'] != "") {
                 $state = $array['state_1'];
             }
         }
         // Searching by state too
         if ($state != '') {
             $queryWhere .= " AND LOWER(shipstate)='" . $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($state)) . "'";
         }
     }
     return array("query" => $queryWhere, "join" => $joinQuery);
 }
コード例 #8
0
 /**
  * Imports an tracking numbers in to the database.
  *
  * @param array Array of record data
  */
 protected function _ImportRecord($record)
 {
     if (trim($record['ordernumber']) == "") {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportMissingOrderNumber');
         return;
     }
     $record['ordertrackingnumber'] = trim($record['ordertrackingnumber']);
     if ($record['ordertrackingnumber'] == "") {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportMissingTrackingNumber');
         return;
     }
     if (isc_strlen($record['ordertrackingnumber']) > 100) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportTrackingNumberTooLong');
         return;
     }
     // Does the order number exist in the database?
     $query = "SELECT orderid, ordtrackingno, ordvendorid FROM [|PREFIX|]orders WHERE orderid='" . (int) $record['ordernumber'] . "'";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     $order = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
     if (!$order['orderid']) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportInvalidOrderNumber');
         return;
     }
     if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() != $order['ordvendorid']) {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportInvalidOrderNumber');
         return;
     }
     // Does this order already have a tracking number?
     if ($order['ordtrackingno']) {
         // Overriding existing tracking number
         if (isset($this->ImportSession['OverrideDuplicates']) && $this->ImportSession['OverrideDuplicates'] == 1) {
             $this->ImportSession['Results']['Updates'][] = $record['ordernumber'] . " " . $record['ordertrackingnumber'];
         } else {
             $this->ImportSession['Results']['Duplicates'][] = $record['ordernumber'] . " " . $record['ordertrackingnumber'];
             return;
         }
     }
     $orderData = array("ordtrackingno" => $record['ordertrackingnumber']);
     if (isset($this->ImportSession['updateOrderStatus']) && $this->ImportSession['updateOrderStatus'] != 0) {
         $orderData['ordstatus'] = (int) $this->ImportSession['updateOrderStatus'];
     }
     if ($record['ordernumber'] > 0) {
         $GLOBALS['ISC_CLASS_DB']->UpdateQuery("orders", $orderData, "orderid='" . $order['orderid'] . "'");
         ++$this->ImportSession['Results']['SuccessCount'];
     } else {
         $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportInvalidOrderNumber');
         return;
     }
 }
コード例 #9
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>';
             }
         }
     }
 }
コード例 #10
0
ファイル: class.rss.php プロジェクト: nirvana-info/old_bak
 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();
 }
コード例 #11
0
ファイル: class.backup.php プロジェクト: hungnv0789/vhtm
	public function _CreateDBBackup($file, &$error)
	{
		$time = isc_date('dS F Y \a\t H:i', time());
		$contents = sprintf("-- Database Backup\n-- Generated: %s\n-- -------------------------------------\n\n", $time);

		if(!function_exists('gzopen')) {
			$error = 'PHP is not compiled with ZLIB support';
			return false;
		}

		$progress = 0;

		$tables = $this->_FetchTables();

		foreach($tables as $table => $rowCount) {
			$this->_UpdateProgress(sprintf(GetLang('BackupStatusTable'), $table));

			$fields = $this->_FetchTableFields($table);
			$fields = implode("`,`", $fields);

			$contents .= "\n\n".$this->_ShowCreateTable($table).";\n\n";

			// Now fetch out all of the data
			$query = sprintf("SELECT * FROM %s", $table);
			$Result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($Result)) {
				$values = '';
				foreach($row as $k => $v) {
					if(is_null($v)) {
						$values .= 'NULL,';
					}
					else {
						$values .= "'".$GLOBALS['ISC_CLASS_DB']->Quote($v)."',";
					}
				}
				$values = rtrim($values,",");
				$insert = sprintf("INSERT INTO %s (`%s`) VALUES (%s);\n", $table, $fields, $values);

				$contents .= $insert;

				if(isc_strlen($contents) > BACKUP_BUFFER_SIZE) {
					$this->_handler->WriteCompressedFile($file, $contents);
					$contents = '';
				}
			}
			if($this->Verbose) {
				$this->_DBProgress += $rowCount;
			}
		}

		// Write any remaining data
		$this->_handler->WriteCompressedFile($file, $contents);
		if($this->_handler->type == "remote") {
			$this->_UpdateProgress(GetLang('BackupStatusUploading'));
		}
		$this->_handler->CloseFile($file);
	}
コード例 #12
0
 /**
  * Apply a coupon code or gift certificate code to the order that's being created/edited.
  */
 private function OrderApplyCouponCode()
 {
     if (!isset($_REQUEST['couponCode']) || !isset($_REQUEST['orderSession'])) {
         exit;
     }
     $orderClass = GetClass('ISC_ADMIN_ORDERS');
     $api = $orderClass->GetCartApi($_REQUEST['orderSession']);
     $response = array();
     $code = trim($_REQUEST['couponCode']);
     // If we were passed a gift certificate code, attempt to apply it first
     if (isc_strlen($code) == GIFT_CERTIFICATE_LENGTH && gzte11(ISC_LARGEPRINT)) {
         if (!$api->ApplyGiftCertificate($code)) {
             $errors = implode("\n", $api->GetErrors());
         }
     } else {
         if (!$api->ApplyCoupon($code)) {
             $errors = implode("\n", $api->GetErrors());
         } else {
             // If we've applied a coupon code, we need to refresh the entire grid of order items
             // as prices may have also changed.
             $response['orderTable'] = $orderClass->GenerateOrderItemsGrid();
         }
     }
     if (isset($errors)) {
         $response['error'] = $errors;
     }
     // Generate the order summary again
     $response['orderSummary'] = $orderClass->GenerateOrderSummaryTable();
     echo isc_json_encode($response);
     exit;
 }
コード例 #13
0
ファイル: class.remote.php プロジェクト: nirvana-info/old_bak
 private function GetExpressOfferShippers()
 {
     // Now we have the zone, what available shipping methods do we have?
     $checkout = GetClass('ISC_FINALIZEOFFER');
     $cart = GetClass('ISC_MAKEAOFFER');
     if (!$cart->api->AllProductsInCartAreIntangible()) {
         // Using a new shipping address
         if (isset($_REQUEST['shippingType']) && $_REQUEST['shippingType'] == 'new') {
             $addressData = $this->GetExpressCheckoutAddressData('shipping');
             if (isset($_POST['shipping_SaveThisAddress']) && $_POST['shipping_SaveThisAddress'] !== '') {
                 $addressData['saveAddress'] = true;
             }
             $addressId = 0;
             // Set aside any of the custom fields if we have any
             if (isset($_POST['custom']) && is_array($_POST['custom'])) {
                 /**
                  * We need to map this into the billing fields as we are assuming that any
                  * address is using the billing fields in the frontend
                  */
                 $shippingKeys = array_keys($_POST['custom']);
                 $fieldAddressMap = $GLOBALS['ISC_CLASS_FORM']->mapAddressFieldList(FORMFIELDS_FORM_SHIPPING, $shippingKeys);
                 $shippingSessData = array();
                 foreach ($fieldAddressMap as $field => $newBillingId) {
                     $shippingSessData[$newBillingId] = $_POST['custom'][$field];
                 }
                 $checkout->SetCustomFieldData('shipping', $shippingSessData);
             }
             if (!$checkout->SetOrderShippingAddress($addressData)) {
                 $tags[] = $this->MakeXMLTag('status', 0);
                 $tags[] = $this->MakeXMLTag('step', 'ShippingAddress');
                 $tags[] = $this->MakeXMLTag('message', GetLang('UnableSaveOrderShippingAddress'));
                 $this->SendXMLHeader();
                 $this->SendXMLResponse($tags);
                 exit;
             }
         } else {
             if (!isset($_REQUEST['shippingAddressId']) || !$checkout->SetOrderShippingAddress($_REQUEST['shippingAddressId'])) {
                 $tags[] = $this->MakeXMLTag('status', 0);
                 $tags[] = $this->MakeXMLTag('step', 'ShippingAddress');
                 $tags[] = $this->MakeXMLTag('message', GetLang('UnableSaveOrderShippingAddress'));
                 $this->SendXMLHeader();
                 $this->SendXMLResponse($tags);
                 exit;
             } else {
                 $addressId = $_REQUEST['shippingAddressId'];
             }
         }
     }
     $availableMethods = $checkout->GetCheckoutShippingMethods();
     if (empty($availableMethods)) {
         $tags[] = $this->MakeXMLTag('status', 0);
         $tags[] = $this->MakeXMLTag('step', 'ShippingAddress');
         $tags[] = $this->MakeXMLTag('message', GetLang('UnableToShipToAddressSingle'), true);
         $this->SendXMLHeader();
         $this->SendXMLResponse($tags);
         exit;
     }
     $hideItemList = false;
     if (count($availableMethods) == 1 && count(current($availableMethods)) == 1) {
         $GLOBALS['HideVendorTitle'] = 'display: none';
         $GLOBALS['HideVendorItems'] = 'display: none';
         $hideItemList = true;
     }
     $hasTransit = false;
     $GLOBALS['ShippingQuotes'] = '';
     $orderShippingAddresses = $checkout->GetOrderShippingAddresses();
     $vendors = $cart->api->GetCartVendorIds();
     $vendors = array(0 => $vendors[0]);
     foreach ($vendors as $i => $vendorId) {
         $GLOBALS['VendorId'] = $vendorId;
         if ($vendorId != 0) {
             $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
             $vendor = $vendorCache[$vendorId];
             $GLOBALS['VendorName'] = isc_html_escape($vendor['vendorname']);
         } else {
             $GLOBALS['VendorName'] = GetConfig('StoreName');
         }
         $shippingDestinations = $availableMethods[$vendorId];
         if (count($shippingDestinations) == 1 && !isset($_SESSION['CHECKOUT']['SPLIT_SHIPPING'])) {
             $GLOBALS['HideAddressLine'] = 'display: none';
         } else {
             $GLOBALS['HideAddressLine'] = '';
         }
         $textItemList = '';
         foreach ($shippingDestinations as $addressId => $shippingInfo) {
             if (isset($vendors[$i + 1]) || isset($shippingDestinations[$addressId + 1])) {
                 $GLOBALS['HideHorizontalRule'] = '';
             } else {
                 $GLOBALS['HideHorizontalRule'] = 'display: none';
             }
             $GLOBALS['AddressId'] = $addressId;
             // If no methods are available, this order can't progress so show an error
             if (empty($shippingInfo['quotes'])) {
                 $GLOBALS['HideNoShippingProviders'] = '';
                 $GLOBALS['HideShippingProviderList'] = 'none';
                 $hideItemList = false;
             }
             $GLOBALS['ItemList'] = '';
             if (!$hideItemList) {
                 foreach ($shippingInfo['items'] as $product) {
                     // Only show physical items
                     if ($product['data']['prodtype'] != PT_PHYSICAL) {
                         continue;
                     }
                     $textItemList .= $product['quantity'] . ' x ' . $product['product_name'] . "\n";
                     $GLOBALS['ProductQuantity'] = $product['quantity'];
                     $GLOBALS['ProductName'] = isc_html_escape($product['product_name']);
                     $GLOBALS['HideGiftWrapping'] = 'display: none';
                     $GLOBALS['HideGiftMessagePreview'] = 'display: none';
                     $GLOBALS['GiftWrappingName'] = '';
                     $GLOBALS['GiftMessagePreview'] = '';
                     if (isset($product['wrapping']['wrapname'])) {
                         $GLOBALS['HideGiftWrapping'] = '';
                         $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping']['wrapname']);
                         if (isset($product['wrapping']['wrapmessage'])) {
                             if (isc_strlen($product['wrapping']['wrapmessage']) > 30) {
                                 $product['wrapping']['wrapmessage'] = substr($product['wrapping']['wrapmessage'], 0, 27) . '...';
                             }
                             $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping']['wrapmessage']);
                             if ($product['wrapping']['wrapmessage']) {
                                 $GLOBALS['HideGiftMessagePreview'] = '';
                             }
                         }
                     }
                     $GLOBALS['ItemList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ShippingQuoteProduct');
                 }
             }
             // If no methods are available, this order can't progress so show an error
             if (empty($shippingInfo['quotes'])) {
                 $tags[] = $this->MakeXMLTag('status', 0);
                 $tags[] = $this->MakeXMLTag('step', 'ShippingAddress');
                 $textItemList = rtrim($textItemList, "\n");
                 $tags[] = $this->MakeXMLTag('message', GetLang('AjaxUnableToShipToAddress') . "\n\n" . $textItemList, true);
                 $this->SendXMLHeader();
                 $this->SendXMLResponse($tags);
                 exit;
             }
             if (!$GLOBALS['HideAddressLine']) {
                 $address = $orderShippingAddresses[$addressId];
                 $addressLine = array($address['shipfirstname'] . ' ' . $address['shiplastname'], $address['shipcompany'], $address['shipaddress1'], $address['shipaddress2'], $address['shipcity'], $address['shipstate'], $address['shipzip'], $address['shipcountry']);
                 // Please see self::GenerateShippingSelect below.
                 $addressLine = array_filter($addressLine, array($checkout, 'FilterAddressFields'));
                 $GLOBALS['AddressLine'] = isc_html_escape(implode(', ', $addressLine));
             } else {
                 $GLOBALS['AddressLine'] = '';
             }
             // Now build a list of the actual available quotes
             $GLOBALS['ShippingProviders'] = '';
             foreach ($shippingInfo['quotes'] as $quoteId => $method) {
                 $GLOBALS['ShipperName'] = isc_html_escape($method['description']);
                 $GLOBALS['ShippingPrice'] = CurrencyConvertFormatPrice($method['price']);
                 $GLOBALS['ShippingQuoteId'] = $quoteId;
                 $GLOBALS['ShippingData'] = $GLOBALS['ShippingQuoteId'];
                 if (isset($method['transit'])) {
                     $hasTransit = true;
                     $days = $method['transit'];
                     if ($days == 0) {
                         $transit = GetLang("SameDay");
                     } else {
                         if ($days == 1) {
                             $transit = GetLang('NextDay');
                         } else {
                             $transit = sprintf(GetLang('Days'), $days);
                         }
                     }
                     $GLOBALS['TransitTime'] = $transit;
                     $GLOBALS['TransitTime'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CartShippingTransitTime');
                 } else {
                     $GLOBALS['TransitTime'] = "";
                 }
                 $GLOBALS['ShippingProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ExpressCheckoutShippingMethod");
             }
             // Add it to the list
             $GLOBALS['ShippingQuotes'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ShippingQuote');
             $_SESSION['CHECKOUT']['SHIPPING_QUOTES'][$vendorId][$addressId] = $shippingInfo['quotes'];
         }
     }
     if ($hasTransit) {
         $GLOBALS['DeliveryDisclaimer'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CartShippingDeliveryDisclaimer');
     }
     $GLOBALS['ExpressCheckoutSelectShippingProviderLabel'] = GetLang('ExpressCheckoutSelectShippingProviderOffer');
     $methodList = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ExpressCheckoutChooseShipper');
     $tags[] = $this->MakeXMLTag('status', 1);
     $tags[] = $this->MakeXMLTag('providerContents', $methodList, true);
     $this->SendXMLHeader();
     $this->SendXMLResponse($tags);
 }
コード例 #14
0
ファイル: class.redirects.php プロジェクト: hungnv0789/vhtm
	/**
	* The 'New' for this refers to the fact that this is for normalising redirect target urls (as opposed to 'old', source urls) and has nothing to do with the age of the method.
	*
	* @param string $url
	* @param string $error
	*/
	public static function normalizeNewURLForDatabase($url, &$error = '')
	{
		// only allow valid urls
		$url = parse_url($url);
		if (!$url) {
			$error = GetLang('NewURLInvalid');
			return false;
		}

		// build a list of urls this store is known by
		$storeUrls = array();

		$primary = parse_url(GetConfig('ShopPath'));
		$storeUrls[] = $primary;

		if (GetConfig('ShopPathSSL') && GetConfig('ShopPathSSL') != GetConfig('ShopPath')) {
			$storeUrls[] = parse_url(GetConfig('ShopPathSSL'));
		}

		if (isset($url['scheme'])) {
			// if a scheme is specified, only allow http
			if ($url['scheme'] != 'http' && $url['scheme'] != 'https') {
				$error = GetLang('NewURLInvalid');
				return false;
			}
		} else {
			if (!isset($url['path']) || isc_substr($url['path'], 0, 1) != '/') {
				// hostless paths must begin with a /
				$error = GetLang('NewURLInvalid');
				return false;
			}

			$path = $url['path'];
			unset($url['path']);

			$url = array_merge($url, $primary);
			if (isset($url['path'])) {
				$url['path'] .= $path;
			} else {
				$url['path'] = $path;
			}

		}

		GetLib('class.urls');
		$url = ISC_URLS::unparseUrl($url);

		// see if the redirect url matches any url this store is known by
		foreach ($storeUrls as $storeUrl) {
			// yeah, this ends up parsing and unparsing the stored urls but it means we get a reliable, well-formatted check
			$storeUrl = ISC_URLS::unparseUrl($storeUrl);

			if (isc_substr($url, 0, isc_strlen($storeUrl)) === $storeUrl) {
				$url = isc_substr($url, isc_strlen($storeUrl));
				break;
			}
		}

		return $url;
	}
コード例 #15
0
ファイル: class.review.php プロジェクト: nirvana-info/old_bak
 public function ManageReviewsGrid(&$numReviews)
 {
     // Show a list of reviews in a table
     $page = 0;
     $start = 0;
     $numReviews = 0;
     $numPages = 0;
     $GLOBALS['ReviewGrid'] = "";
     $GLOBALS['Nav'] = "";
     $max = 0;
     $searchURL = '';
     $filterURL = '';
     //Added by Simha
     if (isset($_GET['brandid'])) {
         $filterURL .= "&amp;brandid=" . trim($_GET['brandid']) . "";
     }
     if (isset($_GET['seriesid'])) {
         $filterURL .= "&amp;seriesid=" . trim($_GET['seriesid']) . "";
     }
     //Added by Simha Ends
     //lguan_20100612: Category supporting in product rating
     if (isset($_GET['catid'])) {
         $filterURL .= "&amp;catid=" . trim($_GET['catid']) . "";
     }
     if (isset($_GET['subcatid'])) {
         $filterURL .= "&amp;subcatid=" . trim($_GET['subcatid']) . "";
     }
     //lguan_20100615: Append information for from and to
     if (isset($GLOBALS['FromStamp']) && is_numeric($GLOBALS['FromStamp'])) {
         $filterURL .= "&amp;from=" . isc_date('m/d/Y', $GLOBALS['FromStamp']) . "";
     }
     if (isset($GLOBALS['ToStamp']) && is_numeric($GLOBALS['ToStamp'])) {
         $filterURL .= "&amp;to=" . isc_date('m/d/Y', $GLOBALS['ToStamp']) . "";
     }
     if (isset($_GET['datetype'])) {
         $filterURL .= "&amp;datetype=" . $_GET['datetype'] . "";
     }
     //wiyin_20100628: get the review status
     if (isset($_GET['reviewStatus'])) {
         $GLOBALS['reviewStatus'] = (int) $_GET['reviewStatus'];
     }
     if (isset($_GET['ISSelectReplacement_category'])) {
         $cateList = $_GET['ISSelectReplacement_category'];
         if (is_array($cateList)) {
             if (!in_array(0, $cateList)) {
                 $GLOBALS['CateList'] = $cateList;
             }
         }
     }
     if (isset($_GET['searchQuery'])) {
         $query = $_GET['searchQuery'];
         $GLOBALS['Query'] = $query;
         $searchURL = sprintf("&amp;searchQuery=%s", urlencode($query));
     } else {
         $query = "";
         $GLOBALS['Query'] = "";
     }
     if (isset($_GET['sortOrder']) && $_GET['sortOrder'] == 'asc') {
         $sortOrder = 'asc';
     } else {
         $sortOrder = "desc";
     }
     $sortLinks = array("OrderId" => "r.orderid", "Review" => "r.revtitle", "Name" => "p.prodname", "By" => "r.revfromname", "Rating" => "r.revrating", "Date" => "r.revdate", "Status" => "r.revstatus", "RatingQuality" => "r.qualityrating", "RatingInstall" => "r.installrating", "RatingValue" => "r.valuerating", "RatingSupport" => "r.supportrating", "RatingDelivery" => "r.deliveryrating");
     if (isset($_GET['sortField']) && in_array($_GET['sortField'], $sortLinks)) {
         $sortField = $_GET['sortField'];
         SaveDefaultSortField("ManageReviews", $_REQUEST['sortField'], $sortOrder);
     } else {
         list($sortField, $sortOrder) = GetDefaultSortField("ManageReviews", "r.reviewid", $sortOrder);
     }
     if (isset($_GET['page'])) {
         $page = (int) $_GET['page'];
     } else {
         $page = 1;
     }
     $GLOBALS['Page'] = $page;
     $sortURL = sprintf("&sortField=%s&sortOrder=%s", $sortField, $sortOrder);
     $GLOBALS['SortURL'] = $sortURL;
     // Limit the number of questions returned
     if ($page == 1) {
         $start = 1;
     } else {
         $start = $page * ISC_REVIEWS_PER_PAGE - (ISC_REVIEWS_PER_PAGE - 1);
     }
     $start = $start - 1;
     // Get the results for the query
     $reviewResult = $this->_GetReviewList($query, $start, $sortField, $sortOrder, $numReviews);
     $numPages = ceil($numReviews / ISC_REVIEWS_PER_PAGE);
     // Add the "(Page x of n)" label
     if ($numReviews > ISC_REVIEWS_PER_PAGE) {
         $GLOBALS['Nav'] = sprintf("(%s %d of %d) &nbsp;&nbsp;&nbsp;", GetLang('Page'), $page, $numPages);
         $GLOBALS['Nav'] .= BuildPagination($numReviews, ISC_REVIEWS_PER_PAGE, $page, sprintf("index.php?ToDo=viewReviews%s%s%s", $sortURL, $filterURL, $searchURL));
     } else {
         $GLOBALS['Nav'] = "";
     }
     $GLOBALS['Nav'] = rtrim($GLOBALS['Nav'], ' |');
     $GLOBALS['SearchQuery'] = $query;
     $GLOBALS['SortField'] = $sortField;
     $GLOBALS['SortOrder'] = $sortOrder;
     BuildAdminSortingLinks($sortLinks, "index.php?ToDo=viewReviews&amp;" . $searchURL . "&amp;page=" . $page . $filterURL, $sortField, $sortOrder);
     // Workout the maximum size of the array
     $max = $start + ISC_REVIEWS_PER_PAGE;
     if ($max > $numReviews) {
         $max = $numReviews;
     }
     if ($numReviews > 0) {
         // Display the reviews
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($reviewResult)) {
             $GLOBALS['ReviewId'] = $row['reviewid'];
             $GLOBALS['ProdName'] = isc_html_escape($row['prodname']);
             $GLOBALS['ProdLink'] = ProdLink($row['prodname']);
             if (isc_strlen($row['revtext']) > 100) {
                 $GLOBALS['ReviewTitle'] = isc_html_escape(sprintf("%s...", isc_substr($row['revtitle'], 0, 100)));
             } else {
                 $GLOBALS['ReviewTitle'] = isc_html_escape($row['revtitle']);
             }
             //lguan_20100612: Show extra rating options
             $GLOBALS['Rating'] = $this->wrapRatingImages($row['revrating']);
             $GLOBALS['RatingQuality'] = $this->wrapRatingImages($row['qualityrating']);
             $GLOBALS['RatingInstall'] = $this->wrapRatingImages($row['installrating']);
             $GLOBALS['RatingValue'] = $this->wrapRatingImages($row['valuerating']);
             $GLOBALS['RatingSupport'] = $this->wrapRatingImages($row['supportrating']);
             $GLOBALS['RatingDelivery'] = $this->wrapRatingImages($row['deliveryrating']);
             if ($row['revfromname'] != "") {
                 $GLOBALS['PostedBy'] = isc_html_escape($row['revfromname']);
             } else {
                 $GLOBALS['PostedBy'] = GetLang('NA');
             }
             $GLOBALS['Date'] = CDate($row['revdate']);
             $GLOBALS['PreviewLink'] = sprintf("<a title='%s' href='javascript:PreviewReview(%d)'>%s</a>", GetLang('PreviewReview'), $row['reviewid'], GetLang('Preview'));
             if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Edit_Reviews)) {
                 $GLOBALS['EditLink'] = sprintf("<a title='%s' href='index.php?ToDo=editReview&amp;reviewId=%d'>%s</a>", GetLang('EditReview'), $row['reviewid'], GetLang('Edit'));
             } else {
                 $GLOBALS['EditLink'] = sprintf("<a class='Action' disabled>%s</a>", GetLang('Edit'));
             }
             switch ($row['revstatus']) {
                 case "0":
                     $GLOBALS['Status'] = GetLang('Pending');
                     break;
                 case "1":
                     $GLOBALS['Status'] = sprintf("<font color='green'>%s</font>", GetLang('Approved'));
                     break;
                 case "2":
                     $GLOBALS['Status'] = sprintf("<font color='red'>%s</font>", GetLang('Disapproved'));
                     break;
             }
             $revOrderid = $row['orderid'];
             //$orderInformations = $this->GetOrderInformationsByOrderId($revOrderid);
             if (is_numeric($revOrderid) && $revOrderid > 0 && isset($row["ordcustid"])) {
                 //viewOrders&orderId
                 $GLOBALS["OrderId"] = "<a href='index.php?ToDo=viewOrders&orderId=" . $row["orderid"] . "' >" . $row["orderid"] . "</a>";
             } else {
                 $GLOBALS["OrderId"] = "unknown";
             }
             $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("reviews.manage.row");
             $GLOBALS['ReviewGrid'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
         }
         $GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("reviews.manage.grid");
         return $GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate(true);
     }
 }
コード例 #16
0
	private function GetProducts()
	{
		header('Content-type: text/xml');
		echo '<?xml version="1.0"?>';
		echo '<results>';

		if(!isset($_REQUEST['searchQuery']) && !isset($_REQUEST['category']) || (isset($_REQUEST['searchQuery']) && isc_strlen($_REQUEST['searchQuery']) <= 3)) {
			echo "<error>".GetLang('DevEditLinkerEnterSearchTerms')."</error>";
		}
		else {
			$_REQUEST['category'] = array($_REQUEST['category']);
			$ResultCount = 0;
			$GLOBALS['ISC_CLASS_ADMIN_ENGINE'] = GetClass('ISC_ADMIN_ENGINE');
			$GLOBALS['ISC_CLASS_ADMIN_AUTH'] = GetClass('ISC_ADMIN_AUTH');
			$GLOBALS['ISC_CLASS_ADMIN_PRODUCT'] = GetClass('ISC_ADMIN_PRODUCT');
			$products = $GLOBALS['ISC_CLASS_ADMIN_PRODUCT']->_GetProductList(0, 'prodname', 'asc', $ResultCount, 'p.productid,p.prodname', false);

			if($ResultCount == 0) {
				if(isset($_REQUEST['searchQuery'])) {
					echo "<error>".GetLang('DevEditLinkerNoProducts')."</error>";
				}
				else {
					echo "<error>".GetLang('DevEditLinkerNoCategoryProducts')."</error>";
				}
			}
			else {
				while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($products)) {
					echo sprintf('<result title="%s" icon="images/product.gif" id="%s"><![CDATA[%s]]></result>', isc_html_escape(isc_html_escape($product['prodname'])), $product['productid'], ProdLink($product['prodname']));
				}
			}
		}
		echo '</results>';
	}
コード例 #17
0
ファイル: products_panel.php プロジェクト: hungnv0789/vhtm
	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'] = '';
			}
		}
	}
コード例 #18
0
ファイル: orders.php プロジェクト: hungnv0789/vhtm
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;
}
コード例 #19
0
ファイル: class.orders.php プロジェクト: nirvana-info/old_bak
    /**
     * 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');
        }
    }
コード例 #20
0
ファイル: class.search.php プロジェクト: nirvana-info/old_bak
 function DoAjaxSearch()
 {
     if (isset($_GET['search_query']) && isc_strlen($_GET['search_query']) >= 3) {
         $searchterms = BuildProductSearchTerms($_REQUEST);
         // Build the search query using our terms & the fields we want
         $searchQueries = BuildProductSearchQuery($searchterms);
         $Search_Count = $GLOBALS['ISC_CLASS_DB']->FetchOne($searchQueries['countQuery']);
         // No results?
         if ($Search_Count == 0) {
             exit;
         }
         // Add the limit
         $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 5);
         $Search_Result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);
         while ($product = $GLOBALS['ISC_CLASS_DB']->Fetch($Search_Result)) {
             $product['imagefile'] = '';
             $products[$product['productid']] = $product;
         }
         // Fetch product images
         $productids = implode(",", array_keys($products));
         $query = sprintf("select imageprodid, imagefile from [|PREFIX|]product_images where imageprodid in (%s) and imageisthumb=2", $GLOBALS['ISC_CLASS_DB']->Quote($productids));
         $Result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($productimage = $GLOBALS['ISC_CLASS_DB']->Fetch($Result)) {
             $products[$productimage['imageprodid']]['imagefile'] = $productimage['imagefile'];
         }
         $view_all = '';
         if ($Search_Count > 5) {
             $view_all = sprintf(' view_all="%s"', $this->EscapeEntity(sprintf('<a href="%s/search.php?search_query=%s">%s &raquo;</a>', $GLOBALS['ShopPathNormal'], $_REQUEST['search_query'], GetLang('QuickSearchViewAll'))));
         }
         echo '<?xml version="1.0"?>' . "\n";
         echo sprintf('<results type="%s" result_count="%s"%s>' . "\n", GetLang('QuickSearchProducts'), $Search_Count, $view_all);
         foreach ($products as $product) {
             if ($product['imagefile']) {
                 $image = sprintf("%s/%s/%s", $GLOBALS['ShopPathNormal'], GetConfig('ImageDirectory'), $product['imagefile']);
             } else {
                 $image = GetLang('QuickSearchNoImage');
             }
             if (GetConfig('EnableProductReviews')) {
                 $ratingimg = sprintf("%s/images/IcoRating%s.gif", $GLOBALS['TPL_PATH'], (int) $product['prodavgrating']);
             } else {
                 $ratingimg = '';
             }
             echo sprintf('<result title="%s" price="%s" url="%s" image="%s" ratingimg="%s" />' . "\n", $this->EscapeEntity($product['prodname']), $this->EscapeEntity(CalculateProductPrice_retail($product)), ProdLink($product['prodname']), $this->EscapeEntity($image), $this->EscapeEntity($ratingimg));
         }
         echo "</results>\n";
     }
 }
コード例 #21
0
ファイル: CartContent.php プロジェクト: hungnv0789/vhtm
	/**
	 * 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");
				}
			}
		}
	}
コード例 #22
0
ファイル: class.orders.php プロジェクト: hungnv0789/vhtm
		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;
		}
コード例 #23
0
 private function CurrencyCheck($data, &$message)
 {
     $isDefault = false;
     if (array_key_exists("currencyid", $_REQUEST) && isId($_REQUEST['currencyid']) && $_REQUEST['currencyid'] == GetConfig("DefaultCurrencyID")) {
         $isDefault = true;
     }
     // General check to see if the required fields were entered
     $requiredFields = array('currencyname' => GetLang('EnterCurrencyName'), 'currencycode' => GetLang('EnterCurrencyCode'), 'currencyexchangerate' => GetLang('EnterCurrencyExchangeRate'), 'currencystringposition' => GetLang('EnterCurrencyStringPosition'), 'currencystring' => GetLang('EnterCurrencyString'), 'currencydecimalstring' => GetLang('EnterCurrencyDecimalString'), 'currencythousandstring' => GetLang('EnterCurrencyThousandString'), 'currencydecimalplace' => GetLang('EnterCurrencyDecimalPlace'));
     if ($isDefault) {
         unset($requiredFields['currencyexchangerate']);
     }
     foreach ($requiredFields as $key => $err) {
         if (!array_key_exists($key, $data) || strlen($data[$key]) == 0) {
             $message = $err;
             return false;
         }
     }
     if (!isId($data["currencycountryid"]) && !isId($data["currencycouregid"])) {
         $message = GetLang('EnterCurrencyOrigin');
         return false;
     }
     if (!preg_match('/^[a-z]{3}$/i', $data['currencycode'])) {
         $message = GetLang('InvalidCurrencyCode');
         return false;
     }
     if (!$isDefault && !is_numeric($data['currencyexchangerate'])) {
         $message = GetLang('InvalidCurrencyExchangeRate');
         return false;
     }
     $oneChar = array("currencydecimalstring" => GetLang('InvalidCurrencyDecimalString'), "currencythousandstring" => GetLang('InvalidCurrencyThousandString'));
     foreach ($oneChar as $key => $err) {
         if (isc_strlen($data[$key]) > 1 || preg_match("/[0-9]+/", $data[$key])) {
             $message = $err;
             return false;
         }
     }
     if ($data['currencydecimalstring'] == $data['currencythousandstring']) {
         $message = GetLang('InvalidCurrencyStringMatch');
         return false;
     }
     // Check to see if we already have this one setup
     $query = "SELECT currencycode FROM [|PREFIX|]currencies WHERE currencycode='" . $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtoupper($data['currencycode'])) . "' AND ";
     if (isId($data['currencycountryid'])) {
         $query .= " currencycountryid='" . (int) $data['currencycountryid'] . "'";
     } else {
         if (isId($data['currencycouregid'])) {
             $query .= " currencycouregid='" . (int) $data['currencycouregid'] . "'";
         }
     }
     if (array_key_exists("currencyid", $_REQUEST) && isId($_REQUEST['currencyid'])) {
         $query .= " AND currencyid != '" . (int) $_REQUEST['currencyid'] . "'";
     }
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     if ($GLOBALS['ISC_CLASS_DB']->FetchOne($result, 'currencycode')) {
         $message = GetLang('CurrencyAlreadySetup');
         return false;
     }
     return true;
 }
コード例 #24
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)
    {
        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');
        }
    }
コード例 #25
0
 /**
  * Save the tags a product has been tagged with in the database.
  *
  * @param string A CSV list of tags to be associated with the product.
  * @param int The product ID to associate the tags with.
  * @param boolean True if this is a new product, false if not (new products mean we don't need to delete existing tags etc)
  * @return boolean True if successful, false if not.
  */
 public function SaveProductTags($tags, $productId, $newProduct = false)
 {
     // Split up the tags and make them unique
     $tags = explode(',', $tags);
     foreach ($tags as $k => $tag) {
         if (!trim($tag) || isc_strlen($tag) == 2) {
             unset($tags[$k]);
             continue;
         }
         $tags[$k] = trim($tags[$k]);
     }
     // No tags & away we go!
     if ($newProduct && empty($tags)) {
         return false;
     }
     $uniqueTags = array_unique(array_map('isc_strtolower', $tags));
     $tagList = array();
     foreach (array_keys($uniqueTags) as $k) {
         $tagList[] = trim($tags[$k]);
     }
     $uniqueTags = array_values($uniqueTags);
     // Get a list of the tags that this product already has
     $existingTags = array();
     $productTagIds = array();
     if ($newProduct == false) {
         $query = "\n\t\t\t\t\tSELECT a.tagid, t.tagname, t.tagcount\n\t\t\t\t\tFROM [|PREFIX|]product_tagassociations a\n\t\t\t\t\tINNER JOIN [|PREFIX|]product_tags t ON (t.tagid=a.tagid)\n\t\t\t\t\tWHERE a.productid='" . (int) $productId . "'\n\t\t\t\t";
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         while ($tag = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
             $existingTags[$tag['tagid']] = $tag;
         }
     }
     // Now attempt to establish which of these tags already exist and which we need to create
     $query = "\n\t\t\t\tSELECT tagid, tagname\n\t\t\t\tFROM [|PREFIX|]product_tags\n\t\t\t\tWHERE LOWER(tagname) IN ('" . implode("','", array_map(array($GLOBALS['ISC_CLASS_DB'], 'Quote'), $tagList)) . "')\n\t\t\t";
     $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
     while ($tag = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
         // This tag exists but the product doesn't have it already, so we need to tag it
         $productTagIds[] = $tag['tagid'];
         if (!isset($existingTags[$tag['tagid']])) {
             $tagsToMark[] = $tag['tagid'];
         }
         // Remove the tag from the list of what we need to create
         $keyId = array_search(strtolower($tag['tagname']), $uniqueTags);
         if ($keyId !== false) {
             unset($tagList[$keyId], $uniqueTags[$keyId]);
         }
     }
     // What's left in the array is now what we need to create, so go ahead and create those tags
     foreach ($tagList as $tag) {
         $tagId = $this->CreateProductTag($tag);
         $productTagIds[] = $tagId;
         $tagsToMark[] = $tagId;
     }
     // Update the tag count for all of the tags - so now that current + 1 products have this tag
     if (!empty($tagsToMark)) {
         $query = "\n\t\t\t\t\tUPDATE [|PREFIX|]product_tags\n\t\t\t\t\tSET tagcount=tagcount+1\n\t\t\t\t\tWHERE tagid IN (" . implode(',', $tagsToMark) . ")\n\t\t\t\t";
         $GLOBALS['ISC_CLASS_DB']->Query($query);
     }
     // Now delete any tag associations
     if ($newProduct == false) {
         $deletedTags = array_diff(array_keys($existingTags), $productTagIds);
         if (!empty($deletedTags)) {
             $GLOBALS['ISC_CLASS_DB']->DeleteQuery('product_tagassociations', "WHERE tagid IN (" . implode(',', $deletedTags) . ") AND productid='" . (int) $productId . "'");
             // Delete any existing tags where they were only previously associated with one product, as now they're associated with 0
             $GLOBALS['ISC_CLASS_DB']->DeleteQuery('product_tags', "WHERE tagid IN (" . implode(',', $deletedTags) . ") AND tagcount=1");
             $query = "\n\t\t\t\t\t\tUPDATE [|PREFIX|]product_tags\n\t\t\t\t\t\tSET tagcount=tagcount-1\n\t\t\t\t\t\tWHERE tagid IN (" . implode(',', $deletedTags) . ")\n\t\t\t\t\t";
             $GLOBALS['ISC_CLASS_DB']->Query($query);
         }
     }
     // And finally, insert all of the new tag associations
     $insertValues = '';
     if (!empty($tagsToMark)) {
         foreach ($tagsToMark as $tagId) {
             $insertValues .= "('" . $tagId . "', '" . $productId . "'), ";
         }
         $insertValues = rtrim($insertValues, ', ');
         $GLOBALS['ISC_CLASS_DB']->Query("\n\t\t\t\t\tINSERT INTO [|PREFIX|]product_tagassociations\n\t\t\t\t\t(tagid, productid)\n\t\t\t\t\tVALUES\n\t\t\t\t\t" . $insertValues);
     }
     return true;
 }
コード例 #26
0
ファイル: class.install.php プロジェクト: hungnv0789/vhtm
		/**
		 * _CheckPermissions
		 * Create the database and perform other install-orientated tasks
		 *
		 * @param none
		 *
		 * @return void
		 */
		private function RunInstall()
		{
			
				$lk = '';
				if(isset($_POST['LK'])) {
					$lk = ech0($_POST['LK']);
				}

				if(!$lk) {
					$installMessage = GetLang('LKBad');
					$installCode = "badLicenseKey";
				}

			if(!isset($_POST['StoreCountryLocationId']) || !isId($_POST['StoreCountryLocationId'])) {
				$_POST['StoreCountryLocationId'] = 227; // United States
			}

			if(!isset($_POST['StoreCurrencyCode']) || $_POST['StoreCurrencyCode'] == '') {
				$_POST['StoreCurrencyCode'] = 'USD';
			}

			if(!isset($_POST['ShopPath']) || $_POST['ShopPath'] == '') {
				$installMessage = GetLang('InstallMissingShopPath');
				$installCode = "missingShopPath";
			}
			else if (isc_strlen($_POST['StoreCurrencyCode']) > 3) {
				$installMessage = GetLang('InstallInvalidStoreCurrencyCode');
				$installCode = "invalidStoreCurrencyCode";
			}
			else if(!isset($_POST['ShopPath']) || $_POST['ShopPath'] == '') {
				$installMessage = GetLang('InstallMissingShopPath');
				$installCode = "missingShopPath";
			}
			else if(!isset($_POST['UserEmail']) || $_POST['UserEmail'] == '') {
				$installMessage = GetLang('InstallMissingUserEmail');
				$installCode = "missingUserEmail";
			}
			else if(!isset($_POST['UserPass']) || $_POST['UserPass'] == '') {
				$installMessage = GetLang('InstallMissingUserPass');
				$installCode = "missingUserPass";
			}
			else if(!isset($_POST['dbServer']) || $_POST['dbServer'] == '') {
				$installMessage = GetLang('InstallMissingDbServer');
				$installCode = "missingDbServer";
			}
			else if(!isset($_POST['dbUser']) || $_POST['dbUser'] == '') {
				$installMessage = GetLang('InstallMissingDbUser');
				$installCode = "missingDbUser";
			}
			else if(!isset($_POST['dbPass'])) {
				$installMessage = GetLang('InstallMissingDbPass');
				$installCode = "missingDbPass";
			}
			else if(!isset($_POST['dbDatabase']) || $_POST['dbDatabase'] == '') {
				$installMessage = GetLang('InstallMissingDbDatabase');
				$installCode = "missingDbDatabase";
			}

			if(!isset($_POST['tablePrefix'])) {
				$_POST['tablePrefix'] = '';
			}

			// One or more error messages were detected
			if(isset($installMessage)) {
				$errors = array(
					0 => array(
						"code" => $installCode,
						"message" => $installMessage
					)
				);
				$this->ShowInstallErrors($installMessage, $errors, false, true);
				return;
			}

			// Try to connect to the database
			$db_type = GetConfig("dbType") . 'Db';
			$db = new $db_type();

			if(isset($GLOBALS['ISC_CFG']["dbEncoding"])) {
				$db->charset = $GLOBALS['ISC_CFG']["dbEncoding"];
			}

			$connection = $db->Connect($_POST['dbServer'], $_POST['dbUser'], $_POST['dbPass'], $_POST['dbDatabase']);
			$db->TablePrefix = $_POST['tablePrefix'];

			if($connection) {
				$GLOBALS["ISC_CLASS_DB"] = &$db;

				// Are we running the required version of MySQL?
				$ver = $GLOBALS["ISC_CLASS_DB"]->FetchOne("select version() as ver");

				$mysql_check = version_compare($ver, MYSQL_VERSION_REQUIRED);

				if($mysql_check < 0) {
					$message = sprintf(GetLang("MySQLV4Message"), MYSQL_VERSION_REQUIRED, $ver);
					$errors = array(
						0 => array(
							"code" => "mysqlVersion",
							"extra" => $ver,
							"message" => $message
						)
					);
					$this->ShowInstallErrors($message, $errors, false, true);
					return;
				}
				else {
					// Run the database commands
					$queries = $this->template->render('install.schema.tpl');
					$queries = str_replace("\r", "\n", str_replace("\r\n", "\n", $queries));
					$queries = explode(";\n", $queries);
					$GLOBALS["ISC_CLASS_DB"]->Query("start transaction");

					// Initialize the admin auth class to get the list of permissions
					$auth = new ISC_ADMIN_AUTH();

					require_once(dirname(__FILE__) . "/class.user.php");
					$userManager = GetClass('ISC_ADMIN_USER');
					$pass = $_POST['UserPass'];
					$token = $userManager->_GenerateUserToken();

					foreach($queries as $query) {
						$query = str_replace("%%PREFIX%%", $_POST['tablePrefix'], $query);
						$query = str_replace("%%EMAIL%%", $GLOBALS["ISC_CLASS_DB"]->Quote($_POST['UserEmail']), $query);
						$query = str_replace("%%TOKEN%%", $GLOBALS["ISC_CLASS_DB"]->Quote($token), $query);

						if(trim($query) != "") {
							$GLOBALS["ISC_CLASS_DB"]->Query($query);
						}
					}

					// update admin user password
					$user_id = $userManager->getUserByField('username', 'admin');
					$userManager->updatePassword($user_id, $pass);

					// Give the admin user permissions
					$constants = get_defined_constants();

					foreach($constants as $constant => $val) {
						if(is_numeric(strpos($constant, "AUTH_")) && strpos($constant, "AUTH_") == 0) {
							$newPermission = array(
								"permuserid" => $user_id,
								"permpermissionid" => $val
							);
							$GLOBALS['ISC_CLASS_DB']->InsertQuery("permissions", $newPermission);
						}
					}

					// Set the version
					$db_version = array(
						'database_version' => PRODUCT_VERSION_CODE
					);
					$GLOBALS['ISC_CLASS_DB']->InsertQuery('config', $db_version);

					// Install our default currency. We need to do it here as it also needs to be in the config file
					$GLOBALS['ISC_CLASS_DB']->Query("DELETE FROM [|PREFIX|]currencies");
					$GLOBALS['ISC_CLASS_DB']->Query("ALTER TABLE [|PREFIX|]currencies AUTO_INCREMENT=1");
					$currency = array(
						'currencycountryid'			=> $_POST['StoreCountryLocationId'],
						'currencycode'				=> isc_strtoupper($_POST['StoreCurrencyCode']),
						'currencyname'				=> GetLang('InstallDefaultCurrencyName'),
						'currencyexchangerate'		=> GetConfig('DefaultCurrencyRate'),
						'currencystring'			=> html_entity_decode(GetLang('InstallDefaultCurrencyString')),
						'currencystringposition'	=> isc_strtolower(GetLang('InstallDefaultCurrencyStringPosition')),
						'currencydecimalstring'		=> GetLang('InstallDefaultCurrencyDecimalString'),
						'currencythousandstring'	=> GetLang('InstallDefaultCurrencyThousandString'),
						'currencydecimalplace'		=> GetLang('InstallDefaultCurrencyDecimalPlace'),
						'currencylastupdated'		=> time(),
						'currencyisdefault'			=> 1,
						'currencystatus'			=> 1
					);
					$defaultCurrencyId = $GLOBALS['ISC_CLASS_DB']->InsertQuery('currencies', $currency);

					// Insert the default/master shipping zone
					$GLOBALS['ISC_CLASS_DB']->Query("DELETE FROM [|PREFIX|]shipping_zones");
					$GLOBALS['ISC_CLASS_DB']->Query("ALTER TABLE [|PREFIX|]shipping_zones AUTO_INCREMENT=1");
					$masterZone = array(
						'zonename' => 'Default Zone',
						'zonetype' => 'country',
						'zonefreeshipping' => 0,
						'zonefreeshippingtotal' => 0,
						'zonehandlingtype' => 'none',
						'zonehandlingfee' => 0,
						'zonehandlingseparate' => 1,
						'zoneenabled' => 1,
						'zonedefault' => 1
					);
					$GLOBALS['ISC_CLASS_DB']->InsertQuery('shipping_zones', $masterZone);

					// Is there a custom SQL file to include?
					$customPath = ISC_BASE_PATH.'/custom';
					if(file_exists($customPath.'/install.schema.tpl')) {
						$template = Interspire_Template::getInstance('custominstall', $customPath, array(
							'cache' => getAdminTwigTemplateCacheDirectory(),
							'auto_reload' => true
						));
						$queries = $template->render('install.schema.tpl');
						$queries = str_replace("\r", "\n", str_replace("\r\n", "\n", $queries));
						$queries = explode(";\n", $queries);
						$GLOBALS['ISC_CLASS_DB']->StartTransaction();
						foreach($queries as $query) {
							$query = str_replace("%%PREFIX%%", $_POST['tablePrefix'], $query);
							if(trim($query)) {
								$GLOBALS['ISC_CLASS_DB']->Query($query);
							}
						}
						$GLOBALS['ISC_CLASS_DB']->CommitTransaction();
					}

					// Was there an error?
					if($GLOBALS["ISC_CLASS_DB"]->Error() == "") {
						$GLOBALS["ISC_CLASS_DB"]->Query("commit");

						// Save the config file
						foreach($_POST as $k => $v) {
							$GLOBALS['ISC_NEW_CFG'][$k] = $v;
						}

						// Set the email address for this user as the store admin/order email address
						$GLOBALS['ISC_NEW_CFG']['AdminEmail'] = $_POST['UserEmail'];
						$GLOBALS['ISC_NEW_CFG']['OrderEmail'] = $_POST['UserEmail'];

						$GLOBALS['ISC_NEW_CFG']['serverStamp'] = $_POST['LK'];
						$GLOBALS['ISC_CFG']['serverStamp'] = $_POST['LK'];

						$settings = GetClass('ISC_ADMIN_SETTINGS');

						$GLOBALS['ISC_NEW_CFG']['HostingProvider'] = "";


						// Can we send server details back to Interspire?
						// If we can, the HostingProvider global will also be set
						if(isset($_POST['sendServerDetails'])) {
							$this->SendServerDetails();
							if(isset($GLOBALS['InfoImage'])) {
								$GLOBALS['HiddenImage'] = $GLOBALS['InfoImage'];
							}
						}


						$GLOBALS['ISC_NEW_CFG']['ShopPath'] = $_POST['ShopPath'];
						$GLOBALS['ISC_NEW_CFG']['DefaultCurrencyID'] = $defaultCurrencyId;

						if (isset($GLOBALS['ISC_NEW_CFG']['StoreCountryLocationId'])) {
							unset($GLOBALS['ISC_NEW_CFG']['StoreCountryLocationId']);
						}
						if (isset($GLOBALS['ISC_NEW_CFG']['StoreCurrencyCode'])) {
							unset($GLOBALS['ISC_NEW_CFG']['StoreCurrencyCode']);
						}

						// set up the product images sizes
						// load the product image class to get the constants
						GetClass('ISC_PRODUCT_IMAGE');
						$GLOBALS['ISC_NEW_CFG']['ProductImagesStorewideThumbnail_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesStorewideThumbnail_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesProductPageImage_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesProductPageImage_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesGalleryThumbnail_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesGalleryThumbnail_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesZoomImage_width'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_ZOOM;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesZoomImage_height'] = ISC_PRODUCT_DEFAULT_IMAGE_SIZE_ZOOM;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesTinyThumbnailsEnabled'] = 1;
						$GLOBALS['ISC_NEW_CFG']['ProductImagesImageZoomEnabled'] = 1;

						// Build the unique encryption token
						$GLOBALS['ISC_NEW_CFG']['EncryptionToken'] = $this->_BuildEncryptionToken();

						// Set the install date
						$GLOBALS['ISC_NEW_CFG']['InstallDate'] = time();

						if ($settings->CommitSettings()) {
							// Calling commit settings a second time to ensure the config.backup.php file
							// Is written with valid data
							$settings->CommitSettings();

							// The installation is complete
							$GLOBALS['Password'] = $pass;

							// Do we need to install the sample product data? Copy that across
							if(isset($_POST['installSampleData']) && $_POST['installSampleData'] == 1) {
								$this->InstallSampleData();
							}

							// The install schemas can't predict the nested set values if custom install scripts arbitrarily add categories or pages
							// Rebuilt any nested sets instead of including their values in the install schema
							$nestedSet = new ISC_NESTEDSET_CATEGORIES();
							$nestedSet->rebuildTree();

							$nestedSet = new ISC_NESTEDSET_PAGES();
							$nestedSet->rebuildTree();

							// Remove any existing cookies
							ISC_UnsetCookie("STORESUITE_CP_TOKEN");

							//Initialize the data store system
							require_once ISC_BASE_PATH."/lib/class.datastore.php";
							$GLOBALS['ISC_CLASS_DATA_STORE'] = new ISC_DATA_STORE();

							// Clear the data store just in case it contains something
							$GLOBALS['ISC_CLASS_DATA_STORE']->Clear();

							$GLOBALS['ISC_LANG']['InstallationCompleted'] = sprintf(GetLang('InstallationCompleted'), $pass);

							unset($_SESSION['LK'.md5(strtolower($_POST['ShopPath']))]);

							// The installation was complete!
							if($this->apiMode == 'cli') {
								fwrite(STDOUT, "Success:\n");
								fwrite(STDOUT, "\n");
								fwrite(STDOUT, "ShopPath: ".$_POST['ShopPath']."\n");
								fwrite(STDOUT, "ControlPanel: ".$_POST['ShopPath']."admin/index.php\n");
								fwrite(STDOUT, "Username: admin\n");
								fwrite(STDOUT, "Password: "******"1.0" encoding="'.GetConfig("CharacterSet").'" ?'.">\n";
								echo "<response>\n";
								echo "  <status>OK</status>\n";
								echo "  <shop>\n";
								echo "      <shopPath>".$_POST['ShopPath']."</shopPath>\n";
								echo "      <controlPanel>".$_POST['ShopPath']."admin/index.php</controlPanel>\n";
								echo "  </shop>\n";
								echo "  <user>\n";
								echo "      <username>admin</username>\n";
								echo "      <password>".$_POST['UserPass']."</password>\n";
								echo "  </user>\n";
								echo "</response>\n";
								exit;
							}
							else {
								$this->template->display('install.done.tpl');
							}
						}
						else {
							$message = GetLang("ConfigErr");
							$errors = array(
								0 => array(
									"code" => "unableSaveConfig",
									"message" => $message
								)
							);
							$this->ShowInstallErrors($message, $errors, false, true);
							return;
						}
					}
					else {
						list($error, $level) = $db->GetError();
						$GLOBALS["ISC_CLASS_DB"]->Query("rollback");
						$message = sprintf(GetLang("DBErr"), $error);
						$errors = array(
							0 => array(
								"code" => "dbError",
								"message" => $GLOBALS["ISC_CLASS_DB"]->Error()
							)
						);
						$this->ShowInstallErrors($message, $errors, false, true);
						return;
					}
				}
			}
			else {
				list($error, $level) = $db->GetError();
				$message = sprintf(GetLang("DBErr"), $error);
				$errors = array(
					0 => array(
						"code" => "dbConnectError",
						"message" => $error
					)
				);
				$this->ShowInstallErrors($message, $errors, false, true);
				return;
			}
		}
コード例 #27
0
ファイル: CategoryContent.php プロジェクト: hungnv0789/vhtm
		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());
			}
		}
コード例 #28
0
 /**
  * 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;
 }
コード例 #29
0
ファイル: general.php プロジェクト: nirvana-info/old_bak
function hex2rgb($hex)
{
    // If the first char is a # strip it off
    if (isc_substr($hex, 0, 1) == '#') {
        $hex = isc_substr($hex, 1);
    }
    // If the string isnt the right length return false
    if (isc_strlen($hex) != 6) {
        return false;
    }
    $vals = array();
    $vals[] = hexdec(isc_substr($hex, 0, 2));
    $vals[] = hexdec(isc_substr($hex, 2, 2));
    $vals[] = hexdec(isc_substr($hex, 4, 2));
    $vals['r'] = $vals[0];
    $vals['g'] = $vals[1];
    $vals['b'] = $vals[2];
    return $vals;
}
コード例 #30
0
 /**
  * Check that a gift certificate is valid to apply
  *
  * @param string $code The gift certificate code
  * @param array $data The google request array
  *
  * @return mixed The google gift certificate if is valid, otherwise false
  **/
 private function ValidateGiftCertificate($code, $data)
 {
     $root = 'merchant-calculation-callback';
     $giftcert = new GoogleGiftcerts("false", $code, 0, GetLang('BadGiftCertificate'));
     if (isc_strlen($code) == GIFT_CERTIFICATE_LENGTH && gzte11(ISC_LARGEPRINT)) {
         $error = '';
         $cart = GetClass('ISC_CART');
         if ($cart->api->ApplyGiftCertificate($code)) {
             $certificates = $cart->api->GetGiftCertificates();
             foreach ($certificates as $certid => $certificate) {
                 if ($certificate['giftcertcode'] == $code) {
                     break;
                 }
             }
             // If successful return a valid coupon
             $giftcert = new GoogleGiftcerts('true', $code, $certificate['giftcertamount'], sprintf(GetLang('GiftCertificateAppliedToCart'), $certificate['giftcertcode'], GetConfig('CurrencyToken') . $certificate['giftcertbalance']));
         } else {
             $GLOBALS['CheckoutErrorMsg'] = implode("\n", $cart->api->GetErrors());
             $giftcert = new GoogleGiftcerts("false", $code, 0, $error);
         }
     } else {
         return false;
     }
     return $giftcert;
 }