Author Topic: Using ffmpeg to generate uploaded video thumbnails  (Read 115761 times)

0 Members and 1 Guest are viewing this topic.

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #45 on: March 22, 2007, 08:58:58 PM »
Hi son_goku

first, nacigate to the directory --> c:\Mplayer

then don't put two \\'s in your command

also, your timescale value is incorrect...

run this command:
Code: [Select]
mplayer c:\mplayer\amigo.avi -ss 00:00:03 -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt

does something get generated now?

Yes! Thumbail is generated

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #46 on: March 23, 2007, 02:57:27 PM »
I get this error when uploading a image.

Warning: unlink(imagegenoutput.txt) [function.unlink]: No such file or directory in /home/songokou/public_html/aceleras/includes/image_utils.php on line 191

Warning: rename(00000001.jpg,./data/thumbnails/6/amigo.avi.jpg) [function.rename]: No such file or directory in /home/songokou/public_html/aceleras/includes/image_utils.php on line 192


I did this:

Wow... this sounds crazy hard. I'm a little overwhelmed with all of the updates & corrections.

 Can we get a step by step for n00bs in one post?

OK guys... let's try again to put all code modifications in one place:

You should have mplayer.exe installed in "C:/mplayer/mplayer.exe" . You can download this application from here: http://www.mplayerhq.hu/design7/dload.html

Step 1.
In image_utils.php find and modify as follows:

Code: [Select]
function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
    return false;
  }
  $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
  $resize_handle = "resize_image_".$convert_options['convert_tool'];
  if ($resize_handle($src, $dest, $quality, $width_height['width'], $width_height['height'], $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
//****added from here****
  if (in_array(get_file_extension($new_name), array("mpg", "mpeg", "avi", "wmv")) && Generate_VideoThumb($src, $dest.".jpg")) {
    $new_thumb_name = $new_name.".jpg";
}
//****added to here****
  else {
    return false;
  }
}

//****added from here****
/**************************************************************************
 * WeZ - Get Vid Info Code                                                *
 *************************************************************************/
function movie_get_length_in_seconds($src)
{
$cmd = "C:\\mplayer\\mplayer.exe -identify -vo null -ao null -frames 1 \"".$src."\" 2>&1 | grep ID_LENGTH";
$output = exec($cmd);
list(,$length) = explode("=", $output);
$length = ceil($length/2);
return $length;
}


/**************************************************************************
 * WeZ - Get Thumb Code                                                *
 *************************************************************************/
function Generate_VideoThumb($src, $dest) {
  global $convert_options;
  $length = movie_get_length_in_seconds($src);
  $command = "C:\\mplayer\\mplayer.exe \"".$src."\" -ss ".$length." -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt";
  system($command);
  unlink("imagegenoutput.txt");
  rename("00000001.jpg",$dest);
  movie_get_length_in_seconds($src);
  return (file_exists($dest)) ? 1 : 0;
}
//****added to here****

Step2:
in member.php modify as follows:

Code: [Select]
// Upload thumb file
      $new_thumb_name = "";
      if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
        $new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
        if (!$new_thumb_name) {
          $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
          @unlink(MEDIA_TEMP_PATH."/".$new_name);
          $uploaderror = 1;
        }
      }
      elseif (check_remote_thumb($remote_thumb_file)) {
        $new_thumb_name = $remote_thumb_file;
      }
      elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {
        if ($direct_upload) {
          $src = MEDIA_PATH."/".$cat_id."/".$new_name;
          $dest = THUMB_PATH."/".$cat_id."/".$new_name;
        }
        else {
          $src = MEDIA_TEMP_PATH."/".$new_name;
          $dest = THUMB_TEMP_PATH."/".$new_name;
        }
        $do_create = 0;
        if ($image_info = @getimagesize($src)) {
          if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
            $do_create = 1;
          }
        }
        require_once(ROOT_PATH.'includes/image_utils.php');
        $convert_options = init_convert_options();
        if ($do_create) {
          if (!$convert_options['convert_error']) {
            $dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
            $resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
            $quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;

            if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
              $new_thumb_name = $new_name;
            }
            }
          }
        else {
  if (in_array(get_file_extension($new_name), array("mpg", "mpeg", "avi", "wmv")) && Generate_VideoThumb($src, $dest.".jpg")) {
  $new_thumb_name = $new_name.".jpg";
}

        }
    }

And the final advise: If you want to try it then BACKUP YOUR ORIGINALS so you can always roll back the changes.  Hope I helped some of you guys! Good luck!


Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #47 on: March 28, 2007, 12:37:54 AM »
I'm running on a linux server. Could be that? How I change the path C:\\mplayer\\mplayer.exe  into a linux path?

Offline abdoh2010

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Racing 4 Education
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #48 on: March 30, 2007, 08:30:49 AM »
hi WeZ
i'm willing to work with you side by side to get this thing build up completely.
all what i need from you is posting all your updated modified files right here so i can start helping you with it
i'm a programmer and i have good idea about solving programming problems

