Compare commits

..

4 Commits

Author SHA1 Message Date
dbabd89491 Backport Login changes
Password change backport
2018-05-09 15:11:06 +09:00
9842c979b6 Backport of missing password changes for Login class
move password check into method.
do proper check for password change.
remove all password log/error outputs. ever.
2018-05-09 12:26:01 +09:00
85a327f45f Backport new password interface to legacy classes 2018-05-09 11:47:16 +09:00
7b085f86f0 Change to <?php for core core classes
Basic/DB IO/db_pgsql switch only
2018-04-17 10:05:41 +09:00
462 changed files with 29976 additions and 3440 deletions

View File

@@ -8,7 +8,7 @@
-- DROP TABLE edit_access; -- DROP TABLE edit_access;
CREATE TABLE edit_access ( CREATE TABLE edit_access (
edit_access_id SERIAL PRIMARY KEY, edit_access_id SERIAL PRIMARY KEY,
name VARCHAR UNIQUE, name VARCHAR(255) UNIQUE,
description VARCHAR, description VARCHAR,
COLOR VARCHAR COLOR VARCHAR
) INHERITS (edit_generic) WITHOUT OIDS; ) INHERITS (edit_generic) WITHOUT OIDS;

View File

@@ -8,7 +8,7 @@
-- DROP TABLE edit_group; -- DROP TABLE edit_group;
CREATE TABLE edit_group ( CREATE TABLE edit_group (
edit_group_id SERIAL PRIMARY KEY, edit_group_id SERIAL PRIMARY KEY,
name VARCHAR, name VARCHAR(50),
enabled SMALLINT NOT NULL DEFAULT 0, enabled SMALLINT NOT NULL DEFAULT 0,
edit_scheme_id INT, edit_scheme_id INT,
edit_access_right_id INT NOT NULL, edit_access_right_id INT NOT NULL,

View File

@@ -9,12 +9,12 @@
-- DROP TABLE edit_language; -- DROP TABLE edit_language;
CREATE TABLE edit_language ( CREATE TABLE edit_language (
edit_language_id SERIAL PRIMARY KEY, edit_language_id SERIAL PRIMARY KEY,
short_name VARCHAR, short_name VARCHAR(2),
long_name VARCHAR, long_name VARCHAR(70),
iso_name VARCHAR, iso_name VARCHAR(12),
order_number INT, order_number INT,
enabled SMALLINT NOT NULL DEFAULT 0, enabled SMALLINT NOT NULL DEFAULT 0,
lang_default SMALLINT NOT NULL DEFAULT 0 lang_default SMALLINT NOT NULL DEFAULT 0 UNIQUE
) INHERITS (edit_generic) WITHOUT OIDS; ) INHERITS (edit_generic) WITHOUT OIDS;
INSERT INTO edit_language (short_name, long_name, iso_name, order_number, enabled, lang_default) VALUES ('en', 'English', 'UTF-8', 1, 1, 1); INSERT INTO edit_language (short_name, long_name, iso_name, order_number, enabled, lang_default) VALUES ('en', 'English', 'UTF-8', 1, 1, 1);

View File

@@ -8,8 +8,8 @@
-- DROP TABLE edit_menu_group; -- DROP TABLE edit_menu_group;
CREATE TABLE edit_menu_group ( CREATE TABLE edit_menu_group (
edit_menu_group_id SERIAL PRIMARY KEY, edit_menu_group_id SERIAL PRIMARY KEY,
name VARCHAR, name VARCHAR(255),
flag VARCHAR, flag VARCHAR(50),
order_number INT NOT NULL order_number INT NOT NULL
) INHERITS (edit_generic) WITHOUT OIDS; ) INHERITS (edit_generic) WITHOUT OIDS;

View File

@@ -8,8 +8,8 @@
-- DROP TABLE edit_page; -- DROP TABLE edit_page;
CREATE TABLE edit_page ( CREATE TABLE edit_page (
edit_page_id SERIAL PRIMARY KEY, edit_page_id SERIAL PRIMARY KEY,
filename VARCHAR, filename VARCHAR(70),
name VARCHAR UNIQUE, name VARCHAR(255) UNIQUE,
order_number INT NOT NULL, order_number INT NOT NULL,
online SMALLINT NOT NULL DEFAULT 0, online SMALLINT NOT NULL DEFAULT 0,
menu SMALLINT NOT NULL DEFAULT 0, menu SMALLINT NOT NULL DEFAULT 0,

View File

@@ -8,8 +8,8 @@
-- DROP TABLE edit_query_string; -- DROP TABLE edit_query_string;
CREATE TABLE edit_query_string ( CREATE TABLE edit_query_string (
edit_query_string_id SERIAL PRIMARY KEY, edit_query_string_id SERIAL PRIMARY KEY,
name VARCHAR, name VARCHAR(255),
value VARCHAR, value VARCHAR(255),
enabled SMALLINT NOT NULL DEFAULT 0, enabled SMALLINT NOT NULL DEFAULT 0,
dynamic SMALLINT NOT NULL DEFAULT 0, dynamic SMALLINT NOT NULL DEFAULT 0,
edit_page_id INT NOT NULL, edit_page_id INT NOT NULL,

View File

@@ -9,12 +9,12 @@
CREATE TABLE edit_scheme ( CREATE TABLE edit_scheme (
edit_scheme_id SERIAL PRIMARY KEY, edit_scheme_id SERIAL PRIMARY KEY,
enabled SMALLINT NOT NULL DEFAULT 0, enabled SMALLINT NOT NULL DEFAULT 0,
name VARCHAR, name VARCHAR(50),
header_color VARCHAR, header_color VARCHAR(7),
css_file VARCHAR, css_file VARCHAR(50),
template VARCHARs template VARCHAR(50)
) INHERITS (edit_generic) WITHOUT OIDS; ) INHERITS (edit_generic) WITHOUT OIDS;
INSERT INTO edit_scheme (name, header_color, enabled) VALUES ('Default Scheme', 'E0E2FF', 1); INSERT INTO edit_scheme (name, header_color, enabled) VALUES ('Default Scheme', '#E0E2FF', 1);
INSERT INTO edit_scheme (name, header_color, enabled) VALUES ('Admin', 'CC7E7E', 1); INSERT INTO edit_scheme (name, header_color, enabled) VALUES ('Admin', '#CC7E7E', 1);
INSERT INTO edit_scheme (name, header_color, enabled) VALUES ('Visitor', 'B0C4B3', 1); INSERT INTO edit_scheme (name, header_color, enabled) VALUES ('Visitor', '#B0C4B3', 1);

View File

@@ -7,5 +7,5 @@
-- DROP TABLE temp_files; -- DROP TABLE temp_files;
CREATE TABLE temp_files ( CREATE TABLE temp_files (
filename VARCHAR filename VARCHAR(250)
); );

View File

@@ -8,8 +8,8 @@
-- DROP TABLE edit_visible_group; -- DROP TABLE edit_visible_group;
CREATE TABLE edit_visible_group ( CREATE TABLE edit_visible_group (
edit_visible_group_id SERIAL PRIMARY KEY, edit_visible_group_id SERIAL PRIMARY KEY,
name VARCHAR, name VARCHAR(255),
flag VARCHAR flag VARCHAR(50)
) INHERITS (edit_generic) WITHOUT OIDS; ) INHERITS (edit_generic) WITHOUT OIDS;
DELETE FROM edit_visible_group; DELETE FROM edit_visible_group;

View File

@@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
# create path # create path
path=$(pwd)"/"$0; path=`pwd`"/"$0;
LOCAL_BASE_DIR="<local folder>"; LOCAL_BASE_DIR="<local folder>";
LOCAL_DIR=$LOCAL_BASE_DIR""; LOCAL_DIR=$LOCAL_BASE_DIR"";
REMOTE_WEB="<remote folder>"; REMOTE_WEB="<remote folder>";
TARGET_HOST_WEB="<user>@<host>"; TARGET_HOST_WEB="<user>@<host>
TMP_DIR=$LOCAL_BASE_DIR"/4dev/"; TMP_DIR=$LOCAL_BASE_DIR"/4dev/";
tmpf_web=$TMP_DIR"tmp.web"; tmpf_web=$TMP_DIR"tmp.web";

View File

@@ -1,72 +0,0 @@
#!/bin/bash
OIFS=${IFS};
base_dir="/home/clemens/html/developers/clemens/core_data/php_libraries/trunk/";
class_file="CoreLibs/Output/Form/Generate.inc";
tmp_file=${base_dir}"4dev/tmp/tmp.comp."$(echo "${class_file}" | tr \/. _);
rpl_file=${base_dir}"4dev/tmp/tmp.rpl."$(echo "${class_file}" | tr \/. _);
rm -f "${tmp_file}";
rm -f "${rpl_file}";
if [ ! -f ${class_file} ];
then
echo "Cannot find ${class_file} in current folder: $(pwd)";
exit;
fi;
cat "${class_file}" | grep "WAS :" -B 1 | while read line;
do
# if method grep for function call
found=$(echo "${line}" | sed -e 's/^[ \t]*//' | grep "METHOD:");
if [ -n "${found}" ];
then
method=$(echo "${line}" | cut -d " " -f 3);
echo "1 MET: ${method}";
# is method
if [ -n "${method}" ];
then
# the full new call
new_function_call_full=$(grep "function ${method}(" "${class_file}" | grep "function" | sed -e 's/^[ \t]*//');
# just the method name
new_function_call=$(echo "${new_function_call_full}" | sed -e 's/public //' | sed -e 's/private //' | sed -e 's/static //' | sed -e 's/function //' | cut -d "(" -f 1);
# check if func call is more than just alphanumeric (we don't need to redeclare those, functions are case insenstivie)
#
# only params (remove all = ... stuff)
new_function_call_params=$(echo "${new_function_call_full}" | cut -d "(" -f 2- | sed -e 's/)//');
old_function_call_params='';
IFS=',';
for el in ${new_function_call_params};
do
if [ -n "${old_function_call_params}" ];
then
old_function_call_params=${old_function_call_params}", ";
fi;
old_function_call_params=${old_function_call_params}$(echo "${el}" | cut -d "=" -f 1 | tr -d ' ');
done;
# cut -d "," "${new_function_call_params}" | while
fi;
fi;
# if this is a WAS
was=$(echo "${line}" | sed -e 's/^[ \t]*//' | grep "WAS :" | tr -s " ");
if [ -n "${was}" ];
then
old_function_call=$(echo "${was}" | cut -d " " -f 4)
echo "2 OLD: ${old_function_call} => ${new_function_call} [${new_function_call_full}]";
# for return write:
# rpl new -> old { new }
rpl=$(echo "${new_function_call_full}" | sed -e "s/${new_function_call}/${old_function_call}/");
new_call="${rpl}\n";
new_call=${new_call}"{\n";
new_call=${new_call}"\terror_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);\n";
new_call=${new_call}"\treturn \$this->${new_function_call}(${old_function_call_params});\n";
new_call=${new_call}"}\n";
echo -e "${new_call}" >> "${tmp_file}";
echo "3A RPL CALL: ${rpl}";
echo "3B RPL CALL: return \$this->${new_function_call}(${old_function_call_params});";
echo "4 SWT RPL : rpl '\$this->${old_function_call}' '\$this->${new_function_call}'";
# write the replace calls for old $this->old_call to $this->new_call
echo "rpl '\$this->${old_function_call}' '\$this->${new_function_call}' ##TARGET_FILE##" >> "${rpl_file}";
echo "----";
fi;
done;
IFS=${OIFS};
# __END__

View File

@@ -1,18 +0,0 @@
#!/bin/bash
cat tmp.comp | while read i;
do
found=$(echo "${i}" | grep "function ");
if [ -n "${found}" ]; then
fk=$(echo "${i}" | cut -d " " -f 3 | cut -d "(" -f 1);
fi;
found=$(echo "${i}" | grep "\$this->");
if [ -n "${found}" ]; then
# no to debug
found=$(echo "${i}" | grep "debug(");
if [ -z "${found}" ]; then
fk_n=$(echo "${i}" | cut -d "(" -f 1);
echo "rpl '\$this->${fk}' '${fk_n}' CoreLibs/DB/IO.inc";
fi;
fi;
done;

View File

@@ -14,14 +14,12 @@ There are three branches:
### master ### master
The active branch, which is the namespace branch This is currently the legacy branch set live. This will change to the namespace branch once development is finished
### legacy ### legacy
The old non namepsace format layout. The old non namepsace format layout. This will only get bug fixes and no new development
This is fully deprecated and will no longer be maintaned.
last tested PHP 5.6 and PHP 7.0
### namespace ### namespace
The new namespace branch. This is the development area for the master branch The new namespace branch. Once development is finished this branch will be removed or renamed to development only branch

1
www/Smarty Symbolic link
View File

@@ -0,0 +1 @@
smarty-3.1.30

1
www/admin/Smarty Symbolic link
View File

@@ -0,0 +1 @@
../Smarty

1
www/admin/cache Symbolic link
View File

@@ -0,0 +1 @@
../cache/

View File

@@ -1,5 +1,4 @@
<?php <?
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations $DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = 1; $DEBUG_ALL = 1;
$PRINT_ALL = 1; $PRINT_ALL = 1;
@@ -9,39 +8,36 @@ 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);
} }
ob_start();
// basic class test file
define('USE_DATABASE', true); define('USE_DATABASE', true);
// sample config // sample config
require("config.inc"); require("config.inc");
// set session name // set session name
if (!defined('SET_SESSION_NAME')) {
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME); DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
// session_name(EDIT_SESSION_NAME);
// session_start();
// basic class test file
foreach (array ('Login', 'Admin.Backend') as $class) {
_spl_autoload('Class.'.$class.'.inc');
} }
// define log file id
DEFINE('LOG_FILE_ID', 'classTest');
// set language for l10n
$lang = 'en_utf8'; $lang = 'en_utf8';
// init login & backend class
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang); DEFINE('LOG_FILE_ID', 'classTest');
$basic = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang); $login = new login($DB_CONFIG[LOGIN_DB], $lang);
$basic->dbInfo(1); // init with standard
ob_end_flush(); // $basic = new db_io($DB_CONFIG[MAIN_DB]);
$basic = new AdminBackend($DB_CONFIG[MAIN_DB], $lang);
$basic->db_info(1);
// set + check edit access id // set + check edit access id
$edit_access_id = 3; $edit_access_id = 3;
if (array_key_exists('unit', $login->acl)) {
print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."<br>"; print "ACL UNIT: ".print_r(array_keys($login->acl['unit']), 1)."<br>";
print "ACCESS CHECK: ".$login->loginCheckEditAccess($edit_access_id)."<br>"; print "ACCESS CHECK: ".$login->login_check_edit_access($edit_access_id)."<br>";
if ($login->loginCheckEditAccess($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['unit_id']; $basic->edit_access_id = $login->acl['unit_id'];
} }
} else {
print "Something went wrong with the login<br>";
}
// $basic->debug('SESSION', $basic->print_ar($_SESSION)); // $basic->debug('SESSION', $basic->print_ar($_SESSION));
@@ -63,12 +59,12 @@ print "DEBUG OUT ALL: ".$basic->debug_output_all."<br>";
print "ECHO OUT ALL: ".$basic->echo_output_all."<br>"; print "ECHO OUT ALL: ".$basic->echo_output_all."<br>";
print "PRINT OUT ALL: ".$basic->print_output_all."<br>"; print "PRINT OUT ALL: ".$basic->print_output_all."<br>";
print "CALLER BACKTRACE: ".$basic->getCallerMethod()."<br>"; print "CALLER BACKTRACE: ".$basic->get_caller_method()."<br>";
$basic->debug('SOME MARK', 'Some error output'); $basic->debug('SOME MARK', 'Some error output');
print "EDIT ACCESS ID: ".$basic->edit_access_id."<br>"; print "EDIT ACCESS ID: ".$basic->edit_access_id."<br>";
// print "ACL: <br>".$basic->print_ar($login->acl)."<br>"; // print "ACL: <br>".$basic->print_ar($login->acl)."<br>";
$basic->debug('ACL', "ACL: ".$basic->printAr($login->acl)); $basic->debug('ACL', "ACL: ".$basic->print_ar($login->acl));
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>"; // print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
// print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>"; // print "DEFAULT ACL: <br>".$basic->print_ar($login->default_acl_list)."<br>";
// $result = array_flip(array_filter(array_flip($login->default_acl_list), function ($key) { if (is_numeric($key)) return $key; })); // $result = array_flip(array_filter(array_flip($login->default_acl_list), function ($key) { if (is_numeric($key)) return $key; }));
@@ -76,54 +72,51 @@ $basic->debug('ACL', "ACL: ".$basic->printAr($login->acl));
// DEPRICATED CALL // DEPRICATED CALL
// $basic->adbSetACL($login->acl); // $basic->adbSetACL($login->acl);
// DB client encoding while ($res = $basic->db_return("SELECT * FROM max_test")) {
print "DB Client encoding: ".$basic->dbGetEncoding()."<br>";
while ($res = $basic->dbReturn("SELECT * FROM max_test")) {
print "TIME: ".$res['time']."<br>"; print "TIME: ".$res['time']."<br>";
} }
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test"); $status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO TEST ".time()."') RETURNING test");
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>"; print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>"; print "DIRECT INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>";
$basic->dbPrepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)"); $basic->db_prepare("ins_foo", "INSERT INTO foo (test) VALUES ($1)");
$status = $basic->dbExecute("ins_foo", array('BAR TEST '.time())); $status = $basic->db_execute("ins_foo", array('BAR TEST '.time()));
print "PREPARE INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>"; print "PREPARE INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>"; print "PREPARE INSERT PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>";
// returning test with multiple entries // returning test with multiple entries
// $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id"); // $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id");
$status = $basic->dbExec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test"); $status = $basic->db_exec("INSERT INTO foo (test) values ('BAR 1 ".time()."'), ('BAR 2 ".time()."'), ('BAR 3 ".time()."') RETURNING foo_id, test");
print "DIRECT MULTIPLE INSERT STATUS: $status | PRIMARY KEYS: ".print_r($basic->insert_id, 1)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>"; print "DIRECT MULTIPLE INSERT STATUS: $status | PRIMARY KEYS: ".print_r($basic->insert_id, 1)." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
// no returning, but not needed ; // no returning, but not needed ;
$status = $basic->dbExec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');"); $status = $basic->db_exec("INSERT INTO foo (test) VALUES ('FOO; TEST ".time()."');");
print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>"; print "DIRECT INSERT STATUS: $status | PRIMARY KEY: ".$basic->insert_id." | PRIMARY KEY EXT: ".print_r($basic->insert_id_ext, 1)."<br>";
# db write class test # db write class test
$table = 'foo'; $table = 'foo';
print "TABLE META DATA: ".$basic->printAr($basic->dbShowTableMetaData($table))."<br>"; print "TABLE META DATA: ".$basic->print_ar($basic->db_show_table_meta_data($table))."<br>";
$primary_key = ''; # unset $primary_key = ''; # unset
$db_write_table = array ('test', 'string_a', 'number_a', 'some_bool'); $db_write_table = array ('test', 'string_a', 'number_a', 'some_bool');
// $db_write_table = array ('test'); // $db_write_table = array ('test');
$object_fields_not_touch = array (); $object_fields_not_touch = array ();
$object_fields_not_update = array (); $object_fields_not_update = array ();
$data = array ('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5); $data = array ('test' => 'BOOL TEST SOMETHING '.time(), 'string_a' => 'SOME TEXT', 'number_a' => 5);
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); $primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key<br>"; print "Wrote to DB tabel $table and got primary key $primary_key<br>";
$data = array ('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1); $data = array ('test' => 'BOOL TEST ON '.time(), 'string_a' => '', 'number_a' => 0, 'some_bool' => 1);
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); $primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key<br>"; print "Wrote to DB tabel $table and got primary key $primary_key<br>";
$data = array ('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0); $data = array ('test' => 'BOOL TEST OFF '.time(), 'string_a' => null, 'number_a' => null, 'some_bool' => 0);
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); $primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key<br>"; print "Wrote to DB tabel $table and got primary key $primary_key<br>";
$data = array ('test' => 'BOOL TEST UNSET '.time()); $data = array ('test' => 'BOOL TEST UNSET '.time());
$primary_key = $basic->dbWriteDataExt($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data); $primary_key = $basic->db_write_data_ext($db_write_table, $primary_key, $table, $object_fields_not_touch, $object_fields_not_update, $data);
print "Wrote to DB tabel $table and got primary key $primary_key<br>"; print "Wrote to DB tabel $table and got primary key $primary_key<br>";
# async test queries # async test queries
/* $basic->dbExecAsync("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)"); /* $basic->db_exec_async("SELECT test FROM foo, (SELECT pg_sleep(10)) as sub WHERE foo_id IN (27, 50, 67, 44, 10)");
echo "WAITING FOR ASYNC: "; echo "WAITING FOR ASYNC: ";
$chars = array('|', '/', '-', '\\'); $chars = array('|', '/', '-', '\\');
while (($ret = $basic->dbCheckAsync()) === true) while (($ret = $basic->db_check_async()) === true)
{ {
if ((list($_, $char) = each($chars)) === FALSE) if ((list($_, $char) = each($chars)) === FALSE)
{ {
@@ -135,37 +128,37 @@ while (($ret = $basic->dbCheckAsync()) === true)
flush(); flush();
} }
print "<br>END STATUS: ".$ret."<br>"; print "<br>END STATUS: ".$ret."<br>";
// while ($res = $basic->dbFetchArray($ret)) // while ($res = $basic->db_fetch_array($ret))
while ($res = $basic->dbFetchArray()) while ($res = $basic->db_fetch_array())
{ {
echo "RES: ".$res['test']."<br>"; echo "RES: ".$res['test']."<br>";
} }
# test async insert # test async insert
$basic->dbExecAsync("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')"); $basic->db_exec_async("INSERT INTO foo (Test) VALUES ('ASYNC TEST ".time()."')");
echo "WAITING FOR ASYNC INSERT: "; echo "WAITING FOR ASYNC INSERT: ";
while (($ret = $basic->dbCheckAsync()) === true) while (($ret = $basic->db_check_async()) === true)
{ {
print "."; print ".";
sleep(1); sleep(1);
flush(); flush();
} }
print "<br>END STATUS: ".$ret." | PK: ".$basic->insert_id."<br>"; print "<br>END STATUS: ".$ret." | PK: ".$basic->insert_id."<br>";
print "ASYNC PREVIOUS INSERTED: ".print_r($basic->dbReturnRow("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>"; */ print "ASYNC PREVIOUS INSERTED: ".print_r($basic->db_return_row("SELECT foo_id, test FROM foo WHERE foo_id = ".$basic->insert_id), 1)."<br>"; */
$to_db_version = '9.1.9'; $to_db_version = '9.1.9';
print "VERSION DB: ".$basic->dbVersion()."<br>"; print "VERSION DB: ".$basic->db_version()."<br>";
print "DB Version smaller $to_db_version: ".$basic->dbCompareVersion('<'.$to_db_version)."<br>"; print "DB Version smaller $to_db_version: ".$basic->db_compare_version('<'.$to_db_version)."<br>";
print "DB Version smaller than $to_db_version: ".$basic->dbCompareVersion('<='.$to_db_version)."<br>"; print "DB Version smaller than $to_db_version: ".$basic->db_compare_version('<='.$to_db_version)."<br>";
print "DB Version equal $to_db_version: ".$basic->dbCompareVersion('='.$to_db_version)."<br>"; print "DB Version equal $to_db_version: ".$basic->db_compare_version('='.$to_db_version)."<br>";
print "DB Version bigger than $to_db_version: ".$basic->dbCompareVersion('>='.$to_db_version)."<br>"; print "DB Version bigger than $to_db_version: ".$basic->db_compare_version('>='.$to_db_version)."<br>";
print "DB Version bigger $to_db_version: ".$basic->dbCompareVersion('>'.$to_db_version)."<br>"; print "DB Version bigger $to_db_version: ".$basic->db_compare_version('>'.$to_db_version)."<br>";
/* $q = "SELECT FOO FRO BAR"; /* $q = "SELECT FOO FRO BAR";
// $q = "Select * from foo"; // $q = "Select * from foo";
$foo = $basic->dbExecAsync($q); $foo = $basic->db_exec_async($q);
print "[ERR] Query: ".$q."<br>"; print "[ERR] Query: ".$q."<br>";
print "[ERR] RESOURCE: $foo<br>"; print "[ERR] RESOURCE: $foo<br>";
while (($ret = $basic->dbCheckAsync()) === true) while (($ret = $basic->db_check_async()) === true)
{ {
print "[ERR]: $ret<br>"; print "[ERR]: $ret<br>";
// sleep(5); // sleep(5);
@@ -173,39 +166,30 @@ while (($ret = $basic->dbCheckAsync()) === true)
// search path check // search path check
$q = "SHOW search_path"; $q = "SHOW search_path";
$cursor = $basic->dbExec($q); $cursor = $basic->db_exec($q);
$data = $basic->dbFetchArray($cursor)['search_path']; $data = $basic->db_fetch_array($cursor)['search_path'];
print "RETURN DATA FOR search_path: ".$data."<br>"; print "RETURN DATA FOR search_path: ".$data."<br>";
// print "RETURN DATA FOR search_path: ".$basic->printAr($data)."<br>"; // print "RETURN DATA FOR search_path: ".$basic->print_ar($data)."<br>";
// insert something into test.schema_test and see if we get the PK back // insert something into test.schema_test and see if we get the PK back
$status = $basic->dbExec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")"); $status = $basic->db_exec("INSERT INTO test.schema_test (contents, id) VALUES ('TIME: ".time()."', ".rand(1, 10).")");
print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."<br>"; print "OTHER SCHEMA INSERT STATUS: ".$status." | PK NAME: ".$basic->pk_name.", PRIMARY KEY: ".$basic->insert_id."<br>";
// time string thest // time string thest
$timestamp = 5887998.33445; $timestamp = 5887998.33445;
$time_string = $basic->timeStringFormat($timestamp); $time_string = $basic->TimeStringFormat($timestamp);
print "PLANE TIME STRING: ".$timestamp."<br>";
print "TIME STRING TEST: ".$time_string."<br>"; print "TIME STRING TEST: ".$time_string."<br>";
print "REVERSE TIME STRING: ".$basic->stringToTime($time_string)."<br>"; print "REVERSE TIME STRING: ".$basic->StringToTime($time_string);
if (round($timestamp, 4) == $basic->stringToTime($time_string)) {
print "REVERSE TIME STRING MATCH<br>";
} else {
print "REVERSE TRIME STRING DO NOT MATCH<br>";
}
// magic links test // magic links test
print $basic->magicLinks('user@bubu.at').'<br>'; print $basic->magic_links('user@bubu.at').'<br>';
print $basic->magicLinks('http://test.com/foo/bar.php?foo=1').'<br>'; print $basic->magic_links('http://test.com/foo/bar.php?foo=1').'<br>';
// compare date // compare date
$date_1 = '2017/1/5'; $date_1 = '2017/1/5';
$date_2 = '2017-01-05'; $date_2 = '2017-01-05';
print "COMPARE DATE: ".$basic->compareDate($date_1, $date_2)."<br>"; print "COMPARE DATE: ".$basic->CompareDate($date_1, $date_2)."<br>";
// print error messages // print error messages
print $login->printErrorMsg(); print $basic->print_error_msg();
print $basic->printErrorMsg();
print "</body></html>"; print "</body></html>";
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org) * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/06/10 * CREATED: 2003/06/10
@@ -24,19 +24,26 @@ extract($_POST, EXTR_SKIP);
$table_width = 750; $table_width = 750;
// this is for certain CMS modules that set a relative path // this is for certain CMS modules that set a relative path
define('REL_PATH', ''); define(REL_PATH, '');
ob_start(); ob_start();
include("config.inc"); include("config.inc");
// set session name here
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
// overrride debug flags // overrride debug flags
if (!DEBUG) { if (!DEBUG) {
$DEBUG_ALL = 0; $DEBUG_ALL = 0;
$PRINT_ALL = 0; $PRINT_ALL = 0;
$DB_DEBUG = 0; $DB_DEBUG = 0;
$ECHO_ALL = 0; $ECHO_ALL = 0;
// $DEBUG_TMPL = 0;
} }
// set session name here
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
// login class
require(LIBS."Class.Login.inc");
// form generate for edit interface
require(LIBS."Class.Form.Generate.inc");
// Smarty: and the small extend for l10n calls
require(LIBS.'Class.Smarty.Extend.inc');
// set default lang if not set otherwise // set default lang if not set otherwise
if (!$lang) { if (!$lang) {
@@ -45,17 +52,17 @@ if (!$lang) {
// should be utf8 // should be utf8
header("Content-type: text/html; charset=".DEFAULT_ENCODING); header("Content-type: text/html; charset=".DEFAULT_ENCODING);
ob_end_flush(); ob_end_flush();
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang); $login = new login($DB_CONFIG[LOGIN_DB], $lang);
// create form class // create form class
$form = new CoreLibs\Output\Form\Generate($DB_CONFIG[MAIN_DB], $lang); $form = new form($DB_CONFIG[MAIN_DB], $lang);
$form->dbExec("SET search_path TO ".LOGIN_DB_SCHEMA); $form->db_exec("SET search_path TO ".LOGIN_DB_SCHEMA);
if ($form->mobile_phone) { if ($form->mobile_phone) {
echo "I am sorry, but this page cannot be viewed by a mobile phone"; echo "I am sorry, but this page cannot be viewed by a mobile phone";
exit; exit;
} }
// smarty template engine (extended Translation version) // smarty template engine (extended Translation version)
$smarty = new CoreLibs\Template\SmartyExtend($lang); $smarty = new SmartyML($lang);
if (TARGET == 'live' || TARGET == 'remote') { if (TARGET == 'live' || TARGET == 'remote') {
// login // login
@@ -91,7 +98,7 @@ function EditLog($event = '', $data = '')
{ {
$q = "INSERT INTO edit_log "; $q = "INSERT INTO edit_log ";
$q .= "(euid, event_date, ip, event, data, page) "; $q .= "(euid, event_date, ip, event, data, page) ";
$q .= "VALUES (".$_SESSION['EUID'].", NOW(), '".$_SERVER["REMOTE_ADDR"]."', '".$GLOBALS['form']->dbEscapeString($event)."', '".$GLOBALS['form']->dbEscapeString($data)."', '".$GLOBALS['form']->getPageName()."')"; $q .= "VALUES (".$_SESSION['EUID'].", NOW(), '".$_SERVER["REMOTE_ADDR"]."', '".$GLOBALS['form']->db_escape_string($event)."', '".$GLOBALS['form']->db_escape_string($data)."', '".$GLOBALS['form']->get_page_name()."')";
} }
// log backend data // log backend data
@@ -105,11 +112,11 @@ $data = array (
// log action // log action
EditLog('Edit Submit', serialize($data)); EditLog('Edit Submit', serialize($data));
$form->formProcedureLoad(${$form->archive_pk_name}); $form->form_procedure_load(${$form->archive_pk_name});
$form->formProcedureNew(); $form->form_procedure_new();
$form->formProcedureSave(); $form->form_procedure_save();
$form->formProcedureDelete(); $form->form_procedure_delete();
$form->formProcedureDeleteFromElementList($element_list, $remove_name); $form->form_procedure_delete_from_element_list($element_list, $remove_name);
// define all needed smarty stuff for the general HTML/page building // define all needed smarty stuff for the general HTML/page building
$HEADER['CSS'] = CSS; $HEADER['CSS'] = CSS;
@@ -121,7 +128,7 @@ $HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
$DATA['table_width'] = $table_width; $DATA['table_width'] = $table_width;
// write out error / status messages // write out error / status messages
$messages[] = $form->formPrintMsg(); $messages[] = $form->form_error_msg();
$DATA['form_error_msg'] = $messages; $DATA['form_error_msg'] = $messages;
// MENU START // MENU START
@@ -137,7 +144,7 @@ $DATA['GROUP_NAME'] = $_SESSION["GROUP_NAME"];
$DATA['GROUP_LEVEL'] = $_SESSION["GROUP_LEVEL"]; $DATA['GROUP_LEVEL'] = $_SESSION["GROUP_LEVEL"];
$PAGES = $_SESSION["PAGES"]; $PAGES = $_SESSION["PAGES"];
//$form->debug('menu', $form->printAr($PAGES)); //$form->debug('menu', $form->print_ar($PAGES));
// baue nav aus $PAGES ... // baue nav aus $PAGES ...
for ($i = 0; $i < count($PAGES); $i ++) { for ($i = 0; $i < count($PAGES); $i ++) {
@@ -165,7 +172,7 @@ for ($i = 1; $i <= count($menuarray); $i ++) {
if ($i == 1 || !(($i - 1) % $SPLIT_FACTOR)) { if ($i == 1 || !(($i - 1) % $SPLIT_FACTOR)) {
$menu_data[$j]['splitfactor_in'] = 1; $menu_data[$j]['splitfactor_in'] = 1;
} }
if ($menuarray[($i - 1)]["filename"] == $form->getPageName()) { if ($menuarray[($i - 1)]["filename"] == $form->get_page_name()) {
$position = $i - 1; $position = $i - 1;
$menu_data[$j]['position'] = 1; $menu_data[$j]['position'] = 1;
} else { } else {
@@ -190,112 +197,112 @@ $L_TITLE = $DATA['page_name'];
$HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE)); $HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE));
// END MENU // END MENU
// LOAD AND NEW // LOAD AND NEW
$DATA['load'] = $form->formCreateLoad(); $DATA['load'] = $form->form_create_load();
$DATA['new'] = $form->formCreateNew(); $DATA['new'] = $form->form_create_new();
// SHOW DATA PART // SHOW DATA PART
if ($form->yes) { if ($form->yes) {
$DATA['form_yes'] = $form->yes; $DATA['form_yes'] = $form->yes;
$DATA['form_my_page_name'] = $form->my_page_name; $DATA['form_my_page_name'] = $form->my_page_name;
// depending on the "getPageName()" I show different stuff // depending on the "get_page_name()" I show different stuff
switch ($form->my_page_name) { switch ($form->my_page_name) {
case "edit_users": case "edit_users":
$elements[] = $form->formCreateElement("login_error_count"); $elements[] = $form->form_create_element("login_error_count");
$elements[] = $form->formCreateElement("login_error_date_last"); $elements[] = $form->form_create_element("login_error_date_last");
$elements[] = $form->formCreateElement("login_error_date_first"); $elements[] = $form->form_create_element("login_error_date_first");
$elements[] = $form->formCreateElement("enabled"); $elements[] = $form->form_create_element("enabled");
$elements[] = $form->formCreateElement("username"); $elements[] = $form->form_create_element("username");
$elements[] = $form->formCreateElement("password"); $elements[] = $form->form_create_element("password");
$elements[] = $form->formCreateElement("password_change_interval"); $elements[] = $form->form_create_element("password_change_interval");
$elements[] = $form->formCreateElement("email"); $elements[] = $form->form_create_element("email");
$elements[] = $form->formCreateElement("last_name"); $elements[] = $form->form_create_element("last_name");
$elements[] = $form->formCreateElement("first_name"); $elements[] = $form->form_create_element("first_name");
$elements[] = $form->formCreateElement("edit_group_id"); $elements[] = $form->form_create_element("edit_group_id");
$elements[] = $form->formCreateElement("edit_access_right_id"); $elements[] = $form->form_create_element("edit_access_right_id");
$elements[] = $form->formCreateElement("strict"); $elements[] = $form->form_create_element("strict");
$elements[] = $form->formCreateElement("locked"); $elements[] = $form->form_create_element("locked");
$elements[] = $form->formCreateElement("admin"); $elements[] = $form->form_create_element("admin");
$elements[] = $form->formCreateElement("debug"); $elements[] = $form->form_create_element("debug");
$elements[] = $form->formCreateElement("db_debug"); $elements[] = $form->form_create_element("db_debug");
$elements[] = $form->formCreateElement("edit_language_id"); $elements[] = $form->form_create_element("edit_language_id");
$elements[] = $form->formCreateElement("edit_scheme_id"); $elements[] = $form->form_create_element("edit_scheme_id");
$elements[] = $form->formCreateElementListTable("edit_access_user"); $elements[] = $form->form_show_list_table("edit_access_user");
break; break;
case "edit_schemes": case "edit_schemes":
$elements[] = $form->formCreateElement("enabled"); $elements[] = $form->form_create_element("enabled");
$elements[] = $form->formCreateElement("name"); $elements[] = $form->form_create_element("name");
$elements[] = $form->formCreateElement("header_color"); $elements[] = $form->form_create_element("header_color");
$elements[] = $form->formCreateElement("template"); $elements[] = $form->form_create_element("template");
break; break;
case "edit_pages": case "edit_pages":
if (!$form->table_array["edit_page_id"]["value"]) { if (!$form->table_array["edit_page_id"]["value"]) {
$q = "DELETE FROM temp_files"; $q = "DELETE FROM temp_files";
$form->dbExec($q); $form->db_exec($q);
// gets all files in the current dir ending with .php // gets all files in the current dir ending with .php
$crap = exec("ls *.php", $output, $status); $crap = exec("ls *.php", $output, $status);
// now get all that are NOT in de DB // now get all that are NOT in de DB
$q = "INSERT INTO temp_files VALUES "; $q = "INSERT INTO temp_files VALUES ";
for ($i = 0; $i < count($output); $i ++) { for ($i = 0; $i < count($output); $i ++) {
$t_q = "('".$form->dbEscapeString($output[$i])."')"; $t_q = "('".$form->db_escape_string($output[$i])."')";
$form->dbExec($q.$t_q, 'NULL'); $form->db_exec($q.$t_q, 'NULL');
} }
$elements[] = $form->formCreateElement("filename"); $elements[] = $form->form_create_element("filename");
} else { } else {
// show file menu // show file menu
// just show name of file ... // just show name of file ...
$DATA['filename_exist'] = 1; $DATA['filename_exist'] = 1;
$DATA['filename'] = $form->table_array["filename"]["value"]; $DATA['filename'] = $form->table_array["filename"]["value"];
} // File Name View IF } // File Name View IF
$elements[] = $form->formCreateElement("name"); $elements[] = $form->form_create_element("name");
// $elements[] = $form->formCreateElement("tag"); // $elements[] = $form->form_create_element("tag");
// $elements[] = $form->formCreateElement("min_acl"); // $elements[] = $form->form_create_element("min_acl");
$elements[] = $form->formCreateElement("order_number"); $elements[] = $form->form_create_element("order_number");
$elements[] = $form->formCreateElement("online"); $elements[] = $form->form_create_element("online");
$elements[] = $form->formCreateElement("menu"); $elements[] = $form->form_create_element("menu");
$elements[] = $form->formCreateElementListTable("edit_query_string"); $elements[] = $form->form_show_list_table("edit_query_string");
$elements[] = $form->formCreateElement("popup"); $elements[] = $form->form_create_element("popup");
$elements[] = $form->formCreateElement("popup_x"); $elements[] = $form->form_create_element("popup_x");
$elements[] = $form->formCreateElement("popup_y"); $elements[] = $form->form_create_element("popup_y");
$elements[] = $form->formCreateElementReferenceTable("edit_visible_group"); $elements[] = $form->form_show_reference_table("edit_visible_group");
$elements[] = $form->formCreateElementReferenceTable("edit_menu_group"); $elements[] = $form->form_show_reference_table("edit_menu_group");
break; break;
case "edit_languages": case "edit_languages":
$elements[] = $form->formCreateElement("enabled"); $elements[] = $form->form_create_element("enabled");
$elements[] = $form->formCreateElement("short_name"); $elements[] = $form->form_create_element("short_name");
$elements[] = $form->formCreateElement("long_name"); $elements[] = $form->form_create_element("long_name");
$elements[] = $form->formCreateElement("iso_name"); $elements[] = $form->form_create_element("iso_name");
break; break;
case "edit_groups": case "edit_groups":
$elements[] = $form->formCreateElement("enabled"); $elements[] = $form->form_create_element("enabled");
$elements[] = $form->formCreateElement("name"); $elements[] = $form->form_create_element("name");
$elements[] = $form->formCreateElement("edit_access_right_id"); $elements[] = $form->form_create_element("edit_access_right_id");
$elements[] = $form->formCreateElement("edit_scheme_id"); $elements[] = $form->form_create_element("edit_scheme_id");
$elements[] = $form->formCreateElementListTable("edit_page_access"); $elements[] = $form->form_show_list_table("edit_page_access");
break; break;
case "edit_visible_group": case "edit_visible_group":
$elements[] = $form->formCreateElement("name"); $elements[] = $form->form_create_element("name");
$elements[] = $form->formCreateElement("flag"); $elements[] = $form->form_create_element("flag");
break; break;
case "edit_menu_group": case "edit_menu_group":
$elements[] = $form->formCreateElement("name"); $elements[] = $form->form_create_element("name");
$elements[] = $form->formCreateElement("flag"); $elements[] = $form->form_create_element("flag");
$elements[] = $form->formCreateElement("order_number"); $elements[] = $form->form_create_element("order_number");
break; break;
case "edit_access": case "edit_access":
$elements[] = $form->formCreateElement("name"); $elements[] = $form->form_create_element("name");
$elements[] = $form->formCreateElement("color"); $elements[] = $form->form_create_element("color");
$elements[] = $form->formCreateElement("description"); $elements[] = $form->form_create_element("description");
// add name/value list here // add name/value list here
$elements[] = $form->formCreateElementListTable("edit_access_data"); $elements[] = $form->form_show_list_table("edit_access_data");
break; break;
default: default:
print "[No valid page definition given]"; print "[No valid page definition given]";
break; break;
} }
// $form->debug('edit', "Elements: <pre>".$form->printAr($elements)); // $form->debug('edit', "Elements: <pre>".$form->print_ar($elements));
$DATA['elements'] = $elements; $DATA['elements'] = $elements;
$DATA['hidden'] = $form->formCreateHiddenFields(); $DATA['hidden'] = $form->form_create_hidden_fields();
$DATA['save_delete'] = $form->formCreateSaveDelete(); $DATA['save_delete'] = $form->form_create_save_delete();
} }
// debug data, if DEBUG flag is on, this data is print out // debug data, if DEBUG flag is on, this data is print out
@@ -304,19 +311,14 @@ $DEBUG_DATA['DEBUG'] = $DEBUG_TMPL;
// create main data array // create main data array
$CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA); $CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA);
// data is 1:1 mapping (all vars, values, etc) // data is 1:1 mapping (all vars, values, etc)
foreach ($CONTENT_DATA as $key => $value) { while (list($key, $value) = each($CONTENT_DATA)) {
$smarty->assign($key, $value); $smarty->assign($key, $value);
} }
if (is_dir(BASE.TEMPLATES_C)) {
$smarty->setCompileDir(BASE.TEMPLATES_C); // $smarty->assign('popup_page', 'mt_popup_'.$body_part.'.tpl');
}
if (is_dir(BASE.CACHE)) {
$smarty->setCacheDir(BASE.CACHE);
}
$smarty->display('edit_body.tpl'); $smarty->display('edit_body.tpl');
// debug output // debug output
echo $login->printErrorMsg(); echo $login->print_error_msg();
echo $form->printErrorMsg(); echo $form->print_error_msg();
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2001/07/11 * CREATED: 2001/07/11
@@ -17,32 +17,35 @@ extract($_GET, EXTR_SKIP);
extract($_POST, EXTR_SKIP); extract($_POST, EXTR_SKIP);
include("config.inc"); include("config.inc");
// set session name
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
// overrride debug flags // overrride debug flags
if (!DEBUG) { if (!DEBUG)
{
$DEBUG_ALL = 0; $DEBUG_ALL = 0;
$PRINT_ALL = 0; $PRINT_ALL = 0;
$DB_DEBUG = 0; $DB_DEBUG = 0;
$ECHO_ALL = 0; $ECHO_ALL = 0;
// $DEBUG_TMPL = 0;
} }
// set session name
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
require(LIBS."Class.Login.inc");
require(LIBS.'Class.Smarty.Extend.inc');
// default lang // default lang
if (!$lang) { if (!$lang)
$lang = DEFAULT_LANG; $lang = DEFAULT_LANG;
}
$table_width = 600; $table_width = 600;
if (!$table_width) { if (!$table_width)
$table_width = PAGE_WIDTH; $table_width = PAGE_WIDTH;
}
ob_end_flush(); ob_end_flush();
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang); $login = new login($DB_CONFIG[LOGIN_DB], $lang);
$db = new CoreLibs\DB\IO($DB_CONFIG[MAIN_DB]); $db = new db_io($DB_CONFIG[MAIN_DB]);
$db->dbExec("SET search_path TO ".LOGIN_DB_SCHEMA); $db->db_exec("SET search_path TO ".LOGIN_DB_SCHEMA);
$smarty = new CoreLibs\Template\SmartyExtend($lang); $smarty = new SmartyML($lang);
if (TARGET == 'live' || TARGET == 'remote') { if (TARGET == 'live' || TARGET == 'remote')
{
// login // login
$login->debug_output_all = DEBUG ? 1 : 0; $login->debug_output_all = DEBUG ? 1 : 0;
$login->echo_output_all = 0; $login->echo_output_all = 0;
@@ -53,11 +56,14 @@ if (TARGET == 'live' || TARGET == 'remote') {
$db->print_output_all = DEBUG ? 1 : 0; $db->print_output_all = DEBUG ? 1 : 0;
} }
// set the template dir // set the template dir
if (defined('LAYOUT')) { if (defined('LAYOUT'))
{
$smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES); $smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES);
$DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS; $DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS;
$DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS; $DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS;
} else { }
else
{
$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;
@@ -66,18 +72,18 @@ if (defined('LAYOUT')) {
// order name is _always_ order_number for the edit interface // order name is _always_ order_number for the edit interface
// follwing arrays do exist here: // follwing arrays do exist here:
// $position ... has the positions of the array (0..max), cause in a <select> // $position ... has the positions of the array (0..max), cause in a <select> I can't put an number into the array field, in this array, there are the POSITION stored, that should CHANGE there order (up/down)
// I can't put an number into the array field, in this array,
// there are the POSITION stored, that should CHANGE there order (up/down)
// $row_data_id ... has ALL ids from the sorting part // $row_data_id ... has ALL ids from the sorting part
// $row_data_order ... has ALL order positions from the soirting part // $row_data_order ... has ALL order positions from the soirting part
if (count($position)) { if (count($position))
{
$original_id = $row_data_id; $original_id = $row_data_id;
// FIRST u have to put right sort, then read again ... // FIRST u have to put right sort, then read again ...
// hast to be >0 or the first one is selected and then there is no move if ($up && $position[0] > 0) // hast to be >0 or the first one is selected and then there is no move
if ($up && $position[0] > 0) { {
for ($i = 0; $i < count($position); $i++) { for ($i = 0; $i < count($position); $i++)
{
// change position order // change position order
// this gets temp, id before that, gets actual (moves one "down") // this gets temp, id before that, gets actual (moves one "down")
// this gets the old before (moves one "up") // this gets the old before (moves one "up")
@@ -90,9 +96,10 @@ if (count($position)) {
} // for } // for
} // if up } // if up
// the last position id from position array is not to be the count-1 of row_data_id array, or it is the last element if ($down && ($position[count($position) - 1] != (count($row_data_id) - 1))) // the last position id from position array is not to be the count-1 of row_data_id array, or it is the last element
if ($down && ($position[count($position) - 1] != (count($row_data_id) - 1))) { {
for ($i = count($position) - 1; $i >= 0; $i --) { for ($i = count($position) - 1; $i >= 0; $i --)
{
// same as up, just up in other way, starts from bottom (last element) and moves "up" // same as up, just up in other way, starts from bottom (last element) and moves "up"
// element before actuel gets temp, this element, becomes element after this, // element before actuel gets temp, this element, becomes element after this,
// element after this, gets this // element after this, gets this
@@ -103,22 +110,26 @@ if (count($position)) {
} // if down } // if down
// write data ... (which has to be abstrackt ...) // write data ... (which has to be abstrackt ...)
if (($up && $position[0] > 0) || ($down && ($position[count($position) - 1]!=(count($row_data_id) - 1)))) { if (($up && $position[0] > 0) || ($down && ($position[count($position) - 1]!=(count($row_data_id) - 1))))
for ($i = 0; $i < count($row_data_id); $i ++) { {
for ($i = 0;$i < count($row_data_id); $i ++)
{
// $q="UPDATE broschueren SET broschuere_order=".$row_data_order[$i]." WHERE unique_id='".$row_data_id[$i]."'";
$q = "UPDATE ".$table_name." SET order_number = ".$row_data_order[$i]." WHERE ".$table_name."_id = ".$row_data_id[$i]; $q = "UPDATE ".$table_name." SET order_number = ".$row_data_order[$i]." WHERE ".$table_name."_id = ".$row_data_id[$i];
$q = $db->dbExec($q); //echo "Q: $q<br>";
$q = $db->db_exec($q);
} // for all article ids ... } // for all article ids ...
} // if write } // if write
} // if there is something to move } // if there is something to move
// get ... // get ...
$q = "SELECT ".$table_name."_id, name, order_number FROM ".$table_name." "; $q = "SELECT ".$table_name."_id, name, order_number FROM ".$table_name." ";
if ($where_string) { if ($where_string)
$q .= "WHERE $where_string "; $q .= "WHERE $where_string ";
}
$q .= "ORDER BY order_number"; $q .= "ORDER BY order_number";
while ($res = $db->dbReturn($q)) { while ($res = $db->db_return($q))
{
$row_data[] = array ( $row_data[] = array (
"id" => $res[$table_name."_id"], "id" => $res[$table_name."_id"],
"name" => $res["name"], "name" => $res["name"],
@@ -135,12 +146,13 @@ $HEADER['JS'] = JS;
$HEADER['STYLESHEET'] = $EDIT_STYLESHEET; $HEADER['STYLESHEET'] = $EDIT_STYLESHEET;
$HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT; $HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
// html title // html title
$HEADER['HTML_TITLE'] = (!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE); $HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE));
$DATA['table_width'] = $table_width; $DATA['table_width'] = $table_width;
// error msg // error msg
if ($error) { if ($error)
{
$messages[] = array('msg' => $msg, 'class' => 'error', 'width' => $table_width); $messages[] = array('msg' => $msg, 'class' => 'error', 'width' => $table_width);
} }
$DATA['form_error_msg'] = $messages; $DATA['form_error_msg'] = $messages;
@@ -149,17 +161,18 @@ $DATA['form_error_msg'] = $messages;
$options_id = array(); $options_id = array();
$options_name = array(); $options_name = array();
$options_selected = array(); $options_selected = array();
for ($i = 0; $i < count($row_data); $i ++) { for ($i = 0; $i < count($row_data); $i ++)
{
$options_id[] = $i; $options_id[] = $i;
$options_name[] = $row_data[$i]["name"]; $options_name[] = $row_data[$i]["name"];
// list of points to order // list of points to order
for ($j = 0; $j < count($position); $j++) { for ($j = 0; $j < count($position); $j++)
{
// if matches, put into select array // if matches, put into select array
if ($original_id[$position[$j]] == $row_data[$i]["id"]) { if ($original_id[$position[$j]] == $row_data[$i]["id"])
$options_selected[] = $i; $options_selected[] = $i;
} }
} }
}
$DATA['options_id'] = $options_id; $DATA['options_id'] = $options_id;
$DATA['options_name'] = $options_name; $DATA['options_name'] = $options_name;
$DATA['options_selected'] = $options_selected; $DATA['options_selected'] = $options_selected;
@@ -167,7 +180,8 @@ $DATA['options_selected'] = $options_selected;
// hidden list for the data (id, order number) // hidden list for the data (id, order number)
$row_data_id = array(); $row_data_id = array();
$row_data_order = array(); $row_data_order = array();
for ($i = 0; $i < count($row_data); $i++) { for ($i = 0; $i < count($row_data); $i++)
{
$row_data_id[] = $row_data[$i]["id"]; $row_data_id[] = $row_data[$i]["id"];
$row_data_order[] = $row_data[$i]["order"]; $row_data_order[] = $row_data[$i]["order"];
} }
@@ -184,13 +198,12 @@ $DEBUG_DATA['DEBUG'] = $DEBUG_TMPL;
// create main data array // create main data array
$CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA); $CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA);
// data is 1:1 mapping (all vars, values, etc) // data is 1:1 mapping (all vars, values, etc)
while (list($key, $value) = each($CONTENT_DATA)) { while (list($key, $value) = each($CONTENT_DATA))
{
$smarty->assign($key, $value); $smarty->assign($key, $value);
} }
$smarty->display('edit_order.tpl'); $smarty->display('edit_order.tpl');
echo $login->printErrorMsg(); echo $login->print_error_msg();
echo $db->printErrorMsg(); echo $db->print_error_msg();
?>
# __END__

View File

@@ -11,8 +11,7 @@ if ($DEBUG_ALL) {
// sample config // sample config
require("config.inc"); require("config.inc");
echo "FILE: ".BASE.LIB."Error.Handling.inc<br>"; require(LIBS."Error.Handling.inc");
require(BASE.LIB."Error.Handling.inc");
if ($var) { if ($var) {
echo "OUT<br>"; echo "OUT<br>";

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2005/07/13 * CREATED: 2005/07/13
@@ -52,9 +52,6 @@ if (!$show_type) {
$show_type = 'P'; $show_type = 'P';
} }
// set edit access array
$edit_access_ids = array_keys($cms->user_unit);
// yes no list (online) // yes no list (online)
$yesno_list['f'] = 'No'; $yesno_list['f'] = 'No';
$yesno_list['t'] = 'Yes'; $yesno_list['t'] = 'Yes';
@@ -205,10 +202,10 @@ if ($cms->action == 'save') {
$file = DEV_SCHEMA."_".$file_uid; $file = DEV_SCHEMA."_".$file_uid;
// now upload the file // now upload the file
if ($_FILES['file_up']['name']) { if ($_FILES['file_up']['name']) {
$upload_file = BASE.MEDIA.$cms->data_path[$file_type].$file; $upload_file = ROOT.MEDIA.$cms->data_path[$file_type].$file;
// wipe out any old tmp data for this new upload // wipe out any old tmp data for this new upload
if (is_array(glob(BASE.TMP."thumb_".$file."*"))) { if (is_array(glob(ROOT.TMP."thumb_".$file."*"))) {
foreach (glob(BASE.TMP."thumb_".$file."*") as $filename) { foreach (glob(ROOT.TMP."thumb_".$file."*") as $filename) {
@unlink($filename); @unlink($filename);
} }
} }
@@ -216,7 +213,7 @@ if ($cms->action == 'save') {
$error = move_uploaded_file($_FILES['file_up']['tmp_name'], $upload_file); $error = move_uploaded_file($_FILES['file_up']['tmp_name'], $upload_file);
$cms->debug('file_upload', "UP: $upload_file"); $cms->debug('file_upload', "UP: $upload_file");
$cms->debug('file_upload', "Orig: ".$cms->printAr($_FILES['file_up'])); $cms->debug('file_upload', "Orig: ".$cms->print_ar($_FILES['file_up']));
// because I get bogus error info from move_uploaded_file ... // because I get bogus error info from move_uploaded_file ...
$error = 0; $error = 0;
@@ -245,7 +242,7 @@ if ($cms->action == 'save') {
} }
$q .= ") VALUES ('".$cms->queue_name."', '".$file_uid."', 'file_uid', '".$sql_action."', 'file', '".$cms->db_escape_string($sql_data)."', '".$cms->queue_key."', '".$cms->action."'"; $q .= ") VALUES ('".$cms->queue_name."', '".$file_uid."', 'file_uid', '".$sql_action."', 'file', '".$cms->db_escape_string($sql_data)."', '".$cms->queue_key."', '".$cms->action."'";
if ($_FILES['file_up']['name']) { if ($_FILES['file_up']['name']) {
$q .= ", '".BASE.MEDIA.$cms->data_path[$file_type].$file."#".BASE.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."'"; $q .= ", '".ROOT.MEDIA.$cms->data_path[$file_type].$file."#".ROOT.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."'";
} }
$q .= ")"; $q .= ")";
$cms->db_exec($q); $cms->db_exec($q);
@@ -265,16 +262,9 @@ if ($cms->action == 'delete' && $cms->action_yes == 'true') {
} }
if (QUEUE == 'live_queue') { if (QUEUE == 'live_queue') {
$q = "INSERT INTO ".GLOBAL_DB_SCHEMA.".live_queue (queue_key, key_value, key_name, type, target, data, group_key, action, file) VALUES ("; $q = "INSERT INTO ".GLOBAL_DB_SCHEMA.".live_queue (queue_key, key_value, key_name, type, target, data, group_key, action, file) VALUES (";
$q .= "'".$cms->queue_name."', '".$file_uid."', 'file_uid', 'DELETE', 'file', '', '".$cms->queue_key."', '".$cms->action."', '". $q .= "'".$cms->queue_name."', '".$file_uid."', 'file_uid', 'DELETE', 'file', '', '".$cms->queue_key."', '".$cms->action."', '".ROOT.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."')";
$q .= BASE.MEDIA.$cms->data_path[$file_type].PUBLIC_SCHEMA."_".$file_uid."')";
}
@unlink(BASE.MEDIA.$cms->data_path[$file_type].DEV_SCHEMA."_".$file_uid);
// wipe out any old cache data for this new upload
if (is_array(glob($cms->cache_pictures."thumb_".TEST_SCHEMA."_".$file_uid."*"))) {
foreach (glob($cms->cache_pictures."thumb_".TEST_SCHEMA."_".$file_uid."*") as $filename) {
@unlink($filename);
}
} }
@unlink(ROOT.MEDIA.$cms->data_path[$file_type].DEV_SCHEMA."_".$file_uid);
unset($file_uid); unset($file_uid);
unset($file_id); unset($file_id);
$delete_done = 1; $delete_done = 1;
@@ -306,13 +296,7 @@ if ($cms->action_flag == 'set_live' && $cms->action = 'set_delete') {
while ($res = $cms->db_return($q)) { while ($res = $cms->db_return($q)) {
$q_del = "DELETE FROM ".PUBLIC_SCHEMA.".file WHERE file_uid = '".$res['pkid'].'"'; $q_del = "DELETE FROM ".PUBLIC_SCHEMA.".file WHERE file_uid = '".$res['pkid'].'"';
$cms->db_exec($q_del); $cms->db_exec($q_del);
@unlink(BASE.MEDIA.$cms->data_path[$res['type']].PUBLIC_SCHEMA."_".$res['file_uid']); @unlink(ROOT.MEDIA.$cms->data_path[$res['type']].PUBLIC_SCHEMA."_".$res['file_uid']);
// wipe out any old cache data for this new upload
if (is_array(glob($cms->cache_pictures."thumb_".LIVE_SCHEMA."_".$file_uid."*"))) {
foreach (glob($cms->cache_pictures."thumb_".LIVE_SCHEMA."_".$file_uid."*") as $filename) {
@unlink($filename);
}
}
} }
$q = "DELETE FROM ".LOGIN_DB_SCHEMA.".set_live WHERE table_name = '".$cms->page_name."' AND delete_flag = 't'"; $q = "DELETE FROM ".LOGIN_DB_SCHEMA.".set_live WHERE table_name = '".$cms->page_name."' AND delete_flag = 't'";
$cms->db_exec($q); $cms->db_exec($q);
@@ -320,21 +304,13 @@ if ($cms->action_flag == 'set_live' && $cms->action = 'set_delete') {
if (DEV_SCHEMA != PUBLIC_SCHEMA) { if (DEV_SCHEMA != PUBLIC_SCHEMA) {
// read out possible deleted, to add "delete from live" // read out possible deleted, to add "delete from live"
$q = "SELECT pkid FROM ".LOGIN_DB_SCHEMA.".set_live WHERE table_name = '".$cms->page_name."' AND delete_flag = 't'"; $q = "SELECT pkid FROM ".LOGIN_DB_SCHEMA.".set_live WHERE table_name = '".$cms->page_name."' AND delete_flag = 't'";
if ($cms->access_rights['base_acl'] < 90) {
$q .= "AND edit_access_id IN (".join(',', $edit_access_ids).") ";
}
while ($res = $cms->db_return($q, 3)) { while ($res = $cms->db_return($q, 3)) {
$cms->DATA['set_delete'][]['pkid'] = $res['pkid']; $cms->DATA['set_delete'][]['pkid'] = $res['pkid'];
} }
} }
// get th max entries // get th max entries
$q = "SELECT COUNT(file_uid) FROM file "; $q = "SELECT COUNT(file_uid) FROM file ";
$q_search_where = "WHERE "; $q_search_where = "WHERE type in ('".str_replace(',', "','", $show_type)."') ";
// only for current edit_access id, unless it is an admin user, then he can see all of them
if ($cms->access_rights['base_acl'] < 90) {
$q_search_where .= "edit_access_id IN (".join(',', $edit_access_ids).") AND ";
}
$q_search_where .= "type in ('".str_replace(',', "','", $show_type)."') ";
if ($search_what) { if ($search_what) {
$q_search_where .= "AND LOWER(name_en) LIKE '%".addslashes(strtolower($search_what))."%' OR name_ja LIKE '%".addslashes($search_what)."%' OR LOWER(file_name) LIKE '%".addslashes(strtolower($search_what))."%' "; $q_search_where .= "AND LOWER(name_en) LIKE '%".addslashes(strtolower($search_what))."%' OR name_ja LIKE '%".addslashes($search_what)."%' OR LOWER(file_name) LIKE '%".addslashes(strtolower($search_what))."%' ";
} }

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2008/08/14 * CREATED: 2008/08/14
@@ -8,5 +8,5 @@
*********************************************************************/ *********************************************************************/
// print debug messages // print debug messages
echo $login->printErrorMsg(); echo $login->print_error_msg();
echo $cms->printErrorMsg(); echo $cms->print_error_msg();

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2008/08/01 * CREATED: 2008/08/01
@@ -23,6 +23,11 @@ extract($_POST, EXTR_SKIP);
// set output to quiet for load of classes & session settings // set output to quiet for load of classes & session settings
ob_start(); ob_start();
require("config.inc"); require("config.inc");
// login class, DB connections & Admin class, Smarty extension
foreach (array ('Login', 'Admin.Backend', 'Smarty.Extend') as $class) {
_spl_autoload('Class.'.$class.'.inc');
}
//------------------------------ library include end //------------------------------ library include end
//------------------------------ basic variable settings start //------------------------------ basic variable settings start
@@ -45,19 +50,21 @@ if (array_key_exists('action', $_POST) && $_POST['action'] != 'download_csv') {
//------------------------------ class init start //------------------------------ class init start
// login & page access check // login & page access check
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang); $login = new login($DB_CONFIG[LOGIN_DB], $lang);
// post login lang check // post login lang check
if ($_SESSION['DEFAULT_LANG']) { if ($_SESSION['DEFAULT_LANG']) {
$lang = $_SESSION['DEFAULT_LANG']; $lang = $_SESSION['DEFAULT_LANG'];
} }
// create smarty object // create smarty object
$smarty = new CoreLibs\Template\SmartyExtend($lang); $smarty = new SmartyML($lang);
// create new DB class // create new DB class
$cms = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang); $cms = new AdminBackend($DB_CONFIG[MAIN_DB], $lang);
// set search path to the default DB schema
$cms->db_exec("SET search_path TO ".DB_SCHEMA);
// the menu show flag (what menu to show) // the menu show flag (what menu to show)
$cms->menu_show_flag = 'main'; $cms->menu_show_flag = 'main';
// db nfo // db nfo
$cms->dbInfo(); $cms->db_info();
// set acl // set acl
$cms->acl = $login->acl; $cms->acl = $login->acl;
//------------------------------ class init end //------------------------------ class init end

