summaryrefslogtreecommitdiff
path: root/cgi-bin/import
blob: fc7add58c052e38cc712a0126d97374685582d3e (plain)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/usr/bin/perl
#########################################
# import
# escorts ftp'd files into the database
#########################################

use localbucky;

my $pid;

$dbh = DBI->connect ($dsn);

our ($USER, $lastlog) = checkin();
logout() unless ($USER != -1);

if ($input->{c} eq "n")
	{
	my $valid = 0;
	my $thread_id = 0;
	if ($DEBUG)
		{
		header("importing files...");
		foreach $k (sort keys %$input) { print "$k => ".$input->{$k}."<br>"; }
		}
	foreach my $k (keys %$input)
		{
		if ($k =~ /^import/)
			{ $valid = 1; last; }
		}
	if ($valid)
		{
		if ($input->{id} && $input->{id} ne "new")
			{
			$thread = get_thread($input->{id});
			$keyword = get_keyword($thread->{keyword});
       			if ($thread != -1 && check_privacy($thread, $keyword))
				{
				$thread_id = $thread->{id};
				touch_thread($thread);
				}
			else
				{
				error("cannot import into specified thread");
				}
			}
		else
			{
			if ($input->{title} eq undef || $input->{title} =~ /^\s+$/)
				{
				error ("No thread title!");
				}
			else
				{
				$thread_id = add_thread($input->{title}, $USER->{username}, 0);
				}
			}
		print "thread_id => $thread_id<br>" if ($DEBUG);
		add_comment($thread_id,-1,$USER->{username},$input->{comment}) if ($input->{comment} ne undef);
		situate_imports($thread_id, $USER->{username});
		if (exists($input->{keyword}))
			{
			my $k = get_keyword($input->{keyword});
			if ($k->{public} || check_op($k))
				{
				keyword_assign_mechanism($input->{keyword}, $thread_id, $k);
				}
			}
		}
	else
		{ error("No imports specified!"); }
	if ($DEBUG)
		{
		print qq{this way to your new thread: <a href="$BUCKY/details/$thread_id">link!</a>};
		footer();
		}
	redirect("$BUCKY/details/$thread_id");
	}

