post.php.t
来自「eGroupWare is a multi-user, web-based gr」· T 代码 · 共 628 行 · 第 1/2 页
T
628 行
<?php/**************************************************************************** copyright : (C) 2001-2003 Advanced Internet Designs Inc.* email : forum@prohost.org* $Id: post.php.t,v 1.3 2003/12/18 18:20:49 iliaa Exp $** This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or * (at your option) any later version.***************************************************************************/function flood_check(){ $check_time = __request_timestamp__-$GLOBALS['FLOOD_CHECK_TIME']; if (($v = q_singleval("SELECT post_stamp FROM {SQL_TABLE_PREFIX}msg WHERE ip_addr='".get_ip()."' AND poster_id="._uid." AND post_stamp>".$check_time." ORDER BY post_stamp DESC LIMIT 1"))) { return (($v + $GLOBALS['FLOOD_CHECK_TIME']) - __request_timestamp__); } return;}/*{PRE_HTML_PHP}*/ $pl_id = 0; $old_subject = $attach_control_error = ''; /* redirect user where need be in moderated forums after they've seen the moderation message. */ if (isset($_POST['moderated_redr'])) { check_return($usr->returnto); } /* we do this because we don't want to take a chance that data is passed via cookies */ if (isset($_GET['reply_to']) || isset($_POST['reply_to'])) { $reply_to = (int) (isset($_GET['reply_to']) ? $_GET['reply_to'] : $_POST['reply_to']); } else { $reply_to = 0; } if (isset($_GET['msg_id']) || isset($_POST['msg_id'])) { $msg_id = (int) (isset($_GET['msg_id']) ? $_GET['msg_id'] : $_POST['msg_id']); } else { $msg_id = 0; } if (isset($_GET['th_id']) || isset($_POST['th_id'])) { $th_id = (int) (isset($_GET['th_id']) ? $_GET['th_id'] : $_POST['th_id']); } else { $th_id = 0; } if (isset($_GET['frm_id']) || isset($_POST['frm_id'])) { $frm_id = (int) (isset($_GET['frm_id']) ? $_GET['frm_id'] : $_POST['frm_id']); } else { $frm_id = 0; } /* replying or editing a message */ if ($reply_to || $msg_id) { $msg = msg_get(($reply_to ? $reply_to : $msg_id)); $th_id = $msg->thread_id; $msg->login = q_singleval('SELECT alias FROM {SQL_TABLE_PREFIX}users WHERE id='.$msg->poster_id); } if ($th_id) { $thr = db_sab('SELECT t.forum_id, t.replies, t.thread_opt, t.root_msg_id, t.orderexpiry, m.subject FROM {SQL_TABLE_PREFIX}thread t INNER JOIN {SQL_TABLE_PREFIX}msg m ON t.root_msg_id=m.id WHERE t.id='.$th_id); if (!$thr) { invl_inp_err(); } $frm_id = $thr->forum_id; } else if ($frm_id) { $th_id = null; } else { std_error('systemerr'); } $frm = db_sab('SELECT id, name, max_attach_size, forum_opt, max_file_attachments, post_passwd, message_threshold FROM {SQL_TABLE_PREFIX}forum WHERE id='.$frm_id); $frm->forum_opt = (int) $frm->forum_opt; /* fetch permissions & moderation status */ $MOD = (int) ($usr->users_opt & 1048576 || ($usr->users_opt & 524288 && is_moderator($frm->id, _uid))); $perms = perms_from_obj(db_sab('SELECT group_cache_opt, '.$MOD.' as md FROM {SQL_TABLE_PREFIX}group_cache WHERE user_id IN('._uid.',2147483647) AND resource_id='.$frm->id.' ORDER BY user_id ASC LIMIT 1'), ($usr->users_opt & 1048576)); /* this is a hack, it essentially disables file attachment code when file_uploads are off */ if (ini_get("file_uploads") != 1 || !($perms & 256)) { $post_enctype = ''; $perms = $perms &~ 256; } else { $post_enctype = '{TEMPLATE: post_enctype}'; } /* More Security */ if (isset($thr) && !($perms & 4096) && $thr->thread_opt & 1) { error_dialog('{TEMPLATE: post_err_lockedthread_title}', '{TEMPLATE: post_err_lockedthread_msg}'); } if (_uid) { /* all sorts of user blocking filters */ is_allowed_user($usr); /* if not moderator, validate user permissions */ if (!$reply_to && !$msg_id && !($perms & 4)) { std_error('perms'); } else if (!$msg_id && ($th_id || $reply_to) && !($perms & 8)) { std_error('perms'); } else if ($msg_id && $msg->poster_id != $usr->id && !($perms & 16)) { std_error('perms'); } else if ($msg_id && $EDIT_TIME_LIMIT && !$MOD && ($msg->post_stamp + $EDIT_TIME_LIMIT * 60 <__request_timestamp__)) { error_dialog('{TEMPLATE: post_err_edttimelimit_title}', '{TEMPLATE: post_err_edttimelimit_msg}'); } } else { if (!$th_id && !($perms & 4)) { error_dialog('{TEMPLATE: post_err_noannontopics_title}', '{TEMPLATE: post_err_noannontopics_msg}'); } else if ($reply_to && !($perms & 8)) { error_dialog('{TEMPLATE: post_err_noannonposts_title}', '{TEMPLATE: post_err_noannonposts_msg}'); } else if (($msg_id && !($perms & 16)) || is_ip_blocked(get_ip())) { invl_inp_err(); } } if (isset($_GET['prev_loaded'])) { $_POST['prev_loaded'] = $_GET['prev_loaded']; } /* Retrieve Message */ if (!isset($_POST['prev_loaded'])) { if (_uid) { $msg_show_sig = !$msg_id ? ($usr->users_opt & 2048) : ($msg->msg_opt & 1); if ($msg_id || $reply_to || $th_id) { $msg_poster_notif = (($usr->users_opt & 2) && !q_singleval("SELECT id FROM {SQL_TABLE_PREFIX}msg WHERE thread_id=".$msg->thread_id." AND poster_id="._uid)) || is_notified(_uid, $msg->thread_id); } else { $msg_poster_notif = ($usr->users_opt & 2); } } if ($msg_id) { $msg_subject = $msg->subject; reverse_fmt($msg_subject); $msg_subject = apply_reverse_replace($msg_subject); $msg_body = post_to_smiley($msg->body); if ($frm->forum_opt & 16) { $msg_body = html_to_tags($msg_body); } else if ($frm->forum_opt & 8) { reverse_fmt($msg_body); reverse_nl2br($msg_body); } $msg_body = apply_reverse_replace($msg_body); $msg_smiley_disabled = ($msg->msg_opt & 2); $msg_icon = $msg->icon; if ($msg->attach_cnt) { $r = q("SELECT id FROM {SQL_TABLE_PREFIX}attach WHERE message_id=".$msg->id." AND attach_opt=0"); while ($fa_id = db_rowarr($r)) { $attach_list[$fa_id[0]] = $fa_id[0]; } unset($r); $attach_count = count($attach_list); } $pl_id = (int) $msg->poll_id; } else if ($reply_to || $th_id) { $subj = $reply_to ? $msg->subject : $thr->subject; reverse_fmt($subj); $msg_subject = strncmp('{TEMPLATE: reply_prefix}', $subj, strlen('{TEMPLATE: reply_prefix}')) ? '{TEMPLATE: reply_prefix}' . ' ' . $subj : $subj; $old_subject = $msg_subject; if (isset($_GET['quote'])) { $msg_body = post_to_smiley(str_replace("\r", '', $msg->body)); if (!strlen($msg->login)) { $msg->login =& $ANON_NICK; } reverse_fmt($msg->login); if ($frm->forum_opt & 16) { $msg_body = html_to_tags($msg_body); reverse_fmt($msg_body); $msg_body = '{TEMPLATE: fud_quote}'; } else if ($frm->forum_opt & 8) { reverse_fmt($msg_body); reverse_nl2br($msg_body); $msg_body = str_replace('<br>', "\n", '{TEMPLATE: plain_quote}'); } else { $msg_body = '{TEMPLATE: html_quote}'; } $msg_body .= "\n"; } } } else { /* $_POST['prev_loaded'] */ if ($FLOOD_CHECK_TIME && !$MOD && !$msg_id && ($tm = flood_check())) { error_dialog('{TEMPLATE: post_err_floodtrig_title}', '{TEMPLATE: post_err_floodtrig_msg}'); } /* import message options */ $msg_show_sig = isset($_POST['msg_show_sig']) ? $_POST['msg_show_sig'] : ''; $msg_smiley_disabled = isset($_POST['msg_smiley_disabled']) ? $_POST['msg_smiley_disabled'] : ''; $msg_poster_notif = isset($_POST['msg_poster_notif']) ? $_POST['msg_poster_notif'] : ''; $pl_id = !empty($_POST['pl_id']) ? poll_validate((int)$_POST['pl_id'], $msg_id) : 0; $msg_body = $_POST['msg_body']; $msg_subject = $_POST['msg_subject']; if ($perms & 256) { $attach_count = 0; /* restore the attachment array */ if (!empty($_POST['file_array']) ) { $attach_list = @unserialize(base64_decode($_POST['file_array'])); if (($attach_count = count($attach_list))) { foreach ($attach_list as $v) { if (!$v) { --$attach_count; } } } } /* remove file attachment */ if (!empty($_POST['file_del_opt']) && isset($attach_list[$_POST['file_del_opt']])) { $attach_list[$_POST['file_del_opt']] = 0; /* Remove any reference to the image from the body to prevent broken images */ if (strpos($msg_body, '[img]{ROOT}?t=getfile&id='.$_POST['file_del_opt'].'[/img]') !== false) { $msg_body = str_replace('[img]{ROOT}?t=getfile&id='.$_POST['file_del_opt'].'[/img]', '', $msg_body); } $attach_count--; } if ($frm->forum_opt & 32 && $MOD) { $frm->max_attach_size = (int) ini_get('upload_max_filesize'); $t = str_replace($frm->max_attach_size, '', ini_get('upload_max_filesize')); if ($t == 'M' || $t == 'm') { $frm->max_attach_size *= 1024; } $frm->max_file_attachments = 100; } $MAX_F_SIZE = $frm->max_attach_size * 1024; /* newly uploaded files */ if (isset($_FILES['attach_control']) && $_FILES['attach_control']['size']) { if ($_FILES['attach_control']['size'] > $MAX_F_SIZE) { $attach_control_error = '{TEMPLATE: post_err_attach_size}'; } else { if (!($MOD && $frm->forum_opt & 32) && filter_ext($_FILES['attach_control']['name'])) { $attach_control_error = '{TEMPLATE: post_err_attach_ext}'; } else { if (($attach_count+1) <= $frm->max_file_attachments) { $val = attach_add($_FILES['attach_control'], _uid); $attach_list[$val] = $val; $attach_count++; } else { $attach_control_error = '{TEMPLATE: post_err_attach_filelimit}'; } } } } $attach_cnt = $attach_count; } else { $attach_cnt = 0; } /* removal of a poll */ if (!empty($_POST['pl_del']) && $pl_id && $perms & 128) { poll_delete($pl_id); $pl_id = 0; } if ($reply_to && $old_subject == $msg_subject) { $no_spell_subject = 1; } if (isset($_POST['btn_spell'])) { $GLOBALS['MINIMSG_OPT']['DISABLED'] = 1; $text = apply_custom_replace($msg_body); $text_s = apply_custom_replace($msg_subject); if ($frm->forum_opt & 16) { $text = tags_to_html($text, $perms & 32768); } else if ($frm->forum_opt & 8) { $text = htmlspecialchars($text); } if ($frm->forum_opt & 24) { char_fix($text); } if ($perms & 16384 && !$msg_smiley_disabled) { $text = smiley_to_post($text); } if (strlen($text)) { $wa = tokenize_string($text); $msg_body = spell_replace($wa, 'body'); if ($perms & 16384 && !$msg_smiley_disabled) { $msg_body = post_to_smiley($msg_body); } if ($frm->forum_opt & 16) { $msg_body = html_to_tags($msg_body); } else if ($frm->forum_opt & 8) { reverse_fmt($msg_body); } $msg_body = apply_reverse_replace($msg_body); } $wa = ''; if (strlen($_POST['msg_subject']) && empty($no_spell_subject)) { $text_s = htmlspecialchars($text_s); char_fix($text_s); $wa = tokenize_string($text_s); $text_s = spell_replace($wa, 'subject'); reverse_fmt($text_s); $msg_subject = apply_reverse_replace($text_s); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?