OK, solved the most part of the problems.
Only have to solve one more issue.
Now i can upload images to the main directory and create subfolders with 0777 permissions but i can't upload images to the new directories and the system doesn't create the thumbs folder.
Here the code:
//Create /thumbs folder
if(!file_exists($config_path_image_upload.'/thumbs'))
@mkdir($config_path_image_upload.'/thumbs');
chmod($config_path_image_upload.'/thumbs',0777);
Any idea?
Part of the code what i modify is the follow:
// ********************************************************************************
// Upload Image(s)
// ********************************************************************************
//Rename image
if ($action == 'rename' and $image and $name){
$dir = end(explode("/", $path));
@rename($path.'/'.$image, $path.'/'.$name);
@rename($path.'/thumbs/'.$image, $path.'/thumbs/'.$name);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.($path == $static_path_image_upload ? '' : $dir).'&start_from='.$start_from.'";</script>';
}
//Rename subfolder
if ($action == 'change_dir' and $new_name){
$new_name = str_replace(" ", "_", $new_name);
$path_arr = explode("/", $config_path_image_upload);
$length = strlen(end($path_arr))+1;
$new_path = substr($config_path_image_upload, 0, -$length);
if(file_exists($new_path.'/'.$new_name)) echo "<font color=red>Error, ".$new_name." already exists.</font>";
else{
@rename($config_path_image_upload, $new_path.'/'.$new_name);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$new_name.'";</script>';
}
}
//Create subfolder
if ($action == 'create_dir' and $new_dir){
$new_dir = str_replace(" ", "_", $new_dir);
if(file_exists($config_path_image_upload.'/'.$new_dir)) echo "<font color=red>Error, ".$new_dir." already exists.</font>";
else{
@mkdir($config_path_image_upload.'/'.$new_dir);
chmod($config_path_image_upload.'/'.$new_dir,0777);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$new_dir.'";</script>';
create_htaccess($config_path_image_upload.'/'.$new_dir.'/.htaccess');
}
}
//Delete empty subfolder
if ($action == "delete_dir"){
unlink($config_path_image_upload.'/thumbs/.htaccess');
rmdir($config_path_image_upload.'/thumbs');
unlink($config_path_image_upload.'/.htaccess');
rmdir($config_path_image_upload);
echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images";</script>';
}
//Move file
if ($action == "move_file"){
if(!file_exists($config_path_image_upload.'/'.$file)){
copy($old_path.'/'.$file, $config_path_image_upload.'/'.$file);
copy($old_path.'/thumbs/'.$file, $config_path_image_upload.'/thumbs/'.$file);
unlink($old_path.'/'.$file);
unlink($old_path.'/thumbs/'.$file);
//echo '<script type="text/javascript">self.location.href="'.$PHP_SELF.'?mod=images&folder='.$folder.'";</script>';
}
}
//Upload image
if($subaction == "upload")
{
for ($i = 0; $i < count($_FILES['image']['name'])-1; $i++) {
$image = $_FILES['image']['tmp_name'][$i];
$image_name = $_FILES['image']['name'][$i];
$image_name = str_replace(" ", "_", $image_name);
$img_name_arr = explode(".",$image_name);
$type = end($img_name_arr);
if($image_name == ""){ $img_result .= "
<font color=red>$current_image -> No File Specified For Upload!</font>"; }
elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "
<font color=red>$image_name -> Image already exist!</font>";}
elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){
$img_result .= "
<font color=red>$image_name ->This type of file is not allowed !!!</font>";
}
else
{
@copy($image, $config_path_image_upload.'/'.$image_name) or $img_result = "<font color=red>Not able to upload image.</font>
Make sure that file upload is enabled or contact your server administrator.";
chmod($image, $config_path_image_upload.'/'.$image_name, 0777);
//Add watermark (text)
if ($watermark and $watermark_text != "") {
if($watermark_font == "none") {
@add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'));
}
else {
@add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'), 'data/watermark/'.$watermark_font);
}
}
//Add watermark (image)
if ($merge) {
@mergePix($config_path_image_upload.'/'.$image_name, 'data/watermark/'.$watermark_image, $config_path_image_upload.'/'.$image_name, $hotspot2, ($merge_transition ? $merge_transition : '40'));
}
//Make thumb
if ($max < 1 or $max == "") {$max = 100;}
if ($square == "yes") {
make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'square');
chmod($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'square',0777);
}
else make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'normal');
chmod($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'normal',0777);
//Shadow
if ($shadow == "yes") {
shadow($config_path_image_upload."/".$image_name);
shadow($config_path_image_upload."/thumbs/".$image_name);
}
if(file_exists($config_path_image_upload."/".$image_name))
{
$img_result .= "
<font color=green>$image_name -> Image was uploaded</font>";
}//if file is uploaded succesfully
}
}
}
Thanks in advance, any help will be appreciated.