コード例 #1
0
 public function postUserSettings()
 {
     $error = false;
     if (Request::has('user_id')) {
         $user_id = (int) Auth::user()->user_id;
         $input_id = (int) Request::input('user_id');
         if (Request::input('roles') === null) {
             $roles = [];
         } else {
             $roles = Request::input('roles');
         }
         if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) {
             $roles[] = env('ROLE_ADMIN');
             $error = true;
         }
         $editUser = User::find(Request::input('user_id'));
         $editUser->roles()->sync($roles);
         $editUser->save();
         $this->streamingUser->update();
     }
     if ($error) {
         return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!');
     }
     return redirect()->back();
 }
コード例 #2
0
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email')->unique();
         $table->string('password');
         $table->boolean('active');
         $table->boolean('banned');
         $table->string('register_ip');
         $table->string('country_code');
         $table->string('locale');
         $table->string('activation_key');
         $table->boolean('su');
         $table->rememberToken();
         $table->timestamps();
     });
     $user = \Laralum::newUser();
     $user->name = env('USER_NAME', 'admin');
     $user->email = env('USER_EMAIL', '*****@*****.**');
     $user->password = bcrypt(env('USER_PASSWORD', 'admin123'));
     $user->active = true;
     $user->banned = false;
     $user->register_ip = "";
     $user->country_code = env('USER_COUNTRY_CODE', 'ES');
     $user->locale = env('USER_LOCALE', 'en');
     $user->activation_key = str_random(25);
     $user->su = true;
     $user->save();
 }
コード例 #3
0
ファイル: Request.php プロジェクト: pckg/framework
 function __construct(Router $router, Response $response)
 {
     $this->router = $router;
     $this->response = $response;
     $this->post = new Lazy($_POST);
     $this->get = new Lazy($_GET);
     $this->server = new Lazy($_SERVER);
     $this->files = new Lazy($_FILES);
     $parsedUrl = parse_url($_SERVER['REQUEST_URI'] ?? '/');
     $url = $parsedUrl['path'];
     $envPrefix = env()->getUrlPrefix();
     // replace environment prefix
     if (strpos($url, $envPrefix) === 0) {
         $url = substr($url, strlen($envPrefix));
     }
     // default url if empty
     if (!$url) {
         $url = '/';
     } else {
         if (strlen($url) > 1 && substr($url, -1) == "/") {
             // add / to beginning
             $url = substr($url, 0, -1);
         }
     }
     $this->url = $url;
 }
コード例 #4
0
 public function register()
 {
     $this->app->configure("mail");
     $this->app->register(MailServiceProvider::class);
     $this->app->singleton(MailClerk::class, function () {
         return new MailClerk(app("mailer"));
     });
     $this->app->extend("swift.transport", function (TransportManager $manager) {
         $manager->extend("slack", function () {
             $token = env("SLACKMAIL_APIKEY");
             $channel = env("SLACKMAIL_CHANNEL");
             return new SlackTransport($token, $channel);
         });
         $manager->extend("sendgrid", function () {
             if (class_exists(\SendGrid::class)) {
                 $sendgrid = new \SendGrid(env("SENDGRID_APIKEY"));
                 return new SendGridTransport($sendgrid);
             } else {
                 throw new \Exception("SendGrid class not found. plz install via `composer install sendgrid/sendgrid`");
             }
         });
         $manager->extend("array", function () {
             return new ArrayTransport();
         });
         return $manager;
     });
 }
コード例 #5
0
 public function run()
 {
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     }
     if (env('DB_DRIVER') == 'mysql') {
         DB::table(config('access.roles_table'))->truncate();
     } else {
         //For PostgreSQL or anything else
         DB::statement("TRUNCATE TABLE " . config('access.roles_table') . " CASCADE");
     }
     //Create admin role, id of 1
     $role_model = config('access.role');
     $admin = new $role_model();
     $admin->name = 'Administrator';
     $admin->all = true;
     $admin->sort = 1;
     $admin->created_at = Carbon::now();
     $admin->updated_at = Carbon::now();
     $admin->save();
     //id = 2
     $role_model = config('access.role');
     $user = new $role_model();
     $user->name = 'User';
     $user->sort = 2;
     $user->created_at = Carbon::now();
     $user->updated_at = Carbon::now();
     $user->save();
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     }
 }
