Posts

Showing posts from February, 2013

How to remove compatibility view in IE

just write simple code in Head tab < meta http-equiv = "X-UA-Compatible" content = "IE=9; IE=8; IE=7; IE=EDGE" />

How to Display "logged in" user information in wordpress

<?php global $current_user; get_currentuserinfo(); echo 'Username: ' . $current_user->user_login . "\n"; echo 'User email: ' . $current_user->user_email . "\n"; echo 'User first name: ' . $current_user->user_firstname . "\n"; echo 'User last name: ' . $current_user->user_lastname . "\n"; echo 'User display name: ' . $current_user->display_name . "\n"; echo 'User ID: ' . $current_user->ID . "\n"; ?>     Login/Log out and redirect on same page    <?php echo wp_logout_url( get_permalink() ); ?>   <?php echo wp_login_url( get_permalink() ); ?>    

HTML Useful Character Entities

Result Description Entity Name Entity Number   non-breaking space &nbsp; &#160; < less than &lt; &#60; > greater than &gt; &#62; & ampersand &amp; &#38; ¢ cent &cent; &#162; £ pound &pound; &#163; ¥ yen &yen; &#165; € euro &euro; &#8364; § section &sect; &#167; © copyright &copy; &#169; ® registered trademark &reg; &#174; ™ trademark &trade; &#8482;

Send mail with attachment

?php function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $head

Create Directory in PHP

if (! is_dir ( 'path/to/directory' )) { mkdir ( 'path/to/directory' ); }

Generate CSV file in PHP

<?php     function query_to_csv ( $db_conn , $query , $filename , $attachment = false , $headers = true ) {                 if( $attachment ) {             // send response headers to the browser             header ( 'Content-Type: text/csv' );             header ( 'Content-Disposition: attachment;filename=' . $filename );             $fp = fopen ( 'php://output' , 'w' );         } else {             $fp = fopen ( $filename , 'w' );         }                 $result = mysql_query ( $query , $db_conn ) or die( mysql_error ( $db_conn ) );                 if( $headers ) {             // output header row (if at least one row exists)             $row = mysql_fetch_assoc ( $result );             if( $row ) {                 fputcsv ( $fp , array_keys ( $row ));                 // reset pointer back to beginning                 mysql_data_seek ( $result , 0 );             }         }                 while( $row = mysql_fetch