- <?php
- session_start();
- ################################################
- # Script by Rifke for the osrose compunity
- # index.php
- # date: 05 August 2009
- ################################################
- ############ MySQL connection remove if you already have one #############
- mysql_connect('localhost:3306', 'root', 'root');
- mysql_select_db('gh');
- ############ Settings ############
- $cmd['add_points'] = 'dpts'; // You can choise between zully and dpts (donation points!)
- $cmd['amount'] = 2; // Amount to be added
- $cmd['page_type'] = '&'; // ? or & => ? for main page & for a sub page!
- $cmd['time_out'] = (3600 * 12); // Time in seconds to get another point in voting! Default: 24 hours...
- $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');
- // A tiny login screen!
- if ( ($_SERVER['REQUEST_METHOD'] == 'POST') ) {
- $sql = "SELECT id FROM accounts WHERE username = '%s' AND password = '%s';";
- $sql = sprintf($sql, mysql_real_escape_string($_POST['user_name']), md5($_POST['password']));
- $res = @mysql_query($sql);
- if ( $res === false ) {
- echo '<p class="error_block">Problem with loggin in</p>';
- } elseif ( mysql_num_rows($res) == 0 ) {
- echo '<p class="error_block">Invalid combination username/password</p>';
- } else {
- echo '<p class="ok_block">Valid login</p>';
- $_SESSION['user_account_id'] = mysql_result($res, 0);
- }
- }
- if ( isset($_SESSION['user_account_id']) ) {
- #echo 'Welcome: ' . $_SESSION['user_account_id'] . '<br />';
- } else {
- echo '
- <form action="" method="post">
- User name: <input type="text" name="user_name" id="user_name">
- Password: <input type="password" name="password" id="password">
- <input type="submit" name="login" id="login" value="login">
- </form>
- ';
- }
- # Start with the vote for points
- if ( isset($_GET['vote_site']) ) {
- # Check if the vote site exist
- if ( isset($cmd['vote_site'][$_GET['vote_site']]) ) {
- # check the 'if login'
- $refresh = true;
- if ( isset($_SESSION['user_account_id']) && ctype_digit($_SESSION['user_account_id']) ) {
- # add point!
- $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() ;';
- $sql = sprintf($sql, ( $cmd['add_points'] == 'dpts' ? 'nb_donation' : 'zulystorage'), $cmd['amount'], $_SESSION['user_account_id'], $cmd['time_out']);
- $res = @mysql_query($sql);
- if ( $res === false ) {
- $refresh = false;
- } elseif ( mysql_affected_rows() == 0 ) {
- $refresh = false;
- }
- }
- if ( $refresh === true ) {
- echo 'One moment please while we redirect you!';
- echo '<meta http-equiv="refresh" content="2; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
- } else {
- echo '<strong>Warning: </strong>Our voting system has detected that you already voted within 24 hours and therefore not receive any credit!';
- echo 'click <a href="' . $cmd['vote_site'][$_GET['vote_site']][0] . '">here</a> to vote for us!';
- }
- } else {
- echo 'The clicked voting site does not exist! Please try again!';
- }
- }
- ############ Print voting sites ############
- if ( @is_array($cmd['vote_site']) ) {
- // print sites
- echo '<br />';
- foreach ( $cmd['vote_site'] as $id => $vote_site ) {
- list($http,$img) = $vote_site;
- echo '<a href="' . ( $cmd['page_type'] == '&' ? $_SERVER['REQUEST_URI'].'&' : $cmd['page_type'] ) . 'vote_site=' . $id . '" target="_blank"><img src="' . $img . '" /></a> ';
- }
- } else {
- 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!';
- }
- ?>
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:)
and it should give something like 8-9-2009 23:21... I can be wrong on the displaying...