adamjakab    /
                    SuiteCRM
                
                            This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
                                via PHP's auto-loading mechanism.
                                                    These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php  | 
            ||
| 2 | if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | 
            ||
| 3 | /*********************************************************************************  | 
            ||
| 4 | * SugarCRM Community Edition is a customer relationship management program developed by  | 
            ||
| 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.  | 
            ||
| 6 | |||
| 7 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.  | 
            ||
| 8 | * Copyright (C) 2011 - 2014 Salesagility Ltd.  | 
            ||
| 9 | *  | 
            ||
| 10 | * This program is free software; you can redistribute it and/or modify it under  | 
            ||
| 11 | * the terms of the GNU Affero General Public License version 3 as published by the  | 
            ||
| 12 | * Free Software Foundation with the addition of the following permission added  | 
            ||
| 13 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK  | 
            ||
| 14 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY  | 
            ||
| 15 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.  | 
            ||
| 16 | *  | 
            ||
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT  | 
            ||
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  | 
            ||
| 19 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more  | 
            ||
| 20 | * details.  | 
            ||
| 21 | *  | 
            ||
| 22 | * You should have received a copy of the GNU Affero General Public License along with  | 
            ||
| 23 | * this program; if not, see http://www.gnu.org/licenses or write to the Free  | 
            ||
| 24 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  | 
            ||
| 25 | * 02110-1301 USA.  | 
            ||
| 26 | *  | 
            ||
| 27 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,  | 
            ||
| 28 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].  | 
            ||
| 29 | *  | 
            ||
| 30 | * The interactive user interfaces in modified source and object code versions  | 
            ||
| 31 | * of this program must display Appropriate Legal Notices, as required under  | 
            ||
| 32 | * Section 5 of the GNU Affero General Public License version 3.  | 
            ||
| 33 | *  | 
            ||
| 34 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3,  | 
            ||
| 35 | * these Appropriate Legal Notices must retain the display of the "Powered by  | 
            ||
| 36 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not  | 
            ||
| 37 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must  | 
            ||
| 38 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".  | 
            ||
| 39 | ********************************************************************************/  | 
            ||
| 40 | |||
| 41 | require_once('include/MVC/View/SugarView.php'); | 
            ||
| 42 | |||
| 43 | |||
| 44 | class ImportView extends SugarView  | 
            ||
