Ejemplo n.º 1
0
	/**
	 * Convert string or array of string to UTF-8
	 *
	 * Method will convert $str which is either a string or array of string from $fromEncoding to UTF-8. If $fromEncoding
	 * is empty then use the output from GetConfig("dbEncoding")
	 *
	 * @access protected
	 * @param mixed $str The string or array of strings to convert
	 * @param string $fromEncoding The optional from encoding. Default is GetConfig("dbEncoding")
	 * @return mixed The converted string or array of strings
	 */
	protected function convert2UTF8($str, $fromEncoding='')
	{
		if (trim($str) == '') {
			return $str;
		}

		if (trim($fromEncoding) == '') {
			$fromEncoding = GetConfig("dbEncoding");
		}

		if (trim($fromEncoding) == '') {
			return $str;
		}

		/**
		 * Convert the $fromEncoding as mb_convert_encoding doesn't understand MySQL char encoding names. Just look
		 * for the most common encodings
		 */
		switch (isc_strtolower($fromEncoding)) {
			case "utf8":
				$fromEncoding = "utf-8";
				break;

			case "latin1":
				$fromEncoding = "iso-8859-1";
				break;

			case "latin2":
				$fromEncoding = "iso-8859-2";
				break;
		}

		return isc_convert_charset($fromEncoding, "utf-8", $str);
	}
Ejemplo n.º 2
0
/**
 * Convert all request inputs from $from character set to $to character set
 *
 * Function will convert all $_GET, $_POST and $_REQUEST data from the character set
 * in $from to the character set in $to
 *
 * @access public
 * @param string $from The character set to convert from
 * @param string $to The character set to convert to
 * @param bool $toRequest TRUE to also do $_REQUEST, FALSE to skip it. Default is TRUE
 * @return null
 */
