Thread View: pl.comp.lang.php
2 messages
2 total messages
Started by jivanmukta
Tue, 02 Dec 2014 18:45
captcha przestało mi działać
Author: jivanmukta
Date: Tue, 02 Dec 2014 18:45
Date: Tue, 02 Dec 2014 18:45
76 lines
3305 bytes
3305 bytes
Przestała mi działać captcha, mimo że kodu nie zmieniałem.
Wyświetlam ją tak:
Kontroler zawiera:
private function loadAnnouncementView(array $params) {
$params['captcha'] = $this->mycaptcha->deleteImage()->createWord()->createCaptcha();
$this->load->view('announcement/form', $params);
}
Widok zawiera:
<p>
<?php echo $captcha; ?>
Wpisz napis widoczny na obrazku:
<input type="text" name="captcha" maxlength="8" size="8" style="width: 8ex">
<?php echo myFormError('captcha'); ?>
</p>
libraries/mycaptcha.php ma treść:
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Mycaptcha {
public $word = '';
public $ci = '';
public function __construct() {
$ci =& get_instance();
$ci->load->helper('captcha');
$this->ci = $ci;
}
public function createWord() {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$word = '';
for ($a = 0; $a <= 5; $a++) {
$b = rand(0, strlen($chars) - 1);
$word .= $chars[$b];
}
$this->word = $word;
return $this;
}
public function createCaptcha() {
$cap = array(
'word' => $this->word,
'img_path' => './captcha/',
'img_url' => base_url() . 'captcha/',
'img_width' => '150',
'img_height' => '30',
'expiration' => '7200'
);
$captchaOutput = create_captcha($cap);
$this->ci->session->set_userdata(array('word' => $this->word, 'image' => $captchaOutput['time'] . '.jpg')); //set data to session for compare
return $captchaOutput['image'];
}
public function deleteImage() {
$image = $this->ci->session->userdata('image');
if (!empty($image)) {
$lastImage = FCPATH . 'captcha/' . $image;
if (file_exists($lastImage)) {
unlink($lastImage);
}
}
return $this;
}
}
Problem polega na tym,ze w wierszu
$captchaOutput = create_captcha($cap);
funkcja create_captcha zwraca FALSE.
Katalog public_html/captcha ma atrybuty:
drwxrwxr-x robert robert 4096 gru 2 19:24
Proszę o pomoc.
Re: captcha przestało mi działać
Author: Borys Pogoreło
Date: Wed, 10 Dec 2014 19:56
Date: Wed, 10 Dec 2014 19:56
14 lines
1339 bytes
1339 bytes
Dnia Tue, 2 Dec 2014 10:45:42 -0800 (PST), jivanmukta@poczta.onet.pl napisał(a): > Problem polega na tym,ze w wierszu Problem polega na tym, że mało gdzie w ogóle sprawdzasz zwracaną wartość. Nic dziwnego, że w takim kodzie coś przestaje działać i nie wiesz dlaczego. Zacznij sprawdzać wartości zwracane przez funkcje i zwiększ poziom raportowania błędów przynajmniej do E_NOTICE, to się pewnie dużo rzeczy wyjaśni. -- Borys Pogoreło borys(#)leszno,edu,pl
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads