Pages

Tuesday, September 25, 2012

PHP: “Notice: Undefined variable” and “Notice: Undefined index”


Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globalsturned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized.

Some explanations:

Although PHP does not require variable declaration, it does recommend it in order to avoid some security vulnerabilities or bugs where one would forget to give a value to a variable that he will use later in the script. What PHP does in the case of undeclared variables is issue a very low level error, E_NOTICE, one that is not even reported by default, but the Manual advises to allow during development.

Ways to deal with the issue:

  1. Recommended: Declare your variables. Or use isset to check if they are declared before referencing them.
  2. Set a custom error handler for E_NOTICE and redirect the messages away from the standard output (maybe to a log file). set_error_handler('myHandlerForMinorErrors', E_NOTICE | E_STRICT).
  3. Disable E_NOTICE from reporting. A quick way to exclude just E_NOTICE is error_reporting( error_reporting() & ~E_NOTICE ).
  4. Suppress the error with the @ operator.
Note: It would be recommended to implement just point 1.

Wednesday, September 19, 2012

NTT DoCoMo testing out eye-controlled music interface



If you're scouting the strange, the weird and the weirder, you'll find plenty to get absorbed in over at the research facilities of NTT DoCoMo. The Japanese giant is at it once more, but this time the invention is actually somewhat down to Earth. It's mission? To create a method for easily controlling a music interface (on a PMP or cellphone) with just your eyes. By rolling one's eyes and jerking them from side to side, the outfit is hoping to have the corresponding music player change tracks and get louder / softer. If you're not exactly keen with freaking out fellow citizens on the street with completely erratic eye movements, you may also appreciate a similar technology it's working up which can detect a user's finger tapping to achieve to same goal. Of course, said technology would be halfway useless on the smash hit-packed ZVUE Journey (no way you're bypassing any of those tracks, son), but we guess you could check out your toes every now and then to keep from constantly staying at 11.

Eye-controlled Tablet



http://www.thesun-epaper.com/thu/20092012/index.html#/10
Refer to the news "eye-controlled tablet".
Answer the following questions:
a) List a number of ways of sending input signal to computer. [4M]
b) Discuss the advantages and disadvantages of eye-controlled tablet device. [4M]

Taiwan civil servants fall for sex video trap




http://www.thesun-epaper.com/thu/20092012/index.html#/1

Refer to the news headline "Taiwan civil servants fall for sex video trap". Answer the following questions:
a) What is Cyber Security? [2M]
b) Give rationale why should the government agency check the employees for their cyber security awareness? [4M]
c) Discuss whether it is ethical for the government agency to use the sex video trap as part of its internet safety check. [4M]
Stats