function sendInvitations()
{
- # CSRF protection
+ // CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token. Try again, please.'));
$newpassword = $this->arg('newpassword');
$confirm = $this->arg('confirm');
- # Some validation
+ // Some validation
if (strlen($newpassword) < 6) {
// TRANS: Form validation error on page where to change password.
function showContent()
{
- # This should probably be cached rather than recalculated
+ // This should probably be cached rather than recalculated
$tags = new Notice_tag();
#Need to clear the selection and then only re-add the field
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-# You have 24 hours to claim your password
+// You have 24 hours to claim your password
define('MAX_RECOVERY_TIME', 24 * 60 * 60);
$touched = strtotime($confirm->modified);
$email = $confirm->address;
- # Burn this code
+ // Burn this code
$result = $confirm->delete();
return;
}
- # These should be reaped, but for now we just check mod time
- # Note: it's still deleted; let's avoid a second attempt!
+ // These should be reaped, but for now we just check mod time
+ // Note: it's still deleted; let's avoid a second attempt!
if ((time() - $touched) > MAX_RECOVERY_TIME) {
common_log(LOG_WARNING,
return;
}
- # If we used an outstanding confirmation to send the email,
- # it's been confirmed at this point.
+ // If we used an outstanding confirmation to send the email,
+ // it's been confirmed at this point.
if (!$user->email) {
$orig = clone($user);
}
}
- # Success!
+ // Success!
$this->setTempUser($user);
$this->showPasswordForm();
}
}
- # See if it's an unconfirmed email address
+ // See if it's an unconfirmed email address
if (!$user) {
// Warning: it may actually be legit to have multiple folks
return;
}
- # Try to get an unconfirmed email address if they used a user name
+ // Try to get an unconfirmed email address if they used a user name
if (!$user->email && !$confirm_email) {
$confirm_email = new Confirm_address();
return;
}
- # Success! We have a valid user and a confirmed or unconfirmed email address
+ // Success! We have a valid user and a confirmed or unconfirmed email address
$confirm = new Confirm_address();
$confirm->code = common_confirmation_code(128);
function resetPassword()
{
- # CSRF protection
+ // CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Form validation error message.
return;
}
- # OK, we're ready to go
+ // OK, we're ready to go
$original = clone($user);
{
$notice = new Notice();
- # XXX: cache this. Depends on how big this protocol becomes;
- # Re-doing this query every 15 seconds isn't the end of the world.
+ // XXX: cache this. Depends on how big this protocol becomes;
+ // Re-doing this query every 15 seconds isn't the end of the world.
$divider = common_sql_date(time() - $seconds);
return ($avatar) ? $avatar->url : null;
}
- # override parent to add X-SUP-ID URL
+ // override parent to add X-SUP-ID URL
function initRss($limit=0)
{
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- # We clean up the file, too
+ // We clean up the file, too
function delete()
{
$this->profilesync = 0;
}
- # Convenience methods
+ // Convenience methods
function getForeignUser()
{
$fuser = new Foreign_user();
}
}
if (count($parts) == 0) {
- # No changes
+ // No changes
return true;
}
$toupdate = implode(', ', $parts);
{
if (is_null($v)) {
$v = $k;
- # XXX: HACK!
+ // XXX: HACK!
$i = new $cls;
$keys = $i->keys();
$k = $keys[0];
$autosource = common_config('public', 'autosource');
- # Sandboxed are non-false, but not 1, either
+ // Sandboxed are non-false, but not 1, either
if (!$profile->hasRight(Right::PUBLICNOTICE) ||
($source && $autosource && in_array($source, $autosource))) {
}
- # Clear the cache for subscribed users, so they'll update at next request
- # XXX: someone clever could prepend instead of clearing the cache
+ // Clear the cache for subscribed users, so they'll update at next request
+ // XXX: someone clever could prepend instead of clearing the cache
$notice->blowOnInsert();
}
}
}
- # If we get here, oldest item in cache window is not
- # old enough for dupe limit; do direct check against DB
+ // If we get here, oldest item in cache window is not
+ // old enough for dupe limit; do direct check against DB
$notice = new Notice();
$notice->profile_id = $profile_id;
$notice->content = $content;
if (empty($profile)) {
return false;
}
- # Get the Nth notice
+ // Get the Nth notice
$notice = $profile->getNotices(common_config('throttle', 'count') - 1, 1);
if ($notice && $notice->fetch()) {
- # If the Nth notice was posted less than timespan seconds ago
+ // If the Nth notice was posted less than timespan seconds ago
if (time() - strtotime($notice->created) <= common_config('throttle', 'timespan')) {
- # Then we throttle
+ // Then we throttle
return false;
}
}
- # Either not N notices in the stream, OR the Nth was not posted within timespan seconds
+ // Either not N notices in the stream, OR the Nth was not posted within timespan seconds
return true;
}
if (common_config('public', 'localonly')) {
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
} else {
- # -1 == blacklisted, -2 == gateway (i.e. Twitter)
+ // -1 == blacklisted, -2 == gateway (i.e. Twitter)
$notice->whereAdd('is_local !='. Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !='. Notice::GATEWAY);
}
}
}
if (count($parts) == 0) {
- # No changes
+ // No changes
return true;
}
$toupdate = implode(', ', $parts);
$avatar->url = Avatar::url($filename);
$avatar->created = DB_DataObject_Cast::dateTime(); # current time
- # XXX: start a transaction here
+ // XXX: start a transaction here
if (!$this->delete_avatars() || !$avatar->insert()) {
@unlink(Avatar::path($filename));
}
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
- # We don't do a scaled one if original is our scaled size
+ // We don't do a scaled one if original is our scaled size
if (!($avatar->width == $size && $avatar->height == $size)) {
$scaled_filename = $imagefile->resize($size);
static function getTags($tagger, $tagged) {
$tags = array();
- # XXX: store this in memcached
+ // XXX: store this in memcached
$profile_tag = new Profile_tag();
$profile_tag->tagger = $tagger;
$newtags = array_unique($newtags);
$oldtags = Profile_tag::getTags($tagger, $tagged);
- # Delete stuff that's old that not in new
+ // Delete stuff that's old that not in new
$to_delete = array_diff($oldtags, $newtags);
- # Insert stuff that's in new and not in old
+ // Insert stuff that's in new and not in old
$to_insert = array_diff($newtags, $oldtags);
return true;
}
- # Return profiles with a given tag
+ // Return profiles with a given tag
static function getTagged($tagger, $tag) {
$profile = new Profile();
$profile->query('SELECT profile.* ' .
$cnt = $qi->find(true);
if ($cnt) {
- # XXX: potential race condition
- # can we force it to only update if claimed is still null
- # (or old)?
+ // XXX: potential race condition
+ // can we force it to only update if claimed is still null
+ // (or old)?
common_log(LOG_INFO, 'claiming queue item id = ' . $qi->id .
' for transport ' . $qi->transport);
$orig = clone($qi);
function notify()
{
- # XXX: add other notifications (Jabber, SMS) here
- # XXX: queue this and handle it offline
- # XXX: Whatever happens, do it in Twitter-like API, too
+ // XXX: add other notifications (Jabber, SMS) here
+ // XXX: queue this and handle it offline
+ // XXX: Whatever happens, do it in Twitter-like API, too
$this->notifyEmail();
}
$oldaliases = $this->getAliases();
- # Delete stuff that's old that not in new
+ // Delete stuff that's old that not in new
$to_delete = array_diff($oldaliases, $newaliases);
- # Insert stuff that's in new and not in old
+ // Insert stuff that's in new and not in old
$to_insert = array_diff($newaliases, $oldaliases);
if ($get_notice) {
$notice = $profile->getCurrentNotice();
if ($notice) {
- # don't get user!
+ // don't get user!
$twitter_user['status'] = $this->twitterStatusArray($notice, false);
}
}
}
if ($include_user && $profile) {
- # Don't get notice (recursive!)
+ // Don't get notice (recursive!)
$twitter_user = $this->twitterUserArray($profile, false);
$twitter_status['user'] = $twitter_user;
}
$this->element('guid', null, $entry['guid']);
$this->element('link', null, $entry['link']);
- # RSS only supports 1 enclosure per item
+ // RSS only supports 1 enclosure per item
if(array_key_exists('enclosures', $entry) and !empty($entry['enclosures'])){
$enclosure = $entry['enclosures'][0];
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
}
if (!is_null($suplink)) {
- # For FriendFeed's SUP protocol
+ // For FriendFeed's SUP protocol
$this->element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',
'href' => $suplink,
'type' => 'application/json'));
function output($user, $text)
{
- # XXX: buffer all output and send it at the end
- # XXX: even better, redirect to appropriate page
- # depending on what command was run
+ // XXX: buffer all output and send it at the end
+ // XXX: even better, redirect to appropriate page
+ // depending on what command was run
$this->out->startHTML();
$this->out->elementStart('head');
// TRANS: Title for command results.
define('NOTICE_INBOX_SOURCE_FORWARD', 4);
define('NOTICE_INBOX_SOURCE_GATEWAY', -1);
-# append our extlib dir as the last-resort place to find libs
+// append our extlib dir as the last-resort place to find libs
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib/');
}
}
-# global configuration object
+// global configuration object
require_once('PEAR.php');
require_once('PEAR/Exception.php');
{
parent::handle($args);
- # Post from the tag dropdown; redirect to a GET
+ // Post from the tag dropdown; redirect to a GET
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
common_redirect($this->selfUrl(), 303);
$this->out->elementEnd('p');
}
- # If we're on a list with an owner (subscriptions or subscribers)...
+ // If we're on a list with an owner (subscriptions or subscribers)...
if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
$this->showOwnerControls();
$this->out->elementStart('div', 'entity_actions');
$this->out->elementStart('ul');
$this->out->elementStart('li', 'entity_subscribe');
- # XXX: special-case for user looking at own
- # subscriptions page
+ // XXX: special-case for user looking at own
+ // subscriptions page
if ($user->isMember($this->group)) {
$lf = new LeaveForm($this->out, $this->group);
$lf->show();
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
+// FIXME: we use both Mail_mimeDecode and mailparse
+// Need to move everything to mailparse
class MailHandler
{
$profile = Profile::staticGet($remote->id);
$orig_remote = clone($remote);
$orig_profile = clone($profile);
- # XXX: compare current postNotice and updateProfile URLs to the ones
- # stored in the DB to avoid (possibly...) above attack
+ // XXX: compare current postNotice and updateProfile URLs to the ones
+ // stored in the DB to avoid (possibly...) above attack
} else {
$exists = false;
$remote = new Remote_profile();
return true;
}
- # Array of servers, URL => type
+ // Array of servers, URL => type
$notify = common_config('ping', 'notify');
try {
$profile = $notice->getProfile();
class Rss10Action extends Action
{
- # This will contain the details of each feed item's author and be used to generate SIOC data.
+ // This will contain the details of each feed item's author and be used to generate SIOC data.
var $creators = array();
var $limit = DEFAULT_RSS_LIMIT;
if (common_config('site', 'private')) {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
- # This header makes basic auth go
+ // This header makes basic auth go
header('WWW-Authenticate: Basic realm="StatusNet RSS"');
- # If the user hits cancel -- bam!
+ // If the user hits cancel -- bam!
$this->show_basic_auth_error();
return;
} else {
$password = $_SERVER['PHP_AUTH_PW'];
if (!common_check_user($nickname, $password)) {
- # basic authentication failed
+ // basic authentication failed
list($proxy, $ip) = common_client_ip();
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
$parts = parse_url($url);
- # If any of these parts exist, this won't work
+ // If any of these parts exist, this won't work
foreach ($bad as $badpart) {
if (array_key_exists($badpart, $parts)) {
}
}
- # We just have host and/or path
+ // We just have host and/or path
- # If it's just a host...
+ // If it's just a host...
if (array_key_exists('host', $parts) &&
(!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0))
{
$hostparts = explode('.', $parts['host']);
- # Try to catch common idiom of nickname.service.tld
+ // Try to catch common idiom of nickname.service.tld
if ((count($hostparts) > 2) &&
(strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au
{
return common_nicknamize($hostparts[0]);
} else {
- # Do the whole hostname
+ // Do the whole hostname
return common_nicknamize($parts['host']);
}
} else {
if (array_key_exists('path', $parts)) {
- # Strip starting, ending slashes
+ // Strip starting, ending slashes
$path = preg_replace('@/$@', '', $parts['path']);
$path = preg_replace('@^/@', '', $path);
$path = basename($path);
}
#
- # Build an Atom message from the notice
+ // Build an Atom message from the notice
#
$noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
$msg = $profile->nickname . ': ' . $notice->content;
);
#
- # POST the message to $config['enjit']['apiurl']
+ // POST the message to $config['enjit']['apiurl']
#
$request = HTTPClient::start();
$response = $request->post($url, null, $data);
$cnt = $wm->find(true);\r
\r
if ($cnt) {\r
- # XXX: potential race condition\r
- # can we force it to only update if claimed is still null\r
- # (or old)?\r
+ // XXX: potential race condition\r
+ // can we force it to only update if claimed is still null\r
+ // (or old)?\r
common_log(LOG_INFO, 'claiming IRC waiting message id = ' . $wm->id);\r
$orig = clone($wm);\r
$wm->claimed = common_sql_now();\r
$cnt = $wm->find(true);\r
\r
if ($cnt) {\r
- # XXX: potential race condition\r
- # can we force it to only update if claimed is still null\r
- # (or old)?\r
+ // XXX: potential race condition\r
+ // can we force it to only update if claimed is still null\r
+ // (or old)?\r
common_log(LOG_INFO, 'claiming msn waiting message id = ' . $wm->id);\r
$orig = clone($wm);\r
$wm->claimed = common_sql_now();\r
if ($user) {
oid_set_last($display);
- # XXX: commented out at @edd's request until better
- # control over how data flows from OpenID provider.
- # oid_update_user($user, $sreg);
+ // XXX: commented out at @edd's request until better
+ // control over how data flows from OpenID provider.
+ // oid_update_user($user, $sreg);
common_set_user($user);
common_real_login(true);
if (isset($_SESSION['openid_rememberme']) && $_SESSION['openid_rememberme']) {
function createNewUser()
{
- # FIXME: save invite code before redirect, and check here
+ // FIXME: save invite code before redirect, and check here
if (!Event::handle('StartRegistrationTry', array($this))) {
return;
return;
}
- # Possible race condition... let's be paranoid
+ // Possible race condition... let's be paranoid
$other = oid_get_user($canonical);
$location = '';
if (!empty($sreg['country'])) {
if ($sreg['postcode']) {
- # XXX: use postcode to get city and region
- # XXX: also, store postcode somewhere -- it's valuable!
+ // XXX: use postcode to get city and region
+ // XXX: also, store postcode somewhere -- it's valuable!
$location = $sreg['postcode'] . ', ' . $sreg['country'];
} else {
$location = $sreg['country'];
$email = $this->getEmail();
- # XXX: add language
- # XXX: add timezone
+ // XXX: add language
+ // XXX: add timezone
$args = array('nickname' => $nickname,
'email' => $email,
return;
}
- # They're legit!
+ // They're legit!
$user = User::staticGet('nickname', $nickname);
{
$url = common_get_returnto();
if ($url) {
- # We don't have to return to it again
+ // We don't have to return to it again
common_set_returnto(null);
$url = common_inject_session($url);
} else {
function bestNewNickname($display, $sreg)
{
- # Try the passed-in nickname
+ // Try the passed-in nickname
if (!empty($sreg['nickname'])) {
$nickname = $this->nicknamize($sreg['nickname']);
}
}
- # Try the full name
+ // Try the full name
if (!empty($sreg['fullname'])) {
$fullname = $this->nicknamize($sreg['fullname']);
}
}
- # Try the URL
+ // Try the URL
$from_url = $this->openidToNickname($display);
return $from_url;
}
- # XXX: others?
+ // XXX: others?
return null;
}
}
}
- # We try to use an OpenID URL as a legal StatusNet user name in this order
- # 1. Plain hostname, like http://evanp.myopenid.com/
- # 2. One element in path, like http://profile.typekey.com/EvanProdromou/
- # or http://getopenid.com/evanprodromou
+ // We try to use an OpenID URL as a legal StatusNet user name in this order
+ // 1. Plain hostname, like http://evanp.myopenid.com/
+ // 2. One element in path, like http://profile.typekey.com/EvanProdromou/
+ // or http://getopenid.com/evanprodromou
function urlToNickname($openid)
{
if (!$base) {
return null;
} else {
- # =evan.prodromou
- # or @gratis*evan.prodromou
+ // =evan.prodromou
+ // or @gratis*evan.prodromou
$parts = explode('*', substr($base, 1));
return $this->nicknamize(array_pop($parts));
}
}
}
- # Given a string, try to make it work as a nickname
+ // Given a string, try to make it work as a nickname
function nicknamize($str)
{
require_once('Auth/OpenID/SReg.php');
require_once('Auth/OpenID/MySQLStore.php');
-# About one year cookie expiry
+// About one year cookie expiry
define('OPENID_COOKIE_EXPIRY', round(365.25 * 24 * 60 * 60));
define('OPENID_COOKIE_KEY', 'lastusedopenid');
{
static $store = null;
if (!$store) {
- # Can't be called statically
+ // Can't be called statically
$user = new User();
$conn = $user->getDatabaseConnection();
$store = new Auth_OpenID_MySQLStore($conn);
$form_html = $auth_request->formMarkup($trust_root, $process_url,
$immediate, array('id' => $form_id));
- # XXX: This is cheap, but things choke if we don't escape ampersands
- # in the HTML attributes
+ // XXX: This is cheap, but things choke if we don't escape ampersands
+ // in the HTML attributes
$form_html = preg_replace('/&/', '&', $form_html);
*/
}
-# Half-assed attempt at a module-private function
+// Half-assed attempt at a module-private function
function _oid_print_instructions()
{
if (!empty($sreg['country'])) {
if ($sreg['postcode']) {
- # XXX: use postcode to get city and region
- # XXX: also, store postcode somewhere -- it's valuable!
+ // XXX: use postcode to get city and region
+ // XXX: also, store postcode somewhere -- it's valuable!
$profile->location = $sreg['postcode'] . ', ' . $sreg['country'];
} else {
$profile->location = $sreg['country'];
}
}
- # XXX save language if it's passed
- # XXX save timezone if it's passed
+ // XXX save language if it's passed
+ // XXX save timezone if it's passed
if (!$profile->update($orig_profile)) {
// TRANS: OpenID plugin server error.
*/
public function handleInput($socket)
{
- # Process the queue for as long as needed
+ // Process the queue for as long as needed
try {
common_log(LOG_DEBUG, "Servicing the XMPP queue.");
$this->stats('xmpp_process');
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
print "This script must be run from the command line\n";
exit();
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
print "This script must be run from the command line\n";
exit();
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
print "This script must be run from the command line\n";
exit();
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
print "This script must be run from the command line\n";
exit();
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
+// Abort if called from a web server
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
foreach ($config as $section => $section_value) {
foreach ($section_value as $setting => $value) {
if (have_option('v', 'verbose') || !is_array($value)) {
- # Don't print array's without the verbose flag
+ // Don't print array's without the verbose flag
printf("%-20s %-20s %s\n", $section, $setting, var_export($value, true));
}
}
if (!empty($user)) {
if (empty($user->email)) {
- # Check for unconfirmed emails
+ // Check for unconfirmed emails
$unconfirmed_email = new Confirm_address();
$unconfirmed_email->user_id = $user->id;
$unconfirmed_email->address_type = 'email';
$user->email = get_option_value('e', 'email');
$user->find(false);
if (!$user->fetch()) {
- # Check unconfirmed emails
+ // Check unconfirmed emails
$unconfirmed_email = new Confirm_address();
$unconfirmed_email->address = $user->email;
$unconfirmed_email->address_type = 'email';