Skip to content
Browse files

Initial commit

  • Loading branch information...
0 parents commit 494fabcd729ed072b8fc21a7bfbc28cdff1e3174 @farcaller committed Jan 16, 2011
Showing with 13,265 additions and 0 deletions.
  1. +227 −0 autodownload.php
  2. +329 −0 checkemail.php
  3. +213 −0 classes/Command.class.php
  4. +105 −0 classes/MyCurl.class.php
  5. +504 −0 classes/PHPMailer/LICENSE
  6. +218 −0 classes/PHPMailer/README
  7. +2,089 −0 classes/PHPMailer/class.phpmailer.php
  8. +407 −0 classes/PHPMailer/class.pop3.php
  9. +814 −0 classes/PHPMailer/class.smtp.php
  10. +23 −0 classes/PHPMailer/docs/Note_for_SMTP_debugging.txt
  11. +148 −0 classes/PHPMailer/docs/extending.html
  12. +67 −0 classes/PHPMailer/docs/faq.html
  13. +39 −0 classes/PHPMailer/docs/pop3_article.txt
  14. +45 −0 classes/PHPMailer/docs/use_gmail.txt
  15. +27 −0 classes/PHPMailer/language/phpmailer.lang-ar.php
  16. +26 −0 classes/PHPMailer/language/phpmailer.lang-br.php
  17. +26 −0 classes/PHPMailer/language/phpmailer.lang-ca.php
  18. +26 −0 classes/PHPMailer/language/phpmailer.lang-ch.php
  19. +25 −0 classes/PHPMailer/language/phpmailer.lang-cz.php
  20. +25 −0 classes/PHPMailer/language/phpmailer.lang-de.php
  21. +26 −0 classes/PHPMailer/language/phpmailer.lang-dk.php
  22. +26 −0 classes/PHPMailer/language/phpmailer.lang-es.php
  23. +26 −0 classes/PHPMailer/language/phpmailer.lang-et.php
  24. +27 −0 classes/PHPMailer/language/phpmailer.lang-fi.php
  25. +27 −0 classes/PHPMailer/language/phpmailer.lang-fo.php
  26. +25 −0 classes/PHPMailer/language/phpmailer.lang-fr.php
  27. +25 −0 classes/PHPMailer/language/phpmailer.lang-hu.php
  28. +27 −0 classes/PHPMailer/language/phpmailer.lang-it.php
  29. +26 −0 classes/PHPMailer/language/phpmailer.lang-ja.php
  30. +25 −0 classes/PHPMailer/language/phpmailer.lang-nl.php
  31. +25 −0 classes/PHPMailer/language/phpmailer.lang-no.php
  32. +25 −0 classes/PHPMailer/language/phpmailer.lang-pl.php
  33. +27 −0 classes/PHPMailer/language/phpmailer.lang-ro.php
  34. +25 −0 classes/PHPMailer/language/phpmailer.lang-ru.php
  35. +26 −0 classes/PHPMailer/language/phpmailer.lang-se.php
  36. +27 −0 classes/PHPMailer/language/phpmailer.lang-tr.php
  37. +26 −0 classes/PHPMailer/language/phpmailer.lang-zh.php
  38. +26 −0 classes/PHPMailer/language/phpmailer.lang-zh_cn.php
  39. +170 −0 classes/RTorrent.class.php
  40. +162 −0 classes/Scrubber.class.php
  41. +208 −0 classes/Torrent.class.php
  42. +214 −0 classes/Tracker.class.php
  43. +892 −0 classes/Video.class.php
  44. BIN classes/xmlrpc/.DS_Store
  45. +3,718 −0 classes/xmlrpc/xmlrpc.inc
  46. +944 −0 classes/xmlrpc/xmlrpc_wrappers.inc
  47. +21 −0 cleardatabase.php
  48. +116 −0 config.xml
  49. +491 −0 functions.php
  50. BIN images/bluray.png
  51. BIN images/blurayflare.png
  52. BIN images/dt.jpg
  53. BIN images/flare.png
  54. BIN images/google.jpg
  55. BIN images/kp.jpg
  56. BIN images/status_green.png
  57. BIN images/status_red.png
  58. BIN images/status_yellow.png
  59. BIN images/vidcase.png
  60. BIN images/vidcasesmall.png
  61. BIN images/youtube.jpg
  62. +222 −0 mediagic.sql
  63. +62 −0 scrubbers/scrubber.torrents.vfose.ru.xml
  64. BIN templates/.DS_Store
  65. +63 −0 templates/newvideo.html
  66. +38 −0 templates/status.html
  67. +94 −0 trackers/tracker.torrents.vfose.ru.xml
