Hits : 6691

Contents


captcha


Έγραψα μία captcha[link1] function με όνομα paptcha
I wrote a php function for capthca by the name papthca

Παίρνει 2 ορίσματα,
  1. Ο αριθμός των ψηφίων του αριθμού captcha που θέλουμε να παράγουμε (για παράδειγμα 3 σημαίνει ένας αριθμός της μορφής 123)
  2. Ο αριθμος των παραγόμενων επιλογών

It takes 3 arguments,
  1. The digits number for the captcha number (for example 3 is for a number like 123)
  2. The number of numbers to select.

Αρχικές τιμές είναι οι παρακάτω:
  1. ψηφία = 1 (αυτό σημαίνει έναν αριθμό μεταξύ του 0 και του 9)
  2. επιλογές = 2 (To λιγότερο 2)

Default values are:
  1. Digits = 1 (this is a number between 0 to 9)
  2. Choices = 2 (At least 2)

Επιστρέφει:

Returns:

Τι πρέπει να γίνουν:

ToDO:

top

Source


Παρακάτω είναι ο κώδικας (ημιτελής ακόμα)
Below is the source code (not complete yet)

Version 0.0.2


<?php

function paptcha() {

error_reporting E_ERROR );

  if (
is_int(func_get_arg(0)) && abs(func_get_arg(0)) < 10)
    
$dig abs(func_get_arg(0));
  else
    
$dig 1;

  if (
is_int(func_get_arg(1)) && abs(func_get_arg(1)) < 10 && abs(func_get_arg(1)) > 1)
    
$chs abs(func_get_arg(1));
  else
    
$chs 2;

 for(
$i 0$i $dig$i++)
   
$res .= rand(09);

 
// I put the result to first position of the choice array
 
$choices[0] = $res;

 
// File the choice array with options (numbers)
 
for($k 1$k $chs$k++)
   for(
$i 0$i $dig$i++)
     
$choices[$k] .= rand(09);

  
// Mix up a little the numbers
  
shuffle ($choices);

/*
 * I put the result to the final position of the choice array.
 * Now we know that one of the results of the array is our Captcha Choice
 * and we can verify the answer with the last number of the array
 */
  
$choices[$k] = $res;
 return(
$choices);
//end of func
?>


top

Demo


Παρακάτω είναι ένα παράδειγμα του paptcha:

Below is an online demo example for paptcha:

https://balaskas.gr/paptcha/

top



Links
[link1] http://en.wikipedia.org/wiki/Captcha