Merge branch '0.9.x' of git://gitorious.org/statusnet/mainline into 0.9.x

This commit is contained in:
root 2010-01-09 23:25:08 +00:00
commit d59df6b270
188 changed files with 30528 additions and 13196 deletions

25
README
View File

@ -710,15 +710,21 @@ private site, but users of the private site may be able to subscribe
to users on a remote site. (Or not... it's not well tested.) The
"proper behaviour" hasn't been defined here, so handle with care.
If fancy URLs is enabled, access to file attachments can also be
restricted to logged-in users only. Uncomment the appropriate rewrite
<<<<<<< HEAD:README
rule in .htaccess or your server's httpd.conf. (This most likely will
not work if you are using a virtual server for attachments, so consider
the performance/security tradeoff.)
=======
rule in .htaccess or your server's httpd.conf.
>>>>>>> 446de62... Revert "Added some explanatory text to README":README
Access to file attachments can also be restricted to logged-in users only.
1. Add a directory outside the web root where your file uploads will be
stored. Usually a command like this will work:
mkdir /var/www/mublog-files
2. Make the file uploads directory writeable by the web server. An
insecure way to do this is:
chmod a+x /var/www/mublog-files
3. Tell StatusNet to use this directory for file uploads. Add a line
like this to your config.php:
$config['attachments']['dir'] = '/var/www/mublog-files';
Upgrading
=========
@ -1616,6 +1622,7 @@ if anyone's been overlooked in error.
* Craig Andrews
* mEDI
* Brett Taylor
* Brigitte Schuster
Thanks also to the developers of our upstream library code and to the
thousands of people who have tried out Identi.ca, installed StatusNet,

View File

@ -108,7 +108,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
$member = new Group_member();
$member->group_id = $this->group->id;
$member->profile_id = $this->auth->id;
$member->profile_id = $this->auth_user->id;
if (!$member->find(true)) {
$this->serverError(_('You are not a member of this group.'));
@ -118,12 +118,12 @@ class ApiGroupLeaveAction extends ApiAuthAction
$result = $member->delete();
if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__);
common_log_db_error($member, 'DELETE', __FILE__);
$this->serverError(
sprintf(
_('Could not remove user %s to group %s.'),
_('Could not remove user %s from group %s.'),
$this->user->nickname,
$this->$group->nickname
$this->group->nickname
)
);
return;

View File

@ -203,12 +203,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
}
}
$location = null;
if (!empty($this->lat) && !empty($this->lon)) {
$location = Location::fromLatLon($this->lat, $this->lon);
}
$upload = null;
try {
@ -235,11 +229,15 @@ class ApiStatusesUpdateAction extends ApiAuthAction
$options = array('reply_to' => $reply_to);
if (!empty($location)) {
$options['lat'] = $location->lat;
$options['lon'] = $location->lon;
$options['location_id'] = $location->location_id;
$options['location_ns'] = $location->location_ns;
if ($this->user->shareLocation()) {
$locOptions = Notice::locationOptions($this->lat,
$this->lon,
null,
null,
$this->user->getProfile());
$options = array_merge($options, $locOptions);
}
$this->notice =

View File

@ -96,7 +96,7 @@ class FeaturedAction extends Action
function getInstructions()
{
return sprintf(_('A selection of some of the great users on %s'),
return sprintf(_('A selection of some great users on %s'),
common_config('site', 'name'));
}

98
actions/geocode.php Normal file
View File

@ -0,0 +1,98 @@
<?php
/**
* Geocode action class
*
* PHP version 5
*
* @category Action
* @package StatusNet
* @author Craig Andrews <candrews@integralblue.com>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
/**
* Geocode action class
*
* @category Action
* @package StatusNet
* @author Craig Andrews <candrews@integralblue.com>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class GeocodeAction extends Action
{
function prepare($args)
{
parent::prepare($args);
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. '.
'Try again, please.'));
}
$this->lat = $this->trimmed('lat');
$this->lon = $this->trimmed('lon');
$location = Location::fromLatLon($this->lat, $this->lon);
if ($location) {
$this->location = Location::fromId($location->location_id, $location->location_ns);
$this->lat = $this->location->lat;
$this->lon = $this->location->lon;
}
return true;
}
/**
* Class handler
*
* @param array $args query arguments
*
* @return nothing
*
**/
function handle($args)
{
header('Content-Type: application/json; charset=utf-8');
$location_object = array();
$location_object['lat']=$this->lat;
$location_object['lon']=$this->lon;
if($this->location) {
$location_object['location_id']=$this->location->location_id;
$location_object['location_ns']=$this->location->location_ns;
$location_object['name']=$this->location->getName();
$location_object['url']=$this->location->getUrl();
}
print(json_encode($location_object));
}
/**
* Is this action read-only?
*
* @return boolean true
*/
function isReadOnly($args)
{
return true;
}
}
?>

View File

@ -1,13 +1,13 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2009, StatusNet, Inc.
*
* Returns a given file attachment, allowing private sites to only allow
* access to file attachments after login.
* Return a requested file
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@ -20,28 +20,32 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Personal
* @category PrivateAttachments
* @package StatusNet
* @author Jeffery To <jeffery.to@gmail.com>
* @copyright 2008-2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
if (!defined('STATUSNET')) {
exit(1);
}
require_once 'MIME/Type.php';
/**
* Action for getting a file attachment
* An action for returning a requested file
*
* @category Personal
* @package StatusNet
* @author Jeffery To <jeffery.to@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* The StatusNet system will do an implicit user check if the site is
* private before allowing this to continue
*
* @category PrivateAttachments
* @package StatusNet
* @author Jeffery To <jeffery.to@gmail.com>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class GetfileAction extends Action
@ -68,7 +72,7 @@ class GetfileAction extends Action
$path = null;
if ($filename) {
$path = common_config('attachments', 'dir') . $filename;
$path = File::path($filename);
}
if (empty($path) or !file_exists($path)) {
@ -103,6 +107,10 @@ class GetfileAction extends Action
function lastModified()
{
if (common_config('site', 'use_x_sendfile')) {
return null;
}
return filemtime($this->path);
}
@ -114,8 +122,24 @@ class GetfileAction extends Action
*
* @return string etag http header
*/
function etag()
{
if (common_config('site', 'use_x_sendfile')) {
return null;
}
$cache = common_memcache();
if($cache) {
$key = common_cache_key('attachments:etag:' . $this->path);
$etag = $cache->get($key);
if($etag === false) {
$etag = crc32(file_get_contents($this->path));
$cache->set($key,$etag);
}
return $etag;
}
$stat = stat($this->path);
return '"' . $stat['ino'] . '-' . $stat['size'] . '-' . $stat['mtime'] . '"';
}
@ -133,13 +157,19 @@ class GetfileAction extends Action
// undo headers set by PHP sessions
$sec = session_cache_expire() * 60;
header('Expires: ' . date(DATE_RFC1123, time() + $sec));
header('Cache-Control: public, max-age=' . $sec);
header('Pragma: public');
header('Cache-Control: max-age=' . $sec);
parent::handle($args);
$path = $this->path;
header('Content-Type: ' . MIME_Type::autoDetect($path));
readfile($path);
if (common_config('site', 'use_x_sendfile')) {
header('X-Sendfile: ' . $path);
} else {
header('Content-Length: ' . filesize($path));
readfile($path);
}
}
}

View File

