Skip to content

Commit 021ed60

Browse files
author
Ian Moore
committed
5.0-1 2015-08-05
1 parent 2e885ce commit 021ed60

File tree

3 files changed

+93
-87
lines changed

3 files changed

+93
-87
lines changed

CHANGELOG.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-------------------------------------
2-
5.0-1 2015-08-04
2+
5.0-1 2015-08-05
33
-------------------------------------
44
Fix paths in recovery.php-disabled
55

@@ -11,6 +11,12 @@ Fix RDP link
1111

1212
Fix bug when changing password
1313

14+
Removed unused OnAdditionsStateChanged event
15+
16+
Change in the way Windows drive list is obtained
17+
18+
Fixed errors manipulating groups when $phpVboxGroups is set
19+
1420
-------------------------------------
1521
5.0-0 2015-07-18
1622
-------------------------------------

endpoints/jqueryFileTree.php

Lines changed: 77 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,33 @@
7272
if(!is_array($allowed_folders))
7373
$allowed_folders = array();
7474

75+
/*
76+
* Get a list of windows drives
77+
*/
78+
function get_windows_drives() {
79+
$checklist = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
80+
$drives = array();
81+
for($i = 0; $i < strlen($d); $i++) {
82+
if(is_dir($checklist[$i].':\\')) {
83+
$drives[] = $checklist[$i].':\\';
84+
}
85+
}
86+
return $drives;
87+
}
88+
7589
/*
7690
* Allowed folders in windows if none are set
7791
*/
7892
if(stripos($vbox->vbox->host->operatingSystem,'win') === 0 && !count($allowed_folders)) {
79-
93+
8094
/*
81-
* Get from WMIC. Assumes web server and vbox host are the same physical machine
95+
* Assumes web server and vbox host are the same physical machine
8296
*/
8397
if($request['fullpath'] && !$settings->forceWindowsAllDriveList && !$settings->noWindowsDriveList && stripos(PHP_OS,'win') === 0) {
84-
85-
exec("wmic logicaldisk get caption", $out);
86-
if(is_array($out) && count($out) > 2) {
87-
88-
$allowed_folders = array();
89-
90-
// Shift off header
91-
array_shift($out);
92-
93-
// Shift off footer
94-
array_pop($out);
95-
96-
// These are now restricted folders
97-
foreach ($out as $val) {
98-
$allowed_folders[] = $val . '\\';
99-
}
100-
}
101-
98+
99+
100+
$allowed_folders = get_windows_drives();
101+
102102
/*
103103
* Just show all C-Z drive letters if vboxhost is windows and our web server is not...
104104
*/
@@ -109,7 +109,7 @@
109109
}
110110
}
111111
$allowed_folders = array_combine($allowed_folders,$allowed_folders);
112-
112+
113113
}
114114

115115

@@ -124,7 +124,7 @@
124124
$request['dir'] = str_replace(DSEP.DSEP,DSEP,$request['dir']);
125125

126126

