Example #1
0
function updateImg($idimgact, $imgnva, $tipo, $descripcion, $Host, $User, $Pass, $dbName)
{
    $idnueva = InserImg($imgnva, $tipo, $descripcion, $Host, $User, $Pass, $dbName);
    if ($idimgact != 1) {
        eliminaArch($idimgact, $Host, $User, $Pass, $dbName);
    }
    return $idnueva;
}
ini_set('display_errors', '1');
$operacion = $_POST['operacion'];
include "../clases/Usuario.class.php";
include "../clases/query.php";
include "../seguridad/configdb.php";
if ($operacion == 1) {
    //agregar usuario
    foreach ($_POST as $clave => $valor) {
        $fdatos[$clave] = $valor;
    }
    $nombre_foto = 'defecto.png';
    $fileperfil = 1;
    if ($_FILES['perfil']['error'] == 0) {
        $nombre_foto = $_FILES['perfil']['name'];
        cargaArchivo($_FILES['perfil']['name'], "../../includes/img/perfil/", $_FILES['perfil']['tmp_name']);
        $idimg = InserImg($_FILES['perfil']['name'], 1, 'Foto Perfil', $Host, $User, $Pass, $dbName);
        if ($idimg != '' && $idimg != null) {
            $fileperfil = $idimg;
        }
    }
    $tel = !empty($fdatos['telefono']) ? $fdatos['telefono'] : '';
    $mail = !empty($fdatos['correo']) ? $fdatos['correo'] : '';
    $fnac = !empty($fdatos['fnac']) ? date('Y-m-d', strtotime($fdatos['fnac'])) : '';
    $datosUsu = array();
    $datosUsu[0] = ucwords(strtolower(trim($fdatos['nombre'])));
    $datosUsu[1] = ucwords(strtolower(trim($fdatos['ap'])));
    $datosUsu[2] = ucwords(strtolower(trim($fdatos['am'])));
    $datosUsu[3] = $mail;
    $datosUsu[4] = $tel;
    $datosUsu[5] = trim($fdatos['usuario']);
    $datosUsu[6] = md5(trim($fdatos['clave']));
extract($_POST);
include "../clases/query.php";
include "../seguridad/configdb.php";
if ($operacion == 1) {
    //agregar equipo
    //print_r($_POST);exit(0);
    $fileperfil = 0;
    //print_r($_FILES);exit(0);
    if ($_FILES['imgeq']['error'] == 0) {
        $sep = explode('image/', $_FILES["imgeq"]["type"]);
        // Separamos image/
        $tipo = $sep[1];
        // Optenemos el tipo de imagen que es
        $nombre_foto = trim($nome0) . "." . $tipo;
        cargaArchivo($nombre_foto, "../../includes/img/escudo/", $_FILES['imgeq']['tmp_name']);
        $idimg = InserImg($nombre_foto, 2, 'Foto Equipo', $Host, $User, $Pass, $dbName);
        if ($idimg != '' && $idimg != null) {
            $fileperfil = $idimg;
        }
    }
    $equipo = array();
    $equipo['nombre'] = trim($nome0);
    $equipo['estadio'] = trim($estadio0);
    $equipo['liga'] = $liga0;
    $equipo['jj'] = $jj0 == '' ? 0 : $jj0;
    $equipo['jg'] = $jg0 == '' ? 0 : $jg0;
    $equipo['jp'] = $jp0 == '' ? 0 : $jp0;
    $equipo['je'] = $je0 == '' ? 0 : $je0;
    $equipo['gf'] = $gf0 == '' ? 0 : $gf0;
    $equipo['gc'] = $gc0 == '' ? 0 : $gc0;
    $equipo['dg'] = $dif0 == '' ? 0 : $dif0;