Archive for August, 2009

Sending Text Messages Via PHP

August 26th, 2009

Sunday is family day for us. We try on most Sundays to get together for lunch after church. It is nice to get together and catchup on what is happening in everyone’s lives.

The problem is it is so hard to get everyone to agree on a restaurant! Honestly this is usually a 15 to 20 minute ordeal. Lots of I don’t care, whatever you want, anything but that kind of comments.

The solution, write down all the restaurants within a 5 mile radius that everyone can tolerate, then either go down the list or choose randomly.

Below is a fun little script that I wrote to choose a random restaurant and text the results too us.

Most of the cell phone carriers allow sending of text messages via email Verizon’s format is thenumber@vtext.com, other carriers you will have to check.

set_time_limit(0);

//Creating Restaurants List
$restaurants = array();
$restaurants = array("Applebees", "Red Lobster", "Red Robin", "Chilis", "Sweet Tomatos", "Culvers", "Olive Garden", "Macayos", "Rio Marage", "Golden Corral", "Brookside", "Chipolte", "My Greek Corner", "Fridays", "Paridise Bakery", "Chuy's", "Streets of New York", "Taco Bell", "Charleys", "Wendy's", "Long John Silvers", "Out Back", "Buffalo Wild Wings", "Burger King", "A&W KFC", "NYPD Pizza");

//Selecting Random Restaurant
$rand_restaurant = array_rand($restaurants,1);

//Creating Email List
$emailaddress = array();
$emailaddress = array("1111111111@vtext.com,2222222222@vtext.com");

//Setting Email Properties
$emailsubject = "Today we are eating at....";
$emailbody = $restaurants[$rand_restaurant];
$fromaddress = "you@youremail.com";

//Getting email Count
$i = count($emailaddress);

$z = 0;

//Loop only if we have some email addresses
if ($i != 0)

{

while ($i != $z)

{
// Send the Mail
mail($emailaddress[$z], $emailsubject, $emailbody, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");

echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")
";

++$z;

}

}

else

{

echo "Warning: No emails in array.";
}

Also I wanted the text to be sent out every Sunday at 10:05AM so I added the following line to /etc/crontab

5 10 * * sun php /path/to/file.php

Setting Up OpenBD on a Linux Cpanel Server

August 21st, 2009

There is an excellent writeup on openbluedragon.org that explains installing OpenBD on Centos/Redhat with Apache and Tomcat. Cpanel can be used to install Tomcat so the setup is a little different.

Install Tomcat

This can be done in WHM under EasyApache (Apache Update).  Just check the Tomcat option when saving your build.

Install OpenBD

cd /usr/local/jakarta/
wget http://openbd.viviotech.net/downloader.cfm/id/64/file/openbd.war
cp /usr/local/jakarta/openbd.war /usr/local/jakarta/tomcat

Go to http://localhost:8080/openbd/bluedragon/administrator. Login with the password admin and change the default password to whatever you want.

Enable CFM

By default Tomcat will execute any jsp page for an account that has jsp enabled. To enable cfm we have to modify the setup script slightly.  To do this open /scripts/addservlets2 in your favorite editor and modify the IfModule mod_jk.c portion of the file to look like the code below.

<IfModule mod_jk.c>
JkMount /*.cfm ajp13
JkMount /*.cfc ajp13
JkMount /*.do ajp13
JkMount /*.jsp ajp13
JkMount /*.cfchart ajp13
JkMount /*.cfres ajp13
JkMount /*.cfm/* ajp13
JkMount /*.cfml/* ajp13
JkMount /servlet/* ajp13
JkMount /servlets/* ajp13
</IfModule>

Enable Tomcat for your Domain

/scripts/addservlets2 --domain=yourdomain.com

Copy Directories

Unfortunately with this setup you have to have an admin for every domain.

cp -Rf /usr/local/jakarta/tomcat/bluedragon /home/yourdomaindirectory/public_html
cp -Rf /usr/local/jakarta/tomcat/WEB-INF /home/yourdomaindirectory/public_html