require_once '../irrSched/library/config.php'; include('../irrSched/library/funcs.php'); include('../irrSched/library/dbfuncs.php'); $conn = db_connect(); $today = getdate(); $theDate = prepDate($today); $dArr = explode(" ", $theDate); $currDate = strtotime($dArr[0]); $rCount = 0; $tCount = 0; $pdfFile = ''; $sql = 'select c.iContentNo, c.strContentName, c.dPostStart, c.dPostEnd, c.bPost, c.enContentType, d.iTemplateNo, d.strPdfFileName, strThmbFileName, d.strThmbText from tblContent c left join tblContentData d on c.iContentNo = d.iContentNo where c.bMarkDeleted = 0 order by c.dPostStart, c.dPostEnd'; $result = mysql_query($sql) or die("Select DB Error: ".mysql_error().", sql = ".$sql); $res = fillArray($result); $resCount = mysql_num_rows($result); $dbg = "
content prep:\n";
if($resCount > 0) {
$content_arr = array();
$thmb_arr = array();
foreach($res as $key => $val) {
$content_arr[$rCount]['contentNo'] = $val['iContentNo'];
$content_arr[$rCount]['dbStart'] = $val['dPostStart'];
$content_arr[$rCount]['dbEnd'] = $val['dPostEnd'];
$content_arr[$rCount]['postYN'] = $val['bPost'];
$content_arr[$rCount]['publishYN'] = $val['bPublish'];
$content_arr[$rCount]['contentType'] = $val['enContentType'];
$content_arr[$rCount]['templateNo'] = $val['iTemplateNo'];
$content_arr[$rCount]['pdfFile'] = $val['strPdfFileName'];
$content_arr[$rCount]['thmbFile'] = $val['strThmbFileName'];
$content_arr[$rCount]['thmbText'] = $val['strThmbText'];
$rCount++;
}
for($i = 0; $i < count($content_arr); $i++) {
foreach($content_arr[$i] as $key_1 => $val_1) {
//$dbg .= $key_1." = ".$content_arr[$i][$key_1]."\n";
//$pStart = $content_arr[$i]['dbStart'];
//$pEnd = $content_arr[$i]['dbEnd'];
//$dbg .= "pStart = ".$pStart."\n";
//$dbg .= "pEnd = ".$pEnd."\n";
if($key_1 == 'dbStart') {
if(!is_null($content_arr[$i][$key_1]) || $content_arr[$i][$key_1] != '') {
$pStart = strtotime($content_arr[$i][$key_1]);
}
$dbg .= $key_1." = ".$content_arr[$i][$key_1]."\n";
}
if($key_1 == 'dbEnd') {
if(!is_null($content_arr[$i][$key_1]) || $content_arr[$i][$key_1] != '') {
$pEnd = strtotime($content_arr[$i][$key_1]);
}
$dbg .= $key_1." = ".$content_arr[$i][$key_1]."\n";
}
if($key_1 == 'postYN') {
if(!$content_arr[$i]['postYN']) {
if(!$content_arr[$i][$key_1]) {
$dbg .= "post by date: ".$content_arr[$i]['contentNo']."\n";
if($currDate >= $pStart && $currDate <= $pEnd) {
if($content_arr[$i]['contentType'] == 'thmb') {
$thmb_arr[$tCount]['thmbFile'] = $content_arr[$i]['thmbFile'];
$thmb_arr[$tCount]['thmbText'] = $content_arr[$i]['thmbText'];
$thmb_arr[$tCount]['pdfFile'] = $content_arr[$i]['pdfFile'];
$tCount++;
}
//pdfFile takes precedence over thumbs. Update DB if todays's date is in conflict with active thumb(s)?
if($content_arr[$i]['contentType'] == 'pdf') {
$pdfFile = $content_arr[$i]['pdfFile'];
}
}
} else {
$dbg .= "post manually: ".$content_arr[$i]['contentNo']."\n";
if($content_arr[$i]['contentType'] == 'thmb') {
$thmb_arr[$tCount]['thmbFile'] = $content_arr[$i]['thmbFile'];
$thmb_arr[$tCount]['thmbText'] = $content_arr[$i]['thmbText'];
$thmb_arr[$tCount]['pdfFile'] = $content_arr[$i]['pdfFile'];
$tCount++;
}
if($content_arr[$i]['contentType'] == 'pdf') {
$pdfFile = $content_arr[$i]['pdfFile'];
}
}
}
}
}
$dbg .= "------------------------\n";
}
$dbg .= "tCount = ".$tCount."\n";
$dbg .= "pdfFile = ".$pdfFile."\n";
//echo $dbg."";
//exit;
}
include '../common/header.php'; ?>
include '../common/banner.php'; ?>