Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######## load your kareha logs into redis with this script in the kareha folder (where your log file is)
- #!/usr/bin/perl
- use Redis;
- use strict;
- BEGIN { require 'config.pl'; }
- my $redis = Redis->new(sock => '/tmp/redis.sock');
- my $file = "log.txt";
- open(LOGFILE, $file) or die("nope");
- my @lines = reverse <LOGFILE>;
- foreach my $line (@lines)
- {
- chomp($line);
- my @data=split(/\s*,\s*/, $line);
- $redis->set( TITLE . ":$data[5]" => "$data[0],$data[1],$data[6]");
- }
- close $file;
- ######## make these changes to kareha
- ######import the module
- use Redis;
- ######establish redis connection
- my $redis = Redis->new(sock => '/tmp/redis.sock');
- if($md5) # if we managed to generate an md5 checksum, check for duplicate files
- {
- ######remove $log from find_md5
- my ($thread,$post)=find_md5($md5);
- if($thread)
- {
- unlink $filename; # make sure to remove the file
- make_error(sprintf S_DUPE,"$path\kareha.pl/$thread/$post");
- }
- }
- sub add_log($$$$$$$)
- {
- my ($log,$thread,$post,$password,$ip,$key,$md5,$file)=@_;
- ######add this
- $redis->set( TITLE . ":$md5" => "$thread,$post,$file");
- $password=encrypt_string(hide_password($password),"cryptpass");
- $ip=encrypt_string($ip,"ip");
- unshift @$log,"$thread,$post,$password,$ip,$key,$md5,$file";
- }
- ######switch out find_md5 with this
- sub find_md5($)
- {
- my ($md5)=@_;
- my $keycheck = $redis->keys( TITLE . ":$md5" );
- if ($keycheck)
- {
- my $getkey = $redis->get( TITLE . ":$md5" );
- my @data=split(/\s*,\s*/, $getkey);
- return ($data[0],$data[1]) if(-e $data[2]);
- }
- return ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement