source: trunk/admin/include/functions_plugins.inc.php @ 2223

Last change on this file since 2223 was 2135, checked in by rvelices, 17 years ago
  • fix plugin menu link broken with xamp (realpath behaves differently)
  • complete quick search rewriting
    • now we can quote phrases as in google "New York" is not the same as New York
    • user comments not searched anymore (faster)
    • the big full text query does not use joins anymore (faster)
    • related tags not shown on the index page, but now you can see the matching tags and matching categories
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | branch        : BSF (Best So Far)
7// | file          : $Id: functions_plugins.inc.php 2135 2007-10-12 03:27:34Z rvelices $
8// | last update   : $Date: 2007-10-12 03:27:34 +0000 (Fri, 12 Oct 2007) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 2135 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27/* Returns an array of plugins defined in the plugin directory
28*/
29function get_fs_plugins()
30{
31  $plugins = array();
32
33  $dir = opendir(PHPWG_PLUGINS_PATH);
34  while ($file = readdir($dir))
35  {
36    if ($file!='.' and $file!='..')
37    {
38      $path = PHPWG_PLUGINS_PATH.$file;
39      if (is_dir($path) and !is_link($path)
40          and preg_match('/^[a-zA-Z0-9-_]+$/', $file )
41          and file_exists($path.'/main.inc.php')
42          )
43      {
44        $plugin = array(
45            'name'=>$file,
46            'version'=>'0',
47            'uri'=>'',
48            'description'=>'',
49            'author'=>'',
50          );
51        $plg_data = implode( '', file($path.'/main.inc.php') );
52
53        if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )
54        {
55          $plugin['name'] = trim( $val[1] );
56        }
57        if (preg_match("|Version: (.*)|", $plg_data, $val))
58        {
59          $plugin['version'] = trim($val[1]);
60        }
61        if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )
62        {
63          $plugin['uri'] = trim($val[1]);
64        }
65        if ( preg_match("|Description: (.*)|", $plg_data, $val) )
66        {
67          $plugin['description'] = trim($val[1]);
68        }
69        if ( preg_match("|Author: (.*)|", $plg_data, $val) )
70        {
71          $plugin['author'] = trim($val[1]);
72        }
73        if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
74        {
75          $plugin['author uri'] = trim($val[1]);
76        }
77        // IMPORTANT SECURITY !
78        $plugin = array_map('htmlspecialchars', $plugin);
79        $plugins[$file] = $plugin;
80      }
81    }
82  }
83  closedir($dir);
84  return $plugins;
85}
86
87/**
88 * Retrieves an url for a plugin page.
89 * @param string file - php script full name
90 */
91function get_admin_plugin_menu_link($file)
92{
93  global $page;
94  $real_file = realpath($file);
95  $url = get_root_url().'admin.php?page=plugin';
96  if (false!==$real_file)
97  {
98    $real_plugin_path = rtrim(realpath(PHPWG_PLUGINS_PATH), '\\/');
99    $file = substr($real_file, strlen($real_plugin_path)+1);
100    $file = str_replace('\\', '/', $file);//Windows
101    $url .= '&amp;section='.urlencode($file);
102  }
103  else if (isset($page['errors']))
104  {
105    array_push($page['errors'], 'PLUGIN ERROR: "'.$file.'" is not a valid file');
106  }
107  return $url;
108}
109
110?>
Note: See TracBrowser for help on using the repository browser.