PHP - Compra y descarga Paypal con seguridad.

 
Vista:

Compra y descarga Paypal con seguridad.

Publicado por Jose Luis (1 intervención) el 02/01/2013 20:32:20
Buenas amigos. Queria pedidos una ayuda a ver si se os ocurre una solución.
Voy a abrir una web, ya desarrollada y acabada pero aun no abierta. En esta web muestro carteles míos para comprar, pagando por papal y descargar.
El sistema es el siguiente (Esto lo saque de un articulo, no lo desarrolle yo.):
Una vez hecho el pago, papal redirecciona automáticamente a una PRIMERA_PAGINA.php, que ha su vez redirecciona a otra SEGUNDA_PAGINA.php, que ha su vez redirecciona a la PAGINA_DE_DESCARGA.php (en esta pagina hay un a href"DOWNLOAD_FINISH.php el cual indica la carpeta donde se encuentran el articulo a descargar). Todo esto por seguridad. Parece complejo pero no lo es tanto. Ya lo he utilizado anteriormente en otra web y funciona perfectamente.
La cuestios es que en la web que esta activa solo se descargaban 12 artículos, es decir 12 botones de compra diferentes, con lo que hay 12 PRIMERAS_PAGINAS a las que se enlaza desde papal, 12 SEGUNDA_PAGINA, 12 PAGINA_DESCARGA y 1 DOWNLOAD_FIINISH.php. Os podéis imaginar la de archivos que hay.
Y ahí esta la cuestión, en la NUEVA web en principio, y se irán sumando mas, hay mas de 60 piezas para comprar y descargar; y me gustaría encontrar una solución para simplificar los pasos o bien desarrollarlos en una misma pagina.
Para que os hagais una idea a continuación os enseño todas las paginas de las que os he hablado.
Perdon por el "discurso" y gracias de antemano.

ENLAZE PAYPAL. PRIMERA_PAGINA.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="0;url=http://www.MIWEB.com/RELEVANTE.php"/>
<meta name="robots" content="noindex, nofollow" />
<meta http-equiv="window-target" content="_top">
<title>pagina1</title>
</head>
<body onload="document.getElementById('form1').submit()">
<form id="form1" name="form1" method="post" action="RELEVANTE.php" onsubmit="validar()">
<table width="31%" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#C0CEE0">
<tr>
<td width="21%">usuario</td>
<td width="79%"><div align="center">
<input name="usu" type="text" id="usu" value="admi" />
admi</div></td>
</tr>
<tr>
<td>password</td>
<td><div align="center">
<input name="pas" type="password" id="pas" value="123456" />
1234567</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="enviar" />
</div></td>
</tr>
</table>
</form>
</body>
</html>

PAGINA RELEVANTE. SEGUNDA_PAGINA.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
session_start();
?>
<?
$pas=$_POST['pas'];
    $pas1='123456';
    $usu=$_POST['usu'];
    $usu1='admi';
if($pas=='123456' || $usu=='admi'){
    $_SESSION["k_username"] = $usu1;
    echo'<script>alert("se ha logueado bien"),</script>';
    echo'<SCRIPT LANGUAJE="javascript">
    location.href = "DESCARGA.php"; 
    </SCRIPT>';
}
?>

PAGINA_DE_DESCARGA.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
session_start();
?>
<?php
if (isset($_SESSION['k_username'])) {
    echo 'bienvenido '.$_SESSION['k_username'];
}else{
echo'<SCRIPT LANGUAJE="javascript">
        location.href = "../index.html"; 
        </SCRIPT>';
        }
?>
<?php
header('Content-Type: text/html;charset=UTF-8');
?>
<!DOCTYPE html>
 
<html lang="en">
 
<head>
 
<meta name="robots" content="noindex,nofollow">
<meta charset="utf-8" />
<meta name="keywords" content="XXX" />
 
<meta name="robots" content="all" />
<meta name="author" content="XXX" />
<meta name="dc.date.issued" content="2012-12-01" />
<meta name="description" content="XXX" />
<meta name="dcterms.dateCopyrighted" content="Copyright" />
 
</head>
<body>
<div id="container">
<div id="botondescarga"><a href="DOWNLOAD_FINISH.php?file=ARTICULODESCARGA.ZIP"></a><span>DOWNLOAD</span></div>
</div>
</body>
</html>

PAGINA DOWNLOAD_FINISH.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
if (!isset($_GET['file']) || empty($_GET['file'])) {
 exit();
}
$root = "CARPETADESCARGA/";
$file = basename($_GET['file']);
$path = $root.$file;
$type = '';
 
if (is_file($path)) {
 $size = filesize($path);
 if (function_exists('mime_content_type')) {
 $type = mime_content_type($path);
 } else if (function_exists('finfo_file')) {
 $info = finfo_open(FILEINFO_MIME);
 $type = finfo_file($info, $path);
 finfo_close($info);
 }
 if ($type == '') {
 $type = "application/force-download";
 }
 // Definir headers  
 header("Content-Type: $type");
 header("Content-Disposition: attachment; filename=$file");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: " . $size);
 // Descargar archivo  
 readfile($path);
} else {
 die("El archivo no existe.");
}
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder