function PasswordImage() { // outputs a png image for a random password // and a crypted string for it. The filename // for this image can be computed from the crypted // string by PasswordImageName. // the retrun value is just the crypted password. PasswordImageClean(); // purges former passwords $mdp = makeRandomPassword(7); $c = crypt($mdp); $png = imagecreate(10 + 7.5 * strlen($mdp), 18); $bg = imagecolorallocate($png, 160, 160, 160); imagestring($png, 3, 5, 2, $mdp, imagecolorallocate($png, 0, 0, 0)); $file = STOCK_FILES . "/" . PasswordImageName($c); //TODO:2 lines below is useless but necessary by a bug in php-gd(http://bugs.php.net/bug.php?id=35246) $fh = fopen($file, 'w'); fclose($fh); imagepng($png, $file); // The perms of the file can be wrong, correct it // WARN : chmod() can be desacivated (i.e. : Free/Online) @chmod($file, 0644); return $c; }
$adherent["id_statut"] = "4"; $adherent["titre_adh"] = "1"; $adherent["date_crea_adh"] = date("d/m/Y"); #annoying #$adherent["url_adh"] = "http://"; $adherent["url_adh"] = ""; $adherent["pref_lang"] = PREF_LANG; } // - declare dynamic fields for display $disabled['dyn'] = array(); if (!isset($adherent['dyn'])) { $adherent['dyn'] = array(); } //image to defeat mass filling forms $spam_pass = PasswordImage(); $s = PasswordImageName($spam_pass); $spam_img = print_img($s); $dynamic_fields = prepare_dynamic_fields_for_display($DB, 'adh', $_SESSION["admin_status"], $adherent['dyn'], $disabled['dyn'], 1); // template variable declaration $tpl->assign("spam_pass", $spam_pass); $tpl->assign("spam_img", $spam_img); $tpl->assign("required", $required); $tpl->assign("disabled", $disabled); $tpl->assign("data", $adherent); $tpl->assign("time", time()); $tpl->assign("dynamic_fields", $dynamic_fields); $tpl->assign("error_detected", $error_detected); $tpl->assign("warning_detected", $warning_detected); $tpl->assign("languages", drapeaux()); $tpl->assign("head_redirect", $head_redirect); // pseudo random int