Files
portal_v3/admin/services/stripe/app1/server/run.php
equippedcoding-master e2c98790b2 initial commit
2025-09-17 09:37:06 -05:00

111 lines
4.2 KiB
PHP

<?php
$param1 = $argv[1];
function _sendEmail($param2,$param3 ){
$config_domain = __get_main_configurations();
$managed_domain = $config_domain["managed_domain"];
$config = $config_domain["configurations"];
// echo json_encode($config);
// echo json_encode($GLOBALS) . "\n";
// echo $_ENV['MY_HOST'] . "\n";
$integration = GetActiveEmailIntegration($config);
if($integration==null){
EchoJsonResponse("Email integration is null!");
return;
}
$otherdata = json_decode(file_get_contents($param3), true);
$otherdata["mail_handlers"]["email_response"]["integration"] = $integration;
$otherdata["mail_handlers"]["email_confirm"]["integration"] = $integration;
$otherdata["mail_handlers"]["email_alert"]["integration"] = $integration;
Utils_WriteFile("/mnt/appfactorystudio/tmp/tmpfile1.json",$otherdata);
SendEmailBuilder($otherdata["mail_handlers"]["email_response"],$managed_domain, function($resp1) use($otherdata,$managed_domain) {
Utils_WriteFile("/mnt/appfactorystudio/tmp/tmpfile2.json",$resp1);
SendEmailBuilder($otherdata["mail_handlers"]["email_confirm"],$managed_domain, function($resp2) use($otherdata,$managed_domain,$resp1){
Utils_WriteFile("/mnt/appfactorystudio/tmp/tmpfile2.json",$resp2);
SendEmailBuilder($otherdata["mail_handlers"]["email_alert"],$managed_domain, function($resp3) use($otherdata,$managed_domain,$resp1,$resp2){
// EchoJsonObject(["resp1" => $resp1, "resp2" => $resp2]);
Utils_WriteFile("/mnt/appfactorystudio/tmp/tmpfile3.json",$resp3);
});
});
});
// $db = new DB();
// $rows = $db->query("SELECT * FROM general_data_storage WHERE name='$param2'",[],PDO::FETCH_ASSOC);
// if($rows->count() > 0){
// $mydata = $rows->results()[0];
// $mydata["json"] = html_entity_decode($mydata["json"]);
// $otherdata = json_decode($mydata["json"], true);
// $otherdata["mail_handlers"]["email_response"]["integration"] = $integration;
// $otherdata["mail_handlers"]["email_confirm"]["integration"] = $integration;
// // EchoJsonObject(["data" => json_last_error(), "param" => $param2, "count" => $rows->count()]);
// SendEmailBuilder($otherdata["mail_handlers"]["email_response"],$managed_domain, function($resp1) use($otherdata,$managed_domain) {
// SendEmailBuilder($otherdata["mail_handlers"]["email_confirm"],$managed_domain, function($resp2) use($otherdata,$managed_domain,$resp1){
// EchoJsonObject(["mail_handlers" => $otherdata, "resp1" => $resp1, "resp2" => $resp2]);
// });
// });
// // EchoJsonResponse("Sending...");
// }else{
// EchoJsonResponse("No record found");
// }
// $db = null;
}
function _sendEmail2($param2,$param3 ){
$config_domain = __get_main_configurations();
$managed_domain = $config_domain["managed_domain"];
$config = $config_domain["configurations"];
$integration = GetActiveEmailIntegration($config);
if($integration==null){
EchoJsonResponse("Email integration is null!");
return;
}
$otherdata = json_decode(file_get_contents($param3), true);
foreach ($otherdata["mail_handlers"] as $key => $value) {
// $value[$key]["integration"] = $integration;
$otherdata["mail_handlers"][$key]["integration"] = $integration;
$mail = $otherdata["mail_handlers"][$key];
SendEmailBuilder($mail,$managed_domain, function($resp) use($otherdata,$managed_domain,$key){
EchoJsonObject(["resp1" => $resp["emails"]]);
});
}
}
if($param1=="send_email"){
require dirname( __DIR__,4 ) . "/core/api/php/includes/init.php";
require dirname( __DIR__,4 ) . "/core/api/php/includes/functions.php";
$param2 = $argv[2];
$param3 = $argv[3];
_sendEmail($param2,$param3);
}
if($param1=="send_email2"){
require dirname( __DIR__,4 ) . "/core/api/php/includes/init.php";
require dirname( __DIR__,4 ) . "/core/api/php/includes/functions.php";
$param2 = $argv[2];
$param3 = $argv[3];
_sendEmail2($param2,$param3);
}