Sporum.Org
Newest Members:
muskokee (Canada)
rikb53 (houston,texas)
Shirley
Los (Finland)
Mike Robb
Most Recent Posts:
SPT
Re: Error after installation
Re: Error after installation
Re: missing separator
Re: HTML Parser Error after upgrading Perl
Re: HTML Parser Error after upgrading Perl
HTML Parser Error after upgrading Perl
Re: Error after installation
Error after installation
Re: missing separator
missing separator
SPORUM
Re: Section description is wrong.
Re: Section description is wrong.
Re: Section description is wrong.
Site Moved
Re: test post
Re: test
Re: Section description is wrong.
Re: Section description is wrong.
Re: Section description is wrong.
Re: Section description is wrong.
SPMAIL
Re: a subreply
Re: can this post
Re: can this post
Re: can this post
Re: a subreply
Re: adada
Re: adada
Re: can this post
Re: a subreply
adada
|
 |
These scripts can be used to query the Sporum database
PHP - Builds menus shows on this page
<?
$path = "/home/sporum/public_html/cgi-bin/docs";
/// DATABASE INFORMATION BEGIN ///
$DB_URL ="localhost"; ///
$DB_NAME="sporum"; ///
$DB_USER="sporum"; ///
$DB_PASS="yourpassword"; ///
/// DATABASE INFORMATION END ///
function connect_To_DB($_db_url,$_db_user,$_db_pass)
{
if ($bd_link = mysql_connect($_db_url,$_db_user,$_db_pass))
{
}
else
{
echo "ERROR(CONNECT) : ".mysql_errno()." : ".mysql_error();
exit;
}
}
function sel_DB($_db_name) {
if ($select = mysql_select_db($_db_name))
{
}
else
{
echo "ERROR(SELECT DB) : ".mysql_errno()." : ".mysql_error();
exit;
}
}
connect_To_DB($DB_URL,$DB_USER,$DB_PASS);
sel_DB($DB_NAME);
$realname="";
$location="";
$query="SELECT active,uid,nickname,location FROM Users WHERE active like '1' ORDER BY uid DESC LIMIT 1";
if ($result = mysql_query($query))
{
if ($row = mysql_fetch_array($result))
{
$realname = $row[nickname];
$location = $row[location];
$uid = $row[uid];
}
}
if($location){$location="<BR>($location)";}
$newmember="<a href='/cgi-bin/cgiwrap/sporum/spt/user.cgi?op=userinfo&suid=$uid'>$realname$location</a>";
if($newmember){echo "<span class=section>Newest Member:</span><BR> $newmember\n";}
echo "<BR>";
echo "<BR><span class=section>Most Recent Posts:</span><BR>";
echo "<BR><b><a href='/cgi-bin/cgiwrap/sporum/spt/sporum/spt/index.cgi'>SPT</a></b><BR>\n";
$query="SELECT sid,cid,subject FROM spt_Posts ORDER BY date DESC LIMIT 0,10";
if ($result = mysql_query($query))
{
while ($row = mysql_fetch_array($result))
{
$subject = $row[subject];
$subject = ereg_replace("<","<",$subject);
$subject = ereg_replace(">",">",$subject);
$cid = $row[cid];
$sid = $row[sid];
echo " <a href='/cgi-bin/cgiwrap/sporum/spt/sporum/spt/comments.cgi?display=threaded&op=threadlist&sid=$sid&cid=$cid'>$subject</a><BR>\n";
}
} else { echo " No Posts Found<BR>\n"; }
echo "<BR><b><a href='/cgi-bin/cgiwrap/sporum/spt/sporum/sporum/index.cgi'>SPORUM</a></b><BR>\n";
$query="SELECT sid,cid,subject FROM sporum_Posts ORDER BY date DESC LIMIT 0,10";
if ($result = mysql_query($query))
{
while ($row = mysql_fetch_array($result))
{
$subject = $row[subject];
$cid = $row[cid];
$sid = $row[sid];
echo " <a href='/cgi-bin/cgiwrap/sporum/spt/sporum/sporum/comments.cgi?display=threaded&op=threadlist&sid=$sid&cid=$cid'>$subject</a><BR>\n";
}
} else { echo " No Posts Found<BR>\n"; }
echo "<BR><b><a href='/cgi-bin/cgiwrap/sporum/spt/sporum/spmail/index.cgi'>SPMAIL</a></b><BR>\n";
$query="SELECT sid,cid,subject FROM spmail_Posts ORDER BY date DESC LIMIT 0,10";
if ($result = mysql_query($query))
{
while ($row = mysql_fetch_array($result))
{
$subject = $row[subject];
$cid = $row[cid];
$sid = $row[sid];
echo " <a href='/cgi-bin/cgiwrap/sporum/spt/sporum/spmail/comments.cgi?display=threaded&op=threadlist&sid=$sid&cid=$cid'>$subject</a><BR>\n";
}
} else { echo " No Posts Found<BR>\n"; }
?>
Perl - Creates HTML code that can be included (SSIs)
#!/usr/bin/perl
# This is the directory to place the output file
$path="/home/beaker/public_html/php/db";
# This is the name of the file to generate the output
$output_file="$path/forum_js.html";
# This will place the html code into a file by using the OUT
# as defined by the OPEN and used in the prints
open(OUT,">$output_file") || die "Can not open $output_file:$!\n";
# This adds the path of the sporum-spt directory that contains
# the perl files SmallPig.pm and SmallPigVars.pm
# these files configure your database connections
BEGIN { unshift(@INC, "/home/beaker/public_html/cgi-bin/spt"); }
use SmallPig;
use SmallPigVars qw($config);
use SPDB;
sub show() {
my $limit = 14;
print OUT qq|
<table class=wrap border=0 cellpadding=0 cellspacing=0 align=center valign=top width="100%">
<tr><td align=center><b><span class=sth>Script Topics</span></b></td></tr>
|;
my $spdb = SPDB->new();
my $ndf = "W, m/d/y \@ h:i p";
# added and pid to make sure we don't print replies
#changed mhits to hits (mar) 7/2000
my ($new) = $spdb->db_select_many(1,"sid,cid,subject,bodytext,uid,date_format(date, \"$ndf\")", "Posts","approved\=\"1\" AND pid\=\"0\" AND (sid\=\"guruscript\" OR sid\=\"advtopic\" OR sid\=\"howdoi\" OR sid\=\"begarea\")", "ORDER BY date DESC LIMIT $limit");
foreach (@$new) {
my ($sid, $cid, $subject, $bodytext, $uid, $date) = @$_;
$subject=~s/</</g; ## added (mar) 7/2000
$subject=~s/"/"/g; ## added (mar) 7/2000
$subject=~s/>/>/g; ## added (mar) 8/2000
$subject=~s/\f/ /g; ## added (mar) 8/2000
$subject=~s/\r/ /g; ## added (mar) 8/2000
$subject=~s/\n/<BR>/g; ## added (mar) 8/2000
$subject=~s/'/"/g; ## added (mar) 7/2000
my $subj2 = $subject;
$subj2=~s/&/&/g; ## added (mar) 3/2001
if(length($subject) > 16){
($subject) = unpack "a16", $subject;
$subject .= "*";
}
# Truncate long silly messages ...
# add in SmallPigsVars.pm
# 'bodylen' => XXX,
# where XXX = number of bytes you want to appear
if(length($bodytext) > 120){
($bodytext) = unpack ("a120", $bodytext);
$bodytext .= "<...more>";
}
# --- format markup and add <BR>
# $bodytext = SmallPig::format_markup($bodytext);
# $bodytext = SmallPig::add_br($bodytext);
$bodytext=~s/</</g; ## added to remove the posibility of < (mar) 7/2000
$bodytext=~s/"/"/g; ## added to remove Quotes (mar) 7/2000
$bodytext=~s/>/>/g; ## added (mar) 8/2000
$bodytext=~s/'/"/g; ## added (mar) 8/2000
$bodytext=~s/\n/<BR>/g; ## added (mar) 8/2000
$bodytext=~s/\f/ /g; ## added (mar) 8/2000
$bodytext=~s/\r/ /g; ## added (mar) 8/2000
$bodytext=~s/&/&/g; ## added (mar) 3/2001
# Please change these lines, to fit to your page-layout
print OUT qq|
<tr><td><span class=st> </span><a class=st href="/cgi-bin/spt/sporum/sporum/comments.cgi?op=threadlist&sid=$sid&cid=$cid">$subject</a></td></tr>
|;
} # end of foreach
print OUT qq|
</td></tr><TR><TD><BR></td</tr></table>
|;
#$spdb->db_disconnect($spdb->{'dbh'});
}
sub showExpert() {
my $limit = 20;
print OUT qq|
<;BR>
<table class=wrap border=0 cellpadding=0 cellspacing=0 align=center valign=top width="100%">
<tr><td align=center><b><span class=sth>Forum Experts</span></b></td></tr>
|;
my $spdb = SPDB->new();
my $ndf = "W, m/d/y \@ h:i p";
#$query = "SELECT uid,username,qanswered,xpertpts FROM UserStatus,Users WHERE UserStatus.uid = Users.uid ORDER BY qanswered
my ($new) = $spdb->db_select_many(1,"Users.uid,Users.username,Users.realname,UserStatus.qanswered,UserStatus.xpertpts", "UserStatus,Users","UserStatus.uid \=Users.uid AND UserStatus.qanswered > 5", "ORDER BY UserStatus.xpertpts DESC LIMIT $limit");
# my ($new) = $spdb->db_select_many(1,"Users.uid,Users.username,Users.realname,UserStatus.qanswered,UserStatus.xpertpts", "UserStatus,Users","UserStatus.uid \=Users.uid AND UserStatus.qanswered > 5", "ORDER BY UserStatus.qanswered DESC LIMIT $limit");
foreach (@$new) {
my ($uid, $loginname, $username, $qanswered, $xpertpts) = @$_;
$username = $loginname if(!$username);
next if (!$username);
$username=~s/</</g; ## added (mar) 7/2000
$username=~s/"/"/g; ## added (mar) 7/2000
$username=~s/>/>/g; ## added (mar) 8/2000
$username=~s/\f/ /g; ## added (mar) 8/2000
$username=~s/\r/ /g; ## added (mar) 8/2000
$username=~s/\n/<BR>/g; ## added (mar) 8/2000
$username=~s/'/"/g; ## added (mar) 7/2000
my $subj2 = $username;
$subj2=~s/&/&/g; ## added (mar) 3/2001
if(length($username) > 16){
($username) = unpack "a16", $username;
$username .= "*";
}
# Please change these lines, to fit to your page-layout
print OUT qq|
<tr><td><span class=st> </span><a class=st href="cgi-bin/spt/user.cgi?op=userinfo&suid=$uid&page=1&postsper=10">$username</a></td></tr>
|;
} # end of foreach
print OUT qq|
</td></tr><TR><TD><BR></td</tr></table>
|;
#$spdb->db_disconnect($spdb->{'dbh'});
}
&show;
&showExpert;
|