Wednesday, 30 November 2011

Open Source Php Forums

After googling for open source forums in php, Thought of finalizing with punBB
Phpbb is also nice but comlicated with highly featured, where as punbb is realy simple with less templates to be edited for customization.

Below link shows the comparison of punbb and phpbb :
http://www.forum-software.org/forum-comparator/phpbb3-vs-punbb

if u feel like installing punbb plugins u can easily find  it here :
http://punbb.informer.com/extensions/


Wednesday, 23 November 2011

Apache htaccess - Compressing JS CSS and the lot

In Apache there are modules, gzip, and deflate, these are tools for compression.
Gzip only compresses html where as deflate compresses the file that you specify.
High end community sites like www.royalchallengers.com, ihealthu.com uses this feature.

Please add this to htaccess :
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
    # file-types indicated will not be compressed
SetEnvIfNoCase Request_URI \.(?:rar|zip|pdf|swf)$ no-gzip dont-vary
    <IfModule mod_headers.c>
        Header append Vary User-Agent
    </IfModule>
</IfModule> 


Use this url to test the results http://www.gidnetwork.com/tools/gzip-test.php

Tuesday, 15 November 2011

Jquery Mobile

With the emerge of mobile technologies, many new mobile ui development frame works have arrived.
Checkout links, might be useful for mobile websites, mobile-App webviews :

Jquery UI (html 5) Framework for mobile :

Jquery Javascript Frameworks for Mobile :
 
PhoneGap :

Modernizr : a small JavaScript Library, its usage and useful links

Modernizr is a small JavaScript Library that detects the availability of native implementations for next-generation web technologies
There are several new features which are being introduced through HTML5 and CSS3 but same time many browsers do not support these news features.
Modernizr provides an easy way to detect any new feature so that you can take corresponding action. For example, if a browser does not support video feature then you would like to display a simple page.
You can create CSS rules based on the feature availability and these rules would apply automatically on the webpage if browser does not support a new featur.
You can download latest version of this utility from Modernizr Download.

Syntax:

Before you start using Modernizr, you would have to include its javascript library in your HTML page header as follows:
<script src="modernizr.min.js" type="text/javascript"></script>
As mentioned above, you can create CSS rules based on the feature availability and these rules would apply automatically on the webpage if browser does not support a new featur.
Following is the simple syntax to handle supported and non supported features:
/* In your CSS: */
.no-audio #music {
   display: none; /* Don't show Audio options */
}
.audio #music button {
   /* Style the Play and Pause buttons nicely */
}

<!-- In your HTML: -->
<div id="music">
   <audio>
      <source src="audio.ogg" />
      <source src="audio.mp3" />
   </audio>
   <button id="play">Play</button>
   <button id="pause">Pause</button>
</div>
Here it is notable that you need to prefix "no-" to every feature/property you want to handle for the browser which does not support them.
Following is the syntax to detect a particular feature through Javascript:
if (Modernizr.audio) {
     /* properties for browsers that
     support audio */
}else{
     /* properties for browsers that
     does not support audio */
}
To learn above concept - Do Online Practice using different browsers.

Features detected by Modernizr:

Following is the list of features which can be detected by Modernizr:
FeatureCSS PropertyJavaScript Check
@font-face.fontfaceModernizr.fontface
Canvas.canvasModernizr.canvas
Canvas Text.canvastextModernizr.canvastext
HTML5 Audio.audioModernizr.audio
HTML5 Audio formatsNAModernizr.audio[format]
HTML5 Video.videoModernizr.video
HTML5 Video FormatsNAModernizr.video[format]
rgba().rgbaModernizr.rgba
hsla().hslaModernizr.hsla
border-image.borderimageModernizr.borderimage
border-radius.borderradiusModernizr.borderradius
box-shadow.boxshadowModernizr.boxshadow
Multiple backgrounds.multiplebgsModernizr.multiplebgs
opacity.opacityModernizr.opacity
CSS Animations.cssanimationsModernizr.cssanimations
CSS Columns.csscolumnsModernizr.csscolumns
CSS Gradients.cssgradientsModernizr.cssgradients
CSS Reflections.cssreflectionsModernizr.cssreflections
CSS 2D Transforms.csstransformsModernizr.csstransforms
CSS 3D Transforms.csstransforms3dModernizr.csstransforms3d
CSS Transitions.csstransitionsModernizr.csstransitions
Geolocation API.geolocationModernizr.geolocation
Input TypesNAModernizr.inputtypes[type]
Input AttributesNAModernizr.input[attribute]
localStorage.localstorageModernizr.localstorage
sessionStorage.sessionstorageModernizr.sessionstorage
Web Workers.webworkersModernizr.webworkers
applicationCache.applicationcacheModernizr.applicationcache
SVG.svgModernizr.svg
SVG Clip Paths.svgclippathsModernizr.svgclippaths
SMIL.smilModernizr.smil
Web SQL Database.websqldatabaseModernizr.websqldatabase
IndexedDB.indexeddbModernizr.indexeddb
Web Sockets.websocketsModernizr.websockets
Hashchange Event.hashchangeModernizr.hashchange
History Management.historymanagementModernizr.historymanagement
Drag and Drop.draganddropModernizr.draganddrop
Cross-window Messaging.crosswindowmessagingModernizr.crosswindowmessaging
addTest() Plugin APINAModernizr.addTest(str,fn)

Wednesday, 9 November 2011

Facebook Open Graph v2 and Auth Dialog Tutorial

Facebook has recently introduced new version of opengraph and Oauto dialogs
Below links would be useful in guiding the new versions :

Open Graph :
http://developers.facebook.com/docs/opengraph/
https://developers.facebook.com/docs/beta/opengraph/tutorial/
https://developers.facebook.com/docs/beta/opengraph/opengraph-approval/

Add to timeline plugin :
https://developers.facebook.com/docs/beta/plugins/

The new activity plugin is here :
https://developers.facebook.com/docs/reference/plugins/activity2/

Auth Dialog Updated :
https://developers.facebook.com/docs/beta/authentication/

Facebook has also provided with sample apps to play around with so that we could get familiar with the open graph :
https://developers.facebook.com/docs/beta/samples/

A facebook debugger for validating meta info, its a kind of html validator :
http://developers.facebook.com/tools/debug

Thursday, 13 October 2011

crypt and md5 usage in php

MD5 Encryption :

$str = "Hello";
echo md5($str);

if (md5($str) == '8b1a9953c4611296a827abf8c47804d7')
{
echo "
Hello world!";
exit;
}

The output of the above code would be :
8b1a9953c4611296a827abf8c47804d7
Hello world!

Crypt Encryption :

$password = crypt('mypassword'); // let the salt be automatically generated

/* You should pass the entire results of crypt() as the salt for comparing a
password, to avoid problems when different hashing algorithms are used. (As
it says above, standard DES-based password hashing uses a 2-character salt,
but MD5-based hashing uses 12.) */
if (crypt($user_input, $password) == $password) {
echo "Password verified!";
}

Monday, 29 August 2011

Bookmarking Firebug lite for Safari/ipad

Setting up firebug lite on safari for ipad debugging, using bookmarking,

Checkout : 



u can get the script to bookmark here : 

 
Steps 

1.) create a bookmark with 
name => firebug lite 
address => 
javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened');
2.) Open link which you want to use firebug and open that bookmark, and firebug loads like maska :)

Wednesday, 17 August 2011

DOCTYPE and namespace !!!

A typical DOCTYPE you might see on an HTML document is the HTML 4.01 transitional DOCTYPE. The DOCTYPE for HTML 4.01 Transitional documents looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

The DOCTYPE isn't exactly an HTML tag or XHTML element. Instead it is a declaration and always appears at the very top of your documents.

A DOCTYPE is made up of the following parts:
1. !DOCTYPE
    The identifier. It indicates to the user-agent that the enclosed information will define the type of document of the page.
   
2. HTML
    The Top Element. This tells the browser what element to expect as the top-level element. For HTML and XHTML documents this element would be <html>
   
3. PUBLIC
    The Availability. The most common DOCTYPES you will use will be publicly available - "PUBLIC". But you can also specify a local DTD with the "SYSTEM" key word.
   
4. "-//W3C//DTD HTML 4.01 Transitional//EN"
    The Formal Public Identifier. This entire string is what identifies the DOCTYPE.
   
   
The FPI is made up of these parts:

-
    Registration. If there is a plus-sign (+) here, that means that the organization is registered with the ISO. A minus-sign (-) indicates that it is not registered.
   
W3C
    The Organization. This is the group that owns and maintains the DOCTYPE being used.
   
DTD
    The Type. This defines the type of DOCTYPE used.
   
HTML 4.01 Transitional
    The Human-Readable Label. This is the label that tells you what DTD is being used. It is written so that humans, rather than computers, can understand it.
   
EN
    The Language. This is the language that the DTD is written in. It is not the language of the content of the page.

-----------------------------------------------------------------------------------------
Doctypes Available in the W3C Recommendations :

HTML 4.01 Strict

This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

HTML 4.01 Transitional

This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 Frameset

This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 Strict

This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

XHTML 1.0 Transitional

This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML 1.0 Frameset

This DTD is equal to XHTML 1.0 Transitional, but allows the use of frameset content.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

XHTML 1.1

This DTD is equal to XHTML 1.0 Strict, but allows you to add modules (for example to provide ruby support for East-Asian languages).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

#########################################################################
NAMESPACE

<html xmlns="http://www.w3.org/1999/xhtml" xmlnd:og="http://ogp.me/ns" xmlns:fb="https://www.facebook.com/2008/fbml">

Wednesday, 13 July 2011

How to setup git hub for windows

Check this link out for setting github :

http://help.github.com/win-set-up-git/

configuring github on local windows machine :
final step try :  $ ssh-add ~/.ssh/id_rsa


Global setup:

Set up git
  git config --global user.name "karan"
  git config --global user.email karan.adep@gmail.com
        

Next steps:

mkdir royalchallengers_v2
  cd royalchallengers_v2
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:karanadep/royalchallengers_v2.git
  git push -u origin master
      

Existing Git Repo?

cd existing_git_repo
  git remote add origin git@github.com:karanadep/royalchallengers_v2.git
  git push -u origin master
      

Importing a Subversion Repo?

Click here
      

When you're done:

Continue

Monday, 11 July 2011

Password protecting a directory using htaccess file


Password Protect a Directory with .htaccess

A tutorial explaining how to retrict access to a directory on a web server using .htaccess.
Password protecting a directory can be done several ways. Many people use PHP or ASP to verify users, but if you want to protect a directory of files or images (for example), that often isn't practical. Fortunately, Apache has a built-in method for protecting directories from prying eyes, using the .htaccess file.
In order to protect your chosen directory, you will first need to create an .htaccess file. This is the file that the server will check before allowing access to anything in the same directory. That's right, the .htaccess file belongs in the directory you are protecting, and you can have one in each of as many directories as you like.
You'll need first to define a few parameters for the .htaccess file. It needs to know where to find certain information, for example a list of valid usernames and passwords. This is a sample of the few lines required in an .htaccess file to begin with, telling it where the usernames and passwords can be found, amongst other things.
AuthUserFile /full/path/to/.htpasswd AuthName "Please Log In" AuthType Basic
You've now defined a few basic parameters for Apache to manage the authorisation process. First, you've defined the location of the .htpasswd file. This is the file that contains all the usernams and encrypted passwords for your site. We'll cover adding information to this file shortly. It's extremely important that you place this file outside of the web root. You should only be able to access it by FTP, not over the web.
The AuthName parameter basically just defines the title of the password entry box when the user logs in. It's not exactly the most important part of the file, but should be defined. The AuthType tells the server what sort of processing is in use, and "Basic" is the most common and perfectly adequate for almost any purpose.
We've told apache where to find files, but we've not told it who, of those people defined in the .htpasswd file, can access the directory. For that reason, we still have another line to define.
If we want to grant access to everyone in the .htpasswd file, we can add this line ("valid-user" is like a keyword, telling apache any user will do):
require valid-user
If we want to just grant access to a single user, we can use "user" and their username instead of "valid-user":
require user dave
A normal and complete .htaccess file might look like this:
AuthUserFile /home/dave/.htpasswd AuthName "Dave's Login Area" AuthType Basic require user dave
Now we have almost everything defined, but we are still missing an .htpasswd file. Without that, the server won't know what usernames and passwords are ok.
An .htpasswd file is made up of a series of lines, one for each valid user. Each line looks like this, with a username, then colon, then encrypted password:
username:encryptedpassword
The password encryption is the same as you'll find in PHP's crypt() function. It is not reversible, so you can't find out a password from the encrypted version. (Please note that on page 2 of this article is a tool to help you generate an .htpasswd file, that will help you encrypt passwords).
A user of "dave" and password of "dave" might be added with the following line:
dave:XO5UAT7ceqPvc
Each time you run an encryption function like "crypt", you will almost certainly get a different result. This is down to something called "salt", which in the above case was "XO" (first two letters of encrypted password). Different salt will give different encrypted values, and if not explicitly specified will be randomly generated. Don't worry though, the server is quite capable of understanding all this - if you come up with a different value for the encrypted password and replace it, everything would still work fine, as long as the password was the same.
Once you've created your .htpasswd file, you need to upload it to a safe location on your server, and check you've set the .htaccess file to point to it correctly. Then, upload the .htaccess file to the directory you want to protect and you'll be all set. Simply visit the directory to check it is all working.
Credits :  

