12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- if (!defined('GNUSOCIAL')) {
- exit(1);
- }
- class AvatarAction extends Action
- {
- public $filename;
- protected function prepare(array $args = [])
- {
- parent::prepare($args);
- if (empty($this->filename = $this->trimmed('file'))) {
-
- $this->clientError(_m('No such avatar.'), 404);
- }
- return true;
- }
- protected function handle()
- {
- parent::handle();
- if (is_string($srv = common_config('avatar', 'server')) && $srv != '') {
- common_redirect(Avatar::url($this->filename), 302);
- } else {
- $attachment = new AttachmentAction();
- $attachment->filepath = common_config('avatar', 'dir') . $this->filename;
- $attachment->sendFile();
- }
- return true;
- }
- }
|