コード例 #1
0
 public function upload_file($ShowUpload = TRUE)
 {
     $id_file_cnt = 1;
     // Contador de archivos subidos
     if ($this->Directory != '') {
         // obtenemos los datos del archivo
         $file_ext = fkore::file_ext($_FILES["archivo"]["name"]);
         $id_usr = isset($_SESSION['id_usuario']) ? $_SESSION['id_usuario'] : '0';
         $archivo = $id_usr . '_' . date('YmdHis') . '_' . substr(encode($_FILES["archivo"]['name']), 0, 6) . '.' . $file_ext;
         $this->file_name = $archivo;
         $this->file_size = $_FILES["archivo"]['size'];
         $this->file_type = $_FILES["archivo"]['type'];
         $this->file_ext = $file_ext;
         $this->file_title = $_FILES["archivo"]["name"];
         //$tamano = $_FILES["archivo"]['size'];
         //$tipo = $_FILES["archivo"]['type'];
         $file_extencion_allowed = $this->verifyAllowedFileType();
         if ($archivo != "" && $file_extencion_allowed == TRUE) {
             // (mmendoza )Removido
             //$this->forsa_creacion_dir($this-> Directory);
             $subfolder = $this->subfolder_creation();
             // guardamos el archivo a la carpeta files
             $destino = $this->Directory . "/" . $subfolder . $archivo;
             if (copy($_FILES['archivo']['tmp_name'], $destino)) {
                 // Guarda referencia en la db
                 //$this->FileRecord-> fields[$this->fld_id] = 0; es new
                 $this->FileRecord->fields[$this->fdl_id_user] = $_SESSION['id_usuario'];
                 $this->FileRecord->fields[$this->fdl_id_cuenta] = $_SESSION['id_cuenta'];
                 $this->FileRecord->fields[$this->fld_path] = $this->Directory;
                 $this->FileRecord->fields[$this->fld_type] = $this->file_type;
                 $this->FileRecord->fields[$this->fld_file_ext] = $this->file_ext;
                 $this->FileRecord->fields[$this->fld_size] = $this->file_size;
                 $this->FileRecord->fields[$this->fld_file] = $this->file_name;
                 $this->FileRecord->fields[$this->fld_title] = $this->file_title;
                 $this->FileRecord->fields[$this->fld_leyend] = $this->file_leyend;
                 $this->FileRecord->fields[$this->fld_desc] = $this->file_desc;
                 $this->FileRecord->fields[$this->fld_updated_date] = date('Y-m-d H:i:s');
                 $this->FileRecord->fields['upload_method'] = $this->uploadMethod;
                 $this->FileRecord->insert();
                 $this->record_id = $this->FileRecord->inserted_id();
                 $this->FileRecord->fields[$this->fld_id] = $this->FileRecord->inserted_id();
                 if ($ShowUpload == TRUE) {
                     echo fk_ok_message(__('El archivo subió correctamente'));
                 }
                 $this->UploadDetails[$id_file_cnt]['file'] = $this->FileRecord->fields;
                 $this->UploadDetails[$id_file_cnt]['file']['http_path'] = $this->HttpDirectory . '/' . $archivo;
             } else {
                 try {
                     throw new FkException('Error al subir archivo');
                 } catch (FkException $e) {
                     $e->show();
                 }
             }
         } else {
             echo fk_alert_message('Hubo un error al subir archivo');
             $this->UploadDetails[$id_file_cnt]['error'][] = 'Extencion invalida o no hay archivo';
         }
     } else {
         try {
             throw new FkException('$this->Directory no esta definido');
         } catch (FkException $e) {
             $e->show();
         }
     }
 }
コード例 #2
0
ファイル: appform.php プロジェクト: mmendoza000/freekore
 /**
  *@package AppForm
  *@since v0.1 beta
  *@method PrintSearchResult()
  *@desc  Returns the search result
  * */
 private function PrintSeachResults()
 {
     $db = new db();
     $db->connect();
     $proyection_fields = $this->SearchCustomFields;
     if (trim($this->SearchCustomFields) != '*') {
         $proyection_fields = $this->DbRecord->id_field_name . ' as Id, ' . $this->SearchCustomFields;
     }
     //pa($this->DbRecord-> form_fields);
     $where = '';
     if ($_POST['srch-by-field'] == '0') {
         $where_fields = '';
         foreach ($this->DbRecord->form_fields as $f) {
             $where_fields .= $f['Field'] . ' like "%' . $_POST['srch-word'] . '%" OR ';
         }
         $where_fields = substr($where_fields, 0, -3);
         $where = ' WHERE (' . $where_fields . ')';
     } else {
         $where = ' WHERE (' . $_POST['srch-by-field'] . ' like "%' . $_POST['srch-word'] . '%") ';
     }
     $sqlSrch = 'SELECT ' . $proyection_fields . ' FROM ' . $this->model . ' ' . $where . ' ' . $this->DbRecord->SqlAnd . ' ';
     $db->query_assoc($sqlSrch);
     $data_rs = '';
     $tot = $db->num_rows();
     if ($tot == 0) {
         $data_rs .= fk_alert_message($tot . ' resultados', false);
     } else {
         $data_rs .= fk_ok_message($tot . ' resultados', false);
     }
     $data_rs .= '<table class="tbl-1" style="width:100%" border="0" cellspacing="0" cellpadding="0" >';
     $cnt = 0;
     while ($rows = $db->next()) {
         $cnt++;
         //pa($rows);
         if ($cnt % 2 == 0) {
             $even_odd = 'even';
         } else {
             $even_odd = 'odd';
         }
         if ($cnt == 1) {
             // Header
             $data_rs .= '<tr><th>&nbsp</th>';
             foreach ($rows as $col => $val) {
                 $data_rs .= '<th>' . ucwords(strtolower(strtr($col, '_', ' '))) . '</th>';
             }
             $data_rs .= '</tr>';
         }
         if (trim($this->SearchCustomFields) != '*') {
             $id_record = $rows['Id'];
         } else {
             $id_record = $rows[$this->DbRecord->id_field_name];
         }
         $fx_sel_rec = new ajax('url', 'pannel-1-' . $this->IdObject, 'args:op=' . encode('selec-record') . '&rec-srch=' . $id_record . ';form:' . $this->IdObject . ';url:' . $this->CurrentPage);
         $data_rs .= '<tr class="' . $even_odd . '" onclick="' . $fx_sel_rec->render() . '"><td><a href="javascript:void(0)">Ver</a></td>';
         foreach ($rows as $col => $val) {
             $data_rs .= '<td>' . $val . '</td>';
         }
         $data_rs .= '</tr>';
     }
     $data_rs .= '</table>';
     echo $data_rs;
 }