function display($tpl = null) { global $mainframe; $id = JRequest::getVar('cid', array(0), '', 'array'); $boxchecked = JRequest::getVar('boxchecked'); //echo $boxchecked; $uid = (int) @$id[0]; $data['company'] = nl2br(getCompanyReport($uid)); //$date['company'] = str_replace("\n", "<br/>"); $data['lenses'] = nl2br(getCompanyLensesReport($uid)); $mysqli = DBAccess::getConnection(); $sql = "SELECT * from pn_lenses_companies WHERE pn_comp_tid = {$uid}"; $result = $mysqli->selectQuery($sql); $row = $result->fetch_assoc(); //massage the data for the email if ($row['pn_contact_email'] == "") { $row['pn_contact_email'] = $row['pn_email']; } if ($row['pn_comp_name_short'] == "") { $row['pn_comp_name_short'] = $row['pn_comp_name']; } //get the email intro content $row['content'] = makeEmailIntro($row); //pass along the contact person $row['contact'] = $row['pn_contact_nameF'] . " " . $row['pn_contact_nameL']; if ($row['pn_contact_nameF'] == "") { $row['contact'] = $row['pn_comp_name_short']; } //echo $data['lenses']; //had to reset the database, otherwise joomla was looking for the component in the 'eyedock_data' database and causing an error (I assume the function above was causing this database switch) //$connect =mysql_connect('mysql.eyedock.com', 'eyedockdatauser', 'kvBS^VQR'); //mysql_connect('localhost', 'root', 'root'); $connect = getCONNECT(); $database = mysql_select_db("eyedockjoomla", $connect); $this->assignRef('data', $data); $this->assignRef('companyData', $row); parent::display($tpl); }
ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); ini_set('html_errors', 'On'); //include_once $_SERVER['DOCUMENT_ROOT']. "/eyedock.com/api_new/dataGetters.php"; include_once "comp_db.php"; include_once "companyFunctions.php"; //get all the companies $companiesSQL = "SELECT pn_comp_tid from pn_lenses_companies"; $results = $mysqli->query($companiesSQL); while ($row = $results->fetch_assoc()) { //print_r($row['pn_comp_tid']); //echo "<br/>"; $report = getCompanyReport($row['pn_comp_tid']); echo "<br/>" . $report; $lensReport = getCompanyLensesReport($row['pn_comp_tid']); } /* // multiple recipients (note the commas) $to = "*****@*****.**"; // subject $subject = "Testing CL company reports"; // compose message $message = " <html> <head> <title>CL company report</title> </head>
$lastEmail = strtotime($row['pn_last_email']); $interval = $row['pn_email_interval']; $daysSinceEmail = (time() - $lastEmail) / 60 / 60 / 24; //echo " [" . $daysSinceEmail . " < ". $interval . "], "; if ($daysSinceEmail < $interval) { continue; } //it hasn't been long enough //just a safeguard (don't automatically send anyone more than 1 email in a month) if ($daysSinceEmail < 30) { continue; } $count++; //echo "-> " . $row['pn_comp_tid'] . ", "; $data['company'] = getCompanyReport($row['pn_comp_tid']); $data['lenses'] = getCompanyLensesReport($row['pn_comp_tid']); //massage the data for the email if ($row['pn_contact_email'] == "") { $row['pn_contact_email'] = $row['pn_email']; } if ($row['pn_comp_name_short'] == "") { $row['pn_comp_name_short'] = $row['pn_comp_name']; } //get the email intro content $data['intro'] = makeEmailIntro($row); $to = $row['pn_contact_email']; $subject = $row['pn_comp_name_short'] . " lenses on EyeDock"; $contact = $row['pn_contact_nameF'] . " " . $row['pn_contact_nameL']; if ($row['pn_contact_nameF'] == "") { $contact = $row['pn_comp_name_short']; }
<?php // ini_set('display_errors', 1); // ini_set('log_errors', 1); // ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); // error_reporting(E_ALL); // ini_set('html_errors', 'On'); require_once 'emailer.php'; require_once 'companyFunctions.php'; $to = $_REQUEST['to']; $subject = $_REQUEST['subject']; //$report_content = $_REQUEST['report_content']; $intro = $_REQUEST['email_body']; $company = $_REQUEST['company']; $contact = $_REQUEST['contact']; $id = $_REQUEST['id']; $companyReport = getCompanyReport($id); $lensesReport = getCompanyLensesReport($id); $lensesReport = str_replace("°", "", $lensesReport); $lensesReport = str_replace("<br/>", "\n", $lensesReport); $content = $intro . "\n\n\n" . $companyReport . "\n\n\n" . $lensesReport; //echo $content; emailCompanyReport($to, $subject, $content, $company, $contact); updateLastEmail($id);