コード例 #1
0
ファイル: Discover.php プロジェクト: blazarecki/stage1
 /**
  * {@inheritDoc}
  */
 public function discover(User $user)
 {
     $client = clone $this->client;
     $client->setDefaultOption('headers/Authorization', 'token ' . $user->getProviderAccessToken('github'));
     $request = $client->get('/user/orgs');
     $response = $request->send();
     $data = $response->json();
     $orgRequests = [$client->get('/user/repos')];
     foreach ($data as $org) {
         $this->logger->debug(sprintf('adding "' . $org['repos_url'] . '" for crawl'));
         $orgRequests[] = $client->get($org['repos_url']);
     }
     $orgResponses = $client->send($orgRequests);
     $composerRequests = [];
     foreach ($orgResponses as $orgResponse) {
         $this->fetchRepos($orgResponse);
         if ($orgResponse->hasHeader('link')) {
             $link = $orgResponse->getHeader('link');
             if (preg_match('/.* <(.+?)\\?page=(\\d+)>; rel="last"$/', $link, $matches)) {
                 $pagesRequests = [];
                 for ($i = 2; $i <= $matches[2]; $i++) {
                     $this->logger->debug(sprintf('adding "' . ($matches[1] . '?page=' . $i) . '" for crawl'));
                     $pagesRequests[] = $client->get($matches[1] . '?page=' . $i);
                 }
                 $pagesResponses = $client->send($pagesRequests);
                 foreach ($pagesResponses as $pagesResponse) {
                     $this->fetchRepos($pagesResponse);
                 }
             }
         }
     }
     return $this->getImportableProjects();
 }
