本文整理汇总了PHP中fURL类的典型用法代码示例。如果您正苦于以下问题:PHP fURL类的具体用法?PHP fURL怎么用?PHP fURL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fURL类的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: email_plugin_notify
function email_plugin_notify($check,$check_result,$subscription,$alt_email=false) {
global $status_array;
$user = new User($subscription->getUserId());
$email = new fEmail();
// This sets up fSMTP to connect to the gmail SMTP server
// with a 5 second timeout. Gmail requires a secure connection.
$smtp = new fSMTP(sys_var('smtp_server'), sys_var('smtp_port'), TRUE, 5);
$smtp->authenticate(sys_var('smtp_user'), sys_var('smtp_pass'));
if ($alt_email) {
$email_address = usr_var('alt_email',$user->getUserId());
} else {
$email_address = $user->getEmail();
}
$email->addRecipient($email_address, $user->getUsername());
// Set who the email is from
$email->setFromEmail(sys_var('email_from'), sys_var('email_from_display'));
// Set the subject include UTF-8 curly quotes
$email->setSubject(str_replace('{check_name}', $check->prepareName(), sys_var('email_subject')));
// Set the body to include a string containing UTF-8
$state = $status_array[$check_result->getStatus()];
$email->setHTMLBody("<p>$state Alert for {$check->prepareName()} </p><p>The check returned {$check_result->prepareValue()}</p><p>Warning Threshold is : ". $check->getWarn() . "</p><p>Error Threshold is : ". $check->getError() . '</p><p>View Alert Details : <a href="' . fURL::getDomain() . '/' . CheckResult::makeURL('list',$check_result) . '">'.$check->prepareName()."</a></p>");
$email->setBody("
$state Alert for {$check->prepareName()}
The check returned {$check_result->prepareValue()}
Warning Threshold is : ". $check->getWarn() . "
Error Threshold is : ". $check->getError() . "
");
try {
$message_id = $email->send($smtp);
} catch ( fConnectivityException $e) {
fCore::debug("email send failed",FALSE);
}
}
示例3: ensureLogin
function ensureLogin()
{
global $user;
if (!isset($user)) {
fURL::redirect("/login.php?forward={$_SERVER['REQUEST_URI']}");
}
}
示例4: 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());
}
}
示例5: 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');
}
}
示例6: 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());
}
}
示例7: 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());
}
示例8: 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');
}
示例9: 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());
}
}
示例10: 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()));
?>
示例11: htmlspecialchars
if ($newStatus != $project->getState() && $project->canTransitionStates($project->getState(), $newStatus)) {
$project->setState($newStatus);
$project->store();
if ($reason != '') {
$reason = ' with the reason \'' . $reason . "'";
}
// log the update
$project->submitLog('Status changed to ' . $project->getState() . $reason, $user->getId());
if ($project->getState() != 'Archived') {
// send to mailing list
$project->submitMailingList('Status changed to ' . $project->getState() . $reason . " by " . htmlspecialchars($user->getFullName()));
// inform the owner
$project->submitEmailToOwner("Dear {$projectUser->getFullName()},<br/><br/>" . "This is an automatic email to let you know your project {$project->getName()} has been updated with status {$project->getState()}{$reason}.<br/><br/>" . "If you have any questions or concerns regarding this change you can discuss this with members on the <a href=\"{$project->getMailingListURL()}\">Mailing List</a>.<br/><br/>" . "Best,<br/>Monkeys in the machine");
}
}
fURL::redirect("/storage/list.php");
} catch (fValidationException $e) {
echo $e->printMessage();
} catch (fSQLException $e) {
echo '<div class="alert alert-danger">An unexpected error occurred, please try again later</div>';
}
}
?>
<?php
if ($user->getId() == $project->getUserId() && ($project->getState() == 'Pending Approval' || $project->getState() == 'Unapproved')) {
?>
<small class="edit_bttn">
<a href="/storage/edit/<?php
echo $project->getId();
?>
示例12: strpos
<meta property="og:title" content="Safecast" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://www.safecast.org" />
<meta property="og:image" content="http://www.safecast.org/images/logo.png" />
<meta property="og:site_name" content="Safecast" />
<meta property="fb:admins" content="595809984" />
<meta name="description" content="Safecast is a website that aggregates radioactivity data from throughout the world in order to provide real-time hyper-local information about the status of the Japanese nuclear crisis.">
<meta name="keywords" content="japan,fukushima,radiation,nuclear,reactor,geiger,counter,RDTN,Safecast">
<title><?php
echo $this->prepare('title');
echo strpos($this->get('title'), 'Safecast') === FALSE ? ' - Safecast' : '';
?>
</title>
<base href="<?php
echo fURL::getDomain() . URL_ROOT;
?>
" />
<link rel="stylesheet" type="text/css" href="style/reset.css" media="screen" />
<!--<link rel="stylesheet" type="text/css" href="style/base.css" media="screen" />-->
<?php
echo $this->place('css');
?>
<script type="text/javascript" src="script/jquery-1.5.1.min.js"></script>
<?php
echo $this->place('js', 'js');
?>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
<script type="text/javascript">
示例13: 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';
}
}
示例14:
<?php
$tmpl->set('title', 'Log In');
$tmpl->set('no-nav', true);
$tmpl->place('header');
?>
<form action="<?php
echo fURL::get() . '?action=log_in';
?>
" method="post">
<div class="main" id="main">
<fieldset>
<div class="clearfix">
<label for="username">Username</label>
<div class="input">
<input id="username" type="text" name="username" value="<?php
echo fRequest::get('username');
?>
" />
</div>
</div><!-- /clearfix -->
<div class="clearfix">
<label for="password">Password</label>
<div class="input">
<input id="password" type="password" name="password" value="" />
</div>
</div><!-- /clearfix -->
<div class="actions">
<input class="btn" type="submit" value="Log In" />
<a class="btn" href="<?php
echo User::makeUrl('add');
示例15: validateCSRFToken
/**
* Validates a request token generated by ::generateCSRFToken()
*
* This method takes a request token and ensures it is valid, otherwise
* it will throw an fValidationException.
*
* @throws fValidationException When the CSRF token specified is invalid
*
* @param string $token The request token to validate
* @param string $url The URL to validate the token for, default to the current page
* @return void
*/
public static function validateCSRFToken($token, $url = NULL)
{
if ($url === NULL) {
$url = fURL::get();
}
$key = __CLASS__ . '::' . $url . '::csrf_tokens';
$tokens = fSession::get($key, array());
if (!in_array($token, $tokens)) {
throw new fValidationException('The form submitted could not be validated as authentic, please try submitting it again');
}
$tokens = array_diff($tokens, array($token));
fSession::set($key, $tokens);
}