1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Title plugin for piwigo by TEMMII | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2011 - 2024 ddtddt http://temmii.com/piwigo/ | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | This program is free software; you can redistribute it and/or modify | |
---|
8 | // | it under the terms of the GNU General Public License as published by | |
---|
9 | // | the Free Software Foundation | |
---|
10 | // | | |
---|
11 | // | This program is distributed in the hope that it will be useful, but | |
---|
12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
14 | // | General Public License for more details. | |
---|
15 | // | | |
---|
16 | // | You should have received a copy of the GNU General Public License | |
---|
17 | // | along with this program; if not, write to the Free Software | |
---|
18 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
19 | // | USA. | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | |
---|
22 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
23 | |
---|
24 | class title_maintain extends PluginMaintain |
---|
25 | { |
---|
26 | function install($plugin_version, &$errors=array()) |
---|
27 | { |
---|
28 | global $conf, $prefixeTable; |
---|
29 | |
---|
30 | $q = 'CREATE TABLE IF NOT EXISTS ' . $prefixeTable . 'title( |
---|
31 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
32 | page VARCHAR( 255 ) NOT NULL , |
---|
33 | title lONGTEXT NOT NULL , |
---|
34 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;'; |
---|
35 | pwg_query($q); |
---|
36 | |
---|
37 | $q = ' |
---|
38 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (1,"home","");'; |
---|
39 | pwg_query($q); |
---|
40 | $q = ' |
---|
41 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (2,"best_rated","");'; |
---|
42 | pwg_query($q); |
---|
43 | $q = ' |
---|
44 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (3,"most_visited","");'; |
---|
45 | pwg_query($q); |
---|
46 | $q = ' |
---|
47 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (4,"recent_pics","");'; |
---|
48 | pwg_query($q); |
---|
49 | $q = ' |
---|
50 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (5,"recent_cats","");'; |
---|
51 | pwg_query($q); |
---|
52 | $q = ' |
---|
53 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (6,"favorites","");'; |
---|
54 | pwg_query($q); |
---|
55 | $q = ' |
---|
56 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (7,"tags","");'; |
---|
57 | pwg_query($q); |
---|
58 | $q = ' |
---|
59 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (8,"comments","");'; |
---|
60 | pwg_query($q); |
---|
61 | $q = ' |
---|
62 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (9,"about","");'; |
---|
63 | pwg_query($q); |
---|
64 | $q = ' |
---|
65 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (10,"search","");'; |
---|
66 | pwg_query($q); |
---|
67 | $q = ' |
---|
68 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (11,"random","");'; |
---|
69 | pwg_query($q); |
---|
70 | $q = ' |
---|
71 | INSERT INTO ' . $prefixeTable . 'title(id,page,title)VALUES (12,"notification","");'; |
---|
72 | pwg_query($q); |
---|
73 | |
---|
74 | if (!defined('TITLE_PHOTO_TABLE')) define('TITLE_PHOTO_TABLE', $prefixeTable.'title_photo'); |
---|
75 | $query = "CREATE TABLE IF NOT EXISTS ". TITLE_PHOTO_TABLE ." ( |
---|
76 | id MEDIUMINT(8) UNSIGNED NOT NULL , |
---|
77 | title VARCHAR( 255 ) NOT NULL , |
---|
78 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
79 | $result = pwg_query($query); |
---|
80 | |
---|
81 | if (!defined('TITLE_ALBUM_TABLE')) define('TITLE_ALBUM_TABLE', $prefixeTable.'title_album'); |
---|
82 | $query = "CREATE TABLE IF NOT EXISTS ". TITLE_ALBUM_TABLE ." ( |
---|
83 | id MEDIUMINT(8) UNSIGNED NOT NULL , |
---|
84 | title VARCHAR( 255 ) NOT NULL , |
---|
85 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
86 | $result = pwg_query($query); |
---|
87 | |
---|
88 | if (empty($conf['contacttitle'])) |
---|
89 | { |
---|
90 | conf_update_param('contacttitle', ''); |
---|
91 | } |
---|
92 | |
---|
93 | if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap'); |
---|
94 | $query = "CREATE TABLE IF NOT EXISTS ". TITLE_AP_TABLE ." ( |
---|
95 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
96 | title VARCHAR( 255 ) NOT NULL , |
---|
97 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
98 | $result = pwg_query($query); |
---|
99 | } |
---|
100 | |
---|
101 | function update($old_version, $new_version, &$errors=array()) |
---|
102 | { |
---|
103 | //$this->install($new_version, $errors); |
---|
104 | global $conf, $prefixeTable; |
---|
105 | |
---|
106 | if (!defined('TITLE_PHOTO_TABLE')) define('TITLE_PHOTO_TABLE', $prefixeTable.'title_photo'); |
---|
107 | $row = pwg_db_fetch_assoc(pwg_query('SHOW COLUMNS FROM `'.TITLE_PHOTO_TABLE.'` LIKE "id";')); |
---|
108 | if (!preg_match('/^mediumint/i', $row['Type'])){ |
---|
109 | $q = 'ALTER TABLE ' . TITLE_PHOTO_TABLE . ' CHANGE `id` `id` MEDIUMINT(8) UNSIGNED NOT NULL '; |
---|
110 | pwg_query($q); |
---|
111 | } |
---|
112 | |
---|
113 | if (!isset($conf['contacttitle'])) |
---|
114 | { |
---|
115 | conf_update_param('contacttitle', ''); |
---|
116 | } |
---|
117 | |
---|
118 | if (!defined('TITLE_AP_TABLE')) define('TITLE_AP_TABLE', $prefixeTable.'title_ap'); |
---|
119 | $query = "CREATE TABLE IF NOT EXISTS ". TITLE_AP_TABLE ." ( |
---|
120 | id SMALLINT( 5 ) UNSIGNED NOT NULL , |
---|
121 | title VARCHAR( 255 ) NOT NULL , |
---|
122 | PRIMARY KEY (id))DEFAULT CHARSET=utf8;"; |
---|
123 | $result = pwg_query($query); |
---|
124 | |
---|
125 | } |
---|
126 | |
---|
127 | function uninstall() |
---|
128 | { |
---|
129 | global $prefixeTable; |
---|
130 | |
---|
131 | $q = 'DROP TABLE ' . $prefixeTable . 'title;'; |
---|
132 | pwg_query($q); |
---|
133 | |
---|
134 | $q = 'DROP TABLE ' . $prefixeTable . 'title_photo;'; |
---|
135 | pwg_query($q); |
---|
136 | |
---|
137 | $q = 'DROP TABLE ' . $prefixeTable . 'title_album;'; |
---|
138 | pwg_query($q); |
---|
139 | |
---|
140 | $q = 'DROP TABLE ' . $prefixeTable . 'title_ap;'; |
---|
141 | pwg_query($q); |
---|
142 | |
---|
143 | conf_delete_param('contacttitle'); |
---|
144 | |
---|
145 | } |
---|
146 | } |
---|