Hab nen Php script, welches als klicks in und out sperre dienen soll, so das in meiner Topliste Hits in und out (index.php?id=1 / out.php?id=1) erst nach der sperre von 12 stunden wieder gezählt werden:
PHP-Code:
<PHP
$sperre = "43200"; //Sperzeit in Sekunden
if (empty($_COOKIE['cookiename'])){
// Hier muss der Teil rein, der den Klick zählt
setcookie("cookiename","Reloadsperre",time()+$sperre);
}
else {
echo "Du hast bereits eine Stimme abgegeben";
}
?>
In der mitte des Scriptes (Zitat: // Hier muss der Teil rein, der den Klick zählt) muss der teil der topliste rein der die klicks zählt.
hab schon versucht diesen teil da einzufügen aber irgendwie krieg ich das nicht hin. Wahrscheinlich muss ich dann noch irgendetwas ändern oder so aber kenn mich nicht so mit php aus.
kann mir den teil vielleicht einer richtig da einfügen ?
Hier die index.php:
PHP-Code:
<?
// Report all script errors on this page
error_reporting(E_ALL);
// Including CONFIG.PHP which includes all configurations
require("config.php");
// Including language file
include("languages/" . $lang_file);
if(isset($_GET['id']))
{
$date = date("dmY");
$query = mysql_query("SELECT * FROM " . $table . "_sites WHERE memberid = '" . $_GET['id'] . "'");
$result = mysql_result(mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE memberid = '" . $_GET['id'] . "'"),0);
if($result)
{
$clicksin = "UPDATE " . $table . "_sites SET clicksin = clicksin + 1, hitstotal = hitstotal + 1 WHERE memberid = '" . $_GET['id'] . "'";
while($row = mysql_fetch_assoc($query))
{
$today = $row['hitstoday'];
$today = explode(" | ",$today);
$datetoday = $today[0];
$hitstoday = $today[1];
$hitsplus = $today[1] + 1;
if($date != "$datetoday")
{
$update = "UPDATE " . $table . "_sites SET hitstoday = '" . $date . " | 1' WHERE memberid = '" . $_GET['id'] . "'";
}
else
{
$update = "UPDATE " . $table . "_sites SET hitstoday = '" . $date . " | " . $hitsplus . "' WHERE memberid = '" . $_GET['id'] . "'";
}
$days = $row['date'];
$days = explode(" | ",$days);
$daytoday = $days[0];
$dayplus = $days[1] + 1;
$update2 = "UPDATE " . $table . "_sites SET date = '" . $date . " | " . $dayplus . "' WHERE memberid = '" . $_GET['id'] . "'";
function dohits()
{
global $clicksin,$update,$update2,$date,$daytoday;
mysql_query($clicksin) or die(mysql_error());
mysql_query($update) or die(mysql_error());
if($date != "$daytoday")
{
mysql_query($update2) or die(mysql_error());
}
}
}
dohits();
header("Location:http://www.compu-zone.de/topliste/index.php");
}
else{
echo "" . $text['90'] . "<br><br><a href=\"" . $_SERVER['PHP_SELF'] . "\">" . $text['82'] . " >></a>";
}
}
else
{
?>
Hier die out.php:
PHP-Code:
<?
require("config.php");
$query = mysql_query("SELECT * FROM " . $table . "_sites WHERE memberid = '" . $_GET['id'] . "'");
$result = mysql_result(mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE memberid = '" . $_GET['id'] . "'"),0);
if($result)
{
$hitsout = "UPDATE " . $table . "_sites SET hitsout = hitsout + 1, hitstotal = hitstotal + 1 WHERE memberid = '" . $_GET['id'] . "'";
$date = date("dmY");
while($row = mysql_fetch_assoc($query))
{
$today = $row['hitstoday'];
$today = explode(" | ",$today);
$datetoday = $today[0];
$hitstoday = $today[1];
$hitsplus = $today[1] + 1;
if($date != $datetoday)
{
$update = "UPDATE " . $table . "_sites SET hitstoday = '" . $date . " | 1' WHERE memberid = '" . $_GET['id'] . "'";
}
else
{
$update = "UPDATE " . $table . "_sites SET hitstoday = '" . $date . " | " . $hitsplus . "' WHERE memberid = '" . $_GET['id'] . "'";
}
$days = $row['date'];
$days = explode(" | ",$days);
$daytoday = $days[0];
$dayplus = $days[1] + 1;
$update2 = "UPDATE " . $table . "_sites SET date = '" . $date . " | " . $dayplus . "' WHERE memberid = '" . $_GET['id'] . "'";
function dohits()
{
global $hitsout,$update,$update2,$date,$daytoday;
mysql_query($hitsout) or die(mysql_error());
mysql_query($update) or die(mysql_error());
if($date != "$daytoday")
{
mysql_query($update2) or die(mysql_error());
}
}
dohits();
header("Location: " . $row['url'] . "");
}
}
else
{
echo "This ID doesn't exist.<br><br><a href=\"". $script_url ."/index.php\"><< Return to topsite</a>";
}
?>
so ab ich es versucht:
<PHP
$sperre = "43200"; //Sperzeit in Sekunden
if (empty($_COOKIE['cookiename'])){
// Report all script errors on this page
error_reporting(E_ALL);
// Including CONFIG.PHP which includes all configurations
require("config.php");
// Including language file
include("languages/" . $lang_file);
if(isset($_GET['id']))
{
$date = date("dmY");
$query = mysql_query("SELECT * FROM " . $table . "_sites WHERE memberid = '" . $_GET['id'] . "'");
$result = mysql_result(mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE memberid = '" . $_GET['id'] . "'"),0);
if($result)
{
$clicksin = "UPDATE " . $table . "_sites SET clicksin = clicksin + 1, hitstotal = hitstotal + 1 WHERE memberid = '" . $_GET['id'] . "'";
while($row = mysql_fetch_assoc($query))
{
$today = $row['hitstoday'];
$today = explode(" | ",$today);
# $datetoday = $today;
$hitstoday = $today[1];
$hitsplus = $today[1] + 1;
if($date != "$datetoday")
{
$update = "UPDATE " . $table . "_sites SET hitstoday = '" . $date . " | 1' WHERE memberid = '" . $_GET['id'] . "'";
}
else
{
$update = "UPDATE " . $table . "_sites SET hitstoday = '" . $date . " | " . $hitsplus . "' WHERE memberid = '" . $_GET['id'] . "'";
}
$days = $row['date'];
$days = explode(" | ",$days);
$daytoday = $days
# ;
$dayplus = $days[1] + 1;
$update2 = "UPDATE " . $table . "_sites SET date = '" . $date . " | " . $dayplus . "' WHERE memberid = '" . $_GET['id'] . "'";
function dohits()
{
global $clicksin,$update,$update2,$date,$daytoday;
mysql_query($clicksin) or die(mysql_error());
mysql_query($update) or die(mysql_error());
if($date != "$daytoday")
{
mysql_query($update2) or die(mysql_error());
}
}
}
dohits();
header("Location:http://www.compu-zone.de/topliste/index.php");
}
else{
echo "" . $text['90'] . "<br><br><a href=\"" . $_SERVER['PHP_SELF'] . "\">" . $text['82'] . " >></a>";
}
}
else
{
setcookie("cookiename","Reloadsperre",time()+$sperre);
}
else {
echo "Du hast bereits eine Stimme abgegeben";
}
?>
Fehlermeldung wenn ich es so machen: Parse error: parse error, unexpected T_ELSE in /usr/export/www/vhosts/funnetwork/hosting/pcfreak/topliste/index.php on line 305
PC Freak (209) 2x Beste Antwort 3x "Danke"
|