X-Git-Url: http://git.pjr.cc/?p=gwvp-mini.git;a=blobdiff_plain;f=gwvpmini%2Fgwvpmini_admin.php;h=e19a2684b5d4c558d44adc477d40ade6c015273d;hp=353749adbe2de3aef06d1bc0b08faad265760fe6;hb=979dc6190296b0c7ffdfe17031f2d32318da7e2b;hpb=4d6a42b605b8c52c5621fb704b284e4c12672755 diff --git a/gwvpmini/gwvpmini_admin.php b/gwvpmini/gwvpmini_admin.php index 353749a..e19a268 100644 --- a/gwvpmini/gwvpmini_admin.php +++ b/gwvpmini/gwvpmini_admin.php @@ -1,24 +1,62 @@ Disable)"; + } else { + $register = "Registration Disabled (Enable)"; + } + + if($reg_reqs_confirm) { + $regconfirm = "Registration Requires Confirmation (Disable)"; + } else { + $regconfirm = "Registration Doesnt Require Confirmation (Enable)"; + } + + if($use_gravatar) { + $usegrav = "Gravatars are enabled (Disable)"; + } else { + $usegrav = "Gravatars are disabled (Enable)"; + } + + if($force_ssl) { + $forcessl = "Force SSL is enabled (Disable)"; + } else { + $forcessl = "Force SSL is disabled (Enable)"; + } - echo "

Users

"; + + $totalusers = gwvpmini_GetNUsers(); + echo "
"; + echo "

Users - $totalusers

"; + echo "$register
$regconfirm
$usegrav
$forcessl
"; + echo "
"; + echo "Address emails are sent from
"; + echo "
"; + echo ""; - echo ""; + echo ""; foreach(gwvpmini_GetUsers() as $key => $val) { $id = $key; $un = $val["username"]; $em = $val["email"]; $fn = $val["fullname"]; $ds = $val["desc"]; - echo ""; + $st_t = $val["status"]; + $st_l = $val["level"]; + + $astat = "0"; + $cstat = "WTF"; + $level = "WTF"; + if($st_l == 0) $level = "User"; + if($st_l == 1) $level = "Admin"; + + $status = ""; + if($st_t[0] == "1") { + $status = ", disabled"; + $astat = 0; + $cstat = "Enable"; + } else if ($st_t[0] == "0") { + $astat = 1; + $cstat = "Disable"; + } else if($st_t[0] == "2") { + $vl = explode(":", $st_t); + error_log("VL: ".print_r($vl, true)); + $status = " Awaiting Confirmation (Confirm)"; + } + + $st = "$level$status"; + + $unlval = "$un"; + echo ""; + else echo ""; + } + + + echo "
UsernameEmail AddressFull NameDescriptionControl
UsernameEmail AddressFull NameDescriptionStatusControl
$un$em$fn$dsRemove Disable
$unlval$em$fn$ds$stRemove "; + if ($st_t[0] == "0"||$st_t[0] == "1") echo "$cstat
"; + echo "
"; + echo "

Create User

"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
Username
Password
Confirm Password
Full Name
Description
Email
Confirm Email
Admin?
"; + echo "
"; + echo "
"; + + $totalrepos = gwvpmini_GetNRepos(); + echo "

Repo's - $totalrepos

"; + echo ""; + echo ""; + foreach(gwvpmini_GetRepos() as $key => $val) { + $id = $key; + $rn = $val["name"]; + $ds = $val["desc"]; + $ow = $val["owner"]; + $st = $val["status"]; + $udet = gwvpmini_getUser(null, null, $ow); + if(!$udet) { + $owl = "Orphaned"; + } else { + $owl = $udet["username"]." (".$udet["id"].") - ".$udet["fullname"]." (".$udet["email"].") - Email Owner"; + } + + if($st == 1) { + $stat = 0; + $cstat = "Enable"; + } else { + $stat = 1; + $cstat = "Disable"; + } + + echo ""; + } echo "
Repo NameRepo DescOwnerControl
$rn$ds$owlRemove $cstat
"; } + +function gwvpmini_AdminUserCreate() +{ + global $BASE_URL; + + $name = $_REQUEST["username"]; + $pass1 = $_REQUEST["password"]; + $pass2 = $_REQUEST["confpassword"]; + $fname = $_REQUEST["fullname"]; + $desc = $_REQUEST["desc"]; + $email1 = $_REQUEST["email"]; + $email2 = $_REQUEST["confemail"]; + if(isset($_REQUEST["isadmin"])) $level = 1; + else $level = 0; + + $id = gwvpmini_GetUserId($name); + + if(!$id) { + if($pass1 != $pass2) { + gwvpmini_SendMessage("error", "Passwords dont match"); + header("Location: $BASE_URL/admin"); + return; + } + if($email1 != $email2) { + gwvpmini_SendMessage("error", "Email Addresses dont match"); + header("Location: $BASE_URL/admin"); + return; + } + + gwvpmini_AddUser($name, $pass1, $fname, $email1, $desc, $level, 0); + gwvpmini_SendMessage("info", "User $fname created"); + } else { + gwvpmini_SendMessage("error", "User $name already exists, cant create"); + } + + header("Location: $BASE_URL/admin"); + return; + +} + + +function gwvpmini_ChangeRegistration() +{ + global $can_register, $BASE_URL; + + if($can_register) { + gwvpmini_setConfigVal("canregister", "0"); + gwvpmini_SendMessage("info", "Registration disabled"); + } else { + gwvpmini_setConfigVal("canregister", "1"); + gwvpmini_SendMessage("info", "Registration enabled"); + } + + header("Location: $BASE_URL/admin"); +} + + +function gwvpmini_ChangeRegConfig() +{ + global $reg_reqs_confirm, $BASE_URL; + + if($reg_reqs_confirm) { + gwvpmini_setConfigVal("registerrequiresconfirm", "0"); + gwvpmini_SendMessage("info", "Registration Confirmation disabled"); + } else { + gwvpmini_setConfigVal("registerrequiresconfirm", "1"); + gwvpmini_SendMessage("info", "Registration Confirmation enabled"); + } + + header("Location: $BASE_URL/admin"); +} + +function gwvpmini_ChangeFromAddress() +{ + global $BASE_URL; + + $newfrom = $_REQUEST["fromemail"]; + + gwvpmini_setConfigVal("eamilfromaddress", "$newfrom"); + gwvpmini_SendMessage("info", "Email from address updated to \"$newfrom\""); + + header("Location: $BASE_URL/admin"); + +} + +function gwvpmini_RemoveUserPageBody() +{ + global $BASE_URL; + + $uid = -1; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + if(isset($qspl[2])) { + $uid = $qspl[2]; + } + } + + if($uid != -1) { + $details = gwvpmini_GetUsers($uid, 1); + $username = $details[$uid]["username"]; + $fullname = $details[$uid]["fullname"]; + $email = $details[$uid]["email"]; + $desc = $details[$uid]["desc"]; + + error_log("user dets:".print_r($details, true)); + + echo "

Remove User?

"; + echo "Are you sure you wish to remove the user, $username ($uid) - $fullname - $email - $desc?
"; + echo "Yes No
"; + } else { + echo "

How?

"; + echo "You got here in a weird way or the uid of the user you were trying to delete is invalid
"; + echo "Go Back"; + } + +} + +function gwvpmini_RemoveRepoPageBody() +{ + global $BASE_URL; + + $rid = -1; + $uid = -1; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + if(isset($qspl[2])) { + $rid = $qspl[2]; + } + } + + $repdet = gwvpmini_getRepo(null, null, $rid); + if($repdet != false) $uid = $repdet["ownerid"]; + $usedet = gwvpmini_getUser(null, null, $uid); + + + if($rid != -1) { + $rname = $repdet["name"]; + $rdesc = $repdet["desc"]; + if($usedet == false) { + $ownedby = "which is unowned (Orphaned)"; + } else { + $ownedby = "owned by $username ($uid) - \"$fullname\""; + } + $username = $usedet["username"]; + $fullname = $usedet["fullname"]; + + + error_log("user dets:".print_r($details, true)); + + echo "

Remove User?

"; + echo "Are you sure you wish to remove the repo, $rname ($rid) - \"$rdesc\" $ownedby?
"; + echo "Yes No
"; + } else { + echo "

