【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“admin_smilies.php”一文,供大家参考学习
<?php
/***************************************************************************
* admin_smilies.php
* -------------------
* begin : Thu May 31, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: admin_smilies.php,v 1.22.2.18 2006/04/13 09:56:48 grahamje 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.
*
***************************************************************************/
/**************************************************************************
* 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.
//
if( !empty($setmodules) )
{
$filename = basename(__FILE__);
$module['General']['Smilies'] = $filename;
return;
}
//
// Load default header
//
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');
$cancel = ( isset($HTTP_POST_VARS['cancel']) ) ? true : false;
$no_page_header = $cancel;
require('./pagestart.' . $phpEx);
if ($cancel)
{
redirect('admin/' . append_sid("admin_smilies.$phpEx", true));
}
//
// Check to see what mode we should operate in.
//
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 = htmlspecialchars($mode);
}
else
{
$mode = "";
}
$delimeter = '=+:';
//
// Read a listing of uploaded smilies for use in the add or edit smliey code...
//
$dir = @opendir($phpbb_root_path . $board_config['smilies_path']);
while($file = @readdir($dir))
{
if( !@is_dir(phpbb_realpath($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) )
{
$img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file);
if( $img_size[0] && $img_size[1] )
{
$smiley_images[] = $file;
}
else if( eregi('.pak$', $file) )
{
$smiley_paks[] = $file;
}
}
}
@closedir($dir);
//
// Select main mode
//
if( isset($HTTP_GET_VARS['import_pack']) || isset($HTTP_POST_VARS['import_pack']) )
{
//
// Import a list a "Smiley Pack"
//
$smile_pak = ( isset($HTTP_POST_VARS['smile_pak']) ) ? $HTTP_POST_VARS['smile_pak'] : $HTTP_GET_VARS['smile_pak'];
$clear_current = ( isset($HTTP_POST_VARS['clear_current']) ) ? $HTTP_POST_VARS['clear_current'] : $HTTP_GET_VARS['clear_current'];
$replace_existing = ( isset($HTTP_POST_VARS['replace']) ) ? $HTTP_POST_VARS['replace'] : $HTTP_GET_VARS['replace'];
if ( !empty($smile_pak) )
{
//
// The user has already selected a smile_pak file.. Import it.
//
if( !empty($clear_current) )
{
$sql = "DELETE
FROM " . SMILIES_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't delete current smilies", "", __LINE__, __FILE__, $sql);
}
}
else
{
$sql = "SELECT code
FROM ". SMILIES_TABLE;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't get current smilies", "", __LINE__, __FILE__, $sql);
}
$cur_smilies = $db->sql_fetchrowset($result);
for( $i = 0; $i < count($cur_smilies); $i++ )
{
$k = $cur_smilies[$i]['code'];
$smiles[$k] = 1;
}
}
$fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smile_pak);
if( empty($fcontents) )
{
message_die(GENERAL_ERROR, "Couldn't read smiley pak file", "", __LINE__, __FILE__, $sql);
}
for( $i = 0; $i < count($fcontents); $i++ )
{
$smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
for( $j = 2; $j < count($smile_data); $j++)
{
//
// Replace > and < with the proper html_entities for matching.
//
$smile_data[$j] = str_replace("<", "<", $smile_data[$j]);
$smile_data[$j] = str_replace(">", ">", $smile_data[$j]);
$k = $smile_data[$j];
if(