Script: Vote For Points

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Rate this script

0-2
1
33%
3-4
0
No votes
5-6
0
No votes
7-8
0
No votes
9-10
2
67%
 
Total votes : 3

Script: Vote For Points

Postby Rifke on Sat Sep 05, 2009 12:54 am

A fully built voting website, wich allows as many voting sites as you wich, each voting site will be recorded and taken into concideration by the script itself. So a user will only get one time the credit in the setted time per voting website.


Please check the inside file configuration:

  1.  
  2. ############ Settings ############
  3. $cmd['add_points'] = 'dpts';            // You can choise between zully and dpts (donation points!)
  4. $cmd['amount'] = 9;                     // Amount to be added
  5. $cmd['page_type'] = '?';                // ? or &       => ? for main page      & for a sub page!
  6. $cmd['time_out'] = (3600 * 24);         // Time in seconds to get another point in voting! Default: 24 hours...
  7. $cmd['refresh_rate'] = 4;               // Time to refferer to the voting website
  8.  
  9. $cmd['vote_site'][] = array('Vote Link 1', 'Vote Img 1');       // eg: array('http://www.votesite1.com', 'http://yoursite.com/votesite1.jpg');
  10. $cmd['vote_site'][] = array('Vote Link 2', 'Vote Img 2');       // eg: array('http://www.votesite2.com', 'http://yoursite.com/votesite2.jpg');
  11. $cmd['vote_site'][] = array('Vote Link 3', 'Vote Img 3');       // eg: array('http://www.votesite3.com', 'http://yoursite.com/votesite3.jpg');
  12. $cmd['vote_site'][] = array('Vote Link 4', 'Vote Img 4');       // eg: array('http://www.votesite4.com', 'http://yoursite.com/votesite4.jpg');
  13.  
Attachments
vote_for_points.txt
Supports multiple voting sites
(6.87 KiB) Downloaded 691 times
Last edited by Rifke on Thu Sep 10, 2009 8:52 pm, edited 6 times in total.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Mike567 on Sat Sep 05, 2009 8:40 am

how can i changed the dpts into nbdpts ?
and this is only can vote every 12hours?
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Script: Vote For Points

Postby Rifke on Sat Sep 05, 2009 11:39 am

It is currently with nb_donation ....


  1.  
  2. $sql = 'UPDATE accounts SET %1$s = %1$s + %2$d, donation=UNIX_TIMESTAMP() + 3600 WHERE id = %3$d AND donation < UNIX_TIMESTAMP() ;';
  3.  


Change the 3600 with (3600*12)


  1.  
  2. $sql = 'UPDATE accounts SET %1$s = %1$s + %2$d, donation=UNIX_TIMESTAMP() + (3600 * 12) WHERE id = %3$d AND donation < UNIX_TIMESTAMP() ;';
  3.  
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Choseal on Sat Sep 05, 2009 8:22 pm

Carefull though guys, for some reason the 12 hour security didn't work (For me) for:
TopMMO.com and TopOfGames.com

So test it first or they might get infinite voting points.

Might be my mistake though, will check it later, but it's just a warning. :P
Choseal
Electric Ghost
Electric Ghost
 
Posts: 837
Joined: Fri Jan 09, 2009 6:40 pm

Re: Script: Vote For Points

Postby Rifke on Sat Sep 05, 2009 8:37 pm

I have uploaded a 2nd version wich allows you to set the time with the configuration lines!
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Mike567 on Mon Sep 07, 2009 4:38 pm

its direct me in http://localhost/index.php?vote_site=0 and nothing happend

EDIT:My script
  1. <?php
  2. session_start();
  3. ################################################
  4. # Script by Rifke for the osrose compunity
  5. # index.php
  6. # date: 05 August 2009
  7. ################################################
  8.  
  9.  
  10.  
  11. ############ MySQL connection remove if you already have one #############
  12. mysql_connect('localhost:3306', 'rose', 'rose');
  13. mysql_select_db('rose');
  14.  
  15. ############ Settings ############
  16. $cmd['add_points'] = 'dpts';            // You can choise between zully and dpts (donation points!)
  17. $cmd['amount'] = 9;                     // Amount to be added
  18. $cmd['page_type'] = '?';                // ? or &       => ? for main page      & for a sub page!
  19. $cmd['time_out'] = (3600 * 12);         // Time in seconds to get another point in voting! Default: 24 hours...
  20.  
  21. $cmd['vote_site'][] = array('http://www.xtremetop100.com/in.php?site=1132288171', 'http://www.xtremetop100.com/votenew.jpg');       // eg: array('http://www.votesite1.com', 'http://yoursite.com/votesite1.jpg');
  22. $cmd['vote_site'][] = array('http://www.gtop100.com/in.php?site=38170', 'http://www.gtop100.com/images/nvotebutton.jpg');       // eg: array('http://www.votesite2.com', 'http://yoursite.com/votesite2.jpg');
  23. $cmd['vote_site'][] = array('http://www.gtop100.com/in.php?site=38170', 'http://www.gtop100.com/images/nvotebutton.jpg');       // eg: array('http://www.votesite3.com', 'http://yoursite.com/votesite3.jpg');
  24. $cmd['vote_site'][] = array('http://www.mmorpgtop200.com/in.php?site=4888', 'http://www.mmorpgtop200.com/votenew.jpg');     // eg: array('http://www.votesite4.com', 'http://yoursite.com/votesite4.jpg');
  25.  
  26.  
  27.  
  28.  
  29. // A tiny login screen!
  30. if ( ($_SERVER['REQUEST_METHOD'] == 'POST') ) {
  31.     $sql = "SELECT id FROM accounts WHERE username = '%s' AND password = '%s';";
  32.     $sql = sprintf($sql, mysql_real_escape_string($_POST['user_name']), md5($_POST['password']));
  33.     $res = @mysql_query($sql);
  34.     if ( $res === false ) {
  35.         echo '<p class="error_block">Problem with loggin in</p>';
  36.     } elseif ( mysql_num_rows($res) == 0 ) {
  37.         echo '<p class="error_block">Invalid combination username/password</p>';
  38.     } else {
  39.         echo '<p class="ok_block">Valid login</p>';
  40.         $_SESSION['user_account_id'] = mysql_result($res, 0);
  41.     }
  42. }
  43. if ( isset($_SESSION['user_account_id']) ) {
  44.     echo 'Welcome: ' . $_SESSION['user_account_id'] . '<br />';
  45. } else {   
  46.     echo '
  47.     <form action="" method="post">
  48.         User name: <input type="text" name="user_name" id="user_name">
  49.         Password: <input type="password" name="password" id="password">
  50.         <input type="submit" name="login" id="login" value="login">
  51.     </form>
  52.     ';
  53. }
  54.  
  55. # Start with the vote for points
  56.  
  57.  
  58. if ( isset($_GET['vote_site']) ) {
  59.     # Check if the vote site exist
  60.     if ( isset($cmd['vote_site'][$_GET['vote_site']]) ) {
  61.         # check the 'if login'
  62.         $refresh = true;
  63.         if ( isset($_SESSION['user_account_id']) && ctype_digit($_SESSION['user_account_id']) ) {
  64.             # add point!
  65.             $sql = 'UPDATE accounts SET %1$s = %1$s + %2$d, donation=UNIX_TIMESTAMP() + %4$d WHERE id = %3$d AND donation < UNIX_TIMESTAMP() ;';
  66.             $sql = sprintf($sql, ( $cmd['add_points'] == 'dpts' ? 'nb_donation' : 'zulystorage'), $cmd['amount'], $_SESSION['user_account_id'], $cmd['time_out']);
  67.             $res = @mysql_query($sql);
  68.             if ( $res === false ) {
  69.                 $refresh = false;
  70.             } elseif ( mysql_affected_rows() == 0 ) {
  71.                 $refresh = false;
  72.             }
  73.         }
  74.         if ( $refresh === true ) {
  75.             echo 'One moment please while we redirect you!';
  76.             echo '<meta http-equiv="refresh" content="2000; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  77.         } else {
  78.             echo '<strong>Warning: </strong>Our voting system has detected that you already voted within 12 hours and therefore not receive any credit!';
  79.             echo 'click <a href="' . $cmd['vote_site'][$_GET['vote_site']][0] . '">here</a> to vote for us!';
  80.         }
  81.     } else {
  82.         echo 'The clicked voting site does not exist! Please try again!';
  83.     }
  84. }
  85.  
  86.  
  87.  
  88. ############ Print voting sites ############
  89. if ( @is_array($cmd['vote_site']) ) {
  90.     // print sites
  91.     echo '<br />';
  92.     foreach ( $cmd['vote_site'] as $id => $vote_site ) {
  93.         list($http,$img) = $vote_site;
  94.         echo '<a href="' . $cmd['page_type'] . 'vote_site=' . $id . '" target="_blank"><img src="' . $img . '" /></a> ';
  95.     }
  96. } else {
  97.     echo 'Your voting sites are NOT configured correctly! Please check them again! or visit <a href="http://forum.dev-osrose.com/index.php">os Rose development</a> for more information!';
  98. }
  99. ?>
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Script: Vote For Points

Postby Rifke on Mon Sep 07, 2009 9:58 pm

You always get a messager wether it succeeds or fails... What message do you get?


Edit I found the fault:
  1.  
  2. echo '<meta http-equiv="refresh" content="2000; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  3.  

I set the refresh at 2000 seconds (because of testing) but you can set it to 0 for instant refresh!

  1.  
  2. echo '<meta http-equiv="refresh" content="0; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  3.  
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Mike567 on Tue Sep 08, 2009 8:30 am

i don't get any message if it success or fail its only direct me to homepage.

Rifke wrote:You always get a messager wether it succeeds or fails... What message do you get?


Edit I found the fault:
  1.  
  2. echo '<meta http-equiv="refresh" content="2000; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  3.  

I set the refresh at 2000 seconds (because of testing) but you can set it to 0 for instant refresh!

  1.  
  2. echo '<meta http-equiv="refresh" content="0; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  3.  


still not working
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Script: Vote For Points

Postby Rifke on Tue Sep 08, 2009 1:10 pm

Set the refresh to 5 orso, to see what happens, but I've tested it with your configuration and it just works fine. It opens a new window and and refreshes it to the clicked website.


Edit:
Check version 3 (in first post)
If your website is included in your page website you have to change $cmd['page_type'] = '?' to $cmd['page_type'] = '&' then I think your problem will be solved...
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Mike567 on Tue Sep 08, 2009 3:05 pm

yah its working, thnx

but i got a problem too, i only vote one time mean i can vote only in a 1 top list, and the others can't example i vote in xtremetop100.com and says we are direct you to, then when i click on gtop , mmorpgtoplist and mmorptop200 its say
Warning: Our voting system has detected that you already voted within 24 hours and therefore not receive any credit!click here to vote for us!


and also when i check nb_donation in database is fine, but its adding too in donation row in accounts table, its add 1252461749

thnx
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Next

Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 6 guests

cron