[fix] cosmetics && sec
This commit is contained in:
parent
b95d02c411
commit
f7f6fa25ea
2 changed files with 210 additions and 217 deletions
|
|
@ -5,29 +5,26 @@ $vertical = intval( $_POST['vertical'] );
|
|||
$bgImage = basename( $_POST['bgImage'], ".jpg");
|
||||
$landscape = intval( $_POST['landscape'] );
|
||||
function panic( $msg ){
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
die( $msg );
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
die( $msg );
|
||||
}
|
||||
|
||||
if (strpos($img, 'data:image/png;base64') === 0) {
|
||||
|
||||
$img = str_replace('data:image/png;base64,', '', $img);
|
||||
$img = str_replace(' ', '+', $img);
|
||||
$data = base64_decode($img);
|
||||
$file = __DIR__.'/../a4/'.microtime(true).'_'.$bgImage.".png";
|
||||
|
||||
if ( ! file_put_contents($file, $data)) {
|
||||
panic("Failed to save canvas");
|
||||
}
|
||||
|
||||
$img = str_replace('data:image/png;base64,', '', $img);
|
||||
$img = str_replace(' ', '+', $img);
|
||||
$data = base64_decode($img);
|
||||
$file = __DIR__.'/../a4/'.microtime(true).'_'.$bgImage.".png";
|
||||
if ( ! file_put_contents($file, $data)) {
|
||||
panic("Failed to save canvas");
|
||||
}
|
||||
}else{
|
||||
panic("Not a valid image");
|
||||
panic("Not a valid image");
|
||||
}
|
||||
$output = $return_code = NULL;
|
||||
exec( __DIR__."/../page_generator.sh $file $horizontal $vertical $landscape" , $output, $return_code);
|
||||
exec( __DIR__."/../page_generator.sh ".escapeshellargs($file)." ".escapeshellargs($horizontal)." ".escapeshellargs($vertical)." ".escapeshellargs($landscape) , $output, $return_code);
|
||||
if( 0 === $return_code ){
|
||||
$pdf = basename(implode("", $output));
|
||||
echo( "https://2020.hackersfest.org//ImageGenerator/a4/".urlencode($pdf) );
|
||||
echo( "https://2020.hackersfest.org/ImageGenerator/a4/".urlencode($pdf) );
|
||||
}else{
|
||||
panic( implode(" / ", $output ) );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue