function admin_smilies_add() { global $db; if (!isset($_SESSION['rights']['admin']['smilies']['add']) and !isset($_SESSION['rights']['superadmin'])) { echo NO_ADMIN_RIGHTS; } else { if (@$_FILES['smilie']['tmp_name'] == '') { table(ERROR, NOT_NEED_ALL_INPUTS); $tpl = new smarty(); ob_start(); $tpl->display(DESIGN . '/tpl/admin/smilies.html'); $content = ob_get_contents(); ob_end_clean(); main_content(SMILIES, $content, '', 1); get_smilies(); } elseif ($_FILES['smilie']['type'] != 'image/jpg' and $_FILES['smilie']['type'] != 'image/gif' and $_FILES['smilie']['type'] != 'image/png' and $_FILES['smilie']['type'] != 'image/jpeg') { table(ERROR, WRONG_FILE_TYPE); $tpl = new smarty(); ob_start(); $tpl->display(DESIGN . '/tpl/admin/smilies.html'); $content = ob_get_contents(); ob_end_clean(); main_content(SMILIES, $content, '', 1); get_smilies(); } else { ajax_convert_array($_POST); ajax_convert_array($_FILES); if (move_uploaded_file($_FILES['smilie']['tmp_name'], 'images/smilies/' . str_replace(' ', '_', $_FILES['smilie']['name']))) { umask(0); chmod('images/smilies/' . str_replace(' ', '_', $_FILES['smilie']['name']), CHMOD); $sql = sprintf('INSERT INTO ' . DB_PRE . 'ecp_smilies (`bedeutung`, `filename`) VALUES (\'%s\', \'%s\')', strsave($_POST['bedeutung']), strsave(str_replace(' ', '_', $_FILES['smilie']['name']))); if ($db->query($sql)) { header1('?section=admin&site=smilies'); } } } } }
function parse_code($string, $do_br = 0, $do_img = 0, $do_code = 0, $do_smilies = 0) { global $config, $style; static $smilies_fixed = 0; // HTML-Security & special characters $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); foreach ($trans as $key => $value) { $trans[$key] = '&#' . ord($key) . ';'; } strtr($string, $trans); $string = str_replace('<', '<', $string); $string = str_replace('>', '>', $string); if ($do_code) { global $a_thwbcode, $a_thwbcode2nd; if (!defined('THWB_TAGS')) { get_thwb_tags(); } $string = preg_replace($a_thwbcode[SEARCH], $a_thwbcode[REPLACE], $string); // nested [quote] fixup $string = fixup_quotes($string); $string = preg_replace($a_thwbcode2nd[SEARCH], $a_thwbcode2nd[REPLACE], $string); } if ($do_smilies && $config['smilies']) { global $a_smilies; if (!defined('THWB_SMILIES')) { $a_smilies = get_smilies(); } if (!$smilies_fixed) { reset($a_smilies); $url_prepend = '<img src="templates/' . $style['styletemplate'] . '/images/icon/'; while (current($a_smilies)) { $a_smilies[key($a_smilies)] = $url_prepend . current($a_smilies) . '_new.png" border="0">'; next($a_smilies); } $smilies_fixed = 1; } $string = strtr($string, $a_smilies); } // reinsert extracted parts $string = preg_replace('/\\<noparse ([0-9]+)\\>/e', 'noparse("",\\1)', $string); if ($do_img && $config['imageslevel'] != 2) { $string = preg_replace('/\\[img\\](|[ \\n]*<a href=\\")([a-zA-Z]+):\\/\\/([^ \\"\\n]+)(|\\" target=\\"_blank\\">\\2:\\/\\/\\3([ \\n]*)<\\/a>[ \\n]*)\\[\\/img\\]/Usi', '<img src="\\2://\\3" alt="" border="0">', $string); } if ($do_br) { $string = str_replace("\n", '<br />', $string); } else { $string = str_replace("\n", '', $string); } return $string; }
function do_smilies($text) { global $luna_config; $smilies = get_smilies(); $text = ' ' . $text . ' '; foreach ($smilies as $smiley_text => $smiley_img) { if (strpos($text, $smiley_text) !== false) { if ($luna_config['o_emoji'] == 1) { $text = ucp_preg_replace('%(?<=[>\\s])' . preg_quote($smiley_text, '%') . '(?=[^\\p{L}\\p{N}])%um', '<span class="emoji">' . $smiley_img . '</span>', $text); } else { $text = ucp_preg_replace('%(?<=[>\\s])' . preg_quote($smiley_text, '%') . '(?=[^\\p{L}\\p{N}])%um', '<img src="' . luna_htmlspecialchars(get_base_url(true) . '/img/smilies/' . $smiley_img) . '" width="' . $luna_config['o_emoji_size'] . '" height="' . $luna_config['o_emoji_size'] . '" alt="' . substr($smiley_img, 0, strrpos($smiley_img, '.')) . '" />', $text); } } } return substr($text, 1, -1); }
function set_smilies($message, $url = '') { static $orig, $repl; if (!isset($orig)) { global $smilies_path, $smilies_desc; $orig = $repl = array(); $smilies = get_smilies(); if ($url != '' && substr($url, -1) != '/') { $url .= '/'; } for ($i = 0; $i < count($smilies); $i++) { $smilies[$i]['code'] = str_replace('#', '\\#', preg_quote($smilies[$i]['code'])); $orig[] = "#([\\s])" . $smilies[$i]['code'] . "([\\s<])#si"; $repl[] = '\\1<img class="bbsmilies" src="' . $url . $smilies_path . $smilies[$i]['smile_url'] . '" alt="' . get_code_lang($smilies[$i]['emoticon'], $smilies_desc) . '" title="' . get_code_lang($smilies[$i]['emoticon'], $smilies_desc) . '" />\\2'; } } if (count($orig)) { $message = preg_replace($orig, $repl, " {$message} "); $message = substr($message, 1, -1); } return $message; }
</p></li><li><p><?php _e('Example list item 3.', 'luna'); ?> </p></li></ol> </div> </div> <div class="tab-pane" id="smilies"> <p><a id="emoticons"></a><?php _e('If enabled, the forum can convert a series of smilies to graphical representations. The following smilies you can use are:', 'luna'); ?> </p> <div class="row"> <?php // Display the smiley set require LUNA_ROOT . 'include/parser.php'; $smilies = get_smilies(); $smiley_groups = array(); foreach ($smilies as $smiley_text => $smiley_img) { $smiley_groups[$smiley_img][] = $smiley_text; } foreach ($smiley_groups as $smiley_img => $smiley_texts) { if ($luna_config['o_emoji'] == 1) { echo "\t\t" . '<div class="col-sm-3"><p><code>' . implode('</code> ' . __('and', 'luna') . ' <code>', $smiley_texts) . '</code> <span>' . __('produces', 'luna') . '</span> <span class="emoji">' . $smiley_img . '</span></p></div>' . "\n"; } else { echo "\t\t" . '<div class="col-sm-3"><p><code>' . implode('</code> ' . __('and', 'luna') . ' <code>', $smiley_texts) . '</code> <span>' . __('produces', 'luna') . '</span> <img src="' . luna_htmlspecialchars(get_base_url(true)) . '/img/smilies/' . $smiley_img . '" width="' . $luna_config['o_emoji_size'] . '" height="' . $luna_config['o_emoji_size'] . '" alt="' . $smiley_texts[0] . '" /></p></div>' . "\n"; } } ?> </div> </div> </div>
function parse_code($string, $do_br = 0, $do_img = 0, $do_code = 0, $do_smilies = 0) { global $config, $style; static $smilies_fixed = 0; // HTML-Security $string = str_replace('&', '&', $string); $string = str_replace('<', '<', $string); $string = str_replace('>', '>', $string); if ($do_code) { global $a_thwbcode; if (!defined('THWB_TAGS')) { $a_thwbcode = get_thwb_tags(); } //echo "<pre style=\"font-size:8pt\">"; // nested [quote] fixup $string = fixup_quotes($string); //echo "$string</pre>"; $string = preg_replace($a_thwbcode[SEARCH], $a_thwbcode[REPLACE], $string); } if ($do_img && $config['imageslevel'] != 2) { $string = preg_replace('/\\[img\\]([a-zA-Z]+):\\/\\/([^ ,\\"\\n]+)\\[\\/img\\]/Usi', '<img src="\\1://\\2.\\3" alt="" border="0">', $string); } if ($do_smilies && $config['smilies']) { global $a_smilies; if (!defined('THWB_SMILIES')) { $a_smilies = get_smilies(); } if (!$smilies_fixed) { reset($a_smilies); $url_prepend = '<img src="templates/' . $style['styletemplate'] . '/images/icon/'; while (current($a_smilies)) { $a_smilies[key($a_smilies)] = $url_prepend . current($a_smilies) . '_new.gif" width="15" height="15" border="0">'; next($a_smilies); } $smilies_fixed = 1; } $string = strtr($string, $a_smilies); } // reinsert extracted parts $string = preg_replace('/\\<noparse ([0-9]+)\\>/e', 'noparse("",\\1)', $string); if ($do_br) { $string = str_replace("\n", '<br>', $string); } else { $string = str_replace("\n", '', $string); } return $string; }