From e91625300fc842fd60d43b816cc1e438e2b2fd2c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 31 Aug 2012 20:18:23 +0000 Subject: [PATCH] Added data/basic add functionality --- app/classes/controller.php | 21 ++ app/config/config.php | 10 + app/config/routes.php | 23 +- app/modules/meta/controllers/category.php | 5 +- app/modules/meta/controllers/data.php | 66 ++++++ app/modules/meta/controllers/section.php | 48 ++-- app/modules/meta/controllers/welcome.php | 14 +- app/modules/meta/models/model.php | 263 +++++++++++++++------ app/modules/meta/models/user_model.php | 28 ++- app/modules/meta/views/category_detail.php | 41 +++- app/modules/meta/views/edit_form.php | 19 ++ app/modules/meta/views/genre_detail.php | 22 +- app/modules/meta/views/genres.php | 18 +- app/modules/meta/views/outline.php | 78 +++--- app/modules/meta/views/section_detail.php | 47 +++- app/modules/setup/controllers/setup.php | 33 +++ app/views/header.php | 2 +- assets/config/config.php | 2 +- assets/config/js_groups.php | 11 +- assets/css/theme.css | 74 ++++++ assets/js.php | 14 +- assets/js/cache/js | 17 ++ assets/js/kis-lite-dom-min.js | 17 ++ assets/js/meta.js | 21 +- sys/core/Page.php | 2 +- sys/db | 2 +- sys/libraries/Session.php | 7 +- 27 files changed, 693 insertions(+), 212 deletions(-) create mode 100644 app/modules/meta/controllers/data.php create mode 100644 app/modules/meta/views/edit_form.php create mode 100644 app/modules/setup/controllers/setup.php create mode 100644 assets/js/cache/js create mode 100755 assets/js/kis-lite-dom-min.js diff --git a/app/classes/controller.php b/app/classes/controller.php index 3de2d2f..6972490 100644 --- a/app/classes/controller.php +++ b/app/classes/controller.php @@ -30,14 +30,35 @@ abstract class Controller extends \miniMVC\Controller { parent::__construct(); $this->load_model('meta\model'); $this->load_model('meta\user_model'); + + $this->session =& \miniMVC\Session::get_instance(); + + // Check if user is logged in + $this->check_login_status(); + $this->page->build_header(); } + /** + * Require user login for access + */ + private function check_login_status() + { + if ( ! isset($this->session->uid)) + { + // Redirect to login + } + + return; + + } + /** * Destruct controller and build page footer */ public function __destruct() { + $this->page->set_foot_js_group('js'); $this->page->build_footer(); } diff --git a/app/config/config.php b/app/config/config.php index fc291f4..425346a 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -134,4 +134,14 @@ define('DEFAULT_JS_GROUP', "js"); */ define('SHOW_DEBUG_BACKTRACE', TRUE); +/* +|-------------------------------------------------------------------------- +| Gzip compress +|-------------------------------------------------------------------------- +| +| Whether or not use gzip compression on page output +| +*/ +define('GZ_COMPRESS', FALSE); + // End of config.php \ No newline at end of file diff --git a/app/config/routes.php b/app/config/routes.php index 3c052e5..1f6bdd8 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -31,17 +31,18 @@ return array( // Default Paths - 'default_controller' => 'welcome', - 'default_module' => 'meta', - 'genre' => 'meta/genre/index', - 'genre/add' => 'meta/genre/add', - 'category' => 'meta/category/index', - 'category/add' => 'meta/category/add', - 'category/detail' => 'meta/category/detail', - 'section' => 'meta/section/index', - 'section/add' => 'meta/section/add', - 'section/detail' => 'meta/section/detail', - '404_route' => '', + 'default_controller' => 'welcome', + 'default_module' => 'meta', + 'genre' => 'meta/genre/index', + 'genre/add' => 'meta/genre/add', + 'category' => 'meta/category/index', + 'category/add' => 'meta/category/add', + 'category/detail' => 'meta/category/detail', + 'section' => 'meta/section/index', + 'section/add' => 'meta/section/add', + 'data/add' => 'meta/data/add', + 'data/update' => 'meta/data/update', + '404_route' => '', ); // End of routes.php \ No newline at end of file diff --git a/app/modules/meta/controllers/category.php b/app/modules/meta/controllers/category.php index 92ef9a2..76df7d5 100644 --- a/app/modules/meta/controllers/category.php +++ b/app/modules/meta/controllers/category.php @@ -58,7 +58,7 @@ class category extends meta\controller { } // Render the basic page - $this->detail(-1); + $this->detail($this->model->get_last_id('category')); } /** @@ -78,7 +78,8 @@ class category extends meta\controller { $data = array( 'category' => $this->model->get_category_by_id($id), - 'sections' => $this->model->get_sections($id), + 'sections' => $this->model->get_category_outline_data($id), + 'genre' => $this->model->get_genre_by_category($id), 'category_id' => $id ); diff --git a/app/modules/meta/controllers/data.php b/app/modules/meta/controllers/data.php new file mode 100644 index 0000000..b27c98b --- /dev/null +++ b/app/modules/meta/controllers/data.php @@ -0,0 +1,66 @@ +model->get_data($section_id); + + + $keys = filter_var_array($_POST['name'], FILTER_SANITIZE_STRING); + $vals = filter_var_array($_POST['val'], FILTER_SANITIZE_STRING); + + //echo miniMVC\to_string($_POST); + + $data = array_combine($keys, $vals); + + $res = /*(empty($old_data)) + ?*/ $this->model->add_data($section_id, $data); + //: FALSE; + + ($res) + ? $this->page->set_message('success', 'Added data') + : $this->page->set_message('error', 'Data already exists'); + + } +} + +// End of data.php \ No newline at end of file diff --git a/app/modules/meta/controllers/section.php b/app/modules/meta/controllers/section.php index e2a1daf..f711ac9 100644 --- a/app/modules/meta/controllers/section.php +++ b/app/modules/meta/controllers/section.php @@ -31,9 +31,26 @@ class section extends meta\controller { /** * Default controller method */ - public function index() + public function index($id=0) { - $this->detail(); + if ($id === 0) + { + $id = (int) miniMVC\get_last_segment(); + } + + if ($id === 0) + { + miniMVC\show_404(); + } + + $data = array( + 'section' => $this->model->get_section_by_id($id), + 'sdata' => $this->model->get_data($id), + 'p' => $this->model->get_path_by_section($id), + 'section_id' => $id + ); + + $this->load_view('section_detail', $data); } /** @@ -58,33 +75,8 @@ class section extends meta\controller { } // Render the basic page - $this->detail(-1); + $this->index($this->model->get_last_id('section')); } - - /** - * Returns the sections / editing options for a category - */ - public function detail($id = 0) - { - if ($id === 0) - { - $id = (int) miniMVC\get_last_segment(); - } - - if ($id === 0) - { - miniMVC\show_404(); - } - - $data = array( - 'section' => $this->model->get_section_by_id($id), - 'data' => $this->model->get_data($id), - 'section_id' => $id - ); - - $this->load_view('section_detail', $data); - } - } // End of section.php \ No newline at end of file diff --git a/app/modules/meta/controllers/welcome.php b/app/modules/meta/controllers/welcome.php index 07f0460..6370827 100644 --- a/app/modules/meta/controllers/welcome.php +++ b/app/modules/meta/controllers/welcome.php @@ -54,9 +54,19 @@ class welcome extends \meta\controller { { $this->page->render('login'); } - + // -------------------------------------------------------------------------- - + + /** + * Logout + */ + public function logout() + { + + } + + // -------------------------------------------------------------------------- + /** * Display an outline of the data for a table of contents */ diff --git a/app/modules/meta/models/model.php b/app/modules/meta/models/model.php index 16ac208..d21303f 100644 --- a/app/modules/meta/models/model.php +++ b/app/modules/meta/models/model.php @@ -47,6 +47,8 @@ class model extends \miniMVC\Model { $this->db =& \miniMVC\db::get_instance(); } + // -------------------------------------------------------------------------- + // ! Data Manipulation // -------------------------------------------------------------------------- /** @@ -104,7 +106,7 @@ class model extends \miniMVC\Model { // for databases that do not support // grabbing result counts (SQLite / Firebird) $array = $query->fetchAll(); - if (count($array) === 0) + if (count($array)< 1) { $this->db->set('genre', $genre) ->insert('genre'); @@ -118,21 +120,6 @@ class model extends \miniMVC\Model { // -------------------------------------------------------------------------- - /** - * Rename a genre - * - * @param int - * @param string - */ - public function update_genre($genre_id, $genre) - { - $this->db->set('genre', $genre) - ->where('id', $genre_id) - ->update('genre'); - } - - // -------------------------------------------------------------------------- - /** * Add category to genre * @@ -146,13 +133,14 @@ class model extends \miniMVC\Model { $query = $this->db->from('category') ->where('genre_id', $genre_id) ->where('category', $cat) + ->limit(1) ->get(); // Fetch the data as a workaround // for databases that do not support // grabbing result counts (SQLite / Firebird) $array = $query->fetchAll(); - if (count($array) === 0) + if (count($array)< 1) { $this->db->set('category', $cat) ->set('genre_id', $genre_id) @@ -166,21 +154,6 @@ class model extends \miniMVC\Model { // -------------------------------------------------------------------------- - /** - * Rename a category - * - * @param int - * @param string - */ - public function update_category($cat_id, $category) - { - $this->db->set('category', $category) - ->where('id', (int) $cat_id) - ->update('category'); - } - - // -------------------------------------------------------------------------- - /** * Add a section to a category * @@ -189,24 +162,27 @@ class model extends \miniMVC\Model { */ public function add_section($section, $category_id) { - $this->db->set('section', $section) - ->set('category_id', (int) $category_id) - ->insert('section'); - } + // Check if the section exists + $q = $this->db->from('section') + ->where('category_id', $category_id) + ->where('section', $section) + ->limit(1) + ->get(); - // -------------------------------------------------------------------------- + // Fetch the data as a workaround + // for databases that do not support + // grabbing result counts (SQLite / Firebird) + $array = $q->fetchAll(); + if (count($array) < 1) + { + $this->db->set('section', $section) + ->set('category_id', (int) $category_id) + ->insert('section'); - /** - * Rename a section - * - * @param int - * @param string - */ - public function update_section($section_id, $section) - { - $this->db->set('section', $section) - ->where('id', (int) $section_id) - ->update('section'); + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------------- @@ -219,13 +195,40 @@ class model extends \miniMVC\Model { */ public function add_data($section_id, $data) { - // Convert the data to json for storage - $data_str = json_encode($data); + foreach($data as $key => $val) + { + // See if the data exists + $q = $this->db->from('data') + ->where('section_id', $section_id) + ->where('key', $key) + ->get(); - // Save the data - $this->db->set('data', $data_str) - ->set('section_id', (int) $section_id) - ->insert('data'); + if ($this->db->num_rows() > 0) return FALSE; + + // Save the data + $this->db->set('key', $key) + ->set('value', $val) + ->set('section_id', (int) $section_id) + ->insert('data'); + } + + return TRUE; + } + + // -------------------------------------------------------------------------- + + /** + * Rename a genre/category/section + * + * @param string + * @param int + * @param string + */ + public function update($type, $id, $name) + { + $this->db->set($type, $name) + ->where('id', (int) $id) + ->update('genre'); } // -------------------------------------------------------------------------- @@ -248,6 +251,49 @@ class model extends \miniMVC\Model { } + // -------------------------------------------------------------------------- + // ! Data Retrieval + // -------------------------------------------------------------------------- + + /** + * Get the id of the last item of the type + * + * @param string $type + * @return int + */ + public function get_last_id($type) + { + $query = $this->db->select('id') + ->from($type) + ->order_by('id', 'DESC') + ->limit(1) + ->get(); + + $r = $query->fetch(\PDO::FETCH_ASSOC); + + return $r['id']; + } + + // -------------------------------------------------------------------------- + + /** + * Get breadcrumb data for section + * + * @param section_id + * @return array + */ + public function get_path_by_section($section_id) + { + $query = $this->db->select('genre, genre_id, category, category_id') + ->from('section s') + ->join('category c', 'c.id=s.category_id') + ->join('genre g', 'g.id=c.genre_id') + ->where('s.id', $section_id) + ->get(); + + return $query->fetch(\PDO::FETCH_ASSOC); + } + // -------------------------------------------------------------------------- /** @@ -313,6 +359,27 @@ class model extends \miniMVC\Model { // -------------------------------------------------------------------------- + /** + * Get the genre name by category id + * + * @param int + * @return array + */ + public function get_genre_by_category($cat_id) + { + $query = $this->db->select('g.id, genre') + ->from('genre g') + ->join('category c', 'c.genre_id=g.id', 'inner') + ->where('c.id', (int)$cat_id) + ->get(); + + $row = $query->fetch(\PDO::FETCH_ASSOC); + + return $row; + } + + // -------------------------------------------------------------------------- + /** * Gets the name of the section from its id * @@ -393,21 +460,71 @@ class model extends \miniMVC\Model { { $data = array(); - $query = $this->db->select('id, data') + $query = $this->db->select('id, key, value') ->from('data') ->where('section_id', (int) $section_id) ->get(); while($row = $query->fetch(\PDO::FETCH_ASSOC)) { - $data[$row['id']] = json_decode($row['data'], TRUE); + $data[$row['id']] = array($row['key'] => str_replace("\n", "
", $row['value'])); } return $data; } - + // -------------------------------------------------------------------------- - + + /** + * Get sections and data for a general data outline + * + * @param int $category_id + * @return array + */ + public function get_category_outline_data($category_id) + { + // Get the sections + $s_query = $this->db->from('section') + ->where('category_id', (int) $category_id) + ->get(); + + $sections = array(); + + while($row = $s_query->fetch(\PDO::FETCH_ASSOC)) + { + $sections[$row['id']] = $row['section']; + } + + // Get the data for the sections + $d_array = array(); + + if ( ! empty($sections)) + { + $d_query = $this->db->from('data') + ->where_in('section_id', array_keys($sections)) + ->get(); + + while($row = $d_query->fetch(\PDO::FETCH_ASSOC)) + { + $d_array[$row['section_id']][$row['key']] = str_replace("\n", "
", $row['value']); + } + } + + // Reorganize the data + $data = array(); + + foreach($sections as $section_id => $section) + { + $data[$section_id] = (isset($d_array[$section_id])) + ? array($section, $d_array[$section_id]) + : $section; + } + + return $data; + } + + // -------------------------------------------------------------------------- + /** * Get data for a full outline * @@ -418,53 +535,53 @@ class model extends \miniMVC\Model { // Get the genres $g_query = $this->db->from('genre') ->get(); - + $genres = array(); - + while ($row = $g_query->fetch(\PDO::FETCH_ASSOC)) { $genres[$row['id']] = $row['genre']; } - + // Get the categories $c_query = $this->db->from('category') ->get(); - + $categories = array(); - + while($row = $c_query->fetch(\PDO::FETCH_ASSOC)) { $categories[$row['genre_id']][$row['id']] = $row['category']; } - + // Get the sections $s_query = $this->db->from('section') ->get(); - + $sections = array(); - + while($row = $s_query->fetch(\PDO::FETCH_ASSOC)) { $sections[$row['category_id']][$row['id']] = $row['section']; } - - - // Organize into a nested array + + + // Organize into a nested array foreach($genres as $genre_id => $genre) { $return[$genre_id][$genre] = array(); $g =& $return[$genre_id][$genre]; - + // Categories for this genre if (isset($categories[$genre_id])) { $g = $categories[$genre_id]; - + foreach($categories[$genre_id] as $category_id => $category) { $g[$category_id] = array($category => array()); $c =& $g[$category_id][$category]; - + // Sections for this category if (isset($sections[$category_id])) { @@ -473,7 +590,7 @@ class model extends \miniMVC\Model { } } } - + return $return; } diff --git a/app/modules/meta/models/user_model.php b/app/modules/meta/models/user_model.php index b24c71f..883b40d 100644 --- a/app/modules/meta/models/user_model.php +++ b/app/modules/meta/models/user_model.php @@ -35,7 +35,7 @@ class user_model extends \miniMVC\Model { * @var Bcrypt */ protected $bcrypt; - + /** * Reference to session * @@ -56,7 +56,7 @@ class user_model extends \miniMVC\Model { } // -------------------------------------------------------------------------- - + /** * Add a user for access * @@ -66,9 +66,29 @@ class user_model extends \miniMVC\Model { */ public function add_user($username, $pass1, $pass2) { - + // Check for the existing username + $query = $this->db->select('username') + ->from('user') + ->where('username', $username) + ->get(); + + $res = $query->fetch(\PDO::FETCH_ASSOC); + + if (empty($res)) return FALSE; + + // Verify that passwords match + if ($pass1 !== $pass2) return FALSE; + + // Add user + $hashed = $this->bcrypt->hash($pass1); + + $this->db->set('username', $username) + ->set('hash', $hashed) + ->insert('user'); + + return TRUE; } - + // -------------------------------------------------------------------------- /** diff --git a/app/modules/meta/views/category_detail.php b/app/modules/meta/views/category_detail.php index 0ecdb9a..5ca2608 100644 --- a/app/modules/meta/views/category_detail.php +++ b/app/modules/meta/views/category_detail.php @@ -1,15 +1,12 @@ -

+

-

Category Sections

- +
" method="post">
- Add Section + Add Section
@@ -19,4 +16,30 @@
-
\ No newline at end of file + + + \ No newline at end of file diff --git a/app/modules/meta/views/edit_form.php b/app/modules/meta/views/edit_form.php new file mode 100644 index 0000000..827117e --- /dev/null +++ b/app/modules/meta/views/edit_form.php @@ -0,0 +1,19 @@ +
+
+ Edit +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/app/modules/meta/views/genre_detail.php b/app/modules/meta/views/genre_detail.php index f3a261d..1077671 100644 --- a/app/modules/meta/views/genre_detail.php +++ b/app/modules/meta/views/genre_detail.php @@ -1,15 +1,12 @@ -

+

-

Genre Categories

- +
" method="post">
- Add Category + Add Category
@@ -19,4 +16,11 @@
-
\ No newline at end of file + + + + diff --git a/app/modules/meta/views/genres.php b/app/modules/meta/views/genres.php index 0f59f9e..85cce01 100644 --- a/app/modules/meta/views/genres.php +++ b/app/modules/meta/views/genres.php @@ -1,14 +1,8 @@ -

Genres

- - +

Genres

" method="post">
- Add Genre + Add Genre
@@ -18,4 +12,10 @@
-
\ No newline at end of file + + + \ No newline at end of file diff --git a/app/modules/meta/views/outline.php b/app/modules/meta/views/outline.php index 2919874..432da7b 100644 --- a/app/modules/meta/views/outline.php +++ b/app/modules/meta/views/outline.php @@ -1,39 +1,47 @@ -

Data Outline

+

Outline

- \ No newline at end of file + \ No newline at end of file diff --git a/app/modules/meta/views/section_detail.php b/app/modules/meta/views/section_detail.php index 7afbb32..d7206b1 100644 --- a/app/modules/meta/views/section_detail.php +++ b/app/modules/meta/views/section_detail.php @@ -1,8 +1,41 @@ -

+

-

Section Data

- - $d): ?> -
  • ">
  • - - */ ?> + + +
    " method="post"> +
    + Add Data +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + + + + + $v): ?> + ") !== FALSE) ? 'multiline' : 'pair' ?> +
    + +
    +
    + +
    + + + + \ No newline at end of file diff --git a/app/modules/setup/controllers/setup.php b/app/modules/setup/controllers/setup.php new file mode 100644 index 0000000..7c26231 --- /dev/null +++ b/app/modules/setup/controllers/setup.php @@ -0,0 +1,33 @@ + > -

    Meta

    \ No newline at end of file +

    Meta

    \ No newline at end of file diff --git a/assets/config/config.php b/assets/config/config.php index 235397d..2f44507 100755 --- a/assets/config/config.php +++ b/assets/config/config.php @@ -73,4 +73,4 @@ $path_to = ''; | The folder where javascript files exist, in relation to the document root | */ -$js_root = $document_root. '/js/'; \ No newline at end of file +$js_root = $document_root. 'js/'; \ No newline at end of file diff --git a/assets/config/js_groups.php b/assets/config/js_groups.php index 7836649..811ef79 100755 --- a/assets/config/js_groups.php +++ b/assets/config/js_groups.php @@ -16,8 +16,8 @@ /** * This is the config array for javascript files to concatenate and minify */ -return [ - /* +return array( + /*= For each group create an array like so 'my_group' => array( @@ -25,4 +25,9 @@ return [ 'path/to/css/file2.css' ), */ -]; \ No newline at end of file + + 'js' => array( + 'kis-lite-dom-min.js', + 'meta.js' + ), +); \ No newline at end of file diff --git a/assets/css/theme.css b/assets/css/theme.css index a836496..d939611 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -6,6 +6,11 @@ html, body { font-weight:200; max-width:800px; margin: 0 auto; + color:#312; +} + +button { + color:#312; } a { @@ -16,6 +21,26 @@ a:hover { text-decoration:underline; } +legend { + display:block; +} + +legend:hover { + cursor:pointer; +} + +h1,h2 { + display:-moz-inline-box; + display:inline-block; + vertical-align:middle; + width:25%; +} + +/* Hide forms by default */ +fieldset dl { + display:none; +} + /* form styles */ form dt, form dd { display:-moz-inline-box; /* For older versions of Mozilla/Firefox */ @@ -35,3 +60,52 @@ form dd { padding-left:.25em; } +/* Outline styles */ +.list { + padding:0; + margin:0; +} + +.list dl { + margin-left:0.5em; +} + +.list li { + list-style:none; +} + +/* Data listing styles */ +dl.multiline, dl.pair { + border-bottom:1px dotted #312; +} + +dl.multiline dt { + font-weight:bold; + line-height:1.5; + font-size:1em; + margin:0; +} + +dl.multiline dd { + margin:1em; + margin-right:0; +} + +dl.pair dt, dl.pair dd { + display:-moz-inline-block; + display:inline-block; + padding:0.25em 0; +} + +dl.pair dt { + width:35%; +} + +dl.pair dd { + width:64%; + margin-left:0; + padding-left:0; +} + + + diff --git a/assets/js.php b/assets/js.php index b26e04b..5bda3bd 100755 --- a/assets/js.php +++ b/assets/js.php @@ -12,6 +12,7 @@ */ // -------------------------------------------------------------------------- +error_reporting(-1); /** * JS Minifier and Cacher @@ -45,7 +46,7 @@ function get_files() $js = ''; - foreach ($groups[$_GET['g']] as &$file) + foreach ($groups[$_GET['g']] as $file) { $new_file = realpath($js_root.$file); $js .= file_get_contents($new_file); @@ -69,9 +70,13 @@ function google_min($new_file) $ch = curl_init('http://closure-compiler.appspot.com/compile'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); + //curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($new_file)); $output = curl_exec($ch); + + //die(curl_getinfo($ch, CURLINFO_HTTP_CODE)); curl_close($ch); + return $output; } @@ -150,7 +155,8 @@ if ($last_modified === $requested_time) //Determine what to do: rebuild cache, send files as is, or send cache. if ($cache_modified < $last_modified) { - $js = google_min(get_files()); + $js = get_files(); + $js = google_min($js); $cs = file_put_contents($cache_file, $js); //Make sure cache file gets created/updated @@ -174,7 +180,7 @@ else //This GZIPs the js for transmission to the user //making file size smaller and transfer rate quicker -ob_start("ob_gzhandler"); +//ob_start("ob_gzhandler"); header("Content-Type: text/javascript; charset=utf8"); header("Cache-control: public, max-age=691200, must-revalidate"); @@ -183,6 +189,6 @@ header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime($this_file) + 691200))." echo $js; -ob_end_flush(); +//ob_end_flush(); //end of js.php \ No newline at end of file diff --git a/assets/js/cache/js b/assets/js/cache/js new file mode 100644 index 0000000..215d404 --- /dev/null +++ b/assets/js/cache/js @@ -0,0 +1,17 @@ +(function(){if("undefined"!==typeof document.querySelector){var d,e,b,c;d=function(a){c="undefined"===typeof a?"undefined"!==typeof d.el?d.el:document.documentElement:"object"!==typeof a?e(a):a;d.prototype.el=c;var a=b(d),f;for(f in a)"object"===typeof a[f]&&(a[f].el=c);a.el=c;return a};e=function(a,f){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=f&&1===f.nodeType?f:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a); +return 1===b.length?b[0]:b};b=function(a){var f;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);f=typeof a;if(!("object"!==f&&"function"!==f))return f=function(){},f.prototype=a,new f}};d.ext=function(a,f){f.el=c;d[a]=f};d.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(c,a);else{var f=c.length;if(0!==f)for(var b,d=0;d1&&typeof c==="undefined")return null;if(a.length>1&&typeof c!=="undefined")$_.each(function(a){return d(a,b,c)});else return d(a,b,c)},text:function(b){var c,a,d;d=this.el;a=typeof d.textContent!=="undefined"?"textContent":typeof d.innerText!=="undefined"?"innerText": +"innerHTML";c=d[a];if(typeof b!=="undefined")return d[a]=b;return c},css:function(b,c){if(typeof c==="undefined")return e(this.el,b);$_.each(function(a){e(a,b,c)})},append:function(b){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("beforeend",b):this.el.innerHTML=this.el.innerHTML+b},prepend:function(b){typeof document.insertAdjacentHTML!=="undefined"?this.el.insertAdjacentHTML("afterbegin",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){if(typeof b!=="undefined")this.el.innerHTML= +b;return this.el.innerHTML}})})(); diff --git a/assets/js/meta.js b/assets/js/meta.js index aa146af..f52e52a 100644 --- a/assets/js/meta.js +++ b/assets/js/meta.js @@ -1,14 +1,15 @@ -var meta = (function (){ - "use strict"; +(function() { - var meta = window.meta || {}; + "use strict"; - meta.addItem = function() { + // Show/hide forms based on use + $_("fieldset dl").dom.hide(); + $_("fieldset legend").event.add('click', function(e){ + var form = $_("fieldset dl").dom; - }; + (form.css('display').trim() == 'none') + ? form.show() + : form.hide(); + }); - - // Return the object to the global scope - return meta; - -)()); \ No newline at end of file +}()); \ No newline at end of file diff --git a/sys/core/Page.php b/sys/core/Page.php index 55eb562..bc1c287 100644 --- a/sys/core/Page.php +++ b/sys/core/Page.php @@ -156,7 +156,7 @@ class Page { if ( ! empty($this->buffer)) { - //ob_start('ob_gzhandler'); + (GZ_COMPRESS) ? ob_start('ob_gzhandler') : ob_start(); echo $this->buffer; diff --git a/sys/db b/sys/db index 90c6760..4c546ed 160000 --- a/sys/db +++ b/sys/db @@ -1 +1 @@ -Subproject commit 90c676019652341836edd7bf71dfc70979341810 +Subproject commit 4c546ed3e90aa371053290ed4842fd9cad7f175c diff --git a/sys/libraries/Session.php b/sys/libraries/Session.php index 8903c3d..8210e5a 100644 --- a/sys/libraries/Session.php +++ b/sys/libraries/Session.php @@ -44,9 +44,12 @@ class Session { { session_start(); + // Create a re-generatable id using a hash of the user's ip address and user agent + $session_id = sha1($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); + // Save a reference to the session for later access - $_SESSION['MM_SESSION'] = (isset($_SESSION['MM_SESSION'])) ?: array(); - $this->sess =& $_SESSION['MM_SESSION']; + $_SESSION[$session_id] = (isset($_SESSION[$session_id])) ?: array(); + $this->sess =& $_SESSION[$session_id]; } // --------------------------------------------------------------------------