ipv4-wildcard-calculator and update github plugin

This commit is contained in:
Denny Dai 2015-07-05 15:12:42 +08:00
parent 954e096809
commit aa26e56e92
2 changed files with 47 additions and 1 deletions

View File

@ -2,6 +2,7 @@
PluginSet("find someone on Github"); PluginSet("find someone on Github");
$opts = array ('http' => array ('header' => "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",)); $opts = array ('http' => array ('header' => "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",));
if (strpos($plugin_text,"@") === 0) {$plugin_text = substr($plugin_text,1);}
if (!strpos($plugin_text,'/')) { if (!strpos($plugin_text,'/')) {
$user = file_get_contents("https://api.github.com/users/".urlencode($plugin_text).'?access_token='.PLUGIN_GITHUB_TOKEN, false, stream_context_create($opts)); $user = file_get_contents("https://api.github.com/users/".urlencode($plugin_text).'?access_token='.PLUGIN_GITHUB_TOKEN, false, stream_context_create($opts));
$starred = file_get_contents("https://api.github.com/users/".urlencode($plugin_text)."/starred".'?access_token='.PLUGIN_GITHUB_TOKEN, false, stream_context_create($opts)); $starred = file_get_contents("https://api.github.com/users/".urlencode($plugin_text)."/starred".'?access_token='.PLUGIN_GITHUB_TOKEN, false, stream_context_create($opts));
@ -11,7 +12,12 @@ if (!strpos($plugin_text,'/')) {
plugin_github_check("Name", $user['name']); plugin_github_check("Name", $user['name']);
plugin_github_check("Email", $user['email']); plugin_github_check("Email", $user['email']);
plugin_github_check("Company", $user['company']); plugin_github_check("Company", $user['company']);
plugin_github_check("Starred", count(json_decode($starred,true))); if (count(json_decode($starred,true)) == 30) {
$starred = '>30';
}else{
$starred = count(json_decode($starred,true));
}
plugin_github_check("Starred", $starred);
plugin_github_check("Repos", $user['public_repos']); plugin_github_check("Repos", $user['public_repos']);
plugin_github_check("Followers", $user['followers']); plugin_github_check("Followers", $user['followers']);
plugin_github_check("Following", $user['following']); plugin_github_check("Following", $user['following']);

40
plugins/ipcalc.php Normal file
View File

@ -0,0 +1,40 @@
<?php
PluginSet("ipv4 Calculator.");
$var = explode('/',$plugin_text);
if(filter_var($var[0], FILTER_VALIDATE_IP)){
$arr = explode('.',$var[0]);
$msg = 'Address: '.$var[0];
$Netmask_bin = str_repeat('1', $var[1]).str_repeat('0', 32-$var[1]);
$Wildcard_bin = strtr($Netmask_bin,"10","01");
$msg .= "\nNetmask: ".bindec(substr($Netmask_bin, 0, 8)).'.'.bindec(substr($Netmask_bin, 8, 8)).'.'.bindec(substr($Netmask_bin, 16, 8)).'.'.bindec(substr($Netmask_bin, 24, 8)).' or /'.$var[1];
$msg .= "\nWildcard: ".bindec(substr($Wildcard_bin, 0, 8)).'.'.bindec(substr($Wildcard_bin, 8, 8)).'.'.bindec(substr($Wildcard_bin, 16, 8)).'.'.bindec(substr($Wildcard_bin, 24, 8));
$plugin_ipcalc_address_long = ip2long($var[0]);
$plugin_ipcalc_nmask_long = ip2long(bindec(substr($Netmask_bin, 0, 8)).'.'.bindec(substr($Netmask_bin, 8, 8)).'.'.bindec(substr($Netmask_bin, 16, 8)).'.'.bindec(substr($Netmask_bin, 24, 8)));
$plugin_ipcalc_net = long2ip($plugin_ipcalc_address_long & $plugin_ipcalc_nmask_long);
$plugin_ipcalc_host_first = ((~$plugin_ipcalc_nmask_long) & $plugin_ipcalc_address_long);
$plugin_ipcalc_first = ($plugin_ipcalc_address_long ^ $plugin_ipcalc_host_first) + 1;
$plugin_ipcalc_broadcast_invert = ~$plugin_ipcalc_nmask_long;
$plugin_ipcalc_last = ($plugin_ipcalc_address_long | $plugin_ipcalc_broadcast_invert) - 1;
$plugin_ipcalc_broadcast = long2ip($plugin_ipcalc_address_long | $plugin_ipcalc_broadcast_invert);
if($plugin_ipcalc_last < 0) $plugin_ipcalc_last += 4294967296;
if($plugin_ipcalc_first < 0) $plugin_ipcalc_first += 4294967296;
$plugin_ipcalc_hosts = $plugin_ipcalc_last - $plugin_ipcalc_first;
$msg .= "\nNetwork: ".$plugin_ipcalc_net.'/'.$var[1];
$msg .= "\nBroadcast: ".$plugin_ipcalc_broadcast;
$msg .= "\nHostMin: ".long2ip($plugin_ipcalc_first);
$msg .= "\nHostMax: ".long2ip($plugin_ipcalc_last);
$msg .= "\nHosts/Net: ".($plugin_ipcalc_hosts + 1);
$BOT->msg($plugin_sendto, $msg);
}else{
$BOT->msg($plugin_sendto, "Bad IP Address.");
}