function camila_formdeletelink(&$field, &$row, $fields) { global $_CAMILA; $arr = array(); foreach ($fields as $key) { if (substr($key->field, 0, strlen('camilakey_del_')) == 'camilakey_del_') { if (strpos($key->field, '__') !== false) { $kf .= 'camilakey_' . substr($key->field, strpos($key->field, '__') + 2); } else { $kf .= 'camilakey_' . substr($key->field, 14); } $arr[$kf] = $key->value; } } if ($_SERVER['QUERY_STRING'] != '') { $url = basename($_SERVER['PHP_SELF']) . "?" . $_SERVER['QUERY_STRING'] . "&camila_delete=" . serialize($arr) . '&camila_token=' . camila_token(serialize($arr)) . '&camila_returl=' . urlencode($_CAMILA['returl']); } else { $url = basename($_SERVER['PHP_SELF']) . "?camila_delete=" . serialize($arr) . '&camila_returl=' . urlencode($_CAMILA['returl']) . '&camila_token=' . camila_token(serialize($arr)); } $myLink = new CHAW_link(camila_get_translation('camila.delete'), $url); $myLink->set_br(0); $row->add_column($myLink); }
function _new() { if ($this->extfsenabled) { $this->_tree_checkup(); } require_once CAMILA_DIR . 'datagrid/form.class.php'; require_once CAMILA_DIR . 'datagrid/elements/form/hidden.php'; require_once CAMILA_DIR . 'datagrid/elements/form/textbox.php'; require_once CAMILA_DIR . 'datagrid/elements/form/static_listbox.php'; require_once CAMILA_DIR . 'datagrid/elements/form/fm_dir_listbox.php'; $form = new phpform('camila'); $form->submitbutton = camila_get_translation('camila.save'); $form->drawrules = false; new form_hidden($form, 'update', 'new'); global $_CAMILA; $pos = strrpos($_CAMILA['page_url'], '?'); if ($pos !== false) { new form_hidden($form, substr($_CAMILA['page_url'], $pos + 1)); } new form_textbox($form, 'name', 'Nome file', true, 30); $types; foreach ($this->editabletypes as $k => $v) { $types .= $v . ';' . '.' . $v . ' - ' . camila_get_translation('camila.mimetype.' . $v) . ','; } new form_static_listbox($form, 'type', 'Tipo', $types, true); if ($this->extfsenabled) { new form_fm_dir_listbox($form, 'dir', camila_get_translation('camila.fm.intofolder'), $this->usergroup, true); } $fp = $form->process(); if ($fp) { $filename = $form->fields['name']->value . '.' . $form->fields['type']->value; if ($this->extfsenabled) { $sfile = $filename . camila_hash(CAMILA_FM_PREFIX); $arr = array('name' => $sfile); $item = $this->stmt . '/' . $this->usergroup . '/' . $sfile; $f = fopen($item, 'w'); $this->_addfile($this->usergroup, $form->fields['dir']->value, $filename, $sfile); } else { $arr = array('name' => $filename); $item = $this->stmt . '/' . $filename; $f = fopen($item, 'w'); } camila_information_text(camila_get_translation('camila.fm.filecreated')); $myLink = new CHAW_link(camila_get_translation('camila.edit') . ' ' . $filename, basename($_SERVER['PHP_SELF']) . $_CAMILA['returl'] . '&camila_update=' . serialize($arr) . '&camila_token=' . camila_token(serialize($arr))); $myLink->set_br(2); $_CAMILA['page']->add_link($myLink); } else { $form->draw(); } return $fp; }
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 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(); } }