Merge edit_order into edit_base, core libs update
edit_order.php is merged into includes/edit_base and changed to symlink In the CoreLibs Output/Form/Generate - switch all " to ' in strings - add not set init config_array parts if loaded with no includes/table_arrays/ file DB/Extended/ArrayIO - switch all " to ' in strings ACL/Login - swich all missing " strings to ' - not TEMPLATE part is deprecated (but leave load in)
This commit is contained in:
@@ -1,207 +0,0 @@
|
||||
<?php
|
||||
/********************************************************************
|
||||
* AUTHOR: Clemens Schwaighofer
|
||||
* CREATED: 2001/07/11
|
||||
* SHORT DESCRIPTION:
|
||||
* sets the order from a table (edit_)
|
||||
* HISTORY:
|
||||
* 2005/07/11 (cs) adept to new edit interface
|
||||
* 2002-10-18: little include changes
|
||||
* 2001-07-11: erste Version
|
||||
**********************************************************************/
|
||||
|
||||
$DEBUG_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
|
||||
extract($_GET, EXTR_SKIP);
|
||||
extract($_POST, EXTR_SKIP);
|
||||
|
||||
require 'config.php';
|
||||
// set session name
|
||||
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
|
||||
// overrride debug flags
|
||||
if (!DEBUG) {
|
||||
$DEBUG_ALL = 0;
|
||||
$PRINT_ALL = 0;
|
||||
$DB_DEBUG = 0;
|
||||
$ECHO_ALL = 0;
|
||||
}
|
||||
|
||||
// default lang
|
||||
if (!$lang) {
|
||||
$lang = DEFAULT_LANG;
|
||||
}
|
||||
|
||||
$table_width = 600;
|
||||
if (!$table_width) {
|
||||
$table_width = PAGE_WIDTH;
|
||||
}
|
||||
|
||||
ob_end_flush();
|
||||
$login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
|
||||
$db = new CoreLibs\DB\IO($DB_CONFIG[MAIN_DB]);
|
||||
$db->dbExec("SET search_path TO ".LOGIN_DB_SCHEMA);
|
||||
$smarty = new CoreLibs\Template\SmartyExtend($lang);
|
||||
if (TARGET == 'live' || TARGET == 'remote') {
|
||||
// login
|
||||
$login->debug_output_all = DEBUG ? 1 : 0;
|
||||
$login->echo_output_all = 0;
|
||||
$login->print_output_all = DEBUG ? 1 : 0;
|
||||
// form
|
||||
$db->debug_output_all = DEBUG ? 1 : 0;
|
||||
$db->echo_output_all = 0;
|
||||
$db->print_output_all = DEBUG ? 1 : 0;
|
||||
}
|
||||
// set the template dir
|
||||
if (defined('LAYOUT')) {
|
||||
$smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES);
|
||||
$DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS;
|
||||
$DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS;
|
||||
} else {
|
||||
$smarty->setTemplateDir(TEMPLATES.DEFAULT_TEMPLATE);
|
||||
$DATA['css'] = CSS.DEFAULT_TEMPLATE;
|
||||
$DATA['js'] = JS.DEFAULT_TEMPLATE;
|
||||
}
|
||||
|
||||
// order name is _always_ order_number for the edit interface
|
||||
|
||||
// follwing arrays do exist here:
|
||||
// $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)
|
||||
// $row_data_id ... has ALL ids from the sorting part
|
||||
// $row_data_order ... has ALL order positions from the soirting part
|
||||
if (!is_array($position)) {
|
||||
$position = array ();
|
||||
}
|
||||
if (count($position)) {
|
||||
$original_id = $row_data_id;
|
||||
|
||||
// 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) {
|
||||
for ($i = 0; $i < count($position); $i++) {
|
||||
// change position order
|
||||
// this gets temp, id before that, gets actual (moves one "down")
|
||||
// this gets the old before (moves one "up")
|
||||
// is done for every element in row
|
||||
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||
$temp_id = $row_data_id[$position[$i]];
|
||||
$row_data_id[$position[$i]] = $row_data_id[$position[$i]-1];
|
||||
$row_data_id[$position[$i]-1] = $temp_id;
|
||||
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||
} // for
|
||||
} // 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))) {
|
||||
for ($i = count($position) - 1; $i >= 0; $i --) {
|
||||
// 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 after this, gets this
|
||||
$temp_id = $row_data_id[$position[$i] + 1];
|
||||
$row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]];
|
||||
$row_data_id[$position[$i]] = $temp_id;
|
||||
} // for
|
||||
} // if down
|
||||
|
||||
// write data ... (which has to be abstrackt ...)
|
||||
if (($up && $position[0] > 0) || ($down && ($position[count($position) - 1]!=(count($row_data_id) - 1)))) {
|
||||
for ($i = 0; $i < count($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);
|
||||
} // for all article ids ...
|
||||
} // if write
|
||||
} // if there is something to move
|
||||
|
||||
// get ...
|
||||
$q = "SELECT ".$table_name."_id, name, order_number FROM ".$table_name." ";
|
||||
if ($where_string) {
|
||||
$q .= "WHERE $where_string ";
|
||||
}
|
||||
$q .= "ORDER BY order_number";
|
||||
|
||||
while ($res = $db->dbReturn($q)) {
|
||||
$row_data[] = array (
|
||||
"id" => $res[$table_name."_id"],
|
||||
"name" => $res["name"],
|
||||
"order" => $res["order_number"]
|
||||
);
|
||||
} // while read data ...
|
||||
|
||||
// define all needed smarty stuff for the general HTML/page building
|
||||
$DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS;
|
||||
$DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS;
|
||||
$HEADER['CSS'] = CSS;
|
||||
$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||
$HEADER['JS'] = JS;
|
||||
$HEADER['STYLESHEET'] = $EDIT_STYLESHEET;
|
||||
$HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
|
||||
// html title
|
||||
$HEADER['HTML_TITLE'] = (!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE);
|
||||
|
||||
$DATA['table_width'] = $table_width;
|
||||
|
||||
// error msg
|
||||
if ($error) {
|
||||
$messages[] = array('msg' => $msg, 'class' => 'error', 'width' => $table_width);
|
||||
}
|
||||
$DATA['form_error_msg'] = $messages;
|
||||
|
||||
// all the row data
|
||||
$options_id = array ();
|
||||
$options_name = array ();
|
||||
$options_selected = array ();
|
||||
if (!is_array($row_data)) {
|
||||
$row_data = array ();
|
||||
}
|
||||
for ($i = 0; $i < count($row_data); $i ++) {
|
||||
$options_id[] = $i;
|
||||
$options_name[] = $row_data[$i]["name"];
|
||||
// list of points to order
|
||||
for ($j = 0; $j < count($position); $j++) {
|
||||
// if matches, put into select array
|
||||
if ($original_id[$position[$j]] == $row_data[$i]["id"]) {
|
||||
$options_selected[] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
$DATA['options_id'] = $options_id;
|
||||
$DATA['options_name'] = $options_name;
|
||||
$DATA['options_selected'] = $options_selected;
|
||||
|
||||
// hidden list for the data (id, order number)
|
||||
$row_data_id = array ();
|
||||
$row_data_order = array ();
|
||||
for ($i = 0; $i < count($row_data); $i++) {
|
||||
$row_data_id[] = $row_data[$i]["id"];
|
||||
$row_data_order[] = $row_data[$i]["order"];
|
||||
}
|
||||
$DATA['row_data_id'] = $row_data_id;
|
||||
$DATA['row_data_order'] = $row_data_order;
|
||||
|
||||
// hidden names for the table & where string
|
||||
$DATA['table_name'] = $table_name;
|
||||
$DATA['where_string'] = $where_string;
|
||||
|
||||
// debug data, if DEBUG flag is on, this data is print out
|
||||
$DEBUG_DATA['DEBUG'] = $DEBUG_TMPL;
|
||||
|
||||
// create main data array
|
||||
$CONTENT_DATA = array_merge($HEADER, $DATA, $DEBUG_DATA);
|
||||
// data is 1:1 mapping (all vars, values, etc)
|
||||
foreach ($CONTENT_DATA as $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('edit_order.tpl');
|
||||
|
||||
echo $login->printErrorMsg();
|
||||
echo $db->printErrorMsg();
|
||||
|
||||
// __END__
|
||||
1
www/admin/edit_order.php
Symbolic link
1
www/admin/edit_order.php
Symbolic link
@@ -0,0 +1 @@
|
||||
../includes/edit_base.inc
|
||||
@@ -7,7 +7,6 @@
|
||||
* HISTORY:
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
// master template
|
||||
if (!isset($MASTER_TEMPLATE_NAME)) {
|
||||
$MASTER_TEMPLATE_NAME = MASTER_TEMPLATE_NAME;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
$DEBUG_ALL = 1;
|
||||
$DB_DEBUG = 1;
|
||||
|
||||
// TODO: only extract _POST data that is needed
|
||||
extract($_POST, EXTR_SKIP);
|
||||
|
||||
$table_width = '100%';
|
||||
@@ -49,7 +50,6 @@ $login = new CoreLibs\ACL\Login($DB_CONFIG[LOGIN_DB], $lang);
|
||||
|
||||
// create form class
|
||||
$form = new CoreLibs\Output\Form\Generate($DB_CONFIG[MAIN_DB], $lang);
|
||||
$form->dbExec("SET search_path TO ".LOGIN_DB_SCHEMA);
|
||||
if ($form->mobile_phone) {
|
||||
echo "I am sorry, but this page cannot be viewed by a mobile phone";
|
||||
exit;
|
||||
@@ -70,13 +70,13 @@ if (TARGET == 'live' || TARGET == 'remote') {
|
||||
// set the template dir
|
||||
// WARNING: this has a special check for the mailing tool layout (old layout)
|
||||
if (defined('LAYOUT')) {
|
||||
$smarty->setTemplateDir(LAYOUT.DEFAULT_TEMPLATE.TEMPLATES);
|
||||
$DATA['css'] = LAYOUT.DEFAULT_TEMPLATE.CSS;
|
||||
$DATA['js'] = LAYOUT.DEFAULT_TEMPLATE.JS;
|
||||
$smarty->setTemplateDir(BASE.INCLUDES.TEMPLATES.CONTENT_PATH);
|
||||
$DATA['css'] = LAYOUT.CSS;
|
||||
$DATA['js'] = LAYOUT.JS;
|
||||
} else {
|
||||
$smarty->setTemplateDir(TEMPLATES.DEFAULT_TEMPLATE);
|
||||
$DATA['css'] = CSS.DEFAULT_TEMPLATE;
|
||||
$DATA['js'] = JS.DEFAULT_TEMPLATE;
|
||||
$smarty->setTemplateDir(TEMPLATES);
|
||||
$DATA['css'] = CSS;
|
||||
$DATA['js'] = JS;
|
||||
}
|
||||
|
||||
// space for setting special debug flags
|
||||
@@ -105,203 +105,328 @@ $data = array (
|
||||
// log action
|
||||
EditLog('Edit Submit', serialize($data));
|
||||
|
||||
$form->formProcedureLoad(${$form->archive_pk_name});
|
||||
$form->formProcedureNew();
|
||||
$form->formProcedureSave();
|
||||
$form->formProcedureDelete();
|
||||
$form->formProcedureDeleteFromElementList($element_list, $remove_name);
|
||||
if ($form->my_page_name == 'edit_order') {
|
||||
// get is for "table_name" and "where" only
|
||||
$table_name = isset($_GET['table_name']) ? $_GET['table_name'] : '';
|
||||
// $where = isset($_GET['where']) ? $_GET['where'] : '';
|
||||
// order name is _always_ order_number for the edit interface
|
||||
|
||||
// define all needed smarty stuff for the general HTML/page building
|
||||
$HEADER['CSS'] = CSS;
|
||||
$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||
$HEADER['JS'] = JS;
|
||||
$HEADER['STYLESHEET'] = $EDIT_STYLESHEET;
|
||||
$HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
|
||||
// follwing arrays do exist here:
|
||||
// $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)
|
||||
// $row_data_id ... has ALL ids from the sorting part
|
||||
// $row_data_order ... has ALL order positions from the soirting part
|
||||
if (!is_array($position)) {
|
||||
$position = array ();
|
||||
}
|
||||
if (count($position)) {
|
||||
$original_id = $row_data_id;
|
||||
|
||||
$DATA['table_width'] = $table_width;
|
||||
// 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) {
|
||||
for ($i = 0; $i < count($position); $i++) {
|
||||
// change position order
|
||||
// this gets temp, id before that, gets actual (moves one "down")
|
||||
// this gets the old before (moves one "up")
|
||||
// is done for every element in row
|
||||
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||
$temp_id = $row_data_id[$position[$i]];
|
||||
$row_data_id[$position[$i]] = $row_data_id[$position[$i]-1];
|
||||
$row_data_id[$position[$i]-1] = $temp_id;
|
||||
// echo "A: ".$row_data_id[$position[$i]]." (".$row_data_order[$position[$i]].") -- ".$row_data_id[$position[$i]-1]." (".$row_data_order[$position[$i]-1].")<br>";
|
||||
} // for
|
||||
} // if up
|
||||
|
||||
// write out error / status messages
|
||||
$messages[] = $form->formPrintMsg();
|
||||
$DATA['form_error_msg'] = $messages;
|
||||
// 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 --) {
|
||||
// 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 after this, gets this
|
||||
$temp_id = $row_data_id[$position[$i] + 1];
|
||||
$row_data_id[$position[$i] + 1] = $row_data_id[$position[$i]];
|
||||
$row_data_id[$position[$i]] = $temp_id;
|
||||
} // for
|
||||
} // if down
|
||||
|
||||
// MENU START
|
||||
// request some session vars
|
||||
if (!$HEADER_COLOR) {
|
||||
$DATA['HEADER_COLOR'] = "#E0E2FF";
|
||||
// write data ... (which has to be abstrackt ...)
|
||||
if (($up && $position[0] > 0) || ($down && ($position[count($position) - 1]!=(count($row_data_id) - 1)))) {
|
||||
for ($i = 0; $i < count($row_data_id); $i ++) {
|
||||
$q = "UPDATE ".$table_name." SET order_number = ".$row_data_order[$i]." WHERE ".$table_name."_id = ".$row_data_id[$i];
|
||||
$q = $form->dbExec($q);
|
||||
} // for all article ids ...
|
||||
} // if write
|
||||
} // if there is something to move
|
||||
|
||||
// get ...
|
||||
$q = "SELECT ".$table_name."_id, name, order_number FROM ".$table_name." ";
|
||||
if ($where_string) {
|
||||
$q .= "WHERE $where_string ";
|
||||
}
|
||||
$q .= "ORDER BY order_number";
|
||||
|
||||
while ($res = $form->dbReturn($q)) {
|
||||
$row_data[] = array (
|
||||
"id" => $res[$table_name."_id"],
|
||||
"name" => $res["name"],
|
||||
"order" => $res["order_number"]
|
||||
);
|
||||
} // while read data ...
|
||||
|
||||
// define all needed smarty stuff for the general HTML/page building
|
||||
$HEADER['CSS'] = CSS;
|
||||
$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||
$HEADER['JS'] = JS;
|
||||
$HEADER['STYLESHEET'] = $EDIT_STYLESHEET;
|
||||
$HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
|
||||
// html title
|
||||
$HEADER['HTML_TITLE'] = (!$L_TITLE) ? $smarty->l10n->__($G_TITLE) : $smarty->l10n->__($L_TITLE);
|
||||
|
||||
// error msg
|
||||
if ($error) {
|
||||
$messages[] = array('msg' => $msg, 'class' => 'error', 'width' => '100%');
|
||||
}
|
||||
$DATA['form_error_msg'] = $messages;
|
||||
|
||||
// all the row data
|
||||
$options_id = array ();
|
||||
$options_name = array ();
|
||||
$options_selected = array ();
|
||||
if (!is_array($row_data)) {
|
||||
$row_data = array ();
|
||||
}
|
||||
for ($i = 0; $i < count($row_data); $i ++) {
|
||||
$options_id[] = $i;
|
||||
$options_name[] = $row_data[$i]["name"];
|
||||
// list of points to order
|
||||
for ($j = 0; $j < count($position); $j++) {
|
||||
// if matches, put into select array
|
||||
if ($original_id[$position[$j]] == $row_data[$i]["id"]) {
|
||||
$options_selected[] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
$DATA['options_id'] = $options_id;
|
||||
$DATA['options_name'] = $options_name;
|
||||
$DATA['options_selected'] = $options_selected;
|
||||
|
||||
// hidden list for the data (id, order number)
|
||||
$row_data_id = array ();
|
||||
$row_data_order = array ();
|
||||
for ($i = 0; $i < count($row_data); $i++) {
|
||||
$row_data_id[] = $row_data[$i]["id"];
|
||||
$row_data_order[] = $row_data[$i]["order"];
|
||||
}
|
||||
$DATA['row_data_id'] = $row_data_id;
|
||||
$DATA['row_data_order'] = $row_data_order;
|
||||
|
||||
// hidden names for the table & where string
|
||||
$DATA['table_name'] = $table_name;
|
||||
$DATA['where_string'] = $where_string;
|
||||
|
||||
$EDIT_TEMPLATE = 'edit_order.tpl';
|
||||
} else {
|
||||
$DATA['HEADER_COLOR'] = $_SESSION['HEADER_COLOR'];
|
||||
}
|
||||
$DATA['USER_NAME'] = $_SESSION["USER_NAME"];
|
||||
$DATA['EUID'] = $_SESSION["EUID"];
|
||||
$DATA['GROUP_NAME'] = $_SESSION["GROUP_NAME"];
|
||||
$DATA['GROUP_LEVEL'] = $_SESSION["GROUP_LEVEL"];
|
||||
$PAGES = $_SESSION["PAGES"];
|
||||
$form->formProcedureLoad(${$form->archive_pk_name});
|
||||
$form->formProcedureNew();
|
||||
$form->formProcedureSave();
|
||||
$form->formProcedureDelete();
|
||||
$form->formProcedureDeleteFromElementList($element_list, $remove_name);
|
||||
|
||||
//$form->debug('menu', $form->printAr($PAGES));
|
||||
// define all needed smarty stuff for the general HTML/page building
|
||||
$HEADER['CSS'] = CSS;
|
||||
$HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING;
|
||||
$HEADER['JS'] = JS;
|
||||
$HEADER['STYLESHEET'] = $EDIT_STYLESHEET;
|
||||
$HEADER['JAVASCRIPT'] = $EDIT_JAVASCRIPT;
|
||||
|
||||
// build nav from $PAGES ...
|
||||
if (!is_array($PAGES)) {
|
||||
$PAGES = array ();
|
||||
}
|
||||
for ($i = 0, $i_max = count($PAGES); $i < $i_max; $i ++) {
|
||||
if ($PAGES[$i]["menu"] && $PAGES[$i]["online"]) {
|
||||
$menuarray[] = $PAGES[$i];
|
||||
}
|
||||
}
|
||||
$DATA['table_width'] = $table_width;
|
||||
|
||||
// split point for nav points
|
||||
$COUNT_NAV_POINTS = count($menuarray);
|
||||
$SPLIT_FACTOR = 3;
|
||||
$START_SPLIT_COUNT = 3;
|
||||
// WTF ?? I dunno what I am doing here ...
|
||||
for ($i = 9; $i < $COUNT_NAV_POINTS; $i += $START_SPLIT_COUNT) {
|
||||
if ($COUNT_NAV_POINTS > $i) {
|
||||
$SPLIT_FACTOR += 1;
|
||||
}
|
||||
}
|
||||
// write out error / status messages
|
||||
$messages[] = $form->formPrintMsg();
|
||||
$DATA['form_error_msg'] = $messages;
|
||||
|
||||
for ($i = 1; $i <= count($menuarray); $i ++) {
|
||||
// do that for new array
|
||||
$j = $i - 1;
|
||||
$menu_data[$j]['pagename'] = htmlentities($menuarray[($i-1)]["page_name"]);
|
||||
$menu_data[$j]['filename'] = $menuarray[($i-1)]["filename"].$menuarray[($i-1)]["query_string"];
|
||||
if ($i == 1 || !(($i - 1) % $SPLIT_FACTOR)) {
|
||||
$menu_data[$j]['splitfactor_in'] = 1;
|
||||
}
|
||||
if ($menuarray[($i - 1)]["filename"] == $form->getPageName()) {
|
||||
$position = $i - 1;
|
||||
$menu_data[$j]['position'] = 1;
|
||||
// MENU START
|
||||
// request some session vars
|
||||
if (!$HEADER_COLOR) {
|
||||
$DATA['HEADER_COLOR'] = "#E0E2FF";
|
||||
} else {
|
||||
// add query stuff
|
||||
// HAS TO DONE LATER ... set urlencode, etc ...
|
||||
// check if popup needed
|
||||
if ($menuarray[($i - 1)]["popup"]) {
|
||||
$menu_data[$j]['popup'] = 1;
|
||||
$menu_data[$j]['rand'] = uniqid(rand());
|
||||
$menu_data[$j]['width'] = $menuarray[($i-1)]["popup_x"];
|
||||
$menu_data[$j]['height'] = $menuarray[($i-1)]["popup_y"];
|
||||
} // popup or not
|
||||
} // highlight or not
|
||||
if (!($i % $SPLIT_FACTOR) || (($i + 1) > count($menuarray))) {
|
||||
$menu_data[$j]['splitfactor_out'] = 1;
|
||||
} // split
|
||||
} // for
|
||||
$DATA['menu_data'] = $menu_data;
|
||||
$DATA['page_name'] = $menuarray[$position]["page_name"];
|
||||
$L_TITLE = $DATA['page_name'];
|
||||
// html title
|
||||
$HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE));
|
||||
// END MENU
|
||||
// LOAD AND NEW
|
||||
$DATA['load'] = $form->formCreateLoad();
|
||||
$DATA['new'] = $form->formCreateNew();
|
||||
// SHOW DATA PART
|
||||
if ($form->yes) {
|
||||
$DATA['form_yes'] = $form->yes;
|
||||
$DATA['form_my_page_name'] = $form->my_page_name;
|
||||
|
||||
// depending on the "getPageName()" I show different stuff
|
||||
switch ($form->my_page_name) {
|
||||
case "edit_users":
|
||||
$elements[] = $form->formCreateElement("login_error_count");
|
||||
$elements[] = $form->formCreateElement("login_error_date_last");
|
||||
$elements[] = $form->formCreateElement("login_error_date_first");
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("protected");
|
||||
$elements[] = $form->formCreateElement("username");
|
||||
$elements[] = $form->formCreateElement("password");
|
||||
$elements[] = $form->formCreateElement("password_change_interval");
|
||||
$elements[] = $form->formCreateElement("email");
|
||||
$elements[] = $form->formCreateElement("last_name");
|
||||
$elements[] = $form->formCreateElement("first_name");
|
||||
$elements[] = $form->formCreateElement("edit_group_id");
|
||||
$elements[] = $form->formCreateElement("edit_access_right_id");
|
||||
$elements[] = $form->formCreateElement("strict");
|
||||
$elements[] = $form->formCreateElement("locked");
|
||||
$elements[] = $form->formCreateElement("admin");
|
||||
$elements[] = $form->formCreateElement("debug");
|
||||
$elements[] = $form->formCreateElement("db_debug");
|
||||
$elements[] = $form->formCreateElement("edit_language_id");
|
||||
$elements[] = $form->formCreateElement("edit_scheme_id");
|
||||
$elements[] = $form->formCreateElementListTable("edit_access_user");
|
||||
break;
|
||||
case "edit_schemes":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("header_color");
|
||||
$elements[] = $form->formCreateElement("template");
|
||||
break;
|
||||
case "edit_pages":
|
||||
if (!$form->table_array["edit_page_id"]["value"]) {
|
||||
$q = "DELETE FROM temp_files";
|
||||
$form->dbExec($q);
|
||||
// gets all files in the current dir ending with .php
|
||||
$crap = exec("ls *.php", $output, $status);
|
||||
// now get all that are NOT in de DB
|
||||
$q = "INSERT INTO temp_files VALUES ";
|
||||
for ($i = 0; $i < count($output); $i ++) {
|
||||
$t_q = "('".$form->dbEscapeString($output[$i])."')";
|
||||
$form->dbExec($q.$t_q, 'NULL');
|
||||
}
|
||||
$elements[] = $form->formCreateElement("filename");
|
||||
} else {
|
||||
// show file menu
|
||||
// just show name of file ...
|
||||
$DATA['filename_exist'] = 1;
|
||||
$DATA['filename'] = $form->table_array["filename"]["value"];
|
||||
} // File Name View IF
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
// $elements[] = $form->formCreateElement("tag");
|
||||
// $elements[] = $form->formCreateElement("min_acl");
|
||||
$elements[] = $form->formCreateElement("order_number");
|
||||
$elements[] = $form->formCreateElement("online");
|
||||
$elements[] = $form->formCreateElement("menu");
|
||||
$elements[] = $form->formCreateElementListTable("edit_query_string");
|
||||
$elements[] = $form->formCreateElement("popup");
|
||||
$elements[] = $form->formCreateElement("popup_x");
|
||||
$elements[] = $form->formCreateElement("popup_y");
|
||||
$elements[] = $form->formCreateElementReferenceTable("edit_visible_group");
|
||||
$elements[] = $form->formCreateElementReferenceTable("edit_menu_group");
|
||||
break;
|
||||
case "edit_languages":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("short_name");
|
||||
$elements[] = $form->formCreateElement("long_name");
|
||||
$elements[] = $form->formCreateElement("iso_name");
|
||||
break;
|
||||
case "edit_groups":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("edit_access_right_id");
|
||||
$elements[] = $form->formCreateElement("edit_scheme_id");
|
||||
$elements[] = $form->formCreateElementListTable("edit_page_access");
|
||||
break;
|
||||
case "edit_visible_group":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("flag");
|
||||
break;
|
||||
case "edit_menu_group":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("flag");
|
||||
$elements[] = $form->formCreateElement("order_number");
|
||||
break;
|
||||
case "edit_access":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("protected");
|
||||
$elements[] = $form->formCreateElement("color");
|
||||
$elements[] = $form->formCreateElement("description");
|
||||
// add name/value list here
|
||||
$elements[] = $form->formCreateElementListTable("edit_access_data");
|
||||
break;
|
||||
default:
|
||||
print "[No valid page definition given]";
|
||||
break;
|
||||
$DATA['HEADER_COLOR'] = $_SESSION['HEADER_COLOR'];
|
||||
}
|
||||
// $form->debug('edit', "Elements: <pre>".$form->printAr($elements));
|
||||
$DATA['elements'] = $elements;
|
||||
$DATA['hidden'] = $form->formCreateHiddenFields();
|
||||
$DATA['save_delete'] = $form->formCreateSaveDelete();
|
||||
$DATA['USER_NAME'] = $_SESSION["USER_NAME"];
|
||||
$DATA['EUID'] = $_SESSION["EUID"];
|
||||
$DATA['GROUP_NAME'] = $_SESSION["GROUP_NAME"];
|
||||
$DATA['GROUP_LEVEL'] = $_SESSION["GROUP_LEVEL"];
|
||||
$PAGES = $_SESSION["PAGES"];
|
||||
|
||||
//$form->debug('menu', $form->printAr($PAGES));
|
||||
|
||||
// build nav from $PAGES ...
|
||||
if (!is_array($PAGES)) {
|
||||
$PAGES = array ();
|
||||
}
|
||||
for ($i = 0, $i_max = count($PAGES); $i < $i_max; $i ++) {
|
||||
if ($PAGES[$i]["menu"] && $PAGES[$i]["online"]) {
|
||||
$menuarray[] = $PAGES[$i];
|
||||
}
|
||||
}
|
||||
|
||||
// split point for nav points
|
||||
$COUNT_NAV_POINTS = count($menuarray);
|
||||
$SPLIT_FACTOR = 3;
|
||||
$START_SPLIT_COUNT = 3;
|
||||
// WTF ?? I dunno what I am doing here ...
|
||||
for ($i = 9; $i < $COUNT_NAV_POINTS; $i += $START_SPLIT_COUNT) {
|
||||
if ($COUNT_NAV_POINTS > $i) {
|
||||
$SPLIT_FACTOR += 1;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= count($menuarray); $i ++) {
|
||||
// do that for new array
|
||||
$j = $i - 1;
|
||||
$menu_data[$j]['pagename'] = htmlentities($menuarray[($i-1)]["page_name"]);
|
||||
$menu_data[$j]['filename'] = $menuarray[($i-1)]["filename"].$menuarray[($i-1)]["query_string"];
|
||||
if ($i == 1 || !(($i - 1) % $SPLIT_FACTOR)) {
|
||||
$menu_data[$j]['splitfactor_in'] = 1;
|
||||
}
|
||||
if ($menuarray[($i - 1)]["filename"] == $form->getPageName()) {
|
||||
$position = $i - 1;
|
||||
$menu_data[$j]['position'] = 1;
|
||||
} else {
|
||||
// add query stuff
|
||||
// HAS TO DONE LATER ... set urlencode, etc ...
|
||||
// check if popup needed
|
||||
if ($menuarray[($i - 1)]["popup"]) {
|
||||
$menu_data[$j]['popup'] = 1;
|
||||
$menu_data[$j]['rand'] = uniqid(rand());
|
||||
$menu_data[$j]['width'] = $menuarray[($i-1)]["popup_x"];
|
||||
$menu_data[$j]['height'] = $menuarray[($i-1)]["popup_y"];
|
||||
} // popup or not
|
||||
} // highlight or not
|
||||
if (!($i % $SPLIT_FACTOR) || (($i + 1) > count($menuarray))) {
|
||||
$menu_data[$j]['splitfactor_out'] = 1;
|
||||
} // split
|
||||
} // for
|
||||
$DATA['menu_data'] = $menu_data;
|
||||
$DATA['page_name'] = $menuarray[$position]["page_name"];
|
||||
$L_TITLE = $DATA['page_name'];
|
||||
// html title
|
||||
$HEADER['HTML_TITLE'] = ((!$L_TITLE) ? $form->l->__($G_TITLE) : $form->l->__($L_TITLE));
|
||||
// END MENU
|
||||
// LOAD AND NEW
|
||||
$DATA['load'] = $form->formCreateLoad();
|
||||
$DATA['new'] = $form->formCreateNew();
|
||||
// SHOW DATA PART
|
||||
if ($form->yes) {
|
||||
$DATA['form_yes'] = $form->yes;
|
||||
$DATA['form_my_page_name'] = $form->my_page_name;
|
||||
|
||||
// depending on the "getPageName()" I show different stuff
|
||||
switch ($form->my_page_name) {
|
||||
case "edit_users":
|
||||
$elements[] = $form->formCreateElement("login_error_count");
|
||||
$elements[] = $form->formCreateElement("login_error_date_last");
|
||||
$elements[] = $form->formCreateElement("login_error_date_first");
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("protected");
|
||||
$elements[] = $form->formCreateElement("username");
|
||||
$elements[] = $form->formCreateElement("password");
|
||||
$elements[] = $form->formCreateElement("password_change_interval");
|
||||
$elements[] = $form->formCreateElement("email");
|
||||
$elements[] = $form->formCreateElement("last_name");
|
||||
$elements[] = $form->formCreateElement("first_name");
|
||||
$elements[] = $form->formCreateElement("edit_group_id");
|
||||
$elements[] = $form->formCreateElement("edit_access_right_id");
|
||||
$elements[] = $form->formCreateElement("strict");
|
||||
$elements[] = $form->formCreateElement("locked");
|
||||
$elements[] = $form->formCreateElement("admin");
|
||||
$elements[] = $form->formCreateElement("debug");
|
||||
$elements[] = $form->formCreateElement("db_debug");
|
||||
$elements[] = $form->formCreateElement("edit_language_id");
|
||||
$elements[] = $form->formCreateElement("edit_scheme_id");
|
||||
$elements[] = $form->formCreateElementListTable("edit_access_user");
|
||||
break;
|
||||
case "edit_schemes":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("header_color");
|
||||
$elements[] = $form->formCreateElement("template");
|
||||
break;
|
||||
case "edit_pages":
|
||||
if (!$form->table_array["edit_page_id"]["value"]) {
|
||||
$q = "DELETE FROM temp_files";
|
||||
$form->dbExec($q);
|
||||
// gets all files in the current dir ending with .php
|
||||
$crap = exec("ls *.php", $output, $status);
|
||||
// now get all that are NOT in de DB
|
||||
$q = "INSERT INTO temp_files VALUES ";
|
||||
for ($i = 0; $i < count($output); $i ++) {
|
||||
$t_q = "('".$form->dbEscapeString($output[$i])."')";
|
||||
$form->dbExec($q.$t_q, 'NULL');
|
||||
}
|
||||
$elements[] = $form->formCreateElement("filename");
|
||||
} else {
|
||||
// show file menu
|
||||
// just show name of file ...
|
||||
$DATA['filename_exist'] = 1;
|
||||
$DATA['filename'] = $form->table_array["filename"]["value"];
|
||||
} // File Name View IF
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
// $elements[] = $form->formCreateElement("tag");
|
||||
// $elements[] = $form->formCreateElement("min_acl");
|
||||
$elements[] = $form->formCreateElement("order_number");
|
||||
$elements[] = $form->formCreateElement("online");
|
||||
$elements[] = $form->formCreateElement("menu");
|
||||
$elements[] = $form->formCreateElementListTable("edit_query_string");
|
||||
$elements[] = $form->formCreateElement("popup");
|
||||
$elements[] = $form->formCreateElement("popup_x");
|
||||
$elements[] = $form->formCreateElement("popup_y");
|
||||
$elements[] = $form->formCreateElementReferenceTable("edit_visible_group");
|
||||
$elements[] = $form->formCreateElementReferenceTable("edit_menu_group");
|
||||
break;
|
||||
case "edit_languages":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("short_name");
|
||||
$elements[] = $form->formCreateElement("long_name");
|
||||
$elements[] = $form->formCreateElement("iso_name");
|
||||
break;
|
||||
case "edit_groups":
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("edit_access_right_id");
|
||||
$elements[] = $form->formCreateElement("edit_scheme_id");
|
||||
$elements[] = $form->formCreateElementListTable("edit_page_access");
|
||||
break;
|
||||
case "edit_visible_group":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("flag");
|
||||
break;
|
||||
case "edit_menu_group":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("flag");
|
||||
$elements[] = $form->formCreateElement("order_number");
|
||||
break;
|
||||
case "edit_access":
|
||||
$elements[] = $form->formCreateElement("name");
|
||||
$elements[] = $form->formCreateElement("enabled");
|
||||
$elements[] = $form->formCreateElement("protected");
|
||||
$elements[] = $form->formCreateElement("color");
|
||||
$elements[] = $form->formCreateElement("description");
|
||||
// add name/value list here
|
||||
$elements[] = $form->formCreateElementListTable("edit_access_data");
|
||||
break;
|
||||
default:
|
||||
print "[No valid page definition given]";
|
||||
break;
|
||||
}
|
||||
// $form->debug('edit', "Elements: <pre>".$form->printAr($elements));
|
||||
$DATA['elements'] = $elements;
|
||||
$DATA['hidden'] = $form->formCreateHiddenFields();
|
||||
$DATA['save_delete'] = $form->formCreateSaveDelete();
|
||||
}
|
||||
$EDIT_TEMPLATE = 'edit_body.tpl';
|
||||
}
|
||||
|
||||
// debug data, if DEBUG flag is on, this data is print out
|
||||
@@ -319,7 +444,7 @@ if (is_dir(BASE.TEMPLATES_C)) {
|
||||
if (is_dir(BASE.CACHE)) {
|
||||
$smarty->setCacheDir(BASE.CACHE);
|
||||
}
|
||||
$smarty->display('edit_body.tpl');
|
||||
$smarty->display($EDIT_TEMPLATE, $lang, $lang);
|
||||
|
||||
// debug output
|
||||
echo $login->printErrorMsg();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
{/if}
|
||||
</head>
|
||||
<body>
|
||||
<table width="{$table_width}" border="0" cellpadding="0" cellspacing="1">
|
||||
<table width="100%" border="0" cellpadding="0" cellspacing="1">
|
||||
<!-- ERROR MSG START //-->
|
||||
{foreach from=$form_error_msg item=element key=key name=loop}
|
||||
{include file="edit_error_msg.tpl"}
|
||||
|
||||
@@ -114,25 +114,25 @@ class Login extends \CoreLibs\DB\IO
|
||||
|
||||
// create db connection and init base class
|
||||
if (!parent::__construct($db_config, $debug, $db_debug, $echo, $print)) {
|
||||
echo "Could not connect to DB<br>";
|
||||
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
|
||||
if (!session_id()) {
|
||||
echo "<b>Session not started!</b><br>Use 'session_start();'.<br>";
|
||||
echo "For less problems with other session, you can set a session name with 'session_name(\"name\");'.<br>";
|
||||
echo '<b>Session not started!</b><br>Use \'session_start();\'.<br>';
|
||||
echo 'For less problems with other session, you can set a session name with \'session_name("name");\'.<br>';
|
||||
exit;
|
||||
}
|
||||
|
||||
// pre-check that password min/max lengths are inbetween 1 and 255;
|
||||
if ($this->password_max_length > 255) {
|
||||
echo "<b>Settings problem</b> PMaL<br>";
|
||||
echo '<b>Settings problem</b> PMaL<br>';
|
||||
exit;
|
||||
}
|
||||
if ($this->password_min_length < 1) {
|
||||
echo "<b>Settings problem</b> PMiL<br>";
|
||||
echo '<b>Settings problem</b> PMiL<br>';
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -212,11 +212,11 @@ class Login extends \CoreLibs\DB\IO
|
||||
$this->lock_deny_users = array ('admin');
|
||||
|
||||
// internal
|
||||
$this->class_info["login"] = array(
|
||||
"class_name" => "Login",
|
||||
"class_version" => "5.0.0",
|
||||
"class_created" => "2000-06-01",
|
||||
"class_author" => "Clemens Schwaighofer"
|
||||
$this->class_info['login'] = array(
|
||||
'class_name' => 'Login',
|
||||
'class_version' => '5.0.0',
|
||||
'class_created' => '2000-06-01',
|
||||
'class_author' => 'Clemens Schwaighofer'
|
||||
);
|
||||
|
||||
// init default ACL list array
|
||||
@@ -378,7 +378,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
// - encrypted password matches
|
||||
// - plain password matches
|
||||
|
||||
if (!$res["enabled"]) {
|
||||
if (!$res['enabled']) {
|
||||
// user is enabled
|
||||
$this->login_error = 104;
|
||||
} elseif ($res['locked']) {
|
||||
@@ -396,25 +396,26 @@ class Login extends \CoreLibs\DB\IO
|
||||
}
|
||||
// normal user processing
|
||||
// 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
|
||||
$this->loginCheckPermissions();
|
||||
if (!$this->login_error) {
|
||||
// now set all session vars and read page permissions
|
||||
$GLOBALS["DEBUG_ALL"] = $_SESSION["DEBUG_ALL"] = $res["debug"];
|
||||
$GLOBALS["DB_DEBUG"] = $_SESSION["DB_DEBUG"] = $res["db_debug"];
|
||||
$_SESSION["USER_NAME"] = $res["username"];
|
||||
$_SESSION["ADMIN"] = $res["admin"];
|
||||
$_SESSION["GROUP_NAME"] = $res["edit_group_name"];
|
||||
$_SESSION["USER_ACL_LEVEL"] = $res["user_level"];
|
||||
$_SESSION["USER_ACL_TYPE"] = $res["user_type"];
|
||||
$_SESSION["GROUP_ACL_LEVEL"] = $res["group_level"];
|
||||
$_SESSION["GROUP_ACL_TYPE"] = $res["group_type"];
|
||||
$_SESSION["TEMPLATE"] = ($res["template"]) ? $res["template"] : DEFAULT_TEMPLATE;
|
||||
$_SESSION["HEADER_COLOR"] = ($res["second_header_color"]) ? $res["second_header_color"] : $res["first_header_color"];
|
||||
$_SESSION["LANG"] = $res["lang_short"];
|
||||
$_SESSION["DEFAULT_CHARSET"] = $res["lang_iso"];
|
||||
$_SESSION["DEFAULT_LANG"] = $res["lang_short"].'_'.strtolower(str_replace('-', '', $res["lang_iso"]));
|
||||
$GLOBALS['DEBUG_ALL'] = $_SESSION['DEBUG_ALL'] = $res['debug'];
|
||||
$GLOBALS['DB_DEBUG'] = $_SESSION['DB_DEBUG'] = $res['db_debug'];
|
||||
$_SESSION['USER_NAME'] = $res['username'];
|
||||
$_SESSION['ADMIN'] = $res['admin'];
|
||||
$_SESSION['GROUP_NAME'] = $res['edit_group_name'];
|
||||
$_SESSION['USER_ACL_LEVEL'] = $res['user_level'];
|
||||
$_SESSION['USER_ACL_TYPE'] = $res['user_type'];
|
||||
$_SESSION['GROUP_ACL_LEVEL'] = $res['group_level'];
|
||||
$_SESSION['GROUP_ACL_TYPE'] = $res['group_type'];
|
||||
// deprecated TEMPLATE setting
|
||||
$_SESSION['TEMPLATE'] = ($res['template']) ? $res['template'] : '';
|
||||
$_SESSION['HEADER_COLOR'] = ($res['second_header_color']) ? $res['second_header_color'] : $res['first_header_color'];
|
||||
$_SESSION['LANG'] = $res['lang_short'];
|
||||
$_SESSION['DEFAULT_CHARSET'] = $res['lang_iso'];
|
||||
$_SESSION['DEFAULT_LANG'] = $res['lang_short'].'_'.strtolower(str_replace('-', '', $res['lang_iso']));
|
||||
// reset any login error count for this user
|
||||
if ($res['login_error_count'] > 0) {
|
||||
$q = "UPDATE edit_user ";
|
||||
@@ -436,22 +437,22 @@ class Login extends \CoreLibs\DB\IO
|
||||
$edit_page_ids[] = $res['edit_page_id'];
|
||||
// create the array for pages
|
||||
array_push($pages, array (
|
||||
"edit_page_id" => $res["edit_page_id"],
|
||||
"filename" => $res["filename"],
|
||||
"page_name" => $res["edit_page_name"],
|
||||
"order" => $res['edit_page_order'],
|
||||
"menu" => $res["menu"],
|
||||
"popup" => $res["popup"],
|
||||
"popup_x" => $res["popup_x"],
|
||||
"popup_y" => $res["popup_y"],
|
||||
"online" => $res["online"],
|
||||
"acl_level" => $res["level"],
|
||||
"acl_type" => $res["type"],
|
||||
"query" => array (),
|
||||
"visible" => array ()
|
||||
'edit_page_id' => $res['edit_page_id'],
|
||||
'filename' => $res['filename'],
|
||||
'page_name' => $res['edit_page_name'],
|
||||
'order' => $res['edit_page_order'],
|
||||
'menu' => $res['menu'],
|
||||
'popup' => $res['popup'],
|
||||
'popup_x' => $res['popup_x'],
|
||||
'popup_y' => $res['popup_y'],
|
||||
'online' => $res['online'],
|
||||
'acl_level' => $res['level'],
|
||||
'acl_type' => $res['type'],
|
||||
'query' => array (),
|
||||
'visible' => array ()
|
||||
));
|
||||
// make reference filename -> level
|
||||
$pages_acl[$res["filename"]] = $res["level"];
|
||||
$pages_acl[$res['filename']] = $res['level'];
|
||||
} // for each page
|
||||
// get the visible groups for all pages and write them to the pages
|
||||
$_edit_page_id = 0;
|
||||
@@ -478,14 +479,14 @@ class Login extends \CoreLibs\DB\IO
|
||||
$_edit_page_id = $res['edit_page_id'];
|
||||
}
|
||||
$pages[$pos[0]]['query'][] = array (
|
||||
"name" => $res['name'],
|
||||
"value" => $res['value'],
|
||||
"dynamic" => $res['dynamic']
|
||||
'name' => $res['name'],
|
||||
'value' => $res['value'],
|
||||
'dynamic' => $res['dynamic']
|
||||
);
|
||||
}
|
||||
|
||||
$_SESSION["PAGES"] = $pages;
|
||||
$_SESSION["PAGES_ACL_LEVEL"] = $pages_acl;
|
||||
$_SESSION['PAGES'] = $pages;
|
||||
$_SESSION['PAGES_ACL_LEVEL'] = $pages_acl;
|
||||
// load the edit_access user rights
|
||||
$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 ";
|
||||
@@ -504,25 +505,25 @@ class Login extends \CoreLibs\DB\IO
|
||||
}
|
||||
// build master unit array
|
||||
$unit_access[$res['edit_access_id']] = array (
|
||||
"id" => $res['edit_access_id'],
|
||||
"acl_level" => $res["level"],
|
||||
"acl_type" => $res["type"],
|
||||
"name" => $res["name"],
|
||||
"uid" => $res['uid'],
|
||||
"color" => $res["color"],
|
||||
"default" => $res["edit_default"],
|
||||
'id' => $res['edit_access_id'],
|
||||
'acl_level' => $res['level'],
|
||||
'acl_type' => $res['type'],
|
||||
'name' => $res['name'],
|
||||
'uid' => $res['uid'],
|
||||
'color' => $res['color'],
|
||||
'default' => $res['edit_default'],
|
||||
'data' => $ea_data
|
||||
);
|
||||
// set the default unit
|
||||
if ($res['edit_default']) {
|
||||
$_SESSION["UNIT_DEFAULT"] = $res['edit_access_id'];
|
||||
$_SESSION['UNIT_DEFAULT'] = $res['edit_access_id'];
|
||||
}
|
||||
// sub arrays for simple access
|
||||
array_push($eauid, $res['edit_access_id']);
|
||||
$unit_acl[$res['edit_access_id']] = $res['level'];
|
||||
}
|
||||
$_SESSION["UNIT"] = $unit_access;
|
||||
$_SESSION["UNIT_ACL_LEVEL"] = $unit_acl;
|
||||
$_SESSION['UNIT'] = $unit_access;
|
||||
$_SESSION['UNIT_ACL_LEVEL'] = $unit_acl;
|
||||
$_SESSION['EAID'] = $eauid;
|
||||
} // user has permission to THIS page
|
||||
} // user was not enabled or other login error
|
||||
@@ -571,7 +572,7 @@ class Login extends \CoreLibs\DB\IO
|
||||
// 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)
|
||||
// ini_set('memory_limit', -1);
|
||||
if ($res["filename"] == $this->page_name) {
|
||||
if ($res['filename'] == $this->page_name) {
|
||||
$this->permission_okay = 1;
|
||||
} else {
|
||||
$this->login_error = 103;
|
||||
@@ -591,20 +592,20 @@ class Login extends \CoreLibs\DB\IO
|
||||
{
|
||||
if ($this->logout || $this->login_error) {
|
||||
// unregister and destroy session vars
|
||||
unset($_SESSION["EUID"]);
|
||||
unset($_SESSION["GROUP_LEVEL"]);
|
||||
unset($_SESSION["PAGES"]);
|
||||
unset($_SESSION["USER_NAME"]);
|
||||
unset($_SESSION["UNIT"]);
|
||||
unset($_SESSION["DEBUG_ALL"]);
|
||||
unset($_SESSION["DB_DEBUG"]);
|
||||
unset($GLOBALS["DEBUG_ALL"]);
|
||||
unset($GLOBALS["DB_DEBUG"]);
|
||||
unset($_SESSION["LANG"]);
|
||||
unset($_SESSION["DEFAULT_CHARSET"]);
|
||||
unset($_SESSION["DEFAULT_LANG"]);
|
||||
unset($_SESSION["GROUP_NAME"]);
|
||||
unset($_SESSION["HEADER_COLOR"]);
|
||||
unset($_SESSION['EUID']);
|
||||
unset($_SESSION['GROUP_LEVEL']);
|
||||
unset($_SESSION['PAGES']);
|
||||
unset($_SESSION['USER_NAME']);
|
||||
unset($_SESSION['UNIT']);
|
||||
unset($_SESSION['DEBUG_ALL']);
|
||||
unset($_SESSION['DB_DEBUG']);
|
||||
unset($GLOBALS['DEBUG_ALL']);
|
||||
unset($GLOBALS['DB_DEBUG']);
|
||||
unset($_SESSION['LANG']);
|
||||
unset($_SESSION['DEFAULT_CHARSET']);
|
||||
unset($_SESSION['DEFAULT_LANG']);
|
||||
unset($_SESSION['GROUP_NAME']);
|
||||
unset($_SESSION['HEADER_COLOR']);
|
||||
session_destroy();
|
||||
// then prints the login screen again
|
||||
$this->permission_okay = 0;
|
||||
@@ -939,11 +940,11 @@ class Login extends \CoreLibs\DB\IO
|
||||
$password = '';
|
||||
// set event
|
||||
if ($this->login) {
|
||||
$event = "Login";
|
||||
$event = 'Login';
|
||||
} elseif ($this->logout) {
|
||||
$event = "Logout";
|
||||
$event = 'Logout';
|
||||
} else {
|
||||
$event = "No Permission";
|
||||
$event = 'No Permission';
|
||||
}
|
||||
// prepare for log
|
||||
if ($this->euid) {
|
||||
|
||||
@@ -60,26 +60,26 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
// instance db_io class
|
||||
parent::__construct($db_config, $debug, $db_debug, $echo, $print);
|
||||
// more error vars for this class
|
||||
$this->error_string["21"] = "No Primary Key given";
|
||||
$this->error_string["22"] = "Could not run Array Query";
|
||||
$this->error_string['21'] = 'No Primary Key given';
|
||||
$this->error_string['22'] = 'Could not run Array Query';
|
||||
|
||||
$this->table_array = $table_array;
|
||||
$this->table_name = $table_name;
|
||||
|
||||
// set primary key for given table_array
|
||||
if ($this->table_array) {
|
||||
foreach ($table_array as $key => $value) {
|
||||
if ($value["pk"]) {
|
||||
if (is_array($this->table_array)) {
|
||||
foreach ($this->table_array as $key => $value) {
|
||||
if ($value['pk']) {
|
||||
$this->pk_name = $key;
|
||||
}
|
||||
}
|
||||
} // set pk_name IF table_array was given
|
||||
// internal
|
||||
$this->class_info["db_array_io"] = array(
|
||||
"class_name" => "DB Array IO",
|
||||
"class_version" => "1.0.0",
|
||||
"class_created" => "2002/12/17",
|
||||
"class_author" => "Clemens Schwaighofer"
|
||||
$this->class_info['db_array_io'] = array(
|
||||
'class_name' => 'DB Array IO',
|
||||
'class_version' => '1.0.0',
|
||||
'class_created' => '2002/12/17',
|
||||
'class_author' => 'Clemens Schwaighofer'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
reset($this->table_array);
|
||||
$string = '';
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
$string .= "<b>".$column."</b> -> ".$data_array["value"]."<br>";
|
||||
$string .= '<b>'.$column.'</b> -> '.$data_array['value'].'<br>';
|
||||
}
|
||||
// add output to internal error_msg
|
||||
if ($write) {
|
||||
@@ -153,10 +153,10 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
{
|
||||
// if pk_id is set, overrule ...
|
||||
if ($this->pk_id) {
|
||||
$this->table_array[$this->pk_name]["value"] = $this->pk_id;
|
||||
$this->table_array[$this->pk_name]['value'] = $this->pk_id;
|
||||
}
|
||||
// if not set ... produce error
|
||||
if (!$this->table_array[$this->pk_name]["value"]) {
|
||||
if (!$this->table_array[$this->pk_name]['value']) {
|
||||
// if no PK found, error ...
|
||||
$this->error_id = 21;
|
||||
$this->__dbError();
|
||||
@@ -175,10 +175,10 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
{
|
||||
reset($this->table_array);
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
if (!$this->table_array[$column]["pk"]) {
|
||||
unset($this->table_array[$column]["value"]);
|
||||
if (!$this->table_array[$column]['pk']) {
|
||||
unset($this->table_array[$column]['value']);
|
||||
} elseif ($reset_pk) {
|
||||
unset($this->table_array[$column]["value"]);
|
||||
unset($this->table_array[$column]['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,37 +197,37 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
return $this->table_array;
|
||||
}
|
||||
// delete query
|
||||
$q = "DELETE FROM ".$this->table_name." WHERE ";
|
||||
$q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." ";
|
||||
$q = 'DELETE FROM '.$this->table_name.' WHERE ';
|
||||
$q .= $this->pk_name.' = '.$this->table_array[$this->pk_name]['value'].' ';
|
||||
// delete files and build FK query
|
||||
reset($this->table_array);
|
||||
$q_where = '';
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
// suchen nach bildern und lschen ...
|
||||
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"])) {
|
||||
unlink($this->table_array[$column]["path"].$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'])) {
|
||||
unlink($this->table_array[$column]['path'].$this->table_array[$column]['value']);
|
||||
}
|
||||
$file_name = str_replace("_tn", "", $this->table_array[$column]["value"]);
|
||||
if (file_exists($this->table_array[$column]["path"].$file_name)) {
|
||||
unlink($this->table_array[$column]["path"].$file_name);
|
||||
$file_name = str_replace('_tn', '', $this->table_array[$column]['value']);
|
||||
if (file_exists($this->table_array[$column]['path'].$file_name)) {
|
||||
unlink($this->table_array[$column]['path'].$file_name);
|
||||
}
|
||||
}
|
||||
// if we have a foreign key
|
||||
if ($this->table_array[$column]["fk"]) {
|
||||
if ($this->table_array[$column]['fk']) {
|
||||
// create FK constraint checks
|
||||
if ($q_where) {
|
||||
$q_where .= " AND ";
|
||||
$q_where .= ' AND ';
|
||||
}
|
||||
$q_where .= $column." = ".$this->table_array[$column]["value"];
|
||||
$q_where .= $column.' = '.$this->table_array[$column]['value'];
|
||||
}
|
||||
// allgemeines zurcksetzen des arrays
|
||||
unset($this->table_array[$column]["value"]);
|
||||
unset($this->table_array[$column]['value']);
|
||||
}
|
||||
|
||||
// attach fk row if there ...
|
||||
if ($q_where) {
|
||||
$q .= " AND ".$q_where;
|
||||
$q .= ' AND '.$q_where;
|
||||
}
|
||||
// if 0, error
|
||||
unset($this->pk_id);
|
||||
@@ -258,25 +258,25 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
// create select part & addition FK part
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
if ($q_select) {
|
||||
$q_select .= ", ";
|
||||
$q_select .= ', ';
|
||||
}
|
||||
$q_select .= $column;
|
||||
|
||||
// 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) {
|
||||
$q_where .= " AND ";
|
||||
$q_where .= ' AND ';
|
||||
}
|
||||
$q_where .= $column .= " = ".$this->table_array[$column]["value"];
|
||||
$q_where .= $column .= ' = '.$this->table_array[$column]['value'];
|
||||
}
|
||||
}
|
||||
|
||||
$q = "SELECT ";
|
||||
$q = 'SELECT ';
|
||||
$q .= $q_select;
|
||||
$q .= " FROM ".$this->table_name." WHERE ";
|
||||
$q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." ";
|
||||
$q .= ' FROM '.$this->table_name.' WHERE ';
|
||||
$q .= $this->pk_name.' = '.$this->table_array[$this->pk_name]['value'].' ';
|
||||
if ($q_where) {
|
||||
$q .= " AND ".$q_where;
|
||||
$q .= ' AND '.$q_where;
|
||||
}
|
||||
|
||||
// if query was executed okay, else set error
|
||||
@@ -286,21 +286,21 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
// wenn "edit" dann gib daten wie in DB zurck, ansonten aufbereiten fr ausgabe
|
||||
// ?? sollte das nicht drauen ??? 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) {
|
||||
$this->table_array[$column]["value"] = $res[$column];
|
||||
$this->table_array[$column]['value'] = $res[$column];
|
||||
// if password, also write to hidden
|
||||
if ($this->table_array[$column]["type"] == "password") {
|
||||
$this->table_array[$column]["HIDDEN_value"] = $res[$column];
|
||||
if ($this->table_array[$column]['type'] == 'password') {
|
||||
$this->table_array[$column]['HIDDEN_value'] = $res[$column];
|
||||
}
|
||||
} else {
|
||||
$this->table_array[$column]["value"] = $this->convertData(nl2br($res[$column]));
|
||||
$this->table_array[$column]['value'] = $this->convertData(nl2br($res[$column]));
|
||||
// had to put out the htmlentities from the line above as it breaks japanese characters
|
||||
}
|
||||
}
|
||||
}
|
||||
// possible dbFetchArray errors ...
|
||||
$this->pk_id = $this->table_array[$this->pk_name]["value"];
|
||||
$this->pk_id = $this->table_array[$this->pk_name]['value'];
|
||||
} else {
|
||||
$this->error_id = 22;
|
||||
$this->__dbError();
|
||||
@@ -323,7 +323,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
// $this->table_array[$this->pk_name]["value"]=$this->pk_id;
|
||||
// }
|
||||
// checken ob PKs gesetzt, wenn alle -> update, wenn keiner -> insert, wenn ein paar -> ERROR!
|
||||
if (!$this->table_array[$this->pk_name]["value"]) {
|
||||
if (!$this->table_array[$this->pk_name]['value']) {
|
||||
$insert = 1;
|
||||
} else {
|
||||
$insert = 0;
|
||||
@@ -336,47 +336,47 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
/********************************* START FILE *************************************/
|
||||
// file upload
|
||||
if ($this->table_array[$column]["file"]) {
|
||||
if ($this->table_array[$column]['file']) {
|
||||
// falls was im tmp drinnen, sprich ein upload, datei kopieren, Dateinamen in db schreiben
|
||||
// falls datei schon am server (physischer pfad), dann einfach url in db schreiben (update)
|
||||
// falls in "delete" "ja" dann loeschen (und gibts eh nur beim update)
|
||||
if ($this->table_array[$column]["delete"]) {
|
||||
unset($this->table_array[$column]["delete"]);
|
||||
if (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) {
|
||||
unlink($this->table_array[$column]["path"].$this->table_array[$column]["value"]);
|
||||
// falls in 'delete' 'ja' dann loeschen (und gibts eh nur beim update)
|
||||
if ($this->table_array[$column]['delete']) {
|
||||
unset($this->table_array[$column]['delete']);
|
||||
if (file_exists($this->table_array[$column]['path'].$this->table_array[$column]['value'])) {
|
||||
unlink($this->table_array[$column]['path'].$this->table_array[$column]['value']);
|
||||
}
|
||||
$file_name = str_replace("_tn", "", $this->table_array[$column]["value"]);
|
||||
if (file_exists($this->table_array[$column]["path"].$file_name)) {
|
||||
unlink($this->table_array[$column]["path"].$file_name);
|
||||
$file_name = str_replace('_tn', '', $this->table_array[$column]['value']);
|
||||
if (file_exists($this->table_array[$column]['path'].$file_name)) {
|
||||
unlink($this->table_array[$column]['path'].$file_name);
|
||||
}
|
||||
$this->table_array[$column]["value"] = "";
|
||||
$this->table_array[$column]['value'] = '';
|
||||
} else {
|
||||
if ($this->table_array[$column]["tmp"] != "none" && $this->table_array[$column]["tmp"]) {
|
||||
if ($this->table_array[$column]['tmp'] != 'none' && $this->table_array[$column]['tmp']) {
|
||||
// Dateiname zusammenbasteln: org-name + _pkid liste + .ext
|
||||
list($name, $ext) = explode(".", $this->table_array[$column]["dn"]);
|
||||
list($name, $ext) = explode('.', $this->table_array[$column]['dn']);
|
||||
|
||||
// mozilla, patch
|
||||
$fn_name = explode("/", $this->table_array[$column]["dn"]);
|
||||
$this->table_array[$column]["dn"] = $fn_name[count($fn_name)-1];
|
||||
$filename_parts = explode(".", $this->table_array[$column]["dn"]);
|
||||
$fn_name = explode('/', $this->table_array[$column]['dn']);
|
||||
$this->table_array[$column]['dn'] = $fn_name[count($fn_name)-1];
|
||||
$filename_parts = explode('.', $this->table_array[$column]['dn']);
|
||||
$ext = end($filename_parts);
|
||||
array_splice($filename_parts, -1, 1);
|
||||
$name = str_replace(" ", "_", implode(".", $filename_parts));
|
||||
$file_name = $name.".".$ext;
|
||||
//echo "Dn: $file_name";
|
||||
copy($this->table_array[$column]["tmp"], $this->table_array[$column]["path"].$file_name);
|
||||
$name = str_replace(' ', '_', implode('.', $filename_parts));
|
||||
$file_name = $name.'.'.$ext;
|
||||
//echo 'Dn: $file_name';
|
||||
copy($this->table_array[$column]['tmp'], $this->table_array[$column]['path'].$file_name);
|
||||
// automatisch thumbnail generieren, geht nur mit convert (ImageMagic!!!), aber nur bei bild ..
|
||||
if (strtolower($ext) == "jpeg" || strtolower($ext) == "jpg" || strtolower($ext) == "gif" || strtolower($ext) == "png") {
|
||||
$file_name_tn = $name."_tn.".$ext;
|
||||
$eingang = $this->table_array[$column]["path"].$file_name;
|
||||
$ausgang = $this->table_array[$column]["path"].$file_name_tn;
|
||||
$com = "convert -geometry 115 $eingang $ausgang";
|
||||
if (strtolower($ext) == 'jpeg' || strtolower($ext) == 'jpg' || strtolower($ext) == 'gif' || strtolower($ext) == 'png') {
|
||||
$file_name_tn = $name.'_tn.'.$ext;
|
||||
$input = $this->table_array[$column]['path'].$file_name;
|
||||
$output = $this->table_array[$column]['path'].$file_name_tn;
|
||||
$com = 'convert -geometry 115 '.$input.' '.$output;
|
||||
exec($com);
|
||||
$this->table_array[$column]["value"] = $file_name_tn;
|
||||
$this->table_array[$column]['value'] = $file_name_tn;
|
||||
} else {
|
||||
$this->table_array[$column]["value"] = $file_name;
|
||||
$this->table_array[$column]['value'] = $file_name;
|
||||
}
|
||||
} elseif (file_exists($this->table_array[$column]["path"].$this->table_array[$column]["value"])) {
|
||||
} elseif (file_exists($this->table_array[$column]['path'].$this->table_array[$column]['value'])) {
|
||||
// mach gar nix, wenn bild schon da ???
|
||||
}
|
||||
} // delete or upload
|
||||
@@ -384,43 +384,43 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
/********************************* END FILE **************************************/
|
||||
|
||||
// do not write 'pk' (primary key) or 'view' values
|
||||
if (!$this->table_array[$column]["pk"] && $this->table_array[$column]['type'] != 'view' && strlen($column) > 0) {
|
||||
if (!$this->table_array[$column]['pk'] && $this->table_array[$column]['type'] != 'view' && strlen($column) > 0) {
|
||||
// for password use hidden value if main is not set
|
||||
if ($this->table_array[$column]["type"] == "password" && !$this->table_array[$column]["value"]) {
|
||||
$this->table_array[$column]["value"] = $this->table_array[$column]["HIDDEN_value"];
|
||||
if ($this->table_array[$column]['type'] == 'password' && !$this->table_array[$column]['value']) {
|
||||
$this->table_array[$column]['value'] = $this->table_array[$column]['HIDDEN_value'];
|
||||
}
|
||||
if (!$insert) {
|
||||
if (strlen($q_data)) {
|
||||
$q_data .= ", ";
|
||||
$q_data .= ', ';
|
||||
}
|
||||
$q_data .= $column." = ";
|
||||
$q_data .= $column.' = ';
|
||||
} else {
|
||||
// this is insert
|
||||
if (strlen($q_data)) {
|
||||
$q_data .= ", ";
|
||||
$q_data .= ', ';
|
||||
}
|
||||
if ($q_vars) {
|
||||
$q_vars .= ", ";
|
||||
$q_vars .= ', ';
|
||||
}
|
||||
$q_vars .= $column;
|
||||
}
|
||||
// integer is different
|
||||
if ($this->table_array[$column]["int"] || $this->table_array[$column]["int_null"]) {
|
||||
$this->debug('write_check', "[$column][".$this->table_array[$column]["value"]."] Foo: ".isset($this->table_array[$column]["value"])." | ".$this->table_array[$column]["int_null"]);
|
||||
if (!$this->table_array[$column]["value"] && $this->table_array[$column]["int_null"]) {
|
||||
if ($this->table_array[$column]['int'] || $this->table_array[$column]['int_null']) {
|
||||
$this->debug('write_check', '[$column]['.$this->table_array[$column]['value'].'] Foo: '.isset($this->table_array[$column]['value']).' | '.$this->table_array[$column]['int_null']);
|
||||
if (!$this->table_array[$column]['value'] && $this->table_array[$column]['int_null']) {
|
||||
$_value = 'NULL';
|
||||
} elseif (!isset($this->table_array[$column]["value"])) {
|
||||
} elseif (!isset($this->table_array[$column]['value'])) {
|
||||
$_value = 0;
|
||||
} else {
|
||||
$_value = $this->table_array[$column]["value"];
|
||||
$_value = $this->table_array[$column]['value'];
|
||||
}
|
||||
$q_data .= $_value;
|
||||
} elseif ($this->table_array[$column]['bool']) {
|
||||
// boolean storeage (reverse check on ifset)
|
||||
$q_data .= "'".$this->dbBoolean($this->table_array[$column]["value"], true)."'";
|
||||
$q_data .= "'".$this->dbBoolean($this->table_array[$column]['value'], true)."'";
|
||||
} elseif ($this->table_array[$column]["interval"]) {
|
||||
// for interval we check if no value, then we set null
|
||||
if (!$this->table_array[$column]["value"]) {
|
||||
if (!$this->table_array[$column]['value']) {
|
||||
$_value = 'NULL';
|
||||
}
|
||||
$q_data .= $_value;
|
||||
@@ -429,9 +429,9 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
$q_data .= "'";
|
||||
// if add slashes do convert & add slashes else write AS is
|
||||
if ($addslashes) {
|
||||
$q_data .= $this->dbEscapeString($this->convertEntities($this->table_array[$column]["value"]));
|
||||
$q_data .= $this->dbEscapeString($this->convertEntities($this->table_array[$column]['value']));
|
||||
} else {
|
||||
$q_data .= $this->dbEscapeString($this->table_array[$column]["value"]);
|
||||
$q_data .= $this->dbEscapeString($this->table_array[$column]['value']);
|
||||
}
|
||||
$q_data .= "'";
|
||||
}
|
||||
@@ -444,39 +444,39 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
// create select part & addition FK part
|
||||
foreach ($this->table_array as $column => $data_array) {
|
||||
// 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) {
|
||||
$q_where .= " AND ";
|
||||
$q_where .= ' AND ';
|
||||
}
|
||||
$q_where .= $column .= " = ".$this->table_array[$column]["value"];
|
||||
$q_where .= $column .= ' = '.$this->table_array[$column]['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// if no PK set, then get max ID from DB
|
||||
if (!$this->table_array[$this->pk_name]["value"]) {
|
||||
// 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);
|
||||
if (!$res["pk_id"]) {
|
||||
$res["pk_id"] = 1;
|
||||
if (!$res['pk_id']) {
|
||||
$res['pk_id'] = 1;
|
||||
}
|
||||
$this->table_array[$this->pk_name]["value"] = $res["pk_id"];
|
||||
$this->table_array[$this->pk_name]['value'] = $res['pk_id'];
|
||||
}
|
||||
|
||||
if (!$insert) {
|
||||
$q = "UPDATE ".$this->table_name." SET ";
|
||||
$q = 'UPDATE '.$this->table_name.' SET ';
|
||||
$q .= $q_data;
|
||||
$q .= " WHERE ";
|
||||
$q .= $this->pk_name." = ".$this->table_array[$this->pk_name]["value"]." ";
|
||||
$q .= ' WHERE ';
|
||||
$q .= $this->pk_name.' = '.$this->table_array[$this->pk_name]['value'].' ';
|
||||
if ($q_where) {
|
||||
$q .= " AND ".$q_where;
|
||||
$q .= ' AND '.$q_where;
|
||||
}
|
||||
// set pk_id ... if it has changed or so
|
||||
$this->pk_id = $this->table_array[$this->pk_name]["value"];
|
||||
$this->pk_id = $this->table_array[$this->pk_name]['value'];
|
||||
} else {
|
||||
$q = "INSERT INTO ".$this->table_name." ";
|
||||
$q .= "(".$q_vars.") ";
|
||||
$q .= "VALUES (".$q_data.")";
|
||||
$q = 'INSERT INTO '.$this->table_name.' ';
|
||||
$q .= '('.$q_vars.') ';
|
||||
$q .= 'VALUES ('.$q_data.')';
|
||||
// write primary key too
|
||||
// if ($q_data)
|
||||
// $q .= ", ";
|
||||
@@ -490,7 +490,7 @@ class ArrayIO extends \CoreLibs\DB\IO
|
||||
}
|
||||
// set primary key
|
||||
if ($insert) {
|
||||
$this->table_array[$this->pk_name]["value"] = $this->insert_id;
|
||||
$this->table_array[$this->pk_name]['value'] = $this->insert_id;
|
||||
$this->ok = $this->insert_id;
|
||||
}
|
||||
// return the table if needed
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user