Jump to content

Moved to a new server now cookies dont work in php?


Trevors

Recommended Posts

Heya all i just moved to a new server and now im code isnt working with cookies? i have gone through the code several times but cannot find the problem.
I have searched through the code to see where it messes it up and found it but still dont know whats wrong.

I would really appreciate if someone could have a look at the code.
The cookie code is very important since it stops robots/proxy programs from voting (runnin a top list for websites).


have a look at this code

/*if ($err == 1 && $use_cookies == 1) {
if ($anti_cheat[$site] == 1) $err = 2;
if ($test_cookies != 1) $err = 5;
}*/

i had to comment out that or else the system wouldnt work at all but i need cookies enabled as soon as possible.

As i said i would be very glad if someone could have a look at it and i know im not the best programmer hehe


[code]

<?

include "config.php";
$MinPerVote = 5; // 1 vote per 5 minutes
$cookie_message = "<font color=red face=verdana size=2>Please enable cookies.</font><br>";
$vote_timeout = "12";
$use_cookies = "1";


if(isset($_GET['site'])){
    $site = $_GET['site'];
            }
else        {

    $site = $_POST['site'];
        }

$Time = Time() - ($MinPerVote * 60);

$open = mysql_connect($dbhost, $user, $pass);
$data = mysql_db_query($dbname, "DELETE FROM top_ip WHERE time < $Time");


    //Links / htaccess
      $data = mysql_db_query($dbname, "SELECT * FROM top_user Where sid='$site'");
    if($rad = mysql_fetch_array ($data)) {
          $inCID = $rad["category"];
    }
      $data = mysql_db_query($dbname, "SELECT * FROM top_cats Where cid='$inCID'");
    if($rad = mysql_fetch_array ($data)) {
          $InCurrentID = $rad["cid"];
        $inCurrentCatName  = $rad["catname"];
        $LLink = str_replace(" ", "-", $inCurrentCatName);
        $LLink = str_replace("/", "-", $LLink);
        $LLink = strtolower($LLink);
    }


//Which Category
      $Sitecat = $inCID;
//Category ID
      $incatename = $inCurrentCatName;
//Category name




$get_rows = mysql_db_query ($dbname,"Select title,url from top_user Where sid='$site'",$db) or die (mysql_error());
if (!mysql_num_rows($get_rows) OR mysql_num_rows ($get_rows) < 1) { header("location: $url_to_folder"); }

if ($gateway == 1 && $_POST['stat'] != "gate") {

    if ($use_cookies == 1)    {
        setcookie ("test_cookies", "1",time()+(3600*$vote_timeout));
                }
include "header.php";

?>

<br />


<style type="text/css" media="screen, tv, projection"> @import "menu.css"> </style>
<TABLE Width="750" CellPadding="3" CellSpacing="0" style="border-left-width: 1px; border-right: 1px solid #3E4968; border-left: 1px solid #3E4968; border-top-width: 1px; border-bottom-width: 1px" bgcolor="#ddecf8" align="left" >
<TR>
<TD background="bg_menu.jpg" colspan="5" height="22">
<font color="black" face="<? echo $font_face; ?>" Size="2"<small><center><B>- <?Print "$incatename";?> Top 100</B></center></small></font>
</TD>
</TR>
<TR>
<TD>
<font color="black" face="<? echo $font_face; ?>" Size="<? echo $font_size; ?>">

<small>
              
              
<body bgcolor="#FFFFFF" onLoad="if (self != top) top.location = self.location">
<FORM ACTION="in.php" METHOD="POST">
<p align="center">&nbsp;</p>
<p align="center">

<font color="black" face="<? echo $font_face; ?>" Size="5"<small><center><B><?Print "$incatename";?> Top 100</B></small></font>
<p>

<?

      $open = mysql_connect($dbhost, $user, $pass);
      $data = mysql_db_query($dbname, "SELECT * FROM top_user WHERE sid='$site'");

      while($rad = mysql_fetch_array ($data)) {
          $SiteTitle  = $rad["title"];
        
        echo "<input type=\"submit\" value=\"Vote for $SiteTitle\" name=\"SUBMIT_IMAGE\" ALT=\"ENTER TO $top_name\"><BR>\n";



    //which category

      $data = mysql_db_query($dbname, "SELECT * FROM top_user WHERE sid='$site'");
    if($rad = mysql_fetch_array ($data)) {
          $Category = $rad["category"];
    }
?>    
        <script type="text/javascript"><!--
        google_ad_client = "";
        google_ad_width = 468;
        google_ad_height = 60;
        google_ad_format = "468x60_as";
        google_ad_channel ="";
        google_color_border = "ddecf8";
        google_color_bg = "ddecf8";
        google_color_link = "ddecf8";
        google_color_url = "008000";
        google_color_text = "000000";
        //--></script>
        <script type="text/javascript"
          src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
    

        <center><p>[Please click <a href="">here</a> if you have been tricked.]</p></center>
        <center><p>Voting is once every 12 hours</p></center>
        <center><p>In/Out resets every 30 days</p></center>
<?}?>
    </p>
    <p align="center">&nbsp;</p>
    <INPUT TYPE="HIDDEN" NAME="site" VALUE="<?Print $site;?>">
    <INPUT TYPE="HIDDEN" NAME="stat" VALUE="gate">
    </FORM>
    <a href=""></a> &copy; 2004 <br></font>

    </small><br>
    <br>
    </font>
    </TD>
    </TR>
    <TR>
    <TD Colspan="6"  Align="center" background="logoborder.jpg" height="13">
    </TD>
    </TR>
    </Table>
    <font style="FONT-FAMILY: Verdana, Tahoma, Arial; FONT-SIZE: 7pt;">
    <br />
    


<?    
}
else {setcookie ("test_cookies", "1",time()+(3600*$vote_timeout));}


