-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
76 lines (64 loc) · 2.36 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
require('scripts/S3.php');
include ('settings.php');
error_reporting(0);
$gyazo_url = 'http://'.$_SERVER['SERVER_NAME'];
//Bitly credentials
$pic=$_GET['pic'];
/* returns the shortened url */
function get_bitly_short_url($url,$login,$appkey,$format='txt') {
$connectURL = 'http://api.bit.ly/v3/shorten/?login='.$login.'&apiKey='.$appkey.'&uri='.urlencode($url).'&format='.$format;
return curl_get_result($connectURL);
}
/* returns a result form url */
function curl_get_result($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//When file is uploaded
if(isset($_FILES['imagedata']['name'])) {
$name = substr(md5(time()), -28).'.'.$company_name.'.png';
//Store it on s3
if ($tempname = $_FILES['imagedata']['tmp_name']){
$s3 = new S3($aws_key,$aws_secret);
$s3->putBucket($aws_bucket, S3::ACL_PUBLIC_READ);
$s3->putObjectFile($tempname, $aws_bucket,$name, S3::ACL_PUBLIC_READ);
// If you use CloudFront change settings:
// $imageu=$aws_site.$aws_bucket.'/'.$name; //we use CloudFront
$imageu=$cloudfront_site.'/'.$name;
//Output file url
if (!$pic){ echo $gyazo_url."?limage=$imageu";}
// if index.php?pic=1 in client is set it will return shorted link
elseif($pic==1){ echo $shorten = get_bitly_short_url($imageu,$bitly_name,$bitly_key);}
// if index.php?pic=2 in client is set it will return full link
elseif($pic==2){ echo $imageu ;}
}
}else {
$limage=$_GET['limage'];
$shorten = get_bitly_short_url($limage,$bitly_name,$bitly_key);
list($width, $height, $type, $attr) = getimagesize($limage);
include ('scripts/html5-canvas-drawing-app.js.php');
echo "<head>
<link rel='shortcut icon' href=$limage>
<link rel='stylesheet' href='styles/style.css'>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js'></script>
<script src='scripts/jquery.zclip.min.js'></script>
<script type='text/javascript' src='scripts/copy.js'></script>
</head>
<span class='wrap'><input id='url1' type='text' value=$shorten> <span class='copy' id='copy1'></span></span>
<hr />
<body>
<div id='canvasDiv'></div>
<script type='text/javascript'> $(document).ready(function() {
prepareCanvas();
});</script>
</body>
";
}
?>