$texte = '=';
// hack pour IE
$texte = strlen($texte) > 10 ? $texte : str_pad($texte, 10);
for ($i = 0; $i <= 5; $i++){
sleep(1); // pour simuler l'exécution de ton code
echo $texte;
flush();
}
80 secondes, ben mon vieux quel script! (ou quel serveur!)...voir combien de temps prenait le script. j'ai environ 80 s ....
J'ai le souvenir d'avoir eu le même problème. Après recherches sur le net j'ai trouvé que IE n'affiche les flush() que si il y a un minimum de caractères. D'où mon hack plus haut. Essaye d'augmenter le nombre d'espaces insérés dans str_pad().Rien ne s'affiche avant la fin de l'exécution du script. J'ai même forcé une erreur sur la 1ère ligne pour qu'elle soit affiché dés le début de l'exécution.
Ca affiche sur FF mais rien sur IE.
Tu ne fais quand même pas 55000 requêtes MySQL en boucle?Quant au 80-90 s pris par le script... Je sais pas trop s'il est optimisé. J'ai fait une boucle qui lit une ligne dans un fichier avec fgets() et qui appelle ensuite une fonction qui analyse le contenu du buffer et en extrait les infos que j'ai besoin, puis le contenu alimente une requête MySQL qui sauve le contenu dans la base., et ainsi de suite.
Le fichier que je traite actuellement a plus de 55000 lignes..
// get language
if (!isset($_GET['lang']))
{ include "en.php";
$lang="en";
}
else
{ include $_GET['lang'].".php";
$lang=explode (".",$_GET['lang']);
$lang=$lang[0];
}
// make a connection to database
include "connectdb.php";
// init some variables
$NbQso=0;
$dateday=date("Y-m-d");
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// | function adif2qsl
// | to extract fields from a valid ADIF line and insert it in the MySQL database
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function adif2sql ($string)
{ // start of function adif2sql
// setting function variables
global $NbQso;
global $error;
$error="";
$string=strtoupper($string);
// to limit the number of lines to be read
// line must at least be not empty and have and end of record tag + CALL field
// if an important field is missing, we set a flag , so we do not import the QSO and display the line as error
if ( $string != "\n" && $string != "\r\n" && stristr($string, "<CALL:") && stristr($string,"<EOR>"))
{
// extracting date if found
// 2 formats possible
// else there is a problem
if ($x = stristr($string,"<QSO_DATE:8:D>"))
{ //eregi ("<QSO_DATE:([0-9]+):([A-Z]+)>([0-9]+)",$x,$regs);
//list($null,$length,$type,$adifdate)=$regs;
//$adifdate=substr($adifdate,0,$length);
$x = sscanf ($x, "<QSO_DATE:8:D>%s ",$adifdate);
$adifdate = substr($adifdate,0,8);
$date=substr($adifdate,0,4)."-".substr($adifdate,4,2)."-".substr($adifdate,6,2);
}
elseif ($x = stristr($string,"<QSO_DATE:8>"))
{ $x = sscanf ($x, "<QSO_DATE:8>%s ",$adifdate);
$adifdate = substr($adifdate,0,8);
$date=substr($adifdate,0,4)."-".substr($adifdate,4,2)."-".substr($adifdate,6,2);
}
else {$error="NO DATE HEADER";}
// Extract time is found
// 4 formats possible
// else there is a problem
if ($x = stristr($string,"<TIME_ON:6>"))
{ $x = sscanf ($x, "<TIME_ON:6>%s ",$adiftime);
$adiftime = substr($adiftime,0,6);
$time=substr($adiftime,0,2).":".substr($adiftime,2,2).":".substr($adiftime,4,2);
}
elseif ($x = stristr($string,"<TIME_ON:4>"))
{ $x = sscanf ($x, "<TIME_ON:4>%s ",$adiftime);
$adiftime = substr($adiftime,0,4);
$time=substr($adiftime,0,2).":".substr($adiftime,2,2).":00";
}
elseif ($x = stristr($string,"<TIME_ON:6:T>"))
{ $x = sscanf ($x, "<TIME_ON:6:T>%s",$adiftime);
$adiftime = substr($adiftime,0,6);
$time=substr($adiftime,0,2).":".substr($adiftime,2,2).":".substr($adiftime,4,2);
}
elseif ($x = stristr($string,"<TIME_ON:4:T>"))
{ $x = sscanf ($x, "<TIME_ON:4:T>%s",$adiftime);
$adiftime = substr($adiftime,0,4);
$time=substr($adiftime,0,2).":".substr($adiftime,2,2).":00";
}
else {$error="NO TIME HEADER";}
// extracting callsign if found
// else there is a problem
if ($x = stristr($string,"<CALL"))
{ $x = sscanf ($x, "<CALL:%d>%s ",$length,$adifcall);
$callsign = substr($adifcall,0,$length);
}
// extracting mode if found
// else there is a problem
if ($x = stristr($string,"<MODE"))
{ $x = sscanf ($x, "<MODE:%d>%s ",$length,$adifmode);
$mode = substr ($adifmode,0,$length);
}
else {$error="NO MODE HEADER";}
// Extracting BAND if present
// if not check is FREQ is present
// if not, then there is a problem
if ($x = stristr($string,"<BAND"))
{ $x = sscanf ($x, "<BAND:%d>%s ",$length,$adifband);
$band = substr($adifband,0,$length);
}
elseif ($x = stristr($string,"<FREQ"))
{ $x = sscanf ($x, "<FREQ:%d>%s ",$length,$adifreq);
$freq = substr($adifreq,0,$length);
// case 1800-2000
if (ereg('^1.8',$freq)) { $band = "160M"; }
// case 3.5-3.8
elseif (ereg('^3',$freq)) { $band = "80M"; }
// case 7.0-7.2
elseif (ereg('^7',$freq)) { $band = "40M"; }
// case 10
elseif (ereg('^10',$freq)) { $band = "30M"; }
// case 14-14.350
elseif (ereg('^14',$freq)) { $band = "20M"; }
// case 18
elseif (ereg('^18',$freq)) { $band = "17M"; }
// case 21-21.4
elseif (ereg('^21',$freq)) { $band = "15M"; }
// case 24
elseif (ereg('^24',$freq)) { $band = "12M"; }
// case 28-29.7
elseif (ereg('^28',$freq)) { $band = "10M"; }
// case 144-148
elseif (ereg('^144',$freq)) { $band = "2M"; }
}
else
{ $error="NO BAND HEADER";
}
// Extracting QSL received
// if QSL_RCVD field found, than extract data
// if not we assume no QSL was received
if ($x = stristr($string,"<QSL_RCVD"))
{ $x = sscanf ($x, "<QSL_RCVD:%d>%s ",$length,$qslrcvd);
$qsl_rcvd = substr($qslrcvd,0,$length);
}
else
{ $qsl_rcvd="N"; }
// Extracting QSL sent
// if QSL_SENT field found, than extract data
// if not we assume no QSL was SENT
if ($x = stristr($string,"<QSL_SENT"))
{ $x = sscanf ($x, "<QSL_SENT:%d>%s ",$length,$qslsent);
$qsl_sent = substr($qslsent,0,$length);
}
else
{$qsl_sent="N";}
// Extracting rst received when field is found
// else there is a problem
if ($x = stristr($string,"<RST_RCVD"))
{ $x = sscanf ($x, "<RST_RCVD:%d>%s ",$length,$rstrcvd);
$rst_rcvd = substr($rstrcvd,0,$length);
}
else {$error="NO RST_RCVD HEADER";}
// Extracting rst received if found
// else there is a problem
if ($x = stristr($string,"<RST_SENT"))
{ $x = sscanf ($x, "<RST_SENT:%d>%s ",$length,$rstsent);
$rst_sent = substr($rstsent,0,$length);
}
else {$error="NO RST_SENT HEADER";}
// extracting QSLSDATE
// 2 formats possible
// not critical so no error generated
if ($x = stristr($string,"<QSLSDATE:8>"))
{ $x = sscanf ($x, "<QSLSDATE:8>%s",$adifdate);
$adifdate = substr($adifdate,0,8);
$qslsdate=substr($adifdate,0,4)."-".substr($adifdate,4,2)."-".substr($adifdate,6,2);
}
elseif ($x = stristr($string,"<QSLSDATE:8:D>"))
{ $x = sscanf ($x, "<QSLSDATE:8:D>%s ",$adifdate);
$adifdate = substr($adifdate,0,8);
$qslsdate=substr($adifdate,0,4)."-".substr($adifdate,4,2)."-".substr($adifdate,6,2);
}
// extracting QSLRDATE
// 2 formats possible
// not critical so no error generated
if ($x = stristr($string,"<QSLRDATE:8:D>"))
{ $x = sscanf ($x, "<QSLRDATE:8:D>%s ",$adifdate);
$adifdate = substr($adifdate,0,8);
$qslrdate=substr($adifdate,0,4)."-".substr($adifdate,4,2)."-".substr($adifdate,6,2);
}
elseif ($x = stristr($string,"<QSLRDATE:8>"))
{ $x = sscanf ($x, "<QSLRDATE:8>%s ",$adifdate);
$adifdate = substr($adifdate,0,8);
$qslrdate=substr($adifdate,0,4)."-".substr($adifdate,4,2)."-".substr($adifdate,6,2);
}
// uncomment for displaying result for test
// echo $NbQso." ".$date." ".$time." ".$callsign." ".$band." ".$mode." ".$rst_rcvd." ".$rst_sent." ".$qsl_rcvd." ".$qsl_sent."<BR>";
// if no errors found we save the QSO in the MySQL database and increment the number of valid QSO found
if ($error == "")
{ // build MySQL query and execute
$query = "INSERT INTO log_".$_GET['logname']." SET date='".$date."', time='".$time."', callsign='".$callsign."', band='".$band."', mode='".$mode."', qsl_rcvd='".$qsl_rcvd."', qsl_sent='".$qsl_sent."', rst_rcvd='".$rst_rcvd."', rst_sent='".$rst_sent."', date_sent='".$qslsdate."', date_rcvd='".$qslrdate."'";
$query=mysql_query($query) or die (mysql_error());
// increment number of QSO found in file
$NbQso++;
}
}
} // end of function adif2sql ***********************
// +++++++++++++++++++++++++++
// | start of main program
// +++++++++++++++++++++++++++
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
<meta content='text/html; charset=ISO-8859-1' http-equiv='content-type'>
<title>Logbook Admin page</title>
<link href='weblog.css' rel='stylesheet' type='text/css'>
</head>
<body background='weblog_bg.jpg'>
<br>
<div align='center'><img src='weblog_title.jpg'><br></div>";
if ( !isset($_GET['logname']) || $_GET['logname'] == "" )
{ die($nocallset); }
else
{ $adifile=$_GET['logname'].".ADI";
$startTime = array_sum(explode(" ",microtime())); // start calculation of ellapsed time
// check if this file is an ADIF file
// by looking for <EOR> or <CALL: in first 20 lines, if not found it is certainly not an ADIF file
$fh = fopen($adifile, 'r') or die($filenotfound);
$i=0;
while ( $i<=20 )
{ $buffer=fgets($fh);
if (stristr($buffer, "<CALL:") && stristr($buffer,"<EOR>")) { $ValidAdifFile=1; }
$i++;
}
fclose($fh);
if ( $ValidAdifFile==1 ) // if it's a valid ADIF file then proceed
{
echo "
<table border='0' cellspacing='0' cellpadding='0' class='medium' align='center'>
<tr><td class='medium' colspan='2'>".$startconv1.$adifile.$startconv2.$_GET['logname']."</td></tr>
<tr><td height='10' bgcolor='#ffffff' colspan='2'><img src='null.gif' width='1' height='10'></td></tr>
<tr><td class='medium' colspan='2'>".$psewait."</td></tr>
<tr><td height='10' bgcolor='' colspan='2'><img src='null.gif' width='1' height='10'></td></tr>";
// open log file
$fh = fopen($adifile, 'r') or die($filenotfound);
// read every line until end of file and proceed conversion
while ( !feof ($fh) )
{
$buffer=fgets($fh); // read line by line
adif2sql($buffer); // call function to convert to MySQL
if ($error != "") // display errors
{ echo "<tr><td class='medium'><font color='red'>".$error." </font></td><td>".$buffer."</td></tr>";
$Nberror++;
}
// update date in database
$query="UPDATE `log_callsigns` SET `updated` = '".$dateday."' WHERE `callsign`='".$_GET['logname']."' LIMIT 1" ;
$result=mysql_query($query) or die (mysql_error());
if ($NbQso % 500 == 0)
{
ob_start();
//$bar = strlen($bar) > 10 ? $bar : str_pad($bar, 10);
echo "|";
//echo "<tr><td>".$bar."</td></tr>";
ob_end_flush();
}
}
}
else
// it's not an ADIF file
{ echo "<tr class='medium'><td>".$warningnotadif."</td></tr>";
}
}
// displaying result
echo "<tr><td height='10' bgcolor='#ffffff' colspan='2'><img src='null.gif' width='1' height='10'></td></tr>";
echo "<tr class='medium'><td colspan='2'>".$NbQso.$convertdone.$txt_but.$Nberror.$errors."</td></tr>";
echo "<tr><td height='10' bgcolor='#ffffff' colspan='2'><img src='null.gif' width='1' height='10'></td></tr>";
echo "<tr class='medium'><td colspan='2'>".$computetime.round((array_sum(explode(' ',microtime())) - $startTime),4)." sec</td></tr>";
echo "<tr><td height='10' bgcolor='#ffffff' colspan='2'><img src='null.gif' width='1' height='10'></td></tr>";
echo"<tr class='medium'><td colspan='2'><a href='admin.php?lang=".$lang."'>".$back2admin."</a></td></tr>
</table>
</body>
</html>";
// close database and file
mysql_close ($connection);
fclose($fh);
Code : Tout sélectionner
1994-01-29;06:06:00;F6KQW/39;80M;CW;Y;Y;599;599;1994-01-29;
1994-01-29;06:08:00;F6BDM/59;80M;CW;Y;Y;599;599;1994-01-29;
1994-01-29;06:09:00;F5JNT/30;80M;CW;N;N;599;599;;
Soit il y a une erreur dans le mot de passe, soit il n'y en a tout simplement pas besoin. Ce n'est pas priori pas un problème de syntaxe. Du reste tu pourrais le vérifier en testant ta requête en ligne dans phpMyAdmin (http://sql.free.fr)"Access denied for user 'tk5ep'@'212.27.63.124' (using password: YES)"
Effectivement, il faut les privilèges FILE.Dans la doc, il est dit qu'il faut que j'ai le privilège file et que le chemin soit bon, je n'ai pas de maîtrise, ni sur l'un ni sur l'autre....