31
xgarb
Re: ImageManager - Replacement - Long Post!...
  • 2008/7/13 16:25

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Have you tried turning on debug?..

admin > Preferences Main > General Settings

Debug mode (enable inline mode)

see an error message at the base of the page?

Also I only tested this on Apache on Linux.



32
xgarb
Re: ImageManager - Replacement - Long Post!...
  • 2008/7/13 8:56

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


The existing image manager or the new hack in this thread?



33
xgarb
Re: ImageManager - Replacement - Long Post!...
  • 2008/7/5 13:28

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


duh!

Realised line 53 of imagemanager.php is wrong, should be..

$numberImagesShown in_array(12,$group) ? 15 10// groupID 12 gets 15 images in their dir


two things the wrong way round!



34
xgarb
Re: ImageManager - Replacement - Long Post!...
  • 2008/6/30 10:10

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


Feel free to use it however you like. My code will need some work to integrate it properly into the core.

I've always thought a user and site file manager would work well in XOOPS with areas for storing images, mp3s, video etc.

I usually favour features being 'modulalized' but in the case of a file manager I wonder if it would be better in the core so all modules would use the same system.

Maybe a core module so it's a module but always comes with the core?



35
xgarb
Re: Image Manager improvements - file uploads
  • 2008/6/29 18:42

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


for anyone who's got notifications set on this thread...

I've created something that people might be able to use..

https://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=64670&forum=14



36
xgarb
Re: ImageManager - Process
  • 2008/6/29 18:35

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


I think rather than droning on through the code it's probably better if I go through how the system works. There's lots of commenting in the code to explain it anyway.

In the old imagemanager all the images are stored in a single directory.

In this system each of the sections from the XOOPS image admin has a directory on the file system. In addition each user can have their own directory. These are created the first time the imagemanager is started by a user for a user's own directory or a section from the admin area is selected in the imagemanager.

When an image is uploaded it is stored in one of these directories as an exact copy of the file on the user's PC.

If a user views their own images or the site's images a thumbnail is created of the relevant files and stored in the /cache folder. The user is shown these thumbnails on the screen.

Selecting a thumbnail shows a preview of the image (again generated and then stored in the /cache folder). The user can choose the size of image required and the alignment. If the user is viewing their own images they have the option of removing the image from their area (this only removes the original uploaded file).

Finally the file they've selected is created at the size chosen and moved to the upload folder. They can then press a button to add the image display code to the page.

Short Version!: Images are uploaded to a specific directory for storage. All the images shown on the site are created from this original. Thumbnails and previews shown while using the imagemanager are stored in the cache folder. If an image is selected to be shown on the site a copy is made of the original and this copy is stored in the /uploads directory.



37
xgarb
Re: ImageManager - imagemanager.php - Thumbnail creation
  • 2008/6/29 18:09

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


I won't paste all the code here but the function...

function im_manager_createThumbnail($source,$thisActiveDir)

creates thumbnails in the cache folder. The new imagemagick command makes much better quality thumbnails than the previous code.



38
xgarb
Re: ImageManager - imagemanager.php - Directories
  • 2008/6/29 18:05

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


I'll try and explain how some of the code works - if anyone spots improvements or problems let me know!

The new image manager creates directories on the server to store the images. This code creates either a directory matching one of the sections added in the images part of XOOPS admin or a directory for the user.

It also adds an .htaccess file to secure the directory

// site directories 
 
if (isset($_REQUEST['imgcat_id'])){ // POST or GET
   
$showPulldown 'yes';
   
$numberImagesShown 15;   
   
$imgcat_handler =& xoops_gethandler('imagecategory');
   
$catlist =& $imgcat_handler->getList($group'imgcat_read'1);
   
$currentcat_id intval($_REQUEST['imgcat_id']);
   
$imgcatname $catlist[$currentcat_id];
   
$cleanimgcatname preg_replace("/[^a-z0-9\.\-\_]/i"'_' ,$imgcatname); //replace odd characters with underscore
   
$userID $xoopsUser->getVar('uid');
   
$userIDcode str_pad($userID5"0"STR_PAD_LEFT); // always have 5 digits ie: userid 123 becomes 00123
   
$activeDir XOOPS_UPLOAD_PATH.'/'.$cleanimgcatname;
  } 