also i made some private MOD for 4images to my website

i need this as much as everyone else need it
but i'm willing to work for it instead of watching you do all the work
I don’t want anything except seeing this MOD working in my website

so what do say?

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #49 on: March 30, 2007, 02:12:40 PM »
Wez doesn't come here a long time. You can talk to me. I know everything step by step that was made here. What do you exactly want to know?

Offline abdoh2010

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Racing 4 Education
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #50 on: March 30, 2007, 03:17:47 PM »
i see a lot of crap codes here and there
and all of them are updated to other codes or adding new code to other files

i can track everything down but i want to save my self the headache by asking for all the modified files so i can debug them and put every thing in it right place

if you have them post them all and i will deal with them

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #51 on: March 30, 2007, 04:38:44 PM »
Oki, I will describe the exact point we are with ffmpeg.

Files to edit:

member.php
includes/image_utils.php

In member.php find:

Code: [Select]
    // Uplad thumb file
    $new_thumb_name = "";
    if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
      $new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
      if (!$new_thumb_name) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
        @unlink(MEDIA_TEMP_PATH."/".$new_name);
        $uploaderror = 1;
      }
    }
    elseif (check_remote_thumb($remote_thumb_file)) {
      $new_thumb_name = $remote_thumb_file;
    }
    elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {
      if ($direct_upload) {
        $src = MEDIA_PATH."/".$cat_id."/".$new_name;
        $dest = THUMB_PATH."/".$cat_id."/".$new_name;
      }
      else {
        $src = MEDIA_TEMP_PATH."/".$new_name;
        $dest = THUMB_TEMP_PATH."/".$new_name;
      }
      $do_create = 0;
      if ($image_info = @getimagesize($src)) {
        if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
          $do_create = 1;
        }
      }
      if ($do_create) {
        require_once(ROOT_PATH.'includes/image_utils.php');
        $convert_options = init_convert_options();
        if (!$convert_options['convert_error']) {
          $dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
          $resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
          $quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;

          if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
            $new_thumb_name = $new_name;
          }
        }
      }
    }

Change to:
Code: [Select]
    // Uplad thumb file
    $new_thumb_name = "";
    if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
      $new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
      if (!$new_thumb_name) {
        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
        @unlink(MEDIA_TEMP_PATH."/".$new_name);
        $uploaderror = 1;
      }
    }
    elseif (check_remote_thumb($remote_thumb_file)) {
      $new_thumb_name = $remote_thumb_file;
    }
    elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {
      if ($direct_upload) {
        $src = MEDIA_PATH."/".$cat_id."/".$new_name;
        $dest = THUMB_PATH."/".$cat_id."/".$new_name;
      }
      else {
        $src = MEDIA_TEMP_PATH."/".$new_name;
        $dest = THUMB_TEMP_PATH."/".$new_name;
      }
      $do_create = 0;
      if ($image_info = @getimagesize($src)) {
        if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
          $do_create = 1;
        }
      }
      require_once(ROOT_PATH.'includes/image_utils.php');
      $convert_options = init_convert_options();
      if ($do_create) {
        if (!$convert_options['convert_error']) {
          $dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
          $resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
          $quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;

          if (create_thumbnail($src, $dest, $quality, $dimension, $resize_type)) {
            $new_thumb_name = $new_name;
          }
          }
        }
      else {
if (in_array(get_file_extension($new_name), array("mpg", "mpeg", "avi")) && Generate_VideoThumb($src, $dest.".jpg")) {
  $new_thumb_name = $new_name.".jpg";
}
      }
  }

In image_utils.php find:

Code: [Select]
function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
    return false;
  }
  $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
  $resize_handle = "resize_image_".$convert_options['convert_tool'];
  if ($resize_handle($src, $dest, $quality, $width_height['width'], $width_height['height'], $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
  else {
    return false;
  }
}

Change to:
Code: [Select]
function create_thumbnail($src, $dest, $quality, $dimension, $resize_type) {
  global $convert_options;

  if (file_exists($dest)) {
    @unlink($dest);
  }
  $image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (!$image_info) {
  if (Generate_VideoThumb($src, $dest)) {
echo $src.$dest;
return true;
}
else {
echo $src.$dest;
    return false;
    }
  }
  echo $src.$dest;
  $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);
  $resize_handle = "resize_image_".$convert_options['convert_tool'];
  if ($resize_handle($src, $dest, $quality, $width_height['width'], $width_height['height'], $image_info)) {
    @chmod($dest, CHMOD_FILES);
    return true;
  }
  else {
    return false;
  }
}
function Generate_VideoThumb($src, $dest) {
  global $convert_options;

  $command = "C:\\ffmpeg\\ffmpeg.exe -i ".$src." -f mjpeg -t 0.001 ".$dest;
  system($command);
  return (file_exists($dest)) ? 1 : 0;
}

For what I know from video work ffmpeg is more complete than mplayer, so I'm trying to work with ffmpeg on this.
You saw a lot of crap codes... and  I saw particulary this
Code: [Select]
$command = "C:\\ffmpeg\\ffmpeg.exe -i ".$src." -f mjpeg -t 0.001 ".$dest; This is for windows server right? I think most of people uses linux server... it would be great to change and explain this.

I can help in topics I understand... but in this one... I'm completely lost.

Offline abdoh2010

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Racing 4 Education
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #52 on: March 30, 2007, 06:52:24 PM »
thats all what i need to know
it seem like there is alot of stuff missing, but it's ok
i think i know where to start at

when i' done i will share it here.

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #53 on: April 09, 2007, 11:49:32 PM »
Looks like there isn´t anyone that expert to do it :)

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #54 on: April 24, 2007, 10:43:24 PM »
Hi All,

Sorry for the long time without contact.

i have alot of projects running at the moment and 4Images which is only a hobby is taking a serious back seat.

I will try my best to log in over the next two or three days to help whoever needs help on this...

So, who is having what problem?  :lol:

Cheers

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #55 on: April 25, 2007, 12:04:33 AM »
Me :) would you like to work a few minutes on this with me?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #56 on: April 25, 2007, 11:01:46 AM »
Hi son_gokou,

Sure. what i can do, is give you my config files, although to be hones, i'm not sure which ones you need... i have added quite a few mods to my gallery so you might need to comment out some bits...

which files do you want?

Cheers

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #57 on: April 25, 2007, 04:53:22 PM »
It would be great the files that you edit for these MOD. image_utils.php and member.php

What OS does your host provider use?

Offline WeZ

  • Jr. Member
  • **
  • Posts: 72
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #58 on: April 25, 2007, 05:51:31 PM »
Hi son_gokou,

here are the files. Remember that i have many mods so you might need to only take some sections.

here is image_utils.php
Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: image_utils.php                                      *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.2                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die(
"Security violation");
}

function 
init_convert_options() {
  global 
$config$lang;

  
$convert_options = array(
    
"convert_error" => 0,
    
"convert_tool" => $config['convert_tool'],
    
"convert_path" => ereg_replace("\/$"""$config['convert_tool_path'])
  );
  switch(
$config['convert_tool']) {
  case 
"im":
    
$exec check_executable("convert");
        
$convert_options['convert_path'] = preg_replace("/\/?(".check_executable("mogrify")."|$exec)+$/i"''$convert_options['convert_path']);
    
$convert_options['convert_path'] = $convert_options['convert_path'] . '/' $exec;
        if (!@
is_executable($convert_options['convert_path'])) {
      
$convert_options['convert_error'] = "<b class=\"marktext\">".$lang['im_error']."</b><br />\n".$lang['check_module_settings'];
    }
    break;
  case 
"gd":
    
$convert_options['convert_gd2'] = false;

    if (
defined('CONVERT_IS_GD2')) {
      
$convert_options['convert_gd2'] = CONVERT_IS_GD2 == false true;
    } elseif (
function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled")) {
      
$convert_options['convert_gd2'] = true;
    }

    if (!
function_exists("imagetypes")) {
      
$convert_options['convert_error'] = (defined("IN_CP")) ? "<b class=\"marktext\">".$lang['gd_error']."</b><br />\n".$lang['check_module_settings'] : 1;
    }
    break;
  case 
"netpbm":
    if (!@
is_executable($convert_options['convert_path']."/".check_executable("pnmscale"))) {
      
$convert_options['convert_error'] = (defined("IN_CP")) ? "<b class=\"marktext\">".$lang['netpbm_error']."</b><br />\n".$lang['check_module_settings'] : 1;
    }
    break;
  default:
    
$convert_options['convert_error'] = (defined("IN_CP")) ? "<b class=\"marktext\">".$lang['no_convert_module']."</b><br />\n".$lang['check_module_settings'] : 1;
  }
  return 
$convert_options;
}

function 
resize_image_gd($src$dest$quality$width$height$image_info) {
  global 
$convert_options;

  
$types = array(=> "gif"=> "jpeg"=> "png");
  if (
$convert_options['convert_gd2']) {
    
$thumb imagecreatetruecolor($width$height);
  }
  else {
    
$thumb imagecreate($width$height);
  }
  
$image_create_handle "imagecreatefrom".$types[$image_info[2]];

  if (
$image $image_create_handle($src)) {
    if (
$convert_options['convert_gd2']) {
      
imagecopyresampled($thumb$image0000$width$heightImageSX($image), ImageSY($image));
    }
    else {
      
imagecopyresized($thumb$image0000$width$heightImageSX($image), ImageSY($image));
    }
    
$image_handle "image".$types[$image_info[2]];
    
$image_handle($thumb$dest$quality);
    
imagedestroy($image);
    
imagedestroy($thumb);
  }
  return (
file_exists($dest)) ? 0;
}

function 
resize_image_im($src$dest$quality$width$height$image_info) {
  global 
$convert_options;

  
$command $convert_options['convert_path']." -quality ".$quality." -antialias -sample $width"."x"."$height \"$src\" \"$dest\"";
  
system($command);
  return (
file_exists($dest)) ? 0;
}

function 
resize_image_netpbm($src$dest$quality$width$height$image_info) {
  global 
$convert_options;

  
$convert_path $convert_options['convert_path'];
  
$types = array(=> "gif"=> "jpeg"=> "png");
  
$target = ($width $height) ? $width $height;
  
$command $convert_path."/".check_executable($types[$image_info[2]]."topnm")." ".$src." | ".$convert_path."/".check_executable("pnmscale")." --quiet -xysize ".$target." ".$target." | ";
  if (
$image_info[2] == 1) {
    
$command .= $convert_path."/".check_executable("ppmquant")." 256 | " $convert_path."/".check_executable("ppmtogif")." > ".$dest;
  }
  elseif (
$image_info[2] == 3) {
    
$command .= $convert_path."/".check_executable("pnmtopng")." > ".$dest;
  }
  else {
    
$jpeg_exec = (file_exists($convert_path."/".check_executable("pnmtojpeg"))) ? check_executable("pnmtojpeg") : check_executable("ppmtojpeg");
    
$command .= $convert_path."/".$jpeg_exec." --quality=".$quality." > ".$dest;
  }
  
system($command);
  return (
file_exists($dest)) ? 0;
}

function 
get_width_height($dimension$width$height$resize_type 1) {
  if (
$resize_type == 2) {
    
$new_width $dimension;
    
$new_height floor(($dimension/$width) * $height);
  }
  elseif (
$resize_type == 3) {
    
$new_width floor(($dimension/$height) * $width);
    
$new_height $dimension;
  }
  else {
    
$ratio $width $height;
    if (
$ratio 1) {
      
$new_width $dimension;
      
$new_height floor(($dimension/$width) * $height);
    }
    else {
      
$new_width floor(($dimension/$height) * $width);
      
$new_height $dimension;
    }
  }
  return array(
"width" => $new_width"height" => $new_height);
}

function 
create_thumbnail($src$dest$quality$dimension$resize_type) {
  global 
$convert_options;
  if (
file_exists($dest)) {
    @
unlink($dest);
  }
  
$image_info = (defined("IN_CP")) ? getimagesize($src) : @getimagesize($src);
  if (
in_array(get_file_extension($src), array("asf""wma""wmv""mpg""mpeg""avi""mov""asx""mp4""flv"))) {
  
Generate_VideoThumb($src$dest.".jpg");
      
@chmod($destCHMOD_FILES);
      
$image_handle $dest.".jpg";
      
$new_thumb_name $dest.".jpg";
      
return true;
  
}
  if (!
$image_info) {
    
return false;
  }
  
$width_height get_width_height($dimension$image_info[0], $image_info[1], $resize_type);
   
$resize_handle "resize_image_".(($image_info[2] == 1) ? "im" $convert_options['convert_tool']);
  if (
$resize_handle($src$dest$quality$width_height['width'], $width_height['height'], $image_info)) {
    @
chmod($destCHMOD_FILES);
    return 
true;
  }
  else {
    return 
false;
  }
}


function 
resize_image($file$quality$dimension$resize_type 1) {
  global 
$convert_options;
  
$image_info = (defined("IN_CP")) ? getimagesize($file) : @getimagesize($file);
  if (!
$image_info) {
    return 
false;
  }
  
$file_bak $file.".bak";
  if (!
rename($file$file_bak)) {
    return 
false;
  }
  
$width_height get_width_height($dimension$image_info[0], $image_info[1], $resize_type);
   
$resize_handle "resize_image_".(($image_info[2] == 1) ? "im" $convert_options['convert_tool']);
  if (
$resize_handle($file_bak$file$quality$width_height['width'], $width_height['height'], $image_info)) {
    @
chmod($fileCHMOD_FILES);
    @
unlink($file_bak);
    return 
true;
  }
  else {
    
rename($file_bak$file);
    return 
false;
  }
}


/**************************************************************************
 * WeZ - Get Vid Info Code                                                *
 *************************************************************************/
function movie_get_length_in_seconds($src)
{
$cmd "C:\\mplayer\\mplayer.exe -identify -vo null -ao null -frames 1 \"".$src."\" 2>&1 | grep ID_LENGTH";
$output exec($cmd);
list(,
$length) = explode("="$output);
$length ceil($length/3);
return 
$length;
}


/**************************************************************************
 * WeZ - Get Thumb Code                                                *
 *************************************************************************/
function Generate_VideoThumb($src$dest) {
  global 
$convert_options;
  
$length movie_get_length_in_seconds($src);
  
$command "C:\\mplayer\\mplayer.exe \"".$src."\" -ss ".$length." -nosound -vo jpeg:smooth=75 -vop scale=100:70 -frames 2 > imagegenoutput.txt";
  
system($command);
  
unlink("imagegenoutput.txt");
  
unlink("00000001.jpg");
  
rename("00000002.jpg",$dest);
  return (
file_exists($dest)) ? 0;
}





?>


here is member.php
[code]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: member.php                                           *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.2                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$main_template = "member";

define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');

if ($action == "") {
  $action = "lostpassword";
}
$content = "";
$txt_clickstream = "";

$sendprocess = 0;

if (isset($HTTP_GET_VARS[URL_COMMENT_ID]) || isset($HTTP_POST_VARS[URL_COMMENT_ID])) {
  $comment_id = (isset($HTTP_GET_VARS[URL_COMMENT_ID])) ? intval($HTTP_GET_VARS[URL_COMMENT_ID]) : intval($HTTP_POST_VARS[URL_COMMENT_ID]);
}
else {
  $comment_id = 0;
}

if ($action == "deletecomment") {
  if (!$comment_id || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $sql = "SELECT c.comment_id, c.user_id AS comment_user_id, i.image_id, i.cat_id, i.user_id, i.image_name
          FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".format_text($comment_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_delete'];

  $sql = "UPDATE ".IMAGES_TABLE."
          SET image_comments = image_comments - 1
          WHERE image_id = ".$comment_row['image_id'];
  $site_db->query($sql);

  if ($comment_row['comment_user_id'] != GUEST) {
    $sql = "UPDATE ".USERS_TABLE."
            SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
            WHERE ".get_user_table_field("", "user_id")." = ".$comment_row['comment_user_id'];
    $site_db->query($sql);
  }

  $sql = "DELETE FROM ".COMMENTS_TABLE."
          WHERE comment_id = $comment_id";
  $result = $site_db->query($sql);
  $msg = ($result) ? $lang['comment_delete_success'] : $lang['comment_delete_error'];
}

if ($action == "removecomment") {
  if (!$comment_id || ($config['user_delete_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    redirect($url);
  }

  $sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
          FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    redirect($url);
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".format_text($comment_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_delete'];

  if (isset($comment_row[$user_table_fields['user_name']]) && $comment_row['comment_user_id'] != GUEST) {
    $user_name = $comment_row[$user_table_fields['user_name']];
  }
  else {
    $user_name = $comment_row['comment_user_name'];
  }

  $site_template->register_vars(array(
    "comment_id" => $comment_id,
    "image_name" => format_text($comment_row['image_name']),
    "user_name" => format_text($user_name),
    "comment_headline" => format_text($comment_row['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
    "comment_text" => format_text($comment_row['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
    "lang_delete_comment" => $lang['comment_delete'],
    "lang_delete_comment_confirm" => $lang['comment_delete_confirm'],
    "lang_image_name" => $lang['image_name'],
    "lang_name" => $lang['name'],
    "lang_headline" => $lang['headline'],
    "lang_comment" => $lang['comment'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));
  $content = $site_template->parse_template("member_deletecomment");
}

if ($action == "updatecomment") {
  if (!$comment_id || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }
  $sql = "SELECT c.comment_id, c.image_id, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
          FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".format_text($comment_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_edit'];

  $error = 0;

  $comment_headline = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
  $comment_text = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));

  if ($comment_headline == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['headline']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
  if ($comment_text == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['comment']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

  if (!$error) {
    $sql = "UPDATE ".COMMENTS_TABLE."
            SET comment_headline = '$comment_headline', comment_text = '$comment_text'
            WHERE comment_id = $comment_id";
    $result = $site_db->query($sql);
    $msg = ($result) ? $lang['comment_edit_success'] : $lang['comment_edit_error'];
  }
  else {
    $action = "editcomment";
    $sendprocess = 1;
  }
}

if ($action == "editcomment") {
  if (!$comment_id || ($config['user_edit_comments'] != 1 && $user_info['user_level'] != ADMIN)) {
    redirect($url);
  }

  $sql = "SELECT c.comment_id, c.image_id, c.user_id AS comment_user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, i.image_name, i.cat_id, i.user_id".get_user_table_field(", u.", "user_name")."
          FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
          WHERE c.comment_id = $comment_id AND i.image_id = c.image_id";
  $comment_row = $site_db->query_firstrow($sql);
  if (!$comment_row || $comment_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $comment_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }

  $txt_clickstream = get_category_path($comment_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$comment_row['image_id'])."\" class=\"clickstream\">".format_text($comment_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['comment_edit'];

  $comment_headline = (isset($HTTP_POST_VARS['comment_headline'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['comment_headline']))) : $comment_row['comment_headline'];
  $comment_text = (isset($HTTP_POST_VARS['comment_text'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['comment_text']))) : $comment_row['comment_text'];

  if (isset($comment_row[$user_table_fields['user_name']]) && $comment_row['comment_user_id'] != GUEST) {
    $user_name = $comment_row[$user_table_fields['user_name']];
  }
  else {
    $user_name = $comment_row['comment_user_name'];
  }

  $bbcode = "";
  if ($config['bb_comments'] == 1) {
    $site_template->register_vars(array(
      "lang_bbcode" => $lang['bbcode'],
      "lang_tag_prompt" => $lang['tag_prompt'],
      "lang_link_text_prompt" => $lang['link_text_prompt'],
      "lang_link_url_prompt" => $lang['link_url_prompt'],
      "lang_link_email_prompt" => $lang['link_email_prompt'],
      "lang_list_type_prompt" => $lang['list_type_prompt'],
      "lang_list_item_prompt" => $lang['list_item_prompt']
    ));
    $bbcode = $site_template->parse_template("bbcode");
  }

  $site_template->register_vars(array(
    "bbcode" => $bbcode,
    "comment_id" => $comment_id,
    "image_name" => format_text($comment_row['image_name']),
    "user_name" => format_text($user_name),
    "comment_headline" => format_text($comment_headline, 2),
    "comment_text" => format_text($comment_text, 2),
    "lang_edit_comment" => $lang['comment_edit'],
    "lang_image_name" => $lang['image_name'],
    "lang_name" => $lang['name'],
    "lang_headline" => $lang['headline'],
    "lang_comment" => $lang['comment'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));
  $content = $site_template->parse_template("member_editcomment");
}

if ($action == "deleteimage") {
  if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = $lang['image_delete'];

  $sql = "DELETE FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $del_img = $site_db->query($sql);

  if (!is_remote($image_row['image_media_file']) && !is_local_file($image_row['image_media_file'])) {
    @unlink(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file']);
  }
  if (!empty($image_row['image_thumb_file']) && !is_remote($image_row['image_thumb_file']) && !is_local_file($image_row['image_thumb_file'])) {
    @unlink(THUMB_PATH."/".$image_row['cat_id']."/".$image_row['image_thumb_file']);
  }

  include(ROOT_PATH.'includes/search_utils.php');
  remove_searchwords($image_id);

  if (!empty($user_table_fields['user_comments'])) {
    $sql = "SELECT user_id
            FROM ".COMMENTS_TABLE."
            WHERE image_id = $image_id";
    $result = $site_db->query($sql);
    $user_id_sql = "";
    while ($row = $site_db->fetch_array($result)) {
      if ($row['user_id'] != GUEST) {
        $sql = "UPDATE ".USERS_TABLE."
                SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
                WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
        $site_db->query($sql);
      }
    }
  }

  $sql = "DELETE FROM ".COMMENTS_TABLE."
          WHERE image_id = $image_id";
  $del_com = $site_db->query($sql);

  if ($del_img) {
    $msg = $lang['image_delete_success'];
  }
  else {
    $msg = $lang['image_delete_error'];
  }
}

if ($action == "removeimage") {
  if (!$image_id || ($config['user_delete_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    redirect($url);
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".format_text($image_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_delete'];

  $site_template->register_vars(array(
    "image_id" => $image_id,
    "image_name" => format_text($image_row['image_name']),
    "lang_delete_image" => $lang['image_delete'],
    "lang_delete_image_confirm" => $lang['image_delete_confirm'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));
  $content = $site_template->parse_template("member_deleteimage");
}

if ($action == "updateimage") {
  if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".format_text($image_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_edit'];

  $error = 0;

  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
  $image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
  $image_keywords = str_replace(","," ",$image_keywords);
  $image_keywords = ereg_replace("( ){2,}", " ", $image_keywords);

  if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

  if (!empty($additional_image_fields)) {
    foreach ($additional_image_fields as $key => $val) {
      if (isset($HTTP_POST_VARS[$key]) && intval($val[2]) == 1 && trim($HTTP_POST_VARS[$key]) == "") {
        $error = 1;
        $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
        $msg .= (($msg != "") ? "<br />" : "").$field_error;
      }
    }
  }

  if (!$error) {
    $additional_sql = "";

    if (isset($HTTP_POST_VARS['image_allow_comments'])) {
      $additional_sql .= ", image_allow_comments = ".intval($HTTP_POST_VARS['image_allow_comments']);
    }

    if (!empty($additional_image_fields)) {
      $table_fields = $site_db->get_table_fields(IMAGES_TABLE);
      foreach ($additional_image_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }

    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords'".$additional_sql."
            WHERE image_id = $image_id";
    $result = $site_db->query($sql);
    if ($result) {
      include(ROOT_PATH.'includes/search_utils.php');
      $search_words = array();
      foreach ($search_match_fields as $image_column => $match_column) {
        if (isset($HTTP_POST_VARS[$image_column])) {
          $search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column]);
        }
      }
      remove_searchwords($image_id);
      add_searchwords($image_id, $search_words);
      $msg = $lang['image_edit_success'];
    }
    else {
      $msg = $lang['image_edit_error'];
    }
  }
  else {
    $action = "editimage";
    $sendprocess = 1;
  }
}

if ($action == "editimage") {
  if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    redirect($url);
  }

  $additional_sql = "";
  if (!empty($additional_image_fields)) {
    foreach ($additional_image_fields as $key => $val) {
      $additional_sql .= ", ".$key;
    }
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_description, image_keywords, image_allow_comments".$additional_sql."
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    redirect($url);
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".format_text($image_row['image_name'])."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_edit'];

  $image_name = (isset($HTTP_POST_VARS['image_name'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_name']))) : $image_row['image_name'];
  $image_description = (isset($HTTP_POST_VARS['image_description'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_description']))) : $image_row['image_description'];
  $image_keywords = (isset($HTTP_POST_VARS['image_keywords'])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_keywords']))) : $image_row['image_keywords'];
  $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments'])) ? intval($HTTP_POST_VARS['image_allow_comments']) : $image_row['image_allow_comments'];

  $site_template->register_vars(array(
    "image_id" => $image_id,
    "image_name" => format_text($image_name, 2),
    "image_description" => format_text($image_description, 2),
    "image_keywords" => format_text($image_keywords, 2),
    "image_allow_comments_yes" => ($image_allow_comments) ? " checked=\"checked\"" : "",
    "image_allow_comments_no" => (!$image_allow_comments) ? " checked=\"checked\"" : "",
    "lang_edit_image" => $lang['image_edit'],
    "lang_image_name" => $lang['image_name'],
    "lang_description" => $lang['description'],
    "lang_keywords" => $lang['keywords_ext'],
    "lang_allow_comments" => isset($lang['allow_comments']) ? $lang['allow_comments'] : "",
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset'],
    "lang_yes" => $lang['yes'],
    "lang_no" => $lang['no']
  ));

  if (!empty($additional_image_fields)) {
    $additional_field_array = array();
    foreach ($additional_image_fields as $key => $val) {
      if ($val[1] == "radio") {
        $value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : $image_row[$key];
        if ($value == 1) {
          $additional_field_array[$key.'_yes'] = " checked=\"checked\"";
          $additional_field_array[$key.'_no'] = "";
        }
        else {
          $additional_field_array[$key.'_yes'] = "";
          $additional_field_array[$key.'_no'] = " checked=\"checked\"";
        }
      }
      else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
      }
      $additional_field_array[$key] = $value;
      $additional_field_array['lang_'.$key] = $val[0];
    }
    if (!empty($additional_field_array)) {
      $site_template->register_vars($additional_field_array);
    }
  }
  $content = $site_template->parse_template("member_editimage");
}

if ($action == "uploadimage" || $action=="multiuploadimage") {
  if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = "";
  if ($cat_id && isset($cat_cache[$cat_id])) {
    $txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  }
  $txt_clickstream .= $lang['user_upload'];

  $remote_media_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_media_file'])));
  $remote_thumb_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_thumb_file'])));

  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
  $image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
  $image_keywords = str_replace(","," ",$image_keywords);
  $image_keywords = ereg_replace("( ){2,}", " ", $image_keywords);

  $image_active = (isset($HTTP_POST_VARS['image_active']) && $HTTP_POST_VARS['image_active'] == 0) ? 0 : 1;
  $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments']) && $HTTP_POST_VARS['image_allow_comments'] == 0) ? 0 : 1;
  $image_download_url = (isset($HTTP_POST_VARS['image_download_url'])) ? format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['image_download_url']))) : "";

  $direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
  $upload_cat = ($direct_upload) ? $cat_id : 0;

  $error = 0;
  $uploaderror = 0;

  if ($cat_id == 0)  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
  if ((empty($HTTP_POST_FILES['media_file']['tmp_name']) || $HTTP_POST_FILES['media_file']['tmp_name'] == "none") && ($remote_media_file == "" || !check_remote_media($remote_media_file))) {
    $error = 1;
    $msg .= (($msg != "") ? "<br />" : "").$lang['image_file_required'];
  }
  if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

  if (!empty($additional_image_fields)) {
    foreach ($additional_image_fields as $key => $val) {
      if (isset($HTTP_POST_VARS[$key]) && intval($val[2]) == 1 && trim($HTTP_POST_VARS[$key]) == "") {
        $error = 1;
        $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
        $msg .= (($msg != "") ? "<br />" : "").$field_error;
      }
    }
  }

      /*
        MOD CHECK FOR DUPLICATE IMAGES
        START INSERT
      */
      ##########
      # CONFIG #
      ##########

        $check_admin = true; //do check when administrator is uploading? (true/false)
        $show_image = true; //show link to the image that was previously uploaded? (true/false)
        $show_member = true; //show name and link to profile page of the member who previously uploaded that file? (true/false)

      ##############
      # END CONFIG #
      ##############

        $md5 = "";
        unset($HTTP_POST_VARS['image_md5']);
        if ($user_info['user_level'] != ADMIN || $check_admin)
        {
         if (!empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none")
         {
           $md5 = md5_file($HTTP_POST_FILES['media_file']['tmp_name']);
           $file = $HTTP_POST_FILES['media_file']['filename'];
         }
         elseif ($remote_media_file)
         {
           $md5 = md5($remote_media_file);
           $file = $remote_media_file;
         }
         if ($md5)
         {
           $sql = "SELECT image_id, image_name, cat_id, user_id
                 FROM ".IMAGES_TABLE."
                 WHERE image_md5 = '".$md5."'
                 LIMIT 1";
           if ($row = $site_db->query_firstrow($sql))
           {

            $row['image_name'] = stripslashes($row['image_name']);
            if (function_exists('multilang')) $row['image_name'] = multilang($row['image_name']);
            $user_row = get_user_info($row['user_id']);
      //        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$file."</b><br />";
            $msg .= (($msg != "") ? "<br />" : "").(($user_info['user_level'] > GUEST && $user_info['user_id'] == $user_row['user_id']) ? $lang['image_md5_duplicate_self'] : sprintf(($show_member ? $lang['image_md5_duplicate_more'] : $lang['image_md5_duplicate_simple']), "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$user_row['user_id'])."\">".$user_row['user_name']."</a>"));
            if ($show_image && (($user_info['user_level'] > GUEST && $user_info['user_id'] != $user_row['user_id']) || (check_permission("auth_viewcat", $row['cat_id'] && check_permission("auth_viewimage", $row['cat_id'])))))
            {
              $msg .= ": <a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$row['image_id'])."\">".$row['image_name']."</a>";
            }
            $error = 1;
           }
           else
           {
            $sql = "SELECT image_id, image_name, user_id
                  FROM ".IMAGES_TEMP_TABLE."
                  WHERE image_md5 = '".$md5."'
                  LIMIT 1";
            if ($row = $site_db->query_firstrow($sql))
            {
              $user_row = get_user_info($row['user_id']);
      //          $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$file."</b><br />";
              $msg .= (($msg != "") ? "<br />" : "").(($user_info['user_level'] > GUEST && $user_info['user_id'] == $row['user_id']) ? $lang['image_md5_duplicate_validation_self'] : sprintf(($show_member ? $lang['image_md5_duplicate_validation_more'] : $lang['image_md5_duplicate_validation_simple']), "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$user_row['user_id'])."\">".$user_row['user_name']."</a>"));
              $error = 1;
            }
           }
           $HTTP_POST_VARS['image_md5'] = $md5;
         }
        }
      /*
        MOD CHECK FOR DUPLICATE IMAGES
        END INSERT
      */

      if (!$error) {
      //MULTI FILE UPLOAD
      $fileext="";
      while(isset($HTTP_POST_FILES['media_file'.$fileext]))
      {
      include_once(ROOT_PATH.'includes/upload.php');
         $site_upload = new Upload();

         // Upload Media file
         if (!empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none") {
           $new_name = $site_upload->upload_file('media_file'.$fileext, "media", $upload_cat);
           if (!$new_name) {
            $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$new_name."</b><br />".$site_upload->get_upload_errors();
            $uploaderror = 1;
           }
         }
         elseif($action=="uploadimage") {
           $new_name = $remote_media_file;
         }
         else
         {
         $new_name = "";
         break;
         }

      // Upload thumb file
      $new_thumb_name = "";
      if (!empty($HTTP_POST_FILES['thumb_file']['tmp_name']) && $HTTP_POST_FILES['thumb_file']['tmp_name'] != "none" && !$uploaderror) {
        $new_thumb_name = $site_upload->upload_file("thumb_file", "thumb", $upload_cat, basename($new_name));
        if (!$new_thumb_name) {
          $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$new_thumb_name."</b><br />".$site_upload->get_upload_errors();
          @unlink(MEDIA_TEMP_PATH."/".$new_name);
          $uploaderror = 1;
        }
      }
      elseif (check_remote_thumb($remote_thumb_file)) {
        $new_thumb_name = $remote_thumb_file;
      }
      elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file'.$fileext]['tmp_name']) && $HTTP_POST_FILES['media_file'.$fileext]['tmp_name'] != "none" && !$uploaderror) {
        if ($direct_upload) {
          $src = MEDIA_PATH."/".$cat_id."/".$new_name;
          $dest = THUMB_PATH."/".$cat_id."/".$new_name;
        }
        else {
          $src = MEDIA_TEMP_PATH."/".$new_name;
          $dest = THUMB_TEMP_PATH."/".$new_name;
        }
        $do_create = 0;
        if ($image_info = @getimagesize($src)) {
          if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
            $do_create = 1;
          }
        }
        require_once(ROOT_PATH.'includes/image_utils.php');
        $convert_options = init_convert_options();
        if ($do_create) {
          if (!$convert_options['convert_error']) {
            $dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
            $resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
            $quality = (intval($config['auto_thumbnail_quality']) && i

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: Using ffmpeg to generate uploaded video thumbnails
« Reply #59 on: April 25, 2007, 08:11:12 PM »
Is member.php finished?

What about the OS of your host provider?

Thanks