Skip to content

Commit

Permalink
Update getConfig.php
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickCRM authored Apr 3, 2018
1 parent b420f8b commit cb82cb8
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions modules/QuickCRM/getConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit cb82cb8

Please sign in to comment.