--- /dev/null
+<?php
+/*
+ * Harvie's PHP HTTP-Auth script
+ * Copyright (C) 2oo7-2o11 Thomas Mudrunka
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+///SETTINGS//////////////////////////////////////////////////////////////////////////////////////////////////////
+//Login
+$require_login = false; //Require login? (if false, no login needed) - WARNING!!!
+$realm = 'music'; //This is used by browser to identify protected area and saving passwords (one_site+one_realm==one_user+one_password)
+$users = array( //You can specify multiple users in this array
+ 'music' => 'passw'
+);
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//MANUAL/////////////////////////////////////////////////////////////////////////////////////////////////////////
+/* HOWTO
+ * To each file, you want to lock add this line (at begin of first line - Header-safe):
+ * <?php require_once('http_auth.php'); ?> //Password Protection 8')
+ * Protected file have to be php script (if it's html, simply rename it to .php)
+ * Server needs to have PHP as module (not CGI).
+ * You need HTTP Basic auth enabled on server and php.
+ */
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////CODE/////////////////////////////////////////////////////////////////////////////////////////////////////////
+class HTTP_Auth {
+
+ function send_auth_headers($realm='') {
+ Header('WWW-Authenticate: Basic realm="'.$realm.'"');
+ Header('HTTP/1.0 401 Unauthorized');
+ }
+
+ static function check_auth_internal($user, $pass) { //Check if login is succesfull
+ //(U can modify this to use DB, or anything else)
+ return (isset($GLOBALS['users'][$user]) && ($GLOBALS['users'][$user] == $pass));
+ }
+
+ function check_auth($user, $pass) {
+ return call_user_func($this->auth_function, $user, $pass);
+ }
+
+ function unauthorized() { //Do this when login fails
+ //Show warning and die
+ die("$this->cbanner<title>401 - Forbidden</title>\n<h1>401 - Forbidden</h1>\n<a href=\"?\">Login...</a>\n$this->hbanner");
+ die(); //Don't forget!!!
+ }
+
+
+ function auth($realm) {
+ //Backward compatibility
+ if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_PW'] != '') $PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
+ if(isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_PW'] != '') $PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];
+
+ //Logout
+ if(isset($_GET['logout'])) { //script.php?logout
+ if(isset($PHP_AUTH_USER) || isset($PHP_AUTH_PW)) {
+ Header('WWW-Authenticate: Basic realm="'.$realm.'"');
+ Header('HTTP/1.0 401 Unauthorized');
+ } else {
+ $location=$this->location;
+ if($_GET['logout'] != '') $location = $_GET['logout'];
+ if(trim($location) != '401') Header('Location: '.$location);
+ die("$this->cbanner<title>401 - Log out successfull</title>\n<h1>401 - Log out successfull</h1>\n<a href=\"?\">Continue...</a>\n$this->hbanner");
+ }
+ }
+
+ if(!isset($PHP_AUTH_USER)) {
+ //Storno or first visit of page
+ $this->send_auth_headers($realm);
+ $this->unauthorized();
+ } else {
+ //Login sent
+ if($this->check_auth($PHP_AUTH_USER, $PHP_AUTH_PW)) {
+ //Login succesfull - probably do nothing here
+ } else {
+ //Bad login
+ $this->send_auth_headers($realm);
+ $this->unauthorized();
+ }
+ }
+ //Rest of file will be displayed only if login is correct
+ }
+
+ function __construct($realm='private', $require_login=true, $auth_function=false) {
+ //Misc
+ $this->location = '401'; //Location after logout - 401 = default logout page (can be overridden by ?logout=[LOCATION])
+ //CopyLeft
+ $ver = '2o1o-4.0';
+ $link = '<a href="https://blog.harvie.cz/">blog.harvie.cz</a>';
+ $banner = "Harvie's PHP HTTP-Auth script (v$ver)";
+ $this->hbanner = "<hr /><i>$banner\n-\n$link</i>\n";
+ $this->cbanner = "<!-- $banner -->\n";
+
+ $this->auth_function=array($this,'check_auth_internal');
+ if($auth_function) $this->auth_function=$auth_function;
+
+ if($require_login) {
+ $this->auth($realm);
+ }
+ }
+
+}
+
+if($require_login) new HTTP_Auth($realm);
--- /dev/null
+<?php
+/*
+ * SkladovySystem - Storage management system compatible with LMS
+ * Copyright (C) 2011 Thomas Mudrunka
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+require_once('sklad.conf.php');
+require_once('Sklad_LMS-fake.class.php');
+require_once('HTTP_Auth.class.php');
+
+class Sklad_HTML {
+ function header_print($title='') {
+ $home = URL_HOME;
+ $script = $_SERVER['SCRIPT_NAME'];
+ $search = @trim($_GET['q']);
+ echo <<<EOF
+<h1><a href="$script/">SystémSklad</a><small>$title</small></h1>
+<div>
+ <menu>
+ <li><a href="?logout">Logout</a></li>
+ <li><a href="$script/">Home</a></li>
+ </menu>
+ <form action="?" method="GET">
+ <input type="text" name="q" placeholder="regexp..." value="$search" />
+ <input type="submit" value="filter" />
+ </form>
+ <!-- form action="$script/" method="GET">
+ <input type="text" name="q" placeholder="regexp..." value="$search" />
+ <input type="submit" value="search items" />
+ </form -->
+</div>
+EOF;
+ }
+
+ function row_print($row) {
+ echo('<tr>');
+ foreach($row as $var) {
+ if(trim($var) == '') $var = ' ';
+ echo("<td>$var</td>");
+ }
+ echo('</tr>');
+ }
+
+ function table_print(&$table, $params='border=1') {
+ echo("<table $params>");
+ $header=true;
+ foreach($table as $row) {
+ if($header) {
+ $this->row_print(array_keys($row));
+ $header=false;
+ }
+ $this->row_print($row);
+ }
+ echo('</table>');
+ }
+
+ function link($title='n/a', $link='#void', $internal=true) {
+ if($internal) $link = $_SERVER['SCRIPT_NAME'].'/'.$link;
+ return "<a href='$link'>$title</a>";
+ }
+
+ function img($src='#void', $title='img') {
+ return "<img src='$src' alt='$title' title='$title' width=64 />";
+ }
+
+ function table_add_images(&$table) {
+ $image = array('model_id');
+ foreach($table as $id => $row) {
+ foreach($image as $column) if(isset($table[$id][$column])) {
+ $type = @array_shift(preg_split('/_/', $column));
+ $src=URL_IMAGES."/$type/".$table[$id][$column].'.jpg';
+ $table[$id][$type.'_image']=$this->img($src, $table[$id][$column]);
+ }
+ }
+ }
+
+ function table_collapse(&$table) {
+ $collapse = array(
+ 'item_id' => 'item_id',
+ 'model_id' => 'model_name',
+ 'category_id' => 'category_name',
+ 'producer_id' => 'producer_name',
+ 'vendor_id' => 'vendor_name',
+ 'room_id' => 'room_name',
+ 'status_id' => 'status_name',
+ );
+ foreach($table as $id => $row) {
+ foreach($collapse as $link => $title)
+ if(isset($table[$id][$link])) {
+ $type = @array_shift(preg_split('/_/', $link));
+ if($link != $title) unset($table[$id][$link]);
+ $table[$id][$title]=$this->link($row[$title], $type.'/'.$row[$link].'/');
+ }
+ }
+ }
+
+ function table_sort(&$table) {
+ $precedence = array('item_id', 'model_image', 'model_name','model_descript','category_name','status_name','room_name');
+ $table_sorted = array();
+ foreach($table as $id => $row) {
+ $table_sorted[$id] = array();
+ foreach($precedence as $column) if(isset($table[$id][$column])) {
+ $table_sorted[$id][$column]=$table[$id][$column];
+ unset($table[$id][$column]);
+ }
+ $table_sorted[$id]=array_merge($table_sorted[$id],$table[$id]);
+ }
+ $table = $table_sorted;
+ }
+
+ function print_item_table($table) {
+ $this->table_add_images($table);
+ $this->table_collapse($table);
+ $this->table_sort($table);
+ return $this->table_print($table);
+ }
+
+ function input($name=false, $value=false, $type='text', $placeholder=false, $options=false) {
+ $html = "<input type='$type' ";
+ if($name) $html.= "name='$name' ";
+ if(!is_bool($value)) $html.= "value='$value' ";
+ if($options) $html.= "$options ";
+ if($placeholder) $html.= "placeholder='$placeholder' ";
+ $html .= '/>';
+ return $html;
+ }
+
+ function select($name, $selectbox, $default=false) {
+ //echo('<pre>'); print_r($selectbox);
+ $html = "<select name='$name'>";
+
+ if($default) {
+ $value=$default; $title=$selectbox[$value];
+ $html .= "<option value='$value'>$value :: $title</option>";
+ unset($selectbox[$value]);
+ }
+ foreach($selectbox as $value => $title) {
+ $html .= "<option value='$value'>$value :: $title</option>";
+ }
+ $html .= "</select>";
+ return $html;
+ }
+
+ function print_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) {
+ //echo('<pre>'); print_r($selectbox);
+ //echo('<pre>'); print_r($current);
+ $update = false;
+ if(is_array($current)) {
+ $update = true;
+ $current = array_shift($current);
+ }
+
+ echo('<form method="POST">');
+ if($multi_insert) echo('<div name="input_set" style="float:left; border:1px solid grey;">');
+ echo $this->input('table', $class, 'hidden');
+ foreach($columns as $column) {
+ echo($column['Field'].': ');
+ $name='value:'.$column['Field'].'[]';
+ switch(true) {
+ case preg_match('/auto_increment/', $column['Extra']):
+ $val = $update ? $current[$column['Field']] : ''; //opakuje se (skoro) zbytecne
+ echo $this->input($name, $val, 'hidden');
+ echo($val.'(AUTO)');
+ break;
+ case isset($selectbox[$column['Field']]):
+ $val = $update ? $current[$column['Field']] : false;
+ echo $this->select($name,$selectbox[$column['Field']],$val); //opakuje se
+ break;
+ default:
+ $val = $update ? $current[$column['Field']] : false; //opakuje se
+ echo $this->input($name, $val);
+ break;
+ }
+ echo('<br />');
+ }
+
+ if($multi_insert) {
+ //TODO, move to separate JS file
+ echo <<<EOF
+ </div>
+ <span name="input_set_next"></span><br style="clear:both" />
+ <script>
+ function duplicate_element(what, where) {
+ document.getElementsByName(where)[0].outerHTML =
+ document.getElementsByName(what)[0].outerHTML
+ + document.getElementsByName(where)[0].outerHTML;
+ }
+ </script>
+ <a href='#' onClick="duplicate_element('input_set', 'input_set_next')">+</a>
+EOF;
+ }
+
+ $btn = is_array($current) ? 'UPDATE' : 'INSERT';
+ echo($this->input(false, $btn, 'submit'));
+ echo('</form>');
+ }
+}
+
+class Sklad_DB extends PDO {
+ function __construct() {
+ $this->lms = new Sklad_LMS();
+
+ parent::__construct(
+ DB_DSN, DB_USER, DB_PASS,
+ array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") //Force UTF8 for MySQL
+ );
+ }
+
+ function escape($str) {
+ return preg_replace('(^.|.$)', '', $this->quote($str)); //TODO HACK
+ }
+
+ function build_query_select($class, $id=false, $limit=false, $offset=0, $search=false, $id_suffix='_id') {
+ $class = $this->escape($class);
+ $join = array(
+ 'item' => array('model', 'category', 'producer', 'vendor', 'room', 'status'),
+ 'model' => array('category', 'producer')
+ );
+ $search_fields = array(
+ 'item' => array('item_id','model_name','model_barcode','model_descript','producer_name','vendor_name')
+ );
+ $sql="SELECT * FROM $class\n";
+ if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN $j USING($j$id_suffix)\n";
+ if($search) {
+ $search = $this->quote($search);
+ if(!isset($search_fields[$class])) {
+ trigger_error("Ve tride $class zatim vyhledavat nemozno :-(");
+ die();
+ }
+ $sql .= 'WHERE FALSE ';
+ foreach($search_fields[$class] as $column) $sql .= "OR $column REGEXP $search ";
+ } elseif($id) $sql .= "WHERE $class$id_suffix = $id\n";
+ if($limit) {
+ $limit = $this->escape((int)$limit);
+ $offset = $this->escape((int)$offset);
+ $sql .= "LIMIT $offset,$limit\n";
+ }
+ return $sql;
+ }
+
+ function safe_query($sql) {
+ $result = $this->query($sql);
+ if(!$result) {
+ trigger_error('<font color=red><b>QUERY FAILED:</b><pre>'.$sql.'</pre></font>');
+ die();
+ }
+ return $result;
+ }
+
+ function get_listing($class, $id=false, $limit=false, $offset=0, $search=false, $indexed=array(), $suffix_id='_id') {
+ $sql = $this->build_query_select($class, $id, $limit, $offset, $search);
+ $result = $this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC);
+ if(!$result || !is_array($indexed)) return $result;
+
+ foreach($result as $key => $row) $indexed[$row[$class.$suffix_id]]=$row;
+ return $indexed;
+ }
+
+ function get_columns($class) {
+ $class = $this->escape($class);
+ $sql = "SHOW COLUMNS FROM $class;";
+ return $this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC);
+ }
+
+ function columns_get_selectbox($columns, $class=false, $suffix_id='_id', $suffix_name='_name') {
+ $selectbox=array();
+ foreach($columns as $column) {
+ if($class && $column['Field'] == $class.$suffix_id) continue;
+ if(!preg_match('/'.$suffix_id.'$/', $column['Field'])) continue;
+ $table=preg_replace('/'.$suffix_id.'$/','',$column['Field']);
+ $sql = "SELECT $table$suffix_id, $table$suffix_name FROM $table;";
+ $result=$this->safe_query($sql)->fetchAll(PDO::FETCH_ASSOC);
+ foreach($result as $row) $selectbox[$table.$suffix_id][$row[$table.$suffix_id]]=$row[$table.$suffix_name];
+ }
+ //echo('<pre>'); print_r($selectbox);
+ return $selectbox;
+ }
+
+ function build_query_insert($table, $values, $replace=true, $suffix_id='_id') {
+ $table = $this->escape($table);
+
+ //Get list of POSTed columns
+ $columns = implode(',',array_map(array($this,'escape'), array_keys($values[0])));
+
+ //Insert into table (columns)
+ $sql = 'INSERT';
+ if($replace) $sql = 'REPLACE';
+ $sql .= " INTO $table ($columns) VALUES ";
+
+ //Values (a,b,c),(d,e,f)
+ $comma='';
+ foreach($values as $row) {
+ $sql .= $comma.'('.implode(',',array_map(array($this,'quote'), $row)).')';
+ $comma = ',';
+ }
+
+ //Terminate
+ $sql .= ';';
+ return $sql;
+ }
+
+ function insert_or_update($table, $values) {
+ $sql = $this->build_query_insert($table, $values);
+ $this->safe_query($sql);
+ return $this->lastInsertId();
+ }
+
+ function delete($table, $id, $suffix_id='_id') {
+ $key = $this->escape($table.$suffix_id);
+ $table = $this->escape($table);
+ $id = $this->quote($id);
+ return $this->safe_query("DELETE FROM $table WHERE $key = $id LIMIT 1;");
+ }
+}
+
+class Sklad_UI {
+ function __construct() {
+ $this->db = new Sklad_DB();
+ $this->html = new Sklad_HTML();
+ }
+
+ function show_items($class, $id=false, $limit=false, $offset=0, $search=false) {
+ $this->html->print_item_table($this->db->get_listing($class, $id, $limit, $offset, $search));
+ }
+
+ function show_form_add($class) {
+ $columns = $this->db->get_columns($class);
+ $selectbox = $this->db->columns_get_selectbox($columns, $class);
+ $this->html->print_insert_form($class, $columns, $selectbox);
+ }
+
+ function show_form_edit($class, $id) {
+ $columns = $this->db->get_columns($class);
+ $selectbox = $this->db->columns_get_selectbox($columns, $class);
+ $current = $this->db->get_listing($class, $id);
+ $this->html->print_insert_form($class, $columns, $selectbox, $current);
+ }
+
+ function show_single_record_details($class, $id) {
+ $id_next = $id + 1;
+ $id_prev = $id - 1 > 0 ? $id - 1 : 0;
+ $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
+ echo $this->html->link('<<', "$class/$id_prev/");
+ echo '-';
+ echo $this->html->link('>>', "$class/$id_next/");
+ echo ('<br />');
+ echo $this->html->link('edit', "$class/$id/edit/");
+ }
+
+ function show_listing_navigation($class, $id, $limit, $offset) {
+ $offset_next = $offset + $limit;
+ $offset_prev = $offset - $limit > 0 ? $offset - $limit : 0;
+ $get = $_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] : '';
+ echo $this->html->link('<<', "$class/$id/$limit/$offset_prev/$get");
+ echo '-';
+ echo $this->html->link('>>', "$class/$id/$limit/$offset_next/$get");
+ echo ('<br />');
+ echo $this->html->link('new', "$class/new/$get");
+ }
+
+ function show_listing_extensions($class, $id, $limit, $offset, $edit=false) {
+ if(is_numeric($id)) {
+ $this->show_single_record_details($class, $id);
+ } else {
+ $this->show_listing_navigation($class, '*', $limit, $offset);
+ }
+ if($edit) {
+ echo('<br />TODO UPDATE FORM!<br />');
+ $this->show_form_edit($class, $id);
+ $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete";
+ echo("<form action='$action' method='POST'>");
+ echo $this->html->input(false, 'DELETE', 'submit');
+ echo 'sure?'.$this->html->input('sure', false, 'checkbox');
+ echo('</form>');
+ $action = $_SERVER['SCRIPT_NAME']."/$class/$id/image";
+ echo("<form action='$action' method='POST' enctype='multipart/form-data'>");
+ echo $this->html->input('image', false, 'file', false, 'size="30"');
+ echo $this->html->input(false, 'IMAGE', 'submit');
+ echo('</form>');
+ }
+ }
+
+ function check_auth() {
+ new HTTP_Auth('SkladovejSystem', true, array($this->db->lms,'check_auth'));
+ }
+
+ function post_redirect_get($last, $next) { //TODO prepracovat, tohle je uplna picovina...
+ //header('Location: '.$_SERVER['REQUEST_URI']); //TODO redirect (need templating system or ob_start() first!!!)
+ echo 'Hotovo. Poslední vložený záznam naleznete '.$this->html->link('zde', $last).'.<br />'.
+ 'Další záznam přidáte '.$this->html->link('zde', $next).'.';
+ die();
+ }
+
+ function process_http_request_post($action=false, $class=false, $id=false) {
+ if($_SERVER['REQUEST_METHOD'] != 'POST') return;
+ echo('<pre>'); //DEBUG (maybe todo remove)
+
+ //SephirPOST:
+ $values=array();
+ foreach($_POST as $key => $value) {
+ $name = preg_split('/:/',$key);
+ if(isset($name[0])) switch($name[0]) {
+ case 'value':
+ foreach($value as $id => $val) $values[$id][$name[1]]=$value[$id];
+ break;
+ default:
+ break;
+ }
+ }
+
+ if($action) switch($action) {
+ case 'new':
+ case 'edit':
+ if(!isset($_POST['table'])) die(trigger_error("Jest nutno specifikovat tabulku voe!"));
+ $table=$_POST['table'];
+ //print_r($values); //debug
+ $last = $this->db->insert_or_update($table, $values);
+ $this->post_redirect_get("$table/$last/", "$table/new/");
+ break;
+ case 'delete':
+ if(!isset($_POST['sure']) || !$_POST['sure']) die(trigger_error('Sure user expected :-)'));
+ //$this->db->delete($class, $id);
+ die('Neco asi bylo smazano. Fnuk :\'-('); //TODO REDIRECT
+ break;
+ case 'image':
+ $image_classes = array('model'); //TODO, use this more widely across the code
+ if(!in_array($class, $image_classes)) die(trigger_error("Nekdo nechce k DB Tride '$class' prirazovat obrazky!"));
+ $image_destination = DIR_IMAGES."/$class/$id.jpg";
+ if($_FILES['image']['name'] == '') die(trigger_error('Kazde neco se musi nejak jmenovat!'));
+ if(move_uploaded_file($_FILES['image']['tmp_name'], $image_destination)) {
+ chmod ($image_destination, 0664);
+ die('Obrazek se naladoval :)'); //TODO REDIRECT
+ } else die(trigger_error('Soubor se nenahral :('));
+ break;
+ default:
+ trigger_error('Nothin\' to do here my cutie :-*');
+ break;
+ }
+
+ die('POSTed pyčo!');
+ }
+
+ function process_http_request() {
+ $this->check_auth();
+
+ @ini_set('magic_quotes_gpc' , 'off');
+ if(get_magic_quotes_gpc()) {
+ die(trigger_error("Error: magic_quotes_gpc needs to be disabled! F00K!"));
+ }
+
+ $PATH_INFO=@trim($_SERVER[PATH_INFO]);
+ $this->html->header_print($PATH_INFO);
+
+
+ //Sephirot:
+ $PATH_CHUNKS = preg_split('/\//', $PATH_INFO);
+ if(!isset($PATH_CHUNKS[1])) $PATH_CHUNKS[1]='';
+ switch($PATH_CHUNKS[1]) {
+ case 'test': //test
+ die('Tell me why you cry');
+ break;
+ default: //?
+ $search = (isset($_GET['q']) && trim($_GET['q']) != '') ? trim($_GET['q']) : false;
+ $class = (isset($PATH_CHUNKS[1]) && $PATH_CHUNKS[1] != '') ? $PATH_CHUNKS[1] : 'item';
+ if(!isset($PATH_CHUNKS[2])) $PATH_CHUNKS[2]='';
+ switch($PATH_CHUNKS[2]) {
+ case 'new': //?/new
+ $this->process_http_request_post($PATH_CHUNKS[2], $class);
+ $this->show_form_add($class);
+ break;
+ default: //?/?
+ $id = (isset($PATH_CHUNKS[2]) && is_numeric($PATH_CHUNKS[2]) ? (int) $PATH_CHUNKS[2] : false);
+ if(!isset($PATH_CHUNKS[3])) $PATH_CHUNKS[3]='';
+ $edit=false;
+ switch($PATH_CHUNKS[3]) {
+ case 'edit': //?/?/edit
+ case 'image': //?/image
+ case 'delete': //?/delete
+ $this->process_http_request_post($PATH_CHUNKS[3], $class, $id);
+ $edit=true;
+ default: //?/?/?
+ $limit = (int) (isset($PATH_CHUNKS[3]) ? $PATH_CHUNKS[3] : '0');
+ $offset = (int) (isset($PATH_CHUNKS[4]) ? $PATH_CHUNKS[4] : '0');
+ $this->show_items($class, $id, $limit, $offset, $search);
+ $this->show_listing_extensions($class, $id, $limit, $offset, $edit);
+ //print_r(array("<pre>",$_SERVER));
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ }
+}
+
+$sklad = new Sklad_UI();
+$sklad->process_http_request();
+
+echo("<hr/>");
--- /dev/null
+-- MySQL dump 10.11
+--
+-- Host: localhost Database: sklad
+-- ------------------------------------------------------
+-- Server version 5.0.51a-24+lenny5
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `category`
+--
+
+DROP TABLE IF EXISTS `category`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `category` (
+ `category_id` int(11) NOT NULL auto_increment,
+ `category_name` varchar(64) collate utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`category_id`),
+ UNIQUE KEY `category_name` (`category_name`)
+) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `category`
+--
+
+LOCK TABLES `category` WRITE;
+/*!40000 ALTER TABLE `category` DISABLE KEYS */;
+INSERT INTO `category` VALUES (1,'picovinky'),(2,'Tezka technika, Traktory, etc..');
+/*!40000 ALTER TABLE `category` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `item`
+--
+
+DROP TABLE IF EXISTS `item`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `item` (
+ `item_id` int(11) NOT NULL auto_increment,
+ `model_id` int(11) NOT NULL,
+ `vendor_id` int(11) NOT NULL,
+ `item_serial` varchar(128) collate utf8_czech_ci NOT NULL,
+ `item_quantity` int(11) default NULL,
+ `room_id` int(11) NOT NULL default '0',
+ `status_id` int(11) NOT NULL default '0',
+ `item_price_in` decimal(9,2) NOT NULL default '0.00',
+ `item_price_out` decimal(9,2) default NULL,
+ PRIMARY KEY (`item_id`),
+ UNIQUE KEY `item_serial` (`item_serial`)
+) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `item`
+--
+
+LOCK TABLES `item` WRITE;
+/*!40000 ALTER TABLE `item` DISABLE KEYS */;
+INSERT INTO `item` VALUES (1,1,1,'JGFHGA343',NULL,1,1,'13.00',NULL),(2,1,1,'OMG42',NULL,1,1,'7.00','25.00'),(3,2,0,'aaa232',NULL,0,0,'0.00',NULL),(9,3,2,'SATAN',0,1,1,'0.10','0.00'),(20,3,1,'editmeeeee',23,1,1,'0.00','0.00');
+/*!40000 ALTER TABLE `item` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `model`
+--
+
+DROP TABLE IF EXISTS `model`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `model` (
+ `model_id` int(11) NOT NULL auto_increment,
+ `model_name` varchar(64) collate utf8_czech_ci NOT NULL,
+ `producer_id` int(11) NOT NULL default '0',
+ `category_id` int(11) NOT NULL default '0',
+ `model_barcode` varchar(128) collate utf8_czech_ci NOT NULL,
+ `model_price_out` decimal(9,2) default NULL,
+ `model_descript` varchar(1024) collate utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`model_id`),
+ UNIQUE KEY `model_barcode` (`model_barcode`)
+) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `model`
+--
+
+LOCK TABLES `model` WRITE;
+/*!40000 ALTER TABLE `model` DISABLE KEYS */;
+INSERT INTO `model` VALUES (1,'Rushkoff: Klub extáze',0,0,'9788086096599','23.00','prvni vec s carovym kodem co sem videl'),(2,'Rama MultiVita',1,1,'8593838925918','15.00','oblibeny ropny produkt'),(3,'Karel Gott - kompletní diskografie',2,2,'4792207502505','666.00','možno použít i k sebeobraně');
+/*!40000 ALTER TABLE `model` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `producer`
+--
+
+DROP TABLE IF EXISTS `producer`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `producer` (
+ `producer_id` int(11) NOT NULL auto_increment,
+ `producer_name` varchar(64) collate utf8_czech_ci NOT NULL,
+ `producer_note` varchar(512) collate utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`producer_id`),
+ UNIQUE KEY `producer_name` (`producer_name`)
+) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `producer`
+--
+
+LOCK TABLES `producer` WRITE;
+/*!40000 ALTER TABLE `producer` DISABLE KEYS */;
+INSERT INTO `producer` VALUES (1,'C.C.M.E','Czech Company Making Everything'),(2,'AchAchne Labz','Ach ne');
+/*!40000 ALTER TABLE `producer` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `rights`
+--
+
+DROP TABLE IF EXISTS `rights`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `rights` (
+ `user_id` int(11) NOT NULL default '0',
+ `permit` enum('user','admin') collate utf8_czech_ci NOT NULL default 'user',
+ UNIQUE KEY `user_id` (`user_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `rights`
+--
+
+LOCK TABLES `rights` WRITE;
+/*!40000 ALTER TABLE `rights` DISABLE KEYS */;
+/*!40000 ALTER TABLE `rights` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `room`
+--
+
+DROP TABLE IF EXISTS `room`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `room` (
+ `room_id` int(11) NOT NULL auto_increment,
+ `room_name` varchar(64) collate utf8_czech_ci NOT NULL,
+ `manager_id` int(11) NOT NULL default '0',
+ `room_descript` text collate utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`room_id`),
+ UNIQUE KEY `room_name` (`room_name`)
+) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `room`
+--
+
+LOCK TABLES `room` WRITE;
+/*!40000 ALTER TABLE `room` DISABLE KEYS */;
+INSERT INTO `room` VALUES (1,'BarvyLaky',0,'LakyBarvy');
+/*!40000 ALTER TABLE `room` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `status`
+--
+
+DROP TABLE IF EXISTS `status`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `status` (
+ `status_id` int(11) NOT NULL auto_increment,
+ `status_name` varchar(16) collate utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`status_id`),
+ UNIQUE KEY `status_name` (`status_name`)
+) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `status`
+--
+
+LOCK TABLES `status` WRITE;
+/*!40000 ALTER TABLE `status` DISABLE KEYS */;
+INSERT INTO `status` VALUES (1,'stored'),(2,'placed'),(3,'saled'),(4,'destroyed');
+/*!40000 ALTER TABLE `status` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `transaction`
+--
+
+DROP TABLE IF EXISTS `transaction`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `transaction` (
+ `transaction_id` int(11) NOT NULL auto_increment,
+ `item_id` int(11) NOT NULL default '0',
+ `transaction_time` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ `status_id_in` int(11) NOT NULL default '0',
+ `status_id_out` int(11) NOT NULL default '0',
+ `user_id` int(11) NOT NULL default '0',
+ PRIMARY KEY (`transaction_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `transaction`
+--
+
+LOCK TABLES `transaction` WRITE;
+/*!40000 ALTER TABLE `transaction` DISABLE KEYS */;
+/*!40000 ALTER TABLE `transaction` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `vendor`
+--
+
+DROP TABLE IF EXISTS `vendor`;
+SET @saved_cs_client = @@character_set_client;
+SET character_set_client = utf8;
+CREATE TABLE `vendor` (
+ `vendor_id` int(11) NOT NULL auto_increment,
+ `vendor_name` varchar(64) collate utf8_czech_ci NOT NULL,
+ `vendor_note` varchar(256) collate utf8_czech_ci NOT NULL,
+ PRIMARY KEY (`vendor_id`),
+ UNIQUE KEY `vendor_name` (`vendor_name`)
+) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
+SET character_set_client = @saved_cs_client;
+
+--
+-- Dumping data for table `vendor`
+--
+
+LOCK TABLES `vendor` WRITE;
+/*!40000 ALTER TABLE `vendor` DISABLE KEYS */;
+INSERT INTO `vendor` VALUES (1,'C.C.S.E','Czech Company Selling Everything'),(2,'Trolo Cybernetix','trololo');
+/*!40000 ALTER TABLE `vendor` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2011-06-12 3:18:45