Advertisement
johnburn

corefunctions.php

Apr 18th, 2011
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.85 KB | None | 0 0
  1. <?php
  2. function write_cache($f_cache_data, $f_cache_file) {
  3.     if (!($fp = fopen($f_cache_file, "w"))) {
  4.         trigger_error("Error opening cache file");
  5.         exit();
  6.     }
  7.     if (!flock($fp, LOCK_EX)) {
  8.         trigger_error("Unable to lock file");
  9.         exit();
  10.     }
  11.     if (!fwrite($fp, serialize($f_cache_data))) {
  12.         trigger_error("Error writing to cache file");
  13.         exit();
  14.     }
  15.     flock($fp, LOCK_UN);
  16.     fclose($fp);
  17. }
  18. function read_cache($f_cache_file) {
  19.     if (!file_exists($f_cache_file)) {
  20.         trigger_error("Invalid cache file");
  21.         exit();
  22.     }
  23.     return unserialize(file_get_contents($f_cache_file));
  24. }
  25. function list_options($arrayname, $mode) {
  26.     global $row;
  27.     global $row_2;
  28.     $sarray = "";
  29.     foreach($arrayname as $v) {
  30.         if (!isset($row['salutation']) && $row['salutation'] == $v || isset($row_2['salutation']) && $row_2['salutation'] == $v) {
  31.             if (!isset($mode)) {
  32.                 echo "<option value=\"" . $v . "\" selected>{$v}</option>\n";
  33.             } else {
  34.                 $sarray.= "<option value=\"" . $v . "\" selected>{$v}</option>\n";
  35.             }
  36.         } else if (!isset($mode)) {
  37.             echo "<option value=\"" . $v . "\">{$v}</option>\n";
  38.         } else {
  39.             $sarray.= "<option value=\"" . $v . "\">{$v}</option>\n";
  40.         }
  41.     }
  42.     return $sarray;
  43. }
  44. function genprevnext($numrows, $position, $nresults, $scriptis, $extras) {
  45.     $disppages = intval($numrows / $nresults);
  46.     if ($numrows % $nresults) {
  47.         ++$disppages;
  48.     }
  49.     if ($nresults <= $position) {
  50.         $current_page_num = $position / $nresults + 1;
  51.     } else {
  52.         $current_page_num = 1;
  53.     }
  54.     if (1 < $disppages) {
  55.         echo "(Viewing " . $current_page_num . " of {$disppages} pages)<br /><br />";
  56.     }
  57.     if (!($numrows <= $nresults)) {
  58.         if ("{$nresults}" <= $position) {
  59.             $prevoffset = $position - $nresults;
  60.             echo "<a href=\"" . $shopur . "{$scriptis}?position={$prevoffset}&nresults={$nresults}{$extras}\">&laquo; Prev</a>";
  61.         } else {
  62.             echo "<a href=\"#\">&laquo; Prev&nbsp;</a>";
  63.         }
  64.         $pages = intval($numrows / $nresults);
  65.         if ($numrows % $nresults) {
  66.             ++$pages;
  67.         }
  68.         $i = 1;
  69.         for (;$i <= $pages;++$i) {
  70.             $newoffset = $nresults * ($i - 1);
  71.             echo "<a href=\"" . $http . "{$scriptis}?position={$newoffset}&nresults={$nresults}{$extras}\">{$i}</a>";
  72.         }
  73.         if (!($offset / $nresults == $pages) || $pages != 1) {
  74.             $newoffset = $position + $nresults;
  75.             if ($numrows <= $newoffset) {
  76.                 echo "<a href=\"#\">Next &raquo;</a>";
  77.             } else {
  78.                 echo "<a href=\"" . $shopur . "{$scriptis}?position={$newoffset}&nresults={$nresults}{$extras}\">Next &raquo;</a>";
  79.             }
  80.         }
  81.     }
  82. }
  83. function buildCategorySelect() {
  84.     global $connection;
  85.     global $category_id;
  86.     $level = "0";
  87.     $sql = "SELECT * from categories WHERE category_parent_id='deftl'";
  88.     if (!($result = @mysql_query($sql, $connection))) {
  89.         exit("** COULD NOT BUILD CATEGORY DROP DOWN ** " . mysql_error());
  90.     }
  91.     while ($row = mysql_fetch_array($result)) {
  92.         $parent = "{$row['category_id']}";
  93.         $row[category_name] = stripslashes("{$row['category_name']}");
  94.         if ($category_id == $row[category_id]) {
  95.             echo "<option value=\"" . $row['category_id'] . "\" selected>+ {$row['category_name']}</option>\n";
  96.         } else {
  97.             echo "<option value=\"" . $row['category_id'] . "\">+ {$row['category_name']}</option>\n";
  98.         }
  99.         getchildren($parent, $level);
  100.     }
  101. }
  102. function getChildren($parent, $level) {
  103.     global $connection;
  104.     global $category_id;
  105.     ++$level;
  106.     $sql1 = "SELECT * from categories WHERE category_parent_id='" . $parent . "' order by category_name";
  107.     if (!($result1 = @mysql_query($sql1, $connection))) {
  108.         exit("Couldn't build category tree child part: " . mysql_error());
  109.     }
  110.     while ($row1 = mysql_fetch_array($result1)) {
  111.         $parent = "{$row1['category_id']}";
  112.         if ($category_id == $row1[category_id]) {
  113.             echo "<option value=\"" . $row1['category_id'] . "\" selected>";
  114.         } else {
  115.             echo "<option value=\"" . $row1['category_id'] . "\">";
  116.         }
  117.         $i = 0;
  118.         for (;$i < $level;++$i) {
  119.             echo " ";
  120.         }
  121.         echo "|--[" . $level . "]";
  122.         echo " " . $row1['category_name'] . "</option>\n";
  123.         getchildren($parent, $level);
  124.     }
  125. }
  126. function getChildrenSEL($parent, $myparent, $level) {
  127.     global $connection;
  128.     global $https;
  129.     global $category_id;
  130.     ++$level;
  131.     $sql1 = "SELECT * from categories WHERE category_parent_id='" . $parent . "' order by category_name";
  132.     if (!($result1 = @mysql_query($sql1, $connection))) {
  133.         exit("Couldn't build category tree child part: " . mysql_error());
  134.     }
  135.     while ($row1 = mysql_fetch_array($result1)) {
  136.         $parent = "{$row1['category_id']}";
  137.         if ($myparent == $row1[category_id]) {
  138.             echo "<option value=\"" . $row1['category_id'] . "\" selected>";
  139.         } else if ($category_id == $row1[category_id]) {
  140.             echo "<option value=\"deftl\">";
  141.         } else {
  142.             echo "<option value=\"" . $row1['category_id'] . "\">";
  143.         }
  144.         $i = 0;
  145.         for (;$i < $level;++$i) {
  146.             echo " ";
  147.         }
  148.         echo "|" . $level . "|";
  149.         echo "{$row1['category_name']}</option>\n";
  150.         getchildrensel($parent, $myparent, $level);
  151.     }
  152. }
  153. function makeCategoryMap() {
  154.     global $connection;
  155.     global $adminurl;
  156.     $level = "0";
  157.     $sql = "SELECT * from categories WHERE category_parent_id='deftl'";
  158.     if (!($result = @mysql_query($sql, $connection))) {
  159.         exit("Couldn't build category tree parent part: " . mysql_error());
  160.     }
  161.     while ($row = mysql_fetch_array($result)) {
  162.         $parent = "{$row['category_id']}";
  163.         $sql3 = "SELECT product_id from products WHERE category_id='" . $parent . "'";
  164.         if (!($result3 = @mysql_query($sql3, $connection))) {
  165.             exit("Couldn't get data from products db");
  166.         }
  167.         $numrows = mysql_num_rows($result3);
  168.         if ($numrows < 1) {
  169.             $linker = "";
  170.         } else {
  171.             $linker = "<input type=\"button\" class=\"list\" onclick=\"location.href='" . $adminurl . "products/productlist.php?category_id={$row['category_id']}'\" value=\"Products ({$numrows})\" />";
  172.         }
  173.         $row[category_name] = stripslashes("{$row['category_name']}");
  174.         echo "<tr>\n\t\t\t\t<td> + <a href=\"" . $adminurl . "products/editcategory.php?category_id={$row['category_id']}\" title=\"{$row['category_desc']}\">{$row['category_name']}</a> </td>\n\t\t\t\t<td>";
  175.         if ($row[category_publish] == Y) {
  176.             echo "<input type=\"button\" class=\"deactivate\" value=\"(click to deactivate)\" onclick=\"location.href='" . $adminurl . "products/bin/categoryonoff.php?category_id={$row['category_id']}&act=N'\" />";
  177.         } else {
  178.             echo "<input type=\"button\" class=\"activate\" value=\"(click to activate)\" onclick=\"location.href='" . $adminurl . "products/bin/categoryonoff.php?category_id={$row['category_id']}&act=Y'\" />";
  179.         }
  180.         echo "</td>\n\t\t\t\t<td> <input type=\"button\" class=\"add\" onclick=\"location.href='" . $adminurl . "products/addproduct.php?category_id={$row['category_id']}'\" value=\"Add\" /> {$linker} </td>\n\t\t\t\t<td> <input type=\"button\" class=\"edit\" onclick=\"location.href='{$adminurl}products/editcategory.php?category_id={$row['category_id']}'\" value=\"Edit\" /> <input type=\"button\" class=\"delete\" value=\"DELETE\" onclick='usr_conf(\"{$adminurl}products/bin/deletecategory.php\",\"category_id={$row['category_id']}\",\"Are you sure you want to delete this category?\");' /> </td>\n\t\t\t</tr>\n";
  181.         getchildrenlist($parent, $level);
  182.     }
  183. }
  184. function getChildrenList($parent, $level) {
  185.     global $connection;
  186.     global $adminurl;
  187.     ++$level;
  188.     $where_in_level = "0";
  189.     $sql1 = "SELECT * from categories WHERE category_parent_id='" . $parent . "'";
  190.     if (!($result1 = @mysql_query($sql1, $connection))) {
  191.         exit("Couldn't build category tree child part: " . mysql_error());
  192.     }
  193.     while ($row1 = mysql_fetch_array($result1)) {
  194.         ++$where_in_level;
  195.         $parent = "{$row1['category_id']}";
  196.         $level_indent = $level - 1;
  197.         $i = 0;
  198.         for (;$i < $level_indent;++$i) {
  199.             echo " ";
  200.         }
  201.         if ($last_level == $level) {
  202.             echo " ";
  203.         } else {
  204.             echo " ";
  205.         }
  206.         $i = 0;
  207.         for (;$i < $level;++$i) {
  208.             echo " ";
  209.         }
  210.         $sql3 = "SELECT product_id from products WHERE category_id='" . $parent . "'";
  211.         if (!($result3 = @mysql_query($sql3, $connection))) {
  212.             exit("Couldn't get data from products db");
  213.         }
  214.         $numrows = mysql_num_rows($result3);
  215.         if ($numrows < 1) {
  216.             $linker = "";
  217.         } else {
  218.             $linker = "<input type=\"button\" class=\"list\" onclick=\"location.href='" . $adminurl . "products/productlist.php?category_id={$row1['category_id']}'\" value=\"Products ({$numrows})\" />";
  219.         }
  220.         echo "\t<tr>\n\t\t<td> &raquo; (" . $level . ") <a href=\"{$adminurl}products/editcategory.php?category_id={$row1['category_id']}\" title=\"{$row1['category_desc']}\">{$row1['category_name']}</a></td>\n\t\t\t<td>";
  221.         if ($row1[category_publish] == Y) {
  222.             echo "<input type=\"button\" class=\"deactivate\" value=\"(click to deactivate)\" onclick=\"location.href='" . $adminurl . "products/bin/categoryonoff.php?category_id={$row1['category_id']}&act=N'\" />";
  223.         } else {
  224.             echo "<input type=\"button\" class=\"activate\" value=\"(click to activate)\" onclick=\"location.href='" . $adminurl . "products/bin/categoryonoff.php?category_id={$row1['category_id']}&act=Y'\" />";
  225.         }
  226.         echo "</td> \n\t\t\t<td><input type=\"button\" class=\"add\" onclick=\"location.href='" . $adminurl . "products/addproduct.php?category_id={$row1['category_id']}'\" value=\"Add\" /> {$linker}</td>\n\t\t\t<td> <input type=\"button\" class=\"edit\" onclick=\"location.href='{$adminurl}products/editcategory.php?category_id={$row1['category_id']}'\" value=\"Edit\" /> <input type=\"button\" class=\"delete\" value=\"DELETE\" onclick='usr_conf(\"{$adminurl}products/bin/deletecategory.php\",\"category_id={$row1['category_id']}\",\"Are you sure you want to delete this category?\");' /></td>\n\t</tr>\n";
  227.         getchildrenlist($parent, $level);
  228.         $last_level = $level;
  229.     }
  230. }
  231. function productcheckcategories() {
  232.     global $connection;
  233.     global $oktoadd;
  234.     $sql3 = "SELECT * from categories";
  235.     if (!($result3 = @mysql_query($sql3, $connection))) {
  236.         exit("Couldn't get data from category db");
  237.     }
  238.     $numrows = mysql_num_rows($result3);
  239.     if (1 <= $numrows) {
  240.         $oktoadd = "Y";
  241.     }
  242. }
  243. function countrycompareDD($country_dd) {
  244.     global $connection;
  245.     echo "<select name=\"country\">";
  246.     $sql3 = "SELECT country_short, country_long from country WHERE zone_id !='0'";
  247.     if (!($result3 = @mysql_query($sql3, $connection))) {
  248.         exit("Couldn't execute request 1");
  249.     }
  250.     while ($row3 = mysql_fetch_array($result3)) {
  251.         if ($row3[country_short] == $country_dd) {
  252.             echo "<option value=\"" . $row3['country_short'] . "\" selected>{$row3['country_long']}</option>\n";
  253.         } else {
  254.             echo "<option value=\"" . $row3['country_short'] . "\">{$row3['country_long']}</option>\n";
  255.         }
  256.     }
  257.     echo "</select>";
  258. }
  259. function alternatecolour($level) {
  260.     global $altclass;
  261.     $class_1 = " class=altlight";
  262.     $class_2 = " class=altdark";
  263.     $altclass = $class_1;
  264.     $level % 2 ? 0 : ($altclass = $class_2);
  265. }
  266. function check_email_address($email) {
  267.     if (!ereg("[^@]{1,64}@[^@]{1,255}", $email)) {
  268.         return FALSE;
  269.     }
  270.     $email_array = explode("@", $email);
  271.     $local_array = explode(".", $email_array[0]);
  272.     $i = 0;
  273.     for (;$i < sizeof($local_array);++$i) {
  274.         if (ereg("^(([A-Za-z0-9!#\$%&'*+/=?^_`{|}~-][A-Za-z0-9!#\$%&'*+/=?^_`{|}~\\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))\$", $local_array[$i])) {
  275.             continue;
  276.         }
  277.         return FALSE;
  278.     }
  279.     if (!ereg("^\\[?[0-9\\.]+\\]?\$", $email_array[1])) {
  280.         $domain_array = explode(".", $email_array[1]);
  281.         if (sizeof($domain_array) < 2) {
  282.             return FALSE;
  283.         }
  284.         $i = 0;
  285.         for (;$i < sizeof($domain_array);++$i) {
  286.             if (ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))\$", $domain_array[$i])) {
  287.                 continue;
  288.             }
  289.             return FALSE;
  290.         }
  291.     }
  292.     return TRUE;
  293. }
  294. $sYear = "2007";
  295. $cwd = dirname(__FILE__);
  296. $instdir = str_replace("private", "", "{$cwd}");
  297. include ("{$instdir}private/config.php");
  298. include ("{$instdir}private/cache.php");
  299. if (!$shopurl) {
  300.     header("Location: install/");
  301.     exit();
  302. }
  303. include ("{$instdir}private/db_connect.php");
  304. include ("{$instdir}private/messages.php");
  305. include ("{$instdir}private/shop_messages.php");
  306. $s_cache_file = "{$sscache_dir}key.txt";
  307. if ($sscache == "Y" && file_exists($s_cache_file) && time() - $sscache_exp < filemtime($s_cache_file)) {
  308.     $s_cache_data = read_cache($s_cache_file);
  309. } else {
  310.     $sql = "SELECT copyRightKey,domainName FROM shop_settings";
  311.     if (!($result = @mysql_query($sql, $connection))) {
  312.         exit("**COULD NOT GET COPYRIGHT KEYS**");
  313.     }
  314.     while ($row = mysql_fetch_array($result)) {
  315.         $s_cache_data[] = $row;
  316.     }
  317.     if ("" . $sscache . "" == "Y" && isset($s_cache_data)) {
  318.         write_cache($s_cache_data, $s_cache_file);
  319.     }
  320. }
  321. if (isset($s_cache_data)) {
  322.     foreach($s_cache_data as $key => $row) {
  323.         $copyRightCode = "{$row['copyRightKey']}";
  324.         $domainName = "{$row['domainName']}";
  325.     }
  326.     $s_cache_data = "";
  327. }
  328. $stylish = array("tuxdiscs.com_CC66BD976A919DBA1D389EA030F1C98E", "homeheatgas.co.uk_7E3987914C37A595611AA2B02647AB3E", "htcshop.co.uk_D1463A8E25B25DBBF2828A05F1A4C786", "creativegiftcompany.co.uk_A0084DC13CAD4EF04745341D7B2859A0", "satnavnow.com_CB37C0E975D7C997C02DD8C2A903CCCE", "officesource.co.uk_D1F94EC11C220D3607897126CF0FC60B", "snapitshowit.com_EA669BA712152AC7604824CC4C821810", "englandathome.co.uk_FA3831E23466E7B22D4A17076C0795FC", "ellisofficefurniture.co.uk_B36B5A3FBEB39CF965EDE33C4F6607EE", "myweddingbox.co.uk_4856BFB9DBF37F90C0FA492CE087154E", "dukkaan.net_AA339C99F82BCD6C7DB0CB38A1A2D35C", "sosophisticated.co.uk_524D866DF422AB6211030E0400408957", "pure-beauty.co.uk_8DF947D81601F80C75A6109FD8E14DDA", "pure-beauty_31B643B484171B66354FC78FB2C272AA", "goodiessweetshop.co.uk_77489A3F2430FB4AF433250B9BFF9F71", "whiskcooking.co.uk_DDEB2054E47603FA9183BF8C91FD703D", "bodychef.co.uk_9F2D61781FA3B2F70EFDD3992604A551", "athenaflooring.co.uk_E7D0D322B5F23A3A2BFBB010001AB21B", "partyshop-mold.co.uk_41E26ED3FA379384B2EB103F60EDD059", "thegolfzone.net_86A65F7F8E7355649A4BA1B78462A60B", "littlereddogshop.co.uk_03B59361FD76EC594037262FEB44EAD3", "furnituregiant.co.uk_8C2C781A7C590FF3239182ED3DC24368", "dancevinyls.com_0999AB3CEAF33D53C7599BF2AFB9D804", "brainegg.com_A76ADAE00F80DA87C83C1C6B7939809E", "mrbates.co.uk_B24D6A529B75FD6BC256EB4FF8FAA28A", "metrosales.co.uk_3F507226A07DF97E8DAD87FED2BD7C25", "2pic1.co.uk_2FD2A963331EE04AFE7882AC447F3D53", "thingsonline.co.uk_340520B537817C03E4EEE71765A9769D", "tenpinshop.com_9ACBC1B6E153F74E2E8D58DF4AFFFE37", "drakepneumatics.co.uk_282A7137E3AAA0E7FA1A3A8E42899C49", "ipendpoints.co.uk_7470912986F50101ED255A5AF8679DB3");
  329. $admin_dirs = array("settings", "orders", "newsletter", "reports", "shoppers", "products", "content");
  330. $mtta = array("mail", "smtp");
  331. $ppgfields = array("ppemail", "ppmerchantid", "ppsecret", "pptestmode", "ppinstid", "ppintip", "ppextip", "ppgiftaid", "ppApply3DSecure", "ppApplyAVSCV2", "ppauthmode", "ppsignature");
  332. $category_style = array("List with Thumbnail", "List no Thumbnail", "Grid 2 Across", "Grid 3 Across", "Grid 4 Across", "Grid 5 Across");
  333. $category_sort_order = array("Alphabetical", "Newest Items First", "Newest Items Last", "Featured Items First", "Custom Sort", "Price Low - High", "Price High - Low");
  334. $sf_style = array("List", "Grid 2 Across", "Grid 3 Across", "Grid 4 Across", "Grid 5 Across");
  335. $sf_sort_order = array("Alphabetical", "By ID", "Randomised");
  336. $cf_sort_order = array("Alphabetical", "By ID", "Custom");
  337. $allow_next = array("selectdeliveryaddress.php", "revieworder.php", "reviewproduct.php", "revieworder.php?clearptid=Y", "orders.php");
  338. if ($_GET[next] && !in_array("{$_GET['next']}", $allow_next)) {
  339.     echo "Not allowed!";
  340.     exit();
  341. }
  342. $GLOBALS['_GET'][category_id] = mysql_real_escape_string("{$_GET['category_id']}");
  343. $GLOBALS['_GET'][product_id] = mysql_real_escape_string("{$_GET['product_id']}");
  344. $GLOBALS['_GET'][product_xo_id] = mysql_real_escape_string("{$_GET['product_xo_id']}");
  345. $GLOBALS['_GET'][o_id] = mysql_real_escape_string("{$_GET['o_id']}");
  346. $GLOBALS['_GET'][p_id] = mysql_real_escape_string("{$_GET['p_id']}");
  347. $GLOBALS['_GET'][a_id] = mysql_real_escape_string("{$_GET['a_id']}");
  348. $GLOBALS['_POST'][query_string] = mysql_real_escape_string("{$_POST['query_string']}");
  349. $GLOBALS['_POST'][new_currency_id] = mysql_real_escape_string("{$_POST['new_currency_id']}");
  350. $GLOBALS['_POST'][pre_xo_id] = mysql_real_escape_string("{$_POST['pre_xo_id']}");
  351. $GLOBALS['_POST'][p_id] = mysql_real_escape_string("{$_POST['p_id']}");
  352. $GLOBALS['_POST'][qty] = mysql_real_escape_string("{$_POST['qty']}");
  353. $GLOBALS['_POST'][loginemail] = mysql_real_escape_string("{$_POST['loginemail']}");
  354. $GLOBALS['_POST'][loginpass] = mysql_real_escape_string("{$_POST['loginpass']}");
  355. $GLOBALS['_POST'][mail_outs] = mysql_real_escape_string("{$_POST['mail_outs']}");
  356. $GLOBALS['_POST'][old_password] = mysql_real_escape_string("{$_POST['old_password']}");
  357. $GLOBALS['_POST'][confirm_password] = mysql_real_escape_string("{$_POST['confirm_password']}");
  358. $GLOBALS['_GET'][category_id] = mysql_real_escape_string("{$_GET['category_id']}");
  359. $GLOBALS['_GET'][product_id] = mysql_real_escape_string("{$_GET['product_id']}");
  360. $GLOBALS['_GET'][new_currency_id] = mysql_real_escape_string("{$_GET['new_currency_id']}");
  361. $GLOBALS['_GET'][new_currency_id] = mysql_real_escape_string("{$_GET['new_currency_id']}");
  362. $search = array("@<script[^>]*?>.*?</script>@si", "@<[\\/\\!]*?[^<>]*?>@si", "@&(quot|#34);@i", "@&(amp|#38);@i", "@&(lt|#60);@i", "@&(gt|#62);@i", "@&(nbsp|#160);@i", "@&(iexcl|#161);@i", "@&(cent|#162);@i", "@&(pound|#163);@i", "@&(copy|#169);@i", "@&#(\\d+);@e");
  363. $replace = array("", "", "\\1", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "chr(\\1)");
  364. $GLOBALS['_POST'][company] = mysql_real_escape_string("{$_POST['company']}");
  365. $GLOBALS['_POST'][company] = preg_replace($search, $replace, $_POST[company]);
  366. $GLOBALS['_POST'][first_name] = mysql_real_escape_string("{$_POST['first_name']}");
  367. $GLOBALS['_POST'][first_name] = preg_replace($search, $replace, $_POST[first_name]);
  368. $GLOBALS['_POST'][last_name] = mysql_real_escape_string("{$_POST['last_name']}");
  369. $GLOBALS['_POST'][last_name] = preg_replace($search, $replace, $_POST[last_name]);
  370. $GLOBALS['_POST'][email] = mysql_real_escape_string("{$_POST['email']}");
  371. $GLOBALS['_POST'][email] = preg_replace($search, $replace, $_POST[email]);
  372. $GLOBALS['_POST'][no_name] = mysql_real_escape_string("{$_POST['no_name']}");
  373. $GLOBALS['_POST'][no_name] = preg_replace($search, $replace, $_POST[no_name]);
  374. $GLOBALS['_POST'][street] = mysql_real_escape_string("{$_POST['street']}");
  375. $GLOBALS['_POST'][street] = preg_replace($search, $replace, $_POST[street]);
  376. $GLOBALS['_POST'][town] = mysql_real_escape_string("{$_POST['town']}");
  377. $GLOBALS['_POST'][town] = preg_replace($search, $replace, $_POST[town]);
  378. $GLOBALS['_POST'][county] = mysql_real_escape_string("{$_POST['county']}");
  379. $GLOBALS['_POST'][county] = preg_replace($search, $replace, $_POST[county]);
  380. $GLOBALS['_POST'][postcode] = mysql_real_escape_string("{$_POST['postcode']}");
  381. $GLOBALS['_POST'][postcode] = preg_replace($search, $replace, $_POST[postcode]);
  382. $GLOBALS['_POST'][country] = mysql_real_escape_string("{$_POST['country']}");
  383. $GLOBALS['_POST'][country] = preg_replace($search, $replace, $_POST[country]);
  384. $GLOBALS['_POST'][day_tel] = mysql_real_escape_string("{$_POST['day_tel']}");
  385. $GLOBALS['_POST'][day_tel] = preg_replace($search, $replace, $_POST[day_tel]);
  386. $GLOBALS['_POST'][eve_tel] = mysql_real_escape_string("{$_POST['eve_tel']}");
  387. $GLOBALS['_POST'][eve_tel] = preg_replace($search, $replace, $_POST[eve_tel]);
  388. $GLOBALS['_POST'][mobile] = mysql_real_escape_string("{$_POST['mobile']}");
  389. $GLOBALS['_POST'][mobile] = preg_replace($search, $replace, $_POST[mobile]);
  390. $GLOBALS['_POST'][fax] = mysql_real_escape_string("{$_POST['fax']}");
  391. $GLOBALS['_POST'][fax] = preg_replace($search, $replace, $_POST[fax]);
  392. $GLOBALS['_POST'][emailaddress] = mysql_real_escape_string("{$_POST['emailaddress']}");
  393. $GLOBALS['_POST'][emailaddress] = preg_replace($search, $replace, $_POST[emailaddress]);
  394. $GLOBALS['_POST'][password] = mysql_real_escape_string("{$_POST['password']}");
  395. $GLOBALS['_POST'][password] = preg_replace($search, $replace, $_POST[password]);
  396. if ($_GET[sssess]) {
  397.     session_id($_GET[sssess]);
  398. }
  399. session_start();
  400. header("cache-control: private");
  401. if (isset($_GET[redeempoints]) && $_GET[redeempoints] == "Y") {
  402.     $_SESSION[redeemer] = "Y";
  403. }
  404. if ($_POST[purchaseorder]) {
  405.     $_SESSION[po] = "{$_POST['purchaseorder']}";
  406. }
  407. if (!$_SESSION[loginemail]) {
  408.     $_SESSION[loginemail] = "noemail@ssprite";
  409. }
  410. if (!$_SESSION[adminemail]) {
  411.     $_SESSION[adminemail] = "noadmin@ssprite";
  412. }
  413. if ($_POST[discode]) {
  414.     $_SESSION[discode] = trim("{$_POST['discode']}");
  415. }
  416. $auth_ok_check = md5("{$_SESSION['loginemail']}.{$hash}");
  417. $admin_ok_check = md5("{$_SESSION['adminemail']}.{$hash}");
  418. if (isset($_GET['oidref'])) {
  419.     $GLOBALS['_GET']['oidref'] = mysql_real_escape_string($_GET['oidref']);
  420.     $sql = "SELECT o_id FROM order_list WHERE ref='" . $_GET['oidref'] . "' AND unh='{$_GET['oidref']}'";
  421.     if (!($result = @mysql_query($sql, $connection))) {
  422.         exit("**COULD NOT GET COPYRIGHT KEYS**");
  423.     }
  424.     if ($row = mysql_fetch_array($result)) {
  425.         $_SESSION['unh'] = $_GET['oidref'];
  426.         header("location: " . $sshopurl . "orderdetails_os.php?o_id={$row['o_id']}");
  427.         exit();
  428.     }
  429.     if ($_SESSION['auth_ok'] == $auth_ok_check) {
  430.         header("location: " . $sshopurl . "secure/orders.php");
  431.         exit();
  432.     }
  433.     header("location: " . $sshopurl . "secure/login.php?next=orders.php");
  434.     exit();
  435. }
  436. if (preg_match("/secure/", "{$_SERVER['PHP_SELF']}") && !preg_match("/doqreg.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/qreg.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/voicepaycallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/secpaysecpagecallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/vps_handle_protx_response.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/protx/", "{$_SERVER['PHP_SELF']}") || !preg_match("/protxformcallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/protxcallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/worldpaycallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/securetradingcallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/barclayscpicallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/paypalcallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/moneybookerscallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/nochexcallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/offlinecallback.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/doregister.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/register.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/doprereg.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/login.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/dologin.php/", "{$_SERVER['PHP_SELF']}")) {
  437.     if ($auth_ok_check != $_SESSION[auth_ok]) {
  438.         header("Location: " . $sshopurl . "secure/login.php?next={$_GET['next']}&shk&p={$_SERVER['PHP_SELF']}");
  439.         exit();
  440.     }
  441.     if (preg_match("/secure/", "{$_SERVER['PHP_SELF']}")) {
  442.         $isaccount = "1";
  443.     }
  444. }
  445. if (preg_match("/" . $adminDir . "/", "{$_SERVER['PHP_SELF']}") && !preg_match("/adlogin.php/", "{$_SERVER['PHP_SELF']}") || !preg_match("/forgetful.php/", "{$_SERVER['PHP_SELF']}")) {
  446.     if ($admin_ok_check != $_SESSION[admin_ok]) {
  447.         header("Location: " . $adminurl . "adlogin.php");
  448.         exit();
  449.     }
  450.     if (preg_match("/" . $adminDir . "/", "{$_SERVER['PHP_SELF']}")) {
  451.         $isadmin = "1";
  452.     }
  453. }
  454. $noadirs = count($admin_dirs);
  455. $i = 0;
  456. for (;$i <= $noadirs;++$i) {
  457.     if (!preg_match("/admin\\/" . $admin_dirs[$i] . "/", "{$_SERVER['PHP_SELF']}") && preg_match("/" . $admin_dirs[$i] . "/", "{$_SESSION['admin_type']}")) {
  458.         continue;
  459.     }
  460.     header("Location: " . $adminurl . "perms.php?noperm={$admin_dirs[$i]}");
  461.     exit();
  462. }
  463. if (!$_SESSION[shopper_type]) {
  464.     $_SESSION[shopper_type] = "1";
  465. }
  466. if ($_GET[setcurrency] == 1) {
  467.     if ($_GET[new_currency_id]) {
  468.         $GLOBALS['_POST'][new_currency_id] = $_GET[new_currency_id];
  469.     }
  470.     $_SESSION['currency_id'] = $_POST[new_currency_id];
  471. }
  472. if ($_GET[clearptid] == Y) {
  473.     session_unregister("ptid");
  474. }
  475. if ($_GET[selectpostage] == 1) {
  476.     if ($_POST[selptid] == Free || $_POST[selptid] == free) {
  477.         session_unregister("ptid");
  478.     } else if (isset($_POST[selptid])) {
  479.         $_SESSION['ptid'] = $_POST[selptid];
  480.     } else {
  481.         session_unregister("ptid");
  482.     }
  483.     $GLOBALS['_POST'][selptid] = mysql_real_escape_string($_POST[selptid]);
  484.     $sql1 = "UPDATE basket SET ptid='" . $_POST['selptid'] . "' WHERE session_id='" . session_id() . "'";
  485.     if (!($result1 = @mysql_query($sql1, $connection))) {
  486.         exit("Couldn't execute request 1");
  487.     }
  488. }
  489. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement