Files

38 lines
1.3 KiB
PHP

<?php
require_once __DIR__.'/auth_guard.php';
require_once __DIR__.'/audit.php';
require_once "../config.php";
$catsuperior = isset($_POST['catsuperior']) ? (int)$_POST['catsuperior'] : 0;
$nombre = isset($_POST['nombre']) ? $_POST['nombre'] : '';
$url = isset($_POST['url']) ? $_POST['url'] : '';
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
$clave = isset($_POST['clave']) ? $_POST['clave'] : '';
$habilitado = isset($_POST['habilitado']) ? (int)$_POST['habilitado'] : 0;
if (isset($_POST['urlimgrecurso']) && $_POST['urlimgrecurso'] !== "") {
$urlimgrecurso = $_POST['urlimgrecurso'];
} else {
$urlimgrecurso = $CFG->wwwroot.'img/icons/211-gift.png';
}
global $link;
dbConnect();
$sql = "INSERT INTO scormpkg (idcategoria, clave, nombre, url, habilitado, descripcion, imagen) VALUES (?,?,?,?,?,?,?)";
$stmt = mysqli_prepare($link, $sql);
if ($stmt) {
mysqli_stmt_bind_param($stmt, 'isssiss', $catsuperior, $clave, $nombre, $url, $habilitado, $desc, $urlimgrecurso);
if (mysqli_stmt_execute($stmt)) {
audit_log('recurso_create', 'nombre=' . $nombre . ' cat=' . $catsuperior . ' url=' . $url);
echo "Recurso creado";
} else {
http_response_code(500);
echo "Error al crear recurso";
}
mysqli_stmt_close($stmt);
} else {
http_response_code(500);
echo "Error al preparar la consulta";
}
?>