version 1.11, 2002/05/31 08:26:53 |
version 1.14, 2002/09/26 09:08:10 |
|
|
$archive_no - index of archived file |
$archive_no - index of archived file |
$submit_type - submit button type |
$submit_type - submit button type |
$reply_to - index of message you want to reply (inserts quoted message) |
$reply_to - index of message you want to reply (inserts quoted message) |
|
$rootlogin - wether should display the root login dialog |
|
|
CHANGE LOG: |
CHANGE LOG: |
|
* 5.4 - "fixed" adduser bug (now ignoring result of flock() :() |
|
- added root login for viewing deleted messages |
* 5.3 - external CSS file |
* 5.3 - external CSS file |
* 5.2 - added "reply" link |
* 5.2 - added "reply" link |
* 5.1 - updated SQL queries |
* 5.1 - updated SQL queries |
|
|
$root_md5_password = "896ae34257056a6edb7643e3db85bb21"; |
$root_md5_password = "896ae34257056a6edb7643e3db85bb21"; |
|
|
// Filesystem defaults |
// Filesystem defaults |
$message_file = "board_messages.txt"; |
$message_file = "messages.dat"; |
$user_file = "board_emails.txt"; |
$user_file = "users.dat"; |
$move_old_mesages = 1; |
$move_old_mesages = 1; |
$old_messages_folder = "history/"; |
$old_messages_folder = "history/"; |
$hist_file_prefix = "board_hist_file_"; // used in REGEXPs! alphabeticals only |
$hist_file_prefix = "board_hist_file_"; // used in REGEXPs! alphabeticals only |
|
|
|
|
function link_replace($link, $paramname, $paramvalue) { |
function link_replace($link, $paramname, $paramvalue) { |
$link = eregi_replace("&$", "", $link); |
$link = eregi_replace("&$", "", $link); |
$link = eregi_replace("&?$paramname=[^&]*", "", $link); |
$link = eregi_replace("(&|^)$paramname=[^&]*", "", $link); |
if ($paramvalue) |
if ($paramvalue) |
$link .= "&$paramname=$paramvalue"; |
$link .= "&$paramname=$paramvalue"; |
return $link; |
return $link; |
|
|
$start = time(); |
$start = time(); |
while ((!flock($f, 1)) && ($start + $max_wait < time())) |
while ((!flock($f, 1)) && ($start + $max_wait < time())) |
sleep(1); |
sleep(1); |
return ($start + $max_wait < time())? |
return ($start + $max_wait < time()); |
1:0; |
|
} // wait_read_lock($f, $max_wait = 9999) |
} // wait_read_lock($f, $max_wait = 9999) |
|
|
function wait_write_lock($f, $max_wait = 9999) { |
function wait_write_lock($f, $max_wait = 9999) { |
$start = time(); |
$start = time(); |
while ((!flock($f, 2)) && ($start + $max_wait < time())) |
while ((!flock($f, 2)) && ($start + $max_wait < time())) |
sleep(1); |
sleep(1); |
|
return ($start + $max_wait < time()); |
} // wait_write_lock($f, $max_wait = 9999) |
} // wait_write_lock($f, $max_wait = 9999) |
|
|
function release_lock($f) { |
function release_lock($f) { |
|
|
return ""; |
return ""; |
} // get_email($str) |
} // get_email($str) |
|
|
function write_mail($usr_file, $user, $mail = "", $pass = "", $use_db = 0, $db_conn) { |
function write_mail($usr_file, $user, $mail = '', $pass = '', $root_name = '', $use_db = 0, $db_conn) { |
$pass = md5(rawurlencode($pass)); |
$pass = md5(rawurlencode($pass)); |
|
if ($user == $root_name) |
|
return false; |
if (!$use_db) { |
if (!$use_db) { |
// Working with files |
// Working with files |
$fp = fopen($usr_file, "a"); |
$fp = fopen($usr_file, "a"); |
|
wait_write_lock($fp); |
|
/* |
|
// this should work, but doesn't :((( |
|
// won't use this shitty file locking mechanism |
if (!wait_write_lock($fp)) |
if (!wait_write_lock($fp)) |
return false; |
return false; |
|
*/ |
fwrite($fp, strtr($user, ":", ";") . ":" . strtr($mail, ":", ";") . |
fwrite($fp, strtr($user, ":", ";") . ":" . strtr($mail, ":", ";") . |
":" . $pass . "\n"); |
":" . $pass . "\n"); |
release_lock($fp); |
release_lock($fp); |
|
|
} |
} |
} |
} |
|
|
|
function show_root_login_form($rootnick, $user_nick = '') { |
|
global $self; |
|
echo "\n<center><h3><b>Admin login</b></h3><br><br>"; |
|
echo "\n<center>\n<form name=rootlogin method=get action=$self>\n"; |
|
echo create_hidden_inputs(split_url_vars(link_replace(link_replace(create_link(), 'nick', $rootnick), 'newnick', $user_nick))); |
|
echo "<table align=center>\n"; |
|
echo "\t\n<tr>\n\t\t<td>Password:</td><td><input type=password name=pass></td></tr>\n"; |
|
echo "\t\n<tr>\n\t\t<td colspan=2 align=center><input type=submit name=submit_type value=Login>\n</td></tr>\n"; |
|
echo "\t<tr><td align=center colspan=2><a href=$self?" . |
|
create_link() . |
|
">cancel</a></td></tr>\n"; |
|
echo "</table>\n"; |
|
echo "</form>\n</center>\n"; |
|
} // show_root_login_form($rootnick, $user_nick) |
|
|
function show_data_form($user_file, $self, $nick, $message, |
function show_data_form($user_file, $self, $nick, $message, |
$style, $WB_name, $autorefresh, $pagesize, $use_db = 0, $db_conn = 0) { |
$style, $WB_name, $autorefresh, $pagesize, $use_db = 0, $db_conn = 0) { |
// TODO !!!!!! |
// TODO !!!!!! |
|
|
global $frameset; |
global $frameset; |
?> |
?> |
<center> |
<center> |
<font color="#C0C0C0" face="Courier" size=5><b><?echo $WB_name?></b></font><br> |
<h3><?echo $WB_name?></h3> |
Current time is <?echo format_time(time())?>. |
Current time is <?echo format_time(time())?>. |
<br> |
<br> |
<table border=0> |
<table border=0> |
Line 871 Current time is <?echo format_time(time( |
|
Line 896 Current time is <?echo format_time(time( |
|
?> |
?> |
<tr> |
<tr> |
<td align=center valign=middle rowspan=3> |
<td align=center valign=middle rowspan=3> |
<textarea name="message" cols=30 rows=<? |
<textarea name="message" cols=40 rows=<? |
echo (sizeof(explode("\n",$message)) + 5)?>><?echo $message?></textarea></td> |
echo (sizeof(explode("\n",$message)) + 5)?>><?echo $message?></textarea></td> |
<td align=center valign=middle><font face="Arial" color=#ffcc00 size=3>Nick</font></td> |
<td align=center valign=middle>Nick</td> |
<td align=left valign=middle> |
<td align=left valign=middle> |
<select name="nick"> |
<select name="nick"> |
<option value="Anonym"><choose></option> |
<option value="Anonym"><choose></option> |
Line 939 Current time is <?echo format_time(time( |
|
Line 964 Current time is <?echo format_time(time( |
|
<a href="<? |
<a href="<? |
echo "$self?" . link_replace(link_replace(create_link(), "setframes", 1), "disablepart", 3); |
echo "$self?" . link_replace(link_replace(create_link(), "setframes", 1), "disablepart", 3); |
?>" target=_top>Switch to frames</a> <font size=-3><a href="<? |
?>" target=_top>Switch to frames</a> <font size=-3><a href="<? |
echo $self . '?' . link_replace(create_link(), 'nick', 'root'); |
echo $self . '?' . link_replace(create_link(), 'rootlogin', '1'); |
?>">π</a></font> |
?>">π</a></font> |
</td> |
</td> |
</tr> |
</tr> |
Line 1008 Current time is <?echo format_time(time( |
|
Line 1033 Current time is <?echo format_time(time( |
|
<title><?echo "$WB_name v$WB_version"?></title> |
<title><?echo "$WB_name v$WB_version"?></title> |
<link rel="stylesheet" href="<?echo $css_file?>" type="text/css"> |
<link rel="stylesheet" href="<?echo $css_file?>" type="text/css"> |
</head> |
</head> |
<body bgcolor="black" text="#C0C0C0" link="#8888ff" alink="#8888ff" vlink="#8888ff"> |
<body> |
<? |
<? |
} // show_nonrefresh_head() |
} // show_nonrefresh_head() |
|
|
function show_delete_dialog($nick, $time) { |
function show_delete_dialog($nick, $time) { |
global $self; |
global $self; |
echo "\n<center><font color=#C0C0C0 face=Courier size=4><b>Delete message</font></b><br><br>"; |
echo "\n<center><h3><b>Delete message</b></h3><br><br>"; |
echo "\n<center>\n<form name=deletemessage method=get action=$self>\n"; |
echo "\n<center>\n<form name=deletemessage method=get action=$self>\n"; |
echo create_hidden_inputs(split_url_vars(link_replace(link_replace(create_link(), "deleteok", 1), "time", $time))); |
echo create_hidden_inputs(split_url_vars(link_replace(link_replace(create_link(), "deleteok", 1), "time", $time))); |
echo "<table align=center>\n"; |
echo "<table align=center>\n"; |
Line 1031 Current time is <?echo format_time(time( |
|
Line 1056 Current time is <?echo format_time(time( |
|
|
|
function show_createuser_dialog($newnick, $email) { |
function show_createuser_dialog($newnick, $email) { |
global $self; |
global $self; |
echo "\n<center><font color=#C0C0C0 face=Courier size=4><b>Create new user</font></b><br><br>"; |
echo "\n<center><h3><b>Create new user</b></h3><br><br>"; |
echo "<table size=90% align=center>\n"; |
echo "<table size=90% align=center>\n"; |
|
|
echo "\n<form name=createuser method=get action=$self>"; |
echo "\n<form name=createuser method=get action=$self>"; |
Line 1234 Current time is <?echo format_time(time( |
|
Line 1259 Current time is <?echo format_time(time( |
|
if (!good($page)) |
if (!good($page)) |
$page = 0; |
$page = 0; |
|
|
|
// check for superuser view |
|
if ($nick == $root_name) { |
|
if (md5($pass) == $root_md5_password) |
|
$superuser = 1; |
|
else { |
|
unset($nick); |
|
$superuser = 0; |
|
} |
|
} |
|
|
|
// SHOW ROOT LOGIN FORM |
|
if ($rootlogin) { |
|
show_nonrefresh_head(); |
|
show_root_login_form($root_name, $nick); |
|
$show_body = false; |
|
$show_head = false; |
|
} |
|
|
if (!isset($nick) && good($newnick)) |
if (!isset($nick) && good($newnick)) |
$nick = $newnick; |
$nick = $newnick; |
|
|
Line 1246 Current time is <?echo format_time(time( |
|
Line 1289 Current time is <?echo format_time(time( |
|
if (good($archive_no) && !$use_db) |
if (good($archive_no) && !$use_db) |
$message_file = $old_messages_folder . $hist_file_prefix . $archive_no; |
$message_file = $old_messages_folder . $hist_file_prefix . $archive_no; |
|
|
// check for superuser view |
|
if (($nick == $root_name) && (md5($pass) == $root_md5_password)) |
|
$superuser = 1; |
|
else |
|
$superuser = 0; |
|
|
|
if ($use_db) { |
if ($use_db) { |
require_once "DB.php"; |
require_once "DB.php"; |
|
|
Line 1299 Current time is <?echo format_time(time( |
|
Line 1336 Current time is <?echo format_time(time( |
|
// CREATE NEW USER |
// CREATE NEW USER |
if ($createuser) { |
if ($createuser) { |
$mails = get_emails($user_file, $use_db, $db_handle); |
$mails = get_emails($user_file, $use_db, $db_handle); |
echo "1"; |
|
if ((!($mails === false)) && |
if ((!($mails === false)) && |
good($newnick) && |
good($newnick) && |
($mails[$newnick] == "") && |
($mails[$newnick] == "") && |
good($createok) && |
good($createok) && |
($createok == 1)) { |
($createok == 1)) { |
echo "1"; |
if (!write_mail($user_file, $newnick, $mail, $pass, $root_name, $use_db, $db_handle)) { |
if (write_mail($user_file, $newnick, $mail, $pass, $use_db, $db_handle)) { |
//echo "drblo to"; // something failed, ignoring for now |
echo "drblo to"; // something failed, ignoring for now |
|
die(); |
die(); |
} |
} |
|
|
Line 1339 Current time is <?echo format_time(time( |
|
Line 1374 Current time is <?echo format_time(time( |
|
// DELETE MESSAGE FROM DB |
// DELETE MESSAGE FROM DB |
if (good($time)) { |
if (good($time)) { |
if (good($deleteok) && ($deleteok == 1)){ |
if (good($deleteok) && ($deleteok == 1)){ |
|
header('HTTP/1.0 302 Found'); |
|
header("Location: $abs_self?" . create_link()); |
switch(delete_message($message_file, $user_file, $nick, |
switch(delete_message($message_file, $user_file, $nick, |
$time, $pass, $use_virtual_delete, $use_db, $db_handle)) { |
$time, $pass, $use_virtual_delete, $use_db, $db_handle)) { |
case 0: // All OK |
case 0: // All OK |
Line 1357 Current time is <?echo format_time(time( |
|
Line 1394 Current time is <?echo format_time(time( |
|
echo "<center>Fatal Error while deleting: unknown error code!</center><br>\n"; |
echo "<center>Fatal Error while deleting: unknown error code!</center><br>\n"; |
break; |
break; |
} |
} |
//die(); |
|
header('HTTP/1.0 302 Found'); |
|
header("Location: $abs_self?" . create_link()); |
|
die(); |
die(); |
} else { |
} else { |
show_nonrefresh_head(); |
show_nonrefresh_head(); |
Line 1377 Current time is <?echo format_time(time( |
|
Line 1411 Current time is <?echo format_time(time( |
|
<head> |
<head> |
<title><?echo "$WB_name v$WB_version"?></title> |
<title><?echo "$WB_name v$WB_version"?></title> |
<link rel="stylesheet" href="<?echo $css_file?>" type="text/css"> |
<link rel="stylesheet" href="<?echo $css_file?>" type="text/css"> |
|
</head> |
|
<body> |
<? |
<? |
/* |
/* |
If set, do nothing, just create frames and recursively call self |
If set, do nothing, just create frames and recursively call self |
Line 1405 Current time is <?echo format_time(time( |
|
Line 1441 Current time is <?echo format_time(time( |
|
} |
} |
|
|
if ($show_head) { |
if ($show_head) { |
?> |
|
</head> |
|
<body bgcolor=black text=#C0C0C0 link=#888ff alink=#888ff vlink=#888ff> |
|
<? |
|
show_data_form($user_file, $self, $nick, $message, $style, |
show_data_form($user_file, $self, $nick, $message, $style, |
$WB_name, $autorefresh, $pagesize, $use_db, $db_handle); |
$WB_name, $autorefresh, $pagesize, $use_db, $db_handle); |
} |
} |
Line 1416 Current time is <?echo format_time(time( |
|
Line 1448 Current time is <?echo format_time(time( |
|
if ($show_body) { |
if ($show_body) { |
echo "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"$autorefresh URL=$self?" . |
echo "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"$autorefresh URL=$self?" . |
create_link() . "\">\n"; |
create_link() . "\">\n"; |
?> |
|
</head> |
|
<body bgcolor=black text=#C0C0C0 link=#888ff alink=#888ff vlink=#888ff> |
|
<? |
|
show_messages($message_file, $user_file, $page, $pagesize, |
show_messages($message_file, $user_file, $page, $pagesize, |
$style, $superuser, $use_db, $db_handle); |
$style, $superuser, $use_db, $db_handle); |
} |
} |