コード例 #1
0
ファイル: cron_nonpayers.php プロジェクト: whedro/vpsadmin
include WWW_ROOT . 'lib/db.lib.php';
include WWW_ROOT . 'lib/functions.lib.php';
include WWW_ROOT . 'lib/transact.lib.php';
include WWW_ROOT . 'lib/vps.lib.php';
include WWW_ROOT . 'lib/members.lib.php';
include WWW_ROOT . 'lib/networking.lib.php';
include WWW_ROOT . 'lib/version.lib.php';
include WWW_ROOT . 'lib/cluster.lib.php';
include WWW_ROOT . 'lib/mail.lib.php';
$db = new sql_db(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$nonpayers = "<table cellspacing=\"0\" cellpadding=\"6\" border=\"1\">\n";
$nonpayers .= "\t<tr>\n";
$nonpayers .= "\t\t<th>" . _("Nickname") . "</th>\n\t\t<th>" . _("Expiration") . "</th>\n\t\t<th>" . _("Info") . "</th>\n";
$nonpayers .= "\t</tr>\n";
$whereCond = "m_state != 'deleted' AND m_paid_until IS NOT NULL AND m_paid_until != '' AND ADDDATE(FROM_UNIXTIME(m_paid_until), INTERVAL 14 DAY) < NOW()";
while ($m = $db->find("members", $whereCond, "FROM_UNIXTIME(m_paid_until)")) {
    $member = member_load($m["m_id"]);
    $nonpayers .= "\t<tr>\n";
    $nonpayers .= "\t\t<td>" . $member->m["m_nick"] . "</td>\n";
    $nonpayers .= "\t\t<td>" . strftime("%Y-%m-%d %H:%M", $member->m["m_paid_until"]) . " (" . round(($member->m["m_paid_until"] - time()) / 60 / 60 / 24) . ")</td>\n";
    $nonpayers .= "\t\t<td>" . $member->m["m_info"] . "</td>\n";
    $nonpayers .= "\t</tr>\n";
}
$nonpayers .= "</table>\n";
$neverpaid = "<table cellspacing=\"0\" cellpadding=\"6\" border=\"1\">\n";
$neverpaid .= "\t<tr>\n";
$neverpaid .= "\t\t<th>" . _("Nickname") . "</th>\n\t\t<th>" . _("Created") . "</th>\n\t\t<th>" . _("Info") . "</th>\n";
$neverpaid .= "\t</tr>\n";
$whereCond = "m_state != 'deleted' AND (m_paid_until IS NULL OR m_paid_until = '') AND ADDDATE(FROM_UNIXTIME(m_created), INTERVAL 7 DAY) < NOW()";
while ($m = $db->find("members", $whereCond, "m_created")) {
    $member = member_load($m["m_id"]);
コード例 #2
0
ファイル: cron_mailer.php プロジェクト: whedro/vpsadmin
$_SESSION["is_admin"] = true;
define('CRON_MODE', true);
define('DEMO_MODE', false);
// Include libraries
include WWW_ROOT . 'lib/db.lib.php';
include WWW_ROOT . 'lib/functions.lib.php';
include WWW_ROOT . 'lib/transact.lib.php';
include WWW_ROOT . 'lib/vps.lib.php';
include WWW_ROOT . 'lib/members.lib.php';
include WWW_ROOT . 'lib/networking.lib.php';
include WWW_ROOT . 'lib/version.lib.php';
include WWW_ROOT . 'lib/cluster.lib.php';
include WWW_ROOT . 'lib/mail.lib.php';
$db = new sql_db(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$whereCond = "m_mailer_enable = 1 AND m_state != 'deleted'";
while ($m = $db->find("members", $whereCond)) {
    $member = member_load($m["m_id"]);
    if ($member->m["m_paid_until"] - time() <= 604800) {
        $subject = $cluster_cfg->get("mailer_tpl_payment_warning_subj");
        $subject = str_replace("%member%", $m["m_nick"], $subject);
        $content = $cluster_cfg->get("mailer_tpl_payment_warning");
        $content = str_replace("%member%", $m["m_nick"], $content);
        $content = str_replace("%memberid%", $m["m_id"], $content);
        $content = str_replace("%expiredate%", $m["m_paid_until"] ? strftime("%Y-%m-%d", $m["m_paid_until"]) : '---', $content);
        $content = str_replace("%monthly%", $m["m_monthly_payment"], $content);
        send_mail($m["m_mail"], $subject, $content, $cluster_cfg->get("mailer_admins_in_cc") ? explode(",", $cluster_cfg->get("mailer_admins_cc_mails")) : array());
    }
}
$rs = $db->query("SELECT v.vps_id, vps_expiration, m_nick, m_mail FROM vps v\n                  INNER JOIN members m ON v.m_id = m.m_id\n                  WHERE m_mailer_enable = 1\n                    AND vps_expiration IS NOT NULL\n                    AND vps_deleted IS NULL\n                    AND DATE_SUB(FROM_UNIXTIME(vps_expiration), INTERVAL 7 DAY) < NOW()\n                    AND FROM_UNIXTIME(vps_expiration) > NOW()");
while ($row = $db->fetch_array($rs)) {
    $subject = $cluster_cfg->get("mailer_tpl_vps_expiration_subj");