diff --git a/api/api.php b/api/api.php index d3e50a6..6b1424c 100644 --- a/api/api.php +++ b/api/api.php @@ -34,12 +34,12 @@ class api { //Parameters $parentid = $commands[count($commands)-1][0]; - $parentid = $parentid[\SYSTEM\DBD\APITable::FIELD_ID]; + $parentid = $parentid[\SYSTEM\DBD\system_api::FIELD_ID]; $parameters = self::do_parameters($params, $tree, $parentid, $commands[count($commands)-1][1],$verifyclassname); //throws //Opt Parameters $parentid = $commands[count($commands)-1][0]; - $parentid = $parentid[\SYSTEM\DBD\APITable::FIELD_ID]; + $parentid = $parentid[\SYSTEM\DBD\system_api::FIELD_ID]; $parameters_opt = self::do_parameters_opt($params, $tree, $parentid, $commands[count($commands)-1][1],$verifyclassname); //throws //strict check @@ -62,9 +62,9 @@ class api { private static function getApiTree($group){ $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); if(\SYSTEM\system::isSystemDbInfoPG()){ - $res = $con->query('SELECT * FROM '.\SYSTEM\DBD\APITable::NAME_PG .' WHERE "'.\SYSTEM\DBD\APITable::FIELD_GROUP.'" = '.$group.' ORDER BY "'.\SYSTEM\DBD\APITable::FIELD_ID.'"'); + $res = $con->query('SELECT * FROM '.\SYSTEM\DBD\system_api::NAME_PG .' WHERE "'.\SYSTEM\DBD\system_api::FIELD_GROUP.'" = '.$group.' ORDER BY "'.\SYSTEM\DBD\system_api::FIELD_ID.'"'); } else { - $res = $con->query('SELECT * FROM '.\SYSTEM\DBD\APITable::NAME_MYS.' WHERE `'.\SYSTEM\DBD\APITable::FIELD_GROUP.'` = '.$group.' ORDER BY '.\SYSTEM\DBD\APITable::FIELD_ID); + $res = $con->query('SELECT * FROM '.\SYSTEM\DBD\system_api::NAME_MYS.' WHERE `'.\SYSTEM\DBD\system_api::FIELD_GROUP.'` = '.$group.' ORDER BY '.\SYSTEM\DBD\system_api::FIELD_ID); } if(!$res){ @@ -84,23 +84,23 @@ class api { $statics = array(); $parentid = self::ROOT_PARENTID; foreach($tree as $item){ - if( intval($item[\SYSTEM\DBD\APITable::FIELD_TYPE]) == \SYSTEM\DBD\APITable::VALUE_TYPE_STATIC && - intval($item[\SYSTEM\DBD\APITable::FIELD_PARENTID]) == $parentid && - isset($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ + if( intval($item[\SYSTEM\DBD\system_api::FIELD_TYPE]) == \SYSTEM\DBD\system_api::VALUE_TYPE_STATIC && + intval($item[\SYSTEM\DBD\system_api::FIELD_PARENTID]) == $parentid && + isset($params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ - $statics[] = array($item,$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]]); - $call_funcname = 'static_'.$item[\SYSTEM\DBD\APITable::FIELD_NAME]; + $statics[] = array($item,$params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]]); + $call_funcname = 'static_'.$item[\SYSTEM\DBD\system_api::FIELD_NAME]; //verify func if(!\method_exists($apiclassname, $call_funcname)){ return self::do_default($default, $apiclassname, $call_funcname);} //throws //verify parameter - if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) || - !call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ - throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]);} + if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\system_api::FIELD_VERIFY]) || + !call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\system_api::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]);} - \call_user_func_array(array($apiclassname,$call_funcname),array($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])); + \call_user_func_array(array($apiclassname,$call_funcname),array($params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])); } } @@ -131,18 +131,18 @@ class api { $commands = array(); $parentid = self::ROOT_PARENTID; foreach($tree as $item){ - if( (intval($item[\SYSTEM\DBD\APITable::FIELD_TYPE]) == \SYSTEM\DBD\APITable::VALUE_TYPE_COMMAND || - intval($item[\SYSTEM\DBD\APITable::FIELD_TYPE]) == \SYSTEM\DBD\APITable::VALUE_TYPE_COMMAND_FLAG) && - intval($item[\SYSTEM\DBD\APITable::FIELD_PARENTID]) == $parentid && - isset($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ + if( (intval($item[\SYSTEM\DBD\system_api::FIELD_TYPE]) == \SYSTEM\DBD\system_api::VALUE_TYPE_COMMAND || + intval($item[\SYSTEM\DBD\system_api::FIELD_TYPE]) == \SYSTEM\DBD\system_api::VALUE_TYPE_COMMAND_FLAG) && + intval($item[\SYSTEM\DBD\system_api::FIELD_PARENTID]) == $parentid && + isset($params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ //check parent value - if( isset($item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]) && - $commands[count($commands)-1][1] != $item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]){ + if( isset($item[\SYSTEM\DBD\system_api::FIELD_PARENTVALUE]) && + $commands[count($commands)-1][1] != $item[\SYSTEM\DBD\system_api::FIELD_PARENTVALUE]){ continue;} - $commands[] = array($item,$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]]); - $parentid = intval($item[\SYSTEM\DBD\APITable::FIELD_ID]); + $commands[] = array($item,$params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]]); + $parentid = intval($item[\SYSTEM\DBD\system_api::FIELD_ID]); } } @@ -152,24 +152,24 @@ class api { private static function do_parameters($params,$tree,$parentid,$lastcommandvalue,$verifyclassname){ $parameters = array(); foreach($tree as $item){ - if( intval($item[\SYSTEM\DBD\APITable::FIELD_TYPE]) == \SYSTEM\DBD\APITable::VALUE_TYPE_PARAM && - intval($item[\SYSTEM\DBD\APITable::FIELD_PARENTID]) == $parentid){ + if( intval($item[\SYSTEM\DBD\system_api::FIELD_TYPE]) == \SYSTEM\DBD\system_api::VALUE_TYPE_PARAM && + intval($item[\SYSTEM\DBD\system_api::FIELD_PARENTID]) == $parentid){ //check parent value - if( isset($item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]) && - $lastcommandvalue != $item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]){ + if( isset($item[\SYSTEM\DBD\system_api::FIELD_PARENTVALUE]) && + $lastcommandvalue != $item[\SYSTEM\DBD\system_api::FIELD_PARENTVALUE]){ continue;} //all parameters are required - if(!isset($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ - throw new \SYSTEM\LOG\ERROR('Parameter missing: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME]);} + if(!isset($params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter missing: '.$item[\SYSTEM\DBD\system_api::FIELD_NAME]);} //verify parameter - if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) || - !call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ - throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]);} + if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\system_api::FIELD_VERIFY]) || + !call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\system_api::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]);} - $parameters[] = array($item, $params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]]); + $parameters[] = array($item, $params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]]); } } @@ -179,24 +179,24 @@ class api { private static function do_parameters_opt($params,$tree,$parentid,$lastcommandvalue,$verifyclassname){ $parameters_opt = array(); foreach($tree as $item){ - if( intval($item[\SYSTEM\DBD\APITable::FIELD_TYPE]) == \SYSTEM\DBD\APITable::VALUE_TYPE_PARAM_OPT && - intval($item[\SYSTEM\DBD\APITable::FIELD_PARENTID]) == $parentid){ + if( intval($item[\SYSTEM\DBD\system_api::FIELD_TYPE]) == \SYSTEM\DBD\system_api::VALUE_TYPE_PARAM_OPT && + intval($item[\SYSTEM\DBD\system_api::FIELD_PARENTID]) == $parentid){ //check parent value - if( isset($item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]) && - $lastcommandvalue != $item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]){ + if( isset($item[\SYSTEM\DBD\system_api::FIELD_PARENTVALUE]) && + $lastcommandvalue != $item[\SYSTEM\DBD\system_api::FIELD_PARENTVALUE]){ continue;} //all parameters are NOT required - just continue - if(!isset($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ + if(!isset($params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ continue;} //verify parameter - if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) || - !call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){ - throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]);} + if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\system_api::FIELD_VERIFY]) || + !call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]])){ + throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\system_api::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\system_api::FIELD_VERIFY]);} - $parameters_opt[] = array($item, $params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]]); + $parameters_opt[] = array($item, $params[$item[\SYSTEM\DBD\system_api::FIELD_NAME]]); } } @@ -209,10 +209,10 @@ class api { if(!\preg_match('^[0-9A-Za-z_]+$^', $com[1])){ throw new \SYSTEM\LOG\ERROR('Call Command can only have letters! command: '.$com[0]['name'].'; value: '.$com[1]);} - if($com[0][\SYSTEM\DBD\APITable::FIELD_TYPE] == \SYSTEM\DBD\APITable::VALUE_TYPE_COMMAND_FLAG){ - $call_funcname .= '_flag_'.$com[0][\SYSTEM\DBD\APITable::FIELD_NAME]; + if($com[0][\SYSTEM\DBD\system_api::FIELD_TYPE] == \SYSTEM\DBD\system_api::VALUE_TYPE_COMMAND_FLAG){ + $call_funcname .= '_flag_'.$com[0][\SYSTEM\DBD\system_api::FIELD_NAME]; } else { - $call_funcname .= '_'.$com[0][\SYSTEM\DBD\APITable::FIELD_NAME].'_'.\strtolower($com[1]);} + $call_funcname .= '_'.$com[0][\SYSTEM\DBD\system_api::FIELD_NAME].'_'.\strtolower($com[1]);} } $call_funcname = substr($call_funcname, 1); //strip leading _ diff --git a/dbd/sql/pg/schema/schema.sql b/dbd/sql/pg/schema/schema.sql new file mode 100644 index 0000000..349ddc7 --- /dev/null +++ b/dbd/sql/pg/schema/schema.sql @@ -0,0 +1,2 @@ +CREATE SCHEMA system + AUTHORIZATION username; \ No newline at end of file diff --git a/dbd/sql/pg/schema/system_api.sql b/dbd/sql/pg/schema/system_api.sql new file mode 100644 index 0000000..0bb4366 --- /dev/null +++ b/dbd/sql/pg/schema/system_api.sql @@ -0,0 +1,16 @@ +CREATE TABLE system.api +( + "ID" integer NOT NULL, + "group" integer NOT NULL, + type integer NOT NULL, + "parentID" integer NOT NULL, + "parentValue" character varying(50), + name character varying(50) NOT NULL, + verify character varying(50), + CONSTRAINT system_api_pk PRIMARY KEY ("ID", "group") +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.api + OWNER TO username; diff --git a/dbd/sql/pg/schema/system_cache.sql b/dbd/sql/pg/schema/system_cache.sql new file mode 100644 index 0000000..b2e6fd7 --- /dev/null +++ b/dbd/sql/pg/schema/system_cache.sql @@ -0,0 +1,32 @@ +CREATE TABLE system.cache +( + "ID" integer NOT NULL DEFAULT nextval('system."cache_ID_seq"'::regclass), + "CacheID" integer NOT NULL, + "Ident" character varying NOT NULL, + data bytea, + CONSTRAINT pk_system_cache_id PRIMARY KEY ("ID"), + CONSTRAINT unique_system_cache_cid_ident UNIQUE ("CacheID", "Ident") +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.cache + OWNER TO username; + +-- Index: system."cache_CacheID_Ident_idx" + +-- DROP INDEX system."cache_CacheID_Ident_idx"; + +CREATE INDEX "cache_CacheID_Ident_idx" + ON system.cache + USING btree + ("CacheID", "Ident" COLLATE pg_catalog."default"); + +-- Index: system."cache_Ident_idx" + +-- DROP INDEX system."cache_Ident_idx"; + +CREATE INDEX "cache_Ident_idx" + ON system.cache + USING btree + ("Ident" COLLATE pg_catalog."default"); \ No newline at end of file diff --git a/dbd/sql/pg/schema/system_locale_string.sql b/dbd/sql/pg/schema/system_locale_string.sql new file mode 100644 index 0000000..9a4c462 --- /dev/null +++ b/dbd/sql/pg/schema/system_locale_string.sql @@ -0,0 +1,13 @@ +CREATE TABLE system.locale_string +( + id character varying(50) NOT NULL, + category integer NOT NULL DEFAULT 0, + "enUS" text, + "deDE" text, + CONSTRAINT system_locale_string_pk_id PRIMARY KEY (id) +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.locale_string + OWNER TO username; \ No newline at end of file diff --git a/dbd/sql/pg/schema/system_rights.sql b/dbd/sql/pg/schema/system_rights.sql new file mode 100644 index 0000000..02fe0a6 --- /dev/null +++ b/dbd/sql/pg/schema/system_rights.sql @@ -0,0 +1,12 @@ +CREATE TABLE system.rights +( + "ID" integer NOT NULL DEFAULT nextval('system."user_rights_ID_seq"'::regclass), + name character varying(55) NOT NULL, + description character varying(255) NOT NULL, + CONSTRAINT system_rights_pk PRIMARY KEY ("ID") +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.rights + OWNER TO username; \ No newline at end of file diff --git a/dbd/sql/pg/schema/system_sys_log.sql b/dbd/sql/pg/schema/system_sys_log.sql new file mode 100644 index 0000000..d76711b --- /dev/null +++ b/dbd/sql/pg/schema/system_sys_log.sql @@ -0,0 +1,19 @@ +CREATE TABLE system.sys_log +( + "ID" integer NOT NULL DEFAULT nextval('system."sys_log_ID_seq"'::regclass), + class text NOT NULL, + message text NOT NULL, + code integer NOT NULL, + file text NOT NULL, + line integer NOT NULL, + trace text NOT NULL, + ip text NOT NULL, + querytime double precision NOT NULL, + "time" timestamp with time zone NOT NULL DEFAULT now() +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.sys_log + OWNER TO username; + diff --git a/dbd/sql/pg/schema/system_todo.sql b/dbd/sql/pg/schema/system_todo.sql new file mode 100644 index 0000000..b7f08cb --- /dev/null +++ b/dbd/sql/pg/schema/system_todo.sql @@ -0,0 +1,19 @@ +CREATE TABLE system.todo +( + "ID" integer NOT NULL, + "time" timestamp with time zone NOT NULL, + author integer NOT NULL, + type integer NOT NULL, + state integer NOT NULL, + msg_1 text NOT NULL, + msg_2 text, + msg_3 text, + msg_4 text, + msg_5 text, + CONSTRAINT system_todo_pk_id PRIMARY KEY ("ID") +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.todo + OWNER TO username; diff --git a/dbd/sql/pg/schema/system_user.sql b/dbd/sql/pg/schema/system_user.sql new file mode 100644 index 0000000..1b11fa2 --- /dev/null +++ b/dbd/sql/pg/schema/system_user.sql @@ -0,0 +1,18 @@ +CREATE TABLE system."user" +( + id serial NOT NULL, + username character varying(32) NOT NULL, + password_sha character varying(255), + password_md5 character varying(255), + email character varying(255) NOT NULL, + joindate timestamp with time zone NOT NULL DEFAULT now(), + locale character varying(6) NOT NULL DEFAULT 'enUS'::character varying, + last_active timestamp with time zone NOT NULL DEFAULT now(), + account_flag integer, + CONSTRAINT system_user_pk_id PRIMARY KEY (id) +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system."user" + OWNER TO username; diff --git a/dbd/sql/pg/schema/system_user_to_rights.sql b/dbd/sql/pg/schema/system_user_to_rights.sql new file mode 100644 index 0000000..1fde6e6 --- /dev/null +++ b/dbd/sql/pg/schema/system_user_to_rights.sql @@ -0,0 +1,16 @@ +CREATE TABLE system.user_to_rights +( + "rightID" integer NOT NULL, + "userID" integer NOT NULL, + CONSTRAINT "system_user_to_rights_fk_userID" FOREIGN KEY ("userID") + REFERENCES system."user" (id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "system_user_to_rights_rightID" FOREIGN KEY ("rightID") + REFERENCES system.rights ("ID") MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +) +WITH ( + OIDS=FALSE +); +ALTER TABLE system.user_to_rights + OWNER TO username; \ No newline at end of file diff --git a/dbd/tbl/PAGETable.php b/dbd/tbl/PAGETable.php deleted file mode 100644 index 2d4567b..0000000 --- a/dbd/tbl/PAGETable.php +++ /dev/null @@ -1,20 +0,0 @@ -