Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Detecting 404 Aqnd Other Page Errors On A Remote Website


Is it possible to detect page errors such as 404 (page not found)? I've searched good but can't find anything, or i'm not looking in the right places.

If so, would you be able to detect it even if a htaccess redirects it to an error page?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Supress Errors At The Page Level? Undefined Index Errors.
I'm creating a simple reply form, and if a form item isn't answered I
get an error:
"Notice: Undefined index: rb_amntspent in
c:inetpubwwwrootmackinawsurvey.php on line 36"
even if in the code I allow for an unselected item. (Code at the
bottom here.)
It works fine otherwise.

Now in the past I've made a change to php.ini to repress errors, but
for this project I don't have access to the php.ini.
Is there a way to supress errors on that page for that session?

Or, is there a way to just not get that error at all?

Here's a sample of the code that gets the form response. If an item is
selected, no error for that question, but if an item is not selected I
get the error above even though I still get a successful echo for the
"else" or "default" option which occurs if nothing is selected:

$rb_visited = $_POST["rb_visited"]; //Have you ever visited Mackinaw
City, Michigan?
if ($rb_visited == "1") {
$rb_visited_reply = "Yes";
} elseif ($rb_visited == "0") {
$rb_visited_reply = "No";
} else {
$rb_visited_reply = "You did not answer this question";
};

$rb_lastvisit = $_POST["rb_lastvisit"]; //When was your last visit to
Mackinaw ity?
switch ($rb_lastvisit) {
case "1":
$rb_lastvisit_reply = "Earlier this year (2003)";
break;
case "2":
$rb_lastvisit_reply = "Last year (2002)";
break;
case "3":
$rb_lastvisit_reply = "2 years ago (2001)";
break;
case "4":
$rb_lastvisit_reply = "3 years ago (2000)";
break;
case "5":
$rb_lastvisit_reply = "4 or more years ago (1999)";
break;
default:
$rb_lastvisit_reply = "You did not answer this uestion";
}

Detecting The Name Of The Page You Just Came From
I know there is a way to detect the name of the page you just browsed from, but I cannot seem to find it.

Regular Expression Detecting Entire Page
I am making a flat file, static HTML search engine for a site. I
downloaded a script from the net and have been working with it for my
needs.

Everything was working OK with a few test Lorem Ipsum pages. But the
moment I try to search real data, fit hits the shan.

The script uses a regular expression to search through the files. And
for most of these files, the regular expression doesnt seem to pick up
the matches as it should, and for lack of a match, it outputs the
entire html page as a hit. The search word is on the page somewhere,
but it still outputs the entire page.

Allow me
--------8<----------------------------
if(preg_match_all("/((sS*){0,3})($keyword)
((s?S*){0,3})/i", $portion, $match, PREG_SET_ORDER));
{
if(!$limit_extracts)
$number=count($match);
else $number=$limit_extracts;

for ($h=0;$h<$number;$h++){ // no limit
if (!empty($match[$h][3]))
$text = sprintf("... %s<font
class='keyword'>%s</font>%s ...", $match[$h][1], $match[$h][3],
$match[$h][4]);
else{
//print_r($match);
}
}
}
--------8<----------------------------

There's the regex that looks through $portion, which is the strip_tags
version of the file's contents. And if I echo $portion right before
that line, I see the stripped code. However, when I get to the line
where it checks $match[$h][3] for the keyword that was searched for,
it craps out. Not 100% of the time, but most of the time. Im trying
to figure out details about these html pages, to no avail.
So as a result of failing that empty test, the entire html page is
dumped out as a search result.

Not being a regex expert, Ive had a hell of time troubleshooting. But
I feel the problem lies in there. Something with the regex not finding
the keyword correctly, or something.

Placing Errors On The Page
I have code below (due to length I only included a portion). I am
validating an email address. It checks to see if the email field is
blank, in the proper format, etc... It prints errors to the screen and
everything works perfectly, but the errors always print at the very
top of the page and I am having difficulty moving those errors around
so they fit nicely into the page design I have. Rather than printing
the errors I tried assigning them to variables and printing them
elsewhere on the page, but it didn't work and the errors did not try
at all. I also tried moving the function to a different part of the
page where the errors would print where I wanted them, but I had the
same problem as with the variables. I'm kind of in a bind and need
this done asap. Does anyone have any thoughts on this?

<?php
function process_form() {

global $db;

$firstName = addslashes($_POST['firstName']);
$lastName = addslashes($_POST['lastName']);
$email = $_POST['email'];
$emailHash = md5($email);
$active = "n";

// Check syntax
$validEmailExpr = "^[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$
%&_-])*" .
"@[0-9a-z~!#$%&_-]([.]?[0-9a-z~!#$%&_-])*
$";

// Validate the email
if (empty($email))
{
print "The email field cannot be blank";
return false;
}
elseif (!eregi($validEmailExpr, $email))
{
print "The email must be in the name@domain format.";
return false;
}
elseif (strlen($email) 30)
{
print "The email address can be no longer than 30
characters.";
return false;
}
elseif (function_exists("getmxrr") &&
function_exists("gethostbyname"))
{
// Extract the domain of the email address
$maildomain = substr(strstr($email, '@'), 1);

if (!(getmxrr($maildomain, $temp) ||
gethostbyname($maildomain) != $maildomain))
{
print "The domain does not exist.";
return false;
}
}

$db->query('INSERT INTO users (firstName, lastName, email, hash,
active)
VALUES (?,?,?,?,?)',
array($firstName, $lastName, $email, $emailHash,
$active));

$message = "
Thank you for signing up for the . Please click on the link below
to confirm your registration. If the link is not active, copy-and-
paste it into your browser window.

http://www.EmailCapture/validateSuccess.php?id=$emailHash
";

$subject = "";
$from = "";

mail("$email", "$subject", "$message", "From: $from");

print "<script>window.location=..

Errors Validating XHTML Page
I've been validating some pages as XHTML 1.0 using the W3C HTML Validation Service.
(http://validator.w3.org/) I've come across 2 familiar snippets of PHP code that make it ack, and have had no luck resolving it! Code:

No Errors, Just Blank Page - Error_reporting(E_ALL)
Hey people. I have a strange problem. I never get any errors, just blank pages. Even if I insert error_reporting(E_ALL); . Is there an INI setting that I am missing?

Remote Web Page Information
I am trying to create a script that can grab information from a 3rd party website. For example, say I wanted to copy the text

"Advertising Programs - Business Solutions - About Google"

Off of Google's homepage. I wanted my website to open Google and select that text and output it onto my site. So if Google where to edit that information, it would also edit on my site.

Anyone have any idea how to do this? I had a buddy who did that once with a Roster Rankings chart for IGN Gamespy Arena, but he ran off.

Prevent Page Access Outside Website
I have a php webside with a guestbook and I want access to the guestbook
only via the homepage. How can I modify the index.php of the guestbook to prevent access from outside the website?

Detect Change Of Remote Page
i have some links on my site, i need to be absolutely sure that the
html has not been modified, even one character. i would rather not
rely on http headers, just the html (so it is not dependant on the
webserver). should i make a database to actually mirror the page, and
then check against my copy? any better ideas? :)

Open And Process Remote Page
I want to be able to ask users for a URL, open that page, change some of the
contents and then display that page as if they had typed the URL into a
browser. I have toyed with some of the php functions for opening URLs, but
what I am not clear on is how much work my script will have to do (do I need
to fully emulate a browser, for example).

The net effect I am after is very similar to the page translation feature
that Google offers. Does anyone have any examples of this kind of technique.
Any ideas how much work is involved? (My 'translation' is pretty trivial, so
really it is mostly a question of how much work to display the remote page).

Parsing Remote Page And Outputting
Here is a general idea of what I want to do:

HTML Form is submitted by remote user using POST methodVariables are received by 'search.php'Script within 'search.php' will POST same variables to a remote (3rd party) website Script downloads the resulting HTML pageScript parses HTML page and displays relevant data (ie. a specific table)

I'm stuck at the part with the -- how would I get PHP to POST the user's vars to get the page returned? I know how to do this if I were using a GET method, but this is not an option.

Validation Errors From Displaying On Form Page Load Instead Of Submit
creating two forms and they work fine. Problem is that the validation errors display immediately on page load instead of on submit. Here's the full code for the form parsing: Code:

Call Remote PHP Script On HTML Page
I have (almost) completed a php script. The client has an existing site and the pages have some graphical elements that need to be there. Hence whenever the htm page is called, i want the php script to run at a particular location on the page and insert the result there before sending the page back to the user.

I am trying to avoid having to copy and paste the php code onto every page and save all pages with the php extension.

