Nicola Moretti – Hanicker IT Blog

Tag: php

Upload sicuri con PHP

by Nick on feb.07, 2010, under Programming, Sicurezza

Il caricamento di file su un server è una delle maggiori fonti di insicurezza per i siti web.

Il documento che riporto, scritto da Alla Bezroutchko (ingegnere della sicurezza presso Scanit e persona presente da vari anni nel mondo della sicurezza con molti bug disclosures a proprio nome), rappresenta un vero vademecum per il caricamento tramite PHP.

Link originale:

http://www.scanit.be/uploads/php-file-upload.pdf

Se non funzionante, accedi direttamente al file cliccando qui.

Personalmente, oltre ai soliti consigli, raccomando sempre di usare per i file caricati un nome casuale, associato a quello del file caricato tramite php. Quando possibile, posizionare i file fuori dalle directory accessibili (o bloccarne l’accesso diretto tramite le configurazioni di Apache) e accederne tramite php. Quando non possibile, controllare il contenuto dei file caricati, bloccare l’esecuzione di script nella cartella dedicata all’upload, verificare accuratamente le impostazioni di apache.

  • Facebook
  • Delicious
  • Twitter
  • StumbleUpon
  • Google Reader
  • Orkut
  • Google Bookmarks
  • MySpace
  • Slashdot
  • Technorati Favorites
  • Yahoo Bookmarks
  • LinkedIn
  • Blogger Post
  • Netlog
  • Tumblr
  • Digg
  • FriendFeed
  • Share/Bookmark
1 Comment :, , , more...

Coderun : IDE PHP Online

by Nick on feb.04, 2010, under Programming, Tools

All’indirizzo http://www.coderun.com/ troverete un comodissimo IDE (Integrated development environment) PHP, Javascript e C-Sharp interamente web-based. In questo modo, anche col primo pc che vi capita sottomano in vacanza, potrete lavorare con comodità. Al momento riscontro vari bug ma il software appare in costante aggiornamento.

E pensando a Google OS, il futuro forse sta un po’ anche qui.

  • Facebook
  • Delicious
  • Twitter
  • StumbleUpon
  • Google Reader
  • Orkut
  • Google Bookmarks
  • MySpace
  • Slashdot
  • Technorati Favorites
  • Yahoo Bookmarks
  • LinkedIn
  • Blogger Post
  • Netlog
  • Tumblr
  • Digg
  • FriendFeed
  • Share/Bookmark
Leave a Comment :, , more...

Formattazione Output XML con PHP

by Nick on gen.15, 2010, under Programming

Funzione molto utile per formattare il testo XML in uscita (ad esempio da DomDocument).

function formatXmlString($xml, $indentBase = 0, $indentString = ' ') {
// add marker linefeeds to aid the pretty-tokeniser (adds a linefeed between all tag-end boundaries)
$xml = preg_replace('/(>)(<)(\/*)/', "$1\n$2$3", $xml);
// now indent the tags
$token = strtok($xml, "\n");
$result = ''; // holds formatted version as it is built
$pad = ($indentBase > 0) ? $indentBase : 0; // initial indent
$matches = array(); // returns from preg_matches()
// scan each line and adjust indent based on opening/closing tags
while ($token !== false):
// test for the various tag states
// 1. open and closing tags on same line - no change
if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches)):
$indent = 0;
// 2. closing tag - outdent now
elseif (preg_match('/^<\/\w/', $token, $matches)):
$pad--;
// 3. opening tag - don't pad this one, only subsequent tags
elseif (preg_match('/^<\w[^>]*[^\/]>.*$/', $token, $matches)):
$indent = 1;
// 4. no indentation needed
else:
$indent = 0;
endif;
// pad the line with the required number of leading spaces
$line = str_pad($token, strlen($token) + $pad, $indentString, STR_PAD_LEFT);
$result .= $line . "\n"; // add to the cumulative result, with linefeed
$token = strtok("\n"); // get the next token
$pad += $indent; // update the pad size for subsequent lines
endwhile;
return $result;
}

Tratta (e modificata) da recurser.com.

http://recurser.com/articles/2007/04/05/format-xml-with-php/
  • Facebook
  • Delicious
  • Twitter
  • StumbleUpon
  • Google Reader
  • Orkut
  • Google Bookmarks
  • MySpace
  • Slashdot
  • Technorati Favorites
  • Yahoo Bookmarks
  • LinkedIn
  • Blogger Post
  • Netlog
  • Tumblr
  • Digg
  • FriendFeed
  • Share/Bookmark
Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...