예제 #1
0
session_start();
function gettxt()
{
    $txtarray = chr(rand(97, 122));
    $txtnumb = rand(0, 9);
    $flag = rand(0, 1);
    if ($flag == 1) {
        $return = $txtarray;
    } else {
        $return = $txtnumb;
    }
    return $return;
}
$size = 13;
$font = "c:/windows/fonts/simsun.ttc";
$code = gettxt() . " " . gettxt() . " " . gettxt() . " " . gettxt();
$_SESSION['code'] = $code;
$img = imagecreate(72, 30);
$color2 = hexdec(mt_rand(10, 235));
$color3 = hexdec(mt_rand(30, 215));
imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, $color2, $color3, 0);
for ($i = 0; $i < 100; $i++) {
    $pointColor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    imagesetpixel($img, mt_rand(0, 72), mt_rand(0, 30), $pointColor);
}
for ($i = 0; $i < 5; $i++) {
    $lineColor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), 20);
    imageline($img, 0, mt_rand(0, 255), 72, mt_rand(0, 30), $lineColor);
}
imagettftext($img, $size, 0, 5, 18, $black, $font, $_SESSION['code']);
예제 #2
0
/**
 * Generuje strankovac - tlacitka ktere strankuji tabulku dat.
 * PAGE_SELECTOR_SIZE udava pocet odkazu na jednotlive stranky.
 * @param int $page cislo stranky 0..n
 * @param int $page_size pocet polozek na strance, napr. 5, 10, 20
 * @param int $total_items celkovy pocet polozek
 * @return string html kod strankovace, pokud neni co strankovat tak prazdny retezec
 */
function strankovac($page, $page_size, $total_items)
{
    $strankovac = "";
    // vynulovat
    $pocet_stran = ceil($total_items / $page_size);
    $range = floor($page / PAGE_SELECTOR_SIZE);
    // kolikata n-tice stranek to je
    // urcime posledni klikatelnou sranku v range
    if ($pocet_stran > ($range + 1) * PAGE_SELECTOR_SIZE) {
        $page_to = ($range + 1) * PAGE_SELECTOR_SIZE;
    } else {
        $page_to = $pocet_stran;
    }
    // urcime prvni klikatelnou stranku v range
    if ($range > 0) {
        $page_from = $range * PAGE_SELECTOR_SIZE;
    } else {
        $page_from = 0;
    }
    if ($range > 0) {
        //odkaz na prvni stranku
        $strankovac .= " <a href=\"" . getUrl($_REQUEST["modul"], array("page" => 0, "filtrActive" => "on"), true, true) . "\" title=\"" . getTxt("První") . "\">&lt;&lt;</a> ";
        $strankovac .= " <a href=\"" . getUrl($_REQUEST["modul"], array("page" => $range * PAGE_SELECTOR_SIZE - 1, "filtrActive" => "on"), true, true) . "\" title=\"" . getTxt("Strana") . " " . $range * PAGE_SELECTOR_SIZE . "\">&lt;</a> ";
    } else {
        // $strankovac.=" předchozí ";
    }
    for ($i = $page_from; $i < $page_to; $i++) {
        if ($i == $page) {
            $style = "";
            $strankovac .= " <strong>" . ($i + 1) . "</strong> ";
        } else {
            $style = "";
            $strankovac .= " <a href=\"" . getUrl($_REQUEST["modul"], array("page" => $i, "filtrActive" => "on"), true, true) . "\" " . $style . ">" . ($i + 1) . "</a> ";
        }
    }
    if ($page != 0) {
        $predchozi = "<a href=\"" . getUrl($_REQUEST["modul"], array("page" => $page - 1, "filtrActive" => "on"), true, true) . "\" " . $style . ">" . gettxt("&lt; Předchozí") . "</a>";
    }
    if ($page != $page_to - 1) {
        $dalsi = "<a href=\"" . getUrl($_REQUEST["modul"], array("page" => $page + 1, "filtrActive" => "on"), true, true) . "\" " . $style . ">" . gettxt("Další\t&gt;") . "</a>";
    }
    /** sipky
         *
        if (($range+1)*PAGE_SELECTOR_SIZE<$pocet_stran-1) {
            $strankovac.=" <a href=\"".getUrl($_REQUEST["modul"],array("page" => ($range+1)*PAGE_SELECTOR_SIZE),true,true)."\" title=\"".getTxt("Strana")." ".(($range+1)*PAGE_SELECTOR_SIZE+1)."\">&gt;</a> ";
            $strankovac.=" <a href=\"".getUrl($_REQUEST["modul"],array("page" => $pocet_stran-1),true,true)."\" title=\"".getTxt("Poslední")."\">&gt;&gt;</a> ";
        }
        else {
          //$strankovac.=" další ";
        }
        **/
    //         <span>strana: ".($page_from+1)."/".($pocet_stran)."</span>
    /*    if ($pocet_stran>=1)
          {
          $strankovac="<span>".$strankovac."</span>\n";
          };
    */
    if ($strankovac == "" || $strankovac == " 1 ") {
        return "";
    } else {
        return $predchozi . $strankovac . $dalsi;
    }
}