/** * Returns the maximum accepted file size * * @return int */ public function maxSize() { $sizes = array(detect::maxPostSize(), detect::maxUploadSize()); if ($this->options['maxSize']) { $sizes[] = $this->options['maxSize']; } return min($sizes); }
public function __construct($options = array()) { $this->roots = new Roots(dirname(__DIR__)); $this->urls = new Urls(); $this->options = array_merge($this->defaults(), $options); $this->path = implode('/', (array) url::fragments(detect::path())); // make sure the instance is stored / overwritten static::$instance = $this; }
public function __construct($to, $params = array()) { $defaults = array('input' => 'file', 'to' => $to, 'overwrite' => true, 'maxSize' => detect::maxUploadSize(), 'accept' => null); $this->options = array_merge($defaults, $params); try { $this->move(); $this->file = new Media($this->to()); } catch (Exception $e) { $this->error = $e; } }
public function source() { $source = isset($_FILES[$this->options['input']]) ? $_FILES[$this->options['input']] : null; // prevent duplicate ios uploads // ios automatically uploads all images as image.jpg, // which will lead to overwritten duplicates. // this dirty hack will simply add a uniqid between the // name and the extension to avoid duplicates if ($source and f::name($source['name']) == 'image' and detect::ios()) { $source['name'] = 'image-' . uniqid() . ltrim('.' . f::extension($source['name']), '.'); } return $source; }
public static function configure() { if (is_null(static::$site)) { static::$site = kirby::panelsetup(); } // load all available routes static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'api.php'); static::$routes = array_merge(static::$routes, require root('panel.app.routes') . DS . 'views.php'); // setup the blueprint root blueprint::$root = c::get('root.site') . DS . 'blueprints'; // start the router static::$router = new Router(); static::$router->register(static::$routes); // content language switcher variable if (static::$site->multilang()) { if ($language = server::get('http_language') or $language = s::get('lang')) { static::$site->visit('/', $language); } app::$language = static::$site->language()->code(); s::set('lang', app::$language); } // load the interface language file if (static::$site->user()) { $languageCode = static::$site->user()->language(); } else { $languageCode = c::get('panel.language', 'en'); } // validate the language code if (!in_array($languageCode, static::languages()->keys())) { $languageCode = 'en'; } // store the interface language app::$interfaceLanguage = $languageCode; $language = (require root('panel.app.languages') . DS . $languageCode . '.php'); // set all language variables l::$data = $language['data']; // register router filters static::$router->filter('auth', function () { if (!app::$site->user()) { go('panel/login'); } }); // check for a completed installation static::$router->filter('isInstalled', function () { if (app::$site->users()->count() == 0) { go('panel/install'); } }); // only use the fragments of the path without params static::$path = implode('/', (array) url::fragments(detect::path())); }
public function source() { $source = isset($_FILES[$this->options['input']]) ? $_FILES[$this->options['input']] : null; // get the correct file out of multiple based on the "index" option if ($source && is_int($this->options['index']) && is_array($source['name'])) { $allSources = $source; $source = array(); // get the correct value out of the $values array with all files foreach ($allSources as $key => $values) { $source[$key] = isset($values[$this->options['index']]) ? $values[$this->options['index']] : null; } } // prevent duplicate ios uploads // ios automatically uploads all images as image.jpg, // which will lead to overwritten duplicates. // this dirty hack will simply add a uniqid between the // name and the extension to avoid duplicates if ($source and f::name($source['name']) == 'image' and detect::ios()) { $source['name'] = 'image-' . uniqid() . ltrim('.' . f::extension($source['name']), '.'); } return $source; }
/** * Returns the correct separator for parameters * depending on the operating system * * @return string */ public static function paramSeparator() { return detect::windows() ? ';' : ':'; }
/** * Iterate through every route to find a matching route. * * @param string $path Optional path to match against * @return Route */ public function run($path = null) { $method = r::method(); $ajax = r::ajax(); $https = r::ssl(); $routes = a::get($this->routes, $method, array()); // detect path if not set manually if ($path === null) { $path = implode('/', (array) url::fragments(detect::path())); } // empty urls should never happen if (empty($path)) { $path = '/'; } foreach ($routes as $route) { if ($route->https and !$https) { continue; } if ($route->ajax and !$ajax) { continue; } // handle exact matches if ($route->pattern == $path) { $this->route = $route; break; } // We only need to check routes with regular expression since all others // would have been able to be matched by the search for literal matches // we just did before we started searching. if (strpos($route->pattern, '(') === false) { continue; } $preg = '#^' . $this->wildcards($route->pattern) . '$#u'; // If we get a match we'll return the route and slice off the first // parameter match, as preg_match sets the first array item to the // full-text match of the pattern. if (preg_match($preg, $path, $parameters)) { $this->route = $route; $this->route->arguments = array_slice($parameters, 1); break; } } if ($this->route and $this->filterer($this->route->filter) !== false) { return $this->route; } else { return null; } }
<?php if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } /* --------------------------------------- License Setup --------------------------------------- Please add your license key, which you've received via email after purchasing Kirby on http://getkirby.com/buy It is not permitted to run a public website without a valid license key. Please read the End User License Agreement for more information: http://getkirby.com/license */ c::set('license', yaml::read(detect::documentRoot() . DS . 'secrets.yml')['licenses']['kirby']); /* --------------------------------------- Kirby Configuration --------------------------------------- By default you don't have to configure anything to make Kirby work. For more fine-grained configuration of the system, please check out http://getkirby.com/docs/advanced/options */ c::set('markdown.extra', true); c::set('smartypants', true);
public function requirements() { if (!version_compare(PHP_VERSION, static::$requires['php'], '>=')) { throw new Exception('Your PHP version is too old. Please upgrade to ' . static::$requires['php'] . ' or newer.'); } if (!detect::mbstring()) { throw new Exception('The mbstring extension must be installed'); } if (!version_compare(toolkit::version(), static::$requires['toolkit'], '>=')) { throw new Exception('Your Toolkit version is too old. Please upgrade to ' . static::$requires['toolkit'] . ' or newer.'); } if (!version_compare(kirby::version(), static::$requires['kirby'], '>=')) { throw new Exception('Your Kirby version is too old. Please upgrade to ' . static::$requires['kirby'] . ' or newer.'); } }
/** * The path which will be used for the router * * @return string */ public static function path() { return implode('/', (array) url::fragments(detect::path())); }
$city = get('city'); if (!$city) { $error = 'City is required.'; goto errored; } $state = get('state'); if (!$state) { $error = 'State is required.'; goto errored; } $zip = get('zip'); if (!$zip) { $error = 'ZIP is required.'; goto errored; } \Stripe\Stripe::setApiKey(yaml::read(detect::documentRoot() . DS . 'secrets.yml')['keys']['stripe']['secret']); // Get the credit card details submitted by the form $token = get('stripeToken'); try { $customer = \Stripe\Customer::create(["source" => $token, "email" => $email, "metadata" => ["name" => $name, "address" => $address, "city" => $city, "state" => strtoupper($state), "zip" => $zip]]); $charge = \Stripe\Charge::create(["amount" => $amount * 100, "currency" => "usd", "customer" => $customer->id, "description" => "Web donation", "receipt_email" => $email]); $completed = true; } catch (\Stripe\Error\Card $e) { $error = $e->getMessage(); goto errored; } catch (\Stripe\Error\InvalidRequest $e) { $error = $e->getMessage(); goto errored; } } errored:
"> <meta name="keywords" content="<?php echo $site->keywords()->html(); ?> "> <link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Raleway:500,600,700" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic" rel="stylesheet" /> <?php echo css('public/styles/evanosky.css'); ?> <script type="text/javascript" src="https://js.stripe.com/v2/"></script> <script type="text/javascript"> Stripe.setPublishableKey("<?php echo yaml::read(detect::documentRoot() . DS . 'secrets.yml')['keys']['stripe']['publishable']; ?> "); </script> <?php echo js('public/scripts/vendor/modernizr-custom.min.js'); ?> <div class="invisible"><?php echo file_get_contents(url('public/sprites.svg')); ?> </div> <div class="wrapper"> <?php snippet('site-header');