# Campaign Continues # Reset All Data and Update New Cron Date # New Launch Date $genDate = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s") . " +" . $opArDataRs['ar_time'] . " " . $opArDataRs['ar_time_type'] . "")); # New Finish Date $difference = dateDiff(strtotime($opCampRs['launch_date']), strtotime($opArDataRs['ar_end_date'])); $genFinDate = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s") . " +" . $difference . "")); $myconn->query("UPDATE " . db_table_pref . "campaigns SET campaign_pos=0,launch_date='" . $genDate . "' WHERE OID=" . $orgSets['set_ID'] . " AND ID = " . $opCampRs['ID'] . "") or die(mysqli_error($myconn)); $myconn->query("UPDATE " . db_table_pref . "campaign_ar SET ar_end_date='" . $genFinDate . "' WHERE OID=" . $orgSets['set_ID'] . " AND CID = " . $opCampRs['ID'] . "") or die(mysqli_error($myconn)); # Remove Old Cron $myconn->query("UPDATE " . db_table_pref . "chronos SET pos=1 WHERE OID=" . $orgSets['set_ID'] . " AND CID = " . $opCampRs['ID'] . "") or die(mysqli_error($myconn)); # Add New Cron $buildCron = new lethe(); $buildCron->chronosMin = "*"; $buildCron->chronosURL = "'" . lethe_root_url . 'chronos/lethe.tasks.php?ID=' . $opCampRs['ID'] . "' > /dev/null 2>&1"; $genComm = $buildCron->buildChronos(); $addCron = $myconn->prepare("INSERT INTO " . db_table_pref . "chronos SET OID=" . $orgSets['set_ID'] . ", CID=" . $opCampRs['ID'] . ", pos=0, cron_command=?, launch_date=?"); $addCron->bind_param('ss', $genComm, $genDate); $addCron->execute(); $addCron->close(); # Remove Datas $myconn->query("DELETE FROM " . db_table_pref . "tasks WHERE OID=" . $orgSets['set_ID'] . " AND CID = " . $opCampRs['ID'] . "") or die(mysqli_error($myconn)); $myconn->query("DELETE FROM " . db_table_pref . "reports WHERE OID=" . $orgSets['set_ID'] . " AND CID = " . $opCampRs['ID'] . "") or die(mysqli_error($myconn)); # Close Phase For New Settings die; } # AR 2 Settings End } # ------- Settings will apply after all tasks done ----- } else { # If Position is Pending Turn it to In Progress
public function addSubAccount() { global $myconn; global $LETHE_BOUNCE_TYPES; /* General */ if (!isset($_POST['acc_title']) || empty($_POST['acc_title'])) { $this->errPrint .= '* ' . settings_please_enter_a_account_title . '<br>'; } if (!isset($_POST['daily_limit']) || !is_numeric($_POST['daily_limit'])) { $this->errPrint .= '* ' . settings_please_enter_a_daily_limit . '<br>'; } if (!isset($_POST['spec_limit_range']) || !is_numeric($_POST['spec_limit_range'])) { $_POST['spec_limit_range'] = 1440; } if (!isset($_POST['send_per_conn']) || !is_numeric($_POST['send_per_conn'])) { $this->errPrint .= '* ' . settings_please_enter_a_per_connection_limit . '<br>'; } if (!isset($_POST['standby_time']) || !is_numeric($_POST['standby_time'])) { $this->errPrint .= '* ' . settings_please_enter_a_standby_limit . '<br>'; } if (isset($_POST['systemAcc']) && $_POST['systemAcc'] == 'YES') { $systemAcc = 1; } else { $systemAcc = 0; } if (isset($_POST['debug']) && $_POST['debug'] == 'YES') { $isDebug = 1; } else { $isDebug = 0; } if (isset($_POST['active']) && $_POST['active'] == 'YES') { $isActive = 1; } else { $isActive = 0; } /* Sending */ if (!isset($_POST['from_title']) || empty($_POST['from_title'])) { $this->errPrint .= '* ' . settings_please_enter_a_sender_title . '<br>'; } if (!isset($_POST['from_mail']) || !mailVal($_POST['from_mail'])) { $this->errPrint .= '* ' . settings_invalid_sender_mail . '<br>'; } if (!isset($_POST['reply_mail']) || !mailVal($_POST['reply_mail'])) { $this->errPrint .= '* ' . settings_invalid_reply_mail . '<br>'; } if (!isset($_POST['test_mail']) || !mailVal($_POST['test_mail'])) { $this->errPrint .= '* ' . settings_invalid_test_mail . '<br>'; } if (!isset($_POST['mail_type']) || !is_numeric($_POST['mail_type'])) { $this->errPrint .= '* ' . settings_please_choose_a_mail_content_type . '<br>'; } if (!isset($_POST['send_method']) || !is_numeric($_POST['send_method'])) { $this->errPrint .= '* ' . settings_please_choose_a_sending_method . '<br>'; } if (!isset($_POST['mail_engine']) || empty($_POST['mail_engine'])) { $this->errPrint .= '* ' . settings_please_choose_a_mail_engine . '<br>'; } /* Connection SMTP */ if (isset($_POST['send_method']) && intval($_POST['send_method']) == 0) { if (!isset($_POST['smtp_host']) || empty($_POST['smtp_host'])) { $this->errPrint .= '* ' . settings_please_enter_a_smtp_server . '<br>'; } if (!isset($_POST['smtp_port']) || empty($_POST['smtp_port'])) { $this->errPrint .= '* ' . settings_please_enter_a_smtp_port . '<br>'; } if (!isset($_POST['smtp_user']) || empty($_POST['smtp_user'])) { $this->errPrint .= '* ' . settings_please_enter_a_smtp_username . '<br>'; } if (!isset($_POST['smtp_pass']) || empty($_POST['smtp_pass'])) { $this->errPrint .= '* ' . settings_please_enter_a_smtp_password . '<br>'; } if (!isset($_POST['smtp_secure']) || !is_numeric($_POST['smtp_secure'])) { $this->errPrint .= '* ' . settings_please_choose_a_smtp_encryption . '<br>'; } } else { $_POST['smtp_host'] = ''; $_POST['smtp_port'] = 0; $_POST['smtp_user'] = ''; $_POST['smtp_pass'] = ''; $_POST['smtp_secure'] = 0; } # PHP Mail if (isset($_POST['send_method']) && intval($_POST['send_method']) == 1) { if (!function_exists('mail')) { $this->errPrint .= '* Server does not support PHP mail() !<br>'; } } # AWS if (isset($_POST['send_method']) && intval($_POST['send_method']) == 2) { if (!isset($_POST['aws_acc_key']) || empty($_POST['aws_acc_key'])) { $this->errPrint .= '* ' . settings_please_enter_aws_access_key . '<br>'; } if (!isset($_POST['aws_sec_key']) || empty($_POST['aws_sec_key'])) { $this->errPrint .= '* ' . settings_please_enter_aws_secret_key . '<br>'; } } else { $_POST['aws_acc_key'] = ''; $_POST['aws_sec_key'] = ''; } # Mandrill if (isset($_POST['send_method']) && intval($_POST['send_method']) == 3) { if (!isset($_POST['mandrill_user']) || empty($_POST['mandrill_user'])) { $this->errPrint .= '* ' . settings_please_enter_a_mandrill_username . '<br>'; } if (!isset($_POST['mandrill_key']) || empty($_POST['mandrill_key'])) { $this->errPrint .= '* ' . settings_please_enter_a_mandrill_key . '<br>'; } } else { $_POST['mandrill_user'] = ''; $_POST['mandrill_key'] = ''; } # SendGrid if (isset($_POST['send_method']) && intval($_POST['send_method']) == 4) { if (!isset($_POST['sendgrid_user']) || empty($_POST['sendgrid_user'])) { $this->errPrint .= '* ' . settings_please_enter_a_sendgrid_username . '<br>'; } if (!isset($_POST['sendgrid_pass']) || empty($_POST['sendgrid_pass'])) { $this->errPrint .= '* ' . settings_please_enter_a_sendgrid_password . '<br>'; } } else { $_POST['sendgrid_user'] = ''; $_POST['sendgrid_pass'] = ''; } if (!isset($_POST['pop3_host']) || empty($_POST['pop3_host'])) { $this->errPrint .= '* ' . settings_please_enter_a_pop3_server . '<br>'; } if (!isset($_POST['pop3_port']) || empty($_POST['pop3_port'])) { $this->errPrint .= '* ' . settings_please_enter_a_pop3_port . '<br>'; } if (!isset($_POST['pop3_user']) || empty($_POST['pop3_user'])) { $this->errPrint .= '* ' . settings_please_enter_a_pop3_username . '<br>'; } if (!isset($_POST['pop3_pass']) || empty($_POST['pop3_pass'])) { $this->errPrint .= '* ' . settings_please_enter_a_pop3_password . '<br>'; } if (!isset($_POST['pop3_secure']) || !is_numeric($_POST['pop3_secure'])) { $this->errPrint .= '* ' . settings_please_choose_a_pop3_encryption . '<br>'; } if (!isset($_POST['imap_host']) || empty($_POST['imap_host'])) { $this->errPrint .= '* ' . settings_please_enter_a_imap_server . '<br>'; } if (!isset($_POST['imap_port']) || empty($_POST['imap_port'])) { $this->errPrint .= '* ' . settings_please_enter_a_imap_port . '<br>'; } if (!isset($_POST['imap_user']) || empty($_POST['imap_user'])) { $this->errPrint .= '* ' . settings_please_enter_a_imap_username . '<br>'; } if (!isset($_POST['imap_pass']) || empty($_POST['imap_pass'])) { $this->errPrint .= '* ' . settings_please_enter_a_imap_password . '<br>'; } if (!isset($_POST['imap_secure']) || !is_numeric($_POST['imap_secure'])) { $this->errPrint .= '* ' . settings_please_choose_a_imap_encryption . '<br>'; } if (isset($_POST['smtp_auth']) && $_POST['smtp_auth'] == 'YES') { $smtp_auth = 1; } else { $smtp_auth = 0; } if (!isset($_POST['bounce_acc']) || !is_numeric($_POST['bounce_acc'])) { $this->errPrint .= '* ' . settings_please_choose_a_bounce_connector . '<br>'; } /* DKIM */ if (isset($_POST['dkimactive']) && $_POST['dkimactive'] == 'YES') { $dkimactive = 1; if (!isset($_POST['dkimdomain']) || empty($_POST['dkimdomain'])) { $this->errPrint .= '* ' . settings_please_enter_a_dkim_domain . '<br>'; } if (!isset($_POST['dkimprivate']) || empty($_POST['dkimprivate'])) { $this->errPrint .= '* ' . settings_please_enter_a_dkim_private_key . '<br>'; } if (!isset($_POST['dkimselector']) || empty($_POST['dkimselector'])) { $this->errPrint .= '* ' . settings_please_enter_a_dkim_selector . '<br>'; } if (!isset($_POST['dkimpassphrase']) || empty($_POST['dkimpassphrase'])) { $this->errPrint .= '* ' . settings_please_enter_a_dkim_passphrase . '<br>'; } } else { $dkimactive = 0; $_POST['dkimdomain'] = ''; $_POST['dkimprivate'] = ''; $_POST['dkimselector'] = ''; $_POST['dkimpassphrase'] = ''; } /* Bounce Actions */ $bounceActions = array(); foreach ($LETHE_BOUNCE_TYPES as $k => $v) { if ($this->onInstall) { $frmAct = 1; } else { $frmAct = isset($_POST['bounces_' . $k]) && is_numeric($_POST['bounces_' . $k]) ? $_POST['bounces_' . $k] : 0; } $bounceActions[$k] = $frmAct; } $bounceActions = json_encode($bounceActions); if ($this->errPrint == '') { $account_id = encr(uniqid('lethe', true) . time() . rand()); $daily_date = date("Y-m-d H:i:s"); $daily_date = strtotime(date("Y-m-d H:i:s", strtotime($daily_date)) . " +" . $_POST['spec_limit_range'] . " minutes"); if ($systemAcc) { $myconn->query("UPDATE " . db_table_pref . "submission_accounts SET systemAcc=0 WHERE ID>0"); } $LTH = $myconn->prepare("INSERT INTO \n\t\t\t\t\t\t\t\t\t\t\t\t\t" . db_table_pref . "submission_accounts \n\t\t\t\t\t\t\t\t\t\t\t SET\n\t\t\t\t\t\t\t\t\t\t\t\t\tacc_title=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdaily_limit=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsend_per_conn=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tstandby_time=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsystemAcc=" . $systemAcc . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\tisDebug=" . $isDebug . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\tisActive=" . $isActive . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_title=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom_mail=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\treply_mail=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttest_mail=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tmail_type=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsend_method=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tmail_engine=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsmtp_host=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsmtp_port=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsmtp_user=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsmtp_pass=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsmtp_secure=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpop3_host=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpop3_port=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpop3_user=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpop3_pass=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpop3_secure=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\timap_host=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\timap_port=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\timap_user=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\timap_pass=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\timap_secure=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tsmtp_auth=" . $smtp_auth . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\tbounce_acc=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\taws_access_key=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\taws_secret_key=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdkim_active=" . $dkimactive . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\tdkim_domain=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdkim_private=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdkim_selector=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tdkim_passphrase=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\taccount_id='" . $account_id . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\tdaily_reset='" . date("Y-m-d H:i:s", $daily_date) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\tlimit_range=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbounce_actions=?\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t") or die(mysqli_error($myconn)); $LTH->bind_param('siiissssiississisissisissiissssssis', $_POST['acc_title'], $_POST['daily_limit'], $_POST['send_per_conn'], $_POST['standby_time'], $_POST['from_title'], $_POST['from_mail'], $_POST['reply_mail'], $_POST['test_mail'], $_POST['mail_type'], $_POST['send_method'], $_POST['mail_engine'], $_POST['smtp_host'], $_POST['smtp_port'], $_POST['smtp_user'], $_POST['smtp_pass'], $_POST['smtp_secure'], $_POST['pop3_host'], $_POST['pop3_port'], $_POST['pop3_user'], $_POST['pop3_pass'], $_POST['pop3_secure'], $_POST['imap_host'], $_POST['imap_port'], $_POST['imap_user'], $_POST['imap_pass'], $_POST['imap_secure'], $_POST['bounce_acc'], $_POST['aws_acc_key'], $_POST['aws_sec_key'], $_POST['dkimdomain'], $_POST['dkimprivate'], $_POST['dkimselector'], $_POST['dkimpassphrase'], $_POST['spec_limit_range'], $bounceActions); if ($LTH->execute()) { $subAccID = $myconn->insert_id; # Add Bounce Cron $buildCron = new lethe(); # Check every 5 min $buildCron->chronosMin = "*/5"; $buildCron->chronosURL = "'" . lethe_root_url . 'chronos/lethe.bounce.php?ID=' . $subAccID . "' > /dev/null 2>&1"; $genComm = $buildCron->buildChronos(); $genDate = date('Y-m-d H:i:s'); $addCron = $myconn->prepare("INSERT INTO " . db_table_pref . "chronos SET OID=" . set_org_id . ", SAID=" . $subAccID . ", pos=0, cron_command=?, launch_date=?"); $addCron->bind_param('ss', $genComm, $genDate); $addCron->execute(); $addCron->close(); } $LTH->close(); if (!$this->onInstall) { unset($_POST); } $this->errPrint = errMod('' . letheglobal_recorded_successfully . '!', 'success'); } else { $this->errPrint = errMod($this->errPrint, 'danger'); } }