Exemple #1
0
<?php

/*
|--------------------------------------------------------------------------
| Load Site Configuration
|--------------------------------------------------------------------------
|
| Before anything we need to load all the user-specified configurations,
| global variables, custom routes, and theme settings. Many methods
| depend on these settings.
|
*/
$config = Statamic::loadAllConfigs();
$config['_cookies.secret_key'] = Cookie::getSecretKey();
$config['log_enabled'] = TRUE;
$config['log.level'] = Log::convert_log_level($config['_log_level']);
$config['whoops.editor'] = 'sublime';
$config['log.writer'] = new Statamic_Logwriter(array('path' => $config['_log_file_path'], 'file_prefix' => $config['_log_file_prefix']));
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Many users are upgrading to PHP 5.3 for the first time. I know.
| We've gone ahead set the default timezone that will be used by the PHP
| date and date-time functions. This prevents some potentially
| frustrating errors for novice developers.
|
*/
date_default_timezone_set(Helper::pick($config['_timezone'], @date_default_timezone_get(), "UTC"));
/*
 public function member__forgot_password()
 {
     $globals = Statamic::loadAllConfigs();
     $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
     $token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING);
     $return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_STRING);
     $reset_return = filter_input(INPUT_POST, 'reset_return', FILTER_SANITIZE_STRING);
     $referrer = Request::getReferrer();
     // validate form token
     if (!$this->tokens->validate($token)) {
         $this->flash->set('forgot_password_error', 'Invalid token.');
         URL::redirect($referrer);
     }
     // bail if member doesn't exist
     if (!($member = Member::load($username))) {
         $this->flash->set('forgot_password_error', Localization::fetch('member_doesnt_exist'));
         URL::redirect($referrer);
     }
     // cache reset data
     $token = $this->tokens->create();
     $reset_data = array('username' => $username);
     if (isset($reset_return)) {
         $reset_data['return'] = $reset_return;
     }
     $this->cache->putYAML($token, $reset_data);
     // generate reset url
     $reset_url = URL::makeFull($this->fetchConfig('reset_password_url', str_replace(Config::getSiteURL(), '', $referrer)));
     $reset_url .= '?H=' . $token;
     // send email
     $attributes = array('from' => $this->fetchConfig('email_sender', Config::get('email_sender'), null, false, false), 'to' => $member->get('email'), 'subject' => $this->fetchConfig('reset_password_subject', 'Password Reset', null, false, false));
     if ($html_template = $this->fetchConfig('reset_password_html_email', false, null, false, false)) {
         $attributes['html'] = Theme::getTemplate($html_template);
     }
     if ($text_template = $this->fetchConfig('reset_password_text_email', false, null, false, false)) {
         $attributes['text'] = Theme::getTemplate($text_template);
     }
     foreach ($attributes as $key => $value) {
         $attributes[$key] = Parse::template($value, array('reset_url' => $reset_url), array('statamic_view', 'callback'), $globals);
     }
     Email::send($attributes);
     $this->flash->set('forgot_password_sent', true);
     // redirect
     URL::redirect($return);
 }
|--------------------------------------------------------------------------
|
| "Autoload" the application dependencies and libraries
|
*/
require __DIR__ . '/_app/autoload.php';
/*
|--------------------------------------------------------------------------
| Load Configs
|--------------------------------------------------------------------------
|
| We need to load the configs here because we don't necessarily know
| the name of the admin folder.
|
*/
$config = Statamic::loadAllConfigs(true);
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Many users are upgrading to PHP 5.3 for the first time. I know.
| We've gone ahead set the default timezone that will be used by the PHP
| date and date-time functions. This prevents some potentially
| frustrating errors for novice developers.
|
*/
date_default_timezone_set(Helper::pick($config['_timezone'], @date_default_timezone_get(), "UTC"));
/*
|--------------------------------------------------------------------------
| Start the Engine