From: Thomas Mudrunka Date: Sun, 12 Jun 2011 04:14:23 +0000 (+0200) Subject: Migrated from SVN to GIT (history was containing passwords, so i didn't converted it) X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=cdfce7c291830a69e3e91aac21f75c4fd3f09448;p=mirrors%2FSokoMan.git Migrated from SVN to GIT (history was containing passwords, so i didn't converted it) --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b181347 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.bak +*.conf.php +.svn diff --git a/HTTP_Auth.class.php b/HTTP_Auth.class.php new file mode 100755 index 0000000..f1f0f6e --- /dev/null +++ b/HTTP_Auth.class.php @@ -0,0 +1,116 @@ +. + */ + +///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): + * //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->cbanner401 - Forbidden\n

401 - Forbidden

\nLogin...\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->cbanner401 - Log out successfull\n

401 - Log out successfull

\nContinue...\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 = 'blog.harvie.cz'; + $banner = "Harvie's PHP HTTP-Auth script (v$ver)"; + $this->hbanner = "
$banner\n-\n$link\n"; + $this->cbanner = "\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); diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4085047 --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +.PHONY: dump +dump: + ./dump_sql.php > install.sql diff --git a/Sklad_LMS-fake.class.php b/Sklad_LMS-fake.class.php new file mode 100755 index 0000000..3814ec2 --- /dev/null +++ b/Sklad_LMS-fake.class.php @@ -0,0 +1,37 @@ +. +*/ + +class Sklad_LMS_common { + function get_authorized_user_id($die=true) { + if(isset($this->authorized_user_id)) return $this->authorized_user_id; + if($die) die('No user authorized!!!'); + return false; + } +} + +class Sklad_LMS extends Sklad_LMS_common { //FAKE! + function check_auth($user, $pass) { + $users = array( //You can specify multiple users in this array + DB_USER => DB_PASS + ); + if(isset($GLOBALS['fake_lms_users'])) $users = $GLOBALS['fake_lms_users'] + $users; + $this->authorized_user_id=23; //LMS user_id + return (isset($users[$user]) && ($users[$user] == $pass)); + } +} diff --git a/dump_sql.php b/dump_sql.php new file mode 100755 index 0000000..efa005d --- /dev/null +++ b/dump_sql.php @@ -0,0 +1,4 @@ +#!/usr/bin/php +. + */ + +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 <<SystémSklad$title +
+ +
  • Logout
  • +
  • Home
  • +
    +
    + + +
    + +
    +EOF; + } + + function row_print($row) { + echo(''); + foreach($row as $var) { + if(trim($var) == '') $var = ' '; + echo("$var"); + } + echo(''); + } + + function table_print(&$table, $params='border=1') { + echo(""); + $header=true; + foreach($table as $row) { + if($header) { + $this->row_print(array_keys($row)); + $header=false; + } + $this->row_print($row); + } + echo('
    '); + } + + function link($title='n/a', $link='#void', $internal=true) { + if($internal) $link = $_SERVER['SCRIPT_NAME'].'/'.$link; + return "$title"; + } + + function img($src='#void', $title='img') { + return "$title"; + } + + 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 = "'); print_r($selectbox); + $html = ""; + return $html; + } + + function print_insert_form($class, $columns, $selectbox=array(), $current=false, $multi_insert=true) { + //echo('
    '); print_r($selectbox);
    +		//echo('
    '); print_r($current);
    +		$update = false;
    +		if(is_array($current)) {
    +			$update = true;
    +			$current = array_shift($current);
    +		}
    +
    +		echo('
    '); + if($multi_insert) echo('
    '); + 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('
    '); + } + + if($multi_insert) { + //TODO, move to separate JS file + echo << +
    + + + +EOF; + } + + $btn = is_array($current) ? 'UPDATE' : 'INSERT'; + echo($this->input(false, $btn, 'submit')); + echo(''); + } +} + +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('QUERY FAILED:
    '.$sql.'
    '); + 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('
    '); 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 ('
    '); + 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 ('
    '); + 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('
    TODO UPDATE FORM!
    '); + $this->show_form_edit($class, $id); + $action = $_SERVER['SCRIPT_NAME']."/$class/$id/delete"; + echo("
    "); + echo $this->html->input(false, 'DELETE', 'submit'); + echo 'sure?'.$this->html->input('sure', false, 'checkbox'); + echo('
    '); + $action = $_SERVER['SCRIPT_NAME']."/$class/$id/image"; + echo("
    "); + echo $this->html->input('image', false, 'file', false, 'size="30"'); + echo $this->html->input(false, 'IMAGE', 'submit'); + echo('
    '); + } + } + + 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).'.
    '. + '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('
    '); //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("
    ",$_SERVER));
    +								break;
    +						}
    +						break;
    +				}
    +				break;
    +		}
    +	}
    +}
    +
    +$sklad = new Sklad_UI();
    +$sklad->process_http_request();
    +
    +echo("
    "); diff --git a/index.phps b/index.phps new file mode 120000 index 0000000..0012f7d --- /dev/null +++ b/index.phps @@ -0,0 +1 @@ +index.php \ No newline at end of file diff --git a/install.sql b/install.sql new file mode 100644 index 0000000..6babd7b --- /dev/null +++ b/install.sql @@ -0,0 +1,268 @@ +-- 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 diff --git a/sklad.conf.php.example b/sklad.conf.php.example new file mode 100755 index 0000000..6fa48cd --- /dev/null +++ b/sklad.conf.php.example @@ -0,0 +1,17 @@ + DB_PASS +);