本文整理匯總了PHP中Tool::isOk方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tool::isOk方法的具體用法?PHP Tool::isOk怎麽用?PHP Tool::isOk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tool
的用法示例。
在下文中一共展示了Tool::isOk方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: configureData
public function configureData()
{
if (!Tool::isOk($_POST['id']) || !($user = Model_User::getLoggedUser()) || $user->getId() != $_POST['id'] || !Tool::isOk($_POST['zip']) || !isset($_POST['gender']) || !Tool::isOk($_POST['login'])) {
header('Location: ' . Conf::get('ROOT_PATH'));
exit;
}
DB::update('UPDATE `user` SET
`zip`="' . $_POST['zip'] . '",
`male`="' . $_POST['gender'] . '"
WHERE `id`="' . $_POST['id'] . '"');
if (isset($_FILES) && isset($_FILES['avatar']) && $_FILES['avatar']['error'] != 4) {
$size = filesize($_FILES['avatar']['tmp_name']);
$stat = stat($_FILES['avatar']['tmp_name']);
if ($size[0] <= 1680 && $size[1] <= 1680 && $stat['size'] <= 450 * 1024) {
$extention = strtolower(preg_replace('#.+\\.([a-zA-Z]+)$#isU', '$1', $_FILES['avatar']['name']));
$original = Conf::get('MEDIA_DIR') . 'avatar/original/' . $_POST['id'] . '.' . $extention;
move_uploaded_file($_FILES['avatar']['tmp_name'], $original);
$sizeSmall = explode('x', Conf::get('AVATAR_SMALL_SIZE'));
$sizeMedium = explode('x', Conf::get('AVATAR_MEDIUM_SIZE'));
$sizeLarge = explode('x', Conf::get('AVATAR_LARGE_SIZE'));
Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_LARGE_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeLarge[0], isset($sizeLarge[1]) ? $sizeLarge[1] : false, true);
Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_MEDIUM_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeMedium[0], isset($sizeMedium[1]) ? $sizeMedium[1] : false, true);
Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_SMALL_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeSmall[0], isset($sizeSmall[1]) ? $sizeSmall[1] : false, true);
}
}
$_SESSION['feedback'] = 'Your informations has been updated';
header('Location: ' . Conf::get('ROOT_PATH') . $_POST['login']);
}
示例2: configureData
public function configureData()
{
header("Cache-Control: no-cache");
if (!($user = Model_User::getLoggedUser())) {
$_SESSION['warning'] = 'You need to be logged to vote';
echo 'register';
exit;
}
if (Tool::isOk($_POST['question'])) {
$question = new Model_Question($_POST['question']);
if (isset($_POST['answer'])) {
if ($_POST['answer'] == 0) {
if (Tool::isOk($_POST['vote']) && $_POST['vote'] == $user->getId()) {
// vote
$user->removeVote($question);
} else {
if (Tool::isOk($_POST['guess']) && $_POST['guess'] == $user->getId()) {
// guess
$user->removeGuess($question);
} else {
if (Tool::isOk($_POST['user']) && Tool::isOk($_POST['friend']) && $_POST['user'] == $user->getId()) {
// guess for friend
$user->removeGuessAboutFriend($question, new Model_User($_POST['friend']));
}
}
}
} else {
$answer = new Model_Answer($_POST['answer'], $_POST['question']);
if (Tool::isOk($_POST['vote']) && $_POST['vote'] == $user->getId()) {
// vote
$user->removeVote($question);
$user->vote($question, $answer);
} else {
if (Tool::isOk($_POST['guess']) && $_POST['guess'] == $user->getId()) {
// guess
$user->removeGuess($question);
$user->guess($question, $answer);
} else {
if (Tool::isOk($_POST['user']) && Tool::isOk($_POST['friend']) && $_POST['user'] == $user->getId()) {
// guess for friend
$friend = new Model_User($_POST['friend']);
$user->removeGuessAboutFriend($question, $friend);
$user->guessAboutFriend($question, $friend, $answer);
}
}
}
}
}
}
}
示例3: configure
public function configure()
{
if ($user = Model_User::getLoggedUser()) {
$this->tpl->assignVar(array('user_login' => $user->getLogin(), 'user_id' => $user->getId()));
$this->tpl->assignSection('logged');
} else {
$this->tpl->assignSection('notLogged');
}
// If a feedback should be displayed
if (Tool::isOk($_SESSION['feedback'])) {
$this->tpl->assignSection('feedback');
$this->tpl->assignVar('feedback', $_SESSION['feedback']);
unset($_SESSION['feedback']);
}
// If a warning should be displayed
if (Tool::isOk($_SESSION['warning'])) {
$this->tpl->assignSection('warning');
$this->tpl->assignVar('warning', $_SESSION['warning']);
unset($_SESSION['warning']);
}
}
示例4: configureData
public function configureData()
{
$top = new Block_Top($this->tpl);
$top->configure();
$id = $this->getParameter('u');
$key = $this->getParameter('k');
if (Tool::isOk($id) && Tool::isOk($key)) {
// If some user are connected
if ($user = Model_User::getLoggedUser()) {
$this->tpl->assignSection('confirm_ok');
} else {
if (Model_User::isKeyValid($id, $key)) {
Model_User::validateRegistration($id);
Model_User::login($id);
$this->tpl->assignSection('confirm_ok');
} else {
$this->tpl->assignSection('confirm_error');
}
}
} else {
$this->tpl->assignSection('confirm_wait');
}
}
示例5: configure
public function configure()
{
if ($user = Model_User::getLoggedUser()) {
Globals::$tpl->assignVar(array('user_login' => $user->getLogin(), 'user_id' => $user->getId(), 'user_avatarURL' => $user->getAvatarURL('medium')));
Globals::$tpl->assignSection('logged');
} else {
Globals::$tpl->assignVar(array('user_login' => '', 'user_id' => 0));
Globals::$tpl->assignSection('notLogged');
}
// If a feedback should be displayed
if (Tool::isOk($_SESSION['feedback'])) {
Globals::$tpl->assignSection('feedback');
Globals::$tpl->assignVar('feedback', $_SESSION['feedback']);
unset($_SESSION['feedback']);
}
// If a warning should be displayed
if (Tool::isOk($_SESSION['warning'])) {
Globals::$tpl->assignSection('warning');
Globals::$tpl->assignVar('warning', $_SESSION['warning']);
unset($_SESSION['warning']);
}
// Did you know ?
//$question = Model_Question::getRandomQuestion(); // USE THE METHOD FROM MODEL CATEGORY !
//$answers = $question->getAnswers();
//$didyouknow = $question->getDidyouknow();
//foreach ($answers as $key => $answer)
//{
//$didyouknow = str_replace('{PERCENT_' . ($key + 1) . '}', number_format($answer->getPercentResultsMatching($question->getId()), 1, ',', ' '), $didyouknow);
//}
//$tpl->assignVar(array
//(
//'didyouknow_label' => $didyouknow,
//'didyouknow_id' => $question->getId(),
//'didyouknow_guid' => Tool::makeGuid($question->getLabel()),
//));
}
示例6: logout
public static function logout($id)
{
if (isset($_SESSION['user'])) {
if (Tool::isOk($_COOKIE[Conf::get('SITE_NAME') . '_login'])) {
setcookie(Conf::get('SITE_NAME') . '_login', '', time() - 3600, '/');
}
unset($_SESSION['user']);
}
}
示例7: unset
<?php
// Logout user
if (isset($_SESSION['user'])) {
unset($_SESSION['user']);
if (Tool::isOk($_COOKIE[Conf::get('SITE_NAME') . '_login'])) {
setcookie(Conf::get('SITE_NAME') . '_login', '', time() - 3600, '/');
}
}
// Go back to home or to where I was
if (substr($_SERVER['HTTP_REFERER'], 0, strlen(Conf::get('ROOT_PATH'))) == Conf::get('ROOT_PATH')) {
header('Location: ' . $_SERVER['HTTP_REFERER']);
} else {
header('Location: ' . Conf::get('ROOT_PATH'));
}
示例8: getLoggedUser
public static function getLoggedUser()
{
// If a user is connected get its infos
if (Tool::isOk($_SESSION['user'])) {
return new Model_User($_SESSION['user']['id'], array('login' => $_SESSION['user']['login']));
} else {
if (Tool::isOk($_COOKIE[Conf::get('SITE_NAME') . '_login'])) {
// If the cookie's data matches
if (preg_match('/([0-9]+)-([a-z0-9]{32})/s', $_COOKIE[Conf::get('SITE_NAME') . '_login'], $matches)) {
if (Model_User::isKeyValid($matches[1], $matches[2])) {
$user = new Model_User($matches[1]);
$_SESSION['user'] = array('id' => $user->getId(), 'login' => $user->getLogin());
return $user;
}
}
setcookie(Conf::get('SITE_NAME') . '_login', '', time() - 3600);
}
}
return false;
}
示例9: header
<?php
if (!Tool::isOk($_POST['id']) || !Tool::isOk($_SESSION['user']) || $_SESSION['user']['id'] != $_POST['id'] || !Tool::isOk($_POST['old_password']) || !Tool::isOk($_POST['new_password'])) {
header('Location: ' . Conf::get('ROOT_PATH'));
exit;
}
$rs = DB::select('SELECT `id` FROM `user` WHERE `password`="' . md5($_POST['old_password']) . '"');
if ($rs['total'] == 0) {
$_SESSION['feedback'] = 'Your current password is not correct !';
} else {
$_SESSION['feedback'] = 'Password changed';
DB::update('UPDATE `user` SET
`password`="' . md5($_POST['new_password']) . '"
WHERE `id`="' . $_POST['id'] . '"');
}
header('Location: ' . Conf::get('ROOT_PATH') . $_POST['login']);