\n"; echo "
Please specify the database admin user at Admin
\n"; echo "\n"; die(""); } if(!mysql_select_db(Settings::value("DBNAME"))){ echo "
\n"; echo "
Could not select the specified database ". Settings::value("DBNAME") .".
\n"; echo "
\n"; mysql_close($connId); die(""); } if($manu > 0){ if($_GET["action"] == "delete"){ # the queued manufacturer should be deleted. # therefore delete also all mins which references this manufacturer # and not needed min types # start transaction if(!mysql_query("BEGIN")){ mysql_close($connId); echo "Could not delete manufacturer (Could not start transaction).
\n"; echo "\n"; echo ""; mysql_close($connId); exit; } if(!mysql_query("DELETE FROM manufacturerhasmins_queue WHERE manufacturersId=". $manu)){ echo "Could not delete manufacturer (Could delete all related queued MINs).
\n"; echo "\n"; echo ""; mysql_query("ROLLBACK"); mysql_close($connId); exit; } # remove not needed mintypes if(!mysql_query("DELETE FROM mintypes_queue WHERE id NOT IN (SELECT mintypesId FROM manufacturerhasmins_queue)")){ echo "Could not delete manufacturer (Could not remove queued MIN-Types).
\n"; echo "\n"; echo ""; mysql_query("ROLLBACK"); mysql_close($connId); exit; } if(!mysql_query("DELETE FROM manufacturers_queue WHERE id=". $manu)){ echo "Could not delete manufacturer (Could delete manufacturer).
\n"; echo "\n"; echo ""; mysql_query("ROLLBACK"); mysql_close($connId); exit; } mysql_query("COMMIT"); echo "\n"; echo "\n"; echo ""; mysql_close($connId); exit; } if($manufacturersid > 0){ # $manu is the same manufacturer as the already stored one at $manufacturersid if(!mysql_query("UPDATE manufacturers_queue SET manufacturersId=". $manufacturersid ." WHERE id=". $manu)) echo "Could not associate the selected manufacturers.
\n"; else{ echo "\n"; } echo "\n"; echo ""; mysql_close($connId); exit; } if(array_key_exists("storemanu", $_POST)){ # store the manufacturer $query = sprintf( "INSERT INTO manufacturers (name, street, number, city, postalCode, postOfficeBox, country, website, email, phone, fax) VALUES('%s', '%s', '%s', '%s', %s, %s, '%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string(stripText($_POST["manuname"])), mysql_real_escape_string(stripText($_POST["manustreet"])), mysql_real_escape_string(stripText($_POST["manunumber"])), mysql_real_escape_string(stripText($_POST["manucity"])), mysql_real_escape_string($_POST["manuzip"]), mysql_real_escape_string($_POST["manupostofficebox"]), mysql_real_escape_string(stripText($_POST["manucountry"])), mysql_real_escape_string(Manufacturer::prepareWebsite(stripText($_POST["manuwebsite"]))), mysql_real_escape_string(stripText($_POST["manuemail"])), mysql_real_escape_string(stripText($_POST["manuphone"])), mysql_real_escape_string(stripText($_POST["manufax"])) ); if(!mysql_query($query)){ echo "Could not store manufacturer (Could not insert)"; mysql_close($connId); echo "\n"; echo ""; exit; } # get id of new manufacturer $name = mysql_real_escape_string($_POST["manuname"]); $result = mysql_query("SELECT id FROM manufacturers WHERE name='". $name ."'"); if(!$result){ echo "Could not store manufacturer (Could not fetch new id)"; mysql_close($connId); echo "\n"; echo ""; exit; } $id = 0; $result = mysql_fetch_object($result); if($result){ if($result->id > 0) $id = $result->id; } if($id < 1){ echo "Could not store manufacturer (New id < 1)"; mysql_close($connId); echo "\n"; echo ""; exit; } # insert soundexes $manufacturer = new Manufacturer($name); $manufacturer->setId($id); if(!insertSoundexes($manufacturer, true)){ echo "Could not store the selected manufacturer (Could not insert soundexes).
\n"; echo "\n"; echo ""; mysql_close($connId); exit; } # set the new id as manufacturersId at the manufacturer_queue # $manu is the same as $manufacturersid if(!mysql_query("UPDATE manufacturers_queue SET manufacturersId=". $id ." WHERE id=". $manu)){ echo "Could not store the selected manufacturer.
\n"; } else{ echo "\n"; } echo "\n"; echo ""; mysql_close($connId); exit; } $res = mysql_query("SELECT * FROM manufacturers_queue WHERE id=". $manu); if(!$res){ die(""); } $manu = mysql_fetch_object($res); $manus = matchManufacturer($manu->name); $maxManus = 10; if($manus){ if(count($manus) > 0){ echo "Found "; if(count($manus) > $maxManus) echo $maxManus ." of ". count($manus); else echo count($maxManus); echo " possible Manufacturers:\n"; echo "\n"; $i = 0; foreach(array_keys($manus) as $score){ foreach(array_keys($manus[$score]) as $key){ if($i == $maxManus) break 2; echo " \n"; echo " \n"; echo " \n"; $i++; } } echo "
\n"; echo " ". $manus[$score][$key]; echo " ". $score ."% ("; echo "Use"; echo ")\n"; echo "
\n"; } } echo "
\n"; echo " id ."\">\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
". _("Name") .":name ."\" autofocus required>
". _("Address") .":\n"; echo " street ."\">\n"; echo " number ."\">
". _("City") .":city ."\">
". _("ZIP") .":postalCode ."\">
". _("Post Office Box") .":postOfficeBox ."\">
". _("Country") .":country ."\">
". _("Website") .":website ."\">
". _("E-Mail") .":email ."\">
". _("Phone") .":phone ."\">
". _("Fax") .":fax ."\">
\n"; echo "
\n"; echo "\n"; echo ""; mysql_close($connId); exit; } ?>