Jump to content
php.lv forumi

Statistika


Chickenz

Recommended Posts

Ir scripts kas nosaka ip, os, time, Pieprasiito failu utt

if(getenv("HTTP_X_FORWARDED_FOR")!=''){
 $ip=getenv("HTTP_X_FORWARDED_FOR");
 $host=gethostbyaddr($ip);}
else{
 $ip=getenv("REMOTE_ADDR");
 $host=getenv("REMOTE_HOST");
}

$ref=$_SERVER["HTTP_REFERER"];
$req=$_SERVER["REQUEST_URI"];
$agent=$_SERVER["HTTP_USER_AGENT"];
$tmp=explode(";",$agent);
$browseris=$tmp[1];
$os=str_replace(")","",$tmp[2]);
$time=date("d/m/y/ H:i");
mysql_query("INSERT INTO `stats` (`host`, `browser`, `os`,`ts`,`req`,`ip`)
VALUES ('$host', '$browseris','$os','$time','$req','$ip')")or die("Nav iespējams turpināt procesu jo: " . mysql_error());

 

Probleema sekojosha:

Gribu lai tiktu ielikts db tikai tad ja links neatbilst piem. index.php?news=3

Vaardu sakot, tad kad kaads meegjina uzlaust lapu ar visaadiem F*** pieprasiijumiem... kaa lai to izdara???

es meegjinaaju ar if tachu tik un taa nesanaak....

Link to comment
Share on other sites

varbut.....

<?
if(!$news){
mysql_query("INSERT INTO `stats` (`host`, `browser`, `os`,`ts`,`req`,`ip`)
VALUES ('$host', '$browseris','$os','$time','$req','$ip')")or die("Nav iespējams turpināt procesu jo: " . mysql_error());
}
?>

Edited by rumpels
Link to comment
Share on other sites

taadaa gadiijumaa tev ir noteikti GET , kuri ar atjauti.

 

ja ir adrese: index.php?id=3

 

bet ja adrese index.php?news=3

 

respektiivi: atljautaa adrese: id=3

 

if ($_GET['id']){

...

statement

...

}else{

insert into ....

ievieto tabulaa

}

 

ja tev nododas news un tu negribi lai news=3

tad:

if ($_GET['news'] == 2 || $_GET['news'] == 1){

... statement

}else{

atkal ievietojam DB

}

 

mok iebraucu auzaas ... :)

Link to comment
Share on other sites

×
×
  • Create New...