Do I (I am Java-speaking here) declare it as a class and the procedure as a method with parameters? and place the script in the cgi-bin. Then make an instance of it on the page and call the method and pass the parameters to the phh script from there?? i was not able to locate an 'import' declaration to achieve this.

Can't Read Remote Web Page From Local Apache/PHP
I'm trying to read the contents of any Web page on another
host. I'm finding that...

echo file_get_contents( 'http://www.php.net' );

.... works fine if I upload the PHP script to my Web host, and run it
there. But if I run it on my PC, which is running Apache 1.3.33
(Win32) and PHP 5.0.5, then it always times out, and gives me the error
message...

[error] PHP Warning: file_get_contents(http://www.php.net) [<a
href='function.file-get-contents'>function.file-get-contents</a>]:
failed to open stream: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to
respond.

I get the exact same results using...

$fh = fopen( 'http://www.php.net', 'r' ) or die( $php_errormsg );
while (! feof($fh)) {
$page .= fread($fh,1048576);
}
fclose($fh);
echo $page;

Anyone know what could cause this to happen?

Retrieving The Description Meta Tag Of A Remote Page
How can I retrieve the "description" meta tag of a remote page?

Redirect Page On Remote Web Host When Local Server Is Offline
Hope some one can help . I have my web site hosted on powweb (my remote web host)and I want a user to be redirected when they access my local server through a link on my remote web site to another page on my remote web site when my local server is offline.

Change Website To Php,mysql Data-driven Website
At the moment this site is not completely php. How can I make the content of the pages be from a mysql database? and how do I make the nav buttons work correctly connecting to the mysql database and displaying the correct content, ?

How To Upload File From Website To My Website?
I want to make upload page. I could upload file from computer to my website. But I don't know how to upload file from website to my website? How can I make it?

Detecting Host URL.
I've got a site that has both secure access (https) and normal http access. both use the same index.html.

The problem I have is that I cannot find a way to check which method is being used to access the site.

Ideally I want to check for https access and if that's not being used, redirect to the https url.

Anyone know of a way of doing this in PHP?

Detecting Frames With PHP
Is it possible to use PHP to see if the person who is accessing ur website is using the frame set up or the non frame set up?

Detecting Flash
I need a way to detect whether someone has flash installed. I will use this information to take them to two different pages depeding on the result.

Detecting Recursion
Say I have an array containing a reference to itself:
$myArray = array();
$myArray['self'] =& $myArray;
How can I, looping iteratively through the array, detect the fact that
$myArray['self'] will "take" me to where I have already been? The print_r()
and var_dump() functions print *RECURSION* in such a case (though only after
the "second round"). Setting a flag seems to be the only solution, but I
don't want to modify the array in question - I want to produce a visual
representation of its contents like var_dump(), but formatted to my taste. I
had considered parsing the output of var_dump(), but first, that format
might change in a future version of PHP and second, an array key might be a
string resembling part of the output (like $myArray['["myArray"]=>']), which
seems to be difficult to detect by the parsing code.

Is there another way of doing this?

Detecting Domain?
how I can use PHP to detect the domain that is being used? Or just detect the full URL? Because I have more then 1 domain and I want to redirect the others to the first one, so that google won't think I am using duplicate content and penalize me for it.

So like either a way to detect what the domain is (E.G. domain2.com) so that I can redirect to domain1.com

Or just a way to detect if it ISN'T domain1.com, and redirect to domain1.com if it isn't? Because I like to register more then 1 domain for common misspellings, like the way google has gooogle.com redirect to google.com

Problem With Detecting Speed Of Net.
Well i comes accross little bit tricky problem around in php..there is any way to detect net speed in php ?

Waiting for some one to reply

Detecting Sum Of Array = 0 Problems
I use the following code to put directories that are on the server but not in the database yet on my website, so I can use a function to have them added.

However, when all my directories are in the database I get just an empty page, I want to put in a nice line that says all dirs are already added.

I don't know why the following code doesn't do just that. I tried several other things, no luck yet.

Do you have any idea what goes wrong, or how to solve this?

Detecting Windows Servers
Is there a way, within PHP, to determine if it is running on a Windows
Server?

Detecting If There Is A Mobile Phone
Is there a way (maybe a variable) to detect whether the user is using a mobile phone with internet to view your website?

Detecting Browser Resolution
How can I detect the resolution used by a visitor (i.e. 640x480, 800x600, etc.)?


