1
bitter_end
Re: Do not rename image uploaded with Xoops Image manager ?
  • 2009/2/17 14:13

  • bitter_end

  • Just popping in

  • Posts: 3

  • Since: 2009/2/7 1


Thanks a lot. This small code saved my life. I was working on another issue and forun the solution here. My need was the opposite and I added this code and worked well for me.



2
bitter_end
Extgallery upload filename problem
  • 2009/2/17 0:53

  • bitter_end

  • Just popping in

  • Posts: 3

  • Since: 2009/2/7 1


Hello everyone.
I'm using extgallery as a picture gallery but when a photo including turkish characters in the photo name it's saved to the server with that characters and not shown by browsers. It saves the filename as this: filename_tempname.jpg

I thing it can be solved by XOOPS class/uploader.php but dont know what to do about it. I just need it to have a random filename or just the temp name, not he filename

Can anyone help me about this issue



3
bitter_end
How to save user ip address when uploading images to extgallery
  • 2009/2/7 14:35

  • bitter_end

  • Just popping in

  • Posts: 3

  • Since: 2009/2/7 1


I'm usnig extgallery module as an image gallry but I need it to save the user ip when uploading a picture.
I have created a field called "IP" in the table in MySQL but don't know hot to make it write the user IP to there. Here is the uploader file code for extgallery

I would be very happy if anyone can help me about this small issue


<?php

require '../../mainfile.php';
include_once XOOPS_ROOT_PATH.'/modules/extgallery/class/publicPerm.php';
include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
include_once XOOPS_ROOT_PATH.'/class/uploader.php';

if(isset($_POST['step'])) {
$step = $_POST['step'];
} else {
$step = 'default';
}

$permHandler = ExtgalleryPublicPermHandler::getHandler();
if(count($permHandler->getAuthorizedPublicCat($xoopsUser, 'public_upload')) < 1) {
redirect_header("index.php", 3, _MD_EXTGALLERY_NOPERM);
exit;
}

switch($step) {

case 'enreg':

include_once XOOPS_ROOT_PATH.'/modules/extgallery/class/php-captcha.inc.php';

// Enable captcha only if GD is Used
if($xoopsModuleConfig['graphic_lib'] == 'GD') {
if (!PhpCaptcha::Validate($_POST['captcha'])) {
redirect_header("public-photo.php?photoId=".$photoId."#photoNav", 3, _MD_EXTGALLERY_CAPTCHA_ERROR);
exit;
}
}

include_once XOOPS_ROOT_PATH.'/modules/extgallery/class/pear/Image/Transform.php';

$catHandler = xoops_getmodulehandler('publiccat', 'extgallery');
$photoHandler = xoops_getmodulehandler('publicphoto', 'extgallery');

$catId = intval($_POST['cat_id']);

// If isn't an album when stop the traitment
$cat = $catHandler->getCat($catId);
if($cat->getVar('nright') - $cat->getVar('nleft') != 1) {
redirect_header("photo.php", 3, _MD_EXTGALLERY_NOT_AN_ALBUM);
exit;
}

$allowedMimeTypes = array('image/jpeg','image/gif','image/png');
$uploadDir = XOOPS_ROOT_PATH."/uploads/extgallery/public-photo/";

$uploader = new XoopsMediaUploader($uploadDir, $allowedMimeTypes, 3145728, 5000, 5000);

foreach($_FILES as $file => $fileArray) {

// Test if there is an error during upload
if($fileArray['error'] != 0) {
redirect_header("public-upload.php", 3, _MD_EXTGALLERY_UPLOAD_ERROR);
exit;
}

if ($uploader->fetchMedia($file)) {

if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
$extra = isset($_POST['photo_extra']) ? $_POST['photo_extra'] : "";
$photoStatus = $photoHandler->addLocalPhoto($catId,$uploader->getSavedFileName(),$_POST['photo_title']);
$cat = $catHandler->getCat($catId);
$cat->setVar('cat_isalbum',1);
$catHandler->insert($cat);

$notification_handler =& xoops_gethandler('notification');
$extraTags = array(
'X_ITEM_CAT'=>$cat->getVar('cat_name'),
'X_ITEM_NBPHOTO'=>1
);
if($photoStatus == 1) {
$extraTags['X_ITEM_URL'] = XOOPS_URL."/modules/extgallery/public-album.php?id=".$cat->getVar('cat_id');
$notification_handler->triggerEvent('global', 0, 'new_photo',$extraTags);
$notification_handler->triggerEvent('album', $cat->getVar('cat_id'), 'new_photo_album',$extraTags);

// Update album count
if($cat->getVar('cat_nb_photo') == 0) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('nleft',$cat->getVar('nleft'),'<'));
$criteria->add(new Criteria('nright',$cat->getVar('nright'),'>'));
$catHandler->updateFieldValue('cat_nb_album', 'cat_nb_album + 1', $criteria);
}

// Update photo count
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('nleft',$cat->getVar('nleft'),'<='));
$criteria->add(new Criteria('nright',$cat->getVar('nright'),'>='));
$catHandler->updateFieldValue('cat_nb_photo', 'cat_nb_photo + 1', $criteria);

echo "SUCCESS\n";

redirect_header("public-album.php?id=1", 3, _MD_EXTGALLERY_PHOTO_UPLOADED);
} else {
$extraTags['X_ITEM_URL'] = XOOPS_URL."/modules/extgallery/admin/photo.php";
$notification_handler->triggerEvent('global', 0, 'new_photo_pending',$extraTags);

echo "SUCCESS\n";

redirect_header("public-album.php?id=1", 3, _MD_EXTGALLERY_PHOTO_PENDING);
}

}
} else {
echo $uploader->getErrors();
}

}

break;

case 'default':
default:

include_once XOOPS_ROOT_PATH.'/header.php';

$catHandler = xoops_getmodulehandler('publiccat', 'extgallery');

$form = new XoopsThemeForm(_MD_EXTGALLERY_PUBLIC_UPLOAD, 'add_photo', 'public-upload.php', 'post', true);
$form->setExtra('enctype="multipart/form-data"');
$form->addElement(new XoopsFormLabel(_MD_EXTGALLERY_ALBUMS, $catHandler->getLeafSelect('cat_id', false, 0, "", "public_upload")));
$form->addElement(new XoopsFormFile(_MD_EXTGALLERY_PHOTO, 'photo_file', 3145728),false);
if($xoopsModuleConfig['display_extra_field'])
$form->addElement(new XoopsFormTextArea(_MD_EXTGALLERY_EXTRA_INFO, "photo_extra"));
$form->addElement(new XoopsFormHidden("step", 'enreg'));
// Enable captcha only if GD is Used
if($xoopsModuleConfig['graphic_lib'] == 'GD') {
$form->addElement(new XoopsFormText(_MD_EXTGALLERY_SECURITY, 'captcha', '10', '5', ''),false);
}
$form->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
$form->display();

include(XOOPS_ROOT_PATH."/footer.php");

break;

}

?>




TopTop



Login

Who's Online

166 user(s) are online (99 user(s) are browsing Support Forums)


Members: 0


Guests: 166


more...

Donat-O-Meter

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

Latest GitHub Commits