Posts

Customize & Extend PHP Codesniffer ruleset for Sonar PHP Profile

Image
Customize & Extend PHP Codesniffer ruleset for Sonar PHP Profile Sonar the tool that we are using for our code review. For PHP sonar has plugin which uses a PHP Codesniffer PEAR package to sniff code for violations. Almost all of them are predefined. If there is a requirement to add few more rules to the default ruleset, there is a way to do it with PHP_Codesniffer pear package. How to customize default ruleset of PHP_Codesniffer ruleset for Sonar profile. Following are the steps when one needs to change the predefined value for a rule and make it configuratioble settings via sonar profile page user interface. Violation in your project, BREAK statement must be indented 4 spaces from SWITCH keyword. Here the statement is indented 2 space as per it's a code done for Drupal, but the rules show that we need 4 space which avoid the drupal standards . Here it is SwitchDeclarationBreakIndent is the rule name which is having that spe...

Sonar setup with local for PHP

Hi All, Please setup sonar in local machines. first validate your code in local, whatever you are committing the code should be 100% compliance. Please follow following instructions Installation Steps :         To setup a sonar for PHP we need to have following on our machine. JDK for Window/linux. Winant for Windows or ant for linux. PHP PEAR Install XDebug Sonar 3.6.3 http://dist.sonar.codehaus.org/sonar-3.6.3.zip Sonar PHP Plugin Code Sniffers for Drupal / Moodle and it's ruleset for sonar. build.xml file for creating a ant task. JDK for Window/Linux         Download and install the latest JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html on windows machine. Or can use smb://192.168.102.226/software/Java/Windows .         After installation Right click on “My Computer” >> ...

PHP Force Download – Keep Track of What’s Going Down

Thanks to my Friend Jainesh to suggest A force-download script can give you more control over a file download than you would have providing a direct link. Using a force-download script, you can: Validate that a person is logged in Increment a counter in a text file Connect to your database and log IP information, increment a counter, and so on. The code itself is pretty basic: // grab the requested file's name $file_name = $_GET [ 'file' ] ; // make sure it's a file before doing anything! if ( is_file ( $file_name ) ) { /* Do any processing you'd like here: 1. Increment a counter 2. Do something with the DB 3. Check user permissions 4. Anything you want! */ // required for IE if ( ini_get ( 'zlib.output_compression' ) ) { ini_set ( 'zlib.output_compression' , 'Off' ) ; } // get the file mime type using the file extension switch ( strtolower ( substr ( strrchr ( $file_name , '.' ) , ...

Satya Mev Jayte..

Tera rung aisa chadh gaya Koi aur rang naa chadh sake Tera naam seene pe likha Har koi aake padh sakey Hai junoon hai junoon hai Tere ishq ka ye junoon hai Rag rag mein ishq tera daudta Yeh bawraa sa khoon hai Tune hi sikhaya sachchaiyon ka matlab Tere paas aake jaana maine zindagi ka maqsad Satyamev... satyamev... satyamev jayate Sachcha hai pyaar tera, satyamev jayate Tere noor ke dastoor mein Na ho salwatein na shikan rahe Meri koshishein toh hai bas yahin Rahein khushbooein gulshan rahe Teri zulf suljhane chala Tere aur paas aane chala Jahan koi sur na ho be-sura Woh geet main gaane chala Tera rang aisa chadh gaya Tha nasha jo aur bhi badh gaya Teri barishon ka karam hai ye Main nikhar Gaya main sanwar gaya Jaisa bhi hoon apna mujhe Mujhe ye nahin hai bolna Qaabil tere main ban sakoo Mujhe dwaar aisa kholna Saanson ki iss raftaar ko Dhadkan ke iss tyohaar ko Har jeet ko har haar ko Khud apne iss sansaar ko Badloonga main tere liye Mujhe khud ko...

The year 2038 problem : Unix Millennium Bug, Y2K38 or Y2.038K

The year 2038 problem : Unix Millennium Bug, Y2K38 or Y2.038K Hey friends, some systems which are using unix timestamp at various step may cause error after 2038. The problem affects all software and systems that stores both system time as a signed 32-bit integer. For such sytems time beyond 19 Jan 2038  will "wrap around" and be stored internally as a negative number, which will counted as a date in 1901 rather than 2038. Affect of this in PHP: php's strtotime function fails to create timestamp if date is above then year 2038 and the server stores timestamp with 32 bit signed integer. (my local packages fails to create timestamp ) Solution : There is no particular system solution have been arrived yet for this. First solution from some people is to use unsigner 32 bit integer for time stamp so it will increase the availibility of time stamp till 2106 but still after that it will not useful and may create other problems in system. same way ...

Creating nodes programmatically in Drupal (including cck and location fields)

Creating a new node in drupal is trivial, but when the node includes custom cck fields, then a few things can trip you up. To save time and energy, here’s a quick guide and some tips to make your drupal life easier. Creating a basic node: global $user; //get current logged in user $new_node = new stdClass(); $new_node->type = 'YOUR_NODE_TYPE_HERE'; $new_node->uid = $user->uid; //you can specify some other userID here if you want $new_node->name = $user->name; $new_node->title = $YOUR_NODE_TITLE; $new_node->body = $YOUR_NODE_BODY; $new_node->status = 1; // published node_save($new_node); The function node_save() does a few things behind the scene. It checks if the nid property is empty to determine if this is a new insert or an update, then calls the appropriate functions so that you would not have duplicates. Put simply, if you want to do an update, populate the nid, and leave it out otherwise. Creatnig a node with CCK fields involves ...

How to Reinstall Windows XP Without Having to Reactivate With Microsoft

To tell you the truth, I have never understood what the big deal is with product activation. The fact is that software piracy is rampant, and Microsoft is the target for a large percentage of the piracy due to their dominance in the market. They have a right to try to stop or at least control that privacy, and the product activation seems to be a fair way of ensuring that only legitimate software owners get to benefit from using it. That said, I know many users abhor the process. It may be because they have had problems activating and have had to call the toll-free number and wait to talk to a Microsoft support agent who then read them some 278-character long activation code. (OK, that’s slight exaggeration.) Or maybe they just feel that it is some sort of invasion of privacy or that Microsoft is acting as “Big Brother” and monitoring their actions. No matter the reason, there are plenty of users who would rather never go through the product activation process again. Unf...