Browse Source

Removed old git settings.

development
Teknikode 4 years ago
parent
commit
21026b2732

+ 3
- 36
home/profile.php View File

@@ -32,7 +32,7 @@ if (isset($_GET['id']))
<?php if ($Profile_User->blog_title) { ?>
<li class="list-group-item text-right"><span class="pull-left"><strong>Blog</strong></span> <a href="<?php echo get_page_url('blog', $CONF).'/'.$Profile_User->username; ?>" id="blog_title"><?php echo $Profile_User->blog_title; ?></a></li>
<?php } ?>
<?php if (is_dir("G:\\Repositories\\u\\".$Profile_User->username) && !is_dir_empty("G:\\Repositories\\u\\".$Profile_User->username)) { ?>
<?php if (is_dir("B:\\Repositories\\Teknik\\".strtolower($Profile_User->username)) && !is_dir_empty("B:\\Repositories\\Teknik\\".strtolower($Profile_User->username))) { ?>
<li class="list-group-item text-right"><span class="pull-left"><strong>Git</strong></span> <a href="<?php echo get_page_url('git', $CONF).'/u/'.$Profile_User->username; ?>">Public Repos</a></li>
<?php } ?>
<?php if ($own_profile) { ?>
@@ -176,40 +176,7 @@ if (isset($_GET['id']))
<input class="form-control" id="update_minecraft" name="update_minecraft" placeholder="super_miner64" title="enter your minecraft username" type="text" value="<?php echo $Profile_User->minecraft_user; ?>" />
</div>
</div>
-->
<!-- Git Settings -->
<div class="row">
<div class="col-sm-12 text-center">
<h3>Git Settings</h3>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-12">
<h4>Public Key(s)</h4>
<input id="update_public_key" name="update_public_key" type="hidden" value="<?php echo $Profile_User->public_key; ?>" />
</div>
</div>
<div class="row">
<div class="col-sm-12" id="public_key_list">
<?php
$keyList = array_filter(explode(",", $Profile_User->public_key));
$index = 1;
foreach ($keyList as $key)
{
?>
<div class="public_key_<?php echo $index; ?>"><div class="input-group"><input type="text" class="form-control" id="public_key_input_<?php echo $index; ?>" value="<?php echo $key; ?>" readonly><span class="input-group-btn"><button class="btn btn-danger public_key_delete" type="button" id="<?php echo $index; ?>">Remove</button></span></div><br /></div>
<?php
$index++;
}
?>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<button class="btn btn-md btn-primary" id="add_public_key"><i class="glyphicon glyphicon-plus"></i> Add Key</button>
</div>
</div>
-->
<!-- Blog Settings -->
<div class="row">
<div class="col-sm-12 text-center">
@@ -271,4 +238,4 @@ else
redirect(get_page_url("home", $CONF));
}
include('../templates/'.$CONF['template'].'/footer.php');
?>
?>

+ 4
- 9
includes/classes/User.class.php View File

@@ -9,8 +9,7 @@ class User {
public $admin;
public $join_date;
public $last_seen;
public $theme;
public $public_key;
public $theme;
public $profile_image;
public $website;
public $about;
@@ -28,9 +27,7 @@ class User {
$this->admin = (isset($data['site_admin'])) ? (bool) $data['site_admin'] : "";
$this->join_date = (isset($data['join_date'])) ? $data['join_date'] : "";
$this->last_seen = (isset($data['last_seen'])) ? $data['last_seen'] : "";
$this->theme = (isset($data['theme'])) ? $data['theme'] : "";
$this->public_key = (isset($data['public_key'])) ? $data['public_key'] : "";
$this->minecraft_user = (isset($data['minecraft_user'])) ? $data['minecraft_user'] : "";
$this->theme = (isset($data['theme'])) ? $data['theme'] : "";
$this->website = (isset($data['website'])) ? $data['website'] : "";
$this->about = (isset($data['about'])) ? $data['about'] : "";
$this->quote = (isset($data['quote'])) ? $data['quote'] : "";
@@ -63,9 +60,7 @@ class User {
"username" => $this->username,
"password" => $this->hashedPassword,
"last_seen" => date("Y-m-d H:i:s",time()),
"theme" => $this->theme,
"public_key" => $this->public_key,
"minecraft_user" => $this->minecraft_user,
"theme" => $this->theme,
"website" => $this->website,
"quote" => $this->quote,
"about" => $this->about,
@@ -117,4 +112,4 @@ class User {
return isset($this->roles[$role_name]);
}
}
?>
?>

+ 34
- 0
includes/common.php View File

@@ -657,4 +657,38 @@ function multi_array_search($array, $search)
// Return the result array
return $result;
}

function CallAPI($method, $url, $username, $password, $data = false)
{
$curl = curl_init();

switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);

if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}

// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, $username.":".$password);

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($curl);

curl_close($curl);

return $result;
}
?>

+ 1
- 15
includes/config.php.default View File

