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 hellmaster on Fri Aug 28, 2009 12:47 am

hello i'm newbie when it comes to .php files... but i already put the item mall on the modules and when i click the link it appears to blank what should i do can u give me... step on where and how to put the files..? thank you
hellmaster
Little soul
Little soul
 
Posts: 6
Joined: Fri Aug 28, 2009 12:45 am

Re: Item mall V2

Postby Mike567 on Fri Aug 28, 2009 11:55 am

Rifke wrote:Edit the item mall.php to the right value
  1.  
  2. $item_mall->setaccount_id( $_SESSION['account_id'] ); // set the users account ID
  3.  


still says Your account does not exists.
here's my itemmalv2.php

  1. <style type="text/css">
  2. /*
  3. .type_11 {
  4.     background:#99CCFF;
  5. }
  6. .type_1 {
  7.     background:#CCFF99;
  8. }
  9. .type_13 {
  10.     background:#FFFF99;
  11. }
  12. .type_6 {
  13.     background:#ff8c9e;
  14. }
  15. .type_2, .type_3, .type_4, .type_5, .type_7, .type_8, .type_9,  {
  16.     background:##66CC00;
  17. }
  18. */
  19. .error_block {
  20.     color: #FF0000;
  21. }
  22. .info_block {
  23.     color: #FF8000;
  24. }
  25. .ok_block {
  26.     color: #008000;
  27. }
  28. </style>
  29. <script language="JavaScript" type="text/javascript">
  30.     <!--
  31.     function conf_purchase( item, quantity, price) {
  32.       if (window.confirm("Are you sure you want to purchase "+quantity+" "+item+" for "+price+"? This action can not be rolled back!") ) {
  33.         //window.location.href = to;
  34.         return true;
  35.       } else {
  36.         return false;
  37.       }
  38.     }
  39. </script>
  40. <?php
  41. //session_start();
  42.  
  43. ################################################
  44. # Script by Rifke for the osrose compunity
  45. # date: 22 Januari 2009
  46. ################################################
  47.  
  48. ############ MySQL connection remove if you already have one #############
  49. mysql_connect('localhost:3306', 'root', 'root');
  50. mysql_select_db('evo');
  51.  
  52. ########### Account information ##################
  53. $account_id = ( isset($_SESSION['user_account_id']) ) ? $_SESSION['user_account_id'] : 0 ;
  54. include('class.table.inc.php');
  55.  
  56. // variables
  57. $i_cid = ( isset($_GET['i_cid']) && is_numeric($_GET['i_cid']) ) ? $_GET['i_cid'] : 0;
  58. $i_par = ( isset($_GET['i_par']) && is_numeric($_GET['i_par']) ) ? $_GET['i_par'] : -1;
  59. $i_pur = ( isset($_GET['i_pur']) && is_numeric($_GET['i_pur']) ) ? $_GET['i_pur'] : 0;
  60.  
  61. $item_mall = new itemmallv2($account_id,true);
  62. // Configuring some data
  63. $item_mall->setlog(true); // enable/disable to create an information stream of who bought what
  64. $item_mall->setaccount_id( $_SESSION['82'] ); // set the users account ID
  65. $item_mall->setalevel(100); // set the users access level
  66.  
  67. // make a breadcrum
  68. $item_mall->breadcrum($i_par,$i_cid);
  69.  
  70. // add item to cart
  71. if ( isset($_GET['i_pur']) && $i_pur > 0 ) {
  72.     $item_mall->addItemToCar($i_pur);
  73. }
  74.  
  75.  
  76.  
  77. if ( isset($_GET['i_cid']) && $i_cid > 0 ) {
  78.  
  79.     $item_mall->getCategory($i_cid);
  80.    
  81. } else {
  82.     $item_mall->getCategory();
  83. }
  84.  
  85.  
  86. class itemmallv2
  87. {
  88.     private $log = false;
  89.     private $alevel = 300;
  90.     private $table_prefs = NULL;
  91.     private $breadcrum = array();
  92.     private $account_id;
  93.     function __construct() {
  94.         $this->table_prefs = array( 'cellspacing' => 0,
  95.                                     'cellpading' => 2,
  96.                                     'width'=> '100%',
  97.                                     'border' => 0,
  98.                                     'style'=> "td,th { font-family: Tahoma, Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 1.1em; }"
  99.                                     );
  100.     }
  101.     // Getters
  102.     function getlog() {
  103.         return $this->log;
  104.     }
  105.     function getalevel() {
  106.         return $this->alevel();
  107.     }
  108.     function gettable_prefs() {
  109.         return $this->table_prefs;
  110.     }
  111.     function getaccount_id(){
  112.         return $this->account_id();
  113.     }
  114.     // Setters
  115.     function setlog($a) {
  116.         $this->log = $a;
  117.     }
  118.     function setalevel($a) {
  119.         $this->alevel = $a;
  120.     }
  121.     function settable_prefs($a) {
  122.         $this->table_prefs = $a;
  123.     }
  124.     function setaccount_id($a) {
  125.         if ( is_numeric($a) )
  126.             $this->account_id = $a;
  127.     }
  128.    
  129.     /*
  130.     * @update   04/02/2009
  131.     * @desc get storage money/donation
  132.     * @param    string $type , int $amount
  133.     * @return   boolean
  134.     */
  135.     function decreaseMoney($type,$amount) {
  136.         if ( $type == 'D' ) {
  137.             $sql = "SELECT donation FROM accounts WHERE id=%d;";
  138.         } else {
  139.             $sql = "SELECT zulystorage FROM accounts WHERE id=%d;";
  140.         }
  141.         $sql = sprintf($sql,$this->account_id);
  142.         $res = @mysql_query($sql);
  143.         if ( $res === false ) {
  144.             echo '<p class="error_block">There has been a problem with adding your item.</p>';
  145.             $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  146.         } elseif ( mysql_fetch_assoc($res) == 0 ) {
  147.             echo 'Your account does not exists.';
  148.         } else {
  149.             $a = mysql_result($res,0);
  150.             if ( ($a-$amount) < 0 )
  151.                 echo '<p class="info_block">You have not enough money to purchase this item.</p>';
  152.             else {
  153.                 if ( $type == 'D' ) {
  154.                     $sql = "UPDATE accounts SET donation=donation-%d WHERE id=%d AND online=1;";
  155.                 } else {
  156.                     $sql = "UPDATE accounts SET zulystorage=zulystorage-%d WHERE id=%d AND online=1;";
  157.                 }
  158.                 $sql = sprintf($sql,$amount, $this->account_id);
  159.                 $res = @mysql_query($sql);
  160.                 if ( $res === false ) {
  161.                     echo '<p class="error_block">Please make sure you are logged out the game!</p>';
  162.                     $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  163.                 } elseif ( mysql_affected_rows() == 1 ) {
  164.                     return true;
  165.                 } else {
  166.                     echo '<p class="error_block">Could not purchase your item, please make sure you are logged out of the game!</p>';
  167.                 }
  168.                 return false;
  169.             }
  170.         }
  171.     }
  172.     /*
  173.     * @update   23/01/2009
  174.     * @desc     make a breadcrum so the users can easly hit the 'back' button'
  175.     * @param    int $i_cid
  176.     * @return   void
  177.     */
  178.     function breadcrum($i_cid) {
  179.         $b = NULL;
  180.         //$b = '<a href="'.$this->getUrl().'&amp;i_par='.$i_par.'">'.$this->getBreadcrumName($i_cid).'</a> &raquo';
  181.         echo $this->getBreadcrums($i_cid);
  182.         $m = count( $this->breadcrum )-1;
  183.         echo '<div><a href="'.$this->getURL(true).'">Main</a> ';
  184.         if ( $m > 0 ) echo ' &raquo; ';
  185.         foreach ( $this->breadcrum as $index => $value )  {
  186.             if ( $m == $index ) {
  187.                 echo ' &raquo; ';
  188.             }
  189.             echo '<a href="'.$this->getURL(true).'&amp;i_cid='.$value[0].'&amp;i_par='.$value[1].'">'.$value[2].'</a>';
  190.            
  191.         }
  192.         echo '</div>';
  193.     }
  194.  
  195.     function getBreadcrums($i) {
  196.        
  197.         $sql = "SELECT ctitle,cparent FROM mall_category WHERE cid=%d;";
  198.         $sql = sprintf($sql,$i);
  199.         $res = @mysql_query($sql);
  200.         if ( $res === false ) {
  201.             $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  202.         } elseif ( mysql_num_rows($res) == 0 ) {
  203.            
  204.         } else {
  205.             $r = mysql_fetch_assoc($res);
  206.             $this->getBreadcrums($r['cparent']);
  207.             $this->breadcrum[] = array($i,$r['cparent'],$r['ctitle']);
  208.         }
  209.     }
  210.     /*
  211.     * @update   02/02/2009
  212.     * @desc     add an item to a user's cart
  213.     * @param    int $iid
  214.     * @return   void
  215.     */
  216.     function addItemToCar($iid) {
  217.         // Check if this item already is in the cart else re raise it
  218.         $sql = "SELECT mc.quantity FROM mall_cart as mc WHERE mc.uid = %d, mc.iid = %d;";
  219.         $sql = sprintf($sql,$this->account_id,$iid);
  220.         $res = @mysql_query($sql);
  221.        
  222.    
  223.         // get some item information (if possible offcourse)
  224.         $sql = "SELECT
  225.                     fs.quantity,
  226.                     fs.payment,
  227.                     fs.price,
  228.                     fs.ref_able,
  229.                     fs.soc_able,
  230.                     mi.item_name,
  231.                     mi.item_type,
  232.                     mi.item_id
  233.                 FROM
  234.                     mall_forsale AS fs
  235.                     Inner Join mall_items AS mi ON mi.iid = fs.iid
  236.                 WHERE
  237.                     fs.sid = %d;
  238.                 ";
  239.         $sql = sprintf($sql,$iid);
  240.         $res = @mysql_query($sql);
  241.         if ( $res === false ) {
  242.             $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  243.         } elseif ( mysql_num_rows($res) == 0 ) {
  244.             echo '<p class="error_block">The given item doesn not exist anymore.</p>';
  245.         } else {
  246.             $r = mysql_fetch_assoc($res);
  247.             $slotnum = $this->getFreeSlot();
  248.             if ( $slotnum == 0 || $slotnum > 160 ) {
  249.                 echo '<p class="error_block">You have no free storage slot(s) available.</p>';
  250.             }
  251.             else {
  252.                 if ( $this->decreaseMoney($r['payment'],$r['price']) === true ) {
  253.                     $sql = "INSERT INTO storage (owner,itemnum,itemtype,refine,slotnum,socketed,count) VALUES (%d,%d,%d,%d,%d,%d,%d);";
  254.                    
  255.                     $sql = sprintf($sql,$this->account_id,$r['item_id'],$r['item_type'],$this->gradeToServerGrade($r['ref_able']),$slotnum,$r['soc_able'],$r['quantity']);
  256.                     $res = @mysql_query($sql);
  257.                     if ( $res === false ) {
  258.                         echo '<p class="error_block">Adding your item to your shoping cast has failed.</p>';
  259.                         $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  260.                         $this->decreaseMoney($r['payment'],-$r['price']); // re-adding the money to the account when failed.
  261.                     } elseif ( mysql_affected_rows() == 1 ) {
  262.                         echo '<p class="ok_block">'.$r['item_name'] . ' has been added to your storage<p>';
  263.                         $sql = "INSERT INTO mall_log (date_purchased,owner,itemname,itemid,itemtype,quantity,price,payment,socket,refine,slot) VALUES
  264.                                 (NOW(),%d,'%s',%d,%d,%d,%d,'%s',%d,%d,%d);";
  265.                         $sql = sprintf($sql,$this->account_id,$r['item_name'],$r['item_id'],$r['item_type'],$r['quantity'],$r['price'],$r['payment'],$r['soc_able'],$r['ref_able'],$slotnum);
  266.                         mysql_query($sql);
  267.                     } else {
  268.                         echo '<p class="error_block">Your item is not added to your storage.</p>';
  269.                         $this->decreaseMoney($r['payment'],-$r['price']); // re-adding the money to the account when failed.
  270.                     }
  271.                 }
  272.             }
  273.         }
  274.     }
  275.    
  276.     /*
  277.     * @update   04/02/2009
  278.     * @desc     Get a free slot
  279.     * @param    void
  280.     * @return   int
  281.     */
  282.     function getFreeSlot() {
  283.         $slotnum = 0;
  284.         $sql = "SELECT slotnum FROM storage WHERE owner=%d;";
  285.         $sql = sprintf($sql,$this->account_id);
  286.         $res = mysql_query($sql);
  287.         while ( $r = mysql_fetch_assoc($res) ) {
  288.             $slots[] = $r['slotnum'];
  289.         }
  290.         for ( $x = 159; $x >= 1; $x--) {
  291.             if ( !in_array($x,$slots) ) {
  292.                 $slotnum = $x;
  293.                 break;
  294.             }
  295.         }
  296.         return $slotnum;
  297.     }
  298.     /*
  299.     * @update   22/01/2009
  300.     * @desc show content of a category
  301.     * @param    int $cid
  302.     * @return   void
  303.     */
  304.     function getItems($cid) {
  305.         $sql = "SELECT
  306.                     fs.sid,
  307.                     fs.price,
  308.                     fs.payment,
  309.                     fs.price,
  310.                     fs.quantity,
  311.                     fs.ref_able,
  312.                     fs.soc_able,
  313.                     i.image,
  314.                     i.item_type,
  315.                     i.item_id,
  316.                     i.item_name,
  317.                     i.item_desc
  318.                 FROM
  319.                     mall_forsale AS fs
  320.                     Inner Join mall_items AS i ON i.iid = fs.iid
  321.                 WHERE
  322.                     fs.cid = %d
  323.                 ;
  324.                 ";
  325.         $sql = sprintf($sql,$cid);
  326.         $res = @mysql_query($sql);
  327.         if ( $res === false ) {
  328.             $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  329.         } elseif ( mysql_num_rows($res) == 0 ) {
  330.             echo '<p class="error_block">Sorry there are no items available for the selected category.</p>';
  331.         } else {
  332.             // maken van table
  333.             $tbl_cat = new table($this->table_prefs);
  334.             $tbl_cat->table_header( array("Item name", "Quantity", "Socket", "Refine", "Payment", "Price", NULL) );
  335.             while ( $r = mysql_fetch_assoc($res) ) {
  336.                 // Keep the header layout in mind or your table will be screwed up... I could built in a check for that but that would just make it havier :)
  337.                 if ( $r['price'] > 0 ) {
  338.                     $params = "'".htmlentities($r['item_name'])."', '".htmlentities($r['quantity'])."', '".htmlentities(number_format($r['price']).' '.$r['payment'])."'";
  339.                    
  340.                     $values = array($r['item_name']. ' <span style="font-size: 0.8em;">('.$r['item_desc']. '</span>)',
  341.                                     $r['quantity'],
  342.                                     ( $r['soc_able'] == 1 ) ? 'Y' : 'N',
  343.                                     ($r['ref_able'] > 0 ) ? 'Grade '.$r['ref_able'] : 'N',
  344.                                     number_format($r['price']).$r['payment'],
  345.                                      '<a href="'.$this->getURL().'&amp;i_pur='.$r['sid'].'" onClick="return conf_purchase('.$params.');">Purchase</a>'
  346.                                     );
  347.                     $tbl_cat->add_values($values, array('valign' => 'top', 'class' => 'type_'.$r['item_id']) );
  348.                 }
  349.             }
  350.             $tbl_cat->printTable();
  351.         }
  352.     }
  353.    
  354.     /*
  355.     * @update   22/01/2009
  356.     * @desc Getting categories and sub categories.
  357.     * @param    int $cid
  358.     * @return   void
  359.     */
  360.     function getCategory($cid = -1) {
  361.         if ( !is_numeric($cid) ) {
  362.             echo '<p class="error_block">Your (sub)category id is invalid.</p>';
  363.         } else {
  364.             $sql = "SELECT
  365.                         c.cid,
  366.                         c.ctitle,
  367.                         c.cdesc,
  368.                         c.cparent
  369.                     FROM
  370.                         mall_category as c
  371.                     WHERE
  372.                         c.cparent = %d AND
  373.                         c.cminlevel <= %d AND
  374.                         c.chidden = 0;
  375.                     ";
  376.             $sql = sprintf($sql,$cid,$this->alevel);
  377.             $res = @mysql_query($sql); // error subpression
  378.             if ( $res === false ) {
  379.                 $this->dbError('Database error, ' .mysql_error(). ' in ' . nl2br($sql) .' <br />');
  380.             } elseif ( mysql_num_rows($res) == 0 ) {
  381.                 if ( isset($_GET['i_par']) && $_GET['i_par'] < 0 )
  382.                     echo '<p class="error_block">Sorry there are no categories available for the selected category.</p>';
  383.                 else
  384.                     $this->getItems($cid);
  385.             } else {
  386.                 $tbl_cat = new table($this->table_prefs);
  387.                 $tbl_cat->table_header( array("Category name", "Sub Categories", "Options") );
  388.                     while ( $r = mysql_fetch_assoc($res) ) {
  389.                         // Keep the header layout in mind or your table will be screwed up... I could built in a check for that but that would just make it havier :)
  390.                         $values = array( $r['ctitle']. ' <span style="font-size: 0.8em;">('.$r['cdesc']. '</span>)',
  391.                                          $this->deep_out($r['cid']),
  392.                                          '<a href="'.$this->getURL().'&amp;i_cid='.$r['cid'].'&amp;i_par='.$r['cparent'].'">View</a>'
  393.                                         );
  394.                         $tbl_cat->add_values($values, array('valign' => 'top') );
  395.                     }
  396.                 $tbl_cat->printTable();
  397.             }
  398.         }
  399.     }
  400.     /*
  401.     * @update   22/01/2009
  402.     * @desc Deep out a category
  403.     * @param    int $cid
  404.     * @return   string $c
  405.     */
  406.     function deep_out($cid) {
  407.         $c = Null;
  408.         $sql = "SELECT
  409.                     c.cid,
  410.                     c.ctitle,
  411.                     c.cparent
  412.                 FROM
  413.                     mall_category as c
  414.                 WHERE
  415.                     c.cparent = %d AND
  416.                     c.cminlevel <= %d AND
  417.                     c.chidden = 0;
  418.                 ";
  419.         $sql = sprintf($sql,$cid,$this->alevel);
  420.         $res = @mysql_query($sql); // error subpression
  421.         if ( $res === false ) { 
  422.             // ah shame, but no hard feelings acutaly
  423.         } elseif ( mysql_num_rows($res) == 0 ) {
  424.             // already set
  425.             $c = 'None available';
  426.         } else {
  427.             while ( $r = mysql_fetch_assoc($res) ) {
  428.                 $c .= '<a href="'.$this->getURL().'&amp;i_cid='.$r['cid'].'&amp;i_par='.$r['cparent'].'">'.$r['ctitle'].'</a> <br />';
  429.             }
  430.         }
  431.         return $c;
  432.     }
  433.     /*
  434.     * @update   22/01/2009
  435.     * @desc get a url
  436.     * @param    none
  437.     * @return   string $s
  438.     */
  439.     function getURL($bSkip = false) {
  440.         if ( isset($_GET) ) {
  441.         $i = 0;
  442.         $s = NULL;
  443.         $skip = array('i_cid', 'i_fid','i_pur','i_del', 'i_par');
  444.         $skip_a = array('i_pur');
  445.             foreach ( $_GET AS $index => $waarde ) {
  446.                 if ( (in_array($index,$skip) && $bSkip === true ) || in_array($index,$skip_a) ) {
  447.                
  448.                 } else {
  449.                     $s .= ($i==0) ? '?'.$index.'='.$waarde : '&amp;'.$index.'='.$waarde;
  450.                     $i++;
  451.                 }
  452.             }
  453.         return $s;
  454.         }
  455.     }
  456.     /*
  457.     * @update   04/02/2009
  458.     * @desc     Make some kind of log to track when, how many times a user has bought something
  459.     * @param    string itemname, int itemid, int itemtype, int quantity, int price, string payment, int socket, int refine
  460.     * @return   void
  461.     */
  462.     function addTransactionToLog($itemname,$itemid,$itemtype,$quantity,$price,$payment,$socket,$refine,$slot) {
  463.         if ( $this->log === true ) {
  464.             $sql = "INSERT INTO mall_log (date_purchased,owner,itemname,itemid,itemtype,quantity,price,payment,socket,refine,slot) VALUES
  465.                     (NOW(),%d,'%s',%d,%d,%d,%d,'%s',%d,%d,%d);";
  466.             $sql = sprintf($sql,$this->account_id,$itemname,$itemid,$itemtype,$quantity,$price,$payment,$socket,$refine,$slot);
  467.             echo $sql;
  468.             $res = mysql_query($sql);
  469.         }
  470.     }
  471.     /*
  472.     * @update   04/02/2009
  473.     * @desc give a grade (0-9) and the function wil convert it in a useable grade to work with for the server (that it will acutaly be refined)
  474.     * @param    int grade
  475.     * @return   int server_grade
  476.     */
  477.     function gradeToServerGrade($grade) {
  478.         $RefiningGrades = array(0 => 0, 1 => 16, 2 => 32, 3 => 48, 4 => 64, 5 => 80, 6 => 96, 7 => 112, 8 => 128, 9 => 144);
  479.        
  480.         if ( $RefiningGrades[$grade] != null ) {
  481.             $server_grade = $RefiningGrades[$grade];
  482.         }
  483.         else {
  484.             $server_grade = 0;
  485.         }
  486.             return $server_grade;
  487.     }
  488.     function dbError($msg) {
  489.         // GM only
  490.         if ( $this->alevel >= 300 )
  491.             echo '<p clas="error_block">DB ERROR: ' .$msg .'</p>';
  492.     }
  493. }
  494. ?>


so shall i need to put my account id? or its automatic when you logon in userpanel

Rifke wrote:
  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.  

i can't see anything, its a blank
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

Postby skyflakes on Fri Aug 28, 2009 12:46 pm

just two files for item_mall?

how will the players get a points and how will they pay like, after paying they will get the points automaticaly to buy some items in itemmall.?
skyflakes
Pomic
Pomic
 
Posts: 90
Joined: Mon Aug 20, 2007 2:33 am

Re: Item mall V2

Postby Rifke on Fri Aug 28, 2009 2:30 pm

@skyflakes
This one just handles the item mall. The rest it up to you to distrubute the user's donation points.


@Mike567
What is this line
  1.  
  2. $item_mall->setaccount_id( $_SESSION['82'] ); // set the users account ID
  3.  


That isn't right...

It should be
  1.  
  2. $item_mall->setaccount_id( $_SESSION['account_id'] ); // set the users account ID
  3.  


The following piece of code is for admin use only.. It is used for adding donation points to a user. And should therefore only be used for that purpose

File: add_dpts.php

  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']) && 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=add_dpts">
  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.  
Last edited by Rifke on Mon Sep 14, 2009 12:29 pm, edited 2 times in total.
Rifke
Pero pero
Pero pero
 
Posts: 719
Joined: Thu Aug 09, 2007 3:01 pm
Location: Belgium

Re: Item mall V2

Postby JaBbAr on Mon Aug 31, 2009 12:08 pm

XD, wrong message...

it all are working fine. thnx
JaBbAr
Jelly Bean
Jelly Bean
 
Posts: 10
Joined: Fri Aug 28, 2009 1:42 pm

Re: Item mall V2

Postby hellmaster on Thu Sep 03, 2009 7:41 am

what should i do 1st to have an item mall.. on my website T_T is there something package file or a file that i will just extract and paste to my files so that i can use the item mall?
hellmaster
Little soul
Little soul
 
Posts: 6
Joined: Fri Aug 28, 2009 12:45 am

Re: Item mall V2

Postby Mike567 on Fri Sep 04, 2009 4:55 pm

hi, rifke

what i need to changed so i can use nb_donation in accounts table and not donation
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

Postby Rifke on Fri Sep 04, 2009 7:20 pm

Just search the main file (itemmall_v2.php) for donation and change it manualy to nb_donation, make sure you have every SQL statement covered!


hellmaster wrote:what should i do 1st to have an item mall.. on my website T_T is there something package file or a file that i will just extract and paste to my files so that i can use the item mall?

Just the main package from the main post!?
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 Sep 05, 2009 7:12 pm

when i go http://localhost/itemmal_v2.php then i click the category its say
http://localhost/&i_cid=2&i_par=1

EDIT:nvm its need http://localhost/index1.php?op=itemmall_v2
btw, rifke can you give me the auto logout when you closed the page?

EDIT:ohhh its auto logout, btw thnx for this great and friendly item mall :D
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: Item mall V2

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

Well normaly it isn't auto logout... But if you close your browser it is... Tell me when it doesn't work and I'll upload some with an auto-logout.
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 5 guests

cron