if ($gateway == 1 && isset($_POST['site'])) {

    //Finding the correct category for the website

      $data = mysql_db_query($dbname, "SELECT * FROM top_user WHERE sid='$site'");
    if($rad = mysql_fetch_array ($data)) {
          $Category = $rad["category"];
    }

    //Looking up if the users is connecting through a proxy
    if($_SERVER['HTTP_X_FORWARDED_FOR'] != "" && $_SERVER['HTTP_VIA'] != "") {
    //Print "Proxy detected!\n";
        header("location: $url_to_folder/$LLink");
    exit;
    }


    // Checking if the website has voted within 5 minutes
    $open = mysql_connect($dbhost, $user, $pass);
    $data = mysql_db_query($dbname, "SELECT * FROM top_ip WHERE sid='$site'");


    if($rad = mysql_fetch_array ($data)) {
      header("location: $url_to_folder/$LLink");
      exit;
    }
    else {
      $Time = Time();
      $data = mysql_db_query($dbname, "INSERT top_ip (sid, time) VALUES ('$site', '$Time')");
    }

    if ($use_cookies == 1) {
        setcookie ("test_cookies", "1",time()+(3600*$vote_timeout));
    }

    $cdate = date ("Ymd");
    $err = 1;

    $pdate = time()-(3600*$vote_timeout);
    $cndate = time();

    $REMOTE_ADDR=$_SERVER['remote_addr'];
    $query = mysql_db_query ($dbname,"Select ip from top_hits Where sid='$site' and cdate between $pdate and $cndate and ip='$REMOTE_ADDR'",$db) or die (mysql_error());
    if ($err == 1 && @mysql_num_rows($query) >= 1) $err = 2;

    /*if ($err == 1 && $use_cookies == 1) {
        if ($anti_cheat[$site] == 1) $err = 2;
        if ($test_cookies != 1) $err = 5;
    }*/


    if ($err == 1) {
        if ($use_cookies == 1) {
            setcookie ("anti_cheat[$site]", "1",time()+(3600*$vote_timeout));
    }

        mysql_db_query ($dbname,"update top_user set thin=thin+1 Where sid='$site'",$db) or die (mysql_error());
        mysql_db_query ($dbname,"update top_user set totin=totin+1 Where sid='$site'",$db) or die (mysql_error());//- Total in
        mysql_db_query ($dbname,"update top_user set monthin=monthin+1 Where sid='$site'",$db) or die (mysql_error());//- Monthly in
        mysql_db_query ($dbname,"insert into top_hits (sid,ip) values ('$site','$REMOTE_ADDR')",$db) or die (mysql_error());
    }
    
    header("location: $url_to_folder/$LLink");
}

include "footer.php";

?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.