First pass at adding key files
This commit is contained in:
23
site/forum.slowtwitch.com/cgi-bin/gforum.cgi
Executable file
23
site/forum.slowtwitch.com/cgi-bin/gforum.cgi
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/speedy
|
||||
|
||||
# Nathan moved this to speedycgi, Nov 23 2017 #!/usr/bin/perl
|
||||
|
||||
# ==================================================================
|
||||
# Gossamer Forum - Advanced web community
|
||||
#
|
||||
# Website : http://gossamer-threads.com/
|
||||
# Support : http://gossamer-threads.com/scripts/support/
|
||||
# CVS Info :
|
||||
# Revision : $Id: gforum.cgi,v 1.56 2006/03/31 21:32:04 jagerman Exp $
|
||||
#
|
||||
# Copyright (c) 2006 Gossamer Threads Inc. All Rights Reserved.
|
||||
# Redistribution in part or in whole strictly prohibited. Please
|
||||
# see LICENSE file for full details.
|
||||
# ==================================================================
|
||||
|
||||
use strict;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw/$PLG/;
|
||||
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
$PLG->dispatch(main => \&GForum::request);
|
6
site/forum.slowtwitch.com/cgi-bin/poll/admin/.htaccess
Normal file
6
site/forum.slowtwitch.com/cgi-bin/poll/admin/.htaccess
Normal file
@ -0,0 +1,6 @@
|
||||
AuthUserFile /home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin/.htpasswd
|
||||
AuthGroupFile /dev/null
|
||||
AuthType Basic
|
||||
AuthName "Gossamer Forum Administration"
|
||||
|
||||
require valid-user
|
411
site/forum.slowtwitch.com/cgi-bin/poll/admin/admin.cgi
Executable file
411
site/forum.slowtwitch.com/cgi-bin/poll/admin/admin.cgi
Executable file
@ -0,0 +1,411 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw/$DB $CFG $IN/;
|
||||
use vars qw/$PRINT_HEADER $FONT $MAX $poll_vars/;
|
||||
|
||||
local $SIG{__DIE__} = \&GForum::fatal;
|
||||
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
|
||||
$poll_vars = do "poll.cfg";
|
||||
|
||||
$MAX = 20;
|
||||
$FONT = qq~font face="tacoma, arial, san-serif" size="2"~;
|
||||
main();
|
||||
|
||||
sub main {
|
||||
header();
|
||||
nav();
|
||||
my $do = $IN->param('do');
|
||||
if ($do eq 'add_form') { add_form(); }
|
||||
elsif ($do eq 'add') { add(); }
|
||||
elsif ($do eq 'modify_form') { modify_form(); }
|
||||
elsif ($do eq 'modify') { modify(); }
|
||||
elsif ($do eq 'disable') { disable(); }
|
||||
elsif ($do eq 'enable') { enable(); }
|
||||
elsif ($do eq 'home_show') { home_show(); }
|
||||
elsif ($do eq 'home_notshow') { home_notshow(); }
|
||||
else {
|
||||
&list();
|
||||
}
|
||||
footer();
|
||||
}
|
||||
|
||||
sub header {
|
||||
if (!$PRINT_HEADER) {
|
||||
print $IN->header();
|
||||
}
|
||||
print "<html><head><title>Poll Admin</title></head><body><$FONT>";
|
||||
}
|
||||
|
||||
sub nav {
|
||||
print qq!
|
||||
<b>Poll</b>: <a href="admin.cgi?do=add_form">Add Poll</a> | <a href="admin.cgi">List Poll</a>
|
||||
!;
|
||||
#<br><b>Quiz</b>: <a href="admin.cgi?do=add_form&poll_type=1">Add Quiz</a> | <a href="admin.cgi?poll_type=1">List Quiz</a><br>
|
||||
}
|
||||
|
||||
sub footer {
|
||||
print "</body></html>";
|
||||
}
|
||||
|
||||
sub include_form {
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
my $val = shift || {};
|
||||
my $option = shift || $MAX;
|
||||
my $output = qq~<form action="admin.cgi" method="post">
|
||||
<input type="hidden" name="do" value="$val->{do}">
|
||||
<input type="hidden" name="poll_id" value="$val->{poll_id}">\n~;
|
||||
|
||||
$output .= qq~<p><$FONT color="red">$val->{error}</font></p>~ if $val->{error};
|
||||
|
||||
$output .= qq~
|
||||
<B>Question:</B> <br><textarea rows="4" cols="50" name="poll_question">$val->{poll_question}</textarea><br>\n
|
||||
<B>Description:</B> <br><textarea rows="4" cols="50" name="poll_text">$val->{poll_text}</textarea><br>\n
|
||||
<b>Answers Options:</b> <br>
|
||||
~;
|
||||
my $i = 1;
|
||||
my $select = qq~<select name="poll_answer">~;
|
||||
if ($val->{poll_answers_loop}) {
|
||||
foreach my $ans (@{$val->{poll_answers_loop}}) {
|
||||
$output .= qq~Option $i: <input type="text" name="poll_answer_answer_$i" size="30" value="$ans->{poll_answer_answer}"> ~;
|
||||
if (!$val->{poll_type}) {
|
||||
$output .= qq~Votes: <input type="text" name="poll_answer_votes_$i" size="10" value="$ans->{poll_answer_votes}"><br>\n~;
|
||||
}
|
||||
$output .= qq~<input type="hidden" name="current_poll_answer_id_$i" value="$ans->{poll_answer_id}">\n~;
|
||||
$output .= "<br>";
|
||||
$select .= qq~<option value="$ans->{poll_answer_id}"~;
|
||||
if ($val->{poll_answer} == $ans->{poll_answer_id}) {
|
||||
$select .= " selected";
|
||||
}
|
||||
$select .= qq~>$i</option>\n~;
|
||||
$i++;
|
||||
}
|
||||
if ($IN->param('num_answers') > $i) {
|
||||
foreach ($i .. $IN->param('num_answers')) {
|
||||
$output .= qq~Option $_: <input type="text" name="poll_answer_answer_$_" size="30" value=""> ~;
|
||||
if (!$val->{poll_type}) {
|
||||
$output .= qq~Votes: <input type="text" name="poll_answer_votes_$_" size="10" value="0"><br>\n~;
|
||||
}
|
||||
$output .= "<br>";
|
||||
$select .= qq~<option value="$_">$_</option>\n~;
|
||||
}
|
||||
}
|
||||
$i += 2;
|
||||
}
|
||||
else {
|
||||
foreach (1 .. $option) {
|
||||
my $ans = $val->{'poll_answer_answer_' . $_};
|
||||
$output .= qq~Option $_: <input type="text" name="poll_answer_answer_$_" size="30" value="$ans"> ~;
|
||||
if (!$val->{poll_type}) {
|
||||
$output .= qq~Votes: <input type="text" name="poll_answer_votes_$_" size="10" value="0">\n~;
|
||||
}
|
||||
$output .= "<br>";
|
||||
$select .= qq~<option value="$_">$_</option>\n~;
|
||||
}
|
||||
}
|
||||
$select .= "</select>";
|
||||
if ($val->{poll_type} == 1) {
|
||||
$output .= qq~<b>Right Answer:</b> $select<br><input type="hidden" name="poll_type" value="1">\n~;
|
||||
}
|
||||
$output .= qq~<B>Total Votes:</B> <input type="text" size="10" name="poll_votes" value="$val->{poll_votes}"><br><br>\n~;
|
||||
$output .= $val->{poll_id} ?
|
||||
qq~<input type="submit" value="Modify"> <a href="admin.cgi?do=modify_form&poll_id=$val->{poll_id}&num_answers=$i">Want to add more options?</a></form>~ :
|
||||
qq~<input type="submit" value="Add"></form>~;
|
||||
|
||||
return $output . "\n";
|
||||
}
|
||||
|
||||
sub list {
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
my $msg = shift;
|
||||
my $start_at = $IN->param("start_at") || 1;
|
||||
my $poll_count = $IN->param("poll_count") || 100;
|
||||
my $cgi = $IN->get_hash();
|
||||
$cgi->{nh} ||= $start_at;
|
||||
$cgi->{mh} ||= $poll_count;
|
||||
$cgi->{sb} ||= "poll_date";
|
||||
$cgi->{so} ||= "DESC";
|
||||
$cgi->{poll_type} ||= 0;
|
||||
|
||||
#use Data::Dumper; print "<pre>" . Dumper($cgi) . "</pre>";
|
||||
my $db = $DB->table('Poll');
|
||||
my $ans_db = $DB->table('PollAnswer');
|
||||
my $sth = $db->query_sth($cgi);
|
||||
my $output;
|
||||
|
||||
if ($msg) {
|
||||
$output .= "<p>$msg</p>";
|
||||
}
|
||||
my $i=1;
|
||||
my $correct = "";
|
||||
while (my $row = $sth->fetchrow_hashref()) {
|
||||
my $date = $row->{poll_date};
|
||||
$output .= qq~<p><table width="100%"><tr><td colspan="2"><$FONT>$i.) $row->{poll_question} (posted on $date)</td></tr>
|
||||
<tr><td colspan="2"><$FONT>Description: $row->{poll_text}</td></tr>~;
|
||||
my $answers = $ans_db->select( { poll_id_fk => $row->{poll_id} })->fetchall_hashref();
|
||||
my $max = 0;
|
||||
my $votes = $row->{poll_votes};
|
||||
foreach my $poll_answer (@$answers) {
|
||||
if ($votes) {
|
||||
$poll_answer->{poll_answer_percentage} = sprintf("%" . $poll_vars->{percentage_pre} . "." . $poll_vars->{percentage_post} . "f",$poll_answer->{poll_answer_votes} / $votes * 100);
|
||||
}
|
||||
if ($poll_answer->{poll_answer_votes} > $max) {
|
||||
$max = $poll_answer->{poll_answer_votes};
|
||||
$poll_answer->{poll_answer_is_leading} = 1;
|
||||
}
|
||||
else {
|
||||
$poll_answer->{poll_answer_is_leading} = 0;
|
||||
}
|
||||
if ($poll_answer->{poll_answer_id} == $row->{poll_answer}) {
|
||||
$correct = $poll_answer->{poll_answer_answer};
|
||||
}
|
||||
$output .= qq~
|
||||
<tr>
|
||||
<td align="right" width="20%">
|
||||
<$FONT>
|
||||
$poll_answer->{poll_answer_answer}
|
||||
</td>
|
||||
<td align="left" width="80%">
|
||||
<$FONT> ~;
|
||||
if ($poll_answer->{poll_answer_percentage}) {
|
||||
my $width = $poll_answer->{poll_answer_percentage} * 4;
|
||||
$output .= qq~<img src="/images/leftbar.gif" height="10" width="2" alt="" /><img src="/images/mainbar.gif" height="10" width="$width" alt="" /><img src="/images/rightbar.gif" height="10" width="2" alt="" />~;
|
||||
}
|
||||
else {
|
||||
$output .= qq~<img src="/images/leftbar.gif" height="10" width="2" alt="" /><img src="/images/rightbar.gif" height="10" width="2" alt="" />~;
|
||||
}
|
||||
$output .= qq~$poll_answer->{poll_answer_votes} / $poll_answer->{poll_answer_percentage} %
|
||||
</td>
|
||||
</tr>
|
||||
~;
|
||||
}
|
||||
if ($row->{poll_type}) {
|
||||
$output .= qq~<tr><td colspan="2"><$FONT>The Correct Answer is: $correct</td></tr>~;
|
||||
$output .= qq~<tr><td colspan="2"><$FONT>Total Answered: $row->{poll_votes}</td></tr>~;
|
||||
}
|
||||
else {
|
||||
$output .= qq~<tr><td colspan="2"><$FONT>Total Votes: $row->{poll_votes}</td></tr>~;
|
||||
}
|
||||
$output .= qq~<tr><td colspan="2"><$FONT> <a href="admin.cgi?do=modify_form&poll_id=$row->{poll_id}">Edit</a> | ~;
|
||||
$output .= $row->{poll_enabled} ?
|
||||
qq~<a href="admin.cgi?do=disable&poll_id=$row->{poll_id}"> Disable </a>~ :
|
||||
qq~<a href="admin.cgi?do=enable&poll_id=$row->{poll_id}"> Enable</a>~ ;
|
||||
$output .= $row->{poll_home} ?
|
||||
qq~| <a href="admin.cgi?do=home_notshow&poll_id=$row->{poll_id}"> Don't Show this on Home Page</a>~ :
|
||||
qq~| <a href="admin.cgi?do=home_show&poll_id=$row->{poll_id}"> Show this on Home Page</a>~ ;
|
||||
$output .= qq~</td></tr></table>~;
|
||||
$i++;
|
||||
}
|
||||
print $output;
|
||||
}
|
||||
|
||||
sub add_form {
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
my $cgi = $IN->get_hash();
|
||||
my $error = shift;
|
||||
if ($error) {
|
||||
$cgi->{error} = $error;
|
||||
}
|
||||
$cgi->{do} = 'add';
|
||||
my $form = include_form( { %$cgi }, 4 );
|
||||
print $form;
|
||||
}
|
||||
|
||||
sub add {
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
# This subroutine will get called whenever the hook 'do_post_post'
|
||||
# is run.
|
||||
my $total_options = 0;
|
||||
my %seen;
|
||||
my $dup = 0;
|
||||
for (1 .. $MAX) {
|
||||
my $ans = $IN->param("poll_answer_answer_$_");
|
||||
if ($ans) {
|
||||
if ($seen{$ans}) {
|
||||
$dup = 1;
|
||||
last;
|
||||
}
|
||||
$seen{$ans} = 1;
|
||||
$total_options++;
|
||||
}
|
||||
}
|
||||
if ($dup) {
|
||||
return add_form("Answers are the same.");
|
||||
}
|
||||
|
||||
if (!$IN->param('poll_question')) {
|
||||
add_form("No question entered!");
|
||||
return;
|
||||
}
|
||||
if ($total_options < 2) {
|
||||
add_form("POLL_NOT_ENOUGH_OPTIONS");
|
||||
return;
|
||||
}
|
||||
|
||||
# Insert question into Poll table
|
||||
my $a = $DB->table('Poll');
|
||||
my $cgi = $IN->get_hash;
|
||||
$cgi->{'poll_enabled'} = '1';
|
||||
$cgi->{'poll_type'} ||= 0;
|
||||
$cgi->{'poll_votes'} = 0;
|
||||
if (!$cgi->{'poll_type'}){
|
||||
$cgi->{'poll_answer'} = 0;
|
||||
}
|
||||
require GT::Date;
|
||||
$cgi->{'poll_date'} = GT::Date::date_get();
|
||||
my $rec = $a->insert($cgi) or die "$GT::SQL::error";
|
||||
my $poll_id = $rec->insert_id;
|
||||
|
||||
if (!$poll_id) {
|
||||
print "error: can't add poll, reason: $GT::SQL::error";
|
||||
return;
|
||||
}
|
||||
# Insert answers into PollAnswer table
|
||||
my $votes_sum;
|
||||
my $b = $DB->table('PollAnswer');
|
||||
for (my $i = 1; $i <= $MAX; $i++) {
|
||||
my %answer;
|
||||
if ($IN->param("poll_answer_answer_$i")) {
|
||||
$answer{'poll_answer_answer'} = $IN->param("poll_answer_answer_$i");
|
||||
$answer{'poll_answer_votes'} = 0;
|
||||
$answer{'poll_id_fk'} = $poll_id;
|
||||
my $res = $b->insert(\%answer);
|
||||
my $ans_id = $res->insert_id;
|
||||
if ($i == $cgi->{poll_answer}) {
|
||||
$a->update( { poll_answer => $ans_id }, { poll_id => $poll_id });
|
||||
}
|
||||
};
|
||||
};
|
||||
my $msg = "Poll added successfully!";
|
||||
&list($msg);
|
||||
}
|
||||
|
||||
sub modify_form {
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
my $id = $IN->param('poll_id') || shift;
|
||||
if (!$id) {
|
||||
print "no poll id passed";
|
||||
return;
|
||||
}
|
||||
my $poll = $DB->table('Poll')->get($id);
|
||||
my $ans_db = $DB->table('PollAnswer');
|
||||
my $poll_answer = $ans_db->select( { poll_id_fk => $id } )->fetchall_hashref();
|
||||
my $hits = $ans_db->hits;
|
||||
my $form = include_form( { do => 'modify', %$poll, poll_answers_loop => $poll_answer}, 4 );
|
||||
print $form;
|
||||
}
|
||||
|
||||
sub modify {
|
||||
# -------------------------------------------------------------------
|
||||
#
|
||||
my $poll_id = $IN->param('poll_id');
|
||||
my $cgi = $IN->get_hash();
|
||||
|
||||
# Update existing record or insert new record (PollAnswer table)
|
||||
my $votes_sum = 0;
|
||||
my $a = $DB->table('PollAnswer');
|
||||
for (my $i = 1; $i <= $MAX; $i++) {
|
||||
my %answer;
|
||||
if ($IN->param("poll_answer_answer_$i")) {
|
||||
$answer{'poll_answer_answer'} = $IN->param("poll_answer_answer_$i");
|
||||
if ($IN->param("poll_answer_votes_$i")) {
|
||||
$answer{'poll_answer_votes'} = $IN->param("poll_answer_votes_$i");
|
||||
}
|
||||
$answer{'poll_id_fk'} = $poll_id;
|
||||
$votes_sum += $IN->param("poll_answer_votes_$i");
|
||||
if ($IN->param("current_poll_answer_id_$i")) {
|
||||
$a->update(\%answer, { poll_answer_id => $IN->param("current_poll_answer_id_$i") }) or die $GT::SQL::error;
|
||||
}
|
||||
else {
|
||||
$a->insert(\%answer);
|
||||
}
|
||||
}
|
||||
elsif ($IN->param("current_poll_answer_id_$i") and not $IN->param("poll_answer_answer_$i")) {
|
||||
$a->delete( { poll_answer_id => $IN->param("current_poll_answer_id_$i") });
|
||||
};
|
||||
};
|
||||
|
||||
# Update vote count
|
||||
my $p = $DB->table('Poll');
|
||||
my $poll_type = $IN->param('poll_type') || '0';
|
||||
my $cols = $p->cols;
|
||||
my $mod = {};
|
||||
foreach (keys %$cols) {
|
||||
next if ($_ eq 'poll_id');
|
||||
next if ($_ eq 'poll_date');
|
||||
next if ($_ eq 'poll_home');
|
||||
next if ($_ eq 'poll_enabled');
|
||||
$mod->{$_} = $cgi->{$_};
|
||||
}
|
||||
if (!$poll_type) {
|
||||
$mod->{poll_answer} = 0;
|
||||
$mod->{poll_type} = 0;
|
||||
}
|
||||
$p->update( $mod , { poll_id => $poll_id }) or die "$GT::SQL::error";
|
||||
&list("The poll has been updated successfully!");
|
||||
}
|
||||
|
||||
sub disable {
|
||||
my $poll_id = $IN->param('poll_id');
|
||||
my $p = $DB->table('Poll');
|
||||
|
||||
my $poll = $p->get($poll_id);
|
||||
if (!$poll) {
|
||||
return &list("No such quiz or poll: $poll_id");
|
||||
}
|
||||
$p->update({ poll_enabled => 0 }, { poll_id => $poll_id });
|
||||
$IN->param('poll_id',"");
|
||||
$IN->param('poll_type',$poll->{poll_type});
|
||||
&list("The poll/quiz $poll->{poll_question} has been disabled.");
|
||||
}
|
||||
|
||||
sub enable {
|
||||
my $poll_id = $IN->param('poll_id');
|
||||
my $p = $DB->table('Poll');
|
||||
|
||||
my $poll = $p->get($poll_id);
|
||||
if (!$poll) {
|
||||
return &list("No such quiz or poll: $poll_id");
|
||||
}
|
||||
$p->update({ poll_enabled => 1 }, { poll_id => $poll_id });
|
||||
$IN->param('poll_id',"");
|
||||
$IN->param('poll_type',$poll->{poll_type});
|
||||
&list("The poll/quiz $poll->{poll_question} has been enabled.");
|
||||
}
|
||||
|
||||
sub home_show {
|
||||
my $poll_id = $IN->param('poll_id');
|
||||
my $p = $DB->table('Poll');
|
||||
|
||||
my $poll = $p->get($poll_id);
|
||||
if (!$poll) {
|
||||
return &list("No such quiz or poll: $poll_id");
|
||||
}
|
||||
$p->update({ poll_home => 0 });
|
||||
$p->update({ poll_home => 1 }, { poll_id => $poll_id });
|
||||
$IN->param('poll_id',"");
|
||||
$IN->param('poll_type',$poll->{poll_type});
|
||||
&list("The poll/quiz $poll->{poll_question} has been set to show on home page.");
|
||||
}
|
||||
|
||||
sub home_notshow {
|
||||
my $poll_id = $IN->param('poll_id');
|
||||
my $p = $DB->table('Poll');
|
||||
|
||||
my $poll = $p->get($poll_id);
|
||||
if (!$poll) {
|
||||
return &list("No such quiz or poll: $poll_id");
|
||||
}
|
||||
$p->update({ poll_home => 1 }, { poll_id => $poll_id });
|
||||
$IN->param('poll_id',"");
|
||||
$IN->param('poll_type',$poll->{poll_type});
|
||||
&list("The poll/quiz $poll->{poll_question} has been removed from showing on the home page.");
|
||||
}
|
83
site/forum.slowtwitch.com/cgi-bin/poll/admin/sql.cgi
Executable file
83
site/forum.slowtwitch.com/cgi-bin/poll/admin/sql.cgi
Executable file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw/$DB $CFG/;
|
||||
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
|
||||
main();
|
||||
|
||||
sub main {
|
||||
# Create the Poll table.
|
||||
my $p = $DB->creator ('Poll');
|
||||
$p->cols([
|
||||
poll_id => { type => 'INT', not_null => 1 },
|
||||
poll_question => { type => 'VARCHAR',size => '255',not_null => 1},
|
||||
poll_answer => { type => 'VARCHAR',size => '255',not_null => 1},
|
||||
poll_type => { type => 'TINYINT',default => '1',not_null => '1'},
|
||||
poll_votes => { type => 'INT',not_null => 1},
|
||||
poll_enabled => { type => 'TINYINT',default => '1',not_null => 1},
|
||||
poll_date => { type => 'Date', not_null => 1},
|
||||
poll_text => { type => 'TEXT', not_null => 0},
|
||||
poll_home => { type => 'TINYINT',default => '0',not_null => 1},
|
||||
]);
|
||||
|
||||
$p->pk('poll_id');
|
||||
$p->ai('poll_id');
|
||||
|
||||
if (!$p->create and $GT::SQL::errcode eq 'TBLEXISTS') {
|
||||
$p->set_defaults();
|
||||
$p->save_schema();
|
||||
}
|
||||
|
||||
# Create the PollAnswer table
|
||||
my $a = $DB->creator ('PollAnswer');
|
||||
$a->cols([
|
||||
poll_answer_id => { type => 'INT', not_null => 1 },
|
||||
poll_id_fk => { type => 'INT', not_null => 1 },
|
||||
poll_answer_answer => {type => 'VARCHAR',size => '255',not_null => 1,default => 0},
|
||||
poll_answer_votes => {type => 'INT',not_null => 1,default => 0}
|
||||
]);
|
||||
|
||||
$a->pk('poll_answer_id');
|
||||
$a->ai('poll_answer_id');
|
||||
|
||||
$a->fk({
|
||||
Poll => { poll_id_fk => 'poll_id' },
|
||||
});
|
||||
|
||||
$a->index({ a_pl => ['poll_id_fk']});
|
||||
|
||||
if (!$a->create and $GT::SQL::errcode eq 'TBLEXISTS') {
|
||||
$a->set_defaults();
|
||||
$a->save_schema();
|
||||
}
|
||||
|
||||
# Create the PollVote table
|
||||
my $v = $DB->creator ('PollVote');
|
||||
$v->cols([
|
||||
poll_vote_id => { type => 'INT', not_null => 1 },
|
||||
poll_id_fk => { type => 'INT', not_null => 1 },
|
||||
poll_vote_ip => { type => 'VARCHAR',size => '15', not_null => 1 },
|
||||
poll_vote_time => { type => 'INT', default => '0', not_null => '1' }
|
||||
]);
|
||||
|
||||
$v->pk('poll_vote_id');
|
||||
$v->ai('poll_vote_id');
|
||||
|
||||
$v->fk ( {
|
||||
'Poll' => {
|
||||
'poll_id_fk' => 'poll_id'
|
||||
},
|
||||
});
|
||||
|
||||
$v->index({ v_p => ['poll_id_fk'] });
|
||||
|
||||
if (!$v->create and $GT::SQL::errcode eq 'TBLEXISTS') {
|
||||
$v->set_defaults();
|
||||
$v->save_schema();
|
||||
}
|
||||
|
||||
}
|
||||
|
11
site/forum.slowtwitch.com/cgi-bin/poll/poll.cgi
Executable file
11
site/forum.slowtwitch.com/cgi-bin/poll/poll.cgi
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw/$DB $CFG $IN/;
|
||||
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
|
||||
use Poll;
|
||||
Poll::handle();
|
||||
|
107
site/forum.slowtwitch.com/cgi-bin/silent_post_live.cgi
Executable file
107
site/forum.slowtwitch.com/cgi-bin/silent_post_live.cgi
Executable file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw/:objects/;
|
||||
use GForum::Payment qw/:status :log/;
|
||||
use Data::Dumper;
|
||||
use vars qw/%INVALID %EMPTY/;
|
||||
use GT::Payment::Direct::AuthorizeDotNetRec;
|
||||
use Slowtwitch::Payment;
|
||||
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
|
||||
main();
|
||||
|
||||
sub main {
|
||||
silent_post();
|
||||
}
|
||||
|
||||
sub silent_post {
|
||||
# -----------------------------------------------------------------------------
|
||||
# Handle PayPal postback
|
||||
my $unique = $IN->param('x_invoice_num');
|
||||
my $pay = $DB->table('Subscription_Payments');
|
||||
my $log = $DB->table('Subscription_PaymentLogs');
|
||||
my $in = $IN->get_hash();
|
||||
my $payment = $pay->get($unique);
|
||||
if (!$payment) {
|
||||
open (LOG, ">>/var/home/virginia/virginialo.com/cgi-bin/forum/admin/auth_silent_error.log");
|
||||
print LOG Dumper($in);
|
||||
close (LOG);
|
||||
print $IN->header . "No such invoice: $unique.";
|
||||
return;
|
||||
}
|
||||
|
||||
open (LOG, ">>/var/home/virginia/virginialo.com/cgi-bin/forum/admin/auth_silent_live.log");
|
||||
print LOG Dumper($payment,$in);
|
||||
close (LOG);
|
||||
|
||||
print $IN->header;
|
||||
GT::Payment::Direct::AuthorizeDotNetRec::process(
|
||||
param => $IN,
|
||||
test_mode => $CFG->{payment}->{direct}->{used}->{AuthorizeDotNetRec}->{test_mode},
|
||||
account_username => $CFG->{payment}->{direct}->{used}->{AuthorizeDotNetRec}->{account_username},
|
||||
md5_key => $CFG->{payment}->{direct}->{used}->{AuthorizeDotNetRec}->{md5_key},
|
||||
duplicate => sub {
|
||||
my $id = $IN->param('x_trans_id');
|
||||
my $cond = GT::SQL::Condition->new();
|
||||
$cond->add(paylogs_payments_id => '=' => $unique);
|
||||
$cond->add(paylogs_type => '=' => LOG_ACCEPTED);
|
||||
$cond->add(paylogs_text => LIKE => "%Transaction ID: $id\n%");
|
||||
my $found = $log->count($cond);
|
||||
#warn "$found ($id) **";
|
||||
return $found ? undef : 1; # True if everything checks out; undef if a duplicate was found
|
||||
},
|
||||
on_invalid => sub {
|
||||
},
|
||||
on_error => sub {
|
||||
my $errmsg = shift;
|
||||
print $errmsg . "\n";
|
||||
$pay->update(
|
||||
{ payments_status => ERROR, payments_last => time },
|
||||
{ payments_id => $payment->{payments_id} }
|
||||
);
|
||||
|
||||
$log->insert({
|
||||
paylogs_payments_id => $payment->{payments_id},
|
||||
paylogs_type => LOG_ERROR,
|
||||
paylogs_time => time,
|
||||
paylogs_text => $errmsg
|
||||
});
|
||||
},
|
||||
on_recurring => sub {
|
||||
if ($IN->param('x_amount') < $payment->{payments_amount}) {
|
||||
$log->insert({
|
||||
paylogs_payments_id => $payment->{payments_id},
|
||||
paylogs_type => LOG_ERROR,
|
||||
paylogs_time => time,
|
||||
paylogs_text => "Invalid payment (payment amount is less than original charge): " .
|
||||
$IN->param('x_amount') . " < " . $payment->{payments_amount}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$pay->update(
|
||||
{ payments_status => COMPLETED, payments_last => time },
|
||||
{ payments_id => $payment->{payments_id} }
|
||||
);
|
||||
|
||||
$log->insert({
|
||||
paylogs_payments_id => $payment->{payments_id},
|
||||
paylogs_type => LOG_ACCEPTED,
|
||||
paylogs_time => time,
|
||||
paylogs_text => (
|
||||
"Transaction ID: " . $IN->param('x_trans_id') . "\n" .
|
||||
"Amount: " . $IN->param('x_amount') . " " .
|
||||
"Subscription payment #: " . $IN->param('x_subscription_paynum') . " " .
|
||||
"Subscription ID: " . $IN->param('x_subscription_id') . "\n"
|
||||
)
|
||||
});
|
||||
|
||||
Slowtwitch::Payment::process_payment($payment->{payments_userid}, '', $payment->{payments_id});
|
||||
}
|
||||
);
|
||||
|
||||
1;
|
||||
}
|
24
site/forum.slowtwitch.com/cgi-bin/threads.cgi
Executable file
24
site/forum.slowtwitch.com/cgi-bin/threads.cgi
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use lib "/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin";
|
||||
use GForum qw/$IN $CFG $DB/;
|
||||
use GForum::SEO;
|
||||
|
||||
GForum::init("/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin");
|
||||
|
||||
my @ids = split(/\s*,\s*/, $IN->param('id') || '');
|
||||
|
||||
print $IN->header;
|
||||
if (scalar @ids) {
|
||||
my $posts = $DB->table('Post')->select(/post_id post_subject/, { post_id => \@ids })->fetchall_hashref;
|
||||
my %posts = map { $_->{post_id} => $_ } @$posts;
|
||||
|
||||
my ($count, $html) = (0, "");
|
||||
foreach my $id (@ids) {
|
||||
$count++;
|
||||
my $url = $CFG->{cgi_root_url} . GForum::SEO::url(type => "post", id => $id);
|
||||
$html .= qq!<div class="link"><div><span>$count</span></div><a href="$url">$posts{$id}{post_subject}</a></div>!;
|
||||
}
|
||||
print qq!<div class="list">$html</div>!;
|
||||
}
|
6
site/forum.slowtwitch.com/cgi-bin/ticker/admin/.htaccess
Normal file
6
site/forum.slowtwitch.com/cgi-bin/ticker/admin/.htaccess
Normal file
@ -0,0 +1,6 @@
|
||||
AuthUserFile /home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin/.htpasswd
|
||||
AuthGroupFile /dev/null
|
||||
AuthType Basic
|
||||
AuthName "Gossamer Forum Administration"
|
||||
|
||||
require valid-user
|
160
site/forum.slowtwitch.com/cgi-bin/ticker/admin/admin.cgi
Executable file
160
site/forum.slowtwitch.com/cgi-bin/ticker/admin/admin.cgi
Executable file
@ -0,0 +1,160 @@
|
||||
#!/bin/env perl
|
||||
#
|
||||
# The ticker (client & admin) loosely follows an MVC architecture. The model
|
||||
# is over in Ticker.pm (it does all the DB work). ticker.cgi is the view for
|
||||
# the client, while this is the view+controller for the admin.
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw($IN);
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
use Ticker;
|
||||
use Error qw(:try);
|
||||
|
||||
use constant {
|
||||
STATE_NORMAL => 0,
|
||||
STATE_UPDATE => 1,
|
||||
STATE_REDIRECT => 2,
|
||||
ADMIN_URL => "http://forum.slowtwitch.com/cgi-bin/ticker/admin/admin.cgi"
|
||||
};
|
||||
|
||||
# prototypes.
|
||||
sub controller();
|
||||
sub view($);
|
||||
|
||||
# And call the controller.
|
||||
controller();
|
||||
|
||||
#
|
||||
# This is the controller. This is where work gets done.
|
||||
#
|
||||
sub controller() {
|
||||
my %viewstate = (state => STATE_NORMAL);
|
||||
|
||||
# if we have an action parameter (that's non-empty), then do work:
|
||||
if(defined $IN->param('action') && length($IN->param('action')) > 0) {
|
||||
$viewstate{state} = STATE_REDIRECT;
|
||||
try {
|
||||
my $p = $IN->get_hash();
|
||||
if($p->{action} =~ /create/) {
|
||||
Ticker::create_ticker($p->{msg}, $p->{link});
|
||||
} elsif($p->{action} =~ /show_update/) {
|
||||
$viewstate{state} = STATE_UPDATE;
|
||||
$viewstate{id} = $p->{'id'};
|
||||
} elsif($p->{action} =~ /do_update/) {
|
||||
Ticker::update_ticker($p->{'id'}, $p->{'msg'}, $p->{'link'});
|
||||
} elsif($p->{action} =~ /delete/) {
|
||||
Ticker::delete_ticker($p->{'id'});
|
||||
}
|
||||
} catch Ticker::TickerException with {
|
||||
# oops. something bad happened.
|
||||
$viewstate{error} = "Error: " . shift;
|
||||
# reset the viewstate so that we display the error message.
|
||||
$viewstate{state} = STATE_NORMAL;
|
||||
};
|
||||
}
|
||||
|
||||
return view(\%viewstate);
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Build the view, which takes a single hashref describing how the view should
|
||||
# behave.
|
||||
#
|
||||
sub view($) {
|
||||
my ($state) = @_;
|
||||
my %s = %$state;
|
||||
|
||||
# If the state is redirect, we're done.
|
||||
if($s{state} == STATE_REDIRECT) {
|
||||
print $IN->redirect(ADMIN_URL);
|
||||
return;
|
||||
}
|
||||
|
||||
# Now let's actually build the view, depending on our current state:
|
||||
print $IN->header();
|
||||
print qq{<html><head><title>Ticker Admin</title></head><body>};
|
||||
|
||||
# Try to load all the tickers:
|
||||
try {
|
||||
$s{data} = Ticker::read_tickers();
|
||||
|
||||
# Are we also trying to update a record? Yeah, I know - we're
|
||||
# hitting the db again. I wish that fetchall_hashref actually worked...
|
||||
if(defined $s{id}) {
|
||||
my $result = Ticker::read_ticker($s{id});
|
||||
$s{msg} = $result->{ticker_text};
|
||||
$s{link} = $result->{ticker_link};
|
||||
}
|
||||
} catch Ticker::TickerException with {
|
||||
$s{error} .= " Could not read tickers from database!";
|
||||
};
|
||||
|
||||
# Print an error message if we have one:
|
||||
if(defined $s{error}) {
|
||||
print "<p>" . $s{error} . "</p>";
|
||||
}
|
||||
|
||||
# What should the top form look like?
|
||||
if($s{state} == STATE_NORMAL) {
|
||||
$s{title} = 'Create a ticker:';
|
||||
$s{submit} = 'Create ticker';
|
||||
$s{action} = 'create';
|
||||
$s{id} = "";
|
||||
$s{msg} = "";
|
||||
$s{link} = "";
|
||||
} elsif($s{state} == STATE_UPDATE) {
|
||||
$s{title} = 'Update a ticker:';
|
||||
$s{submit} = 'Update ticker';
|
||||
$s{action} = 'do_update';
|
||||
}
|
||||
|
||||
# print the form, which is configured for the type of action we're
|
||||
# performing:
|
||||
print qq{<h3>} . $s{title} . qq{</h3>
|
||||
<form method="post" action="} . ADMIN_URL . qq{">
|
||||
<input type="hidden" name="action" value="} .
|
||||
$s{action} . qq{"/>
|
||||
<input type="hidden" name="id" value="} . $s{id} . qq{"/>
|
||||
<div><label for="message">Message:</label>
|
||||
<input type="text" name="msg" value="} . $s{msg} . qq{"/>
|
||||
</div><div><label for="link">Link:</label>
|
||||
<input type="text" name="link" value="} . $s{link} . qq{"/>
|
||||
</div><div><input type="submit" value="} . $s{submit} . qq{"/>
|
||||
</div></form>
|
||||
};
|
||||
|
||||
# provide a way to get back to the create interface:
|
||||
if($s{action} =~ /update/) {
|
||||
print qq{<a href="} . ADMIN_URL . qq{">Create a ticker instead.</a>};
|
||||
}
|
||||
|
||||
# Now print the entire list of all tickers.
|
||||
print qq{<h3>Current tickers:</h3>};
|
||||
|
||||
|
||||
# If there are no tickers, say so:
|
||||
if(@{$s{data}} == 0) {
|
||||
print "There are no tickers.";
|
||||
} else {
|
||||
# Print a table showing the ID, delete/edit links, messages, and links:
|
||||
print "<table>";
|
||||
print "<tr><td>ID</td><td/><td/><td>Message</td><td>Link</td></tr>";
|
||||
foreach my $k (@{$s{data}}) {
|
||||
my $id = $k->{ticker_id};
|
||||
my $msg = $k->{ticker_text};
|
||||
my $link = $k->{ticker_link};
|
||||
print qq{<tr><td>$id</td><td>
|
||||
<a href="} . ADMIN_URL . qq{?action=delete&id=$id">Delete</a></td><td>
|
||||
<a href="} . ADMIN_URL . qq{?action=show_update&id=$id">Update</a></td><td>} .
|
||||
$msg . "</td><td>" .
|
||||
qq{<a href="} . $link . qq{">} .
|
||||
$link . "</a></td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
print qq{</body></html>};
|
||||
}
|
||||
|
8
site/forum.slowtwitch.com/cgi-bin/ticker/admin/sql.cgi
Executable file
8
site/forum.slowtwitch.com/cgi-bin/ticker/admin/sql.cgi
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use Ticker;
|
||||
|
||||
Ticker::create_table();
|
18
site/forum.slowtwitch.com/cgi-bin/ticker/coupons.cgi
Executable file
18
site/forum.slowtwitch.com/cgi-bin/ticker/coupons.cgi
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/env perl
|
||||
#
|
||||
# Handle requests for the client-side view of the Ticker.
|
||||
#
|
||||
# Returns an xml document containing all the tickers currently present in
|
||||
# the database.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw($IN);
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
use Ticker;
|
||||
|
||||
print $IN->header();
|
||||
GForum::Template->parse_print('include_ticker_coupons.html');
|
||||
|
17
site/forum.slowtwitch.com/cgi-bin/ticker/ticker.cgi
Executable file
17
site/forum.slowtwitch.com/cgi-bin/ticker/ticker.cgi
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/env perl
|
||||
#
|
||||
# Handle requests for the client-side view of the Ticker.
|
||||
#
|
||||
# Returns an xml document containing all the tickers currently present in
|
||||
# the database.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw($IN);
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
use Ticker;
|
||||
|
||||
print $IN->header(-type => "text/xml");
|
||||
print Ticker::read_tickers_xml();
|
@ -0,0 +1,6 @@
|
||||
AuthUserFile /home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin/.htpasswd
|
||||
AuthGroupFile /dev/null
|
||||
AuthType Basic
|
||||
AuthName "Gossamer Forum Administration"
|
||||
|
||||
require valid-user
|
160
site/forum.slowtwitch.com/cgi-bin/tickerad/admin/admin.cgi
Executable file
160
site/forum.slowtwitch.com/cgi-bin/tickerad/admin/admin.cgi
Executable file
@ -0,0 +1,160 @@
|
||||
#!/bin/env perl
|
||||
#
|
||||
# The ticker (client & admin) loosely follows an MVC architecture. The model
|
||||
# is over in TickerAd.pm (it does all the DB work). ticker.cgi is the view for
|
||||
# the client, while this is the view+controller for the admin.
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw($IN);
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
use TickerAd;
|
||||
use Error qw(:try);
|
||||
|
||||
use constant {
|
||||
STATE_NORMAL => 0,
|
||||
STATE_UPDATE => 1,
|
||||
STATE_REDIRECT => 2,
|
||||
ADMIN_URL => "http://forum.slowtwitch.com/cgi-bin/tickerad/admin/admin.cgi"
|
||||
};
|
||||
|
||||
# prototypes.
|
||||
sub controller();
|
||||
sub view($);
|
||||
|
||||
# And call the controller.
|
||||
controller();
|
||||
|
||||
#
|
||||
# This is the controller. This is where work gets done.
|
||||
#
|
||||
sub controller() {
|
||||
my %viewstate = (state => STATE_NORMAL);
|
||||
|
||||
# if we have an action parameter (that's non-empty), then do work:
|
||||
if(defined $IN->param('action') && length($IN->param('action')) > 0) {
|
||||
$viewstate{state} = STATE_REDIRECT;
|
||||
try {
|
||||
my $p = $IN->get_hash();
|
||||
if($p->{action} =~ /create/) {
|
||||
TickerAd::create_ticker($p->{msg}, $p->{link});
|
||||
} elsif($p->{action} =~ /show_update/) {
|
||||
$viewstate{state} = STATE_UPDATE;
|
||||
$viewstate{id} = $p->{'id'};
|
||||
} elsif($p->{action} =~ /do_update/) {
|
||||
TickerAd::update_ticker($p->{'id'}, $p->{'msg'}, $p->{'link'});
|
||||
} elsif($p->{action} =~ /delete/) {
|
||||
TickerAd::delete_ticker($p->{'id'});
|
||||
}
|
||||
} catch TickerAd::TickerAdException with {
|
||||
# oops. something bad happened.
|
||||
$viewstate{error} = "Error: " . shift;
|
||||
# reset the viewstate so that we display the error message.
|
||||
$viewstate{state} = STATE_NORMAL;
|
||||
};
|
||||
}
|
||||
|
||||
return view(\%viewstate);
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Build the view, which takes a single hashref describing how the view should
|
||||
# behave.
|
||||
#
|
||||
sub view($) {
|
||||
my ($state) = @_;
|
||||
my %s = %$state;
|
||||
|
||||
# If the state is redirect, we're done.
|
||||
if($s{state} == STATE_REDIRECT) {
|
||||
print $IN->redirect(ADMIN_URL);
|
||||
return;
|
||||
}
|
||||
|
||||
# Now let's actually build the view, depending on our current state:
|
||||
print $IN->header();
|
||||
print qq{<html><head><title>TickerAd Admin</title></head><body>};
|
||||
|
||||
# Try to load all the tickers:
|
||||
try {
|
||||
$s{data} = TickerAd::read_tickers();
|
||||
|
||||
# Are we also trying to update a record? Yeah, I know - we're
|
||||
# hitting the db again. I wish that fetchall_hashref actually worked...
|
||||
if(defined $s{id}) {
|
||||
my $result = TickerAd::read_ticker($s{id});
|
||||
$s{msg} = $result->{ticker_text};
|
||||
$s{link} = $result->{ticker_link};
|
||||
}
|
||||
} catch TickerAd::TickerAdException with {
|
||||
$s{error} .= " Could not read tickers from database!";
|
||||
};
|
||||
|
||||
# Print an error message if we have one:
|
||||
if(defined $s{error}) {
|
||||
print "<p>" . $s{error} . "</p>";
|
||||
}
|
||||
|
||||
# What should the top form look like?
|
||||
if($s{state} == STATE_NORMAL) {
|
||||
$s{title} = 'Create a ticker:';
|
||||
$s{submit} = 'Create ticker';
|
||||
$s{action} = 'create';
|
||||
$s{id} = "";
|
||||
$s{msg} = "";
|
||||
$s{link} = "";
|
||||
} elsif($s{state} == STATE_UPDATE) {
|
||||
$s{title} = 'Update a ticker:';
|
||||
$s{submit} = 'Update ticker';
|
||||
$s{action} = 'do_update';
|
||||
}
|
||||
|
||||
# print the form, which is configured for the type of action we're
|
||||
# performing:
|
||||
print qq{<h3>} . $s{title} . qq{</h3>
|
||||
<form method="post" action="} . ADMIN_URL . qq{">
|
||||
<input type="hidden" name="action" value="} .
|
||||
$s{action} . qq{"/>
|
||||
<input type="hidden" name="id" value="} . $s{id} . qq{"/>
|
||||
<div><label for="message">Message:</label>
|
||||
<input type="text" name="msg" value="} . $s{msg} . qq{"/>
|
||||
</div><div><label for="link">Link:</label>
|
||||
<input type="text" name="link" value="} . $s{link} . qq{"/>
|
||||
</div><div><input type="submit" value="} . $s{submit} . qq{"/>
|
||||
</div></form>
|
||||
};
|
||||
|
||||
# provide a way to get back to the create interface:
|
||||
if($s{action} =~ /update/) {
|
||||
print qq{<a href="} . ADMIN_URL . qq{">Create a ticker instead.</a>};
|
||||
}
|
||||
|
||||
# Now print the entire list of all tickers.
|
||||
print qq{<h3>Current tickers:</h3>};
|
||||
|
||||
|
||||
# If there are no tickers, say so:
|
||||
if(@{$s{data}} == 0) {
|
||||
print "There are no tickers.";
|
||||
} else {
|
||||
# Print a table showing the ID, delete/edit links, messages, and links:
|
||||
print "<table>";
|
||||
print "<tr><td>ID</td><td/><td/><td>Message</td><td>Link</td></tr>";
|
||||
foreach my $k (@{$s{data}}) {
|
||||
my $id = $k->{ticker_id};
|
||||
my $msg = $k->{ticker_text};
|
||||
my $link = $k->{ticker_link};
|
||||
print qq{<tr><td>$id</td><td>
|
||||
<a href="} . ADMIN_URL . qq{?action=delete&id=$id">Delete</a></td><td>
|
||||
<a href="} . ADMIN_URL . qq{?action=show_update&id=$id">Update</a></td><td>} .
|
||||
$msg . "</td><td>" .
|
||||
qq{<a href="} . $link . qq{">} .
|
||||
$link . "</a></td></tr>";
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
print qq{</body></html>};
|
||||
}
|
||||
|
8
site/forum.slowtwitch.com/cgi-bin/tickerad/admin/sql.cgi
Executable file
8
site/forum.slowtwitch.com/cgi-bin/tickerad/admin/sql.cgi
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use Ticker;
|
||||
|
||||
Ticker::create_table();
|
18
site/forum.slowtwitch.com/cgi-bin/tickerad/coupons.cgi
Executable file
18
site/forum.slowtwitch.com/cgi-bin/tickerad/coupons.cgi
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/env perl
|
||||
#
|
||||
# Handle requests for the client-side view of the Ticker.
|
||||
#
|
||||
# Returns an xml document containing all the tickers currently present in
|
||||
# the database.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw($IN);
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
use Ticker;
|
||||
|
||||
print $IN->header();
|
||||
GForum::Template->parse_print('include_ticker_coupons.html');
|
||||
|
17
site/forum.slowtwitch.com/cgi-bin/tickerad/ticker.cgi
Executable file
17
site/forum.slowtwitch.com/cgi-bin/tickerad/ticker.cgi
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/env perl
|
||||
#
|
||||
# Handle requests for the client-side view of the Ticker.
|
||||
#
|
||||
# Returns an xml document containing all the tickers currently present in
|
||||
# the database.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw($IN);
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
use Ticker;
|
||||
|
||||
print $IN->header(-type => "text/xml");
|
||||
print Ticker::read_tickers_xml();
|
89
site/forum.slowtwitch.com/cgi-bin/toggle.cgi
Executable file
89
site/forum.slowtwitch.com/cgi-bin/toggle.cgi
Executable file
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/perl
|
||||
# ==================================================================
|
||||
# Gossamer Forum -
|
||||
#
|
||||
# Website : http://gossamer-threads.com/
|
||||
# Support : http://gossamer-threads.com/scripts/support/
|
||||
# CVS Info :
|
||||
# Revision : $Id: gforum.cgi,v 1.52.2.5 2003/10/10 20:30:01 jagerman Exp $
|
||||
#
|
||||
# Copyright (c) 2003 Gossamer Threads Inc. All Rights Reserved.
|
||||
# Redistribution in part or in whole strictly prohibited. Please
|
||||
# see LICENSE file for full details.
|
||||
# ==================================================================
|
||||
use strict;
|
||||
use lib '/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin';
|
||||
use GForum qw/:forum :user $DB $IN $CFG $USER $GUEST %HIDDEN $TEMPLATE_SET/;
|
||||
use GForum::Template;
|
||||
use GForum::Authenticate;
|
||||
|
||||
GForum::init('/home/slowtwitch/forum.slowtwitch.com/cgi-bin/admin');
|
||||
|
||||
main();
|
||||
|
||||
sub main {
|
||||
# -------------------------------------------------------------------
|
||||
# Display whatever page the user has requested
|
||||
#
|
||||
local $SIG{__DIE__} = \&GForum::fatal;
|
||||
|
||||
# Show the disabled page if the forum has been disabled
|
||||
if ($CFG->{disabled} == 1) {
|
||||
print $IN->header;
|
||||
my $message = $CFG->{disabled_message};
|
||||
$message =~ s/\n/<br>\n/g;
|
||||
return GForum::Template->parse_print("disabled.html" => { message => \$message });
|
||||
}
|
||||
{
|
||||
# If the user is banned, simply deny them access
|
||||
my @expanded_bans = @{$CFG->{bans}};
|
||||
for (@expanded_bans) {
|
||||
if (/^(\d+\.\d+\.\d+\.)(\d+)-(\d+)$/ and $2 < $3) {
|
||||
# Allows you to specify '123.45.67.89-123' to ban that range of IP's
|
||||
for ($2 .. $3) {
|
||||
push @expanded_bans, "$1$_";
|
||||
}
|
||||
next;
|
||||
}
|
||||
# Turn a ban into a regexp
|
||||
my $ban = quotemeta($_);
|
||||
# *'s match anything
|
||||
$ban =~ s/\\\*/.*/g;
|
||||
# ?'s match any single character
|
||||
$ban =~ s/\\\?/./g;
|
||||
if ($ENV{REMOTE_HOST} and $ENV{REMOTE_HOST} =~ /^$ban$/i or $ENV{REMOTE_ADDR} =~ /^$ban$/i) {
|
||||
print $IN->header;
|
||||
return GForum::Template->parse_print($CFG->{functions}->{banned}->{page}, { error => GForum::language('USER_BANNED') });
|
||||
}
|
||||
}
|
||||
}
|
||||
GForum::authenticate() or return; # False = stop!
|
||||
|
||||
if ($CFG->{disabled} == 2 and (not $USER or $USER->{user_status} != ADMINISTRATOR)) {
|
||||
print $IN->header;
|
||||
my $message = $CFG->{disabled_message};
|
||||
$message =~ s/\n/<br>\n/g;
|
||||
return GForum::Template->parse_print("disabled.html" => { message => \$message });
|
||||
}
|
||||
|
||||
my $template_set = $IN->param('t');
|
||||
if (not $template_set or $template_set !~ /^[\w-]+$/ or not -d "$CFG->{admin_root_path}/templates/$template_set" or $template_set =~ /^(?:help|admin|fileman|CVS)$/) {
|
||||
$template_set = '';
|
||||
}
|
||||
else { # It's good!
|
||||
$HIDDEN{t} = $template_set;
|
||||
}
|
||||
|
||||
if ($USER) {
|
||||
if ($USER->{user_show_racetags}) {
|
||||
$DB->table('User')->update({ user_show_racetags => 0 }, { user_id => $USER->{user_id} });
|
||||
print $IN->header . qq~Hidden <a href="#" onclick="return status_toggle()">(click to unhide)</a>~;
|
||||
}
|
||||
else {
|
||||
$DB->table('User')->update({ user_show_racetags => 1 }, { user_id => $USER->{user_id} });
|
||||
print $IN->header . qq~Viewable <a href="#" onclick="return status_toggle()">(click to hide)</a>~;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
27
site/forum.slowtwitch.com/cgi-bin/widget.cgi
Executable file
27
site/forum.slowtwitch.com/cgi-bin/widget.cgi
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use lib '/var/home/slowtwitch/slowtwitch.com/cgi-bin/articles/admin';
|
||||
|
||||
use Links qw/$PLG $IN $DB/;
|
||||
use Links::User::Page;
|
||||
|
||||
local $SIG{__DIE__} = \&Links::fatal;
|
||||
|
||||
Links::init('/var/home/slowtwitch/slowtwitch.com/cgi-bin/articles/admin');
|
||||
|
||||
my $id = $IN->param('id');
|
||||
|
||||
print $IN->header;
|
||||
if ($id) {
|
||||
my $tab = $DB->table('Widgets');
|
||||
my $widget = $tab->get($id);
|
||||
|
||||
if ($widget) {
|
||||
if ($widget->{Image}) {
|
||||
my $fh = $tab->file_info('Image', $widget->{ID});
|
||||
$widget->{Image_URL} = '/images/widgets/' . $fh->File_RelativeURL;
|
||||
}
|
||||
print Links::SiteHTML::display('include_widgets', { widgets_loop => [$widget] });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user