本文整理汇总了PHP中SessionUtils::getUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionUtils::getUserId方法的具体用法?PHP SessionUtils::getUserId怎么用?PHP SessionUtils::getUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionUtils
的用法示例。
在下文中一共展示了SessionUtils::getUserId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session_start
VPN is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
VPN is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VPN. If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
require_once "config/database.php";
require_once "engine/utils/SessionUtils.php";
require_once "engine/bo/VpnBo.php";
require_once "engine/bo/VpnServerBo.php";
$accountId = SessionUtils::getUserId($_SESSION);
$connection = openConnection();
$logs = array();
if ($accountId) {
$vpnBo = VpnBo::newInstance($connection);
$vpns = $vpnBo->getVpns(array("with_account" => 1, "with_servers" => 1, "vpn_account_id" => $accountId));
if (count($vpns) != 0) {
$logs = $vpnBo->getLogs($vpns);
}
}
$vpnServerBo = VpnServerBo::newInstance($connection);
$servers = $vpnServerBo->getLogs();
echo json_encode(array("ok" => "ok", "logs" => $logs, "servers" => $servers));
示例2: isset
$remoteIp = isset($_SERVER["HTTP_X_REAL_IP"]) && $_SERVER["HTTP_X_REAL_IP"] ? $_SERVER["HTTP_X_REAL_IP"] : $_SERVER["REMOTE_ADDR"];
$connection = openConnection();
$accountBo = AccountBo::newInstance($connection);
//$logActionBo = LogActionBo::newInstance(openConnection());
// $numberOfFails = $logActionBo->getNumberOfFails($remoteIp, 600);
// if ($numberOfFails > 2) {
// echo json_encode(array("ko" => "ko", "message" => "error_login_ban"));
// exit;
// }
//print_r($_REQUEST);
$data = array();
if ($accountBo->login($login, $password, $_SESSION)) {
$data["ok"] = "ok";
if ($rememberMe) {
setcookie("userId", SessionUtils::getUserId($_SESSION), time() + 60 * 60 * 24 * 30);
setcookie("userCode", hash("sha512", SessionUtils::getUserId($_SESSION) . $config["salt"], false), time() + 60 * 60 * 24 * 30);
}
} else {
$data["ko"] = "ko";
$data["message"] = "error_login_bad";
// $numberOfFails = $logActionBo->getNumberOfFails($remoteIp, 600);
// if ($numberOfFails > 2) {
// echo json_encode(array("ko" => "ko", "message" => "error_login_ban"));
// exit;
// }
}
// $logAction = array();
// $logAction["lac_status"] = isset($data["ok"]) ? 1 : 0;
// $logAction["lac_label"] = "login";
// $logAction["lac_login"] = $login;
// $logAction["lac_ip"] = $remoteIp;