Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Replace dirname() by forwardSlashDirname() when manipulating groupPat…
Browse files Browse the repository at this point in the history
…h to avoid errors on Windows.
  • Loading branch information
cdujeu committed Jul 26, 2013
1 parent e0c21b1 commit 4d12eb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions core/src/core/classes/class.AJXP_Utils.php
Expand Up @@ -181,6 +181,15 @@ public static function setApplicationFirstRunPassed(){
@file_put_contents(AJXP_CACHE_DIR."/first_run_passed", "true");
}

public static function forwardSlashDirname($path){
return (DIRECTORY_SEPARATOR === "\\" ? str_replace("\\", "/", dirname($path)): dirname($path));
}

public static function forwardSlashBasename($path){
return (DIRECTORY_SEPARATOR === "\\" ? str_replace("\\", "/", basename($path)): basename($path));
}


/**
* Parse a Comma-Separated-Line value
* @static
Expand Down
Expand Up @@ -375,7 +375,7 @@ function switchAction($action, $httpVars, $fileVars){
case "create_group":

if(isSet($httpVars["group_path"])){
$basePath = dirname($httpVars["group_path"]);
$basePath = AJXP_Utils::forwardSlashDirname($httpVars["group_path"]);
if(empty($basePath)) $basePath = "/";
$gName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic(basename($httpVars["group_path"])), AJXP_SANITIZE_ALPHANUM);
}else{
Expand Down Expand Up @@ -414,7 +414,7 @@ function switchAction($action, $httpVars, $fileVars){
$roleGroup = false;
if(strpos($roleId, "AJXP_GRP_") === 0){
$groupPath = AuthService::filterBaseGroup(substr($roleId, strlen("AJXP_GRP_/")));
$groups = AuthService::listChildrenGroups(dirname($groupPath));
$groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
$key = "/".basename($groupPath);
if(!array_key_exists($key, $groups)){
throw new Exception("Cannot find group with this id!");
Expand Down Expand Up @@ -485,7 +485,7 @@ function switchAction($action, $httpVars, $fileVars){
if(strpos($roleId, "AJXP_GRP_") === 0){
$groupPath = AuthService::filterBaseGroup(substr($roleId, strlen("AJXP_GRP_")));
$roleId = "AJXP_GRP_".$groupPath;
$groups = AuthService::listChildrenGroups(dirname($groupPath));
$groups = AuthService::listChildrenGroups(AJXP_Utils::forwardSlashDirname($groupPath));
$key = "/".basename($groupPath);
if(!array_key_exists($key, $groups)){
throw new Exception("Cannot find group with this id!");
Expand Down Expand Up @@ -1321,7 +1321,7 @@ function switchAction($action, $httpVars, $fileVars){
AJXP_XMLWriter::close();
}else if(isSet($httpVars["group"])){
$groupPath = $httpVars["group"];
$basePath = substr(dirname($groupPath), strlen("/data/users"));
$basePath = substr(AJXP_Utils::forwardSlashDirname($groupPath), strlen("/data/users"));
$gName = basename($groupPath);
AuthService::deleteGroup($basePath, $gName);
AJXP_XMLWriter::header();
Expand Down

0 comments on commit 4d12eb1

Please sign in to comment.