Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. <?php
  2. include 'connect.php';
  3. date_default_timezone_set('America/Los_Angeles');
  4.  
  5. //$url = "http://engines.pressstart.co/alcaldia/preguntas/image2.php?name=Pedro%20Perez&cc=111111";
  6. //$url = "http://engines.pressstart.co/alcaldia/preguntas/image.php?name=".$row[1]."%20".$row[3]."&cc=".$row[2];
  7. //$data = array('key1' => 'value1', 'key2' => 'value2');
  8.  
  9. // use key 'http' even if you send the request to https://...
  10. /*
  11. $options = array(
  12. 'http' => array(
  13. 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
  14. 'method' => 'POST',
  15. 'content' => http_build_query($data)
  16. )
  17. );
  18. */
  19.  
  20. //$context = stream_context_create($options);
  21.  
  22.  
  23.  
  24. //$result = file_get_contents($url, false);
  25. //if ($result === FALSE) { /* Handle error */ }
  26.  
  27. //var_dump($result);
  28.  
  29. if(isset($_POST['User'])){
  30. $User = preg_replace('/\s+/', '', $_POST["User"]);
  31. }else{
  32. $User = preg_replace('/\s+/', '', $_GET["User"]);
  33. }
  34.  
  35. $sql="SELECT COUNT(id_usuario),nombre,cedula,apellido FROM usuario where mail = '$User'";
  36. //$sql="SELECT COUNT(id),a.nombre FROM alcaldia a join usuario u on u.id_alcaldia = a.id where a.email = '$email' and a.pass = '$pass' and u.state = 1";
  37. $result=mysqli_query($conn,$sql);
  38. $row=mysqli_fetch_array($result,MYSQLI_NUM);
  39.  
  40.  
  41. if( $row[0] > 0 ){
  42.  
  43. $url2 = "".$row[1]." ".$row[3];
  44. $url2 = rawurlencode($url2);
  45.  
  46. //$url = "http://engines.pressstart.co/alcaldia/preguntas/image2.php?name=".$row[1]."%20".$row[3]."&cc=".$row[2];
  47. $url = "http://soy10aprende.secretariageneral.gov.co/15305b88b0e5661d5ced334ac50f4335/image.php?name=".$url2."&cc=".$row[2];
  48. //echo rawurlencode($url);
  49.  
  50. $imageData = base64_encode(file_get_contents($url));
  51. echo '<img src="data:image/jpeg;base64,'.$imageData.'" style="width: 60%;">';
  52. //echo '<img style="-webkit-user-select: none;cursor: zoom-in;" src="data:image/jpeg;base64,'.$imageData.'" width="414" height="320">';
  53.  
  54. //echo '<a href="'.$imageData.'" download>DESCARGAR CERFITICADO</a>';
  55. /*
  56. header("Content-Disposition: attachment; filename=\"" . basename($imageData) . "\"");
  57. header("Content-Type: application/force-download");
  58. header("Content-Length: " . filesize($imageData));
  59. header("Connection: close");
  60. */
  61. /*
  62. $image = base64_to_jpeg( $imageData, 'tmp.jpg' );
  63.  
  64. header("Content-Disposition: attachment; filename=\"" . basename($image) . "\"");
  65. header("Content-Type: application/force-download");
  66. header("Content-Length: " . filesize($image));
  67. header("Connection: close");
  68. */
  69.  
  70. }
  71.  
  72. function base64_to_jpeg($base64_string, $output_file) {
  73. // open the output file for writing
  74. $ifp = fopen( $output_file, 'wb' );
  75.  
  76. // split the string on commas
  77. // $data[ 0 ] == "data:image/png;base64"
  78. // $data[ 1 ] == <actual base64 string>
  79. $data = explode( ',', $base64_string );
  80.  
  81. // we could add validation here with ensuring count( $data ) > 1
  82. fwrite( $ifp, base64_decode( $data[ 1 ] ) );
  83.  
  84. // clean up the file resource
  85. fclose( $ifp );
  86.  
  87. return $output_file;
  88. }
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement