Results 1 to 12 of 12

Thread: Need fast help IP count

  1. #1
    Hyperactive Member
    Join Date
    Jul 09
    Posts
    312

    Need fast help IP count

    Hello, this script is for vote reward, but it logs only IP's in the database, and if user change his ip he can vote again and again unlimited, can someone fix this script also to login the account when he clicks on all votes 1 time he can click again after 24 hours

    Code:
    <?PHP
    
    if(isset($_POST[id_vote])) {
    	include("vote.php");
    	$ip = $_SERVER['REMOTE_ADDR'];
    	$login = clean_var( stripslashes($_SESSION['user']) );
    	$id = substr( clean_var( stripslashes($_POST[id_vote]) ) , 3);
    	$file = "vote_logs/".date("Y-m-d", time())."_$id.dat";
    
    	if(empty($_SESSION['pass']) || empty($_SESSION['user'])) {
    		echo $die_start . mmw_lang_guest_must_be_logged_on . $die_end . $rowbr;
    	}
    	elseif(is_file($file) && $vote[$id][2]>0) {
    		$handle = fopen($file, "r");
    		$data = fread($handle, filesize($file));
    		fclose($handle);
    		$substr_count = substr_count($data,$ip);
    		if($substr_count <= 0) {
    			$data = "$ip \n";
    			$fp = fopen($file, 'a');
    			fputs($fp, $data);
    			fclose($fp);
    			mssql_query("UPDATE MEMB_CREDITS SET credits = credits + ".$vote[$id][2]." WHERE memb___id='$login'");
    			echo "$okey_start Thanks For Vote! $okey_end $rowbr";
    			writelog("vote_for_us","Vote <b>$id</b> Has Been <font color=#FF0000>Added</font> For $_SESSION[user] - ".$vote[$id][2]);
    		}
    		else {
    			echo "$die_start Today You Can't Vote For This! $die_end $rowbr";
    		}
    	}
    	elseif(isset($_SESSION['pass']) && isset($_SESSION['user']) && $vote[$id][2]>0) {
    		$data = "$ip \n";
    		$fp = fopen($file, 'a');
    		fputs($fp, $data);
    		fclose($fp);
    		mssql_query("UPDATE MEMB_CREDITS SET credits = credits + ".$vote[$id][2]." WHERE memb___id='$login'");
    		echo "$okey_start Thanks For Vote! $okey_end $rowbr";
    		writelog("vote_for_us","Vote <b>$id</b> Has Been <font color=#FF0000>Added</font> For $_SESSION[user] - ".$vote[$id][2]);
    	}
    	else {
    		echo "$die_start Fatal ErroR! $die_end $rowbr";
    	}
    }
    ?>
    
    <script>
    function windopen(url) {
     window.open(url,"HellEntry","width=800,height=540,left=0,top=0");
     // window.top.location.href = url;
     // window.location = url;
    }
    </script>
    
    <center><big><b>Vote For Us</b></big><br>&nbsp;<br></center>
    
    <table class="sort-table" height="30" border="0" cellpadding="0" cellspacing="0" align="center" width="400">                
    	<thead><tr>
              <td width="10">#</td>
              <td>URL</td>
              <td width="100">Credit You Get</td>
              <td width="20"><?echo mmw_lang_voting;?></td>
              </tr>
    	</thead>
    <?
    include("vote.php");
    if(count($vote)==0) {
       echo "<tr><td colspan='4'>".mmw_lang_no_vote."</td></tr>";
    }
    else {
       for($i=0; $i < count($vote); ++$i) {
    	$rank = $i + 1;
    	$rand = rand(100,999);
    	echo "<tbody><tr>
           	    <td>$rank</td>
           	    <td>".$vote[$i][0]."</td>
           	    <td>".$vote[$i][2]."</td>
           	    <td><form name=\"vote\" method=\"post\" action=\"\"><input name=\"id_vote\" type=\"hidden\" value=\"$rand$i\"><input type=\"submit\" value=\"".mmw_lang_to_vote."\" title=\"".$vote[$i][0]."\" onclick=\"return windopen('".$vote[$i][1]."')\"></form></td>
           	    </tr></tbody>";
       }
    }
    ?>
    </table>

  2. #2
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 07
    Posts
    365

    Re: Need fast help IP count

    Are you saying you want it to check the users IP address and the users login?

  3. #3
    Hyperactive Member
    Join Date
    Jul 09
    Posts
    312

    Re: Need fast help IP count

    the script already check for ip, but not the account i want to make to check is the account already voted for today if he had voted 1 time, he can vote again after 24 hours that is what i want to be

  4. #4
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 07
    Posts
    365

    Re: Need fast help IP count

    What you need to do is, when the user first votes you need to store the userid and the vote_time using the NOW() function in your DB. In your if statement, you make a query that check for userid and vote_time < interval('24 hours'). Make sense?

  5. #5
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,836

    Re: Need fast help IP count

    Why not require the user to log-in in-order to vote then save both the username and ip address to the database. If the user attempts to vote again have a script to check if their username and ip address is already the database then display a message telling to user that they may only vote once.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  6. #6
    Hyperactive Member
    Join Date
    Jul 09
    Posts
    312

    Re: Need fast help IP count

    they need to be loged to vote, but if they change the ip they can vote again and again, that is what i want to fix if they vote once from the account to be included in the database and cannot vote again, please need fast fix about this

  7. #7
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,836

    Re: Need fast help IP count

    You could probably do something like this.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  8. #8
    Hyperactive Member
    Join Date
    Jul 09
    Posts
    312

    Re: Need fast help IP count

    can someone help to fix the code because it must had an also maybe $_SESSION['account'] or $_SESSION['login'] and to check them in database, i had tryed some guides but i cannot manage it to get it work like it should be. If someone knows php to help here

  9. #9
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 07
    Posts
    365

    Re: Need fast help IP count

    Did you even read what I posted? It will work.

  10. #10
    Hyperactive Member
    Join Date
    Jul 09
    Posts
    312

    Re: Need fast help IP count

    Quote Originally Posted by xxarmoxx View Post
    Did you even read what I posted? It will work.
    Yes i understand your option with SQL Job, but how should this help exactly with the php script
    I think the best option is to include it in the php script that to solve the problem with the account and ip change

  11. #11
    Web developer Nightwalker83's Avatar
    Join Date
    Dec 01
    Location
    Adelaide, Australia
    Posts
    9,836

    Re: Need fast help IP count

    xxarmoxx means something along the lines of:

    PHP Code:
    <?php 
    date_default_timezone_set
    ('Country/City'); 
    if (
    date("F d Y H:i:s.") > date("F d Y H:i:s." lastvote)){
    // Do something
    }
    ?>
    Where lastvote would be the date on which the person last voted which, you will pull from the database.

    Edit:

    Replace country with the country you want the time zone for and the same for the city.
    Last edited by penagate; Jul 31st, 2012 at 07:29 PM. Reason: fixed PHP tag
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    DON'T BUMP YOUR POSTS!!! Links to my code examples can now be found on my website: My websites
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

  12. #12
    Hyperactive Member
    Join Date
    Jul 09
    Posts
    312

    Re: Need fast help IP count

    so if i make the hole code in the if it will work ?

    Code:
    <?php 
    date_default_timezone_set('Bulgaria/Sofia'); 
    if (date("F d Y H:i:s.") > date("F d Y H:i:s." lastvote)){
    
    if(isset($_POST[id_vote])) {
    	include("vote.php");
    	$ip = $_SERVER['REMOTE_ADDR'];
    	$login = clean_var( stripslashes($_SESSION['user']) );
    	$id = substr( clean_var( stripslashes($_POST[id_vote]) ) , 3);
    	$file = "vote_logs/".date("Y-m-d", time())."_$id.dat";
    
    	if(empty($_SESSION['pass']) || empty($_SESSION['user'])) {
    		echo $die_start . mmw_lang_guest_must_be_logged_on . $die_end . $rowbr;
    	}
    	elseif(is_file($file) && $vote[$id][2]>0) {
    		$handle = fopen($file, "r");
    		$data = fread($handle, filesize($file));
    		fclose($handle);
    		$substr_count = substr_count($data,$ip);
    		if($substr_count <= 0) {
    			$data = "$ip \n";
    			$fp = fopen($file, 'a');
    			fputs($fp, $data);
    			fclose($fp);
    			mssql_query("UPDATE MEMB_CREDITS SET credits = credits + ".$vote[$id][2]." WHERE memb___id='$login'");
    			echo "$okey_start Thanks For Vote! $okey_end $rowbr";
    			writelog("vote_for_us","Vote <b>$id</b> Has Been <font color=#FF0000>Added</font> For $_SESSION[user] - ".$vote[$id][2]);
    		}
    		else {
    			echo "$die_start Today You Can't Vote For This! $die_end $rowbr";
    		}
    	}
    	elseif(isset($_SESSION['pass']) && isset($_SESSION['user']) && $vote[$id][2]>0) {
    		$data = "$ip \n";
    		$fp = fopen($file, 'a');
    		fputs($fp, $data);
    		fclose($fp);
    		mssql_query("UPDATE MEMB_CREDITS SET credits = credits + ".$vote[$id][2]." WHERE memb___id='$login'");
    		echo "$okey_start Thanks For Vote! $okey_end $rowbr";
    		writelog("vote_for_us","Vote <b>$id</b> Has Been <font color=#FF0000>Added</font> For $_SESSION[user] - ".$vote[$id][2]);
    	}
    	else {
    		echo "$die_start Fatal ErroR! $die_end $rowbr";
    	}
    }
    ?>
    
    <script>
    function windopen(url) {
     window.open(url,"HellEntry","width=800,height=540,left=0,top=0");
     // window.top.location.href = url;
     // window.location = url;
    }
    </script>
    
    <center><big><b>Vote For Us</b></big><br>&nbsp;<br></center>
    
    <table class="sort-table" height="30" border="0" cellpadding="0" cellspacing="0" align="center" width="400">                
    	<thead><tr>
              <td width="10">#</td>
              <td>URL</td>
              <td width="100">Credit You Get</td>
              <td width="20"><?echo mmw_lang_voting;?></td>
              </tr>
    	</thead>
    <?
    include("vote.php");
    if(count($vote)==0) {
       echo "<tr><td colspan='4'>".mmw_lang_no_vote."</td></tr>";
    }
    else {
       for($i=0; $i < count($vote); ++$i) {
    	$rank = $i + 1;
    	$rand = rand(100,999);
    	echo "<tbody><tr>
           	    <td>$rank</td>
           	    <td>".$vote[$i][0]."</td>
           	    <td>".$vote[$i][2]."</td>
           	    <td><form name=\"vote\" method=\"post\" action=\"\"><input name=\"id_vote\" type=\"hidden\" value=\"$rand$i\"><input type=\"submit\" value=\"".mmw_lang_to_vote."\" title=\"".$vote[$i][0]."\" onclick=\"return windopen('".$vote[$i][1]."')\"></form></td>
           	    </tr></tbody>";
       }
    }
    ?>
    </table>
    
    }
    ?>

Posting Permissions

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