Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

misc

  • Loading branch information...
commit 0ab9ef37619f3490539f65a598c7c631f59e5223 1 parent 1fe5d6f
Jonathan Bradley authored July 25, 2012
1  .htaccess
... ...
@@ -1,5 +1,6 @@
1 1
 <IfModule mod_rewrite.c>
2 2
    RewriteEngine on
  3
+   RewriteBase  /
3 4
    RewriteRule    ^$ app/webroot/    [L]
4 5
    RewriteRule    (.*) app/webroot/$1 [L]
5 6
 </IfModule>
40  app/Controller/AppController.php
... ...
@@ -1,16 +1,30 @@
1 1
 <?php
2 2
 
3 3
 App::uses('Controller', 'Controller');
  4
+App::uses('Security', 'Utility');
4 5
 
5 6
 class AppController extends Controller {
6 7
   
7  
-  var $components = array('Auth', 'RequestHandler', 'Session', 'DebugKit.Toolbar');
8  
-  var $passed = null;
9  
-  var $replace = array(
  8
+  public $components = array(
  9
+    'Auth' => array(
  10
+      'loginAction' => array(
  11
+        'controller' => 'users',
  12
+        'action' => 'login',
  13
+      ),
  14
+    ),
  15
+    'Auth', 
  16
+    'RequestHandler', 
  17
+    'Session', 
  18
+  );
  19
+  public $passed = null;
  20
+  public $replace = array(
10 21
       'phone' => array('+', '-', '(', ')', ' ')
11 22
     );
12 23
 
13  
-   function beforeFilter() {  
  24
+  public function beforeFilter() {  
  25
+
  26
+    Security::setHash('sha256');
  27
+    
14 28
     // auth component stuff
15 29
     $this->Auth->loginRedirect    = array('controller' => 'leads', 'action' => 'index');
16 30
     $this->Auth->allowedActions   = array('*');
@@ -23,18 +37,15 @@ function beforeFilter() {
23 37
       }
24 38
       
25 39
       $this->passed = rtrim($this->passed, ",");
26  
-      $this->logAction();
27  
-      }
28  
-      else {
29  
-          if ($this->request->params['action'] != 'login') $this->redirect('/users/login');
30  
-      }
  40
+      // $this->logAction();
  41
+    }
31 42
     
32 43
     // set our default page title into our view based off the current controller name
33 44
     $this->pageTitle = Inflector::humanize($this->request->params['controller']) . ' : ' . Inflector::humanize($this->request->params['action']);
34 45
   }
35 46
   
36 47
   // this function tracks our user's actions
37  
-  function logAction () {
  48
+  public function logAction () {
38 49
     // prepare the data variable
39 50
     $this->request->data['ActionLog']['user_id']    = $this->Auth->user('id');
40 51
     $this->request->data['ActionLog']['controller'] = $this->request->params['controller'];
@@ -42,14 +53,14 @@ function logAction () {
42 53
     $this->request->data['ActionLog']['params']     = $this->passed;
43 54
     
44 55
     // insert new log
45  
-    $this->ActionLog = ClassRegistry::init('ActionLog');
  56
+    Controller::loadModel('ActionLog');
46 57
     $this->ActionLog->create();
47 58
     $this->ActionLog->save($this->request->data);
48 59
     
49 60
     unset($this->request->data['ActionLog']);
50 61
   }
51 62
 
52  
-  function beforeRender() {  
  63
+  public function beforeRender() {  
53 64
     if ($this->Auth->user()) {      
54 65
        $this->set('task', ClassRegistry::init('Note')->getTasks());
55 66
     }
@@ -58,12 +69,11 @@ function beforeRender() {
58 69
   /**
59 70
    * Phone Format Utility for 10 digit US Phone numbers
60 71
    */
61  
-  function phone($data = '') {
  72
+  public function phone($data = '') {
62 73
     $data = str_replace($this->replace['phone'], '', $data);
63 74
     $data = ereg_replace("[^0-9]",'',$data);
64 75
     if(strlen($data) == 10) $data = '('. substr($data,0,3) .') '. substr($data,3,3) .'-'. substr($data,6,4);
65 76
     else $data = '('. substr($data,1,3) .') '. substr($data,4,3) .'-'. substr($data,7,4);
66 77
     return($data);
67 78
   }
68  
-}
69  
-?>
  79
+}
66  app/Controller/UsersController.php
... ...
@@ -1,37 +1,47 @@
1 1
 <?php
  2
+
  3
+
  4
+App::uses('Sanitize', 'Utility');
2 5
 class UsersController extends AppController {
3 6
 
4 7
   var $name = 'Users';
5 8
   
6  
-  function beforeFilter() {
7  
-    $this->Auth->allow('add');
  9
+  public function beforeFilter() {
8 10
   }
9 11
   
10  
-  function login() {
  12
+  public function login() {
  13
+    if ($this->request->is('post')) {
  14
+      if ($this->Auth->login()) {
  15
+        return $this->redirect($this->Auth->redirect());
  16
+      } else {
  17
+        $this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
  18
+      }
  19
+    }
11 20
   }
12 21
     
13  
-    function logout() {
14  
-        $this->Session->setFlash('You have successfully logged out.');
15  
-        $this->redirect($this->Auth->logout());
16  
-    }
  22
+  public function logout() {
  23
+    $this->Session->setFlash('You have successfully logged out.');
  24
+    $this->redirect($this->Auth->logout());
  25
+  }
17 26
 
18  
-  function index() {
  27
+  public function index() {
19 28
     $this->User->recursive = 0;
20 29
     $this->set('data', $this->paginate());
21 30
   }
22 31
 
23  
-  function view($id = null) {
  32
+  public function view($id = null) {
24 33
     if (!$id) {
25 34
       $this->flash('invalid', 'index');
26 35
     }
27 36
     $this->set('user', $this->User->read(null, $id));
28 37
   }
29 38
 
30  
-  function add() {
  39
+  public function add() {
  40
+
31 41
     if (!empty($this->request->data)) {
32  
-      $this->User->create();
33  
-      $this->__convertPasswords();
34  
-      if ($this->User->save($this->request->data)) {
  42
+      $data = Sanitize::clean($this->request->data);
  43
+      $data['User']['password'] = self::__convertPasswords($data['User']['password'], null, true);
  44
+      if ($this->User->save($data)) {
35 45
         $this->Session->setFlash('User Saved');
36 46
         $this->redirect('index');
37 47
       } else {
@@ -42,7 +52,7 @@ function add() {
42 52
     $this->set(compact('groups'));
43 53
   }
44 54
 
45  
-  function edit($id = null) {
  55
+  public function edit($id = null) {
46 56
     if (!$id && empty($this->request->data)) {
47 57
       $this->flash('invalid', 'index');
48 58
     }
@@ -62,7 +72,7 @@ function edit($id = null) {
62 72
     $this->set(compact('groups'));
63 73
   }
64 74
 
65  
-  function delete($id = null) {
  75
+  public function delete($id = null) {
66 76
     if (!$id) {
67 77
       $this->Session->setFlash('User Invalid');
68 78
     }
@@ -72,7 +82,7 @@ function delete($id = null) {
72 82
     }
73 83
   }
74 84
   
75  
-  function xmlLogin() {
  85
+  public function xmlLogin() {
76 86
       // Verify request is from a webservice
77 87
       if ($this->Session->check('webserviceRequest')) {
78 88
           $this->Session->delete('webserviceRequest');
@@ -104,28 +114,10 @@ function xmlLogin() {
104 114
           $this->cakeError('serviceResponse', array('errorMessage' => $errorMessage, 'errorCode' => $errorCode));
105 115
       }
106 116
   }
107  
-
108  
-    
109  
-    /**
110  
-     * Hash submitted passwords according to the scheme used by the Auth component
111  
-   *
112  
-   * We need to keep a copy of the string submitted by the user, so we can
113  
-   * use built-in validation rules on it.  However, we also need to convert this value
114  
-   * to the hashed string that will be stored in the database.
115  
-   *
116  
-   * @access private
117  
-   * @return null
118  
-     *
119  
-     */
120  
-  function __convertPasswords()
  117
+  
  118
+  private function __convertPasswords($password)
121 119
   {
122  
-      if(!empty( $this->request->data['User']['new_password'] ) ){
123  
-            // we still want to validate the value entered in new_passwd
124  
-            // so we store the hashed value in a new data field which
125  
-            // we will later pass on to the passwd field in an 
126  
-            // afterSave() function 
127  
-        $this->request->data['User']['password'] = $this->Auth->password( $this->request->data['User']['new_password'] );
128  
-    }
  120
+     return Security::hash($password, null, true);
129 121
   }
130 122
 
131 123
 }
2  app/View/Layouts/default.ctp
@@ -92,7 +92,5 @@
92 92
   </div> <!-- /footer -->
93 93
 
94 94
 </div> <!-- /main -->
95  
-
96  
-  <?php echo $this->element('sql_dump'); ?>
97 95
 </body>
98 96
 </html>
4  app/config/bootstrap.php
@@ -7,10 +7,6 @@
7 7
   'CacheDispatcher'
8 8
 ));
9 9
 
10  
-CakePlugin::load('DebugKit');
11  
-
12  
-date_default_timezone_set('America/New_York');
13  
-
14 10
 App::uses('CakeLog', 'Log');
15 11
 CakeLog::config('debug', array(
16 12
   'engine' => 'FileLog',
2  app/config/core.php
@@ -173,7 +173,7 @@
173 173
  *
174 174
  */
175 175
   Configure::write('Session', array(
176  
-    'defaults' => 'php'
  176
+    'defaults' => 'cake'
177 177
   ));
178 178
 
179 179
 /**
BIN  app/tmp/cache/cake_toolbar_cache290cb16e901fb06c0331494e99d7209d
Binary file not shown
BIN  app/tmp/cache/cake_toolbar_cache6985cc0f76773ebd6fac4f63eaf07a06
Binary file not shown
9  app/webroot/.htaccess
... ...
@@ -1,6 +1,7 @@
1 1
 <IfModule mod_rewrite.c>
2  
-    RewriteEngine On
3  
-    RewriteCond %{REQUEST_FILENAME} !-d
4  
-    RewriteCond %{REQUEST_FILENAME} !-f
5  
-    RewriteRule ^(.*)$ index.php [QSA,L]
  2
+  RewriteEngine On
  3
+  RewriteBase  /
  4
+  RewriteCond %{REQUEST_FILENAME} !-d
  5
+  RewriteCond %{REQUEST_FILENAME} !-f
  6
+  RewriteRule ^(.*)$ index.php [QSA,L]
6 7
 </IfModule>
2  app/webroot/index.php
@@ -89,4 +89,4 @@
89 89
 App::uses('Dispatcher', 'Routing');
90 90
 
91 91
 $Dispatcher = new Dispatcher();
92  
-$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
  92
+$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
3  lib/Cake/Utility/Debugger.php
@@ -520,7 +520,6 @@ protected static function _export($var, $depth, $indent) {
520 520
  */
521 521
 	protected static function _array(array $var, $depth, $indent) {
522 522
 		$secrets = array(
523  
-			'password' => '*****',
524 523
 			'login'  => '*****',
525 524
 			'host' => '*****',
526 525
 			'database' => '*****',
@@ -720,7 +719,7 @@ public function outputError($data) {
720 719
 		$info = '';
721 720
 
722 721
 		foreach ((array)$data['context'] as $var => $value) {
723  
-			$context[] = "\${$var} = " . $this->exportVar($value, 1);
  722
+			$context[] = "\${$var} = " . $this->exportVar($value, 3);
724 723
 		}
725 724
 
726 725
 		switch ($this->_outputFormat) {
1  lib/Cake/Utility/Security.php
@@ -123,6 +123,7 @@ public static function hash($string, $type = null, $salt = false) {
123 123
  * @return void
124 124
  * @see Security::hash()
125 125
  */
  126
+
126 127
 	public static function setHash($hash) {
127 128
 		self::$hashType = $hash;
128 129
 	}

0 notes on commit 0ab9ef3

Please sign in to comment.
Something went wrong with that request. Please try again.