I am PHP developer from Kaliningrad (Russian Federation). Here I publish my pet projects.
Sometimes I publish articles on habr.com. The source code for these articles can be found here.
Define data by IP Address
License: MIT License
first_ip,last_ip,register_id
"0.0.0.0","63.255.255.255",1
"64.0.0.0","127.255.255.255",2
"128.0.0.0","191.255.255.255",2
"192.0.0.0","255.255.255.255",2
id,name
1,"small interval"
2,"big interval"
$tmpDir = __DIR__.DIRECTORY_SEPARATOR.'tmp';
$csvDir = __DIR__.DIRECTORY_SEPARATOR.'csv';
$dbFile = __DIR__.DIRECTORY_SEPARATOR.'dat'.DIRECTORY_SEPARATOR.'iptool.dat';
$converter = new Converter($tmpDir);
$converter->setAuthor('Ivan Dudarev');
$converter->setTime(time());
$converter->setLicense('MIT');
$converter->addCSV('infoCSV',$csvDir.DIRECTORY_SEPARATOR.'info.csv',1);
$converter->addCSV('networksCSV',$csvDir.DIRECTORY_SEPARATOR.'networks.csv',1);
$info = array(
'name' => array(
'type' => 'string',
'column' => 1,
),
);
$converter->addRegister('info','infoCSV',0, $info);
$networks = array(
'info' => 2,
);
$converter->addNetworks('networksCSV', 'ip', 0, 1, $networks);
$converter->create($dbFile);
$iptool = new Iptool($dbFile);
$meta = $iptool->about();
print_r($meta)
Array
(
...
[networks] => Array
(
[count] => 2
...
)
)
Array
(
...
[networks] => Array
(
[count] => 4
...
)
)
Q | A |
---|---|
IP Tool version | 1.0.8 |
PHP version | 7.0 |
Operating system | Linux Mint |
Class Convertor to be renamed to Wizard
Codestyle to be changed
$converter->setAuthor('author');
$converter->setLicense('license');
$converter->setTime(time());
$converter->addCSV('infoCSV','/path/to/cvs/info.csv',2);
$converter->addCSV('networksCSV','/path/to/cvs/networks.csv',1);
$info = array(
'interval' => array(
'type' => 'int',
'column' => 1,
),
'caption' => array(
'type' => 'string',
'column' => 2,
'transform' => 'low',
),
'ext' => array(
'type' => 'string',
'column' => 3,
),
);
$converter->addRegister('info','infoCSV',0, $info);
$networks = array(
'info' => 2,
);
$network->create($dbFile);
$info = (new \Ddrv\Iptool\Wizard\Register('info.csv'))
->addField('interval',1,'int')
->addField('caption',2,'string')
->addField('ext',3,'string')
->setFirstRow(2)
;
$net = (new \Ddrv\Iptool\Wizard\Network('networks.csv','ip',0,1))
->setCsv('UTF-8', ',', '"','\\')
->addRegister('info', 2, $info)
->setFirstRow(1)
;
$wizard = (new Ddrv\Iptool\Wizard('/tmp'))
->setAuthor('author')
->setTime(time())
->setLicense('license')
->addNetwork($net)
->compile('iptool.test.dat')
;
Need to change the search algorithm to binary search
Update documentation for actual version (wiki and docs fordel in source).
<?php
/*
* Some code
*/
$iptool = new Iptool($dbFile);
$info = $iptool->find($ip);
print_r($info);
Array
(
[network] => Array
(
[first] => 114.12.70.0
[last] => 114.12.70.255
)
...
)
Array
(
[network] => Array
(
[first] => 114.12.70.0
[last] => 114.12.71.0
)
...
)
Q | A |
---|---|
IP Tool version | 1.0.7 |
PHP version | 7.0 |
Operating system | Linux Mint |
It is necessary to specify the time when the database was created
because saving 3 bytes is not significant, but resources are being used for parsing and unpack
#Feedback
you can leave feedback about the iptool here.
This will allow in some cases to reduce the size of the database.
call
$ip = '10.10.10.10'; // Any IP address
$iptool->find($ip);
In method find() incorrect define last block; It always last block of database
Last block must be first block of nex octet
Q | A |
---|---|
IP Tool version | 1.0.5 |
PHP version | 7.0.1 |
Operating system | Arch Linux |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.