Latest project: http://​www.​tech​nosec.net

April 27th, 2006

So, finally, this is my latest project:

Technosec Site Screenshot
That’s not an Amaz­ing Graphic Site as you could think. This time I wanted to make sure that every­thing on the site was extremely usable.
Yes, every­thing on that site works around the con­cept of usabil­ity.
That’s what I’ve been trying to make:

  • Easy reading: characters are not too big, neither too small. The reading should be just a pleasure
  • Information retrieving: you should be able to find what you were looking for in an extremely relative small amount of time
  • Accessibility: colour contrast, hidden menus, completely tableless layout, language changement segnalation. These are just some of the precautions I taken when I had to design the layout
  • Scalability: the layout should degrade nicely under non-common displays, like embedded devices (pda, mobile phones, ecc…)

I tried to make my best to make sure that every­thing was ok when pub­lish­ing. Of course I’m human too, if I made some mis­takes, let me know…

0 Comments, tagged with PHP, Web

Access keys: more confusion than else?

April 10th, 2006

These days I’ve been won­der­ing on an impor­tant (web) issue: does the access keys really helps the end user more than con­fus­ing it?
I used access keys in dif­fer­ent sit­u­a­tions: a company’s site, an “ama­to­r­ial” page, a very little asso­ci­a­tion and so on. Every time I used them because I felt I had to do it, but not this time. I’ve been redesign­ing a company’s site (as I said in the pre­vi­ous post) that now is pretty fin­ished, and I choose to remove the access keys. And I have at least three rea­sons to moti­vate this choice.

1. Dif­fer­ent imple­men­ta­tions for every browser
Let do an exam­ple: sup­pose we have to go to the link pointed by the access key ‘0’. Now you’re run­ning explorer on win­dows, so you have to press CTRL + ALT + 0. If you are, instead, run­ning fire­fox on win­dows, you have to press CTRL + 0. And if you run opera, you have to press ALT + 0. And wait, if you’re on linux, with fire­fox, you have to press ALT + 0. And, at least for me, it’s a bit confusing.

2. Short­cut rede­f­i­n­i­tion
What hap­pens if you define ‘F’ as an access key? Well, hap­pens that you can’t use it. Not always, at least. Because you’re redefin­ing one of the most used short­cuts: ALT + F. This means you can’t use the ‘F’ as an access key under fire­fox on linux and opera both on win­dows and on linux. And this is just an example.

3. Do you remem­ber?
When you have more than three links with an access key defined, becomes hard to know what to press every­time. If you want to know what access key you should press, then you should see what letter is next to the link (sup­pos­ing is writ­ten, as it should be). Or worst, you should pass the mouse over the link. At this point, I guess that a click is faster.

By the way I didn’t talked about dis­able users. I guess they uses the access keys, although I don’t know in what per­centual. But they’re a restricted group, and I think that if you can make an acces­si­ble menu (I should make an entire post ded­i­cated to this topic), you shouldn’t have any big problem.

0 Comments, tagged with Web

PHP, PATH_INFO and url-friendly site

April 9th, 2006

These days I had to redesign a company’s site layout, due to host­ing ser­vices upgrades. Before, they were simple static HTML pages: now, they are (not really, they are about to be…) dynamic gen­er­ated ones. I cannot use mod_rewrite since the hoster dis­abled it due to secu­rity issues (?).
So I had to look for other ways to get a URL-​friendly site. The answer came from the phpinfo(); func­tion. I looked at the gen­er­ated page if there were some para­me­ter that well fits to have a URL friendly site. So I dis­cov­ered PATH_INFO.
I’m using PHP since a long time but I never heard such a fea­ture, so I had to learn some­thing new.
We can have, in this way, a URL like this: http://​www.​site.​com/​p​a​g​e​.​p​h​p​/​s​e​c​t​i​o​n​/​s​u​b​s​e​c​t​i​o​n​/​s​u​b​s​u​b​s​e​ction that can easily become using apache .htaccess (if the hoster sup­ports it, obvi­ously) like this: http://​www.​site.​com/​p​a​g​e​/​s​e​c​t​i​o​n​/​s​u​b​s​e​c​t​i​o​n​/​s​u​b​s​u​b​s​e​ction, hence by remov­ing the .php exten­sion and by make the php page as another sub­di­rec­tory (I’ll describe how to do this later).

