/** * * Saves changes to session, user objects and sends asynchronous request for search indexing * You should call this at the end of every request to ensure that user and session variables are saved. * * @access public */ function close() { $this->session->close(); if (is_object($this->user)) { $this->user->close(); } if (defined('__CA_SITE_HOSTNAME__') && strlen(__CA_SITE_HOSTNAME__) > 0) { if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']) { $vn_port = $_SERVER['SERVER_PORT']; } else { $vn_port = 80; } if ($vn_port == 443) { $vs_proto = 'tls://'; } else { $vs_proto = 'tcp://'; } // trigger async search indexing if (!$this->getAppConfig()->get('disable_out_of_process_search_indexing')) { $r_socket = fsockopen($vs_proto . __CA_SITE_HOSTNAME__, $vn_port, $errno, $err, 3); if ($r_socket) { $vs_http = "GET " . $this->getBaseUrlPath() . "/index.php?processIndexingQueue=1 HTTP/1.1\r\n"; $vs_http .= "Host: " . __CA_SITE_HOSTNAME__ . "\r\n"; $vs_http .= "Connection: Close\r\n\r\n"; fwrite($r_socket, $vs_http); fclose($r_socket); } } } }
/** * This file is a part of MyWebSQL package * * @file: modules/download.php * @author Samnan ur Rehman * @copyright (c) 2008-2012 Samnan ur Rehman * @web http://mywebsql.net * @license http://mywebsql.net/license */ function processRequest(&$db) { if (!ini_get('safe_mode')) { set_time_limit(0); } Session::close(); switch ($_REQUEST['id']) { case 'backup': include_once BASE_PATH . "/config/backups.php"; $compression = v($_REQUEST['compression']); $file = get_backup_filename($compression); include_once BASE_PATH . "/lib/output.php"; $output = new Output($file, $compression); $message = '<div class="message ui-state-highlight">' . __('Database backup successfully created') . '</div>'; if ($output->is_valid()) { downloadDatabase($db, false); $output->end(); } else { $message = '<div class="error ui-state-highlight">' . __('Failed to create database backup') . '</div>'; } echo view('backup', array('MESSAGE' => $message), $db->getObjectList()); break; case 'exportres': downloadResults($db); break; case 'exporttbl': downloadTable($db, $_REQUEST['name']); break; case 'export': downloadDatabase($db); break; } }
/** * Test expiration of namespaces and namespace variables. * @return void */ public function testSetExpiration() { // try to expire whole namespace $s = $this->session->getNamespace('expire'); $s->a = 'apple'; $s->p = 'pear'; $s['o'] = 'orange'; $s->setExpiration('+ 5 seconds'); $this->session->close(); sleep(6); $this->session->start(); $s = $this->session->getNamespace('expire'); $result = $this->serialize($s->getIterator()); $this->assertEquals('', $result, 'iteration over named Session namespace failed'); // try to expire only 1 of the keys $s = $this->session->getNamespace('expireSingle'); $s->setExpiration(5, 'g'); $s->g = 'guava'; $s->p = 'plum'; $this->session->close(); sleep(6); $this->session->start(); $s = $this->session->getNamespace('expireSingle'); $result = $this->serialize($s->getIterator()); $this->assertEquals('p=plum;', $result, 'iteration over named Session namespace failed'); }
/** * * Saves changes to session and user objects. You should call this at the end of every request to ensure * that user and session variables are saved. * * @access public * @return float Seconds elapsed since request started. */ function close() { $this->session->close(); if (is_object($this->user)) { $this->user->close(); } }
private function getJSON(&$aRequest) { if ($this->sAction === 'destroy') { foreach ($aRequest['session_key'] as $sSessionKey) { Session::getSession()->setArrayAttributeValueForKey(WidgetModule::WIDGET_SESSION_KEY, $sSessionKey, null); } return; } $sWidgetClass = WidgetModule::getClassNameByName($this->sWidgetType); $bIsPersistent = $sWidgetClass::isPersistent(); if (!$bIsPersistent) { // Close session early on readonly calls Session::close(); } if ($this->sAction == 'widgetInformation') { $aInformation = array(); $sWidgetClass::includeResources(); $aInformation['resources'] = ResourceIncluder::defaultIncluder()->getIncludes()->render(); $aInformation['methods'] = $sWidgetClass::getCustomMethods(); $aInformation['is_singleton'] = $sWidgetClass::isSingleton(); $aInformation['is_persistent'] = $bIsPersistent; return $aInformation; } if ($this->sAction == 'staticMethodCall') { $this->checkPermissions($sWidgetClass); $sMethodName = isset($aRequest['method']) ? $aRequest['method'] : Manager::usePath(); if (!method_exists($sWidgetClass, $sMethodName)) { throw new LocalizedException('wns.file.widget_json.method_does_not_exist', array('method' => $sMethodName, 'widget' => $sWidgetClass)); } return array("result" => call_user_func_array(array($sWidgetClass, $sMethodName), isset($aRequest['method_parameters']) ? $aRequest['method_parameters'] : array())); } $aInstanceArgs = array(@$aRequest['session_key']); if (isset($aRequest['instance_args'])) { $aInstanceArgs = $aRequest['instance_args']; } $aNewArgs = array_merge(array($this->sWidgetType), $aInstanceArgs); $oWidget = call_user_func_array(array('WidgetModule', 'getWidget'), $aNewArgs); if ($this->sAction === 'instanciateWidget') { $this->checkPermissions($sWidgetClass); $aInformation = array(); $aInformation['session_id'] = $oWidget->getSessionKey(); $oWidgetContents = $oWidget->doWidget(); if ($oWidgetContents instanceof Template) { $oWidgetContents = $oWidgetContents->render(); } $aInformation['content'] = $oWidgetContents; $aInformation['is_new'] = $oWidget->isNew(); $aInformation['initial_settings'] = $oWidget->allSettings(); return $aInformation; } if ($this->sAction === 'methodCall') { $this->checkPermissions($sWidgetClass); $sMethodName = isset($aRequest['method']) ? $aRequest['method'] : Manager::usePath(); if (!method_exists($oWidget, $sMethodName)) { throw new LocalizedException('wns.file.widget_json.method_does_not_exist', array('method' => $sMethodName, 'widget' => $oWidget->getName())); } return array("result" => call_user_func_array(array($oWidget, $sMethodName), isset($aRequest['method_parameters']) ? $aRequest['method_parameters'] : array())); } }
/** * This file is a part of MyWebSQL package * * @file: modules/import.php * @author Samnan ur Rehman * @copyright (c) 2008-2014 Samnan ur Rehman * @web http://mywebsql.net * @license http://mywebsql.net/license */ function processRequest(&$db) { $importDone = FALSE; $message = ''; $refresh = '0'; $max_upload_size = min(bytes_value(ini_get('post_max_size')), bytes_value(ini_get('upload_max_filesize'))) / 1024; $max_upload_size_text = $max_upload_size < 1024 ? $max_upload_size . 'KB' : $max_upload_size / 1024 . ' MB'; if (isset($_FILES['impfile'])) { if (v($_FILES['impfile']['tmp_name']) != '' && file_exists($_FILES['impfile']['tmp_name'])) { include BASE_PATH . "/lib/sqlparser.php"; $parser = new sqlParser($db); $parser->stopOnError(v($_REQUEST['ignore_errors']) == 'yes' ? FALSE : TRUE); //$parser->setCallback( 'report_progress', $module_id ); //$parser->collectStats(v($_REQUEST['stats']) == 'yes'); Session::close(); $result = $parser->parse($_FILES['impfile']['tmp_name'], $_FILES['impfile']['size'], $_FILES['impfile']['name']); $executed = $parser->getExecutedQueries(); $failed = $parser->getFailedQueries(); if (!$result || $executed > 0 || $failed > 0) { $message .= '<div class="message ui-state-default">' . str_replace('{{NUM}}', $executed, __('{{NUM}} queries successfully executed')); $message .= '<br />[ ' . str_replace('{{NUM}}', $parser->getRowsAffected(), __('{{NUM}} record(s) were affected')) . '. ]</div>'; if ($failed > 0) { $message_tmp = $failed > 1 ? str_replace('{{NUM}}', $failed, __('{{NUM}} queries failed to execute')) : __('Error occurred while executing the query'); $message .= '<div class="message ui-state-error">' . $message_tmp . '</div>'; if ($failed == 1) { $message .= '<div class="message ui-state-highlight">' . htmlspecialchars($parser->getError()) . '</div>'; $message .= '<div class="sql-text ui-state-error">' . htmlspecialchars($parser->getLastQuery()) . '</div>'; } } } else { $message .= '<div class="message ui-state-default">' . __('No queries were executed during import') . '.</div>'; } } else { $message .= '<div class="message ui-state-error">' . __('File upload failed. Please try again') . '.</div>'; } $importDone = TRUE; } if (!$importDone) { $message = '<div class="message ui-state-default">' . str_replace('{{SIZE}}', $max_upload_size_text, __('Maximum upload filesize is {{SIZE}}')); $message .= '<br/>' . str_replace('{{LIST}}', valid_import_files(), __('Supported filetypes / extensions are: ({{LIST}})')) . '</div>'; } else { $refresh = '1'; } $replace = array('MESSAGE' => $message, 'MAX_SIZE' => $max_upload_size, 'REFRESH' => $refresh); echo view('import', $replace, array('progress' => phpCheck(5.4))); }
public function __construct($aRequestPath) { parent::__construct($aRequestPath); if (!isset($this->aPath[0])) { // Exceptions thrown in a file module’s constructor yield a UserError but that’s OK. throw new Exception("Error in DisplayDocumentFileModule->__construct: no key given"); } $this->oSession = Session::close(); $this->oDocument = DocumentQuery::create()->findPk(intval($this->aPath[0])); if ($this->oDocument === null || $this->oDocument->getIsProtected() && !$this->isAuthenticated()) { $oErrorPage = PageQuery::create()->findOneByName(Settings::getSetting('error_pages', 'not_found', 'error_404')); if ($oErrorPage) { LinkUtil::redirect(LinkUtil::link($oErrorPage->getLinkArray(), "FrontendManager")); } else { print "Not found"; exit; } } Session::close(); }
public static function init() { if (defined('CURRENTLY_INSTALLING')) { return; } if (!is_file(EDUCASK_ROOT . '/site/config.xml')) { header('Location: ' . EDUCASK_WEB_ROOT . '/install.php'); exit; } if (is_readable(EDUCASK_ROOT . '/update.php')) { header('Location: ' . EDUCASK_WEB_ROOT . '/update.php'); exit; } self::registerAutoloader(); self::connectDatabase(); Session::start(); self::initializePlugins(); self::getVariables(); self::cron(); Router::moveCurrentParametersToPrevious(); Session::close(); Database::getInstance()->bootstrapDisconnect(); ObjectCache::saveInstance(); }
protected function loginUser() { if ($id = Application::param('user_id')) { Session::close(); Application::appInit(); $user_class = constant('SYSTEM_USER'); $user = new $user_class(); $user->clauseSafe('user_id', $id); $user->read(); Application::current()->setUser($user); SiteNavigation::init($user->getHandlerTree()); } }
break; } } // -------------------------------------------------------------- // Route the request and get the response from the route. // -------------------------------------------------------------- if (is_null($response)) { $route = Routing\Router::make(Request::method(), Request::uri(), new Routing\Loader(ACTIVE_MODULE_PATH))->route(); $response = is_null($route) ? Response::error('404') : $route->call(); } $response = Response::prepare($response); // -------------------------------------------------------------- // Call the "after" filter for the application and module. // -------------------------------------------------------------- foreach (array(ACTIVE_MODULE . '::after', 'after') as $filter) { Routing\Filter::call($filter, array($response, Request::method(), Request::uri())); } // -------------------------------------------------------------- // Stringify the response. // -------------------------------------------------------------- $response->content = (string) $response->content; // -------------------------------------------------------------- // Close the session. // -------------------------------------------------------------- if (Config::get('session.driver') != '') { Session::close(); } // -------------------------------------------------------------- // Send the response to the browser. // -------------------------------------------------------------- $response->send();
foreach ($plugins as $plugin_name) { if (is_readable(LIB_DIR . '/plugins/' . $plugin_name . '.php')) { require LIB_DIR . '/plugins/' . $plugin_name . '.php'; } } } $res = $LMS->ExecHook('access_table_init', array('accesstable' => $access['table'])); if (isset($res['accesstable'])) { $access['table'] = $res['accesstable']; } LMSConfig::getConfig(array('force' => true, 'force_user_rights_only' => true, 'access_table' => $access['table'], 'user_id' => $AUTH->id)); $module = isset($_GET['m']) ? preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['m']) : ''; $deny = $allow = FALSE; $res = $LMS->ExecHook('module_load_before', array('module' => $module)); if ($res['abort']) { $SESSION->close(); $DB->Destroy(); die; } $module = $res['module']; if ($AUTH->passwdrequiredchange) { $module = 'chpasswd'; } if ($module == '') { $module = ConfigHelper::getConfig('phpui.default_module'); } if (file_exists(MODULES_DIR . '/' . $module . '.php')) { $global_allow = !$AUTH->id || !empty($access['allow']) && preg_match('/' . $access['allow'] . '/i', $module); if ($AUTH->id && ($rights = $LMS->GetUserRights($AUTH->id))) { foreach ($rights as $level) { if (!$global_allow && !$deny && isset($access['table'][$level]['deny_reg'])) {
function processError($num_err, $mens_err, $nombre_archivo, $num_linea, $vars) { // conjunto de errores de los cuales se almacenara un rastreo $errores_de_usuario = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); if (in_array($num_err, $errores_de_usuario)) { // marca de fecha/hora para el registro de error $dt = date('Y-m-d H:i:s (T)'); // definir una matriz asociativa de cadenas de error // en realidad las unicas entradas que deberiamos // considerar son E_WARNING, E_NOTICE, E_USER_ERROR, // E_USER_WARNING y E_USER_NOTICE $tipo_error = array(E_ERROR => 'Error', E_WARNING => 'Advertencia', E_PARSE => 'Error de Intérprete', E_NOTICE => 'Anotación', E_CORE_ERROR => 'Error de Núcleo', E_CORE_WARNING => 'Advertencia de Núcleo', E_COMPILE_ERROR => 'Error de Compilación', E_COMPILE_WARNING => 'Advertencia de Compilacón', E_USER_ERROR => 'Error de Usuario', E_USER_WARNING => 'Advertencia de Usuario', E_USER_NOTICE => 'Anotación de Usuario'); $err = "<errorentry>\n"; $err .= "\t<datetime>" . $dt . "</datetime>\n"; $err .= "\t<errornum>" . $num_err . "</errornum>\n"; $err .= "\t<errortype>" . $tipo_error[$num_err] . "</errortype>\n"; $err .= "\t<errormsg>" . $mens_err . "</errormsg>\n"; if (!empty($nombre_archivo)) { $err .= "\t<scriptname>" . $nombre_archivo . "</scriptname>\n"; } if (!empty($num_linea)) { $err .= "\t<scriptlinenum>" . $num_linea . "</scriptlinenum>\n"; } //if (in_array($num_err, $errores_de_usuario)){ // $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n"; //} $err .= "</errorentry>\n\n"; // guardar en el registro de errores, y enviar un correo error_log($err, 3, MIGUELBASE_ERRORLOG_FILE); //)mail("*****@*****.**", "Error Critico de Usuario en miguel", $err); if ($num_err != E_USER_ERROR) { include_once Util::app_Path('error/control/classes/miguel_cerror.class.php'); $obj_error = new miguel_CError($tipo_error[$num_err], $mens_err); $obj_error->Exec(); } else { $err = "\n"; $err .= "\tdatetime: " . $dt . "\n"; $err .= "\terrornum: " . $num_err . "\n"; $err .= "\terrortype: " . $tipo_error[$num_err] . "\n"; $err .= "\terrormsg: " . $mens_err . "\n"; if (!empty($nombre_archivo)) { $err .= "\tscriptname: " . $nombre_archivo . "\n"; } if (!empty($num_linea)) { $err .= "\tscriptlinenum: " . $num_linea . "\n"; } echo '<h1>Error Fatal</h1><br>'; echo '<pre>' . $err . '</pre><br>'; echo '<h3>Consulte con el administrador</h3><br>'; Session::close(); die; } } }
/** * Cierra el controlador, borrando contenidos y liberando recursos * */ function Close(&$obj_model) { //Log de salida include_once Util::app_Path("common/control/classes/miguel_userinfo.class.php"); $ok = miguel_UserInfo::setLogin($obj_model, $this->getSessionElement('userinfo', 'user_alias'), false); //Borramos menu_item.js $filename = Session::getValue('menufile'); $menuFile = Util::formatPath(MIGUELBASE_CACHE_DIR . '/' . $filename); if (file_exists($menuFile)) { File::Delete($menuFile); } //Cerramos modelo $obj_model->closeDDBB(); //Damos de baja en el registro el mÛdulo. $this->registry->popApp(); //Cerrando la sesiÛn, se cierra el contexto. Session::close(); $this->arr_form = array(); }
/** * Redirects the user to the specified URL. * * @param string $url * @throws Exception * @api */ public static function redirectToUrl($url) { // Close the session manually. // We should not have to call this because it was registered via register_shutdown_function, // but it is not always called fast enough Session::close(); self::redirectToUrlNoExit($url); exit; }
public static function logout() { Session::close(); Application::appInit(); }
/** * Redirects to the given path and stops execution. * @param string $path The path to redirect to. */ private static function redirectToPath($path) { if (headers_sent()) { return; } Session::close(); header('Status: 303 See Other'); header('Location: ' . $path, true, 303); exit; }
/** * Attempt to log in using the given username and password. * * On a successful login, this function should return the users attributes. On failure, * it should throw an exception. If the error was caused by the user entering the wrong * username or password, a SimpleSAML_Error_Error('WRONGUSERPASS') should be thrown. * * Note that both the username and the password are UTF-8 encoded. * * @param string $username The username the user wrote. * @param string $password The password the user wrote. * @param string $organization The id of the organization the user chose. * @return array Associative array with the users attributes. */ protected function login($username, $password, $organization) { assert('is_string($username)'); assert('is_string($password)'); assert('is_string($organization)'); if ($organization != '') { //$organization contient le numéro de rne setcookie('RNE', $organization, null, '/'); } $path = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))); require_once("$path/secure/connect.inc.php"); // Database connection require_once("$path/lib/mysql.inc"); require_once("$path/lib/mysqli.inc.php"); require_once("$path/lib/settings.inc"); require_once("$path/lib/settings.inc.php"); require_once("$path/lib/old_mysql_result.php"); // Load settings if (!loadSettings()) { die("Erreur chargement settings"); } // Global configuration file require_once("$path/lib/global.inc.php"); // Libraries include "$path/lib/share.inc.php"; // Session related functions require_once("$path/lib/Session.class.php"); $session_gepi = new Session(); # L'instance de Session permettant de gérer directement les authentifications # SSO, on ne s'embête pas : $auth = $session_gepi->authenticate_gepi($username, $password); if ($auth != "1") { # Echec d'authentification. $session_gepi->record_failed_login($username); session_write_close(); SimpleSAML_Logger::error('gepiauth:' . $this->authId . ': not authenticated. Probably wrong username/password.'); throw new SimpleSAML_Error_Error('WRONGUSERPASS'); } SimpleSAML_Logger::info('gepiauth:' . $this->authId . ': authenticated'); # On interroge la base de données pour récupérer des attributs qu'on va retourner $query = mysqli_query($GLOBALS["mysqli"], "SELECT nom, prenom, email, statut FROM utilisateurs WHERE (login = '******')"); $row = mysqli_fetch_object($query); //on vérifie le status if ($this->requiredStatut != null) { if ($this->requiredStatut != $row->statut) { # Echec d'authentification pour ce statut $session_gepi->close('2'); session_write_close(); SimpleSAML_Logger::error('gepiauth:' . $this->authId . ': not authenticated. Statut is wrong.'); throw new SimpleSAML_Error_Error('WRONGUSERPASS'); } } $attributes = array(); $attributes['login_gepi'] = array($username); $attributes['nom'] = array($row->nom); $attributes['prenom'] = array($row->prenom); $attributes['statut'] = array($row->statut); $attributes['email'] = array($row->email); $sql = "SELECT id_matiere FROM j_professeurs_matieres WHERE (id_professeur = '" . $username . "') ORDER BY ordre_matieres LIMIT 1"; $matiere_principale = sql_query1($sql); $attributes['matieres'] = array($matiere_principale); SimpleSAML_Logger::info('gepiauth:' . $this->authId . ': Attributes: ' . implode(',', array_keys($attributes))); return $attributes; }
/** * Close function, this works like a destructor in classes and is executed when the session operation is done. * * @depends testSessionOpen */ public function testSessionClose() { Session::close(); }
public function close() { session_write_close(); parent::close(); }
/** * Wait for worker to finish task */ function waitWorker($sleeptime = 1) { if ($_SESSION['w_active'] == 1) { logWorker('[client] waiting for worker'); $wait = 0; do { sleep($sleeptime); if (++$wait % 5 === 0) { logWorker(sprintf('[client] waitWorker (%d)', $wait)); } Session::open(); Session::close(); } while ($_SESSION['w_active'] == 1); logWorker('[client] worker finished'); } }
/* * This example shows how new documents can be added. * * Documentation: http://docs.basex.org/wiki/Clients * * (C) BaseX Team 2005-12, BSD License */ include "BaseXClient.php"; try { // create session $session = new Session("localhost", 1984, "admin", "admin"); // create new database $session->execute("create db database"); print $session->info(); // add document $session->add("world/World.xml", "<x>Hello World!</x>"); print "<br/>" . $session->info(); // add document $session->add("Universe.xml", "<x>Hello Universe!</x>"); print "<br/>" . $session->info(); // run query on database print "<br/>" . $session->execute("xquery /"); // drop database $session->execute("drop db database"); // close session $session->close(); } catch (Exception $e) { // print exception print $e->getMessage(); }
public static function close__open_new__init($memo_GET) { Session::close(); Session::open_new(); Session::init(); $_SESSION['MEMO_GET'] = ( $memo_GET && !empty($_GET) ) ? $_GET : NULL ; }