-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabdump.pl
64 lines (48 loc) · 1.19 KB
/
abdump.pl
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/local/bin/perl
# Path to RCategories
use AbHeader qw(:all);
use AbUtils;
use RCategories;
use Mysql;
&Init;
&AbConnect; # sets obj, dbh
$q = "select * from $ITEM_TABLE";
$sth = $dbh->prepare($q) || die("Unable to prepare $q");
$sth->execute() || die("unable to execute $q");
#foreach item in rcatdb_items
while ($ref = $sth->fetchrow_hashref('NAME_uc')) {
generate or lookup catcode
foreach field {
print "catcode:itemid:fieldname:value"
}
foreach table in types (dependent content) {
get fields
foreach field {
print "catcode:itemid:TYPE tablename:fieldname:value"
}
}
if value isurl or isfile {
add url to wg_toindex w/catcode:itemid as extra data
}
}
$sth->finish;
#index & search generated dump file + urls in wg_toindex
# Set global variables; used as sub for brevity
sub Init {
$DBNAME = 'rcats';
$DBUSER = 'rcats';
$DBPASS = 'meoow';
}
sub AbConnect {
# Use MySQL (or DBI) to connect
$obj = RCategories->new(database => $DBNAME, user => $DBUSER, pass => $DBPASS, host => 'localhost');
$dbh = $obj->{'dbh'};
if (!$obj) {
print "Error - cannot connect to database";
exit;
}
if (!$dbh) {
print "Error - cannot get database handle\n";
exit;
}
}