LoRz

Thursday, May 28, 2009

 

Paste Word in TinyMCE


<script language="javascript" src="js/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">


tinyMCE.init({
theme : "advanced",
mode : "exact",
elements : "profile",
plugins : "paste",
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect|,forecolor,backcolor",
theme_advanced_buttons3_add : "pastetext,pasteword,selectall",
paste_create_paragraphs : false,
paste_create_linebreaks : false,
paste_use_dialog : true,
paste_auto_cleanup_on_paste : true,
paste_convert_middot_lists : false,
paste_unindented_list_class : "unindentedList",
paste_convert_headers_to_strong : true,
paste_insert_word_content_callback : "convertWord"
});

function convertWord(type, content) {
switch (type) {
// Gets executed before the built in logic performes it's cleanups
case "before":
// do nothing
break;

// Gets executed after the built in logic performes it's cleanups
case "after":
content = content.replace(/<(!--)([\s\S]*)(--)>/gi, "");
break;
}

return content;
}

</script>


Wednesday, May 27, 2009

 

Obtain Email Addresses in a string

preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i",  trim(substr($line, 16)), $matches);
print_r(implode("\n", $matches[0]));

Sunday, May 17, 2009

 

Force SSL/https using .htaccess and mod_rewrite

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]


Force HTTPS for a particular folder
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]

Wednesday, March 4, 2009

 

Convert URL into Link using PHP


ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str); 

Friday, February 27, 2009

 

Get Starting and Ending Date of a Week in PHP



function week_start_date($wk_num, $yr, $first = 1, $format = 'Y-m-d')
{
$wk_ts = strtotime('+' . $wk_num . ' weeks', strtotime($yr . '0101'));
$mon_ts = strtotime('-' . date('w', $wk_ts) + $first . ' days', $wk_ts);
return date($format, $mon_ts);
}

$start_date = week_start_date(date("W"), date("Y"));
$end_date = date('Y-m-d', strtotime('+6 days', strtotime($start_date)));

Thursday, February 26, 2009

 

Get First Monday of a Month in PHP



function get_firstmonday($month,$year) {

$num = date('w',mktime(0,0,0,$month,1,$year));

if($num==1)
return date('Y-m-d',mktime(0,0,0,$month,1,$year));
elseif($num>1)
return date('Y-m-d',mktime(0,0,0,$month,1,$year)+(86400*(8-$num)));
else
return date('Y-m-d',mktime(0,0,0,$month,1,$year)+(86400*(1-$num)));
}

Friday, February 20, 2009

 

Posting to Twitter using PHP



<?php
// Set username and password
$username = 'username';
$password = 'password';
// The message you want to send
$message = 'is twittering from php using curl';
// The twitter API address
$url = 'http://twitter.com/statuses/update.xml';
// Alternative JSON version
// $url = 'http://twitter.com/statuses/update.json';
// Set up and execute the curl process
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
// check for success or failure
if (empty($buffer)) {
echo 'message';
} else {
echo 'success';
}
?>

Archives

June 2008   July 2008   August 2008   September 2008   October 2008   November 2008   December 2008   January 2009   February 2009   March 2009   May 2009   Watch UFC 100 Live Stream Joseph Agbeko vs Vic Darchinyan live stream Watch K-1 World MAX 2009 World Championship Tournament Final 8 live stream Watch Dream 10 live stream

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]