public function index()
 {
     if (request()->ajax()) {
         return $this->getUpcomingBooks(Auth::user()->id);
     }
     return view('books.upcoming');
 }
Exemple #2
0
function task_list($admin_id)
{
    $url = $prefix . '/admin/' . $admin_id . '/list';
    $result = request($url);
    if (!empty($result)) {
    }
}
Exemple #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     $this->validate(request(), ['note' => ['required', 'max:200']]);
     $data = request()->all();
     Note::create($data);
     return redirect()->to('notes');
 }
 public function __construct($companyId = null)
 {
     parent::__construct();
     if ($companyId !== null) {
         $this->company = Company::instance()->find($companyId);
     } else {
         $this->company = new Company();
     }
     $this->exists = $this->company->exists();
     if ($this->exists) {
         $this->prependSiteTitle(lang('Companies.EditCompany', $this->company->name));
     } else {
         $this->prependSiteTitle(lang('Companies.AddCompany'));
     }
     if ($this->isPostBack()) {
         $this->validate(['name' => [new NotNullOrEmpty()]]);
         if (!$this->hasErrors()) {
             $this->company->save(['name' => input()->get('name'), 'ip' => request()->getIp()]);
             if ($this->exists) {
                 $this->setMessage(lang('Companies.CompanyUpdated'), 'success');
             } else {
                 $this->setMessage(lang('Companies.CompanySaved'), 'success');
             }
             // Refresh
             response()->refresh();
         }
     }
 }
Exemple #5
0
 public function testConvenienceFunction()
 {
     $x = request();
     $this->assertEquals(request(), $x);
     $x = request('method');
     $this->assertEquals('GET', $x);
 }
Exemple #6
0
 public function run($id = false, $model = false, $forceDelete = false)
 {
     $modelName = $this->model && is_string($this->model) ? $this->model : (request()->getParam('model') ? request()->getParam('model') : $this->controller->model);
     if ($id) {
         //delete one model
         $result = $this->controller->loadModel($modelName, $id)->delete();
         if (!request()->isAjaxRequest && $result) {
             $this->controller->redirect(user()->gridIndex);
         }
         Common::jsonSuccess(true);
     } else {
         $items = Common::getChecked('items');
         if ($items) {
             if (!$forceDelete) {
                 foreach ($items as $id) {
                     $this->controller->loadModel($modelName, $id)->delete();
                 }
             } else {
                 $criteria = new SDbCriteria();
                 $criteria->compare('id', $items);
                 CActiveRecord::model($modelName)->deleteAll($criteria);
             }
             Common::jsonSuccess(true);
         }
     }
     Common::jsonError("Ошибка");
 }
 public function index()
 {
     $token = config('global.token');
     $role = \Input::get('role');
     if (!empty($token)) {
         $cacheTag = ['managers', 'auth'];
         $cacheKey = $token;
         $data = Cache::tags($cacheTag)->remember($cacheKey, 60 * 48, function () use($token) {
             $_manager = Managers::where('token', $token)->where('ip', request()->ip());
             if ($_manager->count() > 0) {
                 return $_manager->first()->toArray();
             } else {
                 return false;
             }
         });
         if ($data) {
             if (!empty($role)) {
                 $roles = !is_array($role) ? [$role] : $role;
                 if (!in_array($data['role'], $roles)) {
                     return new \Exception('Você não tem permissão para realizar esta ação.');
                 }
             }
             return ['name' => $data['name'], 'email' => $data['email'], 'role' => $data['role'], 'avatar' => $data['avatar']];
         } else {
             Cache::tags($cacheTag)->forget($cacheKey);
             return new \Exception('Token de acesso inválido. Faça login novamente');
         }
     } else {
         return new \Exception('Chave de acesso não encontrada. Você precisa fazer login');
     }
 }
 public function actionCreate()
 {
     if (request()->getIsPostRequest()) {
         $content = trim($_POST['kwcontent']);
         if ($content) {
             $keywords = explode("\n", $content);
             foreach ((array) $keywords as $kw) {
                 $kwArray = explode(',', $kw);
                 $kwArray = array_unique($kwArray);
                 $model = new FilterKeyword();
                 $model->keyword = trim($kwArray[0]);
                 $model->replace = trim($kwArray[1]);
                 try {
                     if (!$model->save()) {
                         $error['keyword'] = $kw;
                         $error['message'] = implode('; ', $model->getErrors('keyword')) . implode('; ', $model->getErrors('replace'));
                         $errors[] = $error;
                     }
                 } catch (Exception $e) {
                     $error['keyword'] = $kw;
                     $error['message'] = $e->getMessage();
                     $errors[] = $kw;
                 }
                 unset($model);
             }
             FilterKeyword::updateCacheFile();
         }
     }
     $this->adminTitle = t('create_filter_keyword', 'admin');
     $this->render('create', array('errors' => $errors));
 }
 public function __construct($esxman, $database, $username = '', $error = null)
 {
     $this->esxman = $esxman;
     $this->database = $database;
     $this->username = $username;
     $this->html = array('footer' => ' ', 'menu' => ' ', 'tree' => ' ', 'user' => ' ', 'content' => ' ');
     $this->commands = array();
     $this->title = _('Login');
     if (request('form_name') == 'login') {
         if ($this->database->authenticate_user(request('username'), request('password'))) {
             session_destroy();
             session_start();
             $_SESSION['username'] = request('username');
             $_SESSION['key'] = md5($_SESSION['username'] . getenv('REMOTE_ADDR') . getenv('X-FORWARDED-FOR'));
             debug('User ' . request('username') . ' logging in!');
             $this->commands[] = "\$('#dialog').html('" . _('Populating inventory...') . "');";
             $this->commands[] = js_command('get', 'action=populate_inventory');
             return;
         }
         $error = _('Authentication failed');
     }
     $tpl = new Template('dialog_login.html');
     if ($error) {
         $tpl->setVar('error', $error);
         $tpl->parse('error_message');
     }
     $this->commands[] = js_command('display_dialog', _('Login'), $tpl->get(), _('Login'));
 }
Exemple #10
0
 /**
  * Play/stream a song.
  *
  * @link https://github.com/phanan/koel/wiki#streaming-music
  *
  * @param Song      $song      The song to stream.
  * @param null|bool $transcode Whether to force transcoding the song.
  *                             If this is omitted, by default Koel will transcode FLAC.
  * @param null|int  $bitRate   The target bit rate to transcode, defaults to OUTPUT_BIT_RATE.
  *                             Only taken into account if $transcode is truthy.
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function play(Song $song, $transcode = null, $bitRate = null)
 {
     if ($song->s3_params) {
         return (new S3Streamer($song))->stream();
     }
     // If `transcode` parameter isn't passed, the default is to only transcode FLAC.
     if ($transcode === null && ends_with(mime_content_type($song->path), 'flac')) {
         $transcode = true;
     }
     $streamer = null;
     if ($transcode) {
         $streamer = new TranscodingStreamer($song, $bitRate ?: config('koel.streaming.bitrate'), request()->input('time', 0));
     } else {
         switch (config('koel.streaming.method')) {
             case 'x-sendfile':
                 $streamer = new XSendFileStreamer($song);
                 break;
             case 'x-accel-redirect':
                 $streamer = new XAccelRedirectStreamer($song);
                 break;
             default:
                 $streamer = new PHPStreamer($song);
                 break;
         }
     }
     $streamer->stream();
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules(Locale $locale)
 {
     //only for next request:: ->flash
     //session()->flash('active_language_tab',$request->get('active_language_tab'));
     //        $locales = new Locale();                                                              §
     $locales = $locale->getEnabled();
     $sitemapRules = ['parent_id' => 'required', 'online' => 'required', 'template_id' => 'required'];
     $translationRules = array();
     foreach ($locales as $key => $locale) {
         $translationRules['translations.' . $locale->languageCode . '.name'] = 'required';
         //homepage geen slug , patch is update
         if (request()->get('parent_id') != 0 && request()->get('_method') == 'PATCH') {
             $translationRules['translations.' . $locale->languageCode . '.slug'] = 'required';
             //dc('wel verplicht');
         } else {
             //dc('niet verplicht');
         }
         switch ($this->input('post_type')) {
             case 'homepage':
                 //$translationRules['translations.'.$locale->identifier.'.news.author'] = 'required|integer';
                 //uit
                 //$translationRules['translations.'.$locale->languageCode.'.homepage.content'] = 'required';
                 break;
             case 'defaultpage-uit':
                 $translationRules['translations.' . $locale->languageCode . '.defaultpage.content'] = 'required';
                 break;
             default:
         }
     }
     return array_merge($sitemapRules, $translationRules);
 }
Exemple #12
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $direction = request()->get('direction');
     $orderby = request()->get('orderby');
     $posts = $this->postRepo->getPaginatedAndOrdered();
     return view('admin::posts.index', compact('posts', 'direction', 'orderby'));
 }
 /**
  * Display a listing of the resource.
  *
  * @param \App\Models\Article $article
  * @return \Illuminate\Http\Response
  */
 public function index($article)
 {
     if (request()->ajax()) {
         return response()->json($article->comments);
     }
     return response('');
 }
 public function deleteVolunteers($id)
 {
     can('event.volunteer');
     $this->volunteer_repo->delete(request()->record_id);
     flash('volunteer deleted successfully', 'success');
     return redirect("/event/volunteers/{$id}");
 }
    protected function getRequestInfo()
    {
        if (empty($_SERVER['REQUEST_METHOD']) || !$this->debug) {
            return '';
        }
        $request = request();
        try {
            $url = !empty($_SERVER['REQUEST_URI']) ? $request->url() : 'Probably console command';
        } catch (\UnexpectedValueException $exc) {
            $url = 'Error: ' . $exc->getMessage();
        }
        $title = 'Request Information';
        $content = <<<EOF
            <div class="request-info">
                <hr>
                <h2 style="margin: 20px 0 20px 0; text-align: center; font-weight: bold; font-size: 18px;">
                    <b>{$title}</b><br>
                </h2>
                <h2 style="font-size: 18px;">({$request->getRealMethod()} -> {$request->getMethod()}) {$url}</h2>
                <br>
                <div style="font-size: 14px !important">

EOF;
        foreach ($this->getAdditionalData() as $label => $data) {
            $content .= '<h2 style="margin: 20px 0 20px 0; font-weight: bold; font-size: 18px;">' . $label . '</h2>';
            $json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
            $content .= <<<EOF
                <pre style="border: 1px solid {$this->colors['json_block_border']}; background: {$this->colors['json_block_bg']};
                padding: 10px; font-size: 14px !important; word-break: break-all; white-space: pre-wrap;">{$json}</pre>
EOF;
        }
        return $this->cleanPasswords($content) . '</div></div>';
    }
 function post_login()
 {
     $input = request()->input();
     ///////////////////////
     // Validate remotely //
     ///////////////////////
     $data['email'] = $input['username'];
     $data['password'] = $input['password'];
     $data['grant_type'] = 'password';
     $data['key'] = env('CAPCUS_API_KEY', 'qwerty123');
     $data['secret'] = env('CAPCUS_API_SECRET', 'qwerty123');
     $api_response = json_decode($this->api->post($this->api_url . '/authorized/client', ['form_params' => $data])->getBody());
     //////////////
     // redirect //
     //////////////
     if (str_is('success', $api_response->status)) {
         foreach ($api_response->data->whoami->auths as $key => $value) {
             if (str_is('cms', $value->app)) {
                 Session::put('access_token', $api_response->data->access_token);
                 Session::put('refresh_token', $api_response->data->refresh_token);
                 Session::put('expired_at', $api_response->data->expired_at);
                 Session::put('me', $api_response->data->whoami);
                 Session::put('auth_cms', $value->roles);
                 return redirect()->intended(route('dashboard'));
             }
         }
     }
     return redirect()->back()->withErrors(new MessageBag(['auth' => "Unauthorized Access"]));
 }
