|
-
Jul 28th, 2012, 07:25 PM
#1
Thread Starter
Fanatic Member
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> <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>
-
Jul 28th, 2012, 11:02 PM
#2
Hyperactive Member
Re: Need fast help IP count
Are you saying you want it to check the users IP address and the users login?
-
Jul 29th, 2012, 07:31 AM
#3
Thread Starter
Fanatic Member
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
-
Jul 29th, 2012, 12:56 PM
#4
Hyperactive Member
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?
-
Jul 30th, 2012, 05:21 AM
#5
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jul 30th, 2012, 06:28 AM
#6
Thread Starter
Fanatic Member
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
-
Jul 30th, 2012, 09:29 PM
#7
Re: Need fast help IP count
You could probably do something like this.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jul 31st, 2012, 12:31 AM
#8
Thread Starter
Fanatic Member
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
-
Jul 31st, 2012, 12:53 AM
#9
Hyperactive Member
Re: Need fast help IP count
Did you even read what I posted? It will work.
-
Jul 31st, 2012, 01:10 AM
#10
Thread Starter
Fanatic Member
Re: Need fast help IP count
 Originally Posted by xxarmoxx
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
-
Jul 31st, 2012, 02:49 AM
#11
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
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Aug 1st, 2012, 02:10 AM
#12
Thread Starter
Fanatic Member
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> <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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|