Raya Deleva’s Web

/ Web development

HTTP status codes

The following is a list of HTTP response status codes with there standard associated phrases and short description. These status codes are specified by RFC 2616, along with additional, unstandardized status codes sometimes used on Web.
The first digit of the status code specifies one of five classes of response...... Read more »
visit: www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
category: Web development, posted date: 12.07.2006, Comment

The PNG problem in Windows Internet Explorer

For the Web, PNG really has three main advantages over GIF:

  • alpha channels (variable transparency),
  • cross-platform gamma correction (control of image brightness) and color correction
  • two-dimensional interlacing (a method of progressive display).

PNG also compresses better than GIF in almost every case (5% to 25% in typical cases).

Here is a JavaScript-based PNG fix for Internet Explorer 5.5 and 6 on Windows. The fix allows IE to properly render PNG alpha transparency.


<!--[if lt IE 7]>
<script language="JavaScript">
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters))
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style="" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src='" + img.src + "', sizingMethod='scale');"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }   
}
window.attachEvent("onload", correctPNG);
</script>
<![endif]-->

visit: homepage.ntlworld.com/bobosola/index.htm
category: Web development, posted date: 28.06.2006, Comment

PHP regular expressions tutorial

I will try to write here a little tutorial about how to write regular expressions with PHP.

Basic syntacs.
This is a list of the basic used symbols with patterns, but there are and more, see also what O'Rielly Pocket Reference says.

Special symbol: ^ . It matches any string that starts with a given pattern.
Some example here:
'^ojo' - here matches the strings, that starts with 'ojo'.
 
Special symbol: $ . It matches any string that ends with a given pattern.
Some example here:
'bojo$' - here matches the strings, that end with 'bojo'.

Special symbol: | . It matches any string that has one from two given values, it works like OR operator.
Some example here:
'hey|hi' - matches a string that has either "hey..... Read more » category: Web development, posted date: 04.06.2006, Comments [2]

Problem IMG tag, ALT attribute in FireFox

It was something that I  had never pay attention to... I do not use much the ALT attribute of IMG tag. Most of the cases I used to leave it empty. I believed that it's purpose was to give an description, tooltip ot the image. But this is wrong!

The real purpose of  "ALT" defined by the World Wide Web Consortium is:
For user agents that cannot display images, forms, or applets, this attribute specifies alternate text. The alt attribute must be specified for the IMG and AREA elements. It is optional for the INPUT and APPLET elements.

..... Read more »
visit: www.w3schools.com/tags/ref_standardattributes.asp
category: Web development, posted date: 31.05.2006, Comment

SQL Injection - a few ways to prevent it

Till today, I never take seriously what in fact is SQL injection and how SQL queries can be tampered with. Maybe and because the projects that I worked till now weren't so big and I wasn't afraid for the information in DB, because the information wasn't some kind of a secret. What about you (or I) have to work on secure new project where that matters more?

SQL injection is the name for a general class of attacks that can allow nefarious users to retrieve data, alter server settings, or even take over your server if you're not careful. SQL injection is not a SQL Server problem, but a problem with improperly written applications.

Some ways to prevent SQL Injection are:

  • perform a regular expression match - if the user input field is for example "email" you can prevent "bad symbols"  with an reg expression.
  • escaping quotes - not every input field can be verified with an expression, "company name" can hold many different symbols.
  • configure error reporting - well when one site is on the Internet, then it is good noone can see if there are some errors from queries. The problem is that when a query is wrong in some way and the error is printed the possible attacker can see names of databese tables and fields.  In PHP errors can be stopped with
    error_reporting(0);
    ini_set('display_errors', 0);
  • use stored procedures for database access - this is what I am learning right now, but I read that is secure way.
For different cases of attacks you can try, read "SQL Injection Attacks by Example". category: Web development, posted date: 22.05.2006, Comment
What is this blog about? - A blog about sharing wisdoms mostly connected with web development. I truly hope that you will find something useful here. Cheers, Raya.
» About
» Playlist (Social music experiment)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 Subscribe

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CSS Beauty A List Apart W3schools The best forum for development in Bulgarian CSS Zen Garden Photo Cult PEAR - PHP Extension and Application Repository Rapid development framework for PHP
My lovely friend Bobbyta Awesome! - Mootools Smashing Magazine