ติดต่อลงโฆษณา [email protected]

แสดงกระทู้

ส่วนนี้จะช่วยให้คุณสามารถดูกระทู้ทั้งหมดสมาชิกนี้ โปรดทราบว่าคุณสามารถเห็นเฉพาะกระทู้ในพื้นที่ที่คุณเข้าถึงในขณะนี้


แสดงหัวข้อ - bomb_006

หน้า: [1]
1
ใครเก่งด้าน smf ช่วยผมแก้หน่อยคับ
คือต้องการให้ผู้ใช้ป้อน username และ password ที่สมัครไว้จากหน้า homepage และเมื่อผู้ใช้กดปุ่ม login ก็จะเข้าสู่บอร์ด smf พร้อมใช้งานบอร์ด (login ชื่อสมาชิกให้โดยอัตโนมัติ)

โค้ดที่ผมแก้นะคับ index.php
โค้ด: [เลือก]
<?php
/**********************************************************************************
* index.php                                                                       *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel ([email protected])                    *
* =============================================================================== *
* Software Version:           SMF 1.1.5                                           *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
* Support, News, Updates at:  http://www.simplemachines.org                       *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/


/* This, as you have probably guessed, is the crux on which SMF functions.
Everything should start here, so all the setup and security is done
properly.  The most interesting part of this file is the action array in
the smf_main() function.  It is formatted as so:

'action-in-url' => array('Source-File.php', 'FunctionToCall'),

Then, you can access the FunctionToCall() function from Source-File.php
with the URL index.php?action=action-in-url.  Relatively simple, no?
*/

$forum_version 'SMF 1.1.5';

// Get everything started up...
define('SMF'1);
@
set_magic_quotes_runtime(0);
error_reporting(E_ALL);
$time_start microtime();

// Make sure some things simply do not exist.
foreach (array('db_character_set') as $variable)
if (isset($GLOBALS[$variable]))
unset($GLOBALS[$variable]);

########## Maintenance ##########
# Note: If $maintenance is set to 2, the forum will be unusable!  Change it to 0 to fix it.
$maintenance 0; # Set to 1 to enable Maintenance Mode, 2 to make the forum untouchable. (you'll have to make it 0 again manually!)
$mtitle 'Maintenance Mode'; # Title for the Maintenance Mode message.
$mmessage 'Okay faithful users...we\'re attempting to restore an older backup of the database...news will be posted once we\'re back!'; # Description of why the forum is in maintenance mode.

########## Forum Info ##########
$mbname '-== Mororwor Board ==-'; # The name of your forum.
$language 'thai'; # The default language file set for the forum.
$boardurl 'http://localhost/board'; # URL to your forum's folder. (without the trailing /!)
$webmaster_email '[email protected]'; # Email address to send emails from. (like [email protected].)
$cookiename 'SMFCookie956'; # Name of the cookie to set for authentication.

########## Database Info ##########
$db_server 'localhost';
$db_name 'smf';
$db_user 'root';
$db_passwd '12345';
$db_prefix 'smf_';
$db_persist 0;
$db_error_send 1;

########## Directories/Files ##########
# Note: These directories do not have to be changed unless you move things.
$boarddir 'C:\\AppServ\\www\\board'; # The absolute path to the forum's folder. (not just '.'!)
$sourcedir 'C:\\AppServ\\www\\board/Sources'; # Path to the Sources directory.

########## Error-Catching ##########
# Note: You shouldn't touch these settings.
$db_last_error 0;


# Make sure the paths are correct... at least try to fix them.
if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
$boarddir dirname(__FILE__);
if (!
file_exists($sourcedir) && file_exists($boarddir '/Sources'))
$sourcedir $boarddir '/Sources';

// And important includes.
require_once($sourcedir '/QueryString.php');
require_once(
$sourcedir '/Subs.php');
require_once(
$sourcedir '/Load.php');
require_once(
$sourcedir '/Security.php');

// Using an old version of PHP?
if (@version_compare(PHP_VERSION'4.2.3') != 1)
require_once($sourcedir '/Subs-Compat.php');

// If $maintenance is set specifically to 2, then we're upgrading or something.
if (!empty($maintenance) && $maintenance == 2)
db_fatal_error();

// Connect to the MySQL database.
if (empty($db_persist))
$db_connection = @mysql_connect($db_server$db_user$db_passwd);
else
$db_connection = @mysql_pconnect($db_server$db_user$db_passwd);

// Show an error if the connection couldn't be made.
if (!$db_connection || !@mysql_select_db($db_name$db_connection))
db_fatal_error();

// Load the settings from the settings table, and perform operations like optimizing.
reloadSettings();
// Clean the request variables, add slashes, etc.
cleanRequest();
$context = array();

// Seed the random generator for PHP < 4.2.0.
if (@version_compare(PHP_VERSION'4.2.0') == -1)
smf_seed_generator();

// Determine if this is using WAP, WAP2, or imode.  Technically, we should check that wap comes before application/xhtml or text/html, but this doesn't work in practice as much as it should.
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml') !== false)
$_REQUEST['wap2'] = 1;
elseif (isset(
$_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false)
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'DoCoMo/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'portalmmm/') !== false)
$_REQUEST['imode'] = 1;
else
$_REQUEST['wap'] = 1;
}

if (!
defined('WIRELESS'))
define('WIRELESS', isset($_REQUEST['wap']) || isset($_REQUEST['wap2']) || isset($_REQUEST['imode']));

// Some settings and headers are different for wireless protocols.
if (WIRELESS)
{
define('WIRELESS_PROTOCOL', isset($_REQUEST['wap']) ? 'wap' : (isset($_REQUEST['wap2']) ? 'wap2' : (isset($_REQUEST['imode']) ? 'imode' '')));

// Some cellphones can't handle output compression...
$modSettings['enableCompressedOutput'] = '0';
// !!! Do we want these hard coded?
$modSettings['defaultMaxMessages'] = 5;
$modSettings['defaultMaxTopics'] = 9;

// Wireless protocol header.
if (WIRELESS_PROTOCOL == 'wap')
header('Content-Type: text/vnd.wap.wml');
}

// Check if compressed output is enabled, supported, and not already being done.
if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0)
{
// If zlib is being used, turn off output compression.
if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler' || @version_compare(PHP_VERSION'4.2.0') == -1)
$modSettings['enableCompressedOutput'] = '0';
else
ob_start('ob_gzhandler');
}
// This makes it so headers can be sent!
if (empty($modSettings['enableCompressedOutput']))
ob_start();

// Register an error handler.
set_error_handler('error_handler');

// Start the session. (assuming it hasn't already been.)
loadSession();

// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

// Call obExit specially; we're coming from the main area ;).
obExit(nullnulltrue);

// The main controlling function.
function smf_main()
{
global $modSettings$settings$user_info$board$topic$maintenance$sourcedir;

// Special case: session keep-alive.
if (isset($_GET['action']) && $_GET['action'] == 'keepalive')
die;

// Load the user's cookie (or set as guest) and load their settings.
loadUserSettings();

// Load the current board's information.
loadBoard();

// Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
loadTheme();

// Check if the user should be disallowed access.
is_not_banned();

// Load the current user's permissions.
loadPermissions();


// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum'))
{
// You can only login.... otherwise, you're getting the "maintenance mode" display.
if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout'))
{
require_once($sourcedir '/LogInOut.php');
return $_REQUEST['action'] == 'login2' 'Login2' 'Logout';
}
// Don't even try it, sonny.
else
{
require_once($sourcedir '/Subs-Auth.php');
return 'InMaintenance';
}
}



// Get the function and file to include - if it's not there, do the board index.
if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']]))
{
// Catch the action with the theme?
if (!empty($settings['catch_action']))
{
require_once($sourcedir '/Themes.php');
return 'WrapAction';
}

// Fall through to the board index then...
require_once($sourcedir '/BoardIndex.php');
return 'BoardIndex';
}

// Otherwise, it was set - so let's go to that action.
require_once($sourcedir '/' $actionArray[$_REQUEST['action']][0]);
return $actionArray[$_REQUEST['action']][1];
}

?>

ปัญหาที่ผมตอนนี้คือโค้ดข้างบนเป็นโค้ดที่ผม copy มาจากหน้า index.php แล้วต้องการนำมาดัดแปลงให้เหลือ  แค่ช่องกรอก username และ password  แล้วก็สามารถตรวจสอบได้ว่าชื่อผู้ใช้งานมีใน database ของ board smf หรือไม่รวมทั้ง password ถ้ากรอกผิดก็ให้แสดง error message ขึ้นมาอ่ะคับ  ควรตัดตรงไหนออกอีกดีคับ

ปัญหาที่ทำให้ลบหลายๆอันออกไม่ได้  เพราะว่าหน้า index.php จะเรียกใช้งานโค้ดจาก template อีกทีทำให้มันต้องอ้างถึงมากมาย  รวมทั้งมันจะมีเกี่ยวกับการตรวจสอบหัวข้อ topic มาเกี่ยวข้องทำให้ผมสับสนไปหมดแล้วคับ  55+  ใครเก่งๆช่วยทีคับ  อ่าน code php จนลายตาไปหมดแล้วคับ

ฝากด้วยนะคับ    :'( :'(  ขอบคุณล่วงหน้างับ    :D :D ;D

หน้า: [1]