SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member solutionsunited's Avatar
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Php Cookie Problem

    Hello Sitepoint Members,

    I have a cookie problem. I have used cookies before and surely I do know how it works.

    Currently I have a website at http://www.solutionsunited.net/seehits where I need to block a computer from counting the hits.

    So, the block system will be requested from domain www.solutionsunited.net

    and then the computer blocked by this system will not be counted as hits.

    if you can see, my program use an embeded javascript such as:

    <!-- SEEHITS.COM Code -->
    <script> mypage="DEFAULT"; </script>
    <script type="text/javascript" src="
    http://www.solutionsunited.net/seehits/tracker/index.php?id=1"></script>
    <noscript><a href="
    http://www.solutionsunited.net/seehits"><img src="http://www.solutionsunited.net/seehits/tracker/index.php?id=1&noscript=true"></a></noscript>
    <!-- End SEEHITS.COM Code -->



    so here is the objective, the solutionsunited.net will send a cookie (say blocked = 1) and then when any url with the above script is run, the system will need to read this cookie.

    do any of you know how to do this?

  2. #2
    SitePoint Zealot Cheeser's Avatar
    Join Date
    Nov 2003
    Location
    Washington, DC
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try
    PHP Code:
    if ($_COOKIE['blocked'] == '1') {

    // no hit counted

    exit();

    } else {

    // do whatever


    you must have register_globals set to 'on' in the php.ini file

    also, couldn't someone just delete their cookies in order to bypass this? my recommendation is to record the users ip address and insert it into a database, then check to see if the ip address is in the database, if not then dont count as a hit, or if it isn't count the hit.

    heres something i'm just making now:
    PHP Code:
    <?php

    // insert ip into database after the user voted
    $sql "INSERT INTO ip SET
    ip = '
    $_SERVER[REMOTE_ADDR]'";
    $res mysql_query($sql);

    // or whatever

    ////////////////////////////

    // for comparison

    $ip $_SERVER['REMOTE_ADDR'];

    // connect to db
    $sql "SELECT * FROM ip WHERE ip = '$ip'";
    $res mysql_query($sql);

    if (
    mysql_num_rows($res)==0) {

    // HIT ME

    } else {

    // dont count hit

    }

    ?>
    just an example, if there are errors in there...sorry lol
    my aim is: dark 3xplosion if you need further help

  3. #3
    SitePoint Member solutionsunited's Avatar
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi cheser, thank you for your help.

    my i know what register_globals is? how do they work?
    is this a kind of cookie?

  4. #4
    SitePoint Zealot Cheeser's Avatar
    Join Date
    Nov 2003
    Location
    Washington, DC
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its a setting in your php.ini file its default is off, for security issues, but many people keep it on and have no problems. (like me )

  5. #5
    SitePoint Member solutionsunited's Avatar
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi chesser,

    unfortunately i have tried your solution and it is not working also.

    there is a very good example on jellycounter.com
    please try to register (which is free) and you can get 5 days for trial

    then please try to block & unblock your self.

    i will get back to you with a better example.


    thanks anyway.

  6. #6
    SitePoint Member solutionsunited's Avatar
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi cheeser.

    i have a better sample. please take a look at http://www.jellycounter.com

    this is currently what i am trying to develop.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •