40 global $dolibarr_main_db_type, $dolibarr_main_db_host;
41 global $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name, $dolibarr_main_db_port;
43 global $dolibarr_session_db_type, $dolibarr_session_db_host;
44 global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port;
46 if (empty($dolibarr_session_db_type)) { $dolibarr_session_db_type = $dolibarr_main_db_type; }
47 if (empty($dolibarr_session_db_host)) { $dolibarr_session_db_host = $dolibarr_main_db_host; }
48 if (empty($dolibarr_session_db_user)) { $dolibarr_session_db_user = $dolibarr_main_db_user; }
49 if (empty($dolibarr_session_db_pass)) { $dolibarr_session_db_pass = $dolibarr_main_db_pass; }
50 if (empty($dolibarr_session_db_name)) { $dolibarr_session_db_name = $dolibarr_main_db_name; }
51 if (empty($dolibarr_session_db_port)) { $dolibarr_session_db_port = $dolibarr_main_db_port; }
54 $dbsession =
getDoliDBInstance($dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port);
68 global $sessionlastvalueread;
69 global $sessionidfound;
71 $sql =
"SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX.
"session";
72 $sql .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
75 $resql = $dbsession->query($sql);
76 $num_rows = $dbsession->num_rows(
$resql);
79 $sessionlastvalueread =
'';
84 $obj = $dbsession->fetch_object(
$resql);
85 $sessionlastvalueread = $obj->session_variable;
86 $sessionidfound = $obj->session_id;
89 return $obj->session_variable;
104 global $sessionlastvalueread;
105 global $sessionidfound;
112 if ($sessionlastvalueread != $val) {
115 if (empty($sessionidfound)) {
117 $insert_query =
"INSERT INTO ".MAIN_DB_PREFIX.
"session";
118 $insert_query .=
"(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)";
119 $insert_query .=
" VALUES ('".$dbsession->escape($sess_id).
"', '".$dbsession->escape($val).
"', '".$dbsession->idate($time_stamp).
"', 0, '".$dbsession->escape(
getUserRemoteIP()).
"', '".$dbsession->escape(substr($_SERVER[
'HTTP_USER_AGENT'], 0, 255)).
"')";
121 $result = $dbsession->query($insert_query);
127 if ($sessionidfound != $sess_id) {
129 dol_print_error($dbsession,
'Oops sess_id received in dolSessionWrite differs from the cache value $sessionidfound. How can this happen ?');
152 $update_query =
"UPDATE ".MAIN_DB_PREFIX.
"session";
153 $update_query .=
" SET session_variable = '".$dbsession->escape($val).
"',";
154 $update_query .=
" last_accessed = '".$dbsession->idate($time_stamp).
"',";
155 $update_query .=
" remote_ip = '".$dbsession->escape(
getUserRemoteIP()).
"',";
156 $update_query .=
" user_agent = '".$dbsession->escape($_SERVER[
'HTTP_USER_AGENT']).
"'";
157 $update_query .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
159 $result = $dbsession->query($update_query);
198 $delete_query =
"DELETE FROM ".MAIN_DB_PREFIX.
"session";
199 $delete_query .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
200 $dbsession->query($delete_query);
218 $delete_query =
"DELETE FROM ".MAIN_DB_PREFIX.
"session";
219 $delete_query .=
" WHERE last_accessed < '".$dbsession->idate($time_stamp - $max_lifetime).
"'";
221 $resql = $dbsession->query($delete_query);
230 session_set_save_handler(
"dolSessionOpen",
"dolSessionClose",
"dolSessionRead",
"dolSessionWrite",
"dolSessionDestroy",
"dolSessionGC");
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_now($mode='auto')
Return date for now.
getUserRemoteIP()
Return the IP of remote user.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
dolSessionOpen($save_path, $session_name)
The session open handler called by PHP whenever a session is initialized.
dolSessionWrite($sess_id, $val)
This function is called when a session is initialized with a session_start( ) call,...
dolSessionDestroy($sess_id)
This is called whenever the session_destroy() function call is made.
dolSessionClose()
This function is executed on shutdown of the session.
dolSessionGC($max_lifetime)
This function is called on a session's start up with the probability specified in session....
dolSessionRead($sess_id)
This function is called whenever a session_start() call is made and reads the session variables.