@@ -107,21 +107,7 @@ $CONF['upload_dir'] = 'C:\\Upload\\Dir\\';
$CONF['max_upload_size'] = 100; // In MB
// Git Info
$CONF['git_path'] = 'C:\\Git\\bin\\git.exe';
$CONF['git_repo_path'] = array('C:\\Repositories\\Dir\\');
$CONF['gitolite_path'] = '/cygwin/bin/gitolite/';
$CONF['git_key_dir'] = 'C:\\cygwin\\var\\keys';
$CONF['git_user'] = "gituser";
$CONF['git_pass'] = "password";
$CONF['ssh_pub_keys'] = "C:\\Users\\user\\.ssh\\authorized_keys";
$CONF['forced_commands'] = "no-port-forwarding,no-agent-forwarding,command=\"./gitserv\"";
$CONF['git_csrf'] = "";
// IRC Info
$CONF['irc_network'] = "irc.server.net";

+ 27
- 34
includes/delete_account.php View File

@@ -4,46 +4,39 @@ require_once('config.php');
//check to see that the form has been submitted
if(isset($_POST))
{
//delete user from mail-server
$obBaseApp = new COM("hMailServer.Application");
$obBaseApp->Connect();
$obBaseApp->Authenticate($CONF['mail_admin_user'], $CONF['mail_admin_pass']);
$domain = $obBaseApp->Domains->ItemByName($CONF['host']);
$email = $user->username . "@" . $CONF['host'];
$account = $domain->Accounts->ItemByAddress($email);
$account->Delete();
//delete user from mail-server
$obBaseApp = new COM("hMailServer.Application");
$obBaseApp->Connect();
$obBaseApp->Authenticate($CONF['mail_admin_user'], $CONF['mail_admin_pass']);
$domain = $obBaseApp->Domains->ItemByName($CONF['host']);
$email = $user->username . "@" . $CONF['host'];
$account = $domain->Accounts->ItemByAddress($email);
$account->Delete();
//delete any public keys from git auth
$dir = $CONF['git_key_dir'].'u\\'.$user->username;
if (is_dir($dir))
{
foreach (glob($dir."\\*") as $filename)
// delete user from git database
$result = CallAPI("POST", get_page_url('git', $CONF)."/user/settings/delete", $user->username, $user->password, array("_csrf" => $CONF['git_csrf']));
if($result)
{
if (is_file($filename))
{
unlink($filename);
}
}
}
putenv("HOME=/home/git");
$result = shell_exec('bash --login -c "'.$CONF['gitolite_path'].'gitolite trigger SSH_AUTHKEYS"');
/*
$r = new minecraftRcon($CONF['minecraft_server'], $CONF['rcon_port'], $CONF['rcon_pass']);
echo $result;
}
// Authenticate, and if so, execute command(s)
if ( $r->Auth() ) {
/*
$r = new minecraftRcon($CONF['minecraft_server'], $CONF['rcon_port'], $CONF['rcon_pass']);

// Authenticate, and if so, execute command(s)
if ( $r->Auth() ) {
$r->mcRconCommand('pex user '.$user->minecraft_user." group remove Member");
}
*/
//delete the user from the main database
$user->delete($db);
//log the user out
$userTools->logout($CONF);
echo "true";
}
*/
//delete the user from the main database
$user->delete($db);
//log the user out
$userTools->logout($CONF);
echo "true";
}
else
{
echo "false";
}
?>
?>

+ 6
- 60
includes/update_profile.php View File

@@ -5,8 +5,7 @@ require_once('config.php');
$current_password = "";
$password = "";
$password_confirm = "";
$theme = "";
$public_key = "";
$theme = "";
$minecraft = "";
$website = "";
$profile_image = "";
@@ -35,8 +34,7 @@ if(isset($_POST))
$current_password = rawurldecode($_POST['current_password']);
$password = rawurldecode($_POST['password']);
$password_confirm = rawurldecode($_POST['password_confirm']);
$theme = rawurldecode($_POST['theme']);
$public_key = rawurldecode($_POST['public_key']);
$theme = rawurldecode($_POST['theme']);
//$minecraft = rawurldecode($revised_post_array['minecraft']);
$website = rawurldecode($revised_post_array['website']);
$quote = rawurldecode($revised_post_array['quote']);
@@ -105,19 +103,7 @@ if(isset($_POST))
{
$error = "Invalid Theme Choice.";
$success = false;
}
$keys = explode(",", $public_key);
foreach ($keys as $key)
{
$pattern = "/^(ssh-rsa)\s([0-9A-Za-z\/\+]+)([=]*)((\s.*)|())$/";
if($success && $key && !preg_match($pattern, $key))
{
$error = "Invalid Public Key.<br />Please make sure it follows this format.<br /><b>ssh-rsa [0-9A-Za-z/+ ]</b>";
$success = false;
break;
}
}
}
if($success)
{
@@ -137,46 +123,7 @@ if(isset($_POST))
$account->Save();
}
}
// Add the user's keys to his git account
if ($public_key != $user->public_key)
{
$dir = $CONF['git_key_dir'].'u\\'.$user->username;
if (is_dir($dir))
{
foreach (glob($dir."\\*") as $filename)
{
if (is_file($filename))
{
unlink($filename);
}
}
}
if (!is_dir($dir))
{
mkdir($dir, 0777, true);
}
$index = 0;
$keys = explode(",", $public_key);
foreach ($keys as $key)
{
preg_match($pattern, $key, $matches);
if (trim($matches[2]) != "")
{
$key = "ssh-rsa " . $matches[2];
$keyFileName = $dir."\\".$user->username."@Key".$index.".pub";
$fileHandle = fopen($keyFileName, 'w');
fwrite($fileHandle, $key);
fclose($fileHandle);
$index++;
}
}
putenv("HOME=/home/git");
$result = shell_exec('bash --login -c "'.$CONF['gitolite_path'].'gitolite trigger SSH_AUTHKEYS"');
}

