Some implementation of hard coded HTML

git-svn-id: file:///svn/phpbb/trunk@2795 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-07-30 01:05:09 +00:00
parent 56eea32ffd
commit cea28bc26c

View file

@ -1,6 +1,6 @@
<?php <?php
/*************************************************************************** /***************************************************************************
* admin_smilies.php * admin_icons.php
* ------------------- * -------------------
* begin : Thu May 31, 2001 * begin : Thu May 31, 2001
* copyright : (C) 2001 The phpBB Group * copyright : (C) 2001 The phpBB Group
@ -19,48 +19,46 @@
* *
***************************************************************************/ ***************************************************************************/
/**************************************************************************
* This file will be used for modifying the smiley settings for a board.
**************************************************************************/
define('IN_PHPBB', 1);
// //
// First we do the setmodules stuff for the admin cp. // First we do the setmodules stuff for the admin cp.
// //
if( !empty($setmodules) ) if ( !empty($setmodules) )
{ {
if ( !$acl->get_acl_admin('general') )
{
return;
}
$filename = basename(__FILE__); $filename = basename(__FILE__);
$module['General']['Emoticons'] = $filename . $SID; $module['General']['Emoticons'] = $filename . $SID . "&amp;mode=emoticons";
return; return;
} }
// define('IN_PHPBB', 1);
// Load default header $phpbb_root_path = '../';
//
if( isset($HTTP_GET_VARS['export_pack']) )
{
if ( $HTTP_GET_VARS['export_pack'] == "send" )
{
$no_page_header = true;
}
}
$phpbb_root_path = "../";
require($phpbb_root_path . 'extension.inc'); require($phpbb_root_path . 'extension.inc');
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
//
//
//
if ( !$acl->get_acl_admin('general') )
{
message_die(MESSAGE, $lang['No_admin']);
}
// //
// Check to see what mode we should operate in. // Check to see what mode we should operate in.
// //
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
{ {
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
} }
else else
{ {
$mode = ""; $mode = '';
} }
$delimeter = '=+:'; $delimeter = '=+:';
@ -70,9 +68,9 @@ $delimeter = '=+:';
// //
$dir = @opendir($phpbb_root_path . $board_config['smilies_path']); $dir = @opendir($phpbb_root_path . $board_config['smilies_path']);
while($file = @readdir($dir)) while( $file = @readdir($dir) )
{ {
if( !@is_dir($phpbb_root_path . $board_config['smilies_path'] . '/' . $file) ) if ( !is_dir($phpbb_root_path . $board_config['smilies_path'] . '/' . $file) )
{ {
$img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file); $img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file);
@ -92,7 +90,7 @@ while($file = @readdir($dir))
// //
// Select main mode // Select main mode
// //
if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']) ) if ( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']) )
{ {
// //
// Import a list a "Smiley Pack" // Import a list a "Smiley Pack"
@ -110,19 +108,13 @@ if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']
{ {
$sql = "DELETE $sql = "DELETE
FROM " . SMILIES_TABLE; FROM " . SMILIES_TABLE;
if( !$result = $db->sql_query($sql) ) $db->sql_query($sql);
{
message_die(GENERAL_ERROR, "Couldn't delete current smilies", "", __LINE__, __FILE__, $sql);
}
} }
else else
{ {
$sql = "SELECT code $sql = "SELECT code
FROM ". SMILIES_TABLE; FROM ". SMILIES_TABLE;
if( !$result = $db->sql_query($sql) ) $result = $db->sql_query($sql);
{
message_die(GENERAL_ERROR, "Couldn't get current smilies", "", __LINE__, __FILE__, $sql);
}
$cur_smilies = $db->sql_fetchrowset($result); $cur_smilies = $db->sql_fetchrowset($result);
@ -135,9 +127,9 @@ if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']
$fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smile_pak); $fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smile_pak);
if( empty($fcontents) ) if ( empty($fcontents) )
{ {
message_die(GENERAL_ERROR, "Couldn't read smiley pak file", "", __LINE__, __FILE__, $sql); message_die(ERROR, "Couldn't read smiley pak file", "", __LINE__, __FILE__, $sql);
} }
for( $i = 0; $i < count($fcontents); $i++ ) for( $i = 0; $i < count($fcontents); $i++ )
@ -172,20 +164,14 @@ if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']
VALUES('" . str_replace("\'", "''", $smile_data[$j]) . "', '" . str_replace("\'", "''", $smile_data[0]) . "', '" . str_replace("\'", "''", $smile_data[1]) . "')"; VALUES('" . str_replace("\'", "''", $smile_data[$j]) . "', '" . str_replace("\'", "''", $smile_data[0]) . "', '" . str_replace("\'", "''", $smile_data[1]) . "')";
} }
if( $sql != '' ) if ( $sql != '' )
{ {
$result = $db->sql_query($sql); $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't update smilies!", "", __LINE__, __FILE__, $sql);
}
} }
} }
} }
$message = $lang['smiley_import_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $lang['smiley_import_success']);
message_die(GENERAL_MESSAGE, $message);
} }
else else
@ -237,14 +223,11 @@ else if( isset($HTTP_POST_VARS['export_pack']) || isset($HTTP_GET_VARS['export_p
{ {
$sql = "SELECT * $sql = "SELECT *
FROM " . SMILIES_TABLE; FROM " . SMILIES_TABLE;
if( !$result = $db->sql_query($sql) ) $result = $db->sql_query($sql);
{
message_die(GENERAL_ERROR, "Couldn't delete smiley", "", __LINE__, __FILE__, $sql);
}
$resultset = $db->sql_fetchrowset($result); $resultset = $db->sql_fetchrowset($result);
$smile_pak = ""; $smile_pak = '';
for($i = 0; $i < count($resultset); $i++ ) for($i = 0; $i < count($resultset); $i++ )
{ {
$smile_pak .= $resultset[$i]['smile_url'] . $delimeter; $smile_pak .= $resultset[$i]['smile_url'] . $delimeter;
@ -260,9 +243,7 @@ else if( isset($HTTP_POST_VARS['export_pack']) || isset($HTTP_GET_VARS['export_p
exit; exit;
} }
$message = sprintf($lang['export_smiles'], "<a href=\"" . append_sid("admin_smilies.$phpEx?export_pack=send", true) . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, sprintf($lang['export_smiles'], '<a href="' . "admin_smilies.$phpEx$SID&amp;export_pack=send" . '">', '</a>'));
message_die(GENERAL_MESSAGE, $message);
} }
else if( isset($HTTP_POST_VARS['add']) ) else if( isset($HTTP_POST_VARS['add']) )
@ -303,45 +284,32 @@ else if( isset($HTTP_POST_VARS['add']) )
$template->pparse("body"); $template->pparse("body");
} }
else if ( $mode != "" )
{
switch( $mode )
{
case 'delete':
//
// Admin has selected to delete a smiley.
//
$smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; //
//
//
switch( $mode )
{
case 'delete':
$smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']);
$sql = "DELETE FROM " . SMILIES_TABLE . " $sql = "DELETE FROM " . SMILIES_TABLE . "
WHERE smilies_id = " . $smiley_id; WHERE smilies_id = " . $smiley_id;
$result = $db->sql_query($sql); $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't delete smiley", "", __LINE__, __FILE__, $sql);
}
$message = $lang['smiley_del_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $lang['smiley_del_success']);
message_die(GENERAL_MESSAGE, $message);
break; break;
case 'edit': case 'edit':
//
// Admin has selected to edit a smiley.
//
$smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id']; $smiley_id = ( !empty($HTTP_POST_VARS['id']) ) ? intval($HTTP_POST_VARS['id']) : intval($HTTP_GET_VARS['id']);
$sql = "SELECT * $sql = "SELECT *
FROM " . SMILIES_TABLE . " FROM " . SMILIES_TABLE . "
WHERE smilies_id = " . $smiley_id; WHERE smilies_id = " . $smiley_id;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, $lang['smile_edit_err'], "", __LINE__, __FILE__, $sql);
}
$smile_data = $db->sql_fetchrow($result); $smile_data = $db->sql_fetchrow($result);
$filename_list = ""; $filename_list = "";
@ -390,10 +358,7 @@ else if ( $mode != "" )
$template->pparse("body"); $template->pparse("body");
break; break;
case "save": case 'save':
//
// Admin has submitted changes while editing a smiley.
//
// //
// Get the submitted data, being careful to ensure that we only // Get the submitted data, being careful to ensure that we only
@ -403,11 +368,8 @@ else if ( $mode != "" )
$smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url']; $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
$smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion']; $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion'];
$smile_id = ( isset($HTTP_POST_VARS['smile_id']) ) ? intval($HTTP_POST_VARS['smile_id']) : intval($HTTP_GET_VARS['smile_id']); $smile_id = ( isset($HTTP_POST_VARS['smile_id']) ) ? intval($HTTP_POST_VARS['smile_id']) : intval($HTTP_GET_VARS['smile_id']);
//
// Convert < and > to proper htmlentities for parsing. $smile_code = htmlspecialchars($smile_code);
//
$smile_code = str_replace('<', '&lt;', $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// //
// Proceed with updating the smiley table. // Proceed with updating the smiley table.
@ -415,21 +377,12 @@ else if ( $mode != "" )
$sql = "UPDATE " . SMILIES_TABLE . " $sql = "UPDATE " . SMILIES_TABLE . "
SET code = '" . str_replace("\'", "''", $smile_code) . "', smile_url = '" . str_replace("\'", "''", $smile_url) . "', emoticon = '" . str_replace("\'", "''", $smile_emotion) . "' SET code = '" . str_replace("\'", "''", $smile_code) . "', smile_url = '" . str_replace("\'", "''", $smile_url) . "', emoticon = '" . str_replace("\'", "''", $smile_emotion) . "'
WHERE smilies_id = $smile_id"; WHERE smilies_id = $smile_id";
$result = $db->sql_query($sql); $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't update smilies info", "", __LINE__, __FILE__, $sql);
}
$message = $lang['smiley_edit_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $lang['smiley_edit_success']);
message_die(GENERAL_MESSAGE, $message);
break; break;
case "savenew": case 'savenew':
//
// Admin has submitted changes while adding a new smiley.
//
// //
// Get the submitted data being careful to ensure the the data // Get the submitted data being careful to ensure the the data
@ -439,103 +392,72 @@ else if ( $mode != "" )
$smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url']; $smile_url = ( isset($HTTP_POST_VARS['smile_url']) ) ? $HTTP_POST_VARS['smile_url'] : $HTTP_GET_VARS['smile_url'];
$smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion']; $smile_emotion = ( isset($HTTP_POST_VARS['smile_emotion']) ) ? $HTTP_POST_VARS['smile_emotion'] : $HTTP_GET_VARS['smile_emotion'];
// $smile_code = htmlspecialchars($smile_code);
// Convert < and > to proper htmlentities for parsing.
//
$smile_code = str_replace('<', '&lt;', $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// //
// Save the data to the smiley table. // Save the data to the smiley table.
// //
$sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon) $sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon)
VALUES ('" . str_replace("\'", "''", $smile_code) . "', '" . str_replace("\'", "''", $smile_url) . "', '" . str_replace("\'", "''", $smile_emotion) . "')"; VALUES ('" . str_replace("\'", "''", $smile_code) . "', '" . str_replace("\'", "''", $smile_url) . "', '" . str_replace("\'", "''", $smile_emotion) . "')";
$result = $db->sql_query($sql); $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't insert new smiley", "", __LINE__, __FILE__, $sql);
}
$message = $lang['smiley_add_success'] . "<br /><br />" . sprintf($lang['Click_return_smileadmin'], "<a href=\"" . append_sid("admin_smilies.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $lang['smiley_add_success']);
message_die(GENERAL_MESSAGE, $message);
break; break;
}
}
else
{
// default:
// This is the main display of the page before the admin has selected
// any options.
//
$sql = "SELECT * $sql = "SELECT *
FROM " . SMILIES_TABLE; FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't obtain smileys from database", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result); page_header($lang['Emoticons']);
$template->set_filenames(array( ?>
"body" => "admin/smile_list_body.tpl")
); <h1><?php echo $lang['Emoticons']; ?></h1>
$template->assign_vars(array( <p><?php echo $lang['Emoticons_explain']; ?></p>
"L_ACTION" => $lang['Action'],
"L_SMILEY_TITLE" => $lang['smiley_title'], <form method="post" action="<?php echo "admin_smilies.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
"L_SMILEY_TEXT" => $lang['smile_desc'], <tr>
"L_DELETE" => $lang['Delete'], <th><?php echo $lang['Code']; ?></th>
"L_EDIT" => $lang['Edit'], <th><?php echo $lang['Smile']; ?></th>
"L_SMILEY_ADD" => $lang['smile_add'], <th><?php echo $lang['Emotion']; ?></th>
"L_CODE" => $lang['Code'], <th colspan="2"><?php echo $lang['Action']; ?></th>
"L_EMOT" => $lang['Emotion'], </tr>
"L_SMILE" => $lang['Smile'], <?php
"L_IMPORT_PACK" => $lang['import_smile_pack'],
"L_EXPORT_PACK" => $lang['export_smile_pack'], if ( $row = $db->sql_fetchrow($result) )
{
"S_HIDDEN_FIELDS" => $s_hidden_fields, do
"S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx")) {
); $row_class = ( $row_class != 'row1' ) ? 'row1' : 'row2';
// ?>
// Loop throuh the rows of smilies setting block vars for the template. <tr>
// <td class="<?php echo $row_class; ?>" align="center"><?php echo htmlspecialchars($row['code']); ?></td>
for($i = 0; $i < count($smilies); $i++) <td class="<?php echo $row_class; ?>" align="center"><img src="<?php echo './../' . $board_config['smilies_path'] . '/' . $row['smile_url']; ?>" alt="<?php echo htmlspecialchars($row['code']); ?>" /></td>
{ <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['emoticon']; ?></td>
// <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_smilies.$phpEx$SID&amp;mode=edit&amp;id=" . $row['smilies_id']; ?>"><?php echo $lang['Edit']; ?></a></td>
// Replace htmlentites for < and > with actual character. <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_smilies.$phpEx$SID&amp;mode=delete&amp;id=" . $row['smilies_id']; ?>"><?php echo $lang['Delete']; ?></a></td>
// </tr>
$smilies[$i]['code'] = str_replace('&lt;', '<', $smilies[$i]['code']); <?php
$smilies[$i]['code'] = str_replace('&gt;', '>', $smilies[$i]['code']);
}
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; while ( $row = $db->sql_fetchrow($result) );
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; }
$template->assign_block_vars("smiles", array( ?>
"ROW_COLOR" => "#" . $row_color, <tr>
"ROW_CLASS" => $row_class, <td class="cat" colspan="5" align="center"><input type="submit" name="add" value="<?php echo $lang['smile_add']; ?>" class="mainoption" />&nbsp;&nbsp;<input class="liteoption" type="submit" name="import_pack" value="<?php echo $lang['import_smile_pack']; ?>">&nbsp;&nbsp;<input class="liteoption" type="submit" name="export_pack" value="<?php echo $lang['export_smile_pack']; ?>"></td>
</tr>
"SMILEY_IMG" => $phpbb_root_path . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'], </table></form>
"CODE" => $smilies[$i]['code'],
"EMOT" => $smilies[$i]['emoticon'], <?php
"U_SMILEY_EDIT" => append_sid("admin_smilies.$phpEx?mode=edit&amp;id=" . $smilies[$i]['smilies_id']), page_footer();
"U_SMILEY_DELETE" => append_sid("admin_smilies.$phpEx?mode=delete&amp;id=" . $smilies[$i]['smilies_id']))
); break;
} }
//
// Spit out the page.
//
$template->pparse("body");
}
//
// Page Footer
//
include('page_footer_admin.'.$phpEx);
?> ?>