Last active
January 2, 2016 17:59
-
-
Save synchrone/8340425 to your computer and use it in GitHub Desktop.
Gyazo hosting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { #generic php-fpm setup, really | |
server_name i; | |
root /var/www/i/www; | |
client_max_body_size 20m; | |
index index.php index.htm index.html; | |
location ~ ^.+\.php$ { | |
if ( -f $document_root/../maintenance) { | |
return 503; | |
} | |
#fastcgi_pass 127.0.0.1:9000; | |
#or | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
include fastcgi_params; | |
fastcgi_index index.php; | |
fastcgi_split_path_info ^(.+\.php)(.*)$; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; | |
} | |
location / { | |
try_files $uri $uri/ /index.php; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_FILES['imagedata'])){ | |
$storage = 'i/'; | |
$ext = 'png'; | |
$id=sha1(file_get_contents($_FILES['imagedata']['tmp_name'])); | |
move_uploaded_file($_FILES['imagedata']['tmp_name'],sprintf('%s%s.%s',$storage,$id,$ext)); | |
$url = sprintf('http://%s/i/%s.%s',$_SERVER["HTTP_HOST"],$id,$ext); | |
if(strpos($_SERVER["HTTP_USER_AGENT"],'Gyazo')!==false){ | |
echo $url; | |
}else{ | |
header('Location: '.$url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment