예제 #1
0
   Copyright (C) 2006-2011 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_once CAMILA_DIR . "datagrid/db_form.class.php";
require_once CAMILA_DIR . '/datagrid/elements/form/static_listbox.php';
require_once CAMILA_DIR . '/datagrid/elements/form/textbox.php';
require_once CAMILA_DIR . '/datagrid/elements/form/hidden.php';
require_once CAMILA_DIR . '/datagrid/elements/form/textarea.php';
require_once CAMILA_DIR . '/datagrid/elements/form/integer.php';
$form = new dbform(CAMILA_APPLICATION_PREFIX . 'camila_bookmarks', 'id', 'id,sequence,base_url,title,url', 'sequence', 'asc', 'lang = ' . $_CAMILA['db']->qstr($_CAMILA['lang']), true, true, true, false, true);
$form->mapping = camila_get_translation('camila.mapping.admin.users');
new form_hidden($form, 'id', $_CAMILA['db']->GenID(CAMILA_APPLICATION_PREFIX . 'bookmarkseq', 10000) . camila_hash(10));
new form_integer($form, 'sequence', camila_get_translation('camila.login.username'), true);
new form_textbox($form, 'base_url', camila_get_translation('camila.login.username'), true, 50, 50);
new form_textbox($form, 'title', camila_get_translation('camila.login.username'), true, 50, 50);
new form_textarea($form, 'url', camila_get_translation('camila.login.surname'), true);
new form_hidden($form, 'lang', $_CAMILA['lang']);
$form->process();
$form->draw();
예제 #2
0
$form = new phpform('camila_bookmark');
$form->submitbutton = camila_get_translation('camila.save');
$form->drawrules = false;
$form->preservecontext = true;
global $_CAMILA;
new form_hidden($form, 'base_url', basename($_SERVER['PHP_SELF']));
new form_textbox($form, 'title', 'Titolo', true, 50, 50);
$export_format = 'camila_bookmark';
//$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
//$url = ereg_replace("&" . $export_format, '', $url);
//$url = ereg_replace("\?" . $export_format, '', $url);
$url = $_SERVER['PHP_SELF'] . '?filter=' . $_REQUEST['camila_bookmark'];
new form_hidden($form, 'url', $url);
if ($form->process()) {
    $record = array();
    $record['id'] = $_CAMILA['db']->GenID(CAMILA_APPLICATION_PREFIX . 'bookmarkseq', 10000) . camila_hash(10);
    $record['lang'] = $_CAMILA['lang'];
    $record['url'] = $form->fields['url']->value;
    $record['base_url'] = $form->fields['base_url']->value;
    $record['title'] = $form->fields['title']->value;
    $insertSQL = $_CAMILA['db']->AutoExecute(CAMILA_APPLICATION_PREFIX . 'camila_bookmarks', $record, 'INSERT');
    if (!$insertSQL) {
        camila_information_text(camila_get_translation('camila.worktable.db.error'));
        $success = false;
    }
    $url = $form->fields['url']->value;
} else {
    $form->draw();
}
$myLink = new CHAW_link(camila_get_translation('camila.back.page'), $url);
$myImage = new HAW_image(CAMILA_IMG_DIR . 'wbmp/resultset_previous.wbmp', CAMILA_IMG_DIR . 'png/resultset_previous.png', '-');
예제 #3
0
 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;
 }
예제 #4
0
 function process()
 {
     $this->value = $this->form->fields[$this->field . '_camilauploaded']->value;
     global $_CAMILA;
     if (isset($_FILES[$this->key])) {
         $cnt = count($_FILES[$this->key]['name']);
         $err = false;
         $err_avaliable = isset($_FILES[$this->key]['error']);
         for ($i = 0; $i < $cnt; $i++) {
             $this->uploaderrors[$i] = null;
             $tmp = $_FILES[$this->key]['tmp_name'][$i];
             $items[$i] = stripslashes($_FILES[$this->key]['name'][$i]);
             if ($err_avaliable) {
                 $up_err = $_FILES[$this->key]['error'][$i];
             } else {
                 $up_err = file_exists($tmp) ? 0 : 4;
             }
             //$rel = $items[$i] . camila_hash(CAMILA_FM_PREFIX);
             //$abs = get_abs_item($this->usergroup, $rel);
             if ($this->extfsenabled) {
                 $rel = $items[$i] . camila_hash(CAMILA_FM_PREFIX);
             } else {
                 $rel = $items[$i];
             }
             $abs = $this->uploadfolder . '/' . $rel;
             if ($items[$i] == '' || $up_err == 4) {
                 continue;
             }
             if ($up_err == 1 || $up_err == 2) {
                 $this->uploaderrors[$i] = 904;
                 $err = true;
                 continue;
             }
             if ($up_err == 3) {
                 $this->uploaderrors[$i] = 905;
                 $err = true;
                 continue;
             }
             if (!@is_uploaded_file($tmp)) {
                 $this->uploaderrors[$i] = 906;
                 $err = true;
                 continue;
             }
             if (!$this->override && @file_exists($abs)) {
                 $this->uploaderrors[$i] = 906;
                 $err = true;
                 continue;
             }
             if (function_exists('move_uploaded_file')) {
                 $ok = @move_uploaded_file($tmp, $abs);
             } else {
                 $ok = @copy($tmp, $abs);
                 // trying to delete file...
                 @unlink($tmp);
             }
             if ($ok === false) {
                 $this->uploaderrors[$i] = 906;
                 $err = true;
                 continue;
             }
             if (!$err) {
                 $uparr = $this->form->fields[$this->field . '_camilauploaded']->value;
                 $eluparr = !is_array($uparr) ? 0 : count($uparr);
                 $this->value[count($this->value)] = $rel;
                 $this->form->fields[$this->field . '_camilauploaded']->value[$eluparr] = $rel;
                 //if ($this->selectuploadfolder)
                 //    fm_add_file($rel, fm_name($rel, $this->usergroup), $this->usergroup, $_POST[$this->key.'_camiladir'][$i] );
                 //else
                 //    fm_add_file($rel, , $this->usergroup );
                 if ($this->extfsenabled) {
                     if ($this->selectuploadfolder) {
                         $this->_addfile($this->usergroup, $_POST[$this->key . '_camiladir'], substr($rel, 0, -CAMILA_FM_PREFIX), $rel);
                     } else {
                         $rootnode = $this->_tree_get_group_root_node($this->usergroup);
                         $this->_addfile($this->usergroup, $rootnode['id'], substr($rel, 0, -CAMILA_FM_PREFIX), $rel);
                     }
                 }
                 $this->value = $this->form->fields[$this->field . '_camilauploaded']->value;
             }
         }
     }
     if ($err == true) {
         return false;
     } else {
         return true;
     }
 }