» »

[PHP+ArchLinux]zajem podatkov o mreznih vmesnikih

[PHP+ArchLinux]zajem podatkov o mreznih vmesnikih

KernelPanic ::

Spostovani!

Imam dva sledeca problema: Prvi je dejstvo, da sem v php novinec in da ga sovrazim. :D No, salo na stran, torej, na webpage-u bi rad pokazal informacije o mreznih vmesnikih. Tu je trenutni output komande
ip addr
:
[root@pi ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b8:27:eb:3c:03:fe brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.154/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:11:6b:f0:bb:31 brd ff:ff:ff:ff:ff:ff
[root@pi ~]#
Do tu je vse ok. Naredil sem php class NetworkInterface, v katerem ni nic kompleksnega, njegova naloga je samo to, da se za vsak zaznan interface instancira objekt:
<?php

class NetworkInterface
{
    private $name;
    private $addressIp;
    private $networkMask;
    private $networkGateway;
    private $addressHardware;
    private $active;

    public function name()
    {
        return $this->name;
    }   // name

    public function setName($name)
    {
        $this->name=$name;
    }   // setName

    public function addressIp()
    {
        return $this->addressIp;
    }   // addressIp

    public function setAddressIp($addressIp)
    {
        $this->addressIp=$addressIp;
    }   // setAddressIp

    public function networkMask()
    {
        return $this->networkMask;
    }   // networkMask

    public function setNetworkMask($mask)
    {
        $this->networkMask=$mask;
    }   // setNetworkMask

    public function networkGateway()
    {
        return $this->networkGateway;
    }   // networkGateway

    public function setNetworkGateWay($gateway)
    {
        $this->networkGateway=$gateway;
    }   // setNetworkGateWay

    public function addressHardware()
    {
        return $this->addressHardware;
    }   // addressHardware

    public function setAddressHardware($addressHardware)
    {
        $this->addressHardware=$addressHardware;
    }   // setAddressHardware

    public function isActive()
    {
        return $this->active;
    }   // isActive

    public function setActive($isActive)
    {
        $this->active=$isActive;
    }   // setActive

    public function __construct()
    {
        $this->setName('');
        $this->setAddressIp('');
        $this->setNetworkMask('');
        $this->setNetworkGateWay('');
        $this->setAddressHardware('');
        $this->setActive(False);
    }   // constructor

/*
    public function __construct($name,
        $addressIp,
        $networkMask,
        $networkGateway,
        $setAddressHardware,
        $isActive)
    {
        $this->setName($name);
        $this->setAddressIp($addressIp);
        $this->setNetworkMask($networkMask);
        $this->setNetworkGateWay($networkGateway);
        $this->setAddressHardware($setAddressHardware);
        $this->setActive($isActive);
    }   // constructor
*/
}
V arrayu teh objektov bi torej rad imel podatke o mreznih vmesnikih. Kako naj izhod komande
        $result=exec('ip addr',
            $ifsText);
obdelam tako, da bom lahko vrednosti, ki jih potrebujem v objektu razreda NetworkInterface, shranil vanj?

Lp,
Marko

keworkian ::

Z regexom in loopanjem.
Obscenities in B-Flat

KernelPanic ::

keworkian je izjavil:

Z regexom in loopanjem.
Hvala za izcrpen odgovor.

BigWhale ::

php skripti bos dal root dostop do racunalnika? Nevem, ce je tole ravno najbolj pametno. Obstajajo drugi servisi, ki te stvari pocnejo bolj ucinkovito in na lepsi nacin.

technolog ::

Sej ni s tem nič narobe, dokler ne lavfa kot servis na nekem portu, ni nevarnosti.

čuhalev ::

BigWhale je izjavil:

php skripti bos dal root dostop do racunalnika?

ip addr
deluje tudi z navadnim uporabnikom

KernelPanic ::

čuhalev je izjavil:

BigWhale je izjavil:

php skripti bos dal root dostop do racunalnika?

ip addr
deluje tudi z navadnim uporabnikom
Hvala, tole je bil fin nasvet, podatke sem nato pridobil z grep ter awk!


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

router asus WL550ge, ARP tabela in WOL

Oddelek: Omrežja in internet
101728 (1582) mNeRo
»

Kako v linuxu naštimat dva IP naslova na eni mrežni karticikartici?

Oddelek: Operacijski sistemi
71267 (1176) Bakunin
»

Martian source v dmesg

Oddelek: Operacijski sistemi
5850 (818) kriko1
»

ebtables+linux+brctl+siol-tv

Oddelek: Omrežja in internet
122355 (2207) korenje_ver2
»

mac spoofing

Oddelek: Pomoč in nasveti
161638 (1374) Suhy

Več podobnih tem