From 8f714681f0b8452e97c1d4eeb02262f1ffd3ee7b Mon Sep 17 00:00:00 2001 From: paulr Date: Tue, 1 Nov 2011 15:54:08 +1100 Subject: [PATCH] added more framework bits, - repo admin - user admin - debug page - started setup pages - database creation - login forms - minor css changes --- gwvplib/gwvpauth.php | 91 ++++++++++++++++++++++++++++++++++++++++++++++ gwvplib/gwvpdatabase.php | 19 ++++++++++ gwvplib/gwvpdebug.php | 74 +++++++++++++++++++++++++++++++++++++ gwvplib/gwvplib.php | 10 +++--- gwvplib/gwvpsetup.php | 38 +++++++++++++++++++ gwvplib/gwvpweb.php | 60 +++++++++++++++++++++++++++++-- www/css/normal.css | 13 ++++++- www/index.php | 13 ++----- 8 files changed, 298 insertions(+), 20 deletions(-) create mode 100644 gwvplib/gwvpauth.php create mode 100644 gwvplib/gwvpdebug.php create mode 100644 gwvplib/gwvpsetup.php diff --git a/gwvplib/gwvpauth.php b/gwvplib/gwvpauth.php new file mode 100644 index 0000000..27afec8 --- /dev/null +++ b/gwvplib/gwvpauth.php @@ -0,0 +1,91 @@ + +
+ + + + + +
NameYour Full Name
EmailYour Email Address
Nick NameThe Name Used to Refer to you on the site
+
+ Username "; + echo " Passowrd "; + if(gwvp_IsRegistrationEnabled()) echo "Register"; + else echo ""; +} + + +function gwvp_IsRegistrationEnabled() +{ + return true; +} + +// TODO translate info here +function gwvp_GetFullName($login) +{ + return $login; +} +?> \ No newline at end of file diff --git a/gwvplib/gwvpdatabase.php b/gwvplib/gwvpdatabase.php index d53373e..507fdfc 100644 --- a/gwvplib/gwvpdatabase.php +++ b/gwvplib/gwvpdatabase.php @@ -44,5 +44,24 @@ function gwvp_ConnectDB() } } +/* functions we'll need to access data: + * + * getUsers(pattern) + * getUserData(username) + * getGroups(pattern) + * getGroupData(groupname) + * modifyGroup(...) + * addGroupMember(...) + * deleteGroupMember(...) + * + * createUser(...) + * deleteUser(...) + * modifyUser(...) + * createRepo(...) + * deleteRepo(...) + * getRepos() + */ + + ?> \ No newline at end of file diff --git a/gwvplib/gwvpdebug.php b/gwvplib/gwvpdebug.php new file mode 100644 index 0000000..cd3c86f --- /dev/null +++ b/gwvplib/gwvpdebug.php @@ -0,0 +1,74 @@ +"; + echo "BASEURL: $BASE_URL\n"; + echo "CUSTOM\n"; + echo "\n\nserver\n"; + print_r($_SERVER); + echo "\n\n\nrequest\n"; + print_r($_REQUEST); + echo "\n\n\nsession\n"; + print_r($_SESSION); + + + echo ""; +} + +function gwvp_DebugCallMe() +{ + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $myquery = explode("/",$query); + if($myquery[0] == "debug") return "gwvp_DebugCall"; + else return false; + } + + return false; + +} + +function gwvp_DebugCall() +{ + global $BASE_URL; + + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $myquery = explode("/",$query); + if(isset($myquery[1])) { + switch($myquery[1]) { + case "errormessage": + error_log("generate error message"); + gwvp_SendMessage("error", "random message"); + header("Location: $BASE_URL/debug"); + break; + case "infomessage": + error_log("generate info message"); + gwvp_SendMessage("info", "random message"); + header("Location: $BASE_URL/debug"); + break; + default: + gwvp_goMainPage("gwvp_DebugBody"); + return; + } + } else { + gwvp_goMainPage("gwvp_DebugBody"); + } + } +} + +function gwvp_DebugBody() +{ + global $BASE_URL; + ?> + Generate error message
+ Generate info message
+ \ No newline at end of file diff --git a/gwvplib/gwvplib.php b/gwvplib/gwvplib.php index 2a70f0c..674e87c 100644 --- a/gwvplib/gwvplib.php +++ b/gwvplib/gwvplib.php @@ -4,11 +4,11 @@ require_once("gwvpweb.php"); require_once("gwvpgitbackend.php"); require_once("gwvpuseradmin.php"); require_once("gwvprepoadmin.php"); +require_once("gwvpauth.php"); +require_ocne("gwvpsetup.php"); + +// only enable this if you need it: +require_once("gwvpdebug.php"); -// TODO: need to do this bit -function gwvp_issetup() -{ - return true; -} ?> \ No newline at end of file diff --git a/gwvplib/gwvpsetup.php b/gwvplib/gwvpsetup.php new file mode 100644 index 0000000..b83e415 --- /dev/null +++ b/gwvplib/gwvpsetup.php @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/gwvplib/gwvpweb.php b/gwvplib/gwvpweb.php index f476161..474cdff 100644 --- a/gwvplib/gwvpweb.php +++ b/gwvplib/gwvpweb.php @@ -20,7 +20,8 @@ function gwvp_goWebBegin() // next, we go thru the CALL_ME_FUNCTIONS - the purpose of call_me_functions is to determine if a function should be called based on // the functions return (i.e. if function returns false, its not it, otherwise it returns a function name we have to call) - // this is important for our plugin structure later on + // this is important for our plugin structure later on - the key on the array serves an an ordering method + ksort($CALL_ME_FUNCTIONS); foreach($CALL_ME_FUNCTIONS as $key => $val) { error_log("checking callmefunction $key as $val"); $callme = $val(); @@ -34,6 +35,12 @@ function gwvp_goWebBegin() gwvp_goMainPage(); } +function gwvp_SendMessage($messagetype, $message) +{ + $_SESSION["messagetype"] = $messagetype; + $_SESSION["message"] = $message; +} + function gwvp_goMainPage($bodyFunction = null) { // the main page will look pretty simple, a title, a menu then a body @@ -79,9 +86,21 @@ function gwvp_goMainPage($bodyFunction = null) echo "

Git over Web Via PHP

"; - echo "
"; + echo ""; + + if(isset($_SESSION["message"])) { + echo ""; + } + + echo ""; + echo ""; + + echo ""; echo "
"; + gwvp_MessageBuilder(); + echo "
"; gwvp_MenuBuilder(); - echo "
"; + gwvp_LoginBuilder(); + echo "
"; if($bodyFunction == null) { @@ -102,6 +121,29 @@ function gwvp_goMainPage($bodyFunction = null) } + +// builds the message builder if its needed +function gwvp_MessageBuilder() +{ + $message = ""; + $messagetype = "info"; + if(isset($_SESSION["message"])) $message = $_SESSION["message"]; + if(isset($_SESSION["messagetype"])) $messagetype = $_SESSION["messagetype"]; + + if($message != "") { + switch($messagetype) { + case "info": + echo "
$message
"; + break; + case "error": + echo "
$message
"; + break; + } + unset($_SESSION["message"]); + if(isset($_SESSION["messagetype"])) unset($_SESSION["messagetype"]); + } +} + // builds the menu structure function gwvp_MenuBuilder() { @@ -119,6 +161,18 @@ function gwvp_MenuBuilder() } +function gwvp_LoginBuilder() +{ + global $WEB_ROOT_FS, $BASE_URL; + + $login = gwvp_IsLoggedIn(); + if($login === false) { + gwvp_SingleLineLoginForm(); + } else { + echo "Hello, ".gwvp_GetFullName($login); + } +} + // builds the body structure function gwvp_BodyBuilder() { diff --git a/www/css/normal.css b/www/css/normal.css index bf63908..78f157d 100644 --- a/www/css/normal.css +++ b/www/css/normal.css @@ -130,9 +130,18 @@ div.wrapper { input[type=text] { width: 200px; - + border: 1px solid } -input.storage { +input.login { + width: 100px; + border: 1px solid +} + +.loginbutton { + border: 1px solid +} + +input.long { width: 400px; } \ No newline at end of file diff --git a/www/index.php b/www/index.php index aef8e3d..1bc6bc7 100644 --- a/www/index.php +++ b/www/index.php @@ -30,15 +30,8 @@ require_once("gwvplib.php"); gwvp_goWebBegin(); //goWebGitBackEnd(); - -echo "
";
-echo "BASEURL: $BASE_URL\n";
-echo "CUSTOM\n";
-print_r($_SERVER);
-print_r($_REQUEST);
-
-
-echo "
"; - +if(function_exists("gwvp_DebugEnabled")) { + gwvp_DebugEnabled(); +} ?> -- 1.7.0.4