1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based photo gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2011 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 | $upgrade_description = 'remove user upload as core feature and save config for Community plugin'; |
---|
30 | |
---|
31 | $user_upload_conf = array(); |
---|
32 | |
---|
33 | // upload_user_access |
---|
34 | $conf_orig = $conf; |
---|
35 | load_conf_from_db(); |
---|
36 | $user_upload_conf['upload_user_access'] = $conf['upload_user_access']; |
---|
37 | $conf = $conf_orig; |
---|
38 | |
---|
39 | // unvalidated photos submitted by users |
---|
40 | $query = ' |
---|
41 | SELECT * |
---|
42 | FROM '.PREFIX_TABLE.'waiting |
---|
43 | ;'; |
---|
44 | $result = pwg_query($query); |
---|
45 | $user_upload_conf['waiting_rows'] = array(); |
---|
46 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
47 | array_push($user_upload_conf['waiting_rows'], $row); |
---|
48 | } |
---|
49 | |
---|
50 | // uploadable categories |
---|
51 | $query = ' |
---|
52 | SELECT id |
---|
53 | FROM '.CATEGORIES_TABLE.' |
---|
54 | WHERE uploadable = \'true\' |
---|
55 | ;'; |
---|
56 | $result = pwg_query($query); |
---|
57 | $user_upload_conf['uploadable_categories'] = array(); |
---|
58 | while ($row = pwg_db_fetch_assoc($result)) { |
---|
59 | array_push($user_upload_conf['uploadable_categories'], $row['id']); |
---|
60 | } |
---|
61 | |
---|
62 | // save configuration for a future use by the Community plugin |
---|
63 | $backup_filepath = $conf['local_data_dir'].'/plugins/core_user_upload_to_community.php'; |
---|
64 | $save_conf = true; |
---|
65 | if (is_dir(dirname($backup_filepath))) |
---|
66 | { |
---|
67 | if (!is_writable(dirname($backup_filepath))) |
---|
68 | { |
---|
69 | $save_conf = false; |
---|
70 | } |
---|
71 | } |
---|
72 | elseif (!is_writable($conf['local_data_dir'])) |
---|
73 | { |
---|
74 | $save_conf = false; |
---|
75 | } |
---|
76 | |
---|
77 | if ($save_conf) |
---|
78 | { |
---|
79 | mkgetdir(dirname($backup_filepath)); |
---|
80 | |
---|
81 | file_put_contents( |
---|
82 | $backup_filepath, |
---|
83 | '<?php $user_upload_conf = \''.serialize($user_upload_conf).'\'; ?>' |
---|
84 | ); |
---|
85 | } |
---|
86 | |
---|
87 | // |
---|
88 | // remove all what is related to user upload in the database |
---|
89 | // |
---|
90 | |
---|
91 | // categories.uploadable |
---|
92 | pwg_query('ALTER TABLE '.CATEGORIES_TABLE.' DROP COLUMN uploadable;'); |
---|
93 | |
---|
94 | // waiting |
---|
95 | pwg_query('DROP TABLE '.PREFIX_TABLE.'waiting;'); |
---|
96 | |
---|
97 | // config parameter settings : upload_user_access, upload_link_everytime |
---|
98 | $query = ' |
---|
99 | DELETE FROM '.PREFIX_TABLE.'config |
---|
100 | WHERE param IN (\'upload_user_access\', \'upload_link_everytime\', \'email_admin_on_picture_uploaded\') |
---|
101 | ;'; |
---|
102 | pwg_query($query); |
---|
103 | |
---|
104 | echo |
---|
105 | "\n" |
---|
106 | . $upgrade_description |
---|
107 | ."\n" |
---|
108 | ; |
---|
109 | ?> |
---|