本文整理汇总了PHP中Sql::setUniqueUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::setUniqueUrl方法的具体用法?PHP Sql::setUniqueUrl怎么用?PHP Sql::setUniqueUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql::setUniqueUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public static function login()
{
if (isset($_POST['email'])) {
$mysqli = DB::getInstance();
$usernameClean = $mysqli->real_escape_string($_POST['email']);
$passwordClean = $mysqli->real_escape_string($_POST['password']);
$password = crypt($passwordClean, '$2a$' . sha1($usernameClean));
$user = Sql::logIn($usernameClean, $password);
//Om inloggning lyckas sparas user id och role in i session
if ($user['id']) {
$_SESSION['user']['id'] = $user['id'];
$_SESSION['user']['role'] = $user['role'];
Sql::getUserPermission($_SESSION['user']['id']);
Sql::setUniqueUrl($_SESSION['user']['id']);
//Role == 1 innebär Admin
if ($user['role'] == 1) {
return ['redirect' => "?/Admin/adminDash"];
}
return ['redirect' => "?/wishList/myList"];
} else {
return ['redirect' => "?/"];
}
}
return [];
}
示例2: adminDash
public static function adminDash()
{
//Sätts för att andra funtioner ska kunna byggas till. Överflödig i dagsläget.
Sql::setUniqueUrl($_SESSION['user']['id']);
$dashboard = Sql::getDashboard();
// Räknar om värden från databasen till en procentsats som sedan läggs in i return arrayen
foreach ($dashboard['permissions'] as $permission => $value) {
foreach ($value as $key => $val) {
if ($key == 'number_of_permissions') {
$val = round($val / $dashboard['customers']['customers'] * 100);
$percent[] = $val;
}
}
}
return ['users' => $dashboard['users'], 'lists' => $dashboard['lists'], 'customers' => $dashboard['customers'], 'percent' => $percent, 'categories' => Sql::category(), 'imageUrl' => Sql::getListImage($_SESSION['uniqueUrl'])];
}