woodwyn
asked on
TCPDF ERROR: [Image] Unable to get image
Taking over an older website for someone I upgraded their backend db from SQL 2000 to 2016. The web hosting server has not been modified, but now we are seeing a new error when trying to create a PDF report. This worked before, so I don't think that suggestions I found online about cURL are accurate.
"TCPDF ERROR: [Image] Unable to get image: ../../ban/main/ProductImag es/HeaderI mages/bbts _header.jp g"
Here's the entire content of Reports.php where I believe the issue is occurring. I am not a PHP developer, but can typically support issues like this. Please be specific with suggested solutions. You can search for header or logo to see the area where the issue most likely is occurring.
<?php
require_once('../../tcpdf/ config/lan g/eng.php' );
require_once('../../tcpdf/ tcpdf.php' );
class ReportsEntity extends Entity
{
# Reports
function getReportsList() {
global $keyWebSubDomains;
return NDatabase::getAllAssoc("SE LECT convert(varchar(256),keyRe port) as keyReport, title, stored_procedure, header_image, columns, execString FROM Reports WHERE
keyWebSubDomains = convert(uniqueidentifier,' $keyWebSub Domains') ORDER BY title");
}
function getReport($uid) {
#NDatabase::setDebug();
$report = NDatabase::getARow("SELECT convert(varchar(256),keyRe port) as keyReport, title, stored_procedure, header_image, columns, execString FROM Reports WHERE
keyReport=convert(uniqueid entifier,' $uid')");
return $report;
}
function setReport($uid, $params) {
#die(print_r($params));
global $keyWebSubDomains;
if (!empty($uid)) {
NDatabase::query('UPDATE Reports SET title=?, stored_procedure=?, header_image=?, columns=?, execString=? WHERE convert(varchar(255),keyRe port)=?',
array($params['title'], $params['stored_procedure' ], $params['header_image'], $params['columns'], $params['execString'], $uid));
} else {
$uid = Entity::getNUI();
NDatabase::query('INSERT INTO Reports (keyWebSubDomains,title,st ored_proce dure,heade r_image,co lumns,exec String) VALUES(convert(uniqueident ifier,?),? ,?,?,?,?)' ,
array($keyWebSubDomains, $params['title'], $params['stored_procedure' ], $params['header_image'], $params['columns'], $params['execString']));
}
return $uid;
}
function deleteReport($uid) {
NDatabase::query('DELETE FROM Reports WHERE keyReport = convert(uniqueidentifier,? )', array($uid));
NDatabase::query('DELETE FROM ReportsInputs WHERE keyReport = convert(uniqueidentifier,? )', array($uid));
}
# Inputs
function getInputsList($uid) {
return NDatabase::getAllAssoc("SE LECT convert(varchar(256),keyIn put) as keyInput, ltrim(rtrim(title)) as title, ltrim(rtrim(data_type)) as data_type, ltrim(rtrim(sp_variable)) as sp_variable,
is_required, sorting, ord FROM ReportsInputs WHERE keyReport = convert(uniqueidentifier,' $uid') ORDER BY ord");
}
function getInput($ind) {
return NDatabase::getARow("SELECT convert(varchar(256),keyIn put) as keyInput, convert(varchar(256),keyRe port) as keyReport, ltrim(rtrim(title)) as title, ltrim(rtrim(data_type)) as
data_type, ltrim(rtrim(sp_variable)) as sp_variable, is_required, sorting, ord FROM ReportsInputs WHERE keyInput=convert(uniqueide ntifier,'$ ind')");
}
function setInput($uid, $ind, $params) {
if (!empty($ind)) {
NDatabase::query('UPDATE ReportsInputs SET title=?, data_type=?, sp_variable=?, is_required=?, sorting=?, ord=? WHERE convert(varchar(255),keyIn put)=?',
array($params['title'], $params['data_type'], $params['sp_variable'], $params['is_required'], $params['sorting'], $params['ord'], $ind));
} else {
$ind = Entity::getNUI();
NDatabase::query('INSERT INTO ReportsInputs (keyReport,title,data_type ,sp_variab le,is_requ ired,sorti ng,ord) VALUES(convert(uniqueident ifier,?),? ,?,?,?,?,? )',
array($uid, $params['title'], $params['data_type'], $params['sp_variable'], $params['is_required'], $params['sorting'], $params['ord']));
}
return $ind;
}
function deleteInput($ind) {
NDatabase::query('DELETE FROM ReportsInputs WHERE keyInput = convert(uniqueidentifier,? )', array($ind));
}
# create report
function createReport($cmd, $report, $params, $categories) {
global $keyWebSubDomains;
$cKeyWebSubDomains = $keyWebSubDomains;
/*
EXEC EOLReportAssetUsage
@cKeyWebSubDomains,@dStart Date,@dEnd Date,@cWeb SubDomains MenusKeys, @cDescript ion,@nIsPD F,@cSortBy 1,@cSortBy 2,@cSortBy 3,@cSortBy 4,@cSortBy 5
EXEC EOLReportOrderHistory
@cKeyWebSubDomains,@dStart Date,@dEnd Date,@cWeb SubDomains MenusKeys, @cOrderNum ber,@cDesc ription,@n IsPDF,@cSo rtBy1,@cSo rtBy2,@cSo rtBy3,@cSo rtBy4,@cSo rtBy5
EXEC EOLReportPostPortable
@cKeyWebSubDomains,@dStart Date,@dEnd Date,@cWeb SubDomains MenusKeys, @cOrderNum ber,@cDesc ription,@n IsPDF,@cSo rtBy1,@cSo rtBy2,@cSo rtBy3,@cSo rtBy4,@cSo rtBy5
-- WKH '{0CD12A89-8AEA-4F80-AA3B- 370D475B8C 06}'
-- PCB '{8BAB3BAB-A22F-48A9-8ADF- CCC2ED70FB F7}'
-- woowdwyn '{92913C74-BAA9-4A5A-9703- C650D1B069 4B}'
*/
$values = $crits = array();
$cWebSubDomainsMenusKeys = $cSortBy1 = $cSortBy2 = $cSortBy3 = $cSortBy4 = $cSortBy5 = '';
$inputs = ReportsEntity::getInputsLi st($report ['keyRepor t']);
foreach($inputs as $input) {
if ($input['data_type'] != 'Select') {
$values[$input['sp_variabl e']] = $params[$input['keyInput'] ];
} else {
$select = $params[$input['keyInput'] ];
if (is_array($select) && $input['sp_variable'] == '@cSortBy') {
foreach($select as $sel) {
if ($sel == '99') continue;
if (empty($cSortBy1)) $cSortBy1 = $sel;
else if (empty($cSortBy2)) $cSortBy2 = $sel;
else if (empty($cSortBy3)) $cSortBy3 = $sel;
else if (empty($cSortBy4)) $cSortBy4 = $sel;
else if (empty($cSortBy5)) { $cSortBy5 = $sel; break; }
}
} else {
$cSortBy1 = $params[$input['keyInput'] ];
}
}
}
$dStartDate = isset($values['@dStartDate ']) ? date('Y-m-d 00:00:01', strtotime($values['@dStart Date'])) : 'GETDATE()';
$crits['Start Date'] = date('m-d-Y', strtotime($dStartDate));
$dEndDate = isset($values['@dEndDate'] ) ? date('Y-m-d 23:59:59', strtotime($values['@dEndDa te'])) : 'GETDATE()';
$crits['End Date'] = date('m-d-Y', strtotime($dEndDate));
$cOrderNumber = isset($values['@cOrderNumb er']) ? $values['@cOrderNumber'] : '';
if ($cOrderNumber) $crits['Order Number'] = $cOrderNumber;
$cDescription = isset($values['@cDescripti on']) ? $values['@cDescription'] : '';
if ($cOrderNumber) $crits['Description'] = $cDescription;
$cCategory = isset($values['@cCategory' ]) ? $values['@cCategory'] : '';
if ($cCategory) $crits['Category'] = $cCategory;
$nAllOverlapCats = isset($values['@nAllOverla pCats']) ? $values['@nAllOverlapCats' ] : '';
if ($nAllOverlapCats) $crits['All Overlap Categories'] = $nAllOverlapCats;
$n33Cube = isset($values['@n33Cube']) ? $values['@n33Cube'] : '';
if ($n33Cube) $crits['33" Cube'] = $n33Cube;
$n6TableSkirt = isset($values['@n6TableSki rt']) ? $values['@n6TableSkirt'] : '';
if ($n6TableSkirt) $crits['6 Table Skirt'] = $n6TableSkirt;
$n8TableSkirt = isset($values['@n8TableSki rt']) ? $values['@n8TableSkirt'] : '';
if ($n8TableSkirt) $crits['8 Table Skirt'] = $n8TableSkirt;
$nBanners = isset($values['@nBanners'] ) ? $values['@nBanners'] : '';
if ($nBanners) $crits['Banners'] = $nBanners;
$nFeatherLite = isset($values['@nFeatherLi te']) ? $values['@nFeatherLite'] : '';
if ($nFeatherLite) $crits['Featherlite'] = $nFeatherLite;
$nHOP = isset($values['@nHOP']) ? $values['@nHOP'] : '';
if ($nHOP) $crits['HOP'] = $nHOP;
$nPipe8x7 = isset($values['@nPipe8x7'] ) ? $values['@nPipe8x7'] : '';
if ($nPipe8x7) $crits['Pipe 8x7'] = $nPipe8x7;
$nPipe8x10 = isset($values['@nPipe8x10' ]) ? $values['@nPipe8x10'] : '';
if ($nPipe8x10) $crits['Pipe 8x10'] = $nPipe8x10;
$nTableRunner = isset($values['@nTableRunn er']) ? $values['@nTableRunner'] : '';
if ($nTableRunner) $crits['Table Runner'] = $nTableRunner;
$nIsPDF = $cmd == 'pdf' ? 1 : 0;
if (!empty($categories)) {
$cWebSubDomainsMenusKeys = implode(',', $categories);
}
$exec = trim($report['execString'] );
$execParams = explode('@', $exec);
if (empty($exec) || $execParams == $exec) {
$sp = trim($report['stored_proce dure']);
if ($sp == 'EOLReportOrderHistory') {
$q = "EXEC $sp '$keyWebSubDomains','$dSta rtDate','$ dEndDate', '$cWebSubD omainsMenu sKeys','$c OrderNumbe r','$cDesc ription',
$nIsPDF,'$cSortBy1','$cSor tBy2','$cS ortBy3','$ cSortBy4', '$cSortBy5 '";
}
else if ($sp == 'EOLReportAssetUsage') {
$q = " DECLARE @nIsPDF TinyInt
SET @nIsPDF = 1
EXEC $sp '$keyWebSubDomains','$dSta rtDate','$ dEndDate', '$cWebSubD omainsMenu sKeys','$c Descriptio n',$nIsPDF ,'$cSortBy 1','$cSort By2','$cSo rtBy3','$c SortBy4',' $cSortBy5' ;
";
}
else if ($sp == 'EOLReportPostPortable') {
$q = " DECLARE @nIsPDF TinyInt
SET @nIsPDF = 1
EXEC $sp '$keyWebSubDomains','$dSta rtDate','$ dEndDate', '$cWebSubD omainsMenu sKeys','$c OrderNumbe r','$cDesc ription',
$nIsPDF,'$cSortBy1','$cSor tBy2','$cS ortBy3','$ cSortBy4', '$cSortBy5 ';
";
}
/*
else if ($sp == 'EOLReportAssetUsageWithOv erlaps') {
$q = " DECLARE @nIsPDF TinyInt
SET @nIsPDF = 7
DECLARE @cTest TinyInt
SET @cTest='OOOPS'
EXEC $sp '$keyWebSubDomains','$dSta rtDate','$ dEndDate', '$cWebSubD omainsMenu sKeys','$c Descriptio n','$cTest ',
$nIsPDF,'$cSortBy1','$cSor tBy2','$cS ortBy3','$ cSortBy4', '$cSortBy5 ';
";
}
*/
} else {
$execParams = explode('@', $exec);
$q = $execParams[0];
$l = strlen($q);
unset($execParams[0]);
foreach($execParams as $execParam) {
$q .= ($l == strlen($q) ? ' ' : ',' );
$execParam = str_replace(",", "", $execParam);
if ($execParam == 'nIsPDF') {
$q .= "$" . $execParam;
} else {
$q .= "'$$execParam'";
}
}
}
eval ("\$q = \"$q\";");
#die($q);
$_SESSION["SP"] = $q;
$data = NDatabase::getOne($q);
if (!$data)
return 'No records found.';
$data = NDatabase::getAllAssoc($q) ;
#echo "<pre>"; die(print_r($data));
if (is_array($data)) {
$filename = trim($report['title']) . '_' . time();
$parts = explode("/", $_SERVER['PHP_SELF']);
$subDomain = $parts[count($parts) - 3];
$main = $parts[count($parts) - 2];
$uploaddir = $subDomain .'/'. $main . '/ProductImages/Reports/';
$_logo = '../../' . $subDomain .'/'. $main . '/ProductImages/HeaderImag es/'.$repo rt['header _image'];
$logo = file_exists($_logo) ? $_logo : '';
$_ss = explode('.', $report['header_image']);
$ext = $_ss[ count($_ss)-1 ];
$_SESSION['title'] = $title = trim($report['title']);
$_SESSION['logo'] = $logo;
$_SESSION['ext'] = strtoupper($_ss[ count($_ss)-1 ]);
if ($cmd == 'pdf') {
return ReportsEntity::createPDF($ filename.' .pdf', $uploaddir, $data, $report, $logo, $crits);
} else {
return ReportsEntity::createCSV($ filename.' .csv', $uploaddir, $data);
}
}
}
# to CSV
function createCSV($filename, $path, $data) {
$file_csv = '../../' . $path . $filename;
#echo $file_csv."<br>";
$fp = fopen($file_csv, 'w');
$row = 0;
foreach($data as $d) {
$str = '';
if ($row == 0) {
$headers = array_keys($d);
foreach ($headers as $header) { $str .= $header.","; }
fwrite($fp, $str . PHP_EOL);
$str = '';
$row++;
}
foreach ($d as $v) {
# $str .= "'".addslashes($v)."',";
$str .= "$v,";
}
fwrite($fp, $str . PHP_EOL);
}
fclose($fp);
return (file_exists($file_csv)) ? $filename : 'File not exists. Please connect to admins.';
}
# to PDF
function createPDF($filename, $path, $data, $report, $logo, $crits) {
$file_pdf = '../../' . $path . $filename;
$title = trim($report['title']);
# $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf = new MYPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREAT OR);
$pdf->SetAuthor('DS6 Team');
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetKeywords('TCPDF, PDF, report');
# $pdf->SetHeaderData(PDF_HE ADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 006', PDF_HEADER_STRING);
# $pdf->SetFont('helvetica', 'B', 24);
# $pdf->SetHeaderData($logo, PDF_HEADER_LOGO_WIDTH, $report['title'], " Created on ".date('F d, Y'));
# $pdf->SetHeaderData($logo) ;
$pdf->setHeaderFont(array( PDF_FONT_N AME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array( PDF_FONT_N AME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospaced Font(PDF_F ONT_MONOSP ACED);
// set margins
# $pdf->SetMargins(PDF_MARGI N_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
$pdf->SetHeaderMargin(PDF_ MARGIN_HEA DER);
$pdf->SetFooterMargin(PDF_ MARGIN_FOO TER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRU E, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IM AGE_SCALE_ RATIO);
$pdf->SetFont('dejavusans' , '', 8);
$pdf->AddPage();
$y = $pdf->GetY();
$pdf->SetY( $y-7, true );
// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)
$text = '';
$substring='1969';
foreach($crits as $title => $value) {
if (strpos($value, $substring) !== false) {
$value="";
}
$text .= "<tr><td> $titl e: &n bsp;$value </td></tr> ";
}
$html .= "<table style='width:100%; cellspacing='0'> <tr><td><b>Report Criteria</b></td></tr>$tex t</table>< br><br>";
#echo "<br>".$html;
#die();
# $y = $pdf->GetY();
# $pdf->SetY( $y+2, true );
$headers = array_keys($data[0]);
$width = 0;
if (!empty($report['columns'] )) {
$cols = strpos($report['columns'], ';') !== false ? explode(';', $report['columns']) : $report['columns'];
if (is_array($cols)) {
foreach($cols as $col) {
$_col = explode(':', $col);
$columns[$_col[0]] =$_col[1];
$width = $width + (int)$_col[1];
}
} else {
$_col = explode(':', $cols);
$columns[$_col[0]] = $_col[1];
$width = $width + (int)$_col[1];
}
}
#die(print_r($columns));
$count_h = count($headers);
$count_c = count($columns);
$const_width = ceil((982 - $width) / ($count_h - $count_c));
#die("$const_width = (982 - $width) / ($count_h - $count_c)");
$html .= '<table style="width:100%;" cellspacing="0">';
$html .= '<tr>';
$k = 1;
foreach($headers as $header) {
$col_width = isset($columns[$header]) ? $columns[$header] : $const_width;
$hd = ucwords($header);
$h = split(",", substr( preg_replace("/([A-Z])/", ',\\1', $hd), 1 ));
$header = implode(' ', $h);
$html .= '<td bgcolor="#eee" align="left" width="'.$col_width.'" height="32" vertical-align="middle"><b >'.$header .'</b></td >';
$k++;
}
$html .= '</tr>';
foreach( $data as $dat ) {
$html .= '<tr>';
foreach($dat as $d) {
$html .= "<td style='word-wrap:break-wor d;'>$d</td >";
}
$html .= '</tr>';
}
$html .= '</table>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->lastPage();
$pdf->Output($file_pdf, 'F');
return (file_exists($file_pdf)) ? $filename : 'File not exists. Please connect to admins.';
}
}
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Logo
$this->Image($_SESSION['lo go'], 5, 5, 40, '', $_SESSION['ext'], '', 'T', false, 72, 'L', false, false, 0, false, false, false);
// Title
$this->SetFont('helvetica' , '', 16);
$this->Cell(10, 15, " ", 0, false, 'L', 0, '', 0, false, 'M', 'M');
$this->Cell(180, 15, $_SESSION['title'], 0, false, 'L', 0, '', 0, false, 'T', 'M');
$this->SetFont('helvetica' , 'i', 12 );
$this->Cell(0, 15, "Created on ".date('F d, Y'), 0, false, 'R', 0, '', 0, false, 'T', 'M');
$this->Line( 10, 17, $this->getPageWidth() - 10, 17 );
}
}
?>
"TCPDF ERROR: [Image] Unable to get image: ../../ban/main/ProductImag
Here's the entire content of Reports.php where I believe the issue is occurring. I am not a PHP developer, but can typically support issues like this. Please be specific with suggested solutions. You can search for header or logo to see the area where the issue most likely is occurring.
<?php
require_once('../../tcpdf/
require_once('../../tcpdf/
class ReportsEntity extends Entity
{
# Reports
function getReportsList() {
global $keyWebSubDomains;
return NDatabase::getAllAssoc("SE
keyWebSubDomains = convert(uniqueidentifier,'
}
function getReport($uid) {
#NDatabase::setDebug();
$report = NDatabase::getARow("SELECT
keyReport=convert(uniqueid
return $report;
}
function setReport($uid, $params) {
#die(print_r($params));
global $keyWebSubDomains;
if (!empty($uid)) {
NDatabase::query('UPDATE Reports SET title=?, stored_procedure=?, header_image=?, columns=?, execString=? WHERE convert(varchar(255),keyRe
array($params['title'], $params['stored_procedure'
} else {
$uid = Entity::getNUI();
NDatabase::query('INSERT INTO Reports (keyWebSubDomains,title,st
array($keyWebSubDomains, $params['title'], $params['stored_procedure'
}
return $uid;
}
function deleteReport($uid) {
NDatabase::query('DELETE FROM Reports WHERE keyReport = convert(uniqueidentifier,?
NDatabase::query('DELETE FROM ReportsInputs WHERE keyReport = convert(uniqueidentifier,?
}
# Inputs
function getInputsList($uid) {
return NDatabase::getAllAssoc("SE
is_required, sorting, ord FROM ReportsInputs WHERE keyReport = convert(uniqueidentifier,'
}
function getInput($ind) {
return NDatabase::getARow("SELECT
data_type, ltrim(rtrim(sp_variable)) as sp_variable, is_required, sorting, ord FROM ReportsInputs WHERE keyInput=convert(uniqueide
}
function setInput($uid, $ind, $params) {
if (!empty($ind)) {
NDatabase::query('UPDATE ReportsInputs SET title=?, data_type=?, sp_variable=?, is_required=?, sorting=?, ord=? WHERE convert(varchar(255),keyIn
array($params['title'], $params['data_type'], $params['sp_variable'], $params['is_required'], $params['sorting'], $params['ord'], $ind));
} else {
$ind = Entity::getNUI();
NDatabase::query('INSERT INTO ReportsInputs (keyReport,title,data_type
array($uid, $params['title'], $params['data_type'], $params['sp_variable'], $params['is_required'], $params['sorting'], $params['ord']));
}
return $ind;
}
function deleteInput($ind) {
NDatabase::query('DELETE FROM ReportsInputs WHERE keyInput = convert(uniqueidentifier,?
}
# create report
function createReport($cmd, $report, $params, $categories) {
global $keyWebSubDomains;
$cKeyWebSubDomains = $keyWebSubDomains;
/*
EXEC EOLReportAssetUsage
@cKeyWebSubDomains,@dStart
EXEC EOLReportOrderHistory
@cKeyWebSubDomains,@dStart
EXEC EOLReportPostPortable
@cKeyWebSubDomains,@dStart
-- WKH '{0CD12A89-8AEA-4F80-AA3B-
-- PCB '{8BAB3BAB-A22F-48A9-8ADF-
-- woowdwyn '{92913C74-BAA9-4A5A-9703-
*/
$values = $crits = array();
$cWebSubDomainsMenusKeys = $cSortBy1 = $cSortBy2 = $cSortBy3 = $cSortBy4 = $cSortBy5 = '';
$inputs = ReportsEntity::getInputsLi
foreach($inputs as $input) {
if ($input['data_type'] != 'Select') {
$values[$input['sp_variabl
} else {
$select = $params[$input['keyInput']
if (is_array($select) && $input['sp_variable'] == '@cSortBy') {
foreach($select as $sel) {
if ($sel == '99') continue;
if (empty($cSortBy1)) $cSortBy1 = $sel;
else if (empty($cSortBy2)) $cSortBy2 = $sel;
else if (empty($cSortBy3)) $cSortBy3 = $sel;
else if (empty($cSortBy4)) $cSortBy4 = $sel;
else if (empty($cSortBy5)) { $cSortBy5 = $sel; break; }
}
} else {
$cSortBy1 = $params[$input['keyInput']
}
}
}
$dStartDate = isset($values['@dStartDate
$crits['Start Date'] = date('m-d-Y', strtotime($dStartDate));
$dEndDate = isset($values['@dEndDate']
$crits['End Date'] = date('m-d-Y', strtotime($dEndDate));
$cOrderNumber = isset($values['@cOrderNumb
if ($cOrderNumber) $crits['Order Number'] = $cOrderNumber;
$cDescription = isset($values['@cDescripti
if ($cOrderNumber) $crits['Description'] = $cDescription;
$cCategory = isset($values['@cCategory'
if ($cCategory) $crits['Category'] = $cCategory;
$nAllOverlapCats = isset($values['@nAllOverla
if ($nAllOverlapCats) $crits['All Overlap Categories'] = $nAllOverlapCats;
$n33Cube = isset($values['@n33Cube'])
if ($n33Cube) $crits['33" Cube'] = $n33Cube;
$n6TableSkirt = isset($values['@n6TableSki
if ($n6TableSkirt) $crits['6 Table Skirt'] = $n6TableSkirt;
$n8TableSkirt = isset($values['@n8TableSki
if ($n8TableSkirt) $crits['8 Table Skirt'] = $n8TableSkirt;
$nBanners = isset($values['@nBanners']
if ($nBanners) $crits['Banners'] = $nBanners;
$nFeatherLite = isset($values['@nFeatherLi
if ($nFeatherLite) $crits['Featherlite'] = $nFeatherLite;
$nHOP = isset($values['@nHOP']) ? $values['@nHOP'] : '';
if ($nHOP) $crits['HOP'] = $nHOP;
$nPipe8x7 = isset($values['@nPipe8x7']
if ($nPipe8x7) $crits['Pipe 8x7'] = $nPipe8x7;
$nPipe8x10 = isset($values['@nPipe8x10'
if ($nPipe8x10) $crits['Pipe 8x10'] = $nPipe8x10;
$nTableRunner = isset($values['@nTableRunn
if ($nTableRunner) $crits['Table Runner'] = $nTableRunner;
$nIsPDF = $cmd == 'pdf' ? 1 : 0;
if (!empty($categories)) {
$cWebSubDomainsMenusKeys = implode(',', $categories);
}
$exec = trim($report['execString']
$execParams = explode('@', $exec);
if (empty($exec) || $execParams == $exec) {
$sp = trim($report['stored_proce
if ($sp == 'EOLReportOrderHistory') {
$q = "EXEC $sp '$keyWebSubDomains','$dSta
$nIsPDF,'$cSortBy1','$cSor
}
else if ($sp == 'EOLReportAssetUsage') {
$q = " DECLARE @nIsPDF TinyInt
SET @nIsPDF = 1
EXEC $sp '$keyWebSubDomains','$dSta
";
}
else if ($sp == 'EOLReportPostPortable') {
$q = " DECLARE @nIsPDF TinyInt
SET @nIsPDF = 1
EXEC $sp '$keyWebSubDomains','$dSta
$nIsPDF,'$cSortBy1','$cSor
";
}
/*
else if ($sp == 'EOLReportAssetUsageWithOv
$q = " DECLARE @nIsPDF TinyInt
SET @nIsPDF = 7
DECLARE @cTest TinyInt
SET @cTest='OOOPS'
EXEC $sp '$keyWebSubDomains','$dSta
$nIsPDF,'$cSortBy1','$cSor
";
}
*/
} else {
$execParams = explode('@', $exec);
$q = $execParams[0];
$l = strlen($q);
unset($execParams[0]);
foreach($execParams as $execParam) {
$q .= ($l == strlen($q) ? ' ' : ',' );
$execParam = str_replace(",", "", $execParam);
if ($execParam == 'nIsPDF') {
$q .= "$" . $execParam;
} else {
$q .= "'$$execParam'";
}
}
}
eval ("\$q = \"$q\";");
#die($q);
$_SESSION["SP"] = $q;
$data = NDatabase::getOne($q);
if (!$data)
return 'No records found.';
$data = NDatabase::getAllAssoc($q)
#echo "<pre>"; die(print_r($data));
if (is_array($data)) {
$filename = trim($report['title']) . '_' . time();
$parts = explode("/", $_SERVER['PHP_SELF']);
$subDomain = $parts[count($parts) - 3];
$main = $parts[count($parts) - 2];
$uploaddir = $subDomain .'/'. $main . '/ProductImages/Reports/';
$_logo = '../../' . $subDomain .'/'. $main . '/ProductImages/HeaderImag
$logo = file_exists($_logo) ? $_logo : '';
$_ss = explode('.', $report['header_image']);
$ext = $_ss[ count($_ss)-1 ];
$_SESSION['title'] = $title = trim($report['title']);
$_SESSION['logo'] = $logo;
$_SESSION['ext'] = strtoupper($_ss[ count($_ss)-1 ]);
if ($cmd == 'pdf') {
return ReportsEntity::createPDF($
} else {
return ReportsEntity::createCSV($
}
}
}
# to CSV
function createCSV($filename, $path, $data) {
$file_csv = '../../' . $path . $filename;
#echo $file_csv."<br>";
$fp = fopen($file_csv, 'w');
$row = 0;
foreach($data as $d) {
$str = '';
if ($row == 0) {
$headers = array_keys($d);
foreach ($headers as $header) { $str .= $header.","; }
fwrite($fp, $str . PHP_EOL);
$str = '';
$row++;
}
foreach ($d as $v) {
# $str .= "'".addslashes($v)."',";
$str .= "$v,";
}
fwrite($fp, $str . PHP_EOL);
}
fclose($fp);
return (file_exists($file_csv)) ? $filename : 'File not exists. Please connect to admins.';
}
# to PDF
function createPDF($filename, $path, $data, $report, $logo, $crits) {
$file_pdf = '../../' . $path . $filename;
$title = trim($report['title']);
# $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf = new MYPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREAT
$pdf->SetAuthor('DS6 Team');
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetKeywords('TCPDF, PDF, report');
# $pdf->SetHeaderData(PDF_HE
# $pdf->SetFont('helvetica',
# $pdf->SetHeaderData($logo,
# $pdf->SetHeaderData($logo)
$pdf->setHeaderFont(array(
$pdf->setFooterFont(array(
$pdf->SetDefaultMonospaced
// set margins
# $pdf->SetMargins(PDF_MARGI
$pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
$pdf->SetHeaderMargin(PDF_
$pdf->SetFooterMargin(PDF_
// set auto page breaks
$pdf->SetAutoPageBreak(TRU
// set image scale factor
$pdf->setImageScale(PDF_IM
$pdf->SetFont('dejavusans'
$pdf->AddPage();
$y = $pdf->GetY();
$pdf->SetY( $y-7, true );
// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)
$text = '';
$substring='1969';
foreach($crits as $title => $value) {
if (strpos($value, $substring) !== false) {
$value="";
}
$text .= "<tr><td> $titl
}
$html .= "<table style='width:100%; cellspacing='0'> <tr><td><b>Report Criteria</b></td></tr>$tex
#echo "<br>".$html;
#die();
# $y = $pdf->GetY();
# $pdf->SetY( $y+2, true );
$headers = array_keys($data[0]);
$width = 0;
if (!empty($report['columns']
$cols = strpos($report['columns'],
if (is_array($cols)) {
foreach($cols as $col) {
$_col = explode(':', $col);
$columns[$_col[0]] =$_col[1];
$width = $width + (int)$_col[1];
}
} else {
$_col = explode(':', $cols);
$columns[$_col[0]] = $_col[1];
$width = $width + (int)$_col[1];
}
}
#die(print_r($columns));
$count_h = count($headers);
$count_c = count($columns);
$const_width = ceil((982 - $width) / ($count_h - $count_c));
#die("$const_width = (982 - $width) / ($count_h - $count_c)");
$html .= '<table style="width:100%;" cellspacing="0">';
$html .= '<tr>';
$k = 1;
foreach($headers as $header) {
$col_width = isset($columns[$header]) ? $columns[$header] : $const_width;
$hd = ucwords($header);
$h = split(",", substr( preg_replace("/([A-Z])/", ',\\1', $hd), 1 ));
$header = implode(' ', $h);
$html .= '<td bgcolor="#eee" align="left" width="'.$col_width.'" height="32" vertical-align="middle"><b
$k++;
}
$html .= '</tr>';
foreach( $data as $dat ) {
$html .= '<tr>';
foreach($dat as $d) {
$html .= "<td style='word-wrap:break-wor
}
$html .= '</tr>';
}
$html .= '</table>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->lastPage();
$pdf->Output($file_pdf, 'F');
return (file_exists($file_pdf)) ? $filename : 'File not exists. Please connect to admins.';
}
}
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Logo
$this->Image($_SESSION['lo
// Title
$this->SetFont('helvetica'
$this->Cell(10, 15, " ", 0, false, 'L', 0, '', 0, false, 'M', 'M');
$this->Cell(180, 15, $_SESSION['title'], 0, false, 'L', 0, '', 0, false, 'T', 'M');
$this->SetFont('helvetica'
$this->Cell(0, 15, "Created on ".date('F d, Y'), 0, false, 'R', 0, '', 0, false, 'T', 'M');
$this->Line( 10, 17, $this->getPageWidth() - 10, 17 );
}
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok great. So, what is the relative path to this image from the script?
(the script is going UP two directories from the script "../../" then going through the directories from that level)
../../ban/main/ProductImag es/HeaderI mages/bbts _header.jp g
Being that the "ban" folder is at the root directory, the script is coded as being two directories deep.
e.g. http://mydomain.com/1/2/script.php
(if it was two levels deep, the script would work as is.)
Since it is not two levels deep, where is this script located?
So is it one level deep?:
e.g. http://mydomain.com/1/script.php
Or on the root directory level?:
e.g. http://mydomain.com/script.php
Or 3 levels deep?:
e.g. http://mydomain.com/1/2/3/script.php
etc.
(the script is going UP two directories from the script "../../" then going through the directories from that level)
../../ban/main/ProductImag
Being that the "ban" folder is at the root directory, the script is coded as being two directories deep.
e.g. http://mydomain.com/1/2/script.php
(if it was two levels deep, the script would work as is.)
Since it is not two levels deep, where is this script located?
So is it one level deep?:
e.g. http://mydomain.com/1/script.php
$_logo = '../' . $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];
Or on the root directory level?:
e.g. http://mydomain.com/script.php
$_logo = $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];
Or 3 levels deep?:
e.g. http://mydomain.com/1/2/3/script.php
$_logo = '../../..' . $subDomain .'/'. $main . '/ProductImages/HeaderImages/'.$report['header_image'];
etc.
ASKER
Hope this helps.
http://mydomain.com/ban/main/report_build.php? Is the URL when I get the error. This directs us back up two folder levels, but the Reports.php file is two levels back down, basically at http://mydomain.com/application/entity/reports.php.
The content of report_build.php page is
<?php
//load file which contain including Smarty, PEAR and other required libraries
require_once "../../sub_report_build.ph p";
?>
The content of sub_report_build.php is
<?php
//load file which contain including Smarty, PEAR and other required libraries
require_once "_loader.php";
if(!UserEntity::checkRoles ($user_id, array("GA","RU","DA"))) {
$Msgr->sendMessage("login. php", $Msgr->GetMessage('login_n eed'));
General::Redirect("login.p hp");
}
$uid = http_request('uid');
$cmd = http_request('cmd');
if (!isset($cmd) || empty($cmd)) $cmd = 'params';
$response = http_request('input');
NTemplate::assign("respons e", $response);
$rep_cats = http_request('rep_cats');
$report_link_pdf = http_request('report_link_ pdf');
$report_link_csv = http_request('report_link_ csv');
$errors = array();
loadEntity('user');
loadEntity('reports');
# the method doesn't return data for USER ?????????????????????
#$report = ReportsEntity::getReport($ uid);
$reports = ReportsEntity::getReportsL ist();
foreach($reports as $report) {
if ($report['keyReport'] == $uid) {
NTemplate::assign("report" , $report);
break;
}
}
$inputs = ReportsEntity::getInputsLi st($uid);
foreach($inputs as $key => $input) {
if ($input['data_type'] == 'Select' && !empty($input['sorting'])) {
$sort = array();
$sorts = explode(';', $input['sorting']);
$resp_ar = isset($response) ? $response[$input['keyInput ']] : array();
foreach ($sorts as $kid=>$sid) {
$select = "<select name='input[".$input['keyI nput']."][ ]' style='width:146px;'>";
if ($input['is_required'] == 0)
$select .= "<option value='99'".(!isset($respo nse) ? " selected='selected'" : '')."> </option>";
foreach ($sorts as $k=>$s) {
if (!isset($response))
$select .= "<option value='$s'".($k==0 && $input['is_required'] == 1 ? 'selected="selected"' : '').">$s</option>";
else
$select .= "<option value='$s'".($resp_ar[$kid ] == $s ? 'selected="selected"' : '').">$s</option>";
}
$select .= "</select>";
$sort[$input['title']." ".($kid+1)] = "$select";
}
$inputs[$key]['sorting'] = $sort;
}
}
#echo "<pre>"; die(print_r($inputs));
NTemplate::assign("inputs" , $inputs);
if (isset($response)) {
foreach ($inputs as $input) {
if ( $input['is_required'] == 1 && empty( $response[$input['keyInput ']] ) ) {
$errors[] = $input['title'].' value cannot be blank';
}
}
}
$categories = array();
$role = UserEntity::getRoles($user _id);
#die("$user_id, $role");
if (UserEntity::getMenuLimitS etting() == 1) {
global $keyWebSubDomains;
$sub_left_menu = ItemEntity::getViewCategor ies($keyWe bSubDomain s);
#echo "<pre>";print_r($sub_left_ menu);echo "</pre>";
$user_id = NSession::get("user_id");
$access_left_menu = UserEntity::getAccessCateg ories($use r_id);
#echo "<pre>";print_r($access_le ft_menu);e cho "</pre>";
$idx = 0;
foreach ($sub_left_menu as $item) {
if ( ($role == 'RU' && in_array($item['keyWebSubD omainsMenu s'], $access_left_menu)) || $role !== 'RU') {
$checked = in_array($item['keyWebSubD omainsMenu s'], $rep_cats) ? '1' : '0';
$categories[] = array(
"key" => $item['keyWebSubDomainsMen us'],
"parent" => $item['keyWebSubDomainsMen usParent'] ,
'name' => $item['LeftMenuHeader'],
'checked' => $checked,
'level' => $item['level'],
'idx' => $idx
);
$idx++;
}
}
}
NTemplate::assign("categor ies", $categories);
# create a Report
NTemplate::assign("build_r esponse", '');
if (empty($errors) && $cmd != 'params') {
loadEntity('domain');
$keyWebSubDomains = DomainEntity::getSubDomain Key();
$filename = ReportsEntity::createRepor t($cmd, $report, $response, $rep_cats);
if (strpos($filename, '.csv') > 0 || strpos($filename, '.pdf') > 0) {
$parts = explode("/", $_SERVER['PHP_SELF']);
$link = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $parts[count($parts) - 3] . '/' . $parts[count($parts) - 2] . '/ProductImages/Reports/' . $filename;
if ($cmd == 'pdf')
$report_link_pdf = $link;
else
$report_link_csv = $link;
}
else {
NTemplate::assign("build_r esponse", $filename);
}
}
NTemplate::assign("report_ link_pdf", $report_link_pdf);
NTemplate::assign("report_ link_csv", $report_link_csv);
NTemplate::assign("title", $report['title']);
NTemplate::assign("uid", $uid);
NTemplate::assign("cmd", $cmd);
NTemplate::assign("errors" , $errors);
NTemplate::display("sub_re port_build .tpl");
?>
http://mydomain.com/ban/main/report_build.php? Is the URL when I get the error. This directs us back up two folder levels, but the Reports.php file is two levels back down, basically at http://mydomain.com/application/entity/reports.php.
The content of report_build.php page is
<?php
//load file which contain including Smarty, PEAR and other required libraries
require_once "../../sub_report_build.ph
?>
The content of sub_report_build.php is
<?php
//load file which contain including Smarty, PEAR and other required libraries
require_once "_loader.php";
if(!UserEntity::checkRoles
$Msgr->sendMessage("login.
General::Redirect("login.p
}
$uid = http_request('uid');
$cmd = http_request('cmd');
if (!isset($cmd) || empty($cmd)) $cmd = 'params';
$response = http_request('input');
NTemplate::assign("respons
$rep_cats = http_request('rep_cats');
$report_link_pdf = http_request('report_link_
$report_link_csv = http_request('report_link_
$errors = array();
loadEntity('user');
loadEntity('reports');
# the method doesn't return data for USER ?????????????????????
#$report = ReportsEntity::getReport($
$reports = ReportsEntity::getReportsL
foreach($reports as $report) {
if ($report['keyReport'] == $uid) {
NTemplate::assign("report"
break;
}
}
$inputs = ReportsEntity::getInputsLi
foreach($inputs as $key => $input) {
if ($input['data_type'] == 'Select' && !empty($input['sorting']))
$sort = array();
$sorts = explode(';', $input['sorting']);
$resp_ar = isset($response) ? $response[$input['keyInput
foreach ($sorts as $kid=>$sid) {
$select = "<select name='input[".$input['keyI
if ($input['is_required'] == 0)
$select .= "<option value='99'".(!isset($respo
foreach ($sorts as $k=>$s) {
if (!isset($response))
$select .= "<option value='$s'".($k==0 && $input['is_required'] == 1 ? 'selected="selected"' : '').">$s</option>";
else
$select .= "<option value='$s'".($resp_ar[$kid
}
$select .= "</select>";
$sort[$input['title']." ".($kid+1)] = "$select";
}
$inputs[$key]['sorting'] = $sort;
}
}
#echo "<pre>"; die(print_r($inputs));
NTemplate::assign("inputs"
if (isset($response)) {
foreach ($inputs as $input) {
if ( $input['is_required'] == 1 && empty( $response[$input['keyInput
$errors[] = $input['title'].' value cannot be blank';
}
}
}
$categories = array();
$role = UserEntity::getRoles($user
#die("$user_id, $role");
if (UserEntity::getMenuLimitS
global $keyWebSubDomains;
$sub_left_menu = ItemEntity::getViewCategor
#echo "<pre>";print_r($sub_left_
$user_id = NSession::get("user_id");
$access_left_menu = UserEntity::getAccessCateg
#echo "<pre>";print_r($access_le
$idx = 0;
foreach ($sub_left_menu as $item) {
if ( ($role == 'RU' && in_array($item['keyWebSubD
$checked = in_array($item['keyWebSubD
$categories[] = array(
"key" => $item['keyWebSubDomainsMen
"parent" => $item['keyWebSubDomainsMen
'name' => $item['LeftMenuHeader'],
'checked' => $checked,
'level' => $item['level'],
'idx' => $idx
);
$idx++;
}
}
}
NTemplate::assign("categor
# create a Report
NTemplate::assign("build_r
if (empty($errors) && $cmd != 'params') {
loadEntity('domain');
$keyWebSubDomains = DomainEntity::getSubDomain
$filename = ReportsEntity::createRepor
if (strpos($filename, '.csv') > 0 || strpos($filename, '.pdf') > 0) {
$parts = explode("/", $_SERVER['PHP_SELF']);
$link = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $parts[count($parts) - 3] . '/' . $parts[count($parts) - 2] . '/ProductImages/Reports/' . $filename;
if ($cmd == 'pdf')
$report_link_pdf = $link;
else
$report_link_csv = $link;
}
else {
NTemplate::assign("build_r
}
}
NTemplate::assign("report_
NTemplate::assign("report_
NTemplate::assign("title",
NTemplate::assign("uid", $uid);
NTemplate::assign("cmd", $cmd);
NTemplate::assign("errors"
NTemplate::display("sub_re
?>
Where is reports.php referenced/included (it seems as if it isn't)?
ASKER
$_logo = '../../' . $subDomain .'/'. $main . '/ProductImages/HeaderImag es/'.$repo rt['header _image'];
I don't think this train of thought is productive. I have tried changing the relative path to ../, ../../, ../../../ and ../../../../. I have also tried entering the actual URL of the image instead of a relative path,
$_logo = 'http://mydomain.com/ban/main/ProductImages/HeaderImages/bbts_header.jpg';
I'm not sure if that is the right syntax for that, but it doesn't work either.
I think the issue is not in the relative path. It worked up until a couple of weeks ago and this type of relative path works in other areas of the website. I believe the issue is based around PDFs loading images.
I don't think this train of thought is productive. I have tried changing the relative path to ../, ../../, ../../../ and ../../../../. I have also tried entering the actual URL of the image instead of a relative path,
$_logo = 'http://mydomain.com/ban/main/ProductImages/HeaderImages/bbts_header.jpg';
I'm not sure if that is the right syntax for that, but it doesn't work either.
I think the issue is not in the relative path. It worked up until a couple of weeks ago and this type of relative path works in other areas of the website. I believe the issue is based around PDFs loading images.
Could it be a permissions issue with the files or folders involved? How are these files and folders CHMOD'd?
ASKER
It's not a permissions issue. The images are accessed in other areas of the sites, but it the PDFs are no longer able to access the images.
Thanks for trying the exact path as that was going to be my next question.
Check the TCPDF cache folder permissions.
Also, double check permissions on the files and folders as TCPDF accesses files as an anonymous user.
Check php.ini allow_url_fopen = On; allow_url_include = On;
Check the TCPDF cache folder permissions.
Also, double check permissions on the files and folders as TCPDF accesses files as an anonymous user.
Check php.ini allow_url_fopen = On; allow_url_include = On;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://mydomain.com/ban/main/ProductImages/HeaderImages/bbts_header.jpg