Compare commits

...

27 Commits

Author SHA1 Message Date
Clemens Schwaighofer
a2129f91c5 White space fixes 2016-08-31 15:20:40 +09:00
Clemens Schwaighofer
adf46f620b Update class basic, bug fixes for acl unit set in login class
class basic has a simple date string format method. returns Y-m-d h:i:s
for a trimestring, optional microseconds too
bug fix for unit/edit access id check in login class
2016-08-27 13:28:42 +09:00
Clemens Schwaighofer
31bef7a531 Add default space in byte string format, only read enable ea data
read only enabled edit access data fields
add default space between the converted byte data and the label
2016-08-02 14:38:23 +09:00
Clemens Schwaighofer
20b134231e Update description for edit access data return method 2016-07-20 10:57:29 +09:00
Clemens Schwaighofer
236a415fb4 Add get edit access data value for edit access id/key pair 2016-07-20 10:56:36 +09:00
Clemens Schwaighofer
1551df058d Bug fix for Login class and read sub data for edit access block 2016-07-19 16:44:21 +09:00
Clemens Schwaighofer
f980b1e76a Bug fix: did not add new sub data entries if there are no entries
If we load data that has no sub data referenced the list was not created
2016-07-19 16:14:41 +09:00
Clemens Schwaighofer
8de868fe4a Add new direct reference data element list to edit page
An edit page can have a new type of reference data type that is not a
link between table A and main table, but a sub table to main table with
several text fields + enable field.
This sub field list can have a max set, that adds empty rows to keep max
empty list available.
The sub table filed does not need a read_data element as the read is
directly connected to the master table (uses the elemen list key name
for table and the elements as read fields).
This sub elements need to have at least one as type = text and can have
error check addded (currently unique and alphanumeric work).

Also fix all old addslashes to correct db_escape_string

Read in for reference list also can have multiple elements (read data ->
name | seperated)

All sub reads have element prefixes

Inline documentation update
2016-07-19 15:12:43 +09:00
Clemens Schwaighofer
a20df16c2c Add enable field to edit access data 2016-07-15 17:31:40 +09:00
Clemens Schwaighofer
939ff2e4a5 Update Login Class with correct acl method and edit access data read
edit access data is read and put into the unit (edit access) array
the base acl method is adjusted to the current simple flat array one
- base acl only
- no max anymore (never needed)
- page acl
- unit (edit access) acl list + detail data
2016-07-15 16:17:40 +09:00
Clemens Schwaighofer
1c3cc95fdb Update form class and edit access table array
Form class has new check part for alpha numeric with spaces called
"alphanumericspace".

edit access table array gets update for making color no longer mandatory
(almost never used).
And adds alpha numeric with spaces and unique check for the name.
2016-07-15 11:40:42 +09:00
Clemens Schwaighofer
115e9ad700 Add edit access automatic UID set psql function
Trigger that gets called when edit access table is insert or update
called.

UID is set by removing all white spaces.
Original name set is already checked for Alphanumeric with spaces and
unique check.

On Insert always set UID.
On Update only set if UID is not set yet.
2016-07-15 11:37:45 +09:00
Clemens Schwaighofer
3aaa9b3f0d Remove old SVN $id$, add edit_access_data table
edit_access_data table can hold name/value pairs for additional info in
the access group
2016-07-15 10:13:29 +09:00
Clemens Schwaighofer
799cff4e00 Update config base files 2016-07-12 17:55:10 +09:00
Clemens Schwaighofer
72ef4a24c5 Check in neutral config.inc file before we set it to update ignore 2016-07-12 17:42:54 +09:00
Clemens Schwaighofer
0f44aaf3e4 Update config.inc file 2016-07-12 17:37:58 +09:00
Clemens Schwaighofer
795f69050a Update edit user base, config template, class basic
Class.Basic
add general 8 char hash wrapper function (for adler32, fnv, jooa)

Edit Users
add first/last name to the basic user info

Config template
Update config template from current working template
2016-07-12 10:44:53 +09:00
Clemens Schwaighofer
1c5bb8aebe Make db debug var public 2016-06-14 13:22:08 +09:00
Clemens Schwaighofer
36f19e64d0 Add new correct mobile email detect 2016-05-17 12:22:36 +09:00
Clemens Schwaighofer
19a1081197 Add missing mobile domains, fixup pc naming
PC type is now pc_html
pc is only for simple
2016-05-16 15:46:26 +09:00
Clemens Schwaighofer
45974a9e30 Set detailed japanese mobile phone carrier types 2016-05-12 14:20:51 +09:00
Clemens Schwaighofer
f1247efd34 Fix class declarations
old class declarations for constructors replaced with correct
"__construct" part.
2016-03-14 11:59:42 +09:00
Clemens Schwaighofer
c38346b97c Comment update 2016-02-22 11:03:09 +09:00
Clemens Schwaighofer
3c26adb493 Smarty 3.1 fix for options html 2016-01-25 16:16:36 +09:00
Clemens Schwaighofer
4458f366f9 Bug fixes for data insert with interval fields in form generate
- if interval is emtpy set NULL
- do some clean up for pk return data from the form/db array io part
2016-01-07 13:06:47 +09:00
Clemens Schwaighofer
805330638a Bug fix in DB IO for setting _db_error public
_db_error method was private, but was called in DB.Array.IO, so it had
to be set public again.

removed debug message from Form Generate class
2016-01-07 12:44:05 +09:00
Clemens Schwaighofer
86cd04f862 Fix bug in regex check in form generate 2016-01-07 12:40:05 +09:00
64 changed files with 820 additions and 469 deletions

View File

@@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
# $Id: create_default_trigger.sh 3158 2010-09-02 02:49:00Z gullevek $
# creates the default on update trigger for the inherited generic tables (date/name) # creates the default on update trigger for the inherited generic tables (date/name)
orig_file="../tmpl/trigger.tmpl" orig_file="../tmpl/trigger.tmpl"

View File

@@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
# $Id: drop_data.sh 3158 2010-09-02 02:49:00Z gullevek $
# quick hack for import # quick hack for import
#echo "EXIT"; #echo "EXIT";

View File

@@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
# $Id: drop_reload.sh 3158 2010-09-02 02:49:00Z gullevek $
rm error; rm error;
rm output; rm output;
bin/drop_data.sh; bin/drop_data.sh;

View File

@@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
# $Id: import_data.sh 4382 2013-02-18 07:27:24Z gullevek $
# quick hack for import # quick hack for import
#echo "EXIT"; #echo "EXIT";

View File

@@ -0,0 +1,28 @@
-- add uid add for edit_access table
CREATE OR REPLACE FUNCTION set_edit_access_uid() RETURNS TRIGGER AS
$$
DECLARE
myrec RECORD;
v_uid VARCHAR;
BEGIN
-- skip if NEW.name is not set
IF NEW.name IS NOT NULL AND NEW.name <> '' THEN
-- use NEW.name as base, remove all spaces
-- name data is already unique, so we do not need to worry about this here
v_uid := REPLACE(NEW.name, ' ', '');
IF TG_OP = 'INSERT' THEN
-- always set
NEW.uid := v_uid;
ELSIF TG_OP = 'UPDATE' THEN
-- check if not set, then set
SELECT INTO myrec t.* FROM edit_access t WHERE edit_access_id = NEW.edit_access_id;
IF FOUND THEN
NEW.uid := v_uid;
END IF;
END IF;
END IF;
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';

View File

@@ -1,4 +1,3 @@
-- $Id: update_function.sql 3158 2010-09-02 02:49:00Z gullevek $
-- adds the created or updated date tags -- adds the created or updated date tags
CREATE OR REPLACE FUNCTION set_generic() RETURNS TRIGGER AS ' CREATE OR REPLACE FUNCTION set_generic() RETURNS TRIGGER AS '

View File

@@ -1,4 +1,3 @@
-- $Id: edit_access.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -0,0 +1,16 @@
-- AUTHOR: Clemens Schwaighofer
-- DATE: 2016/7/15
-- DESCRIPTION:
-- sub table to edit access, holds additional data for access group
-- TABLE: edit_access_data
-- HISTORY:
-- DROP TABLE edit_access_data;
CREATE TABLE edit_access_data (
edit_access_data_id SERIAL PRIMARY KEY,
edit_access_id INT NOT NULL,
name VARCHAR,
value VARCHAR,
enabled SMALLINT NOT NULL DEFAULT 0,
FOREIGN KEY (edit_access_id) REFERENCES edit_access (edit_access_id) MATCH FULL ON DELETE CASCADE ON UPDATE CASCADE
) INHERITS (edit_generic) WITHOUT OIDS;

View File

@@ -1,4 +1,3 @@
-- $Id: edit_access_right.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_access_user.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_generic.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_group.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_language.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_log.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_menu_group.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_page.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_page_access.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_page_menu_group.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_page_visible_group.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_query_string.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_scheme.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_temp_files.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/08 -- DATE: 2005/07/08
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_user.sql 4226 2012-11-02 07:19:57Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/06 -- DATE: 2005/07/06
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: edit_visible_group.sql 4382 2013-02-18 07:27:24Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,4 +1,3 @@
-- $Id: generic.sql 3158 2010-09-02 02:49:00Z gullevek $
-- AUTHOR: Clemens Schwaighofer -- AUTHOR: Clemens Schwaighofer
-- DATE: 2005/07/05 -- DATE: 2005/07/05
-- DESCRIPTION: -- DESCRIPTION:

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_access.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_access ON edit_access; -- DROP TRIGGER trg_edit_access ON edit_access;
CREATE TRIGGER trg_edit_access CREATE TRIGGER trg_edit_access
BEFORE INSERT OR UPDATE ON edit_access BEFORE INSERT OR UPDATE ON edit_access

View File

@@ -0,0 +1,4 @@
-- DROP TRIGGER trg_edit_access_data ON edit_access_data;
CREATE TRIGGER trg_edit_access_data
BEFORE INSERT OR UPDATE ON edit_access_data
FOR EACH ROW EXECUTE PROCEDURE set_generic();

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_access_right.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_access_right ON edit_access_right; -- DROP TRIGGER trg_edit_access_right ON edit_access_right;
CREATE TRIGGER trg_edit_access_right CREATE TRIGGER trg_edit_access_right
BEFORE INSERT OR UPDATE ON edit_access_right BEFORE INSERT OR UPDATE ON edit_access_right

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_access_user.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_access_user ON edit_access_user; -- DROP TRIGGER trg_edit_access_user ON edit_access_user;
CREATE TRIGGER trg_edit_access_user CREATE TRIGGER trg_edit_access_user
BEFORE INSERT OR UPDATE ON edit_access_user BEFORE INSERT OR UPDATE ON edit_access_user

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_group.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_group ON edit_group; -- DROP TRIGGER trg_edit_group ON edit_group;
CREATE TRIGGER trg_edit_group CREATE TRIGGER trg_edit_group
BEFORE INSERT OR UPDATE ON edit_group BEFORE INSERT OR UPDATE ON edit_group

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_language.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_language ON edit_language; -- DROP TRIGGER trg_edit_language ON edit_language;
CREATE TRIGGER trg_edit_language CREATE TRIGGER trg_edit_language
BEFORE INSERT OR UPDATE ON edit_language BEFORE INSERT OR UPDATE ON edit_language

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_log.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_log ON edit_log; -- DROP TRIGGER trg_edit_log ON edit_log;
CREATE TRIGGER trg_edit_log CREATE TRIGGER trg_edit_log
BEFORE INSERT OR UPDATE ON edit_log BEFORE INSERT OR UPDATE ON edit_log

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_menu_group.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_visible_group ON edit_visible_group; -- DROP TRIGGER trg_edit_visible_group ON edit_visible_group;
CREATE TRIGGER trg_edit_menu_group CREATE TRIGGER trg_edit_menu_group
BEFORE INSERT OR UPDATE ON edit_menu_group BEFORE INSERT OR UPDATE ON edit_menu_group

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_page.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_page ON edit_page; -- DROP TRIGGER trg_edit_page ON edit_page;
CREATE TRIGGER trg_edit_page CREATE TRIGGER trg_edit_page
BEFORE INSERT OR UPDATE ON edit_page BEFORE INSERT OR UPDATE ON edit_page

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_page_access.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_page_access ON edit_page_access; -- DROP TRIGGER trg_edit_page_access ON edit_page_access;
CREATE TRIGGER trg_edit_page_access CREATE TRIGGER trg_edit_page_access
BEFORE INSERT OR UPDATE ON edit_page_access BEFORE INSERT OR UPDATE ON edit_page_access

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_query_string.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_query_string ON edit_query_string; -- DROP TRIGGER trg_edit_query_string ON edit_query_string;
CREATE TRIGGER trg_edit_query_string CREATE TRIGGER trg_edit_query_string
BEFORE INSERT OR UPDATE ON edit_query_string BEFORE INSERT OR UPDATE ON edit_query_string

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_scheme.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_scheme ON edit_scheme; -- DROP TRIGGER trg_edit_scheme ON edit_scheme;
CREATE TRIGGER trg_edit_scheme CREATE TRIGGER trg_edit_scheme
BEFORE INSERT OR UPDATE ON edit_scheme BEFORE INSERT OR UPDATE ON edit_scheme

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_user.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_user ON edit_user; -- DROP TRIGGER trg_edit_user ON edit_user;
CREATE TRIGGER trg_edit_user CREATE TRIGGER trg_edit_user
BEFORE INSERT OR UPDATE ON edit_user BEFORE INSERT OR UPDATE ON edit_user

