Item mall V2

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
8
28%
3-4
0
No votes
5-6
2
7%
7-8
3
10%
9-10
16
55%
 
Total votes : 29

Re: Item mall V2

Postby Rifke on Fri Aug 21, 2009 3:01 pm

  1.  
  2. <?php if(!session_is_registered(Admin)) {
  3. die('Access Denied');
  4. }
  5.  
  6. if( ($_SERVER['REQUEST_METHOD'] == 'POST') && isset($_POST['sure']) ) {
  7.     if ( isset($_POST['account_name']) &&n ctype_digit($_POST['donation_points'])) {
  8.         #mysql_query("UPDATE accounts SET donation = '".$_POST['textfield2']."' WHERE username = '".$_POST['textfield1']."'");
  9.         if ( ctype_digit($_POST['account_name')) {     
  10.             $sql = "UPDATE accounts SET donation = donation + %d WHERE id=%d;";
  11.         } else {
  12.             $sql = "UPDATE accounts SET donation = donation + %d WHERE username='%s';";
  13.         }
  14.         $sql = sprintf($sql, $_POST['donation_points'], $_POST['account_name']);
  15.         $res = @mysql_query($sql);
  16.         if ( $res === false ) {
  17.             echo 'Adding donation points to <strong>'.$_POST['account_name'].'</strong> has failed! Reason: '. mysql_error(). '<br />';
  18.         } elseif ( mysql_affected_rows() == 0 ) {
  19.             echo 'Appearently <strong>'.$_POST['account_name'].'</strong> does not exist. Please check your parameters! <br />';
  20.         } else {
  21.             echo 'Donation points are added to <strong>'.$_POST['account_name'].'</strong>.<br />';
  22.         }
  23.     } else {
  24.         echo 'Please fill in all the fields.';
  25.     }
  26. } else {
  27.     echo 'If you want to add the donation points, then click the box!';
  28. }
  29. ?>
  30. <form id="form1" name="form1" method="post" action="?op=name_change">
  31. <table width="275" border="0" align="center">
  32.   <tr>
  33.     <td width="98">Account Name or id: </td>
  34.     <td width="167"><label>
  35.       <input type="text" name="account_name">
  36.     </label></td>
  37.   </tr>
  38.   <tr>
  39.     <td width="98"> Donation PT: </td>
  40.     <td width="167"><label>
  41.       <input type="text" name="donation_points">
  42.     </label></td>
  43.   </tr>
  44.   <tr>
  45.     <td>Are you sure? </td>
  46.     <td><label>
  47.       <input name="sure" type="checkbox" id="sure" value="checkbox">
  48.     </label></td>
  49.   </tr>
  50. </table>
  51.  
  52. <p align="center">
  53.   <input name="submit" type="submit" id="submit" />
  54.   <br />
  55.   <br />
  56. </p>
  57.  
  58. </form>
  59.  
  60.  
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Item mall V2

Postby Mike567 on Sat Aug 22, 2009 7:58 am

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

Re: Item mall V2

Postby Mike567 on Tue Aug 25, 2009 5:43 pm

when i tried to Purchase the items its say Account Doesn't Exits
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

Postby Rifke on Wed Aug 26, 2009 11:25 am

In the itemmall.php file you'll see the following block

  1.  
  2. ########### Account information ##################
  3. $account_id = ( isset($_SESSION['user_account_id']) ) ? $_SESSION['user_account_id'] : 0 ;
  4. include('class.table.inc.php');
  5.  
  6. // variables
  7. $i_cid = ( isset($_GET['i_cid']) && is_numeric($_GET['i_cid']) ) ? $_GET['i_cid'] : 0;
  8. $i_par = ( isset($_GET['i_par']) && is_numeric($_GET['i_par']) ) ? $_GET['i_par'] : -1;
  9. $i_pur = ( isset($_GET['i_pur']) && is_numeric($_GET['i_pur']) ) ? $_GET['i_pur'] : 0;
  10.  
  11. $item_mall = new itemmallv2($account_id,true);
  12. // Configuring some data
  13. $item_mall->setlog(true); // enable/disable to create an information stream of who bought what
  14. $item_mall->setaccount_id(1); // set the users account ID
  15. $item_mall->setalevel(100); // set the users access level
  16.  
  17.  


I've bolted the line you need to change... the 1 has to be changed (dynamicly through a session/cookie) with the right account ID of the user that is logged on...


Example Given:
  1.  
  2. $item_mall->setaccount_id($_SESSION['Here_Is_My_Session_With_The_Users_Account_ID'); // set the users account ID
  3.  

This code example is only for explaining and might not be valid in your situation.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Item mall V2

Postby Mike567 on Wed Aug 26, 2009 4:08 pm

i don't know what you mean, i try to changed the 1 into my account id which is 81

but when i try to purchase again its say Please make sure you are logged out the game!

is there a way that automatic reads the account id when entering the login page?
or the problem is in login page? bcz i only put the link of item mall in the menu of user
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

Postby Rifke on Wed Aug 26, 2009 6:15 pm

Well have you tried to log out of the game? (Checking if the online field in accounts is set to 0)


Uhm yes? Find the login page and add the account id to a session ...
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Item mall V2

Postby Mike567 on Thu Aug 27, 2009 9:40 am

what is the account session? sorry noob at php

this is the code of my login page


  1. <form id="form1" name="form1" method="post" action="?op=login">
  2.   <p align="center" class="tdglobal"><span class="b01"><?php echo $DynCMS['title']; ?> User Control Panel</span></p>
  3.   <table width="200" border="0" align="center" class="liteoption">
  4.     <tr>
  5.       <td width="97" class="center"><div align="center"><b>Username:</b></div></td>
  6.       <td width="93" class="center"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  7.     </tr>
  8.     <tr>
  9.       <td class="center"><div align="center"><b>Password:</b></div></td>
  10.       <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  11.     </tr>
  12.   </table>
  13.   <p align="center" class="tdglobal"><span class="center">
  14.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  15.   </span></p>
  16. </form>
  17. <p align="center" class="tdglobal">
  18.   <?php
  19. if(isset($_POST['submit'])) {
  20. $U = $_POST['user'];
  21. $P = md5($_POST['pass']);
  22.  
  23. mysql_connect($dbhost, $dbuser, $dbpasswd);
  24. mysql_select_db($dbname);
  25.  
  26. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel = '100'";
  27. $query = mysql_query($result1);
  28.  
  29. $count = mysql_num_rows($query);
  30.  
  31.  
  32. if($count == 1){
  33.  
  34. session_register("User_Name");
  35. session_register("User_Pass");
  36. $_SESSION['account'] = $_POST['user'];
  37. echo('Logged in.... Click <a href=?op=user><strong>here</strong></a>');
  38. }
  39. else {
  40. echo "<strong>Try Again</strong>";
  41. }
  42. }
  43. ?>
  44.   <br />
  45. </p>
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

Postby Rifke on Thu Aug 27, 2009 2:49 pm

  1. <form id="form1" name="form1" method="post" action="?op=login">
  2.   <p align="center" class="tdglobal"><span class="b01"><?php echo $DynCMS['title']; ?> User Control Panel</span></p>
  3.   <table width="200" border="0" align="center" class="liteoption">
  4.     <tr>
  5.       <td width="97" class="center"><div align="center"><b>Username:</b></div></td>
  6.       <td width="93" class="center"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  7.     </tr>
  8.     <tr>
  9.       <td class="center"><div align="center"><b>Password:</b></div></td>
  10.       <td class="center"><input name="pass" type="password" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  11.     </tr>
  12.   </table>
  13.   <p align="center" class="tdglobal"><span class="center">
  14.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  15.   </span></p>
  16. </form>
  17. <p align="center" class="tdglobal">
  18.   <?php
  19. if(isset($_POST['submit'])) {
  20. $U = $_POST['user'];
  21. $P = md5($_POST['pass']);
  22.  
  23. mysql_connect($dbhost, $dbuser, $dbpasswd);
  24. mysql_select_db($dbname);
  25.  
  26. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel = '100'";
  27. $query = mysql_query($result1);
  28.  
  29. $count = mysql_num_rows($query);
  30.  
  31.  
  32. if($count == 1){
  33.  
  34. session_register("User_Name");
  35. session_register("User_Pass");
  36. $res_array = mysql_fetch_assoc($query);         // Added
  37.  
  38. $_SESSION['account_id'] = $res_array['id'];         // Added
  39. $_SESSION['account'] = $_POST['user'];
  40. echo('Logged in.... Click <a href=?op=user><strong>here</strong></a>');
  41. }
  42. else {
  43. echo "<strong>Try Again</strong>";
  44. }
  45. }
  46. ?>
  47.   <br />
  48. </p>
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Item mall V2

Postby Mike567 on Thu Aug 27, 2009 3:29 pm

its say Your account does not exists.
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

Postby Rifke on Thu Aug 27, 2009 3:36 pm

Edit the item mall.php to the right value
  1.  
  2. $item_mall->setaccount_id( $_SESSION['account_id'] ); // set the users account ID
  3.  
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

PreviousNext

Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 3 guests