Topic: Image private or not

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:

define('DIR_TH','thumbs/');

Add After:

define('DIR_PRIV_NAME', 'private/');
define('DIR_PRIV', DIR_IM.DIR_PRIV_NAME);

Open engine.php

Find:

check_permissions(DIR_TH);

Add After:

check_permissions(DIR_PRIV);

Find:

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

Add After:

$private = $_POST['private']; // Is image public or not

Find:

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

REPLACE with:

            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:

            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:

            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:

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

REPLACE with:

    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:

?>

Add BEFORE

define('IMG_PUBLIC', 'Public Image');
define('IMG_PRIVATE', 'Private Image');

Open index.php

Find:

<div id="boton_subir">

Add After:

        <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:

<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:

<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>
 

Last edited by Danny.Domb (2011-03-17 19:51:13)

~ Sup?!

Thumbs up

Re: Image private or not

Excellent!! Here a Example http://chilepic.comoj.com/

Thanks ;D

PD: Friend, this lead me to create multiple servers on my image hosting I thank you

Last edited by GoodBay (2011-03-17 21:33:16)

Thumbs up

Re: Image private or not

If you added an gallery to your website, you could show all images in the images folder and keep others private  cool

~ Sup?!

Thumbs up

Re: Image private or not

I tested and it's good  big_smile

thank you Danny.Domb good job  wink

Thumbs up

Re: Image private or not

Yes, implemented it on my website too smile Works good and nice that you shared it  big_smile

Thumbs up

Re: Image private or not

There is a bug with thumbs of priv images.

For have it working u need to open engine.php

Find:

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

And replace with:

// 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);

wink

Last edited by Remedy Memory (2011-11-29 09:31:59)

Thumbs up

Re: Image private or not

huh is this working also for 2.0+ ?

Thumbs up

Re: Image private or not

Their is no way of making a chevereto 1.9 mod compatible with 2.0

~ Sup?!

Thumbs up

Re: Image private or not

well then can you make image private or not for 2.0 + ?
If it's not a problem of course...

Thumbs up

Re: Image private or not

It has been added on the roadmap of Chevereto for V 2.1...

So wait until then wink

~ Sup?!

Thumbs up

Re: Image private or not

oh ok, i didn't notice... smile
thanks big_smile

Thumbs up