diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..7664592 --- /dev/null +++ b/.htaccess @@ -0,0 +1,5 @@ + RewriteEngine On + RewriteRule ^$ main [QSA] + RewriteRule ^index\.php$ wiki.php?page=main [QSA] + RewriteCond %{REQUEST_URI} !(/includes/|/media) + RewriteRule ^([^\d]+)/?$ wiki.php?page=$1 [QSA] diff --git a/FOOTER.php b/FOOTER.php deleted file mode 100644 index f96e097..0000000 --- a/FOOTER.php +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/HEADER.php b/HEADER.php deleted file mode 100644 index 3193047..0000000 --- a/HEADER.php +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/HEADER2.php b/HEADER2.php deleted file mode 100644 index 3da4409..0000000 --- a/HEADER2.php +++ /dev/null @@ -1,12 +0,0 @@ - - -
- -
-
-
-
diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..cb564da --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,163 @@ +GNU Lesser General Public License +================================= + +_Version 3, 29 June 2007_ +_Copyright © 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. diff --git a/MENU.php b/MENU.php deleted file mode 100644 index 98aea6f..0000000 --- a/MENU.php +++ /dev/null @@ -1,49 +0,0 @@ - -
 
-
diff --git a/README.md b/README.md index 13f5f62..44ffcaf 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,49 @@ -# thunix 2.0 website update +Wiki.php +======== -This is the code powering the website for thunix, originally founded by hexhaxtron. Since the original site went down, amcclure and ubergeek revived the site, though with only the bare necessities. +Wiki.php is a simple cms/wiki script. You can see it in use here: -These updates are designed to not only beautify the website with updated CSS and fully compliant HTML5 code, but also to automate visitor interaction with site administration and to provide server status information. +* [Thunix Wiki](https://wiki.thunix.net) +* [Ubergeek's Personal Page](https://thunix.net/~ubergeek) -Features include: -- Emailing scripts for general inquiries, registration and abuse reporting -- Scripting to automatically present functional user web pages in a menu list -- Scripting to provide server status reports to visitors* +Installation +============ -*This requires the monurbox server monitoring shell script, executed through an hourly cron job +Installation is really only a couple of steps: + + +* Clone down the repo +* Edit config.php. The values are pretty self-explantory, but there's also comments explaining +* Edit includes/header.md, includes/footer.md, and includes/sidebar.md + +If you are not using apache, you'll need to add in some mechanism for the rewrites to work, unless you don't care about pretty URLs. But, you will need to keep those in mind when adding links to your documents. + +Something along these lines ~should~ work: + + location / { + # This is cool because no php is touched for static content. + # include the "?$args" part so non-default permalinks doesn't break when using query string + try_files $uri $uri/ /wiki.php?page=$uri; + } + +Once that's all set, you can start editing articles. Main.md is always the landing page. + +Directory Structure +=================== + + ./ <-- Doc root + ./wiki.php <-- main code + ./media <-- Images and such. Files here do get get hit by the rewrite rule + ./articles <-- All of your site's content + ./includes <-- Support files that make up the layout + header.md <-- site header + footer.md <-- site footer + sidebar.mb <-- site sidebar + ./config.php <-- Site configuration file + ./parsedown-{version} <-- The parsedown version used in this engine + +Support +======= + +Open an issue at [ubergeek/wiki.php](https://tildegit.org/ubergeek/wiki.php/issues). PRs are also welcomed! -To run this website, the server computer requires PHP, with the GD extension (for generating CAPTCHA images,) Sendmail (to send emails from the website, to administration) and monurbox (to generate server status reports). \ No newline at end of file diff --git a/abuse.admin.php b/abuse.admin.php deleted file mode 100644 index 92fbf55..0000000 --- a/abuse.admin.php +++ /dev/null @@ -1,860 +0,0 @@ - - $isHideForm, - 'error_fields' => isset($phpfmg_send['error']) ? $phpfmg_send['error']['fields'] : '', - 'OneEntry' => isset($GLOBALS['OneEntry']) ? $GLOBALS['OneEntry'] : '', - ); - - @header("Content-Type:text/html; charset=$charset"); - echo ""; - -} - - -function phpfmg_admin_default(){ - if( phpfmg_user_login() ){ - phpfmg_admin_panel(); - }; -} - - - -function phpfmg_admin_panel() -{ - if( !phpfmg_user_isLogin() ){ - exit; - }; - - phpfmg_admin_header(); - phpfmg_writable_check(); -?> - - - - -
- - - - - - -
- 1. Email Traffics -
-
- view    - download    - delete all'; - }; - ?> -
- - -
- 2. Form Data -
-
- view    - download    - delete all'; - }; - ?> -
- -
- 3. Form Generator -
-
- Edit Form    - New Form -
-
- - "> -
- -
- - - - - <?php echo '' == $title ? '' : $title . ' | ' ; ?>PHP FormMail Admin Panel - - - - - - - - - - - -
- Form Admin Panel - -   -Main Menu   ' ; - echo 'Logout' ; - }; -?> -
- -
- - - -
- -
- :: PHP FormMail Generator :: -
- - - -out_processing_gif(); -} - - -# phpfmg module : captcha -# ------------------------------------------------------ -function phpfmg_captcha_get(){ - $img = new phpfmgImage(); - $img->out(); - //$_SESSION[PHPFMG_ID.'fmgCaptchCode'] = $img->text ; - $_SESSION[ phpfmg_captcha_name() ] = $img->text ; -} - - - -function phpfmg_captcha_generate_images(){ - for( $i = 0; $i < 50; $i ++ ){ - $file = "$i.png"; - $img = new phpfmgImage(); - $img->out($file); - $data = base64_encode( file_get_contents($file) ); - echo "'{$img->text}' => '{$data}',\n" ; - unlink( $file ); - }; -} - - -function phpfmg_dd_lookup(){ - $paraOk = ( isset($_REQUEST['n']) && isset($_REQUEST['lookup']) && isset($_REQUEST['field_name']) ); - if( !$paraOk ) - return; - - $base64 = phpfmg_dependent_dropdown_data(); - $data = @unserialize( base64_decode($base64) ); - if( !is_array($data) ){ - return ; - }; - - - foreach( $data as $field ){ - if( $field['name'] == $_REQUEST['field_name'] ){ - $nColumn = intval($_REQUEST['n']); - $lookup = $_REQUEST['lookup']; // $lookup is an array - $dd = new DependantDropdown(); - echo $dd->lookupFieldColumn( $field, $nColumn, $lookup ); - return; - }; - }; - - return; -} - - -function phpfmg_filman_download(){ - if( !isset($_REQUEST['filelink']) ) - return ; - - $filelink = base64_decode($_REQUEST['filelink']); - $file = PHPFMG_SAVE_ATTACHMENTS_DIR . basename($filelink); - - // 2016-12-05: to prevent *LFD/LFI* attack. patch provided by Pouya Darabi, a security researcher in cert.org - $real_basePath = realpath(PHPFMG_SAVE_ATTACHMENTS_DIR); - $real_requestPath = realpath($file); - if ($real_requestPath === false || strpos($real_requestPath, $real_basePath) !== 0) { - return; - }; - - if( !file_exists($file) ){ - return ; - }; - - phpfmg_util_download( $file, $filelink ); -} - - -class phpfmgDataManager -{ - var $dataFile = ''; - var $columns = ''; - var $records = ''; - - function __construct(){ - $this->dataFile = PHPFMG_SAVE_FILE; - } - - function phpfmgDataManager(){ - $this->dataFile = PHPFMG_SAVE_FILE; - } - - function parseFile(){ - $fp = @fopen($this->dataFile, 'rb'); - if( !$fp ) return false; - - $i = 0 ; - $phpExitLine = 1; // first line is php code - $colsLine = 2 ; // second line is column headers - $this->columns = array(); - $this->records = array(); - $sep = chr(0x09); - while( !feof($fp) ) { - $line = fgets($fp); - $line = trim($line); - if( empty($line) ) continue; - $line = $this->line2display($line); - $i ++ ; - switch( $i ){ - case $phpExitLine: - continue; - break; - case $colsLine : - $this->columns = explode($sep,$line); - break; - default: - $this->records[] = explode( $sep, phpfmg_data2record( $line, false ) ); - }; - }; - fclose ($fp); - } - - function displayRecords(){ - $this->parseFile(); - echo ""; - echo "\n"; - $i = 1; - foreach( $this->records as $r ){ - echo "\n"; - $i++; - }; - echo "
 " . join( " ", $this->columns ) . "
{$i} " . join( " ", $r ) . "
\n"; - } - - function line2display( $line ){ - $line = str_replace( array('"' . chr(0x09) . '"', '""'), array(chr(0x09),'"'), $line ); - $line = substr( $line, 1, -1 ); // chop first " and last " - return $line; - } - -} -# end of class - - - -# ------------------------------------------------------ -class phpfmgImage -{ - var $im = null; - var $width = 73 ; - var $height = 33 ; - var $text = '' ; - var $line_distance = 8; - var $text_len = 4 ; - - function __construct( $text = '', $len = 4 ){ - $this->phpfmgImage( $text, $len ); - } - - function phpfmgImage( $text = '', $len = 4 ){ - $this->text_len = $len ; - $this->text = '' == $text ? $this->uniqid( $this->text_len ) : $text ; - $this->text = strtoupper( substr( $this->text, 0, $this->text_len ) ); - } - - function create(){ - $this->im = imagecreate( $this->width, $this->height ); - $bgcolor = imagecolorallocate($this->im, 255, 255, 255); - $textcolor = imagecolorallocate($this->im, 0, 0, 0); - $this->drawLines(); - imagestring($this->im, 5, 20, 9, $this->text, $textcolor); - } - - function drawLines(){ - $linecolor = imagecolorallocate($this->im, 210, 210, 210); - - //vertical lines - for($x = 0; $x < $this->width; $x += $this->line_distance) { - imageline($this->im, $x, 0, $x, $this->height, $linecolor); - }; - - //horizontal lines - for($y = 0; $y < $this->height; $y += $this->line_distance) { - imageline($this->im, 0, $y, $this->width, $y, $linecolor); - }; - } - - function out( $filename = '' ){ - if( function_exists('imageline') ){ - $this->create(); - if( '' == $filename ) header("Content-type: image/png"); - ( '' == $filename ) ? imagepng( $this->im ) : imagepng( $this->im, $filename ); - imagedestroy( $this->im ); - }else{ - $this->out_predefined_image(); - }; - } - - function uniqid( $len = 0 ){ - $md5 = md5( uniqid(rand()) ); - return $len > 0 ? substr($md5,0,$len) : $md5 ; - } - - function out_predefined_image(){ - header("Content-type: image/png"); - $data = $this->getImage(); - echo base64_decode($data); - } - - // Use predefined captcha random images if web server doens't have GD graphics library installed - function getImage(){ - $images = array( - 'F152' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbElEQVR4nGNYhQEaGAYTpIn7QkMZAlhDHaY6IIkFNDAGsDYwBASgiLECxRgdRFDEgHqnMjSIILkvNGpV1NLMrFVRSO4DqQOSjQ5oeoFkKwO6eQ0BU9DFGB0dAlDFWEMZQhlDQwZB+FERYnEfAAa9y0AwZOMeAAAAAElFTkSuQmCC', - 'E0D3' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj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HvAAAAAElFTkSuQmCC', - '19B0' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZUlEQVR4nGNYhQEaGAYTpIn7GB0YQ1hDGVqRxVgdWFtZGx2mOiCJiTqINLo2BAQEoOgFijU6OogguW9l1tKlqaErs6YhuQ9oRyCSOqgYA9C8QDQxFix2YHFLCKabByr8qAixuA8AyM3KUvjtMMoAAAAASUVORK5CYII=', - '2105' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcUlEQVR4nM2QsRHAIAwDReENGAiK9ErhIkxDwwYkG6RhykDnHCmTu1idTrL/jDZNxp/0CZ8QRHVK4/nqCHXB5liELsabhwJKXpdg+Y6WzralZPk4cszedPv2yZOeHDes50dbQcunKoqKPfzgfy/qge8CQVvIaymcbJsAAAAASUVORK5CYII=', - '0F97' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbUlEQVR4nGNYhQEaGAYTpIn7GB1EQx1CGUNDkMRYA0QaGB0dGkSQxESmiDSwNgSgiAW0QsQCkNwXtXRq2MrMqJVZSO4DqWMICWhlQNMLJKcwoNnB2BAQwIDhFkcHVDcD9YYyoogNVPhREWJxHwAt+8sjvlP2ygAAAABJRU5ErkJggg==', - '77F7' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYklEQVR4nGNYhQEaGAYTpIn7QkNFQ11DA0NDkEVbGRpdgbQIIbEpDK2sQDoA2X1Rq6YtDV21MgvJfYwODAGsIBOQ9LICRVlBJiCJiQBFgWIByGIBYFGgCQTEBir8qAixuA8A5/nK1kyB4VAAAAAASUVORK5CYII=', - '2160' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcElEQVR4nGNYhQEaGAYTpIn7WAMYAhhCGVqRxUSmMAYwOjpMdUASC2hlDWBtcAgIQNbdygAUY3QQQXbftFVRS6euzJqG7D6gHayOjjB1YMjoANIbiCLG2gASC0CxAyiP4ZbQUNZQdDcPVPhREWJxHwBFackYlJahVAAAAABJRU5ErkJggg==', - '6978' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdUlEQVR4nGNYhQEaGAYTpIn7WAMYQ1hDA6Y6IImJTGFtZWgICAhAEgtoEWl0aAh0EEEWawCKNTrA1IGdFBm1dGnW0lVTs5DcFzKFMdBhCgOqea0MQJ2MqOa1sjQ6OqCKgdzC2oCqF+zmBgYUNw9U+FERYnEfAJtEzRM1OoL1AAAAAElFTkSuQmCC', - 'CE84' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYUlEQVR4nGNYhQEaGAYTpIn7WENEQxlCGRoCkMREWkUaGB0dGpHFAhpFGlgbAlpRxBrA6qYEILkvatXUsFWhq6KikNwHUefogK6XtSEwNATTDmxuQRHD5uaBCj8qQizuAwDuiM2jcyLlCAAAAABJRU5ErkJggg==', - '00F1' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXklEQVR4nGNYhQEaGAYTpIn7GB0YAlhDA1qRxVgDGENYGximIouJTGFtBYqFIosFtIo0ujYwwPSCnRS1dNrK1NBVS5Hdh6YOpxjUDmxuQREDuxnoloBBEH5UhFjcBwAh48qTb0HaGAAAAABJRU5ErkJggg==', - '684F' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZklEQVR4nGNYhQEaGAYTpIn7WAMYQxgaHUNDkMREprC2MrQ6OiCrC2gRaXSYiibWA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jcBwCmSsirRUkFjQAAAABJRU5ErkJggg==', - '691C' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAb0lEQVR4nGNYhQEaGAYTpIn7WAMYQximMEwNQBITmcLayhDCECCCJBbQItLoGMLowIIs1iDS6DCF0QHZfZFRS5dmTVuZhey+kCmMgUjqIHpbGRoxxVjAYsh2gN0yBdUtIDczhjqguHmgwo+KEIv7APkGy0sLSVsmAAAAAElFTkSuQmCC', - 'B561' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7QgNEQxlCGVqRxQKmiDQwOjpMRRFrFWlgbXAIRVMXwtoA1wt2UmjU1KVLp65aiuy+gCkMja6ODqh2tALFQCSqHZhiU1hbGdH0hgYwhgDdHBowCMKPihCL+wAEBs3FJNZm/wAAAABJRU5ErkJggg==', - 'EFEB' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAATUlEQVR4nGNYhQEaGAYTpIn7QkNEQ11DHUMdkMQCGkQaWBsYHQKwiIngVgd2UmjU1LCloStDs5DcR6p5eOyAuhkohubmgQo/KkIs7gMAzNXL2UVo758AAAAASUVORK5CYII=', - '2BC3' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaElEQVR4nGNYhQEaGAYTpIn7WANEQxhCHUIdkMREpoi0MjoEOgQgiQW0ijS6Ngg0iCDrbhVpZQXJIbtv2tSwpatWLc1Cdl8AijowZHQAmceAYh5rA6YdIg2YbgkNxXTzQIUfFSEW9wEAnUDMi4E+pBwAAAAASUVORK5CYII=', - '3209' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAA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CKah6GR2AfDQxViBEFxMBQnSx0FCRBsZQR1S3DFD4URFicR8AxEDIdp5oglcAAAAASUVORK5CYII=', - '9F9F' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZUlEQVR4nGNYhQEaGAYTpIn7WANEQx1CGUNDkMREpog0MDo6OiCrC2gVaWBtCMQnBnbStKlTw1ZmRoZmIbmP1VWkgSEEVS8DUC8DmnkCQDFGNDFsbmENAOoNZUQ1b4DCj4oQi/sAsh/JLHYl18IAAAAASUVORK5CYII=', - 'DEDD' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAUUlEQVR4nGNYhQEaGAYTpIn7QgNEQ1lDGUMdkMQCpog0sDY6OgQgi7UCxRoCHURwi4GdFLV0atjSVZFZ05DcR4Re3GJY3ILNzQMVflSEWNwHAKFizVh9TwSKAAAAAElFTkSuQmCC', - '9F74' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7WANEQ11DAxoCkMREpogAyYBGZLGAVrBYK4ZYo8OUACT3TZs6NWzV0lVRUUjuY3UFqpvC6ICslwGkN4AxNARJTAAoxujAgOEW1gZUMdYATLGBCj8qQizuAwBiZM2fhhaKUAAAAABJRU5ErkJggg==', - '9317' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7WANYQximMIaGIImJTBFpZQgB0khiAa0MjY6YYq0MU4A0kvumTV0VtmraqpVZSO5jdQWra0WxGWiewxSQbgQUgIgFMKC7ZQqjA7qbGUMdUcQGKvyoCLG4DwDlGMrwZVHhOwAAAABJRU5ErkJggg==', - '1917' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcElEQVR4nGNYhQEaGAYTpIn7GB0YQximMIaGIImxOrC2MoQwNIggiYk6iDQ6ookxAsUcpjA0BCC5b2XW0qVZ04AUkvuAdgQC1bWi2ssA0jsFVYwFJBaAKgZ0yxSgamS3hDCGMIY6oogNVPhREWJxHwD7/siyYXw2RAAAAABJRU5ErkJggg==', - 'DED8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAVklEQVR4nGNYhQEaGAYTpIn7QgNEQ1lDGaY6IIkFTBFpYG10CAhAFmsFijUEOohgiAXA1IGdFLV0atjSVVFTs5Dch6aOgHloYljcgs3NAxV+VIRY3AcAIfXOioZ7rn0AAAAASUVORK5CYII=', - '177F' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZElEQVR4nGNYhQEaGAYTpIn7GB1EQ11DA0NDkMRYHRgaHRoCHZDViWIRY3RgaGVodISJgZ20MmvVtFVLV4ZmIbkPqC6AYQojml6QKLoYK0QcRUykASSK4pYQTLGBCj8qQizuAwDvO8a5dD0LpAAAAABJRU5ErkJggg==', - '5BC8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZ0lEQVR4nGNYhQEaGAYTpIn7QkNEQxhCHaY6IIkFNIi0MjoEBASgijW6Ngg6iCCJBQaItLI2MMDUgZ0UNm1q2NJVq6ZmIbuvFUUdTAxoHiOKeQGtmHaITMF0C2sAppsHKvyoCLG4DwARFczDMjPWawAAAABJRU5ErkJggg==', - '9803' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZklEQVR4nGNYhQEaGAYTpIn7WAMYQximMIQ6IImJTGFtZQhldAhAEgtoFWl0dHR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AAASUVORK5CYII=', - '3536' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbUlEQVR4nGNYhQEaGAYTpIn7RANEQxlDGaY6IIkFTBFpYG10CAhAVtkqAiQDHQSQxaaIhDA0Ojogu29l1NSlq6auTM1Cdt8UhkaHRkc084BiQPNEUO3AEAuYwtqK7hbRAMYQdDcPVPhREWJxHwCuwMypBIcJeAAAAABJRU5ErkJggg==', - '1864' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAa0lEQVR4nGNYhQEaGAYTpIn7GB0YQxhCGRoCkMRYHVhbGR0dGpHFRB1EGl0bHFoDUPSytrI2MEwJQHLfyqyVYUunroqKQnIfWJ2jowOqXpB5gaEhGGIBDeh2AN2CIiYagunmgQo/KkIs7gMAhrfK/CzBCWwAAAAASUVORK5CYII=', - '989B' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7WAMYQxhCGUMdkMREprC2Mjo6OgQgiQW0ijS6NgQ6iKCIsbayAsUCkNw3berKsJWZkaFZSO5jdWVtZQgJRDGPAWieA5p5AkAxRzQxbG7B5uaBCj8qQizuAwDITssEUwJrEwAAAABJRU5ErkJggg==', - 'B6B6' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYklEQVR4nGNYhQEaGAYTpIn7QgMYQ1hDGaY6IIkFTGFtZW10CAhAFmsVaWRtCHQQQFEn0sDa6OiA7L7QqGlhS0NXpmYhuS9giijQPEcM81yB5okQEsPiFmxuHqjwoyLE4j4AOlTN7ga1Fu8AAAAASUVORK5CYII=', - '72EE' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8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ANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYUlEQVR4nGNYhQEaGAYTpIn7GB1EQx1CGVqRxVgdRBoYHR2mOiCJiQLFWBscAgJQ9ILEQCTCfSuzpoYtnboyaxqS+8DqHB1h6pD0BmIRC8CwA8MtIUBdaG4eqPCjIsTiPgA/8skaq3bH7wAAAABJRU5ErkJggg==', - '98D8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYElEQVR4nGNYhQEaGAYTpIn7WAMYQ1hDGaY6IImJTGFtZW10CAhAEgtoFWl0bQh0EEERA6prCICpAztp2tSVYUtXRU3NQnIfqyuKOgjEYp4AFjFsbsHm5oEKPypCLO4DAExozQggqthMAAAAAElFTkSuQmCC', - 'F874' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAY0lEQVR4nGNYhQEaGAYTpIn7QkMZQ1hDAxoCkMQCGlhbgWQjqphIo0NDQCuGukaHKQFI7guNWhm2aumqqCgk94HVTWF0wDAvgDE0BE3M0YEBwy2sDehiQDejiQ1U+FERYnEfAF0Dz2BFrXwyAAAAAElFTkSuQmCC', - '002D' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbklEQVR4nGNYhQEaGAYTpIn7GB0YAhhCGUMdkMRYAxhDGB0dHQKQxESmsLayNgQ6iCCJBbSKNDogxMBOilo6bWXWysysaUjuA6trZcTUOwVVDGQHQwCqGNgtDowobgG5mTU0EMXNAxV+VIRY3AcAEBnJpP1QmcoAAAAASUVORK5CYII=', - 'AF79' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbElEQVR4nGNYhQEaGAYTpIn7GB1EQ11DA6Y6IImxBogAyYC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UhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXElEQVR4nGNYhQEaGAYTpIn7WANYQxhDGUIdkMREpoi0sjY6OgQgiQW0MjQ6NAQ0iKCKQUUR7ps2dVXYqqmrlmYhuY/VFUUdBGIxTwCLGDa3YHPzQIUfFSEW9wEA1/HNeY5OYhUAAAAASUVORK5CYII=', - '88B8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAUUlEQVR4nGNYhQEaGAYTpIn7WAMYQ1hDGaY6IImJTGFtZW10CAhAEgtoFWl0bQh0EMGtDuykpVErw5aGrpqaheQ+Ys0jwg6cbh6o8KMixOI+ALskzXrMxfy/AAAAAElFTkSuQmCC', - '5F59' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAb0lEQVR4nGNYhQEaGAYTpIn7QkNEQ11DHaY6IIkFNIg0sDYwBARgiDE6iCCJBQYAxabCxcBOCps2NWxpZlZUGLL7WkEqAqYi64WKNSCLBbSC7AhAsUNkikgDo6MDiltYgfYyhDKguHmgwo+KEIv7ACDdzAmhHWYrAAAAAElFTkSuQmCC', - '9D43' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbUlEQVR4nGNYhQEaGAYTpIn7WANEQxgaHUIdkMREpoi0MrQ6OgQgiQW0ijQ6THVoEEEXC3RoCEBy37Sp01ZmZmYtzUJyH6urSKNrI1wdBAL1uoYGoJgnADKvEdUOsFsaUd2Czc0DFX5UhFjcBwAgDc58de4yqgAAAABJRU5ErkJggg==' - ); - $this->text = array_rand( $images ); - return $images[ $this->text ] ; - } - - function out_processing_gif(){ - $image = dirname(__FILE__) . '/processing.gif'; - $base64_image = "R0lGODlhFAAUALMIAPh2AP+TMsZiALlcAKNOAOp4ANVqAP+PF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K9YLBYvLtHH5K0J0IADs="; - $binary = is_file($image) ? join("",file($image)) : base64_decode($base64_image); - header("Cache-Control: post-check=0, pre-check=0, max-age=0, no-store, no-cache, must-revalidate"); - header("Pragma: no-cache"); - header("Content-type: image/gif"); - echo $binary; - } - -} -# end of class phpfmgImage -# ------------------------------------------------------ -# end of module : captcha - - -# module user -# ------------------------------------------------------ -function phpfmg_user_isLogin(){ - return ( isset($_SESSION['authenticated']) && true === $_SESSION['authenticated'] ); -} - - -function phpfmg_user_logout(){ - session_destroy(); - header("Location: admin.php"); -} - -function phpfmg_user_login() -{ - if( phpfmg_user_isLogin() ){ - return true ; - }; - - $sErr = "" ; - if( 'Y' == $_POST['formmail_submit'] ){ - if( - defined( 'PHPFMG_USER' ) && strtolower(PHPFMG_USER) == strtolower($_POST['Username']) && - defined( 'PHPFMG_PW' ) && strtolower(PHPFMG_PW) == strtolower($_POST['Password']) - ){ - $_SESSION['authenticated'] = true ; - return true ; - - }else{ - $sErr = 'Login failed. Please try again.'; - } - }; - - // show login form - phpfmg_admin_header(); -?> -
- -


- -
-
-
- - - - - - - - - - - - -
Email : - -
Password : - -
-

- {$sErr}

\n"; ?> - I forgot my password -
-
-
- - - -
- -


- -
-
-
-Request Password -Enter Email Address :
- -
-The password will be sent to this email address. -
{$sErr}

\n"; ?> -
-
- - -" ); - echo "
Your password has been sent.

Click here to login again
"; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_writable_check(){ - - if( is_writable( dirname(PHPFMG_SAVE_FILE) ) && is_writable( dirname(PHPFMG_EMAILS_LOGFILE) ) ){ - return ; - }; -?> - -

-
-
Your form data or email traffic log is NOT saving.
- The form data () and email traffic log () will be created automatically when the form is submitted. - However, the script doesn't have writable permission to create those files. In order to save your valuable information, please set the directory to writable. - If you don't know how to do it, please ask for help from your web Administrator or Technical Support of your hosting company. -
-

- PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - - phpfmg_admin_header(); - - $file = $files[$n]; - if( is_file($file) ){ - if( 1== $n ){ - echo "
\n";
-            echo join("",file($file) );
-            echo "
\n"; - }else{ - $man = new phpfmgDataManager(); - $man->displayRecords(); - }; - - - }else{ - echo "No form data found."; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_log_download(){ - $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; - $files = array( - 1 => PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - - $file = $files[$n]; - if( is_file($file) ){ - phpfmg_util_download( $file, PHPFMG_SAVE_FILE == $file ? 'form-data.csv' : 'email-traffics.txt', true, 1 ); // skip the first line - }else{ - phpfmg_admin_header(); - echo "No email traffic log found."; - phpfmg_admin_footer(); - }; - -} - - -function phpfmg_log_delete(){ - $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; - $files = array( - 1 => PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - phpfmg_admin_header(); - - $file = $files[$n]; - if( is_file($file) ){ - echo unlink($file) ? "It has been deleted!" : "Failed to delete!" ; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_util_download($file, $filename='', $toCSV = false, $skipN = 0 ){ - if (!is_file($file)) return false ; - - set_time_limit(0); - - - $buffer = ""; - $i = 0 ; - $fp = @fopen($file, 'rb'); - while( !feof($fp)) { - $i ++ ; - $line = fgets($fp); - if($i > $skipN){ // skip lines - if( $toCSV ){ - $line = str_replace( chr(0x09), ',', $line ); - $buffer .= phpfmg_data2record( $line, false ); - }else{ - $buffer .= $line; - }; - }; - }; - fclose ($fp); - - - - /* - If the Content-Length is NOT THE SAME SIZE as the real conent output, Windows+IIS might be hung!! - */ - $len = strlen($buffer); - $filename = basename( '' == $filename ? $file : $filename ); - $file_extension = strtolower(substr(strrchr($filename,"."),1)); - - switch( $file_extension ) { - case "pdf": $ctype="application/pdf"; break; - case "exe": $ctype="application/octet-stream"; break; - case "zip": $ctype="application/zip"; break; - case "doc": $ctype="application/msword"; break; - case "xls": $ctype="application/vnd.ms-excel"; break; - case "ppt": $ctype="application/vnd.ms-powerpoint"; break; - case "gif": $ctype="image/gif"; break; - case "png": $ctype="image/png"; break; - case "jpeg": - case "jpg": $ctype="image/jpg"; break; - case "mp3": $ctype="audio/mpeg"; break; - case "wav": $ctype="audio/x-wav"; break; - case "mpeg": - case "mpg": - case "mpe": $ctype="video/mpeg"; break; - case "mov": $ctype="video/quicktime"; break; - case "avi": $ctype="video/x-msvideo"; break; - //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files) - case "php": - case "htm": - case "html": - $ctype="text/plain"; break; - default: - $ctype="application/x-download"; - } - - - //Begin writing headers - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - //Use the switch-generated Content-Type - header("Content-Type: $ctype"); - //Force the download - header("Content-Disposition: attachment; filename=".$filename.";" ); - header("Content-Transfer-Encoding: binary"); - header("Content-Length: ".$len); - - while (@ob_end_clean()); // no output buffering ! - flush(); - echo $buffer ; - - return true; - - -} -?> diff --git a/abuse.lib.php b/abuse.lib.php deleted file mode 100644 index f7427eb..0000000 --- a/abuse.lib.php +++ /dev/null @@ -1,3377 +0,0 @@ -unauthorized domain." ); - -define( 'PHPFMG_ONE_ENTRY' , '' ); -define( 'PHPFMG_ONE_ENTRY_METHOD' , '' ); - -phpfmg_init(); -# ----------------------------------------------------------------------------- - - - - - - - - - -function phpfmg_thankyou(){ - phpfmg_redirect_js(); -?> - - -
- - Your form has been sent. Thank you! -

- - - - - - "field_0", "text" => "Contact Name:", "type" => "sender's name", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_1'] = array( "name" => "field_1", "text" => "Email Address:", "type" => "sender's email", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_2'] = array( "name" => "field_2", "text" => "Subject:", "type" => "text", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_3'] = array( "name" => "field_3", "text" => "Message:", "type" => "textarea", "instruction" => "", "required" => "Required" ) ; - - -/** - * GNU Library or Lesser General Public License version 2.0 (LGPLv2) -*/ - -function phpfmg_init(){ - - error_reporting( E_ERROR ); - ini_set('magic_quotes_runtime', 0); - ini_set( 'max_execution_time', 0 ); - ini_set( 'max_input_time', 36000 ); - - session_start(); - - if( !isset($_SESSION['HTTP_REFERER']) ) - $_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'] ; - phpfmg_check_referers(); - - if ( get_magic_quotes_gpc() && isset($_POST) ) { - phpfmg_stripslashes( $_POST ); - }; - -} - - -function phpfmg_stripslashes(&$var){ - if(!is_array($var)) { - $var = stripslashes($var); - } else { - array_walk($var,'phpfmg_stripslashes'); - }; -} - - -function phpfmg_display_form( $title="", $keywords="", $description="" ){ - @header( 'Content-Type: text/html; charset=' . PHPFMG_CHARSET ); - $phpfmg_send = phpfmg_sendmail( $GLOBALS['form_mail'] ) ; - $isHideForm = isset($phpfmg_send['isHideForm']) ? $phpfmg_send['isHideForm'] : false; - $sErr = isset($phpfmg_send['error']) ? $phpfmg_send['error'] : ''; - - # FormMail main() - phpfmg_header( $title, $keywords, $description ); - if( !$isHideForm ){ - phpfmg_form($sErr); - }else{ - phpfmg_thankyou(); - }; - phpfmg_footer(); - - return; -} - -function phpfmg_linebreak(){ - $os = strtolower(PHP_OS); - switch( true ){ - case ("\\" == DIRECTORY_SEPARATOR) : // windows - return "\x0d\x0a" ; - case ( strpos($os, 'darwin') !== false ) : // Mac - return "\x0d" ; - default : - return "\x0a" ; // *nix - }; -} - -function phpfmg_sendmail( &$form_mail ) { - if( !isset($_POST["formmail_submit"]) ) return ; - - $isHideForm = false ; - $sErr = checkPass($form_mail); - - $err_captcha = phpfmg_check_captcha(); - if( $err_captcha != '' ){ - $sErr['fields'][] = 'phpfmg_captcha'; - $sErr['errors'][] = ERR_CAPTCHA; - }; - - if( empty($sErr['fields']) && phpfmg_has_entry() ){ - $sErr['fields'][] = 'phpfmg_found_entry'; - $sErr['errors'][] = 'Found entry already!'; - }; - if( empty($sErr['fields']) ){ - - sendFormMail( $form_mail, PHPFMG_SAVE_FILE ) ; - $isHideForm = true; - // move the redirect to phpfmg_thankyou() to get around the redirection within an iframe problem - /* - $redirect = PHPFMG_REDIRECT; - if( strlen(trim($redirect)) ): - header( "Location: $redirect" ); - exit; - endif; - */ - }; - - return array( - 'isHideForm' => $isHideForm, - 'error' => $sErr , - ); -} - - -function phpfmg_has_entry(){ - if( !file_exists(PHPFMG_SAVE_FILE) ){ - return false; // has nothing to check - }; - - $found = false ; - if( defined('PHPFMG_ONE_ENTRY') && 'Y' == PHPFMG_ONE_ENTRY ){ - $query = defined('PHPFMG_ONE_ENTRY_METHOD') && PHPFMG_ONE_ENTRY_METHOD == 'email' && isset($GLOBALS['sender_email']) ? $GLOBALS['sender_email'] : $_SERVER['REMOTE_ADDR'] ; - if( empty($query) ) - return false ; - - $GLOBALS['OneEntry'] = $query; - $query = '"'. strtolower($query) . '"'; - $handle = fopen(PHPFMG_SAVE_FILE,'r'); - if ($handle) { - while (!feof($handle)) { - $entry = strtolower(fgets($handle, 4096)); - if( strpos($entry,$query) !== false ){ - $found = true ; - break; - }; - }; - fclose($handle); - }; - }; - return $found ; - -} - -function sendFormMail( $form_mail, $sFileName = "" ) -{ - $to = filterEmail(PHPFMG_TO) ; - $cc = filterEmail(PHPFMG_CC) ; - $bcc = filterEmail(PHPFMG_BCC) ; - - // simply chop email address to avoid my website being abused - if( false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com') ){ - $cc = substr($cc, 0, 50); - $bcc = substr($bcc,0, 50); - }; - - - $subject = PHPFMG_SUBJECT ; - $from = $to ; - $fromName = ""; - $titleOfSender = ''; - $firstName = ""; - $lastName = ""; - - $strip = get_magic_quotes_gpc() ; - $content = '' ; - $style = 'font-family:Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color:#474747;padding:6px;border-bottom:1px solid #cccccc;' ; - $tr = array() ; // html table - $csvValues = array(); - $cols = array(); - $replace = array(); - $RecordID = phpfmg_getRecordID(); - $isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) ); - - foreach( $form_mail as $field ){ - $field_type = strtolower($field[ "type" ]); - if( 'sectionbreak' == $field_type ){ - continue; - }; - - $field[ "text" ] = stripslashes( $field[ "text" ] ); - //$value = trim( $_POST[ $field[ "name" ] ] ); - $value = phpfmg_field_value( $field[ "name" ] ); - $value = $strip ? stripslashes($value) : $value ; - if( 'attachment' == $field_type ){ - $value = $isWritable ? phpfmg_file2value( $RecordID, $_FILES[ $field[ "name" ] ] ) : $_FILES[ $field[ "name" ] ]['name']; - //$value = $_FILES[ $field[ "name" ] ]['name']; - }; - - $content .= $field[ "text" ] . " \t : " . $value .PHPFMG_LNCR; - $tr[] = " " . $field[ "text" ] . "  " . nl2br($value) . " " ; - $csvValues[] = csvfield( $value ); - $cols[] = csvfield( $field[ "text" ] ); - $replace["%".$field[ "name" ]."%"] = $value; - - switch( $field_type ){ - case "sender's email" : - $from = filterEmail($value) ; - break; - case "sender's name" : - $fromName = filterEmail($value) ; - break; - case "titleofsender" : - $titleOfSender = $value ; - break; - case "senderfirstname" : - $firstName = filterEmail($value) ; - break; - case "senderlastname" : - $lastName = filterEmail($value) ; - break; - default : - // nothing - }; - - }; // for - - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - - if( $isHtml ) { - $content = "" . PHPFMG_LNCR . join( PHPFMG_LNCR, $tr ) . PHPFMG_LNCR . "
" ; - }; - - - if( !empty($firstName) && !empty($lastName) ){ - $fromName = $firstName . ' ' . $lastName; - }; - $fromHeader = filterEmail( ('' != $fromName ? "\"$fromName\"" : '' ) . " <{$from}>",array(",", ";")) ; // no multiple emails are allowed. - $GLOBALS['ReplyTo'] = $fromHeader; - - $_fields = array( - '%NameOfSender%' => $fromName, - '%FirstNameOfSender%' => $firstName, - '%LastNameOfSender%' => $lastName, - '%EmailOfSender%' => $from, - '%TitleOfSender%' => $titleOfSender, - '%DataOfForm%' => $content, - '%IP%' => $_SERVER['REMOTE_ADDR'], - '%Date%' => date("Y-m-d"), - '%Time%' => date("H:i:s"), - '%HTTP_HOST%' => $_SERVER['HTTP_HOST'], - '%FormPageLink%' => phpfmg_request_uri(), - '%HTTP_REFERER%' => $_SESSION['HTTP_REFERER'], - '%AutoID%' => $RecordID, - '%FormAdminURL%' => phpfmg_admin_url() - ); - $fields = array_merge( $_fields, $replace ); - - $esh_mail_template = trim(phpfmg_mail_template()); - if( !empty($esh_mail_template) ){ - $esh_mail_template = phpfmg_adjust_template($esh_mail_template); - $content = phpfmg_parse_mail_body( $esh_mail_template, $fields ); - }; - $subject = phpfmg_parse_mail_body( $subject, $fields ); - - if( $isHtml ) { - $content = phpfmg_getHtmlContent( $content ); - }; - - $oldMask = umask(0); - //$sep = ','; //chr(0x09); - $sep = chr(0x09); - $recordCols = phpfmg_data2record( csvfield('RecordID') . $sep . csvfield('Date') . $sep . csvfield('IP') . $sep . join($sep,$cols) ); - $record = phpfmg_data2record( csvfield($RecordID) . $sep . csvfield(date("Y-m-d H:i:s")) . $sep . csvfield($_SERVER['REMOTE_ADDR']) .$sep . join($sep,$csvValues) ); - - - /* - Some hosting companies (like Yahoo and GoDaddy) REQUIRED a registered email address to send out all emails! - The mailer HAS to use the REGISTERED email address as the sender's email address. This is called the sendmail_from. - */ - $sendmail_from = $from; - $sender_email = $from; - $force_sender = defined('PHPFMG_SENDMAIL_FROM') && '' != PHPFMG_SENDMAIL_FROM ; - if( $force_sender ){ - ini_set("sendmail_from", PHPFMG_SENDMAIL_FROM); - $sendmail_from = PHPFMG_SENDMAIL_FROM; - }; - if( defined('PHPFMG_SMTP') && '' != PHPFMG_SMTP ){ - ini_set("SMTP", PHPFMG_SMTP); - }; - - - - switch( strtolower(PHPFMG_ACTION) ){ - case 'fileonly' : - appendToFile( $sFileName, $record, $recordCols ); - break; - case 'mailonly' : - mailAttachments( $to , $subject , $content, $sendmail_from, $fromName, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ; - break; - case 'mailandfile' : - default: - mailAttachments( $to , $subject , $content, $sendmail_from, $fromName, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ; - appendToFile( $sFileName, $record, $recordCols ); - }; // switch - - mailAutoResponse( $sender_email, $force_sender ? $sendmail_from : $to, $fields ) ; - umask($oldMask); - - session_destroy(); - session_regenerate_id(true); -} - - - - - -function phpfmg_file2value( $recordID, $file ){ - $tmp = $file[ "tmp_name" ] ; - $name = phpfmg_rename_harmful(trim($file[ "name" ])) ; - if( !defined('PHPFMG_FILE2LINK_SIZE') ){ - return $name; - }; - - if( is_uploaded_file( $tmp ) ) { - $size = trim(PHPFMG_FILE2LINK_SIZE) ; - switch( $size ){ - case '' : - return $name; - default: - $isHtml = 'html' == PHPFMG_MAIL_TYPE; - $filelink = base64_encode($recordID . '-' . $name); - $url = phpfmg_admin_url() . "?mod=filman&func=download&filelink=" . urlencode($filelink) ; - $isLarger = (filesize($tmp)/1024) > $size ; - $link = $isHtml ? "$name" : $name . " ( {$url} )"; - return $isLarger ? $link : $name ; // email download link when size is larger defined size, otherwise send as attachment - };// switch - }; // if - - return $name; -} - - -function phpfmg_dir2unix( $dir ){ - return str_replace( array("\\", '//'), '/', $dir ); -} - - - -function phpfmg_request_uri(){ - $uri = getEnv('REQUEST_URI'); // apache has this - if( false !== $uri && strlen($uri) > 0 ){ - return $uri ; - } else { - - $uri = ($uri = getEnv('SCRIPT_NAME')) !== false - ? $uri - : getEnv('PATH_INFO') ; - $qs = getEnv('QUERY_STRING'); // IIS and Apache has this - return $uri . ( empty($qs) ? '' : '?' . $qs ); - - }; - return "" ; -} - - - - -// parse full admin url to view large size uploaded file online -function phpfmg_admin_url(){ - $http_host = "http://{$_SERVER['HTTP_HOST']}"; - switch( true ){ - case (0 === strpos(PHPFMG_ADMIN_URL, 'http://' )) : - $url = PHPFMG_ADMIN_URL; - break; - case ( '/' == substr(PHPFMG_ADMIN_URL,0,1) ) : - $url = $http_host . PHPFMG_ADMIN_URL ; - break; - default: - $uri = phpfmg_request_uri(); - $pos = strrpos( $uri, '/' ); - $vdir = substr( $uri, 0, $pos ); - $url = $http_host . $vdir . '/' . PHPFMG_ADMIN_URL ; - }; - return $url; -} - - - -function phpfmg_ispost(){ - return 'POST' == strtoupper($_SERVER["REQUEST_METHOD"]) || 'POST' == strtoupper(getEnv('REQUEST_METHOD')) ; -} - - -function phpfmg_is_mysite(){ - return false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com'); // accessing form at mysite -} - -// don't allow hotlink form to my website. To avoid people create phishing form. -function phpfmg_hotlinking_mysite(){ - $yes = phpfmg_is_mysite() - && ( empty($_SERVER['HTTP_REFERER']) || false === strpos( strtolower($_SERVER['HTTP_REFERER']),'formmail-maker.com') ) ; // doesn't have referer of mysite - - if( $yes ){ - die( "Access Denied. -

- You are visiting a form hotlinkink from formmail-maker.com which is not allowed. - Please read the FAQ. - " ); - }; -} - - - -function phpfmg_check_referers(){ - - phpfmg_hotlinking_mysite(); // anti phishing - - $debugs = array(); - $debugs[] = "Your IP: " . $_SERVER['REMOTE_ADDR']; - $debugs[] = "Referer link: " . $_SERVER['HTTP_REFERER']; - $debugs[] = "Host of referer: $referer"; - - $check = defined('PHPFMG_ANTI_HOTLINKING') && 'Y' == PHPFMG_ANTI_HOTLINKING; - if( !$check ) { - $debugs[] = "Referer is empty. No need to check hot linking."; - //echo "
" . join("\n",$debugs) . "
\n"; - //appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ; - return true; - }; - - // maybe post from local file - if( !isset($_SERVER['HTTP_REFERER']) && phpfmg_ispost() ){ - appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n phpfmg_ispost " . join("\n",$debugs) ) ; - die( PHPFMG_REFERERS_DENIED_MSG ); - }; - - - $url = parse_url($_SERVER['HTTP_REFERER']); - $referer = str_replace( 'www.', '', strtolower($url['host']) ); - if( empty($referer) ) { - return true; - }; - - $hosts = explode(',',PHPFMG_REFERERS_ALLOW); - $http_host = strtolower($_SERVER['HTTP_HOST']); - $referer = $http_host ; - $hosts[] = str_replace('www.', '', $http_host ); - - $debugs[] = "Hosts Allow: " . PHPFMG_REFERERS_ALLOW; - - $allow = false ; - foreach( $hosts as $host ){ - $host = strtolower(trim($host)); - $debugs[] = "check host: $host " ; - if( false !== strpos($referer, $host) || false !== strpos($referer, 'www.'.$host) ){ - $allow = true; - $debugs[] = " -> allow (quick exit)"; - break; - }else{ - $debugs[] = " -> deny"; - }; - }; - - //echo "
" . join("\n",$debugs) . "
\n"; - //appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ; - - if( !$allow ){ - die( PHPFMG_REFERERS_DENIED_MSG ); - }; -} - - - -function phpfmg_getRecordID(){ - if( !isset($GLOBALS['RecordID']) ){ - $GLOBALS['RecordID'] = date("Ymd") . '-'. substr( md5(uniqid(rand(), true)), 0,4 ); - }; - return $GLOBALS['RecordID']; -} - - - -function phpfmg_data2record( $s, $b=true ){ - $from = array( "\r", "\n"); - $to = array( "\\r", "\\n" ); - return $b ? str_replace( $from, $to, $s ) : str_replace( $to, $from, $s ) ; -} - - - -function csvfield( $str ){ - $str = str_replace( '"', '""', $str ); - return '"' . trim($str) . '"'; -} - - - -function mailAttachments( $to = "" , $subject = "" , $message = "" , $from="", $fromName = "" , $fromHeader ="", $cc = "" , $bcc = "", $charset = "UTF-8", $type = 'FormMail' ){ - - if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ; - - $isAutoResponse = $type == 'AutoResponseEmail' ; - // added PHPMailer SMTP support at Mar 12, 2011 - $isSMTP = defined('PHPFMG_USE_SMTP') && 'Y' == PHPFMG_USE_SMTP && defined('PHPFMG_SMTP_HOST') && '' != PHPFMG_SMTP_HOST; - - // due to security issues, in most case, the smtp will fail on my website. It only works on user's own server - // so just disable the smtp here - if( phpfmg_is_mysite() ){ - $isSMTP = false ; - }; - - $attachments = array(); - $noAutoAttachements = $isAutoResponse && defined('PHPFMG_RETURN_NO_ATTACHMENT') && 'Y' == PHPFMG_RETURN_NO_ATTACHMENT ; - $use_phpmailer = defined('PHPFMG_USE_PHPMAILER') && 'Y' == PHPFMG_USE_PHPMAILER ; - - - $boundary = "====_My_PHP_Form_Generator_" . md5( uniqid( srand( time() ) ) ) . "===="; - $content_type = 'html' == PHPFMG_MAIL_TYPE ? "text/html" : "text/plain" ; - - // setup mail header infomation - $headers = 'Y' == PHPFMG_NO_FROM_HEADER ? '' : "From: {$fromHeader}" .PHPFMG_LNCR; - $headers .= "Reply-To: {$GLOBALS['ReplyTo']}" .PHPFMG_LNCR; - if ($cc) $headers .= "CC: $cc".PHPFMG_LNCR; - if ($bcc) $headers .= "BCC: $bcc".PHPFMG_LNCR; - //$headers .= "Content-type: {$content_type}; charset={$charset}" .PHPFMG_LNCR ; - - $plainHeaders = $headers ; // for no attachments header - $plainHeaders .= 'MIME-Version: 1.0' . PHPFMG_LNCR; - $plainHeaders .= "Content-type: {$content_type}; charset={$charset}" ; - - //create mulitipart attachments boundary - $sError = "" ; - $nFound = 0; - - - if( false && isset($GLOBALS['phpfmg_files_content']) && '' != $GLOBALS['phpfmg_files_content'] ){ - - // use previous encoded content - $sEncodeBody = $GLOBALS['phpfmg_files_content'] ; - $nFound = $GLOBALS['phpfmg_nFound'] ; - - }else{ - - $file2link_size = trim(PHPFMG_FILE2LINK_SIZE) ; - $isSave = ('' != $file2link_size || defined('PHPFMG_SAVE_ATTACHMENTS') && 'Y' == PHPFMG_SAVE_ATTACHMENTS); - if( $isSave ){ - if( defined('PHPFMG_SAVE_ATTACHMENTS_DIR') ){ - if( !is_dir(PHPFMG_SAVE_ATTACHMENTS_DIR) ){ - $ok = @mkdir( PHPFMG_SAVE_ATTACHMENTS_DIR, 0777 ); - if( !$ok ) $isSave = false; - }; - }; - }; - - $isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) ); - // parse attachments content - foreach( $_FILES as $aFile ){ - $sFileName = $aFile[ "tmp_name" ] ; - $sFileRealName = phpfmg_rename_harmful($aFile[ "name" ]) ; - if( is_uploaded_file( $sFileName ) ): - - $isSkip = '' != $file2link_size && ( (filesize($sFileName)/1024) > $file2link_size ); - // save uploaded file - if( $isWritable && $isSave ){ - $tofile = PHPFMG_SAVE_ATTACHMENTS_DIR . phpfmg_getRecordID() . '-' . basename($sFileRealName); - if( @copy( $sFileName, $tofile) ) { - $sFileName = $tofile; // to fix problem : in some windows php, the uploaded temp file might not be mailed as attachment - chmod($tofile,0777); - }; - }; - - if( $isSkip ) - continue; // mail file as link - - $attachments[] = array('file' => $sFileName, 'name' => $aFile[ "name" ] ); - - if( !$use_phpmailer && !$isSMTP && ($fp = @fopen( $sFileName, "rb" )) ) : - $sContent = fread( $fp, filesize( $sFileName ) ); - fclose($fp); - $sFName = basename( $sFileRealName ) ; - $sMIME = getMIMEType( $sFName ) ; - - $bPlainText = ( $sMIME == "text/plain" ) ; - if( $bPlainText ) : - $encoding = "" ; - else: - $encoding = "Content-Transfer-Encoding: base64".PHPFMG_LNCR; - $sContent = chunk_split( base64_encode( $sContent ) ); - endif; - - $sEncodeBody .= PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR. - "Content-Type: $sMIME;" . PHPFMG_LNCR. - "\tname=\"$sFName\"" . PHPFMG_LNCR. - $encoding . - "Content-Disposition: attachment;" . PHPFMG_LNCR. - "\tfilename=\"$sFName\"" . PHPFMG_LNCR. PHPFMG_LNCR. - $sContent . PHPFMG_LNCR ; - $nFound ++; - else: - $sError .= "
Failed to open file $sFileName.\n" ; - endif; // if( $fp = fopen( $sFileName, "rb" ) ) : - - else: - $sError .= "
File $sFileName doesn't exist.\n" ; - endif; //if( file_exists( $sFileName ) ): - }; // end foreach - - $sEncodeBody .= PHPFMG_LNCR.PHPFMG_LNCR."--$boundary--" ; - - $GLOBALS['phpfmg_files_content'] = $sEncodeBody ; - $GLOBALS['phpfmg_nFound'] = $nFound ; - - }; // if - - $headers .= "MIME-Version: 1.0".PHPFMG_LNCR."Content-type: multipart/mixed;".PHPFMG_LNCR."\tboundary=\"$boundary\""; - $txtMsg = PHPFMG_LNCR."This is a multi-part message in MIME format." .PHPFMG_LNCR . - PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR . - "Content-Type: {$content_type};".PHPFMG_LNCR. - "\tcharset=\"$charset\"" .PHPFMG_LNCR.PHPFMG_LNCR . - $message . PHPFMG_LNCR; - - - if( $noAutoAttachements ) $sEncodeBody = '' ; - - $body = $nFound ? $txtMsg . $sEncodeBody : $message ; - $headers = $nFound ? $headers : $plainHeaders ; - - - $errmsg = ""; - if( $isSMTP || $use_phpmailer ){ - if( $noAutoAttachements ) $attachments = false ; - $errmsg = phpfmg_phpmailer( $to, $subject, $body, $from, $fromName, $cc , $bcc , $charset, $attachments ); - - }else{ - - if ( !mail( $to, $subject, $body, $headers ) ) - $errmsg = "Failed to send mail"; - }; - - $ok = $errmsg == "" ; - $status = $ok ? "\n[Email sent]" : "\n[{$errmsg}]" ; - phpfmg_log_mail( $to, $subject, ($ok ? 'Email sent' : 'Failed to send mail') . "\n" . ($nFound ? $headers . $txtMsg : $headers . $message), '', $type . $status ); // no log for attachments - - return $sError ; -} - - -function phpfmg_phpmailer( $to, $subject, $message, $from, $fromName, $cc = "" , $bcc = "", $charset = "UTF-8",$attachments = false ){ - - $mail = new PHPMailer(); - $mail->Host = PHPFMG_SMTP_HOST; // SMTP server - $mail->Username = PHPFMG_SMTP_USER; - $mail->Password = PHPFMG_SMTP_PLAIN_PASSWORD != '' ? PHPFMG_SMTP_PLAIN_PASSWORD : base64_decode(PHPFMG_SMTP_PASSWORD); - $mail->SMTPAuth = PHPFMG_SMTP_PASSWORD != ""; - $mail->SMTPSecure = PHPFMG_SMTP_SECURE; - $mail->Port = PHPFMG_SMTP_PORT == "" ? 25 : PHPFMG_SMTP_PORT; - if( defined('PHPFMG_SMTP_DEBUG_LEVEL') && PHPFMG_SMTP_DEBUG_LEVEL != "" ){ - $mail->SMTPDebug = (int)PHPFMG_SMTP_DEBUG_LEVEL ; - }; - - if( isset($GLOBALS['ReplyTo']) ) $mail->AddReplyTo($GLOBALS['ReplyTo']); - $mail->From = $from; - $mail->FromName = $fromName; - $mail->Subject = $subject; - $mail->Body = $message; - $mail->CharSet = $charset; - - if( !phpfmg_is_mysite() && (defined('PHPFMG_USE_SMTP') && 'Y' == PHPFMG_USE_SMTP) ){ - $mail->IsSMTP(); - }; - - $mail->IsHTML('html' == PHPFMG_MAIL_TYPE); - - $mail->AddAddress($to); - - if( ''!= $cc ){ - $CCs = explode(',',$cc); - foreach($CCs as $c){ - $mail->AddCC( $c ); - }; - }; - - if( ''!= $bcc ){ - $BCCs = explode(',',$bcc); - foreach($BCCs as $b){ - $mail->AddBCC( $b ); - }; - }; - - - if( is_array($attachments) ){ - foreach($attachments as $f){ - $mail->AddAttachment( $f['file'], basename($f['name']) ); - }; - }; - - return $mail->Send() ? "" : $mail->ErrorInfo; - -} - - - -function mailAutoResponse( $to, $from, $fields = false ){ - if( !formIsEMail($to) ) return ERR_EMAIL ; // one more check for spam robot - $enable = defined('PHPFMG_RETURN_ENABLE') && PHPFMG_RETURN_ENABLE === 'Y'; - $body = trim(phpfmg_auto_response_message()); - if( !$enable || empty($body) ){ - return false ; - }; - - $subject = PHPFMG_RETURN_SUBJECT; - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - $body = phpfmg_adjust_template($body); - $body = phpfmg_parse_mail_body($body,$fields); - $subject = phpfmg_parse_mail_body( $subject, $fields ); - if( $isHtml ) { - $body = phpfmg_getHtmlContent( $body ); - }; - $body = str_replace( "0x0d", '', $body ); - $body = str_replace( "0x0a", PHPFMG_LNCR, $body ); - - if( defined('PHPFMG_RETURN_EMAIL') && formIsEMail(PHPFMG_RETURN_EMAIL) ){ - $from = PHPFMG_RETURN_EMAIL; - }; - $fromHeader = ( PHPFMG_YOUR_NAME == "" ? "" : "\"".PHPFMG_YOUR_NAME . "\"" ) . " <{$from}>"; - return mailAttachments( $to , $subject , $body, filterEmail($from), PHPFMG_YOUR_NAME, $fromHeader, '' , '', PHPFMG_CHARSET, 'AutoResponseEmail' ); - -} - - -function phpfmg_log_mail( $to='', $subject='', $body='', $headers = '', $type='' ){ - $sep = PHPFMG_LNCR . str_repeat('----',20) . PHPFMG_LNCR ; - appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$type}" . $sep . "To: {$to}\r\nSubject: {$subject}\r\n" . $headers . $body . "
" . PHPFMG_LNCR . $sep . PHPFMG_LNCR ) ; -} - - - -function phpfmg_getHtmlContent( $body ){ - $html = "Your Form Mail Content | htttp://phpfmg.sourceforge.net" - . $body .""; - return $html ; -} - - - -function phpfmg_adjust_template( $body ){ - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - if( $isHtml ){ - $body = preg_match( "/<[^<>]+>/", $body ) ? $body : nl2br($body); - }; - return $body; -} - - - -function phpfmg_parse_mail_body( $body, $fields = false ){ - if( !is_array($fields) ) - return $body ; - - $yes = function_exists( 'str_ireplace' ); - foreach( $fields as $name => $value ){ - $body = $yes ? str_ireplace( $name, $value ,$body ) - : str_replace ( $name, $value ,$body ); - }; - return trim($body); -} - - - -# filter line breaks to avoid emails injecting -function filterEmail($email, $chars = ''){ - $email = trim(str_replace( array("\r","\n"), '', $email )); - if( is_array($chars) ) $email = str_replace( $chars, '', $email ); - $email = preg_replace( '/(cc\s*\:|bcc\s*\:)/i', '', $email ); - return $email; -} - - - -function mailReport( $content = "", $file = '' ){ - $content = " -Dear Sir or Madam, - -Your online form at " . HOST_NAME . PHP_SELF . " failed to save data to file. Please make sure the web user has permission to write to file \"{$file}\". If you don't know how to fix it, please forward this email to technical support team of your web hosting company or your Administrator. - -PHPFMG -- PHP FormMail Generator -"; - mail(PHPFMG_TO, "Error@" . HOST_NAME . PHP_SELF, $content ); -} - - - -function remove_newline( $str = "" ){ - return str_replace( array("\r\n", "\r", "\n"), array('\r\n', '\r', '\n'), $str ); -} - - - -function checkPass( $form_mail = array() ) -{ - - $names = array(); - $labels = array(); - - foreach( $form_mail as $field ){ - $type = strtolower( $field[ "type" ] ); - //$value = trim( $_POST[ $field[ "name" ] ] ); - $value = phpfmg_field_value( $field[ "name" ] ); - $required = strtolower($field[ "required" ]) ; - $text = stripslashes( $field[ "text" ] ); - - // simple check the field has something keyed in. - if( !strlen($value) && ( $required == "required" ) && $type != "attachment" ){ - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_MISSING . $text ; - continue; - }; - - // verify the special case - if( - ( strlen($value) || $type == "attachment" ) - && $required == "required" - ): - - switch( $type ){ - case strtolower("Sender's Name") : - break; - case strtolower("Generic email"): - case strtolower("Sender's email"): - if( ! formIsEMail($value) ) { - $names[] = $field[ "name" ]; - $labels[] = $text . ERR_EMAIL; - //return ERR_EMAIL . $text ; - }; - // for checking entry limitation - if( $type == "sender's email" ){ - $GLOBALS['sender_email'] = $value; - }; - break; - case "text" : - break; - case "textarea" : - break; - case "checkbox" : - case "radio" : - break; - case "select" : - break; - case "attachment" : - $upload_file = $_FILES[ $field["name"] ][ "tmp_name" ] ; - if( ! is_uploaded_file($upload_file) ){ - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_SELECT_UPLOAD . $text; - }; - break; - case strtolower("Date(MM-DD-YYYY)"): - break; - case strtolower("Date(MM-YYYY)"): - break; - case strtolower("CreditCard(MM-YYYY)"): - if( $value < date("Y-m") ) { - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_CREDIT_CARD_EXPIRED . $text; - }; - break; - case strtolower("CreditCard#"): - if( !formIsCreditNumber( $value ) ) { - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_CREDIT_CARD_NUMBER . $text ; - }; - break; - case strtolower("Time(HH:MM:SS)"): - break; - case strtolower("Time(HH:MM)"): - break; - default : - //return $sErrRequired . $form_mail[ $i ][ "text" ]; - }; // switch - endif; - }; // for - - return array( - 'fields' => $names, - 'errors' => $labels, - ); -} - - - -function formSelected( $var, $val ) -{ - echo ( $var == $val ) ? "selected" : ""; -} - - - -function formChecked( $var, $val ) -{ - echo ( $var == $val ) ? "checked" : ""; -} - - - -function formIsEMail( $email ){ - return preg_match( "/^(.+)@(.+)\\.(.+)$/", $email ); -} - - - -function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" ) -{ - $tab = "\t" ; - print "\n\n" ; -} - - - -# something like CreditCard.pm in perl CPAN -function formIsCreditNumber( $number ) { - - $tmp = $number; - $number = preg_replace( "/[^0-9]/", "", $tmp ); - - if ( preg_match( "/[^\d\s]/", $number ) ) return 0; - if ( strlen($number) < 13 && 0+$number ) return 0; - - for ($i = 0; $i < strlen($number) - 1; $i++) { - $weight = substr($number, -1 * ($i + 2), 1) * (2 - ($i % 2)); - $sum += (($weight < 10) ? $weight : ($weight - 9)); - } - - if ( substr($number, -1) == (10 - $sum % 10) % 10 ) return $number; - return $number; -} - - -/* --------------------------------------------------------------------------------------------------- - Parameters: $sFileName - Return : - 1. "" : no extendsion name, or sFileName is empty - 2. string: MIME Type name of array aMimeType's definition. - ---------------------------------------------------------------------------------------------------*/ -function getMIMEType( $sFileName = "" ) { - $sFileName = strtolower( trim( $sFileName ) ); - if( ! strlen( $sFileName ) ) return ""; - - $aMimeType = array( - "txt" => "text/plain" , - "pdf" => "application/pdf" , - "zip" => "application/x-compressed" , - - "html" => "text/html" , - "htm" => "text/html" , - - "avi" => "video/avi" , - "mpg" => "video/mpeg " , - "wav" => "audio/wav" , - - "jpg" => "image/jpeg " , - "gif" => "image/gif" , - "tif" => "image/tiff " , - "png" => "image/x-png" , - "bmp" => "image/bmp" - ); - $aFile = explode( "\.", basename( $sFileName ) ) ; - $nDiminson = count( $aFile ) ; - $sExt = $aFile[ $nDiminson - 1 ] ; // get last part: like ".tar.zip", return "zip" - - return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : ""; -} - - - -function appendToFile( $sFileName = "", $line = "", $dataColumnsLine = '' ){ - $obey = defined('PHPFMG_GDPR') && 'Y' == PHPFMG_GDPR; // obey General Data Protection Regulation (GDPR)? - if( $obey ) return 0; - - if( !$sFileName || !$line ) return 0; - - $isExists = file_exists( $sFileName ); - $hFile = @fopen( "$sFileName", "a+w" ); - $nBytes = 0; - if( $hFile ){ - if( !$isExists && false !== strpos(strtolower(basename($sFileName)), '.php') ){ - fputs( $hFile, "\r\n"); - if( !empty($dataColumnsLine) ){ - fputs($hFile,$dataColumnsLine."\r\n"); - }; - }; - $nBytes = fputs( $hFile , trim($line)."\r\n" ); - fclose( $hFile ); - }; - return $nBytes ; -} - -function phpfmg_get_csv_header(){ - $csvValues = array(); - foreach( $GLOBALS['form_mail'] as $field ){ - $csvValues[] = csvfield( $field[ "text" ] ); - }; - return join(chr(0x09),/*","*/$csvValues) ; -} - -/* -function phpfmg_field_instruction($name, $show = true ){ - global $form_mail, $sErr; - $isError = in_array($name,$sErr['fields']); - $class = $isError ? 'instruction_error' : 'instruction' ; - if( $show || $isError ) echo "
". htmlspecialchars_decode($form_mail[ $name ]['instruction']) . "
"; -} -*/ - -function phpfmg_rand( $len = 4 ){ - $md5 = md5( uniqid(rand()) ); - return $len > 0 ? substr($md5,0,$len) : $md5 ; -} - - - -// use a random name for stopping spam bot bypass the form.php, and post raw data directly -function phpfmg_captcha_name(){ - if( !isset($_SESSION['captcha_name']) ){ - $_SESSION['captcha_name'] = phpfmg_rand(8); //PHPFMG_ID.'fmgCaptchCode'; - }; - return $_SESSION['captcha_name']; -} - - -function phpfmg_check_recaptcha(){ - $errmsg = ERR_CAPTCHA; - if( isset($_POST['g-recaptcha-response']) ){ - $get = 'https://www.google.com/recaptcha/api/siteverify?secret=' . phpfmg_reCAPTCHA_key('secret_key'). '&response=' . $_POST['g-recaptcha-response']; - $response = file_get_contents($get); - echo $response; - $success = false; - if( function_exists('json_decode') ){ - $json = json_decode( $response, true ); - var_dump($json); - $success = $json['success'] === true; - }else{ - $success = preg_match( '/success[\"\']*\\:\\s*(true|1|y)/i', $response ); - }; - return $success ? '' : $errmsg; - } - return $errmsg; -} - -function phpfmg_check_captcha(){ - $errmsg = ''; - if( phpfmg_is_reCAPTCHA() ){ - $errmsg = phpfmg_check_recaptcha(); - }else{ - - $name = phpfmg_captcha_name(); - if( (defined('PHPFMG_SIMPLE_CAPTCHA_NAME') && PHPFMG_SIMPLE_CAPTCHA_NAME != '') && - ( !isset( $_POST[$name] ) || // maybe sutmited by spam bot - strtoupper($_POST[$name]) != strtoupper($_SESSION[$name]) // or user didn't type correct code - ) - ){ - $errmsg = ERR_CAPTCHA ; - }; - - }; - - return $errmsg ; -} - -function phpfmg_reCAPTCHA_key( $type ){ - $isSitekey = $type == 'site_key'; - // this keys are for formmail-maker.com domain only - $phpfmgSiteKey = '6LcQuv8SAAAAAKSvNHfF5gQuW9WIpcualeEYllCn'; - $phpfmgSecretKey = '6LcQuv8SAAAAABczBmLx85TQfdlkeMkjhz4Hzv5D'; - if( $isSitekey ){ - return phpfmg_is_mysite() ? $phpfmgSiteKey : RECAP_SITE_KEY; - }else{ - return phpfmg_is_mysite() ? $phpfmgSecretKey : RECAP_SECRET_KEY; - } - -} - - -function phpfmg_is_reCAPTCHA(){ - return (defined('RECAP_SITE_KEY') && '' != RECAP_SITE_KEY && defined('RECAP_SECRET_KEY') && '' != RECAP_SECRET_KEY) || (phpfmg_is_mysite() && defined('RECAP_SITE_KEY') ) ; -} - -function phpfmg_get_reCAPTCHA_html(){ - return - " -
"; - -} - -function phpfmg_show_captcha(){ - if( phpfmg_is_reCAPTCHA() ){ - echo phpfmg_get_reCAPTCHA_html(); - return ; - }; - $url = PHPFMG_ADMIN_URL . '?mod=captcha&func=get&tid=' ; - $onclick= "onclick=\"document.getElementById('phpfmg_captcha_image').src='{$url}'+Math.random();return false;\" " ; - echo "\"Click\n"; - echo "Reload Verification Image
\n"; - echo "\n"; -} - - - -function phpfmg_hsc($field, $default = false){ - echo isset($_POST[ $field ]) - ? HtmlSpecialChars( $_POST[ $field ] ) - : $default; -} - -function phpfmg_dropdown( $name, $options, $showInputbox = false, $isMultiple = false, $extra = '', $isReturn = false, $class = 'text_select' ){ - //$showInputbox = true; - $displayLast = 'none' ; - $onchange = $showInputbox ? " onchange=\"toggleOtherInputBox('{$name}','select','{$name}');\" " : "" ; - $sMultiple = $isMultiple ? 'multiple="multiple"' : '' ; - $other = "{$name}_other" ; - - $dropdown = array(); - $list = explode( '|', $options ); - $dropdown[] = "\n"; - - if( $showInputbox ){ - $dropdown[] = "" ; - $dropdown[] = "
" ; - }; - - $s = join("\t\n",$dropdown); - - if( $isReturn ) - return $s; - else - echo $s ; -} - - -function phpfmg_date_dropdown( $cfgDate, $showSep = true ){ - $sep = $showSep ? $cfgDate['separator'] . " " : ""; - $field_name = $cfgDate['field_name']; - if( !isset($cfgDate['yyyy']) ){ - $startYear = $cfgDate['startYear']; - $endYear = $cfgDate['endYear']; - $year = range( $startYear, $endYear ); - $cfgDate['yyyy'] = $cfgDate['yearPrompt'] . '=,|' . join("|",$year); - }; - - switch( $cfgDate['format'] ){ - case 'mm/dd/yyyy' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'dd/mm/yyyy' : - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'yyyy/mm/dd' : - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - break; - case 'mm/yyyy' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'yyyy/mm' : - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - break; - case 'mm/dd' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - break; - case 'dd/mm' : - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - break; - }; - echo "\n\n"; - echo "\n"; - -} - - -function phpfmg_date_dropdown_require( $field_name ){ - if( !isset($_POST) ) - return ; - - $month = $_POST[$field_name.'_month']; - $day = $_POST[$field_name.'_day']; - $yyyy = $_POST[$field_name.'_yyyy']; - $format = $_POST[$field_name.'_format']; - $sep = isset($_POST[$field_name.'_separator']) ? $_POST[$field_name.'_separator'] : '/'; - - // make up $_POST[$field_name] value - $_POST[$field_name] = ''; - switch( $format ){ - case 'mm/dd/yyyy' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $day . $sep . $yyyy; - break; - case 'dd/mm/yyyy' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $day . $sep . $month . $sep . $yyyy; - break; - case 'yyyy/mm/dd' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $yyyy . $sep . $month . $sep . $day; - break; - case 'mm/yyyy' : - if( !empty($month) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $yyyy; - break; - case 'yyyy/mm' : - if( !empty($month) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $yyyy; - break; - case 'mm/dd' : - if( !empty($month) && !empty($day) ) - $_POST[$field_name] = $month . $sep . $day; - break; - case 'dd/mm' : - if( !empty($month) && !empty($day) ) - $_POST[$field_name] = $day . $sep . $month; - break; - }; - -} - -function phpfmg_time_dropdown( $cfgTime ){ - $field_name = $cfgTime['field_name']; - $sep =": "; - switch( $cfgTime['hourOpt'] ){ - case 'h12' : - phpfmg_dropdown( $field_name.'_hour', $cfgTime['hour'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_minute', $cfgTime['minute'], false, false, '', false, '' ); - phpfmg_dropdown( $field_name.'_amfm', $cfgTime['amfm'], false, false, '', false, '' ); - break; - case 'h24' : - phpfmg_dropdown( $field_name.'_hour', $cfgTime['hour'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_minute', $cfgTime['minute'], false, false, '', false, '' ); - break; - }; - echo "\n\n"; -} - - -function phpfmg_time_dropdown_require( $field_name ){ - if( !isset($_POST) ) - return ; - - $hour = $_POST[$field_name.'_hour']; - $minute = $_POST[$field_name.'_minute']; - $amfm = $_POST[$field_name.'_amfm']; - $format = $_POST[$field_name.'_format']; - $sep = ':'; - - // make up $_POST[$field_name] value - $_POST[$field_name] = ""; - switch( $format ){ - case 'h12' : - if( !empty($hour) && !empty($minute) && !empty($amfm) ) - $_POST[$field_name] = $hour . $sep . $minute . ' ' . $amfm; - break; - case 'h24' : - if( !empty($hour) && !empty($minute) ) - $_POST[$field_name] = $hour . $sep . $minute; - break; - }; - -} - - - -function phpfmg_dependent_dropdown( $field_name ){ - $field = phpfmg_dependent_dropdown_get_field( $field_name ); - $dd = new DependantDropdown(); - $dd->parseFmgField($field); - $html = $dd->getHtml(); - echo $html; -} - -function phpfmg_dependent_dropdown_dynamic_require( $field_name ){ - $field = phpfmg_dependent_dropdown_get_field( $field_name ); - $dd = new DependantDropdown(); - $dd->parseFmgField($field); - $dd->dynamicRequired(); -} - -function phpfmg_dependent_dropdown_get_field( $field_name ){ - if( !isset($_SESSION[PHPFMG_ID]) ){ - $_SESSION[PHPFMG_ID] = array(); - }; - if( !isset($_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name]) ){ - $base64 = phpfmg_dependent_dropdown_data(); - $data = @unserialize( base64_decode($base64) ); - $_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name] = $data; - }else{ - $data = $_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name]; - }; - - if( !is_array($data) ){ - return ; - }; - - foreach( $data as $field ){ - if( $field['name'] == $field_name ){ - return $field; - }; - }; -} - - -# ------------------------------------------------------ -class DependantDropdown -{ - var $data = ''; - var $sheet = array(); - var $fields = array(); - var $fieldInfo = array( 'label', 'instruction', 'required', 'prompt' ); // describe field information from the first N rows of data - var $prefix = 'dd'; // in case there is no name for dropdown, it will name the dropdown like dd_0, dd_1, ... - - var $fmgField = false; - var $newliner = "" ; // replace \r\n with $newliner ; - var $newtaber = "" ; // replace \t with $newtaber ; - - function __construct(){ - } - - function DependantDropdown(){ - } - - - function lookupFieldColumn( $field, $column, $lookup, $contentType='text/plain', $charset='utf-8' ){ - $this->parseFmgField( $field ); - $this->nocache_headers( $contentType, $charset ); - return join( "\n", $this->getColumn( $column, $lookup ) ); - } - - function parseFmgField( $field ){ - if( !isset($_SESSION[PHPFMG_ID]) ){ - $_SESSION[PHPFMG_ID] = array(); - }; - $this->fmgField = $field; - $value = $this->newline_back($field['value']); - $this->data = explode("\r\n",$value); - if( !isset($_SESSION[PHPFMG_ID][ "DD_".$field['name'] ]) ){ - $this->parseData($field); - $_SESSION[PHPFMG_ID][ "DD_".$field['name'] ] = $this->fields; - }else{ - $this->fields = $_SESSION[PHPFMG_ID][ "DD_".$field['name'] ]; - }; - $this->makeupFieldsName(); - } - - function newline_back( $str = "" ){ - return str_replace( array($this->newtaber, $this->newliner), array("\t","\r\n"), $str ); - } - - function nocache_headers($contentType='text/plain', $charset='utf-8'){ - header("Expires: Mon, 01 Jan 1970 00:00:01 GMT"); - header("Cache-Control: max-age=0, no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); - header( "Content-Type: {$contentType}; charset={$charset}" ); - } - - - function setData( $s ){ - $this->data = $s ; - } - - function setPrefix( $s ){ - $this->prefix = $s; - } - - function parseData(){ - $tab = chr(0x09); - $nFieldInfoRows = count( $this->fieldInfo ); - for( $i = 0, $n = count($this->data); $i < $n; $i ++ ){ - $line = str_replace('"', '', $this->data[$i] ); - //$line = stripslashes( $line ); - $cols = explode( $tab, $line ); - - if( is_array($cols) && count($cols) > 1 ){ - - if( $i < $nFieldInfoRows ){ - $trims = array(); - foreach( $cols as $col ){ - $trims[] = trim($col); - }; - $this->fields[ $this->fieldInfo[$i] ] = $trims; - } - else - $this->fields['data'][] = $cols; - - }; // if - - //if ( $i > 1000 ) break; - }; // for - - } - - // $quickTest : to see whether a column contains data - function getColumn( $n, $lookup = array(), $quickTest = false ){ - $count = count($lookup); - if( $n > 0 && empty($count) ){ - return array(); // can not get column without search query - }; - - $col = array(); - $lastValue = $lookup[ $count - 1 ]; - $flatLookup = join( '|', $lookup ); - // when using ajax GET method, use utf8 to encoude the lookup query. otherwise, some special chars like France characters might not work - if( !$this->isPost() ){ - $lastValue = utf8_encode( $lastValue ); - $flatLookup = utf8_encode( $flatLookup ); - }; - - foreach( $this->fields['data'] as $r ){ - - if( !isset($r[$n]) ) - continue; - - $value = trim($r[$n]); - if( $value == '' ) - continue; - - if( $n == 0 ){ - $col[] = $value; - - }else{ - - //if( trim($r[$n-1]) == $lastValue ){ // quick check to improve performance - if( $r[$n-1] == $lastValue ){ // quick check the last value to improve performance - $leftCols = array_slice( $r, 0, $n ); - $flatLeftValues = join( '|', $leftCols ); - if( $flatLeftValues == $flatLookup ){ // show value only by lookuping by joining all its parents' values - $col[] = $value; - }; - }; // if - - }; // if $n == 0 - - if( $quickTest && count($col) > 0 ) break; - - }; // foreach - - return array_unique($col); - } - - function getColumnOptions( $n, $lookup = array(), $default = '' ){ - $opts = array(); - foreach( $this->getColumn($n, $lookup) as $v ){ - $selected = $default == $v ? 'selected' : '' ; - $opts[] = ""; - }; - return join("\n",$opts); - } - - function hsc($s){ - return str_replace ( array ( '&', '"', "'", '<', '>' ), array ( '&' , '"', ''' , '<' , '>' ), $s ); - } - - function isPost(){ - return isset($_POST[ $this->fields['name'][0] ]); - } - - function getHtml(){ - $html = array(); - - $field_name = $this->fmgField['name']; - $this->prefix = $field_name; - $count = count($this->fields['label']); - - // prepare for getting column options after form submitted - $lookup = array(); - $isPost = $this->isPost(); // isset($_POST[ $this->fields['name'][0] ]); - if( $isPost ){ - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $lookup[] = $_POST[ $this->fields['name'][$i] ]; - }; - }; - - for( $i = 0; $i < $count; $i++ ){ - $label = stripslashes( $this->fields['label'][$i] ); - if( empty($label) ) - continue; - - $name = $this->fields['name'][$i]; - $instruction = $this->fields['instruction'][$i]; - $prompt = $this->fields['prompt'][$i]; - $required = $this->fields['required'][$i]; - $promptOption = empty($prompt) ? "" : ""; - if( $isPost ) - $options = $this->getColumnOptions( $i, array_slice($lookup,0,$i), $_POST[$name] ); - else - $options = $this->getColumnOptions( $i, array(), '' ); - - $select = ""; - $sRequired = "" ; -$li = " -
  • -
    - {$sRequired} -
    -
    - {$select} -
    {$instruction}
    -
    -
  • -"; - $html[] = $li; - }; - - echo join("\n\n",$html); - - } - - - function dynamicRequired(){ - if( !isset($_POST) ){ - return ; - }; - - $field_name = $this->fmgField['name']; - $this->prefix = $field_name; - $count = count($this->fields['label']); - - $lookup = array(); - $isPost = isset($_POST[ $this->fields['name'][0] ]); - if( $isPost ){ - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $lookup[] = $_POST[ $this->fields['name'][$i] ]; - }; - }; - - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $name = $this->fields['name'][$i]; - $required = $this->fields['required'][$i]; - if( strtolower($required) == 'required' ){ - $rows = $this->getColumn( $i, array_slice($lookup,0,$i), true ); - if( empty($rows) ) { - $GLOBALS['form_mail'][ $name ]['required'] = '' ; // - }; - }else{ - $GLOBALS['form_mail'][ $name ]['required'] = '' ; - }; - }; - - } - - - function getFormMailArrayCode(){ - $code = array(); - for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - $name = $this->fields['name'][$i]; - $instruction = $this->fields['instruction'][$i]; - $prompt = $this->fields['prompt'][$i]; - $required = $this->fields['required'][$i]; - $code[] = "\$GLOBALS['form_mail']['{$name}'] = array( \"name\" => \"$name\", \"text\" => \"" . addslashes( $label ) . "\", \"type\" => \"select\", \"instruction\" => \"$instruction\", \"required\" => \"$required\" ) ;" ; - }; - return join("\n",$code); - } - - function makeupFieldsName($default='field_99'){ - $field_name = isset($this->fmgField['name']) ? $this->fmgField['name'] : $default; - $this->prefix = $field_name; - for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++ ){ - $this->fields['name'][$i] = $this->prefix . '_' . $i; - }; - } - -} - - - -function phpfmg_parse_option( $opt ){ - $opt = $opt; - $a = array( - 'text' => $opt, - 'value' => $opt, - 'default' => false, - ); - $pos = strrpos( $opt, '=' ); - if( false !== $pos ){ - $a['text'] = substr($opt,0,$pos); - $part = substr($opt,$pos+1); - $nv = strrpos( $part, ',' ); - if( false !== $nv ){ - $a['value'] = substr($part,0,$nv); - $a['default'] = 'default' == strtolower(substr($part,$nv+1)); - }else{ - $a['value'] = $part; - }; - }; - $a['text'] = trim($a['text']); - $a['value'] = trim($a['value']); - return $a ; -} - - - -function phpfmg_field_value( $name ){ - $value = "" ; - if( isset($GLOBALS[$name."_value"]) ) - return $GLOBALS[$name."_value"] ; - - $field = $GLOBALS['form_mail'][$name]; - $checkOther = isset( $_POST[$name.'_other_check'] ) && 1 == $_POST[$name.'_other_check'] ; - $otherInputValue = $checkOther ? $_POST[$name.'_other'] : '' ; - - switch( $field['type'] ){ - case 'select' : - if( $checkOther && $otherInputValue == "" ){ - return $value; - }; - - if( is_array($_POST[$name]) ){ - //array_pop( $_POST[$name] ); // pop the last "other" element - $value = join(PHPFMG_LNCR,$_POST[$name]) . PHPFMG_LNCR. $otherInputValue ; - $value = str_replace( PHPFMG_LNCR . "other", "", $value ); - }else{ - $value = $checkOther ? $otherInputValue : $_POST[ $name ]; - }; - break; - - case 'radio' : - if( $checkOther ){ - $value = $otherInputValue == '' ? '' : $otherInputValue; - }else{ - $value = $_POST[ $name ]; - }; - break; - - case 'checkbox' : - if( $checkOther && $otherInputValue == "" ){ - return $value; - }; - - $length = isset($_POST[$name.'_length']) ? $_POST[$name.'_length'] : 100; - $values = array(); - for( $i = 1; $i <= $length; $i ++){ - $newName = 'Checkbox' . ($i<10 ? '0' .$i : $i ) . "_" . $name; - if( $_POST[ $newName ] != "" && $_POST[ $newName ] != 'other' ) - $values[] = $_POST[ $newName ]; - }; - $value = ( empty($values) ? "" : join( PHPFMG_LNCR, $values ) ) . ( $otherInputValue != "" ? PHPFMG_LNCR . $otherInputValue : "" ); - break; - - default: - $value = $_POST[ $name ]; - break; - }; - $value = phpfmg_stripTags( $value ); - $GLOBALS[$name."_value"] = $value ; - return $value; -} - -function phpfmg_stripTags($str){ - $allowable_tags = "


    1. 
      -
      \ No newline at end of file
      diff --git a/abuse.phpmailer.php b/abuse.phpmailer.php
      deleted file mode 100644
      index b61fda7..0000000
      --- a/abuse.phpmailer.php
      +++ /dev/null
      @@ -1,5258 +0,0 @@
      -
      - * @author Jim Jagielski (jimjag) 
      - * @author Andy Prevost (codeworxtech) 
      - * @author Brent R. Matzelle (original founder)
      - * @copyright 2014 Marcus Bointon
      - * @copyright 2010 - 2012 Jim Jagielski
      - * @copyright 2004 - 2009 Andy Prevost
      - * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
      - * @note 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.
      - */
      -
      -/**
      - * PHPMailer RFC821 SMTP email transport class.
      - * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
      - * @package PHPMailer
      - * @author Chris Ryan
      - * @author Marcus Bointon 
      - */
      -class SMTP
      -{
      -    /**
      -     * The PHPMailer SMTP version number.
      -     * @var string
      -     */
      -    const VERSION = '5.2.21';
      -
      -    /**
      -     * SMTP line break constant.
      -     * @var string
      -     */
      -    const CRLF = "\r\n";
      -
      -    /**
      -     * The SMTP port to use if one is not specified.
      -     * @var integer
      -     */
      -    const DEFAULT_SMTP_PORT = 25;
      -
      -    /**
      -     * The maximum line length allowed by RFC 2822 section 2.1.1
      -     * @var integer
      -     */
      -    const MAX_LINE_LENGTH = 998;
      -
      -    /**
      -     * Debug level for no output
      -     */
      -    const DEBUG_OFF = 0;
      -
      -    /**
      -     * Debug level to show client -> server messages
      -     */
      -    const DEBUG_CLIENT = 1;
      -
      -    /**
      -     * Debug level to show client -> server and server -> client messages
      -     */
      -    const DEBUG_SERVER = 2;
      -
      -    /**
      -     * Debug level to show connection status, client -> server and server -> client messages
      -     */
      -    const DEBUG_CONNECTION = 3;
      -
      -    /**
      -     * Debug level to show all messages
      -     */
      -    const DEBUG_LOWLEVEL = 4;
      -
      -    /**
      -     * The PHPMailer SMTP Version number.
      -     * @var string
      -     * @deprecated Use the `VERSION` constant instead
      -     * @see SMTP::VERSION
      -     */
      -    public $Version = '5.2.21';
      -
      -    /**
      -     * SMTP server port number.
      -     * @var integer
      -     * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
      -     * @see SMTP::DEFAULT_SMTP_PORT
      -     */
      -    public $SMTP_PORT = 25;
      -
      -    /**
      -     * SMTP reply line ending.
      -     * @var string
      -     * @deprecated Use the `CRLF` constant instead
      -     * @see SMTP::CRLF
      -     */
      -    public $CRLF = "\r\n";
      -
      -    /**
      -     * Debug output level.
      -     * Options:
      -     * * self::DEBUG_OFF (`0`) No debug output, default
      -     * * self::DEBUG_CLIENT (`1`) Client commands
      -     * * self::DEBUG_SERVER (`2`) Client commands and server responses
      -     * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
      -     * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages
      -     * @var integer
      -     */
      -    public $do_debug = self::DEBUG_OFF;
      -
      -    /**
      -     * How to handle debug output.
      -     * Options:
      -     * * `echo` Output plain-text as-is, appropriate for CLI
      -     * * `html` Output escaped, line breaks converted to `
      `, appropriate for browser output - * * `error_log` Output to error log as configured in php.ini - * - * Alternatively, you can provide a callable expecting two params: a message string and the debug level: - * - * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; - * - * @var string|callable - */ - public $Debugoutput = 'echo'; - - /** - * Whether to use VERP. - * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path - * @link http://www.postfix.org/VERP_README.html Info on VERP - * @var boolean - */ - public $do_verp = false; - - /** - * The timeout value for connection, in seconds. - * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 - * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. - * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2 - * @var integer - */ - public $Timeout = 300; - - /** - * How long to wait for commands to complete, in seconds. - * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 - * @var integer - */ - public $Timelimit = 300; - - /** - * @var array patterns to extract smtp transaction id from smtp reply - * Only first capture group will be use, use non-capturing group to deal with it - * Extend this class to override this property to fulfil your needs. - */ - protected $smtp_transaction_id_patterns = array( - 'exim' => '/[0-9]{3} OK id=(.*)/', - 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/', - 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/' - ); - - /** - * The socket for the server connection. - * @var resource - */ - protected $smtp_conn; - - /** - * Error information, if any, for the last SMTP command. - * @var array - */ - protected $error = array( - 'error' => '', - 'detail' => '', - 'smtp_code' => '', - 'smtp_code_ex' => '' - ); - - /** - * The reply the server sent to us for HELO. - * If null, no HELO string has yet been received. - * @var string|null - */ - protected $helo_rply = null; - - /** - * The set of SMTP extensions sent in reply to EHLO command. - * Indexes of the array are extension names. - * Value at index 'HELO' or 'EHLO' (according to command that was sent) - * represents the server name. In case of HELO it is the only element of the array. - * Other values can be boolean TRUE or an array containing extension options. - * If null, no HELO/EHLO string has yet been received. - * @var array|null - */ - protected $server_caps = null; - - /** - * The most recent reply received from the server. - * @var string - */ - protected $last_reply = ''; - - /** - * Output debugging info via a user-selected method. - * @see SMTP::$Debugoutput - * @see SMTP::$do_debug - * @param string $str Debug string to output - * @param integer $level The debug level of this message; see DEBUG_* constants - * @return void - */ - protected function edebug($str, $level = 0) - { - if ($level > $this->do_debug) { - return; - } - //Avoid clash with built-in function names - if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { - call_user_func($this->Debugoutput, $str, $level); - return; - } - switch ($this->Debugoutput) { - case 'error_log': - //Don't output, just log - error_log($str); - break; - case 'html': - //Cleans up output a bit for a better looking, HTML-safe output - echo htmlentities( - preg_replace('/[\r\n]+/', '', $str), - ENT_QUOTES, - 'UTF-8' - ) - . "
      \n"; - break; - case 'echo': - default: - //Normalize line breaks - $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); - echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( - "\n", - "\n \t ", - trim($str) - )."\n"; - } - } - - /** - * Connect to an SMTP server. - * @param string $host SMTP server IP or host name - * @param integer $port The port number to connect to - * @param integer $timeout How long to wait for the connection to open - * @param array $options An array of options for stream_context_create() - * @access public - * @return boolean - */ - public function connect($host, $port = null, $timeout = 30, $options = array()) - { - static $streamok; - //This is enabled by default since 5.0.0 but some providers disable it - //Check this once and cache the result - if (is_null($streamok)) { - $streamok = function_exists('stream_socket_client'); - } - // Clear errors to avoid confusion - $this->setError(''); - // Make sure we are __not__ connected - if ($this->connected()) { - // Already connected, generate error - $this->setError('Already connected to a server'); - return false; - } - if (empty($port)) { - $port = self::DEFAULT_SMTP_PORT; - } - // Connect to the SMTP server - $this->edebug( - "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true), - self::DEBUG_CONNECTION - ); - $errno = 0; - $errstr = ''; - if ($streamok) { - $socket_context = stream_context_create($options); - set_error_handler(array($this, 'errorHandler')); - $this->smtp_conn = stream_socket_client( - $host . ":" . $port, - $errno, - $errstr, - $timeout, - STREAM_CLIENT_CONNECT, - $socket_context - ); - restore_error_handler(); - } else { - //Fall back to fsockopen which should work in more places, but is missing some features - $this->edebug( - "Connection: stream_socket_client not available, falling back to fsockopen", - self::DEBUG_CONNECTION - ); - set_error_handler(array($this, 'errorHandler')); - $this->smtp_conn = fsockopen( - $host, - $port, - $errno, - $errstr, - $timeout - ); - restore_error_handler(); - } - // Verify we connected properly - if (!is_resource($this->smtp_conn)) { - $this->setError( - 'Failed to connect to server', - $errno, - $errstr - ); - $this->edebug( - 'SMTP ERROR: ' . $this->error['error'] - . ": $errstr ($errno)", - self::DEBUG_CLIENT - ); - return false; - } - $this->edebug('Connection: opened', self::DEBUG_CONNECTION); - // SMTP server can take longer to respond, give longer timeout for first read - // Windows does not have support for this timeout function - if (substr(PHP_OS, 0, 3) != 'WIN') { - $max = ini_get('max_execution_time'); - // Don't bother if unlimited - if ($max != 0 && $timeout > $max) { - @set_time_limit($timeout); - } - stream_set_timeout($this->smtp_conn, $timeout, 0); - } - // Get any announcement - $announce = $this->get_lines(); - $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); - return true; - } - - /** - * Initiate a TLS (encrypted) session. - * @access public - * @return boolean - */ - public function startTLS() - { - if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) { - return false; - } - - //Allow the best TLS version(s) we can - $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; - - //PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT - //so add them back in manually if we can - if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; - } - - // Begin encrypted connection - if (!stream_socket_enable_crypto( - $this->smtp_conn, - true, - $crypto_method - )) { - return false; - } - return true; - } - - /** - * Perform SMTP authentication. - * Must be run after hello(). - * @see hello() - * @param string $username The user name - * @param string $password The password - * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2) - * @param string $realm The auth realm for NTLM - * @param string $workstation The auth workstation for NTLM - * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth) - * @return bool True if successfully authenticated.* @access public - */ - public function authenticate( - $username, - $password, - $authtype = null, - $realm = '', - $workstation = '', - $OAuth = null - ) { - if (!$this->server_caps) { - $this->setError('Authentication is not allowed before HELO/EHLO'); - return false; - } - - if (array_key_exists('EHLO', $this->server_caps)) { - // SMTP extensions are available. Let's try to find a proper authentication method - - if (!array_key_exists('AUTH', $this->server_caps)) { - $this->setError('Authentication is not allowed at this stage'); - // 'at this stage' means that auth may be allowed after the stage changes - // e.g. after STARTTLS - return false; - } - - self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); - self::edebug( - 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), - self::DEBUG_LOWLEVEL - ); - - if (empty($authtype)) { - foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN', 'NTLM', 'XOAUTH2') as $method) { - if (in_array($method, $this->server_caps['AUTH'])) { - $authtype = $method; - break; - } - } - if (empty($authtype)) { - $this->setError('No supported authentication methods found'); - return false; - } - self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); - } - - if (!in_array($authtype, $this->server_caps['AUTH'])) { - $this->setError("The requested authentication method \"$authtype\" is not supported by the server"); - return false; - } - } elseif (empty($authtype)) { - $authtype = 'LOGIN'; - } - switch ($authtype) { - case 'PLAIN': - // Start authentication - if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) { - return false; - } - // Send encoded username and password - if (!$this->sendCommand( - 'User & Password', - base64_encode("\0" . $username . "\0" . $password), - 235 - ) - ) { - return false; - } - break; - case 'LOGIN': - // Start authentication - if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) { - return false; - } - if (!$this->sendCommand("Username", base64_encode($username), 334)) { - return false; - } - if (!$this->sendCommand("Password", base64_encode($password), 235)) { - return false; - } - break; - case 'XOAUTH2': - //If the OAuth Instance is not set. Can be a case when PHPMailer is used - //instead of PHPMailerOAuth - if (is_null($OAuth)) { - return false; - } - $oauth = $OAuth->getOauth64(); - - // Start authentication - if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) { - return false; - } - break; - case 'NTLM': - /* - * ntlm_sasl_client.php - * Bundled with Permission - * - * How to telnet in windows: - * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx - * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication - */ - require_once 'extras/ntlm_sasl_client.php'; - $temp = new stdClass; - $ntlm_client = new ntlm_sasl_client_class; - //Check that functions are available - if (!$ntlm_client->initialize($temp)) { - $this->setError($temp->error); - $this->edebug( - 'You need to enable some modules in your php.ini file: ' - . $this->error['error'], - self::DEBUG_CLIENT - ); - return false; - } - //msg1 - $msg1 = $ntlm_client->typeMsg1($realm, $workstation); //msg1 - - if (!$this->sendCommand( - 'AUTH NTLM', - 'AUTH NTLM ' . base64_encode($msg1), - 334 - ) - ) { - return false; - } - //Though 0 based, there is a white space after the 3 digit number - //msg2 - $challenge = substr($this->last_reply, 3); - $challenge = base64_decode($challenge); - $ntlm_res = $ntlm_client->NTLMResponse( - substr($challenge, 24, 8), - $password - ); - //msg3 - $msg3 = $ntlm_client->typeMsg3( - $ntlm_res, - $username, - $realm, - $workstation - ); - // send encoded username - return $this->sendCommand('Username', base64_encode($msg3), 235); - case 'CRAM-MD5': - // Start authentication - if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) { - return false; - } - // Get the challenge - $challenge = base64_decode(substr($this->last_reply, 4)); - - // Build the response - $response = $username . ' ' . $this->hmac($challenge, $password); - - // send encoded credentials - return $this->sendCommand('Username', base64_encode($response), 235); - default: - $this->setError("Authentication method \"$authtype\" is not supported"); - return false; - } - return true; - } - - /** - * Calculate an MD5 HMAC hash. - * Works like hash_hmac('md5', $data, $key) - * in case that function is not available - * @param string $data The data to hash - * @param string $key The key to hash with - * @access protected - * @return string - */ - protected function hmac($data, $key) - { - if (function_exists('hash_hmac')) { - return hash_hmac('md5', $data, $key); - } - - // The following borrowed from - // http://php.net/manual/en/function.mhash.php#27225 - - // RFC 2104 HMAC implementation for php. - // Creates an md5 HMAC. - // Eliminates the need to install mhash to compute a HMAC - // by Lance Rushing - - $bytelen = 64; // byte length for md5 - if (strlen($key) > $bytelen) { - $key = pack('H*', md5($key)); - } - $key = str_pad($key, $bytelen, chr(0x00)); - $ipad = str_pad('', $bytelen, chr(0x36)); - $opad = str_pad('', $bytelen, chr(0x5c)); - $k_ipad = $key ^ $ipad; - $k_opad = $key ^ $opad; - - return md5($k_opad . pack('H*', md5($k_ipad . $data))); - } - - /** - * Check connection state. - * @access public - * @return boolean True if connected. - */ - public function connected() - { - if (is_resource($this->smtp_conn)) { - $sock_status = stream_get_meta_data($this->smtp_conn); - if ($sock_status['eof']) { - // The socket is valid but we are not connected - $this->edebug( - 'SMTP NOTICE: EOF caught while checking if connected', - self::DEBUG_CLIENT - ); - $this->close(); - return false; - } - return true; // everything looks good - } - return false; - } - - /** - * Close the socket and clean up the state of the class. - * Don't use this function without first trying to use QUIT. - * @see quit() - * @access public - * @return void - */ - public function close() - { - $this->setError(''); - $this->server_caps = null; - $this->helo_rply = null; - if (is_resource($this->smtp_conn)) { - // close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = null; //Makes for cleaner serialization - $this->edebug('Connection: closed', self::DEBUG_CONNECTION); - } - } - - /** - * Send an SMTP DATA command. - * Issues a data command and sends the msg_data to the server, - * finializing the mail transaction. $msg_data is the message - * that is to be send with the headers. Each header needs to be - * on a single line followed by a with the message headers - * and the message body being separated by and additional . - * Implements rfc 821: DATA - * @param string $msg_data Message data to send - * @access public - * @return boolean - */ - public function data($msg_data) - { - //This will use the standard timelimit - if (!$this->sendCommand('DATA', 'DATA', 354)) { - return false; - } - - /* The server is ready to accept data! - * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF) - * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into - * smaller lines to fit within the limit. - * We will also look for lines that start with a '.' and prepend an additional '.'. - * NOTE: this does not count towards line-length limit. - */ - - // Normalize line breaks before exploding - $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data)); - - /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field - * of the first line (':' separated) does not contain a space then it _should_ be a header and we will - * process all lines before a blank line as headers. - */ - - $field = substr($lines[0], 0, strpos($lines[0], ':')); - $in_headers = false; - if (!empty($field) && strpos($field, ' ') === false) { - $in_headers = true; - } - - foreach ($lines as $line) { - $lines_out = array(); - if ($in_headers and $line == '') { - $in_headers = false; - } - //Break this line up into several smaller lines if it's too long - //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len), - while (isset($line[self::MAX_LINE_LENGTH])) { - //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on - //so as to avoid breaking in the middle of a word - $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' '); - //Deliberately matches both false and 0 - if (!$pos) { - //No nice break found, add a hard break - $pos = self::MAX_LINE_LENGTH - 1; - $lines_out[] = substr($line, 0, $pos); - $line = substr($line, $pos); - } else { - //Break at the found point - $lines_out[] = substr($line, 0, $pos); - //Move along by the amount we dealt with - $line = substr($line, $pos + 1); - } - //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1 - if ($in_headers) { - $line = "\t" . $line; - } - } - $lines_out[] = $line; - - //Send the lines to the server - foreach ($lines_out as $line_out) { - //RFC2821 section 4.5.2 - if (!empty($line_out) and $line_out[0] == '.') { - $line_out = '.' . $line_out; - } - $this->client_send($line_out . self::CRLF); - } - } - - //Message data has been sent, complete the command - //Increase timelimit for end of DATA command - $savetimelimit = $this->Timelimit; - $this->Timelimit = $this->Timelimit * 2; - $result = $this->sendCommand('DATA END', '.', 250); - //Restore timelimit - $this->Timelimit = $savetimelimit; - return $result; - } - - /** - * Send an SMTP HELO or EHLO command. - * Used to identify the sending server to the receiving server. - * This makes sure that client and server are in a known state. - * Implements RFC 821: HELO - * and RFC 2821 EHLO. - * @param string $host The host name or IP to connect to - * @access public - * @return boolean - */ - public function hello($host = '') - { - //Try extended hello first (RFC 2821) - return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host)); - } - - /** - * Send an SMTP HELO or EHLO command. - * Low-level implementation used by hello() - * @see hello() - * @param string $hello The HELO string - * @param string $host The hostname to say we are - * @access protected - * @return boolean - */ - protected function sendHello($hello, $host) - { - $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250); - $this->helo_rply = $this->last_reply; - if ($noerror) { - $this->parseHelloFields($hello); - } else { - $this->server_caps = null; - } - return $noerror; - } - - /** - * Parse a reply to HELO/EHLO command to discover server extensions. - * In case of HELO, the only parameter that can be discovered is a server name. - * @access protected - * @param string $type - 'HELO' or 'EHLO' - */ - protected function parseHelloFields($type) - { - $this->server_caps = array(); - $lines = explode("\n", $this->helo_rply); - - foreach ($lines as $n => $s) { - //First 4 chars contain response code followed by - or space - $s = trim(substr($s, 4)); - if (empty($s)) { - continue; - } - $fields = explode(' ', $s); - if (!empty($fields)) { - if (!$n) { - $name = $type; - $fields = $fields[0]; - } else { - $name = array_shift($fields); - switch ($name) { - case 'SIZE': - $fields = ($fields ? $fields[0] : 0); - break; - case 'AUTH': - if (!is_array($fields)) { - $fields = array(); - } - break; - default: - $fields = true; - } - } - $this->server_caps[$name] = $fields; - } - } - } - - /** - * Send an SMTP MAIL command. - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more recipient - * commands may be called followed by a data command. - * Implements rfc 821: MAIL FROM: - * @param string $from Source address of this message - * @access public - * @return boolean - */ - public function mail($from) - { - $useVerp = ($this->do_verp ? ' XVERP' : ''); - return $this->sendCommand( - 'MAIL FROM', - 'MAIL FROM:<' . $from . '>' . $useVerp, - 250 - ); - } - - /** - * Send an SMTP QUIT command. - * Closes the socket if there is no error or the $close_on_error argument is true. - * Implements from rfc 821: QUIT - * @param boolean $close_on_error Should the connection close if an error occurs? - * @access public - * @return boolean - */ - public function quit($close_on_error = true) - { - $noerror = $this->sendCommand('QUIT', 'QUIT', 221); - $err = $this->error; //Save any error - if ($noerror or $close_on_error) { - $this->close(); - $this->error = $err; //Restore any error from the quit command - } - return $noerror; - } - - /** - * Send an SMTP RCPT command. - * Sets the TO argument to $toaddr. - * Returns true if the recipient was accepted false if it was rejected. - * Implements from rfc 821: RCPT TO: - * @param string $address The address the message is being sent to - * @access public - * @return boolean - */ - public function recipient($address) - { - return $this->sendCommand( - 'RCPT TO', - 'RCPT TO:<' . $address . '>', - array(250, 251) - ); - } - - /** - * Send an SMTP RSET command. - * Abort any transaction that is currently in progress. - * Implements rfc 821: RSET - * @access public - * @return boolean True on success. - */ - public function reset() - { - return $this->sendCommand('RSET', 'RSET', 250); - } - - /** - * Send a command to an SMTP server and check its return code. - * @param string $command The command name - not sent to the server - * @param string $commandstring The actual command to send - * @param integer|array $expect One or more expected integer success codes - * @access protected - * @return boolean True on success. - */ - protected function sendCommand($command, $commandstring, $expect) - { - if (!$this->connected()) { - $this->setError("Called $command without being connected"); - return false; - } - //Reject line breaks in all commands - if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) { - $this->setError("Command '$command' contained line breaks"); - return false; - } - $this->client_send($commandstring . self::CRLF); - - $this->last_reply = $this->get_lines(); - // Fetch SMTP code and possible error code explanation - $matches = array(); - if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) { - $code = $matches[1]; - $code_ex = (count($matches) > 2 ? $matches[2] : null); - // Cut off error code from each response line - $detail = preg_replace( - "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m", - '', - $this->last_reply - ); - } else { - // Fall back to simple parsing if regex fails - $code = substr($this->last_reply, 0, 3); - $code_ex = null; - $detail = substr($this->last_reply, 4); - } - - $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); - - if (!in_array($code, (array)$expect)) { - $this->setError( - "$command command failed", - $detail, - $code, - $code_ex - ); - $this->edebug( - 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply, - self::DEBUG_CLIENT - ); - return false; - } - - $this->setError(''); - return true; - } - - /** - * Send an SMTP SAML command. - * Starts a mail transaction from the email address specified in $from. - * Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more recipient - * commands may be called followed by a data command. This command - * will send the message to the users terminal if they are logged - * in and send them an email. - * Implements rfc 821: SAML FROM: - * @param string $from The address the message is from - * @access public - * @return boolean - */ - public function sendAndMail($from) - { - return $this->sendCommand('SAML', "SAML FROM:$from", 250); - } - - /** - * Send an SMTP VRFY command. - * @param string $name The name to verify - * @access public - * @return boolean - */ - public function verify($name) - { - return $this->sendCommand('VRFY', "VRFY $name", array(250, 251)); - } - - /** - * Send an SMTP NOOP command. - * Used to keep keep-alives alive, doesn't actually do anything - * @access public - * @return boolean - */ - public function noop() - { - return $this->sendCommand('NOOP', 'NOOP', 250); - } - - /** - * Send an SMTP TURN command. - * This is an optional command for SMTP that this class does not support. - * This method is here to make the RFC821 Definition complete for this class - * and _may_ be implemented in future - * Implements from rfc 821: TURN - * @access public - * @return boolean - */ - public function turn() - { - $this->setError('The SMTP TURN command is not implemented'); - $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT); - return false; - } - - /** - * Send raw data to the server. - * @param string $data The data to send - * @access public - * @return integer|boolean The number of bytes sent to the server or false on error - */ - public function client_send($data) - { - $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); - return fwrite($this->smtp_conn, $data); - } - - /** - * Get the latest error. - * @access public - * @return array - */ - public function getError() - { - return $this->error; - } - - /** - * Get SMTP extensions available on the server - * @access public - * @return array|null - */ - public function getServerExtList() - { - return $this->server_caps; - } - - /** - * A multipurpose method - * The method works in three ways, dependent on argument value and current state - * 1. HELO/EHLO was not sent - returns null and set up $this->error - * 2. HELO was sent - * $name = 'HELO': returns server name - * $name = 'EHLO': returns boolean false - * $name = any string: returns null and set up $this->error - * 3. EHLO was sent - * $name = 'HELO'|'EHLO': returns server name - * $name = any string: if extension $name exists, returns boolean True - * or its options. Otherwise returns boolean False - * In other words, one can use this method to detect 3 conditions: - * - null returned: handshake was not or we don't know about ext (refer to $this->error) - * - false returned: the requested feature exactly not exists - * - positive value returned: the requested feature exists - * @param string $name Name of SMTP extension or 'HELO'|'EHLO' - * @return mixed - */ - public function getServerExt($name) - { - if (!$this->server_caps) { - $this->setError('No HELO/EHLO was sent'); - return null; - } - - // the tight logic knot ;) - if (!array_key_exists($name, $this->server_caps)) { - if ($name == 'HELO') { - return $this->server_caps['EHLO']; - } - if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) { - return false; - } - $this->setError('HELO handshake was used. Client knows nothing about server extensions'); - return null; - } - - return $this->server_caps[$name]; - } - - /** - * Get the last reply from the server. - * @access public - * @return string - */ - public function getLastReply() - { - return $this->last_reply; - } - - /** - * Read the SMTP server's response. - * Either before eof or socket timeout occurs on the operation. - * With SMTP we can tell if we have more lines to read if the - * 4th character is '-' symbol. If it is a space then we don't - * need to read anything else. - * @access protected - * @return string - */ - protected function get_lines() - { - // If the connection is bad, give up straight away - if (!is_resource($this->smtp_conn)) { - return ''; - } - $data = ''; - $endtime = 0; - stream_set_timeout($this->smtp_conn, $this->Timeout); - if ($this->Timelimit > 0) { - $endtime = time() + $this->Timelimit; - } - while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { - $str = @fgets($this->smtp_conn, 515); - $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); - $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); - $data .= $str; - // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen - if ((isset($str[3]) and $str[3] == ' ')) { - break; - } - // Timed-out? Log and break - $info = stream_get_meta_data($this->smtp_conn); - if ($info['timed_out']) { - $this->edebug( - 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', - self::DEBUG_LOWLEVEL - ); - break; - } - // Now check if reads took too long - if ($endtime and time() > $endtime) { - $this->edebug( - 'SMTP -> get_lines(): timelimit reached ('. - $this->Timelimit . ' sec)', - self::DEBUG_LOWLEVEL - ); - break; - } - } - return $data; - } - - /** - * Enable or disable VERP address generation. - * @param boolean $enabled - */ - public function setVerp($enabled = false) - { - $this->do_verp = $enabled; - } - - /** - * Get VERP address generation mode. - * @return boolean - */ - public function getVerp() - { - return $this->do_verp; - } - - /** - * Set error messages and codes. - * @param string $message The error message - * @param string $detail Further detail on the error - * @param string $smtp_code An associated SMTP error code - * @param string $smtp_code_ex Extended SMTP code - */ - protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '') - { - $this->error = array( - 'error' => $message, - 'detail' => $detail, - 'smtp_code' => $smtp_code, - 'smtp_code_ex' => $smtp_code_ex - ); - } - - /** - * Set debug output method. - * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it. - */ - public function setDebugOutput($method = 'echo') - { - $this->Debugoutput = $method; - } - - /** - * Get debug output method. - * @return string - */ - public function getDebugOutput() - { - return $this->Debugoutput; - } - - /** - * Set debug output level. - * @param integer $level - */ - public function setDebugLevel($level = 0) - { - $this->do_debug = $level; - } - - /** - * Get debug output level. - * @return integer - */ - public function getDebugLevel() - { - return $this->do_debug; - } - - /** - * Set SMTP timeout. - * @param integer $timeout - */ - public function setTimeout($timeout = 0) - { - $this->Timeout = $timeout; - } - - /** - * Get SMTP timeout. - * @return integer - */ - public function getTimeout() - { - return $this->Timeout; - } - - /** - * Reports an error number and string. - * @param integer $errno The error number returned by PHP. - * @param string $errmsg The error message returned by PHP. - */ - protected function errorHandler($errno, $errmsg) - { - $notice = 'Connection: Failed to connect to server.'; - $this->setError( - $notice, - $errno, - $errmsg - ); - $this->edebug( - $notice . ' Error number ' . $errno . '. "Error notice: ' . $errmsg, - self::DEBUG_CONNECTION - ); - } - - /** - * Will return the ID of the last smtp transaction based on a list of patterns provided - * in SMTP::$smtp_transaction_id_patterns. - * If no reply has been received yet, it will return null. - * If no pattern has been matched, it will return false. - * @return bool|null|string - */ - public function getLastTransactionID() - { - $reply = $this->getLastReply(); - - if (empty($reply)) { - return null; - } - - foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { - if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) { - return $matches[1]; - } - } - - return false; - } -} - - - -/** - * PHPMailer - PHP email creation and transport class. - * @package PHPMailer - * @author Marcus Bointon (Synchro/coolbru) - * @author Jim Jagielski (jimjag) - * @author Andy Prevost (codeworxtech) - * @author Brent R. Matzelle (original founder) - */ -class PHPMailer -{ - /** - * The PHPMailer Version number. - * @var string - */ - public $Version = '5.2.21'; - - /** - * Email priority. - * Options: null (default), 1 = High, 3 = Normal, 5 = low. - * When null, the header is not set at all. - * @var integer - */ - public $Priority = null; - - /** - * The character set of the message. - * @var string - */ - public $CharSet = 'iso-8859-1'; - - /** - * The MIME Content-type of the message. - * @var string - */ - public $ContentType = 'text/plain'; - - /** - * The message encoding. - * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". - * @var string - */ - public $Encoding = '8bit'; - - /** - * Holds the most recent mailer error message. - * @var string - */ - public $ErrorInfo = ''; - - /** - * The From email address for the message. - * @var string - */ - public $From = 'root@localhost'; - - /** - * The From name of the message. - * @var string - */ - public $FromName = 'Root User'; - - /** - * The Sender email (Return-Path) of the message. - * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. - * @var string - */ - public $Sender = ''; - - /** - * The Return-Path of the message. - * If empty, it will be set to either From or Sender. - * @var string - * @deprecated Email senders should never set a return-path header; - * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything. - * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference - */ - public $ReturnPath = ''; - - /** - * The Subject of the message. - * @var string - */ - public $Subject = ''; - - /** - * An HTML or plain text message body. - * If HTML then call isHTML(true). - * @var string - */ - public $Body = ''; - - /** - * The plain-text message body. - * This body can be read by mail clients that do not have HTML email - * capability such as mutt & Eudora. - * Clients that can read HTML will view the normal Body. - * @var string - */ - public $AltBody = ''; - - /** - * An iCal message part body. - * Only supported in simple alt or alt_inline message types - * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator - * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ - * @link http://kigkonsult.se/iCalcreator/ - * @var string - */ - public $Ical = ''; - - /** - * The complete compiled MIME message body. - * @access protected - * @var string - */ - protected $MIMEBody = ''; - - /** - * The complete compiled MIME message headers. - * @var string - * @access protected - */ - protected $MIMEHeader = ''; - - /** - * Extra headers that createHeader() doesn't fold in. - * @var string - * @access protected - */ - protected $mailHeader = ''; - - /** - * Word-wrap the message body to this number of chars. - * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. - * @var integer - */ - public $WordWrap = 0; - - /** - * Which method to use to send mail. - * Options: "mail", "sendmail", or "smtp". - * @var string - */ - public $Mailer = 'mail'; - - /** - * The path to the sendmail program. - * @var string - */ - public $Sendmail = '/usr/sbin/sendmail'; - - /** - * Whether mail() uses a fully sendmail-compatible MTA. - * One which supports sendmail's "-oi -f" options. - * @var boolean - */ - public $UseSendmailOptions = true; - - /** - * Path to PHPMailer plugins. - * Useful if the SMTP class is not in the PHP include path. - * @var string - * @deprecated Should not be needed now there is an autoloader. - */ - public $PluginDir = ''; - - /** - * The email address that a reading confirmation should be sent to, also known as read receipt. - * @var string - */ - public $ConfirmReadingTo = ''; - - /** - * The hostname to use in the Message-ID header and as default HELO string. - * If empty, PHPMailer attempts to find one with, in order, - * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value - * 'localhost.localdomain'. - * @var string - */ - public $Hostname = ''; - - /** - * An ID to be used in the Message-ID header. - * If empty, a unique id will be generated. - * You can set your own, but it must be in the format "", - * as defined in RFC5322 section 3.6.4 or it will be ignored. - * @see https://tools.ietf.org/html/rfc5322#section-3.6.4 - * @var string - */ - public $MessageID = ''; - - /** - * The message Date to be used in the Date header. - * If empty, the current date will be added. - * @var string - */ - public $MessageDate = ''; - - /** - * SMTP hosts. - * Either a single hostname or multiple semicolon-delimited hostnames. - * You can also specify a different port - * for each host by using this format: [hostname:port] - * (e.g. "smtp1.example.com:25;smtp2.example.com"). - * You can also specify encryption type, for example: - * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). - * Hosts will be tried in order. - * @var string - */ - public $Host = 'localhost'; - - /** - * The default SMTP server port. - * @var integer - * @TODO Why is this needed when the SMTP class takes care of it? - */ - public $Port = 25; - - /** - * The SMTP HELO of the message. - * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find - * one with the same method described above for $Hostname. - * @var string - * @see PHPMailer::$Hostname - */ - public $Helo = ''; - - /** - * What kind of encryption to use on the SMTP connection. - * Options: '', 'ssl' or 'tls' - * @var string - */ - public $SMTPSecure = ''; - - /** - * Whether to enable TLS encryption automatically if a server supports it, - * even if `SMTPSecure` is not set to 'tls'. - * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. - * @var boolean - */ - public $SMTPAutoTLS = true; - - /** - * Whether to use SMTP authentication. - * Uses the Username and Password properties. - * @var boolean - * @see PHPMailer::$Username - * @see PHPMailer::$Password - */ - public $SMTPAuth = false; - - /** - * Options array passed to stream_context_create when connecting via SMTP. - * @var array - */ - public $SMTPOptions = array(); - - /** - * SMTP username. - * @var string - */ - public $Username = ''; - - /** - * SMTP password. - * @var string - */ - public $Password = ''; - - /** - * SMTP auth type. - * Options are CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified - * @var string - */ - public $AuthType = ''; - - /** - * SMTP realm. - * Used for NTLM auth - * @var string - */ - public $Realm = ''; - - /** - * SMTP workstation. - * Used for NTLM auth - * @var string - */ - public $Workstation = ''; - - /** - * The SMTP server timeout in seconds. - * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 - * @var integer - */ - public $Timeout = 300; - - /** - * SMTP class debug output mode. - * Debug output level. - * Options: - * * `0` No output - * * `1` Commands - * * `2` Data and commands - * * `3` As 2 plus connection status - * * `4` Low-level data output - * @var integer - * @see SMTP::$do_debug - */ - public $SMTPDebug = 0; - - /** - * How to handle debug output. - * Options: - * * `echo` Output plain-text as-is, appropriate for CLI - * * `html` Output escaped, line breaks converted to `
      `, appropriate for browser output - * * `error_log` Output to error log as configured in php.ini - * - * Alternatively, you can provide a callable expecting two params: a message string and the debug level: - * - * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; - * - * @var string|callable - * @see SMTP::$Debugoutput - */ - public $Debugoutput = 'echo'; - - /** - * Whether to keep SMTP connection open after each message. - * If this is set to true then to close the connection - * requires an explicit call to smtpClose(). - * @var boolean - */ - public $SMTPKeepAlive = false; - - /** - * Whether to split multiple to addresses into multiple messages - * or send them all in one message. - * Only supported in `mail` and `sendmail` transports, not in SMTP. - * @var boolean - */ - public $SingleTo = false; - - /** - * Storage for addresses when SingleTo is enabled. - * @var array - * @TODO This should really not be public - */ - public $SingleToArray = array(); - - /** - * Whether to generate VERP addresses on send. - * Only applicable when sending via SMTP. - * @link https://en.wikipedia.org/wiki/Variable_envelope_return_path - * @link http://www.postfix.org/VERP_README.html Postfix VERP info - * @var boolean - */ - public $do_verp = false; - - /** - * Whether to allow sending messages with an empty body. - * @var boolean - */ - public $AllowEmpty = false; - - /** - * The default line ending. - * @note The default remains "\n". We force CRLF where we know - * it must be used via self::CRLF. - * @var string - */ - public $LE = "\n"; - - /** - * DKIM selector. - * @var string - */ - public $DKIM_selector = ''; - - /** - * DKIM Identity. - * Usually the email address used as the source of the email. - * @var string - */ - public $DKIM_identity = ''; - - /** - * DKIM passphrase. - * Used if your key is encrypted. - * @var string - */ - public $DKIM_passphrase = ''; - - /** - * DKIM signing domain name. - * @example 'example.com' - * @var string - */ - public $DKIM_domain = ''; - - /** - * DKIM private key file path. - * @var string - */ - public $DKIM_private = ''; - - /** - * DKIM private key string. - * If set, takes precedence over `$DKIM_private`. - * @var string - */ - public $DKIM_private_string = ''; - - /** - * Callback Action function name. - * - * The function that handles the result of the send email action. - * It is called out by send() for each email sent. - * - * Value can be any php callable: http://www.php.net/is_callable - * - * Parameters: - * boolean $result result of the send action - * string $to email address of the recipient - * string $cc cc email addresses - * string $bcc bcc email addresses - * string $subject the subject - * string $body the email body - * string $from email address of sender - * @var string - */ - public $action_function = ''; - - /** - * What to put in the X-Mailer header. - * Options: An empty string for PHPMailer default, whitespace for none, or a string to use - * @var string - */ - public $XMailer = ''; - - /** - * Which validator to use by default when validating email addresses. - * May be a callable to inject your own validator, but there are several built-in validators. - * @see PHPMailer::validateAddress() - * @var string|callable - * @static - */ - public static $validator = 'auto'; - - /** - * An instance of the SMTP sender class. - * @var SMTP - * @access protected - */ - protected $smtp = null; - - /** - * The array of 'to' names and addresses. - * @var array - * @access protected - */ - protected $to = array(); - - /** - * The array of 'cc' names and addresses. - * @var array - * @access protected - */ - protected $cc = array(); - - /** - * The array of 'bcc' names and addresses. - * @var array - * @access protected - */ - protected $bcc = array(); - - /** - * The array of reply-to names and addresses. - * @var array - * @access protected - */ - protected $ReplyTo = array(); - - /** - * An array of all kinds of addresses. - * Includes all of $to, $cc, $bcc - * @var array - * @access protected - * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc - */ - protected $all_recipients = array(); - - /** - * An array of names and addresses queued for validation. - * In send(), valid and non duplicate entries are moved to $all_recipients - * and one of $to, $cc, or $bcc. - * This array is used only for addresses with IDN. - * @var array - * @access protected - * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc - * @see PHPMailer::$all_recipients - */ - protected $RecipientsQueue = array(); - - /** - * An array of reply-to names and addresses queued for validation. - * In send(), valid and non duplicate entries are moved to $ReplyTo. - * This array is used only for addresses with IDN. - * @var array - * @access protected - * @see PHPMailer::$ReplyTo - */ - protected $ReplyToQueue = array(); - - /** - * The array of attachments. - * @var array - * @access protected - */ - protected $attachment = array(); - - /** - * The array of custom headers. - * @var array - * @access protected - */ - protected $CustomHeader = array(); - - /** - * The most recent Message-ID (including angular brackets). - * @var string - * @access protected - */ - protected $lastMessageID = ''; - - /** - * The message's MIME type. - * @var string - * @access protected - */ - protected $message_type = ''; - - /** - * The array of MIME boundary strings. - * @var array - * @access protected - */ - protected $boundary = array(); - - /** - * The array of available languages. - * @var array - * @access protected - */ - protected $language = array(); - - /** - * The number of errors encountered. - * @var integer - * @access protected - */ - protected $error_count = 0; - - /** - * The S/MIME certificate file path. - * @var string - * @access protected - */ - protected $sign_cert_file = ''; - - /** - * The S/MIME key file path. - * @var string - * @access protected - */ - protected $sign_key_file = ''; - - /** - * The optional S/MIME extra certificates ("CA Chain") file path. - * @var string - * @access protected - */ - protected $sign_extracerts_file = ''; - - /** - * The S/MIME password for the key. - * Used only if the key is encrypted. - * @var string - * @access protected - */ - protected $sign_key_pass = ''; - - /** - * Whether to throw exceptions for errors. - * @var boolean - * @access protected - */ - protected $exceptions = false; - - /** - * Unique ID used for message ID and boundaries. - * @var string - * @access protected - */ - protected $uniqueid = ''; - - /** - * Error severity: message only, continue processing. - */ - const STOP_MESSAGE = 0; - - /** - * Error severity: message, likely ok to continue processing. - */ - const STOP_CONTINUE = 1; - - /** - * Error severity: message, plus full stop, critical error reached. - */ - const STOP_CRITICAL = 2; - - /** - * SMTP RFC standard line ending. - */ - const CRLF = "\r\n"; - - /** - * The maximum line length allowed by RFC 2822 section 2.1.1 - * @var integer - */ - const MAX_LINE_LENGTH = 998; - - /** - * Constructor. - * @param boolean $exceptions Should we throw external exceptions? - */ - public function __construct($exceptions = null) - { - if ($exceptions !== null) { - $this->exceptions = (boolean)$exceptions; - } - } - - /** - * Destructor. - */ - public function __destruct() - { - //Close any open SMTP connection nicely - $this->smtpClose(); - } - - /** - * Call mail() in a safe_mode-aware fashion. - * Also, unless sendmail_path points to sendmail (or something that - * claims to be sendmail), don't pass params (not a perfect fix, - * but it will do) - * @param string $to To - * @param string $subject Subject - * @param string $body Message Body - * @param string $header Additional Header(s) - * @param string $params Params - * @access private - * @return boolean - */ - private function mailPassthru($to, $subject, $body, $header, $params) - { - //Check overloading of mail function to avoid double-encoding - if (ini_get('mbstring.func_overload') & 1) { - $subject = $this->secureHeader($subject); - } else { - $subject = $this->encodeHeader($this->secureHeader($subject)); - } - - //Can't use additional_parameters in safe_mode, calling mail() with null params breaks - //@link http://php.net/manual/en/function.mail.php - if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) { - $result = @mail($to, $subject, $body, $header); - } else { - $result = @mail($to, $subject, $body, $header, $params); - } - return $result; - } - /** - * Output debugging info via user-defined method. - * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug). - * @see PHPMailer::$Debugoutput - * @see PHPMailer::$SMTPDebug - * @param string $str - */ - protected function edebug($str) - { - if ($this->SMTPDebug <= 0) { - return; - } - //Avoid clash with built-in function names - if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { - call_user_func($this->Debugoutput, $str, $this->SMTPDebug); - return; - } - switch ($this->Debugoutput) { - case 'error_log': - //Don't output, just log - error_log($str); - break; - case 'html': - //Cleans up output a bit for a better looking, HTML-safe output - echo htmlentities( - preg_replace('/[\r\n]+/', '', $str), - ENT_QUOTES, - 'UTF-8' - ) - . "
      \n"; - break; - case 'echo': - default: - //Normalize line breaks - $str = preg_replace('/\r\n?/ms', "\n", $str); - echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( - "\n", - "\n \t ", - trim($str) - ) . "\n"; - } - } - - /** - * Sets message type to HTML or plain. - * @param boolean $isHtml True for HTML mode. - * @return void - */ - public function isHTML($isHtml = true) - { - if ($isHtml) { - $this->ContentType = 'text/html'; - } else { - $this->ContentType = 'text/plain'; - } - } - - /** - * Send messages using SMTP. - * @return void - */ - public function isSMTP() - { - $this->Mailer = 'smtp'; - } - - /** - * Send messages using PHP's mail() function. - * @return void - */ - public function isMail() - { - $this->Mailer = 'mail'; - } - - /** - * Send messages using $Sendmail. - * @return void - */ - public function isSendmail() - { - $ini_sendmail_path = ini_get('sendmail_path'); - - if (!stristr($ini_sendmail_path, 'sendmail')) { - $this->Sendmail = '/usr/sbin/sendmail'; - } else { - $this->Sendmail = $ini_sendmail_path; - } - $this->Mailer = 'sendmail'; - } - - /** - * Send messages using qmail. - * @return void - */ - public function isQmail() - { - $ini_sendmail_path = ini_get('sendmail_path'); - - if (!stristr($ini_sendmail_path, 'qmail')) { - $this->Sendmail = '/var/qmail/bin/qmail-inject'; - } else { - $this->Sendmail = $ini_sendmail_path; - } - $this->Mailer = 'qmail'; - } - - /** - * Add a "To" address. - * @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 - */ - public function addAddress($address, $name = '') - { - return $this->addOrEnqueueAnAddress('to', $address, $name); - } - - /** - * Add a "CC" address. - * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. - * @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 - */ - public function addCC($address, $name = '') - { - return $this->addOrEnqueueAnAddress('cc', $address, $name); - } - - /** - * Add a "BCC" address. - * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. - * @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 - */ - public function addBCC($address, $name = '') - { - return $this->addOrEnqueueAnAddress('bcc', $address, $name); - } - - /** - * Add a "Reply-To" address. - * @param string $address The email address to reply to - * @param string $name - * @return boolean true on success, false if address already used or invalid in some way - */ - public function addReplyTo($address, $name = '') - { - return $this->addOrEnqueueAnAddress('Reply-To', $address, $name); - } - - /** - * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer - * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still - * be modified after calling this function), addition of such addresses is delayed until send(). - * Addresses that have been added already return false, but do not throw exceptions. - * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' - * @param string $address The email address to send, resp. to reply to - * @param string $name - * @throws phpmailerException - * @return boolean true on success, false if address already used or invalid in some way - * @access protected - */ - protected function addOrEnqueueAnAddress($kind, $address, $name) - { - $address = trim($address); - $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim - if (($pos = strrpos($address, '@')) === false) { - // At-sign is misssing. - $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address"; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - $params = array($kind, $address, $name); - // Enqueue addresses with IDN until we know the PHPMailer::$CharSet. - if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) { - if ($kind != 'Reply-To') { - if (!array_key_exists($address, $this->RecipientsQueue)) { - $this->RecipientsQueue[$address] = $params; - return true; - } - } else { - if (!array_key_exists($address, $this->ReplyToQueue)) { - $this->ReplyToQueue[$address] = $params; - return true; - } - } - return false; - } - // Immediately add standard addresses without IDN. - return call_user_func_array(array($this, 'addAnAddress'), $params); - } - - /** - * Add an address to one of the recipient arrays or to the ReplyTo array. - * Addresses that have been added already return false, but do not throw exceptions. - * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' - * @param string $address The email address to send, resp. to reply to - * @param string $name - * @throws phpmailerException - * @return boolean true on success, false if address already used or invalid in some way - * @access protected - */ - protected function addAnAddress($kind, $address, $name = '') - { - if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) { - $error_message = $this->lang('Invalid recipient kind: ') . $kind; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - if (!$this->validateAddress($address)) { - $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address"; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - if ($kind != 'Reply-To') { - if (!array_key_exists(strtolower($address), $this->all_recipients)) { - array_push($this->$kind, array($address, $name)); - $this->all_recipients[strtolower($address)] = true; - return true; - } - } else { - if (!array_key_exists(strtolower($address), $this->ReplyTo)) { - $this->ReplyTo[strtolower($address)] = array($address, $name); - return true; - } - } - return false; - } - - /** - * Parse and validate a string containing one or more RFC822-style comma-separated email addresses - * of the form "display name
      " into an array of name/address pairs. - * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. - * Note that quotes in the name part are removed. - * @param string $addrstr The address list string - * @param bool $useimap Whether to use the IMAP extension to parse the list - * @return array - * @link http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation - */ - public function parseAddresses($addrstr, $useimap = true) - { - $addresses = array(); - if ($useimap and function_exists('imap_rfc822_parse_adrlist')) { - //Use this built-in parser if it's available - $list = imap_rfc822_parse_adrlist($addrstr, ''); - foreach ($list as $address) { - if ($address->host != '.SYNTAX-ERROR.') { - if ($this->validateAddress($address->mailbox . '@' . $address->host)) { - $addresses[] = array( - 'name' => (property_exists($address, 'personal') ? $address->personal : ''), - 'address' => $address->mailbox . '@' . $address->host - ); - } - } - } - } else { - //Use this simpler parser - $list = explode(',', $addrstr); - foreach ($list as $address) { - $address = trim($address); - //Is there a separate name part? - if (strpos($address, '<') === false) { - //No separate name, just use the whole thing - if ($this->validateAddress($address)) { - $addresses[] = array( - 'name' => '', - 'address' => $address - ); - } - } else { - list($name, $email) = explode('<', $address); - $email = trim(str_replace('>', '', $email)); - if ($this->validateAddress($email)) { - $addresses[] = array( - 'name' => trim(str_replace(array('"', "'"), '', $name)), - 'address' => $email - ); - } - } - } - } - return $addresses; - } - - /** - * Set the From and FromName properties. - * @param string $address - * @param string $name - * @param boolean $auto Whether to also set the Sender address, defaults to true - * @throws phpmailerException - * @return boolean - */ - public function setFrom($address, $name = '', $auto = true) - { - $address = trim($address); - $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim - // Don't validate now addresses with IDN. Will be done in send(). - if (($pos = strrpos($address, '@')) === false or - (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and - !$this->validateAddress($address)) { - $error_message = $this->lang('invalid_address') . " (setFrom) $address"; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - $this->From = $address; - $this->FromName = $name; - if ($auto) { - if (empty($this->Sender)) { - $this->Sender = $address; - } - } - return true; - } - - /** - * Return the Message-ID header of the last email. - * Technically this is the value from the last time the headers were created, - * but it's also the message ID of the last sent message except in - * pathological cases. - * @return string - */ - public function getLastMessageID() - { - return $this->lastMessageID; - } - - /** - * Check that a string looks like an email address. - * @param string $address The email address to check - * @param string|callable $patternselect A selector for the validation pattern to use : - * * `auto` Pick best pattern automatically; - * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; - * * `pcre` Use old PCRE implementation; - * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; - * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. - * * `noregex` Don't use a regex: super fast, really dumb. - * Alternatively you may pass in a callable to inject your own validator, for example: - * PHPMailer::validateAddress('user@example.com', function($address) { - * return (strpos($address, '@') !== false); - * }); - * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. - * @return boolean - * @static - * @access public - */ - public static function validateAddress($address, $patternselect = null) - { - if (is_null($patternselect)) { - $patternselect = self::$validator; - } - if (is_callable($patternselect)) { - return call_user_func($patternselect, $address); - } - //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 - if (strpos($address, "\n") !== false or strpos($address, "\r") !== false) { - return false; - } - if (!$patternselect or $patternselect == 'auto') { - //Check this constant first so it works when extension_loaded() is disabled by safe mode - //Constant was added in PHP 5.2.4 - if (defined('PCRE_VERSION')) { - //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2 - if (version_compare(PCRE_VERSION, '8.0.3') >= 0) { - $patternselect = 'pcre8'; - } else { - $patternselect = 'pcre'; - } - } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) { - //Fall back to older PCRE - $patternselect = 'pcre'; - } else { - //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension - if (version_compare(PHP_VERSION, '5.2.0') >= 0) { - $patternselect = 'php'; - } else { - $patternselect = 'noregex'; - } - } - } - switch ($patternselect) { - case 'pcre8': - /** - * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains. - * @link http://squiloople.com/2009/12/20/email-address-validation/ - * @copyright 2009-2010 Michael Rushton - * Feel free to use and redistribute this code. But please keep this copyright notice. - */ - return (boolean)preg_match( - '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . - '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . - '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . - '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . - '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . - '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . - '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . - '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . - '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', - $address - ); - case 'pcre': - //An older regex that doesn't need a recent PCRE - return (boolean)preg_match( - '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . - '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' . - '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' . - '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' . - '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' . - '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' . - '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' . - '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' . - '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' . - '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', - $address - ); - case 'html5': - /** - * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. - * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) - */ - return (boolean)preg_match( - '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . - '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', - $address - ); - case 'noregex': - //No PCRE! Do something _very_ approximate! - //Check the address is 3 chars or longer and contains an @ that's not the first or last char - return (strlen($address) >= 3 - and strpos($address, '@') >= 1 - and strpos($address, '@') != strlen($address) - 1); - case 'php': - default: - return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL); - } - } - - /** - * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the - * "intl" and "mbstring" PHP extensions. - * @return bool "true" if required functions for IDN support are present - */ - public function idnSupported() - { - // @TODO: Write our own "idn_to_ascii" function for PHP <= 5.2. - return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding'); - } - - /** - * Converts IDN in given email address to its ASCII form, also known as punycode, if possible. - * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet. - * This function silently returns unmodified address if: - * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form) - * - Conversion to punycode is impossible (e.g. required PHP functions are not available) - * or fails for any reason (e.g. domain has characters not allowed in an IDN) - * @see PHPMailer::$CharSet - * @param string $address The email address to convert - * @return string The encoded address in ASCII form - */ - public function punyencodeAddress($address) - { - // Verify we have required functions, CharSet, and at-sign. - if ($this->idnSupported() and - !empty($this->CharSet) and - ($pos = strrpos($address, '@')) !== false) { - $domain = substr($address, ++$pos); - // Verify CharSet string is a valid one, and domain properly encoded in this CharSet. - if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { - $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet); - if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ? - idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : - idn_to_ascii($domain)) !== false) { - return substr($address, 0, $pos) . $punycode; - } - } - } - return $address; - } - - /** - * Create a message and send it. - * Uses the sending method specified by $Mailer. - * @throws phpmailerException - * @return boolean false on error - See the ErrorInfo property for details of the error. - */ - public function send() - { - try { - if (!$this->preSend()) { - return false; - } - return $this->postSend(); - } catch (phpmailerException $exc) { - $this->mailHeader = ''; - $this->setError($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - return false; - } - } - - /** - * Prepare a message for sending. - * @throws phpmailerException - * @return boolean - */ - public function preSend() - { - try { - $this->error_count = 0; // Reset errors - $this->mailHeader = ''; - - // Dequeue recipient and Reply-To addresses with IDN - foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { - $params[1] = $this->punyencodeAddress($params[1]); - call_user_func_array(array($this, 'addAnAddress'), $params); - } - if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL); - } - - // Validate From, Sender, and ConfirmReadingTo addresses - foreach (array('From', 'Sender', 'ConfirmReadingTo') as $address_kind) { - $this->$address_kind = trim($this->$address_kind); - if (empty($this->$address_kind)) { - continue; - } - $this->$address_kind = $this->punyencodeAddress($this->$address_kind); - if (!$this->validateAddress($this->$address_kind)) { - $error_message = $this->lang('invalid_address') . ' (punyEncode) ' . $this->$address_kind; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - } - - // Set whether the message is multipart/alternative - if ($this->alternativeExists()) { - $this->ContentType = 'multipart/alternative'; - } - - $this->setMessageType(); - // Refuse to send an empty message unless we are specifically allowing it - if (!$this->AllowEmpty and empty($this->Body)) { - throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL); - } - - // Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) - $this->MIMEHeader = ''; - $this->MIMEBody = $this->createBody(); - // createBody may have added some headers, so retain them - $tempheaders = $this->MIMEHeader; - $this->MIMEHeader = $this->createHeader(); - $this->MIMEHeader .= $tempheaders; - - // To capture the complete message when using mail(), create - // an extra header list which createHeader() doesn't fold in - if ($this->Mailer == 'mail') { - if (count($this->to) > 0) { - $this->mailHeader .= $this->addrAppend('To', $this->to); - } else { - $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); - } - $this->mailHeader .= $this->headerLine( - 'Subject', - $this->encodeHeader($this->secureHeader(trim($this->Subject))) - ); - } - - // Sign with DKIM if enabled - if (!empty($this->DKIM_domain) - && !empty($this->DKIM_selector) - && (!empty($this->DKIM_private_string) - || (!empty($this->DKIM_private) && file_exists($this->DKIM_private)) - ) - ) { - $header_dkim = $this->DKIM_Add( - $this->MIMEHeader . $this->mailHeader, - $this->encodeHeader($this->secureHeader($this->Subject)), - $this->MIMEBody - ); - $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . - str_replace("\r\n", "\n", $header_dkim) . self::CRLF; - } - return true; - } catch (phpmailerException $exc) { - $this->setError($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - return false; - } - } - - /** - * Actually send a message. - * Send the email via the selected mechanism - * @throws phpmailerException - * @return boolean - */ - public function postSend() - { - try { - // Choose the mailer and send through it - switch ($this->Mailer) { - case 'sendmail': - case 'qmail': - return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); - case 'smtp': - return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); - case 'mail': - return $this->mailSend($this->MIMEHeader, $this->MIMEBody); - default: - $sendMethod = $this->Mailer.'Send'; - if (method_exists($this, $sendMethod)) { - return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); - } - - return $this->mailSend($this->MIMEHeader, $this->MIMEBody); - } - } catch (phpmailerException $exc) { - $this->setError($exc->getMessage()); - $this->edebug($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - } - return false; - } - - /** - * Send mail using the $Sendmail program. - * @param string $header The message headers - * @param string $body The message body - * @see PHPMailer::$Sendmail - * @throws phpmailerException - * @access protected - * @return boolean - */ - protected function sendmailSend($header, $body) - { - // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (!empty($this->Sender) and self::isShellSafe($this->Sender)) { - if ($this->Mailer == 'qmail') { - $sendmailFmt = '%s -f%s'; - } else { - $sendmailFmt = '%s -oi -f%s -t'; - } - } else { - if ($this->Mailer == 'qmail') { - $sendmailFmt = '%s'; - } else { - $sendmailFmt = '%s -oi -t'; - } - } - - // TODO: If possible, this should be changed to escapeshellarg. Needs thorough testing. - $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); - - if ($this->SingleTo) { - foreach ($this->SingleToArray as $toAddr) { - if (!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - fputs($mail, 'To: ' . $toAddr . "\n"); - fputs($mail, $header); - fputs($mail, $body); - $result = pclose($mail); - $this->doCallback( - ($result == 0), - array($toAddr), - $this->cc, - $this->bcc, - $this->Subject, - $body, - $this->From - ); - if ($result != 0) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - } - } else { - if (!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - fputs($mail, $header); - fputs($mail, $body); - $result = pclose($mail); - $this->doCallback( - ($result == 0), - $this->to, - $this->cc, - $this->bcc, - $this->Subject, - $body, - $this->From - ); - if ($result != 0) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - } - return true; - } - - /** - * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. - * - * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. - * @param string $string The string to be validated - * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report - * @access protected - * @return boolean - */ - protected static function isShellSafe($string) - { - // Future-proof - if (escapeshellcmd($string) !== $string - or !in_array(escapeshellarg($string), array("'$string'", "\"$string\"")) - ) { - return false; - } - - $length = strlen($string); - - for ($i = 0; $i < $length; $i++) { - $c = $string[$i]; - - // All other characters have a special meaning in at least one common shell, including = and +. - // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. - // Note that this does permit non-Latin alphanumeric characters based on the current locale. - if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { - return false; - } - } - - return true; - } - - /** - * Send mail using the PHP mail() function. - * @param string $header The message headers - * @param string $body The message body - * @link http://www.php.net/manual/en/book.mail.php - * @throws phpmailerException - * @access protected - * @return boolean - */ - protected function mailSend($header, $body) - { - $toArr = array(); - foreach ($this->to as $toaddr) { - $toArr[] = $this->addrFormat($toaddr); - } - $to = implode(', ', $toArr); - - $params = null; - //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver - if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { - // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (self::isShellSafe($this->Sender)) { - $params = sprintf('-f%s', $this->Sender); - } - } - if (!empty($this->Sender) and !ini_get('safe_mode') and $this->validateAddress($this->Sender)) { - $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); - } - $result = false; - if ($this->SingleTo and count($toArr) > 1) { - foreach ($toArr as $toAddr) { - $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); - $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); - } - } else { - $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); - $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); - } - if (isset($old_from)) { - ini_set('sendmail_from', $old_from); - } - if (!$result) { - throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL); - } - return true; - } - - /** - * Get an instance to use for SMTP operations. - * Override this function to load your own SMTP implementation - * @return SMTP - */ - public function getSMTPInstance() - { - if (!is_object($this->smtp)) { - $this->smtp = new SMTP; - } - return $this->smtp; - } - - /** - * Send mail via SMTP. - * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. - * Uses the PHPMailerSMTP class by default. - * @see PHPMailer::getSMTPInstance() to use a different class. - * @param string $header The message headers - * @param string $body The message body - * @throws phpmailerException - * @uses SMTP - * @access protected - * @return boolean - */ - protected function smtpSend($header, $body) - { - $bad_rcpt = array(); - if (!$this->smtpConnect($this->SMTPOptions)) { - throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); - } - if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { - $smtp_from = $this->Sender; - } else { - $smtp_from = $this->From; - } - if (!$this->smtp->mail($smtp_from)) { - $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); - throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL); - } - - // Attempt to send to all recipients - foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { - foreach ($togroup as $to) { - if (!$this->smtp->recipient($to[0])) { - $error = $this->smtp->getError(); - $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']); - $isSent = false; - } else { - $isSent = true; - } - $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); - } - } - - // Only send the DATA command if we have viable recipients - if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { - throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL); - } - if ($this->SMTPKeepAlive) { - $this->smtp->reset(); - } else { - $this->smtp->quit(); - $this->smtp->close(); - } - //Create error message for any bad addresses - if (count($bad_rcpt) > 0) { - $errstr = ''; - foreach ($bad_rcpt as $bad) { - $errstr .= $bad['to'] . ': ' . $bad['error']; - } - throw new phpmailerException( - $this->lang('recipients_failed') . $errstr, - self::STOP_CONTINUE - ); - } - return true; - } - - /** - * Initiate a connection to an SMTP server. - * Returns false if the operation failed. - * @param array $options An array of options compatible with stream_context_create() - * @uses SMTP - * @access public - * @throws phpmailerException - * @return boolean - */ - public function smtpConnect($options = null) - { - if (is_null($this->smtp)) { - $this->smtp = $this->getSMTPInstance(); - } - - //If no options are provided, use whatever is set in the instance - if (is_null($options)) { - $options = $this->SMTPOptions; - } - - // Already connected? - if ($this->smtp->connected()) { - return true; - } - - $this->smtp->setTimeout($this->Timeout); - $this->smtp->setDebugLevel($this->SMTPDebug); - $this->smtp->setDebugOutput($this->Debugoutput); - $this->smtp->setVerp($this->do_verp); - $hosts = explode(';', $this->Host); - $lastexception = null; - - foreach ($hosts as $hostentry) { - $hostinfo = array(); - if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { - // Not a valid host entry - continue; - } - // $hostinfo[2]: optional ssl or tls prefix - // $hostinfo[3]: the hostname - // $hostinfo[4]: optional port number - // The host string prefix can temporarily override the current setting for SMTPSecure - // If it's not specified, the default value is used - $prefix = ''; - $secure = $this->SMTPSecure; - $tls = ($this->SMTPSecure == 'tls'); - if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) { - $prefix = 'ssl://'; - $tls = false; // Can't have SSL and TLS at the same time - $secure = 'ssl'; - } elseif ($hostinfo[2] == 'tls') { - $tls = true; - // tls doesn't use a prefix - $secure = 'tls'; - } - //Do we need the OpenSSL extension? - $sslext = defined('OPENSSL_ALGO_SHA1'); - if ('tls' === $secure or 'ssl' === $secure) { - //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled - if (!$sslext) { - throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); - } - } - $host = $hostinfo[3]; - $port = $this->Port; - $tport = (integer)$hostinfo[4]; - if ($tport > 0 and $tport < 65536) { - $port = $tport; - } - if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { - try { - if ($this->Helo) { - $hello = $this->Helo; - } else { - $hello = $this->serverHostname(); - } - $this->smtp->hello($hello); - //Automatically enable TLS encryption if: - // * it's not disabled - // * we have openssl extension - // * we are not already using SSL - // * the server offers STARTTLS - if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) { - $tls = true; - } - if ($tls) { - if (!$this->smtp->startTLS()) { - throw new phpmailerException($this->lang('connect_host')); - } - // We must resend EHLO after TLS negotiation - $this->smtp->hello($hello); - } - if ($this->SMTPAuth) { - if (!$this->smtp->authenticate( - $this->Username, - $this->Password, - $this->AuthType, - $this->Realm, - $this->Workstation - ) - ) { - throw new phpmailerException($this->lang('authenticate')); - } - } - return true; - } catch (phpmailerException $exc) { - $lastexception = $exc; - $this->edebug($exc->getMessage()); - // We must have connected, but then failed TLS or Auth, so close connection nicely - $this->smtp->quit(); - } - } - } - // If we get here, all connection attempts have failed, so close connection hard - $this->smtp->close(); - // As we've caught all exceptions, just report whatever the last one was - if ($this->exceptions and !is_null($lastexception)) { - throw $lastexception; - } - return false; - } - - /** - * Close the active SMTP session if one exists. - * @return void - */ - public function smtpClose() - { - if (is_a($this->smtp, 'SMTP')) { - if ($this->smtp->connected()) { - $this->smtp->quit(); - $this->smtp->close(); - } - } - } - - /** - * Set the language for error messages. - * Returns false if it cannot load the language file. - * The default language is English. - * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") - * @param string $lang_path Path to the language file directory, with trailing separator (slash) - * @return boolean - * @access public - */ - public function setLanguage($langcode = 'en', $lang_path = '') - { - // Backwards compatibility for renamed language codes - $renamed_langcodes = array( - 'br' => 'pt_br', - 'cz' => 'cs', - 'dk' => 'da', - 'no' => 'nb', - 'se' => 'sv', - ); - - if (isset($renamed_langcodes[$langcode])) { - $langcode = $renamed_langcodes[$langcode]; - } - - // Define full set of translatable strings in English - $PHPMAILER_LANG = array( - 'authenticate' => 'SMTP Error: Could not authenticate.', - 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', - 'data_not_accepted' => 'SMTP Error: data not accepted.', - 'empty_message' => 'Message body empty', - 'encoding' => 'Unknown encoding: ', - 'execute' => 'Could not execute: ', - 'file_access' => 'Could not access file: ', - 'file_open' => 'File Error: Could not open file: ', - 'from_failed' => 'The following From address failed: ', - 'instantiate' => 'Could not instantiate mail function.', - 'invalid_address' => 'Invalid address: ', - 'mailer_not_supported' => ' mailer is not supported.', - 'provide_address' => 'You must provide at least one recipient email address.', - 'recipients_failed' => 'SMTP Error: The following recipients failed: ', - 'signing' => 'Signing Error: ', - 'smtp_connect_failed' => 'SMTP connect() failed.', - 'smtp_error' => 'SMTP server error: ', - 'variable_set' => 'Cannot set or reset variable: ', - 'extension_missing' => 'Extension missing: ' - ); - if (empty($lang_path)) { - // Calculate an absolute path so it can work if CWD is not here - $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR; - } - //Validate $langcode - if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { - $langcode = 'en'; - } - $foundlang = true; - $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; - // There is no English translation file - if ($langcode != 'en') { - // Make sure language file path is readable - if (!is_readable($lang_file)) { - $foundlang = false; - } else { - // Overwrite language-specific strings. - // This way we'll never have missing translation keys. - $foundlang = include $lang_file; - } - } - $this->language = $PHPMAILER_LANG; - return (boolean)$foundlang; // Returns false if language not found - } - - /** - * Get the array of strings for the current language. - * @return array - */ - public function getTranslations() - { - return $this->language; - } - - /** - * Create recipient headers. - * @access public - * @param string $type - * @param array $addr An array of recipient, - * where each recipient is a 2-element indexed array with element 0 containing an address - * and element 1 containing a name, like: - * array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User')) - * @return string - */ - public function addrAppend($type, $addr) - { - $addresses = array(); - foreach ($addr as $address) { - $addresses[] = $this->addrFormat($address); - } - return $type . ': ' . implode(', ', $addresses) . $this->LE; - } - - /** - * Format an address for use in a message header. - * @access public - * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name - * like array('joe@example.com', 'Joe User') - * @return string - */ - public function addrFormat($addr) - { - if (empty($addr[1])) { // No name provided - return $this->secureHeader($addr[0]); - } else { - return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( - $addr[0] - ) . '>'; - } - } - - /** - * Word-wrap message. - * For use with mailers that do not automatically perform wrapping - * and for quoted-printable encoded messages. - * Original written by philippe. - * @param string $message The message to wrap - * @param integer $length The line length to wrap to - * @param boolean $qp_mode Whether to run in Quoted-Printable mode - * @access public - * @return string - */ - public function wrapText($message, $length, $qp_mode = false) - { - if ($qp_mode) { - $soft_break = sprintf(' =%s', $this->LE); - } else { - $soft_break = $this->LE; - } - // If utf-8 encoding is used, we will need to make sure we don't - // split multibyte characters when we wrap - $is_utf8 = (strtolower($this->CharSet) == 'utf-8'); - $lelen = strlen($this->LE); - $crlflen = strlen(self::CRLF); - - $message = $this->fixEOL($message); - //Remove a trailing line break - if (substr($message, -$lelen) == $this->LE) { - $message = substr($message, 0, -$lelen); - } - - //Split message into lines - $lines = explode($this->LE, $message); - //Message will be rebuilt in here - $message = ''; - foreach ($lines as $line) { - $words = explode(' ', $line); - $buf = ''; - $firstword = true; - foreach ($words as $word) { - if ($qp_mode and (strlen($word) > $length)) { - $space_left = $length - strlen($buf) - $crlflen; - if (!$firstword) { - if ($space_left > 20) { - $len = $space_left; - if ($is_utf8) { - $len = $this->utf8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == '=') { - $len--; - } elseif (substr($word, $len - 2, 1) == '=') { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - $buf .= ' ' . $part; - $message .= $buf . sprintf('=%s', self::CRLF); - } else { - $message .= $buf . $soft_break; - } - $buf = ''; - } - while (strlen($word) > 0) { - if ($length <= 0) { - break; - } - $len = $length; - if ($is_utf8) { - $len = $this->utf8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == '=') { - $len--; - } elseif (substr($word, $len - 2, 1) == '=') { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - - if (strlen($word) > 0) { - $message .= $part . sprintf('=%s', self::CRLF); - } else { - $buf = $part; - } - } - } else { - $buf_o = $buf; - if (!$firstword) { - $buf .= ' '; - } - $buf .= $word; - - if (strlen($buf) > $length and $buf_o != '') { - $message .= $buf_o . $soft_break; - $buf = $word; - } - } - $firstword = false; - } - $message .= $buf . self::CRLF; - } - - return $message; - } - - /** - * Find the last character boundary prior to $maxLength in a utf-8 - * quoted-printable encoded string. - * Original written by Colin Brown. - * @access public - * @param string $encodedText utf-8 QP text - * @param integer $maxLength Find the last character boundary prior to this length - * @return integer - */ - public function utf8CharBoundary($encodedText, $maxLength) - { - $foundSplitPos = false; - $lookBack = 3; - while (!$foundSplitPos) { - $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); - $encodedCharPos = strpos($lastChunk, '='); - if (false !== $encodedCharPos) { - // Found start of encoded character byte within $lookBack block. - // Check the encoded byte value (the 2 chars after the '=') - $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); - $dec = hexdec($hex); - if ($dec < 128) { - // Single byte character. - // If the encoded char was found at pos 0, it will fit - // otherwise reduce maxLength to start of the encoded char - if ($encodedCharPos > 0) { - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - } - $foundSplitPos = true; - } elseif ($dec >= 192) { - // First byte of a multi byte character - // Reduce maxLength to split at start of character - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec < 192) { - // Middle byte of a multi byte character, look further back - $lookBack += 3; - } - } else { - // No encoded character found - $foundSplitPos = true; - } - } - return $maxLength; - } - - /** - * Apply word wrapping to the message body. - * Wraps the message body to the number of chars set in the WordWrap property. - * You should only do this to plain-text bodies as wrapping HTML tags may break them. - * This is called automatically by createBody(), so you don't need to call it yourself. - * @access public - * @return void - */ - public function setWordWrap() - { - if ($this->WordWrap < 1) { - return; - } - - switch ($this->message_type) { - case 'alt': - case 'alt_inline': - case 'alt_attach': - case 'alt_inline_attach': - $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap); - break; - default: - $this->Body = $this->wrapText($this->Body, $this->WordWrap); - break; - } - } - - /** - * Assemble message headers. - * @access public - * @return string The assembled headers - */ - public function createHeader() - { - $result = ''; - - if ($this->MessageDate == '') { - $this->MessageDate = self::rfcDate(); - } - $result .= $this->headerLine('Date', $this->MessageDate); - - // To be created automatically by mail() - if ($this->SingleTo) { - if ($this->Mailer != 'mail') { - foreach ($this->to as $toaddr) { - $this->SingleToArray[] = $this->addrFormat($toaddr); - } - } - } else { - if (count($this->to) > 0) { - if ($this->Mailer != 'mail') { - $result .= $this->addrAppend('To', $this->to); - } - } elseif (count($this->cc) == 0) { - $result .= $this->headerLine('To', 'undisclosed-recipients:;'); - } - } - - $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName))); - - // sendmail and mail() extract Cc from the header before sending - if (count($this->cc) > 0) { - $result .= $this->addrAppend('Cc', $this->cc); - } - - // sendmail and mail() extract Bcc from the header before sending - if (( - $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail' - ) - and count($this->bcc) > 0 - ) { - $result .= $this->addrAppend('Bcc', $this->bcc); - } - - if (count($this->ReplyTo) > 0) { - $result .= $this->addrAppend('Reply-To', $this->ReplyTo); - } - - // mail() sets the subject itself - if ($this->Mailer != 'mail') { - $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); - } - - // Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4 - // https://tools.ietf.org/html/rfc5322#section-3.6.4 - if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) { - $this->lastMessageID = $this->MessageID; - } else { - $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname()); - } - $result .= $this->headerLine('Message-ID', $this->lastMessageID); - if (!is_null($this->Priority)) { - $result .= $this->headerLine('X-Priority', $this->Priority); - } - if ($this->XMailer == '') { - $result .= $this->headerLine( - 'X-Mailer', - 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer)' - ); - } else { - $myXmailer = trim($this->XMailer); - if ($myXmailer) { - $result .= $this->headerLine('X-Mailer', $myXmailer); - } - } - - if ($this->ConfirmReadingTo != '') { - $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); - } - - // Add custom headers - foreach ($this->CustomHeader as $header) { - $result .= $this->headerLine( - trim($header[0]), - $this->encodeHeader(trim($header[1])) - ); - } - if (!$this->sign_key_file) { - $result .= $this->headerLine('MIME-Version', '1.0'); - $result .= $this->getMailMIME(); - } - - return $result; - } - - /** - * Get the message MIME type headers. - * @access public - * @return string - */ - public function getMailMIME() - { - $result = ''; - $ismultipart = true; - switch ($this->message_type) { - 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; - default: - // Catches case 'plain': and case '': - $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); - $ismultipart = false; - break; - } - // RFC1341 part 5 says 7bit is assumed if not specified - if ($this->Encoding != '7bit') { - // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE - if ($ismultipart) { - if ($this->Encoding == '8bit') { - $result .= $this->headerLine('Content-Transfer-Encoding', '8bit'); - } - // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible - } else { - $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); - } - } - - if ($this->Mailer != 'mail') { - $result .= $this->LE; - } - - return $result; - } - - /** - * Returns the whole MIME message. - * Includes complete headers and body. - * Only valid post preSend(). - * @see PHPMailer::preSend() - * @access public - * @return string - */ - public function getSentMIMEMessage() - { - return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . self::CRLF . self::CRLF . $this->MIMEBody; - } - - /** - * Create unique ID - * @return string - */ - protected function generateId() { - return md5(uniqid(time())); - } - - /** - * Assemble the message body. - * Returns an empty string on failure. - * @access public - * @throws phpmailerException - * @return string The assembled message body - */ - public function createBody() - { - $body = ''; - //Create unique IDs and preset boundaries - $this->uniqueid = $this->generateId(); - $this->boundary[1] = 'b1_' . $this->uniqueid; - $this->boundary[2] = 'b2_' . $this->uniqueid; - $this->boundary[3] = 'b3_' . $this->uniqueid; - - if ($this->sign_key_file) { - $body .= $this->getMailMIME() . $this->LE; - } - - $this->setWordWrap(); - - $bodyEncoding = $this->Encoding; - $bodyCharSet = $this->CharSet; - //Can we do a 7-bit downgrade? - if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) { - $bodyEncoding = '7bit'; - //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit - $bodyCharSet = 'us-ascii'; - } - //If lines are too long, and we're not already using an encoding that will shorten them, - //change to quoted-printable transfer encoding for the body part only - if ('base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) { - $bodyEncoding = 'quoted-printable'; - } - - $altBodyEncoding = $this->Encoding; - $altBodyCharSet = $this->CharSet; - //Can we do a 7-bit downgrade? - if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) { - $altBodyEncoding = '7bit'; - //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit - $altBodyCharSet = 'us-ascii'; - } - //If lines are too long, and we're not already using an encoding that will shorten them, - //change to quoted-printable transfer encoding for the alt body part only - if ('base64' != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) { - $altBodyEncoding = 'quoted-printable'; - } - //Use this as a preamble in all multipart message types - $mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE; - switch ($this->message_type) { - case 'inline': - $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('inline', $this->boundary[1]); - break; - case 'attach': - $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('attachment', $this->boundary[1]); - break; - case 'inline_attach': - $body .= $mimepre; - $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], $bodyCharSet, '', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $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 .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - if (!empty($this->Ical)) { - $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', ''); - $body .= $this->encodeString($this->Ical, $this->Encoding); - $body .= $this->LE . $this->LE; - } - $body .= $this->endBoundary($this->boundary[1]); - break; - case 'alt_inline': - $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $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], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('inline', $this->boundary[2]); - $body .= $this->LE; - $body .= $this->endBoundary($this->boundary[1]); - break; - case 'alt_attach': - $body .= $mimepre; - $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], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->endBoundary($this->boundary[2]); - $body .= $this->LE; - $body .= $this->attachAll('attachment', $this->boundary[1]); - break; - case 'alt_inline_attach': - $body .= $mimepre; - $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], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $body .= $this->LE . $this->LE; - $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], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('inline', $this->boundary[3]); - $body .= $this->LE; - $body .= $this->endBoundary($this->boundary[2]); - $body .= $this->LE; - $body .= $this->attachAll('attachment', $this->boundary[1]); - break; - default: - // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types - //Reset the `Encoding` property in case we changed it for line length reasons - $this->Encoding = $bodyEncoding; - $body .= $this->encodeString($this->Body, $this->Encoding); - break; - } - - if ($this->isError()) { - $body = ''; - } elseif ($this->sign_key_file) { - try { - if (!defined('PKCS7_TEXT')) { - throw new phpmailerException($this->lang('extension_missing') . 'openssl'); - } - // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 - $file = tempnam(sys_get_temp_dir(), 'mail'); - if (false === file_put_contents($file, $body)) { - throw new phpmailerException($this->lang('signing') . ' Could not write temp file'); - } - $signed = tempnam(sys_get_temp_dir(), 'signed'); - //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 - if (empty($this->sign_extracerts_file)) { - $sign = @openssl_pkcs7_sign( - $file, - $signed, - 'file://' . realpath($this->sign_cert_file), - array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), - null - ); - } else { - $sign = @openssl_pkcs7_sign( - $file, - $signed, - 'file://' . realpath($this->sign_cert_file), - array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), - null, - PKCS7_DETACHED, - $this->sign_extracerts_file - ); - } - if ($sign) { - @unlink($file); - $body = file_get_contents($signed); - @unlink($signed); - //The message returned by openssl contains both headers and body, so need to split them up - $parts = explode("\n\n", $body, 2); - $this->MIMEHeader .= $parts[0] . $this->LE . $this->LE; - $body = $parts[1]; - } else { - @unlink($file); - @unlink($signed); - throw new phpmailerException($this->lang('signing') . openssl_error_string()); - } - } catch (phpmailerException $exc) { - $body = ''; - if ($this->exceptions) { - throw $exc; - } - } - } - return $body; - } - - /** - * Return the start of a message boundary. - * @access protected - * @param string $boundary - * @param string $charSet - * @param string $contentType - * @param string $encoding - * @return string - */ - protected function getBoundary($boundary, $charSet, $contentType, $encoding) - { - $result = ''; - if ($charSet == '') { - $charSet = $this->CharSet; - } - if ($contentType == '') { - $contentType = $this->ContentType; - } - if ($encoding == '') { - $encoding = $this->Encoding; - } - $result .= $this->textLine('--' . $boundary); - $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); - $result .= $this->LE; - // RFC1341 part 5 says 7bit is assumed if not specified - if ($encoding != '7bit') { - $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); - } - $result .= $this->LE; - - return $result; - } - - /** - * Return the end of a message boundary. - * @access protected - * @param string $boundary - * @return string - */ - protected function endBoundary($boundary) - { - return $this->LE . '--' . $boundary . '--' . $this->LE; - } - - /** - * Set the message type. - * PHPMailer only supports some preset message types, not arbitrary MIME structures. - * @access protected - * @return void - */ - protected function setMessageType() - { - $type = array(); - if ($this->alternativeExists()) { - $type[] = 'alt'; - } - if ($this->inlineImageExists()) { - $type[] = 'inline'; - } - if ($this->attachmentExists()) { - $type[] = 'attach'; - } - $this->message_type = implode('_', $type); - if ($this->message_type == '') { - //The 'plain' message_type refers to the message having a single body element, not that it is plain-text - $this->message_type = 'plain'; - } - } - - /** - * Format a header line. - * @access public - * @param string $name - * @param string $value - * @return string - */ - public function headerLine($name, $value) - { - return $name . ': ' . $value . $this->LE; - } - - /** - * Return a formatted mail line. - * @access public - * @param string $value - * @return string - */ - public function textLine($value) - { - return $value . $this->LE; - } - - /** - * Add an attachment from a path on the filesystem. - * Returns false if the file could not be found or read. - * @param string $path Path to the attachment. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @param string $disposition Disposition to use - * @throws phpmailerException - * @return boolean - */ - public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') - { - try { - if (!@is_file($path)) { - throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); - } - - // If a MIME type is not specified, try to work it out from the file name - if ($type == '') { - $type = self::filenameToType($path); - } - - $filename = basename($path); - if ($name == '') { - $name = $filename; - } - - $this->attachment[] = array( - 0 => $path, - 1 => $filename, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => false, // isStringAttachment - 6 => $disposition, - 7 => 0 - ); - - } catch (phpmailerException $exc) { - $this->setError($exc->getMessage()); - $this->edebug($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - return false; - } - return true; - } - - /** - * Return the array of attachments. - * @return array - */ - public function getAttachments() - { - return $this->attachment; - } - - /** - * Attach all file, string, and binary attachments to the message. - * Returns an empty string on failure. - * @access protected - * @param string $disposition_type - * @param string $boundary - * @return string - */ - protected function attachAll($disposition_type, $boundary) - { - // Return text of body - $mime = array(); - $cidUniq = array(); - $incl = array(); - - // Add all attachments - foreach ($this->attachment as $attachment) { - // Check if it is a valid disposition_filter - if ($attachment[6] == $disposition_type) { - // Check for string attachment - $string = ''; - $path = ''; - $bString = $attachment[5]; - if ($bString) { - $string = $attachment[0]; - } else { - $path = $attachment[0]; - } - - $inclhash = md5(serialize($attachment)); - if (in_array($inclhash, $incl)) { - continue; - } - $incl[] = $inclhash; - $name = $attachment[2]; - $encoding = $attachment[3]; - $type = $attachment[4]; - $disposition = $attachment[6]; - $cid = $attachment[7]; - if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) { - continue; - } - $cidUniq[$cid] = true; - - $mime[] = sprintf('--%s%s', $boundary, $this->LE); - //Only include a filename property if we have one - if (!empty($name)) { - $mime[] = sprintf( - 'Content-Type: %s; name="%s"%s', - $type, - $this->encodeHeader($this->secureHeader($name)), - $this->LE - ); - } else { - $mime[] = sprintf( - 'Content-Type: %s%s', - $type, - $this->LE - ); - } - // RFC1341 part 5 says 7bit is assumed if not specified - if ($encoding != '7bit') { - $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE); - } - - if ($disposition == 'inline') { - $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE); - } - - // If a filename contains any of these chars, it should be quoted, - // but not otherwise: RFC2183 & RFC2045 5.1 - // Fixes a warning in IETF's msglint MIME checker - // Allow for bypassing the Content-Disposition header totally - if (!(empty($disposition))) { - $encoded_name = $this->encodeHeader($this->secureHeader($name)); - if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) { - $mime[] = sprintf( - 'Content-Disposition: %s; filename="%s"%s', - $disposition, - $encoded_name, - $this->LE . $this->LE - ); - } else { - if (!empty($encoded_name)) { - $mime[] = sprintf( - 'Content-Disposition: %s; filename=%s%s', - $disposition, - $encoded_name, - $this->LE . $this->LE - ); - } else { - $mime[] = sprintf( - 'Content-Disposition: %s%s', - $disposition, - $this->LE . $this->LE - ); - } - } - } else { - $mime[] = $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 ''; - } - $mime[] = $this->LE . $this->LE; - } - } - } - - $mime[] = sprintf('--%s--%s', $boundary, $this->LE); - - return implode('', $mime); - } - - /** - * Encode a file attachment in requested format. - * Returns an empty string on failure. - * @param string $path The full path to the file - * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' - * @throws phpmailerException - * @access protected - * @return string - */ - protected function encodeFile($path, $encoding = 'base64') - { - try { - if (!is_readable($path)) { - throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE); - } - $magic_quotes = get_magic_quotes_runtime(); - if ($magic_quotes) { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - set_magic_quotes_runtime(false); - } else { - //Doesn't exist in PHP 5.4, but we don't need to check because - //get_magic_quotes_runtime always returns false in 5.4+ - //so it will never get here - ini_set('magic_quotes_runtime', false); - } - } - $file_buffer = file_get_contents($path); - $file_buffer = $this->encodeString($file_buffer, $encoding); - if ($magic_quotes) { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - set_magic_quotes_runtime($magic_quotes); - } else { - ini_set('magic_quotes_runtime', $magic_quotes); - } - } - return $file_buffer; - } catch (Exception $exc) { - $this->setError($exc->getMessage()); - return ''; - } - } - - /** - * Encode a string in requested format. - * Returns an empty string on failure. - * @param string $str The text to encode - * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' - * @access public - * @return string - */ - public function encodeString($str, $encoding = 'base64') - { - $encoded = ''; - switch (strtolower($encoding)) { - case 'base64': - $encoded = chunk_split(base64_encode($str), 76, $this->LE); - break; - case '7bit': - case '8bit': - $encoded = $this->fixEOL($str); - // Make sure it ends with a line break - if (substr($encoded, -(strlen($this->LE))) != $this->LE) { - $encoded .= $this->LE; - } - break; - case 'binary': - $encoded = $str; - break; - case 'quoted-printable': - $encoded = $this->encodeQP($str); - break; - default: - $this->setError($this->lang('encoding') . $encoding); - break; - } - return $encoded; - } - - /** - * Encode a header string optimally. - * Picks shortest of Q, B, quoted-printable or none. - * @access public - * @param string $str - * @param string $position - * @return string - */ - public function encodeHeader($str, $position = 'text') - { - $matchcount = 0; - switch (strtolower($position)) { - case 'phrase': - if (!preg_match('/[\200-\377]/', $str)) { - // Can't use addslashes as we don't know the value of magic_quotes_sybase - $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { - return ($encoded); - } else { - return ("\"$encoded\""); - } - } - $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); - break; - /** @noinspection PhpMissingBreakStatementInspection */ - case 'comment': - $matchcount = preg_match_all('/[()"]/', $str, $matches); - // Intentional fall-through - case 'text': - default: - $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); - break; - } - - //There are no chars that need encoding - if ($matchcount == 0) { - return ($str); - } - - $maxlen = 75 - 7 - strlen($this->CharSet); - // Try to select the encoding which should produce the shortest output - if ($matchcount > strlen($str) / 3) { - // More than a third of the content will need encoding, so B encoding will be most efficient - $encoding = 'B'; - if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) { - // Use a custom function which correctly encodes and wraps long - // multibyte strings without breaking lines within a character - $encoded = $this->base64EncodeWrapMB($str, "\n"); - } else { - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); - } - } else { - $encoding = 'Q'; - $encoded = $this->encodeQ($str, $position); - $encoded = $this->wrapText($encoded, $maxlen, true); - $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded)); - } - - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); - $encoded = trim(str_replace("\n", $this->LE, $encoded)); - - return $encoded; - } - - /** - * Check if a string contains multi-byte characters. - * @access public - * @param string $str multi-byte text to wrap encode - * @return boolean - */ - public function hasMultiBytes($str) - { - if (function_exists('mb_strlen')) { - return (strlen($str) > mb_strlen($str, $this->CharSet)); - } else { // Assume no multibytes (we can't handle without mbstring functions anyway) - return false; - } - } - - /** - * Does a string contain any 8-bit chars (in any charset)? - * @param string $text - * @return boolean - */ - public function has8bitChars($text) - { - return (boolean)preg_match('/[\x80-\xFF]/', $text); - } - - /** - * Encode and wrap long multibyte strings for mail headers - * without breaking lines within a character. - * Adapted from a function by paravoid - * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283 - * @access public - * @param string $str multi-byte text to wrap encode - * @param string $linebreak string to use as linefeed/end-of-line - * @return string - */ - public function base64EncodeWrapMB($str, $linebreak = null) - { - $start = '=?' . $this->CharSet . '?B?'; - $end = '?='; - $encoded = ''; - if ($linebreak === null) { - $linebreak = $this->LE; - } - - $mb_length = mb_strlen($str, $this->CharSet); - // Each line must have length <= 75, including $start and $end - $length = 75 - strlen($start) - strlen($end); - // Average multi-byte ratio - $ratio = $mb_length / strlen($str); - // Base64 has a 4:3 ratio - $avgLength = floor($length * $ratio * .75); - - for ($i = 0; $i < $mb_length; $i += $offset) { - $lookBack = 0; - do { - $offset = $avgLength - $lookBack; - $chunk = mb_substr($str, $i, $offset, $this->CharSet); - $chunk = base64_encode($chunk); - $lookBack++; - } while (strlen($chunk) > $length); - $encoded .= $chunk . $linebreak; - } - - // Chomp the last linefeed - $encoded = substr($encoded, 0, -strlen($linebreak)); - return $encoded; - } - - /** - * Encode a string in quoted-printable format. - * According to RFC2045 section 6.7. - * @access public - * @param string $string The text to encode - * @param integer $line_max Number of chars allowed on a line before wrapping - * @return string - * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment - */ - public function encodeQP($string, $line_max = 76) - { - // Use native function if it's available (>= PHP5.3) - if (function_exists('quoted_printable_encode')) { - return quoted_printable_encode($string); - } - // Fall back to a pure PHP implementation - $string = str_replace( - array('%20', '%0D%0A.', '%0D%0A', '%'), - array(' ', "\r\n=2E", "\r\n", '='), - rawurlencode($string) - ); - return preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string); - } - - /** - * Backward compatibility wrapper for an old QP encoding function that was removed. - * @see PHPMailer::encodeQP() - * @access public - * @param string $string - * @param integer $line_max - * @param boolean $space_conv - * @return string - * @deprecated Use encodeQP instead. - */ - public function encodeQPphp( - $string, - $line_max = 76, - /** @noinspection PhpUnusedParameterInspection */ $space_conv = false - ) { - return $this->encodeQP($string, $line_max); - } - - /** - * Encode a string using Q encoding. - * @link http://tools.ietf.org/html/rfc2047 - * @param string $str the text to encode - * @param string $position Where the text is going to be used, see the RFC for what that means - * @access public - * @return string - */ - public function encodeQ($str, $position = 'text') - { - // There should not be any EOL in the string - $pattern = ''; - $encoded = str_replace(array("\r", "\n"), '', $str); - switch (strtolower($position)) { - case 'phrase': - // RFC 2047 section 5.3 - $pattern = '^A-Za-z0-9!*+\/ -'; - break; - /** @noinspection PhpMissingBreakStatementInspection */ - case 'comment': - // RFC 2047 section 5.2 - $pattern = '\(\)"'; - // intentional fall-through - // for this reason we build the $pattern without including delimiters and [] - case 'text': - default: - // RFC 2047 section 5.1 - // Replace every high ascii, control, =, ? and _ characters - $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; - break; - } - $matches = array(); - if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { - // If the string contains an '=', make sure it's the first thing we replace - // so as to avoid double-encoding - $eqkey = array_search('=', $matches[0]); - if (false !== $eqkey) { - unset($matches[0][$eqkey]); - array_unshift($matches[0], '='); - } - foreach (array_unique($matches[0]) as $char) { - $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); - } - } - // Replace every spaces to _ (more readable than =20) - return str_replace(' ', '_', $encoded); - } - - /** - * Add a string or binary attachment (non-filesystem). - * This method can be used to attach ascii or binary data, - * such as a BLOB record from a database. - * @param string $string String attachment data. - * @param string $filename Name of the attachment. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @param string $disposition Disposition to use - * @return void - */ - public function addStringAttachment( - $string, - $filename, - $encoding = 'base64', - $type = '', - $disposition = 'attachment' - ) { - // If a MIME type is not specified, try to work it out from the file name - if ($type == '') { - $type = self::filenameToType($filename); - } - // Append to $attachment array - $this->attachment[] = array( - 0 => $string, - 1 => $filename, - 2 => basename($filename), - 3 => $encoding, - 4 => $type, - 5 => true, // isStringAttachment - 6 => $disposition, - 7 => 0 - ); - } - - /** - * Add an embedded (inline) attachment from a file. - * This can include images, sounds, and just about any other document type. - * These differ from 'regular' attachments in that they are intended to be - * displayed inline with the message, not just attached for download. - * This is used in HTML messages that embed the images - * the HTML refers to using the $cid value. - * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment; Use this to reference - * the content when using an embedded image in HTML. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File MIME type. - * @param string $disposition Disposition to use - * @return boolean True on successfully adding an attachment - */ - public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') - { - if (!@is_file($path)) { - $this->setError($this->lang('file_access') . $path); - return false; - } - - // If a MIME type is not specified, try to work it out from the file name - if ($type == '') { - $type = self::filenameToType($path); - } - - $filename = basename($path); - if ($name == '') { - $name = $filename; - } - - // Append to $attachment array - $this->attachment[] = array( - 0 => $path, - 1 => $filename, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => false, // isStringAttachment - 6 => $disposition, - 7 => $cid - ); - return true; - } - - /** - * Add an embedded stringified attachment. - * This can include images, sounds, and just about any other document type. - * Be sure to set the $type to an image type for images: - * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'. - * @param string $string The attachment binary data. - * @param string $cid Content ID of the attachment; Use this to reference - * the content when using an embedded image in HTML. - * @param string $name - * @param string $encoding File encoding (see $Encoding). - * @param string $type MIME type. - * @param string $disposition Disposition to use - * @return boolean True on successfully adding an attachment - */ - public function addStringEmbeddedImage( - $string, - $cid, - $name = '', - $encoding = 'base64', - $type = '', - $disposition = 'inline' - ) { - // If a MIME type is not specified, try to work it out from the name - if ($type == '' and !empty($name)) { - $type = self::filenameToType($name); - } - - // Append to $attachment array - $this->attachment[] = array( - 0 => $string, - 1 => $name, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => true, // isStringAttachment - 6 => $disposition, - 7 => $cid - ); - return true; - } - - /** - * Check if an inline attachment is present. - * @access public - * @return boolean - */ - public function inlineImageExists() - { - foreach ($this->attachment as $attachment) { - if ($attachment[6] == 'inline') { - return true; - } - } - return false; - } - - /** - * Check if an attachment (non-inline) is present. - * @return boolean - */ - public function attachmentExists() - { - foreach ($this->attachment as $attachment) { - if ($attachment[6] == 'attachment') { - return true; - } - } - return false; - } - - /** - * Check if this message has an alternative body set. - * @return boolean - */ - public function alternativeExists() - { - return !empty($this->AltBody); - } - - /** - * Clear queued addresses of given kind. - * @access protected - * @param string $kind 'to', 'cc', or 'bcc' - * @return void - */ - public function clearQueuedAddresses($kind) - { - $RecipientsQueue = $this->RecipientsQueue; - foreach ($RecipientsQueue as $address => $params) { - if ($params[0] == $kind) { - unset($this->RecipientsQueue[$address]); - } - } - } - - /** - * Clear all To recipients. - * @return void - */ - public function clearAddresses() - { - foreach ($this->to as $to) { - unset($this->all_recipients[strtolower($to[0])]); - } - $this->to = array(); - $this->clearQueuedAddresses('to'); - } - - /** - * Clear all CC recipients. - * @return void - */ - public function clearCCs() - { - foreach ($this->cc as $cc) { - unset($this->all_recipients[strtolower($cc[0])]); - } - $this->cc = array(); - $this->clearQueuedAddresses('cc'); - } - - /** - * Clear all BCC recipients. - * @return void - */ - public function clearBCCs() - { - foreach ($this->bcc as $bcc) { - unset($this->all_recipients[strtolower($bcc[0])]); - } - $this->bcc = array(); - $this->clearQueuedAddresses('bcc'); - } - - /** - * Clear all ReplyTo recipients. - * @return void - */ - public function clearReplyTos() - { - $this->ReplyTo = array(); - $this->ReplyToQueue = array(); - } - - /** - * Clear all recipient types. - * @return void - */ - public function clearAllRecipients() - { - $this->to = array(); - $this->cc = array(); - $this->bcc = array(); - $this->all_recipients = array(); - $this->RecipientsQueue = array(); - } - - /** - * Clear all filesystem, string, and binary attachments. - * @return void - */ - public function clearAttachments() - { - $this->attachment = array(); - } - - /** - * Clear all custom headers. - * @return void - */ - public function clearCustomHeaders() - { - $this->CustomHeader = array(); - } - - /** - * Add an error message to the error container. - * @access protected - * @param string $msg - * @return void - */ - protected function setError($msg) - { - $this->error_count++; - if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { - $lasterror = $this->smtp->getError(); - if (!empty($lasterror['error'])) { - $msg .= $this->lang('smtp_error') . $lasterror['error']; - if (!empty($lasterror['detail'])) { - $msg .= ' Detail: '. $lasterror['detail']; - } - if (!empty($lasterror['smtp_code'])) { - $msg .= ' SMTP code: ' . $lasterror['smtp_code']; - } - if (!empty($lasterror['smtp_code_ex'])) { - $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; - } - } - } - $this->ErrorInfo = $msg; - } - - /** - * Return an RFC 822 formatted date. - * @access public - * @return string - * @static - */ - public static function rfcDate() - { - // Set the time zone to whatever the default is to avoid 500 errors - // Will default to UTC if it's not set properly in php.ini - date_default_timezone_set(@date_default_timezone_get()); - return date('D, j M Y H:i:s O'); - } - - /** - * Get the server hostname. - * Returns 'localhost.localdomain' if unknown. - * @access protected - * @return string - */ - protected function serverHostname() - { - $result = 'localhost.localdomain'; - if (!empty($this->Hostname)) { - $result = $this->Hostname; - } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) { - $result = $_SERVER['SERVER_NAME']; - } elseif (function_exists('gethostname') && gethostname() !== false) { - $result = gethostname(); - } elseif (php_uname('n') !== false) { - $result = php_uname('n'); - } - return $result; - } - - /** - * Get an error message in the current language. - * @access protected - * @param string $key - * @return string - */ - protected function lang($key) - { - if (count($this->language) < 1) { - $this->setLanguage('en'); // set the default language - } - - if (array_key_exists($key, $this->language)) { - if ($key == 'smtp_connect_failed') { - //Include a link to troubleshooting docs on SMTP connection failure - //this is by far the biggest cause of support questions - //but it's usually not PHPMailer's fault. - return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; - } - return $this->language[$key]; - } else { - //Return the key as a fallback - return $key; - } - } - - /** - * Check if an error occurred. - * @access public - * @return boolean True if an error did occur. - */ - public function isError() - { - return ($this->error_count > 0); - } - - /** - * Ensure consistent line endings in a string. - * Changes every end of line from CRLF, CR or LF to $this->LE. - * @access public - * @param string $str String to fixEOL - * @return string - */ - public function fixEOL($str) - { - // Normalise to \n - $nstr = str_replace(array("\r\n", "\r"), "\n", $str); - // Now convert LE as needed - if ($this->LE !== "\n") { - $nstr = str_replace("\n", $this->LE, $nstr); - } - return $nstr; - } - - /** - * Add a custom header. - * $name value can be overloaded to contain - * both header name and value (name:value) - * @access public - * @param string $name Custom header name - * @param string $value Header value - * @return void - */ - public function addCustomHeader($name, $value = null) - { - if ($value === null) { - // Value passed in as name:value - $this->CustomHeader[] = explode(':', $name, 2); - } else { - $this->CustomHeader[] = array($name, $value); - } - } - - /** - * Returns all custom headers. - * @return array - */ - public function getCustomHeaders() - { - return $this->CustomHeader; - } - - /** - * Create a message body from an HTML string. - * Automatically inlines images and creates a plain-text version by converting the HTML, - * overwriting any existing values in Body and AltBody. - * $basedir is used when handling relative image paths, e.g. - * will look for an image file in $basedir/images/a.png and convert it to inline. - * If you don't want to apply these transformations to your HTML, just set Body and AltBody yourself. - * @access public - * @param string $message HTML message string - * @param string $basedir base directory for relative paths to images - * @param boolean|callable $advanced Whether to use the internal HTML to text converter - * or your own custom converter @see PHPMailer::html2text() - * @return string $message The transformed message Body - */ - public function msgHTML($message, $basedir = '', $advanced = false) - { - preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images); - if (array_key_exists(2, $images)) { - foreach ($images[2] as $imgindex => $url) { - // Convert data URIs into embedded images - if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) { - $data = substr($url, strpos($url, ',')); - if ($match[2]) { - $data = base64_decode($data); - } else { - $data = rawurldecode($data); - } - $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 - if ($this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1])) { - $message = str_replace( - $images[0][$imgindex], - $images[1][$imgindex] . '="cid:' . $cid . '"', - $message - ); - } - } elseif (substr($url, 0, 4) !== 'cid:' && !preg_match('#^[a-z][a-z0-9+.-]*://#i', $url)) { - // Do not change urls for absolute images (thanks to corvuscorax) - // Do not change urls that are already inline images - $filename = basename($url); - $directory = dirname($url); - if ($directory == '.') { - $directory = ''; - } - $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 - if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { - $basedir .= '/'; - } - if (strlen($directory) > 1 && substr($directory, -1) != '/') { - $directory .= '/'; - } - if ($this->addEmbeddedImage( - $basedir . $directory . $filename, - $cid, - $filename, - 'base64', - self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION)) - ) - ) { - $message = preg_replace( - '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', - $images[1][$imgindex] . '="cid:' . $cid . '"', - $message - ); - } - } - } - } - $this->isHTML(true); - // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better - $this->Body = $this->normalizeBreaks($message); - $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced)); - if (!$this->alternativeExists()) { - $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . - self::CRLF . self::CRLF; - } - return $this->Body; - } - - /** - * Convert an HTML string into plain text. - * This is used by msgHTML(). - * Note - older versions of this function used a bundled advanced converter - * which was been removed for license reasons in #232. - * Example usage: - * - * // Use default conversion - * $plain = $mail->html2text($html); - * // Use your own custom converter - * $plain = $mail->html2text($html, function($html) { - * $converter = new MyHtml2text($html); - * return $converter->get_text(); - * }); - * - * @param string $html The HTML text to convert - * @param boolean|callable $advanced Any boolean value to use the internal converter, - * or provide your own callable for custom conversion. - * @return string - */ - public function html2text($html, $advanced = false) - { - if (is_callable($advanced)) { - return call_user_func($advanced, $html); - } - return html_entity_decode( - trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), - ENT_QUOTES, - $this->CharSet - ); - } - - /** - * Get the MIME type for a file extension. - * @param string $ext File extension - * @access public - * @return string MIME type of file. - * @static - */ - public static function _mime_types($ext = '') - { - $mimes = array( - 'xl' => 'application/excel', - 'js' => 'application/javascript', - 'hqx' => 'application/mac-binhex40', - 'cpt' => 'application/mac-compactpro', - 'bin' => 'application/macbinary', - 'doc' => 'application/msword', - 'word' => 'application/msword', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - 'class' => 'application/octet-stream', - 'dll' => 'application/octet-stream', - 'dms' => 'application/octet-stream', - 'exe' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'psd' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'so' => 'application/octet-stream', - 'oda' => 'application/oda', - 'pdf' => 'application/pdf', - 'ai' => 'application/postscript', - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'mif' => 'application/vnd.mif', - 'xls' => 'application/vnd.ms-excel', - 'ppt' => 'application/vnd.ms-powerpoint', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', - 'dvi' => 'application/x-dvi', - 'gtar' => 'application/x-gtar', - 'php3' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'php' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => 'application/x-tar', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'zip' => 'application/zip', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mpga' => 'audio/mpeg', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', - 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpeg' => 'image/jpeg', - 'jpe' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'png' => 'image/png', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'eml' => 'message/rfc822', - 'css' => 'text/css', - 'html' => 'text/html', - 'htm' => 'text/html', - 'shtml' => 'text/html', - 'log' => 'text/plain', - 'text' => 'text/plain', - 'txt' => 'text/plain', - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'vcf' => 'text/vcard', - 'vcard' => 'text/vcard', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'mpeg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mov' => 'video/quicktime', - 'qt' => 'video/quicktime', - 'rv' => 'video/vnd.rn-realvideo', - 'avi' => 'video/x-msvideo', - 'movie' => 'video/x-sgi-movie' - ); - if (array_key_exists(strtolower($ext), $mimes)) { - return $mimes[strtolower($ext)]; - } - return 'application/octet-stream'; - } - - /** - * Map a file name to a MIME type. - * Defaults to 'application/octet-stream', i.e.. arbitrary binary data. - * @param string $filename A file name or full path, does not need to exist as a file - * @return string - * @static - */ - public static function filenameToType($filename) - { - // In case the path is a URL, strip any query string before getting extension - $qpos = strpos($filename, '?'); - if (false !== $qpos) { - $filename = substr($filename, 0, $qpos); - } - $pathinfo = self::mb_pathinfo($filename); - return self::_mime_types($pathinfo['extension']); - } - - /** - * Multi-byte-safe pathinfo replacement. - * Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe. - * Works similarly to the one in PHP >= 5.2.0 - * @link http://www.php.net/manual/en/function.pathinfo.php#107461 - * @param string $path A filename or path, does not need to exist as a file - * @param integer|string $options Either a PATHINFO_* constant, - * or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2 - * @return string|array - * @static - */ - public static function mb_pathinfo($path, $options = null) - { - $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''); - $pathinfo = array(); - if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) { - if (array_key_exists(1, $pathinfo)) { - $ret['dirname'] = $pathinfo[1]; - } - if (array_key_exists(2, $pathinfo)) { - $ret['basename'] = $pathinfo[2]; - } - if (array_key_exists(5, $pathinfo)) { - $ret['extension'] = $pathinfo[5]; - } - if (array_key_exists(3, $pathinfo)) { - $ret['filename'] = $pathinfo[3]; - } - } - switch ($options) { - case PATHINFO_DIRNAME: - case 'dirname': - return $ret['dirname']; - case PATHINFO_BASENAME: - case 'basename': - return $ret['basename']; - case PATHINFO_EXTENSION: - case 'extension': - return $ret['extension']; - case PATHINFO_FILENAME: - case 'filename': - return $ret['filename']; - default: - return $ret; - } - } - - /** - * Set or reset instance properties. - * You should avoid this function - it's more verbose, less efficient, more error-prone and - * harder to debug than setting properties directly. - * Usage Example: - * `$mail->set('SMTPSecure', 'tls');` - * is the same as: - * `$mail->SMTPSecure = 'tls';` - * @access public - * @param string $name The property name to set - * @param mixed $value The value to set the property to - * @return boolean - * @TODO Should this not be using the __set() magic function? - */ - public function set($name, $value = '') - { - if (property_exists($this, $name)) { - $this->$name = $value; - return true; - } else { - $this->setError($this->lang('variable_set') . $name); - return false; - } - } - - /** - * Strip newlines to prevent header injection. - * @access public - * @param string $str - * @return string - */ - public function secureHeader($str) - { - return trim(str_replace(array("\r", "\n"), '', $str)); - } - - /** - * Normalize line breaks in a string. - * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format. - * Defaults to CRLF (for message bodies) and preserves consecutive breaks. - * @param string $text - * @param string $breaktype What kind of line break to use, defaults to CRLF - * @return string - * @access public - * @static - */ - public static function normalizeBreaks($text, $breaktype = "\r\n") - { - return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text); - } - - /** - * Set the public and private key files and password for S/MIME signing. - * @access public - * @param string $cert_filename - * @param string $key_filename - * @param string $key_pass Password for private key - * @param string $extracerts_filename Optional path to chain certificate - */ - public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '') - { - $this->sign_cert_file = $cert_filename; - $this->sign_key_file = $key_filename; - $this->sign_key_pass = $key_pass; - $this->sign_extracerts_file = $extracerts_filename; - } - - /** - * Quoted-Printable-encode a DKIM header. - * @access public - * @param string $txt - * @return string - */ - public function DKIM_QP($txt) - { - $line = ''; - for ($i = 0; $i < strlen($txt); $i++) { - $ord = ord($txt[$i]); - if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { - $line .= $txt[$i]; - } else { - $line .= '=' . sprintf('%02X', $ord); - } - } - return $line; - } - - /** - * Generate a DKIM signature. - * @access public - * @param string $signHeader - * @throws phpmailerException - * @return string The DKIM signature value - */ - public function DKIM_Sign($signHeader) - { - if (!defined('PKCS7_TEXT')) { - if ($this->exceptions) { - throw new phpmailerException($this->lang('extension_missing') . 'openssl'); - } - return ''; - } - $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private); - if ('' != $this->DKIM_passphrase) { - $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); - } else { - $privKey = openssl_pkey_get_private($privKeyStr); - } - //Workaround for missing digest algorithms in old PHP & OpenSSL versions - //@link http://stackoverflow.com/a/11117338/333340 - if (version_compare(PHP_VERSION, '5.3.0') >= 0 and - in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) { - if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) { - openssl_pkey_free($privKey); - return base64_encode($signature); - } - } else { - $pinfo = openssl_pkey_get_details($privKey); - $hash = hash('sha256', $signHeader); - //'Magic' constant for SHA256 from RFC3447 - //@link https://tools.ietf.org/html/rfc3447#page-43 - $t = '3031300d060960864801650304020105000420' . $hash; - $pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3); - $eb = pack('H*', '0001' . str_repeat('FF', $pslen) . '00' . $t); - - if (openssl_private_encrypt($eb, $signature, $privKey, OPENSSL_NO_PADDING)) { - openssl_pkey_free($privKey); - return base64_encode($signature); - } - } - openssl_pkey_free($privKey); - return ''; - } - - /** - * Generate a DKIM canonicalization header. - * @access public - * @param string $signHeader Header - * @return string - */ - public function DKIM_HeaderC($signHeader) - { - $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader); - $lines = explode("\r\n", $signHeader); - foreach ($lines as $key => $line) { - list($heading, $value) = explode(':', $line, 2); - $heading = strtolower($heading); - $value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces - $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value - } - $signHeader = implode("\r\n", $lines); - return $signHeader; - } - - /** - * Generate a DKIM canonicalization body. - * @access public - * @param string $body Message Body - * @return string - */ - 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); - // END stabilize line endings - while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { - $body = substr($body, 0, strlen($body) - 2); - } - return $body; - } - - /** - * Create the DKIM header and body in a new message header. - * @access public - * @param string $headers_line Header lines - * @param string $subject Subject - * @param string $body Body - * @return string - */ - public function DKIM_Add($headers_line, $subject, $body) - { - $DKIMsignatureType = 'rsa-sha256'; // 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($this->LE, $headers_line); - $from_header = ''; - $to_header = ''; - $date_header = ''; - $current = ''; - foreach ($headers as $header) { - if (strpos($header, 'From:') === 0) { - $from_header = $header; - $current = 'from_header'; - } elseif (strpos($header, 'To:') === 0) { - $to_header = $header; - $current = 'to_header'; - } elseif (strpos($header, 'Date:') === 0) { - $date_header = $header; - $current = 'date_header'; - } else { - if (!empty($$current) && strpos($header, ' =?') === 0) { - $$current .= $header; - } else { - $current = ''; - } - } - } - $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); - $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); - $date = str_replace('|', '=7C', $this->DKIM_QP($date_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*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body - if ('' == $this->DKIM_identity) { - $ident = ''; - } else { - $ident = ' i=' . $this->DKIM_identity . ';'; - } - $dkimhdrs = 'DKIM-Signature: v=1; a=' . - $DKIMsignatureType . '; q=' . - $DKIMquery . '; l=' . - $DKIMlen . '; s=' . - $this->DKIM_selector . - ";\r\n" . - "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . - "\th=From:To:Date:Subject;\r\n" . - "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . - "\tz=$from\r\n" . - "\t|$to\r\n" . - "\t|$date\r\n" . - "\t|$subject;\r\n" . - "\tbh=" . $DKIMb64 . ";\r\n" . - "\tb="; - $toSign = $this->DKIM_HeaderC( - $from_header . "\r\n" . - $to_header . "\r\n" . - $date_header . "\r\n" . - $subject_header . "\r\n" . - $dkimhdrs - ); - $signed = $this->DKIM_Sign($toSign); - return $dkimhdrs . $signed . "\r\n"; - } - - /** - * Detect if a string contains a line longer than the maximum line length allowed. - * @param string $str - * @return boolean - * @static - */ - public static function hasLineLongerThanMax($str) - { - //+2 to include CRLF line break for a 1000 total - return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str); - } - - /** - * Allows for public read access to 'to' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getToAddresses() - { - return $this->to; - } - - /** - * Allows for public read access to 'cc' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getCcAddresses() - { - return $this->cc; - } - - /** - * Allows for public read access to 'bcc' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getBccAddresses() - { - return $this->bcc; - } - - /** - * Allows for public read access to 'ReplyTo' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getReplyToAddresses() - { - return $this->ReplyTo; - } - - /** - * Allows for public read access to 'all_recipients' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getAllRecipientAddresses() - { - return $this->all_recipients; - } - - /** - * Perform a callback. - * @param boolean $isSent - * @param array $to - * @param array $cc - * @param array $bcc - * @param string $subject - * @param string $body - * @param string $from - */ - protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from) - { - if (!empty($this->action_function) && is_callable($this->action_function)) { - $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from); - call_user_func_array($this->action_function, $params); - } - } -} - -/** - * PHPMailer exception handler - * @package PHPMailer - */ -class phpmailerException extends Exception -{ - /** - * Prettify error message output - * @return string - */ - public function errorMessage() - { - $errorMsg = '' . $this->getMessage() . "
      \n"; - return $errorMsg; - } -} diff --git a/ansible-hook.php b/ansible-hook.php deleted file mode 100644 index e1787a3..0000000 --- a/ansible-hook.php +++ /dev/null @@ -1,46 +0,0 @@ - $ratelimit ) { - touch ( $ansible_dropfile ); - touch ( $ansible_lastrun ); - echo "HTTP 200 - Ansible webhook recieved."; - die(); - } - else { - http_response_code(429); - echo "HTTP 429 - Rate Limited."; - die(); - } - die(); - -?> diff --git a/articles/.signup.md.swp b/articles/.signup.md.swp new file mode 100644 index 0000000..da92d1a Binary files /dev/null and b/articles/.signup.md.swp differ diff --git a/articles/copyright.md b/articles/copyright.md new file mode 100644 index 0000000..0332177 --- /dev/null +++ b/articles/copyright.md @@ -0,0 +1,173 @@ +## creative commons + +# Attribution-ShareAlike 4.0 International + +Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +### Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). + +* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). + +## Creative Commons Attribution-ShareAlike 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +### Section 1 – Definitions. + +a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + +b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + +c. __BY-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License. + +d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + +e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + +f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + +g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike. + +h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + +i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + +j. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License. + +k. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + +l. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + +m. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. + +### Section 2 – Scope. + +a. ___License grant.___ + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + + 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. __Term.__ The term of this Public License is specified in Section 6(a). + + 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. __Downstream recipients.__ + + A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. + + C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + +b. ___Other rights.___ + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. + +### Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + +a. ___Attribution.___ + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + +b. ___ShareAlike.___ + +In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. + +1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License. + +2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. + +3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. + +### Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; + +b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and + +c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +### Section 5 – Disclaimer of Warranties and Limitation of Liability. + +a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__ + +b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__ + +c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + +### Section 6 – Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + +b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + +c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + +d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +### Section 7 – Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + +b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + +### Section 8 – Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + +b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + +c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + +d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. + +> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the [CC0 Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/legalcode). Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. +> +> Creative Commons may be contacted at creativecommons.org. diff --git a/articles/donate.md b/articles/donate.md new file mode 100644 index 0000000..d83f118 --- /dev/null +++ b/articles/donate.md @@ -0,0 +1,17 @@ +# Donations + +As this server and our projects are all a labor of love and goodwill for +the community, operating the thunix server costs money. We love what we +do and we love sharing what we do for free, but over time, operating +expenses can have a big impact. + +That being said, we also rely on the good nature of generous people, who +are willing to donate to us. The price breakdown right now is €38/month. +So to help with server costs and time spent, you can donate the +following ways: + +Via BitCoin: 1DFM3qY7XmCxGTFPATSQJVCNjvmWiVubGN + +You can donate via Liberapay here: [![Donate using Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/ub3g33k/donate) + +Or via PayPal here: [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GW2H85HY9VJ3L) diff --git a/articles/faq.md b/articles/faq.md new file mode 100644 index 0000000..c941bf0 --- /dev/null +++ b/articles/faq.md @@ -0,0 +1,66 @@ +# Frequently Asked Questions + +**How do I sign up for an account?** + +Simply by going to our [signup page](/signup.php) and filling in the +form. You can ask for help in \#thunix on tilde.chat, or you can +[contact us](/contact.php), if you run into any difficulties. + +**Who is running thunix?** + +The current system administrators are [amcclure](/~amcclure), +[ubergeek](/~ubergeek), [Naglfar](/~naglfar), and +[fosslinux](/~fosslinux). + +**What happened to the old thunix? Why the name change?** + +The original machine and founder dissappeared without any warning to +anyone, including server staff. For this reason, most things were not +backed up, and we needed to obtain a new domain name, and a new set of +machines. + +**I want a new package installed, or I want something changed on +Thunix!** + +Excellent! We're looking to make this system useful for the +community! You can submit a PR or an issue +[here](https://tildegit.org/thunix/ansible) to request the system +change. + +**Can I get password-based login? Old thunix had it!** + +No. Sorry. Not for +shell access. For other integrated services, password auth will be +enabled, but not for your ssh connection. We use key based +authentication, as it's more secure, and more convienent for you, to be +honest. + +**I want to run {fill in the blank} server, but I can't seem to access +it?** + +The only exposed ports to the internet are services as defined in +our [ansible playbook.](https://tildegit.org/thunix/ansible) If there is +a public service you want to see, open an issue, or do a pull request +for it, and we'll probably enable it without much question. + +**That's too hard! Can you just open the port up for this service I have +running?** + +No. Due to security issues, we cannot. HOWEVER! You can +certainly use an [SSH tunnel](https://duckduckgo.com/?q=ssh+tunnnel) to +access it. + +**Old thunix did {fill in the blank}, and now it doesn't. Make it work +like it used to!** + +There was a huge changeover. Maybe we can get +something going old thunix had, and maybe not. You can mention it in the +IRC channel, and we'll see what we can do. + +**How can I access my thunix email?** + +You can use the following for your +mail settings (This is Thunderbird's setting screen, but the settings +are the same): + +[![](https://thunix.net/images/mail.png)](https://thunix.net/images/mail.png) diff --git a/articles/gdpr.md b/articles/gdpr.md new file mode 100644 index 0000000..0101293 --- /dev/null +++ b/articles/gdpr.md @@ -0,0 +1,43 @@ +# GDPR Statement and Privacy Policy + +Thunix takes privacy seriously, and as such remains committed to being +in compliance with the GDPR, which took affect on May 25th, 2018. + +## What data do we collect from you? + +Thunix collects your email address, during signup, and IPs you log into +the system from, in accordance with technical requirements. + +We also store whatever data you create or maintain in your home +directory on Thunix, which may include emails to and from your Thunix +account. + +## How long do we retain data about you? + +Your email address is retained only long enough to process you account +creation request. IPs you log into from are retained for a maximum of 30 +days. + +## How can I request a copy of my data? + +You can submit a request at [contact page](/contact.php). We will +endeavor to provide you a copy of all data we store within 14 days. + +## How can I request removal of my information? + +You can submit a request at [contact page](/contact.php), and we will +endeavor to remove all personal data of yours from our system within 14 +days. However, this will include removal of your user account from our +system as well, which will prevent access to most of the services +provided by Thunix. + +If you request deletion of your account, all of your data will be purged +within 14 days from our system. + +## How do you protect my data? + +All data on thunix is encrypted at rest. Logs are maintained only for as +long as is technically required (30 days, for troubleshooting of +issues). Personally created data, is protected by the UNIX permissions +model, as dictated by yourself, however, by default, your personally +created data is viewable by all other users of the system, per design. diff --git a/articles/index.html b/articles/index.html new file mode 100644 index 0000000..e9cf1d2 --- /dev/null +++ b/articles/index.html @@ -0,0 +1 @@ +Apache is functioning normally diff --git a/articles/main.md b/articles/main.md new file mode 100644 index 0000000..1d6a667 --- /dev/null +++ b/articles/main.md @@ -0,0 +1,50 @@ +# Welcome to thunix! + +We're so glad you could drop by and we hope you enjoy your visit. Stay a +while! Feel free to inquire about what we have to offer and explore our +services. + + +## About thunix + +thunix offers Secure Shell (SSH) accounts, Web Hosting, Email Accounts, +and many other services. But, most of all, we are a community of users. +It was founded by hexhaxtron in the Summer of 2017, and was continued by +[amcclure](/~amcclure) and [ubergeek](/~ubergeek) since 2018. We aim to +provide the best service possible with a wide variety of features, and +we hope you have fun with it! + + +## Project Phoenix + +The thunix Phoenix project aims to provide a new user experience for +shell users, with integration into the wider Tildeverse network. + +Join us on IRC on irc.tilde.chat/6697 in the #thunix channel, or just +click here for a web client: [![#thunix channel](https://tilde.chat/badges/badge.php?channel=%23thunix)](https://web.tilde.chat/?join=thunix) + +If you want to sign up for an account, simply open our [signup +form](/signup.php) and provide us with: + +* Your contact name +* Your email address (so that we can contact you with login details) +* Your desired username (all lowercase, alphanumeric characters only, no spaces) +* How you heard about us and what interests you in thunix +* Your Public SSH Key + +thunix tries to adhere to the values and philosophy of the Hacker Ethic +whenever possible. The hacker ethics and beliefs as described by Levy +are: + +* Access to computers - and anything which might teach you something about the way the world works - should be unlimited and total. Always yield to the Hands-On Imperative! +* All information should be free +* Mistrust authority - promote decentralization +* Hackers should be judged by their hacking, not criteria such as degrees, age, race, sex, or position +* You can create art and beauty on a computer +* Computers can change your life for the better + +thunix will never use proprietary software but users can do that if they +wish. This is something they should avoid however. + +If you want to help keep thunix running, please consider +[donating](donate). diff --git a/articles/news.md b/articles/news.md new file mode 100644 index 0000000..ebda4d7 --- /dev/null +++ b/articles/news.md @@ -0,0 +1,40 @@ +# State of the Thunix - May 09, 2019 + +Another month, another update! + +Not too much to announce, as far as front end changes. New user requests +should happen much faster now that we've written/stolen a tool from +tilde.team that we can use to expedite user creation, and automation of +a bunch of the steps we take to onboard users. + +We're considering adding in user aging for accounts. Lots of accounts +get created, and then never logged into. This can actually post a +security problem for the system, as often times, accounts get created +now, to be used months from today for botnets and the like. Let us know +what your thoughts are on a reasonable time to age off users. At this +time, I am personally leaning towards 180 days. Plenty of time to log +into your shell, and use it a bit. And, once every 6 months isn't much +to ask, since we expect members to actually contribute to the community, +anyways. + +We've terminated one account already for running a botnet member from +here, and we'll keep a vigilant eye for any others. + +This leads to another point: Just running a znc process doesn't count +for login. Neither does checking your email. You'll need to actually log +into the shell, in order to reset the counter. You should, anyways, +since we have a lot of services internally, that we don't offer external +access too. + +We are also looking at terminating the minecraft and minetest instances +here. If anyone is using them, speak up now, or forever hold you peace! +Not really. We wouldn't be deleting anything, just shutting down the +processes, and removing them from the backup scheme. + +We do need to welcome our newest sysadmin here: fosslinux. Give them a +warm welcome if you see them around. + +And again, any questions, or concerns, feel free to drop myself, or any +of the other admins a line. + +Ubergeek/ub3g33k diff --git a/articles/server.md b/articles/server.md new file mode 100644 index 0000000..f9e1da9 --- /dev/null +++ b/articles/server.md @@ -0,0 +1,57 @@ +# Service Status and Information + +## Minetest + +Connect to thunix.net:30000 in your minetest client + +## Minecraft + +Connect to thunix.net in your minecraft client. Running the Paperclip +minecraft server. + +## Mail Services + +Thunix offers webmail at [https://thunix.net/webmail](/webmail). You can +also connect via imap. Thunderbird will autodetect your settings, and we +recommend the use of Thunderbird email client, so you can get the +best-of-breed email experience. We also recommend using enigmail with +Thunderbird as well. You can get it from your distro's package manager, +or from [the Thunderbird project's site](https://www.thunderbird.net/) + +## Onion Service + +Thunix's services are available as a onion site as well. Our onion +address is thunixme5v4rnoby.onion. + +## BZFlag Game Server + +BZFlag runs on the standard port. If you have a specific map you want +loaded, send an email to root, and we'll look at getting the map swapped +out + +## IRC Chat + +Thunix is part of the tilde.chat network. You can access chat via the +terminal, with the 'chat' command, via your favorite email client at +irc.tilde.chat/6697, or via a web chat interface located [here](). + +## FOSS Project Mirrors + +Thunix hosts mirrors for several FOSS projects. You can see the full +mirror list in the sidebar link. + + +# Server Status + +Last update: 18:17 + +| Check | Status| +|---|---| +| sshd | GOOD| +| BZFlag\_Server | GOOD| +| Memory | GOOD| +| Minetest\_Server | GOOD| +| web\_site | GOOD| +| web\_site\_https| GOOD| +| imap | GOOD| +| smtp | GOOD| diff --git a/articles/signup.md b/articles/signup.md new file mode 100644 index 0000000..334727a --- /dev/null +++ b/articles/signup.md @@ -0,0 +1,73 @@ +# Formtest + +
      +

      Enter Name:

      +

      Enter Email Address:

      +

      Enter Message:

      + +
      + + diff --git a/articles/tos.md b/articles/tos.md new file mode 100644 index 0000000..280d6ff --- /dev/null +++ b/articles/tos.md @@ -0,0 +1,59 @@ +# Terms of Service + +Nothing is without its rules and regulations; thunix is no exception. +Below are the site's service terms. Everything in this page should be +clear to everyone who wishes to use thunix's services; failure to abide +by these terms can result in penalties such as service bans and may +result in legal action against any offending users, depending on the +severity of each case and any other individuals who may have been +affected. Thunix may conduct investigations on any suspected violations, +and we will cooperate with law enforcement agencies with their +investigations. Be sure to read this page carefully and understand it. + +You are responsibe for checking your local mail account from time to +time. This email address is the only one we retain, and as such, any +warnings and notices regarding your account, or service status will be +sent to this account. + +1. Deliberately defacing the accounts of other users +2. Deliberately trying to disrupt thunix's server +3. Using thunix as a launch pad for disrupting other servers +4. Using thunix to impersonate other websites and businesses for + criminal purposes +5. Storing/distributing pornography of any genre and medium (especially + child pornography) +6. Storing/distributing content that defames any individual +7. Promoting racial, ethnic, religious, political and other forms of + bigotry +8. Storing/distributing, promoting, or encouraging use of + pirated/cracked software, license keys, license/registration + circumvention programs, or any questionable programs/scripts that + can risk causing unauthorized modifications, or disrupts network + services for any programs or devices. +9. Mining cryptocurrencies +10. Spamming on any forums, mailing lists, irc channels, + newsgroups, etc. +11. Leaking or publishing any user's or individual's personal + information without that person's consent. + +Copyright infringement is not allowed on thunix, and we will not allow +any illegal content to be distributed. It's also expected that all users +respect the copyrights of those who produce original content of any kind +and only share if the author or license grants you permission. Content +hosted on accounts used for external file storage must also follow +copyright law. + +If you want to request for content you own the copyright for to be +removed from thunix, please refer to our [abuse reporting +page](/abuse.php). In the email, please identify who you are, if you are +the copyright holder or legally representing them, the exact files you +want removed with links to the files and infringed content, and contact +information such as phone numbers or a reply-to email address. + +Users that repeatedly violate the Terms of Service will have their +account removed. Depending on the degree of the offense, their account +may be removed immediately. These terms also apply to communication +services such as forums, mailing lists, irc channels, newsgroups, and +any other service either hosted on or used for thunix. If you come +across anything that violates the terms of service, please let us know +with the [abuse reporting page](/abuse.php). diff --git a/config.php b/config.php new file mode 100644 index 0000000..a531808 --- /dev/null +++ b/config.php @@ -0,0 +1,14 @@ + diff --git a/contact.admin.php b/contact.admin.php deleted file mode 100644 index 4e07aef..0000000 --- a/contact.admin.php +++ /dev/null @@ -1,860 +0,0 @@ - - $isHideForm, - 'error_fields' => isset($phpfmg_send['error']) ? $phpfmg_send['error']['fields'] : '', - 'OneEntry' => isset($GLOBALS['OneEntry']) ? $GLOBALS['OneEntry'] : '', - ); - - @header("Content-Type:text/html; charset=$charset"); - echo ""; - -} - - -function phpfmg_admin_default(){ - if( phpfmg_user_login() ){ - phpfmg_admin_panel(); - }; -} - - - -function phpfmg_admin_panel() -{ - if( !phpfmg_user_isLogin() ){ - exit; - }; - - phpfmg_admin_header(); - phpfmg_writable_check(); -?> - - - - -
      - - - - - - -
      - 1. Email Traffics -
      -
      - view    - download    - delete all'; - }; - ?> -
      - - -
      - 2. Form Data -
      -
      - view    - download    - delete all'; - }; - ?> -
      - -
      - 3. Form Generator -
      -
      - Edit Form    - New Form -
      -
      - - "> -
      - -
      - - - - - <?php echo '' == $title ? '' : $title . ' | ' ; ?>PHP FormMail Admin Panel - - - - - - - - - - - -
      - Form Admin Panel - -   -Main Menu   ' ; - echo 'Logout' ; - }; -?> -
      - -
      - - - -
      - -
      - - - -out_processing_gif(); -} - - -# phpfmg module : captcha -# ------------------------------------------------------ -function phpfmg_captcha_get(){ - $img = new phpfmgImage(); - $img->out(); - //$_SESSION[PHPFMG_ID.'fmgCaptchCode'] = $img->text ; - $_SESSION[ phpfmg_captcha_name() ] = $img->text ; -} - - - -function phpfmg_captcha_generate_images(){ - for( $i = 0; $i < 50; $i ++ ){ - $file = "$i.png"; - $img = new phpfmgImage(); - $img->out($file); - $data = base64_encode( file_get_contents($file) ); - echo "'{$img->text}' => '{$data}',\n" ; - unlink( $file ); - }; -} - - -function phpfmg_dd_lookup(){ - $paraOk = ( isset($_REQUEST['n']) && isset($_REQUEST['lookup']) && isset($_REQUEST['field_name']) ); - if( !$paraOk ) - return; - - $base64 = phpfmg_dependent_dropdown_data(); - $data = @unserialize( base64_decode($base64) ); - if( !is_array($data) ){ - return ; - }; - - - foreach( $data as $field ){ - if( $field['name'] == $_REQUEST['field_name'] ){ - $nColumn = intval($_REQUEST['n']); - $lookup = $_REQUEST['lookup']; // $lookup is an array - $dd = new DependantDropdown(); - echo $dd->lookupFieldColumn( $field, $nColumn, $lookup ); - return; - }; - }; - - return; -} - - -function phpfmg_filman_download(){ - if( !isset($_REQUEST['filelink']) ) - return ; - - $filelink = base64_decode($_REQUEST['filelink']); - $file = PHPFMG_SAVE_ATTACHMENTS_DIR . basename($filelink); - - // 2016-12-05: to prevent *LFD/LFI* attack. patch provided by Pouya Darabi, a security researcher in cert.org - $real_basePath = realpath(PHPFMG_SAVE_ATTACHMENTS_DIR); - $real_requestPath = realpath($file); - if ($real_requestPath === false || strpos($real_requestPath, $real_basePath) !== 0) { - return; - }; - - if( !file_exists($file) ){ - return ; - }; - - phpfmg_util_download( $file, $filelink ); -} - - -class phpfmgDataManager -{ - var $dataFile = ''; - var $columns = ''; - var $records = ''; - - function __construct(){ - $this->dataFile = PHPFMG_SAVE_FILE; - } - - function phpfmgDataManager(){ - $this->dataFile = PHPFMG_SAVE_FILE; - } - - function parseFile(){ - $fp = @fopen($this->dataFile, 'rb'); - if( !$fp ) return false; - - $i = 0 ; - $phpExitLine = 1; // first line is php code - $colsLine = 2 ; // second line is column headers - $this->columns = array(); - $this->records = array(); - $sep = chr(0x09); - while( !feof($fp) ) { - $line = fgets($fp); - $line = trim($line); - if( empty($line) ) continue; - $line = $this->line2display($line); - $i ++ ; - switch( $i ){ - case $phpExitLine: - continue; - break; - case $colsLine : - $this->columns = explode($sep,$line); - break; - default: - $this->records[] = explode( $sep, phpfmg_data2record( $line, false ) ); - }; - }; - fclose ($fp); - } - - function displayRecords(){ - $this->parseFile(); - echo ""; - echo "\n"; - $i = 1; - foreach( $this->records as $r ){ - echo "\n"; - $i++; - }; - echo "
       " . join( " ", $this->columns ) . "
      {$i} " . join( " ", $r ) . "
      \n"; - } - - function line2display( $line ){ - $line = str_replace( array('"' . chr(0x09) . '"', '""'), array(chr(0x09),'"'), $line ); - $line = substr( $line, 1, -1 ); // chop first " and last " - return $line; - } - -} -# end of class - - - -# ------------------------------------------------------ -class phpfmgImage -{ - var $im = null; - var $width = 73 ; - var $height = 33 ; - var $text = '' ; - var $line_distance = 8; - var $text_len = 4 ; - - function __construct( $text = '', $len = 4 ){ - $this->phpfmgImage( $text, $len ); - } - - function phpfmgImage( $text = '', $len = 4 ){ - $this->text_len = $len ; - $this->text = '' == $text ? $this->uniqid( $this->text_len ) : $text ; - $this->text = strtoupper( substr( $this->text, 0, $this->text_len ) ); - } - - function create(){ - $this->im = imagecreate( $this->width, $this->height ); - $bgcolor = imagecolorallocate($this->im, 255, 255, 255); - $textcolor = imagecolorallocate($this->im, 0, 0, 0); - $this->drawLines(); - imagestring($this->im, 5, 20, 9, $this->text, $textcolor); - } - - function drawLines(){ - $linecolor = imagecolorallocate($this->im, 210, 210, 210); - - //vertical lines - for($x = 0; $x < $this->width; $x += $this->line_distance) { - imageline($this->im, $x, 0, $x, $this->height, $linecolor); - }; - - //horizontal lines - for($y = 0; $y < $this->height; $y += $this->line_distance) { - imageline($this->im, 0, $y, $this->width, $y, $linecolor); - }; - } - - function out( $filename = '' ){ - if( function_exists('imageline') ){ - $this->create(); - if( '' == $filename ) header("Content-type: image/png"); - ( '' == $filename ) ? imagepng( $this->im ) : imagepng( $this->im, $filename ); - imagedestroy( $this->im ); - }else{ - $this->out_predefined_image(); - }; - } - - function uniqid( $len = 0 ){ - $md5 = md5( uniqid(rand()) ); - return $len > 0 ? substr($md5,0,$len) : $md5 ; - } - - function out_predefined_image(){ - header("Content-type: image/png"); - $data = $this->getImage(); - echo base64_decode($data); - } - - // Use predefined captcha random images if web server doens't have GD graphics library installed - function getImage(){ - $images = array( - 'F29A' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcUlEQVR4nGNYhQEaGAYTpIn7QkMZQxhCGVqRxQIaWFsZHR2mOqCIiTS6NgQEBKCIMQDFAh1EkNwXGrVq6crMyKxpSO4DqpvCEAJXBxMLYGgIDA1BEWN0YGxAV8fawOjoiCYmGuoQyogiNlDhR0WIxX0A4WHMkXyw53UAAAAASUVORK5CYII=', - '80EE' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAWElEQVR4nGNYhQEaGAYTpIn7WAMYAlhDHUMDkMREpjCGsDYwOiCrC2hlbUUXE5ki0uiKEAM7aWnUtJWpoStDs5Dch6YOah42MWx2YLoFm5sHKvyoCLG4DwB5nMk7XGkkZgAAAABJRU5ErkJggg==', - 'B46A' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdElEQVR4nGNYhQEaGAYTpIn7QgMYWhlCgRhJLGAKw1RGR4epDshiQFWsDQ4BASjqGF1ZGxgdRJDcFxq1dOnSqSuzpiG5L2CKSCuroyNMHdQ80VDXhsDQEFQ7WlkbAlHVTWFoZUTTC3EzI4rYQIUfFSEW9wEAr5nMfCHD8SgAAAAASUVORK5CYII=', - '0413' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcUlEQVR4nGNYhQEaGAYTpIn7GB0YWhmmMIQ6IImxBjBMZQhhd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gwo+KEIv7AMmbzx9SYeT/AAAAAElFTkSuQmCC', - '854D' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAb0lEQVR4nGNYhQEaGAYTpIn7WANEQxkaHUMdkMREpog0MLQ6OgQgiQW0AsWmOjqIoKoLYQiEi4GdtDRq6tKVmZlZ05DcJzKFodG1EVVvQCtQLDQQTUyk0aER3Q5WoEpUt7AGMIagu3mgwo+KEIv7AJAIzI6R5ixaAAAAAElFTkSuQmCC', - '51F9' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7QkMYAlhDA6Y6IIkFNDAGsDYwBASgiLECxRgdRJDEAgMYkMXATgqbtipqaeiqqDBk97WC1DFMRdYLFWtAFguAiKHYITKFAcMtQJeEgsxDdvNAhR8VIRb3AQCTZMksXTMt4AAAAABJRU5ErkJggg==', - '7B92' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdElEQVR4nGNYhQEaGAYTpIn7QkNFQxhCGaY6IIu2irQyOjoEBKCKNbo2BDqIIItNEWllbQhoEEF2X9TUsJWZUauikNzH6CDSyhAS0IhsB2uDCJAf0IrsFhGgmGNDwBRkMaDpYLegioHczBgaMgjCj4oQi/sAaLTMcMk0b84AAAAASUVORK5CYII=', - '574E' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7QkNEQx0aHUMDkMSA7EaHVkcHBnSxqahigQEMrQyBcDGwk8KmrZq2MjMzNAvZfa0MAayNqHoZWhkdWEMDUe1oZQXagqpOZIoIhhhrAFgMxc0DFX5UhFjcBwAoyssY9VovqwAAAABJRU5ErkJggg==', - '490D' => 'iVBORw0KG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O4DALOmyUwL4QKcAAAAAElFTkSuQmCC', - 'EDE6' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAU0lEQVR4nGNYhQEaGAYTpIn7QkNEQ1hDHaY6IIkFNIi0sjYwBASgijW6NjA6CGARQ3ZfaNS0lamhK1OzkNwHVYfVPBHCYhhuwebmgQo/KkIs7gMAb17NOLndlp8AAAAASUVORK5CYII=', - '1083' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAX0lEQVR4nGNYhQEaGAYTpIn7GB0YAhhCGUIdkMRYHRhDGB0dHQKQxEQdWFtZGwIaRFD0ijQClTUEILlvZda0lVmhq5ZmIbkPTR1czBXDPGx2YHFLCKabByr8qAixuA8AfoXJVB5lVNgAAAAASUVORK5CYII=', - '18F8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXklEQVR4nGNYhQEaGAYTpIn7GB0YQ1hDA6Y6IImxOrC2sjYwBAQgiYk6iDS6AlWLoOhFUQd20sqslWFLQ1dNzUJyHyMW8xixmkfQDohbQoBubmBAcfNAhR8VIRb3AQD3YMjVwccB2gAAAABJRU5ErkJggg==', - '39E7' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZUlEQVR4nGNYhQEaGAYTpIn7RAMYQ1hDHUNDkMQCprC2sgJpEWSVrSKNruhiUyBiAUjuWxm1dGlq6KqVWcjum8IYCFTXimJzKwNI7xRUMRaQWACyGMQtjA5Y3IwiNlDhR0WIxX0AVLvLPNH3z8oAAAAASUVORK5CYII=', - '0F58' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAa0lEQVR4nGNYhQEaGAYTpIn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PhREWJxHwAQqMvVcHElcQAAAABJRU5ErkJggg==', - '66E6' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZUlEQVR4nGNYhQEaGAYTpIn7WAMYQ1hDHaY6IImJTGFtZW1gCAhAEgtoEWlkbWB0EEAWaxBpAIkhuy8yalrY0tCVqVlI7guZIgo0jxHVvFaRRlegXhECYtjcgs3NAxV+VIRY3AcA+v/LVezBmYoAAAAASUVORK5CYII=', - '8564' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcUlEQVR4nM2QsQ3AIAwETeENnH2gSO9I0DCNKdgARqBhylAakjJR4u9OL/tk6JcR+FNe8UPeAgQQVowKiXE2acaZBMXmpedRoLDya7G2VnuMyo8KpN05O+8bTI7g5xuD8eKCebhMDNn41fmr/z2YG78TpBPOQiecYIkAAAAASUVORK5CYII=', - '6150' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcklEQVR4nGNYhQEaGAYTpIn7WAMYAlhDHVqRxUSmMAawNjBMdUASC2hhBYkFBCCLAfmsUxkdRJDcFxm1KmppZmbWNCT3hUxhCGBoCISpg+htxS7G2hCAYocIUC+jowOKW4AuCWUIZUBx80CFHxUhFvcBAHASygaQAM4/AAAAAElFTkSuQmCC', - 'BB5A' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbElEQVR4nGNYhQEaGAYTpIn7QgNEQ1hDHVqRxQKmiLSyNjBMdUAWaxVpdG1gCAhAVzeV0UEEyX2hUVPDlmZmZk1Dch9IHUNDIEwd3DyHhsDQEAw70NQB9TI6OqKIgdzMEMqIIjZQ4UdFiMV9ALWqzUHNtgc3AAAAAElFTkSuQmCC', - 'CF6F' => 'iVBORw0KGgoA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UVORK5CYII=', - '3E15' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZklEQVR4nGNYhQEaGAYTpIn7RANEQxmmMIYGIIkFTBFpYAhhdEBR2SrSwIguBlI3hdHVAcl9K6Omhq2atjIqCtl9YHUMDSJo5mEXY3QQQXfLFIYAZPeB3MwY6jDVYRCEHxUhFvcBAI67ylZN/A5jAAAAAElFTkSuQmCC', - '2F65' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcklEQVR4nM2QsQ2AMAwE7SIbmH2cgt4Upsg0btiAsAEFTElC5QhKkOLvTv/SyXA+zqCn/OIXZFBWVHGMVjKMkX1PFrJgLYOb4cjeb8vzno+UvJ+UXmQjt0WuW2lYsMom9oysurB4P9XSUMjcwf8+zIvfBTmsysrEdM0vAAAAAElFTkSuQmCC', - 'E60C' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAX0lEQVR4nGNYhQEaGAYTpIn7QkMYQximMEwNQBILaGBtZQhlCBBBERNpZHR0dGBBFWtgbQh0QHZfaNS0sKWrIrOQ3RfQINqKpA5unisWMUcMOzDdgs3NAxV+VIRY3AcA4X7MAwCJ8VoAAAAASUVORK5CYII=', - '7B44' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbUlEQVR4nGNYhQEaGAYTpIn7QkNFQxgaHRoCkEVbRVoZWh0a0cQaHaY6tKKITQGqC3SYEoDsvqipYSszs6KikNzH6CDSytro6ICsl7VBpNE1NDA0BElMBCjmgOaWgAagHRhiWNw8QOFHRYjFfQCIBc8FR+n6agAAAABJRU5ErkJggg==', - '7C16' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbklEQVR4nGNYhQEaGAYTpIn7QkMZQxmmMEx1QBZtZW10CGEICEARE2lwDGF0EEAWmyICxIwOKO6LmrZq1bSVqVlI7mN0AKtDMY+1AaJXBElMBAgd0MQCGoBumYLqloAGRqCrHVDdPEDhR0WIxX0APT3LoyIZ2K4AAAAASUVORK5CYII=', - '1129' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZklEQVR4nGNYhQEaGAYTpIn7GB0YAhhCGaY6IImxOjAGMDo6BAQgiYk6sAawNgQ6iKDrRYiBnbQya1UUkIgKQ3IfWF0rw1QMvVMYGjDEAhgw7ABhFLeEsIayhgaguHmgwo+KEIv7AKJixi3WghgIAAAAAElFTkSuQmCC', - '038B' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXElEQVR4nGNYhQEaGAYTpIn7GB1YQxhCGUMdkMRYA0RaGR0dHQKQxESmMDS6NgQ6iCCJBbQyIKsDOylq6aqwVaErQ7OQ3IemDiaGYR42O7C5BZubByr8qAixuA8A/DPKfflFnKkAAAAASUVORK5CYII=', - 'FD96' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAW0lEQVR4nGNYhQEaGAYTpIn7QkNFQxhCGaY6IIkFNIi0Mjo6BASgijW6NgQ6CGARQ3ZfaNS0lZmZkalZSO4DqXMICcQwzwGoVwRNzBFTDItbMN08UOFHRYjFfQBCEs3uUm25TAAAAABJRU5ErkJggg==', - 'BD0C' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAWklEQVR4nGNYhQEaGAYTpIn7QgNEQximMEwNQBILmCLSyhDKECCCLNYq0ujo6OjAgqqu0bUh0AHZfaFR01amrorMQnYfmjq4edjEsNiB4RZsbh6o8KMixOI+AL4DzW+cuJRxAAAAAElFTkSuQmCC', - '25AD' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdElEQVR4nGNYhQEaGAYTpIn7WANEQxmmMIY6IImJTBFpYAhldAhAEgtoFWlgdHR0EEHW3SoSwtoQCBODuGna1KVLV0VmTUN2XwBDoytCHRgyOgDFQlHFWBtEMNSJNLC2guxAdktoKCPIXhQ3D1T4URFicR8A/K3LfS3XHTAAAAAASUVORK5CYII=' - ); - $this->text = array_rand( $images ); - return $images[ $this->text ] ; - } - - function out_processing_gif(){ - $image = dirname(__FILE__) . '/processing.gif'; - $base64_image = "R0lGODlhFAAUALMIAPh2AP+TMsZiALlcAKNOAOp4ANVqAP+PFv///wAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgAIACwAAAAAFAAUAAAEUxDJSau9iBDMtebTMEjehgTBJYqkiaLWOlZvGs8WDO6UIPCHw8TnAwWDEuKPcxQml0Ynj2cwYACAS7VqwWItWyuiUJB4s2AxmWxGg9bl6YQtl0cAACH5BAUKAAgALAEAAQASABIAAAROEMkpx6A4W5upENUmEQT2feFIltMJYivbvhnZ3Z1h4FMQIDodz+cL7nDEn5CH8DGZhcLtcMBEoxkqlXKVIgAAibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkphaA4W5upMdUmDQP2feFIltMJYivbvhnZ3V1R4BNBIDodz+cL7nDEn5CH8DGZAMAtEMBEoxkqlXKVIg4HibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpjaE4W5tpKdUmCQL2feFIltMJYivbvhnZ3R0A4NMwIDodz+cL7nDEn5CH8DGZh8ONQMBEoxkqlXKVIgIBibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpS6E4W5spANUmGQb2feFIltMJYivbvhnZ3d1x4JMgIDodz+cL7nDEn5CH8DGZgcBtMMBEoxkqlXKVIggEibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpAaA4W5vpOdUmFQX2feFIltMJYivbvhnZ3V0Q4JNhIDodz+cL7nDEn5CH8DGZBMJNIMBEoxkqlXKVIgYDibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpz6E4W5tpCNUmAQD2feFIltMJYivbvhnZ3R1B4FNRIDodz+cL7nDEn5CH8DGZg8HNYMBEoxkqlXKVIgQCibbK9YLBYvLtHH5K0J0IACH5BAkKAAgALAEAAQASABIAAAROEMkpQ6A4W5spIdUmHQf2feFIltMJYivbvhnZ3d0w4BMAIDodz+cL7nDEn5CH8DGZAsGtUMBEoxkqlXKVIgwGibbK9YLBYvLtHH5K0J0IADs="; - $binary = is_file($image) ? join("",file($image)) : base64_decode($base64_image); - header("Cache-Control: post-check=0, pre-check=0, max-age=0, no-store, no-cache, must-revalidate"); - header("Pragma: no-cache"); - header("Content-type: image/gif"); - echo $binary; - } - -} -# end of class phpfmgImage -# ------------------------------------------------------ -# end of module : captcha - - -# module user -# ------------------------------------------------------ -function phpfmg_user_isLogin(){ - return ( isset($_SESSION['authenticated']) && true === $_SESSION['authenticated'] ); -} - - -function phpfmg_user_logout(){ - session_destroy(); - header("Location: admin.php"); -} - -function phpfmg_user_login() -{ - if( phpfmg_user_isLogin() ){ - return true ; - }; - - $sErr = "" ; - if( 'Y' == $_POST['formmail_submit'] ){ - if( - defined( 'PHPFMG_USER' ) && strtolower(PHPFMG_USER) == strtolower($_POST['Username']) && - defined( 'PHPFMG_PW' ) && strtolower(PHPFMG_PW) == strtolower($_POST['Password']) - ){ - $_SESSION['authenticated'] = true ; - return true ; - - }else{ - $sErr = 'Login failed. Please try again.'; - } - }; - - // show login form - phpfmg_admin_header(); -?> -
      - -


      - -
      -
      -
      - - - - - - - - - - - - -
      Email : - -
      Password : - -
      -

      - {$sErr}

      \n"; ?> - I forgot my password -
      -
      -
      - - - -
      - -


      - -
      -
      -
      -Request Password -Enter Email Address :
      - -
      -The password will be sent to this email address. -
      {$sErr}

      \n"; ?> -
      -
      - - -" ); - echo "
      Your password has been sent.

      Click here to login again
      "; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_writable_check(){ - - if( is_writable( dirname(PHPFMG_SAVE_FILE) ) && is_writable( dirname(PHPFMG_EMAILS_LOGFILE) ) ){ - return ; - }; -?> - -

      -
      -
      Your form data or email traffic log is NOT saving.
      - The form data () and email traffic log () will be created automatically when the form is submitted. - However, the script doesn't have writable permission to create those files. In order to save your valuable information, please set the directory to writable. - If you don't know how to do it, please ask for help from your web Administrator or Technical Support of your hosting company. -
      -

      - PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - - phpfmg_admin_header(); - - $file = $files[$n]; - if( is_file($file) ){ - if( 1== $n ){ - echo "
      \n";
      -            echo join("",file($file) );
      -            echo "
      \n"; - }else{ - $man = new phpfmgDataManager(); - $man->displayRecords(); - }; - - - }else{ - echo "No form data found."; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_log_download(){ - $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; - $files = array( - 1 => PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - - $file = $files[$n]; - if( is_file($file) ){ - phpfmg_util_download( $file, PHPFMG_SAVE_FILE == $file ? 'form-data.csv' : 'email-traffics.txt', true, 1 ); // skip the first line - }else{ - phpfmg_admin_header(); - echo "No email traffic log found."; - phpfmg_admin_footer(); - }; - -} - - -function phpfmg_log_delete(){ - $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; - $files = array( - 1 => PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - phpfmg_admin_header(); - - $file = $files[$n]; - if( is_file($file) ){ - echo unlink($file) ? "It has been deleted!" : "Failed to delete!" ; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_util_download($file, $filename='', $toCSV = false, $skipN = 0 ){ - if (!is_file($file)) return false ; - - set_time_limit(0); - - - $buffer = ""; - $i = 0 ; - $fp = @fopen($file, 'rb'); - while( !feof($fp)) { - $i ++ ; - $line = fgets($fp); - if($i > $skipN){ // skip lines - if( $toCSV ){ - $line = str_replace( chr(0x09), ',', $line ); - $buffer .= phpfmg_data2record( $line, false ); - }else{ - $buffer .= $line; - }; - }; - }; - fclose ($fp); - - - - /* - If the Content-Length is NOT THE SAME SIZE as the real conent output, Windows+IIS might be hung!! - */ - $len = strlen($buffer); - $filename = basename( '' == $filename ? $file : $filename ); - $file_extension = strtolower(substr(strrchr($filename,"."),1)); - - switch( $file_extension ) { - case "pdf": $ctype="application/pdf"; break; - case "exe": $ctype="application/octet-stream"; break; - case "zip": $ctype="application/zip"; break; - case "doc": $ctype="application/msword"; break; - case "xls": $ctype="application/vnd.ms-excel"; break; - case "ppt": $ctype="application/vnd.ms-powerpoint"; break; - case "gif": $ctype="image/gif"; break; - case "png": $ctype="image/png"; break; - case "jpeg": - case "jpg": $ctype="image/jpg"; break; - case "mp3": $ctype="audio/mpeg"; break; - case "wav": $ctype="audio/x-wav"; break; - case "mpeg": - case "mpg": - case "mpe": $ctype="video/mpeg"; break; - case "mov": $ctype="video/quicktime"; break; - case "avi": $ctype="video/x-msvideo"; break; - //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files) - case "php": - case "htm": - case "html": - $ctype="text/plain"; break; - default: - $ctype="application/x-download"; - } - - - //Begin writing headers - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - //Use the switch-generated Content-Type - header("Content-Type: $ctype"); - //Force the download - header("Content-Disposition: attachment; filename=".$filename.";" ); - header("Content-Transfer-Encoding: binary"); - header("Content-Length: ".$len); - - while (@ob_end_clean()); // no output buffering ! - flush(); - echo $buffer ; - - return true; - - -} -?> diff --git a/contact.lib.php b/contact.lib.php deleted file mode 100644 index 0545a69..0000000 --- a/contact.lib.php +++ /dev/null @@ -1,3377 +0,0 @@ -unauthorized domain." ); - -define( 'PHPFMG_ONE_ENTRY' , '' ); -define( 'PHPFMG_ONE_ENTRY_METHOD' , '' ); - -phpfmg_init(); -# ----------------------------------------------------------------------------- - - - - - - - - - -function phpfmg_thankyou(){ - phpfmg_redirect_js(); -?> - - -
      - - Your form has been sent. Thank you! -

      - - - - - - "field_0", "text" => "Contact Name:", "type" => "sender's name", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_1'] = array( "name" => "field_1", "text" => "Email Address:", "type" => "sender's email", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_2'] = array( "name" => "field_2", "text" => "Subject:", "type" => "text", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_3'] = array( "name" => "field_3", "text" => "Message:", "type" => "textarea", "instruction" => "", "required" => "Required" ) ; - - -/** - * GNU Library or Lesser General Public License version 2.0 (LGPLv2) -*/ - -function phpfmg_init(){ - - error_reporting( E_ERROR ); - ini_set('magic_quotes_runtime', 0); - ini_set( 'max_execution_time', 0 ); - ini_set( 'max_input_time', 36000 ); - - session_start(); - - if( !isset($_SESSION['HTTP_REFERER']) ) - $_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'] ; - phpfmg_check_referers(); - - if ( get_magic_quotes_gpc() && isset($_POST) ) { - phpfmg_stripslashes( $_POST ); - }; - -} - - -function phpfmg_stripslashes(&$var){ - if(!is_array($var)) { - $var = stripslashes($var); - } else { - array_walk($var,'phpfmg_stripslashes'); - }; -} - - -function phpfmg_display_form( $title="", $keywords="", $description="" ){ - @header( 'Content-Type: text/html; charset=' . PHPFMG_CHARSET ); - $phpfmg_send = phpfmg_sendmail( $GLOBALS['form_mail'] ) ; - $isHideForm = isset($phpfmg_send['isHideForm']) ? $phpfmg_send['isHideForm'] : false; - $sErr = isset($phpfmg_send['error']) ? $phpfmg_send['error'] : ''; - - # FormMail main() - phpfmg_header( $title, $keywords, $description ); - if( !$isHideForm ){ - phpfmg_form($sErr); - }else{ - phpfmg_thankyou(); - }; - phpfmg_footer(); - - return; -} - -function phpfmg_linebreak(){ - $os = strtolower(PHP_OS); - switch( true ){ - case ("\\" == DIRECTORY_SEPARATOR) : // windows - return "\x0d\x0a" ; - case ( strpos($os, 'darwin') !== false ) : // Mac - return "\x0d" ; - default : - return "\x0a" ; // *nix - }; -} - -function phpfmg_sendmail( &$form_mail ) { - if( !isset($_POST["formmail_submit"]) ) return ; - - $isHideForm = false ; - $sErr = checkPass($form_mail); - - $err_captcha = phpfmg_check_captcha(); - if( $err_captcha != '' ){ - $sErr['fields'][] = 'phpfmg_captcha'; - $sErr['errors'][] = ERR_CAPTCHA; - }; - - if( empty($sErr['fields']) && phpfmg_has_entry() ){ - $sErr['fields'][] = 'phpfmg_found_entry'; - $sErr['errors'][] = 'Found entry already!'; - }; - if( empty($sErr['fields']) ){ - - sendFormMail( $form_mail, PHPFMG_SAVE_FILE ) ; - $isHideForm = true; - // move the redirect to phpfmg_thankyou() to get around the redirection within an iframe problem - /* - $redirect = PHPFMG_REDIRECT; - if( strlen(trim($redirect)) ): - header( "Location: $redirect" ); - exit; - endif; - */ - }; - - return array( - 'isHideForm' => $isHideForm, - 'error' => $sErr , - ); -} - - -function phpfmg_has_entry(){ - if( !file_exists(PHPFMG_SAVE_FILE) ){ - return false; // has nothing to check - }; - - $found = false ; - if( defined('PHPFMG_ONE_ENTRY') && 'Y' == PHPFMG_ONE_ENTRY ){ - $query = defined('PHPFMG_ONE_ENTRY_METHOD') && PHPFMG_ONE_ENTRY_METHOD == 'email' && isset($GLOBALS['sender_email']) ? $GLOBALS['sender_email'] : $_SERVER['REMOTE_ADDR'] ; - if( empty($query) ) - return false ; - - $GLOBALS['OneEntry'] = $query; - $query = '"'. strtolower($query) . '"'; - $handle = fopen(PHPFMG_SAVE_FILE,'r'); - if ($handle) { - while (!feof($handle)) { - $entry = strtolower(fgets($handle, 4096)); - if( strpos($entry,$query) !== false ){ - $found = true ; - break; - }; - }; - fclose($handle); - }; - }; - return $found ; - -} - -function sendFormMail( $form_mail, $sFileName = "" ) -{ - $to = filterEmail(PHPFMG_TO) ; - $cc = filterEmail(PHPFMG_CC) ; - $bcc = filterEmail(PHPFMG_BCC) ; - - // simply chop email address to avoid my website being abused - if( false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com') ){ - $cc = substr($cc, 0, 50); - $bcc = substr($bcc,0, 50); - }; - - - $subject = PHPFMG_SUBJECT ; - $from = $to ; - $fromName = ""; - $titleOfSender = ''; - $firstName = ""; - $lastName = ""; - - $strip = get_magic_quotes_gpc() ; - $content = '' ; - $style = 'font-family:Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color:#474747;padding:6px;border-bottom:1px solid #cccccc;' ; - $tr = array() ; // html table - $csvValues = array(); - $cols = array(); - $replace = array(); - $RecordID = phpfmg_getRecordID(); - $isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) ); - - foreach( $form_mail as $field ){ - $field_type = strtolower($field[ "type" ]); - if( 'sectionbreak' == $field_type ){ - continue; - }; - - $field[ "text" ] = stripslashes( $field[ "text" ] ); - //$value = trim( $_POST[ $field[ "name" ] ] ); - $value = phpfmg_field_value( $field[ "name" ] ); - $value = $strip ? stripslashes($value) : $value ; - if( 'attachment' == $field_type ){ - $value = $isWritable ? phpfmg_file2value( $RecordID, $_FILES[ $field[ "name" ] ] ) : $_FILES[ $field[ "name" ] ]['name']; - //$value = $_FILES[ $field[ "name" ] ]['name']; - }; - - $content .= $field[ "text" ] . " \t : " . $value .PHPFMG_LNCR; - $tr[] = " " . $field[ "text" ] . "  " . nl2br($value) . " " ; - $csvValues[] = csvfield( $value ); - $cols[] = csvfield( $field[ "text" ] ); - $replace["%".$field[ "name" ]."%"] = $value; - - switch( $field_type ){ - case "sender's email" : - $from = filterEmail($value) ; - break; - case "sender's name" : - $fromName = filterEmail($value) ; - break; - case "titleofsender" : - $titleOfSender = $value ; - break; - case "senderfirstname" : - $firstName = filterEmail($value) ; - break; - case "senderlastname" : - $lastName = filterEmail($value) ; - break; - default : - // nothing - }; - - }; // for - - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - - if( $isHtml ) { - $content = "" . PHPFMG_LNCR . join( PHPFMG_LNCR, $tr ) . PHPFMG_LNCR . "
      " ; - }; - - - if( !empty($firstName) && !empty($lastName) ){ - $fromName = $firstName . ' ' . $lastName; - }; - $fromHeader = filterEmail( ('' != $fromName ? "\"$fromName\"" : '' ) . " <{$from}>",array(",", ";")) ; // no multiple emails are allowed. - $GLOBALS['ReplyTo'] = $fromHeader; - - $_fields = array( - '%NameOfSender%' => $fromName, - '%FirstNameOfSender%' => $firstName, - '%LastNameOfSender%' => $lastName, - '%EmailOfSender%' => $from, - '%TitleOfSender%' => $titleOfSender, - '%DataOfForm%' => $content, - '%IP%' => $_SERVER['REMOTE_ADDR'], - '%Date%' => date("Y-m-d"), - '%Time%' => date("H:i:s"), - '%HTTP_HOST%' => $_SERVER['HTTP_HOST'], - '%FormPageLink%' => phpfmg_request_uri(), - '%HTTP_REFERER%' => $_SESSION['HTTP_REFERER'], - '%AutoID%' => $RecordID, - '%FormAdminURL%' => phpfmg_admin_url() - ); - $fields = array_merge( $_fields, $replace ); - - $esh_mail_template = trim(phpfmg_mail_template()); - if( !empty($esh_mail_template) ){ - $esh_mail_template = phpfmg_adjust_template($esh_mail_template); - $content = phpfmg_parse_mail_body( $esh_mail_template, $fields ); - }; - $subject = phpfmg_parse_mail_body( $subject, $fields ); - - if( $isHtml ) { - $content = phpfmg_getHtmlContent( $content ); - }; - - $oldMask = umask(0); - //$sep = ','; //chr(0x09); - $sep = chr(0x09); - $recordCols = phpfmg_data2record( csvfield('RecordID') . $sep . csvfield('Date') . $sep . csvfield('IP') . $sep . join($sep,$cols) ); - $record = phpfmg_data2record( csvfield($RecordID) . $sep . csvfield(date("Y-m-d H:i:s")) . $sep . csvfield($_SERVER['REMOTE_ADDR']) .$sep . join($sep,$csvValues) ); - - - /* - Some hosting companies (like Yahoo and GoDaddy) REQUIRED a registered email address to send out all emails! - The mailer HAS to use the REGISTERED email address as the sender's email address. This is called the sendmail_from. - */ - $sendmail_from = $from; - $sender_email = $from; - $force_sender = defined('PHPFMG_SENDMAIL_FROM') && '' != PHPFMG_SENDMAIL_FROM ; - if( $force_sender ){ - ini_set("sendmail_from", PHPFMG_SENDMAIL_FROM); - $sendmail_from = PHPFMG_SENDMAIL_FROM; - }; - if( defined('PHPFMG_SMTP') && '' != PHPFMG_SMTP ){ - ini_set("SMTP", PHPFMG_SMTP); - }; - - - - switch( strtolower(PHPFMG_ACTION) ){ - case 'fileonly' : - appendToFile( $sFileName, $record, $recordCols ); - break; - case 'mailonly' : - mailAttachments( $to , $subject , $content, $sendmail_from, $fromName, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ; - break; - case 'mailandfile' : - default: - mailAttachments( $to , $subject , $content, $sendmail_from, $fromName, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ; - appendToFile( $sFileName, $record, $recordCols ); - }; // switch - - mailAutoResponse( $sender_email, $force_sender ? $sendmail_from : $to, $fields ) ; - umask($oldMask); - - session_destroy(); - session_regenerate_id(true); -} - - - - - -function phpfmg_file2value( $recordID, $file ){ - $tmp = $file[ "tmp_name" ] ; - $name = phpfmg_rename_harmful(trim($file[ "name" ])) ; - if( !defined('PHPFMG_FILE2LINK_SIZE') ){ - return $name; - }; - - if( is_uploaded_file( $tmp ) ) { - $size = trim(PHPFMG_FILE2LINK_SIZE) ; - switch( $size ){ - case '' : - return $name; - default: - $isHtml = 'html' == PHPFMG_MAIL_TYPE; - $filelink = base64_encode($recordID . '-' . $name); - $url = phpfmg_admin_url() . "?mod=filman&func=download&filelink=" . urlencode($filelink) ; - $isLarger = (filesize($tmp)/1024) > $size ; - $link = $isHtml ? "
      $name" : $name . " ( {$url} )"; - return $isLarger ? $link : $name ; // email download link when size is larger defined size, otherwise send as attachment - };// switch - }; // if - - return $name; -} - - -function phpfmg_dir2unix( $dir ){ - return str_replace( array("\\", '//'), '/', $dir ); -} - - - -function phpfmg_request_uri(){ - $uri = getEnv('REQUEST_URI'); // apache has this - if( false !== $uri && strlen($uri) > 0 ){ - return $uri ; - } else { - - $uri = ($uri = getEnv('SCRIPT_NAME')) !== false - ? $uri - : getEnv('PATH_INFO') ; - $qs = getEnv('QUERY_STRING'); // IIS and Apache has this - return $uri . ( empty($qs) ? '' : '?' . $qs ); - - }; - return "" ; -} - - - - -// parse full admin url to view large size uploaded file online -function phpfmg_admin_url(){ - $http_host = "http://{$_SERVER['HTTP_HOST']}"; - switch( true ){ - case (0 === strpos(PHPFMG_ADMIN_URL, 'http://' )) : - $url = PHPFMG_ADMIN_URL; - break; - case ( '/' == substr(PHPFMG_ADMIN_URL,0,1) ) : - $url = $http_host . PHPFMG_ADMIN_URL ; - break; - default: - $uri = phpfmg_request_uri(); - $pos = strrpos( $uri, '/' ); - $vdir = substr( $uri, 0, $pos ); - $url = $http_host . $vdir . '/' . PHPFMG_ADMIN_URL ; - }; - return $url; -} - - - -function phpfmg_ispost(){ - return 'POST' == strtoupper($_SERVER["REQUEST_METHOD"]) || 'POST' == strtoupper(getEnv('REQUEST_METHOD')) ; -} - - -function phpfmg_is_mysite(){ - return false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com'); // accessing form at mysite -} - -// don't allow hotlink form to my website. To avoid people create phishing form. -function phpfmg_hotlinking_mysite(){ - $yes = phpfmg_is_mysite() - && ( empty($_SERVER['HTTP_REFERER']) || false === strpos( strtolower($_SERVER['HTTP_REFERER']),'formmail-maker.com') ) ; // doesn't have referer of mysite - - if( $yes ){ - die( "Access Denied. -

      - You are visiting a form hotlinkink from formmail-maker.com which is not allowed. - Please read the FAQ. - " ); - }; -} - - - -function phpfmg_check_referers(){ - - phpfmg_hotlinking_mysite(); // anti phishing - - $debugs = array(); - $debugs[] = "Your IP: " . $_SERVER['REMOTE_ADDR']; - $debugs[] = "Referer link: " . $_SERVER['HTTP_REFERER']; - $debugs[] = "Host of referer: $referer"; - - $check = defined('PHPFMG_ANTI_HOTLINKING') && 'Y' == PHPFMG_ANTI_HOTLINKING; - if( !$check ) { - $debugs[] = "Referer is empty. No need to check hot linking."; - //echo "
      " . join("\n",$debugs) . "
      \n"; - //appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ; - return true; - }; - - // maybe post from local file - if( !isset($_SERVER['HTTP_REFERER']) && phpfmg_ispost() ){ - appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n phpfmg_ispost " . join("\n",$debugs) ) ; - die( PHPFMG_REFERERS_DENIED_MSG ); - }; - - - $url = parse_url($_SERVER['HTTP_REFERER']); - $referer = str_replace( 'www.', '', strtolower($url['host']) ); - if( empty($referer) ) { - return true; - }; - - $hosts = explode(',',PHPFMG_REFERERS_ALLOW); - $http_host = strtolower($_SERVER['HTTP_HOST']); - $referer = $http_host ; - $hosts[] = str_replace('www.', '', $http_host ); - - $debugs[] = "Hosts Allow: " . PHPFMG_REFERERS_ALLOW; - - $allow = false ; - foreach( $hosts as $host ){ - $host = strtolower(trim($host)); - $debugs[] = "check host: $host " ; - if( false !== strpos($referer, $host) || false !== strpos($referer, 'www.'.$host) ){ - $allow = true; - $debugs[] = " -> allow (quick exit)"; - break; - }else{ - $debugs[] = " -> deny"; - }; - }; - - //echo "
      " . join("\n",$debugs) . "
      \n"; - //appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ; - - if( !$allow ){ - die( PHPFMG_REFERERS_DENIED_MSG ); - }; -} - - - -function phpfmg_getRecordID(){ - if( !isset($GLOBALS['RecordID']) ){ - $GLOBALS['RecordID'] = date("Ymd") . '-'. substr( md5(uniqid(rand(), true)), 0,4 ); - }; - return $GLOBALS['RecordID']; -} - - - -function phpfmg_data2record( $s, $b=true ){ - $from = array( "\r", "\n"); - $to = array( "\\r", "\\n" ); - return $b ? str_replace( $from, $to, $s ) : str_replace( $to, $from, $s ) ; -} - - - -function csvfield( $str ){ - $str = str_replace( '"', '""', $str ); - return '"' . trim($str) . '"'; -} - - - -function mailAttachments( $to = "" , $subject = "" , $message = "" , $from="", $fromName = "" , $fromHeader ="", $cc = "" , $bcc = "", $charset = "UTF-8", $type = 'FormMail' ){ - - if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ; - - $isAutoResponse = $type == 'AutoResponseEmail' ; - // added PHPMailer SMTP support at Mar 12, 2011 - $isSMTP = defined('PHPFMG_USE_SMTP') && 'Y' == PHPFMG_USE_SMTP && defined('PHPFMG_SMTP_HOST') && '' != PHPFMG_SMTP_HOST; - - // due to security issues, in most case, the smtp will fail on my website. It only works on user's own server - // so just disable the smtp here - if( phpfmg_is_mysite() ){ - $isSMTP = false ; - }; - - $attachments = array(); - $noAutoAttachements = $isAutoResponse && defined('PHPFMG_RETURN_NO_ATTACHMENT') && 'Y' == PHPFMG_RETURN_NO_ATTACHMENT ; - $use_phpmailer = defined('PHPFMG_USE_PHPMAILER') && 'Y' == PHPFMG_USE_PHPMAILER ; - - - $boundary = "====_My_PHP_Form_Generator_" . md5( uniqid( srand( time() ) ) ) . "===="; - $content_type = 'html' == PHPFMG_MAIL_TYPE ? "text/html" : "text/plain" ; - - // setup mail header infomation - $headers = 'Y' == PHPFMG_NO_FROM_HEADER ? '' : "From: {$fromHeader}" .PHPFMG_LNCR; - $headers .= "Reply-To: {$GLOBALS['ReplyTo']}" .PHPFMG_LNCR; - if ($cc) $headers .= "CC: $cc".PHPFMG_LNCR; - if ($bcc) $headers .= "BCC: $bcc".PHPFMG_LNCR; - //$headers .= "Content-type: {$content_type}; charset={$charset}" .PHPFMG_LNCR ; - - $plainHeaders = $headers ; // for no attachments header - $plainHeaders .= 'MIME-Version: 1.0' . PHPFMG_LNCR; - $plainHeaders .= "Content-type: {$content_type}; charset={$charset}" ; - - //create mulitipart attachments boundary - $sError = "" ; - $nFound = 0; - - - if( false && isset($GLOBALS['phpfmg_files_content']) && '' != $GLOBALS['phpfmg_files_content'] ){ - - // use previous encoded content - $sEncodeBody = $GLOBALS['phpfmg_files_content'] ; - $nFound = $GLOBALS['phpfmg_nFound'] ; - - }else{ - - $file2link_size = trim(PHPFMG_FILE2LINK_SIZE) ; - $isSave = ('' != $file2link_size || defined('PHPFMG_SAVE_ATTACHMENTS') && 'Y' == PHPFMG_SAVE_ATTACHMENTS); - if( $isSave ){ - if( defined('PHPFMG_SAVE_ATTACHMENTS_DIR') ){ - if( !is_dir(PHPFMG_SAVE_ATTACHMENTS_DIR) ){ - $ok = @mkdir( PHPFMG_SAVE_ATTACHMENTS_DIR, 0777 ); - if( !$ok ) $isSave = false; - }; - }; - }; - - $isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) ); - // parse attachments content - foreach( $_FILES as $aFile ){ - $sFileName = $aFile[ "tmp_name" ] ; - $sFileRealName = phpfmg_rename_harmful($aFile[ "name" ]) ; - if( is_uploaded_file( $sFileName ) ): - - $isSkip = '' != $file2link_size && ( (filesize($sFileName)/1024) > $file2link_size ); - // save uploaded file - if( $isWritable && $isSave ){ - $tofile = PHPFMG_SAVE_ATTACHMENTS_DIR . phpfmg_getRecordID() . '-' . basename($sFileRealName); - if( @copy( $sFileName, $tofile) ) { - $sFileName = $tofile; // to fix problem : in some windows php, the uploaded temp file might not be mailed as attachment - chmod($tofile,0777); - }; - }; - - if( $isSkip ) - continue; // mail file as link - - $attachments[] = array('file' => $sFileName, 'name' => $aFile[ "name" ] ); - - if( !$use_phpmailer && !$isSMTP && ($fp = @fopen( $sFileName, "rb" )) ) : - $sContent = fread( $fp, filesize( $sFileName ) ); - fclose($fp); - $sFName = basename( $sFileRealName ) ; - $sMIME = getMIMEType( $sFName ) ; - - $bPlainText = ( $sMIME == "text/plain" ) ; - if( $bPlainText ) : - $encoding = "" ; - else: - $encoding = "Content-Transfer-Encoding: base64".PHPFMG_LNCR; - $sContent = chunk_split( base64_encode( $sContent ) ); - endif; - - $sEncodeBody .= PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR. - "Content-Type: $sMIME;" . PHPFMG_LNCR. - "\tname=\"$sFName\"" . PHPFMG_LNCR. - $encoding . - "Content-Disposition: attachment;" . PHPFMG_LNCR. - "\tfilename=\"$sFName\"" . PHPFMG_LNCR. PHPFMG_LNCR. - $sContent . PHPFMG_LNCR ; - $nFound ++; - else: - $sError .= "
      Failed to open file $sFileName.\n" ; - endif; // if( $fp = fopen( $sFileName, "rb" ) ) : - - else: - $sError .= "
      File $sFileName doesn't exist.\n" ; - endif; //if( file_exists( $sFileName ) ): - }; // end foreach - - $sEncodeBody .= PHPFMG_LNCR.PHPFMG_LNCR."--$boundary--" ; - - $GLOBALS['phpfmg_files_content'] = $sEncodeBody ; - $GLOBALS['phpfmg_nFound'] = $nFound ; - - }; // if - - $headers .= "MIME-Version: 1.0".PHPFMG_LNCR."Content-type: multipart/mixed;".PHPFMG_LNCR."\tboundary=\"$boundary\""; - $txtMsg = PHPFMG_LNCR."This is a multi-part message in MIME format." .PHPFMG_LNCR . - PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR . - "Content-Type: {$content_type};".PHPFMG_LNCR. - "\tcharset=\"$charset\"" .PHPFMG_LNCR.PHPFMG_LNCR . - $message . PHPFMG_LNCR; - - - if( $noAutoAttachements ) $sEncodeBody = '' ; - - $body = $nFound ? $txtMsg . $sEncodeBody : $message ; - $headers = $nFound ? $headers : $plainHeaders ; - - - $errmsg = ""; - if( $isSMTP || $use_phpmailer ){ - if( $noAutoAttachements ) $attachments = false ; - $errmsg = phpfmg_phpmailer( $to, $subject, $body, $from, $fromName, $cc , $bcc , $charset, $attachments ); - - }else{ - - if ( !mail( $to, $subject, $body, $headers ) ) - $errmsg = "Failed to send mail"; - }; - - $ok = $errmsg == "" ; - $status = $ok ? "\n[Email sent]" : "\n[{$errmsg}]" ; - phpfmg_log_mail( $to, $subject, ($ok ? 'Email sent' : 'Failed to send mail') . "\n" . ($nFound ? $headers . $txtMsg : $headers . $message), '', $type . $status ); // no log for attachments - - return $sError ; -} - - -function phpfmg_phpmailer( $to, $subject, $message, $from, $fromName, $cc = "" , $bcc = "", $charset = "UTF-8",$attachments = false ){ - - $mail = new PHPMailer(); - $mail->Host = PHPFMG_SMTP_HOST; // SMTP server - $mail->Username = PHPFMG_SMTP_USER; - $mail->Password = PHPFMG_SMTP_PLAIN_PASSWORD != '' ? PHPFMG_SMTP_PLAIN_PASSWORD : base64_decode(PHPFMG_SMTP_PASSWORD); - $mail->SMTPAuth = PHPFMG_SMTP_PASSWORD != ""; - $mail->SMTPSecure = PHPFMG_SMTP_SECURE; - $mail->Port = PHPFMG_SMTP_PORT == "" ? 25 : PHPFMG_SMTP_PORT; - if( defined('PHPFMG_SMTP_DEBUG_LEVEL') && PHPFMG_SMTP_DEBUG_LEVEL != "" ){ - $mail->SMTPDebug = (int)PHPFMG_SMTP_DEBUG_LEVEL ; - }; - - if( isset($GLOBALS['ReplyTo']) ) $mail->AddReplyTo($GLOBALS['ReplyTo']); - $mail->From = $from; - $mail->FromName = $fromName; - $mail->Subject = $subject; - $mail->Body = $message; - $mail->CharSet = $charset; - - if( !phpfmg_is_mysite() && (defined('PHPFMG_USE_SMTP') && 'Y' == PHPFMG_USE_SMTP) ){ - $mail->IsSMTP(); - }; - - $mail->IsHTML('html' == PHPFMG_MAIL_TYPE); - - $mail->AddAddress($to); - - if( ''!= $cc ){ - $CCs = explode(',',$cc); - foreach($CCs as $c){ - $mail->AddCC( $c ); - }; - }; - - if( ''!= $bcc ){ - $BCCs = explode(',',$bcc); - foreach($BCCs as $b){ - $mail->AddBCC( $b ); - }; - }; - - - if( is_array($attachments) ){ - foreach($attachments as $f){ - $mail->AddAttachment( $f['file'], basename($f['name']) ); - }; - }; - - return $mail->Send() ? "" : $mail->ErrorInfo; - -} - - - -function mailAutoResponse( $to, $from, $fields = false ){ - if( !formIsEMail($to) ) return ERR_EMAIL ; // one more check for spam robot - $enable = defined('PHPFMG_RETURN_ENABLE') && PHPFMG_RETURN_ENABLE === 'Y'; - $body = trim(phpfmg_auto_response_message()); - if( !$enable || empty($body) ){ - return false ; - }; - - $subject = PHPFMG_RETURN_SUBJECT; - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - $body = phpfmg_adjust_template($body); - $body = phpfmg_parse_mail_body($body,$fields); - $subject = phpfmg_parse_mail_body( $subject, $fields ); - if( $isHtml ) { - $body = phpfmg_getHtmlContent( $body ); - }; - $body = str_replace( "0x0d", '', $body ); - $body = str_replace( "0x0a", PHPFMG_LNCR, $body ); - - if( defined('PHPFMG_RETURN_EMAIL') && formIsEMail(PHPFMG_RETURN_EMAIL) ){ - $from = PHPFMG_RETURN_EMAIL; - }; - $fromHeader = ( PHPFMG_YOUR_NAME == "" ? "" : "\"".PHPFMG_YOUR_NAME . "\"" ) . " <{$from}>"; - return mailAttachments( $to , $subject , $body, filterEmail($from), PHPFMG_YOUR_NAME, $fromHeader, '' , '', PHPFMG_CHARSET, 'AutoResponseEmail' ); - -} - - -function phpfmg_log_mail( $to='', $subject='', $body='', $headers = '', $type='' ){ - $sep = PHPFMG_LNCR . str_repeat('----',20) . PHPFMG_LNCR ; - appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$type}" . $sep . "To: {$to}\r\nSubject: {$subject}\r\n" . $headers . $body . "
      " . PHPFMG_LNCR . $sep . PHPFMG_LNCR ) ; -} - - - -function phpfmg_getHtmlContent( $body ){ - $html = "Your Form Mail Content | htttp://phpfmg.sourceforge.net" - . $body .""; - return $html ; -} - - - -function phpfmg_adjust_template( $body ){ - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - if( $isHtml ){ - $body = preg_match( "/<[^<>]+>/", $body ) ? $body : nl2br($body); - }; - return $body; -} - - - -function phpfmg_parse_mail_body( $body, $fields = false ){ - if( !is_array($fields) ) - return $body ; - - $yes = function_exists( 'str_ireplace' ); - foreach( $fields as $name => $value ){ - $body = $yes ? str_ireplace( $name, $value ,$body ) - : str_replace ( $name, $value ,$body ); - }; - return trim($body); -} - - - -# filter line breaks to avoid emails injecting -function filterEmail($email, $chars = ''){ - $email = trim(str_replace( array("\r","\n"), '', $email )); - if( is_array($chars) ) $email = str_replace( $chars, '', $email ); - $email = preg_replace( '/(cc\s*\:|bcc\s*\:)/i', '', $email ); - return $email; -} - - - -function mailReport( $content = "", $file = '' ){ - $content = " -Dear Sir or Madam, - -Your online form at " . HOST_NAME . PHP_SELF . " failed to save data to file. Please make sure the web user has permission to write to file \"{$file}\". If you don't know how to fix it, please forward this email to technical support team of your web hosting company or your Administrator. - -PHPFMG -- PHP FormMail Generator -"; - mail(PHPFMG_TO, "Error@" . HOST_NAME . PHP_SELF, $content ); -} - - - -function remove_newline( $str = "" ){ - return str_replace( array("\r\n", "\r", "\n"), array('\r\n', '\r', '\n'), $str ); -} - - - -function checkPass( $form_mail = array() ) -{ - - $names = array(); - $labels = array(); - - foreach( $form_mail as $field ){ - $type = strtolower( $field[ "type" ] ); - //$value = trim( $_POST[ $field[ "name" ] ] ); - $value = phpfmg_field_value( $field[ "name" ] ); - $required = strtolower($field[ "required" ]) ; - $text = stripslashes( $field[ "text" ] ); - - // simple check the field has something keyed in. - if( !strlen($value) && ( $required == "required" ) && $type != "attachment" ){ - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_MISSING . $text ; - continue; - }; - - // verify the special case - if( - ( strlen($value) || $type == "attachment" ) - && $required == "required" - ): - - switch( $type ){ - case strtolower("Sender's Name") : - break; - case strtolower("Generic email"): - case strtolower("Sender's email"): - if( ! formIsEMail($value) ) { - $names[] = $field[ "name" ]; - $labels[] = $text . ERR_EMAIL; - //return ERR_EMAIL . $text ; - }; - // for checking entry limitation - if( $type == "sender's email" ){ - $GLOBALS['sender_email'] = $value; - }; - break; - case "text" : - break; - case "textarea" : - break; - case "checkbox" : - case "radio" : - break; - case "select" : - break; - case "attachment" : - $upload_file = $_FILES[ $field["name"] ][ "tmp_name" ] ; - if( ! is_uploaded_file($upload_file) ){ - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_SELECT_UPLOAD . $text; - }; - break; - case strtolower("Date(MM-DD-YYYY)"): - break; - case strtolower("Date(MM-YYYY)"): - break; - case strtolower("CreditCard(MM-YYYY)"): - if( $value < date("Y-m") ) { - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_CREDIT_CARD_EXPIRED . $text; - }; - break; - case strtolower("CreditCard#"): - if( !formIsCreditNumber( $value ) ) { - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_CREDIT_CARD_NUMBER . $text ; - }; - break; - case strtolower("Time(HH:MM:SS)"): - break; - case strtolower("Time(HH:MM)"): - break; - default : - //return $sErrRequired . $form_mail[ $i ][ "text" ]; - }; // switch - endif; - }; // for - - return array( - 'fields' => $names, - 'errors' => $labels, - ); -} - - - -function formSelected( $var, $val ) -{ - echo ( $var == $val ) ? "selected" : ""; -} - - - -function formChecked( $var, $val ) -{ - echo ( $var == $val ) ? "checked" : ""; -} - - - -function formIsEMail( $email ){ - return preg_match( "/^(.+)@(.+)\\.(.+)$/", $email ); -} - - - -function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" ) -{ - $tab = "\t" ; - print "\n\n" ; -} - - - -# something like CreditCard.pm in perl CPAN -function formIsCreditNumber( $number ) { - - $tmp = $number; - $number = preg_replace( "/[^0-9]/", "", $tmp ); - - if ( preg_match( "/[^\d\s]/", $number ) ) return 0; - if ( strlen($number) < 13 && 0+$number ) return 0; - - for ($i = 0; $i < strlen($number) - 1; $i++) { - $weight = substr($number, -1 * ($i + 2), 1) * (2 - ($i % 2)); - $sum += (($weight < 10) ? $weight : ($weight - 9)); - } - - if ( substr($number, -1) == (10 - $sum % 10) % 10 ) return $number; - return $number; -} - - -/* --------------------------------------------------------------------------------------------------- - Parameters: $sFileName - Return : - 1. "" : no extendsion name, or sFileName is empty - 2. string: MIME Type name of array aMimeType's definition. - ---------------------------------------------------------------------------------------------------*/ -function getMIMEType( $sFileName = "" ) { - $sFileName = strtolower( trim( $sFileName ) ); - if( ! strlen( $sFileName ) ) return ""; - - $aMimeType = array( - "txt" => "text/plain" , - "pdf" => "application/pdf" , - "zip" => "application/x-compressed" , - - "html" => "text/html" , - "htm" => "text/html" , - - "avi" => "video/avi" , - "mpg" => "video/mpeg " , - "wav" => "audio/wav" , - - "jpg" => "image/jpeg " , - "gif" => "image/gif" , - "tif" => "image/tiff " , - "png" => "image/x-png" , - "bmp" => "image/bmp" - ); - $aFile = explode( "\.", basename( $sFileName ) ) ; - $nDiminson = count( $aFile ) ; - $sExt = $aFile[ $nDiminson - 1 ] ; // get last part: like ".tar.zip", return "zip" - - return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : ""; -} - - - -function appendToFile( $sFileName = "", $line = "", $dataColumnsLine = '' ){ - $obey = defined('PHPFMG_GDPR') && 'Y' == PHPFMG_GDPR; // obey General Data Protection Regulation (GDPR)? - if( $obey ) return 0; - - if( !$sFileName || !$line ) return 0; - - $isExists = file_exists( $sFileName ); - $hFile = @fopen( "$sFileName", "a+w" ); - $nBytes = 0; - if( $hFile ){ - if( !$isExists && false !== strpos(strtolower(basename($sFileName)), '.php') ){ - fputs( $hFile, "\r\n"); - if( !empty($dataColumnsLine) ){ - fputs($hFile,$dataColumnsLine."\r\n"); - }; - }; - $nBytes = fputs( $hFile , trim($line)."\r\n" ); - fclose( $hFile ); - }; - return $nBytes ; -} - -function phpfmg_get_csv_header(){ - $csvValues = array(); - foreach( $GLOBALS['form_mail'] as $field ){ - $csvValues[] = csvfield( $field[ "text" ] ); - }; - return join(chr(0x09),/*","*/$csvValues) ; -} - -/* -function phpfmg_field_instruction($name, $show = true ){ - global $form_mail, $sErr; - $isError = in_array($name,$sErr['fields']); - $class = $isError ? 'instruction_error' : 'instruction' ; - if( $show || $isError ) echo "
      ". htmlspecialchars_decode($form_mail[ $name ]['instruction']) . "
      "; -} -*/ - -function phpfmg_rand( $len = 4 ){ - $md5 = md5( uniqid(rand()) ); - return $len > 0 ? substr($md5,0,$len) : $md5 ; -} - - - -// use a random name for stopping spam bot bypass the form.php, and post raw data directly -function phpfmg_captcha_name(){ - if( !isset($_SESSION['captcha_name']) ){ - $_SESSION['captcha_name'] = phpfmg_rand(8); //PHPFMG_ID.'fmgCaptchCode'; - }; - return $_SESSION['captcha_name']; -} - - -function phpfmg_check_recaptcha(){ - $errmsg = ERR_CAPTCHA; - if( isset($_POST['g-recaptcha-response']) ){ - $get = 'https://www.google.com/recaptcha/api/siteverify?secret=' . phpfmg_reCAPTCHA_key('secret_key'). '&response=' . $_POST['g-recaptcha-response']; - $response = file_get_contents($get); - echo $response; - $success = false; - if( function_exists('json_decode') ){ - $json = json_decode( $response, true ); - var_dump($json); - $success = $json['success'] === true; - }else{ - $success = preg_match( '/success[\"\']*\\:\\s*(true|1|y)/i', $response ); - }; - return $success ? '' : $errmsg; - } - return $errmsg; -} - -function phpfmg_check_captcha(){ - $errmsg = ''; - if( phpfmg_is_reCAPTCHA() ){ - $errmsg = phpfmg_check_recaptcha(); - }else{ - - $name = phpfmg_captcha_name(); - if( (defined('PHPFMG_SIMPLE_CAPTCHA_NAME') && PHPFMG_SIMPLE_CAPTCHA_NAME != '') && - ( !isset( $_POST[$name] ) || // maybe sutmited by spam bot - strtoupper($_POST[$name]) != strtoupper($_SESSION[$name]) // or user didn't type correct code - ) - ){ - $errmsg = ERR_CAPTCHA ; - }; - - }; - - return $errmsg ; -} - -function phpfmg_reCAPTCHA_key( $type ){ - $isSitekey = $type == 'site_key'; - // this keys are for formmail-maker.com domain only - $phpfmgSiteKey = '6LcQuv8SAAAAAKSvNHfF5gQuW9WIpcualeEYllCn'; - $phpfmgSecretKey = '6LcQuv8SAAAAABczBmLx85TQfdlkeMkjhz4Hzv5D'; - if( $isSitekey ){ - return phpfmg_is_mysite() ? $phpfmgSiteKey : RECAP_SITE_KEY; - }else{ - return phpfmg_is_mysite() ? $phpfmgSecretKey : RECAP_SECRET_KEY; - } - -} - - -function phpfmg_is_reCAPTCHA(){ - return (defined('RECAP_SITE_KEY') && '' != RECAP_SITE_KEY && defined('RECAP_SECRET_KEY') && '' != RECAP_SECRET_KEY) || (phpfmg_is_mysite() && defined('RECAP_SITE_KEY') ) ; -} - -function phpfmg_get_reCAPTCHA_html(){ - return - " -
      "; - -} - -function phpfmg_show_captcha(){ - if( phpfmg_is_reCAPTCHA() ){ - echo phpfmg_get_reCAPTCHA_html(); - return ; - }; - $url = PHPFMG_ADMIN_URL . '?mod=captcha&func=get&tid=' ; - $onclick= "onclick=\"document.getElementById('phpfmg_captcha_image').src='{$url}'+Math.random();return false;\" " ; - echo "\"Click\n"; - echo "Reload Verification Image
      \n"; - echo "\n"; -} - - - -function phpfmg_hsc($field, $default = false){ - echo isset($_POST[ $field ]) - ? HtmlSpecialChars( $_POST[ $field ] ) - : $default; -} - -function phpfmg_dropdown( $name, $options, $showInputbox = false, $isMultiple = false, $extra = '', $isReturn = false, $class = 'text_select' ){ - //$showInputbox = true; - $displayLast = 'none' ; - $onchange = $showInputbox ? " onchange=\"toggleOtherInputBox('{$name}','select','{$name}');\" " : "" ; - $sMultiple = $isMultiple ? 'multiple="multiple"' : '' ; - $other = "{$name}_other" ; - - $dropdown = array(); - $list = explode( '|', $options ); - $dropdown[] = "\n"; - - if( $showInputbox ){ - $dropdown[] = "" ; - $dropdown[] = "
      " ; - }; - - $s = join("\t\n",$dropdown); - - if( $isReturn ) - return $s; - else - echo $s ; -} - - -function phpfmg_date_dropdown( $cfgDate, $showSep = true ){ - $sep = $showSep ? $cfgDate['separator'] . " " : ""; - $field_name = $cfgDate['field_name']; - if( !isset($cfgDate['yyyy']) ){ - $startYear = $cfgDate['startYear']; - $endYear = $cfgDate['endYear']; - $year = range( $startYear, $endYear ); - $cfgDate['yyyy'] = $cfgDate['yearPrompt'] . '=,|' . join("|",$year); - }; - - switch( $cfgDate['format'] ){ - case 'mm/dd/yyyy' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'dd/mm/yyyy' : - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'yyyy/mm/dd' : - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - break; - case 'mm/yyyy' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'yyyy/mm' : - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - break; - case 'mm/dd' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - break; - case 'dd/mm' : - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - break; - }; - echo "\n\n"; - echo "\n"; - -} - - -function phpfmg_date_dropdown_require( $field_name ){ - if( !isset($_POST) ) - return ; - - $month = $_POST[$field_name.'_month']; - $day = $_POST[$field_name.'_day']; - $yyyy = $_POST[$field_name.'_yyyy']; - $format = $_POST[$field_name.'_format']; - $sep = isset($_POST[$field_name.'_separator']) ? $_POST[$field_name.'_separator'] : '/'; - - // make up $_POST[$field_name] value - $_POST[$field_name] = ''; - switch( $format ){ - case 'mm/dd/yyyy' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $day . $sep . $yyyy; - break; - case 'dd/mm/yyyy' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $day . $sep . $month . $sep . $yyyy; - break; - case 'yyyy/mm/dd' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $yyyy . $sep . $month . $sep . $day; - break; - case 'mm/yyyy' : - if( !empty($month) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $yyyy; - break; - case 'yyyy/mm' : - if( !empty($month) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $yyyy; - break; - case 'mm/dd' : - if( !empty($month) && !empty($day) ) - $_POST[$field_name] = $month . $sep . $day; - break; - case 'dd/mm' : - if( !empty($month) && !empty($day) ) - $_POST[$field_name] = $day . $sep . $month; - break; - }; - -} - -function phpfmg_time_dropdown( $cfgTime ){ - $field_name = $cfgTime['field_name']; - $sep =": "; - switch( $cfgTime['hourOpt'] ){ - case 'h12' : - phpfmg_dropdown( $field_name.'_hour', $cfgTime['hour'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_minute', $cfgTime['minute'], false, false, '', false, '' ); - phpfmg_dropdown( $field_name.'_amfm', $cfgTime['amfm'], false, false, '', false, '' ); - break; - case 'h24' : - phpfmg_dropdown( $field_name.'_hour', $cfgTime['hour'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_minute', $cfgTime['minute'], false, false, '', false, '' ); - break; - }; - echo "\n\n"; -} - - -function phpfmg_time_dropdown_require( $field_name ){ - if( !isset($_POST) ) - return ; - - $hour = $_POST[$field_name.'_hour']; - $minute = $_POST[$field_name.'_minute']; - $amfm = $_POST[$field_name.'_amfm']; - $format = $_POST[$field_name.'_format']; - $sep = ':'; - - // make up $_POST[$field_name] value - $_POST[$field_name] = ""; - switch( $format ){ - case 'h12' : - if( !empty($hour) && !empty($minute) && !empty($amfm) ) - $_POST[$field_name] = $hour . $sep . $minute . ' ' . $amfm; - break; - case 'h24' : - if( !empty($hour) && !empty($minute) ) - $_POST[$field_name] = $hour . $sep . $minute; - break; - }; - -} - - - -function phpfmg_dependent_dropdown( $field_name ){ - $field = phpfmg_dependent_dropdown_get_field( $field_name ); - $dd = new DependantDropdown(); - $dd->parseFmgField($field); - $html = $dd->getHtml(); - echo $html; -} - -function phpfmg_dependent_dropdown_dynamic_require( $field_name ){ - $field = phpfmg_dependent_dropdown_get_field( $field_name ); - $dd = new DependantDropdown(); - $dd->parseFmgField($field); - $dd->dynamicRequired(); -} - -function phpfmg_dependent_dropdown_get_field( $field_name ){ - if( !isset($_SESSION[PHPFMG_ID]) ){ - $_SESSION[PHPFMG_ID] = array(); - }; - if( !isset($_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name]) ){ - $base64 = phpfmg_dependent_dropdown_data(); - $data = @unserialize( base64_decode($base64) ); - $_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name] = $data; - }else{ - $data = $_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name]; - }; - - if( !is_array($data) ){ - return ; - }; - - foreach( $data as $field ){ - if( $field['name'] == $field_name ){ - return $field; - }; - }; -} - - -# ------------------------------------------------------ -class DependantDropdown -{ - var $data = ''; - var $sheet = array(); - var $fields = array(); - var $fieldInfo = array( 'label', 'instruction', 'required', 'prompt' ); // describe field information from the first N rows of data - var $prefix = 'dd'; // in case there is no name for dropdown, it will name the dropdown like dd_0, dd_1, ... - - var $fmgField = false; - var $newliner = "" ; // replace \r\n with $newliner ; - var $newtaber = "" ; // replace \t with $newtaber ; - - function __construct(){ - } - - function DependantDropdown(){ - } - - - function lookupFieldColumn( $field, $column, $lookup, $contentType='text/plain', $charset='utf-8' ){ - $this->parseFmgField( $field ); - $this->nocache_headers( $contentType, $charset ); - return join( "\n", $this->getColumn( $column, $lookup ) ); - } - - function parseFmgField( $field ){ - if( !isset($_SESSION[PHPFMG_ID]) ){ - $_SESSION[PHPFMG_ID] = array(); - }; - $this->fmgField = $field; - $value = $this->newline_back($field['value']); - $this->data = explode("\r\n",$value); - if( !isset($_SESSION[PHPFMG_ID][ "DD_".$field['name'] ]) ){ - $this->parseData($field); - $_SESSION[PHPFMG_ID][ "DD_".$field['name'] ] = $this->fields; - }else{ - $this->fields = $_SESSION[PHPFMG_ID][ "DD_".$field['name'] ]; - }; - $this->makeupFieldsName(); - } - - function newline_back( $str = "" ){ - return str_replace( array($this->newtaber, $this->newliner), array("\t","\r\n"), $str ); - } - - function nocache_headers($contentType='text/plain', $charset='utf-8'){ - header("Expires: Mon, 01 Jan 1970 00:00:01 GMT"); - header("Cache-Control: max-age=0, no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); - header( "Content-Type: {$contentType}; charset={$charset}" ); - } - - - function setData( $s ){ - $this->data = $s ; - } - - function setPrefix( $s ){ - $this->prefix = $s; - } - - function parseData(){ - $tab = chr(0x09); - $nFieldInfoRows = count( $this->fieldInfo ); - for( $i = 0, $n = count($this->data); $i < $n; $i ++ ){ - $line = str_replace('"', '', $this->data[$i] ); - //$line = stripslashes( $line ); - $cols = explode( $tab, $line ); - - if( is_array($cols) && count($cols) > 1 ){ - - if( $i < $nFieldInfoRows ){ - $trims = array(); - foreach( $cols as $col ){ - $trims[] = trim($col); - }; - $this->fields[ $this->fieldInfo[$i] ] = $trims; - } - else - $this->fields['data'][] = $cols; - - }; // if - - //if ( $i > 1000 ) break; - }; // for - - } - - // $quickTest : to see whether a column contains data - function getColumn( $n, $lookup = array(), $quickTest = false ){ - $count = count($lookup); - if( $n > 0 && empty($count) ){ - return array(); // can not get column without search query - }; - - $col = array(); - $lastValue = $lookup[ $count - 1 ]; - $flatLookup = join( '|', $lookup ); - // when using ajax GET method, use utf8 to encoude the lookup query. otherwise, some special chars like France characters might not work - if( !$this->isPost() ){ - $lastValue = utf8_encode( $lastValue ); - $flatLookup = utf8_encode( $flatLookup ); - }; - - foreach( $this->fields['data'] as $r ){ - - if( !isset($r[$n]) ) - continue; - - $value = trim($r[$n]); - if( $value == '' ) - continue; - - if( $n == 0 ){ - $col[] = $value; - - }else{ - - //if( trim($r[$n-1]) == $lastValue ){ // quick check to improve performance - if( $r[$n-1] == $lastValue ){ // quick check the last value to improve performance - $leftCols = array_slice( $r, 0, $n ); - $flatLeftValues = join( '|', $leftCols ); - if( $flatLeftValues == $flatLookup ){ // show value only by lookuping by joining all its parents' values - $col[] = $value; - }; - }; // if - - }; // if $n == 0 - - if( $quickTest && count($col) > 0 ) break; - - }; // foreach - - return array_unique($col); - } - - function getColumnOptions( $n, $lookup = array(), $default = '' ){ - $opts = array(); - foreach( $this->getColumn($n, $lookup) as $v ){ - $selected = $default == $v ? 'selected' : '' ; - $opts[] = ""; - }; - return join("\n",$opts); - } - - function hsc($s){ - return str_replace ( array ( '&', '"', "'", '<', '>' ), array ( '&' , '"', ''' , '<' , '>' ), $s ); - } - - function isPost(){ - return isset($_POST[ $this->fields['name'][0] ]); - } - - function getHtml(){ - $html = array(); - - $field_name = $this->fmgField['name']; - $this->prefix = $field_name; - $count = count($this->fields['label']); - - // prepare for getting column options after form submitted - $lookup = array(); - $isPost = $this->isPost(); // isset($_POST[ $this->fields['name'][0] ]); - if( $isPost ){ - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $lookup[] = $_POST[ $this->fields['name'][$i] ]; - }; - }; - - for( $i = 0; $i < $count; $i++ ){ - $label = stripslashes( $this->fields['label'][$i] ); - if( empty($label) ) - continue; - - $name = $this->fields['name'][$i]; - $instruction = $this->fields['instruction'][$i]; - $prompt = $this->fields['prompt'][$i]; - $required = $this->fields['required'][$i]; - $promptOption = empty($prompt) ? "" : ""; - if( $isPost ) - $options = $this->getColumnOptions( $i, array_slice($lookup,0,$i), $_POST[$name] ); - else - $options = $this->getColumnOptions( $i, array(), '' ); - - $select = ""; - $sRequired = "" ; -$li = " -
    2. -
      - {$sRequired} -
      -
      - {$select} -
      {$instruction}
      -
      -
    3. -"; - $html[] = $li; - }; - - echo join("\n\n",$html); - - } - - - function dynamicRequired(){ - if( !isset($_POST) ){ - return ; - }; - - $field_name = $this->fmgField['name']; - $this->prefix = $field_name; - $count = count($this->fields['label']); - - $lookup = array(); - $isPost = isset($_POST[ $this->fields['name'][0] ]); - if( $isPost ){ - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $lookup[] = $_POST[ $this->fields['name'][$i] ]; - }; - }; - - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $name = $this->fields['name'][$i]; - $required = $this->fields['required'][$i]; - if( strtolower($required) == 'required' ){ - $rows = $this->getColumn( $i, array_slice($lookup,0,$i), true ); - if( empty($rows) ) { - $GLOBALS['form_mail'][ $name ]['required'] = '' ; // - }; - }else{ - $GLOBALS['form_mail'][ $name ]['required'] = '' ; - }; - }; - - } - - - function getFormMailArrayCode(){ - $code = array(); - for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - $name = $this->fields['name'][$i]; - $instruction = $this->fields['instruction'][$i]; - $prompt = $this->fields['prompt'][$i]; - $required = $this->fields['required'][$i]; - $code[] = "\$GLOBALS['form_mail']['{$name}'] = array( \"name\" => \"$name\", \"text\" => \"" . addslashes( $label ) . "\", \"type\" => \"select\", \"instruction\" => \"$instruction\", \"required\" => \"$required\" ) ;" ; - }; - return join("\n",$code); - } - - function makeupFieldsName($default='field_99'){ - $field_name = isset($this->fmgField['name']) ? $this->fmgField['name'] : $default; - $this->prefix = $field_name; - for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++ ){ - $this->fields['name'][$i] = $this->prefix . '_' . $i; - }; - } - -} - - - -function phpfmg_parse_option( $opt ){ - $opt = $opt; - $a = array( - 'text' => $opt, - 'value' => $opt, - 'default' => false, - ); - $pos = strrpos( $opt, '=' ); - if( false !== $pos ){ - $a['text'] = substr($opt,0,$pos); - $part = substr($opt,$pos+1); - $nv = strrpos( $part, ',' ); - if( false !== $nv ){ - $a['value'] = substr($part,0,$nv); - $a['default'] = 'default' == strtolower(substr($part,$nv+1)); - }else{ - $a['value'] = $part; - }; - }; - $a['text'] = trim($a['text']); - $a['value'] = trim($a['value']); - return $a ; -} - - - -function phpfmg_field_value( $name ){ - $value = "" ; - if( isset($GLOBALS[$name."_value"]) ) - return $GLOBALS[$name."_value"] ; - - $field = $GLOBALS['form_mail'][$name]; - $checkOther = isset( $_POST[$name.'_other_check'] ) && 1 == $_POST[$name.'_other_check'] ; - $otherInputValue = $checkOther ? $_POST[$name.'_other'] : '' ; - - switch( $field['type'] ){ - case 'select' : - if( $checkOther && $otherInputValue == "" ){ - return $value; - }; - - if( is_array($_POST[$name]) ){ - //array_pop( $_POST[$name] ); // pop the last "other" element - $value = join(PHPFMG_LNCR,$_POST[$name]) . PHPFMG_LNCR. $otherInputValue ; - $value = str_replace( PHPFMG_LNCR . "other", "", $value ); - }else{ - $value = $checkOther ? $otherInputValue : $_POST[ $name ]; - }; - break; - - case 'radio' : - if( $checkOther ){ - $value = $otherInputValue == '' ? '' : $otherInputValue; - }else{ - $value = $_POST[ $name ]; - }; - break; - - case 'checkbox' : - if( $checkOther && $otherInputValue == "" ){ - return $value; - }; - - $length = isset($_POST[$name.'_length']) ? $_POST[$name.'_length'] : 100; - $values = array(); - for( $i = 1; $i <= $length; $i ++){ - $newName = 'Checkbox' . ($i<10 ? '0' .$i : $i ) . "_" . $name; - if( $_POST[ $newName ] != "" && $_POST[ $newName ] != 'other' ) - $values[] = $_POST[ $newName ]; - }; - $value = ( empty($values) ? "" : join( PHPFMG_LNCR, $values ) ) . ( $otherInputValue != "" ? PHPFMG_LNCR . $otherInputValue : "" ); - break; - - default: - $value = $_POST[ $name ]; - break; - }; - $value = phpfmg_stripTags( $value ); - $GLOBALS[$name."_value"] = $value ; - return $value; -} - -function phpfmg_stripTags($str){ - $allowable_tags = "


      - - diff --git a/donate.php b/donate.php deleted file mode 100644 index 7074d6a..0000000 --- a/donate.php +++ /dev/null @@ -1,30 +0,0 @@ - -Donations - thunix - -
      -

      Donations

      -
       
      -
      -

      As this server and our projects are all a labor of love and goodwill for the community, operating the thunix server costs money. We love what we do and we love sharing what we do for free, but over time, operating expenses can have a big impact.

      -

      That being said, we also rely on the good nature of generous people, who are willing to donate to us. The price breakdown right now is €38/month. So to help with server costs and time spent, you can donate the following ways:

      -

      Via BitCoin:

      -

      1DFM3qY7XmCxGTFPATSQJVCNjvmWiVubGN

      -

      You can donate via Liberapay here:

      -

      -
      -

      Or via Paypal: -

      - - - - - -
      -

      -
      -
      -
      -
       
      -
  • - - diff --git a/faq.php b/faq.php deleted file mode 100644 index 7aeb593..0000000 --- a/faq.php +++ /dev/null @@ -1,23 +0,0 @@ - -Frequently Asked Questions - thunix - -
    -

    Frequently Asked Questions

    -
     
    -
    -

    How do I sign up for an account?
    Simply by going to our signup page and filling in the form. You can ask for help in #thunix on tilde.chat, or you can contact us, if you run into any difficulties.

    -

    Who is running thunix?
    The current system administrators are amcclure, ubergeek, Naglfar, and fosslinux.

    -

    What happened to the old thunix? Why the name change?
    The original machine and founder dissappeared without any warning to anyone, including server staff. For this reason, most things were not backed up, and we needed to obtain a new domain name, and a new set of machines.

    -

    I want a new package installed, or I want something changed on Thunix!
    Excellent! We're looking to make this system useful for the community! You can submit a PR or an issue here to request the system change.

    -

    Can I get password-based login? Old thunix had it!
    No. Sorry. Not for shell access. For other integrated services, password auth will be enabled, but not for your ssh connection. We use key based authentication, as it's more secure, and more convienent for you, to be honest.

    -

    I want to run {fill in the blank} server, but I can't seem to access it?
    The only exposed ports to the internet are services as defined in our ansible playbook. If there is a public service you want to see, open an issue, or do a pull request for it, and we'll probably enable it without much question.

    -

    That's too hard! Can you just open the port up for this service I have running?
    No. Due to security issues, we cannot. HOWEVER! You can certainly use an SSH tunnel to access it.

    -

    Old thunix did {fill in the blank}, and now it doesn't. Make it work like it used to!
    There was a huge changeover. Maybe we can get something going old thunix had, and maybe not. You can mention it in the IRC channel, and we'll see what we can do.

    -

    How can I access my thunix email?
    You can use the following for your mail settings (This is Thunderbird's setting screen, but the settings are the same):

    -

    -
    -
    -
     
    -
    - - diff --git a/gdpr.php b/gdpr.php deleted file mode 100644 index f43c50c..0000000 --- a/gdpr.php +++ /dev/null @@ -1,51 +0,0 @@ - -GDPR Statement and Privacy Policy - thunix - -
    -

    GDPR Statement and Privacy Policy

    -
     
    -
    -

    Thunix takes privacy seriously, and as such remains committed to being in compliance with the GDPR, which took affect on May 25th, 2018.

    -
    -
    -
    -

    What data do we collect from you?

    -
     
    -
    -

    Thunix collects your email address, during signup, and IPs you log into the system from, in accordance with technical requirements.

    -

    We also store whatever data you create or maintain in your home directory on Thunix, which may include emails to and from your Thunix account.

    -
    -
    -
    -

    How long do we retain data about you?

    -
     
    -
    -

    Your email address is retained only long enough to process you account creation request. IPs you log into from are retained for a maximum of 30 days.

    -
    -
    -
    -

    How can I request a copy of my data?

    -
     
    -
    -

    You can submit a request at contact page. We will endeavor to provide you a copy of all data we store within 14 days.

    -
    -
    -
    -

    How can I request removal of my information?

    -
     
    -
    -

    You can submit a request at contact page, and we will endeavor to remove all personal data of yours from our system within 14 days. However, this will include removal of your user account from our system as well, which will prevent access to most of the services provided by Thunix.

    -

    If you request deletion of your account, all of your data will be purged within 14 days from our system.

    -
    -
    -
    -

    How do you protect my data?

    -
     
    -
    -

    All data on thunix is encrypted at rest. Logs are maintained only for as long as is technically required (30 days, for troubleshooting of issues). Personally created data, is protected by the UNIX permissions model, as dictated by yourself, however, by default, your personally created data is viewable by all other users of the system, per design.

    -
    -
    -
     
    - - - diff --git a/githook.php b/githook.php deleted file mode 100644 index f5936b5..0000000 --- a/githook.php +++ /dev/null @@ -1,149 +0,0 @@ - $ratelimit ) { - touch ( $ansible_dropfile ); - touch ( $ansible_lastrun ); - echo "HTTP 200 - Ansible webhook recieved.\n"; - } - else { - http_response_code(429); - echo "HTTP 429 - Rate Limited.\n"; - exit(0); - } -} - -// Hook for www repo here. Same rules apply, as above, for www. We -// could probably make it able to run more frequently. Backend job is -// just a git pull, and is quick. -elseif ($data["repository"]["full_name"] == 'thunix/www') { - syslog(LOG_INFO, 'WWW Webhook recieved.'); - if ( time () - filemtime ( $www_lastrun ) > $ratelimit/30 ) { - touch ( $www_dropfile ); - touch ( $www_lastrun ); - http_response_code(200); - echo "HTTP 200 - WWW webhook recieved.\n"; - } - else { - http_response_code(429); - echo "HTTP 429 - Rate Limited.\n"; - exit(0); - } -} - -// Hook for gopher. Not implemented on the backend yet. -elseif ($data["repository"]["full_name"] == 'thunix/thunix_gopher') { - syslog(LOG_INFO, 'Gopher Webhook recieved.'); - if ( time () - filemtime ( $gopher_lastrun ) > $ratelimit ) { - touch ( $gopher_dropfile ); - touch ( $gopher_lastrun ); - http_response_code(200); - echo "HTTP 200 - Gopher webhook recieved.\n"; - } - else { - http_response_code(429); - echo "HTTP 429 - Rate Limited.\n"; - exit(0); - } -} - -//Wiki webhook -elseif ($data["repository"]["full_name"] == 'thunix/wiki') { - syslog(LOG_INFO, 'Wiki Webhook recieved.'); - if ( time () - filemtime ( $wiki_lastrun ) > $ratelimit/30 ) { - touch ( $wiki_dropfile ); - touch ( $wiki_lastrun ); - http_response_code(200); - echo "HTTP 200 - Wiki webhook recieved.\n"; - } - else { - http_response_code(429); - echo "HTTP 429 - Rate Limited.\n"; - exit(0); - } -} - -// Easter egg for anyone probing the hook. Enjoy. We're a coffee maker -// and not a teapot :) -else { - http_response_code(418); - echo "HTTP 418 - I'm a teapot.\n"; - syslog(LOG_INFO, "Tea Pot Webhook recieved.\n"); - exit(0); - } - -/*$fp = pfsockopen( "tcp://127.0.0.1", 1234, $errno, $errstr ); - -if (!$fp) -{ - echo "ERROR: $errno - $errstr
    \n"; -} -socket_set_timeout ($fp, 10); -$msg = "Commit '".$data['commits'][0]["message"]."' was pushed to ".$data["repository"]["full_name"].' by '.$data["pusher"]["login"]; -$msg = trim(preg_replace('/\s+/', ' ', $msg)); -$write = fwrite ($fp, $msg); -fclose($fp); - -if (!$write) { - echo "error writing to port.
    "; - next; -} -*/ -?> - diff --git a/includes/footer.md b/includes/footer.md new file mode 100644 index 0000000..0555fa5 --- /dev/null +++ b/includes/footer.md @@ -0,0 +1,9 @@ +Unless otherwise noted, all thunix.net materials (besides all user-generated content) is licensed as [CC BY-SA 4.0license](https://creativecommons.org/licenses/by-sa/4.0/). Permissions beyond the scope of this license may be available at [https://www.thunix.net/copyright.php](/copyright.php). + +Users define their own licensing and own all of their content. + +Page last updated on 2019-06-23T19:32:58+0000. You may have to refresh the page to see any changes or updates. + +All questions, comments, and concerns about this site should be sent to [the administration team](/contact.php). + +Created with valid [HTML](https://validator.w3.org/check?uri=referer) and [CSS](https://jigsaw.w3.org/css-validator/check/referer) code. diff --git a/includes/header.md b/includes/header.md new file mode 100644 index 0000000..3b14f80 --- /dev/null +++ b/includes/header.md @@ -0,0 +1 @@ +☣ thunix ☣ diff --git a/includes/sidebar.md b/includes/sidebar.md new file mode 100644 index 0000000..e14f521 --- /dev/null +++ b/includes/sidebar.md @@ -0,0 +1,31 @@ +- Main Menu + --------- + + - [Home](main) + - [FAQ](faq) + - [Terms of Service](tos) + - [GDPR Statement and Privacy Policy](gdpr) + - [Contact Us](contact.php) + - [Sign Up](signup.php) + - [Report Abuse](abuse.php) + - [thunix Mirror Services](https://ftp.thunix.net/) + - [Web Server Stats](https://stats.thunix.net/) + - [Donations](donate) +- Main Resources On This Site + --------------------------- + + - [Wiki](https://wiki.thunix.net/) + - [Status of thunix Servers and Services](server.php) + - [Service News](news) + - [User Web Directories](users.php) + - [User Gopher + Directories](https://gopher.tildeverse.org/thunix.net) + - [Web Mail](/webmail/) + - [ZNC Service](https://thunix.net:1326/) +- Server Staff + ------------ + + - [Anton McClure](/~amcclure/) + - [Ubergeek](/~ubergeek/) + - [Naglfar](/~naglfar/) + - [fosslinux](/~fosslinux/) diff --git a/includes/site.css b/includes/site.css new file mode 100644 index 0000000..449f04e --- /dev/null +++ b/includes/site.css @@ -0,0 +1,40 @@ +/* +This file is licensed under the GPL 3.0 or later. +*/ + +body { + font-family: "Courier New", Courier, monospace; +} + +#body { + width: 95%; +} + +#header { + width: 90%; + text-align: center; + font-size: xx-large; +} +#content { + width: 78%; + float: left; + font-size: medium; +} + +#content img { + max-height: 400px; + max-width: 98%; +} + +#sidebar { + width: 18%; + float: right; + font-size: small; +} + +#footer { + width: 90%; + text-align: center; + clear: both; + font-size: smaller; +} diff --git a/includes/thunix.css b/includes/thunix.css new file mode 100644 index 0000000..17729a5 --- /dev/null +++ b/includes/thunix.css @@ -0,0 +1,80 @@ +/* +This file is licensed under the GPL 3.0 or later. +*/ + +body { + font-family: "Courier New", Courier, monospace; + background: black; + color: lime; +} + +#body { + width: 95%; +} + +#body h1 { + background: white; + color: green; +} + +#body h2 { + background: white; + color: green; +} + +#body h3 { + background: white; + color: green; +} + +#body a { + background: black; + color: lime; +} + +#body a:visited { + color: green; +} + +#header { + width: 90%; + text-align: center; + font-size: xx-large; +} +#content { + width: 78%; + float: left; + font-size: medium; +} + +#content img { + max-height: 400px; + max-width: 98%; +} + +.lineitem { + border: 1px; + border-color:white; +} +#sidebar { + width: 18%; + float: right; + font-size: small; +} + +#sidebar h1 { + color: lime; + background: black; +} + +#sidebar h2 { + color: lime; + background: black; +} + +#footer { + width: 95%; + text-align: center; + clear: both; + font-size: smaller; +} diff --git a/index.php b/index.php deleted file mode 100644 index 16942da..0000000 --- a/index.php +++ /dev/null @@ -1,55 +0,0 @@ - -Welcome to thunix - -
    -

    Welcome to thunix!

    -
     
    -
    -

    We're so glad you could drop by and we hope you enjoy your visit. Stay a while! Feel free to inquire about what we have to offer and explore our services.

    -
    -
    - -
    -

    About thunix

    -
     
    -
    -

    thunix offers Secure Shell (SSH) accounts, Web Hosting, Email Accounts, and many other services. But, most of all, we are a community of users. It was founded by hexhaxtron in the Summer of 2017, and was continued by amcclure and ubergeek since 2018. We aim to provide the best service possible with a wide variety of features, and we hope you have fun with it!

    -
    -
    -
    -

    Project Phoenix

    -
     
    -
    -

    The thunix Phoenix project aims to provide a new user experience for shell users, with integration into the wider Tildeverse network.

    -

    Join us on IRC on irc.tilde.chat/6697 in the #thunix channel, or just click here for a web client: #thunix channel

    -

    If you want to sign up for an account, simply open our signup form and provide us with:

    -
      -
    • Your contact name
    • -
    • Your email address (so that we can contact you with login details)
    • -
    • Your desired username (all lowercase, alphanumeric characters only, no spaces)
    • -
    • How you heard about us and what interests you in thunix
    • -
    • Your Public SSH Key
    • -
    -

    thunix tries to adhere to the values and philosophy of the Hacker Ethic whenever possible. The hacker ethics and beliefs as described by Levy are:

    -
      -
    • Access to computers - and anything which might teach you something about the way the world works - should be unlimited and total. Always yield to the Hands-On Imperative!
    • -
    • All information should be free
    • -
    • Mistrust authority - promote decentralization
    • -
    • Hackers should be judged by their hacking, not criteria such as degrees, age, race, sex, or position
    • -
    • You can create art and beauty on a computer
    • -
    • Computers can change your life for the better
    • -
    -

    thunix will never use proprietary software but users can do that if they wish. This is something they should avoid however.

    -

    If you want to help keep thunix running, please consider donating.

    -
    -
    -
     
    - - - diff --git a/license.txt.php b/license.txt.php deleted file mode 100644 index b7a7a01..0000000 --- a/license.txt.php +++ /dev/null @@ -1,181 +0,0 @@ -

    Attribution-ShareAlike 4.0 International

    -

    =======================================================================

    -

    Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.

    -

    Using Creative Commons Public Licenses

    -

    Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.

    -
     Considerations for licensors: Our public licenses are
    - intended for use by those authorized to give the public
    - permission to use material in ways otherwise restricted by
    - copyright and certain other rights. Our licenses are
    - irrevocable. Licensors should read and understand the terms
    - and conditions of the license they choose before applying it.
    - Licensors should also secure all rights necessary before
    - applying our licenses so that the public can reuse the
    - material as expected. Licensors should clearly mark any
    - material not subject to the license. This includes other CC-
    - licensed material, or material used under an exception or
    - limitation to copyright. More considerations for licensors:
    -wiki.creativecommons.org/Considerations_for_licensors
    -
    - Considerations for the public: By using one of our public
    - licenses, a licensor grants the public permission to use the
    - licensed material under specified terms and conditions. If
    - the licensor's permission is not necessary for any reason--for
    - example, because of any applicable exception or limitation to
    - copyright--then that use is not regulated by the license. Our
    - licenses grant only permissions under copyright and certain
    - other rights that a licensor has authority to grant. Use of
    - the licensed material may still be restricted for other
    - reasons, including because others have copyright or other
    - rights in the material. A licensor may make special requests,
    - such as asking that all changes be marked or described.
    - Although not required by our licenses, you are encouraged to
    - respect those requests where reasonable. More considerations
    - for the public: 
    -wiki.creativecommons.org/Considerations_for_licensees
    -

    =======================================================================

    -

    Creative Commons Attribution-ShareAlike 4.0 International Public License

    -

    By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.

    -

    Section 1 -- Definitions.

    -
      -
    1. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.

    2. -
    3. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.

    4. -
    5. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.

    6. -
    7. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.

    8. -
    9. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.

    10. -
    11. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.

    12. -
    13. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.

    14. -
    15. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.

    16. -
    17. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.

    18. -
    19. Licensor means the individual(s) or entity(ies) granting rights under this Public License.

    20. -
    21. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.

    22. -
    23. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.

    24. -
    25. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.

    26. -
    -

    Section 2 -- Scope.

    -
      -
    1. License grant.

      -
        -
      1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:

        -
        a. reproduce and Share the Licensed Material, in whole or
        -   in part; and
        -
        -b. produce, reproduce, and Share Adapted Material.
      2. -
      3. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.

      4. -
      5. Term. The term of this Public License is specified in Section 6(a).

      6. -
      7. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) -
          -
        1. never produces Adapted Material.
        2. -
      8. -
      9. Downstream recipients.

        -
        a. Offer from the Licensor -- Licensed Material. Every
        -   recipient of the Licensed Material automatically
        -   receives an offer from the Licensor to exercise the
        -   Licensed Rights under the terms and conditions of this
        -   Public License.
        -
        -b. Additional offer from the Licensor -- Adapted Material.
        -   Every recipient of Adapted Material from You
        -   automatically receives an offer from the Licensor to
        -   exercise the Licensed Rights in the Adapted Material
        -   under the conditions of the Adapter's License You apply.
        -
        -c. No downstream restrictions. You may not offer or impose
        -   any additional or different terms or conditions on, or
        -   apply any Effective Technological Measures to, the
        -   Licensed Material if doing so restricts exercise of the
        -   Licensed Rights by any recipient of the Licensed
        -   Material.
      10. -
      11. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).

      12. -
    2. -
    3. Other rights.

      -
        -
      1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.

      2. -
      3. Patent and trademark rights are not licensed under this Public License.

      4. -
      5. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.

      6. -
    4. -
    -

    Section 3 -- License Conditions.

    -

    Your exercise of the Licensed Rights is expressly made subject to the following conditions.

    -
      -
    1. Attribution.

      -
        -
      1. If You Share the Licensed Material (including in modified form), You must:

        -
        a. retain the following if it is supplied by the Licensor
        -   with the Licensed Material:
        -
        -     i. identification of the creator(s) of the Licensed
        -        Material and any others designated to receive
        -        attribution, in any reasonable manner requested by
        -        the Licensor (including by pseudonym if
        -        designated);
        -
        -    ii. a copyright notice;
        -
        -   iii. a notice that refers to this Public License;
        -
        -    iv. a notice that refers to the disclaimer of
        -        warranties;
        -
        -     v. a URI or hyperlink to the Licensed Material to the
        -        extent reasonably practicable;
        -
        -b. indicate if You modified the Licensed Material and
        -   retain an indication of any previous modifications; and
        -
        -c. indicate the Licensed Material is licensed under this
        -   Public License, and include the text of, or the URI or
        -   hyperlink to, this Public License.
      2. -
      3. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.

      4. -
      5. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.

      6. -
    2. -
    3. ShareAlike.

      -

      In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.

      -
        -
      1. The Adapter's License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.

      2. -
      3. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.

      4. -
      5. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.

      6. -
    4. -
    -

    Section 4 -- Sui Generis Database Rights.

    -

    Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:

    -
      -
    1. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;

    2. -
    3. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material,

      -including for purposes of Section 3(b); and
    4. -
    5. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.

    6. -
    -

    For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.

    -

    Section 5 -- Disclaimer of Warranties and Limitation of Liability.

    -
      -
    1. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.

    2. -
    3. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.

    4. -
    5. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.

    6. -
    -

    Section 6 -- Term and Termination.

    -
      -
    1. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.

    2. -
    3. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:

      -
        -
      1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or

      2. -
      3. upon express reinstatement by the Licensor.

      4. -
      -

      For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.

    4. -
    5. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.

    6. -
    7. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.

    8. -
    -

    Section 7 -- Other Terms and Conditions.

    -
      -
    1. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.

    2. -
    3. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.

    4. -
    -

    Section 8 -- Interpretation.

    -
      -
    1. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.

    2. -
    3. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.

    4. -
    5. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.

    6. -
    7. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.

    8. -
    -

    =======================================================================

    -

    Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” The text of the Creative Commons public licenses is dedicated to the public domain under the CC0 Public Domain Dedication. Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.

    -

    Creative Commons may be contacted at creativecommons.org.

    diff --git a/news.php b/news.php deleted file mode 100644 index 6d52595..0000000 --- a/news.php +++ /dev/null @@ -1,24 +0,0 @@ - -Thunix News and Updates - thunix - -
    -

    State of the Thunix - May 09, 2019

    -
     
    -
    -

    Another month, another update!

    - -

    Not too much to announce, as far as front end changes. New user requests should happen much faster now that we've written/stolen a tool from tilde.team that we can use to expedite user creation, and automation of a bunch of the steps we take to onboard users.

    -

    We're considering adding in user aging for accounts. Lots of accounts get created, and then never logged into. This can actually post a security problem for the system, as often times, accounts get created now, to be used months from today for botnets and the like. Let us know what your thoughts are on a reasonable time to age off users. At this time, I am personally leaning towards 180 days. Plenty of time to log into your shell, and use it a bit. And, once every 6 months isn't much to ask, since we expect members to actually contribute to the community, anyways.

    -

    We've terminated one account already for running a botnet member from here, and we'll keep a vigilant eye for any others.

    -

    This leads to another point: Just running a znc process doesn't count for login. Neither does checking your email. You'll need to actually log into the shell, in order to reset the counter. You should, anyways, since we have a lot of services internally, that we don't offer external access too.

    -

    We are also looking at terminating the minecraft and minetest instances here. If anyone is using them, speak up now, or forever hold you peace! Not really. We wouldn't be deleting anything, just shutting down the processes, and removing them from the backup scheme.

    -

    We do need to welcome our newest sysadmin here: fosslinux. Give them a warm welcome if you see them around.

    -

    And again, any questions, or concerns, feel free to drop myself, or any of the other admins a line.

    -

    -

    Ubergeek/ub3g33k

    -
    -
    -
     
    - - - diff --git a/parsedown-1.7.3/LICENSE.txt b/parsedown-1.7.3/LICENSE.txt new file mode 100644 index 0000000..8e7c764 --- /dev/null +++ b/parsedown-1.7.3/LICENSE.txt @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013-2018 Emanuil Rusev, erusev.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/parsedown-1.7.3/Parsedown.php b/parsedown-1.7.3/Parsedown.php new file mode 100644 index 0000000..a34b44f --- /dev/null +++ b/parsedown-1.7.3/Parsedown.php @@ -0,0 +1,1693 @@ +DefinitionData = array(); + + # standardize line breaks + $text = str_replace(array("\r\n", "\r"), "\n", $text); + + # remove surrounding line breaks + $text = trim($text, "\n"); + + # split text into lines + $lines = explode("\n", $text); + + # iterate through lines to identify blocks + $markup = $this->lines($lines); + + # trim line breaks + $markup = trim($markup, "\n"); + + return $markup; + } + + # + # Setters + # + + function setBreaksEnabled($breaksEnabled) + { + $this->breaksEnabled = $breaksEnabled; + + return $this; + } + + protected $breaksEnabled; + + function setMarkupEscaped($markupEscaped) + { + $this->markupEscaped = $markupEscaped; + + return $this; + } + + protected $markupEscaped; + + function setUrlsLinked($urlsLinked) + { + $this->urlsLinked = $urlsLinked; + + return $this; + } + + protected $urlsLinked = true; + + function setSafeMode($safeMode) + { + $this->safeMode = (bool) $safeMode; + + return $this; + } + + protected $safeMode; + + protected $safeLinksWhitelist = array( + 'http://', + 'https://', + 'ftp://', + 'ftps://', + 'mailto:', + 'data:image/png;base64,', + 'data:image/gif;base64,', + 'data:image/jpeg;base64,', + 'irc:', + 'ircs:', + 'git:', + 'ssh:', + 'news:', + 'steam:', + ); + + # + # Lines + # + + protected $BlockTypes = array( + '#' => array('Header'), + '*' => array('Rule', 'List'), + '+' => array('List'), + '-' => array('SetextHeader', 'Table', 'Rule', 'List'), + '0' => array('List'), + '1' => array('List'), + '2' => array('List'), + '3' => array('List'), + '4' => array('List'), + '5' => array('List'), + '6' => array('List'), + '7' => array('List'), + '8' => array('List'), + '9' => array('List'), + ':' => array('Table'), + '<' => array('Comment', 'Markup'), + '=' => array('SetextHeader'), + '>' => array('Quote'), + '[' => array('Reference'), + '_' => array('Rule'), + '`' => array('FencedCode'), + '|' => array('Table'), + '~' => array('FencedCode'), + ); + + # ~ + + protected $unmarkedBlockTypes = array( + 'Code', + ); + + # + # Blocks + # + + protected function lines(array $lines) + { + $CurrentBlock = null; + + foreach ($lines as $line) + { + if (chop($line) === '') + { + if (isset($CurrentBlock)) + { + $CurrentBlock['interrupted'] = true; + } + + continue; + } + + if (strpos($line, "\t") !== false) + { + $parts = explode("\t", $line); + + $line = $parts[0]; + + unset($parts[0]); + + foreach ($parts as $part) + { + $shortage = 4 - mb_strlen($line, 'utf-8') % 4; + + $line .= str_repeat(' ', $shortage); + $line .= $part; + } + } + + $indent = 0; + + while (isset($line[$indent]) and $line[$indent] === ' ') + { + $indent ++; + } + + $text = $indent > 0 ? substr($line, $indent) : $line; + + # ~ + + $Line = array('body' => $line, 'indent' => $indent, 'text' => $text); + + # ~ + + if (isset($CurrentBlock['continuable'])) + { + $Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock); + + if (isset($Block)) + { + $CurrentBlock = $Block; + + continue; + } + else + { + if ($this->isBlockCompletable($CurrentBlock['type'])) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + } + } + + # ~ + + $marker = $text[0]; + + # ~ + + $blockTypes = $this->unmarkedBlockTypes; + + if (isset($this->BlockTypes[$marker])) + { + foreach ($this->BlockTypes[$marker] as $blockType) + { + $blockTypes []= $blockType; + } + } + + # + # ~ + + foreach ($blockTypes as $blockType) + { + $Block = $this->{'block'.$blockType}($Line, $CurrentBlock); + + if (isset($Block)) + { + $Block['type'] = $blockType; + + if ( ! isset($Block['identified'])) + { + $Blocks []= $CurrentBlock; + + $Block['identified'] = true; + } + + if ($this->isBlockContinuable($blockType)) + { + $Block['continuable'] = true; + } + + $CurrentBlock = $Block; + + continue 2; + } + } + + # ~ + + if (isset($CurrentBlock) and ! isset($CurrentBlock['type']) and ! isset($CurrentBlock['interrupted'])) + { + $CurrentBlock['element']['text'] .= "\n".$text; + } + else + { + $Blocks []= $CurrentBlock; + + $CurrentBlock = $this->paragraph($Line); + + $CurrentBlock['identified'] = true; + } + } + + # ~ + + if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) + { + $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); + } + + # ~ + + $Blocks []= $CurrentBlock; + + unset($Blocks[0]); + + # ~ + + $markup = ''; + + foreach ($Blocks as $Block) + { + if (isset($Block['hidden'])) + { + continue; + } + + $markup .= "\n"; + $markup .= isset($Block['markup']) ? $Block['markup'] : $this->element($Block['element']); + } + + $markup .= "\n"; + + # ~ + + return $markup; + } + + protected function isBlockContinuable($Type) + { + return method_exists($this, 'block'.$Type.'Continue'); + } + + protected function isBlockCompletable($Type) + { + return method_exists($this, 'block'.$Type.'Complete'); + } + + # + # Code + + protected function blockCode($Line, $Block = null) + { + if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) + { + return; + } + + if ($Line['indent'] >= 4) + { + $text = substr($Line['body'], 4); + + $Block = array( + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => array( + 'name' => 'code', + 'text' => $text, + ), + ), + ); + + return $Block; + } + } + + protected function blockCodeContinue($Line, $Block) + { + if ($Line['indent'] >= 4) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['element']['text']['text'] .= "\n"; + + $text = substr($Line['body'], 4); + + $Block['element']['text']['text'] .= $text; + + return $Block; + } + } + + protected function blockCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Comment + + protected function blockComment($Line) + { + if ($this->markupEscaped or $this->safeMode) + { + return; + } + + if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') + { + $Block = array( + 'markup' => $Line['body'], + ); + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + } + + protected function blockCommentContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + $Block['markup'] .= "\n" . $Line['body']; + + if (preg_match('/-->$/', $Line['text'])) + { + $Block['closed'] = true; + } + + return $Block; + } + + # + # Fenced Code + + protected function blockFencedCode($Line) + { + if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([^`]+)?[ ]*$/', $Line['text'], $matches)) + { + $Element = array( + 'name' => 'code', + 'text' => '', + ); + + if (isset($matches[1])) + { + /** + * https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes + * Every HTML element may have a class attribute specified. + * The attribute, if specified, must have a value that is a set + * of space-separated tokens representing the various classes + * that the element belongs to. + * [...] + * The space characters, for the purposes of this specification, + * are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), + * U+000A LINE FEED (LF), U+000C FORM FEED (FF), and + * U+000D CARRIAGE RETURN (CR). + */ + $language = substr($matches[1], 0, strcspn($matches[1], " \t\n\f\r")); + + $class = 'language-'.$language; + + $Element['attributes'] = array( + 'class' => $class, + ); + } + + $Block = array( + 'char' => $Line['text'][0], + 'element' => array( + 'name' => 'pre', + 'handler' => 'element', + 'text' => $Element, + ), + ); + + return $Block; + } + } + + protected function blockFencedCodeContinue($Line, $Block) + { + if (isset($Block['complete'])) + { + return; + } + + if (isset($Block['interrupted'])) + { + $Block['element']['text']['text'] .= "\n"; + + unset($Block['interrupted']); + } + + if (preg_match('/^'.$Block['char'].'{3,}[ ]*$/', $Line['text'])) + { + $Block['element']['text']['text'] = substr($Block['element']['text']['text'], 1); + + $Block['complete'] = true; + + return $Block; + } + + $Block['element']['text']['text'] .= "\n".$Line['body']; + + return $Block; + } + + protected function blockFencedCodeComplete($Block) + { + $text = $Block['element']['text']['text']; + + $Block['element']['text']['text'] = $text; + + return $Block; + } + + # + # Header + + protected function blockHeader($Line) + { + if (isset($Line['text'][1])) + { + $level = 1; + + while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') + { + $level ++; + } + + if ($level > 6) + { + return; + } + + $text = trim($Line['text'], '# '); + + $Block = array( + 'element' => array( + 'name' => 'h' . min(6, $level), + 'text' => $text, + 'handler' => 'line', + ), + ); + + return $Block; + } + } + + # + # List + + protected function blockList($Line) + { + list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); + + if (preg_match('/^('.$pattern.'[ ]+)(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'indent' => $Line['indent'], + 'pattern' => $pattern, + 'element' => array( + 'name' => $name, + 'handler' => 'elements', + ), + ); + + if($name === 'ol') + { + $listStart = stristr($matches[0], '.', true); + + if($listStart !== '1') + { + $Block['element']['attributes'] = array('start' => $listStart); + } + } + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $matches[2], + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + } + + protected function blockListContinue($Line, array $Block) + { + if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['li']['text'] []= ''; + + $Block['loose'] = true; + + unset($Block['interrupted']); + } + + unset($Block['li']); + + $text = isset($matches[1]) ? $matches[1] : ''; + + $Block['li'] = array( + 'name' => 'li', + 'handler' => 'li', + 'text' => array( + $text, + ), + ); + + $Block['element']['text'] []= & $Block['li']; + + return $Block; + } + + if ($Line['text'][0] === '[' and $this->blockReference($Line)) + { + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + return $Block; + } + + if ($Line['indent'] > 0) + { + $Block['li']['text'] []= ''; + + $text = preg_replace('/^[ ]{0,4}/', '', $Line['body']); + + $Block['li']['text'] []= $text; + + unset($Block['interrupted']); + + return $Block; + } + } + + protected function blockListComplete(array $Block) + { + if (isset($Block['loose'])) + { + foreach ($Block['element']['text'] as &$li) + { + if (end($li['text']) !== '') + { + $li['text'] []= ''; + } + } + } + + return $Block; + } + + # + # Quote + + protected function blockQuote($Line) + { + if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + $Block = array( + 'element' => array( + 'name' => 'blockquote', + 'handler' => 'lines', + 'text' => (array) $matches[1], + ), + ); + + return $Block; + } + } + + protected function blockQuoteContinue($Line, array $Block) + { + if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) + { + if (isset($Block['interrupted'])) + { + $Block['element']['text'] []= ''; + + unset($Block['interrupted']); + } + + $Block['element']['text'] []= $matches[1]; + + return $Block; + } + + if ( ! isset($Block['interrupted'])) + { + $Block['element']['text'] []= $Line['text']; + + return $Block; + } + } + + # + # Rule + + protected function blockRule($Line) + { + if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) + { + $Block = array( + 'element' => array( + 'name' => 'hr' + ), + ); + + return $Block; + } + } + + # + # Setext + + protected function blockSetextHeader($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (chop($Line['text'], $Line['text'][0]) === '') + { + $Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2'; + + return $Block; + } + } + + # + # Markup + + protected function blockMarkup($Line) + { + if ($this->markupEscaped or $this->safeMode) + { + return; + } + + if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches)) + { + $element = strtolower($matches[1]); + + if (in_array($element, $this->textLevelElements)) + { + return; + } + + $Block = array( + 'name' => $matches[1], + 'depth' => 0, + 'markup' => $Line['text'], + ); + + $length = strlen($matches[0]); + + $remainder = substr($Line['text'], $length); + + if (trim($remainder) === '') + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + $Block['closed'] = true; + + $Block['void'] = true; + } + } + else + { + if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) + { + return; + } + + if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder)) + { + $Block['closed'] = true; + } + } + + return $Block; + } + } + + protected function blockMarkupContinue($Line, array $Block) + { + if (isset($Block['closed'])) + { + return; + } + + if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open + { + $Block['depth'] ++; + } + + if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close + { + if ($Block['depth'] > 0) + { + $Block['depth'] --; + } + else + { + $Block['closed'] = true; + } + } + + if (isset($Block['interrupted'])) + { + $Block['markup'] .= "\n"; + + unset($Block['interrupted']); + } + + $Block['markup'] .= "\n".$Line['body']; + + return $Block; + } + + # + # Reference + + protected function blockReference($Line) + { + if (preg_match('/^\[(.+?)\]:[ ]*?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) + { + $id = strtolower($matches[1]); + + $Data = array( + 'url' => $matches[2], + 'title' => null, + ); + + if (isset($matches[3])) + { + $Data['title'] = $matches[3]; + } + + $this->DefinitionData['Reference'][$id] = $Data; + + $Block = array( + 'hidden' => true, + ); + + return $Block; + } + } + + # + # Table + + protected function blockTable($Line, array $Block = null) + { + if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) + { + return; + } + + if (strpos($Block['element']['text'], '|') !== false and chop($Line['text'], ' -:|') === '') + { + $alignments = array(); + + $divider = $Line['text']; + + $divider = trim($divider); + $divider = trim($divider, '|'); + + $dividerCells = explode('|', $divider); + + foreach ($dividerCells as $dividerCell) + { + $dividerCell = trim($dividerCell); + + if ($dividerCell === '') + { + continue; + } + + $alignment = null; + + if ($dividerCell[0] === ':') + { + $alignment = 'left'; + } + + if (substr($dividerCell, - 1) === ':') + { + $alignment = $alignment === 'left' ? 'center' : 'right'; + } + + $alignments []= $alignment; + } + + # ~ + + $HeaderElements = array(); + + $header = $Block['element']['text']; + + $header = trim($header); + $header = trim($header, '|'); + + $headerCells = explode('|', $header); + + foreach ($headerCells as $index => $headerCell) + { + $headerCell = trim($headerCell); + + $HeaderElement = array( + 'name' => 'th', + 'text' => $headerCell, + 'handler' => 'line', + ); + + if (isset($alignments[$index])) + { + $alignment = $alignments[$index]; + + $HeaderElement['attributes'] = array( + 'style' => 'text-align: '.$alignment.';', + ); + } + + $HeaderElements []= $HeaderElement; + } + + # ~ + + $Block = array( + 'alignments' => $alignments, + 'identified' => true, + 'element' => array( + 'name' => 'table', + 'handler' => 'elements', + ), + ); + + $Block['element']['text'] []= array( + 'name' => 'thead', + 'handler' => 'elements', + ); + + $Block['element']['text'] []= array( + 'name' => 'tbody', + 'handler' => 'elements', + 'text' => array(), + ); + + $Block['element']['text'][0]['text'] []= array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $HeaderElements, + ); + + return $Block; + } + } + + protected function blockTableContinue($Line, array $Block) + { + if (isset($Block['interrupted'])) + { + return; + } + + if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) + { + $Elements = array(); + + $row = $Line['text']; + + $row = trim($row); + $row = trim($row, '|'); + + preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]+`|`)+/', $row, $matches); + + foreach ($matches[0] as $index => $cell) + { + $cell = trim($cell); + + $Element = array( + 'name' => 'td', + 'handler' => 'line', + 'text' => $cell, + ); + + if (isset($Block['alignments'][$index])) + { + $Element['attributes'] = array( + 'style' => 'text-align: '.$Block['alignments'][$index].';', + ); + } + + $Elements []= $Element; + } + + $Element = array( + 'name' => 'tr', + 'handler' => 'elements', + 'text' => $Elements, + ); + + $Block['element']['text'][1]['text'] []= $Element; + + return $Block; + } + } + + # + # ~ + # + + protected function paragraph($Line) + { + $Block = array( + 'element' => array( + 'name' => 'p', + 'text' => $Line['text'], + 'handler' => 'line', + ), + ); + + return $Block; + } + + # + # Inline Elements + # + + protected $InlineTypes = array( + '"' => array('SpecialCharacter'), + '!' => array('Image'), + '&' => array('SpecialCharacter'), + '*' => array('Emphasis'), + ':' => array('Url'), + '<' => array('UrlTag', 'EmailTag', 'Markup', 'SpecialCharacter'), + '>' => array('SpecialCharacter'), + '[' => array('Link'), + '_' => array('Emphasis'), + '`' => array('Code'), + '~' => array('Strikethrough'), + '\\' => array('EscapeSequence'), + ); + + # ~ + + protected $inlineMarkerList = '!"*_&[:<>`~\\'; + + # + # ~ + # + + public function line($text, $nonNestables=array()) + { + $markup = ''; + + # $excerpt is based on the first occurrence of a marker + + while ($excerpt = strpbrk($text, $this->inlineMarkerList)) + { + $marker = $excerpt[0]; + + $markerPosition = strpos($text, $marker); + + $Excerpt = array('text' => $excerpt, 'context' => $text); + + foreach ($this->InlineTypes[$marker] as $inlineType) + { + # check to see if the current inline type is nestable in the current context + + if ( ! empty($nonNestables) and in_array($inlineType, $nonNestables)) + { + continue; + } + + $Inline = $this->{'inline'.$inlineType}($Excerpt); + + if ( ! isset($Inline)) + { + continue; + } + + # makes sure that the inline belongs to "our" marker + + if (isset($Inline['position']) and $Inline['position'] > $markerPosition) + { + continue; + } + + # sets a default inline position + + if ( ! isset($Inline['position'])) + { + $Inline['position'] = $markerPosition; + } + + # cause the new element to 'inherit' our non nestables + + foreach ($nonNestables as $non_nestable) + { + $Inline['element']['nonNestables'][] = $non_nestable; + } + + # the text that comes before the inline + $unmarkedText = substr($text, 0, $Inline['position']); + + # compile the unmarked text + $markup .= $this->unmarkedText($unmarkedText); + + # compile the inline + $markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']); + + # remove the examined text + $text = substr($text, $Inline['position'] + $Inline['extent']); + + continue 2; + } + + # the marker does not belong to an inline + + $unmarkedText = substr($text, 0, $markerPosition + 1); + + $markup .= $this->unmarkedText($unmarkedText); + + $text = substr($text, $markerPosition + 1); + } + + $markup .= $this->unmarkedText($text); + + return $markup; + } + + # + # ~ + # + + protected function inlineCode($Excerpt) + { + $marker = $Excerpt['text'][0]; + + if (preg_match('/^('.$marker.'+)[ ]*(.+?)[ ]*(? strlen($matches[0]), + 'element' => array( + 'name' => 'code', + 'text' => $text, + ), + ); + } + } + + protected function inlineEmailTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + if ( ! isset($matches[2])) + { + $url = 'mailto:' . $url; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $matches[1], + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + protected function inlineEmphasis($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + $marker = $Excerpt['text'][0]; + + if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'strong'; + } + elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) + { + $emphasis = 'em'; + } + else + { + return; + } + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => $emphasis, + 'handler' => 'line', + 'text' => $matches[1], + ), + ); + } + + protected function inlineEscapeSequence($Excerpt) + { + if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) + { + return array( + 'markup' => $Excerpt['text'][1], + 'extent' => 2, + ); + } + } + + protected function inlineImage($Excerpt) + { + if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') + { + return; + } + + $Excerpt['text']= substr($Excerpt['text'], 1); + + $Link = $this->inlineLink($Excerpt); + + if ($Link === null) + { + return; + } + + $Inline = array( + 'extent' => $Link['extent'] + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => $Link['element']['attributes']['href'], + 'alt' => $Link['element']['text'], + ), + ), + ); + + $Inline['element']['attributes'] += $Link['element']['attributes']; + + unset($Inline['element']['attributes']['href']); + + return $Inline; + } + + protected function inlineLink($Excerpt) + { + $Element = array( + 'name' => 'a', + 'handler' => 'line', + 'nonNestables' => array('Url', 'Link'), + 'text' => null, + 'attributes' => array( + 'href' => null, + 'title' => null, + ), + ); + + $extent = 0; + + $remainder = $Excerpt['text']; + + if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches)) + { + $Element['text'] = $matches[1]; + + $extent += strlen($matches[0]); + + $remainder = substr($remainder, $extent); + } + else + { + return; + } + + if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*"|\'[^\']*\'))?\s*[)]/', $remainder, $matches)) + { + $Element['attributes']['href'] = $matches[1]; + + if (isset($matches[2])) + { + $Element['attributes']['title'] = substr($matches[2], 1, - 1); + } + + $extent += strlen($matches[0]); + } + else + { + if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches)) + { + $definition = strlen($matches[1]) ? $matches[1] : $Element['text']; + $definition = strtolower($definition); + + $extent += strlen($matches[0]); + } + else + { + $definition = strtolower($Element['text']); + } + + if ( ! isset($this->DefinitionData['Reference'][$definition])) + { + return; + } + + $Definition = $this->DefinitionData['Reference'][$definition]; + + $Element['attributes']['href'] = $Definition['url']; + $Element['attributes']['title'] = $Definition['title']; + } + + return array( + 'extent' => $extent, + 'element' => $Element, + ); + } + + protected function inlineMarkup($Excerpt) + { + if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false) + { + return; + } + + if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + + if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) + { + return array( + 'markup' => $matches[0], + 'extent' => strlen($matches[0]), + ); + } + } + + protected function inlineSpecialCharacter($Excerpt) + { + if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) + { + return array( + 'markup' => '&', + 'extent' => 1, + ); + } + + $SpecialCharacter = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); + + if (isset($SpecialCharacter[$Excerpt['text'][0]])) + { + return array( + 'markup' => '&'.$SpecialCharacter[$Excerpt['text'][0]].';', + 'extent' => 1, + ); + } + } + + protected function inlineStrikethrough($Excerpt) + { + if ( ! isset($Excerpt['text'][1])) + { + return; + } + + if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) + { + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'del', + 'text' => $matches[1], + 'handler' => 'line', + ), + ); + } + } + + protected function inlineUrl($Excerpt) + { + if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') + { + return; + } + + if (preg_match('/\bhttps?:[\/]{2}[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) + { + $url = $matches[0][0]; + + $Inline = array( + 'extent' => strlen($matches[0][0]), + 'position' => $matches[0][1], + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + + return $Inline; + } + } + + protected function inlineUrlTag($Excerpt) + { + if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) + { + $url = $matches[1]; + + return array( + 'extent' => strlen($matches[0]), + 'element' => array( + 'name' => 'a', + 'text' => $url, + 'attributes' => array( + 'href' => $url, + ), + ), + ); + } + } + + # ~ + + protected function unmarkedText($text) + { + if ($this->breaksEnabled) + { + $text = preg_replace('/[ ]*\n/', "
    \n", $text); + } + else + { + $text = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "
    \n", $text); + $text = str_replace(" \n", "\n", $text); + } + + return $text; + } + + # + # Handlers + # + + protected function element(array $Element) + { + if ($this->safeMode) + { + $Element = $this->sanitiseElement($Element); + } + + $markup = '<'.$Element['name']; + + if (isset($Element['attributes'])) + { + foreach ($Element['attributes'] as $name => $value) + { + if ($value === null) + { + continue; + } + + $markup .= ' '.$name.'="'.self::escape($value).'"'; + } + } + + if (isset($Element['text'])) + { + $markup .= '>'; + + if (!isset($Element['nonNestables'])) + { + $Element['nonNestables'] = array(); + } + + if (isset($Element['handler'])) + { + $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']); + } + else + { + $markup .= self::escape($Element['text'], true); + } + + $markup .= ''; + } + else + { + $markup .= ' />'; + } + + return $markup; + } + + protected function elements(array $Elements) + { + $markup = ''; + + foreach ($Elements as $Element) + { + $markup .= "\n" . $this->element($Element); + } + + $markup .= "\n"; + + return $markup; + } + + # ~ + + protected function li($lines) + { + $markup = $this->lines($lines); + + $trimmedMarkup = trim($markup); + + if ( ! in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '

    ') + { + $markup = $trimmedMarkup; + $markup = substr($markup, 3); + + $position = strpos($markup, "

    "); + + $markup = substr_replace($markup, '', $position, 4); + } + + return $markup; + } + + # + # Deprecated Methods + # + + function parse($text) + { + $markup = $this->text($text); + + return $markup; + } + + protected function sanitiseElement(array $Element) + { + static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; + static $safeUrlNameToAtt = array( + 'a' => 'href', + 'img' => 'src', + ); + + if (isset($safeUrlNameToAtt[$Element['name']])) + { + $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); + } + + if ( ! empty($Element['attributes'])) + { + foreach ($Element['attributes'] as $att => $val) + { + # filter out badly parsed attribute + if ( ! preg_match($goodAttribute, $att)) + { + unset($Element['attributes'][$att]); + } + # dump onevent attribute + elseif (self::striAtStart($att, 'on')) + { + unset($Element['attributes'][$att]); + } + } + } + + return $Element; + } + + protected function filterUnsafeUrlInAttribute(array $Element, $attribute) + { + foreach ($this->safeLinksWhitelist as $scheme) + { + if (self::striAtStart($Element['attributes'][$attribute], $scheme)) + { + return $Element; + } + } + + $Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]); + + return $Element; + } + + # + # Static Methods + # + + protected static function escape($text, $allowQuotes = false) + { + return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8'); + } + + protected static function striAtStart($string, $needle) + { + $len = strlen($needle); + + if ($len > strlen($string)) + { + return false; + } + else + { + return strtolower(substr($string, 0, $len)) === strtolower($needle); + } + } + + static function instance($name = 'default') + { + if (isset(self::$instances[$name])) + { + return self::$instances[$name]; + } + + $instance = new static(); + + self::$instances[$name] = $instance; + + return $instance; + } + + private static $instances = array(); + + # + # Fields + # + + protected $DefinitionData; + + # + # Read-Only + + protected $specialCharacters = array( + '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', + ); + + protected $StrongRegex = array( + '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', + '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', + ); + + protected $EmRegex = array( + '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', + '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', + ); + + protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; + + protected $voidElements = array( + 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', + ); + + protected $textLevelElements = array( + 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', + 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', + 'i', 'rp', 'del', 'code', 'strike', 'marquee', + 'q', 'rt', 'ins', 'font', 'strong', + 's', 'tt', 'kbd', 'mark', + 'u', 'xm', 'sub', 'nobr', + 'sup', 'ruby', + 'var', 'span', + 'wbr', 'time', + ); +} diff --git a/parsedown-1.7.3/README.md b/parsedown-1.7.3/README.md new file mode 100644 index 0000000..b5d9ed2 --- /dev/null +++ b/parsedown-1.7.3/README.md @@ -0,0 +1,86 @@ +> I also make [Caret](https://caret.io?ref=parsedown) - a Markdown editor for Mac and PC. + +## Parsedown + +[![Build Status](https://img.shields.io/travis/erusev/parsedown/master.svg?style=flat-square)](https://travis-ci.org/erusev/parsedown) + + +Better Markdown Parser in PHP + +[Demo](http://parsedown.org/demo) | +[Benchmarks](http://parsedown.org/speed) | +[Tests](http://parsedown.org/tests/) | +[Documentation](https://github.com/erusev/parsedown/wiki/) + +### Features + +* One File +* No Dependencies +* Super Fast +* Extensible +* [GitHub flavored](https://help.github.com/articles/github-flavored-markdown) +* Tested in 5.3 to 7.1 and in HHVM +* [Markdown Extra extension](https://github.com/erusev/parsedown-extra) + +### Installation + +Include `Parsedown.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown). + +### Example + +``` php +$Parsedown = new Parsedown(); + +echo $Parsedown->text('Hello _Parsedown_!'); # prints:

    Hello Parsedown!

    +``` + +More examples in [the wiki](https://github.com/erusev/parsedown/wiki/) and in [this video tutorial](http://youtu.be/wYZBY8DEikI). + +### Security + +Parsedown is capable of escaping user-input within the HTML that it generates. Additionally Parsedown will apply sanitisation to additional scripting vectors (such as scripting link destinations) that are introduced by the markdown syntax itself. + +To tell Parsedown that it is processing untrusted user-input, use the following: +```php +$parsedown = new Parsedown; +$parsedown->setSafeMode(true); +``` + +If instead, you wish to allow HTML within untrusted user-input, but still want output to be free from XSS it is recommended that you make use of a HTML sanitiser that allows HTML tags to be whitelisted, like [HTML Purifier](http://htmlpurifier.org/). + +In both cases you should strongly consider employing defence-in-depth measures, like [deploying a Content-Security-Policy](https://scotthelme.co.uk/content-security-policy-an-introduction/) (a browser security feature) so that your page is likely to be safe even if an attacker finds a vulnerability in one of the first lines of defence above. + +#### Security of Parsedown Extensions + +Safe mode does not necessarily yield safe results when using extensions to Parsedown. Extensions should be evaluated on their own to determine their specific safety against XSS. + +### Escaping HTML +> ⚠️  **WARNING:** This method isn't safe from XSS! + +If you wish to escape HTML **in trusted input**, you can use the following: +```php +$parsedown = new Parsedown; +$parsedown->setMarkupEscaped(true); +``` + +Beware that this still allows users to insert unsafe scripting vectors, such as links like `[xss](javascript:alert%281%29)`. + +### Questions + +**How does Parsedown work?** + +It tries to read Markdown like a human. First, it looks at the lines. It’s interested in how the lines start. This helps it recognise blocks. It knows, for example, that if a line starts with a `-` then perhaps it belongs to a list. Once it recognises the blocks, it continues to the content. As it reads, it watches out for special characters. This helps it recognise inline elements (or inlines). + +We call this approach "line based". We believe that Parsedown is the first Markdown parser to use it. Since the release of Parsedown, other developers have used the same approach to develop other Markdown parsers in PHP and in other languages. + +**Is it compliant with CommonMark?** + +It passes most of the CommonMark tests. Most of the tests that don't pass deal with cases that are quite uncommon. Still, as CommonMark matures, compliance should improve. + +**Who uses it?** + +[Laravel Framework](https://laravel.com/), [Bolt CMS](http://bolt.cm/), [Grav CMS](http://getgrav.org/), [Herbie CMS](http://www.getherbie.org/), [Kirby CMS](http://getkirby.com/), [October CMS](http://octobercms.com/), [Pico CMS](http://picocms.org), [Statamic CMS](http://www.statamic.com/), [phpDocumentor](http://www.phpdoc.org/), [RaspberryPi.org](http://www.raspberrypi.org/), [Symfony demo](https://github.com/symfony/symfony-demo) and [more](https://packagist.org/packages/erusev/parsedown/dependents). + +**How can I help?** + +Use it, star it, share it and if you feel generous, [donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=528P3NZQMP8N2). diff --git a/parsedown-1.7.3/composer.json b/parsedown-1.7.3/composer.json new file mode 100644 index 0000000..f8b40f8 --- /dev/null +++ b/parsedown-1.7.3/composer.json @@ -0,0 +1,33 @@ +{ + "name": "erusev/parsedown", + "description": "Parser for Markdown.", + "keywords": ["markdown", "parser"], + "homepage": "http://parsedown.org", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "require": { + "php": ">=5.3.0", + "ext-mbstring": "*" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35" + }, + "autoload": { + "psr-0": {"Parsedown": ""} + }, + "autoload-dev": { + "psr-0": { + "TestParsedown": "test/", + "ParsedownTest": "test/", + "CommonMarkTest": "test/", + "CommonMarkTestWeak": "test/" + } + } +} diff --git a/parsedown-extra-0.7.1/.travis.yml b/parsedown-extra-0.7.1/.travis.yml new file mode 100644 index 0000000..ea376fb --- /dev/null +++ b/parsedown-extra-0.7.1/.travis.yml @@ -0,0 +1,11 @@ +language: php + +php: + - 5.6 + - 5.5 + - 5.4 + - 5.3 + +install: + - composer self-update + - composer install \ No newline at end of file diff --git a/parsedown-extra-0.7.1/LICENSE.txt b/parsedown-extra-0.7.1/LICENSE.txt new file mode 100644 index 0000000..baca86f --- /dev/null +++ b/parsedown-extra-0.7.1/LICENSE.txt @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Emanuil Rusev, erusev.com + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/parsedown-extra-0.7.1/ParsedownExtra.php b/parsedown-extra-0.7.1/ParsedownExtra.php new file mode 100644 index 0000000..be6966d --- /dev/null +++ b/parsedown-extra-0.7.1/ParsedownExtra.php @@ -0,0 +1,526 @@ +BlockTypes[':'] []= 'DefinitionList'; + $this->BlockTypes['*'] []= 'Abbreviation'; + + # identify footnote definitions before reference definitions + array_unshift($this->BlockTypes['['], 'Footnote'); + + # identify footnote markers before before links + array_unshift($this->InlineTypes['['], 'FootnoteMarker'); + } + + # + # ~ + + function text($text) + { + $markup = parent::text($text); + + # merge consecutive dl elements + + $markup = preg_replace('/<\/dl>\s+
    \s+/', '', $markup); + + # add footnotes + + if (isset($this->DefinitionData['Footnote'])) + { + $Element = $this->buildFootnoteElement(); + + $markup .= "\n" . $this->element($Element); + } + + return $markup; + } + + # + # Blocks + # + + # + # Abbreviation + + protected function blockAbbreviation($Line) + { + if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches)) + { + $this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2]; + + $Block = array( + 'hidden' => true, + ); + + return $Block; + } + } + + # + # Footnote + + protected function blockFootnote($Line) + { + if (preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches)) + { + $Block = array( + 'label' => $matches[1], + 'text' => $matches[2], + 'hidden' => true, + ); + + return $Block; + } + } + + protected function blockFootnoteContinue($Line, $Block) + { + if ($Line['text'][0] === '[' and preg_match('/^\[\^(.+?)\]:/', $Line['text'])) + { + return; + } + + if (isset($Block['interrupted'])) + { + if ($Line['indent'] >= 4) + { + $Block['text'] .= "\n\n" . $Line['text']; + + return $Block; + } + } + else + { + $Block['text'] .= "\n" . $Line['text']; + + return $Block; + } + } + + protected function blockFootnoteComplete($Block) + { + $this->DefinitionData['Footnote'][$Block['label']] = array( + 'text' => $Block['text'], + 'count' => null, + 'number' => null, + ); + + return $Block; + } + + # + # Definition List + + protected function blockDefinitionList($Line, $Block) + { + if ( ! isset($Block) or isset($Block['type'])) + { + return; + } + + $Element = array( + 'name' => 'dl', + 'handler' => 'elements', + 'text' => array(), + ); + + $terms = explode("\n", $Block['element']['text']); + + foreach ($terms as $term) + { + $Element['text'] []= array( + 'name' => 'dt', + 'handler' => 'line', + 'text' => $term, + ); + } + + $Block['element'] = $Element; + + $Block = $this->addDdElement($Line, $Block); + + return $Block; + } + + protected function blockDefinitionListContinue($Line, array $Block) + { + if ($Line['text'][0] === ':') + { + $Block = $this->addDdElement($Line, $Block); + + return $Block; + } + else + { + if (isset($Block['interrupted']) and $Line['indent'] === 0) + { + return; + } + + if (isset($Block['interrupted'])) + { + $Block['dd']['handler'] = 'text'; + $Block['dd']['text'] .= "\n\n"; + + unset($Block['interrupted']); + } + + $text = substr($Line['body'], min($Line['indent'], 4)); + + $Block['dd']['text'] .= "\n" . $text; + + return $Block; + } + } + + # + # Header + + protected function blockHeader($Line) + { + $Block = parent::blockHeader($Line); + + if (preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE)) + { + $attributeString = $matches[1][0]; + + $Block['element']['attributes'] = $this->parseAttributeData($attributeString); + + $Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]); + } + + return $Block; + } + + # + # Markup + + protected function blockMarkupComplete($Block) + { + if ( ! isset($Block['void'])) + { + $Block['markup'] = $this->processTag($Block['markup']); + } + + return $Block; + } + + # + # Setext + + protected function blockSetextHeader($Line, array $Block = null) + { + $Block = parent::blockSetextHeader($Line, $Block); + + if (preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE)) + { + $attributeString = $matches[1][0]; + + $Block['element']['attributes'] = $this->parseAttributeData($attributeString); + + $Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]); + } + + return $Block; + } + + # + # Inline Elements + # + + # + # Footnote Marker + + protected function inlineFootnoteMarker($Excerpt) + { + if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches)) + { + $name = $matches[1]; + + if ( ! isset($this->DefinitionData['Footnote'][$name])) + { + return; + } + + $this->DefinitionData['Footnote'][$name]['count'] ++; + + if ( ! isset($this->DefinitionData['Footnote'][$name]['number'])) + { + $this->DefinitionData['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » & + } + + $Element = array( + 'name' => 'sup', + 'attributes' => array('id' => 'fnref'.$this->DefinitionData['Footnote'][$name]['count'].':'.$name), + 'handler' => 'element', + 'text' => array( + 'name' => 'a', + 'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'), + 'text' => $this->DefinitionData['Footnote'][$name]['number'], + ), + ); + + return array( + 'extent' => strlen($matches[0]), + 'element' => $Element, + ); + } + } + + private $footnoteCount = 0; + + # + # Link + + protected function inlineLink($Excerpt) + { + $Link = parent::inlineLink($Excerpt); + + $remainder = substr($Excerpt['text'], $Link['extent']); + + if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches)) + { + $Link['element']['attributes'] += $this->parseAttributeData($matches[1]); + + $Link['extent'] += strlen($matches[0]); + } + + return $Link; + } + + # + # ~ + # + + protected function unmarkedText($text) + { + $text = parent::unmarkedText($text); + + if (isset($this->DefinitionData['Abbreviation'])) + { + foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning) + { + $pattern = '/\b'.preg_quote($abbreviation, '/').'\b/'; + + $text = preg_replace($pattern, ''.$abbreviation.'', $text); + } + } + + return $text; + } + + # + # Util Methods + # + + protected function addDdElement(array $Line, array $Block) + { + $text = substr($Line['text'], 1); + $text = trim($text); + + unset($Block['dd']); + + $Block['dd'] = array( + 'name' => 'dd', + 'handler' => 'line', + 'text' => $text, + ); + + if (isset($Block['interrupted'])) + { + $Block['dd']['handler'] = 'text'; + + unset($Block['interrupted']); + } + + $Block['element']['text'] []= & $Block['dd']; + + return $Block; + } + + protected function buildFootnoteElement() + { + $Element = array( + 'name' => 'div', + 'attributes' => array('class' => 'footnotes'), + 'handler' => 'elements', + 'text' => array( + array( + 'name' => 'hr', + ), + array( + 'name' => 'ol', + 'handler' => 'elements', + 'text' => array(), + ), + ), + ); + + uasort($this->DefinitionData['Footnote'], 'self::sortFootnotes'); + + foreach ($this->DefinitionData['Footnote'] as $definitionId => $DefinitionData) + { + if ( ! isset($DefinitionData['number'])) + { + continue; + } + + $text = $DefinitionData['text']; + + $text = parent::text($text); + + $numbers = range(1, $DefinitionData['count']); + + $backLinksMarkup = ''; + + foreach ($numbers as $number) + { + $backLinksMarkup .= ' '; + } + + $backLinksMarkup = substr($backLinksMarkup, 1); + + if (substr($text, - 4) === '

    ') + { + $backLinksMarkup = ' '.$backLinksMarkup; + + $text = substr_replace($text, $backLinksMarkup.'

    ', - 4); + } + else + { + $text .= "\n".'

    '.$backLinksMarkup.'

    '; + } + + $Element['text'][1]['text'] []= array( + 'name' => 'li', + 'attributes' => array('id' => 'fn:'.$definitionId), + 'text' => "\n".$text."\n", + ); + } + + return $Element; + } + + # ~ + + protected function parseAttributeData($attributeString) + { + $Data = array(); + + $attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY); + + foreach ($attributes as $attribute) + { + if ($attribute[0] === '#') + { + $Data['id'] = substr($attribute, 1); + } + else # "." + { + $classes []= substr($attribute, 1); + } + } + + if (isset($classes)) + { + $Data['class'] = implode(' ', $classes); + } + + return $Data; + } + + # ~ + + protected function processTag($elementMarkup) # recursive + { + # http://stackoverflow.com/q/1148928/200145 + libxml_use_internal_errors(true); + + $DOMDocument = new DOMDocument; + + # http://stackoverflow.com/q/11309194/200145 + $elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8'); + + # http://stackoverflow.com/q/4879946/200145 + $DOMDocument->loadHTML($elementMarkup); + $DOMDocument->removeChild($DOMDocument->doctype); + $DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild); + + $elementText = ''; + + if ($DOMDocument->documentElement->getAttribute('markdown') === '1') + { + foreach ($DOMDocument->documentElement->childNodes as $Node) + { + $elementText .= $DOMDocument->saveHTML($Node); + } + + $DOMDocument->documentElement->removeAttribute('markdown'); + + $elementText = "\n".$this->text($elementText)."\n"; + } + else + { + foreach ($DOMDocument->documentElement->childNodes as $Node) + { + $nodeMarkup = $DOMDocument->saveHTML($Node); + + if ($Node instanceof DOMElement and ! in_array($Node->nodeName, $this->textLevelElements)) + { + $elementText .= $this->processTag($nodeMarkup); + } + else + { + $elementText .= $nodeMarkup; + } + } + } + + # because we don't want for markup to get encoded + $DOMDocument->documentElement->nodeValue = 'placeholder\x1A'; + + $markup = $DOMDocument->saveHTML($DOMDocument->documentElement); + $markup = str_replace('placeholder\x1A', $elementText, $markup); + + return $markup; + } + + # ~ + + protected function sortFootnotes($A, $B) # callback + { + return $A['number'] - $B['number']; + } + + # + # Fields + # + + protected $regexAttribute = '(?:[#.][-\w]+[ ]*)'; +} diff --git a/parsedown-extra-0.7.1/README.md b/parsedown-extra-0.7.1/README.md new file mode 100644 index 0000000..cee4b54 --- /dev/null +++ b/parsedown-extra-0.7.1/README.md @@ -0,0 +1,31 @@ +> You might also like [Caret](http://caret.io?ref=parsedown) - our Markdown editor for the Desktop. + +## Parsedown Extra + +[![Build Status](https://img.shields.io/travis/erusev/parsedown-extra/master.svg?style=flat-square)](https://travis-ci.org/erusev/parsedown-extra) + +An extension of [Parsedown](http://parsedown.org) that adds support for [Markdown Extra](https://michelf.ca/projects/php-markdown/extra/). + +[See Demo](http://parsedown.org/extra/) + +### Installation + +Include both `Parsedown.php` and `ParsedownExtra.php` or install [the composer package](https://packagist.org/packages/erusev/parsedown-extra). + +### Example + +``` php +$Extra = new ParsedownExtra(); + +echo $Extra->text('# Header {.sth}'); # prints:

    Header

    +``` + +### Questions + +**Who uses Parsedown Extra?** + +[October CMS](http://octobercms.com/), [Bolt CMS](http://bolt.cm/), [Kirby CMS](http://getkirby.com/), [Grav CMS](http://getgrav.org/), [Statamic CMS](http://www.statamic.com/) and [more](https://www.versioneye.com/php/erusev:parsedown-extra/references). + +**How can I help?** + +Use it, star it, share it and in case you feel generous, [donate some money](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=528P3NZQMP8N2). diff --git a/parsedown-extra-0.7.1/composer.json b/parsedown-extra-0.7.1/composer.json new file mode 100644 index 0000000..36eedbb --- /dev/null +++ b/parsedown-extra-0.7.1/composer.json @@ -0,0 +1,21 @@ +{ + "name": "erusev/parsedown-extra", + "description": "An extension of Parsedown that adds support for Markdown Extra.", + "keywords": ["markdown", "markdown extra", "parser", "parsedown"], + "homepage": "https://github.com/erusev/parsedown-extra", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Emanuil Rusev", + "email": "hello@erusev.com", + "homepage": "http://erusev.com" + } + ], + "require": { + "erusev/parsedown": "~1.4" + }, + "autoload": { + "psr-0": {"ParsedownExtra": ""} + } +} \ No newline at end of file diff --git a/parsedown-extra-0.7.1/phpunit.xml.dist b/parsedown-extra-0.7.1/phpunit.xml.dist new file mode 100644 index 0000000..d4f2cac --- /dev/null +++ b/parsedown-extra-0.7.1/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + test/ParsedownExtraTest.php + + + \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/ParsedownExtraTest.php b/parsedown-extra-0.7.1/test/ParsedownExtraTest.php new file mode 100644 index 0000000..4fff778 --- /dev/null +++ b/parsedown-extra-0.7.1/test/ParsedownExtraTest.php @@ -0,0 +1,20 @@ +The HTML specification +is maintained by the W3C. +The abbreviation ML is contained in the abbreviation HTML.

    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/abbreviation.md b/parsedown-extra-0.7.1/test/data/abbreviation.md new file mode 100644 index 0000000..4ac8f88 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/abbreviation.md @@ -0,0 +1,7 @@ +The HTML specification +is maintained by the W3C. +The abbreviation ML is contained in the abbreviation HTML. + +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +*[ML]: Markup Language \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/compound_footnote.html b/parsedown-extra-0.7.1/test/data/compound_footnote.html new file mode 100644 index 0000000..1a3848f --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/compound_footnote.html @@ -0,0 +1,18 @@ +

    footnote 1 and another one 2

    +
    +
    +
      +
    1. +

      line 1 +line 2

      +
      +

      quote

      +
      +

      another paragraph 

      +
    2. +
    3. +

      paragraph

      +

      another paragraph 

      +
    4. +
    +
    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/compound_footnote.md b/parsedown-extra-0.7.1/test/data/compound_footnote.md new file mode 100644 index 0000000..5bca3c7 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/compound_footnote.md @@ -0,0 +1,14 @@ +footnote [^1] and another one [^2] + +[^1]: line 1 + line 2 + + > quote + + another paragraph + +[^2]: + paragraph + + another paragraph + \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/definition_list.html b/parsedown-extra-0.7.1/test/data/definition_list.html new file mode 100644 index 0000000..2567dc1 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/definition_list.html @@ -0,0 +1,17 @@ +
    +
    Term 1
    +
    one
    +
    two +extra line
    +
    Term 2
    +

    lazy +line

    +

    multiple

    +

    paragraphs

    +

    nested

    +
    code block
    +
    +

    quote +block

    +
    +
    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/definition_list.md b/parsedown-extra-0.7.1/test/data/definition_list.md new file mode 100644 index 0000000..ec0ee03 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/definition_list.md @@ -0,0 +1,20 @@ +Term 1 +: one +: two + extra line + +Term 2 + +: lazy +line + +: multiple + + paragraphs + +: nested + + code block + + > quote + > block \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/footnote.html b/parsedown-extra-0.7.1/test/data/footnote.html new file mode 100644 index 0000000..d0ba76c --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/footnote.html @@ -0,0 +1,20 @@ +

    first 1 second 2.

    +

    first 3 second 4.

    +

    second time 1

    +
    +
    +
      +
    1. +

      one 

      +
    2. +
    3. +

      two 

      +
    4. +
    5. +

      one 

      +
    6. +
    7. +

      two 

      +
    8. +
    +
    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/footnote.md b/parsedown-extra-0.7.1/test/data/footnote.md new file mode 100644 index 0000000..07d7010 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/footnote.md @@ -0,0 +1,11 @@ +first [^1] second [^2]. + +[^1]: one +[^2]: two + +first [^a] second [^b]. + +[^a]: one +[^b]: two + +second time [^1] \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/markdown_inside_markup.html b/parsedown-extra-0.7.1/test/data/markdown_inside_markup.html new file mode 100644 index 0000000..27da259 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/markdown_inside_markup.html @@ -0,0 +1,25 @@ +
    +

    markdown

    +

    This is another paragraph. It contains inline markup.

    +
    +_no markdown_ +
    +
    +
    +
    +

    markdown

    +
    +

    markdown

    +
    +
    +
    +
    +_no markdown_ +
    +

    markdown

    +
    +
    +
    +
    +_no markdown_ +
    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/markdown_inside_markup.md b/parsedown-extra-0.7.1/test/data/markdown_inside_markup.md new file mode 100644 index 0000000..dbb85d6 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/markdown_inside_markup.md @@ -0,0 +1,32 @@ +
    +_markdown_ + +This is another paragraph. It contains inline markup. +
    +_no markdown_ +
    +
    + +--- + +
    +_markdown_ +
    +_markdown_ +
    +
    + +--- + +
    +_no markdown_ +
    +_markdown_ +
    +
    + +--- + +
    +_no markdown_ +
    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/special_attributes.html b/parsedown-extra-0.7.1/test/data/special_attributes.html new file mode 100644 index 0000000..cafa311 --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/special_attributes.html @@ -0,0 +1,6 @@ +

    Header 1

    +

    Header 2

    +

    The Site

    +

    The Site

    +

    link

    +

    \ No newline at end of file diff --git a/parsedown-extra-0.7.1/test/data/special_attributes.md b/parsedown-extra-0.7.1/test/data/special_attributes.md new file mode 100644 index 0000000..01f29fc --- /dev/null +++ b/parsedown-extra-0.7.1/test/data/special_attributes.md @@ -0,0 +1,12 @@ +Header 1 {#header1} +======== + +## Header 2 ## {#header2} + +## The Site ## {.main} + +## The Site ## {.main .shine #the-site} + +[link](http://parsedown.org) {.primary #link .upper-case} + +![logo](/md.png) {#logo .big} \ No newline at end of file diff --git a/server.php b/server.php deleted file mode 100644 index 03f687e..0000000 --- a/server.php +++ /dev/null @@ -1,101 +0,0 @@ - -Status of thunix Servers and Services - thunix - -
    -

    Service Status and Information

    -
     
    -
    -

    Minetest

    -

    Connect to thunix.net:30000 in your minetest client

    -
    -

    Minecraft

    -

    Connect to thunix.net in your minecraft client. Running the Paperclip minecraft server.

    -


    -

    Mail Services

    -

    Thunix offers webmail at https://thunix.net/webmail. You can also connect via imap. Thunderbird will autodetect your settings, and we recommend the use of Thunderbird email client, so you can get the best-of-breed email experience. We also recommend using enigmail with Thunderbird as well. You can get it from your distro's package manager, or from the Thunderbird project's site

    -
    -

    Onion Service

    -

    Thunix's services are available as a onion site as well. Our onion address is thunixme5v4rnoby.onion.

    -
    -

    BZFlag Game Server

    -

    BZFlag runs on the standard port. If you have a specific map you want loaded, send an email to root, and we'll look at getting the map swapped out

    -
    -

    IRC Chat

    -

    Thunix is part of the tilde.chat network. You can access chat via the terminal, with the 'chat' command, via your favorite email client at irc.tilde.chat/6697, or via a web chat interface located here.

    -
    -

    FOSS Project Mirrors

    -

    Thunix hosts mirrors for several FOSS projects. You can see the full mirror list in the sidebar link.

    -
    -
    - - -
    -
    -

    Server Status

    -
     
    -
    -

    - -\n"; -echo ""; -echo " - - - - "; -while (($line = fgetcsv($f)) !== false) { - echo ""; - if ($hosts == "failed" ) { - if ($line[2] == "FAILED") { - foreach ($line as $cell) { - if ($cell == "FAILED") { - echo ''; - } - else { - echo ""; - } - } - } - } - elseif ($hosts == "all") { - foreach ($line as $cell) { - if ($cell == "FAILED") { - echo ''; - } - elseif ($cell=="GOOD") { - echo '"; - } - else { - echo ""; - } - } - } - echo "\n"; -} -echo "\n
    HostCheckStatus
    ' . htmlspecialchars($cell) . '" .htmlspecialchars($cell) . "' . htmlspecialchars($cell) . '' . htmlspecialchars($cell) . "" .htmlspecialchars($cell) . "
    \n"; -fclose($f); -?> - - -

    -
    -
    -
     
    - - - diff --git a/server.php.old b/server.php.old deleted file mode 100644 index 598b4fb..0000000 --- a/server.php.old +++ /dev/null @@ -1,92 +0,0 @@ - -Status of thunix Servers and Services - thunix - -
    -

    Information and Service Status

    -
     
    -
    -

    State of the Thunix - May 09, 2019

    -

    Another month, another update!

    - -

    Not too much to announce, as far as front end changes. New user requests should happen much faster now that we've written/stolen a tool from tilde.team that we can use to expedite user creation, and automation of a bunch of the steps we take to onboard users.

    -

    We're considering adding in user aging for accounts. Lots of accounts get created, and then never logged into. This can actually post a security problem for the system, as often times, accounts get created now, to be used months from today for botnets and the like. Let us know what your thoughts are on a reasonable time to age off users. At this time, I am personally leaning towards 180 days. Plenty of time to log into your shell, and use it a bit. And, once every 6 months isn't much to ask, since we expect members to actually contribute to the community, anyways.

    -

    We've terminated one account already for running a botnet member from here, and we'll keep a vigilant eye for any others.

    -

    This leads to another point: Just running a znc process doesn't count for login. Neither does checking your email. You'll need to actually log into the shell, in order to reset the counter. You should, anyways, since we have a lot of services internally, that we don't offer external access too.

    -

    We are also looking at terminating the minecraft and minetest instances here. If anyone is using them, speak up now, or forever hold you peace! Not really. We wouldn't be deleting anything, just shutting down the processes, and removing them from the backup scheme.

    -

    We do need to welcome our newest sysadmin here: fosslinux. Give them a warm welcome if you see them around.

    -

    And again, any questions, or concerns, feel free to drop myself, or any of the other admins a line.

    -

    -

    Ubergeek/ub3g33k

    -
    - - -
    -
    -

    Server Status

    -
     
    -
    -

    - -\n"; -echo ""; -echo " - - - - "; -while (($line = fgetcsv($f)) !== false) { - echo ""; - if ($hosts == "failed" ) { - if ($line[2] == "FAILED") { - foreach ($line as $cell) { - if ($cell == "FAILED") { - echo ''; - } - else { - echo ""; - } - } - } - } - elseif ($hosts == "all") { - foreach ($line as $cell) { - if ($cell == "FAILED") { - echo ''; - } - elseif ($cell=="GOOD") { - echo '"; - } - else { - echo ""; - } - } - } - echo "\n"; -} -echo "\n
    HostCheckStatus
    ' . htmlspecialchars($cell) . '" .htmlspecialchars($cell) . "' . htmlspecialchars($cell) . '' . htmlspecialchars($cell) . "" .htmlspecialchars($cell) . "
    \n"; -fclose($f); -?> - - -

    -
    -
    -
     
    - - - diff --git a/signup.admin.php b/signup.admin.php deleted file mode 100644 index 8b7ca03..0000000 --- a/signup.admin.php +++ /dev/null @@ -1,860 +0,0 @@ - - $isHideForm, - 'error_fields' => isset($phpfmg_send['error']) ? $phpfmg_send['error']['fields'] : '', - 'OneEntry' => isset($GLOBALS['OneEntry']) ? $GLOBALS['OneEntry'] : '', - ); - - @header("Content-Type:text/html; charset=$charset"); - echo ""; - -} - - -function phpfmg_admin_default(){ - if( phpfmg_user_login() ){ - phpfmg_admin_panel(); - }; -} - - - -function phpfmg_admin_panel() -{ - if( !phpfmg_user_isLogin() ){ - exit; - }; - - phpfmg_admin_header(); - phpfmg_writable_check(); -?> - - - - -
    - - - - - - -
    - 1. Email Traffics -
    -
    - view    - download    - delete all'; - }; - ?> -
    - - -
    - 2. Form Data -
    -
    - view    - download    - delete all'; - }; - ?> -
    - -
    - 3. Form Generator -
    -
    - Edit Form    - New Form -
    -
    - - "> -
    - -
    - - - - - <?php echo '' == $title ? '' : $title . ' | ' ; ?>PHP FormMail Admin Panel - - - - - - - - - - - -
    - Form Admin Panel - -   -Main Menu   ' ; - echo 'Logout' ; - }; -?> -
    - -
    - - - -
    - - - - - -out_processing_gif(); -} - - -# phpfmg module : captcha -# ------------------------------------------------------ -function phpfmg_captcha_get(){ - $img = new phpfmgImage(); - $img->out(); - //$_SESSION[PHPFMG_ID.'fmgCaptchCode'] = $img->text ; - $_SESSION[ phpfmg_captcha_name() ] = $img->text ; -} - - - -function phpfmg_captcha_generate_images(){ - for( $i = 0; $i < 50; $i ++ ){ - $file = "$i.png"; - $img = new phpfmgImage(); - $img->out($file); - $data = base64_encode( file_get_contents($file) ); - echo "'{$img->text}' => '{$data}',\n" ; - unlink( $file ); - }; -} - - -function phpfmg_dd_lookup(){ - $paraOk = ( isset($_REQUEST['n']) && isset($_REQUEST['lookup']) && isset($_REQUEST['field_name']) ); - if( !$paraOk ) - return; - - $base64 = phpfmg_dependent_dropdown_data(); - $data = @unserialize( base64_decode($base64) ); - if( !is_array($data) ){ - return ; - }; - - - foreach( $data as $field ){ - if( $field['name'] == $_REQUEST['field_name'] ){ - $nColumn = intval($_REQUEST['n']); - $lookup = $_REQUEST['lookup']; // $lookup is an array - $dd = new DependantDropdown(); - echo $dd->lookupFieldColumn( $field, $nColumn, $lookup ); - return; - }; - }; - - return; -} - - -function phpfmg_filman_download(){ - if( !isset($_REQUEST['filelink']) ) - return ; - - $filelink = base64_decode($_REQUEST['filelink']); - $file = PHPFMG_SAVE_ATTACHMENTS_DIR . basename($filelink); - - // 2016-12-05: to prevent *LFD/LFI* attack. patch provided by Pouya Darabi, a security researcher in cert.org - $real_basePath = realpath(PHPFMG_SAVE_ATTACHMENTS_DIR); - $real_requestPath = realpath($file); - if ($real_requestPath === false || strpos($real_requestPath, $real_basePath) !== 0) { - return; - }; - - if( !file_exists($file) ){ - return ; - }; - - phpfmg_util_download( $file, $filelink ); -} - - -class phpfmgDataManager -{ - var $dataFile = ''; - var $columns = ''; - var $records = ''; - - function __construct(){ - $this->dataFile = PHPFMG_SAVE_FILE; - } - - function phpfmgDataManager(){ - $this->dataFile = PHPFMG_SAVE_FILE; - } - - function parseFile(){ - $fp = @fopen($this->dataFile, 'rb'); - if( !$fp ) return false; - - $i = 0 ; - $phpExitLine = 1; // first line is php code - $colsLine = 2 ; // second line is column headers - $this->columns = array(); - $this->records = array(); - $sep = chr(0x09); - while( !feof($fp) ) { - $line = fgets($fp); - $line = trim($line); - if( empty($line) ) continue; - $line = $this->line2display($line); - $i ++ ; - switch( $i ){ - case $phpExitLine: - continue; - break; - case $colsLine : - $this->columns = explode($sep,$line); - break; - default: - $this->records[] = explode( $sep, phpfmg_data2record( $line, false ) ); - }; - }; - fclose ($fp); - } - - function displayRecords(){ - $this->parseFile(); - echo ""; - echo "\n"; - $i = 1; - foreach( $this->records as $r ){ - echo "\n"; - $i++; - }; - echo "
     " . join( " ", $this->columns ) . "
    {$i} " . join( " ", $r ) . "
    \n"; - } - - function line2display( $line ){ - $line = str_replace( array('"' . chr(0x09) . '"', '""'), array(chr(0x09),'"'), $line ); - $line = substr( $line, 1, -1 ); // chop first " and last " - return $line; - } - -} -# end of class - - - -# ------------------------------------------------------ -class phpfmgImage -{ - var $im = null; - var $width = 73 ; - var $height = 33 ; - var $text = '' ; - var $line_distance = 8; - var $text_len = 4 ; - - function __construct( $text = '', $len = 4 ){ - $this->phpfmgImage( $text, $len ); - } - - function phpfmgImage( $text = '', $len = 4 ){ - $this->text_len = $len ; - $this->text = '' == $text ? $this->uniqid( $this->text_len ) : $text ; - $this->text = strtoupper( substr( $this->text, 0, $this->text_len ) ); - } - - function create(){ - $this->im = imagecreate( $this->width, $this->height ); - $bgcolor = imagecolorallocate($this->im, 255, 255, 255); - $textcolor = imagecolorallocate($this->im, 0, 0, 0); - $this->drawLines(); - imagestring($this->im, 5, 20, 9, $this->text, $textcolor); - } - - function drawLines(){ - $linecolor = imagecolorallocate($this->im, 210, 210, 210); - - //vertical lines - for($x = 0; $x < $this->width; $x += $this->line_distance) { - imageline($this->im, $x, 0, $x, $this->height, $linecolor); - }; - - //horizontal lines - for($y = 0; $y < $this->height; $y += $this->line_distance) { - imageline($this->im, 0, $y, $this->width, $y, $linecolor); - }; - } - - function out( $filename = '' ){ - if( function_exists('imageline') ){ - $this->create(); - if( '' == $filename ) header("Content-type: image/png"); - ( '' == $filename ) ? imagepng( $this->im ) : imagepng( $this->im, $filename ); - imagedestroy( $this->im ); - }else{ - $this->out_predefined_image(); - }; - } - - function uniqid( $len = 0 ){ - $md5 = md5( uniqid(rand()) ); - return $len > 0 ? substr($md5,0,$len) : $md5 ; - } - - function out_predefined_image(){ - header("Content-type: image/png"); - $data = $this->getImage(); - echo base64_decode($data); - } - - // Use predefined captcha random images if web server doens't have GD graphics library installed - function getImage(){ - $images = array( - '3B4D' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZklEQVR4nGNYhQEaGAYTpIn7RANEQxgaHUMdkMQCpoi0MrQ6OgQgq2wVaXSY6ugggiwGUhcIFwM7aWXU1LCVmZlZ05DdB1TH2oimF2iea2gghpgDmjqwWxpR3YLNzQMVflSEWNwHAEOFzEh9UajnAAAAAElFTkSuQmCC', - '7BFD' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYUlEQVR4nGNYhQEaGAYTpIn7QkNFQ1hDA0MdkEVbRVpZGxgdAlDFGl2BYiLIYlMg6kSQ3Rc1NWxp6MqsaUjuA6pAVgeGrA2Y5olgEQtowHRLQAPQzQ2MqG4eoPCjIsTiPgAe5cqdZczn0gAAAABJRU5ErkJggg==', - 'E261' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaUlEQVR4nGNYhQEaGAYTpIn7QkMYQxhCGVqRxQIaWFsZHR2mooqJNLo2OISiijEAxeB6wU4KjVq1dOnUVUuR3QdUN4XV0QHNDoYA1oYANDFGB0wx1gZGNL2hIaKhQJeEBgyC8KMixOI+AEt9zRwxrfAxAAAAAElFTkSuQmCC', - 'F3FA' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXklEQVR4nGNYhQEaGAYTpIn7QkNZQ1hDA1qRxQIaRFpZGximOqCIMTS6NjAEBKCKAdUxOogguS80alXY0tCVWdOQ3IemDsk8xtAQTDE0dSJY9ALdjCY2UOFHRYjFfQBC9swX+iY1kQAAAABJRU5ErkJggg==', - '3386' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAW0lEQVR4nGNYhQEaGAYTpIn7RANYQxhCGaY6IIkFTBFpZXR0CAhAVtnK0OjaEOgggCw2hQGoztEB2X0ro1aFrQpdmZqF7D6IOqzmiRAQw+YWbG4eqPCjIsTiPgDfEcs3qL/F3gAAAABJRU5ErkJggg==', - '73F5' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbElEQVR4nGNYhQEaGAYTpIn7QkNZQ1hDA0MDkEVbRVpZGxgdUFS2MjS6ootNYQCpc3VAdl/UqrCloSujopDcB9QFVMfQIIKkF8gHmocqJtIAsQNZLKAB5BaGgAAUMaCbGximOgyC8KMixOI+ANLhyovUCikUAAAAAElFTkSuQmCC', - 'B262' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAc0lEQVR4nM2QMQ7AIAhFcfAG9j44dGeQxdPo4A30CC6csrpB2rFNyk8YXn7CCyC3KfCnfOLH5BIwDFSMum8uIpFmLdSzRAymB4tBCcqPs8w5RLLyW73uI1ZzowH5vQ1z6HfbupTtYp0PRnacfvC/F/PgdwEm382td3YaZgAAAABJRU5ErkJggg==', - 'F5BF' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXUlEQVR4nGNYhQEaGAYTpIn7QkNFQ1lDGUNDkMQCGkQaWBsdHRjQxRoC0cVCkNSBnRQaNXXp0tCVoVlI7gtoYGh0xTAPKIZpHhYx1lZMtzCGAN2MIjZQ4UdFiMV9AOWey+1Mo0I6AAAAAElFTkSuQmCC', - 'BA88' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AA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rAFZTKQBZIcDih0BDZhuCWjA4uYBCj8qQizuAwATscxANMnEiwAAAABJRU5ErkJggg==', - 'B18E' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXUlEQVR4nGNYhQEaGAYTpIn7QgMYAhhCGUMDkMQCpjAGMDo6OiCrC2hlDWBtCEQVm8KArA7spNCoVVGrQleGZiG5D00d1DwGTPOwiWHRGxrAGoru5oEKPypCLO4DAAcdyOK2z/uBAAAAAElFTkSuQmCC', - 'DAAA' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZElEQVR4nGNYhQEaGAYTpIn7QgMYAhimMLQiiwVMYQxhCGWY6oAs1srayujoEBCAIibS6NoQ6CCC5L6opdNWpq6KzJqG5D40dVAx0VDX0MDQENzmQd2CKRYagCk2UOFHRYjFfQDwH865R4QP8AAAAABJRU5ErkJggg==', - '61ED' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXklEQVR4nGNYhQEaGAYTpIn7WAMYAlhDHUMdkMREpjAGsDYwOgQgiQW0sILFRJDFGhiQxcBOioxaFbU0dGXWNCT3hUxhwNTbSpyYCFQvsluALglFd/NAhR8VIRb3AQCR1siDjlalSAAAAABJRU5ErkJggg==', - '0A24' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdUlEQVR4nGNYhQEaGAYTpIn7GB0YAhhCGRoCkMRYAxhDGB0dGpHFRKawtrI2BLQiiwW0ijQ6NARMCUByX9TSaSuzVmZFRSG5D6yuldEBVa9oqMMUxtAQFDuA6gLQ3SLS6OiAKsboINLoGhqAIjZQ4UdFiMV9AJD2zYxT1n0AAAAAAElFTkSuQmCC', - 'C0E4' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYUlEQVR4nGNYhQEaGAYTpIn7WEMYAlhDHRoCkMREWhlDWBsYGpHFAhpZW4FirShiDSKNrg0MUwKQ3Be1atrK1NBVUVFI7oOoY3TA1MsYGoJpBza3oIhhc/NAhR8VIRb3AQCVuM1V0409bQAAAABJRU5ErkJggg==', - '74B3' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7QkMZWllDGUIdkEVbGaayNjo6BKCKhbI2BDSIIItNYXRlbXRoCEB2X9TSpUtDVy3NQnIfo4NIK5I6MGRtEA11RTMPyG5FtyMAJIbmFrAYupsHKPyoCLG4DwAG680IoYzDzAAAAABJRU5ErkJggg==', - '7A7E' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaUlEQVR4nGNYhQEaGAYTpIn7QkMZAlhDA0MDkEVbGUMYGgIdUFS2srZiiE0RaXRodISJQdwUNW1l1tKVoVlI7mN0AKqbwoiil7VBNNQhAFVMpEEEaBqqWABQzLUBqxiqmwco/KgIsbgPAAFcypYSgkVsAAAAAElFTkSuQmCC', - 'D503' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaElEQVR4nGNYhQEaGAYTpIn7QgNEQxmmMIQ6IIkFTBFpYAhldAhAFmsVaWB0dGgQQRULYW0IaAhAcl/U0qlLlwLJLCT3BbQyNLoi1KGIoZnX6IhuxxTWVnS3hAYwhqC7eaDCj4oQi/sAM0POpHsVDboAAAAASUVORK5CYII=', - '80A8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbklEQVR4nGNYhQEaGAYTpIn7WAMYAhimMEx1QBIT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YowOKmGgIUCyUITRgEIQfFSEW9wEAJavK9ihcb3IAAAAASUVORK5CYII=', - '7933' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZUlEQVR4nGNYhQEaGAYTpIn7QkMZQxhDGUIdkEVbWVtZGx0dAlDERBodGgIaRJDFpgDFwKJI7otaujRr6qqlWUjuY3RgDERSB4asDQwY5ok0sGCIBTRguiWgAYubByj8qAixuA8AMdzN5ey1N+8AAAAASUVORK5CYII=', - 'B3D8' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAW0lEQVR4nGNYhQEaGAYTpIn7QgNYQ1hDGaY6IIkFTBFpZW10CAhAFmtlaHRtCHQQQVHH0MraEABTB3ZSaNSqsKWroqZmIbkPTR1u87DagekWbG4eqPCjIsTiPgBZ/c6+pSgHzQAAAABJRU5ErkJggg==', - 'C515' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcUlEQVR4nM2QsRHAIAhFoXADsg9NegtsnEYLN9BskCJOGUpMLJM7+d07PvcO6K9JsFJ+8XOyBagYvGFUKIEg2z2fKeGTJRLt7mz8Ym9nP64YjZ/ezlz17tCdsEzKkGlwcQUqeOvnRE0CN17gfx9m4ncDIaLLo3yxb4MAAAAASUVORK5CYII=', - 'AB33' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYUlEQVR4nGNYhQEaGAYTpIn7GB1EQxhDGUIdkMRYA0RaWRsdHQKQxESmiDQ6NAQ0iCCJBbSKtDKARRHui1o6NWzV1FVLs5Dch6YODENDsZqH1Q50twS0Yrp5oMKPihCL+wAB+M7FephSdgAAAABJRU5ErkJggg==', - '5FCA' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgM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2tYHWNyHZAxVqR3RLQCrID6BokMZEpELcgi7EC7WWYwhgaMgjCj4oQi/sAtsvMZosFNiwAAAAASUVORK5CYII=', - 'E517' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaUlEQVR4nGNYhQEaGAYTpIn7QkNEQxmmMIaGIIkFNIg0MIQwgEgUMUZMsRCGKSAa4b7QqKlLV01btTILyX1A+UaHKQytDCh6wWJTUMVEQGIBqGKsrUD3OaC6mTGEMdQRRWygwo+KEIv7AOp9zKdA/I00AAAAAElFTkSuQmCC', - 'B7D3' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaklEQVR4nGNYhQEaGAYTpIn7QgNEQ11DGUIdkMQCpjA0ujY6OgQgi7UCxRoCGkRQ1bWyAsUCkNwXGrVq2tJVUUuzkNwHVBeApA5qHqMDK7p5QNMwxKaINLCiuSU0ACiG5uaBCj8qQizuAwA4/89LBb7x1QAAAABJRU5ErkJggg==', - '3CDD' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXElEQVR4nGNYhQEaGAYTpIn7RAMYQ1lDGUMdkMQCprA2ujY6OgQgq2wVaXBtCHQQQRabItLAihADO2ll1LRVS1dFZk1Ddh+qOrh52MTQ7cDmFmxuHqjwoyLE4j4AjRrMe5rkSpEAAAAASUVORK5CYII=', - '913A' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcklEQVR4nGNYhQEaGAYTpIn7WAMYAhhDGVqRxUSmMAawNjpMdUASC2gFqmwICAhAEWMIYGh0dBBBct+0qauiVk1dmTUNyX2srijqIBCktyEwNARJTAAihqJOZAoD0C2oelkDWEMZQxlRzRug8KMixOI+AHGBycFywSvGAAAAAElFTkSuQmCC', - '3349' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaElEQVR4nGNYhQEaGAYTpIn7RANYQxgaHaY6IIkFTBFpZWh1CAhAVtkKUuXoIIIsNgUoGggXAztpZdSqsJWZWVFhyO4DqmMF6hZBM881NKABXcyh0QHFDrBbGlHdgs3NAxV+VIRY3AcAwFDMuPPKh68AAAAASUVORK5CYII=', - 'B742' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAc0lEQVR4nGNYhQEaGAYTpIn7QgNEQx0aHaY6IIkFTGFodGh1CAhAFmsFik11dBBBVdfKEOjQIILkvtCoVdNWZmatikJyH1BdAGsj0BYU8xgdWEOBpqKIsTYAbZmCIjZFBCQWgOpmkJhjaMggCD8qQizuAwC5M87T/bVB7QAAAABJRU5ErkJggg==', - '7D9E' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYklEQVR4nGNYhQEaGAYTpIn7QkNFQxhCGUMDkEVbRVoZHR0dGFDFGl0bAlHFpqCIQdwUNW1lZmZkaBaS+xgdRBodQlD1sjYAxdDMEwGKOaKJBTRguiWgAYubByj8qAixuA8ADr7Kl8Etk1gAAAAASUVORK5CYII=', - 'A845' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdUlEQVR4nGNYhQEaGAYTpIn7GB0YQxgaHUMDkMRYA1hbGVodHZDViUwRaXSYiioW0ApUF+jo6oDkvqilK8NWZmZGRSG5D6SOtdGhQQRJb2ioSKMr0FYRFPOAdjQ6Ooig29HoEBCAIgZys8NUh0EQflSEWNwHALWGzRnVHtv+AAAAAElFTkSuQmCC', - '4234' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8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EDMd6sgAAAABJRU5ErkJggg==', - '59A4' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAdklEQVR4nGNYhQEaGAYTpIn7QkMYQximMDQEIIkFNLC2MoQyNKKKiTQ6Ojq0IosFBog0ujYETAlAcl/YtKVLU1dFRUUhu6+VMdC1IdABWS9DK0Oja2hgaAiyHa0sIPNQ3CIyhbWVFU2MNYAxBF1soMKPihCL+wDGH88nX8x7dgAAAABJRU5ErkJggg==', - 'C92F' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbklEQVR4nGNYhQEaGAYTpIn7WEMYQxhCGUNDkMREWllbGR0dHZDVBTSKNLo2BKKKNYg0OiDEwE6KWrV0adbKzNAsJPcFNDAGOrQyoullaHSYgibWyNLoEIAqBnaLA6oYyM2soahuGajwoyLE4j4Ad+PJzH4VaYoAAAAASUVORK5CYII=', - 'A66C' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAcElEQVR4nGNYhQEaGAYTpIn7GB0YQxhCGaYGIImxBrC2Mjo6BIggiYlMEWlkbXB0YEESC2gVaWAFmoDsvqil08KWTl2Zhey+gFbRVlZHRwdke0NDRRpdGwJRxIDmgcVQ7cB0S0ArppsHKvyoCLG4DwDHfMtw1BiCIgAAAABJRU5ErkJggg==', - '7DF9' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaUlEQVR4nGNYhQEaGAYTpIn7QkNFQ1hDA6Y6IIu2irSyNjAEBKCKNbo2MDqIIItNQRGDuClq2srU0FVRYUjuA6oAqmOYiqyXtQEs1oAsJgIRQ7EjoAHTLQENQDcDzUNx8wCFHxUhFvcBANqIzAhkFCpQAAAAAElFTkSuQmCC', - '283B' => 'iVBORw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ECFHxUhFvcBAFxZy1Z99b8CAAAAAElFTkSuQmCC', - '9F57' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZklEQVR4nGNYhQEaGAYTpIn7WANEQ11DHUNDkMREpog0sIJoJLGAVhxiU4E0kvumTZ0atjQza2UWkvtYXUXAqlFsbgWLTUEWEwDbERCALAZyC6OjowOqm4F6QxlRxAYq/KgIsbgPAItNy1U7f0upAAAAAElFTkSuQmCC', - '3638' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAXklEQVR4nGNYhQEaGAYTpIn7RAMYQxhDGaY6IIkFTGFtZW10CAhAVtkq0sjQEOgggiw2BchDqAM7aWXUtLBVU1dNzUJ23xTRVgYs5jmgm4dFDJtbsLl5oMKPihCL+wAB8czpoVQXcgAAAABJRU5ErkJggg==', - 'AC13' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAa0lEQVR4nGNYhQEaGAYTpIn7GB0YQxmmMIQ6IImxBrA2OoQwOgQgiYlMEWlwDAHSSGIBrUDeFCCN5L6opdNWrZq2amkWkvvQ1IFhaChEDN08BwwxoFumoLoloJUxlDHUAcXNAxV+VIRY3AcAcMHNjzTEe8AAAAAASUVORK5CYII=', - '8E74' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYklEQVR4nGNYhQEaGAYTpIn7WANEQ1lDAxoCkMREpogAyYBGZLGAVrBYK4a6RocpAUjuWxo1NWzV0lVRUUjuA6ubwuiAYV4AY2gImhijAwOGW1gbUMXAbkYTG6jwoyLE4j4AcebNysJDn8gAAAAASUVORK5CYII=', - 'A54F' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS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gAAAABJRU5ErkJggg==', - '55EF' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAYElEQVR4nGNYhQEaGAYTpIn7QkNEQ1lDHUNDkMQCGkQaWBsYHRgIiAUGiIQgiYGdFDZt6tKloStDs5Dd18rQ6IqmF5tYQKsIhpjIFNZWdHtZAxhDgG5GNW+Awo+KEIv7AOO5yVKY4EAIAAAAAElFTkSuQmCC', - '8488' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAZElEQVR4nGNYhQEaGAYTpIn7WAMYWhlCGaY6IImJTGGYyujoEBCAJBYAVMXaEOgggqKO0RVJHdhJS6OWLl0VumpqFpL7RKaItGKaJxrqimYe0I5WTDsYMPRic/NAhR8VIRb3AQC4J8vmHxEM0gAAAABJRU5ErkJggg==', - 'AF2C' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAbklEQVR4nGNYhQEaGAYTpIn7GB1EQx1CGaYGIImxBog0MDo6AEmEmMgUkQbWhkAHFiSxgFaQikAHZPdFLZ0atmplZhay+8DqWhkdkO0NDQWKTUEVA6sLYMSwA6gKxS0gMdbQABQ3D1T4URFicR8Ai/jLD1sSajUAAAAASUVORK5CYII=', - '105D' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAaUlEQVR4nGNYhQEaGAYTpIn7GB0YAlhDHUMdkMRYHRhDWIEyAUhiog6srSAxERS9Io2uU+FiYCetzJq2MjUzM2sakvtA6hwaAjH0YoqB7EAXYwxhdHREdUsIQwBDKCOKmwcq/KgIsbgPAIpgx7v+WAmDAAAAAElFTkSuQmCC', - '019C' => 'iVBORw0KGgoAAAANSUhEUgAAAEkAAAAhAgMAAADoum54AAAACVBMVEX///8AAADS0tIrj1xmAAAAa0lEQVR4nGNYhQEaGAYTpIn7GB0YAhhCGaYGIImxBjAGMDo6BIggiYlMYQ1gbQh0YEESC2hlAIshuy9q6aqolZmRWcjuA6ljCIGrQ4g1oIqJTGEIYESzgzWAAcMtjA6soehuHqjwoyLE4j4AGn7IJHjHWsQAAAAASUVORK5CYII=' - ); - $this->text = array_rand( $images ); - return $images[ $this->text ] ; - } - - function out_processing_gif(){ - $image = dirname(__FILE__) . '/processing.gif'; - $base64_image = "R0lGODlhFAAUALMIAPh2AP+TMsZiALlcAKNOAOp4ANVqAP+PFv///wAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgAIACwAAAAAFAAUAAAEUxDJSau9iBDMtebTMEjehgTBJYqkiaLWOlZvGs8WDO6UIPCHw8TnAwWDEuKPcxQml0Ynj2cwYACAS7VqwWItWyuiUJB4s2AxmWxGg9bl6YQtl0cAACH5BAUKAAgALAEAAQASABIAAAROEMkpx6A4W5upENUmEQT2feFIltMJYivbvhnZ3Z1h4FMQIDodz+cL7nDEn5CH8DGZhcLtcMBEoxkqlXKVIgAAibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkphaA4W5upMdUmDQP2feFIltMJYivbvhnZ3V1R4BNBIDodz+cL7nDEn5CH8DGZAMAtEMBEoxkqlXKVIg4HibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpjaE4W5tpKdUmCQL2feFIltMJYivbvhnZ3R0A4NMwIDodz+cL7nDEn5CH8DGZh8ONQMBEoxkqlXKVIgIBibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpS6E4W5spANUmGQb2feFIltMJYivbvhnZ3d1x4JMgIDodz+cL7nDEn5CH8DGZgcBtMMBEoxkqlXKVIggEibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpAaA4W5vpOdUmFQX2feFIltMJYivbvhnZ3V0Q4JNhIDodz+cL7nDEn5CH8DGZBMJNIMBEoxkqlXKVIgYDibbK9YLBYvLtHH5K0J0IACH5BAUKAAgALAEAAQASABIAAAROEMkpz6E4W5tpCNUmAQD2feFIltMJYivbvhnZ3R1B4FNRIDodz+cL7nDEn5CH8DGZg8HNYMBEoxkqlXKVIgQCibbK9YLBYvLtHH5K0J0IACH5BAkKAAgALAEAAQASABIAAAROEMkpQ6A4W5spIdUmHQf2feFIltMJYivbvhnZ3d0w4BMAIDodz+cL7nDEn5CH8DGZAsGtUMBEoxkqlXKVIgwGibbK9YLBYvLtHH5K0J0IADs="; - $binary = is_file($image) ? join("",file($image)) : base64_decode($base64_image); - header("Cache-Control: post-check=0, pre-check=0, max-age=0, no-store, no-cache, must-revalidate"); - header("Pragma: no-cache"); - header("Content-type: image/gif"); - echo $binary; - } - -} -# end of class phpfmgImage -# ------------------------------------------------------ -# end of module : captcha - - -# module user -# ------------------------------------------------------ -function phpfmg_user_isLogin(){ - return ( isset($_SESSION['authenticated']) && true === $_SESSION['authenticated'] ); -} - - -function phpfmg_user_logout(){ - session_destroy(); - header("Location: admin.php"); -} - -function phpfmg_user_login() -{ - if( phpfmg_user_isLogin() ){ - return true ; - }; - - $sErr = "" ; - if( 'Y' == $_POST['formmail_submit'] ){ - if( - defined( 'PHPFMG_USER' ) && strtolower(PHPFMG_USER) == strtolower($_POST['Username']) && - defined( 'PHPFMG_PW' ) && strtolower(PHPFMG_PW) == strtolower($_POST['Password']) - ){ - $_SESSION['authenticated'] = true ; - return true ; - - }else{ - $sErr = 'Login failed. Please try again.'; - } - }; - - // show login form - phpfmg_admin_header(); -?> -
    - -


    - -
    -
    -
    - - - - - - - - - - - - -
    Email : - -
    Password : - -
    -

    - {$sErr}

    \n"; ?> - I forgot my password -
    -
    -
    - - - -
    - -


    - -
    -
    -
    -Request Password -Enter Email Address :
    - -
    -The password will be sent to this email address. -
    {$sErr}

    \n"; ?> -
    -
    - - -" ); - echo "
    Your password has been sent.

    Click here to login again
    "; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_writable_check(){ - - if( is_writable( dirname(PHPFMG_SAVE_FILE) ) && is_writable( dirname(PHPFMG_EMAILS_LOGFILE) ) ){ - return ; - }; -?> - -

    -
    -
    Your form data or email traffic log is NOT saving.
    - The form data () and email traffic log () will be created automatically when the form is submitted. - However, the script doesn't have writable permission to create those files. In order to save your valuable information, please set the directory to writable. - If you don't know how to do it, please ask for help from your web Administrator or Technical Support of your hosting company. -
    -

    - PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - - phpfmg_admin_header(); - - $file = $files[$n]; - if( is_file($file) ){ - if( 1== $n ){ - echo "
    \n";
    -            echo join("",file($file) );
    -            echo "
    \n"; - }else{ - $man = new phpfmgDataManager(); - $man->displayRecords(); - }; - - - }else{ - echo "No form data found."; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_log_download(){ - $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; - $files = array( - 1 => PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - - $file = $files[$n]; - if( is_file($file) ){ - phpfmg_util_download( $file, PHPFMG_SAVE_FILE == $file ? 'form-data.csv' : 'email-traffics.txt', true, 1 ); // skip the first line - }else{ - phpfmg_admin_header(); - echo "No email traffic log found."; - phpfmg_admin_footer(); - }; - -} - - -function phpfmg_log_delete(){ - $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; - $files = array( - 1 => PHPFMG_EMAILS_LOGFILE, - 2 => PHPFMG_SAVE_FILE, - ); - phpfmg_admin_header(); - - $file = $files[$n]; - if( is_file($file) ){ - echo unlink($file) ? "It has been deleted!" : "Failed to delete!" ; - }; - phpfmg_admin_footer(); -} - - -function phpfmg_util_download($file, $filename='', $toCSV = false, $skipN = 0 ){ - if (!is_file($file)) return false ; - - set_time_limit(0); - - - $buffer = ""; - $i = 0 ; - $fp = @fopen($file, 'rb'); - while( !feof($fp)) { - $i ++ ; - $line = fgets($fp); - if($i > $skipN){ // skip lines - if( $toCSV ){ - $line = str_replace( chr(0x09), ',', $line ); - $buffer .= phpfmg_data2record( $line, false ); - }else{ - $buffer .= $line; - }; - }; - }; - fclose ($fp); - - - - /* - If the Content-Length is NOT THE SAME SIZE as the real conent output, Windows+IIS might be hung!! - */ - $len = strlen($buffer); - $filename = basename( '' == $filename ? $file : $filename ); - $file_extension = strtolower(substr(strrchr($filename,"."),1)); - - switch( $file_extension ) { - case "pdf": $ctype="application/pdf"; break; - case "exe": $ctype="application/octet-stream"; break; - case "zip": $ctype="application/zip"; break; - case "doc": $ctype="application/msword"; break; - case "xls": $ctype="application/vnd.ms-excel"; break; - case "ppt": $ctype="application/vnd.ms-powerpoint"; break; - case "gif": $ctype="image/gif"; break; - case "png": $ctype="image/png"; break; - case "jpeg": - case "jpg": $ctype="image/jpg"; break; - case "mp3": $ctype="audio/mpeg"; break; - case "wav": $ctype="audio/x-wav"; break; - case "mpeg": - case "mpg": - case "mpe": $ctype="video/mpeg"; break; - case "mov": $ctype="video/quicktime"; break; - case "avi": $ctype="video/x-msvideo"; break; - //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files) - case "php": - case "htm": - case "html": - $ctype="text/plain"; break; - default: - $ctype="application/x-download"; - } - - - //Begin writing headers - header("Pragma: public"); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("Cache-Control: public"); - header("Content-Description: File Transfer"); - //Use the switch-generated Content-Type - header("Content-Type: $ctype"); - //Force the download - header("Content-Disposition: attachment; filename=".$filename.";" ); - header("Content-Transfer-Encoding: binary"); - header("Content-Length: ".$len); - - while (@ob_end_clean()); // no output buffering ! - flush(); - echo $buffer ; - - return true; - - -} -?> diff --git a/signup.lib.php b/signup.lib.php deleted file mode 100644 index eb20fa2..0000000 --- a/signup.lib.php +++ /dev/null @@ -1,3378 +0,0 @@ -unauthorized domain.
    " ); - -define( 'PHPFMG_ONE_ENTRY' , '' ); -define( 'PHPFMG_ONE_ENTRY_METHOD' , '' ); - -phpfmg_init(); -# ----------------------------------------------------------------------------- - - - - - - - - - -function phpfmg_thankyou(){ - phpfmg_redirect_js(); -?> - - -
    - - Your form has been sent. Thank you! -

    - - - - - - "field_0", "text" => "Contact Name:", "type" => "sender's name", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_1'] = array( "name" => "field_1", "text" => "Desired Username:", "type" => "text", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_2'] = array( "name" => "field_2", "text" => "Email Address:", "type" => "sender's email", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_3'] = array( "name" => "field_3", "text" => "What interests you about thunix?", "type" => "textarea", "instruction" => "", "required" => "Required" ) ; -$GLOBALS['form_mail']['field_4'] = array( "name" => "field_4", "text" => "Desired Public SSH Key :", "type" => "textarea", "instruction" => "", "required" => "Required" ) ; - - -/** - * GNU Library or Lesser General Public License version 2.0 (LGPLv2) -*/ - -function phpfmg_init(){ - - error_reporting( E_ERROR ); - ini_set('magic_quotes_runtime', 0); - ini_set( 'max_execution_time', 0 ); - ini_set( 'max_input_time', 36000 ); - - session_start(); - - if( !isset($_SESSION['HTTP_REFERER']) ) - $_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'] ; - phpfmg_check_referers(); - - if ( get_magic_quotes_gpc() && isset($_POST) ) { - phpfmg_stripslashes( $_POST ); - }; - -} - - -function phpfmg_stripslashes(&$var){ - if(!is_array($var)) { - $var = stripslashes($var); - } else { - array_walk($var,'phpfmg_stripslashes'); - }; -} - - -function phpfmg_display_form( $title="", $keywords="", $description="" ){ - @header( 'Content-Type: text/html; charset=' . PHPFMG_CHARSET ); - $phpfmg_send = phpfmg_sendmail( $GLOBALS['form_mail'] ) ; - $isHideForm = isset($phpfmg_send['isHideForm']) ? $phpfmg_send['isHideForm'] : false; - $sErr = isset($phpfmg_send['error']) ? $phpfmg_send['error'] : ''; - - # FormMail main() - phpfmg_header( $title, $keywords, $description ); - if( !$isHideForm ){ - phpfmg_form($sErr); - }else{ - phpfmg_thankyou(); - }; - phpfmg_footer(); - - return; -} - -function phpfmg_linebreak(){ - $os = strtolower(PHP_OS); - switch( true ){ - case ("\\" == DIRECTORY_SEPARATOR) : // windows - return "\x0d\x0a" ; - case ( strpos($os, 'darwin') !== false ) : // Mac - return "\x0d" ; - default : - return "\x0a" ; // *nix - }; -} - -function phpfmg_sendmail( &$form_mail ) { - if( !isset($_POST["formmail_submit"]) ) return ; - - $isHideForm = false ; - $sErr = checkPass($form_mail); - - $err_captcha = phpfmg_check_captcha(); - if( $err_captcha != '' ){ - $sErr['fields'][] = 'phpfmg_captcha'; - $sErr['errors'][] = ERR_CAPTCHA; - }; - - if( empty($sErr['fields']) && phpfmg_has_entry() ){ - $sErr['fields'][] = 'phpfmg_found_entry'; - $sErr['errors'][] = 'Found entry already!'; - }; - if( empty($sErr['fields']) ){ - - sendFormMail( $form_mail, PHPFMG_SAVE_FILE ) ; - $isHideForm = true; - // move the redirect to phpfmg_thankyou() to get around the redirection within an iframe problem - /* - $redirect = PHPFMG_REDIRECT; - if( strlen(trim($redirect)) ): - header( "Location: $redirect" ); - exit; - endif; - */ - }; - - return array( - 'isHideForm' => $isHideForm, - 'error' => $sErr , - ); -} - - -function phpfmg_has_entry(){ - if( !file_exists(PHPFMG_SAVE_FILE) ){ - return false; // has nothing to check - }; - - $found = false ; - if( defined('PHPFMG_ONE_ENTRY') && 'Y' == PHPFMG_ONE_ENTRY ){ - $query = defined('PHPFMG_ONE_ENTRY_METHOD') && PHPFMG_ONE_ENTRY_METHOD == 'email' && isset($GLOBALS['sender_email']) ? $GLOBALS['sender_email'] : $_SERVER['REMOTE_ADDR'] ; - if( empty($query) ) - return false ; - - $GLOBALS['OneEntry'] = $query; - $query = '"'. strtolower($query) . '"'; - $handle = fopen(PHPFMG_SAVE_FILE,'r'); - if ($handle) { - while (!feof($handle)) { - $entry = strtolower(fgets($handle, 4096)); - if( strpos($entry,$query) !== false ){ - $found = true ; - break; - }; - }; - fclose($handle); - }; - }; - return $found ; - -} - -function sendFormMail( $form_mail, $sFileName = "" ) -{ - $to = filterEmail(PHPFMG_TO) ; - $cc = filterEmail(PHPFMG_CC) ; - $bcc = filterEmail(PHPFMG_BCC) ; - - // simply chop email address to avoid my website being abused - if( false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com') ){ - $cc = substr($cc, 0, 50); - $bcc = substr($bcc,0, 50); - }; - - - $subject = PHPFMG_SUBJECT ; - $from = $to ; - $fromName = ""; - $titleOfSender = ''; - $firstName = ""; - $lastName = ""; - - $strip = get_magic_quotes_gpc() ; - $content = '' ; - $style = 'font-family:Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color:#474747;padding:6px;border-bottom:1px solid #cccccc;' ; - $tr = array() ; // html table - $csvValues = array(); - $cols = array(); - $replace = array(); - $RecordID = phpfmg_getRecordID(); - $isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) ); - - foreach( $form_mail as $field ){ - $field_type = strtolower($field[ "type" ]); - if( 'sectionbreak' == $field_type ){ - continue; - }; - - $field[ "text" ] = stripslashes( $field[ "text" ] ); - //$value = trim( $_POST[ $field[ "name" ] ] ); - $value = phpfmg_field_value( $field[ "name" ] ); - $value = $strip ? stripslashes($value) : $value ; - if( 'attachment' == $field_type ){ - $value = $isWritable ? phpfmg_file2value( $RecordID, $_FILES[ $field[ "name" ] ] ) : $_FILES[ $field[ "name" ] ]['name']; - //$value = $_FILES[ $field[ "name" ] ]['name']; - }; - - $content .= $field[ "text" ] . " \t : " . $value .PHPFMG_LNCR; - $tr[] = " " . $field[ "text" ] . "  " . nl2br($value) . " " ; - $csvValues[] = csvfield( $value ); - $cols[] = csvfield( $field[ "text" ] ); - $replace["%".$field[ "name" ]."%"] = $value; - - switch( $field_type ){ - case "sender's email" : - $from = filterEmail($value) ; - break; - case "sender's name" : - $fromName = filterEmail($value) ; - break; - case "titleofsender" : - $titleOfSender = $value ; - break; - case "senderfirstname" : - $firstName = filterEmail($value) ; - break; - case "senderlastname" : - $lastName = filterEmail($value) ; - break; - default : - // nothing - }; - - }; // for - - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - - if( $isHtml ) { - $content = "" . PHPFMG_LNCR . join( PHPFMG_LNCR, $tr ) . PHPFMG_LNCR . "
    " ; - }; - - - if( !empty($firstName) && !empty($lastName) ){ - $fromName = $firstName . ' ' . $lastName; - }; - $fromHeader = filterEmail( ('' != $fromName ? "\"$fromName\"" : '' ) . " <{$from}>",array(",", ";")) ; // no multiple emails are allowed. - $GLOBALS['ReplyTo'] = $fromHeader; - - $_fields = array( - '%NameOfSender%' => $fromName, - '%FirstNameOfSender%' => $firstName, - '%LastNameOfSender%' => $lastName, - '%EmailOfSender%' => $from, - '%TitleOfSender%' => $titleOfSender, - '%DataOfForm%' => $content, - '%IP%' => $_SERVER['REMOTE_ADDR'], - '%Date%' => date("Y-m-d"), - '%Time%' => date("H:i:s"), - '%HTTP_HOST%' => $_SERVER['HTTP_HOST'], - '%FormPageLink%' => phpfmg_request_uri(), - '%HTTP_REFERER%' => $_SESSION['HTTP_REFERER'], - '%AutoID%' => $RecordID, - '%FormAdminURL%' => phpfmg_admin_url() - ); - $fields = array_merge( $_fields, $replace ); - - $esh_mail_template = trim(phpfmg_mail_template()); - if( !empty($esh_mail_template) ){ - $esh_mail_template = phpfmg_adjust_template($esh_mail_template); - $content = phpfmg_parse_mail_body( $esh_mail_template, $fields ); - }; - $subject = phpfmg_parse_mail_body( $subject, $fields ); - - if( $isHtml ) { - $content = phpfmg_getHtmlContent( $content ); - }; - - $oldMask = umask(0); - //$sep = ','; //chr(0x09); - $sep = chr(0x09); - $recordCols = phpfmg_data2record( csvfield('RecordID') . $sep . csvfield('Date') . $sep . csvfield('IP') . $sep . join($sep,$cols) ); - $record = phpfmg_data2record( csvfield($RecordID) . $sep . csvfield(date("Y-m-d H:i:s")) . $sep . csvfield($_SERVER['REMOTE_ADDR']) .$sep . join($sep,$csvValues) ); - - - /* - Some hosting companies (like Yahoo and GoDaddy) REQUIRED a registered email address to send out all emails! - The mailer HAS to use the REGISTERED email address as the sender's email address. This is called the sendmail_from. - */ - $sendmail_from = $from; - $sender_email = $from; - $force_sender = defined('PHPFMG_SENDMAIL_FROM') && '' != PHPFMG_SENDMAIL_FROM ; - if( $force_sender ){ - ini_set("sendmail_from", PHPFMG_SENDMAIL_FROM); - $sendmail_from = PHPFMG_SENDMAIL_FROM; - }; - if( defined('PHPFMG_SMTP') && '' != PHPFMG_SMTP ){ - ini_set("SMTP", PHPFMG_SMTP); - }; - - - - switch( strtolower(PHPFMG_ACTION) ){ - case 'fileonly' : - appendToFile( $sFileName, $record, $recordCols ); - break; - case 'mailonly' : - mailAttachments( $to , $subject , $content, $sendmail_from, $fromName, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ; - break; - case 'mailandfile' : - default: - mailAttachments( $to , $subject , $content, $sendmail_from, $fromName, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ; - appendToFile( $sFileName, $record, $recordCols ); - }; // switch - - mailAutoResponse( $sender_email, $force_sender ? $sendmail_from : $to, $fields ) ; - umask($oldMask); - - session_destroy(); - session_regenerate_id(true); -} - - - - - -function phpfmg_file2value( $recordID, $file ){ - $tmp = $file[ "tmp_name" ] ; - $name = phpfmg_rename_harmful(trim($file[ "name" ])) ; - if( !defined('PHPFMG_FILE2LINK_SIZE') ){ - return $name; - }; - - if( is_uploaded_file( $tmp ) ) { - $size = trim(PHPFMG_FILE2LINK_SIZE) ; - switch( $size ){ - case '' : - return $name; - default: - $isHtml = 'html' == PHPFMG_MAIL_TYPE; - $filelink = base64_encode($recordID . '-' . $name); - $url = phpfmg_admin_url() . "?mod=filman&func=download&filelink=" . urlencode($filelink) ; - $isLarger = (filesize($tmp)/1024) > $size ; - $link = $isHtml ? "$name" : $name . " ( {$url} )"; - return $isLarger ? $link : $name ; // email download link when size is larger defined size, otherwise send as attachment - };// switch - }; // if - - return $name; -} - - -function phpfmg_dir2unix( $dir ){ - return str_replace( array("\\", '//'), '/', $dir ); -} - - - -function phpfmg_request_uri(){ - $uri = getEnv('REQUEST_URI'); // apache has this - if( false !== $uri && strlen($uri) > 0 ){ - return $uri ; - } else { - - $uri = ($uri = getEnv('SCRIPT_NAME')) !== false - ? $uri - : getEnv('PATH_INFO') ; - $qs = getEnv('QUERY_STRING'); // IIS and Apache has this - return $uri . ( empty($qs) ? '' : '?' . $qs ); - - }; - return "" ; -} - - - - -// parse full admin url to view large size uploaded file online -function phpfmg_admin_url(){ - $http_host = "http://{$_SERVER['HTTP_HOST']}"; - switch( true ){ - case (0 === strpos(PHPFMG_ADMIN_URL, 'http://' )) : - $url = PHPFMG_ADMIN_URL; - break; - case ( '/' == substr(PHPFMG_ADMIN_URL,0,1) ) : - $url = $http_host . PHPFMG_ADMIN_URL ; - break; - default: - $uri = phpfmg_request_uri(); - $pos = strrpos( $uri, '/' ); - $vdir = substr( $uri, 0, $pos ); - $url = $http_host . $vdir . '/' . PHPFMG_ADMIN_URL ; - }; - return $url; -} - - - -function phpfmg_ispost(){ - return 'POST' == strtoupper($_SERVER["REQUEST_METHOD"]) || 'POST' == strtoupper(getEnv('REQUEST_METHOD')) ; -} - - -function phpfmg_is_mysite(){ - return false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com'); // accessing form at mysite -} - -// don't allow hotlink form to my website. To avoid people create phishing form. -function phpfmg_hotlinking_mysite(){ - $yes = phpfmg_is_mysite() - && ( empty($_SERVER['HTTP_REFERER']) || false === strpos( strtolower($_SERVER['HTTP_REFERER']),'formmail-maker.com') ) ; // doesn't have referer of mysite - - if( $yes ){ - die( "Access Denied. -

    - You are visiting a form hotlinkink from formmail-maker.com which is not allowed. - Please read the FAQ. - " ); - }; -} - - - -function phpfmg_check_referers(){ - - phpfmg_hotlinking_mysite(); // anti phishing - - $debugs = array(); - $debugs[] = "Your IP: " . $_SERVER['REMOTE_ADDR']; - $debugs[] = "Referer link: " . $_SERVER['HTTP_REFERER']; - $debugs[] = "Host of referer: $referer"; - - $check = defined('PHPFMG_ANTI_HOTLINKING') && 'Y' == PHPFMG_ANTI_HOTLINKING; - if( !$check ) { - $debugs[] = "Referer is empty. No need to check hot linking."; - //echo "
    " . join("\n",$debugs) . "
    \n"; - //appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ; - return true; - }; - - // maybe post from local file - if( !isset($_SERVER['HTTP_REFERER']) && phpfmg_ispost() ){ - appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n phpfmg_ispost " . join("\n",$debugs) ) ; - die( PHPFMG_REFERERS_DENIED_MSG ); - }; - - - $url = parse_url($_SERVER['HTTP_REFERER']); - $referer = str_replace( 'www.', '', strtolower($url['host']) ); - if( empty($referer) ) { - return true; - }; - - $hosts = explode(',',PHPFMG_REFERERS_ALLOW); - $http_host = strtolower($_SERVER['HTTP_HOST']); - $referer = $http_host ; - $hosts[] = str_replace('www.', '', $http_host ); - - $debugs[] = "Hosts Allow: " . PHPFMG_REFERERS_ALLOW; - - $allow = false ; - foreach( $hosts as $host ){ - $host = strtolower(trim($host)); - $debugs[] = "check host: $host " ; - if( false !== strpos($referer, $host) || false !== strpos($referer, 'www.'.$host) ){ - $allow = true; - $debugs[] = " -> allow (quick exit)"; - break; - }else{ - $debugs[] = " -> deny"; - }; - }; - - //echo "
    " . join("\n",$debugs) . "
    \n"; - //appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ; - - if( !$allow ){ - die( PHPFMG_REFERERS_DENIED_MSG ); - }; -} - - - -function phpfmg_getRecordID(){ - if( !isset($GLOBALS['RecordID']) ){ - $GLOBALS['RecordID'] = date("Ymd") . '-'. substr( md5(uniqid(rand(), true)), 0,4 ); - }; - return $GLOBALS['RecordID']; -} - - - -function phpfmg_data2record( $s, $b=true ){ - $from = array( "\r", "\n"); - $to = array( "\\r", "\\n" ); - return $b ? str_replace( $from, $to, $s ) : str_replace( $to, $from, $s ) ; -} - - - -function csvfield( $str ){ - $str = str_replace( '"', '""', $str ); - return '"' . trim($str) . '"'; -} - - - -function mailAttachments( $to = "" , $subject = "" , $message = "" , $from="", $fromName = "" , $fromHeader ="", $cc = "" , $bcc = "", $charset = "UTF-8", $type = 'FormMail' ){ - - if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ; - - $isAutoResponse = $type == 'AutoResponseEmail' ; - // added PHPMailer SMTP support at Mar 12, 2011 - $isSMTP = defined('PHPFMG_USE_SMTP') && 'Y' == PHPFMG_USE_SMTP && defined('PHPFMG_SMTP_HOST') && '' != PHPFMG_SMTP_HOST; - - // due to security issues, in most case, the smtp will fail on my website. It only works on user's own server - // so just disable the smtp here - if( phpfmg_is_mysite() ){ - $isSMTP = false ; - }; - - $attachments = array(); - $noAutoAttachements = $isAutoResponse && defined('PHPFMG_RETURN_NO_ATTACHMENT') && 'Y' == PHPFMG_RETURN_NO_ATTACHMENT ; - $use_phpmailer = defined('PHPFMG_USE_PHPMAILER') && 'Y' == PHPFMG_USE_PHPMAILER ; - - - $boundary = "====_My_PHP_Form_Generator_" . md5( uniqid( srand( time() ) ) ) . "===="; - $content_type = 'html' == PHPFMG_MAIL_TYPE ? "text/html" : "text/plain" ; - - // setup mail header infomation - $headers = 'Y' == PHPFMG_NO_FROM_HEADER ? '' : "From: {$fromHeader}" .PHPFMG_LNCR; - $headers .= "Reply-To: {$GLOBALS['ReplyTo']}" .PHPFMG_LNCR; - if ($cc) $headers .= "CC: $cc".PHPFMG_LNCR; - if ($bcc) $headers .= "BCC: $bcc".PHPFMG_LNCR; - //$headers .= "Content-type: {$content_type}; charset={$charset}" .PHPFMG_LNCR ; - - $plainHeaders = $headers ; // for no attachments header - $plainHeaders .= 'MIME-Version: 1.0' . PHPFMG_LNCR; - $plainHeaders .= "Content-type: {$content_type}; charset={$charset}" ; - - //create mulitipart attachments boundary - $sError = "" ; - $nFound = 0; - - - if( false && isset($GLOBALS['phpfmg_files_content']) && '' != $GLOBALS['phpfmg_files_content'] ){ - - // use previous encoded content - $sEncodeBody = $GLOBALS['phpfmg_files_content'] ; - $nFound = $GLOBALS['phpfmg_nFound'] ; - - }else{ - - $file2link_size = trim(PHPFMG_FILE2LINK_SIZE) ; - $isSave = ('' != $file2link_size || defined('PHPFMG_SAVE_ATTACHMENTS') && 'Y' == PHPFMG_SAVE_ATTACHMENTS); - if( $isSave ){ - if( defined('PHPFMG_SAVE_ATTACHMENTS_DIR') ){ - if( !is_dir(PHPFMG_SAVE_ATTACHMENTS_DIR) ){ - $ok = @mkdir( PHPFMG_SAVE_ATTACHMENTS_DIR, 0777 ); - if( !$ok ) $isSave = false; - }; - }; - }; - - $isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) ); - // parse attachments content - foreach( $_FILES as $aFile ){ - $sFileName = $aFile[ "tmp_name" ] ; - $sFileRealName = phpfmg_rename_harmful($aFile[ "name" ]) ; - if( is_uploaded_file( $sFileName ) ): - - $isSkip = '' != $file2link_size && ( (filesize($sFileName)/1024) > $file2link_size ); - // save uploaded file - if( $isWritable && $isSave ){ - $tofile = PHPFMG_SAVE_ATTACHMENTS_DIR . phpfmg_getRecordID() . '-' . basename($sFileRealName); - if( @copy( $sFileName, $tofile) ) { - $sFileName = $tofile; // to fix problem : in some windows php, the uploaded temp file might not be mailed as attachment - chmod($tofile,0777); - }; - }; - - if( $isSkip ) - continue; // mail file as link - - $attachments[] = array('file' => $sFileName, 'name' => $aFile[ "name" ] ); - - if( !$use_phpmailer && !$isSMTP && ($fp = @fopen( $sFileName, "rb" )) ) : - $sContent = fread( $fp, filesize( $sFileName ) ); - fclose($fp); - $sFName = basename( $sFileRealName ) ; - $sMIME = getMIMEType( $sFName ) ; - - $bPlainText = ( $sMIME == "text/plain" ) ; - if( $bPlainText ) : - $encoding = "" ; - else: - $encoding = "Content-Transfer-Encoding: base64".PHPFMG_LNCR; - $sContent = chunk_split( base64_encode( $sContent ) ); - endif; - - $sEncodeBody .= PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR. - "Content-Type: $sMIME;" . PHPFMG_LNCR. - "\tname=\"$sFName\"" . PHPFMG_LNCR. - $encoding . - "Content-Disposition: attachment;" . PHPFMG_LNCR. - "\tfilename=\"$sFName\"" . PHPFMG_LNCR. PHPFMG_LNCR. - $sContent . PHPFMG_LNCR ; - $nFound ++; - else: - $sError .= "
    Failed to open file $sFileName.\n" ; - endif; // if( $fp = fopen( $sFileName, "rb" ) ) : - - else: - $sError .= "
    File $sFileName doesn't exist.\n" ; - endif; //if( file_exists( $sFileName ) ): - }; // end foreach - - $sEncodeBody .= PHPFMG_LNCR.PHPFMG_LNCR."--$boundary--" ; - - $GLOBALS['phpfmg_files_content'] = $sEncodeBody ; - $GLOBALS['phpfmg_nFound'] = $nFound ; - - }; // if - - $headers .= "MIME-Version: 1.0".PHPFMG_LNCR."Content-type: multipart/mixed;".PHPFMG_LNCR."\tboundary=\"$boundary\""; - $txtMsg = PHPFMG_LNCR."This is a multi-part message in MIME format." .PHPFMG_LNCR . - PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR . - "Content-Type: {$content_type};".PHPFMG_LNCR. - "\tcharset=\"$charset\"" .PHPFMG_LNCR.PHPFMG_LNCR . - $message . PHPFMG_LNCR; - - - if( $noAutoAttachements ) $sEncodeBody = '' ; - - $body = $nFound ? $txtMsg . $sEncodeBody : $message ; - $headers = $nFound ? $headers : $plainHeaders ; - - - $errmsg = ""; - if( $isSMTP || $use_phpmailer ){ - if( $noAutoAttachements ) $attachments = false ; - $errmsg = phpfmg_phpmailer( $to, $subject, $body, $from, $fromName, $cc , $bcc , $charset, $attachments ); - - }else{ - - if ( !mail( $to, $subject, $body, $headers ) ) - $errmsg = "Failed to send mail"; - }; - - $ok = $errmsg == "" ; - $status = $ok ? "\n[Email sent]" : "\n[{$errmsg}]" ; - phpfmg_log_mail( $to, $subject, ($ok ? 'Email sent' : 'Failed to send mail') . "\n" . ($nFound ? $headers . $txtMsg : $headers . $message), '', $type . $status ); // no log for attachments - - return $sError ; -} - - -function phpfmg_phpmailer( $to, $subject, $message, $from, $fromName, $cc = "" , $bcc = "", $charset = "UTF-8",$attachments = false ){ - - $mail = new PHPMailer(); - $mail->Host = PHPFMG_SMTP_HOST; // SMTP server - $mail->Username = PHPFMG_SMTP_USER; - $mail->Password = PHPFMG_SMTP_PLAIN_PASSWORD != '' ? PHPFMG_SMTP_PLAIN_PASSWORD : base64_decode(PHPFMG_SMTP_PASSWORD); - $mail->SMTPAuth = PHPFMG_SMTP_PASSWORD != ""; - $mail->SMTPSecure = PHPFMG_SMTP_SECURE; - $mail->Port = PHPFMG_SMTP_PORT == "" ? 25 : PHPFMG_SMTP_PORT; - if( defined('PHPFMG_SMTP_DEBUG_LEVEL') && PHPFMG_SMTP_DEBUG_LEVEL != "" ){ - $mail->SMTPDebug = (int)PHPFMG_SMTP_DEBUG_LEVEL ; - }; - - if( isset($GLOBALS['ReplyTo']) ) $mail->AddReplyTo($GLOBALS['ReplyTo']); - $mail->From = $from; - $mail->FromName = $fromName; - $mail->Subject = $subject; - $mail->Body = $message; - $mail->CharSet = $charset; - - if( !phpfmg_is_mysite() && (defined('PHPFMG_USE_SMTP') && 'Y' == PHPFMG_USE_SMTP) ){ - $mail->IsSMTP(); - }; - - $mail->IsHTML('html' == PHPFMG_MAIL_TYPE); - - $mail->AddAddress($to); - - if( ''!= $cc ){ - $CCs = explode(',',$cc); - foreach($CCs as $c){ - $mail->AddCC( $c ); - }; - }; - - if( ''!= $bcc ){ - $BCCs = explode(',',$bcc); - foreach($BCCs as $b){ - $mail->AddBCC( $b ); - }; - }; - - - if( is_array($attachments) ){ - foreach($attachments as $f){ - $mail->AddAttachment( $f['file'], basename($f['name']) ); - }; - }; - - return $mail->Send() ? "" : $mail->ErrorInfo; - -} - - - -function mailAutoResponse( $to, $from, $fields = false ){ - if( !formIsEMail($to) ) return ERR_EMAIL ; // one more check for spam robot - $enable = defined('PHPFMG_RETURN_ENABLE') && PHPFMG_RETURN_ENABLE === 'Y'; - $body = trim(phpfmg_auto_response_message()); - if( !$enable || empty($body) ){ - return false ; - }; - - $subject = PHPFMG_RETURN_SUBJECT; - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - $body = phpfmg_adjust_template($body); - $body = phpfmg_parse_mail_body($body,$fields); - $subject = phpfmg_parse_mail_body( $subject, $fields ); - if( $isHtml ) { - $body = phpfmg_getHtmlContent( $body ); - }; - $body = str_replace( "0x0d", '', $body ); - $body = str_replace( "0x0a", PHPFMG_LNCR, $body ); - - if( defined('PHPFMG_RETURN_EMAIL') && formIsEMail(PHPFMG_RETURN_EMAIL) ){ - $from = PHPFMG_RETURN_EMAIL; - }; - $fromHeader = ( PHPFMG_YOUR_NAME == "" ? "" : "\"".PHPFMG_YOUR_NAME . "\"" ) . " <{$from}>"; - return mailAttachments( $to , $subject , $body, filterEmail($from), PHPFMG_YOUR_NAME, $fromHeader, '' , '', PHPFMG_CHARSET, 'AutoResponseEmail' ); - -} - - -function phpfmg_log_mail( $to='', $subject='', $body='', $headers = '', $type='' ){ - $sep = PHPFMG_LNCR . str_repeat('----',20) . PHPFMG_LNCR ; - appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$type}" . $sep . "To: {$to}\r\nSubject: {$subject}\r\n" . $headers . $body . "
    " . PHPFMG_LNCR . $sep . PHPFMG_LNCR ) ; -} - - - -function phpfmg_getHtmlContent( $body ){ - $html = "Your Form Mail Content | htttp://phpfmg.sourceforge.net" - . $body .""; - return $html ; -} - - - -function phpfmg_adjust_template( $body ){ - $isHtml = 'html' == PHPFMG_MAIL_TYPE ; - if( $isHtml ){ - $body = preg_match( "/<[^<>]+>/", $body ) ? $body : nl2br($body); - }; - return $body; -} - - - -function phpfmg_parse_mail_body( $body, $fields = false ){ - if( !is_array($fields) ) - return $body ; - - $yes = function_exists( 'str_ireplace' ); - foreach( $fields as $name => $value ){ - $body = $yes ? str_ireplace( $name, $value ,$body ) - : str_replace ( $name, $value ,$body ); - }; - return trim($body); -} - - - -# filter line breaks to avoid emails injecting -function filterEmail($email, $chars = ''){ - $email = trim(str_replace( array("\r","\n"), '', $email )); - if( is_array($chars) ) $email = str_replace( $chars, '', $email ); - $email = preg_replace( '/(cc\s*\:|bcc\s*\:)/i', '', $email ); - return $email; -} - - - -function mailReport( $content = "", $file = '' ){ - $content = " -Dear Sir or Madam, - -Your online form at " . HOST_NAME . PHP_SELF . " failed to save data to file. Please make sure the web user has permission to write to file \"{$file}\". If you don't know how to fix it, please forward this email to technical support team of your web hosting company or your Administrator. - -PHPFMG -- PHP FormMail Generator -"; - mail(PHPFMG_TO, "Error@" . HOST_NAME . PHP_SELF, $content ); -} - - - -function remove_newline( $str = "" ){ - return str_replace( array("\r\n", "\r", "\n"), array('\r\n', '\r', '\n'), $str ); -} - - - -function checkPass( $form_mail = array() ) -{ - - $names = array(); - $labels = array(); - - foreach( $form_mail as $field ){ - $type = strtolower( $field[ "type" ] ); - //$value = trim( $_POST[ $field[ "name" ] ] ); - $value = phpfmg_field_value( $field[ "name" ] ); - $required = strtolower($field[ "required" ]) ; - $text = stripslashes( $field[ "text" ] ); - - // simple check the field has something keyed in. - if( !strlen($value) && ( $required == "required" ) && $type != "attachment" ){ - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_MISSING . $text ; - continue; - }; - - // verify the special case - if( - ( strlen($value) || $type == "attachment" ) - && $required == "required" - ): - - switch( $type ){ - case strtolower("Sender's Name") : - break; - case strtolower("Generic email"): - case strtolower("Sender's email"): - if( ! formIsEMail($value) ) { - $names[] = $field[ "name" ]; - $labels[] = $text . ERR_EMAIL; - //return ERR_EMAIL . $text ; - }; - // for checking entry limitation - if( $type == "sender's email" ){ - $GLOBALS['sender_email'] = $value; - }; - break; - case "text" : - break; - case "textarea" : - break; - case "checkbox" : - case "radio" : - break; - case "select" : - break; - case "attachment" : - $upload_file = $_FILES[ $field["name"] ][ "tmp_name" ] ; - if( ! is_uploaded_file($upload_file) ){ - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_SELECT_UPLOAD . $text; - }; - break; - case strtolower("Date(MM-DD-YYYY)"): - break; - case strtolower("Date(MM-YYYY)"): - break; - case strtolower("CreditCard(MM-YYYY)"): - if( $value < date("Y-m") ) { - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_CREDIT_CARD_EXPIRED . $text; - }; - break; - case strtolower("CreditCard#"): - if( !formIsCreditNumber( $value ) ) { - $names[] = $field[ "name" ]; - $labels[] = $text; - //return ERR_CREDIT_CARD_NUMBER . $text ; - }; - break; - case strtolower("Time(HH:MM:SS)"): - break; - case strtolower("Time(HH:MM)"): - break; - default : - //return $sErrRequired . $form_mail[ $i ][ "text" ]; - }; // switch - endif; - }; // for - - return array( - 'fields' => $names, - 'errors' => $labels, - ); -} - - - -function formSelected( $var, $val ) -{ - echo ( $var == $val ) ? "selected" : ""; -} - - - -function formChecked( $var, $val ) -{ - echo ( $var == $val ) ? "checked" : ""; -} - - - -function formIsEMail( $email ){ - return preg_match( "/^(.+)@(.+)\\.(.+)$/", $email ); -} - - - -function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" ) -{ - $tab = "\t" ; - print "\n\n" ; -} - - - -# something like CreditCard.pm in perl CPAN -function formIsCreditNumber( $number ) { - - $tmp = $number; - $number = preg_replace( "/[^0-9]/", "", $tmp ); - - if ( preg_match( "/[^\d\s]/", $number ) ) return 0; - if ( strlen($number) < 13 && 0+$number ) return 0; - - for ($i = 0; $i < strlen($number) - 1; $i++) { - $weight = substr($number, -1 * ($i + 2), 1) * (2 - ($i % 2)); - $sum += (($weight < 10) ? $weight : ($weight - 9)); - } - - if ( substr($number, -1) == (10 - $sum % 10) % 10 ) return $number; - return $number; -} - - -/* --------------------------------------------------------------------------------------------------- - Parameters: $sFileName - Return : - 1. "" : no extendsion name, or sFileName is empty - 2. string: MIME Type name of array aMimeType's definition. - ---------------------------------------------------------------------------------------------------*/ -function getMIMEType( $sFileName = "" ) { - $sFileName = strtolower( trim( $sFileName ) ); - if( ! strlen( $sFileName ) ) return ""; - - $aMimeType = array( - "txt" => "text/plain" , - "pdf" => "application/pdf" , - "zip" => "application/x-compressed" , - - "html" => "text/html" , - "htm" => "text/html" , - - "avi" => "video/avi" , - "mpg" => "video/mpeg " , - "wav" => "audio/wav" , - - "jpg" => "image/jpeg " , - "gif" => "image/gif" , - "tif" => "image/tiff " , - "png" => "image/x-png" , - "bmp" => "image/bmp" - ); - $aFile = explode( "\.", basename( $sFileName ) ) ; - $nDiminson = count( $aFile ) ; - $sExt = $aFile[ $nDiminson - 1 ] ; // get last part: like ".tar.zip", return "zip" - - return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : ""; -} - - - -function appendToFile( $sFileName = "", $line = "", $dataColumnsLine = '' ){ - $obey = defined('PHPFMG_GDPR') && 'Y' == PHPFMG_GDPR; // obey General Data Protection Regulation (GDPR)? - if( $obey ) return 0; - - if( !$sFileName || !$line ) return 0; - - $isExists = file_exists( $sFileName ); - $hFile = @fopen( "$sFileName", "a+w" ); - $nBytes = 0; - if( $hFile ){ - if( !$isExists && false !== strpos(strtolower(basename($sFileName)), '.php') ){ - fputs( $hFile, "\r\n"); - if( !empty($dataColumnsLine) ){ - fputs($hFile,$dataColumnsLine."\r\n"); - }; - }; - $nBytes = fputs( $hFile , trim($line)."\r\n" ); - fclose( $hFile ); - }; - return $nBytes ; -} - -function phpfmg_get_csv_header(){ - $csvValues = array(); - foreach( $GLOBALS['form_mail'] as $field ){ - $csvValues[] = csvfield( $field[ "text" ] ); - }; - return join(chr(0x09),/*","*/$csvValues) ; -} - -/* -function phpfmg_field_instruction($name, $show = true ){ - global $form_mail, $sErr; - $isError = in_array($name,$sErr['fields']); - $class = $isError ? 'instruction_error' : 'instruction' ; - if( $show || $isError ) echo "
    ". htmlspecialchars_decode($form_mail[ $name ]['instruction']) . "
    "; -} -*/ - -function phpfmg_rand( $len = 4 ){ - $md5 = md5( uniqid(rand()) ); - return $len > 0 ? substr($md5,0,$len) : $md5 ; -} - - - -// use a random name for stopping spam bot bypass the form.php, and post raw data directly -function phpfmg_captcha_name(){ - if( !isset($_SESSION['captcha_name']) ){ - $_SESSION['captcha_name'] = phpfmg_rand(8); //PHPFMG_ID.'fmgCaptchCode'; - }; - return $_SESSION['captcha_name']; -} - - -function phpfmg_check_recaptcha(){ - $errmsg = ERR_CAPTCHA; - if( isset($_POST['g-recaptcha-response']) ){ - $get = 'https://www.google.com/recaptcha/api/siteverify?secret=' . phpfmg_reCAPTCHA_key('secret_key'). '&response=' . $_POST['g-recaptcha-response']; - $response = file_get_contents($get); - echo $response; - $success = false; - if( function_exists('json_decode') ){ - $json = json_decode( $response, true ); - var_dump($json); - $success = $json['success'] === true; - }else{ - $success = preg_match( '/success[\"\']*\\:\\s*(true|1|y)/i', $response ); - }; - return $success ? '' : $errmsg; - } - return $errmsg; -} - -function phpfmg_check_captcha(){ - $errmsg = ''; - if( phpfmg_is_reCAPTCHA() ){ - $errmsg = phpfmg_check_recaptcha(); - }else{ - - $name = phpfmg_captcha_name(); - if( (defined('PHPFMG_SIMPLE_CAPTCHA_NAME') && PHPFMG_SIMPLE_CAPTCHA_NAME != '') && - ( !isset( $_POST[$name] ) || // maybe sutmited by spam bot - strtoupper($_POST[$name]) != strtoupper($_SESSION[$name]) // or user didn't type correct code - ) - ){ - $errmsg = ERR_CAPTCHA ; - }; - - }; - - return $errmsg ; -} - -function phpfmg_reCAPTCHA_key( $type ){ - $isSitekey = $type == 'site_key'; - // this keys are for formmail-maker.com domain only - $phpfmgSiteKey = '6LcQuv8SAAAAAKSvNHfF5gQuW9WIpcualeEYllCn'; - $phpfmgSecretKey = '6LcQuv8SAAAAABczBmLx85TQfdlkeMkjhz4Hzv5D'; - if( $isSitekey ){ - return phpfmg_is_mysite() ? $phpfmgSiteKey : RECAP_SITE_KEY; - }else{ - return phpfmg_is_mysite() ? $phpfmgSecretKey : RECAP_SECRET_KEY; - } - -} - - -function phpfmg_is_reCAPTCHA(){ - return (defined('RECAP_SITE_KEY') && '' != RECAP_SITE_KEY && defined('RECAP_SECRET_KEY') && '' != RECAP_SECRET_KEY) || (phpfmg_is_mysite() && defined('RECAP_SITE_KEY') ) ; -} - -function phpfmg_get_reCAPTCHA_html(){ - return - " -
    "; - -} - -function phpfmg_show_captcha(){ - if( phpfmg_is_reCAPTCHA() ){ - echo phpfmg_get_reCAPTCHA_html(); - return ; - }; - $url = PHPFMG_ADMIN_URL . '?mod=captcha&func=get&tid=' ; - $onclick= "onclick=\"document.getElementById('phpfmg_captcha_image').src='{$url}'+Math.random();return false;\" " ; - echo "\"Click\n"; - echo "Reload Verification Image
    \n"; - echo "\n"; -} - - - -function phpfmg_hsc($field, $default = false){ - echo isset($_POST[ $field ]) - ? HtmlSpecialChars( $_POST[ $field ] ) - : $default; -} - -function phpfmg_dropdown( $name, $options, $showInputbox = false, $isMultiple = false, $extra = '', $isReturn = false, $class = 'text_select' ){ - //$showInputbox = true; - $displayLast = 'none' ; - $onchange = $showInputbox ? " onchange=\"toggleOtherInputBox('{$name}','select','{$name}');\" " : "" ; - $sMultiple = $isMultiple ? 'multiple="multiple"' : '' ; - $other = "{$name}_other" ; - - $dropdown = array(); - $list = explode( '|', $options ); - $dropdown[] = "\n"; - - if( $showInputbox ){ - $dropdown[] = "" ; - $dropdown[] = "
    " ; - }; - - $s = join("\t\n",$dropdown); - - if( $isReturn ) - return $s; - else - echo $s ; -} - - -function phpfmg_date_dropdown( $cfgDate, $showSep = true ){ - $sep = $showSep ? $cfgDate['separator'] . " " : ""; - $field_name = $cfgDate['field_name']; - if( !isset($cfgDate['yyyy']) ){ - $startYear = $cfgDate['startYear']; - $endYear = $cfgDate['endYear']; - $year = range( $startYear, $endYear ); - $cfgDate['yyyy'] = $cfgDate['yearPrompt'] . '=,|' . join("|",$year); - }; - - switch( $cfgDate['format'] ){ - case 'mm/dd/yyyy' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'dd/mm/yyyy' : - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'yyyy/mm/dd' : - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - break; - case 'mm/yyyy' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - break; - case 'yyyy/mm' : - phpfmg_dropdown( $field_name.'_yyyy', $cfgDate['yyyy'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - break; - case 'mm/dd' : - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - break; - case 'dd/mm' : - phpfmg_dropdown( $field_name.'_day', $cfgDate['day'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_month', $cfgDate['month'], false, false, '', false, '' ); - break; - }; - echo "\n\n"; - echo "\n"; - -} - - -function phpfmg_date_dropdown_require( $field_name ){ - if( !isset($_POST) ) - return ; - - $month = $_POST[$field_name.'_month']; - $day = $_POST[$field_name.'_day']; - $yyyy = $_POST[$field_name.'_yyyy']; - $format = $_POST[$field_name.'_format']; - $sep = isset($_POST[$field_name.'_separator']) ? $_POST[$field_name.'_separator'] : '/'; - - // make up $_POST[$field_name] value - $_POST[$field_name] = ''; - switch( $format ){ - case 'mm/dd/yyyy' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $day . $sep . $yyyy; - break; - case 'dd/mm/yyyy' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $day . $sep . $month . $sep . $yyyy; - break; - case 'yyyy/mm/dd' : - if( !empty($month) && !empty($day) && !empty($yyyy) ) - $_POST[$field_name] = $yyyy . $sep . $month . $sep . $day; - break; - case 'mm/yyyy' : - if( !empty($month) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $yyyy; - break; - case 'yyyy/mm' : - if( !empty($month) && !empty($yyyy) ) - $_POST[$field_name] = $month . $sep . $yyyy; - break; - case 'mm/dd' : - if( !empty($month) && !empty($day) ) - $_POST[$field_name] = $month . $sep . $day; - break; - case 'dd/mm' : - if( !empty($month) && !empty($day) ) - $_POST[$field_name] = $day . $sep . $month; - break; - }; - -} - -function phpfmg_time_dropdown( $cfgTime ){ - $field_name = $cfgTime['field_name']; - $sep =": "; - switch( $cfgTime['hourOpt'] ){ - case 'h12' : - phpfmg_dropdown( $field_name.'_hour', $cfgTime['hour'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_minute', $cfgTime['minute'], false, false, '', false, '' ); - phpfmg_dropdown( $field_name.'_amfm', $cfgTime['amfm'], false, false, '', false, '' ); - break; - case 'h24' : - phpfmg_dropdown( $field_name.'_hour', $cfgTime['hour'], false, false, '', false, '' ); - echo $sep; - phpfmg_dropdown( $field_name.'_minute', $cfgTime['minute'], false, false, '', false, '' ); - break; - }; - echo "\n\n"; -} - - -function phpfmg_time_dropdown_require( $field_name ){ - if( !isset($_POST) ) - return ; - - $hour = $_POST[$field_name.'_hour']; - $minute = $_POST[$field_name.'_minute']; - $amfm = $_POST[$field_name.'_amfm']; - $format = $_POST[$field_name.'_format']; - $sep = ':'; - - // make up $_POST[$field_name] value - $_POST[$field_name] = ""; - switch( $format ){ - case 'h12' : - if( !empty($hour) && !empty($minute) && !empty($amfm) ) - $_POST[$field_name] = $hour . $sep . $minute . ' ' . $amfm; - break; - case 'h24' : - if( !empty($hour) && !empty($minute) ) - $_POST[$field_name] = $hour . $sep . $minute; - break; - }; - -} - - - -function phpfmg_dependent_dropdown( $field_name ){ - $field = phpfmg_dependent_dropdown_get_field( $field_name ); - $dd = new DependantDropdown(); - $dd->parseFmgField($field); - $html = $dd->getHtml(); - echo $html; -} - -function phpfmg_dependent_dropdown_dynamic_require( $field_name ){ - $field = phpfmg_dependent_dropdown_get_field( $field_name ); - $dd = new DependantDropdown(); - $dd->parseFmgField($field); - $dd->dynamicRequired(); -} - -function phpfmg_dependent_dropdown_get_field( $field_name ){ - if( !isset($_SESSION[PHPFMG_ID]) ){ - $_SESSION[PHPFMG_ID] = array(); - }; - if( !isset($_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name]) ){ - $base64 = phpfmg_dependent_dropdown_data(); - $data = @unserialize( base64_decode($base64) ); - $_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name] = $data; - }else{ - $data = $_SESSION[PHPFMG_ID]['DD_DATA_' . $field_name]; - }; - - if( !is_array($data) ){ - return ; - }; - - foreach( $data as $field ){ - if( $field['name'] == $field_name ){ - return $field; - }; - }; -} - - -# ------------------------------------------------------ -class DependantDropdown -{ - var $data = ''; - var $sheet = array(); - var $fields = array(); - var $fieldInfo = array( 'label', 'instruction', 'required', 'prompt' ); // describe field information from the first N rows of data - var $prefix = 'dd'; // in case there is no name for dropdown, it will name the dropdown like dd_0, dd_1, ... - - var $fmgField = false; - var $newliner = "" ; // replace \r\n with $newliner ; - var $newtaber = "" ; // replace \t with $newtaber ; - - function __construct(){ - } - - function DependantDropdown(){ - } - - - function lookupFieldColumn( $field, $column, $lookup, $contentType='text/plain', $charset='utf-8' ){ - $this->parseFmgField( $field ); - $this->nocache_headers( $contentType, $charset ); - return join( "\n", $this->getColumn( $column, $lookup ) ); - } - - function parseFmgField( $field ){ - if( !isset($_SESSION[PHPFMG_ID]) ){ - $_SESSION[PHPFMG_ID] = array(); - }; - $this->fmgField = $field; - $value = $this->newline_back($field['value']); - $this->data = explode("\r\n",$value); - if( !isset($_SESSION[PHPFMG_ID][ "DD_".$field['name'] ]) ){ - $this->parseData($field); - $_SESSION[PHPFMG_ID][ "DD_".$field['name'] ] = $this->fields; - }else{ - $this->fields = $_SESSION[PHPFMG_ID][ "DD_".$field['name'] ]; - }; - $this->makeupFieldsName(); - } - - function newline_back( $str = "" ){ - return str_replace( array($this->newtaber, $this->newliner), array("\t","\r\n"), $str ); - } - - function nocache_headers($contentType='text/plain', $charset='utf-8'){ - header("Expires: Mon, 01 Jan 1970 00:00:01 GMT"); - header("Cache-Control: max-age=0, no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); - header( "Content-Type: {$contentType}; charset={$charset}" ); - } - - - function setData( $s ){ - $this->data = $s ; - } - - function setPrefix( $s ){ - $this->prefix = $s; - } - - function parseData(){ - $tab = chr(0x09); - $nFieldInfoRows = count( $this->fieldInfo ); - for( $i = 0, $n = count($this->data); $i < $n; $i ++ ){ - $line = str_replace('"', '', $this->data[$i] ); - //$line = stripslashes( $line ); - $cols = explode( $tab, $line ); - - if( is_array($cols) && count($cols) > 1 ){ - - if( $i < $nFieldInfoRows ){ - $trims = array(); - foreach( $cols as $col ){ - $trims[] = trim($col); - }; - $this->fields[ $this->fieldInfo[$i] ] = $trims; - } - else - $this->fields['data'][] = $cols; - - }; // if - - //if ( $i > 1000 ) break; - }; // for - - } - - // $quickTest : to see whether a column contains data - function getColumn( $n, $lookup = array(), $quickTest = false ){ - $count = count($lookup); - if( $n > 0 && empty($count) ){ - return array(); // can not get column without search query - }; - - $col = array(); - $lastValue = $lookup[ $count - 1 ]; - $flatLookup = join( '|', $lookup ); - // when using ajax GET method, use utf8 to encoude the lookup query. otherwise, some special chars like France characters might not work - if( !$this->isPost() ){ - $lastValue = utf8_encode( $lastValue ); - $flatLookup = utf8_encode( $flatLookup ); - }; - - foreach( $this->fields['data'] as $r ){ - - if( !isset($r[$n]) ) - continue; - - $value = trim($r[$n]); - if( $value == '' ) - continue; - - if( $n == 0 ){ - $col[] = $value; - - }else{ - - //if( trim($r[$n-1]) == $lastValue ){ // quick check to improve performance - if( $r[$n-1] == $lastValue ){ // quick check the last value to improve performance - $leftCols = array_slice( $r, 0, $n ); - $flatLeftValues = join( '|', $leftCols ); - if( $flatLeftValues == $flatLookup ){ // show value only by lookuping by joining all its parents' values - $col[] = $value; - }; - }; // if - - }; // if $n == 0 - - if( $quickTest && count($col) > 0 ) break; - - }; // foreach - - return array_unique($col); - } - - function getColumnOptions( $n, $lookup = array(), $default = '' ){ - $opts = array(); - foreach( $this->getColumn($n, $lookup) as $v ){ - $selected = $default == $v ? 'selected' : '' ; - $opts[] = ""; - }; - return join("\n",$opts); - } - - function hsc($s){ - return str_replace ( array ( '&', '"', "'", '<', '>' ), array ( '&' , '"', ''' , '<' , '>' ), $s ); - } - - function isPost(){ - return isset($_POST[ $this->fields['name'][0] ]); - } - - function getHtml(){ - $html = array(); - - $field_name = $this->fmgField['name']; - $this->prefix = $field_name; - $count = count($this->fields['label']); - - // prepare for getting column options after form submitted - $lookup = array(); - $isPost = $this->isPost(); // isset($_POST[ $this->fields['name'][0] ]); - if( $isPost ){ - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $lookup[] = $_POST[ $this->fields['name'][$i] ]; - }; - }; - - for( $i = 0; $i < $count; $i++ ){ - $label = stripslashes( $this->fields['label'][$i] ); - if( empty($label) ) - continue; - - $name = $this->fields['name'][$i]; - $instruction = $this->fields['instruction'][$i]; - $prompt = $this->fields['prompt'][$i]; - $required = $this->fields['required'][$i]; - $promptOption = empty($prompt) ? "" : ""; - if( $isPost ) - $options = $this->getColumnOptions( $i, array_slice($lookup,0,$i), $_POST[$name] ); - else - $options = $this->getColumnOptions( $i, array(), '' ); - - $select = ""; - $sRequired = "" ; -$li = " -
  • -
    - {$sRequired} -
    -
    - {$select} -
    {$instruction}
    -
    -
  • -"; - $html[] = $li; - }; - - echo join("\n\n",$html); - - } - - - function dynamicRequired(){ - if( !isset($_POST) ){ - return ; - }; - - $field_name = $this->fmgField['name']; - $this->prefix = $field_name; - $count = count($this->fields['label']); - - $lookup = array(); - $isPost = isset($_POST[ $this->fields['name'][0] ]); - if( $isPost ){ - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $lookup[] = $_POST[ $this->fields['name'][$i] ]; - }; - }; - - for( $i = 0; $i < $count; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - - $name = $this->fields['name'][$i]; - $required = $this->fields['required'][$i]; - if( strtolower($required) == 'required' ){ - $rows = $this->getColumn( $i, array_slice($lookup,0,$i), true ); - if( empty($rows) ) { - $GLOBALS['form_mail'][ $name ]['required'] = '' ; // - }; - }else{ - $GLOBALS['form_mail'][ $name ]['required'] = '' ; - }; - }; - - } - - - function getFormMailArrayCode(){ - $code = array(); - for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++ ){ - $label = $this->fields['label'][$i]; - if( empty($label) ) - continue; - $name = $this->fields['name'][$i]; - $instruction = $this->fields['instruction'][$i]; - $prompt = $this->fields['prompt'][$i]; - $required = $this->fields['required'][$i]; - $code[] = "\$GLOBALS['form_mail']['{$name}'] = array( \"name\" => \"$name\", \"text\" => \"" . addslashes( $label ) . "\", \"type\" => \"select\", \"instruction\" => \"$instruction\", \"required\" => \"$required\" ) ;" ; - }; - return join("\n",$code); - } - - function makeupFieldsName($default='field_99'){ - $field_name = isset($this->fmgField['name']) ? $this->fmgField['name'] : $default; - $this->prefix = $field_name; - for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++ ){ - $this->fields['name'][$i] = $this->prefix . '_' . $i; - }; - } - -} - - - -function phpfmg_parse_option( $opt ){ - $opt = $opt; - $a = array( - 'text' => $opt, - 'value' => $opt, - 'default' => false, - ); - $pos = strrpos( $opt, '=' ); - if( false !== $pos ){ - $a['text'] = substr($opt,0,$pos); - $part = substr($opt,$pos+1); - $nv = strrpos( $part, ',' ); - if( false !== $nv ){ - $a['value'] = substr($part,0,$nv); - $a['default'] = 'default' == strtolower(substr($part,$nv+1)); - }else{ - $a['value'] = $part; - }; - }; - $a['text'] = trim($a['text']); - $a['value'] = trim($a['value']); - return $a ; -} - - - -function phpfmg_field_value( $name ){ - $value = "" ; - if( isset($GLOBALS[$name."_value"]) ) - return $GLOBALS[$name."_value"] ; - - $field = $GLOBALS['form_mail'][$name]; - $checkOther = isset( $_POST[$name.'_other_check'] ) && 1 == $_POST[$name.'_other_check'] ; - $otherInputValue = $checkOther ? $_POST[$name.'_other'] : '' ; - - switch( $field['type'] ){ - case 'select' : - if( $checkOther && $otherInputValue == "" ){ - return $value; - }; - - if( is_array($_POST[$name]) ){ - //array_pop( $_POST[$name] ); // pop the last "other" element - $value = join(PHPFMG_LNCR,$_POST[$name]) . PHPFMG_LNCR. $otherInputValue ; - $value = str_replace( PHPFMG_LNCR . "other", "", $value ); - }else{ - $value = $checkOther ? $otherInputValue : $_POST[ $name ]; - }; - break; - - case 'radio' : - if( $checkOther ){ - $value = $otherInputValue == '' ? '' : $otherInputValue; - }else{ - $value = $_POST[ $name ]; - }; - break; - - case 'checkbox' : - if( $checkOther && $otherInputValue == "" ){ - return $value; - }; - - $length = isset($_POST[$name.'_length']) ? $_POST[$name.'_length'] : 100; - $values = array(); - for( $i = 1; $i <= $length; $i ++){ - $newName = 'Checkbox' . ($i<10 ? '0' .$i : $i ) . "_" . $name; - if( $_POST[ $newName ] != "" && $_POST[ $newName ] != 'other' ) - $values[] = $_POST[ $newName ]; - }; - $value = ( empty($values) ? "" : join( PHPFMG_LNCR, $values ) ) . ( $otherInputValue != "" ? PHPFMG_LNCR . $otherInputValue : "" ); - break; - - default: - $value = $_POST[ $name ]; - break; - }; - $value = phpfmg_stripTags( $value ); - $GLOBALS[$name."_value"] = $value ; - return $value; -} - -function phpfmg_stripTags($str){ - $allowable_tags = "


    1. 
      -
      \ No newline at end of file
      diff --git a/signup.phpmailer.php b/signup.phpmailer.php
      deleted file mode 100644
      index 219c647..0000000
      --- a/signup.phpmailer.php
      +++ /dev/null
      @@ -1,5258 +0,0 @@
      -
      - * @author Jim Jagielski (jimjag) 
      - * @author Andy Prevost (codeworxtech) 
      - * @author Brent R. Matzelle (original founder)
      - * @copyright 2014 Marcus Bointon
      - * @copyright 2010 - 2012 Jim Jagielski
      - * @copyright 2004 - 2009 Andy Prevost
      - * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
      - * @note 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.
      - */
      -
      -/**
      - * PHPMailer RFC821 SMTP email transport class.
      - * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
      - * @package PHPMailer
      - * @author Chris Ryan
      - * @author Marcus Bointon 
      - */
      -class SMTP
      -{
      -    /**
      -     * The PHPMailer SMTP version number.
      -     * @var string
      -     */
      -    const VERSION = '5.2.21';
      -
      -    /**
      -     * SMTP line break constant.
      -     * @var string
      -     */
      -    const CRLF = "\r\n";
      -
      -    /**
      -     * The SMTP port to use if one is not specified.
      -     * @var integer
      -     */
      -    const DEFAULT_SMTP_PORT = 25;
      -
      -    /**
      -     * The maximum line length allowed by RFC 2822 section 2.1.1
      -     * @var integer
      -     */
      -    const MAX_LINE_LENGTH = 998;
      -
      -    /**
      -     * Debug level for no output
      -     */
      -    const DEBUG_OFF = 0;
      -
      -    /**
      -     * Debug level to show client -> server messages
      -     */
      -    const DEBUG_CLIENT = 1;
      -
      -    /**
      -     * Debug level to show client -> server and server -> client messages
      -     */
      -    const DEBUG_SERVER = 2;
      -
      -    /**
      -     * Debug level to show connection status, client -> server and server -> client messages
      -     */
      -    const DEBUG_CONNECTION = 3;
      -
      -    /**
      -     * Debug level to show all messages
      -     */
      -    const DEBUG_LOWLEVEL = 4;
      -
      -    /**
      -     * The PHPMailer SMTP Version number.
      -     * @var string
      -     * @deprecated Use the `VERSION` constant instead
      -     * @see SMTP::VERSION
      -     */
      -    public $Version = '5.2.21';
      -
      -    /**
      -     * SMTP server port number.
      -     * @var integer
      -     * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
      -     * @see SMTP::DEFAULT_SMTP_PORT
      -     */
      -    public $SMTP_PORT = 25;
      -
      -    /**
      -     * SMTP reply line ending.
      -     * @var string
      -     * @deprecated Use the `CRLF` constant instead
      -     * @see SMTP::CRLF
      -     */
      -    public $CRLF = "\r\n";
      -
      -    /**
      -     * Debug output level.
      -     * Options:
      -     * * self::DEBUG_OFF (`0`) No debug output, default
      -     * * self::DEBUG_CLIENT (`1`) Client commands
      -     * * self::DEBUG_SERVER (`2`) Client commands and server responses
      -     * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
      -     * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages
      -     * @var integer
      -     */
      -    public $do_debug = self::DEBUG_OFF;
      -
      -    /**
      -     * How to handle debug output.
      -     * Options:
      -     * * `echo` Output plain-text as-is, appropriate for CLI
      -     * * `html` Output escaped, line breaks converted to `
      `, appropriate for browser output - * * `error_log` Output to error log as configured in php.ini - * - * Alternatively, you can provide a callable expecting two params: a message string and the debug level: - * - * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; - * - * @var string|callable - */ - public $Debugoutput = 'echo'; - - /** - * Whether to use VERP. - * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path - * @link http://www.postfix.org/VERP_README.html Info on VERP - * @var boolean - */ - public $do_verp = false; - - /** - * The timeout value for connection, in seconds. - * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 - * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. - * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2 - * @var integer - */ - public $Timeout = 300; - - /** - * How long to wait for commands to complete, in seconds. - * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 - * @var integer - */ - public $Timelimit = 300; - - /** - * @var array patterns to extract smtp transaction id from smtp reply - * Only first capture group will be use, use non-capturing group to deal with it - * Extend this class to override this property to fulfil your needs. - */ - protected $smtp_transaction_id_patterns = array( - 'exim' => '/[0-9]{3} OK id=(.*)/', - 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/', - 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/' - ); - - /** - * The socket for the server connection. - * @var resource - */ - protected $smtp_conn; - - /** - * Error information, if any, for the last SMTP command. - * @var array - */ - protected $error = array( - 'error' => '', - 'detail' => '', - 'smtp_code' => '', - 'smtp_code_ex' => '' - ); - - /** - * The reply the server sent to us for HELO. - * If null, no HELO string has yet been received. - * @var string|null - */ - protected $helo_rply = null; - - /** - * The set of SMTP extensions sent in reply to EHLO command. - * Indexes of the array are extension names. - * Value at index 'HELO' or 'EHLO' (according to command that was sent) - * represents the server name. In case of HELO it is the only element of the array. - * Other values can be boolean TRUE or an array containing extension options. - * If null, no HELO/EHLO string has yet been received. - * @var array|null - */ - protected $server_caps = null; - - /** - * The most recent reply received from the server. - * @var string - */ - protected $last_reply = ''; - - /** - * Output debugging info via a user-selected method. - * @see SMTP::$Debugoutput - * @see SMTP::$do_debug - * @param string $str Debug string to output - * @param integer $level The debug level of this message; see DEBUG_* constants - * @return void - */ - protected function edebug($str, $level = 0) - { - if ($level > $this->do_debug) { - return; - } - //Avoid clash with built-in function names - if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { - call_user_func($this->Debugoutput, $str, $level); - return; - } - switch ($this->Debugoutput) { - case 'error_log': - //Don't output, just log - error_log($str); - break; - case 'html': - //Cleans up output a bit for a better looking, HTML-safe output - echo htmlentities( - preg_replace('/[\r\n]+/', '', $str), - ENT_QUOTES, - 'UTF-8' - ) - . "
      \n"; - break; - case 'echo': - default: - //Normalize line breaks - $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); - echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( - "\n", - "\n \t ", - trim($str) - )."\n"; - } - } - - /** - * Connect to an SMTP server. - * @param string $host SMTP server IP or host name - * @param integer $port The port number to connect to - * @param integer $timeout How long to wait for the connection to open - * @param array $options An array of options for stream_context_create() - * @access public - * @return boolean - */ - public function connect($host, $port = null, $timeout = 30, $options = array()) - { - static $streamok; - //This is enabled by default since 5.0.0 but some providers disable it - //Check this once and cache the result - if (is_null($streamok)) { - $streamok = function_exists('stream_socket_client'); - } - // Clear errors to avoid confusion - $this->setError(''); - // Make sure we are __not__ connected - if ($this->connected()) { - // Already connected, generate error - $this->setError('Already connected to a server'); - return false; - } - if (empty($port)) { - $port = self::DEFAULT_SMTP_PORT; - } - // Connect to the SMTP server - $this->edebug( - "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true), - self::DEBUG_CONNECTION - ); - $errno = 0; - $errstr = ''; - if ($streamok) { - $socket_context = stream_context_create($options); - set_error_handler(array($this, 'errorHandler')); - $this->smtp_conn = stream_socket_client( - $host . ":" . $port, - $errno, - $errstr, - $timeout, - STREAM_CLIENT_CONNECT, - $socket_context - ); - restore_error_handler(); - } else { - //Fall back to fsockopen which should work in more places, but is missing some features - $this->edebug( - "Connection: stream_socket_client not available, falling back to fsockopen", - self::DEBUG_CONNECTION - ); - set_error_handler(array($this, 'errorHandler')); - $this->smtp_conn = fsockopen( - $host, - $port, - $errno, - $errstr, - $timeout - ); - restore_error_handler(); - } - // Verify we connected properly - if (!is_resource($this->smtp_conn)) { - $this->setError( - 'Failed to connect to server', - $errno, - $errstr - ); - $this->edebug( - 'SMTP ERROR: ' . $this->error['error'] - . ": $errstr ($errno)", - self::DEBUG_CLIENT - ); - return false; - } - $this->edebug('Connection: opened', self::DEBUG_CONNECTION); - // SMTP server can take longer to respond, give longer timeout for first read - // Windows does not have support for this timeout function - if (substr(PHP_OS, 0, 3) != 'WIN') { - $max = ini_get('max_execution_time'); - // Don't bother if unlimited - if ($max != 0 && $timeout > $max) { - @set_time_limit($timeout); - } - stream_set_timeout($this->smtp_conn, $timeout, 0); - } - // Get any announcement - $announce = $this->get_lines(); - $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); - return true; - } - - /** - * Initiate a TLS (encrypted) session. - * @access public - * @return boolean - */ - public function startTLS() - { - if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) { - return false; - } - - //Allow the best TLS version(s) we can - $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; - - //PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT - //so add them back in manually if we can - if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; - } - - // Begin encrypted connection - if (!stream_socket_enable_crypto( - $this->smtp_conn, - true, - $crypto_method - )) { - return false; - } - return true; - } - - /** - * Perform SMTP authentication. - * Must be run after hello(). - * @see hello() - * @param string $username The user name - * @param string $password The password - * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2) - * @param string $realm The auth realm for NTLM - * @param string $workstation The auth workstation for NTLM - * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth) - * @return bool True if successfully authenticated.* @access public - */ - public function authenticate( - $username, - $password, - $authtype = null, - $realm = '', - $workstation = '', - $OAuth = null - ) { - if (!$this->server_caps) { - $this->setError('Authentication is not allowed before HELO/EHLO'); - return false; - } - - if (array_key_exists('EHLO', $this->server_caps)) { - // SMTP extensions are available. Let's try to find a proper authentication method - - if (!array_key_exists('AUTH', $this->server_caps)) { - $this->setError('Authentication is not allowed at this stage'); - // 'at this stage' means that auth may be allowed after the stage changes - // e.g. after STARTTLS - return false; - } - - self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); - self::edebug( - 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), - self::DEBUG_LOWLEVEL - ); - - if (empty($authtype)) { - foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN', 'NTLM', 'XOAUTH2') as $method) { - if (in_array($method, $this->server_caps['AUTH'])) { - $authtype = $method; - break; - } - } - if (empty($authtype)) { - $this->setError('No supported authentication methods found'); - return false; - } - self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); - } - - if (!in_array($authtype, $this->server_caps['AUTH'])) { - $this->setError("The requested authentication method \"$authtype\" is not supported by the server"); - return false; - } - } elseif (empty($authtype)) { - $authtype = 'LOGIN'; - } - switch ($authtype) { - case 'PLAIN': - // Start authentication - if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) { - return false; - } - // Send encoded username and password - if (!$this->sendCommand( - 'User & Password', - base64_encode("\0" . $username . "\0" . $password), - 235 - ) - ) { - return false; - } - break; - case 'LOGIN': - // Start authentication - if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) { - return false; - } - if (!$this->sendCommand("Username", base64_encode($username), 334)) { - return false; - } - if (!$this->sendCommand("Password", base64_encode($password), 235)) { - return false; - } - break; - case 'XOAUTH2': - //If the OAuth Instance is not set. Can be a case when PHPMailer is used - //instead of PHPMailerOAuth - if (is_null($OAuth)) { - return false; - } - $oauth = $OAuth->getOauth64(); - - // Start authentication - if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) { - return false; - } - break; - case 'NTLM': - /* - * ntlm_sasl_client.php - * Bundled with Permission - * - * How to telnet in windows: - * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx - * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication - */ - require_once 'extras/ntlm_sasl_client.php'; - $temp = new stdClass; - $ntlm_client = new ntlm_sasl_client_class; - //Check that functions are available - if (!$ntlm_client->initialize($temp)) { - $this->setError($temp->error); - $this->edebug( - 'You need to enable some modules in your php.ini file: ' - . $this->error['error'], - self::DEBUG_CLIENT - ); - return false; - } - //msg1 - $msg1 = $ntlm_client->typeMsg1($realm, $workstation); //msg1 - - if (!$this->sendCommand( - 'AUTH NTLM', - 'AUTH NTLM ' . base64_encode($msg1), - 334 - ) - ) { - return false; - } - //Though 0 based, there is a white space after the 3 digit number - //msg2 - $challenge = substr($this->last_reply, 3); - $challenge = base64_decode($challenge); - $ntlm_res = $ntlm_client->NTLMResponse( - substr($challenge, 24, 8), - $password - ); - //msg3 - $msg3 = $ntlm_client->typeMsg3( - $ntlm_res, - $username, - $realm, - $workstation - ); - // send encoded username - return $this->sendCommand('Username', base64_encode($msg3), 235); - case 'CRAM-MD5': - // Start authentication - if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) { - return false; - } - // Get the challenge - $challenge = base64_decode(substr($this->last_reply, 4)); - - // Build the response - $response = $username . ' ' . $this->hmac($challenge, $password); - - // send encoded credentials - return $this->sendCommand('Username', base64_encode($response), 235); - default: - $this->setError("Authentication method \"$authtype\" is not supported"); - return false; - } - return true; - } - - /** - * Calculate an MD5 HMAC hash. - * Works like hash_hmac('md5', $data, $key) - * in case that function is not available - * @param string $data The data to hash - * @param string $key The key to hash with - * @access protected - * @return string - */ - protected function hmac($data, $key) - { - if (function_exists('hash_hmac')) { - return hash_hmac('md5', $data, $key); - } - - // The following borrowed from - // http://php.net/manual/en/function.mhash.php#27225 - - // RFC 2104 HMAC implementation for php. - // Creates an md5 HMAC. - // Eliminates the need to install mhash to compute a HMAC - // by Lance Rushing - - $bytelen = 64; // byte length for md5 - if (strlen($key) > $bytelen) { - $key = pack('H*', md5($key)); - } - $key = str_pad($key, $bytelen, chr(0x00)); - $ipad = str_pad('', $bytelen, chr(0x36)); - $opad = str_pad('', $bytelen, chr(0x5c)); - $k_ipad = $key ^ $ipad; - $k_opad = $key ^ $opad; - - return md5($k_opad . pack('H*', md5($k_ipad . $data))); - } - - /** - * Check connection state. - * @access public - * @return boolean True if connected. - */ - public function connected() - { - if (is_resource($this->smtp_conn)) { - $sock_status = stream_get_meta_data($this->smtp_conn); - if ($sock_status['eof']) { - // The socket is valid but we are not connected - $this->edebug( - 'SMTP NOTICE: EOF caught while checking if connected', - self::DEBUG_CLIENT - ); - $this->close(); - return false; - } - return true; // everything looks good - } - return false; - } - - /** - * Close the socket and clean up the state of the class. - * Don't use this function without first trying to use QUIT. - * @see quit() - * @access public - * @return void - */ - public function close() - { - $this->setError(''); - $this->server_caps = null; - $this->helo_rply = null; - if (is_resource($this->smtp_conn)) { - // close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = null; //Makes for cleaner serialization - $this->edebug('Connection: closed', self::DEBUG_CONNECTION); - } - } - - /** - * Send an SMTP DATA command. - * Issues a data command and sends the msg_data to the server, - * finializing the mail transaction. $msg_data is the message - * that is to be send with the headers. Each header needs to be - * on a single line followed by a with the message headers - * and the message body being separated by and additional . - * Implements rfc 821: DATA - * @param string $msg_data Message data to send - * @access public - * @return boolean - */ - public function data($msg_data) - { - //This will use the standard timelimit - if (!$this->sendCommand('DATA', 'DATA', 354)) { - return false; - } - - /* The server is ready to accept data! - * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF) - * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into - * smaller lines to fit within the limit. - * We will also look for lines that start with a '.' and prepend an additional '.'. - * NOTE: this does not count towards line-length limit. - */ - - // Normalize line breaks before exploding - $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data)); - - /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field - * of the first line (':' separated) does not contain a space then it _should_ be a header and we will - * process all lines before a blank line as headers. - */ - - $field = substr($lines[0], 0, strpos($lines[0], ':')); - $in_headers = false; - if (!empty($field) && strpos($field, ' ') === false) { - $in_headers = true; - } - - foreach ($lines as $line) { - $lines_out = array(); - if ($in_headers and $line == '') { - $in_headers = false; - } - //Break this line up into several smaller lines if it's too long - //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len), - while (isset($line[self::MAX_LINE_LENGTH])) { - //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on - //so as to avoid breaking in the middle of a word - $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' '); - //Deliberately matches both false and 0 - if (!$pos) { - //No nice break found, add a hard break - $pos = self::MAX_LINE_LENGTH - 1; - $lines_out[] = substr($line, 0, $pos); - $line = substr($line, $pos); - } else { - //Break at the found point - $lines_out[] = substr($line, 0, $pos); - //Move along by the amount we dealt with - $line = substr($line, $pos + 1); - } - //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1 - if ($in_headers) { - $line = "\t" . $line; - } - } - $lines_out[] = $line; - - //Send the lines to the server - foreach ($lines_out as $line_out) { - //RFC2821 section 4.5.2 - if (!empty($line_out) and $line_out[0] == '.') { - $line_out = '.' . $line_out; - } - $this->client_send($line_out . self::CRLF); - } - } - - //Message data has been sent, complete the command - //Increase timelimit for end of DATA command - $savetimelimit = $this->Timelimit; - $this->Timelimit = $this->Timelimit * 2; - $result = $this->sendCommand('DATA END', '.', 250); - //Restore timelimit - $this->Timelimit = $savetimelimit; - return $result; - } - - /** - * Send an SMTP HELO or EHLO command. - * Used to identify the sending server to the receiving server. - * This makes sure that client and server are in a known state. - * Implements RFC 821: HELO - * and RFC 2821 EHLO. - * @param string $host The host name or IP to connect to - * @access public - * @return boolean - */ - public function hello($host = '') - { - //Try extended hello first (RFC 2821) - return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host)); - } - - /** - * Send an SMTP HELO or EHLO command. - * Low-level implementation used by hello() - * @see hello() - * @param string $hello The HELO string - * @param string $host The hostname to say we are - * @access protected - * @return boolean - */ - protected function sendHello($hello, $host) - { - $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250); - $this->helo_rply = $this->last_reply; - if ($noerror) { - $this->parseHelloFields($hello); - } else { - $this->server_caps = null; - } - return $noerror; - } - - /** - * Parse a reply to HELO/EHLO command to discover server extensions. - * In case of HELO, the only parameter that can be discovered is a server name. - * @access protected - * @param string $type - 'HELO' or 'EHLO' - */ - protected function parseHelloFields($type) - { - $this->server_caps = array(); - $lines = explode("\n", $this->helo_rply); - - foreach ($lines as $n => $s) { - //First 4 chars contain response code followed by - or space - $s = trim(substr($s, 4)); - if (empty($s)) { - continue; - } - $fields = explode(' ', $s); - if (!empty($fields)) { - if (!$n) { - $name = $type; - $fields = $fields[0]; - } else { - $name = array_shift($fields); - switch ($name) { - case 'SIZE': - $fields = ($fields ? $fields[0] : 0); - break; - case 'AUTH': - if (!is_array($fields)) { - $fields = array(); - } - break; - default: - $fields = true; - } - } - $this->server_caps[$name] = $fields; - } - } - } - - /** - * Send an SMTP MAIL command. - * Starts a mail transaction from the email address specified in - * $from. Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more recipient - * commands may be called followed by a data command. - * Implements rfc 821: MAIL FROM: - * @param string $from Source address of this message - * @access public - * @return boolean - */ - public function mail($from) - { - $useVerp = ($this->do_verp ? ' XVERP' : ''); - return $this->sendCommand( - 'MAIL FROM', - 'MAIL FROM:<' . $from . '>' . $useVerp, - 250 - ); - } - - /** - * Send an SMTP QUIT command. - * Closes the socket if there is no error or the $close_on_error argument is true. - * Implements from rfc 821: QUIT - * @param boolean $close_on_error Should the connection close if an error occurs? - * @access public - * @return boolean - */ - public function quit($close_on_error = true) - { - $noerror = $this->sendCommand('QUIT', 'QUIT', 221); - $err = $this->error; //Save any error - if ($noerror or $close_on_error) { - $this->close(); - $this->error = $err; //Restore any error from the quit command - } - return $noerror; - } - - /** - * Send an SMTP RCPT command. - * Sets the TO argument to $toaddr. - * Returns true if the recipient was accepted false if it was rejected. - * Implements from rfc 821: RCPT TO: - * @param string $address The address the message is being sent to - * @access public - * @return boolean - */ - public function recipient($address) - { - return $this->sendCommand( - 'RCPT TO', - 'RCPT TO:<' . $address . '>', - array(250, 251) - ); - } - - /** - * Send an SMTP RSET command. - * Abort any transaction that is currently in progress. - * Implements rfc 821: RSET - * @access public - * @return boolean True on success. - */ - public function reset() - { - return $this->sendCommand('RSET', 'RSET', 250); - } - - /** - * Send a command to an SMTP server and check its return code. - * @param string $command The command name - not sent to the server - * @param string $commandstring The actual command to send - * @param integer|array $expect One or more expected integer success codes - * @access protected - * @return boolean True on success. - */ - protected function sendCommand($command, $commandstring, $expect) - { - if (!$this->connected()) { - $this->setError("Called $command without being connected"); - return false; - } - //Reject line breaks in all commands - if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) { - $this->setError("Command '$command' contained line breaks"); - return false; - } - $this->client_send($commandstring . self::CRLF); - - $this->last_reply = $this->get_lines(); - // Fetch SMTP code and possible error code explanation - $matches = array(); - if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) { - $code = $matches[1]; - $code_ex = (count($matches) > 2 ? $matches[2] : null); - // Cut off error code from each response line - $detail = preg_replace( - "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m", - '', - $this->last_reply - ); - } else { - // Fall back to simple parsing if regex fails - $code = substr($this->last_reply, 0, 3); - $code_ex = null; - $detail = substr($this->last_reply, 4); - } - - $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); - - if (!in_array($code, (array)$expect)) { - $this->setError( - "$command command failed", - $detail, - $code, - $code_ex - ); - $this->edebug( - 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply, - self::DEBUG_CLIENT - ); - return false; - } - - $this->setError(''); - return true; - } - - /** - * Send an SMTP SAML command. - * Starts a mail transaction from the email address specified in $from. - * Returns true if successful or false otherwise. If True - * the mail transaction is started and then one or more recipient - * commands may be called followed by a data command. This command - * will send the message to the users terminal if they are logged - * in and send them an email. - * Implements rfc 821: SAML FROM: - * @param string $from The address the message is from - * @access public - * @return boolean - */ - public function sendAndMail($from) - { - return $this->sendCommand('SAML', "SAML FROM:$from", 250); - } - - /** - * Send an SMTP VRFY command. - * @param string $name The name to verify - * @access public - * @return boolean - */ - public function verify($name) - { - return $this->sendCommand('VRFY', "VRFY $name", array(250, 251)); - } - - /** - * Send an SMTP NOOP command. - * Used to keep keep-alives alive, doesn't actually do anything - * @access public - * @return boolean - */ - public function noop() - { - return $this->sendCommand('NOOP', 'NOOP', 250); - } - - /** - * Send an SMTP TURN command. - * This is an optional command for SMTP that this class does not support. - * This method is here to make the RFC821 Definition complete for this class - * and _may_ be implemented in future - * Implements from rfc 821: TURN - * @access public - * @return boolean - */ - public function turn() - { - $this->setError('The SMTP TURN command is not implemented'); - $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT); - return false; - } - - /** - * Send raw data to the server. - * @param string $data The data to send - * @access public - * @return integer|boolean The number of bytes sent to the server or false on error - */ - public function client_send($data) - { - $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); - return fwrite($this->smtp_conn, $data); - } - - /** - * Get the latest error. - * @access public - * @return array - */ - public function getError() - { - return $this->error; - } - - /** - * Get SMTP extensions available on the server - * @access public - * @return array|null - */ - public function getServerExtList() - { - return $this->server_caps; - } - - /** - * A multipurpose method - * The method works in three ways, dependent on argument value and current state - * 1. HELO/EHLO was not sent - returns null and set up $this->error - * 2. HELO was sent - * $name = 'HELO': returns server name - * $name = 'EHLO': returns boolean false - * $name = any string: returns null and set up $this->error - * 3. EHLO was sent - * $name = 'HELO'|'EHLO': returns server name - * $name = any string: if extension $name exists, returns boolean True - * or its options. Otherwise returns boolean False - * In other words, one can use this method to detect 3 conditions: - * - null returned: handshake was not or we don't know about ext (refer to $this->error) - * - false returned: the requested feature exactly not exists - * - positive value returned: the requested feature exists - * @param string $name Name of SMTP extension or 'HELO'|'EHLO' - * @return mixed - */ - public function getServerExt($name) - { - if (!$this->server_caps) { - $this->setError('No HELO/EHLO was sent'); - return null; - } - - // the tight logic knot ;) - if (!array_key_exists($name, $this->server_caps)) { - if ($name == 'HELO') { - return $this->server_caps['EHLO']; - } - if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) { - return false; - } - $this->setError('HELO handshake was used. Client knows nothing about server extensions'); - return null; - } - - return $this->server_caps[$name]; - } - - /** - * Get the last reply from the server. - * @access public - * @return string - */ - public function getLastReply() - { - return $this->last_reply; - } - - /** - * Read the SMTP server's response. - * Either before eof or socket timeout occurs on the operation. - * With SMTP we can tell if we have more lines to read if the - * 4th character is '-' symbol. If it is a space then we don't - * need to read anything else. - * @access protected - * @return string - */ - protected function get_lines() - { - // If the connection is bad, give up straight away - if (!is_resource($this->smtp_conn)) { - return ''; - } - $data = ''; - $endtime = 0; - stream_set_timeout($this->smtp_conn, $this->Timeout); - if ($this->Timelimit > 0) { - $endtime = time() + $this->Timelimit; - } - while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { - $str = @fgets($this->smtp_conn, 515); - $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); - $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); - $data .= $str; - // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen - if ((isset($str[3]) and $str[3] == ' ')) { - break; - } - // Timed-out? Log and break - $info = stream_get_meta_data($this->smtp_conn); - if ($info['timed_out']) { - $this->edebug( - 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', - self::DEBUG_LOWLEVEL - ); - break; - } - // Now check if reads took too long - if ($endtime and time() > $endtime) { - $this->edebug( - 'SMTP -> get_lines(): timelimit reached ('. - $this->Timelimit . ' sec)', - self::DEBUG_LOWLEVEL - ); - break; - } - } - return $data; - } - - /** - * Enable or disable VERP address generation. - * @param boolean $enabled - */ - public function setVerp($enabled = false) - { - $this->do_verp = $enabled; - } - - /** - * Get VERP address generation mode. - * @return boolean - */ - public function getVerp() - { - return $this->do_verp; - } - - /** - * Set error messages and codes. - * @param string $message The error message - * @param string $detail Further detail on the error - * @param string $smtp_code An associated SMTP error code - * @param string $smtp_code_ex Extended SMTP code - */ - protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '') - { - $this->error = array( - 'error' => $message, - 'detail' => $detail, - 'smtp_code' => $smtp_code, - 'smtp_code_ex' => $smtp_code_ex - ); - } - - /** - * Set debug output method. - * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it. - */ - public function setDebugOutput($method = 'echo') - { - $this->Debugoutput = $method; - } - - /** - * Get debug output method. - * @return string - */ - public function getDebugOutput() - { - return $this->Debugoutput; - } - - /** - * Set debug output level. - * @param integer $level - */ - public function setDebugLevel($level = 0) - { - $this->do_debug = $level; - } - - /** - * Get debug output level. - * @return integer - */ - public function getDebugLevel() - { - return $this->do_debug; - } - - /** - * Set SMTP timeout. - * @param integer $timeout - */ - public function setTimeout($timeout = 0) - { - $this->Timeout = $timeout; - } - - /** - * Get SMTP timeout. - * @return integer - */ - public function getTimeout() - { - return $this->Timeout; - } - - /** - * Reports an error number and string. - * @param integer $errno The error number returned by PHP. - * @param string $errmsg The error message returned by PHP. - */ - protected function errorHandler($errno, $errmsg) - { - $notice = 'Connection: Failed to connect to server.'; - $this->setError( - $notice, - $errno, - $errmsg - ); - $this->edebug( - $notice . ' Error number ' . $errno . '. "Error notice: ' . $errmsg, - self::DEBUG_CONNECTION - ); - } - - /** - * Will return the ID of the last smtp transaction based on a list of patterns provided - * in SMTP::$smtp_transaction_id_patterns. - * If no reply has been received yet, it will return null. - * If no pattern has been matched, it will return false. - * @return bool|null|string - */ - public function getLastTransactionID() - { - $reply = $this->getLastReply(); - - if (empty($reply)) { - return null; - } - - foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) { - if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) { - return $matches[1]; - } - } - - return false; - } -} - - - -/** - * PHPMailer - PHP email creation and transport class. - * @package PHPMailer - * @author Marcus Bointon (Synchro/coolbru) - * @author Jim Jagielski (jimjag) - * @author Andy Prevost (codeworxtech) - * @author Brent R. Matzelle (original founder) - */ -class PHPMailer -{ - /** - * The PHPMailer Version number. - * @var string - */ - public $Version = '5.2.21'; - - /** - * Email priority. - * Options: null (default), 1 = High, 3 = Normal, 5 = low. - * When null, the header is not set at all. - * @var integer - */ - public $Priority = null; - - /** - * The character set of the message. - * @var string - */ - public $CharSet = 'iso-8859-1'; - - /** - * The MIME Content-type of the message. - * @var string - */ - public $ContentType = 'text/plain'; - - /** - * The message encoding. - * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". - * @var string - */ - public $Encoding = '8bit'; - - /** - * Holds the most recent mailer error message. - * @var string - */ - public $ErrorInfo = ''; - - /** - * The From email address for the message. - * @var string - */ - public $From = 'root@localhost'; - - /** - * The From name of the message. - * @var string - */ - public $FromName = 'Root User'; - - /** - * The Sender email (Return-Path) of the message. - * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. - * @var string - */ - public $Sender = ''; - - /** - * The Return-Path of the message. - * If empty, it will be set to either From or Sender. - * @var string - * @deprecated Email senders should never set a return-path header; - * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything. - * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference - */ - public $ReturnPath = ''; - - /** - * The Subject of the message. - * @var string - */ - public $Subject = ''; - - /** - * An HTML or plain text message body. - * If HTML then call isHTML(true). - * @var string - */ - public $Body = ''; - - /** - * The plain-text message body. - * This body can be read by mail clients that do not have HTML email - * capability such as mutt & Eudora. - * Clients that can read HTML will view the normal Body. - * @var string - */ - public $AltBody = ''; - - /** - * An iCal message part body. - * Only supported in simple alt or alt_inline message types - * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator - * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ - * @link http://kigkonsult.se/iCalcreator/ - * @var string - */ - public $Ical = ''; - - /** - * The complete compiled MIME message body. - * @access protected - * @var string - */ - protected $MIMEBody = ''; - - /** - * The complete compiled MIME message headers. - * @var string - * @access protected - */ - protected $MIMEHeader = ''; - - /** - * Extra headers that createHeader() doesn't fold in. - * @var string - * @access protected - */ - protected $mailHeader = ''; - - /** - * Word-wrap the message body to this number of chars. - * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. - * @var integer - */ - public $WordWrap = 0; - - /** - * Which method to use to send mail. - * Options: "mail", "sendmail", or "smtp". - * @var string - */ - public $Mailer = 'mail'; - - /** - * The path to the sendmail program. - * @var string - */ - public $Sendmail = '/usr/sbin/sendmail'; - - /** - * Whether mail() uses a fully sendmail-compatible MTA. - * One which supports sendmail's "-oi -f" options. - * @var boolean - */ - public $UseSendmailOptions = true; - - /** - * Path to PHPMailer plugins. - * Useful if the SMTP class is not in the PHP include path. - * @var string - * @deprecated Should not be needed now there is an autoloader. - */ - public $PluginDir = ''; - - /** - * The email address that a reading confirmation should be sent to, also known as read receipt. - * @var string - */ - public $ConfirmReadingTo = ''; - - /** - * The hostname to use in the Message-ID header and as default HELO string. - * If empty, PHPMailer attempts to find one with, in order, - * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value - * 'localhost.localdomain'. - * @var string - */ - public $Hostname = ''; - - /** - * An ID to be used in the Message-ID header. - * If empty, a unique id will be generated. - * You can set your own, but it must be in the format "", - * as defined in RFC5322 section 3.6.4 or it will be ignored. - * @see https://tools.ietf.org/html/rfc5322#section-3.6.4 - * @var string - */ - public $MessageID = ''; - - /** - * The message Date to be used in the Date header. - * If empty, the current date will be added. - * @var string - */ - public $MessageDate = ''; - - /** - * SMTP hosts. - * Either a single hostname or multiple semicolon-delimited hostnames. - * You can also specify a different port - * for each host by using this format: [hostname:port] - * (e.g. "smtp1.example.com:25;smtp2.example.com"). - * You can also specify encryption type, for example: - * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). - * Hosts will be tried in order. - * @var string - */ - public $Host = 'localhost'; - - /** - * The default SMTP server port. - * @var integer - * @TODO Why is this needed when the SMTP class takes care of it? - */ - public $Port = 25; - - /** - * The SMTP HELO of the message. - * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find - * one with the same method described above for $Hostname. - * @var string - * @see PHPMailer::$Hostname - */ - public $Helo = ''; - - /** - * What kind of encryption to use on the SMTP connection. - * Options: '', 'ssl' or 'tls' - * @var string - */ - public $SMTPSecure = ''; - - /** - * Whether to enable TLS encryption automatically if a server supports it, - * even if `SMTPSecure` is not set to 'tls'. - * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. - * @var boolean - */ - public $SMTPAutoTLS = true; - - /** - * Whether to use SMTP authentication. - * Uses the Username and Password properties. - * @var boolean - * @see PHPMailer::$Username - * @see PHPMailer::$Password - */ - public $SMTPAuth = false; - - /** - * Options array passed to stream_context_create when connecting via SMTP. - * @var array - */ - public $SMTPOptions = array(); - - /** - * SMTP username. - * @var string - */ - public $Username = ''; - - /** - * SMTP password. - * @var string - */ - public $Password = ''; - - /** - * SMTP auth type. - * Options are CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified - * @var string - */ - public $AuthType = ''; - - /** - * SMTP realm. - * Used for NTLM auth - * @var string - */ - public $Realm = ''; - - /** - * SMTP workstation. - * Used for NTLM auth - * @var string - */ - public $Workstation = ''; - - /** - * The SMTP server timeout in seconds. - * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 - * @var integer - */ - public $Timeout = 300; - - /** - * SMTP class debug output mode. - * Debug output level. - * Options: - * * `0` No output - * * `1` Commands - * * `2` Data and commands - * * `3` As 2 plus connection status - * * `4` Low-level data output - * @var integer - * @see SMTP::$do_debug - */ - public $SMTPDebug = 0; - - /** - * How to handle debug output. - * Options: - * * `echo` Output plain-text as-is, appropriate for CLI - * * `html` Output escaped, line breaks converted to `
      `, appropriate for browser output - * * `error_log` Output to error log as configured in php.ini - * - * Alternatively, you can provide a callable expecting two params: a message string and the debug level: - * - * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; - * - * @var string|callable - * @see SMTP::$Debugoutput - */ - public $Debugoutput = 'echo'; - - /** - * Whether to keep SMTP connection open after each message. - * If this is set to true then to close the connection - * requires an explicit call to smtpClose(). - * @var boolean - */ - public $SMTPKeepAlive = false; - - /** - * Whether to split multiple to addresses into multiple messages - * or send them all in one message. - * Only supported in `mail` and `sendmail` transports, not in SMTP. - * @var boolean - */ - public $SingleTo = false; - - /** - * Storage for addresses when SingleTo is enabled. - * @var array - * @TODO This should really not be public - */ - public $SingleToArray = array(); - - /** - * Whether to generate VERP addresses on send. - * Only applicable when sending via SMTP. - * @link https://en.wikipedia.org/wiki/Variable_envelope_return_path - * @link http://www.postfix.org/VERP_README.html Postfix VERP info - * @var boolean - */ - public $do_verp = false; - - /** - * Whether to allow sending messages with an empty body. - * @var boolean - */ - public $AllowEmpty = false; - - /** - * The default line ending. - * @note The default remains "\n". We force CRLF where we know - * it must be used via self::CRLF. - * @var string - */ - public $LE = "\n"; - - /** - * DKIM selector. - * @var string - */ - public $DKIM_selector = ''; - - /** - * DKIM Identity. - * Usually the email address used as the source of the email. - * @var string - */ - public $DKIM_identity = ''; - - /** - * DKIM passphrase. - * Used if your key is encrypted. - * @var string - */ - public $DKIM_passphrase = ''; - - /** - * DKIM signing domain name. - * @example 'example.com' - * @var string - */ - public $DKIM_domain = ''; - - /** - * DKIM private key file path. - * @var string - */ - public $DKIM_private = ''; - - /** - * DKIM private key string. - * If set, takes precedence over `$DKIM_private`. - * @var string - */ - public $DKIM_private_string = ''; - - /** - * Callback Action function name. - * - * The function that handles the result of the send email action. - * It is called out by send() for each email sent. - * - * Value can be any php callable: http://www.php.net/is_callable - * - * Parameters: - * boolean $result result of the send action - * string $to email address of the recipient - * string $cc cc email addresses - * string $bcc bcc email addresses - * string $subject the subject - * string $body the email body - * string $from email address of sender - * @var string - */ - public $action_function = ''; - - /** - * What to put in the X-Mailer header. - * Options: An empty string for PHPMailer default, whitespace for none, or a string to use - * @var string - */ - public $XMailer = ''; - - /** - * Which validator to use by default when validating email addresses. - * May be a callable to inject your own validator, but there are several built-in validators. - * @see PHPMailer::validateAddress() - * @var string|callable - * @static - */ - public static $validator = 'auto'; - - /** - * An instance of the SMTP sender class. - * @var SMTP - * @access protected - */ - protected $smtp = null; - - /** - * The array of 'to' names and addresses. - * @var array - * @access protected - */ - protected $to = array(); - - /** - * The array of 'cc' names and addresses. - * @var array - * @access protected - */ - protected $cc = array(); - - /** - * The array of 'bcc' names and addresses. - * @var array - * @access protected - */ - protected $bcc = array(); - - /** - * The array of reply-to names and addresses. - * @var array - * @access protected - */ - protected $ReplyTo = array(); - - /** - * An array of all kinds of addresses. - * Includes all of $to, $cc, $bcc - * @var array - * @access protected - * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc - */ - protected $all_recipients = array(); - - /** - * An array of names and addresses queued for validation. - * In send(), valid and non duplicate entries are moved to $all_recipients - * and one of $to, $cc, or $bcc. - * This array is used only for addresses with IDN. - * @var array - * @access protected - * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc - * @see PHPMailer::$all_recipients - */ - protected $RecipientsQueue = array(); - - /** - * An array of reply-to names and addresses queued for validation. - * In send(), valid and non duplicate entries are moved to $ReplyTo. - * This array is used only for addresses with IDN. - * @var array - * @access protected - * @see PHPMailer::$ReplyTo - */ - protected $ReplyToQueue = array(); - - /** - * The array of attachments. - * @var array - * @access protected - */ - protected $attachment = array(); - - /** - * The array of custom headers. - * @var array - * @access protected - */ - protected $CustomHeader = array(); - - /** - * The most recent Message-ID (including angular brackets). - * @var string - * @access protected - */ - protected $lastMessageID = ''; - - /** - * The message's MIME type. - * @var string - * @access protected - */ - protected $message_type = ''; - - /** - * The array of MIME boundary strings. - * @var array - * @access protected - */ - protected $boundary = array(); - - /** - * The array of available languages. - * @var array - * @access protected - */ - protected $language = array(); - - /** - * The number of errors encountered. - * @var integer - * @access protected - */ - protected $error_count = 0; - - /** - * The S/MIME certificate file path. - * @var string - * @access protected - */ - protected $sign_cert_file = ''; - - /** - * The S/MIME key file path. - * @var string - * @access protected - */ - protected $sign_key_file = ''; - - /** - * The optional S/MIME extra certificates ("CA Chain") file path. - * @var string - * @access protected - */ - protected $sign_extracerts_file = ''; - - /** - * The S/MIME password for the key. - * Used only if the key is encrypted. - * @var string - * @access protected - */ - protected $sign_key_pass = ''; - - /** - * Whether to throw exceptions for errors. - * @var boolean - * @access protected - */ - protected $exceptions = false; - - /** - * Unique ID used for message ID and boundaries. - * @var string - * @access protected - */ - protected $uniqueid = ''; - - /** - * Error severity: message only, continue processing. - */ - const STOP_MESSAGE = 0; - - /** - * Error severity: message, likely ok to continue processing. - */ - const STOP_CONTINUE = 1; - - /** - * Error severity: message, plus full stop, critical error reached. - */ - const STOP_CRITICAL = 2; - - /** - * SMTP RFC standard line ending. - */ - const CRLF = "\r\n"; - - /** - * The maximum line length allowed by RFC 2822 section 2.1.1 - * @var integer - */ - const MAX_LINE_LENGTH = 998; - - /** - * Constructor. - * @param boolean $exceptions Should we throw external exceptions? - */ - public function __construct($exceptions = null) - { - if ($exceptions !== null) { - $this->exceptions = (boolean)$exceptions; - } - } - - /** - * Destructor. - */ - public function __destruct() - { - //Close any open SMTP connection nicely - $this->smtpClose(); - } - - /** - * Call mail() in a safe_mode-aware fashion. - * Also, unless sendmail_path points to sendmail (or something that - * claims to be sendmail), don't pass params (not a perfect fix, - * but it will do) - * @param string $to To - * @param string $subject Subject - * @param string $body Message Body - * @param string $header Additional Header(s) - * @param string $params Params - * @access private - * @return boolean - */ - private function mailPassthru($to, $subject, $body, $header, $params) - { - //Check overloading of mail function to avoid double-encoding - if (ini_get('mbstring.func_overload') & 1) { - $subject = $this->secureHeader($subject); - } else { - $subject = $this->encodeHeader($this->secureHeader($subject)); - } - - //Can't use additional_parameters in safe_mode, calling mail() with null params breaks - //@link http://php.net/manual/en/function.mail.php - if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) { - $result = @mail($to, $subject, $body, $header); - } else { - $result = @mail($to, $subject, $body, $header, $params); - } - return $result; - } - /** - * Output debugging info via user-defined method. - * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug). - * @see PHPMailer::$Debugoutput - * @see PHPMailer::$SMTPDebug - * @param string $str - */ - protected function edebug($str) - { - if ($this->SMTPDebug <= 0) { - return; - } - //Avoid clash with built-in function names - if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { - call_user_func($this->Debugoutput, $str, $this->SMTPDebug); - return; - } - switch ($this->Debugoutput) { - case 'error_log': - //Don't output, just log - error_log($str); - break; - case 'html': - //Cleans up output a bit for a better looking, HTML-safe output - echo htmlentities( - preg_replace('/[\r\n]+/', '', $str), - ENT_QUOTES, - 'UTF-8' - ) - . "
      \n"; - break; - case 'echo': - default: - //Normalize line breaks - $str = preg_replace('/\r\n?/ms', "\n", $str); - echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( - "\n", - "\n \t ", - trim($str) - ) . "\n"; - } - } - - /** - * Sets message type to HTML or plain. - * @param boolean $isHtml True for HTML mode. - * @return void - */ - public function isHTML($isHtml = true) - { - if ($isHtml) { - $this->ContentType = 'text/html'; - } else { - $this->ContentType = 'text/plain'; - } - } - - /** - * Send messages using SMTP. - * @return void - */ - public function isSMTP() - { - $this->Mailer = 'smtp'; - } - - /** - * Send messages using PHP's mail() function. - * @return void - */ - public function isMail() - { - $this->Mailer = 'mail'; - } - - /** - * Send messages using $Sendmail. - * @return void - */ - public function isSendmail() - { - $ini_sendmail_path = ini_get('sendmail_path'); - - if (!stristr($ini_sendmail_path, 'sendmail')) { - $this->Sendmail = '/usr/sbin/sendmail'; - } else { - $this->Sendmail = $ini_sendmail_path; - } - $this->Mailer = 'sendmail'; - } - - /** - * Send messages using qmail. - * @return void - */ - public function isQmail() - { - $ini_sendmail_path = ini_get('sendmail_path'); - - if (!stristr($ini_sendmail_path, 'qmail')) { - $this->Sendmail = '/var/qmail/bin/qmail-inject'; - } else { - $this->Sendmail = $ini_sendmail_path; - } - $this->Mailer = 'qmail'; - } - - /** - * Add a "To" address. - * @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 - */ - public function addAddress($address, $name = '') - { - return $this->addOrEnqueueAnAddress('to', $address, $name); - } - - /** - * Add a "CC" address. - * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. - * @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 - */ - public function addCC($address, $name = '') - { - return $this->addOrEnqueueAnAddress('cc', $address, $name); - } - - /** - * Add a "BCC" address. - * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. - * @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 - */ - public function addBCC($address, $name = '') - { - return $this->addOrEnqueueAnAddress('bcc', $address, $name); - } - - /** - * Add a "Reply-To" address. - * @param string $address The email address to reply to - * @param string $name - * @return boolean true on success, false if address already used or invalid in some way - */ - public function addReplyTo($address, $name = '') - { - return $this->addOrEnqueueAnAddress('Reply-To', $address, $name); - } - - /** - * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer - * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still - * be modified after calling this function), addition of such addresses is delayed until send(). - * Addresses that have been added already return false, but do not throw exceptions. - * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' - * @param string $address The email address to send, resp. to reply to - * @param string $name - * @throws phpmailerException - * @return boolean true on success, false if address already used or invalid in some way - * @access protected - */ - protected function addOrEnqueueAnAddress($kind, $address, $name) - { - $address = trim($address); - $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim - if (($pos = strrpos($address, '@')) === false) { - // At-sign is misssing. - $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address"; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - $params = array($kind, $address, $name); - // Enqueue addresses with IDN until we know the PHPMailer::$CharSet. - if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) { - if ($kind != 'Reply-To') { - if (!array_key_exists($address, $this->RecipientsQueue)) { - $this->RecipientsQueue[$address] = $params; - return true; - } - } else { - if (!array_key_exists($address, $this->ReplyToQueue)) { - $this->ReplyToQueue[$address] = $params; - return true; - } - } - return false; - } - // Immediately add standard addresses without IDN. - return call_user_func_array(array($this, 'addAnAddress'), $params); - } - - /** - * Add an address to one of the recipient arrays or to the ReplyTo array. - * Addresses that have been added already return false, but do not throw exceptions. - * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' - * @param string $address The email address to send, resp. to reply to - * @param string $name - * @throws phpmailerException - * @return boolean true on success, false if address already used or invalid in some way - * @access protected - */ - protected function addAnAddress($kind, $address, $name = '') - { - if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) { - $error_message = $this->lang('Invalid recipient kind: ') . $kind; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - if (!$this->validateAddress($address)) { - $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address"; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - if ($kind != 'Reply-To') { - if (!array_key_exists(strtolower($address), $this->all_recipients)) { - array_push($this->$kind, array($address, $name)); - $this->all_recipients[strtolower($address)] = true; - return true; - } - } else { - if (!array_key_exists(strtolower($address), $this->ReplyTo)) { - $this->ReplyTo[strtolower($address)] = array($address, $name); - return true; - } - } - return false; - } - - /** - * Parse and validate a string containing one or more RFC822-style comma-separated email addresses - * of the form "display name
      " into an array of name/address pairs. - * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. - * Note that quotes in the name part are removed. - * @param string $addrstr The address list string - * @param bool $useimap Whether to use the IMAP extension to parse the list - * @return array - * @link http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation - */ - public function parseAddresses($addrstr, $useimap = true) - { - $addresses = array(); - if ($useimap and function_exists('imap_rfc822_parse_adrlist')) { - //Use this built-in parser if it's available - $list = imap_rfc822_parse_adrlist($addrstr, ''); - foreach ($list as $address) { - if ($address->host != '.SYNTAX-ERROR.') { - if ($this->validateAddress($address->mailbox . '@' . $address->host)) { - $addresses[] = array( - 'name' => (property_exists($address, 'personal') ? $address->personal : ''), - 'address' => $address->mailbox . '@' . $address->host - ); - } - } - } - } else { - //Use this simpler parser - $list = explode(',', $addrstr); - foreach ($list as $address) { - $address = trim($address); - //Is there a separate name part? - if (strpos($address, '<') === false) { - //No separate name, just use the whole thing - if ($this->validateAddress($address)) { - $addresses[] = array( - 'name' => '', - 'address' => $address - ); - } - } else { - list($name, $email) = explode('<', $address); - $email = trim(str_replace('>', '', $email)); - if ($this->validateAddress($email)) { - $addresses[] = array( - 'name' => trim(str_replace(array('"', "'"), '', $name)), - 'address' => $email - ); - } - } - } - } - return $addresses; - } - - /** - * Set the From and FromName properties. - * @param string $address - * @param string $name - * @param boolean $auto Whether to also set the Sender address, defaults to true - * @throws phpmailerException - * @return boolean - */ - public function setFrom($address, $name = '', $auto = true) - { - $address = trim($address); - $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim - // Don't validate now addresses with IDN. Will be done in send(). - if (($pos = strrpos($address, '@')) === false or - (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and - !$this->validateAddress($address)) { - $error_message = $this->lang('invalid_address') . " (setFrom) $address"; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - $this->From = $address; - $this->FromName = $name; - if ($auto) { - if (empty($this->Sender)) { - $this->Sender = $address; - } - } - return true; - } - - /** - * Return the Message-ID header of the last email. - * Technically this is the value from the last time the headers were created, - * but it's also the message ID of the last sent message except in - * pathological cases. - * @return string - */ - public function getLastMessageID() - { - return $this->lastMessageID; - } - - /** - * Check that a string looks like an email address. - * @param string $address The email address to check - * @param string|callable $patternselect A selector for the validation pattern to use : - * * `auto` Pick best pattern automatically; - * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; - * * `pcre` Use old PCRE implementation; - * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; - * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. - * * `noregex` Don't use a regex: super fast, really dumb. - * Alternatively you may pass in a callable to inject your own validator, for example: - * PHPMailer::validateAddress('user@example.com', function($address) { - * return (strpos($address, '@') !== false); - * }); - * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator. - * @return boolean - * @static - * @access public - */ - public static function validateAddress($address, $patternselect = null) - { - if (is_null($patternselect)) { - $patternselect = self::$validator; - } - if (is_callable($patternselect)) { - return call_user_func($patternselect, $address); - } - //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 - if (strpos($address, "\n") !== false or strpos($address, "\r") !== false) { - return false; - } - if (!$patternselect or $patternselect == 'auto') { - //Check this constant first so it works when extension_loaded() is disabled by safe mode - //Constant was added in PHP 5.2.4 - if (defined('PCRE_VERSION')) { - //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2 - if (version_compare(PCRE_VERSION, '8.0.3') >= 0) { - $patternselect = 'pcre8'; - } else { - $patternselect = 'pcre'; - } - } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) { - //Fall back to older PCRE - $patternselect = 'pcre'; - } else { - //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension - if (version_compare(PHP_VERSION, '5.2.0') >= 0) { - $patternselect = 'php'; - } else { - $patternselect = 'noregex'; - } - } - } - switch ($patternselect) { - case 'pcre8': - /** - * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains. - * @link http://squiloople.com/2009/12/20/email-address-validation/ - * @copyright 2009-2010 Michael Rushton - * Feel free to use and redistribute this code. But please keep this copyright notice. - */ - return (boolean)preg_match( - '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . - '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . - '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . - '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . - '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . - '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . - '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . - '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . - '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', - $address - ); - case 'pcre': - //An older regex that doesn't need a recent PCRE - return (boolean)preg_match( - '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . - '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' . - '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' . - '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' . - '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' . - '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' . - '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' . - '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' . - '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' . - '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', - $address - ); - case 'html5': - /** - * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. - * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) - */ - return (boolean)preg_match( - '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . - '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', - $address - ); - case 'noregex': - //No PCRE! Do something _very_ approximate! - //Check the address is 3 chars or longer and contains an @ that's not the first or last char - return (strlen($address) >= 3 - and strpos($address, '@') >= 1 - and strpos($address, '@') != strlen($address) - 1); - case 'php': - default: - return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL); - } - } - - /** - * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the - * "intl" and "mbstring" PHP extensions. - * @return bool "true" if required functions for IDN support are present - */ - public function idnSupported() - { - // @TODO: Write our own "idn_to_ascii" function for PHP <= 5.2. - return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding'); - } - - /** - * Converts IDN in given email address to its ASCII form, also known as punycode, if possible. - * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet. - * This function silently returns unmodified address if: - * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form) - * - Conversion to punycode is impossible (e.g. required PHP functions are not available) - * or fails for any reason (e.g. domain has characters not allowed in an IDN) - * @see PHPMailer::$CharSet - * @param string $address The email address to convert - * @return string The encoded address in ASCII form - */ - public function punyencodeAddress($address) - { - // Verify we have required functions, CharSet, and at-sign. - if ($this->idnSupported() and - !empty($this->CharSet) and - ($pos = strrpos($address, '@')) !== false) { - $domain = substr($address, ++$pos); - // Verify CharSet string is a valid one, and domain properly encoded in this CharSet. - if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { - $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet); - if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ? - idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : - idn_to_ascii($domain)) !== false) { - return substr($address, 0, $pos) . $punycode; - } - } - } - return $address; - } - - /** - * Create a message and send it. - * Uses the sending method specified by $Mailer. - * @throws phpmailerException - * @return boolean false on error - See the ErrorInfo property for details of the error. - */ - public function send() - { - try { - if (!$this->preSend()) { - return false; - } - return $this->postSend(); - } catch (phpmailerException $exc) { - $this->mailHeader = ''; - $this->setError($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - return false; - } - } - - /** - * Prepare a message for sending. - * @throws phpmailerException - * @return boolean - */ - public function preSend() - { - try { - $this->error_count = 0; // Reset errors - $this->mailHeader = ''; - - // Dequeue recipient and Reply-To addresses with IDN - foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { - $params[1] = $this->punyencodeAddress($params[1]); - call_user_func_array(array($this, 'addAnAddress'), $params); - } - if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL); - } - - // Validate From, Sender, and ConfirmReadingTo addresses - foreach (array('From', 'Sender', 'ConfirmReadingTo') as $address_kind) { - $this->$address_kind = trim($this->$address_kind); - if (empty($this->$address_kind)) { - continue; - } - $this->$address_kind = $this->punyencodeAddress($this->$address_kind); - if (!$this->validateAddress($this->$address_kind)) { - $error_message = $this->lang('invalid_address') . ' (punyEncode) ' . $this->$address_kind; - $this->setError($error_message); - $this->edebug($error_message); - if ($this->exceptions) { - throw new phpmailerException($error_message); - } - return false; - } - } - - // Set whether the message is multipart/alternative - if ($this->alternativeExists()) { - $this->ContentType = 'multipart/alternative'; - } - - $this->setMessageType(); - // Refuse to send an empty message unless we are specifically allowing it - if (!$this->AllowEmpty and empty($this->Body)) { - throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL); - } - - // Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) - $this->MIMEHeader = ''; - $this->MIMEBody = $this->createBody(); - // createBody may have added some headers, so retain them - $tempheaders = $this->MIMEHeader; - $this->MIMEHeader = $this->createHeader(); - $this->MIMEHeader .= $tempheaders; - - // To capture the complete message when using mail(), create - // an extra header list which createHeader() doesn't fold in - if ($this->Mailer == 'mail') { - if (count($this->to) > 0) { - $this->mailHeader .= $this->addrAppend('To', $this->to); - } else { - $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); - } - $this->mailHeader .= $this->headerLine( - 'Subject', - $this->encodeHeader($this->secureHeader(trim($this->Subject))) - ); - } - - // Sign with DKIM if enabled - if (!empty($this->DKIM_domain) - && !empty($this->DKIM_selector) - && (!empty($this->DKIM_private_string) - || (!empty($this->DKIM_private) && file_exists($this->DKIM_private)) - ) - ) { - $header_dkim = $this->DKIM_Add( - $this->MIMEHeader . $this->mailHeader, - $this->encodeHeader($this->secureHeader($this->Subject)), - $this->MIMEBody - ); - $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . - str_replace("\r\n", "\n", $header_dkim) . self::CRLF; - } - return true; - } catch (phpmailerException $exc) { - $this->setError($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - return false; - } - } - - /** - * Actually send a message. - * Send the email via the selected mechanism - * @throws phpmailerException - * @return boolean - */ - public function postSend() - { - try { - // Choose the mailer and send through it - switch ($this->Mailer) { - case 'sendmail': - case 'qmail': - return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); - case 'smtp': - return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); - case 'mail': - return $this->mailSend($this->MIMEHeader, $this->MIMEBody); - default: - $sendMethod = $this->Mailer.'Send'; - if (method_exists($this, $sendMethod)) { - return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); - } - - return $this->mailSend($this->MIMEHeader, $this->MIMEBody); - } - } catch (phpmailerException $exc) { - $this->setError($exc->getMessage()); - $this->edebug($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - } - return false; - } - - /** - * Send mail using the $Sendmail program. - * @param string $header The message headers - * @param string $body The message body - * @see PHPMailer::$Sendmail - * @throws phpmailerException - * @access protected - * @return boolean - */ - protected function sendmailSend($header, $body) - { - // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (!empty($this->Sender) and self::isShellSafe($this->Sender)) { - if ($this->Mailer == 'qmail') { - $sendmailFmt = '%s -f%s'; - } else { - $sendmailFmt = '%s -oi -f%s -t'; - } - } else { - if ($this->Mailer == 'qmail') { - $sendmailFmt = '%s'; - } else { - $sendmailFmt = '%s -oi -t'; - } - } - - // TODO: If possible, this should be changed to escapeshellarg. Needs thorough testing. - $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender); - - if ($this->SingleTo) { - foreach ($this->SingleToArray as $toAddr) { - if (!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - fputs($mail, 'To: ' . $toAddr . "\n"); - fputs($mail, $header); - fputs($mail, $body); - $result = pclose($mail); - $this->doCallback( - ($result == 0), - array($toAddr), - $this->cc, - $this->bcc, - $this->Subject, - $body, - $this->From - ); - if ($result != 0) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - } - } else { - if (!@$mail = popen($sendmail, 'w')) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - fputs($mail, $header); - fputs($mail, $body); - $result = pclose($mail); - $this->doCallback( - ($result == 0), - $this->to, - $this->cc, - $this->bcc, - $this->Subject, - $body, - $this->From - ); - if ($result != 0) { - throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); - } - } - return true; - } - - /** - * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters. - * - * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows. - * @param string $string The string to be validated - * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report - * @access protected - * @return boolean - */ - protected static function isShellSafe($string) - { - // Future-proof - if (escapeshellcmd($string) !== $string - or !in_array(escapeshellarg($string), array("'$string'", "\"$string\"")) - ) { - return false; - } - - $length = strlen($string); - - for ($i = 0; $i < $length; $i++) { - $c = $string[$i]; - - // All other characters have a special meaning in at least one common shell, including = and +. - // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here. - // Note that this does permit non-Latin alphanumeric characters based on the current locale. - if (!ctype_alnum($c) && strpos('@_-.', $c) === false) { - return false; - } - } - - return true; - } - - /** - * Send mail using the PHP mail() function. - * @param string $header The message headers - * @param string $body The message body - * @link http://www.php.net/manual/en/book.mail.php - * @throws phpmailerException - * @access protected - * @return boolean - */ - protected function mailSend($header, $body) - { - $toArr = array(); - foreach ($this->to as $toaddr) { - $toArr[] = $this->addrFormat($toaddr); - } - $to = implode(', ', $toArr); - - $params = null; - //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver - if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { - // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped. - if (self::isShellSafe($this->Sender)) { - $params = sprintf('-f%s', $this->Sender); - } - } - if (!empty($this->Sender) and !ini_get('safe_mode') and $this->validateAddress($this->Sender)) { - $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); - } - $result = false; - if ($this->SingleTo and count($toArr) > 1) { - foreach ($toArr as $toAddr) { - $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); - $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); - } - } else { - $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); - $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); - } - if (isset($old_from)) { - ini_set('sendmail_from', $old_from); - } - if (!$result) { - throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL); - } - return true; - } - - /** - * Get an instance to use for SMTP operations. - * Override this function to load your own SMTP implementation - * @return SMTP - */ - public function getSMTPInstance() - { - if (!is_object($this->smtp)) { - $this->smtp = new SMTP; - } - return $this->smtp; - } - - /** - * Send mail via SMTP. - * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. - * Uses the PHPMailerSMTP class by default. - * @see PHPMailer::getSMTPInstance() to use a different class. - * @param string $header The message headers - * @param string $body The message body - * @throws phpmailerException - * @uses SMTP - * @access protected - * @return boolean - */ - protected function smtpSend($header, $body) - { - $bad_rcpt = array(); - if (!$this->smtpConnect($this->SMTPOptions)) { - throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); - } - if (!empty($this->Sender) and $this->validateAddress($this->Sender)) { - $smtp_from = $this->Sender; - } else { - $smtp_from = $this->From; - } - if (!$this->smtp->mail($smtp_from)) { - $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); - throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL); - } - - // Attempt to send to all recipients - foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { - foreach ($togroup as $to) { - if (!$this->smtp->recipient($to[0])) { - $error = $this->smtp->getError(); - $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']); - $isSent = false; - } else { - $isSent = true; - } - $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); - } - } - - // Only send the DATA command if we have viable recipients - if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { - throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL); - } - if ($this->SMTPKeepAlive) { - $this->smtp->reset(); - } else { - $this->smtp->quit(); - $this->smtp->close(); - } - //Create error message for any bad addresses - if (count($bad_rcpt) > 0) { - $errstr = ''; - foreach ($bad_rcpt as $bad) { - $errstr .= $bad['to'] . ': ' . $bad['error']; - } - throw new phpmailerException( - $this->lang('recipients_failed') . $errstr, - self::STOP_CONTINUE - ); - } - return true; - } - - /** - * Initiate a connection to an SMTP server. - * Returns false if the operation failed. - * @param array $options An array of options compatible with stream_context_create() - * @uses SMTP - * @access public - * @throws phpmailerException - * @return boolean - */ - public function smtpConnect($options = null) - { - if (is_null($this->smtp)) { - $this->smtp = $this->getSMTPInstance(); - } - - //If no options are provided, use whatever is set in the instance - if (is_null($options)) { - $options = $this->SMTPOptions; - } - - // Already connected? - if ($this->smtp->connected()) { - return true; - } - - $this->smtp->setTimeout($this->Timeout); - $this->smtp->setDebugLevel($this->SMTPDebug); - $this->smtp->setDebugOutput($this->Debugoutput); - $this->smtp->setVerp($this->do_verp); - $hosts = explode(';', $this->Host); - $lastexception = null; - - foreach ($hosts as $hostentry) { - $hostinfo = array(); - if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { - // Not a valid host entry - continue; - } - // $hostinfo[2]: optional ssl or tls prefix - // $hostinfo[3]: the hostname - // $hostinfo[4]: optional port number - // The host string prefix can temporarily override the current setting for SMTPSecure - // If it's not specified, the default value is used - $prefix = ''; - $secure = $this->SMTPSecure; - $tls = ($this->SMTPSecure == 'tls'); - if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) { - $prefix = 'ssl://'; - $tls = false; // Can't have SSL and TLS at the same time - $secure = 'ssl'; - } elseif ($hostinfo[2] == 'tls') { - $tls = true; - // tls doesn't use a prefix - $secure = 'tls'; - } - //Do we need the OpenSSL extension? - $sslext = defined('OPENSSL_ALGO_SHA1'); - if ('tls' === $secure or 'ssl' === $secure) { - //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled - if (!$sslext) { - throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); - } - } - $host = $hostinfo[3]; - $port = $this->Port; - $tport = (integer)$hostinfo[4]; - if ($tport > 0 and $tport < 65536) { - $port = $tport; - } - if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { - try { - if ($this->Helo) { - $hello = $this->Helo; - } else { - $hello = $this->serverHostname(); - } - $this->smtp->hello($hello); - //Automatically enable TLS encryption if: - // * it's not disabled - // * we have openssl extension - // * we are not already using SSL - // * the server offers STARTTLS - if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) { - $tls = true; - } - if ($tls) { - if (!$this->smtp->startTLS()) { - throw new phpmailerException($this->lang('connect_host')); - } - // We must resend EHLO after TLS negotiation - $this->smtp->hello($hello); - } - if ($this->SMTPAuth) { - if (!$this->smtp->authenticate( - $this->Username, - $this->Password, - $this->AuthType, - $this->Realm, - $this->Workstation - ) - ) { - throw new phpmailerException($this->lang('authenticate')); - } - } - return true; - } catch (phpmailerException $exc) { - $lastexception = $exc; - $this->edebug($exc->getMessage()); - // We must have connected, but then failed TLS or Auth, so close connection nicely - $this->smtp->quit(); - } - } - } - // If we get here, all connection attempts have failed, so close connection hard - $this->smtp->close(); - // As we've caught all exceptions, just report whatever the last one was - if ($this->exceptions and !is_null($lastexception)) { - throw $lastexception; - } - return false; - } - - /** - * Close the active SMTP session if one exists. - * @return void - */ - public function smtpClose() - { - if (is_a($this->smtp, 'SMTP')) { - if ($this->smtp->connected()) { - $this->smtp->quit(); - $this->smtp->close(); - } - } - } - - /** - * Set the language for error messages. - * Returns false if it cannot load the language file. - * The default language is English. - * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") - * @param string $lang_path Path to the language file directory, with trailing separator (slash) - * @return boolean - * @access public - */ - public function setLanguage($langcode = 'en', $lang_path = '') - { - // Backwards compatibility for renamed language codes - $renamed_langcodes = array( - 'br' => 'pt_br', - 'cz' => 'cs', - 'dk' => 'da', - 'no' => 'nb', - 'se' => 'sv', - ); - - if (isset($renamed_langcodes[$langcode])) { - $langcode = $renamed_langcodes[$langcode]; - } - - // Define full set of translatable strings in English - $PHPMAILER_LANG = array( - 'authenticate' => 'SMTP Error: Could not authenticate.', - 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', - 'data_not_accepted' => 'SMTP Error: data not accepted.', - 'empty_message' => 'Message body empty', - 'encoding' => 'Unknown encoding: ', - 'execute' => 'Could not execute: ', - 'file_access' => 'Could not access file: ', - 'file_open' => 'File Error: Could not open file: ', - 'from_failed' => 'The following From address failed: ', - 'instantiate' => 'Could not instantiate mail function.', - 'invalid_address' => 'Invalid address: ', - 'mailer_not_supported' => ' mailer is not supported.', - 'provide_address' => 'You must provide at least one recipient email address.', - 'recipients_failed' => 'SMTP Error: The following recipients failed: ', - 'signing' => 'Signing Error: ', - 'smtp_connect_failed' => 'SMTP connect() failed.', - 'smtp_error' => 'SMTP server error: ', - 'variable_set' => 'Cannot set or reset variable: ', - 'extension_missing' => 'Extension missing: ' - ); - if (empty($lang_path)) { - // Calculate an absolute path so it can work if CWD is not here - $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR; - } - //Validate $langcode - if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) { - $langcode = 'en'; - } - $foundlang = true; - $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; - // There is no English translation file - if ($langcode != 'en') { - // Make sure language file path is readable - if (!is_readable($lang_file)) { - $foundlang = false; - } else { - // Overwrite language-specific strings. - // This way we'll never have missing translation keys. - $foundlang = include $lang_file; - } - } - $this->language = $PHPMAILER_LANG; - return (boolean)$foundlang; // Returns false if language not found - } - - /** - * Get the array of strings for the current language. - * @return array - */ - public function getTranslations() - { - return $this->language; - } - - /** - * Create recipient headers. - * @access public - * @param string $type - * @param array $addr An array of recipient, - * where each recipient is a 2-element indexed array with element 0 containing an address - * and element 1 containing a name, like: - * array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User')) - * @return string - */ - public function addrAppend($type, $addr) - { - $addresses = array(); - foreach ($addr as $address) { - $addresses[] = $this->addrFormat($address); - } - return $type . ': ' . implode(', ', $addresses) . $this->LE; - } - - /** - * Format an address for use in a message header. - * @access public - * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name - * like array('joe@example.com', 'Joe User') - * @return string - */ - public function addrFormat($addr) - { - if (empty($addr[1])) { // No name provided - return $this->secureHeader($addr[0]); - } else { - return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( - $addr[0] - ) . '>'; - } - } - - /** - * Word-wrap message. - * For use with mailers that do not automatically perform wrapping - * and for quoted-printable encoded messages. - * Original written by philippe. - * @param string $message The message to wrap - * @param integer $length The line length to wrap to - * @param boolean $qp_mode Whether to run in Quoted-Printable mode - * @access public - * @return string - */ - public function wrapText($message, $length, $qp_mode = false) - { - if ($qp_mode) { - $soft_break = sprintf(' =%s', $this->LE); - } else { - $soft_break = $this->LE; - } - // If utf-8 encoding is used, we will need to make sure we don't - // split multibyte characters when we wrap - $is_utf8 = (strtolower($this->CharSet) == 'utf-8'); - $lelen = strlen($this->LE); - $crlflen = strlen(self::CRLF); - - $message = $this->fixEOL($message); - //Remove a trailing line break - if (substr($message, -$lelen) == $this->LE) { - $message = substr($message, 0, -$lelen); - } - - //Split message into lines - $lines = explode($this->LE, $message); - //Message will be rebuilt in here - $message = ''; - foreach ($lines as $line) { - $words = explode(' ', $line); - $buf = ''; - $firstword = true; - foreach ($words as $word) { - if ($qp_mode and (strlen($word) > $length)) { - $space_left = $length - strlen($buf) - $crlflen; - if (!$firstword) { - if ($space_left > 20) { - $len = $space_left; - if ($is_utf8) { - $len = $this->utf8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == '=') { - $len--; - } elseif (substr($word, $len - 2, 1) == '=') { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - $buf .= ' ' . $part; - $message .= $buf . sprintf('=%s', self::CRLF); - } else { - $message .= $buf . $soft_break; - } - $buf = ''; - } - while (strlen($word) > 0) { - if ($length <= 0) { - break; - } - $len = $length; - if ($is_utf8) { - $len = $this->utf8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == '=') { - $len--; - } elseif (substr($word, $len - 2, 1) == '=') { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - - if (strlen($word) > 0) { - $message .= $part . sprintf('=%s', self::CRLF); - } else { - $buf = $part; - } - } - } else { - $buf_o = $buf; - if (!$firstword) { - $buf .= ' '; - } - $buf .= $word; - - if (strlen($buf) > $length and $buf_o != '') { - $message .= $buf_o . $soft_break; - $buf = $word; - } - } - $firstword = false; - } - $message .= $buf . self::CRLF; - } - - return $message; - } - - /** - * Find the last character boundary prior to $maxLength in a utf-8 - * quoted-printable encoded string. - * Original written by Colin Brown. - * @access public - * @param string $encodedText utf-8 QP text - * @param integer $maxLength Find the last character boundary prior to this length - * @return integer - */ - public function utf8CharBoundary($encodedText, $maxLength) - { - $foundSplitPos = false; - $lookBack = 3; - while (!$foundSplitPos) { - $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); - $encodedCharPos = strpos($lastChunk, '='); - if (false !== $encodedCharPos) { - // Found start of encoded character byte within $lookBack block. - // Check the encoded byte value (the 2 chars after the '=') - $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); - $dec = hexdec($hex); - if ($dec < 128) { - // Single byte character. - // If the encoded char was found at pos 0, it will fit - // otherwise reduce maxLength to start of the encoded char - if ($encodedCharPos > 0) { - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - } - $foundSplitPos = true; - } elseif ($dec >= 192) { - // First byte of a multi byte character - // Reduce maxLength to split at start of character - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec < 192) { - // Middle byte of a multi byte character, look further back - $lookBack += 3; - } - } else { - // No encoded character found - $foundSplitPos = true; - } - } - return $maxLength; - } - - /** - * Apply word wrapping to the message body. - * Wraps the message body to the number of chars set in the WordWrap property. - * You should only do this to plain-text bodies as wrapping HTML tags may break them. - * This is called automatically by createBody(), so you don't need to call it yourself. - * @access public - * @return void - */ - public function setWordWrap() - { - if ($this->WordWrap < 1) { - return; - } - - switch ($this->message_type) { - case 'alt': - case 'alt_inline': - case 'alt_attach': - case 'alt_inline_attach': - $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap); - break; - default: - $this->Body = $this->wrapText($this->Body, $this->WordWrap); - break; - } - } - - /** - * Assemble message headers. - * @access public - * @return string The assembled headers - */ - public function createHeader() - { - $result = ''; - - if ($this->MessageDate == '') { - $this->MessageDate = self::rfcDate(); - } - $result .= $this->headerLine('Date', $this->MessageDate); - - // To be created automatically by mail() - if ($this->SingleTo) { - if ($this->Mailer != 'mail') { - foreach ($this->to as $toaddr) { - $this->SingleToArray[] = $this->addrFormat($toaddr); - } - } - } else { - if (count($this->to) > 0) { - if ($this->Mailer != 'mail') { - $result .= $this->addrAppend('To', $this->to); - } - } elseif (count($this->cc) == 0) { - $result .= $this->headerLine('To', 'undisclosed-recipients:;'); - } - } - - $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName))); - - // sendmail and mail() extract Cc from the header before sending - if (count($this->cc) > 0) { - $result .= $this->addrAppend('Cc', $this->cc); - } - - // sendmail and mail() extract Bcc from the header before sending - if (( - $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail' - ) - and count($this->bcc) > 0 - ) { - $result .= $this->addrAppend('Bcc', $this->bcc); - } - - if (count($this->ReplyTo) > 0) { - $result .= $this->addrAppend('Reply-To', $this->ReplyTo); - } - - // mail() sets the subject itself - if ($this->Mailer != 'mail') { - $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); - } - - // Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4 - // https://tools.ietf.org/html/rfc5322#section-3.6.4 - if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) { - $this->lastMessageID = $this->MessageID; - } else { - $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname()); - } - $result .= $this->headerLine('Message-ID', $this->lastMessageID); - if (!is_null($this->Priority)) { - $result .= $this->headerLine('X-Priority', $this->Priority); - } - if ($this->XMailer == '') { - $result .= $this->headerLine( - 'X-Mailer', - 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer)' - ); - } else { - $myXmailer = trim($this->XMailer); - if ($myXmailer) { - $result .= $this->headerLine('X-Mailer', $myXmailer); - } - } - - if ($this->ConfirmReadingTo != '') { - $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); - } - - // Add custom headers - foreach ($this->CustomHeader as $header) { - $result .= $this->headerLine( - trim($header[0]), - $this->encodeHeader(trim($header[1])) - ); - } - if (!$this->sign_key_file) { - $result .= $this->headerLine('MIME-Version', '1.0'); - $result .= $this->getMailMIME(); - } - - return $result; - } - - /** - * Get the message MIME type headers. - * @access public - * @return string - */ - public function getMailMIME() - { - $result = ''; - $ismultipart = true; - switch ($this->message_type) { - 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; - default: - // Catches case 'plain': and case '': - $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); - $ismultipart = false; - break; - } - // RFC1341 part 5 says 7bit is assumed if not specified - if ($this->Encoding != '7bit') { - // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE - if ($ismultipart) { - if ($this->Encoding == '8bit') { - $result .= $this->headerLine('Content-Transfer-Encoding', '8bit'); - } - // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible - } else { - $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); - } - } - - if ($this->Mailer != 'mail') { - $result .= $this->LE; - } - - return $result; - } - - /** - * Returns the whole MIME message. - * Includes complete headers and body. - * Only valid post preSend(). - * @see PHPMailer::preSend() - * @access public - * @return string - */ - public function getSentMIMEMessage() - { - return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . self::CRLF . self::CRLF . $this->MIMEBody; - } - - /** - * Create unique ID - * @return string - */ - protected function generateId() { - return md5(uniqid(time())); - } - - /** - * Assemble the message body. - * Returns an empty string on failure. - * @access public - * @throws phpmailerException - * @return string The assembled message body - */ - public function createBody() - { - $body = ''; - //Create unique IDs and preset boundaries - $this->uniqueid = $this->generateId(); - $this->boundary[1] = 'b1_' . $this->uniqueid; - $this->boundary[2] = 'b2_' . $this->uniqueid; - $this->boundary[3] = 'b3_' . $this->uniqueid; - - if ($this->sign_key_file) { - $body .= $this->getMailMIME() . $this->LE; - } - - $this->setWordWrap(); - - $bodyEncoding = $this->Encoding; - $bodyCharSet = $this->CharSet; - //Can we do a 7-bit downgrade? - if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) { - $bodyEncoding = '7bit'; - //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit - $bodyCharSet = 'us-ascii'; - } - //If lines are too long, and we're not already using an encoding that will shorten them, - //change to quoted-printable transfer encoding for the body part only - if ('base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) { - $bodyEncoding = 'quoted-printable'; - } - - $altBodyEncoding = $this->Encoding; - $altBodyCharSet = $this->CharSet; - //Can we do a 7-bit downgrade? - if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) { - $altBodyEncoding = '7bit'; - //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit - $altBodyCharSet = 'us-ascii'; - } - //If lines are too long, and we're not already using an encoding that will shorten them, - //change to quoted-printable transfer encoding for the alt body part only - if ('base64' != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) { - $altBodyEncoding = 'quoted-printable'; - } - //Use this as a preamble in all multipart message types - $mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE; - switch ($this->message_type) { - case 'inline': - $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('inline', $this->boundary[1]); - break; - case 'attach': - $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('attachment', $this->boundary[1]); - break; - case 'inline_attach': - $body .= $mimepre; - $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], $bodyCharSet, '', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $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 .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - if (!empty($this->Ical)) { - $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', ''); - $body .= $this->encodeString($this->Ical, $this->Encoding); - $body .= $this->LE . $this->LE; - } - $body .= $this->endBoundary($this->boundary[1]); - break; - case 'alt_inline': - $body .= $mimepre; - $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $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], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('inline', $this->boundary[2]); - $body .= $this->LE; - $body .= $this->endBoundary($this->boundary[1]); - break; - case 'alt_attach': - $body .= $mimepre; - $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], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->endBoundary($this->boundary[2]); - $body .= $this->LE; - $body .= $this->attachAll('attachment', $this->boundary[1]); - break; - case 'alt_inline_attach': - $body .= $mimepre; - $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], $altBodyCharSet, 'text/plain', $altBodyEncoding); - $body .= $this->encodeString($this->AltBody, $altBodyEncoding); - $body .= $this->LE . $this->LE; - $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], $bodyCharSet, 'text/html', $bodyEncoding); - $body .= $this->encodeString($this->Body, $bodyEncoding); - $body .= $this->LE . $this->LE; - $body .= $this->attachAll('inline', $this->boundary[3]); - $body .= $this->LE; - $body .= $this->endBoundary($this->boundary[2]); - $body .= $this->LE; - $body .= $this->attachAll('attachment', $this->boundary[1]); - break; - default: - // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types - //Reset the `Encoding` property in case we changed it for line length reasons - $this->Encoding = $bodyEncoding; - $body .= $this->encodeString($this->Body, $this->Encoding); - break; - } - - if ($this->isError()) { - $body = ''; - } elseif ($this->sign_key_file) { - try { - if (!defined('PKCS7_TEXT')) { - throw new phpmailerException($this->lang('extension_missing') . 'openssl'); - } - // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 - $file = tempnam(sys_get_temp_dir(), 'mail'); - if (false === file_put_contents($file, $body)) { - throw new phpmailerException($this->lang('signing') . ' Could not write temp file'); - } - $signed = tempnam(sys_get_temp_dir(), 'signed'); - //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 - if (empty($this->sign_extracerts_file)) { - $sign = @openssl_pkcs7_sign( - $file, - $signed, - 'file://' . realpath($this->sign_cert_file), - array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), - null - ); - } else { - $sign = @openssl_pkcs7_sign( - $file, - $signed, - 'file://' . realpath($this->sign_cert_file), - array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), - null, - PKCS7_DETACHED, - $this->sign_extracerts_file - ); - } - if ($sign) { - @unlink($file); - $body = file_get_contents($signed); - @unlink($signed); - //The message returned by openssl contains both headers and body, so need to split them up - $parts = explode("\n\n", $body, 2); - $this->MIMEHeader .= $parts[0] . $this->LE . $this->LE; - $body = $parts[1]; - } else { - @unlink($file); - @unlink($signed); - throw new phpmailerException($this->lang('signing') . openssl_error_string()); - } - } catch (phpmailerException $exc) { - $body = ''; - if ($this->exceptions) { - throw $exc; - } - } - } - return $body; - } - - /** - * Return the start of a message boundary. - * @access protected - * @param string $boundary - * @param string $charSet - * @param string $contentType - * @param string $encoding - * @return string - */ - protected function getBoundary($boundary, $charSet, $contentType, $encoding) - { - $result = ''; - if ($charSet == '') { - $charSet = $this->CharSet; - } - if ($contentType == '') { - $contentType = $this->ContentType; - } - if ($encoding == '') { - $encoding = $this->Encoding; - } - $result .= $this->textLine('--' . $boundary); - $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); - $result .= $this->LE; - // RFC1341 part 5 says 7bit is assumed if not specified - if ($encoding != '7bit') { - $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); - } - $result .= $this->LE; - - return $result; - } - - /** - * Return the end of a message boundary. - * @access protected - * @param string $boundary - * @return string - */ - protected function endBoundary($boundary) - { - return $this->LE . '--' . $boundary . '--' . $this->LE; - } - - /** - * Set the message type. - * PHPMailer only supports some preset message types, not arbitrary MIME structures. - * @access protected - * @return void - */ - protected function setMessageType() - { - $type = array(); - if ($this->alternativeExists()) { - $type[] = 'alt'; - } - if ($this->inlineImageExists()) { - $type[] = 'inline'; - } - if ($this->attachmentExists()) { - $type[] = 'attach'; - } - $this->message_type = implode('_', $type); - if ($this->message_type == '') { - //The 'plain' message_type refers to the message having a single body element, not that it is plain-text - $this->message_type = 'plain'; - } - } - - /** - * Format a header line. - * @access public - * @param string $name - * @param string $value - * @return string - */ - public function headerLine($name, $value) - { - return $name . ': ' . $value . $this->LE; - } - - /** - * Return a formatted mail line. - * @access public - * @param string $value - * @return string - */ - public function textLine($value) - { - return $value . $this->LE; - } - - /** - * Add an attachment from a path on the filesystem. - * Returns false if the file could not be found or read. - * @param string $path Path to the attachment. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @param string $disposition Disposition to use - * @throws phpmailerException - * @return boolean - */ - public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') - { - try { - if (!@is_file($path)) { - throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); - } - - // If a MIME type is not specified, try to work it out from the file name - if ($type == '') { - $type = self::filenameToType($path); - } - - $filename = basename($path); - if ($name == '') { - $name = $filename; - } - - $this->attachment[] = array( - 0 => $path, - 1 => $filename, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => false, // isStringAttachment - 6 => $disposition, - 7 => 0 - ); - - } catch (phpmailerException $exc) { - $this->setError($exc->getMessage()); - $this->edebug($exc->getMessage()); - if ($this->exceptions) { - throw $exc; - } - return false; - } - return true; - } - - /** - * Return the array of attachments. - * @return array - */ - public function getAttachments() - { - return $this->attachment; - } - - /** - * Attach all file, string, and binary attachments to the message. - * Returns an empty string on failure. - * @access protected - * @param string $disposition_type - * @param string $boundary - * @return string - */ - protected function attachAll($disposition_type, $boundary) - { - // Return text of body - $mime = array(); - $cidUniq = array(); - $incl = array(); - - // Add all attachments - foreach ($this->attachment as $attachment) { - // Check if it is a valid disposition_filter - if ($attachment[6] == $disposition_type) { - // Check for string attachment - $string = ''; - $path = ''; - $bString = $attachment[5]; - if ($bString) { - $string = $attachment[0]; - } else { - $path = $attachment[0]; - } - - $inclhash = md5(serialize($attachment)); - if (in_array($inclhash, $incl)) { - continue; - } - $incl[] = $inclhash; - $name = $attachment[2]; - $encoding = $attachment[3]; - $type = $attachment[4]; - $disposition = $attachment[6]; - $cid = $attachment[7]; - if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) { - continue; - } - $cidUniq[$cid] = true; - - $mime[] = sprintf('--%s%s', $boundary, $this->LE); - //Only include a filename property if we have one - if (!empty($name)) { - $mime[] = sprintf( - 'Content-Type: %s; name="%s"%s', - $type, - $this->encodeHeader($this->secureHeader($name)), - $this->LE - ); - } else { - $mime[] = sprintf( - 'Content-Type: %s%s', - $type, - $this->LE - ); - } - // RFC1341 part 5 says 7bit is assumed if not specified - if ($encoding != '7bit') { - $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE); - } - - if ($disposition == 'inline') { - $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE); - } - - // If a filename contains any of these chars, it should be quoted, - // but not otherwise: RFC2183 & RFC2045 5.1 - // Fixes a warning in IETF's msglint MIME checker - // Allow for bypassing the Content-Disposition header totally - if (!(empty($disposition))) { - $encoded_name = $this->encodeHeader($this->secureHeader($name)); - if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) { - $mime[] = sprintf( - 'Content-Disposition: %s; filename="%s"%s', - $disposition, - $encoded_name, - $this->LE . $this->LE - ); - } else { - if (!empty($encoded_name)) { - $mime[] = sprintf( - 'Content-Disposition: %s; filename=%s%s', - $disposition, - $encoded_name, - $this->LE . $this->LE - ); - } else { - $mime[] = sprintf( - 'Content-Disposition: %s%s', - $disposition, - $this->LE . $this->LE - ); - } - } - } else { - $mime[] = $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 ''; - } - $mime[] = $this->LE . $this->LE; - } - } - } - - $mime[] = sprintf('--%s--%s', $boundary, $this->LE); - - return implode('', $mime); - } - - /** - * Encode a file attachment in requested format. - * Returns an empty string on failure. - * @param string $path The full path to the file - * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' - * @throws phpmailerException - * @access protected - * @return string - */ - protected function encodeFile($path, $encoding = 'base64') - { - try { - if (!is_readable($path)) { - throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE); - } - $magic_quotes = get_magic_quotes_runtime(); - if ($magic_quotes) { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - set_magic_quotes_runtime(false); - } else { - //Doesn't exist in PHP 5.4, but we don't need to check because - //get_magic_quotes_runtime always returns false in 5.4+ - //so it will never get here - ini_set('magic_quotes_runtime', false); - } - } - $file_buffer = file_get_contents($path); - $file_buffer = $this->encodeString($file_buffer, $encoding); - if ($magic_quotes) { - if (version_compare(PHP_VERSION, '5.3.0', '<')) { - set_magic_quotes_runtime($magic_quotes); - } else { - ini_set('magic_quotes_runtime', $magic_quotes); - } - } - return $file_buffer; - } catch (Exception $exc) { - $this->setError($exc->getMessage()); - return ''; - } - } - - /** - * Encode a string in requested format. - * Returns an empty string on failure. - * @param string $str The text to encode - * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' - * @access public - * @return string - */ - public function encodeString($str, $encoding = 'base64') - { - $encoded = ''; - switch (strtolower($encoding)) { - case 'base64': - $encoded = chunk_split(base64_encode($str), 76, $this->LE); - break; - case '7bit': - case '8bit': - $encoded = $this->fixEOL($str); - // Make sure it ends with a line break - if (substr($encoded, -(strlen($this->LE))) != $this->LE) { - $encoded .= $this->LE; - } - break; - case 'binary': - $encoded = $str; - break; - case 'quoted-printable': - $encoded = $this->encodeQP($str); - break; - default: - $this->setError($this->lang('encoding') . $encoding); - break; - } - return $encoded; - } - - /** - * Encode a header string optimally. - * Picks shortest of Q, B, quoted-printable or none. - * @access public - * @param string $str - * @param string $position - * @return string - */ - public function encodeHeader($str, $position = 'text') - { - $matchcount = 0; - switch (strtolower($position)) { - case 'phrase': - if (!preg_match('/[\200-\377]/', $str)) { - // Can't use addslashes as we don't know the value of magic_quotes_sybase - $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { - return ($encoded); - } else { - return ("\"$encoded\""); - } - } - $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); - break; - /** @noinspection PhpMissingBreakStatementInspection */ - case 'comment': - $matchcount = preg_match_all('/[()"]/', $str, $matches); - // Intentional fall-through - case 'text': - default: - $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); - break; - } - - //There are no chars that need encoding - if ($matchcount == 0) { - return ($str); - } - - $maxlen = 75 - 7 - strlen($this->CharSet); - // Try to select the encoding which should produce the shortest output - if ($matchcount > strlen($str) / 3) { - // More than a third of the content will need encoding, so B encoding will be most efficient - $encoding = 'B'; - if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) { - // Use a custom function which correctly encodes and wraps long - // multibyte strings without breaking lines within a character - $encoded = $this->base64EncodeWrapMB($str, "\n"); - } else { - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); - } - } else { - $encoding = 'Q'; - $encoded = $this->encodeQ($str, $position); - $encoded = $this->wrapText($encoded, $maxlen, true); - $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded)); - } - - $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); - $encoded = trim(str_replace("\n", $this->LE, $encoded)); - - return $encoded; - } - - /** - * Check if a string contains multi-byte characters. - * @access public - * @param string $str multi-byte text to wrap encode - * @return boolean - */ - public function hasMultiBytes($str) - { - if (function_exists('mb_strlen')) { - return (strlen($str) > mb_strlen($str, $this->CharSet)); - } else { // Assume no multibytes (we can't handle without mbstring functions anyway) - return false; - } - } - - /** - * Does a string contain any 8-bit chars (in any charset)? - * @param string $text - * @return boolean - */ - public function has8bitChars($text) - { - return (boolean)preg_match('/[\x80-\xFF]/', $text); - } - - /** - * Encode and wrap long multibyte strings for mail headers - * without breaking lines within a character. - * Adapted from a function by paravoid - * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283 - * @access public - * @param string $str multi-byte text to wrap encode - * @param string $linebreak string to use as linefeed/end-of-line - * @return string - */ - public function base64EncodeWrapMB($str, $linebreak = null) - { - $start = '=?' . $this->CharSet . '?B?'; - $end = '?='; - $encoded = ''; - if ($linebreak === null) { - $linebreak = $this->LE; - } - - $mb_length = mb_strlen($str, $this->CharSet); - // Each line must have length <= 75, including $start and $end - $length = 75 - strlen($start) - strlen($end); - // Average multi-byte ratio - $ratio = $mb_length / strlen($str); - // Base64 has a 4:3 ratio - $avgLength = floor($length * $ratio * .75); - - for ($i = 0; $i < $mb_length; $i += $offset) { - $lookBack = 0; - do { - $offset = $avgLength - $lookBack; - $chunk = mb_substr($str, $i, $offset, $this->CharSet); - $chunk = base64_encode($chunk); - $lookBack++; - } while (strlen($chunk) > $length); - $encoded .= $chunk . $linebreak; - } - - // Chomp the last linefeed - $encoded = substr($encoded, 0, -strlen($linebreak)); - return $encoded; - } - - /** - * Encode a string in quoted-printable format. - * According to RFC2045 section 6.7. - * @access public - * @param string $string The text to encode - * @param integer $line_max Number of chars allowed on a line before wrapping - * @return string - * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment - */ - public function encodeQP($string, $line_max = 76) - { - // Use native function if it's available (>= PHP5.3) - if (function_exists('quoted_printable_encode')) { - return quoted_printable_encode($string); - } - // Fall back to a pure PHP implementation - $string = str_replace( - array('%20', '%0D%0A.', '%0D%0A', '%'), - array(' ', "\r\n=2E", "\r\n", '='), - rawurlencode($string) - ); - return preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string); - } - - /** - * Backward compatibility wrapper for an old QP encoding function that was removed. - * @see PHPMailer::encodeQP() - * @access public - * @param string $string - * @param integer $line_max - * @param boolean $space_conv - * @return string - * @deprecated Use encodeQP instead. - */ - public function encodeQPphp( - $string, - $line_max = 76, - /** @noinspection PhpUnusedParameterInspection */ $space_conv = false - ) { - return $this->encodeQP($string, $line_max); - } - - /** - * Encode a string using Q encoding. - * @link http://tools.ietf.org/html/rfc2047 - * @param string $str the text to encode - * @param string $position Where the text is going to be used, see the RFC for what that means - * @access public - * @return string - */ - public function encodeQ($str, $position = 'text') - { - // There should not be any EOL in the string - $pattern = ''; - $encoded = str_replace(array("\r", "\n"), '', $str); - switch (strtolower($position)) { - case 'phrase': - // RFC 2047 section 5.3 - $pattern = '^A-Za-z0-9!*+\/ -'; - break; - /** @noinspection PhpMissingBreakStatementInspection */ - case 'comment': - // RFC 2047 section 5.2 - $pattern = '\(\)"'; - // intentional fall-through - // for this reason we build the $pattern without including delimiters and [] - case 'text': - default: - // RFC 2047 section 5.1 - // Replace every high ascii, control, =, ? and _ characters - $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; - break; - } - $matches = array(); - if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { - // If the string contains an '=', make sure it's the first thing we replace - // so as to avoid double-encoding - $eqkey = array_search('=', $matches[0]); - if (false !== $eqkey) { - unset($matches[0][$eqkey]); - array_unshift($matches[0], '='); - } - foreach (array_unique($matches[0]) as $char) { - $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); - } - } - // Replace every spaces to _ (more readable than =20) - return str_replace(' ', '_', $encoded); - } - - /** - * Add a string or binary attachment (non-filesystem). - * This method can be used to attach ascii or binary data, - * such as a BLOB record from a database. - * @param string $string String attachment data. - * @param string $filename Name of the attachment. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @param string $disposition Disposition to use - * @return void - */ - public function addStringAttachment( - $string, - $filename, - $encoding = 'base64', - $type = '', - $disposition = 'attachment' - ) { - // If a MIME type is not specified, try to work it out from the file name - if ($type == '') { - $type = self::filenameToType($filename); - } - // Append to $attachment array - $this->attachment[] = array( - 0 => $string, - 1 => $filename, - 2 => basename($filename), - 3 => $encoding, - 4 => $type, - 5 => true, // isStringAttachment - 6 => $disposition, - 7 => 0 - ); - } - - /** - * Add an embedded (inline) attachment from a file. - * This can include images, sounds, and just about any other document type. - * These differ from 'regular' attachments in that they are intended to be - * displayed inline with the message, not just attached for download. - * This is used in HTML messages that embed the images - * the HTML refers to using the $cid value. - * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment; Use this to reference - * the content when using an embedded image in HTML. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File MIME type. - * @param string $disposition Disposition to use - * @return boolean True on successfully adding an attachment - */ - public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') - { - if (!@is_file($path)) { - $this->setError($this->lang('file_access') . $path); - return false; - } - - // If a MIME type is not specified, try to work it out from the file name - if ($type == '') { - $type = self::filenameToType($path); - } - - $filename = basename($path); - if ($name == '') { - $name = $filename; - } - - // Append to $attachment array - $this->attachment[] = array( - 0 => $path, - 1 => $filename, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => false, // isStringAttachment - 6 => $disposition, - 7 => $cid - ); - return true; - } - - /** - * Add an embedded stringified attachment. - * This can include images, sounds, and just about any other document type. - * Be sure to set the $type to an image type for images: - * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'. - * @param string $string The attachment binary data. - * @param string $cid Content ID of the attachment; Use this to reference - * the content when using an embedded image in HTML. - * @param string $name - * @param string $encoding File encoding (see $Encoding). - * @param string $type MIME type. - * @param string $disposition Disposition to use - * @return boolean True on successfully adding an attachment - */ - public function addStringEmbeddedImage( - $string, - $cid, - $name = '', - $encoding = 'base64', - $type = '', - $disposition = 'inline' - ) { - // If a MIME type is not specified, try to work it out from the name - if ($type == '' and !empty($name)) { - $type = self::filenameToType($name); - } - - // Append to $attachment array - $this->attachment[] = array( - 0 => $string, - 1 => $name, - 2 => $name, - 3 => $encoding, - 4 => $type, - 5 => true, // isStringAttachment - 6 => $disposition, - 7 => $cid - ); - return true; - } - - /** - * Check if an inline attachment is present. - * @access public - * @return boolean - */ - public function inlineImageExists() - { - foreach ($this->attachment as $attachment) { - if ($attachment[6] == 'inline') { - return true; - } - } - return false; - } - - /** - * Check if an attachment (non-inline) is present. - * @return boolean - */ - public function attachmentExists() - { - foreach ($this->attachment as $attachment) { - if ($attachment[6] == 'attachment') { - return true; - } - } - return false; - } - - /** - * Check if this message has an alternative body set. - * @return boolean - */ - public function alternativeExists() - { - return !empty($this->AltBody); - } - - /** - * Clear queued addresses of given kind. - * @access protected - * @param string $kind 'to', 'cc', or 'bcc' - * @return void - */ - public function clearQueuedAddresses($kind) - { - $RecipientsQueue = $this->RecipientsQueue; - foreach ($RecipientsQueue as $address => $params) { - if ($params[0] == $kind) { - unset($this->RecipientsQueue[$address]); - } - } - } - - /** - * Clear all To recipients. - * @return void - */ - public function clearAddresses() - { - foreach ($this->to as $to) { - unset($this->all_recipients[strtolower($to[0])]); - } - $this->to = array(); - $this->clearQueuedAddresses('to'); - } - - /** - * Clear all CC recipients. - * @return void - */ - public function clearCCs() - { - foreach ($this->cc as $cc) { - unset($this->all_recipients[strtolower($cc[0])]); - } - $this->cc = array(); - $this->clearQueuedAddresses('cc'); - } - - /** - * Clear all BCC recipients. - * @return void - */ - public function clearBCCs() - { - foreach ($this->bcc as $bcc) { - unset($this->all_recipients[strtolower($bcc[0])]); - } - $this->bcc = array(); - $this->clearQueuedAddresses('bcc'); - } - - /** - * Clear all ReplyTo recipients. - * @return void - */ - public function clearReplyTos() - { - $this->ReplyTo = array(); - $this->ReplyToQueue = array(); - } - - /** - * Clear all recipient types. - * @return void - */ - public function clearAllRecipients() - { - $this->to = array(); - $this->cc = array(); - $this->bcc = array(); - $this->all_recipients = array(); - $this->RecipientsQueue = array(); - } - - /** - * Clear all filesystem, string, and binary attachments. - * @return void - */ - public function clearAttachments() - { - $this->attachment = array(); - } - - /** - * Clear all custom headers. - * @return void - */ - public function clearCustomHeaders() - { - $this->CustomHeader = array(); - } - - /** - * Add an error message to the error container. - * @access protected - * @param string $msg - * @return void - */ - protected function setError($msg) - { - $this->error_count++; - if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { - $lasterror = $this->smtp->getError(); - if (!empty($lasterror['error'])) { - $msg .= $this->lang('smtp_error') . $lasterror['error']; - if (!empty($lasterror['detail'])) { - $msg .= ' Detail: '. $lasterror['detail']; - } - if (!empty($lasterror['smtp_code'])) { - $msg .= ' SMTP code: ' . $lasterror['smtp_code']; - } - if (!empty($lasterror['smtp_code_ex'])) { - $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; - } - } - } - $this->ErrorInfo = $msg; - } - - /** - * Return an RFC 822 formatted date. - * @access public - * @return string - * @static - */ - public static function rfcDate() - { - // Set the time zone to whatever the default is to avoid 500 errors - // Will default to UTC if it's not set properly in php.ini - date_default_timezone_set(@date_default_timezone_get()); - return date('D, j M Y H:i:s O'); - } - - /** - * Get the server hostname. - * Returns 'localhost.localdomain' if unknown. - * @access protected - * @return string - */ - protected function serverHostname() - { - $result = 'localhost.localdomain'; - if (!empty($this->Hostname)) { - $result = $this->Hostname; - } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) { - $result = $_SERVER['SERVER_NAME']; - } elseif (function_exists('gethostname') && gethostname() !== false) { - $result = gethostname(); - } elseif (php_uname('n') !== false) { - $result = php_uname('n'); - } - return $result; - } - - /** - * Get an error message in the current language. - * @access protected - * @param string $key - * @return string - */ - protected function lang($key) - { - if (count($this->language) < 1) { - $this->setLanguage('en'); // set the default language - } - - if (array_key_exists($key, $this->language)) { - if ($key == 'smtp_connect_failed') { - //Include a link to troubleshooting docs on SMTP connection failure - //this is by far the biggest cause of support questions - //but it's usually not PHPMailer's fault. - return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; - } - return $this->language[$key]; - } else { - //Return the key as a fallback - return $key; - } - } - - /** - * Check if an error occurred. - * @access public - * @return boolean True if an error did occur. - */ - public function isError() - { - return ($this->error_count > 0); - } - - /** - * Ensure consistent line endings in a string. - * Changes every end of line from CRLF, CR or LF to $this->LE. - * @access public - * @param string $str String to fixEOL - * @return string - */ - public function fixEOL($str) - { - // Normalise to \n - $nstr = str_replace(array("\r\n", "\r"), "\n", $str); - // Now convert LE as needed - if ($this->LE !== "\n") { - $nstr = str_replace("\n", $this->LE, $nstr); - } - return $nstr; - } - - /** - * Add a custom header. - * $name value can be overloaded to contain - * both header name and value (name:value) - * @access public - * @param string $name Custom header name - * @param string $value Header value - * @return void - */ - public function addCustomHeader($name, $value = null) - { - if ($value === null) { - // Value passed in as name:value - $this->CustomHeader[] = explode(':', $name, 2); - } else { - $this->CustomHeader[] = array($name, $value); - } - } - - /** - * Returns all custom headers. - * @return array - */ - public function getCustomHeaders() - { - return $this->CustomHeader; - } - - /** - * Create a message body from an HTML string. - * Automatically inlines images and creates a plain-text version by converting the HTML, - * overwriting any existing values in Body and AltBody. - * $basedir is used when handling relative image paths, e.g. - * will look for an image file in $basedir/images/a.png and convert it to inline. - * If you don't want to apply these transformations to your HTML, just set Body and AltBody yourself. - * @access public - * @param string $message HTML message string - * @param string $basedir base directory for relative paths to images - * @param boolean|callable $advanced Whether to use the internal HTML to text converter - * or your own custom converter @see PHPMailer::html2text() - * @return string $message The transformed message Body - */ - public function msgHTML($message, $basedir = '', $advanced = false) - { - preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images); - if (array_key_exists(2, $images)) { - foreach ($images[2] as $imgindex => $url) { - // Convert data URIs into embedded images - if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) { - $data = substr($url, strpos($url, ',')); - if ($match[2]) { - $data = base64_decode($data); - } else { - $data = rawurldecode($data); - } - $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 - if ($this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1])) { - $message = str_replace( - $images[0][$imgindex], - $images[1][$imgindex] . '="cid:' . $cid . '"', - $message - ); - } - } elseif (substr($url, 0, 4) !== 'cid:' && !preg_match('#^[a-z][a-z0-9+.-]*://#i', $url)) { - // Do not change urls for absolute images (thanks to corvuscorax) - // Do not change urls that are already inline images - $filename = basename($url); - $directory = dirname($url); - if ($directory == '.') { - $directory = ''; - } - $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 - if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { - $basedir .= '/'; - } - if (strlen($directory) > 1 && substr($directory, -1) != '/') { - $directory .= '/'; - } - if ($this->addEmbeddedImage( - $basedir . $directory . $filename, - $cid, - $filename, - 'base64', - self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION)) - ) - ) { - $message = preg_replace( - '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', - $images[1][$imgindex] . '="cid:' . $cid . '"', - $message - ); - } - } - } - } - $this->isHTML(true); - // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better - $this->Body = $this->normalizeBreaks($message); - $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced)); - if (!$this->alternativeExists()) { - $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . - self::CRLF . self::CRLF; - } - return $this->Body; - } - - /** - * Convert an HTML string into plain text. - * This is used by msgHTML(). - * Note - older versions of this function used a bundled advanced converter - * which was been removed for license reasons in #232. - * Example usage: - * - * // Use default conversion - * $plain = $mail->html2text($html); - * // Use your own custom converter - * $plain = $mail->html2text($html, function($html) { - * $converter = new MyHtml2text($html); - * return $converter->get_text(); - * }); - * - * @param string $html The HTML text to convert - * @param boolean|callable $advanced Any boolean value to use the internal converter, - * or provide your own callable for custom conversion. - * @return string - */ - public function html2text($html, $advanced = false) - { - if (is_callable($advanced)) { - return call_user_func($advanced, $html); - } - return html_entity_decode( - trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), - ENT_QUOTES, - $this->CharSet - ); - } - - /** - * Get the MIME type for a file extension. - * @param string $ext File extension - * @access public - * @return string MIME type of file. - * @static - */ - public static function _mime_types($ext = '') - { - $mimes = array( - 'xl' => 'application/excel', - 'js' => 'application/javascript', - 'hqx' => 'application/mac-binhex40', - 'cpt' => 'application/mac-compactpro', - 'bin' => 'application/macbinary', - 'doc' => 'application/msword', - 'word' => 'application/msword', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - 'class' => 'application/octet-stream', - 'dll' => 'application/octet-stream', - 'dms' => 'application/octet-stream', - 'exe' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'psd' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'so' => 'application/octet-stream', - 'oda' => 'application/oda', - 'pdf' => 'application/pdf', - 'ai' => 'application/postscript', - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'mif' => 'application/vnd.mif', - 'xls' => 'application/vnd.ms-excel', - 'ppt' => 'application/vnd.ms-powerpoint', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', - 'dvi' => 'application/x-dvi', - 'gtar' => 'application/x-gtar', - 'php3' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'php' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => 'application/x-tar', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'zip' => 'application/zip', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mpga' => 'audio/mpeg', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', - 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpeg' => 'image/jpeg', - 'jpe' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'png' => 'image/png', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'eml' => 'message/rfc822', - 'css' => 'text/css', - 'html' => 'text/html', - 'htm' => 'text/html', - 'shtml' => 'text/html', - 'log' => 'text/plain', - 'text' => 'text/plain', - 'txt' => 'text/plain', - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'vcf' => 'text/vcard', - 'vcard' => 'text/vcard', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'mpeg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mov' => 'video/quicktime', - 'qt' => 'video/quicktime', - 'rv' => 'video/vnd.rn-realvideo', - 'avi' => 'video/x-msvideo', - 'movie' => 'video/x-sgi-movie' - ); - if (array_key_exists(strtolower($ext), $mimes)) { - return $mimes[strtolower($ext)]; - } - return 'application/octet-stream'; - } - - /** - * Map a file name to a MIME type. - * Defaults to 'application/octet-stream', i.e.. arbitrary binary data. - * @param string $filename A file name or full path, does not need to exist as a file - * @return string - * @static - */ - public static function filenameToType($filename) - { - // In case the path is a URL, strip any query string before getting extension - $qpos = strpos($filename, '?'); - if (false !== $qpos) { - $filename = substr($filename, 0, $qpos); - } - $pathinfo = self::mb_pathinfo($filename); - return self::_mime_types($pathinfo['extension']); - } - - /** - * Multi-byte-safe pathinfo replacement. - * Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe. - * Works similarly to the one in PHP >= 5.2.0 - * @link http://www.php.net/manual/en/function.pathinfo.php#107461 - * @param string $path A filename or path, does not need to exist as a file - * @param integer|string $options Either a PATHINFO_* constant, - * or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2 - * @return string|array - * @static - */ - public static function mb_pathinfo($path, $options = null) - { - $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''); - $pathinfo = array(); - if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) { - if (array_key_exists(1, $pathinfo)) { - $ret['dirname'] = $pathinfo[1]; - } - if (array_key_exists(2, $pathinfo)) { - $ret['basename'] = $pathinfo[2]; - } - if (array_key_exists(5, $pathinfo)) { - $ret['extension'] = $pathinfo[5]; - } - if (array_key_exists(3, $pathinfo)) { - $ret['filename'] = $pathinfo[3]; - } - } - switch ($options) { - case PATHINFO_DIRNAME: - case 'dirname': - return $ret['dirname']; - case PATHINFO_BASENAME: - case 'basename': - return $ret['basename']; - case PATHINFO_EXTENSION: - case 'extension': - return $ret['extension']; - case PATHINFO_FILENAME: - case 'filename': - return $ret['filename']; - default: - return $ret; - } - } - - /** - * Set or reset instance properties. - * You should avoid this function - it's more verbose, less efficient, more error-prone and - * harder to debug than setting properties directly. - * Usage Example: - * `$mail->set('SMTPSecure', 'tls');` - * is the same as: - * `$mail->SMTPSecure = 'tls';` - * @access public - * @param string $name The property name to set - * @param mixed $value The value to set the property to - * @return boolean - * @TODO Should this not be using the __set() magic function? - */ - public function set($name, $value = '') - { - if (property_exists($this, $name)) { - $this->$name = $value; - return true; - } else { - $this->setError($this->lang('variable_set') . $name); - return false; - } - } - - /** - * Strip newlines to prevent header injection. - * @access public - * @param string $str - * @return string - */ - public function secureHeader($str) - { - return trim(str_replace(array("\r", "\n"), '', $str)); - } - - /** - * Normalize line breaks in a string. - * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format. - * Defaults to CRLF (for message bodies) and preserves consecutive breaks. - * @param string $text - * @param string $breaktype What kind of line break to use, defaults to CRLF - * @return string - * @access public - * @static - */ - public static function normalizeBreaks($text, $breaktype = "\r\n") - { - return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text); - } - - /** - * Set the public and private key files and password for S/MIME signing. - * @access public - * @param string $cert_filename - * @param string $key_filename - * @param string $key_pass Password for private key - * @param string $extracerts_filename Optional path to chain certificate - */ - public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '') - { - $this->sign_cert_file = $cert_filename; - $this->sign_key_file = $key_filename; - $this->sign_key_pass = $key_pass; - $this->sign_extracerts_file = $extracerts_filename; - } - - /** - * Quoted-Printable-encode a DKIM header. - * @access public - * @param string $txt - * @return string - */ - public function DKIM_QP($txt) - { - $line = ''; - for ($i = 0; $i < strlen($txt); $i++) { - $ord = ord($txt[$i]); - if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { - $line .= $txt[$i]; - } else { - $line .= '=' . sprintf('%02X', $ord); - } - } - return $line; - } - - /** - * Generate a DKIM signature. - * @access public - * @param string $signHeader - * @throws phpmailerException - * @return string The DKIM signature value - */ - public function DKIM_Sign($signHeader) - { - if (!defined('PKCS7_TEXT')) { - if ($this->exceptions) { - throw new phpmailerException($this->lang('extension_missing') . 'openssl'); - } - return ''; - } - $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private); - if ('' != $this->DKIM_passphrase) { - $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); - } else { - $privKey = openssl_pkey_get_private($privKeyStr); - } - //Workaround for missing digest algorithms in old PHP & OpenSSL versions - //@link http://stackoverflow.com/a/11117338/333340 - if (version_compare(PHP_VERSION, '5.3.0') >= 0 and - in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) { - if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) { - openssl_pkey_free($privKey); - return base64_encode($signature); - } - } else { - $pinfo = openssl_pkey_get_details($privKey); - $hash = hash('sha256', $signHeader); - //'Magic' constant for SHA256 from RFC3447 - //@link https://tools.ietf.org/html/rfc3447#page-43 - $t = '3031300d060960864801650304020105000420' . $hash; - $pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3); - $eb = pack('H*', '0001' . str_repeat('FF', $pslen) . '00' . $t); - - if (openssl_private_encrypt($eb, $signature, $privKey, OPENSSL_NO_PADDING)) { - openssl_pkey_free($privKey); - return base64_encode($signature); - } - } - openssl_pkey_free($privKey); - return ''; - } - - /** - * Generate a DKIM canonicalization header. - * @access public - * @param string $signHeader Header - * @return string - */ - public function DKIM_HeaderC($signHeader) - { - $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader); - $lines = explode("\r\n", $signHeader); - foreach ($lines as $key => $line) { - list($heading, $value) = explode(':', $line, 2); - $heading = strtolower($heading); - $value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces - $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value - } - $signHeader = implode("\r\n", $lines); - return $signHeader; - } - - /** - * Generate a DKIM canonicalization body. - * @access public - * @param string $body Message Body - * @return string - */ - 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); - // END stabilize line endings - while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { - $body = substr($body, 0, strlen($body) - 2); - } - return $body; - } - - /** - * Create the DKIM header and body in a new message header. - * @access public - * @param string $headers_line Header lines - * @param string $subject Subject - * @param string $body Body - * @return string - */ - public function DKIM_Add($headers_line, $subject, $body) - { - $DKIMsignatureType = 'rsa-sha256'; // 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($this->LE, $headers_line); - $from_header = ''; - $to_header = ''; - $date_header = ''; - $current = ''; - foreach ($headers as $header) { - if (strpos($header, 'From:') === 0) { - $from_header = $header; - $current = 'from_header'; - } elseif (strpos($header, 'To:') === 0) { - $to_header = $header; - $current = 'to_header'; - } elseif (strpos($header, 'Date:') === 0) { - $date_header = $header; - $current = 'date_header'; - } else { - if (!empty($$current) && strpos($header, ' =?') === 0) { - $$current .= $header; - } else { - $current = ''; - } - } - } - $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); - $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); - $date = str_replace('|', '=7C', $this->DKIM_QP($date_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*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body - if ('' == $this->DKIM_identity) { - $ident = ''; - } else { - $ident = ' i=' . $this->DKIM_identity . ';'; - } - $dkimhdrs = 'DKIM-Signature: v=1; a=' . - $DKIMsignatureType . '; q=' . - $DKIMquery . '; l=' . - $DKIMlen . '; s=' . - $this->DKIM_selector . - ";\r\n" . - "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . - "\th=From:To:Date:Subject;\r\n" . - "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . - "\tz=$from\r\n" . - "\t|$to\r\n" . - "\t|$date\r\n" . - "\t|$subject;\r\n" . - "\tbh=" . $DKIMb64 . ";\r\n" . - "\tb="; - $toSign = $this->DKIM_HeaderC( - $from_header . "\r\n" . - $to_header . "\r\n" . - $date_header . "\r\n" . - $subject_header . "\r\n" . - $dkimhdrs - ); - $signed = $this->DKIM_Sign($toSign); - return $dkimhdrs . $signed . "\r\n"; - } - - /** - * Detect if a string contains a line longer than the maximum line length allowed. - * @param string $str - * @return boolean - * @static - */ - public static function hasLineLongerThanMax($str) - { - //+2 to include CRLF line break for a 1000 total - return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str); - } - - /** - * Allows for public read access to 'to' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getToAddresses() - { - return $this->to; - } - - /** - * Allows for public read access to 'cc' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getCcAddresses() - { - return $this->cc; - } - - /** - * Allows for public read access to 'bcc' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getBccAddresses() - { - return $this->bcc; - } - - /** - * Allows for public read access to 'ReplyTo' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getReplyToAddresses() - { - return $this->ReplyTo; - } - - /** - * Allows for public read access to 'all_recipients' property. - * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. - * @access public - * @return array - */ - public function getAllRecipientAddresses() - { - return $this->all_recipients; - } - - /** - * Perform a callback. - * @param boolean $isSent - * @param array $to - * @param array $cc - * @param array $bcc - * @param string $subject - * @param string $body - * @param string $from - */ - protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from) - { - if (!empty($this->action_function) && is_callable($this->action_function)) { - $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from); - call_user_func_array($this->action_function, $params); - } - } -} - -/** - * PHPMailer exception handler - * @package PHPMailer - */ -class phpmailerException extends Exception -{ - /** - * Prettify error message output - * @return string - */ - public function errorMessage() - { - $errorMsg = '' . $this->getMessage() . "
      \n"; - return $errorMsg; - } -} diff --git a/site.css b/site.css deleted file mode 100644 index 05cf25f..0000000 --- a/site.css +++ /dev/null @@ -1,317 +0,0 @@ -body { -margin: 0; -padding: 0; -background: #222222; -font-family: Consolas, Arial, Helvetica, Sans-Serif; -font-size: 12px; -color: #00CD00; -} - -h1, h2, h3 { -margin: 0; -padding: 0; -font-weight: normal; -color: #00CD00; -} - -h1 { -font-size: 2em; -} - -h2 { -font-size: 1.8em; -} - -h3 { -font-size: 1.6em; -} - -p, ul, ol { -margin-top: 0; -line-height: 180%; -} - -ul, ol { -} - -a { -color: #00CDCD; -text-decoration: none; -} - -a:hover { -text-decoration: underline; -} - -#top { -margin: 0 auto; -padding: 0; -} - -/* Header */ - -#header { -background: linear-gradient(#666666,#222222); -margin: 0 auto; -padding: 0px 0px 0px 0px; -} - -/* Logo */ - -#logo { -text-align: center; -margin: 0; -padding-top: 20px; -} - -#logo h1, #logo p { -margin: 0; -padding: 0; -} - -#logo h1 { -font-size: 3.8em; -color: #EEEEEE; -text-shadow: -1px 1px #000000; -} - -#logo p { -margin: 0; -padding: 0px 0 0 2px; -font: normal 14px Georgia, "Times New Roman", Times, serif; -font-style: italic; -color: #00CD00; -} - -#logo a { -text-decoration: none; -font-family: sans-serif; -color: #EEEEEE; -} - -#logo a:hover { -text-decoration: underline; -font-family: sans-serif; -color: #EEEEEE; -} - -/* Menu */ - -#menu { -height: 90px; -margin: 0 auto; -padding: 0; -} - -#menu ul { -margin: 0; -padding: 50px 0px 0px 0px; -list-style: none; -line-height: normal; -} - -#menu li { -float: left; -} - -#menu a { -display: block; -width: 130px; -height: 30px; -margin-right: 1px; -padding: 9px 0px 0px 0px; -text-decoration: none; -text-align: center; -font-size: 13px; -font-weight: bold; -color: #00CDCD; -border: none; -} - -#menu a:hover, #menu .current_page_item a { -text-decoration: none; -} - -#menu .current_page_item a { -padding-left: 0; -} - -/* Page */ - -#page { -margin: 0 auto; -padding: 0px 0px 0px 0px; -} - -#page-bgtop { -padding: 20px 0px; -} - -/* Content */ - -#content { -padding: 0px 20px 0px 20px; -} - -@media only screen and (orientation: landscape) and (min-width: 1024px){ -#content { -float: right; -width: 74%; -padding: 0px 20px 0px 0px; -} -} - -.post { -background: #000000; -border: 2px solid #EEEEEE; -border-radius: 5px; -margin-bottom: 40px; -} - -.post .title { -height: 33px; -padding: 7px 0px 0px 30px; -background: #EEEEEE; -letter-spacing: -.5px; -color: #000000; -} - -.post .title a { -color: #000000; -border: none; -} - -.post .meta { -margin-bottom: 30px; -padding: 20px 30px 0px 30px; -text-align: left; -font-family: Consolas, Arial, Helvetica, Sans-Serif; -font-size: 13px; -font-weight: bold; -font-style: italic; -} - -.post .meta .date { -float: left; -} - -.post .meta .posted { -float: right; -} - -.post .meta a { -} - -.post .entry { -font-size: 14px; -padding: 0px 30px 20px 30px; -padding-bottom: 20px; -text-align: justify; -} - -.links { -padding-top: 20px; -font-size: 12px; -font-weight: bold; -} - -/* Sidebar */ - - -#sidebar { -margin: 0px; -padding: 0px 0px 0px 0px; -color: #00CD00; -} - -@media only screen and (orientation: landscape) and (min-width: 1024px){ -#sidebar { -float: left; -width: 22%; -margin: 0px; -padding: 0px 20px 0px 0px; -color: #00CD00; -} -} - -#sidebar ul { -margin: 0; -padding: 0; -list-style: none; -} - -#sidebar li { -margin: 0; -padding: 0; -} - -#sidebar li ul { -margin: 0px 0px; -padding-bottom: 30px; -} - -#sidebar li li { -padding-bottom: 5px; -line-height: 16px; -border-bottom: 1px solid #222222; -margin: 5px 30px 0px; -border-left: none; -} - -#sidebar li li span { -display: block; -margin-top: -20px; -padding: 0; -font-size: 11px; -font-style: italic; -} - -#sidebar h2 { -height: 38px; -padding-left: 30px; -letter-spacing: -.5px; -font-size: 1.5em; -} - -#sidebar p { -margin: 0 0px; -padding: 0px 30px 20px 30px; -text-align: justify; -} - -#sidebar a { -border: none; -color: #00CDCD; -} - -#sidebar a:hover { -text-decoration: underline; -color: #00CDCD; -} - -/* Footer */ - -#footer { -margin: 0 auto; -padding: 0px 0 15px 0; -background: linear-gradient(#222222,#000000); -font-family: Consolas, Arial, Helvetica, Sans-Serif; -} - -#footer p { -margin: 0; -padding-top: 15px; -line-height: normal; -font-size: 9px; -text-align: center; -color: #00CD00; -} - -#footer a { -color: #00CDCD; -} - -#footer a:hover { -text-decoration: underline; -color: #00CDCD; -} \ No newline at end of file diff --git a/teapot.php b/teapot.php deleted file mode 100644 index 85dc757..0000000 --- a/teapot.php +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/tos.php b/tos.php deleted file mode 100644 index 376630d..0000000 --- a/tos.php +++ /dev/null @@ -1,33 +0,0 @@ - -Terms of Service - thunix - -
      -

      Terms of Service

      -
       
      -
      -

      Nothing is without its rules and regulations; thunix is no exception. Below are the site's service terms. Everything in this page should be clear to everyone who wishes to use thunix's services; failure to abide by these terms can result in penalties such as service bans and may result in legal action against any offending users, depending on the severity of each case and any other individuals who may have been affected. Thunix may conduct investigations on any suspected violations, and we will cooperate with law enforcement agencies with their investigations. Be sure to read this page carefully and understand it.

      -

      You are responsibe for checking your local mail account from time to time. This email address is the only one we retain, and as such, any warnings and notices regarding your account, or service status will be sent to this account.

      -
        -
      1. Deliberately defacing the accounts of other users
      2. -
      3. Deliberately trying to disrupt thunix's server
      4. -
      5. Using thunix as a launch pad for disrupting other servers
      6. -
      7. Using thunix to impersonate other websites and businesses for criminal purposes
      8. -
      9. Storing/distributing pornography of any genre and medium (especially child pornography)
      10. -
      11. Storing/distributing content that defames any individual
      12. -
      13. Promoting racial, ethnic, religious, political and other forms of bigotry
      14. -
      15. Storing/distributing, promoting, or encouraging use of pirated/cracked software, license keys, license/registration circumvention programs, or any questionable programs/scripts that can risk causing unauthorized modifications, or disrupts network services for any programs or devices.
      16. -
      17. Mining cryptocurrencies
      18. -
      19. Spamming on any forums, mailing lists, irc channels, newsgroups, etc.
      20. -
      21. Leaking or publishing any user's or individual's personal information without that person's consent.
      22. -
      -

      Copyright infringement is not allowed on thunix, and we will not allow any illegal content to be distributed. It's also expected that all users respect the copyrights of those who produce original content of any kind and only share if the author or license grants you permission. Content hosted on accounts used for external file storage must also follow copyright law.

      -

      If you want to request for content you own the copyright for to be removed from thunix, please refer to our abuse reporting page. In the email, please identify who you are, if you are the copyright holder or legally representing them, the exact files you want removed with links to the files and infringed content, and contact information such as phone numbers or a reply-to email address.

      -

      Users that repeatedly violate the Terms of Service will have their account removed. Depending on the degree of the offense, their account may be removed immediately. These terms also apply to communication services such as forums, mailing lists, irc channels, newsgroups, and any other service either hosted on or used for thunix. If you come across anything that violates the terms of service, please let us know with the abuse reporting page.

      -
      -

      Last Updated: March 28, 2019

      -
      -
      -
       
      -
  • - - diff --git a/users.php b/users.php deleted file mode 100644 index b09e6b7..0000000 --- a/users.php +++ /dev/null @@ -1,26 +0,0 @@ - -User Web Directories - thunix - -
    -

    User Web Directories

    -
     
    -
    -

    Below is a list of user web directories:

    -
    -

    Note that most content on thunix are provided by thunix's users, not the owner of the server. Comments should be addressed to the owner of the web directory in the first instance - their email address here is <username>@thunix.net, unless otherwise specified within their web directory.

    -

    If there is a problem which is not resolved by the owner of the web directory, please send us an abuse report.

    -

    If you want to be added to this list, simply create an index.html or index.php file and upload it to your public_html directory. If you want to be removed from the list, simply remove your index file from your public_html directory.

    -
    -
    -
     
    - - - diff --git a/wiki.php b/wiki.php new file mode 100644 index 0000000..14f3fe6 --- /dev/null +++ b/wiki.php @@ -0,0 +1,87 @@ +setMarkupEscaped(true); +$ParsedownExtra = new ParsedownExtra(); + +if ( $page == "") { + $page = "main"; + } + +if ( $style == "") { + if ( $site_style == "") { + $site_style="site"; + } +} +else { + $site_style=$style; +} + +$header = file_get_contents("$doc_root/includes/header.md"); +$sidebar = file_get_contents("$doc_root/includes/sidebar.md"); +$content = file_get_contents("$doc_root/articles/$page.md"); +$footer = file_get_contents("$doc_root/includes/footer.md"); + +print " + + + $site_name - $page + + + + + + + +"; + +print "
    +
    + + + + + + +
    "; + +echo $ParsedownExtra->text($content); + +print "
    + + +
    + + + + + + +"; +?> diff --git a/www-hook.php b/www-hook.php deleted file mode 100644 index 090d0ac..0000000 --- a/www-hook.php +++ /dev/null @@ -1,46 +0,0 @@ - $ratelimit ) { - touch ( $www_dropfile ); - touch ( $www_lastrun ); - echo "HTTP 200 - WWW webhook recieved."; - die(); - } - else { - http_response_code(429); - echo "HTTP 429 - Rate Limited."; - die(); - } - die(); - -?>