-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathput_session.php
31 lines (27 loc) · 1013 Bytes
/
put_session.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
OCP\App::checkAppEnabled('files_sharding');
include_once("files_sharding/lib/lib_files_sharding.php");
$ret = array();
if(!OCA\FilesSharding\Lib::checkIP()){
$ret['error'] = "Network not secure";
}
else{
$id = $_POST['id'];
$data = json_decode($_POST['session']);
$session_save_path = trim(session_save_path());
\OC_Log::write('files_sharding',"Saving session ".(!empty($id)?$id:"NONE").":".$data.":".(file_exists("$session_save_path/sess_$id")?"$session_save_path/sess_$id":"not found"), \OC_Log::WARN);
if(empty($session_save_path)){
$session_save_path = "/tmp";
}
if(empty($data) && !empty($id) && file_exists("$session_save_path/sess_$id")) {
\OC_Log::write('files_sharding',"Deleting session file "."$session_save_path/sess_$id", \OC_Log::WARN);
$res = unlink("$session_save_path/sess_$id");
}
else{
$res = file_put_contents("$session_save_path/sess_$id", $data);
}
if(!$res){
$ret['error'] = "Could not save $session_save_path/sess_$id";
}
}
OCP\JSON::encodedPrint($ret);