Git Product home page Git Product logo

php-iptool's Introduction

Hello world!

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.

php-iptool's People

Contributors

ddrv avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

php-iptool's Issues

Necessary to combine intervals with the same data

What steps will reproduce the problem?

file networks.csv

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

file info.csv

id,name
1,"small interval"
2,"big interval"

script of converting

$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)    

What is the expected result?

Array
(
    ...
    [networks] => Array
        (
            [count] => 2
            ...
        )
)

What do you get instead?

Array
(
    ...
    [networks] => Array
        (
            [count] => 4
            ...
        )
)

Additional info

Q A
IP Tool version 1.0.8
PHP version 7.0
Operating system Linux Mint

Incorrect index

What steps will reproduce the problem?

call

$ip = '10.10.10.10'; // Any IP address
$iptool->find($ip);

What is the expected result?

In method find() incorrect define last block; It always last block of database

What do you get instead?

Last block must be first block of nex octet

Additional info

Q A
IP Tool version 1.0.5
PHP version 7.0.1
Operating system Arch Linux

Feedback

#Feedback
you can leave feedback about the iptool here.

Error last ip address in info.network

What steps will reproduce the problem?

<?php
/*
 * Some code
 */
$iptool = new Iptool($dbFile);
$info = $iptool->find($ip);
print_r($info);

What is the expected result?

Array
(
    [network] => Array
        (
            [first] => 114.12.70.0
            [last] => 114.12.70.255
        )
    ...
)

What do you get instead?

Array
(
    [network] => Array
        (
            [first] => 114.12.70.0
            [last] => 114.12.71.0
        )
    ...
)

Additional info

Q A
IP Tool version 1.0.7
PHP version 7.0
Operating system Linux Mint

Refactoring code of Converter

Code of Converter need to refactoring

Class Convertor to be renamed to Wizard

Codestyle to be changed

As is

$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);

To be

$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')
;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.