function ajax_parsesmileys($message) { global $smiley_cache; if (!$smiley_cache) { cache_smileys(); } if (is_array($smiley_cache) && count($smiley_cache)) { foreach ($smiley_cache as $smiley) { $smiley_code = preg_quote($smiley['smiley_code']); $smiley_image = "<img src='" . $smiley['smiley_image'] . "' alt='" . $smiley['smiley_image'] . "' style='vertical-align:middle;' class='smiley' />"; $message = preg_replace("#{$smiley_code}#si", $smiley_image, $message); } } return $message; }
function form_textarea($input_name, $label = '', $input_value = '', array $options = array()) { global $locale, $defender, $userdata; // for editor $title = $label ? stripinput($label) : ucfirst(strtolower(str_replace("_", " ", $input_name))); $input_name = isset($input_name) && !empty($input_name) ? stripinput($input_name) : ""; require_once INCLUDES . "bbcode_include.php"; require_once INCLUDES . "html_buttons_include.php"; include_once LOCALE . LOCALESET . "admin/html_buttons.php"; include_once LOCALE . LOCALESET . "error.php"; if (!empty($options['bbcode'])) { $options['type'] = "bbcode"; } elseif (!empty($options['html'])) { $options['type'] = "html"; } $options = array('input_id' => !empty($options['input_id']) ? $options['input_id'] : $input_name, "type" => !empty($options['type']) && in_array($options['type'], array("html", "bbcode", "tinymce")) ? $options['type'] : "", 'required' => !empty($options['required']) && $options['required'] == 1 ? '1' : '0', 'placeholder' => !empty($options['placeholder']) ? $options['placeholder'] : '', 'deactivate' => !empty($options['deactivate']) && $options['deactivate'] == 1 ? '1' : '', 'width' => !empty($options['width']) ? $options['width'] : '100%', 'height' => !empty($options['height']) ? $options['height'] : '80px', 'class' => !empty($options['class']) ? $options['class'] : '', 'inline' => !empty($options['inline']) && $options['inline'] == 1 ? '1' : '0', 'length' => !empty($options['length']) ? $options['length'] : '200', 'error_text' => !empty($options['error_text']) ? $options['error_text'] : $locale['error_input_default'], 'safemode' => !empty($options['safemode']) && $options['safemode'] == 1 ? '1' : '0', 'form_name' => !empty($options['form_name']) ? $options['form_name'] : 'input_form', 'tinymce' => !empty($options['tinymce']) && in_array($options['tinymce'], array(TRUE, 'simple', 'advanced')) ? $options['tinymce'] : "simple", 'no_resize' => !empty($options['no_resize']) && $options['no_resize'] == '1' ? '1' : '0', 'autosize' => !empty($options['autosize']) && $options['autosize'] == 1 ? '1' : '0', 'preview' => !empty($options['preview']) && $options['preview'] == TRUE ? TRUE : FALSE, 'path' => !empty($options['path']) && $options['path'] ? $options['path'] : IMAGES, 'maxlength' => !empty($options['maxlength']) && isnum($options['maxlength']) ? $options['maxlength'] : '', 'tip' => !empty($options['tip']) ? $options['tip'] : ''); if ($options['type'] == "tinymce") { $tinymce_list = array(); $image_list = makefilelist(IMAGES, ".|..|"); $image_filter = array('png', 'PNG', 'bmp', 'BMP', 'jpg', 'JPG', 'jpeg', 'gif', 'GIF', 'tiff', 'TIFF'); foreach ($image_list as $image_name) { $image_1 = explode('.', $image_name); $last_str = count($image_1) - 1; if (in_array($image_1[$last_str], $image_filter)) { $tinymce_list[] = array('title' => $image_name, 'value' => IMAGES . $image_name); } } $tinymce_list = json_encode($tinymce_list); $tinymce_smiley_vars = ""; if (!defined('tinymce')) { add_to_head("<style type='text/css'>.mceIframeContainer iframe{width:100%!important; height:30px;}</style>"); add_to_footer("<script type='text/javascript' src='" . INCLUDES . "jscripts/tinymce/tinymce.min.js'></script>"); define('tinymce', TRUE); // PHP-Fusion Parse Cache Smileys $smileys = cache_smileys(); $tinymce_smiley_vars = ""; if (!empty($smileys)) { $tinymce_smiley_vars = "var shortcuts = {\n"; foreach ($smileys as $params) { $tinymce_smiley_vars .= "'" . strtolower($params['smiley_code']) . "' : '<img alt=\"" . $params['smiley_text'] . "\" src=\"" . IMAGES . "smiley/" . $params['smiley_image'] . "\"/>',\n"; } $tinymce_smiley_vars .= "};\n"; $tinymce_smiley_vars .= "\n\t\t\t\ted.on('keyup load', function(e){\n\t\t\t\t\tvar marker = tinymce.activeEditor.selection.getBookmark();\n\t\t\t\t\t// Store editor contents\n\t\t\t\t\tvar content = tinymce.activeEditor.getContent({'format':'raw'});\n\t\t\t\t\t// Loop through all shortcuts\n\t\t\t\t\tfor(var key in shortcuts){\n\t\t\t\t\t\t// Check if the editor html contains the looped shortcut\n\t\t\t\t\t\tif(content.toLowerCase().indexOf(key) != -1) {\n\t\t\t\t\t\t\t// Escaping special characters to be able to use the shortcuts in regular expression\n\t\t\t\t\t\t\tvar k = key.replace(/[<>*()?']/ig, \"\\\$&\");\n\t\t\t\t\t\t\ttinymce.activeEditor.setContent(content.replace(k, shortcuts[key]));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Now put cursor back where it was\n\t\t\t\t\ttinymce.activeEditor.selection.moveToBookmark(marker);\n\t\t\t\t});\n\t\t\t\t"; } } // Mode switching for TinyMCE switch ($options['tinymce']) { case 'advanced': add_to_jquery("\n tinymce.init({\n selector: '#" . $options['input_id'] . "',\n theme: 'modern',\n entity_encoding : 'raw',\n width: '100%',\n height: 300,\n plugins: [\n 'advlist autolink autoresize link image lists charmap print preview hr anchor pagebreak spellchecker',\n 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n 'save table contextmenu directionality template paste textcolor'\n ],\n image_list: {$tinymce_list},\n content_css: '" . THEMES . "admin_templates/" . fusion_get_settings("admin_theme") . "/acp_styles.css',\n toolbar1: 'insertfile undo redo | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | newdocument fullscreen preview cut copy paste pastetext spellchecker searchreplace code',\n toolbar2: 'styleselect formatselect removeformat | fontselect fontsizeselect bold italic underline strikethrough subscript superscript blockquote | forecolor backcolor',\n toolbar3: 'hr pagebreak insertdatetime | link unlink anchor | image media | table charmap visualchars visualblocks emoticons',\n image_advtab: true,\n style_formats: [\n {title: 'Bold text', inline: 'b'},\n {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},\n {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},\n {title: 'Example 1', inline: 'span', classes: 'example1'},\n {title: 'Example 2', inline: 'span', classes: 'example2'},\n {title: 'Table styles'},\n {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}\n ],\n setup: function(ed) {\n \t\t\t\t\t// add tabkey listener\n \t\t\t\t\ted.on('keydown', function(event) {\n \t\t\t\t\tif (event.keyCode == 9) { // tab pressed\n \t\t\t\t\t\tif (event.shiftKey) { ed.execCommand('Outdent'); } else { ed.execCommand('Indent'); }\n \t\t\t\t\t\tevent.preventDefault();\n \t\t\t\t\t\treturn false;\n \t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// auto smileys parsing\n\t\t\t\t\t\t" . $tinymce_smiley_vars . "\n\t\t\t\t}\n });\n "); break; case 'simple': add_to_jquery("\n tinymce.init({\n selector: '#" . $options['input_id'] . "',\n theme: 'modern',\n menubar: false,\n statusbar: false,\n content_css: '" . THEMES . "/templates/tinymce.css',\n image_list: {$tinymce_list},\n plugins: [\n 'advlist autolink autoresize link lists charmap print preview hr anchor pagebreak spellchecker',\n 'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',\n 'contextmenu directionality template paste bbcode autoresize'\n ],\n height: 30,\n image_advtab: true,\n toolbar1: 'undo redo | bold italic underline | bullist numlist blockquote | hr media | fullscreen',\n entity_encoding : 'raw',\n language: '" . $locale['tinymce'] . "',\n object_resizing: false,\n resize: false,\n relative_urls: false,\n setup: function(ed) {\n \t\t\t\t\t// add tabkey listener\n \t\t\t\t\ted.on('keydown', function(event) {\n \t\t\t\t\tif (event.keyCode == 9) { // tab pressed\n \t\t\t\t\t\tif (event.shiftKey) { ed.execCommand('Outdent'); } else { ed.execCommand('Indent'); }\n \t\t\t\t\t\tevent.preventDefault();\n \t\t\t\t\t\treturn false;\n \t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// auto smileys parsing\n\t\t\t\t\t\t" . $tinymce_smiley_vars . "\n\t\t\t\t}\n });\n "); add_to_jquery("\n\t\t\t\t\$('#inject').bind('click', function() {\n\t\t\t\t\ttinyMCE.activeEditor.execCommand(\"mceInsertContent\", true, '[b]I am injecting in stuff..[/b]');\n\t\t\t\t\t});\n\t\t\t\t"); break; case 'default': add_to_jquery("\n tinymce.init({\n selector: '#" . $options['input_id'] . "',\n theme: 'modern',\n entity_encoding : 'raw',\n language:'" . $locale['tinymce'] . "',\n setup: function(ed) {\n \t\t\t\t\t// add tabkey listener\n \t\t\t\t\ted.on('keydown', function(event) {\n \t\t\t\t\tif (event.keyCode == 9) { // tab pressed\n \t\t\t\t\t\tif (event.shiftKey) { ed.execCommand('Outdent'); } else { ed.execCommand('Indent'); }\n \t\t\t\t\t\tevent.preventDefault();\n \t\t\t\t\t\treturn false;\n \t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// auto smileys parsing\n\t\t\t\t\t\t" . $tinymce_smiley_vars . "\n\t\t\t\t}\n });\n "); break; } } else { if (!defined('autogrow') && $options['autosize']) { define('autogrow', TRUE); add_to_footer("<script src='" . DYNAMICS . "assets/autosize/jquery.autosize.min.js'></script>"); } if ($options['autosize']) { add_to_jquery("\n\t\t \$('#" . $options['input_id'] . "').autosize();\n\t\t "); } } if ($input_value !== '') { $input_value = html_entity_decode(stripslashes($input_value), ENT_QUOTES, $locale['charset']); $input_value = str_replace("<br />", "", $input_value); } $error_class = ""; if ($defender->inputHasError($input_name)) { $error_class = "has-error "; if (!empty($options['error_text'])) { $new_error_text = $defender->getErrorText($input_name); if (!empty($new_error_text)) { $options['error_text'] = $new_error_text; } addNotice("danger", "<strong>{$title}</strong> - " . $options['error_text']); } } $html = "<div id='" . $options['input_id'] . "-field' class='form-group " . $error_class . $options['class'] . "' " . ($options['inline'] && $options['width'] && !$label ? "style='width: " . $options['width'] . " !important;'" : '') . ">\n"; $html .= $label ? "<label class='control-label " . ($options['inline'] ? "col-xs-12 col-sm-3 col-md-3 col-lg-3 p-l-0" : '') . "' for='" . $options['input_id'] . "'>{$label} " . ($options['required'] == 1 ? "<span class='required'>*</span>" : '') . " " . ($options['tip'] ? "<i class='pointer fa fa-question-circle' title='" . $options['tip'] . "'></i>" : '') . "</label>\n" : ''; $html .= $options['inline'] ? "<div class='col-xs-12 " . ($label ? "col-sm-9 col-md-9 col-lg-9 p-r-0" : "col-sm-12 p-l-0") . "'>\n" : ""; $tab_active = 0; $tab_title = array(); if ($options['preview'] && ($options['type'] == "html" || $options['type'] == "bbcode")) { $tab_title['title'][] = $locale['preview']; $tab_title['id'][] = "prw-" . $options['input_id']; $tab_title['icon'][] = ''; $tab_title['title'][] = $locale['texts']; $tab_title['id'][] = "txt-" . $options['input_id']; $tab_title['icon'][] = ''; $tab_active = tab_active($tab_title, 1); $html .= opentab($tab_title, $tab_active, $options['input_id'] . "-link", "", "editor-wrapper"); $html .= opentabbody($tab_title['title'][1], "txt-" . $options['input_id'], $tab_active); } $html .= $options['type'] == "html" || $options['type'] == "bbcode" ? "<div class='panel panel-default panel-txtarea m-b-0' " . ($options['preview'] ? "style='border-top:0 !important; border-radius:0 !important;'" : '') . ">\n<div class='panel-heading clearfix' style='padding-bottom:0 !important;'>\n" : ''; if ($options['type'] == "bbcode" && $options['form_name']) { $html .= display_bbcodes('90%', $input_name, $options['form_name']); } elseif ($options['type'] == "html" && $options['form_name']) { $html .= display_html($options['form_name'], $input_name, TRUE, TRUE, TRUE, $options['path']); } $html .= $options['type'] == "html" || $options['type'] == "bbcode" ? "</div>\n<div class='panel-body p-0'>\n" : ''; $html .= "<textarea name='{$input_name}' style='width:100%; height:" . $options['height'] . "; " . ($options['no_resize'] ? 'resize: none;' : '') . "' class='form-control p-15 m-0 " . $options['class'] . " " . ($options['autosize'] ? 'animated-height' : '') . " " . ($options['type'] == "html" || $options['type'] == "bbcode" ? "no-shadow no-border" : '') . " textbox ' placeholder='" . $options['placeholder'] . "' id='" . $options['input_id'] . "' " . ($options['deactivate'] ? 'readonly' : '') . ($options['maxlength'] ? "maxlength='" . $options['maxlength'] . "'" : '') . ">" . $input_value . "</textarea>\n"; if ($options['type'] == "html" || $options['type'] == "bbcode") { $html .= "</div>\n<div class='panel-footer clearfix'>\n"; $html .= "<div class='overflow-hide'><small>" . $locale['word_count'] . ": <span id='" . $options['input_id'] . "-wordcount'></span></small></div>"; add_to_jquery("\n\t\tvar init_str = \$('#" . $options['input_id'] . "').val().replace(/<[^>]+>/ig, '').replace(/\\n/g,'').replace(/ /g, '').length;\n\t\t\$('#" . $options['input_id'] . "-wordcount').text(init_str);\n\t\t\$('#" . $options['input_id'] . "').on('input propertychange paste', function() {\n\t\tvar str = \$(this).val().replace(/<[^>]+>/ig, '').replace(/\\n/g,'').replace(/ /g, '').length;\n\t\t\$('#" . $options['input_id'] . "-wordcount').text(str);\n\t\t});\n\t\t"); $html .= "</div>\n</div>\n"; } if ($options['preview'] && ($options['type'] == "bbcode" || $options['type'] == "html")) { $html .= closetabbody(); $html .= opentabbody($tab_title['title'][0], "prw-" . $options['input_id'] . "", $tab_active); $html .= "No Result"; $html .= closetabbody(); $html .= closetab(); add_to_jquery("\n\t\t// preview syntax\n\t\tvar form = \$('#" . $options['form_name'] . "');\n\t\t\$('#tab-prw-" . $options['input_id'] . "').bind('click',function(){\n\t\tvar text = \$('#" . $options['input_id'] . "').val();\n\t\tvar format = '" . ($options['type'] == "bbcode" ? 'bbcode' : 'html') . "';\n\t\tvar data = {\n\t\t\t" . (defined('ADMIN_PANEL') ? "'mode': 'admin', " : "") . "\n\t\t\t'text' : text,\n\t\t\t'editor' : format,\n\t\t\t'url' : '" . $_SERVER['REQUEST_URI'] . "',\n\t\t};\n\t\tvar sendData = form.serialize() + '&' + \$.param(data);\n\t\t\$.ajax({\n\t\t\turl: '" . INCLUDES . "dynamics/assets/preview/preview.ajax.php',\n\t\t\ttype: 'POST',\n\t\t\tdataType: 'html',\n\t\t\tdata : sendData,\n\t\t\tsuccess: function(result){\n\t\t\t//console.log(result);\n\t\t\t\$('#prw-" . $options['input_id'] . "').html(result);\n\t\t\t},\n\t\t\terror: function(result) {\n\t\t\t\tnew PNotify({\n\t\t\t\t\ttitle: '" . $locale['error_preview'] . "',\n\t\t\t\t\ttext: '" . $locale['error_preview_text'] . "',\n\t\t\t\t\ticon: 'notify_icon n-attention',\n\t\t\t\t\tanimation: 'fade',\n\t\t\t\t\twidth: 'auto',\n\t\t\t\t\tdelay: '3000'\n\t\t\t\t});\n\t\t\t}\n\t\t\t});\n\t\t});\n\t\t"); } $html .= $options['required'] == 1 && $defender->inputHasError($input_name) || $defender->inputHasError($input_name) ? "<div id='" . $options['input_id'] . "-help' class='label label-danger p-5 display-inline-block'>" . $options['error_text'] . "</div>" : ""; $html .= $options['inline'] ? "</div>\n" : ''; $html .= "</div>\n"; $defender->add_field_session(array('input_name' => $input_name, 'type' => 'textarea', 'title' => $label, 'id' => $options['input_id'], 'required' => $options['required'], 'safemode' => $options['safemode'], 'error_text' => $options['error_text'])); return $html; }
| can read by viewing the included agpl.txt or online | at www.gnu.org/licenses/agpl.html. Removal of this | copyright header is strictly prohibited without | written permission from the original author(s). +--------------------------------------------------------*/ require_once dirname(__FILE__) . "../../../../../maincore.php"; $text = stripinput($_POST['text']); // filter to relative path conversion echo "<div class='preview-response clearfix p-20'>\n"; // Set get_image paths based on URI. This is ajax request file. It doesn't return a standard BASEDIR. $prefix_ = ""; if (!fusion_get_settings("site_seo") && isset($_POST['url'])) { $uri = pathinfo($_POST['url']); $count = substr($_POST['url'], -1) == "/" ? substr_count($uri['dirname'], "/") : substr_count($uri['dirname'], "/") - 1; $prefix_ = str_repeat("../", $count); foreach (cache_smileys() as $smiley) { $smiley_path = "./" . $prefix_ . "images/smiley/" . $smiley['smiley_image']; \PHPFusion\ImageRepo::setImage("smiley_" . $smiley['smiley_text'], $smiley_path); } } if ($_POST['editor'] == 'html') { $text = parsesmileys(nl2br(html_entity_decode(stripslashes($text)))); if (isset($_POST['mode']) && $_POST['mode'] == 'admin') { $images = str_replace('../../../', '', IMAGES); $text = str_replace(IMAGES, $images, $text); $text = str_replace(IMAGES_N, $images, $text); $text = parse_imageDir($text, $prefix_ . "images/"); } echo html_entity_decode($text, ENT_QUOTES, $locale['charset']) ?: "<p class='text-center'>" . $locale['nopreview'] . "</p>\n"; } elseif ($_POST['editor'] == 'bbcode') { $text = parseubb(parsesmileys($text));
function displaysmileys($textarea, $form = "inputform") { global $smiley_cache; $smileys = ""; $i = 0; if (!$smiley_cache) { cache_smileys(); } if (is_array($smiley_cache) && count($smiley_cache)) { foreach ($smiley_cache as $smiley) { if ($i != 0 && $i % 10 == 0) { $smileys .= "<br />\n"; $i++; } $smileys .= "<img src='" . get_image("smiley_" . $smiley['smiley_text']) . "' alt='" . $smiley['smiley_text'] . "' onclick=\"insertText('" . $textarea . "', '" . $smiley['smiley_code'] . "', '" . $form . "');\" />\n"; } } return $smileys; }
+--------------------------------------------------------+ | Filename: system_images.php | Author: Max "Matonor" Toball +--------------------------------------------------------+ | This program is released as free software under the | Affero GPL license. You can redistribute it and/or | modify it under the terms of this license which you | can read by viewing the included agpl.txt or online | at www.gnu.org/licenses/agpl.html. Removal of this | copyright header is strictly prohibited without | written permission from the original author(s). +--------------------------------------------------------*/ if (!defined("IN_FUSION")) { die("Access Denied"); } cache_smileys(); $smiley_images = array(); if (is_array($smiley_cache) && count($smiley_cache)) { foreach ($smiley_cache as $smiley) { $smiley_images["smiley_" . $smiley['smiley_text']] = IMAGES . "smiley/" . $smiley['smiley_image']; } } $result = dbquery("SELECT news_cat_image, news_cat_name FROM " . DB_NEWS_CATS); $nc_images = array(); while ($data = dbarray($result)) { $nc_images["nc_" . $data['news_cat_name']] = file_exists(IMAGES_NC . $data['news_cat_image']) ? IMAGES_NC . $data['news_cat_image'] : IMAGES . "imagenotfound.jpg"; } $result = dbquery("SELECT admin_title, admin_image FROM " . DB_ADMIN); $ac_images = array(); while ($data = dbarray($result)) { $ac_images["ac_" . $data['admin_title']] = file_exists(ADMIN . "images/" . $data['admin_image']) ? ADMIN . "images/" . $data['admin_image'] : (file_exists($data['admin_image']) ? $data['admin_image'] : ADMIN . "images/infusion_panel.gif");
/** * Fetch and cache all off the imagepaths */ private static function cache() { if (self::$cached) { return; } self::$cached = TRUE; //<editor-fold desc="imagePaths"> // You need to + sign it, so setImage will work. self::$imagePaths += array("arrow" => IMAGES . "arrow.png", "attach" => FORUM . "images/attach.png", "blank" => THEME . "images/blank.gif", "calendar" => IMAGES . "dl_calendar.png", "down" => THEME . "images/down.gif", "download" => IMAGES . "dl_download.png", "downloads" => IMAGES . "dl_downloads1.png", "edit" => IMAGES . "edit.png", "folder" => THEME . "forum/folder.gif", "folderlock" => THEME . "forum/folderlock.gif", "foldernew" => THEME . "forum/foldernew.gif", "forum_edit" => THEME . "forum/edit.gif", "go_first" => IMAGES . "go_first.png", "go_last" => IMAGES . "go_last.png", "go_next" => IMAGES . "go_next.png", "go_previous" => IMAGES . "go_previous.png", "homepage" => IMAGES . "dl_homepage.png", "hot" => FORUM . "images/hot.png", "info" => IMAGES . "dl_info.png", "imagenotfound" => IMAGES . "imagenotfound.jpg", "image_attach" => FORUM . "images/image_attach.png", "left" => THEME . "images/left.gif", "lastpost" => FORUM . "images/lastpost.png", "lastpostnew" => FORUM . "images/lastpostnew.png", "newthread" => THEME . "forum/newthread.gif", "no" => IMAGES . "no.png", "noavatar50" => "noavatar50.png", "noavatar100" => "noavatar100.png", "noavatar150" => "noavatar150.png", "panel_on" => THEME . "images/panel_on.gif", "panel_off" => THEME . "images/panel_off.gif", "pm" => THEME . "forum/pm.gif", "poll_posticon" => FORUM . "images/poll_posticon.gif", "pollbar" => THEME . "images/pollbar.gif", "printer" => IMAGES . "printer.png", "quote" => THEME . "forum/quote.gif", "reply" => THEME . "forum/reply.gif", "right" => THEME . "images/right.gif", "save" => IMAGES . "php-save.png", "screenshot" => IMAGES . "dl_screenshot.png", "star" => IMAGES . "star.png", "statistics" => IMAGES . "dl_stats.png", "stickythread" => THEME . "forum/stickythread.gif", "tick" => IMAGES . "tick.png", "up" => THEME . "images/up.gif", "web" => THEME . "forum/web.gif", "yes" => IMAGES . "yes.png"); //</editor-fold> $installedTables = array('blog' => db_exists('blog'), 'news' => db_exists('news')); $selects = array("SELECT admin_image as image, admin_rights as name, 'ac_' as prefix FROM " . DB_ADMIN); if ($installedTables['blog']) { $selects[] = "SELECT blog_cat_image as image, blog_cat_name as name, 'bl_' as prefix FROM " . DB_BLOG_CATS . " " . (multilang_table("BL") ? " where blog_cat_language='" . LANGUAGE . "'" : ""); } if ($installedTables['news']) { $selects[] = "SELECT news_cat_image as image, news_cat_name as name, 'nc_' as prefix FROM " . DB_NEWS_CATS . " " . (multilang_table("NS") ? " where news_cat_language='" . LANGUAGE . "'" : ""); } //smiley foreach (cache_smileys() as $smiley) { // set image if (empty(self::$imagePaths["smiley_" . $smiley['smiley_text']])) { self::$imagePaths["smiley_" . $smiley['smiley_text']] = IMAGES . "smiley/" . $smiley['smiley_image']; } } $union = implode(' union ', $selects); $result = dbquery($union); while ($data = dbarray($result)) { $image = ""; switch ($data['prefix']) { case 'ac_': $image = file_exists(ADMIN . "images/" . $data['image']) ? ADMIN . "images/" . $data['image'] : (file_exists(INFUSIONS . $data['image']) ? INFUSIONS . $data['image'] : ADMIN . "images/infusion_panel.png"); break; case 'nc_': default: $image = file_exists(IMAGES_NC . $data['image']) ? IMAGES_NC . $data['image'] : IMAGES . "imagenotfound.jpg"; break; case 'bl_': $image = file_exists(IMAGES_BC . $data['image']) ? IMAGES_BC . $data['image'] : IMAGES . "imagenotfound.jpg"; break; } // Set image if (empty(self::$imagePaths[$data['prefix'] . $data['name']])) { self::$imagePaths[$data['prefix'] . $data['name']] = $image; } } }
function parsersssmileys($message) { global $smiley_cache, $settings; if (!preg_match("#(\\[code\\](.*?)\\[/code\\]|\\[geshi=(.*?)\\](.*?)\\[/geshi\\]|\\[php\\](.*?)\\[/php\\])#si", $message)) { if (!$smiley_cache) { cache_smileys(); } if (is_array($smiley_cache) && count($smiley_cache)) { foreach ($smiley_cache as $smiley) { $smiley_code = preg_quote($smiley['smiley_code']); $smiley_image = "<img src='" . $settings['siteurl'] . get_image("smiley_" . $smiley['smiley_text']) . "' alt='" . $smiley['smiley_text'] . "' style='vertical-align:middle;' />"; $message = preg_replace("#{$smiley_code}#si", $smiley_image, $message); } } } return $message; }
/** * Show smiley icons in comments, forum and other post pages * @param string $textarea The name of the textarea * @param string $form The name of the form * @return string */ function displaysmileys($textarea, $form = "inputform") { $smileys = ""; $i = 0; foreach (cache_smileys() as $smiley) { if ($i != 0 && $i % 10 == 0) { $smileys .= "<br />\n"; } $i++; $smileys .= "<img src='" . get_image("smiley_" . $smiley['smiley_text']) . "' alt='" . $smiley['smiley_text'] . "' onclick=\"insertText('" . $textarea . "', '" . $smiley['smiley_code'] . "', '" . $form . "');\" />\n"; } return $smileys; }
function cache_editor_smiley() { $result = dbcount("(bbcode_id)", DB_BBCODES, "bbcode_name='smiley'"); if ($result) { $path = INCLUDES . "bbcodes/bbcode_libs/smiley/smiley.inc.php"; if (file_exists($path)) { require_once $path; $data = cache_smileys(); $counter = count(cache_smileys()); $show_limit = $counter <= 50 ? $counter : 50; $i = 0; $threshold = 30; $more_threshold = 60; foreach ($data as $emoticons) { if ($emoticons['smiley_placement'] == 0 && $i <= $threshold) { $smiley[] = "'" . $emoticons['smiley_code'] . "' : '" . $emoticons['smiley_image'] . "'"; } elseif ($emoticons['smiley_placement'] == 1 || $i > $threshold && $i <= $more_threshold) { $smiley_more[] = "'" . $emoticons['smiley_code'] . "' : '" . $emoticons['smiley_image'] . "'"; } elseif ($emoticons['smiley_placement'] == 2 || $i >= $more_threshold) { $smiley_hidden[] = "'" . $emoticons['smiley_code'] . "' : '" . $emoticons['smiley_image'] . "'"; } $i++; // to ensure only 30 on main, 60 on more and the rest is hidden. } } } $smiley_ = ""; $smiley_more_ = ""; $smiley_hidden_ = ""; if (isset($smiley)) { $smiley_ = ""; foreach ($smiley as $arr => $text) { $smiley_ .= $arr == count($smiley) - 1 ? "{$text}" : "{$text},"; } } if (isset($smiley_more)) { $smiley_more_ = ""; foreach ($smiley_more as $arr => $text) { $smiley_more_ .= $arr == count($smiley) - 1 ? "{$text}" : "{$text},"; } } if (isset($smiley_hidden)) { $smiley_hidden_ = ""; foreach ($smiley_hidden as $arr => $text) { $smiley_hidden .= $arr == count($smiley) - 1 ? "{$text}" : "{$text},"; } } return "\n emoticonsRoot : '" . IMAGES . "emotes/',\n emoticons: {\n dropdown: {\n {$smiley_}\n },\n more: {\n {$smiley_more_}\n },\n hidden: {\n {$smiley_hidden_}\n }\n }\n "; }