コード例 #6
0
ファイル: CrudTrait.php プロジェクト: Ghitu/crud
 public static function isColumnNullable($column_name)
 {
     $instance = new static();
     // create an instance of the model to be able to get the table name
     $answer = DB::select(DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" . $instance->getTable() . "' AND COLUMN_NAME='" . $column_name . "' AND table_schema='" . env('DB_DATABASE') . "'"))[0];
     return $answer->IS_NULLABLE == 'YES' ? true : false;
 }
コード例 #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $images = $request->input('images');
     $gallery_name = 'gallery_' . time();
     $directory = 'uploads/' . $gallery_name . '/';
     mkdir($directory, 0755);
     $gallery = Gallery::create(['name' => $gallery_name, 'directory' => $directory]);
     foreach ($images as $image) {
         $url = $image['url'];
         $img = Image::make($url);
         $img->resize(800, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         preg_match('/\\.[^\\.]+$/i', $url, $ext);
         $filename = $directory . time() . $ext[0];
         $stream = $img->stream();
         $s3 = Storage::disk('s3');
         $s3->put($filename, $stream->__toString(), 'public');
         $client = $s3->getDriver()->getAdapter()->getClient();
         $public_url = $client->getObjectUrl(env('S3_BUCKET'), $filename);
         $gallery->images()->create(['url' => $public_url]);
     }
     $response = ['message' => 'Images successfully uploaded', 'redirect' => url('gallery', $gallery_name)];
     return response()->json($response);
 }
コード例 #8
0
ファイル: TestCase.php プロジェクト: adiachenko/rabbits
 /**
  * Creates the application.
  *
  * @return \Illuminate\Foundation\Application
  */
 public function createApplication()
 {
     $app = (require __DIR__ . '/../bootstrap/app.php');
     $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
     $this->baseUrl = env('APP_URL');
     return $app;
 }
コード例 #9
0
 /**
  * test applying settings in the constructor
  *
  * @return void
  */
 public function testConstructor()
 {
     $object = new BasicAuthenticate($this->Collection, array('userModel' => 'AuthUser', 'fields' => array('username' => 'user', 'password' => 'password')));
     $this->assertEquals('AuthUser', $object->settings['userModel']);
     $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']);
     $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']);
 }
コード例 #10
0
ファイル: Basics.php プロジェクト: Djtec/HumbFramework
 function env($key)
 {
     if ($key === 'HTTPS') {
         if (isset($_SERVER['HTTPS'])) {
             return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
         }
         return strpos(env('SCRIPT_URI'), 'https://') === 0;
     }
     if ($key === 'SCRIPT_NAME') {
         if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) {
             $key = 'SCRIPT_URL';
         }
     }
     $val = null;
     if (isset($_SERVER[$key])) {
         $val = $_SERVER[$key];
     } elseif (isset($_ENV[$key])) {
         $val = $_ENV[$key];
     } elseif (getenv($key) !== false) {
         $val = getenv($key);
     }
     if ($key === 'REMOTE_ADDR' && $val === env('SERVER_ADDR')) {
         $addr = env('HTTP_PC_REMOTE_ADDR');
         if ($addr !== null) {
             $val = $addr;
         }
     }
     if ($val !== null) {
         return $val;
     }
     return null;
 }
コード例 #11
0
ファイル: Site.php プロジェクト: nowarena/homestead
 private static function setDomains($domain = false, $subdomain = false)
 {
     if ($domain !== false && $subdomain !== false) {
         // set domain and subdomain manually
         self::$domain = $domain;
         self::$subdomain = $subdomain;
     } else {
         $domain = env('DOMAIN');
         $subdomain = '';
         //set subdomain - parse the actual url
         if (isset($_SERVER['HTTP_HOST'])) {
             $arr = explode('.', $_SERVER['HTTP_HOST']);
             if (count($arr) == 2) {
                 // if the array is only a length of 2, that means it is the domain name plus extension,
                 // eg. nowarena.com, so no subdomain
                 $subdomain = '';
             } else {
                 $subdomain = strtolower($arr[0]);
             }
         }
         // set values based on what was determined in config/app.php
         self::$domain = $domain;
         self::$subdomain = $subdomain;
     }
 }
コード例 #12
0
ファイル: Remainder.php プロジェクト: princesust/SUN-TASK
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $tasks = Task::where('date', '>=', Carbon::parse(date('d-m-Y')))->where('date', '<=', Carbon::parse(date('d-m-Y'))->addDay(7))->orderBy('date', 'asc')->get();
     \Mail::send('emails.remainder', ['tasks' => $tasks], function ($m) {
         $m->to(env('REMAINDER_EMAIL'), env('REMAINDER_NAME'))->subject('[SUN TASK] Your Task Reminder.');
     });
 }
コード例 #13
0
 public function sendNotificationEmail(Group $group, User $user)
 {
     if ($user->verified == 1) {
         // Establish timestamp for notifications from membership data (when was an email sent for the last time?)
         $membership = \App\Membership::where('user_id', '=', $user->id)->where('group_id', "=", $group->id)->firstOrFail();
         $last_notification = $membership->notified_at;
         // find unread discussions since timestamp
         $discussions = QueryHelper::getUnreadDiscussionsSince($user->id, $group->id, $membership->notified_at);
         // find new files since timestamp
         $files = \App\File::where('updated_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->get();
         // find new members since timestamp
         $users = QueryHelper::getNewMembersSince($user->id, $group->id, $membership->notified_at);
         // find future actions until next 2 weeks, this is curently hardcoded... TODO use the mail sending interval to determine stop date
         $actions = \App\Action::where('start', '>', Carbon::now())->where('stop', '<', Carbon::now()->addWeek()->addWeek())->where('group_id', "=", $group->id)->orderBy('start')->get();
         // we only trigger mail sending if a new action has been **created** since last notfication email.
         // BUT we will send actions for the next two weeks in all cases, IF a mail must be sent
         $actions_count = \App\Action::where('created_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->count();
         // in all cases update timestamp
         $membership->notified_at = Carbon::now();
         $membership->save();
         // if we have anything, build the message and send
         // removed that : or count($users) > 0
         // because we don't want to be notified just because there is a new member
         if (count($discussions) > 0 or count($files) > 0 or $actions_count > 0) {
             Mail::send('emails.notification', ['user' => $user, 'group' => $group, 'membership' => $membership, 'discussions' => $discussions, 'files' => $files, 'users' => $users, 'actions' => $actions, 'last_notification' => $last_notification], function ($message) use($user, $group) {
                 $message->from(env('MAIL_NOREPLY', '*****@*****.**'), env('APP_NAME', 'Laravel'))->to($user->email)->subject('[' . env('APP_NAME') . '] ' . trans('messages.news_from_group_email_subject') . ' "' . $group->name . '"');
             });
             return true;
         }
         return false;
     }
 }
コード例 #14
0
ファイル: TaskListTest.php プロジェクト: r8j3/phragile
 private function addDummyDataToTasks()
 {
     $i = 0;
     $this->tasks = array_map(function ($task) use(&$i) {
         return array_merge($task, ['title' => 'a task', 'priority' => 'low', 'isClosed' => false, 'projectPHIDs' => ['x'], 'ownerPHID' => null, 'id' => ++$i, 'auxiliary' => [env('MANIPHEST_STORY_POINTS_FIELD') => $task['points']]]);
     }, $this->tasks);
 }
コード例 #15
0
ファイル: BinController.php プロジェクト: everdaniel/LaraBin
 public function createGuestPost(Requests\Bins\CreateGuestBin $request)
 {
     $recaptcha = new ReCaptcha(env('RECAPTCHA_SECRET'));
     $response = $recaptcha->verify($request->input('grc-response'), $_SERVER['REMOTE_ADDR']);
     if (!$response->isSuccess()) {
         session()->flash('error', 'You must prove you are human by completing the catpcha!');
         return redirect()->route('bins.create');
     }
     $description = $request->has('description') && trim($request->input('description')) != '' ? $request->input('description') : null;
     $bin = Bin::create(['title' => $request->input('title'), 'description' => $description, 'visibility' => $request->input('visibility')]);
     $bin->versions()->sync($request->input('versions'));
     $files = [];
     foreach ($request->input('name') as $key => $value) {
         $files[$key]['name'] = $value;
     }
     foreach ($request->input('language') as $key => $value) {
         $files[$key]['language'] = $value;
     }
     foreach ($request->input('code') as $key => $value) {
         $files[$key]['code'] = $value;
     }
     foreach ($files as $item) {
         $type = Type::where('css_class', $item['language'])->first();
         $bin->snippets()->create(['type_id' => $type->id, 'name' => $item['name'], 'code' => $item['code']]);
     }
     session()->flash('success', 'Bin created successfully!');
     return redirect()->route('bin.code', $bin->getRouteKey());
 }
コード例 #16
0
ファイル: SiteAccident.php プロジェクト: unclefudge/whs
 /**
  * Email Accident
  */
 public function emailAccident()
 {
     $site = Site::findOrFail($this->site_id);
     $email_list = env('EMAIL_ME');
     if (\App::environment('dev', 'prod')) {
         $email_list = "robert@capecod.com.au; gary@capecod.com.au; tara@capecod.com.au; jo@capecod.com.au; " . $email_list;
         foreach ($site->supervisors as $super) {
             if (preg_match(VALID_EMAIL_PATTERN, $super->email)) {
                 $email_list .= '; ' . $super->email;
             }
         }
     }
     $email_list = trim($email_list);
     $email_list = explode(';', $email_list);
     $email_list = array_map('trim', $email_list);
     // trim white spaces
     $email_user = \App::environment('dev', 'prod') ? Auth::user()->email : '';
     $data = ['id' => $this->id, 'site' => $site->name . ' (' . $site->code . ')', 'address' => $site->address . ', ' . $site->SuburbStatePostcode, 'date' => $this->date->format('d/m/Y g:i a'), 'worker' => $this->name . ' (age: ' . $this->age . ')', 'occupation' => $this->occupation, 'location' => $this->location, 'nature' => $this->nature, 'referred' => $this->referred, 'damage' => $this->damage, 'description' => $this->info, 'user_fullname' => User::find($this->created_by)->fullname, 'user_company_name' => User::find($this->created_by)->company->name, 'submit_date' => $this->created_at->format('d/m/Y g:i a'), 'site_owner' => $site->client->clientOfCompany->name];
     Mail::send('emails.siteAccident', $data, function ($m) use($email_list, $email_user) {
         $m->from('*****@*****.**');
         $m->to($email_list);
         if (preg_match(VALID_EMAIL_PATTERN, $email_user)) {
             $m->cc($email_user);
         }
         $m->subject('WHS Accident Notification');
     });
 }
コード例 #17
0
 /**
  * @param \Symfony\Component\HttpFoundation\ParameterBag $params
  * @param int                                            $page
  * @param int                                            $perPage
  *
  * @return array
  */
 public function paginateByParams(ParameterBag $params, $page = null, $perPage = null)
 {
     $query = $this->_query();
     if ($this->queryDelegate) {
         $query = call_user_func_array($this->queryDelegate, [$query, $params]);
     } else {
         foreach ($params as $name => $value) {
             if ($this->hasColumn($name)) {
                 $query->where($name, '=', $value);
             }
         }
     }
     $method = 'defaultOrderByString';
     if (in_array($method, get_class_methods($this->modelClass))) {
         $orderBy = call_user_func([$this->modelClass, $method]);
         if ($orderBy) {
             $query->orderByRaw($orderBy);
         }
     }
     !$perPage && ($perPage = intval(env('RESTFUL_PER_PAGE', 40)));
     !$page && ($page = 1);
     /** @var \Illuminate\Pagination\LengthAwarePaginator $paginator */
     $paginator = $query->paginate($perPage, ['*'], 'page', $page);
     $array = $paginator->toArray();
     return ['total' => $array['total'], 'per_page' => $array['per_page'], 'next_page_ur' => $this->_pageUrl($array['next_page_url'], $params), 'prev_page_url' => $this->_pageUrl($array['prev_page_url'], $params), 'current_page' => $array['current_page'], 'last_page' => max($array['last_page'], 1), 'list' => $array['data']];
 }
コード例 #18
0
ファイル: Handler.php プロジェクト: spira/api-core
 /**
  * Render an exception into an HTTP response.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Exception               $e
  *
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     $debug = env('APP_DEBUG', false);
     $message = $e->getMessage();
     if (!$message) {
         $message = 'An error occurred';
     }
     $debugData = ['exception' => get_class($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => explode("\n", $e->getTraceAsString())];
     $responseData = ['message' => $message];
     if ($e instanceof HttpExceptionInterface) {
         if (method_exists($e, 'getResponse')) {
             if ($e instanceof TransformableInterface) {
                 $responseData = $e->transform(app(ValidationExceptionTransformer::class));
             } else {
                 $responseData = $e->getResponse();
             }
         }
     }
     if ($debug) {
         $responseData['debug'] = $debugData;
     }
     $response = parent::render($request, $e);
     $response = new JsonResponse($responseData, $response->getStatusCode(), $response->headers->all(), JSON_PRETTY_PRINT);
     $response->exception = $e;
     app('Asm89\\Stack\\CorsService')->addActualRequestHeaders($response, $request);
     return $response;
 }
コード例 #19
0
ファイル: Media.php プロジェクト: carriercomm/koel
 /**
  * Sync the media. Oh sync the media.
  *
  * @param string|null $path
  * @param array       $tags        The tags to sync.
  *                                 Only taken into account for existing records.
  *                                 New records will have all tags synced in regardless.
  * @param bool        $force       Whether to force syncing even unchanged files
  * @param SyncMedia   $syncCommand The SyncMedia command object, to log to console if executed by artisan.
  */
 public function sync($path = null, $tags = [], $force = false, SyncMedia $syncCommand = null)
 {
     if (!app()->runningInConsole()) {
         set_time_limit(env('APP_MAX_SCAN_TIME', 600));
     }
     $path = $path ?: Setting::get('media_path');
     $this->setTags($tags);
     $results = ['good' => [], 'bad' => [], 'ugly' => []];
     $getID3 = new getID3();
     foreach ($this->gatherFiles($path) as $file) {
         $file = new File($file, $getID3);
         $song = $file->sync($this->tags, $force);
         if ($song === true) {
             $results['ugly'][] = $file;
         } elseif ($song === false) {
             $results['bad'][] = $file;
         } else {
             $results['good'][] = $file;
         }
         if ($syncCommand) {
             $syncCommand->logToConsole($file->getPath(), $song);
         }
     }
     // Delete non-existing songs.
     $hashes = array_map(function ($f) {
         return self::getHash($f->getPath());
     }, array_merge($results['ugly'], $results['good']));
     Song::whereNotIn('id', $hashes)->delete();
     // Trigger LibraryChanged, so that TidyLibrary handler is fired to, erm, tidy our library.
     event(new LibraryChanged());
 }
コード例 #20
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (false === env('APP_INSTALLED', false)) {
         return redirect(route('installer.index'));
     }
     return $next($request);
 }
コード例 #21
0
 /**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Events\UserWasInvitedEvent $event
  *
  * @return void
  */
 public function handle(UserWasInvitedEvent $event)
 {
     $mail = ['email' => $event->invite->email, 'subject' => 'You have been invited.', 'link' => route('signup.invite', ['code' => $event->invite->code]), 'app_url' => env('APP_URL')];
     $this->mailer->queue(['html' => 'emails.users.invite-html', 'text' => 'emails.users.invite-text'], $mail, function (Message $message) use($mail) {
         $message->to($mail['email'])->subject($mail['subject']);
     });
 }
コード例 #22
0
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     if (env('APP_ENV') !== 'spira-core-testing') {
         return true;
     }
     Schema::drop(SecondTestEntity::getTableName());
 }
