Add sha1 feature in Exercice class
This commit is contained in:
parent
0640a261d6
commit
fffb86e971
@ -105,23 +105,26 @@ class Exercice
|
|||||||
{
|
{
|
||||||
$path = $file['path'];
|
$path = $file['path'];
|
||||||
$name = $file['name'];
|
$name = $file['name'];
|
||||||
|
$sha1 = $file['sha1'];
|
||||||
|
|
||||||
if (isset($file['id']))
|
if (isset($file['id']))
|
||||||
$fid = intval($file['id']);
|
$fid = intval($file['id']);
|
||||||
|
|
||||||
$db->escape($path);
|
$db->escape($path);
|
||||||
$db->escape($name);
|
$db->escape($name);
|
||||||
|
$db->escape($sha1);
|
||||||
|
|
||||||
if (!isset($file['id']))
|
if (!isset($file['id']))
|
||||||
{
|
{
|
||||||
$db->query("INSERT INTO exercice_files
|
$db->query("INSERT INTO exercice_files
|
||||||
VALUES (NULL, '".$id."', '".$path."', '".$name."');");
|
VALUES (NULL, '".$id."', '".$path."', '".$name."', '".$sha1."');");
|
||||||
|
|
||||||
$this->files[$k]['id'] = $db->insert_id();
|
$this->files[$k]['id'] = $db->insert_id();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->query("UPDATE exercice_files
|
$db->query("UPDATE exercice_files
|
||||||
SET `path` = '".$path."', `name` = '".$name."'
|
SET `path` = '".$path."', `name` = '".$name."', `sha1` = '".$sha1."'
|
||||||
WHERE id = ".$fid);
|
WHERE id = ".$fid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,9 +147,9 @@ class Exercice
|
|||||||
$this->keys[] = $key;
|
$this->keys[] = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_file($path, $name)
|
function add_file($path, $name, $sha1)
|
||||||
{
|
{
|
||||||
$file = ["path" => $path, "name" => $name];
|
$file = ["path" => $path, "name" => $name, "sha1" => $sha1];
|
||||||
if (isset($file))
|
if (isset($file))
|
||||||
$this->files[] = $file;
|
$this->files[] = $file;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user