Beispiel #1
0
 public function __construct()
 {
     parent::__construct();
     $url = parse_url(request()->getUri());
     $url = trim($url['path'], '/');
     if (empty($url)) {
         redirect('https://' . Registry::getInstance()->get('host'));
     }
     $this->imageHandler = new NinjaImageHandler($url);
 }
Beispiel #2
0
 public function __construct()
 {
     parent::__construct();
     // GetSite contains information about the site - here we can add javascript and change styling etc.
     $this->getSite()->setTitle('NinjaImg.com');
     $this->getSite()->setDescription('Let our Ninja\'s manage your files directly from S3, FTP or SFTP with a breeze, so you can focus on your business.');
     // Make sure that requests from other than ninjaimg.com are redirected
     if (!$this->getSite()->getDebug() && strtolower(request()->getHost()) != Registry::getInstance()->get('host')) {
         redirect('https://' . Registry::getInstance()->get('host') . $_SERVER['REQUEST_URI'], 301);
     }
     $this->mainMenu = new Menu();
     $this->mainMenu->addClass('nav navbar-nav navbar-right');
 }
Beispiel #3
0
 public function handle(Request $request)
 {
     $domain = env('DEBUG', false) ? 'dscuz' : str_ireplace('.' . Registry::getInstance()->get('host'), '', $request->getHost());
     $request->source = Memcache::getInstance()->put('source_' . $domain, 60 * 60, function () use($domain) {
         return Source::getBySubdomain($domain);
     });
     $this->setParameters($request);
     if (!$request->source->hasRow()) {
         throw new \ErrorException('Invalid source.');
     }
     if ($request->source->getOrganisation() !== null && $request->source->getOrganisation()->disabled) {
         throw new OrganisationDisabledException('Source has been disabled');
     }
     if ($request->source->require_ssl && !$request->getIsSecure()) {
         redirect('https://' . $request->getHost() . $request->getUri(), 101);
     }
     // Check for valid api-token if posting
     if ($request->getMethod() !== 'get') {
         $token = request()->getHeader('X-Auth-Token');
         if ($token === null || $token !== $request->source->getOrganisation()->api_token) {
             throw new \InvalidArgumentException('Invalid X-Auth-Token.');
         }
     }
 }
Beispiel #4
0
<?php

use Pecee\DB\Pdo;
use Pecee\Locale;
$key = \Pecee\Registry::getInstance();
$site = \Pecee\UI\Site::getInstance();
/* ---------- Configuration start ---------- */
$key->set('host', 'ninjaimg.com');
// Debug mode enabled
$site->setDebug(env('DEBUG'));
/* Database */
$key->set(Pdo::SETTINGS_CONNECTION_STRING, 'mysql:host=' . env('DB_HOST') . ';dbname=' . env('DB_DATABASE') . ';charset=utf8');
$key->set(Pdo::SETTINGS_USERNAME, env('DB_USERNAME'));
$key->set(Pdo::SETTINGS_PASSWORD, env('DB_PASSWORD'));
/* Site main language */
Locale::getInstance()->setLocale('da-DK');
Locale::getInstance()->setDefaultLocale('da-DK');
// Add IP's that are allowed to debug, clear-cache etc.
$site->addAdminIp('127.0.0.1');
$site->addAdminIp('::1');
/* ---------- Configuration end ---------- */
Beispiel #5
0
 public function toPHP($filename = null)
 {
     if ($this->getTag() === 'phtml') {
         $result = $this->getInnerPHP();
         if ($filename !== null) {
             file_put_contents($filename, $result);
         }
         return $result;
     }
     $str = '<';
     $method = false;
     $body = '';
     if ($this->getNs()) {
         $method = true;
     } else {
         $str .= $this->getTag();
     }
     if (count($this->getAttrs()) > 0) {
         if ($method) {
             $str .= 'array(';
         } else {
             $str .= ' ';
         }
         foreach ($this->getAttrs() as $name => $val) {
             if ($method) {
                 $str .= sprintf('"%s"=>%s,', $name, $this->processAttrValue($val));
             } else {
                 $str .= sprintf('%s="%s" ', $name, $val);
             }
         }
         if ($method) {
             $str = trim($str, ',') . '),';
         } else {
             $str = trim($str);
         }
     } else {
         if ($method) {
             $str .= 'array(),';
         }
     }
     if ($this->isContainer()) {
         if (!$method) {
             $str .= '>';
         } else {
             $body = '';
         }
         if ($method) {
             $body .= $this->getInnerPHP();
         } else {
             $str .= $this->getInnerPHP();
         }
         if ($method) {
             $taglibs = Registry::getInstance()->get(Phtml::SETTINGS_TAGLIB, []);
             if (isset($taglibs[$this->getNs()])) {
                 $tag = $this->getTag();
                 $str = $taglibs[$this->getNs()]->callTag($tag, $this->getAttrs(), $body);
             }
         } else {
             $str .= sprintf("</%s>", $this->getTag());
         }
     } else {
         if ($method) {
             $taglibs = Registry::getInstance()->get(Phtml::SETTINGS_TAGLIB, []);
             if (isset($taglibs[$this->getNs()])) {
                 $tag = $this->getTag();
                 $str = $taglibs[$this->getNs()]->callTag($tag, $this->getAttrs(), null, null);
             }
         } else {
             $str .= '/>';
         }
     }
     if ($this->getParent() == null || $this->getParent()->getTag() == 'phtml') {
         $str = self::$prepend . $str . self::$append;
         self::$prepend = '';
         self::$append = '';
     }
     $str = $this->processEvals($str);
     if ($filename !== null) {
         file_put_contents($filename, $str);
     }
     return $str;
 }
Beispiel #6
0
 protected function formatUrl(ModelActivity $activity)
 {
     return sprintf('http://%s.%s/%s', $activity->getSource()->subdomain, Registry::getInstance()->get('host'), $activity->path);
 }