diff --git a/trunk/config/backend.xml b/trunk/config/backend.xml index e73ec0e..3026afd 100644 --- a/trunk/config/backend.xml +++ b/trunk/config/backend.xml @@ -6,17 +6,18 @@ mysql localhost yolanda - yolanda - + root + - http://localhost/ + http://localhost - /var/www/yolanda/ + /var/www/yolanda/ en-us xhtml.xsl - 10 + 10 + 500 3 20 true @@ -31,5 +32,12 @@ 204800 512 64 + + + + http://www.w3.org/1999/XSL/Transform + http://purl.org/dc/elements/1.1/ + http://web.resource.org/cc/ + http://www.w3.org/1999/02/22-rdf-syntax-ns# diff --git a/trunk/functions.pl b/trunk/functions.pl index c51e839..a16367b 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -42,9 +42,10 @@ sub get_page_array } $page->{'username'} = $userinfo->{'username'}; - $page->{'xmlns:dc'} = $xmlns_dc; - $page->{'xmlns:cc'} = $xmlns_cc; - $page->{'xmlns:rdf'} = $xmlns_rdf; + $page->{'xmlns:dc'} = $config->{"xml_namespace_dc"}; + $page->{'xmlns:cc'} = $config->{"xml_namespace_cc"}; + $page->{'xmlns:rdf'} = $config->{"xml_namespace_rdf"}; + } # called by video.pl (display ambiguous videos), @@ -59,10 +60,10 @@ sub fill_results $resultcount = $sth->execute(@_) or die $dbh->errstr; #set pagesize by query or usersettings or default - $pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = $defaultpagesize; + $pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = $config->{"page_results_pagesize_default"}; #if pagesize is more than maxpagesize reduce to maxpagesize - $pagesize = $pagesize > $maxpagesize ? $maxpagesize : $pagesize; + $pagesize = $pagesize > $config->{"page_results_pagesize_max"} ? $config->{"page_results_pagesize_max"} : $pagesize; #rediculous but funny round up, will fail with 100000000000000 results per page #on 0.0000000000001% of all queries - this is a risk we can handle @@ -92,22 +93,22 @@ sub fill_results #before code cleanup, this was a really obfuscated array/hash creation push @{ $page->{'results'}->{'result'} }, { - 'thumbnail' => "$domain/video-stills/thumbnails/$id", - 'preview' => "$domain/video-stills/previews/$id", + 'thumbnail' => $config->{"url_root"}."/video-stills/thumbnails/$id", + 'preview' => $config->{"url_root"}."/video-stills/previews/$id", 'duration' => $duration, 'viewcount' => $viewcount, 'rdf:RDF' => { 'cc:Work' => { - 'rdf:about' => "$domain/download/$id/", + 'rdf:about' => $config->{"url_root"}."/download/$id/", 'dc:title' => [$title], 'dc:creator' => [$creator], 'dc:subject' => [$subject], 'dc:description' => [$description], 'dc:publisher' => [$publisher], 'dc:date' => [$timestamp], - 'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/" . ($duration == 0 ? "/action=edit" : "")], + 'dc:identifier' => [$config->{"url_root"}."/video/".urlencode($title)."/$id/" . ($duration == 0 ? "/action=edit" : "")], 'dc:source' => [$source], 'dc:language' => [$language], 'dc:coverage' => [$coverage], diff --git a/trunk/include.pl b/trunk/include.pl index c2c992d..bb12203 100644 --- a/trunk/include.pl +++ b/trunk/include.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w use CGI qw(:standard); use CGI::Session; @@ -17,19 +17,13 @@ $root = '/var/www/yolanda'; use lib qw(/var/www/yolanda); +#set global config variable +$config = XMLin("$root/config/backend.xml", KeyAttr => {string => 'id'}, ForceArray => [ 'string' ], ContentKey => '-content'); +$config = $config->{"strings"}->{"string"}; #set global variables -$database = 'yolanda'; -$dbhost = 'localhost'; -$dbuser = 'root'; -$dbpass = ''; -$domain = 'http://localhost'; + $session_name = 'sid'; $locale = "en-US"; -$xmlns_dc = "http://purl.org/dc/elements/1.1/"; -$xmlns_cc = "http://web.resource.org/cc/"; -$xmlns_rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; -$defaultpagesize = 20; -$maxpagesize = 500; -$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); +$dbh = DBI->connect("DBI:mysql:".$config->{"database_name"}.":".$config->{"database_host"}, $config->{"database_username"}, $config->{"database_password"}) or die $DBI::errstr; 1; diff --git a/trunk/login.pl b/trunk/login.pl index f548b0f..cca542b 100644 --- a/trunk/login.pl +++ b/trunk/login.pl @@ -34,7 +34,7 @@ elsif($query->param('pass') eq '' and $query->param('user')=~m/^http:\/\//) cache => undef, # or File::Cache->new, args => $query, consumer_secret => $session->id, #is this save? don't know... - required_root => $domain ); + required_root => $config->{"url_root"} ); #is an openid passed? if($query->param('user')) @@ -49,8 +49,8 @@ elsif($query->param('pass') eq '' and $query->param('user')=~m/^http:\/\//) { #try to set the check_url $check_url = $claimed->check_url( - return_to => "$domain/login.pl?action=openid", #on success return to this address - trust_root => $domain); #this is the string the user will be asked to trust + return_to => $config->{"url_root"}."login.pl?action=openid", #on success return to this address + trust_root => $config->{"url_root"}); #this is the string the user will be asked to trust #redirect to openid server to check claim print $query->redirect($check_url); @@ -73,7 +73,7 @@ elsif($query->param('action') eq 'openid') cache => undef, # or File::Cache->new, args => $query, consumer_secret => $session->id, #is this save? don't know... - required_root => $domain ); + required_root => $config->{"url_root"} ); if($setup_url = $con->user_setup_url) { diff --git a/trunk/uploader.pl b/trunk/uploader.pl index 07c89ce..8aba2af 100644 --- a/trunk/uploader.pl +++ b/trunk/uploader.pl @@ -163,7 +163,7 @@ if($userinfo->{'id'} && $query->param("DC.Title") && } #print success to the user - print $query->redirect("index.pl?information=information_uploaded&value=$domain/video/".urlencode($query->param("DC.Title"))."/$id/"); + print $query->redirect("index.pl?information=information_uploaded&value=".$config->{"url_root"}."/video/".urlencode($query->param("DC.Title"))."/$id/"); } else { diff --git a/trunk/video.pl b/trunk/video.pl index 49a629f..de8cecf 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -86,8 +86,8 @@ if($query->url_param('id')) #before code cleanup, this was a really obfuscated array/hash creation push @{ $page->{'video'} }, { - 'thumbnail' => "$domain/video-stills/thumbnails/$id", - 'preview' => "$domain/video-stills/previews/$id", + 'thumbnail' => $config->{"url_root"}."/video-stills/thumbnails/$id", + 'preview' => $config->{"url_root"}."/video-stills/previews/$id", 'filesize' => $filesize, 'duration' => $duration, 'width' => $width, @@ -99,14 +99,14 @@ if($query->url_param('id')) { 'cc:Work' => { - 'rdf:about' => "$domain/download/$id/", + 'rdf:about' => $config->{"url_root"}."/download/$id/", 'dc:title' => [$title], 'dc:creator' => [$creator], 'dc:subject' => [$subject], 'dc:description' => [$description], 'dc:publisher' => [$publisher], 'dc:date' => [$timestamp], - 'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/"], + 'dc:identifier' => [$config->{"url_root"}."/video/".urlencode($title)."/$id/"], 'dc:source' => [$source], 'dc:language' => [$language], 'dc:coverage' => [$coverage],