IsValidPath() public static method

Returns true if the template path is valid.
public static IsValidPath ( string $p_path, boolenan $p_checkIfExists = true ) : boolean
$p_path string
$p_checkIfExists boolenan
return boolean
Example #1
0
<?php
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/templates/template_common.php");

$f_template_code = Input::Get('f_template_code', 'array', array(), true);
$f_destination_folder = Input::Get('f_destination_folder', 'string', '', true);
$f_current_folder = Input::Get('f_current_folder', 'string', 0, true);
$f_action = Input::Get('f_action');

$f_current_folder = urldecode($f_current_folder);

if (!Template::IsValidPath($f_current_folder) || !Template::IsValidPath($f_destination_folder)) {
	camp_html_goto_page("/$ADMIN/templates/");
}

foreach ($f_template_code as $name) {
     if (!Template::IsValidPath($name, false)) {
    	camp_html_goto_page("/$ADMIN/templates/");
    }
}

//
// Check permissions
//
if ($f_action == "move") {
	if (!$g_user->hasPermission("ManageTempl")) {
		camp_html_display_error(getGS("You do not have the right to move articles."));
		exit;
	}
}

// $articles array:
Example #2
0
<?php
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/templates/template_common.php");

if (!$g_user->hasPermission('ManageTempl') && !$g_user->hasPermission('DeleteTempl')) {
	camp_html_goto_page("/$ADMIN/");
}

$path = Input::Get('Path', 'string', '');
if (!Template::IsValidPath($path)) {
	$path = "";
}

Template::UpdateStatus();

$crumbs = array();
$crumbs[] = array(getGS("Configure"), "");
$crumbs[] = array(getGS("Templates"), "/$ADMIN/templates/");
$crumbs = array_merge($crumbs, camp_template_path_crumbs($path));
$crumbs[] = array(getGS('Templates'), '');
echo camp_html_breadcrumbs($crumbs);

include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php");

?>
<P>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" class="action_buttons">
<TR>
	<?php
	if (!empty($path)) {
		$new_path = substr($path, 0, strrpos($path, '/'));
		?>
Example #3
0
    $f_path = substr($f_path_name, 0, strrpos($f_path_name, $f_name)-1);
} else {
    $f_path = Input::Get('f_path', 'string', '');
    $f_name = Input::Get('f_name', 'string', '');
}

$f_path = preg_replace('#//+#', '/', $f_path);

if ($f_path == '/') {
    $f_path = '';
}

$f_content = Input::Get('f_content', 'string', '', true);

$backLink  = "/$ADMIN/templates/";
if (!Template::IsValidPath($f_path.DIR_SEP.$f_name)) {
    camp_html_goto_page($backLink);
}
$filename = Template::GetFullPath($f_path, $f_name);
$templateName = (!empty($f_path) ? $f_path."/" : "").$f_name;
if ($templateName[0] == '/') {
    $templateName = substr($templateName, 1);
}
$templateObj = new Template($templateName);

if (!file_exists($filename)) {
    camp_html_display_error(getGS("Invalid template file $1" , $f_path."/$f_name"), $backLink);
    exit;
}

