Gridlock

Gridlock is a game where you can test your speed when you control a computer mouse. There are many different rooms where you can test your skills.

You have to follow the green line with your mouse as fast as you can, when you leave the green zone you will get a message.

Are you the fastest?
When you beat your personal time the game will submit and you can see how you are doing against the rest of the world.

You can see the rankings here

Continue reading Gridlock

Get Folder or Directory size in PHP


In PHP we have an inbuilt function called filesize() to get the size of any file, but what about a directory/ folder. A folder can content many files and sub folders in it. So lets write down a simple PHP function to calculate the folder size.

<?php
function folderSize($dir){
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
  foreach($dir_array as $key=>$filename){
    if($filename!=".." && $filename!="."){
       if(is_dir($dir."/".$filename)){
          $new_foldersize = foldersize($dir."/".$filename);
          $count_size = $count_size+ $new_foldersize;
        }else if(is_file($dir."/".$filename)){
          $count_size = $count_size + filesize($dir."/".$filename);
          $count++;
        }
   }
 }
return $count_size;
}
?>

Call the function:

<?php
  $folder_name = "myFolder";
  echo folderSize($folder_name);
?>

Continue reading Get Folder or Directory size in PHP

Slot Machine


Here we have a slot machine with a MySQL database and php. My main goal was to write a slot machine script without the use of JavaScript. My conclusion: it is possible but your user will be bored within a minute. Even my daughter (6 years old) said to me that the wheels must be spinning otherwise there is no fun. So there i go, i use a a couple of javascript functions and that’s it. for the rest it’s all php.

In the future i will make more statics of what a player has done but for now this is the result.

Example:

Continue reading Slot Machine