Archive for the ‘1st PHP Web’ Category

Top BookMarking Sites

Save your important links online with top bookmarking sites……

1 | twitter
2 | digg.com
3 | Yahoo! Buzz
4 | tweetmeme.com
5 | StumbleUpon.com
6 | reddit.com
7 | Technorati.com
8 | del.icio.us
9 | kaboodle.com
10 | mixx.com
11 | Propeller.com
12 | newsvine.com
13 | Fark.com
14 | Slashdot.org
15 | twine.com
16 | clipmarks.com
17 | dzone.com
18 | faves.com
19 | blinklist.com
20 | diigo.com

Wildcard DNS – subdomain profile

A wildcard DNS record is a record in a DNS zone that will match requests for non-existent domain names. A wildcard DNS record is specified by  “*” as the left most label of a domain name, e.g. *.example.com.

DNS zone Entry

example.com. 86400 IN SOA example.com. hostmaster.example.com.
IN NS ns1.example.com.
IN NS ns2.example.com.
IN MX 10      mail.example.com.
IN A 192.168.1.1
mail A 192.168.1.1
ns1 A 192.168.1.1
ns2 A 10.0.0.2
*.example.com. A 192.168.1.1

.htaccess file:
<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.com
RewriteRule ^$ profile.php?uid=%1

</IfModule>

Now if you want sandeepverma.example.com it will redirect to profile.php with uid=sandeepverma

solution: ffmpeg, libogg, libvorbis, freetype, gcc, faad2, faac

These are the basic tools/libs for video encoding:

sudo yum -y install \
SDL* glew glew-devel libmad-devel tre tre-devel \
libogg libogg-devel libvorbis libvorbis-devel \
boost boost-devel bzip2-devel bzip2-libs fribidi* \
lzo lzo-devel mysql-libs mysql-devel jasper jasper-devel \
faac faac-devel enca enca-devel hal hal-devel hal-libs \
cmake gperf nasm libXmu-devel fontconfig-devel \
freetype-devel libXinerama-devel pcre-devel gcc-c++ \
sqlite-devel curl-devel libsamplerate-devel libcdio-devel \
pulseaudio-libs-devel avahi-devel ffmpeg-devel libmad-devel \
a52dec-devel libdca faad2-devel libmpeg2-devel libass-devel \
libvorbis-devel libogg-devel libmpcdec-devel flac-devel \
wavpack-devel python-devel subversion

Regular Expressions (REX)

‘#<title>(.*?)</title>#’
‘|<title>([^<]*?)</title>|is’
‘#<body[^>]*>(.*)</body>#siU’
‘#(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$#i’
‘#\.swf$#i’
‘/xcf|odg|gif|jpg|png|bmp/i’
‘/{([A-Za-z\-_]+)}/’
‘/<a[^>]+href=”([^"]*)”[^>]*>([^<]*)<\/a>/ui’
‘/; (120×160|240×280|240×320|320×320)\)/’

‘/opera/i’
‘/<category>(.+?)<\/category>/is’
“#href=\”(.*?)\”#s”
‘|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i’
“/youtube\.com\/watch/i”
“/username=\”([^\"]+)\”/i”
‘/^[a-zA-Z0-9]+$/’
“‘<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>’i”

“‘<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))’Usi”

‘/(\b)GLOBALS|_REQUEST|_SERVER|_ENV|_COOKIE|_GET|_POST|_FILES|_SESSION(\b)/i’
‘/<input type\=”hidden” name\=”([^"]+)”.*?value\=”([^"]*)”[^>]*>/si’
‘#[?&](p|page_id|attachment_id)=(\d+)#’
‘/<!–more(.*?)?–>/’

Protect file uploads via PHP

Check server-side MIME type of uploaded files

The PHP form variable $_FILES['file']['type'] does not return correct mime type, so we have to use some php functions like…….
> finfo_file()
> getimagesize()
> exif_imagetype()


if(version_compare(substr(PHP_VERSION,0,1),5) == -1)
{
$san	= finfo_open(FILEINFO_MIME);
$mime	= finfo_file($san,$FileName);
$tmpvar = explode(";", $mime);
finfo_close($san);
if($mime == "image/jpeg")
{
echo "this is jpeg";
}
else
{
echo "this is not jpeg";
}
}

One can use getID3 [http://getid3.sourceforge.net/] classes to get mime type other than images….

Don’t upload to a web accessible directory

Protect your directory to execute perticular file type by putting a .htacces file in directory

AddType text/plain .php .js .cgi

more help here:

http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html

Speed up FireFox

In your address bar goto about:config

Quote:
[Search for the string]
network.http.pipelining
double click and change the value to true

[Search for the string]
network.http.pipelining.maxrequests
double click and change the value to 34

[Search for the string]
browser.turbo.enabled
double click and change the value to true

Then restart your browser, and see the difference!

Check Mail Online the Easy Way

Today, eXo2.net and e-Mol continue to innovate, with new features such as Palm synchronization and secure instant messaging. For over six years, tens of thousands of users and organizations from all over the world have trusted e-Mol to fulfill their e-mail and information needs.

http://e-mol.com/

A free, secure and anonymous web-based email retrieval application. Pick up your email from almost any POP3 or IMAP4 email server. No registration is required to access or use the application.

http://www.mail2web.com/

PHPLiveX – An Open Source PHP / AJAX Library And Framework

PHPLiveX is a lightweight php-javascript class library that helps you integrate AJAX to your php applications. Without a page is loaded again, you may call your php functions in the same page, submit your form to an url and send a request to another page with any type of data.

PHPLiveX is an open source project developed under GNU Lesser General Public License (LGPL).

  1. <?PHP
  2. include(“PHPLiveX.php”);
  3. //Magic here
  4. // Your PHP Function
  5. function generateRandomCode($length){
  6. sleep(1); // Function is slowed to show you the process exactly.
  7. $chars = array(“1″,“2″,“3″,“4″,“5″,“6″,“a”,“b”,“c”,“d”,“e”,“f”);
  8. $code = array_rand(array_flip($chars), $length);
  9. return implode($code);
  10. }
  11. // Necessary PHPLiveX Codes
  12. $ajax = new PHPLiveX(array(“generateRandomCode”));
  13. $ajax->Run(); // Must be called inside the ’html’ tags.
  14. ?>

  1. <!– Inside the html –>
  2. <input type=“button” value=“Generate Random Code”
  3. onclick=“generateRandomCode(10, {‘target’:'rcode’,'preloader’:'pr’});”>
  4. <img id=“pr” src=“images/loading.gif” style=“visibility:hidden;”>
  5. <span id=“rcode”></span>

Reference: http://www.phplivex.com

Extremely useful Web Tools

PHP: http://superblog.theblogspecialist.com/2009/01/50-extremely-useful-php-tools/

CSS: http://www.smashingmagazine.com/2008/12/09/50-really-useful-css-tools/

WEB: http://www.smashingmagazine.com/2008/11/18/15-helpful-in-browser-web-development-tools/

BLOG: http://superblog.theblogspecialist.com/tag/10-blog-traffic-tips/

PHP Web Tricks/Tips

Some Web PHP Tricks/Tips :)

Database:
1. Delete all information from databse related to, if deleting user or any content from CMS.
2. Use PDO, ADO, Pear, Zend etc. library to connect to database.
3. Take regular backup for database.
4. Use better naming convension.

Folders:
1. Use better naming convension.
2. Take regular backup for folders.
3. Protect project’s folder to unauthorized access, just put index.html or use apache security.
4. Folder name are case sensitive on servers like linux.
5. Don’t use 0777 permission on any folder use 0755.

Files:
1. Use better naming convension.
2. Use better documentation for web files, apply comments for coding and indent it.
3. Make consistency in DB, Filesnames, Variables, Page design.
4. Take regular backup for files.
5. Use caching for file to make site speed more fast.
6. Create debug files .txt, .log, .html etc. (fopen() | fwrite()) for tracking logical bugs.

Images:
1. Use version number in image URL to avoid image caching. (<img src=”san.jpg?ver=123″ alt=”san” />)
2. Images should have Etags, Max Age and far future expired header for caching.
3. Use a global funtion to display images ( draw_images($src, $attr); )

Class:
1. Use better naming convension.
2. Use encryption class (md5, sha, base64 etc. with salt) for storing password and important data into database.
3. Spidering web page (Curl, Pear etc.) is used for getting content of web page.

Functions:
1. Use function or include files for multiple use of web data to make reusability, integrity and productivity.
2. Use PHP session ID, remote IP and page name on increment views/hits.
3. Make function to load CSS, JS, Links, Forms & Elements, Images, Iframes etc. on webpage. (load_css_file(), load_js_file()….)
4. Looping should be start from Left to Right…

Variables:
1. Use better naming convension.
2. Use defined variables/constants for folder names, DB table names, Files and global variables (avoid hard coding, be happy coder).

CSS:
1. Avoid inline CSS on pages because it effect the page load time & speed also it matter in W3C validation.
2. Combine multiple CSS file in a single file with cached version.
3. Avoid conflict in CSS.
4. Avoid CSS expressions.
5. Use CSS Sprite for images.

JS:
1. Avoid inline JS on pages because it effect the page load time & speed also it matter in W3C validation.
2. Combine multiple JS file in a single file with cached version.
3. Use valid syntax for browser checking in javascript.
4. Avoid duplicate JS function.

Ajax:
1. Minimize the errors in HTML closing tags etc.
2. Use proper hyrarchy for HTML tags.
3. Use Math.random() in Ajax URL as parameter.
4. Send URL as parameter after encodeURIComponent() similar to urlencode() in PHP.
5. Use file_get_contents($url) for first time filling Ajax DIV.
6. Use new window to display javascript alert debug messages as append messages in log files.
7. Use Ajax Cached version.

WebPage:
1. On login page username/password should be case sensitive.
2. Open terms of use page in popup window on registration page.
3. Use better UI for Errors/Success messages.
4. Use cancle button near submit button.
5. Use captcha code on pages by session value to avoid Spams.
6. Put valid ALT values in IMG tags.
7. Use Enter button event on form’s submit control.
8. Use scrolling DIV on webpages for better GUI.
9. Use returnto parameter for redirecting page after login.
10. Use remember option on login page.
11. Use valid/correct statements in error/success/warning messages.
12. Use dynamic Title and Meta tags on page.
13. Use error pages like 404, 500 etc. by .htaccess
14. Use good NO/Blank image for image not found.
15. Use htmlspecialchars() in strings displayed on webpages for W3C validations.
16. Use favicon for webpages for better GUI.

Emails:
1. Use good words like Dear, Regards, Thanks etc. in emails.
2. Attach some links, images, videos etc. for proper understanding.
3. Use reference and ref. # in emails.

Tools:
1. Use IDE like APTANA, Dreamweaver, Zend Editor.
2. Use DW’s context menu for HTML/PHP code to avoid W3C errors/warnings.
3. Use FireFox plugins for development (Web Developer, Firebug, Scribefire, ColorZilla, FireFTP, S3Fire, ElastoFox, Gtalk, GrabScreen, YSlow, FireShot etc.) for site’s speed, performance and optimization.
4. Make sure we are using secure FTP, Email Client….
5. Command Line tools (putty, CMD etc.) are very good utilities for batch processes and large files.

Search:
1. View source and display function (echo, print etc.) are very useful for finding bugs and faults.
2. Try to search visual concept like jQuery, Ajax etc. on google images search engine.
3. Use google operator for getting better results.

Keep browsing, happy coding…….   :)

Next Page »