Webmaster общности: Predpriemach.com | SearchEngines.bg

    Минимум мнения за влизане в форум

    Автор: ProGame

    Минимум мнения за влизане в форум
    1-во проверих и няма такъв урок
    има урок за Минимум мнения за пускане на нова тема
    и 2-та уроци работят заедно!

    С този урок Ще можете да слагате лимит на мнения на потребители за да влизат в някои от форумите ви!

    Преди да започнем и със самия урок трябва да създадем един файл db_update.php

    db_update.php

    <?php
    /***************************************************************************
    * db_update.php
    * -------------------
    *
    * copyright : ©2007 ProGame
    * Website : http://help.headoff.com
    *
    ***************************************************************************/
    
    /***************************************************************************
    *
    * 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.
    *
    ***************************************************************************/
    
    define('IN_PHPBB', true);
    $phpbb_root_path = './';
    include($phpbb_root_path . 'extension.inc');
    include($phpbb_root_path . 'common.'.$phpEx);
    
    //
    // Start session management
    //
    $userdata = session_pagestart($user_ip, PAGE_INDEX);
    init_userprefs($userdata);
    //
    // End session management
    //
    
    
    if( !$userdata['session_logged_in'] )
    {
    $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
    header($header_location . append_sid("login.$phpEx?redirect=db_update.$phpEx", true));
    exit;
    }
    
    if( $userdata['user_level'] != ADMIN )
    {
    message_die(GENERAL_MESSAGE, 'You are not authorised to access this page');
    }
    
    
    $page_title = 'Updating the database';
    include($phpbb_root_path . 'includes/page_header.'.$phpEx);
    
    echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';
    echo '<tr><th>Updating the database</th></tr><tr><td><span class="genmed"><ul type="circle">';
    
    
    $sql = array();
    $sql[] = "ALTER TABLE " . $table_prefix . "forums ADD forum_enter_limit MEDIUMINT(8) unsigned default '0'";
    
    for( $i = 0; $i < count($sql); $i++ )
    {
    if( !$result = $db->sql_query ($sql[$i]) )
    {
    $error = $db->sql_error();
    
    echo '<li>' . $sql[$i] . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />';
    }
    else
    {
    echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>Successfull</b></font></li><br />';
    }
    }
    
    
    echo '</ul></span></td></tr><tr><td class="catBottom" height="28"> </td></tr>';
    
    echo '<tr><th>End</th></tr><tr><td><span class="genmed">Installation is now finished. Please be sure to delete this file now.<br />If you have run into any errors, please visit the <a href="http://www.phpbbsupport.co.uk" target="_phpbbsupport">phpBBSupport.co.uk</a> and ask someone for help.</span></td></tr>';
    echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">Have a nice day</a></span></td></table>';
    
    include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
    
    ?>

    след като сложито този код в файла стартирайте го … след ако всичко е минало добре го изтрийте !
    за тези който незнаят файла служи за промени в базата данни вместо за ръчкате из phpmyadmin направо файла си върши работата !

    след това

    #
    #-----[ Отваряте ]------------------------------------------
    #
    
    viewforum.php
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    //
    // Grab all the basic data (all topics except announcements)
    // for this forum
    //
    
    #
    #-----[ преди него добавяте ]------------------------------------------
    #
    
    //
    // forum enter limit by ProGame
    //
    if (!($userdata['user_level'] == ADMIN OR $userdata['user_level'] == MOD))
    {
    $sql = "SELECT f.forum_id, f.forum_enter_limit, u.user_posts
    FROM " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
    WHERE user_id = " . $userdata['user_id'];
    
    if( !($result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query information', '', __LINE__, __FILE__, $sql);
    }
    
    while ($row = $db->sql_fetchrow($result))
    {
    $forum_id_limit = $row['forum_id'];
    $forum_enter_limit = $row['forum_enter_limit'];
    $user_posts_limit = $row['user_posts'];
    
    $error_limit = sprintf($lang['Forum_enter_limit_error'], $forum_enter_limit);
    
    if ($forum_id == $forum_id_limit AND $user_posts_limit < $forum_enter_limit)
    {
    message_die(GENERAL_ERROR, $error_limit);
    }
    }
    }
    //
    // forum enter limit by ProGame
    //
    
    #
    #-----[ Отваряте ]------------------------------------------
    #
    
    viewtopic.php
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    //
    // Go ahead and pull all data for this topic
    //
    
    #
    #----[ преди него добавяте ]------------------------------------------
    #
    
    //
    // forum enter limit by ProGame
    //
    if (!($userdata['user_level'] == ADMIN OR $userdata['user_level'] == MOD))
    {
    $sql = "SELECT f.forum_id, f.forum_enter_limit, u.user_posts
    FROM " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
    WHERE user_id = " . $userdata['user_id'];
    
    if( !($result = $db->sql_query($sql)) )
    {
    message_die(GENERAL_ERROR, 'Could not query information', '', __LINE__, __FILE__, $sql);
    }
    
    while ($row = $db->sql_fetchrow($result))
    {
    $forum_id_limit = $row['forum_id'];
    $forum_enter_limit = $row['forum_enter_limit'];
    $user_posts_limit = $row['user_posts'];
    
    $error_limit = sprintf($lang['Forum_enter_limit_error'], $forum_enter_limit);
    
    if ($forum_id == $forum_id_limit AND $user_posts_limit < $forum_enter_limit)
    {
    message_die(GENERAL_ERROR, $error_limit);
    }
    }
    }
    //
    // forum enter limit by ProGame
    //
    
    
    #
    #-----[ Отваряте ]------------------------------------------
    #
    
    admin/admin_forums.php
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    $forumstatus = $row['forum_status'];
    
    #
    #----[ След него добавяте ]------------------------------------------
    #
    
    $forum_enter_limit = $row['forum_enter_limit'];
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    $forumstatus = FORUM_UNLOCKED;
    
    #
    #----[ След него добавяте ]------------------------------------------
    #
    
    $forum_enter_limit = '';
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    'FORUM_NAME' => $forumname,
    
    #
    #----[ След него добавяте ]------------------------------------------
    #
    
    'FORUM_ENTER_LIMIT' => $forum_enter_limit,
    'L_FORUM_ENTER_LIMIT' => $lang['Forum_enter_limit'],
    
    #
    #-----[ Намирате ]--------------------------------------------
    #
    $sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
    VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
    
    #
    #-----[ На линията намирате ]------------------------------------
    #
    , forum_status
    
    #
    #-----[ След него добавяте ]--------------------------------------
    #
    
    , forum_enter_limit
    
    #
    #-----[ На линията намирате ]------------------------------------
    #
    , " . intval($HTTP_POST_VARS['forumstatus']) . "
    
    #
    #-----[ След него добавяте ]--------------------------------------
    #
    
    , " . intval($HTTP_POST_VARS['forum_enter_limit']) . "
    
    #
    #-----[ Намирате ]--------------------------------------------
    #
    $sql = "UPDATE " . FORUMS_TABLE . "
    SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
    
    #
    #-----[ На линията намирате ]------------------------------------
    #
    , forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . "
    
    #
    #-----[ След него добавяте ]--------------------------------------
    #
    
    , forum_enter_limit = " . intval($HTTP_POST_VARS['forum_enter_limit']) . "
    
    #
    #-----[ Отваряте ]------------------------------------------
    #
    
    language/lang_english/lang_main.php
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    ?>
    
    #
    #----[ След него добавяте ]------------------------------------------
    #
    
    $lang['Forum_enter_limit'] = 'Минимум мнения за влизане в форума';
    $lang['Forum_enter_limit_error'] = 'За да влезнете в този форум трябва да имате минимум <b>%d</b> мнения.';
    #
    #-----[ Отваряте ]------------------------------------------
    #
    
    templates/subSilver/admin/forum_edit_body.tpl
    
    #
    #----[ Намирате ]------------------------------------------
    #
    
    <tr>
    <td class="row1">{L_FORUM_STATUS}</td>
    <td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
    </tr>
    
    #
    #----[ След него добавяте ]------------------------------------------
    #
    
    <tr>
    <td class="row1">{L_FORUM_ENTER_LIMIT}</td>
    <td class="row2"><input type="text" name="forum_enter_limit" value="{FORUM_ENTER_LIMIT}" size="10" maxlength="8" /></td>
    </tr>
    
    #
    #-----[ Запазвате всички фаилове и е готово!:) ]------------------------------------------

    Оставете коментар