} } else { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_types_id = '" . (int) $type_id . "' and products_status = '1' and products_listing_status = '1' and products_image_exists = '1'" . ((int) $type_id > 2 ? " and products_quantity > '0'" : "") . " order by rand() limit 1000"); if ($type_id > 2 && tep_db_num_rows($products_query) == 0) { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_types_id = '" . (int) $type_id . "' and products_status = '1' and products_listing_status = '1' and products_image_exists = '1' order by rand() limit 1000"); } } while ($products = tep_db_fetch_array($products_query)) { $random_products[] = $products['products_id']; } $fp = fopen($cache_filename, 'w'); fwrite($fp, implode("\n", $random_products)); fclose($fp); } else { $fp = fopen($cache_filename, 'r'); while (!feof($fp)) { $random_products[] = trim(fgets($fp, 16)); } fclose($fp); } $box_info_query = tep_db_query("select blocks_id, blocks_name from " . TABLE_BLOCKS . " where blocks_filename = '" . tep_db_input(basename(__FILE__)) . "' and language_id = '" . (int) $languages_id . "'"); $box_info = tep_db_fetch_array($box_info_query); $boxHeading = '<a href="' . tep_href_link($page_link, 'tPath=' . $type_id) . '">' . $box_info['blocks_name'] . '</a>'; srand((double) microtime() * 1000000); if (($random_products_count = sizeof(array_flip($random_products))) > 3) { $carousel_products = array_rand(array_flip($random_products), $random_products_count < 24 ? $random_products_count : 24); $boxContent = tep_show_products_carousel($carousel_products, 'carousel_' . $table_name . '_' . $type_id, '', 'table'); include DIR_WS_TEMPLATES_BOXES . 'box1.php'; } } }
if ($type == TABLE_SPECIALS_TYPES) { $products_query = tep_db_query("select products_id from " . TABLE_SPECIALS . " where specials_types_id = '" . (int) $type_id . "' and specials_first_page = '1' and status = '1' and specials_date_added >= '" . date('Y-m-d', time() - 60 * 60 * 24 * 7) . " 00:00:00' order by rand() limit 13"); if (tep_db_num_rows($products_query) == 0) { $products_query = tep_db_query("select products_id from " . TABLE_SPECIALS . " where specials_types_id = '" . (int) $type_id . "' and specials_first_page = '1' and status = '1' order by rand() limit 13"); } } else { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_types_id = '" . (int) $type_id . "' and products_status = '1' and products_listing_status = '1' and products_image_exists = '1'" . ((int) $type_id > 2 ? " and products_quantity > '0'" : "") . " order by rand() limit 13"); if ($type_id > 2 && tep_db_num_rows($products_query) == 0) { $products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where products_types_id = '" . (int) $type_id . "' and products_status = '1' and products_listing_status = '1' and products_image_exists = '1' order by rand() limit 13"); } } while ($products = tep_db_fetch_array($products_query)) { $carousel_products[] = $products['products_id']; } if (sizeof($carousel_products) > 0) { echo tep_show_products_carousel($carousel_products, $carousel_id, '', 'html'); } } tep_exit(); break; case 'load_captcha': header('Content-type: image/gif'); $image_width = 95; $image_height = 18; $font_size = 5; $rand_number1 = rand(6, 20); $rand_number2 = rand(1, 15); $string = $rand_number1 . ($rand_number1 > $rand_number2 ? ' - ' : ' + ') . $rand_number2 . ' = '; $captcha_value = $rand_number1 > $rand_number2 ? $rand_number1 - $rand_number2 : $rand_number1 + $rand_number2; if (!tep_session_is_registered('captcha_value')) { tep_session_register('captcha_value');
<?php if (basename(SCRIPT_FILENAME) == FILENAME_PRODUCT_INFO) { $limit = 16; $products_id = (int) $HTTP_GET_VARS['products_id']; $product_additional_info_query = tep_db_query("select products_periodicity from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'"); $product_additional_info = tep_db_fetch_array($product_additional_info_query); if ($product_additional_info['products_periodicity'] == '0') { $orders_products_array = array(); $orders_products_query = tep_db_query("select op.products_id from " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS_PRODUCTS_VIEWED . " opv where opv.products_id = '" . (int) $products_id . "' and op.orders_id = opv.orders_id order by opv.orders_products_viewed_id desc limit {$limit}"); if (tep_db_num_rows($orders_products_query) > 0) { while ($orders_products = tep_db_fetch_array($orders_products_query)) { $orders_products_array[] = $orders_products['products_id']; } $boxContent = tep_show_products_carousel($orders_products_array, 'viewed_carousel'); $box_info_query = tep_db_query("select blocks_name from " . TABLE_BLOCKS . " where blocks_filename = '" . tep_db_input(basename(__FILE__)) . "' and language_id = '" . (int) $languages_id . "'"); $box_info = tep_db_fetch_array($box_info_query); $boxHeading = $box_info['blocks_name']; include DIR_WS_TEMPLATES_BOXES . 'box1.php'; } } }
<?php if (basename(SCRIPT_FILENAME) == FILENAME_PRODUCT_INFO) { $limit = 16; $products_id = (int) $HTTP_GET_VARS['products_id']; $product_additional_info_query = tep_db_query("select authors_id from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'"); $product_additional_info = tep_db_fetch_array($product_additional_info_query); if ($product_additional_info['authors_id'] > 0) { $author_products_array = array(); $author_products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where authors_id = '" . (int) $product_additional_info['authors_id'] . "' and products_id <> '" . (int) $products_id . "' and products_status = '1' order by rand() limit {$limit}"); if (tep_db_num_rows($author_products_query) > 0) { while ($author_products = tep_db_fetch_array($author_products_query)) { $author_products_array[] = $author_products['products_id']; } $boxContent = tep_show_products_carousel($author_products_array, 'author_carousel'); $box_info_query = tep_db_query("select blocks_name from " . TABLE_BLOCKS . " where blocks_filename = '" . tep_db_input(basename(__FILE__)) . "' and language_id = '" . (int) $languages_id . "'"); $box_info = tep_db_fetch_array($box_info_query); $boxHeading = '<a href="' . tep_href_link(FILENAME_AUTHORS, 'authors_id=' . $product_additional_info['authors_id']) . '">' . sprintf($box_info['blocks_name'], tep_get_authors_info($product_additional_info['authors_id'], DEFAULT_LANGUAGE_ID)) . '</a>'; include DIR_WS_TEMPLATES_BOXES . 'box1.php'; } } }
$linked_query = tep_db_query("select cl.linked_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_LINKED . " cl where 1 and c.categories_status = '1' and c.categories_id = cl.linked_id and cl.categories_id in ('" . implode("', '", $parent_categories) . "')"); if (tep_db_num_rows($linked_query) > 0 || sizeof($linked_products_array) > 0) { while ($linked = tep_db_fetch_array($linked_query)) { $linked_categories[] = $linked['linked_id']; tep_get_subcategories($linked_categories, $linked['linked_id']); } reset($linked_categories); shuffle($linked_categories); while (list(, $linked_categories_id) = each($linked_categories)) { $linked_products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int) $linked_categories_id . "'"); while ($linked_products = tep_db_fetch_array($linked_products_query)) { $product_check_status_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int) $linked_products['products_id'] . "'"); $product_check_status = tep_db_fetch_array($product_check_status_query); if ($product_check_status['products_status'] == '1' && $linked_products['products_id'] != $products_id) { $linked_products_array[] = $linked_products['products_id']; if (sizeof($linked_products_array) >= $limit) { break; } } } } // $linked_products_array = array_rand(array_flip($linked_products_array), (sizeof($linked_products_array)<$limit ? sizeof($linked_products_array) : $limit)); if (sizeof($linked_products_array) > 0) { $boxContent = tep_show_products_carousel($linked_products_array, 'linked_carousel', array(), 'js', true); $box_info_query = tep_db_query("select blocks_name from " . TABLE_BLOCKS . " where blocks_filename = '" . tep_db_input(basename(__FILE__)) . "' and language_id = '" . (int) $languages_id . "'"); $box_info = tep_db_fetch_array($box_info_query); $boxHeading = $box_info['blocks_name']; include DIR_WS_TEMPLATES_BOXES . 'box1.php'; } } }
<?php if (basename(SCRIPT_FILENAME) == FILENAME_PRODUCT_INFO) { $limit = 16; $products_id = (int) $HTTP_GET_VARS['products_id']; $product_additional_info_query = tep_db_query("select series_id from " . TABLE_PRODUCTS . " where products_id = '" . (int) $products_id . "'"); $product_additional_info = tep_db_fetch_array($product_additional_info_query); if ($product_additional_info['series_id'] > 0) { $serie_products_array = array(); $serie_products_query = tep_db_query("select products_id from " . TABLE_PRODUCTS . " where series_id = '" . (int) $product_additional_info['series_id'] . "' and products_id <> '" . (int) $products_id . "' and products_status = '1' order by rand() limit {$limit}"); if (tep_db_num_rows($serie_products_query) > 0) { while ($serie_products = tep_db_fetch_array($serie_products_query)) { $serie_products_array[] = $serie_products['products_id']; } $boxContent = tep_show_products_carousel($serie_products_array, 'serie_carousel'); $box_info_query = tep_db_query("select blocks_name from " . TABLE_BLOCKS . " where blocks_filename = '" . tep_db_input(basename(__FILE__)) . "' and language_id = '" . (int) $languages_id . "'"); $box_info = tep_db_fetch_array($box_info_query); $boxHeading = '<a href="' . tep_href_link(FILENAME_SERIES, 'series_id=' . $product_additional_info['series_id']) . '">' . sprintf($box_info['blocks_name'], tep_get_series_info($product_additional_info['series_id'], DEFAULT_LANGUAGE_ID)) . '</a>'; include DIR_WS_TEMPLATES_BOXES . 'box1.php'; } } }