BitTorrent Трекер RusTrek.ru http://5.45.70.241/ |
|
ReadOnly (Только чтение) http://5.45.70.241/viewtopic.php?f=817&t=36136 |
Страница 1 из 1 |
Автор: | Romanuy [ 2012-03-14 19:20 ] |
Заголовок сообщения: | ReadOnly (Только чтение) |
#################################################################################################### ## MOD Title: ReadOnly (Только чтение) ## MOD Author: (Nightmare) http://greattorrent.tv/profile.php?mode=viewprofile&u=1 ## http://torrentpier.kz/profile.php?mode=viewprofile&u=1 ## MOD Description: Мод добавляет возможность администраторам и модераторам, ставить пользователям ## режим "Только Чтение", с таймером и уведомлениями в ЛС. Мод не включает панель ## управления предупреждениями. ## MOD Version: 0.1 ## ## Installation Level: Easy ## Installation Time: 10 Minutes ## Files To Edit: ## modcp.php ## viewtopic.php ## viewforum.php ## templates/default/viewtopic.tpl ## language/lang_russian/lang_main.php ## includes/functions.php ## includes/init_bb.php ## ## Included Files: N/A #################################################################################################### ## Для безопасности, свяжитесь со мной #################################################################################################### ## Author Notes: ## За идею мода спасибо svk ## Написан SVN R534 #################################################################################################### ## #################################################################################################### ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD #################################################################################################### Код: #
# #-----[ SQL ]------------------------------------------ # CREATE TABLE `bb_readonly` ( `user_id` mediumint(8) NOT NULL default '0', `forum_id` mediumint(8) NOT NULL default '0', `endtime` int(32) NOT NULL default '0', `mod_id` mediumint(8) NOT NULL default '0' ); #-----[ OPEN ]------------------------------------------ # includes/functions.php # #-----[ FIND ]------------------------------------------ # function get_user_id ($username) { if (empty($username)) return false; $row = $GLOBALS['db']->fetch_row("SELECT user_id FROM ". USERS_TABLE ." WHERE username = '$username' LIMIT 1"); return $row['user_id']; } # #-----[ AFTER, ADD ]------------------------------------------ # // Check user Read Only mode by Nightmare function get_user_readonly ($user_id, $forum_id) { global $is_auth; if (empty($user_id) || empty($forum_id)) return false; $sql = "SELECT * FROM ".READONLY_TABLE." WHERE user_id = ".$user_id." AND (forum_id = ".$forum_id." OR forum_id = 0) AND (endtime > ".time()." OR endtime = 0)"; $row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query($sql)); return (!empty($row['user_id'])) ? ($is_auth['auth_post'] = $is_auth['auth_reply'] = $is_auth['auth_edit'] = $is_auth['auth_delete'] = $is_auth['auth_vote'] = 0) : false; } //Send PM by Nightmare function send_pm ($subject, $message, $user_from, $user_to) { $sql = "INSERT INTO ". PRIVMSGS_TABLE. "(privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip) VALUES(" . PRIVMSGS_NEW_MAIL . ",'" . $subject . "'," . $user_from ."," . $user_to . "," . time() . ",'" . encode_ip($HTTP_SERVER_VARS['REMOTE_ADDR']) . "')"; if(!$result = $GLOBALS['db']->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't send message", "", __LINE__, __FILE__, $sql); } $id_mess=mysql_insert_id(); $sql = "INSERT INTO ". PRIVMSGS_TEXT_TABLE ." VALUES(" . $id_mess . ", '', '" .$message. "')"; if(!$result = $GLOBALS['db']->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't send text by message", "", __LINE__, __FILE__, $sql); } $sql = "SELECT u.user_new_privmsg FROM " . USERS_TABLE . " u WHERE user_id=".$user_to; if(!$result = $GLOBALS['db']->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't UPDATE popup", "", __LINE__, __FILE__, $sql); } $priv_msg = $GLOBALS['db']->sql_fetchrowset($result); $sql = "UPDATE " . USERS_TABLE . " SET user_new_privmsg=".($priv_msg[0]['user_new_privmsg'] + 1).", user_last_privmsg=" . time() . ", user_newest_pm_id=". $id_mess ." WHERE user_id=" . $user_to; if(!$result = $GLOBALS['db']->sql_query($sql)) { message_die(GENERAL_ERROR, "Couldn't UPDATE popup", "", __LINE__, __FILE__, $sql); } return $id_mess; } # #-----[ OPEN ]------------------------------------------ # includes/init_bb.php # #-----[ FIND ]------------------------------------------ # define('TOPICS_WATCH_TABLE', $t .'topics_watch'); # #-----[ AFTER, ADD ]------------------------------------------ # // Read Only by Nightmare define('READONLY_TABLE', $t.'readonly'); // Read Only by Nightmare # #-----[ OPEN ]------------------------------------------ # language/lang_russian/lang_main.php # #-----[ FIND ]------------------------------------------ # // That's all, Folks! // ------------------------------------------------- # #-----[ AFTER, ADD ]------------------------------------------ # // Read Only by Nightmare $lang['add_readonly'] = '+'; $lang['user_already_readonly'] = 'Пользователь уже имеет статус "только чтение" в этом форуме'; $lang['del_readonly'] = '-'; $lang['readonly'] = 'Только чтение'; $lang['ro_in_all'] = 'Во всех форумах'; // Read Only by Nightmare # #-----[ OPEN ]------------------------------------------ # modcp.php # #-----[ FIND ]------------------------------------------ # $start = isset($_REQUEST['start']) ? abs(intval($_REQUEST['start'])) : 0; $confirmed = isset($_POST['confirm']); # #-----[ AFTER, ADD ]------------------------------------------ # // Read Only by Nightmare if ( isset($_REQUEST['user']) ) { $ro_user_id = intval($_REQUEST['user']); } else { $ro_user_id = ''; } if ( isset($_REQUEST['time']) ) { $time = intval($_REQUEST['time']); } else { $time = ''; } if ( isset($_REQUEST['mod']) ) { $mod_id = intval($_REQUEST['mod']); } else { $mod_id = ''; } $all = ($_REQUEST['all'] == 'on') ? TRUE : FALSE; // Возможны нотисы с $REQUEST['all'], уверен у вас хватит сил справится с ними // Read Only by Nightmare # #-----[ FIND ]------------------------------------------ # default: bb_die('invalid action'); break; # #-----[ BEFORE, ADD ]------------------------------------------ # //readonly mode by Nightmare case 'readonly' : $endtime = time()+($time*60*60); //seconds if ($all) $forum_id = 0; $sql = "SELECT user_id FROM " . READONLY_TABLE . " WHERE user_id = ". $ro_user_id ." AND (forum_id = ".$forum_id." OR forum_id = 0) AND (endtime > ".time()." OR endtime = 0)"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get Read Only information for this user', '', __LINE__, __FILE__, $sql); } $ro_row = $db->sql_fetchrow($result); if ( !empty($ro_row['user_id']) ) { // if ( $ro_row['forum_id'] == 0 ) $forum_id = 0; $sql = "DELETE FROM ".READONLY_TABLE." WHERE user_id = ".$ro_user_id." AND forum_id = ".$forum_id; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not delete Read Only information', '', __LINE__, __FILE__, $sql); } } else { $sql = "INSERT INTO ".READONLY_TABLE." (user_id, forum_id, endtime, mod_id) VALUES (".$ro_user_id.", ".$forum_id.", ".$endtime.", ".$mod_id.")"; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not add Read Only information', '', __LINE__, __FILE__, $sql); } $forum_row = $db->sql_fetchrow($result); if ($forum_id==0){$forums_txt="во всех форумах" ;} else {$sql = "SELECT forum_name FROM " . FORUMS_TABLE . " WHERE forum_id = ". $forum_id ." LIMIT 1"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not get forums information', '', __LINE__, __FILE__, $sql); } $forums_txt = "в форуме <b><a href=\"viewforum.php?f=".$forum_id."\">".$forum_row['forum_name']."</a></b>";} $tz = get_userdata($ro_user_id); $user_from = $mod_id; $user_to = $ro_user_id; $subject = 'Уведомление о включении режима "Только Чтение"'; $message ='Здравствуйте, вам был включен режим "Только Чтение" '.$forums_txt.' за данное <b><a href="viewtopic.php?p='.$post_id.'#'.$post_id.'">сообщение</a></b>.<br>В данном режиме вы не имеете возможности писать сообщения, а только просматривать темы в данном форуме<br> Режим включен до '. create_date("d.m.Y H:i", $endtime, $tz['user_timezone']) .''; // не стал использовать $langs для ЛС $id_mess = send_pm($subject, $message, $user_from, $user_to); // Send e-mail notification $script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($bb_cfg['script_path'])); $script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx; $server_name = trim($bb_cfg['server_name']); $server_protocol = ( $bb_cfg['cookie_secure'] ) ? 'https://' : 'http://'; $server_port = ( $bb_cfg['server_port'] <> 80 ) ? ':' . trim($bb_cfg['server_port']) . '/' : '/'; $to_userdata = get_userdata($ro_user_id); include($phpbb_root_path . 'includes/emailer.'.$phpEx); $emailer = new emailer($bb_cfg['smtp_delivery']); $emailer->from($bb_cfg['board_email']); $emailer->replyto($bb_cfg['board_email']); $emailer->use_template('privmsg_notify', $to_userdata['user_lang']); $emailer->email_address($to_userdata['user_email']); $emailer->set_subject($lang['NOTIFICATION_SUBJECT']); $emailer->assign_vars(array( 'USERNAME' => stripslashes($to_userdata['username']), 'NAME_FROM' => $userdata['username'], 'MSG_SUBJECT' => stripslashes($privmsg_subject), 'SITENAME' => $bb_cfg['sitename'], 'EMAIL_SIG' => (!empty($bb_cfg['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $bb_cfg['board_email_sig']) : '', 'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox&mode=read&p=' . $id_mess) ); $emailer->send(); $emailer->reset(); } redirect("viewtopic.$phpEx?p=$post_id#$post_id"); break; // readonly mode by Nightmare # #-----[ OPEN ]------------------------------------------ # templates/default/viewtopic.tpl # #-----[ FIND ]------------------------------------------ # </script> <!-- ENDIF / SPLIT_FORM --> # #-----[ AFTER, ADD ]------------------------------------------ # <script type-"text/javascript"> $(document).ready(function (){ $('div.ro-parent').toggle(function(){ $(this).parent().children('div.ro-child').slideDown(500); }, function(){ $(this).parent().children('div.ro-child').slideUp("SLOW"); }); }); </script> # #-----[ FIND ]------------------------------------------ # <!-- IF postrow.POSTER_FROM_FLAG --><p class="flag">{postrow.POSTER_FROM_FLAG}</p><!-- ENDIF --> <!-- ENDIF --> # #-----[ AFTER, ADD ]------------------------------------------ # <!-- READONLY BY NIGHTMARE --> {postrow.POSTER_READONLY} <!-- READONLY BY NIGHTMARE --> # #-----[ OPEN ]------------------------------------------ # viewtopic.php # #-----[ FIND ]------------------------------------------ # // Auth check $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $t_data); # #-----[ AFTER, ADD ]------------------------------------------ # // Read Only by Nightmare if (!(IS_ADMIN)) { get_user_readonly ($userdata['user_id'], $forum_id); } // Read Only by Nightmare # #-----[ FIND ]------------------------------------------ # $l_edited_by = ''; } # #-----[ AFTER, ADD ]------------------------------------------ # // Read Only by Nightmare $sql = "SELECT * FROM ".READONLY_TABLE." WHERE user_id = ".$poster_id." AND (forum_id = ".$forum_id." OR forum_id = 0) AND (endtime > ".time()." OR endtime = 0)"; if ( !($result2 = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not get Read Only information", '', __LINE__, __FILE__, $sql); } $rorow = $db->sql_fetchrow($result2); if ( !empty($rorow['user_id']) && ($rorow['forum_id'] == 0 || $rorow['forum_id'] = $forum_id) ) { $langreadonly = $lang['del_readonly']; $readonly = true; } else { $langreadonly = $lang['add_readonly']; $readonly = false; } // if you haven't LESS_ADMIN, delete && ($postrow[$i]['user_level'] != LESS_ADMIN) if ( $is_auth['auth_mod'] && ($postrow[$i]['user_level'] != ADMIN) && ($postrow[$i]['user_level'] != MOD) && ($userdata['user_id'] != $poster_id) && ($poster_id != BOT_UID) ) { $poster_readonly = '<div><div align="center" style="border:1px solid #DEDEDE;background-color:#FFFFFF;padding:5px;padding-bottom:-5px;margin-left:-2px;margin-right:-2px;cursor:pointer;" class="ro-parent" title="Нажмите для того чтобы открыть опции режима Только Чтение"> <form action="modcp.php" method=get> <input type="hidden" name="mode" value="readonly" /> <input type="hidden" name="f" value="'.$forum_id.'" /> <input type="hidden" name="user" value="'.$poster_id.'" /> <input type="hidden" name="p" value="'.$postrow[$i]['post_id'].'" /> <input type="hidden" name="sid" value="'.$userdata['session_id'].'" /> <input type="hidden" name="mod" value="'.$userdata['user_id'].'" /> '.$lang['readonly'].' </div><div style="display:none;border:1px solid #DEDEDE;border-top:none;background-color:#FFFFFF;padding:5px;padding-bottom:-5px;margin-left:-2px;margin-right:-2px;" class="ro-child">'; if (!$readonly) { if ( IS_ADMIN ) $poster_readonly.=$lang['ro_in_all'].'<input type="checkbox" name="all" checked /><br />'; $poster_readonly.='<input type="text" name="time" value="1" size=3 /> '.$lang['HOURS']; } elseif ( $rorow['forum_id'] == 0 ) { $poster_readonly.= '<input type="hidden" name="all" value="on" />'; } $poster_readonly.=' <input type="submit" name="submit" value=\''.$langreadonly.'\' /></form></div></div>'; } else { $poster_readonly = ''; } // Read Only by Nightmare # #-----[ FIND ]------------------------------------------ # 'POSTER_AVATAR' => $poster_avatar, # #-----[ AFTER, ADD ]------------------------------------------ # 'POSTER_READONLY' => $poster_readonly, // Read Only by Nightmare # #-----[ FIND ]------------------------------------------ # $new_topic_url = ( $t_data['forum_status'] == FORUM_LOCKED ) ? "" : "posting.$phpEx?mode=newtopic&f=$forum_id"; # #-----[ REPLACE ]------------------------------------------ # $new_topic_url = ( $t_data['forum_status'] == FORUM_LOCKED || !$is_auth['auth_post'] ) ? "" : "posting.$phpEx?mode=newtopic&f=$forum_id"; # #-----[ FIND ]------------------------------------------ # $reply_topic_url = ( $t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED ) ? "" : "posting.$phpEx?mode=reply&t=$topic_id"; # #-----[ REPLACE ]------------------------------------------ # $reply_topic_url = ( $t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED || !$is_auth['auth_reply'] ) ? "" : "posting.$phpEx?mode=reply&t=$topic_id"; # #-----[ FIND ]------------------------------------------ # $reply_img = ( $t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new']; $reply_alt = ( $t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED ) ? $lang['TOPIC_LOCKED_SHORT'] : $lang['REPLY_TO_TOPIC']; # #-----[ REPLACE ]------------------------------------------ # $reply_img = ( $t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED || !$is_auth['auth_reply'] ) ? $images['reply_locked'] : $images['reply_new']; $reply_alt = ( $t_data['forum_status'] == FORUM_LOCKED || $t_data['topic_status'] == TOPIC_LOCKED || !$is_auth['auth_reply']) ? $lang['TOPIC_LOCKED_SHORT'] : $lang['REPLY_TO_TOPIC']; # #-----[ OPEN ]------------------------------------------ # viewforum.php # #-----[ FIND ]------------------------------------------ # // Auth $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_data); $moderation = (!empty($_REQUEST['mod']) && $is_auth['auth_mod']); # #-----[ AFTER, ADD ]------------------------------------------ # // Read Only by Nightmare if (!(IS_ADMIN)) { get_user_readonly ($userdata['user_id'], $forum_id); } // Read Only by Nightmare # #-----[ FIND ]------------------------------------------ # $post_new_topic_url = "posting.$phpEx?mode=newtopic&f=$forum_id"; # #-----[ REPLACE ]------------------------------------------ # $post_new_topic_url =(!$is_auth['auth_post']) ? "" : "posting.$phpEx?mode=newtopic&f=$forum_id"; # #-----[ FIND ]------------------------------------------ # 'T_POST_NEW_TOPIC' => ($forum_data['forum_status'] == FORUM_LOCKED) ? $lang['FORUM_LOCKED'] : $lang['POST_NEW_TOPIC'], # #-----[ REPLACE ]------------------------------------------ # 'T_POST_NEW_TOPIC' => ($forum_data['forum_status'] == FORUM_LOCKED || !$is_auth['auth_post']) ? $lang['FORUM_LOCKED'] : $lang['POST_NEW_TOPIC'], # #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ # # EoM |
Автор: | mxcmnewyywnl [ 2012-03-15 19:11 ] |
Заголовок сообщения: | |
Как решить ошибку Код: PHP Notice: Undefined variable: privmsg_subject in /home/tlab/domains/мой адрес/public_html/forum/modcp.php on line 866 Код: 'MSG_SUBJECT' => stripslashes($privmsg_subject),
|
Автор: | Romanuy [ 2012-03-19 18:44 ] |
Заголовок сообщения: | |
Данному моду явно не хватает пару аддонов это вывод в виевтопик какой режим у пользователя и историю режимов как на картинках |
Страница 1 из 1 | Часовой пояс: UTC + 3 часа |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |