本文整理匯總了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'])];
}