WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Function that does language negotiation based on the Accept-Language header, a cookie or host name
Categories : HTTP, PHP, Cookies Update Picture
Stig Bakken
Date : Jan 17th 1999
Grade : 3 of 5 (graded 5 times)
Viewed : 6173
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Stig Bakken
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php

/*
* $Id: language.phl,v 1.3 1998/08/03 13:21:45 ssb Exp $
*/

$supported_languages = array(
"no" => 1, /* Norwegian */
"en" => 1 /* English */
);

$default_language = "en";

/* Try to figure out which language to use.
*/
function negotiate_language($lang) {
global $supported_languages, $HTTP_ACCEPT_LANGUAGE;

if (isset($supported_languages[$lang])) {
return $lang;
}

/* If the client has sent an Accept-Language: header,
* see if it is for a language we support.
*/
if ($HTTP_ACCEPT_LANGUAGE) {
$accepted = explode( ",", $HTTP_ACCEPT_LANGUAGE);
for ($i = 0; $i < count($accepted); $i++) {
if ($supported_languages[$accepted[$i]]) {
return $accepted[$i];
}
}
}

/* One last desperate try: check for a valid language code in the
* top-level domain of the client's source address.
*/
if (eregi( "\\.[^\\.]+$"", $REMOTE_HOST, &$arr)) {
$lang = strtolower($arr[1]);
if ($supported_languages[$lang]) {
return $lang;
}
}

global $default_language;
return $default_language;
}

?>



A flat file counter
Categories : PHP, Cookies, Filesystem, Beginner Guides
The following snippet gives complete info about all submitted HTTP_POST_VARS and HTTP_GET_VARS
Categories : Variables, HTTP, PHP
Smart Counter - This little script is a plain and simple hit counter that uses cookies to determine whether or not the visitor has already been counted.
Categories : Cookies, HTML and PHP, PHP
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, Databases
Simple Password example
Categories : PHP, Authentication, Security, HTTP
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
header -- Send a raw HTTP header
Categories : PHP, PHP Functions, HTTP
cookie
Categories : Cookies, PHP
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
Authentication script to authenticate users in Active Directory through LDAP.
Categories : LDAP, Authentication, Cookies, PHP
Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP
Categories : PHP, HTTP, Regexps
Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases
Remote File Saving with PHP - Download and serve a remote file. The content of the file will be updated at fixed intervals.
Categories : PHP, Filesystem, Cache, Sockets, HTTP
A function to check if a URL exists
Categories : PHP, CURL, HTTP