Apache Logout Script

This works really well for one page:
<?
header(“Expires: Sat, 01 Jan 2000 00:00:00 GMT”);
header(“Last-Modified: “.gmdate(“D, d M Y H:i:s”).” GMT”);
header(“Cache-Control: post-check=0, pre-check=0″,false);
header(“Pragma: no-cache”);
session_cache_limiter(“public, no-store”);
session_start();

function auth_user() {
$realm = mt_rand( 1, 1000000000 );
header(‘WWW-Authenticate: Basic realm=”Protected:[ID'.$realm.']“‘);
header(‘HTTP/1.0 401 Unauthorized’);
die(“Unauthorized access forbidden!”);
}

if(isset($_GET['logout'])) {
auth_user();
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
auth_user();
} else if (!isset($_SERVER['PHP_AUTH_PW'])) {
auth_user();
}

echo “pass = “.$_SERVER['PHP_AUTH_PW'].”
“;

mysql_connect(“localhost”, “root”);
mysql_select_db(“database”);
$validate_sql = “SELECT Username, PasswordĂ‚
FROM user WHERE Username = ‘”.$_SERVER['PHP_AUTH_USER'].”‘
AND Password = ‘”.$_SERVER['PHP_AUTH_PW'].”‘”;
if(!$validate_qry = mysql_query($validate_sql)){
die(mysql_error());
}

if(mysql_num_rows($validate_qry) < 1) {
if($_SERVER['PHP_AUTH_USER'] == “logout”) {
// message for firefox
die(“You have successfully logged out.”);
} else {
auth_user();
}
}

echo “You are now logged in
“;
if (ereg(“MSIE”, $_SERVER['HTTP_USER_AGENT'])) {
// Use basic logout
echo “<a href=\”".$_SERVER['PHP_SELF'].”?logout=y\”>Logout</a>”;
} else {
// use other logout for Firefox and other browsers
echo “<a href=\”<a href=”http://logout:logout/”>http://logout:logout</a>@”.
$_SERVER['SERVER_NAME'].”/”.$_SERVER['PHP_SELF'].”\”>Logout</a>”;
}
?>

Javascript DOM examples and PHP

<a href=”http://www.w3schools.com/js/js_examples_3.asp”>http://www.w3schools.com/js/js_examples_3.asp</a>
<html>
<head>
<script type=”text/javascript”>
function alertId()
{
var txt=”Element id: ” + document.getElementById(“myButton”).id
txt=txt + “, element type: ” + document.getElementById(“myButton”).type
txt=txt + “, element value: ” + document.getElementById(“myButton”).value
alert(txt)
document.getElementById(“myButton”).disabled=true
}
</script>
</head>

<body>
<form>
<input type=”button” value=”Click me!” id=”myButton” onClick=”alertId()” />
</form>
</body>

</html>

Ternary Operator PHP

boolean_condition?true_value:false_value

If it were written as an if-else statement, it would look like this:
if( boolean_condition )
{
true_value;
}
else
{
false_value;
}

In both cases you’re testing a condition that evaluates to true or false. If it evaluates as true, you want execute the true_value statement, otherwise you’d execute the false_value statement. Here’s an example:
$test_me = 1;

if( $test_me >= 0 )
{
print “Positive”;
}
else
{
print “Negative”;
}

To use all that with the conditional operator, you’d do this:
$test_me = 1;

print ($test_me > 0?”Positive”:”Negative”);

Nusoap, PHP, and C#

Nusoap Soap PHP and C #

For Real estate go to <a href=”http://www.restorent.net/”>www.restorent.net</a>

The best way to get php and c# to work together is to use nusoap and create an object that will connect from the desktop application to your web service. Do this by making a web reference in C#