From e363e11485867a857cdd0823e80170af6d34d780 Mon Sep 17 00:00:00 2001 From: paulr Date: Tue, 1 Nov 2011 17:53:04 +1100 Subject: [PATCH] initial setup pages --- gwvplib/gwvpdebug.php | 8 +++- gwvplib/gwvplib.php | 2 +- gwvplib/gwvpsetup.php | 112 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 119 insertions(+), 3 deletions(-) diff --git a/gwvplib/gwvpdebug.php b/gwvplib/gwvpdebug.php index cd3c86f..c580ad1 100644 --- a/gwvplib/gwvpdebug.php +++ b/gwvplib/gwvpdebug.php @@ -6,6 +6,8 @@ $MENU_ITEMS["999debug"]["link"] = "$BASE_URL/debug"; function gwvp_DebugEnabled() { + global $BASE_URL; + echo "
";
 	echo "BASEURL: $BASE_URL\n";
 	echo "CUSTOM\n";
@@ -14,7 +16,11 @@ function gwvp_DebugEnabled()
 	echo "\n\n\nrequest\n";
 	print_r($_REQUEST);
 	echo "\n\n\nsession\n";
-	print_r($_SESSION);
+	if(isset($_SESSION)) {
+		print_r($_SESSION);
+	} else {
+		echo "No session data";
+	}
 	
 	
 	echo "
"; diff --git a/gwvplib/gwvplib.php b/gwvplib/gwvplib.php index 674e87c..afd06d8 100644 --- a/gwvplib/gwvplib.php +++ b/gwvplib/gwvplib.php @@ -5,7 +5,7 @@ require_once("gwvpgitbackend.php"); require_once("gwvpuseradmin.php"); require_once("gwvprepoadmin.php"); require_once("gwvpauth.php"); -require_ocne("gwvpsetup.php"); +require_once("gwvpsetup.php"); // only enable this if you need it: require_once("gwvpdebug.php"); diff --git a/gwvplib/gwvpsetup.php b/gwvplib/gwvpsetup.php index b83e415..bc639da 100644 --- a/gwvplib/gwvpsetup.php +++ b/gwvplib/gwvpsetup.php @@ -27,12 +27,122 @@ function gwvp_PostSetupPageBody() // TODO: need to do this bit function gwvp_issetup() { - return true; + return false; } function gwvp_goSetup() { + global $BASE_URL; + if(isset($_REQUEST["install"])) { + switch($_REQUEST["install"]) { + case "tryinstall": + gwvp_goSetupDoInstall(); + break; + default: + gwvp_goSetupGoMain(); + break; + + } + } else { + header("Location: $BASE_URL/?install=begin"); + } } + +function gwvp_goSetupGoMain() +{ + + // interesting, TODO: need a non-unix dependant way of doing this + $webusername = exec("whoami"); + + $defrepoloc = "/var/lib/gwvp/gitrepos"; + $defdataloc = "/var/lib/gwvp/data"; + + $repodata = "$defrepoloc"; + if(file_exists("$defrepoloc")) { + $repodata .= " exists"; + if(is_writable("$defrepoloc")) { + $repodata .= " and is wriable - this is ok as it is"; + } else { + $repodata .= " but is not writable - needs permissions for the web user"; + } + } else $repodata .= " does not exist (needs to be created)"; + + $datadata = "$defdataloc"; + if(file_exists("$defdataloc")) { + $datadata .= " exists"; + if(is_writable("$defdataloc")) { + $datadata .= " and is wriable - this is ok as it is"; + } else { + $datadata .= " but is not writable - needs permissions for the web user"; + } + } else $datadata .= " does not exist (needs to be created)"; + + echo "

Welcome to the GWVP setup Page

"; + echo "Fill out the form below and lets get started
"; + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
Site NameSome Name for your site
First User Full NameThe name of the admin of your site
First User email addressThe email address of the admin of your site (login)
First User Nick NameThe name used to idenity the user on the site
First User PasswordPassword for the user
First User Password (confirm)and confirm it...
Database TypeSQLite only at this point
Database nameFor SQLite, this is simple the file on disk
GIT repository storage LocationThe location (on disk) of the repos - you need to create this (see below)Note: $repodata
Data storage LocationThe location (on disk) where the database for this site is stored - you need to create this (see below)Note: $datadata
"; + + echo "

GIT Repo Storage Location Creation

"; + echo "GIT Repo Storage Location - A location (accessible by the web user, $webusername) must be created on disk for this application to store git repositories (and only repositories) in."; + echo "To do this, do the following (as root or via sudo):
"; + echo "
  • Create a directory - sudo mkdir -p $defrepoloc
    "; + echo "
  • Change ownership of the directory to the web user - sudo chown $webusername $defrepoloc
    "; + echo "And, your done
    "; + + + echo "

    Data Storage Location Creation

    "; + echo "Data Storage Location - A location (accessible by the web user, $webusername) must be created on disk for this application to store data (such as database information) in."; + echo "To do this, do the following (as root or via sudo):
    "; + echo "
  • Create a directory - sudo mkdir -p $defdataloc
    "; + echo "
  • Change ownership of the directory to the web user - sudo chown $webusername $defdataloc
    "; + echo "And, your done
    "; + echo ""; +} + +function gwvp_goSetupDoInstall() +{ + $sitename = $_REQUEST["sitename"]; + $fufn = $_REQUEST["firstuserfullname"]; + $fwem = $_REQUEST["firstuseremail"]; + $fwnick = $_REQUEST["firstusernickname"]; + $fwpass = $_REQUEST["pass1"]; + $fwpassconf = $_REQUEST["pass2"]; + $dbtype = $_REQUEST["dbtype"]; + $dbname = $_REQUEST["dbname"]; + $repoloc = $_REQUEST["repoloc"]; + $dataloc = $_REQUEST["dataloc"]; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
    Sitename$sitename
    fullname$fufn
    email$fwem
    nick$fwnick
    pass$fwpass
    passconfirm$fwpassconf
    dbtype$dbtype
    dbname$dbname
    repoloc$repoloc
    dataloc$dataloc
    "; + echo ""; + +} + + ?> \ No newline at end of file -- 1.7.0.4