Merge pull request #30 from hiagohubert/master

Check if b374k is in a git repository
This commit is contained in:
b374k 2018-06-06 11:22:19 +07:00 committed by GitHub
commit dfabccb364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#tobottom{-webkit-transform:scaleY(-1);-moz-transform:scaleY(-1);-o-transform:scaleY(-1);transform:scaleY(-1);filter:FlipV;-ms-filter:"FlipV";}
#showinfo{float:right;display:none;}
#logout{float:right;}
.git_alert{font-weight: bold; color:#ef793e; font-size: 16px;}
</style>
</head>
<body>
@ -64,6 +65,11 @@
foreach(get_server_info() as $k=>$v){
echo "<div>".$v."</div>";
}
if(is_git_repo(getcwd())){
echo "<p class=\"git_alert\">Warning: b374k is running under a git repository!</p>
<a href=\"#\"> Click here to hide b374k from git </a>";
}
?>
</div>
<!--server info end-->

View File

@ -985,4 +985,24 @@ if(!function_exists('output')){
die();
}
}
if(!function_exists('is_git_repo')){
function is_git_repo(){
return boolval( find_git_repo(getcwd().DIRECTORY_SEPARATOR.".git") );
}
}
if(!function_exists('find_git_repo')){
function find_git_repo($path){
if(dirname($path) == DIRECTORY_SEPARATOR){
return false;
}else if(is_dir(dirname($path).DIRECTORY_SEPARATOR.".git")){
return dirname($path).DIRECTORY_SEPARATOR.".git";
}else{
return find_git_repo(dirname($path));
}
}
}
?>