| version 1.6, 2002/03/20 13:21:52 |
version 1.7, 2002/03/29 19:45:45 |
|
|
| <? |
<?
|
| /* |
/*
|
| Module: WolBoard.php3 |
Module: WolBoard.php3
|
| |
|
| Author: Martin Karas a.k.a. Wolcano |
Author: Martin Karas a.k.a. Wolcano
|
| Date: 14.03.2002 |
Date: 14.03.2002
|
| Mail: wolcano@pobox.sk |
Mail: wolcano@pobox.sk
|
| Version: v4.4 |
Version: v5.0
|
| |
License: not chosen yet - this file is strictly private,
|
| |
you may not copy/change/distribute it without authors
|
| Description: Simple message-board. Uses two external files to store |
explicit premission.
|
| data - messages, usernames and e-mails. Main functions are show_data_form, |
Description: Simple message-board. Can store data in files or
|
| show_messages. Other runtime information (new user creation form, etc) are |
PEAR-compliant DB (not fully implemented yet)
|
| shown not using function calls. |
|
| |
TODO: (see TODO file)
|
| |
|
| TODO: |
External files specification:
|
| * zmena hesla/e-mailu usera |
$message_file :== (<message_line><eoln>)*
|
| * zmazanie usera (suicide) |
<message_line> :== <unix_time>:<username>:<message> ||
|
| * moznost nastavit si pocet messages pre kazdeho usera zvlast |
<unix_time>:<username>:<deleted_message>
|
| * OPTIONS_DIALOG (autorefresh, pagesize, nick, pass, email...all) |
<deleted_message> :== *<message>
|
| * stalost nastaveni uzivatela (cookies?) |
|
| * plne implementovat pracu s DB/PEAR |
$user_file :== (<user_line><eoln>)*
|
| |
<user_line> :== <username>:<email>:<md5sum_of_password>
|
| |
|
| External files specification: |
Database specification:
|
| $message_file :== (<message_line><eoln>)* |
create table messages <unknown for now>
|
| <message_line> :== <unix_time>:<username>:<message> || |
|
| <unix_time>:<username>:<deleted_message> |
create table users <unknown>
|
| <deleted_message> :== *<message> |
|
| |
|
| $user_file :== (<user_line><eoln>)* |
Input parameters:
|
| <user_line> :== <username>:<email>:<md5sum_of_password> |
$pagesize - # of messages per page
|
| |
$page - #th page
|
| Database specification: |
$autorefresh - refresh time (secs)
|
| create table messages <unknown for now> |
// $admin - user/message mantainance
|
| |
$style - message view style (0 = board, 1 = chat)
|
| create table users <unknown> |
$time - message time index
|
| |
$nick - user nickname
|
| |
$pass - password
|
| Input parameters: |
$message - text of the posted message
|
| $pagesize - # of messages per page |
$header - shows only header
|
| $page - #th page |
$body - show only body
|
| $autorefresh - refresh time (secs) |
$bodyframe - target body frame
|
| // $admin - user mantainance |
$headerframe - targer header frame
|
| $style - message view style (0 = board, 1 = chat) |
$disablepart - Wont show some parts of the whole document
|
| $time - message time index |
(0 - none, 1 - body, 2 - head, 3 - both)
|
| $nick - |
$setframes - 1 - create <framesset>
|
| $pass - |
0 - disable frames (?? :))
|
| $message - |
$frameset - are the frames set? :)
|
| $header - shows only header |
|
| $body - show only body |
$createuser - (internal)
|
| $bodyframe - target body frame |
$deleteok - (internal)
|
| $headerframe - targer header frame |
$newnick - (internal)
|
| $disablepart - Wont show some parts of the whole document |
$archive - archive file prefix
|
| (0 - none, 1 - body, 2 - head, 3 - both) |
$archive_no - index of archived file
|
| $setframes - 1 - create frames |
$submit_type - submit button type
|
| 0 - disable frames (?? :)) |
|
| |
CHANGE LOG:
|
| $createuser - (internal) |
* 5.0 - DB implementation finished (hopefully)
|
| $deleteok - (internal) |
- now allowing some html tags (specified by (array) $allowed_tags)
|
| $newnick - (internal) |
- no more dependent on external <framesets>! :) we do the dirty work
|
| $archive - archive file prefix |
ourselves (try setting the setframes=1 GET parameter)
|
| $archive_no - index of archived file |
* 4.4.2 - 3/4 implementation DB done
|
| $submit_type |
* 4.4 - DB/PEAR drafts
|
| |
- sources moved to CVS
|
| CHANGE LOG: |
* 4.3 - starting MySQL DB implementation
|
| * 4.4 - PEAR basic implementation (not functional fully) |
* 4.2 - started documentation
|
| * 4.3 - starting MySQL DB implementation |
- removed autosubmit on nick change
|
| * 4.2 - started documentation |
- changed default autorefresh to 5 mins
|
| - removed autosubmit on nick change |
*FIX* now rawurldecoding username (previously rawurlencoded)
|
| - changed default autorefresh to 5 mins |
* 4.1 - undocumented :)
|
| *FIX* now rawurldecoding username (previously rawurlencoded) |
*/
|
| * 4.1 - undocumented :) |
|
| */ |
|
| |
// IMPORTANT CONSTANTS (change if needed)
|
| |
$WB_version = "5.0";
|
| // IMPORTANT CONSTANTS (change if needed) |
$WB_name = "Wol's Message Board";
|
| $WB_version = "4.4"; |
$strip_slashes = 1;
|
| $WB_name = "Wol's Message Board"; |
$DEFAULT_HEAD_FRAME = "";
|
| $strip_slashes = 1; |
$DEFAULT_BODY_FRAME = "";
|
| $DEFAULT_HEAD_FRAME = ""; |
$use_virtual_delete = 1; //use delete flagging instead of real delete
|
| $DEFAULT_BODY_FRAME = ""; |
$root_name = "root";
|
| $use_virtual_delete = 1; //use delete flagging instead of real delete |
$root_md5_password = "896ae34257056a6edb7643e3db85bb21";
|
| $root_name = "root"; |
|
| $root_md5_password = "896ae34257056a6edb7643e3db85bb21"; |
// Filesystem defaults
|
| |
$message_file = "board_messages.txt";
|
| // Filesystem defaults |
$user_file = "board_emails.txt";
|
| $message_file = "board_messages.txt"; |
$move_old_mesages = 1;
|
| $user_file = "board_emails.txt"; |
$old_messages_folder = "history/";
|
| $move_old_mesages = 1; |
$hist_file_prefix = "board_hist_file_"; // used in REGEXPs! alphabeticals only
|
| $old_messages_folder = "history/"; |
$max_msgs_in_one_file = 200;
|
| $hist_file_prefix = "board_hist_file_"; // used in REGEXPs! alphabeticals only |
$min_msgs_in_board = 50;
|
| $max_msgs_in_one_file = 200; |
|
| $min_msgs_in_board = 50; |
// Database defaults
|
| |
$use_db = 1;
|
| // Database defaults |
$db_message_table = "wolboard_messages";
|
| $use_db = 1; |
$db_user_table = "wolboard_users";
|
| $db_message_table = "wolboard_messages"; |
//$db_host = "db.host.sk";
|
| $db_user_table = "wolboard_users"; |
$db_host = "localhost";
|
| $db_host = "db.host.sk"; |
$db_database = "syndrome";
|
| $db_database = "syndrome"; |
//$db_user = "syndrome";
|
| $db_user = "syndrome"; |
$db_user = "";
|
| $db_pass = "kofola"; |
//$db_pass = "kofola";
|
| |
$db_pass = "";
|
| |
|
| |
$allowed_tags = array(
|
| // FUNCTIONS |
"<b>", "</b>",
|
| |
"<i>", "</i>",
|
| function good($a) { |
"<u>", "</u>",
|
| return (isset($a) |
"<del>", "</del>",
|
| && ( |
"©"
|
| (is_string($a) && ($a != "")) || |
);
|
| (!is_string($a) && ($a != 0)) |
|
| ) |
|
| ); |
// FUNCTIONS
|
| } |
|
| |
function good($a) {
|
| function link_replace($link, $paramname, $paramvalue) { |
return (isset($a)
|
| $link = eregi_replace("&$", "", $link); |
&& (
|
| $link = eregi_replace("&?$paramname=[^&]*", "", $link); |
(is_string($a) && ($a != "")) ||
|
| if ($paramvalue) |
(!is_string($a) && ($a != 0))
|
| $link .= "&$paramname=$paramvalue"; |
)
|
| return $link; |
);
|
| } |
}
|
| |
|
| function show_array($a) { |
function link_replace($link, $paramname, $paramvalue) {
|
| echo "<table border=1>\n"; |
$link = eregi_replace("&$", "", $link);
|
| $keys = array_keys($a); |
$link = eregi_replace("&?$paramname=[^&]*", "", $link);
|
| |
if ($paramvalue)
|
| for($i = 0; $i < sizeof($a); $i++) { |
$link .= "&$paramname=$paramvalue";
|
| echo "<tr>\n"; |
return $link;
|
| echo "<td>"; |
}
|
| echo $keys[$i]."</td>\n<td>"; |
|
| |
function show_array($a) {
|
| if ((is_array($a[$keys[$i]])) && ($keys[$i] !== "GLOBALS")) { |
echo "<table border=1>\n";
|
| show_array($a[$keys[$i]]); |
$keys = array_keys($a);
|
| } |
|
| else { |
for($i = 0; $i < sizeof($a); $i++) {
|
| echo $a[$keys[$i]]; |
echo "<tr>\n";
|
| }; |
echo "<td>";
|
| echo "</td>\n</tr>\n"; |
echo $keys[$i]."</td>\n<td>";
|
| } |
|
| echo "</table>"; |
if ((is_array($a[$keys[$i]])) && ($keys[$i] !== "GLOBALS")) {
|
| } |
show_array($a[$keys[$i]]);
|
| |
}
|
| function array_copy($a, $i, $n = "x") { |
else {
|
| if (($n == "x") || ($n > (sizeof($a) - $i))) |
echo $a[$keys[$i]];
|
| $n = sizeof($a) - $i; |
};
|
| |
echo "</td>\n</tr>\n";
|
| for($j = 0; $j < $n; $j++) { |
}
|
| $ret[$j] = $a[$j + $i]; |
echo "</table>";
|
| } |
}
|
| |
|
| return $ret; |
function array_copy($a, $i, $n = "x") {
|
| } |
if (($n == "x") || ($n > (sizeof($a) - $i)))
|
| |
$n = sizeof($a) - $i;
|
| function array_chunk($a, $n) { |
|
| if (!is_array($a)) |
for($j = 0; $j < $n; $j++) {
|
| return $a; |
$ret[$j] = $a[$j + $i];
|
| $splits = sizeof($a) / $n; |
}
|
| for($i = 0; $i < $splits; $i++) { |
|
| $ret[$i] = array_copy($a, $i*$n, $n); |
return $ret;
|
| } |
}
|
| return $ret; |
|
| } |
function array_chunk($a, $n) {
|
| |
if (!is_array($a))
|
| function w_chk($n, $v) { |
return $a;
|
| return ($v?"$n=$v&":""); |
$splits = sizeof($a) / $n;
|
| } |
for($i = 0; $i < $splits; $i++) {
|
| |
$ret[$i] = array_copy($a, $i*$n, $n);
|
| function create_link() { |
}
|
| global $pagesize, $page, $autorefresh, $admin, $style, |
return $ret;
|
| $time, $nick, $pass, $message, $createuser, $deleteok, |
}
|
| $autorefresh, $disablepart, $frameset, $headframe, |
|
| $bodyframe, $archive, $archive_no; |
function w_chk($n, $v) {
|
| return eregi_replace("&$", "", |
return ($v?"$n=$v&":"");
|
| w_chk("nick", $nick). |
}
|
| w_chk("pagesize", $pagesize). |
|
| w_chk("page", $page). |
function create_link() {
|
| // w_chk("time", $time). |
global $pagesize, $page, $autorefresh, $admin, $style,
|
| // w_chk("pass", $pass). |
$time, $nick, $pass, $message, $createuser, $deleteok,
|
| // w_chk("message", $message). |
$autorefresh, $disablepart, $frameset, $headframe,
|
| // w_chk("deleteok", $deleteok). |
$bodyframe, $archive, $archive_no;
|
| // w_chk("createuser", $createuser). |
return eregi_replace("&$", "",
|
| // w_chk("newnick", $newnick). |
w_chk("nick", $nick).
|
| w_chk("autorefresh", $autorefresh). |
w_chk("pagesize", $pagesize).
|
| w_chk("style", $style). |
w_chk("page", $page).
|
| w_chk("admin", $admin). |
// w_chk("time", $time).
|
| w_chk("disablepart", $disablepart). |
// w_chk("pass", $pass).
|
| w_chk("frameset", $frameset). |
// w_chk("message", $message).
|
| w_chk("headframe", $headframe). |
// w_chk("deleteok", $deleteok).
|
| w_chk("bodyframe", $bodyframe). |
// w_chk("createuser", $createuser).
|
| w_chk("archive", $archive). |
// w_chk("newnick", $newnick).
|
| w_chk("archive_no", $archive_no) |
w_chk("autorefresh", $autorefresh).
|
| ); |
w_chk("style", $style).
|
| } |
w_chk("admin", $admin).
|
| |
w_chk("disablepart", $disablepart).
|
| function wait_read_lock($f, $max_wait = 9999) { |
w_chk("frameset", $frameset).
|
| $start = time(); |
w_chk("headframe", $headframe).
|
| while ((!flock($f, 1)) && ($start + $max_wait < time())) |
w_chk("bodyframe", $bodyframe).
|
| sleep(1); |
w_chk("archive", $archive).
|
| return ($start + $max_wait < time())? |
w_chk("archive_no", $archive_no)
|
| 1:0; |
);
|
| } |
}
|
| |
|
| function wait_write_lock($f, $max_wait = 9999) { |
function wait_read_lock($f, $max_wait = 9999) {
|
| $start = time(); |
$start = time();
|
| while ((!flock($f, 2)) && ($start + $max_wait < time())) |
while ((!flock($f, 1)) && ($start + $max_wait < time()))
|
| sleep(1); |
sleep(1);
|
| } |
return ($start + $max_wait < time())?
|
| |
1:0;
|
| function release_lock($f) { |
}
|
| flock($f, 3); |
|
| return 1; |
function wait_write_lock($f, $max_wait = 9999) {
|
| } |
$start = time();
|
| |
while ((!flock($f, 2)) && ($start + $max_wait < time()))
|
| function show_options($optnames, $optvalues, $selected) { |
sleep(1);
|
| if (!is_array($optvalues)) |
}
|
| return 0; |
|
| |
function release_lock($f) {
|
| $found = 0; |
flock($f, 3);
|
| $ret = ""; |
return 1;
|
| for($i = 0; $i < sizeof($optvalues); $i++) { |
}
|
| $ret .= "<option"; |
|
| if (good($optvalues[$i])) { |
function show_options($optnames, $optvalues, $selected) {
|
| $ret .= " value=".$optvalues[$i]; |
if (!is_array($optvalues))
|
| if ($optvalues[$i] == $selected) { |
return 0;
|
| $found++; |
|
| $ret .= " selected"; |
$found = 0;
|
| } |
$ret = "";
|
| } |
for($i = 0; $i < sizeof($optvalues); $i++) {
|
| $ret .= ">"; |
$ret .= "<option";
|
| if (good($optnames[$i])) |
if (good($optvalues[$i])) {
|
| $ret .= $optnames[$i]; |
$ret .= " value=".$optvalues[$i];
|
| $ret .= "</option>\n"; |
if ($optvalues[$i] == $selected) {
|
| } |
$found++;
|
| if ((!$found) && ($selected != "")) |
$ret .= " selected";
|
| $ret .= "<option value=$selected selected>Custom</option>\n"; |
}
|
| echo $ret; |
}
|
| } |
$ret .= ">";
|
| |
if (good($optnames[$i]))
|
| function get_user($str, $i = 0) { |
$ret .= $optnames[$i];
|
| $tmp = strtok(trim($str), ":"); |
$ret .= "</option>\n";
|
| if ($i) |
}
|
| // (1) from $MESSAGE_FILE |
if ((!$found) && ($selected != ""))
|
| return strtok(":"); |
$ret .= "<option value=$selected selected>Custom</option>\n";
|
| else |
echo $ret;
|
| // (0) from $USER_FILE |
}
|
| return $tmp; |
|
| } |
function get_user($str, $i = 0) {
|
| |
$tmp = strtok(trim($str), ":");
|
| function get_users($usr_file, $use_db = 0, $db_conn = 0) { |
if ($i)
|
| if (!$use_db) { |
// (1) from $MESSAGE_FILE
|
| // Working with files |
return strtok(":");
|
| $fp = fopen($usr_file, "r"); |
else
|
| wait_read_lock($fp); |
// (0) from $USER_FILE
|
| $ret = file($usr_file); |
return $tmp;
|
| for($i = 0; $i < sizeof($ret); $i++) { |
}
|
| $ret[$i] = trim($ret[$i]); |
|
| $ret[$i] = get_user($ret[$i], 0); |
function get_users($usr_file, $use_db = 0, $db_conn = 0) {
|
| } |
if (!$use_db) {
|
| release_lock($fp); |
// Working with files
|
| return $ret; |
$fp = fopen($usr_file, "r");
|
| } |
wait_read_lock($fp);
|
| else { |
$ret = file($usr_file);
|
| // Working with DB |
for($i = 0; $i < sizeof($ret); $i++) {
|
| // $usr_file stores Table name |
$ret[$i] = trim($ret[$i]);
|
| $res = $db_conn->query("select nick from $usr_file where nick <> ''"); |
$ret[$i] = get_user($ret[$i], 0);
|
| $i = 0; |
}
|
| while ($tmp = $res->fetchRow()) { |
release_lock($fp);
|
| $ret[$i] = $tmp[0]; |
return $ret;
|
| $i++; |
}
|
| } |
else {
|
| $db_conn->free; |
// Working with DB
|
| return $ret; |
// $usr_file stores Table name
|
| } |
if (!$db_conn)
|
| } |
return false;
|
| |
|
| function format_time($time, $style = 0) { |
$res = $db_conn->query("select nick from $usr_file");
|
| switch($style) { |
$i = 0;
|
| case 1: |
while ($tmp = $res->fetchRow()) {
|
| return date("H:i:s", $time); |
$ret[$i++] = $tmp["nick"];
|
| default: |
}
|
| return date("H:i:s - d. M Y", $time); |
|
| } |
$db_conn->free;
|
| } |
return $ret;
|
| |
}
|
| function get_time($str) { |
}
|
| return strtok(trim($str), ":"); |
|
| } |
function format_time($time, $style = 0) {
|
| |
switch($style) {
|
| function get_pass($str) { |
case 1:
|
| return rawurldecode(trim(strtr(strrchr($str, ":"), ":", ";"))); |
return date("H:i:s", $time);
|
| } |
default:
|
| |
return date("H:i:s - d. M Y", $time);
|
| function get_email($str) { |
}
|
| if (ereg("[^:]*:([^:]*):", $str, $regs)) |
}
|
| return $regs[1]; |
|
| else |
function get_time($str) {
|
| return ""; |
return strtok(trim($str), ":");
|
| } |
}
|
| |
|
| function write_mail($usr_file, $user, $mail = "", $pass = "", $use_db = 0, $db_conn) { |
function get_pass($str) {
|
| $pass = md5(rawurlencode($pass)); |
return rawurldecode(trim(strtr(strrchr($str, ":"), ":", ";")));
|
| if (!$use_db) { |
}
|
| // Working with files |
|
| $fp = fopen($usr_file, "a"); |
function get_email($str) {
|
| if (!wait_write_lock($fp)) |
if (ereg("[^:]*:([^:]*):", $str, $regs))
|
| return false; |
return $regs[1];
|
| fwrite($fp, strtr($user, ":", ";").":".strtr($mail, ":", ";"). |
else
|
| ":".$pass."\n"); |
return "";
|
| release_lock($fp); |
}
|
| fclose($fp); |
|
| return true; |
function write_mail($usr_file, $user, $mail = "", $pass = "", $use_db = 0, $db_conn) {
|
| } |
$pass = md5(rawurlencode($pass));
|
| else { |
if (!$use_db) {
|
| // Working with DB |
// Working with files
|
| $user = addslashes($user); |
$fp = fopen($usr_file, "a");
|
| $mail = addslashes($mail); |
if (!wait_write_lock($fp))
|
| $res = $db_conn->query("insert into $usr_file values". |
return false;
|
| "('$user', '$mail', '$pass', '', '', '')");//!!!TODO |
fwrite($fp, strtr($user, ":", ";").":".strtr($mail, ":", ";").
|
| return (DB::isError($res)); |
":".$pass."\n");
|
| } |
release_lock($fp);
|
| } |
fclose($fp);
|
| |
return true;
|
| function change_mail($usr_file, $user, $newmail = "", $pass = "", |
}
|
| $use_db = 0, $db_conn = 0) { |
else {
|
| function set_mail($usr_line, $newmail) { |
// Working with DB
|
| $ret = strtok($usr_line, ":"); |
if (!$db_conn)
|
| strtok(":"); |
return false;
|
| $ret .= $newmail.":".strtok(":"); |
|
| return $ret; |
$user = addslashes($user);
|
| } |
$mail = addslashes($mail);
|
| |
$sql = "insert into $usr_file ".
|
| //check if valid data is sent |
"(nick, email, pass) ".
|
| //we dont want to run for now |
"values ".
|
| if (true)//!!!!!!!! |
"('$user', '$mail', '$pass')";
|
| return 0; |
$res = $db_conn->query($sql);
|
| |
return (DB::isError($res));
|
| if (!$use_db) { |
}
|
| // Using files |
}
|
| $fp = fopen($usr_file, "w+"); |
|
| wait_write_lock($fp); |
function change_mail($usr_file, $user, $newmail = "", $pass = "",
|
| $tmp = files($usr_file); |
$use_db = 0, $db_conn = 0) {
|
| $i = 0; |
function set_mail($usr_line, $newmail) {
|
| $found = false; |
$ret = strtok($usr_line, ":");
|
| while (($i < length($tmp)) && (!$found)) { |
strtok(":");
|
| $u = get_user($tmp[$i]); |
$ret .= $newmail.":".strtok(":");
|
| if ($u == $user) { |
return $ret;
|
| $tmp[$i] = set_mail($tmp[$i], $newmail); |
}
|
| $found = true; |
|
| } |
if (!$use_db) {
|
| $i++; |
//check if valid data is sent
|
| } |
//we dont want to run for now
|
| |
if (true)//!!!!!!!!
|
| if ($found) { |
return 0;
|
| fwrite($fp, $u); |
|
| release_lock($fp); |
// Using files
|
| fclose($fp); |
$fp = fopen($usr_file, "w+");
|
| return 1; |
wait_write_lock($fp);
|
| } |
$tmp = files($usr_file);
|
| else |
$i = 0;
|
| return 0; |
$found = false;
|
| } |
while (($i < length($tmp)) && (!$found)) {
|
| else { |
$u = get_user($tmp[$i]);
|
| // Using DB |
if ($u == $user) {
|
| /* |
$tmp[$i] = set_mail($tmp[$i], $newmail);
|
| !!!TODO |
$found = true;
|
| $sql = "update $usr_file set mail = '$newmail' where name = '$user' and pass = '$pass'" |
}
|
| $res = $db_conn->query($sql); |
$i++;
|
| if (DB::isError($res)) |
}
|
| return false; |
|
| return 1; |
if ($found) {
|
| } |
fwrite($fp, $u);
|
| } |
release_lock($fp);
|
| |
fclose($fp);
|
| function delete_mail($usr_file, $user = "", $mail = "", $pass = "", |
return 1;
|
| $use_db = 0, $db_conn = 0) { |
}
|
| //!!!! TODO |
else
|
| if (!$use_db) { |
return 0;
|
| // Use files |
}
|
| return 0; |
else {
|
| } |
// Using DB
|
| else { |
if (!$db_conn)
|
| // Use DB |
return false;
|
| /* TODO |
|
| $sql = "update $usr_file set mail = ''". |
$sql = "update $usr_file set mail = '$newmail' ".
|
| "where name = '$user' and pass = '$pass'". |
"where name = '$user' and pass = '$pass'";
|
| "and mail = '$mail'"; |
$res = $db_conn->query($sql);
|
| $res = $db_conn->query($sql); |
if (DB::isError($res))
|
| if (DB::isError($res)) |
return false;
|
| return false; |
return 1;
|
| */ |
}
|
| return 0; |
}
|
| } |
|
| } |
function delete_mail($usr_file, $user = "", $mail = "", $pass = "",
|
| |
$use_db = 0, $db_conn = 0) {
|
| function get_emails($usr_file, $use_db = 0, $db_conn = 0) { |
if (!$use_db) {
|
| if (!$use_db) { |
//!!!! TODO
|
| // Use files |
// Use files
|
| $fp = fopen($usr_file, "r"); |
return 0;
|
| wait_read_lock($fp); |
}
|
| $f = file($usr_file); |
else {
|
| for($i = 0; $i < sizeof($f); $i++) |
// Use DB
|
| $ret[get_user($f[$i], 0)] = get_email($f[$i]); |
if (!$db_conn)
|
| |
return false;
|
| release_lock($fp); |
|
| return $ret; |
$sql = "update $usr_file set mail = '' ".
|
| } |
"where name = '$user' and pass = '$pass'".
|
| else { |
"and mail = '$mail'";
|
| // Use DB |
$res = $db_conn->query($sql);
|
| /* TODO |
if (DB::isError($res))
|
| $sql = "select * from $usr_file where status = 1"; |
return false;
|
| $res = $db_conn->query($sql); |
|
| */ |
return 0;
|
| return ""; |
}
|
| } |
}
|
| } |
|
| |
function get_emails($usr_file, $use_db = 0, $db_conn = 0) {
|
| function read_messages($msg_file, $usr_file, $full = 0, $use_db = 0, |
if (!$use_db) {
|
| $db_conn = 0) { |
// Use files
|
| if (!$use_db) { |
$fp = fopen($usr_file, "r");
|
| $mails = get_emails($usr_file, 0); |
wait_read_lock($fp);
|
| $mfp = fopen($msg_file, "r"); |
$f = file($usr_file);
|
| wait_read_lock($mfp); |
for($i = 0; $i < sizeof($f); $i++)
|
| $f = file($msg_file); |
$ret[get_user($f[$i], 0)] = get_email($f[$i]);
|
| $n = 0; |
|
| for ($i = 0; $i < sizeof($f); $i++) { |
release_lock($fp);
|
| if ($f[$i] != "") { |
return $ret;
|
| if ((!$full) && ereg("[^:]*:[^:]*:\*", $f[$i], $regs)) |
}
|
| continue; |
else {
|
| $ret[$n]["time"] = strtok($f[$i], ":"); |
// Use DB
|
| $ret[$n]["name"] = rawurldecode(strtok(":")); |
if (!$db_conn)
|
| $ret[$n]["message"] = trim(rawurldecode(strtok(":"))); |
return false;
|
| $ret[$n]["email"] = $mails[$ret[$n]["name"]]; |
|
| $n++; |
$sql = "select nick, email from $usr_file";
|
| } |
$res = $db_conn->query($sql);
|
| } |
if (DB::isError($res))
|
| release_lock($mfp); |
return false;
|
| return $ret; |
while ($row = $res->fetchRow()) {
|
| } |
$rows[$row["nick"]] = $row["email"];
|
| else { |
}
|
| // Use DB |
return $rows;
|
| /* TODO |
}
|
| if ($full) |
}
|
| $q = $db_conn->query("select autor_id, ". |
|
| "text, created from $msg_file"); |
function read_messages($msg_file, $usr_file, $full = 0, $use_db = 0,
|
| else |
$db_conn = 0) {
|
| $q = $db_conn->query("select autor_id, ". |
if (!$use_db) {
|
| "text, created from $msg_file where flags = 0"); |
$mails = get_emails($usr_file, 0);
|
| */ |
$mfp = fopen($msg_file, "r");
|
| return false; |
wait_read_lock($mfp);
|
| } |
$f = file($msg_file);
|
| } |
$n = 0;
|
| |
for ($i = 0; $i < sizeof($f); $i++) {
|
| function need_to_split($a, $max, $min) { |
if ($f[$i] != "") {
|
| if ((sizeof($a) - $max) <= $min) |
if ((!$full) && ereg("[^:]*:[^:]*:\*", $f[$i], $regs))
|
| return false; |
continue;
|
| else |
$ret[$n]["time"] = strtok($f[$i], ":");
|
| return true; |
$ret[$n]["name"] = rawurldecode(strtok(":"));
|
| } |
$ret[$n]["message"] = trim(rawurldecode(strtok(":")));
|
| |
$ret[$n]["email"] = $mails[$ret[$n]["name"]];
|
| function split_messages_to_more_files($msgs, $max_len, $min_len, |
$n++;
|
| $hist_dir, $hist_file_prefix = "board_hist_file_", $index_style = 0) { |
}
|
| if (!need_to_split($msgs, $max_len, $min_len)) |
}
|
| return $msgs; |
release_lock($mfp);
|
| $full = array_chunk($msgs, $max_len); |
return $ret;
|
| |
}
|
| $d = opendir($hist_dir); |
else {
|
| $i = -1; |
// Use DB
|
| $max_num = -1; |
if (!$db_conn)
|
| // looking for previous save of maximum index (and count of saves) |
return false;
|
| while (($file = readdir($d)) !== false) { |
|
| if (ereg("^$hist_file_prefix([0-9]*)", $file, $regs)) { |
$sql = "select author_id, created AS time, text AS message from $msg_file";
|
| $i++; |
if (!$full)
|
| if ($max_num < $regs[1]) |
$sql .= " where flags = 0";
|
| $max_num = $regs[1]; |
|
| } |
$res = $db_conn->query($sql);
|
| } |
|
| closedir($d); |
if (DB::isError($res))
|
| |
return false;
|
| switch($index_style) { |
$j = 0;
|
| case "0": |
while ($row = $res->fetchRow()) {
|
| $new_index = $max_num + 1; |
$authors[$row["author_id"]][] = $j;
|
| break; |
$t = $row["time"];
|
| case "1": |
/*
|
| $new_index = ++$i; |
$time = unpack($row["time"],
|
| break; |
"a4year/a2month/a2day/a2hours/a2minutes/a2seconds");
|
| } |
$row["time"] = mktime($time["seconds"],
|
| |
$time["minutes"], $time["hours"],
|
| for($i = 0; $i < (sizeof($full) - 1); $i++) { |
$time["day"], $time["month"], $time["year"]);
|
| $new_file = $hist_dir.$hist_file_prefix.($new_index + $i); |
/*/
|
| $fp = fopen($new_file, "a"); |
$row["time"] = mktime(
|
| wait_write_lock($fp); |
$row["time"][8] . $row["time"][9],
|
| fwrite($fp, implode($full[$i], "")); |
$row["time"][10] . $row["time"][11],
|
| release_lock($fp); |
$row["time"][12] . $row["time"][13],
|
| } |
$row["time"][4] . $row["time"][5],
|
| $msgs = $full[sizeof($full) - 1]; |
$row["time"][6] . $row["time"][7],
|
| |
$row["time"][0] . $row["time"][1] .
|
| return $msgs; |
$row["time"][2] . $row["time"][3]
|
| } |
);
|
| |
//*/
|
| function write_message($msg_file, $user = "Anonym", $text = "<no message>", |
$row["message"] = rawurldecode($row["message"]);
|
| $time = 0, $old_messages_folder, $max_msgs_in_one_file, |
$messages[$j++] = $row;
|
| $min_msgs_in_board, $hist_file_prefix, $use_db = 0, $db_conn = 0) { |
}
|
| |
$req->free;
|
| if (($time == 0) || !ereg("^[0-9]*$", $time)) |
|
| $time = time(); |
$sql = "select id, nick AS name, email from $usr_file ";
|
| $user = rawurlencode($user); |
if (is_array($authors))
|
| $text = trim($text); |
$sql .= "where id = " . implode(array_keys($authors), "or id = ");
|
| $text = str_replace("ignorant", "ign-co? (c) Wol", $text); //some fun :) |
|
| if ($text[0] == '*') // this is used as the deleted flag prefix |
$res = $db_conn->query($sql);
|
| $text = " ".$text; |
|
| |
if (DB::isError($res))
|
| if (!$use_db) { |
return false;
|
| // Use files |
|
| $new_msg = |
while ($row = $res->fetchRow())
|
| $time.":". |
for ($i = 0; $i < sizeof($authors[$row["id"]]); $i++) {
|
| $user.":". |
$messages[$authors[$row["id"]][$i]]["name"] = rawurldecode($row["name"]);
|
| rawurlencode(nl2br(htmlspecialchars($text)))."\n"; |
$messages[$authors[$row["id"]][$i]]["email"] = $row["email"];
|
| $msgs = file($msg_file); |
}
|
| $msgs[] = $new_msg; |
|
| |
return $messages;
|
| if (need_to_split($msgs, $max_msgs_in_one_file, |
}
|
| $min_msgs_in_board)) { |
}
|
| $fp = fopen($msg_file, "w"); |
|
| wait_write_lock($fp); |
function need_to_split($a, $max, $min) {
|
| sort($msgs); |
if ((sizeof($a) - $max) <= $min)
|
| $msgs = split_messages_to_more_files( |
return false;
|
| $msgs, |
else
|
| $max_msgs_in_one_file, |
return true;
|
| $min_msgs_in_board, |
}
|
| $old_messages_folder, |
|
| $hist_file_prefix, |
function split_messages_to_more_files($msgs, $max_len, $min_len,
|
| 0 |
$hist_dir, $hist_file_prefix = "board_hist_file_", $index_style = 0) {
|
| ); |
if (!need_to_split($msgs, $max_len, $min_len))
|
| $msgs = implode($msgs, ""); |
return $msgs;
|
| if (trim($msgs) == "") |
$full = array_chunk($msgs, $max_len);
|
| $msgs = ""; |
|
| fwrite($fp, $msgs); |
$d = opendir($hist_dir);
|
| } |
$i = -1;
|
| else { |
$max_num = -1;
|
| unset($msgs); |
// looking for previous save of maximum index (and count of saves)
|
| $fp = fopen($msg_file, "a"); |
while (($file = readdir($d)) !== false) {
|
| wait_write_lock($fp); |
if (ereg("^$hist_file_prefix([0-9]*)", $file, $regs)) {
|
| fwrite($fp, $new_msg); |
$i++;
|
| } |
if ($max_num < $regs[1])
|
| |
$max_num = $regs[1];
|
| release_lock($fp); |
}
|
| fclose($fp); |
}
|
| return 1; |
closedir($d);
|
| } |
|
| else { |
switch($index_style) {
|
| // Use DB |
case "0":
|
| // TODO |
$new_index = $max_num + 1;
|
| // $msg_file stores Message Table name |
break;
|
| // "insert into $msg_file values (". |
case "1":
|
| // "'$user', '$text', '$time', '', '')" |
$new_index = ++$i;
|
| /* |
break;
|
| $res = $db_conn->query("insert into $msg_file" |
}
|
| . " (author_id, created, text ) values " |
|
| . " ('".addslashes($user)."', sysdate()," |
for($i = 0; $i < (sizeof($full) - 1); $i++) {
|
| . " '" . addslashes($message) . "')" |
$new_file = $hist_dir.$hist_file_prefix.($new_index + $i);
|
| ) |
$fp = fopen($new_file, "a");
|
| */ |
wait_write_lock($fp);
|
| return 0; |
fwrite($fp, implode($full[$i], ""));
|
| } |
release_lock($fp);
|
| } |
}
|
| |
$msgs = $full[sizeof($full) - 1];
|
| |
|
| function delete_message($msg_file, $usr_file, $user, $time, $pass, |
return $msgs;
|
| $use_virtual_delete, $use_db = 0, $db_handle = 0) { |
}
|
| if (!$use_db) { |
|
| // Use files |
function validate_message($message, $allowed_tags) {
|
| $found = false; |
$message = trim($message);
|
| $i = 0; |
//some fun :)
|
| $fp = fopen($usr_file, "r"); |
$message = ereg_replace("ignor[^a-zA-Z]*", "igno-what? © Wol ", $message);
|
| wait_read_lock($fp); |
$message = rawurlencode(nl2br(htmlspecialchars($message)));
|
| $p = file($usr_file); |
|
| release_lock($fp); |
for ($i = 0; $i < sizeof($allowed_tags); $i++) {
|
| if ($user != "") { |
$message = str_replace(
|
| while ((!$found) && ($i < sizeof($p))) { |
rawurlencode(htmlspecialchars($allowed_tags[$i])),
|
| if ($user == get_user($p[$i], 0)) |
$allowed_tags[$i],
|
| $found = true; |
$message
|
| $i++; |
);
|
| }; |
}
|
| } |
|
| else |
return $message;
|
| $found = true; |
}
|
| |
|
| if (!$found) |
function write_message($msg_file, $usr_file, $user = "Anonym", $text = "<no message>",
|
| return 1; |
$time = 0, $old_messages_folder, $max_msgs_in_one_file, $min_msgs_in_board,
|
| |
$hist_file_prefix, $allowed_tags, $use_db = 0, $db_conn = 0) {
|
| if (!(($user == "") && ($pass == ""))) |
|
| if (get_pass($p[--$i]) != md5($pass)) |
if (($time == 0) || !ereg("^[0-9]*$", $time))
|
| return 2; |
$time = time();
|
| |
$text = validate_message($text, $allowed_tags);
|
| $fp = fopen($msg_file, "r"); |
|
| wait_read_lock($fp); |
if (!$use_db) {
|
| $f = file($msg_file); |
// Use files
|
| $found = false; |
$user = rawurlencode($user);
|
| $i = 0; |
if ($text[0] == '*') // this is used as the deleted flag prefix
|
| while (!$found && ($i < sizeof($f))) { |
$text = " ".$text;
|
| if (get_user($f[$i], 1) == $user && get_time($f[$i]) == $time) |
$new_msg =
|
| $found = true; |
"$time:$user:$text\n";
|
| $i++; |
$msgs = file($msg_file);
|
| } |
$msgs[] = $new_msg;
|
| if (!$found) |
|
| return 3; |
if (need_to_split($msgs, $max_msgs_in_one_file,
|
| $i--; |
$min_msgs_in_board)) {
|
| |
$fp = fopen($msg_file, "w");
|
| if ($use_virtual_delete) { |
wait_write_lock($fp);
|
| // if already marked as deleted then delete it really |
sort($msgs);
|
| if (ereg("[^:]*:[^:]*:\*.*", $f[$i], $regs)) |
$msgs = split_messages_to_more_files(
|
| $f[$i] = $f[sizeof($f) - 1]; |
$msgs,
|
| // if not marked, mark it :) |
$max_msgs_in_one_file,
|
| else |
$min_msgs_in_board,
|
| $f[$i] = ereg_replace("([^:]*:[^:]*:)(.*)", "\\1*\\2", $f[$i]); |
$old_messages_folder,
|
| } |
$hist_file_prefix,
|
| else { |
0
|
| if (sizeof($f) > 0) { |
);
|
| $f[$i] = $f[sizeof($f) - 1]; |
$msgs = implode($msgs, "");
|
| } |
if (trim($msgs) == "")
|
| else |
$msgs = "";
|
| $f = array(); |
fwrite($fp, $msgs);
|
| } |
}
|
| |
else {
|
| // we supppose the array to be sorted (sorting while insert) |
unset($msgs);
|
| //sort($f); |
$fp = fopen($msg_file, "a");
|
| |
wait_write_lock($fp);
|
| release_lock($fp); |
fwrite($fp, $new_msg);
|
| |
}
|
| $fp = fopen($msg_file, "w"); |
|
| wait_write_lock($fp); |
release_lock($fp);
|
| if (is_array($f)) |
fclose($fp);
|
| fwrite($fp, trim(implode($f, ""))."\n"); |
return 1;
|
| else |
}
|
| if (trim($f) != "") |
else {
|
| fwrite($fp, trim($f)."\n"); |
// Use DB
|
| release_lock($fp); |
// $msg_file stores Message Table name
|
| fclose($fp); |
if (!$db_conn)
|
| |
return false;
|
| return 0; |
|
| } |
$user = addslashes($user);
|
| else { |
$text = addslashes($text);
|
| // Use DB |
|
| // TODO |
// get the authors id
|
| /* |
$sql = "select id from $usr_file where nick='$user'";
|
| $sql = "select * from $usr_file where" . |
$res = $db_conn->query($sql);
|
| "name = '$user' and pass = '$pass'"; |
|
| $res = $db_conn->query($sql); |
if (DB::isError($res))
|
| if (DB::isError($res) || ($res[0] == 0)) |
return false;
|
| return 0; |
|
| $rows = array(); |
$row = $res->fetchRow();
|
| while ($row = $res->fetchRow()) |
$author_id = $row["id"];
|
| $rows[] = $row; |
|
| if ($use_virtual_delete) |
$sql = "insert into $msg_file" .
|
| $res = $db_conn->query("update $msg_file ". |
" (author_id, created, text) values " .
|
| "set deleted=sysdate(), flags |
" ('$author_id', sysdate(), '$text')";
|
| "where name = '$user' and time='$time'"); |
$res = $db_conn->query($sql);
|
| else//TODO!!! following |
|
| $res = $db_conn->query("delete from $msg_file " . |
if (DB::isError($res))
|
| "where name = '$user' and time='$time'" |
return false;
|
| //*/ |
|
| return -1; |
return true;
|
| } |
}
|
| } |
}
|
| |
|
| function show_data_form($user_file, $self, $nick, |
|
| $style, $WB_name, $autorefresh, $pagesize, $use_db = 0, $db_conn = 0) { |
function delete_message($msg_file, $usr_file, $user, $time, $pass,
|
| global $headframe; |
$use_virtual_delete, $use_db = 0, $db_conn = 0) {
|
| global $bodyframe; |
if (!$use_db) {
|
| global $show_body; |
// Use files
|
| global $frameset; |
$found = false;
|
| ?> |
$i = 0;
|
| <center> |
$fp = fopen($usr_file, "r");
|
| <font color="#C0C0C0" face="Courier" size=5><b><?echo $WB_name?></b></font><br> |
wait_read_lock($fp);
|
| Current time is <?echo format_time(time())?>. |
$p = file($usr_file);
|
| <br> |
release_lock($fp);
|
| <table border=0> |
if ($user != "") {
|
| <form name=data method=POST action="<? |
while ((!$found) && ($i < sizeof($p))) {
|
| echo "$self?"; |
if ($user == get_user($p[$i], 0))
|
| $tmp = link_replace(create_link(), "page", ""); |
$found = true;
|
| if (good($frameset)) |
$i++;
|
| $tmp = link_replace($tmp, "disablepart", "2"); |
};
|
| echo $tmp; |
}
|
| ?>" target="<?echo $bodyframe?>"> |
else
|
| <tr> |
$found = true;
|
| <td align=center valign=middle rowspan=3> |
|
| <textarea name="message" cols=30 rows=5></textarea></td> |
if (!$found)
|
| <td align=center valign=middle><font face="Arial" color=#ffcc00 size=3>Nick</font></td> |
return 1;
|
| <td align=left valign=middle> |
|
| <select name="nick"> |
if (!(($user == "") && ($pass == "")))
|
| <option value="Anonym"><choose></option> |
if (get_pass($p[--$i]) != md5($pass))
|
| <? |
return 2;
|
| |
|
| $nicknames = get_users($user_file, $use_db, $db_conn); |
$fp = fopen($msg_file, "r");
|
| sort($nicknames); |
wait_read_lock($fp);
|
| show_options( |
$f = file($msg_file);
|
| $nicknames, |
$found = false;
|
| $nicknames, |
$i = 0;
|
| $nick); |
while (!$found && ($i < sizeof($f))) {
|
| ?> |
if (get_user($f[$i], 1) == $user && get_time($f[$i]) == $time)
|
| </select> |
$found = true;
|
| </td> |
$i++;
|
| </tr> |
}
|
| <tr> |
if (!$found)
|
| <td valign=middle align=center colspan=2 rowspan=1><input type=submit name=submit_type value="Send"<? |
return 3;
|
| echo "showing=$show_body"; |
$i--;
|
| if (!$show_body) //!!!!!!!!!!!!TOTO NEJDE - JS clearovanie textarea v combo prikaze, aspon nie v tomto zdrojaku :( |
|
| echo " onClick=\"javascript:submit();message.value=''\""; |
if ($use_virtual_delete) {
|
| |
// if already marked as deleted then delete it really
|
| ?>></td> |
if (ereg("[^:]*:[^:]*:\*.*", $f[$i], $regs))
|
| </tr> |
$f[$i] = $f[sizeof($f) - 1];
|
| <tr></tr> |
// if not marked, mark it :)
|
| <tr> |
else
|
| <td align=center> |
$f[$i] = ereg_replace("([^:]*:[^:]*:)(.*)", "\\1*\\2", $f[$i]);
|
| <a href="<?echo $self."?".link_replace(create_link(), "createuser", "1")?>">New nick</a> |
}
|
| </td> |
else {
|
| <td align=right><? |
if (sizeof($f) > 0) {
|
| if (!$style) |
$f[$i] = $f[sizeof($f) - 1];
|
| echo "Board\t /</td><td><a href=$self?". |
}
|
| link_replace(create_link(), "style", "1").">Chat</a></td>"; |
else
|
| else |
$f = array();
|
| echo "<a href=$self?".link_replace(create_link(), "style", "0"). |
}
|
| ">Board</a> /</td><td>Chat</td>"; |
|
| ?> |
// we supppose the array to be sorted (sorting while insert)
|
| </tr> |
//sort($f);
|
| <tr> |
|
| <td align=center colspan=1>Autorefresh time: |
release_lock($fp);
|
| <select name=autorefresh onChange="javascript:form.submit()"> |
|
| <? |
$fp = fopen($msg_file, "w");
|
| show_options( |
wait_write_lock($fp);
|
| array("10 secs","30 secs", "1 min", "5 min", "10 min", "30 min", "infinite"), |
if (is_array($f))
|
| array("10", "30", "60", "300", "600", "1800", "999999999"), |
fwrite($fp, trim(implode($f, ""))."\n");
|
| $autorefresh); |
else
|
| ?> |
if (trim($f) != "")
|
| </select> |
fwrite($fp, trim($f)."\n");
|
| </td><td align=center colspan=1>Page size: |
release_lock($fp);
|
| <select name=pagesize onChange="javascript:form.submit()"> |
fclose($fp);
|
| <? |
|
| show_options( |
return 0;
|
| array("10", "25", "50", "100", "all"), |
}
|
| array("10", "25", "50", "100", "999999"), |
else {
|
| $pagesize); |
// Use DB
|
| ?> |
if (!$db_conn)
|
| </select> |
return false;
|
| </td><td align=center><a href="boardframes.html" target=_top>Switch </a><a href="boardframes.html" target=_blank>to</a> <a href="boardframes.html" target=_parent>frames</a></td> |
|
| </tr> |
$user = addslashes($user);
|
| </form> |
$pass = md5(addslashes($pass));
|
| </table> |
$time = date("YmdHis", $time);
|
| </center> |
|
| <? |
$sql = "select id from $usr_file where " .
|
| return 1; |
"nick = '$user' and pass = '$pass'";
|
| } |
$res = $db_conn->query($sql);
|
| |
|
| function show_page_walk($currentpage, $pagesize, $nummsgs, $firstmsg, $lastmsg) { |
if ((DB::isError($res)) || ($res->numRows() != 1))
|
| global $self; |
return 0;
|
| $lastpage = ceil($nummsgs / $pagesize); |
|
| |
$res->fetchInto($row);
|
| echo "<center>Messages ".($firstmsg + 1)."-". |
$res->free;
|
| ($lastmsg + 1)." of $nummsgs<br>"; |
$author_id = $row["id"];
|
| |
|
| // REWIND to begin |
switch($use_virtual_delete) {
|
| if ($firstmsg == 0) |
case true:
|
| echo "<<"; |
$sql = "select id from $msg_file where flags=1 and author_id='".
|
| else |
"$author_id' and created='$time'";
|
| echo "<a href=$self?".link_replace(create_link(), "page", "1")."><<</a>"; |
$res = $db_conn->query($sql);
|
| echo " "; |
if ($res->numRows() == 0) {
|
| |
$sql = "update $msg_file " .
|
| // PREVIOUS PAGE |
"set created='$time', deleted=sysdate(), flags=1 where ".
|
| if ($firstmsg == 0) |
"author_id = '$author_id' and created='$time'";
|
| echo "<"; |
$res->free;
|
| else |
break;
|
| echo "<a href=$self?".link_replace(create_link(), "page", ($currentpage-1))."><</a>"; |
}
|
| |
// else continue to hard delete
|
| echo " "; |
case false:
|
| |
$sql = "delete from $msg_file where ".
|
| // OTHER PAGES |
"author_id = '$author_id' and created='$time'";
|
| for ($i = 1; $i <= $lastpage; $i++) { |
}
|
| echo ($i == $currentpage)?"$i ":"<a href=$self?". |
echo "!@#$sql#@!";
|
| link_replace(create_link(), "page", $i).">".$i."</a> "; |
$res = $db_conn->query($sql);
|
| } |
if (DB::isError($res))
|
| |
return false;
|
| // NEXT PAGE |
|
| if ($lastmsg >= ($nummsgs - 1)) |
$res->free;
|
| echo ">"; |
return true;
|
| else |
}
|
| echo "<a href=$self?". |
}
|
| link_replace(create_link(), "page", ($currentpage+1)). |
|
| ">></a>"; |
function show_data_form($user_file, $self, $nick,
|
| |
$style, $WB_name, $autorefresh, $pagesize, $use_db = 0, $db_conn = 0) {
|
| echo " "; |
global $headframe;
|
| |
global $bodyframe;
|
| // REWIND PAGE to end |
global $show_body;
|
| if ($lastmsg >= ($nummsgs - 1)) |
global $frameset;
|
| echo ">>"; |
?>
|
| else |
<center>
|
| echo "<a href=$self?". |
<font color="#C0C0C0" face="Courier" size=5><b><?echo $WB_name?></b></font><br>
|
| link_replace(create_link(), "page", $lastpage). |
Current time is <?echo format_time(time())?>.
|
| ">>></a>"; |
<br>
|
| |
<table border=0>
|
| echo "</center>\n"; |
<form name=data method=POST action="<?
|
| } |
echo "$self?";
|
| |
$tmp = link_replace(create_link(), "page", "");
|
| function show_nonrefresh_head() { |
if (good($frameset))
|
| global $WB_name, $WB_version; |
$tmp = link_replace($tmp, "disablepart", "2");
|
| ?> |
echo $tmp;
|
| <html> |
?>" target="<?echo $bodyframe?>">
|
| <head> |
<tr>
|
| <title><?echo "$WB_name v$WB_version"?></title> |
<td align=center valign=middle rowspan=3>
|
| </head> |
<textarea name="message" cols=30 rows=5></textarea></td>
|
| <body bgcolor="black" text="#C0C0C0" link="#888ff" alink="#888ff" vlink="#888ff"> |
<td align=center valign=middle><font face="Arial" color=#ffcc00 size=3>Nick</font></td>
|
| <? |
<td align=left valign=middle>
|
| } |
<select name="nick">
|
| |
<option value="Anonym"><choose></option>
|
| function show_delete_dialog($nick, $time) { |
<?
|
| global $self; //!!!!!!!TODO |
|
| echo "\n<center><font color=#C0C0C0 face=Courier size=4><b>Delete message</font></b><br><br>"; |
$nicknames = get_users($user_file, $use_db, $db_conn);
|
| echo "\n<center>\n<form name=deletemessage method=post action=$self?". |
sort($nicknames);
|
| link_replace(link_replace(create_link(), "deleteok", 1), |
show_options(
|
| "time", $time).">\n"; |
$nicknames,
|
| echo "<table align=center>\n"; |
$nicknames,
|
| echo "\t\n<tr>\n\t\t<td>Nick:</td><td><input type=text value=\"$nick\" readonly></td></tr>\n"; |
$nick);
|
| echo "\t\n<tr>\n\t\t<td>Message No.:</td><td><input type=text value=\"$time\" readonly></td></tr>\n"; |
?>
|
| echo "\t\n<tr>\n\t\t<td>Password:</td><td><input type=password name=pass></td></tr>\n"; |
</select>
|
| echo "\t\n<tr>\n\t\t<td colspan=2 align=center><input type=submit name=submit_type value=Delete>\n</td></tr>\n"; |
</td>
|
| echo "\t<tr><td align=center colspan=2><a href=$self?". |
</tr>
|
| create_link(). |
<tr>
|
| ">cancel</a></td></tr>\n"; |
<td valign=middle align=center colspan=2 rowspan=1><input type=submit name=submit_type value="Send"<?
|
| echo "</table>\n"; |
// TODO redo the JS inline function (it doesn't clear the memo now)
|
| echo "</form>\n</center>\n"; |
if (!$show_body)
|
| } |
echo " onClick=\"javascript:submit();message.value=''\"";
|
| |
|
| function show_createuser_dialog($newnick, $email) { |
?>></td>
|
| global $self; // !!! TODO |
</tr>
|
| echo "\n<center><font color=#C0C0C0 face=Courier size=4><b>Create new user</font></b><br><br>"; |
<tr></tr>
|
| echo "<table size=90% align=center>\n"; |
<tr>
|
| |
<td align=center>
|
| echo "\n<form name=createuser method=post action=$self?". |
<a href="<?echo $self."?".link_replace(create_link(), "createuser", "1")?>">New nick</a>
|
| link_replace(link_replace( |
</td>
|
| create_link(), "createok", 1), "createuser", 1 |
<td align=right><?
|
| ). |
if (!$style)
|
| ">\n"; |
echo "Board\t /</td><td><a href=$self?".
|
| echo "\t<tr>\n\t\t<td>New Nick:</td><td><input type=text name=newnick maxsize=16 value=$newnick></td>\n"; |
link_replace(create_link(), "style", "1").">Chat</a></td>";
|
| echo "\t<tr><td>E-mail:</td><td><input type=text name=mail value=$email></td>\n\t</tr>\n"; |
else
|
| echo "\t<tr><td>Password:</td><td><input type=password name=pass></td>\n\t</tr>\n"; |
echo "<a href=$self?".link_replace(create_link(), "style", "0").
|
| echo "\t<tr><td align=center colspan=2><input type=submit name=submit_type value=Create></td>\n\t</tr>\n"; |
">Board</a> /</td><td>Chat</td>";
|
| echo "\t<tr><td align=center colspan=2><a href=$self?". |
?>
|
| link_replace(create_link(), "createuser", ""). |
</tr>
|
| ">cancel</a></td></tr>\n"; |
<tr>
|
| echo "</form>\n</table>\n</center>\n"; |
<td align=center colspan=1>Autorefresh time:
|
| } |
<select name=autorefresh onChange="javascript:form.submit()">
|
| |
<?
|
| function show_message($message, $style = 0) { |
show_options(
|
| global $self; // !!!TODO |
array("10 secs","30 secs", "1 min", "5 min", "10 min", "30 min", "infinite"),
|
| switch($style) { |
array("10", "30", "60", "300", "600", "1800", "999999999"),
|
| case 1: |
$autorefresh);
|
| // Chat message line |
?>
|
| echo "<tr><td valign=top>"; |
</select>
|
| echo "<a href=$self?". |
</td><td align=center colspan=1>Page size:
|
| link_replace( |
<select name=pagesize onChange="javascript:form.submit()">
|
| link_replace( |
<?
|
| create_link(), "time", $message["time"] |
show_options(
|
| ), |
array("10", "25", "50", "100", "all"),
|
| "nick", |
array("10", "25", "50", "100", "999999"),
|
| $message["name"]). |
$pagesize);
|
| ">".format_time($message["time"], 1)."</a>_"; |
?>
|
| if ($message["email"] != "") |
</select>
|
| echo "<a href=\"mailto:".$message["email"]. |
</td>
|
| "\""." class=\"amsg\">". |
<td align=center>
|
| $message["name"]."</a>"; |
<a href="<?
|
| else |
echo "$self?".link_replace(link_replace(create_link(), "setframes", 1), "disablepart", 3);
|
| echo $message["name"]; |
?>" target=_top>Switch to frames</a>
|
| echo ":</td><td>".$message["message"]; |
</td>
|
| echo "</td></tr>\n"; |
</tr>
|
| break; |
</form>
|
| default: |
</table>
|
| // Board message style |
</center>
|
| echo "<tr><td>"; |
<?
|
| if ($message["email"] != "") |
return 1;
|
| echo "<a href=\"mailto:" . |
}
|
| $message["email"] . |
|
| "\" class=\"amsg\">\n"; |
function show_page_walk($currentpage, $pagesize, $nummsgs, $firstmsg, $lastmsg) {
|
| echo "\t" . $message["name"] . "\n"; |
global $self;
|
| echo "</a>\n\t - "; |
$lastpage = ceil($nummsgs / $pagesize);
|
| echo "\t" . format_time($message["time"])."\n"; |
|
| echo "\t\t - <a href=$self?" . |
echo "<center>Messages ".($firstmsg + 1)."-".
|
| link_replace( |
($lastmsg + 1)." of $nummsgs<br>";
|
| link_replace( |
|
| create_link(), "time", $message["time"] |
// REWIND to begin
|
| ), |
if ($firstmsg == 0)
|
| "nick", |
echo "<<";
|
| $message["name"]). |
else
|
| ">delete</a>\n"; |
echo "<a href=$self?".link_replace(create_link(), "page", "1")."><<</a>";
|
| echo "<br>"; |
echo " ";
|
| echo "\t" . $message["message"] . "\n"; |
|
| echo "</td></tr>\n"; |
// PREVIOUS PAGE
|
| break; |
if ($firstmsg == 0)
|
| } |
echo "<";
|
| } |
else
|
| |
echo "<a href=$self?".link_replace(create_link(), "page", ($currentpage-1))."><</a>";
|
| function show_messages($message_file, $user_file, $page, $pagesize, |
|
| $msg_style = 0, $show_all = 0, $use_db = 0, $db_conn = 0) { |
echo " ";
|
| |
|
| $messages = read_messages($message_file, $user_file, $show_all, |
// OTHER PAGES
|
| $use_db, $db_conn); |
for ($i = 1; $i <= $lastpage; $i++) {
|
| $n = sizeof($messages); |
echo ($i == $currentpage)?"$i ":"<a href=$self?".
|
| global $self;//!!!!! TODO |
link_replace(create_link(), "page", $i).">".$i."</a> ";
|
| |
}
|
| if ($n <= 0) { |
|
| echo "<center><font color=red><b>No messages YeT !</b></font></center>"; |
// NEXT PAGE
|
| } |
if ($lastmsg >= ($nummsgs - 1))
|
| else { |
echo ">";
|
| if ($page < 1) |
else
|
| $page = 1; |
echo "<a href=$self?".
|
| if ($page >= ($n / $pagesize)) |
link_replace(create_link(), "page", ($currentpage+1)).
|
| $page = ceil($n / $pagesize); |
">></a>";
|
| |
|
| $first = $pagesize * ($page - 1); |
echo " ";
|
| $last = ($pagesize * $page) - 1; |
|
| |
// REWIND PAGE to end
|
| if ($first < 0) |
if ($lastmsg >= ($nummsgs - 1))
|
| $first = 0; |
echo ">>";
|
| if ($first > $n) |
else
|
| $first = $n - 1; |
echo "<a href=$self?".
|
| |
link_replace(create_link(), "page", $lastpage).
|
| if ($last > ($n - 1)) |
">>></a>";
|
| $last = $n - 1; |
|
| if ($last < $first) |
echo "</center>\n";
|
| $last = $first; |
}
|
| |
|
| show_page_walk($page, $pagesize, $n, $first, $last); |
function show_nonrefresh_head() {
|
| |
global $WB_name, $WB_version;
|
| echo "<table width=100%>"; |
?>
|
| for ($i = $first; $i <= $last; $i++) { |
<html>
|
| show_message($messages[sizeof($messages) - 1 - $i], $msg_style); |
<head>
|
| } |
<title><?echo "$WB_name v$WB_version"?></title>
|
| echo "</table>"; |
</head>
|
| |
<body bgcolor="black" text="#C0C0C0" link="#888ff" alink="#888ff" vlink="#888ff">
|
| show_page_walk($page, $pagesize, $n, $first, $last); |
<?
|
| } |
}
|
| } |
|
| |
function show_delete_dialog($nick, $time) {
|
| |
global $self; //!!!!!!!TODO
|
| // /////////////////////////////////////////////// |
echo "\n<center><font color=#C0C0C0 face=Courier size=4><b>Delete message</font></b><br><br>";
|
| // /////////// THIS IS MAIN FUNCTION ///////////// |
echo "\n<center>\n<form name=deletemessage method=post action=$self?".
|
| // /////////////////////////////////////////////// |
link_replace(link_replace(create_link(), "deleteok", 1),
|
| |
"time", $time).">\n";
|
| // DEFAULTS |
echo "<table align=center>\n";
|
| if ($use_db) { |
echo "\t\n<tr>\n\t\t<td>Nick:</td><td><input type=text value=\"$nick\" readonly></td></tr>\n";
|
| require_once "DB.php"; |
echo "\t\n<tr>\n\t\t<td>Message No.:</td><td><input type=text value=\"$time\" readonly></td></tr>\n";
|
| $db_handle = DB::connect("mysql://$db_user:$db_pass" |
echo "\t\n<tr>\n\t\t<td>Password:</td><td><input type=password name=pass></td></tr>\n";
|
| . "@$db_host/$db_database"); |
echo "\t\n<tr>\n\t\t<td colspan=2 align=center><input type=submit name=submit_type value=Delete>\n</td></tr>\n";
|
| if (DB::isError($db_handle)) { |
echo "\t<tr><td align=center colspan=2><a href=$self?".
|
| echo $db_handle->getMessage(); |
create_link().
|
| exit; |
">cancel</a></td></tr>\n";
|
| } |
echo "</table>\n";
|
| if ($use_db) { |
echo "</form>\n</center>\n";
|
| $user_file = $db_user_table; |
}
|
| $message_file = $db_message_table; |
|
| } |
function show_createuser_dialog($newnick, $email) {
|
| } |
global $self; // !!! TODO
|
| |
echo "\n<center><font color=#C0C0C0 face=Courier size=4><b>Create new user</font></b><br><br>";
|
| if (!good($self)) |
echo "<table size=90% align=center>\n";
|
| $self = $PHP_SELF; |
|
| |
echo "\n<form name=createuser method=post action=$self?".
|
| if ($strip_slashes) { |
link_replace(link_replace(
|
| $message = stripslashes($message); |
create_link(), "createok", 1), "createuser", 1
|
| $nick = stripslashes($nick); |
).
|
| $pass = stripslashes($pass); |
">\n";
|
| $header = stripslashes($header); |
echo "\t<tr>\n\t\t<td>New Nick:</td><td><input type=text name=newnick maxsize=16 value=$newnick></td>\n";
|
| $body = stripslashes($body); |
echo "\t<tr><td>E-mail:</td><td><input type=text name=mail value=$email></td>\n\t</tr>\n";
|
| $bodyframe = stripslashes($bodyframe); |
echo "\t<tr><td>Password:</td><td><input type=password name=pass></td>\n\t</tr>\n";
|
| $headerframe = stripslashes($headerframe); |
echo "\t<tr><td align=center colspan=2><input type=submit name=submit_type value=Create></td>\n\t</tr>\n";
|
| $disablepart = stripslashes($disablepart); |
echo "\t<tr><td align=center colspan=2><a href=$self?".
|
| $setframes = stripslashes($setframes); |
link_replace(create_link(), "createuser", "").
|
| $newnick = stripslashes($newnick); |
">cancel</a></td></tr>\n";
|
| } |
echo "</form>\n</table>\n</center>\n";
|
| |
}
|
| if ($pagesize < 10) |
|
| $pagesize = 50; |
function show_message($message, $style = 0) {
|
| settype($pagesize, integer); |
global $self; // !!!TODO
|
| if ($autorefresh < 10) |
switch($style) {
|
| $autorefresh = 300; |
case 1:
|
| settype($autorefresh, integer); |
// Chat message line
|
| |
echo "<tr><td valign=top>";
|
| |
echo "<a href=$self?".
|
| if (!good($disablepart) || ($disablepart>3) || ($disablepart<0)) |
link_replace(
|
| $disablepart = 0; |
link_replace(
|
| |
create_link(), "time", $message["time"]
|
| if (!good($headframe)) |
),
|
| $headframe = $DEFAULT_HEAD_FRAME; |
"nick",
|
| |
$message["name"]).
|
| if (!good($bodyframe)) |
">".format_time($message["time"], 1)."</a>_";
|
| $bodyframe = $DEFAULT_BODY_FRAME; |
if ($message["email"] != "")
|
| |
echo "<a href=\"mailto:".$message["email"].
|
| switch ($disablepart) { |
"\""." class=\"amsg\">".
|
| case 0: |
$message["name"]."</a>";
|
| $show_body = true; |
else
|
| $show_head = true; |
echo $message["name"];
|
| break; |
echo ":</td><td>".$message["message"];
|
| case 1: |
echo "</td></tr>\n";
|
| $show_head = true; |
break;
|
| $show_body = false; |
default:
|
| break; |
// Board message style
|
| case 2: |
echo "<tr><td>";
|
| $show_head = false; |
if ($message["email"] != "")
|
| $show_body = true; |
echo "<a href=\"mailto:" .
|
| break; |
$message["email"] .
|
| case 3: |
"\" class=\"amsg\">\n";
|
| $show_body = false; |
echo "\t" . $message["name"] . "\n";
|
| $show_head = false; |
echo "</a>\n\t - ";
|
| break; |
echo "\t" . format_time($message["time"])."\n";
|
| } |
echo "\t\t - <a href=$self?" .
|
| |
link_replace(
|
| if (!good($page)) |
link_replace(
|
| $page = 0; |
create_link(), "time", $message["time"]
|
| |
),
|
| if (!isset($nick) && good($newnick)) |
"nick",
|
| $nick = $newnick; |
$message["name"]).
|
| |
">delete</a>\n";
|
| if (!good($mail)) |
echo "<br>";
|
| $mail = get_email($nick); |
echo "\t" . $message["message"] . "\n";
|
| |
echo "</td></tr>\n";
|
| if (good($archive)) |
break;
|
| $hist_file_prefix = $archive; |
}
|
| |
}
|
| if (good($archive_no) && !$use_db) |
|
| $message_file = $old_messages_folder.$hist_file_prefix.$archive_no; |
function show_messages($message_file, $user_file, $page, $pagesize,
|
| |
$msg_style = 0, $show_all = 0, $use_db = 0, $db_conn = 0) {
|
| //header ("Cache-Control: no-cache, must-revalidate"); |
|
| //header ("Pragma: no-cache"); |
$messages = read_messages($message_file, $user_file, $show_all,
|
| |
$use_db, $db_conn);
|
| // CREATE NEW USER |
if ($messages === false)
|
| if ($createuser) { |
$messages = array();
|
| $mails = get_emails($user_file, $use_db, $db_handle); |
$n = sizeof($messages);
|
| |
global $self;//!!!!! TODO
|
| if (good($newnick) && |
|
| ($mails[$newnick] == "") && |
if ($n <= 0) {
|
| good($mail) && |
echo "<center><font color=red><b>No messages YeT !</b></font></center>";
|
| good($createok) && |
}
|
| ($createok == 1)) |
else {
|
| write_mail($user_file, $newnick, $mail, $pass, $use_db, $db_handle); |
if ($page < 1)
|
| else { |
$page = 1;
|
| show_nonrefresh_head(); |
if ($page >= ($n / $pagesize))
|
| show_createuser_dialog($newnick, $email); |
$page = ceil($n / $pagesize);
|
| $show_body = false; |
|
| } |
$first = $pagesize * ($page - 1);
|
| } |
$last = ($pagesize * $page) - 1;
|
| |
|
| // WRITE MESSAGE TO DB |
if ($first < 0)
|
| if (good($message) && good($submit_type)) |
$first = 0;
|
| write_message($message_file, $nick, $message, 0, |
if ($first > $n)
|
| $old_messages_folder, $max_msgs_in_one_file, |
$first = $n - 1;
|
| $min_msgs_in_board, $hist_file_prefix, $use_db, $db_handle); |
|
| |
if ($last > ($n - 1))
|
| // DELETE MESSAGE FROM DB |
$last = $n - 1;
|
| if (good($time)) { |
if ($last < $first)
|
| if (good($deleteok) && ($deleteok == 1)){ |
$last = $first;
|
| switch(delete_message($message_file, $user_file, $nick, |
|
| $time, $pass, $use_virtual_delete, $use_db, $db_handle)) { |
show_page_walk($page, $pagesize, $n, $first, $last);
|
| // TOTO ESTE DOROBIT - SPRAVANIE SA |
|
| // SKRIPTU KED NASTANU PROBLEMY PRI DELETOVANI SPRAVY |
echo "<table width=100%>";
|
| case 0: // All OK |
for ($i = $first; $i <= $last; $i++) {
|
| // echo "<center>Message deleted succesfully<br></center>\n"; |
show_message($messages[sizeof($messages) - 1 - $i], $msg_style);
|
| break; |
}
|
| case 1: // No such user |
echo "</table>";
|
| // echo "<center>Error while deleting: There is no such user!<br></center>\n"; |
|
| break; |
show_page_walk($page, $pagesize, $n, $first, $last);
|
| case 2: // Wrong password |
}
|
| // echo "<center>Error while deleting: Wrong password!<br></center>\n"; |
}
|
| break; |
|
| case 3: // No such message |
|
| // echo "<center>Error while deleting: No such message!<br></center>\n"; |
// ///////////////////////////////////////////////
|
| break; |
// /////////// THIS IS MAIN FUNCTION /////////////
|
| default:// Unknown error |
// ///////////////////////////////////////////////
|
| // echo "<center>Fatal Error while deleting: unknown error code!</center><br>\n"; |
|
| break; |
// DEFAULTS
|
| } |
|
| } else { |
if (!good($self))
|
| show_nonrefresh_head(); |
$self = $PHP_SELF;
|
| show_delete_dialog($nick, $time); |
|
| $show_body = false; |
if ($strip_slashes) {
|
| } |
$message = stripslashes($message);
|
| } |
$nick = stripslashes($nick);
|
| |
$pass = stripslashes($pass);
|
| // check for superuser view |
$header = stripslashes($header);
|
| if (($nick == $root_name) && (md5($pass) == $root_md5_password)) |
$body = stripslashes($body);
|
| $superuser = 1; |
$bodyframe = stripslashes($bodyframe);
|
| else |
$headerframe = stripslashes($headerframe);
|
| $superuser = 0; |
$disablepart = stripslashes($disablepart);
|
| |
$newnick = stripslashes($newnick);
|
| // We don't want to show body, when other form is shown |
}
|
| |
|
| ?> |
|
| <html> |
if ($pagesize < 10)
|
| <head> |
$pagesize = 50;
|
| <title><?echo "$WB_name v$WB_version"?></title> |
settype($pagesize, integer);
|
| <? |
|
| if ($show_head) { |
if ($autorefresh < 10)
|
| ?> |
$autorefresh = 300;
|
| </head> |
settype($autorefresh, integer);
|
| <body bgcolor=black text=#C0C0C0 link=#888ff alink=#888ff vlink=#888ff> |
|
| <? |
if (!good($disablepart) || ($disablepart > 3) || ($disablepart < 0))
|
| show_data_form($user_file, $self, $nick, $style, $WB_name, |
$disablepart = 0;
|
| $autorefresh, $pagesize, $use_db, $db_handle); |
|
| } |
if (!good($headframe))
|
| |
$headframe = $DEFAULT_HEAD_FRAME;
|
| if ($show_body) { |
|
| echo "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"$autorefresh URL=$self?". |
if (!good($bodyframe))
|
| create_link()."\">\n"; |
$bodyframe = $DEFAULT_BODY_FRAME;
|
| ?> |
|
| </head> |
switch ($disablepart) {
|
| <body bgcolor=black text=#C0C0C0 link=#888ff alink=#888ff vlink=#888ff> |
case 0:
|
| <? |
$show_body = true;
|
| show_messages($message_file, $user_file, $page, $pagesize, |
$show_head = true;
|
| $style, $superuser, $use_db, $db_handle); |
break;
|
| } |
case 1:
|
| |
$show_head = true;
|
| if ($use_db) { |
$show_body = false;
|
| $db_handle->disconnect(); |
break;
|
| } |
case 2:
|
| ?> |
$show_head = false;
|
| </p> |
$show_body = true;
|
| </body> |
break;
|
| </html> |
case 3:
|
| |
$show_body = false;
|
| |
$show_head = false;
|
| |
break;
|
| |
}
|
| |
|
| |
if (!good($page))
|
| |
$page = 0;
|
| |
|
| |
if (!isset($nick) && good($newnick))
|
| |
$nick = $newnick;
|
| |
|
| |
if (!good($mail))
|
| |
$mail = get_email($nick);
|
| |
|
| |
if (good($archive))
|
| |
$hist_file_prefix = $archive;
|
| |
|
| |
if (good($archive_no) && !$use_db)
|
| |
$message_file = $old_messages_folder.$hist_file_prefix.$archive_no;
|
| |
|
| |
//header ("Cache-Control: no-cache, must-revalidate");
|
| |
//header ("Pragma: no-cache");
|
| |
|
| |
if ($use_db) {
|
| |
require_once "DB.php";
|
| |
$db_handle = DB::connect("mysql://$db_user:$db_pass"
|
| |
. "@$db_host/$db_database");
|
| |
if (DB::isError($db_handle)) {
|
| |
echo $db_handle->getMessage();
|
| |
$db_handle = 0;
|
| |
//exit;
|
| |
}
|
| |
if ($use_db) {
|
| |
$db_handle->setFetchMode(DB_FETCHMODE_ASSOC);
|
| |
$user_file = $db_user_table;
|
| |
$message_file = $db_message_table;
|
| |
}
|
| |
}
|
| |
// CREATE NEW USER
|
| |
if ($createuser) {
|
| |
$mails = get_emails($user_file, $use_db, $db_handle);
|
| |
|
| |
if (good($newnick) &&
|
| |
($mails[$newnick] == "") &&
|
| |
good($createok) &&
|
| |
($createok == 1))
|
| |
write_mail($user_file, $newnick, $mail, $pass, $use_db, $db_handle);
|
| |
else {
|
| |
show_nonrefresh_head();
|
| |
show_createuser_dialog($newnick, $email);
|
| |
$show_head = false;
|
| |
$show_body = false;
|
| |
}
|
| |
}
|
| |
|
| |
// WRITE MESSAGE TO DB
|
| |
if (good($message) && good($submit_type))
|
| |
write_message($message_file, $user_file, $nick, $message, 0,
|
| |
$old_messages_folder, $max_msgs_in_one_file, $min_msgs_in_board,
|
| |
$hist_file_prefix, $allowed_tags, $use_db, $db_handle);
|
| |
|
| |
// DELETE MESSAGE FROM DB
|
| |
if (good($time)) {
|
| |
if (good($deleteok) && ($deleteok == 1)){
|
| |
switch(delete_message($message_file, $user_file, $nick,
|
| |
$time, $pass, $use_virtual_delete, $use_db, $db_handle)) {
|
| |
// TOTO ESTE DOROBIT - SPRAVANIE SA
|
| |
// SKRIPTU KED NASTANU PROBLEMY PRI DELETOVANI SPRAVY
|
| |
case 0: // All OK
|
| |
// echo "<center>Message deleted succesfully<br></center>\n";
|
| |
break;
|
| |
case 1: // No such user
|
| |
// echo "<center>Error while deleting: There is no such user!<br></center>\n";
|
| |
break;
|
| |
case 2: // Wrong password
|
| |
// echo "<center>Error while deleting: Wrong password!<br></center>\n";
|
| |
break;
|
| |
case 3: // No such message
|
| |
// echo "<center>Error while deleting: No such message!<br></center>\n";
|
| |
break;
|
| |
default:// Unknown error
|
| |
// echo "<center>Fatal Error while deleting: unknown error code!</center><br>\n";
|
| |
break;
|
| |
}
|
| |
} else {
|
| |
show_nonrefresh_head();
|
| |
show_delete_dialog($nick, $time);
|
| |
$show_body = false;
|
| |
$show_head = false;
|
| |
}
|
| |
}
|
| |
|
| |
// check for superuser view
|
| |
if (($nick == $root_name) && (md5($pass) == $root_md5_password))
|
| |
$superuser = 1;
|
| |
else
|
| |
$superuser = 0;
|
| |
|
| |
// We don't want to show body, when other form is shown
|
| |
|
| |
?>
|
| |
<html>
|
| |
<head>
|
| |
<title><?echo "$WB_name v$WB_version"?></title>
|
| |
<?
|
| |
/*
|
| |
If set, do nothing, just create frames and recursively call self
|
| |
*/
|
| |
if (good($setframes)) {
|
| |
$frmlnk =
|
| |
link_replace(
|
| |
link_replace(
|
| |
link_replace(create_link(), "frameset", 1),
|
| |
"bodyframe",
|
| |
"bodyframe"),
|
| |
"headframe",
|
| |
"headframe"
|
| |
);
|
| |
echo "<frameset rows=\"230,*\" framespacing=0 cols=*>\n";
|
| |
echo "<frame name=headframe src=\"$self?" .
|
| |
link_replace($frmlnk, "disablepart", 1) .
|
| |
"\">\n";
|
| |
echo "<frame name=headframe src=\"$self?" .
|
| |
link_replace($frmlnk, "disablepart", 2) .
|
| |
"\" scrolling=AUTO>\n";
|
| |
echo "</frameset>\n";
|
| |
echo "</html>";
|
| |
$show_body = false;
|
| |
$show_head = false;
|
| |
}
|
| |
|
| |
if ($show_head) {
|
| |
?>
|
| |
</head>
|
| |
<body bgcolor=black text=#C0C0C0 link=#888ff alink=#888ff vlink=#888ff>
|
| |
<?
|
| |
show_data_form($user_file, $self, $nick, $style, $WB_name,
|
| |
$autorefresh, $pagesize, $use_db, $db_handle);
|
| |
}
|
| |
|
| |
if ($show_body) {
|
| |
echo "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"$autorefresh URL=$self?".
|
| |
create_link()."\">\n";
|
| |
?>
|
| |
</head>
|
| |
<body bgcolor=black text=#C0C0C0 link=#888ff alink=#888ff vlink=#888ff>
|
| |
<?
|
| |
show_messages($message_file, $user_file, $page, $pagesize,
|
| |
$style, $superuser, $use_db, $db_handle);
|
| |
}
|
| |
|
| |
if ($use_db && $db_handle) {
|
| |
$db_handle->disconnect();
|
| |
}
|
| |
?>
|
| |
</body>
|
| |
</html>
|