Changeset 468 for trunk/dns.cgi
- Timestamp:
- 03/12/13 13:39:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r458 r468 45 45 use lib '.'; ##uselib## 46 46 47 use DNSDB qw(:ALL);47 use DNSDB; 48 48 49 49 my @debugbits; # temp, to be spit out near the end of processing … … 69 69 # we'll catch a bad DB connect string once we get to trying that 70 70 ##fixme: pass params to loadConfig, and use them there, to allow one codebase to support multiple sites 71 if (!loadConfig()) { 72 warn "Using default configuration; unable to load custom settings: $DNSDB::errstr"; 71 my $dnsdb = new DNSDB; 72 73 my $header = HTML::Template->new(filename => "$templatedir/header.tmpl"); 74 my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl"); 75 $footer->param(version => $DNSDB::VERSION); 76 77 if (!$dnsdb) { 78 print "Content-type: text/html\n\n"; 79 print $header->output; 80 my $errpage = HTML::Template->new(filename => "$templatedir/dberr.tmpl"); 81 $errpage->param(errmsg => $DNSDB::errstr); 82 print $errpage->output; 83 print $footer->output; 84 exit; 73 85 } 86 87 $header->param(orgname => $dnsdb->{orgname}) if $dnsdb->{orgname} ne 'Example Corp'; 74 88 75 89 # persistent stuff needed on most/all pages 76 90 my $sid = ($webvar{sid} ? $webvar{sid} : undef); 77 my $session = new CGI::Session("driver:File", $sid, {Directory => $ config{sessiondir}})91 my $session = new CGI::Session("driver:File", $sid, {Directory => $dnsdb->{sessiondir}}) 78 92 or die CGI::Session->errstr(); 79 93 #$sid = $session->id() if !$sid; … … 81 95 # init stuff. can probably axe this down to just above if'n'when user manipulation happens 82 96 $sid = $session->id(); 83 $session->expire($ config{timeout});97 $session->expire($dnsdb->{timeout}); 84 98 # need to know the "upper" group the user can deal with; may as well 85 99 # stick this in the session rather than calling out to the DB every time. … … 149 163 push @filterargs, $filter if $filter; 150 164 151 # nrgh, can't handle login here because we don't have a database handle to check the user/pass with yet152 153 my $header = HTML::Template->new(filename => "$templatedir/header.tmpl");154 my $footer = HTML::Template->new(filename => "$templatedir/footer.tmpl");155 $header->param(orgname => $config{orgname}) if $config{orgname} ne 'Example Corp';156 $footer->param(version => $DNSDB::VERSION);157 158 165 ## set up "URL to self" 159 166 # @#$%@%@#% XHTML - & in a URL must be escaped. >:( … … 179 186 # pagination 180 187 my $perpage = 15; 181 $perpage = $ config{perpage} if $config{perpage};188 $perpage = $dnsdb->{perpage} if $dnsdb->{perpage}; 182 189 my $offset = ($webvar{offset} ? $webvar{offset} : 0); 183 190 … … 186 193 my $sortorder = "ASC"; 187 194 188 ##fixme: quit throwing the database handle around, and put all the SQL and direct DB fiddling into DNSDB.pm189 # dbname, user, pass, host (optional)190 my ($dbh,$msg) = connectDB($config{dbname}, $config{dbuser}, $config{dbpass}, $config{dbhost});191 192 if (!$dbh) {193 print "Content-type: text/html\n\n";194 print $header->output;195 my $errpage = HTML::Template->new(filename => "$templatedir/dberr.tmpl");196 $errpage->param(errmsg => $msg);197 print $errpage->output;198 print $footer->output;199 exit;200 }201 202 # Load config pieces from the database. Ideally all but the DB user/pass/etc should be loaded here.203 initGlobals($dbh);204 205 195 # security check - does the user have permission to view this entity? 206 196 # this is a prep step used "many" places 207 197 my @viewablegroups; 208 getChildren($dbh,$logingroup, \@viewablegroups, 'all');198 $dnsdb->getChildren($logingroup, \@viewablegroups, 'all'); 209 199 push @viewablegroups, $logingroup; 210 200 … … 232 222 # Snag ACL/permissions here too 233 223 234 my $userdata = login($dbh,$webvar{username}, $webvar{password});224 my $userdata = $dnsdb->login($webvar{username}, $webvar{password}); 235 225 236 226 if ($userdata) { … … 293 283 # but if they keep the session active they'll continue to have access long after being disabled. :/ 294 284 # Treat it as a session expiry. 295 if ($session->param('uid') && ! userStatus($dbh,$session->param('uid')) ) {285 if ($session->param('uid') && !$dnsdb->userStatus($session->param('uid')) ) { 296 286 $sid = ''; 297 287 $session->delete; # force expiry of the session Right Away … … 301 291 302 292 # Misc Things To Do on most pages 303 initPermissions($dbh,$session->param('uid'));304 initActionLog($dbh,$session->param('uid'));293 $dnsdb->initPermissions($session->param('uid')); 294 $dnsdb->initActionLog($session->param('uid')); 305 295 306 296 $page->param(sid => $sid) unless $webvar{page} eq 'login'; # no session ID on the login page
Note:
See TracChangeset
for help on using the changeset viewer.