PHP 脚本不断执行 mmap/munmap
我的 PHP 脚本包含一个循环,它只不过是回显和取消引用指针(如 $tab[$othertab[$i]]-> 中的内容)。
直到昨天,这个脚本开始变得非常慢(比以前慢了 50 倍)之前,它一直工作得很好。
使用 strace 后,我发现 90% 的情况下,脚本会执行 mmap/munmap。 这是 strace 日志的随机部分:
mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0152b000 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac014ea000
这是 strace -c 命令的结果:
% time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 82.77 0.004092 0 13542 mmap 9.69 0.000479 0 3642 write 7.54 0.000373 0 13541 munmap 0.00 0.000000 0 100 read 0.00 0.000000 0 88 poll 0.00 0.000000 0 25 4 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.004944 30938 4 total
这是 php 脚本:
function affAnnonce($tabAnnonces, $isDoublon = 0)
{
GLOBAL $db, $base, $tabDomaine, $doublon, $traduction, $tab_contrat, $tab_emploi, $tab_categ,
$tab_metier, $tab_region, $tab_departement, $tab_secteur, $tab_experience, $calc_all, $tabLangues, $tabLanguesNiveau, $tabNoAffAnnonce, $tabHisto;
foreach($tabAnnonces AS $tmp) {
if (in_array($tmp['id'], $tabNoAffAnnonce) === true) {
continue;
}
$value->host = "../";
foreach($tabDomaine AS $domaine => $valeur) {
if ($domaine == $tmp['domaine']) {
$value->host = $valeur->host;
break;
}
}
// Ordre
// secteur;metier;contrat;emploi;region;langues;domaine
$tabPushModif = array();
if ($tmp['push_preview'] != '') {
$tabPushModif = explode(';', $tmp['push_preview']);
$tabPushModif['secteur'] = $tabPushModif[0];
$tabPushModif['metier'] = $tabPushModif[1];
$tabPushModif['contrat'] = $tabPushModif[2];
$tabPushModif['id_emploi'] = $tabPushModif[3];
$tabPushModif['regions'] = $tabPushModif[4];
$tabPushModif['langues'] = $tabPushModif[5];
$tabPushModif['domaine'] = $tabPushModif[6];
}
$infoSoc = get_nom_societe($tmp['id_societe']);
$number = ($tmp['nb_preview_push'] != '' ? $tmp['nb_preview_push'] : ' ');
$secteurs = explode ("/", $tmp[secteur]);
$sector = "";
$count_sect = count($secteurs);
for ($k = 0; $k < $count_sect; $k++) {
if ($secteurs[$k] != '') {
$sector .= $tab_secteur[$secteurs[$k]].'/';
}
}
$tmp['poste'] = apresinsertion($tmp['poste']);
$tmp['metier'] = $tab_metier[$tmp['metier']];
$tmp['region'] = $tab_region[$tmp['region']];
$tmp['departement'] = $tab_departement[$tmp['departement']];
$tmp['secteur'] = $sector;
$tmp['id_contrat'] = $tmp['contrat'];
$tmp['contrat'] = $tab_contrat[$tmp['contrat']];
$tmp['emploi'] = $tab_emploi[$tmp['id_emploi']];
$tmp['categorie'] = $tab_categ[$tmp['categorie']];
echo '<tr id="'.($isDoublon ? 'dbl_' : '').$tmp['id'].'"><td align="center" class="tdFirst nowrap dbl_'.$tmp['id'].'" id="aff_'.$tmp['id'].'"';
switch($tmp['affiche']) {
case '0': echo ' bgcolor=#DBB7FF'; break;
default : ;
}
echo '><a href=?op=annonces&search4='.$tmp[id].' target=_new>'.$tmp[id].'</a><br />';
echo '<a href="'.$value->host.'" target="blank">'.strtoupper($tmp['domaine']).'<br /><img src="../images/flags/'.$tmp['domaine'].'.png" border=0 align=middle></a>';
echo '</TD><TD align=center class=tdNext';
if ($tmp['filtre'] == 1)
echo ' bgcolor=#FF0000';
echo '>';
if ($isDoublon)
echo '<a id="'.$tmp['id'].'" class="doublon" href="#">DOUBLON</a> - ';
if (($tmp[id_reponse] == 1) || ($tmp[id_reponse] == 2) || ($tmp[id_reponse] == 4) || ($tmp[id_reponse] == 5))
echo '<a href="javascript:voir_annonce(\''.$tmp['id'].'\', \''.$value->host.'\')" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">'.$tmp['poste'].'</a>';
if ($tmp[id_reponse] == 3)
echo '<a href="javascript:voir_annonce3(\''.$tmp['url_reponse'].'\')" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">'.$tmp['poste'].'</a>';
if ($tmp['urgent'] == 1)
print " - <font class=r_bold>urgent</font>";
if ($tmp['gold'] == 1)
print " - <font class=g_bold>gold</font>";
if ($tmp['cvtheque'] == 1)
print " - CVthèque";
if ($tmp['url_reponse'] != '' && $tmp['id_reponse'] != 3) {
echo '<br /><br />URL - ';
$len = strlen($tmp['url_reponse']);
if ($len > 50) {
$link = substr($tmp['url_reponse'], 0, 47).'...';
} else {
$link = $tmp['url_reponse'];
}
echo '<a href="'.$tmp['url_reponse'].'" style="color: #666;" target="_blank">'.$link.'</a>';
}
// Début du div ou sera placé l'annonce
echo '<br /><div id="preview_'.$tmp['id'].'" name="preview_'.$tmp['id'].'" class="tdStyle1" style="z-index: 1000; display: none; position: fixed; left: 0px; top: 0px; padding: 4px; border: 1px solid #666; background: #fff; text-align: left; width: 777px;" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">';
$tmp["url"] = substr($tmp["url"], 7);
$id_modele = getIdModeleByAnnonce($tmp['id_societe'], $tmp["id"], $tmp['domaine']);
$tmp["poste"] = mb_strtoupper($tmp["poste"]);
$isFnh = isFnhAnnonce($tmp['id']);
$logo = "";
if ($isFnh) {
$logo_jpg = getFnhLogo();
$logo = "<img align='center' border='0' src='".$logo_jpg."' />";
} else {
if ($id_modele > 0) {
if ($tmp['id_reponse'] == 1) {
$logo_gif = "../fichiers/societes/".$tmp['id_societe']."/".$id_modele.".gif";
if (file_exists($logo_gif)) {
$logo = "<img align=center border=0 src=".$logo_gif.">";
}
}
else
{
$rep = "../fichiers/societes/".$tmp['id_societe']."/".$id_modele;
$logo_jpg = $rep.".jpg";
$logo_swf = $rep.".swf";
$logo_gif = $rep.".gif";
if (file_exists($logo_jpg)) {
$logo = "<img align=center border=0 src=".$logo_jpg.">";
}
elseif (file_exists($logo_swf))
$logo = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="120" height="600">
<param name=movie value="'.$logo_swf.'">
<param name=quality value=high>
<embed src="'.$logo_swf.'"
quality=high
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="120" height="600"></embed>
</object>';
elseif (file_exists($logo_gif)) {
$logo = "<img align=center border=0 src=".$logo_gif.">";
}
}
}
}
if (strlen($logo) > 0 && strlen($tmp['url']) > 0)
$logo = "<a href=http://".$tmp['url']." target=_blank>".$logo."</a>";
if (strlen($tmp['url_reponse']) <= 0) {
$tmp['url_reponse'] = "../jobs/repondre_annonce.php?id=".$tmp['id']."\" onClick=\"";
if ($tmp['contact_email'] == "")
$tmp['url_reponse'] .= "alert('".$traduction->aff_word("repondre_courrier", $tabTrad['only_word']).'\n'.$tmp['societe'].'\n'.str_replace("<br />", '\n', ereg_replace("[\r\n\t]", "", $tmp['adresse']))."');";
else
$tmp['url_reponse'] .= "popUp(this.href, 'scroll', 540, 400);";
$tmp['url_reponse'] .= "return false;";
}
?>
<table width="775" cellspacing="0" cellpadding="0" border=0>
<? if ($tmp['id_reponse'] != "2") { ?>
<tr>
<td width="575" align=center valign=top>
<table width="535" border=0 cellspacing=0 cellpadding=2>
<tr>
<td colspan="2" class="nom_societe"><?=$tmp['societe']?></td>
</tr>
<tr>
<td colspan="2"><hr size=1 color=#000000></td>
</tr>
<tr>
<td colspan="2" align="right"><?=date_2fr($tmp["date_affichage"], 1)?></td>
</tr>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("pays")?> :</td>
<td align="left"><?=$tmp['pays0']?></td>
</tr>
<?
if ($tmp['region']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("region")?> :</td>
<td align="left"><?=$tmp['region']?></td>
</tr>
<? }
if ($tmp['departement']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("departement")?> :</td>
<td align="left"><?=$tmp['departement']?></td>
</tr>
<? }
if ($tmp['ville']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("ville")?> :</td>
<td align="left"><?=$tmp['ville']?></td>
</tr>
<? }
if ($tmp['debut']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("debut_travail")?> :</td>
<td align="left"><?=$tmp['debut']?></td>
</tr>
<? } ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("type_contrat")?> :</td>
<td align="left"><?=$tmp['contrat']?></td>
</tr>
<?
if ($tmp['emploi']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("type_emploi")?> :</td>
<td align="left"><?=$tmp['emploi']?></td>
</tr>
<? }
if ($tmp['salaire']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("salaire")?> :</td>
<td align="left"><?=$tmp['salaire']?></td>
</tr>
<? }
if ($tmp['experience']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("experience_metier")?> :</td>
<td align="left"><?=$tab_experience[$tmp['experience']]?></td>
</tr>
<? }
if ($tmp['reference']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("reference")?> :</td>
<td align="left"><?=$tmp['reference']?></td>
</tr>
<? } ?>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<?
if ($tmp['presentation']) { ?>
<tr>
<td valign=top align="right" class=bold><?=$traduction->aff_word("presentation")?> :</td>
<td style="text-align: justify;"><?=$tmp['presentation']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? } ?>
<tr>
<td valign="top" class=bold align="right"><?=$traduction->aff_word("poste")?> :</td>
<td valign="top" class=titre_poste align=center><?=$tmp['poste']?></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td valign="top" class=bold align="right"><?=$traduction->aff_word("description")?> :</td>
<td style="text-align: justify;"><?=$tmp['description']?></td>
</tr>
<tr>
<td width=100%> </td>
<td width=405><hr size=1 color=#000000 width=405></td>
</tr>
<?
if ($tmp['profil']) { ?>
<tr>
<td valign="top" align="right" class=bold><?=$traduction->aff_word("profil")?> :</td>
<td valign="top" style="text-align: justify;"><?=$tmp['profil']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? }
if ($tmp['recommandation']) { ?>
<tr>
<td valign="top" align="left"></td>
<td valign="top" style="text-align: justify;"><?=$tmp['recommandation']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? }
if ($tmp['contact_nom'] || $tmp['contact_prenom']) { ?>
<tr>
<td valign="top" align="right" class=bold><?=$traduction->aff_word("contact")?> :</td>
<td valign="top" align="left"><?=$tmp['contact_prenom']?> <?=$tmp['contact_nom']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? } ?>
<? } elseif ($tmp['domaine'] != 'de') { ?>
<tr>
<td colspan=2><table width="755" align=right valign=top><tr><td><?=$tmp['presentation']?></td></tr></table></td>
</tr>
<? } ?>
<tr>
<td rowspan=6> </td>
<td><a href="<?=$tmp['url_reponse']?>" target="_blank">>> <?=$traduction->aff_word("repondre_en_ligne")?></a></td>
</tr>
<tr>
<td><a href="../jobs/affiche_imprime_annonce.php?id=<?=$tmp['id']?>" onClick="popUp(this.href, 'scroll', 540, 400);return false;" target="_blank">>> <?=$traduction->aff_word("version_imprimer")?></a></td>
</tr>
<tr>
<td><a href="../jobs/send_friend_annonce.php?id=<?=$tmp['id']?>" onClick="popUp(this.href, 'clean', 400, 300);return false;" target="_blank">>> <?=$traduction->aff_word("envoi_ami")?></a></td>
</tr>
<tr>
<td><a href="./affiche_liste.php?soc=<?=$tmp['societe_clean']?>">>> <?=$traduction->aff_word("toutes_offres")?> <?=$tmp['societe']?></a></td>
</tr>
<tr>
<td><a href="../jobs/index.php">>> <?=$traduction->aff_word("nouvelle_recherche")?></a></td>
</tr>
<tr>
<td><a href="../jobs/index.php" onClick="javascript:retour(); return false;"><< <?=$traduction->aff_word("retour")?></a></td>
</tr>
<? if ($tmp['id_reponse'] != "2") { ?>
</table>
</td>
<td width="200" align=center class=black_bord valign=top>
<table width="190" cellspacing=0 cellpadding=0 border=0>
<tr>
<td colspan="2" align="center" valign="top" class=bold><? if ($tmp['id_reponse'] != "5") { ?><br><? } ?><?=$logo?><br><br><?=$tmp['societe']?></td>
</tr>
<?
if ($tmp['adresse']) { ?>
<tr>
<td align="center" colspan=2><?=$tmp['adresse']?></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<? }
if ($tmp['contact_tel']) { ?>
<tr>
<td class=bold align=right><?=$traduction->aff_word("tel")?> :</td>
<td align=center><?=$tmp['contact_tel']?></td>
</tr>
<? }
if ($tmp['contact_fax']) { ?>
<tr>
<td class=bold align=right><?=$traduction->aff_word("fax")?> :</td>
<td align=center><?=$tmp['contact_fax']?></td>
</tr>
<? }
if ($tmp['url']) { ?>
<tr>
<td colspan=2 align=center><a href="http://<?=$tmp['url']?>" target="_blank"><?=$tmp['url']?></a></td>
</tr>
<? } ?>
</table>
</td>
</tr>
<? } ?>
</table>
<?
echo '</div>';
// Fin du div ou sera placé l'annonce
echo "</TD><TD align=center class=tdNext><b>".date_2fr($tmp['date_creation'], 1)."</b><br>".date_2fr($tmp['date_affichage'], 1);
echo "</TD><TD align=center class=tdNext>".$tmp[societe]."<br>(<i><a href=".$value->host."login/login.php?login=".$infoSoc->email."&pass=".$infoSoc->password." target=_blank>".$infoSoc->nom."</a></i>)<br><a href=index.php?op=entreprise&ac=tableau_bord&id_societe=".$tmp['id_societe'].">compte</a></TD>";
$color = '';
switch($tmp[push_mail]) {
case "0": $color = " bgcolor=#DBB7FF"; break;
case "2": $color = " bgcolor=#CCCCCC"; break;
default : ;
}
$type_rep = "";
switch ($tmp[id_reponse]) {
case 1:
$type_rep = "Standard";
break;
case 2:
$type_rep = "Chartée";
break;
case 3:
$type_rep = "Metamoteur";
break;
case 4:
$type_rep = "Reponse sur site";
break;
case 5:
$type_rep = "Semi-chartée";
break;
}
print "
<td align=center class=tdNext>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td align=center class=cadreBas>".$tmp['contrat']." - ".$tmp['emploi']."</td>
<td $color align=center rowspan=4 width=40%>
<a onclick=\"javascript:colorannonce(this, '#CFFFCF');\" href=?op=agentalertes&action=modify_push&id_annonce=".$tmp[id]." target=_blank>Modifier push</a><br><br>
<a onclick=\"sendPush(this, ".$tmp['id']."); return false;\" href=\"#\">Envoyer Push</a>
</td>
</tr>
<tr>
<td align=center class=cadreBas>".(strlen($tmp['metier']) > 0 ? $tmp['metier'] : '<font class=gris_i>'.$tmp['categorie'].'</font>')."</td>
</tr>
<tr>
<td align=center class=cadreBas>".$tmp[secteur]."</td>
</tr>
<tr>
<td align=center>".($number < 500 ? '<font color="red">' : ($number > 1500 ? '<font color="orange">' : '<font color="green">')).$number."</font></td>
</tr>
</table>
</td>
<td align=center class=tdNext>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td align=center class=cadreBas>";
if (strlen($tabPushModif['regions']) > 0) {
$tab = explode('/', $tabPushModif['regions']);
foreach($tab AS $elem) {
if (strlen($elem) <= 0)
continue;
if (strpos($elem, 'dep-') !== false) {
echo $tab_departement[substr($elem, 4)];
$query_tmp = 'SELECT region FROM ref_departement WHERE id = "'.substr($elem, 4).'"';
$obj = $db->getObj($query_tmp);
if ($obj) {
echo ' - '.$tab_region[$obj->region];
$query_tmp = 'SELECT rp.code_pays FROM ref_pays rp INNER JOIN ref_region rr ON rr.pays = rp.id WHERE rr.id = "'.$obj->region.'"';
$obj = $db->getObj($query_tmp);
if ($obj)
echo ' ('.$obj->code_pays.')';
}
}
elseif (is_numeric($elem) === false) {
echo '<font class=gris_i>'.$tmp['departement'].' - '.$tmp['region'].'</font> ('.$elem.')';
}
else
{
echo '<font class=gris_i>'.$tmp['departement'].'</font> - '.$tab_region[$elem];
$query_tmp = 'SELECT rp.code_pays FROM ref_pays rp INNER JOIN ref_region rr ON rr.pays = rp.id WHERE rr.id = "'.$obj->region.'"';
$obj = $db->getObj($query_tmp);
if ($obj)
echo ' ('.$obj->code_pays.')';
}
}
}
else
echo $tmp['departement']." - ".$tmp['region']." (".$tmp['code_pays'].")";
echo "</td>
</tr>
<tr>
<td align=center class=cadreBas>".$tmp[ville]."</td>
</tr>
<tr>
<td align=center class=cadreBas>";
if (strlen($tabPushModif['metier']) > 0) {
$tmpExp = array();
$tab = explode('/', $tabPushModif['metier']);
foreach($tab AS $elem) {
if (strlen($elem) <= 0)
continue;
$tmpMetier = explode('-', $elem);
if (isset($tmpMetier[1])) {
if (in_array($tmpMetier[1], $tmpExp) === true)
continue;
$tmpExp[] = $tmpMetier[1];
if ($tmpMetier[1] == $tmp['experience'])
echo '<b>'.$tab_experience[$tmpMetier[1]].'</b>/';
else
echo $tab_experience[$tmpMetier[1]].'/';
}
}
if (count($tmpExp) <= 0)
echo '<font class=gris_i>'.$tab_experience[$tmp['experience']].'</font>';
}
else
echo $tab_experience[$tmp['experience']];
echo "</td>
</tr>
<tr>
<td align=center>".$tabLangues[$tmp['id_langue']]->langue." - ".$tabLanguesNiveau[$tmp['id_langue_niveau']]->langue_niveau."</td>
</tr>
</table>
</td>
<td align=center class=tdNext>
<table width=100% cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=center class=cadreBas>$type_rep</td>
</tr>
<tr>
<td align=center>".$tmp[compteur_vu]." / <a href=?op=gcand&ac=liste&id_annonce=".$tmp[id]."&statut=all target=_new>".$tmp[compteur_repondu]."</a></td>
</tr>
</table>
</td>
<td align=center class=tdNext>
<table width=100% cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=center class=cadreBas><a href=?op=annonces&ac=modifier&id_annonce=".$tmp['id']." target=_new>Modifier</a></td>
</tr>
<tr>
<td align=center class=cadreBas><a href='' onClick=\"valid_delete('".$tmp['id']."'); return false;\">Supprimer</a></td>
</tr>
<tr>
<td align=center><a href='' onClick='changeAff(".$tmp['id']."); return false;' id='changeAff_".$tmp['id']."'>".($tmp['affiche'] == 1 ? 'Mettre hors ligne' : 'Mettre en ligne')."</a></td>
</tr>
</table>
</td>
<td align=center class='tdNext gris'>
<p style=\"color:#444;\">
".nl2br($tmp['push_res']).'</p>';
if (is_array($tabHisto[$tmp['id']])) {
echo '<p style="color:#888; padding-top:5px;">';
foreach($tabHisto[$tmp['id']] as $histo) {
echo $histo['type_modif'].' '.HumanDateTime($histo['date']).' par '.$histo['user'];
if ($histo['new_annonce']) {
echo ' [New ID : <a href="index.php?op=annonces&search4='.$histo['new_annonce'].'">'.$histo['new_annonce'].'</a>]';
}
echo '<br />';
}
echo '</p>';
}
echo "
</td>
<td align=center> ".$tmp['source'];
if (!empty($tmp['source_ref'])) {
echo '<br /><a href="redirect.php?site='.$tmp['source_ref'].'" target="_blank">Voir original</a>';
}
echo '</td></tr>';
if (isset($doublon) && !$isDoublon) {
$query2 = " SELECT a.*, rp.pays0, rp.code_pays
FROM annonces a
INNER JOIN ref_pays rp ON rp.id = a.pays
WHERE a.id_societe = '".$tmp['id_societe']."'
AND a.contrat = '".$tmp['id_contrat']."'
AND a.domaine = '".$tmp['domaine']."'
AND a.id != '".$tmp['id']."'
AND ADDDATE(a.date_creation, INTERVAL 2 MONTH) > '".$tmp['date_creation']."'
AND a.poste = \"".addslashes($tmp['poste'])."\"
AND a.ville = \"".addslashes($tmp['ville'])."\"
AND a.societe = \"".addslashes($tmp['societe'])."\"
AND (a.id_societe != 1
OR (a.id_societe = 1 AND a.contact_email = \"".$tab_annonce['contact_email']."\"))
ORDER BY a.id DESC";
$tabAnnonces2 = $db->getTab($query2);
if (count($tabAnnonces2) > 0) {
$tabId = array();
foreach($tabAnnonces2 as $annonc) {
$tabId[] = $annonc['id'];
}
$tmpListAnnonceTab = annoncelist::getHistorique($tabId);
$tmpTabHisto = createTabHisto($tmpListAnnonceTab);
$tabHisto += $tmpTabHisto; //Additionne les 2 tableaux, contrairement à array_merge il garde les clés !!
affAnnonce($tabAnnonces2, 1);
foreach($tabAnnonces2 AS $tmpAnn)
$tabNoAffAnnonce[] = $tmpAnn['id'];
}
}
}
}
?>
只有这个脚本很慢,同一服务器/域/目录上的所有其他脚本都工作得很好。 在其他服务器上,相同的脚本可以正常工作。 该脚本运行时占用 CPU 高达 90%。
有什么想法吗?
My PHP script contains a loop, which does nothing much more than echoing and dereferencing pointers (like in $tab[$othertab[$i]]-> stuff).
It was working great until yesterday, when this script starting being VERY slow (like 50 times slower than before).
After using strace, i figured out that 90% of the time, the script does mmap/munmap.
Here is a random portion of the strace log :
mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 munmap(0x7fac0156c000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0156c000 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac0152b000 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fac014ea000
Here is the result of the strace -c command :
% time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 82.77 0.004092 0 13542 mmap 9.69 0.000479 0 3642 write 7.54 0.000373 0 13541 munmap 0.00 0.000000 0 100 read 0.00 0.000000 0 88 poll 0.00 0.000000 0 25 4 access ------ ----------- ----------- --------- --------- ---------------- 100.00 0.004944 30938 4 total
Here is the php script :
function affAnnonce($tabAnnonces, $isDoublon = 0)
{
GLOBAL $db, $base, $tabDomaine, $doublon, $traduction, $tab_contrat, $tab_emploi, $tab_categ,
$tab_metier, $tab_region, $tab_departement, $tab_secteur, $tab_experience, $calc_all, $tabLangues, $tabLanguesNiveau, $tabNoAffAnnonce, $tabHisto;
foreach($tabAnnonces AS $tmp) {
if (in_array($tmp['id'], $tabNoAffAnnonce) === true) {
continue;
}
$value->host = "../";
foreach($tabDomaine AS $domaine => $valeur) {
if ($domaine == $tmp['domaine']) {
$value->host = $valeur->host;
break;
}
}
// Ordre
// secteur;metier;contrat;emploi;region;langues;domaine
$tabPushModif = array();
if ($tmp['push_preview'] != '') {
$tabPushModif = explode(';', $tmp['push_preview']);
$tabPushModif['secteur'] = $tabPushModif[0];
$tabPushModif['metier'] = $tabPushModif[1];
$tabPushModif['contrat'] = $tabPushModif[2];
$tabPushModif['id_emploi'] = $tabPushModif[3];
$tabPushModif['regions'] = $tabPushModif[4];
$tabPushModif['langues'] = $tabPushModif[5];
$tabPushModif['domaine'] = $tabPushModif[6];
}
$infoSoc = get_nom_societe($tmp['id_societe']);
$number = ($tmp['nb_preview_push'] != '' ? $tmp['nb_preview_push'] : ' ');
$secteurs = explode ("/", $tmp[secteur]);
$sector = "";
$count_sect = count($secteurs);
for ($k = 0; $k < $count_sect; $k++) {
if ($secteurs[$k] != '') {
$sector .= $tab_secteur[$secteurs[$k]].'/';
}
}
$tmp['poste'] = apresinsertion($tmp['poste']);
$tmp['metier'] = $tab_metier[$tmp['metier']];
$tmp['region'] = $tab_region[$tmp['region']];
$tmp['departement'] = $tab_departement[$tmp['departement']];
$tmp['secteur'] = $sector;
$tmp['id_contrat'] = $tmp['contrat'];
$tmp['contrat'] = $tab_contrat[$tmp['contrat']];
$tmp['emploi'] = $tab_emploi[$tmp['id_emploi']];
$tmp['categorie'] = $tab_categ[$tmp['categorie']];
echo '<tr id="'.($isDoublon ? 'dbl_' : '').$tmp['id'].'"><td align="center" class="tdFirst nowrap dbl_'.$tmp['id'].'" id="aff_'.$tmp['id'].'"';
switch($tmp['affiche']) {
case '0': echo ' bgcolor=#DBB7FF'; break;
default : ;
}
echo '><a href=?op=annonces&search4='.$tmp[id].' target=_new>'.$tmp[id].'</a><br />';
echo '<a href="'.$value->host.'" target="blank">'.strtoupper($tmp['domaine']).'<br /><img src="../images/flags/'.$tmp['domaine'].'.png" border=0 align=middle></a>';
echo '</TD><TD align=center class=tdNext';
if ($tmp['filtre'] == 1)
echo ' bgcolor=#FF0000';
echo '>';
if ($isDoublon)
echo '<a id="'.$tmp['id'].'" class="doublon" href="#">DOUBLON</a> - ';
if (($tmp[id_reponse] == 1) || ($tmp[id_reponse] == 2) || ($tmp[id_reponse] == 4) || ($tmp[id_reponse] == 5))
echo '<a href="javascript:voir_annonce(\''.$tmp['id'].'\', \''.$value->host.'\')" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">'.$tmp['poste'].'</a>';
if ($tmp[id_reponse] == 3)
echo '<a href="javascript:voir_annonce3(\''.$tmp['url_reponse'].'\')" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">'.$tmp['poste'].'</a>';
if ($tmp['urgent'] == 1)
print " - <font class=r_bold>urgent</font>";
if ($tmp['gold'] == 1)
print " - <font class=g_bold>gold</font>";
if ($tmp['cvtheque'] == 1)
print " - CVthèque";
if ($tmp['url_reponse'] != '' && $tmp['id_reponse'] != 3) {
echo '<br /><br />URL - ';
$len = strlen($tmp['url_reponse']);
if ($len > 50) {
$link = substr($tmp['url_reponse'], 0, 47).'...';
} else {
$link = $tmp['url_reponse'];
}
echo '<a href="'.$tmp['url_reponse'].'" style="color: #666;" target="_blank">'.$link.'</a>';
}
// Début du div ou sera placé l'annonce
echo '<br /><div id="preview_'.$tmp['id'].'" name="preview_'.$tmp['id'].'" class="tdStyle1" style="z-index: 1000; display: none; position: fixed; left: 0px; top: 0px; padding: 4px; border: 1px solid #666; background: #fff; text-align: left; width: 777px;" onMouseOver="showPreview('.$tmp['id'].');" onMouseOut="hidePreview('.$tmp['id'].');">';
$tmp["url"] = substr($tmp["url"], 7);
$id_modele = getIdModeleByAnnonce($tmp['id_societe'], $tmp["id"], $tmp['domaine']);
$tmp["poste"] = mb_strtoupper($tmp["poste"]);
$isFnh = isFnhAnnonce($tmp['id']);
$logo = "";
if ($isFnh) {
$logo_jpg = getFnhLogo();
$logo = "<img align='center' border='0' src='".$logo_jpg."' />";
} else {
if ($id_modele > 0) {
if ($tmp['id_reponse'] == 1) {
$logo_gif = "../fichiers/societes/".$tmp['id_societe']."/".$id_modele.".gif";
if (file_exists($logo_gif)) {
$logo = "<img align=center border=0 src=".$logo_gif.">";
}
}
else
{
$rep = "../fichiers/societes/".$tmp['id_societe']."/".$id_modele;
$logo_jpg = $rep.".jpg";
$logo_swf = $rep.".swf";
$logo_gif = $rep.".gif";
if (file_exists($logo_jpg)) {
$logo = "<img align=center border=0 src=".$logo_jpg.">";
}
elseif (file_exists($logo_swf))
$logo = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="120" height="600">
<param name=movie value="'.$logo_swf.'">
<param name=quality value=high>
<embed src="'.$logo_swf.'"
quality=high
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="120" height="600"></embed>
</object>';
elseif (file_exists($logo_gif)) {
$logo = "<img align=center border=0 src=".$logo_gif.">";
}
}
}
}
if (strlen($logo) > 0 && strlen($tmp['url']) > 0)
$logo = "<a href=http://".$tmp['url']." target=_blank>".$logo."</a>";
if (strlen($tmp['url_reponse']) <= 0) {
$tmp['url_reponse'] = "../jobs/repondre_annonce.php?id=".$tmp['id']."\" onClick=\"";
if ($tmp['contact_email'] == "")
$tmp['url_reponse'] .= "alert('".$traduction->aff_word("repondre_courrier", $tabTrad['only_word']).'\n'.$tmp['societe'].'\n'.str_replace("<br />", '\n', ereg_replace("[\r\n\t]", "", $tmp['adresse']))."');";
else
$tmp['url_reponse'] .= "popUp(this.href, 'scroll', 540, 400);";
$tmp['url_reponse'] .= "return false;";
}
?>
<table width="775" cellspacing="0" cellpadding="0" border=0>
<? if ($tmp['id_reponse'] != "2") { ?>
<tr>
<td width="575" align=center valign=top>
<table width="535" border=0 cellspacing=0 cellpadding=2>
<tr>
<td colspan="2" class="nom_societe"><?=$tmp['societe']?></td>
</tr>
<tr>
<td colspan="2"><hr size=1 color=#000000></td>
</tr>
<tr>
<td colspan="2" align="right"><?=date_2fr($tmp["date_affichage"], 1)?></td>
</tr>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("pays")?> :</td>
<td align="left"><?=$tmp['pays0']?></td>
</tr>
<?
if ($tmp['region']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("region")?> :</td>
<td align="left"><?=$tmp['region']?></td>
</tr>
<? }
if ($tmp['departement']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("departement")?> :</td>
<td align="left"><?=$tmp['departement']?></td>
</tr>
<? }
if ($tmp['ville']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("ville")?> :</td>
<td align="left"><?=$tmp['ville']?></td>
</tr>
<? }
if ($tmp['debut']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("debut_travail")?> :</td>
<td align="left"><?=$tmp['debut']?></td>
</tr>
<? } ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("type_contrat")?> :</td>
<td align="left"><?=$tmp['contrat']?></td>
</tr>
<?
if ($tmp['emploi']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("type_emploi")?> :</td>
<td align="left"><?=$tmp['emploi']?></td>
</tr>
<? }
if ($tmp['salaire']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("salaire")?> :</td>
<td align="left"><?=$tmp['salaire']?></td>
</tr>
<? }
if ($tmp['experience']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("experience_metier")?> :</td>
<td align="left"><?=$tab_experience[$tmp['experience']]?></td>
</tr>
<? }
if ($tmp['reference']) { ?>
<tr>
<td align="right" class=bold><?=$traduction->aff_word("reference")?> :</td>
<td align="left"><?=$tmp['reference']?></td>
</tr>
<? } ?>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<?
if ($tmp['presentation']) { ?>
<tr>
<td valign=top align="right" class=bold><?=$traduction->aff_word("presentation")?> :</td>
<td style="text-align: justify;"><?=$tmp['presentation']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? } ?>
<tr>
<td valign="top" class=bold align="right"><?=$traduction->aff_word("poste")?> :</td>
<td valign="top" class=titre_poste align=center><?=$tmp['poste']?></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<tr>
<td valign="top" class=bold align="right"><?=$traduction->aff_word("description")?> :</td>
<td style="text-align: justify;"><?=$tmp['description']?></td>
</tr>
<tr>
<td width=100%> </td>
<td width=405><hr size=1 color=#000000 width=405></td>
</tr>
<?
if ($tmp['profil']) { ?>
<tr>
<td valign="top" align="right" class=bold><?=$traduction->aff_word("profil")?> :</td>
<td valign="top" style="text-align: justify;"><?=$tmp['profil']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? }
if ($tmp['recommandation']) { ?>
<tr>
<td valign="top" align="left"></td>
<td valign="top" style="text-align: justify;"><?=$tmp['recommandation']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? }
if ($tmp['contact_nom'] || $tmp['contact_prenom']) { ?>
<tr>
<td valign="top" align="right" class=bold><?=$traduction->aff_word("contact")?> :</td>
<td valign="top" align="left"><?=$tmp['contact_prenom']?> <?=$tmp['contact_nom']?></td>
</tr>
<tr>
<td> </td>
<td><hr size=1 color=#000000 width=405></td>
</tr>
<? } ?>
<? } elseif ($tmp['domaine'] != 'de') { ?>
<tr>
<td colspan=2><table width="755" align=right valign=top><tr><td><?=$tmp['presentation']?></td></tr></table></td>
</tr>
<? } ?>
<tr>
<td rowspan=6> </td>
<td><a href="<?=$tmp['url_reponse']?>" target="_blank">>> <?=$traduction->aff_word("repondre_en_ligne")?></a></td>
</tr>
<tr>
<td><a href="../jobs/affiche_imprime_annonce.php?id=<?=$tmp['id']?>" onClick="popUp(this.href, 'scroll', 540, 400);return false;" target="_blank">>> <?=$traduction->aff_word("version_imprimer")?></a></td>
</tr>
<tr>
<td><a href="../jobs/send_friend_annonce.php?id=<?=$tmp['id']?>" onClick="popUp(this.href, 'clean', 400, 300);return false;" target="_blank">>> <?=$traduction->aff_word("envoi_ami")?></a></td>
</tr>
<tr>
<td><a href="./affiche_liste.php?soc=<?=$tmp['societe_clean']?>">>> <?=$traduction->aff_word("toutes_offres")?> <?=$tmp['societe']?></a></td>
</tr>
<tr>
<td><a href="../jobs/index.php">>> <?=$traduction->aff_word("nouvelle_recherche")?></a></td>
</tr>
<tr>
<td><a href="../jobs/index.php" onClick="javascript:retour(); return false;"><< <?=$traduction->aff_word("retour")?></a></td>
</tr>
<? if ($tmp['id_reponse'] != "2") { ?>
</table>
</td>
<td width="200" align=center class=black_bord valign=top>
<table width="190" cellspacing=0 cellpadding=0 border=0>
<tr>
<td colspan="2" align="center" valign="top" class=bold><? if ($tmp['id_reponse'] != "5") { ?><br><? } ?><?=$logo?><br><br><?=$tmp['societe']?></td>
</tr>
<?
if ($tmp['adresse']) { ?>
<tr>
<td align="center" colspan=2><?=$tmp['adresse']?></td>
</tr>
<tr>
<td colspan=2> </td>
</tr>
<? }
if ($tmp['contact_tel']) { ?>
<tr>
<td class=bold align=right><?=$traduction->aff_word("tel")?> :</td>
<td align=center><?=$tmp['contact_tel']?></td>
</tr>
<? }
if ($tmp['contact_fax']) { ?>
<tr>
<td class=bold align=right><?=$traduction->aff_word("fax")?> :</td>
<td align=center><?=$tmp['contact_fax']?></td>
</tr>
<? }
if ($tmp['url']) { ?>
<tr>
<td colspan=2 align=center><a href="http://<?=$tmp['url']?>" target="_blank"><?=$tmp['url']?></a></td>
</tr>
<? } ?>
</table>
</td>
</tr>
<? } ?>
</table>
<?
echo '</div>';
// Fin du div ou sera placé l'annonce
echo "</TD><TD align=center class=tdNext><b>".date_2fr($tmp['date_creation'], 1)."</b><br>".date_2fr($tmp['date_affichage'], 1);
echo "</TD><TD align=center class=tdNext>".$tmp[societe]."<br>(<i><a href=".$value->host."login/login.php?login=".$infoSoc->email."&pass=".$infoSoc->password." target=_blank>".$infoSoc->nom."</a></i>)<br><a href=index.php?op=entreprise&ac=tableau_bord&id_societe=".$tmp['id_societe'].">compte</a></TD>";
$color = '';
switch($tmp[push_mail]) {
case "0": $color = " bgcolor=#DBB7FF"; break;
case "2": $color = " bgcolor=#CCCCCC"; break;
default : ;
}
$type_rep = "";
switch ($tmp[id_reponse]) {
case 1:
$type_rep = "Standard";
break;
case 2:
$type_rep = "Chartée";
break;
case 3:
$type_rep = "Metamoteur";
break;
case 4:
$type_rep = "Reponse sur site";
break;
case 5:
$type_rep = "Semi-chartée";
break;
}
print "
<td align=center class=tdNext>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td align=center class=cadreBas>".$tmp['contrat']." - ".$tmp['emploi']."</td>
<td $color align=center rowspan=4 width=40%>
<a onclick=\"javascript:colorannonce(this, '#CFFFCF');\" href=?op=agentalertes&action=modify_push&id_annonce=".$tmp[id]." target=_blank>Modifier push</a><br><br>
<a onclick=\"sendPush(this, ".$tmp['id']."); return false;\" href=\"#\">Envoyer Push</a>
</td>
</tr>
<tr>
<td align=center class=cadreBas>".(strlen($tmp['metier']) > 0 ? $tmp['metier'] : '<font class=gris_i>'.$tmp['categorie'].'</font>')."</td>
</tr>
<tr>
<td align=center class=cadreBas>".$tmp[secteur]."</td>
</tr>
<tr>
<td align=center>".($number < 500 ? '<font color="red">' : ($number > 1500 ? '<font color="orange">' : '<font color="green">')).$number."</font></td>
</tr>
</table>
</td>
<td align=center class=tdNext>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td align=center class=cadreBas>";
if (strlen($tabPushModif['regions']) > 0) {
$tab = explode('/', $tabPushModif['regions']);
foreach($tab AS $elem) {
if (strlen($elem) <= 0)
continue;
if (strpos($elem, 'dep-') !== false) {
echo $tab_departement[substr($elem, 4)];
$query_tmp = 'SELECT region FROM ref_departement WHERE id = "'.substr($elem, 4).'"';
$obj = $db->getObj($query_tmp);
if ($obj) {
echo ' - '.$tab_region[$obj->region];
$query_tmp = 'SELECT rp.code_pays FROM ref_pays rp INNER JOIN ref_region rr ON rr.pays = rp.id WHERE rr.id = "'.$obj->region.'"';
$obj = $db->getObj($query_tmp);
if ($obj)
echo ' ('.$obj->code_pays.')';
}
}
elseif (is_numeric($elem) === false) {
echo '<font class=gris_i>'.$tmp['departement'].' - '.$tmp['region'].'</font> ('.$elem.')';
}
else
{
echo '<font class=gris_i>'.$tmp['departement'].'</font> - '.$tab_region[$elem];
$query_tmp = 'SELECT rp.code_pays FROM ref_pays rp INNER JOIN ref_region rr ON rr.pays = rp.id WHERE rr.id = "'.$obj->region.'"';
$obj = $db->getObj($query_tmp);
if ($obj)
echo ' ('.$obj->code_pays.')';
}
}
}
else
echo $tmp['departement']." - ".$tmp['region']." (".$tmp['code_pays'].")";
echo "</td>
</tr>
<tr>
<td align=center class=cadreBas>".$tmp[ville]."</td>
</tr>
<tr>
<td align=center class=cadreBas>";
if (strlen($tabPushModif['metier']) > 0) {
$tmpExp = array();
$tab = explode('/', $tabPushModif['metier']);
foreach($tab AS $elem) {
if (strlen($elem) <= 0)
continue;
$tmpMetier = explode('-', $elem);
if (isset($tmpMetier[1])) {
if (in_array($tmpMetier[1], $tmpExp) === true)
continue;
$tmpExp[] = $tmpMetier[1];
if ($tmpMetier[1] == $tmp['experience'])
echo '<b>'.$tab_experience[$tmpMetier[1]].'</b>/';
else
echo $tab_experience[$tmpMetier[1]].'/';
}
}
if (count($tmpExp) <= 0)
echo '<font class=gris_i>'.$tab_experience[$tmp['experience']].'</font>';
}
else
echo $tab_experience[$tmp['experience']];
echo "</td>
</tr>
<tr>
<td align=center>".$tabLangues[$tmp['id_langue']]->langue." - ".$tabLanguesNiveau[$tmp['id_langue_niveau']]->langue_niveau."</td>
</tr>
</table>
</td>
<td align=center class=tdNext>
<table width=100% cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=center class=cadreBas>$type_rep</td>
</tr>
<tr>
<td align=center>".$tmp[compteur_vu]." / <a href=?op=gcand&ac=liste&id_annonce=".$tmp[id]."&statut=all target=_new>".$tmp[compteur_repondu]."</a></td>
</tr>
</table>
</td>
<td align=center class=tdNext>
<table width=100% cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=center class=cadreBas><a href=?op=annonces&ac=modifier&id_annonce=".$tmp['id']." target=_new>Modifier</a></td>
</tr>
<tr>
<td align=center class=cadreBas><a href='' onClick=\"valid_delete('".$tmp['id']."'); return false;\">Supprimer</a></td>
</tr>
<tr>
<td align=center><a href='' onClick='changeAff(".$tmp['id']."); return false;' id='changeAff_".$tmp['id']."'>".($tmp['affiche'] == 1 ? 'Mettre hors ligne' : 'Mettre en ligne')."</a></td>
</tr>
</table>
</td>
<td align=center class='tdNext gris'>
<p style=\"color:#444;\">
".nl2br($tmp['push_res']).'</p>';
if (is_array($tabHisto[$tmp['id']])) {
echo '<p style="color:#888; padding-top:5px;">';
foreach($tabHisto[$tmp['id']] as $histo) {
echo $histo['type_modif'].' '.HumanDateTime($histo['date']).' par '.$histo['user'];
if ($histo['new_annonce']) {
echo ' [New ID : <a href="index.php?op=annonces&search4='.$histo['new_annonce'].'">'.$histo['new_annonce'].'</a>]';
}
echo '<br />';
}
echo '</p>';
}
echo "
</td>
<td align=center> ".$tmp['source'];
if (!empty($tmp['source_ref'])) {
echo '<br /><a href="redirect.php?site='.$tmp['source_ref'].'" target="_blank">Voir original</a>';
}
echo '</td></tr>';
if (isset($doublon) && !$isDoublon) {
$query2 = " SELECT a.*, rp.pays0, rp.code_pays
FROM annonces a
INNER JOIN ref_pays rp ON rp.id = a.pays
WHERE a.id_societe = '".$tmp['id_societe']."'
AND a.contrat = '".$tmp['id_contrat']."'
AND a.domaine = '".$tmp['domaine']."'
AND a.id != '".$tmp['id']."'
AND ADDDATE(a.date_creation, INTERVAL 2 MONTH) > '".$tmp['date_creation']."'
AND a.poste = \"".addslashes($tmp['poste'])."\"
AND a.ville = \"".addslashes($tmp['ville'])."\"
AND a.societe = \"".addslashes($tmp['societe'])."\"
AND (a.id_societe != 1
OR (a.id_societe = 1 AND a.contact_email = \"".$tab_annonce['contact_email']."\"))
ORDER BY a.id DESC";
$tabAnnonces2 = $db->getTab($query2);
if (count($tabAnnonces2) > 0) {
$tabId = array();
foreach($tabAnnonces2 as $annonc) {
$tabId[] = $annonc['id'];
}
$tmpListAnnonceTab = annoncelist::getHistorique($tabId);
$tmpTabHisto = createTabHisto($tmpListAnnonceTab);
$tabHisto += $tmpTabHisto; //Additionne les 2 tableaux, contrairement à array_merge il garde les clés !!
affAnnonce($tabAnnonces2, 1);
foreach($tabAnnonces2 AS $tmpAnn)
$tabNoAffAnnonce[] = $tmpAnn['id'];
}
}
}
}
?>
Only this script is slow, all the others on the same server/domain/directory work great.
On an other server, the same script works fine.
The script takes up to 90% of CPU when running.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。
这是 php 错误处理程序未正确禁用。
Problem solved.
It was the php error handler that was not correctly disabled.