Jump to content

PHP authentication page executing without being called


Cobalt-Phoenix

Recommended Posts

Hello all, I have been working with PHP for almost a year now, so somewhat still new to it all.

 

OK, this may be an Apache issue, but this involves a php script I wrote that tries to execute on pages that do NOT call it (via the include command).

 

So, here is a little info on how I have set things up.

 

I use WAMP Server to test php and MySQL code for myself (for fun and for practice) and for clients and their web sites. I run WAMP Server off of my laptop, so I can code on the go and because it is on my laptop, I decided to create a PHP & MySQL user authentication setup to keep out unwanted visitors, but allow trusted friends and fellow developers to view my work on client web sites. Let's say the authentication script is called "auth.php" and for all of the pages I want private, I include that script at the top of those pages, if the visitor is not logged in, redirect them to the login page, otherwise, let them view the page (provided their permission level is adequate).

 

Now, for the client web sites that I am working on, I do not call auth.php anywhere on those pages. Now, the problem I notice is that when I visited a client's web site that I am working on (on my WAMP Server), I reviewed my Apache error log and it gave me a PHP error stating the following:

 

Maximum execution time of 60 seconds exceeded in E:\\wamp\\www\\assets\\auth.php on line 3, referer: http://192.168.1.4/Web_Projects/NCCCLP/home.php

 

Of course I am able to view the client web site pages without having to login, however, the auth.php script tries to run nonetheless.

 

So my question is, does anyone know why this is happening and if and how I can stop it? This is not a serious (urgent) issue, but it does clog up my error logs and so forth and I prefer to have as few errors as possible. Plus, I would just like to know why and how it is running without being called.

 

Any and all help is greatly appreciated and if I need to provide anymore details or be more specific, please let me know.

Also, if an issue like this has already been solved and I missed that thread, please let me know and have my apologies.

 

Thanks in advance.

Link to comment
Share on other sites

Unless you have set php's auto_prepend_file directive to always include this file, you MUST be including it within home.php somehow.

Hi, thanks for replying.

 

As to the auto_prepend_file directive, this is what my php.ini file has:

 

; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file =

 

This is the default setting for this directive, I never messed with this one yet. As you can see, it is not set to prepend any page.

 

As to the home.php, here is the code for it (as you can see, it's php lite).

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">



<head>

<title>North Carolina Community College Leadership Program (NCCCLP)</title>
<link rel="stylesheet" type="text/css" href="main.css" />
<script language="JavaScript" src="scripts.js"></script>
<link rel="shortcut icon" href="favicon.ico" type="image/ico" />

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie-only.css" />
<![endif]-->

<style type="text/css">
	.menu ul li a.homeActive {
		color:#000000;
		background: url(images/menu-active-homeFix.png);
	}
	.menu ul li:hover a.homeFix {
		width:95px;
		background: url(images/menu-active-homeFix.png);
	}
</style>

</head>

<body scrolling="no">
<div align="center"> <!-- Centering Div -->
	<noscript>
		<h2 style="color:#FF0000;">You do not have Javascript enabled! Please allow Javascript!</h2>
	</noscript>

	<div id="container">

		<div id="banner">
			<img src="images/banner.png" width="951px" border="0" usemap="#Map2" />
			<map name="Map2" id="Map2"><area shape="rect" coords="282,7,713,148" href="home.php" alt="Return to our home page"  title="Return to our home page" />
			</map>
        
			<div class="menu">
				<?php include("menu.php");?>
			</div><!-- End Menu Div -->    
		</div><!-- End Banner Div -->  

		<div id="content">
			<div id="leftDiv">
				<img src="images/leftdivbg-lead.gif" />
			</div> <!-- End leftDiv -->


			<div id="dateBox">
				<?php
					echo date("m/d/Y");
				?> 
			</div> <!-- End dateBox -->

			<div id="applyLink">
				<h3>How to apply!</h3>For more information<br /><a href="apply.php">Click here</a>!<br />Alternatively, this link is also under "Participants".
			</div> <!-- End applyLink -->

			<div id="contactMatt">
				If you would like more information about NCCCLP please contact Matt Huntanar at 336.249.8186 Ext. 6300 or <script type="text/javascript">showEM("mghuntan","davidsonccc.edu");</script>
			</div> <!-- End contactMatt -->

			<iframe src="edit_these/front-page-content.htm" frameborder="0">Your browser does not support iframes. iframes are needed for the site to work properly.<br />Please update your browser. Goto Help on your browser menu and click where it says to update.</iframe>

			<!--
			<div id="footerDivExt">
				<img src="images/footerbg-ext.gif" />
			</div>  End footerDivExt -->

		</div> <!-- End Content div -->




	</div> <!-- End Container div --> 

	<!-- Footer background -->
	<img src="images/footerbg.png" width="951px" border="0" usemap="#Map" />
	<map name="Map" id="Map"><area shape="rect" coords="690,5,859,27" href="credits.php" alt="Click here to view site designers" title="Click here to view site designers" /></map> 		
	<!-- End Footer background -->


</div> <!-- End Centering Div -->

<!-- Preload images -->
<img class="hiddenPic" src="images/cam.gif" />
<img class="hiddenPic" src="images/cam-on.gif" />
<img class="hiddenPic" src="images/btn-next.png" />
<img class="hiddenPic" src="images/btn-back.png" />
<img class="hiddenPic" src="images/btn-next-on.png" />
<img class="hiddenPic" src="images/btn-back-on.png" />

<img class="hiddenPic" src="edit_these_images/gallery/gallery-thumbnails/t_home.jpg" />
<img class="hiddenPic" src="edit_these_images/gallery/gallery-thumbnails/t_current.jpg" />
<img class="hiddenPic" src="edit_these_images/gallery/gallery-thumbnails/t_2008.jpg" />


</body>
</html>

 

I should also point out that when I coded home.php, auth.php was not yet thought of at the time.

Link to comment
Share on other sites

Unless you have set php's auto_prepend_file directive to always include this file...

Since you pointed that out, I did a little checking up on it and I tried setting the value after the = to "none" to see if this might help. Of course, it may mean, leave it blank, but it is worth a shot. I will have to test it from a few different locations as the error does not always occur when using localhost.

 

Source:

http://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.