Archive for the 'Server' Category

 

Detecting domain names in php ..

Jul 14, 2009 in php, Web

From http://www.webmasterworld.com/forum88/11417.htm

<? 
if (strpos(getenv('SERVER_name'), 'domain1.com')!==false) { 
  echo "<img src='1.jpg'>"; 
} elseif (strpos(getenv('SERVER_name'), 'domain2.com')!==false) { 
  echo "<img src='2.jpg'>"; 
}; 
?>

Hudson continous integration server notes ..

Nov 20, 2008 in Apache, Config Manage

Fastest way to plug tomcat into apache httpd..

Change apache2.conf, add:

<Location /your_tomcat_app>
  ProxyPass ajp://your_host:8009/your_tomcat_app
  Order allow,deny
  allow from all
</Location>

More notes on Hudson here:

http://suereth.blogspot.com/2008/08/ubuntu-dev-server-hudson.html

Hudson is here:

https://hudson.dev.java.net

Apache Tomcat AJP ..

Jul 07, 2008 in Apache, Server, Web

AJP = Apache JServ Protocol

Interface to the Tomcat application server to be used with a
front end web server for proxy and load balancing.

If the Apache web server is used, the mod_jk module is the
interface to AJP from the web server to the application server.


http://en.wikipedia.org/wiki/Apache_JServ_Protocol

php introduction notes.. part 3..

Jul 02, 2008 in php, Web

From


http://www.ibm.com/developerworks/web/library/wa-phprock3/

Variable references

<?php

$name = ‘Amol’;
$nom = &$name; // $nom is now a reference to $name
$nom .= ‘ Hatwar’;

print(“Are you $name?\n”); // Jimmy Ray parody?

?>

Static variables

function funcCount()
{
static $count = 0;
return $count++;
}

Dynamic function calls

function say_hi()
{
print(“Hi! “);
}

$my_func = ‘say_hi’;
$my_func();

php introduction notes – part 2..

Jul 02, 2008 in php, Web

From

https://www6.software.ibm.com/developerworks/education/os-phptut1/section4.html

Functions

Creating a function

<?php

function checkPasswords($firstPass, $secondPass){

if ($firstPass == $secondPass) {
echo “<p>Passwords match. Thank you.</p>”;
} else {
echo “<p>Passwords don’t match. \
Please try again.</p>”;
}

}

?>

Returning a value

<?php
function validate($allSubmitted){

$message = “”;

if ($message == “”){
$message = “OK”;
}

return $message;

}

if (validate($_POST) == “OK”) {
echo “Thank you for registering!”;
} else {
echo “There was a problem with your registration..”;
}

?>

Including files

<?php
include(“top.txt”);
?>

<?php
include(“bottom.txt”);
?>

Requiring files

<?php

include(“top.txt”);
require(“scripts.txt”);
?>

Avoiding duplicates (includes)

<?php

include_once(“top.txt”);
require_once(“scripts.txt”);
?>

php introduction notes – part 1..

Jul 01, 2008 in php, Web

Basic things about php..

From

https://www6.software.ibm.com/developerworks/education/os-phptut1/index.html

Variables

A variable is a placeholder for data. You can assign a value to it, and from then on, any time PHP encounters your variable, it will use the value instead. For example, change your page to read:


<html>
<title>Workflow Registration</title>
<body>
<p>You entered:</p>

<?php
$username = “tyler”;
$password = “mypassword”;

echo “<p>Username = ” . $username . “</p>”;
echo “<p>Password = ” . $password . “</p>”;
?>

</body>
</html>

Constants

<?php
define(“PAGE_TITLE”, “Workflow Registration”);
?>

<html>
<title><?php= PAGE_TITLE ?></title>

Accessing form data

<body>
<p>You entered:</p>

<?php
$username = $_GET[‘name’];
$password = $_GET[‘pword’];

echo “<p>Username = ” . $username . “</p>”;
echo “<p>Password = ” . $password . “</p>”;
?>

</body>
</html>

Arrays


$formnames = array(“name”, “email”, “pword”);
echo “0=”.$formnames[0].”<br />”;
echo “1=”.$formnames[1].”<br />”;
echo “2=”.$formnames[2].”<br />”;

Notice that the first value has an index of 0, rather than 1. Notice also that you specified which value you wanted by adding the index in brackets after the name of the array variable. This action is similar to the way in which you access the form values, and that’s no accident. The $_GET variable is a special kind of an array called an associative array, which means that instead of a numeric index, each value has a key.

When you submit the form, you’re essentially creating an array like so:


$_GET = array(“name” => “roadnick”,
“email” => “ibmquestions@nicholaschase.com”,
“pword” => “supersecretpassword”);

Associative arrays

<?php
$form_names = array_keys($_GET);
$form_values = array_values($_GET);

echo “” . $form_names[0] . ” = ” . $form_values[0] . “”;
echo “” . $form_names[1] . ” = ” . $form_values[1] . “”;
echo “” . $form_names[2] . ” = ” . $form_values[2] . “”;
?>

For-next loop


for ($i = 0; $i < 10; $i++) { echo $i . " "; }


<?php
$form_names = array_keys($_GET);
$form_values = array_values($_GET);

for ($i = 0; $i < sizeof($_GET); $i++) {
echo “<p>”.$form_names[$i].” = ” . $form_values[$i] . “</p>”;
}
?>

Foreach loop

<?php
foreach ($_GET as $value) {
echo “<p>” . $value . “</p>”;
}
?>

<?php

foreach ($_GET as $key=>$value) {
echo “<p>”.$key.” = ” . $value . “</p>”;
}
?>

Using POST

<?php

foreach ($_POST as $key=>$value) {
echo “<p>”.$key.” = ” . $value . “</p>”;
}

$passwords = $_POST[“pword”];
echo “First password = “.$passwords[0];
echo “<br />”;
echo “Second password = “.$passwords[1];
?>