Archive for category Portfolio
CShout 3 Release
Posted by coolersport in News, Portfolio on 16/06/2009
The new version of CShout has been renovated quite a lots with many long waited features. As in previous versions, it requires no database but a text file for storing shouts. Following are key important features:
- Use flat-file database, easy for setup and backup
- Support emoticons, flooding control (spam protection), bad words filtering.
- Display timestamp and ip address via tooltip.
- Timezone adjusting.
- Allow the admin to delete unwanted shouts on the fly.
- Search shouts by date, time, shouter, message, and ip address.
- Page navigation.
- AJAX-Ready.
- Support any language/charset.
- Extremely easy for customising and supporting themes. NEW
- Support integration with other CMS/Forums where users must log in to shout. Their usernames will be used. NEW
- Auto-refresh. Easy to turn into a chat box (rev28: allow admin to force this feature always on). NEW
Click here to download the latest package of CShout. Since version 3, CShout’s source code is Subversion controlled at http://code.google.com/p/cshout/source/checkout. View full change log.
If you have any suggestion or have found any bugs, please create a new issue or submit a comment here. For more information, please visit the wiki.
CShout 2.0 Release
Posted by coolersport in News, Portfolio on 28/09/2006
- Use flat-file database, easy for setup and backup
- Support emoticons, flooding control (spam protection), bad words filtering.
- Display timestamp and ip address via tooltip.
- Timezone adjusting.
- Allow the admin to delete unwanted shouts on the fly.
- Search shouts by date, time, shouter, message, and ip address.
- Page navigation.
- New version 2.0 implements AJAX.
- Support any language/charset.
http://www.hotscripts.com/Detailed/63497.html
http://sourceforge.net/projects/cshout
http://www.sitebeater.com/cshout.html
http://os.job4vn.net
http://www.webtaller.com
http://www.devscripts.com
http://blogs.pathf.com/agileajax
http://digg.com/programming http://korean.osstrans.net/software/cshout.html
http://up-yours.us
http://www.lpv-sev.ch
http://suckamucka.com/anime/blog/biriblog.php
http://www.nightoftherhythm.be
How to write your own GDownloadUrl function
Posted by coolersport in News, Portfolio on 15/09/2006
While doing the javascript calendar with ajax, I figured that I would need a wrapper function like GDownloadUrl() as you may see in Google Map API. The point is how to pass your custom function to this GDownloadUrl() to process returned xml data.
The Code
A few Google searches gave me the idea of how to do it. I would say this function will do exactly what GDownloadUrl does. In that regard, I name it CDownloadUrl.
Now have a look at the code, explanation will be followed.
/*
method : POST/GET
url : Call url
func : custom function which is used to process returned data,
take only one parameter
*/
function CDownloadUrl(method, url, func) {
tvar httpObj;
tvar browser = navigator.appName;
tif(browser.indexOf("Microsoft") > -1)
tthttpObj = new ActiveXObject("Microsoft.XMLHTTP");
telse httpObj = new XMLHttpRequest();
tthttpObj.open(method, url, true);
thttpObj.onreadystatechange = function() {
ttif(httpObj.readyState == 4){
tttif (httpObj.status == 200) {
ttttvar contenttype = httpObj.getResponseHeader('Content-Type');
ttttif (contenttype.indexOf('xml')>-1) {
tttttfunc(httpObj.responseXML);
tttt} else {
tttttfunc(httpObj.responseText);
tttt}
ttt} else {
ttttfunc('Error: '+httpObj.status);
ttt}
tt}
t};
thttpObj.send(null);
}
The function will take 3 parameters which specify method (GET or POST), url and a function taking return data as its parameter. I will give a example of this custom function later.
From line 8 to 13, it is all about setting up variables and instantate an XML object depending on the kind of browser (Microsoft or Non-Microsoft).
After openning a connection on line 15, a handler is defined for onreadystatechange event up to line 29.
The handler actually runs as all the operations are completed (readyState = 4). The early version of this handler was like this:
httpObj.onreadystatechange = function() {
tif(httpObj.readyState == 4){
ttfunc(httpObj.responseXML);
t}
};
It lacks of some essential error checking. The handler needs to check if the request was successful (status code 200 means OK), otherwise it will return Error: plus status code.
Now it seems okie to retrieve data, you may get them from responseXML or responseText. By checking its ‘Content-Type’ header, it knows what to return. Finally, it just pass the data to your custom function.
The last statement is just send the request away.
Example
Many people would find it hard to understand the code without some examples. The following will demonstrate how to use CDownloadUrl to request some text and display it into a div element. Assuming the getsometext.php script return some raw text.
document.write('<div id="test">Old text</div>');
CDownloadUrl('get', 'getsometext.php', function(text) {
tdocument.getElementById('test').innerHTML = text;
});
It can be rewritten in another way as below which is clearer and easy to understand.
document.write('<div id="test">Old text</div>');
function showText(text) {
tdocument.getElementById('test').innerHTML = text;
}
CDownloadUrl('get', 'getsometext.php', showText);
That’s it. I hope you understand and apply it into your own application. If you have any questions or comments, please feel free to shout it in my shoutbox or the form below.
Online Picture EXchange
Posted by coolersport in Portfolio on 12/10/2005
This is an assignment task which was done in PHP and used MySQL as back-end database. Please visithttp://opex.coolersport.info for more information. A demo user has been provided with user for both username and password.
Neuragenix Pty Ltd
Posted by coolersport in Portfolio on 13/09/2005
Visit Neuragenix’s home page at http://neuragenix.com
Nunawading Car Sale
Posted by coolersport in Portfolio on 23/08/2005
Create and Email PDF File ‘On The Fly’ With PHP
Posted by coolersport in Code snippets, Portfolio on 25/06/2005
Create a pdf on the fly, I am sure that many people know how to do it but not attaching those into email. You can have a lot tutorials about generating a pdf on the fly without storing anything on webserver. This technique allow you to customise the pdf as client’s requirements.
Let’s say you have a huge database of various types of books. On your website, visitors have the option to download sample booklet (in pdf format) of a book for which they are looking. In the old days, you have to create all of those pdf files manually or whatever way you can then upload them onto web server. Links to those pdf files have to be set up in advance properly. If you add new books to your database, the same process of making sample booklet will be repeated.
Today, that process can be done just in one php file which uses some libraries to generate pdf booklet on the fly as soon as a visitor asks for downloading it. I will show you this simple step in a moment.
However, what could you do if you do want to send those booklet to your visitors through provided email address instead of downloading them. Should you give them a link to the file or attach them with that email? A link in an email is nothing easier but attachment. After showing you how to create a pdf file on the fly using FPDF class, I will demonstrate how to attach that pdf file into emails.
PART I: Create PDF file on the fly
To generate a PDF file using PHP, you need a tool that supports you to do so. In this tutorial, I use FPDF which is completely free and can be downloaded from http://www.fpdf.org. Following are some highlight features:
° Choice of measure unit, page format and margins
° Page header and footer management
° Automatic page break
° Automatic line break and text justification
° Image support (JPEG and PNG)
° Colors
° Links
° TrueType, Type1 and encoding support
° Page compression
You do not need to have any extra tool to get FPDF to work. However, if you choose to use compression feature, zlib is required. FPDF works just fine with PHP version 4 and 5.
In this tutorial, the main purpose is how to send a pdf that you create on the fly as an email attachment. So, the following simple example on how to create a pdf file using PHP is borrowed from FPDF website. Visit FPDF website for full documentation and tutorials.
<?php
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
The sample code above just returns a pdf file with the message “Hello World!” as usual. I will use the same code in the next part of this tutorial.
Make sure you download the fpdf.php from FPDF website and place it in the same folder with the example file or using absolute/relative path to fpdf.php if it is in another folder.
PART II: Sending pdf as email attachment
You can send email using just native PHP code. However, to make this task simple, I prefer to use PEAR’s Mail class which can be obtained from http://pear.php.net. Do not forget to get a copy of PEAR’s Mime class because PEAR’s Mail need it to attach files into emails.
Make sure you set up all those PEAR classes properly in order to get this to work.
<?php
require('fpdf/fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdfcontent = $pdf->Output("helloworld.pdf", "S");
require_once('Mail.php');
require_once('Mail/mime.php');
// email address of the recipient
$to = "recipient@yahoo.com";
// email address of the sender
$from = "sender@yahoo.com";
// subject of the email
$subject = "Hello world from coolersport";
// email header format complies the PEAR's Mail class
// this header includes sender's email and subject
$headers = array('From' => $from,
'Subject' => $subject);
// We will send this email as HTML format
// which is well presented and nicer than plain text
// using the heredoc syntax
// REMEMBER: there should not be any space after PDFMAIL keyword in the next following lines
$htmlMessage = <<<PDFMAIL
<html>
<body bgcolor="#ffffff">
<p align="center">
Please find the pdf attached in the email.<br>
This is generated by <b style="font-size:18pt;">FPDF</b>
</p>
</body>
</html>
PDFMAIL;
// create a new instance of the Mail_Mime class
$mime = new Mail_Mime();
// set HTML content
$mime->setHtmlBody($htmlMessage);
// IMPORTANT: add pdf content as attachment
$mime->addAttachment($pdfcontent, 'application/pdf', 'helloworld.pdf', false, 'base64');
// build email message and save it in $body
$body = $mime->get();
// build header
$hdrs = $mime->headers($headers);
// create Mail instance that will be used to send email later
$mail = &Mail::factory('mail');
// Sending the email, according to the address in $to,
// the email headers in $hdrs,
// and the message body in $body.
$mail->send($to, $hdrs, $body);
?>
You can notice that this will send email using built-in PHP mail() function, so make sure your web server can send email. I reckon the localhost will not work in this case. Look at the line:
// create Mail instance that will be used to send email later
$mail = &Mail::factory(‘mail’);
If you want to send email using SMTP or other method, please read instruction in PEAR documentation.
As you can see, in the sample in part 1, the function output() is used without any parameter. As default, FPDF will return PDF code to http stream and will be display at client browser. In the example of part 2, output() function has two parameters. The first one is file name of that pdf file, which will be ignored because the second parameter “S” is used. Passing string “S” in the second parameter of the output() function will tell FPDF to return PDF file as a string instead of output it to client browser. As you can see, the result is stored in $pdfcontent and attached into the email later. The addAttachment() function will cast the $pdfcontent string into “base64″ format which will produce correct format for the pdf file in email attachment.
Conclusion
I do not want to cover too much information in this tutorial except what has been discussed above. If you’d like to understand more about FPDF and PEAR’s functions, please visit their website.
I hope that this will give you a idea of what the tutorial title says and you can put this into work.
New replacement tag for phpwcms
Posted by coolersport in News, Portfolio on 13/06/2005
- Copy and paste the css code in codecolorizer/geshi.css into your css file.
- Now you can use the tag [COLOR CODE:][/COLOR CODE] in your article.
Linetics Network Solutions
Posted by coolersport in Portfolio on 01/04/2001
Visit their website at http://linetics.de.