source: trunk/plugins/LocalFilesEditor/functions.inc.php @ 2787

Last change on this file since 2787 was 2787, checked in by patdenice, 16 years ago
  • Move upgrade.tpl to admin template.
  • Deactivate all active plugins during upgrade.php.
  • Update Editarea for LocalFiles Editor to version 0.7.2.3 (bonEcho compatibility)
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24/**
25 * returns $code if php syntax is correct
26 * else return false
27 *
28 * @param string php code
29 */
30function eval_syntax($code)
31{
32  $code = str_replace(array('<?php', '?>'), '', $code);
33  if (!@eval('return true;' . $code))
34  {
35    return false;
36  }
37  return '<?php' . $code . '?>';
38}
39
40/**
41 * returns true or false if $str is bool
42  * returns $str if $str is integer
43 * else "$str"
44 *
45 * @param string
46 */
47function editarea_quote($value)
48{
49  switch (gettype($value))
50  {
51    case "boolean":
52      return $value ? 'true' : 'false';
53    case "integer":
54      return $value;
55    default:
56      return '"'.$value.'"';
57  }
58}
59
60/**
61 * returns bak file for restore
62 * @param string
63 */
64function get_bak_file($file)
65{
66  if (get_extension($file) == 'php')
67  {
68    return substr_replace($file, '.bak', strrpos($file , '.'), 0);
69  }
70  else
71  {
72    return $file . '.bak';
73  }
74}
75
76/**
77 * returns dirs and subdirs
78 * retun array
79 * @param string
80 */
81function get_rec_dirs($path='')
82{
83  $options = array();
84  if (is_dir($path))
85  {
86    $fh = opendir($path);
87    while ($file = readdir($fh))
88    {
89      $pathfile = $path . '/' . $file;
90      if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile))
91      {
92        $options[$pathfile] = str_replace(array('./', '/'), array('', ' / '), $pathfile);
93        $options = array_merge($options, get_rec_dirs($pathfile));
94      }
95    }
96    closedir($fh);
97  }
98  return $options;
99}
100
101?>
Note: See TracBrowser for help on using the repository browser.