/
upgrade.inc.php
148 lines (119 loc) · 7.28 KB
/
upgrade.inc.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
// Must include code to stop this file being access directly
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_".$tablename."_cache`");
// topics table:
$query_topics = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_".$tablename." LIMIT 1");
$topic_fetch = $query_topics->fetchRow();
// Add field authors to mod_topics
if(!isset($topic_fetch['authors'])){
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_".$tablename."` ADD `authors` VARCHAR(255) NOT NULL DEFAULT ''")) {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "authors" added successfully</div><br />';
}
echo '<div style="color:#e92a0b; font-weight:bold;">'.$database->error().'</div><br />';
} else {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "authors" exists, update not needed</div><br />';
}
if($database->is_error()) {
echo ("OOPS, something went wrong. If it's a duplicate error then it's okay - it means that your database has already been modified.<br/>The error was: ".$database->get_error());
} else {
echo ("SUCCESS: The required changes have been made to your database.");
}
// Add field comments_count to mod_topics
if(!isset($topic_fetch['comments_count'])){
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_".$tablename."` ADD `comments_count` INT NOT NULL DEFAULT '-1'")) {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "comments_count" added successfully</div><br />';
}
echo '<div style="color:#e92a0b; font-weight:bold;">'.$database->error().'</div><br />';
} else {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "comments_count" exists, update not needed</div><br />';
}
if($database->is_error()) {
echo ("OOPS, something went wrong. If it's a duplicate error then it's okay - it means that your database has already been modified.<br/>The error was: ".$database->get_error());
} else {
echo ("SUCCESS: The required changes have been made to your database.");
}
//Settings table
// Add various_values:
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_".$tablename."_settings LIMIT 1");
$settings_fetch = $query_settings->fetchRow();
// Add field various_values to mod_topics
if(!isset($settings_fetch['various_values'])){
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_".$tablename."_settings` ADD `various_values` VARCHAR(255) NOT NULL DEFAULT '150,450,0,0,2,0,0,0,0,0'")) {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "various_values" added successfully</div><br />';
}
echo '<div style="color:#e92a0b; font-weight:bold;">'.$database->error().'</div><br />';
} else {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "various_values" exists, update not needed</div><br />';
}
if($database->is_error()) {
echo ("OOPS, something went wrong. If it's a duplicate error then it's okay - it means that your database has already been modified.<br/>The error was: ".$database->get_error());
} else {
echo ("SUCCESS: The required changes have been made to your database.");
}
// Add field autoarchive
if(!isset($settings_fetch['autoarchive'])){
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_".$tablename."_settings` ADD `autoarchive` VARCHAR(255) NOT NULL DEFAULT ''")) {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "autoarchive" added successfully</div><br />';
}
echo '<div style="color:#e92a0b; font-weight:bold;">'.$database->error().'</div><br />';
} else {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "autoarchive" exists, update not needed</div><br />';
}
if($database->is_error()) {
echo ("OOPS, something went wrong. If it's a duplicate error then it's okay - it means that your database has already been modified.<br/>The error was: ".$database->get_error());
} else {
echo ("SUCCESS: The required changes have been made to your database.");
}
// Add field picture_values
if(!isset($settings_fetch['picture_values'])){
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_".$tablename."_settings` ADD `picture_values` VARCHAR(255) NOT NULL DEFAULT '0,0,300,0,70,70,fbx'")) {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "picture_values" added successfully</div><br />';
}
echo '<div style="color:#e92a0b; font-weight:bold;">'.$database->error().'</div><br />';
} else {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "picture_values" exists, update not needed</div><br />';
}
if($database->is_error()) {
echo ("OOPS, something went wrong. If it's a duplicate error then it's okay - it means that your database has already been modified.<br/>The error was: ".$database->get_error());
} else {
echo ("SUCCESS: The required changes have been made to your database.");
}
// Add field is_master_for
if(!isset($settings_fetch['is_master_for'])){
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_".$tablename."_settings` ADD `is_master_for` VARCHAR(255) NOT NULL DEFAULT ''")) {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "is_master_for" added successfully</div><br />';
}
echo '<div style="color:#e92a0b; font-weight:bold;">'.$database->error().'</div><br />';
} else {
echo '<div style="color:#0bb61f; font-weight:bold;">Database Field "is_master_for" exists, update not needed</div><br />';
}
if($database->is_error()) {
echo ("OOPS, something went wrong. If it's a duplicate error then it's okay - it means that your database has already been modified.<br/>The error was: ".$database->get_error());
} else {
echo ("SUCCESS: The required changes have been made to your database.");
}
//Create folders and copy example pics
$picpath = WB_PATH.MEDIA_DIRECTORY.'/'.$mod_dir.'-pictures';
make_dir($picpath);
$frompath = (WB_PATH.'/modules/'.$mod_dir.'/img/');
if (!file_exists($picpath.'/1.jpg')) { copy($frompath.'1.jpg', $picpath.'/1.jpg') ; }
if (!file_exists($picpath.'/2.jpg')) { copy($frompath.'2.jpg', $picpath.'/2.jpg') ; }
if (!file_exists($picpath.'/3.jpg')) { copy($frompath.'3.jpg', $picpath.'/3.jpg') ; }
$picpath = WB_PATH.MEDIA_DIRECTORY.'/'.$mod_dir.'-pictures/thumbs';
make_dir($picpath);
if (!file_exists($picpath.'/1.jpg')) { copy($frompath.'thumb1.jpg', $picpath.'/1.jpg') ; }
if (!file_exists($picpath.'/2.jpg')) { copy($frompath.'thumb2.jpg', $picpath.'/2.jpg') ; }
if (!file_exists($picpath.'/3.jpg')) { copy($frompath.'thumb3.jpg', $picpath.'/3.jpg') ; }
$picpath = WB_PATH.MEDIA_DIRECTORY.'/'.$mod_dir.'-pictures/zoom';
make_dir($picpath);
if (!file_exists($picpath.'/1.jpg')) { copy($frompath.'zoom1.jpg', $picpath.'/1.jpg') ; }
if (!file_exists($picpath.'/2.jpg')) { copy($frompath.'zoom2.jpg', $picpath.'/2.jpg') ; }
if (!file_exists($picpath.'/3.jpg')) { copy($frompath.'zoom3.jpg', $picpath.'/3.jpg') ; }
//Copy settings files
$mpath = WB_PATH.'/modules/'.$mod_dir.'/';
if (!file_exists($mpath.'module_settings.php')) { copy($mpath.'defaults/module_settings.default.php', $mpath.'module_settings.php') ; }
if (!file_exists($mpath.'frontend.css')) { copy($mpath.'defaults/frontend.default.css', $mpath.'frontend.css') ; }
if (!file_exists($mpath.'comment_frame.css')) { copy($mpath.'defaults/comment_frame.default.css', $mpath.'comment_frame.css') ; }
if (!file_exists($mpath.'frontend.js')) { copy($mpath.'defaults/frontend.default.js', $mpath.'frontend.js') ; }
?>