<?php require_once 'nucommon.php'; $response = array(); $response['DATA'] = ''; $response['SUCCESS'] = false; $response['ERRORS'] = array(); $GLOBALS['ERRORS'] = array(); $hashData = nuHashData(); $code = $_GET['c']; $sql = "SELECT * FROM zzzsys_php WHERE slp_code = ?"; $t = nuRunQuery($sql, array($code)); $r = db_fetch_object($t); if (nuPHPAccess($r->zzzsys_php_id)) { $r->slp_php = nuGetSafePHP('slp_php', $r->zzzsys_php_id, $r->slp_php); $e = nuReplaceHashes($r->slp_php, $hashData); eval($e); $response['DATA'] = $nuParameters; if ($nuError != '') { $response['ERRORS'][] = $nuError; } } else { $response['ERRORS'][] = "Access denied to PHP - ({$r->slp_code})"; } print json_encode($response);
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; }