0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
marketting
/
system
/
application
/
controllers
/
[
Home
]
File: cron.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /* | ------------------------------------------------------------------------- | COPYRIGHT NOTICE | Copyright 2008 JROX Technologies, Inc. All Rights Reserved. | ------------------------------------------------------------------------- | This script may be only used and modified in accordance to the license | agreement attached (license.txt) except where expressly noted within | commented areas of the code body. This copyright notice and the | comments above and below must remain intact at all times. By using this | code you agree to indemnify JROX Technologies, Inc, its corporate agents | and affiliates from any liability that might arise from its use. | | Selling the code for this program without prior written consent is | expressly forbidden and in violation of Domestic and International | copyright laws. | | ------------------------------------------------------------------------- | FILENAME - cron.php | ------------------------------------------------------------------------- | | This controller file runs all necessary cron jobs for the system | */ class Cron extends Cron_Controller { function __construct() { parent::Cron_Controller(); set_time_limit(0); } // ------------------------------------------------------------------------ function send_email() { //set data array $data = $this->security_model->_load_config('cron'); $txt = ''; $this->load->model('emailing_model'); //queue follow ups $this->load->model('mailing_lists_model'); $msg = $this->emailing_model->_queue_follow_ups(); if (!empty($msg)) { //log success log_message('info', $msg); $txt .= $msg . "\n"; } $msg = $this->emailing_model->_flush_queue('date'); if (!empty($msg)) { //log success log_message('info', $msg); $txt .= $msg . "emails flushed from queue \n"; } echo nl2br($txt); } // ------------------------------------------------------------------------ function generate_member_coupons() { //set data array $data = $this->security_model->_load_config('cron'); /* |---------------------- | run generate coupons |---------------------- */ $this->load->model('members_model'); $this->load->model('coupons_model'); $this->coupons_model->_auto_generate_credit_coupons(); } // ------------------------------------------------------------------------ function bounce() { //set data array $data = $this->security_model->_load_config('cron'); $this->load->model('bounce_model'); $msg = $this->bounce_model->_process_bounced_emails(); if (!empty($msg)) { //log success log_message('info', $msg); echo $msg; } } // ------------------------------------------------------------------------ function notify() { /* |--------------------------------- | notify content update services |--------------------------------- */ //set data array $data = $this->security_model->_load_config('cron'); $this->load->model('xml_rpc_model'); $this->load->model('content_model'); $sdata = $this->content_model->_get_content_notification(); //check ping.fm services if ($this->config->item('sts_content_enable_ping_fm') == 1) { //initialize PingFM class require_once(APPPATH.'/libraries/PingFM.php'); } if (!empty($sdata)) { $total = 0; foreach ($sdata as $row) { $this->xml_rpc_model->_notify_update_services($row); //check ping.fm services if ($this->config->item('sts_content_enable_ping_fm') == 1) { $this->PingFM = new PingFM(JEM_PING_FM_DEVELOPER_KEY, $this->config->item('sts_content_ping_fm_app_key')); if (!empty($row['status_update'])) { $status_text = $row['status_update'] . ' ' . $row['url']; } else { $status_text = $row['content_title'] . ' ' . $row['url']; } $posted = $this->PingFM->post("microblog", $status_text); } $this->content_model->_update_ping($row['article_id']); $total++; sleep(400); } if (!empty($msg)) { //log success log_message('info', $msg . ' articles sent to update services'); } } } // ------------------------------------------------------------------------ function process_recurring() { /* |------------------------ | pay unpaid invoices |------------------------ */ //set data array $data = $this->security_model->_load_config('cron'); $this->load->model('invoices_model'); $this->load->model('modules_model'); $this->load->model('emailing_model'); $this->load->model('commissions_model'); $this->load->model('downline_model'); $this->load->model('members_model'); //set currency $site_currency = get_site_currency(); $num_options = get_default_currency($site_currency['settings_value']); //load the payment gateway model $this->load->model('modules/module_payment_gateway_' . $this->uri->segment(4) . '_model', 'gateway'); $this->load->helper('country_helper'); //get recurring invoices $invoices = $this->invoices_model->_get_recurring_invoices($this->uri->segment(4)); //charge each invoice if (!empty($invoices)) { $send_inv_email = "Payments Processed for " . date ('M d Y') . "\n\n"; $send_inv_email .= "=============================================\n\n"; foreach ($invoices as $invoice) { //charge each invoice separately $results = $this->gateway->_run_recurring_payment($invoice); if (empty($results['jrox_error'])) { //mark invoice as paid //add the payment $payment_array = array( 'invoice_id' => $invoice['invoice_id'], 'payment_date' => date('m/d/Y'), 'payment_amount' => $results['jrox_payment_amount'], 'transaction_id' => $results['jrox_trans_id'], 'payment_method' => $results['jrox_payment_method'], 'payment_type' => 'credit', 'payment_notes' => '', 'debug_info' => $results['jrox_debug_info'] ); $sdata = $this->invoices_model->_add_payment($invoice['invoice_id'], $payment_array); //update membership with subscription ID $a['jrox_subscription_id'] = $results['jrox_trans_id']; $this->members_model->_append_membership($invoice['member_id'], $invoice['product_id'], $a, $invoice['invoice_id']); //get all admins for sending out admin alerts $this->load->model('admins_model'); $admin_users = $this->admins_model->_get_all_admins(); //generate commmissions if any //generate the downline array of members $members = $this->downline_model->_get_upline($sdata['inv']['referrer_id']); $this->commissions_model->_generate_commissions($sdata, $invoice['member_id'], $admin_users, $num_options, $members); $send_inv_email .= "Successful Payment for Invoice ID " . $invoice['invoice_id'] . "; Amount: " . $results['jrox_payment_amount'] . " Transaction ID: " . $results['jrox_trans_id'] . "\n"; $send_inv_email .= "=============================================\n\n"; } else { $send_inv_email .= "Error Processing Payment for Invoice ID " . $invoice['invoice_id'] . "; Error Message: " . $results['jrox_error_message'] . "\n"; $send_inv_email .= "=============================================\n\n"; } } } if ($this->config->item('cron_send_recurring_payment_info_email')) { //SEND EMAIL mail($this->config->item('sts_sec_admin_failed_login_email'), 'Payments Processed for ' . date('M d Y'), $send_inv_email, 'From: ' . $this->config->item('sts_store_email')); } } // ------------------------------------------------------------------------ function process() { //set data array $data = $this->security_model->_load_config('cron'); $this->load->model('emailing_model'); $this->load->model('mailing_lists_model'); $txt = ''; /* |------------------------ | run invoice generation |------------------------ */ if ($this->config->item('sts_invoice_enable_auto_generate_invoice') == 1) { $this->load->model('invoices_model'); $this->load->model('members_model'); $this->load->model('coupons_model'); $msg = $this->invoices_model->_generate_invoices($this->config->item('sts_invoice_auto_generate_invoice_day')); if (!empty($msg)) { //log success log_message('info', $msg); $txt .= $msg . "\n"; } } /* |-------------------------- | auto prune email archive |-------------------------- */ if ($this->config->item('sts_email_auto_prune_archive') != '0') { $msg = $this->emailing_model->_auto_prune_archive($this->config->item('sts_email_auto_prune_archive')); if (!empty($msg)) { //log success log_message('info', $msg); $txt .= $msg . "\n"; } } /* |-------------------------- | auto approve commissions |-------------------------- */ if ($this->config->item('sts_affiliate_auto_approve_commissions') != '0') { $this->load->model('commissions_model'); $msg = $this->commissions_model->_auto_approve_commissions($this->config->item('sts_affiliate_auto_approve_commissions')); if (!empty($msg)) { //log success log_message('info', $msg); $txt .= $msg . "\n"; } } /* |---------------------------- | auto close support tickets |---------------------------- */ $this->load->model('support_model'); $msg = $this->support_model->_auto_close_tickets(); if (!empty($msg)) { //log success log_message('info', $msg); $txt .= $msg . "\n"; } /* |------------------------------ | prune ad tracking referrals |------------------------------ */ $track_days = $this->config->item('sts_tracking_auto_prune_days'); if (!empty($track_days)) { $this->load->model('tracking_model'); $msg = $this->tracking_model->_prune_ad_trackers($this->config->item('sts_tracking_auto_prune_days')); if (!empty($msg)) { log_message('info', $msg); $txt .= $msg . "\n"; } } /* |------------------------------ | optimize the database tables |------------------------------ */ $this->load->dbutil(); if ($this->dbutil->optimize_database()) { log_message('info', 'database optimized successfully'); $txt .= "database optimized successfully\n"; } /* |---------------------- | run database backup |---------------------- */ $this->load->model('backup_model'); $msg = $this->backup_model->_backup_db(); if (!empty($msg)) { //log success log_message('info', $msg . ' backup file created successfully'); $txt .= "backup file created successfully\n"; } echo nl2br($txt); } } ?>