-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
128 lines (111 loc) · 3.22 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
require('files/cloudfiles.php');
//Bitly credentials
$bitly_name='##Bitly_name';
$bitly_key='##Bitly_key';
$gyazo_url = 'http://'.$_SERVER['SERVER_NAME'];
$company_name='my_company';
//Rackspace Credentials
$username='##Rackspace_UN';
$key='##Rackspace_key';
$container='##Rackspace_container';
/* 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 Rackspace
if ($tempname = $_FILES['imagedata']['tmp_name']){
$auth = new CF_Authentication($username, $key);
$auth->authenticate();
$conn = new CF_Connection($auth);
$container = $conn->create_container($container);
$object = $container->create_object($name);
$object->load_from_filename($tempname);
$fileuri = $container->make_public();
$imageu = $object->public_uri();
//Output file url
echo $gyazo_url."?limage=$imageu";
}
}else {
$limage=$_GET['limage'];
$shorten = get_bitly_short_url($limage,$bitly_name,$bitly_key);
echo "<head>
<link rel='shortcut icon' href=$limage>
</head>
<style type='text/css'>
#url1, #url2 {
width:150px;
}
#url2 {
}
.copy {
display:inline-block;
height:16px;
width:16px;
background:url(files/copy.png);
position:relative;
top:3px;
}
.copy:hover {
opacity:0.5;
cursor:pointer;
}
.copied {
display:inline-block;
height:16px;
width:16px;
background:url(files/copied.png);
position:relative;
top:3px;
margin-left:5px;
}
.wrap {
display:block;
width:300px;
}
</style>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script src='files/jquery.zclip.min.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('#copy1').zclip({
path:'files/ZeroClipboard.swf',
copy:$('#url1').val(),
afterCopy:function(){
$(this).after('<span class=copied></span>');
$(this).next('.copied').fadeOut('slow');
},
});
$('#copy2').zclip({
path:'files/ZeroClipboard.swf',
copy:$('#url2').val(),
afterCopy:function(){
$(this).after('<span class=copied></span>');
$(this).next('.copied').fadeOut('slow');
},
});
$('#url1, #url2').click(function(){
$(this).select();
});
});
</script>
<span class='wrap'><input id='url1' type='text' value=$shorten> <span class='copy' id='copy1'></span></span>
<hr />
<img src=$limage>";
}
?>