D
Ich bekomme es mit PHP nicht gut hin. Wer kann mir das Script in eine stabile Programmiersprache schreiben??? Mehrfache Ausführung bis ans Limit vom V-Server. Brauche es nur recht zeitnah
<?php
$MySQL_Host="localhost"; //Server
$MySQL_User="root"; //User
$MySQL_Passw="123"; //Passwort
$db="xml_import"; //Datenbank
if (! @$link=mysql_connect("$MySQL_Host","$MySQL_User","$MySQL_Passw")){
echo "Die Verbindung zu ",$MySQL_Host," konnte nicht hergestellt werden<br>";
exit;
}
mysql_select_db($db,$link);
//Datenabrufen
$thread = "1";
//Abfrage0
$abfrage0 = @mysql_query ("SELECT * FROM hosts WHERE status = 1 AND thread_id ='".$thread."'" ,$link);
//Wenn NULL, dann hole host aus Main DB
if (@mysql_num_rows ($abfrage0) == "0"){
//mysql_query ("", $link);
echo "Keine Hosts mehr\n";
}
while ($daten0 = @mysql_fetch_array($abfrage0)){
mysql_query ("INSERT INTO urls (host_id,path,status) VALUES ('".@$daten0[id]."','/','0');", $link);
//Abfrage1
$abfrage1 = @mysql_query ("SELECT * FROM urls WHERE host_id = ".@$daten0[id]." AND status = '0'",$link);
if (@mysql_num_rows ($abfrage1) == "0"){
//mysql_query ("Update hosts SET status = '3' Where id = '".$daten0['id']."';", $link);
echo $daten0['host']." ist fertig\n";
}
while ($daten1 = @mysql_fetch_array($abfrage1)){
set_time_limit (60);
$xmlurl = "http://localhost/xml_export.php?url=http://".$daten0['host'].$daten1['path'];
$xml = simplexml_load_string(file_get_contents($xmlurl));
$hosts = explode(".*|",$xml->filter);
$hosts = str_replace(".*", "", $hosts);
$hosts = array_unique($hosts);
foreach ($hosts as $host){
$host_teile = parse_url($host);
$host_teile['host'] = str_replace("www1.", "www.", @$host_teile['host']);
$host_teile['host'] = str_replace("www2.", "www.", @$host_teile['host']);
$host_teile['host'] = str_replace("www3.", "www.", @$host_teile['host']);
$host= str_replace("www.", "", $daten0['host']);
if (strpos(@$host_teile['host'], ".".$host) !== false){
mysql_query ("INSERT INTO hosts (host,status,thread_id) VALUES ('".@$host_teile['host']."','1','".$thread."');", $link);
}else{
mysql_query ("INSERT INTO hosts (host) VALUES ('".@$host_teile['host']."');", $link);
}
}
$count_intern = 0;
$count= 0;
$urls = explode(";",$xml->sitelist);
$urls = str_replace(";", "", $urls);
$urls = array_unique($urls);
foreach ($urls as $url){
$url_teile = parse_url($url);
if (strpos(@$url_teile['host'], @$daten0['host']) !== false){
$count_intern++;
mysql_query ("INSERT INTO urls (host_id,path) VALUES ('".@$daten0['id']."','".@$url_teile['path']."');", $link);
}
$count++;
}
$count_extern = $count - $count_intern;
mysql_query ("Update urls SET status = '1' Where id = '".$daten1['id']."';", $link);
} //While 1
} //While 0
?>