112
|
3 |
0 |
0 |
eval {
do {
require DBI;
my $dbh = 'DBI'->connect('dbi:SQLite:dbname=' . $file, '', '', {'RaiseError', 1});
$cookies = $dbh->selectall_arrayref($query);
$dbh->disconnect;
1
}
} or eval {
do {
require 5.008;
die $! unless open my $fh, '-|', $HTTP::Cookies::Mozilla::SQLITE, $file, $query;
$cookies = [map({[split(/\|/, $_, 0)];} readline $fh)];
1
}
} |
274
|
1 |
0 |
0 |
eval {
do {
require DBI;
my $dbh = 'DBI'->connect('dbi:SQLite:dbname=' . $file, '', '', {'RaiseError', 1, 'AutoCommit', 0});
$dbh->do('DROP TABLE IF EXISTS moz_cookies;');
$dbh->do('CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER);');
{
my $pholds = join(', ', ('?') x @fnames);
my $sth = $dbh->prepare("INSERT INTO moz_cookies($fnames) VALUES ($pholds)");
$self->scan($self->_scansub_maker(sub {
my($domain, $path, $key, $val, $secure, $expires) = @_;
$secure = $secure ? 1 : 0;
$sth->execute($domain, $path, $key, $val, $secure, $expires);
}
));
$sth->finish;
};
$dbh->commit;
$dbh->disconnect;
1
}
} or eval {
do {
die $! unless open my $fh, '|-', $HTTP::Cookies::Mozilla::SQLITE, $file;
print {$fh;} "\nBEGIN TRANSACTION;\n\nDROP TABLE IF EXISTS moz_cookies;\nCREATE TABLE moz_cookies\n (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT,\n path TEXT,expiry INTEGER, lastAccessed INTEGER,\n isSecure INTEGER, isHttpOnly INTEGER);\n\n";
$self->scan($self->_scansub_maker(sub {
my($domain, $path, $key, $val, $secure, $expires) = @_;
$secure = $secure ? 1 : 0;
my $values = join(', ', map({my $hex = unpack('H*', $_);
"X'${hex}'";} $domain, $path, $key, $val, $secure, $expires));
print {$fh;} "INSERT INTO moz_cookies( $fnames ) VALUES ( $values );\n";
}
));
print {$fh;} "\nUPDATE moz_cookies SET lastAccessed = id;\nEND TRANSACTION;\n\n";
1
}
} |