| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 | 
							- <?php
 
- if (!class_exists("plug_mail")) {
 
- 	class plug_mail {
 
- 		function __construct($ns) {
 
- 			$this->title = __("mail", "dagsopt");
 
- 			$this->pluginname = $ns->pluginname;
 
- 			$this->file = $ns->file;
 
- 			$this->ns = $ns;
 
- 		}
 
- 		function start() {
 
- 			$this->logfile = fopen(ABSPATH . "/wp-content/uploads/maillog.log", 'a');
 
- 			add_filter('wp_mail', array(&$this, 'mail_logger'), 10, 1);
 
- 			add_filter('wp_mail_from_name', array(&$this, 'sender_name'));
 
- 			add_filter('wp_mail_from', array(&$this, 'sender_email'));
 
- 			//add_filter("wp_footer", array(&$this, 'tester'));
 
- 		}
 
- 		function sender_email($original_email_address) {
 
- 			$g = stripcslashes(get_option($this->pluginname . "_mail_emailsettings"));
 
- 			$arr = json_decode($g, true);
 
- 			if (isset($arr[$_SERVER['HTTP_HOST']])) {
 
- 				$darr = $arr[$_SERVER['HTTP_HOST']];
 
- 			} else {
 
- 				$dom = explode(".", $_SERVER['HTTP_HOST']);
 
- 				$topdom = implode(".", array_slice($dom, -2));
 
- 				if (isset($arr[$topdom])) {
 
- 					$darr = $arr[$topdom];
 
- 				}
 
- 			}
 
- 			if (isset($darr)) {
 
- 				return $darr[1];
 
- 			} else {
 
- 				return $original_email_address;
 
- 			}
 
- 		}
 
- 		function sender_name($original_email_from) {
 
- 			$g = stripcslashes(get_option($this->pluginname . "_mail_emailsettings"));
 
- 			$arr = json_decode($g, true);
 
- 			if (isset($arr[$_SERVER['HTTP_HOST']])) {
 
- 				$darr = $arr[$_SERVER['HTTP_HOST']];
 
- 			} else {
 
- 				$dom = explode(".", $_SERVER['HTTP_HOST']);
 
- 				$topdom = implode(".", array_slice($dom, -2));
 
- 				if (isset($arr[$topdom])) {
 
- 					$darr = $arr[$topdom];
 
- 				}
 
- 			}
 
- 			if (isset($darr)) {
 
- 				return $darr[0];
 
- 			} else {
 
- 				return $original_email_from;
 
- 			}
 
- 		}
 
- 		function tester() {
 
- 			$g = stripcslashes(get_option($this->pluginname . "_mail_emailsettings"));
 
- 			$arr = json_decode($g, true);
 
- 			if (isset($arr[$_SERVER['HTTP_HOST']])) {
 
- 				$darr = $arr[$_SERVER['HTTP_HOST']];
 
- 			} else {
 
- 				$dom = explode(".", $_SERVER['HTTP_HOST']);
 
- 				$topdom = implode(".", array_slice($dom, -2));
 
- 				if (isset($arr[$topdom])) {
 
- 					$darr = $arr[$topdom];
 
- 				}
 
- 			}
 
- 			if (isset($darr)) {
 
- 				print_r($darr);
 
- 			}
 
- 		}
 
- 		function mail_logger($args) {
 
- 			$str = date("Y-m-d");
 
- 			$str .= " | " . date("H:i:s");
 
- 			$str .= " | " . $args['to'];
 
- 			$str .= " | " . $args['subject'];
 
- 			fwrite($this->logfile, $str . "\n");
 
- 			return $args;
 
- 		}
 
- 		function help() {
 
- 			?>
 
- 				<?php echo (__("Adds mail log functions", "dagsopt")) ?>
 
- 				<?php echo (__("Adds mail settings", "dagsopt")) ?>
 
-  			<?php
 
- }
 
- 		function Option($pre) {
 
- 			update_option($pre . '_emailsettings', $_POST[$pre . '_emailsettings']);
 
- 		}
 
- 		function fullscreen() {
 
- 			?>
 
- 		 	<?php
 
- $data = file_get_contents(ABSPATH . "/wp-content/uploads/maillog.log");
 
- 			?>
 
- 	<table class="form-table">
 
- 			<tr><td style="width: 100px;">Email log</td>
 
- 				<td>
 
- 			<textarea class="" rows="40" style="width: 100%; font-size: 11px;"><?php echo ($data) ?></textarea>
 
- </td></tr>
 
- 	 		</table>
 
- 		  <?php
 
- 		}
 
- 		function admin_line($pre) {
 
- 			?>
 
- 		  <?php echo (__("Emailsettings:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_emailsettings'); ?>"><?php echo (stripcslashes(get_option($pre . "_emailsettings"))); ?></textarea>
 
- 		 <hr>
 
- <?php echo ($pre . "_emailsettings"); ?>
 
- <?php
 
- $g = stripcslashes(get_option($pre . "_emailsettings"));
 
- 			$arr = json_decode($g, true);
 
- 			?>
 
- 		 <hr>
 
- 		 <a href="/wp-admin/admin.php?page=dagsopt-options-mail">Se log</a>
 
- 		  <?php
 
- }
 
- 	}
 
- 	global $plug_mail;
 
- 	$plug_mail = new plug_mail($this);
 
- 	$this->dagsopt['plug_mail'] = $plug_mail;
 
- }
 
 
  |