<?php
require 'header.php';
$fs = $GLOBALS['filesystem'];
$base = '/';
if(isset($_GET['createfile']) && !empty($_GET['createfile']))
{
$file = $fs->deepCreateFile($_GET['createfile']);
if(isset($_GET['namealias']) && !empty($_GET['namealias']))
$file->setNameAlias($_GET['namealias']);
$fs->save();
}
if(isset($_GET['deletefile']) && !empty($_GET['deletefile']) && !preg_match('/^\/404/', $_GET['deletefile']))
{
$fs->file($_GET['deletefile'])->delete();
$fs->save();
}
if(!isset($_GET['file']) || !$fs->isFile($_GET['file']))
{
?>
<h1>mocovi Backend</h1>
<div class="boxed content">
<h1><?php echo $fs->getSourceFile();?></h1>
<?php
if(!is_writable($fs->getSourcePath()))
echo '<h5 style="color: #f00;">readonly</h5>';
/*
?>
<p><strong><?php echo $count = $fs->countChildren($base, true);?></strong> files:</p>
<?php
*/
FSHelper::getFilesystemElements('/');
?>
<!--
<h5>Keys:</h5>
<ul>
<li><a name="invisible" class="invisible">invisible</a></li>
<li><a name="redirect" class="redirect">redirect</a></li>
</ul>
-->
</div>
<div class="boxed content">
<form action="index.php" method="get">
<h4>Create new file</h4>
<p>
<label for="createfile">File Name:</label><br/>
<input type="text" name="createfile" placeholder="/file1/file2/"/>
</p>
<p>
<label for="createfile">Menu Name:</label><br/>
<input type="text" name="namealias" placeholder="menu name"/><br/>
<input type="submit" value="Create"/>
</p>
</form>
<h5>Examples:</h5>
<ul style="font-family: monospace;">
<li>/home/file1</li>
<li>/file1/file2/file3</li>
<li>/dies_ist_ein_langer_dateiname123</li>
</ul>
</div>
<?php
}
else
{
$GLOBALS['page'] = isset($_GET['file']) ? $_GET['file'] : $GLOBALS['defaultpage'];
$GLOBALS['media'] = $GLOBALS['filesystem']->getDefaultMedia();
$GLOBALS['path'] = sprintf($GLOBALS['pathformat'], $GLOBALS['basepath'].'/..', $GLOBALS['linkprefix'], rtrim($GLOBALS['page'], '/'), $GLOBALS['media']);
require_once('content.php');
}
require_once('footer.php');