dirthangel1
Messages postés18Date d'inscriptionsamedi 16 avril 2005StatutMembreDernière intervention20 septembre 2005
-
1 juin 2005 à 06:49
cs_Anthomicro
Messages postés9433Date d'inscriptionmardi 9 octobre 2001StatutMembreDernière intervention13 avril 2007
-
16 juin 2005 à 12:54
Je n'y connais rien en php et je cherche a modifié le script PhpDig version 1.8.8 rc1 pour que le moteur fontionne avec Mysql. Le problème semble venir du fichier robot_functions.php.
Par logique j'ai réussie a déterminier ce qui pose problème
//=================================================
//delete a spider reccord and content file
function phpdigDelSpiderRow($id_connect,$spider_id,$ftp_id='') {
global $relative_script_path,$ftp_id;
$query = "DELETE FROM ".PHPDIG_DB_PREFIX."engine WHERE spider_id=$spider_id";
$result_id = mysql_query($query,$id_connect);
$query = "DELETE FROM ".PHPDIG_DB_PREFIX."spider WHERE spider_id=$spider_id";
$result_id = mysql_query($query,$id_connect);
phpdigDelText($relative_script_path,$spider_id,$ftp_id);
}
//=================================================
//store a content_text from a spider_id
function phpdigWriteText($relative_script_path,$spider_id,$text,$ftp_id='') {
global $br;
if (CONTENT_TEXT == 1) {
$file_text_path = $relative_script_path.'/'.TEXT_CONTENT_PATH.$spider_id.'.txt';
if ($f_handler = @fopen($file_text_path,'wb')) {
$text = phpdigRemoveBreaks(@implode(" ",$text));
$text = phpdigVerifyEnds(mb_substr($text,0,TEXT_STORAGE_AMOUNT));
fwrite($f_handler,$text);
fclose($f_handler);
@chmod($file_text_path,0666);
//here the ftp case
if (FTP_ENABLE) {
$ftp_id = phpdigFtpKeepAlive($ftp_id);
@ftp_delete($ftp_id,$spider_id.'.txt');
$res_ftp = false;
$try_count = 0;
while (!$res_ftp && $try_count++ < 10) {
$res_ftp = @ftp_put($ftp_id,$spider_id.'.txt',$file_text_path,FTP_BINARY);
if (!$res_ftp) {
sleep(2);
}
}
if (!$res_ftp) {
print "Error: ftp_put error ! $br";
}
}
}
else {
print "Warning : Unable to create the content file ! $br";
}
}
return $ftp_id;
}
//=================================================
//delete a content_text from a spider_id
function phpdigDelText($relative_script_path,$spider_id,$ftp_id='') {
if (CONTENT_TEXT == 1) {
$file_text_path = $relative_script_path.'/'.TEXT_CONTENT_PATH.$spider_id.'.txt';
if (@is_file($file_text_path))
@unlink($file_text_path);
//there delete the ftp file
if (FTP_ENABLE && $ftp_id)
@ftp_delete($ftp_id,$spider_id.'.txt');
}
}
//=================================================
//connect to the ftp if the ftp is on and the connection ok.
//the content files are stored locally and could be uploaded
//manually later.
function phpdigFtpConnect()
{if (CONTENT_TEXT 1 && FTP_ENABLE 1) {
$count = 0;
global $br;
while ($count++ < 10) {
//launch connect procedure
if ($ftp_id = ftp_connect(FTP_HOST,FTP_PORT)) {
//login
if (ftp_login ($ftp_id, FTP_USER, FTP_PASS)) {
ftp_pasv ($ftp_id, FTP_PASV);
//echo ftp_pwd($ftp_id);
//change to phpdig directory
if (ftp_chdir ($ftp_id, FTP_PATH)) {
//if content_text doesnt exists, create it
if ([mailto:!@ftp_chdir !@ftp_chdir] ($ftp_id, FTP_TEXT_PATH)) {
ftp_mkdir ($ftp_id, FTP_TEXT_PATH);
ftp_chdir ($ftp_id, FTP_TEXT_PATH);
}
return $ftp_id;
}
}
}
sleep(2);
}
print "Error : Ftp connect failed !".$br;
}
//else return empty string
}
//=================================================
//close the ftp if exists
function phpdigFtpClose($ftp_id) {
if ($ftp_id) {
@ftp_quit($ftp_id);
}
}
//=================================================
//reconnect to ftp if the connexion fails or in case of timout
function phpdigFtpKeepAlive($ftp_id,$relative_script_path=false) {
if (!$ftp_id) {
return phpdigFtpConnect();
}
elseif ([mailto:!@ftp_pwd($ftp_id !@ftp_pwd($ftp_id])) {
phpdigFtpClose($ftp_id);
return phpdigFtpConnect();
}
else {
@ftp_pasv($ftp_id, FTP_PASV);
if ($relative_script_path) {
phpdigWriteText($relative_script_path,'keepalive',array('.'),$ftp_id);
}
return $ftp_id;
}
}
Avec mon niveau inxistant lol j'ai modifier la deuxième fonctions ainsi
// =============================
// Ecriture dans Mysql
function xunWriteText($relative_script_path,$spider_id,$text,$ftp_id='') {
global $br;
if (CONTENT_TEXT ==1) {
$file_text_path = mysql(" SELECT * FROM 'xuntext_content' ORDER BY 'spider_id' ");
dirthangel1
Messages postés18Date d'inscriptionsamedi 16 avril 2005StatutMembreDernière intervention20 septembre 2005 1 juin 2005 à 23:11
Le script est en partie interfacé avec Mysql mais il stocke le texte des pages dans des fichiers txt qui prennent pas mal de place et ralentisse la recherche en plus de faire trainer le serveur en cas de nombreuse requêtes simultané.
Pour ce qui est de contacter les auteurs c'est déjà fait et ce plusieurs fois mais aucune réponse