function draw(&$form) { parent::draw($form); $text = new CHAW_text($this->title . $this->labelseparator); $text->set_br(0); if (!empty($this->title)) { $form->add_text($text); } $mySelect = new CHAW_select($this->key); global $_CAMILA; $_CAMILA['db']->SetFetchMode(ADODB_FETCH_ASSOC); $result = $_CAMILA['db']->Execute($this->query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $val = ''; while (!$result->EOF) { if ($result->fields[$this->lbkey] == $this->value) { $mySelect->add_option($result->fields[$this->lbvalue], $result->fields[$this->lbkey], HAW_SELECTED); $val = $result->fields[$this->lbvalue]; } else { $mySelect->add_option($result->fields[$this->lbvalue], $result->fields[$this->lbkey]); } $result->MoveNext(); } if ($this->updatable) { $form->add_select($mySelect); $text = new CHAW_text(''); $form->add_text($text); } else { $text = new CHAW_text($val); $form->add_text($text); } }
function validate() { if ($_REQUEST[$this->form->table . '_sess_mode'] != 'insert') { return true; } parent::validate(); if ($this->value != '' and $this->maxlength > 0) { $this->form->validator->length($this->field, '<=', $this->maxlength); } if ($this->alphanumeric) { $this->form->validator->alphaNumeric($this->field); } else { $this->form->validator->alpha($this->field); } if ($this->value != '') { global $_CAMILA; $query = 'select * from ' . $this->form->table . ' where ' . $this->field . '=' . $_CAMILA['db']->Quote($this->value); $result = $_CAMILA['db']->Execute($query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } if ($result->RecordCount() > 0) { $this->form->validator->setError($this->field, 907); } } }
function camila_news_counter_value($usergroup, $service_id) { global $_CAMILA; $result = $_CAMILA['db']->Execute("select value from camila_news_counters where usergroup=? and service_id=?", array($usergroup, $service_id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } return $result->fields['value']; }
function worktable_get_next_autoincrement_value($table, $column) { global $_CAMILA; $result = $_CAMILA['db']->Execute('select max(' . $column . ') as id from ' . $table); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } return intval($result->fields['id']) + 1; }
function draw(&$form) { parent::draw($form); $text = new CHAW_text($this->title . $this->labelseparator); $text->set_br(1); if (!empty($this->title)) { $form->add_text($text); } $select_all = new CHAW_js('<div class="camilacheckall" id="camilacheckall"><a id="CheckAll_' . $this->key . '" href="">' . camila_get_translation('camila.form.checkall') . '</a> ' . camila_get_translation('camila.form.checkallseparator') . ' <a id="UncheckAll_' . $this->key . '" href="">' . camila_get_translation('camila.form.uncheckall') . '</a></div>'); $form->add_userdefined($select_all); global $_CAMILA; $_CAMILA['db']->SetFetchMode(ADODB_FETCH_ASSOC); $result = $_CAMILA['db']->Execute($this->query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $count = 0; // while (!$result->EOF) { for ($i = 0; $i < count($this->values); $i++) { // $myHidden = new CHAW_hidden($this->key . '_labels_'.$count, $result->fields[$this->label_field]); // $form->add_input($myHidden); if ($this->values[$i] == '') { $myImage = new CHAW_image(CAMILA_IMG_DIR . 'wbmp/nocheck.wbmp', CAMILA_IMG_DIR . 'png/nocheck.png', '-'); $myImage->set_br(0); $form->add_image($myImage); $text = new CHAW_text($this->labels[$i]); $form->add_text($text); } else { if (in_array($this->values[$i], $this->value)) { $myCheckbox = new CHAW_checkbox($this->key . '_' . $i, $this->values[$i], $this->labels[$i], HAW_SELECTED); } else { $myCheckbox = new CHAW_checkbox($this->key . '_' . $i, $this->values[$i], $this->labels[$i]); } $form->add_checkbox($myCheckbox); $this->checked++; } $count++; // $result->MoveNext(); } // $myHidden = new CHAW_hidden($this->key . '_count', $count); // $form->add_input($myHidden); }
function process() { if (!$this->drawnavigationbox || isset($_REQUEST['camila_xml2pdf'])) { $this->rows = -1; $this->page = 1; } if (isset($_REQUEST['camila_pagnum'])) { $this->page = intval($_REQUEST['camila_pagnum']); if ($this->page < 0) { $this->rows = -1; $this->page = 1; $this->inline_editing = false; } $this->offset = ($this->page - 1) * $this->rows; } if (is_array($this->stmt)) { $stmt = '('; foreach ($this->stmt as $v) { $stmt .= $this->condition != '' ? $v . ' where ' . $this->condition : $v; $stmt .= ') UNION ('; } $stmt = substr($stmt, 0, strlen($stmt) - 8); } else { if (stristr($this->stmt, 'group by') === false) { $cong = ' and '; if (stristr($this->stmt, 'where') === false) { $cong = ' where '; } $stmt = $this->condition != '' ? $this->stmt . $cong . $this->condition : $this->stmt; } else { $cong = ' and '; if (stristr($this->stmt, 'having') === false) { $cong = ' having '; } $stmt = $this->condition != '' ? $this->stmt . $cong . $this->condition : $this->stmt; //$stmt = ($this->condition!='' ? substr( $this->stmt, 0, strpos($this->stmt, "group by")+0).' '.$cong.$this->condition.' '.substr( $this->stmt, strpos( $this->stmt, 'group by')+0) :$this->stmt); } } if ($this->gbyconditionpresent) { //$stmt .= ' group by ' . substr($_REQUEST['camila_w'.$this->totalconditions.'f'], 3); $stmt .= ' group by '; $count = 0; foreach ($this->gbyconditions as $key => $value) { if ($count > 0) { $stmt .= ',' . $value; } else { $stmt .= $value; } $count++; } //$stmt .= ' group by ' . substr($_REQUEST['camila_w'.$this->totalconditions.'f'], 3); } if ($this->orderby != '') { if (strpos($this->orderby, '__') !== false) { $this->orderby = substr($this->orderby, 0, strpos($this->orderby, '__')) . '.' . substr($this->orderby, strpos($this->orderby, '__') + 2); } $stmt = $stmt . ' order by ' . $this->orderby; if (!isset($_REQUEST['d'])) { $stmt .= ' ' . $this->direction; } elseif ($_REQUEST['d'] == 0) { $stmt .= ' asc'; $this->direction = 'asc'; } else { $stmt .= ' desc'; $this->direction = 'desc'; } } global $_CAMILA; $_CAMILA['db']->SetFetchMode(ADODB_FETCH_ASSOC); $result = $_CAMILA['db']->Execute($stmt); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $this->numfields = $result->FieldCount(); $this->totalrows = $result->RecordCount(); $_CAMILA['report_record_count'] = $this->totalrows; if ($this->rows > 0) { $result = $_CAMILA['db']->SelectLimit($stmt, $this->rows, $this->offset); } //$this->totalrows = $result->RecordCount(); $this->res = $result; if ($_CAMILA['db']->databaseType == 'sqlite' && count($this->tables) == 1) { $this->adoMetaColumns = $_CAMILA['db']->MetaColumns($this->tables[0]); } for ($i = 0; $i < $this->numfields; $i++) { $curr_field = $this->res->FetchField($i); $curr = $curr_field->name; $fcurr = $this->map($curr); $type = $this->res->MetaType($curr_field->type); if ($_CAMILA['db']->databaseType == 'sqlite' && count($this->tables) == 1 && $this->adoMetaColumns[strtoupper($curr_field->name)]->type != '') { $type = $this->res->MetaType($this->adoMetaColumns[strtoupper($curr_field->name)]->type); } reset($this->tables); foreach ($this->tables as $key => $value) { if ($this->mapping != '' && strpos($this->mapping . '=', $this->mappingseparator . $value . '.' . $curr . '=') !== false) { $fcurr = $this->map($value . '.' . $curr); $curr = $value . '__' . $curr; } } if (strpos($curr, 'cf_bool_') !== false) { $this->fields[$curr] = new report_icon($curr, $fcurr); } else { if (strpos($curr, 'cf_formula_') !== false) { $this->fields[$curr] = new report_formula($curr, $fcurr); } else { if (strpos($curr, 'cf_query_') !== false) { $this->fields[$curr] = new report_query($curr, $fcurr); } elseif ($type == 'I') { $this->fields[$curr] = new report_int($curr, $fcurr); } elseif ($type == 'N') { $this->fields[$curr] = new report_real($curr, $fcurr); } elseif ($type == 'D') { $this->fields[$curr] = new report_date($curr, $fcurr); } elseif ($type == 'datetime') { $this->fields[$curr] = new report_datetime($curr, $fcurr); } elseif ($type == 'T') { $this->fields[$curr] = new report_timestamp($curr, $fcurr); } else { $this->fields[$curr] = new report_string($curr, $fcurr); } } } $size = $curr_field->max_length; if ($size > 30) { $size = 30; } $this->fields[$curr]->metatype = $type; $this->fields[$curr]->report = $this; if ($this->gbyconditionpresent) { $this->fields[$curr]->inline = false; } } }
function process() { if (isset($this->filter)) { $this->filter->process(); } $afield = "select_{$this->table}_field"; if (!isset($_REQUEST['camila_update']) && !isset($_REQUEST['camila_delete'])) { return false; } if (isset($_REQUEST['camila_update'])) { $this->value = unserialize(stripslashes($_REQUEST['camila_update'])); $check = camila_token($_REQUEST['camila_update']); } else { $this->value = unserialize(stripslashes($_REQUEST['camila_delete'])); $check = camila_token($_REQUEST['camila_delete']); } if ($check != $_REQUEST['camila_token'] && $_REQUEST['camila_update'] != 'new') { camila_error_page('Accesso non consentito a questa pagina'); } return true; }
function _checkboxes($processing) { global $_CAMILA; $sql2 = 'select ' . $this->bkey . ',' . $this->value_field . ' from ' . $this->intertable . ' where ' . $this->akey . '=\'' . $this->form->fields[$this->formkey]->value . '\''; $res2 = $_CAMILA['db']->GetAssoc($sql2); if ($res2 === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $_CAMILA['db']->SetFetchMode(ADODB_FETCH_ASSOC); $result = $_CAMILA['db']->Execute($this->query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $count = 0; while (!$result->EOF) { if (!$processing && array_key_exists($result->fields[$this->key_field], $res2) || $processing && $_REQUEST[$this->key][$result->fields[$this->key_field]] != '') { $this->checked++; if ($processing) { $myCheckbox = new CHAW_input($this->key . '[' . $result->fields[$this->key_field] . ']', $_REQUEST[$this->key][$result->fields[$this->key_field]], $result->fields[$this->label_field]); } else { $myCheckbox = new CHAW_input($this->key . '[' . $result->fields[$this->key_field] . ']', $res2[$result->fields[$this->key_field]], $result->fields[$this->label_field]); } } else { $myCheckbox = new CHAW_input($this->key . '[' . $result->fields[$this->key_field] . ']', '', $result->fields[$this->label_field]); } $this->checklist_values[$result->fields[$this->key_field]] = $result->fields[$this->value_field]; $this->checklist_checkboxes[$count] = $myCheckbox; $count++; $result->MoveNext(); } $this->_checkboxes_loaded = true; }
function validate() { parent::validate(); if ($this->value != '') { global $_CAMILA; $query = 'select password from ' . CAMILA_TABLE_USERS . ' where id=' . $_CAMILA['db']->Quote($_CAMILA['user_id']); $result = $_CAMILA['db']->Execute($query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } if ($result->RecordCount() == 1) { if ($result->fields['password'] != $_REQUEST[$this->key . '_old']) { $this->form->validator->setError($this->field, 910); } } else { $this->form->validator->setError($this->field, 910); } } if ($_REQUEST[$this->key . '_confirm'] != $this->value) { $this->form->validator->setError($this->field, 911); } }
function operation($id, $operation, $returl) { global $_CAMILA; if ($operation == 'delete') { require_once CAMILA_DIR . 'datagrid/form.class.php'; require_once CAMILA_DIR . 'datagrid/elements/form/hidden.php'; $form3 = new phpform('camila', 'cf_worktable_admin.php'); $form3->submitbutton = camila_get_translation('camila.worktable.delete'); $form3->drawrules = false; new form_hidden($form3, 'custom', $id); new form_hidden($form3, 'worktable_op', $operation); if ($returl != '') { new form_hidden($form3, 'returl', $returl); } if ($form3->process()) { $result = $_CAMILA['db']->Execute('select tablename,scriptname from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $table = $result->fields['tablename']; $script = $result->fields['scriptname']; $result = $_CAMILA['db']->Execute('delete from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $result = $_CAMILA['db']->Execute('delete from ' . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ')'); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $stmt = sprintf($_CAMILA['db']->_dropSeqSQL, $table); $result = $_CAMILA['db']->Execute($stmt); //if ($result === false) // camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); $record = array(); $record['visible'] = 'no'; $record['active'] = 'no'; $updateSQL = $_CAMILA['db']->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $_CAMILA['db']->qstr($script)); //if (!$updateSQL) { // camila_information_text(camila_get_translation('camila.worktable.db.error')); // $success3 = false; //} } else { camila_information_text(camila_get_translation('camila.worktable.delete.areyousure')); $result = $_CAMILA['db']->Execute('select short_title from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $name = $result->fields['short_title']; $myText = new CHAW_text($name, HAW_TEXTFORMAT_BOLD); $myText->set_br(2); $_CAMILA['page']->add_text($myText); $form3->draw(); $success = false; } } elseif ($operation == 'rebuild') { require_once CAMILA_DIR . 'datagrid/form.class.php'; require_once CAMILA_DIR . 'datagrid/elements/form/hidden.php'; $form3 = new phpform('camila', 'cf_worktable_admin.php'); $form3->submitbutton = camila_get_translation('camila.worktable.delete'); $form3->drawrules = false; new form_hidden($form3, 'custom', $id); new form_hidden($form3, 'worktable_op', $operation); if ($returl != '') { new form_hidden($form3, 'returl', $returl); } if ($form3->process()) { $this->configure_table($id, true, $returl); } else { camila_information_text(camila_get_translation('camila.worktable.rebuild.areyousure')); $result = $_CAMILA['db']->Execute('select short_title from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $name = $result->fields['short_title']; $myText = new CHAW_text($name, HAW_TEXTFORMAT_BOLD); $myText->set_br(2); $_CAMILA['page']->add_text($myText); $form3->draw(); $success = false; } } elseif ($operation == 'showtemplatefields') { $stmt = "select wt_id,name,name_abbrev,col_name as colname_form, col_name as colname_table from " . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ') order by name'; require_once CAMILA_DIR . 'datagrid/report.class.php'; $report = new report($stmt); $report->mapping = camila_get_translation('camila.worktable.mapping.worktable'); $report->process(); $report->fields['colname_form']->onprint = camila_configurator_template_fieldname_form; $report->fields['colname_form']->dummy = true; $report->fields['colname_form']->orderable = false; $report->fields['colname_table']->onprint = camila_configurator_template_fieldname_table; $report->fields['colname_table']->dummy = true; $report->fields['colname_table']->orderable = false; $report->fields['wt_id']->print = false; $report->fields['name']->orderable = false; $report->fields['name_abbrev']->orderable = false; $report->drawfilterbox = false; $report->drawnavigationbox = false; $report->draw(); } if ($success) { $myText = new CHAW_text(camila_get_translation('camila.worktable.db.importok')); $_CAMILA['page']->add_text($myText); } }
function create_page() { global $_CAMILA; if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download' || $_REQUEST['camila_export_action'] == 'sendmail') { $fname = tempnam(CAMILA_TMP_DIR, 'export.xls'); } else { if (!$this->camila_export_file_exists || $_REQUEST['camila_export_overwrite'] == 'y') { $fname = $this->camila_export_get_dir() . $this->camila_export_filename(); } else { $fname = tempnam(CAMILA_TMP_DIR, 'export.xls'); } } $workbook =& new Spreadsheet_Excel_Writer_Workbook($fname); $workbook->setTempDir(CAMILA_TMP_DIR); $workbook->setVersion(8); $dWorksheet =& $workbook->addworksheet($_CAMILA['page_short_title'] . ' - ' . camila_get_translation('camila.worktable.worksheet.data')); $i = 0; $m = camila_get_translation('camila.dateformat.monthpos'); $d = camila_get_translation('camila.dateformat.daypos'); $y = camila_get_translation('camila.dateformat.yearpos'); $date_format =& $workbook->addFormat(); $fmt = str_replace(array('d', 'm', 'y'), array('dd', 'mm', 'yyyy'), strtolower($_CAMILA['date_format'])); $date_format->setNumFormat($fmt); $dataFound = false; while (isset($this->element[$i])) { $page_element = $this->element[$i]; switch ($page_element->get_elementtype()) { case HAW_TABLE: $table = $this->element[$i]; $row = $table->row[0]; for ($b = 0; $b < $row->number_of_columns; $b++) { $column = $row->column[$b]; if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) { $text = $column->get_text(); } if (is_object($column) && $column->get_elementtype() == HAW_LINK) { $text = $column->get_label(); } $dWorksheet->writeString($a, $b, isUTF8($text) ? utf8_decode($text) : $text); } if (!$_CAMILA['page']->camila_worktable || $_CAMILA['page']->camila_worktable && ($_REQUEST['camila_worktable_export'] == 'all' || $_REQUEST['camila_worktable_export'] == 'dataonly')) { for ($a = 1; $a < $table->number_of_rows; $a++) { $row = $table->row[$a]; $dataFound = true; for ($b = 0; $b < $row->number_of_columns; $b++) { $column = $row->column[$b]; if (is_object($column) && $column->get_elementtype() == HAW_LINK) { $text = $column->get_label(); $url = $column->get_url(); $dWorksheet->writeUrl($a, $b, $url, $text); } else { if (is_object($column) && $column->get_elementtype() == HAW_PLAINTEXT) { $text = $column->get_text(); } switch ($column->metatype) { case 'I': case 'N': if ($text != '') { $dWorksheet->writeNumber($a, $b, intval($text)); } break; case 'D': if ($text != '') { $dWorksheet->writeNumber($a, $b, $this->xl_date_list(intval(substr($text, $y, 4)), intval(substr($text, $m, 2)), intval(substr($text, $d, 2))), $date_format); } break; default: $dWorksheet->writeString($a, $b, isUTF8($text) ? utf8_decode($text) : $text); } } } } } break; } $i++; } if ($_CAMILA['page']->camila_worktable && ($_REQUEST['camila_worktable_export'] == 'all' || $_REQUEST['camila_worktable_export'] == 'confonly')) { $worksheet =& $workbook->addworksheet($_CAMILA['page_short_title'] . ' - ' . camila_get_translation('camila.worktable.worksheet.conf')); $aLeft =& $workbook->addformat(); $aLeft->setAlign('left'); $opt = array(); $opt[] = camila_get_translation('camila.worktable.field.sequence'); $opt[] = camila_get_translation('camila.worktable.field.name.abbrev'); $opt[] = camila_get_translation('camila.worktable.field.type'); $opt[] = camila_get_translation('camila.worktable.field.listofvalues'); $opt[] = camila_get_translation('camila.worktable.field.maxlength'); $opt[] = camila_get_translation('camila.worktable.field.required'); $opt[] = camila_get_translation('camila.worktable.field.defaultval'); $opt[] = camila_get_translation('camila.worktable.field.readonly'); $opt[] = camila_get_translation('camila.worktable.field.visible'); $opt[] = camila_get_translation('camila.worktable.field.force'); $opt[] = camila_get_translation('camila.worktable.field.unique'); $opt[] = camila_get_translation('camila.worktable.field.options'); $opt[] = camila_get_translation('camila.worktable.field.autosuggestwtname'); $opt[] = camila_get_translation('camila.worktable.field.autosuggestwtcolname'); $opt[] = ''; $opt[] = camila_get_translation('camila.worktable.configuration'); $opt[] = camila_get_translation('camila.worktable.name'); $opt[] = camila_get_translation('camila.worktable.desc'); $opt[] = camila_get_translation('camila.worktable.order.by'); $opt[] = camila_get_translation('camila.worktable.order.dir'); $opt[] = camila_get_translation('camila.worktable.canupdate'); $opt[] = camila_get_translation('camila.worktable.caninsert'); $opt[] = camila_get_translation('camila.worktable.candelete'); $opt[] = camila_get_translation('camila.worktable.category'); foreach ($opt as $key => $value) { $text = $opt[$key]; $worksheet->writeString(intval($key) + 1, $o, isUTF8($text) ? utf8_decode($text) : $text); } $worksheet->setColumn(0, 0, 30); $id = substr($_SERVER['PHP_SELF'], 12, -4); $result = $_CAMILA['db']->Execute('select * from ' . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ') order by sequence'); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $yesNoArr = camila_get_translation_array('camila.worktable.options.noyes'); $fieldTypeArr = camila_get_translation_array('camila.worktable.options.fieldtype'); $forceArr = camila_get_translation_array('camila.worktable.options.force'); $orderDirArr = camila_get_translation_array('camila.worktable.options.order.dir'); $colArray = array(); $count = 1; while (!$result->EOF) { $colArray[$result->fields['col_name']] = $result->fields['name']; $text = $result->fields['name']; $worksheet->writeString(0, $count, isUTF8($text) ? utf8_decode($text) : $text); if ($_REQUEST['camila_worktable_export'] == 'all' && !$dataFound) { $dWorksheet->writeString(0, $count - 1, isUTF8($text) ? utf8_decode($text) : $text); } $text = $result->fields['sequence']; $worksheet->writeNumber(1, $count, isUTF8($text) ? utf8_decode($text) : $text, $aLeft); $text = $result->fields['name_abbrev']; $worksheet->writeString(2, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $fieldTypeArr[$result->fields['type']]; $worksheet->writeString(3, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['listbox_options']; $worksheet->writeString(4, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['maxlength']; $worksheet->writeNumber(5, $count, isUTF8($text) ? utf8_decode($text) : $text, $aLeft); $text = $yesNoArr[$result->fields['required']]; $worksheet->writeString(6, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['default_value']; $worksheet->writeString(7, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $text = $yesNoArr[$result->fields['readonly']]; $worksheet->writeString(8, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $text = $yesNoArr[$result->fields['visible']]; $worksheet->writeString(9, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $forceArr[$result->fields['force_case']]; $worksheet->writeString(10, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $yesNoArr[$result->fields['must_be_unique']]; $worksheet->writeString(11, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['field_options']; $worksheet->writeString(12, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['autosuggest_wt_name']; $worksheet->writeString(13, $count, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['autosuggest_wt_colname']; $worksheet->writeString(14, $count, isUTF8($text) ? utf8_decode($text) : $text); $count++; $result->MoveNext(); } $worksheet->setColumn(1, $count - 1, 15); $result = $_CAMILA['db']->Execute('select * from ' . CAMILA_TABLE_WORKT . ' where id=' . $_CAMILA['db']->qstr($id)); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $text = $result->fields['short_title']; $worksheet->writeString(17, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['full_title']; $worksheet->writeString(18, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $colArray[$result->fields['order_field']]; $worksheet->writeString(19, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $orderDirArr[$result->fields['order_dir']]; $worksheet->writeString(20, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $yesNoArr[$result->fields['canupdate']]; $worksheet->writeString(21, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $yesNoArr[$result->fields['caninsert']]; $worksheet->writeString(22, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $yesNoArr[$result->fields['candelete']]; $worksheet->writeString(23, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = $result->fields['category']; $worksheet->writeString(24, 1, isUTF8($text) ? utf8_decode($text) : $text); $text = camila_get_translation('camila.worktable.bookmarks'); $worksheet->writeString(16, 2, isUTF8($text) ? utf8_decode($text) : $text); $query = 'select base_url,url,title from ' . CAMILA_APPLICATION_PREFIX . 'camila_bookmarks where base_url=' . $_CAMILA['db']->qstr('cf_worktable' . $id . '.php') . ' order by sequence'; $result = $_CAMILA['db']->Execute($query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $i = 0; while (!$result->EOF) { $i++; $text = $result->fields['title']; $worksheet->writeString(16 + $i, 2, isUTF8($text) ? utf8_decode($text) : $text); $url = parse_url($result->fields['url'], PHP_URL_QUERY); $qArr = $this->parse_query_string($url); $text = $qArr['filter']; $worksheet->writeString(16 + $i, 3, isUTF8($text) ? utf8_decode($text) : $text); $result->MoveNext(); } } if ($_CAMILA['page']->camila_worktable && !$dataFound && $_REQUEST['camila_worktable_export'] == 'dataonly') { $id = substr($_SERVER['PHP_SELF'], 12, -4); $result = $_CAMILA['db']->Execute('select * from ' . CAMILA_TABLE_WORKC . ' where (wt_id=' . $_CAMILA['db']->qstr($id) . ' and is_deleted<>' . $_CAMILA['db']->qstr('y') . ') order by sequence'); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $count = 1; while (!$result->EOF) { $text = $result->fields['name']; $dWorksheet->writeString(0, $count - 1, isUTF8($text) ? utf8_decode($text) : $text); $count++; $result->MoveNext(); } } $workbook->close(); if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download') { header("Content-Type: application/x-msexcel; name=\"" . $this->camila_export_safe_filename() . '.' . $this->camila_export_get_ext() . "\""); header("Content-Disposition: attachment; filename=\"" . $this->camila_export_safe_filename() . '.' . $this->camila_export_get_ext() . "\""); } $fh = fopen($fname, "rb"); if ($_REQUEST['camila_export_action'] == '' || $_REQUEST['camila_export_action'] == 'download') { fpassthru($fh); unlink($fname); } if ($_REQUEST['camila_export_action'] == 'sendmail') { global $_CAMILA; require_once CAMILA_LIB_DIR . 'phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); if (CAMILA_MAIL_IS_SMTP) { $mail->IsSMTP(); } $mail->Host = CAMILA_MAIL_HOST; $mail->SMTPAuth = CAMILA_MAIL_SMTP_AUTH; $mail->From = CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_FROM; $mail->FromName = CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_FROM_NAME; $mail->AddAttachment($fname, 'file.xls'); $mail->AddAddress(CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_TO); //$mail->AddCC(CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_CC, CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_CC); $mail->IsHTML(false); $mail->Subject = CAMILA_WORKTABLE_CONFIRM_VIA_MAIL_SUBJECT; $text = camila_get_translation('camila.worktable.confirm') . " - " . camila_get_translation('camila.login.username') . ': ' . $_CAMILA['user_name']; $mail->Body = $text; $mail->AltBody = $text; $mail->Send(); unlink($fname); } }
function process() { if (isset($_REQUEST['camila_download']) && $_REQUEST['camila_download'] != '') { $this->_download($_REQUEST['camila_download']); exit; } if (isset($_REQUEST['camila_update']) || isset($_REQUEST['camila_delete']) || isset($_REQUEST['camila_move'])) { if (isset($_REQUEST['camila_update'])) { $this->keyvalue = unserialize(stripslashes($_REQUEST['camila_update'])); $check = camila_token($_REQUEST['camila_update']); } elseif (isset($_REQUEST['camila_move'])) { $this->keyvalue = unserialize(stripslashes($_REQUEST['camila_move'])); $check = camila_token($_REQUEST['camila_move']); } else { $this->keyvalue = unserialize(stripslashes($_REQUEST['camila_delete'])); $check = camila_token($_REQUEST['camila_delete']); } if ($check != $_REQUEST['camila_token'] && $_REQUEST['camila_update'] != 'new' && $_REQUEST['camila_update'] != 'newdir') { camila_error_page(camila_get_translation('camila.pageforbidden')); } } if (!$this->drawnavigationbox) { $this->rows = -1; $this->page = 1; } if (isset($_REQUEST['camila_pagnum'])) { $this->page = intval($_REQUEST['camila_pagnum']); if ($this->page < 0) { $this->rows = -1; $this->page = 1; } $this->offset = ($this->page - 1) * $this->rows; } //$this->numfields = 5; $this->fields['icon'] = new report_icon('icon', ''); $this->fields['icon']->report = $this; $this->fields['name'] = new report_string('name', camila_get_translation('camila.fm.nameheader')); $this->fields['name']->report = $this; $this->fields['size'] = new report_byte('size', camila_get_translation('camila.fm.sizeheader')); $this->fields['size']->report = $this; $this->fields['type'] = new report_string('type', camila_get_translation('camila.fm.typeheader')); $this->fields['type']->report = $this; $this->fields['mod'] = new report_timestamp('mod', camila_get_translation('camila.fm.lastmodifyheader')); $this->fields['mod']->report = $this; if ($this->canupdate) { $this->fields['camila_update'] = new report_string('camila_update', ''); $this->fields['camila_update']->report = $this; } if ($this->canmove) { $this->fields['camila_move'] = new report_string('camila_move', ''); $this->fields['camila_move']->report = $this; } if ($this->candelete) { $this->fields['camila_delete'] = new report_string('camila_delete', ''); $this->fields['camila_delete']->report = $this; } $myArr = array(); if (isset($_REQUEST['camila_dir'])) { $this->is_root_dir = false; } if ($this->extfsenabled) { if (isset($_REQUEST['camila_dir']) && $_REQUEST['camila_dir'] != '') { if ($_REQUEST['camila_up'] == 'yes') { $ancnode = $this->_tree_get_ancestor_node($this->_tree_get_node_by_id($_REQUEST['camila_dir'])); if ($ancnode['usergroup'] == '') { $this->is_root_dir = true; $myArr = $this->_tree_get_file_subtree($this->_tree_get_group_root_node($this->usergroup), array('name'), $this->usergroup); } else { $this->dir_id = $ancnode['id']; $myArr = $this->_tree_get_file_subtree($ancnode, array('name'), $this->usergroup); } } else { $this->dir_id = $_REQUEST['camila_dir']; $myArr = $this->_tree_get_file_subtree($this->_tree_get_node_by_id($_REQUEST['camila_dir']), array('name'), $this->usergroup); } } else { $myArr = $this->_tree_get_file_subtree($this->_tree_get_group_root_node($this->usergroup), array('name'), $this->usergroup); } } else { $count = 0; if (is_dir($this->dir)) { if ($dh = opendir($this->dir)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $myArr[$count] = $file; } $count++; } closedir($dh); } } } $tot_file_size = 0; $num_items = 0; foreach (array_keys($myArr) as $k) { $new_item = $myArr[$k]; if ($new_item != '..') { //$abs_new_item = get_abs_item($usergroup, $new_item); $abs_new_item = $this->dir . '/' . $new_item; $new_file_size = filesize($abs_new_item); $tot_file_size += $new_file_size; $num_items++; if (!@file_exists($abs_new_item)) { if ($_REQUEST['f0'] == 'mod') { $dir_list[$new_item] = 0; //@filemtime($abs_new_item); } else { // order == "size", "type" or "name" $dir_list[$new_item] = $new_item; } $this->filetype_list[$new_item] = $k; } else { if ($_REQUEST['f0'] == 'size') { $file_list[$new_item] = $new_file_size; } elseif ($_REQUEST['f0'] == 'mod') { $file_list[$new_item] = @filemtime($abs_new_item); } elseif ($_REQUEST['f0'] == 'type') { $file_list[$new_item] = $this->_getmimetype($abs_new_item); } else { // order == 'name' $file_list[$new_item] = $new_item; } } } } if ($this->extfsenabled && isset($_REQUEST['camila_dir']) && $_REQUEST['camila_dir'] != 'up') { $this->totalrows = $num_items + 1; } else { $this->totalrows = $num_items; } $this->totalfilesize = $tot_file_size; $this->totalfiles = $num_items; if (is_array($dir_list) && $this->extfsenabled) { if ($_REQUEST['f0'] == 'mod') { if ($this->direction == 'asc') { arsort($dir_list); } else { asort($dir_list); } } else { if ($this->direction == 'asc') { ksort($dir_list); } else { krsort($dir_list); } } } if (is_array($file_list)) { if ($_REQUEST['f0'] == 'mod') { if ($this->direction == 'asc') { arsort($file_list); } else { asort($file_list); } } elseif ($_REQUEST['f0'] == 'size' || $_REQUEST['f0'] == 'type') { if ($this->direction == 'asc') { asort($file_list); } else { arsort($file_list); } } else { if ($this->direction == 'asc') { ksort($file_list); } else { krsort($file_list); } } } if ($this->extfsenabled) { if (is_array($file_list) && is_array($dir_list)) { $this->file_list = array_slice($dir_list + $file_list, ($this->page - 1) * $this->rows, $this->rows == -1 ? null : $this->rows); } elseif (is_array($dir_list)) { $this->file_list = array_slice($dir_list, ($this->page - 1) * $this->rows, $this->rows == -1 ? null : $this->rows); } else { $this->file_list = array_slice($file_list, ($this->page - 1) * $this->rows, $this->rows == -1 ? null : $this->rows); } } else { $this->file_list = array_slice($file_list, ($this->page - 1) * $this->rows, $this->rows == -1 ? null : $this->rows); } if ($this->extfsenabled && !$this->is_root_dir) { if (is_array($this->file_list)) { $this->file_list = array('..' => $_REQUEST['camila_dir']) + $this->file_list; } else { $this->file_list = array('..' => $_REQUEST['camila_dir']); } } }
if ($result['result'] == 2) $text = new HAW_text($file . ' - inserted: ' . $result['processed']); else $text = new HAW_text($file . ' - error: ' . $result['error'] . ', failed: ' . $result['failed'] . ', inserted: ' . $result['processed'], HAW_TEXTFORMAT_BOLD); $page->add_text($text); } } closedir($dh); }*/ foreach ($files as $file) { if ($file != '.' && $file != '..' && substr($file, -3) == 'xls') { $result = XLS_import2(CAMILA_TABLES_DIR . '/xls/' . $_REQUEST['lang'] . '/' . $file, CAMILA_APPLICATION_PREFIX . substr($file, 0, -4), $db); if ($result['result'] == 2) { $text = new HAW_text($file . ' - inserted: ' . $result['processed']); } else { $text = new HAW_text($file . ' - error: ' . $result['error'] . ', failed: ' . $result['failed'] . ', inserted: ' . $result['processed'], HAW_TEXTFORMAT_BOLD); } $page->add_text($text); } } $res = $db->Execute('update ' . CAMILA_TABLE_PLANG . ' set full_title=short_title where page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang'])); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } } camila_delete_files(CAMILA_TMP_DIR); $myLink = new HAW_link($_REQUEST['msg'], 'index.php'); $page->add_link($myLink); $page->create_page();
function _tree_get_group_root_node($usergroup) { $noderes['l'] = 0; $noderes['r'] = 0; global $_CAMILA; $_CAMILA['db']->SetFetchMode(ADODB_FETCH_ASSOC); $res = $_CAMILA['db']->Execute('SELECT * FROM ' . CAMILA_TABLE_FILES . ' WHERE name = ? AND usergroup = ?', array($usergroup, '')); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } else { if (!$res->EOF) { $row = $res->fields; $noderes['id'] = $row['id']; $noderes['l'] = $row['lft']; $noderes['r'] = $row['rgt']; } } return $noderes; }
function process() { if (isset($_POST[$this->key])) { $this->value = $_POST[$this->key]; if ($_POST["noproc_{$this->field}"] == 1) { $this->form->noproc = true; $stmt = "select {$this->fields_from} from {$this->table} where {$this->lbkey}='" . addslashes($this->value) . "'"; global $_CAMILA; $_CAMILA['db']->SetFetchMode(ADODB_FETCH_NUM); $result = $_CAMILA['db']->Execute($query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $tok = strtok($this->fields_to, ','); $i = 0; while ($tok) { $this->form->fields[$tok]->value = $result->fields[$i++]; $this->form->fields[$tok]->process = false; $tok = strtok(','); } } } }
function XLS_import2($file, $table, $db) { $filename = basename($file); $sequence = intval(substr($filename, 0, strpos($filename, '_'))); $res = $db->Execute('select id from ' . CAMILA_TABLE_WORKT . ' where filename=' . $db->qstr($filename)); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $id = $res->fields['id']; $result = array(); $configurator = new configurator(); $configurator->filename = $file; $configurator->sheetnum = 0; $configurator->interactive = false; $db->SetFetchMode(ADODB_FETCH_ASSOC); $configurator->db = $db; $configurator->configure_table($id, false); $record = array(); $res = $db->Execute('select * from ' . CAMILA_TABLE_WORKT . ' where id=' . $db->qstr($id)); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $record['short_title'] = $res->fields['short_title']; $record['full_title'] = $res->fields['full_title']; $record['label_order'] = $sequence; $scriptname = $res->fields['scriptname']; $category = $res->fields['category']; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PLANG, $record, 'UPDATE', 'page_url=' . $db->qstr($scriptname) . ' and lang=' . $db->qstr($_REQUEST['lang'])); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } if (trim($category) != '') { $res = $db->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where short_title=' . $db->qstr($category) . ' AND page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang'])); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $cat_url = '-'; if ($res->RecordCount() == 0) { $res = $db->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where full_title<>' . $db->qstr('-') . ' AND page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang'])); if ($res === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg()); } $cat_url = $res->fields['page_url']; $record = array(); $record['label_order'] = $sequence; $record['short_title'] = $category; $record['full_title'] = '-'; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PLANG, $record, 'UPDATE', 'page_url=' . $db->qstr($cat_url) . ' and lang=' . $db->qstr($_REQUEST['lang'])); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } } else { $cat_url = $res->fields['page_url']; } $record = array(); $record['parent'] = $cat_url; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $db->qstr($scriptname)); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } $record = array(); $record['visible'] = 'yes'; $updateSQL = $db->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $db->qstr($cat_url)); if (!$updateSQL) { camila_information_text(camila_get_translation('camila.worktable.db.error')); } } $result['result'] = 2; //success $result['processed'] = 1; $result['failed'] = 0; return $result; }
<?php /* This File is part of Camila PHP Framework Copyright (C) 2006-2009 Umberto Bresciani Camila PHP Framework 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. Camila PHP Framework 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 Camila PHP Framework; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require '../camila/header.php'; $query = 'SELECT url,short_title FROM ' . CAMILA_TABLE_PAGES . ', ' . CAMILA_TABLE_PLANG . ' WHERE (' . CAMILA_TABLE_PAGES . '.url = ' . CAMILA_TABLE_PLANG . '.page_url) and level>=' . $_CAMILA[user_level] . ' AND visible=' . $_CAMILA['db']->qstr('yes') . ' AND active=' . $_CAMILA['db']->qstr('yes') . ' and parent=' . $_CAMILA['db']->qstr($_CAMILA['page_url']) . " and lang=" . $_CAMILA['db']->qstr($_CAMILA['lang']) . " ORDER by label_order"; $result = $_CAMILA['db']->Execute($query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } while (!$result->EOF) { $link = new CHAW_link($result->fields['short_title'], $result->fields['url']); $_CAMILA['page']->add_link($link); $result->MoveNext(); } require '../camila/footer.php';
function camila_worktable_get_table_id($name) { global $_CAMILA; $result = $_CAMILA['db']->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where short_title=' . $_CAMILA['db']->qstr($name) . ' AND page_url NOT LIKE ' . $_CAMILA['db']->qstr('cf_app.php?cat%') . ' and lang=' . $_CAMILA['db']->qstr($_CAMILA['lang'])); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } return $result->fields['page_url']; }
function validate() { if (!$this->updatable || strpos(strtolower($this->validation), 'ignore') !== false) { return true; } if (strpos(strtolower($this->validation), 'uppercase') !== false) { $this->value = $this->strtoupper_utf8($this->value); } if (strpos(strtolower($this->validation), 'lowercase') !== false) { $this->value = $this->strtolower_utf8($this->value); } if (strpos(strtolower($this->validation), 'ucwords') !== false) { $this->value = ucwords($this->value); } if (strpos(strtolower($this->validation), 'ucwordsforce') !== false) { $this->value = ucwords(strtolower($this->value)); } if (strpos(strtolower($this->validation), 'ucfirst') !== false) { $this->value = ucfirst($this->value); } if (strpos(strtolower($this->validation), 'ucfirstforce') !== false) { $this->value = ucfirst(strtolower($this->value)); } if ($this->required && strpos(strtolower($this->validation), 'fit') !== false) { $this->form->validator->length($this->field, '=', $this->maxlength); } if ($this->required) { $this->form->validator->filledIn($this->field); } if (strpos(strtolower($this->validation), 'unique') !== false) { if ($this->value != '') { global $_CAMILA; $sess = $_REQUEST['camila_update']; if ($sess == '') { $sess = $_REQUEST[$this->form->table . '_sess_key']; } $stmt = ''; if ($sess != 'new') { $ar = unserialize($sess); reset($this->form->keys); $i = 0; while ($akey = each($this->form->keys)) { $stmt .= ' AND '; $k = trim($this->form->keys[$i]); $v = $ar['camilakey_' . $k]; $stmt .= $k . ' <> ' . $_CAMILA['db']->Quote($v); $i++; } } $query = 'select * from ' . $this->form->table . ' where ' . $this->field . '=' . $_CAMILA['db']->Quote($this->value) . $stmt; $result = $_CAMILA['db']->Execute($query); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } if ($result->RecordCount() > 0) { $this->form->validator->setError($this->field, 907); } } } }
function process() { if ($this->mapping != '') { $this->selform->mapping = $this->mappingseparator . $this->mapping . $this->mappingseparator; } if ($this->selform != 0) { $selformprocessed = $this->selform->process(); } elseif (isset($_REQUEST['camila_update']) || isset($_REQUEST['camila_delete'])) { if (isset($_REQUEST['camila_update'])) { $this->keyvalue = unserialize(stripslashes($_REQUEST['camila_update'])); $check = camila_token($_REQUEST['camila_update']); } else { $this->keyvalue = unserialize(stripslashes($_REQUEST['camila_delete'])); $check = camila_token($_REQUEST['camila_delete']); } if ($check != $_REQUEST['camila_token'] && $_REQUEST['camila_update'] != 'new') { camila_error_page(camila_get_translation(camila . pageforbidden)); } } //if (!($this->selform == 0 || isset($_GET['camila_update']) )) // return false; if (!parent::process() && !$this->noproc) { // if this form didn't processed, see if select processed // first check if there is a select form $selected = false; if ($this->selform != 0) { // See if any key was selected by selform $selected = $selformprocessed; if ($selected && !$this->selform->value) { $selected = false; } if ($selected) { $this->keyvalue = $this->selform->value; } } // If there was no selform, or selform selected nothing // try to see if the user has set keyvalue // how user can set keyvalue? using $form->keyvalue = "xxx,xxx" if (!$selected && count($this->keyvalue) > 0) { $selected = true; } // Something filled keyvalue, try loading the values into phpdbform if ($selected) { if ($this->select_data()) { // found data! $this->mode = 'update'; } else { // some error occurred, clear phpdbform and set insertmode $this->clear(); $this->mode = 'insert'; } // nothing was selected, go to insertmode if (isset($_GET['camila_delete'])) { $this->mode = 'delete'; } } else { $this->mode = 'insert'; } // if there is a select form, fill it with data if ($this->selform != 0) { $this->selform->select_data(); } return; } // the form processed anything, let's work // first get key and value from session if (isset($_REQUEST[$this->table . '_sess_mode'])) { $this->mode = $_REQUEST[$this->table . '_sess_mode']; // can be a hack... if ($this->mode != 'insert' && $this->mode != 'update' && $this->mode != 'delete') { die('Invalid mode:' . $this->mode); } $temp = $_REQUEST[$this->table . '_sess_key']; //if (get_magic_quotes_gpc()) // $temp = stripslashes($temp); $this->keyvalue = unserialize($temp); } if (!$this->noproc) { // if delete button was pressed, goto deletemode if (isset($_REQUEST['camila_delete'])) { $this->mode = 'delete'; } if ($this->mode == 'update') { if ($this->selform != 0) { $this->selform->value = $this->keyvalue; } // update data if (isset($this->onupdate)) { if (call_user_func($this->onupdate, &$this)) { $this->update_data(); } } else { $this->update_data(); } $this->_data_updated = true; reset($this->fields); while ($field = each($this->fields)) { if (substr(trim($field[1]->field), 0, strlen('camilafield_')) == 'camilafield_') { $this->fields[$field[1]->field]->process(); //$req[$this->fields[$field[1]->field]->field] = $this->fields[$field[1]->field]->value; } } } elseif ($this->mode == 'insert') { // insert data if (isset($this->oninsert)) { if (call_user_func($this->oninsert, &$this)) { $this->insert_data(); $this->_data_inserted = true; } } else { $this->insert_data(); $this->_data_inserted = true; } reset($this->fields); while ($field = each($this->fields)) { if (substr(trim($field[1]->field), 0, strlen('camilafield_')) == 'camilafield_') { $this->fields[$field[1]->field]->process(); //// //$req[$this->fields[$field[1]->field]->field] = $this->fields[$field[1]->field]->value; } } // clear values $this->clear(); } elseif ($this->mode == 'delete') { if (isset($this->ondelete)) { if (call_user_func($this->ondelete, &$this)) { $this->delete_data(); } } else { $this->delete_data(); } $this->clear(); $this->keyvalue = ''; $this->mode = 'insert'; } } else { //$this->draw_errors(); if ($this->mode == 'update') { if ($this->selform != 0) { $this->selform->value = $this->keyvalue; } // update data } } // if there is a select form, fill it with data if ($this->selform != 0) { $this->selform->select_data(); } }