Пример #1
0
function DB_lo_create($conn)
{
    if (strcmp(phpversion(), '4.2.0') < 0) {
        return pg_locreate($conn);
    } else {
        return pg_lo_create($conn);
    }
}
Пример #2
0
 function UpdateBlobFile($table, $column, $path, $where, $blobtype = 'BLOB')
 {
     pg_exec($this->_connectionID, "begin");
     $fd = fopen($path, 'r');
     $contents = fread($fd, filesize($path));
     fclose($fd);
     $oid = pg_lo_create($this->_connectionID);
     $handle = pg_lo_open($this->_connectionID, $oid, 'w');
     pg_lo_write($handle, $contents);
     pg_lo_close($handle);
     // $oid = pg_lo_import ($path);
     pg_exec($this->_connectionID, "commit");
     $rs = ADOConnection::UpdateBlob($table, $column, $oid, $where, $blobtype);
     $rez = !empty($rs);
     return $rez;
 }
Пример #3
0
 function _firstUse()
 {
     // BLOB opened - do nothing.
     if (is_resource($this->blob)) {
         return true;
     }
     // Open or create blob.
     if ($this->id !== null) {
         $this->blob = @pg_lo_open($this->database->link, $this->id, 'rw');
         if ($this->blob === false) {
             return $this->_setDbError('open');
         }
     } else {
         $this->id = @pg_lo_create($this->database->link);
         $this->blob = @pg_lo_open($this->database->link, $this->id, 'w');
         if ($this->blob === false) {
             return $this->_setDbError('create');
         }
     }
     return true;
 }
Пример #4
0
 public function pgsqlLOBCreate()
 {
     if (false === ($oid = pg_lo_create($this->link))) {
         $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, 'pgsqlLOBCreate');
     }
     return $oid;
 }
 /**
  * Cria L.O. Vazio no Banco de dados e retorna se OID 
  * @param integer $lTemTransacaoAtiva
  */
 public static function criaOID($lTemTransacaoAtiva = false)
 {
     global $conn;
     if (!$lTemTransacaoAtiva) {
         db_inicio_transacao();
     }
     $iOidGerado = pg_lo_create($conn);
     if (!$lTemTransacaoAtiva) {
         db_fim_transacao();
     }
     return $iOidGerado;
 }
Пример #6
0
 function large_object_create($table, $file)
 {
     trigger_before('large_object_create', $this, $this);
     $return = false;
     if (!file_exists($file)) {
         return $return;
     }
     $filename = basename($file);
     if (!$filename) {
         trigger_error("Error determining base name of large object file {$filename}", E_USER_ERROR);
     }
     $handle = fopen($file, "r");
     if (!$handle) {
         trigger_error("Error opening large object file {$file}", E_USER_ERROR);
     }
     $buffer = fread($handle, filesize($file));
     if (!$buffer) {
         trigger_error("Error reading large object file {$file}", E_USER_ERROR);
     }
     $result = fclose($handle);
     $result = @pg_query($this->conn, "BEGIN");
     if (!$result) {
         trigger_error("error starting l_o_c transaction: " . @pg_last_error($this->conn), E_USER_ERROR);
     }
     $oid = @pg_lo_create($this->conn);
     if (!$oid) {
         trigger_error("error in pg_l_o_c: " . @pg_last_error($this->conn), E_USER_ERROR);
     }
     #$result = pg_query($this->conn,"UPDATE $table SET $field = $oid WHERE $pkfield = '$pkvalue'");
     #if (!$result) { trigger_error("Error updating file OID", E_USER_ERROR ); }
     $handle = @pg_lo_open($this->conn, $oid, "w");
     if (!$handle) {
         trigger_error("error in pg_l_o_o: " . @pg_last_error($this->conn), E_USER_ERROR);
     }
     $result = @pg_lo_write($handle, $buffer);
     if (!$result) {
         trigger_error("error in l_o_w: " . @pg_last_error($this->conn), E_USER_ERROR);
     }
     $result = @pg_lo_close($handle);
     if (!$result) {
         trigger_error("error in l_o_close: " . @pg_last_error($this->conn), E_USER_ERROR);
     }
     $result = @pg_query($this->conn, "COMMIT");
     if (!$result) {
         trigger_error("error committing l_o_c transaction: " . @pg_last_error($this->conn), E_USER_ERROR);
     } else {
         $return = $oid;
     }
     return $return;
 }
Пример #7
0
 function Create()
 {
     if (version_compare(phpversion(), "4.2.0", "ge") > 0) {
         $this->oid = pg_lo_create($this->dbconnect);
     } else {
         $this->oid = pg_locreate($this->dbconnect);
     }
 }
Пример #8
0
 public function makePgLO(&$data = null)
 {
     $pg = $this->connectionFactory->get('RW');
     $pgResource = $pg->resource->get();
     if (!isset($data)) {
         $data = file_get_contents($this->makeAndFillFile());
     }
     pg_query($pgResource, "BEGIN");
     $oid = pg_lo_create($pgResource);
     $handle = pg_lo_open($pgResource, $oid, 'w');
     pg_lo_write($handle, $data);
     pg_query($pgResource, "COMMIT");
     return new Oid($oid, $pg);
 }
 function update()
 {
     $ser_id = $_REQUEST["ser_id"];
     $exp_id = $_REQUEST["exp_id"];
     $tra_id = $_REQUEST["tra_id"];
     $cue_id = $_REQUEST["cue_id"];
     // file
     $this->archivo = new tab_archivo();
     $this->archivo->setRequest2Object($_REQUEST);
     $this->archivo->setFil_id($_REQUEST['dov_id']);
     $msm_guardado_archivo = 0;
     if ($_FILES["archivo"]["error"] == 4) {
     } else {
         // Digital file
         $archivo_digital = new tab_archivo_digital();
         $archivo_type = $_FILES["archivo"]["type"];
         $archivo = $_FILES["archivo"]["tmp_name"];
         $archivo_size = $_FILES["archivo"]["size"];
         $archivo_name = $_FILES["archivo"]["name"];
         $nombre = basename($_FILES["archivo"]["name"]);
         $nombreFichero = $_FILES["archivo"]["name"];
         $archivo_name_array = explode(".", $archivo_name);
         $archivo_ext = array_pop($archivo_name_array);
         $archivo_cifrado = md5($archivo_name);
         $sis_tammax = 0;
         // Data Parameters
         $sis_tipcarga = 2;
         $nombreDirectorio = "";
         $tsistema = new tab_sistema();
         $sql = "SELECT *\r\n                FROM tab_sistema";
         $rows2 = $tsistema->dbselectBySQL($sql);
         if (count($rows2) >= 1) {
             $sis_tipcarga = $rows2[0]->sis_tipcarga;
             $sis_tammax = $rows2[0]->sis_tammax;
             $nombreDirectorio = $rows2[0]->sis_ruta;
         }
         // Verify size
         if ($archivo_size > $sis_tammax) {
             $errores["archivo"] = "El tamanio del fichero supera el limite permitido ({$maxsize} bytes)!";
             $error = true;
         } else {
             $nombreArchivo = $_FILES['archivo']['name'];
             if ($nombreArchivo == "") {
             } else {
                 if ($sis_tipcarga == 2) {
                     $error = false;
                     $copiarFichero = false;
                     if (is_uploaded_file($_FILES['archivo']['tmp_name'])) {
                         $nombreFichero = $_FILES['archivo']['name'];
                         $copiarFichero = true;
                         $nombreCompleto = $nombreDirectorio . $nombreFichero;
                         if (is_file($nombreCompleto)) {
                             $idUnico = time();
                             $nombreFichero = $idUnico . "-" . $nombreFichero;
                         }
                     } else {
                         if ($_FILES['archivo']['error'] == UPLOAD_ERR_FORM_SIZE) {
                             $maxsize = $_REQUEST['MAX_FILE_SIZE'];
                             $errores["archivo"] = "El tamanio del fichero supera el limite permitido ({$maxsize} bytes)!";
                             $error = true;
                         } else {
                             if ($_FILES['archivo']['name'] == "") {
                                 $nombreFichero = '';
                             } else {
                                 $errores["archivo"] = "No se ha podido subir el fichero!";
                                 $msm_guardado_archivo = 0;
                                 $error = true;
                             }
                         }
                     }
                     if ($error == false) {
                         // Validate
                         $dov_id = $_REQUEST['dov_id'];
                         $rows = $archivo_digital->dbselectByField("dov_id", $dov_id);
                         if (count($rows)) {
                             $sql = "UPDATE tab_archivo_digital\r\n                                    SET fil_nomoriginal='{$nombreFichero}', \r\n                                        fil_nomcifrado='{$archivo_cifrado}', \r\n                                        fil_tipo='{$archivo_type}', \r\n                                        fil_tamano='{$archivo_size}', \r\n                                        fil_extension='{$archivo_ext}', \r\n                                        nombre='{$nombre}', \r\n                                        mime='{$archivo_type}', \r\n                                        size={$archivo_size}, \r\n                                        archivo='{$nombreFichero}', \r\n                                        dov_estado=1\r\n                                    WHERE dov_id = '{$dov_id}' ";
                             $link = $archivo_digital->connect();
                             pg_query($link, "begin");
                             pg_query($link, $sql) or die(pg_last_error($link));
                             pg_query($link, "commit");
                             if ($copiarFichero) {
                                 move_uploaded_file($_FILES['archivo']['tmp_name'], $nombreDirectorio . $nombreFichero);
                             }
                             $msm_guardado_archivo = 1;
                         } else {
                             $sql = "INSERT INTO tab_archivo_digital(dov_id,\r\n                                                            fil_nomoriginal,\r\n                                                            fil_nomcifrado,\r\n                                                            fil_tipo,\r\n                                                            fil_tamano,\r\n                                                            fil_extension,\r\n                                                            nombre,\r\n                                                            mime,\r\n                                                            size,\r\n                                                            archivo,\r\n                                                            dov_estado)\r\n                                                   VALUES ({$dov_id},\r\n                                                           '{$nombreFichero}',\r\n                                                           '{$archivo_cifrado}',\r\n                                                           '{$archivo_type}',\r\n                                                           '{$archivo_size}' ,\r\n                                                           '{$archivo_ext}' ,\r\n                                                           '{$nombre}',\r\n                                                           '{$archivo_type}',\r\n                                                           {$archivo_size},\r\n                                                           '{$nombreFichero}',\r\n                                                           1)";
                             $link = $archivo_digital->connect();
                             pg_query($link, "begin");
                             pg_query($link, $sql) or die(pg_last_error($link));
                             pg_query($link, "commit");
                             if ($copiarFichero) {
                                 move_uploaded_file($_FILES['archivo']['tmp_name'], $nombreDirectorio . $nombreFichero);
                             }
                             $msm_guardado_archivo = 1;
                         }
                     }
                 } else {
                     // Validate
                     $dov_id = $_REQUEST['dov_id'];
                     $rows = $this->series->dbselectByField("dov_id", $dov_id);
                     $row = $rows[0];
                     if (count($row)) {
                         $sql = "UPDATE tab_archivo_digital\r\n                            SET fil_nomoriginal='{$archivo_name}', \r\n                            fil_nomcifrado='{$archivo_cifrado}', \r\n                            fil_tipo='{$archivo_type}', \r\n                            fil_tamano='{$archivo_size}', \r\n                            fil_extension='{$archivo_ext}', \r\n                            nombre='{$nombre}', \r\n                            archivo_oid={$oid}, \r\n                            mime='{$archivo_type}', \r\n                            size={$archivo_size}, \r\n                            archivo='{$nombreFichero}', \r\n                            dov_estado=1\r\n                            WHERE dov_id = {$dov_id} ";
                         $link = $archivo_digital->connect();
                         $fp = fopen($archivo, "rb");
                         $contenido = fread($fp, filesize($archivo));
                         fclose($fp);
                         pg_query($link, "begin");
                         $oid = pg_lo_create($link);
                         pg_query($link, $sql) or die(pg_last_error($link));
                         $blob = pg_lo_open($link, $oid, "w");
                         pg_lo_write($blob, $contenido);
                         pg_lo_close($blob);
                         pg_query($link, "commit");
                         $msm_guardado_archivo = 1;
                         //"Se subio correctamente el archivo"
                     } else {
                         $sql = "INSERT INTO tab_archivo_digital(dov_id,\r\n                                                                fil_nomoriginal,\r\n                                                                fil_nomcifrado,\r\n                                                                fil_tipo,\r\n                                                                fil_tamano,\r\n                                                                fil_extension,\r\n                                                                nombre,\r\n                                                                archivo_oid,\r\n                                                                mime,\r\n                                                                size,\r\n                                                                archivo)\r\n                                                        VALUES ({$dov_id},\r\n                                                                '{$archivo_name}',\r\n                                                                '{$archivo_cifrado}',\r\n                                                                '{$archivo_type}',\r\n                                                                '{$archivo_size}',\r\n                                                                '{$archivo_ext}',\r\n                                                                '{$nombre}',\r\n                                                                {$oid},\r\n                                                                '{$archivo_type}',\r\n                                                                {$archivo_size},\r\n                                                                '{$nombreFichero}')";
                         $link = $archivo_digital->connect();
                         $fp = fopen($archivo, "rb");
                         $contenido = fread($fp, filesize($archivo));
                         fclose($fp);
                         pg_query($link, "begin");
                         $oid = pg_lo_create($link);
                         pg_query($link, $sql) or die(pg_last_error($link));
                         $blob = pg_lo_open($link, $oid, "w");
                         pg_lo_write($blob, $contenido);
                         pg_lo_close($blob);
                         pg_query($link, "commit");
                         $msm_guardado_archivo = 1;
                     }
                 }
             }
         }
     }
     $dov_id = $_REQUEST['dov_id'];
     // Forwarding
     if ($_REQUEST['accion'] == 'guardarsinsalir') {
         $msm_guardado_archivo = 1;
         Header("Location: " . PATH_DOMAIN . "/archivo/view/" . $exp_id . "/" . $dov_id . "/" . $msm_guardado_archivo . "/");
         //        } else if ($_REQUEST ['accion'] == 'guardarnuevo') {
         //            $_SESSION['SER_ID'] = $_REQUEST['ser_id'];
         //            $this->add();
     } else {
         if ($_REQUEST['accion'] == 'guardar') {
             header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/{$cue_id}/");
         } else {
             header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/{$cue_id}/");
         }
     }
 }
