mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-02 19:39:26 +01:00
- made UploadImage finally working
- integrated with egroupware using appsession vars - added max sizes when uploading - added this CHANGELOG - added the README for developer instructions - checked copyrights - changed icon
This commit is contained in:
parent
7a28a6bcd0
commit
80cd655e2c
9
phpgwapi/js/htmlarea/plugins/UploadImage/CHANGELOG
Normal file
9
phpgwapi/js/htmlarea/plugins/UploadImage/CHANGELOG
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Mon Sep 20 22:23:52 CEST 2004
|
||||||
|
-----------------------------
|
||||||
|
- made UploadImage finally working
|
||||||
|
- integrated with egroupware using appsession vars
|
||||||
|
- added max sizes when uploading
|
||||||
|
- added this CHANGELOG
|
||||||
|
- added the README for developer instructions
|
||||||
|
- checked copyrights
|
||||||
|
- changed icon
|
48
phpgwapi/js/htmlarea/plugins/UploadImage/README
Normal file
48
phpgwapi/js/htmlarea/plugins/UploadImage/README
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
UploadImage for HtmlArea in eGroupWare
|
||||||
|
-----------------------------------------------------------
|
||||||
|
Original Author: Xiang Wei ZHUO <wei@zhuo.org>
|
||||||
|
Author for eGW: Pim Snel <pim@lingewoud.nl>
|
||||||
|
Last Updated: Mon Sep 20 19:55:03 CEST 2004
|
||||||
|
Requirements: eGroupWare 1.x, htmlArea 3rc or higher
|
||||||
|
Note: UploadImage only works as plugin for htmlArea in eGroupWare.
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
UploadImage adds an image_upload-icon in the htmlArea-toolbar. When the icon is clicked
|
||||||
|
the user can Select an image from the Upload Directory or upload an Image to the directory
|
||||||
|
the upload directory eGW-developer has specified. After insertion the image is shown in the
|
||||||
|
htmlarea. Future features will be: resizing images, cropping images, rotating images etc ....
|
||||||
|
|
||||||
|
To use the plugin you have to do the following:
|
||||||
|
|
||||||
|
// thirst setup the sessionvariables UploadImage Need
|
||||||
|
$sessdata = array(
|
||||||
|
'UploadImageBaseDir' => /path/to/eg/egw/images , // absolute path to the base directory
|
||||||
|
'UploadImageBaseURL' => http://yourhost/egw/images, // the complete URL to the base images directory
|
||||||
|
'UploadImageMaxWidth' => 500, // max, image width in pixels
|
||||||
|
'UploadImageMaxHeight' => 500 // max. image height in pixels
|
||||||
|
);
|
||||||
|
|
||||||
|
$GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi',$sessdata);
|
||||||
|
|
||||||
|
|
||||||
|
// then init the html class and call the htmlarea class-method with the UploadPlugin as argument
|
||||||
|
if (!is_object($GLOBALS['phpgw']->html))
|
||||||
|
{
|
||||||
|
$GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
|
||||||
|
}
|
||||||
|
|
||||||
|
$htmlarea = $GLOBALS['phpgw']->html->htmlarea($field_name, $value,$style,false,'UploadImage',$custom_toolbar);
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SECURITY WARNING!!!
|
||||||
|
-----------------------------------------------------------
|
||||||
|
When you are implementing the UploadImage plugin make sure
|
||||||
|
your UploadImageBaseDir is set correctly because else it
|
||||||
|
might give access to other directories apache has access to.
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
Known issues:
|
||||||
|
- Create directory doesn't work
|
||||||
|
- In some cases the OK and cancel buttons won't work anymore (javascript issue)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 181 B |
BIN
phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.xcf
Normal file
BIN
phpgwapi/js/htmlarea/plugins/UploadImage/img/up_image.xcf
Normal file
Binary file not shown.
@ -1,64 +1,87 @@
|
|||||||
<?
|
<?php
|
||||||
|
/**************************************************************************\
|
||||||
|
* eGroupWare - UploadImage-plugin for htmlArea *
|
||||||
|
* http://www.eGroupWare.org *
|
||||||
|
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
|
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
||||||
|
* -------------------------------------------- *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the *
|
||||||
|
* Free Software Foundation; version 2 of the License. *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
//************************** BEGIN CONFIGURATION *****************************//
|
/* $id$ */
|
||||||
|
|
||||||
//example, this is the actual file system path
|
// FIXME: remove imageMagick shit, we only use gdlib
|
||||||
//of the web server document root. e.g.
|
// FIXME: autodetect safe_mode
|
||||||
// Filesystem == /home/web/www.yourdomain.com
|
// FIXME set current app to the calling app
|
||||||
$BASE_DIR = $GLOBALS[UploadImageBaseDir];
|
// FIXME include header nicer
|
||||||
$BASE_URL = $GLOBALS[UploadImageBaseURL];
|
|
||||||
$BASE_ROOT = $GLOBALS[UploadImageRelativePath];
|
|
||||||
|
|
||||||
var_dump($BASE_DIR);
|
$phpgw_flags = Array(
|
||||||
var_dump($BASE_URL);
|
'currentapp' => 'jinn',
|
||||||
var_dump($BASE_ROOT);
|
'noheader' => True,
|
||||||
|
'nonavbar' => True,
|
||||||
|
'noappheader' => True,
|
||||||
|
'noappfooter' => True,
|
||||||
|
'nofooter' => True
|
||||||
|
);
|
||||||
|
|
||||||
//$BASE_DIR = $_SERVER['DOCUMENT_ROOT'];
|
$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
|
||||||
//$BASE_DIR = '/home/www';
|
|
||||||
|
|
||||||
//the path where the browser sees the document root (i.e. http://www.yourdomain.com/)
|
if(@include('../../../../../../header.inc.php'))
|
||||||
//$BASE_URL = 'https://192.168.0.2/';
|
{
|
||||||
|
// I know this is very ugly
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@include('../../../../../../../header.inc.php');
|
||||||
|
}
|
||||||
|
|
||||||
//this is where the images will be stored relative to the $BASE_DIR (and $BASE_URL)
|
define('IMAGE_CLASS', 'GD');
|
||||||
//this directory MUST be readable AND writable by the web server.
|
|
||||||
//$BASE_ROOT = '';
|
|
||||||
|
|
||||||
//The image manipulation library to use, either GD or ImageMagick or NetPBM
|
//In safe mode, directory creation is not permitted.
|
||||||
//valid definitions are 'GD' or 'IM' or 'NetPBM'.
|
$SAFE_MODE = false;
|
||||||
define('IMAGE_CLASS', 'GD'); //
|
|
||||||
|
|
||||||
//After defining which library to use, if it is NetPBM or IM, you need to
|
$sessdata = $GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi');
|
||||||
//specify where the binary for the selected library are. And of course
|
|
||||||
//your server and PHP must be able to execute them (i.e. safe mode is OFF).
|
$BASE_DIR = $sessdata[UploadImageBaseDir];
|
||||||
//If you have safe mode ON, or don't have the binaries, your choice is
|
$BASE_URL = $sessdata[UploadImageBaseURL];
|
||||||
//GD only. GD does not require the following definition.
|
$MAX_HEIGHT = $sessdata[UploadImageMaxHeight];
|
||||||
define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/');
|
$MAX_WIDTH = $sessdata[UploadImageMaxWidth];
|
||||||
//define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\');
|
|
||||||
|
if(!$MAX_HEIGHT) $MAX_HEIGHT = 10000;
|
||||||
|
if(!$MAX_WIDTH) $MAX_WIDTH = 10000;
|
||||||
|
// _debug_array($sessdata);
|
||||||
|
//die();
|
||||||
|
|
||||||
|
|
||||||
//In safe mode, directory creation is not permitted.
|
//After defining which library to use, if it is NetPBM or IM, you need to
|
||||||
$SAFE_MODE = false;
|
//specify where the binary for the selected library are. And of course
|
||||||
|
//your server and PHP must be able to execute them (i.e. safe mode is OFF).
|
||||||
|
//If you have safe mode ON, or don't have the binaries, your choice is
|
||||||
|
//GD only. GD does not require the following definition.
|
||||||
|
//define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/');
|
||||||
|
//define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\');
|
||||||
|
|
||||||
//************************** END CONFIGURATION *****************************//
|
$BASE_ROOT = '';
|
||||||
|
$IMG_ROOT = $BASE_ROOT;
|
||||||
|
|
||||||
$IMG_ROOT = $BASE_ROOT;
|
if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1)
|
||||||
|
|
||||||
if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1)
|
|
||||||
$BASE_DIR .= '/';
|
$BASE_DIR .= '/';
|
||||||
|
|
||||||
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
|
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
|
||||||
$BASE_URL .= '/';
|
$BASE_URL .= '/';
|
||||||
|
|
||||||
//Built in function of dirname is faulty
|
//Built in function of dirname is faulty
|
||||||
//It assumes that the directory nane can not contain a . (period)
|
//It assumes that the directory nane can not contain a . (period)
|
||||||
function dir_name($dir)
|
function dir_name($dir)
|
||||||
{
|
{
|
||||||
$lastSlash = intval(strrpos($dir, '/'));
|
$lastSlash = intval(strrpos($dir, '/'));
|
||||||
if($lastSlash == strlen($dir)-1){
|
if($lastSlash == strlen($dir)-1){
|
||||||
return substr($dir, 0, $lastSlash);
|
return substr($dir, 0, $lastSlash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return dirname($dir);
|
return dirname($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,23 +1,36 @@
|
|||||||
<?
|
<?php
|
||||||
/***********************************************************************
|
/**************************************************************************\
|
||||||
** Title.........: Image Manager, draws the thumbnails and directies
|
* eGroupWare - UploadImage-plugin for htmlArea *
|
||||||
** Version.......: 1.01
|
* http://www.eGroupWare.org *
|
||||||
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
|
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
** Filename......: images.php
|
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
||||||
** Last changed..: 8 Mar 2003
|
* -------------------------------------------- *
|
||||||
** Notes.........: Configuration in config.inc.php
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the *
|
||||||
|
* Free Software Foundation; version 2 of the License. *
|
||||||
|
* -------------------------------------------- *
|
||||||
|
* Title.........: Image Manager, draws the thumbnails and directies *
|
||||||
|
* Version.......: 1.01 *
|
||||||
|
* Author........: Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
|
* Notes.........: Configuration in config.inc.php *
|
||||||
|
* *
|
||||||
|
* Functions *
|
||||||
|
* - create a new folder, *
|
||||||
|
* - delete folder, *
|
||||||
|
* - upload new image *
|
||||||
|
* - use cached thumbnail views *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
Functions
|
/* $id */
|
||||||
- create a new folder,
|
|
||||||
- delete folder,
|
|
||||||
- upload new image
|
|
||||||
- use cached thumbnail views
|
|
||||||
|
|
||||||
***********************************************************************/
|
// FIXME move all php functions to a main file
|
||||||
|
// FIXME better directory-structure
|
||||||
|
|
||||||
include 'config.inc.php';
|
include 'config.inc.php';
|
||||||
|
require_once 'std_functions.inc.php';
|
||||||
|
require_once '../ImageEditor/Transform.php';
|
||||||
|
|
||||||
if(isset($_GET['dir'])) {
|
if(isset($_GET['dir'])) {
|
||||||
$dirParam = $_GET['dir'];
|
$dirParam = $_GET['dir'];
|
||||||
|
|
||||||
if(strlen($dirParam) > 0)
|
if(strlen($dirParam) > 0)
|
||||||
@ -27,33 +40,31 @@ if(isset($_GET['dir'])) {
|
|||||||
else
|
else
|
||||||
$IMG_ROOT = $dirParam;
|
$IMG_ROOT = $dirParam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$refresh_dirs = false;
|
$refresh_dirs = false;
|
||||||
$clearUploads = false;
|
$clearUploads = false;
|
||||||
|
|
||||||
if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1)
|
if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1)
|
||||||
$IMG_ROOT .= '/';
|
$IMG_ROOT .= '/';
|
||||||
|
|
||||||
|
if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false)
|
||||||
if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false)
|
{
|
||||||
{
|
|
||||||
create_folder();
|
create_folder();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['delFile']) && isset($_GET['dir']))
|
if(isset($_GET['delFile']) && isset($_GET['dir']))
|
||||||
{
|
{
|
||||||
delete_file($_GET['delFile']);
|
delete_file($_GET['delFile']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['delFolder']) && isset($_GET['dir']))
|
if(isset($_GET['delFolder']) && isset($_GET['dir']))
|
||||||
{
|
{
|
||||||
delete_folder($_GET['delFolder']);
|
delete_folder($_GET['delFolder']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath']))
|
|
||||||
{
|
|
||||||
|
|
||||||
|
if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirPath']))
|
||||||
|
{
|
||||||
$dirPathPost = $_POST['dirPath'];
|
$dirPathPost = $_POST['dirPath'];
|
||||||
|
|
||||||
if(strlen($dirPathPost) > 0)
|
if(strlen($dirPathPost) > 0)
|
||||||
@ -67,40 +78,87 @@ if(isset($_FILES['upload']) && is_array($_FILES['upload']) && isset($_POST['dirP
|
|||||||
if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1)
|
if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1)
|
||||||
$IMG_ROOT .= '/';
|
$IMG_ROOT .= '/';
|
||||||
|
|
||||||
do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/');
|
// do_upload($_FILES['upload'], $BASE_DIR.$BASE_ROOT.$dirPathPost.'/');
|
||||||
}
|
do_upload($_FILES['upload'], $BASE_DIR.$dirPathPost.'/');
|
||||||
|
}
|
||||||
|
|
||||||
function do_upload($file, $dest_dir)
|
function do_upload($file, $dest_dir)
|
||||||
{
|
{
|
||||||
global $clearUploads;
|
global $clearUploads,$MAX_WIDTH,$MAX_HEIGHT;
|
||||||
|
|
||||||
if(is_file($file['tmp_name']))
|
if(is_file($file['tmp_name']))
|
||||||
{
|
{
|
||||||
//var_dump($file); echo "DIR:$dest_dir";
|
$img_info = getimagesize($file['tmp_name']);
|
||||||
|
|
||||||
|
//_debug_array($img_info);
|
||||||
|
|
||||||
|
if(is_array($img_info))
|
||||||
|
{
|
||||||
|
$w = $img_info[0];
|
||||||
|
$h = $img_info[1];
|
||||||
|
|
||||||
|
if( $w > $MAX_WIDTH || $h > $MAX_HEIGHT )
|
||||||
|
{
|
||||||
|
adapt_size($file['tmp_name'],$dest_dir.$file['name']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']);
|
move_uploaded_file($file['tmp_name'], $dest_dir.$file['name']);
|
||||||
|
}
|
||||||
chmod($dest_dir.$file['name'], 0666);
|
chmod($dest_dir.$file['name'], 0666);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$clearUploads = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function adapt_size($img,$dest_file)
|
||||||
|
{
|
||||||
|
global $BASE_DIR, $BASE_URL,$MAX_WIDTH,$MAX_HEIGHT;
|
||||||
|
|
||||||
|
$path_info = pathinfo($img);
|
||||||
|
$path = $path_info['dirname']."/";
|
||||||
|
$img_file = $path_info['basename'];
|
||||||
|
|
||||||
|
$img_info = getimagesize($path.$img_file);
|
||||||
|
$w = $img_info[0]; $h = $img_info[1];
|
||||||
|
|
||||||
|
$nw = $MAX_WIDTH; $nh = $MAX_HEIGHT;
|
||||||
|
|
||||||
|
$img_resize = Image_Transform::factory(IMAGE_CLASS);
|
||||||
|
$img_resize->load($path.$img_file);
|
||||||
|
|
||||||
|
if ($w > $h)
|
||||||
|
$nh = unpercent(percent($nw, $w), $h);
|
||||||
|
else if ($h > $w)
|
||||||
|
$nw = unpercent(percent($nh, $h), $w);
|
||||||
|
|
||||||
|
$img_resize->resize($nw, $nh);
|
||||||
|
|
||||||
|
$img_resize->save($dest_file);
|
||||||
|
$img_resize->free();
|
||||||
|
|
||||||
|
chmod($dest_file, 0666);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$clearUploads = true;
|
function delete_folder($folder)
|
||||||
}
|
{
|
||||||
|
|
||||||
function delete_folder($folder)
|
|
||||||
{
|
|
||||||
global $BASE_DIR, $refresh_dirs;
|
global $BASE_DIR, $refresh_dirs;
|
||||||
//var_dump($BASE_DIR);
|
|
||||||
$del_folder = dir_name($BASE_DIR).$folder;
|
$del_folder = dir_name($BASE_DIR).$folder;
|
||||||
//echo $del_folder;
|
|
||||||
if(is_dir($del_folder) && num_files($del_folder) <= 0) {
|
if(is_dir($del_folder) && num_files($del_folder) <= 0)
|
||||||
//echo $del_folder.'<br>';
|
{
|
||||||
rm_all_dir($del_folder);
|
rm_all_dir($del_folder);
|
||||||
$refresh_dirs = true;
|
$refresh_dirs = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function rm_all_dir($dir)
|
function rm_all_dir($dir)
|
||||||
{
|
{
|
||||||
//$dir = dir_name($dir);
|
//$dir = dir_name($dir);
|
||||||
//echo "OPEN:".$dir.'<Br>';
|
//echo "OPEN:".$dir.'<Br>';
|
||||||
if(is_dir($dir))
|
if(is_dir($dir))
|
||||||
@ -129,27 +187,28 @@ function rm_all_dir($dir)
|
|||||||
rmdir($dir);
|
rmdir($dir);
|
||||||
}
|
}
|
||||||
//echo "RM: $dir <br>";
|
//echo "RM: $dir <br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_file($file)
|
function delete_file($file)
|
||||||
{
|
{
|
||||||
global $BASE_DIR;
|
global $BASE_DIR,$IMG_ROOT;
|
||||||
|
|
||||||
$del_image = dir_name($BASE_DIR).$file;
|
$del_image = dir_name($BASE_DIR).$IMG_ROOT.$file;
|
||||||
|
$del_thumb = dir_name($BASE_DIR).$IMG_ROOT.$file;
|
||||||
|
|
||||||
$del_thumb = dir_name($del_image).'.'.basename($del_image);
|
if(is_file($del_image))
|
||||||
|
{
|
||||||
if(is_file($del_image)) {
|
|
||||||
unlink($del_image);
|
unlink($del_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_file($del_thumb)) {
|
if(is_file($del_thumb))
|
||||||
|
{
|
||||||
unlink($del_thumb);
|
unlink($del_thumb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_folder()
|
function create_folder()
|
||||||
{
|
{
|
||||||
global $BASE_DIR, $IMG_ROOT, $refresh_dirs;
|
global $BASE_DIR, $IMG_ROOT, $refresh_dirs;
|
||||||
|
|
||||||
$folder_name = $_GET['foldername'];
|
$folder_name = $_GET['foldername'];
|
||||||
@ -165,10 +224,10 @@ function create_folder()
|
|||||||
$refresh_dirs = true;
|
$refresh_dirs = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_files($dir)
|
function num_files($dir)
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
||||||
if(is_dir($dir))
|
if(is_dir($dir))
|
||||||
@ -185,10 +244,10 @@ function num_files($dir)
|
|||||||
$d->close();
|
$d->close();
|
||||||
}
|
}
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dirs($dir,$abs_path)
|
function dirs($dir,$abs_path)
|
||||||
{
|
{
|
||||||
$d = dir($dir);
|
$d = dir($dir);
|
||||||
//echo "Handle: ".$d->handle."<br>\n";
|
//echo "Handle: ".$d->handle."<br>\n";
|
||||||
//echo "Path: ".$d->path."<br>\n";
|
//echo "Path: ".$d->path."<br>\n";
|
||||||
@ -214,10 +273,10 @@ function dirs($dir,$abs_path)
|
|||||||
dirs($dirs[$name]['path'],$current_dir);
|
dirs($dirs[$name]['path'],$current_dir);
|
||||||
next($dirs);
|
next($dirs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_size($size)
|
function parse_size($size)
|
||||||
{
|
{
|
||||||
if($size < 1024)
|
if($size < 1024)
|
||||||
return $size.' btyes';
|
return $size.' btyes';
|
||||||
else if($size >= 1024 && $size < 1024*1024)
|
else if($size >= 1024 && $size < 1024*1024)
|
||||||
@ -228,10 +287,10 @@ function parse_size($size)
|
|||||||
{
|
{
|
||||||
return sprintf('%01.2f',$size/(1024.0*1024)).' Mb';
|
return sprintf('%01.2f',$size/(1024.0*1024)).' Mb';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_image($img, $file, $info, $size)
|
function show_image($img, $file, $info, $size)
|
||||||
{
|
{
|
||||||
global $BASE_DIR, $BASE_URL, $newPath;
|
global $BASE_DIR, $BASE_URL, $newPath;
|
||||||
|
|
||||||
$img_path = dir_name($img);
|
$img_path = dir_name($img);
|
||||||
@ -243,9 +302,9 @@ function show_image($img, $file, $info, $size)
|
|||||||
|
|
||||||
$filesize = parse_size($size);
|
$filesize = parse_size($size);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<td>
|
<td>
|
||||||
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
|
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
|
||||||
<a href="javascript:;" onClick="javascript:imageSelected('<? echo $img_url; ?>', <? echo $info[0];?>, <? echo $info[1]; ?>,'<? echo $file; ?>');"><img src="<? echo $thumb_image; ?>" alt="<? echo $file; ?> - <? echo $filesize; ?>" border="0"></a></td>
|
<a href="javascript:;" onClick="javascript:imageSelected('<? echo $img_url; ?>', <? echo $info[0];?>, <? echo $info[1]; ?>,'<? echo $file; ?>');"><img src="<? echo $thumb_image; ?>" alt="<? echo $file; ?> - <? echo $filesize; ?>" border="0"></a></td>
|
||||||
@ -256,14 +315,14 @@ function show_image($img, $file, $info, $size)
|
|||||||
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
|
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
|
||||||
<a href="javascript:;" onClick="javascript:preview('<? echo $img_url; ?>', '<? echo $file; ?>', ' <? echo $filesize; ?>',<? echo $info[0].','.$info[1]; ?>);"><img src="edit_pencil.gif" width="15" height="15" border="0"></a></td>
|
<a href="javascript:;" onClick="javascript:preview('<? echo $img_url; ?>', '<? echo $file; ?>', ' <? echo $filesize; ?>',<? echo $info[0].','.$info[1]; ?>);"><img src="edit_pencil.gif" width="15" height="15" border="0"></a></td>
|
||||||
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
|
<td width="1%" class="buttonOut" onMouseOver="pviiClassNew(this,'buttonHover')" onMouseOut="pviiClassNew(this,'buttonOut')">
|
||||||
<a href="images.php?delFile=<? echo $img_url; ?>&dir=<? echo $newPath; ?>" onClick="return deleteImage('<? echo $file; ?>');"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
|
<a href="images.php?delFile=<? echo $file; ?>&dir=<? echo $newPath; ?>" onClick="return deleteImage('<? echo $file; ?>');"><img src="edit_trash.gif" width="15" height="15" border="0"></a></td>
|
||||||
<td width="98%" class="imgCaption"><? echo $info[0].'x'.$info[1]; ?></td>
|
<td width="98%" class="imgCaption"><? echo $info[0].'x'.$info[1]; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<?
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_dir($path, $dir)
|
function show_dir($path, $dir)
|
||||||
@ -273,7 +332,7 @@ function show_dir($path, $dir)
|
|||||||
$num_files = num_files($BASE_DIR.$path);
|
$num_files = num_files($BASE_DIR.$path);
|
||||||
?>
|
?>
|
||||||
<td>
|
<td>
|
||||||
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
|
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
|
||||||
<a href="images.php?dir=<? echo $path; ?>" onClick="changeLoadingStatus('load')">
|
<a href="images.php?dir=<? echo $path; ?>" onClick="changeLoadingStatus('load')">
|
||||||
@ -290,7 +349,7 @@ function show_dir($path, $dir)
|
|||||||
</tr>
|
</tr>
|
||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
@ -308,11 +367,11 @@ function draw_no_results()
|
|||||||
|
|
||||||
function draw_no_dir()
|
function draw_no_dir()
|
||||||
{
|
{
|
||||||
global $BASE_DIR, $BASE_ROOT;
|
global $BASE_DIR;
|
||||||
?>
|
?>
|
||||||
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
|
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;">Configuration Problem: "<? echo $BASE_DIR.$BASE_ROOT; ?>" does not exist.</div></td>
|
<td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;">Configuration Problem: "<? echo $BASE_DIR; ?>" does not exist.</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?
|
<?
|
||||||
@ -323,61 +382,62 @@ function draw_table_header()
|
|||||||
{
|
{
|
||||||
echo '<table border="0" cellpadding="0" cellspacing="2">';
|
echo '<table border="0" cellpadding="0" cellspacing="2">';
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw_table_footer()
|
function draw_table_footer()
|
||||||
{
|
{
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Image Browser</title>
|
<title>Image Browser</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
<!--
|
<!--
|
||||||
.imgBorder {
|
.imgBorder {
|
||||||
height: 96px;
|
height: 96px;
|
||||||
border: 1px solid threedface;
|
border: 1px solid threedface;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
.imgBorderHover {
|
.imgBorderHover {
|
||||||
height: 96px;
|
height: 96px;
|
||||||
border: 1px solid threedface;
|
border: 1px solid threedface;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
background: #FFFFCC;
|
background: #FFFFCC;
|
||||||
cursor: hand;
|
cursor: hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonHover {
|
.buttonHover {
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
|
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
|
||||||
cursor: hand;
|
cursor: hand;
|
||||||
background: #FFFFCC;
|
background: #FFFFCC;
|
||||||
}
|
}
|
||||||
.buttonOut
|
.buttonOut
|
||||||
{
|
{
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
border-color: white;
|
border-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.imgCaption {
|
.imgCaption {
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
font-family: "MS Shell Dlg", Helvetica, sans-serif;
|
font-family: "MS Shell Dlg", Helvetica, sans-serif;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.dirField {
|
.dirField {
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
font-family: "MS Shell Dlg", Helvetica, sans-serif;
|
font-family: "MS Shell Dlg", Helvetica, sans-serif;
|
||||||
width:110px;
|
width:110px;
|
||||||
}
|
}
|
||||||
|
|
||||||
-->
|
-->
|
||||||
</style>
|
</style>
|
||||||
<?
|
<?php
|
||||||
$dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT);
|
// $dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT);
|
||||||
|
$dirPath=$IMG_ROOT;
|
||||||
|
|
||||||
$paths = explode('/', $dirPath);
|
$paths = explode('/', $dirPath);
|
||||||
$upDirPath = '/';
|
$upDirPath = '/';
|
||||||
@ -396,33 +456,34 @@ function draw_table_footer()
|
|||||||
{
|
{
|
||||||
$newPath = substr($dirPath, 0,$slashIndex-1);
|
$newPath = substr($dirPath, 0,$slashIndex-1);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="../popup.js"></script>
|
<script type="text/javascript" src="../popup.js"></script>
|
||||||
<script type="text/javascript" src="../../../../dialog.js"></script>
|
<script type="text/javascript" src="../../../../dialog.js"></script>
|
||||||
<script language="JavaScript" type="text/JavaScript">
|
<script language="JavaScript" type="text/JavaScript">
|
||||||
<!--
|
<!--
|
||||||
function pviiClassNew(obj, new_style) { //v2.6 by PVII
|
function pviiClassNew(obj, new_style) { //v2.6 by PVII
|
||||||
obj.className=new_style;
|
obj.className=new_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
function goUp()
|
function goUp()
|
||||||
{
|
{
|
||||||
location.href = "ImageManager/images.php?dir=<? echo $upDirPath; ?>";
|
location.href = "ImageManager/images.php?dir=<? echo $upDirPath; ?>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDir(newDir)
|
function changeDir(newDir)
|
||||||
{
|
{
|
||||||
location.href = "ImageManager/images.php?dir="+newDir;
|
location.href = "ImageManager/images.php?dir="+newDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newFolder(oldDir, newFolder)
|
function newFolder(oldDir, newFolder)
|
||||||
{
|
{
|
||||||
location.href = "ImageManager/images.php?dir="+oldDir+'&create=folder&foldername='+newFolder;
|
location.href = "ImageManager/images.php?dir="+oldDir+'&create=folder&foldername='+newFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDir()
|
function updateDir()
|
||||||
{
|
{
|
||||||
var newPath = "<? echo $newPath; ?>";
|
var newPath = "<?php echo $newPath; ?>";
|
||||||
|
// alert('<?php echo $newPath; ?>');
|
||||||
if(window.top.document.forms[0] != null) {
|
if(window.top.document.forms[0] != null) {
|
||||||
|
|
||||||
var allPaths = window.top.document.forms[0].dirPath.options;
|
var allPaths = window.top.document.forms[0].dirPath.options;
|
||||||
@ -437,15 +498,15 @@ function updateDir()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<?
|
<?
|
||||||
if($clearUploads) {
|
if($clearUploads) {
|
||||||
?>
|
?>
|
||||||
var topDoc = window.top.document.forms[0];
|
var topDoc = window.top.document.forms[0];
|
||||||
topDoc.upload.value = null;
|
topDoc.upload.value = null;
|
||||||
//topDoc.upload.disabled = true;
|
//topDoc.upload.disabled = true;
|
||||||
<?
|
<?
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +516,7 @@ function updateDir()
|
|||||||
function refreshDirs()
|
function refreshDirs()
|
||||||
{
|
{
|
||||||
var allPaths = window.top.document.forms[0].dirPath.options;
|
var allPaths = window.top.document.forms[0].dirPath.options;
|
||||||
var fields = ["/" <? dirs($BASE_DIR.$BASE_ROOT,'');?>];
|
var fields = ["/" <? dirs($BASE_DIR,'');?>];
|
||||||
|
|
||||||
var newPath = "<? echo $newPath; ?>";
|
var newPath = "<? echo $newPath; ?>";
|
||||||
|
|
||||||
@ -481,12 +542,12 @@ function refreshDirs()
|
|||||||
|
|
||||||
allPaths.add(newElem);
|
allPaths.add(newElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshDirs();
|
refreshDirs();
|
||||||
<? } ?>
|
<? } ?>
|
||||||
|
|
||||||
function imageSelected(filename, width, height, alt)
|
function imageSelected(filename, width, height, alt)
|
||||||
{
|
{
|
||||||
var topDoc = window.top.document.forms[0];
|
var topDoc = window.top.document.forms[0];
|
||||||
topDoc.f_url.value = filename;
|
topDoc.f_url.value = filename;
|
||||||
topDoc.f_width.value= width;
|
topDoc.f_width.value= width;
|
||||||
@ -495,10 +556,16 @@ function imageSelected(filename, width, height, alt)
|
|||||||
topDoc.orginal_width.value = width;
|
topDoc.orginal_width.value = width;
|
||||||
topDoc.orginal_height.value = height;
|
topDoc.orginal_height.value = height;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function preview(file, image, size, width, height)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
alert('Not implemented yet,sorry');
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
function preview(file, image, size, width, height)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
var predoc = '<img src="'+file+'" alt="'+image+' ('+width+'x'+height+', '+size+')">';
|
var predoc = '<img src="'+file+'" alt="'+image+' ('+width+'x'+height+', '+size+')">';
|
||||||
var w = 450;
|
var w = 450;
|
||||||
@ -522,18 +589,18 @@ function preview(file, image, size, width, height)
|
|||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteImage(file)
|
function deleteImage(file)
|
||||||
{
|
{
|
||||||
if(confirm("Delete image \""+file+"\"?"))
|
if(confirm("Delete image \""+file+"\"?"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFolder(folder, numFiles)
|
function deleteFolder(folder, numFiles)
|
||||||
{
|
{
|
||||||
if(numFiles > 0) {
|
if(numFiles > 0) {
|
||||||
alert("There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first.");
|
alert("There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first.");
|
||||||
return false;
|
return false;
|
||||||
@ -543,25 +610,25 @@ function deleteFolder(folder, numFiles)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MM_findObj(n, d) { //v4.01
|
function MM_findObj(n, d) { //v4.01
|
||||||
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
|
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
|
||||||
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
|
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
|
||||||
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
|
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
|
||||||
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
|
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
|
||||||
if(!x && d.getElementById) x=d.getElementById(n); return x;
|
if(!x && d.getElementById) x=d.getElementById(n); return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MM_showHideLayers() { //v6.0
|
function MM_showHideLayers() { //v6.0
|
||||||
var i,p,v,obj,args=MM_showHideLayers.arguments;
|
var i,p,v,obj,args=MM_showHideLayers.arguments;
|
||||||
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2];
|
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i],window.top.document))!=null) { v=args[i+2];
|
||||||
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
|
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
|
||||||
obj.visibility=v; }
|
obj.visibility=v; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeLoadingStatus(state)
|
function changeLoadingStatus(state)
|
||||||
{
|
{
|
||||||
var statusText = null;
|
var statusText = null;
|
||||||
if(state == 'load') {
|
if(state == 'load') {
|
||||||
statusText = 'Loading Images';
|
statusText = 'Loading Images';
|
||||||
@ -576,21 +643,21 @@ function changeLoadingStatus(state)
|
|||||||
obj.innerHTML = statusText;
|
obj.innerHTML = statusText;
|
||||||
MM_showHideLayers('loading','','show')
|
MM_showHideLayers('loading','','show')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onLoad="updateDir();" bgcolor="#FFFFFF">
|
<body onLoad="updateDir();" bgcolor="#FFFFFF">
|
||||||
|
|
||||||
<?
|
<?
|
||||||
//var_dump($_GET);
|
//var_dump($_GET);
|
||||||
//echo $dirParam.':'.$upDirPath;
|
//echo $dirParam.':'.$upDirPath;
|
||||||
//echo '<br>';
|
//echo '<br>';
|
||||||
$d = @dir($BASE_DIR.$IMG_ROOT);
|
$d = @dir($BASE_DIR.$IMG_ROOT);
|
||||||
|
|
||||||
if($d)
|
if($d)
|
||||||
{
|
{
|
||||||
//var_dump($d);
|
//var_dump($d);
|
||||||
$images = array();
|
$images = array();
|
||||||
$folders = array();
|
$folders = array();
|
||||||
@ -644,15 +711,15 @@ if($d)
|
|||||||
{
|
{
|
||||||
draw_no_results();
|
draw_no_results();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_no_dir();
|
draw_no_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script language="JavaScript" type="text/JavaScript">
|
<script language="JavaScript" type="text/JavaScript">
|
||||||
MM_showHideLayers('loading','','hide')
|
MM_showHideLayers('loading','','hide')
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**************************************************************************\
|
||||||
|
* eGroupWare - UploadImage-plugin for htmlArea *
|
||||||
|
* http://www.eGroupWare.org *
|
||||||
|
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
|
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
||||||
|
* -------------------------------------------- *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the *
|
||||||
|
* Free Software Foundation; version 2 of the License. *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
|
function percent($p, $w)
|
||||||
|
{
|
||||||
|
return (real)(100 * ($p / $w));
|
||||||
|
}
|
||||||
|
|
||||||
|
function unpercent($percent, $whole)
|
||||||
|
{
|
||||||
|
return (real)(($percent * $whole) / 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -1,33 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
/***********************************************************************
|
/**************************************************************************\
|
||||||
** Title.........: Thumbnail generator, with cache.
|
* eGroupWare - UploadImage-plugin for htmlArea *
|
||||||
** Version.......: 1.0
|
* http://www.eGroupWare.org *
|
||||||
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
|
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
** Filename......: thumbs.php
|
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
||||||
** Last changed..: 1 Mar 2003
|
* -------------------------------------------- *
|
||||||
** Notes.........: Configuration in config.inc.php
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms of the GNU General Public License as published by the *
|
||||||
|
* Free Software Foundation; version 2 of the License. *
|
||||||
|
* -------------------------------------------- *
|
||||||
|
* Title.........: Thumbnail generator, with cache. *
|
||||||
|
* Version.......: 1.01 *
|
||||||
|
* Author........: Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
|
* Notes.........: Configuration in config.inc.php *
|
||||||
|
* *
|
||||||
|
* Functions *
|
||||||
|
* - if the thumbnail does not exists or the source file is newer, create a *
|
||||||
|
* new thumbnail. *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
- if the thumbnail does not exists or the source
|
/* $id */
|
||||||
file is newer, create a new thumbnail.
|
|
||||||
|
|
||||||
***********************************************************************/
|
require_once 'config.inc.php';
|
||||||
|
require_once 'std_functions.inc.php';
|
||||||
|
require_once '../ImageEditor/Transform.php';
|
||||||
|
|
||||||
|
$img = $BASE_DIR.urldecode($_GET['img']);
|
||||||
|
|
||||||
include 'config.inc.php';
|
if(is_file($img)) {
|
||||||
require_once '../ImageEditor/Transform.php';
|
|
||||||
|
|
||||||
$img = $BASE_DIR.urldecode($_GET['img']);
|
|
||||||
|
|
||||||
if(is_file($img)) {
|
|
||||||
make_thumbs(urldecode($_GET['img']));
|
make_thumbs(urldecode($_GET['img']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function make_thumbs($img)
|
||||||
function make_thumbs($img)
|
{
|
||||||
{
|
|
||||||
global $BASE_DIR, $BASE_URL;
|
global $BASE_DIR, $BASE_URL;
|
||||||
|
|
||||||
|
|
||||||
$path_info = pathinfo($img);
|
$path_info = pathinfo($img);
|
||||||
$path = $path_info['dirname']."/";
|
$path = $path_info['dirname']."/";
|
||||||
$img_file = $path_info['basename'];
|
$img_file = $path_info['basename'];
|
||||||
@ -59,7 +66,6 @@ function make_thumbs($img)
|
|||||||
$img_thumbs = Image_Transform::factory(IMAGE_CLASS);
|
$img_thumbs = Image_Transform::factory(IMAGE_CLASS);
|
||||||
$img_thumbs->load($BASE_DIR.$path.$img_file);
|
$img_thumbs->load($BASE_DIR.$path.$img_file);
|
||||||
|
|
||||||
|
|
||||||
if ($w > $h)
|
if ($w > $h)
|
||||||
$nh = unpercent(percent($nw, $w), $h);
|
$nh = unpercent(percent($nw, $w), $h);
|
||||||
else if ($h > $w)
|
else if ($h > $w)
|
||||||
@ -73,19 +79,9 @@ function make_thumbs($img)
|
|||||||
chmod($BASE_DIR.$thumb, 0666);
|
chmod($BASE_DIR.$thumb, 0666);
|
||||||
|
|
||||||
if(is_file($BASE_DIR.$thumb)) {
|
if(is_file($BASE_DIR.$thumb)) {
|
||||||
//echo "Made:".$BASE_URL.$path.'.'.$img_file;
|
|
||||||
header('Location: '.$BASE_URL.$path.'.'.$img_file);
|
header('Location: '.$BASE_URL.$path.'.'.$img_file);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
function percent($p, $w)
|
|
||||||
{
|
|
||||||
return (real)(100 * ($p / $w));
|
|
||||||
}
|
|
||||||
|
|
||||||
function unpercent($percent, $whole)
|
|
||||||
{
|
|
||||||
return (real)(($percent * $whole) / 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -7,15 +7,49 @@
|
|||||||
** Last changed..: 8 Mar 2003
|
** Last changed..: 8 Mar 2003
|
||||||
** Notes.........: Configuration in config.inc.php
|
** Notes.........: Configuration in config.inc.php
|
||||||
|
|
||||||
- Only compatible with IE 5.5+
|
- FIXME Only compatible with IE 5.5+
|
||||||
|
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
/* $id */
|
||||||
|
|
||||||
include 'ImageManager/config.inc.php';
|
include 'ImageManager/config.inc.php';
|
||||||
$no_dir = false;
|
$no_dir = false;
|
||||||
if(!is_dir($BASE_DIR.$BASE_ROOT)) {
|
if(!is_dir($BASE_DIR)) {
|
||||||
$no_dir = true;
|
$no_dir = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// _debug_array($_GET);
|
||||||
|
// die();
|
||||||
|
function dirs($dir,$abs_path)
|
||||||
|
{
|
||||||
|
$d = dir($dir);
|
||||||
|
$dirs = array();
|
||||||
|
while (false !== ($entry = $d->read()))
|
||||||
|
{
|
||||||
|
if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.')
|
||||||
|
{
|
||||||
|
$path['path'] = $dir.'/'.$entry;
|
||||||
|
$path['name'] = $entry;
|
||||||
|
$dirs[$entry] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$d->close();
|
||||||
|
|
||||||
|
ksort($dirs);
|
||||||
|
for($i=0; $i<count($dirs); $i++)
|
||||||
|
{
|
||||||
|
$name = key($dirs);
|
||||||
|
$current_dir = $abs_path.'/'.$dirs[$name]['name'];
|
||||||
|
echo "<option value=\"$current_dir\">$current_dir</option>\n";
|
||||||
|
dirs($dirs[$name]['path'],$current_dir);
|
||||||
|
next($dirs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html style="width: 580; height: 440;">
|
<html style="width: 580; height: 440;">
|
||||||
<head>
|
<head>
|
||||||
@ -326,36 +360,10 @@ function toggleConstrains(constrains)
|
|||||||
<td>
|
<td>
|
||||||
<select name="dirPath" id="dirPath" style="width:30em" onChange="updateDir(this)">
|
<select name="dirPath" id="dirPath" style="width:30em" onChange="updateDir(this)">
|
||||||
<option value="/">/</option>
|
<option value="/">/</option>
|
||||||
<?
|
<?php
|
||||||
|
if($no_dir == false)
|
||||||
|
|
||||||
function dirs($dir,$abs_path)
|
|
||||||
{
|
{
|
||||||
$d = dir($dir);
|
dirs($BASE_DIR,'');
|
||||||
$dirs = array();
|
|
||||||
while (false !== ($entry = $d->read())) {
|
|
||||||
if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.')
|
|
||||||
{
|
|
||||||
$path['path'] = $dir.'/'.$entry;
|
|
||||||
$path['name'] = $entry;
|
|
||||||
$dirs[$entry] = $path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$d->close();
|
|
||||||
|
|
||||||
ksort($dirs);
|
|
||||||
for($i=0; $i<count($dirs); $i++)
|
|
||||||
{
|
|
||||||
$name = key($dirs);
|
|
||||||
$current_dir = $abs_path.'/'.$dirs[$name]['name'];
|
|
||||||
echo "<option value=\"$current_dir\">$current_dir</option>\n";
|
|
||||||
dirs($dirs[$name]['path'],$current_dir);
|
|
||||||
next($dirs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($no_dir == false) {
|
|
||||||
dirs($BASE_DIR.$BASE_ROOT,'');
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
// UploadImage Plugin for HTMLArea-3.0
|
/**************************************************************************\
|
||||||
// Implementation by Mihai Bazon. Sponsored by http://thycotic.com
|
* eGroupWare - UploadImage-plugin for htmlArea in eGroupWare *
|
||||||
//
|
* http://www.eGroupWare.org *
|
||||||
// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
|
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
// This notice MUST stay intact for use (see license.txt).
|
* Used code fragments from plugins by Mihai Bazon *
|
||||||
//
|
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
||||||
// A free WYSIWYG editor replacement for <textarea> fields.
|
* -------------------------------------------- *
|
||||||
// For full source code and docs, visit http://www.interactivetools.com/
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
//
|
* under the terms of the GNU General Public License as published by the *
|
||||||
// Version 3.0 developed by Mihai Bazon for InteractiveTools.
|
* Free Software Foundation; version 2 of the License. *
|
||||||
// http://dynarch.com/mishoo
|
\**************************************************************************/
|
||||||
//
|
|
||||||
// $Id$
|
// $id$
|
||||||
|
|
||||||
|
// FIXME: clean up code
|
||||||
|
|
||||||
function UploadImage(editor) {
|
function UploadImage(editor) {
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
@ -36,12 +38,12 @@ function UploadImage(editor) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
UploadImage._pluginInfo = {
|
UploadImage._pluginInfo = {
|
||||||
name : "UploadImage",
|
name : "UploadImage for eGroupWare",
|
||||||
version : "1.0",
|
version : "1.0",
|
||||||
developer : "Pim Snel",
|
developer : "Pim Snel",
|
||||||
developer_url : "http://lingewoud.com",
|
developer_url : "http://lingewoud.com",
|
||||||
c_owner : "Mihai Bazon",
|
c_owner : "Pim Snel, Xiang Wei ZHUO, Mihai Bazon",
|
||||||
sponsor : "Lingewoud b.v. - Netherlands",
|
sponsor : "Lingewoud bv., Netherlands",
|
||||||
sponsor_url : "http://lingewoud.com",
|
sponsor_url : "http://lingewoud.com",
|
||||||
license : "GPL"
|
license : "GPL"
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user