acl_get('a_icons')) { return; } $filename = basename(__FILE__); $module['Posts']['Emoticons'] = $filename . $SID . '&type=emoticons'; $module['Posts']['Topic_icons'] = $filename . $SID . '&type=icons'; return; } define('IN_PHPBB', 1); // Include files $phpbb_root_path = '../'; require($phpbb_root_path . 'extension.inc'); require('pagestart.' . $phpEx); // Do we have general permissions? if (!$auth->acl_get('a_icons')) { message_die(MESSAGE, $user->lang['No_admin']); } // Check to see what mode we should operate in. $type = (!empty($_REQUEST['type'])) ? $_REQUEST['type'] : ''; $mode = (!empty($_REQUEST['mode'])) ? $_REQUEST['mode'] : ''; // What are we doing? switch ($type) { case 'emoticons': $table = SMILIES_TABLE; $lang = 'smilies'; $path = $config['smilies_path']; break; case 'icons': $table = ICONS_TABLE; $lang = 'icons'; $path = $config['icons_path']; break; } $delimiter = '=+:'; $_images = $_paks = array(); if ($mode == 'edit' || !empty($_POST['add']) || !empty($_POST['import_pak'])) { $dir = @opendir($phpbb_root_path . $path); while ($file = @readdir($dir)) { if (is_file($phpbb_root_path . $path . '/' . $file)) { $img_size = @getimagesize($phpbb_root_path . $path . '/' . $file); if (preg_match('/\.(gif|png|jpg)$/i', $file) || (!empty($img_size[0]) && !empty($img_size[1]))) { $_images[] = $file; } elseif (preg_match('/\.pak$/i', $file)) { $_paks[] = $file; } } } @closedir($dir); } // // Select main mode // if (isset($_POST['import_pak'])) { if (!empty($_POST['_pak'])) { $smile_order = 0; // // The user has already selected a smilies_pak file.. Import it. // if (!empty($_POST['clear_current'])) { $db->sql_query('DELETE FROM ' . $table); } else { $result = $db->sql_query('SELECT code FROM ' . $table); $smilies = array(); while ($row = $db->sql_fetchrow($result)) { ++$smile_order; $smilies[$row['code']] = 1; } } $fcontents = @file($phpbb_root_path . $path . '/'. $_pak); if (empty($fcontents)) { trigger_error('Could not read smiley pak file', E_USER_ERROR); } foreach ($fcontents as $line) { $_data = explode($delimiter, trim($line)); $_url = $_data[0]; $emotion = $_data[1]; $code = htmlentities($_data[2]); if (!isset($_data[4])) { // // The size isn't specified, try to get it from the file and if it fails // arbitrary set it to 15 and let the user correct it later. // $size = @getimagesize($phpbb_root_path . $path . '/' . $smile_url); $_width = (!empty($size[0])) ? $size[0] : 15; $_height = (!empty($size[1])) ? $size[1] : 15; } else { $_width = $_data[3]; $_height = $_data[4]; } if (!empty($smilies[$code])) { if (!empty($_POST['replace_existing'])) { $code_sql = str_replace("'", "''", str_replace('\\', '\\\\', $code)); $sql = array( 'smile_url' => $_url, 'smile_height' => $_height, 'smile_width' => $_width, 'emoticon' => $emotion ); $db->sql_query("UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . "WHERE code = '$code_sql'"); } } else { ++$smile_order; $sql = array( 'code' => $code, 'smile_url' => $_url, 'smile_height' => $_height, 'smile_width' => $_width, 'smile_order' => $_order, 'emoticon' => $emotion ); $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql)); } } message_die(MESSAGE, $user->lang[$lang . '_import_success']); } else { if (!count($_paks)) { $_paks_select = $user->lang['No_smilies_pak']; } else { $_paks_select = ''; } page_header($user->lang['Import_smilies']); ?>
lang['Import_smilies_explain'] ?>
sql_query('SELECT * FROM ' . $table); while ($row = $db->sql_fetchrow($result)) { $smilies_pak .= $row['smile_url'] . $delimiter; $smilies_pak .= $row['emoticon'] . $delimiter; $smilies_pak .= $row['code'] . $delimiter; $smilies_pak .= $row['smile_height'] . $delimiter; $smilies_pak .= $row['smile_width'] . "\n"; } $db->sql_close(); header('Content-Type: text/x-delimtext; name="smilies.pak"'); header('Content-disposition: attachment; filename=smilies.pak"'); echo $smilies_pak; exit; } elseif (isset($_POST['export_pak'])) { page_header($user->lang['Export_smilies']); message_die(MESSAGE, sprintf($user->lang['Export_smilies_explain'], '', '')); } elseif (isset($_POST['add'])) { $filename_list = ''; foreach ($_images as $smile_url) { if (!isset($default_image)) { $default_image = $smile_url; } $filename_list .= ''; } page_header($user->lang['Add_smile']); ?>lang['Emoticons_explain']; ?>