Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'connect.php';
- date_default_timezone_set('America/Los_Angeles');
- //$url = "http://engines.pressstart.co/alcaldia/preguntas/image2.php?name=Pedro%20Perez&cc=111111";
- //$url = "http://engines.pressstart.co/alcaldia/preguntas/image.php?name=".$row[1]."%20".$row[3]."&cc=".$row[2];
- //$data = array('key1' => 'value1', 'key2' => 'value2');
- // use key 'http' even if you send the request to https://...
- /*
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'POST',
- 'content' => http_build_query($data)
- )
- );
- */
- //$context = stream_context_create($options);
- //$result = file_get_contents($url, false);
- //if ($result === FALSE) { /* Handle error */ }
- //var_dump($result);
- if(isset($_POST['User'])){
- $User = preg_replace('/\s+/', '', $_POST["User"]);
- }else{
- $User = preg_replace('/\s+/', '', $_GET["User"]);
- }
- $sql="SELECT COUNT(id_usuario),nombre,cedula,apellido FROM usuario where mail = '$User'";
- //$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";
- $result=mysqli_query($conn,$sql);
- $row=mysqli_fetch_array($result,MYSQLI_NUM);
- if( $row[0] > 0 ){
- $url2 = "".$row[1]." ".$row[3];
- $url2 = rawurlencode($url2);
- //$url = "http://engines.pressstart.co/alcaldia/preguntas/image2.php?name=".$row[1]."%20".$row[3]."&cc=".$row[2];
- $url = "http://soy10aprende.secretariageneral.gov.co/15305b88b0e5661d5ced334ac50f4335/image.php?name=".$url2."&cc=".$row[2];
- //echo rawurlencode($url);
- $imageData = base64_encode(file_get_contents($url));
- echo '<img src="data:image/jpeg;base64,'.$imageData.'" style="width: 60%;">';
- //echo '<img style="-webkit-user-select: none;cursor: zoom-in;" src="data:image/jpeg;base64,'.$imageData.'" width="414" height="320">';
- //echo '<a href="'.$imageData.'" download>DESCARGAR CERFITICADO</a>';
- /*
- header("Content-Disposition: attachment; filename=\"" . basename($imageData) . "\"");
- header("Content-Type: application/force-download");
- header("Content-Length: " . filesize($imageData));
- header("Connection: close");
- */
- /*
- $image = base64_to_jpeg( $imageData, 'tmp.jpg' );
- header("Content-Disposition: attachment; filename=\"" . basename($image) . "\"");
- header("Content-Type: application/force-download");
- header("Content-Length: " . filesize($image));
- header("Connection: close");
- */
- }
- function base64_to_jpeg($base64_string, $output_file) {
- // open the output file for writing
- $ifp = fopen( $output_file, 'wb' );
- // split the string on commas
- // $data[ 0 ] == "data:image/png;base64"
- // $data[ 1 ] == <actual base64 string>
- $data = explode( ',', $base64_string );
- // we could add validation here with ensuring count( $data ) > 1
- fwrite( $ifp, base64_decode( $data[ 1 ] ) );
- // clean up the file resource
- fclose( $ifp );
- return $output_file;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement