Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | daniel-mar | 1 | #!/usr/bin/php |
2 | <?php |
||
3 | |||
4 | require_once __DIR__ . '/includes/db.inc.php'; |
||
5 | require_once __DIR__ . '/includes/src.inc.php'; |
||
6 | |||
7 | if ($argc <> 3) { |
||
8 | echo "Syntax: $argv[0] <cat> <entry>\n"; |
||
9 | exit(2); |
||
10 | } |
||
11 | |||
12 | $cat = trim($argv[1]); |
||
13 | $ent = rtrim($argv[2]); |
||
14 | |||
15 | if ($stam_cfg['simulation']) { |
||
16 | fwrite(STDERR, "============ APS SIMULATION: $cat :: $ent\n"); |
||
17 | die(); |
||
18 | } |
||
19 | |||
20 | $x = db_query("INSERT INTO stam_entries (cat, txt, src) VALUES ( |
||
21 | '".db_real_escape_string($cat)."', |
||
22 | '".db_real_escape_string($ent)."', |
||
23 | '".db_real_escape_string($src)."' |
||
24 | )"); |
||
25 | if (!$x) { |
||
26 | fwrite(STDERR, db_error()."\n"); |
||
27 | db_close(); |
||
28 | exit(1); |
||
29 | } |
||
30 | |||
31 | $id = db_insert_id(); |
||
32 | if (!$id) { |
||
33 | fwrite(STDERR, "Error: Could not insert\n"); |
||
34 | db_close(); |
||
35 | exit(1); |
||
36 | } |
||
37 | #echo green("OK! Created ID $id\n<$cat> $ent\n"); |
||
38 | echo green("OK! $id * <$cat> $ent\n"); |
||
39 | |||
40 | # --- |
||
41 | |||
42 | function green($txt) { |
||
43 | return "\033[1;32;40m".$txt."\033[0m"; |
||
44 | } |