Item Mall

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

Item Mall

Postby Ultra on Wed Apr 25, 2012 8:11 pm

Hi!
Like i said in my last post im making new cms or layout -> im using only dynastycms scripts like register page,rankings and so on.. <-
So everything works - thanks to hoegarden31..
But the problem is that when i go from the user cp to "Item Mall" it gives me :

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

Re: Item Mall

Postby Ultra on Sat Apr 28, 2012 8:07 pm

Ahm ?? no one??
Ultra
Rackie
Rackie
 
Posts: 226
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Item Mall

Postby Vetyst on Sat Apr 28, 2012 9:06 pm

As far as i know, you are receiving Error 404 a.k.a.( also known as ) (Page) Not Found.

First of all, You should make sure your item mall is at the following Directory:
'"Website Source"/irosetest/web/images/items/'

if it isn't you should edit your item mall location or your web source to fit the locations.
-----
You also gave the source of the item mall, which is the error you receive from your item mall.
By looking at this '&i_cid=14&i_par=12' i can tell you are using the item mall V2 of Rifke, am i correct ?

if thats the case you should make sure the configuration is corrent at the page type.

PS : Are you a Web Developer or are you just using others projects?

-Vetyst
User avatar
Vetyst
osRose dev
osRose dev
 
Posts: 146
Joined: Sat Jun 18, 2011 10:56 am
Location: The Netherlands

Re: Item Mall

Postby Ultra on Sun Apr 29, 2012 11:25 pm

Yes,im using item mall v2
And im not a Web dev at all (im still learning...)
mall.php it is fine .... i have put
  1. require ('config.php');
.. < is arleady in it ..
So from what can be the problem ??
Ultra
Rackie
Rackie
 
Posts: 226
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Item Mall

Postby Vetyst on Mon Apr 30, 2012 9:12 am

Did you change anything inside of the files, exept their config ?
And is your database setup fine ?
User avatar
Vetyst
osRose dev
osRose dev
 
Posts: 146
Joined: Sat Jun 18, 2011 10:56 am
Location: The Netherlands

Re: Item Mall

Postby Ultra on Mon Apr 30, 2012 9:38 am

Yea everything...
I think it is so because is only for dynasty cms ...
- Like i said im using only the functions folder and some scripts...
But im not using dynastycms..
Ultra
Rackie
Rackie
 
Posts: 226
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Item Mall

Postby Ultra on Sat May 05, 2012 4:20 pm

no one??????
Ultra
Rackie
Rackie
 
Posts: 226
Joined: Thu Jul 22, 2010 6:31 pm
Location: Usa

Re: Item Mall

Postby hoegarden31 on Sat May 05, 2012 9:17 pm

Give us the code from the user cp... looks like you point your link into the image folder ... :shock:
I'm the one and only. In heaven and on earth.
Image
hoegarden31
Rackie
Rackie
 
Posts: 150
Joined: Sun Nov 13, 2011 7:13 pm

Re: Item Mall

Postby Ultra on Sun May 06, 2012 9:54 pm

nope it is not from that ...
It is in the images folder xD
usercp:
  1. <?php
  2. /*
  3. DynastyCMS
  4. Copyrigt (C) 2007 dynastycms
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19. */
  20. session_start();
  21. if(!session_is_registered(User_Name)) {
  22. die('You must log in you noob!');
  23. }
  24.  
  25. if(!session_is_registered(User_Pass)) {
  26. die('You must log in you noob!');
  27. }
  28. ?>
  29. <form action="?op=edit-char" method="post">
  30.  <p align="center" class="b01">Welcome: <?php echo $_SESSION['account']; ?><strong><br />
  31.     <br />
  32.     </strong>
  33.    <br />
  34.  
  35.  
  36.   <br />
  37.   <em><br />  
  38.     </em><a href="password">Change Password</a><br />
  39.     <a href="cuser-delete">Delete my character</a><br />
  40.     <a href="delete_acc">Delete my account</a><br />
  41.     <a href="mall">Item Mall </a><br />
  42.   <a href="logout">Logout</a></p>
  43. </form>
  44.  </p></p>
  45.  


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

Re: Item Mall

Postby observe on Mon Jun 11, 2012 1:36 pm

Ultra wrote:
  1. /irosetest/web/images/items/&i_cid=14&i_par=12 was not found on this server
  2.  



pretty much the first [GET] variable should start with ? instead of &
observe
osRose dev
osRose dev
 
Posts: 194
Joined: Thu Sep 17, 2009 10:28 am
Location: The Netherlands

Next

Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 3 guests