summaryrefslogtreecommitdiff
path: root/config.php-dist
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2008-02-03 23:23:24 +0000
committerNathan Kinkade <nath@nkinka.de>2008-02-03 23:23:24 +0000
commitd895b852a6e160496ffc760d46d3719a3d62ff86 (patch)
tree52230bb04148197e8312e09b5c5273417e7a3be9 /config.php-dist
Initial checkin of nutridb.org and basic subversion directory structure
Diffstat (limited to 'config.php-dist')
-rw-r--r--config.php-dist86
1 files changed, 86 insertions, 0 deletions
diff --git a/config.php-dist b/config.php-dist
new file mode 100644
index 0000000..cbf01e7
--- /dev/null
+++ b/config.php-dist
@@ -0,0 +1,86 @@
+<?php
+
+# establish an error reporting level suitable for the site
+#error_reporting (0); # don't show any errors
+error_reporting(E_ALL); # show all errors
+#error_reporting(E_ALL ^ E_NOTICE); # show all errors except notices
+
+# set various site-wide variables
+
+# site constants that don't need to be interpolated in strings and/or
+# are more sensitive will be setup as constants
+define("DBHOST", "localhost"); # database host
+define("DBNAME", "nutridb_sr19"); # database name
+define("DBUSER", "nutridb"); # database user
+define("DBPASS", "Nutr1dbAdm1n"); # database password
+
+define("ADODBDIR", "/usr/share/php/adodb"); # adodb db abastractions libs - adodb.sourceforge.net
+define("SMARTYDIR", "/usr/share/php/smarty/libs"); # Smarty templates dir - smarty.php.net
+
+# if true then any db error will cause the error to be printed
+# and the script will be halted. this should probably only be
+# set to true while in development
+#define("DBDEBUG", "true");
+
+# generic empty class for some config variables
+class siteConfig {};
+$config = new siteConfig;
+
+# variables that need to be interpolated inside strings and HEREDOCs
+# will go in the siteConfig object
+$config->_rootDir = "/var/www/nutridb/devel"; # root directory
+$config->_rootUri = "http://localhost/nutridb/devel"; # root uri
+$config->_imgUri = "{$config->_rootUri}/images"; # where images live
+$config->_cssUri = "{$config->_rootUri}/css"; # where css files live
+$config->_jsUri = "{$config->_rootUri}/js"; # where javascript files live
+$config->_smarty = "{$config->_rootDir}/smarty"; # where smarty files live
+$config->_recordsPerPage = "30"; # number of results per page on food_search.php
+$config->_thisScript = basename($_SERVER['PHP_SELF']);
+
+# in some cases we might want to send the user back to the page
+# they came from, but HTTP_REFERER won't always be set for
+# various reason, so if it isn't then just sent them back to the
+# root URI.
+if ( isset($_SERVER['HTTP_REFERER']) ) {
+ $config->_previousUri = $_SERVER['HTTP_REFERER'];
+} else {
+ $config->_previousUri = "{$config->_rootUri}/";
+}
+
+# include the necessary libraries and classes
+require("lib/site.lib.php"); # functions specific to this site
+require("lib/standard.lib.php"); # standard functions useful for any site
+require("lib/database.class.php"); # database class
+require("lib/xajax_0.2.4/xajax.inc.php"); # Ajax class - xajaxproject.org
+require(SMARTYDIR . "/Smarty.class.php"); # Smarty templates
+
+# start a session. we may not need it but start it anyway
+session_start();
+
+# instantiate the database object
+$db = new Database();
+
+# instantiate and configure XAJAX
+$xajax = new xajax();
+$xajax->registerFunction("removeCurrentMealItem");
+$xajax->registerFunction("clearCurrentMeal");
+$xajax->registerFunction("removeMealItem");
+$xajax->registerFunction("removeDiaryItem");
+$xajax->registerFunction("loadMealToEdit");
+$xajax->registerFunction("loadFoodToEdit");
+$xajax->registerFunction("usernameExists");
+$xajax->processRequests();
+
+
+# instantiate and configure Smarty
+$smarty = new Smarty();
+#$smarty->caching = true; # turn on smarty template caching
+$smarty->template_dir = "{$config->_rootDir}/templates";
+$smarty->compile_dir = "{$config->_smarty}/templates_c";
+$smarty->cache_dir = "{$config->_smarty}/cache";
+$smarty->config_dir = "{$config->_smarty}/configs";
+
+# go ahead and register our $config object with smarty
+$smarty->assign("config", $config);
+
+?>