/** * Copies a row an replaces specified values * if translate is specified as value, the given id will be translated to a live id. * * @param string Name of table in which row shall be copied * @param string Filter to apply on table to select record(s) * @param array array[n]["column"]: Column to replace, array[n]["value"]: Value to set, array[n]["datatype"]: type of data (NUMBER|CHAR|DATE) */ function copyRow($table, $filter, $values) { global $db, $c_datatypes, $panic; $sql = "SELECT * FROM $table WHERE $filter"; $query = new query($db, $sql); for ($i = 0; $i < $query->count(); $i++) { $row = $query->getrow(); $newRec = new CreateSet($table); $columns = $db->ADODB->MetaColumns($table); if (!is_array($columns)) return false; foreach ($columns as $name=>$obvalue) { $value[$n] = $query->field($name); foreach ($values as $vcol => $vval) { if ($name == $vcol) { if (sameText($vval, "translate")) { if (is_numeric($value[$n]) && ($value[$n] != "0")) $value[$n] = translateState($value[$n], 10, false); } else { $value[$n] = $vval; } } } $column[$n] = $name; $newRec->add($column[$n], $value[$n], $c_datatypes[$table][$name]); } $newRec->execute(); } }
/** * Checks, if a session is still correct. If so, returns true, else false. * The procedure checks, if the timeout is not reached yet and if the given sid * is correct. Also the remote address of the user is checked. The maximum login time * that is allowed is 4 hours at the moment. After that time, a new login is necessary. * @return boolean true if Session valid, else false. */ function validateSession() { global $db, $c; if ($this->session != "") { if ($c["disalbehostchecking"]) { $sql = "SELECT U.USER_ID, U.USER_NAME, U.FULL_NAME FROM user_session S, users U WHERE U.USER_ID = S.USER_ID AND S.SESSION_ID='{$this->session}' AND U.ACTIVE=1 AND NOW() <= DATE_ADD(S.LAST_LOGIN, INTERVAL 4 HOUR)"; } else { $sql = "SELECT U.USER_ID, U.USER_NAME, U.FULL_NAME FROM user_session S, users U WHERE U.USER_ID = S.USER_ID AND S.SESSION_ID='{$this->session}' AND S.REMOTE_ADDRESS = '{$this->remote}' AND U.ACTIVE=1 AND NOW() <= DATE_ADD(S.LAST_LOGIN, INTERVAL 4 HOUR)"; } $query = new query($db, $sql); if ($query->count() == 1) { // login successfull $query->getrow(); $this->userId = $query->field("USER_ID"); $this->user = $query->field("USER_NAME"); $this->userName = $query->field("FULL_NAME"); if (reg_load("SYSTEM/MAINTENANCE/BB") != "1" || sameText("Administrator", $this->user)) { return true; } } else { return false; } } return false; }
if (sameText($action, "create") || sameText($action, "update")) { don(); $form = new stdEDForm("Create configurator item"); $form->width = 700; $cond = $form->setPK("shop_configurator_item", "GUID"); $form->add(new NonDisplayedValueOnInsert("shop_configurator_item", "CONFIGURATOR_ID", $cond, $configuratorId, "NUMBER")); $form->add(new TextInput($lang->get("title", "Title"), "shop_configurator_item", "TITLE", $cond, "type:text,size:255,width:300", "MANDATORY", "TEXT")); $form->add(new TextInput($lang->get("position", "Position"), "shop_configurator_item", "POSITION", $cond, "type:text,size:2,width:40", "MANDATORY&NUMBER", "NUMBER")); $form->add(new SelectOneInputFixed($lang->get("conf_type", "Configurator Type"), "shop_configurator_item", "TYPE", $ar, $cond, "type:dropdown,width:150", "MANDATORY", "NUMBER")); $form->add(new TextInput($lang->get("configuration", "Configuration"), "shop_configurator_item", "VALUE", $cond, "type:text,size:1024,width:300", "", "TEXT")); $form->add(new Hidden("go", $action)); $form->check(); $form->process(); echo $form->draw(); } else { if (sameText($action, "update")) { echo $action; } else { // draw list with all items. $page = new page("foo"); // dummy page with no use. $form = new MenuForm($lang->get("configurator_settings", "Configurator Settings"), array($lang->get("position0", 'Position'), $lang->get("name", "Name"), $lang->get("value", "Value")), "shop_configurator_item", "GUID", array("POSITION", "TITLE", "VALUE"), "1", 10); $form->addFilterRule($lang->get("name"), "TITLE"); $form->width = 700; $form->newAction = "api/userinterface/spinput/" . doc() . '?go=create&sid=' . $sid; $form->editAction = doc(); echo $form->draw(); } } } /**