Detecting Multiple Sessions
I have an address database running on POSTGRESQL web based ofcourse with php. My Web application has a login page that gives the users a session_start if their data is correct. Users can login at the same time. I would like to know how i can detect the session from these users. Than i want to know:

- How many user are online
- Wich users are online

When they didn't logged out but have closed their browser, how can i detect if their offline?

Detecting User-Agent
I have a site that uses access-restriction to only allow registered users to view certain pages. However, I would really like Google to be able to index *every* page regardless of whether it's password protected or not.

Is there a way to identify the user-agent header in PHP? That way I could identify the Googlebot, and then set a session variable that would allow the Googlebot to spider my entire site.

Detecting URL Forwarding / Redirection
I'm working on a feature in my software that will delete urls from a database if they no longer exist or do exist, but are redirecting to another page. Both cases have a setting to optionally allow a user to delete or keep them based on either one of the two scenarios. My problem is the header status which is being returned and detecting which urls are forwarding - For example,

Page 1) This no longer exists - HTTP/1.1 301 Moved Permanently

Page 2) This page is redirecting - HTTP/1.1 301 Moved Permanently

Page 3) This page is available - HTTP/1.1 302 Found

So page 1 & 2 are showing the same header status, even though page to really does exist.
Any suggestions?

Detecting User Country?
Is there a way using PHP to detect the country a person is browsing from?

Automatically Detecting Tables In A Db
Is it possible to write a script that, when provided with a database,
it will return all the tables names?

I will go onto try and put together a script that will not only output
the table names but also output the sql code required to CREATE the
table (i.e. CREATE TABLE example (exampleid auto_increment not null
primary key integer, name text, email text);) - Is this pretty simple
to do? Are there any free scripts online that would do this?

Php Detecting Javascript Enabled
Is there any php script to detect if java or javascript is enabled?

What is a difference between java, javascript and applet?

Detecting And Displaying The Domain Name
I have a site that has several domains pointing to its DNS.
I would like to implement a script that will grab the domain name visitors typed in, and display it
on the page. Is there a way to do it?


Detecting Multiple Windows
How would a man go about checking if another window (or tab.. same thing) is open from my site? Not allowing the pages (other than that 1 that is allowed) to load, thus showing an error.

Im doing this as more of an expieremental thing, but I have no clue where to start with it. I don't even know if PHP would be involved. Anyways, I've searched and searched and I couldn't find any examples/tuts so I came back here.

Detecting If A String Has A Certain Character?
Is there any sort of function to be able to go through a string and return if there is a certain character in it.

I have a variable for a persons name but and i need to know if there is a space between there name or not.

Detecting Dead Images
My database contains the images of other sites.... when other sites remove some images from their websites, my side shows blank images as i am using their images and the same_path of their images.

1) Is there a way i can detect the blank images.

2) Is it possbile that the desciption of that image will appear only when that image is opened.

Detecting User Abort Or Timeout
I'm writing a download script in php. This script sends files using
echo in order to limit download speed. My script has to do something
after connection abort. Everything is ok unless client pauses
downloading.

I'm using ignore_user_abort() and I'm checking connection_status()
while sending a file. When the user aborts connection, my loop breaks
and script finishes its job. But if the user pauses connection, the
script still sends a file!

I want my script to execute some commands after a break of the loop and
not to send file, if the user doesn't receive it! I don't know how to
implement that. Is it possible to do such script?

Detecting All Game Servers Running On LAN
does anyone know of a way to detect all game servers running on a LAN, preferably Half-life servers. Is this even possible ?

Half life the game obviously detects all the servers running on the network but I have no idea how this could be done in PHP.

Detecting And Replacing Line Endings
ive got a .txt file which i downloaded from a server..when i viewed the file, it was in one line in my editor and realized later that they used a different operating system than what im using..i dont know what their operating system is but im using linux..

i need then (using a php script) to detect the line endings of the text and eventually change it to the line endings for which linux (my operating system) is using so that i can get the strings line by line.

Detecting User Presence/absence
i'm trying to make code which with the help of a db will enable me to keep a check on all the ppl on my site.. the site is tatally dynamic.. just like forums.devshed.com anyway. So what i've got right now is:

when user comes to main page.. session is created. and if he/she clicks on some link then i update the db using the sessionid.. this is all well and good. but
how do i (not pun intended) get the page they are on if the address is typed directly for instance www.mysite.com/file.php?id=5&subid=57 is there anyway to detect this url?

