} while (strpos($form_link, '?&')) { $form_link = str_replace('?&', '?', $form_link); } while (strpos($form_link, '&&')) { $form_link = str_replace('&&', '&', $form_link); } $cur_row = 0; // if ($customer_id==2) echo $listing_sql; $listing = array(); if ($show_listing_string == false) { $listing_query = tep_db_unbuffered_query($listing_sql); } else { $listing_query = tep_db_unbuffered_query($listing_split->sql_query); } while ($row = tep_db_fetch_row($listing_query)) { $listing[] = $row[0]; } reset($listing); while (list($rows, $product_id) = each($listing)) { $product_info_query = tep_db_query("select " . $select_column_list . " p.* from " . TABLE_PRODUCTS . " p where p.products_id = '" . (int) $product_id . "'"); $product_info = tep_db_fetch_array($product_info_query); $product_info['final_price'] = $product_info['products_price']; $product_info['specials_new_products_price'] = 0; $product_info['specials_name'] = ''; $product_info['specials_description'] = ''; $special_info_query = tep_db_query("select specials_name, specials_description, specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int) $product_id . "' and status > '0' and specials_new_products_price > '0' and specials_new_products_price < '" . $product_info['products_price'] . "' and language_id = '" . (int) $languages_id . "' order by specials_date_added desc limit 1"); if (tep_db_num_rows($special_info_query) > 0) { $special_info = tep_db_fetch_array($special_info_query); $product_info['final_price'] = $special_info['specials_new_products_price']; $product_info['specials_new_products_price'] = $special_info['specials_new_products_price'];
function backup() { global $HTTP_POST_VARS; $this->SET['comp_method'] = tep_not_null($HTTP_POST_VARS['compress']) && $HTTP_POST_VARS['compress'] != '0' ? intval($HTTP_POST_VARS['compress']) : ''; $this->SET['comp_level'] = 5; $tables = array(); $result = tep_db_query("SHOW TABLES"); $all = 0; while ($row = tep_db_fetch_row($result)) { $tables[] = $row[0]; } $tabs = count($tables); // Определение размеров таблиц $result = tep_db_query("SHOW TABLE STATUS"); $tabinfo = array(); $tab_charset = array(); $tab_type = array(); $tabinfo[0] = 0; $info = ''; while ($item = tep_db_fetch_array($result)) { if (in_array($item['Name'], $tables)) { $item['Rows'] = empty($item['Rows']) ? 0 : $item['Rows']; $tabinfo[0] += $item['Rows']; $tabinfo[$item['Name']] = $item['Rows']; $tabsize[$item['Name']] = 1 + round(LIMIT * 1048576 / ($item['Avg_row_length'] + 1)); if ($item['Rows']) { $info .= "|" . $item['Rows']; } if (!empty($item['Collation']) && preg_match("/^([a-z0-9]+)_/i", $item['Collation'], $m)) { $tab_charset[$item['Name']] = $m[1]; } $tab_type[$item['Name']] = isset($item['Engine']) ? $item['Engine'] : $item['Type']; } } $show = 10 + $tabinfo[0] / 50; $info = $tabinfo[0] . $info; $this->backup_file = DIR_FS_BACKUP . 'db_' . DB_DATABASE . '-' . date("YmdHis") . '.sql'; $fp = $this->fn_open($this->backup_file, "w"); $this->fn_write($fp, '#SKD101|{' . DB_DATABASE . '|' . $tabs . '|' . date("Y.m.d H:i:s") . '|' . $info . "\n\n"); $t = 0; $result = tep_db_query("SET SQL_QUOTE_SHOW_CREATE = 1"); // Кодировка соединения по умолчанию if ($this->mysql_version > 40101 && DB_CHARSET != 'auto') { tep_db_query("SET NAMES '" . DB_CHARSET . "'"); $last_charset = DB_CHARSET; } else { $last_charset = ''; } if (!is_array($tables)) { $tables = array(); } reset($tables); while (list(, $table) = each($tables)) { // Выставляем кодировку соединения соответствующую кодировке таблицы if ($this->mysql_version > 40101 && $tab_charset[$table] != $last_charset) { if (DB_CHARSET == 'auto') { tep_db_query("SET NAMES '" . $tab_charset[$table] . "'"); $last_charset = $tab_charset[$table]; } } // Создание таблицы $result = tep_db_query("SHOW CREATE TABLE `{$table}`"); $tab = tep_db_fetch_row($result); $tab = preg_replace('/(default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP|DEFAULT CHARSET=\\w+|COLLATE=\\w+|character set \\w+|collate \\w+)/i', '/*!40101 \\1 */', $tab); $this->fn_write($fp, "DROP TABLE IF EXISTS `{$table}`;\n{$tab[1]};\n\n"); // Проверяем нужно ли дампить данные if (in_array($tab_type[$table], $this->only_create)) { continue; } // Опредеделяем типы столбцов $NumericColumn = array(); $result = tep_db_query("SHOW COLUMNS FROM `{$table}`"); $field = 0; while ($col = tep_db_fetch_row($result)) { $NumericColumn[$field++] = preg_match("/^(\\w*int|year)/", $col[1]) ? 1 : 0; } $fields = $field; $from = 0; $limit = $tabsize[$table]; $limit2 = round($limit / 3); $i = 0; while (($result = tep_db_query("SELECT * FROM `{$table}` LIMIT {$from}, {$limit}")) && ($total = tep_db_num_rows($result))) { if ($i == 0) { $this->fn_write($fp, "INSERT INTO `{$table}` VALUES"); } while ($row = tep_db_fetch_row($result)) { $i++; $t++; for ($k = 0; $k < $fields; $k++) { if ($NumericColumn[$k]) { $row[$k] = isset($row[$k]) ? $row[$k] : "NULL"; } else { $row[$k] = isset($row[$k]) ? "'" . mysql_escape_string($row[$k]) . "'" : "NULL"; } $row[$k] = str_replace(array('\\\\"', '\\"', "\\\\'"), array('"', '"', "\\'"), $row[$k]); } $this->fn_write($fp, ($i == 1 ? "" : ",") . "\n(" . implode(", ", $row) . ")"); } tep_db_free_result($result); if ($total < $limit) { break; } $from += $limit; } if ($total > 0) { $this->fn_write($fp, ";\n\n"); } } $this->fn_close($fp); }
echo '</pre>'; } } echo createGoogleSitemap(); } else { echo 'Geen sitemaps gevonden'; } //productfeed if (PRODUCT_FEED_BESLIST == 'true') { tep_export('beslist'); } if (PRODUCT_FEED_KIESKEURIG == 'true') { tep_export('kieskeurig'); } //leegmaken cache $dir = DIR_FS_CATALOG . DIR_FS_CACHE; //cache dir if (is_dir($dir)) { reset_cache_dir($dir); } /********************************/ /* Optimize database tables */ /********************************/ $tables_query = tep_db_query('SHOW TABLES FROM ' . DB_DATABASE); while ($table = tep_db_fetch_row($tables_query)) { tep_db_query('OPTIMIZE TABLE ' . $table[0]); } /*sitemap update*/ tep_db_query('DELETE FROM `productspecs` WHERE `products_model` NOT IN (SELECT products_model FROM products)'); tep_db_query('DELETE FROM `specifications` where (hoofdkenmerk,subkenmerk) not in (SELECT hoofdkenmerk, subkenmerk from productspecs)'); require DIR_WS_INCLUDES . 'application_bottom.php';