Computerhilfen.de Logo
Forum
Tipps
News
Frage stellen

12 stunden sperre durch cookie

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

« Letzte Änderung: 23.01.05, 00:05:52 von PC Freak »
« Verstärkung gesuchtInternet-Installation »
 

Schnelle Hilfe: Hier nach ähnlichen Fragen und passenden Tipps suchen!

Fremdwörter? Erklärungen im Lexikon!
PHP
PHP steht für Personal Home Page und ist eine Skriptsprache die meist verwendet wird zur dynamischen Erzeugen von Internetseiten. PHP zeichnet sich durch die weite D...

Klickrate
Das Wort Klickrate gibt das Verhältnis vom Anklicken der Werbebanner zum Anklicken der Internetseite an auf der sich die Werbung befindet. An dieser Rate werden beis...

Update
Als Update bezeichnet man eine aktualisierte Version einer bereits besessenen Software, die registrierte Anwender meist zu einem Bruchteil des Preises des ursprüngli...