|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-04-27 15:06 UTC] jimw@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 22:00:01 2025 UTC |
Hi, I'd like to see support for a configuration variable which enables developers, to set a negative value (ie - a negative numeric value, not a string starting with a - sign or an intval("-5abc")) to resolve to FALSE. This would make error_handling using constants so much easier. Example: <? define(FILE_NOT_IN_INC=-1); define(INVALID_FILE_REQUEST=-2); $errors=array( 'unknown error', 'Invalid installation. Please contact your administrator. File not in designated include dir', 'Invalid installation. Please contact your administrator. Filename is invalid'); class definition { ... function do_includes() { //______Centralize security checks in the main configuration object $functions_file=$this->appname.'.functions.php'; if(file_exists($this->inc_dir.'/'.$functions_file)) { if(!ereg("^(\.|/)", $functions_file)) { //___assume $this->inc_dir is in php_include_path, but eliminate security threat, that '.' is prefered over $this->inc_dir. include $functions_file; } else { return INVALID_FILE_REQUEST; } } else { return FILE_NOT_IN_INC; } } } $instance=new definition; $ok=$instance->do_includes(); if(!$ok) { mail($instance->admin, "Installation problem your_app", "$SCRIPT_NAME - __LINE__ - $ok"); die($errors[abs($ok)]; } ?>