public function join() { extract($_POST); if ($password != $password_again) { throw new Error("Passwords do not match"); } if (strlen($password) < 6) { throw new Error("Oops, please enter a password at least 6 characters long."); } if (!preg_match('#^[a-zA-Z0-9_.]+$#', $username)) { throw new Error("Oops, please enter a username composed letters, numbers, periods or underscores."); } $userexists = $this->server->db->value($this->sql['checkuser'], array('username' => $username)); if ($userexists) { throw new Error('Sorry, that username has already been taken. Please choose again.'); } $emailexists = $this->server->db->value($this->sql['checkemail'], array('email' => $email)); if ($emailexists) { throw new Error('Sorry, that email has already been used. You can use the password retrieval form to retrieve your username.'); } $user = new User_Object(); $user->set(array('username' => $username, 'display_name' => $username, 'password' => md5($password), 'email' => $email)); $this->server->db->save($user); $this->server->user = $user; }
function get_pay_button($bill_id, $bill_sum, $bill_payment_sum) { if ($bill_payment_sum == '') { $payment_amount = $bill_sum; } else { $payment_amount = $bill_payment_sum; } $user_id = (int) $this->getSessionUserId(); $language = Multilanguage::get_current_language(); require_once SITEBILL_DOCUMENT_ROOT . '/apps/begateway/lib/begateway-api-php/lib/beGateway.php'; require_once SITEBILL_DOCUMENT_ROOT . '/apps/system/lib/system/user/user.php'; require_once SITEBILL_DOCUMENT_ROOT . '/apps/begateway/classes/currency.php'; $currency = new begateway_currency(); $order_currency = $currency->getCurrencyCode(CURRENT_CURRENCY); if ($order_currency == 'RUR') { $order_currency = 'RUB'; } $user = new User_Object(); \beGateway\Settings::$shopId = $this->site_id; \beGateway\Settings::$shopKey = $this->site_key; \beGateway\Settings::$gatewayBase = 'https://' . $this->domain_gateway; \beGateway\Settings::$checkoutBase = 'https://' . $this->domain_checkout; #\beGateway\Logger::getInstance()->setLogLevel(\beGateway\Logger::DEBUG); $transaction = new \beGateway\GetPaymentToken(); $transaction->money->setCurrency($order_currency); $transaction->money->setAmount($payment_amount); $transaction->setDescription(sprintf(Multilanguage::_('ORDER_DESCRIPTION', 'begateway'), $bill_id)); $transaction->setTrackingId($user_id . '|' . $bill_id); $transaction->setLanguage($language); $sitebill_host = $this->_protocol_scheme() . '://' . $_SERVER['HTTP_HOST'] . SITEBILL_MAIN_URL; $notification_url = $sitebill_host . '/apps/begateway/listener.php'; $notification_url = str_replace('carts.local', 'webhook.begateway.com:8443', $notification_url); $transaction->setNotificationUrl($notification_url); $transaction->setSuccessUrl($sitebill_host . '/account/balance'); $transaction->setDeclineUrl($sitebill_host . '/account/balance/?do=add_bill'); $transaction->setFailUrl($sitebill_host . '/account/balance/?do=add_bill'); $transaction->setCancelUrl($sitebill_host . '/account/balance'); $transaction->customer->setEmail($user->getEmail($user_id)); $transaction->setAddressHidden(); $response = $transaction->submit(); if ($response->isSuccess()) { $payment_params = array(); $payment_params['token'] = $response->getToken(); $payment_params['url'] = \beGateway\Settings::$checkoutBase . '/checkout'; $this->template->assign('payment_text', sprintf(Multilanguage::_('YOU_HAVE_ORDER', 'begateway'), (string) $payment_amount, $this->getConfigValue('ue_name'))); $this->template->assign('payment_button', Multilanguage::_('PAYMENT_BUTTON', 'begateway')); $this->template->assign('payment_description', $this->description[$language]); $this->template->assign('payment_params', $payment_params); } else { $this->template->assign('payment_error', Multilanguage::_('PAYMENT_ERROR', 'system') . '<br>' . $response->getMessage()); } return $this->template->fetch(SITEBILL_DOCUMENT_ROOT . '/apps/begateway/site/template/pay_form.tpl'); }
/** * Edit action * * @param string $login */ public function edit_action($id = NULL) { $id or $id = $this->user->id; $user = new User_Object(); $user->id = $id; if (!$user->find()) { return event('404'); } $this->hookUserEditMenu($user); // $user->navbar()->show(); $form = new Form('User/forms/profile'); $user->password = ''; $this->input->post('avatar') !== NULL && ($user->object()->avatar = ''); $form->object($user); if ($user->id == 1) { $form->delete->options->render = FALSE; } if ($result = $form->result()) { if ($result->delete && access('User.delete', $user)) { if ($user->delete()) { flash_success(t('Пользователь <b>%s</b> был удалён!', $user->login)); redirect(l('/admin/users')); } } $user->object()->extend($result); if ($result->password) { $user->hashPassword(); } else { unset($user->password); } if ($user->update()) { success(t('Изменения сохранены!')); redirect(l(TRUE)); } } $form->show(); }
<? $user = new User_Object($item->aid)?> <div class="comment" id="comment-<?php echo $item->id; ?> "> <div class="comment-info"> <? $comment_info = new Stack('comment.info'); $comment_info->avatar = $user->getAvatarLinked();; $comment_info->author = $user->getLink(); $comment_info->time = '<span class="time">'.icon('time').' '.df($item->created_date).'</span>'; echo $comment_info; ?> </div> <div class="comment-body"><?php echo $item->body; ?> </div> </div>
public function receive() { extract($_REQUEST); $f = fopen(dirname(__FILE__) . "/sms.log", "a"); fwrite($f, "[RECEIVE]\n"); fwrite($f, "Phone: {$phone}\n"); fwrite($f, "Message: {$msg}\n"); fwrite($f, "Action: {$action}\n"); fwrite($f, "=====\n\n"); fflush($f); fclose($f); $artworkid = trim($msg); Artwork::store_artwork_by_id($artworkid); $artwork = $this->server->moma->load("artwork({$artworkid})"); if ($artwork) { list($user, $new) = $this->userByPhone($phone); extract($user); $userid = $id; $args = compact('userid', 'artworkid'); $count = $this->server->moma->value("SELECT COUNT(*) FROM savedartwork WHERE userid=:userid AND artworkid=:artworkid", $args); if ($count == 0) { $savedartwork = new SavedArtWork_Object(); $savedartwork->set(compact('userid', 'artworkid')); $this->server->moma->save($savedartwork); } $artwork = $artwork->get(); $title = $artwork['title']; if (!$dontremind) { $updateuser = new User_Object(); $updateuser->set($user); $updateuser->set('dontremind', 1); $this->server->moma->save($updateuser); if ($username == '') { sendsms($normalized_phone, "Hey there. '{$title}' was just saved for you. Go to moma.org/txt to retrieve it and any other works you collect. See you there!"); } else { sendsms($normalized_phone, "Hey {$username}. '{$title}' was added to your collection. You will find it and any other work you collect on moma.org. See you there!"); } } } else { sendsms($phone, "{$artworkid} does not refer to any item in our database. Please verify the number and try again."); } }
/** * Add a new user */ public function admin_add() { $form = new Form('User.register'); if ($data = $form->result()) { $user = new User_Object(FALSE); $user->object($data); $user->hashPassword(); $user->save(); info('User was successfully registered!', 'Registration succeed.'); } else { append('content', $form->render()); } }
<div class="page"> <div class="page-title"> <? $title = new Stack('Page.title') ?> <? $title->name = '<h1>' . ($item->in_grid ? HTML::a($item->getUrl(), $item->name) : $item->name) . '</h1>' ?> <? if ($cogear->user->id === $item->aid OR access('pages edit_all')) { $title->edit = HTML::a(Url::gear('pages') . 'edit/' . $item->id, t('[edit]'),array('class'=>'edit')); } ?> <?php echo $title; ?> </div> <div class="page-content"> <?php echo $item->body; ?> </div> <div class="page-info"> <? $info = new Stack('Page.info'); $info->object($item); $info->created_date = '<span class="created_date">' . df($item->created_date) . '</span>' ?> <? $user = new User_Object($item->aid); $info->author = '<span class="author">' .$user->getAvatarLinked().' '.$user->getLink() . '</span>'; ?> <?php echo $info->render(); ?> </div> </div>
/** * Default dispatcher * * @param string $action */ public function index_action($action = '', $subaction = NULL) { if (!empty($_POST['token'])) { // Get the profile of authorized user $UserProfile = $this->api->getAuthInfo($_POST['token']); // Check for errors if (!empty($UserProfile->error_type)) { // Debug info for developer error(t($UserProfile->error_type . ": " . $UserProfile->error_message)); } elseif (empty($UserProfile)) { error(t('Temporary error with Loginza authentification.')); } else { $this->session->loginza = $UserProfile; } } if ($loginza = $this->session->loginza) { /** * There we have 3 ways of workflow * * 1. User is logged in. Add new identity to database if it's not exist. * 2. User is registred. Authorize. * 3. User is not registred. Show register form connected and fullfilled with Loginza data (login, e-mail and so on). */ $user = new Db_ORM('users_loginza'); $user->identity = $loginza->identity; // If user is logged in if ($this->user->id) { // If integration is found if ($user->find()) { // If integration belongs to the current user if ($user->uid == $this->user->id) { $user->loginza->data = json_encode($loginza); $user->update(); flash_info(t('Your integration with profile <b>%s</b> was updated successfully.', 'Loginza', $loginza->identity), t('Updated succeed.')); } else { flash_error(t('Profile <b>%s</b> is integrated with sombody else account. You cannot use it before someone would left it out.', 'Loginza', $loginza->identity), t('Update failure.')); } } else { // Create new database record $user->uid = $this->user->id; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; // Redirect to user profile redirect(Url::gear('user') . 'edit/#tab-social'); } else { // Record found → try to log in if ($user->find()) { $search = new User_Object(); $search->id = $user->uid; if ($search->find()) { $this->user->forceLogin($user->uid, 'id'); } else { flash_error(t('Cannot find user with id <b>%s</b>.', 'Loginza', $user->uid)); } $this->session->loginza = NULL; // This tiny little redirect caused error by Loginza "Invalid / empty session data! Retry auth.: // Left it where it is for memories. // Important! Do not uncomment! //back(); } else { if (!access('user register')) { return info('You don\'t have an access to registration'); } success('First step of registration is done. Please, fill some fields to complete your registration.'); $form = new Form('User.register'); $UserProfile = new Loginza_UserProfile($loginza); $tpl = new Template('Loginza.register'); $tpl->loginza = $loginza; $tpl->profile = $UserProfile; append('content', $tpl->render()); $data['login'] = $UserProfile->genFullName(); isset($loginza->email) && ($data['email'] = $loginza->email); $form->setValues($data); if ($data = $form->result()) { $this->user->object($data); $this->user->hashPassword(); if ($uid = $this->user->save()) { // Create new database record $user->uid = $uid; $user->provider = $loginza->provider; $UserProfile = new Loginza_UserProfile($loginza); isset($loginza->photo) && ($user->photo = $loginza->photo); $user->full_name = $UserProfile->genFullName(); $user->data = json_encode($loginza); $user->save(); } $this->session->loginza = NULL; flash_success('User was successfully registered! Please, check your email for further instructions.', 'Registration succeed.'); redirect(); } append('content', $form->render()); } } } }