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

Commit

Permalink
Fix multiple smb servers
Browse files Browse the repository at this point in the history
  • Loading branch information
c12simple committed Mar 21, 2016
1 parent 38a5bbf commit 2d31017
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 43 deletions.
80 changes: 41 additions & 39 deletions core/src/plugins/access.smb/smb.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,48 +309,50 @@ public function url_stat ($url, $flags = STREAM_URL_STAT_LINK)
trigger_error ("url_stat(): list failed for host '{$host}'", E_USER_WARNING);
break;
case 'share':
if ($_SESSION["COUNT"] == 0) {
$_SESSION["COUNT"] = 1;
$id = "smb_".md5($pu["host"].$pu["user"]);
if ($_SESSION[$id] == 0 || true) {
$_SESSION[$id] = 1;
//self::debug("OH HEY");
//$__count++;
//self::debug($__count);
if ($o = smb::look ($pu)) {
$_SESSION["disk"] = $o['disk'];
self::debug(print_r($_SESSION["disk"], true));
//self::debug(print_r($_ENV, true));
$found = FALSE;
$lshare = strtolower ($pu['share']); # fix by Eric Leung
if (is_array($o) && isSet($o['disk']) && is_array($o['disk'])) {
foreach ($o['disk'] as $s) if ($lshare == strtolower($s)) {
$found = TRUE;
//self::debug("DISK: " . $s);
$stat = stat (SMB4PHP_SMBTMP);
break;
}
}
if (! $found)
//trigger_error ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING);
return null;
}
break;
} else {
//self::debug($__count);
//self::debug("WORKING");
$found = FALSE;
$lshare = strtolower ($pu['share']); # fix by Eric Leung
if (is_array($_SESSION["disk"]) && isSet($_SESSION["disk"]) && is_array($_SESSION["disk"])) {
foreach ($_SESSION["disk"] as $s) if ($lshare == strtolower($s)) {
$found = TRUE;
//self::debug("oh boy");
$stat = stat (SMB4PHP_SMBTMP);
break;
}
}
if (! $found)
//trigger_error ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING);
return null;
break;
}
if ($o = smb::look($pu)) {
$_SESSION[$id."disk"] = $o['disk'];
self::debug(print_r($_SESSION[$id."disk"], true));
//self::debug(print_r($_ENV, true));
$found = FALSE;
$lshare = strtolower($pu['share']); # fix by Eric Leung
if (is_array($o) && isSet($o['disk']) && is_array($o['disk'])) {
foreach ($o['disk'] as $s){
if ($lshare == strtolower($s)) {
$found = TRUE;
//self::debug("DISK: " . $s);
$stat = stat(SMB4PHP_SMBTMP);
break;
}}
}
if (!$found)
//trigger_error ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING);
return null;
}
break;
} else {
//self::debug($__count);
//self::debug("WORKING");
$found = FALSE;
$lshare = strtolower($pu['share']); # fix by Eric Leung
if (is_array($_SESSION[$id."disk"]) && isSet($_SESSION[$id."disk"]) && is_array($_SESSION[$id."disk"])) {
foreach ($_SESSION[$id."disk"] as $s) if ($lshare == strtolower($s)) {
$found = TRUE;
//self::debug("oh boy");
$stat = stat(SMB4PHP_SMBTMP);
break;
}
}
if (!$found)
//trigger_error ("url_stat(): disk resource '{$share}' not found in '{$host}'", E_USER_WARNING);
return null;
break;
}
case 'path':
//self::debug('before exe'.print_r($pu, true));
$o = smb::execute ('dir "'.$pu['path'].'"', $pu);
Expand Down
14 changes: 10 additions & 4 deletions core/src/plugins/auth.smb/class.smbAuthDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public function logoutCallback($actionName, $httpVars, $fileVars)
AJXP_Safe::clearCredentials();
$adminUser = $this->options["ADMIN_USER"];
$subUsers = array();
unset($_SESSION["COUNT"]);
unset($_SESSION["disk"]);
foreach($_SESSION as $key => $val){
if((substr($key,-4) === "disk") && (substr($key,0,4) == "smb_")){
unset($_SESSION[$key]);
}
}
AuthService::disconnect();
session_write_close();
AJXP_XMLWriter::header();
Expand Down Expand Up @@ -84,8 +87,11 @@ public function checkPassword($login, $pass, $seed)
if (!is_dir($url)) {
$this->logDebug("SMB Login failure");
$_SESSION["AJXP_SESSION_REMOTE_PASS"] = '';
unset($_SESSION["COUNT"]);
unset($_SESSION["disk"]);
foreach($_SESSION as $key => $val){
if((substr($key,-4) === "disk") && (substr($key,0,4) == "smb_")){
unset($_SESSION[$key]);
}
}
return false;
}
AJXP_Safe::storeCredentials($login, $pass);
Expand Down

0 comments on commit 2d31017

Please sign in to comment.