示例#1
0
文件: assets.php 项目: sziszu/pefi
function thumbs($imgs)
{
    $data = '';
    foreach ($imgs as $img) {
        $data .= createThumb($img) . "\n";
    }
    return $data;
}
示例#2
0
 function processFileUploads()
 {
     if (!$_FILES['poster']['error']) {
         /*
         Некрасиво, надо это все в хэлпер запихать!
         */
         $dest = ROOT . DS . 'public' . DS . 'posters' . DS . $_FILES['poster']['name'];
         $relpath = substr('posters/' . $_FILES['poster']['name'], 0, -4);
         if ($_FILES['poster']['type'] == 'image/jpeg') {
             move_uploaded_file($_FILES['poster']['tmp_name'], $dest);
             $source = imagecreatefromjpeg($img);
             createThumb($dest, 100, 145);
             return $_FILES['poster']['name'];
         }
     }
 }
示例#3
0
function addFileToProject($file, $metas, $tcIn, $tcOut)
{
    global $project;
    global $racine;
    //echo $file."=".$tc;
    $tcIn = floatval($tcIn);
    $tcOut = floatval($tcOut);
    $document = $project->createElement("document");
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $user = "";
    if (fileowner($file) != FALSE) {
        $user = fileowner($file);
        $user = posix_getpwuid($user);
        $user = explode(",", $user["gecos"]);
        $user = $user[0];
    }
    //Création des métadatas
    $metasAdd = array("Rekall->Comments" => "", "File->Hash" => strtoupper(sha1_file($file)), "Rekall->Flag" => "File", "File->Thumbnail" => "", "File->Owner" => $user, "File->MIME Type" => finfo_file($finfo, $file), "File->File Type" => finfo_file($finfo, $file), "Rekall->Type" => finfo_file($finfo, $file), "File->File Name" => pathinfo($file, PATHINFO_BASENAME), "File->Extension" => pathinfo($file, PATHINFO_EXTENSION), "File->Basename" => pathinfo($file, PATHINFO_FILENAME), "Rekall->Name" => pathinfo($file, PATHINFO_FILENAME), "Rekall->Extension" => strtoupper(pathinfo($file, PATHINFO_EXTENSION)), "Rekall->Folder" => "", "Rekall->File Size" => filesize($file), "Rekall->File Size (MB)" => filesize($file) / (1024.0 * 1024.0));
    $metas = array_merge($metas, $metasAdd);
    $key = "/" . $metas["Rekall->Folder"] . $metas["File->File Name"];
    $metas["key"] = $key;
    //Génère une vignette
    $fileDestBasename = strtoupper(sha1($metas["Rekall->Folder"]) . "-" . $metas["File->Hash"]);
    $fileDest = "../file/rekall_cache/" . $fileDestBasename . ".jpg";
    createThumb($file, $fileDest, 160);
    if (file_exists($fileDest)) {
        $metas["File->Thumbnail"] = $fileDestBasename;
    }
    //Ajout des métadatas
    foreach ($metas as $metaCategory => $metaContent) {
        $meta = $project->createElement("meta");
        $meta->setAttribute("ctg", $metaCategory);
        $meta->setAttribute("cnt", $metaContent);
        $document->appendChild($meta);
        $racine->appendChild($document);
    }
    //Tag de timeline
    $tag = $project->createElement("tag");
    $tag->setAttribute("key", $key);
    $tag->setAttribute("timeStart", $tcIn);
    $tag->setAttribute("timeEnd", $tcOut);
    $tag->setAttribute("version", 0);
    $racine->appendChild($tag);
    return $metas;
}
示例#4
0
function handleFileupload()
{
    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $upload = $_FILES["file"];
    $filename = $upload["name"];
    $extension = strtolower(end(explode(".", $filename)));
    if (!in_array($extension, $allowedExts)) {
        die("ACHTUNG: Scheint keine Bilddatei zu sein: {$filename}");
    }
    if ($upload["error"] > 0) {
        die("Return Code: " . $upload["error"]);
    }
    $prefix = time() . "-";
    $destination = TARGET_DIRECTORY . "/" . $prefix . $filename;
    $from = $upload["tmp_name"];
    move_uploaded_file($from, $destination);
    createThumb($destination, TARGET_DIRECTORY . "/" . $prefix . "thumb-" . $filename);
}
示例#5
0
文件: bt.php 项目: khanab85/InterOlpe
function createThumbsFromFolder($thisAlbumPath, $thisThumbnailAlbumPath)
{
    if (is_dir("{$thisThumbnailAlbumPath}") == 0) {
        mkdir("{$thisThumbnailAlbumPath}", 0777);
        print "<TR><TD align='left' colspan='2'><font face='arial, helvetica' size='small'><b>{$thisThumbnailAlbumPath} created</b> </font><br>";
    }
    $innerdir = opendir("{$thisAlbumPath}");
    while (false !== ($innerfile = readdir($innerdir))) {
        //print "$innerfile";
        $thisExt = substr("{$innerfile}", -3);
        if (strtolower($thisExt) == 'jpg' && file_exists($thisThumbnailAlbumPath . "/" . $innerfile) == 0) {
            print "<TR><TD width='300'><font face='arial, helvetica' size='small'>{$thisThumbnailAlbumPath}/{$innerfile}</TD><TD>";
            //print $innerfile . " - " . $album;
            $thisImagePath = $thisAlbumPath . "/" . $innerfile;
            $thisThumbnailPath = $thisThumbnailAlbumPath . "/" . $innerfile;
            print createThumb($thisImagePath, $thisThumbnailPath);
            print "</font></TD></TR>";
        }
    }
}
示例#6
0
function upload()
{
    global $destFolder, $shouldBeImage, $target_file, $max_file_size, $basedir;
    if (!file_exists($basedir . $destFolder)) {
        mkdir($basedir . $destFolder, 0777, true);
    }
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        if ($shouldBeImage) {
            createThumb($target_file, $basedir . $destFolder . '/thumbnails');
        }
        $_SESSION['TEMP_UPLOAD'] = $target_file;
        $_SESSION['UPLOAD_MESSAGE'] = 'upload success';
        $_SESSION['UPLOAD_SUCCESS'] = 'true';
    } else {
        if (filesize($target_file) > $max_file_size) {
            $_SESSION['UPLOAD_MESSAGE'] = 'file too large';
        } else {
            $_SESSION['UPLOAD_MESSAGE'] = 'specific error: ' . $_FILES["fileToUpload"]["error"];
        }
    }
}
示例#7
0
function regenVideoThumbs($vid)
{
    global $config;
    $err = NULL;
    $duration = getVideoDuration($vid);
    if (!$duration) {
        $err = 'Failed to get video duration! Converted video not found!?';
    }
    $fc = 0;
    $flv = $config['FLVDO_DIR'] . '/' . $vid . '.flv';
    if ($err == '') {
        settype($duration, 'float');
        $timers = array(ceil($duration / 2), ceil($duration / 2), ceil($duration / 3), ceil($duration / 4));
        @mkdir($config['TMP_DIR'] . '/thumbs/' . $vid);
        foreach ($timers as $timer) {
            if ($config['thumbs_tool'] == 'ffmpeg') {
                $cmd = $config['ffmpeg'] . ' -i ' . $flv . ' -f image2 -ss ' . $timer . ' -s ' . $config['img_max_width'] . 'x' . $config['img_max_height'] . ' -vframes 2 -y ' . $config['TMP_DIR'] . '/thumbs/' . $vid . '/%08d.jpg';
            } else {
                $cmd = $config['mplayer'] . ' ' . $flv . ' -ss ' . $timer . ' -nosound -vo jpeg:outdir=' . $config['TMP_DIR'] . '/thumbs/' . $vid . ' -frames 2';
            }
            exec($cmd);
            $tmb = $fc == 0 ? $vid : $fc . '_' . $vid;
            $fd = get_thumb_dir($vid) . '/' . $tmb . '.jpg';
            $ff = $config['TMP_DIR'] . '/thumbs/' . $vid . '/00000002.jpg';
            if (!file_exists($ff)) {
                $ff = $config['TMP_DIR'] . '/thumbs/' . $vid . '/00000001.jpg';
            }
            if (!file_exists($ff)) {
                $ff = $config['BASE_DIR'] . '/images/default.gif';
            }
            createThumb($ff, $fd, $config['img_max_width'], $config['img_max_height']);
            ++$fc;
        }
        delete_directory($config['TMP_DIR'] . '/thumbs/' . $vid);
    }
    return $err;
}
    } elseif (!in_array($_FILES['image_upload_file']["type"], $allowedImageType)) {
        $output['error'] = "You can only upload JPG, PNG and GIF file";
    } elseif (round($_FILES['image_upload_file']["size"] / 1024) > 4096) {
        $output['error'] = "You can upload file size up to 4 MB";
    } else {
        /*create directory with 777 permission if not exist - start*/
        createDir(IMAGE_SMALL_DIR);
        createDir(IMAGE_MEDIUM_DIR);
        /*create directory with 777 permission if not exist - end*/
        $path[0] = $_FILES['image_upload_file']['tmp_name'];
        $file = pathinfo($_FILES['image_upload_file']['name']);
        $fileType = $file["extension"];
        $desiredExt = 'jpg';
        $fileNameNew = rand(333, 999) . time() . ".{$desiredExt}";
        $path[1] = IMAGE_MEDIUM_DIR . $fileNameNew;
        $path[2] = IMAGE_SMALL_DIR . $fileNameNew;
        //
        list($width, $height, $type, $attr) = getimagesize($_FILES['image_upload_file']['tmp_name']);
        //
        if (createThumb($path[0], $path[1], $fileType, $width, $height, $width)) {
            if (createThumb($path[1], $path[2], "{$desiredExt}", $width, $height, $width)) {
                $output['status'] = TRUE;
                $output['image_medium'] = $path[1];
                $output['image_small'] = $path[2];
            }
        }
    }
    echo json_encode($output);
}
?>
	