/*
if ($minecraft != $user->minecraft_user)
{
@@ -191,8 +138,7 @@ if(isset($_POST))
}
}
*/
$user->theme = $theme;
$user->public_key = $public_key;
$user->theme = $theme;
//$user->minecraft_user = $minecraft;
$user->website = $website;
$user->quote = $quote;
@@ -216,4 +162,4 @@ else
{
echo "$_POST is not set.";
}
?>
?>

+ 5
- 62
templates/default/js/profile.js View File

@@ -26,43 +26,7 @@ $(document).ready(function() {
}
});
});
$("#add_public_key").click(function() {
bootbox.prompt("Enter your Public Key [ie: ssh-rsa (.*)]", function(result) {
if (result)
{
prev_keys = $("#update_public_key").val();
var prev_split = prev_keys.split(",");
var key_used = false;
var index = prev_split.indexOf(result);
var num_keys = prev_split.length;
if (index != -1)
{
key_used = true;
}
if (!key_used)
{
if (num_keys > 0)
{
$("#update_public_key").val(prev_keys + ',' + result);
}
else
{
$("#update_public_key").val(result);
}
var key_index = num_keys + 1;
$("#public_key_list").append('<div class="public_key_'+key_index.toString()+'"><div class="input-group"><input type="text" class="form-control" id="public_key_input_'+key_index.toString()+'" value="'+result+'" readonly><span class="input-group-btn"><button class="btn btn-danger public_key_delete" type="button" id="'+key_index.toString()+'">Remove</button></span></div><br /></div>');
linkKeyDelete('.public_key_delete');
}
else
{
bootbox.alert("That key is already in the list.", function() { });
}
}
});
return false;
});

$("#update_submit").click(function(){
// Start Updating Animation
$.blockUI({ message: '<div class="text-center"><h3>Updating...</h3></div>' });
@@ -70,10 +34,8 @@ $(document).ready(function() {
current_password=encodeURIComponent($("#update_password_current").val());
password=encodeURIComponent($("#update_password").val());
password_confirm=encodeURIComponent($("#update_password_confirm").val());
theme=encodeURIComponent($("#update_theme").val());
public_key=encodeURIComponent($("#update_public_key").val());
website=encodeURIComponent($("#update_website").val());
minecraft=encodeURIComponent($("#update_minecraft").val());
theme=encodeURIComponent($("#update_theme").val());
website=encodeURIComponent($("#update_website").val());
quote=encodeURIComponent($("#update_quote").val());
about=encodeURIComponent($("#update_about").val());
blog_title=encodeURIComponent($("#update_blog_title").val());
@@ -81,7 +43,7 @@ $(document).ready(function() {
$.ajax({
type: "POST",
url: "../../../includes/update_profile.php",
data: "current_password="+current_password+"&password="+password+"&password_confirm="+password_confirm+"&theme="+theme+"&public_key="+public_key+"&website="+website+"&minecraft="+minecraft+"&quote="+quote+"&about="+about+"&blog_title="+blog_title+"&blog_desc="+blog_desc,
data: "current_password="+current_password+"&password="+password+"&password_confirm="+password_confirm+"&theme="+theme+"&website="+website+"&quote="+quote+"&about="+about+"&blog_title="+blog_title+"&blog_desc="+blog_desc,
success: function(html)
{
if(html=='true')
@@ -99,23 +61,4 @@ $(document).ready(function() {
});
return false;
});
});
function linkKeyDelete(selector)
{
$(selector).click(function(){
var object = $(this);
key_index=object.attr('id');
key=$('#public_key_input_'+key_index.toString()).val();
prev_keys = $("#update_public_key").val();
var prev_split = prev_keys.split(",");
var index = prev_split.indexOf(key);
if (index != -1)
{
prev_split.splice(index, 1);
$("#update_public_key").val(prev_split.toString());
}
$(".public_key_"+key_index.toString()).remove();
return false;
});
}
});

Loading…
Cancel
Save