Edit network media folder from web interface.

This commit is contained in:
Pecusx
2017-01-12 23:10:10 +01:00
committed by GitHub
parent ae245db114
commit 285004b4c8
2 changed files with 63 additions and 6 deletions
+48 -1
View File
@@ -212,7 +212,54 @@ if (isset($msg)) {
echo "</script>\r\n";
}
} elseif ($msg == "network") {
echo "Not implemented...";
$option = $_POST['submit'];
if ($option == "confirm") {
$login = $_POST["user"];
$password = $_POST["password"];
$media_link = $_POST["media_link"];
if ($media_link == "") {
$share_string = '';
} else {
if ($login == "") {
$share_string = 'mount.cifs -o ro "'.$media_link.'" /share';
} else {
$share_string = 'mount.cifs -o user="'.$login.'",password="'.$password.'",ro "'.$media_link.'" /share';
}
}
echo $end;
echo "New network media folder configuration.\r\n";
echo "<pre>Network path: <b>".$media_link."</b>\r\n";
echo "Login: <b>".$login."</b>\r\n";
echo "Password: <b>".$password."</b>\r\n";
echo "Shell command: <b>".$share_string."</b></pre>\r\n";
echo '<form action="changeconf.php?file=network" method="post">';
echo "\r\n";
echo "<input type='hidden' name='share_string' value='".$share_string."'><br>\r\n";
echo "<button type='submit' name='submit' value='ok'>Confirm network folder config</button>";
echo "\r\n";
echo "<button type='submit' name='submit' value='no'>Cancel</button>";
echo "\r\n";
} elseif ($option == "ok") {
echo "<b>Update network folder config.</b><br>\r\n";
echo "Wait!<br>\r\n";
echo "<script>\r\n";
echo "// redirect to main after 2 seconds\r\n";
echo "window.setTimeout(function() {\r\n";
echo " window.location.href = 'index.html';\r\n";
echo "}, 2000);\r\n";
echo "</script>\r\n";
$share_string = $_POST["share_string"];
file_put_contents('/var/lib/radiod/share', $share_string);
chmod("/var/lib/radiod/share", 0755);
} elseif ($option == "no") {
echo "<b>Network folder config change canceled.</b>\r\n";
echo "<script>\r\n";
echo "// redirect to main after 2 seconds\r\n";
echo "window.setTimeout(function() {\r\n";
echo " window.location.href = 'index.html';\r\n";
echo "}, 2000);\r\n";
echo "</script>\r\n";
}
} elseif ($msg == "update") {
$confirmation = $_POST["submit"];
if ($confirmation == "yes") {
+15 -5
View File
@@ -85,12 +85,22 @@ Media network folder config
/* Folder /var/lib/radiod/ musi miec uprawnienia 755
inaczej nie da sie stad odczytac plik w nim umieszczony */
$netshare = file_get_contents( "/var/lib/radiod/share" );
echo "<input type='text' name='media' value='";
echo $netshare;
echo "' style='width: 100%'>";
preg_match('/user=\".*\",pass/', $netshare, $matches);
preg_match('/\".*\"/', $matches[0], $matches);
$share_user = substr($matches[0], 1 ,-1);
preg_match('/password=\".*\",ro/', $netshare, $matches);
preg_match('/\".*\"/', $matches[0], $matches);
$share_password = substr($matches[0], 1 ,-1);
preg_match('/ro \".*\"/', $netshare, $matches);
preg_match('/\".*\"/', $matches[0], $matches);
$share_link = substr($matches[0], 1 ,-1);
echo "<pre><b>";
echo "Network path: <input type='text' name='media_link' value='".$share_link."' style='width: 80%'><br>";
echo "Login: <input type='text' name='user' value='".$share_user."'><br>";
echo "Password: <input type='text' name='password' value='".$share_password."'></b><br>";
?>
<br><button type="submit" name="submit">Save network folder config</button>
</form>
<button type="submit" name="submit" value="confirm">Save network folder config</button>
</pre></form>
<hr>
RSS config
<form action="changeconf.php?file=rss" method="post">