| 45 | { | 
            ||
| 46 | protected $currentStep;  | 
            ||
| 47 | protected $pageTitleKey;  | 
            ||
| 48 | protected $instruction;  | 
            ||
| 49 | |||
| 50 | public function __construct($bean = null, $view_object_map = array())  | 
            ||
| 51 |     { | 
            ||
| 52 | global $mod_strings;  | 
            ||
| 53 | |||
| 54 | parent::__construct($bean, $view_object_map);  | 
            ||
| 55 | |||
| 56 |         if (isset($_REQUEST['button']) && trim($_REQUEST['button']) == htmlentities($mod_strings['LBL_BACK'])) { | 
            ||
| 57 | // if the request comes from the "Back" button, decrease the step count  | 
            ||
| 58 | $this->currentStep = isset($_REQUEST['current_step']) ? ($_REQUEST['current_step'] - 1) : 1;  | 
            ||
| 59 |         } else { | 
            ||
| 60 | $this->currentStep = isset($_REQUEST['current_step']) ? ($_REQUEST['current_step'] + 1) : 1;  | 
            ||
| 61 | }  | 
            ||
| 62 | $this->importModule = isset($_REQUEST['import_module']) ? $_REQUEST['import_module'] : '';  | 
            ||
| 63 | |||
| 64 | }  | 
            ||
| 65 | |||
| 66 | /**  | 
            ||
| 67 | * @see SugarView::getMenu()  | 
            ||
| 68 | */  | 
            ||
| 69 | public function getMenu($module = null)  | 
            ||
| 70 |     { | 
            ||
| 71 | global $mod_strings, $current_language;  | 
            ||
| 72 | |||
| 73 | if ( empty($module) )  | 
            ||
| 74 | $module = $this->importModule;  | 
            ||
| 75 | |||
| 76 | $old_mod_strings = $mod_strings;  | 
            ||
| 77 | $mod_strings = return_module_language($current_language, $module);  | 
            ||
| 78 | $returnMenu = parent::getMenu($module);  | 
            ||
| 79 | $mod_strings = $old_mod_strings;  | 
            ||
| 80 | |||
| 81 | return $returnMenu;  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | /**  | 
            ||
| 85 | * @see SugarView::_getModuleTab()  | 
            ||
| 86 | */  | 
            ||
| 87 | protected function _getModuleTab()  | 
            ||
| 88 |     { | 
            ||
| 89 | global $app_list_strings, $moduleTabMap;  | 
            ||
| 90 | |||
| 91 | // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.  | 
            ||
| 92 | if ( !empty($_REQUEST['module_tab']) )  | 
            ||
| 93 | return $_REQUEST['module_tab'];  | 
            ||
| 94 | elseif ( isset($moduleTabMap[$this->importModule]) )  | 
            ||
| 95 | return $moduleTabMap[$this->importModule];  | 
            ||
| 96 | // Default anonymous pages to be under Home  | 
            ||
| 97 | elseif ( !isset($app_list_strings['moduleList'][$this->importModule]) )  | 
            ||
| 98 | return 'Home';  | 
            ||
| 99 | else  | 
            ||
| 100 | return $this->importModule;  | 
            ||
| 101 | }  | 
            ||
| 102 | |||
| 103 | /**  | 
            ||
| 104 | * Send our output to the importer controller.  | 
            ||
| 105 | *  | 
            ||
| 106 | * @param string $html  | 
            ||
| 107 | * @param string $submitContent  | 
            ||
| 108 | * @param string $script  | 
            ||
| 109 | * @param bool $encode  | 
            ||
| 110 | * @return void  | 
            ||
| 111 | */  | 
            ||
| 112 | protected function sendJsonOutput($html = "", $submitContent = "", $script = "", $encode = FALSE)  | 
            ||
| 113 |     { | 
            ||
| 114 | $title = $this->getModuleTitle(false);  | 
            ||
| 115 | $out = array(  | 
            ||
| 116 | 'html' => $html,  | 
            ||
| 117 | 'submitContent' => $submitContent,  | 
            ||
| 118 | 'title' => $title,  | 
            ||
| 119 | 'script' => $script);  | 
            ||
| 120 | |||
| 121 |         if($encode){ | 
            ||
| 122 |             array_walk($out, create_function('&$val', '$val = htmlspecialchars($val,ENT_NOQUOTES);')); | 
            ||
| 
                                                                                                    
                         0 ignored issues 
                            –
                            show
                         | 
                |||
| 123 | }  | 
            ||
| 124 | echo json_encode($out);  | 
            ||
| 125 | }  | 
            ||
| 126 | |||
| 127 | /**  | 
            ||
| 128 | * @see SugarView::_getModuleTitleParams()  | 
            ||
| 129 | */  | 
            ||
| 130 | protected function _getModuleTitleParams($browserTitle = false)  | 
            ||
| 131 | 	{ | 
            ||
| 132 | global $mod_strings, $app_list_strings;  | 
            ||
| 133 | $returnArray = array(string_format($mod_strings[$this->pageTitleKey], array($this->currentStep)));  | 
            ||
| 134 | |||
| 135 | return $returnArray;  | 
            ||
| 136 | }  | 
            ||
| 137 | |||
| 138 | protected function getInstruction()  | 
            ||
| 139 |     { | 
            ||
| 140 | global $mod_strings;  | 
            ||
| 141 | |||
| 142 | $ins = '';  | 
            ||
| 143 | |||
| 144 |         if ($this->instruction) { | 
            ||
| 145 | $ins_string = $mod_strings[$this->instruction];  | 
            ||
| 146 | $ins = '<div class="import_instruction">' . $ins_string . '</div>';  | 
            ||
| 147 | }  | 
            ||
| 148 | |||
| 149 | return $ins;  | 
            ||
| 150 | }  | 
            ||
| 151 | |||
| 152 | /**  | 
            ||
| 153 | * Displays the Smarty template for an error  | 
            ||
| 154 | *  | 
            ||
| 155 | * @param string $message error message to show  | 
            ||
| 156 | * @param string $module what module we were importing into  | 
            ||
| 157 | * @param string $action what page we should go back to  | 
            ||
| 158 | */  | 
            ||
| 159 | protected function _showImportError($message,$module,$action = 'Step1')  | 
            ||
| 160 |     { | 
            ||
| 161 | $ss = new Sugar_Smarty();  | 
            ||
| 162 | |||
| 163 |         $ss->assign("MESSAGE",$message); | 
            ||
| 164 |         $ss->assign("ACTION",$action); | 
            ||
| 165 |         $ss->assign("IMPORT_MODULE",$module); | 
            ||
| 166 |         $ss->assign("MOD", $GLOBALS['mod_strings']); | 
            ||
| 167 |         $ss->assign("SOURCE",""); | 
            ||
| 168 | if ( isset($_REQUEST['source']) )  | 
            ||
| 169 |             $ss->assign("SOURCE", $_REQUEST['source']); | 
            ||
| 170 | |||
| 171 |         echo $ss->fetch('modules/Import/tpls/error.tpl'); | 
            ||
| 172 | }  | 
            ||
| 173 | }  | 
            
create_functioncan pose a great security vulnerability as it is similar toeval, and could be used for arbitrary code execution. We highly recommend to use a closure instead.