00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 class t3lib_htmlmail {
00184
00185 var $recipient = '';
00186 var $recipient_copy = '';
00187 var $subject = '';
00188 var $from_email = '';
00189 var $from_name = '';
00190 var $replyto_email = '';
00191 var $replyto_name = '';
00192 var $organisation = '';
00193 var $priority = 3;
00194 var $mailer = '';
00195 var $alt_base64 = 0;
00196 var $alt_8bit = 0;
00197 var $jumperURL_prefix = '';
00198 var $jumperURL_useId = 0;
00199 var $mediaList = '';
00200 var $http_password = '';
00201 var $http_username = '';
00202 var $postfix_version1 = false;
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 var $theParts = array();
00221
00222 var $messageid = '';
00223 var $returnPath = '';
00224 var $Xid = '';
00225 var $dontEncodeHeader = false;
00226
00227 var $headers = '';
00228 var $message = '';
00229 var $part = 0;
00230 var $image_fullpath_list = '';
00231 var $href_fullpath_list = '';
00232
00233 var $plain_text_header = '';
00234 var $html_text_header = '';
00235 var $charset = '';
00236 var $defaultCharset = 'iso-8859-1';
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 public function t3lib_htmlmail() {
00248 $this->forceReturnPath = $GLOBALS['TYPO3_CONF_VARS']['SYS']['forceReturnPath'];
00249
00250 $this->mailer = 'TYPO3 '.TYPO3_version;
00251 }
00252
00253
00254
00255
00256
00257
00258
00259 public function start() {
00260 global $TYPO3_CONF_VARS;
00261
00262
00263 $host = t3lib_div::getHostname();
00264 if (!$host || $host == '127.0.0.1' || $host == 'localhost' || $host == 'localhost.localdomain') {
00265 $host = ($TYPO3_CONF_VARS['SYS']['sitename'] ? preg_replace('/[^A-Za-z0-9_\-]/', '_', $TYPO3_CONF_VARS['SYS']['sitename']) : 'localhost') . '.TYPO3';
00266 }
00267 $this->messageid = md5(microtime()) . '@' . $host;
00268
00269
00270
00271 $this->linebreak = chr(10);
00272
00273
00274 if (TYPO3_OS == 'WIN') {
00275 $this->linebreak = chr(13).chr(10);
00276 }
00277
00278
00279 if (!$this->charset) {
00280 if (is_object($GLOBALS['TSFE']) && $GLOBALS['TSFE']->renderCharset) {
00281 $this->charset = $GLOBALS['TSFE']->renderCharset;
00282 } elseif (is_object($GLOBALS['LANG']) && $GLOBALS['LANG']->charSet) {
00283 $this->charset = $GLOBALS['LANG']->charSet;
00284 } elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) {
00285 $this->charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'];
00286 } else {
00287 $this->charset = $this->defaultCharset;
00288 }
00289 }
00290
00291
00292 $this->useQuotedPrintable();
00293 }
00294
00295
00296
00297
00298
00299
00300
00301 public function useQuotedPrintable() {
00302 $this->plain_text_header = 'Content-Type: text/plain; charset='.$this->charset.$this->linebreak.'Content-Transfer-Encoding: quoted-printable';
00303 $this->html_text_header = 'Content-Type: text/html; charset='.$this->charset.$this->linebreak.'Content-Transfer-Encoding: quoted-printable';
00304 }
00305
00306
00307
00308
00309
00310
00311 public function useBase64() {
00312 $this->plain_text_header = 'Content-Type: text/plain; charset='.$this->charset.$this->linebreak.'Content-Transfer-Encoding: base64';
00313 $this->html_text_header = 'Content-Type: text/html; charset='.$this->charset.$this->linebreak.'Content-Transfer-Encoding: base64';
00314 $this->alt_base64 = 1;
00315 }
00316
00317
00318
00319
00320
00321
00322
00323 public function use8Bit() {
00324 $this->plain_text_header = 'Content-Type: text/plain; charset='.$this->charset.$this->linebreak.'Content-Transfer-Encoding: 8bit';
00325 $this->html_text_header = 'Content-Type: text/html; charset='.$this->charset.$this->linebreak.'Content-Transfer-Encoding: 8bit';
00326 $this->alt_8bit = 1;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 public function encodeMsg($content) {
00338 if ($this->alt_base64) {
00339 return $this->makeBase64($content);
00340 } elseif ($this->alt_8bit) {
00341 return $content;
00342 } else {
00343 return t3lib_div::quoted_printable($content);
00344 }
00345 }
00346
00347
00348
00349
00350
00351
00352
00353
00354 public function addPlain($content) {
00355 $content = $this->substHTTPurlsInPlainText($content);
00356 $this->setPlain($this->encodeMsg($content));
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366 public function addAttachment($file) {
00367
00368 $fileInfo = $this->getExtendedURL($file);
00369 if ($fileInfo) {
00370 if (!$fileInfo['content_type']) {
00371 $fileInfo['content_type'] = 'application/octet-stream';
00372 }
00373 $temp = $this->split_fileref($file);
00374 if ($temp['file']) {
00375 $fileInfo['filename'] = $temp['file'];
00376 } elseif (strpos(' '.$fileInfo['content_type'], 'htm')) {
00377 $fileInfo['filename'] = 'index.html';
00378 } else {
00379 $fileInfo['filename'] = 'unknown';
00380 }
00381 $this->theParts['attach'][] = $fileInfo;
00382 return true;
00383 }
00384 return false;
00385 }
00386
00387
00388
00389
00390
00391
00392
00393
00394 public function addHTML($file) {
00395 $status = $this->fetchHTML($file);
00396 if (!$status) {
00397 return false;
00398 }
00399 if ($this->extractFramesInfo()) {
00400 return 'Document was a frameset. Stopped';
00401 }
00402 $this->extractMediaLinks();
00403 $this->extractHyperLinks();
00404 $this->fetchHTMLMedia();
00405 $this->substMediaNamesInHTML(0);
00406 $this->substHREFsInHTML();
00407 $this->setHtml($this->encodeMsg($this->theParts['html']['content']));
00408 }
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418 public function extractHtmlInit($html,$url) {
00419 $this->theParts['html']['content'] = $html;
00420 $this->theParts['html']['path'] = $url;
00421 }
00422
00423
00424
00425
00426
00427
00428
00429
00430 public function send($recipient) {
00431 if ($recipient) {
00432 $this->recipient = $recipient;
00433 }
00434 $this->setHeaders();
00435 $this->setContent();
00436 $mailWasSent = $this->sendTheMail();
00437 return $mailWasSent;
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463 public function setHeaders() {
00464 $this->headers = '';
00465
00466 $this->add_header('Message-ID: <'.$this->messageid.'>');
00467
00468 if ($this->returnPath) {
00469 $this->add_header('Return-Path: '.$this->returnPath);
00470 $this->add_header('Errors-To: '.$this->returnPath);
00471 }
00472
00473 if ($this->Xid) {
00474 $this->add_header('X-Typo3MID: '.$this->Xid);
00475 }
00476
00477
00478 if ($this->from_email) {
00479 if ($this->from_name && !t3lib_div::isBrokenEmailEnvironment()) {
00480 $this->add_header('From: '.$this->from_name.' <'.$this->from_email.'>');
00481 } else {
00482 $this->add_header('From: '.$this->from_email);
00483 }
00484 }
00485
00486 if ($this->replyto_email) {
00487 if ($this->replyto_name) {
00488 $this->add_header('Reply-To: '.$this->replyto_name.' <'.$this->replyto_email.'>');
00489 } else {
00490 $this->add_header('Reply-To: '.$this->replyto_email);
00491 }
00492 }
00493
00494 if ($this->organisation) {
00495 $this->add_header('Organisation: '.$this->organisation);
00496 }
00497
00498 if ($this->mailer) {
00499 $this->add_header('X-Mailer: '.$this->mailer);
00500 }
00501
00502 if ($this->priority) {
00503 $this->add_header('X-Priority: '.$this->priority);
00504 }
00505 $this->add_header('Mime-Version: 1.0');
00506
00507 if (!$this->dontEncodeHeader) {
00508 $enc = $this->alt_base64 ? 'base64' : 'quoted_printable';
00509
00510 $this->recipient = t3lib_div::encodeHeader($this->recipient,$enc,$this->charset);
00511 $this->subject = t3lib_div::encodeHeader($this->subject,$enc,$this->charset);
00512 }
00513 }
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523 public function setRecipient($recipient) {
00524 $this->recipient = (is_array($recipient) ? implode(',', $recipient) : $recipient);
00525 }
00526
00527
00528
00529
00530
00531
00532
00533 public function getHTMLContentType() {
00534 return (count($this->theParts['html']['media']) ? 'multipart/related' : 'multipart/alternative');
00535 }
00536
00537
00538
00539
00540
00541
00542
00543 public function setContent() {
00544 $this->message = '';
00545 $boundary = $this->getBoundary();
00546
00547
00548 if (count($this->theParts['attach'])) {
00549
00550 $this->add_header('Content-Type: multipart/mixed;');
00551 $this->add_header(' boundary="' . $boundary . '"');
00552 $this->add_message('This is a multi-part message in MIME format.' . "\n");
00553 $this->constructMixed($boundary);
00554 } elseif ($this->theParts['html']['content']) {
00555
00556 $this->add_header('Content-Type: ' . $this->getHTMLContentType() . ';');
00557 $this->add_header(' boundary="' . $boundary . '"');
00558 $this->add_message('This is a multi-part message in MIME format.' . "\n");
00559 $this->constructHTML($boundary);
00560 } else {
00561
00562 $this->add_header($this->plain_text_header);
00563 $this->add_message($this->getContent('plain'));
00564 }
00565 }
00566
00567
00568
00569
00570
00571
00572
00573
00574 public function constructMixed($boundary) {
00575 $this->add_message('--' . $boundary);
00576
00577 if ($this->theParts['html']['content']) {
00578
00579 $newBoundary = $this->getBoundary();
00580 $this->add_message('Content-Type: '.$this->getHTMLContentType() . ';');
00581 $this->add_message(' boundary="' . $newBoundary . '"');
00582 $this->add_message('');
00583 $this->constructHTML($newBoundary);
00584 } else {
00585
00586 $this->add_message($this->plain_text_header);
00587 $this->add_message('');
00588 $this->add_message($this->getContent('plain'));
00589 }
00590
00591 if (is_array($this->theParts['attach'])) {
00592 foreach ($this->theParts['attach'] as $media) {
00593 $this->add_message('--' . $boundary);
00594 $this->add_message('Content-Type: ' . $media['content_type'] . ';');
00595 $this->add_message(' name="' . $media['filename'] . '"');
00596 $this->add_message('Content-Transfer-Encoding: base64');
00597 $this->add_message('Content-Disposition: attachment;');
00598 $this->add_message(' filename="' . $media['filename'] . '"');
00599 $this->add_message('');
00600 $this->add_message($this->makeBase64($media['content']));
00601 }
00602 }
00603 $this->add_message('--' . $boundary . '--' . "\n");
00604 }
00605
00606
00607
00608
00609
00610
00611
00612
00613 public function constructHTML($boundary) {
00614
00615 if (count($this->theParts['html']['media'])) {
00616 $this->add_message('--' . $boundary);
00617
00618 $newBoundary = $this->getBoundary();
00619 $this->add_message('Content-Type: multipart/alternative;');
00620 $this->add_message(' boundary="' . $newBoundary . '"');
00621 $this->add_message('Content-Transfer-Encoding: 7bit');
00622 $this->add_message('');
00623
00624
00625 $this->constructAlternative($newBoundary);
00626 $this->constructHTML_media($boundary);
00627 } else {
00628
00629 $this->constructAlternative($boundary);
00630 }
00631 }
00632
00633
00634
00635
00636
00637
00638
00639
00640 public function constructAlternative($boundary) {
00641 $this->add_message('--'.$boundary);
00642
00643
00644 $this->add_message($this->plain_text_header);
00645 $this->add_message('');
00646 $this->add_message($this->getContent('plain'));
00647 $this->add_message('--' . $boundary);
00648
00649
00650 $this->add_message($this->html_text_header);
00651 $this->add_message('');
00652 $this->add_message($this->getContent('html'));
00653 $this->add_message('--' . $boundary . '--' . "\n");
00654 }
00655
00656
00657
00658
00659
00660
00661
00662
00663 public function constructHTML_media($boundary) {
00664
00665 if (is_array($this->theParts['html']['media'])) {
00666 foreach($this->theParts['html']['media'] as $key => $media) {
00667 if (!$this->mediaList || t3lib_div::inList($this->mediaList, $key)) {
00668 $this->add_message('--' . $boundary);
00669 $this->add_message('Content-Type: ' . $media['ctype']);
00670 $this->add_message('Content-ID: <part' . $key . '.' . $this->messageid . '>');
00671 $this->add_message('Content-Transfer-Encoding: base64');
00672 $this->add_message('');
00673 $this->add_message($this->makeBase64($media['content']));
00674 }
00675 }
00676 }
00677 $this->add_message('--' . $boundary . '--' . "\n");
00678 }
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706 public function sendTheMail() {
00707 $mailWasSent = false;
00708
00709
00710 if (!trim($this->recipient) || !trim($this->message)) {
00711 return false;
00712 }
00713
00714
00715
00716 $returnPath = (strlen($this->returnPath) > 0) ? '-f ' . escapeshellarg($this->returnPath) : '';
00717 if($this->returnPath) {
00718 @ini_set('sendmail_from', t3lib_div::normalizeMailAddress($this->returnPath));
00719 }
00720 $recipient = t3lib_div::normalizeMailAddress($this->recipient);
00721 $recipient_copy = t3lib_div::normalizeMailAddress($this->recipient_copy);
00722
00723
00724 $returnPathPossible = (!ini_get('safe_mode') && $this->forceReturnPath);
00725 if ($returnPathPossible) {
00726 $mailWasSent = mail($recipient,
00727 $this->subject,
00728 $this->message,
00729 $this->headers,
00730 $returnPath);
00731 } else {
00732 $mailWasSent = mail($recipient,
00733 $this->subject,
00734 $this->message,
00735 $this->headers);
00736 }
00737
00738
00739 if ($recipient_copy) {
00740 if ($returnPathPossible) {
00741 $mailWasSent = mail($recipient_copy,
00742 $this->subject,
00743 $this->message,
00744 $this->headers,
00745 $returnPath);
00746 } else {
00747 $mailWasSent = mail($recipient_copy,
00748 $this->subject,
00749 $this->message,
00750 $this->headers);
00751 }
00752 }
00753
00754 if ($this->auto_respond_msg) {
00755 $theParts = explode('/',$this->auto_respond_msg,2);
00756 $theParts[1] = str_replace("/",chr(10),$theParts[1]);
00757 if ($returnPathPossible) {
00758 $mailWasSent = mail($this->from_email,
00759 $theParts[0],
00760 $theParts[1],
00761 'From: ' . $recipient,
00762 $returnPath);
00763 } else {
00764 $mailWasSent = mail($this->from_email,
00765 $theParts[0],
00766 $theParts[1],
00767 'From: ' . $recipient);
00768 }
00769 }
00770 if ($this->returnPath) {
00771 ini_restore('sendmail_from');
00772 }
00773 return $mailWasSent;
00774 }
00775
00776
00777
00778
00779
00780
00781
00782 public function getBoundary() {
00783 $this->part++;
00784 return "----------".uniqid("part_".$this->part."_");
00785 }
00786
00787
00788
00789
00790
00791
00792
00793
00794 public function setPlain($content) {
00795 $this->theParts['plain']['content'] = $content;
00796 }
00797
00798
00799
00800
00801
00802
00803
00804
00805 public function setHtml($content) {
00806 $this->theParts['html']['content'] = $content;
00807 }
00808
00809
00810
00811
00812
00813
00814
00815
00816 public function add_header($header) {
00817
00818 if (!$this->dontEncodeHeader && !stristr($header,'Content-Type') && !stristr($header,'Content-Transfer-Encoding')) {
00819
00820 $parts = explode(': ',$header,2);
00821 if (count($parts) == 2) {
00822 $enc = $this->alt_base64 ? 'base64' : 'quoted_printable';
00823 $parts[1] = t3lib_div::encodeHeader($parts[1], $enc, $this->charset);
00824 $header = implode(': ', $parts);
00825 }
00826 }
00827
00828 $this->headers .= $header."\n";
00829 }
00830
00831
00832
00833
00834
00835
00836
00837
00838 public function add_message($msg) {
00839 $this->message .= $msg."\n";
00840 }
00841
00842
00843
00844
00845
00846
00847
00848
00849 public function getContent($type) {
00850 return $this->theParts[$type]['content'];
00851 }
00852
00853
00854
00855
00856
00857
00858
00859 public function preview() {
00860 echo nl2br(htmlspecialchars($this->headers));
00861 echo "<BR>";
00862 echo nl2br(htmlspecialchars($this->message));
00863 }
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884 public function fetchHTML($file) {
00885
00886 $this->theParts['html']['content'] = $this->getURL($file);
00887 if ($this->theParts['html']['content']) {
00888 $addr = $this->extParseUrl($file);
00889 $path = ($addr['scheme']) ? $addr['scheme'].':
00890 $this->theParts['html']['path'] = $path;
00891 return true;
00892 } else {
00893 return false;
00894 }
00895 }
00896
00897
00898
00899
00900
00901
00902
00903 public function fetchHTMLMedia() {
00904 if (!is_array($this->theParts['html']['media']) || !count($this->theParts['html']['media'])) return;
00905 foreach ($this->theParts['html']['media'] as $key => $media) {
00906
00907 $picdata = $this->getExtendedURL($this->theParts['html']['media'][$key]['absRef']);
00908 if (is_array($picdata)) {
00909 $this->theParts['html']['media'][$key]['content'] = $picdata['content'];
00910 $this->theParts['html']['media'][$key]['ctype'] = $picdata['content_type'];
00911 }
00912 }
00913 }
00914
00915
00916
00917
00918
00919
00920
00921 public function extractMediaLinks() {
00922 $html_code = $this->theParts['html']['content'];
00923 $attribRegex = $this->tag_regex(array('img','table','td','tr','body','iframe','script','input','embed'));
00924
00925
00926 $codepieces = split($attribRegex, $html_code);
00927 $len = strlen($codepieces[0]);
00928 $pieces = count($codepieces);
00929 $reg = array();
00930 for ($i = 1; $i < $pieces; $i++) {
00931 $tag = strtolower(strtok(substr($html_code,$len+1,10),' '));
00932 $len += strlen($tag)+strlen($codepieces[$i])+2;
00933 $dummy = eregi("[^>]*", $codepieces[$i], $reg);
00934 $attributes = $this->get_tag_attributes($reg[0]);
00935 $imageData = array();
00936
00937
00938 $imageData['ref'] = ($attributes['src'] ? $attributes['src'] : $attributes['background']);
00939 if ($imageData['ref']) {
00940
00941 $imageData['quotes'] = (substr($codepieces[$i], strpos($codepieces[$i], $imageData['ref'])-1,1) == '"') ? '"' : '';
00942
00943 $imageData['subst_str'] = $imageData['quotes'].$imageData['ref'].$imageData['quotes'];
00944 if ($imageData['ref'] && !strstr($this->image_fullpath_list,"|".$imageData["subst_str"]."|")) {
00945 $this->image_fullpath_list .= "|".$imageData['subst_str']."|";
00946 $imageData['absRef'] = $this->absRef($imageData['ref']);
00947 $imageData['tag'] = $tag;
00948 $imageData['use_jumpurl'] = $attributes['dmailerping']?1:0;
00949 $this->theParts['html']['media'][] = $imageData;
00950 }
00951 }
00952 }
00953
00954
00955 $attribRegex = $this->tag_regex(array('link'));
00956
00957 $codepieces = split($attribRegex, $html_code);
00958 $pieces = count($codepieces);
00959 for ($i = 1; $i < $pieces; $i++) {
00960 $dummy = eregi("[^>]*", $codepieces[$i], $reg);
00961
00962 $attributes = $this->get_tag_attributes($reg[0]);
00963 $imageData = array();
00964 if (strtolower($attributes['rel']) == 'stylesheet' && $attributes['href']) {
00965
00966 $imageData['ref'] = $attributes['href'];
00967
00968 $imageData['quotes'] = (substr($codepieces[$i],strpos($codepieces[$i], $imageData['ref'])-1,1) == '"') ? '"' : '';
00969
00970 $imageData['subst_str'] = $imageData['quotes'].$imageData['ref'].$imageData['quotes'];
00971 if ($imageData['ref'] && !strstr($this->image_fullpath_list,"|".$imageData["subst_str"]."|")) {
00972 $this->image_fullpath_list .= "|".$imageData["subst_str"]."|";
00973 $imageData['absRef'] = $this->absRef($imageData["ref"]);
00974 $this->theParts['html']['media'][] = $imageData;
00975 }
00976 }
00977 }
00978
00979
00980 $codepieces = split(quotemeta(".src"), $html_code);
00981 $pieces = count($codepieces);
00982 $expr = "^[^".quotemeta("\"").quotemeta("'")."]*";
00983 for($i = 1; $i < $pieces; $i++) {
00984 $temp = $codepieces[$i];
00985 $temp = trim(ereg_replace("=","",trim($temp)));
00986 ereg($expr,substr($temp,1,strlen($temp)),$reg);
00987 $imageData['ref'] = $reg[0];
00988 $imageData['quotes'] = substr($temp,0,1);
00989
00990 $imageData['subst_str'] = $imageData['quotes'].$imageData['ref'].$imageData['quotes'];
00991 $theInfo = $this->split_fileref($imageData['ref']);
00992
00993 switch ($theInfo['fileext']) {
00994 case 'gif':
00995 case 'jpeg':
00996 case 'jpg':
00997 if ($imageData['ref'] && !strstr($this->image_fullpath_list,"|".$imageData["subst_str"]."|")) {
00998 $this->image_fullpath_list .= "|".$imageData['subst_str']."|";
00999 $imageData['absRef'] = $this->absRef($imageData['ref']);
01000 $this->theParts['html']['media'][] = $imageData;
01001 }
01002 break;
01003 }
01004 }
01005 }
01006
01007
01008
01009
01010
01011
01012
01013 public function extractHyperLinks() {
01014 $html_code = $this->theParts['html']['content'];
01015 $attribRegex = $this->tag_regex(array('a','form','area'));
01016 $codepieces = split($attribRegex, $html_code);
01017 $len = strlen($codepieces[0]);
01018 $pieces = count($codepieces);
01019 for($i = 1; $i < $pieces; $i++) {
01020 $tag = strtolower(strtok(substr($html_code,$len+1,10)," "));
01021 $len += strlen($tag) + strlen($codepieces[$i]) + 2;
01022
01023 $dummy = eregi("[^>]*", $codepieces[$i], $reg);
01024
01025 $attributes = $this->get_tag_attributes($reg[0]);
01026 $hrefData = array();
01027 $hrefData['ref'] = ($attributes['href'] ? $attributes['href'] : $hrefData['ref'] = $attributes['action']);
01028 if ($hrefData['ref']) {
01029
01030 $hrefData['quotes'] = (substr($codepieces[$i],strpos($codepieces[$i], $hrefData["ref"])-1,1) == '"') ? '"' : '';
01031
01032 $hrefData['subst_str'] = $hrefData['quotes'].$hrefData['ref'].$hrefData['quotes'];
01033 if ($hrefData['ref'] && substr(trim($hrefData['ref']),0,1) != "#" && !strstr($this->href_fullpath_list,"|".$hrefData['subst_str']."|")) {
01034 $this->href_fullpath_list .= "|".$hrefData['subst_str']."|";
01035 $hrefData['absRef'] = $this->absRef($hrefData['ref']);
01036 $hrefData['tag'] = $tag;
01037 $this->theParts['html']['hrefs'][] = $hrefData;
01038 }
01039 }
01040 }
01041
01042 $codepieces = explode("onClick=\"openPic('", $html_code);
01043 $pieces = count($codepieces);
01044 for($i = 1; $i < $pieces; $i++) {
01045 $showpic_linkArr = explode("'",$codepieces[$i]);
01046 $hrefData['ref'] = $showpic_linkArr[0];
01047 if ($hrefData['ref']) {
01048 $hrefData['quotes'] = "'";
01049
01050 $hrefData['subst_str'] = $hrefData['quotes'].$hrefData['ref'].$hrefData['quotes'];
01051 if ($hrefData['ref'] && !strstr($this->href_fullpath_list,"|".$hrefData['subst_str']."|")) {
01052 $this->href_fullpath_list .= "|".$hrefData['subst_str']."|";
01053 $hrefData['absRef'] = $this->absRef($hrefData['ref']);
01054 $this->theParts['html']['hrefs'][] = $hrefData;
01055 }
01056 }
01057 }
01058 }
01059
01060
01061
01062
01063
01064
01065
0