Tuesday, June 28, 2016

Hack mod cho Nukeviet và PHPBB


 1. Chuẩn bị: cài IIS (hay Apache,..), PHP, MySQL và install 1 Forums PHPBB.
2. Nguyên tắc: Hack 1 MOD có nghĩa gì? Có nghĩa bạn thực hiện thêm/bớt hoặc thay đổi nội dung hiện tại của PHPBB ở 1 số file nào đó để cuối cùng được kết quả là tính năng mới mà bạn mong muốn. Việc thay đổi này liên quan đến 2 vấn đề là giao diện và Code. PHPBB tổ chức theo nguyên tắc sau: 1 Modules Code (có thể gồm nhiều file .php) lo việc kết nối dữ liệu, tương tác người dùng và cuối cùng trả dữ liệu về các biến (nào đó được đặt tên khá dễ nhớ, mà các biến này sẽ được gọi ở Modules hiển thị); 1 Modules giao diện (dễ thực hiện hơn do bạn có thể xài FrontPage để thiết kế bằng cách kéo thả trực quan), modules này cũng có thể gồm 1 hoặc nhiều file, nó thể hiện thông tin cho người dùng nhìn thấy bằng cách nhận dữ liệu từ Modules Code truyền đến.
Khi hiểu điều này bạn mới có thể đọc hiểu cách Hack 1 MOD (có sẵn) và làm tốt nó; từ đó bạn mới tự Hack MOD do chính bạn nghĩ ra.
3. Thực hành: Cách hack 1 MOD đơn giản - Quick Reply với các hướng dẫn cụ thể từng bước.
- Bạn có thể download cách hack MOD này từ phphack hoặc ở dưới đây.

a. Bạn cần mở file install.txt để đọc và thực hiện theo các bước trong ni.
b. Phần đầu thường giới thiệu MOD và nói đến các file cần Hack, các file cần thêm vào và cả độ khó. (MOD Quick Reply có độ khó thấp "Very Easy", cần chỉnh sửa các file có sẵn sau: viewtopic.php, language/lang_english/lang_main.php, templates/subSilver/viewtopic_body.tpl và cần copy các file sau (Include - các file thêm vào, mã các file này được viết sẵn, các bạn chỉ cần copy vào vị trí đúng như hướng dẫn).
c. #-----[ COPY ]------------------------------------------
Bạn cần copy các file sau (có đi kèm) vào các thư mục như hướng dẫn
copy quick_reply.php to / <== vào thư mục gốc của forum
copy quick_reply.tpl to templates/subSilver <== vào thư mục Giao diện của Forum (lưu ý: bạn cần chép vào templates mà bạn đang chạy thay vì subSilver (măc định) nếu bạn không chạy Templates mặc định.
Ý nghĩa: quick_reply.php là Modules Code; file này chứa các đoạn kết nối dữ liệu, tính toán các trường hợp và gán giá trị cho các biến (sẽ dùng ở Modules Giao diện), bạn có thể mở file và nghiên cứu:
QUOTE
<?php 
/***************************************************************************
*                              quick_reply.php
*                            -------------------
*   begin                : Tuesday, Aug 20, 2015
*   copyright            : RustyDragon 
*   original work by     : Smartor <smartor_xp@hotmail.com>
*   contact              : <dev@RustyDragon.com>, http://www.RustyDragon.com
*   $Id: quick_reply.php,v 1.4.1.1 2015/11/18 13:35:54 RustyDragon 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.
*
***************************************************************************/


//
// BEGIN OUTPUT
//

$phpbb_root_path = "modules/Forums/";

if($HTTP_GET_VARS['mode'] == 'smilies') 
{
        define('IN_PHPBB', true);
        include($phpbb_root_path . 'extension.inc');
        include($phpbb_root_path . 'common.'.$phpEx);
        include('includes/functions_post.'.$phpEx);
        generate_smilies('window', PAGE_POSTING);
        exit;
}

if ( !defined('IN_PHPBB') )
{
        die('Hacking attempt1');
}

$template->set_filenames(array(
        'quick_reply_output' => 'quick_reply.tpl')
);
        

if ( !(((!$is_auth['auth_reply']) or 
($forum_topic_data['forum_status'] == FORUM_LOCKED) or 
($forum_topic_data['topic_status'] == TOPIC_LOCKED)) and ($userdata['user_level'] != ADMIN)))
{
        $bbcode_uid = $postrow[$total_posts - 1]['bbcode_uid'];
        $last_poster = $postrow[$total_posts - 1]['username'];
        $last_msg = $postrow[$total_posts - 1]['post_text'];
        $last_msg = str_replace(":1:$bbcode_uid", '', $last_msg);
        $last_msg = str_replace(":$bbcode_uid", '', $last_msg);        
        $last_msg = str_replace("'", ''', $last_msg);
        $last_msg = "[quocte=\"$last_poster\"]" . $last_msg . '[/quocte]';
        $attach_sig = (( $userdata['session_logged_in'] ) ? $userdata['user_attachsig'] : 0)?"checked='checked'":'';
        $notify_user = (( $userdata['session_logged_in'] ) ? $userdata['user_notify'] : 0)?"checked='checked'":'';
        
        $template->assign_block_vars('quick_reply', array(
                'POST_ACTION' => append_sid("posting.$phpEx"),
                'TOPIC_ID' => $topic_id,
                'SID' => $userdata['session_id'],
                'LAST_MESSAGE' => $last_msg)
        );

        if( $userdata['session_logged_in'])
        {
                $template->assign_block_vars('quick_reply.user_logged_in', array(
                        'ATTACH_SIGNATURE' => $attach_sig,
                        'NOTIFY_ON_REPLY' => $notify_user)
                );
        }else
        {
                $template->assign_block_vars('quick_reply.user_logged_out', array());
        }


        generate_smilies_row();

        $template->assign_vars(array(
                'U_MORE_SMILIES' => append_sid("quick_reply.$phpEx?mode=smilies"),
                'L_USERNAME' => $lang['Username'],
                'L_PREVIEW' => $lang['Preview'],
                'L_OPTIONS' => $lang['Options'],
                'L_SUBMIT' => $lang['Submit'],
                'L_CANCEL' => $lang['Cancel'],
                'L_ATTACH_SIGNATURE' => $lang['Attach_signature'], 
                'L_NOTIFY_ON_REPLY' => $lang['Notify'],
                'L_NOTIFY_ON_REPLY' => $lang['Notify'],
                'L_ATTACH_SIGNATURE' => $lang['Attach_signature'],
                'L_ALL_SMILIES' => $lang['Quick_Reply_smilies'],
                'L_QUOTE_SELECTED' => $lang['QuoteSelelected'],
                'L_NO_TEXT_SELECTED' => $lang['QuoteSelelectedEmpty'],
                'L_EMPTY_MESSAGE' => $lang['Empty_message'],
                'L_QUOTE_LAST_MESSAGE' => $lang['Quick_quote'],
                'L_QUICK_REPLY' => $lang['Quick_Reply'],
                'L_PREVIEW' => $lang['Preview'],
                'L_SUBMIT' => $lang['Submit'])
);
}
$template->assign_var_from_handle('QUICKREPLY_OUTPUT', 'quick_reply_output');
        
function generate_smilies_row()
{
        global $db, $board_config, $template;

        $max_smilies = 24;

        switch ( SQL_LAYER )
        {
                case 'mssql':
                        $sql = 'SELECT TOP ' . $max_smilies . ' min(emoticon) AS emoticon,
                        min(code) AS code, smile_url
                        FROM ' . SMILIES_TABLE . ' 
                        GROUP BY [smile_url]';
                break;

                default:
                        $sql = 'SELECT emoticon, code, smile_url
                        FROM ' . SMILIES_TABLE . ' 
                        GROUP BY smile_url
                        ORDER BY smilies_id LIMIT ' . $max_smilies;
                break;
        }
        if (!$result = $db->sql_query($sql))
        {
                message_die(GENERAL_ERROR, "Couldn't retrieve smilies list", '', __LINE__, __FILE__, $sql);
        }
        $smilies_count = $db->sql_numrows($result);
        $smilies_data = $db->sql_fetchrowset($result);
        for ($i = 0; $i < $smilies_count; $i++)
        {
                        $template->assign_block_vars('quick_reply.smilies', array(
                                'CODE' => $smilies_data[$i]['code'],
                                'URL' => $board_config['smilies_path'] . '/' . $smilies_data[$i]['smile_url'],
                                'DESC' => $smilies_data[$i]['emoticon'])
                        );
        }
}
?>

Hack mod cho Nukeviet và PHPBB Rating: 4.5 Diposkan Oleh: Mã giảm giá