KissGallery

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

maco
Posts: 8
Joined: Thu Dec 11, 2008 10:33 am

KissGallery

Post by maco » Thu Dec 11, 2008 10:38 am

Hi I have installed KissGallery 4 plugin on cmsimple 3.2
.
When enver I want to upload the picture I get error "Wrong extension in "
this is the error catcher in admin.php
if (!(preg_match($ext, $file_name))) $e.='<li>'.$tx['error']['wrongext'].' '.$file_name.'</li>';
I took a look at the code and I saw that variable file_name is always empty
.
$files=kissRFile($fnfile);
if ($action=='save_file') {
$order=kissGetNumber(kissGetVar('order'));
$file_name=kissGetVar('file_name');
$desc=strtr(kissGetVar('desc'),"#","_");
if ($id==0) {
$file_name = strtolower($GLOBALS['HTTP_POST_FILES']['file_name']['name']);
if ($desc=='') $desc=$file_name;
if ($order=='') $order=time();
$file_size = $GLOBALS['HTTP_POST_FILES']['file_name']['size'];
$file_tmp = $GLOBALS['HTTP_POST_FILES']['file_name']['tmp_name'];
$file_type = $GLOBALS['HTTP_POST_FILES']['file_name']['type'];
$ext='/\\'.str_replace(',','|\\',$plugin_cf['kissgallery']['file_extension']).'/i';
if (!(preg_match($ext, $file_name))) $e.='<li>'.$tx['error']['wrongext'].' '.$file_name.'</li>';
if ($file_size > $plugin_cf['kissgallery']['max_filesize']) $e .= '<li>'.$file_name.' '.$tx['error']['tolarge'].' '.$plugin_cf['kissgallery']['max_filesize'].' '.$tx['files']['bytes'].'</li>';
if (!$e) {
$id=kissNextID($files);
if (getImage($file_tmp,$id,$filepath)) {
$o .= '<p>'.ucfirst($tx['filetype']['file']).' '.$file_name.' '.$tx['result']['uploaded'].'</p>';
$file_datetime=time();
$files[]=array($id,$order,$gid,$file_name,$file_datetime,$file_type,$desc);
}
else e('cntsave', 'file', $file_name);
}
} else {
foreach ($files as $num => $rec) {
if ($rec[0]==$id) {
$files[$num][1]=$order;
$files[$num][2]=$gid;
$files[$num][6]=$desc;
}
}
}
kissWFile($fnfile,$files);
$files=kissRFile($fnfile);
}
Did any one have same problem

Connie
Posts: 282
Joined: Thu May 22, 2008 10:11 am
Location: Hamburg
Contact:

Re: KissGallery

Post by Connie » Thu Dec 11, 2008 11:05 am

a similar (or the same) question has been posted already

there is no need to post the complete script code, better would be to know the name of the image which you tried to upload

"Wrong extension in" points to a file-name-permission-problem

so please give us the information which filename you used when you wanted to upload a file
|---
Connie Müller-Gödecke, http://www.webdeerns.de

maco
Posts: 8
Joined: Thu Dec 11, 2008 10:33 am

Re: KissGallery

Post by maco » Thu Dec 11, 2008 11:09 am

I was uploading one test image from my computer
C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg

maco
Posts: 8
Joined: Thu Dec 11, 2008 10:33 am

Re: KissGallery

Post by maco » Thu Dec 11, 2008 11:33 am

One more thing
If I am uploading same picture with CMSimple images option it works perfectly.

Connie
Posts: 282
Joined: Thu May 22, 2008 10:11 am
Location: Hamburg
Contact:

Re: KissGallery

Post by Connie » Thu Dec 11, 2008 12:14 pm

ok, so it can't be a disallowed file format or file-extension

check this:

1. what is the maximum-filesize which is defined in your CMSimple-configuration? This value relates to the standard-image-upload

2. what is the maximum-filesize which is defined for kiss gallery?
see here: \config\config.php

Code: Select all

	$plugin_cf['kissgallery']['max_filesize']="1000000";
3. what is the filesize of the image you tried to upload?

It it is lower/equal the configuration-size but greater than the gallery-config-size you have the reason why...
Last edited by Connie on Thu Dec 11, 2008 12:22 pm, edited 1 time in total.
|---
Connie Müller-Gödecke, http://www.webdeerns.de

maco
Posts: 8
Joined: Thu Dec 11, 2008 10:33 am

Re: KissGallery

Post by maco » Thu Dec 11, 2008 12:17 pm

So how can I solve this problem?

Holger
Site Admin
Posts: 3155
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany
Contact:

Re: KissGallery

Post by Holger » Thu Dec 11, 2008 12:27 pm

Hi maco & Connie,
Connie wrote:"Wrong extension in" points to a file-name-permission-problem
maco wrote:I saw that variable file_name is always empty
That's not a problem with a file-extention, sizes or a wrong permission. It's a problem with the script and the PHP version & settings.
(So it was very helpfull to post the code here :mrgreen: )

IMHO the problem belongs to the use of the $GLOBALS * VARS.
$HTTP_POST_FILES is deprecated since PHP Version 4.1.0. To access this variables, you need the setting register_long_arrays = on.

The author should rewrite the script to use the superglobals: http://de.php.net/manual/en/language.va ... lobals.php

As a quick and dirty solution, to keep such scripts alive, it should help to include a code-snippet like this at the top of the script(s):

Code: Select all

$HTTP_POST_VARS = !empty($HTTP_POST_VARS) ? $HTTP_POST_VARS : $_POST;
$HTTP_GET_VARS = !empty($HTTP_GET_VARS) ? $HTTP_GET_VARS : $_GET;
$HTTP_POST_FILES = !empty($HTTP_POST_FILES) ? $HTTP_POST_FILES : $_FILES;
$HTTP_COOKIE_VARS = !empty($HTTP_COOKIE_VARS) ? $HTTP_COOKIE_VARS : $_COOKIE;
$HTTP_SERVER_VARS = !empty($HTTP_SERVER_VARS) ? $HTTP_SERVER_VARS : $_SERVER;
But it's better to replace all $GLOBALS['HTTP_POST_FILES'] with $_FILES !

WBR
Holger

maco
Posts: 8
Joined: Thu Dec 11, 2008 10:33 am

Re: KissGallery

Post by maco » Thu Dec 11, 2008 1:43 pm

If I do the above then file upload is not working at all
-

Holger
Site Admin
Posts: 3155
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany
Contact:

Re: KissGallery

Post by Holger » Thu Dec 11, 2008 2:07 pm

maco wrote:If I do the above then file upload is not working at all
-
Hmm, like before :mrgreen: ... (what do you mean with "not working at all"?)
As I said, it should work.

Edit:
Yes it's clear. Since we're speaking about arrays, we have to extract each value of these arrays, of course.
But I would prefer to rewrite the script - as mentioned above - to use $_FILES.


Holger

Holger
Site Admin
Posts: 3155
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany
Contact:

Re: KissGallery

Post by Holger » Thu Dec 11, 2008 3:17 pm

Have you tried to search'n replace $GLOBALS['HTTP_POST_FILES'] with $_FILES ?
I bet that's the problem when $file_name is empty.

What's the setting of "register_long_arrays" in your php.ini?

Holger

Post Reply