1
+ − 1
<?php
+ − 2
+ − 3
/*
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
diff
changeset
+ − 5
* Version 1.1.5 (Caoineag alpha 5)
536
+ − 6
* Copyright (C) 2006-2008 Dan Fuhry
1
+ − 7
*
+ − 8
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 9
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 10
*
+ − 11
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 12
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 13
*/
+ − 14
464
+ − 15
/**
+ − 16
* Class used to handle and process plugin requests and loading. Singleton.
+ − 17
* @package Enano
+ − 18
* @author Dan Fuhry <dan@enanocms.org>
+ − 19
* @copyright (C) 2006-2008 Enano Project
+ − 20
* @license GNU General Public License <http://enanocms.org/Special:GNU_General_Public_License>
+ − 21
*/
+ − 22
1
+ − 23
class pluginLoader {
464
+ − 24
+ − 25
/**
+ − 26
* The list of hooks registered.
+ − 27
* @var array
+ − 28
* @access private
+ − 29
*/
+ − 30
1
+ − 31
var $hook_list;
464
+ − 32
+ − 33
/**
+ − 34
* The list of plugins that should be loaded. Used only by common.php.
+ − 35
* @var array
+ − 36
* @access private
+ − 37
*/
+ − 38
1
+ − 39
var $load_list;
464
+ − 40
+ − 41
/**
+ − 42
* The list of plugins that are loaded currently. This is only used by the loaded() method which in turn is
+ − 43
* used by template files with the <!-- IFPLUGIN --> special tag.
+ − 44
* @var array
+ − 45
* @access private
+ − 46
*/
+ − 47
1
+ − 48
var $loaded_plugins;
464
+ − 49
+ − 50
/**
+ − 51
* The list of plugins that are always loaded because they're part of the Enano core. This cannot be modified
+ − 52
* by any external code because user plugins are loaded after the load_list is calculated. Can be useful in
+ − 53
* alternative administration panel frameworks that need the list of system plugins.
+ − 54
* @var array
+ − 55
*/
+ − 56
675
+ − 57
var $system_plugins = Array('SpecialUserFuncs.php','SpecialUserPrefs.php','SpecialPageFuncs.php','SpecialAdmin.php','SpecialCSS.php','SpecialUpdownload.php','SpecialSearch.php','PrivateMessages.php','SpecialGroups.php', 'SpecialRecentChanges.php', 'DemoMode.php');
464
+ − 58
+ − 59
/**
+ − 60
* Name kept for compatibility. Effectively a constructor. Calculates the list of plugins that should be loaded
+ − 61
* and puts that list in the $load_list property. Plugin developers have absolutely no use for this whatsoever.
+ − 62
*/
+ − 63
1
+ − 64
function loadAll()
+ − 65
{
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 66
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
diff
changeset
+ − 67
$GLOBALS['plugins_cache'] = array();
568
+ − 68
+ − 69
// if we're in an upgrade, just skip this step
+ − 70
if ( defined('IN_ENANO_UPGRADE') )
+ − 71
{
+ − 72
$this->load_list = array();
+ − 73
return false;
+ − 74
}
+ − 75
1
+ − 76
$dir = ENANO_ROOT.'/plugins/';
+ − 77
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 78
$this->load_list = $this->system_plugins;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 79
$q = $db->sql_query('SELECT plugin_filename, plugin_version FROM ' . table_prefix . 'plugins WHERE plugin_flags & ~' . PLUGIN_DISABLED . ' = plugin_flags;');
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 80
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 81
$db->_die();
1
+ − 82
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 83
while ( $row = $db->fetchrow() )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 84
{
724
+ − 85
if ( file_exists(ENANO_ROOT . "/plugins/{$row['plugin_filename']}") )
+ − 86
{
+ − 87
$this->load_list[] = $row['plugin_filename'];
+ − 88
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 89
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 90
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 91
$this->loaded_plugins = $this->get_plugin_list($this->load_list);
1
+ − 92
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 93
// check for out-of-date plugins
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 94
foreach ( $this->load_list as $i => $plugin )
1
+ − 95
{
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 96
if ( in_array($plugin, $this->system_plugins) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 97
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 98
if ( $this->loaded_plugins[$plugin]['status'] & PLUGIN_OUTOFDATE )
1
+ − 99
{
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 100
// it's out of date, don't load
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 101
unset($this->load_list[$i]);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 102
unset($this->loaded_plugins[$plugin]);
1
+ − 103
}
+ − 104
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 105
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 106
$this->load_list = array_unique($this->load_list);
1
+ − 107
}
464
+ − 108
+ − 109
/**
+ − 110
* Name kept for compatibility. This method is used to add a new hook into the code somewhere. Plugins are encouraged
+ − 111
* to set hooks and hook into other plugins in a fail-safe way, this encourages reuse of code. Returns an array, whose
+ − 112
* values should be eval'ed.
+ − 113
* @example <code>
+ − 114
$code = $plugins->setHook('my_hook_name');
+ − 115
foreach ( $code as $cmd )
+ − 116
{
+ − 117
eval($cmd);
+ − 118
}
+ − 119
</code>
+ − 120
* @param string The name of the hook.
+ − 121
* @param array Deprecated.
+ − 122
*/
+ − 123
1
+ − 124
function setHook($name, $opts = Array()) {
+ − 125
if(isset($this->hook_list[$name]) && is_array($this->hook_list[$name]))
+ − 126
{
379
82b991bee797
Minor and hopefully non-breaking change to plugin loader to possibly double performance at hook points
Dan
diff
changeset
+ − 127
return array(implode("\n", $this->hook_list[$name]));
1
+ − 128
}
+ − 129
else
+ − 130
{
+ − 131
return Array();
+ − 132
}
+ − 133
}
464
+ − 134
+ − 135
/**
+ − 136
* Attaches to a hook effectively scheduling some code to be run at that point. You should try to keep hooks clean by
+ − 137
* making a function that has variables that need to be modified passed by reference.
+ − 138
* @example Simple example: <code>
+ − 139
$plugins->attachHook('render_wikiformat_pre', '$text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);');
+ − 140
</code>
+ − 141
* @example More complicated example: <code>
+ − 142
$plugins->attachHook('render_wikiformat_pre', 'myplugin_parser_ext($text);');
+ − 143
+ − 144
// Notice that $text is passed by reference.
+ − 145
function myplugin_parser_ext(&$text)
+ − 146
{
+ − 147
$text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);
+ − 148
}
+ − 149
</code>
+ − 150
*/
+ − 151
1
+ − 152
function attachHook($name, $code) {
+ − 153
if(!isset($this->hook_list[$name]))
+ − 154
{
+ − 155
$this->hook_list[$name] = Array();
+ − 156
}
+ − 157
$this->hook_list[$name][] = $code;
+ − 158
}
464
+ − 159
+ − 160
/**
+ − 161
* Tell whether a plugin is loaded or not.
+ − 162
* @param string The filename of the plugin
+ − 163
* @return bool
+ − 164
*/
+ − 165
1
+ − 166
function loaded($plugid)
+ − 167
{
+ − 168
return isset( $this->loaded_plugins[$plugid] );
+ − 169
}
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
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
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
diff
changeset
+ − 172
* 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
diff
changeset
+ − 173
<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
diff
changeset
+ − 174
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
diff
changeset
+ − 175
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
diff
changeset
+ − 176
'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
diff
changeset
+ − 177
// 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
diff
changeset
+ − 178
'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
diff
changeset
+ − 179
'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
diff
changeset
+ − 180
'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
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
diff
changeset
+ − 182
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
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
diff
changeset
+ − 184
)
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
diff
changeset
+ − 185
);
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
diff
changeset
+ − 186
</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
diff
changeset
+ − 187
* @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
diff
changeset
+ − 188
* @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
diff
changeset
+ − 189
* @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
diff
changeset
+ − 190
*/
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
diff
changeset
+ − 191
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
diff
changeset
+ − 192
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
diff
changeset
+ − 193
{
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
diff
changeset
+ − 194
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
diff
changeset
+ − 195
{
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
diff
changeset
+ − 196
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
diff
changeset
+ − 197
}
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
diff
changeset
+ − 198
$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
diff
changeset
+ − 199
$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
diff
changeset
+ − 200
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
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
diff
changeset
+ − 202
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
diff
changeset
+ − 203
}
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
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
diff
changeset
+ − 205
$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
diff
changeset
+ − 206
. '(([\s]+[a-z0-9_]+[\s]*=[\s]*".+?"[\s]*;)*)' // parameters
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
diff
changeset
+ − 207
. '[\s]*\*\*' . "\n" // spacing and header close
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
diff
changeset
+ − 208
. '([\w\W]+?)' . "\n" // value
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
diff
changeset
+ − 209
. '\*\*!\*/' // 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
diff
changeset
+ − 210
. '#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
diff
changeset
+ − 211
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
diff
changeset
+ − 212
// 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
diff
changeset
+ − 213
$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
diff
changeset
+ − 214
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
diff
changeset
+ − 215
$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
diff
changeset
+ − 216
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
diff
changeset
+ − 217
{
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
diff
changeset
+ − 218
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
diff
changeset
+ − 219
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
diff
changeset
+ − 220
519
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 221
$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
diff
changeset
+ − 222
// parse includes
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 223
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
diff
changeset
+ − 224
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
diff
changeset
+ − 225
{
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 226
$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
diff
changeset
+ − 227
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
diff
changeset
+ − 228
{
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 229
$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
diff
changeset
+ − 230
$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
diff
changeset
+ − 231
}
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 232
}
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 233
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
diff
changeset
+ − 234
$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
diff
changeset
+ − 235
$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
diff
changeset
+ − 236
$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
diff
changeset
+ − 237
$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
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
diff
changeset
+ − 239
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
diff
changeset
+ − 240
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
diff
changeset
+ − 241
}
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
diff
changeset
+ − 242
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
diff
changeset
+ − 243
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
diff
changeset
+ − 244
{
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
diff
changeset
+ − 245
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
diff
changeset
+ − 246
$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
diff
changeset
+ − 247
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
diff
changeset
+ − 248
{
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
diff
changeset
+ − 249
$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
diff
changeset
+ − 250
}
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
diff
changeset
+ − 251
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
diff
changeset
+ − 252
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 253
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 254
/**
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 255
* 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
diff
changeset
+ − 256
* on the site.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 257
* @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
diff
changeset
+ − 258
* @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
diff
changeset
+ − 259
* @return array
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 260
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 261
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
diff
changeset
+ − 262
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
diff
changeset
+ − 263
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 264
global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 265
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 266
// Scan all plugins
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 267
$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
diff
changeset
+ − 268
$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
diff
changeset
+ − 269
// 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
diff
changeset
+ − 270
$this->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
diff
changeset
+ − 271
if ( $use_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
diff
changeset
+ − 272
{
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
diff
changeset
+ − 273
global $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
diff
changeset
+ − 274
}
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
diff
changeset
+ − 275
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
diff
changeset
+ − 276
{
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
diff
changeset
+ − 277
// 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
diff
changeset
+ − 278
$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
diff
changeset
+ − 279
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 280
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 281
if ( $dirh = @opendir( ENANO_ROOT . '/plugins' ) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 282
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 283
while ( $dh = @readdir($dirh) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 284
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 285
if ( !preg_match('/\.php$/i', $dh) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 286
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 287
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 288
if ( is_array($restrict) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 289
if ( !in_array($dh, $restrict) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 290
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 291
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
diff
changeset
+ − 292
// 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
diff
changeset
+ − 293
$fullpath = ENANO_ROOT . "/plugins/$dh";
601
+ − 294
$plugin_meta = $this->get_plugin_info($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
diff
changeset
+ − 295
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
diff
changeset
+ − 296
if ( is_array($plugin_meta) )
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 297
{
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
diff
changeset
+ − 298
// 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
diff
changeset
+ − 299
$plugin_list[$dh] = $plugin_meta;
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 300
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 301
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 302
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 303
// gather info about installed plugins
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 304
$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
diff
changeset
+ − 305
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 306
$db->_die();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 307
while ( $row = $db->fetchrow() )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 308
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 309
if ( !isset($plugin_list[ $row['plugin_filename'] ]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 310
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 311
// missing plugin file, don't report (for now)
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 312
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 313
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 314
$filename =& $row['plugin_filename'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 315
$plugin_list[$filename]['installed'] = true;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 316
$plugin_list[$filename]['status'] = PLUGIN_INSTALLED;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 317
$plugin_list[$filename]['plugin id'] = $row['plugin_id'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 318
if ( $row['plugin_version'] != $plugin_list[$filename]['version'] )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 319
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 320
$plugin_list[$filename]['status'] |= PLUGIN_OUTOFDATE;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 321
$plugin_list[$filename]['version installed'] = $row['plugin_version'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 322
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 323
if ( $row['plugin_flags'] & PLUGIN_DISABLED )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 324
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 325
$plugin_list[$filename]['status'] |= PLUGIN_DISABLED;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 326
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 327
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 328
$db->free_result();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 329
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 330
// sort it all out by filename
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 331
ksort($plugin_list);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 332
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 333
// done
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 334
return $plugin_list;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 335
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 336
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 337
/**
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
diff
changeset
+ − 338
* 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
diff
changeset
+ − 339
* @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
diff
changeset
+ − 340
* @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
diff
changeset
+ − 341
*/
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
diff
changeset
+ − 342
601
+ − 343
function get_plugin_info($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
diff
changeset
+ − 344
{
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
diff
changeset
+ − 345
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
diff
changeset
+ − 346
$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
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
diff
changeset
+ − 348
// 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
diff
changeset
+ − 349
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
diff
changeset
+ − 350
{
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
diff
changeset
+ − 351
$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
diff
changeset
+ − 352
}
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
diff
changeset
+ − 353
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
diff
changeset
+ − 354
{
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
diff
changeset
+ − 355
// 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
diff
changeset
+ − 356
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
diff
changeset
+ − 357
$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
diff
changeset
+ − 358
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
diff
changeset
+ − 359
// 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
diff
changeset
+ − 360
$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
diff
changeset
+ − 361
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
diff
changeset
+ − 362
{
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
diff
changeset
+ − 363
// 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
diff
changeset
+ − 364
$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
diff
changeset
+ − 365
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
diff
changeset
+ − 366
// 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
diff
changeset
+ − 367
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
diff
changeset
+ − 368
$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
diff
changeset
+ − 369
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
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
diff
changeset
+ − 371
$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
diff
changeset
+ − 372
}
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
diff
changeset
+ − 373
// 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
diff
changeset
+ − 374
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
diff
changeset
+ − 375
// 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
diff
changeset
+ − 376
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
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
diff
changeset
+ − 378
// 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
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
diff
changeset
+ − 380
}
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
diff
changeset
+ − 381
// 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
diff
changeset
+ − 382
$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
diff
changeset
+ − 383
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
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
diff
changeset
+ − 385
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
diff
changeset
+ − 386
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
diff
changeset
+ − 387
$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
diff
changeset
+ − 388
}
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
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
diff
changeset
+ − 390
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
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
diff
changeset
+ − 392
// 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
diff
changeset
+ − 393
$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
diff
changeset
+ − 394
$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
diff
changeset
+ − 395
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
diff
changeset
+ − 396
{
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
diff
changeset
+ − 397
$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
diff
changeset
+ − 398
}
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
diff
changeset
+ − 399
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
diff
changeset
+ − 400
{
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
diff
changeset
+ − 401
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
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
diff
changeset
+ − 403
// 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
diff
changeset
+ − 404
$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
diff
changeset
+ − 405
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
diff
changeset
+ − 406
{
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
diff
changeset
+ − 407
$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
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
diff
changeset
+ − 409
}
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
diff
changeset
+ − 410
}
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
diff
changeset
+ − 411
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
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
diff
changeset
+ − 413
// 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
diff
changeset
+ − 414
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
diff
changeset
+ − 415
}
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
diff
changeset
+ − 416
// 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
diff
changeset
+ − 417
$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
diff
changeset
+ − 418
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
diff
changeset
+ − 419
{
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
diff
changeset
+ − 420
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
diff
changeset
+ − 421
// 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
diff
changeset
+ − 422
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
diff
changeset
+ − 423
}
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
diff
changeset
+ − 424
// 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
diff
changeset
+ − 425
$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
diff
changeset
+ − 426
// 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
diff
changeset
+ − 427
$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
diff
changeset
+ − 428
$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
diff
changeset
+ − 429
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
diff
changeset
+ − 430
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
diff
changeset
+ − 431
}
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
diff
changeset
+ − 432
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
diff
changeset
+ − 433
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
diff
changeset
+ − 434
/**
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
diff
changeset
+ − 435
* 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
diff
changeset
+ − 436
*/
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
diff
changeset
+ − 437
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
diff
changeset
+ − 438
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
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
diff
changeset
+ − 440
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
diff
changeset
+ − 441
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
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
diff
changeset
+ − 443
// 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
diff
changeset
+ − 444
$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
diff
changeset
+ − 445
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
diff
changeset
+ − 446
{
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
diff
changeset
+ − 447
$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
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
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
diff
changeset
+ − 450
$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
diff
changeset
+ − 451
$GLOBALS['plugins_cache'] = $plugin_info;
613
+ − 452
+ − 453
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
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
diff
changeset
+ − 455
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
diff
changeset
+ − 456
/**
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
diff
changeset
+ − 457
* 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
diff
changeset
+ − 458
* @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
diff
changeset
+ − 459
* @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
diff
changeset
+ − 460
*/
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
diff
changeset
+ − 461
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
diff
changeset
+ − 462
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
diff
changeset
+ − 463
{
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
diff
changeset
+ − 464
global $cache;
769
+ − 465
try
+ − 466
{
+ − 467
$result = $cache->store('plugins', $plugin_info, -1);
+ − 468
}
+ − 469
catch ( Exception $e )
+ − 470
{
+ − 471
return false;
+ − 472
}
+ − 473
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
diff
changeset
+ − 474
}
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
diff
changeset
+ − 475
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
diff
changeset
+ − 476
/**
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
diff
changeset
+ − 477
* 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
diff
changeset
+ − 478
*/
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
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
diff
changeset
+ − 480
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
diff
changeset
+ − 481
{
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
diff
changeset
+ − 482
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
diff
changeset
+ − 483
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
diff
changeset
+ − 484
{
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
diff
changeset
+ − 485
$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
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
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
diff
changeset
+ − 488
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
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
diff
changeset
+ − 490
* 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
diff
changeset
+ − 491
* @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
diff
changeset
+ − 492
* @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
diff
changeset
+ − 493
*/
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
diff
changeset
+ − 494
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
diff
changeset
+ − 495
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
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
diff
changeset
+ − 497
$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
diff
changeset
+ − 498
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
diff
changeset
+ − 499
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
diff
changeset
+ − 500
$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
diff
changeset
+ − 501
$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
diff
changeset
+ − 502
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
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
diff
changeset
+ − 504
$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
diff
changeset
+ − 505
$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
diff
changeset
+ − 506
$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
diff
changeset
+ − 507
}
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
diff
changeset
+ − 508
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
diff
changeset
+ − 509
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
diff
changeset
+ − 510
}
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
diff
changeset
+ − 511
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
diff
changeset
+ − 512
/**
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 513
* Installs a plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 514
* @param string Filename of plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 515
* @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
diff
changeset
+ − 516
* @return array JSON-formatted but not encoded response
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 517
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 518
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 519
function install_plugin($filename, $plugin_list = null)
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 520
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 521
global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 522
global $lang;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 523
675
+ − 524
if ( defined('ENANO_DEMO_MODE') )
+ − 525
{
+ − 526
return array(
+ − 527
'mode' => 'error',
+ − 528
'error' => $lang->get('acppl_err_demo_mode')
+ − 529
);
+ − 530
}
+ − 531
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 532
if ( !$plugin_list )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 533
$plugin_list = $this->get_plugin_list();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 534
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 535
// we're gonna need this
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 536
require_once ( ENANO_ROOT . '/includes/sql_parse.php' );
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 537
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 538
switch ( true ): case true:
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 539
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 540
// 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
diff
changeset
+ − 541
if ( !isset($plugin_list[$filename]) || (
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 542
isset($plugin_list[$filename]) && $plugin_list[$filename]['installed']
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 543
))
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 544
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 545
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 546
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 547
'error' => 'Invalid plugin specified.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 548
'debug' => $filename
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 549
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 550
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 551
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 552
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 553
$dataset =& $plugin_list[$filename];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 554
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 555
// load up the installer schema
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 556
$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
diff
changeset
+ − 557
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 558
$sql = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 559
if ( !empty($schema) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 560
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 561
// parse SQL
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 562
$parser = new SQL_Parser($schema[0]['value'], true);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 563
$parser->assign_vars(array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 564
'TABLE_PREFIX' => table_prefix
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 565
));
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 566
$sql = $parser->parse();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 567
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 568
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 569
// schema is final, check queries
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 570
foreach ( $sql as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 571
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 572
if ( !$db->check_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 573
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 574
// aww crap, a query is bad
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 575
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 576
'mode' => 'error',
528
+ − 577
'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
diff
changeset
+ − 578
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 579
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 580
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 581
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 582
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 583
// this is it, perform installation
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 584
foreach ( $sql as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 585
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 586
if ( substr($query, 0, 1) == '@' )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 587
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 588
$query = substr($query, 1);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 589
$db->sql_query($query);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 590
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 591
else
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 592
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 593
if ( !$db->sql_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 594
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 595
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 596
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 597
529
+ − 598
// log action
+ − 599
$time = time();
+ − 600
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
+ − 601
$username_db = $db->escape($session->username);
+ − 602
$file_db = $db->escape($filename);
+ − 603
$q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
+ − 604
. " ('security', 'plugin_install', $time, '$ip_db', '$username_db', '$file_db');");
+ − 605
if ( !$q )
+ − 606
$db->_die();
+ − 607
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 608
// register plugin
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 609
$version_db = $db->escape($dataset['version']);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 610
$filename_db = $db->escape($filename);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 611
$flags = PLUGIN_INSTALLED;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 612
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 613
$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
diff
changeset
+ − 614
. " VALUES ( '$version_db', '$filename_db', $flags );");
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 615
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 616
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 617
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 618
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 619
'success' => true
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 620
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 621
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 622
endswitch;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 623
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 624
return $return;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 625
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 626
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 627
/**
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 628
* 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
diff
changeset
+ − 629
* @param string Filename of plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 630
* @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
diff
changeset
+ − 631
* @return array JSON-formatted but not encoded response
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 632
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 633
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 634
function uninstall_plugin($filename, $plugin_list = null)
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 635
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 636
global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 637
global $lang;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 638
675
+ − 639
if ( defined('ENANO_DEMO_MODE') )
+ − 640
{
+ − 641
return array(
+ − 642
'mode' => 'error',
+ − 643
'error' => $lang->get('acppl_err_demo_mode')
+ − 644
);
+ − 645
}
+ − 646
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 647
if ( !$plugin_list )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 648
$plugin_list = $this->get_plugin_list();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 649
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 650
// we're gonna need this
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 651
require_once ( ENANO_ROOT . '/includes/sql_parse.php' );
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 652
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 653
switch ( true ): case true:
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 654
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 655
// 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
diff
changeset
+ − 656
if ( !isset($plugin_list[$filename]) || (
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 657
isset($plugin_list[$filename]) && !$plugin_list[$filename]['installed']
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 658
))
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 659
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 660
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 661
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 662
'error' => 'Invalid plugin specified.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 663
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 664
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 665
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 666
// get plugin id
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 667
$dataset =& $plugin_list[$filename];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 668
if ( empty($dataset['plugin id']) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 669
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 670
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 671
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 672
'error' => 'Couldn\'t retrieve plugin ID.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 673
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 674
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 675
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 676
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 677
// load up the installer schema
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 678
$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
diff
changeset
+ − 679
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 680
$sql = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 681
if ( !empty($schema) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 682
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 683
// parse SQL
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 684
$parser = new SQL_Parser($schema[0]['value'], true);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 685
$parser->assign_vars(array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 686
'TABLE_PREFIX' => table_prefix
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 687
));
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 688
$sql = $parser->parse();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 689
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 690
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 691
// schema is final, check queries
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 692
foreach ( $sql as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 693
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 694
if ( !$db->check_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 695
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 696
// aww crap, a query is bad
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 697
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 698
'mode' => 'error',
528
+ − 699
'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
diff
changeset
+ − 700
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 701
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 702
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 703
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 704
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 705
// this is it, perform uninstallation
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 706
foreach ( $sql as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 707
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 708
if ( substr($query, 0, 1) == '@' )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 709
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 710
$query = substr($query, 1);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 711
$db->sql_query($query);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 712
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 713
else
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 714
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 715
if ( !$db->sql_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 716
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 717
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 718
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 719
529
+ − 720
// log action
+ − 721
$time = time();
+ − 722
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
+ − 723
$username_db = $db->escape($session->username);
+ − 724
$file_db = $db->escape($filename);
+ − 725
$q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
+ − 726
. " ('security', 'plugin_uninstall', $time, '$ip_db', '$username_db', '$file_db');");
+ − 727
if ( !$q )
+ − 728
$db->_die();
+ − 729
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 730
// deregister plugin
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 731
$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
diff
changeset
+ − 732
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 733
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 734
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 735
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 736
'success' => true
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 737
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 738
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 739
endswitch;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 740
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 741
return $return;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 742
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 743
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 744
/**
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 745
* 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
diff
changeset
+ − 746
* @param string Filename of plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 747
* @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
diff
changeset
+ − 748
* @return array JSON-formatted but not encoded response
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 749
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 750
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 751
function upgrade_plugin($filename, $plugin_list = null)
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 752
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 753
global $db, $session, $paths, $template, $plugins; // Common objects
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 754
global $lang;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 755
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 756
if ( !$plugin_list )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 757
$plugin_list = $this->get_plugin_list();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 758
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 759
// we're gonna need this
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 760
require_once ( ENANO_ROOT . '/includes/sql_parse.php' );
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 761
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 762
switch ( true ): case true:
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 763
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 764
// 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
diff
changeset
+ − 765
if ( !isset($plugin_list[$filename]) || (
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 766
isset($plugin_list[$filename]) && !$plugin_list[$filename]['installed']
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 767
))
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 768
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 769
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 770
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 771
'error' => 'Invalid plugin specified.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 772
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 773
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 774
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 775
// get plugin id
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 776
$dataset =& $plugin_list[$filename];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 777
if ( empty($dataset['plugin id']) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 778
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 779
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 780
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 781
'error' => 'Couldn\'t retrieve plugin ID.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 782
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 783
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 784
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 785
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 786
//
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 787
// 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
diff
changeset
+ − 788
// 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
diff
changeset
+ − 789
// 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
diff
changeset
+ − 790
//
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 791
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 792
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
diff
changeset
+ − 793
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 794
// 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
diff
changeset
+ − 795
$version = $db->escape($dataset['version']);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 796
$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
diff
changeset
+ − 797
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 798
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 799
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 800
// 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
diff
changeset
+ − 801
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 802
'mode' => 'error',
528
+ − 803
'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
diff
changeset
+ − 804
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 805
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 806
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 807
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 808
// build target list
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 809
$versions = $dataset['version list'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 810
$indices = array_flip($versions);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 811
$installed = $dataset['version installed'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 812
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 813
// is the current version upgradeable?
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 814
if ( !isset($indices[$installed]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 815
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 816
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 817
'mode' => 'error',
528
+ − 818
'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
diff
changeset
+ − 819
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 820
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 821
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 822
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 823
// 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
diff
changeset
+ − 824
if ( !isset($indices[$installed]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 825
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 826
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 827
'mode' => 'error',
528
+ − 828
'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
diff
changeset
+ − 829
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 830
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 831
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 832
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 833
// list out which versions to do
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 834
$index_start = @$indices[$installed] + 1;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 835
$index_stop = @$indices[$dataset['version']];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 836
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 837
// Are we trying to go backwards?
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 838
if ( $index_stop <= $index_start )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 839
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 840
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 841
'mode' => 'error',
528
+ − 842
'error' => $lang->get('acppl_err_upgrade_to_older'),
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 843
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 844
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 845
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 846
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 847
// build the list of version sets
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 848
$ver_previous = $installed;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 849
$targets = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 850
for ( $i = $index_start; $i <= $index_stop; $i++ )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 851
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 852
$targets[] = array($ver_previous, $versions[$i]);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 853
$ver_previous = $versions[$i];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 854
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 855
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 856
// parse out upgrade sections in plugin file
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 857
$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
diff
changeset
+ − 858
$sql_blocks = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 859
foreach ( $plugin_blocks as $block )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 860
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 861
if ( !isset($block['from']) || !isset($block['to']) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 862
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 863
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 864
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 865
$key = "{$block['from']} TO {$block['to']}";
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 866
$sql_blocks[$key] = $block['value'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 867
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 868
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 869
// do version list check
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 870
// 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
diff
changeset
+ − 871
// 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
diff
changeset
+ − 872
foreach ( $targets as $i => $target )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 873
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 874
list($from, $to) = $target;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 875
$key = "$from TO $to";
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 876
if ( !isset($sql_blocks[$key]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 877
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 878
unset($targets[$i]);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 879
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 880
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 881
$targets = array_values($targets);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 882
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 883
// parse and finalize schema
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 884
$schema = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 885
foreach ( $targets as $i => $target )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 886
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 887
list($from, $to) = $target;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 888
$key = "$from TO $to";
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 889
try
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 890
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 891
$parser = new SQL_Parser($sql_blocks[$key], true);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 892
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 893
catch ( Exception $e )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 894
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 895
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 896
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 897
'error' => 'SQL parser init exception',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 898
'debug' => "$e"
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 899
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 900
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 901
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 902
$parser->assign_vars(array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 903
'TABLE_PREFIX' => table_prefix
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 904
));
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 905
$parsed = $parser->parse();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 906
foreach ( $parsed as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 907
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 908
$schema[] = $query;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 909
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 910
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 911
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 912
// schema is final, check queries
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 913
foreach ( $schema as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 914
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 915
if ( !$db->check_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 916
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 917
// aww crap, a query is bad
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 918
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 919
'mode' => 'error',
528
+ − 920
'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
diff
changeset
+ − 921
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 922
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 923
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 924
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 925
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 926
// this is it, perform upgrade
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 927
foreach ( $schema as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 928
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 929
if ( substr($query, 0, 1) == '@' )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 930
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 931
$query = substr($query, 1);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 932
$db->sql_query($query);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 933
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 934
else
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 935
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 936
if ( !$db->sql_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 937
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 938
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 939
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 940
529
+ − 941
// log action
+ − 942
$time = time();
+ − 943
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
+ − 944
$username_db = $db->escape($session->username);
+ − 945
$file_db = $db->escape($filename);
+ − 946
$q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
+ − 947
. " ('security', 'plugin_upgrade', $time, '$ip_db', '$username_db', '$file_db');");
+ − 948
if ( !$q )
+ − 949
$db->_die();
+ − 950
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 951
// update version number
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 952
$version = $db->escape($dataset['version']);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 953
$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
diff
changeset
+ − 954
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 955
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 956
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 957
// all done :-)
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 958
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 959
'success' => true
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 960
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 961
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 962
endswitch;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 963
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 964
return $return;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 965
}
555
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 966
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 967
/**
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 968
* 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
diff
changeset
+ − 969
* @param string File name
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 970
* @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
diff
changeset
+ − 971
*/
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 972
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 973
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
diff
changeset
+ − 974
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 975
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
diff
changeset
+ − 976
global $lang;
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 977
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 978
if ( !$plugin_list )
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 979
$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
diff
changeset
+ − 980
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 981
switch ( true ): case true:
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 982
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 983
// 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
diff
changeset
+ − 984
if ( !isset($plugin_list[$filename]) || (
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 985
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
diff
changeset
+ − 986
))
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 987
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 988
$return = array(
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 989
'mode' => 'error',
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 990
'error' => 'Invalid plugin specified.',
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 991
);
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 992
break;
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 993
}
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 994
// get plugin data
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 995
$dataset =& $plugin_list[$filename];
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 996
560
+ − 997
// check for a language block
+ − 998
$blocks = self::parse_plugin_blocks(ENANO_ROOT . '/plugins/' . $filename, 'language');
+ − 999
if ( count($blocks) < 1 )
+ − 1000
{
+ − 1001
return array(
+ − 1002
'mode' => 'error',
+ − 1003
'error' => $lang->get('acppl_err_import_no_strings')
+ − 1004
);
+ − 1005
}
+ − 1006
555
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1007
$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
diff
changeset
+ − 1008
if ( $result )
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1009
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1010
return array(
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1011
'success' => true
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1012
);
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1013
}
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1014
else
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1015
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1016
return array(
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1017
'mode' => 'error',
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1018
'error' => 'Language API returned error'
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1019
);
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1020
}
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1021
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1022
endswitch;
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1023
}
1
+ − 1024
}
+ − 1025
+ − 1026
?>