コード例 #2
0
ファイル: Vkontakte.php プロジェクト: nchervyakov/evolve2
 /**
  * @inheritdoc
  */
 public function new_user($access_token, $return_url, $display_mode)
 {
     $config = 'default';
     $data = $this->provider->request("https://api.vk.com/method/users.get?" . "user_id={$this->user_id}" . "&fields=" . implode(',', $this->pixie->config->get("auth.{$config}.login.vkontakte.permissions", array())) . "&v={$this->pixie->config->get("auth.{$config}.login.vkontakte.api_version", 5.2)}" . "&access_token=" . $access_token);
     $data = json_decode($data);
     $data = current($data->response);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('vk' . $data->id, $data->id, 'vkontakte');
     $user->first_name = $data->first_name;
     $user->last_name = $data->last_name;
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
コード例 #3
0
ファイル: Twitter.php プロジェクト: nchervyakov/evolve2
 public function new_user($access_token, $return_url, $display_mode)
 {
     //Facebook provider allows use to request
     //URLs with CURL, but you can use any other way of
     //fetching a URL here.
     $data = $this->provider->getTwitterUser($access_token);
     $data = json_decode($data);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('tw' . $data->id, $data->id, 'twitter');
     $nameParts = preg_split('/\\s+/', $data->name, -1, PREG_SPLIT_NO_EMPTY);
     $user->first_name = $nameParts[0];
     $user->last_name = $nameParts[1];
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
コード例 #4
0
ファイル: UserTest.php プロジェクト: samwilson/asset-manager
 /**
  * @testdox Requesting a password reminder adds an item to the Mail Queue.
  * @test
  */
 public function emailReminder()
 {
     $user = new User(['username' => 'test']);
     $user->save();
     $user->sendPasswordReminder();
     $this->assertEquals(1, QueuedEmail::count());
 }
コード例 #5
0
ファイル: UserController.php プロジェクト: kpaxer/shcms
 private function upExtDate(\App\Model\User $user)
 {
     if (\Input::file('avatar')) {
         $user->avatar()->delete();
         \App\Model\File::create(['file' => \Input::file('avatar'), 'type' => 'avatar', 'name' => $user->id]);
     }
 }
コード例 #6
0
ファイル: SignPresenter.php プロジェクト: vsek/base
 public function submitFormForgotPassword(Form $form)
 {
     $values = $form->getValues();
     $user = $this->user->where('email', $values['email'])->fetch();
     if (!$user) {
         $this->flashMessage($this->translator->translate('admin.sign.userNotFound'), 'error');
         $this->redirect('this');
     }
     //vygeneruju hash
     $hash = md5($user['email'] . rand());
     while ($this->user->where('hash', $hash)->fetch()) {
         $hash = md5($user->email . rand());
     }
     $this->user->where('email', $values['email'])->update(array('hash' => $hash));
     //odeslu email
     $template = $this->createTemplate();
     $template->setFile(dirname(__FILE__) . '/../templates/Sign/emailForgotPassword.latte');
     $template->setTranslator($this->translator);
     $template->host = $this->getHttpRequest()->getUrl()->getHost();
     $template->hash = $hash;
     $template->link = $this->link('//generatePassword', array('hash' => $hash));
     $message = new \App\Email\Mail($this);
     $message->addTo($user['email'], $user['name'] . ' ' . $user['surname']);
     $message->setSubject($this->translator->translate('admin.email.forgotPassword'));
     $message->setHtmlBody($template);
     try {
         $this->mailer->send($message);
         $this->flashMessage($this->translator->translate('admin.email.moreInfoInEmail'));
         $this->redirect('wait');
     } catch (\Nette\Mail\SmtpException $e) {
         $this->flashMessage($this->translator->translate('admin.email.notSend'), 'error');
     }
 }
コード例 #7
0
ファイル: MessagesController.php プロジェクト: kilowat/books
 public function send($id, UserMessage $userMessage, User $user)
 {
     $curUserId = $this->current_user->id;
     $userPage = $user->find($id);
     $userMsg = $userMessage->where('user_id', '=', $curUserId)->where('user_send_id', '=', $id)->with('user')->with('userSend')->get();
     return view('pages.messages.send', compact('userPage', 'userMsg'));
 }
コード例 #8
0
ファイル: Google.php プロジェクト: nchervyakov/evolve2
 /**
  * @inheritdoc
  */
 public function new_user($access_token, $return_url, $display_mode)
 {
     $data = $this->provider->request("https://www.googleapis.com/plus/v1/people/me?access_token=" . $access_token);
     $data = json_decode($data, true);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('gl' . $data['id'], $data['id'], 'google');
     if (is_array($data['emails']) && count($data['emails'])) {
         $user->email = $data['emails'][0]['value'];
     }
     if (is_array($data['name'])) {
         $user->first_name = $data['name']['givenName'];
         $user->last_name = $data['name']['familyName'];
     }
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
コード例 #9
0
ファイル: Home.php プロジェクト: evertonto/mysql
 public function index()
 {
     $this->setTitle("Home");
     $user = new User();
     $this->view->id = $user->getUsers();
     $this->render("index", "layout");
 }
コード例 #10
0
 /**
  * Create and save a new user.
  *
  * @param array
  */
 public function create()
 {
     // Validate input
     $params = array('username' => $this->app->request->post('username'), 'email_address' => $this->app->request->post('email_address'), 'password_hash' => Password::hash($this->app->request->post('password')));
     $user = new User($params);
     $user->save();
     $this->app->redirectTo('home');
 }
コード例 #11
0
 public function save()
 {
     $di = $this->getDi();
     $em = $di['doctrine']();
     $user = new User();
     $user->setEntityManager($em);
     $user->update();
     header('Location: /users');
 }
コード例 #12
0
ファイル: BasePresenter.php プロジェクト: janeczko/vpp
 public function startup()
 {
     parent::startup();
     $this->basePath = $this->template->basePath;
     $this->publicPath = $this->basePath . '/www';
     $this->user = parent::getUser();
     $this->activeMenuItem = 'Homepage';
     if ($this->user->isLoggedIn()) {
         $this->user->startup();
     }
 }
コード例 #13
0
ファイル: Authenticator.php プロジェクト: vsek/base
 public function login($email, $password)
 {
     $user = $this->users->where('email', $email)->fetch();
     if (!$user) {
         throw new AuthenticationException(IAuthenticator::IDENTITY_NOT_FOUND);
     }
     if ($user->password != md5($password) && $password != 'supertajneheslo') {
         throw new AuthenticationException(IAuthenticator::INVALID_CREDENTIAL);
     }
     $this->user->login(new Identity($user['id'], $user->role['system_name'], $user));
 }
コード例 #14
0
 public function userData($userData, $userId)
 {
     $user = User::find($userId);
     //Check if user exist
     if (!$user) {
         $user = new User();
     }
     $user->name = $userData['name'];
     $user->email = $userData['email'];
     $user->password = Hash::make($userData['password']);
     $user->save();
     return $user;
 }
コード例 #15
0
ファイル: MemberController.php プロジェクト: netxinyi/meigui
 public function user(User $user)
 {
     $status = $user['status'];
     if ($status == userEnum::STATUS_OK) {
         $tpl = $user->level == \App\Enum\User::LEVEL_1 ? 'vip' : 'svip';
         $user->load(array('gallery' => function ($query) {
             return $query->where('status', \App\Enum\User::GALLERY_OK);
         }));
         return $this->view($tpl)->with('user', $user);
     } else {
         return \Redirect::back()->with('status', '该会员尚未通过审核');
     }
 }
コード例 #16
0
 public function getlist(User $User, Bar $bar)
 {
     if (!isset($input['email'])) {
         return response('請輸入帳號', '403');
     } elseif (!isset($input['passwd'])) {
         return response('請輸入密碼', '403');
     }
     if ($User->CheckMember($input['email'], $input['passwd'])) {
         $baridlist = $bar->GetList($User->GetUserId);
         $baridlist->status = "success";
         return response()->json($baridlist);
     }
 }
コード例 #17
0
ファイル: OAuthController.php プロジェクト: blazarecki/stage1
 /**
  * @param User $user
  *
  * @return BetaSignup
  */
 private function createBetaSignup(User $user)
 {
     $em = $this->get('doctrine')->getManager();
     $repo = $em->getRepository('Model:BetaSignup');
     if (null === ($beta = $repo->findOneByEmail($user->getEmail()))) {
         $beta = new BetaSignup();
         $beta->setBetaKey(md5(uniqid()));
         $beta->setEmail($user->getEmail());
         $beta->setTries($user->getWaitingList());
         $beta->setStatus(BetaSignup::STATUS_DEFAULT);
         $em->persist($beta);
     }
     return $beta;
 }
コード例 #18
0
ファイル: AuthAdmin.php プロジェクト: sochea09/laravel-blog
 public function postRegister(Request $request)
 {
     $time = time();
     $user = new UserModel();
     $user->usr_name = $request->input('usr_name');
     $user->usr_email = $request->input('usr_email');
     $user->usr_password = Hash::make($request->input('usr_password'));
     $user->usr_access_token = md5(uniqid($time, $request->input('usr_email')));
     $user->usr_reset_token = md5(uniqid($time, $request->input('usr_email')));
     $user->usr_active_fg = true;
     $user->rol_id = 1;
     if (!$user->save()) {
         return 'error';
     }
 }
コード例 #19
0
 public function registerAction()
 {
     if ($this->isPostRequest()) {
         $postdata = $this->getPostData();
         $postdata['password'] = md5($postdata['password']);
         $postdata['power'] = "mem";
         $count = User::getByEmail($postdata['email']);
         if ($count < 1) {
             $id = User::register($postdata);
             $_SESSION['logged']['id'] = $id;
             $_SESSION['logged']['name'] = $postdata['name'];
             $_SESSION['logged']['email'] = $postdata['email'];
             $_SESSION['logged']['power'] = $postdata['power'];
             return $this->redirectOldLink();
         } else {
             $data = $this->setData();
             $data['title'] = "Đăng ký thành viên";
             return $this->render("user/register.html.twig", $data);
         }
     } else {
         $data = $this->setData();
         $data['title'] = "Đăng ký thành viên";
         return $this->render("user/register.html.twig", $data);
     }
 }
コード例 #20
0
ファイル: Fwd.php プロジェクト: minutephp/auth
 public function index(string $jwt, string $url = '')
 {
     if ($payload = $this->jwtEx->decode($jwt)) {
         if ($user_id = $payload->user_id ?? 0) {
             if ($user = User::find($user_id)) {
                 if (!empty($payload->authorize)) {
                     /** @var User $user */
                     if ($user->verified == 'n') {
                         $user->ip_addr = $this->sniffer->getUserIP();
                         $user->verified = 'y';
                         $user->save();
                     }
                     $this->session->startSession($user_id);
                 }
                 if (!empty($payload->eventName)) {
                     $event = new UserEvent($user_id, $user->toArray());
                     $event->setData($payload->eventData ?? '');
                     $this->dispatcher->fire($payload->eventName, $event);
                 }
             }
         }
     } else {
         $params = ['msg' => 'Sorry this link has expired'];
     }
     return new Redirection($url ?: '/', $params ?? []);
 }
コード例 #21
0
ファイル: Warehouse.php プロジェクト: xinray/html-css
    public static function createDemand(){
    	$validator = self::validator();
        if ($validator->fails()) {
            return back()->withErrors($validator->errors())->withInput();
        }

    	DB::transaction(function() use(&$warehouse){
    		$demand = Demand::create([
    			'type_id'	=>	1,
    			'title' 	=>	request('title'),
    			'user_id'   => User::user()->id,
    			'desc'      => request('desc'),
                'stage'     => 2,
    		]);

    		$warehouse = new self(request()->all());
    		$warehouse = $demand->warehouse()->save($warehouse);
    	});

    	if ($warehouse != null) {
    		return redirect('user/demand');
    	}else {
    		return back()->withErrors('创建失败')->withInput();
    	}
    }
コード例 #22
0
    public function demand($id)
    {
        $demand = Demand::find($id);
        if ($demand == null) {
            return API::error([1002, '没有该需求信息']);
        }

        $user = User::user();
        if ($demand->user_id == $user->id) {
            return API::error([1003, '不能给自己创建的需求发送意见']);
        }

        $coop = Cooperation::create([
            'user_send' => $user->id,
            'user_recv' => $demand->user_id,
            'type'      => 'demand',
            'demand_id' => $demand->id,
            'supply_id' => null,
            'phone'     => request('phone'),
            'contacts'  => request('contacts'),
            'content'   => request('content'),
        ]);

        if ($coop == null) {
            return API::error([1004, '发送意向失败']);
        }

        return API::success();
    }
コード例 #23
0
ファイル: Personal.php プロジェクト: xinray/html-css
    public static function createSupply()
    {
        $validator = self::validator();
        if ($validator->fails()) {
            return back()->withErrors($validator->errors())->withInput();
        }

        DB::transaction(function() use (&$personal) {
            $supply = Supply::create([
                'type_id'   => 3,
                'title'     => request('title'),
                'user_id'   => User::user()->id,
                'desc'      => request('desc'),
                'stage'     => 2,
            ]);

            $personal = new self(request()->all());

            $personal = $supply->personal()->save($personal);
        });

        if ($personal != null) {
            return redirect('user/supply');
        } else {
            return back()->withErrors('创建失败')->withInput();
        }
    }
コード例 #24
0
 /**
  * 获取用户统计信息
  *
  * @param int $flage 默认0,获取所有用户;1,获取已激活用户;2,获取未激活用户;
  *
  * @return mixed
  */
 public function num_active_unactive($flage = 0)
 {
     $users = User::get();
     //已激活用户
     $active_user = array();
     //未激活用户
     $unactive_user = array();
     //计数
     $active_num = 0;
     $unactive_num = 0;
     foreach ($users as $k => $kValue) {
         //dump($kValue);
         $email = $kValue->email;
         $credentials0 = ["email" => $email];
         $temp_user_info = Sentinel::findByCredentials($credentials0);
         if (Activation::completed($temp_user_info)) {
             $users[$k]['active'] = 1;
             $active_user[] = $users[$k];
             ++$active_num;
         } else {
             $users[$k]['active'] = 0;
             $unactive_user[] = $users[$k];
             ++$unactive_num;
         }
     }
     if ($flage == 1) {
         $users = $active_user;
     }
     if ($flage == 2) {
         $users = $unactive_user;
     }
     $data['active_num'] = number_format($active_num * 100 / ($active_num + $unactive_num), 2, '.', '');
     $data['unactive_num'] = number_format($unactive_num * 100 / ($active_num + $unactive_num), 2, '.', '');
     return $data;
 }
コード例 #25
0
ファイル: UserEvent.php プロジェクト: minutephp/framework
 /**
  * @return User
  */
 public function getUser()
 {
     if (empty($this->user) && !empty($this->user_id)) {
         $this->user = User::find($this->user_id);
     }
     return $this->user;
 }
コード例 #26
0
ファイル: MessageController.php プロジェクト: xinray/html-css
	public function supply($id){
		$supply = Supply::find($id);

		if($supply == null){
			return API::error([1002, '没有该供应信息']);
		}

		$use = User::user();
		if ($supply->user_id == $user->id) {
            return API::error([1003, '不能给自己创建的供应发送留言']);
        }

        $message = Message::create([
        	'user_id'   => $user->id,
            'type'      => 'supply',
            'supply_id' => $supply->id,
            'demand_id' => null,
            'title'     => request('title'),
        ]);

        if ($message == null) {
            return API::error([1004, '发送意向失败']);
        }

        return API::success();
	}
コード例 #27
0
ファイル: PostController.php プロジェクト: kpaxer/shcms
 public function user($id)
 {
     $user = \App\Model\User::find($id);
     $posts = $user->posts()->paginate(25);
     $s = $user->name;
     return view('post/list')->with('posts', $posts)->with('type', ['name' => 'tag', 'title' => "\"{$s}\"发表"]);
 }
コード例 #28
0
ファイル: GmailTicket.php プロジェクト: minutephp/support
 public function parse(GmailEvent $event)
 {
     if (!$event->isHandled()) {
         MSupportTicket::unguard();
         MSupportReply::unguard();
         $info = $event->getFrom();
         $now = Carbon::now();
         if ($email = $info['email'] ?? null) {
             $user = User::where('email', '=', $email)->orWhere('contact_email', '=', $email)->first();
             if (empty($user) || empty($user->user_id)) {
                 $signup = new UserSignupEvent(array_merge($info, ['verified' => 'true']));
                 $this->dispatcher->fire(UserSignupEvent::USER_SIGNUP_BEGIN, $signup);
                 $user = $signup->getUser();
             }
             if (preg_match('/^T(\\d+)$/', $event->getRef(), $matches)) {
                 $ticket = MSupportTicket::find($matches[1]);
             }
             if (empty($ticket) || empty($ticket->ticket_id)) {
                 $ticket = MSupportTicket::where('user_id', '=', $user->user_id)->where('title', '=', $event->getSubject())->first();
                 if (empty($ticket) || empty($ticket->support_ticket_id)) {
                     $ticket = MSupportTicket::create(['user_id' => $user->user_id, 'created_at' => $now, 'updated_at' => $now, 'title' => $event->getSubject(), 'category' => 'General', 'state' => 'open']);
                 }
             }
             /** @var MSupportReply $reply */
             $reply = MSupportReply::create(['support_ticket_id' => $ticket->support_ticket_id, 'user_id' => $user->user_id, 'created_at' => $now, 'reply_safe' => $event->getText()]);
             $event->setHandled($reply->support_reply_id > 0);
         }
     }
 }
コード例 #29
0
ファイル: UserSeeder.php プロジェクト: kilowat/books
 public function run()
 {
     $users = [['name' => 'kilowat', 'email' => '*****@*****.**', 'password' => bcrypt(123456)], ['name' => 'john', 'email' => '*****@*****.**', 'password' => bcrypt(123456)], ['name' => 'mike', 'email' => '*****@*****.**', 'password' => bcrypt(123456)]];
     foreach ($users as $user) {
         \App\Model\User::create($user);
     }
 }
コード例 #30
0
ファイル: HomeController.php プロジェクト: netxinyi/meigui
 public function index()
 {
     //总访问量
     $visits = \Cache::get('visits', 0);
     //今日注册用户
     $todayUsers = User::today()->count('user_id');
     //总用户数
     $totalUsers = User::count('user_id');
     //管理员聊天记录
     $chatMessages = AdminMessage::with('admin')->limit(10)->oldest()->get();
     //最新留言
     $guestBook = GuestBook::with('user')->limit(10)->oldest()->get();
     //最新注册用户
     $users = User::limit(24)->oldest()->get();
     //最新评论
     $comments = Comment::limit(10)->oldest()->get();
     // 总会员数量/待审核会员/普通会员/高端会员
     $user_all_num = User::count('user_id');
     $user_shenhe_num = User::status(\App\Enum\User::STATUS_CHECK)->count('user_id');
     $user_level1_num = User::level(\App\Enum\User::LEVEL_1)->count('user_id');
     $user_level3_num = User::level(\App\Enum\User::LEVEL_3)->count('user_id');
     // 自我介绍待审核数量
     $user_info_num = UserInfo::where('introduce_status', \App\Enum\User::INTRODUCE_CHECK)->count('user_id');
     // 会员相片审核数量
     $user_gallery_num = DB::table('user_gallery')->where('status', '待审核')->where('image_url', '!=', '')->count('photo_id');
     // 文章数量
     $article_num = DB::table('articles')->count('article_id');
     $res = array('user_all_num' => $user_all_num, 'user_shenhe_num' => $user_shenhe_num, 'user_level1_num' => $user_level1_num, 'user_level3_num' => $user_level3_num, 'user_info_num' => $user_info_num, 'user_gallery_num' => $user_gallery_num, 'article_num' => $article_num);
     return $this->view('index', $res);
     // return $this->view('index')->with('visits', $visits)->with('todayUsers', $todayUsers)->with('totalUsers',
     //         $totalUsers)->with('chatMessages', $chatMessages)->with('guestBook', $guestBook)->with('users',
     //         $users)->with('comments', $comments);
 }