Wednesday, 6 July 2011

Best Practices in PHP

Model - Dao structure  ------>
Check out the below URL  : 
http://www.odi.ch/prog/design/php/guide.php

The DAO should only implement basic select / insert / update operations on one table.


But then,
Q1) what if we have data from different tables ?
Q2) what if i need an array of data ?
Q3) why use try ... catch ...  ?


MVC Pattern ------>
check out below url :
http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/

Monday, 4 July 2011

E-Commerce solutions for small businesses

Web based Shopping carts : 

http://bigcartel.com/

http://www.shopify.com/

http://www.bigcommerce.com/

http://www.volusion.com/

http://vendder.com/

Facebook based E-Commerce sites :

http://www.shoptab.net/

http://www.zozolo.com/

http://www.wishpond.com/retailconnect

Mobile Based Shopping carts :

http://www.mobi-cart.com


Five Big Trends in Mobile Commerce [STUDY] :  Survey for use of m commerce,


http://mashable.com/2011/06/21/mobile-commerce-trends/

StarBucks Mobile Payment : 

http://mashable.com/2011/01/18/starbucks-mobile-payments/

You can now shop express entire catalog on facebook


http://mashable.com/2011/05/03/express-facebook-shop/

Bug tracking in Php and Mysql


Debugging Server-Side PHP-code :

Tool -  1  :  firephp
link : http://www.firephp.org/

step 1) install firefox add-on
step 2) download the library  : http://www.firephp.org/HQ/Install.htm?Trigger=Install
step 3) Lookout for Documentation over here  : http://www.firephp.org/HQ/Use.html
step 4) have created a sample code, have a look at it, lookout for attachment(firephp.php)

advantage :
1.) output will be displayed in console, just like firebug

useful links :
http://sixrevisions.com/web-development/how-to-debug-php-using-firefox-with-firephp/
http://blogs.sitepoint.com/debug-php-firebug-firephp/
http://www.developertutorials.com/tutorials/php/debugging-php-with-firebug-and-firephp-365/

Tool - 2 :  x-debug
link : http://www.xdebug.org/

Installation :
step 1.) if you have wamp installed, uncomment "zend_extension = "C:\xampp\php\ext\php_xdebug.dll"" in php.ini
step 2.) Restart server and you are done,
( above would be for localhost, for remote host, check out : http://mitulmpatel.wordpress.com/2009/11/02/how-to-install-xdebug-on-wamp/ )

useful links :
http://mitulmpatel.wordpress.com/2009/11/02/how-to-install-xdebug-on-wamp/
http://wiki.netbeans.org/HowToConfigureXDebug

And if possible, please do suggest me some tools,