function handle($args) { parent::handle($args); if (!Event::handle('StartRegistrationTry', array($this))) { return; } if (empty($this->token)) { $this->clientError(_('token empty')); return; } $platform_type = $this->trimmed('platform'); $this->password = "******"; switch ($platform_type) { case 'sina': $this->registerSina(); break; case 'qq': $this->registQQ(); break; default: $this->clientError(_('invalid platform type')); return; break; } }
/** * Handle the request * * Save the new group * * @param array $args $_REQUEST data (unused) * * @return void */ function handle($args) { parent::handle($args); /*if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError( // TRANS: Client error. POST is a HTTP command. It should not be translated. _('This method requires a POST.'), 200, $this->format ); return; }*/ /*if (empty($this->user)) { // TRANS: Client error given when a user was not found (404). $this->clientError(_('No such user.'), 404, $this->format); return; }*/ if ($this->validateParams() == false) { return; } $user = User::register(array('nickname' => $this->nickname, 'password' => $this->password, 'email' => $this->email, 'fullname' => $this->fullname, 'homepage' => $this->homepage, 'bio' => $this->bio, 'location' => $this->location, 'code' => $this->code)); $profile = $user->getProfile(); switch ($this->format) { case 'xml': $this->showSingleXmlUser($profile); break; case 'json': $this->showSingleJsonUser($profile); break; default: $this->clientError(_('API method not found.'), 404, $this->format); break; } }
/** * Handle the request * * @param array $args $_REQUEST data (unused) * * @return void */ function handle($args) { parent::handle($args); switch ($this->format) { case 'xml': $this->initDocument('xml'); $this->elementStart('config'); // XXX: check that all sections and settings are legal XML elements foreach ($this->keys as $section => $settings) { $this->elementStart($section); foreach ($settings as $setting) { $value = $this->setting($section, $setting); if (is_array($value)) { $value = implode(',', $value); } else { if ($value === false || $value == '0') { $value = 'false'; } else { if ($value === true || $value == '1') { $value = 'true'; } } } // return theme logo if there's no site specific one if (empty($value)) { if ($section == 'site' && $setting == 'logo') { $value = Theme::path('logo.png'); } } $this->element($setting, null, $value); } $this->elementEnd($section); } $this->elementEnd('config'); $this->endDocument('xml'); break; case 'json': $result = array(); foreach ($this->keys as $section => $settings) { $result[$section] = array(); foreach ($settings as $setting) { $result[$section][$setting] = $this->setting($section, $setting); } } $this->initDocument('json'); $this->showJsonObjects($result); $this->endDocument('json'); break; default: $this->clientError(_('API method not found.'), 404, $this->format); break; } }
protected function handle() { parent::handle(); if ($this->emailExists($this->email)) { $email_exists = 1; } else { $email_exists = 0; } $this->initDocument('json'); $this->showJsonObjects($email_exists); $this->endDocument('json'); }
protected function handle() { parent::handle(); $nickname = $this->trimmed('nickname'); try { Nickname::normalize($nickname, true); $nickname_ok = 1; } catch (NicknameException $e) { $nickname_ok = 0; } $this->initDocument('json'); $this->showJsonObjects($nickname_ok); $this->endDocument('json'); }
/** * Handle the request * * Check whether the credentials are valid and output the result * * @param array $args $_REQUEST data (unused) * * @return void */ protected function handle() { parent::handle(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError(_('This method requires a POST.'), 400, $this->format); return; } $user = common_check_user($this->arg('username'), $this->arg('password')); if ($user) { $user = true; } $this->initDocument('json'); $this->showJsonObjects($user); $this->endDocument('json'); }
function handle($args) { parent::handle($args); $notice = new Notice(); $notice->source = 'activity'; $notice->find(); while ($notice->fetch()) { $data = Notice::staticGet('id', $notice->id); $orign = clone $data; $data->content_type = NOTICE::CONTENT_TYPE_ACTIVITY; if (!$data->update($orign)) { echo 'profile update error' . $data->id; echo '<br>'; } } }
function handle($args) { parent::handle($args); $type = $this->trimmed('platform'); $this->password = "******"; switch ($type) { case 'sina': $this->bindSina(); break; case 'qq': $this->bindQQ(); break; default: $this->clientError(_('invalid platform type')); return; break; } header("Location: " . REDIREDT_WEB_URL); }
function handle($args) { parent::handle($args); $profile = new Profile(); $profile->find(); $server = common_config('site', 'server'); $path = common_config('site', 'path'); $mainpath = 'http://' . $server . '/' . $path . '/index.php/'; //'http://192.168.1.123/statusnet_copy/index.php/'; while ($profile->fetch()) { //echo $this->ID; //$store[] = $object; // builds an array of object lines. $nickname = $profile->nickname; $profileurl = $mainpath . $nickname; $data = Profile::staticGet('id', $profile->id); $orign = clone $data; $data->profileurl = $profileurl; if (!$data->update($orign)) { echo 'profile update error' . $data->id; echo '<br>'; } } }
function handle($args) { parent::handle($args); $auth = new ApiAuthAction(); $auth->checkBasicAuthUser(false); $this->user = $auth->auth_user; $type = $this->trimmed('type'); $hotResult = null; switch ($type) { case 'tags': $hotResult = $this->getHotTags(); break; case 'users': $hotResult = $this->getHotUsers(); break; default: $this->clientError(_('invalid type')); return; break; } $this->initDocument('json'); $this->showJsonObjects($hotResult); $this->endDocument('json'); }
/** * Handle a request * * @param array $args Arguments from $_REQUEST * * @return void */ function handle($args) { parent::handle($args); $this->showResults(); }
protected function handle() { parent::handle(); $this->showQvitter(); }
/** * Handle input, produce output * * Switches on request method; either shows the form or handles its input. * * @param array $args $_REQUEST data * * @return void */ function handle($args) { parent::handle($args); self::cleanRequest(); }
function handle($args) { parent::handle($args); $this->checkLogin(); }
function handle($args) { parent::handle($args); if (!Event::handle('StartRegistrationTry', array($this))) { return; } //database use nickname we change it into username for more //easier to understand $nickname = $this->trimmed('username'); $email = $this->trimmed('email'); $fullname = $this->trimmed('nickname'); $homepage = NULL; //$this->trimmed('homepage'); $bio = $this->trimmed('description'); $location = $this->trimmed('location'); $genderStr = $this->trimmed('gender'); if (!empty($bio)) { if (mb_strlen($bio) > self::MAX_DESCRIPTION) { $this->clientError(_('description must be set less than 70')); return; } } if (empty($email) && empty($nickname)) { $this->clientError(_('must set nickname or email')); return; } if (empty($nickname) && !empty($email)) { $user_email_check = User::staticGet('email', $email); if ($user_email_check) { $this->clientError(_('email exists')); return; } $nickname = $this->nicknameFromEmail($email); } // We don't trim these... whitespace is OK in a password! $password = $this->arg('password'); try { $nickname = Nickname::normalize($nickname); } catch (NicknameException $e) { $this->clientError(_('username error')); return; } if (!User::allowed_nickname($nickname)) { // TRANS: Client error displayed when trying to create a new user with an invalid username. $this->clientError(_('username bad'), 400); return; } $gender = 0; if (!empty($genderStr)) { if ($genderStr == 'f') { $gender = 1; } else { if ($genderStr == 'm') { $gender = 2; } } } $user_check = User::staticGet('nickname', $nickname); if ($user_check) { $this->clientError('username exists', 400); return; } if (empty($password)) { $this->clientError(_('password empty'), 400); return; } //no need to confirmed email $email_confirmed = !empty($email); $user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $code, 'gender' => $gender, 'email_confirmed' => $email_confirmed)); if (!$user) { // TRANS: Form validation error displayed when trying to register with an invalid username or password. $this->clientError(_('Invalid username or password.', 400, 'json')); return; } // success! if (!common_set_user($user)) { // TRANS: Server error displayed when saving fails during user registration. $this->serverError(_('Error setting user.', '500', 'json')); return; } // this is a real login common_real_login(true); if ($this->boolean('rememberme')) { common_debug('Adding rememberme cookie for ' . $nickname); common_rememberme($user); } // Re-init language env in case it changed (not yet, but soon) common_init_language(); Event::handle('EndRegistrationTry', array($this)); $resultUser = $this->twitterUserArray($user->getProfile(), false); $this->initDocument('json'); $this->showJsonObjects($resultUser); $this->endDocument('json'); }
/** * Handle a request * * @param array $args Arguments from $_REQUEST * * @return void */ function handle($args) { parent::handle($args); $this->showTrends(); }
/** * Handle a request * * @param array $args Arguments from $_REQUEST * * @return void */ function handle($args) { parent::handle($args); $this->showAtom(); }
/** * Handle the request * * @param array $args $_REQUEST data (unused) * * @return void */ protected function handle() { parent::handle(); $nickname = $this->trimmed('nickname'); $email = $this->trimmed('email'); $fullname = $this->trimmed('fullname'); $homepage = $this->trimmed('homepage'); $bio = $this->trimmed('bio'); $location = $this->trimmed('location'); // We don't trim these... whitespace is OK in a password! $password = $this->arg('password'); $confirm = $this->arg('confirm'); if (empty($this->code)) { common_ensure_session(); if (array_key_exists('invitecode', $_SESSION)) { $this->code = $_SESSION['invitecode']; } } if (common_config('site', 'inviteonly') && empty($this->code)) { // TRANS: Client error displayed when trying to register to an invite-only site without an invitation. $this->clientError(_('Sorry, only invited people can register.'), 401); } if (!empty($this->code)) { $this->invite = Invitation::getKV('code', $this->code); if (empty($this->invite)) { // TRANS: Client error displayed when trying to register to an invite-only site without a valid invitation. $this->clientError(_('Sorry, invalid invitation code.'), 401); } // Store this in case we need it common_ensure_session(); $_SESSION['invitecode'] = $this->code; } // Input scrubbing try { $nickname = Nickname::normalize($nickname, true); } catch (NicknameException $e) { // clientError handles Api exceptions with various formats and stuff $this->clientError($e->getMessage(), $e->getCode()); } $email = common_canonical_email($email); if ($email && !Validate::email($email, common_config('email', 'check_domain'))) { // TRANS: Form validation error displayed when trying to register without a valid e-mail address. $this->clientError(_('Not a valid email address.'), 400); } else { if ($this->emailExists($email)) { // TRANS: Form validation error displayed when trying to register with an already registered e-mail address. $this->clientError(_('Email address already exists.'), 400); } else { if (!is_null($homepage) && strlen($homepage) > 0 && !common_valid_http_url($homepage)) { // TRANS: Form validation error displayed when trying to register with an invalid homepage URL. $this->clientError(_('Homepage is not a valid URL.'), 400); } else { if (!is_null($fullname) && mb_strlen($fullname) > 255) { // TRANS: Form validation error displayed when trying to register with a too long full name. $this->clientError(_('Full name is too long (maximum 255 characters).'), 400); } else { if (Profile::bioTooLong($bio)) { // TRANS: Form validation error on registration page when providing too long a bio text. // TRANS: %d is the maximum number of characters for bio; used for plural. $this->clientError(sprintf(_m('Bio is too long (maximum %d character).', 'Bio is too long (maximum %d characters).', Profile::maxBio()), Profile::maxBio()), 400); } else { if (!is_null($location) && mb_strlen($location) > 255) { // TRANS: Form validation error displayed when trying to register with a too long location. $this->clientError(_('Location is too long (maximum 255 characters).'), 400); } else { if (strlen($password) < 6) { // TRANS: Form validation error displayed when trying to register with too short a password. $this->clientError(_('Password must be 6 or more characters.'), 400); } else { if ($password != $confirm) { // TRANS: Form validation error displayed when trying to register with non-matching passwords. $this->clientError(_('Passwords do not match.'), 400); } else { // annoy spammers sleep(7); try { $user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $this->code)); Event::handle('EndRegistrationTry', array($this)); $this->initDocument('json'); $this->showJsonObjects($this->twitterUserArray($user->getProfile())); $this->endDocument('json'); } catch (Exception $e) { $this->clientError($e->getMessage(), 400); } } } } } } } } } }
/** * Handle the request * * @param array $args $_REQUEST data (unused) * * @return void */ protected function handle() { parent::handle(); $noticeurl = common_path('notice/', StatusNet::isHTTPS()); $instanceurl = common_path('', StatusNet::isHTTPS()); // remove protocol for the comparison below $noticeurl_wo_protocol = preg_replace('(^https?://)', '', $noticeurl); $instanceurl_wo_protocol = preg_replace('(^https?://)', '', $instanceurl); $url_wo_protocol = preg_replace('(^https?://)', '', $this->url); // find local notice if (strpos($url_wo_protocol, $noticeurl_wo_protocol) === 0) { $possible_notice_id = str_replace($noticeurl_wo_protocol, '', $url_wo_protocol); if (ctype_digit($possible_notice_id)) { $notice = Notice::getKV('id', $possible_notice_id); } else { $this->clientError("Notice not found.", 404); } } if (!$notice instanceof Notice) { // TRANS: Client error displayed in oEmbed action when notice not found. // TRANS: %s is a notice. $this->clientError(sprintf(_("Notice %s not found."), $this->id), 404); } $profile = $notice->getProfile(); if (!$profile instanceof Profile) { // TRANS: Server error displayed in oEmbed action when notice has not profile. $this->serverError(_('Notice has no profile.'), 500); } $authorname = $profile->getFancyName(); $oembed = array(); $oembed['version'] = '1.0'; $oembed['provider_name'] = common_config('site', 'name'); $oembed['provider_url'] = common_root_url(); $oembed['type'] = 'link'; // TRANS: oEmbed title. %1$s is the author name, %2$s is the creation date. $oembed['title'] = ApiAction::dateTwitter($notice->created) . ' (Qvitter)'; $oembed['author_name'] = $authorname; $oembed['author_url'] = $profile->profileurl; $oembed['url'] = $notice->getUrl(); $oembed['html'] = $notice->getRendered(); // maybe add thumbnail $attachments = $notice->attachments(); if (!empty($attachments)) { foreach ($attachments as $attachment) { if (is_object($attachment)) { try { $thumb = $attachment->getThumbnail(); } catch (ServerException $e) { // } if (!empty($thumb) && method_exists('File_thumbnail', 'url')) { try { $thumb_url = File_thumbnail::url($thumb->filename); $oembed['thumbnail_url'] = $thumb_url; break; // only first one } catch (ClientException $e) { // } } } } } if ($this->format == 'json') { $this->initDocument('json'); print json_encode($oembed); $this->endDocument('json'); } elseif ($this->format == 'xml') { $this->initDocument('xml'); $this->elementStart('oembed'); foreach (array('version', 'type', 'provider_name', 'provider_url', 'title', 'author_name', 'author_url', 'url', 'html') as $key) { if (isset($oembed[$key]) && $oembed[$key] != '') { $this->element($key, null, $oembed[$key]); } } $this->elementEnd('oembed'); $this->endDocument('xml'); } else { $this->serverError(sprintf(_('Format %s not supported.'), $this->format), 501); } }