コード例 #1
0
    # Work out the from and to range based on the provided period in days.
    $start = time() - 60 * 60 * 24 * $period;
    $from_y = date("Y", $start);
    $from_m = date("m", $start);
    $from_d = date("d", $start);
    $to_y = date("Y");
    $to_m = date("m");
    $to_d = date("d");
}
$from = getvalescaped("from", "");
$to = getvalescaped("to", "");
$output = "";
# Execute report.
if ($report != "" && getval("createemail", "") == "") {
    $download = getval("download", "") != "";
    $output = do_report($report, $from_y, $from_m, $from_d, $to_y, $to_m, $to_d, $download);
}
include "../../include/header.php";
if (getval("createemail", "") != "") {
    # Create a new periodic e-mail report
    create_periodic_email($userref, $report, $period, getval("email_days", ""), getval("send_all_users", "") == "yes");
    ?>
	<script type="text/javascript">
	alert("<?php 
    echo $lang["newemailreportcreated"];
    ?>
");
	</script>
	<?php 
}
$unsubscribe = getvalescaped("unsubscribe", "");
コード例 #2
0
ファイル: amazon.php プロジェクト: rrecurse/IntenseCart
// Select the proper Amazon MWS URL.
if ($region == 'ca') {
    $serviceUrl = "https://mws.amazonservices.ca";
} else {
    $serviceUrl = "https://mws.amazonservices.com";
}
// Create service that connects to the Amazon MWS.
$config = array('ServiceURL' => $serviceUrl, 'ProxyHost' => null, 'ProxyPort' => -1, 'MaxErrorRetry' => 3);
$service = new MarketplaceWebService_Client($Creds['access_key'], $Creds['secret_key'], $config, 'IntenseCart Amazon Plugin Installer', '1.0');
// Request the initial inventory report, if it hasn't been done.
if (!is_file(CACHE_REQ_FILE . $region) && !is_file(CACHE_REP_FILE . $region)) {
    do_request($service, $region, $Creds);
}
// Wait for the Amazon reports to be generated, and parse them.
if (is_file(CACHE_REQ_FILE . $region)) {
    $runtime = do_report($service, $region, $Creds);
    // Show "waiting" page.
    write_waiting($runtime);
    die;
}
// Show and parse the matching form for products.
if (is_file(CACHE_REP_FILE . $region)) {
    echo do_match($region);
    die;
}
/**
 * Shows and parses the product matching form.
 *
 * @param string $region
 * @return string
 */
コード例 #3
0
function send_periodic_report_emails()
{
    # For all configured periodic reports, send a mail if necessary.
    global $lang, $baseurl;
    # Query to return all 'pending' report e-mails, i.e. where we haven't sent one before OR one is now overdue.
    $reports = sql_query("select pe.*,u.email,r.name,pe.send_all_users from report_periodic_emails pe join user u on pe.user=u.ref join report r on pe.report=r.ref where pe.last_sent is null or date_add(pe.last_sent,interval pe.email_days day)<=now()");
    foreach ($reports as $report) {
        $start = time() - 60 * 60 * 24 * $report["period"];
        $from_y = date("Y", $start);
        $from_m = date("m", $start);
        $from_d = date("d", $start);
        $to_y = date("Y");
        $to_m = date("m");
        $to_d = date("d");
        # Translates the report name.
        $report["name"] = lang_or_i18n_get_translated($report["name"], "report-");
        # Generate remote HTML table.
        $output = do_report($report["report"], $from_y, $from_m, $from_d, $to_y, $to_m, $to_d, false, true);
        # Formulate a title
        $title = $report["name"] . ": " . str_replace("?", $report["period"], $lang["lastndays"]);
        # Send mail to original user - this contains the unsubscribe link
        $unsubscribe = "<br>" . $lang["unsubscribereport"] . "<br>" . $baseurl . "/?ur=" . $report["ref"];
        $email = $report["email"];
        echo $lang["sendingreportto"] . " " . $email . "<br>" . $output . $unsubscribe . "<br>";
        send_mail($email, $title, $output . $unsubscribe, "", "", "", null, "", "", true);
        # Send to all other active users, if configured.
        if ($report["send_all_users"]) {
            # Send the report to all active users.
            $users = get_users();
            foreach ($users as $user) {
                $email = $user["email"];
                if ($user["approved"] && $email != $report["email"]) {
                    echo $lang["sendingreportto"] . " " . $email . "<br>" . $output . "<br>";
                    send_mail($email, $title, $output, "", "", "", null, "", "", true);
                }
            }
        }
        # Mark as done.
        sql_query("update report_periodic_emails set last_sent=now() where ref='" . $report["ref"] . "'");
    }
}
コード例 #4
0
function send_periodic_report_emails()
{
    # For all configured periodic reports, send a mail if necessary.
    global $lang, $baseurl;
    # Query to return all 'pending' report e-mails, i.e. where we haven't sent one before OR one is now overdue.
    $query = "\n\t\tSELECT pe.*,\n\t\t       u.email,\n\t\t       r.name\n\t\t  FROM report_periodic_emails pe\n\t\t  JOIN user u ON pe.user = u.ref\n\t\t  JOIN report r ON pe.report = r.ref\n\t\t WHERE pe.last_sent IS NULL\n\t\t    OR date_add(date(pe.last_sent), INTERVAL pe.email_days DAY) <= date(now());\n\t";
    $reports = sql_query($query);
    foreach ($reports as $report) {
        $start = time() - 60 * 60 * 24 * $report["period"];
        $from_y = date("Y", $start);
        $from_m = date("m", $start);
        $from_d = date("d", $start);
        $to_y = date("Y");
        $to_m = date("m");
        $to_d = date("d");
        # Translates the report name.
        $report["name"] = lang_or_i18n_get_translated($report["name"], "report-");
        # Generate remote HTML table.
        $output = do_report($report["report"], $from_y, $from_m, $from_d, $to_y, $to_m, $to_d, false, true);
        # Formulate a title
        $title = $report["name"] . ": " . str_replace("?", $report["period"], $lang["lastndays"]);
        # Send mail to original user - this contains the unsubscribe link
        # Note: this is basically the only way at the moment to delete a periodic report
        $delete_link = sprintf('<br />%s<br />%s/?dr=%s', $lang['report_delete_periodic_email_link'], $baseurl, $report['ref']);
        $unsubscribe = "<br>" . $lang["unsubscribereport"] . "<br>" . $baseurl . "/?ur=" . $report["ref"];
        $email = $report["email"];
        // Check user unsubscribed from this report
        $query = sprintf('
				SELECT true as `value`
				  FROM report_periodic_emails_unsubscribe
				 WHERE user_id = "%s"
				   AND periodic_email_id = "%s";
			', $report['user'], $report['ref']);
        $unsubscribed_user = sql_value($query, false);
        if (!$unsubscribed_user) {
            echo $lang["sendingreportto"] . " " . $email . "<br>" . $output . $delete_link . $unsubscribe . "<br>";
            send_mail($email, $title, $output . $delete_link . $unsubscribe);
        }
        // Jump to next report if this should only be sent to one user
        if (!$report['send_all_users'] && empty($report['user_groups'])) {
            # Mark as done.
            sql_query('UPDATE report_periodic_emails set last_sent = now() where ref = "' . $report['ref'] . '";');
            continue;
        }
        # Send to all other active users, if configured.
        # Send the report to all active users.
        $users = get_users();
        // Send e-mail reports to users belonging to the specific user groups
        if (!empty($report['user_groups'])) {
            $users = get_users($report['user_groups']);
        }
        foreach ($users as $user) {
            $email = $user['email'];
            # Do not send to original report user, as they receive the mail with the unsubscribe link above.
            if ($user['approved'] && $email == $report['email'] || !$user['approved']) {
                continue;
            }
            // Check user unsubscribed from this report
            $query = sprintf('
					SELECT true as `value`
					  FROM report_periodic_emails_unsubscribe
					 WHERE user_id = "%s"
					   AND periodic_email_id = "%s";
				', $user['ref'], $report['ref']);
            $unsubscribed_user = sql_value($query, false);
            if (!$unsubscribed_user) {
                $unsubscribe_link = sprintf('<br />%s<br />%s/?ur=%s', $lang['unsubscribereport'], $baseurl, $report['ref']);
                echo $lang["sendingreportto"] . " " . $email . "<br>" . $output . $unsubscribe_link . "<br>";
                send_mail($email, $title, $output . $unsubscribe_link);
            }
        }
        # Mark as done.
        sql_query('UPDATE report_periodic_emails set last_sent = now() where ref = "' . $report['ref'] . '";');
    }
}