Forum » Programiranje » [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
Lp,
Marko
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
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.
čuhalev ::
KernelPanic ::
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | router asus WL550ge, ARP tabela in WOLOddelek: Omrežja in internet | 1743 (1597) | mNeRo |
» | Kako v linuxu naštimat dva IP naslova na eni mrežni karticikartici?Oddelek: Operacijski sistemi | 1277 (1186) | Bakunin |
» | Martian source v dmesgOddelek: Operacijski sistemi | 865 (833) | kriko1 |
» | ebtables+linux+brctl+siol-tvOddelek: Omrežja in internet | 2369 (2221) | korenje_ver2 |
» | mac spoofingOddelek: Pomoč in nasveti | 1655 (1391) | Suhy |