Пример #1
0
 /**
  * Tests that the base URL can be changed at runtime.
  *
  * @return void
  */
 public function testfullBaseURL()
 {
     Router::fullbaseUrl('http://example.com');
     $this->assertEquals('http://example.com/', Router::url('/', true));
     $this->assertEquals('http://example.com', Configure::read('App.fullBaseUrl'));
     Router::fullBaseUrl('https://example.com');
     $this->assertEquals('https://example.com/', Router::url('/', true));
     $this->assertEquals('https://example.com', Configure::read('App.fullBaseUrl'));
 }
Пример #2
0
 *
 */
Plugin::load('Migrations');
// Only try to load DebugKit in development mode
// Debug Kit should not be installed on a production system
if (Configure::read('debug')) {
    Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
 * Connect middleware/dispatcher filters.
 */
DispatcherFactory::add('Asset');
DispatcherFactory::add('Routing');
DispatcherFactory::add('ControllerFactory');
/**
* CUSTOM GLOBAL VARS GO BELOW
*
*/
Configure::write('TIMEZONE_OFFSET', '-4');
Configure::write('UPLOAD_ROOT', 'file_library');
// this is where all uploaded files will go
Configure::write('UPLOAD_TEMP_DIR', '_tmp');
// this will be created within each file directory per job
Configure::write('UPLOAD_VERSION_DIR', '_versions');
// this will be created within each file directory per job
Configure::write('UPLOAD_ROOT_OFFSET', '../');
// this is necessary for upload folders placed outside the app root
Configure::write('SITE_ROOT', Router::fullbaseUrl());
// this points to the root of the site, independent from the cake folder structure
// list of allowed upload formats
Configure::write('EXT_LIST', array('jpg', 'png', 'gif', 'swf', 'mp4', 'mov', 'pdf', 'zip'));
Пример #3
0
 public function forgot()
 {
     $message_sent = false;
     $msg = false;
     if ($this->request->is('post') && isset($this->request->data['email'])) {
         $Users = TableRegistry::get('Users');
         if ($user = $Users->find('all', ['conditions' => ['email' => $this->request->data['email']]])->first()) {
             $user = $user->toArray();
             // generate temp password and save to user
             $tmp_pw = substr(md5(uniqid(rand(), true)), 0, 8);
             $hashed = $this->create_hash($tmp_pw);
             if ($Users->save($Users->newEntity(['id' => $user['id'], 'salt' => $hashed['salt'], 'hash' => $hashed['hash'], 'require_pw_change' => 1]))) {
                 // send email
                 $message = file_get_contents(Router::fullbaseUrl() . DS . 'email/forgot.html');
                 $message = str_replace("%name%", $user['first_name'], $message);
                 $message = str_replace("%email%", $user['email'], $message);
                 $message = str_replace("%password%", $tmp_pw, $message);
                 //send the message, check for errors
                 if (AppController::sendEmail(array('to' => $user['email'], 'bcc' => '*****@*****.**', 'subject' => 'TDI Preview Password Reset', 'body' => $message))) {
                     $message_sent = true;
                 }
             }
         } else {
             $msg = 'Email address not on record';
         }
     }
     $this->set(compact('msg', 'message_sent'));
 }