Set time limit to increase time backupaccount can take
Wills till run out of memory probably, we should fix that.
This commit is contained in:
parent
9fcfb7cb1d
commit
19b743a9f5
|
@ -28,11 +28,7 @@
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
// This check helps protect against security problems;
|
|
||||||
// your code file can't be executed directly from the web.
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download a backup of your own account to the browser
|
* Download a backup of your own account to the browser
|
||||||
|
@ -48,38 +44,19 @@ if (!defined('STATUSNET')) {
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class BackupaccountAction extends Action
|
class BackupaccountAction extends FormAction
|
||||||
{
|
{
|
||||||
/**
|
protected $form = 'BackupAccount';
|
||||||
* Returns the title of the page
|
|
||||||
*
|
|
||||||
* @return string page title
|
|
||||||
*/
|
|
||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
// TRANS: Title for backup account page.
|
// TRANS: Title for backup account page.
|
||||||
return _('Backup account');
|
return _('Backup account');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doPreparation()
|
||||||
* For initializing members of the class.
|
|
||||||
*
|
|
||||||
* @param array $argarray misc. arguments
|
|
||||||
*
|
|
||||||
* @return boolean true
|
|
||||||
*/
|
|
||||||
function prepare($argarray)
|
|
||||||
{
|
{
|
||||||
parent::prepare($argarray);
|
if (!$this->scoped->hasRight(Right::BACKUPACCOUNT)) {
|
||||||
|
|
||||||
$cur = common_current_user();
|
|
||||||
|
|
||||||
if (empty($cur)) {
|
|
||||||
// TRANS: Client exception thrown when trying to backup an account while not logged in.
|
|
||||||
throw new ClientException(_('Only logged-in users can backup their account.'), 403);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$cur->hasRight(Right::BACKUPACCOUNT)) {
|
|
||||||
// TRANS: Client exception thrown when trying to backup an account without having backup rights.
|
// TRANS: Client exception thrown when trying to backup an account without having backup rights.
|
||||||
throw new ClientException(_('You may not backup your account.'), 403);
|
throw new ClientException(_('You may not backup your account.'), 403);
|
||||||
}
|
}
|
||||||
|
@ -87,40 +64,11 @@ class BackupaccountAction extends Action
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function doPost()
|
||||||
* Handler method
|
|
||||||
*
|
|
||||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function handle($argarray=null)
|
|
||||||
{
|
{
|
||||||
parent::handle($argarray);
|
$stream = new UserActivityStream($this->scoped->getUser(), true, UserActivityStream::OUTPUT_RAW);
|
||||||
|
|
||||||
if ($this->isPost()) {
|
header('Content-Disposition: attachment; filename='.urlencode($this->scoped->getNickname()).'.atom');
|
||||||
$this->sendFeed();
|
|
||||||
} else {
|
|
||||||
$this->showPage();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a feed of the user's activities to the browser
|
|
||||||
*
|
|
||||||
* Uses the UserActivityStream class; may take a long time!
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function sendFeed()
|
|
||||||
{
|
|
||||||
$cur = common_current_user();
|
|
||||||
|
|
||||||
$stream = new UserActivityStream($cur, true, UserActivityStream::OUTPUT_RAW);
|
|
||||||
|
|
||||||
header('Content-Disposition: attachment; filename='.$cur->nickname.'.atom');
|
|
||||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||||
|
|
||||||
// @fixme atom feed logic is in getString...
|
// @fixme atom feed logic is in getString...
|
||||||
|
@ -128,39 +76,6 @@ class BackupaccountAction extends Action
|
||||||
$this->raw($stream->getString());
|
$this->raw($stream->getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a little form so that the person can request a backup.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
|
|
||||||
function showContent()
|
|
||||||
{
|
|
||||||
$form = new BackupAccountForm($this);
|
|
||||||
$form->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if read only.
|
|
||||||
*
|
|
||||||
* MAY override
|
|
||||||
*
|
|
||||||
* @param array $args other arguments
|
|
||||||
*
|
|
||||||
* @return boolean is read only action?
|
|
||||||
*/
|
|
||||||
function isReadOnly($args)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return last modified, if applicable.
|
|
||||||
*
|
|
||||||
* MAY override
|
|
||||||
*
|
|
||||||
* @return string last modified http header
|
|
||||||
*/
|
|
||||||
function lastModified()
|
function lastModified()
|
||||||
{
|
{
|
||||||
// For comparison with If-Last-Modified
|
// For comparison with If-Last-Modified
|
||||||
|
@ -168,89 +83,8 @@ class BackupaccountAction extends Action
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return etag, if applicable.
|
|
||||||
*
|
|
||||||
* MAY override
|
|
||||||
*
|
|
||||||
* @return string etag http header
|
|
||||||
*/
|
|
||||||
function etag()
|
function etag()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A form for backing up the account.
|
|
||||||
*
|
|
||||||
* @category Account
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Evan Prodromou <evan@status.net>
|
|
||||||
* @copyright 2010 StatusNet, Inc.
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
|
||||||
class BackupAccountForm extends Form
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Class of the form.
|
|
||||||
*
|
|
||||||
* @return string the form's class
|
|
||||||
*/
|
|
||||||
function formClass()
|
|
||||||
{
|
|
||||||
return 'form_profile_backup';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL the form posts to
|
|
||||||
*
|
|
||||||
* @return string the form's action URL
|
|
||||||
*/
|
|
||||||
function action()
|
|
||||||
{
|
|
||||||
return common_local_url('backupaccount');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Output form data
|
|
||||||
*
|
|
||||||
* Really, just instructions for doing a backup.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formData()
|
|
||||||
{
|
|
||||||
$msg =
|
|
||||||
// TRANS: Information displayed on the backup account page.
|
|
||||||
_('You can backup your account data in '.
|
|
||||||
'<a href="http://activitystrea.ms/">Activity Streams</a> '.
|
|
||||||
'format. This is an experimental feature and provides an '.
|
|
||||||
'incomplete backup; private account '.
|
|
||||||
'information like email and IM addresses is not backed up. '.
|
|
||||||
'Additionally, uploaded files and direct messages are not '.
|
|
||||||
'backed up.');
|
|
||||||
$this->out->elementStart('p');
|
|
||||||
$this->out->raw($msg);
|
|
||||||
$this->out->elementEnd('p');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Buttons for the form
|
|
||||||
*
|
|
||||||
* In this case, a single submit button
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function formActions()
|
|
||||||
{
|
|
||||||
$this->out->submit('submit',
|
|
||||||
// TRANS: Submit button to backup an account on the backup account page.
|
|
||||||
_m('BUTTON', 'Backup'),
|
|
||||||
'submit',
|
|
||||||
null,
|
|
||||||
// TRANS: Title for submit button to backup an account on the backup account page.
|
|
||||||
_('Backup your account.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
74
lib/backupaccountform.php
Normal file
74
lib/backupaccountform.php
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* A form for backing up the account.
|
||||||
|
*
|
||||||
|
* @category Account
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Evan Prodromou <evan@status.net>
|
||||||
|
* @copyright 2010 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
class BackupAccountForm extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Class of the form.
|
||||||
|
*
|
||||||
|
* @return string the form's class
|
||||||
|
*/
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_profile_backup';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL the form posts to
|
||||||
|
*
|
||||||
|
* @return string the form's action URL
|
||||||
|
*/
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
return common_local_url('backupaccount');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output form data
|
||||||
|
*
|
||||||
|
* Really, just instructions for doing a backup.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formData()
|
||||||
|
{
|
||||||
|
$msg =
|
||||||
|
// TRANS: Information displayed on the backup account page.
|
||||||
|
_('You can backup your account data in '.
|
||||||
|
'<a href="http://activitystrea.ms/">Activity Streams</a> '.
|
||||||
|
'format. This is an experimental feature and provides an '.
|
||||||
|
'incomplete backup; private account '.
|
||||||
|
'information like email and IM addresses is not backed up. '.
|
||||||
|
'Additionally, uploaded files and direct messages are not '.
|
||||||
|
'backed up.');
|
||||||
|
$this->out->elementStart('p');
|
||||||
|
$this->out->raw($msg);
|
||||||
|
$this->out->elementEnd('p');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Buttons for the form
|
||||||
|
*
|
||||||
|
* In this case, a single submit button
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit('submit',
|
||||||
|
// TRANS: Submit button to backup an account on the backup account page.
|
||||||
|
_m('BUTTON', 'Backup'),
|
||||||
|
'submit',
|
||||||
|
null,
|
||||||
|
// TRANS: Title for submit button to backup an account on the backup account page.
|
||||||
|
_('Backup your account.'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -108,6 +108,8 @@ class UserActivityStream extends AtomUserNoticeFeed
|
||||||
|
|
||||||
$end = time() + 1;
|
$end = time() + 1;
|
||||||
foreach ($this->objs as $obj) {
|
foreach ($this->objs as $obj) {
|
||||||
|
set_time_limit(10);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$act = $obj->asActivity();
|
$act = $obj->asActivity();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user