/** * signup to system * @return [type] [description] */ public function post_signup() { // get parameters and set to local variables $mymobile = utility::post('mobile', 'filter'); $mypass = utility::post('password', 'hash'); $myperm = $this->option('account'); if (!$myperm) { $myperm = 'NULL'; } $user_id = \lib\db\users::signup($mymobile, $mypass, $myperm); if ($user_id) { // generate verification code // save in logs table // set SESSION verification_mobile $code = \lib\utility\filter::generate_verification_code($user_id, $mymobile); if ($code) { \lib\utility\sms::send($mymobile, 'signup', $code); debug::true(T_("Register successfully")); $this->redirector()->set_url('verification?from=signup&mobile=' . $mymobile); // $this->redirector()->set_url('login?from=signup&cp=1&mobile='.$mymobile); } else { debug::error(T_("Please contact to administrator!")); } } elseif ($user_id === false) { debug::error(T_("Mobile number exist!")); } else { debug::error(T_("Please contact to administrator!")); } }
/** * Pass a datarow of userdata and field for set in user session * if don't pass a fields name use default data for fill user session * @param [type] $_datarow [description] * @param [type] $_fields [description] */ protected function setLoginSession($_datarow, $_fields) { // set login session \lib\db\users::set_login_session($_datarow, $_fields); if (isset($_datarow['user_permission']) && is_numeric($_datarow['user_permission'])) { $this->setPermissionSession($_datarow['user_permission']); } }
private static function saveUserDetail($_type = 'contact', $_args) { switch ($_type) { case 'contact': $contact = $_args; $from = self::response('from', null); $mobile = null; // set like contact $from['user_id'] = $from['id']; // remove from values to being like contact array unset($from['id']); unset($from['username']); // if mobile isset, use it if (isset($contact['phone_number'])) { $mobile = $contact['phone_number']; unset($contact['phone_number']); } // if user send contact detail save as normal user if ($mobile) { // if this is for current user if ($from == $contact) { \lib\db\users::updateMobile(self::$user_id, $mobile); // if user send contact detail then save all of his/her profile photos self::sendResponse(['method' => 'getUserProfilePhotos']); self::sendResponse(['text' => T_('Your phone number registered successfully;)')]); } else { // set fake value for this contact self::$hook['message']['contact']['fake'] = true; self::sendResponse(['text' => T_('We dont need another users contact:?)')]); // do nothing! } } else { self::$hook['message']['contact']['fake'] = true; self::$hook['message']['contact']['phone_number'] = false; self::sendResponse(['text' => T_('We need mobile number!')]); } break; case 'location': break; default: break; } \lib\db\users::updateDetail(self::$user_id, $_type, 'telegram', $_args); }