Exemplo n.º 1
0
function s3_file_import_init($import, $config)
{
    $response = array();
    $err = '';
    if (!$err) {
        $response['api'] = array();
        $response['data'] = array();
        $id = id_unique();
        $key = __s3_key($id, $import, $config);
        $policy = __s3_policy($id, $import, $config);
        $response['data']['key'] = $key;
        $response['data']['acl'] = $config['s3_acl'];
        $response['data']['policy'] = $policy;
        $response['data']['Content-Type'] = $import['mime'];
        $response['data']['signature'] = __s3_file_access_key($config['aws_secret_access_key'], $policy);
        $response['data']['AWSAccessKeyId'] = $config['aws_access_key_id'];
        $response['endpoint'] = 'https://s3' . ($config['s3_region'] ? '-' . $config['s3_region'] : '') . '.amazonaws.com/' . $config['s3_bucket'];
        $response['api']['id'] = $id;
        $response['api']['type'] = $import['type'];
        $response['api']['extension'] = $import['extension'];
        $response['api']['label'] = $import['label'];
    }
    if ($err) {
        $response['error'] = $err;
    }
    return $response;
}
Exemplo n.º 2
0
function s3_file_import_init($import, $config)
{
    $response = array();
    $err = '';
    if (!$err) {
        $response['api'] = array();
        $response['data'] = array();
        $response['method'] = 'put';
        $id = id_unique();
        $bucket = $config['s3_bucket'];
        $region = $config['s3_region'] ? $config['s3_region'] : 'us-east-1';
        $key = path_strip_slash_start($config['user_media_directory']);
        // remove bucket name from url if it's there
        if (substr($key, 0, strlen($bucket)) == $bucket) {
            $key = substr($key, strlen(path_add_slash_end($bucket)));
        }
        $key = path_concat(path_concat(path_concat($key, $import['uid']), $id), $config['import_original_basename'] . '.' . $import['extension']);
        $options_array = ['version' => 'latest', 'region' => $region];
        if ($config['aws_secret_access_key'] && $config['aws_access_key_id']) {
            $options_array['credentials'] = [];
            $options_array['credentials']['key'] = $config['aws_access_key_id'];
            $options_array['credentials']['secret'] = $config['aws_secret_access_key'];
        }
        try {
            $s3 = new Aws\S3\S3Client($options_array);
            $cmd = $s3->getCommand('PutObject', ['Bucket' => $config['s3_bucket'], 'Key' => $key, 'ACL' => $config['s3_acl'], 'ContentType' => $import['mime']]);
            $request = $s3->createPresignedRequest($cmd, $config['s3_expires']);
            // Get the actual presigned-url
            $response['endpoint'] = $presignedUrl = (string) $request->getUri();
        } catch (Exception $e) {
            $err = $e->getMessage();
        }
        // data key children all become part of the POST file upload request
        $response['api']['id'] = $id;
        $response['api']['type'] = $import['type'];
        $response['api']['extension'] = $import['extension'];
        $response['api']['label'] = $import['label'];
    }
    if ($err) {
        $response['error'] = $err;
    }
    return $response;
}
Exemplo n.º 3
0
 $sql_kardex = "select id_productos from productos where id_productos = '" . $arreglo1[$i] . "'";
 $id_prod = id_unique($conexion, $sql_kardex);
 // kardex y modificar productos
 $c_t = '';
 $v_t = '';
 $t_t = '';
 $c_e = '';
 $v_e = '';
 $t_e = '';
 $consulta = pg_query("select stock,precio from productos where id_productos = '" . $id_prod . "'");
 while ($row = pg_fetch_row($consulta)) {
     $stock = $row[0];
     $precio_compra = $row[1];
 }
 $sql_kardex = "select id_kardex from kardex where id_productos ='" . $id_prod . "'";
 $id_kardex = id_unique($conexion, $sql_kardex);
 $id_det_kardex = unique($fecha_larga);
 $sql_kardex = "select c_e,v_e,t_e,c_s,v_s,t_s,c_t,v_t,t_t from detalles_kardex where id_kardex = '" . $id_kardex . "' order by fecha desc limit 1";
 $sql_kardex = pg_query($sql_kardex);
 while ($row = pg_fetch_row($sql_kardex)) {
     $c_t = $row[6];
     $v_t = $row[7];
     $t_t = $row[8];
 }
 $c_e = $arreglo2[$i];
 $v_e = $precio_compra;
 $t_e = $arreglo2[$i] * $precio_compra;
 $t_e = number_format($t_e, 3, '.', '');
 $c_t = $c_t - $c_e;
 $t_t = $t_t - $t_e;
 if ($t_t > 0 && $c_t > 0) {
}
if (!$err) {
    // make sure there wasn't a problem with the upload
    if (!empty($file['error'])) {
        $err = 'Problem with your file: ' . $file['error'];
    } elseif (!is_uploaded_file($file['tmp_name'])) {
        $err = 'Not an uploaded file';
    }
}
if (!$err) {
    // make sure file extension is valid
    $file_name = $file['name'];
    $file_ext = file_extension($file_name);
    if ('tgz' == $file_ext) {
        set_time_limit(0);
        $archive_dir = path_concat($config['temporary_directory'], id_unique());
        if (!archive_extract($file['tmp_name'], $archive_dir, $config)) {
            $err = 'Could not extract to ' . $archive_dir;
        } else {
            // move select files from the archive to media directory
            if (!file_move_extension('jpg', $archive_dir, $media_dir, $config)) {
                $err = 'Could not move jpg files from ' . $archive_dir . ' to ' . $media_dir;
            } else {
                if (!file_move_extension($config['export_audio_extension'], $archive_dir, $media_dir, $config)) {
                    $err = 'Could not move ' . $config['export_audio_extension'] . ' files from ' . $archive_dir . ' to ' . $media_dir;
                } else {
                    if (!file_move_extension($config['export_extension'], $archive_dir, $media_dir, $config)) {
                        $err = 'Could not move ' . $decoder_extension . ' files from ' . $archive_dir . ' to ' . $media_dir;
                    }
                }
            }
Exemplo n.º 5
0
if ($_GET['fn'] == '0') {
    //function atras
    if ($_GET['id'] == '') {
        ///si exsite un id previo
        $sql = "select id_empresa from empresa order by fecha_creacion desc limit 1";
        $id_tabla = id_unique($conexion, $sql);
    } else {
        $sql = "select id_empresa from empresa where id_empresa not in (select id_empresa from empresa where id_empresa >= '{$_GET['id']}' order by id_empresa desc) order by fecha_creacion desc limit 1";
        $id_tabla = id_unique($conexion, $sql);
    }
    $sql = "select id_empresa,ruc_empresa,nombre_empresa,propietario,slogan,telefono1,telefono2,ciudad,descripcion,direccion,correo,fax,sitio_web,nombre_contador,autorizacion_factura,ascesor_legal,representante_legal,identificacion_repre,inicio_fac_preimpresa,item_factura,anio_contable,modo_costeo,comentario,imagen,estado,ruc_contador,serie_retencion,autorizacion_retencion,serie_nota_credito,autorizacion_nota_credito from empresa,ciudad where empresa.ciudad = ciudad.id_ciudad and id_empresa= '{$id_tabla}'";
    $lista1 = array(atras_adelente($conexion, $sql));
    $data = json_encode($lista1);
    echo $data;
} else {
    if ($_GET['fn'] == '1') {
        //function adelante
        if ($_GET['id'] == '') {
            ///si exsite un id previo
            $sql = "select id_empresa from empresa order by fecha_creacion desc limit 1";
            $id_tabla = id_unique($conexion, $sql);
        } else {
            $sql = "select id_empresa from empresa where id_empresa not in (select id_empresa from empresa where id_empresa <= '{$_GET['id']}' order by id_empresa asc) order by fecha_creacion asc limit 1";
            $id_tabla = id_unique($conexion, $sql);
        }
        $sql = "select id_empresa,ruc_empresa,nombre_empresa,propietario,slogan,telefono1,telefono2,ciudad,descripcion,direccion,correo,fax,sitio_web,nombre_contador,autorizacion_factura,ascesor_legal,representante_legal,identificacion_repre,inicio_fac_preimpresa,item_factura,anio_contable,modo_costeo,comentario,imagen,estado,ruc_contador,serie_retencion,autorizacion_retencion,serie_nota_credito,autorizacion_nota_credito from empresa,ciudad where empresa.ciudad = ciudad.id_ciudad and id_empresa= '{$id_tabla}'";
        $lista1 = array(atras_adelente($conexion, $sql));
        $data = json_encode($lista1);
        echo $data;
    }
}
        $err = 'Not an uploaded file';
    }
}
if (!$err) {
    // make sure file extension is valid
    $file_name = $file['name'];
    $file_ext = file_extension($file_name);
    if ($file_ext != 'tgz') {
        $err = 'Unsupported extension: ' . $file_ext;
    }
}
if (!$err) {
    // check that we can extract the archive to temp directory
    $media_dir = path_concat(path_concat(path_concat($config['web_root_directory'], $config['user_media_directory']), $uid), $id);
    set_time_limit(0);
    $tmp_path = path_concat($config['temporary_directory'], id_unique());
    $archive_dir = $tmp_path;
    if (!archive_extract($file['tmp_name'], $archive_dir, $config)) {
        $err = 'Could not extract to ' . $archive_dir;
    }
}
if (!$err) {
    // move select files from the archive to media directory
    switch ($type) {
        case 'audio':
        case 'video':
            // move any soundtrack
            $frag = $config['import_audio_basename'] . '.' . $config['import_audio_extension'];
            $media_path = path_concat($media_dir, $frag);
            $archive_path = path_concat($archive_dir, $frag);
            if (file_exists($archive_path)) {
Exemplo n.º 7
0
function local_file_import_init($import, $config)
{
    $response = array();
    $id = id_unique();
    $response['api'] = array();
    $response['data'] = array();
    $response['endpoint'] = path_concat($config['cgi_directory'], 'import_upload.php');
    $response['data']['id'] = $id;
    $response['data']['type'] = $import['type'];
    $response['data']['extension'] = $import['extension'];
    $response['api']['id'] = $id;
    $response['api']['type'] = $import['type'];
    $response['api']['extension'] = $import['extension'];
    $response['api']['label'] = $import['label'];
    return $response;
}