Revision 5
Added by stefan about 20 years ago
| functions.php | ||
|---|---|---|
| 32 | 32 |
|
| 33 | 33 |
// Stop this file from being accessed directly |
| 34 | 34 |
if(!defined('WB_PATH')) { exit('Direct access to this file is not allowed'); }
|
| 35 |
|
|
| 35 |
|
|
| 36 | 36 |
// Define that this file has been loaded |
| 37 |
define('FUNCTIONS_FILE_LOADED', true);
|
|
| 37 |
define('FUNCTIONS_FILE_LOADED', true);
|
|
| 38 | 38 |
|
| 39 | 39 |
// Function to remove a non-empty directory |
| 40 | 40 |
function rm_full_dir($directory) |
| ... | ... | |
| 145 | 145 |
|
| 146 | 146 |
// Now delete the folder |
| 147 | 147 |
return $list; |
| 148 |
} |
|
| 149 |
|
|
| 150 |
// Function to get a list of home folders not to show |
|
| 151 |
function get_home_folders() {
|
|
| 152 |
global $database, $admin; |
|
| 153 |
$home_folders = array(); |
|
| 154 |
// Only return home folders is this feature is enabled |
|
| 155 |
if(HOME_FOLDERS) {
|
|
| 156 |
$query_home_folders = $database->query("SELECT home_folder FROM ".TABLE_PREFIX."users WHERE home_folder != '".$admin->get_home_folder()."'");
|
|
| 157 |
if($query_home_folders->numRows() > 0) {
|
|
| 158 |
while($folder = $query_home_folders->fetchRow()) {
|
|
| 159 |
$home_folders[$folder['home_folder']] = $folder['home_folder']; |
|
| 160 |
} |
|
| 161 |
} |
|
| 162 |
function remove_home_subs($directory = '/', $home_folders) {
|
|
| 148 |
}
|
|
| 149 |
|
|
| 150 |
// Function to get a list of home folders not to show
|
|
| 151 |
function get_home_folders() {
|
|
| 152 |
global $database, $admin;
|
|
| 153 |
$home_folders = array();
|
|
| 154 |
// Only return home folders is this feature is enabled
|
|
| 155 |
if(HOME_FOLDERS) {
|
|
| 156 |
$query_home_folders = $database->query("SELECT home_folder FROM ".TABLE_PREFIX."users WHERE home_folder != '".$admin->get_home_folder()."'");
|
|
| 157 |
if($query_home_folders->numRows() > 0) {
|
|
| 158 |
while($folder = $query_home_folders->fetchRow()) {
|
|
| 159 |
$home_folders[$folder['home_folder']] = $folder['home_folder'];
|
|
| 160 |
}
|
|
| 161 |
}
|
|
| 162 |
function remove_home_subs($directory = '/', $home_folders) {
|
|
| 163 | 163 |
if($handle = opendir(WB_PATH.MEDIA_DIRECTORY.$directory)) {
|
| 164 |
// Loop through the dirs to check the home folders sub-dirs are not shown |
|
| 164 |
// Loop through the dirs to check the home folders sub-dirs are not shown
|
|
| 165 | 165 |
while(false !== ($file = readdir($handle))) {
|
| 166 | 166 |
if(substr($file, 0, 1) != '.' AND $file != 'CVS' AND $file != 'index.php') {
|
| 167 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
|
|
| 168 |
if($directory != '/') { $file = $directory.'/'.$file; } else { $file = '/'.$file; }
|
|
| 169 |
foreach($home_folders AS $hf) {
|
|
| 170 |
$hf_length = strlen($hf); |
|
| 171 |
if($hf_length > 0) {
|
|
| 172 |
if(substr($file, 0, $hf_length+1) == $hf) {
|
|
| 173 |
$home_folders[$file] = $file; |
|
| 174 |
} |
|
| 175 |
} |
|
| 176 |
} |
|
| 177 |
$home_folders = remove_home_subs($file, $home_folders); |
|
| 178 |
} |
|
| 179 |
} |
|
| 180 |
} |
|
| 181 |
} |
|
| 182 |
return $home_folders; |
|
| 183 |
} |
|
| 184 |
$home_folders = remove_home_subs('/', $home_folders);
|
|
| 185 |
} |
|
| 186 |
return $home_folders; |
|
| 187 |
} |
|
| 188 |
|
|
| 189 |
// Function to create directories |
|
| 190 |
function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE) {
|
|
| 191 |
if(!file_exists($dir_name)) {
|
|
| 192 |
$umask = umask(0); |
|
| 193 |
mkdir($dir_name, $dir_mode); |
|
| 194 |
umask($umask); |
|
| 195 |
return true; |
|
| 196 |
} else {
|
|
| 197 |
return false; |
|
| 198 |
} |
|
| 199 |
} |
|
| 200 |
|
|
| 201 |
// Function to chmod files and directories |
|
| 202 |
function change_mode($name) {
|
|
| 203 |
if(OPERATING_SYSTEM != 'windows') {
|
|
| 204 |
// Only chmod if os is not windows |
|
| 205 |
if(is_dir($name)) {
|
|
| 206 |
$mode = OCTAL_DIR_MODE; |
|
| 207 |
} else {
|
|
| 208 |
$mode = OCTAL_FILE_MODE; |
|
| 209 |
} |
|
| 210 |
if(file_exists($name)) {
|
|
| 211 |
$umask = umask(0); |
|
| 212 |
chmod($name, $mode); |
|
| 213 |
umask($umask); |
|
| 214 |
return true; |
|
| 215 |
} else {
|
|
| 216 |
return false; |
|
| 217 |
} |
|
| 218 |
} else {
|
|
| 219 |
return true; |
|
| 220 |
} |
|
| 167 |
if(is_dir(WB_PATH.MEDIA_DIRECTORY.$directory.'/'.$file)) {
|
|
| 168 |
if($directory != '/') { $file = $directory.'/'.$file; } else { $file = '/'.$file; }
|
|
| 169 |
foreach($home_folders AS $hf) {
|
|
| 170 |
$hf_length = strlen($hf); |
|
| 171 |
if($hf_length > 0) {
|
|
| 172 |
if(substr($file, 0, $hf_length+1) == $hf) {
|
|
| 173 |
$home_folders[$file] = $file; |
|
| 174 |
} |
|
| 175 |
} |
|
| 176 |
} |
|
| 177 |
$home_folders = remove_home_subs($file, $home_folders); |
|
| 178 |
} |
|
| 179 |
} |
|
| 180 |
} |
|
| 181 |
} |
|
| 182 |
return $home_folders; |
|
| 183 |
} |
|
| 184 |
$home_folders = remove_home_subs('/', $home_folders);
|
|
| 185 |
} |
|
| 186 |
return $home_folders; |
|
| 221 | 187 |
} |
| 222 | 188 |
|
| 189 |
// Function to create directories |
|
| 190 |
function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE) {
|
|
| 191 |
if(!file_exists($dir_name)) {
|
|
| 192 |
$umask = umask(0); |
|
| 193 |
mkdir($dir_name, $dir_mode); |
|
| 194 |
umask($umask); |
|
| 195 |
return true; |
|
| 196 |
} else {
|
|
| 197 |
return false; |
|
| 198 |
} |
|
| 199 |
} |
|
| 200 |
|
|
| 201 |
// Function to chmod files and directories |
|
| 202 |
function change_mode($name) {
|
|
| 203 |
if(OPERATING_SYSTEM != 'windows') {
|
|
| 204 |
// Only chmod if os is not windows |
|
| 205 |
if(is_dir($name)) {
|
|
| 206 |
$mode = OCTAL_DIR_MODE; |
|
| 207 |
} else {
|
|
| 208 |
$mode = OCTAL_FILE_MODE; |
|
| 209 |
} |
|
| 210 |
if(file_exists($name)) {
|
|
| 211 |
$umask = umask(0); |
|
| 212 |
chmod($name, $mode); |
|
| 213 |
umask($umask); |
|
| 214 |
return true; |
|
| 215 |
} else {
|
|
| 216 |
return false; |
|
| 217 |
} |
|
| 218 |
} else {
|
|
| 219 |
return true; |
|
| 220 |
} |
|
| 221 |
} |
|
| 222 |
|
|
| 223 | 223 |
// Function to figure out if a parent exists |
| 224 | 224 |
function is_parent($page_id) {
|
| 225 | 225 |
global $database; |
| ... | ... | |
| 310 | 310 |
$ids = array_merge($ids, $parent_ids); |
| 311 | 311 |
} |
| 312 | 312 |
return $ids; |
| 313 |
} |
|
| 314 |
|
|
| 315 |
// Function to genereate page trail |
|
| 316 |
function get_page_trail($page_id) {
|
|
| 317 |
return implode(',', array_reverse(get_parent_ids($page_id)));
|
|
| 318 | 313 |
} |
| 319 | 314 |
|
| 315 |
// Function to genereate page trail |
|
| 316 |
function get_page_trail($page_id) {
|
|
| 317 |
return implode(',', array_reverse(get_parent_ids($page_id)));
|
|
| 318 |
} |
|
| 319 |
|
|
| 320 | 320 |
// Function to get all sub pages id's |
| 321 | 321 |
function get_subs($parent, $subs) {
|
| 322 | 322 |
// Connect to the database |
| ... | ... | |
| 333 | 333 |
// Return subs array |
| 334 | 334 |
return $subs; |
| 335 | 335 |
} |
| 336 |
|
|
| 336 |
|
|
| 337 | 337 |
// Function to convert a page title to a page filename |
| 338 |
function page_filename($string) {
|
|
| 339 |
// First, translate any non-english characters to their english equivalents |
|
| 340 |
require(WB_PATH.'/framework/convert.php'); |
|
| 341 |
$string = strtr($string, $conversion_array); |
|
| 342 |
// Now replace spaces with page spcacer |
|
| 343 |
$string = str_replace(' ', PAGE_SPACER, $string);
|
|
| 344 |
// Now remove all bad characters |
|
| 345 |
$bad = array( |
|
| 346 |
'\'', /* / */ '"', /* " */ '<', /* < */ '>', /* > */ |
|
| 347 |
'{', /* { */ '}', /* } */ '[', /* [ */ ']', /* ] */ '`', /* ` */
|
|
| 348 |
'!', /* ! */ '@', /* @ */ '#', /* # */ '$', /* $ */ '%', /* % */ |
|
| 349 |
'^', /* ^ */ '&', /* & */ '*', /* * */ '(', /* ( */ ')', /* ) */
|
|
| 350 |
'=', /* = */ '+', /* + */ '|', /* | */ '/', /* / */ '\\', /* \ */ |
|
| 351 |
';', /* ; */ ':', /* : */ ',', /* , */ '?' /* ? */ |
|
| 352 |
); |
|
| 353 |
$string = str_replace($bad, '', $string); |
|
| 354 |
// Now convert to lower-case |
|
| 355 |
$string = strtolower($string); |
|
| 356 |
// Now remove multiple page spacers |
|
| 357 |
$string = str_replace(PAGE_SPACER.PAGE_SPACER, PAGE_SPACER, $string); |
|
| 358 |
// Clean any page spacers at the end of string |
|
| 359 |
$string = str_replace(PAGE_SPACER, ' ', $string); |
|
| 360 |
$string = trim($string); |
|
| 361 |
$string = str_replace(' ', PAGE_SPACER, $string);
|
|
| 362 |
// If there are any weird language characters, this will protect us against possible problems they could cause |
|
| 363 |
$string = str_replace(array('%2F', '%'), array('/', ''), urlencode($string));
|
|
| 338 |
function page_filename($string) {
|
|
| 339 |
// First, translate any non-english characters to their english equivalents
|
|
| 340 |
require(WB_PATH.'/framework/convert.php');
|
|
| 341 |
$string = strtr($string, $conversion_array);
|
|
| 342 |
// Now replace spaces with page spcacer
|
|
| 343 |
$string = str_replace(' ', PAGE_SPACER, $string);
|
|
| 344 |
// Now remove all bad characters
|
|
| 345 |
$bad = array(
|
|
| 346 |
'\'', /* / */ '"', /* " */ '<', /* < */ '>', /* > */
|
|
| 347 |
'{', /* { */ '}', /* } */ '[', /* [ */ ']', /* ] */ '`', /* ` */
|
|
| 348 |
'!', /* ! */ '@', /* @ */ '#', /* # */ '$', /* $ */ '%', /* % */
|
|
| 349 |
'^', /* ^ */ '&', /* & */ '*', /* * */ '(', /* ( */ ')', /* ) */
|
|
| 350 |
'=', /* = */ '+', /* + */ '|', /* | */ '/', /* / */ '\\', /* \ */
|
|
| 351 |
';', /* ; */ ':', /* : */ ',', /* , */ '?' /* ? */
|
|
| 352 |
);
|
|
| 353 |
$string = str_replace($bad, '', $string);
|
|
| 354 |
// Now convert to lower-case
|
|
| 355 |
$string = strtolower($string);
|
|
| 356 |
// Now remove multiple page spacers
|
|
| 357 |
$string = str_replace(PAGE_SPACER.PAGE_SPACER, PAGE_SPACER, $string);
|
|
| 358 |
// Clean any page spacers at the end of string
|
|
| 359 |
$string = str_replace(PAGE_SPACER, ' ', $string);
|
|
| 360 |
$string = trim($string);
|
|
| 361 |
$string = str_replace(' ', PAGE_SPACER, $string);
|
|
| 362 |
// If there are any weird language characters, this will protect us against possible problems they could cause
|
|
| 363 |
$string = str_replace(array('%2F', '%'), array('/', ''), urlencode($string));
|
|
| 364 | 364 |
// Finally, return the cleaned string |
| 365 | 365 |
return $string; |
| 366 |
} |
|
| 367 |
|
|
| 366 |
}
|
|
| 367 |
|
|
| 368 | 368 |
// Function to convert a desired media filename to a clean filename |
| 369 |
function media_filename($string) {
|
|
| 370 |
// First, translate any non-english characters to their english equivalents |
|
| 371 |
require(WB_PATH.'/framework/convert.php'); |
|
| 369 |
function media_filename($string) {
|
|
| 370 |
// First, translate any non-english characters to their english equivalents
|
|
| 371 |
require(WB_PATH.'/framework/convert.php');
|
|
| 372 | 372 |
$string = strtr($string, $conversion_array); |
| 373 |
// Now remove all bad characters |
|
| 374 |
$bad = array( |
|
| 375 |
'\'', // ' |
|
| 376 |
'"', // " |
|
| 377 |
'`', // ` |
|
| 378 |
'!', // ! |
|
| 379 |
'@', // @ |
|
| 380 |
'#', // # |
|
| 381 |
'$', // $ |
|
| 382 |
'%', // % |
|
| 383 |
'^', // ^ |
|
| 384 |
'&', // & |
|
| 385 |
'*', // * |
|
| 386 |
'=', // = |
|
| 387 |
'+', // + |
|
| 388 |
'|', // | |
|
| 389 |
'/', // / |
|
| 390 |
'\\', // \ |
|
| 391 |
';', // ; |
|
| 392 |
':', // : |
|
| 393 |
',', // , |
|
| 394 |
'?' // ? |
|
| 395 |
); |
|
| 396 |
$string = str_replace($bad, '', $string); |
|
| 397 |
// Clean any page spacers at the end of string |
|
| 398 |
$string = trim($string); |
|
| 373 |
// Now remove all bad characters
|
|
| 374 |
$bad = array(
|
|
| 375 |
'\'', // '
|
|
| 376 |
'"', // "
|
|
| 377 |
'`', // `
|
|
| 378 |
'!', // !
|
|
| 379 |
'@', // @
|
|
| 380 |
'#', // #
|
|
| 381 |
'$', // $
|
|
| 382 |
'%', // %
|
|
| 383 |
'^', // ^
|
|
| 384 |
'&', // &
|
|
| 385 |
'*', // *
|
|
| 386 |
'=', // =
|
|
| 387 |
'+', // +
|
|
| 388 |
'|', // |
|
|
| 389 |
'/', // /
|
|
| 390 |
'\\', // \
|
|
| 391 |
';', // ;
|
|
| 392 |
':', // :
|
|
| 393 |
',', // ,
|
|
| 394 |
'?' // ?
|
|
| 395 |
);
|
|
| 396 |
$string = str_replace($bad, '', $string);
|
|
| 397 |
// Clean any page spacers at the end of string
|
|
| 398 |
$string = trim($string);
|
|
| 399 | 399 |
// Finally, return the cleaned string |
| 400 | 400 |
return $string; |
| 401 |
} |
|
| 401 |
}
|
|
| 402 | 402 |
|
| 403 |
// Function to work out a page link |
|
| 403 |
// Function to work out a page link
|
|
| 404 | 404 |
if(!function_exists('page_link')) {
|
| 405 | 405 |
function page_link($link) {
|
| 406 | 406 |
// Check for :// in the link (used in URL's) |
| ... | ... | |
| 409 | 409 |
} else {
|
| 410 | 410 |
return $link; |
| 411 | 411 |
} |
| 412 |
} |
|
| 412 |
}
|
|
| 413 | 413 |
} |
| 414 | 414 |
|
| 415 | 415 |
// Create a new file in the pages directory |
| 416 | 416 |
function create_access_file($filename,$page_id,$level) {
|
| 417 |
global $admin; |
|
| 417 | 418 |
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
|
| 418 | 419 |
$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']); |
| 419 | 420 |
} else {
|
| ... | ... | |
| 431 | 432 |
// The depth of the page directory in the directory hierarchy |
| 432 | 433 |
// '/pages' is at depth 1 |
| 433 | 434 |
$pages_dir_depth=count(explode('/',PAGES_DIRECTORY))-1;
|
| 434 |
// Work-out how many ../'s we need to get to the index page |
|
| 435 |
// Work-out how many ../'s we need to get to the index page
|
|
| 435 | 436 |
$index_location = ''; |
| 436 | 437 |
for($i = 0; $i < $level + $pages_dir_depth; $i++) {
|
| 437 | 438 |
$index_location .= '../'; |
| ... | ... | |
| 607 | 608 |
// And finally, return either true or false |
| 608 | 609 |
return $$action; |
| 609 | 610 |
} |
| 610 |
|
|
| 611 |
// Function to delete a page |
|
| 612 |
function delete_page($page_id) {
|
|
| 613 |
|
|
| 614 |
global $admin, $database; |
|
| 615 |
|
|
| 616 |
// Find out more about the page |
|
| 617 |
$database = new database(); |
|
| 618 |
$query = "SELECT page_id,menu_title,page_title,level,link,parent,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 619 |
$results = $database->query($query); |
|
| 620 |
if($database->is_error()) {
|
|
| 621 |
$admin->print_error($database->get_error()); |
|
| 622 |
} |
|
| 623 |
if($results->numRows() == 0) {
|
|
| 624 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 625 |
} |
|
| 626 |
$results_array = $results->fetchRow(); |
|
| 627 |
$parent = $results_array['parent']; |
|
| 628 |
$level = $results_array['level']; |
|
| 629 |
$link = $results_array['link']; |
|
| 630 |
$page_title = stripslashes($results_array['page_title']); |
|
| 631 |
$menu_title = stripslashes($results_array['menu_title']); |
|
| 632 |
|
|
| 633 |
// Get the sections that belong to the page |
|
| 634 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
|
|
| 635 |
if($query_sections->numRows() > 0) {
|
|
| 636 |
while($section = $query_sections->fetchRow()) {
|
|
| 637 |
// Set section id |
|
| 638 |
$section_id = $section['section_id']; |
|
| 639 |
// Include the modules delete file if it exists |
|
| 640 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
|
| 641 |
require(WB_PATH.'/modules/'.$section['module'].'/delete.php'); |
|
| 642 |
} |
|
| 643 |
} |
|
| 644 |
} |
|
| 645 |
|
|
| 646 |
// Update the pages table |
|
| 647 |
$query = "DELETE FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 648 |
$database->query($query); |
|
| 649 |
if($database->is_error()) {
|
|
| 650 |
$admin->print_error($database->get_error()); |
|
| 651 |
} |
|
| 652 |
|
|
| 653 |
// Update the sections table |
|
| 654 |
$query = "DELETE FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'"; |
|
| 655 |
$database->query($query); |
|
| 656 |
if($database->is_error()) {
|
|
| 657 |
$admin->print_error($database->get_error()); |
|
| 658 |
} |
|
| 659 |
|
|
| 660 |
// Include the ordering class or clean-up ordering |
|
| 661 |
require_once(WB_PATH.'/framework/class.order.php'); |
|
| 662 |
$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent'); |
|
| 663 |
$order->clean($parent); |
|
| 664 |
|
|
| 665 |
// Unlink the page access file and directory |
|
| 666 |
$directory = WB_PATH.PAGES_DIRECTORY.$link; |
|
| 667 |
$filename = $directory.'.php'; |
|
| 668 |
$directory .= '/'; |
|
| 669 |
if(file_exists($filename)) {
|
|
| 670 |
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
|
|
| 671 |
$admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']); |
|
| 672 |
} else {
|
|
| 673 |
unlink($filename); |
|
| 674 |
if(file_exists($directory)) {
|
|
| 675 |
rm_full_dir($directory); |
|
| 676 |
} |
|
| 677 |
} |
|
| 678 |
} |
|
| 679 |
|
|
| 680 |
} |
|
| 681 | 611 |
|
| 682 |
?> |
|
| 612 |
// Function to delete a page |
|
| 613 |
function delete_page($page_id) {
|
|
| 614 |
|
|
| 615 |
global $admin, $database; |
|
| 616 |
|
|
| 617 |
// Find out more about the page |
|
| 618 |
$database = new database(); |
|
| 619 |
$query = "SELECT page_id,menu_title,page_title,level,link,parent,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 620 |
$results = $database->query($query); |
|
| 621 |
if($database->is_error()) {
|
|
| 622 |
$admin->print_error($database->get_error()); |
|
| 623 |
} |
|
| 624 |
if($results->numRows() == 0) {
|
|
| 625 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
| 626 |
} |
|
| 627 |
$results_array = $results->fetchRow(); |
|
| 628 |
$parent = $results_array['parent']; |
|
| 629 |
$level = $results_array['level']; |
|
| 630 |
$link = $results_array['link']; |
|
| 631 |
$page_title = stripslashes($results_array['page_title']); |
|
| 632 |
$menu_title = stripslashes($results_array['menu_title']); |
|
| 633 |
|
|
| 634 |
// Get the sections that belong to the page |
|
| 635 |
$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'");
|
|
| 636 |
if($query_sections->numRows() > 0) {
|
|
| 637 |
while($section = $query_sections->fetchRow()) {
|
|
| 638 |
// Set section id |
|
| 639 |
$section_id = $section['section_id']; |
|
| 640 |
// Include the modules delete file if it exists |
|
| 641 |
if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
|
|
| 642 |
require(WB_PATH.'/modules/'.$section['module'].'/delete.php'); |
|
| 643 |
} |
|
| 644 |
} |
|
| 645 |
} |
|
| 646 |
|
|
| 647 |
// Update the pages table |
|
| 648 |
$query = "DELETE FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
| 649 |
$database->query($query); |
|
| 650 |
if($database->is_error()) {
|
|
| 651 |
$admin->print_error($database->get_error()); |
|
| 652 |
} |
|
| 653 |
|
|
| 654 |
// Update the sections table |
|
| 655 |
$query = "DELETE FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id'"; |
|
| 656 |
$database->query($query); |
|
| 657 |
if($database->is_error()) {
|
|
| 658 |
$admin->print_error($database->get_error()); |
|
| 659 |
} |
|
| 660 |
|
|
| 661 |
// Include the ordering class or clean-up ordering |
|
| 662 |
require_once(WB_PATH.'/framework/class.order.php'); |
|
| 663 |
$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent'); |
|
| 664 |
$order->clean($parent); |
|
| 665 |
|
|
| 666 |
// Unlink the page access file and directory |
|
| 667 |
$directory = WB_PATH.PAGES_DIRECTORY.$link; |
|
| 668 |
$filename = $directory.'.php'; |
|
| 669 |
$directory .= '/'; |
|
| 670 |
if(file_exists($filename)) {
|
|
| 671 |
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/')) {
|
|
| 672 |
$admin->print_error($MESSAGE['PAGES']['CANNOT_DELETE_ACCESS_FILE']); |
|
| 673 |
} else {
|
|
| 674 |
unlink($filename); |
|
| 675 |
if(file_exists($directory)) {
|
|
| 676 |
rm_full_dir($directory); |
|
| 677 |
} |
|
| 678 |
} |
|
| 679 |
} |
|
| 680 |
|
|
| 681 |
} |
|
| 682 |
|
|
| 683 |
?> |
|
Also available in: Unified diff
Restructured frontend code and fixed various bugs