source: extensions/SmiliesSupport/include/functions.inc.php @ 23234

Last change on this file since 23234 was 23234, checked in by mistic100, 11 years ago

rewrite admin page
new set from Pidgin

File size: 1.3 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function get_first_file($path, $ext=null)
5{
6  $path  = rtrim($path, '/').'/';
7  $handle = opendir($path);
8 
9  while ( false !== ($file=readdir($handle)) )
10  {
11    if ( $file!='.' && $file!='..' && is_file($path.$file) && (!is_array($ext) || in_array(get_extension($file), $ext)) )
12    {
13      closedir($handle);
14      return $file;
15    }
16  }
17 
18  closedir($handle);
19  return null;
20}
21
22function smiliessupport_get_list()
23{
24  if (!isset($_GET['action']) || $_GET['action']!='ss_preview') return;
25 
26  global $conf;
27 
28  $folder = SMILIES_DIR . ltrim($_GET['folder'], '/') . '/';
29 
30  $short = array();
31  if (file_exists($folder.'smilies.txt'))
32  {
33    foreach (file($folder.'smilies.txt', FILE_IGNORE_NEW_LINES) as $v)
34    {
35      if (preg_match('#^([^\s]+)[\s]+(.+)$#', trim($v), $matches)) 
36      {
37        $short[ $matches[2] ][] = $matches[1];
38      }
39    }
40  }
41
42  $smilies = array();
43  $handle = opendir($folder);
44  while (false !== ($file = readdir($handle)))
45  {
46    if ( $file != '.' && $file != '..' && in_array(get_extension($file), $conf['smiliessupport']['ext']) )
47    {
48      $smilies[$file] = array('title'=>':'.get_filename_wo_extension($file).':', 'file'=>$file, 'short'=>@$short[$file]);
49    }
50  }
51  closedir($handle);
52 
53  echo json_encode(array('path'=>$folder, 'smilies'=>$smilies));
54  exit;
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.