if (!is_writable($filename)) {
Example #4
0
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/templates/template_common.php");

if (!SecurityToken::isValid()) {
    camp_html_display_error(getGS('Invalid security token!'));
    exit;
}

if (!$g_user->hasPermission('ManageTempl')) {
	camp_html_display_error(getGS("You do not have the right to modify templates."));
	exit;
}

$f_path = Input::Get('f_path', 'string', '');
$f_name = Input::Get('f_name', 'string', '');

if (!Template::IsValidPath($f_path) || !Template::IsValidPath($f_name, false)) {
	camp_html_goto_page("/$ADMIN/templates/");
}

if (trim($f_name) == "") {
	camp_html_add_msg(getGS('You must fill in the $1 field.','<B>'.getGS('Name').'</B>'));
	camp_html_goto_page("/$ADMIN/templates/new_template.php?Path=".urlencode($f_path));
}

$f_name = strtr($f_name,'?~#%*&|"\'\\/<>', '_____________');

// Set the extension of the new file if it doesnt have one already.
$new_path_info = pathinfo($f_name);
$newExtension = isset($new_path_info["extension"]) ? $new_path_info["extension"] : "";
if (empty($newExtension)) {
	if ($f_name[strlen($f_name)-1] != ".") {
Example #5
0
    camp_html_display_error(getGS('Invalid security token!'));
    exit;
}

if (!$g_user->hasPermission('DeleteTempl')) {
	camp_html_display_error(getGS("You do not have the right to delete templates."));
	exit;
}

$Path = Input::Get('Path', 'string', '');
$Name = Input::Get('Name', 'string', '');
$isFile = Input::Get('What', 'int', 0);

$Path = preg_replace('#/+#', '/', $Path);

if (!Template::IsValidPath($Path.DIR_SEP.$Name)) {
	camp_html_goto_page("/$ADMIN/templates/");
}

$backLink = "/$ADMIN/templates/?Path=".urlencode($Path);
$fileFullName = preg_replace('#^/+#', '', (!empty($Path)) ? $Path.DIR_SEP.$Name : $Name);
$fileFullPath = Template::GetFullPath($Path, '');
$errorMsgs = array();

$deleted = false;
if (!$isFile) {
        $deleted = rmdir($fileFullPath.$Name);
	if ($deleted) {
		$logtext = getGS('Directory $1 was deleted', mysql_real_escape_string($fileFullName));
		Log::Message($logtext, $g_user->getUserId(), 112);
		camp_html_add_msg($logtext, "ok");
Example #6
0
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/templates/template_common.php");

if (!SecurityToken::isValid()) {
    camp_html_display_error(getGS('Invalid security token!'));
    exit;
}

if (!$g_user->hasPermission('ManageTempl')) {
	camp_html_display_error(getGS("You do not have the right to modify templates."));
}

$f_path = Input::Get('f_path', 'string', '');
$f_new_name = Input::Get('f_new_name', 'string', '');
$f_orig_name = Input::Get('f_orig_name', 'string', '');

if (!Template::IsValidPath($f_new_name, false) || !Template::IsValidPath($f_path.DIR_SEP.$f_orig_name)) {
	camp_html_goto_page("/$ADMIN/templates/");
}

$backLink = "/$ADMIN/templates/dup.php?Path=".urlencode($f_path)."&Name=".urlencode($f_orig_name);
if (trim($f_new_name) == "") {
	camp_html_add_msg(getGS('You must fill in the $1 field.','<B>'.getGS('Name').'</B>'));
	camp_html_goto_page($backLink);
}
$ok = false;
$f_new_name = strtr($f_new_name,'?~#%*&|"\'\\/<>', '_____________');

// Set the extension of the duplicate to be the same as the original file.
$orig_path_info = pathinfo($f_orig_name);
$origExtension = isset($orig_path_info["extension"]) ? $orig_path_info["extension"] : "";
$new_path_info = pathinfo($f_new_name);
Example #7
0
<?php
require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/templates/template_common.php");

if (!SecurityToken::isValid()) {
    camp_html_display_error(getGS('Invalid security token!'));
    exit;
}

if (!$g_user->hasPermission('ManageTempl')) {
	camp_html_display_error(getGS("You do not have the right to create new folders."));
	exit;
}

$cPath = Input::Get('cPath', 'string', '');
if (!Template::IsValidPath($cPath, false)) {
	camp_html_goto_page("/$ADMIN/templates/");
}
$cName = Input::Get('cName', 'string', '');

$backLink = "/$ADMIN/templates/new_dir.php?Path=".urlencode($cPath);

if (trim($cName) == '') {
	camp_html_add_msg(getGS('You must fill in the $1 field.','<B>'.getGS('Name').'</B>'));
	camp_html_goto_page($backLink);
}

if (trim($cName) == '..' || trim($cName) == '.') {
	camp_html_add_msg(getGS("The folder name can't be '..' or '.'"));
	camp_html_goto_page($backLink);
}