1
www/admin/libs Symbolic link
View File

@@ -0,0 +1 @@
../libs/

1
www/admin/log Symbolic link
View File

@@ -0,0 +1 @@
../log/

View File

@@ -1,42 +0,0 @@
<?php
declare(strict_types=1);
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = 1;
$PRINT_ALL = 1;
$DB_DEBUG = 1;
// namespace test
ob_start();
// admin class tests
require 'config.inc' ;
DEFINE('SET_SESSION_NAME', EDIT_SESSION_NAME);
echo "DIR: ".DIR."<br>ROOT: ".ROOT."<br>BASE: ".BASE."<br>";
$lang = 'ja_utf8';
$base = new CoreLibs\Admin\Backend($DB_CONFIG[MAIN_DB], $lang);
ob_end_flush();
print "Start time: ".$base->runningTime()."<br>";
print "ByteStringFormat: ".$base->ByteStringFormat(1234567.12)."<br>";
print "byteStringFormat: ".$base->byteStringFormat(1234567.12)."<br>";
print "get_page_name [DEPRECATED]: ".$base->get_page_name()."<br>";
print "getPageName: ".$base->getPageName()."<br>";
print "DB Info: ".$base->dbInfo(1)."<br>";
print "End Time: ".$base->runningTime()."<br>";
print "Run Time: ".$base->runningTime()."<br>";
$base->resetRunningtime();
print "Lang: ".$base->l->__getLang().", MO File: ".$base->l->__getMoFile()."<br>";
print "Translate test: Year -> ".$base->l->__('Year')."<br>";
// end error print
print $base->printErrorMsg();
# __END__

View File

@@ -1,23 +0,0 @@
<?php
namespace Foo;
class FooBar
{
public $foo = '';
public function __construct()
{
$this->foo = 'BAR';
}
public function otherBarBar($wrong)
{
echo "B: $wrong<br>";
}
public function barBar($wrong)
{
echo "B: $wrong<br>";
}
}

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2007/09/03 * CREATED: 2007/09/03
@@ -15,7 +15,7 @@ if ($_SESSION['TEMPLATE']) {
} else { } else {
$TEMPLATE = DEFAULT_TEMPLATE; $TEMPLATE = DEFAULT_TEMPLATE;
} }
$TEMPLATE_DIR = $TEMPLATE; $TEMPLATE_DIR = $TEMPLATE.'/';
// master template // master template
if (!$MASTER_TEMPLATE_NAME) { if (!$MASTER_TEMPLATE_NAME) {
$MASTER_TEMPLATE_NAME = MASTER_TEMPLATE_NAME; $MASTER_TEMPLATE_NAME = MASTER_TEMPLATE_NAME;
@@ -41,7 +41,7 @@ $lang_short = substr($lang, 0, 2);
$CONTENT_INCLUDE = str_replace(".php", ".tpl", $cms->page_name); $CONTENT_INCLUDE = str_replace(".php", ".tpl", $cms->page_name);
$FORM_NAME = !isset($FORM_NAME) || !$FORM_NAME ? str_replace(".php", "", $cms->page_name) : $FORM_NAME; $FORM_NAME = !isset($FORM_NAME) || !$FORM_NAME ? str_replace(".php", "", $cms->page_name) : $FORM_NAME;
// set local page title // set local page title
$L_TITLE = ucfirst(str_replace('_', ' ', $cms->getPageName(1))).' - '.$G_TITLE; $L_TITLE = ucfirst(str_replace('_', ' ', $cms->get_page_name(1))).' - '.$G_TITLE;
// strip tpl and replace it with inc // strip tpl and replace it with inc
// php include file per page // php include file per page
$cms->INC_TEMPLATE_NAME = str_replace(".tpl", ".inc", $CONTENT_INCLUDE); $cms->INC_TEMPLATE_NAME = str_replace(".tpl", ".inc", $CONTENT_INCLUDE);
@@ -55,13 +55,13 @@ $cms->CSS_SPECIAL_TEMPLATE_NAME = @$CSS_NAME;
$cms->JS_SPECIAL_TEMPLATE_NAME = @$JS_NAME; $cms->JS_SPECIAL_TEMPLATE_NAME = @$JS_NAME;
// set basic template path (tmp) // set basic template path (tmp)
$smarty->setTemplateDir(LAYOUT.$TEMPLATE_DIR.TEMPLATES); $smarty->setTemplateDir(LAYOUT.$TEMPLATE_DIR.TEMPLATES.'/');
$cms->lang_dir = LAYOUT.$TEMPLATE_DIR.LANG; $cms->lang_dir = LAYOUT.$TEMPLATE_DIR.LANG."/";
$cms->includes = LAYOUT.$TEMPLATE_DIR.INCLUDES; $cms->includes = LAYOUT.$TEMPLATE_DIR.INCLUDES."/";
$cms->javascript = LAYOUT.$TEMPLATE_DIR.JS; $cms->javascript = LAYOUT.$TEMPLATE_DIR.JS."/";
$cms->css = LAYOUT.$TEMPLATE_DIR.CSS; $cms->css = LAYOUT.$TEMPLATE_DIR.CSS."/";
$cms->pictures = LAYOUT.$TEMPLATE_DIR.IMAGES; $cms->pictures = LAYOUT.$TEMPLATE_DIR.IMAGES."/";
$cms->cache_pictures = LAYOUT.$TEMPLATE_DIR.CACHE.IMAGES; $cms->cache_pictures = LAYOUT.$TEMPLATE_DIR.CACHE.IMAGES.'/';
$cms->cache_pictures_root = ROOT.$cms->cache_pictures; $cms->cache_pictures_root = ROOT.$cms->cache_pictures;
if (!is_dir($cms->cache_pictures_root)) { if (!is_dir($cms->cache_pictures_root)) {
mkdir($cms->cache_pictures_root); mkdir($cms->cache_pictures_root);
@@ -69,13 +69,13 @@ if (!is_dir($cms->cache_pictures_root)) {
$template_set = $TEMPLATE; $template_set = $TEMPLATE;
// if we don't find the master template, set the template path back AND set the insert template as absolute path // if we don't find the master template, set the template path back AND set the insert template as absolute path
if (!file_exists(ROOT.$smarty->getTemplateDir()[0].DS.MASTER_TEMPLATE_NAME)) { if (!file_exists(ROOT.$smarty->getTemplateDir()[0]."/".MASTER_TEMPLATE_NAME)) {
if (file_exists(ROOT.$smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) { if (file_exists(ROOT.$smarty->getTemplateDir()[0]."/".$TEMPLATE_NAME)) {
$TEMPLATE_NAME = ROOT.$smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME; $TEMPLATE_NAME = ROOT.$smarty->getTemplateDir()[0]."/".$TEMPLATE_NAME;
} }
$smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES); $smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES);
$template_set = DEFAULT_TEMPLATE; $template_set = DEFAULT_TEMPLATE;
} elseif (!file_exists(ROOT.$smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) { } elseif (!file_exists(ROOT.$smarty->getTemplateDir()[0]."/".$TEMPLATE_NAME)) {
// check if the template exists in the template path, if not, set path to to default // check if the template exists in the template path, if not, set path to to default
$smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES); $smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES);
$template_set = DEFAULT_TEMPLATE; $template_set = DEFAULT_TEMPLATE;
@@ -85,25 +85,25 @@ if (!file_exists(ROOT.$smarty->getTemplateDir()[0].DS.MASTER_TEMPLATE_NAME)) {
// check if the javascript folder exists in the template path, if not fall back to default // check if the javascript folder exists in the template path, if not fall back to default
if (!is_dir($cms->javascript)) { if (!is_dir($cms->javascript)) {
$cms->javascript = LAYOUT.DEFAULT_TEMPLATE.JS; $cms->javascript = LAYOUT.DEFAULT_TEMPLATE.JS."/";
} }
// check if lang_dir folder exists in the template path, if not fall back to default // check if lang_dir folder exists in the template path, if not fall back to default
if (!is_dir($cms->lang_dir)) { if (!is_dir($cms->lang_dir)) {
$cms->lang_dir = LAYOUT.DEFAULT_TEMPLATE.LANG; $cms->lang_dir = LAYOUT.DEFAULT_TEMPLATE.LANG."/";
} }
// check if include folder exists in the template path, if not fall back to default // check if include folder exists in the template path, if not fall back to default
if (!is_dir($cms->includes)) { if (!is_dir($cms->includes)) {
$cms->includes = LAYOUT.DEFAULT_TEMPLATE.INCLUDES; $cms->includes = LAYOUT.DEFAULT_TEMPLATE.INCLUDES."/";
} }
// check if css folder exists in the template path, if not fall back to default // check if css folder exists in the template path, if not fall back to default
if (!is_dir($cms->css)) { if (!is_dir($cms->css)) {
$cms->css = LAYOUT.DEFAULT_TEMPLATE.CSS; $cms->css = LAYOUT.DEFAULT_TEMPLATE.CSS."/";
} }
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
@@ -117,5 +117,3 @@ if (false === strstr(LAYOUT.DEFAULT_TEMPLATE.LANG, $cms->lang_dir) || strcasecmp
// $cms->debug("LANGUAGE", "L: $lang | ".$cms->lang_dir." | MO File: ".$cms->l->mofile); // $cms->debug("LANGUAGE", "L: $lang | ".$cms->lang_dir." | MO File: ".$cms->l->mofile);
$cms->debug("LANGUAGE", "SL: ".$_SESSION['DEFAULT_CHARSET']." | ".$_SESSION['LANG']." | ".$_SESSION['DEFAULT_LANG']); $cms->debug("LANGUAGE", "SL: ".$_SESSION['DEFAULT_CHARSET']." | ".$_SESSION['LANG']." | ".$_SESSION['DEFAULT_LANG']);
$cms->debug("TEMPLATE", "P: ".$smarty->getTemplateDir()[0]); $cms->debug("TEMPLATE", "P: ".$smarty->getTemplateDir()[0]);
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2005/07/12 * CREATED: 2005/07/12
@@ -84,21 +84,13 @@ $cms->DATA['LANG'] = $lang;
$cms->DATA['TINYMCE_LANG'] = $lang_short; $cms->DATA['TINYMCE_LANG'] = $lang_short;
// debug data, if DEBUG flag is on, this data is print out // debug data, if DEBUG flag is on, this data is print out
$cms->DEBUG_DATA['debug_error_msg'] = $cms->runningTime(); $cms->DEBUG_DATA['debug_error_msg'] = $cms->running_time();
$cms->DEBUG_DATA['DEBUG'] = @$DEBUG_TMPL; $cms->DEBUG_DATA['DEBUG'] = @$DEBUG_TMPL;
// create main data array // create main data array
$cms->CONTENT_DATA = array_merge($cms->HEADER, $cms->DATA, $cms->DEBUG_DATA); $cms->CONTENT_DATA = array_merge($cms->HEADER, $cms->DATA, $cms->DEBUG_DATA);
// data is 1:1 mapping (all vars, values, etc) // data is 1:1 mapping (all vars, values, etc)
foreach ($cms->CONTENT_DATA as $key => $value) { while (list($key, $value) = each($cms->CONTENT_DATA)) {
$smarty->assign($key, $value); $smarty->assign($key, $value);
} }
if (is_dir(BASE.TEMPLATES_C)) {
$smarty->setCompileDir(BASE.TEMPLATES_C);
}
if (is_dir(BASE.CACHE)) {
$smarty->setCacheDir(BASE.CACHE);
}
$smarty->display($MASTER_TEMPLATE_NAME, $TEMPLATE.$lang, $TEMPLATE.$lang); $smarty->display($MASTER_TEMPLATE_NAME, $TEMPLATE.$lang, $TEMPLATE.$lang);
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$ENABLE_ERROR_HANDLING = 0; $ENABLE_ERROR_HANDLING = 0;
$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations $DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = 1; $DEBUG_ALL = 1;

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_access = array ( $edit_access = array (
"table_array" => array ( "table_array" => array (
"edit_access_id" => array ( "edit_access_id" => array (
@@ -74,5 +74,3 @@ $edit_access = array (
) )
) )
); );
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_groups = array ( $edit_groups = array (
"table_array" => array ( "table_array" => array (
"edit_group_id" => array ( "edit_group_id" => array (
@@ -97,5 +97,3 @@ $edit_groups = array (
) // edit pages ggroup ) // edit pages ggroup
) )
); );
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_languages=array ( $edit_languages=array (
"table_array" => array ( "table_array" => array (
"edit_language_id" => array ( "edit_language_id" => array (
@@ -70,5 +70,3 @@ $edit_languages=array (
), ),
"table_name" => "edit_language" "table_name" => "edit_language"
); );
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_menu_group = array ( $edit_menu_group = array (
"table_array" => array ( "table_array" => array (
"edit_menu_group_id" => array ( "edit_menu_group_id" => array (
@@ -35,5 +35,3 @@ $edit_menu_group = array (
) )
) )
); );
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_pages = array ( $edit_pages = array (
"table_array" => array ( "table_array" => array (
"edit_page_id" => array ( "edit_page_id" => array (
@@ -175,5 +175,3 @@ $edit_pages = array (
) // query_string element list ) // query_string element list
) // element list ) // element list
); );
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_schemes = array ( $edit_schemes = array (
"table_array" => array ( "table_array" => array (
"edit_scheme_id" => array ( "edit_scheme_id" => array (
@@ -53,4 +53,3 @@ $edit_schemes = array (
) )
); // main array ); // main array
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_users = array ( $edit_users = array (
"table_array" => array ( "table_array" => array (
"edit_user_id" => array ( "edit_user_id" => array (
@@ -251,5 +251,3 @@ $edit_users = array (
) // edit pages ggroup ) // edit pages ggroup
) )
); );
# __END__

View File

@@ -1,4 +1,4 @@
<?php <?
$edit_visible_group = array ( $edit_visible_group = array (
"table_array" => array ( "table_array" => array (
"edit_visible_group_id" => array ( "edit_visible_group_id" => array (
@@ -28,5 +28,3 @@ $edit_visible_group = array (
) )
) )
); );
# __END__

1
www/admin/templates_c Symbolic link
View File

@@ -0,0 +1 @@
../templates_c/

1
www/admin/tmp Symbolic link
View File

@@ -0,0 +1 @@
../tmp/

View File

@@ -1,6 +1,6 @@
<? <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/06/10 * CREATED: 2003/06/10
* SHORT DESCRIPTION: * SHORT DESCRIPTION:
* configuration file * configuration file
@@ -9,82 +9,79 @@
/************* 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>");
// set the session name // set the session name
define('SET_SESSION_NAME', EDIT_SESSION_NAME); define('SET_SESSION_NAME', EDIT_SESSION_NAME);
/************* LANGUAGE / ENCODING *******/ /************* LANGUAGE / ENCODING *******/
DEFINE('DEFAULT_LANG', 'en_utf8'); DEFINE('DEFAULT_LANG', "en_utf8");
// default web page encoding setting // default web page encoding setting
DEFINE('DEFAULT_ENCODING', 'UTF-8'); DEFINE('DEFAULT_ENCODING', "UTF-8");
/************* PATHS *********************/ /************* PATHS *********************/
// directory seperator
DEFINE('DS', DIRECTORY_SEPARATOR);
// ** NEW/BETTER DIR DECLARATIONS ** // ** NEW/BETTER DIR DECLARATIONS **
// path to original file (if symlink) // path to original file (if symlink)
DEFINE('DIR', __DIR__.DS); DEFINE('DIR', __DIR__."/");
// base dir root folder level // libs base path based on DIR
DEFINE('BASE', str_replace('configs', '', __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 ** // ** OLD DIR DECLARATIONS **
// path to document root of file called // path to document root of file called
DEFINE('ROOT', getcwd().DS); DEFINE('ROOT', getcwd()."/");
// libs path // libs path
DEFINE('LIB', 'lib'.DS); DEFINE('LIBS', "libs/");
DEFINE('LIBS', 'lib'.DS);
// includes (strings, arrays for static, etc) // includes (strings, arrays for static, etc)
DEFINE('INCLUDES', 'includes'.DS); DEFINE('INCLUDES', "includes/");
// layout base path // layout base path
DEFINE('LAYOUT', 'layout'.DS); DEFINE('LAYOUT', 'layout/');
// pic-root (compatible to CMS) // pic-root (compatible to CMS)
DEFINE('PICTURES', 'images'.DS); DEFINE('PICTURES', "images/");
// images // images
DEFINE('IMAGES', 'images'.DS); DEFINE('IMAGES', "images/");
// icons (below the images/ folder) // icons (below the images/ folder)
DEFINE('ICONS', 'icons'.DS); DEFINE('ICONS', 'icons/');
// media // media
DEFINE('MEDIA', 'media'.DS); DEFINE('MEDIA', "media/");
// flash-root (below media) // flash-root (below media)
DEFINE('FLASH', 'flash'.DS); DEFINE('FLASH', "flash/");
// uploads (anything to keep) // uploads (anything to keep)
DEFINE('UPLOADS', 'uploads'.DS); DEFINE('UPLOADS', "uploads/");
// files (binaries) (below media) // files (binaries) (below media)
DEFINE('BINARIES', 'binaries'.DS); DEFINE('BINARIES', "binaries/");
// files (videos) (below media) // files (videos) (below media)
DEFINE('VIDEOS', 'videos'.DS); DEFINE('VIDEOS', "videos/");
// files (documents) (below media) // files (documents) (below media)
DEFINE('DOCUMENTS', 'documents'.DS); DEFINE('DOCUMENTS', "documents/");
// files (pdfs) (below media) // files (pdfs) (below media)
DEFINE('PDFS', 'documents'.DS); DEFINE('PDFS', "documents/");
// CSV
DEFINE('CSV', 'csv'.DS);
// css // css
DEFINE('CSS', 'css'.DS); DEFINE('CSS', "css/");
// js // js
DEFINE('JS', 'javascript'.DS); DEFINE('JS', "javascript/");
// table arrays // table arrays
DEFINE('TABLE_ARRAYS', 'table_arrays'.DS); DEFINE('TABLE_ARRAYS', "table_arrays/");
// smarty libs path // smarty libs path
DEFINE('SMARTY', 'Smarty'.DS); DEFINE('SMARTY', "Smarty/");
// po langs // po langs
DEFINE('LANG', 'lang'.DS); DEFINE('LANG', "lang/");
// cache path // cache path
DEFINE('CACHE', 'cache'.DS); DEFINE('CACHE', "cache/");
// temp path // temp path
DEFINE('TMP', 'tmp'.DS); DEFINE('TMP', "tmp/");
// log files // log files
DEFINE('LOG', 'log'.DS); DEFINE('LOG', 'log/');
// compiled template folder
DEFINE('TEMPLATES_C', 'templates_c'.DS);
// template base // template base
DEFINE('TEMPLATES', 'templates'.DS); DEFINE('TEMPLATES', "templates/");
// frontend template dir', only for admin // frontend template dir', only for admin
DEFINE('TEMPLATES_FRONTEND', 'templates_frontend'.DS); DEFINE('TEMPLATES_FRONTEND', "templates_frontend/");
// default template // default template
DEFINE('DEFAULT_TEMPLATE', 'default'.DS); DEFINE('DEFAULT_TEMPLATE', "default/");
// default template file // default template file
DEFINE('DEFAULT_TEMPLATE_FILE', 'default.tpl'); DEFINE('DEFAULT_TEMPLATE_FILE', 'default.tpl');
@@ -102,14 +99,14 @@ DEFINE('DEFAULT_ACL_SEND', 70);
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', 'ssl.host.name'); // 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
// 3: if default template is not found, show error template, do not fall back to default tree // 3: if default template is not found, show error template, do not fall back to default tree
// 4: very strict, even on normal fixable errors through error // 4: very strict, even on normal fixable errors through error
// 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 seconds, 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
@@ -134,11 +131,6 @@ DEFINE('PAGE_WIDTH', 800);
// the default template name // the default template name
DEFINE('MASTER_TEMPLATE_NAME', 'main_body.tpl'); DEFINE('MASTER_TEMPLATE_NAME', 'main_body.tpl');
// below two can be defined here, but they should be
// defined in either the header file or the file itself
/************* LOGGING *******************/
// DEFINE('LOG_FILE_ID', '');
/************* QUEUE TABLE *************/ /************* QUEUE TABLE *************/
// if we have a dev/live system // if we have a dev/live system
// set_live is a per page/per item // set_live is a per page/per item
@@ -150,38 +142,37 @@ DEFINE('MASTER_TEMPLATE_NAME', 'main_body.tpl');
DEFINE('PUBLIC_SCHEMA', 'public'); DEFINE('PUBLIC_SCHEMA', 'public');
DEFINE('DEV_SCHEMA', 'public'); DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public'); DEFINE('TEST_SCHEMA', 'public');
DEFINE('LIVE_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 (
'<db id>' => array ( "<db id>" => array (
'db_name' => '<database>', "db_name" => "<database>",
'db_user' => '<user>', "db_user" => "<user>",
'db_pass' => '<password>', "db_pass" => "<password>",
'db_host' => '<host>', "db_host" => "<host>",
'db_port' => '5432', "db_port" => "5432",
'db_schema' => 'public', // if not set, uses 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
) )
); );
// File and Folder paths // File and Folder paths
// ID is TARGET (first array element) // ID is TARGET (first array element)
// $PATHS['test']['csv_path'] = ''; // $PATHS["test"]["csv_path"] = "";
// $PATHS['test']['perl_bin'] = ''; // $PATHS["test"]["perl_bin"] = "";
// $PATHS['test']['redirect_url'] = ''; // $PATHS["test"]["redirect_url"] = "";
// each host has a different db_host // each host has a different db_host
// development host // development host
$DB_HOST['<host>'] = '<db id>'; $DB_HOST['<host>'] = "<db id>";
// target host (live) // target host (live)
// $DB_TARGET_HOST['<host>'] = '<DB ID>'; // $DB_TARGET_HOST['<host>'] = "<DB ID>";
// url redirect database // url redirect database
// $DB_URL_REDIRECT_HOST['<host>'] = '<DB ID>'; // $DB_URL_REDIRECT_HOST['<host>'] = "<DB ID>";
// location flagging // location flagging
// test/dev/live // test/dev/live
$LOCATION['<host>'] = '<test|live|remote|etc>'; $LOCATION['<host>'] = '<test|live|remote|etc>';
@@ -197,9 +188,9 @@ $USE_DATABASE = defined('USE_DATABASE') ? USE_DATABASE : true;
// live frontend pages // live frontend pages
// ** missing live domains ** // ** missing live domains **
// get the name without the port // get the name without the port
list($HOST_NAME) = array_pad(explode(':', $_SERVER['HTTP_HOST'], 2), 2, null); list($HOST_NAME, $PORT) = array_pad(explode(":", $_SERVER['HTTP_HOST'], 2), 2, null);
if (!$DB_HOST[$HOST_NAME] && $USE_DATABASE) { if (!$DB_HOST[$HOST_NAME] && $USE_DATABASE) {
echo 'No matching DB config found. Contact Admin<br>'; echo "No matching DB config found. Contact Admin<br>";
exit -1; exit -1;
} }
@@ -226,11 +217,11 @@ DEFINE('SHOW_ALL_ERRORS', false); // show all errors if debug_all & show_error_h
$G_TITLE = '<OVERALL PAGE TITLE>'; $G_TITLE = '<OVERALL PAGE TITLE>';
/************ STYLE SHEETS / JS **********/ /************ STYLE SHEETS / JS **********/
$EDIT_STYLESHEET = 'edit.css'; $EDIT_STYLESHEET = "edit.css";
$EDIT_JAVASCRIPT = 'edit.js'; $EDIT_JAVASCRIPT = "edit.js";
$STYLESHEET = 'frontend.css'; $STYLESHEET = "frontend.css";
$JAVASCRIPT = 'frontend.js'; $JAVASCRIPT = "frontend.js";
/************* CONVERT *******************/ /************* CONVERT *******************/
$paths = array ( $paths = array (
@@ -240,14 +231,14 @@ $paths = array (
); );
// find convert // find convert
foreach ($paths as $path) { foreach ($paths as $path) {
if (file_exists($path.DS.'convert') && is_file($path.DS.'convert')) { if (file_exists($path."/convert") && is_file($path."/convert")) {
// image magick convert location // image magick convert location
DEFINE('CONVERT', $path.DS.'convert'); DEFINE('CONVERT', $path."/convert");
} }
} }
// turn off debug if debug flag is OFF // turn off debug if debug flag is OFF
if (defined('DEBUG') && DEBUG == false) { if (DEBUG == false) {
$ECHO_ALL = 0; $ECHO_ALL = 0;
$DEBUG_ALL = 0; $DEBUG_ALL = 0;
$PRINT_ALL = 0; $PRINT_ALL = 0;
@@ -258,7 +249,27 @@ if (defined('DEBUG') && DEBUG == false) {
// any other global definitons here // any other global definitons here
// DEFINE('SOME_ID', <SOME VALUE>); // DEFINE('SOME_ID', <SOME VALUE>);
// read auto loader // function that will be called on top of each class include to load the class
require BASE.LIB.'autoloader.php'; function _spl_autoload($include_file)
{
# __END__ // 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

@@ -1,6 +1,6 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/06/10 * CREATED: 2003/06/10
* SHORT DESCRIPTION: * SHORT DESCRIPTION:
* configuration file * configuration file
@@ -21,70 +21,67 @@ DEFINE('DEFAULT_LANG', "en_utf8");
DEFINE('DEFAULT_ENCODING', "UTF-8"); DEFINE('DEFAULT_ENCODING', "UTF-8");
/************* PATHS *********************/ /************* PATHS *********************/
// directory seperator
DEFINE('DS', DIRECTORY_SEPARATOR);
// ** NEW/BETTER DIR DECLARATIONS ** // ** NEW/BETTER DIR DECLARATIONS **
// path to original file (if symlink) // path to original file (if symlink)
DEFINE('DIR', __DIR__.DS); DEFINE('DIR', __DIR__."/");
// base dir root folder level // libs base path based on DIR
DEFINE('BASE', str_replace('configs', '', __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 ** // ** OLD DIR DECLARATIONS **
// path to document root of file called // path to document root of file called
DEFINE('ROOT', getcwd().DS); DEFINE('ROOT', getcwd()."/");
// libs path // libs path
DEFINE('LIB', 'lib'.DS); DEFINE('LIBS', "libs/");
DEFINE('LIBS', 'lib'.DS);
// includes (strings, arrays for static, etc) // includes (strings, arrays for static, etc)
DEFINE('INCLUDES', 'includes'.DS); DEFINE('INCLUDES', "includes/");
// layout base path // layout base path
DEFINE('LAYOUT', 'layout'.DS); DEFINE('LAYOUT', 'layout/');
// pic-root (compatible to CMS) // pic-root (compatible to CMS)
DEFINE('PICTURES', "images".DS); DEFINE('PICTURES', "images/");
// images // images
DEFINE('IMAGES', "images".DS); DEFINE('IMAGES', "images/");
// icons (below the images/ folder) // icons (below the images/ folder)
DEFINE('ICONS', 'icons'.DS); DEFINE('ICONS', 'icons/');
// media // media
DEFINE('MEDIA', "media".DS); DEFINE('MEDIA', "media/");
// flash-root (below media) // flash-root (below media)
DEFINE('FLASH', "flash".DS); DEFINE('FLASH', "flash/");
// uploads (anything to keep) // uploads (anything to keep)
DEFINE('UPLOADS', "uploads".DS); DEFINE('UPLOADS', "uploads/");
// files (binaries) (below media) // files (binaries) (below media)
DEFINE('BINARIES', "binaries".DS); DEFINE('BINARIES', "binaries/");
// files (videos) (below media) // files (videos) (below media)
DEFINE('VIDEOS', "videos".DS); DEFINE('VIDEOS', "videos/");
// files (documents) (below media) // files (documents) (below media)
DEFINE('DOCUMENTS', "documents".DS); DEFINE('DOCUMENTS', "documents/");
// files (pdfs) (below media) // files (pdfs) (below media)
DEFINE('PDFS', "documents".DS); DEFINE('PDFS', "documents/");
// CSV
DEFINE('CSV', 'csv'.DS);
// css // css
DEFINE('CSS', "css".DS); DEFINE('CSS', "css/");
// js // js
DEFINE('JS', "javascript".DS); DEFINE('JS', "javascript/");
// table arrays // table arrays
DEFINE('TABLE_ARRAYS', "table_arrays".DS); DEFINE('TABLE_ARRAYS', "table_arrays/");
// smarty libs path // smarty libs path
DEFINE('SMARTY', "Smarty".DS); DEFINE('SMARTY', "Smarty/");
// po langs // po langs
DEFINE('LANG', "lang".DS); DEFINE('LANG', "lang/");
// cache path // cache path
DEFINE('CACHE', "cache".DS); DEFINE('CACHE', "cache/");
// temp path // temp path
DEFINE('TMP', "tmp".DS); DEFINE('TMP', "tmp/");
// log files // log files
DEFINE('LOG', 'log'.DS); DEFINE('LOG', 'log/');
// compiled template folder
DEFINE('TEMPLATES_C', 'templates_c'.DS);
// template base // template base
DEFINE('TEMPLATES', "templates".DS); DEFINE('TEMPLATES', "templates/");
// frontend template dir', only for admin // frontend template dir', only for admin
DEFINE('TEMPLATES_FRONTEND', "templates_frontend".DS); DEFINE('TEMPLATES_FRONTEND', "templates_frontend/");
// default template // default template
DEFINE('DEFAULT_TEMPLATE', "default".DS); DEFINE('DEFAULT_TEMPLATE', "default/");
// default template file // default template file
DEFINE('DEFAULT_TEMPLATE_FILE', 'default.tpl'); DEFINE('DEFAULT_TEMPLATE_FILE', 'default.tpl');
@@ -145,7 +142,6 @@ DEFINE('MASTER_TEMPLATE_NAME', 'main_body.tpl');
DEFINE('PUBLIC_SCHEMA', 'public'); DEFINE('PUBLIC_SCHEMA', 'public');
DEFINE('DEV_SCHEMA', 'public'); DEFINE('DEV_SCHEMA', 'public');
DEFINE('TEST_SCHEMA', 'public'); DEFINE('TEST_SCHEMA', 'public');
DEFINE('LIVE_SCHEMA', 'public');
// non constant part // non constant part
/************* DB ACCESS *****************/ /************* DB ACCESS *****************/
@@ -253,7 +249,27 @@ if (DEBUG == false) {
// any other global definitons here // any other global definitons here
// DEFINE('SOME_ID', <SOME VALUE>); // DEFINE('SOME_ID', <SOME VALUE>);
// read auto loader // function that will be called on top of each class include to load the class
require BASE.LIB.'autoloader.php'; function _spl_autoload($include_file)
{
# __END__ // 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

@@ -272,7 +272,7 @@ input[type="text"]:focus, textarea:focus, select:focus {
} }
/* spacer for line break in float elements */ /* spacer for line break in float elements */
.clr, .spacer { .spacer {
clear: both; clear: both;
} }

View File

@@ -10,11 +10,11 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Project Version\n" "Project-Id-Version: Project Version\n"
"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n" "Report-Msgid-Bugs-To: clemens.schwaighofer@e-graphics.com\n"
"POT-Creation-Date: 2018-03-28 10:40+0900\n" "POT-Creation-Date: 2005-08-09 09:26+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@egplusww.com>\n" "Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@e-graphics.com>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"

View File

@@ -1,6 +1,6 @@
#******************************************************************** #********************************************************************
# AUTHOR: Clemens Schwaighofer # AUTHOR: Clemens Schwaighofer
# CREATED: 2018/03/28 # CREATED: 2007/04/18
# SHORT DESCRIPTION: # SHORT DESCRIPTION:
# Backend Japanese Messages file for gettext # Backend Japanese Messages file for gettext
# to craete: msgfmt -o ja.mo messages_ja.po # to craete: msgfmt -o ja.mo messages_ja.po
@@ -10,54 +10,14 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Project Version\n" "Project-Id-Version: Project Version\n"
"Report-Msgid-Bugs-To: clemens.schwaighofer@egplusww.com\n" "Report-Msgid-Bugs-To: clemens.schwaighofer@e-graphics.com\n"
"POT-Creation-Date: 2018-03-28 10:40+0900\n" "POT-Creation-Date: 2007-04-18 17:40+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@egplusww.com>\n" "Language-Team: E-GRAPHICS COMMUNICATIONS Japan <info.jp@e-graphics.com>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
msgid "Yes" msgid "Yes"
msgstr "はい" msgstr ""
msgid "No"
msgstr "いいえ"
# Basic date info
msgid "Year"
msgstr "年"
msgid "Month"
msgstr "月"
msgid "Day"
msgstr "日"
msgid "Hour"
msgstr "時"
msgid "Minute"
msgstr "分"
msgid "Mon"
msgstr "月"
msgid "Tue"
msgstr "火"
msgid "Wed"
msgstr "水"
msgid "Thu"
msgstr "木"
msgid "Fri"
msgstr "金"
msgid "Sat"
msgstr "土"
msgid "Sun"
msgstr "日"

View File

@@ -1,48 +0,0 @@
<?php
/*
Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
PHP-gettext is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHP-gettext; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace CoreLibs\Language\Core;
// Preloads entire file in memory first, then creates a StringReader
// over it (it assumes knowledge of StringReader internals)
class CachedFileReader extends CoreLibs\Language\Core\StringReader
{
public function __construct($filename)
{
if (file_exists($filename)) {
$length = filesize($filename);
$fd = fopen($filename, 'rb');
if (!$fd) {
$this->error = 3; // Cannot read file, probably permissions
return false;
}
$this->_str = fread($fd, $length);
fclose($fd);
} else {
$this->error = 2; // File doesn't exist
return false;
}
}
}
# __END__

View File

@@ -1,91 +0,0 @@
<?php
/*
Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
PHP-gettext is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHP-gettext; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace CoreLibs\Language\Core;
class FileReader
{
public $fr_pos;
public $fr_fd;
public $fr_length;
public function __construct($filename)
{
if (file_exists($filename)) {
$this->fr_length = filesize($filename);
$this->fr_pos = 0;
$this->fr_fd = fopen($filename, 'rb');
if (!$this->fr_fd) {
$this->error = 3; // Cannot read file, probably permissions
return false;
}
} else {
$this->error = 2; // File doesn't exist
return false;
}
}
public function read($bytes)
{
if ($bytes) {
fseek($this->fr_fd, $this->fr_pos);
// PHP 5.1.1 does not read more than 8192 bytes in one fread()
// the discussions at PHP Bugs suggest it's the intended behaviour
$data = '';
while ($bytes > 0) {
$chunk = fread($this->fr_fd, $bytes);
$data .= $chunk;
$bytes -= strlen($chunk);
}
$this->fr_pos = ftell($this->fr_fd);
return $data;
} else {
return '';
}
}
public function seekto($pos)
{
fseek($this->fr_fd, $pos);
$this->fr_pos = ftell($this->fr_fd);
return $this->fr_pos;
}
public function currentpos()
{
return $this->fr_pos;
}
public function length()
{
return $this->fr_length;
}
public function close()
{
fclose($this->fr_fd);
}
}
# __END__

View File

@@ -1,54 +0,0 @@
<?php
/*
Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
PHP-gettext is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHP-gettext; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace CoreLibs\Language\Core;
// Simple class to wrap file streams, string streams, etc.
// seek is essential, and it should be byte stream
class StreamReader
{
// should return a string [FIXME: perhaps return array of bytes?]
public function read($bytes)
{
return false;
}
// should return new position
public function seekto($position)
{
return false;
}
// returns current position
public function currentpos()
{
return false;
}
// returns length of entire stream (limit for seekto()s)
public function length()
{
return false;
}
}
# __END__

View File

@@ -1,67 +0,0 @@
<?php
/*
Copyright (c) 2003, 2005, 2006, 2009 Danilo Segan <danilo@kvota.net>.
This file is part of PHP-gettext.
PHP-gettext is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
PHP-gettext is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHP-gettext; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace CoreLibs\Language\Core;
class StringReader
{
public $sr_pos;
public $sr_str;
public function __construct($str = '')
{
$this->sr_str = $str;
$this->sr_pos = 0;
}
public function read($bytes)
{
$data = substr($this->sr_str, $this->sr_pos, $bytes);
$this->sr_pos += $bytes;
if (strlen($this->sr_str) < $this->sr_pos) {
$this->sr_pos = strlen($this->sr_str);
}
return $data;
}
public function seekto($pos)
{
$this->sr_pos = $pos;
if (strlen($this->sr_str) < $this->sr_pos) {
$this->sr_pos = strlen($this->sr_str);
}
return $this->sr_pos;
}
public function currentpos()
{
return $this->sr_pos;
}
public function length()
{
return strlen($this->sr_str);
}
}
# __END__

View File

@@ -1,31 +0,0 @@
<?php
namespace CoreLibs\Upload\Core;
/**
* Handle file uploads via regular form post (uses the $_FILES array)
*/
class qqUploadedFileForm
{
/**
* Save the file to the specified path
* @return boolean TRUE on success
*/
public function save($path)
{
if (!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) {
return false;
}
return true;
}
public function getName()
{
return $_FILES['qqfile']['name'];
}
public function getSize()
{
return $_FILES['qqfile']['size'];
}
}
# __END__

View File

@@ -1,46 +0,0 @@
<?php
namespace CoreLibs\Upload\Core;
/**
* Handle file uploads via XMLHttpRequest
*/
class qqUploadedFileXhr
{
/**
* Save the file to the specified path
* @return boolean TRUE on success
*/
public function save($path)
{
$input = fopen("php://input", "r");
$temp = tmpfile();
$realSize = stream_copy_to_stream($input, $temp);
fclose($input);
if ($realSize != $this->getSize()) {
return false;
}
$target = fopen($path, "w");
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
return true;
}
public function getName()
{
return $_GET['qqfile'];
}
public function getSize()
{
if (isset($_SERVER["CONTENT_LENGTH"])) {
return (int)$_SERVER["CONTENT_LENGTH"];
} else {
throw new Exception('Getting content length is not supported.');
}
}
}
# __END__

View File

@@ -1,6 +0,0 @@
* copy
plugins/block.t.php
plugins/function.popup*.php
* check & copy
plugins/function.html_checkboxes.php
plugins/function.html_options.php

View File

@@ -1 +0,0 @@
smarty-3.1.30/

View File

@@ -1,57 +0,0 @@
<?php
namespace Autoloader;
// shall implement an auto loader
if (class_exists('Autoload', false) === false) {
// define the auto loader class
class Autoload
{
// we do it simple here
// passes on the class to load and we search here in namespace
// to load that class
public static function load($class)
{
// print "(1) Class: $class / DIR: ".__DIR__."<br>";
// set directory seperator (we need to replace from namespace)
$ds = DS ?? DIRECTORY_SEPARATOR;
// base lib
$LIB = LIB ?? 'lib';
// if lib is in path, do not add lib again
if (strpos(__DIR__, $LIB) !== false) {
$LIB .= DS;
} else {
$LIB = '';
}
// default path is unset
$path = false;
// set path on full dir
// if we have the namespace in the class, strip it out
$len = 0;
if (strpos($class, __NAMESPACE__) !== false) {
$len = strlen(__NAMESPACE__);
}
// set default extension
$extension = '.inc';
// set full include path
$path = __DIR__.$ds.$LIB.substr($class, $len);
// replace namespace \ with dir sepeator
$path = str_replace('\\', $ds, $path).$extension;
// print "(2) Class clean: $path<br>";
// if path is set and a valid file
if ($path !== false && is_file($path)) {
// echo "<b>(3)</b> Load Path: $path<br>";
// we should sub that
// self::loadFile($path);
include $path;
return true;
}
return false;
}
} // end class define
spl_autoload_register('Autoloader\Autoload::load', true, true);
} // end check for already defined
# __END__

View File

@@ -1,8 +1,8 @@
<?php <?
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2006/08/15 * CREATED: 2006/08/15
* VERSION: 1.0.0 * VERSION: 0.1.0
* RELEASED LICENSE: GNU GPL 3 * RELEASED LICENSE: GNU GPL 3
* DESCRIPTION * DESCRIPTION
* Basic Admin interface backend * Basic Admin interface backend
@@ -22,9 +22,10 @@
* *
*********************************************************************/ *********************************************************************/
namespace CoreLibs\Admin; // try to include file from LIBS path, or from normal path
_spl_autoload('Class.DB.IO.inc');
class Backend extends \CoreLibs\DB\IO class AdminBackend extends db_io
{ {
// page name // page name
public $page_name; // the name of the current page public $page_name; // the name of the current page
@@ -60,21 +61,24 @@ class Backend extends \CoreLibs\DB\IO
public function __construct($db_config, $lang, $debug = 0, $db_debug = 0, $echo = 1, $print = 0) public function __construct($db_config, $lang, $debug = 0, $db_debug = 0, $echo = 1, $print = 0)
{ {
// get the language sub class & init it // get the language sub class & init it
$this->l = new \CoreLibs\Language\L10n($lang); _spl_autoload('Class.l10n.inc');
$this->l = new l10n($lang);
// init the database class // init the database class
// $this->db_io($db_config, $debug, $db_debug, $echo, $print);
parent::__construct($db_config, $debug, $db_debug, $echo, $print); parent::__construct($db_config, $debug, $db_debug, $echo, $print);
// internal // internal
$this->class_info["adbBackend"] = array( $this->class_info["adbBackend"] = array(
"class_name" => "Admin Interface Backend", "class_name" => "Admin Interface Backend",
"class_version" => "1.0.0", "class_version" => "0.1.0",
"class_created" => "2006/08/15", "class_created" => "2006/08/15",
"class_author" => "Clemens Schwaighofer" "class_author" => "cs/gullevek/jp"
); );
// set page name // set page name
$this->page_name = $this->getPageName(); $this->page_name = $this->get_page_name();
// set the action ids // set the action ids
foreach ($this->action_list as $_action) { foreach ($this->action_list as $_action) {
@@ -122,11 +126,11 @@ class Backend extends \CoreLibs\DB\IO
public function adbEditLog($event = '', $data = '', $write_type = 'STRING') public function adbEditLog($event = '', $data = '', $write_type = 'STRING')
{ {
if ($write_type == 'BINARY') { if ($write_type == 'BINARY') {
$data_binary = $this->dbEscapeBytea(bzcompress(serialize($data))); $data_binary = $this->db_escape_bytea(bzcompress(serialize($data)));
$data = 'see bzip compressed data_binary field'; $data = 'see bzip compressed data_binary field';
} }
if ($write_type == 'STRING') { if ($write_type == 'STRING') {
$data = $this->dbEscapeString(serialize($data)); $data = $this->db_escape_string(serialize($data));
} }
$q = "INSERT INTO ".LOGIN_DB_SCHEMA.".edit_log "; $q = "INSERT INTO ".LOGIN_DB_SCHEMA.".edit_log ";
@@ -134,20 +138,27 @@ class Backend extends \CoreLibs\DB\IO
$q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, "; $q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, ";
$q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "; $q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) ";
$q .= "VALUES "; $q .= "VALUES ";
$q .= "(".@$_SESSION['EUID'].", NOW(), '".$this->dbEscapeString($event)."', '".$data."', '".$data_binary."', '".$this->page_name."', "; $q .= "(".@$_SESSION['EUID'].", NOW(), '".$this->db_escape_string($event)."', '".$data."', '".$data_binary."', '".$this->page_name."', ";
$q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->dbEscapeString(@$_SERVER['HTTP_USER_AGENT'])."', "; $q .= "'".@$_SERVER["REMOTE_ADDR"]."', '".$this->db_escape_string(@$_SERVER['HTTP_USER_AGENT'])."', ";
$q .= "'".$this->dbEscapeString(@$_SERVER['HTTP_REFERER'])."', '".$this->dbEscapeString(@$_SERVER['SCRIPT_FILENAME'])."', "; $q .= "'".$this->db_escape_string(@$_SERVER['HTTP_REFERER'])."', '".$this->db_escape_string(@$_SERVER['SCRIPT_FILENAME'])."', ";
$q .= "'".$this->dbEscapeString(@$_SERVER['QUERY_STRING'])."', '".$this->dbEscapeString(@$_SERVER['SERVER_NAME'])."', "; $q .= "'".$this->db_escape_string(@$_SERVER['QUERY_STRING'])."', '".$this->db_escape_string(@$_SERVER['SERVER_NAME'])."', ";
$q .= "'".$this->dbEscapeString(@$_SERVER['HTTP_HOST'])."', '".$this->dbEscapeString(@$_SERVER['HTTP_ACCEPT'])."', "; $q .= "'".$this->db_escape_string(@$_SERVER['HTTP_HOST'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT'])."', ";
$q .= "'".$this->dbEscapeString(@$_SERVER['HTTP_ACCEPT_CHARSET'])."', '".$this->dbEscapeString(@$_SERVER['HTTP_ACCEPT_ENCODING'])."', "; $q .= "'".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_CHARSET'])."', '".$this->db_escape_string(@$_SERVER['HTTP_ACCEPT_ENCODING'])."', ";
$q .= "'".session_id()."', "; $q .= "'".session_id()."', ";
$q .= "'".$this->dbEscapeString($this->action)."', '".$this->dbEscapeString($this->action_id)."', "; $q .= "'".$this->db_escape_string($this->action)."', '".$this->db_escape_string($this->action_id)."', ";
$q .= "'".$this->dbEscapeString($this->action_yes)."', '".$this->dbEscapeString($this->action_flag)."', "; $q .= "'".$this->db_escape_string($this->action_yes)."', '".$this->db_escape_string($this->action_flag)."', ";
$q .= "'".$this->dbEscapeString($this->action_menu)."', '".$this->dbEscapeString($this->action_loaded)."', "; $q .= "'".$this->db_escape_string($this->action_menu)."', '".$this->db_escape_string($this->action_loaded)."', ";
$q .= "'".$this->dbEscapeString($this->action_value)."', '".$this->dbEscapeString($this->action_error)."')"; $q .= "'".$this->db_escape_string($this->action_value)."', '".$this->db_escape_string($this->action_error)."')";
$this->dbExec($q, 'NULL'); $this->db_exec($q, 'NULL');
} }
// ==================================
// ALL THE PAGE RIGHTS/USER RIGHTS/ETC need to fixed and put into one
// proper settings have to be done with the defined top down rights flow
// ==================================
// all ACLs are set in the login class
// METHOD: adbTopMenu // METHOD: adbTopMenu
// PARAMS: level // PARAMS: level
// RETURN: returns an array for the top menu with all correct settings // RETURN: returns an array for the top menu with all correct settings
@@ -163,11 +174,13 @@ class Backend extends \CoreLibs\DB\IO
if (!is_array($pages)) { if (!is_array($pages)) {
$pages = array (); $pages = array ();
} }
//$this->debug('pages', $this->print_ar($pages)); //$this->debug('pages', $this->print_ar($pages));
// if flag is 0, then we show all, else, we show only the matching flagges array points // if flag is 0, then we show all, else, we show only the matching flagges array points
// array is already sorted after correct order // array is already sorted after correct order
reset($pages); reset($pages);
for ($i = 0, $iMax = count($pages); $i < $iMax; $i ++) { for ($i = 0; $i < count($pages); $i ++) {
$show = 0; $show = 0;
// is it visible in the menu & is it online // is it visible in the menu & is it online
if ($pages[$i]["menu"] && $pages[$i]["online"]) { if ($pages[$i]["menu"] && $pages[$i]["online"]) {
@@ -192,7 +205,7 @@ class Backend extends \CoreLibs\DB\IO
} }
$query_string = ''; $query_string = '';
if (count($pages[$i]["query"])) { if (count($pages[$i]["query"])) {
for ($j = 0, $jMax = count($pages[$i]["query"]); $j < $jMax; $j ++) { for ($j = 0; $j < count($pages[$i]["query"]); $j ++) {
if (strlen($query_string)) { if (strlen($query_string)) {
$query_string .= "&"; $query_string .= "&";
} }
@@ -211,7 +224,7 @@ class Backend extends \CoreLibs\DB\IO
$name = $pages[$i]["page_name"]; $name = $pages[$i]["page_name"];
// if page name matchs -> set selected flag // if page name matchs -> set selected flag
$selected = 0; $selected = 0;
if ($this->getPageName() == $pages[$i]["filename"]) { if ($this->get_page_name() == $pages[$i]["filename"]) {
$selected = 1; $selected = 1;
$this->page_name = $name; $this->page_name = $name;
} }
@@ -250,7 +263,7 @@ class Backend extends \CoreLibs\DB\IO
// DESC: creates out of a normal db_return array an assoc array // DESC: creates out of a normal db_return array an assoc array
public function adbAssocArray($db_array, $key, $value) public function adbAssocArray($db_array, $key, $value)
{ {
return $this->genAssocArray($db_array, $key, $value); return $this->GenAssocArray($db_array, $key, $value);
} }
// REMARK: below function has moved to "Class.Basic" // REMARK: below function has moved to "Class.Basic"
@@ -260,7 +273,7 @@ class Backend extends \CoreLibs\DB\IO
// DESC: converts bytes into formated string with KB, MB, etc // DESC: converts bytes into formated string with KB, MB, etc
public function adbByteStringFormat($number) public function adbByteStringFormat($number)
{ {
return $this->byteStringFormat($number); return $this->ByteStringFormat($number);
} }
// REMARK: below function has moved to "Class.Basic" // REMARK: below function has moved to "Class.Basic"
@@ -275,7 +288,7 @@ class Backend extends \CoreLibs\DB\IO
// DESC: converts picture to a thumbnail with max x and max y size // DESC: converts picture to a thumbnail with max x and max y size
public function adbCreateThumbnail($pic, $size_x, $size_y, $dummy = false, $path = "", $cache = "") public function adbCreateThumbnail($pic, $size_x, $size_y, $dummy = false, $path = "", $cache = "")
{ {
return $this->createThumbnail($pic, $size_x, $size_y, $dummy, $path, $cache); return $this->CreateThumbnail($pic, $size_x, $size_y, $dummy, $path, $cache);
} }
// METHOD: adbMsg // METHOD: adbMsg
@@ -322,41 +335,76 @@ class Backend extends \CoreLibs\DB\IO
$q = "INSERT INTO ".GLOBAL_DB_SCHEMA.".live_queue ("; $q = "INSERT INTO ".GLOBAL_DB_SCHEMA.".live_queue (";
$q .= "queue_key, key_value, key_name, type, target, data, group_key, action, associate, file"; $q .= "queue_key, key_value, key_name, type, target, data, group_key, action, associate, file";
$q .= ") VALUES ("; $q .= ") VALUES (";
$q .= "'".$this->dbEscapeString($queue_key)."', '".$this->dbEscapeString($key_value)."', "; $q .= "'".$this->db_escape_string($queue_key)."', '".$this->db_escape_string($key_value)."', ";
$q .= "'".$this->dbEscapeString($key_name)."', '".$this->dbEscapeString($type)."', "; $q .= "'".$this->db_escape_string($key_name)."', '".$this->db_escape_string($type)."', ";
$q .= "'".$this->dbEscapeString($target)."', '".$this->dbEscapeString($data)."', "; $q .= "'".$this->db_escape_string($target)."', '".$this->db_escape_string($data)."', ";
$q .= "'".$this->queue_key."', '".$this->action."', '".$this->dbEscapeString($associate)."', "; $q .= "'".$this->queue_key."', '".$this->action."', '".$this->db_escape_string($associate)."', ";
$q .= "'".$this->dbEscapeString($file)."')"; $q .= "'".$this->db_escape_string($file)."')";
$this->db_exec($q); $this->db_exec($q);
} }
// METHOD: adbPrintDateTime // METHOD: adbPrintDateTime
// PARAMS: year, month, day, hour, min: the date and time values // PARAMS: year, month, day, hour, min: the date and time values
// suffix: additional info printed after the date time variable in the drop down, // suffix: additional info printed after the date time variable in the drop down, also used for ID in the on change JS call
// also used for ID in the on change JS call // minute steps, can be 1 (default), 5, 10, etc, if invalid (outside 1h range, it falls back to 1min)
// minute steps: can be 1 (default), 5, 10, etc, if invalid (outside 1h range,
// it falls back to 1min)
// name pos back: default false, if set to true, the name will be printend
// after the drop down and not before the drop down
// RETURN: HTML formated strings for drop down lists of date and time // RETURN: HTML formated strings for drop down lists of date and time
// DESC: print the date/time drop downs, used in any queue/send/insert at date/time place // DESC: print the date/time drop downs, used in any queue/send/insert at date/time place
// NOTE : Basic class holds exact the same, except the Year/Month/Day/etc strings public function adbPrintDateTime($year, $month, $day, $hour, $min, $suffix = '', $min_steps = 1)
// are translated in this call
public function adbPrintDateTime($year, $month, $day, $hour, $min, $suffix = '', $min_steps = 1, $name_pos_back = false)
{ {
// get the build layout // if suffix given, add _ before
$html_time = $this->printDateTime($year, $month, $day, $hour, $min, $suffix, $min_steps, $name_pos_back); if ($suffix) {
// translate the strings inside $suffix = '_'.$suffix;
foreach (array('Year ', 'Month ', 'Day ', 'Hour ', 'Minute ') as $_time) {
$html_time = str_replace($_time, $this->l->__(str_replace(' ', '', $_time)).' ', $html_time);
}
// replace week days in short
foreach (array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun') as $_date) {
$html_time = str_replace('('.$_date.')', '('.$this->l->__($_date).')', $html_time);
}
// return the datetime select string with strings translated
return $html_time;
} }
if ($min_steps < 1 || $min_steps > 59) {
$min_steps = 1;
} }
# __END__ $on_change_call = 'dt_list(\''.$suffix.'\');';
// always be 1h ahead (for safety)
$timestamp = time() + 3600; // in seconds
// the max year is this year + 1;
$max_year = date("Y", $timestamp) + 1;
// preset year, month, ...
$year = (!$year) ? date("Y", $timestamp) : $year;
$month = (!$month) ? date("m", $timestamp) : $month;
$day = (!$day) ? date("d", $timestamp) : $day;
$hour = (!$hour) ? date("H", $timestamp) : $hour;
$min = (!$min) ? date("i", $timestamp) : $min; // add to five min?
// max days in selected month
$days_in_month = date("t", strtotime($year."-".$month."-".$day." ".$hour.":".$min.":0"));
// from now to ?
$string = $this->l->__('Year').' ';
$string .= '<select id="year'.$suffix.'" name="year'.$suffix.'" onChange="'.$on_change_call.'">';
for ($i = date("Y"); $i <= $max_year; $i ++) {
$string .= '<option value="'.$i.'" '.(($year == $i) ? 'selected' : '').'>'.$i.'</option>';
}
$string .= '</select> '.$this->l->__('Month').' ';
$string .= '<select id="month'.$suffix.'" name="month'.$suffix.'" onChange="'.$on_change_call.'">';
for ($i = 1; $i <= 12; $i ++) {
$string .= '<option value="'.(($i < 10) ? '0'.$i : $i).'" '.(($month == $i) ? 'selected' : '').'>'.$i.'</option>';
}
$string .= '</select> '.$this->l->__('Day').' ';
$string .= '<select id="day'.$suffix.'" name="day'.$suffix.'" onChange="'.$on_change_call.'">';
for ($i = 1; $i <= $days_in_month; $i ++) {
// set weekday text based on current month ($month) and year ($year)
$string .= '<option value="'.(($i < 10) ? '0'.$i : $i).'" '.(($day == $i) ? 'selected' : '').'>'.$i.' ('.$this->l->__(date('D', mktime(0, 0, 0, $month, $i, $year))).')</option>';
}
$string .= '</select> '.$this->l->__('Hour').' ';
$string .= '<select id="hour'.$suffix.'" name="hour'.$suffix.'" onChange="'.$on_change_call.'">';
for ($i = 0; $i <= 23; $i ++) {
$string .= '<option value="'.(($i < 10) ? '0'.$i : $i).'" '.(($hour == $i) ? 'selected' : '').'>'.$i.'</option>';
}
$string .= '</select> '.$this->l->__('Minute').' ';
$string .= '<select id="min'.$suffix.'" name="min'.$suffix.'" onChange="'.$on_change_call.'">';
for ($i = 0; $i <= 59; $i += $min_steps) {
$string .= '<option value="'.(( $i < 10) ? '0'.$i : $i).'" '.(($min == $i) ? 'selected' : '').'>'.$i.'</option>';
}
$string .= '</select>';
// return the datetime select string
return $string;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
<?php <?
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2002/12/17 * CREATED: 2002/12/17
* VERSION: 1.0.0 * VERSION: 0.4.0
* RELEASED LICENSE: GNU GPL 3 * RELEASED LICENSE: GNU GPL 3
* SHORT DESC :RIPTION: * SHORT DESCRIPTION:
* DB Array IO Class: * DB Array IO Class:
* writes, reads or deletes a complete array (one data set) in/out a * writes, reads or deletes a complete array (one data set) in/out a
* table from the connected DB. * table from the connected DB.
@@ -14,9 +14,9 @@
* *
* PRIVATE VARIABLES * PRIVATE VARIABLES
* *
* PUBLIC METHOD:S * PUBLIC METHODS
* *
* PRIVATE METHOD:S * PRIVATE METHODS
* *
* HISTORY: * HISTORY:
* 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax * 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax
@@ -36,10 +36,11 @@
// as it actually has nothing to do with this one here ? (or at least // as it actually has nothing to do with this one here ? (or at least
// put into separete function in this class) // put into separete function in this class)
namespace CoreLibs\DB\Extended; // try to include file from LIBS path, or from normal path
_spl_autoload('Class.DB.IO.inc');
// subclass for one array handling // subclass for one array handling
class ArrayIO extends \CoreLibs\DB\IO class db_array_io extends db_io
{ {
// main calss variables // main calss variables
public $table_array; // the array from the table to work on public $table_array; // the array from the table to work on
@@ -47,13 +48,13 @@ class ArrayIO extends \CoreLibs\DB\IO
public $pk_name; // the primary key from this table public $pk_name; // the primary key from this table
public $pk_id; // the PK id public $pk_id; // the PK id
// METHOD: db_array_io // METHOD db_array_io
// PARAMS: db_config -> db_io class init vars // PARAMS db_config -> db_io class init vars
// table_array -> the array from the table // table_array -> the array from the table
// table_name -> name of the table (for the array) // table_name -> name of the table (for the array)
// db_debug -> turn on db_io debug output (DB_DEBUG as global var does the same) // db_debug -> turn on db_io debug output (DB_DEBUG as global var does the same)
// RETURN: none // RETURN none
// DESC : constructor for the array io class, set the // DESC constructor for the array io class, set the
// primary key name automatically (from array) // primary key name automatically (from array)
public function __construct($db_config, $table_array, $table_name, $debug = 0, $db_debug = 0, $echo = 1, $print = 0) public function __construct($db_config, $table_array, $table_name, $debug = 0, $db_debug = 0, $echo = 1, $print = 0)
{ {
@@ -68,7 +69,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// set primary key for given table_array // set primary key for given table_array
if ($this->table_array) { if ($this->table_array) {
foreach ($table_array as $key => $value) { while (list($key, $value) = each($table_array)) {
if ($value["pk"]) { if ($value["pk"]) {
$this->pk_name = $key; $this->pk_name = $key;
} }
@@ -77,9 +78,9 @@ class ArrayIO extends \CoreLibs\DB\IO
// internal // internal
$this->class_info["db_array_io"] = array( $this->class_info["db_array_io"] = array(
"class_name" => "DB Array IO", "class_name" => "DB Array IO",
"class_version" => "1.0.0", "class_version" => "0.4.0",
"class_created" => "2002/12/17", "class_created" => "2002/12/17",
"class_author" => "Clemens Schwaighofer" "class_author" => "cs/gullevek/at"
); );
} }
@@ -89,15 +90,14 @@ class ArrayIO extends \CoreLibs\DB\IO
parent::__destruct(); parent::__destruct();
} }
// METHOD: convertData // METHOD convert_data
// WAS : convert_data // PARAMS string -> the string that should be changed
// PARAMS: string -> the string that should be changed // RETURN string -> the altered string
// RETURN: string -> the altered string // DESC changes all previously alterd HTML code into visible one,
// DESC : changes all previously alterd HTML code into visible one,
// works for <b>,<i>, and <a> (thought <a> can be / or should // works for <b>,<i>, and <a> (thought <a> can be / or should
// be handled with the magic links functions // be handled with the magic links functions
// used with the read function // used with the read function
public function convertData($text) public function convert_data($text)
{ {
$text = str_replace('&lt;b&gt;', '<b>', $text); $text = str_replace('&lt;b&gt;', '<b>', $text);
$text = str_replace('&lt;/b&gt;', '</b>', $text); $text = str_replace('&lt;/b&gt;', '</b>', $text);
@@ -110,12 +110,11 @@ class ArrayIO extends \CoreLibs\DB\IO
return $text; return $text;
} }
// METHOD: convertEntities // METHOD convert_entities
// WAS : convert_entities // PARAMS string -> string to be changed
// PARAMS: string -> string to be changed // RETURN string -> altered string
// RETURN: string -> altered string // DESC changeds all HTML entities into non HTML ones
// DESC : changeds all HTML entities into non HTML ones public function convert_entities($text)
public function convertEntities($text)
{ {
$text = str_replace('&lt;', '<', $text); $text = str_replace('&lt;', '<', $text);
$text = str_replace('&gt;', '>', $text); $text = str_replace('&gt;', '>', $text);
@@ -125,15 +124,14 @@ class ArrayIO extends \CoreLibs\DB\IO
return $text; return $text;
} }
// METHOD: dbDumpArray // METHOD db_dump_array
// WAS : db_dump_array // PARAMS none
// PARAMS: none // RETURN returns the current array
// RETURN: returns the current array // DESC dumps the current data
// DESC : dumps the current data public function db_dump_array($write = 0)
public function dbDumpArray($write = 0)
{ {
reset($this->table_array); reset($this->table_array);
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array) = each($this->table_array)) {
$string .= "<b>".$column."</b> -> ".$data_array["value"]."<br>"; $string .= "<b>".$column."</b> -> ".$data_array["value"]."<br>";
} }
// add output to internal error_msg // add output to internal error_msg
@@ -143,12 +141,24 @@ class ArrayIO extends \CoreLibs\DB\IO
return $string; return $string;
} }
// METHOD: dbCheckPkSet // METHOD _db_error
// WAS : db_check_pk_set // PARAMS none
// PARAMS: none // RETURN none
// RETURN: none // DESC writes errors to internal error string
// DESC : checks if pk is set and if not, set from pk_id and if this also not set return 0 /* function _db_error()
public function dbCheckPkSet() {
// if error occured
if ($this->error_id)
{
$this->error_msg['db'] .= "<b>-DB_ARRAY-error-></b> ".$this->error_id.": ".$this->error_string[$this->error_id]." <br>";
}
} */
// METHOD db_check_pk_set
// PARAMS none
// RETURN none
// DESC checks if pk is set and if not, set from pk_id and if this also not set return 0
public function db_check_pk_set()
{ {
// if pk_id is set, overrule ... // if pk_id is set, overrule ...
if ($this->pk_id) { if ($this->pk_id) {
@@ -158,22 +168,21 @@ class ArrayIO extends \CoreLibs\DB\IO
if (!$this->table_array[$this->pk_name]["value"]) { if (!$this->table_array[$this->pk_name]["value"]) {
// if no PK found, error ... // if no PK found, error ...
$this->error_id = 21; $this->error_id = 21;
$this->__dbError(); $this->_db_error();
return 0; return 0;
} else { } else {
return 1; return 1;
} }
} }
// METHOD: dbResetArray // METHOD db_reset_array
// WAS : db_reset_array // PARAMS reset_pk -> if set reset the pk too
// PARAMS: reset_pk -> if set reset the pk too // RETURN none
// RETURN: none // DESC resets the whole array
// DESC : resets the whole array public function db_reset_array($reset_pk = 0)
public function dbResetArray($reset_pk = 0)
{ {
reset($this->table_array); reset($this->table_array);
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array) = each($this->table_array)) {
if (!$this->table_array[$column]["pk"]) { if (!$this->table_array[$column]["pk"]) {
unset($this->table_array[$column]["value"]); unset($this->table_array[$column]["value"]);
} elseif ($reset_pk) { } elseif ($reset_pk) {
@@ -182,17 +191,16 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
} }
// METHOD: dbDelete // METHOD db_delete
// WAS : db_delete // PARAMS optional the table_array, if not given uses class var
// PARAMS: optional the table_array, if not given uses class var // RETURN 1 for successfull delete or 0 for error
// RETURN: 1 for successfull delete or 0 for error // DESC deletes one dataset
// DESC : deletes one dataset public function db_delete($table_array = 0)
public function dbDelete($table_array = 0)
{ {
if (is_array($table_array)) { if (is_array($table_array)) {
$this->table_array = $table_array; $this->table_array = $table_array;
} }
if (!$this->dbCheckPkSet()) { if (!$this->db_check_pk_set()) {
return $this->table_array; return $this->table_array;
} }
// delete query // delete query
@@ -200,8 +208,8 @@ class ArrayIO extends \CoreLibs\DB\IO
$q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." "; $q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." ";
// delete files and build FK query // delete files and build FK query
reset($this->table_array); reset($this->table_array);
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array) = each($this->table_array)) {
// suchen nach bildern und lschen ... // suchen nach bildern und löschen ...
if ($this->table_array[$column]["file"] && file_exists($this->table_array[$column]["url"].$this->table_array[$column]["value"])) { if ($this->table_array[$column]["file"] && file_exists($this->table_array[$column]["url"].$this->table_array[$column]["value"])) {
if (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) { if (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) {
unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]); unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]);
@@ -219,7 +227,7 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
$q_where .= $column." = ".$this->table_array[$column]["value"]; $q_where .= $column." = ".$this->table_array[$column]["value"];
} }
// allgemeines zurcksetzen des arrays // allgemeines zurücksetzen des arrays
unset($this->table_array[$column]["value"]); unset($this->table_array[$column]["value"]);
} }
@@ -229,30 +237,29 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
// if 0, error // if 0, error
unset($this->pk_id); unset($this->pk_id);
if (!$this->dbExec($q)) { if (!$this->db_exec($q)) {
$this->error_id=22; $this->error_id=22;
$this->__dbError(); $this->_db_error();
} }
return $this->table_array; return $this->table_array;
} }
// METHOD: dbRead // METHOD db_read
// WAS : db_read // PARAMS edit -> if 1 data will not be altered for output, optional the table_array, if not given uses class var
// PARAMS: edit -> if 1 data will not be altered for output, optional the table_array, if not given uses class var // RETURN true or false for reading
// RETURN: true or false for reading // DESC reads one row into the array
// DESC : reads one row into the array public function db_read($edit = 0, $table_array = 0)
public function dbRead($edit = 0, $table_array = 0)
{ {
// if array give, overrules internal array // if array give, overrules internal array
if (is_array($table_array)) { if (is_array($table_array)) {
$this->table_array = $table_array; $this->table_array = $table_array;
} }
if (!$this->dbCheckPkSet()) { if (!$this->db_check_pk_set()) {
return $this->table_array; return $this->table_array;
} }
reset($this->table_array); reset($this->table_array);
// create select part & addition FK part // create select part & addition FK part
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array)=each($this->table_array)) {
if ($q_select) { if ($q_select) {
$q_select .= ", "; $q_select .= ", ";
} }
@@ -276,12 +283,12 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
// if query was executed okay, else set error // if query was executed okay, else set error
if ($this->dbExec($q)) { if ($this->db_exec($q)) {
if ($res = $this->dbFetchArray()) { if ($res = $this->db_fetch_array()) {
reset($this->table_array); reset($this->table_array);
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array) = each($this->table_array)) {
// wenn "edit" dann gib daten wie in DB zurck, ansonten aufbereiten fr ausgabe // wenn "edit" dann gib daten wie in DB zurück, ansonten aufbereiten für ausgabe
// ?? sollte das nicht drauen ??? man weis ja net was da drin steht --> is noch zu berlegen // ?? sollte das nicht draußen ??? man weis ja net was da drin steht --> is noch zu überlegen
// echo "EDIT: $edit | Spalte: $column | type: ".$this->table_array[$column]["type"]." | Res: ".$res[$column]."<br>"; // echo "EDIT: $edit | Spalte: $column | type: ".$this->table_array[$column]["type"]." | Res: ".$res[$column]."<br>";
if ($edit) { if ($edit) {
$this->table_array[$column]["value"] = $res[$column]; $this->table_array[$column]["value"] = $res[$column];
@@ -290,26 +297,25 @@ class ArrayIO extends \CoreLibs\DB\IO
$this->table_array[$column]["HIDDEN_value"] = $res[$column]; $this->table_array[$column]["HIDDEN_value"] = $res[$column];
} }
} else { } else {
$this->table_array[$column]["value"] = $this->convertData(nl2br($res[$column])); $this->table_array[$column]["value"] = $this->convert_data(nl2br($res[$column]));
// had to put out the htmlentities from the line above as it breaks japanese characters // had to put out the htmlentities from the line above as it breaks japanese characters
} }
} }
} }
// possible dbFetchArray errors ... // possible db_fetch_array errors ...
$this->pk_id = $this->table_array[$this->pk_name]["value"]; $this->pk_id = $this->table_array[$this->pk_name]["value"];
} else { } else {
$this->error_id = 22; $this->error_id = 22;
$this->__dbError(); $this->_db_error();
} }
return $this->table_array; return $this->table_array;
} }
// METHOD: dbWrite // METHOD db_write
// WAS : db_write // PARAMS addslashes -> if 1 will make an addslashes for each array field, optional the table_array, if not given uses class var
// PARAMS: addslashes -> if 1 will make an addslashes for each array field, optional the table_array, if not given uses class var // RETURN true or false on write
// RETURN: true or false on write // DESC writes on set into DB or updates one set (if PK exists)
// DESC : writes on set into DB or updates one set (if PK exists) public function db_write($addslashes = 0, $table_array = 0)
public function dbWrite($addslashes = 0, $table_array = 0)
{ {
if (is_array($table_array)) { if (is_array($table_array)) {
$this->table_array = $table_array; $this->table_array = $table_array;
@@ -326,7 +332,8 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
reset($this->table_array); reset($this->table_array);
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array) = each($this->table_array)) {
/********************************* START FILE *************************************/ /********************************* START FILE *************************************/
// file upload // file upload
if ($this->table_array[$column]["file"]) { if ($this->table_array[$column]["file"]) {
@@ -420,9 +427,9 @@ class ArrayIO extends \CoreLibs\DB\IO
$q_data .= "'"; $q_data .= "'";
// if add slashes do convert & add slashes else write AS is // if add slashes do convert & add slashes else write AS is
if ($addslashes) { if ($addslashes) {
$q_data .= $this->dbEscapeString($this->convertEntities($this->table_array[$column]["value"])); $q_data .= $this->db_escape_string($this->convert_entities($this->table_array[$column]["value"]));
} else { } else {
$q_data .= $this->dbEscapeString($this->table_array[$column]["value"]); $q_data .= $this->db_escape_string($this->table_array[$column]["value"]);
} }
$q_data .= "'"; $q_data .= "'";
} }
@@ -433,7 +440,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// get it at the end, cause now we can be more sure of no double IDs, etc // get it at the end, cause now we can be more sure of no double IDs, etc
reset($this->table_array); reset($this->table_array);
// create select part & addition FK part // create select part & addition FK part
foreach ($this->table_array as $column => $data_array) { while (list($column, $data_array) = each($this->table_array)) {
// check FK ... // check FK ...
if ($this->table_array[$column]["fk"] && $this->table_array[$column]["value"]) { if ($this->table_array[$column]["fk"] && $this->table_array[$column]["value"]) {
if ($q_where) { if ($q_where) {
@@ -447,7 +454,7 @@ class ArrayIO extends \CoreLibs\DB\IO
if (!$this->table_array[$this->pk_name]["value"]) { if (!$this->table_array[$this->pk_name]["value"]) {
// max id, falls INSERT // max id, falls INSERT
$q = "SELECT MAX(".$this->pk_name.") + 1 AS pk_id FROM ".$this->table_name; $q = "SELECT MAX(".$this->pk_name.") + 1 AS pk_id FROM ".$this->table_name;
$res = $this->dbReturnRow($q); $res = $this->db_return_row($q);
if (!$res["pk_id"]) { if (!$res["pk_id"]) {
$res["pk_id"] = 1; $res["pk_id"] = 1;
} }
@@ -475,9 +482,9 @@ class ArrayIO extends \CoreLibs\DB\IO
// $this->pk_id = $this->table_array[$this->pk_name]["value"]; // $this->pk_id = $this->table_array[$this->pk_name]["value"];
} }
// return success or not // return success or not
if (!$this->dbExec($q)) { if (!$this->db_exec($q)) {
$this->error_id = 22; $this->error_id = 22;
$this->__dbError(); $this->_db_error();
} }
// set primary key // set primary key
if ($insert) { if ($insert) {
@@ -487,60 +494,4 @@ class ArrayIO extends \CoreLibs\DB\IO
// return the table if needed // return the table if needed
return $this->table_array; return $this->table_array;
} }
// *************************************************************
// COMPATIBILITY METHODS
// those methods are deprecated function call names
// they exist for backwards compatibility only
// *************************************************************
public function convert_data($text)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->convertData($text);
}
public function convert_entities($text)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->convertEntities($text);
}
public function db_dump_array($write = 0)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->dbDumpArray($write);
}
public function db_check_pk_set()
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->dbCheckPkSet();
}
public function db_reset_array($reset_pk = 0)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->dbResetArray($reset_pk);
}
public function db_delete($table_array = 0)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->dbDelete($table_array);
}
public function db_read($edit = 0, $table_array = 0)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->dbRead($edit, $table_array);
}
public function db_write($addslashes = 0, $table_array = 0)
{
error_log('DEPRECATED CALL: '.__METHOD__.', '.__FILE__.':'.__LINE__.', '.debug_backtrace()[0]['file'].':'.debug_backtrace()[0]['line']);
return $this->dbWrite($addslashes, $table_array);
}
} // end of class } // end of class
# __END__

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
<?php <?
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2000/06/01 * CREATED: 2000/06/01
* VERSION: 5.0.0 * VERSION: 4.0.0
* RELEASED LICENSE: GNU GPL 3 * RELEASED LICENSE: GNU GPL 3
* SHORT DESCRIPTON: * SHORT DESCRIPTON:
* ~ 2003/03/03: change the whole include file into one class * ~ 2003/03/03: change the whole include file into one class
@@ -57,9 +57,10 @@
* 2000-06-01: created basic idea and functions * 2000-06-01: created basic idea and functions
*********************************************************************/ *********************************************************************/
namespace CoreLibs\ACL; // try to include file from LIBS path, or from normal path
_spl_autoload('Class.DB.IO.inc');
class Login extends \CoreLibs\DB\IO class login extends db_io
{ {
private $euid; // the user id var private $euid; // the user id var
private $permission_okay = 0; // is set to one if login okay, or EUID is set and user is okay to access this page private $permission_okay = 0; // is set to one if login okay, or EUID is set and user is okay to access this page
@@ -100,36 +101,22 @@ class Login extends \CoreLibs\DB\IO
$this->log_per_class = 1; $this->log_per_class = 1;
// create db connection and init base class // create db connection and init base class
if (!parent::__construct($db_config, $debug, $db_debug, $echo, $print)) { parent::__construct($db_config, $debug, $db_debug, $echo, $print);
echo "Could not connect to DB<br>";
// if I can't connect to the DB to auth exit hard. No access allowed
exit;
}
// no session could be found at all // no session could be found at all
if (!session_id()) { if (!session_id()) {
echo "<b>Session not started!</b><br>Use 'session_start();'.<br>"; echo "<b>Session not started!</b><br>Use 'session_start();'.<br>For less problems with other session, you can set a session name with 'session_name(\"name\");'.<br>";
echo "For less problems with other session, you can set a session name with 'session_name(\"name\");'.<br>";
exit; exit;
} }
$this->l = new \CoreLibs\Language\L10n($lang); // get the language sub class & init it
_spl_autoload('Class.l10n.inc');
$this->l = new l10n($lang);
// if we have a search path we need to set it, to use the correct DB to login // if we have a search path we need to set it, to use the correct DB to login
// check what schema to use. if there is a login schema use this, else check if there is a schema set in the config, or fall back to DB_SCHEMA if this exists, if this also does not exists use public schema // check what schema to use. if there is a login schema use this, else check if there is a schema set in the config, or fall back to DB_SCHEMA if this exists, if this also does not exists use public schema
if (defined('LOGIN_DB_SCHEMA')) { $SCHEMA = defined('LOGIN_DB_SCHEMA') ? LOGIN_DB_SCHEMA : ($db_config['db_schema'] ? $db_config['db_schema'] : (defined('DB_SCHEMA') ? DB_SCHEMA : 'public'));
$SCHEMA = LOGIN_DB_SCHEMA; $this->db_exec("SET search_path TO ".$SCHEMA);
} elseif ($db_config['db_schema']) {
$SCHEMA = $db_config['db_schema'];
} elseif (defined('DB_SCHEMA')) {
$SCHEMA = DB_SCHEMA;
} else {
$SCHEMA = 'public';
}
// set schema if schema differs to schema set in db conneciton
if ($this->dbGetSchema() && $this->dbGetSchema() != $SCHEMA) {
$this->dbExec("SET search_path TO ".$SCHEMA);
}
$this->euid = array_key_exists('EUID', $_SESSION) ? $_SESSION['EUID'] : 0; // if there is none, there is none, saves me POST/GET check $this->euid = array_key_exists('EUID', $_SESSION) ? $_SESSION['EUID'] : 0; // if there is none, there is none, saves me POST/GET check
// get login vars, are so, can't be changed // get login vars, are so, can't be changed
// prepare // prepare
@@ -187,16 +174,16 @@ class Login extends \CoreLibs\DB\IO
// internal // internal
$this->class_info["login"] = array( $this->class_info["login"] = array(
"class_name" => "Login", "class_name" => "Login",
"class_version" => "5.0.0", "class_version" => "4.0.0",
"class_created" => "2000-06-01", "class_created" => "2000-06-01",
"class_author" => "Clemens Schwaighofer" "class_author" => "cs/gullevek/at"
); );
// init default ACL list array // init default ACL list array
$_SESSION['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->dbReturn($q)) { while ($res = $this->db_return($q)) {
// level to description format (numeric) // 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'],
@@ -207,19 +194,19 @@ class Login extends \CoreLibs\DB\IO
$_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list; $_SESSION['DEFAULT_ACL_LIST'] = $this->default_acl_list;
// if username & password & !$euid start login // if username & password & !$euid start login
$this->loginLoginUser(); $this->login_login_user();
// checks if $euid given check if user is okay for that side // checks if $euid given check if user is okay for that side
$this->loginCheckPermissions(); $this->login_check_permissions();
// logsout user // logsout user
$this->loginLogoutUser(); $this->login_logout_user();
// if the password change flag is okay, run the password change method // if the password change flag is okay, run the password change method
if ($this->password_change) { if ($this->password_change) {
$this->loginPasswordChange(); $this->login_password_change();
} }
// if !$euid || permission not okay, print login screan // if !$euid || permission not okay, print login screan
echo $this->loginPrintLogin(); echo $this->login_print_login();
// closing all connections, depending on error status, exit // closing all connections, depending on error status, exit
if (!$this->loginCloseClass()) { if (!$this->login_close_class()) {
// do not go anywhere, quit processing here // do not go anywhere, quit processing here
// do something with possible debug data? // do something with possible debug data?
if (TARGET == 'live' || TARGET == 'remote') { if (TARGET == 'live' || TARGET == 'remote') {
@@ -228,14 +215,14 @@ class Login extends \CoreLibs\DB\IO
$this->echo_output_all = 0; $this->echo_output_all = 0;
$this->print_output_all = DEBUG ? 1 : 0; $this->print_output_all = DEBUG ? 1 : 0;
} }
$status_msg = $this->printErrorMsg(); $status_msg = $this->print_error_msg();
if ($this->echo_output_all) { if ($this->echo_output_all) {
echo $status_msg; echo $status_msg;
} }
exit; exit;
} }
// set acls for this user/group and this page // set acls for this user/group and this page
$this->loginSetAcl(); $this->login_set_acl();
} }
// METHOD: _login // METHOD: _login
@@ -253,12 +240,6 @@ class Login extends \CoreLibs\DB\IO
// DESC : checks if password is valid, sets internal error login variable // DESC : checks if password is valid, sets internal error login variable
private function loginPasswordCheck($hash, $password = '') private function loginPasswordCheck($hash, $password = '')
{ {
// check with what kind of prefix the password begins:
// $2a$ or $2y$: BLOWFISCH
// $1$: MD5
// $ and one alphanumeric letter, 13 chars long, but nor $ at the end: STD_DESC
// if no $ => normal password
// NOW, if we have a password encoded, but not the correct encoder available, throw special error
$password_ok = false; $password_ok = false;
if (!$password) { if (!$password) {
$password = $this->password; $password = $this->password;
@@ -292,7 +273,7 @@ class Login extends \CoreLibs\DB\IO
!preg_match("/^\\$[0-9A-Za-z.]{12}$/", $hash) && !preg_match("/^\\$[0-9A-Za-z.]{12}$/", $hash) &&
$hash != $password $hash != $password
) { ) {
// check old plain password, case sensitive // check old plain password, non case sensitive
$this->login_error = 1012; $this->login_error = 1012;
$password_ok = false; $password_ok = false;
} else { } else {
@@ -302,12 +283,11 @@ class Login extends \CoreLibs\DB\IO
return $password_ok; return $password_ok;
} }
// METHOD: loginLoginUser // METHOD: login_login_user
// WAS : login_login_user
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : if user pressed login button this script is called, but only if there is no preview euid set // DESC : if user pressed login button this script is called, but only if there is no preview euid set
private function loginLoginUser() private function login_login_user()
{ {
// have to get the global stuff here for setting it later // have to get the global stuff here for setting it later
if (!$this->euid && $this->login) { if (!$this->euid && $this->login) {
@@ -315,13 +295,11 @@ class Login extends \CoreLibs\DB\IO
$this->login_error = 102; $this->login_error = 102;
} else { } else {
// we have to get the themes in here too // we have to get the themes in here too
$q = "SELECT eu.edit_user_id, username, password, eu.edit_group_id, eg.name AS edit_group_name, admin, "; $q = "SELECT eu.edit_user_id, username, password, eu.edit_group_id, eg.name AS edit_group_name, admin, eu.login_error_count, eu.login_error_date_last, eu.login_error_date_first, eu.strict, eu.locked, ";
$q .= "eu.login_error_count, eu.login_error_date_last, eu.login_error_date_first, eu.strict, eu.locked, ";
$q .= "debug, db_debug, "; $q .= "debug, db_debug, ";
$q .= "eareu.level AS user_level, eareu.type AS user_type, "; $q .= "eareu.level AS user_level, eareu.type AS user_type, ";
$q .= "eareg.level AS group_level, eareg.type AS group_type, "; $q .= "eareg.level AS group_level, eareg.type AS group_type, ";
$q .= "eu.enabled, el.short_name AS lang_short, el.iso_name AS lang_iso, first.header_color AS first_header_color, "; $q .= "eu.enabled, el.short_name AS lang_short, el.iso_name AS lang_iso, first.header_color AS first_header_color, second.header_color AS second_header_color, second.template ";
$q .= "second.header_color AS second_header_color, second.template ";
$q .= "FROM edit_user eu "; $q .= "FROM edit_user eu ";
$q .= "LEFT JOIN edit_scheme second ON (second.edit_scheme_id = eu.edit_scheme_id AND second.enabled = 1), "; $q .= "LEFT JOIN edit_scheme second ON (second.edit_scheme_id = eu.edit_scheme_id AND second.enabled = 1), ";
$q .= "edit_language el, edit_group eg, "; $q .= "edit_language el, edit_group eg, ";
@@ -332,14 +310,21 @@ class Login extends \CoreLibs\DB\IO
$q .= "eu.edit_access_right_id = eareu.edit_access_right_id AND "; $q .= "eu.edit_access_right_id = eareu.edit_access_right_id AND ";
$q .= "eg.edit_access_right_id = eareg.edit_access_right_id AND "; $q .= "eg.edit_access_right_id = eareg.edit_access_right_id AND ";
// password match is done in script, against old plain or new blowfish encypted // password match is done in script, against old plain or new blowfish encypted
$q .= "(LOWER(username) = '".$this->dbEscapeString(strtolower($this->username))."') "; $q .= "(LOWER(username) = '".strtolower($this->username)."') ";
$res = $this->dbReturn($q); $res = $this->db_return($q);
// username is wrong, but we throw for wrong username and wrong password the same error // username is wrong, but we throw for wrong username and wrong password the same error
if (!$this->cursor_ext[md5($q)]["num_rows"]) { if (!$this->cursor_ext[md5($q)]["num_rows"]) {
$this->login_error = 1010; $this->login_error = 1010;
} else { } else {
// if login errors is half of max errors and the last login error was less than 10s ago, forbid any new login try // if login errors is half of max errors and the last login error was less than 10s ago, forbid any new login try
// check with what kind of prefix the password begins:
// $2a$ or $2y$: BLOWFISCH
// $1$: MD5
// $ and one alphanumeric letter, 13 chars long, but nor $ at the end: STD_DESC
// if no $ => normal password
// NOW, if we have a password encoded, but not the correct encoder available, throw special error
// check flow // check flow
// - user is enabled // - user is enabled
// - user is not locked // - user is not locked
@@ -359,15 +344,16 @@ class Login extends \CoreLibs\DB\IO
// check if the current password is an invalid hash and do a rehash and set password // check if the current password is an invalid hash and do a rehash and set password
// $this->debug('LOGIN', 'Hash: '.$res['password'].' -> VERIFY: '.($this->passwordVerify($this->password, $res['password']) ? 'OK' : 'FAIL').' => HASH: '.($this->passwordRehashCheck($res['password']) ? 'NEW NEEDED' : 'OK')); // $this->debug('LOGIN', 'Hash: '.$res['password'].' -> VERIFY: '.($this->passwordVerify($this->password, $res['password']) ? 'OK' : 'FAIL').' => HASH: '.($this->passwordRehashCheck($res['password']) ? 'NEW NEEDED' : 'OK'));
if ($this->passwordRehashCheck($res['password'])) { if ($this->passwordRehashCheck($res['password'])) {
$new_hash = $this->passwordSet($this->password);
// update password hash to new one now // update password hash to new one now
$q = "UPDATE edit_user SET password = '".$this->dbEscapeString($this->passwordSet($this->password))."' WHERE edit_user_id = ".$res['edit_user_id']; $q = "UPDATE edit_user SET password = '".$this->dbEscapeString($new_hash)."' WHERE edit_user_id = ".$res['edit_user_id'];
$this->dbExec($q); $this->dbExec($q);
} }
// normal user processing // normal user processing
// set class var and session var // set class var and session var
$_SESSION["EUID"] = $this->euid = $res["edit_user_id"]; $_SESSION["EUID"] = $this->euid = $res["edit_user_id"];
// check if user is okay // check if user is okay
$this->loginCheckPermissions(); $this->login_check_permissions();
if (!$this->login_error) { if (!$this->login_error) {
// now set all session vars and read page permissions // now set all session vars and read page permissions
$GLOBALS["DEBUG_ALL"] = $_SESSION["DEBUG_ALL"] = $res["debug"]; $GLOBALS["DEBUG_ALL"] = $_SESSION["DEBUG_ALL"] = $res["debug"];
@@ -387,18 +373,17 @@ class Login extends \CoreLibs\DB\IO
// reset any login error count for this user // reset any login error count for this user
if ($res['login_error_count'] > 0) { if ($res['login_error_count'] > 0) {
$q = "UPDATE edit_user SET login_error_count = 0, login_error_date_last = NULL, login_error_date_first = NULL WHERE edit_user_id = ".$res['edit_user_id']; $q = "UPDATE edit_user SET login_error_count = 0, login_error_date_last = NULL, login_error_date_first = NULL WHERE edit_user_id = ".$res['edit_user_id'];
$this->dbExec($q); $this->db_exec($q);
} }
$pages = array(); $pages = array();
$edit_page_ids = array(); $edit_page_ids = array();
// set pages access // set pages access
$q = "SELECT ep.edit_page_id, filename, ep.name AS edit_page_name, ep.order_number AS edit_page_order, menu, "; $q = "SELECT ep.edit_page_id, filename, ep.name AS edit_page_name, ep.order_number AS edit_page_order, menu, popup, popup_x, popup_y, online, ear.level, ear.type ";
$q .= "popup, popup_x, popup_y, online, ear.level, ear.type ";
$q .= "FROM edit_page ep, edit_page_access epa, edit_access_right ear "; $q .= "FROM edit_page ep, edit_page_access epa, edit_access_right ear ";
$q .= "WHERE ep.edit_page_id = epa.edit_page_id AND ear.edit_access_right_id = epa.edit_access_right_id "; $q .= "WHERE ep.edit_page_id = epa.edit_page_id AND ear.edit_access_right_id = epa.edit_access_right_id ";
$q .= "AND epa.enabled = 1 AND epa.edit_group_id = ".$res["edit_group_id"]." "; $q .= "AND epa.enabled = 1 AND epa.edit_group_id = ".$res["edit_group_id"]." ";
$q .= "ORDER BY ep.order_number"; $q .= "ORDER BY ep.order_number";
while ($res = $this->dbReturn($q)) { while ($res = $this->db_return($q)) {
// page id array for sub data readout // page id array for sub data readout
$edit_page_ids[] = $res['edit_page_id']; $edit_page_ids[] = $res['edit_page_id'];
// create the array for pages // create the array for pages
@@ -422,26 +407,22 @@ class Login extends \CoreLibs\DB\IO
} // for each page } // for each page
// get the visible groups for all pages and write them to the pages // get the visible groups for all pages and write them to the pages
$_edit_page_id = 0; $_edit_page_id = 0;
$q = "SELECT epvg.edit_page_id, name, flag "; $q = "SELECT epvg.edit_page_id, name, flag FROM edit_visible_group evp, edit_page_visible_group epvg WHERE evp.edit_visible_group_id = epvg.edit_visible_group_id AND epvg.edit_page_id IN (".join(', ', $edit_page_ids).") ORDER BY epvg.edit_page_id";
$q .= "FROM edit_visible_group evp, edit_page_visible_group epvg "; while ($res = $this->db_return($q)) {
$q .= "WHERE evp.edit_visible_group_id = epvg.edit_visible_group_id AND epvg.edit_page_id IN (".join(', ', $edit_page_ids).") ";
$q .= "ORDER BY epvg.edit_page_id";
while ($res = $this->dbReturn($q)) {
if ($res['edit_page_id'] != $_edit_page_id) { if ($res['edit_page_id'] != $_edit_page_id) {
// search the pos in the array push // search the pos in the array push
$pos = $this->arraySearchRecursive($res['edit_page_id'], $pages, 'edit_page_id'); $pos = $this->array_search_recursive($res['edit_page_id'], $pages, 'edit_page_id');
$_edit_page_id = $res['edit_page_id']; $_edit_page_id = $res['edit_page_id'];
} }
$pages[$pos[0]]['visible'][$res['name']] = $res['flag']; $pages[$pos[0]]['visible'][$res['name']] = $res['flag'];
} }
// get the same for the query strings // get the same for the query strings
$_edit_page_id = 0; $_edit_page_id = 0;
$q = "SELECT eqs.edit_page_id, name, value, dynamic FROM edit_query_string eqs "; $q = "SELECT eqs.edit_page_id, name, value, dynamic FROM edit_query_string eqs WHERE enabled = 1 AND edit_page_id IN (".join(', ', $edit_page_ids).") ORDER BY eqs.edit_page_id";
$q .= "WHERE enabled = 1 AND edit_page_id IN (".join(', ', $edit_page_ids).") ORDER BY eqs.edit_page_id"; while ($res = $this->db_return($q)) {
while ($res = $this->dbReturn($q)) {
if ($res['edit_page_id'] != $_edit_page_id) { if ($res['edit_page_id'] != $_edit_page_id) {
// search the pos in the array push // search the pos in the array push
$pos = $this->arraySearchRecursive($res['edit_page_id'], $pages, 'edit_page_id'); $pos = $this->array_search_recursive($res['edit_page_id'], $pages, 'edit_page_id');
$_edit_page_id = $res['edit_page_id']; $_edit_page_id = $res['edit_page_id'];
} }
$pages[$pos[0]]['query'][] = array ( $pages[$pos[0]]['query'][] = array (
@@ -456,17 +437,16 @@ class Login extends \CoreLibs\DB\IO
// load the edit_access user rights // load the edit_access user rights
$q = "SELECT ea.edit_access_id, level, type, ea.name, ea.color, ea.uid, 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 "; $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 .= "AND eau.enabled = 1 AND edit_user_id = ".$this->euid." ";
$q .= "ORDER BY ea.name"; $q .= "ORDER BY ea.name";
$unit_access = array(); $unit_access = array();
$eauid = array(); $eauid = array();
$unit_acl = array(); $unit_acl = array();
while ($res = $this->dbReturn($q)) { while ($res = $this->db_return($q)) {
// read edit access data fields and drop them into the unit access array // 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 AND edit_access_id = ".$res['edit_access_id']; $q_sub ="SELECT name, value FROM edit_access_data WHERE enabled = 1 AND edit_access_id = ".$res['edit_access_id'];
$ea_data = array (); $ea_data = array ();
while ($res_sub = $this->dbReturn($q_sub)) { while ($res_sub = $this->db_return($q_sub)) {
$ea_data[$res_sub['name']] = $res_sub['value']; $ea_data[$res_sub['name']] = $res_sub['value'];
} }
// build master unit array // build master unit array
@@ -498,10 +478,8 @@ class Login extends \CoreLibs\DB\IO
$login_error_date_first = ', login_error_date_first = NOW()'; $login_error_date_first = ', login_error_date_first = NOW()';
} }
// update login error count for this user // update login error count for this user
$q = "UPDATE edit_user "; $q = "UPDATE edit_user SET login_error_count = login_error_count + 1, login_error_date_last = NOW() $login_error_date_first WHERE edit_user_id = ".$res['edit_user_id'];
$q .= "SET login_error_count = login_error_count + 1, login_error_date_last = NOW() $login_error_date_first "; $this->db_exec($q);
$q .= "WHERE edit_user_id = ".$res['edit_user_id'];
$this->dbExec($q);
// totally lock the user if error max is reached // totally lock the user if error max is reached
if ($res['login_error_count'] + 1 > $this->max_login_error_count) { if ($res['login_error_count'] + 1 > $this->max_login_error_count) {
// do some alert reporting in case this error is too big // do some alert reporting in case this error is too big
@@ -522,19 +500,18 @@ class Login extends \CoreLibs\DB\IO
} // if he pressed login at least and is not yet loggined in } // if he pressed login at least and is not yet loggined in
} }
// METHOD: loginCheckPermissions // METHOD: login_check_permission
// WAS : login_check_permission
// PARAMS: none // PARAMS: none
// RETUNR none // RETUNR none
// DESC : for every page the user access this script checks if he is allowed to do so // DESC : for every page the user access this script checks if he is allowed to do so
public function loginCheckPermissions() public function login_check_permissions()
{ {
if ($this->euid && $this->login_error != 103) { if ($this->euid && $this->login_error != 103) {
$q = "SELECT filename "; $q = "SELECT filename ";
$q .= "FROM edit_page ep, edit_page_access epa, edit_group eg, edit_user eu "; $q .= "FROM edit_page ep, edit_page_access epa, edit_group eg, edit_user eu ";
$q .= "WHERE ep.edit_page_id = epa.edit_page_id AND eg.edit_group_id = epa.edit_group_id AND eg.edit_group_id = eu.edit_group_id "; $q .= "WHERE ep.edit_page_id = epa.edit_page_id AND eg.edit_group_id = epa.edit_group_id AND eg.edit_group_id = eu.edit_group_id ";
$q .= "AND eu.edit_user_id = ".$this->euid." AND filename = '".$this->page_name."' AND eg.enabled = 1 AND epa.enabled = 1"; $q .= "AND eu.edit_user_id = ".$this->euid." AND filename = '".$this->page_name."' AND eg.enabled = 1 AND epa.enabled = 1";
$res = $this->dbReturnRow($q); $res = $this->db_return_row($q);
// unset mem limit if debug is set to 1 // unset mem limit if debug is set to 1
// if (($GLOBALS["DEBUG_ALL"] || $GLOBALS["DB_DEBUG"] || $_SESSION["DEBUG_ALL"] || $_SESSION["DB_DEBUG"]) && ini_get('memory_limit') != -1) // if (($GLOBALS["DEBUG_ALL"] || $GLOBALS["DB_DEBUG"] || $_SESSION["DEBUG_ALL"] || $_SESSION["DB_DEBUG"]) && ini_get('memory_limit') != -1)
// ini_set('memory_limit', -1); // ini_set('memory_limit', -1);
@@ -549,12 +526,11 @@ class Login extends \CoreLibs\DB\IO
return $this->permission_okay; return $this->permission_okay;
} }
// METHOD: loginLogoutUser // METHOD: login_logout_user
// WAS : login_logout_user
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : if a user pressed on logout, destroyes session and unsets all global vars // DESC : if a user pressed on logout, destroyes session and unsets all global vars
public function loginLogoutUser() public function login_logout_user()
{ {
if ($this->logout || $this->login_error) { if ($this->logout || $this->login_error) {
// unregister and destroy session vars // unregister and destroy session vars
@@ -578,8 +554,7 @@ class Login extends \CoreLibs\DB\IO
} }
} }
// METHOD: loginSetAcl // METHOD: login_set_acl
// WAS : login_set_acl
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : sets all the basic ACLs // DESC : sets all the basic ACLs
@@ -596,7 +571,7 @@ class Login extends \CoreLibs\DB\IO
// * 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 loginSetAcl() public function login_set_acl()
{ {
// we start with the default acl // we start with the default acl
$this->acl['base'] = DEFAULT_ACL_LEVEL; $this->acl['base'] = DEFAULT_ACL_LEVEL;
@@ -606,7 +581,6 @@ class Login extends \CoreLibs\DB\IO
$this->acl['admin'] = 1; $this->acl['admin'] = 1;
$this->acl['base'] = 100; $this->acl['base'] = 100;
} else { } else {
$this->acl['admin'] = 0;
// now go throw the flow and set the correct ACL // now go throw the flow and set the correct ACL
// user > page > group // user > page > group
// group ACL 0 // group ACL 0
@@ -680,12 +654,11 @@ class Login extends \CoreLibs\DB\IO
// $this->debug('ACL', $this->print_ar($this->acl)); // $this->debug('ACL', $this->print_ar($this->acl));
} }
// METHOD: loginCheckEditAccess // METHOD: login_check_edit_access
// WAS : login_check_edit_access
// PARAMS: edit_access_id to check // PARAMS: edit_access_id to check
// RETURN: true/false: if the edit access is not in the valid list: false // RETURN: true/false: if the edit access is not in the valid list: false
// DESC : checks if this edit access id is valid // DESC : checks if this edit access id is valid
public function loginCheckEditAccess($edit_access_id) public function login_check_edit_access($edit_access_id)
{ {
if (array_key_exists($edit_access_id, $this->acl['unit'])) { if (array_key_exists($edit_access_id, $this->acl['unit'])) {
return true; return true;
@@ -716,25 +689,24 @@ class Login extends \CoreLibs\DB\IO
return $is_valid_password; return $is_valid_password;
} }
// METHOD: loginPasswordChange // METHOD: login_password_change
// WAS : login_password_change
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : changes a user password // DESC : changes a user password
private function loginPasswordChange() private function login_password_change()
{ {
if ($this->change_password) { if ($this->change_password) {
$event = 'Password Change'; $event = 'Password Change';
// check that given username is NOT in the deny list, else silent skip (with error log) // check that given username is NOT in the deny list, else silent skip (with error log)
if (!in_array($this->pw_username, $this->pw_change_deny_users)) { if (!in_array($this->pw_username, $this->pw_change_deny_users)) {
if (!$this->pw_username || !$this->pw_old_password) { if (!$this->pw_username || !$this->pw_password) {
$this->login_error = 200; $this->login_error = 200;
$data = 'Missing username or old password.'; $data = 'Missing username or old password.';
} }
// check user exist, if not -> error // check user exist, if not -> error
if (!$this->login_error) { if (!$this->login_error) {
$q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->dbEscapeString($this->pw_username)."'"; $q = "SELECT edit_user_id FROM edit_user WHERE enabled = 1 AND username = '".$this->db_escape_string($this->pw_username)."'";
list ($edit_user_id) = $this->dbReturnRow($q); list ($edit_user_id) = $this->db_return_row($q);
if (!$edit_user_id) { if (!$edit_user_id) {
// username wrong // username wrong
$this->login_error = 201; $this->login_error = 201;
@@ -767,7 +739,7 @@ class Login extends \CoreLibs\DB\IO
} }
// password shall match to something in minimum length or form // password shall match to something in minimum length or form
if (!$this->login_error) { if (!$this->login_error) {
if (!$this->loginPasswordChangeValidPassword($this->pw_new_password)) { if (!$this->loingPasswordChangeValidPassword($this->pw_new_password)) {
$this->login_error = 205; $this->login_error = 205;
$data = 'The new password string is not valid'; $data = 'The new password string is not valid';
} }
@@ -775,8 +747,8 @@ class Login extends \CoreLibs\DB\IO
// no error change this users password // no error change this users password
if (!$this->login_error) { if (!$this->login_error) {
// update the user (edit_user_id) with the new password // update the user (edit_user_id) with the new password
$q = "UPDATE edit_user SET password = '".$this->dbEscapeString($this->passwordSet($this->pw_new_password))."' WHERE edit_user_id = ".$edit_user_id; $q = "UPDATE edit_user SET password = '".$this->db_escape_string($this->passwordSet($this->pw_new_password))."' WHERE edit_user_id = ".$edit_user_id;
$this->dbExec($q); $this->db_exec($q);
$data = 'Password change for user "'.$this->pw_username.'"'; $data = 'Password change for user "'.$this->pw_username.'"';
$this->password_change_ok = true; $this->password_change_ok = true;
} }
@@ -786,20 +758,19 @@ class Login extends \CoreLibs\DB\IO
$data = 'Illegal user for password change: '.$this->pw_username; $data = 'Illegal user for password change: '.$this->pw_username;
} }
// log this password change attempt // log this password change attempt
$this->writeLog($event, $data, $this->login_error, $this->pw_username); $this->write_log($event, $data, $this->login_error, $pw_username);
} // button pressed } // button pressed
} }
// METHOD: loginPrintLogin // METHOD: login_print_login
// WAS : login_print_login
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : prints out login html part if no permission (error) is set // DESC : prints out login html part if no permission (error) is set
private function loginPrintLogin() private function login_print_login()
{ {
if (!$this->permission_okay) { if (!$this->permission_okay) {
// set the templates now // set the templates now
$this->loginSetTemplates(); $this->login_set_templates();
// if there is a global logout target ... // if there is a global logout target ...
if (file_exists($this->logout_target) && $this->logout_target) { if (file_exists($this->logout_target) && $this->logout_target) {
$LOGOUT_TARGET = $this->logout_target; $LOGOUT_TARGET = $this->logout_target;
@@ -816,14 +787,14 @@ class Login extends \CoreLibs\DB\IO
// pre change the data in the PASSWORD_CHANGE_DIV first // pre change the data in the PASSWORD_CHANGE_DIV first
foreach ($this->login_template['strings'] as $string => $data) { foreach ($this->login_template['strings'] as $string => $data) {
if ($data) { if ($data) {
$html_string_password_change = str_replace('{'.$string.'}', $data, $html_string_password_change); $html_string_password_change = str_replace("{".$string."}", $data, $html_string_password_change);
} }
} }
// print error messagae // print error messagae
if ($this->login_error) { if ($this->login_error) {
$html_string_password_change = str_replace('{ERROR_MSG}', $this->login_error_msg[$this->login_error].'<br>', $html_string_password_change); $html_string_password_change = str_replace("{ERROR_MSG}", $this->login_error_msg[$this->login_error]."<br>", $html_string_password_change);
} else { } else {
$html_string_password_change = str_replace('{ERROR_MSG}', '<br>', $html_string_password_change); $html_string_password_change = str_replace("{ERROR_MSG}", "<br>", $html_string_password_change);
} }
// if pw change action, show the float again // if pw change action, show the float again
if ($this->change_password && !$this->password_change_ok) { if ($this->change_password && !$this->password_change_ok) {
@@ -836,23 +807,23 @@ class Login extends \CoreLibs\DB\IO
// put in the logout redirect string // put in the logout redirect string
if ($this->logout && $LOGOUT_TARGET) { if ($this->logout && $LOGOUT_TARGET) {
$html_string = str_replace('{LOGOUT_TARGET}', '<meta http-equiv="refresh" content="0; URL='.$LOGOUT_TARGET.'">', $html_string); $html_string = str_replace("{LOGOUT_TARGET}", '<meta http-equiv="refresh" content="0; URL='.$LOGOUT_TARGET.'">', $html_string);
} else { } else {
$html_string = str_replace('{LOGOUT_TARGET}', '', $html_string); $html_string = str_replace("{LOGOUT_TARGET}", '', $html_string);
} }
// print error messagae // print error messagae
if ($this->login_error) { if ($this->login_error) {
$html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[$this->login_error].'<br>', $html_string); $html_string = str_replace("{ERROR_MSG}", $this->login_error_msg[$this->login_error]."<br>", $html_string);
} elseif ($this->password_change_ok && $this->password_change) { } elseif ($this->password_change_ok && $this->password_change) {
$html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[300].'<br>', $html_string); $html_string = str_replace('{ERROR_MSG}', $this->login_error_msg[300].'<br>', $html_string);
} else { } else {
$html_string = str_replace('{ERROR_MSG}', '<br>', $html_string); $html_string = str_replace("{ERROR_MSG}", "<br>", $html_string);
} }
// create the replace array context // create the replace array context
foreach ($this->login_template['strings'] as $string => $data) { foreach ($this->login_template['strings'] as $string => $data) {
$html_string = str_replace('{'.$string.'}', $data, $html_string); $html_string = str_replace("{".$string."}", $data, $html_string);
} }
// return the created HTML here // return the created HTML here
@@ -860,12 +831,11 @@ class Login extends \CoreLibs\DB\IO
} // if permission is 0 then print out login } // if permission is 0 then print out login
} }
// METHOD: loginCloseClass // METHOD: login_close_class
// WAS : login_close_class
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : last function called, writes log and prints out error msg and exists script if permission 0 // DESC : last function called, writes log and prints out error msg and exists script if permission 0
private function loginCloseClass() private function login_close_class()
{ {
// write to LOG table ... // write to LOG table ...
if ($this->login_error || $this->login || $this->logout) { if ($this->login_error || $this->login || $this->logout) {
@@ -883,9 +853,9 @@ class Login extends \CoreLibs\DB\IO
if ($this->euid) { if ($this->euid) {
// get user from user table // get user from user table
$q = "SELECT username, password FROM edit_user WHERE edit_user_id = ".$this->euid; $q = "SELECT username, password FROM edit_user WHERE edit_user_id = ".$this->euid;
list($username, $password) = $this->dbReturnRow($q); list($username, $password) = $this->db_return_row($q);
} // if euid is set, get username (or try) } // if euid is set, get username (or try)
$this->writeLog($event, '', $this->login_error, $username); $this->write_log($event, '', $this->login_error, $username);
} // write log under certain settings } // write log under certain settings
// now close DB connection // now close DB connection
// $this->error_msg = $this->_login(); // $this->error_msg = $this->_login();
@@ -896,12 +866,11 @@ class Login extends \CoreLibs\DB\IO
} }
} }
// METHOD: loginSetTemplates // METHOD: login_set_templates
// WAS : login_set_templates
// PARAMS: // PARAMS:
// RETURN: none // RETURN: none
// DESC : checks if there are external templates, if not uses internal fallback ones // DESC : checks if there are external templates, if not uses internal fallback ones
private function loginSetTemplates() private function login_set_templates()
{ {
$strings = array ( $strings = array (
'HTML_TITLE' => $this->l->__("LOGIN"), 'HTML_TITLE' => $this->l->__("LOGIN"),
@@ -919,7 +888,6 @@ class Login extends \CoreLibs\DB\IO
"1010" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // user not found "1010" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // user not found
"1011" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // blowfish password wrong "1011" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // blowfish password wrong
"1012" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // fallback md5 password wrong "1012" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // fallback md5 password wrong
"1013" => $this->l->__("Fatal Error: <b>Login Failed - Wrong Username or Password</b>"), // new password_hash wrong
"102" => $this->l->__("Fatal Error: <b>Login Failed - Please enter username and password</b>"), "102" => $this->l->__("Fatal Error: <b>Login Failed - Please enter username and password</b>"),
"103" => $this->l->__("Fatal Error: <b>You do not have the rights to access this Page</b>"), "103" => $this->l->__("Fatal Error: <b>You do not have the rights to access this Page</b>"),
"104" => $this->l->__("Fatal Error: <b>Login Failed - User not enabled</b>"), "104" => $this->l->__("Fatal Error: <b>Login Failed - User not enabled</b>"),
@@ -969,14 +937,14 @@ EOM;
} }
// first check if all strings are set from outside, if not, set with default ones // first check if all strings are set from outside, if not, set with default ones
foreach ($strings as $string => $data) { while (list($string, $data) = each($strings)) {
if (!array_key_exists($string, $this->login_template['strings'])) { if (!array_key_exists($string, $this->login_template['strings'])) {
$this->login_template['strings'][$string] = $data; $this->login_template['strings'][$string] = $data;
} }
} }
// error msgs the same // error msgs the same
foreach ($error_msgs as $code => $data) { while (list($code, $data) = each($error_msgs)) {
if (!array_key_exists($code, $this->login_error_msg)) { if (!array_key_exists($code, $this->login_error_msg)) {
$this->login_error_msg[$code] = $data; $this->login_error_msg[$code] = $data;
} }
@@ -1049,14 +1017,13 @@ EOM;
} }
} }
// METHOD: writeLog // METHOD: write_log
// WAS : write_log
// PARAMS: event -> string of what has been done // PARAMS: event -> string of what has been done
// data -> data information (id, etc) // data -> data information (id, etc)
// error -> if error, write error string (not enougth data, etc) // error -> if error, write error string (not enougth data, etc)
// RETURN: none // RETURN: none
// DESC : writes detailed data into the edit user log table (keep log what user does) // DESC : writes detailed data into the edit user log table (keep log what user does)
private function writeLog($event, $data, $error = '', $username = '') private function write_log($event, $data, $error = '', $username = '')
{ {
if ($this->login) { if ($this->login) {
$this->action = 'Login'; $this->action = 'Login';
@@ -1072,34 +1039,31 @@ EOM;
'_FILES' => $_FILES, '_FILES' => $_FILES,
'error' => $this->login_error 'error' => $this->login_error
); );
$data_binary = $this->dbEscapeBytea(bzcompress(serialize($_data_binary))); $data_binary = $this->db_escape_bytea(bzcompress(serialize($_data_binary)));
// SQL querie for log entry // SQL querie for log entry
$q = "INSERT INTO edit_log "; $q = "INSERT INTO edit_log ";
$q .= "(username, password, euid, event_date, event, error, data, data_binary, page, "; $q .= "(username, password, euid, event_date, event, error, data, data_binary, page, ";
$q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, "; $q .= "ip, user_agent, referer, script_name, query_string, server_name, http_host, http_accept, http_accept_charset, http_accept_encoding, session_id, ";
$q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) "; $q .= "action, action_id, action_yes, action_flag, action_menu, action_loaded, action_value, action_error) ";
$q .= "VALUES ('".$this->dbEscapeString($username)."', 'PASSWORD', ".(($this->euid) ? $this->euid : 'NULL').", "; $q .= "VALUES ('".$this->db_escape_string($username)."', 'PASSWORD', ".(($this->euid) ? $this->euid : 'NULL').", ";
$q .= "NOW(), '".$this->dbEscapeString($event)."', '".$this->dbEscapeString($error)."', '".$this->dbEscapeString($data)."', '".$data_binary."', '".$this->page_name."', "; $q .= "NOW(), '".$this->db_escape_string($event)."', '".$this->db_escape_string($error)."', '".$this->db_escape_string($data)."', '".$data_binary."', '".$this->page_name."', ";
foreach (array( foreach (array('REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'SCRIPT_FILENAME', 'QUERY_STRING', 'SERVER_NAME', 'HTTP_HOST', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING') as $server_code) {
'REMOTE_ADDR', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'SCRIPT_FILENAME', 'QUERY_STRING', 'SERVER_NAME', 'HTTP_HOST', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING'
) as $server_code) {
if (array_key_exists($server_code, $_SERVER)) { if (array_key_exists($server_code, $_SERVER)) {
$q .= "'".$this->dbEscapeString($_SERVER[$server_code])."', "; $q .= "'".$this->db_escape_string($_SERVER[$server_code])."', ";
} else { } else {
$q .= "NULL, "; $q .= "NULL, ";
} }
} }
$q .= "'".session_id()."', "; $q .= "'".session_id()."', ";
$q .= "'".$this->dbEscapeString($this->action)."', '".$this->dbEscapeString($this->username)."', NULL, '".$this->dbEscapeString($this->login_error)."', NULL, NULL, '".$this->dbEscapeString($this->permission_okay)."', NULL)"; $q .= "'".$this->db_escape_string($this->action)."', '".$this->db_escape_string($this->username)."', NULL, '".$this->db_escape_string($this->login_error)."', NULL, NULL, '".$this->db_escape_string($this->permission_okay)."', NULL)";
$this->dbExec($q, 'NULL'); $this->db_exec($q, 'NULL');
} }
// METHOD: loginCheckEditAccessId // METHOD: login_check_edit_access_id
// WAS : login_check_edit_access_id
// PARAMS: edit access id to check // PARAMS: edit access id to check
// RETURN: same edit access id if ok, or the default edit access id if given one is not valud // RETURN: same edit access id if ok, or the default edit access id if given one is not valud
// DESC : checks that the given edit access id is valid for this user // DESC : checks that the given edit access id is valid for this user
public function loginCheckEditAccessId($edit_access_id) public function login_check_edit_access_id($edit_access_id)
{ {
if (!array_key_exists($edit_access_id, $_SESSION["UNIT"])) { if (!array_key_exists($edit_access_id, $_SESSION["UNIT"])) {
return $_SESSION["UNIT_DEFAULT"]; return $_SESSION["UNIT_DEFAULT"];
@@ -1108,12 +1072,11 @@ EOM;
} }
} }
// METHOD: loginSetEditAccessData // METHOD: login_set_edit_access_data
// WAS : login_set_edit_access_data
// PARAMS: edit access id, key value to search for // PARAMS: edit access id, key value to search for
// RETURN: false for not found or string for found data // 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 // DESC : searchs in the data set for the unit for the data key and returns the value asociated with it
public function loginSetEditAccessData($edit_access_id, $data_key) public function login_set_edit_access_data($edit_access_id, $data_key)
{ {
if (!$_SESSION['UNIT'][$edit_access_id]['data'][$data_key]) { if (!$_SESSION['UNIT'][$edit_access_id]['data'][$data_key]) {
return false; return false;
@@ -1122,5 +1085,3 @@ EOM;
} }
} }
} // close class } // close class
# __END__

View File

@@ -8,13 +8,9 @@
* Update: Clemens Schwaighofer * Update: Clemens Schwaighofer
* Date: 2012.9.5 [stacked output] * Date: 2012.9.5 [stacked output]
* Date: 2013.2.21 [proper class formatting] * Date: 2013.2.21 [proper class formatting]
* Date: 2017.4.13 [no output fix with cache overload]
* Date: 2018.3.28 [PHPCS + namespace]
* *
*/ */
namespace CoreLibs\Output;
class ProgressBar class ProgressBar
{ {
// private vars // private vars
@@ -84,13 +80,13 @@ class ProgressBar
$this->height = $height; $this->height = $height;
} }
// needs to be called twice or I do not get any output // needs to be called twice or I do not get any output
$this->__flushCache($this->clear_buffer_size_init); $this->_flushCache($this->clear_buffer_size_init);
$this->__flushCache($this->clear_buffer_size_init); $this->_flushCache($this->clear_buffer_size_init);
} }
// private functions // private functions
private function __flushCache($clear_buffer_size = 0) private function _flushCache($clear_buffer_size = 0)
{ {
if (!$clear_buffer_size) { if (!$clear_buffer_size) {
$clear_buffer_size = $this->clear_buffer_size; $clear_buffer_size = $this->clear_buffer_size;
@@ -100,7 +96,7 @@ class ProgressBar
flush(); flush();
} }
private function __calculatePercent($step) private function _calculatePercent($step)
{ {
// avoid divison through 0 // avoid divison through 0
if ($this->max - $this->min == 0) { if ($this->max - $this->min == 0) {
@@ -113,7 +109,7 @@ class ProgressBar
return $percent; return $percent;
} }
private function __calculatePosition($step) private function _calculatePosition($step)
{ {
switch ($this->direction) { switch ($this->direction) {
case 'right': case 'right':
@@ -166,7 +162,7 @@ class ProgressBar
return $position; return $position;
} }
private function __setStep($step) private function _setStep($step)
{ {
if ($step > $this->max) { if ($step > $this->max) {
$step = $this->max; $step = $this->max;
@@ -327,7 +323,7 @@ class ProgressBar
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";'; $output .= 'document.getElementById("plbl'.$name.$this->code.'").style.align="'.$this->label[$name]['align'].'";';
$output .= '</script>'."\n"; $output .= '</script>'."\n";
echo $output; echo $output;
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -336,7 +332,7 @@ class ProgressBar
$this->label[$name]['color'] = $color; $this->label[$name]['color'] = $color;
if ($this->status != 'new') { if ($this->status != 'new') {
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.color="'.$color.'";</script>'."\n"; echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.color="'.$color.'";</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -345,7 +341,7 @@ class ProgressBar
$this->label[$name]['bgr_color'] = $color; $this->label[$name]['bgr_color'] = $color;
if ($this->status != 'new') { if ($this->status != 'new') {
echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.background="'.$color.'";</script>'."\n"; echo '<script type="text/JavaScript">document.getElementById("plbl'.$name.$this->code.'").style.background="'.$color.'";</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -380,7 +376,7 @@ class ProgressBar
$output .= 'document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";'; $output .= 'document.getElementById("plbl'.$name.$this->code.'").style.font-weight="'.$this->label[$name]['font-weight'].'";';
$output .= '</script>'."\n"; $output .= '</script>'."\n";
echo $output; echo $output;
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -390,7 +386,7 @@ class ProgressBar
// print "NAME[$name], Status: ".$this->status.": ".$value."<Br>"; // print "NAME[$name], Status: ".$this->status.": ".$value."<Br>";
if ($this->status != 'new') { if ($this->status != 'new') {
echo '<script type="text/JavaScript">PBlabelText'.$this->code.'("'.$name.'","'.$this->label[$name]['value'].'");</script>'."\n"; echo '<script type="text/JavaScript">PBlabelText'.$this->code.'("'.$name.'","'.$this->label[$name]['value'].'");</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -399,7 +395,7 @@ class ProgressBar
$this->color = $color; $this->color = $color;
if ($this->status != 'new') { if ($this->status != 'new') {
echo '<script type="text/JavaScript">document.getElementById("pbar'.$this->code.'").style.background="'.$color.'";</script>'."\n"; echo '<script type="text/JavaScript">document.getElementById("pbar'.$this->code.'").style.background="'.$color.'";</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -408,7 +404,7 @@ class ProgressBar
$this->bgr_color = $color; $this->bgr_color = $color;
if ($this->status != 'new') { if ($this->status != 'new') {
echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.background="'.$color.'";</script>'."\n"; echo '<script type="text/JavaScript">document.getElementById("pbrd'.$this->code.'").style.background="'.$color.'";</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -417,7 +413,7 @@ class ProgressBar
$this->direction = $direction; $this->direction = $direction;
if ($this->status != 'new') { if ($this->status != 'new') {
$this->position = $this->__calculatePosition($this->step); $this->position = $this->_calculatePosition($this->step);
echo '<script type="text/JavaScript">'; echo '<script type="text/JavaScript">';
echo 'PBposition'.$this->code.'("left",'.$this->position['left'].');'; echo 'PBposition'.$this->code.'("left",'.$this->position['left'].');';
@@ -425,7 +421,7 @@ class ProgressBar
echo 'PBposition'.$this->code.'("width",'.$this->position['width'].');'; echo 'PBposition'.$this->code.'("width",'.$this->position['width'].');';
echo 'PBposition'.$this->code.'("height",'.$this->position['height'].');'; echo 'PBposition'.$this->code.'("height",'.$this->position['height'].');';
echo '</script>'."\n"; echo '</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -435,8 +431,8 @@ class ProgressBar
$js = ''; $js = '';
$html_button = ''; $html_button = '';
$this->__setStep($this->step); $this->_setStep($this->step);
$this->position = $this->__calculatePosition($this->step); $this->position = $this->_calculatePosition($this->step);
if ($this->top || $this->left) { if ($this->top || $this->left) {
$style_master = 'position:relative;top:'.$this->top.'px;left:'.$this->left.'px;width:'.($this->width + 10).'px;'; $style_master = 'position:relative;top:'.$this->top.'px;left:'.$this->left.'px;width:'.($this->width + 10).'px;';
@@ -528,11 +524,11 @@ class ProgressBar
// only one inner percent // only one inner percent
// print "STYLE[$name]: ".$style_lbl."<br>"; // print "STYLE[$name]: ".$style_lbl."<br>";
if (!$html_percent) { if (!$html_percent) {
$html_percent = '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'width:'.$data['width'].'px;line-height:1;text-shadow: 0 0 .2em white, 0 0 .5em white;">'.$this->__calculatePercent($this->step).'%</div>'."\n"; $html_percent = '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'width:'.$data['width'].'px;line-height:1;text-shadow: 0 0 .2em white, 0 0 .5em white;">'.$this->_calculatePercent($this->step).'%</div>'."\n";
} }
break; break;
case 'percentlbl': case 'percentlbl':
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'width:'.$data['width'].'px;">'.$this->__calculatePercent($this->step).'%</div>'."\n"; $html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'width:'.$data['width'].'px;">'.$this->_calculatePercent($this->step).'%</div>'."\n";
break; break;
case 'crossbar': case 'crossbar':
$html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$data['value'].'</div>'."\n"; $html .= '<div id="plbl'.$name.$this->code.'" style="'.$style_lbl.'">'.$data['value'].'</div>'."\n";
@@ -582,16 +578,16 @@ class ProgressBar
{ {
$this->status = 'show'; $this->status = 'show';
echo $this->getHtml(); echo $this->getHtml();
$this->__flushCache(); $this->_flushCache();
} }
public function moveStep($step) public function moveStep($step)
{ {
$last_step = $this->step; $last_step = $this->step;
$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')) {
if ($this->direction=='left') { if ($this->direction=='left') {
$js .= 'PBposition'.$this->code.'("left",'.$new_position['left'].');'; $js .= 'PBposition'.$this->code.'("left",'.$new_position['left'].');';
@@ -615,8 +611,8 @@ class ProgressBar
break; break;
case 'percentlbl': case 'percentlbl':
case 'percent': case 'percent':
$percent = $this->__calculatePercent($this->step); $percent = $this->_calculatePercent($this->step);
if ($percent != $this->__calculatePercent($last_step)) { if ($percent != $this->_calculatePercent($last_step)) {
$js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$percent.'%");'; $js .= 'PBlabelText'.$this->code.'("'.$name.'","'.$percent.'%");';
} }
break; break;
@@ -628,7 +624,7 @@ class ProgressBar
} }
if ($js != '') { if ($js != '') {
echo '<script type="text/JavaScript">'.$js.'</script>'."\n"; echo '<script type="text/JavaScript">'.$js.'</script>'."\n";
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -651,7 +647,7 @@ class ProgressBar
$output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="hidden";document.getElementById("pbm'.$this->code.'").style.display="none";'; $output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="hidden";document.getElementById("pbm'.$this->code.'").style.display="none";';
$output .= '</script>'."\n"; $output .= '</script>'."\n";
echo $output; echo $output;
$this->__flushCache(); $this->_flushCache();
} }
} }
@@ -664,9 +660,7 @@ class ProgressBar
$output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="visible";document.getElementById("pbm'.$this->code.'").style.visibility="block";'; $output .= 'document.getElementById("pbm'.$this->code.'").style.visibility="visible";document.getElementById("pbm'.$this->code.'").style.visibility="block";';
$output .= '</script>'."\n"; $output .= '</script>'."\n";
echo $output; echo $output;
$this->__flushCache(); $this->_flushCache();
} }
} }
} }
# __END__

View File

@@ -1,6 +1,6 @@
<?php <?
/******************************************************************** /********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2004/12/21 * CREATED: 2004/12/21
* SHORT DESCRIPTION: * SHORT DESCRIPTION:
* extends smarty with the l10n class so I can use __(, etc calls * extends smarty with the l10n class so I can use __(, etc calls
@@ -8,14 +8,12 @@
* 2005/06/22 (cs) include smarty class here, so there is no need to include it in the main file * 2005/06/22 (cs) include smarty class here, so there is no need to include it in the main file
*********************************************************************/ *********************************************************************/
namespace CoreLibs\Template; // read in the Smarty class for definition
// use smarty BC for backwards compability
// try to include file from LIBS path, or from normal path
_spl_autoload('SmartyBC.class.php');
// I need to manually load Smarty BC here (it is not namespaced) class SmartyML extends SmartyBC
require_once(BASE.LIB.SMARTY.'SmartyBC.class.php');
// So it doesn't start looking around in the wrong naemspace as smarty doesn't have one
use SmartyBC;
class SmartyExtend extends SmartyBC
{ {
public $l10n; public $l10n;
@@ -23,10 +21,9 @@ class SmartyExtend extends SmartyBC
public function __construct($lang) public function __construct($lang)
{ {
SmartyBC::__construct(); SmartyBC::__construct();
$this->l10n = new \CoreLibs\Language\L10n($lang); _spl_autoload('Class.l10n.inc');
$this->l10n = new l10n($lang);
// variable variable register // variable variable register
$this->register_modifier('getvar', array(&$this, 'get_template_vars')); $this->register_modifier('getvar', array(&$this, 'get_template_vars'));
} }
} }
# __END__

View File

@@ -1,8 +1,8 @@
<?php <?
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2004/11/18 * CREATED: 2004/11/18
* VERSION: 1.0.0 * VERSION: 0.1.1
* RELEASED LICENSE: GNU GPL 3 * RELEASED LICENSE: GNU GPL 3
* SHORT DESCRIPTION: * SHORT DESCRIPTION:
* init class for gettext. Original was just a function & var setting include for wordpress. * init class for gettext. Original was just a function & var setting include for wordpress.
@@ -14,7 +14,7 @@
* *
* PUBLIC METHODS * PUBLIC METHODS
* __: returns string (translated or original if not found) * __: returns string (translated or original if not found)
* __e: echos out string (translated or original if not found) * _e: echos out string (translated or original if not found)
* __ngettext: should return plural. never tested this. * __ngettext: should return plural. never tested this.
* *
* PRIVATE METHODS * PRIVATE METHODS
@@ -23,12 +23,10 @@
* 2005/10/17 (cs) made an on the fly switch method (reload of lang) * 2005/10/17 (cs) made an on the fly switch method (reload of lang)
*********************************************************************/ *********************************************************************/
namespace CoreLibs\Language; // try to include file from LIBS path, or from normal path
_spl_autoload('Class.Basic.inc');
use \CoreLibs\Language\Core\FileReader; class l10n extends basic
use \CoreLibs\Language\Core\GetTextReader;
class L10n extends \CoreLibs\Basic
{ {
private $lang = ''; private $lang = '';
private $mofile = ''; private $mofile = '';
@@ -37,6 +35,10 @@ class L10n extends \CoreLibs\Basic
public function __construct($lang = '', $path = DEFAULT_TEMPLATE) public function __construct($lang = '', $path = DEFAULT_TEMPLATE)
{ {
foreach (array('streams.php', 'gettext.php') as $include_file) {
_spl_autoload($include_file);
}
if (!$lang) { if (!$lang) {
$this->lang = 'en'; $this->lang = 'en';
} else { } else {
@@ -58,7 +60,7 @@ class L10n extends \CoreLibs\Basic
$this->input = false; $this->input = false;
} }
$this->l10n = new GetTextReader($this->input); $this->l10n = new gettext_reader($this->input);
} }
// reloads the mofile, if the location of the lang file changes // reloads the mofile, if the location of the lang file changes
@@ -80,7 +82,7 @@ class L10n extends \CoreLibs\Basic
// check if get a readable mofile // check if get a readable mofile
if (is_readable($this->mofile)) { if (is_readable($this->mofile)) {
$this->input = new FileReader($this->mofile); $this->input = new FileReader($this->mofile);
$this->l10n = new GetTextReader($this->input); $this->l10n = new gettext_reader($this->input);
} else { } else {
// else fall back to the old ones // else fall back to the old ones
$this->mofile = $old_mofile; $this->mofile = $old_mofile;
@@ -93,7 +95,7 @@ class L10n extends \CoreLibs\Basic
return $this->l10n->translate($text); return $this->l10n->translate($text);
} }
public function __e($text) public function _e($text)
{ {
echo $this->l10n->translate($text); echo $this->l10n->translate($text);
} }
@@ -104,12 +106,12 @@ class L10n extends \CoreLibs\Basic
return $this->l10n->ngettext($single, $plural, $number); return $this->l10n->ngettext($single, $plural, $number);
} }
public function __getLang() public function __get_lang()
{ {
return $this->lang; return $this->lang;
} }
public function __getMoFile() public function __get_mofile()
{ {
return $this->mofile; return $this->mofile;
} }

View File

@@ -1,4 +1,4 @@
<?php <?
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens Schwaighofer
* CREATED: 2011/2/8 * CREATED: 2011/2/8
@@ -8,13 +8,7 @@
*********************************************************************/ *********************************************************************/
// define the base working directory outside because in the function it might return undefined // define the base working directory outside because in the function it might return undefined
// if we have config set BASE use this DEFINE('CURRENT_WORKING_DIR', getcwd().'/');
if (defined('BASE')) {
DEFINE('CURRENT_WORKING_DIR', BASE);
} else {
// else we set. We fully assuem that Error.Handling is where it should be, in lib dir
DEFINE('CURRENT_WORKING_DIR', str_replace('lib', '', __DIR__));
}
// METHOD: MyErrorHandler // METHOD: MyErrorHandler
// PARAMS: $type: the error code from PHP // PARAMS: $type: the error code from PHP

View File

@@ -1,9 +1,71 @@
<?php <?php
namespace CoreLibs\Upload; /**
* Handle file uploads via XMLHttpRequest
*/
class qqUploadedFileXhr
{
/**
* Save the file to the specified path
* @return boolean TRUE on success
*/
public function save($path)
{
$input = fopen("php://input", "r");
$temp = tmpfile();
$realSize = stream_copy_to_stream($input, $temp);
fclose($input);
use \CoreLibs\Upload\Core\qqUploadedFileForm; if ($realSize != $this->getSize()) {
use \CoreLibs\Upload\Core\qqUploadedFileXhr; return false;
}
$target = fopen($path, "w");
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
return true;
}
public function getName()
{
return $_GET['qqfile'];
}
public function getSize()
{
if (isset($_SERVER["CONTENT_LENGTH"])) {
return (int)$_SERVER["CONTENT_LENGTH"];
} else {
throw new Exception('Getting content length is not supported.');
}
}
}
/**
* Handle file uploads via regular form post (uses the $_FILES array)
*/
class qqUploadedFileForm
{
/**
* Save the file to the specified path
* @return boolean TRUE on success
*/
public function save($path)
{
if (!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) {
return false;
}
return true;
}
public function getName()
{
return $_FILES['qqfile']['name'];
}
public function getSize()
{
return $_FILES['qqfile']['size'];
}
}
class qqFileUploader class qqFileUploader
{ {
@@ -108,5 +170,3 @@ class qqFileUploader
} }
} }
} }
# __END__

View File

@@ -0,0 +1 @@
Class.Progressbar.inc

View File

@@ -1,13 +1,10 @@
<?php <?php
/********************************************************************* /*********************************************************************
* AUTHOR: Clemens Schwaighofer * AUTHOR: Clemens "Gullevek" Schwaighofer (www.gullevek.org)
* CREATED: 2003/04/09 * CREATED: 2003/04/09
* SHORT DESCRIPTION: * SHORT DESCRIPTION:
* 2018/3/23, the whole class system is transformed to namespaces
* also all internal class calls are converted to camel case
*
* pgsql wrapper calls * pgsql wrapper calls
*
* HISTORY: * HISTORY:
* 2008/04/16 (cs) wrapper for pg escape string * 2008/04/16 (cs) wrapper for pg escape string
* 2007/01/11 (cs) add prepare/execute for postgres * 2007/01/11 (cs) add prepare/execute for postgres
@@ -41,9 +38,7 @@
* *
*/ */
namespace CoreLibs\DB\SQL; class db_pgsql
class PgSQL
{ {
private $last_error_query; private $last_error_query;
private $dbh; private $dbh;
@@ -56,12 +51,7 @@ class PgSQL
{ {
} }
// METHOD: __dbLastErrorQuery public function _db_last_error_query()
// WAS : _db_last_error_query
// PARAMS: none
// RETURN: true/false if last error is set
// DESC : queries last error query and returns true or false if error was set
public function __dbLastErrorQuery()
{ {
if ($this->last_error_query) { if ($this->last_error_query) {
return true; return true;
@@ -70,12 +60,11 @@ class PgSQL
} }
} }
// METHOD: __dbQuery // METHOD: _db_query
// WAS : _db_query
// PARAMS: query // PARAMS: query
// RETURN: query result // RETURN: query result
// DESC : wrapper for gp_query, catches error and stores it in class var // DESC : wrapper for gp_query, catches error and stores it in class var
public function __dbQuery($query) public function _db_query($query)
{ {
$this->last_error_query = ''; $this->last_error_query = '';
// read out the query status and save the query if needed // read out the query status and save the query if needed
@@ -86,22 +75,20 @@ class PgSQL
return $result; return $result;
} }
// METHOD: __dbSendQuery // METHOD: _db_send_query
// WAS : _db_send_query
// PARAMS: query // PARAMS: query
// RETURN: true/false if query was sent successful // RETURN: true/false if query was sent successful
// DESC : sends an async query to the server // DESC : sends an async query to the server
public function __dbSendQuery($query) public function _db_send_query($query)
{ {
return pg_send_query($this->dbh, $query); return pg_send_query($this->dbh, $query);
} }
// METHOD: __dbGetResult // METHOD: _db_get_result
// WAS : _db_get_result
// PARAMS: none // PARAMS: none
// RETURN: resource handler // RETURN: resource handler
// DESC : wrapper for pg_get_result // DESC : wrapper for pg_get_result
public function __dbGetResult() public function _db_get_result()
{ {
$this->last_error_query = ''; $this->last_error_query = '';
$result = pg_get_result($this->dbh); $result = pg_get_result($this->dbh);
@@ -111,12 +98,11 @@ class PgSQL
return $result; return $result;
} }
// METHOD: __dbClose // METHOD: _db_close
// WAS : _db_close
// PARAMS: none // PARAMS: none
// RETURN: none // RETURN: none
// DESC : wrapper for pg_close // DESC : wrapper for pg_close
public function __dbClose() public function _db_close()
{ {
if (is_resource($this->dbh)) { if (is_resource($this->dbh)) {
if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) { if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) {
@@ -125,12 +111,11 @@ class PgSQL
} }
} }
// METHOD: __dbPrepare // METHOD: _db_prepare
// WAS : _db_prepare
// PARAMS: prepare name, query // PARAMS: prepare name, query
// RETURN: prepared statement handler // RETURN: prepared statement handler
// DESC : wrapper for pg_prepare // DESC : wrapper for pg_prepare
public function __dbPrepare($name, $query) public function _db_prepare($name, $query)
{ {
$result = pg_prepare($this->dbh, $name, $query); $result = pg_prepare($this->dbh, $name, $query);
if (!$result) { if (!$result) {
@@ -139,12 +124,11 @@ class PgSQL
return $result; return $result;
} }
// METHOD: __dbExecute // METHOD: _db_execute
// WAS : _db_execute
// PARAMS: prepare name, data for query // PARAMS: prepare name, data for query
// RETURN: returns status // RETURN: returns status
// DESC : wrapper for pg_execute for running a prepared statement // DESC : wrapper for pg_execute for running a prepared statement
public function __dbExecute($name, $data) public function _db_execute($name, $data)
{ {
$result = pg_execute($this->dbh, $name, $data); $result = pg_execute($this->dbh, $name, $data);
if (!$result) { if (!$result) {
@@ -153,42 +137,38 @@ class PgSQL
return $result; return $result;
} }
// METHOD: __dbNumRows // METHOD: _db_num_rows
// WAS : _db_num_rows
// PARAMS: cursor // PARAMS: cursor
// RETURN: rows // RETURN: rows
// DESC : wrapper for pg_num_rows // DESC : wrapper for pg_num_rows
public function __dbNumRows($cursor) public function _db_num_rows($cursor)
{ {
return pg_num_rows($cursor); return pg_num_rows($cursor);
} }
// METHOD: __dbNumFields // METHOD: _db_num_fields
// WAS : _db_num_fields
// PARAMS: cursor // PARAMS: cursor
// RETURN: number for fields in query // RETURN: number for fields in query
// DESC : wrapper for pg_num_fields // DESC : wrapper for pg_num_fields
public function __dbNumFields($cursor) public function _db_num_fields($cursor)
{ {
return pg_num_fields($cursor); return pg_num_fields($cursor);
} }
// METHOD: __dbFieldName // METHOD: _db_field_name
// WAS : _db_field_name
// PARAMS: cursor, field position // PARAMS: cursor, field position
// RETURN: name of field // RETURN: name of field
// DESC : wrapper for pg_field_name // DESC : wrapper for pg_field_name
public function __dbFieldName($cursor, $i) public function _db_field_name($cursor, $i)
{ {
return pg_field_name($cursor, $i); return pg_field_name($cursor, $i);
} }
// METHOD: __dbFetchArray // METHOD: _db_fetch_array
// WAS : _db_fetch_array
// PARAMS: cursor, opt result type // PARAMS: cursor, opt result type
// RETURN: row // RETURN: row
// DESC : wrapper for pg_fetch_array // DESC : wrapper for pg_fetch_array
public function __dbFetchArray($cursor, $result_type = '') public function _db_fetch_array($cursor, $result_type = '')
{ {
// result type is passed on as is [should be checked] // result type is passed on as is [should be checked]
if ($result_type) { if ($result_type) {
@@ -198,35 +178,32 @@ class PgSQL
} }
} }
// METHOD: __dbFetchAll // METHOD: _db_fetch_all
// WAS : _db_fetch_all
// PARAMS: cursor // PARAMS: cursor
// RETURN: all rows as array // RETURN: all rows as array
// DESC : wrapper for pg_fetch_array // DESC : wrapper for pg_fetch_array
public function __dbFetchAll($cursor) public function _db_fetch_all($cursor)
{ {
return pg_fetch_all($cursor); return pg_fetch_all($cursor);
} }
// METHOD: __dbAffectedRows // METHOD: _db_affected_ros
// WAS : _db_affected_rows
// PARAMS: cursor // PARAMS: cursor
// RETURN: number for rows // RETURN: number for rows
// DESC : wrapper for pg_affected_rows // DESC : wrapper for pg_affected_rows
public function __dbAffectedRows($cursor) public function _db_affected_rows($cursor)
{ {
return pg_affected_rows($cursor); return pg_affected_rows($cursor);
} }
// METHOD: __dbInsertId // METHOD: _db_insert_id
// WAS : _db_insert_id
// PARAMS: query, primary key name // PARAMS: query, primary key name
// RETURN: last insert primary key // RETURN: last insert primary key
// DESC : reads the last inserted primary key for the query // DESC : reads the last inserted primary key for the query
// if ther is no pk_name tries to auto built it from the table name // if ther is no pk_name tries to auto built it from the table name
// this only works if db schema is after "no plural names. and pk name is table name + _id // this only works if db schema is after "no plural names. and pk name is table name + _id
// detects schema prefix in table name // detects schema prefix in table name
public function __dbInsertId($query, $pk_name) public function _db_insert_id($query, $pk_name)
{ {
// only if an insert has been done // only if an insert has been done
if (preg_match("/^insert /i", $query)) { if (preg_match("/^insert /i", $query)) {
@@ -251,8 +228,8 @@ class PgSQL
$seq = (($schema) ? $schema.'.' : '').$table."_".$pk_name."_seq"; $seq = (($schema) ? $schema.'.' : '').$table."_".$pk_name."_seq";
$q = "SELECT CURRVAL('$seq') AS insert_id"; $q = "SELECT CURRVAL('$seq') AS insert_id";
// I have to do manually or I overwrite the original insert internal vars ... // I have to do manually or I overwrite the original insert internal vars ...
if ($q = $this->__dbQuery($q)) { if ($q = $this->_db_query($q)) {
list($id) = $this->__dbFetchArray($q); list($id) = $this->_db_fetch_array($q);
} else { } else {
$id = array(-1, $q); $id = array(-1, $q);
} }
@@ -260,20 +237,19 @@ class PgSQL
} }
} }
// METHOD: __dbPrimaryKey // METHOD: _db_primary_key
// WAS : _db_primary_key
// PARAMS: table and optional schema // PARAMS: table and optional schema
// RETURN: primary key name OR false if not possible // RETURN: primary key name OR false if not possible
// DESC : queries database for the primary key name to this table in the selected schema // DESC : queries database for the primary key name to this table in the selected schema
public function __dbPrimaryKey($table, $schema = '') public function _db_primary_key($table, $schema = '')
{ {
if ($table) { if ($table) {
// check if schema set is different from schema given, only needed if schema is not empty // check if schema set is different from schema given, only needed if schema is not empty
$table_prefix = ''; $table_prefix = '';
if ($schema) { if ($schema) {
$q = "SHOW search_path"; $q = "SHOW search_path";
$cursor = $this->__dbQuery($q); $cursor = $this->_db_query($q);
$search_path = $this->__dbFetchArray($cursor)['search_path']; $search_path = $this->_db_fetch_array($cursor)['search_path'];
if ($search_path != $schema) { if ($search_path != $schema) {
$table_prefix = $schema.'.'; $table_prefix = $schema.'.';
} }
@@ -296,9 +272,9 @@ class PgSQL
$q .= "pg_attribute.attrelid = pg_class.oid AND "; $q .= "pg_attribute.attrelid = pg_class.oid AND ";
$q .= "pg_attribute.attnum = any(pg_index.indkey) "; $q .= "pg_attribute.attnum = any(pg_index.indkey) ";
$q .= "AND indisprimary"; $q .= "AND indisprimary";
$cursor = $this->__dbQuery($q); $cursor = $this->_db_query($q);
if ($cursor) { if ($cursor) {
return $this->__dbFetchArray($cursor)['column_name']; return $this->_db_fetch_array($cursor)['column_name'];
} else { } else {
return false; return false;
} }
@@ -307,12 +283,11 @@ class PgSQL
} }
} }
// METHOD: __dbConnect // METHOD: _db_connect
// WAS : _db_connect
// PARAMS: host name, user name, password, database name, optional port (defaults to default postgres port), optional ssl (default allow) // PARAMS: host name, user name, password, database name, optional port (defaults to default postgres port), optional ssl (default allow)
// RETURN: database handler // RETURN: database handler
// DESC : wrapper for pg_connect, writes out failure to screen if error occurs (hidden var) // DESC : wrapper for pg_connect, writes out failure to screen if error occurs (hidden var)
public function __dbConnect($db_host, $db_user, $db_pass, $db_name, $db_port = 5432, $db_ssl = 'allow') public function _db_connect($db_host, $db_user, $db_pass, $db_name, $db_port = 5432, $db_ssl = 'allow')
{ {
// to avoid empty db_port // to avoid empty db_port
if (!$db_port) { if (!$db_port) {
@@ -325,12 +300,11 @@ class PgSQL
return $this->dbh; return $this->dbh;
} }
// METHOD: __dbPrintError // METHOD: _db_print_error
// WAS : _db_print_error
// PARAMS: database handler, cursor // PARAMS: database handler, cursor
// RETURN: error string (HTML) // RETURN: error string (HTML)
// DESC : reads the last error for this cursor // DESC : reads the last error for this cursor
public function __dbPrintError($cursor = '') public function _db_print_error($cursor = '')
{ {
// run the query again for the error result here // run the query again for the error result here
if (!$cursor && $this->last_error_query) { if (!$cursor && $this->last_error_query) {
@@ -343,52 +317,47 @@ class PgSQL
} }
} }
// METHOD: __dbMetaData // METHOD: _db_meta_data
// WAS : _db_meta_data
// PARAMS: table name // PARAMS: table name
// RETURN: array with table data // RETURN: array with table data
// DESC : wrapper for pg_emta_data // DESC : wrapper for pg_emta_data
public function __dbMetaData($table) public function _db_meta_data($table)
{ {
return pg_meta_data($this->dbh, $table); return pg_meta_data($this->dbh, $table);
} }
// METHOD: __dbEscapeString // METHOD: _db_escape_string
// WAS : _db_escape_string
// PARAMS: string // PARAMS: string
// RETURN: escaped string for postgres // RETURN: escaped string for postgres
// DESC : wrapper for pg_escape_string // DESC : wrapper for pg_escape_string
public function __dbEscapeString($string) public function _db_escape_string($string)
{ {
return pg_escape_string($this->dbh, $string); return pg_escape_string($this->dbh, $string);
} }
// METHOD: __dbEscapeBytea // METHOD: _db_escape_bytea
// WAS : _db_escape_bytea
// PARAMS: string // PARAMS: string
// RETURN: escape bytes for postgres // RETURN: escape bytes for postgres
// DESC : wrapper for pg_escape_bytea // DESC : wrapper for pg_escape_bytea
public function __dbEscapeBytea($bytea) public function _db_escape_bytea($bytea)
{ {
return pg_escape_bytea($this->dbh, $bytea); return pg_escape_bytea($this->dbh, $bytea);
} }
// METHOD: __dbConnectionBusy // METHOD: _db_connection_busy
// WAS : _db_connection_busy
// PARAMS: none // PARAMS: none
// RETURN: true/false for busy connection // RETURN: true/false for busy connection
// DESC : wrapper for pg_connection_busy // DESC : wrapper for pg_connection_busy
public function __dbConnectionBusy() public function _db_connection_busy()
{ {
return pg_connection_busy($this->dbh); return pg_connection_busy($this->dbh);
} }
// METHOD: __dbVersion // METHOD: _db_version
// WAS : _db_version
// PARAMS: none // PARAMS: none
// RETURN: databse version // RETURN: databse version
// DESC : wrapper for pg_version // DESC : wrapper for pg_version
public function __dbVersion() public function _db_version()
{ {
// array has client, protocol, server // array has client, protocol, server
// we just need the server // we just need the server
@@ -396,14 +365,13 @@ class PgSQL
return $v['server']; return $v['server'];
} }
// METHOD: __dbArrayParse // METHOD: _db_array_parse
// WAS : _db_array_parse
// PARAMS: input text, output array [needed] // PARAMS: input text, output array [needed]
// [internal] limit: are we at the end of the parse // [internal] limit: are we at the end of the parse
// [internal] offset: shift for {} // [internal] offset: shift for {}
// RETURN: array with the elements // RETURN: array with the elements
// DESC : postgresql array to php array // DESC : postgresql array to php array
public function __dbArrayParse($text, &$output, $limit = false, $offset = 1) public function _db_array_parse($text, &$output, $limit = false, $offset = 1)
{ {
if (false === $limit) { if (false === $limit) {
$limit = strlen($text) - 1; $limit = strlen($text) - 1;

View File

@@ -20,8 +20,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
namespace CoreLibs\Language\Core;
/** /**
* Provides a simple gettext replacement that works independently from * Provides a simple gettext replacement that works independently from
* the system's gettext abilities. * the system's gettext abilities.
@@ -34,7 +32,7 @@ namespace CoreLibs\Language\Core;
* second parameter in the constructor (e.g. whenusing very large MO files * second parameter in the constructor (e.g. whenusing very large MO files
* that you don't want to keep in memory) * that you don't want to keep in memory)
*/ */
class GetTextReader class gettext_reader
{ {
// public: // public:
public $error = 0; // public variable that holds error code (0 if no error) public $error = 0; // public variable that holds error code (0 if no error)
@@ -456,5 +454,3 @@ class GetTextReader
} }
} }
} }
# __END__

Some files were not shown because too many files have changed in this diff Show More