1 (edited by 2008-08-02 15:26:06)

Topic: [HACK] Different Image Directories For Each User

Name: Different Image Directories For Each User
Author: Sandro & NyNe
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Give each user his own folder where he may upload/use images. Admin has full rights.
Instructions:

open ./data/config.php
find:

?>


add above:

$config_path_image_upload = "./data/upimages";

$config_user_image_upload = "yes";

$config_user_image_delete = "yes";

open ./inc/options.mdu
find:

    echo"
    <input type=hidden name=mod value=options>
    <input type=hidden name=action value=dosavesyscon>".


add above:

        showRow("Image Directory", "folder where images will be saved", "<input type=text style=\"text-align: center;\"  name='save_con[path_image_upload]' value='".str_replace("/".$username, "", $config_path_image_upload)."' size=40>");

        showRow("User Image Directories", "if yes, users keep their images in their own image directories", makeDropDown(array("yes"=>"Yes","no"=>"No"), "save_con[user_image_upload]", "$config_user_image_upload"));

        showRow("Users Can Delete Images", "if yes, users can delete images", makeDropDown(array("yes"=>"Yes","no"=>"No"), "save_con[user_image_delete]", "$config_user_image_delete"));


find:

                    array(
                           'name'                => "Manage Uploaded Images",
                           'url'                => "$PHP_SELF?mod=images",
                           'access'        => "1",
                    ),


replace with:

                    array(
                           'name'                => "Manage Uploaded Images",
                           'url'                => "$PHP_SELF?mod=images",
                           'access'        => "3",
                    ),

open ./inc/images.mdu
find:

if($member_db[1] > 3 or ($member_db[1] != 1 and $action == "doimagedelete")){ msg("error", "Access Denied", "You don't have permission to manage images"); }


replace with:

if($member_db[1] > 3 or ($member_db[1] != 1 and $action == "doimagedelete" and $config_user_image_delete == "no")){ msg("error", "Access Denied", "You don't have permission to manage images"); }

open ./index.php
find:

$config_path_image_upload        = "./data/upimages";


replace with:

/* DIFDU v1.0
$config_path_image_upload        = "./data/upimages"; */


find:

require_once("./data/config.php");


add below:

// Start DIFDU v1.0
if ($config_user_image_upload == "yes") { $config_path_image_upload .= "/$username"; }
// End DIFDU v1.0


find:

/* END Login Authorization using SESSIONS */
}


add below:

// Start DIFDU v1.0
if (!is_dir($config_path_image_upload) && $member_db[1] < 4) {
   mkdir($config_path_image_upload);
   @chmod($config_path_image_upload, 755);
}
// End DIFDU v1.0