dans le code si dessous, les erreurs ne s'affichent pas quand je clique sur "valider".
Plusieurs message devrait s'afficher si je valide sans avoir rempli les champs obligatoires et le captcha.
Si tout est rempli le message est envoyé quand même, donc pas de problème de ce côté.
Merci d'avance de votre aide.
<?php
require_once("initvars.inc.php");
require_once("config.inc.php");
if($image_verification)
{
require_once("captcha.cls.php");
$captcha = new captcha();
}
$msg = "";
$err = "";
?>
<?php
if (!$_GET['adid'])
{
header("Location: $script_url/?view=main&cityid=$xcityid&lang=$xlang");
exit;
}
$adtable = ($_GET['view'] == "showevent") ? $t_events : $t_ads;
$adid_prefix = (($xview == "events") ? "E" : "A");
$full_adid = ($adid_prefix . $xadid);
$reported = explode(";", $_COOKIE["reported"]);
$is_reported = in_array($full_adid, $reported);
$qsA = $_GET; $qs = "";
unset($qsA['do'], $qsA['reported'], $qsA['mailed'], $qsA['mailerr'], $qsA['msg'], $qsA['err']);
foreach ($qsA as $k=>$v) $qs .= "$k=$v&";
if ($_GET['do'] == "reportabuse")
{
if (!$is_reported) {
$sql = "UPDATE $adtable
SET abused = abused + 1
WHERE adid = $_GET[adid]
AND abused < " . ($spam_indicator - 1);
mysql_query($sql) or die($sql);
if(mysql_affected_rows())
{
echo "<div class=\"msg\">$lang[MESSAGE_ABUSE_REPORT]</div>";
if($max_abuse_reports)
{
$sql = "UPDATE $adtable
SET enabled = '0'
WHERE adid = $_GET[adid]
AND abused >= $max_abuse_reports";
mysql_query($sql);
}
header("Location: $script_url/?{$qs}reported=y");
exit;
}
}
unset($_GET['do']);
}
if ($xview == "showevent")
{
$sql = "SELECT a.*, UNIX_TIMESTAMP(a.timestamp) AS timestamp, UNIX_TIMESTAMP(a.createdon) AS createdon, UNIX_TIMESTAMP(a.expireson) AS expireson, UNIX_TIMESTAMP(feat.featuredtill) AS featuredtill,
UNIX_TIMESTAMP(a.starton) AS starton, UNIX_TIMESTAMP(a.endon) AS endon
FROM $t_events a
LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'E'
WHERE a.adid = $xadid
AND $visibility_condn_admin";
$ad = mysql_fetch_array(mysql_query($sql));
$isevent = 1;
$thisurl = buildURL($xview, array($xcityid, $xdate, $xadid, $ad['adtitle']));
}
else
{
$xfieldsql = "";
if(count($xsubcatfields))
{
for($i=1; $i<=$xfields_count; $i++) $xfieldsql .= ", axf.f$i";
}
$sql = "SELECT a.*, ct.cityname as cityname, UNIX_TIMESTAMP(a.timestamp) AS timestamp, UNIX_TIMESTAMP(a.createdon) AS createdon, UNIX_TIMESTAMP(a.expireson) AS expireson, UNIX_TIMESTAMP(feat.featuredtill) AS featuredtill $xfieldsql
FROM $t_ads a
INNER JOIN $t_subcats scat ON scat.subcatid = a.subcatid
INNER JOIN $t_cities ct ON a.cityid = ct.cityid
LEFT OUTER JOIN $t_adxfields axf ON a.adid = axf.adid
LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A'
WHERE a.adid = $xadid
AND $visibility_condn_admin";
$ad = mysql_fetch_array(mysql_query($sql));
$isevent = 0;
$thisurl = buildURL($xview, array($xcityid, $xcatid, $xcatname, $xsubcatid, $xsubcatname,
$xadid, $ad['adtitle']));
}
if (!$ad)
{
header("Location: $script_url/index.php?view=post404&cityid=$xcityid&lang=$xlang");
exit;
}
if ($_POST['email'] && $_POST['mail'] && $ad['showemail'] == EMAIL_USEFORM)
{
$err = "";
if ($image_verification && !$captcha->verify($_POST['captcha']))
{
$err .= $lang['ERROR_IMAGE_VERIFICATION_FAILED'] . "<br>";
}
if (!ValidateEmail($_POST['email']))
{
$err .= $lang['ERROR_INVALID_EMAIL'] . "<br>";
}
if (preg_match("/[\\000-\\037]/", $_POST['email']))
{
handle_security_attack("@");
}
else if (!$err)
{
$thismail_header = file_get_contents("mailtemplates/contact_header.txt");
$thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
$thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
$thismail_header = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_header);
$thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);
$thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
$thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
$thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
$thismail_footer = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_footer);
$thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);
$msg = $thismail_header . "\n" .
stripslashes($_POST['mail']) . "\n" .
$thismail_footer;
$xtraheaders = array("Reply-To: " . $_POST['email']);
$mailerr = sendMail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $msg,
$site_email, $langx['charset'], "attach", $xtraheaders);
if ($mailerr)
{
$mailresult = "n";
if ($mailerr == "FAILED") $mailerr = "";
}
else
{
$mailresult = "y";
}
header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
exit;
}
}
$sql = "SELECT *
FROM $t_adpics p
WHERE p.adid = $xadid
AND isevent = '$isevent'";
$pres = mysql_query($sql);
?>
<script language="javascript">
function confirmAbuseReport()
{
if (confirm('<?php echo addslashes($lang['REPORT_ABUSE_CONFIRM']); ?>'))
{
eval("location.href = '?' + '<?php echo $qs; ?>' + 'do=reportabuse'");
}
}
</script>
<?php
if ($_GET['reported']) {
$reported[] = $full_adid;
setcookie("reported", implode(";", $reported), time()+90*24*60*60, "/");
$is_reported = true;
}
?>
<?php
if(!$_POST['mail'])
{
if($_GET['mailed'] == "y") { $msg .= $lang['MESSAGE_MAIL_SENT']."<br>"; }
elseif ($_GET['mailed'] == "n") { $err .= $lang['ERROR_MAIL_NOT_SENT']."<br>".$_GET['mailerr']."<br>"; }
if($_GET['reported'] == "y") { $msg .= $lang['MESSAGE_ABUSE_REPORT']."<br>"; }
}
if($_GET['msg']) { $msg .= nl2br(htmlentities($_GET['msg']))."<br>"; }
if($_GET['err']) { $err .= nl2br(htmlentities($_GET['err']))."<br>"; }
?>
<?php
if($err) echo "<div class=\"err\">$err</div>";
if($msg) echo "<div class=\"msg\">$msg</div>";
?>
<?php include_once("inc/prev_next.inc.php");?>
<?php if($ad['featuredtill'] && $ad['featuredtill'] > time()) { ?>
<div class="msg">
<img src="images/featured.gif" align="absmiddle">
<b><?php echo $lang['THIS_AD_IS_FEATURED']; ?></b>
</div>
<?php } ?>
<table class="postheader" width="100%">
<tr>
<td>
<div align="right">
<?php if(!$is_reported) { ?><a href="javascript:confirmAbuseReport();"><?php echo $lang['REPORT_ABUSE']; ?></a> | <?php } ?>
<a href="?view=mailad&cityid=<?php echo $xcityid; ?>&adid=<?php echo $xadid; ?>&adtype=<?php echo $xadtype; ?><?php if($xdate) echo "&date={$xdate}"; ?>"><?php echo $lang['EMAIL_THIS_AD_LINK']; ?></a>
</div>
<?php echo $lang['POST_ID']; ?> <?php echo ($xview=="showevent"?"E":"A"); ?><?php echo $ad['adid']; ?><br><br>
<?php
if ($xview == "showevent")
{
?>
<b><?php echo date("d", $ad['starton'])." ".$langx['months_short'][date("n", $ad['starton'])-1] . ", " . date("y", $ad['starton']); ?>
<?php if($ad['starton'] != $ad['endon']) echo " - " . date("d", $ad['endon']) . " " . $langx['months_short'][date("n", $ad['endon'])-1] . ", " . date("y", $ad['endon']); ?></b>
<br>
<?php
}
?>
<div class="posttitle">
<?php echo $ad['adtitle']; ?>
<?php
$loc = "";
if($ad['area']) $loc = $ad['area'];
if($xcityid < 0) $loc .= ($loc ? ", " : "") . $ad['cityname'];
if($loc) echo " <span class=\"adarea\">($loc)</span>";
?>
</div><br>
<b><?php echo $lang['AD_DATE']; ?></b>:
<?php echo QuickDate($ad['createdon']); ?>
<br>
<?php if($ad['createdon'] != $ad['timestamp']) { ?>
<b><?php echo $lang['AD_LAST_UPDATE']; ?></b>:
<?php echo QuickDate($ad['timestamp']); ?>
<br>
<?php } ?>
<b><?php echo $lang['AD_EXPIRES_ON']; ?></b>:
<?php echo QuickDate($ad['expireson']); ?>
<br>
<b><?php echo $lang['REPLY_TO']; ?></b>:
<?php if ($ad['showemail'] == EMAIL_SHOW) { ?>
<a href="mailto:<?php echo $ad['email']; ?>"><?php echo $ad['email']; ?></a>
<?php } elseif ($ad['showemail'] == EMAIL_USEFORM) { ?>
<i><?php echo $lang['USE_CONTACT_FORM']; ?></i>
<?php } else { ?>
<i><?php echo $lang['EMAIL_NOT_SHOWN']; ?></i>
<?php } ?>
<br>
</td>
</tr>
</table>
<?php
if(($xsubcathasprice && $ad['price']) || count($xsubcatfields))
{
$actualfields = $xsubcathasprice ? 1 : 0;
?>
<div>
<table>
<?php if($xsubcathasprice) { ?><tr><td><b><?php echo $xsubcatpricelabel; ?></b></td><td>: <?php if(($xsubcathasprice && $ad['price'] != 0.00)) { ?><?php echo $ad['price'] .' '. $currency; ?><?php } else { echo $lang['AD_PRICE_NOT_PROVIDED']; } ?></td></tr><?php } ?>
<?php if(count($xsubcatfields)) { foreach ($xsubcatfields as $fldnum=>$fld) { if(($fld['TYPE'] == "N" && $ad["f$fldnum"] > 0) || ($fld['TYPE'] != "N" && $ad["f$fldnum"])) { $actualfields++; ?>
<tr><td><b><?php echo $fld['NAME']; ?></b></td><td>: <?php echo $ad["f$fldnum"]; ?></td></tr>
<?php }}} ?>
</table></div>
<?php if ($actualfields) { ?>
<div style="border-bottom:1px solid #E0E0E0;"> </div>
<?php } ?>
<?php
}
?>
<table class="post" width="100%"><tr><td>
<?php echo generateHtml($ad['addesc'], $ad['createdon']); ?>
</td></tr></table>
<?php
if (@mysql_num_rows($pres))
{
$i = 0;
?>
<table class="postpics" width="100%"><tr><td>
<?php
while ($row = mysql_fetch_array($pres))
{
$i++;
$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height);
?>
<img src="<?php echo "{$datadir[adpics]}/{$row[picfile]}"; ?>" id="adimg<?php echo $i; ?>" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>"><br><br>
<?php
}
?>
</td></tr></table>
<?php
$imgcnt = $i;
}
?>
<?php
if($ad['othercontactok']) echo "<p class=\"disclosure_yes\">$lang[COMMERCIAL_CONTACT_OK]</p>";
else echo "<p class=\"disclosure_no\">$lang[COMMERCIAL_CONTACT_NOT_OK]</p>";
?>
<?php
$hits = $ad['hits'];
$already_hit = explode(";", $_COOKIE["hits"]);
if (!in_array($full_adid, $already_hit)) {
$sql = "update $adtable set hits = hits + 1, timestamp = timestamp where adid = $xadid";
mysql_query($sql);
$already_hit[] = $full_adid;
setcookie("hits", implode(";", $already_hit), 0, "/");
$hits++;
}
?>
<div class="hits">Vue <?php echo $hits; ?> fois<br><br></div>
<br style="clear:both">
<?php if ($ad['showemail'] == EMAIL_USEFORM) {
/*$qs = ""; $qsA = $_GET; unset($qsA['syndicate']);
foreach ($qsA as $k=>$v) $qs .= "$k=$v&";*/
?>
<form action="<?php echo "$script_url/?$qs"; ?>" method="post" enctype="multipart/form-data">
<table class="contactform">
<tr>
<th colspan="2"><?php echo $lang['CONTACT_USER']; ?>:<a name="contactform"> </a>
</th>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td><?php echo $lang['YOUR_EMAIL']; ?>: <span class="marker">*</span></td>
<td>
<input type="text" size="65" name="email">
</td>
</tr>
<tr>
<td valign="top"><?php echo $lang['YOUR_MESSAGE']; ?>: <span class="marker">*</span></td>
<td>
<textarea cols="64" rows="10" name="mail"></textarea>
</td>
</tr>
<tr>
<td valign="top"><?php echo $lang['ATTACHMENT']; ?>:</td>
<td>
<input type="file" size="55" name="attach"><br>
<span class="hint"><?php echo $lang['UNSUPPORTED_ATTACHEMNTS']; ?>: <?php echo implode(", ", $contactmail_attach_wrongfiles); ?><br>
<?php echo $lang['MAX_ATTACHMENT_SIZE']; ?>: <?php echo $contactmail_attach_maxsize; ?>KB</span>
</td>
</tr>
<?php
if($image_verification)
{
?>
<tr>
<td valign="top"><?php echo $lang['POST_VERIFY_IMAGE']; ?>: <span class="marker">*</span></td>
<td>
<img src="captcha.png.php?<?php echo rand(0,999); ?>"><br>
<span class="hint"><?php echo $lang['POST_VERIFY_IMAGE_HINT']; ?></span><br>
<input type="text" name="captcha" value="">
</td>
</tr>
<?php
}
?>
<tr>
<td> </td>
<td><button type="submit"><?php echo $lang['BUTTON_SEND_MAIL']; ?></button></td>
</tr>
</table>
</form>
<?php } ?>