Changeset 26075 for extensions/SmiliesSupport/include/functions.inc.php
- Timestamp:
- Dec 21, 2013, 11:02:21 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmiliesSupport/include/functions.inc.php
r23236 r26075 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 2 defined('SMILIES_ID') or die('Hacking attempt!'); 3 4 // return an array with available smilies (name and path) 5 function get_smilies() 6 { 7 global $conf; 8 9 if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder'])) 10 { 11 $i = 1; 12 while (false !== ($file = readdir($handle))) 13 { 14 if ($file != '.' and $file != '..' and 15 in_array(get_extension($file), $conf['smiliessupport_ext']) 16 ) 17 { 18 $smilies[] = array( 19 'PATH' => SMILIES_DIR.$conf['smiliessupport']['folder'].'/'.$file, 20 'TITLE' => ':'.get_filename_wo_extension($file).':', 21 'TR' => ($i>0 and $i%$conf['smiliessupport']['cols'] == 0) ? '</tr><tr>' : null, 22 ); 23 $i++; 24 } 25 } 26 27 closedir($handle); 28 return $smilies; 29 } 30 else 31 { 32 return false; 33 } 34 } 3 35 4 36 function get_first_file($path, $ext=null) … … 7 39 $handle = opendir($path); 8 40 9 while ( false !== ($file=readdir($handle)))41 while (false !== ($file=readdir($handle))) 10 42 { 11 if ( $file!='.' && $file!='..' && is_file($path.$file) && (!is_array($ext) || in_array(get_extension($file), $ext)) ) 43 if ($file!='.' and $file!='..' and is_file($path.$file) and 44 (!is_array($ext) or in_array(get_extension($file), $ext)) 45 ) 12 46 { 13 47 closedir($handle); … … 19 53 return null; 20 54 } 21 22 function smiliessupport_action()23 {24 if (!isset($_GET['action'])) return;25 if (strpos($_GET['action'], 'ss_') !== 0) return;26 27 global $conf;28 29 $folder = SMILIES_DIR . ltrim($_GET['folder'], '/') . '/';30 31 if ($_GET['action'] == 'ss_reset')32 {33 @unlink($folder.'smilies-custom.txt');34 $_GET['action'] = 'ss_list';35 }36 37 if ($_GET['action'] == 'ss_list')38 {39 $short = array();40 if (file_exists($folder.'smilies-custom.txt'))41 {42 $file = file($folder.'smilies-custom.txt', FILE_IGNORE_NEW_LINES);43 }44 else if (file_exists($folder.'smilies.txt'))45 {46 $file = file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES);47 }48 if (!empty($file))49 {50 foreach ($file as $v)51 {52 if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches))53 {54 $short[ $matches[2] ][] = $matches[1];55 }56 }57 }58 59 $smilies = array();60 $handle = opendir($folder);61 while (false !== ($file = readdir($handle)))62 {63 if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport']['ext']) )64 {65 $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);66 }67 }68 closedir($handle);69 70 echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));71 }72 73 exit;74 }75 76 ?>
Note: See TracChangeset
for help on using the changeset viewer.