php.ini variable preventing fopen() - filesize() - fclose() functions?

Posted on 2008-01-31
Medium Priority
Last Modified: 2013-12-13
This is a openscript php code verification script that prevents auto entry where a human views alpha-numeric text and then types in what they see.

Works on different server, not the one copied to hence wondering if php.ini variables are the cause.

Url = http://americas-original.com/simg.php

Code =


 *                            Dolphin Web Community Software
 *                              -------------------
 *     begin                : Mon Mar 23 2006
 *     copyright            : (C) 2006 BoonEx Group
 *     website              : http://www.boonex.com

 *   This is a free software; you can modify it under the terms of BoonEx
 *   Product License Agreement published on BoonEx site at http://www.boonex.com/downloads/license.pdf
 *   You may not however distribute it for free or/and a fee.
 *   This notice may not be removed from the source code. You may not also remove any other visible
 *   reference and links to BoonEx Group as provided in source code.

require_once( "images.inc.php" );

$chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
$textstr = '';
for ($i = 0, $length = 5; $i < $length; $i++) {
   $textstr .= $chars[rand(0, count($chars) - 1)];
$hashtext = md5($textstr);

$_SESSION['strSec'] = $hashtext;

if ( produceSecurityImage( $textstr, $hashtext ) != IMAGE_ERROR_SUCCESS )
      // output header
      header( "Content-Type: image/gif" );
      // output error image
      $errorFilename = $ID_PIC_DIR . 'simg_error.gif';
      $fp = fopen( $errorFilename, 'r' );
      $fsize = filesize( $errorFilename );
      if ( $fp )
            print fread( $fp, $fsize );
      fclose( $fp );


Question by:qdcsinc
  • 2
LVL 19

Expert Comment

ID: 20789714
Most likely... safe_mode is on, and that prevents you from using fopen on files that are outside your include directories....  either turn safe_mode off, or add whatever $ID_PIC_DIR point to to your include directory
LVL 48

Expert Comment

ID: 20789718
Seems that function produceSecurityImage( $textstr, $hashtext ) returns an error

Can you post the content of images.inc.php?

Author Comment

ID: 20789839
I need to install the gd_library.


Do you know how to install the gd library and change php.ini settings?
LVL 19

Accepted Solution

darron_chapman earned 2000 total points
ID: 20789872
try uncommenting

extension=php_gd2.dll in your php.ini file

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question