Project

General

Profile

« Previous | Next » 

Revision 1529

Added by Dietmar almost 13 years ago

add new backend theme handling (Tks to Stefek)

View differences:

class.wb.php
1 1
<?php
2 2
/**
3 3
 *
4
 * @category        frontend
5
 * @package         framework
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
4
 * @category        framework
5
 * @package         frontend 
6
 * @author          Ryan Djurovich, WebsiteBaker Project
8 7
 * @copyright       2009-2011, Website Baker Org. e.V.
9 8
 * @link			http://www.websitebaker2.org/
10 9
 * @license         http://www.gnu.org/licenses/gpl.html
......
337 336
		return (($value & $bits2test) == $bits2test);
338 337
	}
339 338

  
340
/*
341
	// Validate supplied email address
342
	function validate_email($email) {
343
		if(function_exists('idn_to_ascii')){ // use pear if available
344
			$email = idn_to_ascii($email);
345
		}else {
346
			require_once(WB_PATH.'/include/idna_convert/idna_convert.class.php');
347
			$IDN = new idna_convert();
348
			$email = $IDN->encode($email);
349
			unset($IDN);
350
		}
351
		return !(filter_var($email, FILTER_VALIDATE_EMAIL) == false);
352
	}
353
*/
354 339
	// Print a success message which then automatically redirects the user to another page
355 340
	function print_success( $message, $redirect = 'index.php' ) {
356 341
	    global $TEXT;
......
360 345
	    // fetch redirect timer for sucess messages from settings table
361 346
	    $redirect_timer = ((defined( 'REDIRECT_TIMER' )) && (REDIRECT_TIMER <= 10000)) ? REDIRECT_TIMER : 0;
362 347
	    // add template variables
363
	    $tpl = new Template( THEME_PATH.'/templates' );
348
		// Setup template object, parse vars to it, then parse it
349
		$ThemePath = realpath(WB_PATH.$this->correct_theme_source('success.htt'));
350
		$tpl = new Template($ThemePath);
364 351
	    $tpl->set_file( 'page', 'success.htt' );
365 352
	    $tpl->set_block( 'page', 'main_block', 'main' );
366 353
	    $tpl->set_block( 'main_block', 'show_redirect_block', 'show_redirect' );
......
385 372
        if(is_array($message)) {
386 373
           $message = implode ('<br />',$message);
387 374
        }
388
		$success_template = new Template(THEME_PATH.'/templates');
375
		// Setup template object, parse vars to it, then parse it
376
		$ThemePath = realpath(WB_PATH.$this->correct_theme_source('error.htt'));
377
		$success_template = new Template($ThemePath);
389 378
		$success_template->set_file('page', 'error.htt');
390 379
		$success_template->set_block('page', 'main_block', 'main');
391 380
		$success_template->set_var('MESSAGE', $message);
......
440 429
		}
441 430
	}
442 431

  
432
	/**
433
	 * checks if there is an alternative Theme template
434
	 *
435
	 * @access public
436
	 * @param string : set the template.htt
437
	 * @return string: the relative theme path
438
	 *
439
	 */
440
	function correct_theme_source($sThemeFile = 'start.htt'){
441
		$sThemePath = ADMIN_URL.'/themes/templates';
442
		if ( file_exists( THEME_PATH.'/templates/'.$sThemeFile ) ){
443
			$sThemePath = THEME_URL.'/templates';
444
	}
445
		return str_replace(WB_URL,'',$sThemePath);
446
	}
447

  
448
	/**
449
	 * Check if a foldername doesn't have invalid characters
450
	 *
451
	 * @param String $str to check
452
	 * @return Bool
453
	 */
454
	function checkFolderName($str){
455
		return !( preg_match('#\^|\\\|\/|\.|\?|\*|"|\'|\<|\>|\:|\|#i', $str) ? TRUE : FALSE );
456
	}
457

  
458
	/**
459
	 * Check the given path to make sure current path is within given basedir
460
	 * normally document root
461
	 *
462
	 * @param String $sCurrentPath
463
	 * @param String $sBaseDir
464
	 * @return $sCurrentPath or FALSE
465
	 */
466
	function checkpath($sCurrentPath, $sBaseDir = WB_PATH){
467
		// Clean the cuurent path
468
        $sCurrentPath = rawurldecode($sCurrentPath);
469
        $sCurrentPath = realpath($sCurrentPath);
470
        $sBaseDir = realpath($sBaseDir);
471
		// $sBaseDir needs to exist in the $sCurrentPath
472
		$pos = stripos ($sCurrentPath, $sBaseDir );
473

  
474
		if ( $pos === FALSE ){
475
			return false;
476
		} elseif( $pos == 0 ) {
477
			return $sCurrentPath;
478
		} else {
479
			return false;
480
		}
481
	}
482

  
443 483
}

Also available in: Unified diff