@@ -45,6 +45,10 @@ public function __construct(CronMail $mailObj)
4545 */
4646 public function handle ()
4747 {
48+ // If not a valid e-mail address, do not run handler
49+ if (!filter_var ( $ this ->obj ->to , FILTER_VALIDATE_EMAIL )) {
50+ return ;
51+ }
4852 if (!$ this ->doubleCheckTime ()) {
4953 return ;
5054 }
@@ -74,8 +78,11 @@ public function handle()
7478
7579 $ encoded = base64_encode ($ this ->obj ->extension_id . "- " . $ this ->obj ->server_id . "- " . $ this ->obj ->target );
7680 $ time = "awk -F'[]]|[[]' '$0 ~ /^\[/ && $2 >= \"$ before \" { p=1 } $0 ~ /^\[/ && $2 >= \"$ now \" { p=0 } p { print $0 }' /liman/logs/extension.log " ;
77- $ command = "$ time | grep ' " . $ encoded . "' | grep ' " . $ this ->obj ->user_id . "' | wc -l " ;
78- $ count = trim (shell_exec ($ command ));
81+ $ command = Command::runLiman ("{:time} | grep @{:encoded} | grep @{:user_id} | wc -l " , [
82+ "time " => $ time ,
83+ "encoded " => $ encoded ,
84+ "user_id " => $ this ->user ->id
85+ ]);
7986 $ subject = $ this ->user ->name . " kullanıcısının " . __ ($ this ->obj ->cron_type ) . " Liman MYS Raporu " ;
8087 $ view = view ('email.cron_mail ' , [
8188 "user " => $ this ->user ,
@@ -87,14 +94,19 @@ public function handle()
8794 "extension " => $ this ->extension ,
8895 "target " => $ this ->getTagText ($ this ->obj ->target , $ this ->extension ->name ),
8996 "from " => trim (env ("APP_NOTIFICATION_EMAIL " )),
90- "to " => $ this ->obj ->to
97+ "to " => trim ( $ this ->obj ->to )
9198 ])->render ();
9299 $ file = "/tmp/ " . str_random (16 );
93100 file_put_contents ($ file , $ view );
94- $ command = "curl -s -v --connect-timeout 15 \"smtp:// " . trim (env ("MAIL_HOST " )) . ": " . trim (env ("MAIL_PORT " )) . "\" -u \"" .
95- trim (env ("MAIL_USERNAME " )) . ": " . trim (env ("MAIL_PASSWORD " )) . "\" --mail-from \"" . trim (env ("APP_NOTIFICATION_EMAIL " )) . "\" --mail-rcpt \"" .
96- $ this ->obj ->to . "\" -T " . $ file . " 2>&1 " ;
97- $ output = shell_exec ($ command );
101+ $ output = Command::runLiman ("curl -s -v --connect-timeout 15 \"smtp://{:mail_host}:{:mail_port} \" -u \"{:mail_username}:{:mail_password} \" --mail-from \"{:mail_from} \" --mail-rcpt \"{:mail_receipt} \" -T {:file} 2>&1 " , [
102+ "mail_host " => trim (env ("MAIL_HOST " )),
103+ "mail_port " => trim (env ("MAIL_PORT " )),
104+ "mail_username " => trim (env ("MAIL_USERNAME " )),
105+ "mail_password " => trim (env ("MAIL_PASSWORD " )),
106+ "mail_from " => trim (env ("APP_NOTIFICATION_EMAIL " )),
107+ "mail_receipt " => trim ($ this ->obj ->to ),
108+ "file " => $ file
109+ ]);
98110 if (env ("MAIL_DEBUG " )) {
99111 echo "---BEGIN--- \n$ command \n$ output \n---END--- \n" ;
100112 }
0 commit comments