/**
  * Install the components.
  *
  * @return void
  */
 public function install()
 {
     if (Str::contains(file_get_contents(base_path('.env')), 'AUTHY_SECRET')) {
         return;
     }
     (new Filesystem())->append(base_path('.env'), file_get_contents(SPARK_HEX_STUB_PATH . '/.env'));
 }
 public function rollback()
 {
     if (Str::contains($this->menuContents, $this->menuTemplate)) {
         file_put_contents($this->path, str_replace($this->menuTemplate, '', $this->menuContents));
         $this->commandData->commandComment('menu deleted');
     }
 }
示例#3
0
文件: XML.php 项目: phpnfe/tools
 /**
  * Retorna informações do XML com base no caminho separado por ponto.
  *
  * @param $key
  * @return XMLGet
  */
 public function get($key)
 {
     if (Str::contains($key, '|')) {
         $opcoes = explode('|', $key);
         foreach ($opcoes as $op) {
             $achado = $this->get($op);
             if (!$achado->isNull()) {
                 return $achado;
             }
         }
         return new XMLGet(null);
     }
     $base = $this;
     $niveis = $key == '' ? [] : explode('.', $key);
     foreach ($niveis as $i => $nivel) {
         // Verificar se base eh nula
         if (is_null($base)) {
             return new XMLGet(null);
         }
         $elem = $base->getElementsByTagName($nivel);
         $base = $elem->length > 0 ? $elem->item(0) : null;
     }
     // Retornar o conteúdo do ultimo nível
     if (!is_null($base)) {
         return new XMLGet($base);
     }
     return new XMLGet(null);
 }
示例#4
0
    /**
     * Append disqus script on the end of the page.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Illuminate\Http\Response $response
     * @return mixed
     */
    protected function appendDisqusScript($request, $response)
    {
        $content = $response->getContent();
        if (!Str::contains($content, '<div id="disqus_thread"></div>')) {
            return;
        }
        $uri = $request->getRequestUri();
        $pageUrl = url($uri);
        $pageId = 'route' . implode('.', explode('/', $uri));
        $username = config('disqus.username');
        $disqusHtml = <<<CDATA
<script>
     var disqus_config = function () {
         this.page.url = '{$pageUrl}';
         this.page.identifier = '{$pageId}';
     };

    (function() {  // DON'T EDIT BELOW THIS LINE
        var d = document, s = d.createElement('script');

        s.src = '//{$username}.disqus.com/embed.js';

        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href=\\"https://disqus.com/?ref_noscript\\" rel=\\"nofollow\\">comments powered by Disqus.</a></noscript>
CDATA;
        $bodyPosition = strripos($content, '</body>');
        if (false !== $bodyPosition) {
            $content = substr($content, 0, $bodyPosition) . $disqusHtml . substr($content, $bodyPosition);
        }
        $response->setContent($content);
    }
 /**
  * @param Message $message
  * @return mixed
  */
 public function handle(Message $message)
 {
     if ($message->user->login === \Auth::user()->login) {
         return $message;
     }
     // Personal message
     $isBotMention = $message->hasMention(function (User $user) {
         return $user->login === \Auth::user()->login;
     });
     if ($isBotMention) {
         //$this->ai->handle($message);
     } else {
         // Hello all
         $isHello = Str::contains($message->text_without_special_chars, \Lang::get('personal.hello_query'));
         if ($isHello) {
             $id = array_rand(\Lang::get('personal.hello'));
             $message->italic(\Lang::get('personal.hello.' . $id, ['user' => $message->user->login]));
         }
         // Question
         $isQuestion = Str::contains($message->text_without_special_chars, ['можно задать вопрос', 'хочу задать вопрос']);
         if ($isQuestion) {
             $message->italic(sprintf('@%s, и какой ответ ты ожидаешь услышать?', $message->user->login));
         }
     }
     return $message;
 }
示例#6
0
 /**
  * Strip the protocol from a domain.
  *
  * @param string $domain
  *
  * @return string
  */
 protected function stripProtocol($domain)
 {
     if (Str::contains($domain, '://')) {
         $domain = substr($domain, strpos($domain, '://') + 3);
     }
     return $domain;
 }
 /**
  * Retrieve a user by the given credentials.
  *
  * @param  array  $credentials
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     if (empty($credentials)) {
         return null;
     }
     $index = null;
     $values = null;
     foreach ($credentials as $key => $value) {
         if (!Str::contains($key, 'password')) {
             $index = is_null($index) ? $key : $index . '_' . $key;
             $values = is_null($values) ? [] : $values;
             $values[] = $value;
         }
     }
     if (is_null($index) || is_null($values)) {
         return null;
     }
     $values = count($values) == 1 ? $values[0] : $values;
     $result = $this->createModel()->newQuery()->getQuery()->r()->getAll($values, ['index' => $index])->run();
     $result = $this->hydrate($result);
     if ($result) {
         $result = $result->first();
     }
     return $result;
 }
 /**
  * @param $template
  * @return \Illuminate\Contracts\View\View
  */
 protected function view($template)
 {
     if (Str::contains($template, '::')) {
         return $this->view->make($template);
     } else {
         return $this->view->make('admin::' . $template);
     }
 }
 protected function isRelationship(ReflectionMethod $method)
 {
     if ($method->getNumberOfParameters()) {
         return false;
     }
     $source = $this->getMethodSource($method);
     return Str::contains($source, $this->getRelationshipStrings());
 }
示例#10
0
 protected function formatHelperName($helper)
 {
     $namespace = $this->app->getNamespace();
     if (!Str::contains($helper, $namespace)) {
         $helper = $namespace . 'Helpers\\' . $helper;
     }
     return $helper;
 }
示例#11
0
 public function handle(Request $request, Closure $next)
 {
     $agent = $request->header('User-Agent');
     if ($agent && Str::contains($agent, $this->badUserAgents)) {
         return abort(400);
     }
     return $next($request);
 }
示例#12
0
 public static function setActive($path, $active = 'active')
 {
     //funcion para agregar la clase active en el menu del sistema
     if (Str::contains(Request::capture()->path(), 'auth')) {
         return '';
     }
     return Str::contains(Request::capture()->path(), $path) ? $active : '';
 }
 public function rollback()
 {
     if (Str::contains($this->routeContents, $this->routesTemplate)) {
         $this->routeContents = str_replace($this->routesTemplate, '', $this->routeContents);
         file_put_contents($this->path, $this->routeContents);
         $this->commandData->commandComment('scaffold routes deleted');
     }
 }
 /**
  * Apply modifiers to some commands before
  * they're executed
  *
  * @param string $command
  *
  * @return string
  */
 public function processCommand($command)
 {
     // Add environment flag to commands
     $stage = $this->connections->getCurrentConnectionKey()->stage;
     if (Str::contains($command, 'artisan') && $stage) {
         $command .= ' --env="' . $stage . '"';
     }
     return $command;
 }
示例#15
0
 /**
  * @param \Notadd\Foundation\Extension\ExtensionManager           $manager
  * @param \Notadd\Foundation\Setting\Contracts\SettingsRepository $settings
  *
  * @return bool
  */
 public function fire(ExtensionManager $manager, SettingsRepository $settings)
 {
     $name = $this->input->getArgument('name');
     $extensions = $manager->getExtensionPaths();
     if (!$extensions->offsetExists($name)) {
         $this->error("Extension {$name} do not exist!");
         return false;
     }
     if (!$this->container->make(SettingsRepository::class)->get('extension.' . $name . '.installed')) {
         $this->error("Extension {$name} does not installed!");
         return false;
     }
     $extension = $extensions->get($name);
     $path = $extension;
     if (Str::contains($path, $manager->getVendorPath())) {
         $this->error("Please update extension {$name} from composer command!");
         return false;
     }
     $extensionFile = new JsonFile($path . DIRECTORY_SEPARATOR . 'composer.json');
     $extension = collect($extensionFile->read());
     if ($extension->has('autoload')) {
         $autoload = collect($extension->get('autoload'));
         $autoload->has('classmap') && collect($autoload->get('classmap'))->each(function ($value) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
             if (!in_array($path, $this->backup['autoload']['classmap'])) {
                 $this->backup['autoload']['classmap'][] = $path;
             }
         });
         $autoload->has('files') && collect($autoload->get('files'))->each(function ($value) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value));
             if (!in_array($path, $this->backup['autoload']['files'])) {
                 $this->backup['autoload']['files'][] = $path;
             }
         });
         $autoload->has('psr-0') && collect($autoload->get('psr-0'))->each(function ($value, $key) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
             $this->backup['autoload']['psr-0'][$key] = $path;
         });
         $autoload->has('psr-4') && collect($autoload->get('psr-4'))->each(function ($value, $key) use($path) {
             $path = str_replace($this->container->basePath() . '/', '', realpath($path . DIRECTORY_SEPARATOR . $value)) . '/';
             $this->backup['autoload']['psr-4'][$key] = $path;
         });
         $this->json->addProperty('autoload', $this->backup['autoload']);
         $settings->set('extension.' . $name . '.autoload', json_encode($autoload->toArray()));
     }
     if ($extension->has('require')) {
         $require = collect($extension->get('require'));
         $require->each(function ($version, $name) {
             $this->backup['require'][$name] = $version;
         });
         $this->json->addProperty('require', $this->backup['require']);
         $settings->set('extension.' . $name . '.require', json_encode($require->toArray()));
     }
     $this->updateComposer(true);
     $this->info("Extension {$name} is updated!");
     return true;
 }
示例#16
0
 /**
  * Filter out ignored entities.
  *
  * @return Collection
  */
 protected function filterEntities()
 {
     $ignored = $this->codebase->getIgnored();
     $entities = new Collection($this->createEntities());
     $entities = $entities->filter(function (AbstractAnalyzedEntity $entity) use($ignored) {
         return !Str::contains($entity->name, $ignored);
     });
     return $entities;
 }
示例#17
0
 /**
  * Set a data-url attribute
  *
  * @param string $route
  */
 protected function setRoute($route)
 {
     // Find route
     $route = Str::contains('@', $route) ? $this->app['url']->controller($route) : $this->app['url']->route($route);
     if ($route) {
         $this->setAttribute('data-url', $route);
     }
     return $this;
 }
 /**
  * Restore the model after serialization.
  *
  * @return void
  */
 public function __wakeup()
 {
     foreach ($this->data as $key => $value) {
         $this->data[$key] = $this->getRestoredPropertyValue($value);
     }
     if (Str::contains($this->callback, 'SerializableClosure')) {
         $this->callback = (new Serializer())->unserialize($this->callback);
     }
 }
示例#19
0
文件: Basic.php 项目: younes0/reglex
 public function loi()
 {
     $regExp = $this->defaultBuilder()->anyOf(['L.', 'LO.', 'loi n°', 'loi organique n°'])->maybe(' ')->append($this->getBuilder()->eitherFind($this->twoNumbers())->orFind($this->oneNumber()))->asGroup('numero')->optional($this->getBuilder()->then(' du ')->append($this->getBuilder()->anyOf(Utils::$codesFr))->asGroup('code'))->getRegExp();
     $results = $regExp->findIn($this->string);
     foreach ($results[0] as $key => $value) {
         $results['organique'][$key] = Str::contains($value, ['loi organique', 'LO.']);
     }
     return $this->reformat($results, ['numero', 'code']);
 }
 /**
  * Minify the attribute quotes if allowed.
  *
  * @param array $match
  *
  * @return string
  */
 protected function minifyAttribute($match)
 {
     if (Str::contains($match[2], $this->prohibitedChars)) {
         return $match[0];
     } elseif (preg_match('/' . Constants::PLACEHOLDER_PATTERN . '/is', $match[2])) {
         return $match[0];
     }
     return '=' . $match[2];
 }
 /**
  * @inheritdoc
  */
 public function retrieveByCredentials(array $credentials)
 {
     $query = $this->createModel()->newQuery();
     foreach ($credentials as $key => $value) {
         if (!Str::contains($key, 'secret')) {
             $query->where($key, $value);
         }
     }
     return $query->first();
 }
示例#22
0
 /**
  * Nelgect all vendor files.
  *
  * @param $filesByFile Collection
  * @return array
  */
 private function neglectVendorFiles($filesByFile)
 {
     $return = [];
     foreach ($filesByFile->toArray() as $key => $value) {
         if (!Str::contains($key, ':')) {
             $return[$key] = $value;
         }
     }
     return $return;
 }
示例#23
0
 /**
  * Parses the input string.
  *
  * @param  string $input
  *
  * @return array
  */
 protected static function parse($input)
 {
     $command = $input;
     $description = null;
     if (Str::contains($input, ' : ')) {
         list($command, $description) = explode(' : ', $input);
         $description = trim($description);
     }
     return [trim($command), $description];
 }
示例#24
0
 /**
  * Get route domain.
  *
  * @param  bool  $forceBase
  *
  * @return string|null
  */
 public function domain($forceBase = false)
 {
     $pattern = $this->domain;
     if (is_null($pattern) && $forceBase === true) {
         $pattern = $this->baseUrl;
     } elseif (Str::contains($pattern, '{{domain}}')) {
         $pattern = str_replace('{{domain}}', $this->baseUrl, $pattern);
     }
     return $pattern;
 }
 private function namespaceChecker($string)
 {
     if (!is_null($string)) {
         if (Str::contains($string, '/')) {
             $string = str_replace('/', '\\', $string);
         }
         return str_finish($string, '\\');
     }
     return $string;
 }
 /**
  * Turn the given URI into a fully qualified URL.
  *
  * @param  string $uri
  *
  * @return string
  */
 protected function prepareUrlForRequest($uri)
 {
     $uri = parent::prepareUrlForRequest($uri);
     if (Str::contains('?', $uri)) {
         $uri .= '&token=' . DummyAuthBundle::$token;
     } else {
         $uri .= '?token=' . DummyAuthBundle::$token;
     }
     return $uri;
 }
 /**
  * Get resource.
  *
  * @return string
  */
 protected function getResourceOption()
 {
     $name = $this->getNameInput();
     $resource = $this->option('resource') ?: $name;
     if (Str::contains($resource, '/')) {
         $segments = explode('/', $resource);
         $resource = is_array($segments) ? end($segments) : $resource;
     }
     return Str::singular($resource);
 }
 /**
  * Parse class name.
  *
  * @param string $name
  *
  * @return string
  */
 protected function parseClassName($name)
 {
     $rootNamespace = $this->laravel->getNamespace();
     if (Str::startsWith($name, $rootNamespace)) {
         return $name;
     }
     if (Str::contains($name, '/')) {
         $name = str_replace('/', '\\', $name);
     }
     return trim($rootNamespace, '\\') . '\\' . $name;
 }
示例#29
0
 /**
  * Parse the name and format according to the root namespace.
  *
  * @param string $name
  *
  * @return string
  */
 protected function parseName($name)
 {
     $rootNamespace = config('modules.namespace');
     if (Str::startsWith($name, $rootNamespace)) {
         return $name;
     }
     if (Str::contains($name, '/')) {
         $name = str_replace('/', '\\', $name);
     }
     return $this->parseName($this->getDefaultNamespace(trim($rootNamespace, '\\')) . '\\' . $name);
 }
示例#30
0
 /**
  * Register an event listener with the dispatcher.
  *
  * @param  string|array  $events
  * @param  mixed  $listener
  * @param  int  $priority
  * @return void
  */
 public function listen($events, $listener, $priority = 0)
 {
     foreach ((array) $events as $event) {
         if (Str::contains($event, '*')) {
             $this->setupWildcardListen($event, $listener);
         } else {
             $this->listeners[$event][$priority][] = $this->makeListener($listener);
             unset($this->sorted[$event]);
         }
     }
 }