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) |
||
3 | die ( 'Not A Valid Entry Point' ) ; |
||
4 | /********************************************************************************* |
||
5 | * SugarCRM Community Edition is a customer relationship management program developed by |
||
6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
||
7 | |||
8 | * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
||
9 | * Copyright (C) 2011 - 2014 Salesagility Ltd. |
||
10 | * |
||
11 | * This program is free software; you can redistribute it and/or modify it under |
||
12 | * the terms of the GNU Affero General Public License version 3 as published by the |
||
13 | * Free Software Foundation with the addition of the following permission added |
||
14 | * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
||
15 | * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
||
16 | * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
||
17 | * |
||
18 | * This program is distributed in the hope that it will be useful, but WITHOUT |
||
19 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
||
20 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
||
21 | * details. |
||
22 | * |
||
23 | * You should have received a copy of the GNU Affero General Public License along with |
||
24 | * this program; if not, see http://www.gnu.org/licenses or write to the Free |
||
25 | * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
||
26 | * 02110-1301 USA. |
||
27 | * |
||
28 | * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
||
29 | * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
||
30 | * |
||
31 | * The interactive user interfaces in modified source and object code versions |
||
32 | * of this program must display Appropriate Legal Notices, as required under |
||
33 | * Section 5 of the GNU Affero General Public License version 3. |
||
34 | * |
||
35 | * In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
||
36 | * these Appropriate Legal Notices must retain the display of the "Powered by |
||
37 | * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
||
38 | * reasonably feasible for technical reasons, the Appropriate Legal Notices must |
||
39 | * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
||
40 | ********************************************************************************/ |
||
41 | |||
42 | |||
43 | require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ; |
||
44 | |||
45 | class ParserLabel //extends ModuleBuilderParser |
||
46 | { |
||
47 | |||
48 | public function __construct ($moduleName, $packageName = '' ) |
||
49 | { |
||
50 | $this->moduleName = $moduleName; |
||
51 | if (!empty($packageName)) |
||
52 | $this->packageName = $packageName ; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead |
||
57 | */ |
||
58 | public function ParserLabel($moduleName, $packageName = '' ){ |
||
59 | $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code'; |
||
60 | if(isset($GLOBALS['log'])) { |
||
61 | $GLOBALS['log']->deprecated($deprecatedMessage); |
||
62 | } |
||
63 | else { |
||
64 | trigger_error($deprecatedMessage, E_USER_DEPRECATED); |
||
65 | } |
||
66 | self::__construct($moduleName, $packageName); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Takes in the request params from a save request and processes |
||
71 | * them for the save. |
||
72 | * @param REQUEST $params Labels as "label_".System label => Display label pairs |
||
73 | * @param string $language Language key, for example 'en_us' |
||
74 | */ |
||
75 | function handleSave ($params , $language) |
||
76 | { |
||
77 | $labels = array ( ) ; |
||
78 | foreach ( $params as $key => $value ) |
||
79 | { |
||
80 | if (preg_match ( '/^label_/', $key ) && strcmp ( $value, 'no_change' ) != 0) |
||
81 | { |
||
82 | $labels [ strtoupper(substr ( $key, 6 )) ] = SugarCleaner::cleanHtml(from_html($value),false); |
||
83 | } |
||
84 | } |
||
85 | if (!empty($this->packageName)) //we are in Module builder |
||
86 | { |
||
87 | return self::addLabels ( $language, $labels, $this->moduleName, "custom/modulebuilder/packages/{$this->packageName}/modules/{$this->moduleName}/language" ) ; |
||
88 | } else |
||
89 | { |
||
90 | return self::addLabels ( $language, $labels, $this->moduleName ) ; |
||
91 | } |
||
92 | } |
||
93 | |||
94 | /* |
||
95 | * Remove a label from the language pack for a module |
||
96 | * @param string $language Language key, for example 'en_us' |
||
97 | * @param string $label The label to remove |
||
98 | * @param string $labelvalue The value of the label to remove |
||
99 | * @param string $moduleName Name of the module to which to add these labels |
||
100 | * @param string $basepath base path of the language file |
||
101 | * @param string $forRelationshipLabel whether this is a relationship label |
||
102 | */ |
||
103 | static function removeLabel($language, $label, $labelvalue, $moduleName, $basepath = null, $forRelationshipLabel = false) { |
||
104 | $GLOBALS [ 'log' ]->debug ( "ParserLabel->removeLabels($language, \$label, \$labelvalue, $moduleName, $basepath );" ) ; |
||
105 | if (is_null ( $basepath )) |
||
106 | { |
||
107 | $deployedModule = true ; |
||
108 | $basepath = "custom/modules/$moduleName/language" ; |
||
109 | if($forRelationshipLabel){ |
||
110 | $basepath = "custom/modules/$moduleName/Ext/Language" ; |
||
111 | } |
||
112 | if (! is_dir ( $basepath )) |
||
113 | { |
||
114 | $GLOBALS ['log']->debug("$basepath is not a directory."); |
||
115 | return false; |
||
116 | } |
||
117 | } |
||
118 | |||
119 | $filename = "$basepath/$language.lang.php" ; |
||
120 | if($forRelationshipLabel){ |
||
121 | $filename = "$basepath/$language.lang.ext.php" ; |
||
122 | } |
||
123 | |||
124 | $dir_exists = is_dir ( $basepath ) ; |
||
125 | |||
126 | $mod_strings = array ( ) ; |
||
127 | |||
128 | if ($dir_exists) |
||
129 | { |
||
130 | if (file_exists ($filename)) |
||
131 | { |
||
132 | // obtain $mod_strings |
||
133 | include ($filename) ; |
||
134 | } else { |
||
135 | $GLOBALS ['log']->debug("file $filename does not exist."); |
||
136 | return false; |
||
137 | } |
||
138 | } else { |
||
139 | $GLOBALS ['log']->debug("directory $basepath does not exist."); |
||
140 | return false ; |
||
141 | } |
||
142 | |||
143 | $changed = false ; |
||
144 | |||
145 | if (isset($mod_strings[$label]) && $mod_strings[$label]==$labelvalue) { |
||
146 | unset($mod_strings[$label]); |
||
147 | $changed = true; |
||
148 | } |
||
149 | |||
150 | if ($changed) |
||
151 | { |
||
152 | if (! write_array_to_file ( "mod_strings", $mod_strings, $filename )) { |
||
153 | $GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ; |
||
154 | } else { |
||
155 | // if we have a cache to worry about, then clear it now |
||
156 | if ($deployedModule) { |
||
157 | $GLOBALS ['log']->debug ( "PaserLabel->addLabels: clearing language cache" ) ; |
||
158 | $cache_key = "module_language." . $language . $moduleName ; |
||
159 | sugar_cache_clear ( $cache_key ) ; |
||
160 | LanguageManager::clearLanguageCache ( $moduleName, $language ) ; |
||
161 | } |
||
162 | } |
||
163 | } |
||
164 | |||
165 | return true ; |
||
166 | } |
||
167 | |||
168 | /* |
||
169 | * Add a set of labels to the language pack for a module, deployed or undeployed |
||
170 | * @param string $language Language key, for example 'en_us' |
||
171 | * @param array $labels The labels to add in the form of an array of System label => Display label pairs |
||
172 | * @param string $moduleName Name of the module to which to add these labels |
||
173 | * @param string $packageName If module is undeployed, name of the package to which it belongs |
||
0 ignored issues
–
show
|
|||
174 | */ |
||
175 | static function addLabels ($language , $labels , $moduleName , $basepath = null, $forRelationshipLabel = false) |
||
176 | { |
||
177 | |||
178 | $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );" ) ; |
||
179 | $GLOBALS [ 'log' ]->debug ( "\$labels:" . print_r ( $labels, true ) ) ; |
||
180 | |||
181 | $deployedModule = false ; |
||
182 | if (is_null ( $basepath )) |
||
183 | { |
||
184 | $deployedModule = true ; |
||
185 | $basepath = "custom/modules/$moduleName/language" ; |
||
186 | if($forRelationshipLabel){ |
||
187 | $basepath = "custom/modules/$moduleName/Ext/Language" ; |
||
188 | } |
||
189 | if (! is_dir ( $basepath )) |
||
190 | { |
||
191 | mkdir_recursive($basepath); |
||
192 | } |
||
193 | } |
||
194 | |||
195 | $filename = "$basepath/$language.lang.php" ; |
||
196 | if($forRelationshipLabel){ |
||
197 | $filename = "$basepath/$language.lang.ext.php" ; |
||
198 | } |
||
199 | $dir_exists = is_dir ( $basepath ) ; |
||
200 | |||
201 | $mod_strings = array ( ) ; |
||
202 | |||
203 | if ($dir_exists) |
||
204 | { |
||
205 | if (file_exists ( $filename )) |
||
206 | { |
||
207 | // obtain $mod_strings |
||
208 | include ($filename) ; |
||
209 | }else if($forRelationshipLabel){ |
||
210 | $fh = fopen ($filename, 'a'); |
||
211 | fclose($fh); |
||
212 | } |
||
213 | } else |
||
214 | { |
||
215 | return false ; |
||
216 | } |
||
217 | |||
218 | $changed = false ; |
||
219 | |||
220 | //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ; |
||
221 | |||
222 | foreach ( $labels as $key => $value ) |
||
223 | { |
||
224 | if (! isset ( $mod_strings [ $key ] ) || strcmp ( $value, $mod_strings [ $key ] ) != 0) |
||
225 | { |
||
226 | $mod_strings [$key] = to_html(strip_tags(from_html($value))); // must match encoding used in view.labels.php |
||
227 | $changed = true ; |
||
228 | } |
||
229 | } |
||
230 | |||
231 | if ($changed) |
||
232 | { |
||
233 | $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: writing new mod_strings to $filename" ) ; |
||
234 | $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: mod_strings=".print_r($mod_strings,true) ) ; |
||
235 | if (! write_array_to_file ( "mod_strings", $mod_strings, $filename )) |
||
236 | { |
||
237 | $GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ; |
||
238 | } else |
||
239 | { |
||
240 | // if we have a cache to worry about, then clear it now |
||
241 | if ($deployedModule) |
||
242 | { |
||
243 | SugarCache::cleanOpcodes(); |
||
244 | $GLOBALS [ 'log' ]->debug ( "PaserLabel->addLabels: clearing language cache" ) ; |
||
245 | $cache_key = "module_language." . $language . $moduleName ; |
||
246 | sugar_cache_clear ( $cache_key ) ; |
||
247 | LanguageManager::clearLanguageCache ( $moduleName, $language ) ; |
||
248 | } |
||
249 | } |
||
250 | } |
||
251 | |||
252 | // Fix for bug #51 |
||
253 | // when the label is recreated it defaults back to the original value (In this case its "User"). |
||
254 | |||
255 | // Solution: |
||
256 | // 1. Changes to the label names should go to custom/Extension/modules/{ModuleName}/Ext/Language |
||
257 | // This is done in case different users edit the same Relationship concurrently. |
||
258 | // The changes from custom/Extension/modules/{ModuleName}/Ext/Language |
||
259 | // will overwrite stuff in custom/modules/{ModuleName}/Ext/Language/en_us.lang.ext.php after |
||
260 | // Quick Repair and Rebuild is applied. |
||
261 | if($forRelationshipLabel) { |
||
262 | if(!empty($_POST[view_module]) && !empty($_POST[relationship_name]) && !empty($_POST[rhs_label]) && !empty($_POST[lhs_module])) { |
||
263 | // 1. Overwrite custom/Extension/modules/{ModuleName}/Ext/Language |
||
264 | $extension_basepath = "custom/Extension/modules/" . $_POST[view_module] . "/Ext/Language"; |
||
265 | mkdir_recursive($extension_basepath); |
||
266 | |||
267 | $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n"; |
||
268 | $out = $headerString; |
||
269 | |||
270 | $extension_filename = "$extension_basepath/$language.custom" . $_POST[relationship_name] . ".php"; |
||
271 | |||
272 | $mod_strings = array(); |
||
273 | if (file_exists($extension_filename)) { |
||
274 | // obtain $mod_strings |
||
275 | include($extension_filename); |
||
276 | } |
||
277 | |||
278 | $changed_mod_strings = false; |
||
279 | foreach ($labels as $key => $value) { |
||
280 | foreach ($mod_strings as $key_mod_string => $value_mod_string) { |
||
281 | if (strpos($key_mod_string, strtoupper($_POST[relationship_name])) !== false) { |
||
282 | $mod_strings[$key_mod_string] = to_html(strip_tags(from_html($_POST[rhs_label]))); // must match encoding used in view.labels.php |
||
283 | $changed_mod_strings = true; |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | |||
288 | foreach ($mod_strings as $key => $val) |
||
289 | $out .= override_value_to_string_recursive2('mod_strings', $key, $val); |
||
290 | |||
291 | $failed_to_write = false; |
||
292 | try { |
||
293 | $file_contents = fopen($extension_filename, 'w'); |
||
294 | fputs($file_contents, $out, strlen($out)); |
||
295 | fclose($file_contents); |
||
296 | } catch (Exception $e) { |
||
297 | $GLOBALS ['log']->fatal("Could not write $filename"); |
||
298 | $GLOBALS ['log']->fatal("Exception " . $e->getMessage()); |
||
299 | $failed_to_write = true; |
||
300 | } |
||
301 | |||
302 | //2. Overwrite custom/Extension/modules/relationships/language/{ModuleName}.php |
||
303 | // Also need to overwrite custom/Extension/modules/relationships/language/{ModuleName}.php |
||
304 | // because whenever new relationship is created this place is checked by the system to get |
||
305 | // all the label names |
||
306 | $relationships_basepath = "custom/Extension/modules/relationships/language"; |
||
307 | mkdir_recursive($relationships_basepath); |
||
308 | |||
309 | $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n"; |
||
310 | $out = $headerString; |
||
311 | |||
312 | $relationships_filename = "$relationships_basepath/" . $_POST[lhs_module] . ".php"; |
||
313 | |||
314 | |||
315 | $mod_strings = array(); |
||
316 | if (file_exists($relationships_filename)) { |
||
317 | // obtain $mod_strings |
||
318 | include($relationships_filename); |
||
319 | } |
||
320 | |||
321 | $changed_mod_strings = false; |
||
322 | foreach ($labels as $key => $value) { |
||
323 | foreach ($mod_strings as $key_mod_string => $value_mod_string) { |
||
324 | if (strpos($key_mod_string, strtoupper($_POST[relationship_name])) !== false) { |
||
325 | $mod_strings[$key_mod_string] = to_html(strip_tags(from_html($_POST[rhs_label]))); // must match encoding used in view.labels.php |
||
326 | $changed_mod_strings = true; |
||
327 | } |
||
328 | } |
||
329 | } |
||
330 | |||
331 | foreach ($mod_strings as $key => $val) |
||
332 | $out .= override_value_to_string_recursive2('mod_strings', $key, $val); |
||
333 | |||
334 | $failed_to_write = false; |
||
335 | try { |
||
336 | $file_contents = fopen($relationships_filename, 'w'); |
||
337 | fputs($file_contents, $out, strlen($out)); |
||
338 | fclose($file_contents); |
||
339 | } catch (Exception $e) { |
||
340 | $GLOBALS ['log']->fatal("Could not write $filename"); |
||
341 | $GLOBALS ['log']->fatal("Exception " . $e->getMessage()); |
||
342 | $failed_to_write = true; |
||
343 | } |
||
344 | |||
345 | if ($changed_mod_strings) { |
||
346 | if (!$failed_to_write) { |
||
347 | // if we have a cache to worry about, then clear it now |
||
348 | if ($deployedModule) { |
||
349 | SugarCache::cleanOpcodes(); |
||
350 | $GLOBALS ['log']->debug("PaserLabel->addLabels: clearing language cache"); |
||
351 | $cache_key = "module_language." . $language . $moduleName; |
||
352 | sugar_cache_clear($cache_key); |
||
353 | LanguageManager::clearLanguageCache($moduleName, $language); |
||
354 | } |
||
355 | } |
||
356 | } |
||
357 | } |
||
358 | } |
||
359 | |||
360 | return true ; |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * Takes in the request params from a save request and processes |
||
365 | * them for the save. |
||
366 | * @param $metadata |
||
367 | * @param string $language Language key, for example 'en_us' |
||
368 | */ |
||
369 | function handleSaveRelationshipLabels ($metadata , $language) |
||
370 | { |
||
371 | foreach ( $metadata as $definition ) |
||
372 | { |
||
373 | $labels = array(); |
||
374 | $labels[$definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
||
375 | self::addLabels ( $language, $labels, $definition [ 'module' ],null,true ); |
||
376 | } |
||
377 | } |
||
378 | |||
379 | function addLabelsToAllLanguages($labels) |
||
380 | { |
||
381 | $langs = get_languages(); |
||
382 | foreach($langs as $lang_key => $lang_display) |
||
383 | { |
||
384 | $this->addLabels($lang_key, $labels, $this->moduleName); |
||
385 | } |
||
386 | } |
||
387 | } |
||
388 | |||
389 | ?> |
||
390 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.