Exemple #17
0
 public function buildFileName($invoice = false)
 {
     $key = $invoice ? 'invoice' : 'paper';
     if ($this->files[$key . '_name']) {
         #if already build
         return $this->files[$key . '_name'];
     }
     if (!request()->file($this->files[$key])) {
         return '';
     }
     $ext = request()->file($this->files[$key])->getClientOriginalExtension();
     $name = request()->file($this->files[$key])->getClientOriginalName();
     $name = str_replace('.' . $ext, '', $name);
     #check if name is bigger then 90 chars and cut + remove ... from string
     $name = str_limit($name, 90);
     if (substr($name, -1) == '.') {
         $name = substr($name, 0, -3);
     }
     $userName = explode(' ', auth()->user()->name);
     $name .= '_' . $userName[0][0] . $userName[1][0];
     #get user letters
     if ($invoice) {
         $name .= 'I';
         #add i before number
     }
     $name .= rand(1, 999);
     $name .= '.' . $ext;
     #add extension
     if (File::exists(self::$path . $name)) {
         $name = $this->buildFileName($invoice);
     }
     $this->files[$key . '_name'] = $name;
     return $name;
 }
 public function __construct()
 {
     $criteria = Criteria::findOrFail(request()->segment(4));
     if (!$criteria->type['option']) {
         return redirect()->back()->with('error', 'options');
     }
 }
