Saturday, 31 August 2013

How to enable Gzip on your website

Enable Gzip Compression

Compression is enabled by adding some code to a file called .htaccess on your web host/server. This means going to the file manager (or wherever you go to add or upload files) on your webhost. The .htaccess file controls many important things for your site. If you are not familiar with the .htaccess file.


<IfModule mod_mime.c>
 AddType application/x-javascript .js
 AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
 <IfModule mod_setenvif.c>
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 </IfModule>
 <IfModule mod_headers.c>
  Header append Vary User-Agent env=!dont-vary
 </IfModule>
</IfModule>


Enable compression on Apache webservers

The instructions above will work on Apache.

Monday, 8 July 2013

Most Useful CMS in dot net

Most Useful CMS in dot net

Microsoft ASP.NET

Composite C1 

History

Composite C1 development began mid-2007, it reached version 1.0 in January 2009 and until September 2010 was sold as a commercially licensed product, primarily to customers in northern Europe.
On 29 September, 2010, Composite released C1 version 2.0 as free open source software under the Mozilla Public License, pledging to continue development on the free core and providing paid services.
In October 2010, Composite C1 was added to the .NET 4 enabled parts of Microsoft's Web App Gallery (Web Platform Installer 3 and WebMatrix).
In March 2011, Composite C1 version 2.1 was released, making SQL Server support part of the open source project.
In December 2011, Composite C1 version 3.0 was released, improving on the developer and content editor user experience and adding ASP.NET Razor as a layout template technology option.

Website : http://www.composite.net

Source code and community ratings

The source code, issue tracker and forum for Composite C1 is hosted at http://CompositeC1.codeplex.com/ - the CodePlex site also contain user ratings and reviews that can not be moderated.

Modules (C1 packages)

Content versioning
Newsletters
Extranet
Page comments
Issuu reader
RSS / Twitter / YouTube feed readers
XML to SQL Server migration
Google Search (CSE) integration
Microsoft Search Server integration
Package Creator
Data Forms Renderer
ASP.NET MVC Player
Social Media integrations (Facebook, Twitter, Google+)



Features

Multilingual, UNICODE support
Multiple document interface
Publishing workflow
Content security
WYSIWYG editor
XHTML compatible
XSLT developer tooling
.NET 4 and ASP.NET 4 based
Transparent XML and SQL Server support via LINQ
Side-by-side support for both ASP.NET Razor, ASP.NET Web Forms and ASP.NET MVC
Support for templating using plain HTML, ASP.NET Razor, ASP.NET Master Pages and XSLT
Run on Internet Information Services (IIS) 6, 7 and 7.5, WebMatrix, Visual Studio 2010, Windows Azure
Support for Mozilla Firefox, Internet Explorer, Google Chrome. Firefox users have spell check features.



DotNetNuke

DotNetNuke is a web content management system based on Microsoft .NET. The Community Edition is open source.
DotNetNuke was written in VB.NET, though the developer has shifted to C# since version 6.0. It is distributed under both a Community Edition MIT license  and commercial proprietary licenses as the Professional and Enterprise Editions.

DotNetNuke Community Edition

The DotNetNuke content management system is intended to allow management of websites without much technical language, and to be extensible through a large number of third-party apps to provide functionality not included in the DotNetNuke core modules.
Skins can be used to change the look of a website using DotNetNuke.
The DotNetNuke Corporation is the steward of the DotNetNuke open source project. The open source version of DotNetNuke is called the Community Edition and is available as a free download. The Community Edition includes access to the source code of the framework and standard installation modules, and an MIT license allowing modification and distribution rights. The Community Edition is a popular web content management (WCM) system and application development framework for ASP.NET, with over 6,000,000 downloads and 600,000 production web sites as of October 2010. The most recent version of the Community Edition (7.0.0) was published in January 2013.

website : http://www.dotnetnuke.com/

Modules

The default functionality of DotNetNuke can be expanded by adding third-party modules, either from an existing library of modules, or through in-house development of custom functionality. The DotNetNuke framework provides basic functionality such as security, user administration and content management, while modules are used to tailor the web site for specific deployment needs.
A set of primary modules are included with the core DotNetNuke distribution. These modules provide the functionality required to create an e-commerce system, an intranet, a public web site or a custom web application. They are maintained by a volunteer team community on the DotNetNuke Community Forge.

A module can be uploaded and automatically installed on a DotNetNuke installation through the administration pages of DotNetNuke. Once a module is added by the administrator, it can be placed on any of the pages in the web site and custom access permissions can be configured for it.

Skins

A skinning architecture provides a separation between design and content, enabling a web designer to develop skins without requiring any specialist knowledge of development in ASP.NET: only knowledge of HTML and an understanding of how to prepare and package the skins themselves is required. Skins consist of basic HTML files with placeholders (tokens) for content, menus and other functionality, along with support files such as images, style sheets and JavaScript, packaged in a ZIP file.[citation needed]
Upon Microsoft's release of the .NET Framework version 2, Microsoft had included functionality known as master pages. The principal idea behind master pages was to encourage code recycling and consistent design and aesthetics throughout a site by creating a master page with placeholders, which at runtime would be compiled and replaced by content.





Umbraco


Umbraco is an open source content management system (CMS) platform for publishing content on the World Wide Web and intranets. It is written in C# and deployed on Microsoft based infrastructure. The open source backend is released under an MIT License while the UI is released under the Umbraco license.
Umbraco was developed by Niels Hartvig in 2000 and released as open source software in 2004.[4] In 2009, CMS Wire described it as one of the leading .NET-based open source CMS systems. In 2010, with 1000 downloads a day, Umbraco was in the Top 5 most popular downloads via the Microsoft Web Platform Installer, two places below its main rival DotNetNuke and was the 12th most downloaded application from Codeplex, six places below DotNetNuke and 13 places higher than mojoPortal.


Releases
Version 4.1 Beta II was released on 16 February 2010 which refactors a number of key components of the framework,[7] including the UI tree control to improve performance and the user experience and parts of the data access layer to reduce the number of database calls.
Version 5 (codenamed "Jupiter") is a rewrite of the framework, built using ASP.NET MVC,[15] published in January 2012. Problems (performance and code complexity) inherent in the architecture of the new Version 5 data access layer  led to Version 5 being dropped in June 2012 despite having been released on a commercial licence, and development efforts refocused on integrating selected Version 5 front end enhancements into Version 4.


mojoPortal


mojoPortal is an open source, cross-platform, content management system (CMS) for ASP.NET which is written in the C# programming language. The CMS supports plugins and has built-in support for, among others, forums, blogs, event calendars, photo galleries, and an e-commerce feature.The project was awarded an Open Source Content Management System Award by Packt in 2007 saying that the "ease of use, set of relevant tools and plugins and also the fact that it is cross platform, made it stand out above the rest".

Awards

Best Non-PHP Open Source Content Management System in the 2007 CMS Awards by Packt Publishing[4]
3rd place in the 2009 CMS Awards by Packt Publishing, in the Non-PHP category



Key features

Cross-platform - Runs under Windows/IIS or Mono/Apache with most GNU/Linux distributions or Mac OS X
Works with MS SQL Server, SqlAzure, MySQL, PostgreSQL, Firebird Sql, and SQLite databases
Supports multiple sites on one installation and database
XHTML or HTML 5 compliant Content Management with support for work flow and approval/publishing process
Custom Skinning with support for user selectable skins and individual skins per page
Supports TinyMCE, FCKeditor, CKeditor or XStandard HTML WYSIWYG
Easily Customizable User Profile System
Member List
Bread Crumbs
Flexible Menu system
Localizable, currently translated into 10 languages
Passwords encryption
SSL support for the whole website or per page
URL re-writing
Error logging and optional debug logging
Authenticate against the database, LDAP, Active Directory, Windows NTLM, OpenID, or Windows Live ID
Content Workflow
Content Versioning
Content Template System
Content Style Template System
Content Widgets
Built in SEO (Search Engine Optimization)
301 Redirect Manager
Integrated Google Analytics
Support for Artisteer templates


Orchard

Orchard is a free, open source, community-focused content management system written in ASP.NET platform using the ASP.NET MVC framework. Its vision is to create shared components for building ASP.NET applications and extensions, and specific applications that leverage these components to meet the needs of end-users, scripters, and developers.
Orchard is delivered as part of the ASP.NET Open Source Gallery under the OuterCurve Foundation. It is licensed under a New BSD license, which is approved by the Open Source Initiative (OSI).
As per Orchard's codeplex page, the intended output of the Orchard project is three-fold:
Individual .NET-based applications that appeal to end-users, scripters, and developers
A set of re-usable components that makes it easy to build such applications
A vibrant community to help define these applications and extensions

Monday, 8 April 2013

301 redirect HTTPS to HTTP on Apache server

Redirecting https to http site-wide using the .htaccess file would be done through:



Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://yousitename.com/$1 [R=301,L]


One way is as in this example:


RewriteEngine on
#this page has to be on https
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/secure-page1.php$ [NC]
RewriteRule ^(.*)$ https://
yousitename.com/$1 [L,R=301]

#this page has to be on https
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/secure-page2.php$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

#all other pages have to be on http
RewriteCond %{SERVER_PORT} ^443$  [OR]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/secure-page1.php$ [NC]
RewriteCond %{REQUEST_URI} !^/secure-page2.php$ [NC]
RewriteRule ^(.*)$ http://
yousitename.com/$1 [L,R=301]


So assuming you have a good reason to want some urls as https AND have them indexed, then you can add php scripting to each page and determine whether it has to be http or https.
To permit the use of php on pages suffixed as .html you need to add an Apache handler in the .htaccess file:


# parsing html as php
AddHandler application/x-httpd-php .html 
NB: The above directiove can vary greatly depending on the rexact server configuration. It can be any of the below directives (or none for that matter):
Addhandler application/x+https-php5 .html
or
AddType application/x-httpd-php5 .html
or another combination like that.  It's bewildering how many different Apache server configuraiotns the can be and how much basic directievs can differ. The trouble is if yuo use the wrong one, you get a 500 error. So it ends up being trial and error all the way.

 php script to be added at the top of every page where you need to 301 redirect from https to http, before any other line of source code would be: 



<?php
if  ( $_SERVER['HTTPS'] )
        {
                $host = $_SERVER['HTTP_HOST'];
                $request_uri = $_SERVER['REQUEST_URI'];
                $good_url = "http://" . $host . $request_uri; 

                header( "HTTP/1.1 301 Moved Permanently" );
                header( "Location: $good_url" );
                exit;
        }
?> 




Facebook-style tooltip plugin for jQuery





Tipsy is a jQuery plugin for creating a Facebook-like tooltips effect based on an anchor tag's title attribute.

Examples & Usage
Basic
By default, tooltips will appear centred underneath their anchor:

Hover over me

Basic example:
$('#example-1').tipsy();
Gravities
Using the gravity parameter, it's possible to control the positioning of the tooltip relative to the pointee:

Northwest North Northeast
West East
Southwest South Southeast
Gravity example:
$('#foo').tipsy({gravity: 'n'}); // nw | n | ne | w | e | sw | s | se
As of version 0.1.3, it's possible to use a callback function to set the gravity dynamically at hover-time. Within the callback, this refers to the active element, and the function should return the calculated gravity as a string. Two demo callbacks are supplied - $.fn.tipsy.autoNS and $.fn.tipsy.autoWE - which select north/south and west/east gravity, respectively, based on the element's location in the viewport.

Here's an example (scroll the page to see the effect):

Dynamic Gravity
Dynamic gravity example:
$('#foo').tipsy({gravity: $.fn.tipsy.autoNS});
Fading
For full Wob2.0 compliance, you must fade these badboys in:

Hover over me

Fade example:
$('#example-fade').tipsy({fade: true});
Bonus Feature
You can EVEN COMBINE FADE AND GRAVITY! (exercise for reader)

Slightly Advanced Usage
Tooltip text can be set based on any attribute, not just title:

Hover over me

Custom attribute example:
$('#example-custom-attribute').tipsy({title: 'id'});
If any attribute isn't good enough, you may pass a callback function instead. It should return the tooltip text for this element:

Hover over me

Callback example:
$('#example-callback').tipsy({title: function() { return this.getAttribute('original-title').toUpperCase(); } });
Finally, it is possible to specify a fallback tooltip for any element which does not have any tooltip text:

Hover over me

Fallback example:
$('#example-fallback').tipsy({fallback: "Where's my tooltip yo'?" });
If your tooltip content contains HTML, set the html option to true (relies on invalid HTML, sorry):

Hover over me

HTML example:
$('#example-html').tipsy({html: true });
Show/Hide Delay
Delay example:
$('#example-delay').tipsy({delayIn: 500, delayOut: 1000});
Hover and wait

Dynamically Updating Text
Tipsy tooltips are 'live' - if the source attribute's value changes, the tooltip text will be updated the next time the tooltip is shown. There's one caveat - if you wish to remove the tooltip by setting the title attribute to an empty string, set the original-title attribute instead (this only applies if you're using the title attribute).



Form input tooltips code:
<script type='text/javascript'>
  $(function() {
    $('#focus-example [title]').tipsy({trigger: 'focus', gravity: 'w'});
  });
</script>
Manually Triggering a Tooltip
It's possible to disable hover events and instead trigger tooltips manually:

Manual triggering example:
My tooltip is manually triggered | Show it | Hide it
Code for manual triggering:
<p id='manual-example'>
  <a rel='tipsy' title='Well hello there'>My tooltip is manually triggered</a>
  <a href='#' onclick='$("#manual-example a[rel=tipsy]").tipsy("show"); return false;'>Show</a>
  <a href='#' onclick='$("#manual-example a[rel=tipsy]").tipsy("hide"); return false;'>Hide</a>
</p>

<script type='text/javascript'>
  $('#manual-example a[rel=tipsy]').tipsy({trigger: 'manual'});
</script>

Friday, 15 February 2013

multiple file attachment in php script and sending mail


<html>
<head>
<title>GLobal web solution Tutorial</title>
</head>
<body>
<form action="php_sendmail_multiple_upload2.php" method="post" name="form1" enctype="multipart/form-data">
<table width="343" border="1">
<tr>
<td>To</td>
<td><input name="txtTo" type="text" id="txtTo"></td>
</tr>
<tr>
<td>Subject</td>
<td><input name="txtSubject" type="text" id="txtSubject"></td>
</tr>
<tr>
<td>Description</td>
<td><textarea name="txtDescription" cols="30" rows="4" id="txtDescription"></textarea></td>
</tr>
<tr>
<td>Form Name</td>
<td><input name="txtFormName" type="text"></td>
</tr>
<tr>
<tr>
<td>Form Email</td>
<td><input name="txtFormEmail" type="text"></td>
</tr>
<tr>
 <td>Attachment</td>
 <td>
<input name="fileAttach[]" type="file"><br>
<input name="fileAttach[]" type="file"><br>
<input name="fileAttach[]" type="file"><br>
<input name="fileAttach[]" type="file"><br>
<input name="fileAttach[]" type="file"><br>
<input name="fileAttach[]" type="file"><br>
 </td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form>
</body>
</html>







<html>
<head>

</head>
<body>
<?
$strTo = $_POST["txtTo"];
$strSubject = $_POST["txtSubject"];
$strMessage = nl2br($_POST["txtDescription"]);

//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));

$strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]."";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";

//*** Attachment ***//
for($i=0;$i<count($_FILES["fileAttach"]["name"]);$i++)
{
if($_FILES["fileAttach"]["name"][$i] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"][$i];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"][$i])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}
}


$flgSend = @mail($strTo,$strSubject,null,$strHeader);  // @ = No Show Error //

if($flgSend)
{
echo "Mail send completed.";
}
else
{
echo "Cannot send mail.";
}
?>
</body>
</html>

Thursday, 24 January 2013

PHP MAIL() FUNCTION NOT WORKING IN WINDOWS SERVER

When your mail goes to anyone who uses a Windows mail server (comcast, gmail, and maybe aol), the recipients won’t get it.

To test if mail() function exist in your server you can try this few lines of codes.


<?php
if ( function_exists( 'mail') )
   echo 'mail() is enable';
else
   echo 'mail() has been disabled';
?>

If the result above is false/mail is disabled then maybe you need to add the solution I’ve provided below or else of course your mail() code does not formatted correctly

First Steps:


<?php
   // Add this code before mail() function.
  ini_set('SMTP','localhost'); 
   ini_set("sendmail_from", "info@example.com");
?>

Second Steps:


If first steps doesn’t work for you then you need to look a bit in your code header area.
From
$headers .= 'From:  Name <address@example.com>'. "\r\n";
To
$headers .= 'From:  address@example.com'. "\r\n";


Thursday, 6 December 2012

most popular add ons for oscommerce, useful osCommerce add-ons



Here you will find a list of the most popular osCommerce modules

 When installing add-ons make sure you download them from known sources
 Always make backups before you start installing addons. Always! 




Shoes

what's new in php 5.4 and php 5.4 here


New features

PHP 5.4.0 offers a wide range of new features:
  • Support for traits has been added.
  • Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.
  • Function array dereferencing has been added, e.g. foo()[0].
  • Closures now support $this.
  • <?= is now always available, regardless of the short_open_tag php.ini option.
  • Class member access on instantiation has been added, e.g. (new Foo)->bar().
  • Class::{expr}() syntax is now supported.
  • Binary number format has been added, e.g. 0b001001101.
  • Improved parse error messages and improved incompatible arguments warnings.
  • The session extension can now track the upload progress of files.
  • Built-in development web server in CLI mode.     

Backward Incompatible Changes

