--- /dev/null
+<?php
+
+$CALL_ME_FUNCTIONS["00aaa"] = "gwvp_AuthCallMe";
+
+function gwvp_AuthCallMe()
+{
+ session_start();
+
+ if(isset($_REQUEST["q"])) {
+ $query = $_REQUEST["q"];
+ if($query == "login") return "gwvp_AuthHandleLogin";
+ if($query == "register") return "gwvp_RegistrationCall";
+ else return false;
+ }
+
+ return false;
+}
+
+function gwvp_RegistrationCall()
+{
+ if(gwvp_IsRegistrationEnabled()) {
+ gwvp_goMainPage("gwvp_RegistrationPageBody");
+ } else {
+ gwvp_goMainPage("gwvp_RegistrationDisabledBody");
+ }
+}
+
+function gwvp_AuthHandleLogin()
+{
+ global $BASE_URL;
+ $user = "";
+ $pass = "";
+ if(isset($_REQUEST["username"])) $user = $_REQUEST["username"];
+ if(isset($_REQUEST["password"])) $pass = $_REQUEST["password"];
+
+ // auth the user
+ if($user == "user" && $pass == "pass") {
+ $_SESSION["isloggedin"] = true;
+ $_SESSION["username"] = "user";
+ } else {
+ gwvp_SendMessage("error", "Login Failed");
+ }
+
+ header("Location: $BASE_URL");
+}
+
+function gwvp_RegistrationPageBody()
+{
+ ?>
+ <form method="post">
+ <table>
+ <tr><td>Name</td><td><input name="name" type="text"></td><td>Your Full Name</td></tr>
+ <tr><td>Email</td><td><input name="email" type="text"></td><td>Your Email Address</td></tr>
+ <tr><td>Nick Name</td><td><input name="nickname" type="text"></td><td>The Name Used to Refer to you on the site</td></tr>
+ <tr><td><input type="submit" name="register" value="Register"></td></tr>
+ </table>
+ </form>
+ <?php
+}
+
+function gwvp_IsLoggedIn()
+{
+ if(isset($_SESSION["isloggedin"])) {
+ if($_SESSION["isloggedin"]) {
+ return $_SESSION["username"];
+ } else return false;
+ } else return false;
+}
+
+function gwvp_SingleLineLoginForm()
+{
+ global $BASE_URL;
+
+ echo "<form method=\"post\" action=\"$BASE_URL/login\">Username <input type=\"text\" name=\"username\" class=\"login\">";
+ echo " Passowrd <input type=\"text\" name=\"password\" class=\"login\"><input type=\"submit\" name=\"login\" value=\"Login\" class=\"loginbutton\">";
+ if(gwvp_IsRegistrationEnabled()) echo "<a href=\"$BASE_URL/register\">Register</a></form>";
+ else echo "</form>";
+}
+
+
+function gwvp_IsRegistrationEnabled()
+{
+ return true;
+}
+
+// TODO translate info here
+function gwvp_GetFullName($login)
+{
+ return $login;
+}
+?>
\ No newline at end of file
}
}
+/* 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
--- /dev/null
+<?php
+$CALL_ME_FUNCTIONS["debug"] = "gwvp_DebugCallMe";
+
+$MENU_ITEMS["999debug"]["text"] = "Debug";
+$MENU_ITEMS["999debug"]["link"] = "$BASE_URL/debug";
+
+function gwvp_DebugEnabled()
+{
+ echo "<pre>";
+ 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 "</pre>";
+}
+
+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;
+ ?>
+ <a href="<?php echo $BASE_URL?>/debug/errormessage">Generate error message</a><br>
+ <a href="<?php echo $BASE_URL?>/debug/infomessage">Generate info message</a><br>
+ <?php
+}
+
+?>
\ No newline at end of file
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
--- /dev/null
+<?php
+$CALL_ME_FUNCTIONS["setup"] = "gwvp_SetupCall";
+
+
+function gwvp_SetupCall()
+{
+ if(isset($_REQUEST["q"])) {
+ $query = $_REQUEST["q"];
+ if($query == "postsetup") return "gwvp_PostSetup";
+ else return false;
+ }
+
+ return false;
+
+}
+
+function gwvp_PostSetup()
+{
+ gwvp_goMainPage("gwvp_PostSetupPageBody");
+}
+
+function gwvp_PostSetupPageBody()
+{
+ echo "GWVP Is now setup, login at the top of the page and you should in control!";
+}
+
+// TODO: need to do this bit
+function gwvp_issetup()
+{
+ return true;
+}
+
+
+function gwvp_goSetup()
+{
+
+}
+?>
\ No newline at end of file
// 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();
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
echo "<h1>Git over Web Via PHP</h2>";
- echo "<table width=\"100%\"><tr width=\"100%\"><td>";
+ echo "<table width=\"100%\">";
+
+ if(isset($_SESSION["message"])) {
+ echo "<tr width=\"100%\"><td>";
+ gwvp_MessageBuilder();
+ echo "</td></tr>";
+ }
+
+ echo "<tr width=\"100%\"><td>";
gwvp_MenuBuilder();
- echo "</td></tr>";
+ echo "</td><td align=\"right\">";
+ gwvp_LoginBuilder();
+ echo "</td>";
+
+ echo "</tr>";
echo "<tr><td>";
if($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 "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#AAFFAA\">$message</td></tr></table>";
+ break;
+ case "error":
+ echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#FFAAAA\">$message</td></tr></table>";
+ break;
+ }
+ unset($_SESSION["message"]);
+ if(isset($_SESSION["messagetype"])) unset($_SESSION["messagetype"]);
+ }
+}
+
// builds the menu structure
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()
{
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
gwvp_goWebBegin();
//goWebGitBackEnd();
-
-echo "<pre>";
-echo "BASEURL: $BASE_URL\n";
-echo "CUSTOM\n";
-print_r($_SERVER);
-print_r($_REQUEST);
-
-
-echo "</pre>";
-
+if(function_exists("gwvp_DebugEnabled")) {
+ gwvp_DebugEnabled();
+}
?>