@ -123,8 +123,8 @@ class LeavegroupAction extends Action
$result = $member->delete();
if (!$result) {
common_log_db_error($member, 'INSERT', __FILE__);
$this->serverError(sprintf(_('Could not remove user %s to group %s'),
common_log_db_error($member, 'DELETE', __FILE__);
$this->serverError(sprintf(_('Could not remove user %s from group %s'),
$cur->nickname, $this->group->nickname));
}

View File

@ -164,19 +164,6 @@ class NewnoticeAction extends Action
$replyto = 'false';
}
$lat = $this->trimmed('lat');
$lon = $this->trimmed('lon');
$location_id = $this->trimmed('location_id');
$location_ns = $this->trimmed('location_ns');
if (!empty($lat) && !empty($lon) && empty($location_id)) {
$location = Location::fromLatLon($lat, $lon);
if (!empty($location)) {
$location_id = $location->location_id;
$location_ns = $location->location_ns;
}
}
$upload = null;
$upload = MediaFile::fromUpload('attach');
@ -195,12 +182,20 @@ class NewnoticeAction extends Action
}
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web',
array('reply_to' => ($replyto == 'false') ? null : $replyto,
'lat' => $lat,
'lon' => $lon,
'location_id' => $location_id,
'location_ns' => $location_ns));
$options = array('reply_to' => ($replyto == 'false') ? null : $replyto);
if ($user->shareLocation() && $this->arg('notice_data-geo')) {
$locOptions = Notice::locationOptions($this->trimmed('lat'),
$this->trimmed('lon'),
$this->trimmed('location_id'),
$this->trimmed('location_ns'),
$user->getProfile());
$options = array_merge($options, $locOptions);
}
$notice = Notice::saveNew($user->id, $content_shortened, 'web', $options);
if (isset($upload)) {
$upload->attachToNotice($notice);

View File

@ -69,7 +69,7 @@ class ProfilesettingsAction extends AccountSettingsAction
function getInstructions()
{
return _('You can update your personal profile info here '.
'so people know more about you.');
'so people know more about you.');
}
function showScripts()
@ -92,9 +92,9 @@ class ProfilesettingsAction extends AccountSettingsAction
$profile = $user->getProfile();
$this->elementStart('form', array('method' => 'post',
'id' => 'form_settings_profile',
'class' => 'form_settings',
'action' => common_local_url('profilesettings')));
'id' => 'form_settings_profile',
'class' => 'form_settings',
'action' => common_local_url('profilesettings')));
$this->elementStart('fieldset');
$this->element('legend', null, _('Profile information'));
$this->hidden('token', common_session_token());
@ -133,6 +133,13 @@ class ProfilesettingsAction extends AccountSettingsAction
($this->arg('location')) ? $this->arg('location') : $profile->location,
_('Where you are, like "City, State (or Region), Country"'));
$this->elementEnd('li');
if (common_config('location', 'share') == 'user') {
$this->elementStart('li');
$this->checkbox('sharelocation', _('Share my current location when posting notices'),
($this->arg('sharelocation')) ?
$this->arg('sharelocation') : $user->shareLocation());
$this->elementEnd('li');
}
Event::handle('EndProfileFormData', array($this));
$this->elementStart('li');
$this->input('tags', _('Tags'),
@ -185,7 +192,7 @@ class ProfilesettingsAction extends AccountSettingsAction
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token. '.
'Try again, please.'));
'Try again, please.'));
return;
}
@ -203,15 +210,15 @@ class ProfilesettingsAction extends AccountSettingsAction
// Some validation
if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
'format' => NICKNAME_FMT))) {
'max_length' => 64,
'format' => NICKNAME_FMT))) {
$this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
} else if (!User::allowed_nickname($nickname)) {
$this->showForm(_('Not a valid nickname.'));
return;
} else if (!is_null($homepage) && (strlen($homepage) > 0) &&
!Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
!Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
$this->showForm(_('Homepage is not a valid URL.'));
return;
} else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
@ -253,15 +260,15 @@ class ProfilesettingsAction extends AccountSettingsAction
$user->query('BEGIN');
if ($user->nickname != $nickname ||
$user->language != $language ||
$user->timezone != $timezone) {
$user->language != $language ||
$user->timezone != $timezone) {
common_debug('Updating user nickname from ' . $user->nickname . ' to ' . $nickname,
__FILE__);
__FILE__);
common_debug('Updating user language from ' . $user->language . ' to ' . $language,
__FILE__);
__FILE__);
common_debug('Updating user timezone from ' . $user->timezone . ' to ' . $timezone,
__FILE__);
__FILE__);
$original = clone($user);
@ -281,7 +288,7 @@ class ProfilesettingsAction extends AccountSettingsAction
}
}
// XXX: XOR
// XXX: XOR
if ($user->autosubscribe ^ $autosubscribe) {
$original = clone($user);
@ -309,7 +316,12 @@ class ProfilesettingsAction extends AccountSettingsAction
$loc = Location::fromName($location);
if (!empty($loc)) {
if (empty($loc)) {
$profile->lat = null;
$profile->lon = null;
$profile->location_id = null;
$profile->location_ns = null;
} else {
$profile->lat = $loc->lat;
$profile->lon = $loc->lon;
$profile->location_id = $loc->location_id;
@ -318,6 +330,37 @@ class ProfilesettingsAction extends AccountSettingsAction
$profile->profileurl = common_profile_url($nickname);
if (common_config('location', 'share') == 'user') {
$exists = false;
$prefs = User_location_prefs::staticGet('user_id', $user->id);
if (empty($prefs)) {
$prefs = new User_location_prefs();
$prefs->user_id = $user->id;
$prefs->created = common_sql_now();
} else {
$exists = true;
$orig = clone($prefs);
}
$prefs->share_location = $this->boolean('sharelocation');
if ($exists) {
$result = $prefs->update($orig);
} else {
$result = $prefs->insert();
}
if ($result === false) {
common_log_db_error($prefs, ($exists) ? 'UPDATE' : 'INSERT', __FILE__);
$this->serverError(_('Couldn\'t save location prefs.'));
return;
}
}
common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
common_debug('New profile: ' . common_log_objstring($profile), __FILE__);
@ -351,7 +394,7 @@ class ProfilesettingsAction extends AccountSettingsAction
$user = common_current_user();
$other = User::staticGet('nickname', $nickname);
if (!$other) {
return false;
return false;
} else {
return $other->id != $user->id;
}

View File

@ -103,7 +103,7 @@ class ShownoticeAction extends OwnerDesignAction
$this->user = User::staticGet('id', $this->profile->id);
if (! $this->notice->is_local) {
if ($this->notice->is_local == Notice::REMOTE_OMB) {
common_redirect($this->notice->uri);
return false;
}

270
actions/version.php Normal file
View File

@ -0,0 +1,270 @@
<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* Show version information for this software and plugins
*
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Info
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
if (!defined('STATUSNET')) {
exit(1);
}
/**
* Version info page
*
* A page that shows version information for this site. Helpful for
* debugging, for giving credit to authors, and for linking to more
* complete documentation for admins.
*
* @category Info
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
class VersionAction extends Action
{
var $pluginVersions = array();
/**
* Return true since we're read-only.
*
* @param array $args other arguments
*
* @return boolean is read only action?
*/
function isReadOnly($args)
{
return true;
}
/**
* Returns the page title
*
* @return string page title
*/
function title()
{
return sprintf(_("StatusNet %s"), STATUSNET_VERSION);
}
/**
* Prepare to run
*
* Fire off an event to let plugins report their
* versions.
*
* @param array $args array misc. arguments
*
* @return boolean true
*/
function prepare($args)
{
parent::prepare($args);
Event::handle('PluginVersion', array(&$this->pluginVersions));
return true;
}
/**
* Execute the action
*
* Shows a page with the version information in the
* content area.
*
* @param array $args ignored.
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$this->showPage();
}
/*
* Override to add hentry, and content-inner classes
*
* @return void
*/
function showContentBlock()
{
$this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
$this->showPageTitle();
$this->showPageNoticeBlock();
$this->elementStart('div', array('id' => 'content_inner',
'class' => 'entry-content'));
// show the actual content (forms, lists, whatever)
$this->showContent();
$this->elementEnd('div');
$this->elementEnd('div');
}
/*
* Overrride to add entry-title class
*
* @return void
*/
function showPageTitle() {
$this->element('h1', array('class' => 'entry-title'), $this->title());
}
/**
* Show version information
*
* @return void
*/
function showContent()
{
$this->elementStart('p');
$this->raw(sprintf(_('This site is powered by %s version %s, '.
'Copyright 2008-2010 StatusNet, Inc. '.
'and contributors.'),
XMLStringer::estring('a', array('href' => 'http://status.net/'),
_('StatusNet')),
STATUSNET_VERSION));
$this->elementEnd('p');
$this->element('h2', null, _('Contributors'));
$this->element('p', null, implode(', ', $this->contributors));
$this->element('h2', null, _('License'));
$this->element('p', null,
_('StatusNet is free software: you can redistribute it and/or modify '.
'it under the terms of the GNU Affero General Public License as published by '.
'the Free Software Foundation, either version 3 of the License, or '.
'(at your option) any later version. '));
$this->element('p', null,
_('This program is distributed in the hope that it will be useful, '.
'but WITHOUT ANY WARRANTY; without even the implied warranty of '.
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '.
'GNU Affero General Public License for more details. '));
$this->elementStart('p');
$this->raw(sprintf(_('You should have received a copy of the GNU Affero General Public License '.
'along with this program. If not, see %s.'),
XMLStringer::estring('a', array('href' => 'http://www.gnu.org/licenses/agpl.html'),
'http://www.gnu.org/licenses/agpl.html')));
$this->elementEnd('p');
// XXX: Theme information?
if (count($this->pluginVersions)) {
$this->element('h2', null, _('Plugins'));
$this->elementStart('table', array('id' => 'plugins_enabled'));
$this->elementStart('thead');
$this->elementStart('tr');
$this->element('th', array('id' => 'plugin_name'), _('Name'));
$this->element('th', array('id' => 'plugin_version'), _('Version'));
$this->element('th', array('id' => 'plugin_authors'), _('Author(s)'));
$this->element('th', array('id' => 'plugin_description'), _('Description'));
$this->elementEnd('tr');
$this->elementEnd('thead');
$this->elementStart('tbody');
foreach ($this->pluginVersions as $plugin) {
$this->elementStart('tr');
if (array_key_exists('homepage', $plugin)) {
$this->elementStart('th');
$this->element('a', array('href' => $plugin['homepage']),
$plugin['name']);
$this->elementEnd('th');
} else {
$this->element('th', null, $plugin['name']);
}
$this->element('td', null, $plugin['version']);
if (array_key_exists('author', $plugin)) {
$this->element('td', null, $plugin['author']);
}
if (array_key_exists('rawdescription', $plugin)) {
$this->elementStart('td');
$this->raw($plugin['rawdescription']);
$this->elementEnd('td');
} else if (array_key_exists('description', $plugin)) {
$this->element('td', null, $plugin['description']);
}
$this->elementEnd('tr');
}
$this->elementEnd('tbody');
$this->elementEnd('table');
}
}
var $contributors = array('Evan Prodromou (StatusNet)',
'Zach Copley (StatusNet)',
'Earle Martin (StatusNet)',
'Marie-Claude Doyon (StatusNet)',
'Sarven Capadisli (StatusNet)',
'Robin Millette (StatusNet)',
'Ciaran Gultnieks',
'Michael Landers',
'Ori Avtalion',
'Garret Buell',
'Mike Cochrane',
'Matthew Gregg',
'Florian Biree',
'Erik Stambaugh',
'drry',
'Gina Haeussge',
'Tryggvi Björgvinsson',
'Adrian Lang',
'Meitar Moscovitz',
'Sean Murphy',
'Leslie Michael Orchard',
'Eric Helgeson',
'Ken Sedgwick',
'Brian Hendrickson',
'Tobias Diekershoff',
'Dan Moore',
'Fil',
'Jeff Mitchell',
'Brenda Wallace',
'Jeffery To',
'Federico Marani',
'Craig Andrews',
'mEDI',
'Brett Taylor',
'Brigitte Schuster');
}

View File

@ -37,7 +37,7 @@ class Avatar extends Memcached_DataObject
}
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Avatar', $kv);
}

View File

@ -59,7 +59,7 @@ class Config extends Memcached_DataObject
if (!empty($c)) {
$settings = $c->get(common_cache_key(self::settingsKey));
if (!empty($settings)) {
if ($settings !== false) {
return $settings;
}
}
@ -120,7 +120,7 @@ class Config extends Memcached_DataObject
return $result;
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Config', $kv);
}

View File

@ -32,7 +32,7 @@ class Fave extends Memcached_DataObject
return $fave;
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Fave', $kv);
}

View File

@ -182,25 +182,32 @@ class File extends Memcached_DataObject
static function url($filename)
{
$path = common_config('attachments', 'path');
if(common_config('site','private')) {
if ($path[strlen($path)-1] != '/') {
$path .= '/';
return common_local_url('getfile',
array('filename' => $filename));
} else {
$path = common_config('attachments', 'path');
if ($path[strlen($path)-1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/'.$path;
}
$server = common_config('attachments', 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
// XXX: protocol
return 'http://'.$server.$path.$filename;
}
if ($path[0] != '/') {
$path = '/'.$path;
}
$server = common_config('attachments', 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
// XXX: protocol
return 'http://'.$server.$path.$filename;
}
function getEnclosure(){

View File

@ -62,7 +62,7 @@ class File_to_post extends Memcached_DataObject
}
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('File_to_post', $kv);
}

View File

@ -40,7 +40,7 @@ class Group_block extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Group_block', $kv);
}

View File

@ -20,7 +20,7 @@ class Group_inbox extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Group_inbox', $kv);
}

View File

@ -21,7 +21,7 @@ class Group_member extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Group_member', $kv);
}

View File

@ -19,8 +19,6 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Memcached_DataObject extends DB_DataObject
{
/**
@ -68,7 +66,6 @@ class Memcached_DataObject extends DB_DataObject
// Clear this out so we don't accidentally break global
// state in *this* process.
$this->_DB_resultid = null;
// We don't have any local DBO refs, so clear these out.
$this->_link_loaded = false;
}
@ -93,30 +90,42 @@ class Memcached_DataObject extends DB_DataObject
unset($i);
}
$i = Memcached_DataObject::getcached($cls, $k, $v);
if ($i) {
if ($i === false) { // false == cache miss
$i = DB_DataObject::factory($cls);
if (empty($i)) {
$i = false;
return $i;
}
$result = $i->get($k, $v);
if ($result) {
// Hit!
$i->encache();
} else {
// save the fact that no such row exists
$c = self::memcache();
if (!empty($c)) {
$ck = self::cachekey($cls, $k, $v);
$c->set($ck, null);
}
$i = false;
}
}
return $i;
}
/**
* @fixme Should this return false on lookup fail to match staticGet?
*/
function pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv);
if ($i !== false) { // false == cache miss
return $i;
} else {
$i = DB_DataObject::factory($cls);
if (empty($i)) {
return false;
}
$result = $i->get($k, $v);
if ($result) {
$i->encache();
return $i;
} else {
return false;
}
}
}
function &pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv);
if ($i) {
return $i;
} else {
$i = new $cls();
foreach ($kv as $k => $v) {
$i->$k = $v;
}
@ -124,6 +133,11 @@ class Memcached_DataObject extends DB_DataObject
$i->encache();
} else {
$i = null;
$c = self::memcache();
if (!empty($c)) {
$ck = self::multicacheKey($cls, $kv);
$c->set($ck, null);
}
}
return $i;
}
@ -132,6 +146,9 @@ class Memcached_DataObject extends DB_DataObject
function insert()
{
$result = parent::insert();
if ($result) {
$this->encache(); // in case of cached negative lookups
}
return $result;
}
@ -177,6 +194,17 @@ class Memcached_DataObject extends DB_DataObject
function keyTypes()
{
// ini-based classes return number-indexed arrays. handbuilt
// classes return column => keytype. Make this uniform.
$keys = $this->keys();
$keyskeys = array_keys($keys);
if (is_string($keyskeys[0])) {
return $keys;
}
global $_DB_DATAOBJECT;
if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) {
$this->databaseStructure();
@ -188,67 +216,90 @@ class Memcached_DataObject extends DB_DataObject
function encache()
{
$c = $this->memcache();
if (!$c) {
return false;
} else {
$pkey = array();
$pval = array();
$types = $this->keyTypes();
ksort($types);
foreach ($types as $key => $type) {
if ($type == 'K') {
$pkey[] = $key;
$pval[] = $this->$key;
} else {
$c->set($this->cacheKey($this->tableName(), $key, $this->$key), $this);
}
}
# XXX: should work for both compound and scalar pkeys
$pvals = implode(',', $pval);
$pkeys = implode(',', $pkey);
$c->set($this->cacheKey($this->tableName(), $pkeys, $pvals), $this);
}
$keys = $this->_allCacheKeys();
foreach ($keys as $key) {
$c->set($key, $this);
}
}
function decache()
{
$c = $this->memcache();
if (!$c) {
return false;
} else {
$pkey = array();
$pval = array();
$types = $this->keyTypes();
ksort($types);
foreach ($types as $key => $type) {
if ($type == 'K') {
$pkey[] = $key;
$pval[] = $this->$key;
} else {
$c->delete($this->cacheKey($this->tableName(), $key, $this->$key));
}
}
# should work for both compound and scalar pkeys
# XXX: comma works for now but may not be safe separator for future keys
$pvals = implode(',', $pval);
$pkeys = implode(',', $pkey);
$c->delete($this->cacheKey($this->tableName(), $pkeys, $pvals));
}
$keys = $this->_allCacheKeys();
foreach ($keys as $key) {
$c->delete($key, $this);
}
}
function _allCacheKeys()
{
$ckeys = array();
$types = $this->keyTypes();
ksort($types);
$pkey = array();
$pval = array();
foreach ($types as $key => $type) {
assert(!empty($key));
if ($type == 'U') {
if (empty($this->$key)) {
continue;
}
$ckeys[] = $this->cacheKey($this->tableName(), $key, $this->$key);
} else if ($type == 'K' || $type == 'N') {
$pkey[] = $key;
$pval[] = $this->$key;
} else {
throw new Exception("Unknown key type $key => $type for " . $this->tableName());
}
}
assert(count($pkey) > 0);
// XXX: should work for both compound and scalar pkeys
$pvals = implode(',', $pval);
$pkeys = implode(',', $pkey);
$ckeys[] = $this->cacheKey($this->tableName(), $pkeys, $pvals);
return $ckeys;
}
function multicache($cls, $kv)
{
ksort($kv);
$c = Memcached_DataObject::memcache();
$c = self::memcache();
if (!$c) {
return false;
} else {
$pkeys = implode(',', array_keys($kv));
$pvals = implode(',', array_values($kv));
return $c->get(Memcached_DataObject::cacheKey($cls, $pkeys, $pvals));
return $c->get(self::multicacheKey($cls, $kv));
}
}
static function multicacheKey($cls, $kv)
{
ksort($kv);
$pkeys = implode(',', array_keys($kv));
$pvals = implode(',', array_values($kv));
return self::cacheKey($cls, $pkeys, $pvals);
}
function getSearchEngine($table)
{
require_once INSTALLDIR.'/lib/search_engines.php';
@ -283,7 +334,8 @@ class Memcached_DataObject extends DB_DataObject
$key_part = common_keyize($cls).':'.md5($qry);
$ckey = common_cache_key($key_part);
$stored = $c->get($ckey);
if ($stored) {
if ($stored !== false) {
return new ArrayWrapper($stored);
}

View File

@ -63,7 +63,7 @@ class Notice extends Memcached_DataObject
public $created; // datetime multiple_key not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
public $reply_to; // int(4)
public $is_local; // tinyint(1)
public $is_local; // int(4)
public $source; // varchar(32)
public $conversation; // int(4)
public $lat; // decimal(10,7)
@ -289,21 +289,11 @@ class Notice extends Memcached_DataObject
if (!empty($lat) && !empty($lon)) {
$notice->lat = $lat;
$notice->lon = $lon;
}
if (!empty($location_ns) && !empty($location_id)) {
$notice->location_id = $location_id;
$notice->location_ns = $location_ns;
} else if (!empty($location_ns) && !empty($location_id)) {
$location = Location::fromId($location_id, $location_ns);
if (!empty($location)) {
$notice->lat = $location->lat;
$notice->lon = $location->lon;
$notice->location_id = $location_id;
$notice->location_ns = $location_ns;
}
} else {
$notice->lat = $profile->lat;
$notice->lon = $profile->lon;
$notice->location_id = $profile->location_id;
$notice->location_ns = $profile->location_ns;
}
if (Event::handle('StartNoticeSave', array(&$notice))) {
@ -1217,7 +1207,7 @@ class Notice extends Memcached_DataObject
$idstr = $cache->get($idkey);
if (!empty($idstr)) {
if ($idstr !== false) {
// Cache hit! Woohoo!
$window = explode(',', $idstr);
$ids = array_slice($window, $offset, $limit);
@ -1226,7 +1216,7 @@ class Notice extends Memcached_DataObject
$laststr = $cache->get($idkey.';last');
if (!empty($laststr)) {
if ($laststr !== false) {
$window = explode(',', $laststr);
$last_id = $window[0];
$new_ids = call_user_func_array($fn, array_merge($args, array(0, NOTICE_CACHE_WINDOW,
@ -1395,7 +1385,7 @@ class Notice extends Memcached_DataObject
$ids = $this->_repeatStreamDirect($limit);
} else {
$idstr = $cache->get(common_cache_key('notice:repeats:'.$this->id));
if (!empty($idstr)) {
if ($idstr !== false) {
$ids = explode(',', $idstr);
} else {
$ids = $this->_repeatStreamDirect(100);
@ -1438,4 +1428,47 @@ class Notice extends Memcached_DataObject
return $ids;
}
function locationOptions($lat, $lon, $location_id, $location_ns, $profile = null)
{
$options = array();
if (!empty($location_id) && !empty($location_ns)) {
$options['location_id'] = $location_id;
$options['location_ns'] = $location_ns;
$location = Location::fromId($location_id, $location_ns);
if (!empty($location)) {
$options['lat'] = $location->lat;
$options['lon'] = $location->lon;
}
} else if (!empty($lat) && !empty($lon)) {
$options['lat'] = $lat;
$options['lon'] = $lon;
$location = Location::fromLatLon($lat, $lon);
if (!empty($location)) {
$options['location_id'] = $location->location_id;
$options['location_ns'] = $location->location_ns;
}
} else if (!empty($profile)) {
if (isset($profile->lat) && isset($profile->lon)) {
$options['lat'] = $profile->lat;
$options['lon'] = $profile->lon;
}
if (isset($profile->location_id) && isset($profile->location_ns)) {
$options['location_id'] = $profile->location_id;
$options['location_ns'] = $profile->location_ns;
}
}
return $options;
}
}

View File

@ -101,7 +101,7 @@ class Notice_inbox extends Memcached_DataObject
return $ids;
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Notice_inbox', $kv);
}

View File

@ -96,7 +96,7 @@ class Notice_tag extends Memcached_DataObject
}
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Notice_tag', $kv);
}

View File

@ -504,6 +504,7 @@ class Profile extends Memcached_DataObject
'Reply',
'Group_member',
);
Event::handle('ProfileDeleteRelated', array($this, &$related));
foreach ($related as $cls) {
$inst = new $cls();

View File

@ -43,7 +43,7 @@ class Profile_role extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Profile_role', $kv);
}

View File

@ -55,7 +55,7 @@ class Queue_item extends Memcached_DataObject
return null;
}
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Queue_item', $kv);
}

View File

@ -46,7 +46,7 @@ class Subscription extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function &pkeyGet($kv)
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Subscription', $kv);
}

View File

@ -996,4 +996,28 @@ class User extends Memcached_DataObject
return $ids;
}
function shareLocation()
{
$cfg = common_config('location', 'share');
if ($cfg == 'always') {
return true;
} else if ($cfg == 'never') {
return false;
} else { // user
$share = true;
$prefs = User_location_prefs::staticGet('user_id', $this->id);
if (empty($prefs)) {
$share = common_config('location', 'sharedefault');
} else {
$share = $prefs->share_location;
$prefs->free();
}
return $share;
}
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Data class for user location preferences
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Data
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class User_location_prefs extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
public $__table = 'user_location_prefs'; // table name
public $user_id; // int(4) primary_key not_null
public $share_location; // tinyint(1) default_1
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
/* Static get */
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_location_prefs',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function sequenceKey()
{
return array(false, false, false);
}
}

View File

@ -1,4 +1,3 @@
[avatar]
profile_id = 129
original = 17
@ -93,6 +92,7 @@ modified = 384
[file__keys]
id = N
url = U
[file_oembed]
file_id = 129
@ -564,4 +564,14 @@ modified = 384
[user_openid__keys]
trustroot = K
user_id = K
user_id = K
[user_location_prefs]
user_id = 129
share_location = 17
created = 142
modified = 384
[user_location_prefs__keys]
user_id = K

View File

@ -41,6 +41,20 @@ $config['site']['path'] = 'statusnet';
// Make the site invisible to non-logged-in users
// $config['site']['private'] = true;
// If your web server supports X-Sendfile (Apache with mod_xsendfile,
// lighttpd, nginx), you can enable X-Sendfile support for better
// performance. Presently, only attachment serving when the site is
// in private mode will use X-Sendfile.
// $config['site']['X-Sendfile'] = false;
// You may also need to enable X-Sendfile support for your web server and
// allow it to access files outside of the web root. For Apache with
// mod_xsendfile, you can add these to your .htaccess or server config:
//
// XSendFile on
// XSendFileAllowAbove on
//
// See http://tn123.ath.cx/mod_xsendfile/ for mod_xsendfile.
// If you want logging sent to a file instead of syslog
// $config['site']['logfile'] = '/tmp/statusnet.log';
@ -265,6 +279,7 @@ $config['sphinx']['port'] = 3312;
// $config['attachments']['user_quota'] = 50000000;
// $config['attachments']['monthly_quota'] = 15000000;
// $config['attachments']['uploads'] = true;
// $config['attachments']['path'] = "/file/";
// $config['attachments']['path'] = "/file/"; //ignored if site is private
// $config['attachments']['dir'] = INSTALLDIR . '/file/';
// $config['oohembed']['endpoint'] = 'http://oohembed.com/oohembed/';

View File

@ -84,3 +84,13 @@ create table login_token (
constraint primary key (user_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
create table user_location_prefs (
user_id integer not null comment 'user who has the preference' references user (id),
share_location tinyint default 1 comment 'Whether to share location data',
created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified',
constraint primary key (user_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;

View File

@ -587,3 +587,12 @@ create table login_token (
constraint primary key (user_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
create table user_location_prefs (
user_id integer not null comment 'user who has the preference' references user (id),
share_location tinyint default 1 comment 'Whether to share location data',
created datetime not null comment 'date this record was created',
modified timestamp comment 'date this record was modified',
constraint primary key (user_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;

View File

@ -3,7 +3,7 @@
based on the Free Software [StatusNet](http://status.net/) tool.
If you [register](%%action.register%%) for an account,
you can post small (140 chars or less) text notices
you can post small (%%site.textlimit%% chars or less) text notices
about yourself, where you are, what you're doing, or practically
anything you want. You can also subscribe to the notices of your
friends, or other people you're interested in, and follow them on the

View File

@ -1,4 +1,4 @@
%%site.name%% is a **microblogging service**. Users post short (140
%%site.name%% is a **microblogging service**. Users post short (%%site.textlimit%%
character) notices which are broadcast to their friends and fans using
the Web, RSS, or instant messages.
@ -30,4 +30,4 @@ Here are some documents that you might find helpful in understanding
* [Privacy](%%doc.privacy%%) - %%site.name%%'s privacy policy
* [Source](%%doc.source%%) - How to get the StatusNet source code
* [Badge](%%doc.badge%%) - How to put a StatusNet badge on your blog or homepage
* [Bookmarklet](%%doc.bookmarklet%%) - Bookmarklet for posting Web pages
* [Bookmarklet](%%doc.bookmarklet%%) - Bookmarklet for posting Web pages

View File

@ -20,7 +20,7 @@ Sending updates
---------------
You send updates by sending messages to %%xmpp.user%%@%%xmpp.server%%. Messages
should be less than 140 characters; longer messages will be truncated.
should be less than %%site.textlimit%% characters; longer messages will be truncated.
Commands
--------

458
extlib/lgpl-2.1.txt Normal file
View File

@ -0,0 +1,458 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

View File

@ -5,14 +5,6 @@
RewriteBase /mublog/
# If your site is private and want to only allow logged-in users to
# be able to download file attachments, uncomment this rule.
#
# If you have a custom attachment path
# ($config['attachments']['path']), change "file/" to match.
#
#RewriteRule ^file/(.*) getfile/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?p=$1 [L,QSA]

View File

@ -278,6 +278,20 @@ function main()
&& !preg_match('/rss$/', $action)
&& !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;
}

View File

@ -454,7 +454,6 @@ function showForm()
<dd>
<div class="instructions">
<p>Enter your database connection information below to initialize the database.</p>
<p>StatusNet bundles a number of libraries for ease of installation. <a href="?checklibs=true">You can see what bundled libraries you are using, versus what libraries are installed on your server.</a>
</div>
</dd>
</dl>

96
js/jquery.cookie.js Normal file
View File

@ -0,0 +1,96 @@
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};

4
js/json2.js Normal file
View File

@ -0,0 +1,4 @@
/*
http://www.JSON.org/json2.js minified
*/
if(!this.JSON){JSON={};}(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());

View File

@ -50,7 +50,11 @@ var SN = { // StatusNet
NoticeLat: 'notice_data-lat',
NoticeLon: 'notice_data-lon',
NoticeLocationId: 'notice_data-location_id',
NoticeLocationNs: 'notice_data-location_ns'
NoticeLocationNs: 'notice_data-location_ns',
NoticeGeoName: 'notice_data-geo_name',
NoticeDataGeo: 'notice_data-geo',
NoticeDataGeoCookie: 'notice_data-geo_cookie',
NoticeDataGeoSelected: 'notice_data-geo_selected'
}
},
@ -174,12 +178,13 @@ var SN = { // StatusNet
},
FormNoticeXHR: function(form) {
var NDG, NLat, NLon, NLNS, NLID;
form_id = form.attr('id');
form.append('<input type="hidden" name="ajax" value="1"/>');
form.ajaxForm({
dataType: 'xml',
timeout: '60000',
beforeSend: function(xhr) {
beforeSend: function(formData) {
if ($('#'+form_id+' #'+SN.C.S.NoticeDataText)[0].value.length === 0) {
form.addClass(SN.C.S.Warning);
return false;
@ -187,6 +192,29 @@ var SN = { // StatusNet
form.addClass(SN.C.S.Processing);
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled);
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).attr(SN.C.S.Disabled, SN.C.S.Disabled);
NLat = $('#'+SN.C.S.NoticeLat).val();
NLon = $('#'+SN.C.S.NoticeLon).val();
NLNS = $('#'+SN.C.S.NoticeLocationNs).val();
NLID = $('#'+SN.C.S.NoticeLocationId).val();
NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked');
cookieValue = $.cookie(SN.C.S.NoticeDataGeoCookie);
if (cookieValue !== null && cookieValue != 'disabled') {
cookieValue = JSON.parse(cookieValue);
NLat = $('#'+SN.C.S.NoticeLat).val(cookieValue.NLat).val();
NLon = $('#'+SN.C.S.NoticeLon).val(cookieValue.NLon).val();
NLNS = $('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS).val();
NLID = $('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID).val();
}
if (cookieValue == 'disabled') {
NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked', false).attr('checked');
}
else {
NDG = $('#'+SN.C.S.NoticeDataGeo).attr('checked', true).attr('checked');
}
return true;
},
error: function (xhr, textStatus, errorThrown) {
@ -269,6 +297,12 @@ var SN = { // StatusNet
form.removeClass(SN.C.S.Processing);
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled);
$('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
$('#'+SN.C.S.NoticeLat).val(NLat);
$('#'+SN.C.S.NoticeLon).val(NLon);
$('#'+SN.C.S.NoticeLocationNs).val(NLNS);
$('#'+SN.C.S.NoticeLocationId).val(NLID);
$('#'+SN.C.S.NoticeDataGeo).attr('checked', NDG);
}
});
},
@ -316,7 +350,42 @@ var SN = { // StatusNet
},
NoticeRepeat: function() {
$('.form_repeat').each(function() { SN.U.FormXHR($(this)); });
$('.form_repeat').each(function() {
SN.U.FormXHR($(this));
SN.U.NoticeRepeatConfirmation($(this));
});
},
NoticeRepeatConfirmation: function(form) {
function NRC() {
form.closest('.notice-options').addClass('opaque');
form.addClass('dialogbox');
form.append('<button class="close">&#215;</button>');
form.find('button.close').click(function(){
$(this).remove();
form.closest('.notice-options').removeClass('opaque');
form.removeClass('dialogbox');
form.find('.submit_dialogbox').remove();
form.find('.submit').show();
return false;
});
};
form.find('.submit').bind('click', function(e) {
e.preventDefault();
var submit = form.find('.submit').clone();
submit.addClass('submit_dialogbox');
submit.removeClass('submit');
form.append(submit);
$(this).hide();
NRC();
});
},
NoticeAttachments: function() {
@ -396,15 +465,228 @@ var SN = { // StatusNet
$('#'+SN.C.S.NoticeDataAttachSelected+' button').click(function(){
$('#'+SN.C.S.NoticeDataAttachSelected).remove();
NDA.val('');
return false;
});
});
},
NoticeLocationAttach: function() {
if(navigator.geolocation) navigator.geolocation.watchPosition(function(position) {
$('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
$('#'+SN.C.S.NoticeLon).val(position.coords.longitude);
});
var NLat = $('#'+SN.C.S.NoticeLat).val();
var NLon = $('#'+SN.C.S.NoticeLon).val();
var NLNS = $('#'+SN.C.S.NoticeLocationNs).val();
var NLID = $('#'+SN.C.S.NoticeLocationId).val();
var NLN = $('#'+SN.C.S.NoticeGeoName).text();
var NDGe = $('#'+SN.C.S.NoticeDataGeo);
function removeNoticeDataGeo() {
$('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text()));
$('#'+SN.C.S.NoticeDataGeoSelected).hide();
$('#'+SN.C.S.NoticeLat).val('');
$('#'+SN.C.S.NoticeLon).val('');
$('#'+SN.C.S.NoticeLocationNs).val('');
$('#'+SN.C.S.NoticeLocationId).val('');
$('#'+SN.C.S.NoticeDataGeo).attr('checked', false);
$.cookie(SN.C.S.NoticeDataGeoCookie, 'disabled');
}
function getJSONgeocodeURL(geocodeURL, data) {
$.getJSON(geocodeURL, data, function(location) {
var lns, lid;
if (typeof(location.location_ns) != 'undefined') {
$('#'+SN.C.S.NoticeLocationNs).val(location.location_ns);
lns = location.location_ns;
}
if (typeof(location.location_id) != 'undefined') {
$('#'+SN.C.S.NoticeLocationId).val(location.location_id);
lid = location.location_id;
}
if (typeof(location.name) == 'undefined') {
NLN_text = position.coords.latitude + ';' + position.coords.longitude;
}
else {
NLN_text = location.name;
}
$('#'+SN.C.S.NoticeGeoName)
.replaceWith('<a id="notice_data-geo_name"/>');
$('#'+SN.C.S.NoticeGeoName)
.attr('href', location.url)
.text(NLN_text)
.click(function() {
window.open(location.url);
return false;
});
$('#'+SN.C.S.NoticeLat).val(data.lat);
$('#'+SN.C.S.NoticeLon).val(data.lon);
$('#'+SN.C.S.NoticeLocationNs).val(lns);
$('#'+SN.C.S.NoticeLocationId).val(lid);
$('#'+SN.C.S.NoticeDataGeo).attr('checked', true);
var cookieValue = {
'NLat': data.lat,
'NLon': data.lon,
'NLNS': lns,
'NLID': lid,
'NLN': NLN_text,
'NLNU': location.url,
'NDG': true,
'NDGSM': false
};
$.cookie(SN.C.S.NoticeDataGeoCookie, JSON.stringify(cookieValue));
});
}
if (NDGe.length > 0) {
if ($.cookie(SN.C.S.NoticeDataGeoCookie) == 'disabled') {
NDGe.attr('checked', false);
}
else {
NDGe.attr('checked', true);
}
var NGW = $('#notice_data-geo_wrap');
var geocodeURL = NGW.attr('title');
NGW.removeAttr('title');
$('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text()));
NDGe.change(function() {
var NLN = $('#'+SN.C.S.NoticeGeoName);
if (NLN.length > 0) {
NLN.remove();
}
if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === null) {
$('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked').attr('title', NoticeDataGeoShareDisable_text);
var S = '<div id="'+SN.C.S.NoticeDataGeoSelected+'" class="'+SN.C.S.Success+'"/>';
var NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
if (NDGS.length > 0) {
NDGS.replaceWith(S);
}
else {
$('#'+SN.C.S.FormNotice).append(S);
}
NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
NDGS.prepend('<span id="'+SN.C.S.NoticeGeoName+'">Geo</span> <button class="minimize" title="'+NoticeDataGeoInfoMinimize_text+'">&#95;</button> <button class="close" title="'+NoticeDataGeoShareDisable_text+'">&#215;</button>');
var NLN = $('#'+SN.C.S.NoticeGeoName);
NLN.addClass('processing');
$('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){
removeNoticeDataGeo();
$('#'+SN.C.S.NoticeDataGeoSelected).remove();
$('#'+SN.C.S.NoticeDataText).focus();
return false;
});
$('#'+SN.C.S.NoticeDataGeoSelected+' button.minimize').click(function(){
$('#'+SN.C.S.NoticeDataGeoSelected).hide();
var cookieValue = {
'NLat': $('#'+SN.C.S.NoticeLat).val(),
'NLon': $('#'+SN.C.S.NoticeLat).val(),
'NLNS': $('#'+SN.C.S.NoticeLocationNs).val(),
'NLID': $('#'+SN.C.S.NoticeLocationId).val(),
'NLN': $('#'+SN.C.S.NoticeGeoName).text(),
'NLNU': $('#'+SN.C.S.NoticeGeoName).attr('href'),
'NDG': true,
'NDGSM': true
};
$.cookie(SN.C.S.NoticeDataGeoCookie, JSON.stringify(cookieValue));
$('#'+SN.C.S.NoticeDataText).focus();
return false;
});
if ($.cookie(SN.C.S.NoticeDataGeoCookie) === null || $.cookie(SN.C.S.NoticeDataGeoCookie) == 'disabled') {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function(position) {
$('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
$('#'+SN.C.S.NoticeLon).val(position.coords.longitude);
var data = {
'lat': position.coords.latitude,
'lon': position.coords.longitude,
'token': $('#token').val()
};
getJSONgeocodeURL(geocodeURL, data);
},
function(error) {
if (error.PERMISSION_DENIED == 1) {
removeNoticeDataGeo();
}
}
);
}
else {
if (NLat.length > 0 && NLon.length > 0) {
var data = {
'lat': NLat,
'lon': NLon,
'token': $('#token').val()
};
getJSONgeocodeURL(geocodeURL, data);
}
else {
removeNoticeDataGeo();
$('#'+SN.C.S.NoticeDataGeo).remove();
$('label[for='+SN.C.S.NoticeDataGeo+']').remove();
}
}
}
else {
var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));
if (cookieValue.NDGSM === true) {
$('#'+SN.C.S.NoticeDataGeoSelected).hide();
}
$('#'+SN.C.S.NoticeLat).val(cookieValue.NLat);
$('#'+SN.C.S.NoticeLon).val(cookieValue.NLon);
$('#'+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS);
$('#'+SN.C.S.NoticeLocationId).val(cookieValue.NLID);
$('#'+SN.C.S.NoticeDataGeo).attr('checked', cookieValue.NDG);
$('#'+SN.C.S.NoticeGeoName)
.replaceWith('<a id="notice_data-geo_name"/>');
$('#'+SN.C.S.NoticeGeoName)
.attr('href', cookieValue.NLNU)
.text(cookieValue.NLN)
.click(function() {
window.open($(this).attr('href'));
return false;
});
}
}
else {
removeNoticeDataGeo();
}
$('#'+SN.C.S.NoticeDataText).focus();
}).change();
}
},
NewDirectMessage: function() {
@ -439,13 +721,14 @@ var SN = { // StatusNet
Init: {
NoticeForm: function() {
if ($('body.user_in').length > 0) {
SN.U.NoticeLocationAttach();
$('.'+SN.C.S.FormNotice).each(function() {
SN.U.FormNoticeXHR($(this));
SN.U.FormNoticeEnhancements($(this));
});
SN.U.NoticeDataAttach();
SN.U.NoticeLocationAttach();
}
},

View File

@ -252,6 +252,8 @@ class Action extends HTMLOutputter // lawsuit
if (Event::handle('StartShowJQueryScripts', array($this))) {
$this->script('js/jquery.min.js');
$this->script('js/jquery.form.js');
$this->script('js/jquery.cookie.js');
$this->script('js/json2.js');
$this->script('js/jquery.joverlay.min.js');
Event::handle('EndShowJQueryScripts', array($this));
}
@ -735,6 +737,8 @@ class Action extends HTMLOutputter // lawsuit
_('Privacy'));
$this->menuItem(common_local_url('doc', array('title' => 'source')),
_('Source'));
$this->menuItem(common_local_url('version'),
_('Version'));
$this->menuItem(common_local_url('doc', array('title' => 'contact')),
_('Contact'));
$this->menuItem(common_local_url('doc', array('title' => 'badge')),

View File

@ -70,7 +70,7 @@ class AdminPanelAction extends Action
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
return;
return false;
}
$user = common_current_user();
@ -94,7 +94,18 @@ class AdminPanelAction extends Action
if (!$user->hasRight(Right::CONFIGURESITE)) {
$this->clientError(_('You cannot make changes to this site.'));
return;
return false;
}
// This panel must be enabled
$name = $this->trimmed('action');
$name = mb_substr($name, 0, -10);
if (!in_array($name, common_config('admin', 'panels'))) {
$this->clientError(_('Changes to that panel are not allowed.'), 403);
return false;
}
return true;
@ -224,7 +235,7 @@ class AdminPanelAction extends Action
$this->clientError(_('saveSettings() not implemented.'));
return;
}
/**
* Delete a design setting
*
@ -296,20 +307,33 @@ class AdminPanelNav extends Widget
if (Event::handle('StartAdminPanelNav', array($this))) {
$this->out->menuItem(common_local_url('siteadminpanel'), _('Site'),
_('Basic site configuration'), $action_name == 'siteadminpanel', 'nav_site_admin_panel');
if ($this->canAdmin('site')) {
$this->out->menuItem(common_local_url('siteadminpanel'), _('Site'),
_('Basic site configuration'), $action_name == 'siteadminpanel', 'nav_site_admin_panel');
}
$this->out->menuItem(common_local_url('designadminpanel'), _('Design'),
_('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel');
if ($this->canAdmin('design')) {
$this->out->menuItem(common_local_url('designadminpanel'), _('Design'),
_('Design configuration'), $action_name == 'designadminpanel', 'nav_design_admin_panel');
}
$this->out->menuItem(common_local_url('useradminpanel'), _('User'),
_('Paths configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
if ($this->canAdmin('user')) {
$this->out->menuItem(common_local_url('useradminpanel'), _('User'),
_('Paths configuration'), $action_name == 'useradminpanel', 'nav_design_admin_panel');
}
$this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
_('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
if ($this->canAdmin('paths')) {
$this->out->menuItem(common_local_url('pathsadminpanel'), _('Paths'),
_('Paths configuration'), $action_name == 'pathsadminpanel', 'nav_design_admin_panel');
}
Event::handle('EndAdminPanelNav', array($this));
}
$this->action->elementEnd('ul');
}
function canAdmin($name)
{
return in_array($name, common_config('admin', 'panels'));
}
}

View File

@ -99,6 +99,23 @@ abstract class AuthenticationPlugin extends Plugin
}
}
/**
* Internal AutoRegister event handler
* @param nickname
* @param provider_name
* @param user - the newly registered user
*/
function onAutoRegister($nickname, $provider_name, &$user)
{
if($provider_name == $this->provider_name && $this->autoregistration){
$user = $this->autoregister($nickname);
if($user){
User_username::register($user,$nickname,$this->provider_name);
return false;
}
}
}
function onStartCheckPassword($nickname, $password, &$authenticatedUser){
//map the nickname to a username
$user_username = new User_username();
@ -127,13 +144,13 @@ abstract class AuthenticationPlugin extends Plugin
}
}
}else{
if($this->autoregistration){
$authenticated = $this->checkPassword($nickname, $password);
if($authenticated){
$user = $this->autoregister($nickname);
if($user){
$authenticatedUser = $user;
User_username::register($authenticatedUser,$nickname,$this->provider_name);
$authenticated = $this->checkPassword($nickname, $password);
if($authenticated){
if(! Event::handle('AutoRegister', array($nickname, $this->provider_name, &$authenticatedUser))){
//unlike most Event::handle lines of code, this one has a ! (not)
//we want to do this if the event *was* handled - this isn't a "default" implementation
//like most code of this form.
if($authenticatedUser){
return false;
}
}
@ -190,18 +207,6 @@ abstract class AuthenticationPlugin extends Plugin
}
}
function onAutoload($cls)
{
switch ($cls)
{
case 'User_username':
require_once(INSTALLDIR.'/plugins/Authentication/User_username.php');
return false;
default:
return true;
}
}
function onCheckSchema() {
$schema = Schema::get();
$schema->ensureTable('user_username',

View File

@ -66,9 +66,6 @@ abstract class AuthorizationPlugin extends Plugin
}
//------------Below are the methods that connect StatusNet to the implementing Auth plugin------------\\
function onInitializePlugin(){
}
function onStartSetUser(&$user) {
$loginAllowed = $this->loginAllowed($user);

182
lib/cache.php Normal file
View File

@ -0,0 +1,182 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Cache interface plus default in-memory cache implementation
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Cache
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
/**
* Interface for caching
*
* An abstract interface for caching. Because we originally used the
* Memcache plugin directly, the interface uses a small subset of the
* Memcache interface.
*
* @category Cache
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class Cache
{
var $_items = array();
static $_inst = null;
/**
* Singleton constructor
*
* Use this to get the singleton instance of Cache.
*
* @return Cache cache object
*/
static function instance()
{
if (is_null(self::$_inst)) {
self::$_inst = new Cache();
}
return self::$_inst;
}
/**
* Create a cache key from input text
*
* Builds a cache key from input text. Helps to namespace
* the cache area (if shared with other applications or sites)
* and prevent conflicts.
*
* @param string $extra the real part of the key
*
* @return string full key
*/
static function key($extra)
{
$base_key = common_config('cache', 'base');
if (empty($base_key)) {
$base_key = common_keyize(common_config('site', 'name'));
}
return 'statusnet:' . $base_key . ':' . $extra;
}
/**
* Make a string suitable for use as a key
*
* Useful for turning primary keys of tables into cache keys.
*
* @param string $str string to turn into a key
*
* @return string keyized string
*/
static function keyize($str)
{
$str = strtolower($str);
$str = preg_replace('/\s/', '_', $str);
return $str;
}
/**
* Get a value associated with a key
*
* The value should have been set previously.
*
* @param string $key Lookup key
*
* @return string retrieved value or null if unfound
*/
function get($key)
{
$value = false;
if (Event::handle('StartCacheGet', array(&$key, &$value))) {
if (array_key_exists($key, $this->_items)) {
$value = unserialize($this->_items[$key]);
}
Event::handle('EndCacheGet', array($key, &$value));
}
return $value;
}
/**
* Set the value associated with a key
*
* @param string $key The key to use for lookups
* @param string $value The value to store
* @param integer $flag Flags to use, mostly ignored
* @param integer $expiry Expiry value, mostly ignored
*
* @return boolean success flag
*/
function set($key, $value, $flag=null, $expiry=null)
{
$success = false;
if (Event::handle('StartCacheSet', array(&$key, &$value, &$flag,
&$expiry, &$success))) {
$this->_items[$key] = serialize($value);
$success = true;
Event::handle('EndCacheSet', array($key, $value, $flag,
$expiry));
}
return $success;
}
/**
* Delete the value associated with a key
*
* @param string $key Key to delete
*
* @return boolean success flag
*/
function delete($key)
{
$success = false;
if (Event::handle('StartCacheDelete', array(&$key, &$success))) {
if (array_key_exists($key, $this->_items)) {
unset($this->_items[$key]);
}
$success = true;
Event::handle('EndCacheDelete', array($key));
}
return $success;
}
}

View File

@ -74,6 +74,7 @@ class ColumnDef
* @param string $key type of key
* @param value $default default value
* @param value $extra unused
* @param boolean $auto_increment
*/
function __construct($name=null, $type=null, $size=null,

View File

@ -210,6 +210,18 @@ if ($_db_name != 'statusnet' && !array_key_exists('ini_'.$_db_name, $config['db'
$config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/statusnet.ini';
}
// Backwards compatibility
if (array_key_exists('memcached', $config)) {
if ($config['memcached']['enabled']) {
addPlugin('Memcache', array('servers' => $config['memcached']['server']));
}
if (!empty($config['memcached']['base'])) {
$config['cache']['base'] = $config['memcached']['base'];
}
}
function __autoload($cls)
{
if (file_exists(INSTALLDIR.'/classes/' . $cls . '.php')) {
@ -226,6 +238,27 @@ function __autoload($cls)
}
}
// Load default plugins
foreach ($config['plugins']['default'] as $name => $params) {
if (is_null($params)) {
addPlugin($name);
} else if (is_array($params)) {
if (count($params) == 0) {
addPlugin($name);
} else {
$keys = array_keys($params);
if (is_string($keys[0])) {
addPlugin($name, $params);
} else {
foreach ($params as $paramset) {
addPlugin($name, $paramset);
}
}
}
}
}
// XXX: how many of these could be auto-loaded on use?
// XXX: note that these files should not use config options
// at compile time since DB config options are not yet loaded.

View File

@ -54,6 +54,7 @@ $default =
'dupelimit' => 60, # default for same person saying the same thing
'textlimit' => 140,
'indent' => true,
'use_x_sendfile' => false,
),
'db' =>
array('database' => 'YOU HAVE TO SET THIS IN config.php',
@ -147,11 +148,8 @@ $default =
array('enabled' => true,
'consumer_key' => null,
'consumer_secret' => null),
'memcached' =>
array('enabled' => false,
'server' => 'localhost',
'base' => null,
'port' => 11211),
'cache' =>
array('base' => null),
'ping' =>
array('notify' => array()),
'inboxes' =>
@ -226,9 +224,29 @@ $default =
'message' =>
array('contentlimit' => null),
'location' =>
array('namespace' => 1), // 1 = geonames, 2 = Yahoo Where on Earth
array('share' => 'user', // whether to share location; 'always', 'user', 'never'
'sharedefault' => true),
'omb' =>
array('timeout' => 5), // HTTP request timeout in seconds when contacting remote hosts for OMB updates
'logincommand' =>
array('disabled' => true),
'plugins' =>
array('default' => array('LilUrl' => array('shortenerName'=>'ur1.ca',
'freeService' => true,
'serviceUrl'=>'http://ur1.ca/'),
'PtitUrl' => array('shortenerName' => 'ptiturl.com',
'serviceUrl' => 'http://ptiturl.com/?creer=oui&action=Reduire&url=%1$s'),
'SimpleUrl' => array(array('shortenerName' => 'is.gd', 'serviceUrl' => 'http://is.gd/api.php?longurl=%1$s'),
array('shortenerName' => 'snipr.com', 'serviceUrl' => 'http://snipr.com/site/snip?r=simple&link=%1$s'),
array('shortenerName' => 'metamark.net', 'serviceUrl' => 'http://metamark.net/api/rest/simple?long_url=%1$s'),
array('shortenerName' => 'tinyurl.com', 'serviceUrl' => 'http://tinyurl.com/api-create.php?url=%1$s')),
'TightUrl' => array('shortenerName' => '2tu.us', 'freeService' => true,'serviceUrl'=>'http://2tu.us/?save=y&url=%1$s'),
'Geonames' => null,
'Mapstraction' => null,
'Linkback' => null,
'WikiHashtags' => null,
'OpenID' => null),
),
'admin' =>
array('panels' => array('design', 'site', 'user', 'paths')),
);

View File

@ -352,7 +352,7 @@ class HTMLOutputter extends XMLOutputter
{
if(Event::handle('StartScriptElement', array($this,&$src,&$type))) {
$url = parse_url($src);
if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
if( empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment']))
{
$src = common_path($src) . '?version=' . STATUSNET_VERSION;
}

View File

@ -440,7 +440,7 @@ function jabber_public_notice($notice)
// XXX: should we send out non-local messages if public,localonly
// = false? I think not
if ($public && $notice->is_local) {
if ($public && $notice->is_local == Notice::LOCAL_PUBLIC) {
$profile = Profile::staticGet($notice->profile_id);
if (!$profile) {

View File

@ -32,6 +32,21 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
// Locale category constants are usually predefined, but may not be
// on some systems such as Win32.
$LC_CATEGORIES = array('LC_CTYPE',
'LC_NUMERIC',
'LC_TIME',
'LC_COLLATE',
'LC_MONETARY',
'LC_MESSAGES',
'LC_ALL');
foreach ($LC_CATEGORIES as $key => $name) {
if (!defined($name)) {
define($name, $key);
}
}
if (!function_exists('gettext')) {
require_once("php-gettext/gettext.inc");
}
@ -283,6 +298,7 @@ function get_all_languages() {
'en' => array('q' => 1, 'lang' => 'en', 'name' => 'English (US)', 'direction' => 'ltr'),
'es' => array('q' => 1, 'lang' => 'es', 'name' => 'Spanish', 'direction' => 'ltr'),
'fi' => array('q' => 1, 'lang' => 'fi', 'name' => 'Finnish', 'direction' => 'ltr'),
'fa' => array('q' => 1, 'lang' => 'fa', 'name' => 'Persian', 'direction' => 'rtl'),
'fr-fr' => array('q' => 1, 'lang' => 'fr', 'name' => 'French', 'direction' => 'ltr'),
'ga' => array('q' => 0.5, 'lang' => 'ga', 'name' => 'Galician', 'direction' => 'ltr'),
'he' => array('q' => 0.5, 'lang' => 'he', 'name' => 'Hebrew', 'direction' => 'rtl'),

View File

@ -599,6 +599,10 @@ function mail_notify_attn($user, $notice)
$sender = $notice->getProfile();
if ($sender->id == $user->id) {
return;
}
if (!$sender->hasRight(Right::EMAILONREPLY)) {
return;
}

275
lib/mailhandler.php Normal file
View File

@ -0,0 +1,275 @@
<?php
/*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once(INSTALLDIR . '/lib/mail.php');
require_once(INSTALLDIR . '/lib/mediafile.php');
require_once('Mail/mimeDecode.php');
# FIXME: we use both Mail_mimeDecode and mailparse
# Need to move everything to mailparse
class MailHandler
{
function __construct()
{
}
function handle_message($rawmessage)
{
list($from, $to, $msg, $attachments) = $this->parse_message($rawmessage);
if (!$from || !$to || !$msg) {
$this->error(null, _('Could not parse message.'));
}
common_log(LOG_INFO, "Mail from $from to $to with ".count($attachments) .' attachment(s): ' .substr($msg, 0, 20));
$user = $this->user_from_header($from);
if (!$user) {
$this->error($from, _('Not a registered user.'));
return false;
}
if (!$this->user_match_to($user, $to)) {
$this->error($from, _('Sorry, that is not your incoming email address.'));
return false;
}
if (!$user->emailpost) {
$this->error($from, _('Sorry, no incoming email allowed.'));
return false;
}
$response = $this->handle_command($user, $from, $msg);
if ($response) {
return true;
}
$msg = $this->cleanup_msg($msg);
$msg = common_shorten_links($msg);
if (Notice::contentTooLong($msg)) {
$this->error($from, sprintf(_('That\'s too long. '.
'Max notice size is %d chars.'),
Notice::maxContent()));
}
$mediafiles = array();
foreach($attachments as $attachment){
$mf = null;
try {
$mf = MediaFile::fromFileHandle($attachment, $user);
} catch(ClientException $ce) {
$this->error($from, $ce->getMessage());
}
$msg .= ' ' . $mf->shortUrl();
array_push($mediafiles, $mf);
fclose($attachment);
}
$err = $this->add_notice($user, $msg, $mediafiles);
if (is_string($err)) {
$this->error($from, $err);
return false;
} else {
return true;
}
}
function error($from, $msg)
{
file_put_contents("php://stderr", $msg . "\n");
exit(1);
}
function user_from_header($from_hdr)
{
$froms = mailparse_rfc822_parse_addresses($from_hdr);
if (!$froms) {
return null;
}
$from = $froms[0];
$addr = common_canonical_email($from['address']);
$user = User::staticGet('email', $addr);
if (!$user) {
$user = User::staticGet('smsemail', $addr);
}
return $user;
}
function user_match_to($user, $to_hdr)
{
$incoming = $user->incomingemail;
$tos = mailparse_rfc822_parse_addresses($to_hdr);
foreach ($tos as $to) {
if (strcasecmp($incoming, $to['address']) == 0) {
return true;
}
}
return false;
}
function handle_command($user, $from, $msg)
{
$inter = new CommandInterpreter();
$cmd = $inter->handle_command($user, $msg);
if ($cmd) {
$cmd->execute(new MailChannel($from));
return true;
}
return false;
}
function respond($from, $to, $response)
{
$headers['From'] = $to;
$headers['To'] = $from;
$headers['Subject'] = "Command complete";
return mail_send(array($from), $headers, $response);
}
function log($level, $msg)
{
common_log($level, 'MailDaemon: '.$msg);
}
function add_notice($user, $msg, $mediafiles)
{
try {
$notice = Notice::saveNew($user->id, $msg, 'mail');
} catch (Exception $e) {
$this->log(LOG_ERR, $e->getMessage());
return $e->getMessage();
}
foreach($mediafiles as $mf){
$mf->attachToNotice($notice);
}
common_broadcast_notice($notice);
$this->log(LOG_INFO,
'Added notice ' . $notice->id . ' from user ' . $user->nickname);
return true;
}
function parse_message($contents)
{
$parsed = Mail_mimeDecode::decode(array('input' => $contents,
'include_bodies' => true,
'decode_headers' => true,
'decode_bodies' => true));
if (!$parsed) {
return null;
}
$from = $parsed->headers['from'];
$to = $parsed->headers['to'];
$type = $parsed->ctype_primary . '/' . $parsed->ctype_secondary;
$attachments = array();
$this->extract_part($parsed,$msg,$attachments);
return array($from, $to, $msg, $attachments);
}
function extract_part($parsed,&$msg,&$attachments){
if ($parsed->ctype_primary == 'multipart') {
if($parsed->ctype_secondary == 'alternative'){
$altmsg = $this->extract_msg_from_multipart_alternative_part($parsed);
if(!empty($altmsg)) $msg = $altmsg;
}else{
foreach($parsed->parts as $part){
$this->extract_part($part,$msg,$attachments);
}
}
} else if ($parsed->ctype_primary == 'text'
&& $parsed->ctype_secondary=='plain') {
$msg = $parsed->body;
if(strtolower($parsed->ctype_parameters['charset']) != "utf-8"){
$msg = utf8_encode($msg);
}
}else if(!empty($parsed->body)){
if(common_config('attachments', 'uploads')){
//only save attachments if uploads are enabled
$attachment = tmpfile();
fwrite($attachment, $parsed->body);
$attachments[] = $attachment;
}
}
}
function extract_msg_from_multipart_alternative_part($parsed){
foreach ($parsed->parts as $part) {
$this->extract_part($part,$msg,$attachments);
}
//we don't want any attachments that are a result of this parsing
return $msg;
}
function unsupported_type($type)
{
$this->error(null, "Unsupported message type: " . $type);
}
function cleanup_msg($msg)
{
$lines = explode("\n", $msg);
$output = '';
foreach ($lines as $line) {
// skip quotes
if (preg_match('/^\s*>.*$/', $line)) {
continue;
}
// skip start of quote
if (preg_match('/^\s*On.*wrote:\s*$/', $line)) {
continue;
}
// probably interesting to someone, not us
if (preg_match('/^\s*Sent via/', $line)) {
continue;
}
if (preg_match('/^\s*Sent from my/', $line)) {
continue;
}
// skip everything after a sig
if (preg_match('/^\s*--+\s*$/', $line) ||
preg_match('/^\s*__+\s*$/', $line))
{
break;
}
// skip everything after Outlook quote
if (preg_match('/^\s*-+\s*Original Message\s*-+\s*$/', $line)) {
break;
}
// skip everything after weird forward
if (preg_match('/^\s*Begin\s+forward/', $line)) {
break;
}
$output .= ' ' . $line;
}
preg_replace('/\s+/', ' ', $output);
return trim($output);
}
}

View File

@ -110,6 +110,8 @@ class NoticeForm extends Form
$this->user = common_current_user();
}
$this->profile = $this->user->getProfile();
if (common_config('attachments', 'uploads')) {
$this->enctype = 'multipart/form-data';
}
@ -198,12 +200,22 @@ class NoticeForm extends Form
$this->out->hidden('notice_return-to', $this->action, 'returnto');
}
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
$this->out->hidden('notice_data-lat', empty($this->lat) ? null : $this->lat, 'lat');
$this->out->hidden('notice_data-lon', empty($this->lon) ? null : $this->lon, 'lon');
$this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id');
$this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns');
Event::handle('StartShowNoticeFormData', array($this));
if ($this->user->shareLocation()) {
$this->out->hidden('notice_data-lat', empty($this->lat) ? (empty($this->profile->lat) ? null : $this->profile->lat) : $this->lat, 'lat');
$this->out->hidden('notice_data-lon', empty($this->lon) ? (empty($this->profile->lon) ? null : $this->profile->lon) : $this->lon, 'lon');
$this->out->hidden('notice_data-location_id', empty($this->location_id) ? (empty($this->profile->location_id) ? null : $this->profile->location_id) : $this->location_id, 'location_id');
$this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? (empty($this->profile->location_ns) ? null : $this->profile->location_ns) : $this->location_ns, 'location_ns');
$this->out->elementStart('div', array('id' => 'notice_data-geo_wrap',
'title' => common_local_url('geocode')));
$this->out->checkbox('notice_data-geo', _('Share my location'), true);
$this->out->elementEnd('div');
$this->out->inlineScript(' var NoticeDataGeoShareDisable_text = "'._('Do not share my location.').'";'.
' var NoticeDataGeoInfoMinimize_text = "'._('Hide this info').'";');
}
Event::handle('EndShowNoticeFormData', array($this));
}
}

View File

@ -379,7 +379,7 @@ class NoticeListItem extends Widget
function showNoticeLink()
{
if($this->notice->is_local){
if($this->notice->is_local == Notice::LOCAL_PUBLIC || $this->notice->is_local == Notice::LOCAL_NONPUBLIC){
$noticeurl = common_local_url('shownotice',
array('notice' => $this->notice->id));
}else{

View File

@ -21,7 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
function ping_broadcast_notice($notice) {
if (!$notice->is_local) {
if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) {
return true;
}
@ -115,4 +115,4 @@ function ping_notice_tags($notice) {
return implode('|', $tags);
}
return NULL;
}
}

View File

@ -104,5 +104,16 @@ class Plugin
{
$this->log(LOG_DEBUG, $msg);
}
function onPluginVersion(&$versions)
{
$cls = get_class($this);
$name = mb_substr($cls, 0, -6);
$versions[] = array('name' => $name,
'version' => _('Unknown'));
return true;
}
}

View File

@ -104,7 +104,7 @@ class RepeatForm extends Form
*/
function formLegend()
{
$this->out->element('legend', null, _('Repeat this notice'));
$this->out->element('legend', null, _('Repeat this notice?'));
}
/**
@ -129,7 +129,7 @@ class RepeatForm extends Form
function formActions()
{
$this->out->submit('repeat-submit-' . $this->notice->id,
_('Repeat'), 'submit', null, _('Repeat this notice'));
_('Yes'), 'submit', null, _('Repeat this notice'));
}
/**

View File

@ -100,7 +100,10 @@ class Router
'sandbox', 'unsandbox',
'silence', 'unsilence',
'repeat',
'deleteuser');
'deleteuser',
'geocode',
'version',
);
foreach ($main as $a) {
$m->connect('main/'.$a, array('action' => $a));

View File

@ -523,6 +523,14 @@ class Schema
} else {
$sql .= ($cd->nullable) ? "null " : "not null ";
}
if (!empty($cd->auto_increment)) {
$sql .= " auto_increment ";
}
if (!empty($cd->extra)) {
$sql .= "{$cd->extra} ";
}
return $sql;
}

View File

@ -62,7 +62,7 @@ function common_init_language()
// gettext will still select the right language.
$language = common_language();
$locale_set = common_init_locale($language);
setlocale(LC_CTYPE, 'C');
// So we do not have to make people install the gettext locales
$path = common_config('site','locale_path');
@ -1404,41 +1404,17 @@ function common_session_token()
function common_cache_key($extra)
{
$base_key = common_config('memcached', 'base');
if (empty($base_key)) {
$base_key = common_keyize(common_config('site', 'name'));
}
return 'statusnet:' . $base_key . ':' . $extra;
return Cache::key($extra);
}
function common_keyize($str)
{
$str = strtolower($str);
$str = preg_replace('/\s/', '_', $str);
return $str;
return Cache::keyize($str);
}
function common_memcache()
{
static $cache = null;
if (!common_config('memcached', 'enabled')) {
return null;
} else {
if (!$cache) {
$cache = new Memcache();
$servers = common_config('memcached', 'server');
if (is_array($servers)) {
foreach($servers as $server) {
$cache->addServer($server);
}
} else {
$cache->addServer($servers);
}
}
return $cache;
}
return Cache::instance();
}
function common_license_terms($uri)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More