Although most existing PHP 5 code should work without changes, please take note of some backward incompatible changes:
  • Safe mode is no longer supported. Any applications that rely on safe mode may need adjustment, in terms of security.
  • Magic quotes has been removed. Applications relying on this feature may need to be updated, to avoid security issues. get_magic_quotes_gpc() and get_magic_quotes_runtime() now always return FALSE. set_magic_quotes_runtime() raises an E_CORE_ERROR level error.
  • The register_globals and register_long_arrays php.ini directives have been removed.
  • Call-time pass by reference has been removed.
  • The break and continue statements no longer accept variable arguments (e.g., break 1 + foo() * $bar;). Static arguments still work, such as break 2;. As a side effect of this change break 0; and continue 0; are no longer allowed.
  • In the date and time extension, the timezone can no longer be set using the TZ environment variable. Instead you have to specify a timezone using the date.timezone php.ini option or date_default_timezone_set() function. PHP will no longer attempt to guess the timezone, and will instead fall back to "UTC" and issue a E_WARNING.
  • Non-numeric string offsets - e.g. $a['foo'] where $a is a string - now return false on isset() and true on empty(), and produce a E_WARNING if you try to use them. Offsets of types double, bool and null produce a E_NOTICE. Numeric strings (e.g. $a['2']) still work as before. Note that offsets like '12.3' and '5 foobar' are considered non-numeric and produce a E_WARNING, but are converted to 12 and 5 respectively, for backward compatibility reasons. Note: Following code returns different result. $str='abc';var_dump(isset($str['x'])); // false for PHP 5.4 or later, but true for 5.3 or less
  • Converting an array to a string will now generate an E_NOTICE level error, but the result of the cast will still be the string "Array".
  • Turning NULL, FALSE, or an empty string into an object by adding a property will now emit an E_WARNING level error, instead of E_STRICT.
  • Parameter names that shadow super globals now cause a fatal error. This prohibits code like function foo($_GET, $_POST) {}.
  • The Salsa10 and Salsa20 hash algorithms have been removed.
  • array_combine() now returns array() instead of FALSE when two empty arrays are provided as parameters.
  • If you use htmlentities() with asian character sets, it works like htmlspecialchars() - this has always been the case in previous versions of PHP, but now an E_STRICT level error is emitted.     

Deprecated features in PHP 5.4.x

Deprecated functions:

Changed Functions

OpenSSL:

Other changes

  • The default character set for htmlspecialchars() and htmlentities() is now UTF-8, instead of ISO-8859-1. Note that changing your output charset via the default_charset configuration setting does not affect htmlspecialchars/htmlentities unless you are passing "" (an empty string) as the encoding parameter to your htmlspecialchars()/ htmlentities() calls. Generally we do not recommend doing this because you should be able to change your output charset without affecting the runtime charset used by these functions. The safest approach is to explicitly set the charset on each call to htmlspecialchars() and htmlentities().
  • E_ALL now includes E_STRICT level errors in the error_reporting configuration directive.
  • SNMP now has an OOP API. Functions now return FALSE on every error condition including SNMP-related (no such instance, end of MIB, etc). Thus, in particular, breaks previous behavior of get/walk functions returning an empty string on SNMP-related errors. Multi OID get/getnext/set queries are now supported. Dropped UCD-SNMP compatibility code, consider upgrading to net-snmp v5.3+, Net-SNMP v5.4+ is required for Windows version. In sake of adding support for IPv6 DNS name resolution of remote SNMP agent (peer) is done by extension now, not by Net-SNMP library anymore.
  • OpenSSL now supports AES.
  • CLI SAPI doesn't terminate any more on fatal errors when using interactive mode with readline support.
  • $_SERVER['REQUEST_TIME_FLOAT'] has been added to include microsecond precision.
  • Added new hash algorithms: fnv132, fnv164, joaat
  • Chained string offsets - e.g. $a[0][0] where $a is a string - now work.
  • Arrays cast from SimpleXMLElement now always contain all nodes instead of just the first matching node. All SimpleXMLElement children are now always printed when using var_dump(), var_export() and print_r().
  • It's now possible to enforce the class' __construct arguments in an abstract constructor in the base class.     
    

Monday, 19 November 2012

How to Schedule Database Backup Using Cron Job


Many Web Applications are changing daily. In case your site is hacked or its data becomes corrupted, it is beneficial to have regularly stored backups of your databases so you can restore your account quickly. Luckily, there is a quick and reliable way to do this through the use of Cron Jobs. Below is a step by step process on how to set up Cron Jobs to take backups of your Databases.

Change the following details to your database information and email information:
$dbhost = “localhost“; // leave this as localhost for most sites
$dbuser = “dbuser“; // enter your database username here
$dbpass = “dbpass“; // enter your database password here
$dbname = “dbname“; // enter the name of your database here
$sendto = “Send To <sendto @email.com>“; // the email address you are sending to
$sendfrom = “Send From <sendfrom @email.com>“; // This will be the reply to email address
$sendsubject = “Daily Database Backup“; // the subject of the email
$bodyofemail = “Here is the daily backup of my database.“; // The message included within the email

$backupfile = $dbname . date("Y-m-d") . '.sql.gz';
system("mysqldump -h $dbhost -u $dbuser --password=$dbpass $dbname | gzip > $backupfile");


Save the file and upload to “www” directory to your cPanel account.

Log into your cPanel. Locate and click on “Cron Jobs”



Set the Cron Job to run at the desired time, (it is usually best to run this through the middle of the night,) then put the following command in the “Command:” box with your username in place of “cPanelusername”

php -q ~/cPanelusername/public_html/mtebackup/backup.php




