$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}
//Fonction pour générer un captcha aléatoire
function generer_code($taille)
{
    $caracteres = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    $caracteres_aleatoires = array_rand($caracteres, $taille);
    $pass = "";
    foreach ($caracteres_aleatoires as $i) {
        $pass .= $caracteres[$i];
    }
    return $pass;
}
$pass = generer_code(8);
//fonction pour convertir un timestamp en date (formulaire de contact + commentaire) ok
function convertit_timestamp_en_date($timestamp_actuel)
{
    return date("j-m-Y @ H:i:s", $timestamp_actuel);
}
//Fonction pour récupérer l'url du site
function url_actuelle()
{
    return 'http://' . $_SERVER["SERVER_NAME"] . '';
}
$url = url_actuelle();
Example #2
0
    // on remplit l'image de blanc
    //On remplit l'image avec des polygones
    for ($i = 0, $imax = mt_rand(3, 5); $i < $imax; $i++) {
        $x = mt_rand(3, 10);
        $poly = array();
        for ($j = 0; $j < $x; $j++) {
            $poly[] = mt_rand(0, $timage[0]);
            $poly[] = mt_rand(0, $timage[1]);
        }
        imageFilledPolygon($image, $poly, $x, imageColorAllocate($image, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
    }
    // Création des pixels gris
    for ($i = 0; $i < $timage[0] * $timage[1] / rand(15, 18); $i++) {
        imageSetPixel($image, rand(0, $timage[0]), rand(0, $timage[1]), $grey);
    }
    // affichage du texte demandé; on le centre en hauteur et largeur (à peu près ^^")
    //imageString($image, 5, ceil($timage[0]-strlen($content)*8)/2, ceil($timage[1]/2)-9, $content, $text_color);
    $longueur_chaine = strlen($content);
    for ($ch = 0; $ch < $longueur_chaine; $ch++) {
        imagettftext($image, 18, mt_rand(-30, 30), 10 * ($ch + 1), mt_rand(18, 20), $text_color, 'res/georgia.ttf', $content[$ch]);
    }
    $type = function_exists('imageJpeg') ? 'jpeg' : 'png';
    @header('Content-Type: image/' . $type);
    @header('Cache-control: no-cache, no-store');
    $type == 'png' ? imagePng($image) : imageJpeg($image);
    ImageDestroy($image);
    exit;
}
$code_genere = generer_code(5);
$_SESSION['cap_nw'] = $code_genere;
make_img($code_genere);