4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: WeZ on March 24, 2006, 10:39:55 AM
-
Hello All !!
Let me start my first post with a Congratulations on a fantastic system... I Have performed various mods and on the most part they were quite easy to configure.
There is one item missing for me which is the generation of thumbnails from video files. Searching through the forum has lead to a couple posts about this topic, but none that actually suggest the use of ffmpeg as the tool to save the day :lol:
I've tried to investigate the ImageMagick and GD2 solutions but both of them appear to not really support video too well.
From analyzing ffmpeg and testing it from the command line - it appears to generate a thumbnail from quite a range of different video sources.
Here is where i need help. i have the command required to generate the thumbnail - BUT i don't know where to put it. :roll:
The command i use is
ffmpeg -i 1.mpg -f singlejpeg -t 0.001 1.jpg
The only variables that would need to pass to it are the exe location, source video file & destination thumbnail name
I think the best implementation of it would be the same way that ImageMagick is handled in the system:
1. Control panel asks for the location of the .exe
2. extensions are associated to it
3. the command gets executed the same time as normal images are handled.
Considdering the great demand for video these days, i think it should be considdered as a standard feature of 4Images (Just like Imagemagick).
I Am using 4I 1.7.2 (with a couple cool mods 8) )
Can anybody do this?
Cheers,
WeZ
-
Hi All,
I think to acheive this i need to modify the admin/checkimages.php file?
Has anybody got a clue on where i can even start?
Thanks
-
Hi All,
Please can someone help me...
I placed the ffmpeg binary into the system32 dir and also the 4images root.
I created this code
function Generate_VideoThumb($src, $dest) {
global $convert_options;
$command = "ffmpeg -i ".$src." -f singlejpeg -t 0.001 ".$dest;
system($command);
return (file_exists($dest)) ? 1 : 0;
}
and placed it into image_utils.php
i also changed
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;
}
}
to
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)) {
return true;
}
else {
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;
}
}
Please can someone tell me why it is not working??
-
try to replace this:
if ($Generate_VideoThumb($src, $dest)) {
with this
if (Generate_VideoThumb($src, $dest)) {
in your image_utils.php
-
and unless ffmpeg is registered in the system, you will need add full path to it. i.e. C:\\WINDOWS\\SYSTEM32\\ffmpeg.exe
-
Hello IcEcReaM and V@no !!
From all the posts i've read on this forum, my help could'nt have come in a better form than you 2...
From both of your valuable Input I have changed the blocks of code to read:
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)) {
return true;
}
else {
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;
}
}
and
function Generate_VideoThumb($src, $dest) {
global $convert_options;
$command = "C:\\WINDOWS\\SYSTEM32\\ffmpeg.exe -i ".$src." -f singlejpeg -t 0.001 ".$dest;
system($command);
return (file_exists($dest)) ? 1 : 0;
}
I Have a feeling that there is someplace else that needs a little code because right now, I'm not even sure if it is being executed as i'm not getting any errors or anything...
hang on... Let me check the logs...
ok, I've attached a text file of what was found in my server logs...
There is no Line 223 in my image_utils.php and i have attached my admin_functions for your perusal...
How can i debug this Function? :roll:
Once again, thanks for your help...
WeZ
-
debug is easy:
instead of system($command); use: echo $command;
then if it print something on the screen copy it and then paste it in the command prompt (you might need replace \\ with only single back slash)
and see if it create the screenshot.
If it didnt print anything, then you know the function wasnt executed.
as of errors, you must have added a space/newline, whatever before <?php or after ?> in image_utils.php
-
Hi V@no,
thanks for the speedy reply...
debug is easy:
instead of system($command); use: echo $command;
then if it print something on the screen copy it and then paste it in the command prompt (you might need replace \\ with only single back slash)
and see if it create the screenshot.
If it didnt print anything, then you know the function wasnt executed.
Correct, it did not print anything...
as of errors, you must have added a space/newline, whatever before <?php or after ?> in image_utils.php
This this i did by mistake yesterday - I used the section after the "?>" as a scratchpad to write my code before inserting it into the function... this was rectified yesterday already so i guess these errors are old...
not sure if i'm happy or sad to not get any errors... :|
Anyway... i did some more testing and found that if i put echo code into the if (!$image_info) query:
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;
}
}
$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;
}
}
it still did not output anything... so i put an echo outside the query as well like this:
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;
}
}
and my results were that i did not get an output for video files but on an uploaded image i got this echoed output:
./data/media/1/alpha9.jpg./data/thumbnails/1/alpha9.jpg
so i would say that when uploading a video it is not even calling the "create_thumbnail" function at all?
Anyplace else i should be editing code?
Kind Regards,
Wesley.
-
Hello All,
Bit of a breakthrough, but not there yet...
If i changed this code on member.php
from
// 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;
}
}
}
}
if (!$uploaderror) {
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
to
// 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 (Generate_VideoThumb($src, $dest)) {
return true;
}
else {
return false;
}
}
}
if (!$uploaderror) {
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
And It WORKS!! however as you can see from my server logs (and checking on the disk verifies this):
frame= 1 q=1.6 Lsize= 2kB time=0.0 bitrate= 426.6kbits/s
Stream #0.0 -> #0.0
Stream mapping:
Stream #0.0: Video: mjpeg, 352x288, 25.00 fps, q=2-31, 200 kb/s
Output #0, singlejpeg, to './data/thumbnails/4/gymnastics_3.mpg':
Stream #0.1: Audio: mp2, 44100 Hz, stereo, 128 kb/s
Stream #0.0: Video: mpeg1video, 352x288, 25.00 fps
Duration: 00:00:23.4, bitrate: 674 kb/s
Input #0, mpeg, from './data/media/4/gymnastics_3.mpg':
The problem as you can see is that the "$dest" variable i am passing the command has an extension of the file i.e. in this case $dest = "/data/thumbnails/4/gymnastics_3.mpg" and hence ffmpeg created a thumbnail with an mpg extension.
I think the best option would be in my code below:
function Generate_VideoThumb($src, $dest) {
global $convert_options;
$command = "C:\\WINDOWS\\SYSTEM32\\ffmpeg.exe -i ".$src." -f singlejpeg -t 0.001 ".$dest;
system($command);
return (file_exists($dest)) ? 1 : 0;
}
to insert a line of code that replaces the last 3 chars of $dest with "jpg"
Somebody able to help me with this?
-
ok, first of all, there is no return in member.php
second, try replace if (Generate_VideoThumb($src, $dest)) {
return true;
}
else {
return false;
}
with: if (in_array(get_file_extension($new_name), array("mpg", "mpeg", "avi")) && Generate_VideoThumb($src, $dest.".jpg")) {
$new_thumb_name = $new_name.".jpg";
}
-
Hi V@no,
ok, first of all, there is no return in member.php
What do you mean?
-
I ment, you have return true; / return false; in member.php. where were you trying to return? its not a function ;) and theoreticaly it should be equal to exit or die()...(I might be wrong about the last ;))
-
Hey V@no,
Just an update - thanks to your code you gave me (without the return :wink:) ... things have been moving smoothly...
i got it all to work quite nicely, however ffmpeg seems to be really short on codecs. what makes it more difficult is that it does not use the built in codec staore that windows media player would use...
it has to be built with all codecs availalbe etc etc etc... what a mission...
i have changed to use mplayer and that seems to work quite nicely... so far it has converted every video i have thrown at it...
it's a bit of a hack, but here is the code:
function Generate_VideoThumb($src, $dest) {
global $convert_options;
$command = "C:\\mplayer\\mplayer.exe ".$src." -ss 00:00:05 -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt";
system($command);
unlink("00000001.jpg");
unlink("imagegenoutput.txt");
rename("00000002.jpg",$dest);
return (file_exists($dest)) ? 1 : 0;
}
the reason i output to imagegenoutput.txt is coz the bloody program echo's the result regardless of how i try and beat it to submission...
i also can't get it to only generate 1 thumbnail - hence the unlink on 00000001.jpg
also you can't specify the file name (it creates it for you) - hence why i do this rename buggerup...
as i said, it's a bit of a hack, but at least my video's are coming in nicely :D :D :D
my upload and multiupload is working fine, I am currently tackling the batch import mod to cater for video (i might be out my depth here :? )
Anyway, just my .02 worth...
Cheers
WeZ
-
Hi All,
Just a quick one from a newbie...
with my command below, how to i place a " around the $src ?
$command = "C:\\mplayer\\mplayer.exe ".$src." -ss 00:00:05 -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt";
The code above works for any file without any spaces, but how to i put a " in the command string without it terminating the string?
hope you get what im on about?
Cheers
-
just escape them with a backslash:[qcode]$command = "C:\\mplayer\\mplayer.exe \"".$src."\" -ss 00:00:05 -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt";[/qcode]
-
V@no, Everything is working great now, that was my only glitch...
thanks for all your invaluable help...
Kind Regards,
WeZ
-
How well does this work? Can I test your 4images gallery?
thanks
-
Got this mod working with 4images 1.7.1-inter/with phpnuke 7.4 WORKS GREAT!! :wink:
-
how can i use this on a linux server?
-
The same way, just change the path to ffmpeg executible
-
So how do we use ffmpeg to generate an uploaded vid thumbnail.
What folder/files & code and so on?
-
Hello everyone!
I have been following the discussion regarding this issue and trying to modify the code myself.
Here is my result:
I am running of Gallery 1.7 (under runcms 1.5) on WinXP on the intranet.
first of all I had to increase the script timeout in php.ini to more than 30 seconds and memory allocation to more than 8 MB because I had timeout errors when adding 30 and more large images through the control panel (maybe this is irrelevant to the rest of the message, but paybe it will be helpful for some people)
I have modified the image_utils.php in an effort to make the system create the thumbnail from my videos (mostly avi, and wmv - have not tried it with mov yet):
image_utils.php
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****
function Generate_VideoThumb($src, $dest) {
global $convert_options;
$command = "C:\\mplayer\\mplayer.exe \"".$src."\" -ss 00:00:05 -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt";
system($command);
//unlink("00000001.jpg");
unlink("imagegenoutput.txt");
rename("00000001.jpg",$dest);
return (file_exists($dest)) ? 1 : 0;
}
//****added to here****
and this is in my member.php
// 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 when I add a video from the "upload" button everything works just fine!!!
Autothumbnailer MOD 2.2.1 works great with pictures also.
Now here is the problem/request Autothumbnailer MOD 2.2.1 does not see that in 4images_images table the field image_thumb_file field is emply for everything that is not a picture (jpg). (all other autothumbnailers did not see other file types also)
How do I make the MOD see that there is no thumbnail for videos?
-
Hi VAno & the rest who do such a good job...
just FYI - in the last scipt i posted you''ll see i hard coded the number of seconds the thumbnail was generated from... i set this value to 5 seconds and pretty soon realised how many funny little clips i have that just that fall under that number - this caused the thumbnail generation to fail... putting the value shorter to like 2 or 3, left most of the vids still starting and the screenshot was black...
anyway, long story short, this new code will find the length of the file and stream to the middle... you can change the value in the ceil command to suit your needs...
/**************************************************************************
* 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;
}
remember , i'm not a programmer so dont blast my code!! :-)
hope some1 finds useful...
Ciao
WeZ
-
And when I add a video from the "upload" button everything works just fine!!!
Autothumbnailer MOD 2.2.1 works great with pictures also.
Now here is the problem/request Autothumbnailer MOD 2.2.1 does not see that in 4images_images table the field image_thumb_file field is emply for everything that is not a picture (jpg). (all other autothumbnailers did not see other file types also)
How do I make the MOD see that there is no thumbnail for videos?
let me paraphrase my question:
How do I make this code work from thumbnailer.php (version 2.2.1) in CP? This function does not see that mov,wmv,avi files have no thumbs in Database.... Please help. I have a ton of videos with no preview that I want to add thumbs to...
-
And when I add a video from the "upload" button everything works just fine!!!
Autothumbnailer MOD 2.2.1 works great with pictures also.
Now here is the problem/request Autothumbnailer MOD 2.2.1 does not see that in 4images_images table the field image_thumb_file field is emply for everything that is not a picture (jpg). (all other autothumbnailers did not see other file types also)
How do I make the MOD see that there is no thumbnail for videos?
let me paraphrase my question:
How do I make this code work from thumbnailer.php (version 2.2.1) in CP? This function does not see that mov,wmv,avi files have no thumbs in Database.... Please help. I have a ton of videos with no preview that I want to add thumbs to...
Perhaps post this in a thread for "Autothumbnailer MOD 2.2.1"?
-
It would be nice that this mod was well organized in order to all people can easily install it :)
-
Ok... I'm lost in this MOD!
-
It would be nice that this mod was well organized in order to all people can easily install it :)
Guys, this mod is still not working propertly. If you still want to try it then follow the changes listed in post 21 of this thread. BUT BACKUP YOUR ORIGINALS so you can always roll back the changes. Good luck!
-
V@no, Everything is working great now, that was my only glitch...
thanks for all your invaluable help...
Kind Regards,
WeZ
For wez its working well (at least he says that)
but... in your mod what doesn't work?
-
I got this error in your MOD
"
Parse error: syntax error, unexpected '}' in /home/songokou/public_html/aceleras/member.php on line 680
"
Also where I put mplayer.exe ? Could be wmplayer.exe changed to mplayer.exe?
-
Hi son_gokou & alekseyn1,
i always promise myself that when a forum like this one helps me, which it has, i will do my best to return the favour to others in it. Sorta paying it forward...
i have been on honeymoon and away from my pc (at gunpoint i tell you :lol:) ... just kidding...
Anyway, alekseyn1... i think i might be able to help you considering i also have that plug-in installed.
In thumbnailer.php, try finding the code
if ($is_exists || (($image_info[2] == 1 ||
and ensure the ENTIRE STRING looks like this:
if ($is_exists || (($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3 || $image_info[2] == 15 || (in_array(get_file_extension($media_file), array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv")))) && $create)) {
give that a go... p.s. you can modify the extensions in that list to suit your needs...
Now, son_gokou... remember i am not a php programmer, so my troubleshooting techniques are by no means correct. whenever i get the unexpected '}'
error, i look on the line it complains about and sure enough i see a }
on that line. the error often is resolved by adding another }
next to it, or removing the one that is there. have you tried these?
Cheers
-
First of all enjoy your honeymoon ;)
Then... when you have time tell me:
"Also where I put mplayer.exe ? Could be wmplayer.exe changed to mplayer.exe?"
This is vital I think.
-
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?
-
Hi son_gokou & alekseyn1,
Anyway, alekseyn1... i think i might be able to help you considering i also have that plug-in installed.
Thanks Wez! It helps a lot! At least this code now hels the thumbnailer.php to see that the thumb is missing... I will have to dig more in my code... mplayer.exe is not working properly for me...
Thanks anyways!
-
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 (http://www.mplayerhq.hu/design7/dload.html)
Step 1.
In image_utils.php find and modify as follows:
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:
// 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!
-
I did what you told but... no thumbnail was created...
-
I did what you told but... no thumbnail was created...
Hi son_gokou,
do you get any PHP errors on your site when you add a video?
-
Hi son_gokou & alekseyn1,
Anyway, alekseyn1... i think i might be able to help you considering i also have that plug-in installed.
Thanks Wez! It helps a lot! At least this code now hels the thumbnailer.php to see that the thumb is missing... I will have to dig more in my code... mplayer.exe is not working properly for me...
Thanks anyways!
Thanks alekseyn1,
Are you up and running, ok?
Cheers
-
No php error... just no thumbail created...
-
Hi son_gokou,
ok, the first thing you need to do, is get it working in a command window. open a command window and browse to the mplayer directory. place a copy of the video file you want to test with in the directory. run the thumbnail command directly from there and see if you can generate a thumbnail from there?
Cheers
-
I put the directory mplayer on c:\mplayer (it has 22 mb right?).
I put amigo.avi on c:\mplayer .
I run cmd on execute and put the command C:\\mplayer\\mplayer.exe \"".$src."\" -ss ".$length." -nosound -vo jpeg:smooth=75 -vop scale=120:80 -frames 1 > imagegenoutput.txt and the following error appears.
(http://img297.imageshack.us/img297/904/message1xm7.th.jpg) (http://img297.imageshack.us/my.php?image=message1xm7.jpg)
Ok, I replace \"".$src."\" into c:\player\amigo.avi to test and appears this:
(http://img177.imageshack.us/img177/990/message2vv4.th.jpg) (http://img177.imageshack.us/my.php?image=message2vv4.jpg)
-
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:
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?
-
It continues to appear this (http://img263.imageshack.us/img263/7824/message3io5.th.jpg) (http://img263.imageshack.us/my.php?image=message3io5.jpg)
arial.ttf ???
imagegenoutput.txt is created
-
can anyone modify the commands so, that the code works with ffmpeg? unfortunately mplayer is no option for me.....
-
WeZ doesn´t want to share with us :twisted:
-
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:
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
-
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 (http://www.mplayerhq.hu/design7/dload.html)
Step 1.
In image_utils.php find and modify as follows:
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:
// 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!
-
I'm running on a linux server. Could be that? How I change the path C:\\mplayer\\mplayer.exe into a linux path?
-
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?
-
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?
-
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
-
Oki, I will describe the exact point we are with ffmpeg.
Files to edit:
member.php
includes/image_utils.php
In member.php find:
// 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:
// 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:
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:
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 $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.
-
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.
-
Looks like there isn´t anyone that expert to do it :)
-
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
-
Me :) would you like to work a few minutes on this with me?
-
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
-
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?
-
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
<?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 == 0 ? 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(1 => "gif", 2 => "jpeg", 3 => "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, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
}
else {
imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
}
$image_handle = "image".$types[$image_info[2]];
$image_handle($thumb, $dest, $quality);
imagedestroy($image);
imagedestroy($thumb);
}
return (file_exists($dest)) ? 1 : 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)) ? 1 : 0;
}
function resize_image_netpbm($src, $dest, $quality, $width, $height, $image_info) {
global $convert_options;
$convert_path = $convert_options['convert_path'];
$types = array(1 => "gif", 2 => "jpeg", 3 => "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)) ? 1 : 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($dest, CHMOD_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($dest, CHMOD_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($file, CHMOD_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)) ? 1 : 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
-
Is member.php finished?
What about the OS of your host provider?
Thanks
-
Hi ,
Strange, the forum keeps cutting off the code and ends the message...
anyway i have attached the file.
I host my own server on a Windows Server 2003 Standard installed with TSW 3.4.0 (The Saint WAMP) which provides me with php5 and MySQL.
Let me know if all this helps.
Cheers
-
This can´t work in a linux server because the program is for WINDOWS...
duuuuuh
-
Hi Son_gokou,
No, it is actually a linux application, i just use the windows distribution...
go to:
http://www.mplayerhq.hu/DOCS/HTML/en/intro.html
it says "MPlayer is a movie player for Linux"
all you have to do is find a distribution for you...
Ciao
WeZ
-
But i was talking about the ffmpeg...
-
but if i remember correctly, my code only uses MPlayer?
-
Yes dude. I was mistaken (some posts ago). Your code is perfectly. Of course I wouldn´t find any errors. A partner saw everything too. But no way I can work with this on my server. Anyway... they don´t allow ffmpeg too.
Ok, ffmpeg is finished for now. I will look into mplayer as you. And... what about imagemagick? http://www.imagemagick.org/script/formats.php
Dude... thanks for your help :)
-
It's a pity you cant use Mplayer...
IMHO, ImageMagick is good for images and not so good for video... hence why i dont use it...
Keep well...
-
Does this work with flv files? If so I will for sure be installing today.
Aaron
-
Hi Smoothice,
it works fine with FLV's ...
Cheers
-
hi guys
i have 1.7.4
they work
??
-
Hi SnaFy,
Unfortunately I have far too many mods in my site for me to even think of upgrading... so i am still on 1.7.2
My suggestion would be to backup your files and try!!
Cheers
-
this works well on my site running 1.7.4, Fedora 4, lighttpd
ffmpeg with 3gp support:)
-
Hi son_gokou & alekseyn1,
Anyway, alekseyn1... i think i might be able to help you considering i also have that plug-in installed.
Thanks Wez! It helps a lot! At least this code now hels the thumbnailer.php to see that the thumb is missing... I will have to dig more in my code... mplayer.exe is not working properly for me...
Thanks anyways!
Hi Wez and Alekseyn1,
How did you fix the thumbnailer.php to see thumb missing?
thanks
-
Hi JamieFrancis,
Sorry, this was quite long ago, not quite sure i was the one with the missing thumb error - i think it was alekseyn1 who had the problem. i think he was not putting the whole member.php in.
if you look in the source of the resulting page, what is the location of the thumbnail?
Cheers
-
Hi WeZ,
After i installed the ffmpeg to generate the video thumbnails everything works well,
my problem is that all the previous videos i had before i installed the script is using the standard icon ex: 3gp, wmv, avi
when i i use the autothumbnailer MOD 2.2.1 it doesnt detect the video files without a thumbnail.
i thought you were able to remedy this problem:)
thanks
-
In order to help people I must say that this (ffmpeg or wmplayer) just works if the server allow to install one of the programs.
-
Hi JamieFrancis,
i think i have the same mod installed so you might be in luck...
try this out - Back up your Files first though...
open image_utils.php in the includes directory.
find and replace your "create_thumbnail" function with the one (i might have modified myself :-)) below:
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($dest, CHMOD_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($dest, CHMOD_FILES);
return true;
}
else {
return false;
}
}
Hope this helps...
Cheers
-
array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv")
Carful when use that ... upload extension can use with MOD from includes/upload_definitions.php file. No need for use extension 2 time. ;)
-
Hi ThunderStrike,
my upload.php is still the standard shipped with the 4Images with no modifications. mine seemed to work so something must be right...
Ciao
WeZ
-
Sorry, wrong file. My post edit now. ;)
-
Hi ThunderStrike,
Ahh, Yes, Now That file i did modify. I'm Not sure of which ones i added, but JamieFrancis, here is my upload_definitions.php file anyway:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: upload_definitions.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");
}
$mime_type_match['jpg'] = array("image/jpg", "image/jpeg", "image/pjpeg");
$mime_type_match['jpeg'] = array("image/jpg", "image/jpeg", "image/pjpeg");
$mime_type_match['jpe'] = array("image/jpg", "image/jpeg", "image/pjpeg");
$mime_type_match['gif'] = array("image/gif");
$mime_type_match['png'] = array("image/png", "image/x-png");
$mime_type_match['tif'] = array("image/tiff", "application/octet-stream");
$mime_type_match['tiff'] = array("image/tiff", "application/octet-stream");
$mime_type_match['bmp'] = array("image/bmp", "image/x-ms-bmp");
$mime_type_match['aif'] = array("audio/x-aiff");
$mime_type_match['aiff'] = array("audio/x-aiff");
$mime_type_match['au'] = array("audio/basic");
$mime_type_match['snd'] = array("audio/basic");
$mime_type_match['mid'] = array("audio/x-midi", "audio/mid", "audio/midi");
$mime_type_match['mp3'] = array("audio/mpeg", "audio/x-mpeg", "audio/mp3", "audio/mpg");
$mime_type_match['wma'] = array("audio/mpeg", "audio/x-mpeg", "audio/mp3", "audio/mpg", "audio/x-ms-wma");
$mime_type_match['ra'] = array("audio/x-pn-realaudio");
$mime_type_match['ram'] = array("audio/x-pn-realaudio");
$mime_type_match['rm'] = array("audio/vnd.rn-realmedia", "application/vnd.rn-realmedia", "video/vnd.rn-realvideo", "application/vnd");
$mime_type_match['rpm'] = array("audio/x-pn-realaudio-plugin");
$mime_type_match['wav'] = array("audio/x-wav");
$mime_type_match['avi'] = array("video/x-msvideo", "video/avi");
$mime_type_match['mpg'] = array("video/mpeg");
$mime_type_match['mpeg'] = array("video/mpeg");
$mime_type_match['wmv'] = array("video/x-ms-wmv");
$mime_type_match['mov'] = array("video/quicktime");
$mime_type_match['qt'] = array("video/quicktime");
$mime_type_match['swf'] = array("application/x-shockwave-flash");
$mime_type_match['asf'] = array("video/x-ms-asf");
$mime_type_match['asx'] = array("asx, video/x-ms-asf");
$mime_type_match['psd'] = array("application/octet-stream");
$mime_type_match['fla'] = array("application/octet-stream");
$mime_type_match['mp4'] = array("video/mp4", "application/octet-stream");
$mime_type_match['flv'] = array("application/x-shockwave-flash", "application/octet-stream");
$mime_type_match['gz'] = array("application/gzip", "application/x-gzip-compressed");
$mime_type_match['rar'] = array("application/x-rar-compressed");
$mime_type_match['tar'] = array("application/x-tar");
$mime_type_match['gtar'] = array("application/x-gtar");
$mime_type_match['zip'] = array("application/zip", "application/x-zip-compressed");
$mime_type_match['sit'] = array("application/x-stuffit");
$mime_type_match['pdf'] = array("application/pdf", "application/x-pdf");
$mime_type_match['ai'] = array("application/postscript");
$mime_type_match['eps'] = array("application/postscript");
$mime_type_match['ps'] = array("application/postscript");
$mime_type_match['txt'] = array("text/plain", "text/richtext", "text/rtf", "text/html");
$mime_type_match['rtf'] = array("text/plain", "text/richtext", "text/rtf");
$mime_type_match['rtx'] = array("text/plain", "text/richtext", "text/rtf");
$mime_type_match['doc'] = array("application/msword");
$mime_type_match['xls'] = array("application/vnd", "application/x-msexcel");
$mime_type_match['ppt'] = array("application/vnd");
$mime_type_match['csv'] = array("text/comma-separated-values");
$mime_type_match['js'] = array("text/javascript");
$mime_type_match['css'] = array("text/css");
?>
Let me know if it helps.
Ciao
WeZ
-
Sorry for late reply.
Finish code.
In includes/image_utils.php file,
replace:
if (in_array(get_file_extension($src), array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv"))) {
with:
// MOD: Get Upload Extension (match with includes/upload_definitions.php).
include(ROOT_PATH.'includes/upload_definitions.php');
$extension_list = array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv")
if (function_exists('get_upload_definitions') && get_upload_definitions($extension_list)) {
// End of MOD: Get Upload Extension.
In includes/functions.php file,
add on top ?>:
function get_upload_definitions($array) {
if (!isset($array) || !is_array($array) || empty($array)) {
return;
}
if (isset($array) && is_array($array) && !empty($array)) {
include(ROOT_PATH . "includes/upload_definitions.php");
$get_vals = "";
foreach ($array as $key => $val) {
foreach ($mime_type_match[$val] as $key1 => $val1) {
if ($key1 == $val1) {
$get_vals .= $val. ", ";
break;
}
}
}
$get_vals = substr($get_vals, 0, strlen($get_vals) -2);
return $get_vals;
}
}
Check for match with $extension_list and $mime_type_match now. If no exist, foreach error message show. ;)
Note: All list extension in $extension_list is do from $mime_type_match ( ekal ) . If no, error. This will help user to use upload_definitions.php file like Jan code in 1st. ;)
-
Hi Wez and thurnderstrike,
here is my image_utils.php
<?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.4 *
* *
* 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 == 0 ? 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(1 => "gif", 2 => "jpeg", 3 => "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, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
}
else {
imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
}
if ($image_info[2] == 3) {
$quality = 9;
}
$image_handle = "image".$types[$image_info[2]];
$image_handle($thumb, $dest, $quality);
imagedestroy($image);
imagedestroy($thumb);
}
return (file_exists($dest)) ? 1 : 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)) ? 1 : 0;
}
function resize_image_netpbm($src, $dest, $quality, $width, $height, $image_info) {
global $convert_options;
$convert_path = $convert_options['convert_path'];
$types = array(1 => "gif", 2 => "jpeg", 3 => "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)) ? 1 : 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 (!$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 = "/usr/local/bin/ffmpeg -i ".$src." -f mjpeg -t 0.02 -s 90x90 ".$dest;
echo ($command);
system($command);
return (file_exists($dest)) ? 1 : 0;
}
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_".$convert_options['convert_tool'];
if ($resize_handle($file_bak, $file, $quality, $width_height['width'], $width_height['height'], $image_info)) {
@chmod($file, CHMOD_FILES);
@unlink($file_bak);
return true;
}
else {
rename($file_bak, $file);
return false;
}
}
?>
-
And problem ??
-
Hi the problem is that,
videos uploaded before i started using ffmpeg has the standard icon saying no images.
when i use the autothumbnailer its doesnt detect those old video files without thumbnails:(
-
The thumbs are auto created?
-
Sorry for late reply.
Finish code.
In includes/image_utils.php file,
replace:
if (in_array(get_file_extension($src), array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv"))) {
with:
// MOD: Get Upload Extension (match with includes/upload_definitions.php).
include(ROOT_PATH.'includes/upload_definitions.php');
$extension_list = array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv")
if (function_exists('get_upload_definitions') && get_upload_definitions($extension_list)) {
// End of MOD: Get Upload Extension.
In includes/functions.php file,
add on top ?>:
function get_upload_definitions($array) {
if (!isset($array) || !is_array($array) || empty($array)) {
return;
}
if (isset($array) && is_array($array) && !empty($array)) {
include(ROOT_PATH . "includes/upload_definitions.php");
$get_vals = "";
foreach ($array as $key => $val) {
foreach ($mime_type_match[$val] as $key1 => $val1) {
if ($key1 == $val1) {
$get_vals .= $val. ", ";
break;
}
}
}
$get_vals = substr($get_vals, 0, strlen($get_vals) -2);
return $get_vals;
}
}
Check for match with $extension_list and $mime_type_match now. If no exist, foreach error message show. ;)
Note: All list extension in $extension_list is do from $mime_type_match ( ekal ) . If no, error. This will help user to use upload_definitions.php file like Jan code in 1st. ;)
I can't find this code in my image_utils.php
if (in_array(get_file_extension($src), array("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv"))) {
-
Hi Mathuatden,
are you having any errors?
i would suggest applying the MOD on page one and see if you have any issues, work your way through the thread.
you will find the code you are talking about here:
http://www.4homepages.de/forum/index.php?topic=12272.msg92366#msg92366
Cheers
WeZ
-
Is there anything that can thumbnail streaming content? I have a mod installed that streams flash from external sources. There are no extensions in the flash embedcode.
-
I am trying to use WEZ mode with mplayer. I can create thumbnails mannually by SSH in any directory, but in 4 images it appears the error:
Warning: unlink(imagegenoutput.txt) [function.unlink]: No such file or directory in /home/directory/public_html/url.com/includes/image_utils.php on line 221
Warning: unlink(00000001.jpg) [function.unlink]: No such file or directory in /home/directory/public_html/url.com/includes/image_utils.php on line 222
Warning: rename(00000002.jpg,./data/thumbnails/1/1_2.flv.jpg) [function.rename]: No such file or directory in /home/directory/public_html/url.com/includes/image_utils.php on line 223
Here is my member.php (it's wez member.php)
<?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']) && 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("asf", "wma", "wmv", "mpg", "mpeg", "avi", "mov", "asx", "mp4", "flv")) && Generate_VideoThumb($src, $dest.".jpg")) {
$new_thumb_name = $new_name.".jpg";
}
}
}
//-------------------------------------------------------------------------------------------
// --- Annotate Images ----------------------------------------------------------------------
//-------------------------------------------------------------------------------------------
if ($config['annotation_use'] && strtolower(get_file_extension($new_name) == jpg)) {
require_once(ROOT_PATH.'includes/annotate.php');
$ann_user_name = ($user_info['user_name']);
if ($direct_upload) { $ann_src = MEDIA_PATH."/".$cat_id."/".$new_name; }
else { $ann_src = MEDIA_TEMP_PATH."/".$new_name; }
annotate_image($ann_src);
}
//-------------------------------------------------------------------------------------------
if (!$uploaderror) {
$additional_field_sql = "";
$additional_value_sql = "";
if (!empty($additional_image_fields)) {
$table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
$table_fields = $site_db->get_table_fields($table);
foreach ($additional_image_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_field_sql .= ", $key";
$additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
$current_time = time();
$imgname = ($fileext!="")?"$image_name $fileext":$image_name;
if ($direct_upload) {
$sql = "INSERT INTO ".IMAGES_TABLE."
(cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$imgname', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";
$result = $site_db->query($sql);
$image_id = $site_db->get_insert_id();
if ($result) {
include_once(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]);
}
}
add_searchwords($image_id, $search_words);
}
}
else {
$sql = "INSERT INTO ".IMAGES_TEMP_TABLE."
(cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url".$additional_field_sql.")
VALUES
($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url'".$additional_value_sql.")";
$result = $site_db->query($sql);
}
if ($config['upload_notify'] == 1 && !$direct_upload) {
include_once(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$config['upload_emails'] = str_replace(" ", "", $config['upload_emails']);
$emails = explode(",", $config['upload_emails']);
$validation_url = $script_url."/admin/index.php?goto=".urlencode("validateimages.php?action=validateimages");
$site_email->set_to($config['site_email']);
$site_email->set_subject($lang['new_upload_emailsubject']);
$site_email->register_vars(array(
"image_name" => stripslashes($image_name),
"file_name" => $new_name,
"cat_name" => $cat_cache[$cat_id]['cat_name'],
"validation_url" => $validation_url,
"site_name" => $config['site_name']
));
$site_email->set_body("upload_notify", $config['language_dir_default']);
$site_email->set_bcc($emails);
$site_email->send_email();
}
$msg .= $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$new_name.")<br>";
$msg .= (!$direct_upload) ? "<br />".$lang['new_upload_validate_desc'] : "";
$file_extension = get_file_extension($new_name);
$file = (is_remote($new_name)) ? $new_name : (($direct_upload) ? MEDIA_PATH."/".$cat_id."/".$new_name : MEDIA_TEMP_PATH."/".$new_name);
$width_height = "";
if (!is_remote($file) && $imageinfo = @getimagesize($file)) {
$width_height = " ".$imageinfo[3];
}
$media_icon = "<img src=\"".ICON_PATH."/".$file_extension.".gif\" border=\"0\" alt=\"\" />";
$site_template->register_vars(array(
"media_src" => $file,
"media_icon" => $media_icon,
"image_name" => format_text(stripslashes($image_name)),
"width_height" => $width_height
));
$media = $site_template->parse_template("media/".$file_extension);
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
$good=1;
}
else {
//Atleast 1 multifile succeeded.
if(count($HTTP_POST_FILES) && $good==1)
{
$action = "multiuploadform";
break;
}
else
{
$action=($action=="multiuploadimage")?"multiuploadform":"uploadform";
$sendprocess = 1;
break; //break the while if any image upload fails
}
}
$fileext=($fileext=="")?2:$fileext+1;
}//end while
}//end if
else
{
$action = "uploadform";
$sendprocess = 1;
}
}//end upload action
//Show the form
if ($action == "uploadform" || $action == "multiuploadform") {
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'];
if (!$sendprocess) {
$remote_media_file = "";
$remote_thumb_file = "";
$image_name = "";
$image_description = "";
$image_keywords = "";
$image_download_url = "";
$image_allow_comments = 1;
}
$site_template->register_vars(array(
"cat_id" => $cat_id,
"cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name']) : get_category_dropdown($cat_id),
"remote_media_file" => format_text(stripslashes($remote_media_file)),
"remote_thumb_file" => format_text(stripslashes($remote_thumb_file)),
"image_name" => format_text(stripslashes($image_name), 2),
"image_description" => format_text(stripslashes($image_description), 2),
"image_keywords" => format_text(stripslashes($image_keywords), 2),
"image_allow_comments_yes" => ($image_allow_comments) ? " checked=\"checked\"" : "",
"image_allow_comments_no" => (!$image_allow_comments) ? " checked=\"checked\"" : "",
"image_download_url" => format_text(stripslashes($image_download_url), 2),
"lang_category" => $lang['category'],
"lang_user_upload" => $lang['user_upload'],
"lang_media_file" => $lang['media_file'],
"lang_thumb_file" => $lang['thumb_file'],
"lang_allowed_file_types" => $lang['allowed_mediatypes_desc'],
"allowed_media_types" => str_replace(",",", ",$config['allowed_mediatypes']),
"allowed_thumb_types" => "jpg, gif, png",
"lang_max_filesize" => $lang['max_filesize'],
"lang_max_imagewidth" => $lang['max_imagewidth'],
"lang_max_imageheight" => $lang['max_imageheight'],
"max_thumb_filsize" => $config['max_thumb_size']." ".$lang['kb'],
"max_thumb_imagewidth" => $config['max_thumb_width']." ".$lang['px'],
"max_thumb_imageheight" => $config['max_thumb_height']." ".$lang['px'],
"max_media_filsize" => $config['max_media_size']." ".$lang['kb'],
"max_media_imagewidth" => $config['max_image_width']." ".$lang['px'],
"max_media_imageheight" => $config['max_image_height']." ".$lang['px'],
"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]) : 1;
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]))) : "";
}
$additional_field_array[$key] = $value;
$additional_field_array['lang_'.$key] = $val[0];
}
if (!empty($additional_field_array)) {
$site_template->register_vars($additional_field_array);
}
}
if($action == "multiuploadform" || $action=="multiuploadimage")
{
$content = $site_template->parse_template("member_multiuploadform");
}
else
{
$content = $site_template->parse_template("member_uploadform");
}
}
if ($action == "emailuser") {
$txt_clickstream = $lang['profile'];
$user_id = (isset($HTTP_POST_VARS[URL_USER_ID])) ? intval($HTTP_POST_VARS[URL_USER_ID]) : GUEST;
$error = 0;
if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
show_error_page($lang['no_permission']);
exit;
}
$subject = stripslashes(trim($HTTP_POST_VARS['subject']));
$message = stripslashes(trim($HTTP_POST_VARS['message']));
if ($subject == "" || $message == "") {
$msg = $lang['lostfield_error'];
$sendprocess = 1;
$error = 1;
}
if (!$error) {
if ($user_row = get_user_info($user_id)) {
if (isset($user_row['user_showemail']) && $user_row['user_showemail'] == 0) {
$content = $lang['invalid_user_id'];
}
else {
$sender_user_name = ($user_info['user_level'] != GUEST) ? (isset($user_info['user_name']) ? $user_info['user_name'] : $lang['userlevel_user']) : $lang['userlevel_guest'];
$sender_user_email = ($user_info['user_level'] != GUEST && isset($user_info['user_email'])) ? $user_info['user_email'] : $config['site_email'];
// Start Emailer
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$site_email->set_from($sender_user_email, $sender_user_name);
$site_email->set_to($user_row['user_email']);
$site_email->set_subject($subject);
$site_email->register_vars(array(
"sender_user_name" => $sender_user_name,
"sender_user_email" => $sender_user_email,
"message" => $message,
"site_name" => $config['site_name']
));
$site_email->set_body("mailform_message", $config['language_dir']);
$site_email->send_email();
$msg = $lang['emailuser_success'];
}
}
else {
$content = $lang['invalid_user_id'];
}
}
else {
$action = "mailform";
}
}
if ($action == "mailform") {
$txt_clickstream = $lang['profile'];
if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
if (!$user_id) {
$user_id = GUEST;
}
}
else {
$user_id = GUEST;
}
if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
show_error_page($lang['no_permission']);
exit;
}
if (!$sendprocess) {
$subject = "";
$message = "";
}
if ($user_row = get_user_info($user_id)) {
if (isset($user_row['user_showemail']) && $user_row['user_showemail'] == 0) {
$content = $lang['invalid_user_id'];
}
else {
$site_template->register_vars(array(
"user_id" => $user_row['user_id'],
"user_name" => format_text($user_row['user_name']),
"subject" => format_text($subject, 2),
"message" => format_text($message, 2),
"lang_send_email_to" => $lang['send_email_to'],
"lang_subject" => $lang['subject'],
"lang_message" => $lang['message'],
"lang_submit" => $lang['submit'],
"lang_reset" => $lang['reset']
));
$content = $site_template->parse_template("member_mailform");
}
}
else {
$content = $lang['invalid_user_id'];
}
}
//-----------------------------------------------------
//--- Show Profile ------------------------------------
//-----------------------------------------------------
if ($action == "showprofile") {
$txt_clickstream = $lang['profile'];
if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
$user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval($HTTP_GET_VARS[URL_USER_ID]) : intval($HTTP_POST_VARS[URL_USER_ID]);
if (!$user_id) {
$user_id = GUEST;
}
}
else {
$user_id = GUEST;
}
if ($user_row = get_user_info($user_id)) {
$user_homepage = (isset($user_row['user_homepage'])) ? format_url($user_row['user_homepage']) : REPLACE_EMPTY;
if (!empty($user_homepage) && $user_homepage != REPLACE_EMPTY) {
$user_homepage_button = "<a href=\"".$user_homepage."\" target=\"_blank\"><img src=\"".get_gallery_image("homepage.gif")."\" border=\"0\" alt=\"".$user_homepage."\" /></a>";
}
else {
$user_homepage_button = REPLACE_EMPTY;
}
$user_icq = (isset($user_row['user_icq'])) ? $user_row['user_icq'] : REPLACE_EMPTY;
if (!empty($user_icq) && $user_icq != REPLACE_EMPTY) {
$user_icq_button = "<a href=\"http://wwp.icq.com/scripts/search.dll?to=".$user_icq."\" target=\"_blank\"><img src=\"http://web.icq.com/whitepages/online?icq=".$user_icq."&img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"".$user_icq."\" /></a>";
}
else {
$user_icq_button = REPLACE_EMPTY;
}
if (!empty($user_row['user_email']) && (!isset($user_row['user_showemail']) || (isset($user_row['user_showemail']) && $user_row['user_showemail'] == 1))) {
$user_email = $user_row['user_email'];
$user_email_save = str_replace("@", " at ", $user_row['user_email']);
if (!empty($url_mailform)) {
$user_mailform_link = $site_sess->url(preg_replace("/{user_id}/", $user_row['user_id'], $url_mailform));
}
else {
$user_mailform_link = $site_sess->url(ROOT_PATH."member.php?action=mailform&".URL_USER_ID."=".$user_row['user_id']);
}
$user_email_button = "<a href=\"".$user_mailform_link."\"><img src=\"".get_gallery_image("email.gif")."\" border=\"0\" alt=\"".$user_email_save."\" /></a>";
}
else {
$user_email = REPLACE_EMPTY;
$user_email_save = REPLACE_EMPTY;
$user_mailform_link = REPLACE_EMPTY;
$user_email_button = REPLACE_EMPTY;
}
// Birthday Mod
$user_birthday = (isset($user_row[$user_table_fields['birthday']])) ? $user_row[$user_table_fields['birthday']] : REPLACE_EMPTY;
if (!empty($user_birthday) && $user_birthday != REPLACE_EMPTY && $user_row[$user_table_fields['birthday']] != "0000-00-00") {
$birthday = explode("-",$user_row[$user_table_fields['birthday']]);
$user_birthday = $birthday[2].".".$lang['months'][sprintf("%02d",$birthday[1])];
$user_birthday .= ($birthday[0]!="0000") ? " ".$birthday[0]."" : "";
// Show Age in Profile
if (($config['birthday_show_profile_age'] == 1) && ($age = calc_age ($user_row[$user_table_fields['birthday']]))) {
$user_birthday .= " ($age)";
}
// Show Birthdaycountdown in Profile
if ($config['birthday_profile_countdown'] == 1 && $b_cdown = calc_countdown ($user_row[$user_table_fields['birthday']])) {
$site_template->register_vars(array(
"lang_birthday_cdown" => $lang['birthday_cdown'],
"cdown_days" => $b_cdown['days'],
"cdown_hours" => $b_cdown['hours'],
"cdown_minutes" => $b_cdown['minutes'],
"lang_days" => $lang['days'],
"lang_hours" => $lang['hours'],
"lang_minutes" => $lang['minutes']
));
}
// End Show Birthdaycountdown in Profile
}
else {
$user_birthday = REPLACE_EMPTY;
}
// Birthday Mod
$site_template->register_vars(array(
"user_id" => $user_row['user_id'],
"user_name" => (isset($user_row['user_name'])) ? format_text($user_row['user_name']) : REPLACE_EMPTY,
"user_birthday" => $user_birthday,
"user_email" => $user_email,
"user_email_save" => $user_email_save,
"user_mailform_link" => $user_mailform_link,
"user_email_button" => $user_email_button,
"user_join_date" => (isset($user_row['user_joindate'])) ? format_date($config['date_format'], $user_row['user_joindate']) : REPLACE_EMPTY,
"user_last_action" => (isset($user_row['user_lastaction'])) ? format_date($config['date_format']." ".$config['time_format'], $user_row['user_lastaction']) : REPLACE_EMPTY,
"user_homepage" => $user_homepage,
//User Pic
"userpic_img" => ($config['userpic'] && $user_row['userpic']) ? ROOT_PATH."data/userpic/".$user_row['userpic'] : "",
//End User Pic
"user_homepage_button" => $user_homepage_button,
"user_icq" => $user_icq,
"user_icq_button" => $user_icq_button,
"user_icq_status" => (isset($user_row['user_icq'])) ? get_icq_status($user_row['user_icq']) : REPLACE_EMPTY,
"user_comments" => (isset($user_row['user_comments'])) ? $user_row['user_comments'] : REPLACE_EMPTY,
"lang_profile_of" => $lang['profile_of'],
"lang_show_user_images" => preg_replace("/".$site_template->start."user_name".$site_template->end."/siU", $user_row['user_name'], $lang['show_user_images']),
"url_show_user_images" => $site_sess->url(ROOT_PATH."search.php?search_user=".urlencode($user_row['user_name'])),
"lang_join_date" => $lang['join_date'],
"lang_last_action" => $lang['last_action'],
"lang_comments" => $lang['comments'],
"lang_email" => $lang['email'],
"lang_homepage" => $lang['homepage'],
"lang_icq" => $lang['icq']
));
if (!empty($additional_user_fields)) {
$additional_field_array = array();
foreach ($additional_user_fields as $key => $val) {
$additional_field_array[$key] = (!empty($user_row[$key])) ? format_text($user_row[$key], 1) : REPLACE_EMPTY;
$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_profile");
}
else {
$content = $lang['invalid_user_id'];
}
}
//-----------------------------------------------------
//--- Send Password -----------------------------------
//-----------------------------------------------------
if ($action == "sendpassword") {
$txt_clickstream = $lang['lost_password'];
$user_email = un_htmlspecialchars(trim($HTTP_POST_VARS['user_email']));
if ($user_email != "") {
$sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_password")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_email")." = '$user_email'";
if ($checkuser = $site_db->query_firstrow($sql)) {
mt_srand((double) microtime() * 1000000);
$puddle = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$user_password = "";
for ($i = 0; $i < 8; $i++) {
$user_password .= substr($puddle, (mt_rand()%(strlen($puddle))), 1);
}
$sql = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_password")." = '".md5($user_password)."'
WHERE ".get_user_table_field("", "user_id")." = ".$checkuser[$user_table_fields['user_id']];
$site_db->query($sql);
// Start Emailer
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$site_email->set_to($user_email);
$site_email->set_subject($lang['send_password_emailsubject']);
$site_email->register_vars(array(
"user_name" => $checkuser[$user_table_fields['user_name']],
"user_password" => stripslashes($user_password),
"site_name" => $config['site_name']
));
$site_email->set_body("lost_password", $config['language_dir']);
$site_email->send_email();
$msg = $lang['send_password_success'];
$HTTP_POST_VARS['user_email'] = "";
}
else {
$msg = $lang['invalid_email'];
}
}
$action = "lostpassword";
}
if ($action == "lostpassword") {
$txt_clickstream = $lang['lost_password'];
$user_email = (isset($HTTP_POST_VARS['user_email'])) ? format_text(stripslashes($HTTP_POST_VARS['user_email'])) : "";
$site_template->register_vars(array(
"lang_email" => $lang['email'],
"lang_lost_password" => $lang['lost_password'],
"lang_lost_password_msg" => $lang['lost_password_msg'],
"lang_submit" => $lang['submit'],
"user_email" => format_text($user_email, 2)
));
$content = $site_template->parse_template("member_lostpassword");
}
//-----------------------------------------------------
//--- Edit Profile ------------------------------------
//-----------------------------------------------------
$update_process = 0;
$new_email_msg = "";
if ($action == "updateprofile") {
$txt_clickstream = $lang['control_panel'];
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
$user_email = (isset($HTTP_POST_VARS['user_email'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_email'])) : "";
$user_email2 = (isset($HTTP_POST_VARS['user_email2'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_email2'])) : "";
$user_homepage = (isset($HTTP_POST_VARS['user_homepage'])) ? format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['user_homepage']))) : "";
$user_icq = (isset($HTTP_POST_VARS['user_icq'])) ? ((intval(trim($HTTP_POST_VARS['user_icq']))) ? intval(trim($HTTP_POST_VARS['user_icq'])) : "") : "";
$user_showemail = (isset($HTTP_POST_VARS['user_showemail'])) ? intval($HTTP_POST_VARS['user_showemail']) : 0;
$user_allowemails = (isset($HTTP_POST_VARS['user_allowemails'])) ? intval($HTTP_POST_VARS['user_allowemails']) : 0;
$user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;
$user_birthday_day = (isset($HTTP_POST_VARS['user_birthday_day'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_day'])) : "";
$user_birthday_month = (isset($HTTP_POST_VARS['user_birthday_month'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_month'])) : "";
$user_birthday_year = (isset($HTTP_POST_VARS['user_birthday_year'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_year'])) : "";
$error = 0;
if (!$user_birthday = check_birthday($user_birthday_day,$user_birthday_month,$user_birthday_year,$config['birthday_required'])) {
$msg .= (($msg != "") ? "<br />" : "").$lang['birthday_error'];
$error = 1;
}
if ($user_info['user_email'] != $user_email && $checkuser = $site_db->query_firstrow("SELECT ".get_user_table_field("", "user_id")." FROM ".USERS_TABLE." WHERE ".get_user_table_field("", "user_email")." = '$user_email' AND ".get_user_table_field("", "user_id")." <> '".$user_info['user_id']."'")) {
if ($checkuser[$user_table_fields['user_id']] != $user_info['user_id']) {
$msg .= (($msg != "") ? "<br />" : "").$lang['email_exists'];
$error = 1;
}
}
if ($user_email != $user_email2) {
$msg .= (($msg != "") ? "<br />" : "").$lang['update_email_confirm_error'];
$error = 1;
}
if ($user_email == "" || $user_email2 == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['update_email_error'];
$error = 1;
}
if (!check_email($user_email)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
$error = 1;
}
if (!empty($additional_user_fields)) {
foreach ($additional_user_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;
}
}
}
// Upload User Pic
$userpic = $userpic_new = "";
if (!$error && $config['userpic'])
{
$userpics_dir = ROOT_PATH."data/userpic/";
if (!empty($HTTP_POST_FILES['userpic_file']['tmp_name']) && $HTTP_POST_FILES['userpic_file']['tmp_name'] != "none")
{
if (isset($HTTP_COOKIE_VARS['userpic_file']) || isset($HTTP_POST_VARS['userpic_file']) || isset($HTTP_GET_VARS['userpic_file'])) {
die("Security violation");
}
if (!function_exists("is_uploaded_file")) {
function is_uploaded_file($file_name) {
if (!$tmp_file = @get_cfg_var('upload_tmp_dir')) {
$tmp_file = tempnam('','');
$deleted = @unlink($tmp_file);
$tmp_file = dirname($tmp_file);
}
$tmp_file .= '/'.basename($file_name);
return (ereg_replace('/+', '/', $tmp_file) == $file_name) ? 1 : 0;
}
function move_uploaded_file($file_name, $destination) {
return (is_uploaded_file($file_name)) ? ((copy($file_name, $destination)) ? 1 : 0) : 0;
}
}
$error = array();
$mime_types = array(
"image/jpeg",
"image/pjpeg",
"image/gif",
"image/x-png"
);
$extensions = array(
"jpg",
"jpeg",
"gif",
"png"
);
$userpic_ext = strtolower(substr(strrchr($HTTP_POST_FILES['userpic_file']['name'],"."), 1));
$userpic_mime = $HTTP_POST_FILES['userpic_file']['type'];
if (!in_array($userpic_mime, $mime_types) || !in_array($userpic_ext, $extensions))
{
$error[] = $lang['invalid_file_type']. " (".$userpic_ext.", ".$HTTP_POST_FILES['userpic_file']['type'].")";
}
if ($HTTP_POST_FILES['userpic_file']['size'] > $config['userpic_size'] * 1024)
{
$error[] = $lang['invalid_file_size'];
}
if (empty($error))
{
$userpic_name = $user_info['user_id'].".".$userpic_ext;
$userpic_file = $userpics_dir.$userpic_name;
if (file_exists($userpic_file))
{
unlink($userpic_file);
}
if (!move_uploaded_file($HTTP_POST_FILES['userpic_file']['tmp_name'], $userpic_file))
{
$error[] = $lang['file_copy_error'];
}
else
{
@chmod($userpic_file, CHMOD_FILES);
}
}
if (empty($error))
{
$userpic = $HTTP_POST_VARS['userpic'] = $userpic_new = $userpic_name;
if ($user_info['userpic'] != $userpic_name && file_exists($userpics_dir.$user_info['userpic']))
{
@unlink($userpics_dir.$user_info['userpic']);
}
if (!function_exists(init_convert_options))
{
require(ROOT_PATH.'includes/image_utils.php');
}
$image_info = getimagesize($userpic_file);
$convert_options = init_convert_options();
if (($image_info[0] > $config['userpic_width'] || $image_info[1] > $config['userpic_height']))
{
if ($convert_options['convert_error'] || (!$convert_options['convert_error'] && !resize_image($userpic_file, 85, $config['userpic_width'], 1)))
{
if ($image_info[0] > $config['userpic_width'])
{
$error[] = $lang['invalid_image_width'];
}
if ($image_info[1] > $config['userpic_height'])
{
$error[] = $lang['invalid_image_height'];
}
}
}
}
if (!empty($error))
{
$msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$HTTP_POST_FILES['userpic_file']['name']."</b><br />";
foreach ($error as $val) {
$msg .= "<b>".$HTTP_POST_FILES['userpic_file']['name'].":</b> ".$val."<br />";
}
$HTTP_POST_VARS['userpic'] = $user_info['userpic'];
}
}
else
{
if (isset($HTTP_POST_VARS['userpic_del']) && $HTTP_POST_VARS['userpic_del'])
{
@unlink($userpics_dir.$user_info['userpic']);
$HTTP_POST_VARS['userpic'] = $userpic = "";
$userpic_new = 1;
}
}
}
// End Upload User Pic
if (!$error && $user_email != $user_info['user_email'] && $user_info['user_level'] != ADMIN && $config['account_activation'] != 0) {
$activationkey = get_random_key(USERS_TABLE, $user_table_fields['user_activationkey']);
$sql = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_level")." = ".USER_AWAITING.", ".get_user_table_field("", "user_activationkey")." = '$activationkey'
WHERE ".get_user_table_field("", "user_id")." = ".$user_info['user_id'];
$result = $site_db->query($sql);
if ($result) {
$activation_url = $script_url."/register.php?action=activate&activationkey=".$activationkey;
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
switch($config['account_activation']) {
case 2:
$user_details_url = $script_url."/admin/index.php?goto=".urlencode("users.php?action=edituser&user_id=".$user_info['user_id']."&activation=1");
$email_to = $config['site_email'];
$email_subject = $lang['admin_activation_emailsubject'];
$email_template = "admin_activation";
$new_email_msg = $lang['update_email_instruction_admin'];
break;
case 1:
if ($config['language_dir_default'] != $config['language_dir']) {
$activation_url .= "&l=".$config['language_dir'];
}
$user_details_url = "";
$email_to = $user_email;
$email_subject = $lang['update_email_emailsubject'];
$email_template = "newemail_activation";
$new_email_msg = $lang['update_email_instruction'];
break;
case 0:
default:
break;
}
if (!empty($email_to)) {
$site_email->set_to($email_to);
$site_email->set_subject($email_subject);
$site_email->register_vars(array(
"user_details_url" => $user_details_url,
"activation_url" => $activation_url,
"user_name" => $user_info['user_name'],
"site_name" => $config['site_name']
));
$site_email->set_body($email_template, $config['language_dir']);
$site_email->send_email();
}
}
else {
$msg = $lang['general_error'];
$error = 1;
}
}
if (!$error) {
$additional_sql = "";
if (!empty($additional_user_fields)) {
$table_fields = $site_db->get_table_fields(USERS_TABLE);
foreach ($additional_user_fields as $key => $val) {
if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
}
}
// Birthday Mod
$additional_sql .= ", ".get_user_table_field("", "birthday")." = '$user_birthday'";
$sql = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_email")." = '$user_email', ".get_user_table_field("", "user_showemail")." = $user_showemail, ".get_user_table_field("", "user_allowemails")." = $user_allowemails, ".get_user_table_field("", "user_invisible")." = $user_invisible, ".get_user_table_field("", "user_homepage")." = '$user_homepage', ".get_user_table_field("", "user_icq")." = '$user_icq'".$additional_sql."
WHERE ".get_user_table_field("", "user_id")." = ".$user_info['user_id'];
$site_db->query($sql);
$msg = $lang['update_profile_success'];
if (!empty($new_email_msg)) {
$msg .= "<br />".$new_email_msg;
}
$user_info = $site_sess->load_user_info($user_info['user_id']);
}
else {
$update_process = 1;
}
$action = "editprofile";
}
if ($action == "updatepassword") {
$txt_clickstream = $lang['control_panel'];
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
$error = 0;
$current_user_password = md5(trim($HTTP_POST_VARS['current_user_password']));
$user_password = md5(trim($HTTP_POST_VARS['user_password']));
$user_password2 = md5(trim($HTTP_POST_VARS['user_password2']));
if ($current_user_password != $user_info['user_password']) {
$msg .= (($msg != "") ? "<br />" : "").$lang['update_password_error'];
$error = 1;
}
if ($user_password != $user_password2 || $user_password == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['update_password_confirm_error'];
$error = 1;
}
if (!$error) {
$sql = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_password")." = '$user_password'
WHERE ".get_user_table_field("", "user_id")." = ".$user_info['user_id'];
$site_db->query($sql);
$msg = $lang['update_password_success'];
$user_info = $site_sess->load_user_info($user_info['user_id']);
}
$action = "editprofile";
}
if ($action == "editprofile") {
$txt_clickstream = $lang['control_panel'];
if ($user_info['user_level'] == GUEST) {
show_error_page($lang['no_permission']);
exit;
}
$user_name = $user_info['user_name'];
if (!$update_process) {
$user_email = $user_info['user_email'];
$user_email2 = $user_info['user_email'];
$user_showemail = $user_info['user_showemail'];
$user_allowemails = $user_info['user_allowemails'];
$user_invisible = $user_info['user_invisible'];
$user_homepage = $user_info['user_homepage'];
$user_icq = $user_info['user_icq'];
$birthday = explode("-",$user_info['birthday']);
$user_birthday_day = $birthday[2];
$user_birthday_month = $birthday[1];
$user_birthday_year = $birthday[0];
}
$birthday_day_options = "<option value=\"\">--</option>\n";
$birthday_month_options = "<option value=\"\">--</option>\n";
for ($i=1;$i<=31;$i++){
$birthday_day_options .= "<option value=\"".sprintf("%02d",$i)."\"".(($i == $user_birthday_day) ? "selected" : "").">".$i."</option>\n";
}
for ($i=1;$i<=12;$i++){ //getmonth($i)
$birthday_month_options .= "<option value=\"".sprintf("%02d",$i)."\"".(($i == $user_birthday_month) ? "selected" : "").">".$lang['months'][sprintf("%02d",$i)]."</option>\n";
}
if ($user_showemail == 1) {
$user_showemail_yes = " checked=\"checked\"";
$user_showemail_no = "";
}
else {
$user_showemail_yes = "";
$user_showemail_no = " checked=\"checked\"";
}
if ($user_allowemails == 1) {
$user_allowemails_yes = " checked=\"checked\"";
$user_allowemails_no = "";
}
else {
$user_allowemails_yes = "";
$user_allowemails_no = " checked=\"checked\"";
}
if ($user_invisible == 1) {
$user_invisible_yes = " checked=\"checked\"";
$user_invisible_no = "";
}
else {
$user_invisible_yes = "";
$user_invisible_no = " checked=\"checked\"";
}
$edit_profile_msg = $lang['edit_profile_msg'];
if ($config['account_activation'] == 1 && $user_info['user_level'] != ADMIN) {
$edit_profile_msg .= $lang['edit_profile_email_msg'];
}
if ($config['account_activation'] == 2 && $user_info['user_level'] != ADMIN) {
$edit_profile_msg .= $lang['edit_profile_email_msg_admin'];
}
$site_template->register_vars(array(
"user_name" => format_text(stripslashes($user_name), 2),
"user_email" => format_text(stripslashes($user_email), 2),
"user_email2" => format_text(stripslashes($user_email2), 2),
"user_homepage" => format_text(stripslashes($user_homepage), 2),
"birthday_day_options" => $birthday_day_options,
"birthday_month_options" => $birthday_month_options,
"user_birthday_year" => $user_birthday_year,
"lang_day" => $lang['day'],
"lang_month" => $lang['month'],
"lang_year" => $lang['year'],
"user_icq" => $user_icq,
//User Pic
"userpic_allowed" => $config['userpic'],
"userpic_img" => ($user_info['userpic']) ? ROOT_PATH."data/userpic/".$user_info['userpic'] : "",
"lang_userpic_del" => $lang['userpic_del'],
"lang_userpic_upload" => preg_replace("/".$site_template->start."userpic_max_size".$site_template->end."/siU", $config['userpic_size']." ".$lang['kb'], preg_replace("/".$site_template->start."userpic_max_width".$site_template->end."/siU", $config['userpic_width'], preg_replace("/".$site_template->start."userpic_max_height".$site_template->end."/siU", $config['userpic_height'], $lang['userpic_upload']))),
"userpic_max_width" => $config['userpic_width'],
"userpic_max_height" => $config['userpic_height'],
"userpic_max_size" => $config['userpic_size']." ".$lang['kb'],
//End User Pic
"user_showemail_yes" => $user_showemail_yes,
"user_showemail_no" => $user_showemail_no,
"user_allowemails_yes" => $user_allowemails_yes,
"user_allowemails_no" => $user_allowemails_no,
"user_invisible_yes" => $user_invisible_yes,
"user_invisible_no" => $user_invisible_no,
"lang_profile_of" => $lang['profile_of'],
"lang_email" => $lang['email'],
"lang_email_confirm" => $lang['email_confirm'],
"lang_show_email" => $lang['show_email'],
"lang_allow_emails" => $lang['allow_emails'],
"lang_invisible" => $lang['invisible'],
"lang_optional_infos" => $lang['optional_infos'],
"lang_homepage" => $lang['homepage'],
"lang_icq" => $lang['icq'],
"lang_save" => $lang['save'],
"lang_reset" => $lang['reset'],
"lang_change_password" => $lang['change_password'],
"lang_old_password" => $lang['old_password'],
"lang_new_password" => $lang['new_password'],
"lang_new_password_confirm" => $lang['new_password_confirm'],
"lang_edit_profile_msg" => $edit_profile_msg,
"lang_yes" => $lang['yes'],
"lang_no" => $lang['no']
));
if (!empty($additional_user_fields)) {
$additional_field_array = array();
foreach ($additional_user_fields as $key => $val) {
if ($val[1] == "radio") {
$value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : intval($user_info[$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(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$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_editprofile");
if (!empty($new_email_msg)) {
$site_sess->logout($user_info['user_id']);
}
}
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";
$page_title = $config['category_separator'].$txt_clickstream; // MOD: Dynamic page title
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"content" => $content,
"msg" => $msg,
"clickstream" => $clickstream,
"page_title" => $page_title, // MOD: Dynamic page title
"lang_control_panel" => $lang['control_panel']
));
// MOD: Dynamic page title BLOCK BEGIN
//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
$header = $site_template->parse_template("header");
$footer = $site_template->parse_template("footer");
$site_template->register_vars(array(
"header" => $header,
"footer" => $footer
));
unset($header);
unset($footer);
}
// MOD: Dynamic page title BLOCK END
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
And here is my image_utils.php:
<?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 == 0 ? 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(1 => "gif", 2 => "jpeg", 3 => "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, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
}
else {
imagecopyresized($thumb, $image, 0, 0, 0, 0, $width, $height, ImageSX($image), ImageSY($image));
}
$image_handle = "image".$types[$image_info[2]];
$image_handle($thumb, $dest, $quality);
imagedestroy($image);
imagedestroy($thumb);
}
return (file_exists($dest)) ? 1 : 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)) ? 1 : 0;
}
function resize_image_netpbm($src, $dest, $quality, $width, $height, $image_info) {
global $convert_options;
$convert_path = $convert_options['convert_path'];
$types = array(1 => "gif", 2 => "jpeg", 3 => "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)) ? 1 : 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($dest, CHMOD_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($dest, CHMOD_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($file, CHMOD_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 = "mplayer -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 = "mplayer \"".$src."\" -ss ".$length." -nosound -vo jpeg:smooth=75 -vf scale=120:80 -frames 1 > imagegenoutput.txt";
system($command);
unlink("imagegenoutput.txt");
unlink("00000001.jpg");
rename("00000002.jpg",$dest);
return (file_exists($dest)) ? 1 : 0;
}
?>
You can see the command right above $command = "mplayer \"".$src."\" -ss ".$length." -nosound -vo jpeg:smooth=75 -vf scale=120:80 -frames 1 > imagegenoutput.txt";