* An editor for text files in the music box administration interface. */ $config = (require 'config.php'); require_once 'utilities.php'; $filesPath = isset($_GET['path']) ? $_GET['path'] : $_POST['path']; checkPathSanity($config['usbPath'] . '/' . $filesPath, $config) || die('Insane path!'); $rawFile = isset($_GET['file']) ? $_GET['file'] : $_POST['file']; if (isset($_POST['relative'])) { $rawFile = $filesPath . '/' . $rawFile; } $file = $config['usbPath'] . '/' . $rawFile; $basename = basename($file); if (!preg_match('/^[a-zA-Z0-9.]+$/', $basename) || in_array($basename, array('', '.', '..'))) { die('Insane filename!'); } checkPathSanity(dirname($file), $config) || die('Insane file path!'); if (file_exists($file) && !is_file($file)) { die('Insane file type!'); } // Are we writing the contents? if (isset($_POST['contents'])) { file_put_contents($file, $_POST['contents']); header('Location: index.php?path=' . urlencode($_POST['path']) . '#fileManagement'); exit; } ?> <html lang="en"> <head> <title>Music Box: Editing <?php echo htmlspecialchars(basename($file)); ?>
<?php /** * index.php * Copyright (c) 2015 by Alec Smecher * See LICENSE. * * The homepage for the music box administration tool. */ $config = (require 'config.php'); require_once 'utilities.php'; $filesPath = isset($_GET['path']) ? $_GET['path'] : '/'; checkPathSanity($config['usbPath'] . '/' . $filesPath, $config) || die('Insane path!'); ?> <html lang="en"> <head> <title>Music Box</title> <!-- meta http-equiv="refresh" content="5" --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" integrity="sha384-aUGj/X2zp5rLCbBxumKTCw2Z50WgIr1vs/PFN4praOTvYXWlVyh2UtNUU0KAUhAX" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script> </head> <body> <div class="jumbotron"> <div class="container"> <h1>Music Box</h1> <p>Welcome to Music Box administration. You can use this tool to control the actions performed by swiping RFID tags past the reader, and to upload music to the music box.</p> <p><a class="btn btn-primary btn-lg" href="http://cassettepunk.com/small-projects/music-box/" role="button">More information »</a></p>
<?php /** * mkdir.php * Copyright (c) 2015 by Alec Smecher * See LICENSE. * * A script to create a new directory in the music box. */ require 'utilities.php'; $config = (require 'config.php'); $path = $config['usbPath'] . '/' . $_POST['path']; checkPathSanity($path, $config) || die('Insane path!'); if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['name'])) { die('Insane pathname!'); } mkdir($path . '/' . $_POST['name']); header('Location: index.php?path=' . urlencode($_POST['path']) . '#fileManagement');