示例#9
0
function moveUploadImage($path, $file, $tmpfile, $max)
{
    //upload your image and give it a random name so no conflicts occur
    $rand = rand(1000, 9000);
    $save_path = $path . $rand . $file;
    //prep file for db and gd manipulation
    $bad_char_arr = array(' ', '&', '(', ')', '*', '[', ']', '<', '>', '{', '}');
    $replace_char_arr = array('-', '_', '', '', '', '', '', '', '', '', '');
    $save_path = str_replace($bad_char_arr, $replace_char_arr, $save_path);
    //move the temp file to the proper place
    if (move_uploaded_file($tmpfile, $save_path)) {
        $ext = pathinfo($save_path, PATHINFO_EXTENSION);
        $base = pathinfo($save_path, PATHINFO_FILENAME);
        $dir = pathinfo($save_path, PATHINFO_DIRNAME);
        $base_path = "{$dir}/{$base}";
        copy($save_path, "{$base_path}" . "_thumb" . "." . "{$ext}");
        createThumb("{$base_path}" . "_thumb" . "." . "{$ext}", $ext, 150);
        createThumb("{$base_path}" . "." . "{$ext}", $ext, 640);
        //chmod("$base_path" . "_thumb" . "." . "$ext", 0644);
        //chmod("$base_path" . "." . "$ext", 0644);
        return $save_path;
    }
    unlink($tmpfile);
    return false;
}
    $allowedImageType = array("image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/x-png");
    if ($_FILES['image_upload_file']["error"] > 0) {
        $output['error'] = "Error in File";
    } elseif (!in_array($_FILES['image_upload_file']["type"], $allowedImageType)) {
        $output['error'] = "You can only upload JPG, PNG and GIF file";
    } elseif (round($_FILES['image_upload_file']["size"] / 1024) > 4096) {
        $output['error'] = "You can upload file size up to 4 MB";
    } else {
        /*create directory with 777 permission if not exist - start*/
        createDir(IMAGE_SMALL_DIR);
        createDir(IMAGE_MEDIUM_DIR);
        /*create directory with 777 permission if not exist - end*/
        $path[0] = $_FILES['image_upload_file']['tmp_name'];
        $file = pathinfo($_FILES['image_upload_file']['name']);
        $fileType = $file["extension"];
        $desiredExt = 'jpg';
        $fileNameNew = rand(333, 999) . time() . ".{$desiredExt}";
        $path[1] = IMAGE_MEDIUM_DIR . $fileNameNew;
        $path[2] = IMAGE_SMALL_DIR . $fileNameNew;
        if (createThumb($path[0], $path[1], $fileType, IMAGE_MEDIUM_SIZE, IMAGE_MEDIUM_SIZE, IMAGE_MEDIUM_SIZE)) {
            if (createThumb($path[1], $path[2], "{$desiredExt}", IMAGE_SMALL_SIZE, IMAGE_SMALL_SIZE, IMAGE_SMALL_SIZE)) {
                $output['status'] = TRUE;
                $output['image_medium'] = $path[1];
                $output['image_small'] = $path[2];
            }
        }
    }
    echo json_encode($output);
}
?>
	
