$res2 = mysql_query($q2,$conn); if (!$res2) { die('Invalid query: ' . mysql_error()); } } die; while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) { $postal = $row['postcode']; $d = getPostal($zips,$postal); //print_r($d); //continue; if($d) { $regionModel = Mage::getModel('directory/region')->loadByCode($d[3], "US"); $regionId = $regionModel->getId(); //$q2 = "UPDATE `sales_flat_order_address` SET `region`='".$d['3']."' AND `region_id` ='".$regionId."' WHERE `entity_id`='".$row['entity_id']."'"; $q2 = "UPDATE `sales_flat_order_address` SET `region_id` ='".$regionId."' WHERE `entity_id`='".$row['entity_id']."'"; echo $q2."\n"; $res2 = mysql_query($q2,$conn); if (!$res2) {
/** * Writes cache files. * @since 2.0.0 * @version 2.2.1 * @param int $cID Cache file to be created 0 = settings.php, 1 = settings_named.php, 2 = locList(a).php, 3 = meta.php, 4 = selCity(a).php, 5 = selPostal(a).php, 6 = Cache Age File (Default:0) * @param int $a [optional] Version of file to create. 0 = public calendar, 1 = admin console (Default:0, Used for $cID = 2/4/5 only.) * @return void */ function buildCache($cID = 0, $a = 0) { global $hc_cfg, $hc_lang_search; if (!is_writable(HCPATH . '/cache/')) { exit("Cache directory cannot be written to."); } $f = $a == 1 ? 'a' : ''; $hc_fetch_settings = '1,2,3,4,7,8,9,10,11,12,13,14,15,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,40,41,42,43,44,45,48,49,'; $hc_fetch_settings .= '50,51,52,54,53,55,56,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,'; $hc_fetch_settings .= '90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,113,114,115,126,127,128,129,130,131,132,133,134'; switch ($cID) { case 1: if (defined('HC_Named')) { if (!file_exists(HCPATH . '/cache/settings_named.php')) { $result = doQuery("SELECT PkID, Name FROM " . HC_TblPrefix . "settings WHERE PkID IN (" . $hc_fetch_settings . ") AND SettingValue != '' AND Name IS NOT NULL ORDER BY Name"); if (hasRows($result)) { ob_start(); $fp = fopen(HCPATH . '/cache/settings_named.php', 'w'); fwrite($fp, "<?php\n//\tHelios Named Config Cache - Delete this file when upgrading.\n\n"); fwrite($fp, "\$hc_cfg_named = array(\n"); while ($row = mysql_fetch_row($result)) { fwrite($fp, "'" . $row[1] . "'\t=>\t\$hc_cfg[" . $row[0] . "],\n"); } fwrite($fp, "'category_columns'\t=>\t\$hc_cfg['CatCols'],\n"); fwrite($fp, ");\n?>"); fclose($fp); ob_end_clean(); } else { exit(handleError(0, "Setting Data Missing.")); } } } break; case 2: if (!file_exists(HCPATH . '/cache/locList' . $f . '.php')) { $q = $a == 0 ? 'AND IsPublic = 1' : ''; $result = doQuery("SELECT PkID, Name FROM " . HC_TblPrefix . "locations WHERE IsActive = 1 " . $q . " ORDER BY Name"); ob_start(); $fp = fopen(HCPATH . '/cache/locList' . $f . '.php', 'w'); fwrite($fp, "<?php\n//\tHelios Location List - Delete this file when upgrading.\n\n"); fwrite($fp, "\$NewAll = (isset(\$NewAll)) ? \$NewAll : '';?>\n\n"); echo '<select name="locListI" id="locListI" onchange="if(isNaN(this.options[this.selectedIndex].value)){splitLocation(this.options[this.selectedIndex].value);}">'; if (hasRows($result)) { echo "\n\t" . '<option value="0|"><?php echo $NewAll;?></option>'; echo "\n\t" . '<option value="-1">-------------------------</option>'; while ($row = mysql_fetch_row($result)) { echo "\n\t" . '<option value="' . $row[0] . '|' . cOut($row[1]) . '">' . cOut($row[1]) . '</option>'; } } else { echo "\n\t" . '<option value="0">' . $hc_lang_core['NoLocList'] . '</option>'; } echo "\n" . '</select><br />'; fwrite($fp, ob_get_contents()); fclose($fp); ob_end_clean(); } break; case 3: if (!file_exists(HCPATH . '/cache/meta.php')) { ob_start(); $fp = fopen(HCPATH . '/cache/meta.php', 'w'); fwrite($fp, "<?php\n//\tHelios Meta Cache - Delete this file when upgrading.\n\n"); fwrite($fp, "\$hc_meta = array(\n"); $result = doQuery("SELECT * FROM " . HC_TblPrefix . "settingsmeta"); $x = 1; $pairs = array(1 => 1, 2 => 2, 3 => 'submit', 4 => 'search', 5 => 'searchresult', 6 => 'signup', 7 => 'send', 8 => 'rsvp', 9 => 'tools', 10 => 'rss', 11 => 'newsletter', 12 => 'archive', 13 => 'filter', 14 => 'digest', 15 => 'signin', 16 => 'acc'); while ($row = mysql_fetch_row($result)) { fwrite($fp, "\n'" . $pairs[$x] . "'\t=>\tarray('title' => '" . cIn($row[3]) . "', 'keywords' => '" . cIn($row[1]) . "', 'desc' => '" . cIn($row[2]) . "'),"); ++$x; } fwrite($fp, "\n);\n?>"); fwrite($fp, ob_get_contents()); fclose($fp); ob_end_clean(); } break; case 4: if (!file_exists(HCPATH . '/cache/selCity' . $f . '.php')) { ob_start(); $fp = fopen(HCPATH . '/cache/selCity' . $f . '.php', 'w'); fwrite($fp, "<?php\n//\tHelios City Select List Cache - Delete this file when upgrading.\n?>\n"); fwrite($fp, "\n<select name=\"city\" id=\"city\" disabled=\"disabled\">"); fwrite($fp, "\n<option value=\"\">" . $hc_lang_search['City0'] . "</option>"); $cities = getCities($a); foreach ($cities as $val) { if ($val != '') { fwrite($fp, "\n<option value=\"" . $val . "\">" . $val . "</option>"); } } fwrite($fp, "\n</select>"); fwrite($fp, ob_get_contents()); fclose($fp); ob_end_clean(); } break; case 5: if (!file_exists(HCPATH . '/cache/selPostal' . $f . '.php')) { ob_start(); $fp = fopen(HCPATH . '/cache/selPostal' . $f . '.php', 'w'); fwrite($fp, "<?php\n//\tHelios Postal Code Select List Cache - Delete this file when upgrading.\n?>\n"); fwrite($fp, "\n<select name=\"postal\" id=\"postal\" disabled=\"disabled\">"); fwrite($fp, "\n<option value=\"\">" . $hc_lang_search['Postal0'] . "</option>"); $codes = getPostal($a); foreach ($codes as $val) { if ($val != '') { fwrite($fp, "\n<option value=\"" . $val . "\">" . $val . "</option>"); } } fwrite($fp, "\n</select>"); fwrite($fp, ob_get_contents()); fclose($fp); ob_end_clean(); } break; case 6: $cache_date = date("Ymd"); if (!file_exists(HCPATH . '/cache/' . $cache_date . '.php')) { clearCache(); ob_start(); $fp = fopen(HCPATH . '/cache/' . $cache_date . '.php', 'w'); fwrite($fp, "<?php\n/*\n\tHelios Cache Age File. - Delete this file when upgrading.\n*/\n?>"); fclose($fp); ob_end_clean(); } break; default: if (!file_exists(HCPATH . '/cache/settings.php')) { $result = doQuery("SELECT PkID, SettingValue FROM " . HC_TblPrefix . "settings WHERE PkID IN (" . $hc_fetch_settings . ") ORDER BY PkID"); if (hasRows($result)) { ob_start(); $fp = fopen(HCPATH . '/cache/settings.php', 'w'); fwrite($fp, "<?php\n//\tHelios Config Cache - Delete this file when upgrading.\n\n"); fwrite($fp, "\$hc_cfg = array(\n"); while ($row = mysql_fetch_row($result)) { fwrite($fp, $row[0] . " => \"" . str_replace("\"", "'", $row[1]) . "\",\n"); } fwrite($fp, "200 => \"hc_" . sha1(md5(CalRoot) . HC_Rando) . "\",\n"); fwrite($fp, "201 => \"helios_" . md5(CalRoot . HC_Rando) . "\",\n"); fwrite($fp, "\"CatCols\" => \"3\",\n"); fwrite($fp, "\"CatLinks\" => \"1\",\n"); fwrite($fp, "\"IsRSVP\" => \"1\",\n"); fwrite($fp, "\"OLImages\" => \"" . CalRoot . "/img/ol/\",\n"); $resultE = doQuery("SELECT MIN(StartDate), MAX(StartDate) FROM " . HC_TblPrefix . "events WHERE IsApproved = 1 AND IsActive = 1"); if (hasRows($resultE)) { $first = strtotime(mysql_result($resultE, 0, 0)) < date("U", mktime(0, 0, 0, date("m"), date("d"), date("Y"))) ? strtotime(mysql_result($resultE, 0, 0)) : date("U", mktime(0, 0, 0, date("m"), date("d"), date("Y"))); fwrite($fp, "\"First\" => \"" . $first . "\",\n"); fwrite($fp, "\"Last\" => \"" . strtotime(mysql_result($resultE, 0, 1)) . "\",\n"); } $news = date("Y-m-d"); $resultN = doQuery("SELECT MIN(SentDate) FROM " . HC_TblPrefix . "newsletters WHERE STATUS > 0 AND IsArchive = 1 AND IsActive = 1 AND ArchiveContents != ''"); if (hasRows($resultN) && mysql_result($resultN, 0, 0) != '') { $news = mysql_result($resultN, 0, 0); } fwrite($fp, "\"News\" => \"" . $news . "\",\n"); fwrite($fp, ");\n?>"); fclose($fp); ob_end_clean(); } else { exit(handleError(0, "Setting Data Missing.")); } } break; } }