that is full script.
it is fastCGI and problem is memory used by this script.
after yester run is used memory by script bigger and bigger :(
i ned absolute flushing memory from added "modul" (sorry for my
english)
#!/usr/bin/perl
use FCGI;
use Mysql;
require "default.conf";
require "default.def";
require "_cookie.mdl";
# RELOAD
############
sub fcgi_exit
{
my $request = FCGI::Request();
$request->Finish();
exit(0);
}
# CREATE LOG
############
sub save_log
{
my($uroven,$text) = @_;
if ($uroven<=$log)
{
open (HND, ">>_logs/$Wyear$Wmom$Wmday-$$-$Whour.fastlog");
print HND "\\$$\\$fastcount\\[$uroven]\\ $text\n";
close HND;
if ($superlog){$superlog_tmp="$superlog_tmp\\[$uroven]\\ $text <BR>";}
}
}
# ADD MODULE
###############
sub add_module
{
my($tempposition,$name,@variables) = @_;
my $mdl_output;
do "$name.mdl";
if ($mdl_output=&ModulAdd(@variables))
{
$html_write{$tempposition}="$html_write{$tempposition}$mdl_output";
}
undef &ModulAdd;
my $length=length($mdl_output);
&save_log(2,"+\"$name.mdl\" [$tempposition][$length]");
}
###############
#
###############
my $req=FCGI::Request();
local $fastcount;
while ($req->Accept() >= 0)
{
$fastcount++;
&StartScript_new;
}
sub StartScript_new
{
my $time_start=(times)[0]; # START COUNTING TIME
# RELATIVE
############################
my $html_temp=$HTML_TEMP;
# TIME
############################
local $current_time=time;
local ($Tsec, $Tmin, $Thour, $Tmday, $Tmom, $Tyear, $Twday, $Tyday,
$Tisdst)=localtime($current_time);
local $Wsec=$Tsec;local $Wmin=$Tmin;local $Whour=$Thour;local $Wmday=$Tmday;local
$Wmom=$Tmom+1;
local $Wyear=$Tyear+1900;
if ($Wsec<10){$Wsec="0$Wsec"}
if ($Wmin<10){$Wmin="0$Wmin"}
if ($Whour<10){$Whour="0$Whour"}
if ($Wmday<10){$Wmday="0$Wmday"}
if ($Wmom<10){$Wmom="0$Wmom"}
# LOCAL
############################
local $superlog_tmp;
local %form;
local %cookie;
local %html_write;
local $dbh = Mysql->Connect($db_host,$db_name,$db_user,$db_pass);
# MY
############################
my $key;
my $length;
&save_log(0,"START [$$][$fastcount/$max_count]");
&GetQueryString;
if(!$form{type}){$form{type}="first";}
&GetCookie;foreach $key (keys %cookie){&save_log(3,"get_cookie
'$key'=\"$cookie{$key}\"");}
# START BASE MODULE'S
&add_module('00-01',"_check_online");
if ($superlog){&add_module('99-99',"_superlog")};
do "type_$form{type}.mdl";
&BaseModul;undef &BaseModul;
# All others modules is in &BaseModul {&add_module...,&add_module...
etc...}
# CREATE HTML
############################
foreach $key (sort keys %html_write)
{
if (not $html_temp=~s|<%TMP$key%>|$html_write{$key}|g)
{
$length=length($html_write{$key});&save_log(0,"! insert ok '$key' [$length chars]");
}
else
{
$length=length($html_write{$key});&save_log(4,"-> bad insert! '$key' [$length
chars]");
}
}
# SEND COOKIE
############################
$cookie{name}="i-laskanie";
&SetCookie("-1","$host","/","0");
foreach $key (keys %cookie){&save_log(3,"set_cookie '$key'=\"$cookie{$key}\"");}
# COUNT END, LOG END
############################
my $time_end=(times)[0]-$time_start; # END COUNTING TIME
my $memory_end=`ps -p $$ -o vsz=`;$memory_end=~s|[\n\r ]||g;
$length=length($html_temp);
&save_log(0,"END [$$][$current_time][$time_end][$length
chars][$memory_end/$max_memory]\n\n");
# SEND HTML
############################
if ($superlog){$html_temp=~s|<%SUPERLOG%>|$superlog_tmp|g;}
&PrintHeader;
print $html_temp;
# UNDEF
############################
undef %form;
undef %cookie;
undef $dbh;
# RELOAD
############################
if (($fastcount>$max_count)||($memory_end>$max_memory))
{&save_log(0,"RELOAD [$current_time][$$-$memory_end/$max_memory]\n\n");&fcgi_exit;}
}
> and this is "base_clanky_big.mdl" linket by sub
> &add_module(x,'base_clanky_big');
sub ModulAdd
{
##############################
# LOCAL VARIABLES FOR MODULE
##############################
my $mdl_temp;
my $mdl_temp_line=<<"HEADER";
<table border=0 cellpadding=2 cellspacing=0 width=100% bagcolor=#86A3BA>
<tr>
<td valign=top>
<!--IMAGE-->
</td>
<td valign=top><DIV align=justify>
<a href="index.pl?type=clanky&id=<!--ID-->">
<font color=#002F5A size=3 face=Arial><b><!--TITLE--><BR></b></font>
</a>
<font face=Arial size=2><!--TINY--></font>
</DIV></td>
</tr>
</table>
<BR>
HEADER
my $db_micro;
my $db_micro1;
my %db_micro_line;
my %db_micro1_line;
my $nullid;
my %ref;
###############################
# START VARIABLES MANIPULATION
###############################
$db_micro = $dbh->Query("SELECT ID,starttime,author,tiny,title,image FROM clanky WHERE
starttime<$current_time AND active='Y' AND typeview='B' ORDER BY starttime DESC LIMIT
1");
if (@db_micro_line=$db_micro->FetchRow())
{
$mdl_clanok_big_no=$db_micro_line[0];
$mdl_temp="$mdl_temp$mdl_temp_line";
$mdl_temp=~s|<!--TITLE-->|$db_micro_line[4]|g;
$mdl_temp=~s|<!--TINY-->|$db_micro_line[3]|g;
$mdl_temp=~s|<!--ID-->|$db_micro_line[0]|g;
$nullid=$db_micro_line[0];
if ($nullid<10){$nullid="0$nullid"};
if ($nullid<100){$nullid="0$nullid"};
if ($nullid<1000){$nullid="0$nullid"};
if ($nullid<10000){$nullid="0$nullid"};
if ($nullid<100000){$nullid="0$nullid"};
$mdl_temp=~s|<!--NULLID-->|$nullid|g;
@ref=split(',',$db_micro_line[5]);
$nullid=$ref[0];
if ($nullid<10){$nullid="0$nullid"};
if ($nullid<100){$nullid="0$nullid"};
if ($nullid<1000){$nullid="0$nullid"};
if ($nullid<10000){$nullid="0$nullid"};
if ($nullid<100000){$nullid="0$nullid"};
if ($nullid<1000000){$nullid="0$nullid"};
$db_micro1 = $dbh->Query("SELECT ID,small_120x160,original FROM photogallery WHERE
ID='$ref[0]' LIMIT 1");
if (@db_micro1_line=$db_micro1->FetchRow())
{
if ($db_micro1_line[1] eq "Y")
{
@ref=split('x',$db_micro1_line[2]);
@ref=&image_size($ref[0],$ref[1]);
$mdl_temp=~s|<!--IMAGE-->|<a href="javascript://"
onclick='window.open("img.pl?id=$nullid&popis=$db_micro_line[4]","imageWin","width=$ref[0],
height=$ref[1], $ref[2], resizable=no")'><img src="$dir_d/gallery/$nullid-120x160.jpg"
width=120 height=160 align=left border=1></a>|g;
}
else
{
$mdl_temp=~s|<!--IMAGE-->|<img src="$dir_d/gallery/$nullid-120x160.jpg" width=120
height=160 align=left border=1>|g;
}
}
else
{
$mdl_temp=~s|<!--IMAGE-->|<img src="$dir_d/gallery/0000000-120x160.jpg" width=120
height=160 align=left border=1>|g;
}
}
undef %db_micro_line;
undef %db_micro1_line;
undef %ref;
return $mdl_temp}
:
:.. Roman Fordinal
:.: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]