Updates from November, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • danielsaidi 12:53 pm on November 29, 2010 Permalink | Reply
    Tags: viewstate   

    Moving ViewState to the bottom of the page… 

    …can be good for a number of reasons.

    We chose to do so in the project that I’m currently working with, and it’s really quite straightforward to achieve. I followed the following tutorial, and was good to go in a minute or so:

    http://www.dotnetspider.com/resources/786-Move-ViewState-e-bottom-e-page.aspx

    However, I adjusted the script a bit and also moved it to our master page, since the master page is also responsible for converting HTML 5 code to plain old divs if the browser lacks support.

    We have also moved all JavaScript files as well, to ensure that nothing is delaying the page rendering. The result is a page that seems to load faster, although all loading is actually happening after the page is rendered, and that is more friendly to search robots.

     
  • danielsaidi 1:12 am on November 24, 2010 Permalink | Reply
    Tags: magic quotes   

    The horrible magic quotes in PHP 

    A little more than a year ago, I had some problems when AJAX:ing data to a PHP page. In order to be able to unpack the data, I had to use the stripslashes method, which did not seem all that intuitive. However, since it worked, I let it remain without any further considerations.

    Then, about a month ago, I published a new web site that I had developed for a friend. For that page, when I posted HTML content via AJAX, all line feeds turned into u000a strings. The problem only occured on his domain, and not on mine, and looks like this:

    Magic quotes in action - all line breaks are turned into u000a

    Magic quotes in action – all line breaks are turned into u000a

    So then, yesterday, the problem finally appeared at my domain as well. I did not understand this at all, until I chatted with a friend of mine, who just brainstormed and came up with the solution.

    Magic quotes.

    Ok, the purpose of this feature was to protect pages from injections, but it did not work all that well, so the feature is now deprecated. What it does is that is wraps everything in neat little escape slashes, which is why I had to use stripslashes.

    However, if magic quotes are disabled, stripping the slashes will instead destroy the escaped line break.

    So, I now disable magic quotes for all pages, using this in an .htaccess file:

       php_flag magic_quotes_gpc off

    Thanks Mattias – it works like a charm!

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel