示例#1
0
文件: snews.php 项目: retrofox/PCC
function login()
{
    if (!_ADMIN) {
        echo '<div class="adminpanel">
		<h2>' . l('login') . '</h2>';
        echo html_input('form', '', 'post', '', '', '', '', '', '', '', '', '', 'post', _SITE . 'administration/', '');
        echo '<p>' . l('login_limit') . '</p>';
        echo html_input('text', 'uname', 'uname', '', l('username'), 'text', '', '', '', '', '', '', '', '', '');
        echo html_input('password', 'pass', 'pass', '', l('password'), 'text', '', '', '', '', '', '', '', '', '');
        echo mathCaptcha();
        echo '<p>';
        echo html_input('hidden', 'Loginform', 'Loginform', 'True', '', '', '', '', '', '', '', '', '', '', '');
        echo html_input('submit', 'submit', 'submit', l('login'), '', 'button', '', '', '', '', '', '', '', '', '');
        echo '</p></form></div>';
    } else {
        echo '<h2>' . l('logged_in') . '</h2>
			<p><a href="' . _SITE . 'logout/" title="' . l('logout') . '">' . l('logout') . '</a></p>';
    }
}
示例#2
0
 /**
  * Erzeugt die Rechenaufgabe
  *
  * @return	string	$fileName	Gibt die Rechenaufgabe als String für den Dateinamen wieder
  */
 public static function showCaptcha()
 {
     /**
      * Method to generate captcha
      *
      * @param $im
      * @param $size
      * @param $fileTTF
      * @param $imgHeight
      *
      * @return string	$fileName	Gibt die Rechenaufgabe als String für den Dateinamen wieder
      */
     function mathCaptcha($im, $size, $fileTTF, $imgHeight)
     {
         $math = range(0, 9);
         shuffle($math);
         $mix = range(0, 120);
         shuffle($mix);
         $color = imagecolorallocate($im, $mix[0], $mix[1], $mix[2]);
         $text = "{$math['0']} + {$math['1']}";
         $fileName = $math[0] + $math[1];
         imagettftext($im, $size, 0, 5, 25, $color, $fileTTF, $text);
         return $fileName;
     }
     // TTF-Schrift
     // Sie sollten hier unbedingt den absoluten Pfad angeben, da ansonsten
     // eventuell die TTF-Datei nicht eingebunden werden kann!
     $fileTTF = JPATH_COMPONENT_SITE . '/assets/ttf/style.ttf';
     // Verzeichnis für die Captcha-Bilder (muss Schreibrechte besitzen!)
     // Ausserdem sollten in diesem Ordner nur die Bilder gespeichert werden
     // da das Programm in regelmaessigen Abstaenden dieses leert!
     // Kein abschliessenden Slash benutzen!
     $captchaDir = JPATH_COMPONENT_SITE . '/assets/capimgdir';
     // Schriftgröße Rechenaufgabe
     $sizeMath = 20;
     //Bildgroesse
     $imgWidth = 80;
     //200
     $imgHeight = 30;
     //80
     header("Content-type: image/png");
     $im = @imagecreate($imgWidth, $imgHeight) or die("GD! Initialisierung fehlgeschlagen");
     $color = imagecolorallocate($im, 255, 255, 255);
     imagefill($im, 0, $imgWidth, $color);
     $fileName = mathCaptcha($im, $sizeMath, $fileTTF, $imgHeight);
     // Uebermittelter Hash-Wert ueberpruefen
     if (!preg_match('/^[a-f0-9]{32}$/', $_GET['codeCaptcha'])) {
         $_GET['codeCaptcha'] = md5(microtime());
     }
     // Image speichern
     imagepng($im, $captchaDir . '/' . $_GET['codeCaptcha'] . '_' . $fileName . '.png');
     imagedestroy($im);
     // Bild ausgeben
     readfile(JURI::base() . 'components/com_bwpostman/assets/capimgdir/' . $_GET['codeCaptcha'] . '_' . $fileName . '.png');
 }