Show pspass.pl syntax highlighted
#!/usr/bin/perl
BEGIN { use FindBin; use lib "$FindBin::Bin"; }
$| = 1; # do not buffer output on STDOUT
our $VERSION = '1.1';
use strict;
use warnings;
use util;
use LoadConfig;
use Getopt::Long;
use Data::Dumper;
use DBI;
our ($args, $conf, $db, $sth, $plr, $ident);
die usage() unless GetOptions(
'<>' => \&GetOptions_callback,
'config=s' => \$args->{config},
'username=s' => \$args->{username},
'steamid|worldid=s' => \$args->{worldid},
'playername|name=s' => \$args->{name},
'ipaddress=s' => \$args->{ipaddr},
'password=s' => \$args->{password},
);
# include some common functionality that all of the ps*.pl utilities use
do 'psinc.inc' or die $@;
# makes sure we have a steamid, user, playername or ip address
validate_ident($args);
$plr = find_player($args);
die "No matching players found!\n" unless $plr->{plrid};
print "Player \"$plr->{name}\" matched the $ident \"$args->{$ident}\". PLRID=$plr->{plrid} PFID=$plr->{plrprofileid}\n";
my $res = $db->do("UPDATE $conf->{mysql}{tableprefix}plr_profile SET `password`=MD5(" . $db->quote($args->{password}) . ") WHERE plrprofileid=$plr->{plrprofileid}");
if ($res) {
print "Password updated for \"$plr->{name}\".\n";
} else {
print STDERR "An error occured while updating password: " . $db->errstr . "\n";
}
# ------------------------------------------------------
sub usage {
my $me = 'pspass.pl';
print STDERR $_[0] if scalar @_;
print STDERR "USAGE:\n";
print STDERR "$me <identity> <password>\n";
print STDERR "$me -steamid <steamid> -password <password>\n";
print STDERR "$me -username <username> -password <password>\n";
print STDERR "$me -name <player name> -password <password>\n";
print STDERR "$me -ip <ipaddress> -password <password>\n";
print STDERR "$me -c <config> <identity> <password>\n";
return "\n";
}
sub GetOptions_callback {
my $value = shift;
$args->{args} = [] unless ref $args->{args} eq 'ARRAY';
push(@{$args->{args}}, $value);
if ($args->{worldid} or $args->{username} or $args->{name} or $args->{ipaddr}) {
$args->{password} = $value;
} else {
$args->{worldid} = $args->{username} = $args->{name} = $args->{ipaddr} = $value;
}
}
See more files for this project here