PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
  Classes of Alexandru Ocheana  >  PHP Image Based Login  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example file
Class: PHP Image Based Login
Authenticate users using colored images
Author: By
Last change:
Date: 5 years ago
Size: 2,440 bytes
 

 

Contents

Class file image Download
<?php
/**
 * This login system is the intellectual property of Alexandru Ocheana
 * You can modify anything, you can use any algorithm as you wish
 * If you have any ideas which will improve this class, or you have any question please contact me at
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * alexandru.ocheana@gmail.com (Language: english or roumanian)
 * Please respect my work and don't modify this header.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *
 * This stands as DEMO for my NEXT GENERATION LOGIN SYSTEM
 */
spl_autoload_register(function ($class){
   include_once(
"class." . $class . ".php");
});

/**
 * create the image with given width and height
 */
$image = new Image(200, 200);

/**
 * return the settings
 * array:
 * settings["width"]
 * settings["height"]
 * settings["time"] -> save this as registration timestamp. It is ussing microtime() by default
 * settings["path"]
 */
$settings = $image->showSettings();

/**
 * convert settings["time"] to RGB colors
 */
$timeconvertor = new TimeConvertor($settings["time"]);


/**
 * array of colors based on microtime
 */
$pixelRGB = $timeconvertor->showPixelRGB();


/**
 * create position grid for hotPixels generated from microtime
 */
$positions = new Positioner($settings["width"], $settings["height"]);


/**
 * return the position Map to feed the HotPixel creator class
 */
$positionMap = $positions->showPositionMap();

/**
 * generate the hotPixels based on pixel RGB intensity converted from time and position map
 */
$hotPixel = new HotPixel($pixelRGB, $positionMap);

/**
 * return the all hotPixel map
 */
$pixelMap = $hotPixel->showPixelMap();

/**
 * generate the registration key.
 */
$image->createImage($pixelMap);

/**
 * give the key to user for download
 */
echo "<br><a href=\"".$settings["path"]."\" download=\"myimage.png\">download</a><br>";



echo
"buildMatrix:<br>";
echo
"<pre>";
var_dump($settings);
echo
"</pre>";
echo
"<pre>";

/**
 * image matrix. Please save this into your database
 * return array:
 * imageMatrix["matrix"]
 * imageMatrix["md5"]
 */
var_dump($image->buildMatrix());
echo
"</pre>";


/**
 * check if the image is the real key
 */
$checker = new Checker($settings["path"]);
echo
"<br>";
echo
"<pre>";
var_dump($checker->buildMatrix());
echo
"</pre>";