applicious_utils 0.1.25 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/applicious_utils/Plupload/changelog.txt +152 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/bg.jpg +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/custom.html +94 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/dump.php +36 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/jquery/events.html +196 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/jquery/jquery_ui_widget.html +103 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/jquery/queue_widget.html +174 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/jquery/s3.php +158 -0
- data/app/assets/javascripts/applicious_utils/Plupload/examples/upload.php +124 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css +177 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/backgrounds.gif +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/buttons-disabled.png +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/buttons.png +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/delete.gif +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/done.gif +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/error.gif +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/throbber.gif +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/transp50.png +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/jquery.plupload.queue.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css +139 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.ui.plupload/img/plupload-bw.png +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.ui.plupload/img/plupload.png +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.ui.plupload/jquery.ui.plupload.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.browserplus.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.flash.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.flash.swf +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.full.js +2 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.gears.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.html4.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.html5.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.js +2 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.silverlight.js +1 -0
- data/app/assets/javascripts/applicious_utils/Plupload/js/plupload.silverlight.xap +0 -0
- data/app/assets/javascripts/applicious_utils/Plupload/license.txt +339 -0
- data/app/assets/javascripts/applicious_utils/Plupload/readme.md +46 -0
- data/app/assets/javascripts/applicious_utils/index.js +1 -1
- data/applicious_utils.gemspec +2 -1
- data/lib/applicious_utils/engine.rb +2 -0
- data/lib/applicious_utils/uploads_helper.rb +148 -0
- data/lib/applicious_utils/version.rb +1 -1
- data/lib/applicious_utils.rb +11 -2
- data/lib/generators/applicious_uploader_initializer.rb +9 -0
- data/lib/generators/templates/amazon_s3.yml +8 -0
- data/lib/generators/templates/session_store.rb +69 -0
- metadata +41 -14
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/README +0 -70
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/examples/01 - single uploader.html +0 -73
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/examples/02 - multiple uploaders.html +0 -123
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/examples/upload.php +0 -7
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/src/jquery.swfupload.js +0 -64
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/vendor/swfupload/XPButtonUploadText_61x22.png +0 -0
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/vendor/swfupload/swfupload.js +0 -980
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/vendor/swfupload/swfupload.queue.js +0 -99
- data/app/assets/javascripts/applicious_utils/swfupload-jquery/vendor/swfupload/swfupload.swf +0 -0
- data/lib/applicious_utils/applicious_railtie.rb +0 -11
- data/lib/applicious_utils/view_helpers.rb +0 -16
@@ -0,0 +1,174 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
5
|
+
<title>Plupload - Queue widget example</title>
|
6
|
+
<style type="text/css">
|
7
|
+
body {
|
8
|
+
font-family:Verdana, Geneva, sans-serif;
|
9
|
+
font-size:13px;
|
10
|
+
color:#333;
|
11
|
+
background:url(../bg.jpg);
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
<link rel="stylesheet" href="../../js/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" media="screen" />
|
15
|
+
|
16
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
17
|
+
<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
|
18
|
+
|
19
|
+
<script type="text/javascript" src="../../js/plupload.js"></script>
|
20
|
+
<script type="text/javascript" src="../../js/plupload.gears.js"></script>
|
21
|
+
<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>
|
22
|
+
<script type="text/javascript" src="../../js/plupload.flash.js"></script>
|
23
|
+
<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>
|
24
|
+
<script type="text/javascript" src="../../js/plupload.html4.js"></script>
|
25
|
+
<script type="text/javascript" src="../../js/plupload.html5.js"></script>
|
26
|
+
<script type="text/javascript" src="../../js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
27
|
+
|
28
|
+
<!-- <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script> -->
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
|
32
|
+
<form method="post" action="dump.php">
|
33
|
+
<h1>Queue widget example</h1>
|
34
|
+
|
35
|
+
<p>Shows the jQuery Plupload Queue widget and under different runtimes.</p>
|
36
|
+
|
37
|
+
<div style="float: left; margin-right: 20px">
|
38
|
+
<h3>Flash runtime</h3>
|
39
|
+
<div id="flash_uploader" style="width: 450px; height: 330px;">You browser doesn't have Flash installed.</div>
|
40
|
+
|
41
|
+
<h3>Gears runtime</h3>
|
42
|
+
<div id="gears_uploader" style="width: 450px; height: 330px;">You browser doesn't have Gears installed.</div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div style="float: left; margin-right: 20px">
|
46
|
+
<h3>Silverlight runtime</h3>
|
47
|
+
<div id="silverlight_uploader" style="width: 450px; height: 330px;">You browser doesn't have Silverlight installed.</div>
|
48
|
+
|
49
|
+
<h3>HTML 5 runtime</h3>
|
50
|
+
<div id="html5_uploader" style="width: 450px; height: 330px;">You browser doesn't support native upload. Try Firefox 3 or Safari 4.</div>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<div style="float: left; margin-right: 20px">
|
54
|
+
<h3>BrowserPlus runtime</h3>
|
55
|
+
<div id="browserplus_uploader" style="width: 450px; height: 330px;">You browser doesn't have BrowserPlus installed.</div>
|
56
|
+
|
57
|
+
<h3>HTML 4 runtime</h3>
|
58
|
+
<div id="html4_uploader" style="width: 450px; height: 330px;">You browser doesn't have HTML 4 support.</div>
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<br style="clear: both" />
|
62
|
+
|
63
|
+
<input type="submit" value="Send" />
|
64
|
+
</form>
|
65
|
+
|
66
|
+
<script type="text/javascript">
|
67
|
+
$(function() {
|
68
|
+
// Setup flash version
|
69
|
+
$("#flash_uploader").pluploadQueue({
|
70
|
+
// General settings
|
71
|
+
runtimes : 'flash',
|
72
|
+
url : '../upload.php',
|
73
|
+
max_file_size : '10mb',
|
74
|
+
chunk_size : '1mb',
|
75
|
+
unique_names : true,
|
76
|
+
filters : [
|
77
|
+
{title : "Image files", extensions : "jpg,gif,png"},
|
78
|
+
{title : "Zip files", extensions : "zip"}
|
79
|
+
],
|
80
|
+
|
81
|
+
// Resize images on clientside if we can
|
82
|
+
resize : {width : 320, height : 240, quality : 90},
|
83
|
+
|
84
|
+
// Flash settings
|
85
|
+
flash_swf_url : '../../js/plupload.flash.swf'
|
86
|
+
});
|
87
|
+
|
88
|
+
// Setup gears version
|
89
|
+
$("#gears_uploader").pluploadQueue({
|
90
|
+
// General settings
|
91
|
+
runtimes : 'gears',
|
92
|
+
url : 'upload.php',
|
93
|
+
max_file_size : '10mb',
|
94
|
+
chunk_size : '1mb',
|
95
|
+
unique_names : true,
|
96
|
+
filters : [
|
97
|
+
{title : "Image files", extensions : "jpg,gif,png"},
|
98
|
+
{title : "Zip files", extensions : "zip"}
|
99
|
+
],
|
100
|
+
|
101
|
+
// Resize images on clientside if we can
|
102
|
+
resize : {width : 320, height : 240, quality : 90}
|
103
|
+
});
|
104
|
+
|
105
|
+
// Setup silverlight version
|
106
|
+
$("#silverlight_uploader").pluploadQueue({
|
107
|
+
// General settings
|
108
|
+
runtimes : 'silverlight',
|
109
|
+
url : 'upload.php',
|
110
|
+
max_file_size : '10mb',
|
111
|
+
chunk_size : '1mb',
|
112
|
+
unique_names : true,
|
113
|
+
filters : [
|
114
|
+
{title : "Image files", extensions : "jpg,gif,png"},
|
115
|
+
{title : "Zip files", extensions : "zip"}
|
116
|
+
],
|
117
|
+
|
118
|
+
// Resize images on clientside if we can
|
119
|
+
resize : {width : 320, height : 240, quality : 90},
|
120
|
+
|
121
|
+
// Silverlight settings
|
122
|
+
silverlight_xap_url : '../../js/plupload.silverlight.xap'
|
123
|
+
});
|
124
|
+
|
125
|
+
// Setup html5 version
|
126
|
+
$("#html5_uploader").pluploadQueue({
|
127
|
+
// General settings
|
128
|
+
runtimes : 'html5',
|
129
|
+
url : 'upload.php',
|
130
|
+
max_file_size : '10mb',
|
131
|
+
chunk_size : '1mb',
|
132
|
+
unique_names : true,
|
133
|
+
filters : [
|
134
|
+
{title : "Image files", extensions : "jpg,gif,png"},
|
135
|
+
{title : "Zip files", extensions : "zip"}
|
136
|
+
],
|
137
|
+
|
138
|
+
// Resize images on clientside if we can
|
139
|
+
resize : {width : 320, height : 240, quality : 90}
|
140
|
+
});
|
141
|
+
|
142
|
+
// Setup browserplus version
|
143
|
+
$("#browserplus_uploader").pluploadQueue({
|
144
|
+
// General settings
|
145
|
+
runtimes : 'browserplus',
|
146
|
+
url : 'upload.php',
|
147
|
+
max_file_size : '10mb',
|
148
|
+
chunk_size : '1mb',
|
149
|
+
unique_names : true,
|
150
|
+
filters : [
|
151
|
+
{title : "Image files", extensions : "jpg,gif,png"},
|
152
|
+
{title : "Zip files", extensions : "zip"}
|
153
|
+
],
|
154
|
+
|
155
|
+
// Resize images on clientside if we can
|
156
|
+
resize : {width : 320, height : 240, quality : 90}
|
157
|
+
});
|
158
|
+
|
159
|
+
// Setup html4 version
|
160
|
+
$("#html4_uploader").pluploadQueue({
|
161
|
+
// General settings
|
162
|
+
runtimes : 'html4',
|
163
|
+
url : 'upload.php',
|
164
|
+
unique_names : true,
|
165
|
+
filters : [
|
166
|
+
{title : "Image files", extensions : "jpg,gif,png"},
|
167
|
+
{title : "Zip files", extensions : "zip"}
|
168
|
+
]
|
169
|
+
});
|
170
|
+
});
|
171
|
+
</script>
|
172
|
+
|
173
|
+
</body>
|
174
|
+
</html>
|
@@ -0,0 +1,158 @@
|
|
1
|
+
<?php
|
2
|
+
/*
|
3
|
+
In order to upload files to S3 using Flash runtime, one should start by placing crossdomain.xml into the bucket.
|
4
|
+
crossdomain.xml can be as simple as this:
|
5
|
+
|
6
|
+
<?xml version="1.0"?>
|
7
|
+
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
|
8
|
+
<cross-domain-policy>
|
9
|
+
<allow-access-from domain="*" secure="false" />
|
10
|
+
</cross-domain-policy>
|
11
|
+
|
12
|
+
In our tests SilverLight didn't require anything special and worked with this configuration just fine. It may fail back
|
13
|
+
to the same crossdomain.xml as last resort.
|
14
|
+
|
15
|
+
!!!Important!!! Plupload UI Widget here, is used only for demo purposes and is not required for uploading to S3.
|
16
|
+
*/
|
17
|
+
|
18
|
+
// important variables that will be used throughout this example
|
19
|
+
$bucket = 'BUCKET';
|
20
|
+
|
21
|
+
// these can be found on your Account page, under Security Credentials > Access Keys
|
22
|
+
$accessKeyId = 'ACCESS_KEY_ID';
|
23
|
+
$secret = 'SECRET_ACCESS_KEY';
|
24
|
+
|
25
|
+
|
26
|
+
// hash_hmac — Generate a keyed hash value using the HMAC method
|
27
|
+
// (PHP 5 >= 5.1.2, PECL hash >= 1.1)
|
28
|
+
if (!function_exists('hash_hmac')) :
|
29
|
+
// based on: http://www.php.net/manual/en/function.sha1.php#39492
|
30
|
+
function hash_hmac($algo, $data, $key, $raw_output = false)
|
31
|
+
{
|
32
|
+
$blocksize = 64;
|
33
|
+
if (strlen($key) > $blocksize)
|
34
|
+
$key = pack('H*', $algo($key));
|
35
|
+
|
36
|
+
$key = str_pad($key, $blocksize, chr(0x00));
|
37
|
+
$ipad = str_repeat(chr(0x36), $blocksize);
|
38
|
+
$opad = str_repeat(chr(0x5c), $blocksize);
|
39
|
+
$hmac = pack('H*', $algo(($key^$opad) . pack('H*', $algo(($key^$ipad) . $data))));
|
40
|
+
|
41
|
+
return $raw_output ? $hmac : bin2hex($hmac);
|
42
|
+
}
|
43
|
+
endif;
|
44
|
+
|
45
|
+
// prepare policy
|
46
|
+
$policy = base64_encode(json_encode(array(
|
47
|
+
// ISO 8601 - date('c'); generates uncompatible date, so better do it manually
|
48
|
+
'expiration' => date('Y-m-d\TH:i:s.000\Z', strtotime('+1 day')),
|
49
|
+
'conditions' => array(
|
50
|
+
array('bucket' => $bucket),
|
51
|
+
array('acl' => 'public-read'),
|
52
|
+
array('starts-with', '$key', ''),
|
53
|
+
// for demo purposes we are accepting only images
|
54
|
+
array('starts-with', '$Content-Type', 'image/'),
|
55
|
+
// "Some versions of the Adobe Flash Player do not properly handle HTTP responses that have an empty body.
|
56
|
+
// To configure POST to return a response that does not have an empty body, set success_action_status to 201.
|
57
|
+
// When set, Amazon S3 returns an XML document with a 201 status code."
|
58
|
+
// http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTFlash.html
|
59
|
+
array('success_action_status' => '201'),
|
60
|
+
// Plupload internally adds name field, so we need to mention it here
|
61
|
+
array('starts-with', '$name', ''),
|
62
|
+
// One more field to take into account: Filename - gets silently sent by FileReference.upload() in Flash
|
63
|
+
// http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTFlash.html
|
64
|
+
array('starts-with', '$Filename', ''),
|
65
|
+
)
|
66
|
+
)));
|
67
|
+
|
68
|
+
// sign policy
|
69
|
+
$signature = base64_encode(hash_hmac('sha1', $policy, $secret, true));
|
70
|
+
|
71
|
+
?>
|
72
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
73
|
+
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
|
74
|
+
<head>
|
75
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
76
|
+
<title>Plupload to Amazon S3 Example</title>
|
77
|
+
|
78
|
+
<style type="text/css">
|
79
|
+
body {
|
80
|
+
font-family:Verdana, Geneva, sans-serif;
|
81
|
+
font-size:13px;
|
82
|
+
color:#333;
|
83
|
+
background:url(../bg.jpg);
|
84
|
+
}
|
85
|
+
</style>
|
86
|
+
|
87
|
+
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
|
88
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
89
|
+
<script src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
|
90
|
+
|
91
|
+
<!-- Load plupload and all it's runtimes and finally the UI widget -->
|
92
|
+
<link rel="stylesheet" href="../../js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />
|
93
|
+
|
94
|
+
<script type="text/javascript" src="../../js/plupload.js"></script>
|
95
|
+
<script type="text/javascript" src="../../js/plupload.gears.js"></script>
|
96
|
+
<script type="text/javascript" src="../../js/plupload.silverlight.js"></script>
|
97
|
+
<script type="text/javascript" src="../../js/plupload.flash.js"></script>
|
98
|
+
<script type="text/javascript" src="../../js/plupload.browserplus.js"></script>
|
99
|
+
<script type="text/javascript" src="../../js/plupload.html4.js"></script>
|
100
|
+
<script type="text/javascript" src="../../js/plupload.html5.js"></script>
|
101
|
+
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
|
102
|
+
<!--<script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script>-->
|
103
|
+
|
104
|
+
</head>
|
105
|
+
<body>
|
106
|
+
|
107
|
+
<h1>Plupload to Amazon S3 Example</h1>
|
108
|
+
|
109
|
+
<div id="uploader">
|
110
|
+
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<script type="text/javascript">
|
114
|
+
// Convert divs to queue widgets when the DOM is ready
|
115
|
+
$(function() {
|
116
|
+
$("#uploader").plupload({
|
117
|
+
runtimes : 'flash,silverlight',
|
118
|
+
url : 'http://<?php echo $bucket; ?>.s3.amazonaws.com/',
|
119
|
+
max_file_size : '10mb',
|
120
|
+
|
121
|
+
multipart: true,
|
122
|
+
multipart_params: {
|
123
|
+
'key': '${filename}', // use filename as a key
|
124
|
+
'Filename': '${filename}', // adding this to keep consistency across the runtimes
|
125
|
+
'acl': 'public-read',
|
126
|
+
'Content-Type': 'image/jpeg',
|
127
|
+
'success_action_status': '201',
|
128
|
+
'AWSAccessKeyId' : '<?php echo $accessKeyId; ?>',
|
129
|
+
'policy': '<?php echo $policy; ?>',
|
130
|
+
'signature': '<?php echo $signature; ?>'
|
131
|
+
},
|
132
|
+
|
133
|
+
// !!!Important!!!
|
134
|
+
// this is not recommended with S3, since it will force Flash runtime into the mode, with no progress indication
|
135
|
+
//resize : {width : 800, height : 600, quality : 60}, // Resize images on clientside, if possible
|
136
|
+
|
137
|
+
// optional, but better be specified directly
|
138
|
+
file_data_name: 'file',
|
139
|
+
|
140
|
+
// re-use widget (not related to S3, but to Plupload UI Widget)
|
141
|
+
multiple_queues: true,
|
142
|
+
|
143
|
+
// Specify what files to browse for
|
144
|
+
filters : [
|
145
|
+
{title : "JPEG files", extensions : "jpg"}
|
146
|
+
],
|
147
|
+
|
148
|
+
// Flash settings
|
149
|
+
flash_swf_url : '../../js/plupload.flash.swf',
|
150
|
+
|
151
|
+
// Silverlight settings
|
152
|
+
silverlight_xap_url : '../../js/plupload.silverlight.xap'
|
153
|
+
});
|
154
|
+
});
|
155
|
+
</script>
|
156
|
+
|
157
|
+
</body>
|
158
|
+
</html>
|
@@ -0,0 +1,124 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* upload.php
|
4
|
+
*
|
5
|
+
* Copyright 2009, Moxiecode Systems AB
|
6
|
+
* Released under GPL License.
|
7
|
+
*
|
8
|
+
* License: http://www.plupload.com/license
|
9
|
+
* Contributing: http://www.plupload.com/contributing
|
10
|
+
*/
|
11
|
+
|
12
|
+
// HTTP headers for no cache etc
|
13
|
+
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
14
|
+
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
15
|
+
header("Cache-Control: no-store, no-cache, must-revalidate");
|
16
|
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
17
|
+
header("Pragma: no-cache");
|
18
|
+
|
19
|
+
// Settings
|
20
|
+
//$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
21
|
+
$targetDir = 'uploads/';
|
22
|
+
|
23
|
+
//$cleanupTargetDir = false; // Remove old files
|
24
|
+
//$maxFileAge = 60 * 60; // Temp file age in seconds
|
25
|
+
|
26
|
+
// 5 minutes execution time
|
27
|
+
@set_time_limit(5 * 60);
|
28
|
+
|
29
|
+
// Uncomment this one to fake upload time
|
30
|
+
// usleep(5000);
|
31
|
+
|
32
|
+
// Get parameters
|
33
|
+
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
|
34
|
+
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
|
35
|
+
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
|
36
|
+
|
37
|
+
// Clean the fileName for security reasons
|
38
|
+
$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
39
|
+
|
40
|
+
// Make sure the fileName is unique but only if chunking is disabled
|
41
|
+
if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
|
42
|
+
$ext = strrpos($fileName, '.');
|
43
|
+
$fileName_a = substr($fileName, 0, $ext);
|
44
|
+
$fileName_b = substr($fileName, $ext);
|
45
|
+
|
46
|
+
$count = 1;
|
47
|
+
while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b))
|
48
|
+
$count++;
|
49
|
+
|
50
|
+
$fileName = $fileName_a . '_' . $count . $fileName_b;
|
51
|
+
}
|
52
|
+
|
53
|
+
// Create target dir
|
54
|
+
if (!file_exists($targetDir))
|
55
|
+
@mkdir($targetDir);
|
56
|
+
|
57
|
+
// Remove old temp files
|
58
|
+
/* this doesn't really work by now
|
59
|
+
|
60
|
+
if (is_dir($targetDir) && ($dir = opendir($targetDir))) {
|
61
|
+
while (($file = readdir($dir)) !== false) {
|
62
|
+
$filePath = $targetDir . DIRECTORY_SEPARATOR . $file;
|
63
|
+
|
64
|
+
// Remove temp files if they are older than the max age
|
65
|
+
if (preg_match('/\\.tmp$/', $file) && (filemtime($filePath) < time() - $maxFileAge))
|
66
|
+
@unlink($filePath);
|
67
|
+
}
|
68
|
+
|
69
|
+
closedir($dir);
|
70
|
+
} else
|
71
|
+
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
|
72
|
+
*/
|
73
|
+
|
74
|
+
// Look for the content type header
|
75
|
+
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
|
76
|
+
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
|
77
|
+
|
78
|
+
if (isset($_SERVER["CONTENT_TYPE"]))
|
79
|
+
$contentType = $_SERVER["CONTENT_TYPE"];
|
80
|
+
|
81
|
+
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
|
82
|
+
if (strpos($contentType, "multipart") !== false) {
|
83
|
+
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
|
84
|
+
// Open temp file
|
85
|
+
$out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
|
86
|
+
if ($out) {
|
87
|
+
// Read binary input stream and append it to temp file
|
88
|
+
$in = fopen($_FILES['file']['tmp_name'], "rb");
|
89
|
+
|
90
|
+
if ($in) {
|
91
|
+
while ($buff = fread($in, 4096))
|
92
|
+
fwrite($out, $buff);
|
93
|
+
} else
|
94
|
+
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
|
95
|
+
fclose($in);
|
96
|
+
fclose($out);
|
97
|
+
@unlink($_FILES['file']['tmp_name']);
|
98
|
+
} else
|
99
|
+
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
|
100
|
+
} else
|
101
|
+
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
|
102
|
+
} else {
|
103
|
+
// Open temp file
|
104
|
+
$out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
|
105
|
+
if ($out) {
|
106
|
+
// Read binary input stream and append it to temp file
|
107
|
+
$in = fopen("php://input", "rb");
|
108
|
+
|
109
|
+
if ($in) {
|
110
|
+
while ($buff = fread($in, 4096))
|
111
|
+
fwrite($out, $buff);
|
112
|
+
} else
|
113
|
+
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
|
114
|
+
|
115
|
+
fclose($in);
|
116
|
+
fclose($out);
|
117
|
+
} else
|
118
|
+
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
|
119
|
+
}
|
120
|
+
|
121
|
+
// Return JSON-RPC response
|
122
|
+
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
|
123
|
+
|
124
|
+
?>
|
@@ -0,0 +1,177 @@
|
|
1
|
+
/*
|
2
|
+
Plupload
|
3
|
+
------------------------------------------------------------------- */
|
4
|
+
|
5
|
+
.plupload_button {
|
6
|
+
display: -moz-inline-box; /* FF < 3*/
|
7
|
+
display: inline-block;
|
8
|
+
font: normal 12px sans-serif;
|
9
|
+
text-decoration: none;
|
10
|
+
color: #42454a;
|
11
|
+
border: 1px solid #bababa;
|
12
|
+
padding: 2px 8px 3px 20px;
|
13
|
+
margin-right: 4px;
|
14
|
+
background: #f3f3f3 url('../img/buttons.png') no-repeat 0 center;
|
15
|
+
outline: 0;
|
16
|
+
|
17
|
+
/* Optional rounded corners for browsers that support it */
|
18
|
+
-moz-border-radius: 3px;
|
19
|
+
-khtml-border-radius: 3px;
|
20
|
+
-webkit-border-radius: 3px;
|
21
|
+
border-radius: 3px;
|
22
|
+
}
|
23
|
+
|
24
|
+
.plupload_button:hover {
|
25
|
+
color: #000;
|
26
|
+
text-decoration: none;
|
27
|
+
}
|
28
|
+
|
29
|
+
.plupload_disabled, a.plupload_disabled:hover {
|
30
|
+
color: #737373;
|
31
|
+
border-color: #c5c5c5;
|
32
|
+
background: #ededed url('../img/buttons-disabled.png') no-repeat 0 center;
|
33
|
+
cursor: default;
|
34
|
+
}
|
35
|
+
|
36
|
+
.plupload_add {
|
37
|
+
background-position: -181px center;
|
38
|
+
}
|
39
|
+
|
40
|
+
.plupload_wrapper {
|
41
|
+
font: normal 11px Verdana,sans-serif;
|
42
|
+
width: 100%;
|
43
|
+
}
|
44
|
+
|
45
|
+
.plupload_container {
|
46
|
+
padding: 8px;
|
47
|
+
background: url('../img/transp50.png');
|
48
|
+
/*-moz-border-radius: 5px;*/
|
49
|
+
}
|
50
|
+
|
51
|
+
.plupload_container input {
|
52
|
+
border: 1px solid #DDD;
|
53
|
+
font: normal 11px Verdana,sans-serif;
|
54
|
+
width: 98%;
|
55
|
+
}
|
56
|
+
|
57
|
+
.plupload_header {background: #2A2C2E url('../img/backgrounds.gif') repeat-x;}
|
58
|
+
.plupload_header_content {
|
59
|
+
background: url('../img/backgrounds.gif') no-repeat 0 -317px;
|
60
|
+
min-height: 56px;
|
61
|
+
padding-left: 60px;
|
62
|
+
color: #FFF;
|
63
|
+
}
|
64
|
+
.plupload_header_title {
|
65
|
+
font: normal 18px sans-serif;
|
66
|
+
padding: 6px 0 3px;
|
67
|
+
}
|
68
|
+
.plupload_header_text {
|
69
|
+
font: normal 12px sans-serif;
|
70
|
+
}
|
71
|
+
|
72
|
+
.plupload_filelist {
|
73
|
+
margin: 0;
|
74
|
+
padding: 0;
|
75
|
+
list-style: none;
|
76
|
+
}
|
77
|
+
|
78
|
+
.plupload_scroll .plupload_filelist {
|
79
|
+
height: 185px;
|
80
|
+
background: #F5F5F5;
|
81
|
+
overflow-y: scroll;
|
82
|
+
}
|
83
|
+
|
84
|
+
.plupload_filelist li {
|
85
|
+
padding: 10px 8px;
|
86
|
+
background: #F5F5F5 url('../img/backgrounds.gif') repeat-x 0 -156px;
|
87
|
+
border-bottom: 1px solid #DDD;
|
88
|
+
}
|
89
|
+
|
90
|
+
.plupload_filelist_header, .plupload_filelist_footer {
|
91
|
+
background: #DFDFDF;
|
92
|
+
padding: 8px 8px;
|
93
|
+
color: #42454A;
|
94
|
+
}
|
95
|
+
.plupload_filelist_header {
|
96
|
+
border-top: 1px solid #EEE;
|
97
|
+
border-bottom: 1px solid #CDCDCD;
|
98
|
+
}
|
99
|
+
|
100
|
+
.plupload_filelist_footer {border-top: 1px solid #FFF; height: 22px; line-height: 20px; vertical-align: middle;}
|
101
|
+
.plupload_file_name {float: left; overflow: hidden}
|
102
|
+
.plupload_file_status {color: #777;}
|
103
|
+
.plupload_file_status span {color: #42454A;}
|
104
|
+
.plupload_file_size, .plupload_file_status, .plupload_progress {
|
105
|
+
float: right;
|
106
|
+
width: 80px;
|
107
|
+
}
|
108
|
+
.plupload_file_size, .plupload_file_status, .plupload_file_action {text-align: right;}
|
109
|
+
|
110
|
+
.plupload_filelist .plupload_file_name {width: 205px}
|
111
|
+
|
112
|
+
.plupload_file_action {
|
113
|
+
float: right;
|
114
|
+
width: 16px;
|
115
|
+
height: 16px;
|
116
|
+
margin-left: 15px;
|
117
|
+
}
|
118
|
+
|
119
|
+
.plupload_file_action * {
|
120
|
+
display: none;
|
121
|
+
width: 16px;
|
122
|
+
height: 16px;
|
123
|
+
}
|
124
|
+
|
125
|
+
li.plupload_uploading {background: #ECF3DC url('../img/backgrounds.gif') repeat-x 0 -238px;}
|
126
|
+
li.plupload_done {color:#AAA}
|
127
|
+
|
128
|
+
li.plupload_delete a {
|
129
|
+
background: url('../img/delete.gif');
|
130
|
+
}
|
131
|
+
|
132
|
+
li.plupload_failed a {
|
133
|
+
background: url('../img/error.gif');
|
134
|
+
cursor: default;
|
135
|
+
}
|
136
|
+
|
137
|
+
li.plupload_done a {
|
138
|
+
background: url('../img/done.gif');
|
139
|
+
cursor: default;
|
140
|
+
}
|
141
|
+
|
142
|
+
.plupload_progress, .plupload_upload_status {
|
143
|
+
display: none;
|
144
|
+
}
|
145
|
+
|
146
|
+
.plupload_progress_container {
|
147
|
+
margin-top: 3px;
|
148
|
+
border: 1px solid #CCC;
|
149
|
+
background: #FFF;
|
150
|
+
padding: 1px;
|
151
|
+
}
|
152
|
+
.plupload_progress_bar {
|
153
|
+
width: 0px;
|
154
|
+
height: 7px;
|
155
|
+
background: #CDEB8B;
|
156
|
+
}
|
157
|
+
|
158
|
+
.plupload_scroll .plupload_filelist_header .plupload_file_action, .plupload_scroll .plupload_filelist_footer .plupload_file_action {
|
159
|
+
margin-right: 17px;
|
160
|
+
}
|
161
|
+
|
162
|
+
/* Floats */
|
163
|
+
|
164
|
+
.plupload_clear,.plupload_clearer {clear: both;}
|
165
|
+
.plupload_clearer, .plupload_progress_bar {
|
166
|
+
display: block;
|
167
|
+
font-size: 0;
|
168
|
+
line-height: 0;
|
169
|
+
}
|
170
|
+
|
171
|
+
li.plupload_droptext {
|
172
|
+
background: transparent;
|
173
|
+
text-align: center;
|
174
|
+
vertical-align: middle;
|
175
|
+
border: 0;
|
176
|
+
line-height: 165px;
|
177
|
+
}
|
data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/backgrounds.gif
ADDED
Binary file
|
Binary file
|
data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/buttons.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/throbber.gif
ADDED
Binary file
|
data/app/assets/javascripts/applicious_utils/Plupload/js/jquery.plupload.queue/img/transp50.png
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(c){var d={};function a(e){return plupload.translate(e)||e}function b(f,e){e.contents().each(function(g,h){h=c(h);if(!h.is(".plupload")){h.remove()}});e.prepend('<div class="plupload_wrapper plupload_scroll"><div id="'+f+'_container" class="plupload_container"><div class="plupload"><div class="plupload_header"><div class="plupload_header_content"><div class="plupload_header_title">'+a("Select files")+'</div><div class="plupload_header_text">'+a("Add files to the upload queue and click the start button.")+'</div></div></div><div class="plupload_content"><div class="plupload_filelist_header"><div class="plupload_file_name">'+a("Filename")+'</div><div class="plupload_file_action"> </div><div class="plupload_file_status"><span>'+a("Status")+'</span></div><div class="plupload_file_size">'+a("Size")+'</div><div class="plupload_clearer"> </div></div><ul id="'+f+'_filelist" class="plupload_filelist"></ul><div class="plupload_filelist_footer"><div class="plupload_file_name"><div class="plupload_buttons"><a href="#" class="plupload_button plupload_add">'+a("Add files")+'</a><a href="#" class="plupload_button plupload_start">'+a("Start upload")+'</a></div><span class="plupload_upload_status"></span></div><div class="plupload_file_action"></div><div class="plupload_file_status"><span class="plupload_total_status">0%</span></div><div class="plupload_file_size"><span class="plupload_total_file_size">0 b</span></div><div class="plupload_progress"><div class="plupload_progress_container"><div class="plupload_progress_bar"></div></div></div><div class="plupload_clearer"> </div></div></div></div></div><input type="hidden" id="'+f+'_count" name="'+f+'_count" value="0" /></div>')}c.fn.pluploadQueue=function(e){if(e){this.each(function(){var j,i,k;i=c(this);k=i.attr("id");if(!k){k=plupload.guid();i.attr("id",k)}j=new plupload.Uploader(c.extend({dragdrop:true,container:k},e));d[k]=j;function h(l){var n;if(l.status==plupload.DONE){n="plupload_done"}if(l.status==plupload.FAILED){n="plupload_failed"}if(l.status==plupload.QUEUED){n="plupload_delete"}if(l.status==plupload.UPLOADING){n="plupload_uploading"}var m=c("#"+l.id).attr("class",n).find("a").css("display","block");if(l.hint){m.attr("title",l.hint)}}function f(){c("span.plupload_total_status",i).html(j.total.percent+"%");c("div.plupload_progress_bar",i).css("width",j.total.percent+"%");c("span.plupload_upload_status",i).text(a("Uploaded %d/%d files").replace(/%d\/%d/,j.total.uploaded+"/"+j.files.length))}function g(){var m=c("ul.plupload_filelist",i).html(""),n=0,l;c.each(j.files,function(p,o){l="";if(o.status==plupload.DONE){if(o.target_name){l+='<input type="hidden" name="'+k+"_"+n+'_tmpname" value="'+plupload.xmlEncode(o.target_name)+'" />'}l+='<input type="hidden" name="'+k+"_"+n+'_name" value="'+plupload.xmlEncode(o.name)+'" />';l+='<input type="hidden" name="'+k+"_"+n+'_status" value="'+(o.status==plupload.DONE?"done":"failed")+'" />';n++;c("#"+k+"_count").val(n)}m.append('<li id="'+o.id+'"><div class="plupload_file_name"><span>'+o.name+'</span></div><div class="plupload_file_action"><a href="#"></a></div><div class="plupload_file_status">'+o.percent+'%</div><div class="plupload_file_size">'+plupload.formatSize(o.size)+'</div><div class="plupload_clearer"> </div>'+l+"</li>");h(o);c("#"+o.id+".plupload_delete a").click(function(q){c("#"+o.id).remove();j.removeFile(o);q.preventDefault()})});c("span.plupload_total_file_size",i).html(plupload.formatSize(j.total.size));if(j.total.queued===0){c("span.plupload_add_text",i).text(a("Add files."))}else{c("span.plupload_add_text",i).text(j.total.queued+" files queued.")}c("a.plupload_start",i).toggleClass("plupload_disabled",j.files.length==(j.total.uploaded+j.total.failed));m[0].scrollTop=m[0].scrollHeight;f();if(!j.files.length&&j.features.dragdrop&&j.settings.dragdrop){c("#"+k+"_filelist").append('<li class="plupload_droptext">'+a("Drag files here.")+"</li>")}}j.bind("UploadFile",function(l,m){c("#"+m.id).addClass("plupload_current_file")});j.bind("Init",function(l,m){b(k,i);if(!e.unique_names&&e.rename){c("#"+k+"_filelist div.plupload_file_name span",i).live("click",function(s){var q=c(s.target),o,r,n,p="";o=l.getFile(q.parents("li")[0].id);n=o.name;r=/^(.+)(\.[^.]+)$/.exec(n);if(r){n=r[1];p=r[2]}q.hide().after('<input type="text" />');q.next().val(n).focus().blur(function(){q.show().next().remove()}).keydown(function(u){var t=c(this);if(u.keyCode==13){u.preventDefault();o.name=t.val()+p;q.text(o.name);t.blur()}})})}c("a.plupload_add",i).attr("id",k+"_browse");l.settings.browse_button=k+"_browse";if(l.features.dragdrop&&l.settings.dragdrop){l.settings.drop_element=k+"_filelist";c("#"+k+"_filelist").append('<li class="plupload_droptext">'+a("Drag files here.")+"</li>")}c("#"+k+"_container").attr("title","Using runtime: "+m.runtime);c("a.plupload_start",i).click(function(n){if(!c(this).hasClass("plupload_disabled")){j.start()}n.preventDefault()});c("a.plupload_stop",i).click(function(n){n.preventDefault();j.stop()});c("a.plupload_start",i).addClass("plupload_disabled")});j.init();j.bind("Error",function(l,o){var m=o.file,n;if(m){n=o.message;if(o.details){n+=" ("+o.details+")"}if(o.code==plupload.FILE_SIZE_ERROR){alert(a("Error: File to large: ")+m.name)}if(o.code==plupload.FILE_EXTENSION_ERROR){alert(a("Error: Invalid file extension: ")+m.name)}m.hint=n;c("#"+m.id).attr("class","plupload_failed").find("a").css("display","block").attr("title",n)}});j.bind("StateChanged",function(){if(j.state===plupload.STARTED){c("li.plupload_delete a,div.plupload_buttons",i).hide();c("span.plupload_upload_status,div.plupload_progress,a.plupload_stop",i).css("display","block");c("span.plupload_upload_status",i).text("Uploaded "+j.total.uploaded+"/"+j.files.length+" files");if(e.multiple_queues){c("span.plupload_total_status,span.plupload_total_file_size",i).show()}}else{g();c("a.plupload_stop,div.plupload_progress",i).hide();c("a.plupload_delete",i).css("display","block")}});j.bind("QueueChanged",g);j.bind("FileUploaded",function(l,m){h(m)});j.bind("UploadProgress",function(l,m){c("#"+m.id+" div.plupload_file_status",i).html(m.percent+"%");h(m);f();if(e.multiple_queues&&j.total.uploaded+j.total.failed==j.files.length){c(".plupload_buttons,.plupload_upload_status",i).css("display","inline");c(".plupload_start",i).addClass("plupload_disabled");c("span.plupload_total_status,span.plupload_total_file_size",i).hide()}});if(e.setup){e.setup(j)}});return this}else{return d[c(this[0]).attr("id")]}}})(jQuery);
|