function convertRequestInput($from = 'UTF-8', $to = '', $doRequest = true)
{
    if ($to == '') {
        $to = GetConfig('CharacterSet');
    }
    if ($from == '' || $to == '' || $from === $to) {
        return;
    }
    $_GET = isc_convert_charset($from, $to, $_GET);
    $_POST = isc_convert_charset($from, $to, $_POST);
    if ($doRequest) {
        $_REQUEST = isc_convert_charset($from, $to, $_REQUEST);
    }
}
 public function GetOverviewStatsTop20SeriesData()
 {
     if (isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) {
         $from = (int) $_GET['from'];
         $to = (int) $_GET['to'];
         // Only fetch products this user can actually see
         $vendorRestriction = '';
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $vendorRestriction = " AND prodvendorid='" . (int) $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() . "'";
         }
         $output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $output .= "<pie>\n";
         $query = "\n                SELECT\n                    ordprodname, bs.seriesname, b.brandname,\n                    SUM(ordprodqty) AS numsold\n                FROM\n                    [|PREFIX|]order_products\n                    INNER JOIN [|PREFIX|]orders ON (orderorderid=orderid)\n                    LEFT JOIN [|PREFIX|]products p ON (ordprodid=p.productid)\n                    LEFT JOIN [|PREFIX|]brand_series bs ON p.brandseriesid = bs.seriesid   \n                    LEFT JOIN [|PREFIX|]brands b ON bs.brandid = b.brandid\n                WHERE\n                    ordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n                    ordprodtype != 'giftcertificate' AND\n                    ordprodid != 0 AND \n                    p.brandseriesid != 0 AND       \n                    orddate >= '" . $from . "' AND\n                    orddate <= '" . $to . "'\n                    " . $vendorRestriction . "\n                GROUP BY\n                    bs.seriesid\n                UNION\n                SELECT\n                    ordprodname, '' AS seriesname, b.brandname,\n                    SUM(ordprodqty) AS numsold\n                FROM\n                    [|PREFIX|]order_products\n                    INNER JOIN [|PREFIX|]orders ON (orderorderid=orderid)\n                    LEFT JOIN [|PREFIX|]products p ON (ordprodid=p.productid)              \n                    LEFT JOIN [|PREFIX|]brands b ON p.prodbrandid = b.brandid\n                WHERE\n                    ordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n                    ordprodtype != 'giftcertificate' AND\n                    ordprodid != 0 AND   \n                    p.brandseriesid = 0 AND   \n                    b.brandid !=0 AND   \n                    orddate >= '" . $from . "' AND\n                    orddate <= '" . $to . "'\n                    " . $vendorRestriction . "\n                GROUP BY\n                    b.brandid  \n                ORDER BY\n                    numsold DESC\n            ";
         //p.brandseriesid != 0 AND
         $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 30);
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 $CombinedSeriesName = $row['brandname'];
                 if (trim($row['seriesname']) != '') {
                     $CombinedSeriesName .= " - " . $row['seriesname'];
                 }
                 $output .= sprintf("\t<slice title=\"%s\" pull_out=\"false\">%s</slice>\n", isc_html_escape(isc_convert_charset(GetConfig('CharacterSet'), 'UTF-8', $CombinedSeriesName)), (int) $row['numsold']);
             }
         }
         $output .= "</pie>";
         echo $output;
     }
 }
 public function GetOverviewStatsTop20ProductsData()
 {
     if (isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) {
         $from = (int) $_GET['from'];
         $to = (int) $_GET['to'];
         // Only fetch products this user can actually see
         $vendorRestriction = '';
         if ($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) {
             $vendorRestriction = " AND prodvendorid='" . (int) $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() . "'";
         }
         $output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $output .= "<pie>\n";
         $query = "\n\t\t\t\tSELECT\n\t\t\t\t\tordprodname,\n\t\t\t\t\tSUM(ordprodqty) AS numsold\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]order_products\n\t\t\t\t\tINNER JOIN [|PREFIX|]orders ON (orderorderid=orderid)\n\t\t\t\t\tLEFT JOIN [|PREFIX|]products ON (ordprodid=productid)\n\t\t\t\tWHERE\n\t\t\t\t\tordstatus IN (" . implode(',', GetPaidOrderStatusArray()) . ") AND\n\t\t\t\t\tordprodtype != 'giftcertificate' AND\n\t\t\t\t\tordprodid != 0 AND\n\t\t\t\t\torddate >= '" . $from . "' AND\n\t\t\t\t\torddate <= '" . $to . "'\n\t\t\t\t\t" . $vendorRestriction . "\n\t\t\t\tGROUP BY\n\t\t\t\t\tordprodid\n\t\t\t\tORDER BY\n\t\t\t\t\tnumsold DESC\n\t\t\t";
         $query .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, 20);
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 $output .= sprintf("\t<slice title=\"%s\" pull_out=\"false\">%s</slice>\n", isc_html_escape(isc_convert_charset(GetConfig('CharacterSet'), 'UTF-8', $row['ordprodname'])), (int) $row['numsold']);
             }
         }
         $output .= "</pie>";
         echo $output;
     }
 }
 /**
  * Build the top 10 search keywords pie graph.
  */
 public function GetSearchStatsOverviewData()
 {
     if (isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) {
         $from = (int) $_GET['from'];
         $to = (int) $_GET['to'];
         $output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
         $output .= "<pie>\n";
         $query = sprintf("SELECT concat(\n\t\t\t\tsearchtext , \n\t\t\t\t   IF( \n\t\t\t\t     strcmp(concat(UPPER(prodmaker), prodyear, UPPER(prodmodel)), ''),  \n\t\t\t\t     concat( ' (', UPPER(prodmaker) , ' ' , prodyear , ' ', UPPER(prodmodel), ')'), ''\n\t\t\t\t) \n\t\t\t\t) AS searchtext, '' as maker, '' as Year, '' as model, COUNT( searchid ) AS numsearches\n\t\t\t\tFROM isc_searches_extended\n\t\t\t\twhere searchdate >= '%d' and searchdate <= '%d' \n\t\t\t\tGROUP BY searchtext\n\t\t\t\tORDER BY numsearches DESC \n\t\t\t\tLIMIT 10", $from, $to);
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
             while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 $ymm = (isset($row['year']) && $row['year'] != "" ? " " . $row['year'] : '') . (isset($row['maker']) && $row['maker'] != "" ? " " . $row['maker'] : '') . (isset($row['model']) && $row['model'] != "" ? " " . $row['model'] : '');
                 if (isset($ymm) && $ymm != '') {
                     $ymm = "&nbsp;({$ymm})";
                 } else {
                     $ymm = '';
                 }
                 $output .= sprintf("\t<slice title=\"%s\" pull_out=\"false\">%s</slice>\n", isc_html_escape(isc_convert_charset(GetConfig('CharacterSet'), 'UTF-8', $row['searchtext'] . $ymm)), $row['numsearches']);
             }
         }
         $output .= "</pie>";
         echo $output;
     }
 }
Ejemplo n.º 6
0
/**
 * Convert a string between 2 character sets.
 *
 * @param string Character set to convert from.
 * @param string Character set to convert to.
 * @param string String to convert.
 * @return string The converted string.
 */
function isc_convert_charset($in, $out, $str)
{
    if ($in === $out) {
        return $str;
    } elseif (function_exists('mb_convert_encoding')) {
        if (is_array($str)) {
            foreach (array_keys($str) as $key) {
                $str[$key] = isc_convert_charset($in, $out, $str[$key]);
            }
        } else {
            $str = mb_convert_encoding($str, $out, $in);
        }
        return $str;
    } else {
        return $str;
    }
}
Ejemplo n.º 7
0
	/**
	 * Build the top 10 search keywords pie graph.
	 */
	public function GetSearchStatsOverviewData()
	{
		if(isset($_GET['from']) && is_numeric($_GET['from']) && isset($_GET['to']) && is_numeric($_GET['to'])) {

			$from = (int)$_GET['from'];
			$to = (int)$_GET['to'];

			$output = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
			$output .= "<pie>\n";
			$query = sprintf("select distinct(searchtext), count(searchid) as numsearches from [|PREFIX|]searches_extended where searchdate >= '%d' and searchdate <= '%d' group by searchtext order by numsearches desc limit 10", $from, $to);
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

			if($GLOBALS['ISC_CLASS_DB']->CountResult($result) > 0) {
				while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
					$output .= sprintf("\t<slice title=\"%s\" pull_out=\"false\">%s</slice>\n", isc_html_escape(isc_convert_charset(GetConfig('CharacterSet'), 'UTF-8', $row['searchtext'])), $row['numsearches']);
				}
			}

			$output .= "</pie>";
			echo $output;
		}
	}
Ejemplo n.º 8
0
	/**
	 * Revert all the HTML entities in $str to normal UTF-8
	 *
	 * Method will revert all HTML entities in $str to normal UTF-8. Method should work interchangable
	 * with self::filterInvalidQBXMLChars()
	 *
	 * @access public
	 * @param string $str The string to revert
	 * @return string The reverted string on success, FALSE on error
	 */
	public function revertInvalidQBXMLChars($str)
	{
		if (!is_string($str)) {
			return false;
		} else if (trim($str) == "") {
			return $str;
		} else {
			return isc_convert_charset("HTML-ENTITIES", "UTF-8", $str);
		}
	}
Ejemplo n.º 9
0
 /**
  * Perform an insert query of data form the imported store to the new store and convert the data to the right encoding.
  */
 public function ConvertedInsertQuery($table, $data)
 {
     if (isset($this->_importSession['Configuration']['charset'])) {
         foreach ($data as $k => $v) {
             // It's only strings that we need to convert
             if (!is_string($v)) {
                 continue;
             }
             $convertedString = isc_convert_charset($this->_importSession['Configuration']['charset'], GetConfig('CharacterSet'), $v);
             // If the conversion failed, skip it and carry on
             if (!$convertedString) {
                 continue;
             }
             $data[$k] = $convertedString;
         }
     }
     return $GLOBALS['ISC_CLASS_DB']->InsertQuery($table, $data);
 }