So let start look­ing at how PATH_INFO works.
First of all, let create a page called page.php that will handle the para­me­ter pass­ing. Now let sup­pose that we are pass­ing a URL like this: /page.php/section/subsection. We will found in PATH_INFO some­thing like this: /section/subsection. Hence, sup­pose we want to show the file named “section_subsection.php” in the pages/ direc­tory. Simply, a $array = explode('/', $_SERVER['PATH_INFO']); will give us “sec­tion” into $array[0] and “sub­sec­tion” into $array[1]. Now you just need to con­cate­nate the two array ele­ments and adding .php (or what­ever you want) exten­sion and, after check­ing the file exis­tance, you’ll have the work done.

Thats the code I used in order to achieve such effect (the code that’s in pro­duc­tion, I am still work­ing on it so it may have some error):

<?php
  require(dirname(__FILE__) . "/config.php");
  require(dirname(__FILE__) . "/functions.php");

  $exclude_list = array("img", "frontpage");

  if (!isset($_SERVER['PATH_INFO']))
    header("Location: {$_CONFIG['url']}{$_CONFIG['pager']}/home");
  else $tpath = $_SERVER['PATH_INFO'];

  $tpath = explode('/', $tpath);
  $path = $tpath[1];
  if (isset($tpath[2]))
    $subpath = $tpath[2];
  else $subpath = "";

  $exclude = FALSE;
  foreach($exclude_list as $exc)
    if ($exc == $path)
      $exclude = TRUE;

  if (!$exclude) {
    if ((count($tpath) > 3) || (!file_exists(dirname(__FILE__) . "/pages/" . $path . ".php")))
      $page = "/pages/404.php";
    else {
      // if $subpath exists, we have /path/subpath, traslated as path_subpath.php
      if ($subpath !== "")
        $page = "/pages/" . $path . "_" . $subpath . ".php";
      else $page = "/pages/$path.php";
    }

    ob_start("ob_gzhandler");
    require(dirname(__FILE__) . "/head.php");
    require(dirname(__FILE__) . "/title.php");
    require(dirname(__FILE__) . "/menu.php");
    echo "<div id="content">n";
    require(dirname(__FILE__) . $page);
    echo "</div> <!--/content -->n";
    require(dirname(__FILE__) . "/footer.php");
    ob_end_flush();
  } else {
    $fullpath = implode('/', $tpath);
    $fp = fopen(dirname(__FILE__) . $fullpath, "r");
    $contents = fread($fp, filesize(dirname(__FILE__) . $fullpath));
    echo $contents;
  }
?>

Let anal­ize it. Firstly, why do we have an $exclude_list? This is needed because with this way of URL han­dling, every file that we will request under the site path will pass from that script. So, since we want to dis­play images and other things, just take the file as they are and print them out if such path is in the exclude list.
I used a couple of $_CONFIG values (that I define in con​fig.php) to have a cen­tral­ized con­fig­u­ra­tion system. Specif­i­cally, $_CONFIG['url'] will con­tain the site’s URL, while $_CONFIG['pager'] will con­tain the file­name of the script that will handle the PATH_INFO data, in our case page.php.

Suc­ces­sively, there’s a check about the file exis­tence into the /pages direc­tory. The rest is just the use of the buffered output since I some­times use a header() call in the other pages both to redi­rect the user to some other page and to set the right error­code for a 404 page.

Of course there are some improve­ments that could be done. Prob­a­bly, the most impor­tant lim­i­ta­tion in the script now is that it has a limit of two sub­sec­tions (like /section/subsection). This limit could be expanded by doing some­thing like this: implode('_', explode('/', $tpath)); but will need more checks for consistency.

Another thing: as I said before, you could want to delete the .php suffix on the page.php. This can be done by putting this lines in the .htaccess:

<files page>
ForceType application/x-httpd-php
</files>

In this way we will force apache to call page.php if it is called as page only.

That’s all :) I have to make shorter posts, I know.

1 Comment, tagged with PHP

IBM Thinkpad R50e

April 4th, 2006

WARN­ING: long post
I bought my first laptop: an IBM ThinkPad R50e (I found only an ital­ian page for this model, sorry me, but I guess there’s a trans­la­tion some­where over the IBM’s site). It has all the things I need with­outh any esotic com­po­nent. So I started hack­ing it…
The debian’s instal­la­tion worked well (with test­ing netinstaller) and I hadn’t any prob­lem. The only think you should keep in mind when con­fig­ur­ing xorg is to use this in the video section:

Section "Device"
        Identifier      "Intel Corporation 82852/855GM Integrated Graphics Device"
        Driver          "i810"
        Option          "VBERestore" "yes"
        Option          "Clone" "true"
        Option          "MonitorLayout" "CRT,LFP"
        Option          "DevicePresence" "yes"
EndSection

In this way you’ll have the mon­i­tor port work­ing (for exam­ple if you want to con­nect the laptop to a video projector).

The first thing I wanted to make work has been the soft­ware sus­pend fea­ture (I’m not talk­ing about the ACPI sleep state, or as it is com­monly named “stand by”, but a real suspend-to-disk fea­ture).
This can be accom­plished in sev­eral ways, but usu­ally with swsusp (that’s kernel inte­grated since 2.6.12 if I recall cor­rectly) or suspend2. With a default setup it doesn’t always work; the shut­down process works well, but the resume hangs when restor­ing ACPI inter­rupts. I tried both ways, with suspend2 it never worked: when resum­ing it hangs at “copy­ing orig­i­nal kernel back”. With swsusp you have to exclude some dri­vers in order to don’t always hang. First of all, remove rtc (real time clock) sup­port. With it enabled I get crash­ing more often than I need. Then don’t use intelfb: although it should be sup­ported, the swsusp with this module loaded works one out three times. I had some crashes with­outh 3D accel­er­a­tion enabled too (but just load i915 and every­thing goes ok).

Then I tried to make some­thing cool with the thin­k­light. There’s already some­thing really cool out there (rock­light over every­thing). But I did some­thing cooler: every key I press makes the thin­k­light blink. That’s not useful, nor mind­sane, but def­i­nitely geek. That’s done through a kernel patch over the key­board driver. As soon as I finish to do some checks I’ll pub­lish the patch here.

About the wire­less card: I can’t get it in mon­i­tor mode by using vanilla kernel sources. If you want mon­i­tor mode, use ipw2200 and ieee80211 from sf.net (http://​www.​ieee80211.sf.net and http://​www.​ipw2200.sf.net) but they’re not so stable. I keep losing 10-15% of wire­less pack­ets with them. There’s not mon­i­tor mode, but since I never done wardriv­ing (and I don’t plan to make it), I think it’s good for me.

And if you want to make some­thing cool to show to the friends, then install fluxbox and 3ddesktop and bind /usr/bin/3ddesk to some key: that’s what will bring your friends to linux.

0 Comments, tagged with Linux

Microblogging

  • Funny thing: yesterday night I had an idea about a good blog post I could make. But now I completely forgot what that idea was about. 13 hours ago #
  • I think pownce has a little issue with caching since if I delete a message and I write a new one, it doesn't appear in my homepage. Nov 16, 6:34pm #
  • I didn't know that something like [(x,y) for x in range(10) for y in range(x)] was possible in Python. Nov 16, 3:45pm #
  • I'm about to go to the local LUG dinner: pizza for everyone. Nov 14, 9:15pm #
  • Lately I've been very interested in fast data structures with minimum memory usage. Just surprised to find out that list comprehension in Python are sometimes slower for large quantities of data than classic for loops. Still trying to understand why (if someone has a clue, please let me know). Nov 12, 12:44pm #
  • So wordpress was silently modifying HTTP request headers and I was getting a 400 when fetching Pownce RSS. Now everything works as expected on my blog, shame on WP. Nov 9, 3:58pm #
  • Experimenting with document language identification. Nov 6, 10:23pm #
  • So looks like I finally found an interesting topic apart from web development: information retrieval. Nov 3, 5:13pm #
  • Planning a trip to Bologna in December Nov 1, 5:24pm #
  • After today, I want to go as far as I can from Italy. Oct 29, 11:49am #

Search


« Authored by Giuliani Vito Ivan »