Login   Register  
PHP Classes
elePHPant
Icontem

File: TrackLoadedFiles.example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Max Nowack  >  Track Loaded Files  >  TrackLoadedFiles.example.php  >  Download  
File: TrackLoadedFiles.example.php
Role: Example script
Content type: text/plain
Description: how to use
Class: Track Loaded Files
Track and verify if page files were loaded
Author: By
Last change: changed "proof" to "track"
Date: 2 years ago
Size: 1,665 bytes
 

Contents

Class file image Download
<?php
/*******************************************
 * Author: Max Nowack                      *
 * Website: www.dasnov.de                  *
 * Classname: TrackLoadedFiles             *
 *******************************************
 * Description:                            *
 * The class track which files are loaded  *
 * from the client. With this class your   *
 * can make forms or sites securer.        *
 * Example:                                *
 * The client must load all external files *
 * they liked in the script (stylesheets,  *
 * images, etc.). Otherwise the next site  *
 * will not open.                          *
 *******************************************/

require("TrackLoadedFiles.class.php"); //load the class

//create the class-object
//1. parameter: link to the file which open the images or stylesheets (path to image-file will be attached)
//2. parameter: directory of the images or stylesheets
$plf = new TrackLoadedFiles("TrackLoadedFiles.example.php?file=","");

if(isset(
$_GET['file']))
{
    
//send the file to the browser
    
header("Content-Type: ".$plf->getMimeType($_GET['file']));
    echo 
$plf->load($_GET['file']);
}
elseif(isset(
$_GET['track']))
{
    
//track loaded files
    
if($plf->track())
    {
        echo 
"success";
    }
    else
    {
        echo 
"failed";
    }
}
elseif(isset(
$_GET['destroy']))
{
    
//destroy the session (just for test)
    
session_destroy();
    
header("Location: ".$_SERVER['PHP_SELF']);
}
else
{
    
//show the image and the link to the track-script
    
echo "<img src='".$plf->showLinkTo("test.png")."' /><br />";
    echo 
"<a href='".$_SERVER['PHP_SELF']."?track'>Show Result</a>";
}
?>