In case of displaying normal text having CR+LF character string on web browser, you may need to change it to <BR> tag.
PHP provides speedy converting function for supporting that. Following function is very useful.
Proto-type:
function nl2br( <source string> )
function nl2br( <source string> )
As you can expect by function name, it converts new line character set to <BR> tag.
Another posts included in "PHP"
| PHP socket programming to get content with post method (0) | 2009/10/19 |
| How to remove HTML tags in text string? (0) | 2009/08/05 |
| How to delete file on certain path ? (0) | 2008/10/01 |
| ASCII Artwork Generator from image file (0) | 2008/09/23 |
| How to limit by Timeout when opening URL ? (0) | 2008/04/14 |
Trackback : Cannot send a trackbact to this post.
When you need to get content with POST Method in PHP internal code, you need to get the desired result through alternate Socket Programming as below.
Actualluy what I wanted is emailing through alternate server located in different domain, because the current server has some limitation.
Following code is implemented at caller server.
<?
// caller page : kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
function kmail( $recipient, $subject, $body)
{
$host = "foo.com";
$uri = "/api/kmail_api.php";
// acutally security code is removed on below code.
// you can add it by yourself.
$reqbody = "s=" . urlencode($subject)
. "&b=" . urlencode($body)
. "&f=" . urlencode('SAMSUNGDForum')
. "&h=" . urlencode($headers)
. "&r=" . urlencode($recipient);
$contentlength = strlen($reqbody);
$reqheader = "POST $uri HTTP/1.0\xd\xa".
"Host: $host\xd\xa". "User-Agent: Mozala\xd\xa".
"Content-Type: application/x-www-form-urlencoded\xd\xa".
"Content-Length: $contentlength\xd\xa\xd\xa".
"$reqbody\xd\xa";
$socket = fsockopen($host, 80, $errno, $errstr);
if (!$socket)
{
$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket))
{
$result[] = fgets($socket, 4096);
}
fclose($socket);
return $result;
}
?>
// caller page : kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
function kmail( $recipient, $subject, $body)
{
$host = "foo.com";
$uri = "/api/kmail_api.php";
// acutally security code is removed on below code.
// you can add it by yourself.
$reqbody = "s=" . urlencode($subject)
. "&b=" . urlencode($body)
. "&f=" . urlencode('SAMSUNGDForum')
. "&h=" . urlencode($headers)
. "&r=" . urlencode($recipient);
$contentlength = strlen($reqbody);
$reqheader = "POST $uri HTTP/1.0\xd\xa".
"Host: $host\xd\xa". "User-Agent: Mozala\xd\xa".
"Content-Type: application/x-www-form-urlencoded\xd\xa".
"Content-Length: $contentlength\xd\xa\xd\xa".
"$reqbody\xd\xa";
$socket = fsockopen($host, 80, $errno, $errstr);
if (!$socket)
{
$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket))
{
$result[] = fgets($socket, 4096);
}
fclose($socket);
return $result;
}
?>
In addition you need to add following callee PHP page on your callee server.
<?
// callee page : /api/kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
$title = '=?utf-8?b?'.base64_encode($s).'?=';
$recipient = $r;
if (strlen($h)<1)
{
if (strlen($f)>0)
{
$h = "From: $f <no-reply@foo.com>\r\n";
}
else
{
$h = "From: NO-REPLY <no-reply@foo.com>\r\n";
}
$h .= "X-Sender: no-reply@foo.com\r\n";
$h .= "X-Mailer: Mozala PHP ".phpversion()."\n";
}
mail($recipient , $title, $b, $h);
?>
// callee page : /api/kmail.php
// programmed by Super Coder / Chunun Kang (kurapa@kurapa.com)
$title = '=?utf-8?b?'.base64_encode($s).'?=';
$recipient = $r;
if (strlen($h)<1)
{
if (strlen($f)>0)
{
$h = "From: $f <no-reply@foo.com>\r\n";
}
else
{
$h = "From: NO-REPLY <no-reply@foo.com>\r\n";
}
$h .= "X-Sender: no-reply@foo.com\r\n";
$h .= "X-Mailer: Mozala PHP ".phpversion()."\n";
}
mail($recipient , $title, $b, $h);
?>
Finally what you need to do is including above caller page to call kmail function.
include "./kmail.php";
kmail( "foo@foo.com", "howdy?", "test message from Chunun Kang (kurapa@kurapa.com");
kmail( "foo@foo.com", "howdy?", "test message from Chunun Kang (kurapa@kurapa.com");
Another posts included in "PHP"
| PHP function converts new line to BR tag (0) | 2009/11/27 |
| How to remove HTML tags in text string? (0) | 2009/08/05 |
| How to delete file on certain path ? (0) | 2008/10/01 |
| ASCII Artwork Generator from image file (0) | 2008/09/23 |
| How to limit by Timeout when opening URL ? (0) | 2008/04/14 |
| How to put timeout when opening URL by fopen ? (0) | 2008/03/31 |
Trackback : Cannot send a trackbact to this post.
Following is simple example to get Process name and add Process name to listbox control.
As you can see below, you can get working Process by Process control. But most of the properties are supported on windows platform. If you want to access the similar properties on windows mobile, you need to use another function.
using System.Diagnostics;
.
.
.
Process[] prs = Process.GetProcesses();
listBox1.Items.Clear;
foreach( Process pr in prs)
{
listBox1.Items.Add( pr.ProcessName);
}
.
.
.
Process[] prs = Process.GetProcesses();
listBox1.Items.Clear;
foreach( Process pr in prs)
{
listBox1.Items.Add( pr.ProcessName);
}
Another posts included in "C#"
| How to implement switch statement in C# ? (0) | 2009/09/05 |
| How to implement while loop in C# ? (0) | 2009/09/05 |
| How to delete file ? (0) | 2009/09/04 |
| How to convert integer to text string ? (0) | 2009/09/04 |
| How to convert text string to integer ? (0) | 2009/09/04 |
Trackback : Cannot send a trackbact to this post.
Adobe Photoshop provides the strong functions as javascript function for extension. In case of developing web based photo editing application, you can use it with javascript easily.
Follwing is the first step to use Photoshop Scripting:
As you can see above, you can simply check whether Photoshop Script is available or not.
Another posts included in "HTML, Javascript"
| To compare two HTML tables on web page in real time (0) | 2009/08/28 |
| To hide/show area of web page without re-loading a page (0) | 2009/08/28 |
| Displays the html tags without rendering on a webpage (0) | 2009/08/28 |
| Javascript based query parser for AJAX application (0) | 2009/08/28 |
| To get web browser capability (0) | 2009/08/28 |
Trackback : Cannot send a trackbact to this post.
There are FileOpenDialog and FileSaveDialog components on Delphi VCL.
Sometimes you may need Directory Selection dialog, but no components are found on VCL.
Do you know Delphi provides the solution as SelectDirectory().
Here are two examples for Directory Selection.
Following shows directory structure under d:\delphi
procedure TForm1.Button1Click(Sender: TObject);
var
DirSelected: string;
begin
if SelectDirectory('Select a folder:', 'D:\Delphi', DirSelected) then
ShowMessage('You selected ' + DirSelected)
else
ShowMessage('You did not select a folder');
end;
var
DirSelected: string;
begin
if SelectDirectory('Select a folder:', 'D:\Delphi', DirSelected) then
ShowMessage('You selected ' + DirSelected)
else
ShowMessage('You did not select a folder');
end;
Following shows driver names and files as well as directory structure.
procedure TForm1.Button2Click(Sender: TObject);
var
Dir: string;
begin
Dir := 'D:\Delphi';
if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then
ShowMessage('You selected ' + Dir)
else
ShowMessage('You did not select a folder');
end;
var
Dir: string;
begin
Dir := 'D:\Delphi';
if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then
ShowMessage('You selected ' + Dir)
else
ShowMessage('You did not select a folder');
end;
Another posts included in "Delphi"
| How to launch application ? (0) | 2009/09/09 |
| How to print external document ? (0) | 2009/09/09 |
| Delphi API to get windows temporary directory (0) | 2009/09/03 |
| Delphi API to get the current working directory (0) | 2009/09/03 |
| How to resize PNG file in Delphi ? (0) | 2009/09/03 |

Prev

Rss Feed