コード例 #23
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $loggingIn = $request->is('api/v1/login') || $request->is('api/v1/register') || $request->is('api/v1/oauth_login');
     $headers = Utils::getApiHeaders();
     $hasApiSecret = false;
     if ($secret = env(API_SECRET)) {
         $requestSecret = Request::header('X-Ninja-Secret') ?: ($request->api_secret ?: '');
         $hasApiSecret = hash_equals($requestSecret, $secret);
     }
     if ($loggingIn) {
         // check API secret
         if (!$hasApiSecret) {
             sleep(ERROR_DELAY);
             return Response::json('Invalid value for API_SECRET', 403, $headers);
         }
     } else {
         // check for a valid token
         $token = AccountToken::where('token', '=', Request::header('X-Ninja-Token'))->first(['id', 'user_id']);
         // check if user is archived
         if ($token && $token->user) {
             Auth::onceUsingId($token->user_id);
             Session::set('token_id', $token->id);
         } else {
             sleep(ERROR_DELAY);
             return Response::json('Invalid token', 403, $headers);
         }
     }
     if (!Utils::isNinja() && !$loggingIn) {
         return $next($request);
     }
     if (!Utils::hasFeature(FEATURE_API) && !$hasApiSecret) {
         return Response::json('API requires pro plan', 403, $headers);
     } else {
         $key = Auth::check() ? Auth::user()->account->id : $request->getClientIp();
         // http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users
         $hour = 60 * 60;
         $hour_limit = 100;
         # users are limited to 100 requests/hour
         $hour_throttle = Cache::get("hour_throttle:{$key}", null);
         $last_api_request = Cache::get("last_api_request:{$key}", 0);
         $last_api_diff = time() - $last_api_request;
         if (is_null($hour_throttle)) {
             $new_hour_throttle = 0;
         } else {
             $new_hour_throttle = $hour_throttle - $last_api_diff;
             $new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle;
             $new_hour_throttle += $hour / $hour_limit;
             $hour_hits_remaining = floor(($hour - $new_hour_throttle) * $hour_limit / $hour);
             $hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
         }
         if ($new_hour_throttle > $hour) {
             $wait = ceil($new_hour_throttle - $hour);
             sleep(1);
             return Response::json("Please wait {$wait} second(s)", 403, $headers);
         }
         Cache::put("hour_throttle:{$key}", $new_hour_throttle, 10);
         Cache::put("last_api_request:{$key}", time(), 10);
     }
     return $next($request);
 }
