Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.91 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. echo $itemname;
  34. //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
  35. $result=mysql_query("SELECT * FROM items_east_ladder WHERE item_name='$itemname'");
  36. while($row = mysql_fetch_array($result))
  37. {
  38. $skupostfix=$row['storesku'];
  39. }
  40. //Next we need to find all instances of this entry and add them up!
  41. // End of getting the sku
  42.  
  43. if ($realmselect=="East Softcore Ladder")
  44. {
  45. $realmselect2="items_east_ladder";
  46. echo $realmselect2;
  47. $skufull= "ESCL" . $skupostfix;
  48.  
  49. }
  50.  
  51. if ($realmselect=="East Hardcore Ladder")
  52. {
  53. $realmselect2="items_easthc_ladder";
  54. echo $realmselect2;
  55. }
  56.  
  57. if ($realmselect=="West Softcore Ladder")
  58. {
  59. $realmselect2="items_west_ladder";
  60. echo $realmselect2;
  61. }
  62.  
  63. if ($realmselect=="West Hardcore Ladder")
  64. {
  65. $realmselect2="items_westhc_ladder";
  66. echo $realmselect2;
  67. }
  68.  
  69. if ($realmselect=="Europe Softcore Ladder")
  70. {
  71. $realmselect2="items_euro_ladder";
  72. echo $realmselect2;
  73. }
  74.  
  75. if ($realmselect=="Europe Hardcore Ladder")
  76. {
  77. $realmselect2="items_eurohc_ladder";
  78. echo $realmselect2;
  79. }
  80.  
  81.  
  82.  
  83. //We now change the database over to magento
  84. //Connect to magento and fetch the products id #
  85. if(!$link)
  86. {
  87. die("Could not connect to MySQL");
  88. }
  89. mysql_select_db("d2loot",$link) or die ("could not open db".mysql_error());
  90. $result=mysql_query("SELECT * FROM catalog_product_entity WHERE sku='$skufull'");
  91. while($row = mysql_fetch_array($result))
  92. {
  93. $magsku=$row['entity_id'];
  94. }
  95.  
  96.  
  97. //End of connect to magento and fetch products id #
  98.  
  99. //Connect to magento and update items stock using id#
  100. mysql_query("UPDATE cataloginventory_stock_item SET qty = '$quantitynew'
  101. WHERE product_id = '$magsku'");
  102. echo $magsku;
  103. echo "<br>LINE BREAK<br>";
  104. echo $skufull;
  105. echo $skupostfix;
  106. //End of Connect to magento and update items stock using id#
  107.  
  108.  
  109.  
  110.  
  111.  
  112. //Connect to itemdb again
  113. if(!$link)
  114. {
  115. die("Could not connect to MySQL");
  116. }
  117. mysql_select_db("itemdb",$link) or die ("could not open db".mysql_error());
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. if ($quantitynew >="0")
  134. {
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. echo "Quantity Updated to " . $quantitynew . "<a href=\"item_list.php?realm=$realmselect&itemtype=$itemtype\" target=\"view_items\">refresh</a> that page.";
  147. mysql_query("UPDATE $realmselect2 SET quantity = '$quantitynew'
  148. WHERE id = '$id'");
  149.  
  150. mysql_query("UPDATE $realmselect2 SET pass = '$pass'
  151. WHERE id = '$id'");
  152.  
  153. mysql_query("UPDATE $realmselect2 SET mule = '$mule'
  154. WHERE id = '$id'");
  155.  
  156. mysql_query("UPDATE $realmselect2 SET account = '$account'
  157. WHERE id = '$id'");
  158. //Add To Log
  159. //mysql_query("INSERT INTO log (id,user, item_name,mule,acc-ount,pass,quantity)
  160. //VALUES ('', '$itemtype', '$itemname', '$mule','$account','$pass','$quantity')");
  161. //echo '<script type="text/javascript">window.close()</script>';
  162.  
  163. }
  164.  
  165.  
  166. echo "<form name=\"ksdb\" method=\"GET\" action=\"edititem.php\">";
  167.  
  168. //echo "Item: <input type=\"text\" value=\"$itemname\" name=\"itemname\">";
  169. echo "Mule #:<input type=\"text\" value=\"$mule\" name=\"mule\"><br />";
  170. echo "Account: <input type=\"text\" value=\"$account\" name=\"account\"><br />";
  171. echo "Pass: <input type=\"text\" value=\"$pass\" name=\"password\"><br />";
  172. echo "Quantity: <input type=\"text\" value=\"$quantity\" name=\"quantitynew\"><br />";
  173.  
  174.  
  175. echo "<input type=\"hidden\" value=\"$id\" name=\"id\">";
  176. echo "<input type=\"hidden\" value=\"$realmselect\" name=\"realm\">";
  177. echo "<input type=\"hidden\" value=\"$itemtype\" name=\"itemtype\">";
  178. echo "<input type=\"hidden\" value=\"$itemname\" name=\"itemname\">";
  179. echo "<input type=\"submit\" value=\"Update\">";
  180. echo "</form>"
  181.  
  182.  
  183.  
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement