}
/// extra safety
- @session_write_close();
+ @session_get_instance()->write_close();
/// check if execution allowed
if (isset($_SERVER['REMOTE_ADDR'])) { // if the script is accessed via the web.
function dbtransfer_export_xml_database($description, $mdb) {
@set_time_limit(0);
- session_write_close(); // release session
+ session_get_instance()->write_close(); // release session
header('Content-Type: application/xhtml+xml');
header('Content-Disposition: attachment; filename=database.xml');
function dbtransfer_transfer_database($sourcedb, $targetdb) {
@set_time_limit(0);
- session_write_close(); // release session
+ session_get_instance()->write_close(); // release session
$var = new database_mover($sourcedb, $targetdb);
$var->export_database(null);
$stradministration = get_string('administration');
$strreports = get_string('reports');
- session_write_close();
+ session_get_instance()->write_close();
$navlinks = array();
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
- session_write_close();
+ session_get_instance()->write_close();
// we override the default framename so header/footer
// links open in a new window
// ========================================
// finally send the file
// ========================================
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, 0, false, true); // force download - security first!
// ========================================
// finally send the file
// ========================================
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, $lifetime, $CFG->filteruploadedfiles, $forcedownload);
public function dispose() {
if ($this->used_for_db_sessions) {
// this is needed because we need to save session to db before closing it
- session_write_close();
+ session_get_instance()->write_close();
$this->used_for_db_sessions = false;
}
if ($this->database_manager) {
global $CFG;
// close session - not needed anymore
- @session_write_close();
+ @session_get_instance()->write_close();
if (!$pathisstring) {
if (!file_exists($path)) {
}
}
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
// Use given MIME type if specified, otherwise guess it using mimeinfo.
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
ignore_user_abort(true);
}
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
// Use given MIME type if specified, otherwise guess it using mimeinfo.
// IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
}
}
- session_get_instance()->terminate();
+ session_get_instance()->terminate_current();
}
/**
}
interface moodle_session {
- public function terminate();
+ /**
+ * Terminate current session
+ * @return void
+ */
+ public function terminate_current();
+
+ /**
+ * No more changes in session expected.
+ * Unblocks the sesions, other scripts may start executing in parallel.
+ * @return void
+ */
+ public function write_close();
+
}
/**
$this->check_security();
}
+ /**
+ * Terminates active moodle session
+ */
+ public function terminate_current() {
+ global $CFG, $SESSION, $USER;
+
+ if (NO_MOODLE_COOKIES) {
+ return;
+ }
+
+ $_SESSION = array();
+
+ $SESSION = new object();
+ $USER = new object();
+ $USER->id = 0;
+ if (isset($CFG->mnet_localhost_id)) {
+ $USER->mnethostid = $CFG->mnet_localhost_id;
+ }
+
+ // Initialize variable to pass-by-reference to headers_sent(&$file, &$line)
+ $file = null;
+ $line = null;
+ if (headers_sent($file, $line)) {
+ error_log('Can not terminate session properly - headers were already sent in file: '.$file.' on line '.$line);
+ }
+
+ // now let's try to get a new session id and destroy the old one
+ @session_regenerate_id(true);
+
+ // close the session
+ @session_write_close();
+ }
+
+ /**
+ * No more changes in session expected.
+ * Unblocks the sesions, other scripts may start executing in parallel.
+ * @return void
+ */
+ public function write_close() {
+ if (NO_MOODLE_COOKIES) {
+ return;
+ }
+
+ session_write_close();
+ }
+
/**
* Initialise $USER object, handles google access.
*
if ($_SESSION['USER']->sessionip != $remoteaddr) {
// this is a security feature - terminate the session in case of any doubt
- $this->terminate();
+ $this->terminate_current();
print_error('sessionipnomatch2', 'error');
}
}
}
- /**
- * Terminates active moodle session
- */
- public function terminate() {
- global $CFG, $SESSION, $USER;
-
- $_SESSION = array();
-
- $SESSION = new object();
- $USER = new object();
- $USER->id = 0;
- if (isset($CFG->mnet_localhost_id)) {
- $USER->mnethostid = $CFG->mnet_localhost_id;
- }
-
- // Initialize variable to pass-by-reference to headers_sent(&$file, &$line)
- $file = null;
- $line = null;
- if (headers_sent($file, $line)) {
- error_log('Can not terminate session properly - headers were already sent in file: '.$file.' on line '.$line);
- }
-
- // now let's try to get a new session id and destroy the old one
- @session_regenerate_id(true);
-
- // close the session
- @session_write_close();
- }
-
/**
* Prepare cookies and varions system settings
*/
}
ini_set('session.save_path', $CFG->dataroot .'/sessions');
}
+
}
/**
if (isguest()) {
chat_print_error('ERROR', get_string('notlogged','chat'));
}
-session_write_close();
+session_get_instance()->write_close();
chat_delete_old_users();
$chat_message = clean_text($chat_message, FORMAT_MOODLE);
print_error('noguests');
}
- session_write_close();
+ session_get_instance()->write_close();
/// Delete old users now
send_file_not_found();
}
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, 60*60, 0, $forcedownload);
send_file_not_found();
}
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, 0, 0, true);
} else if ($filearea === 'course_intro') {
send_file_not_found();
}
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, 60*60, 0, false); // TODO: change timeout?
} else if ($filearea === 'user_profile') {
send_file_not_found();
}
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, 0, 0, true); // must force download - security!
} else {
}
// send the file
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
$filename = $args[count($args)-1];
send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
} else {
// ========================================
// finally send the file
// ========================================
- session_write_close(); // unlock session during fileserving
+ session_get_instance()->write_close(); // unlock session during fileserving
send_stored_file($file, 0, false, $forcedownload);