Permalink
Browse files

Added initial application structure

  • Loading branch information...
1 parent c31591b commit d859b2d6d591985c6b9894e0919b491b266f9a8a @zachariahtimothy committed Aug 10, 2012
Showing with 7,024 additions and 1,104 deletions.
  1. 0 application/config/{config.orig.php → config.orig}
  2. +3 −3 application/config/config.php
  3. +4 −3 application/config/database.php
  4. +8 −3 application/config/routes.php
  5. +20 −33 application/controllers/{ → api}/stash.php
  6. +59 −0 application/controllers/api/user.php
  7. +1 −0 application/controllers/index.php
  8. +32 −0 application/controllers/test.php
  9. +0 −54 application/controllers/user.php
  10. +0 −806 application/helpers/JSON.php
  11. +0 −73 application/helpers/json_helper.php
  12. +1,700 −0 application/logs/log-2012-08-05.php
  13. +4,374 −0 application/logs/log-2012-08-08.php
  14. +0 −27 application/views/a0-current-month.php
  15. +32 −4 application/views/default.php
  16. +12 −1 application/views/json_view.php
  17. +0 −24 application/views/s0-setup.php
  18. +3 −3 css/jquery.fancybox.css
  19. +4 −0 css/modules/aboutus.css
  20. +3 −0 css/modules/account.css
  21. 0 js/modules/home.html → css/modules/contactus.css
  22. 0 css/modules/error.css
  23. +8 −1 css/modules/footer.css
  24. +12 −0 css/modules/getstarted.css
  25. +6 −1 css/modules/header.css
  26. +7 −8 css/modules/home.css
  27. +9 −0 css/modules/login.css
  28. +4 −0 css/modules/privacypolicy.css
  29. 0 css/modules/stash.css
  30. +4 −0 css/modules/termsofuse.css
  31. +151 −13 css/site.css
  32. BIN images/100percent-secure.jpg
  33. BIN images/debt-free.jpg
  34. BIN images/financial-freedom.jpg
  35. BIN images/temp_current_stash.png
  36. +8 −0 js/helpers.js
  37. +54 −2 js/identity.js
  38. +5 −2 js/models.js
  39. +11 −0 js/modules/aboutus.js
  40. +23 −0 js/modules/account.js
  41. +11 −0 js/modules/contactus.js
  42. +14 −0 js/modules/error.js
  43. +6 −1 js/modules/footer.js
  44. +8 −0 js/modules/getstarted.js
  45. +26 −5 js/modules/header.js
  46. +35 −0 js/modules/login.js
  47. +11 −0 js/modules/privacypolicy.js
  48. +22 −0 js/modules/stash.html
  49. +13 −0 js/modules/stash.js
  50. +11 −0 js/modules/termsofuse.js
  51. +69 −1 js/router.js
  52. +1 −1 js/setup.js
  53. +8 −0 templates/modules/aboutus.html
  54. +52 −0 templates/modules/account.html
  55. +23 −0 templates/modules/contactus.html
  56. +12 −0 templates/modules/error.html
  57. +3 −2 templates/modules/footer.html
  58. +51 −14 templates/modules/getstarted.html
  59. +12 −10 templates/modules/header.html
  60. +14 −9 templates/modules/home.html
  61. +22 −0 templates/modules/login.html
  62. +8 −0 templates/modules/privacypolicy.html
  63. +27 −0 templates/modules/stash.html
  64. +8 −0 templates/modules/termsofuse.html
File renamed without changes.
@@ -14,7 +14,7 @@
| path to your installation.
|
*/
-$config['base_url'] = '';
+$config['base_url'] = 'http://localhost:8888/TheStash/';
/*
|--------------------------------------------------------------------------
@@ -180,7 +180,7 @@
| your log files will fill up very fast.
|
*/
-$config['log_threshold'] = 0;
+$config['log_threshold'] = 2;
/*
|--------------------------------------------------------------------------
@@ -265,7 +265,7 @@
| 'cookie_secure' = Cookies will only be set if a secure HTTPS connection exists.
|
*/
-$config['cookie_prefix'] = "stash";
+$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;
@@ -49,10 +49,11 @@
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
-$db['default']['username'] = '';
-$db['default']['password'] = '';
-$db['default']['database'] = '';
+$db['default']['username'] = 'root';
+$db['default']['password'] = 'root';
+$db['default']['database'] = 'TheStash';
$db['default']['dbdriver'] = 'mysql';
+$db['default']['port'] = 8889;
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
@@ -39,10 +39,15 @@
*/
$route['default_controller'] = "index";
-$route['404_override'] = '';
-// Catchall route accept for static resources
-$route['(^[^\.]*$)'] = "index";
+$route['404_override'] = 'index';
+// $route['api/user/(:any)'] = "user/$1";
+// $route['api/user/:any'] = "user";
+// $route['api/user/*'] = "user";
+// $route['/api/user/(:any)'] = "user";
+// Catchall route accept for static resources
+//$route['(^[^\.]*$)'] = "index";
+//$route['(:any)'] = "index";
/* End of file routes.php */
/* Location: ./application/config/routes.php */
@@ -10,49 +10,36 @@ public function __construct() {
}
public function index(){
-
+ $errors = array();
+ //Get
$query = $this->db->query('
- SELECT s.Id, s.Month, id.`Amount`, id.`Day`
- FROM Stashes s
- INNER JOIN Incomes i on s.`Id` = i.`StashId`
- LEFT OUTER JOIN IncomeDates id on i.`Id` = id.`IncomeId`
- WHERE s.`UserId` = ?
- AND s.`Month` = ?
- AND id.`Day` < ?
- ', array($this->_user['Id'], date('n'), date('j')));
+ SELECT i.`id`, i.`note`, i.`amount`
+ FROM Incomes i
+ WHERE i.`userId` = ?
+ ', array($this->_user['id'], date('n'), date('j')));
if ($query->num_rows() > 0)
{
$row = $query->row_array();
$data['stash'] = array(
- 'Id' => $row['Id'],
- 'Month' => $row['Month'],
- 'MonthName' => $this->monthName($row['Month'])
+ 'id' => $row['id'],
+ 'month' => $row['month'],
+ 'month_name' => $this->monthName($row['month'])
);
- $data['income'] = $row;
+ $data['json'] = array('income' => $row);
+ } else {
+ $errors[count($errors)] = array(
+ 'type' => 'incomeerror',
+ 'message' => 'Income not setup yet. Please visit your <a href="/account" title="Click to visit your account">account</a> to set it up.'
+ );
}
- $query = $this->db->query('
- SELECT s.Id, s.Month, e.`Amount`, e.`Day`
- FROM Stashes s
- INNER JOIN Expenses e on s.`Id` = e.`StashId`
- WHERE s.`UserId` = ?
- AND s.`Month` = ?
- AND e.`Day` < ?
- ', array($this->_user['Id'], date('n'), date('j')));
-
- if ($query->num_rows() > 0)
- {
- $rows = $query->result_array();
-
- $expense_amount = 0;
- foreach ($rows as $row) {
- $expense_amount = $expense_amount + $row['Amount'];
- }
-
- $data['expense'] = array('ExpensesLeft' => $expense_amount);
+ if ($errors){
+ $data['status'] = 404;
+ $data['json'] = $errors;
}
- $this->load->view('a0-current-month', $data);
+
+ $this->load->view('json_view', $data);
}
public function detail($stashId){
@@ -0,0 +1,59 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class User extends CI_Controller {
+ private $_user;
+
+ public function __construct() {
+ parent::__construct();
+ //setup user for use in class
+ $this->_user = $this->session->userdata('theStashUser');
+ }
+
+ public function login(){
+ if ($_SERVER['REQUEST_METHOD'] == "POST") {
+ $this->load->model('user');
+
+ $username = $this->input->post('email');
+ $userpass = $this->input->post('password');
+ //$username = 'zachariahtimothy@gmail.com';
+ //$userpass = 'dodgeramZZ';
+ $query = $this->db->query('
+ SELECT *
+ FROM Users
+ WHERE Email = ?
+ AND Password = MD5(?)
+ ', array($username, $userpass));
+
+ if ($query->num_rows() > 0)
+ {
+ $row = $query->row_array();
+ unset($row->Password); //Remove password from payload.
+ $data['json'] = json_encode(array(
+ 'user' => $row
+ ));
+
+ $this->session->set_userdata(array('theStashUser' => $row));
+ $this->_user = $row;
+ } else {
+ $message = "User ".$username." could not be found.";
+ $data['json'] = '{"status":"error: User '.$message.'"}';
+ }
+
+ $this->load->view('json_view', $data);
+ }
+ }
+
+
+ public function logout(){
+ $this->session->unset_userdata('theStashUser');
+ $this->_user = null;
+ $data['json'] = json_encode(array(
+ 'status' => 'success',
+ 'sesstion' => $this->session->userdata('theStashUser')
+ ));
+ $this->load->view('json_view', $data);
+ }
+
+}
+
+?>
@@ -28,6 +28,7 @@ public function index()
if ($this->_user){
$data['user'] = json_encode($this->_user);
} else {
+ //$data['user'] = '{"name" : "Zach Curtis", "id":"1", "type":"user"}';
$data['user'] = '{}';
}
$this->load->view('default', $data);
@@ -0,0 +1,32 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class Test extends CI_Controller {
+
+ public function __construct() {
+ parent::__construct();
+ //setup user for use in class
+ //$this->_user = $this->session->userdata('theStashUser');
+ }
+ /**
+ * Index Page for this controller.
+ *
+ * Maps to the following URL
+ * http://example.com/index.php/welcome
+ * - or -
+ * http://example.com/index.php/welcome/index
+ * - or -
+ * Since this controller is set as the default controller in
+ * config/routes.php, it's displayed at http://example.com/
+ *
+ * So any other public methods not prefixed with an underscore will
+ * map to /index.php/welcome/<method_name>
+ * @see http://codeigniter.com/user_guide/general/urls.html
+ */
+
+ public function zLogin(){
+ print_r($_POST);
+ }
+}
+
+/* End of file welcome.php */
+/* Location: ./application/controllers/welcome.php */
@@ -1,54 +0,0 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
-
-class User extends CI_Controller {
- private $_user;
-
- public function __construct() {
- parent::__construct();
- //setup user for use in class
- $this->_user = $this->session->userdata('theStashUser');
- }
-
- public function login(){
- $this->load->model('user');
-
- $username = $this->input->post('username');
- $userpass = $this->input->post('password');
-
- $query = $this->db->query('
- SELECT *
- FROM Users
- WHERE Username = ?
- AND Password = MD5(?)
- ', array($username, $userpass));
-
- if ($query->num_rows() > 0)
- {
- $row = $query->row_array();
- unset($row->Password); //Remove password from payload.
- $data['json'] = json_encode(array(
- 'user' => $row
- ));
-
- //echo 'user: '.$user;
- $this->session->set_userdata(array('theStashUser' => $row));
- //$this->_user = array('theStashUser' => $data);
- } else {
- $data['json'] = '{"status":"error"}';
- }
-
- $this->load->view('json_view', $data);
- }
-
-
- public function logout(){
- $this->session->unset_userdata('theStashUser');
- $data['json'] = json_encode(array(
- 'status' => 'success'
- ));
- $this->load->view('json_view', $data);
- }
-
-}
-
-?>
Oops, something went wrong.

0 comments on commit d859b2d

Please sign in to comment.