Image

Imagetrg_lazurus wrote in Imagephp

Authenticate This!

I figured it out. Apparently I had to define my functions outside of the if statement.

Okay... here's the problem.

I have a script that works fine unless I put in some password authentication.  What's happening is that one of my functions is becoming "undefined" once I throw it into an if statement.  In the cut below, you'll see where the authentication ends and the script begins.  I have a feeling it has something to do with globals, but I'm not entirely sure.  Anyone have any ideas?



<?
include("../config.php");
include("../lib/template_class.php");


//Starting the session and using the information.
session_start();
$session=session_id();
$username=$_SESSION['username'];
$password=$_SESSION['password'];



//Calling the database for login/password information.
$result = mysql_query("select * from users where username='$username' AND password='$password' limit 1");
$get_userinfo = @mysql_fetch_array($result);


//Applying DB results to variables.
$username=$get_userinfo[username];
$password=$get_userinfo[password];
$uid = $get_userinfo[id];


//login null checks
if($username=="" AND $password=="" OR $password==""){
	$page = new Page('../template/login.php');
	$page->replace_tags(array(
		'scriptName' => "$scriptName",
		'msg' => "Invalid login or password. Please try again.",
		'footer' => '$footer'));
	$page->output();

	session_destroy();
}else{

##############################################################################
#     									 #
#				   This is the end of the authorizing checks.			     #								 #
#	The user is logged in properly and will now access the page's content.	 #
#									 #
##############################################################################


		if( function resizer_main call here );


		        function resizer_main($image, $dest_file_prefix,$w, $h){
			global $use_imagecreatetruecolor, $use_imagecopyresampled, $IMG_ROOT, 
					$JPG_QUALITY, $HTTP_POST_FILES, $dontResizeMyImage;
					$image_name = $HTTP_POST_FILES [$image]["name"];
					$image = $HTTP_POST_FILES [$image]["tmp_name"];

			if(trim($image) == "" || trim($image) == "none") return false;

				$arr_img = image_from_upload($image);

				if( $arr_img["w"] > $w || $arr_img["h"] > $h){

					$wh = get_sizes($arr_img["w"], $arr_img["h"], $w, $h);
					$img_res = img_get_resized($arr_img["img"], $arr_img["w"], $arr_img["h"], $wh["w"], $wh["h"], $use_imagecreatetruecolor, $use_imagecopyresampled);

				} else {

					//wow it is exactly like needed!!!
					$img_res = $arr_img["img"];
				}

				
##############################################################################
#									 #
#		 Nothing passed this point will be authorized.		   #				##                  Take caution as to what is added beyond                   #
#			this point as it will be executed                      #
#		        without being authorized!		 #
#									#
##############################################################################
}
?>