How?

"; + echo "You got here in a weird way or the uid of the repo you were trying to delete is invalid
"; + echo "Go Back"; + } + +} + +function gwvpmini_ConfRemoveRepo() +{ + global $BASE_URL; + + + error_log("CONF REMOVE REPO"); + + $rid = -1; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + if(isset($qspl[2])) { + $rid = $qspl[2]; + } + } + + if($rid > 0) { + $details = gwvpmini_getRepo(null, null, $rid); + $rname = $details["name"]; + gwvpmini_RemoveRepo($rid); + gwvpmini_SendMessage("info", "Repo $rname ($rid) has been removed"); + } else { + gwvpmini_SendMessage("info", "Problem deleteing repo with rid $rid"); + } + + header("Location: $BASE_URL/admin"); +} + +function gwvpmini_ConfRemoveUser() +{ + global $BASE_URL; + + $uid = -1; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + if(isset($qspl[2])) { + $uid = $qspl[2]; + } + } + + if($uid > 0) { + $details = gwvpmini_getUser(null, null, $uid); + $uname = $details["username"]; + gwvpmini_RemoveUser($uid); + gwvpmini_SendMessage("info", "User $uname ($uid) has been removed"); + } else { + gwvpmini_SendMessage("info", "Problem deleteing user with uid $uid"); + } + + header("Location: $BASE_URL/admin"); +} + +function gwvpmini_SwitchEnableUser() +{ + global $BASE_URL; + + $uid = -1; + $newst = -1; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + if(isset($qspl[2])) { + $newst = $qspl[2]; + } + if(isset($qspl[3])) { + $uid = $qspl[3]; + } + } + + if($newst == 1) $stat = "disabled"; + else $stat = "enabled"; + + if($uid > 0 && ($newst == 1 || $newst == 0)) { + $details = gwvpmini_getUser(null, null, $uid); + $uname = $details["username"]; + if($newst == 1) gwvpmini_DisableUser($uid); + if($newst == 0) gwvpmini_EnableUser($uid); + gwvpmini_SendMessage("info", "User $uname ($uid) has been $stat"); + } else { + gwvpmini_SendMessage("info", "Problem disabling user with uid $uid"); + } + + header("Location: $BASE_URL/admin"); + +} + +function gwvpmini_SwitchEnableRepo() +{ + global $BASE_URL; + + $rid = -1; + $newst = -1; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + if(isset($qspl[2])) { + $newst = $qspl[2]; + } + if(isset($qspl[3])) { + $rid = $qspl[3]; + } + } + + if($newst == 1) $stat = "disabled"; + else $stat = "enabled"; + + if($rid > 0 && ($newst == 1 || $newst == 0)) { + $details = gwvpmini_getRepo(null, null, $rid); + if($newst == 1) gwvpmini_DisableRepo($rid); + if($newst == 0) gwvpmini_EnableRepo($rid); + gwvpmini_SendMessage("info", "Repo $uname ($rid) has been $stat"); + } else { + gwvpmini_SendMessage("info", "Problem disabling repo with rid $rid"); + } + + header("Location: $BASE_URL/admin"); +} + +function gwvpmini_SwitchGravatars() +{ + global $BASE_URL, $use_gravatar; + + if($newst == 1) $stat = "disabled"; + else $stat = "enabled"; + + if($use_gravatar) { + gwvpmini_setConfigVal("gravatarenabled", "0"); + } else { + gwvpmini_setConfigVal("gravatarenabled", "1"); + } + + gwvpmini_SendMessage("info", "Gravatars $stat"); + + header("Location: $BASE_URL/admin"); +} + +function gwvpmini_SwitchForceSSL() +{ + global $BASE_URL, $force_ssl; + + if($newst == 1) $stat = "disabled"; + else $stat = "enabled"; + + if($force_ssl) { + gwvpmini_setConfigVal("forcessl", "0"); + } else { + gwvpmini_setConfigVal("forcessl", "1"); + } + + gwvpmini_SendMessage("info", "forcessl $stat"); + + header("Location: $BASE_URL/admin"); + +} ?> \ No newline at end of file