Voting For Union 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

Voting For Union Points

Postby veveto on Fri Jul 22, 2011 6:50 am

hi
how i can make my voting script for points gives union points ??

heres the 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', '****');
  13. mysql_select_db('roseon');
  14.  
  15. ############ Settings ############
  16. $cmd['add_points'] = 'zully';           // 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 * 24);         // Time in seconds to get another point in voting! Default: 24 hours...
  20. $cmd['refresh_rate'] = 4;               // Time to refferer to the voting website
  21.  
  22. $cmd['vote_site'][] = array('http://www.google.be', 'http://www.google.be/intl/en_com/images/logo_plain.png');      // eg: array('http://www.votesite1.com', 'http://yoursite.com/votesite1.jpg');
  23. $cmd['vote_site'][] = array('http://www.yahoo.com', 'http://l.yimg.com/a/i/ww/beta/y3.gif');        // eg: array('http://www.votesite2.com', 'http://yoursite.com/votesite2.jpg');
  24. $cmd['vote_site'][] = array('http://www.yebol.com/', 'http://www.yebol.com/icons/f_logo.gif');      // eg: array('http://www.votesite3.com', 'http://yoursite.com/votesite3.jpg');
  25.  
  26.  
  27.  
  28.  
  29.  
  30. // A tiny login screen!
  31. if ( ($_SERVER['REQUEST_METHOD'] == 'POST') ) {
  32.     $sql = "SELECT id FROM accounts WHERE username = '%s' AND password = '%s';";
  33.     $sql = sprintf($sql, mysql_real_escape_string($_POST['user_name']), md5($_POST['password']));
  34.     $res = @mysql_query($sql);
  35.     if ( $res === false ) {
  36.         echo '<p class="error_block">Problem with loggin in</p>';
  37.     } elseif ( mysql_num_rows($res) == 0 ) {
  38.         echo '<p class="error_block">Invalid combination username/password</p>';
  39.     } else {
  40.         echo '<p class="ok_block">Valid login</p>';
  41.         $_SESSION['user_account_id'] = mysql_result($res, 0);
  42.     }
  43. }
  44. if ( isset($_SESSION['user_account_id']) ) {
  45.     #echo 'Welcome: ' . $_SESSION['user_account_id'] . '<br />';
  46. } else {   
  47.     echo '
  48.     <form action="" method="post">
  49.         User name: <input type="text" name="user_name" id="user_name">
  50.         Password: <input type="password" name="password" id="password">
  51.         <input type="submit" name="login" id="login" value="login">
  52.     </form>
  53.     ';
  54. }
  55.  
  56. # Start with the vote for points
  57.  
  58.  
  59. if ( isset($_GET['vote_site']) ) {
  60.     # Check if the vote site exist
  61.     if ( isset($cmd['vote_site'][$_GET['vote_site']]) ) {
  62.         # check the 'if login'
  63.        
  64.         if ( isset($_SESSION['user_account_id']) && ctype_digit($_SESSION['user_account_id']) ) {
  65.             # First get the voting times from database
  66.             $sql = "SELECT donation FROM accounts WHERE id = %d;";
  67.             $sql = sprintf($sql, $_SESSION['user_account_id']);
  68.             $res = @mysql_query($sql);
  69.             if ( $res === false ) {
  70.                 echo '<strong>Warning:</strong> due a problem with our database we could not check if you have already voted or not. please try again later.';
  71.             } else {
  72.                 # now we we get the value from the database using mysql_result
  73.                 $voting_times = mysql_result($res, 0);
  74.                 # Now we have our times stored in a variable... Each voting site is seperated by a ; so we extract every time using the php function explode
  75.                 # This wil result in an array with the values... With an index starting at 0.. The first value in the array (postition 0) would be our first
  76.                 # voting site!
  77.                 $voting_times_array = explode(';',$voting_times);
  78.                
  79.                 # now we need to get the current time in seconds. That can be accompished by mktime(), a build in php function.
  80.                 $current_time = mktime();
  81.                
  82.                 # now we have our current time stored an a variable, we need to check it with the value stored in $voting_times_array and the corresponding
  83.                 # voting website.
  84.                
  85.                 if ( $current_time < @$voting_times_array[ $_GET['vote_site'] ] ) {
  86.                     # our current time is 'lower' than the stored value, so the user is still in cooldown. And can not receive any points for voting!
  87.                     # Therefor we will print a warning message that he is still on cooldown. And we will print a message saying he/she has still hours:minutes:seconds to go
  88.                    
  89.                     $resulting_time = $voting_times_array[ $_GET['vote_site'] ] - $current_time;
  90.                     $cooldown = date('h:n:s', $resulting_time);
  91.                     echo '<strong>Warning:</strong> We have detected that you still have ' . $cooldown . ' to go before you receive credit again.';
  92.                 } else {
  93.                     # the user is not on cooldown, so we can suggest he/she can vote agian
  94.                     # Now we have to store the current time + time_out in the voting_times_array at the corresponding voting_site id
  95.                     $voting_times_array[ $_GET['vote_site'] ] = $current_time + $cmd['time_out'];
  96.                    
  97.                     # Now $voting_times_array contains the new time for that voting site we have to rewrite the times back to the databse, including the
  98.                     # updated points! So basicly we have to glue the array back together, we can accomplish that using the implode feater of php
  99.                     $sql = 'UPDATE accounts SET %1$s = %1$s + %2$d, donation='%4$s' WHERE id = %3$d;';
  100.                     $sql = sprintf($sql, ( $cmd['add_points'] == 'dpts' ? 'nb_donation' : 'zulystorage'), $cmd['amount'], $_SESSION['user_account_id'], implode(';',$voting_times_array));
  101.                     $res = @mysql_query($sql);
  102.                     if ( $res === false ) {
  103.                         echo '<strong>Warning:</strong> due a problem with our database we could not add your voting credit.';
  104.                     } else {
  105.                         echo '<strong>Congratulations:</strong> you have received credit for your voting.';
  106.                     }
  107.                 }
  108.                
  109.             }
  110.         } else {
  111.             # This message will only be triggerd when the user is not logged on. Or has an invalid account id.
  112.             echo '<strong>Warning:</strong> We have detected that you are not logged on. If you were logged on you would have recieved credit for your voting';
  113.         }
  114.        
  115.         # The user will always be redirected even if it failed the above things... So a user can also vote when he is not logged on!
  116.         echo 'We will direct you in ' . $cmd['refresh_rate'] . ' seconds, if nothing hapens please click <a href="'.$cmd['vote_site'][$_GET['vote_site']][0].'">here</a>!';
  117.         echo '<meta http-equiv="refresh" content="'.$cmd['refresh_rate'].'; URL=' . $cmd['vote_site'][$_GET['vote_site']][0] . '">';
  118.        
  119.     } else {
  120.         echo 'The clicked voting site does not exist! Please try again!';
  121.     }
  122. }
  123.  
  124.  
  125.  
  126. ############ Print voting sites ############
  127. if ( @is_array($cmd['vote_site']) ) {
  128.     // print sites
  129.     echo '<br />';
  130.     foreach ( $cmd['vote_site'] as $id => $vote_site ) {
  131.         list($http,$img) = $vote_site;
  132.         echo '<a href="' . ( $cmd['page_type'] == '&' ? $_SERVER['REQUEST_URI'].'&' : $cmd['page_type'] ) . 'vote_site=' . $id . '" target="_blank"><img src="' . $img . '" border="0" /></a> ';
  133.     }
  134. } else {
  135.     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!';
  136. }
  137. ?>


Tnx
veveto
Smoulie
Smoulie
 
Posts: 41
Joined: Sun Aug 15, 2010 1:31 am

Re: Voting For Union Points

Postby veveto on Wed Jul 27, 2011 5:13 pm

Bump I need help please .
veveto
Smoulie
Smoulie
 
Posts: 41
Joined: Sun Aug 15, 2010 1:31 am

Re: Voting For Union Points

Postby mit1mit2 on Thu Jul 28, 2011 7:43 am

You aren't allowed to do that.
mit1mit2
Rackie
Rackie
 
Posts: 169
Joined: Wed Dec 30, 2009 9:02 pm

Re: Voting For Union Points

Postby redgie on Sun Aug 07, 2011 4:45 pm

hi sir can you make reborn points to mall ?
redgie
Rackie
Rackie
 
Posts: 267
Joined: Tue Apr 14, 2009 10:03 am

Re: Voting For Union Points

Postby merlon on Sun Aug 14, 2011 2:29 pm

redgie wrote:hi sir can you make reborn points to mall ?


asking people for a mall is not going to go over well...
User avatar
merlon
Antares
Antares
 
Posts: 359
Joined: Fri Jul 09, 2010 2:15 pm

Re: Voting For Union Points

Postby Vetyst on Sun Aug 28, 2011 2:20 pm

this is a part of the vote for union points
since the vote for points isn't working for characters is it working like

Select Character -> vote

  1. <center>
  2.     <h2>Vote For Union</h2>
  3.     <hr width="150px" bgcolor="black">
  4.        
  5.        
  6.     <?php
  7.                 $user = $_SESSION['account'];
  8.                
  9.         if(isset($_GET['char']) == false){
  10.             echo '
  11.             <b style="line-height:5%;">Select a Character</b>
  12.             <hr width="200px" bgcolor="black">
  13.             ';
  14.            
  15.                 $sql = mysql_query("SELECT * FROM characters WHERE account_name='".$user."'");
  16.                 echo '<table border="1" >';
  17.                 echo '<tr><td style="padding:5px;">Name</td><td style="padding:5px;">Union Points</td></tr>';
  18.             while($char = mysql_fetch_assoc($sql))
  19.                 {
  20.                     $union = 0 . $char['unionid'];
  21.                     if($char['unionid'] != '0')
  22.                         {   
  23.                             echo '<tr><td style="padding:5px;" bgcolor="#999999">';
  24.                             echo '<a href="?p=index&char='.$char['id'].'">'.$char['char_name'].'</a></td><td bgcolor="#999999" style="padding:5px;"><br />';
  25.                             echo $char['union'.$union].'</td></tr>';
  26.                         }
  27.                 }
  28.                 echo '</table>';
  29.         } else {
  30.             $charid = mysql_real_escape_string($_GET['char']);
  31.                 $sql = mysql_query("SELECT * FROM characters WHERE account_name='".$user."' AND id='".$charid."'");
  32.                     if(mysql_num_rows($sql) != 0)
  33.                         {
  34.                             ////////////////////////////////////////////
  35.                             ////////////////////////////////////////////
  36.                             //////
  37.                             ////// Script needed
  38.                             //////
  39.                             ////////////////////////////////////////////
  40.                             ////////////////////////////////////////////
  41.                         } else {
  42.                             echo '<font color="#ff0000"> This is not your character! </font>';
  43.                         }
  44.                
  45.         }
  46.  
  47.     ?>
  48.    
  49. </center>
User avatar
Vetyst
osRose dev
osRose dev
 
Posts: 146
Joined: Sat Jun 18, 2011 10:56 am
Location: The Netherlands

Re: Voting For Union Points

Postby veveto on Fri Sep 16, 2011 10:21 am

the script you posted gives me this
Vote For Union

Notice: Undefined variable: _SESSION in F:\xampp\htdocs\vote.php on line 10
Select a Character
Warning: mysql_query() [function.mysql-query]: Access denied for user ''@'localhost' (using password: NO) in F:\xampp\htdocs\vote.php on line 18

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in F:\xampp\htdocs\vote.php on line 18

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in F:\xampp\htdocs\vote.php on line 21
veveto
Smoulie
Smoulie
 
Posts: 41
Joined: Sun Aug 15, 2010 1:31 am

Re: Voting For Union Points

Postby merlon on Fri Dec 23, 2011 3:28 pm

Seems that you dont have access. Check the code and the user/pass for database
User avatar
merlon
Antares
Antares
 
Posts: 359
Joined: Fri Jul 09, 2010 2:15 pm


Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 7 guests