• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.

Image private or not

Danny.Domb

👽 Chevereto Freak
Hey a little mod I did to make images private or not.


I STRONGLY RECOMMEND THAT YOU DO NOT CHANGE ANY NAMES EXCEPT FOR THE LANGUAGES FILES, IT SHOULD WORK IF YOU CHANGE THE NAME, BUT I DIDN'T TEST IT.


Guide how to :

Create a new folder named private in images.
Create a new folder named private in thumbs.

Chmod to 755

Open config.php

Find:
Code:
define('DIR_TH','thumbs/');


Add After:
Code:
define('DIR_PRIV_NAME', 'private/');
define('DIR_PRIV', DIR_IM.DIR_PRIV_NAME);


Open engine.php

Find:
Code:
check_permissions(DIR_TH);

Add After:
Code:
check_permissions(DIR_PRIV);

Find:
Code:
$resizr = $_GET['ancho']; // Resize via GET

Add After:
Code:
$private = $_POST['private']; // Is image public or not

Find:
Code:
            if (empty($resize)) {
                // Haga como si nada...
                copy($handlework, DIR_IM.$name);
                $titulo = UPLOAD_OK.ESP_TITULO;
            }

REPLACE with:
Code:
            if (empty($resize)) {
                // Haga como si nada...
                if ($private == 1)
                {
                    copy($handlework, DIR_PRIV.$name);
                }
                else
                {
                    copy($handlework, DIR_IM.$name);
                }
                $titulo = UPLOAD_OK.ESP_TITULO;
            }


Find:
Code:
            if ($red==1) {
                // Correr la funcion redimensionamiento *img en el working
                redimensionar($exten,$handlework,DIR_WORKING.$name,$ancho,$alto);
                        
                // Mover la redimensionada
                
                copy(DIR_WORKING.$name, DIR_IM.$name);
                
                $titulo = UPLOAD_AND_RESIZED.ESP_TITULO;
                                
                // Borramos
                unlink(DIR_WORKING.$name);
                if($delete_temp==true) { unlink($rup_temp); }

            }

REPLACE WITH:
Code:
            if ($red==1) {
                // Correr la funcion redimensionamiento *img en el working
                redimensionar($exten,$handlework,DIR_WORKING.$name,$ancho,$alto);
                        
                // Mover la redimensionada
                
                if ($private == 1)
                {
                    copy(DIR_WORKING.$name, DIR_PRIV.$name);
                }
                else
                {
                    copy(DIR_WORKING.$name, DIR_IM.$name);
                }
                
                $titulo = UPLOAD_AND_RESIZED.ESP_TITULO;
                                
                // Borramos
                unlink(DIR_WORKING.$name);
                if($delete_temp==true) { unlink($rup_temp); }

            }

Find:
Code:
        $URLimg = URL_SCRIPT.DIR_IM.$name;
        $URLthm = URL_SCRIPT.DIR_TH.$name;
        $URLvim = URL_SCRIPT.'?v='.$name;

REPLACE with:
Code:
    if ($private == 1)
    {
        $URLimg = URL_SCRIPT.DIR_PRIV.$name;
        $URLthm = URL_SCRIPT.DIR_TH.DIR_PRIV_NAME.$name;
        $URLvim = URL_SCRIPT.'?v='.DIR_PRIV_NAME.$name;
    }
    else
    {
        $URLimg = URL_SCRIPT.DIR_IM.$name;
        $URLthm = URL_SCRIPT.DIR_TH.$name;
        $URLvim = URL_SCRIPT.'?v='.$name;
    }

Open the language file you are using (in my case en.php)

Find:
Code:
?>

Add BEFORE
Code:
define('IMG_PUBLIC', 'Public Image');
define('IMG_PRIVATE', 'Private Image');

Open index.php

Find:
Code:
<div id="boton_subir">

Add After:
Code:
        <input type="radio" name="private" value="1" /><?php echo IMG_PRIVATE; ?><br />
        <input type="radio" name="private" value="0" checked /><?php echo IMG_PUBLIC; ?><br />

Find:
Code:
<div id="contenido">
    <div id="tools"><div id="fullsize"<? if ($ancho<=900) { echo ' style="display: none; "'; }?>><a href="<?php echo PATH_SCRIPT.DIR_IM.$folhost.$name?>" title="<?php echo $ancho?>x<?php echo $alto?>"><?php echo FULL_SIZE;?></a></div><div id="sharethis"><a id="sharing"><?php echo SHARE;?></a><a id="sharing-close" style="display: none;"><?php echo SHARE;?></a></div></div>
    <div id="imagen"><a href="<?php echo PATH_SCRIPT.DIR_IM.$folhost.$name?>"><img src="<?php echo PATH_SCRIPT.DIR_IM.$folhost.$name?>" alt="" <? if ($ancho>=900) { echo 'width="900" '; } ?>/></a></div>

Replace with:
Code:
<div id="contenido">
    <div id="tools"><div id="fullsize"<? if ($ancho<=900) { echo ' style="display: none; "'; }?>><a href="<?php if ($private == 1){echo PATH_SCRIPT.DIR_IM.$folhost.DIR_PRIV_NAME.$name;}else{echo PATH_SCRIPT.DIR_IM.$folhost.$name;}?>" title="<?php echo $ancho?>x<?php echo $alto?>"><?php echo FULL_SIZE;?></a></div><div id="sharethis"><a id="sharing"><?php echo SHARE;?></a><a id="sharing-close" style="display: none;"><?php echo SHARE;?></a></div></div>
    <div id="imagen"><a href="<?php if ($private == 1){echo PATH_SCRIPT.DIR_IM.$folhost.DIR_PRIV_NAME.$name;}else{echo PATH_SCRIPT.DIR_IM.$folhost.$name;}?>"><img src="<?php if ($private == 1){echo PATH_SCRIPT.DIR_IM.$folhost.DIR_PRIV_NAME.$name;}else{echo PATH_SCRIPT.DIR_IM.$folhost.$name;}?>" alt="" <? if ($ancho>=900) { echo 'width="900" '; } ?>/></a></div>
 
If you added an gallery to your website, you could show all images in the images folder and keep others private :cool:
 
There is a bug with thumbs of priv images.

For have it working u need to open engine.php

Find:
Code:
// Thumb
redimensionar($exten,$handlework,DIR_TH.$name,$mini_ancho,$mini_alto);

And replace with:
Code:
// Thumb
if( $private == 1) 
    redimensionar($exten,$handlework,DIR_TH.DIR_PRIV_NAME.$name,$mini_ancho,$mini_alto);    
else
    redimensionar($exten,$handlework,DIR_TH.$name,$mini_ancho,$mini_alto);

;)
 
Back
Top