Version: 1.0
Type: Full Script
Category: BBS/Discussion
License: GNU General Public License
Description: A threaded message board/guestbook with search functionality, which does NOT require sql. In the download are 3 files html.inc view.php modify.php the will need to be split to its 3 parts See it working or download it at www.huenik.com
//html.inc
<?PHP
/*
This script / application is copyright to Huw (C) 2002
Huw from Huenik.com
READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE
TERMS (COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE MODIFYING OR USING THE
SOFTWARE PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE
TERMS OF THIS AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY,
INDICATE YOUR ACCEPTANCE OF THESE TERMS BY DOWNLOADING. IF YOU DO NOT AGREE
TO ALL OF THESE TERMS, PROMPTLY REMOVE THE UNUSED SOFTWARE FROM YOUR SYSTEM
1. After any modification to the code should it must be uploaded to the web
site from which it originated if possible. Otherwise it should be
uploaded to phpbuilder.com => code library => BBS/Discussion => 427 With
the version number ending with Alpha.
2. All modified versions must include the following line to be printed or
echoed on every viewable page 'Copyright to Huw.Ukso.com v1.0'
*/
# retreive querry commands
global $admin,$ColourSet,$thread;
# retreive querry commands, if sent by form
if (($admin=="")&&(isset($FORM_ADMIN))) $admin = $FORM_ADMIN;
/*
user modifiable strings
*/
$AdminPassword = "password"; # webmasters password
$AdminUser = "username"; # webmasters username
$webmaster_email = "webmaster@yoursite.com"; # webmasters email address
$web_address = "yoursite.com"; # website url
$delimeter = "!!!"; # string to sepporate all parts in data files
$results_guest = 20; # value of results to display for guest
$results_pole = 20; # value of results to display for pole
# data files
$guest_dat = "guest.data.file.dat"; # file storing guest board threads
$pole_dat = "pole.data.file.dat"; # file storing questions
# php files
$modify_php = "modify.php"; # file with modification / add / reply / remove commands
$view_php = "view.php"; # file with view / search commands
/*
end of user modifiable strings
Data file organisation. Not all parts of the databases are used.
File Guest Pole Log
0 $uidn $uidn $uidn
1 $person_name $person_name $HTTP_HOST
2 $email $email
3 $url $url $QUERY_STRING
4 $ip $ip $ip
5 $posted_on $posted_on $posted_on
6 $icq $icq $HTTP_REFERER
7 $message $question $HTTP_USER_AGENT
8 $subject
9 $level $PHP_SELF
10 $option1
11 $locked $option2
12 $option3
13 $ans1
14 $ans2
15 $ans3
16
17
18
19
*/
# default result values
if (isset($app))
{
if ($app == "guest")
$results = $results_guest;
else
$results = $results_pole;
}
# clear refresh, untill needed
$refresh = "";
# get ip, used in many functions
$ip = ip_retrieve();
# as multiple commands have been combined so have the files
$search_php = $view_php;
$add_php = $modify_php;
$remove_php = $modify_php;
$reply_php = $modify_php;
# dont report errors unless terminal
error_reporting(0);
# copy right link
$copy_right = "Copyright to Huenik.com v1.0";
# make all pages expire, so no browser caching occures
header ("Expires: " . gmdate("r", time())); // Current date
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Current time
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1, no cache command
header ("Pragma: no-cache"); // HTTP/1.0, no cache command
# admin username and password check
$admin_string = "";
$admin_page_enum = "";
if ($admin == true)
{
$admin = false;
$admin_pas_true = false;
if (($PHP_AUTH_USER == $AdminUser) && ($PHP_AUTH_PW == $AdminPassword))
{
$admin = true;
$admin_string = '<input name="admin" id="input" type="hidden" value="true">';
$admin_page_enum = "&admin=true";
}
else
{
header('WWW-Authenticate: Basic realm="Admin Log In Attempt"');
header('HTTP/1.0 401 Unauthorized');
echo "Please log on";
exit;
}
}
# view EOTs
$html1 = <<<EOT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<Base target="_parent">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta http-equiv="Reply-to" content="http://www.huw.ukso.com">
EOT;
$html2 = <<<EOT
</HEAD>
<BODY>
<b style="font-style: italic; text-align: center;">
EOT;
$html3 = <<<EOT
</b>
<hr width="75%">
<a href="$view_php?app=guest$admin_page_enum">GUEST BOOK</a> - <a href="$view_php?app=pole$admin_page_enum">VISITOR POLE</a> - <a href="$view_php?app=guest&admin=true">ADMIN GUEST BOOK</a> - <a href="$view_php?app=pole&admin=true">ADMIN VISITOR POLE</a> - <a href="mailto:$webmaster_email">Webmaster Email</a>
<hr width="75%">
EOT;
$html4 = <<<EOT
<hr width="75%">
EOT;
$html5 = <<<EOT
<hr width="75%">
$copy_right
EOT;
$html6 = <<<EOT
</BODY>
</html>
EOT;
# find next available uidn
function next_uidn($file_contents)
{
global $delimeter;
# detect the next uidn value in the database
$uidn = 0;
for ($i = 1; $i < count($file_contents); $i++)
{
$exploded_line = explode($delimeter,$file_contents[$i]);
if (($exploded_line[0]) >= $uidn)
$uidn = ($exploded_line[0] + 1);
}
return ($uidn);
}
# find ip
function ip_retrieve()
{
global $view_php;
# define ip removed by to eq the ip address of the administrator
$fp = fopen($view_php,"r+");
$ippost = fread($fp,15);
fclose($fp);
$ip_removed_by = getenv("REMOTE_ADDR");
return ($ip_removed_by);
}
# find line with uidn value
function line_no($uidn_no, $file_contents)
{
global $delimeter;
for ($i = 0; $i < count($file_contents); $i++)
{
$line_no = explode($delimeter,$file_contents[$i]);
if ($line_no[0] == $uidn_no)
return ($i);
}
return (false);
}
# find uidn with line value
function uidn_no($line_no, $file_contents)
{
global $delimeter;
$uidn_no = explode($delimeter,$file_contents[$line_no]);
return ($uidn_no[0]);
}
# find the end of a thread for remove and search, returns uidn no
function thread_ending($from_uidn, $file_contents)
{
global $delimeter;
# get the line number for the specified uidn
$backfrom = line_no($from_uidn, $file_contents);
if ($backfrom != false)
{
$tmp_explode = explode($delimeter,$file_contents[$backfrom]);
$return_line = $backfrom;
$tmp_data = $tmp_explode[9];
$i = $backfrom-1;
$tmp_explode = explode($delimeter,$file_contents[$i]);
while ($tmp_explode[9] > $tmp_data)
{
$return_line = $i;
$i--;
$tmp_explode = explode($delimeter,$file_contents[$i]);
}
$return_uidn = uidn_no($return_line,$file_contents);
return ($return_uidn);
}
else
return (false);
}
# find the start of a thread for search, returns uidn no
function thread_starting($from_uidn, $file_contents)
{
global $delimeter;
# get the line number for the specified uidn
$i = line_no($from_uidn, $file_contents);
if ($i != false)
{
$return_line = $i;
$tmp_explode = explode($delimeter,$file_contents[$i]);
if ($tmp_explode[9] == 1)
$return_uidn = uidn_no($i,$file_contents);
else
{
while ($tmp_explode[9] > 1)
{
$return_line = $i;
$i++;
$tmp_explode = explode($delimeter,$file_contents[$i]);
}
$return_uidn = uidn_no(($return_line+1),$file_contents);
}
return ($return_uidn);
}
else
return (false);
}
# strip certain tags prior to data writes, so the view cannot be corrupted
function stripstrings ($in)
{
global $delimeter;
$in = strip_tags ($in, "<a><img><b><br><hr>");
$in = str_replace($delimeter,"",$in);
$in = str_replace("\n","|\'new_line|",$in);
$in = str_replace("\r","|\'new_line|",$in);
$in = str_replace("|\'new_line|","<br>",$in);
$in = str_replace("\'","'",$in);
$in = str_replace('\"','"',$in);
return ($in);
}
?>
//view.php
<?PHP
/*
This script / application is copyright to Huw (C) 2002
Huw from Huenik.com
READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE
TERMS (COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE MODIFYING OR USING THE
SOFTWARE PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE
TERMS OF THIS AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY,
INDICATE YOUR ACCEPTANCE OF THESE TERMS BY DOWNLOADING. IF YOU DO NOT AGREE
TO ALL OF THESE TERMS, PROMPTLY REMOVE THE UNUSED SOFTWARE FROM YOUR SYSTEM
1. After any modification to the code should it must be uploaded to the web
site from which it originated if possible. Otherwise it should be
uploaded to phpbuilder.com => code library => BBS/Discussion => 427 With
the version number ending with Alpha.
2. All modified versions must include the following line to be printed or
echoed on every viewable page 'Copyright to Huw.Ukso.com v1.0'
*/
# retreive querry commands
global $app,$sort,$search,$data,$type,$page,$from,$ord;
if (($app=="")&&(isset($FORM_APP))) $app = $FORM_APP;
if (($sort=="")&&(isset($FORM_SORT))) $sort = $FORM_SORT;
if (($search=="")&&(isset($FORM_SEARCH))) $search = $FORM_SEARCH;
if (($data=="")&&(isset($FORM_DATA))) $data = $FORM_DATA;
if (($type=="")&&(isset($FORM_TYPE))) $type = $FORM_TYPE;
if (($page=="")&&(isset($FORM_PAGE))) $page = $FORM_PAGE;
if (($from=="")&&(isset($FORM_FROM))) $from = $FORM_FROM;
if (($ord=="")&&(isset($FORM_ORD))) $ord = $FORM_ORD;
if ($app != "")
$query_string = "&app=" . $app;
if ($sort != "")
$query_string .= "&sort=" . $sort;
if ($search != "")
$query_string .= "&search=" . $search;
if ($data != "")
$query_string .= "&data=" . $data;
if ($type != "")
$query_string .= "&type=" . $type;
if ($page != "")
$query_string .= "&page=" . $page;
if ($from != "")
$query_string .= "&from=" . $from;
if ($ord != "")
$query_string .= "&ord=" . $ord;
include("html.inc");
if ($page == "")
$page = 1;
# setup data file
if ($app == "pole")
{
$file_contents = file($pole_dat);
$command_links = "<a href='" . $add_php . "?app=" . $app . "$admin_page_enum'>Add New Question</a>";
$additional_search_forms = <<<EOT
<option value="all" selected>All</option>
<option value="1">Name</option>
<option value="7">Question</option>
<option value="10">Answer 1</option>
<option value="11">Answer 2</option>
<option value="12">Answer 3</option>
EOT;
$outline_data = "Viewing the visitor pole, ask a question or answer another. To reorder the data click on the appropriate links.";
# used for search form title
$app_name = "the visitor pole";
# set default sort function if undefined
if ($sort == "")
$sort = 13;
# if ord undefined set to 1
if ($ord == "")
$ord = 1;
}
else
{
$app = "guest";
$file_contents = file($guest_dat);
$command_links = "<a href='" . $add_php . "?app=" . $app . "$admin_page_enum$thread_page_enum'>Add New Thread</a>";
$additional_search_forms = <<<EOT
<option value="all" selected>All</option>
<option value="1">Name</option>
<option value="7">Message</option>
<option value="8">Subject</option>
EOT;
# used for search form title
$app_name = "the guest book";
if ($thread != "")
$app_name = "the message board";
$outline_data = "Viewing $app_name, add a message, get help or anything else you can think of.";
if ($search != "")
$outline_data .= "<br><br>Click on a post to view the rest of the searched thread.";
}
$title = "Viewing " . $app_name;
# if from is unset then set as last post
if ($from == "")
for ($i = 0; $i < count($file_contents); $i++)
$from_array[$i] = uidn_no((count($file_contents)-$i-1),$file_contents);
else
{
# get lines of from and above for search => view thread
$from_line_no = line_no($from,$file_contents);
$to_uidn_no = thread_ending($from, $file_contents);
$to_line_no = line_no($to_uidn_no,$file_contents);
$j = 0;
$i = $from_line_no;
while ($i >= $to_line_no)
{
$from_array[$j] = uidn_no($i,$file_contents);
$j++;
$i--;
}
# create from command for page links in search => thread view
$from_command = "&from=" . $from;
}
# define posts to be viewed if not pre defined else search
if ($search != "")
{
$val_of_from = 0;
$from_array = false;
# check all lines in app
for ($i = (count($file_contents)-1); $i > 0; $i--)
{
# clear for next line proccessing
$data_to_search = "";
# if data set then only search that part
$exploded_search_data = explode($delimeter,$file_contents[$i]);
if ( ($data != "") && ($data != "all") )
{
$data_to_search = " ".$exploded_search_data[$data]." ";
$from_array[$val_of_from] = search($data_to_search,$search,$i,$file_contents,$type);
if ($from_array[$val_of_from] != "")
$val_of_from++;
}
else if ( ($data == "") || ($data == "all") )
{
if ($app == "guest")
$data_to_search = " $exploded_search_data[1] $exploded_search_data[7] $exploded_search_data[8] ";
else if ($app == "pole")
$data_to_search = " $exploded_search_data[1] $exploded_search_data[7] $exploded_search_data[10] $exploded_search_data[11] $exploded_search_data[12] ";
$from_array[$val_of_from] = search($data_to_search,$search,$i,$file_contents,$type);
if ($from_array[$val_of_from] != "")
$val_of_from++;
}
}
$search_command = "&search=" . $search . "&data=" . $data . "&type=" . $type;
$title = "Searching " . $app_name . " for : " . $search;
}
# search function
function search($data_to_search,$search,$i,$file_contents,$type)
{
# get all search words
$search = strtolower($search);
$search = str_replace("-"," ",$search);
$search = str_replace("+"," ",$search);
$search = str_replace(" "," ",$search);
$search = str_replace(" "," ",$search);
$search = str_replace(" "," ",$search);
$search = str_replace(" "," ",$search);
$search_array = explode(" ",$search);
$data_to_search = strtolower($data_to_search);
if ($type == "or")
{
$found_check1 = false;
for ($m = 0; $m < count($search_array); $m++)
{
$found_check = false;
# find search within required data
$found_check = explode($search_array[$m],$data_to_search);
if ($found_check[1] != false)
$found_check1 = true;
}
# if found record location, in uidn format
if ($found_check1)
$from = uidn_no($i,$file_contents);
else
$from = false;
}
else
{
$found_check1 = true;
for ($m = 0; $m < count($search_array); $m++)
{
$found_check = false;
# find search within required data
$found_check = explode($search_array[$m],$data_to_search);
if ($found_check[1] != true)
$found_check1 = false;
}
# if found record location, in uidn format
if ($found_check1)
$from = uidn_no($i,$file_contents);
else
$from = false;
}
return($from);
}
# define search form
$search_form = <<<EOT
<br><br>
<form action="$view_php" name="search" onsubmit="return '$view_php'" method="post">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="main" width="100%">
<tr>
<td colspan="2">
Search $app_name
</td>
</tr>
<tr>
<td colspan="2">
<input type="text" name="search" size="22" id="input" class="input">
</td>
</tr>
<!--
<tr>
<td valign="top">
and :
</td>
<td>
<input type="radio" name="type" value="and" checked class="input">
</td>
</tr>
<tr>
<td valign="top">
or :
</td>
<td>
<input type="radio" name="type" value="or" class="input">
</td>
</tr>
-->
<tr>
<td colspan="2">
<select name="data" class="input">
$additional_search_forms
</select>
<input type="Submit" name="submit" value=" Go " class=button>
</td>
</tr>
<tr>
<td colspan="2">
<input name="app" id="input" type="hidden" value="$app">
$admin_string
$thread_string
</td>
</tr>
</table>
</form>
EOT;
# sort the posts according to selected sort command. dont sort thread.search or not guest.not sort
if ( ($sort != 0) && ($app != "guest") )
{
for ($i = 0; $i < count($from_array); $i++)
{
$explode = explode($delimeter, $from_array[$i]);
$from_line_tmp = line_no($explode[0],$file_contents);
if ($from_line_tmp != false)
{
$exploded_line = explode($delimeter,$file_contents[$from_line_tmp]);
# 13 to 15 all do the same
if ( ($app == "pole") && ( ($sort == 13) || ($sort == 14) || ($sort == 15) ) )
$from_line_array[$i] = ($exploded_line[13] + $exploded_line[14] + $exploded_line[15]) . $delimeter . $from_array[$i] . $delimeter;
else
$from_line_array[$i] = $exploded_line[$sort] . $delimeter . $from_array[$i] . $delimeter;
if ($explode[1] != "")
$from_line_array[$i] .= $explode[1];
}
else
$from_line_array[$i] = false;
}
sort($from_line_array);
if ( ($ord == "") || ($ord == 0) )
{
for ($i = 0; $i < count($from_line_array); $i++)
{
$exploded_line = explode($delimeter,$from_line_array[$i]);
$from_array[$i] = $exploded_line[1];
if ($exploded_line[2] != "")
$from_array[$i] .= $delimeter . $exploded_line;
}
}
else
{
for ($i = 0; $i < count($from_line_array); $i++)
{
$array_position = (count($from_line_array)-$i-1);
$exploded_line = explode($delimeter,$from_line_array[$array_position]);
$from_array[$i] = $exploded_line[1];
if ($exploded_line[2] != "")
$from_array[$i] .= $delimeter . $exploded_line;
}
}
$ord_command = "&sort=" . $sort . "&ord=" . $ord;
# define ord(current sort no) to eq 1 if they are in use, if not in use leave ord values blank
if ( ($sort == 1) && ( ($ord == "") || ($ord == 0) ) )
$ord1 = "&ord=1";
else if ( ($sort == 2) && ( ($ord == "") || ($ord == 0) ) )
$ord2 = "&ord=1";
else if ( ($sort == 3) && ( ($ord == "") || ($ord == 0) ) )
$ord3 = "&ord=1";
else if ( ($sort == 4) && ( ($ord == "") || ($ord == 0) ) )
$ord4 = "&ord=1";
else if ( ($sort == 5) && ( ($ord == "") || ($ord == 0) ) )
$ord5 = "&ord=1";
else if ( ($sort == 6) && ( ($ord == "") || ($ord == 0) ) )
$ord6 = "&ord=1";
else if ( ($sort == 7) && ( ($ord == "") || ($ord == 0) ) )
$ord7 = "&ord=1";
else if ( ($sort == 8) && ( ($ord == "") || ($ord == 0) ) )
$ord8 = "&ord=1";
else if ( ($sort == 9) && ( ($ord == "") || ($ord == 0) ) )
$ord9 = "&ord=1";
else if ( ($sort == 10) && ( ($ord == "") || ($ord == 0) ) )
$ord10 = "&ord=1";
else if ( ($sort == 11) && ( ($ord == "") || ($ord == 0) ) )
$ord11 = "&ord=1";
else if ( ($sort == 12) && ( ($ord == "") || ($ord == 0) ) )
$ord12 = "&ord=1";
else if ( ($sort == 13) && ( ($ord == "") || ($ord == 0) ) )
$ord13 = "&ord=1";
else if ( ($sort == 14) && ( ($ord == "") || ($ord == 0) ) )
$ord14 = "&ord=1";
else if ( ($sort == 15) && ( ($ord == "") || ($ord == 0) ) )
$ord15 = "&ord=1";
else if ( ($sort == 16) && ( ($ord == "") || ($ord == 0) ) )
$ord16 = "&ord=1";
else if ( ($sort == 17) && ( ($ord == "") || ($ord == 0) ) )
$ord17 = "&ord=1";
else if ( ($sort == 18) && ( ($ord == "") || ($ord == 0) ) )
$ord18 = "&ord=1";
else if ( ($sort == 19) && ( ($ord == "") || ($ord == 0) ) )
$ord19 = "&ord=1";
# define these values to be ord 1 as default value, unless set otherwise by being in use
if ($sort != 5)
$ord5 = "&ord=1";
if ($sort != 8)
$ord8 = "&ord=1";
}
# find last available page
$last_page_no = round((count($from_array) / $results) + 0.5);
# define page links, if from is set then resend from to ensure correct data is displayed when chainging to next/prev page
if ($last_page_no > 1)
{
if ( ( $page - 1 ) > 0 )
$next_url = " href='" . $view_php . "?app=" . $app . "&page=" . ($page-1) . "$from_command$admin_page_enum$search_command$ord_command$thread_page_enum'";
if ( ( $page * $results ) <= ( count($from_array) - 1) )
$prev_url = " href='" . $view_php . "?app=" . $app . "&page=" . ($page+1) . "$from_command$admin_page_enum$search_command$ord_command$thread_page_enum'";
$nextprev_all = "<a" . $next_url . ">Next Page</a>";
for ($i = 1; $i <= $last_page_no; $i++)
{
$ib = $i;
if ($i == $page)
$ib = "<b>" . $i . "</b>";
$nextprev_all .= " - <a href='" . $view_php . "?app=" . $app . "&page=" . $i.$from_command.$admin_page_enum.$search_command.$ord_command . $thread_page_enum . "'>" . $ib . "</a>";
}
$nextprev_all .= " - <a" . $prev_url . ">Previous Page</a>";
}
# define what to show from view, search, sort
$from_page = $results * $page;
$to_page = $from_page - $results;
$j = 0;
$i = $to_page;
while ( ($i < $from_page) && ($i <= count($from_array)) )
{
$from_array2[$j] = $from_array[$i];
$j++;
$i++;
}
# clear arrays
$from_array = false;
$threads_sub = false;
# set from arrays correctly
for ($i = 0; $i <= count($from_array2); $i++)
$from_array[$i] = $from_array2[$i];
# define sort links
# define the upper part of tables required for logs, and files with search
if ($app == "pole")
$body_data .= <<<EOT
Sort Data by :
<a href='$view_php?app=$app&sort=1$ord1$admin_page_enum$search_command'>Name</a>
<a href='$view_php?app=$app&sort=5$ord5$admin_page_enum$search_command'>Date</a>
<a href='$view_php?app=$app&sort=13$ord13$admin_page_enum$search_command'>Replies</a>
<TABLE cellspacing=0 cellpadding=0 border=0 class='main' width='100%'>
EOT;
else
$body_data .= <<<EOT
<TABLE cellspacing=0 cellpadding=0 border=0 class='main' width='100%'>
EOT;
# no posts are being displayed
$showing_post = false;
# display all required posts
for ($i = 0; $i < count($from_array); $i++)
{
$explode = explode($delimeter,$from_array[$i]);
if ($explode[1] != "")
$from_once = line_no($explode[1],$file_contents);
else
$from_once = line_no($explode[0],$file_contents);
if ($from_once != false)
{
$explode_dat_view = explode($delimeter,$file_contents[$from_once]);
if ( ($app == "guest") && ($search != "") )
{
# find where the start of the thread is for the link
$from_thread_start = thread_starting($from_array[$i], $file_contents);
# if its a search then set the link
if ($from_thread_start != false)
$explode_dat_view[25] = $view_php . "?app=" . $app . "&from=" . $from_thread_start . $admin_page_enum . $thread_page_enum;
$body_data .= view($app,$explode_dat_view);
$showing_post = true;
}
else
{
$body_data .= view($app,$explode_dat_view);
$showing_post = true;
}
}
}
# if no posts have been displayed set default blank posts
if (!$showing_post)
{
if ($search != "")
$body_data .= "\n\t\t\t\t\t<tr><td>No results found. Please modify your search and try again.</td></tr>\n";
else
{
if ($app == "guest")
$explode_dat_view = array ("-1","Your Name","","http://" . $HTTP_HOST,"","","","Your message here","Your subject here","0","","","","","","","","","","");
else if ($app == "pole")
$explode_dat_view = array ("-1","Your Name","","http://" . $HTTP_HOST,"","","","Your question here","","","Answer 1","Answer 2","Answer 3","","","","","","","");
$body_data .= view($app,$explode_dat_view);
}
}
# end of table
$body_data .= "\n\t\t\t\t</TABLE>";
# change to smilles, and strip html
function smiler($smilers_change)
{
# replace valid smileys with an image file
$smilers_change = str_replace (":\)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":0\)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":o\)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":O\)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":\(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":0\(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":o\(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":O\(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":P", "<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":p", "<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("\;P", "<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("\;p", "<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("\*D", "<IMG SRC=www.huw.ukso.com/smilies/shiny.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("\;\)", "<IMG SRC=www.huw.ukso.com/smilies/wink.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":D", "<IMG SRC=www.huw.ukso.com/smilies/biggrin.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":V", "<IMG SRC=www.huw.ukso.com/smilies/confused.gif HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("B)", "<IMG SRC=www.huw.ukso.com/smilies/coool.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":\-\(", "<IMG SRC=www.huw.ukso.com/smilies/cry.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("}>", "<IMG SRC=www.huw.ukso.com/smilies/devil.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("O\+", "<IMG SRC=www.huw.ukso.com/smilies/heart.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":7", "<IMG SRC=www.huw.ukso.com/smilies/loveit.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":\*", "<IMG SRC=www.huw.ukso.com/smilies/puh.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":r", "<IMG SRC=www.huw.ukso.com/smilies/pukey.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("\;\(", "<IMG SRC=www.huw.ukso.com/smilies/sadley.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":Y", "<IMG SRC=www.huw.ukso.com/smilies/vork.gif HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":9", "<IMG SRC=www.huw.ukso.com/smilies/yummie.gif BORDER=0>", $smilers_change);
$smilers_change = str_replace (":\&", "<IMG SRC=www.huw.ukso.com/smilies/michel.gif BORDER=0>", $smilers_change);
$smilers_change = str_replace (":)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":0)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":o)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":O)", "<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":0(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":o(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":O(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":(", "<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (";P", "<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (";p", "<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("*D", "<IMG SRC=www.huw.ukso.com/smilies/shiny.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (";)", "<IMG SRC=www.huw.ukso.com/smilies/wink.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":-(", "<IMG SRC=www.huw.ukso.com/smilies/cry.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace ("O+", "<IMG SRC=www.huw.ukso.com/smilies/heart.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":*", "<IMG SRC=www.huw.ukso.com/smilies/puh.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (";(", "<IMG SRC=www.huw.ukso.com/smilies/sadley.gif WIDTH=15 HEIGHT=15 BORDER=0>", $smilers_change);
$smilers_change = str_replace (":&", "<IMG SRC=www.huw.ukso.com/smilies/michel.gif BORDER=0>", $smilers_change);
return ($smilers_change);
}
# return the current info, in correct format for required app
function view($app,$explode_dat_view)
{
global $admin,$reply_php,$remove_php,$modify_php,$pages_available,$delimeter,$admin_page_enum,$outline_colour,$foot_colour,$link_colour,$thread_page_enum,$view_php;
# if theres an email address add a link
if ($explode_dat_view[2] != "")
$explode_dat_view[2] = "href='mailto:" . $explode_dat_view[2] . "'";
# if admin add remove and modify commands, show email addy to admin users
if ($app == "guest")
$explode_dat_view[28] = " | <a href='" . $modify_php . "?app=$app&lock=lock&uidn=" . $explode_dat_view[0] . "$admin_page_enum$thread_page_enum'>Lock</a> | <a href='" . $modify_php . "?app=$app&lock=unlock&uidn=" . $explode_dat_view[0] . "$admin_page_enum$thread_page_enum'>Unlock</a>";
if ($admin == true)
$admin_commands = "<a href='" . $remove_php . "?app=$app&remove=true&uidn=" . $explode_dat_view[0] . "$admin_page_enum$thread_page_enum'>Remove</a> | <a href='" . $modify_php . "?app=$app&modify=true&uidn=" . $explode_dat_view[0] . "$admin_page_enum$thread_page_enum'>Modify</a>" . $explode_dat_view[28];
else if ($admin != true)
$explode_dat_view[4] = "";
# if theres a web url make a link
if ($explode_dat_view[3] != "")
$explode_dat_view[3] = "href='" . $explode_dat_view[3] . "'";
# if icq supplied make a link to user info
if ($explode_dat_view[6] != "")
$explode_dat_view[6] = "href='http://wwp.icq.com/scripts/search.dll?to=" . $explode_dat_view[6] . "'";
if ($app == "guest")
{
# width of table based upon layer
$explode_dat_view[9] = (100 - ($explode_dat_view[9] * 5));
if (($admin_commands != "") && ($admin == true) )
$admin_commands = " | " . $admin_commands;
$explode_dat_view[7] = smiler($explode_dat_view[7]);
$explode_dat_view[8] = smiler($explode_dat_view[8]);
if ($explode_dat_view[25] != "")
{
$explode_dat_view[30] = "<a href='" . $explode_dat_view[25] . "''>";
$explode_dat_view[31] = "</a>";
$explode_dat_view[32] = "onmouseover=this.style.cursor='hand'";
$explode_dat_view[9] = 100;
if ($admin_commands != "")
$admin_commands = " | <font color=" . $link_colour . ">Remove</font> | <font color=" . $link_colour . ">Modify</font> | <font color=" . $link_colour . ">Lock</font> | <font color=" . $link_colour . ">Unlock</font>" . $explode_dat_view[27];
$Reply = "<font color=" . $link_colour . ">Reply to Message</font>";
$explode_dat_view[3] = "<font color=" . $link_colour . ">Home Page</font>";
$explode_dat_view[2] = "<font color=" . $link_colour . ">Mail the Author</font>";
$explode_dat_view[6] = "<font color=" . $link_colour . ">ICQ</font>";
}
else
{
$Reply = '<A href="' . $reply_php . '?uidn=' . $explode_dat_view[0] . '&app=' . $app . $admin_page_enum . $thread_page_enum . '">Reply to Message</A>';
$explode_dat_view[3] = "<A " . $explode_dat_view[3] . " target='_blank'>Home Page</A>";
$explode_dat_view[2] = "<A " . $explode_dat_view[2] . ">Mail the Author</A>";
$explode_dat_view[6] = "<A " . $explode_dat_view[6] . ">ICQ</A>";
}
if ($explode_dat_view[11] == "1")
{
$explode_dat_view[29] = " - Post locked.";
$Reply = "<font color='#2F468F'>Reply to Message</font>";
}
if ($explode_dat_view[8] == "")
$explode_dat_view[8] = "No subject";
$body_data = <<<EOT
<tr>
<td>
$explode_dat_view[30]
<TABLE cellspacing=0 cellpadding=0 border=0 width=$explode_dat_view[9]% align=right class="main" $explode_dat_view[32]>
<TR>
<TD valign="bottom" bgcolor="$outline_colour">
<b>$explode_dat_view[8]</b>$explode_dat_view[29]<br>
Posted by <b>$explode_dat_view[1]</b> on <b>$explode_dat_view[5]</b> $explode_dat_view[4]
</TD>
</TR>
<TR>
<TD valign="top">
$explode_dat_view[7]
</TD>
</TR>
<TR>
<TD valign="top" bgcolor="$foot_colour">
$Reply | $explode_dat_view[3] | $explode_dat_view[2] | $explode_dat_view[6]$admin_commands
</TD>
</TR>
</TABLE>
$explode_dat_view[31]
</td>
</tr>
EOT;
}
else if ($app == "pole")
{
if (($admin_commands != "") && ($admin == true) )
$admin_commands = " | " . $admin_commands;
# percentages to 0 dp
$explode_dat_view_13 = number_format((($explode_dat_view[13] / ( $explode_dat_view[13] + $explode_dat_view[14] + $explode_dat_view[15] )) * 100),0);
$explode_dat_view_14 = number_format((($explode_dat_view[14] / ( $explode_dat_view[13] + $explode_dat_view[14] + $explode_dat_view[15] )) * 100),0);
$explode_dat_view_15 = number_format((($explode_dat_view[15] / ( $explode_dat_view[13] + $explode_dat_view[14] + $explode_dat_view[15] )) * 100),0);
$body_data = <<<EOT
<tr>
<td>
<TABLE cellspacing=0 cellpadding=0 border=0 width=100% align=center class="main">
<TR>
<TD valign="bottom" bgcolor="$outline_colour">
<b>$explode_dat_view[7]</b><br>
Posted by <b>$explode_dat_view[1]</b> on <b>$explode_dat_view[5]</b> $explode_dat_view[4]
</TD>
</TR>
<TR>
<TD valign="top">
$explode_dat_view[10] : $explode_dat_view[13] votes ($explode_dat_view_13%) <a href="$reply_php?uidn=$explode_dat_view[0]&app=$app&ans=1$admin_page_enum">Vote</a><br>
$explode_dat_view[11] : $explode_dat_view[14] votes ($explode_dat_view_14%) <a href="$reply_php?uidn=$explode_dat_view[0]&app=$app&ans=2$admin_page_enum">Vote</a><br>
$explode_dat_view[12] : $explode_dat_view[15] votes ($explode_dat_view_15%) <a href="$reply_php?uidn=$explode_dat_view[0]&app=$app&ans=3$admin_page_enum">Vote</a><br>
</TD>
</TR>
<TR>
<TD valign="top" bgcolor="$foot_colour">
<A $explode_dat_view[3] target="_blank">Home Page</A> | <A $explode_dat_view[2]>Mail the Author</A> | <a $explode_dat_view[6]>ICQ</a>$admin_commands
</TD>
</TR>
</TABLE>
</td>
</tr>
EOT;
}
return ($body_data);
}
# echoing all required matterials for view
echo <<<EOT
$html1
<title>$title</title>
$html2
$title
$html3
$outline_data
$search_form
$html4
<center>
$command_links<br>
$nextprev_all
</center>
$body_data
<center>
$nextprev_all<br>
$command_links
</center>
$html5
$html6
EOT;
?>
//modify.php
<?PHP
/*
This script / application is copyright to Huw (C) 2002
Huw from Huenik.com
READ THE TERMS OF THIS AGREEMENT AND ANY PROVIDED SUPPLEMENTAL LICENSE
TERMS (COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE MODIFYING OR USING THE
SOFTWARE PACKAGE. BY OPENING THE SOFTWARE MEDIA PACKAGE, YOU AGREE TO THE
TERMS OF THIS AGREEMENT. IF YOU ARE ACCESSING THE SOFTWARE ELECTRONICALLY,
INDICATE YOUR ACCEPTANCE OF THESE TERMS BY DOWNLOADING. IF YOU DO NOT AGREE
TO ALL OF THESE TERMS, PROMPTLY REMOVE THE UNUSED SOFTWARE FROM YOUR SYSTEM
1. After any modification to the code should it must be uploaded to the web
site from which it originated if possible. Otherwise it should be
uploaded to phpbuilder.com => code library => BBS/Discussion => 427 With
the version number ending with Alpha.
2. All modified versions must include the following line to be printed or
echoed on every viewable page 'Copyright to Huw.Ukso.com v1.0'
*/
global $app,$uidn,$in1,$in2,$in3,$in4,$in5,$in6,$in7,$in8,$in9,$in10,$in11,$in12,$in13,$in14,$in15,$in16,$in17,$in18,$in19,$ans,$HTTP_POST_FILES,$HTTP_COOKIE_VARS,$modify,$remove,$userfile,$lock;
if (($app=="")&&(isset($FORM_APP))) $app = $FORM_APP;
if (($uidn=="")&&(isset($FORM_UIDN))) $uidn = $FORM_UIDN;
if (($in1=="")&&(isset($FORM_IN1))) $in1 = $FORM_IN1;
if (($in2=="")&&(isset($FORM_IN2))) $in2 = $FORM_IN2;
if (($in3=="")&&(isset($FORM_IN3))) $in3 = $FORM_IN3;
if (($in4=="")&&(isset($FORM_IN4))) $in4 = $FORM_IN4;
if (($in5=="")&&(isset($FORM_IN5))) $in5 = $FORM_IN5;
if (($in6=="")&&(isset($FORM_IN6))) $in6 = $FORM_IN6;
if (($in7=="")&&(isset($FORM_IN7))) $in7 = $FORM_IN7;
if (($in8=="")&&(isset($FORM_IN8))) $in8 = $FORM_IN8;
if (($in9=="")&&(isset($FORM_IN9))) $in9 = $FORM_IN9;
if (($in10=="")&&(isset($FORM_IN10))) $in10 = $FORM_IN10;
if (($in11=="")&&(isset($FORM_IN11))) $in11 = $FORM_IN11;
if (($in12=="")&&(isset($FORM_IN12))) $in12 = $FORM_IN12;
if (($in13=="")&&(isset($FORM_IN13))) $in13 = $FORM_IN13;
if (($in14=="")&&(isset($FORM_IN14))) $in14 = $FORM_IN14;
if (($in15=="")&&(isset($FORM_IN15))) $in15 = $FORM_IN15;
if (($in16=="")&&(isset($FORM_IN16))) $in16 = $FORM_IN16;
if (($in17=="")&&(isset($FORM_IN17))) $in17 = $FORM_IN17;
if (($in18=="")&&(isset($FORM_IN18))) $in18 = $FORM_IN18;
if (($in19=="")&&(isset($FORM_IN19))) $in19 = $FORM_IN19;
if (($modify=="")&&(isset($FORM_MODIFY))) $modify = $FORM_MODIFY;
if (($remove=="")&&(isset($FORM_REMOVE))) $remove = $FORM_REMOVE;
if (($lock=="")&&(isset($FORM_LOCK))) $lock = $FORM_LOCK;
if ($app != "")
$query_string = "&app=" . $app;
if ($uidn != "")
$query_string .= "&uidn=" . $uidn;
if ($modify != "")
$query_string = "&modify=" . $modify;
if ($remove != "")
$query_string .= "&remove=" . $remove;
# include default functions and layouts
include("html.inc");
# to correct html coding which user may have sent, only allowing some html code not allowing the delimeter or \n or \r
if ($in1 != "")
$in1 = stripstrings($in1);
if ($in2 != "")
$in2 = stripstrings($in2);
if ($in3 != "")
{
$tmp_explode_http = explode("http://"," " . $in3);
$tmp_explode_ftp = explode("ftp://"," " . $in3);
$tmp_explode_https = explode("https://"," " . $in3);
if ( !isset($tmp_explode_http[1]) && !isset($tmp_explode_ftp[1]) && !isset($tmp_explode_https[1]) )
$in3 = "http://" . $in3;
$in3 = stripstrings($in3);
}
if ($in4 != "")
$in4 = stripstrings($in4);
if ($in5 != "")
$in5 = stripstrings($in5);
if ($in6 != "")
$in6 = stripstrings($in6);
if ($in7 != "")
$in7 = stripstrings($in7);
if ($in8 != "")
$in8 = stripstrings($in8);
if ($in9 != "")
$in9 = stripstrings($in9);
if ($in10 != "")
$in10 = stripstrings($in10);
if ($in11 != "")
$in11 = stripstrings($in11);
if ($in12 != "")
$in12 = stripstrings($in12);
if ($in13 != "")
$in13 = stripstrings($in13);
if ($in14 != "")
$in14 = stripstrings($in14);
if ($in15 != "")
$in15 = stripstrings($in15);
if ($in16 != "")
$in16 = stripstrings($in16);
if ($in17 != "")
$in17 = stripstrings($in17);
if ($in18 != "")
$in18 = stripstrings($in18);
if ($in19 != "")
$in19 = stripstrings($in19);
# define smiles
$smiles = <<<EOT
<table align="center" class="main" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
Place your cursor above the image to see its key combination.<br>
<IMG SRC=www.huw.ukso.com/smilies/smile.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":)">
<IMG SRC=www.huw.ukso.com/smilies/frown.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":(">
<IMG SRC=www.huw.ukso.com/smilies/puh2.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":P">
<IMG SRC=www.huw.ukso.com/smilies/shiny.gif WIDTH=15 HEIGHT=15 BORDER=0 alt="*D">
<IMG SRC=www.huw.ukso.com/smilies/wink.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=";)">
<IMG SRC=www.huw.ukso.com/smilies/biggrin.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":D">
<IMG SRC=www.huw.ukso.com/smilies/confused.gif HEIGHT=15 BORDER=0 alt=":V">
<IMG SRC=www.huw.ukso.com/smilies/coool.gif WIDTH=15 HEIGHT=15 BORDER=0 alt="B)">
<IMG SRC=www.huw.ukso.com/smilies/cry.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":-(">
<IMG SRC=www.huw.ukso.com/smilies/devil.gif WIDTH=15 HEIGHT=15 BORDER=0 alt="}>">
<IMG SRC=www.huw.ukso.com/smilies/heart.gif WIDTH=15 HEIGHT=15 BORDER=0 alt="0+">
<IMG SRC=www.huw.ukso.com/smilies/loveit.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":7">
<IMG SRC=www.huw.ukso.com/smilies/puh.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":*">
<IMG SRC=www.huw.ukso.com/smilies/pukey.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":r">
<IMG SRC=www.huw.ukso.com/smilies/sadley.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=";(">
<IMG SRC=www.huw.ukso.com/smilies/vork.gif HEIGHT=15 BORDER=0 alt=":YB)">
<IMG SRC=www.huw.ukso.com/smilies/yummie.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":9">
<IMG SRC=www.huw.ukso.com/smilies/michel.gif WIDTH=15 HEIGHT=15 BORDER=0 alt=":&"><br>
Images from <a href="http://www.martijnbolt.com">BoltM</a>
</td>
</tr>
</table>
EOT;
# decide upon action, weather to show a form or write the data and how
if ($app == "guest")
{
$storage_file_dat = $guest_dat;
if ( ($modify == true) && ($admin == true) )
{
if ($uidn != "")
{
if (($in1 == "") || ($in7 == ""))
$body_data = add_post_file(true);
else
{
$body_data = modify(true);
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum$thread_page_enum'>";
}
}
else
$body_data = "\t\t\t\tNo uidn defined.";
$outline_data = "Modify a post in the guest book. To clear a field replace its contents with a space. Compleat all parts of the form with a * next to them.";
$title = "Modify a post in the guest book";
}
else if ( ($remove == true) && ($admin == true) )
{
if ($uidn != "")
{
$body_data = remove();
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum$thread_page_enum'>";
}
else
$body_data = "\t\t\t\tNo uidn defined.";
$outline_data = "Remove a post from the guest book.";
$title = "Remove a post from the guest book";
}
else if ( ( ($lock == "lock") || ($lock == "unlock") ) && ($admin == true) )
{
if ($uidn != "")
{
$file_contents = file($storage_file_dat);
# find where the start of the thread is for the link
$from_thread_end = thread_ending($uidn,$file_contents);
$last_line = line_no($from_thread_end,$file_contents);
$first_line = line_no($uidn,$file_contents);
$body_data = modify($uidn);
for ($i = $last_line; $i < $first_line; $i++)
{
$uidn = uidn_no($i,$file_contents);
$body_data = modify($uidn);
}
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum$thread_page_enum'>";
}
else
$body_data = "\t\t\t\tNo uidn defined.";
$outline_data = "Lock a thread in the guest book.";
$title = "Lock a thread in the guest book";
}
else
{
if ($uidn != "")
{
$file_contents = file($storage_file_dat);
$last_line = line_no($uidn,$file_contents);
$explode = explode($delimeter,$file_contents[$last_line]);
if ($explode[11] == 1)
$body_data = "\t\t\t\tThis post has been locked, therefore no replys can be made.";
else if (($in1 == "") || ($in7 == ""))
$body_data = add_post_file(false);
else
{
$body_data = write_post_file(false);
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum$thread_page_enum'>";
}
$outline_data = "Reply to a post in the guest book. Compleat all parts of the form with a * next to them.";
$title = "Reply to a post in the guest book";
}
else
{
if (($in1 == "") || ($in7 == ""))
$body_data = add_post_file(false);
else
{
$body_data = write_post_file(true);
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum$thread_page_enum'>";
}
$outline_data = "Write a new post in the guest book. Compleat all parts of the form with a * next to them.";
$title = "Write a new post in the guest book";
}
}
}
else if ($app == "pole")
{
$storage_file_dat = $pole_dat;
if ( ($modify == true) && ($admin == true) )
{
if ($uidn != "")
{
if (($in1 == "") || ($in7 == "") || ($in10 == "") || ($in11 == "") || ($in12 == ""))
$body_data = add_post_file(true);
else
{
$body_data = modify(true);
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum'>";
}
}
else
$body_data = "\t\t\t\tNo uidn defined.";
$outline_data = "Modify a post in the visitor pole. To clear a field replace its contents with a space. Compleat all parts of the form with a * next to them.";
$title = "Modify a post in the visitor pole";
}
else if ( ($remove == true) && ($admin == true) )
{
if ($uidn != "")
{
$body_data = remove();
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum'>";
}
else
$body_data = "\t\t\t\tNo uidn defined.";
$outline_data = "Remove a post from the visitor pole.";
$title = "Remove a post in the visitor pole";
}
else
{
if ($uidn != "")
{
if ($ans != "")
{
$body_data = write_post_file(false);
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum'>";
}
else
$body_data = "\t\t\t\tNo answer defined.";
$outline_data = "Reply to a post in the visitor pole.";
$title = "Reply to a post in the visitor pole";
}
else
{
if (($in1 == "") || ($in7 == "") || ($in10 == "") || ($in11 == "") || ($in12 == ""))
$body_data = add_post_file(false);
else
{
$body_data = write_post_file(true);
$refresh = "<meta http-equiv='Refresh' content='1;URL=$view_php?app=$app$admin_page_enum'>";
}
$outline_data = "Write a new post in the visitor pole. Compleat all parts of the form with a * next to them.";
$title = "Write a new post in the visitor pole";
}
}
}
else
{
$outline_data = "Invalid function.";
$body_data = "\t\t\t\tInvalid function, the attempted function does not exist or an error has occured";
$title = "Invalid function";
}
# show an add form
function add_post_file($is_modify)
{
global $app,$uidn,$storage_file_dat,$delimeter,$admin_string,$add_php,$web_address,$admin,$thread_string,$smiles,$webmaster_email;
# if is admin then predefine some strings
if ($admin == true)
{
$data[2] = $webmaster_email;
$data[1] = "Webmaster";
$data[3] = $web_address;
}
# if its a modify command set values in the inputs, where required & add add modify input
if ($is_modify)
{
$is_modify = '<input name="modify" id="input" type="hidden" value="true">';
$file_contents = file($storage_file_dat);
$line_no = line_no($uidn, $file_contents);
if ($line_no != false)
$data = explode ($delimeter, $file_contents[$line_no]);
else
$is_modify = "";
$form_4 = "<tr><td>Date : </td><td><input type=text name=in5 size=30 id=input value='$data[5]' class='input'></td></tr>";
}
else
$is_modify = "";
# if a uidn has been sent add the form
if ($uidn != "")
$uidn_string = '<input name="uidn" id="input" type="hidden" value="' . $uidn . '">';
# definr app specific inputs, in required order
if ($app == "guest")
{
$form_7 = "<tr><td>* Your Message : </td><td><textarea cols=30 rows=5 name=in7>$data[7]</textarea></td></tr>";
$form_8 = "<tr><td>Your Subject : </td><td><input type=text name=in8 size=30 id=input value='$data[8]' class='input' maxlength=64></td></tr>";
$form_2 = "<tr><td>Your Email Address : </td><td><input type=text name=in2 size=30 id=input value='$data[2]' class='input' maxlength=128></td></tr>";
$form_3 = "<tr><td>Your ICQ ID : </td><td><input type=text name=in6 size=30 id=input value='$data[6]' class='input' maxlength=16></td></tr>";
$form_0 = "<tr><td>* Your Name : </td><td><input type=text name=in1 size=30 id=input value='$data[1]' class='input' maxlength=32></td></tr>";
$form_1 = "<tr><td>Your Website Address : </td><td><input type=text name=in3 size=30 id=input value='$data[3]' class='input' maxlength=128></td></tr>";
}
else if ($app == "pole")
{
$form_7 = "<tr><td>* Your Question : </td><td><input type=text name=in7 size=30 id=input value='$data[7]' class='input' maxlength=64></td></tr>";
$form_10 = "<tr><td>* Your 1st Answer : </td><td><input type=text name=in10 size=30 id=input value='$data[10]' class='input' maxlength=64></td></tr>";
$form_11 = "<tr><td>* Your 2nd Answer : </td><td><input type=text name=in11 size=30 id=input value='$data[11]' class='input' maxlength=64></td></tr>";
$form_12 = "<tr><td>* Your 3rd Answer : </td><td><input type=text name=in12 size=30 id=input value='$data[12]' class='input' maxlength=64></td></tr>";
$form_2 = "<tr><td>Your Email Address : </td><td><input type=text name=in2 size=30 id=input value='$data[2]' class='input' maxlength=128></td></tr>";
$form_3 = "<tr><td>Your ICQ ID : </td><td><input type=text name=in6 size=30 id=input value='$data[6]' class='input' maxlength=16></td></tr>";
$form_0 = "<tr><td>* Your Name : </td><td><input type=text name=in1 size=30 id=input value='$data[1]' class='input' maxlength=32></td></tr>";
$form_1 = "<tr><td>Your Website Address : </td><td><input type=text name=in3 size=30 id=input value='$data[3]' class='input' maxlength=128></td></tr>";
}
$body_data = <<<EOT
<form action="$add_php" name="add" method="post" onsubmit="return '$add_php' enctype="multipart/form-data">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="main">
$form_0
$form_1
$form_2
$form_3
$form_8
$form_7
$form_10
$form_11
$form_12
$form_9
$form_16
$form_17
$form_18
$form_19
$form_4
<tr>
<td>
<input type="Submit" name="submit" value="Submit" class=button>
<input type="Reset" name="reset" value="Clear" class=button>
</td>
<td>
<input name="app" id="input" type="hidden" value="$app">
$is_modify
$admin_string
$uidn_string
$thread_string
</td>
</tr>
</table>
$smiles
</form>
EOT;
return ($body_data);
}
# modify data
function modify($modify)
{
global $app,$uidn,$in1,$in2,$in3,$in4,$in5,$in6,$in7,$in8,$in9,$in10,$in11,$in12,$in13,$in14,$in15,$in16,$in17,$in18,$in19,$delimeter,$storage_file_dat,$lock;
$file_contents = file($storage_file_dat);
# get time and size of file then line no
$data1_file_size = filesize($storage_file_dat);
$data1_file_date = filemtime($storage_file_dat);
if ($modify != "true")
$line_no = line_no($modify, $file_contents);
else
$line_no = line_no($uidn, $file_contents);
if ($line_no != false)
{
$data = explode($delimeter,$file_contents[$line_no]);
if ($modify != "true")
{
if ($lock == "lock")
$data[11] = 1;
else // if ($lock == "unlock")
$data[11] = 0;
}
else
{
# if the data exists in the form then change it in the database to eq form data
// if ($in0 != "") $data[0] = $in0; // uidn
if ($in1 != "") $data[1] = $in1;
if ($in2 != "") $data[2] = $in2;
if ($in3 != "") $data[3] = $in3;
// if ($in4 != "") $data[4] = $in4; // ip
if ($in5 != "") $data[5] = $in5;
if ($in6 != "") $data[6] = $in6;
if ($in7 != "") $data[7] = $in7;
if ($in8 != "") $data[8] = $in8;
if ($in9 != "") $data[9] = $in9;
if ($in10 != "") $data[10] = $in10;
if ($in11 != "") $data[11] = $in11;
if ($in12 != "") $data[12] = $in12;
if ($in13 != "") $data[13] = $in13;
if ($in14 != "") $data[14] = $in14;
if ($in15 != "") $data[15] = $in15;
if ($in16 != "") $data[16] = $in16;
if ($in17 != "") $data[17] = $in17;
if ($in18 != "") $data[18] = $in18;
if ($in19 != "") $data[19] = $in19;
# if the data exists in the form eq " " then change it in the database to eq blank
// if ($in0 == " ") $data[0] = ""; // uidn
if ($in1 == " ") $data[1] = "";
if ($in2 == " ") $data[2] = "";
if ($in3 == " ") $data[3] = "";
// if ($in4 == " ") $data[4] = ""; // ip
if ($in5 == " ") $data[5] = "";
if ($in6 == " ") $data[6] = "";
if ($in7 == " ") $data[7] = "";
if ($in8 == " ") $data[8] = "";
if ($in9 == " ") $data[9] = "";
if ($in10 == " ") $data[10] = "";
if ($in11 == " ") $data[11] = "";
if ($in12 == " ") $data[12] = "";
if ($in13 == " ") $data[13] = "";
if ($in14 == " ") $data[14] = "";
if ($in15 == " ") $data[15] = "";
if ($in16 == " ") $data[16] = "";
if ($in17 == " ") $data[17] = "";
if ($in18 == " ") $data[18] = "";
if ($in19 == " ") $data[19] = "";
}
$write_data_new = $data[0].$delimeter.$data[1].$delimeter.$data[2].$delimeter.$data[3].$delimeter.$data[4].$delimeter.$data[5].$delimeter.$data[6].$delimeter.$data[7].$delimeter.$data[8].$delimeter.$data[9].$delimeter.$data[10].$delimeter.$data[11].$delimeter.$data[12].$delimeter.$data[13].$delimeter.$data[14].$delimeter.$data[15].$delimeter.$data[16].$delimeter.$data[17].$delimeter.$data[18].$delimeter.$data[19].$delimeter."Reserved";
for ($i = 0; $i < $line_no; $i++)
$tmp_above .= $file_contents[$i];
for ($i = $line_no+1; $i < count($file_contents); $i++)
$tmp_below .= $file_contents[$i]