Project

General

Profile

1
<?php
2

    
3
// $Id: install.php 1157 2009-10-09 21:54:57Z Luisehahne $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
if(defined('WB_URL')) {
27
	
28
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`");
29
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_posts` ( '
30
					 . '`post_id` INT NOT NULL AUTO_INCREMENT,'
31
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
32
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
33
					 . '`group_id` INT NOT NULL DEFAULT \'0\','
34
					 . '`active` INT NOT NULL DEFAULT \'0\','
35
					 . '`position` INT NOT NULL DEFAULT \'0\','
36
					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
37
					 . '`link` TEXT NOT NULL ,'
38
					 . '`content_short` TEXT NOT NULL ,'
39
					 . '`content_long` TEXT NOT NULL ,'
40
					 . '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\','
41
					 . '`published_when` INT NOT NULL DEFAULT \'0\','
42
					 . '`published_until` INT NOT NULL DEFAULT \'0\','
43
					 . '`posted_when` INT NOT NULL DEFAULT \'0\','
44
					 . '`posted_by` INT NOT NULL DEFAULT \'0\','
45
					 . 'PRIMARY KEY (post_id)'
46
					 . ' )';
47
	$database->query($mod_news);
48
	
49
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`");
50
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_groups` ( '
51
					 . '`group_id` INT NOT NULL AUTO_INCREMENT,'
52
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
53
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
54
					 . '`active` INT NOT NULL DEFAULT \'0\','
55
					 . '`position` INT NOT NULL DEFAULT \'0\','
56
					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
57
					 . 'PRIMARY KEY (group_id)'
58
                . ' )';
59
	$database->query($mod_news);
60
	
61
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`");
62
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_comments` ( '
63
					 . '`comment_id` INT NOT NULL AUTO_INCREMENT,'
64
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
65
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
66
					 . '`post_id` INT NOT NULL DEFAULT \'0\','
67
					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
68
					 . '`comment` TEXT NOT NULL ,'
69
		   	    . '`commented_when` INT NOT NULL DEFAULT \'0\','
70
					 . '`commented_by` INT NOT NULL DEFAULT \'0\','
71
					 . 'PRIMARY KEY (comment_id)'
72
                . ' )';
73
	$database->query($mod_news);
74
	
75
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`");
76
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_settings` ( '
77
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
78
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
79
					 . '`header` TEXT NOT NULL ,'
80
					 . '`post_loop` TEXT NOT NULL ,'
81
					 . '`footer` TEXT NOT NULL ,'
82
					 . '`posts_per_page` INT NOT NULL DEFAULT \'0\','
83
					 . '`post_header` TEXT NOT NULL,'
84
					 . '`post_footer` TEXT NOT NULL,'
85
					 . '`comments_header` TEXT NOT NULL,'
86
					 . '`comments_loop` TEXT NOT NULL,'
87
					 . '`comments_footer` TEXT NOT NULL,'
88
					 . '`comments_page` TEXT NOT NULL,'
89
					 . '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\','
90
					 . '`resize` INT NOT NULL DEFAULT \'0\','
91
					 . ' `use_captcha` INT NOT NULL DEFAULT \'0\','
92
					 . 'PRIMARY KEY (section_id)'
93
                . ' )';
94
	$database->query($mod_news);
95
		
96
    $mod_search = "SELECT * FROM ".TABLE_PREFIX."search  WHERE value = 'mod_wysiwyg_query'";
97
    $database->query($mod_search);
98
    $insert_search = $database->is_error();
99

    
100
    if( $insert_search )
101
    {
102
    	// Insert info into the search table
103
    	// Module query info
104
    	$field_info = array();
105
    	$field_info['page_id'] = 'page_id';
106
    	$field_info['title'] = 'page_title';
107
    	$field_info['link'] = 'link';
108
    	$field_info['description'] = 'description';
109
    	$field_info['modified_when'] = 'modified_when';
110
    	$field_info['modified_by'] = 'modified_by';
111
    	$field_info = serialize($field_info);
112
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'news', '$field_info')");
113
    	// Query start
114
    	$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 ";
115
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'news')");
116
    	// Query body
117
    	$query_body_code = "
118
    	[TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.title LIKE \'%[STRING]%\'
119
    	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_short LIKE \'%[STRING]%\'
120
    	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_long LIKE \'%[STRING]%\'
121
    	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.title LIKE \'%[STRING]%\'
122
    	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.comment LIKE \'%[STRING]%\'
123
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.header LIKE \'%[STRING]%\'
124
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.footer LIKE \'%[STRING]%\'
125
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_header LIKE \'%[STRING]%\'
126
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_footer LIKE \'%[STRING]%\'
127
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_header LIKE \'%[STRING]%\'
128
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'";
129
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'news')");
130
    	// Query end
131
    	$query_end_code = "";
132
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'news')");
133

    
134
    	// Insert blank row (there needs to be at least on row for the search to work)
135
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id) VALUES ('0', '0')");
136
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_groups (section_id,page_id) VALUES ('0', '0')");
137
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id) VALUES ('0', '0')");
138
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')");
139
    }
140

    
141
	// Make news post access files dir
142
	require_once(WB_PATH.'/framework/functions.php');
143
	if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
144
		// Add a index.php file to prevent directory spoofing
145
		$content = ''.
146
"<?php
147

    
148
/*
149

    
150
 Website Baker Project <http://www.websitebaker.org/>
151
 Copyright (C) 2004-2009, Ryan Djurovich
152

    
153
 Website Baker is free software; you can redistribute it and/or modify
154
 it under the terms of the GNU General Public License as published by
155
 the Free Software Foundation; either version 2 of the License, or
156
 (at your option) any later version.
157

    
158
 Website Baker is distributed in the hope that it will be useful,
159
 but WITHOUT ANY WARRANTY; without even the implied warranty of
160
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161
 GNU General Public License for more details.
162

    
163
 You should have received a copy of the GNU General Public License
164
 along with Website Baker; if not, write to the Free Software
165
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
166

    
167
*/
168

    
169
header('Location: ../');
170
?>";
171
		$handle = fopen(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'w');
172
		fwrite($handle, $content);
173
		fclose($handle);
174
		change_mode(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'file');
175
	}
176
};
177

    
178
?>
(14-14/30)