コード例 #24
0
 /**
  * Execute the job.
  * @return void
  */
 public function handle()
 {
     $s3 = \App::make('aws');
     $s3->createClient('s3')->putObject(['Bucket' => 'transcoderinput435983', 'Key' => $this->key_input, 'SourceFile' => storage_path() . '/app/' . $this->key_input]);
     $s3->createClient('ElasticTranscoder')->createJob(['PipelineId' => env('PIPLINE_ID'), 'Input' => ['Key' => $this->key_input, 'FrameRate' => 'auto', 'Resolution' => 'auto', 'AspectRatio' => 'auto', 'Interlaced' => 'auto', 'Container' => 'auto'], 'Output' => ['Key' => $this->key_output, 'ThumbnailPattern' => $this->time . '_thumb{count}', 'Rotate' => 'auto', 'PresetId' => '1452215960232-me3asn']]);
     \File::delete(storage_path() . '/app/' . $this->key_input);
 }
コード例 #25
0
ファイル: Media.php プロジェクト: Holdlen2DH/koel
 /**
  * Sync the media. Oh sync the media.
  *
  * @param string|null $path
  * @param SyncMedia   $syncCommand The SyncMedia command object, to log to console if executed by artisan.
  */
 public function sync($path = null, SyncMedia $syncCommand = null)
 {
     set_time_limit(env('APP_MAX_SCAN_TIME', 600));
     $path = $path ?: Setting::get('media_path');
     $results = ['good' => [], 'bad' => [], 'ugly' => []];
     // For now we only care about mp3 and ogg files.
     // Support for other formats (AAC?) may be added in the future.
     $files = Finder::create()->files()->name('/\\.(mp3|ogg)$/')->in($path);
     foreach ($files as $file) {
         $song = $this->syncFile($file);
         if ($song === true) {
             $results['ugly'][] = $file;
         } elseif ($song === false) {
             $results['bad'][] = $file;
         } else {
             $results['good'][] = $file;
         }
         if ($syncCommand) {
             $syncCommand->logToConsole($file->getPathname(), $song);
         }
     }
     // Delete non-existing songs.
     $hashes = array_map(function ($f) {
         return $this->getHash($f->getPathname());
     }, array_merge($results['ugly'], $results['good']));
     Song::whereNotIn('id', $hashes)->delete();
     // Empty albums and artists should be gone as well.
     $inUseAlbums = Song::select('album_id')->groupBy('album_id')->get()->lists('album_id');
     $inUseAlbums[] = Album::UNKNOWN_ID;
     Album::whereNotIn('id', $inUseAlbums)->delete();
     $inUseArtists = Album::select('artist_id')->groupBy('artist_id')->get()->lists('artist_id');
     $inUseArtists[] = Artist::UNKNOWN_ID;
     Artist::whereNotIn('id', $inUseArtists)->delete();
 }