Your backup Cron Job will now be listed in the “Current Cron Jobs” section.

Enjoy receiving daily backups of your database.




Tuesday, 2 October 2012

mail are delivered in the spam folder instead of inbox


How to Avoid Spam Filters with PHP mail() Emails

Just about everyone who uses PHP has encountered the popular PHP mail() function which enables email to be sent from a server. This function is preferred to other methods of sending email, such as sending mail with SMTP Authentication, because its implementation is quick and easy. Unfortunately, when using the mail() function, your emails are more likely to be marked as spam. So how can we fix this?
A Simple Implementation Example

Many users of the mail() function often have simple implementations as shown in the code sample below:

<?
mail("recipient@recipient.com", "Message", "A simple message.", "From: The Sender <sender@sender.com>");
?>

While this implementation will successfully send an email, the email will probably get caught in the recipient’s spam filter. Fortunately, there are some simple fixes that can help you avoid spam filters.
4 Ways To Make Your PHP mail() Emails Less Spammy
1. Use Headers

In the simple example above, the from name and email address was added as the fourth parameter. Instead, consider using headers to set your From and Reply-To email addresses.

<?
  $headers .= "Reply-To: The Sender <sender@sender.com>\r\n";
  $headers .= "Return-Path: The Sender <sender@sender.com>\r\n";
  $headers .= "From: The Sender <senter@sender.com>\r\n";
?>

But headers  are good for more than just setting details about the sender. They are also important for setting the content type, the email priority, and more. Here are how some additional headers look.

<?
  $headers .= "Organization: Sender Organization\r\n";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  $headers .= "X-Priority: 3\r\n";
  $headers .= "X-Mailer: PHP". phpversion() ."\r\n"
?>

Be sure to replace the fourth parameter with the $headers variable as shown below.

<?
mail("recipient@recipient.com", "Message", "A simple message.", $headers);
?>
2. The Message Sender Domain and Server Domain Should Match

Spammers are notorious for sending emails from one server and trying to make the recipient believe that it came from somewhere else. So if you are sending an email from example@example.com, it is a good idea the the script reside on example.com.
3. Be Sure to Properly Use the Content-type Attribute

The Content-type attribute enables a message sender to say whether or not an email is plain text  or html, or whether it has attachments. Obviously, the easiest to use content type is text/plain. You just add your text as shown in the simple example, and you are done. But when you use the other content types, additional pieces might be expected. For example, with the text/html content type, an html body tag is expected. Not having this tag could result in your email being marked as spam.
4. Verify That Your Server Is Not Blacklisted

When a server is blacklisted, it means that that server has identified as one that has been sending a lot of spam. This results in recipient mail servers rejecting or filtering any mail that is received from that server.

So if your mail is not being received it is a good idea to verify that your server has not been blacklisted. This goes for both shared and dedicated servers. In a shared environment, it is common for other users on the server to be sending out spam. And in a dedicated environment, spammers may have found a way to exploit a vulnerability in a server or contact form to send out spam. So it is easy for either type of server to be blacklisted.



Alright, now that you have the basics on avoiding spam filters, reconstruct your scripts and happy emailing!

Tuesday, 4 September 2012

What is .htaccess? Its used


In order to specify your own customized error documents, you simply need to add the following command, on one line, within your htaccess file:
ErrorDocument code /directory/filename.ext
or
ErrorDocument 404 /errors/notfound.html
This would cause any error code resulting in 404 to be forward to yoursite.com/errors/notfound.html

