Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $dbservertype='mysql';
- $servername='localhost';
- $dbusername='root';
- $dbpassword='';
- $dbname='itemdb';
- connecttodb($servername,$dbname,$dbusername,$dbpassword);
- function connecttodb($servername,$dbname,$dbuser,$dbpassword)
- {
- global $link;
- $link=mysql_connect ("$servername","$dbuser","$dbpassword");
- if(!$link){die("Could not connect to MySQL");}
- mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
- }
- $quantitynew=$_GET['quantitynew'];
- $id=$_GET['id'];
- $realmselect=$_GET['realm'];
- $itemtype=$_GET['itemtype'];
- $quantity=$_GET['quantity'];
- $pass=$_GET['password'];
- $itemname=$_GET['itemname'];
- $account=$_GET['account'];
- $mule=$_GET['mule'];
- if ($realmselect=="East Softcore Ladder")
- {
- $realmselect2="items_east_ladder";
- //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
- $result=mysql_query("SELECT * FROM $realmselect2 WHERE id='$id'");
- while($row = mysql_fetch_array($result))
- {
- $skupostfix=$row['storesku'];
- }
- }
- if ($realmselect=="East Hardcore Ladder"){
- $realmselect2="items_easthc_ladder";}
- if ($realmselect=="West Softcore Ladder"){
- $realmselect2="items_west_ladder";}
- if ($realmselect=="West Hardcore Ladder"{
- $realmselect2="items_westhc_ladder";}
- if ($realmselect=="Europe Softcore Ladder")
- {
- $realmselect2="items_euro_ladder";
- echo $realmselect2;
- }
- if ($realmselect=="Europe Hardcore Ladder")
- {
- $realmselect2="items_eurohc_ladder";
- echo $realmselect2;
- }
- if ($quantitynew >="0")
- {
- mysql_select_db("itemdb",$link) or die ("could not open db".mysql_error());
- echo "Quantity Updated to " . $quantitynew . "<a href=\"item_list.php?realm=$realmselect&itemtype=$itemtype\" target=\"view_items\">refresh</a> that page.";
- mysql_query("UPDATE $realmselect2 SET quantity = '$quantitynew'
- WHERE id = '$id'");
- mysql_query("UPDATE $realmselect2 SET pass = '$pass'
- WHERE id = '$id'");
- mysql_query("UPDATE $realmselect2 SET mule = '$mule'
- WHERE id = '$id'");
- mysql_query("UPDATE $realmselect2 SET account = '$account'
- WHERE id = '$id'");
- //This is where we will hunt down all the entries an add them all up
- $result=mysql_query("SELECT * FROM $realmselect2 WHERE id='$id'");
- while($row = mysql_fetch_array($result))
- {
- $itemnametmp=$row['item_name'];
- $count=0;
- $result=mysql_query("SELECT * FROM $realmselect2 WHERE item_name='$itemnametmp'");
- while($row = mysql_fetch_array($result))
- {
- $tmpcount=$row['quantity'];
- $fullitemcount+=$tmpcount;
- }
- }
- //We now change the database over to magento
- //Connect to magento and fetch the products id #
- if(!$link)
- {
- die("Could not connect to MySQL");
- }
- mysql_select_db("d2loot",$link) or die ("could not open db".mysql_error());
- $result=mysql_query("SELECT * FROM catalog_product_entity WHERE sku='$skufull'");
- while($row = mysql_fetch_array($result))
- {
- $magsku=$row['entity_id'];
- }
- //Update Mangeto Stock with the products id
- mysql_query("UPDATE cataloginventory_stock_item SET qty = '$fullitemcount'
- WHERE product_id = '$magsku'");
- }
- echo "<form name=\"ksdb\" method=\"GET\" action=\"edititem.php\">";
- echo "Mule #:<input type=\"text\" value=\"$mule\" name=\"mule\"><br />";
- echo "Account: <input type=\"text\" value=\"$account\" name=\"account\"><br />";
- echo "Pass: <input type=\"text\" value=\"$pass\" name=\"password\"><br />";
- echo "Quantity: <input type=\"text\" value=\"$quantity\" name=\"quantitynew\"><br />";
- echo "<input type=\"hidden\" value=\"$id\" name=\"id\">";
- echo "<input type=\"hidden\" value=\"$realmselect\" name=\"realm\">";
- echo "<input type=\"hidden\" value=\"$itemtype\" name=\"itemtype\">";
- echo "<input type=\"submit\" value=\"Update\">";
- echo "</form>"
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement