4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: satine88 on June 09, 2010, 11:02:43 PM

Title: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 09, 2010, 11:02:43 PM
Hello

My host (which is serious and deem France) blocked my site because:

"Your scripts consume too much CPU and overload our servers"

It categories.php which I have problems

I do not know what to do, can you help me?
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: batu544 on June 10, 2010, 02:34:54 PM
Hi,
    Do you have more details about the server load ?

1. How many categories you have ?
2. how many images, users and what is your daily page visit ?


Thanks,
batu544

Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 10, 2010, 06:00:56 PM
Hi,
    Do you have more details about the server load ?

1. How many categories you have ?
2. how many images, users and what is your daily page visit ?


Thanks,
batu544



--> http://www.fond-ecran-gratuit.biz/
1) 379 categories
2) 800 daily page visit

(categories.php consume too much CPU and overload our servers)

Is what I can alleviate categorie.php
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: budduke on June 10, 2010, 08:17:51 PM
in the includes/constants.php file...
look for..
Code: [Select]
// Debug contants
// define("PRINT_STATS", 1);
// define("PRINT_QUERIES", 1);
// define('PRINT_CACHE_MESSAGES', 1);
if you take out the // in front you can use these for troubleshooting...
The print_stats will tell you the amount of time it took to render the page
the print_queries will show you every database call that page is making while being created..

I have used these in the past to see how long my pages take to process but I am not sure if that is all CPU or other factors involved.

But they have to let you get your site back up too see the results unless you have a local server on your computer you can run them on.

Good Luck, Shared servers are hard to deal with sometimes as your site grows...
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: batu544 on June 10, 2010, 08:22:03 PM
well.. I tried to browse your website .. but its Forbidden for me..

Here couple of tips for minimizing the server load..

1. Turn OFF the random wallpaper option.
2. Enable cache for the category pages.


May be some other member can suggest some more optimization tips..

One other option is... you can move into premium hosting service..


Thanks,
batu544


Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 10, 2010, 08:50:06 PM
Code: [Select]
// define("PRINT_STATS", 1);
--> Page generated in 2.142466 seconds with 1156 queries, spending 0.835000 seconds doing MySQL queries and 1.307466 doing PHP things. GZIP compression disabled

Code: [Select]
define("PRINT_QUERIES", 1);

I did :
Code: [Select]
define('SHOW_RANDOM_IMAGE', 0);
2. Enable cache for the category pages.
Can you tell me how I can do that?

--> http://www.fond-ecran-gratuit.biz/
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: budduke on June 10, 2010, 09:07:02 PM

2. Enable cache for the category pages.
Can you tell me how I can do that?


in your global.php file
look for
Code: [Select]
// Initialize cache configuration
$cache_enable          = 0;
$cache_lifetime        = 3600; // 1 hour
$cache_path            = ROOT_PATH.'cache';
$cache_page_index      = 0;
$cache_page_categories = 1;
$cache_page_top        = 1;
$cache_page_rss        = 1;
Change $cache_enable = 1  and I always have top set to 1 because it does allot of database calls.
Hope that helps!
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 10, 2010, 10:31:17 PM
Thank you for all your advice, I'll see if I still have problems! I'll let you know

Thank you very much
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: V@no on June 11, 2010, 01:07:04 AM
Page generated in 2.142466 seconds with 1156 queries, spending 0.835000 seconds doing MySQL queries and 1.307466 doing PHP things. GZIP compression disabled
:waaa:


Let me guess, you are using "original" version of the SEO (http://www.4homepages.de/forum/index.php?topic=17598.0) mod? If you are, then try optimized (http://www.4homepages.de/forum/index.php?topic=17598.msg126772#msg126772) version (replace code from step 2 with the new code)
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 11, 2010, 01:08:36 PM
Page generated in 2.142466 seconds with 1156 queries, spending 0.835000 seconds doing MySQL queries and 1.307466 doing PHP things. GZIP compression disabled
:waaa:


Let me guess, you are using "original" version of the SEO (http://www.4homepages.de/forum/index.php?topic=17598.0) mod? If you are, then try optimized (http://www.4homepages.de/forum/index.php?topic=17598.msg126772#msg126772) version (replace code from step 2 with the new code)


I do this:
http://www.4homepages.de/forum/index.php?topic=17598.msg126756#msg126756

was it to do?

Result:

index
Quote
Page generated in 0.674547 seconds with 391 queries, spending 0.432000 seconds doing MySQL queries and 0.242547 doing PHP things. GZIP compression disabled

categorie
Quote
Page generated in 0.399420 seconds with 388 queries, spending 0.072000 seconds doing MySQL queries and 0.327420 doing PHP things. GZIP compression disabled

detail
Quote
Page generated in 0.637300 seconds with 416 queries, spending 0.201000 seconds doing MySQL queries and 0.436300 doing PHP things. GZIP compression disabled
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: V@no on June 11, 2010, 02:58:09 PM
The 391 queries now showing is with the cache on, correct? Cause if I start refreshing the page, once in a while I get over 1100 queries, then it drops back to 400. Cache certainly helps, but it doesn't fix the problem.

If you look at Nick's statistics at the SEO mod page, you'll see that with the nic_bck's code it optimized on 50%, but with my code it's 80% optimized. But I'd first suggest disable that mod at all and see if any performance gained (all you need to do is replace code from step 2 with the original code from 4images package)....perhaps it's not that mod that causes such slowdown...anyway, 1156 database queries is way too much.
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 11, 2010, 06:57:16 PM
Yes I have in global.php

Code: [Select]
// Initialize cache configuration
$cache_enable          = 1;
$cache_lifetime        = 3600; // 1 hour
$cache_path            = ROOT_PATH.'cache';
$cache_page_index      = 1;
$cache_page_categories = 1;
$cache_page_top        = 1;
$cache_page_rss        = 1;


To disable the plugins I have to go into "admin"> "setting"?
If it is, there is no other way because I have this problem:
http://nsa15.casimages.com/img/2010/06/11/100611062741840072.jpg

(Standing problem of a year, I never took the time to try to resolve it ...)

I JUST change sessions.php (http://www.4homepages.de/forum/index.php?topic=17598.0), to have him as the start and now:
Several test (with F5)

index
Code: [Select]
Page generated in 0.705108 seconds with 15 queries, spending 0.115000 seconds doing MySQL queries and 0.590108 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.347588 seconds with 10 queries, spending 0.078000 seconds doing MySQL queries and 0.269588 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.205167 seconds with 10 queries, spending 0.013000 seconds doing MySQL queries and 0.192167 doing PHP things. GZIP compression disabled
categorie
Code: [Select]
Page generated in 7.872441 seconds with 355 queries, spending 0.184000 seconds doing MySQL queries and 7.688441 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.483311 seconds with 14 queries, spending 0.099000 seconds doing MySQL queries and 0.384311 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.364798 seconds with 9 queries, spending 0.087000 seconds doing MySQL queries and 0.277798 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 32.019884 seconds with 826 queries, spending 0.867000 seconds doing MySQL queries and 31.152884 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.219854 seconds with 9 queries, spending 0.017000 seconds doing MySQL queries and 0.202854 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.547811 seconds with 9 queries, spending 0.081000 seconds doing MySQL queries and 0.466811 doing PHP things. GZIP compression disabled

detail
Code: [Select]
Page generated in 0.531857 seconds with 18 queries, spending 0.170000 seconds doing MySQL queries and 0.361857 doing PHP things. GZIP compression disabled
Code: [Select]
Page generated in 0.490396 seconds with 18 queries, spending 0.044000 seconds doing MySQL queries and 0.446396 doing PHP things. GZIP compression disabled
And you ?
--> http://www.fond-ecran-gratuit.biz/

I need this mod, because I need the url rewrite

When you talk about your change? (That is: # msg126772 http://www.4homepages.de/forum/index.php?topic=17598.msg126772?)

Sorry if I do not understand everything right away
Thank you for your help
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: batu544 on June 11, 2010, 09:59:58 PM
Hi Satine,
                 What V@no wants you to do is.. first disable the cache system by changing all the values from 1 to 0 of below variables

Code: [Select]
// Initialize cache configuration
$cache_enable          = 1;
$cache_lifetime        = 3600; // 1 hour
$cache_path            = ROOT_PATH.'cache';
$cache_page_index      = 1;
$cache_page_categories = 1;
$cache_page_top        = 1;
$cache_page_rss        = 1;

2.  After this you need to test all the things, what you did exactly..


Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 11, 2010, 11:28:33 PM
I will stop this, because I just noticed that my site was hacked, I opened another topic:

http://www.4homepages.de/forum/index.php?topic=27386.msg148192#msg148192
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: V@no on June 12, 2010, 03:09:28 AM
and yes, viruses/trojans are know for slowing down sites... (replied to your other post already)

When you talk about your change? (That is: # msg126772 http://www.4homepages.de/forum/index.php?topic=17598.msg126772?)

Sorry if I do not understand everything right away
Thank you for your help
Yes, that is the code I meant.

The original mod's code query database for each single link it creates, nic_bck's code (the one you are using) caches some of the links so it would only query database ones if previous link was the same as current, but once a different link created all cache is gone. My code caches all links, so no duplicate database query will be made.

Another thing many people don't know about is that template can dramatically affect on site performance. As more code in the template, as more work template parsing code have to do, slowing down the page creating process.
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 12, 2010, 08:41:01 PM
I do not know what to do, my host just yet to suspend the site because categorie.php slowed their server too.

Is what I can give access to someone watches?
I just watched I have 15 € on paypal (I sold last month a DVD on ebay), I am willing to pay to solve this problem.
For I do not know many things, the problem does not come from my host because it is number one in my country, the problem just come Appears To categorie.php

Thank you.
Satine
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: batu544 on June 13, 2010, 10:05:33 PM
just a guess.. may be your categories.php is infected by virus.. try to put a clean one and post your footer results here ..

Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 14, 2010, 08:25:16 PM
My old file categorie.php:

Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: categories.php                                       *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.6                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$templates_used 'categories,category_bit,thumbnail_bit';
$main_template 'categories';

define('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');

if (!
$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat"$cat_id)) {
  
redirect("index.php");
}

$cache_id create_cache_id(
  
'page.categories',
  array(
    
$user_info[$user_table_fields['user_id']],
    
$cat_id,
    
$page,
    
$perpage,
    isset(
$user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 08) : 0,
    
$config['template_dir'],
    
$config['language_dir']
  )
);

if (!
$cache_page_categories || !$content get_cache_file($cache_id)) {
// Always append session id if cache is enabled
if ($cache_page_categories) {
  
$old_session_mode $site_sess->mode;
  
$site_sess->mode 'get';
}

ob_start();

//-----------------------------------------------------
//--- SEO variables -----------------------------------
//-----------------------------------------------------

$site_template->register_vars(array('prepend_head_title' => $cat_cache[$cat_id]['cat_name'] . " - "));

//--- Show Categories ---------------------------------
//-----------------------------------------------------
if (!check_permission("auth_upload"$cat_id)) {
  
$upload_url "";
  
$upload_button "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  
$upload_url $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  
$upload_button "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}

$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" get_random_image($cat_id);
$site_template->register_vars(array(
  
"categories" => get_categories($cat_id),
  
"cat_name" => format_text($cat_cache[$cat_id]['cat_name'], 2),
  
"cat_description" => format_text($cat_cache[$cat_id]['cat_description'], 101),
  
"cat_hits" => $cat_cache[$cat_id]['cat_hits'],
  
"upload_url" => $upload_url,
  
"upload_button" => $upload_button,
  
"random_cat_image" => $random_cat_image
));

unset(
$random_cat_image);

//-----------------------------------------------------
//--- Show Images -------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"has_rss"   => true,
  
"rss_title" => "RSS Feed: ".format_text($cat_cache[$cat_id]['cat_name'], 2)." (".str_replace(':'''$lang['new_images']).")",
  
"rss_url"   => $script_url."/rss.php?action=images&amp;".URL_CAT_ID."=".$cat_id
));

$num_rows_all = (isset($cat_cache[$cat_id]['num_images'])) ? $cat_cache[$cat_id]['num_images'] : 0;
$link_arg $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);

include(
ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page$perpage$num_rows_all$link_arg);
$offset $getpaging->get_offset();

$site_template->register_vars(array(
  
"paging" => $getpaging->get_paging(),
  
"paging_stats" => $getpaging->get_paging_stats()
));

$imgtable_width ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((
substr($config['image_table_width'], -1)) == "%") {
  
$imgtable_width .= "%";
}

$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}

$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = 
$cat_id AND c.cat_id = i.cat_id
        ORDER BY "
.$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
        LIMIT 
$offset$perpage";
$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

if (!
$num_rows)  {
  
$thumbnails "";
  
$msg $lang['no_images'];
}
else {
  
$thumbnails "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
  
$count 0;
  
$bgcounter 0;
  while (
$image_row $site_db->fetch_array($result)){
    if (
$count == 0) {
      
$row_bg_number = ($bgcounter++ % == 0) ? 2;
      
$thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    
$thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    
show_image($image_row);
    
$thumbnails .= $site_template->parse_template("thumbnail_bit");
    
$thumbnails .= "\n</td>\n";

    
$count++;
    if (
$count == $config['image_cells']) {
      
$thumbnails .= "</tr>\n";
      
$count 0;
    }
  } 
// end while

  
if ($count 0)  {
    
$leftover = ($config['image_cells'] - $count);
    if (
$leftover 0) {
      for (
$i 0$i $leftover$i++){
        
$thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      
$thumbnails .= "</tr>\n";
    }
  }
  
$thumbnails .= "</table>\n";
//end else
$site_template->register_vars("thumbnails"$thumbnails);
unset(
$thumbnails);

//################################ Start MOD Ajax Slideshow/Diashow ##############################
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN "
.USERS_TABLE." u ON (".get_user_table_field("u.""user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = 
$cat_id AND c.cat_id = i.cat_id
        ORDER BY "
.$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."
        LIMIT "
.$config['ajax_slideshowviewer_how_many']."";

$result $site_db->query($sql);
$num_rows $site_db->get_numrows($result);

$max_length_image_name 65;
$max_length_image_description 55;
$ajax_slideshow_view 0;

if (!
$num_rows)  {
  
$site_template->register_vars(array(
  
"ajax_slideshow" => "",
  
"ajax_slideshow_button" => "",
));
}
else {
  
$ajax_slideshow "<script type=\"text/javascript\" src=\"http://slideshow.triptracker.net/slide.js\"></script>\n";
  
$ajax_slideshow .= "<script type=\"text/javascript\">\n<!-- \n";
  
$ajax_slideshow .= "var viewer = new PhotoViewer();\n";
  
$ajax_slideshow .= "viewer.setSlideDuration(".$config['ajax_slideshowviewer_setSlideDuration'].");\n";
  
$ajax_slideshow .= "viewer.".$config['ajax_slideshowviewer_Panning']."Panning();\n";
  
$ajax_slideshow .= "viewer.".$config['ajax_slideshowviewer_AutoPlay']."AutoPlay();\n";
  
$ajax_slideshow .= "viewer.".$config['ajax_slideshowviewer_Fading']."Fading();\n";
  
$ajax_slideshow .= "viewer.setBackgroundColor('".$config['ajax_slideshowviewer_setBackgroundColor']."');\n";
  
$ajax_slideshow .= "viewer.setBorderWidth(".$config['ajax_slideshowviewer_setBorderWidth'].");\n";
  
$ajax_slideshow .= "viewer.setFontSize(".$config['ajax_slideshowviewer_setFontSize'].");\n";
  
$ajax_slideshow .= "viewer.".$config['ajax_slideshowviewer_Shade']."Shade();\n";
  
$ajax_slideshow .= "viewer.setShadeColor('".$config['ajax_slideshowviewer_setShadeColor']."');\n";
  
$ajax_slideshow .= "viewer.setShadeOpacity('".$config['ajax_slideshowviewer_setShadeOpacity']."');\n";
  
$ajax_slideshow .= "viewer.".$config['ajax_slideshowviewer_Loop']."Loop();\n";
  
$ajax_slideshow .= "viewer.setOnClickEvent(".$config['ajax_slideshowviewer_OnClickEvent'].");\n";
  if (
$config['ajax_slideshowviewer_Toolbar'] == "disable") {
  
$ajax_slideshow .= "viewer.disableToolbar();\n"; }
  if (
$config['ajax_slideshowviewer_EmailLink'] == "disable") {
  
$ajax_slideshow .= "viewer.disableEmailLink();\n"; }
  if (
$config['ajax_slideshowviewer_PhotoLink'] == "disable") {
  
$ajax_slideshow .= "viewer.disablePhotoLink();\n"; }
  
$count 0;
  
$bgcounter 0;
while (
$image_row $site_db->fetch_array($result)) {
   
$ext get_file_extension($image_row['image_media_file']);
   
$config['ajax_slideshowviewer_Types_array'] = explode(","$config['ajax_slideshowviewer_Types']);
   if (
in_array($ext$config['ajax_slideshowviewer_Types_array'])) {
   
$ajax_slideshow_view 1;
   
show_image($image_row);
   
$image_name_short = (isset($image_row['image_name']) && strlen($image_row['image_name']) > $max_length_image_name) ? substr(format_text(stripslashes($image_row['image_name']), 2), 0$max_length_image_name)."..." format_text(stripslashes($image_row['image_name']), 2);
   
$image_name_short str_replace("\r","",$image_name_short);
   
$image_name_short str_replace("\n","",$image_name_short);
   
$image_name_short str_replace("<br>","",$image_name_short);
   
$image_name_short str_replace("<br />","",$image_name_short);
   
$image_name_short str_replace("'","",$image_name_short);
   
$image_name_short str_replace("&lt;","<",$image_name_short);
   
$image_name_short str_replace("&gt;",">",$image_name_short);
   
$image_name_short stripslashes($image_name_short);
   
$image_name_short "".$lang['image_name'].$image_name_short";

   if (
$config['ajax_slideshowviewer_description'] == "enable") {
   
$image_description_short = (isset($image_row['image_description']) && strlen($image_row['image_description']) > $max_length_image_description) ? substr(format_text(stripslashes($image_row['image_description']), 101), 0$max_length_image_description)."..." format_text(stripslashes($image_row['image_description']), 101);
   
$image_description_short str_replace("\r","",$image_description_short);
   
$image_description_short str_replace("\n","",$image_description_short);
   
$image_description_short str_replace("<br>","",$image_description_short);
   
$image_description_short str_replace("<br />","",$image_description_short);
   
$image_description_short str_replace("'","",$image_description_short);
   
$image_description_short str_replace("&lt;","<",$image_description_short);
   
$image_description_short str_replace("&gt;",">",$image_description_short);
   
$image_description_short stripslashes($image_description_short);

   if (
$image_description_short == "")  {
   
$image_description_short "&nbsp;";
   } else {
    
$image_description_short "<br>".$lang['description'].$image_description_short";
   }
   }
   else {
   
$image_description_short "&nbsp;";
   }
   
$ajax_slideshow .= "viewer.add('".MEDIA_DIR."/".$image_row['cat_id']."/".$image_row['image_media_file']."', '".$image_description_short."', '".$image_name_short."');\n";
   }
   }
  if (
$count 0)  {
    
$leftover = ($config['image_cells'] - $count);
  }
  
$ajax_slideshow .= "//-->\n</script>\n";

if (
$user_info['user_level'] == GUEST && $config['ajax_slideshowviewer_Show'] == "1" && $ajax_slideshow_view == "1") {
  
$ajax_slideshow_button "<img src=\"".get_gallery_image("diashow_off.gif")."\" border=\"0\" alt=\"\" />";
  
$site_template->register_vars(array(
  
"ajax_slideshow_button" => $ajax_slideshow_button
  
));
}
elseif (
$user_info['user_level'] != GUEST && $config['ajax_slideshowviewer_Show'] == "1" && $ajax_slideshow_view == "1" || $config['ajax_slideshowviewer_Show'] == "2" && $ajax_slideshow_view == "1") {
  
$ajax_slideshow_button "<a href=\"javascript:void(viewer.show(0))\"><img src=\"".get_gallery_image("diashow.gif")."\" border=\"0\" alt=\"\" /></a>";
  
$site_template->register_vars(array(
  
"ajax_slideshow" => $ajax_slideshow,
  
"ajax_slideshow_button" => $ajax_slideshow_button
  
));
}
else {
  
$site_template->register_vars(array(
  
"ajax_slideshow" => "",
  
"ajax_slideshow_button" => "",
));
}
}
unset(
$ajax_slideshow);
//################################ End MOD Ajax Slideshow/Diashow ##############################


//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].get_category_path($cat_id)."</span>";
$page_title $config['category_separator'].get_category_path_nohtml($cat_id); // MOD: Dynamic page title
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"msg" => $msg,
  
"clickstream" => $clickstream,
  
"page_title" => $page_title // MOD: Dynamic page title
));
$main_template get_cat_template($main_template$cat_id);
$site_template->print_template($site_template->parse_template($main_template));

$content ob_get_contents();
ob_end_clean();

if (
$cache_page_categories) {
  
// Reset session mode
  
$site_sess->mode $old_session_mode;

  
save_cache_file($cache_id$content);
}

// end if get_cache_file()

echo $content;

//Update Category Hits
if ($user_info['user_level'] != ADMIN && $page == 1) {
  
$sql "UPDATE ".CATEGORIES_TABLE."
          SET cat_hits = cat_hits + 1
          WHERE cat_id = 
$cat_id";
  
$site_db->query($sql);
}

include(
ROOT_PATH.'includes/page_footer.php');
?>


I put the file categorie.php located on the site 4images (File New)
yet I have no problem

Result:

index :
Page generated in 0.523630 seconds with 391 queries, spending 0.254000 seconds doing MySQL queries and 0.269630 doing PHP things. GZIP compression disabled
Page generated in 0.427981 seconds with 387 queries, spending 0.192000 seconds doing MySQL queries and 0.235981 doing PHP things. GZIP compression disabled


categorie :
Page generated in 0.356049 seconds with 388 queries, spending 0.117000 seconds doing MySQL queries and 0.239049 doing PHP things. GZIP compression disabled
Page generated in 0.576684 seconds with 447 queries, spending 0.231000 seconds doing MySQL queries and 0.345684 doing PHP things. GZIP compression disabled

detail :
Page generated in 0.441164 seconds with 415 queries, spending 0.153000 seconds doing MySQL queries and 0.288164 doing PHP things. GZIP compression disabled
Page generated in 0.461827 seconds with 416 queries, spending 0.168000 seconds doing MySQL queries and 0.293827 doing PHP things. GZIP compression disabled
Page generated in 0.951267 seconds with 415 queries, spending 0.698000 seconds doing MySQL queries and 0.253267 doing PHP things. GZIP compression disabled

with

Code: [Select]
// Initialize cache configuration
$cache_enable          = 1;
$cache_lifetime        = 3600; // 1 hour
$cache_path            = ROOT_PATH.'cache';
$cache_page_index      = 1;
$cache_page_categories = 1;
$cache_page_top        = 1;
$cache_page_rss        = 1;

I think the site is available quickly enough? and you?
http://www.fond-ecran-gratuit.biz/

and yes, viruses/trojans are know for slowing down sites... (replied to your other post already)

When you talk about your change? (That is: # msg126772 http://www.4homepages.de/forum/index.php?topic=17598.msg126772?)

Sorry if I do not understand everything right away
Thank you for your help
Yes, that is the code I meant.

The original mod's code query database for each single link it creates, nic_bck's code (the one you are using) caches some of the links so it would only query database ones if previous link was the same as current, but once a different link created all cache is gone. My code caches all links, so no duplicate database query will be made.

Another thing many people don't know about is that template can dramatically affect on site performance. As more code in the template, as more work template parsing code have to do, slowing down the page creating process.

I'm sorry, but I did not really understand

the code that you proposed is:



Code: [Select]
function fixname($text)
{
  return strtolower(strtr(
    $text,
     array(
      "é" => "e",
      "è" => "e",
      "ê" => "e",
      "à" => "a",
      "ë" => "e",
      "â" => "a",
      "ú" => "a",
      "ó" => "o",
      "í" => "i",
      "á" => "a",

      //russian UTF8 encoded alphabet (lower and upper cases)
      "&#1040;" => "a",
      "&#1072;" => "a",
      "&#1041;" => "b",
      "&#1073;" => "b",
      "&#1042;" => "v",
      "&#1074;" => "v",
      "&#1043;" => "g",
      "&#1075;" => "g",
      "&#1044;" => "d",
      "&#1076;" => "d",
      "&#1045;" => "e",
      "&#1077;" => "e",
      "&#1025;" => "yo",
      "&#1105;" => "yo",
      "&#1046;" => "zh",
      "&#1078;" => "zh",
      "&#1047;" => "z",
      "&#1079;" => "z",
      "&#1048;" => "i",
      "&#1080;" => "i",
      "&#1049;" => "j",
      "&#1081;" => "j",
      "&#1050;" => "k",
      "&#1082;" => "k",
      "&#1051;" => "l",
      "&#1083;" => "l",
      "&#1052;" => "m",
      "&#1084;" => "m",
      "&#1053;" => "n",
      "&#1085;" => "n",
      "&#1054;" => "o",
      "&#1086;" => "o",
      "&#1055;" => "p",
      "&#1087;" => "p",
      "&#1056;" => "r",
      "&#1088;" => "r",
      "&#1057;" => "s",
      "&#1089;" => "s",
      "&#1058;" => "t",
      "&#1090;" => "t",
      "&#1059;" => "u",
      "&#1091;" => "u",
      "&#1060;" => "f",
      "&#1092;" => "f",
      "&#1061;" => "h",
      "&#1093;" => "h",
      "&#1062;" => "c",
      "&#1094;" => "c",
      "&#1063;" => "ch",
      "&#1095;" => "ch",
      "&#1064;" => "sh",
      "&#1096;" => "sh",
      "&#1065;" => "sch",
      "&#1097;" => "sch",
      "&#1066;" => "",
      "&#1098;" => "",
      "&#1067;" => "i",
      "&#1099;" => "i",
      "&#1068;" => "'",
      "&#1100;" => "'",
      "&#1069;" => "e",
      "&#1101;" => "e",
      "&#1070;" => "yu",
      "&#1102;" => "yu",
      "&#1071;" => "ya",
      "&#1103;" => "ya",
  )));
}
function get_category_url($cat_id,$cat_url = '')
{
  global $site_db, $cat_cache;
  static $urlname = array(); //cache names in this array
  if (isset($urlname[$cat_id]))
    return $urlname[$cat_id];
  if (!empty($cat_cache))
  {
    $row['cat_name'] = @$cat_cache[$cat_id]['cat_name'];
    $row['cat_parent_id'] = @$cat_cache[$cat_id]['cat_parent_id'];
  }
  else
  {
    $sql = "SELECT cat_name,cat_parent_id FROM ".CATEGORIES_TABLE." WHERE cat_id = '".$cat_id."'";
    $row = $site_db->query_firstrow($sql);
  }
  $row['cat_name'] = fixname($row['cat_name']);
  $cat_url  = '-'.str_replace('+','-',urlencode($row['cat_name'])).'-'.$cat_id.$cat_url;
  // if you want full path of category in url, put next line in comment
  $row['cat_parent_id'] = 0;
  if($row['cat_parent_id'] != 0)
  {
    $urlname[$cat_id] = get_category_url($row['cat_parent_id'],$cat_url);
  }
  else
  {
    $urlname[$cat_id] = $cat_url;
  }
  return $urlname[$cat_id];
}
//Mod_bmollet
/**
 * Get the image url
 * @param int $image_id The id of the image
 */
function get_image_url($image_id)
{
  global $site_db;
  static $urlname = array(); //cache names in this array
  if (isset($urlname[$image_id]))
    return $urlname[$image_id];
 
  $sql = "SELECT cat_id,image_name FROM ".IMAGES_TABLE." WHERE image_id = '".$image_id."'";
  $row = $site_db->query_firstrow($sql);
  $row['image_name'] = fixname($row['image_name']);
  // if you want comlpete path to image in url, remove comment from following line
  //$urlname[$image_id] = get_category_url($row['cat_id']).'-'.str_replace('+','-',urlencode($row['image_name'])).'-'.$image_id; 
  $urlname[$image_id] = '-'.str_replace('+','-',urlencode($row['image_name'])).'-'.$image_id;
  return $urlname[$image_id];
}


But I must add or? (Or replace with what?)

Thank you! :)
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: V@no on June 15, 2010, 01:07:31 AM
use that code instead of code from step 2 of the mod (http://www.4homepages.de/forum/index.php?topic=17598.0)
Title: Re: Your scripts consume too much CPU and overload our servers
Post by: satine88 on June 15, 2010, 08:13:31 PM
use that code instead of code from step 2 of the mod (http://www.4homepages.de/forum/index.php?topic=17598.0)

Thank you very much!
Now I see the difference

Thank you !