else
	{
	my ($title, $size, $inc);

	my $thread = -1;
	my $keyword = -1;
	if ($input->{id})
		{
		# id title username createdate lastmodified size private allowed flagged
		$thread = get_thread($input->{id});
		$keyword = get_keyword($thread->{keyword});
		}
	if ($input->{keyword})
		{
		$keyword = get_keyword($input->{keyword});
		}
	elsif ($thread->{keyword})
		{
		$keyword = get_keyword($thread->{keyword});
		}

	header("ftp import");
	menu();
  if ($USER->{'username'} eq "asdfasdfadsfadsf")
    {
    print <<__SORRY__;
<center>
<br>
<div style="text-align: left; width: 300px; padding: 10px;" class="bluebox">
<center><b><big>SORRY!</big></b>
<hr noshade color="$BUCKY_COLOR_HR">
You have maxed out your upload quota!<p>
Delete some things you've uploaded, then try again.
</center></div><br></center>
__SORRY__
    exit;
    }
	print <<impHEAD;
<center>
<br>
<div style="float: right; text-align: left; width: 200px; padding: 10px; font-size: 11px; background-color: #f8f8f8;" class="bluebox"><center>

<big><b>UPLOAD FILES TO BUCKY WITH CONVENIENCE USING SFTP</b></big>
<hr noshade color="$BUCKY_COLOR_HR">

You must generate a cryptographic key to use this service. Don't worry it's easy!<br/>
<br/>
<hr noshade color="#ddd">
<br/>

ON A MAC / UNIX<br/>
<br/>
recc'd sftp client: <a href="http://cyberduck.ch/" target="_blank">Cyberd*ck</a><br/>
<b>to generate the key</b>, from Terminal run:<br/>
<big><tt><b>ssh-keygen -t rsa</b></b></tt></big><br/>
<a href="/cgi-bin/bucky/message/jules">send me the public key</a>
<br/>
(private key is handled automatically)
<br/>
<br/>
<hr noshade color="#ddd">
<br/>

ON WINDOWS ...<br/>
<br/>
recc'd sftp client: <a href="http://winscp.net/" target="_blank">WINSCP (PC)</a><br/>
<b>generate the key</b> with the program <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">puttygen</a>
<br/>
<a href="/cgi-bin/bucky/message/jules">send me the public key</a>
<br/>
(the private key goes in the program when you set up the session.)

<br/>
<br/>
<hr noshade color="#ddd">
<br/>

log in here:
<br/>
<br/>
<tt><big>
$BUCKY_FTP_HOST<br>
username: $BUCKY_FTP_USER</big></tt>

<br/>
<br/>
<hr noshade color="#ddd">
<br/>

Once you're in, upload your files and they should show up below.  <b>Check off</b> only the files that are yours,
or click the toggle button to select them all.
impHEAD

	if ($thread == -1)
		{
		print qq(To attach FTP'd files to a pre-existing thread, go to the thread and click <b>ftp here</b>.);
		}
	print qq!</center></div>\n\n!;

	print qq!<form name="checkz" action="$BUCKY/import" method="post" enctype="multipart/form-data">\n!;
	print qq!<div width=500>\n!;
	($title, $inc, $size) = list_imports();

	print <<widget;
<script type="text/javascript">
<!--
function toggle() 
  {
  var e = document.checkz.elements.length;
  for (var i = 0; i < e; i++)
    {
    var y = "document.checkz[i].type";
    type = eval(y);

    var n = "document.checkz[i]";
    box = eval(n);

    if (type == "checkbox")
      {
      if (box.checked == false)
        { box.checked = true; }
      else
        { box.checked = false; }
      }
    }
  }
-->
</script>
<table cellpadding=0 cellspacing=0 width="580">
<tr>
<td align="left" valign="top"><input type=button value="toggle checked" onClick="JavaScript:toggle()"></td>
<td align="center" valign="middle">
widget

	if ($inc)
		{
		print "<center><small><i><b>INCOMPLETE</b> FILES ARE SHOWN IN ITALICS -- PLEASE WAIT FOR YOUR UPLOAD TO FINISH</i></small></center><p>\n\n";
		}

	if ($DEBUG) { print qq!<input type="hidden" name="debug" value="$DEBUG">\n!; }
	print qq!<input type="hidden" name="c" value="n">\n!;

	print qq!<center>!;
	print qq!<table cellpadding=2 cellspacing=0>!;
	if ($thread != -1 && check_privacy($thread, $keyword))
		{
		print qq!<tr><td align="right" valign="baseline">!;
		print qq!&nbsp;!;
		print qq!<td><td align="left" valign="baseline">!;
		print qq!These files will be added to:<p><big><b>$thread->{title}</b></big><br>\n!;
		print qq!posted by $thread->{username} on !.verbosedate($thread->{createdate}).qq!<p>\n\n!;
		print qq!<input type="hidden" name="id" value="$thread->{id}">\n!;
		print qq!</td></tr>!;
		}
	else
		{
		print qq!<input type="hidden" name="id" value="new">\n\n!;
		print qq!<tr><td align="right" valign="baseline">!;
		print qq!title:&nbsp;!;
		print qq!<td><td align="left" valign="baseline">!;
		print qq!<input type="text" name="title" value="$title" size=40 maxlength=48><br>\n!;
		print qq!</td></tr>!;
		print qq!<tr><td align="right" valign="baseline">!;
		print "keyword:&nbsp;";
		print qq!<td><td align="left" valign="baseline">!;
		if (exists($input->{keyword}))
			{
			my $k = get_keyword($input->{keyword});
			if ($k->{public} || check_op($k))
				{
				keyword_pulldown($k->{keyword});
				$checked = $k->{public} ? "" : " checked";
				}
			else
				{ keyword_pulldown("NONE"); }
			}
		else
			{ keyword_pulldown("NONE"); }
		print qq!</td></tr>!;
		}
	print qq!<tr><td>!;
	print "&nbsp;";
	print qq!</td></tr>!;

	print qq!<tr><td align="right" valign="top">!;
	print qq!comment:&nbsp;!;
	print qq!<td><td align="left" valign="top">!;
	print <<impFOOT;
<p>
<textarea name="comment" cols="40" rows="10"></textarea>
<p>
<input type="submit" value="IMPORT" class="clicky">
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</form>
</div>

impFOOT
	footer();
	}

$dbh->disconnect ();