i hve some problem with my admin modul. i can see my entrys and i can delete them but i can't edit or add them
can some one help me?
here are my commands.php
Code: Select all
<?php
/**
*
* @package acp
* @version $Id: acp_commands.php - 2010-10-19 Angel200
* @copyright (c) 2005 phpBB Group, (c) 2010 Angel200 (modified acp_bots.php)
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acp
*/
class acp_commands
{
var $u_action;
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx;
$action = request_var('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
$mark = request_var('mark', array(0));
$command_id = request_var('id', 0);
if (isset($_POST['add']))
{
$action = 'add';
}
$default_key = 'a';
$sort_key = request_var('sk', $default_key);
$sort_dir = request_var('sd', 'a');
$error = array();
$user->add_lang('mods/commands');
$this->tpl_name = 'acp_commands';
$this->page_title = 'ACP_COMMANDS';
add_form_key('acp_commands');
if ($submit && !check_form_key('acp_commands'))
{
$error[] = $user->lang['FORM_INVALID'];
}
$command_id = (int) $command_id;
// User wants to do something, how inconsiderate of them!
switch ($action)
{
case 'delete':
if ($command_id || sizeof($mark))
{
if (confirm_box(true))
{
// Need to delete the relevant command entries
$sql = 'SELECT command_title, command_id
FROM ' . COMMANDS_TABLE . '
WHERE ' . $db->sql_in_set('command_id', ($command_id) ? array($command_id) : $mark);
$result = $db->sql_query($sql);
$command_title_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$command_title_ary[] = (string) $row['command_title'];
}
$db->sql_freeresult($result);
$sql = 'DELETE FROM ' . COMMANDS_TABLE . '
WHERE ' . $db->sql_in_set('command_id', ($command_id) ? array($command_id) : $mark);
$db->sql_query($sql);
add_log('admin', 'LOG_COM_DELETE', implode(', ', $command_title_ary));
trigger_error($user->lang['COM_DELETED'] . adm_back_link($this->u_action));
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'mark' => $mark,
'id' => $command_id,
'mode' => $mode,
'action' => $action))
);
}
}
break;
case 'edit':
case 'add':
$command_row = array(
'command_title' => utf8_normalize_nfc(request_var('command_title', '', true)),
'command_desc1' => utf8_normalize_nfc(request_var('command_desc1', '', true)),
'command_desc2' => utf8_normalize_nfc(request_var('command_desc2', '', true)),
);
if ($submit)
{
if (!$command_row['command_title'] || !$command_row['command_desc2'])
{
$error[] = $user->lang['ERR_COM_NO_MATCHES'];
}
if ($command_id)
{
$sql = 'SELECT command_title
FROM ' . COMMANDS_TABLE . "
WHERE command_id = $command_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row)
{
$error[] = $user->lang['NO_COM'];
}
}
else
{
$sql = 'SELECT command_title
FROM ' . COMMANDS_TABLE . "
WHERE command_title = '" . $db->sql_escape($command_row['command_title']) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['COM_NAME_TAKEN'];
}
}
if (!sizeof($error))
{
// A new Server Command? Create a Server Command entry in the Database
if ($action == 'add')
{
$sql = 'INSERT INTO ' . COMMANDS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'command_title' => (string) $command_row['command_title'],
'command_desc1' => (string) $command_row['command_desc1'],
'command_desc2' => (string) $command_row['command_desc2'],
));
$db->sql_query($sql);
$log = 'ADDED';
}
else if ($command_id)
{
$sql = 'SELECT command_id, command_title
FROM ' . COMMANDS_TABLE . "
WHERE command_id = $command_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row)
{
trigger_error($user->lang['NO_COM'] . adm_back_link($this->u_action . "&id=$command_id&action=$action"), E_USER_WARNING);
}
$sql = 'UPDATE ' . COMMANDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'command_title' => (string) $command_row['command_title'],
'command_desc1' => (string) $command_row['command_desc1'],
'command_desc2' => (string) $command_row['command_desc2'],
)) . " WHERE command_id = $command_id";
$db->sql_query($sql);
$log = 'UPDATED';
}
add_log('admin', 'LOG_COM_' . $log, $command_row['command_title']);
trigger_error($user->lang['COM_' . $log] . adm_back_link($this->u_action));
}
}
else if ($command_id)
{
$sql = 'SELECT *
FROM ' . COMMANDS_TABLE . "
WHERE command_id = $command_id";
$result = $db->sql_query($sql);
$command_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$command_row)
{
trigger_error($user->lang['NO_COM'] . adm_back_link($this->u_action . "&id=$command_id&action=$action"), E_USER_WARNING);
}
}
$l_title = ($action == 'edit') ? 'EDIT' : 'ADD';
$template->assign_vars(array(
'L_TITLE' => $user->lang['COM_' . $l_title],
'U_ACTION' => $this->u_action . "&id=$command_id&action=$action",
'U_BACK' => $this->u_action,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'COMMAND_TITLE' => $command_row['command_title'],
'DESC_ONE' => $command_row['command_desc1'],
'DESC_TWO' => $command_row['command_desc2'],
'S_EDIT_COMMAND' => true,
'S_ERROR' => (sizeof($error)) ? true : false,
)
);
return;
break;
}
$s_options = '';
$_options = array('delete' => 'DELETE');
foreach ($_options as $value => $lang)
{
$s_options .= '<option value="' . $value . '">' . $user->lang[$lang] . '</option>';
}
$sql = 'SELECT *
FROM ' . COMMANDS_TABLE . "
ORDER BY command_id ASC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('com', array(
'COMMAND_ID' => $row['command_id'],
'COMMAND_TITLE' => $row['command_title'],
'DESC_ONE' => $row['command_desc1'],
'DESC_TWO' => $row['command_desc2'],
'U_EDIT' => $this->u_action . "&id={$row['command_id']}&action=edit",
'U_DELETE' => $this->u_action . "&id={$row['command_id']}&action=delete")
);
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_SORT_COM_TITLE' => $this->u_action . '&sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_COM_DESC1' => $this->u_action . '&sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a'),
'U_SORT_COM_DESC2' => $this->u_action . '&sk=c&sd=' . (($sort_key == 'c' && $sort_dir == 'a') ? 'd' : 'a'),
'S_COM_OPTIONS' => $s_options)
);
}
}
?>
Code: Select all
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<!-- IF S_EDIT_COMMAND -->
<a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">« {L_BACK}</a>
<h1>{L_ACP_COMMANDS}</h1>
<p>{L_ACP_COMMAND_DESC}</p>
<!-- IF S_ERROR -->
<div class="errorbox">
<h3>{L_WARNING}</h3>
<p>{ERROR_MSG}</p>
</div>
<!-- ENDIF -->
<form id="acp_commands" method="post" action="{U_ACTION}">
<fieldset>
<legend>{L_COMMAND_USAGE}</legend>
<p>{L_COMMAND_USAGE_EXPLAIN}</p>
<dl>
<dd><input type="text" id="command_title" name="command_title" size="60" maxlength="255" value="{COMMAND_TITLE}" /></dd>
</dl>
</fieldset>
<fieldset>
<legend>{L_DESC_ONE}</legend>
<p>{L_DESCDE_EXPLAIN}</p>
<dl>
<dd><input type="text" id="command_desc1" name="command_desc1" size="60" maxlength="255" value="{DESC_ONE}" /></dd>
</dl>
</fieldset>
<fieldset>
<legend>{L_DESC_TWO}</legend>
<p>{L_DESCEN_EXPLAIN}</p>
<dl>
<dd><input type="text" id="command_desc2" name="command_desc2" size="60" maxlength="255" value="{DESC_TWO}" /></dd>
</dl>
</fieldset>
<fieldset class="submit-buttons">
<legend>{L_SUBMIT}</legend>
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
</fieldset>
</form>
<!-- ELSE -->
<h1>{L_ACP_COMMANDS}</h1>
<p>{L_ACP_COMMAND_DESC}</p>
<form id="acp_commands" method="post" action="{U_ACTION}">
<fieldset class="tabulated">
<legend>{L_ACP_COMMANDS}</legend>
<table cellspacing="1" id="down">
<thead>
<tr>
<th class="cat" style="text-align: center;" nowrap="nowrap"><b>{L_COMMAND_TITLE}</b></th>
<th class="cat" style="text-align: center;" nowrap="nowrap"><b>{L_DESC_ONE}</b></th>
<th class="cat" style="text-align: center;" nowrap="nowrap"><b>{L_DESC_TWO}</b></th>
<th class="cat" width="5%" style="text-align: center;"><b>{L_ACTION}</b></th>
</tr>
</thead>
<tbody>
<!-- BEGIN com -->
<!-- IF com.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
<td class="row1" style="text-align:left;">{com.COMMAND_TITLE}</td>
<td class="row1" style="text-align:left;">{com.DESC_ONE}</td>
<td class="row1" style="text-align:left;">{com.DESC_TWO}</td>
<td class="row1" style="text-align:right;"><a href="{com.U_EDIT}">{ICON_EDIT}</a> <a href="{com.U_DELETE}">{ICON_DELETE}</a></td>
</tr>
<!-- BEGINELSE -->
<tr class="row3">
<td colspan="5">{L_ACP_NO_ITEMS}</td>
</tr>
<!-- END com -->
</tbody>
</table>
<p class="quick">
<input class="button2" name="add" type="submit" value="{L_ADD_COMMAND}" />
</p>
</fieldset>
</form>
<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->