function generateImage($token) { $fig = new phpFiglet(); if (!$fig->loadFont('saf/lib/Ext/phpfiglet/fonts/' . $this->font)) { $this->error = 'Failed to load font file.'; return false; } return $fig->fetch($token); }
/** * Returns the HTML to display the CAPTCHA with the chosen method */ public function getHTML() { global $ID; $rand = (double) rand(0, 10000) / 10000; if ($this->getConf('mode') == 'math') { $code = $this->_generateMATH($this->_fixedIdent(), $rand); $code = $code[0]; $text = $this->getLang('fillmath'); } elseif ($this->getConf('mode') == 'question') { $text = $this->getConf('question'); } else { $code = $this->_generateCAPTCHA($this->_fixedIdent(), $rand); $text = $this->getLang('fillcaptcha'); } $secret = $this->encrypt($rand); $txtlen = $this->getConf('lettercount'); $out = ''; $out .= '<div id="plugin__captcha_wrapper">'; $out .= '<input type="hidden" name="' . $this->field_sec . '" value="' . hsc($secret) . '" />'; $out .= '<label for="plugin__captcha">' . $text . '</label> '; switch ($this->getConf('mode')) { case 'math': case 'text': $out .= $this->_obfuscateText($code); break; case 'js': $out .= '<span id="plugin__captcha_code">' . $this->_obfuscateText($code) . '</span>'; break; case 'image': $out .= '<img src="' . DOKU_BASE . 'lib/plugins/captcha/img.php?secret=' . rawurlencode($secret) . '&id=' . $ID . '" ' . ' width="' . $this->getConf('width') . '" height="' . $this->getConf('height') . '" alt="" /> '; break; case 'audio': $out .= '<img src="' . DOKU_BASE . 'lib/plugins/captcha/img.php?secret=' . rawurlencode($secret) . '&id=' . $ID . '" ' . ' width="' . $this->getConf('width') . '" height="' . $this->getConf('height') . '" alt="" /> '; $out .= '<a href="' . DOKU_BASE . 'lib/plugins/captcha/wav.php?secret=' . rawurlencode($secret) . '&id=' . $ID . '"' . ' class="JSnocheck" title="' . $this->getLang('soundlink') . '">'; $out .= '<img src="' . DOKU_BASE . 'lib/plugins/captcha/sound.png" width="16" height="16"' . ' alt="' . $this->getLang('soundlink') . '" /></a>'; break; case 'figlet': require_once dirname(__FILE__) . '/figlet.php'; $figlet = new phpFiglet(); if ($figlet->loadfont(dirname(__FILE__) . '/figlet.flf')) { $out .= '<pre>'; $out .= rtrim($figlet->fetch($code)); $out .= '</pre>'; } else { msg('Failed to load figlet.flf font file. CAPTCHA broken', -1); } break; } $out .= ' <input type="text" size="' . $txtlen . '" name="' . $this->field_in . '" class="edit" /> '; // add honeypot field $out .= '<label class="no">' . $this->getLang('honeypot') . '<input type="text" name="' . $this->field_hp . '" /></label>'; $out .= '</div>'; return $out; }
function get_ascii($type, $bigtext, $smalltext, $font) { $line = ''; $options = $this->get_options(); // check cache if ($options[$type]['bigtext'] == $bigtext && $options[$type]['font'] == $font) { $line = $options[$type]['line']; } else { if ($bigtext) { require "phpfiglet_class.php"; $phpFiglet = new phpFiglet(); if ($phpFiglet->loadFont(dirname(__FILE__) . '/fonts/' . $font)) { $line = $phpFiglet->fetch($bigtext); } else { $line = "Could not load font file"; } $options[$type]['bigtext'] = $bigtext; $options[$type]['font'] = $font; $options[$type]['line'] = $line; update_option($this->DB_option, $options); } } return $line; }
* | _||_|_|| _||__| |_||_ ||_||___||_| * |_| |_| |___| * * This script opens the supplied font directory and * shows a line of text in every available font * */ require "phpfiglet_class.php"; $out = ""; $phpFiglet = new phpFiglet(); if ($handle = opendir('fonts')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if ($phpFiglet->loadFont("fonts/" . $file)) { $out .= $file . "\n"; $out .= $phpFiglet->fetch("Hello World"); $out .= "\n\n"; } } } closedir($handle); } ?> <html> <body> <pre> <?php print $out; ?> <pre> </body>