-
Notifications
You must be signed in to change notification settings - Fork 1
/
load.php
38 lines (31 loc) · 959 Bytes
/
load.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
30
31
32
33
34
35
36
37
38
<?php
include "db.php";
function Load( $category ) {
global $db;
$data = "[";
$rows = $db->Load( $category );
foreach ( $rows as $row ) {
$id = $row[ 'id' ];
$question = trim( str_replace( '"', '\\"', $row[ 'question' ] ) );
$answer = trim( str_replace( '"', '\\"', $row[ 'answer' ] ) );
$level = $row[ 'level' ];
$rank = $row[ 'rank' ];
$toggle = $row[ 'toggle' ];
$similar = $row[ 'similar' ];
if ( $level != NULL ) {
// limit changing preset level (rank) from learned level by 1
if ( $level > $rank )
$rank++;
else if ( $level < $rank )
$rank--;
}
$data .= "{ \"id\": $id, \"rank\": $rank, \"question\": \"$question\", \"answer\": \"$answer\", \"toggle\": $toggle, \"level\": \"$level\", \"similar\": \"$similar\", \"answered\": \"false\" },";
}
$data .= "{}]";
echo $data;
}
$server_ip = $_SERVER['REMOTE_ADDR'];
if( isset( $_GET['category'] ) ) {
Load( $_GET['category'] );
}
?>