Пример #1
0
/**
 * Ulozit obrazek do uloziste
 * @param resource $res resource obrazku
 * @param string $path cesta k adresari uloziste vcetne lomitka
 * @param string|null subcesta v adresari uloziste vcetne lomitka nebo null
 * @param string $format pozadovany format obrazku
 * @param int $jpg_quality kvalita JPG obrazku
 * @param string|null $uid UID obrazku nebo null (= vygeneruje se automaticky)
 * @return array v pripade uspechu array(true, kod, filepath, uid), jinak array(false, kod, zprava)
 */
function _pictureStoragePut($res, $path, $home_path, $format, $jpg_quality = 80, $uid = null)
{
    // vygenerovani uid
    if (!isset($uid)) {
        $uid = uniqid('');
    }
    // sestaveni cesty
    if (isset($home_path)) {
        $path .= $home_path;
    }
    // proces
    $code = 0;
    do {
        // kontrola adresare
        if (!is_dir($path) && !@mkdir($path, 0777, true)) {
            $code = 1;
            break;
        }
        // kontrola formatu
        if (!_checkGD($format)) {
            $code = 2;
            break;
        }
        // sestaveni nazvu
        $fname = $path . $uid . '.' . $format;
        // zapsani souboru
        switch ($format) {
            case 'jpg':
            case 'jpeg':
                $write = @imagejpeg($res, $fname, $jpg_quality);
                break;
            case 'png':
                $write = @imagepng($res, $fname);
                break;
            case 'gif':
                $write = @imagegif($res, $fname);
                break;
        }
        // uspech?
        if ($write) {
            return array(true, $code, $fname, $uid);
        }
        // jo
        $code = 3;
        // ne
    } while (false);
    // chyba
    global $_lang;
    return array(false, $code, $_lang['pic.put.' . $code]);
}
Пример #2
0
<?php

// jadro
require '../require/load.php';
define('_header', '');
SL::init('../');
// kontrola GD
_checkGD("jpg", true);
// inicializace obrazku, nacteni kodu
$imgw = 65;
$imgh = 22;
$img = imagecreate($imgw, $imgh);
if (isset($_GET['n']) and isset($_SESSION[_sessionprefix . 'captcha_code'][(int) $_GET['n']])) {
    list($code, $drawn) = $_SESSION[_sessionprefix . 'captcha_code'][(int) $_GET['n']];
    if ($drawn) {
        die;
    }
    $_SESSION[_sessionprefix . 'captcha_code'][(int) $_GET['n']][1] = true;
} else {
    die;
}
/**
 * Linear perspective class
 */
class linear_perspective
{
    public $cam_location = array('x' => -30, 'y' => 0, 'z' => -250);
    public $cam_rotation = array('x' => -1, 'y' => 0, 'z' => 0);
    public $viewer_position = array('x' => 450, 'y' => -500, 'z' => -80);
    public function getProjection($point)
    {