-
Notifications
You must be signed in to change notification settings - Fork 0
/
rom.php
32 lines (22 loc) · 924 Bytes
/
rom.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
<?php
$db = sqlite_open("nes.db", 0666);
if(!is_resource($db)) return false;
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
$exists = sqlite_single_query($db, "select * from sqlite_master where type='table' and name='rom'");
if($exists == null){
sqlite_exec($db, "create table 'rom' ( 'id' integer primary key, ".
"'hash' vachar(255) not null, 'name' varchar , 'comment' varchar );");
}
$hash = "null";
if(isset( $_GET["hash"])) $hash = "'".$_GET["hash"]."'";
$id = sqlite_single_query($db, "select id from rom where hash=".$hash.";");
if($id == null){
sqlite_exec($db, "insert into rom (hash) values (".$hash.");");
}
$query = sqlite_query($db, "select id, hash, name from rom where hash=".$hash.";", true);
$row = sqlite_fetch_object($query);
#$result = array('id'=>$id, 'name=>$name);
echo json_encode($row);
sqlite_close($db);
?>