127-
/*
127+
/*
128128
* Check that folder restriction validates if it exists
129129
*/
130130
if($request['dir'] != DSEP && count($allowed_folders)) {
@@ -147,40 +147,40 @@
147147

148148
/* Folder Restriction with root '/' requested */
149149
if($request['dir'] == DSEP && count($allowed_folders)) {
150-
150+
151151
/* Just return restricted folders */
152152
foreach($allowed_folders as $f) {
153153
array_push($returnData, folder_entry($f, true));
154-
154+
155155
}
156-
156+
157157
} else {
158158

159159

160160
/* Full, expanded path to $dir */
161161
if($request['fullpath']) {
162-
163-
162+
163+
164164
/* Go through allowed folders if it is set */
165165
if(count($allowed_folders)) {
166-
167-
166+
167+
168168
foreach($allowed_folders as $f) {
169-
169+
170170
/* If this was not exactly the requested folder, but a parent,
171171
* list everything below it.
172172
*/
173173
if((strtoupper($request['dir']) != strtoupper($f)) && strpos(strtoupper($request['dir']),strtoupper($f)) === 0) {
174-
175-
174+
175+
176176
// List entries in this folder
177177
$path = explode(DSEP,substr($request['dir'],strlen($f)));
178178

179179
// Folder entry
180180
array_push($returnData, getdir($f, $request['dirsOnly'], $path));
181181

182182
} else {
183-
183+
184184
array_push($returnData, folder_entry($f,true));
185185
}
186186
}
@@ -191,25 +191,23 @@
191191
// List entries in this folder
192192
$path = explode(DSEP,$request['dir']);
193193
$root = array_shift($path).DSEP;
194-
194+
195195
// Folder entry
196196
$returnData = getdir($root, $request['dirsOnly'], $path);
197197

198198
}
199-
199+
200200

201201
} else {
202-
202+
203203
/* Default action. Return dir requested */
204204
$returnData = getdir($request['dir'], $request['dirsOnly']);
205205

206206
}
207-
207+
208208
}
209209

210210
header('Content-type', 'application/json');
211-
#echo("<pre>");
212-
#print_r($returnData);
213211
echo(json_encode($returnData));
214212

215213

@@ -221,41 +219,41 @@ function getdir($dir, $dirsOnly=false, $recurse=array()) {
221219
if(!$dir) $dir = DSEP;
222220

223221
$entries = getDirEntries($dir, $dirsOnly);
224-
222+
225223
if(!count($entries))
226224
return array();
227-
225+
228226
$dirents = array();
229227
foreach($entries as $path => $type) {
230-
228+
231229
if($type == 'folder' && count($recurse) && (strcasecmp($recurse[0],vbox_basename($path)) == 0)) {
232230

233231
$entry = folder_entry($path, false, true);
234-
232+
235233
$entry['children'] = getdir($dir.DSEP.array_shift($recurse), $dirsOnly, $recurse);
236-
234+
237235
array_push($dirents, $entry);
238-
236+
239237
} else {
240-
238+
241239
// Push folder on to stack
242240
if($type == 'folder') {
243-
241+
244242
array_push($dirents, folder_entry($path));
245-
243+
246244
// Push file on to stack
247245
} else {
248-
246+
249247
$ext = strtolower(preg_replace('/^.*\./', '', $file));
250248

251249
if(count($allowed) && !$allowed['.'.$ext]) continue;
252-
250+
253251
array_push($dirents, file_entry($path));
254252
}
255253
}
256-
254+
257255
}
258-
256+
259257
return $dirents;
260258

261259
}
@@ -288,55 +286,55 @@ function folder_entry($f,$full=false,$expanded=false) {
288286

289287
/**
290288
* Rreturn a list of directory entries
291-
*
289+
*
292290
* @param String $dir
293291
* @return Array of entries
294292
*/
295293

296294
function getDirEntries($dir, $foldersOnly=false) {
297-
295+
298296
global $localbrowser, $allowed_exts, $vbox;
299-
297+
300298
// Append trailing slash if it isn't here
301299
if(substr($dir,-1) != DSEP)
302300
$dir .= DSEP;
303-
304-
305-
/*
301+
302+
303+
/*
306304
* Use local file / folder browser (PHP)
307305
*/
308306
if($localbrowser) {
309-
307+
310308
// If the dir doesn't exist or we can't scan it, just return
311309
if(!(file_exists($dir) && ($ents = @scandir($dir))))
312310
return array();
313-
311+
314312
$newtypes = array();
315313
$newents = array();
316314
for($i = 0; $i < count($ents); $i++) {
317-
315+
318316
// Skip . and ..
319317
if($ents[$i] == '.' || $ents[$i] == '..')
320318
continue;
321-
319+
322320
$fullpath = $dir.$ents[$i];
323321
$isdir = @is_dir($fullpath);
324-
322+
325323
if(!$isdir && $foldersOnly)
326324
continue;
327-
325+
328326
array_push($newtypes, $isdir ? 'folder' : 'file');
329327
array_push($newents, $fullpath);
330328
}
331329
return array_combine($newents, $newtypes);
332-
330+
333331
/*
334332
* Use remote file / folder browser (vbox)
335333
*/
336334
} else {
337-
335+
338336
try {
339-
337+
340338

341339
$appl = $vbox->vbox->createAppliance();
342340
$vfs = $appl->createVFSExplorer('file://'.str_replace(DSEP.DSEP,DSEP,$dir));
@@ -346,35 +344,35 @@ function getDirEntries($dir, $foldersOnly=false) {
346344
list($ents,$types) = $vfs->entryList();
347345
$vfs->releaseRemote();
348346
$appl->releaseRemote();
349-
347+
350348
} catch (Exception $e) {
351-
349+
352350
echo($e->getMessage());
353-
351+
354352
return array();
355-
353+
356354
}
357-
355+
358356
// Convert types to file / folder
359357
$newtypes = array();
360358
$newents = array();
361359
for($i = 0; $i < count($types); $i++) {
362-
360+
363361
// Skip . and ..
364362
if($ents[$i] == '.' || $ents[$i] == '..')
365363
continue;
366-
364+
367365
$isdir = $types[$i] == 4;
368-
366+
369367
if(!$isdir && $foldersOnly)
370368
continue;
371-
369+
372370
array_push($newtypes, $isdir ? 'folder' : 'file');
373371
array_push($newents, $dir.$ents[$i]);
374372
}
375373
return array_combine($newents,$newtypes);
376-
374+
377375
}
378-
379-
376+
377+
380378
}

endpoints/lib/vboxconnector.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,11 +819,6 @@ private function _getEventData($event, $listenerKey) {
819819
$data['dedupId'] .= '-'. $data['machineId'] .'-' . $data['name'];
820820
break;
821821

822-
case 'OnAdditionsStateChanged':
823-
$data['machineId'] = $eventDataObject->machineId;
824-
$data['dedupId'] .= '-'. $data['machineId'];
825-
break;
826-
827822
case 'OnCPUChanged':
828823
$data['machineId'] = $data['sourceId'];
829824
$data['cpu'] = $eventDataObject->cpu;
@@ -1297,12 +1292,12 @@ public function remote_machinesSaveGroups($args) {
12971292

12981293
$this->session = $this->websessionManager->getSessionObject($this->vbox->handle);
12991294

1300-
$machine->lockMachine($this->session->handle, 'Write');
1295+
$machine->lockMachine($this->session->handle, 'Shared');
13011296

13021297
usort($newGroups,'strnatcasecmp');
13031298

13041299
if($this->settings->phpVboxGroups) {
1305-
$machine->setExtraData(vboxconnector::phpVboxGroupKey, implode(',',$newGroups));
1300+
$this->session->machine->setExtraData(vboxconnector::phpVboxGroupKey, implode(',', $newGroups));
13061301
} else {
13071302
$this->session->machine->groups = $newGroups;
13081303
}
@@ -1318,6 +1313,13 @@ public function remote_machinesSaveGroups($args) {
13181313
$this->errors[] = $e;
13191314
$response['errored'] = true;
13201315

1316+
try {
1317+
$this->session->unlockMachine();
1318+
unset($this->session);
1319+
} catch (Exception $e) {
1320+
// pass
1321+
}
1322+
13211323
continue;
13221324

13231325
}

0 commit comments

Comments
 (0)