Hi, i've changed the system() function to return a string of executed command instead of an builtin true/false. This allows to do some interesting stuff like executing external scripts in Perl/PHP etc. and get an output from them.
Grab it: https://github.com/voron00/libcod/co...c667fb9868f82a
Here is a little example:
A geolocation script written in Perl
PHP Code:
# List of modules
use strict; # strict keeps us from making stupid typos
use warnings; # helps us find problems in code
use diagnostics; # good for detailed explanations about any problems in code
use Geo::IP; # GeoIP is used for locating IP addresses
my $ip = $ARGV[0];
if (!$ip) { die("No IP-Address has been defined"); }
if ($ip =~ /^192\.168\.|^10\.|^169\.254\./) { die("Local Network"); }
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
die("Invalid IP-Address: $ip");
}
my $gi = Geo::IP->open("Geo/GeoLiteCity.dat", GEOIP_STANDARD);
my $record = $gi->record_by_addr($ip);
my $geo_ip_info;
if (!$record) { die("No location found for this IP-Address"); }
if ($record->city) {
# we know the city
if ($record->region_name) {
# and we know the region name
if ($record->city ne $record->region_name) {
# the city and region name are different, all three are relevant.
$geo_ip_info = $record->city . '^7,^2 ' . $record->region_name . ' ^7-^2 ' . $record->country_name;
}
else {
# the city and region name are the same. Use city and country.
$geo_ip_info = $record->city . '^7,^2 ' . $record->country_name;
}
}
else {
# Only two pieces we have are city and country.
$geo_ip_info = $record->city . '^7,^2 ' . $record->country_name;
}
}
elsif ($record->region_name) {
# don't know the city, but we know the region name and country. close enough.
$geo_ip_info = $record->region_name . '^7,^2 ' . $record->country_name;
}
elsif ($record->country_name) {
# We may not know much, but we know the country.
$geo_ip_info = $record->country_name;
}
elsif ($record->country_code3) {
# How about a 3 letter country code?
$geo_ip_info = $record->country_code3;
}
elsif ($record->country_code) {
# How about a 2 letter country code at least?
$geo_ip_info = $record->country_code;
}
else {
# I give up.
$geo_ip_info = "Unknown location";
}
print "$geo_ip_info\n";
Which i cruly copypasted from Nanny, this would return city (in some case not), region name, and country.
So in gsc i would run it like
PHP Code:
location = system("perl locate.pl " + self getIP());
and then iprintln the result:
Ye that's right.