Base de datos manejada Web Hosting Cuestiones
- johnlynches
- Novice


- Registrado: Dic 20, 2010
- Mensajes: 15
- Status: Offline
Tengo un sitio web que es la base de datos mySQL impulsada (www_coinsupplyzone_com), pero es tan lento para cargar la mayor parte del tiempo. Algunas páginas tardan más de 30 segundos en cargarse, mientras que otras veces esa misma página se carga en menos de un segundo.
Actualmente estoy usando "inmotionhosting" como mi compañía de hosting. Hice mucha investigación antes de que apretó el gatillo en ellos, pero me preguntaba si no había tal cosa como una empresa de alojamiento que se especializa en sitios con base de datos? O si había una manera de ayudar a acelerar los tiempos de acceso a mi base de datos? Conozco a una buena cantidad de HTML y CSS, pero cuando se trata de bases de datos que soy un principiante.
Cualquier ayuda será apreciada, gracias....... Juan
Actualmente estoy usando "inmotionhosting" como mi compañía de hosting. Hice mucha investigación antes de que apretó el gatillo en ellos, pero me preguntaba si no había tal cosa como una empresa de alojamiento que se especializa en sitios con base de datos? O si había una manera de ayudar a acelerar los tiempos de acceso a mi base de datos? Conozco a una buena cantidad de HTML y CSS, pero cuando se trata de bases de datos que soy un principiante.
Cualquier ayuda será apreciada, gracias....... Juan
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Abril 28th, 2011, 4:31 pm
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Online
Es posible que desee preguntarle a su servicio de hosting si saben de alguna razón su página web se carga lento a veces. Podría haber muchas cosas que causan el problema, y voy a enumerar algunas de ellas.
El primero podría ser su servicio de hosting tiene la culpa. Es posible que su servicio de hosting o bien tiene demasiados usuarios en sus servidores, que hace que se atascan a veces negativamente está afectando. También podría ser que su servicio de hosting no ha configurado su base de datos MySQL de forma óptima lo que podría hacer que se tienen malos resultados a veces.
El segundo podría ser que usted es culpable. ¿Va a crear sus propias consultas MySQL escribiendo el mismo código? O utilizar el software que ya ha sido escrito por otra persona? La razón que pido es porque si no hacerlo con cuidado artesanal las consultas SQL que fácilmente podría ejecutar algunas consultas resultados muy pobres que millones de la búsqueda de los registros que se tomaría un tiempo para ejecutarse. Si usted ha escrito su propio consultas SQL es posible que desee pasar por cada uno de ellos y ejecutarlos en phpMyAdmin o cualquiera que sea su método favorito es, y poner la palabra EXPLICAR frente a la consulta. Esto le puede decir todo tipo de cosas con el tipo de búsqueda utilizando la consulta es, para el número de registros es tener que buscar a través de darle los resultados. También puede indicar a usted si usted no ha configurado correctamente los índices que podrían velocidad de las consultas mucho. Así, por ejemplo si yo tuviera una consulta como esta que me da un resultado:
se puede encontrar información sobre él mediante la colocación de explicar la palabra en la parte delantera:
Su servicio de hosting puede trabajar con usted para ayudarle a diagnosticar su problema, o si no parece de mucha ayuda siempre se puede pasar a un servicio de hosting nuevo, como Ozzu gif "alt = =";)" título" Guiño ">
A pocos hilos a Ozzu que pueden ser útiles:
MySQL Límites
¿Cuáles son muchas consultas MySQL por página?
MySQL Tabla con millones de entradas
El primero podría ser su servicio de hosting tiene la culpa. Es posible que su servicio de hosting o bien tiene demasiados usuarios en sus servidores, que hace que se atascan a veces negativamente está afectando. También podría ser que su servicio de hosting no ha configurado su base de datos MySQL de forma óptima lo que podría hacer que se tienen malos resultados a veces.
El segundo podría ser que usted es culpable. ¿Va a crear sus propias consultas MySQL escribiendo el mismo código? O utilizar el software que ya ha sido escrito por otra persona? La razón que pido es porque si no hacerlo con cuidado artesanal las consultas SQL que fácilmente podría ejecutar algunas consultas resultados muy pobres que millones de la búsqueda de los registros que se tomaría un tiempo para ejecutarse. Si usted ha escrito su propio consultas SQL es posible que desee pasar por cada uno de ellos y ejecutarlos en phpMyAdmin o cualquiera que sea su método favorito es, y poner la palabra EXPLICAR frente a la consulta. Esto le puede decir todo tipo de cosas con el tipo de búsqueda utilizando la consulta es, para el número de registros es tener que buscar a través de darle los resultados. También puede indicar a usted si usted no ha configurado correctamente los índices que podrían velocidad de las consultas mucho. Así, por ejemplo si yo tuviera una consulta como esta que me da un resultado:
SQL Código: [ Select ]
SELECT *
FROM `phpbb_posts`
WHERE `post_id` =123456
FROM `phpbb_posts`
WHERE `post_id` =123456
- SELECT *
- FROM `phpbb_posts`
- WHERE `post_id` =123456
se puede encontrar información sobre él mediante la colocación de explicar la palabra en la parte delantera:
SQL Código: [ Select ]
EXPLAIN SELECT *
FROM `phpbb_posts`
WHERE `post_id` =123456
FROM `phpbb_posts`
WHERE `post_id` =123456
- EXPLAIN SELECT *
- FROM `phpbb_posts`
- WHERE `post_id` =123456
Su servicio de hosting puede trabajar con usted para ayudarle a diagnosticar su problema, o si no parece de mucha ayuda siempre se puede pasar a un servicio de hosting nuevo, como Ozzu gif "alt = =";)" título" Guiño ">
A pocos hilos a Ozzu que pueden ser útiles:
MySQL Límites
¿Cuáles son muchas consultas MySQL por página?
MySQL Tabla con millones de entradas
Ozzu Hosting - Want your website on a fast server like Ozzu?
- johnlynches
- Novice


- Registrado: Dic 20, 2010
- Mensajes: 15
- Status: Offline
Me comuniqué con mi anfitrión en relación con este tema que siguen diciendo que lo más probable es un problema con mi internet y mi sitio carga muy bien en su extremo. Lo que no tiene sentido si es que durante el día las páginas tardan una eternidad en cargar, pero por la noche se carga en menos de un segundo o dos.
Yo hice lo siguiente en mi panel de control de hosting: "Comprimir los tipos MIME especificado" (text / html text / plain text / xml), pero eso es casi todo lo que sé hacer.
Yo no escribí el código de mí, es mi ViArt cesta de la compra que hizo por mí. Malos echa un vistazo a los otros hilos, gracias.
Yo hice lo siguiente en mi panel de control de hosting: "Comprimir los tipos MIME especificado" (text / html text / plain text / xml), pero eso es casi todo lo que sé hacer.
Yo no escribí el código de mí, es mi ViArt cesta de la compra que hizo por mí. Malos echa un vistazo a los otros hilos, gracias.
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Online
Sólo por curiosidad, ¿tiene su página web recibe una gran cantidad de tráfico?
Normalmente los servidores web recibe más ocupados durante el día, pero si su sitio web no recibe una gran cantidad de tráfico, eso no significa que alguien más en su servidor no es que se bogging las cosas. Es realmente difícil de adivinar sin conseguir en su servidor y el diagnóstico de lo que está pasando, no puede haber numerosas razones que causan esto.
En cuanto a que sea la conexión local, que siempre es posible también. Digamos por ejemplo que haya una conexión de cable, es posible que durante el día en que unas pocas personas en su área local que está utilizando todo el ancho de banda disponible por lo tanto hacer que las cosas parecen más lentos para usted. Una vez más esto es sólo especulación, podría muy bien ser su anfitrión también. Una buena manera de comprobarlo, intente visitar algunos otros sitios web cuando su sitio aparece lenta y ver si la totalidad de Internet es lenta para ti, o simplemente su sitio web. Si es sólo su sitio web, entonces es muy probable que su proveedor de alojamiento web, o algo malo en su sitio web.
Normalmente los servidores web recibe más ocupados durante el día, pero si su sitio web no recibe una gran cantidad de tráfico, eso no significa que alguien más en su servidor no es que se bogging las cosas. Es realmente difícil de adivinar sin conseguir en su servidor y el diagnóstico de lo que está pasando, no puede haber numerosas razones que causan esto.
En cuanto a que sea la conexión local, que siempre es posible también. Digamos por ejemplo que haya una conexión de cable, es posible que durante el día en que unas pocas personas en su área local que está utilizando todo el ancho de banda disponible por lo tanto hacer que las cosas parecen más lentos para usted. Una vez más esto es sólo especulación, podría muy bien ser su anfitrión también. Una buena manera de comprobarlo, intente visitar algunos otros sitios web cuando su sitio aparece lenta y ver si la totalidad de Internet es lenta para ti, o simplemente su sitio web. Si es sólo su sitio web, entonces es muy probable que su proveedor de alojamiento web, o algo malo en su sitio web.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- johnlynches
- Novice


- Registrado: Dic 20, 2010
- Mensajes: 15
- Status: Offline
Mi sitio no obtiene más de 20 visitantes al día en este momento, por lo que debe ser la carga del servidor durante el día jugando conmigo.
Voy a ver si puedo crear páginas HTML estáticas con mi base de datos que pueden acelerar las cosas para mí. Sólo tengo demasiadas consultas corriendo por página.
Voy a ver si puedo crear páginas HTML estáticas con mi base de datos que pueden acelerar las cosas para mí. Sólo tengo demasiadas consultas corriendo por página.
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Online
Tener demasiadas consultas corriendo por página realmente podría frenar una carga de la página hacia abajo. Muchas veces con sólo volver a hacer las consultas SQL y tratando de hacer las cosas más eficiente puede reducir el número está ejecutando por página. Por ejemplo, hace mucho tiempo Ozzu tenía alrededor de 30 llamadas SQL por página, y por hacer de nuevo todo y ser más inteligentes sobre cómo cada consulta se llamaba Recuerdo que fue capaz de bajar a alrededor del 10 por página, y todos de la misma la información fue recuperado todavía.
Puntos a tener en cuenta son los lazos que llamar a la misma pregunta una y otra vez. Así, por ejemplo, si había una serie de 10 valores de los que querían obtener resultados a través de SQL para cada valor, podría ejecutar un bucle y ejecutar 10 instrucciones SQL por separado, o puede ejecutar una sentencia SQL y la búsqueda de todos los identificadores dentro de esa declaración y los mismos resultados. Por lo general, la segunda forma es mucho más eficiente.
Puntos a tener en cuenta son los lazos que llamar a la misma pregunta una y otra vez. Así, por ejemplo, si había una serie de 10 valores de los que querían obtener resultados a través de SQL para cada valor, podría ejecutar un bucle y ejecutar 10 instrucciones SQL por separado, o puede ejecutar una sentencia SQL y la búsqueda de todos los identificadores dentro de esa declaración y los mismos resultados. Por lo general, la segunda forma es mucho más eficiente.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- johnlynches
- Novice


- Registrado: Dic 20, 2010
- Mensajes: 15
- Status: Offline
Creo que eso es exactamente mi problema, mi programadores me dijo que mi sitio tiene hasta un par de cientos de preguntas por página. No sé si es posible para mí "un circuito" mi base de datos para acortar la consulta, ni siquiera por dónde empezar.
He hecho un ejemplo de la base de datos que utilizo para mi carrito de la compra en mi ftp:
www_coinsupplyzone_com / database_example.sql
Si uno de ustedes puede mirarlo y decirme si es posible "condensar" que estaría muy agradecida. Entonces puedo mirar en él en más detalles sobre la forma de acortar ojalá algunas de estas consultas.
He hecho un ejemplo de la base de datos que utilizo para mi carrito de la compra en mi ftp:
www_coinsupplyzone_com / database_example.sql
Si uno de ustedes puede mirarlo y decirme si es posible "condensar" que estaría muy agradecida. Entonces puedo mirar en él en más detalles sobre la forma de acortar ojalá algunas de estas consultas.
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Online
Parte del problema podría ser la estructura de su base de datos, así que gracias por publicar esto. Sin embargo, por lo general el problema de la cantidad de consultas SQL se ejecuta no se debe a su base de datos en sí, sino cómo son las consultas de crear en el código de programación para acceder y recuperar los resultados de su base de datos. ¿Tiene un ejemplo de una parte del código que se ejecuta una de sus páginas lento que incluye algunas consultas SQL?
Ozzu Hosting - Want your website on a fast server like Ozzu?
- johnlynches
- Novice


- Registrado: Dic 20, 2010
- Mensajes: 15
- Status: Offline
Aquí hay dos fragmentos de código de mi sitio. El primero es para llamar a la descripción de la categoría y el otro es para llamar a la lista de categorías:
Por favor, hágamelo saber si esto no es lo que se refiere. Gracias.
Código: [ Select ]
<?php
$desc_image = get_setting_value($vars, "category_description_image", 3);
$desc_type = get_setting_value($vars, "category_description_type", 2);
$sql = " SELECT * ";
$sql .= " FROM " . $table_prefix . "categories ";
$sql .= " WHERE category_id = " . $db->tosql($category_id, INTEGER);
$db->query($sql);
if ($db->next_record())
{
$category_name = get_translation($db->f("category_name"));
$description = "";
if ($desc_type == 2) {
$description = get_translation($db->f("full_description"));
} elseif ($desc_type == "full_description_2" || $desc_type == "full_description2") {
$description = get_translation($db->f("full_description_2"));
} elseif ($desc_type == 1) {
$description = get_translation($db->f("short_description"));
} elseif ($desc_type == "feature_1" || $desc_type == "feature1") {
$description = get_translation($db->f("feature_1"));
} elseif ($desc_type == "feature_2" || $desc_type == "feature2") {
$description = get_translation($db->f("feature_2"));
} elseif ($desc_type == "feature_3" || $desc_type == "feature3") {
$description = get_translation($db->f("feature_3"));
} elseif ($desc_type == "feature_4" || $desc_type == "feature4") {
$description = get_translation($db->f("feature_4"));
} elseif ($desc_type == "feature_5" || $desc_type == "feature5") {
$description = get_translation($db->f("feature_5"));
} elseif ($desc_type == "feature_6" || $desc_type == "feature6") {
$description = get_translation($db->f("feature_6"));
} elseif ($desc_type == "feature_7" || $desc_type == "feature7") {
$description = get_translation($db->f("feature_7"));
}
$image = ""; $image_alt = "";
if ($desc_image == 3) {
$image = $db->f("image_large");
$image_alt = get_translation($db->f("image_large_alt"));
} elseif ($desc_image == 2) {
$image = $db->f("image");
$image_alt = get_translation($db->f("image_alt"));
}
if (!strlen($image)) {
$image_exists = false;
} elseif (!image_exists($image)) {
$image_exists = false;
} else {
$image_exists = true;
}
if (strlen($description) || $image_exists)
{
$html_template = get_setting_value($block, "html_template", "block_category_description.html");
$t->set_file("block_body", $html_template);
if ($image_exists) {
if (preg_match("/^http\:\/\//", $image)) {
$image_size = "";
} else {
$image_size = @GetImageSize($image);
if (isset($restrict_categories_images) && $restrict_categories_images) { $image = "image_show.php?category_id=".$category_id."&type=large"; }
}
if (!strlen($image_alt)) { $image_alt = $category_name; }
$t->set_var("alt", htmlspecialchars($image_alt));
$t->set_var("src", htmlspecialchars($image));
if (is_array($image_size)) {
$t->set_var("width", "width=\"" . $image_size[0] . "\"");
$t->set_var("height", "height=\"" . $image_size[1] . "\"");
} else {
$t->set_var("width", "");
$t->set_var("height", "");
}
$t->sparse("image_large_block", false);
} else {
$t->set_var("image_large_block", "");
}
$t->set_var("category_name", $category_name);
$t->set_var("full_description", $description);
$block_parsed = true;
$t->parse("block_body", false);
}
}
?>
$desc_image = get_setting_value($vars, "category_description_image", 3);
$desc_type = get_setting_value($vars, "category_description_type", 2);
$sql = " SELECT * ";
$sql .= " FROM " . $table_prefix . "categories ";
$sql .= " WHERE category_id = " . $db->tosql($category_id, INTEGER);
$db->query($sql);
if ($db->next_record())
{
$category_name = get_translation($db->f("category_name"));
$description = "";
if ($desc_type == 2) {
$description = get_translation($db->f("full_description"));
} elseif ($desc_type == "full_description_2" || $desc_type == "full_description2") {
$description = get_translation($db->f("full_description_2"));
} elseif ($desc_type == 1) {
$description = get_translation($db->f("short_description"));
} elseif ($desc_type == "feature_1" || $desc_type == "feature1") {
$description = get_translation($db->f("feature_1"));
} elseif ($desc_type == "feature_2" || $desc_type == "feature2") {
$description = get_translation($db->f("feature_2"));
} elseif ($desc_type == "feature_3" || $desc_type == "feature3") {
$description = get_translation($db->f("feature_3"));
} elseif ($desc_type == "feature_4" || $desc_type == "feature4") {
$description = get_translation($db->f("feature_4"));
} elseif ($desc_type == "feature_5" || $desc_type == "feature5") {
$description = get_translation($db->f("feature_5"));
} elseif ($desc_type == "feature_6" || $desc_type == "feature6") {
$description = get_translation($db->f("feature_6"));
} elseif ($desc_type == "feature_7" || $desc_type == "feature7") {
$description = get_translation($db->f("feature_7"));
}
$image = ""; $image_alt = "";
if ($desc_image == 3) {
$image = $db->f("image_large");
$image_alt = get_translation($db->f("image_large_alt"));
} elseif ($desc_image == 2) {
$image = $db->f("image");
$image_alt = get_translation($db->f("image_alt"));
}
if (!strlen($image)) {
$image_exists = false;
} elseif (!image_exists($image)) {
$image_exists = false;
} else {
$image_exists = true;
}
if (strlen($description) || $image_exists)
{
$html_template = get_setting_value($block, "html_template", "block_category_description.html");
$t->set_file("block_body", $html_template);
if ($image_exists) {
if (preg_match("/^http\:\/\//", $image)) {
$image_size = "";
} else {
$image_size = @GetImageSize($image);
if (isset($restrict_categories_images) && $restrict_categories_images) { $image = "image_show.php?category_id=".$category_id."&type=large"; }
}
if (!strlen($image_alt)) { $image_alt = $category_name; }
$t->set_var("alt", htmlspecialchars($image_alt));
$t->set_var("src", htmlspecialchars($image));
if (is_array($image_size)) {
$t->set_var("width", "width=\"" . $image_size[0] . "\"");
$t->set_var("height", "height=\"" . $image_size[1] . "\"");
} else {
$t->set_var("width", "");
$t->set_var("height", "");
}
$t->sparse("image_large_block", false);
} else {
$t->set_var("image_large_block", "");
}
$t->set_var("category_name", $category_name);
$t->set_var("full_description", $description);
$block_parsed = true;
$t->parse("block_body", false);
}
}
?>
- <?php
- $desc_image = get_setting_value($vars, "category_description_image", 3);
- $desc_type = get_setting_value($vars, "category_description_type", 2);
- $sql = " SELECT * ";
- $sql .= " FROM " . $table_prefix . "categories ";
- $sql .= " WHERE category_id = " . $db->tosql($category_id, INTEGER);
- $db->query($sql);
- if ($db->next_record())
- {
- $category_name = get_translation($db->f("category_name"));
- $description = "";
- if ($desc_type == 2) {
- $description = get_translation($db->f("full_description"));
- } elseif ($desc_type == "full_description_2" || $desc_type == "full_description2") {
- $description = get_translation($db->f("full_description_2"));
- } elseif ($desc_type == 1) {
- $description = get_translation($db->f("short_description"));
- } elseif ($desc_type == "feature_1" || $desc_type == "feature1") {
- $description = get_translation($db->f("feature_1"));
- } elseif ($desc_type == "feature_2" || $desc_type == "feature2") {
- $description = get_translation($db->f("feature_2"));
- } elseif ($desc_type == "feature_3" || $desc_type == "feature3") {
- $description = get_translation($db->f("feature_3"));
- } elseif ($desc_type == "feature_4" || $desc_type == "feature4") {
- $description = get_translation($db->f("feature_4"));
- } elseif ($desc_type == "feature_5" || $desc_type == "feature5") {
- $description = get_translation($db->f("feature_5"));
- } elseif ($desc_type == "feature_6" || $desc_type == "feature6") {
- $description = get_translation($db->f("feature_6"));
- } elseif ($desc_type == "feature_7" || $desc_type == "feature7") {
- $description = get_translation($db->f("feature_7"));
- }
- $image = ""; $image_alt = "";
- if ($desc_image == 3) {
- $image = $db->f("image_large");
- $image_alt = get_translation($db->f("image_large_alt"));
- } elseif ($desc_image == 2) {
- $image = $db->f("image");
- $image_alt = get_translation($db->f("image_alt"));
- }
- if (!strlen($image)) {
- $image_exists = false;
- } elseif (!image_exists($image)) {
- $image_exists = false;
- } else {
- $image_exists = true;
- }
- if (strlen($description) || $image_exists)
- {
- $html_template = get_setting_value($block, "html_template", "block_category_description.html");
- $t->set_file("block_body", $html_template);
- if ($image_exists) {
- if (preg_match("/^http\:\/\//", $image)) {
- $image_size = "";
- } else {
- $image_size = @GetImageSize($image);
- if (isset($restrict_categories_images) && $restrict_categories_images) { $image = "image_show.php?category_id=".$category_id."&type=large"; }
- }
- if (!strlen($image_alt)) { $image_alt = $category_name; }
- $t->set_var("alt", htmlspecialchars($image_alt));
- $t->set_var("src", htmlspecialchars($image));
- if (is_array($image_size)) {
- $t->set_var("width", "width=\"" . $image_size[0] . "\"");
- $t->set_var("height", "height=\"" . $image_size[1] . "\"");
- } else {
- $t->set_var("width", "");
- $t->set_var("height", "");
- }
- $t->sparse("image_large_block", false);
- } else {
- $t->set_var("image_large_block", "");
- }
- $t->set_var("category_name", $category_name);
- $t->set_var("full_description", $description);
- $block_parsed = true;
- $t->parse("block_body", false);
- }
- }
- ?>
Código: [ Select ]
<?php
include_once("./includes/products_functions.php");
include_once("./messages/" . $language_code . "/cart_messages.php");
include_once("./messages/" . $language_code . "/reviews_messages.php");
include_once("./messages/" . $language_code . "/download_messages.php");
$user_id = get_session("session_user_id");
$user_info = get_session("session_user_info");
$user_type_id = get_setting_value($user_info, "user_type_id", "");
$friendly_urls = get_setting_value($settings, "friendly_urls", 0);
$friendly_extension = get_setting_value($settings, "friendly_extension", "");
$columns = get_setting_value($vars, "categories_columns", 1);
$categories_type = get_setting_value($vars, "categories_type");
$category_id = get_param("category_id");
$search_category_id = get_param("search_category_id");
$search_string = get_param("search_string");
$is_search = strlen($search_string);
if ($is_search && $search_category_id) { $category_id = $search_category_id; }
$item_id = get_param("item_id");
if (!strlen($category_id)) {
if (strlen($item_id)) {
$category_id = get_db_value("SELECT category_id FROM " . $table_prefix . "items_categories where item_id=".$db->tosql($item_id, INTEGER));
} else {
$category_id = "0";
}
}
$category_id = intval($category_id);
$t->set_var("products_href", get_custom_friendly_url("products.php"));
$t->set_var("list_href", get_custom_friendly_url("products.php"));
$t->set_var("details_href", get_custom_friendly_url("product_details.php"));
$t->set_var("top_category_name",PRODUCTS_TITLE);
$t->set_var("category_rss", "");
$list_page = get_custom_friendly_url("products.php");
$list_url = new VA_URL($list_page);
$categories_image = get_setting_value($vars, "categories_image");
if ($categories_type == 1 || $categories_type == 2) {
if (file_exists("images/".$settings["style_name"]."/category_image.gif")) {
$image_tree_top = "images/".$settings["style_name"]."/category_image.gif";
} else {
$image_tree_top = "images/category_image.gif";
}
$html_template = get_setting_value($block, "html_template", "block_categories_catalog.html");
$t->set_file("block_body", $html_template);
$t->set_var("catalog_sub", "");
$t->set_var("catalog_sub_more", "");
$t->set_var("catalog_rows", "");
$t->set_var("catalog_top", "");
$t->set_var("catalog_description", "");
$categories_ids = VA_Categories::find_all_ids("c.parent_category_id=" . $db->tosql($category_id, INTEGER), VIEW_CATEGORIES_PERM);
if (!$categories_ids) return;
$allowed_categories_ids = VA_Categories::find_all_ids("c.parent_category_id=" . $db->tosql($category_id, INTEGER), VIEW_CATEGORIES_ITEMS_PERM);
if ($categories_type == 2) {
$sub_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")", VIEW_CATEGORIES_PERM);
if (!$sub_categories_ids)
$categories_type = 1;
}
if ($categories_type == 1) {
$sql = " SELECT category_id AS top_category_id, category_name AS top_category_name, a_title AS top_a_title, ";
$sql .= " short_description, friendly_url AS top_friendly_url, ";
$sql .= " image, image_alt, image_large, image_large_alt ";
$sql .= " FROM " . $table_prefix . "categories ";
$sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")";
$sql .= " ORDER BY category_order, category_name ";
} else {
// show categories as catalog
$allowed_sub_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")", VIEW_CATEGORIES_ITEMS_PERM);
$sql = " SELECT c.category_id AS top_category_id,c.category_name AS top_category_name, ";
$sql .= " c.friendly_url AS top_friendly_url, c.a_title AS top_a_title, ";
$sql .= " c.image, c.image_alt, c.image_large, c.image_large_alt, ";
$sql .= " s.category_id AS sub_category_id,s.category_name AS sub_category_name, ";
$sql .= " s.friendly_url AS sub_friendly_url, s.a_title AS sub_a_title ";
$sql .= " FROM (" . $table_prefix . "categories c ";
$sql .= " LEFT JOIN " . $table_prefix . "categories s ";
if ($sub_categories_ids) {
$sql .= " ON (c.category_id=s.parent_category_id ";
$sql .= " AND s.category_id IN (" . $db->tosql($sub_categories_ids, INTEGERS_LIST) . ")))";
} else {
$sql .= " ON c.category_id=s.parent_category_id) ";
}
$sql .= " WHERE c.category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")";
$sql .= " ORDER BY c.category_order, c.category_name, c.category_id, s.category_order, s.category_name ";
}
$db->query($sql);
if ($db->next_record()) {
$category_number = 0;
$is_subcategories = true;
$shown_sub_categories = get_setting_value($vars, "categories_subs");
$catalog_top_number = 0;
$catalog_sub_number = 0;
$column_width = intval(100 / $columns);
$t->set_var("column_width", $column_width . "%");
do {
$category_number++;
$catalog_sub_number++;
$top_category_id = $db->f("top_category_id");
$top_category_name = get_translation($db->f("top_category_name"));
$top_a_title = get_translation($db->f("top_a_title"));
$top_friendly_url = $db->f("top_friendly_url");
$sub_category_id = $db->f("sub_category_id");
$sub_category_name = get_translation($db->f("sub_category_name"));
$sub_a_title = get_translation($db->f("sub_a_title"));
$sub_friendly_url = $db->f("sub_friendly_url");
if ($categories_image == 2) {
$category_image = $db->f("image");
$image_alt = get_translation($db->f("image_alt"));
} else if ($categories_image == 3) {
$category_image = $db->f("image_large");
$image_alt = get_translation($db->f("image_large_alt"));
} else {
$category_image = $image_tree_top;
$image_alt = get_translation($db->f("image_alt"));
}
$t->set_var("catalog_top_id", $top_category_id);
$t->set_var("catalog_top_name", htmlspecialchars($top_category_name));
$t->set_var("top_a_title", htmlspecialchars($top_a_title));
if ($categories_type == 2){
$t->set_var("catalog_sub_id", $sub_category_id);
$t->set_var("catalog_sub_name", htmlspecialchars($sub_category_name));
$t->set_var("sub_a_title", htmlspecialchars($sub_a_title));
} else {
if (strlen($db->f("short_description"))) {
$t->set_var("short_description", get_translation($db->f("short_description")));
$t->parse("catalog_description", false);
} else {
$t->set_var("catalog_description", "");
}
}
$is_next_record = $db->next_record();
$is_new_top = ($top_category_id != $db->f("top_category_id"));
if ($categories_type == 2){
if (intval($shown_sub_categories) >= $catalog_sub_number || $shown_sub_categories == 0)
{
if ($sub_category_id && (!$allowed_sub_categories_ids || !in_array($sub_category_id, $allowed_sub_categories_ids))) {
$t->set_var("restricted_sub_class", " restrictedSubCategory");
$t->sparse("restricted_sub_image", false);
} else {
$t->set_var("restricted_sub_class", "");
$t->set_var("restricted_sub_image", "");
}
if ($friendly_urls && $sub_friendly_url) {
$list_url->remove_parameter("category_id");
$t->set_var("list_url", htmlspecialchars($list_url->get_url($sub_friendly_url. $friendly_extension)));
} else {
$list_url->add_parameter("category_id", CONSTANT, $sub_category_id);
$t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
}
if ($category_id == $sub_category_id) {
$t->set_var("class_sub_selected", "selectedsubCategory");
} else {
$t->set_var("class_sub_selected", "subCategory");
}
if ($is_next_record && !$is_new_top) {
$t->parse("catalog_sub_separator", false);
} else {
$t->set_var("catalog_sub_separator", "");
}
$t->parse("catalog_sub", true);
} elseif (($shown_sub_categories + 1) == $catalog_sub_number) {
if ($friendly_urls && $top_friendly_url) {
$list_url->remove_parameter("category_id");
$t->set_var("list_url", htmlspecialchars($list_url->get_url($top_friendly_url . $friendly_extension)));
} else {
$list_url->add_parameter("category_id", CONSTANT, $top_category_id);
$t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
}
$t->parse("catalog_sub_more", false);
}
}
if ($is_new_top) {
$catalog_top_number++;
if ($friendly_urls && $top_friendly_url) {
$list_url->remove_parameter("category_id");
$t->set_var("list_url", htmlspecialchars($list_url->get_url($top_friendly_url . $friendly_extension)));
} else {
$list_url->add_parameter("category_id", CONSTANT, $top_category_id);
$t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
}
if ($category_image)
{
if (preg_match("/^http\:\/\//", $category_image)) {
$image_size = "";
} else {
$image_size = @GetImageSize($category_image);
if (isset($restrict_categories_images) && $restrict_categories_images) {
$category_image = "image_show.php?category_id=".$top_category_id;
}
}
if (!strlen($image_alt)) { $image_alt = $top_category_name; }
$t->set_var("alt", htmlspecialchars($image_alt));
$t->set_var("src", htmlspecialchars($category_image));
if (is_array($image_size)) {
$t->set_var("width", "width=\"" . $image_size[0] . "\"");
$t->set_var("height", "height=\"" . $image_size[1] . "\"");
} else {
$t->set_var("width", "");
$t->set_var("height", "");
}
$t->parse("catalog_image", false);
} else {
$t->set_var("catalog_image", "");
}
if (!$allowed_categories_ids || !in_array($top_category_id, $allowed_categories_ids)) {
$t->set_var("restricted_class", " restrictedCategory");
$t->sparse("restricted_image", false);
} else {
$t->set_var("restricted_class", "");
$t->set_var("restricted_image", "");
}
if ($category_id == $top_category_id) {
$t->set_var("class_top_selected", "selectedtopCategory");
} else {
$t->set_var("class_top_selected", "topCategory");
}
$t->parse("catalog_top");
$t->set_var("catalog_sub", "");
$t->set_var("catalog_sub_more", "");
if ($catalog_top_number % $columns == 0) {
$t->parse("catalog_rows");
$t->set_var("catalog_top", "");
}
$catalog_sub_number = 0;
}
} while ($is_next_record);
if ($catalog_top_number % $columns != 0) {
$t->parse("catalog_rows");
}
$block_parsed = true;
$t->parse("block_body", false);
}
} else if ($categories_type == 5) {
// chained list type
$is_ajax = get_param("is_ajax");
$level = get_param("level");
$pcategory = get_param("pcategory");
if (!$pcategory) { $pcategory = 0; }
$categories = array();
$sql = " SELECT category_id, category_name FROM " . $table_prefix . "categories ";
$sql .= " WHERE parent_category_id=" . $db->tosql($pcategory, INTEGER);
$sql .= " ORDER BY category_order ";
$db->query($sql);
if ($db->next_record()) {
do {
$category_id = $db->f("category_id");
$categories[$category_id] = get_translation($db->f("category_name"));
} while ($db->next_record());
}
if ($is_ajax) {
// json_encode for PHP4
if (sizeof($categories) > 0) {
echo "{";
foreach($categories as $category_id => $category_name) {
echo '"' . $category_id . '":';
echo '"' . str_replace('"', '\"', $category_name) . '",';
}
echo "}";
}
exit;
} else {
$html_template = get_setting_value($block, "html_template", "block_categories_chained_menu.html");
$t->set_file("block_body", $html_template);
$t->set_var("products_href", get_custom_friendly_url("products.php"));
foreach($categories as $category_id => $category_name) {
$t->set_var("category_id", $category_id);
$t->set_var("category_name", htmlspecialchars($category_name));
$t->parse("category_option");
}
$block_parsed = true;
$t->parse("block_body", false);
}
} else {// list type
$html_template = get_setting_value($block, "html_template", "block_categories_list.html");
$t->set_file("block_body", $html_template);
$t->set_var("categories_rows", "");
$t->set_var("categories", "");
$active_category_path = "0";
$not = false;
if ($categories_type == 4) { // Tree-type structure
$sql = " SELECT category_path ";
$sql .= " FROM " . $table_prefix . "categories ";
$sql .= " WHERE category_id=" . $db->tosql($category_id, INTEGER);
$db->query($sql);
if ($db->next_record()) {
$active_category_path = $db->f("category_path");
$active_category_path .= $category_id;
}
$categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($active_category_path, INTEGERS_LIST) . ")", VIEW_CATEGORIES_PERM);
$allowed_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($active_category_path, INTEGERS_LIST) . ")", VIEW_CATEGORIES_ITEMS_PERM);
} else {
$not = true;
$categories_ids = VA_Categories::find_all_ids(array('not' => 1), VIEW_CATEGORIES_PERM);
$allowed_categories_ids = VA_Categories::find_all_ids(array('not' => 1), VIEW_CATEGORIES_ITEMS_PERM);
}
if (!$not && !$categories_ids) return;
$categories = array();
$sql = " SELECT category_id, category_name, a_title, friendly_url, ";
$sql .= " short_description, image, image_alt, image_large, image_large_alt, parent_category_id ";
$sql .= " FROM " . $table_prefix . "categories ";
if ($not) {
if ($categories_ids) {
$sql .= " WHERE category_id NOT IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") ";
}
$sql .= " ORDER BY parent_category_id, category_order, category_name ";
$db->RecordsPerPage = 1000;
} else {
$sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") ";
$sql .= " ORDER BY category_order, category_name ";
}
$db->query($sql);
while ($db->next_record()) {
$cur_category_id = $db->f("category_id");
$category_name = get_translation($db->f("category_name"));
$a_title = get_translation($db->f("a_title"));
$friendly_url = $db->f("friendly_url");
$short_description = get_translation($db->f("short_description"));
$image = $db->f("image");
$image_alt = get_translation($db->f("image_alt"));
$parent_category_id = $db->f("parent_category_id");
$categories[$cur_category_id]["parent_id"] = $parent_category_id;
$categories[$cur_category_id]["category_name"] = $category_name;
$categories[$cur_category_id]["a_title"] = $a_title;
$categories[$cur_category_id]["friendly_url"] = $friendly_url;
$categories[$cur_category_id]["short_description"] = $short_description;
$categories[$cur_category_id]["image"] = $image;
$categories[$cur_category_id]["image_alt"] = $image_alt;
$categories[$cur_category_id]["image_large"] = $db->f("image_large");
$categories[$cur_category_id]["image_large_alt"] = get_translation($db->f("image_large_alt"));
if ($not) {
if ($allowed_categories_ids && in_array($cur_category_id, $allowed_categories_ids)) {
$categories[$cur_category_id]["allowed"] = false;
} else {
$categories[$cur_category_id]["allowed"] = true;
}
} else {
if (!$allowed_categories_ids || !in_array($cur_category_id, $allowed_categories_ids)) {
$categories[$cur_category_id]["allowed"] = false;
} else {
$categories[$cur_category_id]["allowed"] = true;
}
}
$categories[$parent_category_id]["subs"][] = $cur_category_id;
}
if (sizeof($categories) > 0 && isset($categories[0]))
{
$category_number = 0;
$column_width = intval(100 / $columns);
$t->set_var("column_width", $column_width . "%");
set_categories(0, 0, $columns, 0, $categories_image);
if ($category_number % $columns != 0) {
$t->parse("categories_rows");
}
$block_parsed = true;
$t->parse("block_body", false);
}
}
?>
include_once("./includes/products_functions.php");
include_once("./messages/" . $language_code . "/cart_messages.php");
include_once("./messages/" . $language_code . "/reviews_messages.php");
include_once("./messages/" . $language_code . "/download_messages.php");
$user_id = get_session("session_user_id");
$user_info = get_session("session_user_info");
$user_type_id = get_setting_value($user_info, "user_type_id", "");
$friendly_urls = get_setting_value($settings, "friendly_urls", 0);
$friendly_extension = get_setting_value($settings, "friendly_extension", "");
$columns = get_setting_value($vars, "categories_columns", 1);
$categories_type = get_setting_value($vars, "categories_type");
$category_id = get_param("category_id");
$search_category_id = get_param("search_category_id");
$search_string = get_param("search_string");
$is_search = strlen($search_string);
if ($is_search && $search_category_id) { $category_id = $search_category_id; }
$item_id = get_param("item_id");
if (!strlen($category_id)) {
if (strlen($item_id)) {
$category_id = get_db_value("SELECT category_id FROM " . $table_prefix . "items_categories where item_id=".$db->tosql($item_id, INTEGER));
} else {
$category_id = "0";
}
}
$category_id = intval($category_id);
$t->set_var("products_href", get_custom_friendly_url("products.php"));
$t->set_var("list_href", get_custom_friendly_url("products.php"));
$t->set_var("details_href", get_custom_friendly_url("product_details.php"));
$t->set_var("top_category_name",PRODUCTS_TITLE);
$t->set_var("category_rss", "");
$list_page = get_custom_friendly_url("products.php");
$list_url = new VA_URL($list_page);
$categories_image = get_setting_value($vars, "categories_image");
if ($categories_type == 1 || $categories_type == 2) {
if (file_exists("images/".$settings["style_name"]."/category_image.gif")) {
$image_tree_top = "images/".$settings["style_name"]."/category_image.gif";
} else {
$image_tree_top = "images/category_image.gif";
}
$html_template = get_setting_value($block, "html_template", "block_categories_catalog.html");
$t->set_file("block_body", $html_template);
$t->set_var("catalog_sub", "");
$t->set_var("catalog_sub_more", "");
$t->set_var("catalog_rows", "");
$t->set_var("catalog_top", "");
$t->set_var("catalog_description", "");
$categories_ids = VA_Categories::find_all_ids("c.parent_category_id=" . $db->tosql($category_id, INTEGER), VIEW_CATEGORIES_PERM);
if (!$categories_ids) return;
$allowed_categories_ids = VA_Categories::find_all_ids("c.parent_category_id=" . $db->tosql($category_id, INTEGER), VIEW_CATEGORIES_ITEMS_PERM);
if ($categories_type == 2) {
$sub_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")", VIEW_CATEGORIES_PERM);
if (!$sub_categories_ids)
$categories_type = 1;
}
if ($categories_type == 1) {
$sql = " SELECT category_id AS top_category_id, category_name AS top_category_name, a_title AS top_a_title, ";
$sql .= " short_description, friendly_url AS top_friendly_url, ";
$sql .= " image, image_alt, image_large, image_large_alt ";
$sql .= " FROM " . $table_prefix . "categories ";
$sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")";
$sql .= " ORDER BY category_order, category_name ";
} else {
// show categories as catalog
$allowed_sub_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")", VIEW_CATEGORIES_ITEMS_PERM);
$sql = " SELECT c.category_id AS top_category_id,c.category_name AS top_category_name, ";
$sql .= " c.friendly_url AS top_friendly_url, c.a_title AS top_a_title, ";
$sql .= " c.image, c.image_alt, c.image_large, c.image_large_alt, ";
$sql .= " s.category_id AS sub_category_id,s.category_name AS sub_category_name, ";
$sql .= " s.friendly_url AS sub_friendly_url, s.a_title AS sub_a_title ";
$sql .= " FROM (" . $table_prefix . "categories c ";
$sql .= " LEFT JOIN " . $table_prefix . "categories s ";
if ($sub_categories_ids) {
$sql .= " ON (c.category_id=s.parent_category_id ";
$sql .= " AND s.category_id IN (" . $db->tosql($sub_categories_ids, INTEGERS_LIST) . ")))";
} else {
$sql .= " ON c.category_id=s.parent_category_id) ";
}
$sql .= " WHERE c.category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")";
$sql .= " ORDER BY c.category_order, c.category_name, c.category_id, s.category_order, s.category_name ";
}
$db->query($sql);
if ($db->next_record()) {
$category_number = 0;
$is_subcategories = true;
$shown_sub_categories = get_setting_value($vars, "categories_subs");
$catalog_top_number = 0;
$catalog_sub_number = 0;
$column_width = intval(100 / $columns);
$t->set_var("column_width", $column_width . "%");
do {
$category_number++;
$catalog_sub_number++;
$top_category_id = $db->f("top_category_id");
$top_category_name = get_translation($db->f("top_category_name"));
$top_a_title = get_translation($db->f("top_a_title"));
$top_friendly_url = $db->f("top_friendly_url");
$sub_category_id = $db->f("sub_category_id");
$sub_category_name = get_translation($db->f("sub_category_name"));
$sub_a_title = get_translation($db->f("sub_a_title"));
$sub_friendly_url = $db->f("sub_friendly_url");
if ($categories_image == 2) {
$category_image = $db->f("image");
$image_alt = get_translation($db->f("image_alt"));
} else if ($categories_image == 3) {
$category_image = $db->f("image_large");
$image_alt = get_translation($db->f("image_large_alt"));
} else {
$category_image = $image_tree_top;
$image_alt = get_translation($db->f("image_alt"));
}
$t->set_var("catalog_top_id", $top_category_id);
$t->set_var("catalog_top_name", htmlspecialchars($top_category_name));
$t->set_var("top_a_title", htmlspecialchars($top_a_title));
if ($categories_type == 2){
$t->set_var("catalog_sub_id", $sub_category_id);
$t->set_var("catalog_sub_name", htmlspecialchars($sub_category_name));
$t->set_var("sub_a_title", htmlspecialchars($sub_a_title));
} else {
if (strlen($db->f("short_description"))) {
$t->set_var("short_description", get_translation($db->f("short_description")));
$t->parse("catalog_description", false);
} else {
$t->set_var("catalog_description", "");
}
}
$is_next_record = $db->next_record();
$is_new_top = ($top_category_id != $db->f("top_category_id"));
if ($categories_type == 2){
if (intval($shown_sub_categories) >= $catalog_sub_number || $shown_sub_categories == 0)
{
if ($sub_category_id && (!$allowed_sub_categories_ids || !in_array($sub_category_id, $allowed_sub_categories_ids))) {
$t->set_var("restricted_sub_class", " restrictedSubCategory");
$t->sparse("restricted_sub_image", false);
} else {
$t->set_var("restricted_sub_class", "");
$t->set_var("restricted_sub_image", "");
}
if ($friendly_urls && $sub_friendly_url) {
$list_url->remove_parameter("category_id");
$t->set_var("list_url", htmlspecialchars($list_url->get_url($sub_friendly_url. $friendly_extension)));
} else {
$list_url->add_parameter("category_id", CONSTANT, $sub_category_id);
$t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
}
if ($category_id == $sub_category_id) {
$t->set_var("class_sub_selected", "selectedsubCategory");
} else {
$t->set_var("class_sub_selected", "subCategory");
}
if ($is_next_record && !$is_new_top) {
$t->parse("catalog_sub_separator", false);
} else {
$t->set_var("catalog_sub_separator", "");
}
$t->parse("catalog_sub", true);
} elseif (($shown_sub_categories + 1) == $catalog_sub_number) {
if ($friendly_urls && $top_friendly_url) {
$list_url->remove_parameter("category_id");
$t->set_var("list_url", htmlspecialchars($list_url->get_url($top_friendly_url . $friendly_extension)));
} else {
$list_url->add_parameter("category_id", CONSTANT, $top_category_id);
$t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
}
$t->parse("catalog_sub_more", false);
}
}
if ($is_new_top) {
$catalog_top_number++;
if ($friendly_urls && $top_friendly_url) {
$list_url->remove_parameter("category_id");
$t->set_var("list_url", htmlspecialchars($list_url->get_url($top_friendly_url . $friendly_extension)));
} else {
$list_url->add_parameter("category_id", CONSTANT, $top_category_id);
$t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
}
if ($category_image)
{
if (preg_match("/^http\:\/\//", $category_image)) {
$image_size = "";
} else {
$image_size = @GetImageSize($category_image);
if (isset($restrict_categories_images) && $restrict_categories_images) {
$category_image = "image_show.php?category_id=".$top_category_id;
}
}
if (!strlen($image_alt)) { $image_alt = $top_category_name; }
$t->set_var("alt", htmlspecialchars($image_alt));
$t->set_var("src", htmlspecialchars($category_image));
if (is_array($image_size)) {
$t->set_var("width", "width=\"" . $image_size[0] . "\"");
$t->set_var("height", "height=\"" . $image_size[1] . "\"");
} else {
$t->set_var("width", "");
$t->set_var("height", "");
}
$t->parse("catalog_image", false);
} else {
$t->set_var("catalog_image", "");
}
if (!$allowed_categories_ids || !in_array($top_category_id, $allowed_categories_ids)) {
$t->set_var("restricted_class", " restrictedCategory");
$t->sparse("restricted_image", false);
} else {
$t->set_var("restricted_class", "");
$t->set_var("restricted_image", "");
}
if ($category_id == $top_category_id) {
$t->set_var("class_top_selected", "selectedtopCategory");
} else {
$t->set_var("class_top_selected", "topCategory");
}
$t->parse("catalog_top");
$t->set_var("catalog_sub", "");
$t->set_var("catalog_sub_more", "");
if ($catalog_top_number % $columns == 0) {
$t->parse("catalog_rows");
$t->set_var("catalog_top", "");
}
$catalog_sub_number = 0;
}
} while ($is_next_record);
if ($catalog_top_number % $columns != 0) {
$t->parse("catalog_rows");
}
$block_parsed = true;
$t->parse("block_body", false);
}
} else if ($categories_type == 5) {
// chained list type
$is_ajax = get_param("is_ajax");
$level = get_param("level");
$pcategory = get_param("pcategory");
if (!$pcategory) { $pcategory = 0; }
$categories = array();
$sql = " SELECT category_id, category_name FROM " . $table_prefix . "categories ";
$sql .= " WHERE parent_category_id=" . $db->tosql($pcategory, INTEGER);
$sql .= " ORDER BY category_order ";
$db->query($sql);
if ($db->next_record()) {
do {
$category_id = $db->f("category_id");
$categories[$category_id] = get_translation($db->f("category_name"));
} while ($db->next_record());
}
if ($is_ajax) {
// json_encode for PHP4
if (sizeof($categories) > 0) {
echo "{";
foreach($categories as $category_id => $category_name) {
echo '"' . $category_id . '":';
echo '"' . str_replace('"', '\"', $category_name) . '",';
}
echo "}";
}
exit;
} else {
$html_template = get_setting_value($block, "html_template", "block_categories_chained_menu.html");
$t->set_file("block_body", $html_template);
$t->set_var("products_href", get_custom_friendly_url("products.php"));
foreach($categories as $category_id => $category_name) {
$t->set_var("category_id", $category_id);
$t->set_var("category_name", htmlspecialchars($category_name));
$t->parse("category_option");
}
$block_parsed = true;
$t->parse("block_body", false);
}
} else {// list type
$html_template = get_setting_value($block, "html_template", "block_categories_list.html");
$t->set_file("block_body", $html_template);
$t->set_var("categories_rows", "");
$t->set_var("categories", "");
$active_category_path = "0";
$not = false;
if ($categories_type == 4) { // Tree-type structure
$sql = " SELECT category_path ";
$sql .= " FROM " . $table_prefix . "categories ";
$sql .= " WHERE category_id=" . $db->tosql($category_id, INTEGER);
$db->query($sql);
if ($db->next_record()) {
$active_category_path = $db->f("category_path");
$active_category_path .= $category_id;
}
$categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($active_category_path, INTEGERS_LIST) . ")", VIEW_CATEGORIES_PERM);
$allowed_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($active_category_path, INTEGERS_LIST) . ")", VIEW_CATEGORIES_ITEMS_PERM);
} else {
$not = true;
$categories_ids = VA_Categories::find_all_ids(array('not' => 1), VIEW_CATEGORIES_PERM);
$allowed_categories_ids = VA_Categories::find_all_ids(array('not' => 1), VIEW_CATEGORIES_ITEMS_PERM);
}
if (!$not && !$categories_ids) return;
$categories = array();
$sql = " SELECT category_id, category_name, a_title, friendly_url, ";
$sql .= " short_description, image, image_alt, image_large, image_large_alt, parent_category_id ";
$sql .= " FROM " . $table_prefix . "categories ";
if ($not) {
if ($categories_ids) {
$sql .= " WHERE category_id NOT IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") ";
}
$sql .= " ORDER BY parent_category_id, category_order, category_name ";
$db->RecordsPerPage = 1000;
} else {
$sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") ";
$sql .= " ORDER BY category_order, category_name ";
}
$db->query($sql);
while ($db->next_record()) {
$cur_category_id = $db->f("category_id");
$category_name = get_translation($db->f("category_name"));
$a_title = get_translation($db->f("a_title"));
$friendly_url = $db->f("friendly_url");
$short_description = get_translation($db->f("short_description"));
$image = $db->f("image");
$image_alt = get_translation($db->f("image_alt"));
$parent_category_id = $db->f("parent_category_id");
$categories[$cur_category_id]["parent_id"] = $parent_category_id;
$categories[$cur_category_id]["category_name"] = $category_name;
$categories[$cur_category_id]["a_title"] = $a_title;
$categories[$cur_category_id]["friendly_url"] = $friendly_url;
$categories[$cur_category_id]["short_description"] = $short_description;
$categories[$cur_category_id]["image"] = $image;
$categories[$cur_category_id]["image_alt"] = $image_alt;
$categories[$cur_category_id]["image_large"] = $db->f("image_large");
$categories[$cur_category_id]["image_large_alt"] = get_translation($db->f("image_large_alt"));
if ($not) {
if ($allowed_categories_ids && in_array($cur_category_id, $allowed_categories_ids)) {
$categories[$cur_category_id]["allowed"] = false;
} else {
$categories[$cur_category_id]["allowed"] = true;
}
} else {
if (!$allowed_categories_ids || !in_array($cur_category_id, $allowed_categories_ids)) {
$categories[$cur_category_id]["allowed"] = false;
} else {
$categories[$cur_category_id]["allowed"] = true;
}
}
$categories[$parent_category_id]["subs"][] = $cur_category_id;
}
if (sizeof($categories) > 0 && isset($categories[0]))
{
$category_number = 0;
$column_width = intval(100 / $columns);
$t->set_var("column_width", $column_width . "%");
set_categories(0, 0, $columns, 0, $categories_image);
if ($category_number % $columns != 0) {
$t->parse("categories_rows");
}
$block_parsed = true;
$t->parse("block_body", false);
}
}
?>
- <?php
- include_once("./includes/products_functions.php");
- include_once("./messages/" . $language_code . "/cart_messages.php");
- include_once("./messages/" . $language_code . "/reviews_messages.php");
- include_once("./messages/" . $language_code . "/download_messages.php");
- $user_id = get_session("session_user_id");
- $user_info = get_session("session_user_info");
- $user_type_id = get_setting_value($user_info, "user_type_id", "");
- $friendly_urls = get_setting_value($settings, "friendly_urls", 0);
- $friendly_extension = get_setting_value($settings, "friendly_extension", "");
- $columns = get_setting_value($vars, "categories_columns", 1);
- $categories_type = get_setting_value($vars, "categories_type");
- $category_id = get_param("category_id");
- $search_category_id = get_param("search_category_id");
- $search_string = get_param("search_string");
- $is_search = strlen($search_string);
- if ($is_search && $search_category_id) { $category_id = $search_category_id; }
- $item_id = get_param("item_id");
- if (!strlen($category_id)) {
- if (strlen($item_id)) {
- $category_id = get_db_value("SELECT category_id FROM " . $table_prefix . "items_categories where item_id=".$db->tosql($item_id, INTEGER));
- } else {
- $category_id = "0";
- }
- }
- $category_id = intval($category_id);
- $t->set_var("products_href", get_custom_friendly_url("products.php"));
- $t->set_var("list_href", get_custom_friendly_url("products.php"));
- $t->set_var("details_href", get_custom_friendly_url("product_details.php"));
- $t->set_var("top_category_name",PRODUCTS_TITLE);
- $t->set_var("category_rss", "");
- $list_page = get_custom_friendly_url("products.php");
- $list_url = new VA_URL($list_page);
- $categories_image = get_setting_value($vars, "categories_image");
- if ($categories_type == 1 || $categories_type == 2) {
- if (file_exists("images/".$settings["style_name"]."/category_image.gif")) {
- $image_tree_top = "images/".$settings["style_name"]."/category_image.gif";
- } else {
- $image_tree_top = "images/category_image.gif";
- }
- $html_template = get_setting_value($block, "html_template", "block_categories_catalog.html");
- $t->set_file("block_body", $html_template);
- $t->set_var("catalog_sub", "");
- $t->set_var("catalog_sub_more", "");
- $t->set_var("catalog_rows", "");
- $t->set_var("catalog_top", "");
- $t->set_var("catalog_description", "");
- $categories_ids = VA_Categories::find_all_ids("c.parent_category_id=" . $db->tosql($category_id, INTEGER), VIEW_CATEGORIES_PERM);
- if (!$categories_ids) return;
- $allowed_categories_ids = VA_Categories::find_all_ids("c.parent_category_id=" . $db->tosql($category_id, INTEGER), VIEW_CATEGORIES_ITEMS_PERM);
- if ($categories_type == 2) {
- $sub_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")", VIEW_CATEGORIES_PERM);
- if (!$sub_categories_ids)
- $categories_type = 1;
- }
- if ($categories_type == 1) {
- $sql = " SELECT category_id AS top_category_id, category_name AS top_category_name, a_title AS top_a_title, ";
- $sql .= " short_description, friendly_url AS top_friendly_url, ";
- $sql .= " image, image_alt, image_large, image_large_alt ";
- $sql .= " FROM " . $table_prefix . "categories ";
- $sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")";
- $sql .= " ORDER BY category_order, category_name ";
- } else {
- // show categories as catalog
- $allowed_sub_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")", VIEW_CATEGORIES_ITEMS_PERM);
- $sql = " SELECT c.category_id AS top_category_id,c.category_name AS top_category_name, ";
- $sql .= " c.friendly_url AS top_friendly_url, c.a_title AS top_a_title, ";
- $sql .= " c.image, c.image_alt, c.image_large, c.image_large_alt, ";
- $sql .= " s.category_id AS sub_category_id,s.category_name AS sub_category_name, ";
- $sql .= " s.friendly_url AS sub_friendly_url, s.a_title AS sub_a_title ";
- $sql .= " FROM (" . $table_prefix . "categories c ";
- $sql .= " LEFT JOIN " . $table_prefix . "categories s ";
- if ($sub_categories_ids) {
- $sql .= " ON (c.category_id=s.parent_category_id ";
- $sql .= " AND s.category_id IN (" . $db->tosql($sub_categories_ids, INTEGERS_LIST) . ")))";
- } else {
- $sql .= " ON c.category_id=s.parent_category_id) ";
- }
- $sql .= " WHERE c.category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ")";
- $sql .= " ORDER BY c.category_order, c.category_name, c.category_id, s.category_order, s.category_name ";
- }
- $db->query($sql);
- if ($db->next_record()) {
- $category_number = 0;
- $is_subcategories = true;
- $shown_sub_categories = get_setting_value($vars, "categories_subs");
- $catalog_top_number = 0;
- $catalog_sub_number = 0;
- $column_width = intval(100 / $columns);
- $t->set_var("column_width", $column_width . "%");
- do {
- $category_number++;
- $catalog_sub_number++;
- $top_category_id = $db->f("top_category_id");
- $top_category_name = get_translation($db->f("top_category_name"));
- $top_a_title = get_translation($db->f("top_a_title"));
- $top_friendly_url = $db->f("top_friendly_url");
- $sub_category_id = $db->f("sub_category_id");
- $sub_category_name = get_translation($db->f("sub_category_name"));
- $sub_a_title = get_translation($db->f("sub_a_title"));
- $sub_friendly_url = $db->f("sub_friendly_url");
- if ($categories_image == 2) {
- $category_image = $db->f("image");
- $image_alt = get_translation($db->f("image_alt"));
- } else if ($categories_image == 3) {
- $category_image = $db->f("image_large");
- $image_alt = get_translation($db->f("image_large_alt"));
- } else {
- $category_image = $image_tree_top;
- $image_alt = get_translation($db->f("image_alt"));
- }
- $t->set_var("catalog_top_id", $top_category_id);
- $t->set_var("catalog_top_name", htmlspecialchars($top_category_name));
- $t->set_var("top_a_title", htmlspecialchars($top_a_title));
- if ($categories_type == 2){
- $t->set_var("catalog_sub_id", $sub_category_id);
- $t->set_var("catalog_sub_name", htmlspecialchars($sub_category_name));
- $t->set_var("sub_a_title", htmlspecialchars($sub_a_title));
- } else {
- if (strlen($db->f("short_description"))) {
- $t->set_var("short_description", get_translation($db->f("short_description")));
- $t->parse("catalog_description", false);
- } else {
- $t->set_var("catalog_description", "");
- }
- }
- $is_next_record = $db->next_record();
- $is_new_top = ($top_category_id != $db->f("top_category_id"));
- if ($categories_type == 2){
- if (intval($shown_sub_categories) >= $catalog_sub_number || $shown_sub_categories == 0)
- {
- if ($sub_category_id && (!$allowed_sub_categories_ids || !in_array($sub_category_id, $allowed_sub_categories_ids))) {
- $t->set_var("restricted_sub_class", " restrictedSubCategory");
- $t->sparse("restricted_sub_image", false);
- } else {
- $t->set_var("restricted_sub_class", "");
- $t->set_var("restricted_sub_image", "");
- }
- if ($friendly_urls && $sub_friendly_url) {
- $list_url->remove_parameter("category_id");
- $t->set_var("list_url", htmlspecialchars($list_url->get_url($sub_friendly_url. $friendly_extension)));
- } else {
- $list_url->add_parameter("category_id", CONSTANT, $sub_category_id);
- $t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
- }
- if ($category_id == $sub_category_id) {
- $t->set_var("class_sub_selected", "selectedsubCategory");
- } else {
- $t->set_var("class_sub_selected", "subCategory");
- }
- if ($is_next_record && !$is_new_top) {
- $t->parse("catalog_sub_separator", false);
- } else {
- $t->set_var("catalog_sub_separator", "");
- }
- $t->parse("catalog_sub", true);
- } elseif (($shown_sub_categories + 1) == $catalog_sub_number) {
- if ($friendly_urls && $top_friendly_url) {
- $list_url->remove_parameter("category_id");
- $t->set_var("list_url", htmlspecialchars($list_url->get_url($top_friendly_url . $friendly_extension)));
- } else {
- $list_url->add_parameter("category_id", CONSTANT, $top_category_id);
- $t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
- }
- $t->parse("catalog_sub_more", false);
- }
- }
- if ($is_new_top) {
- $catalog_top_number++;
- if ($friendly_urls && $top_friendly_url) {
- $list_url->remove_parameter("category_id");
- $t->set_var("list_url", htmlspecialchars($list_url->get_url($top_friendly_url . $friendly_extension)));
- } else {
- $list_url->add_parameter("category_id", CONSTANT, $top_category_id);
- $t->set_var("list_url", htmlspecialchars($list_url->get_url($list_page)));
- }
- if ($category_image)
- {
- if (preg_match("/^http\:\/\//", $category_image)) {
- $image_size = "";
- } else {
- $image_size = @GetImageSize($category_image);
- if (isset($restrict_categories_images) && $restrict_categories_images) {
- $category_image = "image_show.php?category_id=".$top_category_id;
- }
- }
- if (!strlen($image_alt)) { $image_alt = $top_category_name; }
- $t->set_var("alt", htmlspecialchars($image_alt));
- $t->set_var("src", htmlspecialchars($category_image));
- if (is_array($image_size)) {
- $t->set_var("width", "width=\"" . $image_size[0] . "\"");
- $t->set_var("height", "height=\"" . $image_size[1] . "\"");
- } else {
- $t->set_var("width", "");
- $t->set_var("height", "");
- }
- $t->parse("catalog_image", false);
- } else {
- $t->set_var("catalog_image", "");
- }
- if (!$allowed_categories_ids || !in_array($top_category_id, $allowed_categories_ids)) {
- $t->set_var("restricted_class", " restrictedCategory");
- $t->sparse("restricted_image", false);
- } else {
- $t->set_var("restricted_class", "");
- $t->set_var("restricted_image", "");
- }
- if ($category_id == $top_category_id) {
- $t->set_var("class_top_selected", "selectedtopCategory");
- } else {
- $t->set_var("class_top_selected", "topCategory");
- }
- $t->parse("catalog_top");
- $t->set_var("catalog_sub", "");
- $t->set_var("catalog_sub_more", "");
- if ($catalog_top_number % $columns == 0) {
- $t->parse("catalog_rows");
- $t->set_var("catalog_top", "");
- }
- $catalog_sub_number = 0;
- }
- } while ($is_next_record);
- if ($catalog_top_number % $columns != 0) {
- $t->parse("catalog_rows");
- }
- $block_parsed = true;
- $t->parse("block_body", false);
- }
- } else if ($categories_type == 5) {
- // chained list type
- $is_ajax = get_param("is_ajax");
- $level = get_param("level");
- $pcategory = get_param("pcategory");
- if (!$pcategory) { $pcategory = 0; }
- $categories = array();
- $sql = " SELECT category_id, category_name FROM " . $table_prefix . "categories ";
- $sql .= " WHERE parent_category_id=" . $db->tosql($pcategory, INTEGER);
- $sql .= " ORDER BY category_order ";
- $db->query($sql);
- if ($db->next_record()) {
- do {
- $category_id = $db->f("category_id");
- $categories[$category_id] = get_translation($db->f("category_name"));
- } while ($db->next_record());
- }
- if ($is_ajax) {
- // json_encode for PHP4
- if (sizeof($categories) > 0) {
- echo "{";
- foreach($categories as $category_id => $category_name) {
- echo '"' . $category_id . '":';
- echo '"' . str_replace('"', '\"', $category_name) . '",';
- }
- echo "}";
- }
- exit;
- } else {
- $html_template = get_setting_value($block, "html_template", "block_categories_chained_menu.html");
- $t->set_file("block_body", $html_template);
- $t->set_var("products_href", get_custom_friendly_url("products.php"));
- foreach($categories as $category_id => $category_name) {
- $t->set_var("category_id", $category_id);
- $t->set_var("category_name", htmlspecialchars($category_name));
- $t->parse("category_option");
- }
- $block_parsed = true;
- $t->parse("block_body", false);
- }
- } else {// list type
- $html_template = get_setting_value($block, "html_template", "block_categories_list.html");
- $t->set_file("block_body", $html_template);
- $t->set_var("categories_rows", "");
- $t->set_var("categories", "");
- $active_category_path = "0";
- $not = false;
- if ($categories_type == 4) { // Tree-type structure
- $sql = " SELECT category_path ";
- $sql .= " FROM " . $table_prefix . "categories ";
- $sql .= " WHERE category_id=" . $db->tosql($category_id, INTEGER);
- $db->query($sql);
- if ($db->next_record()) {
- $active_category_path = $db->f("category_path");
- $active_category_path .= $category_id;
- }
- $categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($active_category_path, INTEGERS_LIST) . ")", VIEW_CATEGORIES_PERM);
- $allowed_categories_ids = VA_Categories::find_all_ids("c.parent_category_id IN (" . $db->tosql($active_category_path, INTEGERS_LIST) . ")", VIEW_CATEGORIES_ITEMS_PERM);
- } else {
- $not = true;
- $categories_ids = VA_Categories::find_all_ids(array('not' => 1), VIEW_CATEGORIES_PERM);
- $allowed_categories_ids = VA_Categories::find_all_ids(array('not' => 1), VIEW_CATEGORIES_ITEMS_PERM);
- }
- if (!$not && !$categories_ids) return;
- $categories = array();
- $sql = " SELECT category_id, category_name, a_title, friendly_url, ";
- $sql .= " short_description, image, image_alt, image_large, image_large_alt, parent_category_id ";
- $sql .= " FROM " . $table_prefix . "categories ";
- if ($not) {
- if ($categories_ids) {
- $sql .= " WHERE category_id NOT IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") ";
- }
- $sql .= " ORDER BY parent_category_id, category_order, category_name ";
- $db->RecordsPerPage = 1000;
- } else {
- $sql .= " WHERE category_id IN (" . $db->tosql($categories_ids, INTEGERS_LIST) . ") ";
- $sql .= " ORDER BY category_order, category_name ";
- }
- $db->query($sql);
- while ($db->next_record()) {
- $cur_category_id = $db->f("category_id");
- $category_name = get_translation($db->f("category_name"));
- $a_title = get_translation($db->f("a_title"));
- $friendly_url = $db->f("friendly_url");
- $short_description = get_translation($db->f("short_description"));
- $image = $db->f("image");
- $image_alt = get_translation($db->f("image_alt"));
- $parent_category_id = $db->f("parent_category_id");
- $categories[$cur_category_id]["parent_id"] = $parent_category_id;
- $categories[$cur_category_id]["category_name"] = $category_name;
- $categories[$cur_category_id]["a_title"] = $a_title;
- $categories[$cur_category_id]["friendly_url"] = $friendly_url;
- $categories[$cur_category_id]["short_description"] = $short_description;
- $categories[$cur_category_id]["image"] = $image;
- $categories[$cur_category_id]["image_alt"] = $image_alt;
- $categories[$cur_category_id]["image_large"] = $db->f("image_large");
- $categories[$cur_category_id]["image_large_alt"] = get_translation($db->f("image_large_alt"));
- if ($not) {
- if ($allowed_categories_ids && in_array($cur_category_id, $allowed_categories_ids)) {
- $categories[$cur_category_id]["allowed"] = false;
- } else {
- $categories[$cur_category_id]["allowed"] = true;
- }
- } else {
- if (!$allowed_categories_ids || !in_array($cur_category_id, $allowed_categories_ids)) {
- $categories[$cur_category_id]["allowed"] = false;
- } else {
- $categories[$cur_category_id]["allowed"] = true;
- }
- }
- $categories[$parent_category_id]["subs"][] = $cur_category_id;
- }
- if (sizeof($categories) > 0 && isset($categories[0]))
- {
- $category_number = 0;
- $column_width = intval(100 / $columns);
- $t->set_var("column_width", $column_width . "%");
- set_categories(0, 0, $columns, 0, $categories_image);
- if ($category_number % $columns != 0) {
- $t->parse("categories_rows");
- }
- $block_parsed = true;
- $t->parse("block_body", false);
- }
- }
- ?>
Por favor, hágamelo saber si esto no es lo que se refiere. Gracias.
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Online
Si los dos anteriores por separado páginas PHP? o todo lo que se llamaría en una sola carga de la página?
A primera vista es difícil decir que no creo que se trata en modo alguno la creación de 200 consultas por página. Ellos no parecen estar en cualquier bucles ni nada. Es posible que algunos de ellos podían ser combinados todavía, pero otro de optimización que podría ayudar sería comprobar los índices de ellos para asegurarse de que las búsquedas son rápidas.
¿Ve usted algún código que ha consultas SQL dentro de una especie de bucle while o bucle en cualquiera de sus páginas? Pienso que en algún lugar en su página que tienen algún tipo de lazo con las consultas SQL dentro de que es realmente conseguir sus consultas SQL para saltar a la alta gama 200.
A primera vista es difícil decir que no creo que se trata en modo alguno la creación de 200 consultas por página. Ellos no parecen estar en cualquier bucles ni nada. Es posible que algunos de ellos podían ser combinados todavía, pero otro de optimización que podría ayudar sería comprobar los índices de ellos para asegurarse de que las búsquedas son rápidas.
¿Ve usted algún código que ha consultas SQL dentro de una especie de bucle while o bucle en cualquiera de sus páginas? Pienso que en algún lugar en su página que tienen algún tipo de lazo con las consultas SQL dentro de que es realmente conseguir sus consultas SQL para saltar a la alta gama 200.
Ozzu Hosting - Want your website on a fast server like Ozzu?
- johnlynches
- Novice


- Registrado: Dic 20, 2010
- Mensajes: 15
- Status: Offline
páginas Theyre no por separado, pero las piezas de una página que se carga. Cada página que tengo tiene muchos "secciones" de las que debe cargar. No veo que ninguna de bucles en las páginas, pero de nuevo no se sabe muy bien lo que es un bucle se vería como si me dio una bofetada en la cara.
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 11 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 32 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
