diff options
Diffstat (limited to 'cgi-bin/import')
| -rwxr-xr-x | cgi-bin/import | 286 |
1 files changed, 286 insertions, 0 deletions
diff --git a/cgi-bin/import b/cgi-bin/import new file mode 100755 index 0000000..fc7add5 --- /dev/null +++ b/cgi-bin/import @@ -0,0 +1,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! !; + 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: !; + 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: "; + 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 " "; + print qq!</td></tr>!; + + print qq!<tr><td align="right" valign="top">!; + print qq!comment: !; + 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 (); + |
