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/wildcard.inc.php'; |
||
6 | |||
7 | array_shift($argv); |
||
8 | if (!isset($argv[0]) || (trim($argv[0])=='')) $argv[0] = '*'; |
||
9 | |||
10 | $arg = trim(implode(' ', $argv)); |
||
11 | # while ($arg = array_shift($argv)) { |
||
12 | $wildcard = trim(mywc($arg)); |
||
13 | |||
14 | $res = db_query("SELECT DISTINCT cat FROM stam_entries |
||
15 | WHERE cat LIKE '".db_real_escape_string($wildcard)."' |
||
16 | ORDER BY cat ASC"); |
||
17 | if (!$res) { |
||
18 | fwrite(STDERR, db_error()."\n"); |
||
19 | db_close(); |
||
20 | exit(1); |
||
21 | } |
||
22 | if (db_num_rows($res) == 0) { |
||
23 | fwrite(STDERR, "No categories matched to wildcard '$wildcard'\n"); |
||
24 | exit(1); |
||
25 | } |
||
26 | while ($row = db_fetch_array($res)) { |
||
27 | $cat = $row['cat']; |
||
28 | echo "$cat\n"; |
||
29 | } |
||
30 | # } |