<?PHP //-- M A I N P H P C O D E N E W D E S I G N
IF ($what == "base" && $id_base == "- Then Choose an Installation -") {
$what = "home";
}
IF ($what == "contacted") { include "UpdateContactInfo.php";
$contacted[business_name] = $business_name;
$contacted[name] = $name;
$contacted[email] = $email;
$contacted[address] = $address;
$contacted[city] = $city;
$contacted[state] = $state;
$contacted[zip_code] = $zip_code;
$contacted[telephone] = $telephone;
$contacted[fax] = $fax;
$contacted[url] = $url;
$contacted[business_address1] = $business_address1;
$contacted[business_address2] = $business_address2;
$contacted[business_address3] = $business_address3;
$contacted[interested_in] = $interested_in;
$contacted[payment_type] = $payment_type;
$contacted[current_advertise] = $current_advertise;
$contacted[interested_location] = $interested_location;
$contacted[interested_location2] = $interested_location2;
$contacted[interested_location3] = $interested_location3;
$contacted[category1] = $category1;
$contacted[category2] = $category2;
$contacted[advertising_rep] = $advertising_rep;
$contacted[relocating] = $relocating;
$contacted[installation_living_at] = $installation_living_at;
$contacted[installation_seeking_info_about] = $installation_seeking_info_about;
$contacted[questions_comments] = $questions_comments;
}
// Establish a database connection
$conn = mysql_connect("localhost", "xxxxxxx", "password");
mysql_select_db("xxxxxxx", $conn);
// Load Main Template and Combox Scripts
$file1 = file("template08.txt");
$file2 = file("script01.txt");
// Print Output
plines(1, 56, $file1);include_once "PutTitle.php";
plines(1, 14, $file2);
s1branches();
plines(18, 19, $file2);
s1bases();
plines(28, 54, $file2);
plines(57, 67, $file1);
plines(55, 60, $file2);
plines(68, 93, $file1);
white_space();
plines(94, 121, $file1);
//--------------------------------------------------------------------- F U N C T I O N S
FUNCTION plines($a, $b, $c) { //-----------------plines()-----
FOR ($i = $a-1; $i < $b; $i++) {
PRINT "$c[$i]";
}
}
FUNCTION banner($a, $b) { //-----------------banner()-----
//######################################################
//# Get one random active banner from the database #
//# that is associated with the proper base (if #
//# specified). #
//######################################################
//+------------------------------------------+
//| DB access requires $conn - which points |
//| to the DB connection established in the |
//| main block of code - to be global. |
//+------------------------------------------+
GLOBAL $conn;
//+------------------------------------------+
//| If no base_id is specified in the |
//| function arguments $a will be empty. |
//| This causes an error if $a is then used |
//| in an SQL querry so if $a is empty it |
//| should be set to zero. |
//+------------------------------------------+
IF (empty($a)) {
$a = 0;
}
//+------------------------------------------+
//| Put the querry to randomly select one |
//| active banner which is either global or |
//| associated with a base_id (if specified) |
//| into variable $sql. |
//+------------------------------------------+
IF ($b == "y") {
$sql = "SELECT graphic, link FROM banner WHERE base_id=\"$a\" AND active=\"y\" ORDER BY RAND() LIMIT 1";
} ELSE {
$sql = "SELECT graphic, link FROM banner WHERE (base_id=\"$a\" OR base_id=\"0\") AND active=\"y\" ORDER BY RAND() LIMIT 1";
}
//+------------------------------------------+
//| Execute the querry (using the querry |
//| string $sql and the DB connection |
//| pointer $conn) and put the MySQL result |
//| set into $result. |
//+------------------------------------------+
$result = mysql_query($sql, $conn);
//+------------------------------------------+
//| Put the first record of the result set |
//| (there should only be one) into $b. |
//+------------------------------------------+
$b = mysql_fetch_array($result);
//+------------------------------------------+
//| If the querry successfully returned |
//| results (which would mean $b[0] has data |
//| in it) then use $b[0] (the file name of |
//| the banner image) and $b[1] (the url of |
//| the banner link) to construct the |
//| nesissary HTML tags to produce the |
//| banner and put that string into $c. |
//+------------------------------------------+
IF ($b[0]) {
$c =" <a href=\"" . $b[1] . "\" target=\"_blank\"><img border=\"0\" src=\"images/" . $b[0] . "\" align=\"right\" width=\"468\" height=\"60\"></a>";
}
//+------------------------------------------+
//| If the querry was not successful (and |
//| $b[0] evaluates to FALSE) put the HTML |
//| for a standard banner ad into $c. |
//+------------------------------------------+
ELSE {
$c = "<p align=\"center\"><a href=\"http://www.peoplesearching.com\" target=\"_blank\"><img border=\"0\" src=\"images/ps1banner.gif\" width=\"468\" height=\"60\"></a></p>";
}
//+------------------------------------------+
//| Return the contents of $c as the output |
//| of the function. |
//+------------------------------------------+
RETURN $c;
}
FUNCTION s1branches() { //-------------s1branches()-----
GLOBAL $conn, $branches;
$sql = "SELECT DISTINCT branch FROM installations ORDER BY branch";
$result = mysql_query($sql, $conn);
$i = 1;
$j = 1;
WHILE ($row = mysql_fetch_array($result)) {
$branches[$i] = trim($row[0]);
$i++;
}
$branches[0] = $i - 1;
WHILE ($j <= $i - 2) {
PRINT " new State($j, \"$branches[$j]\"),\n";
$j++;
}
PRINT " new State($j, \"$branches[$j]\")\n";
}
FUNCTION s1bases() { //----------------s1bases()-----
GLOBAL $conn, $branches;
$i = 1;
WHILE ($i < $branches[0]) {
$sql = "SELECT base_id, base, state FROM installations WHERE branch=\"$branches[$i]\" ORDER BY base";
$result = mysql_query($sql, $conn);
WHILE ($row = mysql_fetch_array($result)) {
$row[1] = trim($row[1]);
$row[2] = trim($row[2]);
PRINT " new Base($row[0], $i, \"$row[1], $row[2]\"),\n";
}
$i++;
}
$sql = "SELECT base_id, base, state FROM installations WHERE branch=\"$branches[$i]\" ORDER BY base";
$result = mysql_query($sql, $conn);
FOR ($j = 1; $row = mysql_fetch_array($result); $j++) {
$last[$j][0] = $row[0];
$last[$j][1] = trim($row[1]);
$last[$j][2] = trim($row[2]);
}
$j--;
$k = 1;
WHILE ($k < $j) {
PRINT " new Base(" . $last[$k][0] . ", $i, \"" . $last[$k][1] . ", " . $last[$k][2] . "\"),\n";
$k++;
}
PRINT " new Base(" . $last[$k][0] . ", $i, \"" . $last[$k][1] . ", " . $last[$k][2] . "\")\n";
}
FUNCTION white_space() { //------------white_space()-----
GLOBAL $what, $conn, $contacted;
IF ($what == "base" || $what == "loc_dir" || $what == "loc_bus" || $what == "web_ad") {
base_page();
} ELSE IF ($what == "contacted") {
$my_email = "email";
$continue = "/";
FOREACH ($contacted as $key => $value) {
$message = $message . "$key: $value\n\n";
}
$message = stripslashes($message);
$subject = $_REQUEST[subject];
$headers = "From: " . $Email . "\n" . "Return-Path: " . $Email . "\n" . "Reply-To: " . $Email . "\n";
mail($my_email,$subject,$message,$headers);
PRINT "<blockquote><br><p><font face=\"arial\" size=\"3\">Thank you";
IF (isset($contacted[name])) {PRINT ", $contacted[name]";}
PRINT ", we will process your request shortly.<br><a href=\"index.php\">Return to Home Page.</a></font></blockquote></p>\n";
} ELSE {
IF (empty($what)) {
$what = "home";
}
// Get Phase One Pages
$sql = "SELECT p1data FROM p1pages WHERE heading=\"$what\"";
$result = mysql_query($sql, $conn);
$data = mysql_fetch_array($result);
// Output
//PRINT " <blockquote>$data[0]</blockquote>\n";
PRINT " $data[0]\n";
}
}
FUNCTION base_page() { //--------------base_page()-----
GLOBAL $conn, $id_base, $what, $local, $dir_id;
IF ($what == "loc_dir" && $local == "Community Information") {
$what = "base";
} ELSE IF ($what == "loc_bus" && $local == "Local Businesses") {
$what = "base";
}
// Load the appropriate template(s)
$file = file("template06.txt");
//$scrip = file("script02.txt");
IF ($what == "web_ad") {
$sql = "SELECT p1data, base_id, heading FROM directory WHERE dir_id=\"$dir_id\"";
$result = mysql_query($sql, $conn);
$ad = mysql_fetch_array($result);
//$id_base = $ad[1];
}
// Get individual base data and put into $data[0-5]
$sql = "SELECT base, state, p1data, domain, banex FROM installations WHERE base_id=\"$id_base\"";
$result = mysql_query($sql, $conn);
$data = mysql_fetch_array($result);
$title = $data[0] . ", " . $data[1];
// Get catagories for "Local Directory" select box
$sql = "SELECT DISTINCT category FROM local_data WHERE (base_id=\"$id_base\" OR base_id=\"0\") ORDER BY category";
$result = mysql_query($sql, $conn);
WHILE ($row = mysql_fetch_array($result)) {
$catagories[] = trim($row[0]);
}
// Get headings for "Local Businesses" select box
$sql = "SELECT DISTINCT heading FROM directory WHERE (base_id=\"$id_base\" OR base_id=\"0\") AND active=\"y\" ORDER BY heading";
$result = mysql_query($sql, $conn);
WHILE ($row = mysql_fetch_array($result)) {
$headings[] = trim($row[0]);
}
$local = trim($local);
IF ($what == "loc_dir") {
$sql = "SELECT p1data FROM local_data WHERE base_id=\"$id_base\" AND category=\"$local\"";
$result = mysql_query($sql, $conn);
$local_data = mysql_fetch_array($result);
} ELSE IF ($what == "loc_bus") {
$sql = "SELECT name, telephone, url, dir_id FROM directory WHERE (base_id=\"$id_base\" OR base_id=\"0\") AND heading=\"$local\" AND active=\"y\" ORDER BY name";
$result = mysql_query($sql, $conn);
$local_data = " <table bordercolor=\"#1a2b6f\">\n <tr>\n <td vAlign=\"top\" align=\"left\" bgcolor=\"#1a2b6f\">\n <font face=\"Arial\" size=\"3\" color=\"#FFFFFF\">";
$local_data .= $local;
$local_data .= "</font>\n </td>\n </tr>\n <tr>\n <td>\n <hr align=\"center\" width=\"650\" noShade SIZE=\"1\">\n </td>\n </tr>\n";
WHILE ($row = mysql_fetch_array($result)) {
$local_data .= " <tr>\n <td vAlign=\"top\">\n";
$local_data .= " <font size=\"-1\" face=\"Arial\"><a href=\"index.php?what=web_ad&dir_id=" . $row[3] . "&id_base=$id_base\"><font color=\"#1a2b6f\"><b>" . $row[0] . "</b></font></a><br>" . $row[1] . "</font>\n";
IF ($row[2]) {
$local_data .= " </td>\n </tr>\n <tr>\n <td>\n <a href=\"http://" . $row[2] . "\" target=\"_blank\"><font face=\"Arial\" size=\"-1\" color=\"#1a2b6f\">" . $row[2] . "</font></a>\n";
}
$local_data .= " </td>\n </tr>\n <tr>\n <td>\n <hr align=\"center\" width=\"650\" noShade SIZE=\"1\">\n </td>\n </tr>\n";
}
$local_data .= " </table>\n";
}
IF ($what != "base") {
$anchor1 = "<a href=\"index.php?what=base&id_base=$id_base\">";
$anchor2 = "</a>";
}
// Output
plines(1, 4, $file);
IF ($data[3]) {
PRINT " <p>";
PRINT "$anchor1<font color=\"#000080\"><font face=\"Times New Roman\" size=\"4\">" . $data[3] . "$anchor2<br>\n";
PRINT " </font><font size=\"1\" face=\"Arial\"><b>" . $title . "</b></font></font></p>\n";
} ELSE {
PRINT " <p>$anchor1<font color=\"#000080\"><font face=\"Times New Roman\" size=\"3\">" . $title . "</font>$anchor2</p>\n";
}
plines(7, 8, $file);
PRINT " " . banner($id_base, $data[4]) . "\n";
plines(10, 11, $file);
//plines(1, 13, $scrip);
plines(12, 15, $file);
FOREACH ($catagories as $catagory) {
PRINT " <option>$catagory</option>\n";
}
plines(16, 17, $file);
PRINT " <input type=\"hidden\" name=\"id_base\" value=\"$id_base\">\n";
plines(19, 27, $file);
FOREACH ($headings as $heading) {
PRINT " <option>$heading</option>\n";
}
plines(28, 29, $file);
PRINT " <input type=\"hidden\" name=\"id_base\" value=\"$id_base\">\n";
plines(31, 37, $file);
IF ($what == "loc_dir") {
IF (empty($local_data[0])) {
PRINT " <font face=\"Arial\" size=\"4\">No Information Available: $local</font>\n";
} ELSE {
PRINT " <font face=\"Arial\" size=\"4\">$local:</font><br><br>\n";
PRINT " $local_data[0]\n </blockquote>\n";
}
} ELSE IF ($what == "loc_bus") {
PRINT "$local_data </blockquote>\n";
} ELSE IF ($what == "web_ad") {
$local_data = " <table bordercolor=\"#1a2b6f\">\n <tr>\n <td vAlign=\"top\" align=\"left\" bgcolor=\"#1a2b6f\">\n <a href=\"index.php?what=loc_bus&id_base=$id_base&local=$ad[2]\"><font face=\"Arial\" size=\"3\" color=\"#FFFFFF\">";
$local_data .= $ad[2];
$local_data .= "</a></font>\n </td>\n </tr>\n <tr>\n <td>\n <hr align=\"left\" width=\"650\" noShade SIZE=\"1\">\n </td>\n </tr>\n </table>\n";
PRINT "$local_data " . $ad[0] . "\n </blockquote>\n";
} ELSE {
PRINT " $data[2]\n </blockquote>\n";
}
}
?>