site/cgi-bin/modules/BSE/Util/Tags.pm
site/cgi-bin/modules/BSE/Util/Valid.pm
site/cgi-bin/modules/BSE/Version.pm
+site/cgi-bin/modules/BSE/WebUtil.pm
site/cgi-bin/modules/Constants.pm
site/cgi-bin/modules/DevHelp/DynSort.pm
site/cgi-bin/modules/DevHelp/Formatter.pm
-VERSION=0.14_14
+VERSION=0.14_15
DISTNAME=bse-$(VERSION)
DISTBUILD=$(DISTNAME)
DISTTAR=../$(DISTNAME).tar
-- 2 - list in sections, but not on the menu
listed smallint not null default 1,
-- date last modified
- lastModified date not null,
+ lastModified datetime not null,
-- flags specified via the config file
-- used by code and templates
use lib "$FindBin::Bin/../modules";
use Articles;
use BSE::Request;
-use Util 'refresh_to';
+use BSE::WebUtil 'refresh_to_admin';
my $req = BSE::Request->new;
my $cfg = $req->cfg;
print $generator->generate($article, $articles);
}
else {
- my $urlbase = $cfg->entryErr('site', 'url');
- refresh_to("$urlbase/cgi-bin/admin/logon.pl");
+ refresh_to_admin($cfg, "/cgi-bin/admin/logon.pl");
}
use Articles;
use CGI qw(:standard);
use Constants;
-use Util qw(generate_button regen_and_refresh refresh_to);
+use Util qw(generate_button regen_and_refresh);
+use BSE::WebUtil qw(refresh_to_admin);
use Carp 'verbose';
use BSE::Request;
use URI::Escape;
my $cgi = $req->cgi;
my $siteurl = $cfg->entryErr('site', 'url');
unless ($req->check_admin_logon()) {
- refresh_to("$siteurl/cgi-bin/admin/logon.pl");
+ refresh_to_admin($cfg, "/cgi-bin/admin/logon.pl");
exit;
}
if ($baseurl =~ /menu\.pl$/) {
$baseurl .= "?m=".uri_escape("You don't have permission to regenerate that");
}
- refresh_to("$siteurl$baseurl");
+ refresh_to_admin($cfg, $baseurl);
}
}
}
else {
if ($req->user_can('regen_all')) {
regen_and_refresh('Articles', undef, 1,
- $siteurl . $baseurl, $cfg, $callback);
+ $baseurl, $cfg, $callback);
}
else {
if ($progress) {
if ($baseurl =~ /menu\.pl$/) {
$baseurl .= "?m=".uri_escape("You don't have permission to regenerate all");
}
- refresh_to("$siteurl$baseurl");
+ refresh_to_admin($cfg, $baseurl);
}
}
}
use BSE::DB;
use Generate;
use BSE::Cfg;
-use Util 'refresh_to';
+use BSE::WebUtil 'refresh_to_admin';
my $in_cgi = exists $ENV{REQUEST_METHOD};
if ($in_cgi) {
#eval "use CGI::Carp qw(fatalsToBrowser)";
}
if ($in_cgi) {
- refresh_to("$urlbase/cgi-bin/admin/menu.pl");
+ refresh_to_admin($cfg, "/cgi-bin/admin/menu.pl");
}
sub makeIndex {
use CGI::Carp 'fatalsToBrowser';
use BSE::Request;
use Constants;
-use Util 'refresh_to';
+use BSE::WebUtil qw/refresh_to refresh_to_admin/;
my $req = BSE::Request->new;
my $cfg = $req->cfg;
my $cgi = $req->cgi;
-my $urlbase = $cfg->entryVar('site', 'url');
unless ($req->check_admin_logon()) {
- refresh_to("$urlbase/cgi-bin/admin/logon.pl");
+ refresh_to_admin($cfg, "/cgi-bin/admin/logon.pl");
exit;
}
}
if ($cgi->param('refreshto')) {
- refresh_to($urlbase .$cgi->param('refreshto'));
+ refresh_to_admin($cgi->param('refreshto'));
}
elsif ($cgi->param('r')) {
refresh_to($cgi->param('r'));
}
elsif ($cgi->param('edit')) {
# refresh back to editor
- refresh_to("$urlbase/cgi-bin/admin/add.pl?id=$article->{parentid}#children");
+ refresh_to_admin($cfg, "/cgi-bin/admin/add.pl?id=$article->{parentid}#children");
}
else {
# refresh back to the parent
my $parent = $articles->getByPkey($article->{parentid});
- refresh_to("$urlbase$parent->{admin}");
+ refresh_to_admin($cfg, $parent->{admin});
}
use lib "$FindBin::Bin/../modules";
use Articles;
use BSE::Request;
-use Util 'refresh_to';
+use BSE::WebUtil 'refresh_to_admin';
use vars qw($VERSION);
-$VERSION = 1.02;
+$VERSION = 1.03;
my $req = BSE::Request->new;
my $cfg = $req->cfg;
my $cgi = $req->cgi;
-my $urlbase = $cfg->entryVar('site', 'url');
unless ($req->check_admin_logon()) {
- refresh_to("$urlbase/cgi-bin/admin/logon.pl");
+ refresh_to_admin("/cgi-bin/admin/logon.pl");
exit;
}
elsif ($sort eq 'current') {
$code = sub { $b->[1]{$b->[2]} <=> $a->[1]{$a->[2]} };
}
+ elsif ($sort eq 'id') {
+ $code = sub { $a->[0]{id} <=> $b->[0]{id} };
+ }
+ elsif (@kids) {
+ my @fields = split ',', $sort;
+ my @reverse = grep(s/^-// || 0, @fields);
+ my %reverse;
+ @reverse{@fields} = @reverse;
+ @fields = grep exists($kids[0]{$_}), @fields;
+ my @num =
+ my %num = map { $_ => 1 } $kids[0]->numeric;
+
+ $code =
+ sub {
+ for my $field (@fields) {
+ my $rev = $reverse{$field};
+ my $cmp;
+ if ($num{$field}) {
+ $cmp = $a->[0]{$field} <=> $b->[0]{$field};
+ }
+ else {
+ $cmp = lc $a->[0]{$field} cmp lc $b->[0]{$field};
+ }
+ $cmp = -$cmp if $rev;
+ return $cmp if $cmp;
+ }
+ return $a->[0]{id} <=> $b->[0]{id};
+ };
+ }
if ($reverse) {
my $temp = $code;
$code = sub { -$temp->() };
}
}
-refresh_to("$urlbase$refreshto");
+refresh_to_admin($cfg, $refreshto);
=head1 NAME
use BSE::Util::Tags;
use DevHelp::Report;
use DevHelp::HTML;
-use Util 'refresh_to';
+use BSE::WebUtil 'refresh_to';
my $req = BSE::Request->new;
my $cgi = $req->cgi;
use BSE::Sort;
use BSE::Util::Tags;
use BSE::Request;
-use Util 'refresh_to';
+use BSE::WebUtil 'refresh_to_admin';
use DevHelp::HTML;
use BSE::Arrows;
my $securlbase = $cfg->entryVar('site', 'secureurl');
my $baseurl = $cfg->entryVar('site', 'url');
unless ($req->check_admin_logon()) {
- refresh_to("$baseurl/cgi-bin/admin/logon.pl");
+ refresh_to_admin($cfg, "/cgi-bin/admin/logon.pl");
exit;
}
#my %session;
use BSE::Util::Tags;
use BSE::Template;
use Articles;
-use Util qw/refresh_to/;
+use BSE::WebUtil qw/refresh_to refresh_to_admin/;
use BSE::Message;
use BSE::Permissions;
use BSE::Request;
my $url = $q->param('r');
unless ($url) {
- $url = $cfg->entryErr('site', 'url') . "/cgi-bin/admin/subs.pl";
+ $url = "/cgi-bin/admin/subs.pl";
if ($msg) {
$url .= "?m=" . CGI::escape($msg);
}
}
- refresh_to($url);
+ refresh_to_admin($cfg, $url);
}
sub addsave {
customInt1 customInt2 customInt3 customInt4/;
}
+sub numeric {
+ qw(id listed parentid threshold summaryLength level
+ customInt1 customInt2 customInt3 customInt4);
+}
+
sub step_parents {
my ($self) = @_;
use strict;
use BSE::Util::Tags qw(tag_error_img);
use DevHelp::HTML;
+use BSE::CfgInfo 'admin_base_url';
my %actions =
(
my $r = $cgi->param('r');
unless ($r) {
- $r = $req->cfg->entryErr('site', 'url') . "/cgi-bin/admin/menu.pl";
+ $r = admin_base_url($req->cfg) . "/cgi-bin/admin/menu.pl";
}
return BSE::Template->get_refresh($r, $req->cfg);
delete $req->session->{adminuserid};
++$req->session->{changed};
- my $r = $req->cfg->entryErr('site', 'url') . "/cgi-bin/admin/logon.pl";
+ my $r = admin_base_url($req->cfg) . "/cgi-bin/admin/logon.pl";
return BSE::Template->get_refresh($r, $req->cfg);
}
use BSE::Util::Tags qw/tag_error_img/;
use BSE::Permissions;
use DevHelp::HTML;
+use BSE::CfgInfo qw(admin_base_url);
my %actions =
(
my $url = $req->cgi->param('r');
unless ($url) {
- $url = $req->cfg->entryVar('site', 'url');
+ $url = admin_base_url($req->cfg);
$url .= $ENV{SCRIPT_NAME};
$url .= "?$target=1";
while (my ($key, $value) = splice @parms, 0, 2) {
use strict;
use base qw(BSE::Edit::Base);
use BSE::Util::Tags qw(tag_error_img);
-use BSE::Util::SQL qw(now_sqldate);
+use BSE::Util::SQL qw(now_sqldate now_sqldatetime);
use BSE::Util::Valid qw/valid_date/;
use BSE::Permissions;
use DevHelp::HTML qw(:default popup_menu);
use BSE::Arrows;
-use BSE::CfgInfo qw(custom_class);
+use BSE::CfgInfo qw(custom_class admin_base_url);
sub article_dispatch {
my ($self, $req, $article, $articles) = @_;
my $cgi_uri = $self->{cfg}->entry('uri', 'cgi', '/cgi-bin');
my $images_uri = $self->{cfg}->entry('uri', 'images', '/images');
- my $urlbase = $req->cfg->entryVar('site', 'url');
+ my $urlbase = admin_base_url($req->cfg);
my $refresh_url = "$urlbase$ENV{SCRIPT_NAME}?id=$article->{id}";
my $t = $req->cgi->param('_t');
if ($t && $t =~ /^\w+$/) {
$img_prefix = '' unless defined $img_prefix;
$urladd = '' unless defined $urladd;
- my $urlbase = $req->cfg->entryVar('site', 'url');
+ my $urlbase = admin_base_url($req->cfg);
my $url = "$urlbase$ENV{SCRIPT_NAME}?id=$article->{id}";
my $t = $req->cgi->param('_t');
if ($t && $t =~ /^\w+$/) {
$$rindex >= 0 && $$rindex < @$files
or return '** movefiles can only be used in the files iterator **';
- my $urlbase = $self->{cfg}->entryVar('site', 'url');
+ my $urlbase = admin_base_url($req->cfg);
my $url = "$urlbase$ENV{SCRIPT_NAME}?id=$article->{id}$urladd";
my $t = $req->cgi->param('_t');
if ($t && $t =~ /^\w+$/) {
if !defined $data{summaryLength} || $data{summaryLength} =~ /^\s*$/;
}
$data{generator} = $self->generator;
- $data{lastModified} = now_sqldate();
+ $data{lastModified} = now_sqldatetime();
$data{level} = $level;
$data{listed} = 1 unless defined $data{listed};
$r .= "id=$article->{id}";
}
else {
- my $urlbase = $self->{cfg}->entryVar('site', 'url');
- $r = $urlbase . $article->{admin};
+
+ $r = admin_base_url($req->cfg) . $article->{admin};
}
return BSE::Template->get_refresh($r, $self->{cfg});
$article->{expire} = sql_date($cgi->param('expire')) || $Constants::D_99
if defined $cgi->param('expire') &&
$req->user_can('edit_field_edit_expire', $article);
- $article->{lastModified} = now_sqldate();
+ $article->{lastModified} = now_sqldatetime();
my $link_titles = $self->{cfg}->entryBool('basic', 'link_titles', 0);
if ($article->{link} &&
!$self->{cfg}->entry('protect link', $article->{id})) {
my $url = $cgi->param('r');
unless ($url) {
- my $urlbase = $self->{cfg}->entryVar('site', 'url');
+ my $urlbase = admin_base_url($self->{cfg});
$url = "$urlbase$ENV{SCRIPT_NAME}?id=$article->{id}";
$url .= "&message=" . CGI::escape($message) if $message;
if ($cgi->param('_t')) {
mov video/quicktime
moov video/quicktime
mpg video/mpeg
+ mp4 video/mp4
mpeg video/mpeg
avi video/avi
flc video/flc
wmv video/x-ms-wmv
asf video/x-ms-asf
- mp2 audio/mpeg
- mp3 audio/mpeg
- mp4 audio/mp4
+ mp2 audio/x-mpeg
+ mp3 audio/x-mpeg
m4a audio/m4a
3gp audio/3gpp
aif audio/aiff
$article->remove;
my $url = $req->cgi->param('r');
unless ($url) {
- my $urlbase = $self->{cfg}->entryVar('site', 'url');
+ my $urlbase = admin_base_url($req->cfg);
$url = "$urlbase$ENV{SCRIPT_NAME}?id=$parentid";
$url .= "&message=Article+deleted";
}
}
my $r = $req->cgi->param('r');
unless ($r) {
- $r = $req->cfg->entryVar('site', 'url') . "/cgi-bin/admin/add.pl?id=" . $article->{parentid};
+ $r = admin_base_url($req->cfg)
+ . "/cgi-bin/admin/add.pl?id=" . $article->{parentid};
}
return $self->refresh($article, $req->cgi, undef, 'Article hidden');
}
}
sub _image {
- my ($self, $im, $align, $url) = @_;
+ my ($self, $im, $align, $url, $style) = @_;
my $text = qq!<img src="/images/$im->{image}" width="$im->{width}"!
. qq! height="$im->{height}" alt="! . escape_html($im->{alt}).'"'
. qq! border="0"!;
$text .= qq! align="$align"! if $align && $align ne 'center';
+ if ($style) {
+ if ($style =~ /^\w+$/) {
+ $text .= qq! class="$style"!;
+ }
+ elsif ($style =~ /^\d/) {
+ $text .= qq! style="padding: $style"!;
+ }
+ else {
+ $text .= qq! style="$style"!;
+ }
+ }
$text .= qq! />!;
$text = qq!<div align="center">$text</div>!
if $align && $align eq 'center';
sub gimage {
my ($self, $args) = @_;
- my ($name, $align, $url) = split /\|/, $args, 3;
+ my ($name, $align, $url, $style) = split /\|/, $args, 4;
my $im = $self->{gen}->get_gimage($name);
if ($im) {
$self->_image($im, $align, $url);
my ($self, $args) = @_;
my $images = $self->{images};
- my ($index, $align, $url) = split /\|/, $args, 3;
+ my ($index, $align, $url, $style) = split /\|/, $args, 4;
my $text = '';
my $im;
if ($index =~ /^\d+$/) {
}
}
if ($im) {
- return $self->_image($im, $align, $url);
+ return $self->_image($im, $align, $url, $style);
}
else {
return '';
sub url {
my ($self, $action, $params, $name) = @_;
- my $url = $self->cfg->entryErr('site', 'url');
+ require BSE::CfgInfo;
+ my $url = BSE::CfgInfo::admin_base_url($self->{cfg});
$url .= "/cgi-bin/admin/$action.pl";
if ($params && keys %$params) {
$url .= "?" . join("&", map { "$_=".escape_uri($params->{$_}) } keys %$params);
use BSE::Util::SQL qw/now_datetime/;
use DevHelp::HTML;
use BSE::CfgInfo qw(custom_class);
+use BSE::WebUtil qw/refresh_to/;
use constant MAX_UNACKED_CONF_MSGS => 3;
use constant MIN_UNACKED_CONF_GAP => 2 * 24 * 60 * 60;
elsif ($subs) {
return if $self->send_conf_request($session, $cgi, $cfg, $user, 1);
}
- use Util qw/refresh_to/;
_got_user_refresh($session, $cgi, $cfg);
sub tag_adminbase {
my ($cfg, $arg) = @_;
- require Util;
- return escape_html(Util::admin_base_url($cfg));
+ require BSE::CfgInfo;
+ return escape_html(BSE::CfgInfo::admin_base_url($cfg));
}
sub static {
--- /dev/null
+package BSE::WebUtil;
+use strict;
+
+use vars qw(@EXPORT_OK @ISA);
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(refresh_to refresh_to_admin);
+
+sub refresh_to {
+ my ($where) = @_;
+
+ print "Content-Type: text/html\n";
+ print qq!Refresh: 0; url=$where\n\n<html></html>\n!;
+}
+
+sub refresh_to_admin {
+ my ($cfg, $where) = @_;
+
+ use Carp 'confess';
+ defined $where or confess 'No url supplied';
+
+
+ unless ($where =~ /^\w+:/) {
+ require BSE::CfgInfo;
+ my $adminbase = BSE::CfgInfo::admin_base_url($cfg);
+ $where = $adminbase . $where;
+ }
+
+ refresh_to($where);
+}
+
+1;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(generate_article generate_all generate_button
- refresh_to regen_and_refresh custom_class);
+ regen_and_refresh);
use Constants qw($CONTENTBASE $GENERATE_BUTTON $SHOPID $AUTO_GENERATE);
use Carp qw(confess);
+use BSE::WebUtil qw(refresh_to_admin);
# returns non-zero if the Regenerate button should work
sub generate_button {
$callback->("Total of ".(time()-$allstart)." seconds") if $callback;
}
-sub refresh_to {
- my ($where) = @_;
-
- print "Content-Type: text/html\n";
- print qq!Refresh: 0; url=$where\n\n<html></html>\n!;
-}
-
=item regen_and_refresh($articles, $article, $generate, $refreshto, $cfg, $progress)
An error checking wrapper around the page regeneration code.
}
unless ($progress) {
- refresh_to($refreshto);
+ refresh_to_admin($cfg, $refreshto);
}
return 1;
use Constants qw(:shop $CGI_URI);
use BSE::Template;
use CGI::Cookie;
-use Util qw(refresh_to);
+use BSE::WebUtil qw(refresh_to);
use BSE::CfgInfo qw(custom_class);
use BSE::Mail;
use BSE::Shop::Util qw/shop_cart_tags cart_item_opts nice_options total
payment_types/;
use BSE::Session;
use BSE::Cfg;
-use Util qw/refresh_to/;
use BSE::Util::Tags qw(tag_hash);
=head1 CHANGES
+=head2 0.14_15
+
+This adds several destabilizing changes, test before using in any
+production setting.
+
+=over
+
+=item *
+
+you can now specify that BSE uses the configured secure URL, the
+normal URL or a separate admin base URL for access to administrative
+functions. The action parameter on any custom admin/logon.tmpl should
+be changed to include the new <:adminbase:> tag.
+
+=item *
+
+reorder.pl now accepts a more sophisticated C<sort> parameter, it can
+now be a comma separated list of fields to sort by, most significant
+at the front. Any unknown fields are ignored. You can put C<-> in
+front of any field name to sort that field in reverse.
+
+=item *
+
+the image[] and gimage[] tags now take a fourth parameter which can
+either be a simple class name (all alphanumeric), a set of parameters
+to the C<padding:> style command, or actual CSS style commands.
+
+=item *
+
+lastModified is now a datetime rather than a date, be sure to run
+upgrade_mysql.pl
+
+=item *
+
+applied a change to the default table mapping from extension to MIME
+content type, sent in by Adrian.
+
+=back
+
=head2 0.14_14
=over
=head1 CONFIGURATION ENTRIES
+=head2 [site]
+
+Contains URL configuration for the site.
+
+=over
+
+=item url
+
+The normal URL for the non-secure parts of the site.
+
+=item secureurl
+
+The secure URL for the shop, products and other portions of the site
+that should use SSL. This isn't checked to make sure it is https.
+
+=item name
+
+Used as the site "name" in a few places.
+
+=item adminurl
+
+If set, this is used as the base URL for accessing the administrative
+functions of your site.
+
+=item secureadmin
+
+Ignored if C<adminurl> is set.
+
+If this is true then C<secureurl> is used as the base URL for
+accessing the administrative functions of your site, otherwise C<url>
+is used as the base URL. Default: false (C<url>'s value is used)
+
+=back
+
=head2 [paths]
Contains various file system paths.
<dd>image[<i>index</i>]</dd>
<dd>image[<i>index</i>|<i>alignment</i>]</dd>
<dd>image[<i>index</i>|<i>alignment</i>|<i>url</i>]</dd>
+<dd>image[<i>index</i>|<i>alignment</i>|<i>url</i>|<i>style</i>]</dd>
<dt>Inserts the image number <i>index</i> associated with the article.
<i>index</i> counts from the top starting with 1. If no alignment is
the image becomes a link, though no border is shown around the
image.</dt>
+<dt>The <i>style</i> parameter can be either a CSS class name,
+inserted as a <code>class="<i>style</i>"</code> parameter, the
+parameters to the CSS style <code>padding</code>, inserted as a
+<code>style="padding: <i>style</i></code> or as CSS style commands
+inserted as a <code>style="<i>style</i>"</code> parameter.</dt>
+
<dt>If you use the image[] tag then the normal automatic image
insertion is not done.</dt>
<dd>image[<i>name</i>]</dd>
<dd>image[<i>name</i>|<i>alignment</i>]</dd>
<dd>image[<i>name</i>|<i>alignment</i>|<i>url</i>]</dd>
+<dd>image[<i>name</i>|<i>alignment</i>|<i>url</i>|<i>style</i>]</dd>
<dt>Same as above, but refers to the images by name. This does not
prevent the normal automatic image placement.</dt>
<dd>gimage[<i>name</i>]</dd>
<dd>gimage[<i>name</i>|<i>alignment</i>]</dd>
<dd>gimage[<i>name</i>|<i>alignment</i>|<i>url</i>]</dd>
+<dd>gimage[<i>name</i>|<i>alignment</i>|<i>url</i>|<i>style</i>]</dd>
<dt>Inserts the given global image where the image is identified by
name.</dt>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <title>Administration - Logon</title>
- <link rel="stylesheet" type="text/css" href="/css/admin.css" />
-</head>
-
-<body>
+<:wrap admin/base.tmpl title=>"Logon":>
<h1>Logon</h1>
<:ifMessage:>
<p><b><:message:></b></p>
<:or:><:eif:>
-<form method="post" action="<:script:>">
+<form method="post" action="<:adminbase:><:script:>">
<:if Cgi r:>
-<input type=hidden name=r value="<:cgi r:>">
+<input type="hidden" name="r" value="<:cgi r:>">
<:or Cgi:><:eif Cgi:>
<table border="0" cellspacing="0" cellpadding="0" bgcolor="#000000" class="table">
<tr>
</tr>
</table>
</form>
-<p><font size="-1">BSE Release <:release:></font></p>
-</body
-></html>
subscriptions.text_link_list=[$3] '$1'$n => $2
#paths.local_templates=/home/tony/dev/bse/base/altadmin/
+
+site.secureadmin=1