-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupload_file.php
167 lines (148 loc) · 6.57 KB
/
upload_file.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE HTML>
<!-- ............................. -->
<!-- ............................. -->
<!-- ..... LIQUID GEM V.1.0. ..... -->
<!-- ............................. -->
<!-- ............................. -->
<!-- ............................. -->
<!-- ............................. -->
<!-- .... MADE BY CHRIS BIRON .... -->
<!-- ............................. -->
<!-- ............................. -->
<!-- ............................. -->
<!-- ............................. -->
<!-- Liquid Gem is licensed under
Creative Commons
Attribution-NonCommercial-ShareAlike
3.0 Unported License -->
<!-- ............................. -->
<!-- ............................. -->
<!-- DON'T TOUCH THIS SECTION -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- END OF DON'T TOUCH -->
<!-- Website Title -->
<title>The #Tweets4Science initiative</title>
<!-- END OF Website Title -->
<!-- Website description - Change the 'content' section to whatever you want -->
<meta name="description" content="#Tweets4Science: A Manifesto - We ask you to donate your tweets for research purposes. We will not profit from your information. We will share the collection of donated tweets with anybody interested in research in social media under a Creative Commons license.">
<!-- END OF Website description -->
<!-- DON'T TOUCH THIS SECTION -->
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700|Cookie' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Gentium+Book+Basic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,600&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="scripts/jquery.carouFredSel-5.5.2.js" type="text/javascript"></script>
<script type="text/javascript" src="scripts/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="scripts/jquery.form.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>
</head>
<!-- END OF DON'T TOUCH -->
<body>
<div class="wrapper">
<div id="top">
<div id="logo">
<h1 id="logotitle">#Tweets4Science</h1> <!-- Logo text -->
</div><!--/logo-->
<nav> <!-- Navigation Start -->
<ul>
<li><a href="index.html">Home</a></li>
</ul>
</nav> <!-- Navigation End -->
</div><!--/top-->
<hr/><!-- Horizontal Line -->
<section id="slideshow"> <!-- Slideshow Start -->
<div class="html_carousel">
<div id="slider">
<div class="slide">
<img src="images/tweets4science-banner.png" width="3000" height="783" alt="image 1"/><!-- Replace these images with your own but make sure they are 3000px wide and 783px high or the same ration -->
</div><!--/slide-->
</div><!--/slider-->
<div class="clearfix"></div>
</div><!--/html_carousel-->
</section> <!-- Slideshow End -->
<aside id="message" class="wide2">
<h3>
<!-------------------------------------------------------------->
<?php
include_once('userid.inc');
$allowedExts = array("zip");
$maxFileSize=20*1024*1024;
$extension = end(explode(".", $_FILES["file"]["name"]));
if (/*($_FILES["file"]["type"] == "application/zip") && */ ($_FILES["file"]["size"] < $maxFileSize) && in_array($extension, $allowedExts)){
if ($_FILES["file"]["error"] > 0){
echo "Return Code: " . $_FILES["file"]["error"];
}else{
$extensionKey = array_search($extension, $allowedExts);
$userInfo = getUserFromTweetsZIP($_FILES["file"]["tmp_name"]);//md5(file_get_contents($_FILES["file"]["tmp_name"])).".".$allowedExts[$extensionKey];
if($userInfo === false){
echo "Something wrong happened with the file. Please make sure you are uploading the file called <tt>tweets.zip</tt> obtained from Twitter, without modifications.";
}else{
$newname = $userInfo['id'].".".$allowedExts[$extensionKey];
if (file_exists("upload/" . $newname)){
echo "This file already exists. File successfully updated";
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $newname);
}
else{
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $newname);
echo "Successfully stored. Thank you!";
$myFile = "upload/CONTRIBUTORS";
$fh = fopen($myFile, 'a');
if (flock($fh, LOCK_EX)) {
fwrite($fh, "@".$userInfo['screen_name']."\n");
fflush($fh);
flock($fh, LOCK_UN);
}
fclose($fh);
}
}
}
}else{
echo "Invalid file";
}
echo '<hr/><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://tweetsforscience.org" data-text="I just donated my tweets to Science! Donate your tweets today!" data-via="tweets4sci" data-size="large" data-related="tweets4sci" data-hashtags="Tweets4Science">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>';
?>
</h3>
</aside>
<div class="clearfix"></div> <!-- Text Section End -->
<hr>
<section id="bottom" class="wide"> <!-- Last Words Section Start -->
<p><a href="http://liquidgem.birondesign.com/">Design based on Liquid Gem template by BironDesign</a></p>.
</section><!-- Last Words Section End-->
</div>
<!-- SLIDESHOW SCRIPT START -->
<script type="text/javascript">
$("#slider").carouFredSel({
responsive : true,
scroll : {
fx : "crossfade",
easing : "swing",
duration : 1000,
},
items : {
visible : 1,
height : "27%"
}
});
</script>
<!-- SLIDESHOW SCRIPT END -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-38781157-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
<!-- Thanks for looking at Liquid Gem! I hope you find it useful :) -->