1<?php 2/************************* 3 Coppermine Photo Gallery 4 ************************ 5 Copyright (c) 2003-2016 Coppermine Dev Team 6 v1.0 originally written by Gregory Demar 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License version 3 10 as published by the Free Software Foundation. 11 12 ******************************************** 13 Coppermine version: 1.6.03 14 $HeadURL$ 15**********************************************/ 16 17// ------------------------------------------------------------------------- // 18// CODE IN THIS MODULE IS TAKEN FROM phpBB // 19// ------------------------------------------------------------------------- // 20 21function get_smilies_table1() 22{ 23 global $lang_smilies_inc_php; 24 25 $smilies_process = array( 26 array(':!:', 'exclaim.gif', $lang_smilies_inc_php['Exclamation']), 27 array(':?:', 'question.gif', $lang_smilies_inc_php['Question']), 28 array(':D', 'biggrin.gif', $lang_smilies_inc_php['Very Happy']), 29 array(':-D', 'biggrin.gif', $lang_smilies_inc_php['Very Happy']), 30 array(':grin:', 'biggrin.gif', $lang_smilies_inc_php['Very Happy']), 31 array(':)', 'smile.gif', $lang_smilies_inc_php['Smile']), 32 array(':-)', 'smile.gif', $lang_smilies_inc_php['Smile']), 33 array(':smile:', 'smile.gif', $lang_smilies_inc_php['Smile']), 34 array(':(', 'sad.gif', $lang_smilies_inc_php['Sad']), 35 array(':-(', 'sad.gif', $lang_smilies_inc_php['Sad']), 36 array(':sad:', 'sad.gif', $lang_smilies_inc_php['Sad']), 37 array(':o', 'surprised.gif', $lang_smilies_inc_php['Surprised']), 38 array(':-o', 'surprised.gif', $lang_smilies_inc_php['Surprised']), 39 array(':eek:', 'surprised.gif', $lang_smilies_inc_php['Surprised']), 40 array(':shock:', 'eek.gif', $lang_smilies_inc_php['Shocked']), 41 array(':?', 'confused.gif', $lang_smilies_inc_php['Confused']), 42 array(':-?', 'confused.gif', $lang_smilies_inc_php['Confused']), 43 array(':???:', 'confused.gif', $lang_smilies_inc_php['Confused']), 44 array('8)', 'cool.gif', $lang_smilies_inc_php['Cool']), 45 array('8-)', 'cool.gif', $lang_smilies_inc_php['Cool']), 46 array(':cool:', 'cool.gif', $lang_smilies_inc_php['Cool']), 47 array(':lol:', 'lol.gif', $lang_smilies_inc_php['Laughing']), 48 array(':x', 'mad.gif', $lang_smilies_inc_php['Mad']), 49 array(':-x', 'mad.gif', $lang_smilies_inc_php['Mad']), 50 array(':mad:', 'mad.gif', $lang_smilies_inc_php['Mad']), 51 array(':P', 'razz.gif', $lang_smilies_inc_php['Razz']), 52 array(':-P', 'razz.gif', $lang_smilies_inc_php['Razz']), 53 array(':razz:', 'razz.gif', $lang_smilies_inc_php['Razz']), 54 array(':oops:', 'redface.gif', $lang_smilies_inc_php['Embarrassed']), 55 array(':cry:', 'cry.gif', $lang_smilies_inc_php['Crying or Very sad']), 56 array(':evil:', 'evil.gif', $lang_smilies_inc_php['Evil or Very Mad']), 57 array(':twisted:', 'twisted.gif', $lang_smilies_inc_php['Twisted Evil']), 58 array(':roll:', 'rolleyes.gif', $lang_smilies_inc_php['Rolling Eyes']), 59 array(':wink:', 'wink.gif', $lang_smilies_inc_php['Wink']), 60 array(';)', 'wink.gif', $lang_smilies_inc_php['Wink']), 61 array(';-)', 'wink.gif', $lang_smilies_inc_php['Wink']), 62 array(':idea:', 'idea.gif', $lang_smilies_inc_php['Idea']), 63 array(':arrow:', 'arrow.gif', $lang_smilies_inc_php['Arrow']), 64 array(':|', 'neutral.gif', $lang_smilies_inc_php['Neutral']), 65 array(':-|', 'neutral.gif', $lang_smilies_inc_php['Neutral']), 66 array(':neutral:', 'neutral.gif', $lang_smilies_inc_php['Neutral']), 67 array(':mrgreen:', 'mrgreen.gif', $lang_smilies_inc_php['Mr. Green']) 68 ); 69 70 $smilies_process = CPGPluginAPI::filter('smilies_process',$smilies_process); 71 return $smilies_process; 72} 73 74function get_smilies_table2() 75{ 76 global $lang_smilies_inc_php; 77 78 $smilies_display = array( 79 array(':lol:', 'lol.gif', $lang_smilies_inc_php['Laughing']), 80 array(':-P', 'razz.gif', $lang_smilies_inc_php['Razz']), 81 array(':-D', 'biggrin.gif', $lang_smilies_inc_php['Very Happy']), 82 array(':-)', 'smile.gif', $lang_smilies_inc_php['Smile']), 83 array(':-|', 'neutral.gif', $lang_smilies_inc_php['Neutral']), 84 array(':-(', 'sad.gif', $lang_smilies_inc_php['Sad']), 85 array(':cry:', 'cry.gif', $lang_smilies_inc_php['Crying or Very sad']), 86 array('8-)', 'cool.gif', $lang_smilies_inc_php['Cool']), 87 array(':-o', 'surprised.gif', $lang_smilies_inc_php['Surprised']), 88 array(':-?', 'confused.gif', $lang_smilies_inc_php['Confused']), 89 array(':oops:', 'redface.gif', $lang_smilies_inc_php['Embarrassed']), 90 array(':shock:', 'eek.gif', $lang_smilies_inc_php['Shocked']), 91 array(':-x', 'mad.gif', $lang_smilies_inc_php['Mad']), 92 array(':roll:', 'rolleyes.gif', $lang_smilies_inc_php['Rolling Eyes']), 93 array(';-)', 'wink.gif', $lang_smilies_inc_php['Wink']), 94 array(':idea:', 'idea.gif', $lang_smilies_inc_php['Idea']), 95 array(':!:', 'exclaim.gif', $lang_smilies_inc_php['Exclamation']), 96 array(':?:', 'question.gif', $lang_smilies_inc_php['Question']) 97 ); 98 99 $smilies_display = CPGPluginAPI::filter('smilies_display',$smilies_display); 100 return $smilies_display; 101} 102// Smilies code ... would this be better tagged on to the end of bbcode.php? 103// Probably so and I'll move it before B2 104 105function process_smilies($message, $url_prefix = '') 106{ 107 static $orig, $repl; 108 109 if (!isset($orig)) { 110 global $db, $board_config,$THEME_DIR; 111 $orig = $repl = array(); 112 113 $smilies = get_smilies_table1(); 114 115 $paths = array($THEME_DIR.'smiles/', 'images/smiles/'); 116 117 foreach ($smilies as $smiley) { 118 $smile_path = file_exists($paths[0].$smiley[1]) ? $paths[0] : $paths[1]; 119 $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smiley[0], "/") . "(?=.\W|\W.|\W$)/"; 120 $repl[] = '<img src="' . $url_prefix . $smile_path . $smiley[1] . '" alt="' . $smiley[2] . '" />'; 121 } 122 } 123 124 if (count($orig)) { 125 $message = preg_replace($orig, $repl, ' ' . $message . ' '); 126 $message = substr($message, 1, -1); 127 } 128 return $message; 129} 130 131// Fill smiley templates (or just the variables) with smileys 132// Either in a window or inline 133 134function generate_smilies($form = 'post', $field = 'message') 135{ 136 global $THEME_DIR, $LINEBREAK; 137 $smilies = get_smilies_table2(); 138 $paths = array($THEME_DIR.'smiles/', 'images/smiles/'); 139 140 if (function_exists('theme_generate_smilies')) { 141 $html = theme_generate_smilies($smilies, $form); 142 } else { 143 144 $html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . $LINEBREAK . ' <tr align="center" valign="middle">' . $LINEBREAK; 145 146 foreach ($smilies as $smiley) { 147 $smile_path = file_exists($paths[0].$smiley[1]) ? $paths[0] : $paths[1]; 148 $caption = $smiley[2] . " " . $smiley[0]; 149 if (file_exists($smile_path . $smiley[1]) == TRUE) { 150 $html .= ' <td width="5%"><img src="' . $smile_path . $smiley[1] . '" alt="' . $caption . '" border="0" style="cursor:pointer;" title="' . $caption . '" onclick="javascript:emot' . $form . '(\'' . $smiley[0] . '\')" /></td>' . $LINEBREAK; 151 } 152 } 153 154 $html .= ' </tr>' . $LINEBREAK . '</table>' . $LINEBREAK; 155 } 156 157 $html .= <<<EOT 158 159<script language="JavaScript" type="text/javascript"> 160<!-- 161function emot$form(text) { 162 text = ' ' + text + ' '; 163 if (document.$form.$field.createTextRange && document.$form.$field.caretPos) { 164 var caretPos = document.$form.$field.caretPos; 165 caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; 166 document.$form.$field.focus(); 167 } else { 168 document.$form.$field.value += text; 169 document.$form.$field.focus(); 170 } 171} 172 173function storeCaret_$form(textEl) { 174 if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); 175} 176//--> 177 178EOT; 179 $html .= '</script>' . $LINEBREAK; 180 return $html; 181} 182 183//EOF