Revision 5
Added by stefan about 19 years ago
trunk/wb/include/htmlarea/popups/link.php | ||
---|---|---|
73 | 73 |
// Function to generate page list |
74 | 74 |
function gen_page_list($parent) { |
75 | 75 |
global $template, $database; |
76 |
$get_pages = $database->query("SELECT page_id,menu_title,link,level FROM ".TABLE_PREFIX."pages WHERE parent = '$parent'"); |
|
76 |
$get_pages = $database->query("SELECT page_id,menu_title,link,level FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted'");
|
|
77 | 77 |
while($page = $get_pages->fetchRow()) { |
78 | 78 |
$title = stripslashes($page['menu_title']); |
79 | 79 |
// Add leading -'s so we can tell what level a page is at |
... | ... | |
91 | 91 |
// Get pages and put them into the pages list |
92 | 92 |
$template->set_block('main_block', 'page_list_block', 'page_list'); |
93 | 93 |
$database = new database(); |
94 |
$get_pages = $database->query("SELECT page_id,menu_title,link FROM ".TABLE_PREFIX."pages WHERE parent = '0'"); |
|
94 |
$get_pages = $database->query("SELECT page_id,menu_title,link FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND visibility!='deleted'");
|
|
95 | 95 |
if($get_pages > 0) { |
96 | 96 |
// Add 'Please select...' |
97 | 97 |
$template->set_var('TITLE', 'Please select...'); |
... | ... | |
115 | 115 |
$template->parse('main', 'main_block', false); |
116 | 116 |
$template->pparse('output', 'page'); |
117 | 117 |
|
118 |
?> |
|
118 |
?> |
trunk/wb/install/save.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
// $Id: save.php,v 1.15 2005/04/25 11:53:12 rdjurovich Exp $ +// $Id: save.php,v 1.15 2005/04/25 11:53:12 rdjurovich Exp $ |
|
4 | 3 |
|
5 | 4 |
/* |
6 | 5 |
|
... | ... | |
21 | 21 |
along with Website Baker; if not, write to the Free Software |
22 | 22 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 | 23 |
|
24 |
*/ |
|
25 |
|
|
26 |
// Start a session |
|
27 |
if(!defined('SESSION_STARTED')) { |
|
28 |
session_name('wb_session_id'); |
|
29 |
session_start(); |
|
30 |
define('SESSION_STARTED', true); |
|
31 |
} |
|
24 |
*/ |
|
32 | 25 |
|
33 |
// Function to set error |
|
34 |
function set_error($message) { |
|
35 |
global $_POST; |
|
36 |
if(isset($message) AND $message != '') { |
|
37 |
// Copy values entered into session so user doesn't have to re-enter everything |
|
38 |
if(isset($_POST['website_title'])) { |
|
39 |
$_SESSION['wb_url'] = $_POST['wb_url']; |
|
40 |
$_SESSION['wb_path'] = $_POST['wb_path']; |
|
41 |
$_SESSION['default_timezone'] = $_POST['default_timezone']; |
|
42 |
if(!isset($_POST['operating_system'])) { |
|
43 |
$_SESSION['operating_system'] = 'linux'; |
|
44 |
} else { |
|
45 |
$_SESSION['operating_system'] = $_POST['operating_system']; |
|
46 |
} |
|
47 |
if(!isset($_POST['world_writeable'])) { |
|
48 |
$_SESSION['world_writeable'] = false; |
|
49 |
} else { |
|
50 |
$_SESSION['world_writeable'] = true; |
|
51 |
} |
|
52 |
$_SESSION['database_host'] = $_POST['database_host']; |
|
53 |
$_SESSION['database_username'] = $_POST['database_username']; |
|
54 |
$_SESSION['database_password'] = $_POST['database_password']; |
|
55 |
$_SESSION['database_name'] = $_POST['database_name']; |
|
56 |
$_SESSION['table_prefix'] = $_POST['table_prefix']; |
|
57 |
if(!isset($_POST['install_tables'])) { |
|
58 |
$_SESSION['install_tables'] = false; |
|
59 |
} else { |
|
60 |
$_SESSION['install_tables'] = true; |
|
61 |
} |
|
62 |
$_SESSION['website_title'] = $_POST['website_title']; |
|
63 |
$_SESSION['admin_username'] = $_POST['admin_username']; |
|
64 |
$_SESSION['admin_email'] = $_POST['admin_email']; |
|
65 |
$_SESSION['admin_password'] = $_POST['admin_password']; |
|
66 |
} |
|
67 |
// Set the message |
|
68 |
$_SESSION['message'] = $message; |
|
69 |
// Specify that session support is enabled |
|
70 |
$_SESSION['session_support'] = '<font class="good">Enabled</font>'; |
|
71 |
// Redirect to first page again and exit |
|
72 |
header('Location: index.php?sessions_checked=true'); |
|
73 |
exit(); |
|
74 |
} |
|
75 |
} |
|
26 |
// Start a session |
|
27 |
if(!defined('SESSION_STARTED')) { |
|
28 |
session_name('wb_session_id'); |
|
29 |
session_start(); |
|
30 |
define('SESSION_STARTED', true); |
|
31 |
} |
|
76 | 32 |
|
77 |
// Function to workout what the default permissions are for files created by the webserver |
|
78 |
function default_file_mode($temp_dir) { |
|
33 |
// Function to set error |
|
34 |
function set_error($message) { |
|
35 |
global $_POST; |
|
36 |
if(isset($message) AND $message != '') { |
|
37 |
// Copy values entered into session so user doesn't have to re-enter everything |
|
38 |
if(isset($_POST['website_title'])) { |
|
39 |
$_SESSION['wb_url'] = $_POST['wb_url']; |
|
40 |
$_SESSION['wb_path'] = $_POST['wb_path']; |
|
41 |
$_SESSION['default_timezone'] = $_POST['default_timezone']; |
|
42 |
if(!isset($_POST['operating_system'])) { |
|
43 |
$_SESSION['operating_system'] = 'linux'; |
|
44 |
} else { |
|
45 |
$_SESSION['operating_system'] = $_POST['operating_system']; |
|
46 |
} |
|
47 |
if(!isset($_POST['world_writeable'])) { |
|
48 |
$_SESSION['world_writeable'] = false; |
|
49 |
} else { |
|
50 |
$_SESSION['world_writeable'] = true; |
|
51 |
} |
|
52 |
$_SESSION['database_host'] = $_POST['database_host']; |
|
53 |
$_SESSION['database_username'] = $_POST['database_username']; |
|
54 |
$_SESSION['database_password'] = $_POST['database_password']; |
|
55 |
$_SESSION['database_name'] = $_POST['database_name']; |
|
56 |
$_SESSION['table_prefix'] = $_POST['table_prefix']; |
|
57 |
if(!isset($_POST['install_tables'])) { |
|
58 |
$_SESSION['install_tables'] = false; |
|
59 |
} else { |
|
60 |
$_SESSION['install_tables'] = true; |
|
61 |
} |
|
62 |
$_SESSION['website_title'] = $_POST['website_title']; |
|
63 |
$_SESSION['admin_username'] = $_POST['admin_username']; |
|
64 |
$_SESSION['admin_email'] = $_POST['admin_email']; |
|
65 |
$_SESSION['admin_password'] = $_POST['admin_password']; |
|
66 |
} |
|
67 |
// Set the message |
|
68 |
$_SESSION['message'] = $message; |
|
69 |
// Specify that session support is enabled |
|
70 |
$_SESSION['session_support'] = '<font class="good">Enabled</font>'; |
|
71 |
// Redirect to first page again and exit |
|
72 |
header('Location: index.php?sessions_checked=true'); |
|
73 |
exit(); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
// Function to workout what the default permissions are for files created by the webserver |
|
78 |
function default_file_mode($temp_dir) { |
|
79 | 79 |
$v = explode(".",PHP_VERSION); |
80 | 80 |
$v = $v[0].$v[1]; |
81 |
if($v > 41 AND is_writable($temp_dir)) { |
|
81 |
if($v > 41 AND is_writable($temp_dir)) {
|
|
82 | 82 |
$filename = $temp_dir.'/test_permissions.txt'; |
83 | 83 |
$handle = fopen($filename, 'w'); |
84 | 84 |
fwrite($handle, 'This file is to get the default file permissions'); |
... | ... | |
91 | 91 |
return $default_file_mode; |
92 | 92 |
} |
93 | 93 |
|
94 |
// Function to workout what the default permissions are for directories created by the webserver |
|
94 |
// Function to workout what the default permissions are for directories created by the webserver
|
|
95 | 95 |
function default_dir_mode($temp_dir) { |
96 | 96 |
$v = explode(".",PHP_VERSION); |
97 | 97 |
$v = $v[0].$v[1]; |
... | ... | |
104 | 104 |
$default_dir_mode = '0777'; |
105 | 105 |
} |
106 | 106 |
return $default_dir_mode; |
107 |
} |
|
108 |
|
|
109 |
// Begin check to see if form was even submitted |
|
110 |
// Set error if no post vars found |
|
111 |
if(!isset($_POST['website_title'])) { |
|
112 |
set_error('Please fill-in the form below'); |
|
113 |
} |
|
107 |
}
|
|
108 |
|
|
109 |
// Begin check to see if form was even submitted
|
|
110 |
// Set error if no post vars found
|
|
111 |
if(!isset($_POST['website_title'])) {
|
|
112 |
set_error('Please fill-in the form below');
|
|
113 |
}
|
|
114 | 114 |
// End check to see if form was even submitted |
115 |
|
|
115 |
|
|
116 | 116 |
// Begin path and timezone details code |
117 |
// Check if user has entered the installation path |
|
118 |
if(!isset($_POST['wb_path']) OR $_POST['wb_path'] == '') { |
|
119 |
set_error('Please enter an absolute path'); |
|
120 |
} else { |
|
121 |
$wb_path = $_POST['wb_path']; |
|
122 |
} |
|
123 |
// Check if user has entered the installation url |
|
124 |
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') { |
|
125 |
set_error('Please enter an absolute URL'); |
|
126 |
} else { |
|
127 |
$wb_url = $_POST['wb_url']; |
|
128 |
} |
|
129 |
// Remove any slashes at the end of the URL and path |
|
117 |
// Check if user has entered the installation path
|
|
118 |
if(!isset($_POST['wb_path']) OR $_POST['wb_path'] == '') {
|
|
119 |
set_error('Please enter an absolute path');
|
|
120 |
} else {
|
|
121 |
$wb_path = $_POST['wb_path'];
|
|
122 |
}
|
|
123 |
// Check if user has entered the installation url
|
|
124 |
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
|
|
125 |
set_error('Please enter an absolute URL');
|
|
126 |
} else {
|
|
127 |
$wb_url = $_POST['wb_url'];
|
|
128 |
}
|
|
129 |
// Remove any slashes at the end of the URL and path
|
|
130 | 130 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
131 | 131 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
132 | 132 |
} |
133 | 133 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "/") { |
134 | 134 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
135 |
} |
|
135 |
}
|
|
136 | 136 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
137 | 137 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
138 | 138 |
} |
139 | 139 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") { |
140 | 140 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
141 |
} |
|
141 |
}
|
|
142 | 142 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") { |
143 | 143 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
144 | 144 |
} |
145 | 145 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "/") { |
146 | 146 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
147 |
} |
|
147 |
}
|
|
148 | 148 |
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") { |
149 | 149 |
$wb_url = substr($wb_url, 0, strlen($wb_url)-1); |
150 | 150 |
} |
151 | 151 |
if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") { |
152 | 152 |
$wb_path = substr($wb_path, 0, strlen($wb_path)-1); |
153 |
} |
|
154 |
// Get the default time zone |
|
155 |
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) { |
|
156 |
set_error('Please select a valid default timezone'); |
|
157 |
} else { |
|
158 |
$default_timezone = $_POST['default_timezone']*60*60; |
|
159 |
} |
|
160 |
// End path and timezone details code |
|
161 |
|
|
162 |
// Begin operating system specific code |
|
163 |
// Get operating system |
|
164 |
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') { |
|
165 |
set_error('Please select a valid operating system'); |
|
166 |
} else { |
|
167 |
$operating_system = $_POST['operating_system']; |
|
168 |
} |
|
169 |
// Work-out file permissions |
|
170 |
if($operating_system == 'windows') { |
|
171 |
$file_mode = '0777'; |
|
172 |
$dir_mode = '0777'; |
|
173 |
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') { |
|
174 |
$file_mode = '0777'; |
|
175 |
$dir_mode = '0777'; |
|
176 |
} else { |
|
153 |
}
|
|
154 |
// Get the default time zone
|
|
155 |
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
|
|
156 |
set_error('Please select a valid default timezone');
|
|
157 |
} else {
|
|
158 |
$default_timezone = $_POST['default_timezone']*60*60;
|
|
159 |
}
|
|
160 |
// End path and timezone details code
|
|
161 |
|
|
162 |
// Begin operating system specific code
|
|
163 |
// Get operating system
|
|
164 |
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
|
|
165 |
set_error('Please select a valid operating system');
|
|
166 |
} else {
|
|
167 |
$operating_system = $_POST['operating_system'];
|
|
168 |
}
|
|
169 |
// Work-out file permissions
|
|
170 |
if($operating_system == 'windows') {
|
|
171 |
$file_mode = '0777';
|
|
172 |
$dir_mode = '0777';
|
|
173 |
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
|
174 |
$file_mode = '0777';
|
|
175 |
$dir_mode = '0777';
|
|
176 |
} else {
|
|
177 | 177 |
$file_mode = default_file_mode('../temp'); |
178 |
$dir_mode = default_dir_mode('../temp'); |
|
179 |
} |
|
180 |
// End operating system specific code |
|
181 |
|
|
178 |
$dir_mode = default_dir_mode('../temp');
|
|
179 |
}
|
|
180 |
// End operating system specific code
|
|
181 |
|
|
182 | 182 |
// Begin database details code |
183 | 183 |
// Check if user has entered a database host |
184 | 184 |
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') { |
... | ... | |
205 | 205 |
$database_name = $_POST['database_name']; |
206 | 206 |
} |
207 | 207 |
// Get table prefix |
208 |
$table_prefix = $_POST['table_prefix']; |
|
209 |
// Find out if the user wants to install tables and data |
|
210 |
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') { |
|
211 |
$install_tables = true; |
|
212 |
} else { |
|
213 |
$install_tables = false; |
|
208 |
$table_prefix = $_POST['table_prefix'];
|
|
209 |
// Find out if the user wants to install tables and data
|
|
210 |
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
|
|
211 |
$install_tables = true;
|
|
212 |
} else {
|
|
213 |
$install_tables = false;
|
|
214 | 214 |
} |
215 | 215 |
// End database details code |
216 |
|
|
217 |
// Begin website title code |
|
218 |
// Get website title |
|
219 |
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') { |
|
220 |
set_error('Please enter a website title'); |
|
221 |
} else { |
|
222 |
$website_title = addslashes($_POST['website_title']); |
|
223 |
} |
|
224 |
// End website title code |
|
225 |
|
|
226 |
// Begin admin user details code |
|
227 |
// Get admin username |
|
228 |
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') { |
|
229 |
set_error('Please enter a username for the Administrator account'); |
|
230 |
} else { |
|
231 |
$admin_username = $_POST['admin_username']; |
|
232 |
} |
|
233 |
// Get admin email and validate it |
|
234 |
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') { |
|
235 |
set_error('Please enter an email for the Administrator account'); |
|
236 |
} else { |
|
237 |
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['admin_email'])) { |
|
238 |
$admin_email = $_POST['admin_email']; |
|
239 |
} else { |
|
240 |
set_error('Please enter a valid email address for the Administrator account'); |
|
241 |
} |
|
242 |
} |
|
243 |
// Get the two admin passwords entered, and check that they match |
|
244 |
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') { |
|
245 |
set_error('Please enter a password for the Administrator account'); |
|
246 |
} else { |
|
247 |
$admin_password = $_POST['admin_password']; |
|
248 |
} |
|
249 |
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') { |
|
250 |
set_error('Please make sure you re-enter the password for the Administrator account'); |
|
251 |
} else { |
|
252 |
$admin_repassword = $_POST['admin_repassword']; |
|
253 |
} |
|
254 |
if($admin_password != $admin_repassword) { |
|
255 |
set_error('Sorry, the two Administrator account passwords you entered do not match'); |
|
256 |
} |
|
257 |
// End admin user details code |
|
258 |
|
|
216 |
|
|
217 |
// Begin website title code
|
|
218 |
// Get website title
|
|
219 |
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
|
|
220 |
set_error('Please enter a website title');
|
|
221 |
} else {
|
|
222 |
$website_title = addslashes($_POST['website_title']);
|
|
223 |
}
|
|
224 |
// End website title code
|
|
225 |
|
|
226 |
// Begin admin user details code
|
|
227 |
// Get admin username
|
|
228 |
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
|
|
229 |
set_error('Please enter a username for the Administrator account');
|
|
230 |
} else {
|
|
231 |
$admin_username = $_POST['admin_username'];
|
|
232 |
}
|
|
233 |
// Get admin email and validate it
|
|
234 |
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
|
|
235 |
set_error('Please enter an email for the Administrator account');
|
|
236 |
} else {
|
|
237 |
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['admin_email'])) {
|
|
238 |
$admin_email = $_POST['admin_email'];
|
|
239 |
} else {
|
|
240 |
set_error('Please enter a valid email address for the Administrator account');
|
|
241 |
}
|
|
242 |
}
|
|
243 |
// Get the two admin passwords entered, and check that they match
|
|
244 |
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
|
|
245 |
set_error('Please enter a password for the Administrator account');
|
|
246 |
} else {
|
|
247 |
$admin_password = $_POST['admin_password'];
|
|
248 |
}
|
|
249 |
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
|
|
250 |
set_error('Please make sure you re-enter the password for the Administrator account');
|
|
251 |
} else {
|
|
252 |
$admin_repassword = $_POST['admin_repassword'];
|
|
253 |
}
|
|
254 |
if($admin_password != $admin_repassword) {
|
|
255 |
set_error('Sorry, the two Administrator account passwords you entered do not match');
|
|
256 |
}
|
|
257 |
// End admin user details code
|
|
258 |
|
|
259 | 259 |
// Try and write settings to config file |
260 | 260 |
$config_content = "" . |
261 | 261 |
"<?php\n". |
... | ... | |
277 | 277 |
"define('DEFAULT_TIMEZONE', '$default_timezone');\n". |
278 | 278 |
"define('DEFAULT_DATE_FORMAT', 'M d Y');\n". |
279 | 279 |
"define('DEFAULT_TIME_FORMAT', 'g:i A');\n". |
280 |
"\n". |
|
281 |
"define('HOME_FOLDERS', true);\n". |
|
282 | 280 |
"\n". |
283 |
"define('DEFAULT_TEMPLATE', 'round');\n". |
|
284 |
"define('MULTIPLE_MENUS', false);\n". |
|
285 |
"\n". |
|
286 |
"define('PAGE_LEVEL_LIMIT', '4');\n". |
|
287 |
"define('INTRO_PAGE', false);\n". |
|
288 |
"define('PAGE_TRASH', 'disabled');\n". |
|
289 |
"define('HOMEPAGE_REDIRECTION', false);\n". |
|
281 |
"define('HOME_FOLDERS', true);\n". |
|
282 |
"\n". |
|
283 |
"define('DEFAULT_TEMPLATE', 'round');\n". |
|
284 |
"define('MULTIPLE_MENUS', false);\n". |
|
285 |
"\n". |
|
286 |
"define('PAGE_LEVEL_LIMIT', '4');\n". |
|
287 |
"define('INTRO_PAGE', false);\n". |
|
288 |
"define('PAGE_TRASH', 'disabled');\n". |
|
289 |
"define('HOMEPAGE_REDIRECTION', false);\n". |
|
290 | 290 |
"define('PAGE_LANGUAGES', false);\n". |
291 |
"\n". |
|
292 |
"define('WYSIWYG_STYLE', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;');\n". |
|
293 | 291 |
"\n". |
294 |
"define('MANAGE_SECTIONS', true);\n". |
|
295 |
"define('SECTION_BLOCKS', false);\n". |
|
292 |
"define('WYSIWYG_STYLE', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;');\n". |
|
296 | 293 |
"\n". |
294 |
"define('MANAGE_SECTIONS', true);\n". |
|
295 |
"define('SECTION_BLOCKS', false);\n". |
|
296 |
"\n". |
|
297 | 297 |
"define('SMART_LOGIN', false);\n". |
298 | 298 |
"define('FRONTEND_LOGIN', false);\n". |
299 | 299 |
"define('FRONTEND_SIGNUP', '');\n". |
300 | 300 |
"\n". |
301 |
"define('SERVER_EMAIL', '".$admin_email."');\n". |
|
301 |
"define('SERVER_EMAIL', '".$admin_email."');\n".
|
|
302 | 302 |
"\n". |
303 | 303 |
"define('SEARCH', 'public');\n". |
304 | 304 |
"\n". |
... | ... | |
307 | 307 |
"\n". |
308 | 308 |
"define('PAGES_DIRECTORY', '/pages');\n". |
309 | 309 |
"define('MEDIA_DIRECTORY', '/media');\n". |
310 |
"\n". |
|
310 |
"\n".
|
|
311 | 311 |
"define('OPERATING_SYSTEM', '$operating_system');\n". |
312 | 312 |
"define('OCTAL_FILE_MODE', $file_mode);\n". |
313 | 313 |
"define('STRING_FILE_MODE', '$file_mode');\n". |
... | ... | |
337 | 337 |
} |
338 | 338 |
} else { |
339 | 339 |
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4."); |
340 |
} |
|
340 |
}
|
|
341 | 341 |
|
342 | 342 |
// Include configuration file |
343 |
require('../config.php'); |
|
344 |
|
|
345 |
// Check if the user has entered a correct path |
|
346 |
if(!file_exists(WB_PATH.'/framework/class.admin.php')) { |
|
347 |
set_error('It appears the Absolute path that you entered is incorrect'); |
|
348 |
} |
|
349 |
|
|
350 |
// Include WB functions file |
|
351 |
if(!defined('FUNCTIONS_FILE_LOADED')) { |
|
352 |
require(WB_PATH.'/framework/functions.php'); |
|
353 |
} |
|
343 |
require('../config.php'); |
|
354 | 344 |
|
345 |
// Check if the user has entered a correct path |
|
346 |
if(!file_exists(WB_PATH.'/framework/class.admin.php')) { |
|
347 |
set_error('It appears the Absolute path that you entered is incorrect'); |
|
348 |
} |
|
349 |
|
|
350 |
// Include WB functions file |
|
351 |
require_once(WB_PATH.'/framework/functions.php'); |
|
352 |
|
|
355 | 353 |
// Try connecting to database |
356 |
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) { |
|
357 |
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error()); |
|
358 |
} |
|
359 |
|
|
354 |
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
|
|
355 |
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
|
|
356 |
}
|
|
357 |
|
|
360 | 358 |
// Try to create the database |
361 |
mysql_query('CREATE DATABASE '.$database_name); |
|
362 |
|
|
363 |
// Close the mysql connection |
|
364 |
mysql_close(); |
|
365 |
|
|
366 |
// Re-connect to the database, this time using in-build database class |
|
367 |
require(WB_PATH.'/framework/class.admin.php'); |
|
359 |
mysql_query('CREATE DATABASE '.$database_name);
|
|
360 |
|
|
361 |
// Close the mysql connection
|
|
362 |
mysql_close();
|
|
363 |
|
|
364 |
// Re-connect to the database, this time using in-build database class
|
|
365 |
require(WB_PATH.'/framework/class.admin.php');
|
|
368 | 366 |
$database = new database(); |
369 | 367 |
|
370 | 368 |
// Check if we should install tables |
... | ... | |
403 | 401 |
. ' `page_title` VARCHAR( 255 ) NOT NULL ,' |
404 | 402 |
. ' `menu_title` VARCHAR( 255 ) NOT NULL ,' |
405 | 403 |
. ' `description` TEXT NOT NULL ,' |
406 |
. ' `keywords` TEXT NOT NULL ,' |
|
404 |
. ' `keywords` TEXT NOT NULL ,'
|
|
407 | 405 |
. ' `page_trail` TEXT NOT NULL ,' |
408 | 406 |
. ' `template` VARCHAR( 255 ) NOT NULL ,' |
409 | 407 |
. ' `visibility` VARCHAR( 255 ) NOT NULL ,' |
410 |
. ' `position` INT NOT NULL ,' |
|
411 |
. ' `menu` INT NOT NULL ,' |
|
408 |
. ' `position` INT NOT NULL ,'
|
|
409 |
. ' `menu` INT NOT NULL ,'
|
|
412 | 410 |
. ' `language` VARCHAR( 5 ) NOT NULL ,' |
413 | 411 |
. ' `searching` INT NOT NULL ,' |
414 | 412 |
. ' `admin_groups` TEXT NOT NULL ,' |
... | ... | |
425 | 423 |
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,' |
426 | 424 |
. ' `page_id` INT NOT NULL ,' |
427 | 425 |
. ' `position` INT NOT NULL ,' |
428 |
. ' `module` VARCHAR( 255 ) NOT NULL ,' |
|
426 |
. ' `module` VARCHAR( 255 ) NOT NULL ,'
|
|
429 | 427 |
. ' `block` VARCHAR( 255 ) NOT NULL ,' |
430 | 428 |
. ' PRIMARY KEY ( `section_id` ) )' |
431 | 429 |
. ' '; |
... | ... | |
452 | 450 |
. ' `timezone` INT NOT NULL ,' |
453 | 451 |
. ' `date_format` VARCHAR( 255 ) NOT NULL ,' |
454 | 452 |
. ' `time_format` VARCHAR( 255 ) NOT NULL ,' |
455 |
. ' `language` VARCHAR( 5 ) NOT NULL ,' |
|
453 |
. ' `language` VARCHAR( 5 ) NOT NULL ,'
|
|
456 | 454 |
. ' `home_folder` TEXT NOT NULL ,' |
457 | 455 |
. ' `login_when` INT NOT NULL ,' |
458 | 456 |
. ' `login_ip` VARCHAR( 15 ) NOT NULL ,' |
... | ... | |
535 | 533 |
$search_footer = addslashes(''); |
536 | 534 |
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')"; |
537 | 535 |
$database->query($insert_search_footer); |
538 |
// Search results header |
|
539 |
$search_results_header = addslashes(''. |
|
540 |
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\': |
|
536 |
// Search results header
|
|
537 |
$search_results_header = addslashes(''.
|
|
538 |
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
|
|
541 | 539 |
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">'); |
542 | 540 |
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')"; |
543 | 541 |
$database->query($insert_search_results_header); |
544 | 542 |
// Search results loop |
545 |
$search_results_loop = addslashes(''. |
|
546 |
'<tr style="background-color: #F0F0F0;"> |
|
547 |
<td><a href="[LINK]">[TITLE]</a></td> |
|
548 |
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td> |
|
549 |
</tr> |
|
543 |
$search_results_loop = addslashes(''.
|
|
544 |
'<tr style="background-color: #F0F0F0;">
|
|
545 |
<td><a href="[LINK]">[TITLE]</a></td>
|
|
546 |
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
|
|
547 |
</tr>
|
|
550 | 548 |
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[DESCRIPTION]</td></tr>'); |
551 | 549 |
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')"; |
552 | 550 |
$database->query($insert_search_results_loop); |
... | ... | |
559 | 557 |
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')"; |
560 | 558 |
$database->query($insert_search_no_results); |
561 | 559 |
// Search template |
562 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')"); |
|
560 |
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
|
|
563 | 561 |
|
564 | 562 |
// Include the pre-installed module install scripts |
565 | 563 |
require(WB_PATH.'/modules/wysiwyg/install.php'); |
... | ... | |
568 | 566 |
require(WB_PATH.'/modules/form/install.php'); |
569 | 567 |
require(WB_PATH.'/modules/wrapper/install.php'); |
570 | 568 |
|
571 |
// Check if there was a database error |
|
569 |
// Check if there was a database error
|
|
572 | 570 |
if($database->is_error()) { |
573 | 571 |
set_error($database->get_error()); |
574 |
} |
|
572 |
}
|
|
575 | 573 |
|
576 | 574 |
} |
577 | 575 |
|
578 |
// Log the user in and go to Website Baker Administration |
|
579 |
require(WB_PATH.'/framework/class.login.php'); |
|
580 |
$thisApp = new Login( |
|
581 |
array( |
|
582 |
"MAX_ATTEMPS" => "50", |
|
583 |
"WARNING_URL" => ADMIN_URL."/login/warning.html", |
|
584 |
"USERNAME_FIELDNAME" => 'admin_username', |
|
585 |
"PASSWORD_FIELDNAME" => 'admin_password', |
|
586 |
"REMEMBER_ME_OPTION" => SMART_LOGIN, |
|
587 |
"MIN_USERNAME_LEN" => "2", |
|
588 |
"MIN_PASSWORD_LEN" => "2", |
|
589 |
"MAX_USERNAME_LEN" => "30", |
|
590 |
"MAX_PASSWORD_LEN" => "30", |
|
591 |
'LOGIN_URL' => ADMIN_URL."/login/index.php", |
|
592 |
'DEFAULT_URL' => ADMIN_URL."/start/index.php", |
|
593 |
'TEMPLATE_DIR' => ADMIN_PATH."/login", |
|
594 |
'TEMPLATE_FILE' => "template.html", |
|
595 |
'FRONTEND' => false, |
|
596 |
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php", |
|
597 |
'USERS_TABLE' => TABLE_PREFIX."users", |
|
598 |
'GROUPS_TABLE' => TABLE_PREFIX."groups", |
|
599 |
) |
|
600 |
); |
|
576 |
// Log the user in and go to Website Baker Administration
|
|
577 |
require(WB_PATH.'/framework/class.login.php');
|
|
578 |
$thisApp = new Login(
|
|
579 |
array(
|
|
580 |
"MAX_ATTEMPS" => "50",
|
|
581 |
"WARNING_URL" => ADMIN_URL."/login/warning.html",
|
|
582 |
"USERNAME_FIELDNAME" => 'admin_username',
|
|
583 |
"PASSWORD_FIELDNAME" => 'admin_password',
|
|
584 |
"REMEMBER_ME_OPTION" => SMART_LOGIN,
|
|
585 |
"MIN_USERNAME_LEN" => "2",
|
|
586 |
"MIN_PASSWORD_LEN" => "2",
|
|
587 |
"MAX_USERNAME_LEN" => "30",
|
|
588 |
"MAX_PASSWORD_LEN" => "30",
|
|
589 |
'LOGIN_URL' => ADMIN_URL."/login/index.php",
|
|
590 |
'DEFAULT_URL' => ADMIN_URL."/start/index.php",
|
|
591 |
'TEMPLATE_DIR' => ADMIN_PATH."/login",
|
|
592 |
'TEMPLATE_FILE' => "template.html",
|
|
593 |
'FRONTEND' => false,
|
|
594 |
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
|
|
595 |
'USERS_TABLE' => TABLE_PREFIX."users",
|
|
596 |
'GROUPS_TABLE' => TABLE_PREFIX."groups",
|
|
597 |
)
|
|
598 |
);
|
|
601 | 599 |
|
602 |
?> |
|
600 |
?> |
trunk/wb/admin/pages/settings.php | ||
---|---|---|
100 | 100 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']); |
101 | 101 |
} else { |
102 | 102 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none'); |
103 |
} |
|
103 |
}
|
|
104 | 104 |
|
105 | 105 |
// Visibility |
106 | 106 |
if($results_array['visibility'] == 'public') { |
107 | 107 |
$template->set_var('PUBLIC_SELECTED', ' selected'); |
108 | 108 |
} elseif($results_array['visibility'] == 'private') { |
109 |
$template->set_var('PRIVATE_SELECTED', ' selected'); |
|
109 |
$template->set_var('PRIVATE_SELECTED', ' selected');
|
|
110 | 110 |
} elseif($results_array['visibility'] == 'registered') { |
111 |
$template->set_var('REGISTERED_SELECTED', ' registered');
|
|
111 |
$template->set_var('REGISTERED_SELECTED', ' selected');
|
|
112 | 112 |
} elseif($results_array['visibility'] == 'hidden') { |
113 | 113 |
$template->set_var('HIDDEN_SELECTED', ' selected'); |
114 | 114 |
} elseif($results_array['visibility'] == 'none') { |
... | ... | |
309 | 309 |
$template->parse('template_list', 'template_list_block', true); |
310 | 310 |
} |
311 | 311 |
} |
312 |
} |
|
313 |
// Unset all menu arrays |
|
312 |
}
|
|
313 |
// Unset all menu arrays
|
|
314 | 314 |
unset($menu); |
315 |
} |
|
316 |
|
|
317 |
// Menu list |
|
318 |
if(MULTIPLE_MENUS == false) { |
|
319 |
$template->set_var('DISPLAY_MENU_LIST', 'none'); |
|
320 |
} |
|
321 |
// Include template info file (if it exists) |
|
322 |
if($results_array['template'] != '') { |
|
323 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
324 |
} else { |
|
325 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
326 |
} |
|
327 |
if(file_exists($template_location)) { |
|
328 |
require($template_location); |
|
329 |
} |
|
330 |
// Check if $menu is set |
|
331 |
if(!isset($menu[1]) OR $menu[1] == '') { |
|
332 |
// Make our own menu list |
|
333 |
$menu[1] = $TEXT['MAIN']; |
|
334 |
} |
|
335 |
// Add menu options to the list |
|
336 |
$template->set_block('main_block', 'menu_list_block', 'menu_list'); |
|
337 |
foreach($menu AS $number => $name) { |
|
338 |
$template->set_var('NAME', $name); |
|
339 |
$template->set_var('VALUE', $number); |
|
340 |
if($results_array['menu'] == $number) { |
|
341 |
$template->set_var('SELECTED', 'selected'); |
|
342 |
} else { |
|
343 |
$template->set_var('SELECTED', ''); |
|
344 |
} |
|
345 |
$template->parse('menu_list', 'menu_list_block', true); |
|
346 |
} |
|
347 |
|
|
348 |
// Language list |
|
349 |
if($handle = opendir(WB_PATH.'/languages/')) { |
|
315 |
}
|
|
316 |
|
|
317 |
// Menu list
|
|
318 |
if(MULTIPLE_MENUS == false) {
|
|
319 |
$template->set_var('DISPLAY_MENU_LIST', 'none');
|
|
320 |
}
|
|
321 |
// Include template info file (if it exists)
|
|
322 |
if($results_array['template'] != '') {
|
|
323 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
|
|
324 |
} else {
|
|
325 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
|
|
326 |
}
|
|
327 |
if(file_exists($template_location)) {
|
|
328 |
require($template_location);
|
|
329 |
}
|
|
330 |
// Check if $menu is set
|
|
331 |
if(!isset($menu[1]) OR $menu[1] == '') {
|
|
332 |
// Make our own menu list
|
|
333 |
$menu[1] = $TEXT['MAIN'];
|
|
334 |
}
|
|
335 |
// Add menu options to the list
|
|
336 |
$template->set_block('main_block', 'menu_list_block', 'menu_list');
|
|
337 |
foreach($menu AS $number => $name) {
|
|
338 |
$template->set_var('NAME', $name);
|
|
339 |
$template->set_var('VALUE', $number);
|
|
340 |
if($results_array['menu'] == $number) {
|
|
341 |
$template->set_var('SELECTED', 'selected');
|
|
342 |
} else {
|
|
343 |
$template->set_var('SELECTED', '');
|
|
344 |
}
|
|
345 |
$template->parse('menu_list', 'menu_list_block', true);
|
|
346 |
}
|
|
347 |
|
|
348 |
// Language list
|
|
349 |
if($handle = opendir(WB_PATH.'/languages/')) {
|
|
350 | 350 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
351 | 351 |
while (false !== ($file = readdir($handle))) { |
352 |
if($file != '.' AND $file != '..' AND $file != 'CVS' AND $file != 'index.php') { |
|
353 |
// Include the languages info file |
|
354 |
require(WB_PATH.'/languages/'.$file); |
|
355 |
// Work-out if this language is selected |
|
356 |
if($language_code == $results_array['language']) { $selected = ' selected'; } else { $selected = ''; } |
|
357 |
// Set the language info |
|
358 |
$template->set_var(array('VALUE' => $language_code, 'SELECTED' => $selected, 'NAME' => $language_name)); |
|
359 |
// Parse row |
|
360 |
$template->parse('language_list', 'language_list_block', true); |
|
361 |
} |
|
362 |
} |
|
363 |
} |
|
364 |
// Restore to original language |
|
365 |
require(WB_PATH.'/languages/'.LANGUAGE.'.php'); |
|
352 |
if($file != '.' AND $file != '..' AND $file != 'CVS' AND $file != 'index.php') {
|
|
353 |
// Include the languages info file
|
|
354 |
require(WB_PATH.'/languages/'.$file);
|
|
355 |
// Work-out if this language is selected
|
|
356 |
if($language_code == $results_array['language']) { $selected = ' selected'; } else { $selected = ''; }
|
|
357 |
// Set the language info
|
|
358 |
$template->set_var(array('VALUE' => $language_code, 'SELECTED' => $selected, 'NAME' => $language_name));
|
|
359 |
// Parse row
|
|
360 |
$template->parse('language_list', 'language_list_block', true);
|
|
361 |
}
|
|
362 |
}
|
|
363 |
}
|
|
364 |
// Restore to original language
|
|
365 |
require(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
|
366 | 366 |
|
367 | 367 |
// Select disabled if searching is disabled |
368 | 368 |
if($results_array['searching'] == 0) { |
... | ... | |
384 | 384 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
385 | 385 |
'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'], |
386 | 386 |
'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'], |
387 |
'TEXT_TYPE' => $TEXT['TYPE'], |
|
387 |
'TEXT_TYPE' => $TEXT['TYPE'],
|
|
388 | 388 |
'TEXT_MENU' => $TEXT['MENU'], |
389 | 389 |
'TEXT_PARENT' => $TEXT['PARENT'], |
390 | 390 |
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'], |
391 | 391 |
'TEXT_PUBLIC' => $TEXT['PUBLIC'], |
392 |
'TEXT_PRIVATE' => $TEXT['PRIVATE'], |
|
392 |
'TEXT_PRIVATE' => $TEXT['PRIVATE'],
|
|
393 | 393 |
'TEXT_REGISTERED' => $TEXT['REGISTERED'], |
394 |
'TEXT_NONE' => $TEXT['NONE'], |
|
394 |
'TEXT_NONE' => $TEXT['NONE'],
|
|
395 | 395 |
'TEXT_HIDDEN' => $TEXT['HIDDEN'], |
396 | 396 |
'TEXT_TEMPLATE' => $TEXT['TEMPLATE'], |
397 | 397 |
'TEXT_TARGET' => $TEXT['TARGET'], |
... | ... | |
400 | 400 |
'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'], |
401 | 401 |
'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'], |
402 | 402 |
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'], |
403 |
'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'], |
|
403 |
'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
|
|
404 | 404 |
'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'], |
405 | 405 |
'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'], |
406 | 406 |
'TEXT_KEYWORDS' => $TEXT['KEYWORDS'], |
407 |
'TEXT_SEARCHING' => $TEXT['SEARCHING'], |
|
407 |
'TEXT_SEARCHING' => $TEXT['SEARCHING'],
|
|
408 | 408 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
409 | 409 |
'TEXT_ENABLED' => $TEXT['ENABLED'], |
410 | 410 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
... | ... | |
421 | 421 |
// Print admin footer |
422 | 422 |
$admin->print_footer(); |
423 | 423 |
|
424 |
?> |
|
424 |
?> |
trunk/wb/admin/pages/add.php | ||
---|---|---|
78 | 78 |
$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'"); |
79 | 79 |
if($get_same_page->numRows() > 0) { |
80 | 80 |
$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']); |
81 |
} elseif(file_exists(WB_PATH.$link.'.php')) { |
|
81 |
} elseif(file_exists(WB_PATH.PAGES_DIRECTORY.$link.'.php')) {
|
|
82 | 82 |
$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']); |
83 |
} elseif(file_exists(WB_PATH.$link.'/')) { |
|
83 |
} elseif(file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/')) {
|
|
84 | 84 |
$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']); |
85 | 85 |
} |
86 | 86 |
|
... | ... | |
150 | 150 |
// Print admin footer |
151 | 151 |
$admin->print_footer(); |
152 | 152 |
|
153 |
?> |
|
153 |
?> |
trunk/wb/modules/wysiwyg/view.php | ||
---|---|---|
27 | 27 |
$get_content = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$section_id'"); |
28 | 28 |
$fetch_content = $get_content->fetchRow(); |
29 | 29 |
$content = stripslashes($fetch_content['content']); |
30 |
// Replace [wblink--PAGE_ID--] with real link |
|
31 |
$pattern = '/\[wblink(.+?)\]/s'; |
|
32 |
preg_match_all($pattern,$content,$ids); |
|
33 |
foreach($ids[1] AS $page_id) { |
|
34 |
$pattern = '/\[wblink'.$page_id.'\]/s'; |
|
35 |
// Get page link |
|
36 |
$get_link = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1"); |
|
37 |
$fetch_link = $get_link->fetchRow(); |
|
38 |
$link = page_link($fetch_link['link']); |
|
39 |
$content = preg_replace($pattern,$link,$content); |
|
40 |
} |
|
30 |
|
|
31 |
$this->preprocess($content); |
|
32 |
|
|
41 | 33 |
echo $content; |
42 | 34 |
|
43 |
?> |
|
35 |
?> |
trunk/wb/modules/news/comment.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id: comment.php,v 1.2 2005/04/02 06:25:56 rdjurovich Exp $ |
|
1 |
<?php |
|
4 | 2 |
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2005, 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 |
|
|
3 |
// $Id: comment.php,v 1.2 2005/04/02 06:25:56 rdjurovich Exp $ |
|
4 |
|
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2005, 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 | 24 |
*/ |
25 |
|
|
26 |
// Include config file |
|
27 |
require('../../config.php'); |
|
28 |
|
|
29 |
// Check if there is a post id |
|
30 |
if(!isset($_GET['id']) OR !is_numeric($_GET['id'])) { |
|
31 |
if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) { |
|
32 |
header('Location: '.WB_URL.'/pages/'); |
|
33 |
} else { |
|
34 |
$post_id = $_POST['post_id']; |
|
35 |
} |
|
36 |
} else { |
|
37 |
$post_id = $_GET['id']; |
|
38 |
} |
|
39 |
|
|
40 |
// Include database class |
|
41 |
if(!defined('DATABASE_CLASS_LOADED')) { |
|
42 |
require(WB_PATH.'/framework/class.database.php'); |
|
43 |
} |
|
44 |
$database = new database(); |
|
45 |
|
|
46 |
// Query post for page id |
|
47 |
$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'"); |
|
48 |
if($query_post->numRows() == 0) { |
|
49 |
header('Location: '.WB_URL.'/pages/'); |
|
50 |
} else { |
|
51 |
$fetch_post = $query_post->fetchRow(); |
|
52 |
$page_id = $fetch_post['page_id']; |
|
53 |
$section_id = $fetch_post['section_id']; |
|
54 |
$post_id = $fetch_post['post_id']; |
|
55 |
$post_title = $fetch_post['title']; |
|
56 |
define('SECTION_ID', $section_id); |
|
57 |
define('POST_ID', $post_id); |
|
58 |
define('POST_TITLE', $post_title); |
|
59 |
// Get page details |
|
60 |
$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); |
|
61 |
if($query_page->numRows() == 0) { |
|
62 |
header('Location: '.WB_URL.'/pages/'); |
|
63 |
} else { |
|
64 |
$page = $query_page->fetchRow(); |
|
65 |
// Required page details |
|
66 |
define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php'); |
|
67 |
// Include index (wrapper) file |
|
68 |
require(WB_PATH.'/index.php'); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
|
|
73 |
?> |
|
25 |
|
|
26 |
// Include config file |
|
27 |
require('../../config.php'); |
|
28 |
|
|
29 |
// Check if there is a post id |
|
30 |
if(!isset($_GET['id']) OR !is_numeric($_GET['id'])) { |
|
31 |
if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) { |
|
32 |
header('Location: '.WB_URL.'/pages/'); |
|
33 |
} else { |
|
34 |
$post_id = $_POST['post_id']; |
|
35 |
} |
|
36 |
} else { |
|
37 |
$post_id = $_GET['id']; |
|
38 |
} |
|
39 |
|
|
40 |
// Include database class |
|
41 |
require_once(WB_PATH.'/framework/class.database.php'); |
|
42 |
$database = new database(); |
|
43 |
|
|
44 |
// Query post for page id |
|
45 |
$query_post = $database->query("SELECT post_id,title,section_id,page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'"); |
|
46 |
if($query_post->numRows() == 0) { |
|
47 |
header('Location: '.WB_URL.'/pages/'); |
|
48 |
} else { |
|
49 |
$fetch_post = $query_post->fetchRow(); |
|
50 |
$page_id = $fetch_post['page_id']; |
|
51 |
$section_id = $fetch_post['section_id']; |
|
52 |
$post_id = $fetch_post['post_id']; |
|
53 |
$post_title = $fetch_post['title']; |
|
54 |
define('SECTION_ID', $section_id); |
|
55 |
define('POST_ID', $post_id); |
|
56 |
define('POST_TITLE', $post_title); |
|
57 |
// Get page details |
|
58 |
$query_page = $database->query("SELECT parent,page_title,menu_title,keywords,description,visibility FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); |
|
59 |
if($query_page->numRows() == 0) { |
|
60 |
header('Location: '.WB_URL.'/pages/'); |
|
61 |
} else { |
|
62 |
$page = $query_page->fetchRow(); |
|
63 |
// Required page details |
|
64 |
define('PAGE_CONTENT', WB_PATH.'/modules/news/comment_page.php'); |
|
65 |
// Include index (wrapper) file |
|
66 |
require(WB_PATH.'/index.php'); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
|
|
71 |
?> |
trunk/wb/modules/news/view.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id: view.php,v 1.7 2005/06/21 09:11:27 rdjurovich Exp $ |
|
1 |
<?php |
|
4 | 2 |
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2005, 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 |
*/ |
|
3 |
// $Id: view.php,v 1.7 2005/06/21 09:11:27 rdjurovich Exp $ |
|
25 | 4 |
|
5 |
/* |
|
6 |
|
|
7 |
Website Baker Project <http://www.websitebaker.org/> |
|
8 |
Copyright (C) 2004-2005, 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 | 26 |
// Must include code to stop this file being access directly |
27 | 27 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); } |
28 |
|
|
29 |
// Check if there is a start point defined |
|
30 |
if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) { |
|
31 |
$position = $_GET['p']; |
|
32 |
} else { |
|
33 |
$position = 0; |
|
34 |
} |
|
35 |
|
|
36 |
// Get user's username, display name, email, and id - needed for insertion into post info |
|
37 |
$users = array(); |
|
38 |
$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users"); |
|
39 |
if($query_users->numRows() > 0) { |
|
40 |
while($user = $query_users->fetchRow()) { |
|
41 |
// Insert user info into users array |
|
42 |
$user_id = $user['user_id']; |
|
43 |
$users[$user_id]['username'] = $user['username']; |
|
44 |
$users[$user_id]['display_name'] = $user['display_name']; |
|
45 |
$users[$user_id]['email'] = $user['email']; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
// Get groups (title, if they are active, and their image [if one has been uploaded]) |
|
50 |
$groups[0]['title'] = ''; |
|
51 |
$groups[0]['active'] = true; |
|
52 |
$groups[0]['image'] = ''; |
|
53 |
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC"); |
|
54 |
if($query_users->numRows() > 0) { |
|
55 |
while($group = $query_users->fetchRow()) { |
|
56 |
// Insert user info into users array |
|
57 |
$group_id = $group['group_id']; |
|
58 |
$groups[$group_id]['title'] = stripslashes($group['title']); |
|
59 |
$groups[$group_id]['active'] = $group['active']; |
|
60 |
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) { |
|
61 |
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'; |
|
62 |
} else { |
|
63 |
$groups[$group_id]['image'] = ''; |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
// Check if we should show the main page or a post itself |
|
69 |
if(!defined('POST_ID') OR !is_numeric(POST_ID)) { |
|
70 |
|
|
71 |
// Check if we should only list posts from a certain group |
|
72 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
73 |
$query_extra = " AND group_id = '".$_GET['g']."'"; |
|
74 |
?> |
|
75 |
<style type="text/css">.selected_group_title { font-size: 14px; text-align: center; }</style> |
|
76 |
<?php |
|
77 |
} else { |
|
78 |
$query_extra = ''; |
|
79 |
} |
|
80 |
|
|
28 |
|
|
29 |
// Check if there is a start point defined
|
|
30 |
if(isset($_GET['p']) AND is_numeric($_GET['p']) AND $_GET['p'] >= 0) {
|
|
31 |
$position = $_GET['p'];
|
|
32 |
} else {
|
|
33 |
$position = 0;
|
|
34 |
}
|
|
35 |
|
|
36 |
// Get user's username, display name, email, and id - needed for insertion into post info
|
|
37 |
$users = array();
|
|
38 |
$query_users = $database->query("SELECT user_id,username,display_name,email FROM ".TABLE_PREFIX."users");
|
|
39 |
if($query_users->numRows() > 0) {
|
|
40 |
while($user = $query_users->fetchRow()) {
|
|
41 |
// Insert user info into users array
|
|
42 |
$user_id = $user['user_id'];
|
|
43 |
$users[$user_id]['username'] = $user['username'];
|
|
44 |
$users[$user_id]['display_name'] = $user['display_name'];
|
|
45 |
$users[$user_id]['email'] = $user['email'];
|
|
46 |
}
|
|
47 |
}
|
|
48 |
|
|
49 |
// Get groups (title, if they are active, and their image [if one has been uploaded])
|
|
50 |
$groups[0]['title'] = '';
|
|
51 |
$groups[0]['active'] = true;
|
|
52 |
$groups[0]['image'] = '';
|
|
53 |
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
|
|
54 |
if($query_users->numRows() > 0) {
|
|
55 |
while($group = $query_users->fetchRow()) {
|
|
56 |
// Insert user info into users array
|
|
57 |
$group_id = $group['group_id'];
|
|
58 |
$groups[$group_id]['title'] = stripslashes($group['title']);
|
|
59 |
$groups[$group_id]['active'] = $group['active'];
|
|
60 |
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
|
|
61 |
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
|
|
62 |
} else {
|
|
63 |
$groups[$group_id]['image'] = '';
|
|
64 |
}
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
// Check if we should show the main page or a post itself
|
|
69 |
if(!defined('POST_ID') OR !is_numeric(POST_ID)) {
|
|
70 |
|
|
71 |
// Check if we should only list posts from a certain group
|
|
72 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
|
73 |
$query_extra = " AND group_id = '".$_GET['g']."'";
|
|
74 |
?>
|
|
75 |
<style type="text/css">.selected_group_title { font-size: 14px; text-align: center; }</style>
|
|
76 |
<?php
|
|
77 |
} else {
|
|
78 |
$query_extra = '';
|
|
79 |
}
|
|
80 |
|
|
81 | 81 |
// Get settings |
82 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
83 |
if($query_settings->numRows() > 0) { |
|
84 |
$fetch_settings = $query_settings->fetchRow(); |
|
85 |
$setting_header = stripslashes($fetch_settings['header']); |
|
86 |
$setting_post_loop = stripslashes($fetch_settings['post_loop']); |
|
87 |
$setting_footer = stripslashes($fetch_settings['footer']); |
|
88 |
$setting_posts_per_page = $fetch_settings['posts_per_page']; |
|
89 |
} else { |
|
90 |
$setting_header = ''; |
|
91 |
$setting_post_loop = ''; |
|
92 |
$setting_footer = ''; |
|
93 |
$setting_posts_per_page = ''; |
|
94 |
} |
|
95 |
|
|
96 |
// Get total number of posts |
|
97 |
$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra"); |
|
98 |
$total_num = $query_total_num->numRows(); |
|
99 |
|
|
100 |
// Work-out if we need to add limit code to sql |
|
101 |
if($setting_posts_per_page != 0) { |
|
102 |
$limit_sql = " LIMIT $position,$setting_posts_per_page"; |
|
103 |
} else { |
|
104 |
$limit_sql = ""; |
|
105 |
} |
|
106 |
|
|
107 |
// Query posts (for this page) |
|
108 |
$query_posts = $database->query("SELECT group_id,post_id,title,link,short,posted_by,posted_when FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra ORDER BY position DESC".$limit_sql); |
|
109 |
$num_posts = $query_posts->numRows(); |
|
110 |
|
|
111 |
// Create previous and next links |
|
112 |
if($setting_posts_per_page != 0) { |
|
113 |
if($position > 0) { |
|
114 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
115 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< '; |
|
116 |
} else { |
|
117 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< '; |
|
118 |
} |
|
119 |
$pl_append = '</a>'; |
|
120 |
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append; |
|
121 |
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append; |
|
122 |
} else { |
|
123 |
$previous_link = ''; |
|
124 |
$previous_page_link = ''; |
|
125 |
} |
|
126 |
if($position+$setting_posts_per_page >= $total_num) { |
|
127 |
$next_link = ''; |
|
128 |
$next_page_link = ''; |
|
129 |
} else { |
|
130 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
131 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> '; |
|
132 |
} else { |
|
133 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> '; |
|
134 |
} |
|
135 |
$nl_append = ' >></a>'; |
|
136 |
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append; |
|
137 |
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append; |
|
138 |
} |
|
139 |
if($position+$setting_posts_per_page > $total_num) { |
|
140 |
$num_of = $position+$num_posts; |
|
141 |
} else { |
|
142 |
$num_of = $position+$setting_posts_per_page; |
|
143 |
} |
|
144 |
$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num; |
|
145 |
$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num; |
|
146 |
$display_previous_next_links = ''; |
|
147 |
} else { |
|
148 |
$display_previous_next_links = 'none'; |
|
149 |
} |
|
150 |
|
|
151 |
// Print header |
|
152 |
if($display_previous_next_links == 'none') { |
|
153 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_header); |
|
154 |
} else { |
|
155 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header); |
|
156 |
} |
|
157 |
|
|
158 |
if($num_posts > 0) { |
|
159 |
if($query_extra != '') { |
|
160 |
?> |
|
161 |
<div class="selected_group_title"> |
|
162 |
<?php echo '<a href="'.$_SERVER['PHP_SELF'].'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?> |
|
163 |
</div> |
|
164 |
<?php |
|
165 |
} |
|
166 |
while($post = $query_posts->fetchRow()) { |
|
167 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
|
168 |
$uid = $post['posted_by']; // User who last modified the post |
|
169 |
// Workout date and time of last modified post |
|
170 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
171 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
172 |
// Work-out the post link |
|
173 |
$post_link = page_link($post['link']); |
|
174 |
if(isset($_GET['p']) AND $position > 0) { |
|
175 |
$post_link .= '?p='.$position; |
|
176 |
} |
|
177 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
178 |
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; } |
|
179 |
$post_link .= 'g='.$_GET['g']; |
|
180 |
} |
|
181 |
// Get group id, title, and image |
|
182 |
$group_id = $post['group_id']; |
|
183 |
$group_title = $groups[$group_id]['title']; |
|
184 |
$group_image = $groups[$group_id]['image']; |
|
185 |
if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; } |
|
186 |
if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; } |
|
187 |
// Replace [wblink--PAGE_ID--] with real link |
|
188 |
$short = stripslashes($post['short']); |
|
189 |
$pattern = '/\[wblink(.+?)\]/s'; |
|
190 |
preg_match_all($pattern,$short,$ids); |
|
191 |
foreach($ids[1] AS $page_id) { |
|
192 |
$pattern = '/\[wblink'.$page_id.'\]/s'; |
|
193 |
// Get page link |
|
194 |
$get_link = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1"); |
|
195 |
$fetch_link = $get_link->fetchRow(); |
|
196 |
$link = page_link($fetch_link['link']); |
|
197 |
$short = preg_replace($pattern,$link,$short); |
|
198 |
} |
|
199 |
// Replace vars with values |
|
200 |
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]'); |
|
201 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
202 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), $short, $post_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $TEXT['READ_MORE']); |
|
203 |
} else { |
|
204 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), $short, $post_link, $post_date, $post_time, '', '', '', '', $TEXT['READ_MORE']); |
|
205 |
} |
|
206 |
echo str_replace($vars, $values, $setting_post_loop); |
|
207 |
} |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
// Print footer |
|
212 |
if($display_previous_next_links == 'none') { |
|
213 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer); |
|
214 |
} else { |
|
215 |
echo str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer); |
|
216 |
} |
|
217 |
|
|
218 |
} elseif(defined('POST_ID') AND is_numeric(POST_ID)) { |
|
219 |
|
|
220 |
// Get settings |
|
221 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
222 |
if($query_settings->numRows() > 0) { |
|
223 |
$fetch_settings = $query_settings->fetchRow(); |
|
224 |
$setting_post_header = stripslashes($fetch_settings['post_header']); |
|
225 |
$setting_post_footer = stripslashes($fetch_settings['post_footer']); |
|
226 |
$setting_comments_header = stripslashes($fetch_settings['comments_header']); |
|
227 |
$setting_comments_loop = stripslashes($fetch_settings['comments_loop']); |
|
228 |
$setting_comments_footer = stripslashes($fetch_settings['comments_footer']); |
|
229 |
} else { |
|
230 |
$setting_post_header = ''; |
|
231 |
$setting_post_footer = ''; |
|
232 |
$setting_comments_header = ''; |
|
233 |
$setting_comments_loop = ''; |
|
234 |
$setting_comments_footer = ''; |
|
235 |
} |
|
236 |
|
|
237 |
// Get page info |
|
238 |
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'"); |
|
239 |
if($query_page->numRows() > 0) { |
|
240 |
$page = $query_page->fetchRow(); |
|
241 |
$page_link = page_link($page['link']); |
|
242 |
if(isset($_GET['p']) AND $position > 0) { |
|
243 |
$page_link .= '?p='.$_GET['p']; |
|
244 |
} |
|
245 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
246 |
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; } |
|
247 |
$page_link .= 'g='.$_GET['g']; |
|
248 |
} |
|
249 |
} else { |
|
250 |
exit('Page not found'); |
|
251 |
} |
|
252 |
|
|
253 |
// Get post info |
|
254 |
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '".POST_ID."' AND active = '1'"); |
|
255 |
if($query_post->numRows() > 0) { |
|
256 |
$post = $query_post->fetchRow(); |
|
257 |
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active |
|
258 |
$uid = $post['posted_by']; // User who last modified the post |
|
259 |
// Workout date and time of last modified post |
|
260 |
$post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE); |
|
261 |
$post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE); |
|
262 |
// Get group id, title, and image |
|
263 |
$group_id = $post['group_id']; |
|
264 |
$group_title = $groups[$group_id]['title']; |
|
265 |
$group_image = $groups[$group_id]['image']; |
|
266 |
if($group_image == '') { $display_image = 'none'; } else { $display_image = ''; } |
|
267 |
if($group_id == 0) { $display_group = 'none'; } else { $display_group = ''; } |
|
268 |
$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[DATE]', '[TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]'); |
|
269 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
270 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $page_link, $post_date, $post_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']); |
|
271 |
} else { |
|
272 |
$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, stripslashes($post['title']), stripslashes($post['short']), $page_link, $post_date, $post_time, '', '', '', ''); |
|
273 |
} |
|
274 |
$post_long = stripslashes($post['long']); |
|
275 |
} |
|
276 |
} else { |
|
277 |
header('Location: '.WB_URL.'/pages/'); |
|
278 |
} |
|
279 |
|
|
280 |
// Print post header |
|
281 |
echo str_replace($vars, $values, $setting_post_header); |
|
282 |
|
|
283 |
// Replace [wblink--PAGE_ID--] with real link |
|
284 |
$pattern = '/\[wblink(.+?)\]/s'; |
|
285 |
preg_match_all($pattern,$post_long,$ids); |
|
286 |
foreach($ids[1] AS $page_id) { |
|
287 |
$pattern = '/\[wblink'.$page_id.'\]/s'; |
|
288 |
// Get page link |
|
289 |
$get_link = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id' LIMIT 1"); |
|
290 |
$fetch_link = $get_link->fetchRow(); |
|
291 |
$link = page_link($fetch_link['link']); |
|
292 |
$post_long = preg_replace($pattern,$link,$post_long); |
|
293 |
} |
|
294 |
|
|
295 |
// Print long |
|
296 |
echo $post_long; |
|
297 |
|
|
298 |
// Print post footer |
|
299 |
echo str_replace($vars, $values, $setting_post_footer); |
|
300 |
|
|
301 |
// Show comments section if we have to |
|
302 |
if($post['commenting'] == 'private' AND isset($admin) AND $admin->is_authenticated() == true OR $post['commenting'] == 'public') { |
|
303 |
|
|
304 |
// Print comments header |
|
305 |
echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_header); |
|
306 |
|
|
307 |
// Query for comments |
|
308 |
$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC"); |
|
309 |
if($query_comments->numRows() > 0) { |
|
310 |
while($comment = $query_comments->fetchRow()) { |
|
311 |
// Display Comments without slashes, but with new-line characters |
|
312 |
$comment['comment'] = nl2br(stripslashes($comment['comment'])); |
|
313 |
$comment['title'] = stripslashes($comment['title']); |
|
314 |
// Print comments loop |
|
315 |
$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE); |
|
316 |
$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE); |
|
317 |
$uid = $comment['commented_by']; |
|
318 |
$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]'); |
|
319 |
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') { |
|
320 |
$values = array(stripslashes($comment['title']), stripslashes($comment['comment']), $commented_date, $commented_time, $uid, stripslashes($users[$uid]['username']), stripslashes($users[$uid]['display_name']), stripslashes($users[$uid]['email'])); |
|
321 |
} else { |
|
322 |
$values = array(stripslashes($comment['title']), stripslashes($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], ''); |
|
323 |
} |
|
324 |
echo str_replace($vars, $values, $setting_comments_loop); |
|
325 |
} |
|
326 |
} else { |
|
327 |
// Say no comments found |
|
328 |
if(isset($TEXT['NONE_FOUND'])) { |
|
329 |
echo $TEXT['NONE_FOUND'].'<br />'; |
|
330 |
} else { |
|
331 |
echo 'None Found<br />'; |
|
332 |
} |
|
333 |
} |
|
334 |
|
|
335 |
// Print comments footer |
|
336 |
echo str_replace('[ADD_COMMENT_URL]', WB_URL.'/modules/news/comment.php?id='.POST_ID, $setting_comments_footer); |
|
337 |
|
|
338 |
} |
|
339 |
|
|
340 |
} |
|
82 |
$query_settings = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'"); |
|
83 |
if($query_settings->numRows() > 0) { |
|
84 |
$fetch_settings = $query_settings->fetchRow(); |
|
85 |
$setting_header = stripslashes($fetch_settings['header']); |
|
86 |
$setting_post_loop = stripslashes($fetch_settings['post_loop']); |
|
87 |
$setting_footer = stripslashes($fetch_settings['footer']); |
|
88 |
$setting_posts_per_page = $fetch_settings['posts_per_page']; |
|
89 |
} else { |
|
90 |
$setting_header = ''; |
|
91 |
$setting_post_loop = ''; |
|
92 |
$setting_footer = ''; |
|
93 |
$setting_posts_per_page = ''; |
|
94 |
} |
|
95 |
|
|
96 |
// Get total number of posts |
|
97 |
$query_total_num = $database->query("SELECT post_id FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra"); |
|
98 |
$total_num = $query_total_num->numRows(); |
|
341 | 99 |
|
342 |
?> |
|
100 |
// Work-out if we need to add limit code to sql |
|
101 |
if($setting_posts_per_page != 0) { |
|
102 |
$limit_sql = " LIMIT $position,$setting_posts_per_page"; |
|
103 |
} else { |
|
104 |
$limit_sql = ""; |
|
105 |
} |
|
106 |
|
|
107 |
// Query posts (for this page) |
|
108 |
$query_posts = $database->query("SELECT group_id,post_id,title,link,short,posted_by,posted_when FROM ".TABLE_PREFIX."mod_news_posts WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra ORDER BY position DESC".$limit_sql); |
|
109 |
$num_posts = $query_posts->numRows(); |
|
110 |
|
|
111 |
// Create previous and next links |
|
112 |
if($setting_posts_per_page != 0) { |
|
113 |
if($position > 0) { |
|
114 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
115 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< '; |
|
116 |
} else { |
|
117 |
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< '; |
|
118 |
} |
|
119 |
$pl_append = '</a>'; |
|
120 |
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append; |
|
121 |
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append; |
|
122 |
} else { |
|
123 |
$previous_link = ''; |
|
124 |
$previous_page_link = ''; |
|
125 |
} |
|
126 |
if($position+$setting_posts_per_page >= $total_num) { |
|
127 |
$next_link = ''; |
|
128 |
$next_page_link = ''; |
|
129 |
} else { |
|
130 |
if(isset($_GET['g']) AND is_numeric($_GET['g'])) { |
|
131 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> '; |
|
132 |
} else { |
|
133 |
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> '; |
|
134 |
} |
|
135 |
$nl_append = ' >></a>'; |
|
136 |
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append; |
|
137 |
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append; |
Also available in: Unified diff
Restructured frontend code and fixed various bugs