Exemplo n.º 1
0
Arquivo: func.php Projeto: jcmwc/fleet
function resizeThumb($arr)
{
    $date = md5(time());
    $arr['temp_uploadfile'] = $arr['img_src'];
    $arr['new_uploadfile'] = $arr['uploaddir'] . strtolower($date) . '.jpg';
    asidoImg($arr);
    exit;
}
Exemplo n.º 2
0
function createdefault($input, $table, $id = 0)
{
    //$id=($id=0)?$_GET["id"]:$id;
    //
    /*
    ?>
    <script>alert("<?=$input?> / <?=$_POST[$input]?>")</script>
    <?
    */
    $args = explode(",", $_POST["args_" . $input]);
    //print_r($_POST);
    if ($id != 0) {
        //tbl_1tmp_phantom_content-1.jpg
        //tbl_tmp_phantom_content-1.jpg
        if (file_exists($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tmp_' . $table . $_SESSION['users_id'] . '.jpg')) {
            rename($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tmp_' . $table . $_SESSION['users_id'] . '.jpg', $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . $table . $id . '.jpg');
            rename($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_tmp_' . $table . $_SESSION['users_id'] . '.jpg', $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . $table . $id . '.jpg');
            //on renone les vignettes
            for ($i = 0; $i < $_POST[$input]; $i++) {
                //tmp_phantom_content-1.jpg
                //if(!file_exists($_SERVER["DOCUMENT_ROOT"].__uploaddir__.'tbl_'.($i+1).'tmp'.$table.$_SESSION['users_id'].'.jpg')){
                //on verifie si la vignette existe
                //tbl_1tmp_phantom_content-1.jpg
                //tbl_1tmp_phantom_content-1.jpg
                if (file_exists($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . ($i + 1) . 'tmp_' . $table . $_SESSION['users_id'] . '.jpg')) {
                    //on renome
                    rename($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . ($i + 1) . 'tmp_' . $table . $_SESSION['users_id'] . '.jpg', $_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . ($i + 1) . $table . $id . '.jpg');
                } else {
                    $info = explode('/', $args[$i]);
                    //on créé la vignette
                    $arr['temp_uploadfile'] = __uploaddir__ . 'tbl_' . $table . $id . '.jpg';
                    $arr['new_uploadfile'] = __uploaddir__ . 'tbl_' . ($i + 1) . $table . $id . '.jpg';
                    $size = getimagesize($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . $table . $id . '.jpg');
                    $arr['height'] = $info[2] == "*" ? $size[1] : $info[2];
                    $arr['width'] = $info[1] == "*" ? $size[0] : $info[1];
                    $arr['x'] = $info[1] == "*" ? 0 : ($size[0] - $arr['width']) / 2;
                    $arr['y'] = $info[2] == "*" ? 0 : ($size[1] - $arr['height']) / 2;
                    $arr['thumb'] = true;
                    asidoImg($arr);
                }
                //}
            }
        }
    } else {
        for ($i = 0; $i < $_POST[$input]; $i++) {
            //on verifie si la vignette existe
            if (!file_exists($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . ($i + 1) . $table . $_GET["id"] . '.jpg')) {
                $info = explode('/', $args[$i]);
                //on créé la vignette
                $arr['temp_uploadfile'] = __uploaddir__ . 'tbl_' . $table . $_GET["id"] . '.jpg';
                $arr['new_uploadfile'] = __uploaddir__ . 'tbl_' . ($i + 1) . $table . $_GET["id"] . '.jpg';
                $size = getimagesize($_SERVER["DOCUMENT_ROOT"] . __uploaddir__ . 'tbl_' . $table . $_GET["id"] . '.jpg');
                //print $info[2];
                $arr['height'] = $info[2] == "*" ? $size[1] : $info[2];
                $arr['width'] = $info[1] == "*" ? $size[0] : $info[1];
                $arr['x'] = $info[1] == "*" ? 0 : ($size[0] - $arr['width']) / 2;
                $arr['y'] = $info[2] == "*" ? 0 : ($size[1] - $arr['height']) / 2;
                $arr['thumb'] = true;
                //print_r($arr);
                asidoImg($arr);
            }
        }
    }
}