mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-06-13 00:57:03 +02:00
rewrote php session variables
This commit is contained in:
@ -853,13 +853,13 @@ class Securimage
|
||||
try {
|
||||
$audio = $this->getAudibleCode();
|
||||
} catch (Exception $ex) {
|
||||
if (($fp = @fopen(dirname(__FILE__) . '/si.error_log', 'a+')) !== false) {
|
||||
fwrite($fp, date('Y-m-d H:i:s') . ': Securimage audio error "' . $ex->getMessage() . '"' . "\n");
|
||||
fclose($fp);
|
||||
if (($fp = @fopen(dirname(__FILE__) . '/si.error_log', 'a+')) !== false) {
|
||||
fwrite($fp, date('Y-m-d H:i:s') . ': Securimage audio error "' . $ex->getMessage() . '"' . "\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$audio = $this->audioError();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->canSendHeaders() || $this->send_headers == false) {
|
||||
if ($this->send_headers) {
|
||||
@ -890,15 +890,15 @@ class Securimage
|
||||
if (!$this->no_exit) exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the code from the session or sqlite database if used. If none exists yet, an empty string is returned
|
||||
*
|
||||
* @param $array bool True to receive an array containing the code and properties
|
||||
* @return array|string Array if $array = true, otherwise a string containing the code
|
||||
*/
|
||||
public function getCode($array = false, $returnExisting = false)
|
||||
{
|
||||
$code = '';
|
||||
/**
|
||||
* Return the code from the session or sqlite database if used. If none exists yet, an empty string is returned
|
||||
*
|
||||
* @param $array bool True to receive an array containing the code and properties
|
||||
* @return array|string Array if $array = true, otherwise a string containing the code
|
||||
*/
|
||||
public function getCode($array = false, $returnExisting = false)
|
||||
{
|
||||
$code = '';
|
||||
$time = 0;
|
||||
$disp = 'error';
|
||||
|
||||
@ -911,31 +911,31 @@ class Securimage
|
||||
} else {
|
||||
return $this->code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->no_session != true) {
|
||||
if (isset($_SESSION['securimage_code_value'][$this->namespace]) &&
|
||||
trim($_SESSION['securimage_code_value'][$this->namespace]) != '') {
|
||||
if ($this->isCodeExpired(
|
||||
$_SESSION['securimage_code_ctime'][$this->namespace]) == false) {
|
||||
$code = $_SESSION['securimage_code_value'][$this->namespace];
|
||||
$time = $_SESSION['securimage_code_ctime'][$this->namespace];
|
||||
$disp = $_SESSION['securimage_code_disp'] [$this->namespace];
|
||||
}
|
||||
if ($this->no_session != true) {
|
||||
if (isset($_SESSION['securimage_code_value'][$this->namespace]) &&
|
||||
trim($_SESSION['securimage_code_value'][$this->namespace]) != '') {
|
||||
if ($this->isCodeExpired(
|
||||
$_SESSION['securimage_code_ctime'][$this->namespace]) == false) {
|
||||
$code = $_SESSION['securimage_code_value'][$this->namespace];
|
||||
$time = $_SESSION['securimage_code_ctime'][$this->namespace];
|
||||
$disp = $_SESSION['securimage_code_disp'] [$this->namespace];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($code) && $this->use_database) {
|
||||
// no code in session - may mean user has cookies turned off
|
||||
$this->openDatabase();
|
||||
$code = $this->getCodeFromDatabase();
|
||||
} else { /* no code stored in session or sqlite database, validation will fail */ }
|
||||
|
||||
if ($array == true) {
|
||||
return array('code' => $code, 'ctime' => $time, 'display' => $disp);
|
||||
} else {
|
||||
return $code;
|
||||
}
|
||||
if (empty($code) && $this->use_database) {
|
||||
// no code in session - may mean user has cookies turned off
|
||||
$this->openDatabase();
|
||||
$code = $this->getCodeFromDatabase();
|
||||
} else { /* no code stored in session or sqlite database, validation will fail */ }
|
||||
|
||||
if ($array == true) {
|
||||
return array('code' => $code, 'ctime' => $time, 'display' => $disp);
|
||||
} else {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1378,24 +1378,24 @@ class Securimage
|
||||
header("Pragma: no-cache");
|
||||
}
|
||||
|
||||
switch ($this->image_type) {
|
||||
case self::SI_IMAGE_JPEG:
|
||||
if ($this->send_headers) header("Content-Type: image/jpeg");
|
||||
imagejpeg($this->im, null, 90);
|
||||
break;
|
||||
case self::SI_IMAGE_GIF:
|
||||
if ($this->send_headers) header("Content-Type: image/gif");
|
||||
imagegif($this->im);
|
||||
break;
|
||||
default:
|
||||
if ($this->send_headers) header("Content-Type: image/png");
|
||||
imagepng($this->im);
|
||||
break;
|
||||
switch ($this->image_type) {
|
||||
case self::SI_IMAGE_JPEG:
|
||||
if ($this->send_headers) header("Content-Type: image/jpeg");
|
||||
imagejpeg($this->im, null, 90);
|
||||
break;
|
||||
case self::SI_IMAGE_GIF:
|
||||
if ($this->send_headers) header("Content-Type: image/gif");
|
||||
imagegif($this->im);
|
||||
break;
|
||||
default:
|
||||
if ($this->send_headers) header("Content-Type: image/png");
|
||||
imagepng($this->im);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
echo '<hr /><strong>'
|
||||
.'Failed to generate captcha image, content has already been '
|
||||
.'output.<br />This is most likely due to misconfiguration or '
|
||||
} else {
|
||||
echo '<hr /><strong>'
|
||||
.'Failed to generate captcha image, content has already been '
|
||||
.'output.<br />This is most likely due to misconfiguration or '
|
||||
.'a PHP error was sent to the browser.</strong>';
|
||||
}
|
||||
|
||||
@ -1943,10 +1943,10 @@ class Securimage
|
||||
if ($this->audio_gap_max > 0 && $this->audio_gap_max > $this->audio_gap_min) {
|
||||
$wavCaptcha->insertSilence( mt_rand($this->audio_gap_min, $this->audio_gap_max) / 1000.0 );
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
} catch (Exception $ex) {
|
||||
// failed to open file, or the wav file is broken or not supported
|
||||
// 2 wav files were not compatible, different # channels, bits/sample, or sample rate
|
||||
throw $ex;
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2038,18 +2038,18 @@ class Securimage
|
||||
*
|
||||
* @return bool true if headers haven't been sent and no output/errors will break audio/images, false if unsafe
|
||||
*/
|
||||
protected function canSendHeaders()
|
||||
{
|
||||
if (headers_sent()) {
|
||||
// output has been flushed and headers have already been sent
|
||||
return false;
|
||||
} else if (strlen((string)ob_get_contents()) > 0) {
|
||||
// headers haven't been sent, but there is data in the buffer that will break image and audio data
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
protected function canSendHeaders()
|
||||
{
|
||||
if (headers_sent()) {
|
||||
// output has been flushed and headers have already been sent
|
||||
return false;
|
||||
} else if (strlen((string)ob_get_contents()) > 0) {
|
||||
// headers haven't been sent, but there is data in the buffer that will break image and audio data
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random float between 0 and 0.9999
|
||||
|
Reference in New Issue
Block a user