Posted by sarapeter on April 20, 2009
Short open tags not work in php5.2.0 and not in php5.2.3
My advice was to put short_open_tag = On in the php.ini file.
The server status is short_open_tag = Off
I set this to short_open_tag = On in the php.ini file in the root of the site.
This did not work but when I renamed the php.ini file to php5.ini this corrected this issue.
However I did not immediately notice but this blocked out the server php.ini file – this start a major component working as it also blocked out zend optimizer.
I have read more about the issue of the short tag.
I have in my limited experience of php coding always used <!–p and not <?
There appears to be a number opinions that setting short_open_tag = On can cause problems where there are xml files as attempts will be made to parse these.
I have been through every php file in the component – I can’t find a short code anywhere in the files.
Posted in Php Codes, Php Errors, Php Security | Tagged: PHP, Php5, Short Open Tags, short_open_tag | Leave a Comment »
Posted by sarapeter on March 26, 2009
Php Fatal error: Allowed memory size of 8388608 bytes exhausted
This error message can spring up in a previously functional PHP script when the memory requirements exceed the default 8MB limit. Don’t fret, though, because this is an easy problem to overcome.
To change the memory limit for one specific script by including a line such as this at the top of the script:
ini_set("memory_limit","12M");
The 12M sets the limit to 12 megabytes (12582912 bytes). If this doesn’t work, keep increasing the memory limit until your script fits or your server squeals for mercy.
You can also make this change permanently for all PHP scripts running on the server by adding a line like this to the server’s php.ini file:
memory_limit = 12M
Keep in mind that a huge memory limit is a poor substitute for good coding. A poorly written script may inefficiently squander memory which can cause severe problems for frequently executed scripts. However, some applications are run infrequently and require lots of memory like importing and processing a big data file.
Posted in Php Codes, Php Errors, Php Functions, Php Methods, Php Security | Tagged: error, exhausted, Fatal error, memory, PHP | Leave a Comment »
Posted by sarapeter on July 4, 2008
<?php
session_start();
http://www.white-hat-web-design.co.uk/articles/php-captcha.phphttp://www.gnu.org/licenses/gpl.html
class CaptchaSecurityImages {
var $font = 'monofont.ttf';
function generateCode($characters) {
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}
function CaptchaSecurityImages($width='120',$height='40',$characters='6') {
$code = $this->generateCode($characters);
$font_size = $height * 0.75;
$image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
for( $i=0; $i<($width*$height)/3; $i++ ) {
imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
}
for( $i=0; $i<($width*$height)/150; $i++ ) {
imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
}
$width = isset($_GET['width']) && $_GET['height'] < 600 ? $_GET['width'] : '120';
$height = isset($_GET['height']) && $_GET['height'] < 200 ? $_GET['height'] : '40';
$characters = isset($_GET['characters']) && $_GET['characters'] > 2 ? $_GET['characters'] : '6';
$captcha = new CaptchaSecurityImages($width,$height,$characters);
?>
Download Link
Posted in Php Security | Tagged: PHP, Captcha, Security, Images, Anti Spamming | Leave a Comment »