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

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

update for Piwigo 2.6 + many code and logical cleaning

File size: 1.2 KB
RevLine 
[23234]1<?php
[26075]2defined('SMILIES_ID') or die('Hacking attempt!');
[23234]3
[26075]4// return an array with available smilies (name and path)
5function get_smilies()
[23234]6{
[26075]7  global $conf;
[23234]8 
[26075]9  if ($handle = opendir(SMILIES_DIR.$conf['smiliessupport']['folder']))
[23234]10  {
[26075]11    $i = 1;
12    while (false !== ($file = readdir($handle)))
[23234]13    {
[26075]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      }
[23234]25    }
[26075]26   
27    closedir($handle);
28    return $smilies;
29  } 
30  else 
31  {
32    return false;
[23234]33  }
34}
35
[26075]36function get_first_file($path, $ext=null)
[23234]37{
[26075]38  $path  = rtrim($path, '/').'/';
39  $handle = opendir($path);
[23234]40 
[26075]41  while (false !== ($file=readdir($handle)))
[23234]42  {
[26075]43    if ($file!='.' and $file!='..' and is_file($path.$file) and
44        (!is_array($ext) or in_array(get_extension($file), $ext))
45      )
[23234]46    {
[26075]47      closedir($handle);
48      return $file;
[23236]49    }
[23234]50  }
51 
[26075]52  closedir($handle);
53  return null;
54}
Note: See TracBrowser for help on using the repository browser.