Likewise with:
ErrorDocument 500 /errors/internalerror.html
You can name the pages anything you want (I'd recommend something that would prevent you from forgetting what the page is being used for), and you can place the error pages anywhere you want within your site, so long as they are web-accessible (through a URL). The initial slash in the directory location represents the root directory of your site, that being where your default page for your first-level domain is located. I typically prefer to keep them in a separate directory for maintenance purposes and in order to better control spiders indexing them through a ROBOTS.TXT file, but it is entirely up to you.
If you were to use an error document handler for each of the error codes I mentioned, the htaccess file would look like the following (note each command is on its own line):
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
You can specify a full URL rather than a virtual URL in the ErrorDocument string (http://yoursite.com/errors/notfound.html vs. /errors/notfound.html). But this is not the preferred method by the server's happiness standards.
You can also specify HTML, believe it or not!
ErrorDocument 401 "<body bgcolor=#ffffff><h1>You have
 to actually <b>BE</b> a <a href="#">member</A> to view 
this page, Colonel!
The only time I use that HTML option is if I am feeling particularly saucy, since you can have so much more control over the error pages when used in conjunction with xSSI or CGI or both. Also note that the ErrorDocument starts with a " just before the HTML starts, but does not end with one...it shouldn't end with one and if you do use that option, keep it that way. And again, that should all be on one line, no naughty word wrapping!


For to password protect a directory and all the directories below.
Put a file named .htaccess in the directory you want to password protect with the follow text.


AuthUserFile /opt/guide/www.widexl.com/.htpasswd
AuthType Basic
AuthName "Member Page"
require valid-user

For to password protect the admin.pl script.
You can use wildcards for this, like: "*.html"   "*.zip"

<files "admin.pl">
AuthUserFile /opt/guide/www.widexl.com/.htpasswd
AuthType Basic
AuthName "Administrator script"
require valid-user
</files>

AuthUserFile: This is the full path to your password file
AuthType: This need to be Basic.
AuthName: This is the name (Realm) you want to give to your password protected site.


top
Auth Digest

MD5 Digest authentication provides a more secure password system than Basic authentication, but only works with supporting browsers. The only major browsers which support digest authentication are Internet Explorer 5.0, Amaya and Konqueror from KDE2. I don't think its save for Big Brother, but it's always more save than Auth Basic. And most users are using Internet Explorer 5.0 or higher.
Module: mod_digest (old version)
Module: mod_auth_digest (new version)
OS: Unix, Linux, WinNT.

Don't use both modules on the same time.

Setting up MD5 Digest authentication is easy.
Put a file named .htaccess in the directory you want to password protect with the follow text.

Example: mod_digest

AuthDigestFile /opt/guide/www.widexl.com/.htpasswd
AuthType Digest
AuthName "Member Page"
require valid-user

Example: mod_auth_digest

AuthDigestFile /opt/guide/www.widexl.com/.htpasswd
AuthType Digest
AuthName "Member Page"
AuthDigestDomain /member/ http://www.widexl.com/members/
AuthDigestNonceLifetime 300
require valid-user


Enabling SSI Via htaccess

Many people want to use SSI, but don't seem to have the ability to do so with their current web host. You can change that with htaccess. A note of caution first...definitely ask permission from your host before you do this, it can be considered 'hacking' or violation of your host's TOS, so be safe rather than sorry:
AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
The first line tells the server that pages with a .shtml extension (for Server parsed HTML) are valid. The second line adds a handler, the actual SSI bit, in all files named .shtml. This tells the server that any file named .shtml should be parsed for server side commands. The last line is just techno-junk that you should throw in there.
And that's it, you should have SSI enabled. But wait...don't feel like renaming all of your pages to .shtml in order to take advantage of this neat little toy? Me either! Just add this line to the fragment above, between the first and second lines:
AddHandler server-parsed .html
A note of caution on that one too, however. This will force the server to parse every page named .html for SSI commands, even if they have no SSI commands within them. If you are using SSI sparingly on your site, this is going to give you more server drain than you can justify. SSI does slow down a server because it does extra stuff before serving up a page, although in human terms of speed, it is virtually transparent. Some people also prefer to allow SSI in html pages so as to avoid letting anyone who looks at the page extension to know that they are using SSI in order to prevent the server being compromised through SSI hacks, which is possible. Either way, you now have the knowledge to use it either way.
If, however, you are going to keep SSI pages with the extension of .shtml, and you want to use SSI on your Index pages, you need to add the following line to your htaccess:
DirectoryIndex index.shtml index.html

jQuery - Selectors


The jQuery library harnesses the power of Cascading Style Sheets (CSS) selectors to let us quickly and easily access elements or groups of elements in the Document Object Model (DOM).
A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria.

The $() factory function:

All type of selectors available in jQuery, always start with the dollar sign and parentheses: $().
The factory function $() makes use of following three building blocks while selecting elements in a given document:
jQueryDescription
Tag Name:Represents a tag name available in the DOM. For example $('p') selects all paragraphs in the document.
Tag ID:Represents a tag available with the given ID in the DOM. For example $('#some-id') selects the single element in the document that has an ID of some-id.
Tag Class:Represents a tag available with the given class in the DOM. For example $('.some-class') selects all elements in the document that have a class of some-class.
All the above items can be used either on their own or in combination with other selectors. All the jQuery selectors are based on the same principle except some tweaking.
NOTE: The factory function $() is a synonym of jQuery() function. So in case you are using any other JavaScript library where $ sign is conflicting with some thing else then you can replace $ sign by jQuery name and you can use function jQuery() instead of $().

Example:

Following is a simple example which makes use of Tag Selector. This would select all the elements with a tag name p.
<html>
<head>
<title>the title</title>
   <script type="text/javascript" 
   src="/jquery/jquery-1.3.2.min.js"></script>
   
   <script type="text/javascript" language="javascript">
   $(document).ready(function() {
      var pars = $("p");
      for( i=0; i<pars.length; i++ ){
         alert("Found paragraph: " + pars[i].innerHTML);
      }
   });
   </script>
</head>
<body>
   <div>
      <p class="myclass">This is a paragraph.</p>
      <p id="myid">This is second paragraph.</p>
      <p>This is third paragraph.</p>
   </div>
</body>
</html>

How to use Selectors?

The selectors are very useful and would be required at every step while using jQuery. They get the exact element that you want from your HTML document.
Following table lists down few basic selectors and explains them with examples.
SelectorDescription
NameSelects all elements which match with the given element Name.
#IDSelects a single element which matches with the given ID
.ClassSelects all elements which match with the given Class.
Universal (*)Selects all elements available in a DOM.
Multiple Elements E, F, GSelects the combined results of all the specified selectors E, F or G.
Similar to above syntax and examples, following examples would give you understanding on using different type of other useful selectors:
  • $('*'): This selector selects all elements in the document.
  • $("p > *"): This selector selects all elements that are children of a paragraph element.
  • $("#specialID"): This selector function gets the element with id="specialID".
  • $(".specialClass"): This selector gets all the elements that have the class of specialClass.
  • $("li:not(.myclass)"): Selects all elements matched by <li> that do not have class="myclass".
  • $("a#specialID.specialClass"): This selector matches links with an id of specialID and a class of specialClass.
  • $("p a.specialClass"): This selector matches links with a class of specialClass declared within <p> elements.
  • $("ul li:first"): This selector gets only the first <li> element of the <ul>.
  • $("#container p"): Selects all elements matched by <p> that are descendants of an element that has an id of container.
  • $("li > ul"): Selects all elements matched by <ul> that are children of an element matched by <li>
  • $("strong + em"): Selects all elements matched by <em> that immediately follow a sibling element matched by <strong>.
  • $("p ~ ul"): Selects all elements matched by <ul> that follow a sibling element matched by <p>.
  • $("code, em, strong"): Selects all elements matched by <code> or <em> or <strong>.
  • $("p strong, .myclass"): Selects all elements matched by <strong> that are descendants of an element matched by <p> as well as all elements that have a class of myclass.
  • $(":empty"): Selects all elements that have no children.
  • $("p:empty"): Selects all elements matched by <p> that have no children.
  • $("div[p]"): Selects all elements matched by <div> that contain an element matched by <p>.
  • $("p[.myclass]"): Selects all elements matched by <p> that contain an element with a class of myclass.
  • $("a[@rel]"): Selects all elements matched by <a> that have a rel attribute.
  • $("input[@name=myname]"): Selects all elements matched by <input> that have a name value exactly equal to myname.
  • $("input[@name^=myname]"): Selects all elements matched by <input> that have a name value beginning with myname.
  • $("a[@rel$=self]"): Selects all elements matched by <p> that have a class value ending with bar
  • $("a[@href*=domain.com]"): Selects all elements matched by <a> that have an href value containing domain.com.
  • $("li:even"): Selects all elements matched by <li> that have an even index value.
  • $("tr:odd"): Selects all elements matched by <tr> that have an odd index value.
  • $("li:first"): Selects the first <li> element.
  • $("li:last"): Selects the last <li> element.
  • $("li:visible"): Selects all elements matched by <li> that are visible.
  • $("li:hidden"): Selects all elements matched by <li> that are hidden.
  • $(":radio"): Selects all radio buttons in the form.
  • $(":checked"): Selects all checked boxex in the form.
  • $(":input"): Selects only form elements (input, select, textarea, button).
  • $(":text"): Selects only text elements (input[type=text]).
  • $("li:eq(2)"): Selects the third <li> element
  • $("li:eq(4)"): Selects the fifth <li> element
  • $("li:lt(2)"): Selects all elements matched by <li> element before the third one; in other words, the first two <li> elements.
  • $("p:lt(3)"): selects all elements matched by <p> elements before the fourth one; in other words the first three <p> elements.
  • $("li:gt(1)"): Selects all elements matched by <li> after the second one.
  • $("p:gt(2)"): Selects all elements matched by <p> after the third one.
  • $("div/p"): Selects all elements matched by <p> that are children of an element matched by <div>.
  • $("div//code"): Selects all elements matched by <code>that are descendants of an element matched by <div>.
  • $("//p//a"): Selects all elements matched by <a> that are descendants of an element matched by <p>
  • $("li:first-child"): Selects all elements matched by <li> that are the first child of their parent.
  • $("li:last-child"): Selects all elements matched by <li> that are the last child of their parent.
  • $(":parent"): Selects all elements that are the parent of another element, including text.
  • $("li:contains(second)"): Selects all elements matched by <li> that contain the text second.
You can use all the above selectors with any HTML/XML element in generic way. For example if selector $("li:first") works for <li> element then $("p:first") would also work for <p> element.