本文整理汇总了PHP中StatusNet::isHTTPS方法的典型用法代码示例。如果您正苦于以下问题:PHP StatusNet::isHTTPS方法的具体用法?PHP StatusNet::isHTTPS怎么用?PHP StatusNet::isHTTPS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatusNet
的用法示例。
在下文中一共展示了StatusNet::isHTTPS方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onEndShowScripts
function onEndShowScripts($action)
{
if (isset($action->recaptchaPluginNeedsOutput) && $action->recaptchaPluginNeedsOutput) {
// Load the AJAX API
if (StatusNet::isHTTPS()) {
$url = "https://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
} else {
$url = "http://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
}
$action->script($url);
// And when we're ready, fill out the captcha!
$key = json_encode($this->public_key);
$action->inlinescript("\$(function(){Recaptcha.create({$key}, 'recaptcha');});");
}
return true;
}
示例2: url
static function url($filename)
{
if (!self::validFilename($filename)) {
// TRANS: Client exception thrown if a file upload does not have a valid name.
throw new ClientException(_("Invalid filename."));
}
if (common_config('site', 'private')) {
return common_local_url('getfile', array('filename' => $filename));
}
if (StatusNet::isHTTPS()) {
$sslserver = common_config('attachments', 'sslserver');
if (empty($sslserver)) {
// XXX: this assumes that background dir == site dir + /file/
// not true if there's another server
if (is_string(common_config('site', 'sslserver')) && mb_strlen(common_config('site', 'sslserver')) > 0) {
$server = common_config('site', 'sslserver');
} else {
if (common_config('site', 'server')) {
$server = common_config('site', 'server');
}
}
$path = common_config('site', 'path') . '/file/';
} else {
$server = $sslserver;
$path = common_config('attachments', 'sslpath');
if (empty($path)) {
$path = common_config('attachments', 'path');
}
}
$protocol = 'https';
} else {
$path = common_config('attachments', 'path');
$server = common_config('attachments', 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
$ssl = common_config('attachments', 'ssl');
$protocol = $ssl ? 'https' : 'http';
}
if ($path[strlen($path) - 1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/' . $path;
}
return $protocol . '://' . $server . $path . $filename;
}
示例3: onNoticeSimpleStatusArray
/**
* Add stuff to notices in API responses
*
* @param Action $action action being executed
*
* @return boolean hook return
*/
function onNoticeSimpleStatusArray($notice, &$twitter_status, $scoped)
{
// groups
$notice_groups = $notice->getGroups();
$group_addressees = false;
foreach ($notice_groups as $g) {
$group_addressees[] = array('nickname' => $g->nickname, 'url' => $g->mainpage);
}
$twitter_status['statusnet_in_groups'] = $group_addressees;
// for older verions of gnu social: include the repeat-id, which we need when unrepeating later
if (array_key_exists('repeated', $twitter_status) && $twitter_status['repeated'] === true) {
$repeated = Notice::pkeyGet(array('profile_id' => $scoped->id, 'repeat_of' => $notice->id, 'verb' => 'http://activitystrea.ms/schema/1.0/share'));
$twitter_status['repeated_id'] = $repeated->id;
}
// more metadata about attachments
// get all attachments first, and put all the extra meta data in an array
$attachments = $notice->attachments();
$attachment_url_to_id = array();
if (!empty($attachments)) {
foreach ($attachments as $attachment) {
if (is_object($attachment)) {
try {
$enclosure_o = $attachment->getEnclosure();
// add id to all attachments
$attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
// add data about thumbnails
$thumb = $attachment->getThumbnail();
$large_thumb = $attachment->getThumbnail(1000, 3000, false);
if (method_exists('File_thumbnail', 'url')) {
$thumb_url = File_thumbnail::url($thumb->filename);
$large_thumb_url = File_thumbnail::url($large_thumb->filename);
} else {
$thumb_url = $thumb->getUrl();
$large_thumb_url = $large_thumb->getUrl();
}
$attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
$attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $large_thumb_url;
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
// animated gif?
if ($attachment->mimetype == 'image/gif') {
$image = ImageFile::fromFileObject($attachment);
if ($image->animated == 1) {
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
} else {
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
}
}
// this applies to older versions of gnu social, i think
} catch (ServerException $e) {
$thumb = File_thumbnail::getKV('file_id', $attachment->id);
if ($thumb instanceof File_thumbnail) {
$thumb_url = $thumb->getUrl();
$attachment_url_to_id[$enclosure_o->url]['id'] = $attachment->id;
$attachment_url_to_id[$enclosure_o->url]['thumb_url'] = $thumb_url;
$attachment_url_to_id[$enclosure_o->url]['large_thumb_url'] = $thumb_url;
$attachment_url_to_id[$enclosure_o->url]['width'] = $attachment->width;
$attachment_url_to_id[$enclosure_o->url]['height'] = $attachment->height;
// animated gif?
if ($attachment->mimetype == 'image/gif') {
$image = ImageFile::fromFileObject($attachment);
if ($image->animated == 1) {
$attachment_url_to_id[$enclosure_o->url]['animated'] = true;
} else {
$attachment_url_to_id[$enclosure_o->url]['animated'] = false;
}
}
}
}
}
}
}
// add the extra meta data to $twitter_status
if (!empty($twitter_status['attachments'])) {
foreach ($twitter_status['attachments'] as &$attachment) {
if (!empty($attachment_url_to_id[$attachment['url']])) {
$attachment = array_merge($attachment, $attachment_url_to_id[$attachment['url']]);
}
}
}
// quoted notices
if (!empty($twitter_status['attachments'])) {
foreach ($twitter_status['attachments'] as &$attachment) {
$quoted_notice = false;
// if this attachment has an url this might be a notice url
if (isset($attachment['url'])) {
$noticeurl = common_path('notice/', StatusNet::isHTTPS());
$instanceurl = common_path('', StatusNet::isHTTPS());
// remove protocol for the comparison below
$noticeurl_wo_protocol = preg_replace('(^https?://)', '', $noticeurl);
$instanceurl_wo_protocol = preg_replace('(^https?://)', '', $instanceurl);
$attachment_url_wo_protocol = preg_replace('(^https?://)', '', $attachment['url']);
// local notice urls
//.........这里部分代码省略.........
示例4: showContentLicense
/**
* Show content license.
*
* @return nothing
*/
function showContentLicense()
{
if (Event::handle('StartShowContentLicense', array($this))) {
// TRANS: DT element for StatusNet site content license.
$this->element('dt', array('id' => 'site_content_license'), _('Site content license'));
$this->elementStart('dd', array('id' => 'site_content_license_cc'));
switch (common_config('license', 'type')) {
case 'private':
// TRANS: Content license displayed when license is set to 'private'.
// TRANS: %1$s is the site name.
$this->element('p', null, sprintf(_('Content and data of %1$s are private and confidential.'), common_config('site', 'name')));
// fall through
// fall through
case 'allrightsreserved':
if (common_config('license', 'owner')) {
// TRANS: Content license displayed when license is set to 'allrightsreserved'.
// TRANS: %1$s is the copyright owner.
$this->element('p', null, sprintf(_('Content and data copyright by %1$s. All rights reserved.'), common_config('license', 'owner')));
} else {
// TRANS: Content license displayed when license is set to 'allrightsreserved' and no owner is set.
$this->element('p', null, _('Content and data copyright by contributors. All rights reserved.'));
}
break;
case 'cc':
// fall through
// fall through
default:
$this->elementStart('p');
$image = common_config('license', 'image');
$sslimage = common_config('license', 'sslimage');
if (StatusNet::isHTTPS()) {
if (!empty($sslimage)) {
$url = $sslimage;
} else {
if (preg_match('#^http://i.creativecommons.org/#', $image)) {
// CC support HTTPS on their images
$url = preg_replace('/^http/', 'https', $image);
} else {
// Better to show mixed content than no content
$url = $image;
}
}
} else {
$url = $image;
}
$this->element('img', array('id' => 'license_cc', 'src' => $url, 'alt' => common_config('license', 'title'), 'width' => '80', 'height' => '15'));
$this->text(' ');
// TRANS: license message in footer.
// TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
$notice = _('All %1$s content and data are available under the %2$s license.');
$link = "<a class=\"license\" rel=\"external license\" href=\"" . htmlspecialchars(common_config('license', 'url')) . "\">" . htmlspecialchars(common_config('license', 'title')) . "</a>";
$this->raw(sprintf(htmlspecialchars($notice), htmlspecialchars(common_config('site', 'name')), $link));
$this->elementEnd('p');
break;
}
$this->elementEnd('dd');
Event::handle('EndShowContentLicense', array($this));
}
}
示例5: showQvitter
function showQvitter()
{
$logged_in_user_nickname = '';
$logged_in_user_obj = false;
$logged_in_user = common_current_user();
if ($logged_in_user) {
$logged_in_user_nickname = $logged_in_user->nickname;
$logged_in_user_obj = ApiAction::twitterUserArray($logged_in_user->getProfile());
}
$registrationsclosed = false;
if (common_config('site', 'closed') == 1 || common_config('site', 'inviteonly') == 1) {
$registrationsclosed = true;
}
// check if the client's ip address is blocked for registration
if (is_array(QvitterPlugin::settings("blocked_ips"))) {
$client_ip_is_blocked = in_array($_SERVER['REMOTE_ADDR'], QvitterPlugin::settings("blocked_ips"));
}
$sitetitle = common_config('site', 'name');
$siterootdomain = common_config('site', 'server');
$qvitterpath = Plugin::staticPath('Qvitter', '');
$apiroot = common_path('api/', StatusNet::isHTTPS());
$attachmentroot = common_path('attachment/', StatusNet::isHTTPS());
$instanceurl = common_path('', StatusNet::isHTTPS());
// user's browser's language setting
$user_browser_language = 'en';
// use english if we can't find the browser language
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$user_browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
common_set_returnto('');
// forget this
// if this is a profile we add a link header for LRDD Discovery (see WebfingerPlugin.php)
if (substr_count($_SERVER['REQUEST_URI'], '/') == 1) {
$nickname = substr($_SERVER['REQUEST_URI'], 1);
if (preg_match("/^[a-zA-Z0-9]+\$/", $nickname) == 1) {
$acct = 'acct:' . $nickname . '@' . common_config('site', 'server');
$url = common_local_url('webfinger') . '?resource=' . $acct;
foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) {
header('Link: <' . $url . '>; rel="' . Discovery::LRDD_REL . '"; type="' . $type . '"');
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php
print $sitetitle;
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<link rel="stylesheet" type="text/css" href="<?php
print $qvitterpath;
?>
css/qvitter.css?changed=<?php
print date('YmdHis', filemtime(QVITTERDIR . '/css/qvitter.css'));
?>
" />
<link rel="stylesheet" type="text/css" href="<?php
print $qvitterpath;
?>
css/jquery.minicolors.css" />
<link rel="shortcut icon" type="image/x-icon" href="<?php
print $qvitterpath;
print QvitterPlugin::settings("favicon");
?>
">
<?php
// if qvitter is a webapp and this is a users url we add feeds
if (substr_count($_SERVER['REQUEST_URI'], '/') == 1) {
$nickname = substr($_SERVER['REQUEST_URI'], 1);
if (preg_match("/^[a-zA-Z0-9]+\$/", $nickname) == 1) {
$user = User::getKV('nickname', $nickname);
if (!isset($user->id)) {
//error_log("QVITTER: Could not get user id for user with nickname: $nickname – REQUEST_URI: ".$_SERVER['REQUEST_URI']);
} else {
print '<link title="Notice feed for ' . $nickname . ' (Activity Streams JSON)" type="application/stream+json" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.as" rel="alternate">' . "\n";
print ' <link title="Notice feed for ' . $nickname . ' (RSS 1.0)" type="application/rdf+xml" href="' . $instanceurl . $nickname . '/rss" rel="alternate">' . "\n";
print ' <link title="Notice feed for ' . $nickname . ' (RSS 2.0)" type="application/rss+xml" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.rss" rel="alternate">' . "\n";
print ' <link title="Notice feed for ' . $nickname . ' (Atom)" type="application/atom+xml" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.atom" rel="alternate">' . "\n";
print ' <link title="FOAF for ' . $nickname . '" type="application/rdf+xml" href="' . $instanceurl . $nickname . '/foaf" rel="meta">' . "\n";
print ' <link href="' . $instanceurl . $nickname . '/microsummary" rel="microsummary">' . "\n";
// maybe openid
if (array_key_exists('OpenID', StatusNet::getActivePlugins())) {
print ' <link rel="openid2.provider" href="' . common_local_url('openidserver') . '"/>' . "\n";
print ' <link rel="openid2.local_id" href="' . $user->getProfile()->profileurl . '"/>' . "\n";
print ' <link rel="openid2.server" href="' . common_local_url('openidserver') . '"/>' . "\n";
print ' <link rel="openid2.delegate" href="' . $user->getProfile()->profileurl . '"/>' . "\n";
}
}
}
} elseif (substr($_SERVER['REQUEST_URI'], 0, 7) == '/group/') {
$group_id_or_name = substr($_SERVER['REQUEST_URI'], 7);
if (stristr($group_id_or_name, '/id')) {
$group_id_or_name = substr($group_id_or_name, 0, strpos($group_id_or_name, '/id'));
$group = User_group::getKV('id', $group_id_or_name);
if ($group instanceof User_group) {
$group_name = $group->nickname;
//.........这里部分代码省略.........
示例6: qvitterTwitterUserArray
function qvitterTwitterUserArray($profile)
{
$twitter_user = array();
try {
$user = $profile->getUser();
} catch (NoSuchUserException $e) {
$user = null;
}
$twitter_user['id'] = intval($profile->id);
$twitter_user['name'] = $profile->getBestName();
$twitter_user['screen_name'] = $profile->nickname;
$twitter_user['location'] = $profile->location ? $profile->location : null;
$twitter_user['description'] = $profile->bio ? $profile->bio : null;
// TODO: avatar url template (example.com/user/avatar?size={x}x{y})
$twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE);
$twitter_user['profile_image_url_https'] = $twitter_user['profile_image_url'];
// START introduced by qvitter API, not necessary for StatusNet API
$twitter_user['profile_image_url_profile_size'] = Avatar::urlByProfile($profile, AVATAR_PROFILE_SIZE);
try {
$avatar = Avatar::getUploaded($profile);
$origurl = $avatar->displayUrl();
} catch (Exception $e) {
// ugly fix if avatar is missing in the db but exists on the server
$largest_avatar = array('name' => false, 'size' => 0);
foreach (glob('avatar/' . $profile->id . '-*') as $filename) {
$size = filesize($filename);
if ($size > $largest_avatar['size']) {
$largest_avatar['size'] = $size;
$largest_avatar['name'] = $filename;
}
}
if ($largest_avatar['size'] > 0) {
$origurl = common_path('', StatusNet::isHTTPS()) . $largest_avatar['name'];
} else {
$origurl = $twitter_user['profile_image_url_profile_size'];
}
}
$twitter_user['profile_image_url_original'] = $origurl;
$twitter_user['groups_count'] = $profile->getGroupCount();
foreach (array('linkcolor', 'backgroundcolor') as $key) {
$twitter_user[$key] = Profile_prefs::getConfigData($profile, 'theme', $key);
}
// END introduced by qvitter API, not necessary for StatusNet API
$twitter_user['url'] = $profile->homepage ? $profile->homepage : null;
$twitter_user['protected'] = !empty($user) && $user->private_stream ? true : false;
$twitter_user['followers_count'] = $profile->subscriberCount();
// Note: some profiles don't have an associated user
$twitter_user['friends_count'] = $profile->subscriptionCount();
$twitter_user['created_at'] = ApiAction::dateTwitter($profile->created);
$timezone = 'UTC';
if (!empty($user) && $user->timezone) {
$timezone = $user->timezone;
}
$t = new DateTime();
$t->setTimezone(new DateTimeZone($timezone));
$twitter_user['utc_offset'] = $t->format('Z');
$twitter_user['time_zone'] = $timezone;
$twitter_user['statuses_count'] = $profile->noticeCount();
// Is the requesting user following this user?
$twitter_user['following'] = false;
$twitter_user['statusnet_blocking'] = false;
$logged_in_profile = null;
if (common_logged_in()) {
$logged_in_profile = Profile::current();
$twitter_user['following'] = $logged_in_profile->isSubscribed($profile);
$twitter_user['statusnet_blocking'] = $logged_in_profile->hasBlocked($profile);
}
// StatusNet-specific
$twitter_user['statusnet_profile_url'] = $profile->profileurl;
Event::handle('TwitterUserArray', array($profile, &$twitter_user, $logged_in_profile, array()));
return $twitter_user;
}
示例7: cssLink
/**
* output a css link
*
* @param string $src relative path within the theme directory, or an absolute path
* @param string $theme 'theme' that contains the stylesheet
* @param string media 'media' attribute of the tag
*
* @return void
*/
function cssLink($src, $theme = null, $media = null)
{
if (Event::handle('StartCssLinkElement', array($this, &$src, &$theme, &$media))) {
$url = parse_url($src);
if (empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment'])) {
if (file_exists(Theme::file($src, $theme))) {
$src = Theme::path($src, $theme);
} else {
$src = common_path($src, StatusNet::isHTTPS());
}
$src .= '?version=' . STATUSNET_VERSION;
}
$this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $src, 'media' => $media));
Event::handle('EndCssLinkElement', array($this, $src, $theme, $media));
}
}
示例8: relativeThemePath
/**
* Build a full URL to the given theme's base directory, possibly
* using an offsite theme server path.
*
* @param string $group configuration section name to pull paths from
* @param string $fallbackSubdir default subdirectory under INSTALLDIR
* @param string $name theme name
*
* @return string URL
*
* @todo consolidate code with that for other customizable paths
*/
protected function relativeThemePath($group, $fallbackSubdir, $name)
{
if (StatusNet::isHTTPS()) {
$sslserver = common_config($group, 'sslserver');
if (empty($sslserver)) {
if (is_string(common_config('site', 'sslserver')) && mb_strlen(common_config('site', 'sslserver')) > 0) {
$server = common_config('site', 'sslserver');
} else {
if (common_config('site', 'server')) {
$server = common_config('site', 'server');
}
}
$path = common_config('site', 'path') . '/';
if ($fallbackSubdir) {
$path .= $fallbackSubdir . '/';
}
} else {
$server = $sslserver;
$path = common_config($group, 'sslpath');
if (empty($path)) {
$path = common_config($group, 'path');
}
}
$protocol = 'https';
} else {
$path = common_config($group, 'path');
if (empty($path)) {
$path = common_config('site', 'path') . '/';
if ($fallbackSubdir) {
$path .= $fallbackSubdir . '/';
}
}
$server = common_config($group, 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
$protocol = 'http';
}
if ($path[strlen($path) - 1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/' . $path;
}
return $protocol . '://' . $server . $path . $name;
}
示例9: onStartAddressData
function onStartAddressData($action)
{
if (common_config('singleuser', 'enabled')) {
$user = User::singleUser();
$url = common_local_url('showstream', array('nickname' => $user->nickname));
} else {
if (common_logged_in()) {
$cur = common_current_user();
$url = common_local_url('all', array('nickname' => $cur->nickname));
} else {
$url = common_local_url('public');
}
}
$action->elementStart('a', array('class' => 'url home bookmark', 'href' => $url));
if (StatusNet::isHTTPS()) {
$logoUrl = common_config('site', 'ssllogo');
if (empty($logoUrl)) {
// if logo is an uploaded file, try to fall back to HTTPS file URL
$httpUrl = common_config('site', 'logo');
if (!empty($httpUrl)) {
$f = File::staticGet('url', $httpUrl);
if (!empty($f) && !empty($f->filename)) {
// this will handle the HTTPS case
$logoUrl = File::url($f->filename);
}
}
}
} else {
$logoUrl = common_config('site', 'logo');
}
if (empty($logoUrl) && file_exists(Theme::file('logo.png'))) {
// This should handle the HTTPS case internally
$logoUrl = Theme::path('logo.png');
}
if (!empty($logoUrl)) {
$action->element('img', array('class' => 'logo photo', 'src' => $logoUrl, 'alt' => common_config('site', 'name')));
}
$action->text(' ');
$action->element('span', array('class' => 'fn org'), common_config('site', 'name'));
$action->elementEnd('a');
Event::handle('EndAddressData', array($action));
return false;
}
示例10: url
static function url($filename)
{
if (StatusNet::isHTTPS()) {
$sslserver = common_config('background', 'sslserver');
if (empty($sslserver)) {
// XXX: this assumes that background dir == site dir + /background/
// not true if there's another server
if (is_string(common_config('site', 'sslserver')) && mb_strlen(common_config('site', 'sslserver')) > 0) {
$server = common_config('site', 'sslserver');
} else {
if (common_config('site', 'server')) {
$server = common_config('site', 'server');
}
}
$path = common_config('site', 'path') . '/background/';
} else {
$server = $sslserver;
$path = common_config('background', 'sslpath');
if (empty($path)) {
$path = common_config('background', 'path');
}
}
$protocol = 'https';
} else {
$path = common_config('background', 'path');
$server = common_config('background', 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
$protocol = 'http';
}
if ($path[strlen($path) - 1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/' . $path;
}
return $protocol . '://' . $server . $path . $filename;
}
示例11: main
function main()
{
// fake HTTP redirects using lighttpd's 404 redirects
if (strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) {
$_lighty_url = $_SERVER['REQUEST_URI'];
$_lighty_url = @parse_url($_lighty_url);
if ($_lighty_url['path'] != '/index.php' && $_lighty_url['path'] != '/') {
$_lighty_path = preg_replace('/^' . preg_quote(common_config('site', 'path')) . '\\//', '', substr($_lighty_url['path'], 1));
$_SERVER['QUERY_STRING'] = 'p=' . $_lighty_path;
if (isset($_lighty_url['query']) && $_lighty_url['query'] != '') {
$_SERVER['QUERY_STRING'] .= '&' . $_lighty_url['query'];
parse_str($_lighty_url['query'], $_lighty_query);
foreach ($_lighty_query as $key => $val) {
$_GET[$key] = $_REQUEST[$key] = $val;
}
}
$_GET['p'] = $_REQUEST['p'] = $_lighty_path;
}
}
$_SERVER['REDIRECT_URL'] = preg_replace("/\\?.+\$/", "", $_SERVER['REQUEST_URI']);
// quick check for fancy URL auto-detection support in installer.
if (isset($_SERVER['REDIRECT_URL']) && preg_replace("/^\\/\$/", "", dirname($_SERVER['REQUEST_URI'])) . '/check-fancy' === $_SERVER['REDIRECT_URL']) {
die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs.");
}
global $user, $action;
Snapshot::check();
if (!_have_config()) {
$msg = sprintf(_("No configuration file found. Try running " . "the installation program first."));
$sac = new ServerErrorAction($msg);
$sac->showPage();
return;
}
// Make sure RW database is setup
setupRW();
// XXX: we need a little more structure in this script
// get and cache current user (may hit RW!)
$user = common_current_user();
// initialize language env
common_init_language();
$path = getPath($_REQUEST);
$r = Router::get();
$args = $r->map($path);
if (!$args) {
// TRANS: Error message displayed when trying to access a non-existing page.
$cac = new ClientErrorAction(_('Unknown page'), 404);
$cac->showPage();
return;
}
$site_ssl = common_config('site', 'ssl');
// If the request is HTTP and it should be HTTPS...
if ($site_ssl != 'never' && !StatusNet::isHTTPS() && common_is_sensitive($args['action'])) {
common_redirect(common_local_url($args['action'], $args));
return;
}
$args = array_merge($args, $_REQUEST);
Event::handle('ArgsInitialize', array(&$args));
$action = $args['action'];
if (!$action || !preg_match('/^[a-zA-Z0-9_-]*$/', $action)) {
common_redirect(common_local_url('public'));
return;
}
// If the site is private, and they're not on one of the "public"
// parts of the site, redirect to login
if (!$user && common_config('site', 'private') && !isLoginAction($action) && !preg_match('/rss$/', $action) && $action != 'robotstxt' && !preg_match('/^Api/', $action)) {
// set returnto
$rargs =& common_copy_args($args);
unset($rargs['action']);
if (common_config('site', 'fancy')) {
unset($rargs['p']);
}
if (array_key_exists('submit', $rargs)) {
unset($rargs['submit']);
}
foreach (array_keys($_COOKIE) as $cookie) {
unset($rargs[$cookie]);
}
common_set_returnto(common_local_url($action, $rargs));
common_redirect(common_local_url('login'));
return;
}
$action_class = ucfirst($action) . 'Action';
if (!class_exists($action_class)) {
// TRANS: Error message displayed when trying to perform an undefined action.
$cac = new ClientErrorAction(_('Unknown action'), 404);
$cac->showPage();
} else {
$action_obj = new $action_class();
checkMirror($action_obj, $args);
try {
if ($action_obj->prepare($args)) {
$action_obj->handle($args);
}
} catch (ClientException $cex) {
$cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
$cac->showPage();
} catch (ServerException $sex) {
// snort snort guffaw
$sac = new ServerErrorAction($sex->getMessage(), $sex->getCode(), $sex);
$sac->showPage();
} catch (Exception $ex) {
//.........这里部分代码省略.........
示例12: handle
/**
* Handle the request
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
$noticeurl = common_path('notice/', StatusNet::isHTTPS());
$instanceurl = common_path('', StatusNet::isHTTPS());
// remove protocol for the comparison below
$noticeurl_wo_protocol = preg_replace('(^https?://)', '', $noticeurl);
$instanceurl_wo_protocol = preg_replace('(^https?://)', '', $instanceurl);
$url_wo_protocol = preg_replace('(^https?://)', '', $this->url);
// find local notice
if (strpos($url_wo_protocol, $noticeurl_wo_protocol) === 0) {
$possible_notice_id = str_replace($noticeurl_wo_protocol, '', $url_wo_protocol);
if (ctype_digit($possible_notice_id)) {
$notice = Notice::getKV('id', $possible_notice_id);
} else {
$this->clientError("Notice not found.", 404);
}
}
if (!$notice instanceof Notice) {
// TRANS: Client error displayed in oEmbed action when notice not found.
// TRANS: %s is a notice.
$this->clientError(sprintf(_("Notice %s not found."), $this->id), 404);
}
$profile = $notice->getProfile();
if (!$profile instanceof Profile) {
// TRANS: Server error displayed in oEmbed action when notice has not profile.
$this->serverError(_('Notice has no profile.'), 500);
}
$authorname = $profile->getFancyName();
$oembed = array();
$oembed['version'] = '1.0';
$oembed['provider_name'] = common_config('site', 'name');
$oembed['provider_url'] = common_root_url();
$oembed['type'] = 'link';
// TRANS: oEmbed title. %1$s is the author name, %2$s is the creation date.
$oembed['title'] = ApiAction::dateTwitter($notice->created) . ' (Qvitter)';
$oembed['author_name'] = $authorname;
$oembed['author_url'] = $profile->profileurl;
$oembed['url'] = $notice->getUrl();
$oembed['html'] = $notice->getRendered();
// maybe add thumbnail
$attachments = $notice->attachments();
if (!empty($attachments)) {
foreach ($attachments as $attachment) {
if (is_object($attachment)) {
try {
$thumb = $attachment->getThumbnail();
} catch (ServerException $e) {
//
}
if (!empty($thumb) && method_exists('File_thumbnail', 'url')) {
try {
$thumb_url = File_thumbnail::url($thumb->filename);
$oembed['thumbnail_url'] = $thumb_url;
break;
// only first one
} catch (ClientException $e) {
//
}
}
}
}
}
if ($this->format == 'json') {
$this->initDocument('json');
print json_encode($oembed);
$this->endDocument('json');
} elseif ($this->format == 'xml') {
$this->initDocument('xml');
$this->elementStart('oembed');
foreach (array('version', 'type', 'provider_name', 'provider_url', 'title', 'author_name', 'author_url', 'url', 'html') as $key) {
if (isset($oembed[$key]) && $oembed[$key] != '') {
$this->element($key, null, $oembed[$key]);
}
}
$this->elementEnd('oembed');
$this->endDocument('xml');
} else {
$this->serverError(sprintf(_('Format %s not supported.'), $this->format), 501);
}
}
示例13: staticPath
static function staticPath($plugin, $relative)
{
$isHTTPS = StatusNet::isHTTPS();
if ($isHTTPS) {
$server = common_config('plugins', 'sslserver');
} else {
$server = common_config('plugins', 'server');
}
if (empty($server)) {
if ($isHTTPS) {
$server = common_config('site', 'sslserver');
}
if (empty($server)) {
$server = common_config('site', 'server');
}
}
if ($isHTTPS) {
$path = common_config('plugins', 'sslpath');
} else {
$path = common_config('plugins', 'path');
}
if (empty($path)) {
// XXX: extra stat().
if (@file_exists(INSTALLDIR . '/local/plugins/' . $plugin . '/' . $relative)) {
$path = common_config('site', 'path') . '/local/plugins/';
} else {
$path = common_config('site', 'path') . '/plugins/';
}
}
if ($path[strlen($path) - 1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/' . $path;
}
$protocol = $isHTTPS ? 'https' : 'http';
return $protocol . '://' . $server . $path . $plugin . '/' . $relative;
}
示例14: onEndShowScripts
/**
* Hook for adding extra JavaScript
*
* This makes sure our scripts get loaded for map-related pages
*
* @param Action $action Action object for the page
*
* @return boolean event handler return
*/
function onEndShowScripts($action)
{
$actionName = $action->trimmed('action');
if (!in_array($actionName, array('showstream', 'all', 'usermap', 'allmap'))) {
return true;
}
switch ($this->provider) {
case 'cloudmade':
$action->script('http://tile.cloudmade.com/wml/0.2/web-maps-lite.js');
break;
case 'google':
$action->script(sprintf('http://maps.google.com/maps?file=api&v=2&sensor=false&key=%s', urlencode($this->apikey)));
break;
case 'microsoft':
$action->script((StatusNet::isHTTPS() ? 'https' : 'http') + '://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6');
break;
case 'openlayers':
// Use our included stripped & minified OpenLayers.
$action->script($this->path('OpenLayers/OpenLayers.js'));
break;
case 'yahoo':
$action->script(sprintf('http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=%s', urlencode($this->apikey)));
break;
case 'geocommons':
// don't support this yet
// don't support this yet
default:
return true;
}
if ($this->provider == 'openlayers') {
// We have an optimized path for our default case.
//
// Note that OpenLayers.js needs to be separate, or it won't
// be able to find its UI images and styles.
$action->script($this->path('usermap-mxn-openlayers.min.js'));
} else {
$action->script(sprintf('%s?(%s)', $this->path('js/mxn.js'), $this->provider));
$action->script($this->path('usermap.js'));
}
$action->inlineScript(sprintf('var _provider = "%s";', $this->provider));
// usermap and allmap handle this themselves
if (in_array($actionName, array('showstream', 'all'))) {
$action->inlineScript('$(document).ready(function() { ' . ' var user = null; ' . ($actionName == 'showstream' ? ' user = scrapeUser(); ' : '') . ' var notices = scrapeNotices(user); ' . ' var canvas = $("#map_canvas")[0]; ' . ' if (typeof(canvas) != "undefined") { showMapstraction(canvas, notices); } ' . '});');
}
return true;
}