mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-08 22:40:23 +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
|
||||
//of the web server document root. e.g.
|
||||
// Filesystem == /home/web/www.yourdomain.com
|
||||
$BASE_DIR = $GLOBALS[UploadImageBaseDir];
|
||||
$BASE_URL = $GLOBALS[UploadImageBaseURL];
|
||||
$BASE_ROOT = $GLOBALS[UploadImageRelativePath];
|
||||
// FIXME: remove imageMagick shit, we only use gdlib
|
||||
// FIXME: autodetect safe_mode
|
||||
// FIXME set current app to the calling app
|
||||
// FIXME include header nicer
|
||||
|
||||
var_dump($BASE_DIR);
|
||||
var_dump($BASE_URL);
|
||||
var_dump($BASE_ROOT);
|
||||
$phpgw_flags = Array(
|
||||
'currentapp' => 'jinn',
|
||||
'noheader' => True,
|
||||
'nonavbar' => True,
|
||||
'noappheader' => True,
|
||||
'noappfooter' => True,
|
||||
'nofooter' => True
|
||||
);
|
||||
|
||||
//$BASE_DIR = $_SERVER['DOCUMENT_ROOT'];
|
||||
//$BASE_DIR = '/home/www';
|
||||
$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
|
||||
|
||||
//the path where the browser sees the document root (i.e. http://www.yourdomain.com/)
|
||||
//$BASE_URL = 'https://192.168.0.2/';
|
||||
if(@include('../../../../../../header.inc.php'))
|
||||
{
|
||||
// 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)
|
||||
//this directory MUST be readable AND writable by the web server.
|
||||
//$BASE_ROOT = '';
|
||||
define('IMAGE_CLASS', 'GD');
|
||||
|
||||
//The image manipulation library to use, either GD or ImageMagick or NetPBM
|
||||
//valid definitions are 'GD' or 'IM' or 'NetPBM'.
|
||||
define('IMAGE_CLASS', 'GD'); //
|
||||
//In safe mode, directory creation is not permitted.
|
||||
$SAFE_MODE = false;
|
||||
|
||||
//After defining which library to use, if it is NetPBM or IM, you need to
|
||||
//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\\');
|
||||
$sessdata = $GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi');
|
||||
|
||||
$BASE_DIR = $sessdata[UploadImageBaseDir];
|
||||
$BASE_URL = $sessdata[UploadImageBaseURL];
|
||||
$MAX_HEIGHT = $sessdata[UploadImageMaxHeight];
|
||||
$MAX_WIDTH = $sessdata[UploadImageMaxWidth];
|
||||
|
||||
if(!$MAX_HEIGHT) $MAX_HEIGHT = 10000;
|
||||
if(!$MAX_WIDTH) $MAX_WIDTH = 10000;
|
||||
// _debug_array($sessdata);
|
||||
//die();
|
||||
|
||||
|
||||
//In safe mode, directory creation is not permitted.
|
||||
$SAFE_MODE = false;
|
||||
//After defining which library to use, if it is NetPBM or IM, you need to
|
||||
//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 .= '/';
|
||||
|
||||
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
|
||||
$BASE_URL .= '/';
|
||||
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
|
||||
$BASE_URL .= '/';
|
||||
|
||||
//Built in function of dirname is faulty
|
||||
//It assumes that the directory nane can not contain a . (period)
|
||||
function dir_name($dir)
|
||||
{
|
||||
//Built in function of dirname is faulty
|
||||
//It assumes that the directory nane can not contain a . (period)
|
||||
function dir_name($dir)
|
||||
{
|
||||
$lastSlash = intval(strrpos($dir, '/'));
|
||||
if($lastSlash == strlen($dir)-1){
|
||||
return substr($dir, 0, $lastSlash);
|
||||
}
|
||||
else
|
||||
return dirname($dir);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,23 +1,36 @@
|
||||
<?
|
||||
/***********************************************************************
|
||||
** Title.........: Image Manager, draws the thumbnails and directies
|
||||
** Version.......: 1.01
|
||||
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
|
||||
** Filename......: images.php
|
||||
** Last changed..: 8 Mar 2003
|
||||
** Notes.........: Configuration in config.inc.php
|
||||
<?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. *
|
||||
* -------------------------------------------- *
|
||||
* 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
|
||||
- create a new folder,
|
||||
- delete folder,
|
||||
- upload new image
|
||||
- use cached thumbnail views
|
||||
/* $id */
|
||||
|
||||
***********************************************************************/
|
||||
// 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'];
|
||||
|
||||
if(strlen($dirParam) > 0)
|
||||
@ -27,33 +40,31 @@ if(isset($_GET['dir'])) {
|
||||
else
|
||||
$IMG_ROOT = $dirParam;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$refresh_dirs = false;
|
||||
$clearUploads = false;
|
||||
$refresh_dirs = false;
|
||||
$clearUploads = false;
|
||||
|
||||
if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1)
|
||||
if(strrpos($IMG_ROOT, '/')!= strlen($IMG_ROOT)-1)
|
||||
$IMG_ROOT .= '/';
|
||||
|
||||
|
||||
if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false)
|
||||
{
|
||||
if(isset($_GET['create']) && isset($_GET['dir']) && $SAFE_MODE == false)
|
||||
{
|
||||
create_folder();
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET['delFile']) && isset($_GET['dir']))
|
||||
{
|
||||
if(isset($_GET['delFile']) && isset($_GET['dir']))
|
||||
{
|
||||
delete_file($_GET['delFile']);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_GET['delFolder']) && isset($_GET['dir']))
|
||||
{
|
||||
if(isset($_GET['delFolder']) && isset($_GET['dir']))
|
||||
{
|
||||
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'];
|
||||
|
||||
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)
|
||||
$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)
|
||||
{
|
||||
global $clearUploads;
|
||||
function do_upload($file, $dest_dir)
|
||||
{
|
||||
global $clearUploads,$MAX_WIDTH,$MAX_HEIGHT;
|
||||
|
||||
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']);
|
||||
}
|
||||
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;
|
||||
//var_dump($BASE_DIR);
|
||||
|
||||
$del_folder = dir_name($BASE_DIR).$folder;
|
||||
//echo $del_folder;
|
||||
if(is_dir($del_folder) && num_files($del_folder) <= 0) {
|
||||
//echo $del_folder.'<br>';
|
||||
|
||||
if(is_dir($del_folder) && num_files($del_folder) <= 0)
|
||||
{
|
||||
rm_all_dir($del_folder);
|
||||
$refresh_dirs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rm_all_dir($dir)
|
||||
{
|
||||
function rm_all_dir($dir)
|
||||
{
|
||||
//$dir = dir_name($dir);
|
||||
//echo "OPEN:".$dir.'<Br>';
|
||||
if(is_dir($dir))
|
||||
@ -129,27 +187,28 @@ function rm_all_dir($dir)
|
||||
rmdir($dir);
|
||||
}
|
||||
//echo "RM: $dir <br>";
|
||||
}
|
||||
}
|
||||
|
||||
function delete_file($file)
|
||||
{
|
||||
global $BASE_DIR;
|
||||
function delete_file($file)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if(is_file($del_thumb)) {
|
||||
if(is_file($del_thumb))
|
||||
{
|
||||
unlink($del_thumb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function create_folder()
|
||||
{
|
||||
function create_folder()
|
||||
{
|
||||
global $BASE_DIR, $IMG_ROOT, $refresh_dirs;
|
||||
|
||||
$folder_name = $_GET['foldername'];
|
||||
@ -165,10 +224,10 @@ function create_folder()
|
||||
$refresh_dirs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function num_files($dir)
|
||||
{
|
||||
function num_files($dir)
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
if(is_dir($dir))
|
||||
@ -185,10 +244,10 @@ function num_files($dir)
|
||||
$d->close();
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
function dirs($dir,$abs_path)
|
||||
{
|
||||
function dirs($dir,$abs_path)
|
||||
{
|
||||
$d = dir($dir);
|
||||
//echo "Handle: ".$d->handle."<br>\n";
|
||||
//echo "Path: ".$d->path."<br>\n";
|
||||
@ -214,10 +273,10 @@ function dirs($dir,$abs_path)
|
||||
dirs($dirs[$name]['path'],$current_dir);
|
||||
next($dirs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parse_size($size)
|
||||
{
|
||||
function parse_size($size)
|
||||
{
|
||||
if($size < 1024)
|
||||
return $size.' btyes';
|
||||
else if($size >= 1024 && $size < 1024*1024)
|
||||
@ -228,10 +287,10 @@ function parse_size($size)
|
||||
{
|
||||
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;
|
||||
|
||||
$img_path = dir_name($img);
|
||||
@ -243,9 +302,9 @@ function show_image($img, $file, $info, $size)
|
||||
|
||||
$filesize = parse_size($size);
|
||||
|
||||
?>
|
||||
<td>
|
||||
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
||||
?>
|
||||
<td>
|
||||
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
||||
<tr>
|
||||
<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>
|
||||
@ -256,14 +315,14 @@ function show_image($img, $file, $info, $size)
|
||||
<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>
|
||||
<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>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<?
|
||||
</table>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
|
||||
function show_dir($path, $dir)
|
||||
@ -273,7 +332,7 @@ function show_dir($path, $dir)
|
||||
$num_files = num_files($BASE_DIR.$path);
|
||||
?>
|
||||
<td>
|
||||
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
||||
<table width="102" border="0" cellpadding="0" cellspacing="2">
|
||||
<tr>
|
||||
<td align="center" class="imgBorder" onMouseOver="pviiClassNew(this,'imgBorderHover')" onMouseOut="pviiClassNew(this,'imgBorder')">
|
||||
<a href="images.php?dir=<? echo $path; ?>" onClick="changeLoadingStatus('load')">
|
||||
@ -290,7 +349,7 @@ function show_dir($path, $dir)
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
</td>
|
||||
<?
|
||||
}
|
||||
@ -308,11 +367,11 @@ function draw_no_results()
|
||||
|
||||
function draw_no_dir()
|
||||
{
|
||||
global $BASE_DIR, $BASE_ROOT;
|
||||
global $BASE_DIR;
|
||||
?>
|
||||
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
|
||||
<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>
|
||||
</table>
|
||||
<?
|
||||
@ -323,61 +382,62 @@ function draw_table_header()
|
||||
{
|
||||
echo '<table border="0" cellpadding="0" cellspacing="2">';
|
||||
echo '<tr>';
|
||||
}
|
||||
}
|
||||
|
||||
function draw_table_footer()
|
||||
{
|
||||
function draw_table_footer()
|
||||
{
|
||||
echo '</tr>';
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Image Browser</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.imgBorder {
|
||||
<head>
|
||||
<title>Image Browser</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.imgBorder {
|
||||
height: 96px;
|
||||
border: 1px solid threedface;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.imgBorderHover {
|
||||
}
|
||||
.imgBorderHover {
|
||||
height: 96px;
|
||||
border: 1px solid threedface;
|
||||
vertical-align: middle;
|
||||
background: #FFFFCC;
|
||||
cursor: hand;
|
||||
}
|
||||
}
|
||||
|
||||
.buttonHover {
|
||||
.buttonHover {
|
||||
border: 1px solid;
|
||||
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
|
||||
cursor: hand;
|
||||
background: #FFFFCC;
|
||||
}
|
||||
.buttonOut
|
||||
{
|
||||
}
|
||||
.buttonOut
|
||||
{
|
||||
border: 1px solid;
|
||||
border-color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.imgCaption {
|
||||
.imgCaption {
|
||||
font-size: 9pt;
|
||||
font-family: "MS Shell Dlg", Helvetica, sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
.dirField {
|
||||
}
|
||||
.dirField {
|
||||
font-size: 9pt;
|
||||
font-family: "MS Shell Dlg", Helvetica, sans-serif;
|
||||
width:110px;
|
||||
}
|
||||
}
|
||||
|
||||
-->
|
||||
</style>
|
||||
<?
|
||||
$dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT);
|
||||
-->
|
||||
</style>
|
||||
<?php
|
||||
// $dirPath = eregi_replace($BASE_ROOT,'',$IMG_ROOT);
|
||||
$dirPath=$IMG_ROOT;
|
||||
|
||||
$paths = explode('/', $dirPath);
|
||||
$upDirPath = '/';
|
||||
@ -396,33 +456,34 @@ function draw_table_footer()
|
||||
{
|
||||
$newPath = substr($dirPath, 0,$slashIndex-1);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="../popup.js"></script>
|
||||
<script type="text/javascript" src="../../../../dialog.js"></script>
|
||||
<script language="JavaScript" type="text/JavaScript">
|
||||
<!--
|
||||
function pviiClassNew(obj, new_style) { //v2.6 by PVII
|
||||
?>
|
||||
<script type="text/javascript" src="../popup.js"></script>
|
||||
<script type="text/javascript" src="../../../../dialog.js"></script>
|
||||
<script language="JavaScript" type="text/JavaScript">
|
||||
<!--
|
||||
function pviiClassNew(obj, new_style) { //v2.6 by PVII
|
||||
obj.className=new_style;
|
||||
}
|
||||
}
|
||||
|
||||
function goUp()
|
||||
{
|
||||
function goUp()
|
||||
{
|
||||
location.href = "ImageManager/images.php?dir=<? echo $upDirPath; ?>";
|
||||
}
|
||||
}
|
||||
|
||||
function changeDir(newDir)
|
||||
{
|
||||
function changeDir(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;
|
||||
}
|
||||
}
|
||||
|
||||
function updateDir()
|
||||
{
|
||||
var newPath = "<? echo $newPath; ?>";
|
||||
function updateDir()
|
||||
{
|
||||
var newPath = "<?php echo $newPath; ?>";
|
||||
// alert('<?php echo $newPath; ?>');
|
||||
if(window.top.document.forms[0] != null) {
|
||||
|
||||
var allPaths = window.top.document.forms[0].dirPath.options;
|
||||
@ -437,15 +498,15 @@ function updateDir()
|
||||
}
|
||||
}
|
||||
|
||||
<?
|
||||
<?
|
||||
if($clearUploads) {
|
||||
?>
|
||||
?>
|
||||
var topDoc = window.top.document.forms[0];
|
||||
topDoc.upload.value = null;
|
||||
//topDoc.upload.disabled = true;
|
||||
<?
|
||||
<?
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
}
|
||||
|
||||
@ -455,7 +516,7 @@ function updateDir()
|
||||
function refreshDirs()
|
||||
{
|
||||
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; ?>";
|
||||
|
||||
@ -481,12 +542,12 @@ function refreshDirs()
|
||||
|
||||
allPaths.add(newElem);
|
||||
}
|
||||
}
|
||||
refreshDirs();
|
||||
<? } ?>
|
||||
}
|
||||
refreshDirs();
|
||||
<? } ?>
|
||||
|
||||
function imageSelected(filename, width, height, alt)
|
||||
{
|
||||
function imageSelected(filename, width, height, alt)
|
||||
{
|
||||
var topDoc = window.top.document.forms[0];
|
||||
topDoc.f_url.value = filename;
|
||||
topDoc.f_width.value= width;
|
||||
@ -495,10 +556,16 @@ function imageSelected(filename, width, height, alt)
|
||||
topDoc.orginal_width.value = width;
|
||||
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 w = 450;
|
||||
@ -522,18 +589,18 @@ function preview(file, image, size, width, height)
|
||||
}
|
||||
}, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function deleteImage(file)
|
||||
{
|
||||
function deleteImage(file)
|
||||
{
|
||||
if(confirm("Delete image \""+file+"\"?"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function deleteFolder(folder, numFiles)
|
||||
{
|
||||
function deleteFolder(folder, numFiles)
|
||||
{
|
||||
if(numFiles > 0) {
|
||||
alert("There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first.");
|
||||
return false;
|
||||
@ -543,25 +610,25 @@ function deleteFolder(folder, numFiles)
|
||||
return true;
|
||||
|
||||
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) {
|
||||
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];
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
function MM_showHideLayers() { //v6.0
|
||||
function MM_showHideLayers() { //v6.0
|
||||
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];
|
||||
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
|
||||
obj.visibility=v; }
|
||||
}
|
||||
}
|
||||
|
||||
function changeLoadingStatus(state)
|
||||
{
|
||||
function changeLoadingStatus(state)
|
||||
{
|
||||
var statusText = null;
|
||||
if(state == 'load') {
|
||||
statusText = 'Loading Images';
|
||||
@ -576,21 +643,21 @@ function changeLoadingStatus(state)
|
||||
obj.innerHTML = statusText;
|
||||
MM_showHideLayers('loading','','show')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-->
|
||||
</script>
|
||||
</head>
|
||||
<body onLoad="updateDir();" bgcolor="#FFFFFF">
|
||||
//-->
|
||||
</script>
|
||||
</head>
|
||||
<body onLoad="updateDir();" bgcolor="#FFFFFF">
|
||||
|
||||
<?
|
||||
//var_dump($_GET);
|
||||
//echo $dirParam.':'.$upDirPath;
|
||||
//echo '<br>';
|
||||
$d = @dir($BASE_DIR.$IMG_ROOT);
|
||||
<?
|
||||
//var_dump($_GET);
|
||||
//echo $dirParam.':'.$upDirPath;
|
||||
//echo '<br>';
|
||||
$d = @dir($BASE_DIR.$IMG_ROOT);
|
||||
|
||||
if($d)
|
||||
{
|
||||
if($d)
|
||||
{
|
||||
//var_dump($d);
|
||||
$images = array();
|
||||
$folders = array();
|
||||
@ -644,15 +711,15 @@ if($d)
|
||||
{
|
||||
draw_no_results();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_no_dir();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<script language="JavaScript" type="text/JavaScript">
|
||||
MM_showHideLayers('loading','','hide')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
?>
|
||||
<script language="JavaScript" type="text/JavaScript">
|
||||
MM_showHideLayers('loading','','hide')
|
||||
</script>
|
||||
</body>
|
||||
</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
|
||||
/***********************************************************************
|
||||
** Title.........: Thumbnail generator, with cache.
|
||||
** Version.......: 1.0
|
||||
** Author........: Xiang Wei ZHUO <wei@zhuo.org>
|
||||
** Filename......: thumbs.php
|
||||
** Last changed..: 1 Mar 2003
|
||||
** Notes.........: Configuration in config.inc.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. *
|
||||
* -------------------------------------------- *
|
||||
* 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
|
||||
file is newer, create a new thumbnail.
|
||||
/* $id */
|
||||
|
||||
***********************************************************************/
|
||||
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';
|
||||
require_once '../ImageEditor/Transform.php';
|
||||
|
||||
$img = $BASE_DIR.urldecode($_GET['img']);
|
||||
|
||||
if(is_file($img)) {
|
||||
if(is_file($img)) {
|
||||
make_thumbs(urldecode($_GET['img']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function make_thumbs($img)
|
||||
{
|
||||
function make_thumbs($img)
|
||||
{
|
||||
global $BASE_DIR, $BASE_URL;
|
||||
|
||||
|
||||
$path_info = pathinfo($img);
|
||||
$path = $path_info['dirname']."/";
|
||||
$img_file = $path_info['basename'];
|
||||
@ -59,7 +66,6 @@ function make_thumbs($img)
|
||||
$img_thumbs = Image_Transform::factory(IMAGE_CLASS);
|
||||
$img_thumbs->load($BASE_DIR.$path.$img_file);
|
||||
|
||||
|
||||
if ($w > $h)
|
||||
$nh = unpercent(percent($nw, $w), $h);
|
||||
else if ($h > $w)
|
||||
@ -73,19 +79,9 @@ function make_thumbs($img)
|
||||
chmod($BASE_DIR.$thumb, 0666);
|
||||
|
||||
if(is_file($BASE_DIR.$thumb)) {
|
||||
//echo "Made:".$BASE_URL.$path.'.'.$img_file;
|
||||
header('Location: '.$BASE_URL.$path.'.'.$img_file);
|
||||
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
|
||||
** 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';
|
||||
$no_dir = false;
|
||||
if(!is_dir($BASE_DIR.$BASE_ROOT)) {
|
||||
if(!is_dir($BASE_DIR)) {
|
||||
$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;">
|
||||
<head>
|
||||
@ -326,36 +360,10 @@ function toggleConstrains(constrains)
|
||||
<td>
|
||||
<select name="dirPath" id="dirPath" style="width:30em" onChange="updateDir(this)">
|
||||
<option value="/">/</option>
|
||||
<?
|
||||
|
||||
|
||||
function dirs($dir,$abs_path)
|
||||
<?php
|
||||
if($no_dir == false)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
if($no_dir == false) {
|
||||
dirs($BASE_DIR.$BASE_ROOT,'');
|
||||
dirs($BASE_DIR,'');
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -1,16 +1,18 @@
|
||||
// UploadImage Plugin for HTMLArea-3.0
|
||||
// Implementation by Mihai Bazon. Sponsored by http://thycotic.com
|
||||
//
|
||||
// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
|
||||
// This notice MUST stay intact for use (see license.txt).
|
||||
//
|
||||
// A free WYSIWYG editor replacement for <textarea> fields.
|
||||
// For full source code and docs, visit http://www.interactivetools.com/
|
||||
//
|
||||
// Version 3.0 developed by Mihai Bazon for InteractiveTools.
|
||||
// http://dynarch.com/mishoo
|
||||
//
|
||||
// $Id$
|
||||
/**************************************************************************\
|
||||
* eGroupWare - UploadImage-plugin for htmlArea in eGroupWare *
|
||||
* http://www.eGroupWare.org *
|
||||
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||
* Used code fragments from plugins by Mihai Bazon *
|
||||
* 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. *
|
||||
\**************************************************************************/
|
||||
|
||||
// $id$
|
||||
|
||||
// FIXME: clean up code
|
||||
|
||||
function UploadImage(editor) {
|
||||
this.editor = editor;
|
||||
@ -36,12 +38,12 @@ function UploadImage(editor) {
|
||||
};
|
||||
|
||||
UploadImage._pluginInfo = {
|
||||
name : "UploadImage",
|
||||
name : "UploadImage for eGroupWare",
|
||||
version : "1.0",
|
||||
developer : "Pim Snel",
|
||||
developer_url : "http://lingewoud.com",
|
||||
c_owner : "Mihai Bazon",
|
||||
sponsor : "Lingewoud b.v. - Netherlands",
|
||||
c_owner : "Pim Snel, Xiang Wei ZHUO, Mihai Bazon",
|
||||
sponsor : "Lingewoud bv., Netherlands",
|
||||
sponsor_url : "http://lingewoud.com",
|
||||
license : "GPL"
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user