1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | // +-----------------------------------------------------------------------+ |
---|
24 | // | PhpWebGallery - a PHP based picture gallery | |
---|
25 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
26 | // | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | // | file : $Id: initialize.inc.php 2297 2008-04-04 22:57:23Z plg $ |
---|
29 | // | last update : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $ |
---|
30 | // | last modifier : $Author: plg $ |
---|
31 | // | revision : $Revision: 2297 $ |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // | This program is free software; you can redistribute it and/or modify | |
---|
34 | // | it under the terms of the GNU General Public License as published by | |
---|
35 | // | the Free Software Foundation | |
---|
36 | // | | |
---|
37 | // | This program is distributed in the hope that it will be useful, but | |
---|
38 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
39 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
40 | // | General Public License for more details. | |
---|
41 | // | | |
---|
42 | // | You should have received a copy of the GNU General Public License | |
---|
43 | // | along with this program; if not, write to the Free Software | |
---|
44 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
45 | // | USA. | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | |
---|
48 | if (!defined('PHPWG_ROOT_PATH')) |
---|
49 | { |
---|
50 | die('Hacking attempt!'); |
---|
51 | } |
---|
52 | |
---|
53 | add_event_handler('list_check_integrity', 'c13y_upgrade'); |
---|
54 | |
---|
55 | function c13y_upgrade($c13y) |
---|
56 | { |
---|
57 | global $conf; |
---|
58 | |
---|
59 | load_language('plugin.lang', dirname(__FILE__).'/'); |
---|
60 | |
---|
61 | $can_be_deactivate = true; |
---|
62 | |
---|
63 | /* Check user with same e-mail */ |
---|
64 | $query = ' |
---|
65 | select |
---|
66 | count(*) |
---|
67 | from |
---|
68 | '.USERS_TABLE.' |
---|
69 | where |
---|
70 | '.$conf['user_fields']['email'].' is not null |
---|
71 | group by |
---|
72 | upper('.$conf['user_fields']['email'].') |
---|
73 | having count(*) > 1 |
---|
74 | limit 0,1 |
---|
75 | ;'; |
---|
76 | |
---|
77 | if (mysql_fetch_array(pwg_query($query))) |
---|
78 | { |
---|
79 | $can_be_deactivate = false; |
---|
80 | $c13y->add_anomaly( |
---|
81 | l10n('c13y_dbl_email_user'), |
---|
82 | null, |
---|
83 | null, |
---|
84 | l10n('c13y_correction_dbl_email_user')); |
---|
85 | } |
---|
86 | |
---|
87 | /* Check plugin included in Piwigo sources */ |
---|
88 | $included_plugins = array('dew', 'UpToDate', 'PluginsManager'); |
---|
89 | $query = ' |
---|
90 | select |
---|
91 | id |
---|
92 | from |
---|
93 | '.PLUGINS_TABLE.' |
---|
94 | where |
---|
95 | id in ('. |
---|
96 | implode( |
---|
97 | ',', |
---|
98 | array_map( |
---|
99 | create_function('$s', 'return "\'".$s."\'";'), |
---|
100 | $included_plugins |
---|
101 | ) |
---|
102 | ) |
---|
103 | .') |
---|
104 | ;'; |
---|
105 | |
---|
106 | $result = pwg_query($query); |
---|
107 | while ($row = mysql_fetch_assoc($result)) |
---|
108 | { |
---|
109 | $can_be_deactivate = false; |
---|
110 | |
---|
111 | $uninstall_msg_link = |
---|
112 | '<a href="'. |
---|
113 | PHPWG_ROOT_PATH. |
---|
114 | 'admin.php?page=plugins_list&plugin='.$row['id'].'&action=uninstall'. |
---|
115 | '" onclick="window.open(this.href, \'\'); return false;">'. |
---|
116 | sprintf(l10n('c13y_correction_obsolete_plugin'), $row['id']).'</a>'; |
---|
117 | |
---|
118 | $c13y->add_anomaly( |
---|
119 | l10n('c13y_obsolete_plugin'), |
---|
120 | null, |
---|
121 | null, |
---|
122 | $uninstall_msg_link); |
---|
123 | } |
---|
124 | |
---|
125 | /* Check if this plugin must deactivate */ |
---|
126 | if ($can_be_deactivate) |
---|
127 | { |
---|
128 | $deactivate_msg_link = |
---|
129 | '<a href="'. |
---|
130 | PHPWG_ROOT_PATH. |
---|
131 | 'admin.php?page=plugins&plugin=c13y_upgrade&action=deactivate'. |
---|
132 | '" onclick="window.open(this.href, \'\'); return false;">'. |
---|
133 | l10n('c13y_upgrade_deactivate').'</a>'; |
---|
134 | |
---|
135 | $c13y->add_anomaly( |
---|
136 | l10n('c13y_upgrade_no_anomaly'), |
---|
137 | 'c13y_upgrade_correction', |
---|
138 | 'deactivate_plugin', |
---|
139 | $deactivate_msg_link |
---|
140 | ); |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | function c13y_upgrade_correction($action) |
---|
145 | { |
---|
146 | $result = false; |
---|
147 | |
---|
148 | switch ($action) |
---|
149 | { |
---|
150 | case 'deactivate_plugin': |
---|
151 | { |
---|
152 | $query = ' |
---|
153 | REPLACE INTO '.PLUGINS_TABLE.' |
---|
154 | (id, state) |
---|
155 | VALUES (\'c13y_upgrade\', \'inactive\') |
---|
156 | ;'; |
---|
157 | pwg_query($query); |
---|
158 | $result = true; |
---|
159 | } |
---|
160 | break; |
---|
161 | } |
---|
162 | |
---|
163 | return $result; |
---|
164 | } |
---|
165 | |
---|
166 | ?> |
---|