23
July

PHP best practice

Low carb PHP: No spaghetti PHPDoc: comments are your friends Game on: Throwing, catching and handling errors Users are stupid: Parsing input and escaping output Start on the right track and clean up your own mess: Initialising and destroying variables correctly Guess the magic number: Using constants Programmers are stupid: Version control can save your life Code reuse? No thanks, I have plenty […]

23
July

How Good PHP code should be..

Structured -separate each Web page that conforms your application in the famous 3 layers of the Web: HTML, CSS and JavaScript, for content, presentation and behavior respectively. I have a short example of how do I manage that in my PHP application. index.php PHP Code: <?php include ‘lib/something_fns.php’; include ‘inc/some_file.inc’; // put in the array the css files that you want to use $css_files = array(‘reset-fonts-grids’, ‘default’); do_html_header(‘Title of your Web Page’, $css_files); do_page_header(); do_page_content(‘open’); display_some_content(); do_page_content(‘close’); […]

23
July

Create your own Custom Exceptions

Here’s a nice tip about creating your own custom Exceptions very easily by extending the standard Exception class: PHP Code: <?php class fileException extends Exception {} This is very handy when you want to do a bunch of stuff in one go and handle the exceptions centrally but not in exactly the same way. Suppose that you want to […]

23
July

Grab IP Address With a small php script

Introduction In this tutorial, I’ll be showing you how to grab someone’s IP address using PHP. Unlike most tutorials, I’ll be showing you what each part of the code means! The Simple Way This PHP code will simply print the visitor’s IP address onto the page. PHP Code: <?php print ($_SERVER[‘REMOTE_ADDR’]; //prints the IP on the page (Obviously) ?> Printing The Visitor’s IP […]

23
July

PHP HTML DOM Parser

The HTML DOM defines a standard way for accessing and manipulating HTML documents. What we are going to do is to read a document using PHP Simple HTML DOM Parser and then manipulate it according to our needs DOWNLOAD Download The script form here and extract it Now we need to create a PHP file to start using the […]

23
July

Most Frequently Used UNIX / Linux Commands (With Examples)

1. tar command examples Create a new tar archive. $ tar cvf archive_name.tar dirname/ Extract from an existing tar archive. $ tar xvf archive_name.tar View an existing tar archive. $ tar tvf archive_name.tar More tar examples: The Ultimate Tar Command Tutorial with 10 Practical Examples 2. grep command examples Search for a given string in a file (case in-sensitive search). […]

23
July

A-Z Index of the Windows CMD command line

A ADDUSERS Add or list users to/from a CSV file ADmodcmd Active Directory Bulk Modify ARP      Address Resolution Protocol ASSOC    Change file extension associations• ASSOCIAT One step file association ATTRIB   Change file attributes b BCDBOOT  Create or repair a system partition BITSADMIN Background Intelligent Transfer Service BOOTCFG  Edit Windows boot settings BROWSTAT Get domain, browser and PDC info c […]

23
July

Phishing attacks with Google Docs

Security researchers at Sophos labs found some phishing scams using Google Docs to steal Google account login details. Google Docs is the free service by Google which allow users to create online forms. These are the few scams which are hitting users inbox and asking for login credentials. In the first example, email asks users […]

17
July

The Fifth Estate

A dramatic thriller based on real events, THE FIFTH ESTATE reveals the quest to expose the deceptions and corruptions of power that turned an Internet upstart into the 21st century’s most fiercely debated organization. Triggering our age of high-stakes secrecy, explosive news leaks and the trafficking of classified information, WikiLeaks forever changed the game. Now, […]