Login   Register  
PHP Classes
elePHPant
Icontem

File: show.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of László Zsidi  >  Protector  >  show.php  >  Download  
File: show.php
Role: Example script
Content type: text/plain
Description: Thumbnail source
Class: Protector
Make it difficult to steal images from Web pages
Author: By
Last change:
Date: 2006-09-13 10:39
Size: 5,924 bytes
 

Contents

Class file image Download
<?
/*
+-------------------------------------------------+
+                                                 +
+        Show.php ver. 1.0 by László Zsidi        +
+     examples and support on http://gifs.hu      +
+                                                 +
+    This example can be used and distributed     +
+                 free of charge.                 +
+                                                 +
+-------------------------------------------------+
*/

class md5_encrypt
{
    var 
$ret;

    function 
md5_encrypt($plain_text$password$iv_len 16)
    {
        
$plain_text .= "\x13";
        
$n strlen($plain_text);
        if (
$n 16$plain_text .= str_repeat("\0"16 - ($n 16));
        
$i 0;
        
$enc_text $this->get_rnd_iv($iv_len);
        
$iv substr($password $enc_text0512);
        while (
$i $n)
        {
            
$block substr($plain_text$i16) ^ pack('H*'md5($iv));
            
$enc_text .= $block;
            
$iv substr($block $iv0512) ^ $password;
            
$i += 16;
        }
        
$this->ret base64_encode($enc_text);
    }

    function 
get_rnd_iv($iv_len)
    {
        
$iv '';
        while (
$iv_len-- > 0)
        {
            
$iv .= chr(mt_rand() & 0xff);
        }
        return 
$iv;
    }

    function 
ret()
    {
        return 
$this->ret;
    }
}

/*
:::::::::::::::::::::::::::::::::::::::::::::::::
::                                             ::
::             H O W  T O  U S E ?             ::
::                                             ::
::                                             ::
::  The keys are the images holder directory   ::
::   which created by multichars {A-Za-z0-9}   ::
::    and the html <span> style attribute      ::
::  <span stlye = "display:block; background:  ::
::       url(loader.php?' . $encrypted .       ::
::    '=' . $images[$_GET['thumb']] . ');">    ::
::                                             ::
::                                             ::
::                                             ::
::              Simple example:                ::
::                                             ::
:: Create a md5 encrypted string and construct ::
::   a <span> element inside a <img> element   ::
::                                             ::
::                                             ::
::                                             ::
:::::::::::::::::::::::::::::::::::::::::::::::::

PHP code:

$dir = "myimageholderdirectory1245678";
$psw = "mypasswordforencrypt/decrypt";
$md5_encrypt = new md5_encrypt($dir, $psw);
$encrypted = $md5_encrypt->ret();
$size = getImageSize($dir . "/image.gif");

HTML code:

<span style="display:block; background:url(loader.php?' . $encrypted . '=image.gif);">
 <img src="redirected/protector.gif" alt=""  width=' . $size[0] . ' height=' . $size[1] . '>
</span>

The protector.gif is a transparent gif and them size
resized by <img> with & height attributes.

Generated example html code:

<html>
 <span style="display:block;
     background:url(loader.php?RgY9sjDqJVvJ+KNvqDrMNpm/L2/LLESuXtH7bsrbdrDnbk18/Y7t1rEJjDaAhyfD=circle.gif);">
         <img src="redirected/protector.gif" alt="" width=198 height=114>
 </span>
</html>

:::::::::::::::::::::::::::::::::::::::::::::::::
::                                             ::
::        Call the loader.php as image         ::
::                                             ::
::                                             ::
::                                             ::
::           P R O T E C T I O N S :           ::
::                                             ::
:: -Disable disk file cache                    ::
:: -Disable 'right click,save as image...'     ::
:: -Disable images save by total web mirror    ::
:: -Disable view image by direct loader url    ::
:: -Set watermark on the images                ::
::                                             ::
:::::::::::::::::::::::::::::::::::::::::::::::::
*/

$dir "p_1225441_ABeffs";
$psw "protected_site";

$md5_encrypt = new md5_encrypt($dir$psw);
$encrypted $md5_encrypt->ret();

if(
$dh opendir($dir))
{
    while (
$file readdir($dh))
    {
        if ((
$file != ".") && ($file != ".."))
        {
            
$images[] = $file;
        }
    }
    
closedir($dh);
}

$k $_GET['thumb'] + 1;
$h $_GET['thumb'] - 1;

if(
$k == count($images)) $k 0;
if(
$h 0$h=count($images)-1;

if (isset(
$_GET['thumb']))
{
    
$size GetImageSize ($dir.'/'.$images[$_GET['thumb']]);
    
$html '
    <html>
     <head>
      <style type="text/css">
       a {font-family: Arial, Sans-serif, Verdana; font-size:11px; color:black; text-decoration:none;}
       a:hover {text-decoration:underline;}
      </style>
     </head>
    <p>
     <table align=center>
      <tr>
       <td align=center><span style="display:block; background:url(loader.php?' 
$encrypted '=' $images[$_GET['thumb']] . ');"><img src="redirected/protector.gif" alt="" width=' $size[0] . ' height=' $size[1] . '></span></td>
      </tr>
      <tr>
       <td align=center><b><a href=?thumb='
.$h.'>Previous image</a> | <a href="?thumb='.$k.'">Next image</a></b></td>
      </tr>
     </table>
    </p>
    </html>'
;
}
else
{
    
$size GetImageSize ($dir.'/'.$images[0]);
    
$html '
    <html>
     <head>
      <style type="text/css">
       a {font-family: Arial, Sans-serif, Verdana; font-size:11px; color:black; text-decoration:none;}
       a:hover {text-decoration:underline;}
      </style>
     </head>
    <p>
     <table align=center>
      <tr>
       <td align=center><span style="display:block; background:url(loader.php?' 
$encrypted '=' $images[0] . ');"><img src="redirected/protector.gif" alt="" width=' $size[0] . ' height=' $size[1] . '></span></td>
      </tr>
      <tr>
       <td align=center><b><a href="?thumb='
.$k.'">Next image</a></b></td>
      </tr>
     </table>
    </p>
    </html>'
;
}
echo 
$html;
?>