コード例 #26
0
ファイル: UserRoleSeeder.php プロジェクト: shiruken1/LEIAs
 public function run()
 {
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     }
     if (env('DB_DRIVER') == 'mysql') {
         DB::table(config('access.assigned_roles_table'))->truncate();
     } elseif (env('DB_DRIVER') == 'sqlite') {
         DB::statement("DELETE FROM " . config('access.assigned_roles_table'));
     } else {
         //For PostgreSQL or anything else
         DB::statement("TRUNCATE TABLE " . config('access.assigned_roles_table') . " CASCADE");
     }
     //Attach admin role to admin user
     $user_model = config('auth.model');
     $user_model = new $user_model();
     $user_model::first()->attachRole(1);
     //Attach user role to general user
     $user_model = config('auth.model');
     $user_model = new $user_model();
     $user_model::find(2)->attachRole(2);
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     }
 }
コード例 #27
0
 public function toViewModel()
 {
     $viewModel = new \stdClass();
     $viewModel->id = $this->id;
     $viewModel->sub_cat_id = $this->sub_cat_id;
     $viewModel->title = $this->title;
     $viewModel->lat = $this->lat;
     $viewModel->lng = $this->lng;
     $viewModel->address = $this->address;
     $viewModel->city = $this->city;
     $viewModel->state = $this->state;
     $viewModel->zipcode = $this->zipcode;
     $viewModel->listingID = $this->listingID;
     $viewModel->resources = [];
     $viewModel->formats = [];
     $formats = explode(',', $this->format);
     foreach ($formats as $format) {
         $viewModel->formats[] = $format;
         $resource = new \stdClass();
         $resource->format = $format;
         $resource->imgs = [];
         for ($i = 1; $i <= $this->num; $i++) {
             $relativePath = $this->img . '_' . $format . '_' . $i . '.' . $this->ext;
             $img = new \stdClass();
             $img->relativePath = $relativePath;
             $img->src = env('UPLOAD_URL') . $relativePath;
             $resource->imgs[] = $img;
         }
         $viewModel->resources[] = $resource;
     }
     return $viewModel;
 }
