Kategoriarkiv: PHP

PHP Script to parse nagios.dat

Please add your own error-handling:

Udgivet i Nagios, PHP | Skriv en kommentar

Nagios / Incinga plugin for verifying ssl certificates

Udgivet i Nagios, PHP, Uncategorized | Skriv en kommentar

Parse dhcpd.leases and return all active leases

#!/usr/bin/php <? $fh=fopen(“/chroot/dhcp/var/lib/dhcp/dhcpd.leases”,”r”); while ($dat=fgets($fh)) { if (preg_match(“/lease/”,$dat)) { $active=false; $ip = preg_split(“/ /”,$dat);$ip=$ip[1]; $dat=fgets($fh); while (!preg_match(“/hardware ethernet/”,$dat)) { if (preg_match(“/binding state active/”,$dat)) { $active=true; } $dat=fgets($fh); } $mac = preg_split(“/ |;/”,$dat); $mac=$mac[4]; if ($active) { print $ip.” – “.$mac.”\n”; … Læs resten

Udgivet i Apache, Knowledge Base, Old Base, PHP | Skriv en kommentar

Renaming PHP Functions

web02:~# apt-get install php4-apd In php.ini zend_extension=/usr/lib/php4/20020429/apd.so apd.dumpdir = NULL apd.statement_tracing = 0 And then in your code: rename_function(‘mysql_query’, ‘doquery’); function mysql_query($query) { doquery($query); echo “Der var en SQL-kommando her<br>\n”; }

Udgivet i Knowledge Base, Linux, Old Base, PHP | Skriv en kommentar

Nyttige PHP-funktioner

number_format() — Format a number with grouped thousands Eksempel: <?php echo number_format(pow(256, 2), null, “,”, “.”); ?> Viser: 65.536 (Flere vil bliver tilføjet)

Udgivet i Knowledge Base, Old Base, PHP | Skriv en kommentar

Byt værdier om i et array i php

<? # Array mangeler, copyright (c) 2006 Mikkel C.M.Christensen function moveup($array,$num) { if ($num == 0) { print “Cant do that”; return $array; } else { $temp=$array[$num-1]; $array[$num-1]=$array[$num]; $array[$num]=$temp; return $array; } } function movedown($array,$num) { if ($num == sizeof($array)-1) … Læs resten

Udgivet i Knowledge Base, Old Base, PHP | Skriv en kommentar

Adding inline images to HTML Files

<? print “<img src=’data:image/gif;base64,”.base64_encode(file_get_contents(“file.gif”)).”‘>”; ?> Works in Firefox

Udgivet i Knowledge Base, Old Base, PHP, Programmering | Skriv en kommentar

Apache, php & mysql on Windows

Fetch: http://archive.apache.org/dist/httpd/binaries/win32/apache_1.3.29-win32-x86-no_src.exe doubleclick the file and follow the install: Network domain should be ‘localhost’ Server name should be ‘127.0.0.1’ Admin email should be your email. Otherwise just leave the defaults, after install your apache should be running. Fetch php windows … Læs resten

Udgivet i Apache, Knowledge Base, Networking, Old Base, PHP, SQL | Skriv en kommentar

special front page from certain IP’s in php

This is trivial I know, but I needed to store the code as I don’t use it anymore… $page = $_REQUEST[‘page’]; if ($page == ”) { /* kode for at sætte specifik forside for specifikke IP’er */ $this_ip = split(“\.”, … Læs resten

Udgivet i Knowledge Base, PHP, Programmering | Skriv en kommentar

Checking if someone is online with ICQ in PHP

<?php // *** // ICQ tjek funktion // *** function icq_test($uin) { $arr = file( “http://online.mirabilis.com/scripts/online.dll?icq=$uin&img=1”); $len = strlen($arr[1]); if ($len == 96) { return “<b><font color=\”#00FF00\”>Online</font></b>”; } elseif ($len == 83) { return “<b><font color=\”#FF4040\”>Offline</font></b>”; } elseif ($len == … Læs resten

Udgivet i Knowledge Base, Old Base, PHP, Programmering | Skriv en kommentar