Пример #10
0
 private function _firstUse()
 {
     if (is_resource($this->_blob)) {
         return true;
     }
     if ($this->_id !== null) {
         $this->_blob = @pg_lo_open($this->_database->link, $this->_id, 'rw');
         if ($this->_blob === false) {
             return $this->_raiseError('open');
         }
     } else {
         $this->_id = @pg_lo_create($this->_database->link);
         $this->_blob = @pg_lo_open($this->_database->link, $this->_id, 'w');
         if ($this->_blob === false) {
             return $this->_raiseError('create');
         }
     }
     return true;
 }
Пример #11
0
 /**
  *
  */
 function lo_create()
 {
     return pg_lo_create($this->connection);
 }
Пример #12
0
   pg_free_result( pg_query( 'BEGIN' ) );
 $result = FALSE;
 for( $rn = 1; $rn < 1000; ++$rn ) {
   if( !array_key_exists( 'r'.$rn, $_POST ) )
     break;
   $data = 'OK:';
   $req = $_POST['r'.$rn];
   if( $req == 'connect' ) {
     dump( 0 );
     dump( 0 );
     dump( 0 );
   } elseif( substr($req,0,11) == 'blob_create' ) {
     list($oid) = sscanf( $req, 'blob_create %u' );
     pg_free_result( pg_query( $commit ? 'COMMIT' : 'ROLLBACK' ) );
     pg_free_result( pg_query( 'BEGIN' ) );
     $oid = pg_lo_create() or pgerr('lo_create failed');
     pg_free_result( pg_query( 'COMMIT' ) );
     pg_free_result( pg_query( 'BEGIN' ) );
     dump($oid);
   } elseif( substr($req,0,11) == 'blob_delete' ) {
     list($oid) = sscanf( $req, 'blob_delete %u' );
     $oid = pg_lo_unlink($oid) or pgerr('lo_unlink failed');
   } elseif( substr($req,0,10) == 'blob_write' ) {
     list($oid) = sscanf( $req, 'blob_write %s ' );
     $bin = substr($req,12+strlen($oid));
     $obj = pg_lo_open($oid,'w') or pgerr( 'lo_open failed' );
     $res = pg_lo_write($obj,$bin) or pgerr( 'lo_write failed' );
     pg_lo_close($obj);
     dump($res);
   } elseif( substr($req,0,9) == 'blob_read' ) {
     list($oid) = sscanf( $req, 'blob_read %u' );
 function update()
 {
     $ser_id = $_REQUEST["ser_id"];
     $exp_id = $_REQUEST["exp_id"];
     $tra_id = $_REQUEST["tra_id"];
     $cue_id = $_REQUEST["cue_id"];
     // file
     $this->archivo = new tab_archivo();
     $this->archivo->setRequest2Object($_REQUEST);
     $this->archivo->setFil_id($_REQUEST['fil_id']);
     if ($_REQUEST['exp_corr'] == 'AUTO') {
         $this->archivo->setFil_codigo(strtoupper($_REQUEST['fil_codigo']));
         $this->archivo->setFil_nro(strtoupper($_REQUEST['fil_nro']));
     } else {
         $this->archivo->setFil_codigo(strtoupper($_REQUEST['fil_codigo']));
         $this->archivo->setFil_nro(strtoupper($_REQUEST['fil_nro']));
     }
     if ($_REQUEST['fil_titulo2']) {
         $this->archivo->setFil_titulo(strtoupper($_REQUEST['fil_titulo'] . " Nro. " . $_REQUEST['fil_titulo2']));
     } else {
         $this->archivo->setFil_titulo(strtoupper($_REQUEST['fil_titulo']));
     }
     $this->archivo->setFil_subtitulo(strtoupper($_REQUEST['fil_subtitulo']));
     //$this->archivo->setFil_fecha($_REQUEST['fil_fecha']);
     $this->archivo->setFil_mes($_REQUEST['fil_mes']);
     $this->archivo->setFil_anio($_REQUEST['fil_anio']);
     $this->archivo->setFil_mesf($_REQUEST['fil_mesf']);
     $this->archivo->setFil_aniof($_REQUEST['fil_aniof']);
     $this->archivo->setIdi_id($_REQUEST['idi_id']);
     $this->archivo->setFil_proc(strtoupper($_REQUEST['fil_proc']));
     $this->archivo->setFil_firma(strtoupper($_REQUEST['fil_firma']));
     $this->archivo->setFil_cargo(strtoupper($_REQUEST['fil_cargo']));
     $this->archivo->setFil_alccon(addslashes(htmlentities(strtoupper($_REQUEST['fil_alccon']))));
     $this->archivo->setSof_id($_REQUEST['sof_id']);
     $this->archivo->setFil_nrofoj(strtoupper($_REQUEST['fil_nrofoj']));
     $this->archivo->setFil_tomovol(strtoupper($_REQUEST['fil_tomovol']));
     $this->archivo->setFil_nroejem(strtoupper($_REQUEST['fil_nroejem']));
     $this->archivo->setFil_nrocaj(strtoupper($_REQUEST['fil_nrocaj']));
     $this->archivo->setFil_nropaq(strtoupper($_REQUEST['fil_nropaq']));
     $this->archivo->setFil_sala(strtoupper($_REQUEST['fil_sala']));
     $this->archivo->setFil_estante(strtoupper($_REQUEST['fil_estante']));
     $this->archivo->setFil_cuerpo(strtoupper($_REQUEST['fil_cuerpo']));
     $this->archivo->setFil_balda(strtoupper($_REQUEST['fil_balda']));
     $this->archivo->setFil_tipoarch($_REQUEST['fil_tipoarch']);
     if ($_REQUEST['fil_mrb']) {
         $this->archivo->setFil_mrb($_REQUEST['fil_mrb']);
     }
     $this->archivo->setFil_cantpaq(strtoupper(trim($_REQUEST['fil_cantpaq'])));
     $this->archivo->setFil_cantcaj(strtoupper(trim($_REQUEST['fil_cantcaj'])));
     if ($_REQUEST['fil_ori']) {
         $this->archivo->setFil_ori($_REQUEST['fil_ori']);
     } else {
         $this->archivo->setFil_ori(0);
     }
     if ($_REQUEST['fil_cop']) {
         $this->archivo->setFil_cop($_REQUEST['fil_cop']);
     } else {
         $this->archivo->setFil_cop(0);
     }
     if ($_REQUEST['fil_fot']) {
         $this->archivo->setFil_fot($_REQUEST['fil_fot']);
     } else {
         $this->archivo->setFil_fot(0);
     }
     $this->archivo->setFil_confidencialidad($_REQUEST['fil_confidencialidad']);
     $this->archivo->setFil_obs(strtoupper($_REQUEST['fil_obs']));
     $this->archivo->setFil_estado('1');
     $this->archivo->update3();
     $this->archivo->update();
     // Tab_doccorr
     if ($_REQUEST['fil_nur']) {
         $this->doccorr = new Tab_doccorr();
         $rows = $this->doccorr->dbselectByField("fil_id", $_REQUEST['fil_id']);
         $row = $rows[0];
         if (count($row)) {
             // Update data
             $this->doccorr->setDco_id($row->dco_id);
             $this->doccorr->setFil_id($_REQUEST['fil_id']);
             $this->doccorr->setFil_nur($_REQUEST['fil_nur']);
             if ($_REQUEST['fil_nur_s']) {
                 $this->doccorr->setFil_nur(strtoupper($_REQUEST['fil_nur_s']));
             }
             if ($_REQUEST['fil_cite']) {
                 $this->doccorr->setFil_cite(strtoupper($_REQUEST['fil_cite']));
             }
             if ($_REQUEST['fil_asunto']) {
                 $this->doccorr->setFil_asunto(strtoupper($_REQUEST['fil_asunto']));
             }
             if ($_REQUEST['fil_sintesis']) {
                 $this->doccorr->setFil_sintesis(strtoupper($_REQUEST['fil_sintesis']));
             }
             $this->doccorr->setDco_estado(1);
             $dco_id = $this->doccorr->update();
             // New
             if ($_REQUEST['tiponur'] == 'ORI' || $_REQUEST['tiponur'] == '') {
                 // Registra en el SIACO tabla archivados
                 $this->archivados = new tab_archivados();
                 $this->archivados->setRequest2Object($_REQUEST);
                 $rows2 = $this->archivados->dbselectByField("codigo", $_REQUEST['fil_nur']);
                 if (count($rows2)) {
                     $row2 = $rows2[0];
                     $this->archivados->setId_archivado($row2->id_archivado);
                     $this->archivados->setCodigo($_REQUEST['fil_nur']);
                     $this->archivados->setFecha(date("Y-m-d"));
                     $this->archivados->setPersona($_SESSION['USU_LOGIN']);
                     $this->archivados->setLugar($_REQUEST['exp_id'] . '-' . $_REQUEST['exp_nombre']);
                     $this->archivados->setObservaciones("SAD");
                     $this->archivados->setCopia("NO");
                     $this->archivados->update();
                     // Update seguimiento
                     $this->seguimientos = new Tab_seguimientos();
                     $sql = "SELECT seguimientos.id_seguimiento\r\n                                FROM seguimientos\r\n                                WHERE codigo = '" . $_REQUEST['fil_nur'] . "'\r\n                                ORDER BY id_seguimiento DESC ";
                     $rows = $this->seguimientos->dbSelectBySQL($sql);
                     $row = $rows[0];
                     $this->seguimientos->setId_seguimiento($row->id_seguimiento);
                     $this->seguimientos->setEstado(100);
                     $this->seguimientos->update();
                 } else {
                     $this->archivados->setId_archivado('');
                     $this->archivados->setCodigo($_REQUEST['fil_nur']);
                     $this->archivados->setFecha(date("Y-m-d"));
                     $this->archivados->setPersona($_SESSION['USU_LOGIN']);
                     $this->archivados->setLugar($_REQUEST['exp_id'] . '-' . $_REQUEST['exp_nombre']);
                     $this->archivados->setObservaciones("SAD");
                     $this->archivados->setCopia("NO");
                     $this->archivados->insert();
                     // Update seguimiento
                     $this->seguimientos = new Tab_seguimientos();
                     $sql = "SELECT seguimientos.id_seguimiento\r\n                                FROM seguimientos\r\n                                WHERE codigo = '" . $_REQUEST['fil_nur'] . "'\r\n                                ORDER BY id_seguimiento DESC ";
                     $rows = $this->seguimientos->dbSelectBySQL($sql);
                     $row = $rows[0];
                     $this->seguimientos->setId_seguimiento($row->id_seguimiento);
                     $this->seguimientos->setEstado(100);
                     $this->seguimientos->update();
                 }
             } else {
                 // Registra en el SIACO tabla archivados_digitales
                 $this->archivados_digitales = new tab_archivados_digitales();
                 $this->archivados_digitales->setRequest2Object($_REQUEST);
                 $rows2 = $this->archivados_digitales->dbselectByField("codigo", $_REQUEST['fil_nur']);
                 if (count($row2)) {
                     $row2 = $rows2[0];
                     $this->archivados_digitales->setId_archivado($row2->id_archivado);
                     $this->archivados_digitales->setCodigo($_REQUEST['fil_nur']);
                     $this->archivados_digitales->setFecha(date("Y-m-d"));
                     $this->archivados_digitales->setPersona($_SESSION['USU_LOGIN']);
                     $this->archivados->setLugar($_REQUEST['exp_id'] . '-' . $_REQUEST['exp_nombre']);
                     $this->archivados_digitales->setObservaciones("SAD");
                     $this->archivados_digitales->setCopia("SI");
                     $this->archivados_digitales->update();
                     // Update seguimiento
                     $this->seguimientos = new Tab_seguimientos();
                     $sql = "SELECT seguimientos.id_seguimiento\r\n                                FROM seguimientos\r\n                                WHERE codigo = '" . $_REQUEST['fil_nur'] . "'\r\n                                ORDER BY id_seguimiento DESC ";
                     $rows = $this->seguimientos->dbSelectBySQL($sql);
                     $row = $rows[0];
                     $this->seguimientos->setId_seguimiento($row->id_seguimiento);
                     $this->seguimientos->setEstado(51);
                     $this->seguimientos->update();
                 } else {
                     $this->archivados_digitales->setId_archivado("0");
                     $this->archivados_digitales->setCodigo($_REQUEST['fil_nur']);
                     $this->archivados_digitales->setFecha(date("Y-m-d"));
                     $this->archivados_digitales->setPersona($_SESSION['USU_LOGIN']);
                     $this->archivados->setLugar($_REQUEST['exp_id'] . '-' . $_REQUEST['exp_nombre']);
                     $this->archivados_digitales->setObservaciones("SAD");
                     $this->archivados_digitales->setCopia("SI");
                     $this->archivados_digitales->insert();
                     // Update seguimiento
                     $this->seguimientos = new Tab_seguimientos();
                     $sql = "SELECT seguimientos.id_seguimiento\r\n                                FROM seguimientos\r\n                                WHERE codigo = '" . $_REQUEST['fil_nur'] . "'\r\n                                ORDER BY id_seguimiento DESC ";
                     $rows = $this->seguimientos->dbSelectBySQL($sql);
                     $row = $rows[0];
                     $this->seguimientos->setId_seguimiento($row->id_seguimiento);
                     $this->seguimientos->setEstado(51);
                     $this->seguimientos->update();
                 }
             }
         } else {
             // Insert data
             $this->doccorr->setDco_id('');
             $this->doccorr->setFil_id($_REQUEST['fil_id']);
             $this->doccorr->setFil_nur($_REQUEST['fil_nur']);
             if ($_REQUEST['fil_nur_s']) {
                 $this->doccorr->setFil_nur(strtoupper($_REQUEST['fil_nur_s']));
             }
             if ($_REQUEST['fil_cite']) {
                 $this->doccorr->setFil_cite(strtoupper($_REQUEST['fil_cite']));
             }
             if ($_REQUEST['fil_asunto']) {
                 $this->doccorr->setFil_asunto(strtoupper($_REQUEST['fil_asunto']));
             }
             if ($_REQUEST['fil_sintesis']) {
                 $this->doccorr->setFil_sintesis(strtoupper($_REQUEST['fil_sintesis']));
             }
             $this->doccorr->setDco_estado(1);
             $dco_id = $this->doccorr->insert();
             if ($_REQUEST['tiponur'] == 'ORI' || $_REQUEST['tiponur'] == '') {
                 // Registra en el SIACO tabla archivados
                 $this->archivados = new tab_archivados();
                 $this->archivados->setRequest2Object($_REQUEST);
                 $this->archivados->setId_archivado("0");
                 $this->archivados->setCodigo($_REQUEST['fil_nur']);
                 $this->archivados->setFecha(date("Y-m-d"));
                 $this->archivados->setPersona($_SESSION['USU_LOGIN']);
                 $this->archivados->setLugar($_REQUEST['exp_id'] . '-' . $_REQUEST['exp_nombre']);
                 $this->archivados->setObservaciones("SAD");
                 $this->archivados->setCopia("NO");
                 $this->archivados->insert();
                 // Update seguimiento
                 $this->seguimientos = new Tab_seguimientos();
                 $sql = "SELECT seguimientos.id_seguimiento\r\n                            FROM seguimientos\r\n                            WHERE codigo = '" . $_REQUEST['fil_nur'] . "'\r\n                            ORDER BY id_seguimiento DESC ";
                 $rows = $this->seguimientos->dbSelectBySQL($sql);
                 $row = $rows[0];
                 $this->seguimientos->setId_seguimiento($row->id_seguimiento);
                 $this->seguimientos->setEstado(100);
                 $this->seguimientos->update();
             } else {
                 // Registra en el SIACO tabla archivados_digitales
                 $this->archivados_digitales = new tab_archivados_digitales();
                 $this->archivados_digitales->setRequest2Object($_REQUEST);
                 $this->archivados_digitales->setId_archivado("0");
                 $this->archivados_digitales->setCodigo($_REQUEST['fil_nur']);
                 $this->archivados_digitales->setFecha(date("Y-m-d"));
                 $this->archivados_digitales->setPersona($_SESSION['USU_LOGIN']);
                 $this->archivados->setLugar($_REQUEST['exp_id'] . '-' . $_REQUEST['exp_nombre']);
                 $this->archivados_digitales->setObservaciones("SAD");
                 $this->archivados_digitales->setCopia("SI");
                 $this->archivados_digitales->insert();
                 // Update seguimiento
                 $this->seguimientos = new Tab_seguimientos();
                 $sql = "SELECT seguimientos.id_seguimiento\r\n                            FROM seguimientos\r\n                            WHERE codigo = '" . $_REQUEST['fil_nur'] . "'\r\n                            ORDER BY id_seguimiento DESC ";
                 $rows = $this->seguimientos->dbSelectBySQL($sql);
                 $row = $rows[0];
                 $this->seguimientos->setId_seguimiento($row->id_seguimiento);
                 $this->seguimientos->setEstado(51);
                 $this->seguimientos->update();
             }
         }
     }
     $this->palclave = new tab_palclave();
     $this->palclave->deleteByField("fil_id", $_REQUEST['fil_id']);
     if (!empty($_REQUEST['fil_descripcion'])) {
         $pac_nombre = trim($_REQUEST['fil_descripcion']);
         $array = explode(SEPARATOR_SEARCH, $pac_nombre);
         for ($j = 0; $j < count($array); $j++) {
             if ($array[$j] != '') {
                 $this->palclave->setFil_id($_REQUEST['fil_id']);
                 $this->palclave->setPac_nombre(strtoupper(trim($array[$j])));
                 $this->palclave->setPac_formulario('Documento');
                 $this->palclave->setPac_estado(1);
                 $this->palclave->insert();
             }
         }
     }
     $msm_guardado_archivo = 0;
     if ($_FILES["archivo"]["error"] == 4) {
     } else {
         // Digital file
         $archivo_digital = new tab_archivo_digital();
         $archivo_type = $_FILES["archivo"]["type"];
         $archivo = $_FILES["archivo"]["tmp_name"];
         $archivo_size = $_FILES["archivo"]["size"];
         $archivo_name = $_FILES["archivo"]["name"];
         $nombre = basename($_FILES["archivo"]["name"]);
         $nombreFichero = $_FILES["archivo"]["name"];
         $archivo_name_array = explode(".", $archivo_name);
         $archivo_ext = array_pop($archivo_name_array);
         $archivo_cifrado = md5($archivo_name);
         $sis_tammax = 0;
         // Data Parameters
         $sis_tipcarga = 2;
         $nombreDirectorio = "";
         $tsistema = new tab_sistema();
         $sql = "SELECT *\r\n                FROM tab_sistema";
         $rows2 = $tsistema->dbselectBySQL($sql);
         if (count($rows2) >= 1) {
             $sis_tipcarga = $rows2[0]->sis_tipcarga;
             $sis_tammax = $rows2[0]->sis_tammax;
             $nombreDirectorio = $rows2[0]->sis_ruta;
         }
         // Verify size
         if ($archivo_size > $sis_tammax) {
             $errores["archivo"] = "El tamanio del fichero supera el limite permitido ({$maxsize} bytes)!";
             $error = true;
         } else {
             $nombreArchivo = $_FILES['archivo']['name'];
             if ($nombreArchivo == "") {
             } else {
                 if ($sis_tipcarga == 2) {
                     $error = false;
                     $copiarFichero = false;
                     if (is_uploaded_file($_FILES['archivo']['tmp_name'])) {
                         $nombreFichero = $_FILES['archivo']['name'];
                         $copiarFichero = true;
                         $nombreCompleto = $nombreDirectorio . $nombreFichero;
                         if (is_file($nombreCompleto)) {
                             $idUnico = time();
                             $nombreFichero = $idUnico . "-" . $nombreFichero;
                         }
                     } else {
                         if ($_FILES['archivo']['error'] == UPLOAD_ERR_FORM_SIZE) {
                             $maxsize = $_REQUEST['MAX_FILE_SIZE'];
                             $errores["archivo"] = "El tamanio del fichero supera el limite permitido ({$maxsize} bytes)!";
                             $error = true;
                         } else {
                             if ($_FILES['archivo']['name'] == "") {
                                 $nombreFichero = '';
                             } else {
                                 $errores["archivo"] = "No se ha podido subir el fichero!";
                                 $msm_guardado_archivo = 0;
                                 $error = true;
                             }
                         }
                     }
                     if ($error == false) {
                         // Validate
                         $fil_id = $_REQUEST['fil_id'];
                         $rows = $archivo_digital->dbselectByField("fil_id", $fil_id);
                         if (count($rows)) {
                             $sql = "UPDATE tab_archivo_digital\r\n                                    SET fil_nomoriginal='{$nombreFichero}', \r\n                                        fil_nomcifrado='{$archivo_cifrado}', \r\n                                        fil_tipo='{$archivo_type}', \r\n                                        fil_tamano='{$archivo_size}', \r\n                                        fil_extension='{$archivo_ext}', \r\n                                        nombre='{$nombre}', \r\n                                        mime='{$archivo_type}', \r\n                                        size={$archivo_size}, \r\n                                        archivo='{$nombreFichero}', \r\n                                        fil_estado=1\r\n                                    WHERE fil_id = '{$fil_id}' ";
                             $link = $archivo_digital->connect();
                             pg_query($link, "begin");
                             pg_query($link, $sql) or die(pg_last_error($link));
                             pg_query($link, "commit");
                             if ($copiarFichero) {
                                 move_uploaded_file($_FILES['archivo']['tmp_name'], $nombreDirectorio . $nombreFichero);
                             }
                             $msm_guardado_archivo = 1;
                         } else {
                             $sql = "INSERT INTO tab_archivo_digital(fil_id,\r\n                                                            fil_nomoriginal,\r\n                                                            fil_nomcifrado,\r\n                                                            fil_tipo,\r\n                                                            fil_tamano,\r\n                                                            fil_extension,\r\n                                                            nombre,\r\n                                                            mime,\r\n                                                            size,\r\n                                                            archivo,\r\n                                                            fil_estado)\r\n                                                   VALUES ({$fil_id},\r\n                                                           '{$nombreFichero}',\r\n                                                           '{$archivo_cifrado}',\r\n                                                           '{$archivo_type}',\r\n                                                           '{$archivo_size}' ,\r\n                                                           '{$archivo_ext}' ,\r\n                                                           '{$nombre}',\r\n                                                           '{$archivo_type}',\r\n                                                           {$archivo_size},\r\n                                                           '{$nombreFichero}',\r\n                                                           1)";
                             $link = $archivo_digital->connect();
                             pg_query($link, "begin");
                             pg_query($link, $sql) or die(pg_last_error($link));
                             pg_query($link, "commit");
                             if ($copiarFichero) {
                                 move_uploaded_file($_FILES['archivo']['tmp_name'], $nombreDirectorio . $nombreFichero);
                             }
                             $msm_guardado_archivo = 1;
                         }
                     }
                 } else {
                     // Validate
                     $fil_id = $_REQUEST['fil_id'];
                     $rows = $this->series->dbselectByField("fil_id", $fil_id);
                     $row = $rows[0];
                     if (count($row)) {
                         $sql = "UPDATE tab_archivo_digital\r\n                            SET fil_nomoriginal='{$archivo_name}', \r\n                            fil_nomcifrado='{$archivo_cifrado}', \r\n                            fil_tipo='{$archivo_type}', \r\n                            fil_tamano='{$archivo_size}', \r\n                            fil_extension='{$archivo_ext}', \r\n                            nombre='{$nombre}', \r\n                            archivo_oid={$oid}, \r\n                            mime='{$archivo_type}', \r\n                            size={$archivo_size}, \r\n                            archivo='{$nombreFichero}', \r\n                            fil_estado=1\r\n                            WHERE fil_id = {$fil_id} ";
                         $link = $archivo_digital->connect();
                         $fp = fopen($archivo, "rb");
                         $contenido = fread($fp, filesize($archivo));
                         fclose($fp);
                         pg_query($link, "begin");
                         $oid = pg_lo_create($link);
                         pg_query($link, $sql) or die(pg_last_error($link));
                         $blob = pg_lo_open($link, $oid, "w");
                         pg_lo_write($blob, $contenido);
                         pg_lo_close($blob);
                         pg_query($link, "commit");
                         $msm_guardado_archivo = 1;
                         //"Se subio correctamente el archivo"
                     } else {
                         $sql = "INSERT INTO tab_archivo_digital(fil_id,\r\n                                                                fil_nomoriginal,\r\n                                                                fil_nomcifrado,\r\n                                                                fil_tipo,\r\n                                                                fil_tamano,\r\n                                                                fil_extension,\r\n                                                                nombre,\r\n                                                                archivo_oid,\r\n                                                                mime,\r\n                                                                size,\r\n                                                                archivo)\r\n                                                        VALUES ({$fil_id},\r\n                                                                '{$archivo_name}',\r\n                                                                '{$archivo_cifrado}',\r\n                                                                '{$archivo_type}',\r\n                                                                '{$archivo_size}',\r\n                                                                '{$archivo_ext}',\r\n                                                                '{$nombre}',\r\n                                                                {$oid},\r\n                                                                '{$archivo_type}',\r\n                                                                {$archivo_size},\r\n                                                                '{$nombreFichero}')";
                         $link = $archivo_digital->connect();
                         $fp = fopen($archivo, "rb");
                         $contenido = fread($fp, filesize($archivo));
                         fclose($fp);
                         pg_query($link, "begin");
                         $oid = pg_lo_create($link);
                         pg_query($link, $sql) or die(pg_last_error($link));
                         $blob = pg_lo_open($link, $oid, "w");
                         pg_lo_write($blob, $contenido);
                         pg_lo_close($blob);
                         pg_query($link, "commit");
                         $msm_guardado_archivo = 1;
                     }
                 }
             }
         }
     }
     $fil_id = $_REQUEST['fil_id'];
     // Forwarding
     if ($_REQUEST['accion'] == 'guardarsinsalir') {
         $msm_guardado_archivo = 1;
         Header("Location: " . PATH_DOMAIN . "/archivo/view/" . $exp_id . "/" . $fil_id . "/" . $msm_guardado_archivo . "/");
         //        } else if ($_REQUEST ['accion'] == 'guardarnuevo') {
         //            $_SESSION['SER_ID'] = $_REQUEST['ser_id'];
         //            $this->add();
     } else {
         if ($_REQUEST['accion'] == 'guardar') {
             header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/{$cue_id}/");
         } else {
             header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/{$cue_id}/");
         }
     }
     //        // Forwarding
     //        if ($_REQUEST ['accion'] == 'cargarnuevo') {
     //            header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/$cue_id/");
     //            //$this->add2();
     //        } else {
     //            header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/$cue_id/");
     //        }
 }
Пример #14
0
if (!$oid) {
    echo "pg_lo_create() error\n";
}
if ($oid != 21000) {
    echo "pg_lo_create() wrong id\n";
}
pg_lo_unlink($db, $oid);
pg_exec($db, "commit");
echo "create LO from string\n";
pg_exec($db, "begin");
$oid = pg_lo_create($db, "21001");
if (!$oid) {
    echo "pg_lo_create() error\n";
}
if ($oid != 21001) {
    echo "pg_lo_create() wrong id\n";
}
pg_lo_unlink($db, $oid);
pg_exec($db, "commit");
echo "create LO using default connection\n";
pg_exec("begin");
$oid = pg_lo_create(21002);
if (!$oid) {
    echo "pg_lo_create() error\n";
}
if ($oid != 21002) {
    echo "pg_lo_create() wrong id\n";
}
pg_lo_unlink($oid);
pg_exec("commit");
echo "OK";
Пример #15
0
}
pg_lo_close($handle);
pg_exec($db, "commit");
echo "unlink LO\n";
pg_exec($db, "begin");
pg_lo_unlink($db, $oid) or print "pg_lo_unlink() error 1\n";
pg_exec($db, "commit");
// more pg_lo_unlink() tests
echo "Test without connection\n";
pg_exec($db, "begin");
$oid = pg_lo_create($db) or print "pg_lo_create() error\n";
pg_lo_unlink($oid) or print "pg_lo_unlink() error 2\n";
pg_exec($db, "commit");
echo "Test with string oid value\n";
pg_exec($db, "begin");
$oid = pg_lo_create($db) or print "pg_lo_create() error\n";
pg_lo_unlink($db, (string) $oid) or print "pg_lo_unlink() error 3\n";
pg_exec($db, "commit");
echo "import/export LO\n";
$path = dirname(__FILE__) . '/';
pg_query($db, 'begin');
$oid = pg_lo_import($db, $path . 'php.gif');
pg_query($db, 'commit');
pg_query($db, 'begin');
@unlink($path . 'php.gif.exported');
pg_lo_export($oid, $path . 'php.gif.exported', $db);
if (!file_exists($path . 'php.gif.exported')) {
    echo "Export failed\n";
}
@unlink($path . 'php.gif.exported');
pg_query($db, 'commit');
$pdf->SetFillColor(00);
$pdf->MultiCell(180, 3, "Código de Autenticidade da Certidão", 0, "R", 0);
$pdf->MultiCell(180, 10, $t1, 0, "R", 0);
$pdf->int25(95, 270, $t1, 15, 0.341);
$nomearq = $pdf->GeraArquivoTemp();
$arqpdf = $nomearq;
$pdf->Output($arqpdf, false, true);
if ($sqlerro == false) {
    db_inicio_transacao();
    $localrecebeanexo = $arqpdf;
    // Para ler conteudo do arquivo pdf gerado
    if ($sqlerro == false && trim($localrecebeanexo) != "") {
        $arquivograva = fopen($localrecebeanexo, "rb");
        $dados = fread($arquivograva, filesize($localrecebeanexo));
        fclose($arquivograva);
        $oidgrava = pg_lo_create();
        if (isset($titulo) && $titulo == 'CGM') {
            $sqlcgm = "select z01_nome from cgm where z01_numcgm = {$origem}";
        } elseif (isset($titulo) && $titulo == 'INSCRICAO') {
            $sqlcgm = "select z01_nome from cgm inner join issbase on q02_numcgm= z01_numcgm where q02_inscr = {$origem}";
        } elseif (isset($titulo) && $titulo == 'MATRICULA') {
            $sqlcgm = "select z01_nome from cgm inner join iptubase on j01_numcgm = z01_numcgm where j01_matric = {$origem}";
        }
        $resultcgm = db_query($sqlcgm);
        $linhascgm = pg_num_rows($resultcgm);
        if ($linhascgm > 0) {
            db_fieldsmemory($resultcgm, 0);
        }
        $clcertidaoweb->codcert = $clcertidao->p50_sequencial;
        $clcertidaoweb->tipocer = $tipo;
        $clcertidaoweb->cerdtemite = $ano . "-" . $mes1 . "-" . $dia;