Issues (4069)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

modules/Campaigns/Subscriptions.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
 <?php
0 ignored issues
show
It is not recommended to output anything before PHP's opening tag in non-template files.
Loading history...
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
/*********************************************************************************
42
43
 * Description:  TODO: To be written.
44
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
45
 * All Rights Reserved.
46
 * Contributor(s): ______________________________________..
47
 ********************************************************************************/
48
49
require_once('modules/Campaigns/utils.php');
50
51
global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map;
52
global $import_file_name, $theme;
53
54
$focus = 0;
55
if(isset($_REQUEST['return_module'])){
56
    if($_REQUEST['return_module'] == 'Contacts'){
57
58
        $focus = new Contact();
59
    }
60
    if($_REQUEST['return_module'] == 'Leads'){
61
62
        $focus = new Lead();
63
    }
64
    if($_REQUEST['return_module'] == 'Prospects'){
65
66
        $focus = new Prospect();
67
    }
68
}
69
70
if(isset($_REQUEST['record'])) {
71
    $GLOBALS['log']->debug("In Subscriptions, about to retrieve record: ".$_REQUEST['record']);
72
    $result = $focus->retrieve($_REQUEST['record']);
73
    if($result == null)
74
    {
75
        sugar_die($app_strings['ERROR_NO_RECORD']);
76
    }
77
}
78
79
80
$this->ss->assign("MOD", $mod_strings);
81
$this->ss->assign("APP", $app_strings);
82
83
if(isset($_REQUEST['return_module'])) {
84
    $this->ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
85
} else {
86
    $this->ss->assign("RETURN_MODULE", '');
87
}
88
if(isset($_REQUEST['return_id'])){
89
    $this->ss->assign("RETURN_ID", $_REQUEST['return_id']);
90
} else {
91
    $this->ss->assign("RETURN_ID", '');
92
}
93
if(isset($_REQUEST['return_action'])){
94
    $this->ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
95
} else {
96
    $this->ss->assign("RETURN_ACTION", '');
97
}
98
if(isset($_REQUEST['record'])){
99
    $this->ss->assign("RECORD", $_REQUEST['record']);
100
} else {
101
    $this->ss->assign("RECORD", '');
102
}
103
104
//if subsaction has been set, then process subscriptions
105
if(isset($_REQUEST['subs_action'])){manageSubscriptions($focus);}
106
107
//$title = $GLOBALS['app_strings']['LBL_MANAGE_SUBSCRIPTIONS_FOR'].$focus->name;
108
$params = array();
109
$params[]  = "<a href='index.php?module={$focus->module_dir}&action=index'>{$focus->module_dir}</a>";
110
$params[] = "<a href='index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}'>{$focus->name}</a>";
111
$params[] = $mod_strings['LBL_MANAGE_SUBSCRIPTIONS_TITLE'];
112
$title = getClassicModuleTitle($focus->module_dir, $params, true);
113
$orig_vals_str = printOriginalValues($focus);
114
$orig_vals_array = constructDDSubscriptionList($focus);
115
116
$this->ss->assign('APP', $app_strings);
117
$this->ss->assign('MOD', $mod_strings);
118
$this->ss->assign('title',  $title);
119
120
$this->ss->assign('enabled_subs', $orig_vals_array[0]);
121
$this->ss->assign('disabled_subs', $orig_vals_array[1]);
122
$this->ss->assign('enabled_subs_string', $orig_vals_str[0]);
123
$this->ss->assign('disabled_subs_string', $orig_vals_str[1]);
124
125
$buttons = array(
126
    '<input id="save_button" title="'.$app_strings['LBL_SAVE_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_SAVE_BUTTON_KEY'].'" class="button" onclick="save();this.form.action.value=\'Subscriptions\'; " type="submit" name="button" value="'.$app_strings['LBL_SAVE_BUTTON_LABEL'].'">',
127
    '<input id="cancel_button" title="'.$app_strings['LBL_CANCEL_BUTTON_TITLE'].'" accessKey="'.$app_strings['LBL_CANCEL_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\''.$this->ss->get_template_vars('RETURN_ACTION').'\'; this.form.module.value=\''.$this->ss->get_template_vars('RETURN_MODULE').'\';" type="submit" name="button" value="'.$app_strings['LBL_CANCEL_BUTTON_LABEL'].'">'
128
);
129
$this->ss->assign('BUTTONS', $buttons);
130
$this->ss->display('modules/Campaigns/Subscriptions.tpl');
131
132
/*
133
 *This function constructs Drag and Drop multiselect box of subscriptions for display in manage subscription form
134
*/
135
function constructDDSubscriptionList($focus,$classname=''){
136
    require_once("include/templates/TemplateDragDropChooser.php");
137
    global $mod_strings;
138
    $unsubs_arr = '';
139
    $subs_arr =  '';
140
141
    // Lets start by creating the subscription and unsubscription arrays
142
    $subscription_arrays = get_subscription_lists($focus);
143
    $unsubs_arr = $subscription_arrays['unsubscribed'];
144
    $subs_arr =  $subscription_arrays['subscribed'];
145
146
    $comb_array = array();
147
	$comb_array [0] = array();
148
	$comb_array [1] = array();
149
150
    foreach ($subs_arr as $key=>$val){
151
        $comb_array [0][$val] = $key;
152
    }
153
154
155
	foreach ($unsubs_arr as $key=>$val){
156
        $comb_array [1][$val] = $key;
157
    }
158
159
    return $comb_array ;
160
161
}
162
163
164
165
/*
166
 *This function constructs multiselect box of subscriptions for display in manage subscription form
167
*/
168
function printOriginalValues($focus){
169
    global $app_strings;
170
    $unsubs_arr = '';
171
    $subs_arr =  '';
172
    $return_arr =  '';
173
174
     // Lets start by creating the subscription and unsubscription arrays
175
        $subscription_arrays = get_subscription_lists($focus);
176
        $unsubs_arr = $subscription_arrays['unsubscribed'];
177
        $subs_arr =  $subscription_arrays['subscribed'];
178
179
//    ORIG_UNSUBS_VALUES
180
        $unsubs_vals = ' ';
181
        $subs_vals = ' ';
182
        foreach($subs_arr as $name => $id){
183
            $subs_vals .= ", $id";
184
        }
185
        $return_arr[]=$subs_vals;
186
187
        foreach($unsubs_arr as $name => $id){
188
            $unsubs_vals .= ", $id";
189
        }
190
191
        $return_arr[]=$unsubs_vals;
192
193
        return $return_arr;
194
    }
195
196
197
/*
198
 * Perform Subscription management work.  This function processes selected subscriptions and calls the
199
 * right methods to subscribe or unsubscribe the user
200
 * */
201
202
function manageSubscriptions($focus){
203
204
205
    //Process Subscription Lists first
206
    //compare current list of subscriptions to original list and see if there are any additions
207
    $orig_subscription_arr = array();
208
    $curr_subscription_arr = array();
209
    //build array of original subscriptions
210
    if(isset($_REQUEST['orig_enabled_values'])  && ! empty($_REQUEST['orig_enabled_values'])){
211
     $orig_subscription_arr = explode(",", $_REQUEST['orig_enabled_values']);
212
     $orig_subscription_arr = process_subscriptions($orig_subscription_arr);
213
    }
214
215
    //build array of current subscriptions
216
    if(isset($_REQUEST['enabled_subs'])  && ! empty($_REQUEST['enabled_subs'])){
217
     $curr_subscription_arr = explode(",", $_REQUEST['enabled_subs']);
218
     $curr_subscription_arr = process_subscriptions($curr_subscription_arr);
219
    }
220
221
    //compare both arrays and find differences
222
    $i=0;
223
    while($i<(count($curr_subscription_arr)/2)){
224
        //if current subscription existed in original subscription list, do nothing
225
        if(in_array($curr_subscription_arr['campaign'.$i], $orig_subscription_arr)){
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
226
            //nothing to process
227
        }else{
228
         //current subscription is new, so subscribe
229
            subscribe($curr_subscription_arr['campaign'.$i], $curr_subscription_arr['prospect_list'.$i], $focus);
230
        }
231
        $i = $i +1;
232
    }
233
234
    //Now process UnSubscription Lists first
235
    //compare current list of subscriptions to original list and see if there are any additions
236
    $orig_unsubscription_arr = array();
237
    $curr_unsubscription_arr = array();
238
239
    //build array of original subscriptions
240
    if(isset($_REQUEST['orig_disabled_values'])  && ! empty($_REQUEST['orig_disabled_values'])){
241
     $orig_unsubscription_arr = explode(",", $_REQUEST['orig_disabled_values']);
242
     $orig_unsubscription_arr = process_subscriptions($orig_unsubscription_arr);
243
    }
244
245
    //build array of current subscriptions
246
    if(isset($_REQUEST['disabled_subs'])  && ! empty($_REQUEST['disabled_subs'])){
247
     $curr_unsubscription_arr = explode(",", $_REQUEST['disabled_subs']);
248
     $curr_unsubscription_arr = process_subscriptions($curr_unsubscription_arr);
249
    }
250
    //compare both arrays and find differences
251
    $i=0;
252
    while($i<(count($curr_unsubscription_arr)/2)){
253
        //if current subscription existed in original subscription list, do nothing
254
        if(in_array($curr_unsubscription_arr['campaign'.$i], $orig_unsubscription_arr)){
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
255
            //nothing to process
256
        }else{
257
         //current subscription is new, so subscribe
258
            unsubscribe($curr_unsubscription_arr['campaign'.$i], $focus);
259
        }
260
        $i = $i +1;
261
    }
262
263
}
264
265
?>