#!/usr/bin/perl -w
###############################################################################
# users.pl - this code is for user creation and administration
#
# Copyright (C) 1997 Rob "CmdrTaco" Malda
# malda@slashdot.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# $Id: users.pl,v 1.22 2000/09/25 17:11:44 pudge Exp $
###############################################################################
use strict;
use lib '../';
use vars '%I';
use Slash;
#################################################################
sub main {
*I = getSlashConf();
getSlash();
my $op = $I{F}{op};
if ($op eq "userlogin" and $I{U}{uid} > 0) {
my $refer = 'disc.pl';
redirect($refer);
return;
}
header("$I{sitename} Users");
print < [
User Info |
Edit User Info |
Edit Homepage |
Edit Comments |
Logout
] Our system doesn't remember who you are,
yet you think you are logged in. This could be because you are using
an older browser. Or are behind a firewall or proxy or something that
is stripping cookies. If you think none of these are the problem,
please send us your browser version, nickname, uid, platform,
and any other details that seem relavant. Optionally, you might not have actually ever logged in, please
click here to login.
";
$string = substr($string, 0, 255);
$string =~ s/,'??\w*?$//g;
} elsif (length $string < 3) {
$string = "";
}
return $string;
}
#################################################################
sub previewSlashbox {
my ($title, $content, $url) = sqlSelect(
"title,block,url", "blocks, sectionblocks",
"blocks.bid = sectionblocks.bid AND blocks.bid = "
. $I{dbh}->quote($I{F}{bid})
);
my $cleantitle = $title;
$cleantitle =~ s/<(.*?)>//g;
titlebar("100%","Preview $cleantitle");
print <
Edit $I{F}{bid}
EOT print qq!User ID: =$uid
Nick: =$I{F}{newuser}
Password: =mailed to $I{F}{email}
Once you receive your password, you can log in and set your account up
EOT mailPassword($I{F}{newuser}); } else { # Duplicate User displayForm(); } } ################################################################# sub changePassword { my @chars = grep !/[0O1Iil]/, 0..9, 'A'..'Z', 'a'..'z'; return join '', map { $chars[rand @chars] } 0 .. 7; } ################################################################# sub mailPassword { my($name) = @_; my($nickname, $passwd, $email) = sqlSelect( "nickname,passwd,realemail", "users", "nickname=" . $I{dbh}->quote($name) ); my $msg = blockCache("newusermsg"); $msg = prepBlock($msg); $msg = eval $msg; if ($name ne '' && (lc($name) eq lc($nickname))) { sendEmail($email, "$I{sitename} user password for $name", $msg) if $name; print "Password for $name was just emailed.
\n"; } else { print "$name was not found. No Password mailed.
\n"; } } ################################################################# sub userInfo { my($nick) = @_; my $c = $I{dbh}->prepare( "SELECT homepage,fakeemail,users.uid,bio, seclev,karma FROM users, users_info WHERE users.uid = users_info.uid AND nickname=" . $I{dbh}->quote($nick) . " and users.uid > 0" ); $c->execute; if (my($home, $email, $uid, $bio, $useclev, $karma) = $c->fetchrow) { $bio = stripByMode($bio, "html"); if ($I{U}{nickname} eq $nick) { my $sth = $I{dbh}->prepare("SELECT points FROM users_comments WHERE uid=$uid"); $sth->execute; my $points = $sth->fetchrow_array; $sth->finish; titlebar("95%", "Welcome back $nick ($uid)"); print <Karma $karma (mostly the sum of moderation done to users comments)
" if $bio;
my($k) = sqlSelect("pubkey", "users_key", "uid=$uid");
$k = stripByMode($k, "html");
print "Public Key
\n$k
" if $k; $I{F}{min} = 0 unless $I{F}{min}; my $sqlquery = "SELECT pid,sid,cid,subject," . getDateFormat("date","d") . ",points FROM comments WHERE uid=$uid "; $sqlquery .= " ORDER BY date DESC LIMIT $I{F}{min},50 "; my $comments = $I{dbh}->prepare($sqlquery); $comments->execute; print "
$nick has posted " . $comments->rows
. " comments (this only counts the last few weeks)
attached to $S->{title}
!; # $S->{section}/$sid.shtml } else { my $P = sqlSelectHashref("question", "pollquestions", "qid='$sid'"); print qq!$nick not found.
"; } $c->finish; } ################################################################# sub editKey { my($k) = sqlSelect("pubkey", "users_key", "uid=$_[0]"); printf qq!Public Key
!,
stripByMode($k, 'literal');
}
#################################################################
sub editUser {
my($name) = @_;
my($uid, $realname, $realemail, $fakeemail, $homepage, $nickname,
$passwd, $sig, $useclev, $bio, $maillist) = sqlSelect(
"users.uid, realname, realemail, fakeemail, homepage, nickname, " .
"passwd, sig, seclev, bio, maillist", "users, users_info",
"users.uid=users_info.uid AND nickname=" . $I{dbh}->quote($name)
);
return if $uid < 1;
titlebar("100%", "Editing $name ($uid) $realemail");
print qq!
| !;
$homepage ||= "http://";
my $tempnick = $nickname;
$tempnick =~ s/ /+/g;
print < |
EOT
# print " " if $I{U}{aseclev}> 499;
}
#################################################################
sub tildeEd {
my($extid, $exsect, $exaid, $exboxes, $userspace) = @_;
titlebar("100%", "Exclude Stories from the Homepage");
print < ";
titlebar("100%", "Customize InfoBoxes");
$userspace = stripByMode($userspace, 'literal');
print < Configuration Options
Important: If you leave these all unchecked, it means you
want the default selection of boxes. If you start selecting
boxes, remember to set all of them that you want because the
default selection will be ignored. Default entries are bolded.
User Space (check 'user space' below and whatever
you place here will appear your custom $I{sitename})
If you have reasonable suggestions for boxes that can be added
here, or a problem with one of the boxes already here,
email $I{siteadmin_name}.
The preferred format is the Netscape RDF format that is
rapidly becoming the de facto format for exchanging headlines
between sites.
EOT
print "
Deactivate Slashboxes (just the news, please.)
No Icons (disable topic icon images on stories)
Maximum Stories The default is 12. The main
column displays 1/3rd of these at minimum, and all of
today's stories at maximum.
Willing to Moderate By default all users are willing to
Moderate.
Uncheck this if you aren't interested.
EOT
tildeEd($extid, $exsect, $exaid, $exboxes, $userspace);
print qq!\t\n!;
# print qq!\t ! if $I{U}{aseclev}> 499;
print "\t\n\n";
}
#################################################################
sub editComm {
my($name) = @_;
my($uid, $points, $posttype, $defaultpoints, $maxcommentsize,
$clsmall, $clbig, $reparent, $noscores, $highlightthresh,
$commentlimit, $nosigs, $commentspill, $commentsort, $mode,
$threshold, $hardthresh)
= sqlSelect("users.uid, points, posttype, defaultpoints, "
. "maxcommentsize, clsmall, clbig, reparent, noscores, "
. "highlightthresh, commentlimit, nosigs, commentspill, "
. "commentsort, mode, threshold, hardthresh",
"users, users_comments","users.uid=users_comments.uid AND nickname="
. $I{dbh}->quote($name)
);
titlebar("100%", "Comment Options");
print < Sort Order\n";
selectForm("sortcodes", "commentsort", $commentsort);
print " Threshold";
selectGeneric("threshcodes", "uthreshold", "thresh", "description", $threshold);
print < Highlight Threshold";
selectGeneric("threshcodes", "highlightthresh", "thresh", "description", $highlightthresh);
print " Reparent Highly Rated Comments (causes comments
to be displayed even if they are replies to comments
under current threshold)
Do Not Display Scores (Hides score:
They still apply you just don't see them.)
Limit only display this many comments.
For best results, set this to a low number and sort by score. Index Spill (When an article has this many comments,
it switches to indexed mode) Small Comment Penalty (Assign -1 to comments smaller
than this many characters. This might cause some comments
to be rated -2 and hence rendered invisible!) Long Comment Bonus (Assign +1 to lengthy comments) Max Comment Size (Truncates long comments, and
adds a \"Read More\" link. Set really big to disable) Disable Sigs (strip sig quotes from comments)
Comment Post Mode
EOT
selectGeneric("postmodes", "posttype", "code", "name", $posttype);
print <
EOT
# print qq! ! if $I{U}{aseclev}> 499;
}
#################################################################
sub saveUser {
my $uid = $I{U}{aseclev} ? shift : $I{U}{uid};
my $name = $I{U}{aseclev} && $I{F}{name} ? $I{F}{name} : $I{U}{nickname};
$name = substr($name, 0, 20);
return unless $uid > 0;
print " Saving $name ";
print < Passwords don't match. Password not changed. Password is too short and was not changed. Saving $name ";
print < Saving $name ";
print < 1. Enter your preferred nickname: 2. Now enter a valid email address address to send your registration
information. 3. Click the button to be mailed a password.
Authors
Topics
Sections
EOT
# Customizable Authors Thingee
my $C = sqlSelectMany("aid", "authors", "seclev > 99", "order by aid");
while (my($aid) = $C->fetchrow) {
my $checked = ($exaid =~ /'$aid'/) ? ' CHECKED' : '';
print qq!$aid
\n!;
}
$C->finish;
# Customizable Topic
print qq! ";
# Customizable Sections
print '
\n! if $tid;
}
$C->finish;
print "';
$C = sqlSelectMany("section,title", "sections", "isolate=0", "order by title");
while (my($section,$title) = $C->fetchrow) {
my $checked = ($exsect =~ /'$section'/) ? " CHECKED" : "";
print qq!$title ";
print "
\n! if $section;
}
$C->finish;
print " ";
}
#################################################################
sub editHome {
my($name) = @_;
my($uid, $willing, $tzformat, $tzcode, $noicons, $light, $userspace,
$extid, $exaid, $exsect, $exboxes, $maxstories, $noboxes)
= sqlSelect("users.uid, willing, dfid, tzcode, noicons, light, "
. "mylinks, users_index.extid, users_index.exaid, "
. "users_index.exsect, users_index.exboxes, users_index.maxstories, "
. "users_index.noboxes", "users, users_prefs, users_index",
"users.uid=users_prefs.uid AND users.uid=users_index.uid AND "
. "users.nickname=" . $I{dbh}->quote($name)
);
return if $uid < 1;
titlebar("100%", "Customize $I{sitename}'s Display");
print <
\n";
print "" if $o > 0;
}
$C->finish;
print <
Date/Time Format
EOT
selectGeneric("dateformats", "tzformat", "id", "description", $tzformat);
selectGeneric("tzcodes", "tzcode", "tz", "description", $tzcode);
print "";
my $l_check = $light ? " CHECKED" : "";
my $b_check = $noboxes ? " CHECKED" : "";
my $i_check = $noicons ? " CHECKED" : "";
my $w_check = $willing ? " CHECKED" : "";
print <
EOT
print "Display Mode";
selectGeneric("commentmodes", "umode", "mode", "name", $mode);
print "
(comments scoring this are displayed even after an article spills into index mode)";
my $h_check = $hardthresh ? " CHECKED" : "";
my $r_check = $reparent ? " CHECKED" : "";
my $n_check = $noscores ? " CHECKED" : "";
my $s_check = $nosigs ? " CHECKED" : "";
print <
\n";
sendEmail($oldEmail, "$I{sitename} user email change for $name", <
!;
} elsif ($I{F}{pass1} ne $I{F}{pass2}) {
print "
EOT
}
main();
$I{dbh}->disconnect if $I{dbh};
1;
EOT
titlebar("100%", $I{F}{newuser} ? "Duplicate Account!" : "I'm a New User!");
print $I{F}{newuser} ? <
EOT2
print <
This address will not be displayed on $I{sitename}.
I declare that I am at least 18 years of age.