acl_get('a_general') ) { return; } $filename = basename(__FILE__); $module['General']['Emoticons'] = $filename . $SID . '&mode=emoticons'; 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_general')) { message_die(MESSAGE, $user->lang['No_admin']); } // // Check to see what mode we should operate in. // if (isset($_POST['mode']) || isset($_GET['mode'])) { $mode = (!empty($_POST['mode'])) ? $_POST['mode'] : $_GET['mode']; } else { $mode = ''; } $delimiter = '=+:'; $smilies_images = $smilies_paks = array(); if ($mode == 'edit' || !empty($_POST['add']) || !empty($_POST['import_pak'])) { $dir = @opendir($phpbb_root_path . $board_config['smilies_path']); while ($file = @readdir($dir)) { if (is_file($phpbb_root_path . $board_config['smilies_path'] . '/' . $file)) { $img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . $file); if (preg_match('/\.(gif|png|jpg)$/i', $file) || (!empty($img_size[0]) && !empty($img_size[1]))) { $smilies_images[] = $file; } elseif (preg_match('/\.pak$/i', $file)) { $smilies_paks[] = $file; } } } @closedir($dir); } // // Select main mode // if (isset($_POST['import_pak'])) { if (!empty($_POST['smilies_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 ' . SMILIES_TABLE); } else { $result = $db->sql_query('SELECT code FROM ' . SMILIES_TABLE); $smilies = array(); while ($row = $db->sql_fetchrow($result)) { ++$smile_order; $smilies[$row['code']] = 1; } } $fcontents = @file($phpbb_root_path . $board_config['smilies_path'] . '/'. $smilies_pak); if (empty($fcontents)) { message_die(ERROR, 'Could not read smiley pak file'); } foreach ($fcontents as $line) { $smile_data = explode($delimiter, trim($line)); $smile_url = $smile_data[0]; $emotion = $smile_data[1]; $code = htmlentities($smile_data[2]); if (!isset($smile_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 . $board_config['smilies_path'] . '/' . $smile_url); $smile_width = (!empty($size[0])) ? $size[0] : 15; $smile_height = (!empty($size[1])) ? $size[1] : 15; } else { $smile_width = $smile_data[3]; $smile_height = $smile_data[4]; } if (!empty($smilies[$code])) { if (!empty($_POST['replace_existing'])) { $code_sql = str_replace("'", "''", str_replace('\\', '\\\\', $code)); $sql = array( 'smile_url' => $smile_url, 'smile_height' => $smile_height, 'smile_width' => $smile_width, 'emoticon' => $emotion ); $db->sql_query_array('UPDATE ' . SMILIES_TABLE . " SET WHERE code = '$code_sql'", $sql); } } else { ++$smile_order; $sql = array( 'code' => $code, 'smile_url' => $smile_url, 'smile_height' => $smile_height, 'smile_width' => $smile_width, 'smile_order' => $smile_order, 'emoticon' => $emotion ); $db->sql_query_array('INSERT INTO ' . SMILIES_TABLE, $sql); } } message_die(MESSAGE, $user->lang['Smilies_import_success']); } else { if (!count($smilies_paks)) { $smilies_paks_select = $user->lang['No_smilies_pak']; } else { $smilies_paks_select = ''; } page_header($user->lang['Import_smilies']); ?>
lang['Import_smilies_explain'] ?>
sql_query('SELECT * FROM ' . SMILIES_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 ($smilies_images as $smile_url) { if (!isset($default_image)) { $default_image = $smile_url; } $filename_list .= ''; } page_header($user->lang['Add_smile']); ?>lang['Emoticons_explain']; ?>