[外掛問題] 狀態列訊息+時間plus0.3 加強版(已解決,也釋放在竹
版主: 版主管理群
[外掛問題] 狀態列訊息+時間plus0.3 加強版(已解決,也釋放在竹
我做的狀態列訊息+時間plus0.3 beta時後台,
我現在想把狀態列訊息+時間自己有一個頁面專是改他,
但是我改了很久到改不到,
改了之後又不懂輸出@@~
我現在想把狀態列訊息+時間自己有一個頁面專是改他,
但是我改了很久到改不到,
改了之後又不懂輸出@@~
最後由 *tytsim* 於 2005-08-12 13:35 編輯,總共編輯了 1 次。
如果我沒有記錯的話....
如果你要再後台有一個專門的頁面(就是左邊有超連結)的話\r
你的檔案名稱要是 "admin_" 開頭的,而且檔案的撰寫有些規範
你可以隨意打開某檔案來看看,例如
其中的
General代表的是再左邊的哪一個區塊
Configuration帶表示的她的名稱 (型態是字串)
如果你要再後台有一個專門的頁面(就是左邊有超連結)的話\r
你的檔案名稱要是 "admin_" 開頭的,而且檔案的撰寫有些規範
你可以隨意打開某檔案來看看,例如
代碼: 選擇全部
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
$file = basename(__FILE__);
$module['General']['Configuration'] = "$file";
return;
}代碼: 選擇全部
$module['General']['Configuration'] = "$file";Configuration帶表示的她的名稱 (型態是字串)
那你這外掛是怎樣寫的.....*tytsim* 寫:改了之後又不懂輸出@@~
-.-
我是說:
admin_times_mod.php
admin_times_mod.php
代碼: 選擇全部
<?php
/***************************************************************************
* admin_times_mod.php
* --------------------
* begin : tytsim, 2005
* copyright : (C) 2005
* email : tytsim@gmail.com
*
*
*
*
***************************************************************************/
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
$file = basename(__FILE__);
$module['General']['Times_mod'] = "$file";
return;
}
//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
if ( $_POST['submit'] )
{
$times_mod_times = $_POST['times_mod_times'];
$times_mod_welcome_message = $_POST['times_mod_welcome_message'];
$sql = "UPDATE " . CONFIG_TABLE . " SET
config_value=$times_mod_times
WHERE config_name='times_mod_times'
UPDATE " . CONFIG_TABLE . " SET
config_value=$times_mod_welcome_message
WHERE config_name='times_mod_welcome_message'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not updata the sql', '', __LINE__, __FILE__, $sql);
}
$message = $lang['Config_updated'] . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid("index.$phpEx?pane=right") . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
exit;
}
$template->set_filenames(array(
"body" => "admin/times_mod_config_body.tpl")
);
$sql = "SELECT config_value
FROM " . CONFIG_TABLE . "
WHERE config_name='times_mod_welcome_message'";
$sql = "SELECT config_value
FROM " . CONFIG_TABLE . "
WHERE config_name='times_mod_times'";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not get times mod config.', '', __LINE__, __FILE__, $sql);
}
$db->sql_freeresult();
$template->assign_vars(array(
'L_CONFIGURATION_TITLE' => $lang['Times_mod'],
'L_TIMES_MOD_WELCOME_MESSAGE' => $lang['Times_mod_welcome_message'],
'L_TIMES_MOD_TIMES' => $lang['Times_mod_times'],
'TIMES_MOD_WELCOME_MESSAGE' => $times_mod_welcome_message,
'TIMES_MOD_TIMES' => $times_mod_times,
'L_SUBMIT' => $lang['Submit'],
'L_RESET' => $lang['Reset'],
'S_ACTION' => append_sid($_SERVER['PHP_SELF'])) // "admin_users.$phpEx"))
);
$template->pparse("body");
include('./page_footer_admin.'.$phpEx);
?>當我用\r
時,
他只會更新第二個sql,
那麼我怎麼辦??
代碼: 選擇全部
$sql = "UPDATE " . CONFIG_TABLE . " SET
config_value=$times_mod_times
WHERE config_name='times_mod_times'";
$sql = "UPDATE " . CONFIG_TABLE . " SET
config_value=$times_mod_welcome_message
WHERE config_name='times_mod_welcome_message'";
他只會更新第二個sql,
那麼我怎麼辦??
喔...
但是我用\r他又說\r
就更新不到第一個,
就算掉換都是更新不到第一個
不過我用times_mod_install.php
就可以用$sql = array();
難道後台和前台的不同
times_mod_install.php:
但是我用\r
代碼: 選擇全部
$sql = array();
$sql[] = "UPDATE " . CONFIG_TABLE . " SET
config_value=$times_mod_welcome_messge
WHERE config_name='times_mod_welcome_message'";
$sql[] = "UPDATE " . CONFIG_TABLE . " SET
config_value=$times_mod_times
WHERE config_name='times_mod_times'";如果不用\rDEBUG MODE
Array
Line : 43
File : admin_times_mod.php
就更新不到第一個,
就算掉換都是更新不到第一個
不過我用times_mod_install.php
就可以用$sql = array();
難道後台和前台的不同
times_mod_install.php:
代碼: 選擇全部
<?php
/***************************************************************************
* times_mod_install.php
* --------------------
* begin : tytsim, 2005
* copyright : (C) 2005
* email : tytsim@gmail.com
*
*
*
*
***************************************************************************/
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 = '安裝';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';
echo '<tr><th>完整安裝</th></tr><tr><td><span class="genmed"><ul type="circle">';
$sql = array();
$sql[] = "INSERT INTO " . $table_prefix . "config (config_name , config_value) VALUES ('times_mod_welcome_message', '您好^_^'); ";
$sql[] = "INSERT INTO " . $table_prefix . "config (config_name , config_value) VALUES ('times_mod_times', '1'); ";
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>錯誤:</b></font> ' . $error['message'] . '</li><br />';
}
else
{
echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>輸入成功</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">?#123;在已經完成安裝,請刪除本檔案!</span></td></tr>';
echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">祝你有好的一天</a></span></td></table>';
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>你這個程式跑起來沒問題丫\r
times_mod_install.php:
至於你前幾篇提到的
所以接下來跑$db->sql_query($sql)時, 自然就只會執行第二句的update語法了
times_mod_install.php:
代碼: 選擇全部
<?php
/***************************************************************************
* times_mod_install.php
* --------------------
* begin : tytsim, 2005
* copyright : (C) 2005
* email : tytsim@gmail.com
*
*
*
*
***************************************************************************/
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 = '安裝';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';
echo '<tr><th>完整安裝</th></tr><tr><td><span class="genmed"><ul type="circle">';
$sql = array();
$sql[] = "INSERT INTO " . $table_prefix . "config (config_name , config_value) VALUES ('times_mod_welcome_message', '您好^_^'); ";
$sql[] = "INSERT INTO " . $table_prefix . "config (config_name , config_value) VALUES ('times_mod_times', '1'); ";
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>錯誤:</b></font> ' . $error['message'] . '</li><br />';
}
else
{
echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>輸入成功</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">?#123;在已經完成安裝,請刪除本檔案!</span></td></tr>';
echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">祝你有好的一天</a></span></td></table>';
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>那是因為你第一句的sql還沒執行, 就又被第二句的內容覆蓋掉了*tytsim* 寫:當我用代碼: 選擇全部
$sql = "UPDATE " . CONFIG_TABLE . " SET config_value=$times_mod_times WHERE config_name='times_mod_times'"; $sql = "UPDATE " . CONFIG_TABLE . " SET config_value=$times_mod_welcome_message WHERE config_name='times_mod_welcome_message'";
時,
他只會更新第二個sql
所以接下來跑$db->sql_query($sql)時, 自然就只會執行第二句的update語法了


