-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_weights.php
29 lines (24 loc) · 957 Bytes
/
get_weights.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include('functions.php');
if(!array_key_exists("id", $_GET)) {
print "No id given.";
exit(1);
}
$model_id = $_GET["id"];
$model_is_public = model_is_public($model_id);
$user_id = get_user_id_from_session_id($_COOKIE["session_id"]);
$user_is_admin = is_admin() ? 1 : 0;
$can_edit_model = can_edit_model($model_id);
if(!($model_is_public || $can_edit_model)) {
if(!$model_is_public && $can_edit_model) {
print "Model is not public, but you can edit it. So you are allowed to see it.";
} else if ($model_is_public && !$can_edit_model) {
print "Model is public, but you cannot edit it";
} else if (!$model_is_public && !$can_edit_model) {
print "Model is not public, you cannot edit it";
}
exit(2);
}
$query = "select model_weights from model where id = ".esc($model_id)." and ((is_public = true and reviewed = true) or user_id = ".esc($user_id).") or $user_is_admin";
print get_single_value_from_query($query);
?>