MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b744/yushibrentwood.com/mailhive/mailbeez/
File Upload :
Current < : /hermes/sb_web/b744/yushibrentwood.com/mailhive/mailbeez/service_db_optimize.php

<?php
/*
  MailBeez Automatic Trigger Email Campaigns
  http://www.mailbeez.com

  Copyright (c) 2010 MailBeez
	
	inspired and in parts based on
  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

	// make path work from admin
  require_once(DIR_FS_CATALOG. 'mailhive/common/classes/mailbeez.php');	
	
	// could be in language-file
	// just easier to define it in the mailbee
	define('MAILBEEZ_SERVICE_DB_OPTIMIZE_TEXT_TITLE', 'Service: Optimize DataBase (all tables)');
	define('MAILBEEZ_SERVICE_DB_OPTIMIZE_TEXT_DESCRIPTION', 'This MailBeez Module optimizes your DataBase sends you an email with the result<br>');	
	
  class service_db_optimize extends mailbeez {
		// class constructor
    function service_db_optimize() {
			// call constructor
			mailbeez::mailbeez(); 
			
			// set some stuff:	
      $this->code = 'service_db_optimize';
			$this->module = 'service_db_optimize';
			$this->version = '1.0'; // float value
			$this->required_mb_version = 1.1; // required mailbeez version
			$this->iteration = $this->_getCheckInterval();
      $this->title = MAILBEEZ_SERVICE_DB_OPTIMIZE_TEXT_TITLE;
      $this->description = MAILBEEZ_SERVICE_DB_OPTIMIZE_TEXT_DESCRIPTION;
      $this->sort_order = 900;
      $this->enabled = ((MAILBEEZ_SERVICE_DB_OPTIMIZE_STATUS == 'True') ? true : false);
			$this->sender = MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER;
			$this->sender_name = MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER_NAME;
			$this->status_key = 'MAILBEEZ_SERVICE_DB_OPTIMIZE_STATUS';
			
			$this->documentation_key = $this->module; // leave empty if no documentation available
			// $this->documentation_root = 'http:://yoursite.com/' // modify documentation root if necessary			
			
			$this->htmlBodyTemplateResource = 'body_html.tpl'; // located in folder of this module
			$this->txtBodyTemplateResource = 'body_txt.tpl'; // located in folder of this module			
			$this->subjectTemplateResource = 'subject.tpl'; // located in folder of this module
			
			
			$this->htmlResultListTemplateResource = 'optlist_html.tpl'; // located in folder of this module
			$this->txtResultListResource = 'optlist_txt.tpl'; // located in folder of this module			
			
			$this->audience = array();
			$this->additionalFields = array('iteration' => $this->iteration); // list of additional fields to show in listing with testvalues
			// list of additional fields to show in listing with testvalues used for Test-Mail
    
}

// class methods
		function getAudience() {
			$id = -42; // the answer... ;-)
			
			// early check to avoid processing when email was already sent
			$mb_chk = new mailbeez_mailer($this);
			$chk_result = $mb_chk->check($this->module, $this->iteration, $id);
			//$chk_result = true; //no email
			if ($chk_result != false) {
				// this iteration was already sent
				return false;
			}
			
			$htmlListOut = '';
			$txtListOut = '';
			
			// load subtemplates
			$htmlResultListTemplate = $this->loadResource($this->pathToMailbeez . $this->module. '/email/' . $this->htmlResultListTemplateResource);
			$txtResultListTemplate = $this->loadResource($this->pathToMailbeez . $this->module. '/email/' . $this->txtResultListResource);			
			
			$tbl_status_sql = 'SHOW TABLE STATUS FROM ' . DB_DATABASE;
		  $tbl_result = mh_db_query($tbl_status_sql);
			
		  while ($tbl_row = mh_db_fetch_array($tbl_result)) {
		    // Statement to optimize table
		    $opt_table_sql = 'OPTIMIZE TABLE ' . $tbl_row['Name'];
		    // Query mySQL to optimize currently looped table
		    $opt_result = mh_db_query($opt_table_sql);
		    $opt = mh_db_fetch_array($opt_result);
				$subTemplateVars = array('table' => $opt['Table'],
																 'operation' => $opt['Op'],
																 'type' => $opt['Msg_type'],
																 'msg' => $opt['Msg_text']
																 );
				$htmlListOut .= $this->replace_variables($htmlResultListTemplate, $subTemplateVars);
				$txtListOut  .= $this->replace_variables($txtResultListTemplate, $subTemplateVars);
			}

			return false;

			$this->audience[$id] = array('firstname' => MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER_NAME,
																	 'lastname' => ' - MailBeez Service DataBase Optimize',
                                   'email_address' => MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER,
																	 'customers_id' => $id,
																	 'iteration' => $this->iteration,
																	 'opt_result_html' => $htmlListOut,
																	 'opt_result_txt' => $txtListOut
																	 );
		
			return $this->audience;
			
		}
		
		
		function _getCheckInterval() {
			switch ( MAILBEEZ_SERVICE_DB_OPTIMIZE_INTERVAL ) {
				case 'every day':
					return date('Yz');
					break;
				case 'every week':
					return date('YW');
					break;
				case 'every month':
					return date('Ym');
					break;
			}
		}		
		
		// installation methods
		
    function keys() {
      return array('MAILBEEZ_SERVICE_DB_OPTIMIZE_STATUS', 'MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER', 'MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER_NAME', 'MAILBEEZ_SERVICE_DB_OPTIMIZE_INTERVAL');
    }
		
    function install() {
		
			mh_insert_config_value(array('configuration_title' => 'Optimize your DataBase', 
																	 'configuration_key' => 'MAILBEEZ_SERVICE_DB_OPTIMIZE_STATUS', 
																	 'configuration_value' => 'True', 
																	 'configuration_description' => 'Do you want to optimzie your DataBase?', 
																	 'set_function' => 'mh_cfg_select_option(array(\'True\', \'False\'), '
																	 ));
																	 
			mh_insert_config_value(array('configuration_title' => 'Interval', 
																	 'configuration_key' => 'MAILBEEZ_SERVICE_DB_OPTIMIZE_INTERVAL', 
																	 'configuration_value' => 'every week', 
																	 'configuration_description' => 'How often do yo want to optimize your DataBase?', 
																	 'set_function' => 'mh_cfg_select_option(array(\'every day\', \'every week\', \'every month\'), '
																	 ));

																	 
			mh_insert_config_value(array('configuration_title' => 'sender and receiver email', 
																	 'configuration_key' => 'MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER', 
																	 'configuration_value' => STORE_OWNER_EMAIL_ADDRESS, 
																	 'configuration_description' => 'sender email', 
																	 'set_function' => ''
																	 ));
																	 
			mh_insert_config_value(array('configuration_title' => 'sender and receiver name', 
																	 'configuration_key' => 'MAILBEEZ_SERVICE_DB_OPTIMIZE_SENDER_NAME', 
																	 'configuration_value' => STORE_NAME, 
																	 'configuration_description' => 'sender email', 
																	 'set_function' => ''
																	 ));
    }
  }
?>