diff --git a/components/contents.php b/components/contents.php index 64e673f94869d6dbe127d1b66779389e870d51eb..395c32f631905a93befb20618a783126bef82f8d 100644 --- a/components/contents.php +++ b/components/contents.php @@ -1,15 +1,15 @@ <?php function listdir($mypath, $recurse, $summaries) { - global $DB, $settings; + global $DB; - $dirlist = @scandir($settings['base']."static".$mypath); + $dirlist = @scandir(SUCS_BASEDIR."static".$mypath); $output = array(); if (is_array($dirlist)) foreach($dirlist as $file) { // Hide files starting with a . if ($file[0]!=".") { $element = array(); - if (!is_dir($settings['base']."static".$mypath."/".$file)) { + if (!is_dir(SUCS_BASEDIR."static".$mypath."/".$file)) { $pagename = ereg_replace("\.txt", "", $file); if ($summaries) $element['summary'] = $DB->GetOne("select summary from static where path=?", array($mypath."/".$pagename)); if ($pagename!=@$lastdir) $output[$pagename]=$element; @@ -36,7 +36,7 @@ if ($path==$component['path']) { include("static.php"); if ($title!="File not found") { - if (!is_dir($settings['base']."static".$path)) { + if (!is_dir(SUCS_BASEDIR."static".$path)) { $pos = strrpos($path, "/"); $path = substr($path, 0, $pos); } diff --git a/components/library.php b/components/library.php index b6cfee1458150f4cdb4025e64c2e587a8ab1ff0b..057471a6ef3306709509b055c573a04bab4019fa 100644 --- a/components/library.php +++ b/components/library.php @@ -87,7 +87,7 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) { // someone wants to check out this book $msgbody = "User {$session->username} would like to take out"; $msgbody .= " {$book['title']} by {$book['author']} from the library.\n\n"; - $msgbody .= "Visit https://$settings['preferred_hostname']$path to process this request."; + $msgbody .= "Visit https://".SUCS_PREFERRED_HOSTNAME."$path to process this request."; mail($librarian_mail, "Book Request", $msgbody); $smarty->assign("checkout_request", true); diff --git a/components/milliways.php b/components/milliways.php index 98ac2202d56d2ab34fe8d58d8a76d42f043d483e..ef9da2ce6904d28f9cb4f94d9fb807c2c297f6fe 100644 --- a/components/milliways.php +++ b/components/milliways.php @@ -12,7 +12,7 @@ foreach ($wholist as $person) { } $smarty->assign("people",$people); -$output = $smarty->fetch($settings['base']."templates/milliways.tpl"); +$output = $smarty->fetch(SUCS_BASEDIR."templates/milliways.tpl"); $smarty->assign("title", "Milliways"); $smarty->assign("body", $output); $smarty->assign("refresh", 120); diff --git a/components/mw.php b/components/mw.php index bc3bc0185b1ab725072cdbe5d3d874323857922c..577df891c0d1ee92892685ee76fca78b8136af6d 100755 --- a/components/mw.php +++ b/components/mw.php @@ -176,7 +176,7 @@ if (isset($pathlist[3])) { $sub = fetch_sub($all, $all[$artno]['ref']); $smarty->assign_by_ref("articles", $sub); $smarty->assign("howmany",count($sub)); - $output = $smarty->fetch($settings['base']."templates/mw-article.tpl"); + $output = $smarty->fetch(SUCS_BASEDIR."templates/mw-article.tpl"); } } else { @@ -200,7 +200,7 @@ if (isset($pathlist[3])) { $smarty->assign("title", htmlentities("Milliways - Folder $name")); $smarty->assign_by_ref("articles", $top); - $output = $smarty->fetch($settings['base']."templates/mw-list.tpl"); + $output = $smarty->fetch(SUCS_BASEDIR."templates/mw-list.tpl"); } } else { $output = "Error, no such folder $name"; @@ -218,7 +218,7 @@ if (isset($pathlist[3])) { $folders[$k]['lastpost'] = $lastone['date']; } $smarty->assign("title", "Milliways - Topic List"); - $output = $smarty->fetch($settings['base']."templates/mw-folders.tpl"); + $output = $smarty->fetch(SUCS_BASEDIR."templates/mw-folders.tpl"); $smarty->assign("body", $output); } diff --git a/components/options.php b/components/options.php index d439955e4c6b6d6fd0fc15059907962ba41db84b..4c1356bd9321b609349999816cc8fc681e3cb434 100644 --- a/components/options.php +++ b/components/options.php @@ -143,8 +143,7 @@ function clearHackergotchi() { // construct the filesystem path to a user's hackergotchi picture function hackergotchiPath($username) { - global $settings; - $path = $settings['base']."htdocs/pictures/people/".$username.".png"; + $path = SUCS_BASEDIR."htdocs/pictures/people/".$username.".png"; return $path; } @@ -217,7 +216,7 @@ if ($session->loggedin === TRUE) { // Some checking could be done here to ensure we have a members record. Ideally we should // be able to assume this though if they are logged in. - if (is_file($settings['base']."htdocs/pictures/people/".$session->username.".png")) $smarty->assign('hackergotchi', TRUE); + if (is_file(SUCS_BASEDIR."htdocs/pictures/people/".$session->username.".png")) $smarty->assign('hackergotchi', TRUE); $member = $sucsDB->GetRow("select * from members where username='".$session->username."'"); diff --git a/components/pagemap.php b/components/pagemap.php index 801a327259e84196ec3977142f84ba4126072751..366ec72d837514c821f0e9429962078b1aaa3f98 100644 --- a/components/pagemap.php +++ b/components/pagemap.php @@ -9,7 +9,7 @@ if (@$pathlist[3] == "Edit") { $res = $DB->GetAll("SELECT * FROM pagemap where id=?", array($id)); if ($res && count($res) > 0) { $smarty->assign("oldmap",$res[0]); - $output = $smarty->fetch($settings['base']."templates/pagemap_edit.tpl"); + $output = $smarty->fetch(SUCS_BASEDIR."templates/pagemap_edit.tpl"); } else { header("Location: /Admin/Pagemap"); exit; @@ -22,7 +22,7 @@ if (@$pathlist[3] == "Edit") { if (!isset($output)) { $smarty->assign("map",$DB->GetAll("SELECT * FROM pagemap ORDER BY depth, path")); - $output = $smarty->fetch($settings['base']."templates/pagemap.tpl"); + $output = $smarty->fetch(SUCS_BASEDIR."templates/pagemap.tpl"); } $smarty->assign("title", "Page Map"); $smarty->assign("body", $output); diff --git a/components/pastebin.php b/components/pastebin.php index c90fd0b75c0eb348532c90af245fd0820f883402..532b1d9df5fdd8d3f5c168c94e0dc6134c0000bc 100755 --- a/components/pastebin.php +++ b/components/pastebin.php @@ -230,7 +230,7 @@ if(!empty($pblang) && $pblang != 'NONE') { $smarty->assign('pasteLanguages', $LANGUAGES); // Load templates etc -$smarty->assign("extra_styles", array("$settings['baseurl']/css/pastebin.css")); +$smarty->assign("extra_styles", array(SUCS_BASEURL"/css/pastebin.css")); $result = $smarty->fetch('pastebin.tpl'); $sidebar = $smarty->fetch('pastebin-sidebar.tpl'); $smarty->assign('title', 'PasteBin'); diff --git a/components/planet.php b/components/planet.php index b10274b58624a5bbd88e01bfa7eb41dff807eac2..32253c3a71c0a4f3879844db094076bbe3aced6b 100644 --- a/components/planet.php +++ b/components/planet.php @@ -4,7 +4,7 @@ $smarty->assign("title", "Planet SUCS"); $smarty->assign("rss_url", "http://planet.sucs.org/rss20.xml"); $smarty->assign("atom_url", "http://planet.sucs.org/atom.xml"); // Read planet output from where (we hope) Planet wrote it -$body = file_get_contents($settings['base']."static/Community/Planet.txt"); +$body = file_get_contents(SUCS_BASEDIR."static/Community/Planet.txt"); $smarty->assign("body", $body); ?> diff --git a/components/static.php b/components/static.php index 6dbe95555bfd923925a9ce64d9498e0d24ae085b..0594b6efc9333ae7592fef70239a57deafa232b2 100644 --- a/components/static.php +++ b/components/static.php @@ -5,11 +5,11 @@ $permission = "html"; // Get the right filename... -$myfile = $settings['base']."static".$path.$language['file'].".txt"; -$secondaryfile = $settings['base']."static".$path.$language['file']."-secondary.txt"; +$myfile = SUCS_BASEDIR."static".$path.$language['file'].".txt"; +$secondaryfile = SUCS_BASEDIR."static".$path.$language['file']."-secondary.txt"; if (!file_exists($myfile)) { - $myfile = $settings['base']."static$path.txt"; - $secondaryfile = $settings['base']."static$path-secondary.txt"; + $myfile = SUCS_BASEDIR."static$path.txt"; + $secondaryfile = SUCS_BASEDIR."static$path-secondary.txt"; // If the file doesn't exist... if (!file_exists($myfile)) { if (isset($session->groups[$permission]) && @$_REQUEST['action']=="create") { @@ -31,7 +31,7 @@ if (!file_exists($myfile)) { } else { // ...serve a 404 error header("HTTP/1.1 404 Not Found"); - $body = @file_get_contents($settings['base']."static/404.txt"); + $body = @file_get_contents(SUCS_BASEDIR."static/404.txt"); $smarty->assign("pathlist", array("", "Error")); $title = "File not found"; $smarty->assign("title", $title); diff --git a/htdocs/index.php b/htdocs/index.php index 38f659f6debec76895a5b8b3e5cdb58449859ac5..140696e639831ed06eb02ce9f9ade97348d041f5 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -15,7 +15,7 @@ if (@$displaytime) { -------------------------------------------------------- */ include("settings.php"); -if (!(isset($settings))) { +if (!defined('SUCS_BASEDIR')) { echo "Website unconfigured"; exit(); } @@ -28,23 +28,22 @@ require("../lib/error.php"); // Include the Smarty templating engine -define('SMARTY_DIR', '/usr/share/Smarty/'); -require("/usr/share/Smarty/Smarty.class.php"); +require(SMARTY_PATH."Smarty.class.php"); $smarty = new Smarty; -$smarty->template_dir = $settings['base']."templates"; -$smarty->compile_dir = $settings['base']."templates_c"; -$smarty->plugins_dir[] = $settings['base']."plugins"; +$smarty->template_dir = SUCS_BASEDIR."templates"; +$smarty->compile_dir = SUCS_BASEDIR."templates_c"; +$smarty->plugins_dir[] = SUCS_BASEDIR."plugins"; -$smarty->assign("baseurl", $settings['baseurl']); +$smarty->assign("baseurl", SUCS_BASEURL); // Initialise the database -require("/var/www/adodb/adodb.inc.php"); -$DB = NewADOConnection('postgres8'); -$DB->Connect('dbname='.$settings['dbname']); +require(ADODB_DIR."adodb.inc.php"); +$DB = NewADOConnection(SUCS_DBTYPE); +$DB->Connect('dbname='.SUCS_DBNAME); $DB->SetFetchMode(ADODB_FETCH_ASSOC); // Include the session library -require($settings['base']."lib/session.php"); +require(SUCS_BASEDIR."lib/session.php"); $session = new Session; $smarty->assign_by_ref("session", $session); @@ -90,7 +89,7 @@ $smarty->assign("language", $language); // SSL? $ssl_path = @$_SERVER['REQUEST_URI']; if (($n=strpos($ssl_path,"?"))!==FALSE) $ssl_path=substr($ssl_path,0,$n); -$ssl_url = "https://".$settings['preferred_hostname'].$ssl_path; +$ssl_url = "https://".SUCS_PREFERRED_HOSTNAME.$ssl_path; $smarty->assign("ssl_url", $ssl_url); @@ -130,10 +129,10 @@ if ($path == "") $path="/"; $smarty->assign("title", "Set Me"); $smarty->assign("body", "Empty Body"); -include($settings['base']."components/menu.php"); +include(SUCS_BASEDIR."components/menu.php"); // Load the component -$comppath = $settings['base']."components/".$component['component'].".php"; +$comppath = SUCS_BASEDIR."components/".$component['component'].".php"; $compoutput = ""; if (file_exists($comppath)) { ob_start(); diff --git a/settingstemplate b/settingstemplate index 7dd51198c5a0afdcdfa9bedbb04f7ace4920b565..430cdd432b20465904cb19a6160c91eba35774a8 100644 --- a/settingstemplate +++ b/settingstemplate @@ -1,15 +1,22 @@ <?php -$settings = array( // root directory for website - *with* trailing / -"base" => "$BASEDIR/", +define('SUCS_BASEDIR', '$BASEDIR/'); // path to root dir on web server -"baseurl" => "/~$USERNAME/sucssite", +define('SUCS_BASEURL', '/~$USERNAME/sucssite'); // Hostname of the server -"preferred_hostname" => "sucs.org", +define('SUCS_PREFERRED_HOSTNAME', 'sucs.org'); + +// Path of ADOdb +define('ADODB_DIR', '/usr/share/adodb/'); + +// Path of Smarty +define('SMARTY_DIR', '/usr/share/Smarty/'); + +// Database type +define('SUCS_DBTYPE', 'postgres8'); // Name of the database -"dbname" => "beta" -); +define('SUCS_DBNAME', 'beta'); ?>