Revision 1587
Added by darkviper almost 13 years ago
install.php | ||
---|---|---|
14 | 14 |
* @lastmodified $Date$ |
15 | 15 |
* |
16 | 16 |
*/ |
17 |
|
|
18 |
if(defined('WB_URL')) |
|
19 |
{ |
|
20 |
|
|
21 |
// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`"); |
|
22 |
$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_posts` ( ' |
|
23 |
. '`post_id` INT NOT NULL AUTO_INCREMENT,' |
|
24 |
. '`section_id` INT NOT NULL DEFAULT \'0\',' |
|
25 |
. '`page_id` INT NOT NULL DEFAULT \'0\',' |
|
26 |
. '`group_id` INT NOT NULL DEFAULT \'0\',' |
|
27 |
. '`active` INT NOT NULL DEFAULT \'0\',' |
|
28 |
. '`position` INT NOT NULL DEFAULT \'0\',' |
|
29 |
. '`title` VARCHAR(255) NOT NULL DEFAULT \'\',' |
|
30 |
. '`link` TEXT NOT NULL ,' |
|
31 |
. '`content_short` TEXT NOT NULL ,' |
|
32 |
. '`content_long` TEXT NOT NULL ,' |
|
33 |
. '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\',' |
|
34 |
. '`created_when` INT NOT NULL DEFAULT \'0\',' |
|
35 |
. '`created_by` INT NOT NULL DEFAULT \'0\',' |
|
36 |
. '`published_when` INT NOT NULL DEFAULT \'0\',' |
|
37 |
. '`published_until` INT NOT NULL DEFAULT \'0\',' |
|
38 |
. '`posted_when` INT NOT NULL DEFAULT \'0\',' |
|
39 |
. '`posted_by` INT NOT NULL DEFAULT \'0\',' |
|
40 |
. 'PRIMARY KEY (post_id)' |
|
41 |
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; |
|
42 |
$database->query($mod_news); |
|
43 |
|
|
44 |
// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`"); |
|
45 |
$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_groups` ( ' |
|
46 |
. '`group_id` INT NOT NULL AUTO_INCREMENT,' |
|
47 |
. '`section_id` INT NOT NULL DEFAULT \'0\',' |
|
48 |
. '`page_id` INT NOT NULL DEFAULT \'0\',' |
|
49 |
. '`active` INT NOT NULL DEFAULT \'0\',' |
|
50 |
. '`position` INT NOT NULL DEFAULT \'0\',' |
|
51 |
. '`title` VARCHAR(255) NOT NULL DEFAULT \'\',' |
|
52 |
. 'PRIMARY KEY (group_id)' |
|
53 |
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; |
|
54 |
$database->query($mod_news); |
|
55 |
|
|
56 |
// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`"); |
|
57 |
$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_comments` ( ' |
|
58 |
. '`comment_id` INT NOT NULL AUTO_INCREMENT,' |
|
59 |
. '`section_id` INT NOT NULL DEFAULT \'0\',' |
|
60 |
. '`page_id` INT NOT NULL DEFAULT \'0\',' |
|
61 |
. '`post_id` INT NOT NULL DEFAULT \'0\',' |
|
62 |
. '`title` VARCHAR(255) NOT NULL DEFAULT \'\',' |
|
63 |
. '`comment` TEXT NOT NULL ,' |
|
64 |
. '`commented_when` INT NOT NULL DEFAULT \'0\',' |
|
65 |
. '`commented_by` INT NOT NULL DEFAULT \'0\',' |
|
66 |
. 'PRIMARY KEY (comment_id)' |
|
67 |
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; |
|
68 |
|
|
69 |
$database->query($mod_news); |
|
70 |
|
|
71 |
// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`"); |
|
72 |
$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_settings` ( ' |
|
73 |
. '`section_id` INT NOT NULL DEFAULT \'0\',' |
|
74 |
. '`page_id` INT NOT NULL DEFAULT \'0\',' |
|
75 |
. '`header` TEXT NOT NULL ,' |
|
76 |
. '`post_loop` TEXT NOT NULL ,' |
|
77 |
. '`footer` TEXT NOT NULL ,' |
|
78 |
. '`posts_per_page` INT NOT NULL DEFAULT \'0\',' |
|
79 |
. '`post_header` TEXT NOT NULL,' |
|
80 |
. '`post_footer` TEXT NOT NULL,' |
|
81 |
. '`comments_header` TEXT NOT NULL,' |
|
82 |
. '`comments_loop` TEXT NOT NULL,' |
|
83 |
. '`comments_footer` TEXT NOT NULL,' |
|
84 |
. '`comments_page` TEXT NOT NULL,' |
|
85 |
. '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\',' |
|
86 |
. '`resize` INT NOT NULL DEFAULT \'0\',' |
|
87 |
. ' `use_captcha` INT NOT NULL DEFAULT \'0\',' |
|
88 |
. 'PRIMARY KEY (section_id)' |
|
89 |
. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; |
|
90 |
|
|
91 |
$database->query($mod_news); |
|
92 |
|
|
93 |
$mod_search = "SELECT * FROM ".TABLE_PREFIX."search WHERE value = 'news'"; |
|
94 |
$insert_search = $database->query($mod_search); |
|
95 |
if( $insert_search->numRows() == 0 ) |
|
96 |
{ |
|
97 |
// Insert info into the search table |
|
98 |
// Module query info |
|
99 |
$field_info = array(); |
|
100 |
$field_info['page_id'] = 'page_id'; |
|
101 |
$field_info['title'] = 'page_title'; |
|
102 |
$field_info['link'] = 'link'; |
|
103 |
$field_info['description'] = 'description'; |
|
104 |
$field_info['modified_when'] = 'modified_when'; |
|
105 |
$field_info['modified_by'] = 'modified_by'; |
|
106 |
$field_info = serialize($field_info); |
|
107 |
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'news', '$field_info')"); |
|
108 |
// Query start |
|
109 |
$query_start_code = "SELECT [TP]pages.page_id, [TP]pages.page_title, [TP]pages.link, [TP]pages.description, [TP]pages.modified_when, [TP]pages.modified_by FROM [TP]mod_news_posts, [TP]mod_news_groups, [TP]mod_news_comments, [TP]mod_news_settings, [TP]pages WHERE "; |
|
110 |
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'news')"); |
|
111 |
// Query body |
|
112 |
$query_body_code = " |
|
113 |
[TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.title LIKE \'%[STRING]%\' |
|
114 |
OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_short LIKE \'%[STRING]%\' |
|
115 |
OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_long LIKE \'%[STRING]%\' |
|
116 |
OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.title LIKE \'%[STRING]%\' |
|
117 |
OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.comment LIKE \'%[STRING]%\' |
|
118 |
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.header LIKE \'%[STRING]%\' |
|
119 |
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.footer LIKE \'%[STRING]%\' |
|
120 |
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_header LIKE \'%[STRING]%\' |
|
121 |
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_footer LIKE \'%[STRING]%\' |
|
122 |
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_header LIKE \'%[STRING]%\' |
|
123 |
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'"; |
|
124 |
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'news')"); |
|
125 |
// Query end |
|
126 |
$query_end_code = ""; |
|
127 |
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'news')"); |
|
128 |
|
|
129 |
// Insert blank row (there needs to be at least on row for the search to work) |
|
130 |
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id) VALUES ('0', '0')"); |
|
131 |
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_groups (section_id,page_id) VALUES ('0', '0')"); |
|
132 |
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id) VALUES ('0', '0')"); |
|
133 |
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')"); |
|
134 |
} |
|
135 |
|
|
136 |
// Make news post access files dir |
|
137 |
require_once(WB_PATH.'/framework/functions.php'); |
|
138 |
if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) { |
|
139 |
// Add a index.php file to prevent directory spoofing |
|
140 |
$content = ''. |
|
141 |
"<?php |
|
142 |
|
|
143 |
/* |
|
144 |
|
|
145 |
Website Baker Project <http://www.websitebaker.org/> |
|
146 |
Copyright (C) 2004-2009, Ryan Djurovich |
|
147 |
|
|
148 |
Website Baker is free software; you can redistribute it and/or modify |
|
149 |
it under the terms of the GNU General Public License as published by |
|
150 |
the Free Software Foundation; either version 2 of the License, or |
|
151 |
(at your option) any later version. |
|
152 |
|
|
153 |
Website Baker is distributed in the hope that it will be useful, |
|
154 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
155 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
156 |
GNU General Public License for more details. |
|
157 |
|
|
158 |
You should have received a copy of the GNU General Public License |
|
159 |
along with Website Baker; if not, write to the Free Software |
|
160 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
161 |
|
|
162 |
*/ |
|
163 |
|
|
164 |
header('Location: ../'); |
|
165 |
?>"; |
|
166 |
$handle = fopen(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'w'); |
|
167 |
fwrite($handle, $content); |
|
168 |
fclose($handle); |
|
169 |
change_mode(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'file'); |
|
17 |
/* -------------------------------------------------------- */ |
|
18 |
// Must include code to stop this file being accessed directly |
|
19 |
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php'); |
|
20 |
if(!defined('WB_PATH')) { throw new IllegalFileException(); } |
|
21 |
/* -------------------------------------------------------- */ |
|
22 |
$sDefaultSql = dirname(__FILE__).'/install.sql'; |
|
23 |
if (is_readable($sDefaultSql)) { |
|
24 |
// create needet database tables and set default records |
|
25 |
if ($database->SqlImport($sDefaultSql, TABLE_PREFIX)) { |
|
26 |
// Make news post access files dir |
|
27 |
require_once(WB_PATH.'/framework/functions.php'); |
|
28 |
if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) { |
|
29 |
// Add a index.php file to prevent directory spoofing |
|
30 |
$sResponse = $_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently'; |
|
31 |
$sContent = |
|
32 |
'<?php'."\n". |
|
33 |
'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n". |
|
34 |
'// *** Creation date: '.date('c')."\n". |
|
35 |
'// *** Do not modify this file manually'."\n". |
|
36 |
'// *** WB will rebuild this file from time to time!!'."\n". |
|
37 |
'// *************************************************'."\n". |
|
38 |
"\t".'header(\''.$sResponse.'\');'."\n". |
|
39 |
"\t".'header(\'Location: ../index.php\');'."\n". |
|
40 |
'// *************************************************'."\n"; |
|
41 |
$sFilename = WB_PATH.PAGES_DIRECTORY.'/posts/index.php'; |
|
42 |
file_put_contents($sFilename, $sContent); |
|
43 |
change_mode($sFilename, 'file'); |
|
44 |
} |
|
45 |
} |
|
170 | 46 |
} |
171 |
};
|
|
47 |
/* **** END INSTALL ********************************************************* */
|
Also available in: Unified diff
news: added sql-dump to create database tables, some little fixes in install/upgrade