discourse-legacysite-perl/site/slowtwitch.com/cgi-bin/articles/postback.cgi
2024-06-17 21:49:12 +10:00

63 lines
2.5 KiB
Perl
Executable File

#!/usr/local/bin/perl
# ==================================================================
# Gossamer Links - enhanced directory management system
#
# Website : http://gossamer-threads.com/
# Support : http://gossamer-threads.com/scripts/support/
# CVS Info : 087,071,086,086,085
# Revision : $Id: postback.cgi,v 1.6 2005/03/05 01:29:08 brewt Exp $
#
# Copyright (c) 2001 Gossamer Threads Inc. All Rights Reserved.
# Redistribution in part or in whole strictly prohibited. Please
# see LICENSE file for full details.
# ==================================================================
#
# This file (postback.cgi) is meant for handling postback for "remote" payment
# methods such as PayPal or WorldPay. Normal users should not reach this page,
# as this typically produces a blank (or nearly blank) page. No sort of user
# authentication is performed, and no user-based functionality is provided.
# Additionally, if no postback is found, or an error occurs, an ordinary die
# (producing a 500 Internal Server Error) is performed - payment providers
# often recognize this and will post the request again after a certain amount
# of time.
# Pragmas
use strict;
use lib '/var/home/slowtwitch/slowtwitch.com/cgi-bin/articles/admin';
# Internal modules
use Links qw/$CFG $IN/;
use Links::Payment;
Links::init('/var/home/slowtwitch/slowtwitch.com/cgi-bin/articles/admin');
$| = 1;
# Start
main();
sub main {
# -----------------------------------------------------------------------------
# Unlike the other .cgi's, we don't perform the various checks (such as the
# enabled/disabled check) because we ought to receive a posted payment even if
# the site has been disabled for some reason.
# Check for payment postbacks
if ($CFG->{payment}->{enabled} and $CFG->{payment}->{postback} and @{$CFG->{payment}->{postback}}) {
for my $postback (@{$CFG->{payment}->{postback}}) {
next unless exists $CFG->{payment}->{$postback->{type}}->{methods}->{$postback->{method}}
and exists $CFG->{payment}->{$postback->{type}}->{used}->{$postback->{method}};
my $var = $postback->{var};
if (my $val = $IN->param($var)) {
if (!$postback->{var_regex} or $val =~ /$postback->{var_regex}/) {
if (Links::Payment->postback($postback)) {
return;
}
}
}
}
}
Links::Payment->invalid_postback;
die 'postback.cgi called, but no payment method postback could be identified.';
}