<?php
/*
This quick script converts the character font array in the defaultFont.php
to a data array that is used by the cellCaptcha class to create the characters
use captcha output.
Look at the defaultFont.php if you want to modify the display characters
to your own liking or use it as an example to build your own font.
1. Just be sure when you run this script to require/include your character
font array like below where it says require('defaultFont.php').
2. Then when running the convert function, pass in the name of your character
font array like the one in the defaultFont.php.
3. Copy browser output of this script to replace the content of
fontmatrix.php that provides the array data that the cellCaptcha
class uses to build the captcha output.
*/
function dump($variable,$return = FALSE) {
if ( is_bool($variable) || !strlen($variable) ) {
if ($return == TRUE) {
printf( "<pre>%s</pre>", var_export($variable, true));
return TRUE;
}else
echo "<pre>", var_dump($variable), "</pre>";
}else{
if($return == TRUE){
return sprintf( "<pre>%s</pre>", print_r($variable, true));
}else{
printf( "<pre>%s</pre>", print_r($variable, true));
return TRUE;
}
}
}
require('defaultFont.php');
function convert($characterFonts){
foreach($characterFonts as $key => $value){
$value = trim($value);
$valArray = explode("\n",$value);
foreach($valArray as $line){
$bites[ ] = '.'.trim($line).'.';
}
}
$matrix = array_unique($bites);
sort($matrix);
foreach($characterFonts as $key => $value){
$value = trim($value);
$valArray = explode("\n",$value);
foreach($valArray as $line){
$line = trim($line);
$matrixKey = array_keys($matrix,'.'.$line.'.');
if( !is_numeric($matrixKey[0]) ) die("MISSING BITES KEY FOR ( $key ) & LINE IS: $line & matrixKey is {$matrixKey[0]}");
$characters[addslashes($key)][ ] = $matrixKey[0];
}
}
echo '<?php <br />';
foreach($characters as $key => $value){
echo "\$chars['".$key."'] = array( ";;
echo implode(',',$value);
echo " );<br />";
}
foreach($matrix as $key => $value){
echo "\$matrix[".$key."] = '".str_replace('.','',$value)."';<br />";
}
echo '?>';
}
convert($character);
?>