global $WEB_ROOT_FS, $BASE_URL, $IS_WEB_REQUEST, $data_directory, $db_type, $db_name, $db_username, $db_password, $IS_WEB_REQUEST, $cmd_line_tool;
$IS_WEB_REQUEST = false;\r
-if(file_exists("../www/config.php")) require_once("../www/config.php");
+if(file_exists("$WEB_ROOT_FS/../www/config.php")) require_once("$WEB_ROOT_FS/../www/config.php");
else if(file_exists("/etc/gwvpmini/config.php")) require_once("/etc/gwvpmini/config.php");
else $noconfig = true;
-if(file_exists("../gwvpmini/gwvpmini.php")) require_once("../gwvpmini/gwvpmini.php");
+if(file_exists("$WEB_ROOT_FS/../gwvpmini/gwvpmini.php")) require_once("$WEB_ROOT_FS/../gwvpmini/gwvpmini.php");
else if(file_exists("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php")) require_once("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php");
if(isset($argv["1"])) {
echo "\tupdatehook <user> <ref> <firstupdate> <lastupdate>\n";
}
+
+// update will log things like branch and tag creations
function gwvpcmdtool_UpdateHook()
{
global $argv;
- echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
+ //echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
+ if(preg_match("/^000000+$/", $argv[3])) {
+ // createion of tag or branch
+ $vals = explode("/", $argv[2]);
+ $type = "unknowncreate";
+ if($vals == "heads") $type = "branchcreate";
+ if($vals == "tags") $type = "tagcreate";
+ gwvpmini_AddActivityLog("$type", "1", "1", $argv[4], "somelogs");
+ }
+ //gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog)
}
+// pre-receive logs all commit info
function gwvpcmdtool_PreReceive()
{
global $argv;
- echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";\r
+ //echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";\r
- passthru("git rev-list --reverse ".$argv[3]." --not --all ");
+ //passthru("git rev-list --reverse ".$argv[3]." --not --all ");
}
?>
\ No newline at end of file
}
- $reg = gwvpmini_getConfigVal("gravatarenabled");
-
- $use_gravatar = false;\r
- if($reg == null) {\r
- gwvpmini_setConfigVal("gravatarenabled", "1");\r
- } else if($reg == 1) {\r
- $use_gravatar = true;\r
- } else {\r
- $use_gravatar = false;\r
- }\r
- \r
- global $use_gravatar;
}
function gwvpmini_AdminCallMe()\r
global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $DB_CONNECTION;\r
\r
// first check if $DB_CONNECTION IS live\r
- //error_log("in connection $db_type, $db_name");\r
+ //error_log("in connection $db_type, $db_name");
+ $db_url = false;\r
\r
if($DB_CONNECTION != false) return $DB_CONNECTION;\r
\r
}\r
\r
// and here we go with pdo.\r
- //error_log("attmpting to open db, $db_type:$db_url");\r
+ error_log("attmpting to open db, $db_type:$db_url");\r
try {\r
$DB_CONNECTION = new PDO("$db_type:$db_url");\r
} catch(PDOException $exep) {\r
return $retval;
}\r
+function gwvpmini_GetActivityLog($nentries = 100)
+{
+ $conn = gwvpmini_ConnectDB();\r
+
+ $sql = "select * from activity order by activity_date desc limit 100";
+
+ $res = $conn->query($sql);
+
+ $logs = null;
+ $i = 0;
+ foreach($res as $row) {
+ $logs[$i]["type"] = $row["activity_type"];
+ $logs[$i]["date"] = $row["activity_date"];
+ $logs[$i]["userid"] = $row["activity_user"];
+ $logs[$i]["repoid"] = $row["activity_repo"];
+ $logs[$i]["commitid"] = $row["activity_commitid"];
+ $logs[$i]["commitlog"] = $row["activity_commitlog"];
+ $logs[$i]["visibleto"] = $row["activity_visibleto"];
+ $i++;
+ }
+
+ return $logs;
+}
+
+function gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog)
+{
+ /*
+ * CREATE TABLE "activity" (
+ "activity_id" INTEGER PRIMARY KEY AUTOINCREMENT,
+ "activity_type" TEXT,
+ "activity_date" TEXT,
+ "activity_user" TEXT,
+ "activity_repo" TEXT,
+ "activity_commitid" TEXT,
+ "activity_commitlog" TEXT,
+ "activity_visibleto" TEXT
+ )';
+
+ */
+
+ $conn = gwvpmini_ConnectDB();
+
+ // TODO: implement visibility
+ $visibleto = "a";\r
+ \r
+ $sql = "insert into 'activity' values ( null, '$type', '".time()."', '$userid', '$repoid', '$commitid', '$commitlog', '$visibleto')";
+
+ error_log("SQL IS $sql");\r
+ \r
+ $res = $conn->query($sql);\r
+ if(!$res) return -1;
+ return true;
+}
function gwvpmini_dbCreateSQLiteStructure($dbloc)\r
{\r
// "a" for everyone
$activitysql = '
CREATE TABLE "activity" (
+ "activity_id" INTEGER PRIMARY KEY AUTOINCREMENT,
"activity_type" TEXT,
"activity_date" TEXT,
- "activity_desc" TEXT,
- "activity_link" TEXT,
- "activity_viewby" TEXT
+ "activity_user" TEXT,
+ "activity_repo" TEXT,
+ "activity_commitid" TEXT,
+ "activity_commitlog" TEXT,
+ "activity_visibleto" TEXT
)';\r
\r
$configsql = '\r
$procenv["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"];
$procenv["AUTH_TYPE"] = "Basic";
- error_log("PROCENV: ".print_r($procenv,true));
+ //error_log("PROCENV: ".print_r($procenv,true));
if(isset($_SERVER["CONTENT_TYPE"])) {
$procenv["CONTENT_TYPE"] = $_SERVER["CONTENT_TYPE"];
echo "</table>";
}\r
}
+
+ $logs = gwvpmini_GetActivityLog();
+ if($logs !== null) {
+ echo "<h2>Global Log</h2><table>";
+ foreach($logs as $ents) {
+ echo "<tr><td>".$ents["type"]."</td><td>".$ents["commitid"]."</td></tr>";
+ }
+ echo "</table>";
+ }
}
function gwvpmini_GitCreateRepoForm()
<?php
$CALL_ME_FUNCTIONS["userview"] = "gwvpmini_UserViewCallMe";
+if($IS_WEB_REQUEST) {
+ $reg = gwvpmini_getConfigVal("gravatarenabled");\r
+ \r
+ $use_gravatar = false;\r
+ if($reg == null) {\r
+ gwvpmini_setConfigVal("gravatarenabled", "1");\r
+ } else if($reg == 1) {\r
+ $use_gravatar = true;\r
+ } else {\r
+ $use_gravatar = false;\r
+ }\r
+ \r
+ global $use_gravatar;
+}\r
function gwvpmini_UserViewCallMe()
{
global $user_view_call;
- echo "Want to see $user_view_call eh?";
+
+ $dets = gwvpmini_getUser($user_view_call);
+ error_log("show view of user with $user_view_call: ". print_r($dets, true));\r
+
+ echo "<h2>".$dets["fullname"]."</h2><br>";
+ echo gwvpmini_HtmlGravatar($dets["email"],80);
}
?>
\ No newline at end of file
global $use_gravatar;
+ if($use_gravatar) {
+ error_log("call to gravatar with yes");
+ } else {
+ error_log("call to gravatar with no");
+ }
if($use_gravatar == false) return "";
return get_gravatar( $email, $size, 'mm', 'g', true)."$htmlappend";