Exemple #19
0
	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();
	}
 public function sequence($item)
 {
     $collections = collect($this->paginator->items());
     $index = $collections->search($item) + 1;
     $start = (request('page', 1) - 1) * $this->paginator->perPage();
     return $start + $index;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $direction = request()->get('direction');
     $orderby = request()->get('orderby');
     $categories = $this->categoryRepo->getPaginatedAndOrdered();
     return view('admin::categories.index', compact('categories', 'orderby', 'direction'));
 }
 public function requestApiResource()
 {
     if (!is_null(request()->route())) {
         if (request()->route()->getName() == "api.endpoint.root") {
             return ApiResponse::CreateResponse(ApiResponse::API_OK, ["info" => "This URL is an API Endpoint URI, used to query specific data based on provided configuration. In order to make use of this API Endpoint, please provide the correct Endpoint Resource, or contact the administrator of this web site for more information"]);
         }
     }
     $resourceDataProvider = $this->apiEndpointHost->resourceDataProvider;
     if (empty(trim($resourceDataProvider))) {
         return ApiResponse::CreateResponse(ApiResponse::API_INVALID_CONFIGURATION);
     }
     $resourceDataProviderMethod = $this->apiEndpointHost->resourceDataProviderMethod;
     if (empty(trim($resourceDataProviderMethod))) {
         return ApiResponse::CreateResponse(ApiResponse::API_INVALID_CONFIGURATION);
     }
     $theDataProvider = new $resourceDataProvider();
     $params = [];
     foreach ($this->apiEndpointHost->resourceRequestParams as $param) {
         if (!isset($this->apiEndpointHost->routeParams[$param])) {
             return ApiResponse::CreateResponse(ApiResponse::API_INSUFFICIENT_INPUT_PARAMS);
         }
         $params[$param] = $this->apiEndpointHost->routeParams[$param];
     }
     // Call Application Method
     $data = $theDataProvider::$resourceDataProviderMethod($params);
     // Return Result
     return $data ? ApiResponse::CreateResponse(ApiResponse::API_OK, $data) : ApiResponse::CreateResponse(ApiResponse::API_NOT_FOUND);
 }
Exemple #23
0
 public function getMmPoint(Request $request)
 {
     $key = request('key');
     $mmpointM = DB::connection(DBUtils::getDBName())->table('mmpoint_table')->where('A', $key)->first();
     // Log::info("lenth ".sizeof($mmtrendM));
     return response()->json(['mmpointM' => json_encode($mmpointM)]);
 }
 public function postRegister()
 {
     $name = request()->input('name');
     $email = request()->input('email');
     $password = request()->input('password');
     $ret = ['status' => 1, 'err_code' => '-1', 'err_msg' => ''];
     if (!isset($name) || !isset($email) || !isset($password)) {
         $ret['status'] = 0;
         $ret['err_code'] = 'params missed';
         $ret['err_msg'] = '参数缺失';
     } else {
         $count = Enterprise::where('en_email', '=', $email)->count();
         if ($count === 0) {
             $en = new Enterprise();
             $en->en_uid = Enterprise::all()->count() + 10000 + 1;
             $en->en_name = $name;
             $en->en_email = $email;
             $en->en_password = md5($password);
             $en->save();
         } else {
             $ret['status'] = 0;
             $ret['err_code'] = 'email exist';
             $ret['err_msg'] = '邮箱已经被注册';
         }
     }
     return response($ret);
 }
Exemple #25
0
 /**
  * Return error response accordingly.
  *
  * @param array|string $attributes
  * @param null         $to
  * @return array
  * 
  * @author Cali
  */
 protected function errorResponse($attributes = [], $to = null)
 {
     if (request()->ajax()) {
         return $this->ajaxErrorResponse($attributes);
     }
     return $to ? redirect($to)->with($this->ajaxErrorResponse($attributes)) : redirect()->back()->with($this->ajaxErrorResponse($attributes));
 }
Exemple #26
0
/**
 * @VP:
 * I'm trying to pass a second parameter to my transformer but don't know how.
 * @param $resource
 */
function transform($resource)
{
    $manager = new Manager();
    $manager->setSerializer(new DataArraySerializer());
    $manager->parseIncludes(request()->get('includes', []));
    return $manager->createData($resource)->toArray();
}
 public function optimize($hash)
 {
     $folder = $this->getImagePath($hash);
     //Check if image exists. If not, throw exception.
     if (is_null($folder)) {
         throw new Exception('Image does not exists.');
     }
     //Check if any etag is set.
     if (!empty(request()->instance()->getETags())) {
         return response(null)->setNotModified();
     }
     $newHeight = $this->getDimensionValue('h');
     $newWidth = $this->getDimensionValue('w');
     $this->image->readImage(sprintf('%s/%s', $folder, $hash));
     if (filter_var($newWidth, FILTER_VALIDATE_INT) && filter_var($newHeight, FILTER_VALIDATE_INT)) {
         $this->crop($newWidth, $newHeight);
     } else {
         if (filter_var($newWidth, FILTER_VALIDATE_INT) && $newHeight === 'auto') {
             $this->resize($newWidth, 0);
         } else {
             if (filter_var($newHeight, FILTER_VALIDATE_INT) && $newWidth === 'auto') {
                 $this->resize(0, $newHeight);
             }
         }
     }
     return response($this->image)->header('Pragma', 'Public')->header('Content-Type', $this->image->getImageMimeType())->setEtag(md5(sprintf('%s-%s', $hash, $_SERVER['QUERY_STRING'])))->setPublic();
 }
 public function save(PostRequest $request, $forum, $topic, $post = null)
 {
     $url = \DB::transaction(function () use($request, $forum, $topic, $post) {
         // parsing text and store it in cache
         $text = app()->make('Parser\\Post')->parse($request->text);
         // post has been modified...
         if ($post !== null) {
             $this->authorize('update', [$post, $forum]);
             $data = $request->only(['text', 'user_name']) + ['edit_count' => $post->edit_count + 1, 'editor_id' => auth()->id()];
             $post->fill($data)->save();
             $activity = Stream_Update::class;
             // user want to change the subject. we must update topics table
             if ($post->id === $topic->first_post_id) {
                 $path = str_slug($request->get('subject'), '_');
                 $topic->fill($request->all() + ['path' => $path])->save();
                 $this->topic->setTags($topic->id, $request->get('tag', []));
             }
         } else {
             $activity = Stream_Create::class;
             // create new post and assign it to topic. don't worry about the rest: trigger will do the work
             $post = $this->post->create($request->all() + ['user_id' => auth()->id(), 'topic_id' => $topic->id, 'forum_id' => $forum->id, 'ip' => request()->ip(), 'browser' => request()->browser(), 'host' => request()->server('SERVER_NAME')]);
             // get id of users that were mentioned in the text
             $usersId = (new Ref_Login())->grab($text);
             if ($usersId) {
                 app()->make('Alert\\Post\\Login')->with(['users_id' => $usersId, 'sender_id' => auth()->id(), 'sender_name' => $request->get('user_name', auth()->user()->name), 'subject' => excerpt($topic->subject, 48), 'excerpt' => excerpt($text), 'url' => route('forum.topic', [$forum->path, $topic->id, $topic->path], false)])->notify();
             }
         }
         $url = route('forum.topic', [$forum->path, $topic->id, $topic->path], false);
         $url .= '?p=' . $post->id . '#id' . $post->id;
         $object = (new Stream_Post(['url' => $url]))->map($post);
         stream($activity, $object, (new Stream_Topic())->map($topic, $forum));
         return $url;
     });
     return redirect()->to($url);
 }
Exemple #29
0
 function parse($url)
 {
     $url = $this->readUrl($url);
     var_dump($url);
     die;
     if (!$url or $this->cacheurl[$url] or $this->cacheurl[preg_replace('#/$#', '', $url)]) {
         return false;
     }
     var_dump('111');
     die;
     $this->_allcount--;
     if ($this->_allcount <= 0) {
         return false;
     }
     $this->cacheurl[$url] = true;
     $item = array();
     $data = str_get_html(request($url));
     $item['url'] = $url;
     $item['title'] = count($data->find('title')) ? $data->find('title', 0)->plaintext : '';
     $item['text'] = $data->plaintext;
     $this->result[] = $item;
     if (count($data->find('a'))) {
         foreach ($data->find('a') as $a) {
             $this->parse($a->href);
         }
     }
     $data->clear();
     unset($data);
 }
function callPrefilter($arr)
{
    // Delimiter Message with |
    //checkRequest($arr)
    if (true) {
        //echo "ARRAY: $arrString\n";
        if ($debug) {
            echo "VALOR A ENVIAR sin convertir\t{$arr}\n";
        }
        $arr = transRequest($arr);
        if ($debug) {
            echo "VALOR A ENVIAR convertido\t\t{$arr}\n";
        }
        $answer = request($arr);
        if ($debug) {
            echo $requestConverted;
        }
        if (checkAnswer($answer)) {
            $answer = transResponse($answer);
            $answerChecked = $answer;
        } else {
            $answerChecked = $answer;
        }
        //$arrString = implode("|", $arrAnswer);
        //echo "RESPUESTA DESDE SERVIDOR: $arrString";
    }
    if ($debug) {
        echo $answerChecked;
    }
    $answerArray = convertAnswerStringToArray($answerChecked);
    return $answerArray;
}