[3304] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 4 | |
---|
| 5 | function set_smiliessupport_page() |
---|
| 6 | { |
---|
| 7 | global $template, $lang, $pwg_loaded_plugins; |
---|
| 8 | |
---|
| 9 | if (!isset($pwg_loaded_plugins['bbcode_bar'])) |
---|
| 10 | { |
---|
[6298] | 11 | $lang['Comment'] .= SmiliesTable(); |
---|
[3304] | 12 | } |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | function SmiliesTable() |
---|
| 16 | { |
---|
| 17 | global $conf, $template; |
---|
| 18 | |
---|
| 19 | $conf_smiliessupport = explode("," , $conf['smiliessupport']); |
---|
| 20 | |
---|
| 21 | $cnt = 1; |
---|
| 22 | |
---|
| 23 | $template->set_filename('smiliessupport_page', dirname(__FILE__).'/smiliessupport_page.tpl'); |
---|
| 24 | |
---|
| 25 | $template->assign(array('REPRESENTANT' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$conf_smiliessupport[2])); |
---|
| 26 | |
---|
| 27 | if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) |
---|
| 28 | { |
---|
| 29 | while (false !== ($file = readdir($handle))) |
---|
| 30 | { |
---|
| 31 | $trvalue = ''; |
---|
| 32 | |
---|
| 33 | if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) |
---|
| 34 | { |
---|
| 35 | if (( $cnt > 0 ) && ( $cnt % $conf_smiliessupport[1] == 0 )) |
---|
| 36 | { |
---|
| 37 | $trvalue = '</tr><tr>'; |
---|
| 38 | } |
---|
| 39 | $cnt = $cnt + 1; |
---|
| 40 | $template->append('smiliesfiles', |
---|
| 41 | array('PATH' => PHPWG_ROOT_PATH.$conf_smiliessupport[0].'/'.$file, |
---|
| 42 | 'TITLE' => ':'.get_filename_wo_extension($file).':', |
---|
| 43 | 'TR'=>$trvalue)); |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | else |
---|
| 48 | { |
---|
| 49 | array_push($page['errors'], l10n('opendir failed : '.PHPWG_ROOT_PATH.$conf_smiliessupport[0].')' )); |
---|
| 50 | } |
---|
| 51 | return $template->parse('smiliessupport_page', true); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | function SmiliesParse($str) |
---|
| 55 | { |
---|
| 56 | global $conf; |
---|
| 57 | |
---|
| 58 | $conf_smiliessupport = explode("," , $conf['smiliessupport']); |
---|
| 59 | |
---|
| 60 | $def_path = $conf_smiliessupport[0].'/smilies.txt'; |
---|
| 61 | if ( file_exists($def_path) ) |
---|
| 62 | { |
---|
| 63 | $def = file($def_path); |
---|
| 64 | foreach($def as $v) |
---|
| 65 | { |
---|
| 66 | $v = trim($v); |
---|
| 67 | if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches)) |
---|
| 68 | { |
---|
| 69 | $r[] = '/(\A|[\s]+|>)('.preg_quote($matches[1],'/').')([\s]+|[<]|\Z)/ms'; |
---|
| 70 | $s[] = '<img src="'.$conf_smiliessupport[0].'/'.$matches[2].'" '.'alt="$2" title="$2" />'; |
---|
| 71 | $str = preg_replace($r, $s, $str); |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | if ($handle = opendir(PHPWG_ROOT_PATH.$conf_smiliessupport[0])) |
---|
| 76 | { |
---|
| 77 | while (false !== ($file = readdir($handle))) |
---|
| 78 | { |
---|
| 79 | if ($file != "." && $file != ".." && ( get_extension($file) == "gif" || get_extension($file) == "png")) { |
---|
| 80 | $v = ':'.get_filename_wo_extension($file).':'; |
---|
| 81 | $s = '<img src="'.$conf_smiliessupport[0].'/'.$file.'" '.'alt="'.get_filename_wo_extension($file).'" title="'.get_filename_wo_extension($file).'" />'; |
---|
| 82 | $str = str_replace($v, $s, $str); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | return $str; |
---|
| 87 | } |
---|
| 88 | ?> |
---|