// or user's directory   
 
if ( (!isset($_GET['imgcat_id']) && !isset($_POST['imgcat_id']) ) || $imgcatname == 'User Images'){
   
$showPulldown 'no';
   
$numberImagesShown in_array($group,12) ? 10 15// groupID 12 gets 15 images in their dir
   
$userID $xoopsUser->getVar('uid');
   
$userIDcode str_pad($userID5"0"STR_PAD_LEFT); // always have 5 digits ie: userid 123 becomes 00123
   
$userDir 'user_'.$userIDcode// this is the folder in uploads dir for this user ie: user_00123
   
$activeDir XOOPS_UPLOAD_PATH.'/'.$userDir;
  }
// create directory if not existing
 
if (!file_exists($activeDir)){
   
mkdir($activeDir0700);
   
// add an htaccess file to prevent script and non-image files being accessed...
   
$filename $activeDir.'/.htaccess';
   
$fh fopen($filename'w');
   
$stringData  "AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgin";
   
$stringData .= "Options -ExecCGIn";
   
$stringData .= "Order Deny,Allown";
   
$stringData .= "Deny from alln";
   
$stringData .= "<FilesMatch '.(gif|jpe?g|png)$'>n";
   
$stringData .= "Allow from alln";
   
$stringData .= "</FilesMatch>n";
   
$stringData .= "Options -Indexesn"// prevent browsing users dir
   
fwrite($fh$stringData);
   
fclose($fh);
   
chmod($filename0400);
  }
}



39
xgarb
Re: ImageManager - Replacement - Screenshots
  • 2008/6/29 17:55

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


After clicking the imagemanager button the user would see their own images. Other users cannot see these images unless they are used somewhere on the site:

Resized Image


If they click the 'Site Images' tab they then see the images all users have access to:

Resized Image


This is the 'user image detail' screen where the user can choose the image size to use or delete the image:

Resized Image


Same screen but for site images (no delete button):
Resized Image

Finally the user can add the image to their post etc..

Resized Image

I've realised the above might be confusing as some images appear in both the user and site wide screens. The user's images wouldn't show in the site images unless they'd uploaded them to both areas



40
xgarb
ImageManager - Replacement - Long Post!...
  • 2008/6/29 17:44

  • xgarb

  • Not too shy to talk

  • Posts: 154

  • Since: 2003/3/30


As mentioned in this thread..https://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&type=&topic_id=61462&forum=14 I’ve gone ahead and re-coded the imagemanager.

I’ve done this for my own use so while I’ve tried to keep it xoopified as much as possible I have taken some shortcuts to get it running. Mostly this is hard coded text rather than language variables.

I’m not a born coder so this is at your own risk. I’ve tried to make it as secure as possible.

If anyone wants to help with this, take it over or absorb some of it into the core than that would be fantastic.

Basic concepts:
Uploaded files are stored as they are originally uploaded. Resized images are generated as required from the original uploads.
Users have their own upload directory that they use to manage their own images.

Improvements over original imagemanager:
Higher quality images produced when using Imagemagick
Quicker access to a user’s commonly used images
Images only need to be uploaded once for use at different sizes
More intuitive and attractive to use

Things missing from the original imagemanager:
Database storage of images
‘Friendly’ image names
Mime type data

Possible Further features:
Resize and crop images in the imagemanager


Download files here..http://www.mediafire.com/?9fbt2d4ttwx

You can test it here ..http://xoopsforever.x10hosting.com
With username and pass combos: test1111/test1111 test2222/test2222 test3333/test3333

Screenshots and code extracts follow….




TopTop
« 1 2 3 (4) 5 6 7 ... 14 »



Login

Who's Online

135 user(s) are online (61 user(s) are browsing Support Forums)


Members: 0


Guests: 135


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits