MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //usr/share/lftp/convert-netscape-cookies
#!/usr/bin/perl
# Copyright (c) 2001,2005,2007 Alexander V. Lukyanov <lav@yars.free.net>
# See COPYING file (GNU GPL) for complete license.

# This script converts netscape-style cookies to lftp set commands.

use strict;

my $file=$ARGV[0] if defined $ARGV[0];
$file=qx{
	ls -t \$HOME/.netscape/cookies \\
	      `find \$HOME/.mozilla -name cookies.txt` | head -1
},chomp $file if !defined $file;

open COOKIES,'<',$file or die "open($file): $!";
print "# converted from $file\n";
my %cookie;
while(<COOKIES>)
{
   chomp;
   next if /^#/ or /^$/;
   s/"/\\"/g;
   s/ /%20/g;
   my ($domain,undef,$path,$secure_bool,$expires,$name,$value)=split /\t/;
   my $secure='';
   $secure=';secure' if $secure_bool eq 'TRUE';
   $domain="*$domain" if $domain =~ /^\./;
   $path='' if $path eq '/';
   $path=";path=$path" if $path ne '';
   $value="=$value" if $name ne '';
   $cookie{"$domain$path$secure"}.=" $name$value";
}
foreach(sort keys %cookie)
{
   $cookie{$_}=~s/^ //;
   print "set http:cookie/$_ \"$cookie{$_}\"\n";
}