Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $dbservertype='mysql';
  4. $servername='localhost';
  5. $dbusername='root';
  6. $dbpassword='';
  7. $dbname='itemdb';
  8.  
  9. connecttodb($servername,$dbname,$dbusername,$dbpassword);
  10. function connecttodb($servername,$dbname,$dbuser,$dbpassword)
  11. {
  12. global $link;
  13. $link=mysql_connect ("$servername","$dbuser","$dbpassword");
  14. if(!$link){die("Could not connect to MySQL");}
  15. mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
  16. }
  17.  
  18. $quantitynew=$_GET['quantitynew'];
  19. $id=$_GET['id'];
  20. $realmselect=$_GET['realm'];
  21. $itemtype=$_GET['itemtype'];
  22. $quantity=$_GET['quantity'];
  23. $pass=$_GET['password'];
  24. $itemname=$_GET['itemname'];
  25. $account=$_GET['account'];
  26. $mule=$_GET['mule'];
  27.  
  28. if ($realmselect=="East Softcore Ladder")
  29. {
  30. $realmselect2="items_east_ladder";
  31. //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
  32. $result=mysql_query("SELECT * FROM $realmselect2 WHERE id='$id'");
  33. while($row = mysql_fetch_array($result))
  34. {
  35. $skupostfix=$row['storesku'];
  36.  
  37.  
  38. }
  39.  
  40.  
  41. }
  42.  
  43. if ($realmselect=="East Hardcore Ladder"){
  44. $realmselect2="items_easthc_ladder";}
  45.  
  46. if ($realmselect=="West Softcore Ladder"){
  47. $realmselect2="items_west_ladder";}
  48.  
  49. if ($realmselect=="West Hardcore Ladder"{
  50. $realmselect2="items_westhc_ladder";}
  51.  
  52. if ($realmselect=="Europe Softcore Ladder")
  53. {
  54. $realmselect2="items_euro_ladder";
  55. echo $realmselect2;
  56. }
  57.  
  58. if ($realmselect=="Europe Hardcore Ladder")
  59. {
  60. $realmselect2="items_eurohc_ladder";
  61. echo $realmselect2;
  62. }
  63.  
  64. if ($quantitynew >="0")
  65. {
  66.  
  67. mysql_select_db("itemdb",$link) or die ("could not open db".mysql_error());
  68. echo "Quantity Updated to " . $quantitynew . "<a href=\"item_list.php?realm=$realmselect&itemtype=$itemtype\" target=\"view_items\">refresh</a> that page.";
  69. mysql_query("UPDATE $realmselect2 SET quantity = '$quantitynew'
  70. WHERE id = '$id'");
  71.  
  72. mysql_query("UPDATE $realmselect2 SET pass = '$pass'
  73. WHERE id = '$id'");
  74.  
  75. mysql_query("UPDATE $realmselect2 SET mule = '$mule'
  76. WHERE id = '$id'");
  77.  
  78. mysql_query("UPDATE $realmselect2 SET account = '$account'
  79. WHERE id = '$id'");
  80.  
  81.  
  82. //This is where we will hunt down all the entries an add them all up
  83. $result=mysql_query("SELECT * FROM $realmselect2 WHERE id='$id'");
  84. while($row = mysql_fetch_array($result))
  85. {
  86. $itemnametmp=$row['item_name'];
  87. $count=0;
  88. $result=mysql_query("SELECT * FROM $realmselect2 WHERE item_name='$itemnametmp'");
  89. while($row = mysql_fetch_array($result))
  90. {
  91.  
  92. $tmpcount=$row['quantity'];
  93. $fullitemcount+=$tmpcount;
  94. }
  95. }
  96.  
  97. //We now change the database over to magento
  98. //Connect to magento and fetch the products id #
  99. if(!$link)
  100. {
  101. die("Could not connect to MySQL");
  102. }
  103. mysql_select_db("d2loot",$link) or die ("could not open db".mysql_error());
  104. $result=mysql_query("SELECT * FROM catalog_product_entity WHERE sku='$skufull'");
  105. while($row = mysql_fetch_array($result))
  106. {
  107. $magsku=$row['entity_id'];
  108. }
  109. //Update Mangeto Stock with the products id
  110. mysql_query("UPDATE cataloginventory_stock_item SET qty = '$fullitemcount'
  111. WHERE product_id = '$magsku'");
  112. }
  113.  
  114.  
  115. echo "<form name=\"ksdb\" method=\"GET\" action=\"edititem.php\">";
  116. echo "Mule #:<input type=\"text\" value=\"$mule\" name=\"mule\"><br />";
  117. echo "Account: <input type=\"text\" value=\"$account\" name=\"account\"><br />";
  118. echo "Pass: <input type=\"text\" value=\"$pass\" name=\"password\"><br />";
  119. echo "Quantity: <input type=\"text\" value=\"$quantity\" name=\"quantitynew\"><br />";
  120. echo "<input type=\"hidden\" value=\"$id\" name=\"id\">";
  121. echo "<input type=\"hidden\" value=\"$realmselect\" name=\"realm\">";
  122. echo "<input type=\"hidden\" value=\"$itemtype\" name=\"itemtype\">";
  123. echo "<input type=\"submit\" value=\"Update\">";
  124. echo "</form>"
  125. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement