diff --git a/aboutus.html b/aboutus.html index 70f3e0fcc..6737bda47 100644 --- a/aboutus.html +++ b/aboutus.html @@ -1,169 +1,169 @@ - - - - - - -
-
-
-The http://phpmailer.codeworxtech.com/ website now carries a few -advertisements through the Google Adsense network to help offset -some of our costs.
-Thanks ....
-
-

PHPMailer is the world's leading email transport class and downloaded an -average of more than 32,000 each month. In March 2009, PHPMailer was downloaded -more than 31,000 times -- that's an average of 1,000 downloads daily. Our thanks -to our new users and loyal users. We understand you have many choices available -to select from and we thank you for select our fast and stable tool for your -website and projects.

-

Credits:
-PHPMailer's original founder is Brent Matzelle. The current team is:
-Project Administrator: Andy Prevost (codeworxtech), - -codeworxtech@users.sourceforge.net
-Author: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net
-Author: Marcus Bointon (coolbru) -coolbru@users.sourceforge.net

-

PHPMailer is used in many projects ranging from Open Source to commercial -packages. Our LGPL licensing terms are very flexible and allow for including -PHPMailer to enhance projects of all types. If you discover PHPMailer being used -in a project, please let us know about it.

-

WHY USE OUR TOOLS & WHAT'S IN IT FOR YOU?

-

A valid question. We're developers too. We've been writing software, primarily for the internet, for more than 15 years. Along the way, there are two major things that had tremendous impact of our company: PHP and Open Source. PHP is without doubt the most popular platform for the internet. There has been more progress in this area of technology because of Open Source software than in any other IT segment. We have used many open source tools, some as learning tools, some as components in projects we were working on. To us, it's not about popularity ... we're committed to robust, stable, and efficient tools you can use to get your projects in your user's hands quickly. So the shorter answer: what's in it for you? rapid development and rapid deployment without fuss and with straight forward open source licensing.

-

Now, here's our team:

- - - - - - - - - -
About Andy Prevost, AKA "codeworxtech".About Marcus Bointon, AKA "coolbru".
-

www.codeworxtech.com for more information.
- Web design, web applications, forms: WorxStudio.com
-

-

Our company, Worx International Inc., is the publisher of several Open Source applications and developer tools as well as several commercial PHP applications. The Open Source applications are ttCMS and DCP Portal. The Open Source developer tools include QuickComponents (QuickSkin and QuickCache) and now PHPMailer. - We have staff and offices in the United States, Caribbean, the Middle - East, and our primary development center in Canada. Our company is represented by - agents and resellers globally.

-

Worx International Inc. is at the forefront of developing PHP applications. Our staff are all Zend Certified university educated and experts at object oriented programming. While Worx International Inc. can handle any project from trouble shooting programs written by others all the way to finished mission-critical applications, we specialize in taking projects from inception all the way through to implementation - on budget, and on time. If you need help with your projects, we're the team to get it done right at a reasonable price.

-

Over the years, there have been a number of tools that have been constant favorites in all of our projects. We have become the project administrators for most of these tools.

-

Our developer tools are all Open Source. Here's a brief description:

-
    -
  • PHPMailer. Originally authored by Brent Matzelle, PHPMailer is the leading "email transfer class" for PHP. PHPMailer is downloaded more than - 26000 times each and every month by developers looking for a fast, stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is - less than 100 Kb), stable, and as complete a solution as you can find. - Other tools are nowhere near as simple. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at - http://phpmailer.codeworxtech.com/.
    - Please note: all of our focus is now on the PHPMailer for PHP5.
    - PS. While you are at it, please visit our sponsor's sites, click on their ads. - It helps offset some of our costs.
    - Want to help? We're looking for progressive developers to join our team of volunteer professionals working on PHPMailer. Our entire focus is on PHPMailer - for PHP5. If you are interested, let us know.
    -
    -
  • -
  • QuickCache. Originally authored by Jean Pierre Deckers as jpCache, QuickCache is an HTTP OpCode caching strategy that works on your entire site with only one line of code at the top of your script. The cached pages can be stored as files or as database objects. The benefits are absolutely astounding: bandwidth savings of up to 80% and screen display times increased by 8 - 10x. Visit the QuickCache website at - http://quickcache.codeworxtech.com/.
    -
    -
  • -
  • QuickSkin. Originally authored by Philipp v. Criegern and named "SmartTemplate". The project was taken over by Manuel 'EndelWar' Dalla Lana and now by "codeworxtech". QuickSkin is one of the truly outstanding templating engines available, but has always been confused with Smarty Templating Engine. QuickSkin is even more relevant today than when it was launched. It's a small footprint with big impact on your projects. It features a built in caching technology, token based substitution, and works on the concept of one single HTML file as the template. The HTML template file can contain variable information making it one small powerful tool for your developer tool kit. Visit the QuickSkin website at - http://quickskin.codeworxtech.com/.
    -
    -
  • -
-

We're committed to PHP and to the Open Source community.

-

Opportunities with Worx International Inc.:

-
    -
  • Resellers/Agents: We're always interested in talking with companies that - want to represent - Worx International Inc. in their markets. We also have private label programs for our commercial products (in certain circumstances).
  • -
  • Programmers/Developers: We are usually fully staffed, however, if you would like to be considered for a career with - Worx International Inc., we would be pleased to hear from you.
    - A few things to note:
    -
      -
    • experience level does not matter: from fresh out of college to multi-year experience - it's your - creative mind and a positive attitude we want
    • -
    • if you contact us looking for employment, include a cover letter, indicate what type of work/career you are looking for and expected compensation
    • -
    • if you are representing someone else looking for work, do not contact us. We have an exclusive relationship with a recruiting partner already and not interested in altering the arrangement. We will not hire your candidate under any circumstances unless they wish to approach us individually.
    • -
    • any contact that ignores any of these points will be discarded
    • -
  • -
  • Affiliates/Partnerships: We are interested in partnering with other firms who are leaders in their field. We clearly understand that successful companies are built on successful relationships in all industries world-wide. We currently have innovative relationships throughout the world that are mutually beneficial. Drop us a line and let's talk.
  • -
- Regards,
- Andy Prevost (aka, codeworxtech)
- codeworxtech@users.sourceforge.net
-
- We now also offer website design. hosting, and remote forms processing. Visit WorxStudio.com for more information.
-
-

Marcus is the technical director of Synchromedia Limited, a UK-based company providing online business services. Synchromedia's main services are:

-

Smartmessages.net

-

Smartmessages.net logo
Smartmessages.net
is Synchromedia's large-scale mailing list management system, providing email delivery services for a wide range of businesses, from sole traders to corporates. - We pride ourselves on personal service, and realise that every one of your subscribers is a precious asset to be handled with care. - We provide fast, reliable, high-volume delivery (some of our customers have lists of more than 1,000,000 subscribers) with fine-grained tracking while ensuring you stay fully compliant with UK, EC and US data protection laws. Smartmessages of course uses PHPMailer at its heart!

-

info@hand

-

info@hand logo
Synchromedia is the official UK distributor of info@hand, a class-leading open-source web-based CRM system. We provide licenses, hosting, planning, support and training for this very fully-featured system at very competitive prices. info@hand also uses PHPMailer!

-

How can we help you?

-

In addition to our headline services, we also provide consulting, development, hosting and sysadmin services, so if you just need a simple web hosting package, we can do that too. Not surprisingly, we know rather a lot about email, so you can talk to us about that too.

-

Please contact us if you'd like to know more.

-

Marcus is a regular attendee at PHP London, and occasionally speaks on email at technical conferences.

-
-
-
- - \ No newline at end of file + + + + + + +
+
+
+The http://phpmailer.codeworxtech.com/ website now carries a few +advertisements through the Google Adsense network to help offset +some of our costs.
+Thanks ....
+
+

PHPMailer is the world's leading email transport class and downloaded an +average of more than 32,000 each month. In March 2009, PHPMailer was downloaded +more than 31,000 times -- that's an average of 1,000 downloads daily. Our thanks +to our new users and loyal users. We understand you have many choices available +to select from and we thank you for select our fast and stable tool for your +website and projects.

+

Credits:
+PHPMailer's original founder is Brent Matzelle. The current team is:
+Project Administrator: Andy Prevost (codeworxtech), + +codeworxtech@users.sourceforge.net
+Author: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net
+Author: Marcus Bointon (coolbru) +coolbru@users.sourceforge.net

+

PHPMailer is used in many projects ranging from Open Source to commercial +packages. Our LGPL licensing terms are very flexible and allow for including +PHPMailer to enhance projects of all types. If you discover PHPMailer being used +in a project, please let us know about it.

+

WHY USE OUR TOOLS & WHAT'S IN IT FOR YOU?

+

A valid question. We're developers too. We've been writing software, primarily for the internet, for more than 15 years. Along the way, there are two major things that had tremendous impact of our company: PHP and Open Source. PHP is without doubt the most popular platform for the internet. There has been more progress in this area of technology because of Open Source software than in any other IT segment. We have used many open source tools, some as learning tools, some as components in projects we were working on. To us, it's not about popularity ... we're committed to robust, stable, and efficient tools you can use to get your projects in your user's hands quickly. So the shorter answer: what's in it for you? rapid development and rapid deployment without fuss and with straight forward open source licensing.

+

Now, here's our team:

+ + + + + + + + + +
About Andy Prevost, AKA "codeworxtech".About Marcus Bointon, AKA "coolbru".
+

www.codeworxtech.com for more information.
+ Web design, web applications, forms: WorxStudio.com
+

+

Our company, Worx International Inc., is the publisher of several Open Source applications and developer tools as well as several commercial PHP applications. The Open Source applications are ttCMS and DCP Portal. The Open Source developer tools include QuickComponents (QuickSkin and QuickCache) and now PHPMailer. + We have staff and offices in the United States, Caribbean, the Middle + East, and our primary development center in Canada. Our company is represented by + agents and resellers globally.

+

Worx International Inc. is at the forefront of developing PHP applications. Our staff are all Zend Certified university educated and experts at object oriented programming. While Worx International Inc. can handle any project from trouble shooting programs written by others all the way to finished mission-critical applications, we specialize in taking projects from inception all the way through to implementation - on budget, and on time. If you need help with your projects, we're the team to get it done right at a reasonable price.

+

Over the years, there have been a number of tools that have been constant favorites in all of our projects. We have become the project administrators for most of these tools.

+

Our developer tools are all Open Source. Here's a brief description:

+
    +
  • PHPMailer. Originally authored by Brent Matzelle, PHPMailer is the leading "email transfer class" for PHP. PHPMailer is downloaded more than + 26000 times each and every month by developers looking for a fast, stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is + less than 100 Kb), stable, and as complete a solution as you can find. + Other tools are nowhere near as simple. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at + http://phpmailer.codeworxtech.com/.
    + Please note: all of our focus is now on the PHPMailer for PHP5.
    + PS. While you are at it, please visit our sponsor's sites, click on their ads. + It helps offset some of our costs.
    + Want to help? We're looking for progressive developers to join our team of volunteer professionals working on PHPMailer. Our entire focus is on PHPMailer + for PHP5. If you are interested, let us know.
    +
    +
  • +
  • QuickCache. Originally authored by Jean Pierre Deckers as jpCache, QuickCache is an HTTP OpCode caching strategy that works on your entire site with only one line of code at the top of your script. The cached pages can be stored as files or as database objects. The benefits are absolutely astounding: bandwidth savings of up to 80% and screen display times increased by 8 - 10x. Visit the QuickCache website at + http://quickcache.codeworxtech.com/.
    +
    +
  • +
  • QuickSkin. Originally authored by Philipp v. Criegern and named "SmartTemplate". The project was taken over by Manuel 'EndelWar' Dalla Lana and now by "codeworxtech". QuickSkin is one of the truly outstanding templating engines available, but has always been confused with Smarty Templating Engine. QuickSkin is even more relevant today than when it was launched. It's a small footprint with big impact on your projects. It features a built in caching technology, token based substitution, and works on the concept of one single HTML file as the template. The HTML template file can contain variable information making it one small powerful tool for your developer tool kit. Visit the QuickSkin website at + http://quickskin.codeworxtech.com/.
    +
    +
  • +
+

We're committed to PHP and to the Open Source community.

+

Opportunities with Worx International Inc.:

+
    +
  • Resellers/Agents: We're always interested in talking with companies that + want to represent + Worx International Inc. in their markets. We also have private label programs for our commercial products (in certain circumstances).
  • +
  • Programmers/Developers: We are usually fully staffed, however, if you would like to be considered for a career with + Worx International Inc., we would be pleased to hear from you.
    + A few things to note:
    +
      +
    • experience level does not matter: from fresh out of college to multi-year experience - it's your + creative mind and a positive attitude we want
    • +
    • if you contact us looking for employment, include a cover letter, indicate what type of work/career you are looking for and expected compensation
    • +
    • if you are representing someone else looking for work, do not contact us. We have an exclusive relationship with a recruiting partner already and not interested in altering the arrangement. We will not hire your candidate under any circumstances unless they wish to approach us individually.
    • +
    • any contact that ignores any of these points will be discarded
    • +
  • +
  • Affiliates/Partnerships: We are interested in partnering with other firms who are leaders in their field. We clearly understand that successful companies are built on successful relationships in all industries world-wide. We currently have innovative relationships throughout the world that are mutually beneficial. Drop us a line and let's talk.
  • +
+ Regards,
+ Andy Prevost (aka, codeworxtech)
+ codeworxtech@users.sourceforge.net
+
+ We now also offer website design. hosting, and remote forms processing. Visit WorxStudio.com for more information.
+
+

Marcus is the technical director of Synchromedia Limited, a UK-based company providing online business services. Synchromedia's main services are:

+

Smartmessages.net

+

Smartmessages.net logo
Smartmessages.net
is Synchromedia's large-scale mailing list management system, providing email delivery services for a wide range of businesses, from sole traders to corporates. + We pride ourselves on personal service, and realise that every one of your subscribers is a precious asset to be handled with care. + We provide fast, reliable, high-volume delivery (some of our customers have lists of more than 1,000,000 subscribers) with fine-grained tracking while ensuring you stay fully compliant with UK, EC and US data protection laws. Smartmessages of course uses PHPMailer at its heart!

+

info@hand

+

info@hand logo
Synchromedia is the official UK distributor of info@hand, a class-leading open-source web-based CRM system. We provide licenses, hosting, planning, support and training for this very fully-featured system at very competitive prices. info@hand also uses PHPMailer!

+

How can we help you?

+

In addition to our headline services, we also provide consulting, development, hosting and sysadmin services, so if you just need a simple web hosting package, we can do that too. Not surprisingly, we know rather a lot about email, so you can talk to us about that too.

+

Please contact us if you'd like to know more.

+

Marcus is a regular attendee at PHP London, and occasionally speaks on email at technical conferences.

+
+
+
+ + diff --git a/changelog.txt b/changelog.txt index dc43a4b60..76c75cf2a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,408 +1,415 @@ -ChangeLog - -NOTE: THIS VERSION OF PHPMAILER IS DESIGNED FOR PHP5/PHP6. - IT WILL NOT WORK WITH PHP4. - -Version 5.1 (October 20, 2009) -* fixed filename issue with AddStringAttachment (thanks to Tony) -* fixed "SingleTo" property, now works with Senmail, Qmail, and SMTP in - addition to PHP mail() -* added DKIM digital signing functionality - New properties: - - DKIM_domain (sets the domain name) - - DKIM_private (holds DKIM private key) - - DKIM_passphrase (holds your DKIM passphrase) - - DKIM_selector (holds the DKIM "selector") - - DKIM_identity (holds the identifying email address) -* added callback function support - - callback function parameters include: - result, to, cc, bcc, subject and body - * see the test/test_callback.php file for usage. -* added "auto" identity functionality - - can automatically add: - - Return-path (if Sender not set) - - Reply-To (if ReplyTo not set) - - can be disabled: - - $mail->SetFrom('yourname@yourdomain.com','First Last',false); - - or by adding the $mail->Sender and/or $mail->ReplyTo properties - Note: "auto" identity added to help with emails ending up in spam - or junk boxes because of missing headers - -Version 5.0.2 (May 24, 2009) -* Fix for missing attachments when inline graphics are present -* Fix for missing Cc in header when using SMTP (mail was sent, - but not displayed in header -- Cc receiver only saw email To: - line and no Cc line, but did get the email (To receiver - saw same) - -Version 5.0.1 (April 05, 2009) -* Temporary fix for missing attachments - -Version 5.0.0 (April 02, 2009) - -* With the release of this version, we are initiating a new version numbering - system to differentiate from the PHP4 version of PHPMailer. -* Most notable in this release is fully object oriented code. -class.smtp.php: -* Refactored class.smtp.php to support new exception handling - code size reduced from 29.2 Kb to 25.6 Kb -* Removed unnecessary functions from class.smtp.php: - public function Expand($name) { - public function Help($keyword="") { - public function Noop() { - public function Send($from) { - public function SendOrMail($from) { - public function Verify($name) { -class.phpmailer.php: -* Refactored class.phpmailer.php with new exception handling -* Changed processing functionality of Sendmail and Qmail so they cannot be - inadvertently used -* removed getFile() function, just became a simple wrapper for - file_get_contents() -* added check for PHP version (will gracefully exit if not at least PHP 5.0) -class.phpmailer.php enhancements -* enhanced code to check if an attachment source is the same as an embedded or - inline graphic source to eliminate duplicate attachments -New /test_script -* We have written a test script you can use to test the script as part of your - installation. Once you press submit, the test script will send a multi-mime - email with either the message you type in or an HTML email with an inline - graphic. Two attachments are included in the email (one of the attachments - is also the inline graphic so you can see that only one copy of the graphic - is sent in the email). The test script will also display the functional - script that you can copy/paste to your editor to duplicate the functionality. -New examples -* All new examples in both basic and advanced modes. Advanced examples show - Exception handling. -PHPDocumentator (phpdocs) documentation for PHPMailer version 5.0.0 -* all new documentation - -Please note: the website has been updated to reflect the changes in PHPMailer -version 5.0.0. http://phpmailer.codeworxtech.com/ - -Version 2.3 (November 06, 2008) - -* added Arabic language (many thanks to Bahjat Al Mostafa) -* removed English language from language files and made it a default within - class.phpmailer.php - if no language is found, it will default to use - the english language translation -* fixed public/private declarations -* corrected line 1728, $basedir to $directory -* added $sign_cert_file to avoid improper duplicate use of $sign_key_file -* corrected $this->Hello on line 612 to $this->Helo -* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user - if default is not acceptable -* removed trim() from return results in EncodeQP -* /test and three files it contained are removed from version 2.3 -* fixed phpunit.php for compliance with PHP5 -* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg); -* We have removed the /phpdoc from the downloads. All documentation is now on - the http://phpmailer.codeworxtech.com website. - -Version 2.2.1 () July 19 2008 - -* fixed line 1092 in class.smtp.php (my apologies, error on my part) - -Version 2.2 () July 15 2008 - -* Fixed redirect issue (display of UTF-8 in thank you redirect) -* fixed error in getResponse function declaration (class.pop3.php) -* PHPMailer now PHP6 compliant -* fixed line 1092 in class.smtp.php (endless loop from missing = sign) - -Version 2.1 (Wed, June 04 2008) - -** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. - IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE - APPRECIATED. - -* added S/MIME functionality (ability to digitally sign emails) - BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. - The "Signed Emails" functionality adds the Sign method to pass the private key - filename and the password to read it, and then email will be sent with - content-type multipart/signed and with the digital signature attached. -* fully compatible with E_STRICT error level - - Please note: - In about half the test environments this development version was subjected - to, an error was thrown for the date() functions used (line 1565 and 1569). - This is NOT a PHPMailer error, it is the result of an incorrectly configured - PHP5 installation. The fix is to modify your 'php.ini' file and include the - date.timezone = America/New York - directive, to your own server timezone - - If you do get this error, and are unable to access your php.ini file: - In your PHP script, add - date_default_timezone_set('America/Toronto'); - - do not try to use - $myVar = date_default_timezone_get(); - as a test, it will throw an error. -* added ability to define path (mainly for embedded images) - function MsgHTML($message,$basedir='') ... where: - $basedir is the fully qualified path -* fixed MsgHTML() function: - - Embedded Images where images are specified by :// will not be altered or embedded -* fixed the return value of SMTP exit code ( pclose ) -* addressed issue of multibyte characters in subject line and truncating -* added ability to have user specified Message ID - (default is still that PHPMailer create a unique Message ID) -* corrected unidentified message type to 'application/octet-stream' -* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al). -* added check for added attachments -* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny") - -Version 2.1.0beta2 (Sun, Dec 02 2007) -* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon) -* finished all testing, all known bugs corrected, enhancements tested -- note: will NOT work with PHP4. - -please note, this is BETA software -** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS -INTENDED STRICTLY FOR TESTING - -Version 2.1.0beta1 -please note, this is BETA software -** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS -INTENDED STRICTLY FOR TESTING - -Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release -* implements new property to control VERP in class.smtp.php - example (requires instantiating class.smtp.php): - $mail->do_verp = true; -* POP-before-SMTP functionality included, thanks to Richard Davey - (see class.pop3.php & pop3_before_smtp_test.php for examples) -* included example showing how to use PHPMailer with GMAIL -* fixed the missing Cc in SendMail() and Mail() - -****************** -A note on sending bulk emails: - -If the email you are sending is not personalized, consider using the -"undisclosed-recipient:;" strategy. That is, put all of your recipients -in the Bcc field and set the To field to "undisclosed-recipients:;". -It's a lot faster (only one send) and saves quite a bit on resources. -Contrary to some opinions, this will not get you listed in spam engines - -it's a legitimate way for you to send emails. - -A partial example for use with PHPMailer: - -$mail->AddAddress("undisclosed-recipients:;"); -$mail->AddBCC("email1@anydomain.com,email2@anyotherdomain.com,email3@anyalternatedomain.com"); - -Many email service providers restrict the number of emails that can be sent -in any given time period. Often that is between 50 - 60 emails maximum -per hour or per send session. - -If that's the case, then break up your Bcc lists into chunks that are one -less than your limit, and put a pause in your script. -******************* - -Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release -* dramatically simplified using inline graphics ... it's fully automated and requires no user input -* added automatic document type detection for attachments and pictures -* added MsgHTML() function to replace Body tag for HTML emails -* fixed the SendMail security issues (input validation vulnerability) -* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address -* removed the need to use the AltBody method (set from the HTML, or default text used) -* set the PHP Mail() function as the default (still support SendMail, SMTP Mail) -* removed the need to set the IsHTML property (set automatically) -* added Estonian language file by Indrek Päri -* added header injection patch -* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc. - example of use: - $mail->set('X-Priority', '3'); - $mail->set('X-MSMail-Priority', 'Normal'); -* fixed warning message in SMTP get_lines method -* added TLS/SSL SMTP support - example of use: - $mail = new PHPMailer(); - $mail->Mailer = "smtp"; - $mail->Host = "smtp.example.com"; - $mail->SMTPSecure = "tls"; // option - //$mail->SMTPSecure = "ssl"; // option - ... - $mail->Send(); -* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) -* Works with PHP installed as a module or as CGI-PHP -- NOTE: will NOT work with PHP5 in E_STRICT error mode - -Version 1.73 (Sun, Jun 10 2005) -* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf -* Now has a total of 20 translations -* Fixed alt attachments bug: http://tinyurl.com/98u9k - -Version 1.72 (Wed, May 25 2004) -* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations. -* Received: Removed this method because spam filter programs like -SpamAssassin reject this header. -* Fixed error count bug. -* SetLanguage default is now "language/". -* Fixed magic_quotes_runtime bug. - -Version 1.71 (Tue, Jul 28 2003) -* Made several speed enhancements -* Added German and Italian translation files -* Fixed HELO/AUTH bugs on keep-alive connects -* Now provides an error message if language file does not load -* Fixed attachment EOL bug -* Updated some unclear documentation -* Added additional tests and improved others - -Version 1.70 (Mon, Jun 20 2003) -* Added SMTP keep-alive support -* Added IsError method for error detection -* Added error message translation support (SetLanguage) -* Refactored many methods to increase library performance -* Hello now sends the newer EHLO message before HELO as per RFC 2821 -* Removed the boundary class and replaced it with GetBoundary -* Removed queue support methods -* New $Hostname variable -* New Message-ID header -* Received header reformat -* Helo variable default changed to $Hostname -* Removed extra spaces in Content-Type definition (#667182) -* Return-Path should be set to Sender when set -* Adds Q or B encoding to headers when necessary -* quoted-encoding should now encode NULs \000 -* Fixed encoding of body/AltBody (#553370) -* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC) -* Multiple bug fixes - -Version 1.65 (Fri, Aug 09 2002) -* Fixed non-visible attachment bug (#585097) for Outlook -* SMTP connections are now closed after each transaction -* Fixed SMTP::Expand return value -* Converted SMTP class documentation to phpDocumentor format - -Version 1.62 (Wed, Jun 26 2002) -* Fixed multi-attach bug -* Set proper word wrapping -* Reduced memory use with attachments -* Added more debugging -* Changed documentation to phpDocumentor format - -Version 1.60 (Sat, Mar 30 2002) -* Sendmail pipe and address patch (Christian Holtje) -* Added embedded image and read confirmation support (A. Ognio) -* Added unit tests -* Added SMTP timeout support (*nix only) -* Added possibly temporary PluginDir variable for SMTP class -* Added LE message line ending variable -* Refactored boundary and attachment code -* Eliminated SMTP class warnings -* Added SendToQueue method for future queuing support - -Version 1.54 (Wed, Dec 19 2001) -* Add some queuing support code -* Fixed a pesky multi/alt bug -* Messages are no longer forced to have "To" addresses - -Version 1.50 (Thu, Nov 08 2001) -* Fix extra lines when not using SMTP mailer -* Set WordWrap variable to int with a zero default - -Version 1.47 (Tue, Oct 16 2001) -* Fixed Received header code format -* Fixed AltBody order error -* Fixed alternate port warning - -Version 1.45 (Tue, Sep 25 2001) -* Added enhanced SMTP debug support -* Added support for multiple ports on SMTP -* Added Received header for tracing -* Fixed AddStringAttachment encoding -* Fixed possible header name quote bug -* Fixed wordwrap() trim bug -* Couple other small bug fixes - -Version 1.41 (Wed, Aug 22 2001) -* Fixed AltBody bug w/o attachments -* Fixed rfc_date() for certain mail servers - -Version 1.40 (Sun, Aug 12 2001) -* Added multipart/alternative support (AltBody) -* Documentation update -* Fixed bug in Mercury MTA - -Version 1.29 (Fri, Aug 03 2001) -* Added AddStringAttachment() method -* Added SMTP authentication support - -Version 1.28 (Mon, Jul 30 2001) -* Fixed a typo in SMTP class -* Fixed header issue with Imail (win32) SMTP server -* Made fopen() calls for attachments use "rb" to fix win32 error - -Version 1.25 (Mon, Jul 02 2001) -* Added RFC 822 date fix (Patrice) -* Added improved error handling by adding a $ErrorInfo variable -* Removed MailerDebug variable (obsolete with new error handler) - -Version 1.20 (Mon, Jun 25 2001) -* Added quoted-printable encoding (Patrice) -* Set Version as public and removed PrintVersion() -* Changed phpdoc to only display public variables and methods - -Version 1.19 (Thu, Jun 21 2001) -* Fixed MS Mail header bug -* Added fix for Bcc problem with mail(). *Does not work on Win32* - (See PHP bug report: http://www.php.net/bugs.php?id=11616) -* mail() no longer passes a fifth parameter when not needed - -Version 1.15 (Fri, Jun 15 2001) -[Note: these changes contributed by Patrice Fournier] -* Changed all remaining \n to \r\n -* Bcc: header no longer writen to message except -when sent directly to sendmail -* Added a small message to non-MIME compliant mail reader -* Added Sender variable to change the Sender email -used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode -* Changed boundary setting to a place it will be set only once -* Removed transfer encoding for whole message when using multipart -* Message body now uses Encoding in multipart messages -* Can set encoding and type to attachments 7bit, 8bit -and binary attachment are sent as is, base64 are encoded -* Can set Encoding to base64 to send 8 bits body -through 7 bits servers - -Version 1.10 (Tue, Jun 12 2001) -* Fixed win32 mail header bug (printed out headers in message body) - -Version 1.09 (Fri, Jun 08 2001) -* Changed date header to work with Netscape mail programs -* Altered phpdoc documentation - -Version 1.08 (Tue, Jun 05 2001) -* Added enhanced error-checking -* Added phpdoc documentation to source - -Version 1.06 (Fri, Jun 01 2001) -* Added optional name for file attachments - -Version 1.05 (Tue, May 29 2001) -* Code cleanup -* Eliminated sendmail header warning message -* Fixed possible SMTP error - -Version 1.03 (Thu, May 24 2001) -* Fixed problem where qmail sends out duplicate messages - -Version 1.02 (Wed, May 23 2001) -* Added multiple recipient and attachment Clear* methods -* Added Sendmail public variable -* Fixed problem with loading SMTP library multiple times - -Version 0.98 (Tue, May 22 2001) -* Fixed problem with redundant mail hosts sending out multiple messages -* Added additional error handler code -* Added AddCustomHeader() function -* Added support for Microsoft mail client headers (affects priority) -* Fixed small bug with Mailer variable -* Added PrintVersion() function - -Version 0.92 (Tue, May 15 2001) -* Changed file names to class.phpmailer.php and class.smtp.php to match - current PHP class trend. -* Fixed problem where body not being printed when a message is attached -* Several small bug fixes - -Version 0.90 (Tue, April 17 2001) -* Intial public release +ChangeLog + +NOTE: THIS VERSION OF PHPMAILER IS DESIGNED FOR PHP5/PHP6. + IT WILL NOT WORK WITH PHP4. + +Version 5.2 (July 19, 2011) +* protected MIME body and header +* better DKIM DNS Resource Record support +* better aly handling +* htmlfilter class added to extras +* moved to Apache Extras + +Version 5.1 (October 20, 2009) +* fixed filename issue with AddStringAttachment (thanks to Tony) +* fixed "SingleTo" property, now works with Senmail, Qmail, and SMTP in + addition to PHP mail() +* added DKIM digital signing functionality + New properties: + - DKIM_domain (sets the domain name) + - DKIM_private (holds DKIM private key) + - DKIM_passphrase (holds your DKIM passphrase) + - DKIM_selector (holds the DKIM "selector") + - DKIM_identity (holds the identifying email address) +* added callback function support + - callback function parameters include: + result, to, cc, bcc, subject and body + * see the test/test_callback.php file for usage. +* added "auto" identity functionality + - can automatically add: + - Return-path (if Sender not set) + - Reply-To (if ReplyTo not set) + - can be disabled: + - $mail->SetFrom('yourname@yourdomain.com','First Last',false); + - or by adding the $mail->Sender and/or $mail->ReplyTo properties + Note: "auto" identity added to help with emails ending up in spam + or junk boxes because of missing headers + +Version 5.0.2 (May 24, 2009) +* Fix for missing attachments when inline graphics are present +* Fix for missing Cc in header when using SMTP (mail was sent, + but not displayed in header -- Cc receiver only saw email To: + line and no Cc line, but did get the email (To receiver + saw same) + +Version 5.0.1 (April 05, 2009) +* Temporary fix for missing attachments + +Version 5.0.0 (April 02, 2009) + +* With the release of this version, we are initiating a new version numbering + system to differentiate from the PHP4 version of PHPMailer. +* Most notable in this release is fully object oriented code. +class.smtp.php: +* Refactored class.smtp.php to support new exception handling + code size reduced from 29.2 Kb to 25.6 Kb +* Removed unnecessary functions from class.smtp.php: + public function Expand($name) { + public function Help($keyword="") { + public function Noop() { + public function Send($from) { + public function SendOrMail($from) { + public function Verify($name) { +class.phpmailer.php: +* Refactored class.phpmailer.php with new exception handling +* Changed processing functionality of Sendmail and Qmail so they cannot be + inadvertently used +* removed getFile() function, just became a simple wrapper for + file_get_contents() +* added check for PHP version (will gracefully exit if not at least PHP 5.0) +class.phpmailer.php enhancements +* enhanced code to check if an attachment source is the same as an embedded or + inline graphic source to eliminate duplicate attachments +New /test_script +* We have written a test script you can use to test the script as part of your + installation. Once you press submit, the test script will send a multi-mime + email with either the message you type in or an HTML email with an inline + graphic. Two attachments are included in the email (one of the attachments + is also the inline graphic so you can see that only one copy of the graphic + is sent in the email). The test script will also display the functional + script that you can copy/paste to your editor to duplicate the functionality. +New examples +* All new examples in both basic and advanced modes. Advanced examples show + Exception handling. +PHPDocumentator (phpdocs) documentation for PHPMailer version 5.0.0 +* all new documentation + +Please note: the website has been updated to reflect the changes in PHPMailer +version 5.0.0. http://phpmailer.codeworxtech.com/ + +Version 2.3 (November 06, 2008) + +* added Arabic language (many thanks to Bahjat Al Mostafa) +* removed English language from language files and made it a default within + class.phpmailer.php - if no language is found, it will default to use + the english language translation +* fixed public/private declarations +* corrected line 1728, $basedir to $directory +* added $sign_cert_file to avoid improper duplicate use of $sign_key_file +* corrected $this->Hello on line 612 to $this->Helo +* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user + if default is not acceptable +* removed trim() from return results in EncodeQP +* /test and three files it contained are removed from version 2.3 +* fixed phpunit.php for compliance with PHP5 +* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg); +* We have removed the /phpdoc from the downloads. All documentation is now on + the http://phpmailer.codeworxtech.com website. + +Version 2.2.1 () July 19 2008 + +* fixed line 1092 in class.smtp.php (my apologies, error on my part) + +Version 2.2 () July 15 2008 + +* Fixed redirect issue (display of UTF-8 in thank you redirect) +* fixed error in getResponse function declaration (class.pop3.php) +* PHPMailer now PHP6 compliant +* fixed line 1092 in class.smtp.php (endless loop from missing = sign) + +Version 2.1 (Wed, June 04 2008) + +** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. + IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE + APPRECIATED. + +* added S/MIME functionality (ability to digitally sign emails) + BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. + The "Signed Emails" functionality adds the Sign method to pass the private key + filename and the password to read it, and then email will be sent with + content-type multipart/signed and with the digital signature attached. +* fully compatible with E_STRICT error level + - Please note: + In about half the test environments this development version was subjected + to, an error was thrown for the date() functions used (line 1565 and 1569). + This is NOT a PHPMailer error, it is the result of an incorrectly configured + PHP5 installation. The fix is to modify your 'php.ini' file and include the + date.timezone = America/New York + directive, to your own server timezone + - If you do get this error, and are unable to access your php.ini file: + In your PHP script, add + date_default_timezone_set('America/Toronto'); + - do not try to use + $myVar = date_default_timezone_get(); + as a test, it will throw an error. +* added ability to define path (mainly for embedded images) + function MsgHTML($message,$basedir='') ... where: + $basedir is the fully qualified path +* fixed MsgHTML() function: + - Embedded Images where images are specified by :// will not be altered or embedded +* fixed the return value of SMTP exit code ( pclose ) +* addressed issue of multibyte characters in subject line and truncating +* added ability to have user specified Message ID + (default is still that PHPMailer create a unique Message ID) +* corrected unidentified message type to 'application/octet-stream' +* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al). +* added check for added attachments +* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny") + +Version 2.1.0beta2 (Sun, Dec 02 2007) +* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon) +* finished all testing, all known bugs corrected, enhancements tested +- note: will NOT work with PHP4. + +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +Version 2.1.0beta1 +please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS +INTENDED STRICTLY FOR TESTING + +Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release +* implements new property to control VERP in class.smtp.php + example (requires instantiating class.smtp.php): + $mail->do_verp = true; +* POP-before-SMTP functionality included, thanks to Richard Davey + (see class.pop3.php & pop3_before_smtp_test.php for examples) +* included example showing how to use PHPMailer with GMAIL +* fixed the missing Cc in SendMail() and Mail() + +****************** +A note on sending bulk emails: + +If the email you are sending is not personalized, consider using the +"undisclosed-recipient:;" strategy. That is, put all of your recipients +in the Bcc field and set the To field to "undisclosed-recipients:;". +It's a lot faster (only one send) and saves quite a bit on resources. +Contrary to some opinions, this will not get you listed in spam engines - +it's a legitimate way for you to send emails. + +A partial example for use with PHPMailer: + +$mail->AddAddress("undisclosed-recipients:;"); +$mail->AddBCC("email1@anydomain.com,email2@anyotherdomain.com,email3@anyalternatedomain.com"); + +Many email service providers restrict the number of emails that can be sent +in any given time period. Often that is between 50 - 60 emails maximum +per hour or per send session. + +If that's the case, then break up your Bcc lists into chunks that are one +less than your limit, and put a pause in your script. +******************* + +Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release +* dramatically simplified using inline graphics ... it's fully automated and requires no user input +* added automatic document type detection for attachments and pictures +* added MsgHTML() function to replace Body tag for HTML emails +* fixed the SendMail security issues (input validation vulnerability) +* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address +* removed the need to use the AltBody method (set from the HTML, or default text used) +* set the PHP Mail() function as the default (still support SendMail, SMTP Mail) +* removed the need to set the IsHTML property (set automatically) +* added Estonian language file by Indrek Päri +* added header injection patch +* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc. + example of use: + $mail->set('X-Priority', '3'); + $mail->set('X-MSMail-Priority', 'Normal'); +* fixed warning message in SMTP get_lines method +* added TLS/SSL SMTP support + example of use: + $mail = new PHPMailer(); + $mail->Mailer = "smtp"; + $mail->Host = "smtp.example.com"; + $mail->SMTPSecure = "tls"; // option + //$mail->SMTPSecure = "ssl"; // option + ... + $mail->Send(); +* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) +* Works with PHP installed as a module or as CGI-PHP +- NOTE: will NOT work with PHP5 in E_STRICT error mode + +Version 1.73 (Sun, Jun 10 2005) +* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf +* Now has a total of 20 translations +* Fixed alt attachments bug: http://tinyurl.com/98u9k + +Version 1.72 (Wed, May 25 2004) +* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations. +* Received: Removed this method because spam filter programs like +SpamAssassin reject this header. +* Fixed error count bug. +* SetLanguage default is now "language/". +* Fixed magic_quotes_runtime bug. + +Version 1.71 (Tue, Jul 28 2003) +* Made several speed enhancements +* Added German and Italian translation files +* Fixed HELO/AUTH bugs on keep-alive connects +* Now provides an error message if language file does not load +* Fixed attachment EOL bug +* Updated some unclear documentation +* Added additional tests and improved others + +Version 1.70 (Mon, Jun 20 2003) +* Added SMTP keep-alive support +* Added IsError method for error detection +* Added error message translation support (SetLanguage) +* Refactored many methods to increase library performance +* Hello now sends the newer EHLO message before HELO as per RFC 2821 +* Removed the boundary class and replaced it with GetBoundary +* Removed queue support methods +* New $Hostname variable +* New Message-ID header +* Received header reformat +* Helo variable default changed to $Hostname +* Removed extra spaces in Content-Type definition (#667182) +* Return-Path should be set to Sender when set +* Adds Q or B encoding to headers when necessary +* quoted-encoding should now encode NULs \000 +* Fixed encoding of body/AltBody (#553370) +* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC) +* Multiple bug fixes + +Version 1.65 (Fri, Aug 09 2002) +* Fixed non-visible attachment bug (#585097) for Outlook +* SMTP connections are now closed after each transaction +* Fixed SMTP::Expand return value +* Converted SMTP class documentation to phpDocumentor format + +Version 1.62 (Wed, Jun 26 2002) +* Fixed multi-attach bug +* Set proper word wrapping +* Reduced memory use with attachments +* Added more debugging +* Changed documentation to phpDocumentor format + +Version 1.60 (Sat, Mar 30 2002) +* Sendmail pipe and address patch (Christian Holtje) +* Added embedded image and read confirmation support (A. Ognio) +* Added unit tests +* Added SMTP timeout support (*nix only) +* Added possibly temporary PluginDir variable for SMTP class +* Added LE message line ending variable +* Refactored boundary and attachment code +* Eliminated SMTP class warnings +* Added SendToQueue method for future queuing support + +Version 1.54 (Wed, Dec 19 2001) +* Add some queuing support code +* Fixed a pesky multi/alt bug +* Messages are no longer forced to have "To" addresses + +Version 1.50 (Thu, Nov 08 2001) +* Fix extra lines when not using SMTP mailer +* Set WordWrap variable to int with a zero default + +Version 1.47 (Tue, Oct 16 2001) +* Fixed Received header code format +* Fixed AltBody order error +* Fixed alternate port warning + +Version 1.45 (Tue, Sep 25 2001) +* Added enhanced SMTP debug support +* Added support for multiple ports on SMTP +* Added Received header for tracing +* Fixed AddStringAttachment encoding +* Fixed possible header name quote bug +* Fixed wordwrap() trim bug +* Couple other small bug fixes + +Version 1.41 (Wed, Aug 22 2001) +* Fixed AltBody bug w/o attachments +* Fixed rfc_date() for certain mail servers + +Version 1.40 (Sun, Aug 12 2001) +* Added multipart/alternative support (AltBody) +* Documentation update +* Fixed bug in Mercury MTA + +Version 1.29 (Fri, Aug 03 2001) +* Added AddStringAttachment() method +* Added SMTP authentication support + +Version 1.28 (Mon, Jul 30 2001) +* Fixed a typo in SMTP class +* Fixed header issue with Imail (win32) SMTP server +* Made fopen() calls for attachments use "rb" to fix win32 error + +Version 1.25 (Mon, Jul 02 2001) +* Added RFC 822 date fix (Patrice) +* Added improved error handling by adding a $ErrorInfo variable +* Removed MailerDebug variable (obsolete with new error handler) + +Version 1.20 (Mon, Jun 25 2001) +* Added quoted-printable encoding (Patrice) +* Set Version as public and removed PrintVersion() +* Changed phpdoc to only display public variables and methods + +Version 1.19 (Thu, Jun 21 2001) +* Fixed MS Mail header bug +* Added fix for Bcc problem with mail(). *Does not work on Win32* + (See PHP bug report: http://www.php.net/bugs.php?id=11616) +* mail() no longer passes a fifth parameter when not needed + +Version 1.15 (Fri, Jun 15 2001) +[Note: these changes contributed by Patrice Fournier] +* Changed all remaining \n to \r\n +* Bcc: header no longer writen to message except +when sent directly to sendmail +* Added a small message to non-MIME compliant mail reader +* Added Sender variable to change the Sender email +used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode +* Changed boundary setting to a place it will be set only once +* Removed transfer encoding for whole message when using multipart +* Message body now uses Encoding in multipart messages +* Can set encoding and type to attachments 7bit, 8bit +and binary attachment are sent as is, base64 are encoded +* Can set Encoding to base64 to send 8 bits body +through 7 bits servers + +Version 1.10 (Tue, Jun 12 2001) +* Fixed win32 mail header bug (printed out headers in message body) + +Version 1.09 (Fri, Jun 08 2001) +* Changed date header to work with Netscape mail programs +* Altered phpdoc documentation + +Version 1.08 (Tue, Jun 05 2001) +* Added enhanced error-checking +* Added phpdoc documentation to source + +Version 1.06 (Fri, Jun 01 2001) +* Added optional name for file attachments + +Version 1.05 (Tue, May 29 2001) +* Code cleanup +* Eliminated sendmail header warning message +* Fixed possible SMTP error + +Version 1.03 (Thu, May 24 2001) +* Fixed problem where qmail sends out duplicate messages + +Version 1.02 (Wed, May 23 2001) +* Added multiple recipient and attachment Clear* methods +* Added Sendmail public variable +* Fixed problem with loading SMTP library multiple times + +Version 0.98 (Tue, May 22 2001) +* Fixed problem with redundant mail hosts sending out multiple messages +* Added additional error handler code +* Added AddCustomHeader() function +* Added support for Microsoft mail client headers (affects priority) +* Fixed small bug with Mailer variable +* Added PrintVersion() function + +Version 0.92 (Tue, May 15 2001) +* Changed file names to class.phpmailer.php and class.smtp.php to match + current PHP class trend. +* Fixed problem where body not being printed when a message is attached +* Several small bug fixes + +Version 0.90 (Tue, April 17 2001) +* Intial public release diff --git a/class.phpmailer.php b/class.phpmailer.php index 602f1210c..4589cd791 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -2,15 +2,15 @@ /*~ class.phpmailer.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | -| Version: 5.1 | -| Contact: via sourceforge.net support pages (also www.worxware.com) | -| Info: http://phpmailer.sourceforge.net | -| Support: http://sourceforge.net/projects/phpmailer/ | +| Version: 5.2 | +| Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | | ------------------------------------------------------------------------- | -| Admin: Andy Prevost (project admininistrator) | +| Admin: Jim Jagielski (project admininistrator) | | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | +| : Jim Jagielski (jimjag) jimjag@gmail.com | | Founder: Brent R. Matzelle (original founder) | +| Copyright (c) 2010-2011, Jim Jagielski. All Rights Reserved. | | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | @@ -19,11 +19,6 @@ | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | -| ------------------------------------------------------------------------- | -| We offer a number of paid services (www.worxware.com): | -| - Web Hosting on highly optimized fast and secure servers | -| - Technology Consulting | -| - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' */ @@ -33,8 +28,10 @@ * @package PHPMailer * @author Andy Prevost * @author Marcus Bointon + * @author Jim Jagielski + * @copyright 2010 - 2011 Jim Jagielski * @copyright 2004 - 2009 Andy Prevost - * @version $Id$ + * @version $Id: class.phpmailer.php 450 2010-06-23 16:46:33Z coolbru $ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License */ @@ -118,6 +115,20 @@ class PHPMailer { */ public $AltBody = ''; + /** + * Stores the complete compiled MIME message body. + * @var string + * @access protected + */ + protected $MIMEBody = ''; + + /** + * Stores the complete compiled MIME message headers. + * @var string + * @access protected + */ + protected $MIMEHeader = ''; + /** * Sets word wrapping on the body of the message to a given number of * characters. @@ -269,6 +280,12 @@ class PHPMailer { */ public $DKIM_identity = ''; + /** + * Used with DKIM DNS Resource Record + * @var string + */ + public $DKIM_passphrase = ''; + /** * Used with DKIM DNS Resource Record * optional, in format of email address 'you@yourdomain.com' @@ -300,28 +317,34 @@ class PHPMailer { * Sets the PHPMailer Version number * @var string */ - public $Version = '5.1'; + public $Version = '5.2'; + + /** + * What to use in the X-Mailer header + * @var string + */ + public $XMailer = ''; ///////////////////////////////////////////////// // PROPERTIES, PRIVATE AND PROTECTED ///////////////////////////////////////////////// - private $smtp = NULL; - private $to = array(); - private $cc = array(); - private $bcc = array(); - private $ReplyTo = array(); - private $all_recipients = array(); - private $attachment = array(); - private $CustomHeader = array(); - private $message_type = ''; - private $boundary = array(); - protected $language = array(); - private $error_count = 0; - private $sign_cert_file = ""; - private $sign_key_file = ""; - private $sign_key_pass = ""; - private $exceptions = false; + protected $smtp = NULL; + protected $to = array(); + protected $cc = array(); + protected $bcc = array(); + protected $ReplyTo = array(); + protected $all_recipients = array(); + protected $attachment = array(); + protected $CustomHeader = array(); + protected $message_type = ''; + protected $boundary = array(); + protected $language = array(); + protected $error_count = 0; + protected $sign_cert_file = ''; + protected $sign_key_file = ''; + protected $sign_key_pass = ''; + protected $exceptions = false; ///////////////////////////////////////////////// // CONSTANTS @@ -447,11 +470,15 @@ public function AddReplyTo($address, $name = '') { * @param string $address The email address to send to * @param string $name * @return boolean true on success, false if address already used or invalid in some way - * @access private + * @access protected */ - private function AddAnAddress($kind, $address, $name = '') { + protected function AddAnAddress($kind, $address, $name = '') { if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { - echo 'Invalid recipient array: ' . kind; + $this->SetError($this->Lang('Invalid recipient array').': '.$kind); + if ($this->exceptions) { + throw new phpmailerException('Invalid recipient array: ' . $kind); + } + echo $this->Lang('Invalid recipient array').': '.$kind; return false; } $address = trim($address); @@ -485,7 +512,7 @@ private function AddAnAddress($kind, $address, $name = '') { * @param string $name * @return boolean */ - public function SetFrom($address, $name = '',$auto=1) { + public function SetFrom($address, $name = '', $auto = 1) { $address = trim($address); $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim if (!self::ValidateAddress($address)) { @@ -543,6 +570,19 @@ public static function ValidateAddress($address) { * @return bool */ public function Send() { + try { + if(!$this->PreSend()) return false; + return $this->PostSend(); + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + return false; + } + } + + protected function PreSend() { try { if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); @@ -555,27 +595,41 @@ public function Send() { $this->error_count = 0; // reset errors $this->SetMessageType(); - $header = $this->CreateHeader(); - $body = $this->CreateBody(); - + //Refuse to send an empty message if (empty($this->Body)) { throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); } + $this->MIMEHeader = $this->CreateHeader(); + $this->MIMEBody = $this->CreateBody(); + + // digitally sign with DKIM if enabled if ($this->DKIM_domain && $this->DKIM_private) { - $header_dkim = $this->DKIM_Add($header,$this->Subject,$body); - $header = str_replace("\r\n","\n",$header_dkim) . $header; + $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody); + $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader; } + return true; + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + return false; + } + } + + protected function PostSend() { + try { // Choose the mailer and send through it switch($this->Mailer) { case 'sendmail': - return $this->SendmailSend($header, $body); + return $this->SendmailSend($this->MIMEHeader, $this->MIMEBody); case 'smtp': - return $this->SmtpSend($header, $body); + return $this->SmtpSend($this->MIMEHeader, $this->MIMEBody); default: - return $this->MailSend($header, $body); + return $this->MailSend($this->MIMEHeader, $this->MIMEBody); } } catch (phpmailerException $e) { @@ -612,7 +666,7 @@ protected function SendmailSend($header, $body) { $result = pclose($mail); // implement call back function if it exists $isSent = ($result == 0) ? 1 : 0; - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); if($result != 0) { throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); } @@ -626,7 +680,7 @@ protected function SendmailSend($header, $body) { $result = pclose($mail); // implement call back function if it exists $isSent = ($result == 0) ? 1 : 0; - $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body); + $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body); if($result != 0) { throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); } @@ -648,8 +702,12 @@ protected function MailSend($header, $body) { } $to = implode(', ', $toArr); - $params = sprintf("-oi -f %s", $this->Sender); - if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { + if (empty($this->Sender)) { + $params = "-oi -f %s"; + } else { + $params = sprintf("-oi -f %s", $this->Sender); + } + if ($this->Sender != '' and !ini_get('safe_mode')) { $old_from = ini_get('sendmail_from'); ini_set('sendmail_from', $this->Sender); if ($this->SingleTo === true && count($toArr) > 1) { @@ -657,13 +715,13 @@ protected function MailSend($header, $body) { $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); } } else { $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); } } else { if ($this->SingleTo === true && count($toArr) > 1) { @@ -671,13 +729,13 @@ protected function MailSend($header, $body) { $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); } } else { $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); // implement call back function if it exists $isSent = ($rt == 1) ? 1 : 0; - $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); } } if (isset($old_from)) { @@ -716,11 +774,11 @@ protected function SmtpSend($header, $body) { $bad_rcpt[] = $to[0]; // implement call back function if it exists $isSent = 0; - $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); } else { // implement call back function if it exists $isSent = 1; - $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); } } foreach($this->cc as $cc) { @@ -728,11 +786,11 @@ protected function SmtpSend($header, $body) { $bad_rcpt[] = $cc[0]; // implement call back function if it exists $isSent = 0; - $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); } else { // implement call back function if it exists $isSent = 1; - $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); } } foreach($this->bcc as $bcc) { @@ -740,11 +798,11 @@ protected function SmtpSend($header, $body) { $bad_rcpt[] = $bcc[0]; // implement call back function if it exists $isSent = 0; - $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); } else { // implement call back function if it exists $isSent = 1; - $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); } } @@ -942,7 +1000,7 @@ public function WrapText($message, $length, $qp_mode = false) { $line = explode($this->LE, $message); $message = ''; - for ($i=0 ;$i < count($line); $i++) { + for ($i = 0 ;$i < count($line); $i++) { $line_part = explode(' ', $line[$i]); $buf = ''; for ($e = 0; $emessage_type) { case 'alt': - case 'alt_attachments': + case 'alt_inline': + case 'alt_attach': + case 'alt_inline_attach': $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); break; default: @@ -1077,6 +1137,7 @@ public function CreateHeader() { $uniq_id = md5(uniqid(time())); $this->boundary[1] = 'b1_' . $uniq_id; $this->boundary[2] = 'b2_' . $uniq_id; + $this->boundary[3] = 'b3_' . $uniq_id; $result .= $this->HeaderLine('Date', self::RFCDate()); if($this->Sender == '') { @@ -1125,12 +1186,16 @@ public function CreateHeader() { } if($this->MessageID != '') { - $result .= $this->HeaderLine('Message-ID',$this->MessageID); + $result .= $this->HeaderLine('Message-ID', $this->MessageID); } else { $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); } $result .= $this->HeaderLine('X-Priority', $this->Priority); - $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)'); + if($this->XMailer) { + $result .= $this->HeaderLine('X-Mailer', $this->XMailer); + } else { + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)'); + } if($this->ConfirmReadingTo != '') { $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); @@ -1158,18 +1223,21 @@ public function GetMailMIME() { switch($this->message_type) { case 'plain': $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); - $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); + $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset="'.$this->CharSet.'"'); break; - case 'attachments': - case 'alt_attachments': - if($this->InlineImageExists()){ - $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); - } else { - $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - } + case 'inline': + $result .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'attach': + case 'inline_attach': + case 'alt_attach': + case 'alt_inline_attach': + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; case 'alt': + case 'alt_inline': $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; @@ -1197,6 +1265,33 @@ public function CreateBody() { $this->SetWordWrap(); switch($this->message_type) { + case 'plain': + $body .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'inline': + $body .= $this->GetBoundary($this->boundary[1], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[1]); + break; + case 'attach': + $body .= $this->GetBoundary($this->boundary[1], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); + break; + case 'inline_attach': + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[2]); + $body .= $this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); + break; case 'alt': $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); $body .= $this->EncodeString($this->AltBody, $this->Encoding); @@ -1206,26 +1301,56 @@ public function CreateBody() { $body .= $this->LE.$this->LE; $body .= $this->EndBoundary($this->boundary[1]); break; - case 'plain': + case 'alt_inline': + $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', ''); $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[2]); + $body .= $this->LE; + $body .= $this->EndBoundary($this->boundary[1]); break; - case 'attachments': - $body .= $this->GetBoundary($this->boundary[1], '', '', ''); + case 'alt_attach': + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', ''); $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->EndBoundary($this->boundary[2]); $body .= $this->LE; - $body .= $this->AttachAll(); + $body .= $this->AttachAll("attachment", $this->boundary[1]); break; - case 'alt_attachments': - $body .= sprintf("--%s%s", $this->boundary[1], $this->LE); - $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); - $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body + case 'alt_inline_attach': + $body .= $this->TextLine("--" . $this->boundary[1]); + $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', ''); $body .= $this->EncodeString($this->AltBody, $this->Encoding); $body .= $this->LE.$this->LE; - $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + $body .= $this->TextLine("--" . $this->boundary[2]); + $body .= $this->HeaderLine('Content-Type', 'multipart/related;'); + $body .= $this->TextLine("\tboundary=\"" . $this->boundary[3] . '"'); + $body .= $this->LE; + $body .= $this->GetBoundary($this->boundary[3], '', 'text/html', ''); $body .= $this->EncodeString($this->Body, $this->Encoding); $body .= $this->LE.$this->LE; + $body .= $this->AttachAll("inline", $this->boundary[3]); + $body .= $this->LE; $body .= $this->EndBoundary($this->boundary[2]); - $body .= $this->AttachAll(); + $body .= $this->LE; + $body .= $this->AttachAll("attachment", $this->boundary[1]); break; } @@ -1258,9 +1383,10 @@ public function CreateBody() { /** * Returns the start of a message boundary. - * @access private + * @access protected + * @return string */ - private function GetBoundary($boundary, $charSet, $contentType, $encoding) { + protected function GetBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; if($charSet == '') { $charSet = $this->CharSet; @@ -1272,7 +1398,7 @@ private function GetBoundary($boundary, $charSet, $contentType, $encoding) { $encoding = $this->Encoding; } $result .= $this->TextLine('--' . $boundary); - $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $contentType, $charSet); $result .= $this->LE; $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); $result .= $this->LE; @@ -1282,31 +1408,25 @@ private function GetBoundary($boundary, $charSet, $contentType, $encoding) { /** * Returns the end of a message boundary. - * @access private + * @access protected + * @return string */ - private function EndBoundary($boundary) { + protected function EndBoundary($boundary) { return $this->LE . '--' . $boundary . '--' . $this->LE; } /** * Sets the message type. - * @access private + * @access protected * @return void */ - private function SetMessageType() { - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { - $this->message_type = 'plain'; - } else { - if(count($this->attachment) > 0) { - $this->message_type = 'attachments'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { - $this->message_type = 'alt'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { - $this->message_type = 'alt_attachments'; - } - } + protected function SetMessageType() { + $this->message_type = array(); + if($this->AlternativeExists()) $this->message_type[] = "alt"; + if($this->InlineImageExists()) $this->message_type[] = "inline"; + if($this->AttachmentExists()) $this->message_type[] = "attach"; + $this->message_type = implode("_", $this->message_type); + if($this->message_type == "") $this->message_type = "plain"; } /** @@ -1386,10 +1506,10 @@ public function GetAttachments() { /** * Attaches all fs, string, and binary attachments to the message. * Returns an empty string on failure. - * @access private + * @access protected * @return string */ - private function AttachAll() { + protected function AttachAll($disposition_type, $boundary) { // Return text of body $mime = array(); $cidUniq = array(); @@ -1397,54 +1517,58 @@ private function AttachAll() { // Add all attachments foreach ($this->attachment as $attachment) { - // Check for string attachment - $bString = $attachment[5]; - if ($bString) { - $string = $attachment[0]; - } else { - $path = $attachment[0]; - } + // CHECK IF IT IS A VALID DISPOSITION_FILTER + if($attachment[6] == $disposition_type) { + // Check for string attachment + $bString = $attachment[5]; + if ($bString) { + $string = $attachment[0]; + } else { + $path = $attachment[0]; + } - if (in_array($attachment[0], $incl)) { continue; } - $filename = $attachment[1]; - $name = $attachment[2]; - $encoding = $attachment[3]; - $type = $attachment[4]; - $disposition = $attachment[6]; - $cid = $attachment[7]; - $incl[] = $attachment[0]; - if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } - $cidUniq[$cid] = true; - - $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); - $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); - - if($disposition == 'inline') { - $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - } + $inclhash = md5(serialize($attachment)); + if (in_array($inclhash, $incl)) { continue; } + $incl[] = $inclhash; + $filename = $attachment[1]; + $name = $attachment[2]; + $encoding = $attachment[3]; + $type = $attachment[4]; + $disposition = $attachment[6]; + $cid = $attachment[7]; + if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } + $cidUniq[$cid] = true; + + $mime[] = sprintf("--%s%s", $boundary, $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); - // Encode as string attachment - if($bString) { - $mime[] = $this->EncodeString($string, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } else { - $mime[] = $this->EncodeFile($path, $encoding); - if($this->IsError()) { - return ''; + // Encode as string attachment + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; } - $mime[] = $this->LE.$this->LE; } } - $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + $mime[] = sprintf("--%s--%s", $boundary, $this->LE); - return join('', $mime); + return implode("", $mime); } /** @@ -1453,10 +1577,10 @@ private function AttachAll() { * @param string $path The full path to the file * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' * @see EncodeFile() - * @access private + * @access protected * @return string */ - private function EncodeFile($path, $encoding = 'base64') { + protected function EncodeFile($path, $encoding = 'base64') { try { if (!is_readable($path)) { throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); @@ -1466,13 +1590,15 @@ function get_magic_quotes() { return false; } } - if (PHP_VERSION < 6) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { $magic_quotes = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); } $file_buffer = file_get_contents($path); $file_buffer = $this->EncodeString($file_buffer, $encoding); - if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime($magic_quotes); + } return $file_buffer; } catch (Exception $e) { $this->SetError($e->getMessage()); @@ -1488,7 +1614,7 @@ function get_magic_quotes() { * @access public * @return string */ - public function EncodeString ($str, $encoding = 'base64') { + public function EncodeString($str, $encoding = 'base64') { $encoded = ''; switch(strtolower($encoding)) { case 'base64': @@ -1637,7 +1763,7 @@ public function Base64EncodeWrapMB($str) { * @return string */ public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) { - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); $lines = preg_split('/(?:\r\n|\r|\n)/', $input); $eol = "\r\n"; $escape = '='; @@ -1718,7 +1844,7 @@ public function EncodeQP($string, $line_max = 76, $space_conv = false) { * @access public * @return string */ - public function EncodeQ ($str, $position = 'text') { + public function EncodeQ($str, $position = 'text') { // There should not be any EOL in the string $encoded = preg_replace('/[\r\n]*/', '', $str); @@ -1733,7 +1859,7 @@ public function EncodeQ ($str, $position = 'text') { // Replace every high ascii, control =, ? and _ characters //TODO using /e (equivalent to eval()) is probably not a good idea $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', - "'='.sprintf('%02X', ord('\\1'))", $encoded); + "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded); break; } @@ -1807,6 +1933,20 @@ public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', return true; } + public function AddStringEmbeddedImage($string, $cid, $filename = '', $encoding = 'base64', $type = 'application/octet-stream') { + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $filename, + 2 => basename($filename), + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => 'inline', + 7 => $cid + ); + } + /** * Returns true if an inline attachment is present. * @access public @@ -1821,6 +1961,19 @@ public function InlineImageExists() { return false; } + public function AttachmentExists() { + foreach($this->attachment as $attachment) { + if ($attachment[6] == 'attachment') { + return true; + } + } + return false; + } + + public function AlternativeExists() { + return strlen($this->AltBody)>0; + } + ///////////////////////////////////////////////// // CLASS METHODS, MESSAGE RESET ///////////////////////////////////////////////// @@ -1933,10 +2086,10 @@ public static function RFCDate() { /** * Returns the server hostname or 'localhost.localdomain' if unknown. - * @access private + * @access protected * @return string */ - private function ServerHostname() { + protected function ServerHostname() { if (!empty($this->Hostname)) { $result = $this->Hostname; } elseif (isset($_SERVER['SERVER_NAME'])) { @@ -1950,10 +2103,10 @@ private function ServerHostname() { /** * Returns a message in the appropriate language. - * @access private + * @access protected * @return string */ - private function Lang($key) { + protected function Lang($key) { if(count($this->language) < 1) { $this->SetLanguage('en'); // set the default language } @@ -1976,10 +2129,10 @@ public function IsError() { /** * Changes every end of line from CR or LF to CRLF. - * @access private + * @access public * @return string */ - private function FixEOL($str) { + public function FixEOL($str) { $str = str_replace("\r\n", "\n", $str); $str = str_replace("\r", "\n", $str); $str = str_replace("\n", $this->LE, $str); @@ -2005,16 +2158,16 @@ public function MsgHTML($message, $basedir = '') { if(isset($images[2])) { foreach($images[2] as $i => $url) { // do not change urls for absolute images (thanks to corvuscorax) - if (!preg_match('#^[A-z]+://#',$url)) { + if (!preg_match('#^[A-z]+://#', $url)) { $filename = basename($url); $directory = dirname($url); - ($directory == '.')?$directory='':''; + ($directory == '.') ? $directory='': ''; $cid = 'cid:' . md5($filename); $ext = pathinfo($filename, PATHINFO_EXTENSION); $mimeType = self::_mime_types($ext); - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } - if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { + if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) { $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); } } @@ -2022,7 +2175,7 @@ public function MsgHTML($message, $basedir = '') { } $this->IsHTML(true); $this->Body = $message; - $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message))); if (!empty($textMsg) && empty($this->AltBody)) { $this->AltBody = html_entity_decode($textMsg); } @@ -2192,14 +2345,14 @@ public function Sign($cert_filename, $key_filename, $key_pass) { * @param string $key_pass Password for private key */ public function DKIM_QP($txt) { - $tmp=""; - $line=""; - for ($i=0;$iDKIM_private); - if ($this->DKIM_passphrase!='') { - $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase); + if ($this->DKIM_passphrase != '') { + $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); } else { $privKey = $privKeyStr; } @@ -2230,15 +2383,15 @@ public function DKIM_Sign($s) { * @param string $s Header */ public function DKIM_HeaderC($s) { - $s=preg_replace("/\r\n\s+/"," ",$s); - $lines=explode("\r\n",$s); - foreach ($lines as $key=>$line) { - list($heading,$value)=explode(":",$line,2); - $heading=strtolower($heading); - $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces - $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value - } - $s=implode("\r\n",$lines); + $s = preg_replace("/\r\n\s+/", " ", $s); + $lines = explode("\r\n", $s); + foreach ($lines as $key => $line) { + list($heading, $value) = explode(":", $line, 2); + $heading = strtolower($heading); + $value = preg_replace("/\s+/", " ", $value) ; // Compress useless spaces + $lines[$key] = $heading.":".trim($value) ; // Don't forget to remove WSP around the value + } + $s = implode("\r\n", $lines); return $s; } @@ -2251,11 +2404,11 @@ public function DKIM_HeaderC($s) { public function DKIM_BodyC($body) { if ($body == '') return "\r\n"; // stabilize line endings - $body=str_replace("\r\n","\n",$body); - $body=str_replace("\n","\r\n",$body); + $body = str_replace("\r\n", "\n", $body); + $body = str_replace("\n", "\r\n", $body); // END stabilize line endings - while (substr($body,strlen($body)-4,4) == "\r\n\r\n") { - $body=substr($body,0,strlen($body)-2); + while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { + $body = substr($body, 0, strlen($body) - 2); } return $body; } @@ -2268,23 +2421,23 @@ public function DKIM_BodyC($body) { * @param string $subject Subject * @param string $body Body */ - public function DKIM_Add($headers_line,$subject,$body) { + public function DKIM_Add($headers_line, $subject, $body) { $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body $DKIMquery = 'dns/txt'; // Query method $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) $subject_header = "Subject: $subject"; - $headers = explode("\r\n",$headers_line); + $headers = explode($this->LE, $headers_line); foreach($headers as $header) { - if (strpos($header,'From:') === 0) { - $from_header=$header; - } elseif (strpos($header,'To:') === 0) { - $to_header=$header; + if (strpos($header, 'From:') === 0) { + $from_header = $header; + } elseif (strpos($header, 'To:') === 0) { + $to_header = $header; } } - $from = str_replace('|','=7C',$this->DKIM_QP($from_header)); - $to = str_replace('|','=7C',$this->DKIM_QP($to_header)); - $subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable + $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); + $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); + $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable $body = $this->DKIM_BodyC($body); $DKIMlen = strlen($body) ; // Length of body $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body @@ -2303,10 +2456,10 @@ public function DKIM_Add($headers_line,$subject,$body) { return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n"; } - protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) { + protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) { if (!empty($this->action_function) && function_exists($this->action_function)) { - $params = array($isSent,$to,$cc,$bcc,$subject,$body); - call_user_func_array($this->action_function,$params); + $params = array($isSent, $to, $cc, $bcc, $subject, $body); + call_user_func_array($this->action_function, $params); } } } @@ -2317,4 +2470,4 @@ public function errorMessage() { return $errorMsg; } } -?> \ No newline at end of file +?> diff --git a/class.pop3.php b/class.pop3.php index c69938493..83df20f38 100644 --- a/class.pop3.php +++ b/class.pop3.php @@ -2,15 +2,15 @@ /*~ class.pop3.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | -| Version: 5.1 | -| Contact: via sourceforge.net support pages (also www.codeworxtech.com) | -| Info: http://phpmailer.sourceforge.net | -| Support: http://sourceforge.net/projects/phpmailer/ | +| Version: 5.2 | +| Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | | ------------------------------------------------------------------------- | -| Admin: Andy Prevost (project admininistrator) | +| Admin: Jim Jagielski (project admininistrator) | | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | +| : Jim Jagielski (jimjag) jimjag@gmail.com | | Founder: Brent R. Matzelle (original founder) | +| Copyright (c) 2010-2011, Jim Jagielski. All Rights Reserved. | | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | @@ -19,11 +19,6 @@ | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | -| ------------------------------------------------------------------------- | -| We offer a number of paid services (www.codeworxtech.com): | -| - Web Hosting on highly optimized fast and secure servers | -| - Technology Consulting | -| - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' */ @@ -33,14 +28,16 @@ * @package PHPMailer * @author Andy Prevost * @author Marcus Bointon + * @author Jim Jagielski + * @copyright 2010 - 2011 Jim Jagielski * @copyright 2004 - 2009 Andy Prevost * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL) - * @version $Id$ + * @version $Id: class.pop3.php 450 2010-06-23 16:46:33Z coolbru $ */ /** * POP Before SMTP Authentication Class - * Version 5.0.0 + * Version 5.2.0 * * Author: Richard Davey (rich@corephp.co.uk) * Modifications: Andy Prevost @@ -114,6 +111,12 @@ class POP3 { */ public $password; + /** + * Sets the POP3 PHPMailer Version number + * @var string + */ + public $Version = '5.2'; + ///////////////////////////////////////////////// // PROPERTIES, PRIVATE AND PROTECTED ///////////////////////////////////////////////// @@ -404,4 +407,4 @@ private function catchWarning ($errno, $errstr, $errfile, $errline) { // End of class } -?> \ No newline at end of file +?> diff --git a/class.smtp.php b/class.smtp.php index 6d3f24eff..07c275936 100644 --- a/class.smtp.php +++ b/class.smtp.php @@ -2,15 +2,15 @@ /*~ class.smtp.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | -| Version: 5.1 | -| Contact: via sourceforge.net support pages (also www.codeworxtech.com) | -| Info: http://phpmailer.sourceforge.net | -| Support: http://sourceforge.net/projects/phpmailer/ | +| Version: 5.2 | +| Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ | | ------------------------------------------------------------------------- | -| Admin: Andy Prevost (project admininistrator) | +| Admin: Jim Jagielski (project admininistrator) | | Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net | | : Marcus Bointon (coolbru) coolbru@users.sourceforge.net | +| : Jim Jagielski (jimjag) jimjag@gmail.com | | Founder: Brent R. Matzelle (original founder) | +| Copyright (c) 2010-2011, Jim Jagielski. All Rights Reserved. | | Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | @@ -19,11 +19,6 @@ | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | -| ------------------------------------------------------------------------- | -| We offer a number of paid services (www.codeworxtech.com): | -| - Web Hosting on highly optimized fast and secure servers | -| - Technology Consulting | -| - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' */ @@ -34,8 +29,10 @@ * @author Andy Prevost * @author Marcus Bointon * @copyright 2004 - 2008 Andy Prevost + * @author Jim Jagielski + * @copyright 2010 - 2011 Jim Jagielski * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL) - * @version $Id$ + * @version $Id: class.smtp.php 450 2010-06-23 16:46:33Z coolbru $ */ /** @@ -71,6 +68,12 @@ class SMTP { */ public $do_verp = false; + /** + * Sets the SMTP PHPMailer Version number + * @var string + */ + public $Version = '5.2'; + ///////////////////////////////////////////////// // PROPERTIES, PRIVATE AND PROTECTED ///////////////////////////////////////////////// @@ -811,4 +814,4 @@ private function get_lines() { } -?> \ No newline at end of file +?> diff --git a/docs/Callback_function_notes.txt b/docs/Callback_function_notes.txt new file mode 100644 index 000000000..461ea508e --- /dev/null +++ b/docs/Callback_function_notes.txt @@ -0,0 +1,17 @@ +NEW CALLBACK FUNCTION: +====================== + +We have had requests for a method to process the results of sending emails +through PHPMailer. In this new release, we have implemented a callback +function that passes the results of each email sent (to, cc, and/or bcc). +We have provided an example that echos the results back to the screen. The +callback function can be used for any purpose. With minor modifications, the +callback function can be used to create CSV logs, post results to databases, +etc. + +Please review the test.php script for the example. + +It's pretty straight forward. + +Enjoy! +Andy diff --git a/docs/DomainKeys_notes.txt b/docs/DomainKeys_notes.txt new file mode 100644 index 000000000..2ad10f159 --- /dev/null +++ b/docs/DomainKeys_notes.txt @@ -0,0 +1,55 @@ +CREATE DKIM KEYS and DNS Resource Record: +========================================= + +To create DomainKeys Identified Mail keys, visit: +http://dkim.worxware.com/ +... read the information, fill in the form, and download the ZIP file +containing the public key, private key, DNS Resource Record and instructions +to add to your DNS Zone Record, and the PHPMailer code to enable DKIM +digital signing. + +/*** PROTECT YOUR PRIVATE & PUBLIC KEYS ***/ + +You need to protect your DKIM private and public keys from being viewed or +accessed. Add protection to your .htaccess file as in this example: + +# secure htkeyprivate file + + order allow,deny + deny from all + + +# secure htkeypublic file + + order allow,deny + deny from all + + +(the actual .htaccess additions are in the ZIP file sent back to you from +http://dkim.worxware.com/ + +A few notes on using DomainKey Identified Mail (DKIM): + +You do not need to use PHPMailer to DKIM sign emails IF: +- you enable DomainKey support and add the DNS resource record +- you use your outbound mail server + +If you are a third-party emailer that works on behalf of domain owners to +send their emails from your own server: +- you absolutely have to DKIM sign outbound emails +- the domain owner has to add the DNS resource record to match the + private key, public key, selector, identity, and domain that you create +- use caution with the "selector" ... at least one "selector" will already + exist in the DNS Zone Record of the domain at the domain owner's server + you need to ensure that the "selector" you use is unique +Note: since the IP address will not match the domain owner's DNS Zone record +you can be certain that email providers that validate based on DomainKey will +check the domain owner's DNS Zone record for your DNS resource record. Before +sending out emails on behalf of domain owners, ensure they have entered the +DNS resource record you provided them. + +Enjoy! +Andy + +PS. if you need additional information about DKIM, please see: +http://www.dkim.org/info/dkim-faq.html diff --git a/docs/Note_for_SMTP_debugging.txt b/docs/Note_for_SMTP_debugging.txt new file mode 100644 index 000000000..afb5b58ef --- /dev/null +++ b/docs/Note_for_SMTP_debugging.txt @@ -0,0 +1,23 @@ +If you are having problems connecting or sending emails through your SMTP server, please note: + +1. The new rewrite of class.smtp.php provides more information about the processing/errors taking place +2. Use the debug functionality of class.smtp.php. To do that, in your own script add the debug level you wish to use. An example of that is: + +$mail->SMTPDebug = 1; +$mail->IsSMTP(); // telling the class to use SMTP +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->Port = 26; // set the SMTP port +$mail->Host = "mail.yourhost.com"; // SMTP server +$mail->Username = "name@yourhost.com"; // SMTP account username +$mail->Password = "your password"; // SMTP account password + +Notes on this: +$mail->SMTPDebug = 0; ... will disable debugging (you can also leave this out completely, 0 is the default +$mail->SMTPDebug = 1; ... will echo errors and messages +$mail->SMTPDebug = 2; ... will echo messages only +... and finally, the options are 0, 1, and 2 ... any number greater than 2 will be interpreted as 2 + +And finally, don't forget to disable debugging before going into production. + +Enjoy! +Andy \ No newline at end of file diff --git a/docs/extending.html b/docs/extending.html new file mode 100644 index 000000000..310f97a3b --- /dev/null +++ b/docs/extending.html @@ -0,0 +1,148 @@ + + +Examples using phpmailer + + + + +

Examples using phpmailer

+ +

1. Advanced Example

+

+ +This demonstrates sending out multiple email messages with binary attachments +from a MySQL database with multipart/alternative support.

+ + + + +
+
+require("class.phpmailer.php");
+
+$mail = new phpmailer();
+
+$mail->From     = "list@example.com";
+$mail->FromName = "List manager";
+$mail->Host     = "smtp1.example.com;smtp2.example.com";
+$mail->Mailer   = "smtp";
+
+@MYSQL_CONNECT("localhost","root","password");
+@mysql_select_db("my_company");
+$query  = "SELECT full_name, email, photo FROM employee WHERE id=$id";
+$result = @MYSQL_QUERY($query);
+
+while ($row = mysql_fetch_array ($result))
+{
+    // HTML body
+    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
+    $body .= "<i>Your</i> personal photograph to this message.<p>";
+    $body .= "Sincerely, <br>";
+    $body .= "phpmailer List manager";
+
+    // Plain text body (for mail clients that cannot read HTML)
+    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
+    $text_body .= "Your personal photograph to this message.\n\n";
+    $text_body .= "Sincerely, \n";
+    $text_body .= "phpmailer List manager";
+
+    $mail->Body    = $body;
+    $mail->AltBody = $text_body;
+    $mail->AddAddress($row["email"], $row["full_name"]);
+    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
+
+    if(!$mail->Send())
+        echo "There has been a mail error sending to " . $row["email"] . "<br>";
+
+    // Clear all addresses and attachments for next loop
+    $mail->ClearAddresses();
+    $mail->ClearAttachments();
+}
+
+
+

+ +

2. Extending phpmailer

+

+ +Extending classes with inheritance is one of the most +powerful features of object-oriented +programming. It allows you to make changes to the +original class for your +own personal use without hacking the original +classes. Plus, it is very +easy to do. I've provided an example: + +

+Here's a class that extends the phpmailer class and sets the defaults +for the particular site:
+PHP include file: mail.inc.php +

+ + + + + +
+
+require("class.phpmailer.php");
+
+class my_phpmailer extends phpmailer {
+    // Set default variables for all new objects
+    var $From     = "from@example.com";
+    var $FromName = "Mailer";
+    var $Host     = "smtp1.example.com;smtp2.example.com";
+    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
+    var $WordWrap = 75;
+
+    // Replace the default error_handler
+    function error_handler($msg) {
+        print("My Site Error");
+        print("Description:");
+        printf("%s", $msg);
+        exit;
+    }
+
+    // Create an additional function
+    function do_something($something) {
+        // Place your new code here
+    }
+}
+
+
+ +Now here's a normal PHP page in the site, which will have all the defaults set +above:
+Normal PHP file: mail_test.php +

+ + + + + +
+
+require("mail.inc.php");
+
+// Instantiate your new class
+$mail = new my_phpmailer;
+
+// Now you only need to add the necessary stuff
+$mail->AddAddress("josh@example.com", "Josh Adams");
+$mail->Subject = "Here is the subject";
+$mail->Body    = "This is the message body";
+$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
+
+if(!$mail->Send())
+{
+   echo "There was an error sending the message";
+   exit;
+}
+
+echo "Message was sent successfully";
+
+
+

+ + + diff --git a/docs/faq.html b/docs/faq.html new file mode 100644 index 000000000..f71c6c892 --- /dev/null +++ b/docs/faq.html @@ -0,0 +1,67 @@ + + +PHPMailer FAQ + + + +
+
+

PHPMailer FAQ

+
    + +
  • Q: I'm using the SMTP mailer and I keep on getting a timeout message + well before the X seconds I set it for. What gives?
    + A: PHP versions 4.0.4pl1 and earlier have a bug in which sockets timeout + early. You can fix this by re-compiling PHP 4.0.4pl1 with this fix: + timeoutfix.diff. Otherwise you can wait for the new PHP release.

  • + +
  • Q: I am concerned that using include files will take up too much + processing time on my computer. How can I make it run faster?
    + A: PHP by itself is very fast. Much faster than ASP or JSP running on + the same type of server. This is because it has very little overhead compared + to its competitors and it pre-compiles all of + its code before it runs each script (in PHP4). However, all of + this compiling and re-compiling can take up a lot of valuable + computer resources. However, there are programs out there that compile + PHP code and store it in memory (or on mmaped files) to reduce the + processing immensely. Two of these: APC + (Alternative PHP Cache) and Afterburner + (Win32 download) + are excellent free tools that do just this. If you have the money + you might also try Zend Cache, it is + even faster than the open source varieties. All of these tools make your + scripts run faster while also reducing the load on your server. I have tried + them myself and they are quite stable too.

  • + +
  • Q: What mailer gives me the best performance?
    + A: On a single machine the sendmail (or Qmail) is fastest overall. + Next fastest is mail() to give you the best performance. Both do not have the overhead of SMTP. + If you have you have your mail server on a another machine then + SMTP is your only option, but you do get the benefit of redundant mail servers.
    + If you are running a mailing list with thousands of names, the fastest mailers in order are: SMTP, sendmail (or Qmail), mail().

  • + +
  • Q: When I try to attach a file with on my server I get a + "Could not find {file} on filesystem error". Why is this?
    + A: If you are using a Unix machine this is probably because the user + running your web server does not have read access to the directory in question. If you are using Windows, + then the problem probably is that you have used single backslashes to denote directories (\). + A single backslash has a special meaning to PHP so these are not + valid. Instead use double backslashes ("\\") or a single forward + slash ("/").

  • + +
+ +
+
+ + + diff --git a/docs/pop3_article.txt b/docs/pop3_article.txt new file mode 100644 index 000000000..cc54f7c00 --- /dev/null +++ b/docs/pop3_article.txt @@ -0,0 +1,39 @@ +This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. + +With that noted, here is how to implement it: +Install the class file + +I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: +[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] +When you need it, create your POP3 object + +Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: +[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] + +The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. +The Parameters + +The Authorise parameters are as follows: +[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] + + 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) + 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) + 3. 30 - A connection time-out value (in seconds) + 4. mailer - The POP3 Username required to logon + 5. password - The POP3 Password required to logon + 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) + +Final Comments + the Download + +1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. + +2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. + +3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. + +4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. +Download + +Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. + +My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) diff --git a/docs/use_gmail.txt b/docs/use_gmail.txt new file mode 100644 index 000000000..7519d7d2f --- /dev/null +++ b/docs/use_gmail.txt @@ -0,0 +1,45 @@ +getFile('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPSecure = "ssl"; // sets the prefix to the servier +$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server +$mail->Port = 465; // set the SMTP port + +$mail->Username = "yourname@gmail.com"; // GMAIL username +$mail->Password = "password"; // GMAIL password + +$mail->From = "replyto@yourdomain.com"; +$mail->FromName = "Webmaster"; +$mail->Subject = "This is the subject"; +$mail->AltBody = "This is the body when user views in plain text format"; //Text Body +$mail->WordWrap = 50; // set word wrap + +$mail->MsgHTML($body); + +$mail->AddReplyTo("replyto@yourdomain.com","Webmaster"); + +$mail->AddAttachment("/path/to/file.zip"); // attachment +$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment + +$mail->AddAddress("username@domain.com","First Last"); + +$mail->IsHTML(true); // send as HTML + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message has been sent"; +} + +?> diff --git a/examples/contents.html b/examples/contents.html index 3d445ba42..fc4c30883 100644 --- a/examples/contents.html +++ b/examples/contents.html @@ -1,20 +1,20 @@ - -
-

-
- This is a test of PHPMailer.
-
-This particular example uses HTML, with a <div> tag and inline
-styles.
-
-Also note the use of the PHPMailer logo above with no specific code to handle -including it.
-Included are two attachments:
-phpmailer.gif is an attachment and used inline as a graphic (above)
-phpmailer_mini.gif is an attachment
-
-PHPMailer:
-Author: Andy Prevost (codeworxtech@users.sourceforge.net)
-Author: Marcus Bointon (coolbru@users.sourceforge.net)
-
- + +
+

+
+ This is a test of PHPMailer.
+
+This particular example uses HTML, with a <div> tag and inline
+styles.
+
+Also note the use of the PHPMailer logo above with no specific code to handle +including it.
+Included are two attachments:
+phpmailer.gif is an attachment and used inline as a graphic (above)
+phpmailer_mini.gif is an attachment
+
+PHPMailer:
+Author: Andy Prevost (codeworxtech@users.sourceforge.net)
+Author: Marcus Bointon (coolbru@users.sourceforge.net)
+
+ diff --git a/examples/index.html b/examples/index.html index c81e35bcb..c829bbcc7 100644 --- a/examples/index.html +++ b/examples/index.html @@ -1,49 +1,49 @@ -This release of PHPMailer (v5.0.0) sets a new milestone in the development -cycle of PHPMailer. First, class.phpmailer.php has a small footprint (65.7 Kb), -while class.smtp.php is even smaller than before (at only 25.0 Kb).
-
-We have maintained all functionality and added Exception handling unique to -PHP 5/6.
-
-There is only one function that has been removed: that is getFile(). The reason -for this is that getFile() became a wrapper for the PHP function 'file_get_contents()' -and nothing more. Rather than burden the class with a function already available -in PHP, we decided to remove it.
-
-Our new Exception handling provides your own scripts far more power than ever.
-
-We have also enhanced the "packaging" of PHPMailer with an entirely new set of -examples. Included are both basic and advanced examples showing how you can take -advantage of PHP Exception handling to improve your own scripts.
-
-A few things to note about PHPMailer: -
    -
  • the use of $mail->AltBody is completely optional. If not used, PHPMailer - will use the HTML text with htmlentities().
    - We also highly recommend using HTML2Text authored by Jon Abernathy. The class description - and download can be viewed at: http://www.chuggnutt.com/html2text.php. -
  • -
  • there is no specific code to define image or attachment types ... that is handled - automatically by PHPMailer when it parses the images
  • -
-A note to users that want to use SMTP with PHPMailer. The most common problems are: -
    -
  • wrong port ... most ISP (Internet Service Providers) will not allow relaying through - their servers. If that's the case with your ISP, try using port 26. -
  • -
  • wrong authentication information (username and/or password) ... don't forget that - many servers require the account name to be in the format of the full email address. -
  • -
  • ... if these tips do not get your SMTP settings working, we have a debug mode - for helping you determine the problem. Insert this after $mail->IsSMTP();
    - $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
    - note that a setting of 2 will display all errors and messages generated by the SMTP - server
    -
  • -
-Our examples all use an HTML file in the /examples folder. To see what the email SHOULD -look like in your HTML compatible email viewer: click here
-
-From the PHPMailer team:
-Author: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net (and Project Administrator)
-Author: Marcus Bointon (coolbru) coolbru@users.sourceforge.net
+This release of PHPMailer (v5.0.0) sets a new milestone in the development +cycle of PHPMailer. First, class.phpmailer.php has a small footprint (65.7 Kb), +while class.smtp.php is even smaller than before (at only 25.0 Kb).
+
+We have maintained all functionality and added Exception handling unique to +PHP 5/6.
+
+There is only one function that has been removed: that is getFile(). The reason +for this is that getFile() became a wrapper for the PHP function 'file_get_contents()' +and nothing more. Rather than burden the class with a function already available +in PHP, we decided to remove it.
+
+Our new Exception handling provides your own scripts far more power than ever.
+
+We have also enhanced the "packaging" of PHPMailer with an entirely new set of +examples. Included are both basic and advanced examples showing how you can take +advantage of PHP Exception handling to improve your own scripts.
+
+A few things to note about PHPMailer: +
    +
  • the use of $mail->AltBody is completely optional. If not used, PHPMailer + will use the HTML text with htmlentities().
    + We also highly recommend using HTML2Text authored by Jon Abernathy. The class description + and download can be viewed at: http://www.chuggnutt.com/html2text.php. +
  • +
  • there is no specific code to define image or attachment types ... that is handled + automatically by PHPMailer when it parses the images
  • +
+A note to users that want to use SMTP with PHPMailer. The most common problems are: +
    +
  • wrong port ... most ISP (Internet Service Providers) will not allow relaying through + their servers. If that's the case with your ISP, try using port 26. +
  • +
  • wrong authentication information (username and/or password) ... don't forget that + many servers require the account name to be in the format of the full email address. +
  • +
  • ... if these tips do not get your SMTP settings working, we have a debug mode + for helping you determine the problem. Insert this after $mail->IsSMTP();
    + $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
    + note that a setting of 2 will display all errors and messages generated by the SMTP + server
    +
  • +
+Our examples all use an HTML file in the /examples folder. To see what the email SHOULD +look like in your HTML compatible email viewer: click here
+
+From the PHPMailer team:
+Author: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net (and Project Administrator)
+Author: Marcus Bointon (coolbru) coolbru@users.sourceforge.net
diff --git a/examples/test_db_smtp_basic.php b/examples/test_db_smtp_basic.php index 85d01f8d5..9c16fb0bf 100644 --- a/examples/test_db_smtp_basic.php +++ b/examples/test_db_smtp_basic.php @@ -1,58 +1,58 @@ - - -PHPMailer - MySQL Database - SMTP basic test with authentication - - - -IsSMTP(); // telling the class to use SMTP -$mail->Host = "smtp1.site.com;smtp2.site.com"; -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent -$mail->Host = "mail.yourdomain.com"; // sets the SMTP server -$mail->Port = 26; // set the SMTP port for the GMAIL server -$mail->Username = "yourname@yourdomain"; // SMTP account username -$mail->Password = "yourpassword"; // SMTP account password -$mail->SetFrom('list@mydomain.com', 'List manager'); -$mail->AddReplyTo('list@mydomain.com', 'List manager'); - -$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; - -@MYSQL_CONNECT("localhost","root","password"); -@mysql_select_db("my_company"); -$query = "SELECT full_name, email, photo FROM employee WHERE id=$id"; -$result = @MYSQL_QUERY($query); - -while ($row = mysql_fetch_array ($result)) { - $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - $mail->MsgHTML($body); - $mail->AddAddress($row["email"], $row["full_name"]); - $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg"); - - if(!$mail->Send()) { - echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '
'; - } else { - echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')
'; - } - // Clear all addresses and attachments for next loop - $mail->ClearAddresses(); - $mail->ClearAttachments(); -} -?> - - - + + +PHPMailer - MySQL Database - SMTP basic test with authentication + + + +IsSMTP(); // telling the class to use SMTP +$mail->Host = "smtp1.site.com;smtp2.site.com"; +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent +$mail->Host = "mail.yourdomain.com"; // sets the SMTP server +$mail->Port = 26; // set the SMTP port for the GMAIL server +$mail->Username = "yourname@yourdomain"; // SMTP account username +$mail->Password = "yourpassword"; // SMTP account password +$mail->SetFrom('list@mydomain.com', 'List manager'); +$mail->AddReplyTo('list@mydomain.com', 'List manager'); + +$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; + +@MYSQL_CONNECT("localhost","root","password"); +@mysql_select_db("my_company"); +$query = "SELECT full_name, email, photo FROM employee WHERE id=$id"; +$result = @MYSQL_QUERY($query); + +while ($row = mysql_fetch_array ($result)) { + $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + $mail->MsgHTML($body); + $mail->AddAddress($row["email"], $row["full_name"]); + $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg"); + + if(!$mail->Send()) { + echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '
'; + } else { + echo "Message sent to :" . $row["full_name"] . ' (' . str_replace("@", "@", $row["email"]) . ')
'; + } + // Clear all addresses and attachments for next loop + $mail->ClearAddresses(); + $mail->ClearAttachments(); +} +?> + + + diff --git a/examples/test_mail_advanced.php b/examples/test_mail_advanced.php index db0dd53bf..38e27902d 100644 --- a/examples/test_mail_advanced.php +++ b/examples/test_mail_advanced.php @@ -1,31 +1,31 @@ - - -PHPMailer - Mail() advanced test - - - -AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); - $mail->SetFrom('name@yourdomain.com', 'First Last'); - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} -?> - - + + +PHPMailer - Mail() advanced test + + + +AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); + $mail->SetFrom('name@yourdomain.com', 'First Last'); + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} +?> + + diff --git a/examples/test_mail_basic.php b/examples/test_mail_basic.php index 5db9f8fb6..f8411fb00 100644 --- a/examples/test_mail_basic.php +++ b/examples/test_mail_basic.php @@ -1,43 +1,43 @@ - - -PHPMailer - Mail() basic test - - - -AddReplyTo("name@yourdomain.com","First Last"); - -$mail->SetFrom('name@yourdomain.com', 'First Last'); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$address = "whoto@otherdomain.com"; -$mail->AddAddress($address, "John Doe"); - -$mail->Subject = "PHPMailer Test Subject via mail(), basic"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment -$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> - - - + + +PHPMailer - Mail() basic test + + + +AddReplyTo("name@yourdomain.com","First Last"); + +$mail->SetFrom('name@yourdomain.com', 'First Last'); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$address = "whoto@otherdomain.com"; +$mail->AddAddress($address, "John Doe"); + +$mail->Subject = "PHPMailer Test Subject via mail(), basic"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment +$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> + + + diff --git a/examples/test_pop_before_smtp_advanced.php b/examples/test_pop_before_smtp_advanced.php index 1828b30b5..ee9d839eb 100644 --- a/examples/test_pop_before_smtp_advanced.php +++ b/examples/test_pop_before_smtp_advanced.php @@ -1,40 +1,40 @@ - - -POP before SMTP Test - - - -Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1); - -$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch - -$mail->IsSMTP(); - -try { - $mail->SMTPDebug = 2; - $mail->Host = 'pop3.yourdomain.com'; - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); - $mail->SetFrom('name@yourdomain.com', 'First Last'); - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} -?> - - - + + +POP before SMTP Test + + + +Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1); + +$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch + +$mail->IsSMTP(); + +try { + $mail->SMTPDebug = 2; + $mail->Host = 'pop3.yourdomain.com'; + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); + $mail->SetFrom('name@yourdomain.com', 'First Last'); + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} +?> + + + diff --git a/examples/test_pop_before_smtp_basic.php b/examples/test_pop_before_smtp_basic.php index 3673436a2..f01bd824e 100644 --- a/examples/test_pop_before_smtp_basic.php +++ b/examples/test_pop_before_smtp_basic.php @@ -1,49 +1,49 @@ - - -POP before SMTP Test - - - -Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1); - -$mail = new PHPMailer(); - -$body = file_get_contents('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); -$mail->SMTPDebug = 2; -$mail->Host = 'pop3.yourdomain.com'; - -$mail->SetFrom('name@yourdomain.com', 'First Last'); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$mail->Subject = "PHPMailer Test Subject via POP before SMTP, basic"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$address = "whoto@otherdomain.com"; -$mail->AddAddress($address, "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment -$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment - - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> - - - + + +POP before SMTP Test + + + +Authorise('pop3.yourdomain.com', 110, 30, 'username', 'password', 1); + +$mail = new PHPMailer(); + +$body = file_get_contents('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->IsSMTP(); +$mail->SMTPDebug = 2; +$mail->Host = 'pop3.yourdomain.com'; + +$mail->SetFrom('name@yourdomain.com', 'First Last'); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$mail->Subject = "PHPMailer Test Subject via POP before SMTP, basic"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$address = "whoto@otherdomain.com"; +$mail->AddAddress($address, "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment +$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment + + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> + + + diff --git a/examples/test_sendmail_advanced.php b/examples/test_sendmail_advanced.php index 460245250..937d31e8e 100644 --- a/examples/test_sendmail_advanced.php +++ b/examples/test_sendmail_advanced.php @@ -1,34 +1,34 @@ - - -PHPMailer - Sendmail advanced test - - - -IsSendmail(); // telling the class to use SendMail transport - -try { - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); - $mail->SetFrom('name@yourdomain.com', 'First Last'); - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} -?> - - - + + +PHPMailer - Sendmail advanced test + + + +IsSendmail(); // telling the class to use SendMail transport + +try { + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); + $mail->SetFrom('name@yourdomain.com', 'First Last'); + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} +?> + + + diff --git a/examples/test_sendmail_basic.php b/examples/test_sendmail_basic.php index 46c05e39a..f70b0f062 100644 --- a/examples/test_sendmail_basic.php +++ b/examples/test_sendmail_basic.php @@ -1,45 +1,45 @@ - - -PHPMailer - Sendmail basic test - - - -IsSendmail(); // telling the class to use SendMail transport - -$body = file_get_contents('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$mail->SetFrom('name@yourdomain.com', 'First Last'); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$address = "whoto@otherdomain.com"; -$mail->AddAddress($address, "John Doe"); - -$mail->Subject = "PHPMailer Test Subject via Sendmail, basic"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment -$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> - - - + + +PHPMailer - Sendmail basic test + + + +IsSendmail(); // telling the class to use SendMail transport + +$body = file_get_contents('contents.html'); +$body = eregi_replace("[\]",'',$body); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$mail->SetFrom('name@yourdomain.com', 'First Last'); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$address = "whoto@otherdomain.com"; +$mail->AddAddress($address, "John Doe"); + +$mail->Subject = "PHPMailer Test Subject via Sendmail, basic"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment +$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> + + + diff --git a/examples/test_smtp_advanced.php b/examples/test_smtp_advanced.php index 71a8614af..9013c8a46 100644 --- a/examples/test_smtp_advanced.php +++ b/examples/test_smtp_advanced.php @@ -1,43 +1,43 @@ - - -PHPMailer - SMTP advanced test with authentication - - - -IsSMTP(); // telling the class to use SMTP - -try { - $mail->Host = "mail.yourdomain.com"; // SMTP server - $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) - $mail->SMTPAuth = true; // enable SMTP authentication - $mail->Host = "mail.yourdomain.com"; // sets the SMTP server - $mail->Port = 26; // set the SMTP port for the GMAIL server - $mail->Username = "yourname@yourdomain"; // SMTP account username - $mail->Password = "yourpassword"; // SMTP account password - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); - $mail->SetFrom('name@yourdomain.com', 'First Last'); - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} -?> - - - + + +PHPMailer - SMTP advanced test with authentication + + + +IsSMTP(); // telling the class to use SMTP + +try { + $mail->Host = "mail.yourdomain.com"; // SMTP server + $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) + $mail->SMTPAuth = true; // enable SMTP authentication + $mail->Host = "mail.yourdomain.com"; // sets the SMTP server + $mail->Port = 26; // set the SMTP port for the GMAIL server + $mail->Username = "yourname@yourdomain"; // SMTP account username + $mail->Password = "yourpassword"; // SMTP account password + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); + $mail->SetFrom('name@yourdomain.com', 'First Last'); + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} +?> + + + diff --git a/examples/test_smtp_advanced_no_auth.php b/examples/test_smtp_advanced_no_auth.php index 69b9b5d4b..101d2e2b8 100644 --- a/examples/test_smtp_advanced_no_auth.php +++ b/examples/test_smtp_advanced_no_auth.php @@ -1,37 +1,37 @@ - - -PHPMailer - SMTP advanced test with no authentication - - - -IsSMTP(); // telling the class to use SMTP - -try { - $mail->Host = "mail.yourdomain.com"; // SMTP server - $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); - $mail->SetFrom('name@yourdomain.com', 'First Last'); - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} -?> - - - + + +PHPMailer - SMTP advanced test with no authentication + + + +IsSMTP(); // telling the class to use SMTP + +try { + $mail->Host = "mail.yourdomain.com"; // SMTP server + $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); + $mail->SetFrom('name@yourdomain.com', 'First Last'); + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} +?> + + + diff --git a/examples/test_smtp_basic.php b/examples/test_smtp_basic.php index f92c53132..145f2acf3 100644 --- a/examples/test_smtp_basic.php +++ b/examples/test_smtp_basic.php @@ -1,58 +1,58 @@ - - -PHPMailer - SMTP basic test with authentication - - - -IsSMTP(); // telling the class to use SMTP -$mail->Host = "mail.yourdomain.com"; // SMTP server -$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) - // 1 = errors and messages - // 2 = messages only -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->Host = "mail.yourdomain.com"; // sets the SMTP server -$mail->Port = 26; // set the SMTP port for the GMAIL server -$mail->Username = "yourname@yourdomain"; // SMTP account username -$mail->Password = "yourpassword"; // SMTP account password - -$mail->SetFrom('name@yourdomain.com', 'First Last'); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$address = "whoto@otherdomain.com"; -$mail->AddAddress($address, "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment -$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> - - - + + +PHPMailer - SMTP basic test with authentication + + + +IsSMTP(); // telling the class to use SMTP +$mail->Host = "mail.yourdomain.com"; // SMTP server +$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) + // 1 = errors and messages + // 2 = messages only +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->Host = "mail.yourdomain.com"; // sets the SMTP server +$mail->Port = 26; // set the SMTP port for the GMAIL server +$mail->Username = "yourname@yourdomain"; // SMTP account username +$mail->Password = "yourpassword"; // SMTP account password + +$mail->SetFrom('name@yourdomain.com', 'First Last'); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$address = "whoto@otherdomain.com"; +$mail->AddAddress($address, "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment +$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> + + + diff --git a/examples/test_smtp_basic_no_auth.php b/examples/test_smtp_basic_no_auth.php index d96cda252..fe72ffa97 100644 --- a/examples/test_smtp_basic_no_auth.php +++ b/examples/test_smtp_basic_no_auth.php @@ -1,53 +1,53 @@ - - -PHPMailer - SMTP basic test with no authentication - - - -IsSMTP(); // telling the class to use SMTP -$mail->Host = "mail.yourdomain.com"; // SMTP server -$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) - // 1 = errors and messages - // 2 = messages only - -$mail->SetFrom('name@yourdomain.com', 'First Last'); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$mail->Subject = "PHPMailer Test Subject via smtp, basic with no authentication"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$address = "whoto@otherdomain.com"; -$mail->AddAddress($address, "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment -$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> - - - + + +PHPMailer - SMTP basic test with no authentication + + + +IsSMTP(); // telling the class to use SMTP +$mail->Host = "mail.yourdomain.com"; // SMTP server +$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) + // 1 = errors and messages + // 2 = messages only + +$mail->SetFrom('name@yourdomain.com', 'First Last'); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$mail->Subject = "PHPMailer Test Subject via smtp, basic with no authentication"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$address = "whoto@otherdomain.com"; +$mail->AddAddress($address, "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment +$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> + + + diff --git a/examples/test_smtp_gmail_advanced.php b/examples/test_smtp_gmail_advanced.php index 055cc618a..10d986073 100644 --- a/examples/test_smtp_gmail_advanced.php +++ b/examples/test_smtp_gmail_advanced.php @@ -1,43 +1,43 @@ - - -PHPMailer - SMTP (Gmail) advanced test - - - -IsSMTP(); // telling the class to use SMTP - -try { - $mail->Host = "mail.yourdomain.com"; // SMTP server - $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) - $mail->SMTPAuth = true; // enable SMTP authentication - $mail->SMTPSecure = "ssl"; // sets the prefix to the servier - $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server - $mail->Port = 465; // set the SMTP port for the GMAIL server - $mail->Username = "yourusername@gmail.com"; // GMAIL username - $mail->Password = "yourpassword"; // GMAIL password - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); - $mail->SetFrom('name@yourdomain.com', 'First Last'); - $mail->AddReplyTo('name@yourdomain.com', 'First Last'); - $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} -?> - - - + + +PHPMailer - SMTP (Gmail) advanced test + + + +IsSMTP(); // telling the class to use SMTP + +try { + $mail->Host = "mail.yourdomain.com"; // SMTP server + $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) + $mail->SMTPAuth = true; // enable SMTP authentication + $mail->SMTPSecure = "ssl"; // sets the prefix to the servier + $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server + $mail->Port = 465; // set the SMTP port for the GMAIL server + $mail->Username = "yourusername@gmail.com"; // GMAIL username + $mail->Password = "yourpassword"; // GMAIL password + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); + $mail->SetFrom('name@yourdomain.com', 'First Last'); + $mail->AddReplyTo('name@yourdomain.com', 'First Last'); + $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} +?> + + + diff --git a/examples/test_smtp_gmail_basic.php b/examples/test_smtp_gmail_basic.php index 3f5788079..abe22c52a 100644 --- a/examples/test_smtp_gmail_basic.php +++ b/examples/test_smtp_gmail_basic.php @@ -1,59 +1,59 @@ - - -PHPMailer - SMTP (Gmail) basic test - - - -IsSMTP(); // telling the class to use SMTP -$mail->Host = "mail.yourdomain.com"; // SMTP server -$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) - // 1 = errors and messages - // 2 = messages only -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->SMTPSecure = "ssl"; // sets the prefix to the servier -$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server -$mail->Port = 465; // set the SMTP port for the GMAIL server -$mail->Username = "yourusername@gmail.com"; // GMAIL username -$mail->Password = "yourpassword"; // GMAIL password - -$mail->SetFrom('name@yourdomain.com', 'First Last'); - -$mail->AddReplyTo("name@yourdomain.com","First Last"); - -$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$address = "whoto@otherdomain.com"; -$mail->AddAddress($address, "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment -$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> - - - + + +PHPMailer - SMTP (Gmail) basic test + + + +IsSMTP(); // telling the class to use SMTP +$mail->Host = "mail.yourdomain.com"; // SMTP server +$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) + // 1 = errors and messages + // 2 = messages only +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->SMTPSecure = "ssl"; // sets the prefix to the servier +$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server +$mail->Port = 465; // set the SMTP port for the GMAIL server +$mail->Username = "yourusername@gmail.com"; // GMAIL username +$mail->Password = "yourpassword"; // GMAIL password + +$mail->SetFrom('name@yourdomain.com', 'First Last'); + +$mail->AddReplyTo("name@yourdomain.com","First Last"); + +$mail->Subject = "PHPMailer Test Subject via smtp (Gmail), basic"; + +$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + +$mail->MsgHTML($body); + +$address = "whoto@otherdomain.com"; +$mail->AddAddress($address, "John Doe"); + +$mail->AddAttachment("images/phpmailer.gif"); // attachment +$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment + +if(!$mail->Send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} + +?> + + + diff --git a/extras/htmlfilter.php b/extras/htmlfilter.php new file mode 100644 index 000000000..d75447dea --- /dev/null +++ b/extras/htmlfilter.php @@ -0,0 +1,861 @@ + + * @Version 1.1 ($Date: 2011-07-04 14:02:23 -0400 (Mon, 04 Jul 2011) $) + */ + +/** + * @Author Jim Jagielski + */ + +/** + * This function returns the final tag out of the tag name, an array + * of attributes, and the type of the tag. This function is called by + * tln_sanitize internally. + * + * @param $tagname the name of the tag. + * @param $attary the array of attributes and their values + * @param $tagtype The type of the tag (see in comments). + * @return a string with the final tag representation. + */ +function tln_tagprint($tagname, $attary, $tagtype){ + $me = 'tln_tagprint'; + if ($tagtype == 2){ + $fulltag = ''; + } else { + $fulltag = '<' . $tagname; + if (is_array($attary) && sizeof($attary)){ + $atts = Array(); + while (list($attname, $attvalue) = each($attary)){ + array_push($atts, "$attname=$attvalue"); + } + $fulltag .= ' ' . join(' ', $atts); + } + if ($tagtype == 3){ + $fulltag .= ' /'; + } + $fulltag .= '>'; + } + return $fulltag; +} + +/** + * A small helper function to use with array_walk. Modifies a by-ref + * value and makes it lowercase. + * + * @param $val a value passed by-ref. + * @return void since it modifies a by-ref value. + */ +function tln_casenormalize(&$val){ + $val = strtolower($val); +} + +/** + * This function skips any whitespace from the current position within + * a string and to the next non-whitespace value. + * + * @param $body the string + * @param $offset the offset within the string where we should start + * looking for the next non-whitespace character. + * @return the location within the $body where the next + * non-whitespace char is located. + */ +function tln_skipspace($body, $offset){ + $me = 'tln_skipspace'; + preg_match('/^(\s*)/s', substr($body, $offset), $matches); + if (sizeof($matches[1])){ + $count = strlen($matches[1]); + $offset += $count; + } + return $offset; +} + +/** + * This function looks for the next character within a string. It's + * really just a glorified "strpos", except it catches the failures + * nicely. + * + * @param $body The string to look for needle in. + * @param $offset Start looking from this position. + * @param $needle The character/string to look for. + * @return location of the next occurance of the needle, or + * strlen($body) if needle wasn't found. + */ +function tln_findnxstr($body, $offset, $needle){ + $me = 'tln_findnxstr'; + $pos = strpos($body, $needle, $offset); + if ($pos === FALSE){ + $pos = strlen($body); + } + return $pos; +} + +/** + * This function takes a PCRE-style regexp and tries to match it + * within the string. + * + * @param $body The string to look for needle in. + * @param $offset Start looking from here. + * @param $reg A PCRE-style regex to match. + * @return Returns a false if no matches found, or an array + * with the following members: + * - integer with the location of the match within $body + * - string with whatever content between offset and the match + * - string with whatever it is we matched + */ +function tln_findnxreg($body, $offset, $reg){ + $me = 'tln_findnxreg'; + $matches = Array(); + $retarr = Array(); + $preg_rule = '%^(.*?)(' . $reg . ')%s'; + preg_match($preg_rule, substr($body, $offset), $matches); + if (!isset($matches[0])){ + $retarr = false; + } else { + $retarr[0] = $offset + strlen($matches[1]); + $retarr[1] = $matches[1]; + $retarr[2] = $matches[2]; + } + return $retarr; +} + +/** + * This function looks for the next tag. + * + * @param $body String where to look for the next tag. + * @param $offset Start looking from here. + * @return false if no more tags exist in the body, or + * an array with the following members: + * - string with the name of the tag + * - array with attributes and their values + * - integer with tag type (1, 2, or 3) + * - integer where the tag starts (starting "<") + * - integer where the tag ends (ending ">") + * first three members will be false, if the tag is invalid. + */ +function tln_getnxtag($body, $offset){ + $me = 'tln_getnxtag'; + if ($offset > strlen($body)){ + return false; + } + $lt = tln_findnxstr($body, $offset, '<'); + if ($lt == strlen($body)){ + return false; + } + /** + * We are here: + * blah blah + * \---------^ + */ + $pos = tln_skipspace($body, $lt + 1); + if ($pos >= strlen($body)){ + return Array(false, false, false, $lt, strlen($body)); + } + /** + * There are 3 kinds of tags: + * 1. Opening tag, e.g.: + * + * 2. Closing tag, e.g.: + * + * 3. XHTML-style content-less tag, e.g.: + * + */ + $tagtype = false; + switch (substr($body, $pos, 1)){ + case '/': + $tagtype = 2; + $pos++; + break; + case '!': + /** + * A comment or an SGML declaration. + */ + if (substr($body, $pos+1, 2) == '--'){ + $gt = strpos($body, '-->', $pos); + if ($gt === false){ + $gt = strlen($body); + } else { + $gt += 2; + } + return Array(false, false, false, $lt, $gt); + } else { + $gt = tln_findnxstr($body, $pos, '>'); + return Array(false, false, false, $lt, $gt); + } + break; + default: + /** + * Assume tagtype 1 for now. If it's type 3, we'll switch values + * later. + */ + $tagtype = 1; + break; + } + + $tag_start = $pos; + $tagname = ''; + /** + * Look for next [\W-_], which will indicate the end of the tag name. + */ + $regary = tln_findnxreg($body, $pos, '[^\w\-_]'); + if ($regary == false){ + return Array(false, false, false, $lt, strlen($body)); + } + list($pos, $tagname, $match) = $regary; + $tagname = strtolower($tagname); + + /** + * $match can be either of these: + * '>' indicating the end of the tag entirely. + * '\s' indicating the end of the tag name. + * '/' indicating that this is type-3 xhtml tag. + * + * Whatever else we find there indicates an invalid tag. + */ + switch ($match){ + case '/': + /** + * This is an xhtml-style tag with a closing / at the + * end, like so: . Check if it's followed + * by the closing bracket. If not, then this tag is invalid + */ + if (substr($body, $pos, 2) == '/>'){ + $pos++; + $tagtype = 3; + } else { + $gt = tln_findnxstr($body, $pos, '>'); + $retary = Array(false, false, false, $lt, $gt); + return $retary; + } + case '>': + return Array($tagname, false, $tagtype, $lt, $pos); + break; + default: + /** + * Check if it's whitespace + */ + if (preg_match('/\s/', $match)){ + } else { + /** + * This is an invalid tag! Look for the next closing ">". + */ + $gt = tln_findnxstr($body, $lt, '>'); + return Array(false, false, false, $lt, $gt); + } + } + + /** + * At this point we're here: + * + * \-------^ + * + * At this point we loop in order to find all attributes. + */ + $attname = ''; + $atttype = false; + $attary = Array(); + + while ($pos <= strlen($body)){ + $pos = tln_skipspace($body, $pos); + if ($pos == strlen($body)){ + /** + * Non-closed tag. + */ + return Array(false, false, false, $lt, $pos); + } + /** + * See if we arrived at a ">" or "/>", which means that we reached + * the end of the tag. + */ + $matches = Array(); + preg_match('%^(\s*)(>|/>)%s', substr($body, $pos), $matches); + if (isset($matches[0]) && $matches[0]){ + /** + * Yep. So we did. + */ + $pos += strlen($matches[1]); + if ($matches[2] == '/>'){ + $tagtype = 3; + $pos++; + } + return Array($tagname, $attary, $tagtype, $lt, $pos); + } + + /** + * There are several types of attributes, with optional + * [:space:] between members. + * Type 1: + * attrname[:space:]=[:space:]'CDATA' + * Type 2: + * attrname[:space:]=[:space:]"CDATA" + * Type 3: + * attr[:space:]=[:space:]CDATA + * Type 4: + * attrname + * + * We leave types 1 and 2 the same, type 3 we check for + * '"' and convert to """ if needed, then wrap in + * double quotes. Type 4 we convert into: + * attrname="yes". + */ + $regary = tln_findnxreg($body, $pos, '[^\w\-_]'); + if ($regary == false){ + /** + * Looks like body ended before the end of tag. + */ + return Array(false, false, false, $lt, strlen($body)); + } + list($pos, $attname, $match) = $regary; + $attname = strtolower($attname); + /** + * We arrived at the end of attribute name. Several things possible + * here: + * '>' means the end of the tag and this is attribute type 4 + * '/' if followed by '>' means the same thing as above + * '\s' means a lot of things -- look what it's followed by. + * anything else means the attribute is invalid. + */ + switch($match){ + case '/': + /** + * This is an xhtml-style tag with a closing / at the + * end, like so: . Check if it's followed + * by the closing bracket. If not, then this tag is invalid + */ + if (substr($body, $pos, 2) == '/>'){ + $pos++; + $tagtype = 3; + } else { + $gt = tln_findnxstr($body, $pos, '>'); + $retary = Array(false, false, false, $lt, $gt); + return $retary; + } + case '>': + $attary{$attname} = '"yes"'; + return Array($tagname, $attary, $tagtype, $lt, $pos); + break; + default: + /** + * Skip whitespace and see what we arrive at. + */ + $pos = tln_skipspace($body, $pos); + $char = substr($body, $pos, 1); + /** + * Two things are valid here: + * '=' means this is attribute type 1 2 or 3. + * \w means this was attribute type 4. + * anything else we ignore and re-loop. End of tag and + * invalid stuff will be caught by our checks at the beginning + * of the loop. + */ + if ($char == '='){ + $pos++; + $pos = tln_skipspace($body, $pos); + /** + * Here are 3 possibilities: + * "'" attribute type 1 + * '"' attribute type 2 + * everything else is the content of tag type 3 + */ + $quot = substr($body, $pos, 1); + if ($quot == '\''){ + $regary = tln_findnxreg($body, $pos+1, '\''); + if ($regary == false){ + return Array(false, false, false, $lt, strlen($body)); + } + list($pos, $attval, $match) = $regary; + $pos++; + $attary{$attname} = '\'' . $attval . '\''; + } else if ($quot == '"'){ + $regary = tln_findnxreg($body, $pos+1, '\"'); + if ($regary == false){ + return Array(false, false, false, $lt, strlen($body)); + } + list($pos, $attval, $match) = $regary; + $pos++; + $attary{$attname} = '"' . $attval . '"'; + } else { + /** + * These are hateful. Look for \s, or >. + */ + $regary = tln_findnxreg($body, $pos, '[\s>]'); + if ($regary == false){ + return Array(false, false, false, $lt, strlen($body)); + } + list($pos, $attval, $match) = $regary; + /** + * If it's ">" it will be caught at the top. + */ + $attval = preg_replace('/\"/s', '"', $attval); + $attary{$attname} = '"' . $attval . '"'; + } + } else if (preg_match('|[\w/>]|', $char)) { + /** + * That was attribute type 4. + */ + $attary{$attname} = '"yes"'; + } else { + /** + * An illegal character. Find next '>' and return. + */ + $gt = tln_findnxstr($body, $pos, '>'); + return Array(false, false, false, $lt, $gt); + } + } + } + /** + * The fact that we got here indicates that the tag end was never + * found. Return invalid tag indication so it gets stripped. + */ + return Array(false, false, false, $lt, strlen($body)); +} + +/** + * Translates entities into literal values so they can be checked. + * + * @param $attvalue the by-ref value to check. + * @param $regex the regular expression to check against. + * @param $hex whether the entites are hexadecimal. + * @return True or False depending on whether there were matches. + */ +function tln_deent(&$attvalue, $regex, $hex=false){ + $me = 'tln_deent'; + $ret_match = false; + preg_match_all($regex, $attvalue, $matches); + if (is_array($matches) && sizeof($matches[0]) > 0){ + $repl = Array(); + for ($i = 0; $i < sizeof($matches[0]); $i++){ + $numval = $matches[1][$i]; + if ($hex){ + $numval = hexdec($numval); + } + $repl{$matches[0][$i]} = chr($numval); + } + $attvalue = strtr($attvalue, $repl); + return true; + } else { + return false; + } +} + +/** + * This function checks attribute values for entity-encoded values + * and returns them translated into 8-bit strings so we can run + * checks on them. + * + * @param $attvalue A string to run entity check against. + * @return Nothing, modifies a reference value. + */ +function tln_defang(&$attvalue){ + $me = 'tln_defang'; + /** + * Skip this if there aren't ampersands or backslashes. + */ + if (strpos($attvalue, '&') === false + && strpos($attvalue, '\\') === false){ + return; + } + $m = false; + do { + $m = false; + $m = $m || tln_deent($attvalue, '/\�*(\d+);*/s'); + $m = $m || tln_deent($attvalue, '/\�*((\d|[a-f])+);*/si', true); + $m = $m || tln_deent($attvalue, '/\\\\(\d+)/s', true); + } while ($m == true); + $attvalue = stripslashes($attvalue); +} + +/** + * Kill any tabs, newlines, or carriage returns. Our friends the + * makers of the browser with 95% market value decided that it'd + * be funny to make "java[tab]script" be just as good as "javascript". + * + * @param attvalue The attribute value before extraneous spaces removed. + * @return attvalue Nothing, modifies a reference value. + */ +function tln_unspace(&$attvalue){ + $me = 'tln_unspace'; + if (strcspn($attvalue, "\t\r\n\0 ") != strlen($attvalue)){ + $attvalue = str_replace(Array("\t", "\r", "\n", "\0", " "), + Array('', '', '', '', ''), $attvalue); + } +} + +/** + * This function runs various checks against the attributes. + * + * @param $tagname String with the name of the tag. + * @param $attary Array with all tag attributes. + * @param $rm_attnames See description for tln_sanitize + * @param $bad_attvals See description for tln_sanitize + * @param $add_attr_to_tag See description for tln_sanitize + * @return Array with modified attributes. + */ +function tln_fixatts($tagname, + $attary, + $rm_attnames, + $bad_attvals, + $add_attr_to_tag + ){ + $me = 'tln_fixatts'; + while (list($attname, $attvalue) = each($attary)){ + /** + * See if this attribute should be removed. + */ + foreach ($rm_attnames as $matchtag=>$matchattrs){ + if (preg_match($matchtag, $tagname)){ + foreach ($matchattrs as $matchattr){ + if (preg_match($matchattr, $attname)){ + unset($attary{$attname}); + continue; + } + } + } + } + /** + * Remove any backslashes, entities, or extraneous whitespace. + */ + tln_defang($attvalue); + tln_unspace($attvalue); + + /** + * Now let's run checks on the attvalues. + * I don't expect anyone to comprehend this. If you do, + * get in touch with me so I can drive to where you live and + * shake your hand personally. :) + */ + foreach ($bad_attvals as $matchtag=>$matchattrs){ + if (preg_match($matchtag, $tagname)){ + foreach ($matchattrs as $matchattr=>$valary){ + if (preg_match($matchattr, $attname)){ + /** + * There are two arrays in valary. + * First is matches. + * Second one is replacements + */ + list($valmatch, $valrepl) = $valary; + $newvalue = preg_replace($valmatch,$valrepl,$attvalue); + if ($newvalue != $attvalue){ + $attary{$attname} = $newvalue; + } + } + } + } + } + } + /** + * See if we need to append any attributes to this tag. + */ + foreach ($add_attr_to_tag as $matchtag=>$addattary){ + if (preg_match($matchtag, $tagname)){ + $attary = array_merge($attary, $addattary); + } + } + return $attary; +} + +/** + * + * @param $body the string with HTML you wish to filter + * @param $tag_list see description above + * @param $rm_tags_with_content see description above + * @param $self_closing_tags see description above + * @param $force_tag_closing see description above + * @param $rm_attnames see description above + * @param $bad_attvals see description above + * @param $add_attr_to_tag see description above + * @return tln_sanitized html safe to show on your pages. + */ +function tln_sanitize($body, + $tag_list, + $rm_tags_with_content, + $self_closing_tags, + $force_tag_closing, + $rm_attnames, + $bad_attvals, + $add_attr_to_tag + ) +{ + $me = 'tln_sanitize'; + /** + * Normalize rm_tags and rm_tags_with_content. + */ + $rm_tags = array_shift($tag_list); + @array_walk($tag_list, 'tln_casenormalize'); + @array_walk($rm_tags_with_content, 'tln_casenormalize'); + @array_walk($self_closing_tags, 'tln_casenormalize'); + /** + * See if tag_list is of tags to remove or tags to allow. + * false means remove these tags + * true means allow these tags + */ + $curpos = 0; + $open_tags = Array(); + $trusted = "\n"; + $skip_content = false; + /** + * Take care of netscape's stupid javascript entities like + * &{alert('boo')}; + */ + $body = preg_replace('/&(\{.*?\};)/si', '&\\1', $body); + while (($curtag = tln_getnxtag($body, $curpos)) != FALSE){ + list($tagname, $attary, $tagtype, $lt, $gt) = $curtag; + $free_content = substr($body, $curpos, $lt - $curpos); + if ($skip_content == false){ + $trusted .= $free_content; + } else { + } + if ($tagname != FALSE){ + if ($tagtype == 2){ + if ($skip_content == $tagname){ + /** + * Got to the end of tag we needed to remove. + */ + $tagname = false; + $skip_content = false; + } else { + if ($skip_content == false){ + if (isset($open_tags{$tagname}) && + $open_tags{$tagname} > 0){ + $open_tags{$tagname}--; + } else { + $tagname = false; + } + } else { + } + } + } else { + /** + * $rm_tags_with_content + */ + if ($skip_content == false){ + /** + * See if this is a self-closing type and change + * tagtype appropriately. + */ + if ($tagtype == 1 + && in_array($tagname, $self_closing_tags)){ + $tagtype = 3; + } + /** + * See if we should skip this tag and any content + * inside it. + */ + if ($tagtype == 1 + && in_array($tagname, $rm_tags_with_content)){ + $skip_content = $tagname; + } else { + if (($rm_tags == false + && in_array($tagname, $tag_list)) || + ($rm_tags == true + && !in_array($tagname, $tag_list))){ + $tagname = false; + } else { + if ($tagtype == 1){ + if (isset($open_tags{$tagname})){ + $open_tags{$tagname}++; + } else { + $open_tags{$tagname} = 1; + } + } + /** + * This is where we run other checks. + */ + if (is_array($attary) && sizeof($attary) > 0){ + $attary = tln_fixatts($tagname, + $attary, + $rm_attnames, + $bad_attvals, + $add_attr_to_tag); + } + } + } + } else { + } + } + if ($tagname != false && $skip_content == false){ + $trusted .= tln_tagprint($tagname, $attary, $tagtype); + } + } else { + } + $curpos = $gt + 1; + } + $trusted .= substr($body, $curpos, strlen($body) - $curpos); + if ($force_tag_closing == true){ + foreach ($open_tags as $tagname=>$opentimes){ + while ($opentimes > 0){ + $trusted .= ''; + $opentimes--; + } + } + $trusted .= "\n"; + } + $trusted .= "\n"; + return $trusted; +} + +// +// Use the nifty htmlfilter library +// + + +function HTMLFilter($body, $trans_image_path, $block_external_images = false) { + + $tag_list = Array( + false, + "object", + "meta", + "html", + "head", + "base", + "link", + "frame", + "iframe", + "plaintext", + "marquee" + ); + + $rm_tags_with_content = Array( + "script", + "applet", + "embed", + "title", + "frameset", + "xmp", + "xml" + ); + + $self_closing_tags = Array( + "img", + "br", + "hr", + "input", + "outbind" + ); + + $force_tag_closing = true; + + $rm_attnames = Array( + "/.*/" => + Array( + // "/target/i", + "/^on.*/i", + "/^dynsrc/i", + "/^data.*/i", + "/^lowsrc.*/i" + ) + ); + + $bad_attvals = Array( + "/.*/" => + Array( + "/^src|background/i" => + Array( + Array( + "/^([\'\"])\s*\S+script\s*:.*([\'\"])/si", + "/^([\'\"])\s*mocha\s*:*.*([\'\"])/si", + "/^([\'\"])\s*about\s*:.*([\'\"])/si" + ), + Array( + "\\1$trans_image_path\\2", + "\\1$trans_image_path\\2", + "\\1$trans_image_path\\2", + "\\1$trans_image_path\\2" + ) + ), + "/^href|action/i" => + Array( + Array( + "/^([\'\"])\s*\S+script\s*:.*([\'\"])/si", + "/^([\'\"])\s*mocha\s*:*.*([\'\"])/si", + "/^([\'\"])\s*about\s*:.*([\'\"])/si" + ), + Array( + "\\1#\\1", + "\\1#\\1", + "\\1#\\1", + "\\1#\\1" + ) + ), + "/^style/i" => + Array( + Array( + "/expression/i", + "/binding/i", + "/behaviou*r/i", + "/include-source/i", + "/position\s*:\s*absolute/i", + "/url\s*\(\s*([\'\"])\s*\S+script\s*:.*([\'\"])\s*\)/si", + "/url\s*\(\s*([\'\"])\s*mocha\s*:.*([\'\"])\s*\)/si", + "/url\s*\(\s*([\'\"])\s*about\s*:.*([\'\"])\s*\)/si", + "/(.*)\s*:\s*url\s*\(\s*([\'\"]*)\s*\S+script\s*:.*([\'\"]*)\s*\)/si" + ), + Array( + "idiocy", + "idiocy", + "idiocy", + "idiocy", + "", + "url(\\1#\\1)", + "url(\\1#\\1)", + "url(\\1#\\1)", + "url(\\1#\\1)", + "url(\\1#\\1)", + "\\1:url(\\2#\\3)" + ) + ) + ) + ); + + if ($block_external_images){ + array_push($bad_attvals{'/.*/'}{'/^src|background/i'}[0], + '/^([\'\"])\s*https*:.*([\'\"])/si'); + array_push($bad_attvals{'/.*/'}{'/^src|background/i'}[1], + "\\1$trans_image_path\\1"); + array_push($bad_attvals{'/.*/'}{'/^style/i'}[0], + '/url\(([\'\"])\s*https*:.*([\'\"])\)/si'); + array_push($bad_attvals{'/.*/'}{'/^style/i'}[1], + "url(\\1$trans_image_path\\1)"); + } + + $add_attr_to_tag = Array( + "/^a$/i" => + Array('target'=>'"_blank"') + ); + + $trusted = tln_sanitize($body, + $tag_list, + $rm_tags_with_content, + $self_closing_tags, + $force_tag_closing, + $rm_attnames, + $bad_attvals, + $add_attr_to_tag + ); + return $trusted; +} + +?> diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php index 99581de11..254d9cae0 100644 --- a/test/phpmailerTest.php +++ b/test/phpmailerTest.php @@ -9,7 +9,7 @@ * @author Andy Prevost * @author Marcus Bointon * @copyright 2004 - 2009 Andy Prevost -* @version $Id$ +* @version $Id: phpmailerTest.php 444 2009-05-05 11:22:26Z coolbru $ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License */ diff --git a/test/test_callback.php b/test/test_callback.php index 4b3dfd6fe..260a44877 100644 --- a/test/test_callback.php +++ b/test/test_callback.php @@ -1,84 +1,84 @@ - - -PHPMailer Lite - DKIM and Callback Function test - - - -\n"; - return true; -} - -$testLite = false; - -if ($testLite) { - require_once '../class.phpmailer-lite.php'; - $mail = new PHPMailerLite(); -} else { - require_once '../class.phpmailer.php'; - $mail = new PHPMailer(); -} - -try { - $mail->IsMail(); // telling the class to use SMTP - $mail->SetFrom('you@yourdomain.com', 'Your Name'); - $mail->AddAddress('another@yourdomain.com', 'John Doe'); - $mail->Subject = 'PHPMailer Lite Test Subject via Mail()'; - $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically - $mail->MsgHTML(file_get_contents('contents.html')); - $mail->AddAttachment('images/phpmailer.gif'); // attachment - $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment - $mail->action_function = 'callbackAction'; - $mail->Send(); - echo "Message Sent OK

\n"; -} catch (phpmailerException $e) { - echo $e->errorMessage(); //Pretty error messages from PHPMailer -} catch (Exception $e) { - echo $e->getMessage(); //Boring error messages from anything else! -} - -function cleanEmails($str,$type) { - if ($type == 'cc') { - $addy['Email'] = $str[0]; - $addy['Name'] = $str[1]; - return $addy; - } - if (!strstr($str, ' <')) { - $addy['Name'] = ''; - $addy['Email'] = $addy; - return $addy; - } - $addyArr = explode(' <', $str); - if (substr($addyArr[1],-1) == '>') { - $addyArr[1] = substr($addyArr[1],0,-1); - } - $addy['Name'] = $addyArr[0]; - $addy['Email'] = $addyArr[1]; - $addy['Email'] = str_replace('@', '@', $addy['Email']); - return $addy; -} - -?> - - + + +PHPMailer Lite - DKIM and Callback Function test + + + +\n"; + return true; +} + +$testLite = false; + +if ($testLite) { + require_once '../class.phpmailer-lite.php'; + $mail = new PHPMailerLite(); +} else { + require_once '../class.phpmailer.php'; + $mail = new PHPMailer(); +} + +try { + $mail->IsMail(); // telling the class to use SMTP + $mail->SetFrom('you@yourdomain.com', 'Your Name'); + $mail->AddAddress('another@yourdomain.com', 'John Doe'); + $mail->Subject = 'PHPMailer Lite Test Subject via Mail()'; + $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically + $mail->MsgHTML(file_get_contents('contents.html')); + $mail->AddAttachment('images/phpmailer.gif'); // attachment + $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment + $mail->action_function = 'callbackAction'; + $mail->Send(); + echo "Message Sent OK

\n"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} + +function cleanEmails($str,$type) { + if ($type == 'cc') { + $addy['Email'] = $str[0]; + $addy['Name'] = $str[1]; + return $addy; + } + if (!strstr($str, ' <')) { + $addy['Name'] = ''; + $addy['Email'] = $addy; + return $addy; + } + $addyArr = explode(' <', $str); + if (substr($addyArr[1],-1) == '>') { + $addyArr[1] = substr($addyArr[1],0,-1); + } + $addy['Name'] = $addyArr[0]; + $addy['Email'] = $addyArr[1]; + $addy['Email'] = str_replace('@', '@', $addy['Email']); + return $addy; +} + +?> + + diff --git a/test_script/LGPLv3.txt b/test_script/LGPLv3.txt index d74a4323d..3f9959fc5 100644 --- a/test_script/LGPLv3.txt +++ b/test_script/LGPLv3.txt @@ -1,165 +1,165 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. \ No newline at end of file diff --git a/test_script/contents.html b/test_script/contents.html index d78ec1f1d..741d3d2da 100644 --- a/test_script/contents.html +++ b/test_script/contents.html @@ -1,14 +1,14 @@ - -
-

-
- This is a test of PHPMailer v5.0.0 for PHP5/6.
-
-This particular example uses HTML, with a <div> tag and inline
-styles.
-
-Also note the use of the PHPMailer at the top with no specific code to handle -including it in the body of the email.
- - - + +
+

+
+ This is a test of PHPMailer v5.0.0 for PHP5/6.
+
+This particular example uses HTML, with a <div> tag and inline
+styles.
+
+Also note the use of the PHPMailer at the top with no specific code to handle +including it in the body of the email.
+ + + diff --git a/test_script/index.php b/test_script/index.php index 94be48e78..9823b6899 100644 --- a/test_script/index.php +++ b/test_script/index.php @@ -1,427 +1,427 @@ - - - - -PHPMailer Test Page - - - - - - - -"; - -if ( substr(phpversion(),0,1) < 5 ) { echo exit("ERROR: Wrong PHP version"); } - -$CFG['smtp_debug'] = 1; -$CFG['smtp_server'] = 'mail.yourserver.com'; -$CFG['smtp_port'] = '25'; -$CFG['smtp_authenticate'] = 'true'; -$CFG['smtp_username'] = 'name@yourserver.com'; -$CFG['smtp_password'] = 'yourpassword'; - -if ( $_POST['submit'] == "Submit" ) { - - class phpmailerAppException extends Exception { - public function errorMessage() { - $errorMsg = '' . $this->getMessage() . "
"; - return $errorMsg; - } - } - - try { - $to = $_POST['To_Email']; - if(filter_var($to, FILTER_VALIDATE_EMAIL) === FALSE) { - throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!
"); - } - } catch (phpmailerAppException $e) { - echo $e->errorMessage(); - return false; - } - - require_once("../class.phpmailer.php"); - - $mail = new PHPMailer(); - - if ( $_POST['Message'] == '' ) { - $body = $mail->getFile('contents.html'); - $body = eregi_replace("[\]",'',$body); - } else { - $body = $_POST['Message']; - } - - if ( $_POST['test_type'] == "smtp" ) { - $mail->IsSMTP(); // telling the class to use SMTP - $mail->SMTPDebug = $_POST['smtp_debug']; - $mail->SMTPAuth = $_POST['smtp_authenticate']; // enable SMTP authentication - $mail->Port = $_POST['smtp_port']; // set the SMTP port - $mail->Host = $_POST['smtp_server']; // SMTP server - $mail->Username = $_POST['authenticate_username']; // SMTP account username - $mail->Password = $_POST['authenticate_password']; // SMTP account password - } elseif ( $_POST['test_type'] == "mail" ) { - $mail->IsMail(); // telling the class to use PHP's Mail() - } elseif ( $_POST['test_type'] == "sendmail" ) { - $mail->IsSendmail(); // telling the class to use Sendmail - } elseif ( $_POST['test_type'] == "qmail" ) { - $mail->IsQmail(); // telling the class to use Qmail - } - - if ( $_POST['From_Name'] != '' ) { - $mail->AddReplyTo($_POST['From_Email'],$_POST['From_Name']); - $mail->From = $_POST['From_Email']; - $mail->FromName = $_POST['From_Name']; - } else { - $mail->AddReplyTo($_POST['From_Email']); - $mail->From = $_POST['From_Email']; - $mail->FromName = $_POST['From_Email']; - } - - if ( $_POST['To_Name'] != '' ) { - $mail->AddAddress($to,$_POST['To_Name']); - } else { - $mail->AddAddress($to); - } - - if ( $_POST['bcc_Email'] != '' ) { - $indiBCC = explode(" ", $_POST['bcc_Email']); - foreach ($indiBCC as $key => $value) { - $mail->AddBCC($value); - } - } - - if ( $_POST['cc_Email'] != '' ) { - $indiCC = explode(" ", $_POST['cc_Email']); - foreach ($indiCC as $key => $value) { - $mail->AddCC($value); - } - } - - $mail->Subject = $_POST['Subject'] . ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')'; - - require_once('../class.html2text.inc.php'); - $h2t =& new html2text($body); - $mail->AltBody = $h2t->get_text(); - //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - $mail->WordWrap = 80; // set word wrap - - $mail->MsgHTML($body); - - // $mail->IsHTML(true); // send as HTML - - $mail->AddAttachment("images/aikido.gif", "aikido.gif"); // optional name - $mail->AddAttachment("images/phpmailer.gif", "phpmailer.gif"); // optional name - - try { - if ( !$mail->Send() ) { - $error = "Unable to send to: " . $to . "
"; - throw new phpmailerAppException($error); - } else { - echo 'Message has been sent using ' . strtoupper($_POST['test_type']) . "

"; - } - } - catch (phpmailerAppException $e) { - $errorMsg[] = $e->errorMessage(); - } - - if ( count($errorMsg) > 0 ) { - foreach ($errorMsg as $key => $value) { - $thisError = $key + 1; - echo $thisError . ': ' . $value; - } - } - ?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-
- Script:
-
-class phpmailerAppException extends Exception {
-  public function errorMessage() {
-    $errorMsg = '' . $this->getMessage() . "
"; - return $errorMsg; - } -} - -try { - $to = ; - if(filter_var($to, FILTER_VALIDATE_EMAIL) === FALSE) { - throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!
"); - } -} catch (phpmailerAppException $e) { - echo $e->errorMessage(); - return false; -} - -require_once("../class.phpmailer.php"); - -$mail = new PHPMailer(); - -getFile(\'contents.html\');' . "\n"; - echo '$body = eregi_replace("[\]",\'\',$body);' . "\n"; -} else { - echo '$body = ' . $_POST['Message'] . "\n"; -} - -echo "\n"; - -if ( $_POST['test_type'] == "smtp" ) { - echo '$mail->IsSMTP(); // telling the class to use SMTP' . "\n"; - echo '$mail->SMTPDebug = ' . $_POST['smtp_debug'] . "\n"; - echo '$mail->SMTPAuth = ' . $_POST['smtp_authenticate']; // enable SMTP authentication' . "\n"; - echo '$mail->Port = ' . $_POST['smtp_port']; // set the SMTP port' . "\n"; - echo '$mail->Host = ' . $_POST['smtp_server']; // SMTP server' . "\n"; - echo '$mail->Username = ' . $_POST['authenticate_username']; // SMTP account username' . "\n"; - echo '$mail->Password = ' . $_POST['authenticate_password']; // SMTP account password' . "\n"; -} elseif ( $_POST['test_type'] == "mail" ) { - echo '$mail->IsMail(); // telling the class to use PHP\'s Mail()' . "\n"; -} elseif ( $_POST['test_type'] == "sendmail" ) { - echo '$mail->IsSendmail(); // telling the class to use Sendmail' . "\n"; -} elseif ( $_POST['test_type'] == "qmail" ) { - echo '$mail->IsQmail(); // telling the class to use Qmail' . "\n"; -} -?> - -$mail->AddReplyTo('',''); - -$mail->From = ''; -$mail->FromName = ''; - - -$mail->AddAddress('',''); - -$mail->AddAddress(''); - $value) { -echo '$mail->AddBCC(\'' . $value . '\');
'; - } -} - -if ( $_POST['cc_Email'] != '' ) { - $indiCC = explode(" ", $_POST['cc_Email']); - foreach ($indiCC as $key => $value) { -echo '$mail->AddCC(\'' . $value . '\');
'; - } -} -?> - -$mail->Subject = (PHPMailer test using ) - -require_once('../class.html2text.inc.php'); -$h2t =& new html2text($body); -$mail->AltBody = $h2t->get_text(); -$mail->WordWrap = 80; // set word wrap - -$mail->MsgHTML($body); - -$mail->AddAttachment("images/aikido.gif", "aikido.gif"); // optional name -$mail->AddAttachment("images/phpmailer.gif", "phpmailer.gif"); // optional name - -try { - if ( !$mail->Send() ) { - $error = "Unable to send to: " . $to . "
"; - throw new phpmailerAppException($error); - } else { - echo 'Message has been sent using

'; - } -} catch (phpmailerAppException $e) { - $errorMsg[] = $e->errorMessage(); -} - -if ( count($errorMsg) > 0 ) { - foreach ($errorMsg as $key => $value) { - $thisError = $key + 1; - echo $thisError . ': ' . $value; - } -} -
- - - - - -
- - - - - -
Message

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
From Name
From Email Address
To Name
To Email Address
cc Email Addresses (separate with commas)
bcc Email Addresses (separate with commas)
Subject
Message
If blank, will use content.html
-
Mail Test Specs

- - - - - -
Test Type - - - - - - - - - - - - - - - - -
>Mail()
>Sendmail
>Qmail
>SMTP
-
- If SMTP test:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SMTP Debug ?
SMTP Server
SMTP Port
SMTP Authenticate ? value="">
Authenticate Username
Authenticate Password
-
-
- Test will include two attachments, plus one of the attachments is used as an inline graphic in the message body.
-
- -
- + + + +PHPMailer Test Page + + + + + + + +"; + +if ( substr(phpversion(),0,1) < 5 ) { echo exit("ERROR: Wrong PHP version"); } + +$CFG['smtp_debug'] = 1; +$CFG['smtp_server'] = 'mail.yourserver.com'; +$CFG['smtp_port'] = '25'; +$CFG['smtp_authenticate'] = 'true'; +$CFG['smtp_username'] = 'name@yourserver.com'; +$CFG['smtp_password'] = 'yourpassword'; + +if ( $_POST['submit'] == "Submit" ) { + + class phpmailerAppException extends Exception { + public function errorMessage() { + $errorMsg = '' . $this->getMessage() . "
"; + return $errorMsg; + } + } + + try { + $to = $_POST['To_Email']; + if(filter_var($to, FILTER_VALIDATE_EMAIL) === FALSE) { + throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!
"); + } + } catch (phpmailerAppException $e) { + echo $e->errorMessage(); + return false; + } + + require_once("../class.phpmailer.php"); + + $mail = new PHPMailer(); + + if ( $_POST['Message'] == '' ) { + $body = $mail->getFile('contents.html'); + $body = eregi_replace("[\]",'',$body); + } else { + $body = $_POST['Message']; + } + + if ( $_POST['test_type'] == "smtp" ) { + $mail->IsSMTP(); // telling the class to use SMTP + $mail->SMTPDebug = $_POST['smtp_debug']; + $mail->SMTPAuth = $_POST['smtp_authenticate']; // enable SMTP authentication + $mail->Port = $_POST['smtp_port']; // set the SMTP port + $mail->Host = $_POST['smtp_server']; // SMTP server + $mail->Username = $_POST['authenticate_username']; // SMTP account username + $mail->Password = $_POST['authenticate_password']; // SMTP account password + } elseif ( $_POST['test_type'] == "mail" ) { + $mail->IsMail(); // telling the class to use PHP's Mail() + } elseif ( $_POST['test_type'] == "sendmail" ) { + $mail->IsSendmail(); // telling the class to use Sendmail + } elseif ( $_POST['test_type'] == "qmail" ) { + $mail->IsQmail(); // telling the class to use Qmail + } + + if ( $_POST['From_Name'] != '' ) { + $mail->AddReplyTo($_POST['From_Email'],$_POST['From_Name']); + $mail->From = $_POST['From_Email']; + $mail->FromName = $_POST['From_Name']; + } else { + $mail->AddReplyTo($_POST['From_Email']); + $mail->From = $_POST['From_Email']; + $mail->FromName = $_POST['From_Email']; + } + + if ( $_POST['To_Name'] != '' ) { + $mail->AddAddress($to,$_POST['To_Name']); + } else { + $mail->AddAddress($to); + } + + if ( $_POST['bcc_Email'] != '' ) { + $indiBCC = explode(" ", $_POST['bcc_Email']); + foreach ($indiBCC as $key => $value) { + $mail->AddBCC($value); + } + } + + if ( $_POST['cc_Email'] != '' ) { + $indiCC = explode(" ", $_POST['cc_Email']); + foreach ($indiCC as $key => $value) { + $mail->AddCC($value); + } + } + + $mail->Subject = $_POST['Subject'] . ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')'; + + require_once('../class.html2text.inc.php'); + $h2t =& new html2text($body); + $mail->AltBody = $h2t->get_text(); + //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test + $mail->WordWrap = 80; // set word wrap + + $mail->MsgHTML($body); + + // $mail->IsHTML(true); // send as HTML + + $mail->AddAttachment("images/aikido.gif", "aikido.gif"); // optional name + $mail->AddAttachment("images/phpmailer.gif", "phpmailer.gif"); // optional name + + try { + if ( !$mail->Send() ) { + $error = "Unable to send to: " . $to . "
"; + throw new phpmailerAppException($error); + } else { + echo 'Message has been sent using ' . strtoupper($_POST['test_type']) . "

"; + } + } + catch (phpmailerAppException $e) { + $errorMsg[] = $e->errorMessage(); + } + + if ( count($errorMsg) > 0 ) { + foreach ($errorMsg as $key => $value) { + $thisError = $key + 1; + echo $thisError . ': ' . $value; + } + } + ?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+
+ Script:
+
+class phpmailerAppException extends Exception {
+  public function errorMessage() {
+    $errorMsg = '' . $this->getMessage() . "
"; + return $errorMsg; + } +} + +try { + $to = ; + if(filter_var($to, FILTER_VALIDATE_EMAIL) === FALSE) { + throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!
"); + } +} catch (phpmailerAppException $e) { + echo $e->errorMessage(); + return false; +} + +require_once("../class.phpmailer.php"); + +$mail = new PHPMailer(); + +getFile(\'contents.html\');' . "\n"; + echo '$body = eregi_replace("[\]",\'\',$body);' . "\n"; +} else { + echo '$body = ' . $_POST['Message'] . "\n"; +} + +echo "\n"; + +if ( $_POST['test_type'] == "smtp" ) { + echo '$mail->IsSMTP(); // telling the class to use SMTP' . "\n"; + echo '$mail->SMTPDebug = ' . $_POST['smtp_debug'] . "\n"; + echo '$mail->SMTPAuth = ' . $_POST['smtp_authenticate']; // enable SMTP authentication' . "\n"; + echo '$mail->Port = ' . $_POST['smtp_port']; // set the SMTP port' . "\n"; + echo '$mail->Host = ' . $_POST['smtp_server']; // SMTP server' . "\n"; + echo '$mail->Username = ' . $_POST['authenticate_username']; // SMTP account username' . "\n"; + echo '$mail->Password = ' . $_POST['authenticate_password']; // SMTP account password' . "\n"; +} elseif ( $_POST['test_type'] == "mail" ) { + echo '$mail->IsMail(); // telling the class to use PHP\'s Mail()' . "\n"; +} elseif ( $_POST['test_type'] == "sendmail" ) { + echo '$mail->IsSendmail(); // telling the class to use Sendmail' . "\n"; +} elseif ( $_POST['test_type'] == "qmail" ) { + echo '$mail->IsQmail(); // telling the class to use Qmail' . "\n"; +} +?> + +$mail->AddReplyTo('',''); + +$mail->From = ''; +$mail->FromName = ''; + + +$mail->AddAddress('',''); + +$mail->AddAddress(''); + $value) { +echo '$mail->AddBCC(\'' . $value . '\');
'; + } +} + +if ( $_POST['cc_Email'] != '' ) { + $indiCC = explode(" ", $_POST['cc_Email']); + foreach ($indiCC as $key => $value) { +echo '$mail->AddCC(\'' . $value . '\');
'; + } +} +?> + +$mail->Subject = (PHPMailer test using ) + +require_once('../class.html2text.inc.php'); +$h2t =& new html2text($body); +$mail->AltBody = $h2t->get_text(); +$mail->WordWrap = 80; // set word wrap + +$mail->MsgHTML($body); + +$mail->AddAttachment("images/aikido.gif", "aikido.gif"); // optional name +$mail->AddAttachment("images/phpmailer.gif", "phpmailer.gif"); // optional name + +try { + if ( !$mail->Send() ) { + $error = "Unable to send to: " . $to . "
"; + throw new phpmailerAppException($error); + } else { + echo 'Message has been sent using

'; + } +} catch (phpmailerAppException $e) { + $errorMsg[] = $e->errorMessage(); +} + +if ( count($errorMsg) > 0 ) { + foreach ($errorMsg as $key => $value) { + $thisError = $key + 1; + echo $thisError . ': ' . $value; + } +} +
+ + + + + +
+ + + + + +
Message

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
From Name
From Email Address
To Name
To Email Address
cc Email Addresses (separate with commas)
bcc Email Addresses (separate with commas)
Subject
Message
If blank, will use content.html
+
Mail Test Specs

+ + + + + +
Test Type + + + + + + + + + + + + + + + + +
>Mail()
>Sendmail
>Qmail
>SMTP
+
+ If SMTP test:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SMTP Debug ?
SMTP Server
SMTP Port
SMTP Authenticate ? value="">
Authenticate Username
Authenticate Password
+
+
+ Test will include two attachments, plus one of the attachments is used as an inline graphic in the message body.
+
+ +
+ \ No newline at end of file diff --git a/test_script/scripts/shBrushBash.js b/test_script/scripts/shBrushBash.js index 378df9399..8137f7864 100644 --- a/test_script/scripts/shBrushBash.js +++ b/test_script/scripts/shBrushBash.js @@ -1,59 +1,59 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Bash = function() -{ - var keywords = 'if fi then elif else for do done until while break continue case function return in eq ne gt lt ge le'; - var commands = 'alias apropos awk bash bc bg builtin bzip2 cal cat cd cfdisk chgrp chmod chown chroot' + - 'cksum clear cmp comm command cp cron crontab csplit cut date dc dd ddrescue declare df ' + - 'diff diff3 dig dir dircolors dirname dirs du echo egrep eject enable env ethtool eval ' + - 'exec exit expand export expr false fdformat fdisk fg fgrep file find fmt fold format ' + - 'free fsck ftp gawk getopts grep groups gzip hash head history hostname id ifconfig ' + - 'import install join kill less let ln local locate logname logout look lpc lpr lprint ' + - 'lprintd lprintq lprm ls lsof make man mkdir mkfifo mkisofs mknod more mount mtools ' + - 'mv netstat nice nl nohup nslookup open op passwd paste pathchk ping popd pr printcap ' + - 'printenv printf ps pushd pwd quota quotacheck quotactl ram rcp read readonly renice ' + - 'remsync rm rmdir rsync screen scp sdiff sed select seq set sftp shift shopt shutdown ' + - 'sleep sort source split ssh strace su sudo sum symlink sync tail tar tee test time ' + - 'times touch top traceroute trap tr true tsort tty type ulimit umask umount unalias ' + - 'uname unexpand uniq units unset unshar useradd usermod users uuencode uudecode v vdir ' + - 'vi watch wc whereis which who whoami Wget xargs yes' - ; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords - { regex: new RegExp(this.getKeywords(commands), 'gm'), css: 'functions' } // commands - ]; -} - -SyntaxHighlighter.brushes.Bash.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Bash.aliases = ['bash', 'shell']; - +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Bash = function() +{ + var keywords = 'if fi then elif else for do done until while break continue case function return in eq ne gt lt ge le'; + var commands = 'alias apropos awk bash bc bg builtin bzip2 cal cat cd cfdisk chgrp chmod chown chroot' + + 'cksum clear cmp comm command cp cron crontab csplit cut date dc dd ddrescue declare df ' + + 'diff diff3 dig dir dircolors dirname dirs du echo egrep eject enable env ethtool eval ' + + 'exec exit expand export expr false fdformat fdisk fg fgrep file find fmt fold format ' + + 'free fsck ftp gawk getopts grep groups gzip hash head history hostname id ifconfig ' + + 'import install join kill less let ln local locate logname logout look lpc lpr lprint ' + + 'lprintd lprintq lprm ls lsof make man mkdir mkfifo mkisofs mknod more mount mtools ' + + 'mv netstat nice nl nohup nslookup open op passwd paste pathchk ping popd pr printcap ' + + 'printenv printf ps pushd pwd quota quotacheck quotactl ram rcp read readonly renice ' + + 'remsync rm rmdir rsync screen scp sdiff sed select seq set sftp shift shopt shutdown ' + + 'sleep sort source split ssh strace su sudo sum symlink sync tail tar tee test time ' + + 'times touch top traceroute trap tr true tsort tty type ulimit umask umount unalias ' + + 'uname unexpand uniq units unset unshar useradd usermod users uuencode uudecode v vdir ' + + 'vi watch wc whereis which who whoami Wget xargs yes' + ; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords + { regex: new RegExp(this.getKeywords(commands), 'gm'), css: 'functions' } // commands + ]; +} + +SyntaxHighlighter.brushes.Bash.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Bash.aliases = ['bash', 'shell']; + diff --git a/test_script/scripts/shBrushCSharp.js b/test_script/scripts/shBrushCSharp.js index dc6304cb0..e8d111b63 100644 --- a/test_script/scripts/shBrushCSharp.js +++ b/test_script/scripts/shBrushCSharp.js @@ -1,64 +1,64 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.CSharp = function() -{ - var keywords = 'abstract as base bool break byte case catch char checked class const ' + - 'continue decimal default delegate do double else enum event explicit ' + - 'extern false finally fixed float for foreach get goto if implicit in int ' + - 'interface internal is lock long namespace new null object operator out ' + - 'override params private protected public readonly ref return sbyte sealed set ' + - 'short sizeof stackalloc static string struct switch this throw true try ' + - 'typeof uint ulong unchecked unsafe ushort using virtual void while'; - - function fixComments(match, regexInfo) - { - var css = (match[0].indexOf("///") == 0) - ? 'color1' - : 'comments' - ; - - return [new SyntaxHighlighter.Match(match[0], match.index, css)]; - } - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLineCComments, func : fixComments }, // one line comments - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings - { regex: /^\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // c# keyword - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); -}; - -SyntaxHighlighter.brushes.CSharp.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; - +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.CSharp = function() +{ + var keywords = 'abstract as base bool break byte case catch char checked class const ' + + 'continue decimal default delegate do double else enum event explicit ' + + 'extern false finally fixed float for foreach get goto if implicit in int ' + + 'interface internal is lock long namespace new null object operator out ' + + 'override params private protected public readonly ref return sbyte sealed set ' + + 'short sizeof stackalloc static string struct switch this throw true try ' + + 'typeof uint ulong unchecked unsafe ushort using virtual void while'; + + function fixComments(match, regexInfo) + { + var css = (match[0].indexOf("///") == 0) + ? 'color1' + : 'comments' + ; + + return [new SyntaxHighlighter.Match(match[0], match.index, css)]; + } + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLineCComments, func : fixComments }, // one line comments + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings + { regex: /^\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // c# keyword + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); +}; + +SyntaxHighlighter.brushes.CSharp.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; + diff --git a/test_script/scripts/shBrushCpp.js b/test_script/scripts/shBrushCpp.js index 146a3dfc1..8da0d1bfe 100644 --- a/test_script/scripts/shBrushCpp.js +++ b/test_script/scripts/shBrushCpp.js @@ -1,99 +1,99 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Cpp = function() -{ - // Copyright 2006 Shin, YoungJin - - var datatypes = 'ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR ' + - 'DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH ' + - 'HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP ' + - 'HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY ' + - 'HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT ' + - 'HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE ' + - 'LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF ' + - 'LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR ' + - 'LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR ' + - 'PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT ' + - 'PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 ' + - 'POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR ' + - 'PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 ' + - 'PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT ' + - 'SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG ' + - 'ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM ' + - 'char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t ' + - 'clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS ' + - 'FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t ' + - '__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t ' + - 'jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler ' + - 'sig_atomic_t size_t _stat __stat64 _stati64 terminate_function ' + - 'time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf ' + - 'va_list wchar_t wctrans_t wctype_t wint_t signed'; - - var keywords = 'break case catch class const __finally __exception __try ' + - 'const_cast continue private public protected __declspec ' + - 'default delete deprecated dllexport dllimport do dynamic_cast ' + - 'else enum explicit extern if for friend goto inline ' + - 'mutable naked namespace new noinline noreturn nothrow ' + - 'register reinterpret_cast return selectany ' + - 'sizeof static static_cast struct switch template this ' + - 'thread throw true false try typedef typeid typename union ' + - 'using uuid virtual void volatile whcar_t while'; - - var functions = 'assert isalnum isalpha iscntrl isdigit isgraph islower isprint' + - 'ispunct isspace isupper isxdigit tolower toupper errno localeconv ' + - 'setlocale acos asin atan atan2 ceil cos cosh exp fabs floor fmod ' + - 'frexp ldexp log log10 modf pow sin sinh sqrt tan tanh jmp_buf ' + - 'longjmp setjmp raise signal sig_atomic_t va_arg va_end va_start ' + - 'clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen ' + - 'fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell ' + - 'fwrite getc getchar gets perror printf putc putchar puts remove ' + - 'rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam ' + - 'ungetc vfprintf vprintf vsprintf abort abs atexit atof atoi atol ' + - 'bsearch calloc div exit free getenv labs ldiv malloc mblen mbstowcs ' + - 'mbtowc qsort rand realloc srand strtod strtol strtoul system ' + - 'wcstombs wctomb memchr memcmp memcpy memmove memset strcat strchr ' + - 'strcmp strcoll strcpy strcspn strerror strlen strncat strncmp ' + - 'strncpy strpbrk strrchr strspn strstr strtok strxfrm asctime ' + - 'clock ctime difftime gmtime localtime mktime strftime time'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings - { regex: /^ *#.*/gm, css: 'preprocessor' }, - { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' }, - { regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions bold' }, - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' } - ]; -}; - -SyntaxHighlighter.brushes.Cpp.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Cpp.aliases = ['cpp', 'c']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Cpp = function() +{ + // Copyright 2006 Shin, YoungJin + + var datatypes = 'ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR ' + + 'DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH ' + + 'HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP ' + + 'HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY ' + + 'HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT ' + + 'HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE ' + + 'LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF ' + + 'LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR ' + + 'LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR ' + + 'PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT ' + + 'PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 ' + + 'POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR ' + + 'PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 ' + + 'PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT ' + + 'SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG ' + + 'ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM ' + + 'char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t ' + + 'clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS ' + + 'FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t ' + + '__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t ' + + 'jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler ' + + 'sig_atomic_t size_t _stat __stat64 _stati64 terminate_function ' + + 'time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf ' + + 'va_list wchar_t wctrans_t wctype_t wint_t signed'; + + var keywords = 'break case catch class const __finally __exception __try ' + + 'const_cast continue private public protected __declspec ' + + 'default delete deprecated dllexport dllimport do dynamic_cast ' + + 'else enum explicit extern if for friend goto inline ' + + 'mutable naked namespace new noinline noreturn nothrow ' + + 'register reinterpret_cast return selectany ' + + 'sizeof static static_cast struct switch template this ' + + 'thread throw true false try typedef typeid typename union ' + + 'using uuid virtual void volatile whcar_t while'; + + var functions = 'assert isalnum isalpha iscntrl isdigit isgraph islower isprint' + + 'ispunct isspace isupper isxdigit tolower toupper errno localeconv ' + + 'setlocale acos asin atan atan2 ceil cos cosh exp fabs floor fmod ' + + 'frexp ldexp log log10 modf pow sin sinh sqrt tan tanh jmp_buf ' + + 'longjmp setjmp raise signal sig_atomic_t va_arg va_end va_start ' + + 'clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen ' + + 'fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell ' + + 'fwrite getc getchar gets perror printf putc putchar puts remove ' + + 'rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam ' + + 'ungetc vfprintf vprintf vsprintf abort abs atexit atof atoi atol ' + + 'bsearch calloc div exit free getenv labs ldiv malloc mblen mbstowcs ' + + 'mbtowc qsort rand realloc srand strtod strtol strtoul system ' + + 'wcstombs wctomb memchr memcmp memcpy memmove memset strcat strchr ' + + 'strcmp strcoll strcpy strcspn strerror strlen strncat strncmp ' + + 'strncpy strpbrk strrchr strspn strstr strtok strxfrm asctime ' + + 'clock ctime difftime gmtime localtime mktime strftime time'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings + { regex: /^ *#.*/gm, css: 'preprocessor' }, + { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' }, + { regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions bold' }, + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' } + ]; +}; + +SyntaxHighlighter.brushes.Cpp.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Cpp.aliases = ['cpp', 'c']; diff --git a/test_script/scripts/shBrushCss.js b/test_script/scripts/shBrushCss.js index ebfc3399c..2c6685e89 100644 --- a/test_script/scripts/shBrushCss.js +++ b/test_script/scripts/shBrushCss.js @@ -1,93 +1,93 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.CSS = function() -{ - function getKeywordsCSS(str) - { - return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b'; - }; - - function getValuesCSS(str) - { - return '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b'; - }; - - var keywords = 'ascent azimuth background-attachment background-color background-image background-position ' + - 'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' + - 'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' + - 'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' + - 'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' + - 'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' + - 'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' + - 'height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' + - 'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' + - 'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page ' + - 'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' + - 'quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' + - 'table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' + - 'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index'; - - var values = 'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+ - 'both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed '+ - 'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double '+ - 'embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+ - 'gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+ - 'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+ - 'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+ - 'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+ - 'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+ - 'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+ - 'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize '+ - 'table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+ - 'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+ - 'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'; - - var fonts = '[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings - { regex: /\#[a-fA-F0-9]{3,6}/g, css: 'value' }, // html colors - { regex: /(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)/g, css: 'value' }, // sizes - { regex: /!important/g, css: 'color3' }, // !important - { regex: new RegExp(getKeywordsCSS(keywords), 'gm'), css: 'keyword' }, // keywords - { regex: new RegExp(getValuesCSS(values), 'g'), css: 'value' }, // values - { regex: new RegExp(this.getKeywords(fonts), 'g'), css: 'color1' } // fonts - ]; - - this.forHtmlScript({ - left: /(<|<)\s*style.*?(>|>)/gi, - right: /(<|<)\/\s*style\s*(>|>)/gi - }); -}; - -SyntaxHighlighter.brushes.CSS.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.CSS.aliases = ['css']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.CSS = function() +{ + function getKeywordsCSS(str) + { + return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b'; + }; + + function getValuesCSS(str) + { + return '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b'; + }; + + var keywords = 'ascent azimuth background-attachment background-color background-image background-position ' + + 'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' + + 'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' + + 'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' + + 'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' + + 'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' + + 'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' + + 'height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' + + 'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' + + 'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page ' + + 'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' + + 'quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' + + 'table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' + + 'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index'; + + var values = 'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+ + 'both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed '+ + 'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double '+ + 'embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+ + 'gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+ + 'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+ + 'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+ + 'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+ + 'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+ + 'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+ + 'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize '+ + 'table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+ + 'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+ + 'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow'; + + var fonts = '[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings + { regex: /\#[a-fA-F0-9]{3,6}/g, css: 'value' }, // html colors + { regex: /(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)/g, css: 'value' }, // sizes + { regex: /!important/g, css: 'color3' }, // !important + { regex: new RegExp(getKeywordsCSS(keywords), 'gm'), css: 'keyword' }, // keywords + { regex: new RegExp(getValuesCSS(values), 'g'), css: 'value' }, // values + { regex: new RegExp(this.getKeywords(fonts), 'g'), css: 'color1' } // fonts + ]; + + this.forHtmlScript({ + left: /(<|<)\s*style.*?(>|>)/gi, + right: /(<|<)\/\s*style\s*(>|>)/gi + }); +}; + +SyntaxHighlighter.brushes.CSS.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.CSS.aliases = ['css']; diff --git a/test_script/scripts/shBrushDelphi.js b/test_script/scripts/shBrushDelphi.js index e46d0748c..bc1fdf39a 100644 --- a/test_script/scripts/shBrushDelphi.js +++ b/test_script/scripts/shBrushDelphi.js @@ -1,57 +1,57 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Delphi = function() -{ - var keywords = 'abs addr and ansichar ansistring array as asm begin boolean byte cardinal ' + - 'case char class comp const constructor currency destructor div do double ' + - 'downto else end except exports extended false file finalization finally ' + - 'for function goto if implementation in inherited int64 initialization ' + - 'integer interface is label library longint longword mod nil not object ' + - 'of on or packed pansichar pansistring pchar pcurrency pdatetime pextended ' + - 'pint64 pointer private procedure program property pshortstring pstring ' + - 'pvariant pwidechar pwidestring protected public published raise real real48 ' + - 'record repeat set shl shortint shortstring shr single smallint string then ' + - 'threadvar to true try type unit until uses val var varirnt while widechar ' + - 'widestring with word write writeln xor'; - - this.regexList = [ - { regex: /\(\*[\s\S]*?\*\)/gm, css: 'comments' }, // multiline comments (* *) - { regex: /{(?!\$)[\s\S]*?}/gm, css: 'comments' }, // multiline comments { } - { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings - { regex: /\{\$[a-zA-Z]+ .+\}/g, css: 'color1' }, // compiler Directives and Region tags - { regex: /\b[\d\.]+\b/g, css: 'value' }, // numbers 12345 - { regex: /\$[a-zA-Z0-9]+\b/g, css: 'value' }, // numbers $F5D3 - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keyword - ]; -}; - -SyntaxHighlighter.brushes.Delphi.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Delphi.aliases = ['delphi', 'pascal']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Delphi = function() +{ + var keywords = 'abs addr and ansichar ansistring array as asm begin boolean byte cardinal ' + + 'case char class comp const constructor currency destructor div do double ' + + 'downto else end except exports extended false file finalization finally ' + + 'for function goto if implementation in inherited int64 initialization ' + + 'integer interface is label library longint longword mod nil not object ' + + 'of on or packed pansichar pansistring pchar pcurrency pdatetime pextended ' + + 'pint64 pointer private procedure program property pshortstring pstring ' + + 'pvariant pwidechar pwidestring protected public published raise real real48 ' + + 'record repeat set shl shortint shortstring shr single smallint string then ' + + 'threadvar to true try type unit until uses val var varirnt while widechar ' + + 'widestring with word write writeln xor'; + + this.regexList = [ + { regex: /\(\*[\s\S]*?\*\)/gm, css: 'comments' }, // multiline comments (* *) + { regex: /{(?!\$)[\s\S]*?}/gm, css: 'comments' }, // multiline comments { } + { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings + { regex: /\{\$[a-zA-Z]+ .+\}/g, css: 'color1' }, // compiler Directives and Region tags + { regex: /\b[\d\.]+\b/g, css: 'value' }, // numbers 12345 + { regex: /\$[a-zA-Z0-9]+\b/g, css: 'value' }, // numbers $F5D3 + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keyword + ]; +}; + +SyntaxHighlighter.brushes.Delphi.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Delphi.aliases = ['delphi', 'pascal']; diff --git a/test_script/scripts/shBrushDiff.js b/test_script/scripts/shBrushDiff.js index 558fe6e8f..6b4983d7a 100644 --- a/test_script/scripts/shBrushDiff.js +++ b/test_script/scripts/shBrushDiff.js @@ -1,43 +1,43 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Diff = function() -{ - this.regexList = [ - { regex: /^\+\+\+.*$/gm, css: 'color2' }, - { regex: /^\-\-\-.*$/gm, css: 'color2' }, - { regex: /^\s.*$/gm, css: 'color1' }, - { regex: /^@@.*@@$/gm, css: 'variable' }, - { regex: /^\+[^\+]{1}.*$/gm, css: 'string' }, - { regex: /^\-[^\-]{1}.*$/gm, css: 'comments' } - ]; -}; - -SyntaxHighlighter.brushes.Diff.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Diff.aliases = ['diff', 'patch']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Diff = function() +{ + this.regexList = [ + { regex: /^\+\+\+.*$/gm, css: 'color2' }, + { regex: /^\-\-\-.*$/gm, css: 'color2' }, + { regex: /^\s.*$/gm, css: 'color1' }, + { regex: /^@@.*@@$/gm, css: 'variable' }, + { regex: /^\+[^\+]{1}.*$/gm, css: 'string' }, + { regex: /^\-[^\-]{1}.*$/gm, css: 'comments' } + ]; +}; + +SyntaxHighlighter.brushes.Diff.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Diff.aliases = ['diff', 'patch']; diff --git a/test_script/scripts/shBrushGroovy.js b/test_script/scripts/shBrushGroovy.js index 22001c5c3..582e37ba1 100644 --- a/test_script/scripts/shBrushGroovy.js +++ b/test_script/scripts/shBrushGroovy.js @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ SyntaxHighlighter.brushes.Groovy = function() { // Contributed by Andres Almiray diff --git a/test_script/scripts/shBrushJScript.js b/test_script/scripts/shBrushJScript.js index 26c941002..6a1603ac1 100644 --- a/test_script/scripts/shBrushJScript.js +++ b/test_script/scripts/shBrushJScript.js @@ -1,51 +1,51 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.JScript = function() -{ - var keywords = 'abstract boolean break byte case catch char class const continue debugger ' + - 'default delete do double else enum export extends false final finally float ' + - 'for function goto if implements import in instanceof int interface long native ' + - 'new null package private protected public return short static super switch ' + - 'synchronized this throw throws transient true try typeof var void volatile while with'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings - { regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags); -}; - -SyntaxHighlighter.brushes.JScript.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.JScript.aliases = ['js', 'jscript', 'javascript']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.JScript = function() +{ + var keywords = 'abstract boolean break byte case catch char class const continue debugger ' + + 'default delete do double else enum export extends false final finally float ' + + 'for function goto if implements import in instanceof int interface long native ' + + 'new null package private protected public return short static super switch ' + + 'synchronized this throw throws transient true try typeof var void volatile while with'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings + { regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags); +}; + +SyntaxHighlighter.brushes.JScript.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.JScript.aliases = ['js', 'jscript', 'javascript']; diff --git a/test_script/scripts/shBrushJava.js b/test_script/scripts/shBrushJava.js index 6208f6fad..e1138438d 100644 --- a/test_script/scripts/shBrushJava.js +++ b/test_script/scripts/shBrushJava.js @@ -1,55 +1,55 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Java = function() -{ - var keywords = 'abstract assert boolean break byte case catch char class const ' + - 'continue default do double else enum extends ' + - 'false final finally float for goto if implements import ' + - 'instanceof int interface long native new null ' + - 'package private protected public return ' + - 'short static strictfp super switch synchronized this throw throws true ' + - 'transient try void volatile while'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings - { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers - { regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno - { regex: /\@interface\b/g, css: 'color2' }, // @interface keyword - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // java keyword - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); -}; - -SyntaxHighlighter.brushes.Java.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Java.aliases = ['java']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Java = function() +{ + var keywords = 'abstract assert boolean break byte case catch char class const ' + + 'continue default do double else enum extends ' + + 'false final finally float for goto if implements import ' + + 'instanceof int interface long native new null ' + + 'package private protected public return ' + + 'short static strictfp super switch synchronized this throw throws true ' + + 'transient try void volatile while'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings + { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers + { regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno + { regex: /\@interface\b/g, css: 'color2' }, // @interface keyword + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // java keyword + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); +}; + +SyntaxHighlighter.brushes.Java.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Java.aliases = ['java']; diff --git a/test_script/scripts/shBrushPerl.js b/test_script/scripts/shBrushPerl.js index efa4bc246..1d4ed7ade 100644 --- a/test_script/scripts/shBrushPerl.js +++ b/test_script/scripts/shBrushPerl.js @@ -1,74 +1,74 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Perl = function() -{ - // Contributed by David Simmons-Duffin and Marty Kube - - var funcs = - 'abs accept alarm atan2 bind binmode chdir chmod chomp chop chown chr ' + - 'chroot close closedir connect cos crypt defined delete each endgrent ' + - 'endhostent endnetent endprotoent endpwent endservent eof exec exists ' + - 'exp fcntl fileno flock fork format formline getc getgrent getgrgid ' + - 'getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr ' + - 'getnetbyname getnetent getpeername getpgrp getppid getpriority ' + - 'getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid ' + - 'getservbyname getservbyport getservent getsockname getsockopt glob ' + - 'gmtime grep hex index int ioctl join keys kill lc lcfirst length link ' + - 'listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd ' + - 'oct open opendir ord pack pipe pop pos print printf prototype push ' + - 'quotemeta rand read readdir readline readlink readpipe recv rename ' + - 'reset reverse rewinddir rindex rmdir scalar seek seekdir select semctl ' + - 'semget semop send setgrent sethostent setnetent setpgrp setpriority ' + - 'setprotoent setpwent setservent setsockopt shift shmctl shmget shmread ' + - 'shmwrite shutdown sin sleep socket socketpair sort splice split sprintf ' + - 'sqrt srand stat study substr symlink syscall sysopen sysread sysseek ' + - 'system syswrite tell telldir time times tr truncate uc ucfirst umask ' + - 'undef unlink unpack unshift utime values vec wait waitpid warn write'; - - var keywords = - 'bless caller continue dbmclose dbmopen die do dump else elsif eval exit ' + - 'for foreach goto if import last local my next no our package redo ref ' + - 'require return sub tie tied unless untie until use wantarray while'; - - this.regexList = [ - { regex: new RegExp('#[^!].*$', 'gm'), css: 'comments' }, - { regex: new RegExp('^\\s*#!.*$', 'gm'), css: 'preprocessor' }, // shebang - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, - { regex: new RegExp('(\\$|@|%)\\w+', 'g'), css: 'variable' }, - { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags); -} - -SyntaxHighlighter.brushes.Perl.prototype = new SyntaxHighlighter.Highlighter(); +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Perl = function() +{ + // Contributed by David Simmons-Duffin and Marty Kube + + var funcs = + 'abs accept alarm atan2 bind binmode chdir chmod chomp chop chown chr ' + + 'chroot close closedir connect cos crypt defined delete each endgrent ' + + 'endhostent endnetent endprotoent endpwent endservent eof exec exists ' + + 'exp fcntl fileno flock fork format formline getc getgrent getgrgid ' + + 'getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr ' + + 'getnetbyname getnetent getpeername getpgrp getppid getpriority ' + + 'getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid ' + + 'getservbyname getservbyport getservent getsockname getsockopt glob ' + + 'gmtime grep hex index int ioctl join keys kill lc lcfirst length link ' + + 'listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd ' + + 'oct open opendir ord pack pipe pop pos print printf prototype push ' + + 'quotemeta rand read readdir readline readlink readpipe recv rename ' + + 'reset reverse rewinddir rindex rmdir scalar seek seekdir select semctl ' + + 'semget semop send setgrent sethostent setnetent setpgrp setpriority ' + + 'setprotoent setpwent setservent setsockopt shift shmctl shmget shmread ' + + 'shmwrite shutdown sin sleep socket socketpair sort splice split sprintf ' + + 'sqrt srand stat study substr symlink syscall sysopen sysread sysseek ' + + 'system syswrite tell telldir time times tr truncate uc ucfirst umask ' + + 'undef unlink unpack unshift utime values vec wait waitpid warn write'; + + var keywords = + 'bless caller continue dbmclose dbmopen die do dump else elsif eval exit ' + + 'for foreach goto if import last local my next no our package redo ref ' + + 'require return sub tie tied unless untie until use wantarray while'; + + this.regexList = [ + { regex: new RegExp('#[^!].*$', 'gm'), css: 'comments' }, + { regex: new RegExp('^\\s*#!.*$', 'gm'), css: 'preprocessor' }, // shebang + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, + { regex: new RegExp('(\\$|@|%)\\w+', 'g'), css: 'variable' }, + { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags); +} + +SyntaxHighlighter.brushes.Perl.prototype = new SyntaxHighlighter.Highlighter(); SyntaxHighlighter.brushes.Perl.aliases = ['perl', 'Perl', 'pl']; \ No newline at end of file diff --git a/test_script/scripts/shBrushPhp.js b/test_script/scripts/shBrushPhp.js index 9dd28fd8a..8facae11a 100644 --- a/test_script/scripts/shBrushPhp.js +++ b/test_script/scripts/shBrushPhp.js @@ -1,91 +1,91 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Php = function() -{ - var funcs = 'abs acos acosh addcslashes addslashes ' + - 'array_change_key_case array_chunk array_combine array_count_values array_diff '+ - 'array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill '+ - 'array_filter array_flip array_intersect array_intersect_assoc array_intersect_key '+ - 'array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map '+ - 'array_merge array_merge_recursive array_multisort array_pad array_pop array_product '+ - 'array_push array_rand array_reduce array_reverse array_search array_shift '+ - 'array_slice array_splice array_sum array_udiff array_udiff_assoc '+ - 'array_udiff_uassoc array_uintersect array_uintersect_assoc '+ - 'array_uintersect_uassoc array_unique array_unshift array_values array_walk '+ - 'array_walk_recursive atan atan2 atanh base64_decode base64_encode base_convert '+ - 'basename bcadd bccomp bcdiv bcmod bcmul bindec bindtextdomain bzclose bzcompress '+ - 'bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite ceil chdir '+ - 'checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists '+ - 'closedir closelog copy cos cosh count count_chars date decbin dechex decoct '+ - 'deg2rad delete ebcdic2ascii echo empty end ereg ereg_replace eregi eregi_replace error_log '+ - 'error_reporting escapeshellarg escapeshellcmd eval exec exit exp explode extension_loaded '+ - 'feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents '+ - 'fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype '+ - 'floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf '+ - 'fseek fsockopen fstat ftell ftok getallheaders getcwd getdate getenv gethostbyaddr gethostbyname '+ - 'gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid getmyuid getopt '+ - 'getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext '+ - 'gettimeofday gettype glob gmdate gmmktime ini_alter ini_get ini_get_all ini_restore ini_set '+ - 'interface_exists intval ip2long is_a is_array is_bool is_callable is_dir is_double '+ - 'is_executable is_file is_finite is_float is_infinite is_int is_integer is_link is_long '+ - 'is_nan is_null is_numeric is_object is_readable is_real is_resource is_scalar is_soap_fault '+ - 'is_string is_subclass_of is_uploaded_file is_writable is_writeable mkdir mktime nl2br '+ - 'parse_ini_file parse_str parse_url passthru pathinfo readlink realpath rewind rewinddir rmdir '+ - 'round str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split '+ - 'str_word_count strcasecmp strchr strcmp strcoll strcspn strftime strip_tags stripcslashes '+ - 'stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk '+ - 'strpos strptime strrchr strrev strripos strrpos strspn strstr strtok strtolower strtotime '+ - 'strtoupper strtr strval substr substr_compare'; - - var keywords = 'and or xor array as break case ' + - 'cfunction class const continue declare default die do else ' + - 'elseif enddeclare endfor endforeach endif endswitch endwhile ' + - 'extends for foreach function include include_once global if ' + - 'new old_function return static switch use require require_once ' + - 'var while abstract interface public implements extends private protected throw'; - - var constants = '__FILE__ __LINE__ __METHOD__ __FUNCTION__ __CLASS__'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings - { regex: /\$\w+/g, css: 'variable' }, // variables - { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // common functions - { regex: new RegExp(this.getKeywords(constants), 'gmi'), css: 'constants' }, // constants - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keyword - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags); -}; - -SyntaxHighlighter.brushes.Php.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Php.aliases = ['php']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Php = function() +{ + var funcs = 'abs acos acosh addcslashes addslashes ' + + 'array_change_key_case array_chunk array_combine array_count_values array_diff '+ + 'array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill '+ + 'array_filter array_flip array_intersect array_intersect_assoc array_intersect_key '+ + 'array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map '+ + 'array_merge array_merge_recursive array_multisort array_pad array_pop array_product '+ + 'array_push array_rand array_reduce array_reverse array_search array_shift '+ + 'array_slice array_splice array_sum array_udiff array_udiff_assoc '+ + 'array_udiff_uassoc array_uintersect array_uintersect_assoc '+ + 'array_uintersect_uassoc array_unique array_unshift array_values array_walk '+ + 'array_walk_recursive atan atan2 atanh base64_decode base64_encode base_convert '+ + 'basename bcadd bccomp bcdiv bcmod bcmul bindec bindtextdomain bzclose bzcompress '+ + 'bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite ceil chdir '+ + 'checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists '+ + 'closedir closelog copy cos cosh count count_chars date decbin dechex decoct '+ + 'deg2rad delete ebcdic2ascii echo empty end ereg ereg_replace eregi eregi_replace error_log '+ + 'error_reporting escapeshellarg escapeshellcmd eval exec exit exp explode extension_loaded '+ + 'feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents '+ + 'fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype '+ + 'floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf '+ + 'fseek fsockopen fstat ftell ftok getallheaders getcwd getdate getenv gethostbyaddr gethostbyname '+ + 'gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid getmyuid getopt '+ + 'getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext '+ + 'gettimeofday gettype glob gmdate gmmktime ini_alter ini_get ini_get_all ini_restore ini_set '+ + 'interface_exists intval ip2long is_a is_array is_bool is_callable is_dir is_double '+ + 'is_executable is_file is_finite is_float is_infinite is_int is_integer is_link is_long '+ + 'is_nan is_null is_numeric is_object is_readable is_real is_resource is_scalar is_soap_fault '+ + 'is_string is_subclass_of is_uploaded_file is_writable is_writeable mkdir mktime nl2br '+ + 'parse_ini_file parse_str parse_url passthru pathinfo readlink realpath rewind rewinddir rmdir '+ + 'round str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split '+ + 'str_word_count strcasecmp strchr strcmp strcoll strcspn strftime strip_tags stripcslashes '+ + 'stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk '+ + 'strpos strptime strrchr strrev strripos strrpos strspn strstr strtok strtolower strtotime '+ + 'strtoupper strtr strval substr substr_compare'; + + var keywords = 'and or xor array as break case ' + + 'cfunction class const continue declare default die do else ' + + 'elseif enddeclare endfor endforeach endif endswitch endwhile ' + + 'extends for foreach function include include_once global if ' + + 'new old_function return static switch use require require_once ' + + 'var while abstract interface public implements extends private protected throw'; + + var constants = '__FILE__ __LINE__ __METHOD__ __FUNCTION__ __CLASS__'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings + { regex: /\$\w+/g, css: 'variable' }, // variables + { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // common functions + { regex: new RegExp(this.getKeywords(constants), 'gmi'), css: 'constants' }, // constants + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keyword + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags); +}; + +SyntaxHighlighter.brushes.Php.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Php.aliases = ['php']; diff --git a/test_script/scripts/shBrushPlain.js b/test_script/scripts/shBrushPlain.js index 6a6f2d69d..da9fa6a31 100644 --- a/test_script/scripts/shBrushPlain.js +++ b/test_script/scripts/shBrushPlain.js @@ -1,35 +1,35 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Plain = function() -{ -}; - -SyntaxHighlighter.brushes.Plain.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Plain.aliases = ['text', 'plain']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Plain = function() +{ +}; + +SyntaxHighlighter.brushes.Plain.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Plain.aliases = ['text', 'plain']; diff --git a/test_script/scripts/shBrushPython.js b/test_script/scripts/shBrushPython.js index f6d3af236..599633e20 100644 --- a/test_script/scripts/shBrushPython.js +++ b/test_script/scripts/shBrushPython.js @@ -1,56 +1,56 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Python = function() -{ - // Contributed by Gheorghe Milas - - var keywords = 'and assert break class continue def del elif else ' + - 'except exec finally for from global if import in is ' + - 'lambda not or pass print raise return try yield while'; - - var special = 'None True False self cls class_'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, - { regex: /^\s*@\w+/gm, css: 'decorator' }, - { regex: /(['\"]{3})([^\1])*?\1/gm, css: 'comments' }, - { regex: /"(?!")(?:\.|\\\"|[^\""\n])*"/gm, css: 'string' }, - { regex: /'(?!')(?:\.|(\\\')|[^\''\n])*'/gm, css: 'string' }, - { regex: /\+|\-|\*|\/|\%|=|==/gm, css: 'keyword' }, - { regex: /\b\d+\.?\w*/g, css: 'value' }, - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, - { regex: new RegExp(this.getKeywords(special), 'gm'), css: 'color1' } - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); -}; - -SyntaxHighlighter.brushes.Python.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Python.aliases = ['py', 'python']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Python = function() +{ + // Contributed by Gheorghe Milas + + var keywords = 'and assert break class continue def del elif else ' + + 'except exec finally for from global if import in is ' + + 'lambda not or pass print raise return try yield while'; + + var special = 'None True False self cls class_'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, + { regex: /^\s*@\w+/gm, css: 'decorator' }, + { regex: /(['\"]{3})([^\1])*?\1/gm, css: 'comments' }, + { regex: /"(?!")(?:\.|\\\"|[^\""\n])*"/gm, css: 'string' }, + { regex: /'(?!')(?:\.|(\\\')|[^\''\n])*'/gm, css: 'string' }, + { regex: /\+|\-|\*|\/|\%|=|==/gm, css: 'keyword' }, + { regex: /\b\d+\.?\w*/g, css: 'value' }, + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, + { regex: new RegExp(this.getKeywords(special), 'gm'), css: 'color1' } + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); +}; + +SyntaxHighlighter.brushes.Python.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Python.aliases = ['py', 'python']; diff --git a/test_script/scripts/shBrushRuby.js b/test_script/scripts/shBrushRuby.js index bbf965a48..269bf30c4 100644 --- a/test_script/scripts/shBrushRuby.js +++ b/test_script/scripts/shBrushRuby.js @@ -1,57 +1,57 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Ruby = function() -{ - // Contributed by Erik Peterson. - - var keywords = 'alias and BEGIN begin break case class def define_method defined do each else elsif ' + - 'END end ensure false for if in module new next nil not or raise redo rescue retry return ' + - 'self super then throw true undef unless until when while yield'; - - var builtins = 'Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload ' + - 'Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol ' + - 'ThreadGroup Thread Time TrueClass'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings - { regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // constants - { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // symbols - { regex: /(\$|@@|@)\w+/g, css: 'variable bold' }, // $global, @instance, and @@class variables - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords - { regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color1' } // builtins - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); -}; - -SyntaxHighlighter.brushes.Ruby.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Ruby.aliases = ['ruby', 'rails', 'ror']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Ruby = function() +{ + // Contributed by Erik Peterson. + + var keywords = 'alias and BEGIN begin break case class def define_method defined do each else elsif ' + + 'END end ensure false for if in module new next nil not or raise redo rescue retry return ' + + 'self super then throw true undef unless until when while yield'; + + var builtins = 'Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload ' + + 'Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol ' + + 'ThreadGroup Thread Time TrueClass'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings + { regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // constants + { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // symbols + { regex: /(\$|@@|@)\w+/g, css: 'variable bold' }, // $global, @instance, and @@class variables + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords + { regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color1' } // builtins + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); +}; + +SyntaxHighlighter.brushes.Ruby.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Ruby.aliases = ['ruby', 'rails', 'ror']; diff --git a/test_script/scripts/shBrushScala.js b/test_script/scripts/shBrushScala.js index cb508008f..f26b677c5 100644 --- a/test_script/scripts/shBrushScala.js +++ b/test_script/scripts/shBrushScala.js @@ -1,53 +1,53 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Scala = function() -{ - // Contributed by Yegor Jbanov and David Bernard. - - var keywords = 'val sealed case def true trait implicit forSome import match object null finally super ' + - 'override try lazy for var catch throw type extends class while with new final yield abstract ' + - 'else do if return protected private this package false'; - - var keyops = '[_:=><%#@]+'; - - this.regexList = [ - { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments - { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // multi-line strings - { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double-quoted string - { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings - { regex: /0x[a-f0-9]+|\d+(\.\d+)?/gi, css: 'value' }, // numbers - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords - { regex: new RegExp(keyops, 'gm'), css: 'keyword' } // scala keyword - ]; -} - -SyntaxHighlighter.brushes.Scala.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Scala.aliases = ['scala']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Scala = function() +{ + // Contributed by Yegor Jbanov and David Bernard. + + var keywords = 'val sealed case def true trait implicit forSome import match object null finally super ' + + 'override try lazy for var catch throw type extends class while with new final yield abstract ' + + 'else do if return protected private this package false'; + + var keyops = '[_:=><%#@]+'; + + this.regexList = [ + { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments + { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // multi-line strings + { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double-quoted string + { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings + { regex: /0x[a-f0-9]+|\d+(\.\d+)?/gi, css: 'value' }, // numbers + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords + { regex: new RegExp(keyops, 'gm'), css: 'keyword' } // scala keyword + ]; +} + +SyntaxHighlighter.brushes.Scala.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Scala.aliases = ['scala']; diff --git a/test_script/scripts/shBrushSql.js b/test_script/scripts/shBrushSql.js index 3499ff68b..bf937470a 100644 --- a/test_script/scripts/shBrushSql.js +++ b/test_script/scripts/shBrushSql.js @@ -1,68 +1,68 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Sql = function() -{ - var funcs = 'abs avg case cast coalesce convert count current_timestamp ' + - 'current_user day isnull left lower month nullif replace right ' + - 'session_user space substring sum system_user upper user year'; - - var keywords = 'absolute action add after alter as asc at authorization begin bigint ' + - 'binary bit by cascade char character check checkpoint close collate ' + - 'column commit committed connect connection constraint contains continue ' + - 'create cube current current_date current_time cursor database date ' + - 'deallocate dec decimal declare default delete desc distinct double drop ' + - 'dynamic else end end-exec escape except exec execute false fetch first ' + - 'float for force foreign forward free from full function global goto grant ' + - 'group grouping having hour ignore index inner insensitive insert instead ' + - 'int integer intersect into is isolation key last level load local max min ' + - 'minute modify move name national nchar next no numeric of off on only ' + - 'open option order out output partial password precision prepare primary ' + - 'prior privileges procedure public read real references relative repeatable ' + - 'restrict return returns revoke rollback rollup rows rule schema scroll ' + - 'second section select sequence serializable set size smallint static ' + - 'statistics table temp temporary then time timestamp to top transaction ' + - 'translation trigger true truncate uncommitted union unique update values ' + - 'varchar varying view when where with work'; - - var operators = 'all and any between cross in join like not null or outer some'; - - this.regexList = [ - { regex: /--(.*)$/gm, css: 'comments' }, // one line and multiline comments - { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings - { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // single quoted strings - { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'color2' }, // functions - { regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such - { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword - ]; -}; - -SyntaxHighlighter.brushes.Sql.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Sql.aliases = ['sql']; - +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Sql = function() +{ + var funcs = 'abs avg case cast coalesce convert count current_timestamp ' + + 'current_user day isnull left lower month nullif replace right ' + + 'session_user space substring sum system_user upper user year'; + + var keywords = 'absolute action add after alter as asc at authorization begin bigint ' + + 'binary bit by cascade char character check checkpoint close collate ' + + 'column commit committed connect connection constraint contains continue ' + + 'create cube current current_date current_time cursor database date ' + + 'deallocate dec decimal declare default delete desc distinct double drop ' + + 'dynamic else end end-exec escape except exec execute false fetch first ' + + 'float for force foreign forward free from full function global goto grant ' + + 'group grouping having hour ignore index inner insensitive insert instead ' + + 'int integer intersect into is isolation key last level load local max min ' + + 'minute modify move name national nchar next no numeric of off on only ' + + 'open option order out output partial password precision prepare primary ' + + 'prior privileges procedure public read real references relative repeatable ' + + 'restrict return returns revoke rollback rollup rows rule schema scroll ' + + 'second section select sequence serializable set size smallint static ' + + 'statistics table temp temporary then time timestamp to top transaction ' + + 'translation trigger true truncate uncommitted union unique update values ' + + 'varchar varying view when where with work'; + + var operators = 'all and any between cross in join like not null or outer some'; + + this.regexList = [ + { regex: /--(.*)$/gm, css: 'comments' }, // one line and multiline comments + { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings + { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // single quoted strings + { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'color2' }, // functions + { regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such + { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword + ]; +}; + +SyntaxHighlighter.brushes.Sql.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Sql.aliases = ['sql']; + diff --git a/test_script/scripts/shBrushVb.js b/test_script/scripts/shBrushVb.js index 9e84549e6..84c7b0c43 100644 --- a/test_script/scripts/shBrushVb.js +++ b/test_script/scripts/shBrushVb.js @@ -1,58 +1,58 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Vb = function() -{ - var keywords = 'AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto ' + - 'Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate ' + - 'CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType ' + - 'Date Decimal Declare Default Delegate Dim DirectCast Do Double Each ' + - 'Else ElseIf End Enum Erase Error Event Exit False Finally For Friend ' + - 'Function Get GetType GoSub GoTo Handles If Implements Imports In ' + - 'Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module ' + - 'MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing ' + - 'NotInheritable NotOverridable Object On Option Optional Or OrElse ' + - 'Overloads Overridable Overrides ParamArray Preserve Private Property ' + - 'Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume ' + - 'Return Select Set Shadows Shared Short Single Static Step Stop String ' + - 'Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until ' + - 'Variant When While With WithEvents WriteOnly Xor'; - - this.regexList = [ - { regex: /'.*$/gm, css: 'comments' }, // one line comments - { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings - { regex: /^\s*#.*$/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion - { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // vb keyword - ]; - - this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); -}; - -SyntaxHighlighter.brushes.Vb.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Vb.aliases = ['vb', 'vbnet']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Vb = function() +{ + var keywords = 'AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto ' + + 'Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate ' + + 'CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType ' + + 'Date Decimal Declare Default Delegate Dim DirectCast Do Double Each ' + + 'Else ElseIf End Enum Erase Error Event Exit False Finally For Friend ' + + 'Function Get GetType GoSub GoTo Handles If Implements Imports In ' + + 'Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module ' + + 'MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing ' + + 'NotInheritable NotOverridable Object On Option Optional Or OrElse ' + + 'Overloads Overridable Overrides ParamArray Preserve Private Property ' + + 'Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume ' + + 'Return Select Set Shadows Shared Short Single Static Step Stop String ' + + 'Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until ' + + 'Variant When While With WithEvents WriteOnly Xor'; + + this.regexList = [ + { regex: /'.*$/gm, css: 'comments' }, // one line comments + { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings + { regex: /^\s*#.*$/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // vb keyword + ]; + + this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); +}; + +SyntaxHighlighter.brushes.Vb.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Vb.aliases = ['vb', 'vbnet']; diff --git a/test_script/scripts/shBrushXml.js b/test_script/scripts/shBrushXml.js index 11a5b5c60..f5aa67cca 100644 --- a/test_script/scripts/shBrushXml.js +++ b/test_script/scripts/shBrushXml.js @@ -1,71 +1,71 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -SyntaxHighlighter.brushes.Xml = function() -{ - function process(match, regexInfo) - { - var constructor = SyntaxHighlighter.Match, - code = match[0], - tag = new XRegExp('(<|<)[\\s\\/\\?]*(?[:\\w-\\.]+)', 'xg').exec(code), - result = [] - ; - - if (match.attributes != null) - { - var attributes, - regex = new XRegExp('(? [\\w:\\-\\.]+)' + - '\\s*=\\s*' + - '(? ".*?"|\'.*?\'|\\w+)', - 'xg'); - - while ((attributes = regex.exec(code)) != null) - { - result.push(new constructor(attributes.name, match.index + attributes.index, 'color1')); - result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string')); - } - } - - if (tag != null) - result.push( - new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword') - ); - - return result; - } - - this.regexList = [ - { regex: new XRegExp('(\\<|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\>|>)', 'gm'), css: 'color2' }, // - { regex: new XRegExp('(\\<|<)!--\\s*.*?\\s*--(\\>|>)', 'gm'), css: 'comments' }, // - { regex: new XRegExp('(<|<)[\\s\\/\\?]*(\\w+)(?.*?)[\\s\\/\\?]*(>|>)', 'sg'), func: process } - ]; -}; - -SyntaxHighlighter.brushes.Xml.prototype = new SyntaxHighlighter.Highlighter(); -SyntaxHighlighter.brushes.Xml.aliases = ['xml', 'xhtml', 'xslt', 'html', 'xhtml']; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +SyntaxHighlighter.brushes.Xml = function() +{ + function process(match, regexInfo) + { + var constructor = SyntaxHighlighter.Match, + code = match[0], + tag = new XRegExp('(<|<)[\\s\\/\\?]*(?[:\\w-\\.]+)', 'xg').exec(code), + result = [] + ; + + if (match.attributes != null) + { + var attributes, + regex = new XRegExp('(? [\\w:\\-\\.]+)' + + '\\s*=\\s*' + + '(? ".*?"|\'.*?\'|\\w+)', + 'xg'); + + while ((attributes = regex.exec(code)) != null) + { + result.push(new constructor(attributes.name, match.index + attributes.index, 'color1')); + result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string')); + } + } + + if (tag != null) + result.push( + new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword') + ); + + return result; + } + + this.regexList = [ + { regex: new XRegExp('(\\<|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\>|>)', 'gm'), css: 'color2' }, // + { regex: new XRegExp('(\\<|<)!--\\s*.*?\\s*--(\\>|>)', 'gm'), css: 'comments' }, // + { regex: new XRegExp('(<|<)[\\s\\/\\?]*(\\w+)(?.*?)[\\s\\/\\?]*(>|>)', 'sg'), func: process } + ]; +}; + +SyntaxHighlighter.brushes.Xml.prototype = new SyntaxHighlighter.Highlighter(); +SyntaxHighlighter.brushes.Xml.aliases = ['xml', 'xhtml', 'xslt', 'html', 'xhtml']; diff --git a/test_script/scripts/shCore.js b/test_script/scripts/shCore.js index e531557f9..f38396f57 100644 --- a/test_script/scripts/shCore.js +++ b/test_script/scripts/shCore.js @@ -1,30 +1,30 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('f(!1o.31){p 31=h(){p l={5S:{"1e-1c":"","73-2E":1,"2a-1P":u,"1I":u,"6T-6S":U,"1F-1P":4,"5F":O,"5x":U,"1q":U,"5v":O,"6i-6p":U,"6J":O},Q:{5D:u,5i:16,5k:16,7P:O,7I:"5L",1b:{4e:"91 1i",3Y:"92 1i",5l:"93 90 6K",6X:"8Z I 8W 1X 8X 6K 8Y",3u:"3u",6h:"?",1u:"31\\n\\n",5Z:"94\'t 95 7J C: ",7z:"9b 9c\'t 9a C 2j-2n 99: ",6B:"<2j 8G=\\"2y://7A.7E.7o/8D/8E\\"><70><8F 2y-8L=\\"8M-8S\\" 5h=\\"2c/2j; 8T=8R-8\\" /><36>8Q 31<2R 1f=\\"2a-7T:8N,\'7h 8O 8P\',7h,7L;9d-53:#9e;53:#9D;2a-1P:9E;2c-8i:85;\\">3184 2.0.9O (9M 9L 6H)2y://6a.4a9w I 9k 9l.9m 9j-6H 9i 9f."},7j:O},1p:{59:u,3q:u,3o:u,5j:{}},30:{},8a:{9g:/\\/\\*[\\s\\S]*?\\*\\//4M,9h:/\\/\\/.*$/4M,9n:/#.*$/4M,9o:/"(?:\\.|(\\\\\\")|[^\\""\\n])*"/g,9u:/\'(?:\\.|(\\\\\\\')|[^\\\'\'\\n])*\'/g,9v:/"(?:\\.|(\\\\\\")|[^\\""])*"/g,9t:/\'(?:\\.|(\\\\\\\')|[^\\\'\'])*\'/g,3e:/\\w+:\\/\\/[\\w-.\\/?%&=]*/g,9s:{E:/(&1C;|<)\\?=?/g,17:/\\?(&2m;|>)/g},9p:{E:/(&1C;|<)%=?/g,17:/%(&2m;|>)/g},9q:{E:/(&1C;|<)\\s*2n.*?(&2m;|>)/47,17:/(&1C;|<)\\/\\s*2n\\s*(&2m;|>)/47}},1q:{15:h(32){p 38=J.1t("37"),4L=l.1q.77;38.Y="1q";C(p 2N 1X 4L){p 6j=4L[2N],4G=R 6j(32),22=4G.15();32.5E[2N]=4G;f(22==u){1V}f(9r(22)=="9P"){22=l.1q.6C(22,32.1j,2N)}22.Y+="8w "+2N;38.1z(22)}q 38},6C:h(4v,6O,4w){p a=J.1t("a"),5e=a.1f,4F=l.Q,57=4F.5i,5c=4F.5k;a.2q="#"+4w;a.36=4v;a.5P=6O;a.6c=4w;a.1r=4v;f(5z(57)==O){5e.1N=57+"5H"}f(5z(5c)==O){5e.2u=5c+"5H"}a.8q=h(e){8j{l.1q.6f(c,e||1o.6g,c.5P,c.6c)}8m(e){l.B.1u(e.6F)}q O};q a},6f:h(7i,7a,5T,7O,72){p 4Y=l.1p.5j[5T],45;f(4Y==u||(45=4Y.5E[7O])==u){q u}q 45.2h(7i,7a,72)},77:{4e:h(4p){c.15=h(){f(4p.T("5v")!=U){q}q l.Q.1b.4e};c.2h=h(4q,8v,8B){p z=4p.z;4q.71.51(4q);z.Y=z.Y.D("5t","")}},3Y:h(8g){c.15=h(){q l.Q.1b.3Y};c.2h=h(8p,8o,8t){p 33=l.B.3d(8g.5r).D(/"+33+"");2b.J.4N()}},5l:h(4S){p 3x,8y,5M=4S.1j;c.15=h(){p 2A=l.Q;f(2A.5D==u){q u}h 1L(5C){p 5s="";C(p 5A 1X 5C){5s+="<8z 1c=\'"+5A+"\' 1W=\'"+5C[5A]+"\'/>"}q 5s};h 2p(43){p 5p="";C(p 5o 1X 43){5p+=" "+5o+"=\'"+43[5o]+"\'"}q 5p};p 48={1N:2A.5i,2u:2A.5k,1j:5M+"ai",6z:"bu/x-74-79",36:l.Q.1b.5l},46={bl:"bm",bx:"bA",bz:"5P="+5M,bF:"O"},4t=2A.5D,35;f(/aQ/i.1R(61.6b)){35="<8h"+2p({aT:"bd:bf-b9-b5-b4-b7",b8:"2y://ba.be.4a/bb/74/bc/79/b3.b2#84=9,0,0,0"})+2p(48)+">"+1L(46)+1L({aU:4t})+""}F{35=""}3x=J.1t("z");3x.1r=35;q 3x};c.2h=h(aV,aW,4R){p 68=4R.b1;6V(68){2J"7C":p 5d=l.B.2W(l.B.3d(4S.5r).D(/&1C;/g,"<").D(/&2m;/g,">").D(/&b0;/g,"&"));f(1o.6e){1o.6e.aZ("2c",5d)}F{q l.B.2W(5d)}2J"aX":l.B.1u(l.Q.1b.6X);2B;2J"aY":l.B.1u(4R.6F);2B}}},bh:h(4I){c.15=h(){q l.Q.1b.3u};c.2h=h(bg,by,bB){p 25=J.1t("bG"),1J=u;f(l.1p.3o!=u){J.2R.51(l.1p.3o)}l.1p.3o=25;25.1f.bC="bE:bD;1N:6m;2u:6m;E:-6l;4z:-6l;";J.2R.1z(25);1J=25.4J.J;6t(1J,1o.J);1J.3t(""+4I.z.1r+"");1J.4N();25.4J.4A();25.4J.3u();h 6t(6A,6s){p 2S=6s.7M("4K");C(p i=0;i<2S.v;i++){f(2S[i].6r.bk()=="6q"&&/bi\\.12$/.1R(2S[i].2q)){6A.3t("<4K 6z=\\"2c/12\\" 6r=\\"6q\\" 2q=\\""+2S[i].2q+"\\">")}}}}},bj:h(bo){c.15=h(){q l.Q.1b.6h};c.2h=h(bv,bt){p 2b=l.B.4y("","4P",bq,bs,"6n=0"),1J=2b.J;1J.3t(l.Q.1b.6B);1J.4N();2b.4A()}}}},B:{5m:h(6R){q 6R+3z.aN(3z.aa()*ab).2f()},5u:h(4E,4x){p 3l={},1S;C(1S 1X 4E){3l[1S]=4E[1S]}C(1S 1X 4x){3l[1S]=4x[1S]}q 3l},7w:h(4u){6V(4u){2J"U":q U;2J"O":q O}q 4u},4y:h(3e,6M,4D,4C,2I){p x=(6N.1N-4D)/2,y=(6N.2u-4C)/2;2I+=", E="+x+", 4z="+y+", 1N="+4D+", 2u="+4C;2I=2I.D(/^,/,"");p 4Q=1o.9Q(3e,6M,2I);4Q.4A();q 4Q},78:h(1A,29,23){f(1A.6D){1A["e"+29+23]=23;1A[29+23]=h(){1A["e"+29+23](1o.6g)};1A.6D("a6"+29,1A[29+23])}F{1A.a7(29,23,O)}},1u:h(A){1u(l.Q.1b.1u+A)},4c:h(5a,5Y){p 2k=l.1p.59,3j=u;f(2k==u){2k={};C(p 55 1X l.30){p 3g=l.30[55].ac;f(3g==u){1V}C(p i=0;i<3g.v;i++){2k[3g[i]]=55}}l.1p.59=2k}3j=l.30[2k[5a]];f(3j==u&&5Y!=O){l.B.1u(l.Q.1b.5Z+5a)}q 3j},42:h(A,60){p 2T=A.21("\\n");C(p i=0;i<2T.v;i++){2T[i]=60(2T[i])}q 2T.4h("\\n")},6x:h(){p z=J.1t("z"),3h=J.1t("z"),6d=10,i=1;28(i<=aO){f(i%6d===0){z.1r+=i;i+=(i+"").v}F{z.1r+="&ah;";i++}}3h.Y="5F 2E";3h.1z(z);q 3h},6U:h(A){q A.D(/^[ ]*[\\n]+|[\\n]*[ ]*$/g,"")},7d:h(A){p 3i,4V={},5b=R M("^\\\\[(?<54>(.*?))\\\\]$"),69=R M("(?<1c>[\\\\w-]+)"+"\\\\s*:\\\\s*"+"(?<1W>"+"[\\\\w-%#]+|"+"\\\\[.*?\\\\]|"+"\\".*?\\"|"+"\'.*?\'"+")\\\\s*;?","g");28((3i=69.N(A))!=u){p 2g=3i.1W.D(/^[\'"]|[\'"]$/g,"");f(2g!=u&&5b.1R(2g)){p m=5b.N(2g);2g=m.54.v>0?m.54.21(/\\s*,\\s*/):[]}4V[3i.1c]=2g}q 4V},80:h(A,12){f(A==u||A.v==0||A=="\\n"){q A}A=A.D(/"+2i+""})}q A},7f:h(66,67){p 2Z=66.2f();28(2Z.v<67){2Z="0"+2Z}q 2Z},5y:h(){p 3b=J.1t("z"),3f,3a=0,52=J.2R,1j=l.B.5m("5y"),2O="",4W="";3b.1r=2O+"6L\\">"+2O+"26\\">"+2O+"2E\\">"+2O+"5h"+"\\"><1T 1e=\\"7V\\"><1T 1j=\\""+1j+"\\">&1O;"+4W+4W+2Q+2Q+2Q+2Q;52.1z(3b);3f=J.a5(1j);f(/a4/i.1R(61.6b)){p 5Q=1o.9V(3f,u);3a=7l(5Q.9W("1N"))}F{3a=3f.9U}52.51(3b);q 3a},6Q:h(7R,6Y){p 1F="";C(p i=0;i<6Y;i++){1F+=" "}q 7R.D(/\\t/g,1F)},6P:h(2P,41){p 9T=2P.21("\\n"),1F="\\t",5f="";C(p i=0;i<50;i++){5f+=" "}h 7X(3c,18,7Z){q 3c.1M(0,18)+5f.1M(0,7Z)+3c.1M(18+1,3c.v)};2P=l.B.42(2P,h(20){f(20.1h(1F)==-1){q 20}p 18=0;28((18=20.1h(1F))!=-1){p 7U=41-18%41;20=7X(20,18,7U)}q 20});q 2P},3d:h(A){q(l.Q.7P==U)?A.D(/|&1C;br\\s*\\/?&2m;/47,"\\n"):A},3P:h(A){q A.D(/\\s*$/g,"").D(/^\\s*/,"")},2W:h(A){p 1Q=l.B.3d(A).21("\\n"),9X=R 5B(),7S=/^\\s*/,24=9Y;C(p i=0;i<1Q.v&&24>0;i++){p 3V=1Q[i];f(l.B.3P(3V).v==0){1V}p 3S=7S.N(3V);f(3S==u){q A}24=3z.24(3S[0].v,24)}f(24>0){C(p i=0;i<1Q.v;i++){1Q[i]=1Q[i].1M(24)}}q 1Q.4h("\\n")},7B:h(2L,2K){f(2L.H<2K.H){q-1}F{f(2L.H>2K.H){q 1}F{f(2L.v<2K.v){q-1}F{f(2L.v>2K.v){q 1}}}}q 0},2D:h(8d,2G){h 8e(3W,81){q[R l.4i(3W[0],3W.H,81.12)]};p a2=0,3X=u,3y=[],8c=2G.4m?2G.4m:8e;28((3X=2G.3D.N(8d))!=u){3y=3y.2H(8c(3X,2G))}q 3y},6o:h(8f){q 8f.D(l.8a.3e,h(m){q""+m+""})}},1I:h(7c,4l){h 88(4s){p 49=[];C(p i=0;i<4s.v;i++){49.K(4s[i])}q 49};p 3m=4l?[4l]:88(J.7M(l.Q.7I)),7g="1r",2t=u;f(3m.v===0){q}C(p i=0;i<3m.v;i++){p 2F=3m[i],2s=l.B.7d(2F.Y),2Y;2s=l.B.5u(7c,2s);2Y=2s["7J"];f(2Y==u){1V}f(2s["2j-2n"]=="U"){2t=R l.44(2Y)}F{p 4o=l.B.4c(2Y);f(4o){2t=R 4o()}F{1V}}2t.1I(2F[7g],2s);p 2l=2t.z;f(l.Q.7j){2l=J.1t("a0");2l.1W=2t.z.1r;2l.1f.1N="aj";2l.1f.2u="aE"}2F.71.aF(2l,2F)}},aD:h(76){l.B.78(1o,"aC",h(){l.1I(76)})}};l.4i=h(4j,75,12){c.1W=4j;c.H=75;c.v=4j.v;c.12=12};l.4i.Z.2f=h(){q c.1W};l.44=h(4g){p 1H=l.B.4c(4g),4f=R l.30.aA(),aB=u;f(1H==u){q}1H=R 1H();c.4X=4f;f(1H.3K==u){l.B.1u(l.Q.1b.7z+4g);q}4f.4B.K({3D:1H.3K.I,4m:7F});h 39(4d,7G){C(p j=0;j<4d.v;j++){4d[j].H+=7G}};h 7F(14,aH){p 7x=14.I,1E=[],4k=1H.4B,7p=14.H+14.E.v,2X=1H.3K,1n;C(p i=0;i<4k.v;i++){1n=l.B.2D(7x,4k[i]);39(1n,7p);1E=1E.2H(1n)}f(2X.E!=u&&14.E!=u){1n=l.B.2D(14.E,2X.E);39(1n,14.H);1E=1E.2H(1n)}f(2X.17!=u&&14.17!=u){1n=l.B.2D(14.17,2X.17);39(1n,14.H+14[0].aM(14.17));1E=1E.2H(1n)}q 1E}};l.44.Z.1I=h(7u,7t){c.4X.1I(7u,7t);c.z=c.4X.z};l.87=h(){};l.87.Z={T:h(7v,7n){p 5J=c.1L[7v];q l.B.7w(5J==u?7n:5J)},15:h(7y){q J.1t(7y)},7m:h(5G){C(p i=0;i2V.H)&&(5G.H<2V.H+2V.v)){q U}}q O},6v:h(3v,7D){p 2e=[];f(3v!=u){C(p i=0;i<3v.v;i++){2e=2e.2H(l.B.2D(7D,3v[i]))}}2e=2e.aL(l.B.7B);q 2e},6u:h(){C(p i=0;i"+""+82+"."+"<1T 1e=\\"5h\\">"+(1D!=u?""+1D.D(/\\s/g,"&1O;")+"":"")+"<1T 1e=\\"7V\\" 1f=\\"5n-E: "+2w+"5H !aq;\\">"+1s+""+""+""}q 2C},6w:h(5N,5K){p 18=0,3n="",3r=l.B.80;C(p i=0;i<5K.v;i++){p 1y=5K[i];f(1y===u||1y.v===0){1V}3n+=3r(5N.1M(18,1y.H-18),"63")+3r(1y.1W,1y.12);18=1y.H+1y.v}3n+=3r(5N.1M(18),"63");q 3n},1I:h(1g,5R){p am=l.Q,3p=l.1p,z,34;c.1L={};c.z=u;c.26=u;c.I=u;c.2d=u;c.5E={};c.1j=l.B.5m("ar");3p.5j[c.1j]=c;f(1g===u){1g=""}f(3p.3q===u){3p.3q=l.B.5y()}c.1L=l.B.5u(l.5S,5R||{});f(c.T("6J")==U){c.1L.1q=c.1L.5x=O}c.z=z=c.15("37");c.26=c.15("37");c.26.Y="26";z.Y="6L";z.1j=c.1j;f(c.T("5v")){z.Y+=" 5t"}f(c.T("5x")==O){z.Y+=" ax"}z.Y+=" "+c.T("1e-1c");z.1f.av=c.T("2a-1P","");c.5r=1g;c.I=l.B.6U(1g).D(/\\r/g," ");34=c.T("1F-1P");c.I=c.T("6T-6S")==U?l.B.6P(c.I,34):l.B.6Q(c.I,34);c.I=l.B.2W(c.I);f(c.T("1q")){c.2d=c.15("37");c.2d.Y="2d";c.2d.1z(l.1q.15(c));z.1z(c.2d)}f(c.T("5F")){z.1z(l.B.6x())}z.1z(c.26);c.1Y=c.6v(c.4B,c.I);c.6u();1g=c.6w(c.I,c.1Y);1g=c.6k(l.B.3P(1g));f(c.T("6i-6p")){1g=l.B.6o(1g)}c.26.1r=1g},au:h(A){A=A.D(/^\\s+|\\s+$/g,"").D(/\\s+/g,"\\\\b|\\\\b");q"\\\\b"+A+"\\\\b"},at:h(2z){c.3K={E:{3D:2z.E,12:"2n"},17:{3D:2z.17,12:"2n"},I:R M("(?"+2z.E.1i+")"+"(?.*?)"+"(?<17>"+2z.17.1i+")","aw")}}};q l}()}f(!5B.1h){5B.Z.1h=h(5V,3J){3J=3z.as(3J||0,0);C(p i=3J;i|[65]{[^}]+})[\\S\\s]?|\\((?=\\?(?!#|<[\\w$]+>)))+|(\\()(?:\\?(?:(#)[^)]*\\)|<([$\\w]+)>))?|\\\\(?:k<([\\w$]+)>|[65]{([^}]+)})|(\\[\\^?)|([\\S\\s])/g,al:/(?:[^$]+|\\$(?![1-9$&`\']|{[$\\w]+}))+|\\$(?:([1-9]\\d*|[$&`\'])|{([$\\w]+)})/g,3F:/^(?:\\s+|#.*)+/,3R:/^(?:[?*+]|{\\d+(?:,\\d*)?})/,7H:/&&\\[\\^?/g,7q:/]/g},7N=h(5I,7Y,7K){C(p i=7K||0;i<5I.v;i++){f(5I[i]===7Y){q i}}q-1},7k=/()??/.N("")[1]!==3A,3L={};M=h(1d,1U){f(1d 4T V){f(1U!==3A){3G 62("56\'t 58 an 6G ao 5X V ap ay")}q 1d.3I()}p 1U=1U||"",7s=1U.1h("s")>-1,7r=1U.1h("x")>-1,4b=O,3C=[],13=[],11=1G.11,G,3N,3O,3E,3B;11.L=0;28(G=2v.N.2x(11,1d)){f(G[2]){f(!1G.3R.1R(1d.19(11.L))){13.K("(?:)")}}F{f(G[1]){3C.K(G[3]||u);f(G[3]){4b=U}13.K("(")}F{f(G[4]){3E=7N(3C,G[4]);13.K(3E>-1?"\\\\"+(3E+1)+(5z(1d.5O(11.L))?"":"(?:)"):G[0])}F{f(G[5]){13.K(3L.6Z?3L.6Z.7C(G[5],G[0].5O(1)==="P"):G[0])}F{f(G[6]){f(1d.5O(11.L)==="]"){13.K(G[6]==="["?"(?!)":"[\\\\S\\\\s]");11.L++}F{3N=M.6E("&&"+1d.19(G.H),1G.7H,1G.7q,"",{5W:"\\\\"})[0];13.K(G[6]+3N+"]");11.L+=3N.v+1}}F{f(G[7]){f(7s&&G[7]==="."){13.K("[\\\\S\\\\s]")}F{f(7r&&1G.3F.1R(G[7])){3O=2v.N.2x(1G.3F,1d.19(11.L-1))[0].v;f(!1G.3R.1R(1d.19(11.L-1+3O))){13.K("(?:)")}11.L+=3O-1}F{13.K(G[7])}}}F{13.K(G[0])}}}}}}}3B=V(13.4h(""),2v.D.2x(1U,/[aG]+/g,""));3B.1v={1i:1d,2o:4b?3C:u};q 3B};M.ak=h(1c,o){3L[1c]=o};V.Z.N=h(A){p 1a=2v.N.2x(c,A),1c,i,5g;f(1a){f(7k&&1a.v>1){5g=R V("^"+c.1i+"$(?!\\\\s)",c.3U());2v.D.2x(1a[0],5g,h(){C(i=1;i<7b.v-2;i++){f(7b[i]===3A){1a[i]=3A}}})}f(c.1v&&c.1v.2o){C(i=1;i<1a.v;i++){1c=c.1v.2o[i-1];f(1c){1a[1c]=1a[i]}}}f(c.3H&&c.L>(1a.H+1a[0].v)){c.L--}}q 1a}})()}V.Z.3U=h(){q(c.3H?"g":"")+(c.9Z?"i":"")+(c.6W?"m":"")+(c.3F?"x":"")+(c.a1?"y":"")};V.Z.3I=h(7Q){p 3T=R M(c.1i,(7Q||"")+c.3U());f(c.1v){3T.1v={1i:c.1v.1i,2o:c.1v.2o?c.1v.2o.19(0):u}}q 3T};V.Z.2x=h(a3,A){q c.N(A)};V.Z.9S=h(9R,7W){q c.N(7W[0])};M.3Z=h(4r,4Z){p 40="/"+4r+"/"+(4Z||"");q M.3Z[40]||(M.3Z[40]=R M(4r,4Z))};M.3M=h(A){q A.D(/[-[\\]{}()*+?.\\\\^$|,#\\s]/g,"\\\\$&")};M.6E=h(A,E,W,1k,2M){p 2M=2M||{},2U=2M.5W,X=2M.af,1k=1k||"",4O=1k.1h("g")>-1,6y=1k.1h("i")>-1,5U=1k.1h("m")>-1,4H=1k.1h("y")>-1,1k=1k.D(/y/g,""),E=E 4T V?(E.3H?E:E.3I("g")):R M(E,"g"+1k),W=W 4T V?(W.3H?W:W.3I("g")):R M(W,"g"+1k),1K=[],2r=0,1m=0,1l=0,1x=0,27,1Z,1w,1B,3Q,4n;f(2U){f(2U.v>1){3G ae("56\'t 58 ag ad 5X 3M 6I")}f(5U){3G 62("56\'t 58 3M 6I 6G a8 a9 6W aP")}3Q=M.3M(2U);4n=R V("^(?:"+3Q+"[\\\\S\\\\s]|(?:(?!"+E.1i+"|"+W.1i+")[^"+3Q+"])+)+",6y?"i":"")}28(U){E.L=W.L=1l+(2U?(4n.N(A.19(1l))||[""])[0].v:0);1w=E.N(A);1B=W.N(A);f(1w&&1B){f(1w.H<=1B.H){1B=u}F{1w=u}}f(1w||1B){1m=(1w||1B).H;1l=(1w?E:W).L}F{f(!2r){2B}}f(4H&&!2r&&1m>1x){2B}f(1w){f(!2r++){27=1m;1Z=1l}}F{f(1B&&2r){f(!--2r){f(X){f(X[0]&&27>1x){1K.K([X[0],A.19(1x,27),1x,27])}f(X[1]){1K.K([X[1],A.19(27,1Z),27,1Z])}f(X[2]){1K.K([X[2],A.19(1Z,1m),1Z,1m])}f(X[3]){1K.K([X[3],A.19(1m,1l),1m,1l])}}F{1K.K(A.19(1Z,1m))}1x=1l;f(!4O){2B}}}F{E.L=W.L=0;3G b6("bw bp 8l 8u 8A")}}f(1m===1l){1l++}}f(4O&&!4H&&X&&X[0]&&A.v>1x){1K.K([X[0],A.19(1x),1x,A.v])}E.L=W.L=0;q 1K};',62,725,'||||||||||||this|||if||function||||sh||||var|return||||null|length||||div|str|utils|for|replace|left|else|_109|index|code|document|push|lastIndex|XRegExp|exec|false||config|new||getParam|true|RegExp|_121|vN|className|prototype||part|css|_107|_c3|create||right|pos|slice|_111|strings|name|_101|class|style|_ed|indexOf|source|id|_122|_12d|_12c|_ca|window|vars|toolbar|innerHTML|_e0|createElement|alert|_x|_131|_12e|_ec|appendChild|obj|_132|lt|_e5|_c6|tab|lib|_bd|highlight|doc|_12a|params|substr|width|nbsp|size|_97|test|_4b|span|_102|continue|value|in|matches|_130|_91|split|_8|_57|min|_3c|lines|_12f|while|_56|font|wnd|text|bar|_d7|toString|_6e|execute|_75|html|_5b|_b7|gt|script|captureNames|attributes|href|_12b|_b4|_b1|height|_f8|_e1|call|http|_f4|_28|break|_da|getMatches|line|_b3|_a1|concat|_51|case|m2|m1|_123|_5|_80|_88|_81|body|_40|_62|_124|_d4|unindent|_c9|_b5|_7a|brushes|SyntaxHighlighter|_2|_22|_f2|_32|title|DIV|_3|offsetMatches|_7d|_7b|_8e|fixForBlogger|url|_7c|_5e|_65|_6a|_5c|_76|_4a|_af|_e9|printFrame|_f0|spaceWidth|_ea|_dc|write|print|_d5|_db|_25|_a6|Math|undefined|_10d|_106|regex|_10c|extended|throw|global|addFlags|_f6|htmlScript|_100|escape|cc|len|trim|_133|quantifier|_9d|_116|getNativeFlags|_9c|_a2|_a5|viewSource|cache|key|_89|eachLine|_2c|HtmlScript|_18|_30|gi|_2f|_ad|com|_105|findBrush|_c0|expandSource|_be|_bc|join|Match|_b9|_c7|_ab|func|esc|_b6|_19|_1a|_11b|_ac|swf|_4c|_9|_b|_49|popup|top|focus|regexList|_50|_4f|_48|_e|_7|_129|_38|contentWindow|link|_4|gm|close|_126|_blank|win|_35|_24|instanceof|_73|_6b|_82|xmlBrush|_17|_11c||removeChild|_7e|color|values|_5d|can|_f|supply|discoveredBrushes|_59|_6c|_10|_37|_d|_8c|r2|content|toolbarItemWidth|highlighters|toolbarItemHeight|copyToClipboard|guid|margin|_2e|_2d|String|originalCode|_2a|collapsed|merge|collapse|_e2|gutter|measureSpace|isNaN|_2b|Array|_29|clipboardSwf|toolbarCommands|ruler|_d2|px|_fb|_d0|_e7|pre|_27|_e6|charAt|highlighterId|_83|_ee|defaults|_14|_128|_f5|escapeChar|one|_5a|noBrush|_61|navigator|TypeError|plain|match|pP|_78|_79|_36|_6d|alexgorbatchev|userAgent|commandName|_66|clipboardData|executeCommand|event|help|auto|_6|createDisplayLines|500px|0px|scrollbars|processUrls|links|stylesheet|rel|_3f|copyStyles|removeNestedMatches|findMatches|processMatches|createRuler|_127|type|_3e|aboutDialog|createButton|attachEvent|matchRecursive|message|when|2009|character|light|clipboard|syntaxhighlighter|_4e|screen|_a|processSmartTabs|processTabs|_47|tabs|smart|trimFirstAndLastLines|switch|multiline|copyToClipboardConfirmation|_85|unicode|head|parentNode|_16|first|shockwave|_ba|_b8|items|addEvent|flash|_13|arguments|_aa|parseParams|_dd|padNumber|_b0|Times|_12|debug|_ff|parseInt|isMatchNested|_cf|org|_c8|classRight|_104|_103|_cd|_cc|_ce|toBoolean|_c5|_d1|brushNotHtmlScript|www|matchesSortCallback|get|_d6|w3|process|_c1|classLeft|tagName|brush|_fd|serif|getElementsByTagName|_fa|_15|bloggerMode|_115|_84|_99|family|_93|block|args|insertSpaces|_fc|_90|decorate|_a3|_e3|_e4|version|center|xhtml1|Highlighter|toArray|_de|regexLib|DTD|_a7|_a0|defaultAdd|_a8|_1e|object|align|try|resizable|contains|catch|400|_20|_1f|onclick|750|menubar|_21|unbalanced|_1b|item|location|_26|param|delimiters|_1c|sans|1999|xhtml|meta|xmlns|dtd|EN|TR|transitional|equiv|Content|Georgia|New|Roman|About|utf|Type|charset|Transitional|XHTML|is|your|now|The|to|expand|view|copy|Can|find|DOCTYPE|PUBLIC|W3C|option|configured|Brush|wasn|background|fff|Gorbatchev|multiLineCComments|singleLineCComments|Alex|2004|syntax|highlighter|Copyright|singleLinePerlComments|doubleQuotedString|aspScriptTags|scriptScriptTags|typeof|phpScriptTags|multiLineSingleQuotedString|singleQuotedString|multiLineDoubleQuotedString|JavaScript|none|Helvetica|xx|large|Arial|Geneva|000|1em|3em|75em|bottom|target|0099FF|decoration|01|March|4em|296|string|open|_119|apply|_8a|offsetWidth|getComputedStyle|getPropertyValue|_98|1000|ignoreCase|textarea|sticky|_a4|_117|opera|getElementById|on|addEventListener|using|the|random|1000000|aliases|than|SyntaxError|valueNames|more|middot|_clipboard|70em|addPlugin|replaceVar|_ef|flags|constructing|from|important|highlighter_|max|forHtmlScript|getKeywords|fontSize|sgi|nogutter|another|spaces|Xml|_bf|load|all|30em|replaceChild|sx|_c4|highlighted|number|alt|sort|lastIndexOf|round|150|flag|msie|src|embed|classid|movie|_33|_34|ok|error|setData|amp|command|cab|swflash|96b8|11cf|Error|444553540000|codebase|ae6d|download|pub|cabs|clsid|macromedia|d27cdb6e|_39|printSource|shCore|about|toLowerCase|allowScriptAccess|always|printing|_42|data|500||250|_44|application|_43|subject|wmode|_3a|flashVars|transparent|_3b|cssText|absolute|position|menu|IFRAME'.split('|'),0,{})) diff --git a/test_script/scripts/shLegacy.js b/test_script/scripts/shLegacy.js index 66f4892f8..8a43ee64e 100644 --- a/test_script/scripts/shLegacy.js +++ b/test_script/scripts/shLegacy.js @@ -1,30 +1,30 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1 y={d:{}};y.d={F:6(S,l,q,k,m,n){6 J(z,Y){1 V=16 15("^"+Y+"\\\\[(?\\\\w+)\\\\]$","14"),x=2;h(1 i=0;i. - */ -// -// Begin anonymous function. This is used to contain local scope variables without polutting global scope. -// -if (!window.SyntaxHighlighter) var SyntaxHighlighter = function() { - -// Shortcut object which will be assigned to the SyntaxHighlighter variable. -// This is a shorthand for local reference in order to avoid long namespace -// references to SyntaxHighlighter.whatever... -var sh = { - defaults : { - /** Additional CSS class names to be added to highlighter elements. */ - 'class-name' : '', - - /** First line number. */ - 'first-line' : 1, - - /** Font size of the SyntaxHighlighter block. */ - 'font-size' : null, - - /** Lines to highlight. */ - 'highlight' : null, - - /** Enables or disables smart tabs. */ - 'smart-tabs' : true, - - /** Gets or sets tab size. */ - 'tab-size' : 4, - - /** Enables or disables ruler. */ - 'ruler' : false, - - /** Enables or disables gutter. */ - 'gutter' : true, - - /** Enables or disables toolbar. */ - 'toolbar' : true, - - /** Forces code view to be collapsed. */ - 'collapse' : false, - - /** Enables or disables automatic links. */ - 'auto-links' : true, - - /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */ - 'light' : false - }, - - config : { - /** Path to the copy to clipboard SWF file. */ - clipboardSwf : null, - - /** Width of an item in the toolbar. */ - toolbarItemWidth : 16, - - /** Height of an item in the toolbar. */ - toolbarItemHeight : 16, - - /** Blogger mode flag. */ - bloggerMode : false, - - /** Name of the tag that SyntaxHighlighter will automatically look for. */ - tagName : 'pre', - - strings : { - expandSource : 'expand source', - viewSource : 'view source', - copyToClipboard : 'copy to clipboard', - copyToClipboardConfirmation : 'The code is in your clipboard now', - print : 'print', - help : '?', - alert: 'SyntaxHighlighter\n\n', - noBrush : 'Can\'t find brush for: ', - brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ', - - // this is populated by the build script - aboutDialog : 'About SyntaxHighlighter
SyntaxHighlighter
version 2.0.296 (March 01 2009)
JavaScript code syntax highlighter.
Copyright 2004-2009 Alex Gorbatchev.
' - }, - - /** If true, output will show HTML produces instead. */ - debug : false - }, - - /** Internal 'global' variables. */ - vars : { - discoveredBrushes : null, - spaceWidth : null, - printFrame : null, - highlighters : {} - }, - - /** This object is populated by user included external brush files. */ - brushes : {}, - - /** Common regular expressions. */ - regexLib : { - multiLineCComments : /\/\*[\s\S]*?\*\//gm, - singleLineCComments : /\/\/.*$/gm, - singleLinePerlComments : /#.*$/gm, - doubleQuotedString : /"(?:\.|(\\\")|[^\""\n])*"/g, - singleQuotedString : /'(?:\.|(\\\')|[^\''\n])*'/g, - multiLineDoubleQuotedString : /"(?:\.|(\\\")|[^\""])*"/g, - multiLineSingleQuotedString : /'(?:\.|(\\\')|[^\''])*'/g, - url : /\w+:\/\/[\w-.\/?%&=]*/g, - - /** tags. */ - phpScriptTags : { left: /(<|<)\?=?/g, right: /\?(>|>)/g }, - - /** <%= %> tags. */ - aspScriptTags : { left: /(<|<)%=?/g, right: /%(>|>)/g }, - - /** tags. */ - scriptScriptTags : { left: /(<|<)\s*script.*?(>|>)/gi, right: /(<|<)\/\s*script\s*(>|>)/gi } - }, - - toolbar : { - /** - * Creates new toolbar for a highlighter. - * @param {Highlighter} highlighter Target highlighter. - */ - create : function(highlighter) - { - var div = document.createElement('DIV'), - items = sh.toolbar.items - ; - - div.className = 'toolbar'; - - for (var name in items) - { - var constructor = items[name], - command = new constructor(highlighter), - element = command.create() - ; - - highlighter.toolbarCommands[name] = command; - - if (element == null) - continue; - - if (typeof(element) == 'string') - element = sh.toolbar.createButton(element, highlighter.id, name); - - element.className += 'item ' + name; - div.appendChild(element); - } - - return div; - }, - - /** - * Create a standard anchor button for the toolbar. - * @param {String} label Label text to display. - * @param {String} highlighterId Highlighter ID that this button would belong to. - * @param {String} commandName Command name that would be executed. - * @return {Element} Returns an 'A' element. - */ - createButton : function(label, highlighterId, commandName) - { - var a = document.createElement('a'), - style = a.style, - config = sh.config, - width = config.toolbarItemWidth, - height = config.toolbarItemHeight - ; - - a.href = '#' + commandName; - a.title = label; - a.highlighterId = highlighterId; - a.commandName = commandName; - a.innerHTML = label; - - if (isNaN(width) == false) - style.width = width + 'px'; - - if (isNaN(height) == false) - style.height = height + 'px'; - - a.onclick = function(e) - { - try - { - sh.toolbar.executeCommand( - this, - e || window.event, - this.highlighterId, - this.commandName - ); - } - catch(e) - { - sh.utils.alert(e.message); - } - - return false; - }; - - return a; - }, - - /** - * Executes a toolbar command. - * @param {Element} sender Sender element. - * @param {MouseEvent} event Original mouse event object. - * @param {String} highlighterId Highlighter DIV element ID. - * @param {String} commandName Name of the command to execute. - * @return {Object} Passes out return value from command execution. - */ - executeCommand : function(sender, event, highlighterId, commandName, args) - { - var highlighter = sh.vars.highlighters[highlighterId], - command - ; - - if (highlighter == null || (command = highlighter.toolbarCommands[commandName]) == null) - return null; - - return command.execute(sender, event, args); - }, - - /** Collection of toolbar items. */ - items : { - expandSource : function(highlighter) - { - this.create = function() - { - if (highlighter.getParam('collapse') != true) - return; - - return sh.config.strings.expandSource; - }; - - this.execute = function(sender, event, args) - { - var div = highlighter.div; - - sender.parentNode.removeChild(sender); - div.className = div.className.replace('collapsed', ''); - }; - }, - - /** - * Command to open a new window and display the original unformatted source code inside. - */ - viewSource : function(highlighter) - { - this.create = function() - { - return sh.config.strings.viewSource; - }; - - this.execute = function(sender, event, args) - { - var code = sh.utils.fixForBlogger(highlighter.originalCode).replace(/' + code + ''); - wnd.document.close(); - }; - }, - - /** - * Command to copy the original source code in to the clipboard. - * Uses Flash method if clipboardSwf is configured. - */ - copyToClipboard : function(highlighter) - { - var flashDiv, flashSwf, - highlighterId = highlighter.id - ; - - this.create = function() - { - var config = sh.config; - - // disable functionality if running locally - if (config.clipboardSwf == null) - return null; - - function params(list) - { - var result = ''; - - for (var name in list) - result += ""; - - return result; - }; - - function attributes(list) - { - var result = ''; - - for (var name in list) - result += " " + name + "='" + list[name] + "'"; - - return result; - }; - - var args1 = { - width : config.toolbarItemWidth, - height : config.toolbarItemHeight, - id : highlighterId + '_clipboard', - type : 'application/x-shockwave-flash', - title : sh.config.strings.copyToClipboard - }, - - // these arguments are used in IE's collection - args2 = { - allowScriptAccess : 'always', - wmode : 'transparent', - flashVars : 'highlighterId=' + highlighterId, - menu : 'false' - }, - swf = config.clipboardSwf, - html - ; - - if (/msie/i.test(navigator.userAgent)) - { - html = '' - + params(args2) - + params({ movie : swf }) - + '' - ; - } - else - { - html = '' - ; - } - - flashDiv = document.createElement('div'); - flashDiv.innerHTML = html; - - return flashDiv; - }; - - this.execute = function(sender, event, args) - { - var command = args.command; - - switch (command) - { - case 'get': - var code = sh.utils.unindent( - sh.utils.fixForBlogger(highlighter.originalCode) - .replace(/</g, '<') - .replace(/>/g, '>') - .replace(/&/g, '&') - ); - - if(window.clipboardData) - // will fall through to the confirmation because there isn't a break - window.clipboardData.setData('text', code); - else - return sh.utils.unindent(code); - - case 'ok': - sh.utils.alert(sh.config.strings.copyToClipboardConfirmation); - break; - - case 'error': - sh.utils.alert(args.message); - break; - } - }; - }, - - /** Command to print the colored source code. */ - printSource : function(highlighter) - { - this.create = function() - { - return sh.config.strings.print; - }; - - this.execute = function(sender, event, args) - { - var iframe = document.createElement('IFRAME'), - doc = null - ; - - // make sure there is never more than one hidden iframe created by SH - if (sh.vars.printFrame != null) - document.body.removeChild(sh.vars.printFrame); - - sh.vars.printFrame = iframe; - - // this hides the iframe - iframe.style.cssText = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;'; - - document.body.appendChild(iframe); - doc = iframe.contentWindow.document; - - copyStyles(doc, window.document); - doc.write('
' + highlighter.div.innerHTML + '
'); - doc.close(); - - iframe.contentWindow.focus(); - iframe.contentWindow.print(); - - function copyStyles(destDoc, sourceDoc) - { - var links = sourceDoc.getElementsByTagName('link'); - - for(var i = 0; i < links.length; i++) - if(links[i].rel.toLowerCase() == 'stylesheet' && /shCore\.css$/.test(links[i].href)) - destDoc.write(''); - }; - }; - }, - - /** Command to display the about dialog window. */ - about : function(highlighter) - { - this.create = function() - { - return sh.config.strings.help; - }; - - this.execute = function(sender, event) - { - var wnd = sh.utils.popup('', '_blank', 500, 250, 'scrollbars=0'), - doc = wnd.document - ; - - doc.write(sh.config.strings.aboutDialog); - doc.close(); - wnd.focus(); - }; - } - } - }, - - utils : { - guid : function(prefix) - { - return prefix + Math.round(Math.random() * 1000000).toString(); - }, - - /** - * Merges two objects. Values from obj2 override values in obj1. - * Function is NOT recursive and works only for one dimensional objects. - * @param {Object} obj1 First object. - * @param {Object} obj2 Second object. - * @return {Object} Returns combination of both objects. - */ - merge: function(obj1, obj2) - { - var result = {}, name; - - for (name in obj1) - result[name] = obj1[name]; - - for (name in obj2) - result[name] = obj2[name]; - - return result; - }, - - /** - * Attempts to convert string to boolean. - * @param {String} value Input string. - * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise. - */ - toBoolean: function(value) - { - switch (value) - { - case "true": - return true; - - case "false": - return false; - } - - return value; - }, - - /** - * Opens up a centered popup window. - * @param {String} url URL to open in the window. - * @param {String} name Popup name. - * @param {int} width Popup width. - * @param {int} height Popup height. - * @param {String} options window.open() options. - * @return {Window} Returns window instance. - */ - popup: function(url, name, width, height, options) - { - var x = (screen.width - width) / 2, - y = (screen.height - height) / 2 - ; - - options += ', left=' + x + - ', top=' + y + - ', width=' + width + - ', height=' + height - ; - options = options.replace(/^,/, ''); - - var win = window.open(url, name, options); - win.focus(); - return win; - }, - - /** - * Adds event handler to the target object. - * @param {Object} obj Target object. - * @param {String} type Name of the event. - * @param {Function} func Handling function. - */ - addEvent: function(obj, type, func) - { - if (obj.attachEvent) - { - obj['e' + type + func] = func; - obj[type + func] = function() - { - obj['e' + type + func](window.event); - } - obj.attachEvent('on' + type, obj[type + func]); - } - else - { - obj.addEventListener(type, func, false); - } - }, - - /** - * Displays an alert. - * @param {String} str String to display. - */ - alert: function(str) - { - alert(sh.config.strings.alert + str) - }, - - /** - * Finds a brush by its alias. - * - * @param {String} alias Brush alias. - * @param {Boolean} alert Suppresses the alert if false. - * @return {Brush} Returns bursh constructor if found, null otherwise. - */ - findBrush: function(alias, alert) - { - var brushes = sh.vars.discoveredBrushes, - result = null - ; - - if (brushes == null) - { - brushes = {}; - - // Find all brushes - for (var brush in sh.brushes) - { - var aliases = sh.brushes[brush].aliases; - - if (aliases == null) - continue; - - for (var i = 0; i < aliases.length; i++) - brushes[aliases[i]] = brush; - } - - sh.vars.discoveredBrushes = brushes; - } - - result = sh.brushes[brushes[alias]]; - - if (result == null && alert != false) - sh.utils.alert(sh.config.strings.noBrush + alias); - - return result; - }, - - /** - * Executes a callback on each line and replaces each line with result from the callback. - * @param {Object} str Input string. - * @param {Object} callback Callback function taking one string argument and returning a string. - */ - eachLine: function(str, callback) - { - var lines = str.split('\n'); - - for (var i = 0; i < lines.length; i++) - lines[i] = callback(lines[i]); - - return lines.join('\n'); - }, - - /** - * Creates rules looking div. - */ - createRuler: function() - { - var div = document.createElement('div'), - ruler = document.createElement('div'), - showEvery = 10, - i = 1 - ; - - while (i <= 150) - { - if (i % showEvery === 0) - { - div.innerHTML += i; - i += (i + '').length; - } - else - { - div.innerHTML += '·'; - i++; - } - } - - ruler.className = 'ruler line'; - ruler.appendChild(div); - - return ruler; - }, - - /** - * This is a special trim which only removes first and last empty lines - * and doesn't affect valid leading space on the first line. - * - * @param {String} str Input string - * @return {String} Returns string without empty first and last lines. - */ - trimFirstAndLastLines: function(str) - { - return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, ''); - }, - - /** - * Parses key/value pairs into hash object. - * - * Understands the following formats: - * - name: word; - * - name: [word, word]; - * - name: "string"; - * - name: 'string'; - * - * For example: - * name1: value; name2: [value, value]; name3: 'value' - * - * @param {String} str Input string. - * @return {Object} Returns deserialized object. - */ - parseParams: function(str) - { - var match, - result = {}, - arrayRegex = new XRegExp("^\\[(?(.*?))\\]$"), - regex = new XRegExp( - "(?[\\w-]+)" + - "\\s*:\\s*" + - "(?" + - "[\\w-%#]+|" + // word - "\\[.*?\\]|" + // [] array - '".*?"|' + // "" string - "'.*?'" + // '' string - ")\\s*;?", - "g" - ) - ; - - while ((match = regex.exec(str)) != null) - { - var value = match.value - .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings - ; - - // try to parse array value - if (value != null && arrayRegex.test(value)) - { - var m = arrayRegex.exec(value); - value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : []; - } - - result[match.name] = value; - } - - return result; - }, - - /** - * Wraps each line of the string into tag with given style applied to it. - * - * @param {String} str Input string. - * @param {String} css Style name to apply to the string. - * @return {String} Returns input string with each line surrounded by tag. - */ - decorate: function(str, css) - { - if (str == null || str.length == 0 || str == '\n') - return str; - - str = str.replace(/... to them so that - // leading spaces aren't included. - if (css != null) - str = sh.utils.eachLine(str, function(line) - { - if (line.length == 0) - return ''; - - var spaces = ''; - - line = line.replace(/^( | )+/, function(s) - { - spaces = s; - return ''; - }); - - if (line.length == 0) - return spaces; - - return spaces + '' + line + ''; - }); - - return str; - }, - - /** - * Pads number with zeros until it's length is the same as given length. - * - * @param {Number} number Number to pad. - * @param {Number} length Max string length with. - * @return {String} Returns a string padded with proper amount of '0'. - */ - padNumber : function(number, length) - { - var result = number.toString(); - - while (result.length < length) - result = '0' + result; - - return result; - }, - - /** - * Measures width of a single space character. - * @return {Number} Returns width of a single space character. - */ - measureSpace : function() - { - var container = document.createElement('div'), - span, - result = 0, - body = document.body, - id = sh.utils.guid('measureSpace'), - - // variable names will be compressed, so it's better than a plain string - divOpen = '
' - + divOpen + 'lines">' - + divOpen + 'line">' - + divOpen + 'content' - + '"> ' + closeSpan + closeSpan - + closeDiv - + closeDiv - + closeDiv - + closeDiv - ; - - body.appendChild(container); - span = document.getElementById(id); - - if (/opera/i.test(navigator.userAgent)) - { - var style = window.getComputedStyle(span, null); - result = parseInt(style.getPropertyValue("width")); - } - else - { - result = span.offsetWidth; - } - - body.removeChild(container); - - return result; - }, - - /** - * Replaces tabs with spaces. - * - * @param {String} code Source code. - * @param {Number} tabSize Size of the tab. - * @return {String} Returns code with all tabs replaces by spaces. - */ - processTabs : function(code, tabSize) - { - var tab = ''; - - for (var i = 0; i < tabSize; i++) - tab += ' '; - - return code.replace(/\t/g, tab); - }, - - /** - * Replaces tabs with smart spaces. - * - * @param {String} code Code to fix the tabs in. - * @param {Number} tabSize Number of spaces in a column. - * @return {String} Returns code with all tabs replaces with roper amount of spaces. - */ - processSmartTabs : function(code, tabSize) - { - var lines = code.split('\n'), - tab = '\t', - spaces = '' - ; - - // Create a string with 1000 spaces to copy spaces from... - // It's assumed that there would be no indentation longer than that. - for (var i = 0; i < 50; i++) - spaces += ' '; // 20 spaces * 50 - - // This function inserts specified amount of spaces in the string - // where a tab is while removing that given tab. - function insertSpaces(line, pos, count) - { - return line.substr(0, pos) - + spaces.substr(0, count) - + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab - ; - }; - - // Go through all the lines and do the 'smart tabs' magic. - code = sh.utils.eachLine(code, function(line) - { - if (line.indexOf(tab) == -1) - return line; - - var pos = 0; - - while ((pos = line.indexOf(tab)) != -1) - { - // This is pretty much all there is to the 'smart tabs' logic. - // Based on the position within the line and size of a tab, - // calculate the amount of spaces we need to insert. - var spaces = tabSize - pos % tabSize; - line = insertSpaces(line, pos, spaces); - } - - return line; - }); - - return code; - }, - - fixForBlogger : function(str) - { - return (sh.config.bloggerMode == true) ? str.replace(/|<br\s*\/?>/gi, '\n') : str; - }, - - /** - * Removes all white space at the begining and end of a string. - * - * @param {String} str String to trim. - * @return {String} Returns string without leading and following white space characters. - */ - trim: function(str) - { - return str.replace(/\s*$/g, '').replace(/^\s*/, ''); - }, - - /** - * Unindents a block of text by the lowest common indent amount. - * @param {String} str Text to unindent. - * @return {String} Returns unindented text block. - */ - unindent: function(str) - { - var lines = sh.utils.fixForBlogger(str).split('\n'), - indents = new Array(), - regex = /^\s*/, - min = 1000 - ; - - // go through every line and check for common number of indents - for (var i = 0; i < lines.length && min > 0; i++) - { - var line = lines[i]; - - if (sh.utils.trim(line).length == 0) - continue; - - var matches = regex.exec(line); - - // In the event that just one line doesn't have leading white space - // we can't unindent anything, so bail completely. - if (matches == null) - return str; - - min = Math.min(matches[0].length, min); - } - - // trim minimum common number of white space from the begining of every line - if (min > 0) - for (var i = 0; i < lines.length; i++) - lines[i] = lines[i].substr(min); - - return lines.join('\n'); - }, - - /** - * Callback method for Array.sort() which sorts matches by - * index position and then by length. - * - * @param {Match} m1 Left object. - * @param {Match} m2 Right object. - * @return {Number} Returns -1, 0 or -1 as a comparison result. - */ - matchesSortCallback: function(m1, m2) - { - // sort matches by index first - if(m1.index < m2.index) - return -1; - else if(m1.index > m2.index) - return 1; - else - { - // if index is the same, sort by length - if(m1.length < m2.length) - return -1; - else if(m1.length > m2.length) - return 1; - } - - return 0; - }, - - /** - * Executes given regular expression on provided code and returns all - * matches that are found. - * - * @param {String} code Code to execute regular expression on. - * @param {Object} regex Regular expression item info from regexList collection. - * @return {Array} Returns a list of Match objects. - */ - getMatches: function(code, regexInfo) - { - function defaultAdd(match, regexInfo) - { - return [new sh.Match(match[0], match.index, regexInfo.css)]; - }; - - var index = 0, - match = null, - result = [], - func = regexInfo.func ? regexInfo.func : defaultAdd - ; - - while((match = regexInfo.regex.exec(code)) != null) - result = result.concat(func(match, regexInfo)); - - return result; - }, - - processUrls: function(code) - { - return code.replace(sh.regexLib.url, function(m) - { - return '' + m + ''; - }); - } - }, // end of utils - - /** - * Shorthand to highlight all elements on the page that are marked as - * SyntaxHighlighter source code. - * - * @param {Object} globalParams Optional parameters which override element's - * parameters. Only used if element is specified. - * - * @param {Object} element Optional element to highlight. If none is - * provided, all elements in the current document - * are highlighted. - */ - highlight : function(globalParams, element) - { - function toArray(source) - { - var result = []; - - for (var i = 0; i < source.length; i++) - result.push(source[i]); - - return result; - }; - - var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)), - propertyName = 'innerHTML', - highlighter = null - ; - - if (elements.length === 0) - return; - - for (var i = 0; i < elements.length; i++) - { - var target = elements[i], - params = sh.utils.parseParams(target.className), - brushName - ; - - // local params take precedence over globals - params = sh.utils.merge(globalParams, params); - brushName = params['brush']; - - if (brushName == null) - continue; - - // Instantiate a brush - if (params['html-script'] == 'true') - { - highlighter = new sh.HtmlScript(brushName); - } - else - { - var brush = sh.utils.findBrush(brushName); - - if (brush) - highlighter = new brush(); - else - continue; - } - - highlighter.highlight(target[propertyName], params); - - var result = highlighter.div; - - if (sh.config.debug) - { - result = document.createElement('textarea'); - result.value = highlighter.div.innerHTML; - result.style.width = '70em'; - result.style.height = '30em'; - } - - target.parentNode.replaceChild(result, target); - } - }, - - /** - * Main entry point for the SyntaxHighlighter. - * @param {Object} params Optional params to apply to all highlighted elements. - */ - all : function(params) - { - sh.utils.addEvent( - window, - 'load', - function() { sh.highlight(params); } - ); - } -}; // end of sh - -/** Match object */ -sh.Match = function(value, index, css) -{ - this.value = value; - this.index = index; - this.length = value.length; - this.css = css; -}; - -sh.Match.prototype.toString = function() -{ - return this.value; -}; - -/** - * Simulates HTML code with a scripting language embedded. - * - * @param {String} scriptBrushName Brush name of the scripting language. - */ -sh.HtmlScript = function(scriptBrushName) -{ - var scriptBrush = sh.utils.findBrush(scriptBrushName), - xmlBrush = new sh.brushes.Xml(), - bracketsRegex = null - ; - - if (scriptBrush == null) - return; - - scriptBrush = new scriptBrush(); - this.xmlBrush = xmlBrush; - - if (scriptBrush.htmlScript == null) - { - sh.utils.alert(sh.config.strings.brushNotHtmlScript + scriptBrushName); - return; - } - - xmlBrush.regexList.push( - { regex: scriptBrush.htmlScript.code, func: process } - ); - - function offsetMatches(matches, offset) - { - for (var j = 0; j < matches.length; j++) - matches[j].index += offset; - } - - function process(match, info) - { - var code = match.code, - matches = [], - regexList = scriptBrush.regexList, - offset = match.index + match.left.length, - htmlScript = scriptBrush.htmlScript, - result - ; - - for (var i = 0; i < regexList.length; i++) - { - result = sh.utils.getMatches(code, regexList[i]); - offsetMatches(result, offset); - matches = matches.concat(result); - } - - if (htmlScript.left != null && match.left != null) - { - result = sh.utils.getMatches(match.left, htmlScript.left); - offsetMatches(result, match.index); - matches = matches.concat(result); - } - - if (htmlScript.right != null && match.right != null) - { - result = sh.utils.getMatches(match.right, htmlScript.right); - offsetMatches(result, match.index + match[0].lastIndexOf(match.right)); - matches = matches.concat(result); - } - - return matches; - } -}; - -sh.HtmlScript.prototype.highlight = function(code, params) -{ - this.xmlBrush.highlight(code, params); - this.div = this.xmlBrush.div; -} - -/** - * Main Highlither class. - * @constructor - */ -sh.Highlighter = function() -{ -}; - -sh.Highlighter.prototype = { - /** - * Returns value of the parameter passed to the highlighter. - * @param {String} name Name of the parameter. - * @param {Object} defaultValue Default value. - * @return {Object} Returns found value or default value otherwise. - */ - getParam : function(name, defaultValue) - { - var result = this.params[name]; - return sh.utils.toBoolean(result == null ? defaultValue : result); - }, - - /** - * Shortcut to document.createElement(). - * @param {String} name Name of the element to create (DIV, A, etc). - * @return {HTMLElement} Returns new HTML element. - */ - create: function(name) - { - return document.createElement(name); - }, - - /** - * Checks if one match is inside another. - * @param {Match} match Match object to check. - * @return {Boolean} Returns true if given match was inside another, false otherwise. - */ - isMatchNested: function(match) - { - for (var i = 0; i < this.matches.length; i++) - { - var item = this.matches[i]; - - if (item === null) - continue; - - if ((match.index > item.index) && (match.index < item.index + item.length)) - return true; - } - - return false; - }, - - /** - * Applies all regular expression to the code and stores all found - * matches in the `this.matches` array. - * @param {Array} regexList List of regular expressions. - * @param {String} code Source code. - * @return {Array} Returns list of matches. - */ - findMatches: function(regexList, code) - { - var result = []; - - if (regexList != null) - for (var i = 0; i < regexList.length; i++) - result = result.concat(sh.utils.getMatches(code, regexList[i])); - - // sort the matches - result = result.sort(sh.utils.matchesSortCallback); - - return result; - }, - - /** - * Checks to see if any of the matches are inside of other matches. - * This process would get rid of highligted strings inside comments, - * keywords inside strings and so on. - */ - removeNestedMatches: function() - { - for (var i = 0; i < this.matches.length; i++) - if (this.isMatchNested(this.matches[i])) - this.matches[i] = null; - }, - - /** - * Splits block of text into individual DIV lines. - * @param {String} code Code to highlight. - * @return {String} Returns highlighted code in HTML form. - */ - createDisplayLines : function(code) - { - var lines = code.split(/\n/g), - firstLine = parseInt(this.getParam('first-line')), - padLength = (firstLine + lines.length).toString().length, - highlightedLines = this.getParam('highlight', []) - ; - - code = ''; - - for (var i = 0; i < lines.length; i++) - { - var line = lines[i], - indent = /^( |\s)+/.exec(line), - lineClass = 'line alt' + (i % 2 == 0 ? 1 : 2), - lineNumber = sh.utils.padNumber(firstLine + i, padLength), - highlighted = highlightedLines.indexOf((firstLine + i).toString()) != -1, - spaces = null - ; - - if (indent != null) - { - spaces = indent[0].toString(); - line = line.substr(spaces.length); - spaces = spaces.replace(/ /g, ' '); - indent = sh.vars.spaceWidth * spaces.length; - } - else - { - indent = 0; - } - - line = sh.utils.trim(line); - - if (line.length == 0) - line = ' '; - - if (highlighted) - lineClass += ' highlighted'; - - code += - '
' - + '' + lineNumber + '.' - + '' - + (spaces != null ? '' + spaces.replace(/\s/g, ' ') + '' : '') - + '' + line + '' - + '' - + '
' - ; - } - - return code; - }, - - /** - * Finds all matches in the source code. - * @param {String} code Source code to process matches in. - * @param {Array} matches Discovered regex matches. - * @return {String} Returns formatted HTML with processed mathes. - */ - processMatches: function(code, matches) - { - var pos = 0, - result = '', - decorate = sh.utils.decorate // make an alias to save some bytes - ; - - // Finally, go through the final list of matches and pull the all - // together adding everything in between that isn't a match. - for (var i = 0; i < matches.length; i++) - { - var match = matches[i]; - - if (match === null || match.length === 0) - continue; - - result += decorate(code.substr(pos, match.index - pos), 'plain') - + decorate(match.value, match.css) - ; - - pos = match.index + match.length; - } - - // don't forget to add whatever's remaining in the string - result += decorate(code.substr(pos), 'plain'); - - return result; - }, - - /** - * Highlights the code and returns complete HTML. - * @param {String} code Code to highlight. - * @param {Object} params Parameters object. - */ - highlight: function(code, params) - { - var conf = sh.config, - vars = sh.vars, - div, - tabSize - ; - - this.params = {}; - this.div = null; - this.lines = null; - this.code = null; - this.bar = null; - this.toolbarCommands = {}; - this.id = sh.utils.guid('highlighter_'); - - // register this instance in the highlighters list - vars.highlighters[this.id] = this; - - if (code === null) - code = ''; - - // Measure width of a single space. - if (vars.spaceWidth === null) - vars.spaceWidth = sh.utils.measureSpace(); - - // local params take precedence over defaults - this.params = sh.utils.merge(sh.defaults, params || {}); - - // process light mode - if (this.getParam('light') == true) - this.params.toolbar = this.params.gutter = false; - - this.div = div = this.create('DIV'); - this.lines = this.create('DIV'); - this.lines.className = 'lines'; - - div.className = 'syntaxhighlighter'; - div.id = this.id; - - if (this.getParam('collapse')) - div.className += ' collapsed'; - - if (this.getParam('gutter') == false) - div.className += ' nogutter'; - - div.className += ' ' + this.getParam('class-name'); - div.style.fontSize = this.getParam('font-size', ''); // IE7 can't take null - - this.originalCode = code; - this.code = sh.utils.trimFirstAndLastLines(code) - .replace(/\r/g, ' ') // IE lets these buggers through - ; - - tabSize = this.getParam('tab-size'); - - // replace tabs with spaces - this.code = this.getParam('smart-tabs') == true - ? sh.utils.processSmartTabs(this.code, tabSize) - : sh.utils.processTabs(this.code, tabSize) - ; - - this.code = sh.utils.unindent(this.code); - - // add controls toolbar - if (this.getParam('toolbar')) - { - this.bar = this.create('DIV'); - this.bar.className = 'bar'; - this.bar.appendChild(sh.toolbar.create(this)); - div.appendChild(this.bar); - } - - // add columns ruler - if (this.getParam('ruler')) - div.appendChild(sh.utils.createRuler()); - - div.appendChild(this.lines); - - this.matches = this.findMatches(this.regexList, this.code); - this.removeNestedMatches(); - - code = this.processMatches(this.code, this.matches); - - // finally, split all lines so that they wrap well - code = this.createDisplayLines(sh.utils.trim(code)); - - // finally, process the links - if (this.getParam('auto-links')) - code = sh.utils.processUrls(code); - - this.lines.innerHTML = code; - }, - - /** - * Converts space separated list of keywords into a regular expression string. - * @param {String} str Space separated keywords. - * @return {String} Returns regular expression string. - */ - getKeywords: function(str) - { - str = str - .replace(/^\s+|\s+$/g, '') - .replace(/\s+/g, '\\b|\\b') - ; - - return '\\b' + str + '\\b'; - }, - - /** - * Makes a brush compatible with the `html-script` functionality. - * @param {Object} regexGroup Object containing `left` and `right` regular expressions. - */ - forHtmlScript: function(regexGroup) - { - this.htmlScript = { - left : { regex: regexGroup.left, css: 'script' }, - right : { regex: regexGroup.right, css: 'script' }, - code : new XRegExp( - "(?" + regexGroup.left.source + ")" + - "(?.*?)" + - "(?" + regexGroup.right.source + ")", - "sgi" - ) - }; - } -}; // end of Highlighter - -return sh; -}(); // end of anonymous function - -if (!Array.indexOf) - /** - * Finds an index of element in the array. - * @ignore - * @param {Object} searchElement - * @param {Number} fromIndex - * @return {Number} Returns index of element if found; -1 otherwise. - */ - Array.prototype.indexOf = function (searchElement, fromIndex) - { - fromIndex = Math.max(fromIndex || 0, 0); - - for (var i = fromIndex; i < this.length; i++) - if(this[i] == searchElement) - return i; - - return -1; - }; - -/** - * XRegExp 0.6.1 - * (c) 2007-2008 Steven Levithan - * - * MIT License - * - * provides an augmented, cross-browser implementation of regular expressions - * including support for additional modifiers and syntax. several convenience - * methods and a recursive-construct parser are also included. - */ - -// prevent running twice, which would break references to native globals -if (!window.XRegExp) { -// anonymous function to avoid global variables -(function () { -// copy various native globals for reference. can't use the name ``native`` -// because it's a reserved JavaScript keyword. -var real = { - exec: RegExp.prototype.exec, - match: String.prototype.match, - replace: String.prototype.replace, - split: String.prototype.split - }, - /* regex syntax parsing with support for all the necessary cross- - browser and context issues (escapings, character classes, etc.) */ - lib = { - part: /(?:[^\\([#\s.]+|\\(?!k<[\w$]+>|[pP]{[^}]+})[\S\s]?|\((?=\?(?!#|<[\w$]+>)))+|(\()(?:\?(?:(#)[^)]*\)|<([$\w]+)>))?|\\(?:k<([\w$]+)>|[pP]{([^}]+)})|(\[\^?)|([\S\s])/g, - replaceVar: /(?:[^$]+|\$(?![1-9$&`']|{[$\w]+}))+|\$(?:([1-9]\d*|[$&`'])|{([$\w]+)})/g, - extended: /^(?:\s+|#.*)+/, - quantifier: /^(?:[?*+]|{\d+(?:,\d*)?})/, - classLeft: /&&\[\^?/g, - classRight: /]/g - }, - indexOf = function (array, item, from) { - for (var i = from || 0; i < array.length; i++) - if (array[i] === item) return i; - return -1; - }, - brokenExecUndef = /()??/.exec("")[1] !== undefined, - plugins = {}; - -/** - * Accepts a pattern and flags, returns a new, extended RegExp object. - * differs from a native regex in that additional flags and syntax are - * supported and browser inconsistencies are ameliorated. - * @ignore - */ -XRegExp = function (pattern, flags) { - if (pattern instanceof RegExp) { - if (flags !== undefined) - throw TypeError("can't supply flags when constructing one RegExp from another"); - return pattern.addFlags(); // new copy - } - - var flags = flags || "", - singleline = flags.indexOf("s") > -1, - extended = flags.indexOf("x") > -1, - hasNamedCapture = false, - captureNames = [], - output = [], - part = lib.part, - match, cc, len, index, regex; - - part.lastIndex = 0; // in case the last XRegExp compilation threw an error (unbalanced character class) - - while (match = real.exec.call(part, pattern)) { - // comment pattern. this check must come before the capturing group check, - // because both match[1] and match[2] will be non-empty. - if (match[2]) { - // keep tokens separated unless the following token is a quantifier - if (!lib.quantifier.test(pattern.slice(part.lastIndex))) - output.push("(?:)"); - // capturing group - } else if (match[1]) { - captureNames.push(match[3] || null); - if (match[3]) - hasNamedCapture = true; - output.push("("); - // named backreference - } else if (match[4]) { - index = indexOf(captureNames, match[4]); - // keep backreferences separate from subsequent literal numbers - // preserve backreferences to named groups that are undefined at this point as literal strings - output.push(index > -1 ? - "\\" + (index + 1) + (isNaN(pattern.charAt(part.lastIndex)) ? "" : "(?:)") : - match[0] - ); - // unicode element (requires plugin) - } else if (match[5]) { - output.push(plugins.unicode ? - plugins.unicode.get(match[5], match[0].charAt(1) === "P") : - match[0] - ); - // character class opening delimiter ("[" or "[^") - // (non-native unicode elements are not supported within character classes) - } else if (match[6]) { - if (pattern.charAt(part.lastIndex) === "]") { - // for cross-browser compatibility with ECMA-262 v3 behavior, - // convert [] to (?!) and [^] to [\S\s]. - output.push(match[6] === "[" ? "(?!)" : "[\\S\\s]"); - part.lastIndex++; - } else { - // parse the character class with support for inner escapes and - // ES4's infinitely nesting intersection syntax ([&&[^&&[]]]). - cc = XRegExp.matchRecursive("&&" + pattern.slice(match.index), lib.classLeft, lib.classRight, "", {escapeChar: "\\"})[0]; - output.push(match[6] + cc + "]"); - part.lastIndex += cc.length + 1; - } - // dot ("."), pound sign ("#"), or whitespace character - } else if (match[7]) { - if (singleline && match[7] === ".") { - output.push("[\\S\\s]"); - } else if (extended && lib.extended.test(match[7])) { - len = real.exec.call(lib.extended, pattern.slice(part.lastIndex - 1))[0].length; - // keep tokens separated unless the following token is a quantifier - if (!lib.quantifier.test(pattern.slice(part.lastIndex - 1 + len))) - output.push("(?:)"); - part.lastIndex += len - 1; - } else { - output.push(match[7]); - } - } else { - output.push(match[0]); - } - } - - regex = RegExp(output.join(""), real.replace.call(flags, /[sx]+/g, "")); - regex._x = { - source: pattern, - captureNames: hasNamedCapture ? captureNames : null - }; - return regex; -}; - -/** - * Barebones plugin support for now (intentionally undocumented) - * @ignore - * @param {Object} name - * @param {Object} o - */ -XRegExp.addPlugin = function (name, o) { - plugins[name] = o; -}; - -/** - * Adds named capture support, with values returned as ``result.name``. - * - * Also fixes two cross-browser issues, following the ECMA-262 v3 spec: - * - captured values for non-participating capturing groups should be returned - * as ``undefined``, rather than the empty string. - * - the regex's ``lastIndex`` should not be incremented after zero-length - * matches. - * @ignore - */ -RegExp.prototype.exec = function (str) { - var match = real.exec.call(this, str), - name, i, r2; - if (match) { - // fix browsers whose exec methods don't consistently return - // undefined for non-participating capturing groups - if (brokenExecUndef && match.length > 1) { - // r2 doesn't need /g or /y, but they shouldn't hurt - r2 = new RegExp("^" + this.source + "$(?!\\s)", this.getNativeFlags()); - real.replace.call(match[0], r2, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } - // attach named capture properties - if (this._x && this._x.captureNames) { - for (i = 1; i < match.length; i++) { - name = this._x.captureNames[i - 1]; - if (name) match[name] = match[i]; - } - } - // fix browsers that increment lastIndex after zero-length matches - if (this.global && this.lastIndex > (match.index + match[0].length)) - this.lastIndex--; - } - return match; -}; -})(); // end anonymous function -} // end if(!window.XRegExp) - -/** - * intentionally undocumented - * @ignore - */ -RegExp.prototype.getNativeFlags = function () { - return (this.global ? "g" : "") + - (this.ignoreCase ? "i" : "") + - (this.multiline ? "m" : "") + - (this.extended ? "x" : "") + - (this.sticky ? "y" : ""); -}; - -/** - * Accepts flags; returns a new XRegExp object generated by recompiling - * the regex with the additional flags (may include non-native flags). - * The original regex object is not altered. - * @ignore - */ -RegExp.prototype.addFlags = function (flags) { - var regex = new XRegExp(this.source, (flags || "") + this.getNativeFlags()); - if (this._x) { - regex._x = { - source: this._x.source, - captureNames: this._x.captureNames ? this._x.captureNames.slice(0) : null - }; - } - return regex; -}; - -/** - * Accepts a context object and string; returns the result of calling - * ``exec`` with the provided string. the context is ignored but is - * accepted for congruity with ``Function.prototype.call``. - * @ignore - */ -RegExp.prototype.call = function (context, str) { - return this.exec(str); -}; - -/** - * Accepts a context object and arguments array; returns the result of - * calling ``exec`` with the first value in the arguments array. the context - * is ignored but is accepted for congruity with ``Function.prototype.apply``. - * @ignore - */ -RegExp.prototype.apply = function (context, args) { - return this.exec(args[0]); -}; - -/** - * Accepts a pattern and flags; returns an XRegExp object. if the pattern - * and flag combination has previously been cached, the cached copy is - * returned, otherwise the new object is cached. - * @ignore - */ -XRegExp.cache = function (pattern, flags) { - var key = "/" + pattern + "/" + (flags || ""); - return XRegExp.cache[key] || (XRegExp.cache[key] = new XRegExp(pattern, flags)); -}; - -/** - * Accepts a string; returns the string with regex metacharacters escaped. - * the returned string can safely be used within a regex to match a literal - * string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \, ^, $, - * |, #, [comma], and whitespace. - * @ignore - */ -XRegExp.escape = function (str) { - return str.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); -}; - -/** - * Accepts a string to search, left and right delimiters as regex pattern - * strings, optional regex flags (may include non-native s, x, and y flags), - * and an options object which allows setting an escape character and changing - * the return format from an array of matches to a two-dimensional array of - * string parts with extended position data. returns an array of matches - * (optionally with extended data), allowing nested instances of left and right - * delimiters. use the g flag to return all matches, otherwise only the first - * is returned. if delimiters are unbalanced within the subject data, an error - * is thrown. - * - * This function admittedly pushes the boundaries of what can be accomplished - * sensibly without a "real" parser. however, by doing so it provides flexible - * and powerful recursive parsing capabilities with minimal code weight. - * - * Warning: the ``escapeChar`` option is considered experimental and might be - * changed or removed in future versions of XRegExp. - * - * unsupported features: - * - backreferences within delimiter patterns when using ``escapeChar``. - * - although providing delimiters as regex objects adds the minor feature of - * independent delimiter flags, it introduces other limitations and is only - * intended to be done by the ``XRegExp`` constructor (which can't call - * itself while building a regex). - * - * @ignore - */ -XRegExp.matchRecursive = function (str, left, right, flags, options) { - var options = options || {}, - escapeChar = options.escapeChar, - vN = options.valueNames, - flags = flags || "", - global = flags.indexOf("g") > -1, - ignoreCase = flags.indexOf("i") > -1, - multiline = flags.indexOf("m") > -1, - sticky = flags.indexOf("y") > -1, - /* sticky mode has its own handling in this function, which means you - can use flag "y" even in browsers which don't support it natively */ - flags = flags.replace(/y/g, ""), - left = left instanceof RegExp ? (left.global ? left : left.addFlags("g")) : new XRegExp(left, "g" + flags), - right = right instanceof RegExp ? (right.global ? right : right.addFlags("g")) : new XRegExp(right, "g" + flags), - output = [], - openTokens = 0, - delimStart = 0, - delimEnd = 0, - lastOuterEnd = 0, - outerStart, innerStart, leftMatch, rightMatch, escaped, esc; - - if (escapeChar) { - if (escapeChar.length > 1) throw SyntaxError("can't supply more than one escape character"); - if (multiline) throw TypeError("can't supply escape character when using the multiline flag"); - escaped = XRegExp.escape(escapeChar); - /* Escape pattern modifiers: - /g - not needed here - /i - included - /m - **unsupported**, throws error - /s - handled by XRegExp when delimiters are provided as strings - /x - handled by XRegExp when delimiters are provided as strings - /y - not needed here; supported by other handling in this function - */ - esc = new RegExp( - "^(?:" + escaped + "[\\S\\s]|(?:(?!" + left.source + "|" + right.source + ")[^" + escaped + "])+)+", - ignoreCase ? "i" : "" - ); - } - - while (true) { - /* advance the starting search position to the end of the last delimiter match. - a couple special cases are also covered: - - if using an escape character, advance to the next delimiter's starting position, - skipping any escaped characters - - first time through, reset lastIndex in case delimiters were provided as regexes - */ - left.lastIndex = right.lastIndex = delimEnd + - (escapeChar ? (esc.exec(str.slice(delimEnd)) || [""])[0].length : 0); - - leftMatch = left.exec(str); - rightMatch = right.exec(str); - - // only keep the result which matched earlier in the string - if (leftMatch && rightMatch) { - if (leftMatch.index <= rightMatch.index) - rightMatch = null; - else leftMatch = null; - } - - /* paths*: - leftMatch | rightMatch | openTokens | result - 1 | 0 | 1 | ... - 1 | 0 | 0 | ... - 0 | 1 | 1 | ... - 0 | 1 | 0 | throw - 0 | 0 | 1 | throw - 0 | 0 | 0 | break - * - does not include the sticky mode special case - - the loop ends after the first completed match if not in global mode - */ - - if (leftMatch || rightMatch) { - delimStart = (leftMatch || rightMatch).index; - delimEnd = (leftMatch ? left : right).lastIndex; - } else if (!openTokens) { - break; - } - - if (sticky && !openTokens && delimStart > lastOuterEnd) - break; - - if (leftMatch) { - if (!openTokens++) { - outerStart = delimStart; - innerStart = delimEnd; - } - } else if (rightMatch && openTokens) { - if (!--openTokens) { - if (vN) { - if (vN[0] && outerStart > lastOuterEnd) - output.push([vN[0], str.slice(lastOuterEnd, outerStart), lastOuterEnd, outerStart]); - if (vN[1]) output.push([vN[1], str.slice(outerStart, innerStart), outerStart, innerStart]); - if (vN[2]) output.push([vN[2], str.slice(innerStart, delimStart), innerStart, delimStart]); - if (vN[3]) output.push([vN[3], str.slice(delimStart, delimEnd), delimStart, delimEnd]); - } else { - output.push(str.slice(innerStart, delimStart)); - } - lastOuterEnd = delimEnd; - if (!global) - break; - } - } else { - // reset lastIndex in case delimiters were provided as regexes - left.lastIndex = right.lastIndex = 0; - throw Error("subject data contains unbalanced delimiters"); - } - - // if the delimiter matched an empty string, advance delimEnd to avoid an infinite loop - if (delimStart === delimEnd) - delimEnd++; - } - - if (global && !sticky && vN && vN[0] && str.length > lastOuterEnd) - output.push([vN[0], str.slice(lastOuterEnd), lastOuterEnd, str.length]); - - // reset lastIndex in case delimiters were provided as regexes - left.lastIndex = right.lastIndex = 0; - - return output; -}; +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +// +// Begin anonymous function. This is used to contain local scope variables without polutting global scope. +// +if (!window.SyntaxHighlighter) var SyntaxHighlighter = function() { + +// Shortcut object which will be assigned to the SyntaxHighlighter variable. +// This is a shorthand for local reference in order to avoid long namespace +// references to SyntaxHighlighter.whatever... +var sh = { + defaults : { + /** Additional CSS class names to be added to highlighter elements. */ + 'class-name' : '', + + /** First line number. */ + 'first-line' : 1, + + /** Font size of the SyntaxHighlighter block. */ + 'font-size' : null, + + /** Lines to highlight. */ + 'highlight' : null, + + /** Enables or disables smart tabs. */ + 'smart-tabs' : true, + + /** Gets or sets tab size. */ + 'tab-size' : 4, + + /** Enables or disables ruler. */ + 'ruler' : false, + + /** Enables or disables gutter. */ + 'gutter' : true, + + /** Enables or disables toolbar. */ + 'toolbar' : true, + + /** Forces code view to be collapsed. */ + 'collapse' : false, + + /** Enables or disables automatic links. */ + 'auto-links' : true, + + /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */ + 'light' : false + }, + + config : { + /** Path to the copy to clipboard SWF file. */ + clipboardSwf : null, + + /** Width of an item in the toolbar. */ + toolbarItemWidth : 16, + + /** Height of an item in the toolbar. */ + toolbarItemHeight : 16, + + /** Blogger mode flag. */ + bloggerMode : false, + + /** Name of the tag that SyntaxHighlighter will automatically look for. */ + tagName : 'pre', + + strings : { + expandSource : 'expand source', + viewSource : 'view source', + copyToClipboard : 'copy to clipboard', + copyToClipboardConfirmation : 'The code is in your clipboard now', + print : 'print', + help : '?', + alert: 'SyntaxHighlighter\n\n', + noBrush : 'Can\'t find brush for: ', + brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ', + + // this is populated by the build script + aboutDialog : 'About SyntaxHighlighter
SyntaxHighlighter
version 2.0.296 (March 01 2009)
JavaScript code syntax highlighter.
Copyright 2004-2009 Alex Gorbatchev.
' + }, + + /** If true, output will show HTML produces instead. */ + debug : false + }, + + /** Internal 'global' variables. */ + vars : { + discoveredBrushes : null, + spaceWidth : null, + printFrame : null, + highlighters : {} + }, + + /** This object is populated by user included external brush files. */ + brushes : {}, + + /** Common regular expressions. */ + regexLib : { + multiLineCComments : /\/\*[\s\S]*?\*\//gm, + singleLineCComments : /\/\/.*$/gm, + singleLinePerlComments : /#.*$/gm, + doubleQuotedString : /"(?:\.|(\\\")|[^\""\n])*"/g, + singleQuotedString : /'(?:\.|(\\\')|[^\''\n])*'/g, + multiLineDoubleQuotedString : /"(?:\.|(\\\")|[^\""])*"/g, + multiLineSingleQuotedString : /'(?:\.|(\\\')|[^\''])*'/g, + url : /\w+:\/\/[\w-.\/?%&=]*/g, + + /** tags. */ + phpScriptTags : { left: /(<|<)\?=?/g, right: /\?(>|>)/g }, + + /** <%= %> tags. */ + aspScriptTags : { left: /(<|<)%=?/g, right: /%(>|>)/g }, + + /** tags. */ + scriptScriptTags : { left: /(<|<)\s*script.*?(>|>)/gi, right: /(<|<)\/\s*script\s*(>|>)/gi } + }, + + toolbar : { + /** + * Creates new toolbar for a highlighter. + * @param {Highlighter} highlighter Target highlighter. + */ + create : function(highlighter) + { + var div = document.createElement('DIV'), + items = sh.toolbar.items + ; + + div.className = 'toolbar'; + + for (var name in items) + { + var constructor = items[name], + command = new constructor(highlighter), + element = command.create() + ; + + highlighter.toolbarCommands[name] = command; + + if (element == null) + continue; + + if (typeof(element) == 'string') + element = sh.toolbar.createButton(element, highlighter.id, name); + + element.className += 'item ' + name; + div.appendChild(element); + } + + return div; + }, + + /** + * Create a standard anchor button for the toolbar. + * @param {String} label Label text to display. + * @param {String} highlighterId Highlighter ID that this button would belong to. + * @param {String} commandName Command name that would be executed. + * @return {Element} Returns an 'A' element. + */ + createButton : function(label, highlighterId, commandName) + { + var a = document.createElement('a'), + style = a.style, + config = sh.config, + width = config.toolbarItemWidth, + height = config.toolbarItemHeight + ; + + a.href = '#' + commandName; + a.title = label; + a.highlighterId = highlighterId; + a.commandName = commandName; + a.innerHTML = label; + + if (isNaN(width) == false) + style.width = width + 'px'; + + if (isNaN(height) == false) + style.height = height + 'px'; + + a.onclick = function(e) + { + try + { + sh.toolbar.executeCommand( + this, + e || window.event, + this.highlighterId, + this.commandName + ); + } + catch(e) + { + sh.utils.alert(e.message); + } + + return false; + }; + + return a; + }, + + /** + * Executes a toolbar command. + * @param {Element} sender Sender element. + * @param {MouseEvent} event Original mouse event object. + * @param {String} highlighterId Highlighter DIV element ID. + * @param {String} commandName Name of the command to execute. + * @return {Object} Passes out return value from command execution. + */ + executeCommand : function(sender, event, highlighterId, commandName, args) + { + var highlighter = sh.vars.highlighters[highlighterId], + command + ; + + if (highlighter == null || (command = highlighter.toolbarCommands[commandName]) == null) + return null; + + return command.execute(sender, event, args); + }, + + /** Collection of toolbar items. */ + items : { + expandSource : function(highlighter) + { + this.create = function() + { + if (highlighter.getParam('collapse') != true) + return; + + return sh.config.strings.expandSource; + }; + + this.execute = function(sender, event, args) + { + var div = highlighter.div; + + sender.parentNode.removeChild(sender); + div.className = div.className.replace('collapsed', ''); + }; + }, + + /** + * Command to open a new window and display the original unformatted source code inside. + */ + viewSource : function(highlighter) + { + this.create = function() + { + return sh.config.strings.viewSource; + }; + + this.execute = function(sender, event, args) + { + var code = sh.utils.fixForBlogger(highlighter.originalCode).replace(/' + code + ''); + wnd.document.close(); + }; + }, + + /** + * Command to copy the original source code in to the clipboard. + * Uses Flash method if clipboardSwf is configured. + */ + copyToClipboard : function(highlighter) + { + var flashDiv, flashSwf, + highlighterId = highlighter.id + ; + + this.create = function() + { + var config = sh.config; + + // disable functionality if running locally + if (config.clipboardSwf == null) + return null; + + function params(list) + { + var result = ''; + + for (var name in list) + result += ""; + + return result; + }; + + function attributes(list) + { + var result = ''; + + for (var name in list) + result += " " + name + "='" + list[name] + "'"; + + return result; + }; + + var args1 = { + width : config.toolbarItemWidth, + height : config.toolbarItemHeight, + id : highlighterId + '_clipboard', + type : 'application/x-shockwave-flash', + title : sh.config.strings.copyToClipboard + }, + + // these arguments are used in IE's collection + args2 = { + allowScriptAccess : 'always', + wmode : 'transparent', + flashVars : 'highlighterId=' + highlighterId, + menu : 'false' + }, + swf = config.clipboardSwf, + html + ; + + if (/msie/i.test(navigator.userAgent)) + { + html = '' + + params(args2) + + params({ movie : swf }) + + '' + ; + } + else + { + html = '' + ; + } + + flashDiv = document.createElement('div'); + flashDiv.innerHTML = html; + + return flashDiv; + }; + + this.execute = function(sender, event, args) + { + var command = args.command; + + switch (command) + { + case 'get': + var code = sh.utils.unindent( + sh.utils.fixForBlogger(highlighter.originalCode) + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/&/g, '&') + ); + + if(window.clipboardData) + // will fall through to the confirmation because there isn't a break + window.clipboardData.setData('text', code); + else + return sh.utils.unindent(code); + + case 'ok': + sh.utils.alert(sh.config.strings.copyToClipboardConfirmation); + break; + + case 'error': + sh.utils.alert(args.message); + break; + } + }; + }, + + /** Command to print the colored source code. */ + printSource : function(highlighter) + { + this.create = function() + { + return sh.config.strings.print; + }; + + this.execute = function(sender, event, args) + { + var iframe = document.createElement('IFRAME'), + doc = null + ; + + // make sure there is never more than one hidden iframe created by SH + if (sh.vars.printFrame != null) + document.body.removeChild(sh.vars.printFrame); + + sh.vars.printFrame = iframe; + + // this hides the iframe + iframe.style.cssText = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;'; + + document.body.appendChild(iframe); + doc = iframe.contentWindow.document; + + copyStyles(doc, window.document); + doc.write('
' + highlighter.div.innerHTML + '
'); + doc.close(); + + iframe.contentWindow.focus(); + iframe.contentWindow.print(); + + function copyStyles(destDoc, sourceDoc) + { + var links = sourceDoc.getElementsByTagName('link'); + + for(var i = 0; i < links.length; i++) + if(links[i].rel.toLowerCase() == 'stylesheet' && /shCore\.css$/.test(links[i].href)) + destDoc.write(''); + }; + }; + }, + + /** Command to display the about dialog window. */ + about : function(highlighter) + { + this.create = function() + { + return sh.config.strings.help; + }; + + this.execute = function(sender, event) + { + var wnd = sh.utils.popup('', '_blank', 500, 250, 'scrollbars=0'), + doc = wnd.document + ; + + doc.write(sh.config.strings.aboutDialog); + doc.close(); + wnd.focus(); + }; + } + } + }, + + utils : { + guid : function(prefix) + { + return prefix + Math.round(Math.random() * 1000000).toString(); + }, + + /** + * Merges two objects. Values from obj2 override values in obj1. + * Function is NOT recursive and works only for one dimensional objects. + * @param {Object} obj1 First object. + * @param {Object} obj2 Second object. + * @return {Object} Returns combination of both objects. + */ + merge: function(obj1, obj2) + { + var result = {}, name; + + for (name in obj1) + result[name] = obj1[name]; + + for (name in obj2) + result[name] = obj2[name]; + + return result; + }, + + /** + * Attempts to convert string to boolean. + * @param {String} value Input string. + * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise. + */ + toBoolean: function(value) + { + switch (value) + { + case "true": + return true; + + case "false": + return false; + } + + return value; + }, + + /** + * Opens up a centered popup window. + * @param {String} url URL to open in the window. + * @param {String} name Popup name. + * @param {int} width Popup width. + * @param {int} height Popup height. + * @param {String} options window.open() options. + * @return {Window} Returns window instance. + */ + popup: function(url, name, width, height, options) + { + var x = (screen.width - width) / 2, + y = (screen.height - height) / 2 + ; + + options += ', left=' + x + + ', top=' + y + + ', width=' + width + + ', height=' + height + ; + options = options.replace(/^,/, ''); + + var win = window.open(url, name, options); + win.focus(); + return win; + }, + + /** + * Adds event handler to the target object. + * @param {Object} obj Target object. + * @param {String} type Name of the event. + * @param {Function} func Handling function. + */ + addEvent: function(obj, type, func) + { + if (obj.attachEvent) + { + obj['e' + type + func] = func; + obj[type + func] = function() + { + obj['e' + type + func](window.event); + } + obj.attachEvent('on' + type, obj[type + func]); + } + else + { + obj.addEventListener(type, func, false); + } + }, + + /** + * Displays an alert. + * @param {String} str String to display. + */ + alert: function(str) + { + alert(sh.config.strings.alert + str) + }, + + /** + * Finds a brush by its alias. + * + * @param {String} alias Brush alias. + * @param {Boolean} alert Suppresses the alert if false. + * @return {Brush} Returns bursh constructor if found, null otherwise. + */ + findBrush: function(alias, alert) + { + var brushes = sh.vars.discoveredBrushes, + result = null + ; + + if (brushes == null) + { + brushes = {}; + + // Find all brushes + for (var brush in sh.brushes) + { + var aliases = sh.brushes[brush].aliases; + + if (aliases == null) + continue; + + for (var i = 0; i < aliases.length; i++) + brushes[aliases[i]] = brush; + } + + sh.vars.discoveredBrushes = brushes; + } + + result = sh.brushes[brushes[alias]]; + + if (result == null && alert != false) + sh.utils.alert(sh.config.strings.noBrush + alias); + + return result; + }, + + /** + * Executes a callback on each line and replaces each line with result from the callback. + * @param {Object} str Input string. + * @param {Object} callback Callback function taking one string argument and returning a string. + */ + eachLine: function(str, callback) + { + var lines = str.split('\n'); + + for (var i = 0; i < lines.length; i++) + lines[i] = callback(lines[i]); + + return lines.join('\n'); + }, + + /** + * Creates rules looking div. + */ + createRuler: function() + { + var div = document.createElement('div'), + ruler = document.createElement('div'), + showEvery = 10, + i = 1 + ; + + while (i <= 150) + { + if (i % showEvery === 0) + { + div.innerHTML += i; + i += (i + '').length; + } + else + { + div.innerHTML += '·'; + i++; + } + } + + ruler.className = 'ruler line'; + ruler.appendChild(div); + + return ruler; + }, + + /** + * This is a special trim which only removes first and last empty lines + * and doesn't affect valid leading space on the first line. + * + * @param {String} str Input string + * @return {String} Returns string without empty first and last lines. + */ + trimFirstAndLastLines: function(str) + { + return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, ''); + }, + + /** + * Parses key/value pairs into hash object. + * + * Understands the following formats: + * - name: word; + * - name: [word, word]; + * - name: "string"; + * - name: 'string'; + * + * For example: + * name1: value; name2: [value, value]; name3: 'value' + * + * @param {String} str Input string. + * @return {Object} Returns deserialized object. + */ + parseParams: function(str) + { + var match, + result = {}, + arrayRegex = new XRegExp("^\\[(?(.*?))\\]$"), + regex = new XRegExp( + "(?[\\w-]+)" + + "\\s*:\\s*" + + "(?" + + "[\\w-%#]+|" + // word + "\\[.*?\\]|" + // [] array + '".*?"|' + // "" string + "'.*?'" + // '' string + ")\\s*;?", + "g" + ) + ; + + while ((match = regex.exec(str)) != null) + { + var value = match.value + .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings + ; + + // try to parse array value + if (value != null && arrayRegex.test(value)) + { + var m = arrayRegex.exec(value); + value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : []; + } + + result[match.name] = value; + } + + return result; + }, + + /** + * Wraps each line of the string into tag with given style applied to it. + * + * @param {String} str Input string. + * @param {String} css Style name to apply to the string. + * @return {String} Returns input string with each line surrounded by tag. + */ + decorate: function(str, css) + { + if (str == null || str.length == 0 || str == '\n') + return str; + + str = str.replace(/... to them so that + // leading spaces aren't included. + if (css != null) + str = sh.utils.eachLine(str, function(line) + { + if (line.length == 0) + return ''; + + var spaces = ''; + + line = line.replace(/^( | )+/, function(s) + { + spaces = s; + return ''; + }); + + if (line.length == 0) + return spaces; + + return spaces + '' + line + ''; + }); + + return str; + }, + + /** + * Pads number with zeros until it's length is the same as given length. + * + * @param {Number} number Number to pad. + * @param {Number} length Max string length with. + * @return {String} Returns a string padded with proper amount of '0'. + */ + padNumber : function(number, length) + { + var result = number.toString(); + + while (result.length < length) + result = '0' + result; + + return result; + }, + + /** + * Measures width of a single space character. + * @return {Number} Returns width of a single space character. + */ + measureSpace : function() + { + var container = document.createElement('div'), + span, + result = 0, + body = document.body, + id = sh.utils.guid('measureSpace'), + + // variable names will be compressed, so it's better than a plain string + divOpen = '
' + + divOpen + 'lines">' + + divOpen + 'line">' + + divOpen + 'content' + + '"> ' + closeSpan + closeSpan + + closeDiv + + closeDiv + + closeDiv + + closeDiv + ; + + body.appendChild(container); + span = document.getElementById(id); + + if (/opera/i.test(navigator.userAgent)) + { + var style = window.getComputedStyle(span, null); + result = parseInt(style.getPropertyValue("width")); + } + else + { + result = span.offsetWidth; + } + + body.removeChild(container); + + return result; + }, + + /** + * Replaces tabs with spaces. + * + * @param {String} code Source code. + * @param {Number} tabSize Size of the tab. + * @return {String} Returns code with all tabs replaces by spaces. + */ + processTabs : function(code, tabSize) + { + var tab = ''; + + for (var i = 0; i < tabSize; i++) + tab += ' '; + + return code.replace(/\t/g, tab); + }, + + /** + * Replaces tabs with smart spaces. + * + * @param {String} code Code to fix the tabs in. + * @param {Number} tabSize Number of spaces in a column. + * @return {String} Returns code with all tabs replaces with roper amount of spaces. + */ + processSmartTabs : function(code, tabSize) + { + var lines = code.split('\n'), + tab = '\t', + spaces = '' + ; + + // Create a string with 1000 spaces to copy spaces from... + // It's assumed that there would be no indentation longer than that. + for (var i = 0; i < 50; i++) + spaces += ' '; // 20 spaces * 50 + + // This function inserts specified amount of spaces in the string + // where a tab is while removing that given tab. + function insertSpaces(line, pos, count) + { + return line.substr(0, pos) + + spaces.substr(0, count) + + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab + ; + }; + + // Go through all the lines and do the 'smart tabs' magic. + code = sh.utils.eachLine(code, function(line) + { + if (line.indexOf(tab) == -1) + return line; + + var pos = 0; + + while ((pos = line.indexOf(tab)) != -1) + { + // This is pretty much all there is to the 'smart tabs' logic. + // Based on the position within the line and size of a tab, + // calculate the amount of spaces we need to insert. + var spaces = tabSize - pos % tabSize; + line = insertSpaces(line, pos, spaces); + } + + return line; + }); + + return code; + }, + + fixForBlogger : function(str) + { + return (sh.config.bloggerMode == true) ? str.replace(/|<br\s*\/?>/gi, '\n') : str; + }, + + /** + * Removes all white space at the begining and end of a string. + * + * @param {String} str String to trim. + * @return {String} Returns string without leading and following white space characters. + */ + trim: function(str) + { + return str.replace(/\s*$/g, '').replace(/^\s*/, ''); + }, + + /** + * Unindents a block of text by the lowest common indent amount. + * @param {String} str Text to unindent. + * @return {String} Returns unindented text block. + */ + unindent: function(str) + { + var lines = sh.utils.fixForBlogger(str).split('\n'), + indents = new Array(), + regex = /^\s*/, + min = 1000 + ; + + // go through every line and check for common number of indents + for (var i = 0; i < lines.length && min > 0; i++) + { + var line = lines[i]; + + if (sh.utils.trim(line).length == 0) + continue; + + var matches = regex.exec(line); + + // In the event that just one line doesn't have leading white space + // we can't unindent anything, so bail completely. + if (matches == null) + return str; + + min = Math.min(matches[0].length, min); + } + + // trim minimum common number of white space from the begining of every line + if (min > 0) + for (var i = 0; i < lines.length; i++) + lines[i] = lines[i].substr(min); + + return lines.join('\n'); + }, + + /** + * Callback method for Array.sort() which sorts matches by + * index position and then by length. + * + * @param {Match} m1 Left object. + * @param {Match} m2 Right object. + * @return {Number} Returns -1, 0 or -1 as a comparison result. + */ + matchesSortCallback: function(m1, m2) + { + // sort matches by index first + if(m1.index < m2.index) + return -1; + else if(m1.index > m2.index) + return 1; + else + { + // if index is the same, sort by length + if(m1.length < m2.length) + return -1; + else if(m1.length > m2.length) + return 1; + } + + return 0; + }, + + /** + * Executes given regular expression on provided code and returns all + * matches that are found. + * + * @param {String} code Code to execute regular expression on. + * @param {Object} regex Regular expression item info from regexList collection. + * @return {Array} Returns a list of Match objects. + */ + getMatches: function(code, regexInfo) + { + function defaultAdd(match, regexInfo) + { + return [new sh.Match(match[0], match.index, regexInfo.css)]; + }; + + var index = 0, + match = null, + result = [], + func = regexInfo.func ? regexInfo.func : defaultAdd + ; + + while((match = regexInfo.regex.exec(code)) != null) + result = result.concat(func(match, regexInfo)); + + return result; + }, + + processUrls: function(code) + { + return code.replace(sh.regexLib.url, function(m) + { + return '' + m + ''; + }); + } + }, // end of utils + + /** + * Shorthand to highlight all elements on the page that are marked as + * SyntaxHighlighter source code. + * + * @param {Object} globalParams Optional parameters which override element's + * parameters. Only used if element is specified. + * + * @param {Object} element Optional element to highlight. If none is + * provided, all elements in the current document + * are highlighted. + */ + highlight : function(globalParams, element) + { + function toArray(source) + { + var result = []; + + for (var i = 0; i < source.length; i++) + result.push(source[i]); + + return result; + }; + + var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)), + propertyName = 'innerHTML', + highlighter = null + ; + + if (elements.length === 0) + return; + + for (var i = 0; i < elements.length; i++) + { + var target = elements[i], + params = sh.utils.parseParams(target.className), + brushName + ; + + // local params take precedence over globals + params = sh.utils.merge(globalParams, params); + brushName = params['brush']; + + if (brushName == null) + continue; + + // Instantiate a brush + if (params['html-script'] == 'true') + { + highlighter = new sh.HtmlScript(brushName); + } + else + { + var brush = sh.utils.findBrush(brushName); + + if (brush) + highlighter = new brush(); + else + continue; + } + + highlighter.highlight(target[propertyName], params); + + var result = highlighter.div; + + if (sh.config.debug) + { + result = document.createElement('textarea'); + result.value = highlighter.div.innerHTML; + result.style.width = '70em'; + result.style.height = '30em'; + } + + target.parentNode.replaceChild(result, target); + } + }, + + /** + * Main entry point for the SyntaxHighlighter. + * @param {Object} params Optional params to apply to all highlighted elements. + */ + all : function(params) + { + sh.utils.addEvent( + window, + 'load', + function() { sh.highlight(params); } + ); + } +}; // end of sh + +/** Match object */ +sh.Match = function(value, index, css) +{ + this.value = value; + this.index = index; + this.length = value.length; + this.css = css; +}; + +sh.Match.prototype.toString = function() +{ + return this.value; +}; + +/** + * Simulates HTML code with a scripting language embedded. + * + * @param {String} scriptBrushName Brush name of the scripting language. + */ +sh.HtmlScript = function(scriptBrushName) +{ + var scriptBrush = sh.utils.findBrush(scriptBrushName), + xmlBrush = new sh.brushes.Xml(), + bracketsRegex = null + ; + + if (scriptBrush == null) + return; + + scriptBrush = new scriptBrush(); + this.xmlBrush = xmlBrush; + + if (scriptBrush.htmlScript == null) + { + sh.utils.alert(sh.config.strings.brushNotHtmlScript + scriptBrushName); + return; + } + + xmlBrush.regexList.push( + { regex: scriptBrush.htmlScript.code, func: process } + ); + + function offsetMatches(matches, offset) + { + for (var j = 0; j < matches.length; j++) + matches[j].index += offset; + } + + function process(match, info) + { + var code = match.code, + matches = [], + regexList = scriptBrush.regexList, + offset = match.index + match.left.length, + htmlScript = scriptBrush.htmlScript, + result + ; + + for (var i = 0; i < regexList.length; i++) + { + result = sh.utils.getMatches(code, regexList[i]); + offsetMatches(result, offset); + matches = matches.concat(result); + } + + if (htmlScript.left != null && match.left != null) + { + result = sh.utils.getMatches(match.left, htmlScript.left); + offsetMatches(result, match.index); + matches = matches.concat(result); + } + + if (htmlScript.right != null && match.right != null) + { + result = sh.utils.getMatches(match.right, htmlScript.right); + offsetMatches(result, match.index + match[0].lastIndexOf(match.right)); + matches = matches.concat(result); + } + + return matches; + } +}; + +sh.HtmlScript.prototype.highlight = function(code, params) +{ + this.xmlBrush.highlight(code, params); + this.div = this.xmlBrush.div; +} + +/** + * Main Highlither class. + * @constructor + */ +sh.Highlighter = function() +{ +}; + +sh.Highlighter.prototype = { + /** + * Returns value of the parameter passed to the highlighter. + * @param {String} name Name of the parameter. + * @param {Object} defaultValue Default value. + * @return {Object} Returns found value or default value otherwise. + */ + getParam : function(name, defaultValue) + { + var result = this.params[name]; + return sh.utils.toBoolean(result == null ? defaultValue : result); + }, + + /** + * Shortcut to document.createElement(). + * @param {String} name Name of the element to create (DIV, A, etc). + * @return {HTMLElement} Returns new HTML element. + */ + create: function(name) + { + return document.createElement(name); + }, + + /** + * Checks if one match is inside another. + * @param {Match} match Match object to check. + * @return {Boolean} Returns true if given match was inside another, false otherwise. + */ + isMatchNested: function(match) + { + for (var i = 0; i < this.matches.length; i++) + { + var item = this.matches[i]; + + if (item === null) + continue; + + if ((match.index > item.index) && (match.index < item.index + item.length)) + return true; + } + + return false; + }, + + /** + * Applies all regular expression to the code and stores all found + * matches in the `this.matches` array. + * @param {Array} regexList List of regular expressions. + * @param {String} code Source code. + * @return {Array} Returns list of matches. + */ + findMatches: function(regexList, code) + { + var result = []; + + if (regexList != null) + for (var i = 0; i < regexList.length; i++) + result = result.concat(sh.utils.getMatches(code, regexList[i])); + + // sort the matches + result = result.sort(sh.utils.matchesSortCallback); + + return result; + }, + + /** + * Checks to see if any of the matches are inside of other matches. + * This process would get rid of highligted strings inside comments, + * keywords inside strings and so on. + */ + removeNestedMatches: function() + { + for (var i = 0; i < this.matches.length; i++) + if (this.isMatchNested(this.matches[i])) + this.matches[i] = null; + }, + + /** + * Splits block of text into individual DIV lines. + * @param {String} code Code to highlight. + * @return {String} Returns highlighted code in HTML form. + */ + createDisplayLines : function(code) + { + var lines = code.split(/\n/g), + firstLine = parseInt(this.getParam('first-line')), + padLength = (firstLine + lines.length).toString().length, + highlightedLines = this.getParam('highlight', []) + ; + + code = ''; + + for (var i = 0; i < lines.length; i++) + { + var line = lines[i], + indent = /^( |\s)+/.exec(line), + lineClass = 'line alt' + (i % 2 == 0 ? 1 : 2), + lineNumber = sh.utils.padNumber(firstLine + i, padLength), + highlighted = highlightedLines.indexOf((firstLine + i).toString()) != -1, + spaces = null + ; + + if (indent != null) + { + spaces = indent[0].toString(); + line = line.substr(spaces.length); + spaces = spaces.replace(/ /g, ' '); + indent = sh.vars.spaceWidth * spaces.length; + } + else + { + indent = 0; + } + + line = sh.utils.trim(line); + + if (line.length == 0) + line = ' '; + + if (highlighted) + lineClass += ' highlighted'; + + code += + '
' + + '' + lineNumber + '.' + + '' + + (spaces != null ? '' + spaces.replace(/\s/g, ' ') + '' : '') + + '' + line + '' + + '' + + '
' + ; + } + + return code; + }, + + /** + * Finds all matches in the source code. + * @param {String} code Source code to process matches in. + * @param {Array} matches Discovered regex matches. + * @return {String} Returns formatted HTML with processed mathes. + */ + processMatches: function(code, matches) + { + var pos = 0, + result = '', + decorate = sh.utils.decorate // make an alias to save some bytes + ; + + // Finally, go through the final list of matches and pull the all + // together adding everything in between that isn't a match. + for (var i = 0; i < matches.length; i++) + { + var match = matches[i]; + + if (match === null || match.length === 0) + continue; + + result += decorate(code.substr(pos, match.index - pos), 'plain') + + decorate(match.value, match.css) + ; + + pos = match.index + match.length; + } + + // don't forget to add whatever's remaining in the string + result += decorate(code.substr(pos), 'plain'); + + return result; + }, + + /** + * Highlights the code and returns complete HTML. + * @param {String} code Code to highlight. + * @param {Object} params Parameters object. + */ + highlight: function(code, params) + { + var conf = sh.config, + vars = sh.vars, + div, + tabSize + ; + + this.params = {}; + this.div = null; + this.lines = null; + this.code = null; + this.bar = null; + this.toolbarCommands = {}; + this.id = sh.utils.guid('highlighter_'); + + // register this instance in the highlighters list + vars.highlighters[this.id] = this; + + if (code === null) + code = ''; + + // Measure width of a single space. + if (vars.spaceWidth === null) + vars.spaceWidth = sh.utils.measureSpace(); + + // local params take precedence over defaults + this.params = sh.utils.merge(sh.defaults, params || {}); + + // process light mode + if (this.getParam('light') == true) + this.params.toolbar = this.params.gutter = false; + + this.div = div = this.create('DIV'); + this.lines = this.create('DIV'); + this.lines.className = 'lines'; + + div.className = 'syntaxhighlighter'; + div.id = this.id; + + if (this.getParam('collapse')) + div.className += ' collapsed'; + + if (this.getParam('gutter') == false) + div.className += ' nogutter'; + + div.className += ' ' + this.getParam('class-name'); + div.style.fontSize = this.getParam('font-size', ''); // IE7 can't take null + + this.originalCode = code; + this.code = sh.utils.trimFirstAndLastLines(code) + .replace(/\r/g, ' ') // IE lets these buggers through + ; + + tabSize = this.getParam('tab-size'); + + // replace tabs with spaces + this.code = this.getParam('smart-tabs') == true + ? sh.utils.processSmartTabs(this.code, tabSize) + : sh.utils.processTabs(this.code, tabSize) + ; + + this.code = sh.utils.unindent(this.code); + + // add controls toolbar + if (this.getParam('toolbar')) + { + this.bar = this.create('DIV'); + this.bar.className = 'bar'; + this.bar.appendChild(sh.toolbar.create(this)); + div.appendChild(this.bar); + } + + // add columns ruler + if (this.getParam('ruler')) + div.appendChild(sh.utils.createRuler()); + + div.appendChild(this.lines); + + this.matches = this.findMatches(this.regexList, this.code); + this.removeNestedMatches(); + + code = this.processMatches(this.code, this.matches); + + // finally, split all lines so that they wrap well + code = this.createDisplayLines(sh.utils.trim(code)); + + // finally, process the links + if (this.getParam('auto-links')) + code = sh.utils.processUrls(code); + + this.lines.innerHTML = code; + }, + + /** + * Converts space separated list of keywords into a regular expression string. + * @param {String} str Space separated keywords. + * @return {String} Returns regular expression string. + */ + getKeywords: function(str) + { + str = str + .replace(/^\s+|\s+$/g, '') + .replace(/\s+/g, '\\b|\\b') + ; + + return '\\b' + str + '\\b'; + }, + + /** + * Makes a brush compatible with the `html-script` functionality. + * @param {Object} regexGroup Object containing `left` and `right` regular expressions. + */ + forHtmlScript: function(regexGroup) + { + this.htmlScript = { + left : { regex: regexGroup.left, css: 'script' }, + right : { regex: regexGroup.right, css: 'script' }, + code : new XRegExp( + "(?" + regexGroup.left.source + ")" + + "(?.*?)" + + "(?" + regexGroup.right.source + ")", + "sgi" + ) + }; + } +}; // end of Highlighter + +return sh; +}(); // end of anonymous function + +if (!Array.indexOf) + /** + * Finds an index of element in the array. + * @ignore + * @param {Object} searchElement + * @param {Number} fromIndex + * @return {Number} Returns index of element if found; -1 otherwise. + */ + Array.prototype.indexOf = function (searchElement, fromIndex) + { + fromIndex = Math.max(fromIndex || 0, 0); + + for (var i = fromIndex; i < this.length; i++) + if(this[i] == searchElement) + return i; + + return -1; + }; + +/** + * XRegExp 0.6.1 + * (c) 2007-2008 Steven Levithan + * + * MIT License + * + * provides an augmented, cross-browser implementation of regular expressions + * including support for additional modifiers and syntax. several convenience + * methods and a recursive-construct parser are also included. + */ + +// prevent running twice, which would break references to native globals +if (!window.XRegExp) { +// anonymous function to avoid global variables +(function () { +// copy various native globals for reference. can't use the name ``native`` +// because it's a reserved JavaScript keyword. +var real = { + exec: RegExp.prototype.exec, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + /* regex syntax parsing with support for all the necessary cross- + browser and context issues (escapings, character classes, etc.) */ + lib = { + part: /(?:[^\\([#\s.]+|\\(?!k<[\w$]+>|[pP]{[^}]+})[\S\s]?|\((?=\?(?!#|<[\w$]+>)))+|(\()(?:\?(?:(#)[^)]*\)|<([$\w]+)>))?|\\(?:k<([\w$]+)>|[pP]{([^}]+)})|(\[\^?)|([\S\s])/g, + replaceVar: /(?:[^$]+|\$(?![1-9$&`']|{[$\w]+}))+|\$(?:([1-9]\d*|[$&`'])|{([$\w]+)})/g, + extended: /^(?:\s+|#.*)+/, + quantifier: /^(?:[?*+]|{\d+(?:,\d*)?})/, + classLeft: /&&\[\^?/g, + classRight: /]/g + }, + indexOf = function (array, item, from) { + for (var i = from || 0; i < array.length; i++) + if (array[i] === item) return i; + return -1; + }, + brokenExecUndef = /()??/.exec("")[1] !== undefined, + plugins = {}; + +/** + * Accepts a pattern and flags, returns a new, extended RegExp object. + * differs from a native regex in that additional flags and syntax are + * supported and browser inconsistencies are ameliorated. + * @ignore + */ +XRegExp = function (pattern, flags) { + if (pattern instanceof RegExp) { + if (flags !== undefined) + throw TypeError("can't supply flags when constructing one RegExp from another"); + return pattern.addFlags(); // new copy + } + + var flags = flags || "", + singleline = flags.indexOf("s") > -1, + extended = flags.indexOf("x") > -1, + hasNamedCapture = false, + captureNames = [], + output = [], + part = lib.part, + match, cc, len, index, regex; + + part.lastIndex = 0; // in case the last XRegExp compilation threw an error (unbalanced character class) + + while (match = real.exec.call(part, pattern)) { + // comment pattern. this check must come before the capturing group check, + // because both match[1] and match[2] will be non-empty. + if (match[2]) { + // keep tokens separated unless the following token is a quantifier + if (!lib.quantifier.test(pattern.slice(part.lastIndex))) + output.push("(?:)"); + // capturing group + } else if (match[1]) { + captureNames.push(match[3] || null); + if (match[3]) + hasNamedCapture = true; + output.push("("); + // named backreference + } else if (match[4]) { + index = indexOf(captureNames, match[4]); + // keep backreferences separate from subsequent literal numbers + // preserve backreferences to named groups that are undefined at this point as literal strings + output.push(index > -1 ? + "\\" + (index + 1) + (isNaN(pattern.charAt(part.lastIndex)) ? "" : "(?:)") : + match[0] + ); + // unicode element (requires plugin) + } else if (match[5]) { + output.push(plugins.unicode ? + plugins.unicode.get(match[5], match[0].charAt(1) === "P") : + match[0] + ); + // character class opening delimiter ("[" or "[^") + // (non-native unicode elements are not supported within character classes) + } else if (match[6]) { + if (pattern.charAt(part.lastIndex) === "]") { + // for cross-browser compatibility with ECMA-262 v3 behavior, + // convert [] to (?!) and [^] to [\S\s]. + output.push(match[6] === "[" ? "(?!)" : "[\\S\\s]"); + part.lastIndex++; + } else { + // parse the character class with support for inner escapes and + // ES4's infinitely nesting intersection syntax ([&&[^&&[]]]). + cc = XRegExp.matchRecursive("&&" + pattern.slice(match.index), lib.classLeft, lib.classRight, "", {escapeChar: "\\"})[0]; + output.push(match[6] + cc + "]"); + part.lastIndex += cc.length + 1; + } + // dot ("."), pound sign ("#"), or whitespace character + } else if (match[7]) { + if (singleline && match[7] === ".") { + output.push("[\\S\\s]"); + } else if (extended && lib.extended.test(match[7])) { + len = real.exec.call(lib.extended, pattern.slice(part.lastIndex - 1))[0].length; + // keep tokens separated unless the following token is a quantifier + if (!lib.quantifier.test(pattern.slice(part.lastIndex - 1 + len))) + output.push("(?:)"); + part.lastIndex += len - 1; + } else { + output.push(match[7]); + } + } else { + output.push(match[0]); + } + } + + regex = RegExp(output.join(""), real.replace.call(flags, /[sx]+/g, "")); + regex._x = { + source: pattern, + captureNames: hasNamedCapture ? captureNames : null + }; + return regex; +}; + +/** + * Barebones plugin support for now (intentionally undocumented) + * @ignore + * @param {Object} name + * @param {Object} o + */ +XRegExp.addPlugin = function (name, o) { + plugins[name] = o; +}; + +/** + * Adds named capture support, with values returned as ``result.name``. + * + * Also fixes two cross-browser issues, following the ECMA-262 v3 spec: + * - captured values for non-participating capturing groups should be returned + * as ``undefined``, rather than the empty string. + * - the regex's ``lastIndex`` should not be incremented after zero-length + * matches. + * @ignore + */ +RegExp.prototype.exec = function (str) { + var match = real.exec.call(this, str), + name, i, r2; + if (match) { + // fix browsers whose exec methods don't consistently return + // undefined for non-participating capturing groups + if (brokenExecUndef && match.length > 1) { + // r2 doesn't need /g or /y, but they shouldn't hurt + r2 = new RegExp("^" + this.source + "$(?!\\s)", this.getNativeFlags()); + real.replace.call(match[0], r2, function () { + for (i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) match[i] = undefined; + } + }); + } + // attach named capture properties + if (this._x && this._x.captureNames) { + for (i = 1; i < match.length; i++) { + name = this._x.captureNames[i - 1]; + if (name) match[name] = match[i]; + } + } + // fix browsers that increment lastIndex after zero-length matches + if (this.global && this.lastIndex > (match.index + match[0].length)) + this.lastIndex--; + } + return match; +}; +})(); // end anonymous function +} // end if(!window.XRegExp) + +/** + * intentionally undocumented + * @ignore + */ +RegExp.prototype.getNativeFlags = function () { + return (this.global ? "g" : "") + + (this.ignoreCase ? "i" : "") + + (this.multiline ? "m" : "") + + (this.extended ? "x" : "") + + (this.sticky ? "y" : ""); +}; + +/** + * Accepts flags; returns a new XRegExp object generated by recompiling + * the regex with the additional flags (may include non-native flags). + * The original regex object is not altered. + * @ignore + */ +RegExp.prototype.addFlags = function (flags) { + var regex = new XRegExp(this.source, (flags || "") + this.getNativeFlags()); + if (this._x) { + regex._x = { + source: this._x.source, + captureNames: this._x.captureNames ? this._x.captureNames.slice(0) : null + }; + } + return regex; +}; + +/** + * Accepts a context object and string; returns the result of calling + * ``exec`` with the provided string. the context is ignored but is + * accepted for congruity with ``Function.prototype.call``. + * @ignore + */ +RegExp.prototype.call = function (context, str) { + return this.exec(str); +}; + +/** + * Accepts a context object and arguments array; returns the result of + * calling ``exec`` with the first value in the arguments array. the context + * is ignored but is accepted for congruity with ``Function.prototype.apply``. + * @ignore + */ +RegExp.prototype.apply = function (context, args) { + return this.exec(args[0]); +}; + +/** + * Accepts a pattern and flags; returns an XRegExp object. if the pattern + * and flag combination has previously been cached, the cached copy is + * returned, otherwise the new object is cached. + * @ignore + */ +XRegExp.cache = function (pattern, flags) { + var key = "/" + pattern + "/" + (flags || ""); + return XRegExp.cache[key] || (XRegExp.cache[key] = new XRegExp(pattern, flags)); +}; + +/** + * Accepts a string; returns the string with regex metacharacters escaped. + * the returned string can safely be used within a regex to match a literal + * string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \, ^, $, + * |, #, [comma], and whitespace. + * @ignore + */ +XRegExp.escape = function (str) { + return str.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); +}; + +/** + * Accepts a string to search, left and right delimiters as regex pattern + * strings, optional regex flags (may include non-native s, x, and y flags), + * and an options object which allows setting an escape character and changing + * the return format from an array of matches to a two-dimensional array of + * string parts with extended position data. returns an array of matches + * (optionally with extended data), allowing nested instances of left and right + * delimiters. use the g flag to return all matches, otherwise only the first + * is returned. if delimiters are unbalanced within the subject data, an error + * is thrown. + * + * This function admittedly pushes the boundaries of what can be accomplished + * sensibly without a "real" parser. however, by doing so it provides flexible + * and powerful recursive parsing capabilities with minimal code weight. + * + * Warning: the ``escapeChar`` option is considered experimental and might be + * changed or removed in future versions of XRegExp. + * + * unsupported features: + * - backreferences within delimiter patterns when using ``escapeChar``. + * - although providing delimiters as regex objects adds the minor feature of + * independent delimiter flags, it introduces other limitations and is only + * intended to be done by the ``XRegExp`` constructor (which can't call + * itself while building a regex). + * + * @ignore + */ +XRegExp.matchRecursive = function (str, left, right, flags, options) { + var options = options || {}, + escapeChar = options.escapeChar, + vN = options.valueNames, + flags = flags || "", + global = flags.indexOf("g") > -1, + ignoreCase = flags.indexOf("i") > -1, + multiline = flags.indexOf("m") > -1, + sticky = flags.indexOf("y") > -1, + /* sticky mode has its own handling in this function, which means you + can use flag "y" even in browsers which don't support it natively */ + flags = flags.replace(/y/g, ""), + left = left instanceof RegExp ? (left.global ? left : left.addFlags("g")) : new XRegExp(left, "g" + flags), + right = right instanceof RegExp ? (right.global ? right : right.addFlags("g")) : new XRegExp(right, "g" + flags), + output = [], + openTokens = 0, + delimStart = 0, + delimEnd = 0, + lastOuterEnd = 0, + outerStart, innerStart, leftMatch, rightMatch, escaped, esc; + + if (escapeChar) { + if (escapeChar.length > 1) throw SyntaxError("can't supply more than one escape character"); + if (multiline) throw TypeError("can't supply escape character when using the multiline flag"); + escaped = XRegExp.escape(escapeChar); + /* Escape pattern modifiers: + /g - not needed here + /i - included + /m - **unsupported**, throws error + /s - handled by XRegExp when delimiters are provided as strings + /x - handled by XRegExp when delimiters are provided as strings + /y - not needed here; supported by other handling in this function + */ + esc = new RegExp( + "^(?:" + escaped + "[\\S\\s]|(?:(?!" + left.source + "|" + right.source + ")[^" + escaped + "])+)+", + ignoreCase ? "i" : "" + ); + } + + while (true) { + /* advance the starting search position to the end of the last delimiter match. + a couple special cases are also covered: + - if using an escape character, advance to the next delimiter's starting position, + skipping any escaped characters + - first time through, reset lastIndex in case delimiters were provided as regexes + */ + left.lastIndex = right.lastIndex = delimEnd + + (escapeChar ? (esc.exec(str.slice(delimEnd)) || [""])[0].length : 0); + + leftMatch = left.exec(str); + rightMatch = right.exec(str); + + // only keep the result which matched earlier in the string + if (leftMatch && rightMatch) { + if (leftMatch.index <= rightMatch.index) + rightMatch = null; + else leftMatch = null; + } + + /* paths*: + leftMatch | rightMatch | openTokens | result + 1 | 0 | 1 | ... + 1 | 0 | 0 | ... + 0 | 1 | 1 | ... + 0 | 1 | 0 | throw + 0 | 0 | 1 | throw + 0 | 0 | 0 | break + * - does not include the sticky mode special case + - the loop ends after the first completed match if not in global mode + */ + + if (leftMatch || rightMatch) { + delimStart = (leftMatch || rightMatch).index; + delimEnd = (leftMatch ? left : right).lastIndex; + } else if (!openTokens) { + break; + } + + if (sticky && !openTokens && delimStart > lastOuterEnd) + break; + + if (leftMatch) { + if (!openTokens++) { + outerStart = delimStart; + innerStart = delimEnd; + } + } else if (rightMatch && openTokens) { + if (!--openTokens) { + if (vN) { + if (vN[0] && outerStart > lastOuterEnd) + output.push([vN[0], str.slice(lastOuterEnd, outerStart), lastOuterEnd, outerStart]); + if (vN[1]) output.push([vN[1], str.slice(outerStart, innerStart), outerStart, innerStart]); + if (vN[2]) output.push([vN[2], str.slice(innerStart, delimStart), innerStart, delimStart]); + if (vN[3]) output.push([vN[3], str.slice(delimStart, delimEnd), delimStart, delimEnd]); + } else { + output.push(str.slice(innerStart, delimStart)); + } + lastOuterEnd = delimEnd; + if (!global) + break; + } + } else { + // reset lastIndex in case delimiters were provided as regexes + left.lastIndex = right.lastIndex = 0; + throw Error("subject data contains unbalanced delimiters"); + } + + // if the delimiter matched an empty string, advance delimEnd to avoid an infinite loop + if (delimStart === delimEnd) + delimEnd++; + } + + if (global && !sticky && vN && vN[0] && str.length > lastOuterEnd) + output.push([vN[0], str.slice(lastOuterEnd), lastOuterEnd, str.length]); + + // reset lastIndex in case delimiters were provided as regexes + left.lastIndex = right.lastIndex = 0; + + return output; +}; diff --git a/test_script/src/shLegacy.js b/test_script/src/shLegacy.js index 7859029a1..f5cb8d22e 100644 --- a/test_script/src/shLegacy.js +++ b/test_script/src/shLegacy.js @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ var dp = { SyntaxHighlighter : {} }; diff --git a/test_script/styles/shCore.css b/test_script/styles/shCore.css index 62e815191..b720e73bd 100644 --- a/test_script/styles/shCore.css +++ b/test_script/styles/shCore.css @@ -1,321 +1,321 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -.syntaxhighlighter, -.syntaxhighlighter div, -.syntaxhighlighter code, -.syntaxhighlighter span -{ - margin: 0 !important; - padding: 0 !important; - border: 0 !important; - outline: 0 !important; - background: none !important; - text-align: left !important; - float: none !important; - vertical-align: baseline !important; - position: static !important; - left: auto !important; - top: auto !important; - right: auto !important; - bottom: auto !important; - height: auto !important; - width: auto !important; - line-height: 1.1em !important; - font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; - font-weight: normal !important; - font-style: normal !important; - font-size: 1em !important; -} - -.syntaxhighlighter -{ - width: 100% !important; - margin: 1em 0 1em 0 !important; - padding: 1px !important; /* adds a little border on top and bottom */ - position: relative !important; -} - -.syntaxhighlighter .bold { - font-weight: bold !important; -} - -.syntaxhighlighter .italic { - font-style: italic !important; -} - -.syntaxhighlighter .line .number -{ - float: left !important; - width: 3em !important; - padding-right: .3em !important; - text-align: right !important; - display: block !important; -} - -/* Disable numbers when no gutter option is set */ -.syntaxhighlighter.nogutter .line .number -{ - display: none !important; -} - -.syntaxhighlighter .line .content -{ - margin-left: 3.3em !important; - padding-left: .5em !important; - display: block !important; -} - -.syntaxhighlighter .line .content .block -{ - display: block !important; - padding-left: 1.5em !important; - text-indent: -1.5em !important; -} - -.syntaxhighlighter .line .content .spaces -{ - display: none !important; -} - -/* Disable border and margin on the lines when no gutter option is set */ -.syntaxhighlighter.nogutter .line .content -{ - margin-left: 0 !important; - border-left: none !important; -} - -.syntaxhighlighter .bar -{ -} - -.syntaxhighlighter.collapsed .bar -{ - -} - -.syntaxhighlighter.nogutter .ruler -{ - margin-left: 0 !important; - padding-left: 0 !important; -} - -.syntaxhighlighter .ruler -{ - padding: 0 0 .5em .5em !important; - margin-left: 3.3em !important; - overflow: hidden !important; -} - -/* Adjust some properties when collapsed */ - -.syntaxhighlighter.collapsed .lines, -.syntaxhighlighter.collapsed .ruler -{ - display: none !important; -} - -/* Styles for the toolbar */ - -.syntaxhighlighter .toolbar -{ - position: absolute !important; - right: 0px !important; - top: 0px !important; - font-size: 1px !important; - padding: 8px 8px 8px 0 !important; /* in px because images don't scale with ems */ -} - -.syntaxhighlighter.collapsed .toolbar -{ - font-size: 80% !important; - padding: .2em 0 .5em .5em !important; - position: static !important; -} - -.syntaxhighlighter .toolbar a.item, -.syntaxhighlighter .toolbar .item -{ - display: block !important; - float: left !important; - margin-left: 8px !important; - background-repeat: no-repeat !important; - overflow: hidden !important; - text-indent: -5000px !important; -} - -.syntaxhighlighter.collapsed .toolbar .item -{ - display: none !important; -} - -.syntaxhighlighter.collapsed .toolbar .item.expandSource -{ - background-image: url(magnifier.png) !important; - display: inline !important; - text-indent: 0 !important; - width: auto !important; - float: none !important; - height: 16px !important; - padding-left: 20px !important; -} - -.syntaxhighlighter .toolbar .item.viewSource -{ - background-image: url(page_white_code.png) !important; -} - -.syntaxhighlighter .toolbar .item.printSource -{ - background-image: url(printer.png) !important; -} - -.syntaxhighlighter .toolbar .item.copyToClipboard -{ - text-indent: 0 !important; - background: none !important; - overflow: visible !important; -} - -.syntaxhighlighter .toolbar .item.about -{ - background-image: url(help.png) !important; -} - -/** - * Print view. - * Colors are based on the default theme without background. - */ - -.syntaxhighlighter.printing, -.syntaxhighlighter.printing .line.alt1 .content, -.syntaxhighlighter.printing .line.alt2 .content, -.syntaxhighlighter.printing .line.highlighted .number, -.syntaxhighlighter.printing .line.highlighted.alt1 .content, -.syntaxhighlighter.printing .line.highlighted.alt2 .content, -.syntaxhighlighter.printing .line .content .block -{ - background: none !important; -} - -/* Gutter line numbers */ -.syntaxhighlighter.printing .line .number -{ - color: #bbb !important; -} - -/* Add border to the lines */ -.syntaxhighlighter.printing .line .content -{ - color: #000 !important; -} - -/* Toolbar when visible */ -.syntaxhighlighter.printing .toolbar, -.syntaxhighlighter.printing .ruler -{ - display: none !important; -} - -.syntaxhighlighter.printing a -{ - text-decoration: none !important; -} - -.syntaxhighlighter.printing .plain, -.syntaxhighlighter.printing .plain a -{ - color: #000 !important; -} - -.syntaxhighlighter.printing .comments, -.syntaxhighlighter.printing .comments a -{ - color: #008200 !important; -} - -.syntaxhighlighter.printing .string, -.syntaxhighlighter.printing .string a -{ - color: blue !important; -} - -.syntaxhighlighter.printing .keyword -{ - color: #069 !important; - font-weight: bold !important; -} - -.syntaxhighlighter.printing .preprocessor -{ - color: gray !important; -} - -.syntaxhighlighter.printing .variable -{ - color: #a70 !important; -} - -.syntaxhighlighter.printing .value -{ - color: #090 !important; -} - -.syntaxhighlighter.printing .functions -{ - color: #ff1493 !important; -} - -.syntaxhighlighter.printing .constants -{ - color: #0066CC !important; -} - -.syntaxhighlighter.printing .script -{ - font-weight: bold !important; -} - -.syntaxhighlighter.printing .color1, -.syntaxhighlighter.printing .color1 a -{ - color: #808080 !important; -} - -.syntaxhighlighter.printing .color2, -.syntaxhighlighter.printing .color2 a -{ - color: #ff1493 !important; -} - -.syntaxhighlighter.printing .color3, -.syntaxhighlighter.printing .color3 a -{ - color: red !important; -} +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +.syntaxhighlighter, +.syntaxhighlighter div, +.syntaxhighlighter code, +.syntaxhighlighter span +{ + margin: 0 !important; + padding: 0 !important; + border: 0 !important; + outline: 0 !important; + background: none !important; + text-align: left !important; + float: none !important; + vertical-align: baseline !important; + position: static !important; + left: auto !important; + top: auto !important; + right: auto !important; + bottom: auto !important; + height: auto !important; + width: auto !important; + line-height: 1.1em !important; + font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; + font-weight: normal !important; + font-style: normal !important; + font-size: 1em !important; +} + +.syntaxhighlighter +{ + width: 100% !important; + margin: 1em 0 1em 0 !important; + padding: 1px !important; /* adds a little border on top and bottom */ + position: relative !important; +} + +.syntaxhighlighter .bold { + font-weight: bold !important; +} + +.syntaxhighlighter .italic { + font-style: italic !important; +} + +.syntaxhighlighter .line .number +{ + float: left !important; + width: 3em !important; + padding-right: .3em !important; + text-align: right !important; + display: block !important; +} + +/* Disable numbers when no gutter option is set */ +.syntaxhighlighter.nogutter .line .number +{ + display: none !important; +} + +.syntaxhighlighter .line .content +{ + margin-left: 3.3em !important; + padding-left: .5em !important; + display: block !important; +} + +.syntaxhighlighter .line .content .block +{ + display: block !important; + padding-left: 1.5em !important; + text-indent: -1.5em !important; +} + +.syntaxhighlighter .line .content .spaces +{ + display: none !important; +} + +/* Disable border and margin on the lines when no gutter option is set */ +.syntaxhighlighter.nogutter .line .content +{ + margin-left: 0 !important; + border-left: none !important; +} + +.syntaxhighlighter .bar +{ +} + +.syntaxhighlighter.collapsed .bar +{ + +} + +.syntaxhighlighter.nogutter .ruler +{ + margin-left: 0 !important; + padding-left: 0 !important; +} + +.syntaxhighlighter .ruler +{ + padding: 0 0 .5em .5em !important; + margin-left: 3.3em !important; + overflow: hidden !important; +} + +/* Adjust some properties when collapsed */ + +.syntaxhighlighter.collapsed .lines, +.syntaxhighlighter.collapsed .ruler +{ + display: none !important; +} + +/* Styles for the toolbar */ + +.syntaxhighlighter .toolbar +{ + position: absolute !important; + right: 0px !important; + top: 0px !important; + font-size: 1px !important; + padding: 8px 8px 8px 0 !important; /* in px because images don't scale with ems */ +} + +.syntaxhighlighter.collapsed .toolbar +{ + font-size: 80% !important; + padding: .2em 0 .5em .5em !important; + position: static !important; +} + +.syntaxhighlighter .toolbar a.item, +.syntaxhighlighter .toolbar .item +{ + display: block !important; + float: left !important; + margin-left: 8px !important; + background-repeat: no-repeat !important; + overflow: hidden !important; + text-indent: -5000px !important; +} + +.syntaxhighlighter.collapsed .toolbar .item +{ + display: none !important; +} + +.syntaxhighlighter.collapsed .toolbar .item.expandSource +{ + background-image: url(magnifier.png) !important; + display: inline !important; + text-indent: 0 !important; + width: auto !important; + float: none !important; + height: 16px !important; + padding-left: 20px !important; +} + +.syntaxhighlighter .toolbar .item.viewSource +{ + background-image: url(page_white_code.png) !important; +} + +.syntaxhighlighter .toolbar .item.printSource +{ + background-image: url(printer.png) !important; +} + +.syntaxhighlighter .toolbar .item.copyToClipboard +{ + text-indent: 0 !important; + background: none !important; + overflow: visible !important; +} + +.syntaxhighlighter .toolbar .item.about +{ + background-image: url(help.png) !important; +} + +/** + * Print view. + * Colors are based on the default theme without background. + */ + +.syntaxhighlighter.printing, +.syntaxhighlighter.printing .line.alt1 .content, +.syntaxhighlighter.printing .line.alt2 .content, +.syntaxhighlighter.printing .line.highlighted .number, +.syntaxhighlighter.printing .line.highlighted.alt1 .content, +.syntaxhighlighter.printing .line.highlighted.alt2 .content, +.syntaxhighlighter.printing .line .content .block +{ + background: none !important; +} + +/* Gutter line numbers */ +.syntaxhighlighter.printing .line .number +{ + color: #bbb !important; +} + +/* Add border to the lines */ +.syntaxhighlighter.printing .line .content +{ + color: #000 !important; +} + +/* Toolbar when visible */ +.syntaxhighlighter.printing .toolbar, +.syntaxhighlighter.printing .ruler +{ + display: none !important; +} + +.syntaxhighlighter.printing a +{ + text-decoration: none !important; +} + +.syntaxhighlighter.printing .plain, +.syntaxhighlighter.printing .plain a +{ + color: #000 !important; +} + +.syntaxhighlighter.printing .comments, +.syntaxhighlighter.printing .comments a +{ + color: #008200 !important; +} + +.syntaxhighlighter.printing .string, +.syntaxhighlighter.printing .string a +{ + color: blue !important; +} + +.syntaxhighlighter.printing .keyword +{ + color: #069 !important; + font-weight: bold !important; +} + +.syntaxhighlighter.printing .preprocessor +{ + color: gray !important; +} + +.syntaxhighlighter.printing .variable +{ + color: #a70 !important; +} + +.syntaxhighlighter.printing .value +{ + color: #090 !important; +} + +.syntaxhighlighter.printing .functions +{ + color: #ff1493 !important; +} + +.syntaxhighlighter.printing .constants +{ + color: #0066CC !important; +} + +.syntaxhighlighter.printing .script +{ + font-weight: bold !important; +} + +.syntaxhighlighter.printing .color1, +.syntaxhighlighter.printing .color1 a +{ + color: #808080 !important; +} + +.syntaxhighlighter.printing .color2, +.syntaxhighlighter.printing .color2 a +{ + color: #ff1493 !important; +} + +.syntaxhighlighter.printing .color3, +.syntaxhighlighter.printing .color3 a +{ + color: red !important; +} diff --git a/test_script/styles/shThemeDefault.css b/test_script/styles/shThemeDefault.css index a4b2f8206..e466c97de 100644 --- a/test_script/styles/shThemeDefault.css +++ b/test_script/styles/shThemeDefault.css @@ -1,191 +1,191 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ -/************************************ - * Default Syntax Highlighter theme. - * - * Interface elements. - ************************************/ - -.syntaxhighlighter -{ - background-color: #E7E5DC !important; -} - -/* Highlighed line number */ -.syntaxhighlighter .line.highlighted .number -{ - background-color: #6CE26C !important; - color: black !important; -} - -/* Highlighed line */ -.syntaxhighlighter .line.highlighted.alt1 .content, -.syntaxhighlighter .line.highlighted.alt2 .content -{ - background-color: #6CE26C !important; -} - -/* Gutter line numbers */ -.syntaxhighlighter .line .number -{ - color: #5C5C5C !important; -} - -/* Add border to the lines */ -.syntaxhighlighter .line .content -{ - border-left: 3px solid #6CE26C !important; - color: #000 !important; -} - -.syntaxhighlighter.printing .line .content -{ - border: 0 !important; -} - -/* First line */ -.syntaxhighlighter .line.alt1 .content -{ - background-color: #fff !important; -} - -/* Second line */ -.syntaxhighlighter .line.alt2 .content -{ - background-color: #F8F8F8 !important; -} - -.syntaxhighlighter .line .content .block -{ - background: url(wrapping.png) 0 1.1em no-repeat !important; -} - -.syntaxhighlighter .ruler -{ - color: silver !important; - background-color: #F8F8F8 !important; - border-left: 3px solid #6CE26C !important; -} - -.syntaxhighlighter.nogutter .ruler -{ - border: 0 !important; -} - -.syntaxhighlighter .toolbar -{ - background-color: #F8F8F8 !important; - border: #E7E5DC solid 1px !important; -} - -.syntaxhighlighter .toolbar a -{ - color: #a0a0a0 !important; -} - -.syntaxhighlighter .toolbar a:hover -{ - color: red !important; -} - -/************************************ - * Actual syntax highlighter colors. - ************************************/ -.syntaxhighlighter .plain, -.syntaxhighlighter .plain a -{ - color: #000 !important; -} - -.syntaxhighlighter .comments, -.syntaxhighlighter .comments a -{ - color: #008200 !important; -} - -.syntaxhighlighter .string, -.syntaxhighlighter .string a -{ - color: blue !important; -} - -.syntaxhighlighter .keyword -{ - color: #069 !important; - font-weight: bold !important; -} - -.syntaxhighlighter .preprocessor -{ - color: gray !important; -} - -.syntaxhighlighter .variable -{ - color: #a70 !important; -} - -.syntaxhighlighter .value -{ - color: #090 !important; -} - -.syntaxhighlighter .functions -{ - color: #ff1493 !important; -} - -.syntaxhighlighter .constants -{ - color: #0066CC !important; -} - -.syntaxhighlighter .script -{ - background-color: yellow !important; -} - -.syntaxhighlighter .color1, -.syntaxhighlighter .color1 a -{ - color: #808080 !important; -} - -.syntaxhighlighter .color2, -.syntaxhighlighter .color2 a -{ - color: #ff1493 !important; -} - -.syntaxhighlighter .color3, -.syntaxhighlighter .color3 a -{ - color: red !important; -} +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ +/************************************ + * Default Syntax Highlighter theme. + * + * Interface elements. + ************************************/ + +.syntaxhighlighter +{ + background-color: #E7E5DC !important; +} + +/* Highlighed line number */ +.syntaxhighlighter .line.highlighted .number +{ + background-color: #6CE26C !important; + color: black !important; +} + +/* Highlighed line */ +.syntaxhighlighter .line.highlighted.alt1 .content, +.syntaxhighlighter .line.highlighted.alt2 .content +{ + background-color: #6CE26C !important; +} + +/* Gutter line numbers */ +.syntaxhighlighter .line .number +{ + color: #5C5C5C !important; +} + +/* Add border to the lines */ +.syntaxhighlighter .line .content +{ + border-left: 3px solid #6CE26C !important; + color: #000 !important; +} + +.syntaxhighlighter.printing .line .content +{ + border: 0 !important; +} + +/* First line */ +.syntaxhighlighter .line.alt1 .content +{ + background-color: #fff !important; +} + +/* Second line */ +.syntaxhighlighter .line.alt2 .content +{ + background-color: #F8F8F8 !important; +} + +.syntaxhighlighter .line .content .block +{ + background: url(wrapping.png) 0 1.1em no-repeat !important; +} + +.syntaxhighlighter .ruler +{ + color: silver !important; + background-color: #F8F8F8 !important; + border-left: 3px solid #6CE26C !important; +} + +.syntaxhighlighter.nogutter .ruler +{ + border: 0 !important; +} + +.syntaxhighlighter .toolbar +{ + background-color: #F8F8F8 !important; + border: #E7E5DC solid 1px !important; +} + +.syntaxhighlighter .toolbar a +{ + color: #a0a0a0 !important; +} + +.syntaxhighlighter .toolbar a:hover +{ + color: red !important; +} + +/************************************ + * Actual syntax highlighter colors. + ************************************/ +.syntaxhighlighter .plain, +.syntaxhighlighter .plain a +{ + color: #000 !important; +} + +.syntaxhighlighter .comments, +.syntaxhighlighter .comments a +{ + color: #008200 !important; +} + +.syntaxhighlighter .string, +.syntaxhighlighter .string a +{ + color: blue !important; +} + +.syntaxhighlighter .keyword +{ + color: #069 !important; + font-weight: bold !important; +} + +.syntaxhighlighter .preprocessor +{ + color: gray !important; +} + +.syntaxhighlighter .variable +{ + color: #a70 !important; +} + +.syntaxhighlighter .value +{ + color: #090 !important; +} + +.syntaxhighlighter .functions +{ + color: #ff1493 !important; +} + +.syntaxhighlighter .constants +{ + color: #0066CC !important; +} + +.syntaxhighlighter .script +{ + background-color: yellow !important; +} + +.syntaxhighlighter .color1, +.syntaxhighlighter .color1 a +{ + color: #808080 !important; +} + +.syntaxhighlighter .color2, +.syntaxhighlighter .color2 a +{ + color: #ff1493 !important; +} + +.syntaxhighlighter .color3, +.syntaxhighlighter .color3 a +{ + color: red !important; +} diff --git a/test_script/styles/shThemeDjango.css b/test_script/styles/shThemeDjango.css index 12433540c..65a7f0672 100644 --- a/test_script/styles/shThemeDjango.css +++ b/test_script/styles/shThemeDjango.css @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ /** * Django SyntaxHighlighter theme */ diff --git a/test_script/styles/shThemeEmacs.css b/test_script/styles/shThemeEmacs.css index d1710a6e8..e4eed1654 100644 --- a/test_script/styles/shThemeEmacs.css +++ b/test_script/styles/shThemeEmacs.css @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ /** * Emacs SyntaxHighlighter theme based on theme by Joshua Emmons * http://www.skia.net/ diff --git a/test_script/styles/shThemeFadeToGrey.css b/test_script/styles/shThemeFadeToGrey.css index 0d036c1cb..b19c3be39 100644 --- a/test_script/styles/shThemeFadeToGrey.css +++ b/test_script/styles/shThemeFadeToGrey.css @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ /** * Fade to Grey SyntaxHighlighter theme based on theme by Brasten Sager * http://www.ibrasten.com/ diff --git a/test_script/styles/shThemeMidnight.css b/test_script/styles/shThemeMidnight.css index f49a7b3e3..0f39d0c80 100644 --- a/test_script/styles/shThemeMidnight.css +++ b/test_script/styles/shThemeMidnight.css @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ /** * Midnight SyntaxHighlighter theme based on theme by J.D. Myers * http://webdesign.lsnjd.com/ diff --git a/test_script/styles/shThemeRDark.css b/test_script/styles/shThemeRDark.css index 618554b98..308db5989 100644 --- a/test_script/styles/shThemeRDark.css +++ b/test_script/styles/shThemeRDark.css @@ -1,32 +1,32 @@ -/** - * SyntaxHighlighter - * http://alexgorbatchev.com/ - * - * SyntaxHighlighter is donationware. If you are using it, please donate. - * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate - * - * @version - * 2.0.296 (March 01 2009) - * - * @copyright - * Copyright (C) 2004-2009 Alex Gorbatchev. - * - * @license - * This file is part of SyntaxHighlighter. - * - * SyntaxHighlighter is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SyntaxHighlighter is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SyntaxHighlighter. If not, see . - */ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/ + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate + * + * @version + * 2.0.296 (March 01 2009) + * + * @copyright + * Copyright (C) 2004-2009 Alex Gorbatchev. + * + * @license + * This file is part of SyntaxHighlighter. + * + * SyntaxHighlighter is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SyntaxHighlighter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SyntaxHighlighter. If not, see . + */ /** * RDark SyntaxHighlighter theme based on theme by Radu Dineiu * http://www.vim.org/scripts/script.php?script_id=1732 diff --git a/test_script/test.html b/test_script/test.html index 5c5a725b3..97caee08d 100644 --- a/test_script/test.html +++ b/test_script/test.html @@ -1,46 +1,46 @@ - - - - - SyntaxHighlighter Build Test Page - - - - - - - - - - -

SyntaxHihglighter Test

-

This is a test file to insure that everything is working well.

- -
-function test() : String
-{
-  return 10;
-}
-
- + + + + + SyntaxHighlighter Build Test Page + + + + + + + + + + +

SyntaxHihglighter Test

+

This is a test file to insure that everything is working well.

+ +
+function test() : String
+{
+  return 10;
+}
+
+