コード例 #28
0
ファイル: ConversionTest.php プロジェクト: oscarotero/env
 public function testEnv()
 {
     $this->assertTrue(Env::init());
     putenv('FOO=123');
     $this->assertSame(123, env('FOO'));
     $this->assertFalse(Env::init());
 }
コード例 #29
0
 /**
  * Take the incomming request referrer and decide if we should save this term in our
  * database
  * @param incoming request usually $this->here
  * @return void
  * @access public
  */
 function parseRequest($request = null)
 {
     if ($request) {
         $referrer = env('HTTP_REFERER');
         // Check if from google and page 2
         if (strpos($referrer, "google.com")) {
             if (!SeoUtil::getConfig('searchTerms')) {
                 return;
             }
             //parse the term out.
             if (strpos($referrer, "q=")) {
                 list($ignore, $term) = explode("q=", $referrer);
                 if (strpos($term, "&")) {
                     list($term, $ignore) = explode("&", $term);
                 }
                 $term = trim(urldecode($term));
                 if ($term && strpos($referrer, "start=")) {
                     //Only proceed if we have a valid term
                     if ($id = $this->field('id', array('SeoSearchTerm.term' => $term))) {
                         $this->itterateCount($id);
                     } else {
                         $data = array('SeoSearchTerm' => array('term' => $term, 'uri' => $request, 'count' => 1));
                         $this->save($data);
                     }
                 } elseif ($term) {
                     //Delete the term if this was found on the first page.
                     if ($id = $this->field('id', array('SeoSearchTerm.term' => $term))) {
                         $this->delete($id);
                     }
                 }
             }
         }
     }
 }
コード例 #30
-2
 public function submitForm(Request $request)
 {
     //Get input
     $input = Input::all();
     //Date
     $input["Date"] = date("j/ n/ Y");
     //Bools for Parties
     if ($input["party"] == "Republican") {
         $input["Rep"] = "Yes";
     } else {
         $input["Dem"] = "Yes";
     }
     //concat name
     $input["Voter_Name"] = $input["first_name"] . " " . $input["last_name"];
     $contents = Storage::disk('local');
     $storagePath = Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
     // $contents = Storage::get('reg.pdf');
     //Save as FDF
     $fdf = new FdfFile($input);
     $fdf->saveAs('data.fdf');
     $docId = md5(uniqid(rand(), true));
     //Save as Pdf
     $pdf = new Pdf($storagePath . 'template.pdf');
     $pdf->fillForm($fdf->getFileName())->saveAs($storagePath . "generated/" . $docId . '.pdf');
     //Setting up Lob
     $apiKey = env('LOB_KEY');
     $lob = new \Lob\Lob($apiKey);
     //Send the letter
     $letter = $lob->letters()->create(array('description' => 'Voter Registration', 'to[name]' => 'Town Clerk', 'to[address_line1]' => '230 Main St, Ste 108', 'to[address_city]' => 'Brattleboro', 'to[address_zip]' => '05301', 'to[address_state]' => 'VT', 'to[address_country]' => 'US', 'from[name]' => 'Benjamin Franklin', 'from[address_line1]' => '123 Fake Street', 'from[address_city]' => 'Philadelphia', 'from[address_zip]' => '94041', 'from[address_state]' => 'PA', 'from[address_country]' => 'US', 'file' => '@' . realpath($storagePath . "generated/" . $docId . '.pdf'), 'color' => false));
     $letter['file'] = $storagePath . "generated/" . $docId . '.pdf';
     return View::make('thanks', $letter)->with('data', $letter);
 }