Web

  toucheatout  2008-02-29 04:23  Web  

This code is designed to prevent execution of some script ('say /maintenance.php), that has to be run from a remote host or from the host itself. The snippet is to be put at the beginning of the script.


if ($_SERVER['REMOTE_ADDR'] != '1.2.3.4' || $_SERVER['REMOTE_ADDR'] != '127.0.0.1') { header('Location: /');exit(); }

Note:

  • The exit() is not necessary, it is just paranoia :)
  toucheatout  2007-02-06 16:51  Web  

Getting a PHP easter-egg

This isn't well-known usually, but PHP features easter-eggs. You can try on a php-enabled website (that has an index.php)
/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42

Which is a neat way of finding out wether a site uses php or not (see below a way of not disclosing this info)

For instance http://www.toucheatout.net/?=PHPE9568F36-D428-11d2-A769-00AA001ACF42 (should be a little dog's picture, the image is dependant on php's version)

Other strings that yield rather undocumented results :

  toucheatout  2006-09-07 12:29  Web  

The base elements

This function supposes that a tree has been created on the filesystem and contains the entire contents of the CD (or zip) to be created and given to the user. The structure is as much as possible created using the symlink() function to save the overhead of copy. The temporary directory created is preferrably using an unique identifier, for instance using uniqid() function, giving something like $nameCD = uniqid('mycd_tmp_');.

  toucheatout  2006-07-15 17:06  Web   Asynchronous transactions is what the regular web is not about. That is, communication with the server of partial information. The page is systematically and fully transmitted to the client. Next request will also be for a complete document, which is unefficient when all you want is updating a single item on the page in reaction of user action. More reactive an interface, more rational with bandwidth... That is more liberty for the developers Tadatin! Here comes AJAX... Here's a simple example on how to fill a div with the server requested date using AJAX:
  toucheatout  2006-05-19 16:17  Web  

Even if the .htaccess mechanism is to be avoided for performance reasons on heavy-duty sites (the whole ancestors directories will be checked for a .htaccess as it applies to the current directory and any other beneath). It is however an exceptionally flexible mechanism for a directory-base tuning of apache configuration options - options can be specified by designers with simple FTP access for testing purposes.

Main uses of a htaccess file

  • access control: password, file and host-based
  • redirections and URL rewriting
  • passing custom php configuration values
  • miscellaneous things as enabling CGI interpreter, MIME type, generic Options as found in httpd.conf

  toucheatout  2006-05-19 11:10  Web  

Nobody likes a page, referenced from other sites, bookmarks or search engines, become unavailable at some point. Therefore, before changing a webpage URL, it is good to use apache RedirectPermanent or RewriteCond/RewriteRule to let users that still use the obsolete reference gain access to the right content (or a replacement for the target URL).

This can be done from a htaccess if allowed in the apache configuration - and of course in apache's conf as well, usually at the VirtualHost level.

  toucheatout  2006-03-26 17:29  Web  

To ensure good impact, those more or less unseenable parameters matter (i mean their absence could be seen as a sign). They can simply be seen as accessible webdesign. Do not abuse and express clearly and honestly what you are talking about, otherwise you could get to be blacklisted and irritate those that could have used those infos.

Generic recommandations for a website

Note: The importance of keywords and other meta tags seems to be getting less and less considered, due to the heavy abuse they have been subjected to. Do not overuse them, since at best there is no real gain, and at worst they hint for a possible search-engine-spamming site. They don't hurt neither, and some older engines still rely on them.

  toucheatout  2006-03-26 17:24  Web  

Favicon generation

Simple with ImageMagick, the convert utility makes it in one simple step:

convert original.png -resize 16x16! favicon.ico

The '!' isn't mandatory if your image already is square. If it is not, this '!' prevents convert to preserve the original height/width ratio (geometry specified is interpreted as maximum size in each axis by default).

Note: You can use the php system() function to invoke convert if allowed and imagemagick configured on the webserver.

The other possibility is to edit an image with The Gimp or another image processing software that knows about this image format.

Animated gif using gimp

Create an image with the first frame, then loop over:

  1. Create a new layer
  2. copy next frame, paste it in the newly created layer
  3. Anchor what is marked "floating selection"

Finally, save as gif and select "Save as an animation". Do not forget to specify the desired delay between frames.

  toucheatout  2006-03-26 04:15  Web  

There come a basic web survival guide with the most important stuff I stumbled upon so far to create in proper (CSS) style. Some more unordered experiments with CSS, javascript and ajax and apis etc... at the labs.

Content Management Systems

While the content and design of websites get the maximum attention, medium-size websites usually don't have every page made individually. It would require too much technical knowledge for updating, enriching etc...

The most common system nowadays is a blog system. The system is constrained in such a way that only 2 elements are needed for a new page : the title and the writeup. Other content management platforms existed before the blog format and still are used (as here, this site is made using the drupal CMS). They propose integration in a multi-user by design publishing platform of tools (usually forums, blogs, news pages, link pages, "regular" pages etc...) while keeping the design template common.

While CMS is a general term, and systems that use that appellation are usually very versatile, blog platforms, forums systems (as phpBB), bulletin board systems, etc... are also all about content management.

Most famous CMS are Joomla (ex-mambo), drupal, typo3 (reputed the most potent, but a whole world in itself), and many others. opensourcecms CMS testing site proposes testing nearly all available opensource CMSes. As the site is regularly refreshed, you only have a bare bone installation. In the normal case, one has quite some work to choose, install, test and maybe tweak the theme to be used, the modules to be added, activated, coordinated, the access control and permission system, the format of the homepage, the navigational elements...

Social networking, social bookmarking

Those are all the rage in the trend of the web to become more and more participative. This is indeed nice for website makers, as they abandon any responsibility on the content, and its production. On the other hand, it makes web user feel empowered : they do not only watch what is proposed, they get to author content as well... Or participate by giving their opinion in comments on on-site blogs or qualifying websites with tags. Those tags are then made public for each user and aggregated for the front-page. Example: del.icio.us social bookmarking website user's profile.

And as trends govern, there is retrievable code that allows you to very easily display a tag cloud :

Javascript + CSS useful features

Playing with Visibility

The CSS visibility property allows the control of wether an element is visible or not. It can be used and manipulated through javascript to create dynamic menus, with the advantage of not reloading the full page when browsing through. Likewise, images or text sections can be displayed and hidden at will. State of elements (for instance selection state of form elements) can be dynamically set. Etc... This creates the opportunity to manage the user interface client-side, at reactivity and network usage benefits.
A typical javascript show/hide of my_elt_id:

 
yro.slashdot.org - Your Rights online


nytimes.com New York Times - International