|
|
|
In order to grad the complete URL as typed in the browser (http://www.company.com), you
need to have a script or HTML-file forward you to your PHP-script and passing the URL as a
parameter using JavaScript.
The solution consists to two files: INDEX.HTM and ACTION.PHP3. Index.HTM forwards the user
to a PHP-script (ACTION.PHP3) with the original URL passed as a parameter.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<SCRIPT language="JavaScript">
function openmain() {
document.location = 'action.php3?url='+document.location;
}
</SCRIPT>
</head>
<body onload ="openmain();">
</body>
</html>
In ACTION.PHP3 we can act upon which URL the user typed. For example:
...
<?
// returns hostname from url (hostname in "www.hostname.com")
// returns value "localhost" if run from a local webserver (developement server)
function returnhostname($p_url)
{
//http://www.hostname.com/something
$tmp = str_replace("http://","",$p_url);
//www.hostname.com/something
$arrTmp = explode ("/",$tmp);
//$arrTmp[0] = www.hostname.com
$arrTmp2 = explode (".",$arrTmp[0]);
$comp = strcmp(strtolower($arrTmp2[0]),"www");
if ( $comp == 0 ) {
return (strtolower($arrTmp2[1]));
} else {
return (strtolower($arrTmp2[0]));
}
}
//check if URL is set
if (!isset($url)) {
//set fallback URL in case user opened PHP-script before INDEX.HTM
$url = "www.sullandbil.no";
}
$company = returnhostname ($url);
if ($company != "sullandbil") {
die ("The website for the company requested is under construction<br>");
}
?>
|
|
| Display Slashdot headers on your own site Categories : HTML and PHP, HTML, PHP | | | webcam cam view image ispy browser independant Categories : Graphics, HTML, HTML and PHP, PHP | | | How to preset a text string in a textarea input field Categories : HTML, HTML and PHP, PHP, Beginner Guides | | | Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but
effective. Categories : PHP, PHP Classes, HTML, HTML and PHP | | | This script shows you the 7th latest php items from the mailing list archive on zend.com Categories : HTML, HTML and PHP, HTTP, PHP | | | GonxTabs : Create elegant HTML tabs based interface Categories : Navigation, HTML, HTML and PHP, PHP | | | class formHTML build your HTML Forms from PHP Categories : PHP, PHP Classes, HTML and PHP, HTML | | | Snipe.Net's Web Design Color Scheme Previewer- Allows uses to input hex
codes for their text, background, and link colors, and preview the color
scheme with their background image. Example:
http://www.snipe.net/tech/snipeschool/hex.php3 Categories : PHP, HTML and PHP, General, Graphics, HTML | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | How to use regular expressions to get the list of links from an HTML page Categories : PHP, Regexps, HTML, HTML and PHP | | | Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance. Categories : HTML, PHP, HTML and PHP, Beginner Guides | | | PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP | | | Popup Menu 0.5, popup, select, html, state-maintaing Categories : HTML, PHP, HTML and PHP | | | A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | |
|
|
|