function nuPDForPHPParameters($hashData, $validate = '', $saveToFile = false) { $hash = array(); if ($validate == '') { //-- (runphp or printpdf) $theID = $hashData['parent_record_id']; } else { //-- just validate user access nuV('call_type', $validate); $theID = nuV('code'); } foreach ($hashData as $key => $val) { //-- add current hash variables $hash[$key] = $val; } if (nuV('call_type') == 'runphp') { //-- add php record to hash variables $s = "SELECT * FROM zzzsys_php WHERE slp_code = '{$theID}'"; $t = nuRunQuery($s); if (nuErrorFound()) { return; } $r = db_fetch_object($t); $r->slp_php = nuGetSafePHP('slp_php', $r->zzzsys_php_id, $r->slp_php); if (!nuPHPAccess($r->zzzsys_php_id)) { nuDisplayError("Access denied to PHP - ({$theID})"); return; } foreach ($r as $key => $v) { //-- add php hash variables $hash[$key] = $v; } } if (nuV('call_type') == 'printpdf') { //-- add report record to hash variables $s = "SELECT * FROM zzzsys_report LEFT JOIN zzzsys_php ON sre_zzzsys_php_id = zzzsys_php_id WHERE sre_code = '{$theID}'"; $t = nuRunQuery($s); if (nuErrorFound()) { return; } $r = db_fetch_object($t); $r->slp_php = nuGetSafePHP('slp_php', $r->zzzsys_php_id, $r->slp_php); if (!nuReportAccess($r->zzzsys_report_id)) { nuDisplayError("Access denied to Report - ({$theID})"); return; } foreach ($r as $key => $v) { //-- add pdf hash variables $hash[$key] = $v; } } if ($validate != '' and $saveToFile == false) { return; } //-- just check $i = nuID(); $hash['sfi_blob'] = null; $j = json_encode($hash); $d = date('Y-m-d h:i:s'); nuRunQuery("INSERT INTO zzzsys_debug (zzzsys_debug_id, deb_message, deb_added) VALUES(?, ?, ?)", array($i, $j, $d)); if (nuErrorFound()) { return; } if (nuV('call_type') == 'printpdf' and nuV('filename') != '') { //-- save pdf to server return nuEmailGetReportFile($i); } return $i; }
} else { if (trim($_REQUEST['calltype']) == 'printpdf') { $request_url .= "nurunpdf.php?i=" . $_REQUEST['debug']; } else { $response['DATA']['email_result'] = false; $response['DATA']['email_message'] = "Invalid Request Type: " . $_REQUEST['calltype']; echo json_encode($response); die; } } if (nuValidateEmailAddress($_REQUEST['to'])) { $to = $_REQUEST['to']; $replyto = $_REQUEST['replyto']; $subject = $_REQUEST['subject']; $content = $_REQUEST['message']; $html = false; $wordWrap = 120; $filelist = array(); $filename = $_REQUEST['attachment']; $report = nuEmailGetReportFile('', $request_url); $filelist[$filename] = $report; $result = nuSendEmail($to, $replyto, $content, $html, $subject, $wordWrap, $filelist); @unlink($report); $response['DATA']['email_result'] = $result[0]; $response['DATA']['email_message'] = $result[1]; echo json_encode($response); } else { $response['DATA']['email_result'] = false; $response['DATA']['email_message'] = "Invalid Email Address"; echo json_encode($response); }