bloginfo('name');

bloginfo('description');

Archives Posts

Replacing adding or adding nodes in SimpleXML

November 18th, 2008 by Blu:RayNe

You just can’t! Because you only communicate with SimpleXML by getter and setter methods. It’s possible there is another interface – anywsy i doubt it!

So, the magic of adding nodes is to convert from and to DOMDocument. The snippet below is just something stripped from sourcecode, so you get the idea how it works.

// This document is emtpy -  it just illustrates an example!
$this->xml = simple_xml_load();

// convert base document from simplexml to dom
$dom = dom_import_simplexml($xml)->ownerDocument;

// get our nodes
$newNode = dom_import_simplexml($this->character->xml);
$oldNode = $dom->getElementsByTagName(‘character’)->item(0);

// import replacement node into our working DOM and reassign it
$newNode = $dom->importNode($newNode,true);

// for example: replace the -element in our DOM
$oldNode->parentNode->replaceChild($newNode, $oldNode);

// convert it back
$this->xml = simplexml_import_dom($dom);

Damn ugly but that’s just the way it is! :(

Filed under Allgemein, PHP having No Comments »

Archives Posts

.htaccess zum Schutz gegen BND Terror-Kracken (Teil2)

November 13th, 2008 by Blu:RayNe

Nachdem gestern das BKA-Gesetz durchgewunken wurde, und uns einen Schritt näher an die Neue Weltordnung Banenrepublik DDR. 2.0 bringt, mal eine positive Nachricht: Soeben sind auf Wikileaks die IP Ranges des BND geleakt!

Endlich kann der Bürger sein virtuelles Hausrecht wieder etwas stärken. Nach der .htaccess zum BKA Terror-Bot, nun die .htaccess gegen den BND Terror-Kracken. Das hilft nur nix gegen Schäubles neue Schnüffelbehörde nach NSA Vorbild, aber seien wir wenigstens froh, dass unsere Bundeskanzlerin keine eigenen ihr unterstellten Geheimdienste á TALON & Co. hat  - oder doch?.

Alle anderen Stellen sind ja gott-sei-dank von inkompetenten Pack und Internetausdruckern besetzt. Tja, da klappt es dann doch nicht so schnell mit dem Polizeistaat ;)

# Deny access from BND Servers
# https://secure.wikileaks.org/wiki/T-Systems_BND_network_assignments%2C_13_Nov_2008

RewriteEngine on
RewriteCond %{HTTP_REFERER} bvoe [NC,OR]
RewriteCond %{HTTP_USER_AGENT} bvoe [NC,OR]
RewriteCond %{REMOTE_HOST} bvoe [NC,OR]
RewriteCond %{HTTP_REFERER} lvp [NC,OR]
RewriteCond %{HTTP_USER_AGENT} lvp [NC,OR]
RewriteCond %{REMOTE_HOST} lvp [NC]
RewriteRule ^.*$ http://www.google.de/search?hl=de&q=fema+death+camps+bush+nazi+fascist [R=301,L]

Order Allow,Deny
Deny from 195.243.248.226/32
Deny from 195.243.248.228/32
Deny from 62.156.187.234/32
Deny from 62.156.187.236/32
Deny from 62.159.60.150/32
Deny from 193.159.228.32/29
Deny from 193.159.238.168/29
Deny from 194.25.184.16/29
Deny from 194.25.42.232/29
Deny from 195.145.128.56/29
Deny from 195.145.163.64/26
Deny from 195.145.182.96/28
Deny from 195.145.182.96/28
Deny from 195.145.31.252/30
Deny from 195.145.57.176/28
Deny from 195.243.157.184/29
Deny from 195.243.248.224/29
Deny from 212.185.184.224/29
Deny from 212.185.191.128/29
Deny from 217.7.155.168/29
Deny from 217.89.74.208/28
Deny from 62.153.59.192/27
Deny from 62.153.65.32/29
Deny from 62.153.80.208/29
Deny from 62.153.87.0/28
Deny from 62.154.211.152/29
Deny from 62.154.226.64/26
Deny from 62.156.187.232/29
Deny from 62.157.136.64/27
Deny from 62.157.144.0/26
Deny from 62.157.193.128/26
Deny from 62.157.193.192/27
Deny from 62.157.194.32/29
Deny from 62.157.194.32/29
Deny from 62.159.19.208/29
Deny from 62.159.104.160/28
Deny from 62.159.209.144/29
Deny from 62.159.209.152/29
Deny from 62.159.21.152/29
Deny from 62.159.60.144/29
Deny from 62.159.63.72/29
Deny from 62.225.139.248/29
Deny from 62.225.74.128/29
Deny from 80.146.198.88/29
Deny from 62.159.104.160/28
Allow from all

How to calculate CIDR:

#!/usr/bin/perl
use Net::CIDR;
$range = shift;
print (join("n", Net::CIDR::range2cidr("$range")) . "n" );

Usage

$ ./iprange2cidr 192.168.0.0-192.168.0.255
192.168.0.0/24

Alternativ vll. ma auf diese Seite gucken:
http://www.ipaddresslocation.org/

Archives Posts

21 Laws of Programming

November 6th, 2008 by Blu:RayNe

This is credited to a text file by anonymous dated in 1998:

  1. Any given rogram, once deployed, is already obsolete.
  2. It is easier to change the specification to fit the program than vice versa.
  3. If a program is useful, it will have to be changed.
  4. If a program is useless, it will have to be documented.
  5. Only ten percent of the code in
    any given
    program will ever execute.
  6. Software expands to consume all available resources.
  7. Any non-trivial program contains at least one error.
  8. The probability of a flawless demo is inversely proportional to the number of people watching, raised to the power of the amount of money involved.
  9. Not until a program has been in production for at least six months will its most harmful error be discovered.
  10. Undetectable errors are infinite in variety, in contrast to detectable errors, which by definition are limited.
  11. The effort required to correct an error increases exponentially with time.
  12. Program complexity grows until it exceeds the capabilities of the programmer who must maintain it.
  13. Any code of your own that you haven’t looked at in months might as well have been written by someone else.
  14. Inside every small program is a large program struggling to get out.
  15. The sooner you start coding a program, the longer it will take.
  16. A carelessly planned project takes three times longer to complete than expected; a carefully planned project takes only twice as long.
  17. Adding programmers to a late project makes it later.
  18. A program is never less than 90% complete, and never more than 95% complete.
  19. If you automate a mess, you get an automated mess.
  20. Build a program that even a fool can use, and only a fool will want to use it.
  21. Users truly don’t know what they want in a program until they use it

…or how i always like to say: Programming is doing, coding is knowing. And sometimes, cryptic coding is knowing without doing or doing without knowing. But that depends on the language ;)

Filed under Allgemein having No Comments »