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

Re: Script: Vote For Points

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

Because it is just a basic voting website (like said in first post) it only supports 1x adding the point. If you want it to handle more website and for every voteingsite you need to add a suporting database table to store that kind of information.

Yes the two fields are updated. But the donation field itself is used to calculate the voting time :), if you add a date paramter around it you'll see the time when the user has vote.

(eg:)
  1.  
  2. <?php
  3. echo date('D-m-Y h:n:s', [here_your_time_integer]);
  4. ?>
  5.  

and it should give something like 8-9-2009 23:21... I can be wrong on the displaying...
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 Thu Sep 10, 2009 9:24 am

i'm noob at php script,

i don't know how to do with it,
i just want is some like in extrereme rose and speed rose


EDIT:
how to erase the updating on donation?

EDIT:i make vote_date row in accounts table, i hope its work

EDIT:i have some problems, i register a new account then trying to vote and then its said
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!

here's is 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', 'root', 'root');
  13. mysql_select_db('gh');
  14.  
  15. ############ Settings ############
  16. $cmd['add_points'] = 'dpts';            // You can choise between zully and dpts (donation points!)
  17. $cmd['amount'] = 2;                     // 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.  
  23. // A tiny login screen!
  24. if ( ($_SERVER['REQUEST_METHOD'] == 'POST') ) {
  25.     $sql = "SELECT id FROM accounts WHERE username = '%s' AND password = '%s';";
  26.     $sql = sprintf($sql, mysql_real_escape_string($_POST['user_name']), md5($_POST['password']));
  27.     $res = @mysql_query($sql);
  28.     if ( $res === false ) {
  29.         echo '<p class="error_block">Problem with loggin in</p>';
  30.     } elseif ( mysql_num_rows($res) == 0 ) {
  31.         echo '<p class="error_block">Invalid combination username/password</p>';
  32.     } else {
  33.         echo '<p class="ok_block">Valid login</p>';
  34.         $_SESSION['user_account_id'] = mysql_result($res, 0);
  35.     }
  36. }
  37. if ( isset($_SESSION['user_account_id']) ) {
  38.     #echo 'Welcome: ' . $_SESSION['user_account_id'] . '<br />';
  39. } else {   
  40.     echo '
  41.     <form action="" method="post">
  42.         User name: <input type="text" name="user_name" id="user_name">
  43.         Password: <input type="password" name="password" id="password">
  44.         <input type="submit" name="login" id="login" value="login">
  45.     </form>
  46.     ';
  47. }
  48.  
  49. # Start with the vote for points
  50.  
  51.  
  52. if ( isset($_GET['vote_site']) ) {
  53.     # Check if the vote site exist
  54.     if ( isset($cmd['vote_site'][$_GET['vote_site']]) ) {
  55.         # check the 'if login'
  56.         $refresh = true;
  57.         if ( isset($_SESSION['user_account_id']) && ctype_digit($_SESSION['user_account_id']) ) {
  58.             # add point!
  59.             $sql = 'UPDATE accounts SET %1$s = %1$s + %2$d, vote_date=UNIX_TIMESTAMP() + %4$d WHERE id = %3$d AND vote_date < UNIX_TIMESTAMP() ;';
  60.             $sql = sprintf($sql, ( $cmd['add_points'] == 'dpts' ? 'nb_donation' : 'zulystorage'), $cmd['amount'], $_SESSION['user_account_id'], $cmd['time_out']);
  61.             $res = @mysql_query($sql);
  62.             if ( $res === false ) {
  63.                 $refresh = false;
  64.             } elseif ( mysql_affected_rows() == 0 ) {
  65.                 $refresh = false;
  66.             }
  67.         }
  68.         if ( $refresh === true ) {
  69.             echo 'One moment please while we redirect you!';
  70.             echo '<meta http-equiv="refresh" content="2; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  71.         } else {
  72.             echo '<strong>Warning: </strong>Our voting system has detected that you already voted within 24 hours and therefore not receive any credit!';
  73.             echo 'click <a href="' . $cmd['vote_site'][$_GET['vote_site']][0] . '">here</a> to vote for us!';
  74.         }
  75.     } else {
  76.         echo 'The clicked voting site does not exist! Please try again!';
  77.     }
  78. }
  79.  
  80.  
  81.  
  82. ############ Print voting sites ############
  83. if ( @is_array($cmd['vote_site']) ) {
  84.     // print sites
  85.     echo '<br />';
  86.     foreach ( $cmd['vote_site'] as $id => $vote_site ) {
  87.         list($http,$img) = $vote_site;
  88.         echo '<a href="' . ( $cmd['page_type'] == '&' ? $_SERVER['REQUEST_URI'].'&' : $cmd['page_type'] ) . 'vote_site=' . $id . '" target="_blank"><img src="' . $img . '" /></a> ';
  89.     }
  90. } else {
  91.     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!';
  92. }
  93. ?>
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 Thu Sep 10, 2009 8:19 pm

Q: How to erase the updating on donation?

A: If you erease the updating in the donation field, you will not have any check ... to remove it
  1.  
  2.  # add point!
  3.              $sql = 'UPDATE accounts SET %1$s = %1$s + %2$d, vote_date=UNIX_TIMESTAMP() WHERE id = %3$d AND vote_date < UNIX_TIMESTAMP() ;';
  4.              $sql = sprintf($sql, ( $cmd['add_points'] == 'dpts' ? 'nb_donation' : 'zulystorage'), $cmd['amount'], $_SESSION['user_account_id']);
  5.  


Q: I make vote_date row in accounts table, i hope its work
A: No it will not work, unless you figure something out, probaly it is doable if you add everything to an 'array' aswel... With array I mean a value seperated with a coma ';' ...

Q:I have some problems, i register a new account then trying to vote and then its said
A: If you're not logged in or if you're still loged in with your old account it would triger this error.


Notice
In first post there is a new script with a complete point checker wich allows you to use more voting sites and a user gets credit per voting site
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 Fri Sep 11, 2009 6:59 pm

thnx,

instead of donation row for the time i make it in email row. ^_^
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 Fri Sep 11, 2009 11:47 pm

If you don't use that row fine, you can also use activation_key for that mather.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Ultra on Sat Feb 25, 2012 8:08 pm

I see that this is OLD post/topic but i have some problems :

www.lightroseonline.tk
UserCP
-------------
user: demo
pass: demo

When i click on Vote4Points it wont show nothing.. and you cant click on the nav.
...
Ultra
Rackie
Rackie
 
Posts: 225
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Script: Vote For Points

Postby Rifke on Wed Mar 14, 2012 12:11 am

Very unlikely I didn't even knew how I did it back in those days. This is a 4 year old script. There are much better ways to building your own thing based on the materials you can find lingering around this place.
Some people brought some nice scripts to the market :)
I'm way to out-dated about the structure of the game to help you further (and I can't seem to find any login button on your site)
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Script: Vote For Points

Postby Ultra on Wed Mar 14, 2012 8:13 pm

It was from me ...
Thanks to FRose xD
Ultra
Rackie
Rackie
 
Posts: 225
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Previous

Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 5 guests

cron