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

Last change on this file since 29580 was 26075, checked in by mistic100, 10 years ago

update for Piwigo 2.6 + many code and logical cleaning

File size: 1.2 KB
Line 
1<?php
2defined('SMILIES_ID') or die('Hacking attempt!');
3
4// return an array with available smilies (name and path)
5function 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}
35
36function get_first_file($path, $ext=null)
37{
38  $path  = rtrim($path, '/').'/';
39  $handle = opendir($path);
40 
41  while (false !== ($file=readdir($handle)))
42  {
43    if ($file!='.' and $file!='..' and is_file($path.$file) and
44        (!is_array($ext) or in_array(get_extension($file), $ext))
45      )
46    {
47      closedir($handle);
48      return $file;
49    }
50  }
51 
52  closedir($handle);
53  return null;
54}
Note: See TracBrowser for help on using the repository browser.