sabato 2 luglio 2011

GOOGLE favicon + YQL favicon

http://www.google.com/s2/favicons?domain=www.overgrid.com

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D"http://bbc.co.uk/"and%20xpath%3D"/html/head/link[@rel%3D'icon']%20|%20/html/head/link[@rel%3D'ICON']%20|%20/html/head/link[@rel%3D'shortcut%20icon']%20|%20/html/head/link[@rel%3D'SHORTCUT%20ICON']"&format=json&callback=grab
 
WORDPRESS CODE 
if (!empty($comment->comment_author_url)) {$url = preg_replace('/^http:\/\//', '', $comment->comment_author_url); if ($url != "") {   $imgurl = "http://www.google.com/s2/favicons?domain=" . $url;    echo '<img src="' . $imgurl . '" width="16" height="16" />';   }} 
 
ALTRE OPZIONI 







lunedì 30 maggio 2011

sabato 30 aprile 2011

AVOID INJECTION

////////////////////////////////////////////////// 
//////////////////////////////////////////////////
MYSQL QUERY CLEAN
//////////////////////////////////////////////////
function cleanQuery($string)
{
  if(get_magic_quotes_gpc())  // prevents duplicate backslashes
  {
    $string = stripslashes($string);
  }
  if (phpversion() >= '4.3.0')
  {
    $string = mysql_real_escape_string($string);
  }
  else
  {
    $string = mysql_escape_string($string);
  }
  return $string;
}

// if you are using form data, use the function like this:
if (isset($_POST['itemID'])) $itemID = cleanQuery($_POST['itemID']);

// you can also filter the data as part of your query:
SELECT * FROM items WHERE itemID = '".  cleanQuery($itemID)."' "
 
 
 
Or, preferably, mysql_real_escape_string(). mysql_escape_string() is deprecated, and should no longer be used.
 
 
////////////////////////////////////////////////// 
//////////////////////////////////////////////////
 
EVITARE SITUAZIONI DI GET DOVE SI SCEGLIE UNA PAGINA INCLUDE
 
  $whitelist = array('home', 'page');

  if (in_array($_GET['page'], $whitelist)) {
        include($_GET['page'].'.php');
  } else {
        include('home.php');
  }
 
//////////////////////////////////////////////////
//////////////////////////////////////////////////