X-Git-Url: http://git.pjr.cc/?p=gwvp.git;a=blobdiff_plain;f=gwvplib%2Fgwvpsetup.php;h=a9e7a06e18cc61377bf5e81a403c7cfa90b50d47;hp=b83e41541ffd603b60973e90a4f1877b48fd8038;hb=4f4bf1da18181d412cd755143e016ede587cc1d6;hpb=8f714681f0b8452e97c1d4eeb02262f1ffd3ee7b diff --git a/gwvplib/gwvpsetup.php b/gwvplib/gwvpsetup.php index b83e415..a9e7a06 100644 --- a/gwvplib/gwvpsetup.php +++ b/gwvplib/gwvpsetup.php @@ -21,18 +21,131 @@ function gwvp_PostSetup() function gwvp_PostSetupPageBody() { - echo "GWVP Is now setup, login at the top of the page and you should in control!"; + echo "GWVP Is now setup, login at the top of the page and you should be in control!"; } // TODO: need to do this bit function gwvp_issetup() { - return true; + // check for the config file + if(!file_exists("config.php")) return false; + + return gwvp_isDBSetup(); } 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 UsernameThe 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"]; + $fwusername = $_REQUEST["firstuserusername"]; + $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
    username$fwusername
    pass$fwpass
    passconfirm$fwpassconf
    dbtype$dbtype
    dbname$dbname
    repoloc$repoloc
    dataloc$dataloc
    "; + echo ""; + } + + ?> \ No newline at end of file