Exemplo n.º 1
0
 public static function returnCombo($comboString)
 {
     // Use regex to match everything between < and >
     preg_match_all("/\\<(.*?)\\>/si", $comboString, $match);
     // Loop through each result
     foreach ($match[1] as $extractedGenID) {
         // Access each generator contained with these tags and replace the original string
         $result = RandomGen::returnGenerator($extractedGenID);
         $comboString = str_replace("<" . $extractedGenID . ">", $result, $comboString);
     }
     return $comboString;
 }
<?php

session_start();
require '../includes/rand.php';
$randomObj = new RandomGen();
$str = $randomObj->createRandom();
$_SESSION['captcha_id'] = $str;
Exemplo n.º 3
0
<?php

require_once 'randomGen.php';
//$_SERVER["PHP_SELF"] the safe way!
$myForm = filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_SPECIAL_CHARS);
$myGenerator = new RandomGen();
$CouponLength = filter_input(INPUT_POST, 'CouponLength');
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
            <title>This is a testing random engine</title> 
    </head>
    <body>
        <form method="post" action="<?php 
echo $myForm;
?>
">
            <input type="text" name="CouponLength" value="<?php 
echo $CouponLength;
?>
">
            <input type="submit" name="submit" value="Click to Generate">
        </form>
        <p>This is what the button returns. A random set of characters. Like a coupon.</p>
        <p>
            <?php 
if (filter_has_var(INPUT_POST, 'CouponLength')) {
    echo $myGenerator->UseGenerator($CouponLength);
}