本文整理汇总了PHP中fURL::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP fURL::redirect方法的具体用法?PHP fURL::redirect怎么用?PHP fURL::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fURL
的用法示例。
在下文中一共展示了fURL::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
try {
$profileId = UserHelper::getProfileId();
$msg = new Msg();
$msg->setSender($profileId);
$msg->setContent(trim(fRequest::get('msg-content')));
$re = trim(fRequest::get('dest', 'integer'));
$x = new Profile($re);
$msg->setReceiver($re);
if (strlen($msg->getContent()) < 1) {
throw new fValidationException('信息长度不能少于1个字符');
}
if (strlen($msg->getContent()) > 140) {
throw new fValidationException('信息长度不能超过140个字符');
}
$msg->store();
//Activity::fireNewTweet();
fMessaging::create('success', 'create msg', '留言成功!');
} catch (fNotFoundException $e) {
fMessaging::create('failure', 'create msg', '该用户名不存在!');
} catch (fException $e) {
fMessaging::create('failure', 'create msg', $e->getMessage());
}
fURL::redirect(SITE_BASE . '/profile/' . $re . '/msgs');
}
示例2: ensureLogin
function ensureLogin()
{
global $user;
if (!isset($user)) {
fURL::redirect("/login.php?forward={$_SERVER['REQUEST_URI']}");
}
}
示例3: upload
/**
* Upload an image file for avatar
*/
public function upload()
{
try {
if (self::isImage($_FILES['avatar-file']) && move_uploaded_file($_FILES['avatar-file']['tmp_name'], $this->uploadfile)) {
fURL::redirect(SITE_BASE . '/avatar/edit');
} else {
throw new fValidationException('上传图片失败');
}
} catch (Exception $e) {
fMessaging::create('failure', 'upload avatar', $e->getMessage());
fURL::redirect(SITE_BASE . '/profile/' . UserHelper::getProfileId());
}
}
示例4: upload
public function upload()
{
$uploadfile = UPLOAD_DIR . basename($_FILES['userfile']['name']);
try {
if (self::validFile($uploadfile) && move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
fURL::redirect(SITE_BASE . '/manage');
} else {
throw new fValidationException('上传失败');
}
} catch (Exception $e) {
fMessaging::create('failure', 'upload file', $e->getMessage());
fURL::redirect(SITE_BASE . '/manage');
}
}
示例5: show
public function show($id)
{
$this->cache_control('private', 2);
try {
$this->record = new Record($id);
if (!$this->record->isReadable()) {
throw new fAuthorizationException('You are not allowed to read this record.');
}
$this->nav_class = 'status';
$this->render('record/show');
} catch (fExpectedException $e) {
fMessaging::create('warning', $e->getMessage());
fURL::redirect(Util::getReferer());
} catch (fUnexpectedException $e) {
fMessaging::create('error', $e->getMessage());
fURL::redirect(Util::getReferer());
}
}
示例6: reply
public function reply($id)
{
try {
$tweet = new Tweet($id);
$comment = new TweetComment();
$comment->setTweetId($tweet->getId());
$comment->setProfileId(UserHelper::getProfileId());
$comment->setContent(trim(fRequest::get('tweet-comment')));
if (strlen($comment->getContent()) < 1) {
throw new fValidationException('回复长度不能少于1个字符');
}
if (strlen($comment->getContent()) > 140) {
throw new fValidationException('回复长度不能超过140个字符');
}
$comment->store();
} catch (fException $e) {
// TODO
}
fURL::redirect(SITE_BASE . '/profile/' . $tweet->getProfileId() . '#tweet/' . $tweet->getId());
}
示例7: create
public function create()
{
try {
$profileId = UserHelper::getProfileId();
$mail = new Mail();
$mail->setSender($profileId);
$mail->setContent(trim(fRequest::get('mail-content')));
$re = trim(fRequest::get('dest'));
if (empty($re)) {
$re = trim(fRequest::get('destre', 'integer'));
$pa = trim(fRequest::get('parent', 'integer', -1));
$x = new Profile($re);
$mail->setReceiver($re);
$mail->setParent($pa);
} else {
//$receiver=fRecordSet::build('Profile',array('login_name=' => $re ),array())->getRecord(0);
$receiver = fRecordSet::build('Profile', array('login_name=' => $re), array());
if ($receiver->count()) {
$receiver = $receiver->getRecord(0);
} else {
throw new fNotFoundException('user doesn\'t exist');
}
$mail->setReceiver($receiver->getId());
}
if (strlen($mail->getContent()) < 1) {
throw new fValidationException('信息长度不能少于1个字符');
}
if (strlen($mail->getContent()) > 140) {
throw new fValidationException('信息长度不能超过140个字符');
}
$mail->store();
//Activity::fireNewTweet();
fMessaging::create('success', 'create mail', '信息发送成功!');
} catch (fNotFoundException $e) {
fMessaging::create('failure', 'create mail', '该用户名不存在,或该用户没有创建个人资料!');
} catch (fException $e) {
fMessaging::create('failure', 'create mail', $e->getMessage());
}
fURL::redirect(SITE_BASE . '/inbox');
}
示例8: show
public function show($id)
{
if (fAuthorization::checkLoggedIn()) {
$this->cache_control('private', 30);
} else {
$this->cache_control('private', 60);
}
try {
$this->problem = new Problem($id);
if ($this->problem->isSecretNow()) {
if (!User::can('view-any-problem')) {
throw new fAuthorizationException('Problem is secret now.');
}
}
$this->nav_class = 'problems';
$this->render('problem/show');
} catch (fExpectedException $e) {
fMessaging::create('warning', $e->getMessage());
fURL::redirect(Util::getReferer());
} catch (fUnexpectedException $e) {
fMessaging::create('error', $e->getMessage());
fURL::redirect(Util::getReferer());
}
}
示例9: array
<?php
$title = 'Project Storage';
require './header.php';
$cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid']));
if ($cards->count() == 0) {
fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']);
}
$card = $cards->getRecord(0);
$user = new User($card->getUserId());
$user->load();
if (isset($_POST['print'])) {
$project = new Project($_POST['print']);
$project->load();
if ($project->getUserId() != $user->getId()) {
print "Incorrect project ID";
exit;
}
$data = array('storage_id' => $project->getId(), 'name' => $project->getName(), 'ownername' => $user->getFullName(), 'more_info' => $project->getDescription(), 'completion_date' => $project->getToDate()->format('Y/m/d'), 'max_extention' => "14");
$data_string = json_encode($data);
$ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/dnh');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
$result = curl_exec($ch);
curl_close($ch);
echo "<p>Your sticker is being printed now.</p>";
}
$projects = fRecordSet::build('Project', array('state_id!=' => array('6', '7'), 'user_id=' => $user->getId()));
?>
示例10: redirectWithLoadedValues
/**
* Checks to see if any values (search or sort) were loaded from the session, and if so redirects the user to the current URL with those values added
*
* @return void
*/
public static function redirectWithLoadedValues()
{
// If values were reset, redirect to the plain URL
if (self::wasResetRequested()) {
fURL::redirect(fURL::get() . fURL::removeFromQueryString('reset'));
}
$query_string = fURL::replaceInQueryString(array_keys(self::$loaded_values), array_values(self::$loaded_values));
$url = fURL::get() . $query_string;
if ($url != fURL::getWithQueryString() && $url != fURL::getWithQueryString() . '?') {
fURL::redirect($url);
}
}
示例11: foreach
foreach ($subscriptions as $sub) {
$user_id = $sub['user_id'];
if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) {
$user = new User($sub['user_id']);
$recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername());
}
}
if (!empty($recipients)) {
// Send the mail to everybody
notify_multiple_users($user_session, $recipients, $subject_mail, $content_mail);
fMessaging::create('success', fURL::get(), 'The mail "' . $subject_mail . '" was successfully sent to all the users who subscribe to "' . $check->getName() . '"');
} else {
fMessaging::create('error', fURL::get(), "Nobody subscribe to this check");
}
}
}
} catch (fNotFoundException $e) {
fMessaging::create('error', $manage_url, 'The check requested, ' . fHTML::encode($check_id) . ', could not be found');
fURL::redirect($manage_url);
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
$page_num = fRequest::get('page', 'int', 1);
$url_redirect = CheckResult::makeURL('list', $check) . "&page=" . $page_num;
fURL::redirect($url_redirect);
} else {
$page_num = fRequest::get('page', 'int', 1);
$check_results = CheckResult::findAll($check_id, false, $GLOBALS['PAGE_SIZE'], $page_num);
include VIEW_PATH . '/list_check_results.php';
}
}
示例12: overrideAction
/**
* Overrides the value of `'action'` in the `DELETE`/`PUT` post data, `$_POST` or `$_GET` superglobals based on the `'action::{action_name}'` value
*
* This method is primarily intended to be used for hanlding multiple
* submit buttons.
*
* @param string $redirect The url to redirect to if the action is overriden. `%action%` will be replaced with the overridden action.
* @return void
*/
public static function overrideAction($redirect = NULL)
{
self::initPutDelete();
$found = FALSE;
$globals = array(&$_GET, &$_POST, &self::$put_delete);
foreach ($globals as &$global) {
foreach ($global as $key => $value) {
if (substr($key, 0, 8) == 'action::') {
$found = (bool) ($global['action'] = substr($key, 8));
unset($global[$key]);
}
}
}
if ($redirect && $found) {
fURL::redirect(str_replace('%action%', $found, $redirect));
}
}
示例13: catch
try {
$user->populate();
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e - getMessage());
}
}
include VIEW_PATH . '/add_edit_user_settings.php';
} elseif ('delete' == $action) {
try {
$user = new User($user_id);
if (fRequest::isPost()) {
fRequest::validateCSRFToken(fRequest::get('token'));
$user->delete();
fMessaging::create('success', User::makeUrl('edit', $user), 'The user ' . $user->getName() . ' was successfully deleted');
fURL::redirect(User::makeUrl('edit', $user));
}
} catch (fNotFoundException $e) {
fMessaging::create('error', User::makeUrl('edit', $user), 'The line requested could not be found');
fURL::redirect(User::makeUrl('edit', $user));
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
include VIEW_PATH . '/delete.php';
} else {
if (!fAuthorization::checkAuthLevel('admin')) {
fURL::redirect(User::makeURL('edit', fSession::get('user_id')));
} else {
$users = User::findAll();
include VIEW_PATH . '/list_users.php';
}
}
示例14: Card
$page = 'cards';
$title = 'Add card';
$desc = '';
require '../header.php';
if (!isset($user)) {
fURL::redirect('/login.php?forward=/members/cards.php');
}
if (isset($_POST['submit'])) {
try {
fRequest::validateCSRFToken($_POST['token']);
$card = new Card();
$card->setUserId($user->getId());
$card->setAddedDate(time());
$card->setUid($_POST['uid']);
$card->store();
fURL::redirect('/members/cards.php');
exit;
} catch (fValidationException $e) {
echo "<p>" . $e->printMessage() . "</p>";
} catch (fSQLException $e) {
echo "<p>An unexpected error occurred, please try again later</p>";
trigger_error($e);
}
}
?>
<h2>Add card</h2>
<form method="POST">
<input type="hidden" name="token" value="<?php
echo fRequest::generateCSRFToken();
?>
示例15: Consumable
// Get objects matching the printer/consumable
$consumable = new Consumable($consumable_id);
// Update cost if present
if ($cost) {
$consumable->setCost($cost);
$consumable->store();
}
// Update consumable
$updated = $consumable->increaseStockBy($qty);
#die(var_export($updated));
// Check status of installation
if ($updated == FALSE) {
fMessaging::create('error', $redirect, $consumable->err);
fURL::redirect($redirect);
} else {
fMessaging::create('success', $redirect, sprintf('The consumable stock for %s has been updated.', $consumable->getName()));
fURL::redirect($redirect);
}
} catch (fNotFoundException $e) {
fMessaging::create('error', $redirect, 'The requested object with ID ' . $id . ', could not be found.');
fURL::redirect($redirect);
}
} else {
// Get consumable object from ID
if ($consumable_id != NULL) {
$c = Consumable::getOne($consumable_id);
}
// No POSTed data, show form (based on request method)
$view = fRequest::isAjax() ? 'ajax.php' : 'simple.php';
include 'views/stock/' . $view;
}