-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsession.php
95 lines (88 loc) · 3.48 KB
/
session.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/*
* session.php
*
* Copyright 2011 Indra Sutriadi Pipii <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
if ( ! isset($_SESSION['plugins_enabled']) OR count($_SESSION['plugins_enabled']) == 0)
$_SESSION['plugins_enabled'] = array();
if ( ! isset($_SESSION['plugins_available']) OR count($_SESSION['plugins_available']) == 0)
$_SESSION['plugins_available'] = array();
$enplugins = $_SESSION['plugins_enabled'];
$avplugins = $_SESSION['plugins_available'];
$sql = 'SELECT * FROM plugins';
$array = array();
if (count($enplugins) != 0)
{
$sql .= ' WHERE ';
$q = array();
foreach ($enplugins as $key => $value)
$q[] = sprintf(" plugins_id != '%s'", $key);
$criteria = implode(' AND ', $q);
$sql .= $criteria;
}
$query = $dbs->query($sql);
if (isset($query->num_rows) && $query->num_rows > 0)
{
$arrays = array();
while($array = $query->fetch_assoc())
$arrays[$array['plugin_id']] = $array;
$enplugins = array_merge($enplugins, $arrays);
}
$thisdir = "./include";
$plugins = scandir($thisdir);
sort($plugins);
$options = '';
$plugdirs = array();
foreach ($plugins as $plugin)
{
$plugdir = $thisdir . '/' . $plugin;
$pluginfo = $plugdir . '/info.php';
if ($plugin != "." AND $plugin != ".." AND ! is_dir($plugdir))
continue;
$plugdirs[] = $plugin;
if ( ! array_key_exists($plugin, $avplugins) AND file_exists($pluginfo))
{
$info = '';
include($pluginfo);
$thisplugin = array(
'plugin_id' => $plugin,
'plugin_name' => ! isset($info['name']) ? __('Untitled') : $info['name'],
'plugin_author' => ! isset($info['author']) ? __('Unknown') : $info['author'],
'plugin_version' => ! isset($info['version']) ? __('Unversion') : $info['version'],
'plugin_build' => ! isset($info['build']) ? '0' : $info['build'],
'plugin_description' => ! isset($info['description']) ? __('No Description') : $info['description'],
'plugin_type' => ! isset($info['type']) ? 0 : $info['type'],
'plugin_page' => ! isset($info['page']) ? null : $plugdir . '/' . $info['page'] . '.php' ,
'plugin_block' => ! isset($info['block']) ? null : $plugdir . '/' . $info['block'] . '.php' ,
'plugin_menu' => ! isset($info['menu']) ? null : $plugdir . '/' . $info['menu'] . '.php' ,
'plugin_install' => ! isset($info['install']) ? null : $plugdir . '/' . $info['install'] . '.php' ,
'plugin_remove' => ! isset($info['remove']) ? null : $plugdir . '/' . $info['remove'] . '.php' ,
'plugin_deps' => ! isset($info['deps']) ? null : $info['deps'],
);
$avplugins = array_merge($avplugins, array($plugin => $thisplugin));
unset($info);
}
}
foreach ($avplugins as $key => $value)
{
if ( ! in_array($key, $plugdirs))
unset($avplugins[$key]);
}
$_SESSION['plugins_enabled'] = $enplugins;
$_SESSION['plugins_available'] = $avplugins;