secondly.. how do i find out that the user has left the site (closed browser window or gone to some other webaddress).

Algorithm For Detecting/highlighting Changes In Documents
Anyone knows a good algorithm for detecting difference between two
pieces of text? I'm working on a content management system and would
like to add the ability to highlight changes made between versions. I
don't think diff is suitable here, since I want word level detection.
Besides, I'll need to handle a large number of relatively short
strings. Spawning an process for each would be too time consuming.

AFAIK, PHP doesn't have a build-in function. If necessary, I can build
a wrapper extension.

Problem Detecting An Ajax Request
I have the following code in Javascript which is creating and sending
an XMLHttpRequest .

<code>
var xmlHttp;

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
@end @*/
alert(xmlHttp);
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}

// Build the URL to connect to
var url = "getURL.php";

// Open a connection to the server
xmlHttp.open("GET", url, true);

// Setup a function for the server to run when it's done
xmlHttp.onreadystatechange = updatePage;

// Send the request
xmlHttp.send(null);

</code>

The problem I am having is server side where I am trying to detect an
Ajax request.
I have the folowing function isAjax() which is returning false:

<code>
<?php

if(isAjax()){
echo "This is an Ajax request";
}
else{
echo "Not Ajax";
}

function isAjax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
$_SERVER ['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
}

?>
</code>

Detecting Checkboxes And Option Lists
I am trying to figure out how to detect a <Form> check box being checked in a PHP script.  Likewise, I am trying to figure out how to detect which option was chosen in a <option> list of drop-down items in a form. Code:

Detecting/Disabling Back Button Using PHP
I was wondering if there is a way to disable or detect when a user presses the browser back button in PHP.

What I want to do is that when a back button is pressed, the page reloads.

Please let me know if there is a way to do this. If any of you use modernbill, it has that feature.

Detecting HEX Codes For Similar Colors
Is there any way by which i can detect the HEX codes for similar colors if i input a color code ?

What i mean if if i enter the color code for an Orange, the output should be another shade of Orange.

This can be seen in action at http://feeds.feedburner.com/~fc/GotChance?bg=FF9900&fg=000000&anim=0

If you change the "bg" parameter, the background color changes to that color and a similar shade is applied to the smaller background. How do i do something like that ? Also, how to i find HEX codes for complement colors ?

Detecting Line Breaks In A Text Area?
This is really frustrating... I have a form in which there is a text area for people to post comments on the site. I'm hoping that people will take the time to fill out reasonable length responses which my spread over two or more paragraphs. My problem lies there; it might spread over two paragraphs...

I know I can use 'special character(s)' which the user can put in that I can then do a ereg_replace() to put the <p> or <br> tags in but I would prefer that they didn't have to... like for instance in this forum

I've tried to see whether there are any line breaks or something in the textarea when a carriage return has been made but I can't seem to pick anything up, has anybody managed to come up with a solution to this?

Dual Array: For Detecting Invalid GET Values?
I'm not sure what the terminology of it would be but I would like to do what I'm referring to in my head as a dual array or maybe a parallel array? I have a list of properties that can be manipulated with certain values. However I would like to detect when a GET request with a non-existent property or an invalid value occurs. I'm using CSS terminology here too so let me clarify visually...

Array Sample
property, value,
(
audio, 0,
audio, 1,
audio, 2,
bandwidth, 1,
bandwidth, 2,
browserpatch, 0,
browserpatch, 1,
dhtmleffects, 0,
dhtmleffects, 1,
dhtmlengine, 0,
dhtmlengine, 1,
dtd, t,
dtd, s,
dtd, 1,
dtd, 2,
mediatype, xx,
mediatype, ax,
mediatype, tx,
mediatype, th,
ieccss, 0,
ieccss, 1,
powerkeys, 0,
powerkeys, 1,
theme, classic,
theme, cityblue,
theme, emerald,
theme, lavender,
)

These are examples of my working properties and values. If I could keep the list like it is right now with minor modifications to get it working it would be great as I plan on adding further options in the future. However I'm not exactly sure how I should approach this.

Also this is important as I have tested invalid values and it broke the page once while being served as application/xhtml+xml so this could potentially lead to loosing visitors if I do not address this issue. Suggestions to create this error handler script?


Copyright © 2005-08 www.BigResource.com, All rights reserved