示例#11
0
function processNewImage()
{
    $fullimagePath = $_FILES['myFile']['tmp_name'];
    //print_r ($_FILES);
    $thumbimagePath = "./thumb/thumb.jpg";
    $category = htmlentities($_POST['category'], ENT_QUOTES);
    $description = htmlentities($_POST['description'], ENT_QUOTES);
    if ($category == 'none' && $description == "") {
        print "Incorrect category and/or no description entered.";
        return;
    }
    $info = getimagesize($fullimagePath);
    $ty = $info[2];
    // type
    if ($ty != 2) {
        $error = "incorrect file type given. Please upload a jpg image.";
        print $error;
        return;
    } else {
        createThumb($fullimagePath, $thumbimagePath);
        $fileContents = addslashes(file_get_contents($fullimagePath));
        $thumbContents = addslashes(file_get_contents($thumbimagePath));
        $db = dbConnect();
        if (!$db) {
            print "Error in connecting to database.";
            return;
        } else {
            $query = "insert into myImages (fullImage, category, description, thumbImage)" . " values ('{$fileContents}','{$category}','{$description}','{$thumbContents}');";
            $result = $db->Execute($query);
            if (!$result) {
                $queryError = "error in the query";
                print $queryError;
                return;
            }
        }
    }
}
示例#12
0
 // Wurde wirklich eine Datei hochgeladen?
 if (is_uploaded_file($_FILES["image1"]["tmp_name"])) {
     // Gültige Endung? ($ = Am Ende des Dateinamens) (/i = Groß- Kleinschreibung nicht berücksichtigen)
     if (preg_match("/\\." . $allowed_image_filetypes . "\$/i", $_FILES["image1"]["name"])) {
         // Datei auch nicht zu groß
         if ($_FILES["image1"]["size"] <= $max_upload_size) {
             // Alles OK -> Datei kopieren
             //http://www.php.net/manual/en/features.file-upload.php, use basename to preserve filename for multiple uploaded files.... if needed ;)
             //save uploaded source image, do watermark and resize
             if (move_uploaded_file($_FILES["image1"]["tmp_name"], $tm_nlimgpath . "/" . $NL_Imagename1_source)) {
                 //copy source image to tmp image
                 copy($tm_nlimgpath . "/" . $NL_Imagename1_source, $tm_nlimgpath . "/" . $NL_Imagename1_tmp);
                 //create thumb ?!
                 if (${$InputName_ImageResize} == 1 && ${$InputName_ImageResizeSize} > 0) {
                     //save resized image
                     $rs = createThumb($tm_nlimgpath . "/" . $NL_Imagename1_tmp, $tm_nlimgpath . "/" . $NL_Imagename1_resized, ${$InputName_ImageResizeSize}, 95);
                     if ($rs) {
                         //move resized image to tmp image
                         rename($tm_nlimgpath . "/" . $NL_Imagename1_resized, $tm_nlimgpath . "/" . $NL_Imagename1_tmp);
                         $_MAIN_MESSAGE .= "<br>" . sprintf(___("Bildgröße geändert in max. %s px."), ${$InputName_ImageResizeSize});
                     } else {
                         $_MAIN_MESSAGE .= "<br>" . sprintf(___("Fehler beim Ändern der Bildgröße in max. %s px."), ${$InputName_ImageResizeSize});
                     }
                 }
                 #add watermark to image?
                 if (${$InputName_ImageWatermark} == 1) {
                     if (file_exists($watermark_image)) {
                         $wm = watermark($tm_nlimgpath . "/" . $NL_Imagename1_tmp, $tm_nlimgpath . "/" . $NL_Imagename1_watermarked, $watermark_image, 95);
                         if ($wm[0]) {
                             //move resized image to tmp image
                             rename($tm_nlimgpath . "/" . $NL_Imagename1_watermarked, $tm_nlimgpath . "/" . $NL_Imagename1_tmp);
示例#13
0
function getThumb()
{
    global $db, $prefix, $iConfig, $moduleName;
    $pictureId = intval($_GET['pictureid']);
    $thumbsPath = $iConfig['thumbs_path'];
    $uploadPath = $iConfig['upload_path'];
    $thumbsFormat = strtolower($iConfig['thumbs_format']);
    $thumbsRealPath = iPath($thumbsPath);
    if ($pictureId) {
        $picture = $db->sql_fetchrow($db->sql_query('SELECT * FROM ' . $prefix . '_igallery_pictures WHERE picture_id=' . $pictureId . ' LIMIT 0,1'));
        $filename = $picture['picture_file'];
        $pictureType = $picture['picture_type'];
        $albumId = intval($picture['album_id']);
        $album = $db->sql_fetchrow($db->sql_query('SELECT album_title, album_folder FROM ' . $prefix . '_igallery_albums WHERE album_id=\'' . $albumId . '\' LIMIT 0,1'));
        $folderName = $album['album_folder'];
        $info = pathinfo($filename);
        $rawFilename = str_replace($info['extension'], '', $filename);
        if ($pictureType) {
            $thumb = iPath($uploadPath . 'thumbs/' . $rawFilename . $thumbsFormat);
            if (file_exists($thumb)) {
                $thumbPath = $thumb;
            } else {
                createThumb($moduleName, '', $filename, $type = 1);
                $thumbPath = NUKE_BASE_DIR . 'modules/' . $moduleName . '/images/no_image.png';
            }
        } else {
            $thumb = iPath($thumbsPath . $folderName . '/' . $rawFilename . $thumbsFormat);
            if (!file_exists($thumbsRealPath . $folderName)) {
                @mkdir($thumbsRealPath . $folderName);
            }
            if (file_exists($thumb)) {
                $thumbPath = $thumb;
            } else {
                createThumb($moduleName, $folderName, $filename);
                $thumbPath = NUKE_BASE_DIR . 'modules/' . $moduleName . '/images/no_image.png';
            }
        }
    }
    if (!isset($thumbPath) || empty($thumbPath)) {
        $thumbPath = NUKE_BASE_DIR . 'modules/' . $moduleName . '/images/no_image.png';
    }
    if (file_exists($thumbPath) && is_readable($thumbPath)) {
        $info = getimagesize($thumbPath);
        $offset = 3600 * 24 * 60;
        // Set offset to keep in cache for 2 months (thumbs would not really change that much)
        header('Cache-Control: max-age=' . $offset . ', must-revalidate');
        header('Content-type: ' . $info['mime']);
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $offset) . ' GMT');
        // check if the browser is sending a $_SERVER['HTTP_IF_MODIFIED_SINCE'] global variable
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            // if the browser has a cached version of this image, send 304
            header('Last-Modified: ' . $_SERVER['HTTP_IF_MODIFIED_SINCE'], true, 304);
            exit;
        }
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($thumbPath)) . ' GMT');
        ob_start();
        readfile($thumbPath);
        //ob_end_flush();
        $outputImage = ob_get_contents();
        //header('Content-length: '.ob_get_length()); //This was causing a loop reloading the picture 'til browser just give up (Google Chrome)
        ob_end_clean();
        echo $outputImage;
    }
    exit;
}
    function install() {

      // SET GALLERY OPTIONS HERE
      // -----------------------
      // Set Gallery options by editing this text:

      $options .= '<simpleviewerGallery maxImageWidth="380" maxImageHeight="380" textColor="0x000000" frameColor="0x000000" frameWidth="5" stagePadding="5" thumbnailColumns="2" thumbnailRows="2" navPosition="right" title="OOS [Gallery]" enableRightClickOpen="false" backgroundImagePath="images/gallery.jpg" imagePath="gallery/images/" thumbPath="gallery/thumbs/">';

      // Set showDownloadLinks to true if you want to show a 'Download Image' link as the caption to each image.
      $showDownloadLinks = false;

      // set useCopyResized to true if thumbnails are not being created.
      // This can be due to the imagecopyresampled function being disabled on some servers
      $useCopyResized = false;

      // Set sortImagesByDate to true to sort by date. Otherwise files are sorted by filename.
      $sortImagesByDate = true;

      // Set sortInReverseOrder to true to sort images in reverse order.
      $sortInReverseOrder = true;

      // END OF OPTIONS
      // -----------------------

      $tgdInfo    = getGDversion();
      if ($tgdInfo == 0){
        // print "Note: The GD imaging library was not found on this Server. Thumbnails will not be created. Please contact your web server administrator.<br><br>";
        $error_gdlib = "Note: The GD imaging library was not found on this Server. Thumbnails will not be created. Please contact your web server administrator.";
        $messageStack->add($error_gdlib, 'error');
      }

      if ($tgdInfo < 2){
        // print "Note: The GD imaging library is version ".$tgdInfo." on this server. Thumbnails will be reduced quality. Please contact your web server administrator to upgrade GD version to 2.0.1 or later.<br><br>";
        $error_gdlib = "Note: The GD imaging library is version ".$tgdInfo." on this server. Thumbnails will be reduced quality. Please contact your web server administrator to upgrade GD version to 2.0.1 or later.";
        $messageStack->add($error_gdlib, 'error');
      }

/*
     if ($sortImagesByDate){
       print "Sorting images by date.<br>";
     } else {
       print "Sorting images by filename.<br>";
     }

     if ($sortInReverseOrder){
       print "Sorting images in reverse order.<br><br>";
     } else {
       print "Sorting images in forward order.<br><br>";
     }
*/


      //loop thru images
      $xml = '<?xml version="1.0" encoding="UTF-8" ?>'.$options;
      $folder = opendir(OOS_GALLERY_PATH ."images");
      while($file = readdir($folder)) {
        if ($file == '.' || $file == '..' || $file == 'CVS' || $file == '.svn') continue;

        if ($sortImagesByDate){
          $files[$file] = filemtime(OOS_GALLERY_PATH . "images/$file");
        } else {
          $files[$file] = $file;
        }
      }

      // now sort by date modified
      if ($sortInReverseOrder){
        arsort($files);
      } else {
        asort($files);
      }


      foreach($files as $key => $value) {
        $xml .= '
        <image>';
        $xml .= '<filename>'.$key.'</filename>';

        //add auto captions: 'Image X'
        if ($showDownloadLinks){
          $xml .= '<caption><![CDATA[<A href="images/'.$key.'" target="_blank"><U>Open image in new window</U></A>]]></caption>';
        }
        $xml .= '</image>';

        // print "- Created Image Entry for: $key<br>";

        if (!file_exists(OOS_GALLERY_PATH. "/thumbs/".$key)){
          if (createThumb($key)){
           // print "- Created Thumbnail for: $key<br>";
          }
        }
      }

      closedir($folder);

      $xml .= '</simpleviewerGallery>';

      $file = OOS_ABSOLUTE_PATH . 'gallery.xml';
      if (!$file_handle = fopen($file,"w")) {
        // print "<br>Cannot open XML document: $file<br>";
      } elseif (!fwrite($file_handle, $xml)) {
        // print "<br>Cannot write to XML document: $file<br>";
      } else {
        // print "<br>Successfully created XML document: $file<br>";
      }
      fclose($file_handle);

      return true;
    }
示例#15
0
                        imagejpeg($newImg, "d:/Websites/myrealtornow.ca/images/" . $matrixid . '_' . $m . ".jpg", 100);
                    }
                    if (file_exists($newname)) {
                        $start = 'd:/websites/myrealtornow.ca/images/' . $matrixid . '_' . $m;
                        if (!file_exists($start . '_sm1.jpg')) {
                            save_resize_image($newname, 475, 350, $ext, '_sm1');
                        }
                        if (!file_exists($start . '_sm2.jpg')) {
                            save_resize_image($newname, 150, 110, $ext, '_sm2');
                        }
                        if (!file_exists($start . '_sm3.jpg')) {
                            save_resize_image($newname, 105, 332, $ext, '_sm3');
                        }
                        save_resize_image($newname, 450, 1200, $ext, '');
                        if (!file_exists($start . '_sm4.jpg')) {
                            createThumb($newname, $ext, '_sm4', 125, 125);
                        }
                        $n = $m + 1;
                        $sql = 'select * from tb_listing_images where imagename="' . $matrixid . '_' . $m . '" and listingid=' . $lid;
                        $res = mysql_query($sql);
                        if (mysql_num_rows($res) == 0) {
                            $sql2 = 'insert into tb_listing_images (listingid,imagename,ext,ordr) values (' . $lid . ',"' . $matrixid . '_' . $m . '","jpg",' . $n . ')';
                            $res = mysql_query($sql2);
                        }
                    }
                }
            }
        }
    }
}
function save_resize_image($file, $height, $width, $ext, $suffix)
示例#16
0
function processNewImage()
{
    $_SESSION['validUser'] = 1;
    $category = htmlentities($_POST['category'], ENT_QUOTES);
    $description = htmlentities($_POST['description'], ENT_QUOTES);
    $fileType = extension();
    $file = $_FILES['myFile']['tmp_name'];
    $array = getimagesize($file);
    $error = "";
    $ty = $array[2];
    if ($ty != IMAGETYPE_JPEG && $ty != IMAGETYPE_PNG && $ty != IMAGETYPE_GIF && $filetype != "Invalid Type") {
        $error .= "Invalid file type. <br />";
    }
    if ($description == "" || $category > 3 || $category < 1) {
        $error .= "Missing description.<br />";
    }
    if ($error) {
        print "<div class='special'>";
        print $error;
        print "</div>";
        return;
    } else {
        if ($category == 1) {
            $category = "Christmas";
        } else {
            if ($category == 2) {
                $category = "Halloween";
            } else {
                if ($category == 3) {
                    $category = "Tropical";
                }
            }
        }
        //$name=$_FILES['myFile']['name'];
        $thumbFile = "../images/myThumb." . $fileType;
        createThumb($file, $thumbFile, 90, $fileType);
        //creates thumbnail
        $imageContents = addslashes(file_get_contents($file));
        $thumbContents = addslashes(file_get_contents($thumbFile));
        //CONNECT TO DATABASE
        $db = dbConnect();
        $query = "insert into myImages(fullImage, thumbImage, description, " . "category, ext)" . "values('{$imageContents}','{$thumbContents}', " . "'{$description}','{$category}', '{$fileType}');";
        $result = $db->Execute($query);
        if (!$result) {
            print "System Error--Contact Administrator.";
        }
    }
}
示例#17
0
    // destroy session data in storage
}
$_SESSION['LAST_ACTIVITY'] = time();
// update last activity time stamp
if (!isset($_SESSION['current_user']['login_user_id'])) {
    header("Location: login.php");
}
//$current_user = strtoupper($_SESSION['current_user']['login_username']);
//get unique id
$up_id = uniqid();
$root_dir = $_SERVER["DOCUMENT_ROOT"] . '/images';
$di = new RecursiveDirectoryIterator($root_dir);
foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
    $path_parts = pathinfo($filename);
    if (fileTypeCorrect($filename, true)) {
        createThumb($filename, $path_parts['dirname'] . '/thumbnails');
    }
}
function createThumb($src, $dest)
{
    if (!file_exists($dest)) {
        mkdir($dest, 0777, true);
    }
    $source_image = imagecreatefromjpeg($src);
    $width = imagesx($source_image);
    $height = imagesy($source_image);
    $virtual_image = imagecreatetruecolor(100, 100);
    imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, 100, 100, $width, $height);
    if (!file_exists($dest . '/' . basename($src, '.' . pathinfo($src, PATHINFO_EXTENSION)) . '_thumb.jpg')) {
        imagejpeg($virtual_image, $dest . '/' . basename($src, '.' . pathinfo($src, PATHINFO_EXTENSION)) . '_thumb.jpg');
    }
示例#18
0
function images()
{
    global $gallerymessage, $max_upload_image_size, $prefix;
    $out = "<h2>{$gallerymessage['7']}</h2>\n<hr />\n<div align=\"center\">\n";
    if ($_GET['do'] == "gallery" && $_GET['action'] == "delete" && $_GET['name'] != "") {
        $out .= deleteimage($_GET['name']);
    }
    if ($_GET['do'] == "gallery" && $_GET['action'] == "deletegal" && $_GET['name'] != "") {
        $galleryname = $_GET['name'];
        $out .= "<h4 style=\"color: red;\">" . $gallerymessage[3] . "{$galleryname}?</h4>\n";
        $out .= "<p>{$gallerymessage['4']}</p>\n";
        $out .= "<form method=\"post\" action=\"\">\n";
        $out .= "<input type=\"hidden\" name=\"name\" value=\"{$galleryname}\" />\n";
        $out .= "<input type=\"hidden\" name=\"submit\" value=\"Delete Gallery\" />\n";
        $out .= "<input type=\"submit\" name=\"aaa\" value=\"" . $gallerymessage[5] . "\" />\n";
        $out .= "</form>\n";
    }
    $out .= "<h3>{$gallerymessage['8']}</h3>\n";
    if ($maxfilesize == "") {
        $maxfilesize = 200000;
    }
    if ($thumbnailwidth == "") {
        $thumbnailwidth = 100;
    }
    if (file_exists("./addons/gallery/settings.php")) {
        require_once "./addons/gallery/settings.php";
    }
    $out .= "<form method=\"post\" action=\"\">\n";
    $out .= "<table><tr><td>{$gallerymessage['9']}&nbsp;</td><td><input type=\"text\" name=\"maxfilesize\" value=\"{$maxfilesize}\" /></td></tr>\n";
    $out .= "<tr><td>{$gallerymessage['10']}&nbsp;</td><td><input type=\"text\" name=\"thumbnailwidth\" value=\"{$thumbnailwidth}\" /></td></tr>\n";
    $out .= "<tr><td><input type=\"hidden\" name=\"submit\" value=\"Submit Settings\" /></td><td><input type=\"submit\" name=\"aaa\" value=\"{$gallerymessage['11']}\" /></td></tr>\n";
    $out .= "</table>\n</form>\n<hr />\n";
    $out .= "<form enctype=\"multipart/form-data\" method=\"post\" action=\"\">\n<fieldset style=\"border: 0;\">\n";
    $out .= "<h3>{$gallerymessage['58']}</h3>\n";
    $out .= "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$maxfilesize}\" />\n";
    $out .= "<table>\n";
    $out .= "<tr><td>{$gallerymessage['60']}</td><td><input type=\"text\" name=\"imagename\" value=\"\" style=\"width: 100%\" /></td></tr>\n";
    $out .= "<tr><td>" . $gallerymessage[59] . ":</td><td><input name=\"uploadedfile\" type=\"file\" />\n</td></tr>\n";
    $out .= "<tr><td>" . $gallerymessage[61] . ":</td><td>";
    $out .= "<select name=\"gal\">\n";
    $folder = "./galeries";
    $files = filelist('/./', $folder, 1);
    foreach ($files as $file) {
        if ($file != ".." && $file != ".") {
            $out .= '<option value="' . $file . "\">" . $file . "&nbsp;</option>\n";
        }
    }
    $out .= "</select>\n</td></tr>\n";
    $out .= "<tr><td></td><td>";
    $out .= "<input type=\"hidden\" name=\"submit\" value=\"Upload image\" />";
    $out .= "<input type=\"submit\" name=\"aaa\" value=\"" . $gallerymessage[58] . "\" /></td>";
    $out .= "</tr>\n</table>\n</fieldset>\n</form>\n<hr /><h3>" . $gallerymessage[62] . "</h3>\n";
    $out .= "<form method=\"post\" action=\"\">\n<fieldset style=\"border: 0;\">\n";
    $out .= "<table>\n<tr><td>{$gallerymessage['117']}:</td>\n<td>";
    $out .= "<input name=\"galeryname\" type=\"text\" value=\"\" />\n</td></tr>\n";
    $out .= "<tr><td><input type=\"hidden\" name=\"submit\" value=\"Create Gallery\" /></td>\n<td>";
    $out .= "<input type=\"submit\" name=\"aa\" value=\"{$gallerymessage['62']}\" /></td>";
    $out .= "</tr></table>\n</fieldset>\n</form>\n<hr />\n";
    $out .= "<h3>" . $gallerymessage[148] . " " . $gallerymessage[176] . "</h3>\n";
    $files = filelist('/./', $folder, 1);
    $none = true;
    foreach ($files as $file) {
        if ($none) {
            $none = false;
            $out .= "<table>";
        }
        if ($file != ".." && $file != ".") {
            $out .= "<tr>";
            $out .= "<td><a href=\"" . $_SERVER["SCRIPT_NAME"] . "?do=gallery&amp;action=deletegal&amp;name={$file}\">";
            $out .= "<img src=\"./images/editdelete.png\" alt=\"delete\" title=\"Delete gallery {$file}\" align=\"left\" border=\"0\" /></a></td>";
            $out .= "<td>" . $file . "</td></tr>\n";
        }
    }
    if (!$none) {
        $out .= "</table>\n";
    }
    $out .= "<hr /><h3>" . $gallerymessage[148] . " " . $gallerymessage[38] . "</h3>\n";
    $out .= "<table>\n";
    $folder = "./galeries";
    $files = filelist('/./', $folder, 1);
    $gal = 0;
    foreach ($files as $file) {
        if ($gal == 0) {
            $out .= "\n<form method=\"post\" name=\"galery\" action=\"\">\n";
            $out .= "<select onchange=\"document.galery.submit();\" name=\"selectgal\">\n";
            $first = $file;
        }
        $gal++;
        $out .= "<option value=\"" . $file . "\"";
        if ($_POST['selectgal'] == $file) {
            $out .= " selected";
        }
        $out .= ">" . $file . "&nbsp;</option>\n";
    }
    if ($gal > 0) {
        $out .= "</select></form>\n<br /><br />\n";
        if ($_POST['selectgal'] != "") {
            $file = $_POST['selectgal'];
        } else {
            $file = $first;
        }
        $folder1 = "./galeries/" . $file;
        $file1 = filelist("/./", $folder1);
        foreach ($file1 as $fil) {
            $out .= "<tr><td><a href=\"" . $_SERVER["SCRIPT_NAME"] . "?do=gallery&amp;action=delete&amp;name={$folder1}/{$fil}\">";
            $out .= "<img src=\"./images/editdelete.png\" alt=\"delete\" title=\"Delete {$fil}\" align=\"left\" border=\"0\" /></a></td>";
            $thumb = createThumb($folder1 . "/" . $fil, "thumbs/", 100);
            if ($row = fetch_array(dbquery("SELECT * FROM " . $prefix . "images WHERE file=\"" . basename($thumb) . "\""))) {
                $filename = decode($row['name']);
            } else {
                $filename = $thumb;
            }
            $out .= "<td>{$filename}</td>";
            $out .= "<td align=\"center\" >";
            $out .= "<img src=\"thumbs/{$thumb}\"  alt=\"{$filename}\"  title=\"{$filename}\" /></td></tr>\n";
        }
    }
    $out .= "</table>\n";
    $out .= "</div>\n";
    return $out;
}
示例#19
0
     $fileName = $_FILES["myfile"]["name"];
     //Get file Extension
     $extension = strtolower(end(explode(".", $fileName)));
     //Give file a unique name
     $newImageNameNoExt = date('Y-m-d-H-i-s') . "_" . uniqid();
     $newImageName = $newImageNameNoExt . '.' . $extension;
     move_uploaded_file($_FILES["myfile"]["tmp_name"], $outputDir . $newImageName);
     $filePath = $outputDir . $newImageName;
     $fileSize = round(filesize($filePath) / 1000);
     $details = array();
     $details["name"] = $newImageNameNoExt;
     $details["extension"] = $extension;
     $details["size"] = $fileSize;
     $returnData[] = $details;
     //Create Thumbnail
     createThumb($newImageName);
     //Insert Into Database
     $query = "INSERT INTO " . $db_table . " (name,size) VALUES ('{$newImageName}',{$fileSize})";
     $dbc->query($query) or die('Database Error: ' . $dbc->error);
     $dbc->close();
 } else {
     //Multiple files, file[]
     $fileCount = count($_FILES["myfile"]["name"]);
     for ($i = 0; $i < $fileCount; $i++) {
         $fileName = $_FILES["myfile"]["name"][$i];
         //Get file Extension
         $extension = strtolower(end(explode(".", $fileName)));
         //Give file a unique name
         $newImageNameNoExt = date('Y-m-d-H-i-s') . "_" . uniqid();
         $newImageName = $newImageNameNoExt . '.' . $extension;
         move_uploaded_file($_FILES["myfile"]["tmp_name"][$i], $outputDir . $newImageName);
function getThumbnailKORA($sourceFile, $width, $height, $debug = false)
{
    // Parse the sourceFile to get the path
    if (!preg_match('/^[0-9A-F]+-[0-9A-F]+-[0-9A-F]+.*/', $sourceFile)) {
        return $debug ? 'Invalid Filename' : '';
    } else {
        $parts = explode('-', $sourceFile);
        $pid = hexdec($parts[0]);
        $sid = hexdec($parts[1]);
        $sourcePath = basePath . fileDir . $pid . '/' . $sid . '/' . $sourceFile;
        $thumbPath = baseFilePath . 'thumbs/' . (string) $width . 'x' . (string) $height . '_' . $sourceFile;
    }
    // See if the file exists
    if (file_exists($sourcePath)) {
        if (file_exists($thumbPath)) {
            // If so, see if the source file is newer than the cached file
            if (filemtime($thumbPath) < filemtime($sourcePath)) {
                // If so, delete the thumb and recreate it
                if (unlink($thumbPath)) {
                    // create the thumbnail
                    if (!createThumb($sourcePath, $thumbPath, $width, $height)) {
                        return $debug ? 'CreateThumb (1) failed' : '';
                    }
                } else {
                    return $debug ? 'Thumb Deletion failed' : '';
                }
            }
            // else we don't care because the thumb is up to date
        } else {
            // create the thumbnail
            if (!createThumb($sourcePath, $thumbPath, $width, $height)) {
                return $debug ? 'CreateThumb (2) failed' : '';
            }
        }
    } else {
        return $debug ? "Source File {$sourcePath} Does Not Exist" : '';
    }
    // If so, create the thumbnail
    return baseURL . 'thumbs/' . (string) $width . 'x' . (string) $height . '_' . $sourceFile;
}
示例#21
0
function video_to_frame($fpath, $name, $mov, $chnl)
{
    global $config;
    $frcount = $mov->getFrameCount() - 1;
    $try = 1;
    $fc = 1;
    while (1) {
        $p = rand(1, $frcount);
        $ff_frame = $mov->getFrame($p);
        if ($ff_frame == true) {
            $gd_image = $ff_frame->toGDImage();
            $ff = $config['TMB_DIR'] . "/" . $name . ".jpg";
            imagejpeg($gd_image, $ff);
            $fd = $config['TMB_DIR'] . "/" . $fc . "_" . $name . ".jpg";
            createThumb($ff, $fd, $config['img_max_width'], $config['img_max_height']);
            $fc++;
        }
        $try++;
        if ($try > 10 || $fc == 4) {
            break;
        }
    }
}
示例#22
0
 /**
  * Return the path with filename of thumbnail of the strip in PNG format
  * @return string the path with filename of thumbnail of the strip in PNG format
  * @access public
  */
 public function getThumbSrc()
 {
     $original = $this->getFilenamePng();
     $dest = Config::getThumbFolder() . '/' . pathinfo(Config::getStripFolder() . '/' . $this->getFilename(), PATHINFO_FILENAME) . '.png';
     if (createThumb($original, $dest) === true) {
         return $dest;
     } else {
         return $original;
     }
 }
示例#23
0
        $im = imageCreateTrueColor($width, $height);
        $bgColor = imagecolorallocate($img, 255, 255, 255);
        imagefill($im, 0, 0, $bgColor);
        $parts = array("hair" => array(0, 0, 230, 120), "eyes" => array(0, 120, 230, 94), "mouth" => array(0, 214, 230, 113));
        foreach ($parts as $part => $dst) {
            // copy each slice into the new image
            $tmpfile = "../images/" . ${$part} . ".jpg";
            if (file_exists($tmpfile)) {
                $tmp = imageCreateFromJpeg($tmpfile);
                imagecopy($im, $tmp, $dst[0], $dst[1], $dst[0], $dst[1], $dst[2], $dst[3]);
                imagedestroy($tmp);
            }
        }
        imagejpeg($im, "../" . $outfile);
        if (!file_exists("../" . $thumbfile)) {
            $thumb = createThumb($im, 55);
            imagejpeg($thumb, "../" . $thumbfile);
        }
        $result['addToList'] = true;
        $result['thumb'] = $thumbfile;
    } else {
        // duplicate!
        $result["duplicate"] = true;
    }
    $result["name"] = $nick;
    $result["clan"] = getClanName($nick);
    $result["file"] = $outfile;
    // send the final data back as a success!
    print json_encode($result);
} else {
    print json_encode(array("error" => "error, someone didn't flip enough!"));
示例#24
0
文件: page.php 项目: joeybaker/iomhas
//if there's more pages, display the nav link
if ($pageCount > 1) {
    echo '<p id="pageNav"><a id="next" href="page2.php">next page</a></p>' . "\n";
    //this creates pages for infinite scroll. We start on page 2 because the index is page 1. We'll first check to make sure we haven't done this before.
    if (!is_generated() || is_generate_url()) {
        for ($currentPage = 2; $currentPage <= $pageCount; $currentPage++) {
            //create a new page and overwrite any content previously written there.
            $pagename = "page" . $currentPage . ".php";
            $fname = fopen($pagename, 'w') or die("can't open file");
            //write the header
            $beginHTML = '<?php  $topdir = "../"; include("' . $topdir . 'pageHeader.php"); ?>' . "\n";
            fwrite($fname, $beginHTML);
            //write out all the photos.
            for ($i = 0; $i < $photosPerPage; $i++) {
                $currentPhoto = getCurrentPhoto($currentPhotoCounter);
                createThumb($currentPhoto);
                $display = showPhotoToString($currentPhoto);
                createPermalinks($currentPhotoCounter);
                $currentPhotoCounter++;
                fwrite($fname, $display);
                if ($currentPhotoCounter == $photoCount - 1) {
                    break;
                }
                //ensure that don't create photos that aren't there.
            }
            //create the nav link
            $nextPage = $currentPage + 1;
            $navLinkString = '<p id="pageNav"><a id="next" href="page' . $nextPage . '.php">next page</a></p>';
            fwrite($fname, $navLinkString);
            //if this is the last page, let us know that
            if ($currentPage == $pageCount) {
示例#25
0
function galery($gal = "", $width = 0, $height = 0)
{
    global $gallerymessage, $set, $prefix;
    if (file_exists("addons/gallery/lang/lang_" . $set['language'] . ".php")) {
        require_once "addons/gallery/lang/lang_" . $set['language'] . ".php";
    } else {
        require_once "addons/gallery/lang/lang_en_US.php";
    }
    require_once "addons/gallery/common.php";
    if (file_exists("./addons/gallery/settings.php")) {
        require_once "./addons/gallery/settings.php";
    }
    $out = "";
    if ($gal != "") {
        $count = 1;
        $out .= "<h2>" . $gal . "</h2><br />\n";
        $galeries[0] = $gal;
    } else {
        if (isset($_POST['gal'])) {
            $gal = sanitize($_POST['gal']);
        }
        $folder = "galeries";
        $files = filelist('/./', $folder, 1);
        $folder = "galeries";
        $count = 0;
        foreach ($files as $file) {
            if ($file != ".." && $file != "." && is_dir($folder . "/" . $file)) {
                $galeries[$count] = $file;
                $count++;
            }
        }
    }
    if ($count > 1) {
        $out .= "\n<form method=\"post\" name=\"galery\" action=\"\"><fieldset style=\"border: 0;\">\n";
        $out .= "<select onchange=\"document.galery.submit();\" name=\"gal\" class=\"LNE_select\">\n";
        for ($i = 0; $i < $count; $i++) {
            $out .= '<option value="' . $galeries[$i] . '"';
            if ($gal == $galeries[$i]) {
                $out .= " selected";
            }
            $out .= ">" . $galeries[$i] . "&nbsp;</option>\n";
            if ($gal == "") {
                $gal = $galeries[$i];
            }
        }
        $out .= "</select>\n";
        $out .= "<input type=\"hidden\" name=\"showgalery\" value=\"{$gallerymessage['94']}\" />\n";
        $out .= "</fieldset></form>\n";
        $out .= "<br />\n";
    } else {
        $gal = $galeries[0];
    }
    //$gal contains the galery folder
    $gal = "galeries/" . $gal;
    $filez = filelist('/./', $gal);
    foreach ($filez as $file) {
        if ($file != "index.html") {
            if (intval($thumbnailwidth) == 0) {
                $thumbnailwidth = 100;
            }
            if ($row = fetch_array(dbquery("SELECT * FROM " . $prefix . "images WHERE file=\"" . basename($file) . "\""))) {
                $filename = decode($row['name']);
            } else {
                $filename = $file;
            }
            $out .= "<a href=\"{$gal}/{$file}\" rel=\"lytebox[" . $gal . "]\" title=\"{$filename}\" >";
            $tname = createThumb($gal . "/" . $file, "thumbs/", $thumbnailwidth);
            $out .= "<img src=\"thumbs/" . $tname . "\" width=\"{$thumbnailwidth}\" alt=\"{$filename}\" class=\"bordered\" /></a>\n";
        }
    }
    return $out;
}
示例#26
0
文件: index.php 项目: Igorpi25/Server
     if (!isset($_FILES['image']['name'])) {
         throw new Exception('Not received any file!F');
     }
     if ($_FILES['image']['size'] > 2 * 1024 * 1024) {
         throw new Exception('File is too big');
     }
     $tmpFile = $_FILES["image"]["tmp_name"];
     // Check if the file is really an image
     list($width, $height) = getimagesize($tmpFile);
     if ($width == null && $height == null) {
         throw new Exception('File is not image!F');
     }
     $image = new abeautifulsite\SimpleImage($tmpFile);
     $value_full = createThumb($image, size_full, $_SERVER['DOCUMENT_ROOT'] . path_fulls);
     $value_avatar = createThumb($image, size_avatar, $_SERVER['DOCUMENT_ROOT'] . path_avatars);
     $value_icon = createThumb($image, size_icon, $_SERVER['DOCUMENT_ROOT'] . path_icons);
     global $user_id;
     $db = new DbHandler();
     if (!$db->createAvatar($user_id, $value_full, $value_avatar, $value_icon)) {
         unlink($_SERVER['DOCUMENT_ROOT'] . path_fulls . $value_full);
         unlink($_SERVER['DOCUMENT_ROOT'] . path_avatars . $value_avatar);
         unlink($_SERVER['DOCUMENT_ROOT'] . path_icons . $value_icon);
         throw new Exception('Failed to insert to DB');
     }
     $response['message'] = 'File uploaded successfully!';
     $response['error'] = false;
     $response['success'] = 1;
 } catch (Exception $e) {
     // Exception occurred. Make error flag true
     $response['error'] = true;
     $response['message'] = $e->getMessage();
示例#27
0
文件: functions.php 项目: saarmae/VR1
function createThumbs()
{
    $images_dir = 'img/';
    $thumbs_dir = 'thumb/';
    $thumbs_height = 150;
    $image_files = get_files($images_dir);
    if (count($image_files)) {
        $index = 0;
        foreach ($image_files as $index => $file) {
            $index++;
            $thumbnail_image = $thumbs_dir . $file;
            if (!file_exists($thumbnail_image)) {
                $extension = get_file_extension($thumbnail_image);
                if ($extension) {
                    createThumb($images_dir . $file, $thumbnail_image, $thumbs_height);
                }
            }
        }
    }
}
示例#28
0
function processFile($filename, $tmp_name, $id, $sid, $cid)
{
    $pth = realpath('.') . '\\images';
    $filename = basename($filename);
    $ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
    if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png' || $ext == 'jpeg') {
        $newname = $pth . '\\' . strtolower($filename);
        if (!move_uploaded_file($tmp_name, $newname)) {
            $err = 'Error: A problem occurred during file upload!';
        }
    } else {
        $err = 'Error: Only .jpg,gif,png,jpeg files are accepted for upload';
    }
    if ($id != '') {
        $bse = substr($filename, 0, strrpos($filename, '.'));
        $sql = 'select * from tb_listing_images where listingid=' . $id . ' and imagename="' . $bse . '" and ext="' . $ext . '"';
        $res = mysql_query($sql);
        if (mysql_num_rows($res) == 0) {
            $sql = 'insert into tb_listing_images (listingid,imagename,ext) values (' . $id . ',"' . $bse . '","' . $ext . '")';
            $res = mysql_query($sql);
            $fid = mysql_insert_id();
        }
    }
    if ($sid != '') {
        $bse = substr($filename, 0, strrpos($filename, '.'));
        $sql = 'select * from tb_subdivision_images where subdivisionid=' . $sid . ' and imagename="' . $bse . '" and ext="' . $ext . '"';
        $res = mysql_query($sql);
        if (mysql_num_rows($res) == 0) {
            $sql = 'insert into tb_subdivision_images (subdivisionid,imagename,ext) values (' . $sid . ',"' . $bse . '","' . $ext . '")';
            $res = mysql_query($sql);
            $fid = mysql_insert_id();
        }
    }
    if ($cid != '') {
        $bse = substr($filename, 0, strrpos($filename, '.'));
        $sql = 'select * from tb_client_images where clientid=' . $cid . ' and imagename="' . $bse . '" and ext="' . $ext . '"';
        $res = mysql_query($sql);
        if (mysql_num_rows($res) == 0) {
            $sql = 'insert into tb_client_images (clientid,imagename,ext) values (' . $cid . ',"' . $bse . '","' . $ext . '")';
            $res = mysql_query($sql);
            $fid = mysql_insert_id();
        }
    }
    save_resize_image($newname, 600, 600, $ext, '_sm1', false);
    list($width, $height) = getimagesize($newname);
    if ($height > 114 || $width > 121) {
        createThumb($newname, $ext, '_sm4', 121, 114, $sql, $fid);
    } else {
        save_resize_image($newname, 114, 121, $ext, '_sm4', true);
    }
    return $err;
}
示例#29
0
 $make_image_public_checkbox = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<form class='input-group' style='display:inline-block;' >\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<select class='form-control make_image_public_input' >\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option>Public</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<option>Private</option>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span onclick='save_changes(" . $id . ")' id='save_changes_' class='btn btn-warning btn-xs input-group-addon' style='color:#fff;' >Save Changes?</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
 // Detect File Type
 if (strpos(strtolower($image), 'mp4') or strpos(strtolower($image), 'm4v') or strpos(strtolower($image), 'mov')) {
     $type = 'video';
 } elseif (strpos(strtolower($image), 'png') or strpos(strtolower($image), 'jpeg') or strpos(strtolower($image), 'jpg') or strpos(strtolower($image), 'gif')) {
     $type = 'image';
 } elseif (strpos(strtolower($image), 'mp3') or strpos(strtolower($image), 'wav')) {
     $type = 'audio';
 } else {
     $type = 'Undetected!';
 }
 switch ($type) {
     case 'image':
         //echo 'THISIMAGE '.$image;
         if ($image != '') {
             $tnl = createThumb($image);
             $media_embed = "<img id='bae_photo' src='" . $tnl . "' alt='" . $tnl . "'>";
         }
         //echo 'THIS '.$tnl;
         break;
     case 'video':
         if ($image != '') {
             $tnl = createThumbnail($image);
             $media_embed = "<video id='bae_photo' controls preload='metadata' src='" . $tnl . "' alt='" . $tnl . "'>";
         }
         break;
     case 'audio':
         if ($image != '') {
             //$tnl = createThumbnail($image);
             $media_embed = "<video id='bae_photo' controls preload='metadata' src='" . $image . "' alt='" . $image . "'>";
         }
示例#30
0
function showBoth()
{
    $image = "../images/myImage.png";
    $thumbnail = "../images/thumbnail.png";
    createThumb($image, $thumbnail, 90);
    print "\n<h3>Original image: </h3>\n" . "<img src='{$image}' alt='test picture' />";
    print "\n</h3> <br /> <br /> ";
    print "\n<h3>Thumbnail image: </h3> \n" . "<img src='{$thumbnail}' alt='thumbnail' />\n";
    print "<br /><br />";
    startOverLink();
}