Skip to content
Snippets Groups Projects
Commit fc6a3937 authored by Bob Mottram's avatar Bob Mottram
Browse files

Allow gogs registrations via web UI

parent 0f81679f
No related branches found
No related tags found
No related merge requests found
...@@ -53,6 +53,22 @@ gogs_variables=(ONION_ONLY ...@@ -53,6 +53,22 @@ gogs_variables=(ONION_ONLY
DDNS_PROVIDER DDNS_PROVIDER
ARCHITECTURE) ARCHITECTURE)
function gogs_setting_registration {
allow_registrations="$1"
if [[ "$allow_registrations" == '1' ]]; then
sed -i "s|DISABLE_REGISTRATION =.*|DISABLE_REGISTRATION = false|g" /home/gogs/custom/conf/app.ini
sed -i "s|SHOW_REGISTRATION_BUTTON =.*|SHOW_REGISTRATION_BUTTON = true|g" /home/gogs/custom/conf/app.ini
systemctl restart gogs
fi
if [[ "$allow_registrations" == '0' ]]; then
sed -i "s|DISABLE_REGISTRATION =.*|DISABLE_REGISTRATION = true|g" /home/gogs/custom/conf/app.ini
sed -i "s|SHOW_REGISTRATION_BUTTON =.*|SHOW_REGISTRATION_BUTTON = false|g" /home/gogs/custom/conf/app.ini
systemctl restart gogs
fi
}
function logging_on_gogs { function logging_on_gogs {
echo -n '' echo -n ''
} }
......
<!DOCTYPE html>
<html>
<style>
* {
box-sizing: border-box;
}
a, u {
text-decoration: none;
color: #72a7cf;
font-weight: bold;
}
a:visited{
color: #72a7cf;
font-weight: bold;
}
#headerpic {
width: 60%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 220px;
}
body {
margin: 0;
font-family: Arial;
}
.header {
text-align: center;
padding: 32px;
}
.headertext {
color: #72a7cf;
text-align: center;
font-size: 120%;
font-weight: bold;
}
.settingtext {
text-align: center;
font-size: 100%;
}
.row {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
padding: 0 4px;
}
.column {
-ms-flex: 25%;
flex: 15%;
max-width: 25%;
padding: 0 4px;
}
.column img {
margin-top: 8px;
vertical-align: middle;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 600px;
margin: auto;
text-align: center;
font-family: arial;
clear: both;
}
.card input[type=text] {
width: 50%;
clear: both;
text-align: left;
color: black;
background-color: lightblue;
}
</style>
<body>
<div class="card">
<div class="header">
<a href="app_gogs.html"><img id="headerpic" class="img-responsive" src="images/logo.png"></a>
<p class="headertext">Gogs allow new registrations</p>
<form action="settings_gogs.php" method="post">
<input type="radio" name="allowregistrations" value="0" checked>No
<input type="radio" name="allowregistrations" value="1">Yes
<br><br>
<input type="submit" name="submitallowregistrations" value="Update" />
</form>
</div>
</div>
</body>
</html>
<?php
// Gogs settings menu
$output_filename = "app_gogs.html";
if (isset($_POST['submitallowregistrations'])) {
$confirm = htmlspecialchars($_POST['allowregistrations']);
$settings_file = fopen(".appsettings.txt", "w") or die("Unable to write to appsettings file");
fwrite($settings_file, "gogs,registration,".$confirm);
fclose($settings_file);
}
$htmlfile = fopen("$output_filename", "r") or die("Unable to open $output_filename");
echo fread($htmlfile,filesize("$output_filename"));
fclose($htmlfile);
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment