コード例 #1
0
ファイル: cron_daily.php プロジェクト: istrwei/ISPCluster
                    $app->dbmaster->datalogUpdate('mail_user', "last_quota_notification = CURDATE()", 'mailuser_id', $rec['mailuser_id']);
                    $placeholders = array('{email}' => $rec['email'], '{admin_mail}' => $global_config['admin_mail'] != '' ? $global_config['admin_mail'] : 'root', '{used}' => $rec['used'], '{name}' => $rec['name'], '{quota}' => $rec['quota'], '{ratio}' => $rec['ratio']);
                    $recipients = array();
                    //* send email to admin
                    if ($global_config['admin_mail'] != '' && $mail_config['overquota_notify_admin'] == 'y') {
                        $recipients[] = $global_config['admin_mail'];
                    }
                    //* Send email to client
                    if ($mail_config['overquota_notify_client'] == 'y') {
                        $client_group_id = $rec["sys_groupid"];
                        $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = {$client_group_id}");
                        if ($client['email'] != '') {
                            $recipients[] = $client['email'];
                        }
                    }
                    send_notification_email('mail_quota_notification', $placeholders, $recipients);
                }
            }
        }
    }
}
//######################################################################################################
// deactivate virtual servers (run only on the "master-server")
//######################################################################################################
if ($app->dbmaster == $app->db) {
    $current_date = date('Y-m-d');
    //* Check which virtual machines have to be deactivated
    $sql = "SELECT * FROM openvz_vm WHERE active = 'y' AND active_until_date != '0000-00-00' AND active_until_date < '{$current_date}'";
    $records = $app->db->queryAllRecords($sql);
    if (is_array($records)) {
        foreach ($records as $rec) {
コード例 #2
0
ファイル: item_borrow.php プロジェクト: horrabin/opendb
/**
 */
function process_borrow_results($op, $mode, $heading, $success_intro, $failure_intro, $more_information, $success_item_rs, $failure_item_rs, $email_notification = TRUE)
{
    $titleMaskCfg = new TitleMask(array('item_borrow', 'item_display'));
    if (is_not_empty_array($success_item_rs)) {
        // Sort the items by user, so we can send emails for multiple
        // items, instead of individually.
        $borrowed_item_user_r = array();
        while (list(, $borrowed_item_r) = each($success_item_rs)) {
            $item_r = fetch_item_instance_r($borrowed_item_r['item_id'], $borrowed_item_r['instance_no']);
            $item_r['title'] = $titleMaskCfg->expand_item_title($item_r);
            $item_entry_r['display_title'] = get_opendb_lang_var('borrow_item_title_listing', array('display_title' => $item_r['title'], 'item_id' => $item_r['item_id'], 'instance_no' => $item_r['instance_no']));
            // A array of item_entries.
            //$item_entry_r['item'] = $item_r;
            $item_entry_r['detail'] = get_borrow_details($op, $item_r, $borrowed_item_r);
            // When reserving or cancelling and the current user is the borrower, we want to
            // send the email to the owner, in all other cases the email should go to the
            // borrower.
            if (($op == 'reserve' || $op == 'cancel_reserve') && get_opendb_session_var('user_id') == $borrowed_item_r['borrower_id']) {
                $to_user = $item_r['owner_id'];
            } else {
                $to_user = $borrowed_item_r['borrower_id'];
            }
            // Now add an entry to this user array.
            $borrowed_item_user_r[$to_user][] = $item_entry_r;
        }
        $success_results = array();
        while (list($to_user, $item_entry_rs) = each($borrowed_item_user_r)) {
            $errors = NULL;
            if (is_valid_opendb_mailer() && $email_notification !== FALSE) {
                // How can the from user be anything but the currently logged in user!
                $email_result = send_notification_email($to_user, get_opendb_session_var('user_id'), $heading, $success_intro, $more_information, $item_entry_rs, $errors);
            }
            $display_title_r = NULL;
            reset($item_entry_rs);
            while (list(, $item_entry_r) = each($item_entry_rs)) {
                $display_title_r[] = $item_entry_r['display_title'];
            }
            $user_name = get_opendb_lang_var('user_name', array('fullname' => fetch_user_name($to_user), 'user_id' => $to_user));
            $success_results_rs[] = array(user_name => $user_name, display_titles => $display_title_r, email_result => $email_result, email_errors => $errors);
        }
        if (is_not_empty_array($success_results_rs)) {
            if ($mode == 'job') {
                display_job_success_borrow_results($success_intro, $success_results_rs);
            } else {
                display_html_success_borrow_results($success_intro, $success_results_rs);
            }
        }
    }
    if (is_not_empty_array($failure_item_rs)) {
        $failure_results = array();
        while (list(, $borrowed_item_r) = each($failure_item_rs)) {
            $item_r = fetch_item_instance_r($borrowed_item_r['item_id'], $borrowed_item_r['instance_no']);
            // Expand title mask.
            $item_r['title'] = $titleMaskCfg->expand_item_title($item_r);
            $display_title = get_opendb_lang_var('borrow_item_title_listing', array('display_title' => $item_r['title'], 'item_id' => $item_r['item_id'], 'instance_no' => $item_r['instance_no']));
            // Now display any errors if present.
            if (strlen($borrowed_item_r['errors']) > 0) {
                $borrow_error_details = get_opendb_lang_var('borrow_error_detail', 'error', $borrowed_item_r['errors']);
            }
            $failure_results[] = array(display_title => $display_title, errors => array($borrow_error_details));
        }
        if (is_not_empty_array($failure_results)) {
            if ($mode == 'job') {
                display_job_failure_borrow_results($failure_intro, $failure_results);
            } else {
                display_html_failure_borrow_results($failure_intro, $failure_results);
            }
        }
    }
}