function getData($sql) { $res = exeSQL($sql); $data = ""; while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) { $item = ""; foreach ($row as $key => $value) { $keyEn = rawurlencode($key); $valueEn = rawurlencode($value); $item = $item . $keyEn . "=" . $valueEn . " "; } if ($data == "") { $data = trim($item); } else { $data = $data . "#" . trim($item); } } return $data; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php require "../dbase/dbFunction.php"; if (isset($_POST['submitLogin'])) { $userName = $_POST['UserName']; $password = $_POST['Password']; if (checkLogin($userName, $password)) { session_start(); $_SESSION['UserName'] = $userName; $sql = "SELECT UserID FROM UserInfoTable WHERE UserName='******'"; $res = exeSQL($sql); $row = mysql_fetch_array($res); $userID = $row['UserID']; $_SESSION['UserID'] = $userID; echo "<script type=text/javascript>window.location=\"/index.php\";</script>"; } } ?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="chrome=1"> <link href="Login.css" rel='stylesheet' type='text/css' /> <title>PicMap</title> </head> <body> <div class="LoginDiv">
function getUserName($userID) { $sql = "SELECT UserName FROM UserInfoTable WHERE UserID='{$userID}'"; $result = exeSQL($sql); $row = mysql_fetch_array($result); if (empty($row)) { return 0; } else { return $row[0]; } }
function setUserPos($name, $longitude, $latitude) { global $dbHost, $dbUser, $dbPwd, $dbName; $tabName = $dbName . "_USER"; $sql = "UPDATE {$tabName} SET longitude='{$longitude}', latitude='{$latitude}' WHERE name='{$name}'"; $result = exeSQL($sql); }
{ $str = '<li><div class="AlbumItemDiv" id="AlbumItemDiv' . $index . '">' . '<div class="AlbumImgDivB1"></div>' . '<div class="AlbumImgDivB2"></div>' . '<div class="AlbumImgDiv">' . ' <img src="' . $imgPath . '" />' . '</div>' . ' <span class="AlbumItemTitle">' . $albumName . ' (' . $createTime . ')' . '</span>' . '</div></li>'; return $str; } $sql = "SELECT * FROM AlbumTable WHERE UserID='{$homeUserID}'"; $res = exeSQL($sql); $index = 0; while ($row = mysql_fetch_array($res)) { $index = $index + 1; $albumID = $row['AlbumID']; $albumName = $row['AlbumName']; $createTime = date("Y/m/d", $row['CreateTime']); $picNum = $row['PicNum']; $facePicID = $row['FacePicID']; $sql2 = "SELECT PicPath FROM PicTable WHERE AlbumID={$albumID} LIMIT 0,1"; $res2 = exeSQL($sql2); $row2 = mysql_fetch_array($res2); $facePicPath = $row2[0] . "_snap.jpg"; $str = createAlbumItem($index, $albumName, $facePicPath, $createTime); printf($str); } ?> <!-- <li> <div class="AlbumItemDiv"> <div class="AlbumImgDivB1" id="AlbumImg0"></div> <div class="AlbumImgDivB2" id="AlbumImg0"></div> <div class="AlbumImgDiv" id="AlbumImg0"> <img src="/images/0.JPG" /> </div>
if (isset($_GET['files'])) { $error = false; $files = array(); $uploaddir = './uploads/'; $random = substr(md5(rand()), 0, 4); substr(basename($file['name']), -3); foreach ($_FILES as $file) { if (substr(basename($file['name']), -3) == "csv") { if (move_uploaded_file($file['tmp_name'], $uploaddir . $random . "_" . basename($file['name']))) { $files[] = $uploaddir . $random . "_" . $file['name']; $filename = $uploaddir . $random . "_" . $file['name']; /////////// $handle = fopen($filename, "r"); fgetcsv($handle, 100000, ",", "'"); //loop through the csv file and insert into database do { if ($data[0]) { exeSQL("INSERT INTO rutas (mes, anio, estado_origen, estado_destino, ciudad_origen, ciudad_destino, transportadora, tipo_transporte, tipo_combustible, tipo_movimiento, costo, carga, rendimiento, diesel, tiempo) VALUES\n (\n '" . addslashes($data[0]) . "',\n '" . addslashes($data[1]) . "',\n '" . addslashes($data[2]) . "',\n '" . addslashes($data[3]) . "',\n '" . addslashes($data[4]) . "',\n '" . addslashes($data[5]) . "',\n '" . addslashes($data[6]) . "',\n '" . addslashes($data[7]) . "',\n '" . addslashes($data[8]) . "',\n '" . addslashes($data[9]) . "',\n '" . addslashes($data[10]) . "',\n '" . addslashes($data[11]) . "',\n '" . addslashes($data[12]) . "',\n '" . addslashes($data[13]) . "',\n '" . addslashes($data[14]) . "'\n )\n "); } } while ($data = fgetcsv($handle, 100000, ",", "'")); ////////// } else { $error = true; } } } $data = $error ? array('error' => 'Ocurrio un error al subir el archivo, por favor verifique que el archivo tenga una extension .csv') : array('files' => $files); } else { $data = array('success' => 'El archivo ha sido importado correctamente, recarge esta pagina para reflejar los cambios.', 'formData' => $_POST); } echo json_encode($data);
{ $conexion = mysqli_connect("localhost", "mexicotr_sitex", "W5OQ%~9S_4(W", "mexicotr_sitex"); return $conexion; } function disconnectDB($conexion) { $close = mysqli_close($conexion); return $close; } function exeSQL($sql) { //Creamos la conexión con la función anterior $conexion = connectDB(); //generamos la consulta mysqli_set_charset($conexion, "utf8"); //formato de datos utf8 if (!($result = mysqli_query($conexion, $sql))) { die; } //si la conexión cancelar programa disconnectDB($conexion); //desconectamos la base de datos } $data = array(); if (isset($_GET['deleteidrow'])) { exeSQL("DELETE FROM rutas WHERE id = " . $_GET['deleteidrow']); $data = array('success' => 'Fila borrada correctamente, recarga la pagina para reflejar los resultados', 'formData' => $_POST); } else { $data = array('success' => 'Error Borrando Fila', 'formData' => $_POST); } echo json_encode($data);