From: Paul J R Date: Wed, 19 Sep 2012 01:04:07 +0000 (+1000) Subject: Added user view page, updated repo view page, added ocmmit logs X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=abfd6ab968291688d09edfbefb38c88f1a33c919;p=gwvp-mini.git Added user view page, updated repo view page, added ocmmit logs --- diff --git a/gwvpmini/gwvpmini.php b/gwvpmini/gwvpmini.php index 696ef0f..8c510b6 100644 --- a/gwvpmini/gwvpmini.php +++ b/gwvpmini/gwvpmini.php @@ -8,6 +8,7 @@ require_once("gwvpmini_gitrepo.php"); require_once("gwvpmini_search.php"); require_once("gwvpmini_gitbackend.php"); require_once("gwvpmini_view.php"); +require_once("gwvpmini_user.php"); if(gwvpmini_isLoggedIn()) if(gwvpmini_isUserAdmin()) { require_once("gwvpmini_admin.php"); } diff --git a/gwvpmini/gwvpmini_admin.php b/gwvpmini/gwvpmini_admin.php index fcd6fa2..55eae57 100644 --- a/gwvpmini/gwvpmini_admin.php +++ b/gwvpmini/gwvpmini_admin.php @@ -80,7 +80,7 @@ function gwvpmini_AdminMainPageBody() $rn = $val["name"]; $ds = $val["desc"]; $ow = $val["owner"]; - echo "$rn$ds$owRemove Disable"; + echo "$rn$ds$owRemove Disable"; } echo ""; } diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index 4408014..3f63804 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -290,6 +290,23 @@ function gwvpmini_GetUserId($username) return $retval; } +function gwvpmini_GetUserNameFromEmail($email) +{ + $conn = gwvpmini_ConnectDB(); + + $sql = "select user_username from users where user_email='$email'"; + + error_log("username sql $sql"); + + $res = $conn->query($sql); + + $retval = false; + foreach($res as $row) { + $retval = $row[0]; + } + + return $retval; +} function gwvpmini_GetOwnedRepos($username) { /* diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php index 54c5328..96ee359 100644 --- a/gwvpmini/gwvpmini_view.php +++ b/gwvpmini/gwvpmini_view.php @@ -42,10 +42,53 @@ function gwvpmini_RepoViewPage() function gwvpmini_RepoViewPageBody() { - global $repo_view_call, $MENU_ITEMS; + global $repo_view_call, $MENU_ITEMS, $BASE_URL; + + $repo_base = gwvpmini_getConfigVal("repodir"); + if($_SERVER["SERVER_PORT"] == 443) $proto="https://"; + else $proto = "http://"; + $sname = $_SERVER["SERVER_NAME"]; + + echo "

$repo_view_call by owner

"; + echo "Desc
"; + echo "
"; + //echo "command: git log --git-dir=$repo_base/$repo_view_call.git --pretty=format:\"%H\" -10"; + $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%H\" -10", "r"); + $commitids = array(); + $i = 0; + if($rs) { + while(!feof($rs)) { + $flin = fgets($rs); + if($flin !== false) { + $commitids[$i] = trim($flin); + $i++; + } + } + fclose($rs); + } else { + echo "No commit logs yet
"; + $commitids = false; + } + + if($commitids != false) { + echo "
Commits
"; + echo ""; + echo ""; + foreach($commitids as $ids) { + $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%at%n%ce%n%s\" $ids -1", "r"); + if($rs) { + $flin1 = trim(fgets($rs)); + $flin2 = gwvpmini_emailToUserLink(trim(fgets($rs))); + while(!feof($rs)) { + $flin3 = fread($rs, 8192); + } + } + echo ""; + } + echo "
Committed ByDateCommit Log Entry
$flin2$flin1$flin3
"; + } - echo "In repoview call for $repo_view_call"; } diff --git a/gwvpmini/gwvpmini_web.php b/gwvpmini/gwvpmini_web.php index b158226..f6b6665 100644 --- a/gwvpmini/gwvpmini_web.php +++ b/gwvpmini/gwvpmini_web.php @@ -110,7 +110,7 @@ function gwvpmini_goMainPage($bodyFunction = null) echo ""; - echo ""; + echo ""; if($bodyFunction == null) { gwvpmini_BodyBuilder(); } else { @@ -227,6 +227,19 @@ function gwvpmini_TailBuilder() echo "Copyright 2011, PJR - licensed under GPL"; } +function gwvpmini_emailToUserLink($email) +{ + global $BASE_URL; + + $username = gwvpmini_GetUserNameFromEmail($username); + + if($username !== false) { + return "$username"; + } else { + return "Uknown"; + } +} + function gwvpmini_fourZeroThree() { error_log("403 called"); diff --git a/www/index.php b/www/index.php index 412c49e..61e77b2 100644 --- a/www/index.php +++ b/www/index.php @@ -29,11 +29,11 @@ if(!gwvpmini_DBExists($db_name)) { gwvpmini_goWeb(); -/* + echo "
";
 print_r($_SERVER);
 print_r($_REQUEST);
 print_r($_SESSION);
 echo "
"; -*/ + ?> \ No newline at end of file