static function createBy(User $user, array $info) { $fields = array('name', 'surname', 'address', 'phone', 'notes'); $fields = userFields($fields, 'order'); $order = with(new static())->fill_raw(array_intersect_key($info, array_flip($fields)))->fill_raw(array('password' => static::generatePassword(), 'user' => $user->id, 'manager' => \Vane\Current::config('general.new_order_manager'), 'sum' => Cart::subtotal(), 'ip' => Request::ip())); return Event::insertModel($order, 'order'); }
public function post_create() { $posts = Input::all(); $title = $posts['thread_name']; $contentRaw = $posts['inputarea']; if ($title != '' && strlen($contentRaw) > 10) { $alias = Str::slug($title, '-'); $exist = Thread::where('alias', '=', $alias)->first(); if ($exist != null) { return Redirect::to($exist->id); } $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s")); $thread = Thread::create($threadData); if ($thread != null) { $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id); $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0); $pst = Post::create($postData); if ($pst != null) { return Redirect::to($thread->id); } } } else { return Redirect::to(URL::full()); } }
/** * Validate data * * @return boolean True if data is valid */ public function check() { $this->offering_id = intval($this->offering_id); if (!$this->offering_id) { $this->setError(Lang::txt('COM_COURSES_LOGS_MUST_HAVE_OFFERING_ID')); return false; } $this->page_id = intval($this->page_id); if (!$this->page_id) { $this->setError(Lang::txt('COM_COURSES_LOGS_MUST_HAVE_PAGE_ID')); return false; } $this->ip = trim($this->ip); if (!$this->id) { $this->timestamp = Date::toSql(); if (!$this->ip) { $this->ip = Request::ip(); } if (!$this->user_id) { $this->user_id = User::get('id'); } } $this->user_id = intval($this->user_id); if (!$this->user_id) { $this->setError(Lang::txt('COM_COURSES_LOGS_MUST_HAVE_USER_ID')); return false; } return true; }
/** * Create the event handler. * @param UserProvider $userProvider * @param GroupProvider $groupProvider * @param ThrottleProvider $throttleProvider */ public function __construct(UserProvider $userProvider, GroupProvider $groupProvider, ThrottleProvider $throttleProvider) { $this->userProvider = $userProvider; $this->groupProvider = $groupProvider; $this->throttleProvider = $throttleProvider; $this->ipAddress = \Request::ip(); }
public static function ip() { $ip = Request::ip(); if (in_array($ip, array('127.0.0.1', '0.0.0.0'))) { return Config::get('locate::options.fallback_ip'); } return $ip; }
/** * Before save content method * * Article is passed by reference, but after the save, so no changes will be saved. * Method is called right after the content is saved * * @param string $context The context of the content passed to the plugin (added in 1.6) * @param object $article Model * @param boolean $isNew If the content is just about to be created * @return void * @since 2.5 */ public function onContentBeforeSave($context, $article, $isNew) { if (!App::isSite()) { return; } if ($article instanceof \Hubzero\Base\Object || $article instanceof \Hubzero\Database\Relational) { $key = $this->_key($context); $content = ltrim($article->get($key)); } else { if (is_object($article) || is_array($article)) { return; } else { $content = $article; } } $content = preg_replace('/^<!-- \\{FORMAT:.*\\} -->/i', '', $content); $content = trim($content); if (!$content) { return; } // Get the detector manager $service = new \Hubzero\Spam\Checker(); foreach (Event::trigger('antispam.onAntispamDetector') as $detector) { if (!$detector) { continue; } $service->registerDetector($detector); } // Check content $data = array('name' => User::get('name'), 'email' => User::get('email'), 'username' => User::get('username'), 'id' => User::get('id'), 'ip' => Request::ip(), 'user_agent' => Request::getVar('HTTP_USER_AGENT', null, 'server'), 'text' => $content); $result = $service->check($data); // Log errors any of the service providers may have thrown if ($service->getError() && App::has('log')) { App::get('log')->logger('debug')->info(implode(' ', $service->getErrors())); } // If the content was detected as spam... if ($result->isSpam()) { // Learn from it? if ($this->params->get('learn_spam', 1)) { Event::trigger('antispam.onAntispamTrain', array($content, true)); } // If a message was set... if ($message = $this->params->get('message')) { Notify::error($message); } // Increment spam hits count...go to spam jail! \Hubzero\User\User::oneOrFail(User::get('id'))->reputation->incrementSpamCount(); if ($this->params->get('log_spam')) { $this->log($result->isSpam(), $data); } return false; } // Content was not spam. // Learn from it? if ($this->params->get('learn_ham', 0)) { Event::trigger('antispam.onAntispamTrain', array($content, false)); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(UserRequest $request) { $newUser = new User($request->getValidInputs()); $newUser->ip_when_created = \Request::ip(); $newUser->password = \Hash::make($request->get('password')); $newUser->save(); Email::sendAccountCreated($newUser); \Notifications::add('OK! Further instructions were sent to provided email.', 'success'); return redirect()->route('user.index'); }
public function __construct(API $base, Request $request) { parent::__construct($base); // TODO: FastCGI, heavy refactoring session_start(); $this->request = $request; if (!isset($_SESSION['IP'])) { $_SESSION['IP'] = (string) $request->ip(false); } else { if ($_SESSION['IP'] != (string) $request->ip(false)) { session_unset(); } } $this->logged_in = false; $this->login_callback = array($this, 'loginDefault'); if (@$_SESSION['SPINDASH_LOGGED_IN'] == 'yes') { $this->logged_in = true; $this->username = @$_SESSION['SPINDASH_USERNAME']; } }
public function postCreateThread() { if (App::environment('production') && Auth::user()->hasCreatedAThreadRecently()) { return Redirect::action('ForumThreadsController@getCreateThread'); } /** @var \Illuminate\Validation\Validator $validator */ $validator = Validator::make(Input::only('g-recaptcha-response'), ['g-recaptcha-response' => 'required|recaptcha']); if ($validator->fails()) { return Redirect::action('ForumThreadsController@getCreateThread')->exceptInput('g-recaptcha-response')->withErrors($validator->errors()); } return $this->threadCreator->create($this, ['subject' => Input::get('subject'), 'body' => Input::get('body'), 'author' => Auth::user(), 'laravel_version' => Input::get('laravel_version'), 'is_question' => Input::get('is_question'), 'tags' => $this->tags->getTagsByIds(Input::get('tags')), 'ip' => Request::ip()], new ThreadForm()); }
/** обрабатываем входные параметры скрипта, определяем запрашиваемую страницу * */ public static function initialize($deep = false) { if (!$deep && self::$initialized) { return; } $headers = @apache_request_headers(); if (array_key_exists('X-Forwarded-For', $headers)) { $hostname = $headers['X-Forwarded-For']; } else { $hostname = $_SERVER["REMOTE_ADDR"]; } self::$ip = $hostname; self::$path_history = ''; self::$initialized = true; // принимаем uri $e = explode('?', $_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI'] = $e[0]; if (isset($e[1])) { parse_str($e[1], $d); } else { $d = array(); } $prepared_get = array(); foreach ($d as $name => &$val) { $val = to_utf8($val); $prepared_get[$name] = stripslashes($val); } self::$get_normal = self::$get = $prepared_get; $path_array = explode('/', self::processRuri($_SERVER['REQUEST_URI'])); // убиваем начальный слеш array_shift($path_array); // определяем, что из этого uri является страницей self::$structureFile = self::getPage($path_array, $deep); if (self::$real_path >= 0) { self::$structureFile = 'errors/p404.xml'; } //die(self::$structureFile); // разбираем параметры self::parse_parameters($path_array); if (isset($_POST)) { foreach ($_POST as $f => $v) { if (!is_array($v)) { self::$post[$f] = stripslashes($v); } else { self::$post[$f] = $v; } } } unset($_POST); unset($_GET); self::afterAll(); }
/** * 创建令牌 */ private function createToken() { if (C('app.token_on')) { //表单添加令牌 if (preg_match_all('/<form.*?>(.*?)<\\/form>/is', $this->content, $matches, PREG_SET_ORDER)) { $token = md5(c('app.key') . Request::ip()); foreach ($matches as $id => $m) { $php = "<input type='hidden' name='" . C('app.token_name') . "' value='" . $token . "'/>"; $this->content = str_replace($m[1], $m[1] . $php, $this->content); } } } }
public static function show() { if (Request::ip() != '127.0.0.1' && self::$enable) { return; } $time = microtime() - self::$start; $tmpl = '<script type="text/javascript">'; $tmpl .= 'console.log("Executing time: ' . $time . ' s.");'; $tmpl .= 'console.info("Queries count: ' . count(self::$data['query']) . '");'; $tmpl .= 'console.log("Queries count: ' . count(self::$data['query']) . '");'; $tmpl .= '</script>'; echo $tmpl; }
public function sendRedPack($data) { $data['mch_billno'] = time(); $data['mch_id'] = c('weixin.mch_id'); $data['wxappid'] = c('weixin.appid'); $data['total_num'] = "1"; //红包发放总人数 $data['client_ip'] = Request::ip(); $data['nonce_str'] = $this->getRandStr(16); $data['sign'] = $this->makeSign($data); $xml = Xml::toSimpleXml($data); $res = $this->curl_post_ssl("https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack", $xml); return Xml::toSimpleArray($res); }
public function post_login() { $credentials = array('username' => Input::get('username'), 'password' => Input::get('password')); if (Auth::attempt($credentials)) { Log::write('info', Request::ip() . ' User : '******' Event: Login', true); //set last login $user = Auth::user(); $user->last_login = new \DateTime(); $user->save(); return Redirect::to('admin/dashboard'); } else { return Redirect::to('admin/login'); } }
public function action_do_login() { $email = Input::get('email'); $password = Input::get('password'); $remember = Input::get('remember'); $credentials = array('username' => $email, 'password' => $password, 'remember' => !empty($remember) ? $remember : null); if (Auth::attempt($credentials)) { Auth::user()->last_ip = Request::ip(); Auth::user()->save(); return Redirect::to('dashboard/'); } else { return Redirect::to('login')->with('login_failed', "Invalid Username/Password"); } }
public function postSignupConfirm() { if (!Session::has('userGithubData')) { return $this->redirectAction('AuthController@getLogin'); } /** @var \Illuminate\Validation\Validator $validator */ $validator = Validator::make(Input::only('g-recaptcha-response'), ['g-recaptcha-response' => 'required|recaptcha']); if ($validator->fails()) { return Redirect::action('AuthController@getSignupConfirm')->exceptInput('g-recaptcha-response')->withErrors($validator->errors()); } $data = Session::get('userGithubData'); $data['ip'] = Request::ip(); $data['name'] = Input::get('name'); $data['email'] = Input::get('email'); return App::make('Lio\\Accounts\\UserCreator')->create($this, $data); }
static function findOrCreate(array $info) { static $fields = array('name', 'surname', 'phone', 'email'); $model = User::where('email', '=', $info['email'])->first(); if ($model) { return $model; } else { $password = static::generatePassword(); $model = with(new User())->fill_raw(array_intersect_key($info, array_flip($fields))); // it won't be hashed if set via fill_raw(). $model->password = $password; $model->reg_ip = Request::ip(); $model = Event::insertModel($model, 'user'); return S::listable(compact('model', 'password')); } }
public function admin($arguments = array()) { if (count($arguments) != 3) { throw new BadMethodCallException('Exactly three arguments expected.'); } $username = $arguments[0]; $password = $arguments[1]; $email = $arguments[2]; // Create admin user $admin_user = User::create(array('username' => $username, 'password' => $password, 'email' => $email, 'language' => Laravel\Config::get('application.language'), 'style' => 'Air', 'last_post' => Request::time(), 'registered' => Request::time(), 'registration_ip' => Request::ip(), 'last_visit' => Request::time())); $admin_group = Group::find(Group::ADMIN); if (is_null($admin_group)) { throw new LogicException('Could not find admin group.'); } $admin_group->users()->insert($admin_user); }
public static function get($url, $params) { $params["ip"] = \Request::ip(); $header = ["Authorization:Bearer " . self::authorization(), "client-id:" . self::$appKey]; $opts = array(CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_HTTPHEADER => $header, CURLOPT_URL => $url . '&' . http_build_query($params)); /* 初始化并执行curl请求 */ $ch = curl_init(); curl_setopt_array($ch, $opts); $data = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if ($error) { // Log::error(sprintf("jwt get error : %s | url : %s", $error, $url)); return $data; } return json_decode($data, true); }
public function postLogin() { $email = Input::get('email'); $password = Input::get('password'); $remember = Input::get('remember') ? true : false; $credentials = array('email' => $email, 'password' => $password); if (Auth::attempt($credentials, $remember)) { Auth::user()->last_ip = Request::ip(); Auth::user()->save(); //Check for update on login if (UpdateUtils::getUpdateCheck()) { Cache::put('update', true, 60); } return Redirect::to('dashboard/'); } else { return Redirect::to('login')->with('login_failed', "Invalid Username/Password"); } }
public function store($inputs) { $contact = new $this->model(); $contact->name = $inputs['name']; $contact->email = $inputs['email']; $contact->text = $inputs['message']; $contact->ip = \Request::ip(); $agent = new Agent(); $lang = $agent->languages(); $lang = implode(",", $lang); $platform = $agent->platform(); $version_p = $agent->version($platform); $device = $agent->device(); $browser = $agent->browser(); $version_b = $agent->version($browser); $contact->agent = $platform . $version_p . "|" . $device . "|" . $browser . $version_b . "|" . $lang; $contact->save(); }
/** * 保存留言 * @return \Illuminate\Http\JsonResponse * @throws CommentApiException */ public function saveComment() { $fid = intval(\Input::get("fid", 0)); //parentId $userId = intval(\Input::get("user_id", 0)); //用户id if ($userId < 1) { throw new CommentApiException("用户id不能为空"); } $nickName = \Input::get("nickname", null); if (empty($nickName)) { throw new CommentApiException("用户昵称不能为空~!"); } $content = \Input::get('content', null); if (empty($content)) { throw new CommentApiException("评论内容不能为空~!"); } $ver = \Input::get("ver", null); if (empty($ver)) { throw new CommentApiException("版本号不能为空~!"); } $data = $this->getCommonData(); $star = \Input::get("star", null); //评星 if (empty($star) == false) { $data["star"] = $star; } $top = \Input::get("top", null); if (empty($top) == false) { $data["top"] = $top; } $ip = \Request::ip(); $data["ip"] = $ip; //ip $data["fid"] = $fid; //parent $data["nickname"] = $nickName; $data["user_id"] = $userId; $data["content"] = $content; $data["ver"] = $ver; $api = new CommentApi(); $result = $api->save($data); return $this->success($result); }
public function post_saveeditkso() { Log::write('info', Request::ip() . ' User : '******' Event: Edit KSO', true); $data = Input::all(); $extradata = array('user_id' => Auth::user()->id, 'last_update' => date('Y-m-d H:i:s')); $savedata = $data + $extradata; $datasave = Kso::find($data['id']); $datasave->kso_number = $data['kso_number']; $datasave->fleet_id = $data['fleet_id']; $datasave->bravo_driver_id = $data['bravo_driver_id']; $datasave->charlie_driver_id = $data['charlie_driver_id']; $datasave->pool_id = $data['pool_id']; $datasave->dp = $data['dp']; $datasave->sisa_dp = $data['sisa_dp']; $datasave->setoran = $data['setoran']; $datasave->tab_sparepart = $data['tab_sparepart']; $datasave->kso_type_id = $data['kso_type_id']; $datasave->ops_start = $data['ops_start']; $datasave->ops_end = $data['ops_end']; $datasave->actived = $data['actived']; $datasave->save(); if ($datasave) { if ($data['actived'] == 2) { $c = Fleet::find($data['fleet_id']); $c->fg_kso = 0; $c->save(); $s = Anakasuh::where('fleet_id', '=', $data['fleet_id'])->where('status', '=', 1)->first(); if ($s) { $s->status = 0; $s->end_date = date('Y-m-d', Myfungsi::sysdate()); $s->save(); } } else { if ($data['actived'] == 1) { $c = Fleet::find($data['fleet_id']); $c->fg_kso = 1; $c->save(); } } return Redirect::to('ksos'); } var_dump($data); }
public function action_create_user() { $user_data = array('email' => Input::get('email'), 'password' => Input::get('password'), 'company' => Input::get('company'), 'company_id' => Input::get('company_id'), 'country_id' => Input::get('country_id'), 'district_id' => Input::get('district_id'), 'city' => Input::get('city'), 'address' => Input::get('address'), 'phone_1' => Input::get('phone_1'), 'contact_person' => Input::get('contact_person'), 'code' => Input::get('code')); $rules = array('email' => 'email|unique:users|required', 'password' => 'required|min:6', 'company' => 'required', 'country_id' => 'required', 'district_id' => 'required', 'city' => 'required', 'address' => 'required', 'phone_1' => 'required'); $v = Validator::make($user_data, $rules); if (!$this->is_code_correct($user_data)) { Log::cheater(Request::ip()); return View::make('sapoc.pages.verification')->with('message', __('form-verify.cheater'))->with('link', __('form-verify.cheater-url')); } if ($v->fails()) { return Redirect::to($this->get_verification_link($user_data['email']))->with('register_errors', true)->with_errors($v)->with_input(); } else { $user_data['password'] = Hash::make($user_data['password']); $user = new User($user_data); $user->save(); return $this->action_login(); // return View::make('sapoc.pages.index-full') // ->with('user', $user_data['email']); } }
public function post_index() { $rules = array('issue' => 'required'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Messages::add('error', 'Please make sure you fill out the form to let us know what problem you are having.'); return Redirect::to('admin/' . $this->views . '')->with_input(); } else { // Get the Swift Mailer instance $mailer = IoC::resolve('mailer'); // Construct the message $message = Swift_Message::newInstance('Message From Website')->setFrom(array($this->data['user']->email => $this->data['user']->fullname))->setTo(array('*****@*****.**' => 'Framework Support For ' . COMPANY_NAME))->setBody('<p><strong>' . $this->data['user']->fullname . ' has emailed you:</strong></p> <q>' . Input::get('issue') . '</q> <p><strong>Email Address: </strong> ' . $this->data['user']->email . '</p> <p><strong>IP Address: </strong> ' . Request::ip() . '</p> <p><strong>User Agent: </strong> ' . Request::server('HTTP_USER_AGENT') . '</p>', 'text/html'); // Send the email $mailer->send($message); Messages::add('success', '<strong>Support Issue Sent</strong> We\'ll be in touch shortly.'); return Redirect::to('admin/help'); } }
public function post_register() { $rules = array('user' => 'Required|Between:2,25|username_not_guest|no_ip|username_not_reserved|no_bbcode|not_censored|Unique:users,username|username_not_banned'); // If email confirmation is enabled if (Config::enabled('o_regs_verify')) { $rules['email'] = 'Required|Email|Confirmed|unique:users,email|email_not_banned'; } else { $rules['password'] = '******'; $rules['email'] = 'Required|Email|Unique:users,email'; } // Agree to forum rules if (Config::enabled('o_rules')) { $rules['rules'] = 'Accepted'; } $validation = $this->make_validator(\Input::all(), $rules); if ($validation->fails()) { return \Redirect::route('register')->withInput(\Input::all())->with('errors', $validation->getMessages()); } $user_data = array('username' => \Input::get('user'), 'group_id' => Config::enabled('o_regs_verify') ? Group::UNVERIFIED : Config::get('o_default_user_group'), 'password' => \Input::get('password'), 'email' => \Input::get('email'), 'email_setting' => Config::get('o_default_email_setting'), 'timezone' => Config::get('o_default_timezone'), 'dst' => Config::get('o_default_dst'), 'language' => Config::get('o_default_lang'), 'style' => Config::get('o_default_style'), 'registered' => \Request::time(), 'registration_ip' => \Request::ip(), 'last_visit' => \Request::time()); $user = User::create($user_data); return \Redirect::action('fluxbb::home@index')->with('message', trans('fluxbb::register.reg_complete')); }
/** * Initialize handling. * * @param bool|false $user_agent * @param bool|false $remote_address */ public function __construct($user_agent = false, $remote_address = false) { /** * Prevent by logged users */ if (\Auth::check()) { $this->guest = false; return false; } $this->user_agent = $user_agent ?: \Request::header('User-Agent'); $this->remote_address = $remote_address ?: \Request::ip(); $this->generateToken(); /** * Find guest in database or create new */ $guestObject = GuestModel::where($this->getCredentials())->where('token_expiration_time', '>', new \DateTime('now'))->first(); if (!$guestObject) { //generate new brand token $this->generateToken(true); $guestObject = GuestModel::create($this->getCredentials(true)); } $this->model = $guestObject; }
/** * default action 'index' * @param Request $request * @param Response $response */ public function index(Request $request, Response $response) { if (Common_Model::admin_logined()) { $admin = D()->get_one("SELECT * FROM {admin_user} WHERE admin_uid=%d", $_SESSION['logined_uid']); $v = new PageView('mod_user_index'); $v->assign('admin', $admin); $v->assign('nav', $this->_nav); if ($request->is_hashreq()) { $srvinfo = array('PHP_OS' => PHP_OS, 'PHP_VERSION' => PHP_VERSION, 'SERVER_SOFTWARE' => $_SERVER['SERVER_SOFTWARE'], 'SYS_VERSION' => C('env.version'), 'SYS_TIME' => date('Y-m-d H:i:s'), 'SYS_TIMEZONE' => date_default_timezone_get(), 'DB_VERSION' => 'MySQL', 'DB_TIME' => date('Y-m-d H:i:s'), 'PHP_EXECTIME' => 0, 'PHP_UPLOAD' => '', 'CLIENT_IP' => $request->ip(), 'CLIENT_UA' => get_client_platform() . ' - ' . get_client_browser()); // DB info $dbinfo = D()->get_one("SELECT VERSION() AS db_ver, UNIX_TIMESTAMP() AS db_time"); $srvinfo['DB_VERSION'] = 'MySQL ' . $dbinfo['db_ver']; $srvinfo['DB_TIME'] = date('Y-m-d H:i:s', $dbinfo['db_time']); // PHP detail $srvinfo['PHP_EXECTIME'] = ini_get('max_execution_time') . ' 秒'; $srvinfo['PHP_UPLOAD'] = @ini_get('file_uploads') ? '最大 ' . ini_get('upload_max_filesize') : '<font color="red">禁止上传</font>'; $v->assign('srvinfo', $srvinfo); } $response->send($v); } else { $response->redirect('/login'); } }
protected final function BusyBlock(array $hz = array(1, 30), Closure $callback = null) { $ip = Request::ip(); if ($ip) { $key = md5($ip); $now = time(); $seconds = intval($hz[0] * 60); $times = intval($hz[1]); $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'BusyBlock' . DIRECTORY_SEPARATOR . substr($key, 0, 2); is_dir($dir) || mkdir($dir, 0777, true); $file = $dir . DIRECTORY_SEPARATOR . substr($key, -6); if (is_file($file)) { $data = unserialize(file_get_contents($file)); $data[$ip] = isset($data[$ip]) ? $data[$ip] : array(0, 0); list($currentTimes, $lastAccess) = $data[$ip]; $currentTimes = $now - $lastAccess > $seconds ? 0 : $currentTimes + 1; $data[$ip] = array($currentTimes, $now); file_put_contents($file, serialize($data)); if ($currentTimes > $times) { if ($callback) { return $callback($ip); } throw new Exception("BusyBlock Block {$ip}", 4); } return $this; } else { $data = array($ip => array(0, 0)); file_put_contents($file, serialize($data)); return $this; } } if ($callback) { return $callback($ip); } throw new Exception("BusyBlock Block {$ip}", 3); }
/** * @return check for IP */ public function check_ip() { $tc = (new ScraperController())->torNew(); $ip = \Request::ip(); $condition = array("open", "blocked"); $key = array_rand($condition, 1); $status = $condition[$key]; \Log::info($ip . ":" . $status); if ($status == 'blocked') { \Log::info("Gaining new tor identity"); if (isset($tc->connected)) { $tc->quit(); } check_ip(); } else { return $ip; } }