From cb82cb82188f9436f9846747fd29fa97a9275973 Mon Sep 17 00:00:00 2001 From: QuickCRM Date: Tue, 3 Apr 2018 16:08:08 +0200 Subject: [PATCH] Update getConfig.php --- modules/QuickCRM/getConfig.php | 47 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/modules/QuickCRM/getConfig.php b/modules/QuickCRM/getConfig.php index 0e92927..8f3ed3a 100644 --- a/modules/QuickCRM/getConfig.php +++ b/modules/QuickCRM/getConfig.php @@ -2,37 +2,36 @@ header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Methods: POST,GET"); header("Access-Control-Allow-Credentials: true"); -ob_clean(); + $res=''; -$already_encoded=false; -if ($_REQUEST['param']=='plugin') { - if (file_exists('custom/QuickCRM/plugins/'.$_REQUEST['name'])) { - $res= file_get_contents('custom/QuickCRM/plugins/'.basename($_REQUEST['name']),true); - } -} -elseif ($_REQUEST['param']=='custom') { - $res= file_get_contents('custom/QuickCRM/custom.js',true); + +if ($_REQUEST['param']=='file') { + header("Content-Type: text/plain"); + $res= file_get_contents('custom/QuickCRM/'.basename($_REQUEST['name']),true); } else { - $prefix='QuickCRM_'; - require_once('modules/Administration/Administration.php'); - $admin = new Administration(); - if (isset($_REQUEST['trial'])) $prefix .= 'trial'; - $admin->retrieveSettings($prefix); // load all settings from db - if (isset($admin->settings[$prefix.$_REQUEST['param'].'f']) && $admin->settings[$prefix.$_REQUEST['param'].'f']=='1'){ - $f='mobile'.(isset($_REQUEST['trial'])?'_trial':'').'/fielddefs/'; - $res= file_get_contents($f.$_REQUEST['param'].'.js',true); - } - else { - $already_encoded=true; - $res= $admin->settings[$prefix.$_REQUEST['param']]; + header("Content-Type: application/javascript"); + $f='mobile'.(isset($_REQUEST['trial'])?'_trial':'').'/fielddefs/'; + + switch ($_REQUEST['param']){ + case 'custom': + if (file_exists('custom/QuickCRM/custom.js')){ + $res = file_get_contents('custom/QuickCRM/custom.js',true); + } + break; + case 'sugar_config': + $res .= file_get_contents($f.'../config.js',true); + break; + default: + $res= file_get_contents($f.basename($_REQUEST['param']).'.js',true); + break; } } - +ob_clean(); if (isset($_REQUEST['to_json'])){ - echo $_GET["jsoncallback"] . '({response: "' . ($already_encoded ? $res : base64_encode($res)) . '"});'; + echo $_GET["jsoncallback"] . '({response: "' . base64_encode($res) . '"});'; } else { - echo ($already_encoded ? base64_decode($res) : $res); + echo $res; } die;