Animal Captcha Maker '; if (!is_writable($ac_dir)) { echo ''; } $txt_accion = ''; if (!isset($_REQUEST['a'])) { $_REQUEST['a'] = false; } // delete notice error switch ($_REQUEST['a']) { // a = make action case 'mod_name': chdir($ac_dir); $dir = opendir('.'); while (($file = readdir($dir)) !== false) { if ((strpos($file,$_POST['name'].'_') !== false) OR (strpos($file,$_POST['name'].'.') !== false)) { $file_new = ereg_replace("[^a-z-]", "", strtolower(str_replace('--', '-', eregi_replace("[\n|\r|\n\r]", '-', $_POST['name_new'])))); if ($file_new != '') { $file_new = str_replace($_POST['name'], $file_new, $file); rename($file, $file_new); $txt_accion .= 'File change: '.$file.' --> '.$file_new.'
'; } } } closedir($dir); chdir('../'); break; case 'add_image': echo '

Add new image

1. Select animal name:
or create new animal: Only letters [a-z].

2. Select image:   Search here in Google Images (creative commons)
IMG URL: (only .jpg)

'; exit; break; case 'pre_process_image': if ($_POST['animal_url'] != 'http://') { if ($_POST['animal_select'] == 'new') { $animal_name = str_replace(' ', '-', trim(strtolower($_POST['animal_text']))); } else { $animal_name = $_POST['animal_select']; } $data = @file_get_contents($_POST['animal_url']); if ($data) { $n = 1; while ($n != false) { $final_name_root = ($in_wp?$ac_dir:$ac_dir_img).$animal_name.($n==1?'':'_'.$n).'.jpg'; $final_name = $ac_dir_img.$animal_name.($n==1?'':'_'.$n).'.jpg'; if (!file_exists($final_name_root)) { $n = false; } $n++; } $file = @fopen($final_name_root, "w+"); @fputs($file, $data); @fclose($file); } echo '

Crop image


x y - Width px Height px

Some images are cropped mistaken for a strange bug. In future versions will fix the problem. '; } exit; break; case 'process_img': $src = $_POST['img_url']; list($width_orig, $height_orig) = getimagesize($src); if (!$_POST['h']) { $_POST['x'] = 0; $_POST['y'] = 0; $_POST['w'] = $width_orig; $_POST['h'] = $height_orig; } $height_new = 120; $width_new = 120; $img_r = imagecreatefromjpeg($src); $dst_r = ImageCreateTrueColor($width_new, $height_new); imagecopyresampled($dst_r, $img_r, 0,0, $_POST['x'],$_POST['y'], $width_new,$height_new, $_POST['w'],$_POST['h']); @imagejpeg($dst_r, $src, 80); $txt_accion = 'Image created: '.$src.' '; break; case 'borrar': @unlink($_GET['imagen']); break; } $width = 120; $jpg_quality = 75; // gen images list chdir($ac_dir); $dir = opendir('.'); while (($file = readdir($dir)) !== false) { $ext = explode('.', $file); if ((isset($ext[1])) && ($ext[1] == 'jpg') && (is_file($file))) { $animal = explode('_', $ext[0]); $animal = $animal[0]; $animals_array[$animal][$file] = true; } } closedir($dir); chdir('../'); //var_dump($animals_array); echo '

'.$txt_accion.'

List of images:

  Total: '.(count($animals_array, COUNT_RECURSIVE) - count($animals_array)).' animals ('.count($animals_array).' differents).   (Try test) (Send opinion or problem) '; foreach ($animals_array AS $animal => $none1) { echo ''; } echo '
'; $num_animals = 0; foreach ($animals_array[$animal] AS $animals => $none2) { echo ' '; $num_animals++; } $num_names = explode('-', $animal); $num_names = count($num_names); echo '
'.$num_animals.' images
'.$num_names.' names
'; } else { echo 'Access error: set active "true" in "source/animal-captcha-maker.php" file.'; } ?>