Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $dbservertype='mysql';
  4. $servername='localhost';
  5. // username and password to log onto db server
  6. $dbusername='root';
  7. $dbpassword='';
  8. // name of database
  9. $dbname='itemdb';
  10.  
  11. ////////////////////////////////////////
  12. ////// DONOT EDIT BELOW /////////
  13. ///////////////////////////////////////
  14. connecttodb($servername,$dbname,$dbusername,$dbpassword);
  15. function connecttodb($servername,$dbname,$dbuser,$dbpassword)
  16. {
  17. global $link;
  18. $link=mysql_connect ("$servername","$dbuser","$dbpassword");
  19. if(!$link){die("Could not connect to MySQL");}
  20. mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
  21. }
  22. //////// End of connecting to database ////////
  23.  
  24. $quantitynew=$_GET['quantitynew'];
  25. $id=$_GET['id'];
  26. $realmselect=$_GET['realm'];
  27. $itemtype=$_GET['itemtype'];
  28. $quantity=$_GET['quantity'];
  29. $pass=$_GET['password'];
  30. $itemname=$_GET['itemname'];
  31. $account=$_GET['account'];
  32. $mule=$_GET['mule'];
  33.  
  34. if ($realmselect=="East Softcore Ladder")
  35. {
  36. $realmselect2="items_east_ladder";
  37. //We now need to get the SKU of the product we are adding from itemdb before we add it! VERSION 2 Which Updates The Store DB if Sku == 0 we need to skip this step
  38. $result=mysql_query("SELECT * FROM $realmselect2 WHERE id='$id'");
  39. while($row = mysql_fetch_array($result))
  40. {
  41. $skupostfix=$row['storesku'];
  42.  
  43.  
  44. }
  45. //This is where we will hunt down all the entries an add them all up
  46. $result=mysql_query("SELECT * FROM $realmselect2 WHERE id='$id'");
  47. while($row = mysql_fetch_array($result))
  48. {
  49. $itemnametmp=$row['item_name'];
  50.  
  51. $result=mysql_query("SELECT * FROM $realmselect2 WHERE item_name='$itemnametmp'");
  52. while($row = mysql_fetch_array($result))
  53. {
  54.  
  55. $tmpcount=$row['quantity'];
  56. $num = (int)$tmpcount;
  57. $count=$count+$num;
  58. echo $count;
  59.  
  60. //echo $count;
  61.  
  62. }
  63. //END OF This is where we will hunt down all the entries and add them all up
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70. //Next we need to find all instances of this entry and add them up!
  71. // End of getting the sku
  72. }
  73.  
  74. if ($realmselect=="East Hardcore Ladder")
  75. {
  76. $realmselect2="items_easthc_ladder";
  77. echo $realmselect2;
  78. }
  79.  
  80. if ($realmselect=="West Softcore Ladder")
  81. {
  82. $realmselect2="items_west_ladder";
  83. echo $realmselect2;
  84. }
  85.  
  86. if ($realmselect=="West Hardcore Ladder")
  87. {
  88. $realmselect2="items_westhc_ladder";
  89. echo $realmselect2;
  90. }
  91.  
  92. if ($realmselect=="Europe Softcore Ladder")
  93. {
  94. $realmselect2="items_euro_ladder";
  95. echo $realmselect2;
  96. }
  97.  
  98. if ($realmselect=="Europe Hardcore Ladder")
  99. {
  100. $realmselect2="items_eurohc_ladder";
  101. echo $realmselect2;
  102. }
  103.  
  104. if ($quantitynew >="0")
  105. {
  106.  
  107.  
  108. //We now change the database over to magento
  109. //Connect to magento and fetch the products id #
  110. if(!$link)
  111. {
  112. die("Could not connect to MySQL");
  113. }
  114. mysql_select_db("d2loot",$link) or die ("could not open db".mysql_error());
  115. $result=mysql_query("SELECT * FROM catalog_product_entity WHERE sku='$skufull'");
  116. while($row = mysql_fetch_array($result))
  117. {
  118. $magsku=$row['entity_id'];
  119. }
  120.  
  121.  
  122. //End of connect to magento and fetch products id #
  123.  
  124. //Connect to magento and update items stock using id#
  125. mysql_query("UPDATE cataloginventory_stock_item SET qty = '$quantitynew'
  126. WHERE product_id = '$magsku'");
  127. //End of Connect to magento and update items stock using id#
  128.  
  129.  
  130. //Connect to itemdb again
  131. if(!$link)
  132. {
  133. die("Could not connect to MySQL");
  134. }
  135. mysql_select_db("itemdb",$link) or die ("could not open db".mysql_error());
  136. echo "Quantity Updated to " . $quantitynew . "<a href=\"item_list.php?realm=$realmselect&itemtype=$itemtype\" target=\"view_items\">refresh</a> that page.";
  137. mysql_query("UPDATE $realmselect2 SET quantity = '$quantitynew'
  138. WHERE id = '$id'");
  139.  
  140. mysql_query("UPDATE $realmselect2 SET pass = '$pass'
  141. WHERE id = '$id'");
  142.  
  143. mysql_query("UPDATE $realmselect2 SET mule = '$mule'
  144. WHERE id = '$id'");
  145.  
  146. mysql_query("UPDATE $realmselect2 SET account = '$account'
  147. WHERE id = '$id'");
  148. //Add To Log
  149. //mysql_query("INSERT INTO log (id,user, item_name,mule,acc-ount,pass,quantity)
  150. //VALUES ('', '$itemtype', '$itemname', '$mule','$account','$pass','$quantity')");
  151. //echo '<script type="text/javascript">window.close()</script>';
  152.  
  153. }
  154.  
  155.  
  156. echo "<form name=\"ksdb\" method=\"GET\" action=\"edititem.php\">";
  157.  
  158. //echo "Item: <input type=\"text\" value=\"$itemname\" name=\"itemname\">";
  159. echo "Mule #:<input type=\"text\" value=\"$mule\" name=\"mule\"><br />";
  160. echo "Account: <input type=\"text\" value=\"$account\" name=\"account\"><br />";
  161. echo "Pass: <input type=\"text\" value=\"$pass\" name=\"password\"><br />";
  162. echo "Quantity: <input type=\"text\" value=\"$quantity\" name=\"quantitynew\"><br />";
  163.  
  164.  
  165. echo "<input type=\"hidden\" value=\"$id\" name=\"id\">";
  166. echo "<input type=\"hidden\" value=\"$realmselect\" name=\"realm\">";
  167. echo "<input type=\"hidden\" value=\"$itemtype\" name=\"itemtype\">";
  168. echo "<input type=\"submit\" value=\"Update\">";
  169. echo "</form>"
  170.  
  171.  
  172.  
  173. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement