Jump to content

Photo
* * * * * 1 votes

[Solution] Improving secure.php with Random Math


  • Please log in to reply
1 reply to this topic

#1 xblitz

xblitz

    Level 1

  • Members
  • Level
  • 48 points
  • 20 posts


Users Awards

Posted 28 December 2012 - 11:31 AM

Open images/secure.php

copy code below and replace your images/secure.php
<?php
if(!function_exists('gd_info')) { exit(); }

//session_start();

header("Cache-Control: no-cache"); 
header("Content-type: image/png"); 

chdir('..');
include "header.php";

$img_handle = @ImageCreate(120, 20); 
$back_color = @ImageColorAllocate($img_handle, 255, 255, 255);
$transparent_bg = @ImageColorTransparent($img_handle, $back_color);

$count = 0;
$code = "";
$answer = "";


  $count++;
  $x_axis = -5 + ($count * 10);
  $y_axis = rand(0, 7);
  $color1 = rand(001, 150);
  $color2 = rand(001, 150);
  $color3 = rand(001, 150);
  $txt_color[$count] = @ImageColorAllocate($img_handle, $color1, $color2, $color3); 
  $size = 6;
  $number = rand(0,20); // Adjusting random number from 0 - 20
  $number2 = rand(0,20); // Adjusting random number from 0 - 20
  $question = "$number + $number2 = ?"; // Set Question
  $answer .= $number+$number2; // Equals question
  
  @ImageString($img_handle, $size, $x_axis, $y_axis, "$question", $txt_color[$count]); 


$pixel_color = @ImageColorAllocate($img_handle, 100, 100, 100); 

$_SESSION['answer'] = $answer; // Store answer
if( !isset($_SESSION['codes']) ) $_SESSION['codes'] = array();
$_SESSION['codes'][] = array(
  'expires' => time() + 300,
  'code' => $answer
);
@ImagePng($img_handle); 
exit();
?>


open signup.php

find


// NOW IN HEADER
//session_start();
$code = $_SESSION['code'];


replace it to

// NOW IN HEADER
//session_start();
$code = $_SESSION['answer'];

Hope improving your site from Spam Bot

Regards,
malaysiawap

#2 paulsj

paulsj

    Level 7

  • Premium
  • Level
  • 377 points
  • 1,255 posts


Users Awards

Posted 09 August 2013 - 03:00 AM

This is for 3.18 or less. Can you revise for 3.20 or higher?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


All the resources listed here are just for testing purpose and they shouldn't be used at any commercial environment without a valid license.
Those are for users who wants to try them before buy. Help the developer to build it better by purchasing them from original authors.