Can edit files in administration
This commit is contained in:
parent
3f731fb8e0
commit
8e7d652688
@ -68,8 +68,8 @@ CREATE TABLE IF NOT EXISTS `exercice_tries` (
|
|||||||
CREATE TABLE IF NOT EXISTS `exercice_keys` (
|
CREATE TABLE IF NOT EXISTS `exercice_keys` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`id_exercice` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
`id_exercice` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
|
||||||
`format` enum('raw','md5','sha1','sha256','sha512','whirlpool') COLLATE utf8_unicode_ci NOT NULL,
|
`format` enum('raw','md5','sha1','sha256','sha512') COLLATE utf8_unicode_ci NOT NULL,
|
||||||
`value` varbinary(100) NOT NULL,
|
`value` varbinary(150) NOT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
@ -30,14 +30,23 @@ try
|
|||||||
$exercice->require = $_POST["require"];
|
$exercice->require = $_POST["require"];
|
||||||
$exercice->level = intval($_POST["level"]);
|
$exercice->level = intval($_POST["level"]);
|
||||||
|
|
||||||
$exercice->keys = array();
|
$exercice->flush_keys();
|
||||||
foreach ($_POST as $k => $key)
|
foreach ($_POST as $k => $key)
|
||||||
{
|
{
|
||||||
if (preg_match("/k([0-9]+)_value/", $k, $out) && !empty($key) && !empty($_POST["k".$out[1]."_type"]))
|
if (preg_match("/k([0-9]+)_value/", $k, $out) && !empty($key) && !empty($_POST["k".$out[1]."_type"]))
|
||||||
$exercice->add_key($_POST["k".$out[1]."_type"], $key);
|
$exercice->add_key($_POST["k".$out[1]."_type"], $key);
|
||||||
|
|
||||||
|
if (preg_match("/f([0-9]+)_name/", $k, $out) && !empty($key) && !empty($_POST["f".$out[1]."_path"]) && isset($exercice->files[$out[1]]))
|
||||||
|
{
|
||||||
|
$exercice->files[$out[1]]["path_orig"] = $_POST["f".$out[1]."_path"];
|
||||||
|
$exercice->files[$out[1]]["name"] = trim($_POST["f".$out[1]."_name"]);
|
||||||
|
$exercice->files[$out[1]]["sha1"] = $_POST["f".$out[1]."_sha1"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$exercice->update();
|
$exercice->update();
|
||||||
|
header("Location: /".implode("/", $p));
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign("ex", $exercice);
|
$template->assign("ex", $exercice);
|
||||||
|
@ -259,6 +259,9 @@ class Exercice
|
|||||||
|
|
||||||
foreach ($this->files as $k => $file)
|
foreach ($this->files as $k => $file)
|
||||||
{
|
{
|
||||||
|
if (!empty($file['path_orig']))
|
||||||
|
$path = $file['path_orig'];
|
||||||
|
else
|
||||||
$path = $file['path'];
|
$path = $file['path'];
|
||||||
$name = $file['name'];
|
$name = $file['name'];
|
||||||
$sha1 = $file['sha1'];
|
$sha1 = $file['sha1'];
|
||||||
@ -296,6 +299,15 @@ class Exercice
|
|||||||
update(true);
|
update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function flush_keys()
|
||||||
|
{
|
||||||
|
$db = new BDD();
|
||||||
|
$db->query("DELETE FROM exercice_keys WHERE id_exercice = ".intval($this->id));
|
||||||
|
$db->deconnexion();
|
||||||
|
|
||||||
|
$this->keys = array();
|
||||||
|
}
|
||||||
|
|
||||||
function add_key($format, $value)
|
function add_key($format, $value)
|
||||||
{
|
{
|
||||||
if ($format == "raw")
|
if ($format == "raw")
|
||||||
|
@ -45,7 +45,9 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="k{$k+1}_type">Type</label>
|
<label for="k{$k+1}_type">Type</label>
|
||||||
<input type="text" class="form-control" name="k{$k+1}_type" id="k{$k+1}_type" value="raw">
|
<select name="k{$k+1}_type" id="k{$k+1}_type" class="form-control">
|
||||||
|
{html_options options=$fortyp selected=$key.format}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="k{$k+1}_value">Valeur</label>
|
<label for="k{$k+1}_value">Valeur</label>
|
||||||
@ -53,18 +55,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{foreach from=$ex->files item=file key=k}
|
||||||
<div class="panel panel-warning">
|
<div class="panel panel-warning">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">Fichiers</h3>
|
<h3 class="panel-title">Fichier</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<ul>
|
<div class="form-group">
|
||||||
{foreach from=$ex->files item=file key=k}
|
<label for="f{$k}_name">Nom du affiché fichier</label>
|
||||||
<li><a href="{$file.path}">{$file.name}</a>: {$file.sha1}</li>
|
<input type="text" class="form-control" name="f{$k}_name" id="f{$k}_name" value="{$file.name|escape}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="f{$k}_path">Chemin</label> <span class="label {if !is_file($file.path)}label-danger">File not found{else}label-success">File found{/if}</span>
|
||||||
|
<input type="text" class="form-control" name="f{$k}_path" id="f{$k}_path" value="{$file.path_orig|escape}">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="f{$k}_sha1">SHA-1</label>{if is_file($file.path)} Calculated from {$file.path}: {sha1_file($file.path)}{/if}
|
||||||
|
<input type="text" class="form-control" name="f{$k}_sha1" id="f{$k}_sha1" value="{$file.sha1|escape}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-success">Modifier</button>
|
<button type="submit" class="btn btn-success">Modifier</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user