1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11: class Folks_Login_Form extends Horde_Form {
12:
13: function __construct($vars, $title = '', $name = null)
14: {
15: parent::__construct($vars, $title, $name);
16:
17: $this->addHidden('', 'url', 'text', Horde_Util::getFormData('url', '/'));
18: $this->setButtons(_("Login"));
19:
20: $this->addVariable(_("Username"), 'username', 'text', true, false,
21: sprintf(_("Enter the username you registered to %s"),
22: $GLOBALS['registry']->get('name', 'horde')), array('', 30, 26));
23:
24: $this->addVariable(_("Password"), 'password', 'password', true, false, _("Enter your password. Please be aware that password is case sensitive."));
25:
26: $v = &$this->addVariable(_("Remember login?"), 'loginfor', 'radio', true, false, null,
27: array(array('0' => _("No, only for this view"),
28: '1' => _("Yes, remember me so the next time I don't neet to login"))));
29: $v->setDefault('0');
30:
31: $username = $vars->get('username');
32: if ($GLOBALS['conf']['login']['tries']
33: && !empty($username)) {
34: $tries = (int)$GLOBALS['cache']->get('login_tries_' . $username, 0);
35: $GLOBALS['cache']->set('login_tries_' . $username, $tries + 1);
36: if ($tries >= $GLOBALS['conf']['login']['tries']) {
37: $desc = _("Please enter the text above");
38: $this->addVariable('Preverjanje:', 'captcha', 'captcha', true, false, $desc,
39: array($this->_getCAPTCHA(!$this->isSubmitted()), HORDE_BASE . '/config/couri.ttf'));
40: }
41: }
42: }
43:
44: 45: 46:
47: private function _getCAPTCHA($new = false)
48: {
49: global $session;
50:
51: if ($new || !$session->get('agora', 'login_captcha')) {
52: $captcha = '';
53: for ($i = 0; $i < 5; ++$i) {
54: $captcha .= chr(rand(65, 90));
55: }
56: $session->set('agora', 'login_captcha', $captcha);
57: }
58:
59: return $session->get('agora', 'login_captcha');
60: }
61:
62: }
63: