1
+ − 1
<?php
+ − 2
+ − 3
/*
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
801
eb8b23f11744
Two big commits in one day I know, but redid password storage to use HMAC-SHA1. Consolidated much AES processing to three core methods in session that should handle everything automagically. Installation works; upgrades should. Rebranded as 1.1.6.
Dan
diff
changeset
+ − 5
* Version 1.1.6 (Caoineag beta 1)
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
893
+ − 57
var $system_plugins = Array('SpecialUserFuncs.php','SpecialUserPrefs.php','SpecialPageFuncs.php','SpecialAdmin.php','SpecialCSS.php','SpecialUpdownload.php','SpecialSearch.php','PrivateMessages.php','SpecialGroups.php', 'SpecialLog.php', 'DemoMode.php');
464
+ − 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
975
+ − 78
$plugin_list = $this->get_plugin_list();
+ − 79
$this->load_list = array();
992
+ − 80
975
+ − 81
foreach ( $plugin_list as $filename => $data )
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 82
{
992
+ − 83
if ( !$data['system plugin'] && ( $data['status'] & PLUGIN_OUTOFDATE || $data['status'] & PLUGIN_DISABLED || !$data['installed'] ) )
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 84
continue;
953
323c4cd1aa37
Made some more changes to the way namespaces are handled, for optimization purposes. This is a bit of a structural reorganization: $paths->pages is obsoleted in its entirety; calculating page existence and metadata is now the job of the Namespace_* backend class. There are many things in PageProcessor that should be reorganized, and page actions in general should really be rethought. This is probably the beginning of a long process that will be taking place over the course of the betas.
Dan
diff
changeset
+ − 85
975
+ − 86
$this->load_list[] = $filename;
+ − 87
$this->loaded_plugins[$filename] = $data;
1
+ − 88
}
+ − 89
}
464
+ − 90
+ − 91
/**
+ − 92
* Name kept for compatibility. This method is used to add a new hook into the code somewhere. Plugins are encouraged
+ − 93
* to set hooks and hook into other plugins in a fail-safe way, this encourages reuse of code. Returns an array, whose
+ − 94
* values should be eval'ed.
+ − 95
* @example <code>
+ − 96
$code = $plugins->setHook('my_hook_name');
+ − 97
foreach ( $code as $cmd )
+ − 98
{
+ − 99
eval($cmd);
+ − 100
}
+ − 101
</code>
+ − 102
* @param string The name of the hook.
+ − 103
* @param array Deprecated.
+ − 104
*/
+ − 105
893
+ − 106
function setHook($name, $dont_split = false)
825
9d5c04c1414f
Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
diff
changeset
+ − 107
{
9d5c04c1414f
Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
diff
changeset
+ − 108
if ( !empty($this->hook_list[$name]) && is_array($this->hook_list[$name]) )
1
+ − 109
{
893
+ − 110
if ( $dont_split )
+ − 111
return $this->hook_list[$name];
+ − 112
379
82b991bee797
Minor and hopefully non-breaking change to plugin loader to possibly double performance at hook points
Dan
diff
changeset
+ − 113
return array(implode("\n", $this->hook_list[$name]));
1
+ − 114
}
+ − 115
else
+ − 116
{
+ − 117
return Array();
+ − 118
}
+ − 119
}
464
+ − 120
+ − 121
/**
+ − 122
* Attaches to a hook effectively scheduling some code to be run at that point. You should try to keep hooks clean by
+ − 123
* making a function that has variables that need to be modified passed by reference.
+ − 124
* @example Simple example: <code>
+ − 125
$plugins->attachHook('render_wikiformat_pre', '$text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);');
+ − 126
</code>
+ − 127
* @example More complicated example: <code>
+ − 128
$plugins->attachHook('render_wikiformat_pre', 'myplugin_parser_ext($text);');
+ − 129
+ − 130
// Notice that $text is passed by reference.
+ − 131
function myplugin_parser_ext(&$text)
+ − 132
{
+ − 133
$text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);
+ − 134
}
+ − 135
</code>
+ − 136
*/
+ − 137
825
9d5c04c1414f
Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
diff
changeset
+ − 138
function attachHook($name, $code)
9d5c04c1414f
Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
diff
changeset
+ − 139
{
9d5c04c1414f
Added (very basic) spam filtering plugin support. Plugins can mark a message as spam by hooking into the spam check API, which is documented in functions.php. No spam checking functionality is built-in.
Dan
diff
changeset
+ − 140
if ( !isset($this->hook_list[$name]) )
1
+ − 141
{
+ − 142
$this->hook_list[$name] = Array();
+ − 143
}
+ − 144
$this->hook_list[$name][] = $code;
+ − 145
}
464
+ − 146
+ − 147
/**
+ − 148
* Tell whether a plugin is loaded or not.
+ − 149
* @param string The filename of the plugin
+ − 150
* @return bool
+ − 151
*/
+ − 152
1
+ − 153
function loaded($plugid)
+ − 154
{
+ − 155
return isset( $this->loaded_plugins[$plugid] );
+ − 156
}
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
+ − 157
586fd7d3202d
Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
diff
changeset
+ − 158
/**
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
+ − 159
* 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
+ − 160
<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
+ − 161
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
+ − 162
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
+ − 163
'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
+ − 164
// 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
+ − 165
'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
+ − 166
'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
+ − 167
'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
+ − 168
),
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
+ − 169
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
+ − 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
);
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
* @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
+ − 175
* @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
+ − 176
* @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
+ − 177
*/
586fd7d3202d
Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
diff
changeset
+ − 178
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
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
+ − 180
{
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
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
+ − 182
{
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
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
+ − 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
$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
+ − 186
$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
+ − 187
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
+ − 188
{
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
$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
+ − 193
. '(([\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
+ − 194
. '[\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
+ − 195
. '([\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
+ − 196
. '\*\*!\*/' // 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
+ − 197
. '#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
+ − 198
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
// 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
+ − 200
$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
+ − 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
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
+ − 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
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
+ − 206
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
+ − 207
519
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 208
$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
+ − 209
// 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
+ − 210
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
+ − 211
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
+ − 212
{
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 213
$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
+ − 214
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
+ − 215
{
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 216
$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
+ − 217
$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
+ − 218
}
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 219
}
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
diff
changeset
+ − 220
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
+ − 221
$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
+ − 222
$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
+ − 223
$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
+ − 224
$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
+ − 225
}
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
+ − 226
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
+ − 227
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
+ − 228
}
586fd7d3202d
Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
diff
changeset
+ − 229
586fd7d3202d
Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
diff
changeset
+ − 230
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
+ − 231
{
586fd7d3202d
Fixed some stray version numbers (again!); added support for Diffie-Hellman logins in the normal login form (not AJAX) - even works in IE
Dan
diff
changeset
+ − 232
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
+ − 233
$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
+ − 234
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
+ − 235
{
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
+ − 236
$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
+ − 237
}
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
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
+ − 239
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 240
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 241
/**
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 242
* 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
+ − 243
* on the site.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 244
* @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
+ − 245
* @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
+ − 246
* @return array
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 247
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 248
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
+ − 249
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
+ − 250
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 251
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
+ − 252
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 253
// Scan all plugins
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 254
$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
+ − 255
$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
+ − 256
// 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
+ − 257
$this->load_plugins_cache();
975
+ − 258
global $plugins_cache;
+ − 259
if ( $use_cache && !empty($plugins_cache) )
590
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 260
{
975
+ − 261
return $plugins_cache;
590
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 262
}
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
+ − 263
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
+ − 264
{
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
+ − 265
// 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
+ − 266
$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
+ − 267
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 268
975
+ − 269
// List all plugins
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 270
if ( $dirh = @opendir( ENANO_ROOT . '/plugins' ) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 271
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 272
while ( $dh = @readdir($dirh) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 273
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 274
if ( !preg_match('/\.php$/i', $dh) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 275
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 276
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 277
if ( is_array($restrict) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 278
if ( !in_array($dh, $restrict) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 279
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 280
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
+ − 281
// 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
+ − 282
$fullpath = ENANO_ROOT . "/plugins/$dh";
975
+ − 283
$plugin_meta = $this->read_plugin_headers($fullpath, $use_cache);
593
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 284
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
+ − 285
if ( is_array($plugin_meta) )
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 286
{
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
+ − 287
// 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
+ − 288
$plugin_list[$dh] = $plugin_meta;
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 289
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 290
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 291
}
975
+ − 292
+ − 293
// Populate with additional metadata from database
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 294
$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
+ − 295
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 296
$db->_die();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 297
while ( $row = $db->fetchrow() )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 298
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 299
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
+ − 300
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 301
// 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
+ − 302
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 303
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 304
$filename =& $row['plugin_filename'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 305
$plugin_list[$filename]['installed'] = true;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 306
$plugin_list[$filename]['status'] = PLUGIN_INSTALLED;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 307
$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
+ − 308
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
+ − 309
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 310
$plugin_list[$filename]['status'] |= PLUGIN_OUTOFDATE;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 311
$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
+ − 312
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 313
if ( $row['plugin_flags'] & PLUGIN_DISABLED )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 314
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 315
$plugin_list[$filename]['status'] |= PLUGIN_DISABLED;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 316
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 317
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 318
$db->free_result();
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
// sort it all out by filename
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 321
ksort($plugin_list);
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
// done
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 324
return $plugin_list;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 325
}
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
/**
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
+ − 328
* 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
+ − 329
* @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
+ − 330
* @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
+ − 331
*/
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
+ − 332
975
+ − 333
function read_plugin_headers($fullpath, $use_cache = true)
593
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 334
{
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 335
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
+ − 336
$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
+ − 337
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 338
// 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
+ − 339
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
+ − 340
{
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 341
$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
+ − 342
}
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
+ − 343
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
+ − 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
// 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
+ − 346
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
+ − 347
$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
+ − 348
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
// 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
+ − 350
$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
+ − 351
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
+ − 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
// 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
+ − 354
$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
+ − 355
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
+ − 356
// 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
+ − 357
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
+ − 358
$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
+ − 359
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
+ − 360
{
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
$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
+ − 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
// 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
+ − 364
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
+ − 365
// 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
+ − 366
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
+ − 367
{
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
// 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
+ − 369
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
+ − 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
// 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
+ − 372
$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
+ − 373
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
+ − 374
{
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
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
+ − 376
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
+ − 377
$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
+ − 378
}
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
}
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
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
+ − 381
{
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 382
// 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
+ − 383
$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
+ − 384
$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
+ − 385
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
+ − 386
{
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_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
+ − 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
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
+ − 390
{
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
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
+ − 392
}
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
// 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
+ − 394
$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
+ − 395
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
+ − 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[ 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
+ − 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
}
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
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
+ − 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
// 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
+ − 404
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
+ − 405
}
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
diff
changeset
+ − 406
// 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
+ − 407
$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
+ − 408
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
+ − 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
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
+ − 411
// 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
+ − 412
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
+ − 413
}
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
// 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
+ − 415
$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
+ − 416
// 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
+ − 417
$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
+ − 418
$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
+ − 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
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
+ − 421
}
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
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
/**
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
+ − 425
* 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
+ − 426
*/
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
+ − 427
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
+ − 428
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
+ − 429
{
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 430
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
+ − 431
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
+ − 432
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 433
// 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
+ − 434
$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
+ − 435
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
+ − 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
$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
+ − 438
}
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
$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
+ − 441
$GLOBALS['plugins_cache'] = $plugin_info;
613
+ − 442
+ − 443
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
+ − 444
}
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
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
* 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
+ − 448
* @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
+ − 449
* @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
+ − 450
*/
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
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
+ − 452
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
+ − 453
{
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
+ − 454
global $cache;
769
+ − 455
try
+ − 456
{
+ − 457
$result = $cache->store('plugins', $plugin_info, -1);
+ − 458
}
+ − 459
catch ( Exception $e )
+ − 460
{
+ − 461
return false;
+ − 462
}
+ − 463
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
+ − 464
}
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
+ − 465
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
+ − 466
/**
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
+ − 467
* 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
+ − 468
*/
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 469
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 470
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
+ − 471
{
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
+ − 472
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
+ − 473
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
+ − 474
{
607
935f3799b654
First stab at cache management backend. Everything seems to have been tested and working so far, but a number of things require a more specialized cache and can't go through the framework (e.g. user ranks which use references to map usernames to user IDs)
Dan
diff
changeset
+ − 475
$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
+ − 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
}
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
* 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
+ − 481
* @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
+ − 482
* @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
+ − 483
*/
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
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
+ − 485
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
+ − 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
$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
+ − 488
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
+ − 489
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
+ − 490
$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
+ − 491
$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
+ − 492
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
+ − 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
$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
+ − 495
$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
+ − 496
$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
+ − 497
}
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
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
+ − 499
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
+ − 500
}
03a60844c7c5
Several optimization changes including getting rid of a few eval()s. Added placeholder functions for the theme manager, which should be working now
Dan
diff
changeset
+ − 501
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
/**
869
+ − 503
* Determines if a file is an authentication extension by looking at the file contents.
+ − 504
* @param string Plugin filename
+ − 505
* @return bool
+ − 506
*/
+ − 507
+ − 508
function is_file_auth_plugin($filename)
+ − 509
{
+ − 510
$filename = ENANO_ROOT . '/plugins/' . $filename;
+ − 511
if ( !file_exists($filename) )
+ − 512
return false;
+ − 513
975
+ − 514
$info = $this->read_plugin_headers($filename);
869
+ − 515
if ( isset($info['auth plugin']) )
+ − 516
return true;
+ − 517
+ − 518
$contents = @file_get_contents($filename);
+ − 519
if ( strstr($contents, 'login_process_userdata_json') )
+ − 520
return true;
+ − 521
+ − 522
return false;
+ − 523
}
+ − 524
+ − 525
/**
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 526
* Installs a plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 527
* @param string Filename of plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 528
* @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
+ − 529
* @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
+ − 530
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 531
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 532
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
+ − 533
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 534
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
+ − 535
global $lang;
791
+ − 536
global $cache;
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 537
675
+ − 538
if ( defined('ENANO_DEMO_MODE') )
+ − 539
{
+ − 540
return array(
+ − 541
'mode' => 'error',
+ − 542
'error' => $lang->get('acppl_err_demo_mode')
+ − 543
);
+ − 544
}
+ − 545
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 546
if ( !$plugin_list )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 547
$plugin_list = $this->get_plugin_list();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 548
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 549
// we're gonna need this
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 550
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
+ − 551
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 552
switch ( true ): case true:
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 553
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 554
// 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
+ − 555
if ( !isset($plugin_list[$filename]) || (
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 556
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
+ − 557
))
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 558
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 559
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 560
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 561
'error' => 'Invalid plugin specified.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 562
'debug' => $filename
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 563
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 564
break;
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
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 567
$dataset =& $plugin_list[$filename];
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
// load up the installer schema
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 570
$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
+ − 571
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 572
$sql = array();
808
+ − 573
global $dbdriver;
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 574
if ( !empty($schema) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 575
{
808
+ − 576
// Decide which schema to use
+ − 577
$use_schema = false;
+ − 578
foreach ( $schema as $current_schema )
+ − 579
{
+ − 580
if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver )
+ − 581
{
+ − 582
$use_schema =& $current_schema['value'];
+ − 583
break;
+ − 584
}
+ − 585
}
+ − 586
if ( !$use_schema )
+ − 587
{
+ − 588
if ( !isset($schema[0]['dbms']) )
+ − 589
{
+ − 590
$use_schema =& $schema[0]['value'];
+ − 591
}
+ − 592
else
+ − 593
{
+ − 594
$return = array(
+ − 595
'mode' => 'error',
+ − 596
'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name))
+ − 597
);
+ − 598
break;
+ − 599
}
+ − 600
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 601
// parse SQL
808
+ − 602
$parser = new SQL_Parser($use_schema, true);
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 603
$parser->assign_vars(array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 604
'TABLE_PREFIX' => table_prefix
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 605
));
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 606
$sql = $parser->parse();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 607
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 608
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 609
// schema is final, check queries
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 610
foreach ( $sql as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 611
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 612
if ( !$db->check_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 613
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 614
// aww crap, a query is bad
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 615
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 616
'mode' => 'error',
528
+ − 617
'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
+ − 618
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 619
break 2;
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
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 623
// this is it, perform installation
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 624
foreach ( $sql as $query )
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
if ( substr($query, 0, 1) == '@' )
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
$query = substr($query, 1);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 629
$db->sql_query($query);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 630
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 631
else
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
if ( !$db->sql_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 634
$db->die_json();
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
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 637
529
+ − 638
// log action
+ − 639
$time = time();
+ − 640
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
+ − 641
$username_db = $db->escape($session->username);
+ − 642
$file_db = $db->escape($filename);
+ − 643
$q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
+ − 644
. " ('security', 'plugin_install', $time, '$ip_db', '$username_db', '$file_db');");
+ − 645
if ( !$q )
+ − 646
$db->_die();
+ − 647
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 648
// register plugin
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 649
$version_db = $db->escape($dataset['version']);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 650
$filename_db = $db->escape($filename);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 651
$flags = PLUGIN_INSTALLED;
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
$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
+ − 654
. " VALUES ( '$version_db', '$filename_db', $flags );");
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 655
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 656
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 657
846
+ − 658
$plugin_list[$filename]['installed'] = true;
+ − 659
$this->reimport_plugin_strings($filename, $plugin_list);
+ − 660
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 661
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 662
'success' => true
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
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 665
endswitch;
812
68060328e9c6
Added CLI installer. Supports interactive, command-line, and internal-call installation. Fixed a few bugs related to anti-SQL injection parser and plugin installation.
Dan
diff
changeset
+ − 666
791
+ − 667
$cache->purge('plugins');
793
c0724bf6039b
Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
diff
changeset
+ − 668
$cache->purge('page_meta');
c0724bf6039b
Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
diff
changeset
+ − 669
$cache->purge('anon_sidebar');
791
+ − 670
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 671
return $return;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 672
}
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
/**
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 675
* 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
+ − 676
* @param string Filename of plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 677
* @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
+ − 678
* @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
+ − 679
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 680
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 681
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
+ − 682
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 683
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
+ − 684
global $lang;
808
+ − 685
global $cache;
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 686
675
+ − 687
if ( defined('ENANO_DEMO_MODE') )
+ − 688
{
+ − 689
return array(
+ − 690
'mode' => 'error',
+ − 691
'error' => $lang->get('acppl_err_demo_mode')
+ − 692
);
+ − 693
}
+ − 694
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 695
if ( !$plugin_list )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 696
$plugin_list = $this->get_plugin_list();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 697
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 698
// we're gonna need this
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 699
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
+ − 700
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 701
switch ( true ): case true:
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
// 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
+ − 704
if ( !isset($plugin_list[$filename]) || (
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 705
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
+ − 706
))
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
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 709
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 710
'error' => 'Invalid plugin specified.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 711
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 712
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 713
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 714
// get plugin id
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 715
$dataset =& $plugin_list[$filename];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 716
if ( empty($dataset['plugin id']) )
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
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 719
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 720
'error' => 'Couldn\'t retrieve plugin ID.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 721
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 722
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 723
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 724
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 725
// load up the installer schema
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 726
$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
+ − 727
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 728
$sql = array();
808
+ − 729
global $dbdriver;
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 730
if ( !empty($schema) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 731
{
808
+ − 732
// Decide which schema to use
+ − 733
$use_schema = false;
+ − 734
foreach ( $schema as $current_schema )
+ − 735
{
+ − 736
if ( isset($current_schema['dbms']) && $current_schema['dbms'] === $dbdriver )
+ − 737
{
+ − 738
$use_schema =& $current_schema['value'];
+ − 739
break;
+ − 740
}
+ − 741
}
+ − 742
if ( !$use_schema )
+ − 743
{
+ − 744
if ( !isset($schema[0]['dbms']) )
+ − 745
{
+ − 746
$use_schema =& $schema[0]['value'];
+ − 747
}
+ − 748
else
+ − 749
{
+ − 750
$return = array(
+ − 751
'mode' => 'error',
+ − 752
'error' => $lang->get('acppl_err_dmbs_not_supported', array('dbdriver' => $db->dbms_name))
+ − 753
);
+ − 754
break;
+ − 755
}
+ − 756
}
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 757
// parse SQL
808
+ − 758
$parser = new SQL_Parser($use_schema, true);
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 759
$parser->assign_vars(array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 760
'TABLE_PREFIX' => table_prefix
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
$sql = $parser->parse();
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
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 765
// schema is final, check queries
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 766
foreach ( $sql as $query )
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
if ( !$db->check_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 769
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 770
// aww crap, a query is bad
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 771
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 772
'mode' => 'error',
528
+ − 773
'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
+ − 774
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 775
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 776
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 777
}
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
// this is it, perform uninstallation
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 780
foreach ( $sql as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 781
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 782
if ( substr($query, 0, 1) == '@' )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 783
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 784
$query = substr($query, 1);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 785
$db->sql_query($query);
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
else
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 788
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 789
if ( !$db->sql_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 790
$db->die_json();
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
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 793
529
+ − 794
// log action
+ − 795
$time = time();
+ − 796
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
+ − 797
$username_db = $db->escape($session->username);
+ − 798
$file_db = $db->escape($filename);
+ − 799
$q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
+ − 800
. " ('security', 'plugin_uninstall', $time, '$ip_db', '$username_db', '$file_db');");
+ − 801
if ( !$q )
+ − 802
$db->_die();
+ − 803
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 804
// deregister plugin
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 805
$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
+ − 806
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 807
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 808
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 809
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 810
'success' => true
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 811
);
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
endswitch;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 814
791
+ − 815
$cache->purge('plugins');
793
c0724bf6039b
Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
diff
changeset
+ − 816
$cache->purge('page_meta');
c0724bf6039b
Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
diff
changeset
+ − 817
$cache->purge('anon_sidebar');
791
+ − 818
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 819
return $return;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 820
}
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
* 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
+ − 824
* @param string Filename of plugin.
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 825
* @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
+ − 826
* @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
+ − 827
*/
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 828
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 829
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
+ − 830
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 831
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
+ − 832
global $lang;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 833
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 834
if ( !$plugin_list )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 835
$plugin_list = $this->get_plugin_list();
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
// we're gonna need this
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 838
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
+ − 839
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 840
switch ( true ): case true:
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 841
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 842
// 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
+ − 843
if ( !isset($plugin_list[$filename]) || (
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 844
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
+ − 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
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 848
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 849
'error' => 'Invalid plugin specified.',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 850
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 851
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 852
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 853
// get plugin id
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 854
$dataset =& $plugin_list[$filename];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 855
if ( empty($dataset['plugin id']) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 856
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 857
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 858
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 859
'error' => 'Couldn\'t retrieve plugin ID.',
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
break;
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
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
// 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
+ − 866
// 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
+ − 867
// 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
+ − 868
//
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 869
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 870
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
+ − 871
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 872
// 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
+ − 873
$version = $db->escape($dataset['version']);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 874
$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
+ − 875
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 876
$db->die_json();
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
// 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
+ − 879
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 880
'mode' => 'error',
528
+ − 881
'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
+ − 882
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 883
break;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 884
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 885
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 886
// build target list
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 887
$versions = $dataset['version list'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 888
$indices = array_flip($versions);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 889
$installed = $dataset['version installed'];
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
// is the current version upgradeable?
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 892
if ( !isset($indices[$installed]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 893
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 894
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 895
'mode' => 'error',
528
+ − 896
'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
+ − 897
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 898
break;
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
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 901
// 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
+ − 902
if ( !isset($indices[$installed]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 903
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 904
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 905
'mode' => 'error',
528
+ − 906
'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
+ − 907
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 908
break;
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
// list out which versions to do
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 912
$index_start = @$indices[$installed] + 1;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 913
$index_stop = @$indices[$dataset['version']];
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
// Are we trying to go backwards?
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 916
if ( $index_stop <= $index_start )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 917
{
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_to_older'),
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;
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
// build the list of version sets
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 926
$ver_previous = $installed;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 927
$targets = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 928
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
+ − 929
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 930
$targets[] = array($ver_previous, $versions[$i]);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 931
$ver_previous = $versions[$i];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 932
}
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
// 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
+ − 935
$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
+ − 936
$sql_blocks = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 937
foreach ( $plugin_blocks as $block )
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
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
+ − 940
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 941
continue;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 942
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 943
$key = "{$block['from']} TO {$block['to']}";
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 944
$sql_blocks[$key] = $block['value'];
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 945
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 946
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 947
// do version list check
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 948
// 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
+ − 949
// 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
+ − 950
foreach ( $targets as $i => $target )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 951
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 952
list($from, $to) = $target;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 953
$key = "$from TO $to";
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 954
if ( !isset($sql_blocks[$key]) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 955
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 956
unset($targets[$i]);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 957
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 958
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 959
$targets = array_values($targets);
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
// parse and finalize schema
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 962
$schema = array();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 963
foreach ( $targets as $i => $target )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 964
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 965
list($from, $to) = $target;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 966
$key = "$from TO $to";
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 967
try
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 968
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 969
$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
+ − 970
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 971
catch ( Exception $e )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 972
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 973
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 974
'mode' => 'error',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 975
'error' => 'SQL parser init exception',
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 976
'debug' => "$e"
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 977
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 978
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 979
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 980
$parser->assign_vars(array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 981
'TABLE_PREFIX' => table_prefix
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 982
));
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 983
$parsed = $parser->parse();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 984
foreach ( $parsed as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 985
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 986
$schema[] = $query;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 987
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 988
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 989
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 990
// schema is final, check queries
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 991
foreach ( $schema as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 992
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 993
if ( !$db->check_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 994
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 995
// aww crap, a query is bad
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 996
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 997
'mode' => 'error',
528
+ − 998
'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
+ − 999
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1000
break 2;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1001
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1002
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1003
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1004
// this is it, perform upgrade
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1005
foreach ( $schema as $query )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1006
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1007
if ( substr($query, 0, 1) == '@' )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1008
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1009
$query = substr($query, 1);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1010
$db->sql_query($query);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1011
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1012
else
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1013
{
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1014
if ( !$db->sql_query($query) )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1015
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1016
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1017
}
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1018
529
+ − 1019
// log action
+ − 1020
$time = time();
+ − 1021
$ip_db = $db->escape($_SERVER['REMOTE_ADDR']);
+ − 1022
$username_db = $db->escape($session->username);
+ − 1023
$file_db = $db->escape($filename);
+ − 1024
$q = $db->sql_query('INSERT INTO '.table_prefix."logs(log_type, action, time_id, edit_summary, author, page_text) VALUES\n"
+ − 1025
. " ('security', 'plugin_upgrade', $time, '$ip_db', '$username_db', '$file_db');");
+ − 1026
if ( !$q )
+ − 1027
$db->_die();
+ − 1028
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1029
// update version number
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1030
$version = $db->escape($dataset['version']);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1031
$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
+ − 1032
if ( !$q )
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1033
$db->die_json();
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1034
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1035
// all done :-)
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1036
$return = array(
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1037
'success' => true
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1038
);
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1039
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1040
endswitch;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1041
791
+ − 1042
$cache->purge('plugins');
793
c0724bf6039b
Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
diff
changeset
+ − 1043
$cache->purge('page_meta');
c0724bf6039b
Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
diff
changeset
+ − 1044
$cache->purge('anon_sidebar');
791
+ − 1045
527
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1046
return $return;
21e11f564463
(Hopefully) finished new plugin manager and implemented the utilization of it. Still HIGHLY experimental.
Dan
diff
changeset
+ − 1047
}
555
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1048
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1049
/**
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1050
* 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
+ − 1051
* @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
+ − 1052
* @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
+ − 1053
*/
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1054
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1055
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
+ − 1056
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1057
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
+ − 1058
global $lang;
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1059
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1060
if ( !$plugin_list )
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1061
$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
+ − 1062
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1063
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
+ − 1064
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1065
// 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
+ − 1066
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
+ − 1067
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
+ − 1068
))
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1069
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1070
$return = array(
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1071
'mode' => 'error',
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1072
'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
+ − 1073
);
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1074
break;
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1075
}
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1076
// get plugin data
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1077
$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
+ − 1078
560
+ − 1079
// check for a language block
+ − 1080
$blocks = self::parse_plugin_blocks(ENANO_ROOT . '/plugins/' . $filename, 'language');
+ − 1081
if ( count($blocks) < 1 )
+ − 1082
{
+ − 1083
return array(
+ − 1084
'mode' => 'error',
+ − 1085
'error' => $lang->get('acppl_err_import_no_strings')
+ − 1086
);
+ − 1087
}
+ − 1088
555
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1089
$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
+ − 1090
if ( $result )
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1091
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1092
return array(
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1093
'success' => true
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1094
);
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1095
}
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1096
else
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1097
{
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1098
return array(
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1099
'mode' => 'error',
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1100
'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
+ − 1101
);
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1102
}
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1103
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1104
endswitch;
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
diff
changeset
+ − 1105
}
1
+ − 1106
}
+ − 1107
+ − 1108
?>