227 autodownload.php
@@ -0,0 +1,227 @@
+<?php
+
+require_once('functions.php');
+
+
+if ($config->verbose>0) echo date("r").NL;
+
+$count_trackers=0;
+$torrents=array();
+$new_torrents=array();
+$trackers=getTrackers();
+
+if ($config->verbose>0) echo SP.'Looking for the new torrents' . NL . SP;
+
+if (count($trackers) > 0)
+{
+ foreach ($trackers as $key=>$tracker_xml)
+ {
+ try
+ {
+ $tracker = new Tracker;
+ $tracker -> createTrackerByXMLData($tracker_xml);
+ if ($config->verbose>0) echo 'Processing '. $tracker->name . NL;
+ if ($tracker->enable == 1)
+ {
+ if ($config->verbose>0) echo SP;
+ $count_trackers++;
+ if (isset ($tracker->filters->accept))
+ $search_terms = $tracker->filters->accept;
+ else $search_terms = array('');
+ foreach ($search_terms as $search)
+ {
+ $new_torrents = $tracker->getTorrents($search);
+ if (is_array($new_torrents))
+ $torrents = array_merge($torrents, $new_torrents);
+ }
+ } else
+ if ($config->verbose>0) echo 'The tracker is disabled. Skipping.' . NL . SP;
+ } catch (Exception $e) {
+ if ($config->verbose>0) echo $e->getMessage() . NL . SP;
+ }
+ }
+}
+
+if ( $count_trackers == 0 )
+{
+ if ($config->verbose>0) echo "No trackers to proceed. Exiting now." . NL;
+ die();
+}
+
+if ($config->verbose>0) echo count($torrents) . ' new torrents were founded.' . NL . SP;
+
+foreach ($torrents as $key=>$torrent)
+{
+ if ($config->verbose>0) echo ($key+1) . ' of ' . count($torrents) . ': '. $torrent->title . NL . SSP;
+ if ($config->verbose>0) echo 'Downloading torrent file.'. NL;
+
+ try
+ {
+ $torrent->downloadTorrentFile();
+ $data_file_path = $torrent->tracker_obj->directories->datafiles_dir.$torrent->data_filename;
+ $result = getMediagicDBResult("SELECT * FROM torrents WHERE data_file_hash='".$torrent->data_file_hash."';");
+ $torrent_res_count = mysql_num_rows($result);
+
+ if ($torrent_res_count != 0)
+ {
+ if ($config->verbose>0) echo "The data file [ " . $torrent->data_filename . " ] is already registered in the database." . NL;
+ if (! myFileExist($data_file_path) )
+ {
+ if ($config->verbose>0) echo 'The file [ '. $data_file_path . ' ] is not exist' . NL;
+ if ($config->verbose>1) echo "Checking data files saved by other torrents:" . NL;
+ while ($row = mysql_fetch_assoc($result))
+ {
+ if (! myFileExist ($data_file_path) )
+ {
+ if ($config->verbose>1) echo ' * Checking [ ' . $row['data_file_dir'].$row['data_file_name'].' ] ... ';
+ if ( myFileExist( $row['data_file_dir'].$row['data_file_name'] ) )
+ {
+ if ($config->verbose>1) echo 'File exists.' . NL;
+ if ($config->verbose>0) echo 'Attempting to create a symlink to [ ' . $row['data_file_dir'].$row['data_file_name'] . ' ]' . NL;
+ if ( ! @ symlink ($row['data_file_dir'].$row['data_file_name'], $data_file_path) )
+ {
+ throw new Exception('ERROR: Can\'t create the symlink. Skipping.');
+ } elseif ($config->verbose>0) echo 'Successful.' . NL;
+ } elseif ($config->verbose>0) echo 'Missing.' . NL;
+ }
+ }
+ if (! myFileExist($data_file_path) ) throw new Exception("Registered data file is missing. Proposing that you deleted data file." . NL . "Skipping this torrent as well.");
+ }
+ }
+
+
+ $files = array();
+ $part = false;
+
+ if ($torrent->tracker_obj->type == 'Video')
+ {
+ if ($config->verbose>1) echo 'The type of the torrent is "Video".' . NL;
+ if ( is_array($torrent->files) )
+ {
+ foreach ($torrent->files as $v)
+ {
+ if ( mb_strpos($v['path'], 'VIDEO_TS/') !== false )
+ {
+ $torrent->dvd = true;
+ $video_ts_folder = mb_substr($torrent->data_filename . '/' . $v['path'], 0, mb_strpos($torrent->data_filename . '/' . $v['path'], 'VIDEO_TS/')-1);
+ $test_array = array( 'correct_hash' => false, 'path' => $video_ts_folder, 'size' => 0, 'video_ts' => true );
+ if ( ! in_array($test_array, $files) )
+ $files[] = $test_array;
+ }
+
+ $files[] = array( 'correct_hash' => false, 'path' => $torrent->data_filename . '/' . $v['path'], 'size' => $v['size'] );
+ }
+ } else {
+ $files[] = array( 'correct_hash' => true, 'path' => $torrent->data_filename, 'size' => $torrent->size );
+ }
+
+ if ($config->verbose>1) echo 'The torrent contains ' . count($files) . ' file(s).' . NL;
+
+ if ($config->verbose>1) echo 'Checking videos for duplicates.' . NL;
+
+ foreach ($files as $k=>$v)
+ {
+ $video_file_path = $torrent->tracker_obj->directories->datafiles_dir . $v['path'];
+ if ( isVideo($video_file_path) || ( isset($v['video_ts']) && $v['video_ts'] == true ) )
+ {
+ if ($v['correct_hash'] == true)
+ {
+ $result = getMediagicDBResult("SELECT * FROM video WHERE file_hash='".$torrent->data_file_hash."';");
+ $video_res_count = mysql_num_rows($result);
+
+ if ($video_res_count != 0)
+ {
+ if ($config->verbose>0) echo "Duplicate of [ " . $v['path'] . " ] was founded in the database." . NL;
+ if (! myFileExist($video_file_path) )
+ {
+ if ($config->verbose>0) echo 'The file [ '. $video_file_path . ' ] is not exist' . NL;
+ if ($config->verbose>1) echo "Checking video files registered in the database:" . NL;
+ while ($row = mysql_fetch_assoc($result))
+ {
+ if (! myFileExist ($video_file_path) )
+ {
+ if ($config->verbose>1) echo ' * Checking [ ' . $row['filename'].' ] ... ';
+ if ( myFileExist( $row['filename'] ) )
+ {
+ if ($config->verbose>1) echo 'File exists.' . NL;
+ if ($config->verbose>0) echo 'Attempting to create a symlink to [ ' . $row['filename'] . ' ]' . NL;
+ if ( ! @ symlink ($row['filename'], $video_file_path) )
+ {
+ if ($config->verbose>0) echo 'ERROR: Can\'t create the symlink.'.NL;
+ } elseif ($config->verbose>0) echo 'Successful.' . NL;
+ } elseif ($config->verbose>1) echo 'Missing.' . NL;
+ }
+ }
+ if (! myFileExist( $video_file_path ) ) echo "Registered video file is missing. Downloading as new.".NL;
+ }
+ }
+ }
+ } else unset($files[$k]);
+ }
+ }
+
+ if ($torrent->isNewByFilename())
+ {
+ if ($config->verbose>0) echo 'Saving [ '. $torrent->filename . ' ]' . NL;
+ $torrent->saveToFS();
+ } else {
+ if ($config->verbose>0) echo 'There is a torrent file with the same name already exist.' . NL;
+ }
+
+ if ($torrent_res_count != 0)
+ {
+ if ($config->verbose>1) echo "Removing duplicate entities from the database" . NL;
+ getMediagicDBResult("DELETE FROM torrents WHERE data_file_hash='".$torrent->data_file_hash."' AND ( tracker='" . addslashes( $torrent->tracker_name ) . "' OR tracker='');", false);
+ if ($config->verbose>1) echo mysql_affected_rows(). " entities were removed." . NL;
+ }
+
+ if ($config->verbose>1) echo "Updating database with the new torrent." . NL;
+ $torrent->saveToDBAsNew();
+
+
+ if ($torrent->tracker_obj->type == 'Video')
+ {
+ if ($config->verbose>1) echo 'Checking videos for duplicates with the same name.' . NL;
+ foreach ($files as $k=>$v)
+ {
+ $v['part'] = ! ( count($files) == 1 || ( isset($v['video_ts']) && $v['video_ts'] == true ) );
+ $video = new Video();
+ if ( $video->create( (($v['part']) ? getTitleFromFileName($v['path']) : $torrent->title ),
+ $torrent->tracker_obj->directories->datafiles_dir.$v['path'], $v['part'],
+ $torrent->title,
+ (($v['correct_hash']) ? $torrent->data_file_hash : false), $v['size'],
+ ( isset( $torrent->tracker_obj->scrubbers->relevant ) ? $torrent->torrent_id : 0 ),
+ ( isset( $torrent->tracker_obj->scrubbers->relevant ) ? trim( $torrent->tracker_obj->scrubbers->relevant ) : false ),
+ ( isset( $torrent->tracker_obj->scrubbers->default ) ? trim( $torrent->tracker_obj->scrubbers->default ) : false )) )
+ {
+ if ( isset($torrent->tracker_obj->scrubbers->automatic) && $torrent->tracker_obj->scrubbers->automatic == 1 )
+ $video->getInfo();
+ $video->saveToDB();
+ $video->updateExtDB();
+ } else {
+ throw new Exception('The file with the same name allready exists in the database. Skipping.');
+ }
+ }
+ if ( isset($video) )
+ {
+ if ( isset( $config->email ) )
+ {
+ $email_config = $config->email;
+ $email_attrs = $email_config->attributes();
+ if ( trim( $email_attrs['enable'] ) == 1 )
+ $video->notifyMe( ($torrent->dvd != true ? $files : ''), $torrent);
+ }
+ unset($video);
+ }
+ }
+
+ } catch (Exception $e) {
+ if ($config->verbose>0) echo $e->getMessage() . NL;
+ }
+ if ($config->verbose>0) echo SP;
+}
+
+//Command::execute();
+
+
+?>
329 checkemail.php
@@ -0,0 +1,329 @@
+<?php
+
+require_once('functions.php');
+
+//Command::addToQueue( 'email', serialize( array( 'body' => $s_body, 'subject' => 'Status', 'send_to_array' => array( array( 'name'=>'Vadim', 'email'=>'vnizzz@gmail.com' ) ), 'html'=>true, 'attachments'=>(is_array($attachments)?$attachments:'') ) ) );
+//Command::execute();
+//die();
+
+if ( $config->verbose > 0 ) echo date("r") . NL . SP;
+if ( isset( $config->email ) )
+{
+ $email_config = $config->email;
+ $email_attrs = $email_config->attributes();
+
+ if ( trim( $email_attrs['enable'] ) == 1 )
+ {
+ $get_responses_config = $email_config->get_responses;
+ $get_responses_config_attrs = $get_responses_config->attributes();
+ if ( trim( $get_responses_config_attrs['enable'] ) == 1 )
+ {
+ try
+ {
+ if ($config->verbose>1) echo 'Connecting to IMAP' . NL;
+ if (! $conn = @imap_open('{' . $get_responses_config->imap_host . '}' . $get_responses_config->imap_mailbox,
+ $email_config->username,
+ $email_config->password))
+ throw new Exception('Unable to connect to IMAP: ' . imap_last_error());
+
+ $MC = imap_check($conn);
+ if ($config->verbose>1) echo 'Getting messages' . NL;
+ if (! $overview = @imap_fetch_overview($conn, "1:{$MC->Nmsgs}") )
+ throw new Exception('Unable to recieve emails: ' . imap_last_error());
+
+ if ($config->verbose>1) echo count( $overview ) . ' messages in the inbox' . NL;
+
+ if ( count( $overview ) > 0 )
+ {
+ $needle_suffix = trim( $email_config->subject->prefix );
+ if ( $GLOBALS['config']->system_encoding != 'UTF-8' )
+ $needle_suffix = iconv( 'UTF-8', $GLOBALS['config']->system_encoding, $needle_suffix);
+ if ($config->verbose>1) echo SP.NL;
+ foreach( $overview as $mes_int_id => $message)
+ {
+ $subject = '';
+ $from = '';
+
+ foreach( imap_mime_header_decode($message->from) as $from_part)
+ {
+ if ( $from_part->charset != $GLOBALS['config']->system_encoding && $from_part->charset != 'default' )
+ {
+ $from .= iconv( $from_part->charset, $GLOBALS['config']->system_encoding . '//IGNORE', $from_part->text);
+ } else $from .= $from_part->text;
+ }
+
+ foreach( imap_mime_header_decode($message->subject) as $subj_part)
+ {
+ if ( $subj_part->charset != $GLOBALS['config']->system_encoding && $subj_part->charset != 'default' )
+ {
+ $subject .= iconv( $subj_part->charset, $GLOBALS['config']->system_encoding . '//IGNORE', $subj_part->text);
+ } else $subject .= $subj_part->text;
+ }
+
+ if ($config->verbose>1)
+ {
+ echo 'Message #' . ($mes_int_id + 1) . NL;
+ echo 'From: ' . $from. NL;
+ echo 'Subject: ' . $subject . NL;
+ }
+
+ preg_match( '/(.*)\<(.*)\>/', $from, $from_arr);
+ $from_name = trim($from_arr[1]);
+ $from_email = $from_arr[2];
+
+ //echo $from_arr[1];
+ $trusted_senders = $email_config->send_to;
+
+ $block_sender = true;
+
+ foreach ($trusted_senders as $trusted_sender)
+ if( trim($trusted_sender->email) == trim( $from_email ) )
+ $block_sender = false;
+
+ if ( $config->verbose > 1 )
+ {
+ if ( $message->seen != 0 ) echo 'Message is marked as read. Skipping'. NL;
+ elseif ( $block_sender == true ) echo 'Message sender is not in the list of trusted users. Skipping'. NL;
+ }
+
+ if ($message->seen == 0 && $block_sender==false )
+ {
+ $body = '';
+ $parts = imap_get_texts($conn, $message->uid);
+ foreach ( $parts as $part )
+ $body .= $part;
+ $body = br2nl( $body );
+ $body = strip_tags( $body );
+ $body = str_replace("&nbsp;", ' ', $body);
+ $body = html_entity_decode( $body );
+ //echo $body . SP. NL;
+ $commands = array();
+
+ if ( stripos($body, '#Delete') !== false )
+ {
+ if ( $config->verbose > 0 ) echo 'Command \'DELETE\' was found' . NL;
+ preg_match('/\#(\w{40})/', $body, $hash_arr);
+ $hash = $hash_arr[1];
+ if ( !empty( $hash ) )
+ {
+ $torrent = new Torrent();
+ $torrent->getFromDB('WHERE data_file_hash=\'' . $hash . '\'');
+ //print_r($torrent);
+ if ( !empty( $torrent->id ) )
+ {
+ if ( $config->verbose > 0 ) echo 'Adding command \'DELETE\' for the torrent [ ' . $torrent->title . ' ] to the queue' . NL;
+ Command::addToQueue('delete', $hash);
+ imap_setflag_full($conn, $message->uid ,"\\Seen", ST_UID);
+ } elseif ( $config->verbose > 1 ) echo 'The torrent file with specified hash-id is not registered in the database. Skipping' . NL;
+ } elseif ( $config->verbose > 0 ) echo 'The hash-id is missed. Skipping' . NL;
+ }
+
+ if ( stripos($body, '#Status') !== false )
+ {
+ // нужно показывать красивый ползунок статума загрузк
+ // нужно показывать кол-во пиров
+ if ( $config->verbose > 0 ) echo 'Command [ STATUS ] was found. Adding to the queue.' . NL;
+ $s_body = getTemplate('status.html');
+ $used_images = array('red'=>false, 'green'=>false, 'yellow'=>false);
+
+ $incomplete = RTorrent::downloadList( 'incomplete' );
+ if ($incomplete !== false)
+ {
+ $s_body = str_ireplace( '%r_status%', "RTorrent is running", $s_body );
+ //$st_body .= (int)count( $incomplete ). " torrents incompleted \r\n" . SSP;
+ if ( count( $incomplete ) > 0 )
+ {
+ if ( count( $incomplete ) == 1 ) $s_body = str_ireplace( '%d_count%', 'There is 1 incompleted download', $s_body );
+ else $s_body = str_ireplace( '%d_count%', 'There are ' . count( $incomplete ) . ' incompleted downloads', $s_body );
+
+ $downloads_list = '';
+ preg_match('/<\!--files_block_start-->(.*)<\!--files_block_end-->/ms', $s_body, $files_block);
+ preg_match('/<\!--file_start-->(.*)<\!--file_end-->/ms', $s_body, $download_inst);
+
+ $attachments = '';
+ $global_cid = md5( time() . 'ololo');
+ foreach ( $incomplete as $hash )
+ {
+ //echo RTorrent::dIsActive( $hash ) . NL;
+ //echo 'Active:' . RTorrent::dIsActive( $hash ) . ' HCd:' . RTorrent::dIsHashChecked( $hash ) . ' HCing:' . RTorrent::dIsHashChecking( $hash ) . ' Open:'. RTorrent::dIsOpen( $hash ) . NL;
+ $torrent = new Torrent();
+ $torrent->getFromDB('WHERE data_file_hash=\'' . $hash . '\'');
+ if ( !empty( $torrent->id ) ) $t_title = $torrent->title;
+ else $t_title = RTorrent::dGetName( $hash );
+ $compl_bytes = RTorrent::dGetCompletedBytes( $hash );
+ $bytes = RTorrent::dGetSizeBytes( $hash );
+
+ $download = str_ireplace( '%title%', $t_title, $download_inst[1] );
+ $download = str_ireplace( '%d_size%', humanSize( $compl_bytes ), $download );
+ $download = str_ireplace( '%t_size%', humanSize( $bytes ), $download );
+ $download = str_ireplace( '%percent%', round( ($compl_bytes/$bytes) * 100, 0) . '%', $download );
+ $d_speed = RTorrent::dGetDownRate( $hash );
+ $download = str_ireplace( '%d_speed%', humanSize( $d_speed ), $download );
+ $download = str_ireplace( '%u_speed%', humanSize( RTorrent::dGetUpRate( $hash ) ), $download );
+ if ($d_speed > 0)
+ {
+ $p_end = strftime ( '%B, %e / %I:%M', time() + ( ( $bytes - $compl_bytes ) / $d_speed ) );
+ $download = str_ireplace( '%p_end%', $p_end, $download );
+ } else {
+ $download = str_ireplace( '%p_end%', 'Unknown', $download );
+ }
+
+ $is_active = RTorrent::dIsActive( $hash ) ;
+ $is_open = RTorrent::dIsOpen( $hash ) ;
+
+ if ( $is_active == 0 && $is_open == 0 )
+ {
+ $status_image = 'status_red.png';
+ $used_images['red'] = true;
+ } elseif ( $is_active == 1 && $is_open == 1 ) {
+ $status_image = 'status_green.png';
+ $used_images['green'] = true;
+ } else {
+ $status_image = 'status_yellow.png';
+ $used_images['yellow'] = true;
+ }
+
+ $download = str_ireplace( '%status_image%', '<img src="cid:' . $global_cid . '/' . $status_image . '" width="10" height="10">', $download );
+
+
+ $genres = '';
+ $countries = '';
+ $year = '';
+ $cover = false;
+
+ $video = new Video();
+ if ( !empty( $torrent->id ) )
+ {
+ $cid = md5( time() . $video->scrub_title );
+ $video->getFromDB ('WHERE file_hash = \'' . $hash . '\'');
+ if ( empty($video->id) )
+ $video->getFromDB ('WHERE filename like \'' . $torrent->data_file_dir . $torrent->data_filename . '%\'');
+ if ( !empty($video->id) )
+ {
+ if ( ! isset( $GLOBALS['all_scrubbers'] ) )
+ {
+ $scrubbers = getScrubbers();
+ if (count($scrubbers) > 0)
+ {
+ foreach ($scrubbers as $key=>$scrubber_info)
+ {
+ try
+ {
+ $scrubber = new Scrubber();
+ $scrubber -> createScrubberByXMLData($scrubber_info);
+ if ($scrubber->enable == true || $scrubber->test == true)
+ $GLOBALS['all_scrubbers'][$scrubber->name] = $scrubber;
+ } catch (Exception $e) {
+ if ($config->verbose>1) echo $e->getMessage() . NL;
+ }
+ }
+ }
+ }
+
+ if ( isset( $GLOBALS['all_scrubbers'][$video->scrubber]->unknown ) )
+ $unkn = trim( $GLOBALS['all_scrubbers'][$video->scrubber]->unknown );
+ else $unkn = '';
+
+ $genres = implode( " / ", $video->genres);
+ if ($genres == $unkn) $genres = '';
+
+ $countries = implode( ", ", $video->countries );
+ if ($countries == $unkn) $countries = '';
+
+ if ( !empty($video->year) )
+ $year = '(' . $video->year . ')';
+ }
+ $cover = $video->createImage(63, 79, false, false);
+
+ if ($cover != false)
+ {
+ $download = str_ireplace( '%cover%', '<img src="cid:'.$cid.'/' . md5($video->title) . '.jpg" width="63" height="79">', $download );
+ $attachments[] = array( 'type' => 'raw', 'name' => md5($video->title) . '.jpg', 'data' => $cover, 'cid' => $cid, 'mime' => 'image/jpeg');
+ }
+ }
+
+ $download = str_ireplace( '%year%', $year, $download );
+ $download = str_ireplace( '%genres%', $genres, $download );
+ $download = str_ireplace( '%countries%', $countries, $download );
+
+ $downloads_list .= $download;
+
+ //$st_body .= $t_title . ' ..... ' . humanSize( $compl_bytes ) . ' of ' . humanSize( $bytes ) . ' (' . round( ($compl_bytes/$bytes) * 100, 2) . '%) downloaded' . "\r\n";
+ }
+ $files_block = preg_replace('/<\!--file_start-->(.*)<\!--file_end-->/ms', $downloads_list, $files_block[1]);
+ $s_body = preg_replace('/<\!--files_block_start-->(.*)<\!--files_block_end-->/ms', $files_block, $s_body);
+
+ if ( strpos( $s_body, '%cover%' ) )
+ {
+ $s_body = str_ireplace( '%cover%', '<img src="cid:'.$global_cid.'/cover.png" width="63" height="79">', $s_body );
+ $attachments[] = array( 'path' => dirname($_SERVER["PHP_SELF"]) . '/images/vidcasesmall.png', 'name' => 'cover.png', 'cid' => $global_cid, 'mime' => 'image/png' );
+ }
+ if ( $used_images['red'] == true ) $attachments[] = array( 'path' => dirname($_SERVER["PHP_SELF"]) . '/images/status_red.png', 'name' => 'status_red.png', 'cid' => $global_cid, 'mime' => 'image/png' );
+ if ( $used_images['yellow'] == true ) $attachments[] = array( 'path' => dirname($_SERVER["PHP_SELF"]) . '/images/status_yellow.png', 'name' => 'status_yellow.png', 'cid' => $global_cid, 'mime' => 'image/png' );
+ if ( $used_images['green'] == true ) $attachments[] = array( 'path' => dirname($_SERVER["PHP_SELF"]) . '/images/status_green.png', 'name' => 'status_green.png', 'cid' => $global_cid, 'mime' => 'image/png' );
+ } else {
+ $s_body = str_ireplace( '%d_count%', "There are no incompleted downloads", $s_body );
+ }
+ } else {
+ $s_body = str_ireplace( '%r_status%', "RTorrent is not running", $s_body );
+ $s_body = preg_replace('/<\!--files_block_start-->(.*)<\!--files_block_end-->/ms','', $s_body);
+ }
+ $os = getOS();
+ if ( $config->verbose > 1 ) echo 'Trying to get names of disks' . NL;
+ if ( $config->verbose > 1 ) echo 'System "' . $os . '" was detected' . NL;
+ if ( $os == 'Linux' )
+ {
+ exec('df -x tmpfs', $df);
+ if ( is_array( $df ) && count( $df ) > 0 )
+ {
+ $devs = array();
+ $devs_list = '';
+ foreach ( $df as $line)
+ {
+ $is_preg = preg_match('/^(\/[^\s]*)\s.*\s(\/[^\s]*)$/', $line, $line_preg);
+ if ( $is_preg )
+ {
+ $devs[] = array( 'dev_name' => $line_preg[1], 'mount_point' => $line_preg[2], 'free' => humanSize( disk_free_space( $line_preg[2] ) ), 'total' => humanSize( disk_total_space( $line_preg[2] ) ) );
+// str_ireplace( '%disk_stat%', '[ ' . $line_preg[1] . ' mounted to ' . $line_preg[2] . ' ] ' . humanSize( disk_free_space( $line_preg[2] ) ) . ' of ' . humanSize( disk_total_space( $line_preg[2] ) ) . ' is free', $s_body );
+ }
+ }
+
+ if ( count( $devs ) > 0 )
+ {
+ preg_match('/<\!--devs_block_start-->(.*)<\!--devs_block_end-->/ms', $s_body, $devs_block);
+ preg_match('/<\!--dev_start-->(.*)<\!--dev_end-->/ms', $s_body, $dev_inst);
+
+ foreach ( $devs as $dev )
+ {
+ $dev_content = str_ireplace( '%dev_name%', $dev['dev_name'], $dev_inst[1] );
+ $dev_content = str_ireplace( '%mount_point%', $dev['mount_point'], $dev_content );
+ $dev_content = str_ireplace( '%disk_free%', $dev['free'], $dev_content );
+ $dev_content = str_ireplace( '%disk_total%', $dev['total'], $dev_content );
+ $devs_list .= $dev_content;
+ }
+
+ $devs_block = preg_replace('/<\!--dev_start-->(.*)<\!--dev_end-->/ms', $devs_list, $devs_block[1]);
+ $s_body = preg_replace('/<\!--devs_block_start-->(.*)<\!--devs_block_end-->/ms', $devs_block, $s_body);
+ }
+ }
+ }
+ $s_body = preg_replace('/<\!--devs_block_start-->(.*)<\!--devs_block_end-->/ms','', $s_body);
+ Command::addToQueue( 'email', serialize( array('body' => $s_body, 'subject' => 'Status', 'send_to_array' => array( array( 'name'=>$from_name, 'email'=>$from_email ) ), 'html'=>true, 'attachments'=>(is_array($attachments)?$attachments:'') ) ) );
+ imap_setflag_full($conn, $message->uid ,"\\Seen", ST_UID);
+ }
+
+ }
+ if ($config->verbose>1) echo SP;
+ }
+ }
+ imap_close($conn);
+ } catch (Exception $e) {
+ if ($config->verbose>0) echo $e->getMessage() . NL . SP;
+ }
+ } elseif ($config->verbose>0) echo 'Mail functions are disabled in the config file' . NL;
+ } elseif ($config->verbose>0) echo 'Mail functions are disabled in the config file' . NL;
+} elseif ($config->verbose>0) echo 'Unable to find mail settings in the config file' . NL;
+
+Command::execute();
+
+?>
213 classes/Command.class.php
@@ -0,0 +1,213 @@
+<?php
+
+class Command
+{
+ public static function addToQueue($command, $target)
+ {
+ $q = "SELECT * from commands WHERE command='" . addslashes($command) . "' AND target='" . addslashes($target) . "';";
+ $res = getMediagicDBResult( $q );
+ if (mysql_num_rows($res) == 0)
+ {
+ $q = "INSERT into commands (command, target, timestamp) VALUES ('" . addslashes($command) . "', '" . addslashes($target) . "', " . time() . ");";
+ getMediagicDBResult( $q );
+ } elseif ( $GLOBALS['config']->verbose > 0 ) echo 'The command is already in the queue. Skipping' . NL;
+ }
+
+ public static function execute()
+ {
+ if ( $GLOBALS['config']->verbose > 0 ) echo 'Proceeding the queue of commands' . NL;
+ $q = "SELECT * from commands ORDER BY timestamp ASC;";
+ $res = getMediagicDBResult( $q );
+
+ if ( $GLOBALS['config']->verbose > 0 ) echo mysql_num_rows($res) . ' commands in the queue' . NL . SSP;
+
+ if (mysql_num_rows($res) > 0)
+ {
+ while ($row = mysql_fetch_assoc($res))
+ {
+ switch ( $row['command'] )
+ {
+ case ('delete'):
+ self::delete_download($row['target']);
+ break;
+ case ('email'):
+ self::sendEmail($row['target']);
+ break;
+ }
+ if ( $GLOBALS['config']->verbose > 0 ) echo SP;
+ }
+ }
+ }
+
+ private static function delete_download($hash)
+ {
+ //Нужно добавить обновление всех баз данных с новой информацией о новом расположении дата-файла в папке Trash
+ //Кроме этого, нужно перед удалением копировать в Trash торрент-файл, и после работы с рторрентом проверять что торрент-файл точно удалился
+ $torrent = new Torrent();
+ $torrent->getFromDB('WHERE data_file_hash=\'' . $hash . '\'');
+ if ( !empty($torrent->id) )
+ {
+ if ( $GLOBALS['config']->verbose > 0 ) echo 'Stopping the downloading of the torrent [ ' . $torrent->title . ' ]' . NL;
+
+ $rt_res = RTorrent::dClose($hash);
+
+ if ($rt_res != false)
+ {
+ sleep (5);
+ $rt_res = RTorrent::dErase($hash);
+ if ($rt_res != false)
+ {
+ if ( $GLOBALS['config']->verbose > 1) echo 'Removing command from the queue' . NL ;
+ getMediagicDBResult("DELETE FROM commands WHERE command='delete' AND target='" . addslashes($hash) . "'");
+ if (is_readable ($torrent->data_file_dir . $torrent->data_filename))
+ {
+ if ( $GLOBALS['config']->verbose > 1 ) echo 'Moving data files to trash' . NL;
+ $trash_dir = $GLOBALS['config']->directories->trash;
+ if (is_dir ($trash_dir))
+ {
+ if (! @ rename ($torrent->data_file_dir . $torrent->data_filename, $trash_dir . $torrent->data_filename) )
+ {
+ if ( $GLOBALS['config']->verbose > 0) echo 'Unable to move [' . $torrent->data_filename . '] to the trash at [' . $trash_dir . ']' . NL;
+ }
+ } else {
+ if ( $GLOBALS['config']->verbose > 0) echo 'Trash directory [' . $trash_dir . '] is not exist' . NL;
+ }
+ }
+ }
+ }
+ } else {
+ if ( $GLOBALS['config']->verbose > 1 ) echo 'Torrent with this hash-id is not registered in the database. Deleting command from queue' . NL;
+ getMediagicDBResult("DELETE FROM commands WHERE command='delete' AND target='" . addslashes($hash) . "'");
+ }
+ }
+
+ private static function sendEmail($ser_message)
+ {
+ if ( isset( $GLOBALS['config']->email ) )
+ {
+ $email = $GLOBALS['config']->email;
+ $email_attrs = $email->attributes();
+
+ if ( trim( $email_attrs['enable'] ) == 1 )
+ {
+ require_once('PHPMailer/class.phpmailer.php');
+ require_once('PHPMailer/class.smtp.php');
+
+ $message = unserialize($ser_message);
+
+ $body = $message['body'];
+
+ if ( isset( $message['subject'] ) )
+ $subject_suffix = $message['subject'];
+ else $subject_suffix = '';
+
+ if ( isset( $message['encoding'] ) )
+ $encoding = $message['encoding'];
+ else $encoding = 'UTF-8';
+
+ if ( isset( $message['attachments'] ) )
+ $attachments = $message['attachments'];
+ else $attachments = false;
+
+ if ( isset( $message['send_to_array'] ) )
+ $send_to_array = $message['send_to_array'];
+ else
+ {
+ foreach ( $email->send_to as $send_to_line)
+ {
+ $send_to_array[] = array( 'name'=>$send_to_line->name, 'email'=>$send_to_line->email );
+ }
+ }
+
+ $mail = new PHPMailer();
+
+ $send_from = $email->send_from;
+
+ $send_to_string = '';
+
+ $send_to_key = 0;
+
+ foreach ($send_to_array as $send_to)
+ {
+ $send_to_string .= $send_to['name'] . ' <'. $send_to['email'] . '>' ;
+ if ( $send_to_key != count($send_to_array) - 1 )
+ $send_to_string .= ', ';
+ $send_to_name = $send_to['name'];
+ if ( $email->encoding != 'UTF-8' )
+ $send_to_name = iconv( $encoding, $email->encoding . '//IGNORE', $send_to_name);
+ $mail->AddAddress( $send_to['email'], $send_to_name);
+ $send_to_key++;
+ }
+
+ if ( $GLOBALS['config']->verbose > 0 ) echo 'Sending email to ' . $send_to_string . NL;
+
+ if ( trim($send_from->type) == 'smtp')
+ {
+ $mail->IsSMTP();
+ $smtp = $send_from->smtp;
+ if ( isset( $smtp->smtp_auth ) )
+ {
+ if ( $smtp->smtp_auth == 'true' || $smtp->smtp_auth == '1')
+ $mail->SMTPAuth = true;
+ }
+
+ if ( isset( $smtp->smtp_secure ) ) $mail->SMTPSecure = $smtp->smtp_secure;
+ if ( isset( $smtp->host ) ) $mail->Host = $smtp->host;
+ if ( isset( $smtp->port ) ) $mail->Port = (int)$smtp->port;
+ if ( isset( $email->username ) ) $mail->Username = $email->username;
+ if ( isset( $email->password ) ) $mail->Password = $email->password;
+ }
+
+ $subject_prefix = $email->subject->prefix;
+ if ( $email->encoding != 'UTF-8' )
+ $subject_prefix = iconv( 'UTF-8', $email->encoding . '//IGNORE', $subject_prefix);
+
+ if ( $encoding != $email->encoding)
+ {
+ $body = iconv( $encoding, $email->encoding . '//IGNORE', $body);
+ $subject_suffix = iconv( $encoding, $email->encoding . '//IGNORE', $subject_suffix);
+ }
+
+ $mail->From = $send_from->email;
+ $mail->FromName = $send_from->name;
+ $mail->Subject = $subject_prefix . ' ' . $subject_suffix;
+
+ $mail->CharSet = $email->encoding;
+
+ if ( isset( $message['html'] ) && $message['html'] == true) $mail->IsHTML(true);
+ //$mail->MsgHTML($body);
+
+ $mail->Body = $body;
+
+ if (!empty($attachments) && is_array($attachments) )
+ {
+ foreach ($attachments as $attachment)
+ {
+ if ( isset( $attachment['type'] ) && $attachment['type'] == 'raw' )
+ {
+ if ( !empty($attachment['data']) )
+ $mail->AddStringEmbeddedImage($attachment['data'], $attachment['cid'] . '/' . $attachment['name'] , $attachment['name'], 'base64', $attachment['mime']);
+ } elseif ( isset( $attachment['path'] ) ) {
+ $mail->AddEmbeddedImage($attachment['path'], $attachment['cid'] . '/' . $attachment['name'] , $attachment['name'], 'base64', $attachment['mime']);
+ }
+ }
+ }
+
+ if(!$mail->Send() && $GLOBALS['config']->verbose>1)
+ {
+ if ( $GLOBALS['config']->verbose > 0 ) echo "Mailer Error: " . $mail->ErrorInfo . NL;
+ } else {
+ if ( $GLOBALS['config']->verbose > 1 ) echo "Message has been sent" . NL;
+ getMediagicDBResult("DELETE FROM commands WHERE command='email' AND target='" . addslashes($ser_message) . "'");
+ }
+ $mail->ClearAddresses();
+ $mail->ClearAttachments();
+ $mail->SmtpClose();
+
+ }
+ }
+ }
+
+}
+
+?>
105 classes/MyCurl.class.php
@@ -0,0 +1,105 @@
+<?php
+
+class MyCurl {
+ private $response;
+ private $response_meta_info;
+ private $url;
+ private $cookies;
+ private $raw;
+ private $encoding;
+ private $user_agent;
+
+ function __construct($url, $cookies='', $encoding='UTF-8', $raw=false) {
+ $this->url = $url;
+ $this->cookies = $cookies;
+ $this->raw = $raw;
+ $this->encoding = $encoding;
+ $this->user_agent = $GLOBALS['config']->user_agent;
+ }
+
+ function getData()
+ {
+ if ($GLOBALS['config']->verbose>0) echo "( Downloading ".$this->url . ' )' . NL;
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $this->url);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ if ($this->raw==true) curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60);
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, array(&$this,'readHeader'));
+ if ( !empty( $this->cookies ) ) curl_setopt($ch, CURLOPT_COOKIE, $this->cookies);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:"));
+ curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
+ if ($this->raw==true)
+ {
+ curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
+ $this->response=curl_exec($ch);
+ }
+ else
+ {
+ $this->response=mb_convert_encoding(curl_exec($ch),'HTML-ENTITIES', $this->encoding);
+ //echo $this->response;
+ //die();
+ }
+ if ( empty( $this->response ) ) {
+ throw new Exception('ERROR: Can\'t download requested URL');
+ }
+ $headers = curl_getinfo($ch);
+ if (!isset($this->response_meta_info)) $this->response_meta_info=array();
+ $this->response_meta_info = array_merge($headers, $this->response_meta_info);
+ curl_close($ch);
+ if (is_bool($this->response)) {
+ if ($this->response==false){
+ throw new Exception('ERROR: No connection');
+ } else {
+ //null the response, because there are actually no data
+ $this->response=null;
+ }
+
+ }
+ return $this->response;
+ }
+
+ /**
+ * CURL callback function for reading and processing headers
+ * Override this for your needs
+ *
+ * @param object $ch
+ * @param string $header
+ * @return integer
+ */
+ private function readHeader($ch, $header) {
+ //extracting example data: filename from header field Content-Disposition
+ //echo $header;
+ $filename = $this->extractCustomHeader('Content-Disposition: attachment; filename="', '".?\n', $header);
+ if ($filename) {
+ $this->response_meta_info['content_disposition'] = trim($filename);
+ //echo $filename;
+ }
+ return strlen($header);
+ }
+
+ private function extractCustomHeader($start,$end,$header) {
+ $pattern = '/'. $start .'(.*?)'. $end .'/';
+ if (preg_match($pattern, $header, $result)) {
+ return $result[1];
+ } else {
+ return false;
+ }
+ }
+
+ function getHeaders() {
+ return $this->response_meta_info;
+ }
+}
+
+function curlHeaderCallback($resURL, $strHeader) {
+ GLOBAL $filename;
+ $pattern = '/Content-Disposition: attachment; filename=(.*?)\n/';
+ if (preg_match($pattern, $strHeader, $result)) {
+ $filename=trim($result);
+ }
+}
+
+?>
504 classes/PHPMailer/LICENSE
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. 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 not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the 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
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
218 classes/PHPMailer/README
@@ -0,0 +1,218 @@
+/*******************************************************************
+* The http://phpmailer.codeworxtech.com/ website now carries a few *
+* advertisements through the Google Adsense network. Please visit *
+* the advertiser sites and help us offset some of our costs. *
+* Thanks .... *
+********************************************************************/
+
+PHPMailer
+Full Featured Email Transfer Class for PHP
+==========================================
+
+Version 5.0.0 (April 02, 2009)
+
+With the release of this version, we are initiating a new version numbering
+system to differentiate from the PHP4 version of PHPMailer.
+
+Most notable in this release is fully object oriented code.
+
+We now have available the PHPDocumentor (phpdocs) documentation. This is
+separate from the regular download to keep file sizes down. Please see the
+download area of http://phpmailer.codeworxtech.com.
+
+We also have created a new test script (see /test_script) that you can use
+right out of the box. Copy the /test_script folder directly to your server (in
+the same structure ... with class.phpmailer.php and class.smtp.php in the
+folder above it. Then launch the test script with:
+http://www.yourdomain.com/phpmailer/test_script/index.php
+from this one script, you can test your server settings for mail(), sendmail (or
+qmail), and SMTP. This will email you a sample email (using contents.html for
+the email body) and two attachments. One of the attachments is used as an inline
+image to demonstrate how PHPMailer will automatically detect if attachments are
+the same source as inline graphics and only include one version. Once you click
+the Submit button, the results will be displayed including any SMTP debug
+information and send status. We will also display a version of the script that
+you can cut and paste to include in your projects. Enjoy!
+
+Version 2.3 (November 08, 2008)
+
+We have removed the /phpdoc from the downloads. All documentation is now on
+the http://phpmailer.codeworxtech.com website.
+
+The phpunit.php has been updated to support PHP5.
+
+For all other changes and notes, please see the changelog.
+
+Donations are accepted at PayPal with our id "paypal@worxteam.com".
+
+Version 2.2 (July 15 2008)
+
+- see the changelog.
+
+Version 2.1 (June 04 2008)
+
+With this release, we are announcing that the development of PHPMailer for PHP5
+will be our focus from this date on. We have implemented all the enhancements
+and fixes from the latest release of PHPMailer for PHP4.
+
+Far more important, though, is that this release of PHPMailer (v2.1) is
+fully tested with E_STRICT error checking enabled.
+
+** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS.
+ IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE
+ APPRECIATED.
+
+We have now added S/MIME functionality (ability to digitally sign emails).
+BIG THANKS TO "sergiocambra" for posting this patch back in November 2007.
+The "Signed Emails" functionality adds the Sign method to pass the private key
+filename and the password to read it, and then email will be sent with
+content-type multipart/signed and with the digital signature attached.
+
+A quick note on E_STRICT:
+
+- In about half the test environments the development version was subjected
+ to, an error was thrown for the date() functions (used at line 1565 and 1569).
+ This is NOT a PHPMailer error, it is the result of an incorrectly configured
+ PHP5 installation. The fix is to modify your 'php.ini' file and include the
+ date.timezone = America/New York
+ directive, (for your own server timezone)
+- If you do get this error, and are unable to access your php.ini file, there is
+ a workaround. In your PHP script, add
+ date_default_timezone_set('America/Toronto');
+
+ * do NOT try to use
+ $myVar = date_default_timezone_get();
+ as a test, it will throw an error.
+
+We have also included more example files to show the use of "sendmail", "mail()",
+"smtp", and "gmail".
+
+We are also looking for more programmers to join the volunteer development team.
+If you have an interest in this, please let us know.
+
+Enjoy!
+
+
+Version 2.1.0beta1 & beta2
+
+please note, this is BETA software
+** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS
+INTENDED STRICTLY FOR TESTING
+
+** NOTE:
+
+As of November 2007, PHPMailer has a new project team headed by industry
+veteran Andy Prevost (codeworxtech). The first release in more than two
+years will focus on fixes, adding ease-of-use enhancements, provide
+basic compatibility with PHP4 and PHP5 using PHP5 backwards compatibility
+features. A new release is planned before year-end 2007 that will provide
+full compatiblity with PHP4 and PHP5, as well as more bug fixes.
+
+We are looking for project developers to assist in restoring PHPMailer to
+its leadership position. Our goals are to simplify use of PHPMailer, provide
+good documentation and examples, and retain backward compatibility to level
+1.7.3 standards.
+
+If you are interested in helping out, visit http://sourceforge.net/projects/phpmailer
+and indicate your interest.
+
+**
+
+http://phpmailer.sourceforge.net/
+
+This software is licenced under the LGPL. Please read LICENSE for information on the
+software availability and distribution.
+
+Class Features:
+- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs
+- Redundant SMTP servers
+- Multipart/alternative emails for mail clients that do not read HTML email
+- Support for 8bit, base64, binary, and quoted-printable encoding
+- Uses the same methods as the very popular AspEmail active server (COM) component
+- SMTP authentication
+- Native language support
+- Word wrap, and more!
+
+Why you might need it:
+
+Many PHP developers utilize email in their code. The only PHP function
+that supports this is the mail() function. However, it does not expose
+any of the popular features that many email clients use nowadays like
+HTML-based emails and attachments. There are two proprietary
+development tools out there that have all the functionality built into
+easy to use classes: AspEmail(tm) and AspMail. Both of these
+programs are COM components only available on Windows. They are also a
+little pricey for smaller projects.
+
+Since I do Linux development I�ve missed these tools for my PHP coding.
+So I built a version myself that implements the same methods (object
+calls) that the Windows-based components do. It is open source and the
+LGPL license allows you to place the class in your proprietary PHP
+projects.
+
+
+Installation:
+
+Copy class.phpmailer.php into your php.ini include_path. If you are
+using the SMTP mailer then place class.smtp.php in your path as well.
+In the language directory you will find several files like
+phpmailer.lang-en.php. If you look right before the .php extension
+that there are two letters. These represent the language type of the
+translation file. For instance "en" is the English file and "br" is
+the Portuguese file. Chose the file that best fits with your language
+and place it in the PHP include path. If your language is English
+then you have nothing more to do. If it is a different language then
+you must point PHPMailer to the correct translation. To do this, call
+the PHPMailer SetLanguage method like so:
+
+// To load the Portuguese version
+$mail->SetLanguage("br", "/optional/path/to/language/directory/");
+
+That's it. You should now be ready to use PHPMailer!
+
+
+A Simple Example:
+
+<?php
+require("class.phpmailer.php");
+
+$mail = new PHPMailer();
+
+$mail->IsSMTP(); // set mailer to use SMTP
+$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
+$mail->SMTPAuth = true; // turn on SMTP authentication
+$mail->Username = "jswan"; // SMTP username
+$mail->Password = "secret"; // SMTP password
+
+$mail->From = "from@example.com";
+$mail->FromName = "Mailer";
+$mail->AddAddress("josh@example.net", "Josh Adams");
+$mail->AddAddress("ellen@example.com"); // name is optional
+$mail->AddReplyTo("info@example.com", "Information");
+
+$mail->WordWrap = 50; // set word wrap to 50 characters
+$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
+$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
+$mail->IsHTML(true); // set email format to HTML
+
+$mail->Subject = "Here is the subject";
+$mail->Body = "This is the HTML message body <b>in bold!</b>";
+$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
+
+if(!$mail->Send())
+{
+ echo "Message could not be sent. <p>";
+ echo "Mailer Error: " . $mail->ErrorInfo;
+ exit;
+}
+
+echo "Message has been sent";
+?>
+
+CHANGELOG
+
+See ChangeLog.txt
+
+Download: http://sourceforge.net/project/showfiles.php?group_id=26031
+
+Andy Prevost
2,089 classes/PHPMailer/class.phpmailer.php
@@ -0,0 +1,2089 @@
+<?php
+/*~ class.phpmailer.php
+.---------------------------------------------------------------------------.
+| Software: PHPMailer - PHP email class |
+| Version: 5.0.2 |
+| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
+| Info: http://phpmailer.sourceforge.net |
+| Support: http://sourceforge.net/projects/phpmailer/ |
+| ------------------------------------------------------------------------- |
+| Admin: Andy Prevost (project admininistrator) |
+| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
+| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
+| Founder: Brent R. Matzelle (original founder) |
+| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
+| Copyright (c) 2001-2003, Brent R. Matzelle |
+| ------------------------------------------------------------------------- |
+| License: Distributed under the Lesser General Public License (LGPL) |
+| http://www.gnu.org/copyleft/lesser.html |
+| This program is distributed in the hope that it will be useful - WITHOUT |
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
+| FITNESS FOR A PARTICULAR PURPOSE. |
+| ------------------------------------------------------------------------- |
+| We offer a number of paid services (www.codeworxtech.com): |
+| - Web Hosting on highly optimized fast and secure servers |
+| - Technology Consulting |
+| - Oursourcing (highly qualified programmers and graphic designers) |
+'---------------------------------------------------------------------------'
+*/
+
+/**
+ * PHPMailer - PHP email transport class
+ * NOTE: Requires PHP version 5 or later
+ * @package PHPMailer
+ * @author Andy Prevost
+ * @author Marcus Bointon
+ * @copyright 2004 - 2009 Andy Prevost
+ * @version $Id: class.phpmailer.php 447 2009-05-25 01:36:38Z codeworxtech $
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ */
+
+if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
+
+class PHPMailer {
+
+ /////////////////////////////////////////////////
+ // PROPERTIES, PUBLIC
+ /////////////////////////////////////////////////
+
+ /**
+ * Email priority (1 = High, 3 = Normal, 5 = low).
+ * @var int
+ */
+ public $Priority = 3;
+
+ /**
+ * Sets the CharSet of the message.
+ * @var string
+ */
+ public $CharSet = 'iso-8859-1';
+
+ /**
+ * Sets the Content-type of the message.
+ * @var string
+ */
+ public $ContentType = 'text/plain';
+
+ /**
+ * Sets the Encoding of the message. Options for this are
+ * "8bit", "7bit", "binary", "base64", and "quoted-printable".
+ * @var string
+ */
+ public $Encoding = '8bit';
+
+ /**
+ * Holds the most recent mailer error message.
+ * @var string
+ */
+ public $ErrorInfo = '';
+
+ /**
+ * Sets the From email address for the message.
+ * @var string
+ */
+ public $From = 'root@localhost';
+
+ /**
+ * Sets the From name of the message.
+ * @var string
+ */
+ public $FromName = 'Root User';
+
+ /**
+ * Sets 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 = '';
+
+ /**
+ * Sets the Subject of the message.
+ * @var string
+ */
+ public $Subject = '';
+
+ /**
+ * Sets the Body of the message. This can be either an HTML or text body.
+ * If HTML then run IsHTML(true).
+ * @var string
+ */
+ public $Body = '';
+
+ /**
+ * Sets the text-only body of the message. This automatically sets the
+ * email to multipart/alternative. This body can be read by mail
+ * clients that do not have HTML email capability such as mutt. Clients
+ * that can read HTML will view the normal Body.
+ * @var string
+ */
+ public $AltBody = '';
+
+ /**
+ * Sets word wrapping on the body of the message to a given number of
+ * characters.
+ * @var int
+ */
+ public $WordWrap = 0;
+
+ /**
+ * Method to send mail: ("mail", "sendmail", or "smtp").
+ * @var string
+ */
+ public $Mailer = 'mail';
+
+ /**
+ * Sets the path of the sendmail program.
+ * @var string
+ */
+ public $Sendmail = '/usr/sbin/sendmail';
+
+ /**
+ * Path to PHPMailer plugins. Useful if the SMTP class
+ * is in a different directory than the PHP include path.
+ * @var string
+ */
+ public $PluginDir = '';
+
+ /**
+ * Sets the email address that a reading confirmation will be sent.
+ * @var string
+ */
+ public $ConfirmReadingTo = '';
+
+ /**
+ * Sets the hostname to use in Message-Id and Received headers
+ * and as default HELO string. If empty, the value returned
+ * by SERVER_NAME is used or 'localhost.localdomain'.
+ * @var string
+ */
+ public $Hostname = '';
+
+ /**
+ * Sets the message ID to be used in the Message-Id header.
+ * If empty, a unique id will be generated.
+ * @var string
+ */
+ public $MessageID = '';
+
+ /////////////////////////////////////////////////
+ // PROPERTIES FOR SMTP
+ /////////////////////////////////////////////////
+
+ /**
+ * Sets the SMTP hosts. All hosts must be separated by a
+ * semicolon. 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").
+ * Hosts will be tried in order.
+ * @var string
+ */
+ public $Host = 'localhost';
+
+ /**
+ * Sets the default SMTP server port.
+ * @var int
+ */
+ public $Port = 25;
+
+ /**
+ * Sets the SMTP HELO of the message (Default is $Hostname).
+ * @var string
+ */
+ public $Helo = '';
+
+ /**
+ * Sets connection prefix.
+ * Options are "", "ssl" or "tls"
+ * @var string
+ */
+ public $SMTPSecure = '';
+
+ /**
+ * Sets SMTP authentication. Utilizes the Username and Password variables.
+ * @var bool
+ */
+ public $SMTPAuth = false;
+
+ /**
+ * Sets SMTP username.
+ * @var string
+ */
+ public $Username = '';
+
+ /**
+ * Sets SMTP password.
+ * @var string
+ */
+ public $Password = '';
+
+ /**
+ * Sets the SMTP server timeout in seconds.
+ * This function will not work with the win32 version.
+ * @var int
+ */
+ public $Timeout = 10;
+
+ /**
+ * Sets SMTP class debugging on or off.
+ * @var bool
+ */
+ public $SMTPDebug = false;
+
+ /**
+ * Prevents the SMTP connection from being closed after each mail
+ * sending. If this is set to true then to close the connection
+ * requires an explicit call to SmtpClose().
+ * @var bool
+ */
+ public $SMTPKeepAlive = false;
+
+ /**
+ * Provides the ability to have the TO field process individual
+ * emails, instead of sending to entire TO addresses
+ * @var bool
+ */
+ public $SingleTo = false;
+
+ /**
+ * Provides the ability to change the line ending
+ * @var string
+ */
+ public $LE = "\n";
+
+ /**
+ * Sets the PHPMailer Version number
+ * @var string
+ */
+ public $Version = '5.0.2';
+
+ /////////////////////////////////////////////////
+ // PROPERTIES, PRIVATE AND PROTECTED
+ /////////////////////////////////////////////////
+
+ private $smtp = NULL;
+ private $to = array();
+ private $cc = array();
+ private $bcc = array();
+ private $ReplyTo = array();
+ private $all_recipients = array();
+ private $attachment = array();
+ private $CustomHeader = array();
+ private $message_type = '';
+ private $boundary = array();
+ protected $language = array();
+ private $error_count = 0;
+ private $sign_cert_file = "";
+ private $sign_key_file = "";
+ private $sign_key_pass = "";
+ private $exceptions = false;
+
+ /////////////////////////////////////////////////
+ // CONSTANTS
+ /////////////////////////////////////////////////
+
+ const STOP_MESSAGE = 0; // message only, continue processing
+ const STOP_CONTINUE = 1; // message?, likely ok to continue processing
+ const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
+
+ /////////////////////////////////////////////////
+ // METHODS, VARIABLES
+ /////////////////////////////////////////////////
+
+ /**
+ * Constructor
+ * @param boolean $exceptions Should we throw external exceptions?
+ */
+ public function __construct($exceptions = false) {
+ $this->exceptions = ($exceptions == true);
+ }
+
+ /**
+ * Sets message type to HTML.
+ * @param bool $ishtml
+ * @return void
+ */
+ public function IsHTML($ishtml = true) {
+ if ($ishtml) {
+ $this->ContentType = 'text/html';
+ } else {
+ $this->ContentType = 'text/plain';
+ }
+ }
+
+ /**
+ * Sets Mailer to send message using SMTP.
+ * @return void
+ */
+ public function IsSMTP() {
+ $this->Mailer = 'smtp';
+ }
+
+ /**
+ * Sets Mailer to send message using PHP mail() function.
+ * @return void
+ */
+ public function IsMail() {
+ $this->Mailer = 'mail';
+ }
+
+ /**
+ * Sets Mailer to send message using the $Sendmail program.
+ * @return void
+ */
+ public function IsSendmail() {
+ if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
+ $this->Sendmail = '/var/qmail/bin/sendmail';
+ }
+ $this->Mailer = 'sendmail';
+ }
+
+ /**
+ * Sets Mailer to send message using the qmail MTA.
+ * @return void
+ */
+ public function IsQmail() {
+ if (stristr(ini_get('sendmail_path'), 'qmail')) {
+ $this->Sendmail = '/var/qmail/bin/sendmail';
+ }
+ $this->Mailer = 'sendmail';
+ }
+
+ /////////////////////////////////////////////////
+ // METHODS, RECIPIENTS
+ /////////////////////////////////////////////////
+
+ /**
+ * Adds a "To" address.
+ * @param string $address
+ * @param string $name
+ * @return boolean true on success, false if address already used
+ */
+ public function AddAddress($address, $name = '') {
+ return $this->AddAnAddress('to', $address, $name);
+ }
+
+ /**
+ * Adds a "Cc" address.
+ * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
+ * @param string $address
+ * @param string $name
+ * @return boolean true on success, false if address already used
+ */
+ public function AddCC($address, $name = '') {
+ return $this->AddAnAddress('cc', $address, $name);
+ }
+
+ /**
+ * Adds a "Bcc" address.
+ * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
+ * @param string $address
+ * @param string $name
+ * @return boolean true on success, false if address already used
+ */
+ public function AddBCC($address, $name = '') {
+ return $this->AddAnAddress('bcc', $address, $name);
+ }
+
+ /**
+ * Adds a "Reply-to" address.
+ * @param string $address
+ * @param string $name
+ * @return boolean
+ */
+ public function AddReplyTo($address, $name = '') {
+ return $this->AddAnAddress('ReplyTo', $address, $name);
+ }
+
+ /**
+ * Adds an address to one of the recipient arrays
+ * Addresses that have been added already return false, but do not throw exceptions
+ * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
+ * @param string $address The email address to send to
+ * @param string $name
+ * @return boolean true on success, false if address already used or invalid in some way
+ * @access private
+ */
+ private function AddAnAddress($kind, $address, $name = '') {
+ if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) {
+ echo 'Invalid recipient array: ' . kind;
+ return false;
+ }
+ $address = trim($address);
+ $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
+ if (!self::ValidateAddress($address)) {
+ $this->SetError($this->Lang('invalid_address').': '. $address);
+ if ($this->exceptions) {
+ throw new phpmailerException($this->Lang('invalid_address').': '.$address);
+ }
+ echo $this->Lang('invalid_address').': '.$address;
+ return false;
+ }
+ if ($kind != 'ReplyTo') {
+ if (!isset($this->all_recipients[strtolower($address)])) {
+ 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;
+ }
+
+/**
+ * Set the From and FromName properties
+ * @param string $address
+ * @param string $name
+ * @return boolean
+ */
+ public function SetFrom($address, $name = '') {
+ $address = trim($address);
+ $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
+ if (!self::ValidateAddress($address)) {
+ $this->SetError($this->Lang('invalid_address').': '. $address);
+ if ($this->exceptions) {
+ throw new phpmailerException($this->Lang('invalid_address').': '.$address);
+ }
+ echo $this->Lang('invalid_address').': '.$address;
+ return false;
+ }
+ $this->From = $address;
+ $this->FromName = $name;
+ return true;
+ }
+
+ /**
+ * Check that a string looks roughly like an email address should
+ * Static so it can be used without instantiation
+ * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator
+ * Conforms approximately to RFC2822
+ * @link http://www.hexillion.com/samples/#Regex Original pattern found here