Getting started development on android with eclipse

Android Image

This post is just a quickie on how to get yourself started with Android development and the step-by-step guide about the basic tools needed to do so. Now there are many ways using which you can start development. But the simplest way is using Eclipse IDE. So, here’s a simple guide for a complete beginner.

For a complete beginner, it would be best to get eclipse and android sdk using this full-felged suite (eclipse, ADT, SDK Manager combined all together), in which case the first four steps of this tutorial can be skipped. Or download each tool separately, and continue with the steps given below.

Step 1. Download Eclipse

Although there are a lot of IDE’s that can be used to start development but eclipse is the most recommended to do so. You can download Eclipse using this link.

Continue reading “Getting started development on android with eclipse”

Php file_exists, does it really exists?

“Php functions are sometimes so confusing”, I don’t know how true that is, but I just found it to be true in this very case. Php’s file_exists, a function that seems like it is made to check if a file exists or not, is the one I encountered recently.

So I created this little test for this very purpose. I created an images folder with 2 files and 1 folder. Next I used file_exists function in 3 conditions with respective relative paths, to see which of those existed.

$file1="images/two.jpeg";
$file2="images/icon/one.jpg";
$file3="images/small/icon/";

if (file_exists($file1))
    echo "File one exists";

if (file_exists($file2))
    echo "File two exists";

if (file_exists($file3))
    echo "File three exists";

To my surprise all the conditions returned true.

File one exists
File two exists
File three exists

file_exists — Checks whether a file or directory exists.

According to php.net manual:

Irrespective of existence of file, file_exists function return true even if the path provided exists, which is in accordance with php manual’s definition, it’s just the name that is confusing. So, its better to use is_file() together with file_exists() if the objective is to check if the file really exists or is_dir()to check for directory.

Cheers!

Creating a zip file using php

Creating a zip file in php is as easy as creating them on your desktop using some zipping software. Php comes with inbuilt class that helps in making a zip file and provides all the functionality that you would ever need. Here is a simple function that I coded for my project. Hope it helps some peoples out there as well.

Php code:

// creates a compressed zip file
function create_zip($files = array(), $filename=array(), $destination = '',$overwrite = false) {
	//if the zip file already exists and overwrite is false, return false
	if(file_exists($destination) && !$overwrite) { return false; }

	//vars
	$valid_files = array();
	$valid_names = array();
	$i=0;

	//if files were passed in...
	if(is_array($files)) {
		//cycle through each file
		foreach($files as $file) {
			//make sure the file exists
			if(is_file($file)) {
				$valid_files[] = $file;
				if(isset($filename[$i]) && $filename[$i]!='') {
					$valid_names[]=$filename[$i];
				} else {
					$valid_names[]=$file;
				}
			}
			$i++;
		}
	}

	//if we have good files...
	if(count($valid_files)) {
		//create the archive
		$zip = new ZipArchive();
		if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
			return false;
		}

		$i=0;
		//add the files
		foreach($valid_files as $file) {
			$zip->addFile($file,$valid_names[$i]);
			$i++;
		}

		//debug
		//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;

		//close the zip -- done!
		$zip->close();

		//check to make sure the file exists
		return file_exists($destination);
	} else {
		return false;
	}
}

Usage demo:

Continue reading “Creating a zip file using php”

HACKERTEST.NET | Level 10: Hidden context

Level 10 is kind of deceiving with its first interaction and with its false clue, like the word cookie it surely points us in wrong direction. But after sometime you will surely find the right path. And it will be a lot easier with the right kind of tool.

After looking for all the cookies I could and getting nothing from them I moved on and started looking for something else. The clue was yet to be found.

Continue reading “HACKERTEST.NET | Level 10: Hidden context”

HACKTHISSITE.ORG | Javascript Mission 5: Escape!

Unescape and escape are javascript functions used to encode and decode string just to make sure they are unreadable easily, but still its not that difficult to read them.

When you check out the source code you will find that there is an encoded string ‘%69%6C%6F%76%65%6D%6F%6F‘ and the variable moo has its decoded word i.e. our answer.

Continue reading “HACKTHISSITE.ORG | Javascript Mission 5: Escape!”