View File

@@ -1,5 +1,3 @@
-- $Id: trg_edit_visible_group.sql 3158 2010-09-02 02:49:00Z gullevek $
-- DROP TRIGGER trg_edit_visible_group ON edit_visible_group; -- DROP TRIGGER trg_edit_visible_group ON edit_visible_group;
CREATE TRIGGER trg_edit_visible_group CREATE TRIGGER trg_edit_visible_group
BEFORE INSERT OR UPDATE ON edit_visible_group BEFORE INSERT OR UPDATE ON edit_visible_group

View File

@@ -0,0 +1,4 @@
-- DROP TRIGGER trg_set_edit_access_uid ON edit_access;
CREATE TRIGGER trg_set_edit_access_uid
BEFORE INSERT OR UPDATE ON edit_access
FOR EACH ROW EXECUTE PROCEDURE set_edit_access_uid();

View File

@@ -5,7 +5,7 @@
$DB_DEBUG = 1; $DB_DEBUG = 1;
if ($DEBUG_ALL) if ($DEBUG_ALL)
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
define('USE_DATABASE', true); define('USE_DATABASE', true);
// sample config // sample config
@@ -28,10 +28,12 @@
// set + check edit access id // set + check edit access id
$edit_access_id = 3; $edit_access_id = 3;
print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."<br>";
print "ACCESS CHECK: ".$login->login_check_edit_access($edit_access_id)."<br>";
if ($login->login_check_edit_access($edit_access_id)) if ($login->login_check_edit_access($edit_access_id))
$basic->edit_access_id = $edit_access_id; $basic->edit_access_id = $edit_access_id;
else else
$basic->edit_access_id = $login->acl['info']['default_edit_access']; $basic->edit_access_id = $login->acl['unit_id'];
// $basic->debug('SESSION', $basic->print_ar($_SESSION)); // $basic->debug('SESSION', $basic->print_ar($_SESSION));

View File

@@ -9,7 +9,7 @@
* - edit_pages.php * - edit_pages.php
* - edit_schemes.php * - edit_schemes.php
* - edit_users.php * - edit_users.php
* - edit_visible_group.php * - edit_visible_group.php
* HISTORY: * HISTORY:
* 2005/06/30 (cs) remove color settings, they are in CSS File now * 2005/06/30 (cs) remove color settings, they are in CSS File now
* 2005/06/22 (cs) moved load of config array into form class, set lang and lang is must set var for form class; removed the page name setting, moved it into the form class, remove all HTML from main page * 2005/06/22 (cs) moved load of config array into form class, set lang and lang is must set var for form class; removed the page name setting, moved it into the form class, remove all HTML from main page
@@ -107,15 +107,15 @@
} }
// log backend data // log backend data
// data part creation // data part creation
$data = array ( $data = array (
'_SESSION' => $_SESSION, '_SESSION' => $_SESSION,
'_GET' => $_GET, '_GET' => $_GET,
'_POST' => $_POST, '_POST' => $_POST,
'_FILES' => $_FILES '_FILES' => $_FILES
); );
// log action // log action
EditLog('Edit Submit', serialize($data)); EditLog('Edit Submit', serialize($data));
$form->form_procedure_load(${$form->archive_pk_name}); $form->form_procedure_load(${$form->archive_pk_name});
$form->form_procedure_new(); $form->form_procedure_new();
@@ -230,6 +230,8 @@
$elements[] = $form->form_create_element("password"); $elements[] = $form->form_create_element("password");
$elements[] = $form->form_create_element("password_change_interval"); $elements[] = $form->form_create_element("password_change_interval");
$elements[] = $form->form_create_element("email"); $elements[] = $form->form_create_element("email");
$elements[] = $form->form_create_element("last_name");
$elements[] = $form->form_create_element("first_name");
$elements[] = $form->form_create_element("edit_group_id"); $elements[] = $form->form_create_element("edit_group_id");
$elements[] = $form->form_create_element("edit_access_right_id"); $elements[] = $form->form_create_element("edit_access_right_id");
$elements[] = $form->form_create_element("strict"); $elements[] = $form->form_create_element("strict");
@@ -308,12 +310,15 @@
$elements[] = $form->form_create_element("name"); $elements[] = $form->form_create_element("name");
$elements[] = $form->form_create_element("color"); $elements[] = $form->form_create_element("color");
$elements[] = $form->form_create_element("description"); $elements[] = $form->form_create_element("description");
// add name/value list here
$elements[] = $form->form_show_list_table("edit_access_data");
break;
break; break;
default: default:
print "NO NO NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!"; print "NO NO NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!";
break; break;
} }
//$form->debug('edit', "Elements: <pre>".$form->print_ar($elements)); // $form->debug('edit', "Elements: <pre>".$form->print_ar($elements));
$DATA['elements'] = $elements; $DATA['elements'] = $elements;
$DATA['hidden'] = $form->form_create_hidden_fields(); $DATA['hidden'] = $form->form_create_hidden_fields();
$DATA['save_delete'] = $form->form_create_save_delete(); $DATA['save_delete'] = $form->form_create_save_delete();

View File

@@ -67,7 +67,7 @@
$smarty->setTemplateDir(TEMPLATES.DEFAULT_TEMPLATE); $smarty->setTemplateDir(TEMPLATES.DEFAULT_TEMPLATE);
$DATA['css'] = CSS.DEFAULT_TEMPLATE; $DATA['css'] = CSS.DEFAULT_TEMPLATE;
$DATA['js'] = JS.DEFAULT_TEMPLATE; $DATA['js'] = JS.DEFAULT_TEMPLATE;
} }
// order name is _always_ order_number for the edit interface // order name is _always_ order_number for the edit interface

View File

@@ -155,7 +155,7 @@
if (!$error) if (!$error)
{ {
if ($_FILES['file_up']['name']) if ($_FILES['file_up']['name'])
{ {
$mime_type = $_FILES['file_up']['type']; $mime_type = $_FILES['file_up']['type'];
$file_size = $_FILES['file_up']['size']; $file_size = $_FILES['file_up']['size'];
$file_name = $_FILES['file_up']['name']; $file_name = $_FILES['file_up']['name'];

View File

@@ -64,6 +64,8 @@
$cms->menu_show_flag = 'main'; $cms->menu_show_flag = 'main';
// db nfo // db nfo
$cms->db_info(); $cms->db_info();
// set acl
$cms->acl = $login->acl;
//------------------------------ class init end //------------------------------ class init end
//------------------------------ logging start //------------------------------ logging start

View File

@@ -95,7 +95,7 @@
if (!is_dir($cms->pictures)) if (!is_dir($cms->pictures))
$cms->pictures = LAYOUT.DEFAULT_TEMPLATE.PICTURES.'/'; $cms->pictures = LAYOUT.DEFAULT_TEMPLATE.PICTURES.'/';
if (!is_dir($cms->cache_pictures)) if (!is_dir($cms->cache_pictures))
$cms->cache_pictures = LAYOUT.DEFAULT_TEMPLATE.CACHE.IMAGES.'/'; $cms->cache_pictures = LAYOUT.DEFAULT_TEMPLATE.CACHE.IMAGES.'/';
// if the template_dir is != DEFAULT_TEMPLATE, then try to make a lang switch // if the template_dir is != DEFAULT_TEMPLATE, then try to make a lang switch
// if the default lang is not like the lang given, switch lang // if the default lang is not like the lang given, switch lang

View File

@@ -10,7 +10,8 @@
"value" => $GLOBALS["name"], "value" => $GLOBALS["name"],
"output_name" => $this->l->__("Access Group Name"), "output_name" => $this->l->__("Access Group Name"),
"mandatory" => 1, "mandatory" => 1,
"type" => "text" "type" => "text",
"error_check" => "alphanumericspace|unique"
), ),
"description" => array ( "description" => array (
"value" => $GLOBALS["description"], "value" => $GLOBALS["description"],
@@ -20,7 +21,7 @@
"color" => array ( "color" => array (
"value" => $GLOBALS["color"], "value" => $GLOBALS["color"],
"output_name" => $this->l->__("Color"), "output_name" => $this->l->__("Color"),
"mandatory" => 1, "mandatory" => 0,
"type" => "text", "type" => "text",
"size" => 6, "size" => 6,
"length" => 6, "length" => 6,
@@ -28,7 +29,6 @@
"error_regex" => "/[\dA-Fa-f]{6}/", "error_regex" => "/[\dA-Fa-f]{6}/",
"error_example" => "F6A544" "error_example" => "F6A544"
) )
), ),
"table_name" => "edit_access", "table_name" => "edit_access",
"load_query" => "SELECT edit_access_id, name FROM edit_access ORDER BY name", "load_query" => "SELECT edit_access_id, name FROM edit_access ORDER BY name",
@@ -36,6 +36,43 @@
array ( array (
"name" => "name" "name" => "name"
) )
),
"element_list" => array (
"edit_access_data" => array (
"output_name" => "Edit Access Data",
"type" => "reference_data", # is not a sub table read and connect, but only a sub table with data
"max_empty" => 5, # maxium visible if no data is set, if filled add this number to visible
"prefix" => "ead",
"elements" => array (
"edit_access_data_id" => array (
"output_name" => "Activate",
"type" => "hidden",
"int" => 1,
"pk_id" => 1
),
"name" => array (
"type" => "text",
"error_check" => "alphanumeric|unique",
"output_name" => "Name"
),
"value" => array (
"type" => "text",
"output_name" => "Value"
),
"enabled" => array (
"type" => "checkbox",
"output_name" => "Activate",
"int" => 1,
"element_list" => array(1)
),
"edit_access_id" => array (
"int" => 1,
"type" => "hidden",
"fk_id" => 1 # reference main key from master table above
)
)
)
) )
); );
?> ?>

View File

@@ -34,6 +34,7 @@
'output_name' => 'Password change interval', 'output_name' => 'Password change interval',
'error_check' => 'intervalshort', // can be any date length format. n Y/M/D [not H/M/S], only one set, no combination 'error_check' => 'intervalshort', // can be any date length format. n Y/M/D [not H/M/S], only one set, no combination
'type' => 'text', 'type' => 'text',
'interval' => 1, // interval needs NULL write for empty
'size' => 5, // make it 5 chars long 'size' => 5, // make it 5 chars long
'length' => 5 'length' => 5
), ),
@@ -103,6 +104,16 @@
"output_name" => "E-Mail", "output_name" => "E-Mail",
"type" => "text" "type" => "text"
), ),
"last_name" => array (
"value" => $GLOBALS["last_name"],
"output_name" => "Last Name",
"type" => "text"
),
"first_name" => array (
"value" => $GLOBALS["first_name"],
"output_name" => "First Name",
"type" => "text"
),
"edit_language_id" => array ( "edit_language_id" => array (
"value" => $GLOBALS["edit_language_id"], "value" => $GLOBALS["edit_language_id"],
"output_name" => "Language", "output_name" => "Language",

View File

@@ -9,9 +9,9 @@
/************* SESSION NAMES *************/ /************* SESSION NAMES *************/
// backend // backend
DEFINE('EDIT_SESSION_NAME', "ADMIN_SESSION_NAME"); DEFINE('EDIT_SESSION_NAME', "<ADMIN SESSION NAME>");
// frontend // frontend
DEFINE('SESSION_NAME', "SESSION_NAME"); DEFINE('SESSION_NAME', "<SESSION NAME>");
/************* LANGUAGE / ENCODING *******/ /************* LANGUAGE / ENCODING *******/
DEFINE('DEFAULT_LANG', "en_utf8"); DEFINE('DEFAULT_LANG', "en_utf8");
@@ -34,7 +34,7 @@
DEFINE('ROOT', getcwd()."/"); DEFINE('ROOT', getcwd()."/");
// libs path // libs path
DEFINE('LIBS', "libs/"); DEFINE('LIBS', "libs/");
// includes (strings, arrays for stati, etc) // includes (strings, arrays for static, etc)
DEFINE('INCLUDES', "includes/"); DEFINE('INCLUDES', "includes/");
// layout base path // layout base path
DEFINE('LAYOUT', 'layout/'); DEFINE('LAYOUT', 'layout/');
@@ -85,7 +85,7 @@
/************* HASH / ACL DEFAULT / ERROR SETTINGS / SMARTY *************/ /************* HASH / ACL DEFAULT / ERROR SETTINGS / SMARTY *************/
// default hash type // default hash type
DEFINE('DEFAULT_HASH', 'ripemd160'); DEFINE('DEFAULT_HASH', 'sha256');
// default acl level // default acl level
DEFINE('DEFAULT_ACL_LEVEL', 80); DEFINE('DEFAULT_ACL_LEVEL', 80);
// default levels for certain actions // default levels for certain actions
@@ -97,7 +97,7 @@
DEFINE('DEFAULT_ACL_DEL', 80); DEFINE('DEFAULT_ACL_DEL', 80);
DEFINE('DEFAULT_ACL_ADMIN', 100); */ DEFINE('DEFAULT_ACL_ADMIN', 100); */
// SSL host name // SSL host name
// DEFINE('SSL_HOST', "www4.adidas.co.jp"); // DEFINE('SSL_HOST', "ssl.host.name");
// error page strictness, Default is 3 // error page strictness, Default is 3
// 1: only show error page as the last mesure if really no mid & aid can be loaded and found at all // 1: only show error page as the last mesure if really no mid & aid can be loaded and found at all
// 2: if template not found, do not search, show error template // 2: if template not found, do not search, show error template
@@ -106,7 +106,7 @@
// DEFINE('ERROR_STRICT', 3); // DEFINE('ERROR_STRICT', 3);
// allow page caching in general, set to "FALSE" if you do debugging or development! // allow page caching in general, set to "FALSE" if you do debugging or development!
// DEFINE('ALLOW_SMARTY_CACHE', FALSE); // DEFINE('ALLOW_SMARTY_CACHE', FALSE);
// cache life time, in second', default here is 2 days (172800s) // cache life time, in seconds, default here is 2 days (172800s)
// -1 is never expire cache // -1 is never expire cache
// DEFINE('SMARTY_CACHE_LIFETIME', -1); // DEFINE('SMARTY_CACHE_LIFETIME', -1);
@@ -135,17 +135,23 @@
// live_queue is a global queue system // live_queue is a global queue system
// DEFINE('QUEUE', 'live_queue'); // DEFINE('QUEUE', 'live_queue');
/************* DB PATHS (PostgreSQL) *****************/
// schema names, can also be defined per <DB INFO>
DEFINE('PUBLIC_SCHEMA', 'public');
DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public');
// non constant part // non constant part
/************* DB ACCESS *****************/ /************* DB ACCESS *****************/
// please be VERY carefull only to change the right side // please be VERY carefull only to change the right side
$DB_CONFIG = array( $DB_CONFIG = array(
"test" => array ( "<db id>" => array (
"db_name" => "gullevek", "db_name" => "<database>",
"db_user" => "gullevek", "db_user" => "<user>",
"db_pass" => "gullevek", "db_pass" => "<password>",
"db_host" => "db.tokyo.tequila.jp", "db_host" => "<host>",
"db_port" => "5432", "db_port" => "5432",
"db_schema" => "public", "db_schema" => "public", // if not set, uses public
"db_type" => "pgsql", "db_type" => "pgsql",
"db_encoding" => '', "db_encoding" => '',
"db_ssl" => 'disable' // allow, disable, require, prefer "db_ssl" => 'disable' // allow, disable, require, prefer
@@ -160,27 +166,19 @@
// each host has a different db_host // each host has a different db_host
// development host // development host
$DB_HOST['soba'] = "test"; $DB_HOST['<host>'] = "<db id>";
$DB_HOST['soba.tokyo.tequila.jp'] = "test";
// target host (live) // target host (live)
// $DB_TARGET_HOST['soba'] = "<DB ID>"; // $DB_TARGET_HOST['<host>'] = "<DB ID>";
// url redirect database // url redirect database
// $DB_URL_REDIRECT_HOST['soba'] = "<DB ID>"; // $DB_URL_REDIRECT_HOST['<host>'] = "<DB ID>";
// location flagging // location flagging
// test/dev/live // test/dev/live
$LOCATION['soba'] = 'test'; $LOCATION['<host>'] = '<test|live|remote|etc>';
$LOCATION['soba.tokyo.tequila.jp'] = 'test';
// show DEBUG override // show DEBUG override
// true/false // true/false
$DEBUG_FLAG['soba'] = true; $DEBUG_FLAG['<host>'] = true;
$DEBUG_FLAG['soba.tokyo.tequila.jp'] = true; // set postgresql paths (schemas)
// schema names, can also be defined per <DB INFO> $DB_PATH['<host>'] = PUBLIC_SCHEMA;
DEFINE('PUBLIC_SCHEMA', 'public');
DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public');
// and set to domain
$DB_PATH['soba'] = PUBLIC_SCHEMA;
$DB_PATH['soba.tokyo.tequila.jp'] = PUBLIC_SCHEMA;
// set the USE_DATABASE var, if there is nothing set, we assume TRUE // set the USE_DATABASE var, if there is nothing set, we assume TRUE
$USE_DATABASE = defined('USE_DATABASE') ? USE_DATABASE : true; $USE_DATABASE = defined('USE_DATABASE') ? USE_DATABASE : true;
@@ -206,7 +204,7 @@
// DEFINE('TEST_SCHEMA', $DB_CONFIG[MAIN_DB]['db_schema']); // DEFINE('TEST_SCHEMA', $DB_CONFIG[MAIN_DB]['db_schema']);
// DEFINE('PUBLIC_SCHEMA', $DB_CONFIG[TARGET_DB]['db_schema']); // DEFINE('PUBLIC_SCHEMA', $DB_CONFIG[TARGET_DB]['db_schema']);
DEFINE('LOGIN_DB_SCHEMA', 'public'); // where the edit* tables are DEFINE('LOGIN_DB_SCHEMA', 'public'); // where the edit* tables are
DEFINE('GLOBAL_DB_SCHEMA', 'public'); // where global tables are that are used by all schemas (eg queue tables for online', etc) DEFINE('GLOBAL_DB_SCHEMA', 'public'); // where global tables are that are used by all schemas (eg queue tables for online, etc)
DEFINE('TARGET', $LOCATION[$HOST_NAME]); DEFINE('TARGET', $LOCATION[$HOST_NAME]);
// DEFINE('CSV_PATH', $PATHS[TARGET]['csv_path']); // DEFINE('CSV_PATH', $PATHS[TARGET]['csv_path']);
// DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']); // DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']);
@@ -279,5 +277,4 @@
} }
return false; return false;
} }
?> ?>

View File

@@ -1,10 +1,5 @@
<? <?
/******************************************************************** /********************************************************************
* $HeadURL: svn://svn/development/core_data/php/www/configs/config.template.inc $
* $LastChangedBy: gullevek $
* $LastChangedDate: 2013-02-18 16:27:24 +0900 (Mon, 18 Feb 2013) $
* $LastChangedRevision: 4382 $
*********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org) * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/06/10 * CREATED: 2003/06/10
* SHORT DESCRIPTION: * SHORT DESCRIPTION:
@@ -24,11 +19,22 @@
DEFINE('DEFAULT_ENCODING', "UTF-8"); DEFINE('DEFAULT_ENCODING', "UTF-8");
/************* PATHS *********************/ /************* PATHS *********************/
// path to document root // ** NEW/BETTER DIR DECLARATIONS **
// path to original file (if symlink)
DEFINE('DIR', __DIR__."/");
// libs base path based on DIR
DEFINE('LIBDIR', DIR.'libs/');
// SMARTY path based on DIR
DEFINE('SMARTYDIR', DIR.'Smarty/');
// table arrays for Class Form
DEFINE('TABLEARRAYDIR', DIR.'table_arrays/');
// ** OLD DIR DECLARATIONS **
// path to document root of file called
DEFINE('ROOT', getcwd()."/"); DEFINE('ROOT', getcwd()."/");
// libs path // libs path
DEFINE('LIBS', "libs/"); DEFINE('LIBS', "libs/");
// includes (strings', arrays for stati, etc) // includes (strings, arrays for static, etc)
DEFINE('INCLUDES', "includes/"); DEFINE('INCLUDES', "includes/");
// layout base path // layout base path
DEFINE('LAYOUT', 'layout/'); DEFINE('LAYOUT', 'layout/');
@@ -79,7 +85,7 @@
/************* HASH / ACL DEFAULT / ERROR SETTINGS / SMARTY *************/ /************* HASH / ACL DEFAULT / ERROR SETTINGS / SMARTY *************/
// default hash type // default hash type
DEFINE('DEFAULT_HASH', 'ripemd160'); DEFINE('DEFAULT_HASH', 'sha256');
// default acl level // default acl level
DEFINE('DEFAULT_ACL_LEVEL', 80); DEFINE('DEFAULT_ACL_LEVEL', 80);
// default levels for certain actions // default levels for certain actions
@@ -91,7 +97,7 @@
DEFINE('DEFAULT_ACL_DEL', 80); DEFINE('DEFAULT_ACL_DEL', 80);
DEFINE('DEFAULT_ACL_ADMIN', 100); */ DEFINE('DEFAULT_ACL_ADMIN', 100); */
// SSL host name // SSL host name
// DEFINE('SSL_HOST', "www4.adidas.co.jp"); // DEFINE('SSL_HOST', "ssl.host.name");
// error page strictness, Default is 3 // error page strictness, Default is 3
// 1: only show error page as the last mesure if really no mid & aid can be loaded and found at all // 1: only show error page as the last mesure if really no mid & aid can be loaded and found at all
// 2: if template not found, do not search, show error template // 2: if template not found, do not search, show error template
@@ -129,6 +135,12 @@
// live_queue is a global queue system // live_queue is a global queue system
// DEFINE('QUEUE', 'live_queue'); // DEFINE('QUEUE', 'live_queue');
/************* DB PATHS (PostgreSQL) *****************/
// schema names, can also be defined per <DB INFO>
DEFINE('PUBLIC_SCHEMA', 'public');
DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public');
// non constant part // non constant part
/************* DB ACCESS *****************/ /************* DB ACCESS *****************/
// please be VERY carefull only to change the right side // please be VERY carefull only to change the right side
@@ -139,8 +151,9 @@
"db_pass" => "<DB PASSWORD>", "db_pass" => "<DB PASSWORD>",
"db_host" => "<DB HOST>", "db_host" => "<DB HOST>",
"db_port" => "5432", "db_port" => "5432",
"db_schema" => "<DB SCHEMA>", "db_schema" => "<DB SCHEMA>", // if not set, uses public
"db_type" => "pgsql", "db_type" => "pgsql",
"db_encoding" => '',
"db_ssl" => 'disable' // allow, disable, require, prefer "db_ssl" => 'disable' // allow, disable, require, prefer
) )
); );
@@ -160,15 +173,11 @@
// $DB_URL_REDIRECT_HOST['<HOST NAME>'] = "<DB ID>"; // $DB_URL_REDIRECT_HOST['<HOST NAME>'] = "<DB ID>";
// location flagging // location flagging
// test/dev/live // test/dev/live
$LOCATION['<HOST NAME>'] = 'test'; $LOCATION['<HOST NAME>'] = '<test|live|remote|etc>';
// show DEBUG override // show DEBUG override
// true/false // true/false
$DEBUG_FLAG['<HOST NAME>'] = true; $DEBUG_FLAG['<HOST NAME>'] = true;
// schema names, can also be defined per <DB INFO> // set postgresql paths (schemas)
DEFINE('PUBLIC_SCHEMA', 'public');
DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public');
// and set to domain
$DB_PATH['<HOST NAME>'] = PUBLIC_SCHEMA; $DB_PATH['<HOST NAME>'] = PUBLIC_SCHEMA;
// set the USE_DATABASE var, if there is nothing set, we assume TRUE // set the USE_DATABASE var, if there is nothing set, we assume TRUE
@@ -201,6 +210,7 @@
// DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']); // DEFINE('EXPORT_SCRIPT', $PATHS[TARGET]['perl_bin']);
// DEFINE('REDIRECT_URL', $PATHS[TARGET]['redirect_url']); // DEFINE('REDIRECT_URL', $PATHS[TARGET]['redirect_url']);
DEFINE('DEBUG', $DEBUG_FLAG[$HOST_NAME]); DEFINE('DEBUG', $DEBUG_FLAG[$HOST_NAME]);
DEFINE('SHOW_ALL_ERRORS', false); // show all errors if debug_all & show_error_handling are enabled
/************* GENERAL PAGE TITLE ********/ /************* GENERAL PAGE TITLE ********/
$G_TITLE = '<OVERALL PAGE TITLE>'; $G_TITLE = '<OVERALL PAGE TITLE>';
@@ -228,8 +238,43 @@
} }
} }
// turn off debug if debug flag is OFF
if (DEBUG == false)
{
$ECHO_ALL = 0;
$DEBUG_ALL = 0;
$PRINT_ALL = 0;
$DB_DEBUG = 0;
$ENABLE_ERROR_HANDLING = 0;
}
// any other global definitons here // any other global definitons here
// DEFINE('SOME_ID', <SOME VALUE>); // DEFINE('SOME_ID', <SOME VALUE>);
// $Id: config.template.inc 4382 2013-02-18 07:27:24Z gullevek $ // function that will be called on top of each class include to load the class
function _spl_autoload($include_file)
{
// where to search for the files to include
$dirs = array (
LIBDIR,
SMARTYDIR,
TABLEARRAYDIR,
'',
LIBS,
SMARTY,
TABLE_ARRAYS,
__DIR__.'/'.LIBS,
__DIR__.'/'.SMARTY
);
// try to find and load the class ifle
foreach ($dirs as $folder)
{
if (file_exists($folder.$include_file))
{
require_once($folder.$include_file);
return true;
}
}
return false;
}
?> ?>

View File

@@ -8,7 +8,6 @@
* with your name on it ... * with your name on it ...
* DESCRIPTION * DESCRIPTION
* Basic Admin interface backend * Basic Admin interface backend
* - sets ACLs
* - sets action flags * - sets action flags
* - menu creation * - menu creation
* - array vars for smarty * - array vars for smarty
@@ -45,11 +44,8 @@
public $action_loaded; public $action_loaded;
public $action_value; public $action_value;
public $action_error; public $action_error;
// DEPRICATED -> use login acl // ACL array variable if we want to set acl data from outisde
// public $page_acl; // the acl the user has on this page public $acl = array ();
// public $default_acl;
// DEPRICATED access rights
// public $access_rights = array ();
// the current active edit access id // the current active edit access id
public $edit_access_id; public $edit_access_id;
// error/warning/info messages // error/warning/info messages
@@ -370,7 +366,8 @@
$string = $this->l->__('Year').' '; $string = $this->l->__('Year').' ';
$string .= '<select id="year'.$suffix.'" name="year'.$suffix.'" onChange="'.$on_change_call.'">'; $string .= '<select id="year'.$suffix.'" name="year'.$suffix.'" onChange="'.$on_change_call.'">';
for ($i = date("Y"); $i <= $max_year; $i ++) for ($i = date("Y"); $i <= $max_year; $i ++)
{ $string .= '<option value="'.$i.'" '.(($year == $i) ? 'selected' : '').'>'.$i.'</option>'; {
$string .= '<option value="'.$i.'" '.(($year == $i) ? 'selected' : '').'>'.$i.'</option>';
} }
$string .= '</select> '.$this->l->__('Month').' '; $string .= '</select> '.$this->l->__('Month').' ';
$string .= '<select id="month'.$suffix.'" name="month'.$suffix.'" onChange="'.$on_change_call.'">'; $string .= '<select id="month'.$suffix.'" name="month'.$suffix.'" onChange="'.$on_change_call.'">';

View File

@@ -36,7 +36,7 @@
* PUBLIC METHODS * PUBLIC METHODS
* debug -> calls with "level", "string" and flag to turn off (0) the newline at the end * debug -> calls with "level", "string" and flag to turn off (0) the newline at the end
* debug_for -> sets debug on/off for a type (error, echo, print) for a certain level * debug_for -> sets debug on/off for a type (error, echo, print) for a certain level
* print_error_msg -> prints out the error message, optional parameter is a header prefix * print_error_msg -> prints out the error message, optional parameter is a header prefix
* fdebug -> prints line directly to debug_file.log in tmp * fdebug -> prints line directly to debug_file.log in tmp
* *
* print_time -> prints time + microtime, optional flag to turn off (0) microtime printout * print_time -> prints time + microtime, optional flag to turn off (0) microtime printout
@@ -247,23 +247,68 @@
); );
// the array with the mobile types that are valid // the array with the mobile types that are valid
$this->mobile_email_type = array ( $this->mobile_email_type = array (
'.*@docomo\.ne\.jp$' => 'docomo', '.*@docomo\.ne\.jp$' => 'keitai_docomo',
'.*@([a-z0-9]{2}\.)?ezweb\.ne\.jp$' => 'kddi_ezweb', # correct are a[2-4], b2, c[1-9], e[2-9], h[2-4], t[1-9] '.*@([a-z0-9]{2}\.)?ezweb\.ne\.jp$' => 'keitai_kddi_ezweb', # correct are a[2-4], b2, c[1-9], e[2-9], h[2-4], t[1-9]
'.*@(ez[a-j]{1}\.)?ido\.ne\.jp$' => 'kddi', # ez[a-j] or nothing '.*@(ez[a-j]{1}\.)?ido\.ne\.jp$' => 'keitai_kddi_ido', # ez[a-j] or nothing
'.*@([a-z]{2}\.)?sky\.tu-ka\.ne\.jp$' => 'kddi_tu-ka', # (sky group) '.*@([a-z]{2}\.)?sky\.tu-ka\.ne\.jp$' => 'keitai_kddi_tu-ka', # (sky group)
'.*@([a-z]{2}\.)?sky\.tk[kc]{1}\.ne\.jp$' => 'kddi_sky', # (sky group) [tkk,tkc only] '.*@([a-z]{2}\.)?sky\.tk[kc]{1}\.ne\.jp$' => 'keitai_kddi_sky', # (sky group) [tkk,tkc only]
'.*@([a-z]{2}\.)?sky\.dtg\.ne\.jp$' => 'kddi', # dtg (sky group) '.*@([a-z]{2}\.)?sky\.dtg\.ne\.jp$' => 'keitai_kddi_dtg', # dtg (sky group)
'.*@[tkdhcrnsq]{1}\.vodafone\.ne\.jp$' => 'softbank', # old vodafone [t,k,d,h,c,r,n,s,q] '.*@[tkdhcrnsq]{1}\.vodafone\.ne\.jp$' => 'keitai_softbank_vodafone', # old vodafone [t,k,d,h,c,r,n,s,q]
'.*@jp-[dhtkrsnqc]{1}\.ne\.jp$' => 'softbank', # very old j-phone (pre vodafone) [d,h,t,k,r,s,n,q,c] '.*@jp-[dhtkrsnqc]{1}\.ne\.jp$' => 'keitai_softbank_j-phone', # very old j-phone (pre vodafone) [d,h,t,k,r,s,n,q,c]
'.*@([dhtcrknsq]{1}\.)?softbank\.ne\.jp$' => 'softbank', # add i for iphone also as keitai, others similar to the vodafone group '.*@([dhtcrknsq]{1}\.)?softbank\.ne\.jp$' => 'keitai_softbank', # add i for iphone also as keitai, others similar to the vodafone group
'.*@i{1}\.softbank(\.ne)?\.jp$' => 'softbank_iphone', # add iPhone also as keitai and not as pc '.*@i{1}\.softbank(\.ne)?\.jp$' => 'smartphone_softbank_iphone', # add iPhone also as keitai and not as pc
'.*@disney\.ne\.jp$' => 'softbank_disney', # (kids) '.*@disney\.ne\.jp$' => 'keitai_softbank_disney', # (kids)
'.*@willcom\.ne\.jp$' => 'willcom', '.*@willcom\.ne\.jp$' => 'keitai_willcom',
'.*@willcom\.com$' => 'willcom', # new for pdx.ne.jp address '.*@willcom\.com$' => 'keitai_willcom', # new for pdx.ne.jp address
'.*@pdx\.ne\.jp$' => 'willcom', # old pdx address for willcom '.*@wcm\.ne\.jp$' => 'keitai_willcom', # old willcom wcm.ne.jp
'.*@bandai\.jp$' => 'willcom', # willcom paipo! (kids) '.*@pdx\.ne\.jp$' => 'keitai_willcom_pdx', # old pdx address for willcom
'.*@pipopa\.ne\.jp$' => 'willcom', # willcom paipo! (kids) '.*@bandai\.jp$' => 'keitai_willcom_bandai', # willcom paipo! (kids)
'.*@([a-z0-9]{2,4}\.)?pdx\.ne\.jp$' => 'willcom' # actually only di,dj,dk,wm -> all others are "wrong", but none also allowed? '.*@pipopa\.ne\.jp$' => 'keitai_willcom_pipopa', # willcom paipo! (kids)
'.*@([a-z0-9]{2,4}\.)?pdx\.ne\.jp$' => 'keitai_willcom_pdx', # actually only di,dj,dk,wm -> all others are "wrong", but none also allowed?
'.*@ymobile([1]{1})?\.ne\.jp$' => 'keitai_willcom_ymobile', # ymobile, ymobile1 techincally not willcom, but I group them there
'.*@y-mobile\.ne\.jp$' => 'keitai_willcom_ymobile', # y-mobile techincally not willcom, but I group them there
'.*@emnet\.ne\.jp$' => 'keitai_willcom_emnet', # e-mobile, group will willcom
'.*@emobile\.ne\.jp$' => 'keitai_willcom_emnet', # e-mobile, group will willcom
'.*@emobile-s\.ne\.jp$' => 'keitai_willcom_emnet' # e-mobile, group will willcom
);
// short list for mobile email types
$this->mobile_email_type_short = array (
'keitai_docomo' => 'docomo',
'keitai_kddi_ezweb' => 'kddi',
'keitai_kddi' => 'kddi',
'keitai_kddi_tu-ka' => 'kddi',
'keitai_kddi_sky' => 'kddi',
'keitai_softbank' => 'softbank',
'smartphone_softbank_iphone' => 'iphone',
'keitai_softbank_disney' => 'softbank',
'keitai_softbank_vodafone' => 'softbank',
'keitai_softbank_j-phone' => 'softbank',
'keitai_willcom' => 'willcom',
'keitai_willcom_pdx' => 'willcom',
'keitai_willcom_bandai' => 'willcom',
'keitai_willcom_pipopa' => 'willcom',
'keitai_willcom_ymobile' => 'willcom',
'keitai_willcom_emnet' => 'willcom',
'pc_html' => 'pc',
// old sets -> to be removed later
'docomo' => 'docomo',
'kddi_ezweb' => 'kddi',
'kddi' => 'kddi',
'kddi_tu-ka' => 'kddi',
'kddi_sky' => 'kddi',
'softbank' => 'softbank',
'keitai_softbank_iphone' => 'iphone',
'softbank_iphone' => 'iphone',
'softbank_disney' => 'softbank',
'softbank_vodafone' => 'softbank',
'softbank_j-phone' => 'softbank',
'willcom' => 'willcom',
'willcom_pdx' => 'willcom',
'willcom_bandai' => 'willcom',
'willcom_pipopa' => 'willcom',
'willcom_ymobile' => 'willcom',
'willcom_emnet' => 'willcom',
'pc' => 'pc'
); );
// initial the session if there is no session running already // initial the session if there is no session running already
@@ -485,8 +530,8 @@
$traces = debug_backtrace(); $traces = debug_backtrace();
// extended info (later) // extended info (later)
/* /*
* $file = $trace[$level]['file']; * $file = $trace[$level]['file'];
* $line = $trace[$level]['line']; * $line = $trace[$level]['line'];
* $object = $trace[$level]['object']; * $object = $trace[$level]['object'];
* if (is_object($object)) { $object = get_class($object); } * if (is_object($object)) { $object = get_class($object); }
* *
@@ -638,7 +683,7 @@
4096 => 'E_RECOVERABLE_ERROR', // since 5.2 4096 => 'E_RECOVERABLE_ERROR', // since 5.2
8192 => 'E_DEPRICATED', // since 5.3 8192 => 'E_DEPRICATED', // since 5.3
16384 => 'E_USER_DEPRICATED', // since 5.3 16384 => 'E_USER_DEPRICATED', // since 5.3
30719 => 'E_ALL' // 6143 in 5.2, 2047 in previous versions 30719 => 'E_ALL' // 6143 in 5.2, 2047 in previous versions
); );
$fn = ROOT.LOG.'php_errors-'.date('Y-m-d').'.log'; $fn = ROOT.LOG.'php_errors-'.date('Y-m-d').'.log';
@@ -768,7 +813,7 @@
if (preg_match("/\/\/$/", $_1) && preg_match("/^\//", $_2)) if (preg_match("/\/\/$/", $_1) && preg_match("/^\//", $_2))
{ {
$_1 = ''; $_1 = '';
$target = ''; $target = '';
} }
else else
{ {
@@ -898,7 +943,7 @@
// haystack (search in) // haystack (search in)
// key: the key to look for in // key: the key to look for in
// path: recursive call for previous path // path: recursive call for previous path
// RETURN all array elements paths where the element was found // RETURN all array elements paths where the element was found
// DESCRIPTION // DESCRIPTION
// recursive array search function, which returns all found not only the first one // recursive array search function, which returns all found not only the first one
public static function array_search_recursive_all($needle, $haystack, $key, $path = NULL) public static function array_search_recursive_all($needle, $haystack, $key, $path = NULL)
@@ -1004,17 +1049,17 @@
} }
// METHOD: ByteStringFormat // METHOD: ByteStringFormat
// PARAMS: int // PARAMS: int bytes, boolean for space, default is set
// RETURN: string // RETURN: string
// DESC: converts bytes into formated string with KB, MB, etc // DESC: converts bytes into formated string with KB, MB, etc
public static function ByteStringFormat($number) public static function ByteStringFormat($number, $space = true)
{ {
if (is_numeric($number) && $number > 0) if (is_numeric($number) && $number > 0)
{ {
// labels in order of size // labels in order of size
$labels = array('B', 'KB', 'MB', 'GB', 'TB'); $labels = array('B', 'KB', 'MB', 'GB', 'TB');
// calc file size, round down too two digits, add label based max change // calc file size, round down too two digits, add label based max change
return round($number / pow(1024, ($i = floor(log($number, 1024)))), 2).''.$labels[$i]; return round($number / pow(1024, ($i = floor(log($number, 1024)))), 2).($space ? ' ' : '').$labels[$i];
} }
return $number; return $number;
} }
@@ -1036,6 +1081,20 @@
return $number; return $number;
} }
// METHOD: DateStringFormat
// PARAMS: unix timestamp, true/false to show microtime
// RETURN: string formated date+time in Y-M-D h:m:s
// DESC : a simple wrapper for the date format
public static function DateStringFormat($timestamp, $show_micro = true)
{
list ($timestamp, $ms) = explode('.', round($timestamp, 4));
if ($show_micro)
$string = date("Y-m-d H:i:s", $timestamp).' '.$ms.'ms';
else
$string = date("Y-m-d H:i:s", $timestamp);
return $string;
}
// METHOD: TimeStringFormat // METHOD: TimeStringFormat
// PARAMS: seconds // PARAMS: seconds
// RETURN: formated time string // RETURN: formated time string
@@ -1397,6 +1456,19 @@
return $this->_crc32b($string); return $this->_crc32b($string);
} }
// METHOD: _hash
// PARAMS: string, type of hash to use
// RETURN: hashed string
// DESC : replacemend for _crc32b call (alternate)
// defaults to adler 32, fnv132, fnv1a32, joaat
// all that create 8 char long hashes
public function _hash($string, $hash_type = 'adler32')
{
if (!in_array($hash_type, array('adler32', 'fnv132', 'fnv1a32', 'joaat')))
$hash_type = 'adler32';
return hash($hash_type, $string);
}
// METHOD: checkPHPVersion // METHOD: checkPHPVersion
// PARAMS: $min_version: minimum version. in format x, x.y or x.y.z // PARAMS: $min_version: minimum version. in format x, x.y or x.y.z
// $max_version: default empty, else in same format as min version // $max_version: default empty, else in same format as min version
@@ -1792,10 +1864,11 @@
} }
// METHOD: getEmailType // METHOD: getEmailType
// PARAMS: email // PARAMS: email, short == false
// RETURN: string for email type, eg "pc", "docomo", etc // RETURN: string for email type, eg "pc", "docomo", etc
// DESC: guesses the email type (mostly for mobile) from the domain // DESC: guesses the email type (mostly for mobile) from the domain
public function getEmailType($email) // if second is set to true, it will return short naming scheme (only provider)
public function getEmailType($email, $short = false)
{ {
// trip if there is no email address // trip if there is no email address
if (!$email) if (!$email)
@@ -1804,10 +1877,27 @@
foreach ($this->mobile_email_type as $email_regex => $email_type) foreach ($this->mobile_email_type as $email_regex => $email_type)
{ {
if (preg_match("/$email_regex/", $email)) if (preg_match("/$email_regex/", $email))
return $email_type; {
if ($short)
return $this->getShortEmailType($email_type);
else
return $email_type;
}
} }
// if no previous return we assume this is a pc address // if no previous return we assume this is a pc address
return "pc"; if ($short)
return "pc";
else
return "pc_html";
}
// METHOD: getShortEmailType
// PARAMS: long email type (not email)
// RETURN: short email type
// DESC : gets the short email type from a long email type
public function getShortEmailType($email_type)
{
return $this->mobile_email_type_short[$email_type];
} }
// METHOD: printDateTime // METHOD: printDateTime

View File

@@ -429,6 +429,13 @@ $this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."]
$_value = $this->table_array[$column]["value"]; $_value = $this->table_array[$column]["value"];
$q_data .= $_value; $q_data .= $_value;
} }
elseif ($this->table_array[$column]["interval"])
{
// for interval we check if no value, then we set null
if (!$this->table_array[$column]["value"])
$_value = 'NULL';
$q_data .= $_value;
}
else else
// normal string // normal string
{ {
@@ -437,7 +444,7 @@ $this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."]
if ($addslashes) if ($addslashes)
$q_data .= $this->db_escape_string($this->convert_entities($this->table_array[$column]["value"])); $q_data .= $this->db_escape_string($this->convert_entities($this->table_array[$column]["value"]));
else else
$q_data .= addslashes($this->table_array[$column]["value"]); $q_data .= $this->db_escape_string($this->table_array[$column]["value"]);
$q_data .= "'"; $q_data .= "'";
} }
} }
@@ -484,7 +491,7 @@ $this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."]
{ {
$q = "INSERT INTO ".$this->table_name." "; $q = "INSERT INTO ".$this->table_name." ";
$q .= "(".$q_vars.") "; $q .= "(".$q_vars.") ";
$q .= "VALUES (".$q_data.")"; $q .= "VALUES (".$q_data.")";
// write primary key too // write primary key too
/* if ($q_data) /* if ($q_data)
$q .= ", "; $q .= ", ";
@@ -500,7 +507,10 @@ $this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."]
} }
// set primary key // set primary key
if ($insert) if ($insert)
$this->ok = $this->table_array[$this->pk_name]["value"] = $this->insert_id; {
$this->table_array[$this->pk_name]["value"] = $this->insert_id;
$this->ok = $this->insert_id;
}
// return the table if needed // return the table if needed
return $this->table_array; return $this->table_array;
} }

View File

@@ -253,7 +253,7 @@
// only inside // only inside
// basic vars // basic vars
private $dbh; // the dbh handler private $dbh; // the dbh handler
private $db_debug; // DB_DEBUG ... (if set prints out debug msgs) public $db_debug; // DB_DEBUG ... (if set prints out debug msgs)
private $db_name; // the DB connected to private $db_name; // the DB connected to
private $db_user; // the username used private $db_user; // the username used
private $db_pwd; // the password used private $db_pwd; // the password used
@@ -523,7 +523,8 @@
// msg -> optional message // msg -> optional message
// RETURN none // RETURN none
// DESC if error_id set, writes long error string into error_msg // DESC if error_id set, writes long error string into error_msg
private function _db_error($cursor = '', $msg = '') // MARK: needed to make public so it can be called from DB.Array.IO too
public function _db_error($cursor = '', $msg = '')
{ {
$where_called = $this->get_caller_method(); $where_called = $this->get_caller_method();
if ($cursor) if ($cursor)

View File

@@ -886,8 +886,7 @@
{ {
// each error check can be a piped seperated value, lets split it // each error check can be a piped seperated value, lets split it
//$this->debug('edit', $value["error_check"]); //$this->debug('edit', $value["error_check"]);
$error_checks = explode("|", $value["error_check"]); foreach (explode('|', $value["error_check"]) as $error_check)
foreach ($error_checks as $error_check)
{ {
switch ($error_check) switch ($error_check)
{ {
@@ -914,7 +913,7 @@
break; break;
// check unique, check if field in table is not yet exist // check unique, check if field in table is not yet exist
case "unique": case "unique":
$q = "SELECT ".$key." FROM ".$this->table_name." WHERE ".$key." = '".addslashes($this->table_array[$key]["value"])."'"; $q = "SELECT ".$key." FROM ".$this->table_name." WHERE ".$key." = '".$this->db_escape_string($this->table_array[$key]["value"])."'";
if ($this->table_array[$this->int_pk_name]["value"]) if ($this->table_array[$this->int_pk_name]["value"])
$q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"]; $q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"];
list($$key) = $this->db_return_row($q); list($$key) = $this->db_return_row($q);
@@ -925,15 +924,20 @@
if (!preg_match($this->table_array[$key]["error_regex"], $this->table_array[$key]["value"])) if (!preg_match($this->table_array[$key]["error_regex"], $this->table_array[$key]["value"]))
$this->msg .= sprintf($this->l->__("Please enter a valid (%s) input for the <b>%s</b> Field!<br>"), $this->table_array[$key]["error_example"], $this->table_array[$key]["output_name"]); $this->msg .= sprintf($this->l->__("Please enter a valid (%s) input for the <b>%s</b> Field!<br>"), $this->table_array[$key]["error_example"], $this->table_array[$key]["output_name"]);
break; break;
case "alphanumericspace":
//$this->debug('edit', 'IN Alphanumericspace');
if (!preg_match("/^[0-9A-Za-z\ ]+$/", $this->table_array[$key]["value"]))
$this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric (Numbers and Letters, spaces allowed) value for the <b>%s</b> Field!<br>"), $this->table_array[$key]["output_name"]);
break;
case "alphanumeric": case "alphanumeric":
//$this->debug('edit', 'IN Alphanumeric'); //$this->debug('edit', 'IN Alphanumeric');
if (!preg_match("/^[0-9A-Za-z_-]+$/", $this->table_array[$key]["value"])) if (!preg_match("/^[0-9A-Za-z_\-]+$/", $this->table_array[$key]["value"]))
$this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric (Numbers and Letters only also - and _, no spaces) value for the <b>%s</b> Field!<br>"), $this->table_array[$key]["output_name"]); $this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric (Numbers and Letters only also - and _, no spaces) value for the <b>%s</b> Field!<br>"), $this->table_array[$key]["output_name"]);
break; break;
// this one also allows @ and . // this one also allows @ and .
case "alphanumericextended": case "alphanumericextended":
//$this->debug('edit', 'IN Alphanumeric'); //$this->debug('edit', 'IN Alphanumericextended');
if (!preg_match("/^[0-9A-Za-z_-@\.]+$/", $this->table_array[$key]["value"])) if (!preg_match("/^[0-9A-Za-z_\-@\.]+$/", $this->table_array[$key]["value"]))
$this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric extended (Numbers, Letters, -, _, @ and . only, no spaces) value for the <b>%s</b> Field!<br>"), $this->table_array[$key]["output_name"]); $this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric extended (Numbers, Letters, -, _, @ and . only, no spaces) value for the <b>%s</b> Field!<br>"), $this->table_array[$key]["output_name"]);
break; break;
case "password": case "password":
@@ -950,13 +954,13 @@
// if mandatory && no input // if mandatory && no input
else if ($value["mandatory"] && else if ($value["mandatory"] &&
( (
// for all "normal" fields // for all "normal" fields
($this->table_array[$key]["type"] != "password" && $this->table_array[$key]["type"] != "drop_down_db_input" && !$this->table_array[$key]["value"]) || ($this->table_array[$key]["type"] != "password" && $this->table_array[$key]["type"] != "drop_down_db_input" && !$this->table_array[$key]["value"]) ||
// for drop_down_db_input check if one of both fields filled // for drop_down_db_input check if one of both fields filled
($this->table_array[$key]["type"] == "drop_down_db_input" && !$this->table_array[$key]["input_value"] && !$this->table_array[$key]["value"]) || ($this->table_array[$key]["type"] == "drop_down_db_input" && !$this->table_array[$key]["input_value"] && !$this->table_array[$key]["value"]) ||
// for password // for password
($this->table_array[$key]["type"] == "password" && !$this->table_array[$key]["value"] && !$this->table_array[$key]["HIDDEN_value"]) ($this->table_array[$key]["type"] == "password" && !$this->table_array[$key]["value"] && !$this->table_array[$key]["HIDDEN_value"])
) )
) // main if end ) // main if end
{ {
//$this->debug('form', "A: ".$this->table_array[$key]["type"]." -- ".$this->table_array[$key]["input_value"]." -- ".$this->table_array[$key]["value"]); //$this->debug('form', "A: ".$this->table_array[$key]["type"]." -- ".$this->table_array[$key]["input_value"]." -- ".$this->table_array[$key]["value"]);
@@ -992,12 +996,20 @@
} }
} }
//$this->debug('edit_error', "QS: <pre>".print_r($_POST, 1)."</pre>"); //$this->debug('edit_error', "QS: <pre>".print_r($_POST, 1)."</pre>");
if (is_array($this->element_list)) if (is_array($this->element_list))
{ {
// check the mandatory stuff // check the mandatory stuff
// if mandatory, check that at least on pk exists or if at least the mandatory field is filled // if mandatory, check that at least on pk exists or if at least the mandatory field is filled
while (list($table_name, $reference_array) = each($this->element_list)) while (list($table_name, $reference_array) = each($this->element_list))
{ {
// set pk/fk id for this
foreach ($reference_array['elements'] as $_name => $_data)
{
if ($_data['pk_id'])
$_pk_name = $_name;
if ($_data['fk_id'])
$_fk_name = $_name;
}
// get the leasy of keys from the elements array // get the leasy of keys from the elements array
$keys = array_keys($reference_array["elements"]); $keys = array_keys($reference_array["elements"]);
// prefix // prefix
@@ -1025,10 +1037,8 @@
{ {
$mand_okay = 1; $mand_okay = 1;
} }
// we found a mandatory field. check now if one is set to satisfy the main mandatory // we found a mandatory field. check now if one is set to satisfy the main mandatory
// also check, if this field is mandatory and its not set, but any other, throw an error // also check, if this field is mandatory and its not set, but any other, throw an error
// for ($i = 0; $i < count($_POST[$prfx.$el_name]); $i ++)
// {
//$this->debug('edit_error_chk', "RG error - Data[".$prfx.$el_name.": ".$_POST[$prfx.$el_name][$i]." | ".$_POST[$prfx.$el_name]." - ".$reference_array['enable_name']." - ".$_POST[$reference_array['enable_name']][$_POST[$prfx.$el_name][$i]]); //$this->debug('edit_error_chk', "RG error - Data[".$prfx.$el_name.": ".$_POST[$prfx.$el_name][$i]." | ".$_POST[$prfx.$el_name]." - ".$reference_array['enable_name']." - ".$_POST[$reference_array['enable_name']][$_POST[$prfx.$el_name][$i]]);
if ($data_array["mandatory"] && $_POST[$prfx.$el_name][$i]) if ($data_array["mandatory"] && $_POST[$prfx.$el_name][$i])
{ {
@@ -1053,9 +1063,30 @@
{ {
$row_okay[$i] = 0; $row_okay[$i] = 0;
} }
// do optional error checks like for normal fields
// } // currently active: unique/alphanumeric
if ($data_rray['error_check'])
{
foreach (explode('|', $value["error_check"]) as $error_check)
{
switch ($error_check)
{
// check unique, check if field in table is not yet exist
case "unique":
$q = "SELECT ".$_pk_name." FROM ".$table_name." WHERE ".$el_name." = '".$this->db_escape_string($_POST[$prfx.$el_name][$i])."'";
if ($this->table_array[$this->int_pk_name]["value"])
$q .= " AND ".$this->int_pk_name." <> ".$this->table_array[$this->int_pk_name]["value"];
list($$key) = $this->db_return_row($q);
if ($$key)
$this->msg .= sprintf($this->l->__("The field <b>%s</b> in row <b>%s</b> can be used only once!<br>"), $reference_array["output_name"], $i);
break;
case "alphanumericspace":
if (!preg_match("/^[0-9A-Za-z\ ]+$/", $_POST[$prfx.$el_name][$i]))
$this->msg .= sprintf($this->l->__("Please enter a valid alphanumeric (Numbers and Letters, spaces allowed) value for the <b>%s</b> Field and row <b>%s</b>!<br>"), $reference_array["output_name"], $i);
break;
}
}
}
} // if main mandatory } // if main mandatory
} }
@@ -1198,7 +1229,7 @@
{ {
//$this->debug('form', "HERE"); //$this->debug('form', "HERE");
// check if this text name already exists (lowercase compare) // check if this text name already exists (lowercase compare)
$q = "SELECT ".$this->table_array[$key]["pk_name"]." FROM ".$this->table_array[$key]["table_name"]." WHERE LCASE(".$this->table_array[$key]["input_name"].") = '".addslashes(strtolower($this->table_array[$key]["input_value"]))."'"; $q = "SELECT ".$this->table_array[$key]["pk_name"]." FROM ".$this->table_array[$key]["table_name"]." WHERE LCASE(".$this->table_array[$key]["input_name"].") = '".$this->db_escape_string(strtolower($this->table_array[$key]["input_value"]))."'";
// if a where was given, add here // if a where was given, add here
if ($this->table_array[$key]["where"]) if ($this->table_array[$key]["where"])
$q .= " AND ".$this->table_array[$key]["where"]; $q .= " AND ".$this->table_array[$key]["where"];
@@ -1211,8 +1242,8 @@
{ {
// if a where was given, set this key also [dangerous!] // if a where was given, set this key also [dangerous!]
// posgres compatible insert // postgreSQL compatible insert
$q = "INSERT INTO ".$this->table_array[$key]["table_name"]." (".$this->table_array[$key]["input_name"].") VALUES ('".addslashes($this->table_array[$key]["input_value"])."')"; $q = "INSERT INTO ".$this->table_array[$key]["table_name"]." (".$this->table_array[$key]["input_name"].") VALUES ('".$this->db_escape_string($this->table_array[$key]["input_value"])."')";
$this->db_exec($q); $this->db_exec($q);
if ($this->table_array[$key]["where"]) if ($this->table_array[$key]["where"])
{ {
@@ -1233,7 +1264,7 @@
if ($this->table_array[$key]["input_value"] != $this->table_array[$key]["value"]) if ($this->table_array[$key]["input_value"] != $this->table_array[$key]["value"])
{ {
// check if "right input" is in DB // check if "right input" is in DB
$q = "SELECT ".$this->table_array[$key]["input_name"]." FROM ".$this->table_array[$key]["table_name"]." WHERE LCASE(".$this->table_array[$key]["input_name"].") = '".strtolower(addslashes($this->table_array[$key]["input_value"]))."'"; $q = "SELECT ".$this->table_array[$key]["input_name"]." FROM ".$this->table_array[$key]["table_name"]." WHERE LCASE(".$this->table_array[$key]["input_name"].") = '".strtolower($this->db_escape_string($this->table_array[$key]["input_value"]))."'";
// if a where was given, add here // if a where was given, add here
if ($this->table_array[$key]["where"]) if ($this->table_array[$key]["where"])
$q .= " AND ".$this->table_array[$key]["where"]; $q .= " AND ".$this->table_array[$key]["where"];
@@ -1352,6 +1383,8 @@
// check if there is a hidden key, update, else insert // check if there is a hidden key, update, else insert
while (list($el_name, $data_array) = each($reference_array["elements"])) while (list($el_name, $data_array) = each($reference_array["elements"]))
{ {
// this is only for reference_data part, at least one of the text fields need to be set for writing
$blow_write = array ();
//$this->debug('edit_error_query', "QUERY: ".$this->print_ar($_POST)); //$this->debug('edit_error_query', "QUERY: ".$this->print_ar($_POST));
// go through all submitted data // go through all submitted data
// for ($i = 0; $i < count($_POST[$el_name]); $i ++) // for ($i = 0; $i < count($_POST[$el_name]); $i ++)
@@ -1367,6 +1400,16 @@
{ {
$no_write[$i] = 1; $no_write[$i] = 1;
} }
// flag if data is in the text field and we are in a reference data set
if ($reference_array['type'] == 'reference_data' )
{
if ($data_array['type'] == 'text' && $_POST[$prfx.$el_name][$i])
$block_write[$i] = 1;
}
else
{
$block_write[$i] = 1;
}
// set type and boundaries for insert/update // set type and boundaries for insert/update
if ($data_array["pk_id"] && $_POST[$prfx.$el_name][$i]) if ($data_array["pk_id"] && $_POST[$prfx.$el_name][$i])
{ {
@@ -1383,19 +1426,24 @@
} }
// write all data (insert/update) because I don't know until all are processed if it is insert or update // write all data (insert/update) because I don't know until all are processed if it is insert or update
// don't write primary key backup for update // don't write primary key backup for update
$this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prfx.$el_name][$i]." {".$_POST[$prfx.$el_name]."} | Type: ".$type[$i]." | PK: ".$data_array["pk_id"]." "); // for reference_data type, only write if at least one text type field is set
if (!$data_array["pk_id"]) //$this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prfx.$el_name][$i]." | Type: ".$type[$i]." | PK: ".$data_array["pk_id"].", Block write: ".$block_write[$i]);
// only add elements that are not PK or FK flaged
if (!$data_array['pk_id'] && !$data_array['fk_id'])
{ {
// update // update data list
if (strlen($q_data[$i])) if (strlen($q_data[$i]))
$q_data[$i] .= ", "; $q_data[$i] .= ", ";
// insert // insert name part list
if ($q_names[$i]) if ($q_names[$i])
$q_names[$i] .= ", "; $q_names[$i] .= ", ";
$q_names[$i] .= $el_name; // insert value part list
if (strlen($q_values[$i])) if (strlen($q_values[$i]))
$q_values[$i] .= ", "; $q_values[$i] .= ", ";
// data part // insert column name add
$q_names[$i] .= $el_name;
// data part, read from where [POST]
// radio group selections (only one can be active)
if ($data_array['type'] == 'radio_group') if ($data_array['type'] == 'radio_group')
{ {
if ($i == $_POST[$prfx.$el_name]) if ($i == $_POST[$prfx.$el_name])
@@ -1407,10 +1455,11 @@ $this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prf
{ {
$_value = $_POST[$prfx.$el_name][$i]; $_value = $_POST[$prfx.$el_name][$i];
} }
// pre write data set. if int value, unset flagged need to be set null or 0 depending on settings
if ($data_array['int'] || $data_array['int_null']) if ($data_array['int'] || $data_array['int_null'])
{ {
if (!$_value && $data_array['int_null']) if (!$_value && $data_array['int_null'])
$value = 'NULL'; $_value = 'NULL';
elseif (!isset($_value)) elseif (!isset($_value))
$_value = 0; $_value = 0;
$q_data[$i] .= $el_name." = ".$_value; $q_data[$i] .= $el_name." = ".$_value;
@@ -1418,27 +1467,31 @@ $this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prf
} }
else else
{ {
$q_data[$i] .= $el_name." = '".addslashes($_value)."'"; // normal data gets escaped
$q_values[$i] .= "'".addslashes($_value)."'"; $q_data[$i] .= $el_name." = '".$this->db_escape_string($_value)."'";
$q_values[$i] .= "'".$this->db_escape_string($_value)."'";
} }
} }
} }
} // eche table elements } // eche table elements
// finalize the queries, add FK key reference for inserts and run the query
for ($i = 0; $i < count($type); $i ++) for ($i = 0; $i < count($type); $i ++)
{ {
$q = '';
if (!$no_write[$i]) if (!$no_write[$i])
{ {
if ($type[$i] == "update") if ($type[$i] == "update")
{ {
$q = $q_begin[$i].$q_data[$i].$q_end[$i]; $q = $q_begin[$i].$q_data[$i].$q_end[$i];
} }
else elseif ($block_write[$i])
{ {
$q = $q_begin[$i].$q_names[$i].", ".$this->int_pk_name.$q_middle[$i].$q_values[$i].", ".$this->table_array[$this->int_pk_name]["value"].$q_end[$i]; $q = $q_begin[$i].$q_names[$i].", ".$this->int_pk_name.$q_middle[$i].$q_values[$i].", ".$this->table_array[$this->int_pk_name]["value"].$q_end[$i];
} }
//$this->debug('edit', "Q: ".$q."<br>"); $this->debug('edit', "Pos[$i] => ".$type[$i]." Q: ".$q."<br>");
// write the dataset // write the dataset
$this->db_exec($q); if ($q)
$this->db_exec($q);
} }
} // for each created query } // for each created query
} // each element list } // each element list
@@ -1544,42 +1597,52 @@ $this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prf
// PARAMS show which element list // PARAMS show which element list
// RETURN array for output // RETURN array for output
// DESC create list of elements next to each other for a group of data in an input field // DESC create list of elements next to each other for a group of data in an input field
// this currently only works for a list that is filled from a sub table and creates only a connection to this one
// new version will allow a sub list with free input fields to directly fill a sub table to a master table
public function form_create_element_list_table($table_name) public function form_create_element_list_table($table_name)
{ {
// output name for the viewable left table td box, prefixed with * if mandatory
$output_name = $this->element_list[$table_name]["output_name"]; $output_name = $this->element_list[$table_name]["output_name"];
if ($this->element_list[$table_name]["mandatory"]) if ($this->element_list[$table_name]["mandatory"])
$output_name .= ' *'; $output_name .= ' *';
// delete button name, if there is one set // delete button name, if there is one set
if ($this->element_list[$table_name]["delete_name"]) if ($this->element_list[$table_name]["delete_name"])
$data['delete_name'] = $this->element_list[$table_name]["delete_name"]; $data['delete_name'] = $this->element_list[$table_name]["delete_name"];
// set the enable checkbox name if there is one // set the enable checkbox for delete, if the delete flag is given if there is one
if ($this->element_list[$table_name]["enable_name"]) if ($this->element_list[$table_name]["enable_name"])
{ {
$data['enable_name'] = $this->element_list[$table_name]["enable_name"]; $data['enable_name'] = $this->element_list[$table_name]["enable_name"];
if ($this->element_list[$table_name]["delete"]) if ($this->element_list[$table_name]["delete"])
$data['delete'] = 1; $data['delete'] = 1;
} }
// prefix for the elements, to not collide with names in the master set
if ($this->element_list[$table_name]["prefix"]) if ($this->element_list[$table_name]["prefix"])
$data["prefix"] = $this->element_list[$table_name]["prefix"]."_"; $data["prefix"] = $this->element_list[$table_name]["prefix"]."_";
// the sub data table name
$data['table_name'] = $table_name; $data['table_name'] = $table_name;
$pos = 0; // position in while for overwrite if needed
// build the select part // build the select part
if (!is_array($this->element_list[$table_name]["elements"])) if (!is_array($this->element_list[$table_name]["elements"]))
$this->element_list[$table_name]["elements"] = array (); $this->element_list[$table_name]["elements"] = array ();
reset($this->element_list[$table_name]["elements"]); reset($this->element_list[$table_name]["elements"]);
// generic data read in (counts for all rows) // generic data read in (counts for all rows)
// visible list data output
while (list($el_name, $data_array) = each($this->element_list[$table_name]["elements"])) while (list($el_name, $data_array) = each($this->element_list[$table_name]["elements"]))
{ {
$_el_name = $el_name; // $this->debug('CFG', 'El: '.$el_name.' -> '.$this->print_ar($data_array));
$el_name = $data["prefix"].$el_name;
// if the element name matches the read array, then set the table as a name prefix // if the element name matches the read array, then set the table as a name prefix
$q_select[] = $_el_name; // this is for reading the data $q_select[] = $el_name; // this is for reading the data
// prefix the name for any further data parts
$el_name = $data["prefix"].$el_name;
$data['output_name'][$el_name] = $data_array["output_name"]; // this are the output names (if given) $data['output_name'][$el_name] = $data_array["output_name"]; // this are the output names (if given)
$data['type'][$el_name] = $data_array["type"]; /// this is the type of the field $data['type'][$el_name] = $data_array["type"]; /// this is the type of the field
// set the primary key name // set the primary key name
if ($data_array['pk_id']) if ($data_array['pk_id'])
$data['pk_name'] = $el_name; $data['pk_name'] = $el_name;
// if drop down db read data for element list if ($data_array['fk_id'])
$data['fk_name'] = $el_name;
// if drop down db read data for element list from the given sub table as from the query
// only two elements are allowed: pos 0 is key, pso 1 is visible output name
if ($data_array['type'] == 'drop_down_db') if ($data_array['type'] == 'drop_down_db')
{ {
$md_q = md5($data_array['query']); $md_q = md5($data_array['query']);
@@ -1594,57 +1657,80 @@ $this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prf
$data['output_data'][$el_name][] = $res[1]; $data['output_data'][$el_name][] = $res[1];
} }
} }
else elseif ($data_array["element_list"])
{ {
$data['element_list'][$el_name] = $data_array["element_list"]; // this is for the checkboxes $data['element_list'][$el_name] = $data_array["element_list"]; // this is for the checkboxes
} }
$proto[$el_name] = ($this->error) ? $_POST[$el_name][(count($_POST[$el_name]) - 1)] : ''; // this is for the new line $proto[$el_name] = ($this->error) ? $_POST[$el_name][(count($_POST[$el_name]) - 1)] : ''; // this is for the new line
} }
// $this->debug('CFG DATA', 'Data: '.$this->print_ar($data));
// $this->debug('CFG PROTO', 'Proto: '.$this->print_ar($proto));
// $this->debug('CFG SELECT', 'Proto: '.$this->print_ar($q_select));
// query for reading in the data // query for reading in the data
//$this->debug('edit_error', "ERR: ".$this->error); //$this->debug('edit_error', "ERR: ".$this->error);
// if we got a read data, build the read select for the read, and read out the "selected" data // if we got a read data, build the read select for the read, and read out the "selected" data
if ($this->element_list[$table_name]["read_data"]) if ($this->element_list[$table_name]["read_data"])
{ {
array_unshift($q_select, $this->element_list[$table_name]["read_data"]["name"]); // we need a second one for the query build only
// prefix all elements with the $table name
foreach ($q_select as $_pos => $element)
{
$_q_select[$_pos] = $table_name.'.'.$element;
}
// add the read names in here, prefix them with the table name
// earch to read part is split by |
if ($this->element_list[$table_name]["read_data"]["name"])
{
foreach (explode('|', $this->element_list[$table_name]["read_data"]["name"]) as $read_name)
{
array_unshift($_q_select, $this->element_list[$table_name]["read_data"]["table_name"].'.'.$read_name);
array_unshift($q_select, $read_name);
}
}
// set the rest of the data so we can print something out // set the rest of the data so we can print something out
$data['type'][$data["prefix"].$this->element_list[$table_name]["read_data"]["name"]] = 'string'; $data['type'][$data["prefix"].$this->element_list[$table_name]["read_data"]["name"]] = 'string';
// build the read query // build the read query
$q = "SELECT "; $q = "SELECT ";
// if (!$this->table_array[$this->int_pk_name]["value"]) // if (!$this->table_array[$this->int_pk_name]["value"])
// $q .= "DISTINCT "; // $q .= "DISTINCT ";
// prefix join key with table name // prefix join key with table name, and implode the query select part
$q .= str_replace($this->element_list[$table_name]["read_data"]["pk_id"], $this->element_list[$table_name]["read_data"]["table_name"].".".$this->element_list[$table_name]["read_data"]["pk_id"], implode(", ", $q_select))." "; $q .= str_replace($table_name.'.'.$this->element_list[$table_name]["read_data"]["pk_id"], $this->element_list[$table_name]["read_data"]["table_name"].'.'.$this->element_list[$table_name]["read_data"]["pk_id"], implode(', ', $_q_select)).' ';
// if (!$this->table_array[$this->int_pk_name]["value"] && $this->element_list[$table_name]["read_data"]["order"]) // if (!$this->table_array[$this->int_pk_name]["value"] && $this->element_list[$table_name]["read_data"]["order"])
// $q .= ", ".$this->element_list[$table_name]["read_data"]["order"]." "; // $q .= ", ".$this->element_list[$table_name]["read_data"]["order"]." ";
// read from the read table as main, and left join to the sub table to read the actual data
$q .= "FROM ".$this->element_list[$table_name]["read_data"]["table_name"]." "; $q .= "FROM ".$this->element_list[$table_name]["read_data"]["table_name"]." ";
$q .= "LEFT JOIN ".$table_name." "; $q .= "LEFT JOIN ".$table_name." ";
$q .= "ON ("; $q .= "ON (";
$q .= $this->element_list[$table_name]["read_data"]["table_name"].".".$this->element_list[$table_name]["read_data"]["pk_id"]." = ".$table_name.".".$this->element_list[$table_name]["read_data"]["pk_id"]." "; $q .= $this->element_list[$table_name]["read_data"]["table_name"].".".$this->element_list[$table_name]["read_data"]["pk_id"]." = ".$table_name.".".$this->element_list[$table_name]["read_data"]["pk_id"]." ";
// if ($this->table_array[$this->int_pk_name]["value"]) // if ($this->table_array[$this->int_pk_name]["value"])
$q .= "AND ".$this->int_pk_name." = ".(($this->table_array[$this->int_pk_name]["value"]) ? $this->table_array[$this->int_pk_name]["value"] : 'NULL')." "; $q .= "AND ".$table_name.".".$this->int_pk_name." = ".(($this->table_array[$this->int_pk_name]["value"]) ? $this->table_array[$this->int_pk_name]["value"] : 'NULL')." ";
$q .= ") "; $q .= ") ";
if ($this->element_list[$table_name]["read_data"]["order"]) if ($this->element_list[$table_name]["read_data"]["order"])
$q .= " ORDER BY ".$this->element_list[$table_name]["read_data"]["order"]; $q .= " ORDER BY ".$this->element_list[$table_name]["read_data"]["table_name"].'.'.$this->element_list[$table_name]["read_data"]["order"];
} }
else else
{ {
// only create query if we have a primary key // only create query if we have a primary key
// reads directly from the reference table
if ($this->table_array[$this->int_pk_name]["value"]) if ($this->table_array[$this->int_pk_name]["value"])
$q = "SELECT ".implode(", ", $q_select)." FROM ".$table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"]; $q = "SELECT ".implode(", ", $q_select)." FROM ".$table_name." WHERE ".$this->int_pk_name." = ".$this->table_array[$this->int_pk_name]["value"];
} }
// $this->debug('CFG QUERY', 'Q: '.$q);
// only run if we have query strnig // only run if we have query strnig
if ($q) if ($q)
{ {
$pos = 0; // position in while for overwrite if needed
// read out the list and add the selected data if needed // read out the list and add the selected data if needed
while ($res = $this->db_return($q)) while ($res = $this->db_return($q))
{ {
$_data = array ();
$prfx = $data["prefix"]; // short $prfx = $data["prefix"]; // short
// go through each res // go through each res
for ($i = 0; $i < count($q_select); $i ++) for ($i = 0; $i < count($q_select); $i ++)
{ {
// query select part, set to the element name // query select part, set to the element name
$el_name = $q_select[$i]; $el_name = $q_select[$i];
//$this->debug('edit_error', "[$i] POS[$prfx$el_name]: ".$_POST[$prfx.$el_name][$pos]." | RES: ".$res[$el_name]); //$this->debug('edit_error', "[$i] ELNAME: $el_name | POS[$prfx$el_name]: ".$_POST[$prfx.$el_name][$pos]." | RES: ".$res[$el_name]);
// if we have an error, we take what we have in the vars, if not we take the data from the db // if we have an error, we take what we have in the vars, if not we take the data from the db
if ($this->error) if ($this->error)
{ {
@@ -1669,6 +1755,44 @@ $this->debug('edit_error', "I: $i | EL Name: $prfx$el_name | Data: ".$_POST[$prf
unset($_data); unset($_data);
} }
} }
// if this is normal single reference data check the content on the element count
// if there is a max_empty is set, then fill up new elements (unfilled) until we reach max empty
if ($this->element_list[$table_name]['type'] == 'reference_data' && is_numeric($this->element_list[$table_name]['max_empty']) && $this->element_list[$table_name]['max_empty'] > 0)
{
// if the max empty is bigger than 10, just cut it to ten at the moment
if ($this->element_list[$table_name]['max_empty'] > 10)
$this->element_list[$table_name]['max_empty'] = 10;
// check if we need to fill fields
$element_count = count($data['content']);
$missing_empty_count = $this->element_list[$table_name]['max_empty'] - count($data['content']);
$this->debug('CFG MAX', 'Max empty: '.$this->element_list[$table_name]['max_empty'].', Missing: '.$missing_empty_count.', Has: '.$element_count);
// set if we need more open entries or if we do not have any entries yet
if (($missing_empty_count < $this->element_list[$table_name]['max_empty']) || $element_count == 0)
{
for ($pos = count($data['content']); $pos <= ($this->element_list[$table_name]['max_empty'] + $element_count); $pos ++)
{
$_data = array ();
// the fields that need to be filled are in data->type array:
// pk fields are unfilled
// fk fields are filled with the fk_id "int_pk_name" value
foreach ($data['type'] as $el_name => $type)
{
$_data[$el_name] = '';
if ($el_name == $data['pk_name'])
{
}
elseif ($el_name == $data['fk_name'])
{
$_data[$el_name] = $this->table_array[$this->int_pk_name]["value"];
}
}
$data['content'][] = $_data;
$data['pos'][] = array(0 => $pos); // this is for the checkboxes
}
}
}
// push in an empty line of this type, but only if we have a delete key // push in an empty line of this type, but only if we have a delete key
if ($data['delete_name']) if ($data['delete_name'])
$data['content'][] = $proto; $data['content'][] = $proto;

View File

@@ -80,16 +80,7 @@
private $login_template = array ('strings' => array (), 'password_change' => '', 'template' => ''); private $login_template = array ('strings' => array (), 'password_change' => '', 'template' => '');
// acl vars // acl vars
public $acl = array ( public $acl = array ();
'acl' => array (
'user' => array (),
'page' => array (),
'edit_access' => array ()
),
'info' => array (
'edit_access' => array ()
)
);
public $default_acl_list = array (); public $default_acl_list = array ();
// METHOD: login // METHOD: login
@@ -172,17 +163,17 @@
"class_author" => "cs/gullevek/at" "class_author" => "cs/gullevek/at"
); );
// init default ACL list array
$_SESSION['DEFAULT_ACL_LIST'] = array ();
// read the current edit_access_right list into an array // read the current edit_access_right list into an array
$q = "SELECT level, type, name FROM edit_access_right WHERE level >= 0 ORDER BY level"; $q = "SELECT level, type, name FROM edit_access_right WHERE level >= 0 ORDER BY level";
while ($res = $this->db_return($q)) while ($res = $this->db_return($q))
{ {
// level to description format // level to description format (numeric)
$this->default_acl_list[$res['level']] = array ( $this->default_acl_list[$res['level']] = array (
'type' => $res['type'], 'type' => $res['type'],
'name' => $res['name'] 'name' => $res['name']
); );
// format type (eg read) => acl number (eg 20)
$this->default_acl_list[$res['type']] = $res['level'];
} }
// write that into the session // write that into the session
$_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list; $_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list;
@@ -404,7 +395,7 @@
$_SESSION["PAGES"] = $pages; $_SESSION["PAGES"] = $pages;
$_SESSION["PAGES_ACL_LEVEL"] = $pages_acl; $_SESSION["PAGES_ACL_LEVEL"] = $pages_acl;
// load the edit_access user rights // load the edit_access user rights
$q = "SELECT ea.edit_access_id, level, type, ea.name, ea.color, edit_default "; $q = "SELECT ea.edit_access_id, level, type, ea.name, ea.color, ea.uid, edit_default ";
$q .= "FROM edit_access_user eau, edit_access_right ear, edit_access ea "; $q .= "FROM edit_access_user eau, edit_access_right ear, edit_access ea ";
$q .= "WHERE eau.edit_access_id = ea.edit_access_id AND eau.edit_access_right_id = ear.edit_access_right_id AND eau.enabled = 1 AND edit_user_id = ".$this->euid." "; $q .= "WHERE eau.edit_access_id = ea.edit_access_id AND eau.edit_access_right_id = ear.edit_access_right_id AND eau.enabled = 1 AND edit_user_id = ".$this->euid." ";
$q .= "ORDER BY ea.name"; $q .= "ORDER BY ea.name";
@@ -413,16 +404,28 @@
$unit_acl = array(); $unit_acl = array();
while ($res = $this->db_return($q)) while ($res = $this->db_return($q))
{ {
// read edit access data fields and drop them into the unit access array
$q_sub ="SELECT name, value FROM edit_access_data WHERE enabled = 1 edit_access_id = ".$res['edit_access_id'];
$ea_data = array ();
while ($res_sub = $this->db_return($q_sub))
{
$ea_data[$res_sub['name']] = $res_sub['value'];
}
// build master unit array
$unit_access[$res['edit_access_id']] = array ( $unit_access[$res['edit_access_id']] = array (
"id" => $res['edit_access_id'], "id" => $res['edit_access_id'],
"acl_level" => $res["level"], "acl_level" => $res["level"],
"acl_type" => $res["type"], "acl_type" => $res["type"],
"name" => $res["name"], "name" => $res["name"],
"uid" => $res['uid'],
"color" => $res["color"], "color" => $res["color"],
"default" => $res["edit_default"] "default" => $res["edit_default"],
'data' => $ea_data
); );
// set the default unit
if ($res['edit_default']) if ($res['edit_default'])
$_SESSION["UNIT_DEFAULT"] = $res['edit_access_id']; $_SESSION["UNIT_DEFAULT"] = $res['edit_access_id'];
// sub arrays for simple access
array_push($eauid, $res['edit_access_id']); array_push($eauid, $res['edit_access_id']);
$unit_acl[$res['edit_access_id']] = $res['level']; $unit_acl[$res['edit_access_id']] = $res['level'];
} }
@@ -526,94 +529,110 @@
// DESC : sets all the basic ACLs // DESC : sets all the basic ACLs
// init set the basic acl the user has, based on the following rules // init set the basic acl the user has, based on the following rules
// * init set from config DEFAULT ACL // * init set from config DEFAULT ACL
// * if group ACL is set, it overrides the default ACL // * if page ACL is set, it overrides the default ACL
// * if page ACL is set, it overrides the group ACL // * if group ACL is set, it overrides the page ACL
// * if user ACL is set, it overrides the page ACL // * if user ACL is set, it overrides the group ACL
// set the page ACL // set the page ACL
// * default ACL set // * default ACL set
// * set group ACL if not default overrides default ACL // * set group ACL if not default overrides default ACL
// * set page ACL if not default overrides group ACL // * set page ACL if not default overrides group ACL
// set edit access ACL an set default edit access group // set edit access ACL and set default edit access group
// * if an account ACL is set, set this parallel, account ACL overrides user ACL if it applies // * if an account ACL is set, set this parallel, account ACL overrides user ACL if it applies
// * if edit access ACL level is set, use this, else use page // * if edit access ACL level is set, use this, else use page
// set all base ACL levels as a list keyword -> ACL number // set all base ACL levels as a list keyword -> ACL number
public function login_set_acl() public function login_set_acl()
{ {
// set the mastser user id // we start with the default acl
$this->acl['info']['euid'] = $_SESSION['EUID']; $this->acl['base'] = DEFAULT_ACL_LEVEL;
// set admin flag, if this is on, all ACLs are set 100
if ($_SESSION['ADMIN'])
$this->acl['info']['admin'] = 1;
else
$this->acl['info']['admin'] = 0;
$this->acl['acl']['admin'] = $this->acl['info']['admin'];
if (!$this->acl['info']['admin']) // set admin flag and base to 100
if ($_SESSION['ADMIN'])
{ {
// this is the base if nothing is set $this->acl['admin'] = 1;
$this->acl['acl']['user'] = DEFAULT_ACL_LEVEL; // old base ACL $this->acl['base'] = 100;
$this->acl['acl']['max'] = DEFAULT_ACL_LEVEL; }
else
{
// now go throw the flow and set the correct ACL
// user > page > group
// group ACL 0 // group ACL 0
if ($_SESSION['GROUP_ACL_LEVEL'] != -1) if ($_SESSION['GROUP_ACL_LEVEL'] != -1)
{ {
$this->acl['acl']['user'] = $_SESSION['GROUP_ACL_LEVEL']; $this->acl['base'] = $_SESSION['GROUP_ACL_LEVEL'];
if ($this->acl['acl']['user'] > $this->acl['acl']['max'])
$this->acl['acl']['max'] = $this->acl['acl']['user'];
} }
// page ACL 2 // page ACL 1
if ($_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1) if ($_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1)
{ {
$this->acl['acl']['user'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name]; $this->acl['base'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name];
if ($this->acl['acl']['user'] > $this->acl['acl']['max'])
$this->acl['acl']['max'] = $this->acl['acl']['user'];
} }
// user ACL 1 // user ACL 2
if ($_SESSION['USER_ACL_LEVEL'] != -1) if ($_SESSION['USER_ACL_LEVEL'] != -1)
{ {
$this->acl['acl']['user'] = $_SESSION['USER_ACL_LEVEL']; $this->acl['base'] = $_SESSION['USER_ACL_LEVEL'];
if ($this->acl['acl']['user'] > $this->acl['acl']['max'])
$this->acl['acl']['max'] = $this->acl['acl']['user'];
} }
} }
else
{
// if admin is on, level is 100 (admin)
$this->acl['acl']['user'] = 100;
$this->acl['acl']['max'] = 100;
}
// set the current page acl // set the current page acl
// start with default acl // start with default acl
// set group if not -1 // set group if not -1, overrides default
// set page if not -1, overrides groug // set page if not -1, overrides group set
$this->acl['acl']['page'] = DEFAULT_ACL_LEVEL; $this->acl['page'] = DEFAULT_ACL_LEVEL;
if ($_SESSION['GROUP_ACL_LEVEL'] != -1) if ($_SESSION['GROUP_ACL_LEVEL'] != -1)
{ {
$this->acl['acl']['page'] = $_SESSION['GROUP_ACL_LEVEL']; $this->acl['page'] = $_SESSION['GROUP_ACL_LEVEL'];
} }
if ($_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1) if ($_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1)
{ {
$this->acl['acl']['page'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name]; $this->acl['page'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name];
} }
// PER ACCOUNT (UNIT/edit access)-> // PER ACCOUNT (UNIT/edit access)->
foreach ($_SESSION['UNIT'] as $unit) foreach ($_SESSION['UNIT'] as $ea_id => $unit)
{ {
// set edit access acl, unless admin, then it is default 100 // if admin flag is set, all units are set to 100
$this->acl['acl']['edit_access'][$unit['id']] = !$this->acl['info']['admin'] ? ($unit['acl_level'] != -1 ? $unit['acl_level'] : $this->acl['acl']['page']) : 100; if ($this->acl['admin'])
$this->acl['info']['edit_access'][$unit['id']] = $unit['name']; {
$this->acl['unit'][$ea_id] = $this->acl['base'];
}
else
{
if ($unit['acl_level'] != -1)
$this->acl['unit'][$ea_id] = $unit['acl_level'];
else
$this->acl['unit'][$ea_id] = $this->acl['base'];
}
// detail name/level set
$this->acl['unit_detail'][$ea_id] = array (
'name' => $unit['name'],
'uid' => $unit['uid'],
'level' => $this->default_acl_list[$this->acl['unit'][$ea_id]]['name'],
'default' => $unit['default'],
'data' => $unit['data']
);
// set default
if ($unit['default'])
{
$this->acl['unit_id'] = $unit['id'];
$this->acl['unit_name'] = $unit['name'];
$this->acl['unit_uid'] = $unit['uid'];
}
} }
// flag if to show extra edit access drop downs (because user has multiple groups assigned) // flag if to show extra edit access drop downs (because user has multiple groups assigned)
if (count($_SESSION['UNIT']) > 1) if (count($_SESSION['UNIT']) > 1)
$this->acl['acl']['show_ea_extra'] = 1; $this->acl['show_ea_extra'] = 1;
else else
$this->acl['acl']['show_ea_extra'] = 0; $this->acl['show_ea_extra'] = 0;
// set the default edit access // set the default edit access
$this->acl['info']['default_edit_access'] = $_SESSION['UNIT_DEFAULT']; $this->acl['default_edit_access'] = $_SESSION['UNIT_DEFAULT'];
// integrate the default_acl list, but only for the keyword -> level // integrate the type acl list, but only for the keyword -> level
foreach ($this->default_acl_list as $key => $value) foreach ($this->default_acl_list as $level => $data)
{ {
if (!is_numeric($key)) $this->acl['min'][$data['type']] = $level;
$this->acl['list'][$key] = $value;
} }
// set the full acl list too
$this->acl['acl_list'] = $_SESSION['DEFAULT_ACL_LIST'];
// debug
// $this->debug('ACL', $this->print_ar($this->acl));
} }
// METHOD: login_check_edit_access // METHOD: login_check_edit_access
@@ -622,7 +641,7 @@
// DESC : checks if this edit access id is valid // DESC : checks if this edit access id is valid
public function login_check_edit_access($edit_access_id) public function login_check_edit_access($edit_access_id)
{ {
if (array_key_exists($edit_access_id, $this->acl['info']['edit_access'])) if (array_key_exists($edit_access_id, $this->acl['unit']))
return true; return true;
else else
return false; return false;
@@ -657,7 +676,7 @@
$data = 'User could not be found'; $data = 'User could not be found';
} }
} }
// check old passwords match -> error // check old passwords match -> error
if (!$this->login_error) if (!$this->login_error)
{ {
$q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->db_escape_string($this->pw_username)."' AND password = '".$this->db_escape_string($this->pw_old_password)."'"; $q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->db_escape_string($this->pw_username)."' AND password = '".$this->db_escape_string($this->pw_old_password)."'";
@@ -1011,5 +1030,17 @@ EOM;
return $edit_access_id; return $edit_access_id;
} }
// METHOD: login_set_edit_access_data
// PARAMS: edit access id, key value to search for
// RETURN: false for not found or string for found data
// DESC : searchs in the data set for the unit for the data key and returns the value asociated with it
public function login_set_edit_access_data($edit_access_id, $data_key)
{
if (!$_SESSION['UNIT'][$edit_access_id]['data'][$data_key])
return false;
else
return $_SESSION['UNIT'][$edit_access_id]['data'][$data_key];
}
} // close class } // close class
?> ?>

View File

@@ -102,7 +102,6 @@ class ProgressBar
$bar = $this->height; $bar = $this->height;
break; break;
} }
// avoid divison through 0 // avoid divison through 0
if ($this->max - $this->min == 0) if ($this->max - $this->min == 0)
$this->max ++; $this->max ++;
@@ -557,7 +556,6 @@ class ProgressBar
$this->_setStep($step); $this->_setStep($step);
$js = ''; $js = '';
$new_position = $this->_calculatePosition($this->step); $new_position = $this->_calculatePosition($this->step);
if ($new_position['width'] != $this->position['width'] && ($this->direction == 'right' || $this->direction == 'left')) if ($new_position['width'] != $this->position['width'] && ($this->direction == 'right' || $this->direction == 'left'))
{ {
@@ -576,7 +574,6 @@ class ProgressBar
$js .= 'PBposition'.$this->code.'("height",'.$new_position['height'].');'; $js .= 'PBposition'.$this->code.'("height",'.$new_position['height'].');';
} }
$this->position = $new_position; $this->position = $new_position;
foreach($this->label as $name => $data) foreach($this->label as $name => $data)
{ {
if (array_key_exists('type', $data)) if (array_key_exists('type', $data))

View File

@@ -10,8 +10,8 @@
// read in the Smarty class for definition // read in the Smarty class for definition
// use smarty BC for backwards compability // use smarty BC for backwards compability
// try to include file from LIBS path, or from normal path // try to include file from LIBS path, or from normal path
_spl_autoload('SmartyBC.class.php'); _spl_autoload('SmartyBC.class.php');
class SmartyML extends SmartyBC class SmartyML extends SmartyBC
{ {

View File

@@ -1,7 +1,7 @@
<? <?
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2011/2/8 * CREATED: 2011/2/8
* DESCRIPTION: pre function to collect all non critical errors into a log file if possible * DESCRIPTION: pre function to collect all non critical errors into a log file if possible
* include this file at the very beginning of the script to get the notices, strict, etc messages. * include this file at the very beginning of the script to get the notices, strict, etc messages.
* error etc will still be written to the log/display * error etc will still be written to the log/display
@@ -42,7 +42,7 @@
4096 => 'E_RECOVERABLE_ERROR', 4096 => 'E_RECOVERABLE_ERROR',
8192 => 'E_DEPRICATED', 8192 => 'E_DEPRICATED',
16384 => 'E_USER_DEPRICATED', 16384 => 'E_USER_DEPRICATED',
30719 => 'E_ALL' 30719 => 'E_ALL'
); );
// get the current page name (strip path) // get the current page name (strip path)

View File

@@ -141,8 +141,8 @@ class qqFileUploader {
} }
} }
$this->uploadFileName = $uploadDirectory . $filename . '.' . $ext; $this->uploadFileName = $uploadDirectory . $filename . '.' . $ext;
$this->uploadFileExt = $ext; $this->uploadFileExt = $ext;
if ($this->file->save($uploadDirectory . $filename . '.' . $ext)){ if ($this->file->save($uploadDirectory . $filename . '.' . $ext)){
return array('success'=>true); return array('success'=>true);

View File

@@ -16,7 +16,7 @@
* 2004/09/30 (cs) layout cleanup * 2004/09/30 (cs) layout cleanup
* / * /
/* collection of PostgreSQL wrappers * collection of PostgreSQL wrappers
* REQUIRES 5.x PHP!!! * REQUIRES 5.x PHP!!!
* *
* pg_prepare * pg_prepare

View File

@@ -7,7 +7,7 @@
* HISTORY: * HISTORY:
* / * /
/* collection of PostgreSQL wrappers /* collection of PostgreSQL wrappers
* REQUIRES 5.x PHP with compiled pdo pgsql (--with-pdo-pgsql) * REQUIRES 5.x PHP with compiled pdo pgsql (--with-pdo-pgsql)
* *
*/ */

View File

@@ -49,7 +49,7 @@ class StringReader {
var $_pos; var $_pos;
var $_str; var $_str;
function StringReader($str='') { function __construct($str='') {
$this->_str = $str; $this->_str = $str;
$this->_pos = 0; $this->_pos = 0;
} }
@@ -86,7 +86,7 @@ class FileReader {
var $_fd; var $_fd;
var $_length; var $_length;
function FileReader($filename) { function __construct($filename) {
if (file_exists($filename)) { if (file_exists($filename)) {
$this->_length=filesize($filename); $this->_length=filesize($filename);
@@ -143,7 +143,7 @@ class FileReader {
// Preloads entire file in memory first, then creates a StringReader // Preloads entire file in memory first, then creates a StringReader
// over it (it assumes knowledge of StringReader internals) // over it (it assumes knowledge of StringReader internals)
class CachedFileReader extends StringReader { class CachedFileReader extends StringReader {
function CachedFileReader($filename) { function __construct($filename) {
if (file_exists($filename)) { if (file_exists($filename)) {
$length=filesize($filename); $length=filesize($filename);

View File

@@ -183,7 +183,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$idx ++; $idx ++;
} else { } else {
$_idx = 0; $_idx = 0;
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, $class, $_idx); $_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, $class, $label, $_idx);
$idx ++; $idx ++;
} }