Move db setup in config.php
authorJean-Michel Vourgère <jvourger@greenpeace.org>
Fri, 24 Feb 2017 22:14:13 +0000 (11:14 +1300)
committerJean-Michel Vourgère <jvourger@greenpeace.org>
Thu, 9 Mar 2017 18:06:29 +0000 (18:06 +0000)
Now using system smarty, can be changed in config

.gitignore
config.php.example [new file with mode: 0644]
include/connect.inc.php.example [deleted file]
index.php
squasher.class.php
squasher.php

index ce60848da1081432aa879ef00c1e670a33cce102..a756e4a5cf871190e402b722c1fc20607b9dcf26 100644 (file)
@@ -1,9 +1,7 @@
-/include/connect.inc.php
+/config.php
 /geoip.php
 /glob.php
-/include/GeoIP.dat
-/include/GeoIP.dat.gz
-/include/geoip.inc
+/include/
 /mail_test.php
 /md5.php
 /smarty/
diff --git a/config.php.example b/config.php.example
new file mode 100644 (file)
index 0000000..20976e3
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+DEFINE('SQUASHER_DB_HOST', '127.0.0.1'); // Ip address of the mysql server
+DEFINE('SQUASHER_DB_USER', 'squasher'); // Username for the database
+DEFINE('SQUASHER_DB_PASSWORD', 'squasher'); // Password for the database
+DEFINE('SQUASHER_DB_DATABASE', 'squasher'); // Mysql database name
+
+// Location of the smarty library
+// Use 'smarty/Smarty.class.php' for relative directory 'smarty/'
+// Use 'smarty3/Smarty.class.php' if you installed package smarty3
+DEFINE('SQUASHER_SMARTY', 'smarty3/Smarty.class.php');
+
+// start session
+session_start();
+
+//connect to db
+$link_db = mysql_connect(SQUASHER_DB_HOST, SQUASHER_DB_USER, SQUASHER_DB_PASSWORD);
+mysql_select_db(SQUASHER_DB_DATABASE, $link_db);
+
+// vim: syntax=php ts=4 sw=4 sts=4 sr noet
+?>
diff --git a/include/connect.inc.php.example b/include/connect.inc.php.example
deleted file mode 100644 (file)
index 2af3946..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-// start session
-session_start();
-
-//connect to db
-$link_db = mysql_connect("dbip", "dbuser", "dbpassword");
-mysql_select_db("squasher", $link_db);
-
-// vim: syntax=php ts=4 sw=4 sts=4 sr noet
-?>
index d733f0ba64f08b863b96e08e6d2d69459a016a69..dfcc4689205efd4de0a1b232a728ce76c849793a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
 <?php
 
-require_once("include/connect.inc.php");
+require_once("config.php");
 
 require_once("squasher.class.php");
 
@@ -23,7 +23,7 @@ if ($_SESSION['creds']['validated'] || @$_GET['f']) {
 } else {
        //show login
 
-       require_once("smarty/Smarty.class.php");
+       require_once(SQUASHER_SMARTY); // See config.php
 
        $smarty = new Smarty;
 
index eefe829ddbdefd5409e28f6d44605af37178ffb1..76e86a88afdffb32f541d6284ec9f6144697455c 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-require_once("include/connect.inc.php");
+require_once("config.php");
 
 function zfill($n, $a) {
        return str_repeat("0", max(0,$a-strlen($n))) . $n;
index c8006469b46053282b5b16f5edeb5332e5a38fb7..c403e9dab07b1b4a36be0b4d37cafec8ef9d234b 100644 (file)
@@ -118,7 +118,7 @@ if (@$_GET['f']) {
        }
 } elseif (@$_GET['tools']=='access' && $_SESSION['creds']['user_level'] > 100) {
 
-       require_once("smarty/Smarty.class.php");
+       require_once(SQUASHER_SMARTY);
 
        $smarty = new Smarty;
 
@@ -148,7 +148,7 @@ if (@$_GET['f']) {
                $squashweb->remove_users($_POST['u']);
        if ($type=="new")
                $squashweb->insert_users($_POST['u'], $_SESSION['creds']['user_level']);
-       require_once("smarty/Smarty.class.php");
+       require_once(SQUASHER_SMARTY);
 
        $smarty = new Smarty;
 
@@ -169,7 +169,7 @@ if (@$_GET['f']) {
        $logtype=@$_GET['logtype'];
        if (!$logtype)
                $logtype = 'all';
-       require_once("smarty/Smarty.class.php");
+       require_once(SQUASHER_SMARTY);
 
        $smarty = new Smarty;
 
@@ -184,7 +184,7 @@ if (@$_GET['f']) {
 } else {
        //show overview
 
-       require_once("smarty/Smarty.class.php");
+       require_once(SQUASHER_SMARTY);
 
        $smarty = new Smarty;