| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | Piwigo - a PHP based picture gallery | |
|---|
| 4 | // +-----------------------------------------------------------------------+ |
|---|
| 5 | // | Copyright(C) 2008-2010 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 | if (!defined('PHPWG_ROOT_PATH')) |
|---|
| 25 | { |
|---|
| 26 | die('Hacking attempt!'); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | add_event_handler('list_check_integrity', 'c13y_upgrade'); |
|---|
| 30 | |
|---|
| 31 | function c13y_upgrade($c13y) |
|---|
| 32 | { |
|---|
| 33 | global $conf; |
|---|
| 34 | |
|---|
| 35 | load_language('plugin.lang', dirname(__FILE__).'/'); |
|---|
| 36 | |
|---|
| 37 | $to_deactivate = true; |
|---|
| 38 | |
|---|
| 39 | /* Check user with same e-mail */ |
|---|
| 40 | $query = ' |
|---|
| 41 | select |
|---|
| 42 | count(*) |
|---|
| 43 | from |
|---|
| 44 | '.USERS_TABLE.' |
|---|
| 45 | where |
|---|
| 46 | '.$conf['user_fields']['email'].' is not null |
|---|
| 47 | group by |
|---|
| 48 | upper('.$conf['user_fields']['email'].') |
|---|
| 49 | having count(*) > 1 |
|---|
| 50 | limit 0,1 |
|---|
| 51 | ;'; |
|---|
| 52 | |
|---|
| 53 | if (pwg_db_fetch_array(pwg_query($query))) |
|---|
| 54 | { |
|---|
| 55 | $to_deactivate = false; |
|---|
| 56 | $c13y->add_anomaly( |
|---|
| 57 | l10n('c13y_dbl_email_user'), |
|---|
| 58 | null, |
|---|
| 59 | null, |
|---|
| 60 | l10n('c13y_correction_dbl_email_user')); |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | /* Check plugin included in Piwigo sources */ |
|---|
| 64 | $included_plugins = array('dew', 'UpToDate', 'PluginsManager', 'LinkRoot'); |
|---|
| 65 | $query = ' |
|---|
| 66 | select |
|---|
| 67 | id |
|---|
| 68 | from |
|---|
| 69 | '.PLUGINS_TABLE.' |
|---|
| 70 | where |
|---|
| 71 | id in ('. |
|---|
| 72 | implode( |
|---|
| 73 | ',', |
|---|
| 74 | array_map( |
|---|
| 75 | create_function('$s', 'return "\'".$s."\'";'), |
|---|
| 76 | $included_plugins |
|---|
| 77 | ) |
|---|
| 78 | ) |
|---|
| 79 | .') |
|---|
| 80 | ;'; |
|---|
| 81 | |
|---|
| 82 | $result = pwg_query($query); |
|---|
| 83 | while ($row = pwg_db_fetch_assoc($result)) |
|---|
| 84 | { |
|---|
| 85 | $to_deactivate = false; |
|---|
| 86 | |
|---|
| 87 | $uninstall_msg_link = |
|---|
| 88 | '<a href="'. |
|---|
| 89 | PHPWG_ROOT_PATH. |
|---|
| 90 | 'admin.php?page=plugins_list&plugin='.$row['id'].'&action=uninstall'. |
|---|
| 91 | '" onclick="window.open(this.href, \'\'); return false;">'. |
|---|
| 92 | sprintf(l10n('c13y_correction_obsolete_plugin'), $row['id']).'</a>'; |
|---|
| 93 | |
|---|
| 94 | $c13y->add_anomaly( |
|---|
| 95 | l10n('c13y_obsolete_plugin'), |
|---|
| 96 | null, |
|---|
| 97 | null, |
|---|
| 98 | $uninstall_msg_link); |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | /* Check if this plugin must be deactivate */ |
|---|
| 102 | if ($to_deactivate) |
|---|
| 103 | { |
|---|
| 104 | $query = ' |
|---|
| 105 | REPLACE INTO '.PLUGINS_TABLE.' |
|---|
| 106 | (id, state) |
|---|
| 107 | VALUES (\'c13y_upgrade\', \'inactive\') |
|---|
| 108 | ;'; |
|---|
| 109 | pwg_query($query); |
|---|
| 110 | |
|---|
| 111 | global $page; |
|---|
| 112 | $page['infos'][] = l10n('c13y_upgrade_no_anomaly'); |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | ?> |
|---|