includes/plugins.php
author Dan
Mon, 01 Feb 2010 02:22:54 -0500
changeset 1217 feeb49aa6270
parent 1216 4125e19d3b27
child 1227 bdac73ed481e
permissions -rw-r--r--
Modified paragraph rule to not use recursive parsing; made parsing of code and pre tags much more reliable. Fixes issue 1 (QA: RE-TEST).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
<?php
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
1081
745200a9cc2a Fixed some upgrade bugs; added support for choosing one's own date/time formats; rebrand as 1.1.7
Dan
parents: 1019
diff changeset
     5
 * Copyright (C) 2006-2009 Dan Fuhry
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
 
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    14
/**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    15
 * Class used to handle and process plugin requests and loading. Singleton.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    16
 * @package Enano
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    17
 * @author Dan Fuhry <dan@enanocms.org>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    18
 * @copyright (C) 2006-2008 Enano Project
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    19
 * @license GNU General Public License <http://enanocms.org/Special:GNU_General_Public_License>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    20
 */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    21
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
class pluginLoader {
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    23
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    24
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    25
   * The list of hooks registered.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    26
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    27
   * @access private
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    28
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    29
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
  var $hook_list;
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    31
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    32
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    33
   * The list of plugins that should be loaded. Used only by common.php.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    34
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    35
   * @access private
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    36
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    37
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
  var $load_list;
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    39
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    40
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    41
   * The list of plugins that are loaded currently. This is only used by the loaded() method which in turn is
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    42
   * used by template files with the <!-- IFPLUGIN --> special tag.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    43
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    44
   * @access private
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    45
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    46
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
  var $loaded_plugins;
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    48
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    49
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    50
   * The list of plugins that are always loaded because they're part of the Enano core. This cannot be modified
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    51
   * by any external code because user plugins are loaded after the load_list is calculated. Can be useful in
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    52
   * alternative administration panel frameworks that need the list of system plugins.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    53
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    54
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    55
  
893
b24601274cd2 SpecialUserPrefs: fixed: userprefs_body hook only allowed first loaded plugin to work
Dan
parents: 869
diff changeset
    56
  var $system_plugins = Array('SpecialUserFuncs.php','SpecialUserPrefs.php','SpecialPageFuncs.php','SpecialAdmin.php','SpecialCSS.php','SpecialUpdownload.php','SpecialSearch.php','PrivateMessages.php','SpecialGroups.php', 'SpecialLog.php', 'DemoMode.php');
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    57
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    58
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    59
   * Name kept for compatibility. Effectively a constructor. Calculates the list of plugins that should be loaded
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    60
   * and puts that list in the $load_list property. Plugin developers have absolutely no use for this whatsoever.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    61
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    62
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    63
  function loadAll() 
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    64
  {
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
    65
    global $db, $session, $paths, $template, $plugins; // Common objects
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
    66
    $GLOBALS['plugins_cache'] = array();
568
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    67
    
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    68
    // if we're in an upgrade, just skip this step
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    69
    if ( defined('IN_ENANO_UPGRADE') )
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    70
    {
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    71
      $this->load_list = array();
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    72
      return false;
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    73
    }
3700f7124c2b A bit of UX improvement to upgrade UI; updated readme for 1.1.4
Dan
parents: 560
diff changeset
    74
    
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
    $dir = ENANO_ROOT.'/plugins/';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
    
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
    77
    $plugin_list = $this->get_plugin_list();
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
    78
    $this->load_list = array();
992
34a7fe38d78b Plugins: fixed a final system plugin bug
apache@ktulu.enanocms.org
parents: 979
diff changeset
    79
  
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
    80
    foreach ( $plugin_list as $filename => $data )
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
    81
    {
992
34a7fe38d78b Plugins: fixed a final system plugin bug
apache@ktulu.enanocms.org
parents: 979
diff changeset
    82
      if ( !$data['system plugin'] && ( $data['status'] & PLUGIN_OUTOFDATE || $data['status'] & PLUGIN_DISABLED || !$data['installed'] ) )
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
    83
        continue;
953
323c4cd1aa37 Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
parents: 893
diff changeset
    84
      
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
    85
      $this->load_list[] = $filename;
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
    86
      $this->loaded_plugins[$filename] = $data;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    87
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    88
  }
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    89
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    90
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    91
   * Name kept for compatibility. This method is used to add a new hook into the code somewhere. Plugins are encouraged
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    92
   * to set hooks and hook into other plugins in a fail-safe way, this encourages reuse of code. Returns an array, whose
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    93
   * values should be eval'ed.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    94
   * @example <code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    95
   $code = $plugins->setHook('my_hook_name');
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    96
   foreach ( $code as $cmd )
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    97
   {
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    98
     eval($cmd);
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    99
   }
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   100
   </code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   101
   * @param string The name of the hook.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   102
   * @param array Deprecated.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   103
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   104
  
893
b24601274cd2 SpecialUserPrefs: fixed: userprefs_body hook only allowed first loaded plugin to work
Dan
parents: 869
diff changeset
   105
  function setHook($name, $dont_split = false)
825
9d5c04c1414f Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
parents: 812
diff changeset
   106
  {
9d5c04c1414f Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
parents: 812
diff changeset
   107
    if ( !empty($this->hook_list[$name]) && is_array($this->hook_list[$name]) )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   108
    {
893
b24601274cd2 SpecialUserPrefs: fixed: userprefs_body hook only allowed first loaded plugin to work
Dan
parents: 869
diff changeset
   109
      if ( $dont_split )
b24601274cd2 SpecialUserPrefs: fixed: userprefs_body hook only allowed first loaded plugin to work
Dan
parents: 869
diff changeset
   110
        return $this->hook_list[$name];
b24601274cd2 SpecialUserPrefs: fixed: userprefs_body hook only allowed first loaded plugin to work
Dan
parents: 869
diff changeset
   111
      
379
82b991bee797 Minor and hopefully non-breaking change to plugin loader to possibly double performance at hook points
Dan
parents: 378
diff changeset
   112
      return array(implode("\n", $this->hook_list[$name]));
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   114
    else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   115
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   116
      return Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   117
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   118
  }
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   119
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   120
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   121
   * Attaches to a hook effectively scheduling some code to be run at that point. You should try to keep hooks clean by
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   122
   * making a function that has variables that need to be modified passed by reference.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   123
   * @example Simple example: <code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   124
   $plugins->attachHook('render_wikiformat_pre', '$text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);');
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   125
   </code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   126
   * @example More complicated example: <code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   127
   $plugins->attachHook('render_wikiformat_pre', 'myplugin_parser_ext($text);');
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   128
   
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   129
   // Notice that $text is passed by reference.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   130
   function myplugin_parser_ext(&$text)
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   131
   {
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   132
     $text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   133
   }
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   134
   </code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   135
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   136
  
825
9d5c04c1414f Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
parents: 812
diff changeset
   137
  function attachHook($name, $code)
9d5c04c1414f Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
parents: 812
diff changeset
   138
  {
9d5c04c1414f Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
parents: 812
diff changeset
   139
    if ( !isset($this->hook_list[$name]) )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   140
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   141
      $this->hook_list[$name] = Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   142
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   143
    $this->hook_list[$name][] = $code;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   144
  }
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   145
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   146
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   147
   * Tell whether a plugin is loaded or not.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   148
   * @param string The filename of the plugin
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   149
   * @return bool
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   150
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   151
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   152
  function loaded($plugid)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   153
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   154
    return isset( $this->loaded_plugins[$plugid] );
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   155
  }
507
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   156
  
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   157
  /**
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   158
   * Parses all special comment blocks in a plugin and returns an array in the format:
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   159
   <code>
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   160
   array(
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   161
       0 => array(
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   162
           'block' => 'upgrade',
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   163
           // parsed from the block's parameters section
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   164
             'release_from' => '1.0b1',
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   165
             'release_to' => '1.0b2',
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   166
           'value' => 'foo'
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   167
         ),
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   168
       1 => array(
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   169
           ...
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   170
         )
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   171
     );
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   172
   </code>
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   173
   * @param string Path to plugin file
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   174
   * @param string Optional. The type of block to fetch. If this is specified, only the block type specified will be read, all others will be discarded.
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   175
   * @return array
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   176
   */
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   177
  
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   178
  public static function parse_plugin_blocks($file, $type = false)
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   179
  {
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   180
    if ( !file_exists($file) )
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   181
    {
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   182
      return array();
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   183
    }
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   184
    $blocks = array();
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   185
    $contents = @file_get_contents($file);
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   186
    if ( empty($contents) )
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   187
    {
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   188
      return array();
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   189
    }
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   190
    
1145
21ef2f8feb59 Plugin block parser: Fixed plugin block parsing for plugin files in CRLF format
Dan
parents: 1081
diff changeset
   191
    // The "\r?" in this regular expression is the result of an embarrassing failure during a job related meeting.
21ef2f8feb59 Plugin block parser: Fixed plugin block parsing for plugin files in CRLF format
Dan
parents: 1081
diff changeset
   192
    // I was demoing the authoring of an Enano plugin and simply could not figure out why the plugin would not
21ef2f8feb59 Plugin block parser: Fixed plugin block parsing for plugin files in CRLF format
Dan
parents: 1081
diff changeset
   193
    // show up in the admin panel.
21ef2f8feb59 Plugin block parser: Fixed plugin block parsing for plugin files in CRLF format
Dan
parents: 1081
diff changeset
   194
507
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   195
    $regexp = '#^/\*\*!([a-z0-9_]+)'  // block header and type
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   196
            . '(([\s]+[a-z0-9_]+[\s]*=[\s]*".+?"[\s]*;)*)' // parameters
1145
21ef2f8feb59 Plugin block parser: Fixed plugin block parsing for plugin files in CRLF format
Dan
parents: 1081
diff changeset
   197
            . '[\s]*\*\*' . "\r?\n"      // spacing and header close
21ef2f8feb59 Plugin block parser: Fixed plugin block parsing for plugin files in CRLF format
Dan
parents: 1081
diff changeset
   198
            . '([\w\W]+?)' . "\r?\n"     // value
507
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   199
            . '\*\*!\*/'              // closing comment
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   200
            . '#m';
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   201
            
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   202
    // Match out all blocks
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   203
    $results = preg_match_all($regexp, $contents, $blocks);
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   204
    
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   205
    $return = array();
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   206
    foreach ( $blocks[0] as $i => $_ )
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   207
    {
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   208
      if ( is_string($type) && $blocks[1][$i] !== $type )
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   209
        continue;
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   210
      
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   211
      $value =& $blocks[4][$i];
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   212
      // parse includes
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   213
      preg_match_all('/^!include [\'"]?(.+?)[\'"]?$/m', $value, $includes);
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   214
      foreach ( $includes[0] as $i => $replace )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   215
      {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   216
        $filename = ENANO_ROOT . '/' . $includes[1][$i];
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   217
        if ( @file_exists( $filename ) && @is_readable( $filename ) )
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   218
        {
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   219
          $contents = @file_get_contents($filename);
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   220
          $value = str_replace_once($replace, $contents, $value);
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   221
        }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   222
      }
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   223
      
507
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   224
      $el = self::parse_vars($blocks[2][$i]);
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   225
      $el['block'] = $blocks[1][$i];
519
94214ec0871c Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents: 507
diff changeset
   226
      $el['value'] = $value;
507
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   227
      $return[] = $el;
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   228
    }
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   229
    
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   230
    return $return;
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   231
  }
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   232
  
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   233
  private static function parse_vars($var_block)
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   234
  {
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   235
    preg_match_all('/[\s]+([a-z0-9_]+)[\s]*=[\s]*"(.+?)";/', $var_block, $matches);
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   236
    $return = array();
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   237
    foreach ( $matches[0] as $i => $_ )
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   238
    {
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   239
      $return[ $matches[1][$i] ] = $matches[2][$i];
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   240
    }
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   241
    return $return;
586fd7d3202d Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
parents: 464
diff changeset
   242
  }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   243
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   244
  /**
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   245
   * Reads all plugins in the filesystem and cross-references them with the database, providing a very complete summary of plugins
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   246
   * on the site.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   247
   * @param array If specified, will restrict scanned files to this list. Defaults to null, which means all PHP files will be scanned.
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   248
   * @param bool If true, allows using cached information. Defaults to true.
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   249
   * @return array
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   250
   */
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   251
  
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   252
  function get_plugin_list($restrict = null, $use_cache = true)
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   253
  {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   254
    global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   255
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   256
    // Scan all plugins
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   257
    $plugin_list = array();
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   258
    $ta = 0;
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   259
    // won't load twice (failsafe automatic skip)
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   260
    $this->load_plugins_cache();
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   261
    global $plugins_cache;
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   262
    if ( $use_cache && !empty($plugins_cache) )
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   263
    {
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   264
      return $plugins_cache;
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   265
    }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   266
    else
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   267
    {
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   268
      // blank array - effectively skips importing the cache
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   269
      $plugins_cache = array();
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   270
    }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   271
    
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   272
    // List all plugins
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   273
    if ( $dirh = @opendir( ENANO_ROOT . '/plugins' ) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   274
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   275
      while ( $dh = @readdir($dirh) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   276
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   277
        if ( !preg_match('/\.php$/i', $dh) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   278
          continue;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   279
        
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   280
        if ( is_array($restrict) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   281
          if ( !in_array($dh, $restrict) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   282
            continue;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   283
          
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   284
        // it's a PHP file, attempt to read metadata
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   285
        $fullpath = ENANO_ROOT . "/plugins/$dh";
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   286
        $plugin_meta = $this->read_plugin_headers($fullpath, $use_cache);
593
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   287
        
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   288
        if ( is_array($plugin_meta) )
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   289
        {
593
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   290
          // all checks passed
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   291
          $plugin_list[$dh] = $plugin_meta;
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   292
        }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   293
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   294
    }
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   295
    
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   296
    // Populate with additional metadata from database
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   297
    $q = $db->sql_query('SELECT plugin_id, plugin_filename, plugin_version, plugin_flags FROM ' . table_prefix . 'plugins;');
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   298
    if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   299
      $db->_die();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   300
    while ( $row = $db->fetchrow() )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   301
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   302
      if ( !isset($plugin_list[ $row['plugin_filename'] ]) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   303
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   304
        // missing plugin file, don't report (for now)
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   305
        continue;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   306
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   307
      $filename =& $row['plugin_filename'];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   308
      $plugin_list[$filename]['installed'] = true;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   309
      $plugin_list[$filename]['status'] = PLUGIN_INSTALLED;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   310
      $plugin_list[$filename]['plugin id'] = $row['plugin_id'];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   311
      if ( $row['plugin_version'] != $plugin_list[$filename]['version'] )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   312
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   313
        $plugin_list[$filename]['status'] |= PLUGIN_OUTOFDATE;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   314
        $plugin_list[$filename]['version installed'] = $row['plugin_version'];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   315
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   316
      if ( $row['plugin_flags'] & PLUGIN_DISABLED )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   317
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   318
        $plugin_list[$filename]['status'] |= PLUGIN_DISABLED;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   319
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   320
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   321
    $db->free_result();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   322
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   323
    // sort it all out by filename
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   324
    ksort($plugin_list);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   325
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   326
    // done
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   327
    return $plugin_list;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   328
  }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   329
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   330
  /**
593
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   331
   * Retrieves the metadata block from a plugin file
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   332
   * @param string Path to plugin file (full path)
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   333
   * @return array
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   334
   */
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   335
  
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   336
  function read_plugin_headers($fullpath, $use_cache = true)
593
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   337
  {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   338
    global $plugins_cache;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   339
    $dh = basename($fullpath);
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   340
    
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   341
    // first can we use cached info?
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   342
    if ( isset($plugins_cache[$dh]) && $plugins_cache[$dh]['file md5'] === $this->md5_header($fullpath) )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   343
    {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   344
      $plugin_meta = $plugins_cache[$dh];
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   345
    }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   346
    else
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   347
    {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   348
      // the cache is out of date if we reached here -- regenerate
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   349
      if ( $use_cache )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   350
        $this->generate_plugins_cache();
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   351
      
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   352
      // pass 1: try to read a !info block
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   353
      $blockdata = $this->parse_plugin_blocks($fullpath, 'info');
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   354
      if ( empty($blockdata) )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   355
      {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   356
        // no !info block, check for old header
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   357
        $fh = @fopen($fullpath, 'r');
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   358
        if ( !$fh )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   359
          // can't read, bail out
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   360
          return false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   361
        $plugin_data = array();
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   362
        for ( $i = 0; $i < 8; $i++ )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   363
        {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   364
          $plugin_data[] = @fgets($fh, 8096);
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   365
        }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   366
        // close our file handle
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   367
        fclose($fh);
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   368
        // is the header correct?
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   369
        if ( trim($plugin_data[0]) != '<?php' || trim($plugin_data[1]) != '/*' )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   370
        {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   371
          // nope. get out.
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   372
          return false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   373
        }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   374
        // parse all the variables
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   375
        $plugin_meta = array();
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   376
        for ( $i = 2; $i <= 7; $i++ )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   377
        {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   378
          if ( !preg_match('/^([A-z0-9 ]+?): (.+?)$/', trim($plugin_data[$i]), $match) )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   379
            return false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   380
          $plugin_meta[ strtolower($match[1]) ] = $match[2];
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   381
        }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   382
      }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   383
      else
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   384
      {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   385
        // parse JSON block
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   386
        $plugin_data =& $blockdata[0]['value'];
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   387
        $plugin_data = enano_clean_json(enano_trim_json($plugin_data));
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   388
        try
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   389
        {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   390
          $plugin_meta_uc = enano_json_decode($plugin_data);
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   391
        }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   392
        catch ( Exception $e )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   393
        {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   394
          return false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   395
        }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   396
        // convert all the keys to lowercase
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   397
        $plugin_meta = array();
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   398
        foreach ( $plugin_meta_uc as $key => $value )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   399
        {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   400
          $plugin_meta[ strtolower($key) ] = $value;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   401
        }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   402
      }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   403
    }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   404
    if ( !isset($plugin_meta) || !is_array(@$plugin_meta) )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   405
    {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   406
      // parsing didn't work.
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   407
      return false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   408
    }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   409
    // check for required keys
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   410
    $required_keys = array('plugin name', 'plugin uri', 'description', 'author', 'version', 'author uri');
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   411
    foreach ( $required_keys as $key )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   412
    {
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   413
      if ( !isset($plugin_meta[$key]) )
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   414
        // not set, skip this plugin
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   415
        return false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   416
    }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   417
    // decide if it's a system plugin
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   418
    $plugin_meta['system plugin'] = in_array($dh, $this->system_plugins);
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   419
    // reset installed variable
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   420
    $plugin_meta['installed'] = false;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   421
    $plugin_meta['status'] = 0;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   422
    
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   423
    return $plugin_meta;
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   424
  }
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   425
  
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   426
  
4f9bec0d65c1 More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents: 590
diff changeset
   427
  /**
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   428
   * Attempts to cache plugin information in a file to speed fetching.
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   429
   */
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   430
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   431
  function generate_plugins_cache()
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   432
  {
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   433
    if ( getConfig('cache_thumbs') != '1' )
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   434
      return;
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   435
    
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   436
    // fetch the most current info
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   437
    $plugin_info = $this->get_plugin_list(null, false);
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   438
    foreach ( $plugin_info as $plugin => &$info )
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   439
    {
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   440
      $info['file md5'] = $this->md5_header(ENANO_ROOT . "/plugins/$plugin");
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   441
    }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   442
    
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   443
    $this->update_plugins_cache($plugin_info);
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   444
    $GLOBALS['plugins_cache'] = $plugin_info;
613
c08670a77871 Completed work (we hope) on CacheManager admin page
Dan
parents: 607
diff changeset
   445
    
c08670a77871 Completed work (we hope) on CacheManager admin page
Dan
parents: 607
diff changeset
   446
    return true;
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   447
  }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   448
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   449
  /**
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   450
   * Writes an information array to the cache file.
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   451
   * @param array
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   452
   * @access private
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   453
   */
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   454
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   455
  function update_plugins_cache($plugin_info)
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   456
  {
607
935f3799b654 First stab at cache management backend. Everything seems to have been tested and working so far, but a number of things require a more specialized cache and can't go through the framework (e.g. user ranks which use references to map usernames to user IDs)
Dan
parents: 601
diff changeset
   457
    global $cache;
769
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   458
    try
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   459
    {
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   460
      $result = $cache->store('plugins', $plugin_info, -1);
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   461
    }
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   462
    catch ( Exception $e )
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   463
    {
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   464
      return false;
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   465
    }
1946d845bb25 Fixed: update_plugins_cache() is now tolerant of write errors
Dan
parents: 724
diff changeset
   466
    return $result;
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   467
  }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   468
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   469
  /**
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   470
   * Loads the plugins cache if any.
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   471
   */
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   472
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   473
  function load_plugins_cache()
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   474
  {
607
935f3799b654 First stab at cache management backend. Everything seems to have been tested and working so far, but a number of things require a more specialized cache and can't go through the framework (e.g. user ranks which use references to map usernames to user IDs)
Dan
parents: 601
diff changeset
   475
    global $cache;
935f3799b654 First stab at cache management backend. Everything seems to have been tested and working so far, but a number of things require a more specialized cache and can't go through the framework (e.g. user ranks which use references to map usernames to user IDs)
Dan
parents: 601
diff changeset
   476
    if ( $data = $cache->fetch('plugins') )
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   477
    {
607
935f3799b654 First stab at cache management backend. Everything seems to have been tested and working so far, but a number of things require a more specialized cache and can't go through the framework (e.g. user ranks which use references to map usernames to user IDs)
Dan
parents: 601
diff changeset
   478
      $GLOBALS['plugins_cache'] = $data;
590
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   479
    }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   480
  }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   481
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   482
  /**
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   483
   * Calculates the MD5 sum of the first 10 lines of a file. Useful for caching plugin header information.
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   484
   * @param string File
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   485
   * @return string
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   486
   */
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   487
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   488
  function md5_header($file)
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   489
  {
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   490
    $fh = @fopen($file, 'r');
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   491
    if ( !$fh )
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   492
      return false;
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   493
    $i = 0;
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   494
    $h = '';
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   495
    while ( $i < 10 )
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   496
    {
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   497
      $line = fgets($fh, 8096);
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   498
      $h .= $line . "\n";
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   499
      $i++;
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   500
    }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   501
    fclose($fh);
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   502
    return md5($h);
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   503
  }
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   504
  
03a60844c7c5 Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
parents: 568
diff changeset
   505
  /**
869
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   506
   * Determines if a file is an authentication extension by looking at the file contents.
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   507
   * @param string Plugin filename
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   508
   * @return bool
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   509
   */
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   510
  
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   511
  function is_file_auth_plugin($filename)
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   512
  {
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   513
    $filename = ENANO_ROOT . '/plugins/' . $filename;
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   514
    if ( !file_exists($filename) )
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   515
      return false;
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   516
    
975
bff25c6113ae Cut out two queries per page with plugin loader routine
Dan
parents: 953
diff changeset
   517
    $info = $this->read_plugin_headers($filename);
869
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   518
    if ( isset($info['auth plugin']) )
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   519
      return true;
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   520
    
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   521
    $contents = @file_get_contents($filename);
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   522
    if ( strstr($contents, 'login_process_userdata_json') )
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   523
      return true;
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   524
    
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   525
    return false;
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   526
  }
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   527
  
58bc29c14a4d Plugins: Added checks and additional warning for authentication plugins.
Dan
parents: 846
diff changeset
   528
  /**
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   529
   * Installs a plugin.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   530
   * @param string Filename of plugin.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   531
   * @param array The list of plugins as output by pluginLoader::get_plugin_list(). If not passed, the function is called, possibly wasting time.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   532
   * @return array JSON-formatted but not encoded response
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   533
   */
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   534
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   535
  function install_plugin($filename, $plugin_list = null)
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   536
  {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   537
    global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   538
    global $lang;
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
   539
    global $cache;
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   540
    
675
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   541
    if ( defined('ENANO_DEMO_MODE') )
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   542
    {
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   543
      return array(
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   544
          'mode' => 'error',
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   545
          'error' => $lang->get('acppl_err_demo_mode')
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   546
        );
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   547
    }
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   548
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   549
    if ( !$plugin_list )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   550
      $plugin_list = $this->get_plugin_list();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   551
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   552
    // we're gonna need this
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   553
    require_once ( ENANO_ROOT . '/includes/sql_parse.php' );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   554
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   555
    switch ( true ): case true:
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   556
      
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   557
    // is the plugin in the directory and awaiting installation?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   558
    if ( !isset($plugin_list[$filename]) || (
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   559
        isset($plugin_list[$filename]) && $plugin_list[$filename]['installed']
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   560
      ))
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   561
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   562
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   563
        'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   564
        'error' => 'Invalid plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   565
        'debug' => $filename
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   566
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   567
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   568
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   569
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   570
    $dataset =& $plugin_list[$filename];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   571
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   572
    // load up the installer schema
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   573
    $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'install' );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   574
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   575
    $sql = array();
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   576
    global $dbdriver;
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   577
    if ( !empty($schema) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   578
    {
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   579
      // Decide which schema to use
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   580
      $use_schema = false;
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   581
      foreach ( $schema as $current_schema )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   582
      {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   583
        if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   584
        {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   585
          $use_schema =& $current_schema['value'];
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   586
          break;
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   587
        }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   588
      }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   589
      if ( !$use_schema )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   590
      {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   591
        if ( !isset($schema[0]['dbms']) )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   592
        {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   593
          $use_schema =& $schema[0]['value'];
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   594
        }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   595
        else
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   596
        {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   597
          $return = array(
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   598
            'mode' => 'error',
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   599
            'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name))
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   600
          );
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   601
          break;
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   602
        }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   603
      }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   604
      // parse SQL
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   605
      $parser = new SQL_Parser($use_schema, true);
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   606
      $parser->assign_vars(array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   607
        'TABLE_PREFIX' => table_prefix
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   608
        ));
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   609
      $sql = $parser->parse();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   610
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   611
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   612
    // schema is final, check queries
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   613
    foreach ( $sql as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   614
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   615
      if ( !$db->check_query($query) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   616
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   617
        // aww crap, a query is bad
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   618
        $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   619
          'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
   620
          'error' => $lang->get('acppl_err_upgrade_bad_query'),
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   621
        );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   622
        break 2;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   623
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   624
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   625
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   626
    // this is it, perform installation
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   627
    foreach ( $sql as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   628
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   629
      if ( substr($query, 0, 1) == '@' )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   630
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   631
        $query = substr($query, 1);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   632
        $db->sql_query($query);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   633
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   634
      else
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   635
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   636
        if ( !$db->sql_query($query) )
1216
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   637
        {
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   638
          $return = array(
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   639
              'mode' => 'error',
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   640
              'error' => "[SQL] " . $db->sql_error()
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   641
            );
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   642
          break 2;
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   643
        }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   644
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   645
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   646
    
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   647
    // log action
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   648
    $time        = time();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   649
    $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   650
    $username_db = $db->escape($session->username);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   651
    $file_db     = $db->escape($filename);
1216
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   652
    $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, author_uid, page_text) VALUES\n"
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   653
                      . "  ('security', 'plugin_install', $time, '$ip_db', '$username_db', $session->user_id, '$file_db');");
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   654
    if ( !$q )
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   655
      $db->_die();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   656
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   657
    // register plugin
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   658
    $version_db = $db->escape($dataset['version']);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   659
    $filename_db = $db->escape($filename);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   660
    $flags = PLUGIN_INSTALLED;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   661
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   662
    $q = $db->sql_query('INSERT INTO ' . table_prefix . "plugins ( plugin_version, plugin_filename, plugin_flags )\n"
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   663
                      . "  VALUES ( '$version_db', '$filename_db', $flags );");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   664
    if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   665
      $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   666
    
846
0d2d0dfbe443 Plugin backend: bugfix: installing a plugin should now properly import its strings
Dan
parents: 832
diff changeset
   667
    $plugin_list[$filename]['installed'] = true;
0d2d0dfbe443 Plugin backend: bugfix: installing a plugin should now properly import its strings
Dan
parents: 832
diff changeset
   668
    $this->reimport_plugin_strings($filename, $plugin_list);
0d2d0dfbe443 Plugin backend: bugfix: installing a plugin should now properly import its strings
Dan
parents: 832
diff changeset
   669
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   670
    $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   671
      'success' => true
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   672
    );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   673
    
832
7152ca0a0ce9 Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
parents: 825
diff changeset
   674
    endswitch;
812
68060328e9c6 Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
parents: 808
diff changeset
   675
    
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
   676
    $cache->purge('plugins');
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 791
diff changeset
   677
    $cache->purge('page_meta');
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 791
diff changeset
   678
    $cache->purge('anon_sidebar');
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
   679
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   680
    return $return;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   681
  }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   682
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   683
  /**
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   684
   * Uninstalls a plugin, removing it completely from the database and calling any custom uninstallation code the plugin specifies.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   685
   * @param string Filename of plugin.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   686
   * @param array The list of plugins as output by pluginLoader::get_plugin_list(). If not passed, the function is called, possibly wasting time.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   687
   * @return array JSON-formatted but not encoded response
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   688
   */
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   689
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   690
  function uninstall_plugin($filename, $plugin_list = null)
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   691
  {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   692
    global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   693
    global $lang;
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   694
    global $cache;
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   695
    
675
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   696
    if ( defined('ENANO_DEMO_MODE') )
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   697
    {
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   698
      return array(
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   699
          'mode' => 'error',
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   700
          'error' => $lang->get('acppl_err_demo_mode')
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   701
        );
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   702
    }
872f0048dd81 [Demo Security] Fixed plugin manager ignoring lockdown settings in demo mode
Dan
parents: 613
diff changeset
   703
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   704
    if ( !$plugin_list )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   705
      $plugin_list = $this->get_plugin_list();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   706
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   707
    // we're gonna need this
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   708
    require_once ( ENANO_ROOT . '/includes/sql_parse.php' );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   709
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   710
    switch ( true ): case true:
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   711
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   712
    // is the plugin in the directory and already installed?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   713
    if ( !isset($plugin_list[$filename]) || (
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   714
        isset($plugin_list[$filename]) && !$plugin_list[$filename]['installed']
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   715
      ))
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   716
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   717
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   718
        'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   719
        'error' => 'Invalid plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   720
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   721
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   722
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   723
    // get plugin id
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   724
    $dataset =& $plugin_list[$filename];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   725
    if ( empty($dataset['plugin id']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   726
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   727
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   728
        'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   729
        'error' => 'Couldn\'t retrieve plugin ID.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   730
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   731
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   732
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   733
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   734
    // load up the installer schema
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   735
    $schema = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'uninstall' );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   736
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   737
    $sql = array();
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   738
    global $dbdriver;
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   739
    if ( !empty($schema) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   740
    {
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   741
      // Decide which schema to use
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   742
      $use_schema = false;
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   743
      foreach ( $schema as $current_schema )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   744
      {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   745
        if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   746
        {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   747
          $use_schema =& $current_schema['value'];
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   748
          break;
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   749
        }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   750
      }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   751
      if ( !$use_schema )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   752
      {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   753
        if ( !isset($schema[0]['dbms']) )
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   754
        {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   755
          $use_schema =& $schema[0]['value'];
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   756
        }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   757
        else
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   758
        {
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   759
          $return = array(
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   760
            'mode' => 'error',
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   761
            'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name))
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   762
          );
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   763
          break;
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   764
        }
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   765
      }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   766
      // parse SQL
808
97cd1a3229d0 Plugin manager: added support for having specific install and uninstall blocks per DBMS
Dan
parents: 801
diff changeset
   767
      $parser = new SQL_Parser($use_schema, true);
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   768
      $parser->assign_vars(array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   769
        'TABLE_PREFIX' => table_prefix
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   770
        ));
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   771
      $sql = $parser->parse();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   772
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   773
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   774
    // schema is final, check queries
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   775
    foreach ( $sql as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   776
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   777
      if ( !$db->check_query($query) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   778
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   779
        // aww crap, a query is bad
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   780
        $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   781
          'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
   782
          'error' => $lang->get('acppl_err_upgrade_bad_query'),
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   783
        );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   784
        break 2;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   785
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   786
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   787
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   788
    // this is it, perform uninstallation
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   789
    foreach ( $sql as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   790
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   791
      if ( substr($query, 0, 1) == '@' )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   792
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   793
        $query = substr($query, 1);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   794
        $db->sql_query($query);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   795
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   796
      else
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   797
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   798
        if ( !$db->sql_query($query) )
1216
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   799
        {
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   800
          $return = array(
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   801
              'mode' => 'error',
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   802
              'error' => "[SQL] " . $db->sql_error()
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   803
            );
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   804
          break 2;
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   805
        }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   806
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   807
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   808
    
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   809
    // log action
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   810
    $time        = time();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   811
    $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   812
    $username_db = $db->escape($session->username);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   813
    $file_db     = $db->escape($filename);
1216
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   814
    $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, author_uid, page_text) VALUES\n"
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
   815
                      . "  ('security', 'plugin_uninstall', $time, '$ip_db', '$username_db', $session->user_id, '$file_db');");
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   816
    if ( !$q )
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   817
      $db->_die();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
   818
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   819
    // deregister plugin
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   820
    $q = $db->sql_query('DELETE FROM ' . table_prefix . "plugins WHERE plugin_id = {$dataset['plugin id']};");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   821
    if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   822
      $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   823
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   824
    $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   825
      'success' => true
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   826
    );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   827
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   828
    endswitch;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   829
    
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
   830
    $cache->purge('plugins');
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 791
diff changeset
   831
    $cache->purge('page_meta');
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 791
diff changeset
   832
    $cache->purge('anon_sidebar');
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
   833
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   834
    return $return;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   835
  }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   836
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   837
  /**
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   838
   * Very intelligently upgrades a plugin to the version specified in the filesystem.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   839
   * @param string Filename of plugin.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   840
   * @param array The list of plugins as output by pluginLoader::get_plugin_list(). If not passed, the function is called, possibly wasting time.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   841
   * @return array JSON-formatted but not encoded response
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   842
   */
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   843
  
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   844
  function upgrade_plugin($filename, $plugin_list = null)
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   845
  {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   846
    global $db, $session, $paths, $template, $plugins; // Common objects
1014
930c1fdd3e9f Fixed missing global $cache; in $plugins->upgrade_plugin();
Dan
parents: 992
diff changeset
   847
    global $lang, $cache;
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   848
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   849
    if ( !$plugin_list )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   850
      $plugin_list = $this->get_plugin_list();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   851
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   852
    // we're gonna need this
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   853
    require_once ( ENANO_ROOT . '/includes/sql_parse.php' );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   854
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   855
    switch ( true ): case true:
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   856
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   857
    // is the plugin in the directory and already installed?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   858
    if ( !isset($plugin_list[$filename]) || (
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   859
        isset($plugin_list[$filename]) && !$plugin_list[$filename]['installed']
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   860
      ))
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   861
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   862
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   863
        'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   864
        'error' => 'Invalid plugin specified.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   865
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   866
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   867
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   868
    // get plugin id
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   869
    $dataset =& $plugin_list[$filename];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   870
    if ( empty($dataset['plugin id']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   871
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   872
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   873
        'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   874
        'error' => 'Couldn\'t retrieve plugin ID.',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   875
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   876
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   877
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   878
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   879
    //
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   880
    // Here we go with the main upgrade process. This is the same logic that the
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   881
    // Enano official upgrader uses, in fact it's the same SQL parser. We need
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   882
    // list of all versions of the plugin to continue, though.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   883
    //
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   884
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   885
    if ( !isset($dataset['version list']) || ( isset($dataset['version list']) && !is_array($dataset['version list']) ) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   886
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   887
      // no version list - update the version number but leave the rest alone
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   888
      $version = $db->escape($dataset['version']);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   889
      $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_version = '$version' WHERE plugin_id = {$dataset['plugin id']};");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   890
      if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   891
        $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   892
      
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   893
      // send an error and notify the user even though it was technically a success
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   894
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   895
        'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
   896
        'error' => $lang->get('acppl_err_upgrade_not_supported'),
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   897
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   898
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   899
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   900
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   901
    // build target list
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   902
    $versions  = $dataset['version list'];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   903
    $indices   = array_flip($versions);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   904
    $installed = $dataset['version installed'];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   905
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   906
    // is the current version upgradeable?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   907
    if ( !isset($indices[$installed]) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   908
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   909
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   910
        'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
   911
        'error' => $lang->get('acppl_err_upgrade_bad_version'),
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   912
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   913
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   914
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   915
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   916
    // does the plugin support upgrading to its own version?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   917
    if ( !isset($indices[$installed]) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   918
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   919
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   920
        'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
   921
        'error' => $lang->get('acppl_err_upgrade_bad_target_version'),
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   922
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   923
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   924
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   925
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   926
    // list out which versions to do
1019
ea039091d154 Whoops, plugin upgrades got broken
Dan
parents: 1014
diff changeset
   927
    $index_start = @$indices[$installed];
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   928
    $index_stop  = @$indices[$dataset['version']];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   929
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   930
    // Are we trying to go backwards?
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   931
    if ( $index_stop <= $index_start )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   932
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   933
      $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   934
        'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
   935
        'error' => $lang->get('acppl_err_upgrade_to_older'),
1019
ea039091d154 Whoops, plugin upgrades got broken
Dan
parents: 1014
diff changeset
   936
        // 'debug' => "going from $installed ($index_start) to {$dataset['version']} ($index_stop)"
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   937
      );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   938
      break;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   939
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   940
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   941
    // build the list of version sets
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   942
    $ver_previous = $installed;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   943
    $targets = array();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   944
    for ( $i = $index_start; $i <= $index_stop; $i++ )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   945
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   946
      $targets[] = array($ver_previous, $versions[$i]);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   947
      $ver_previous = $versions[$i];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   948
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   949
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   950
    // parse out upgrade sections in plugin file
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   951
    $plugin_blocks = $this->parse_plugin_blocks( ENANO_ROOT . '/plugins/' . $filename, 'upgrade' );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   952
    $sql_blocks = array();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   953
    foreach ( $plugin_blocks as $block )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   954
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   955
      if ( !isset($block['from']) || !isset($block['to']) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   956
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   957
        continue;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   958
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   959
      $key = "{$block['from']} TO {$block['to']}";
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   960
      $sql_blocks[$key] = $block['value'];
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   961
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   962
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   963
    // do version list check
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   964
    // for now we won't fret if a specific version set isn't found, we'll just
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   965
    // not do that version and assume there were no DB changes.
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   966
    foreach ( $targets as $i => $target )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   967
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   968
      list($from, $to) = $target;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   969
      $key = "$from TO $to";
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   970
      if ( !isset($sql_blocks[$key]) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   971
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   972
        unset($targets[$i]);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   973
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   974
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   975
    $targets = array_values($targets);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   976
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   977
    // parse and finalize schema
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   978
    $schema = array();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   979
    foreach ( $targets as $i => $target )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   980
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   981
      list($from, $to) = $target;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   982
      $key = "$from TO $to";
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   983
      try
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   984
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   985
        $parser = new SQL_Parser($sql_blocks[$key], true);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   986
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   987
      catch ( Exception $e )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   988
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   989
        $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   990
          'mode' => 'error',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   991
          'error' => 'SQL parser init exception',
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   992
          'debug' => "$e"
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   993
        );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   994
        break 2;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   995
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   996
      $parser->assign_vars(array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   997
        'TABLE_PREFIX' => table_prefix
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   998
        ));
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
   999
      $parsed = $parser->parse();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1000
      foreach ( $parsed as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1001
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1002
        $schema[] = $query;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1003
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1004
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1005
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1006
    // schema is final, check queries
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1007
    foreach ( $schema as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1008
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1009
      if ( !$db->check_query($query) )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1010
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1011
        // aww crap, a query is bad
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1012
        $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1013
          'mode' => 'error',
528
43535769970b Fixed some bad language string references in plugin management API
Dan
parents: 527
diff changeset
  1014
          'error' => $lang->get('acppl_err_upgrade_bad_query'),
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1015
        );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1016
        break 2;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1017
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1018
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1019
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1020
    // this is it, perform upgrade
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1021
    foreach ( $schema as $query )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1022
    {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1023
      if ( substr($query, 0, 1) == '@' )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1024
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1025
        $query = substr($query, 1);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1026
        $db->sql_query($query);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1027
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1028
      else
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1029
      {
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1030
        if ( !$db->sql_query($query) )
1216
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1031
        {
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1032
          $return = array(
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1033
              'mode' => 'error',
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1034
              'error' => "[SQL] " . $db->sql_error()
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1035
            );
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1036
          break 2;
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1037
        }
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1038
      }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1039
    }
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1040
    
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1041
    // log action
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1042
    $time        = time();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1043
    $ip_db       = $db->escape($_SERVER['REMOTE_ADDR']);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1044
    $username_db = $db->escape($session->username);
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1045
    $file_db     = $db->escape($filename);
1216
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1046
    $q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, author_uid, page_text) VALUES\n"
4125e19d3b27 Fixed more places where author_uid wasn't right.
Dan
parents: 1145
diff changeset
  1047
                      . "  ('security', 'plugin_upgrade', $time, '$ip_db', '$username_db', $session->user_id, '$file_db');");
529
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1048
    if ( !$q )
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1049
      $db->_die();
7803c9db3506 Implemented security logging for plugin management
Dan
parents: 528
diff changeset
  1050
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1051
    // update version number
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1052
    $version = $db->escape($dataset['version']);
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1053
    $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_version = '$version' WHERE plugin_id = {$dataset['plugin id']};");
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1054
    if ( !$q )
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1055
      $db->die_json();
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1056
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1057
    // all done :-)
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1058
    $return = array(
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1059
      'success' => true
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1060
    );
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1061
    
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1062
    endswitch;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1063
    
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
  1064
    $cache->purge('plugins');
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 791
diff changeset
  1065
    $cache->purge('page_meta');
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 791
diff changeset
  1066
    $cache->purge('anon_sidebar');
791
e6094f56f941 Fixed a few bugs with plugin management and importing of old plugin metadata
Dan
parents: 769
diff changeset
  1067
    
527
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1068
    return $return;
21e11f564463 (Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
parents: 519
diff changeset
  1069
  }
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1070
  
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1071
  /**
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1072
   * Re-imports the language strings from a plugin.
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1073
   * @param string File name
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1074
   * @return array Enano JSON response protocol
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1075
   */
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1076
  
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1077
  function reimport_plugin_strings($filename, $plugin_list = null)
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1078
  {
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1079
    global $db, $session, $paths, $template, $plugins; // Common objects
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1080
    global $lang;
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1081
    
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1082
    if ( !$plugin_list )
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1083
      $plugin_list = $this->get_plugin_list();
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1084
    
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1085
    switch ( true ): case true:
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1086
    
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1087
    // is the plugin in the directory and already installed?
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1088
    if ( !isset($plugin_list[$filename]) || (
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1089
        isset($plugin_list[$filename]) && !$plugin_list[$filename]['installed']
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1090
      ))
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1091
    {
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1092
      $return = array(
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1093
        'mode' => 'error',
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1094
        'error' => 'Invalid plugin specified.',
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1095
      );
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1096
      break;
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1097
    }
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1098
    // get plugin data
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1099
    $dataset =& $plugin_list[$filename];
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1100
    
560
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1101
    // check for a language block
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1102
    $blocks = self::parse_plugin_blocks(ENANO_ROOT . '/plugins/' . $filename, 'language');
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1103
    if ( count($blocks) < 1 )
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1104
    {
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1105
      return array(
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1106
          'mode' => 'error',
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1107
          'error' => $lang->get('acppl_err_import_no_strings')
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1108
        );
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1109
    }
8981dcf7d485 Added re-import function to plugin manager
Dan
parents: 555
diff changeset
  1110
    
555
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1111
    $result = $lang->import_plugin(ENANO_ROOT . '/plugins/' . $filename);
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1112
    if ( $result )
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1113
    {
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1114
      return array(
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1115
        'success' => true
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1116
      );
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1117
    }
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1118
    else
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1119
    {
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1120
      return array(
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1121
        'mode' => 'error',
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1122
        'error' => 'Language API returned error'
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1123
      );
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1124
    }
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1125
    
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1126
    endswitch;
ac4c6a7f01d8 Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents: 536
diff changeset
  1127
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
  1128
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
  1129
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
  1130
?>