Project

General

Profile

« Previous | Next » 

Revision 1869

Added by Dietmar over 11 years ago

solved renaming access files by page settings if php as apachehandler

View differences:

settings_save.php
18 18
// Create new admin object and print admin header
19 19
if(!defined('WB_URL'))
20 20
{
21
    $config_file = realpath('../../config.php');
22
    if(file_exists($config_file) && !defined('WB_URL'))
23
    {
24
    	require($config_file);
25
    }
21
	$config_file = realpath('../../config.php');
22
	if(file_exists($config_file) && !defined('WB_URL'))
23
	{
24
		require($config_file);
25
	}
26 26
}
27 27
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
28 28

  
......
133 133
}
134 134
if($seo_title == '' || substr($seo_title,0,1)=='.')
135 135
{
136
    $seo_title = $menu_title;
136
	$seo_title = $menu_title;
137 137
}
138 138

  
139 139
// Get existing perms
......
210 210

  
211 211
// Work-out what the link should be
212 212
if($parent == '0') {
213
    if($link == '/index' || $link == '/intro')
214
    {
215
    	$link .= '_' .$page_id;
216
    	$filename = WB_PATH.PAGES_DIRECTORY.$link .PAGE_EXTENSION;
217

  
218
    } else {
219
        $filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
220
    }
213
	if($link == '/index' || $link == '/intro')
214
	{
215
		$link .= '_' .$page_id;
216
		$filename = WB_PATH.PAGES_DIRECTORY.$link .PAGE_EXTENSION;
217
	
218
	} else {
219
	    $filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
220
	}
221 221
} else {
222 222
	$parent_section = '';
223 223
	$parent_titles = array_reverse(get_parent_titles($parent));
......
233 233
    }
234 234

  
235 235
	$link = $parent_section.$link;
236
    $filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
236
	$filename = WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION;
237 237
}
238 238

  
239 239
// Check if a page with same page filename exists
......
257 257

  
258 258
// Update page settings in the pages table
259 259
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` '
260
     . 'SET `parent`='.$parent.', '
261
     .     '`page_title`=\''.$page_title.'\', '
262
     .     '`tooltip`=\''.$page_title.'\', '
263
     .     '`page_icon` =\''.$database->escapeString($sPageIcon).'\', '
264
     .     '`menu_title`=\''.$menu_title.'\', '
265
     .     '`menu_icon_0` =\''.$database->escapeString($sMenuIcon0).'\', '
266
     .     '`menu_icon_1` =\''.$database->escapeString($sMenuIcon1).'\', '
267
     .     '`menu`='.$menu.', '
268
     .     '`level`='.$level.', '
269
     .     '`page_trail`=\''.$page_trail.'\', '
270
     .     '`root_parent`='.$root_parent.', '
271
     .     '`link`=\''.$link.'\', '
272
     .     '`template`=\''.$template.'\', '
273
     .     '`target`=\''.$target.'\', '
274
     .     '`description`=\''.$description.'\', '
275
     .     '`keywords`=\''.$keywords.'\', '
276
     .     '`position`='.$position.', '
277
     .     '`visibility`=\''.$visibility.'\', '
278
     .     '`searching`='.$searching.', '
279
     .     '`language`=\''.$language.'\', ';
260
	 . 'SET `parent`='.$parent.', '
261
	 .     '`page_title`=\''.$page_title.'\', '
262
	 .     '`tooltip`=\''.$page_title.'\', '
263
	 .     '`page_icon` =\''.$database->escapeString($sPageIcon).'\', '
264
	 .     '`menu_title`=\''.$menu_title.'\', '
265
	 .     '`menu_icon_0` =\''.$database->escapeString($sMenuIcon0).'\', '
266
	 .     '`menu_icon_1` =\''.$database->escapeString($sMenuIcon1).'\', '
267
	 .     '`menu`='.$menu.', '
268
	 .     '`level`='.$level.', '
269
	 .     '`page_trail`=\''.$page_trail.'\', '
270
	 .     '`root_parent`='.$root_parent.', '
271
	 .     '`link`=\''.$link.'\', '
272
	 .     '`template`=\''.$template.'\', '
273
	 .     '`target`=\''.$target.'\', '
274
	 .     '`description`=\''.$description.'\', '
275
	 .     '`keywords`=\''.$keywords.'\', '
276
	 .     '`position`='.$position.', '
277
	 .     '`visibility`=\''.$visibility.'\', '
278
	 .     '`searching`='.$searching.', '
279
	 .     '`language`=\''.$language.'\', ';
280 280
if($admin->ami_group_member('1')) {
281 281
	$sql .= ''
282 282
	     . '`admin_groups`=\''.$sAdminGroups.'\', '
283 283
	     . '`admin_users`=\''.$sAdminUsers.'\', ';
284 284
}
285
    $sql .= ''
286
         . '`viewing_groups`=\''.$sViewingGroups.'\', '
287
         . '`viewing_users`=\''.$sViewingUsers.'\', '
288
         . '`page_code`='.$page_code.' '
289
         . 'WHERE `page_id`='.$page_id;
285
	$sql .= ''
286
	 . '`viewing_groups`=\''.$sViewingGroups.'\', '
287
	 . '`viewing_users`=\''.$sViewingUsers.'\', '
288
	 . '`page_code`='.$page_code.' '
289
	 . 'WHERE `page_id`='.$page_id;
290 290

  
291 291
if(!$database->query($sql)) {
292 292
	$target_url = ADMIN_URL.'/pages/settings.php?page_id='.$page_id;
......
301 301

  
302 302
// using standard function by core,
303 303
function fix_page_trail($page_id) {
304
    global $database,$admin,$target_url,$pagetree_url,$MESSAGE;
304
	global $database,$admin,$target_url,$pagetree_url,$MESSAGE;
305 305

  
306
    $target_url = (isset($_POST['back_submit'])) ? $pagetree_url : $target_url;
306
	$target_url = (isset($_POST['back_submit'])) ? $pagetree_url : $target_url;
307
	
308
	// Work out level
309
	$level = level_count($page_id);
310
	// Work out root parent
311
	$root_parent = root_parent($page_id);
312
	// Work out page trail
313
	$page_trail = get_page_trail($page_id);
314
	// Update page with new level and link
315
	$sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
316
	$sql .= '`root_parent` = '.$root_parent.', ';
317
	$sql .= '`level` = '.$level.', ';
318
	$sql .= '`page_trail` = "'.$page_trail.'" ';
319
	$sql .= 'WHERE `page_id` = '.$page_id;
307 320

  
308
    // Work out level
309
    $level = level_count($page_id);
310
    // Work out root parent
311
    $root_parent = root_parent($page_id);
312
    // Work out page trail
313
    $page_trail = get_page_trail($page_id);
314
    // Update page with new level and link
315
    $sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
316
    $sql .= '`root_parent` = '.$root_parent.', ';
317
    $sql .= '`level` = '.$level.', ';
318
    $sql .= '`page_trail` = "'.$page_trail.'" ';
319
    $sql .= 'WHERE `page_id` = '.$page_id;
320

  
321
    if($database->query($sql)) {
322
    	$admin->print_success($MESSAGE['PAGES_SAVED_SETTINGS'], $target_url );
323
    } else {
324
    	$admin->print_error($database->get_error(), $target_url );
325
    }
321
	if($database->query($sql)) {
322
		$admin->print_success($MESSAGE['PAGES_SAVED_SETTINGS'], $target_url );
323
	} else {
324
		$admin->print_error($database->get_error(), $target_url );
325
	}
326 326
}
327 327

  
328 328
// Fix sub-pages page trail
......
336 336
 * otherwise acess denied
337 337
 * 
338 338
 */
339
$bCanCreateAcessFiles = is_writeable(WB_PATH);
340
$bCanCreateAcessFiles = ( ( $bCanCreateAcessFiles==true ) ? make_dir(WB_PATH.PAGES_DIRECTORY) : false );
339

  
340
$bCanCreateAcessFiles = make_dir(WB_PATH.PAGES_DIRECTORY);
341
$bCanCreateAcessFiles = (($bCanCreateAcessFiles==true) ? file_exists(WB_PATH) && is_writable(WB_PATH.PAGES_DIRECTORY) : false );
341 342
if( !$bCanCreateAcessFiles )
342 343
{
343 344
	$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'], $target_url);
344 345
} else {
345 346
// Create a new file in the /pages dir if title changed
346 347

  
347
    $old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
348
	$old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
348 349

  
349 350
	// First check if we need to create a new file
350 351
	if(($old_link != $link) || (!file_exists($old_filename)))
351
    {
352
	{
352 353
		// Delete old file
353 354
		$old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
354 355
		if(file_exists($old_filename))
355
        {
356
		{
356 357
			unlink($old_filename);
357 358
		}
358 359

  
359 360
		// Create access file
360 361
		create_access_file($filename,$page_id,$level);
361
        if(!file_exists($filename)) {
362
        	$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
363
        }
362
		if(!file_exists($filename)) {
363
			$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
364
		}
364 365
		// Move a directory for this page
365 366
		if(is_readable(WB_PATH.PAGES_DIRECTORY.$old_link.'/') && is_dir(WB_PATH.PAGES_DIRECTORY.$old_link.'/'))
366
        {
367
		{
367 368
			rename(WB_PATH.PAGES_DIRECTORY.$old_link.'/', WB_PATH.PAGES_DIRECTORY.$link.'/');
368 369
		}
369 370
		// Update any pages that had the old link with the new one
370 371
		$old_link_len = strlen($old_link);
371
        $sql = '';
372
		$sql = '';
372 373
		$query_subs = $database->query("SELECT page_id,link,level FROM ".TABLE_PREFIX."pages WHERE link LIKE '%$old_link/%' ORDER BY LEVEL ASC");
373 374

  
374 375
		if($query_subs->numRows() > 0)
375
        {
376
		{
376 377
			while($sub = $query_subs->fetchRow())
377
            {
378
			{
378 379
				// Double-check to see if it contains old link
379
				if(substr($sub['link'], 0, $old_link_len) == $old_link)
380
                {
380
				if(substr($sub['link'], 0, $old_link_len) == $old_link) {
381 381
					// Get new link
382 382
					$replace_this = $old_link;
383 383
					$old_sub_link_len =strlen($sub['link']);
......
388 388
					$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$new_sub_link', level = '$new_sub_level' WHERE page_id = '".$sub['page_id']."' LIMIT 1");
389 389
					// Re-write the access file for this page
390 390
					$old_subpage_file = WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION;
391
					if(file_exists($old_subpage_file))
392
                    {
391
					if(file_exists($old_subpage_file)) {
393 392
						unlink($old_subpage_file);
394 393
					}
395
                    $sAccessFile = WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION;
394
					$sAccessFile = WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION;
396 395
					create_access_file($sAccessFile, $sub['page_id'], $new_sub_level);
397
                    if(!file_exists($sAccessFile)) {
398
                    	$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
399
                    }
396
					if(!file_exists($sAccessFile)) {
397
						$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
398
					}
400 399

  
401 400
				}
402 401
			}

Also available in: Unified diff