GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( ca4e83...78be4d )
by gyeong-won
13:50
created

memberController   D

Complexity

Total Complexity 518

Size/Duplication

Total Lines 2778
Duplicated Lines 16.2 %

Coupling/Cohesion

Components 1
Dependencies 11
Metric Value
wmc 518
lcom 1
cbo 11
dl 450
loc 2778
rs 4

54 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
C procMemberLogin() 0 55 15
B procMemberLogout() 0 23 4
B procMemberScrapDocument() 0 31 6
A procMemberDeleteScrap() 0 14 3
A procMemberSaveDocument() 0 4 1
A procMemberDeleteSavedDocument() 0 12 3
C procMemberCheckValue() 0 38 13
F procMemberInsert() 28 170 37
C procMemberModifyInfoBefore() 0 49 7
F procMemberModifyInfo() 23 115 21
B procMemberModifyPassword() 0 34 6
B procMemberLeave() 0 30 6
C procMemberInsertProfileImage() 23 23 8
D insertProfileImage() 0 41 10
C procMemberInsertImageName() 23 23 8
C insertImageName() 23 23 7
B procMemberDeleteProfileImage() 18 18 6
B procMemberDeleteImageName() 18 18 6
C procMemberInsertImageMark() 23 23 8
C insertImageMark() 23 23 7
B procMemberDeleteImageMark() 18 18 6
D procMemberFindAccount() 23 94 19
C procMemberFindAccountByQuestion() 0 48 14
C procMemberAuthAccount() 9 66 9
D procMemberResendAuthMail() 18 86 18
C procMemberResetAuthMail() 0 69 7
C _sendAuthMail() 18 51 11
C procMemberSiteSignUp() 1 13 4
C procMemberSiteLeave() 1 14 5
F setMemberConfig() 0 27 12
A putSignature() 0 15 2
A delSignature() 0 5 1
A addMemberToGroup() 0 15 2
C replaceMemberGroup() 0 32 7
C doAutologin() 10 75 11
F doLogin() 0 156 36
B setSessionInfo() 0 50 6
A addMemberMenu() 0 8 1
A addMemberPopupMenu() 14 14 2
F insertMember() 28 185 36
F updateMember() 45 182 49
B updateMemberPassword() 5 32 5
C deleteMember() 9 75 12
B destroySessionInfo() 0 26 6
B _updatePointByGroup() 0 29 6
C procMemberModifyEmailAddress() 0 70 9
C procMemberAuthEmailAddress() 5 33 7
B triggerGetDocumentMenu() 22 22 5
B triggerGetCommentMenu() 22 22 5
B procMemberSpammerManage() 0 58 8
B _spammerMember() 0 32 2
C _spammerDocuments() 0 34 8
B _clearMemberCache() 0 25 4

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like memberController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use memberController, and based on these observations, apply Extract Interface, too.

1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
/**
4
 * @class  memberController
5
 * @author NAVER ([email protected])
6
 * Controller class of member module
7
 */
8
class memberController extends member
9
{
10
	/**
11
	 * Info of selected member
12
	 *
13
	 * @var object
14
	 */
15
	var $memberInfo;
16
17
	/**
18
	 * Initialization
19
	 *
20
	 * @return void
21
	 */
22
	function init()
23
	{
24
	}
25
26
	/**
27
	 * Log-in by checking user_id and password
28
	 *
29
	 * @param string $user_id
30
	 * @param string $password
31
	 * @param string $keep_signed
32
	 *
33
	 * @return void|Object (void : success, Object : fail)
34
	 */
35
	function procMemberLogin($user_id = null, $password = null, $keep_signed = null)
36
	{
37
		if(!$user_id && !$password && Context::getRequestMethod() == 'GET')
0 ignored issues
show
Bug Best Practice introduced by
The expression $user_id of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
Bug Best Practice introduced by
The expression $password of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
38
		{
39
			$this->setRedirectUrl(getNotEncodedUrl(''));
40
			return new Object(-1, 'null_user_id');
41
		}
42
43
		// Variables
44
		if(!$user_id) $user_id = Context::get('user_id');
0 ignored issues
show
Bug Best Practice introduced by
The expression $user_id of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
45
		$user_id = trim($user_id);
46
47
		if(!$password) $password = Context::get('password');
0 ignored issues
show
Bug Best Practice introduced by
The expression $password of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
48
		$password = trim($password);
49
50
		if(!$keep_signed) $keep_signed = Context::get('keep_signed');
0 ignored issues
show
Bug Best Practice introduced by
The expression $keep_signed of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
51
		// Return an error when id and password doesn't exist
52
		if(!$user_id) return new Object(-1,'null_user_id');
53
		if(!$password) return new Object(-1,'null_password');
54
55
		$output = $this->doLogin($user_id, $password, $keep_signed=='Y'?true:false);
56
		if (!$output->toBool()) return $output;
57
58
		$oModuleModel = getModel('module');
59
		$config = $oModuleModel->getModuleConfig('member');
60
61
		// Check change_password_date
62
		$limit_date = $config->change_password_date;
63
64
		// Check if change_password_date is set
65
		if($limit_date > 0)
66
		{
67
			$oMemberModel = getModel('member');
0 ignored issues
show
Unused Code introduced by
$oMemberModel is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
68
			if($this->memberInfo->change_password_date < date ('YmdHis', strtotime ('-' . $limit_date . ' day')))
69
			{
70
				$msg = sprintf(Context::getLang('msg_change_password_date'), $limit_date);
71
				return $this->setRedirectUrl(getNotEncodedUrl('','vid',Context::get('vid'),'mid',Context::get('mid'),'act','dispMemberModifyPassword'), new Object(-1, $msg));
72
			}
73
		}
74
75
		// Delete all previous authmail if login is successful
76
		$args = new stdClass();
77
		$args->member_srl = $this->memberInfo->member_srl;
78
		executeQuery('member.deleteAuthMail', $args);
79
80
		if(!$config->after_login_url)
81
		{
82
			$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
83
		}
84
		else
85
		{
86
			$returnUrl = $config->after_login_url;
87
		}
88
		return $this->setRedirectUrl($returnUrl, $output);
89
	}
90
91
	/**
92
	 * Log-out
93
	 *
94
	 * @return Object
95
	 */
96
	function procMemberLogout()
97
	{
98
		// Call a trigger before log-out (before)
99
		$logged_info = Context::get('logged_info');
100
		$trigger_output = ModuleHandler::triggerCall('member.doLogout', 'before', $logged_info);
0 ignored issues
show
Documentation introduced by
$logged_info is of type string, but the function expects a object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
101
		if(!$trigger_output->toBool()) return $trigger_output;
102
		// Destroy session information
103
		$this->destroySessionInfo();
104
		// Call a trigger after log-out (after)
105
		$trigger_output = ModuleHandler::triggerCall('member.doLogout', 'after', $logged_info);
106
		if(!$trigger_output->toBool()) return $trigger_output;
107
108
		$output = new Object();
109
110
		$oModuleModel = getModel('module');
111
		$config = $oModuleModel->getModuleConfig('member');
112
		if($config->after_logout_url)
113
			$output->redirect_url = $config->after_logout_url;
0 ignored issues
show
Bug introduced by
The property redirect_url does not seem to exist in Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
114
115
		$this->_clearMemberCache($logged_info->member_srl);
116
117
		return $output;
118
	}
119
120
	/**
121
	 * Scrap document
122
	 *
123
	 * @return void|Object (void : success, Object : fail)
124
	 */
125
	function procMemberScrapDocument()
126
	{
127
		// Check login information
128
		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
129
		$logged_info = Context::get('logged_info');
130
131
		$document_srl = (int)Context::get('document_srl');
132
		if(!$document_srl) $document_srl = (int)Context::get('target_srl');
133
		if(!$document_srl) return new Object(-1,'msg_invalid_request');
134
		// Get document
135
		$oDocumentModel = getModel('document');
136
		$oDocument = $oDocumentModel->getDocument($document_srl);
137
		// Variables
138
		$args = new stdClass();
139
		$args->document_srl = $document_srl;
140
		$args->member_srl = $logged_info->member_srl;
141
		$args->user_id = $oDocument->get('user_id');
142
		$args->user_name = $oDocument->get('user_name');
143
		$args->nick_name = $oDocument->get('nick_name');
144
		$args->target_member_srl = $oDocument->get('member_srl');
145
		$args->title = $oDocument->get('title');
146
		// Check if already scrapped
147
		$output = executeQuery('member.getScrapDocument', $args);
148
		if($output->data->count) return new Object(-1, 'msg_alreay_scrapped');
149
		// Insert
150
		$output = executeQuery('member.addScrapDocument', $args);
151
		if(!$output->toBool()) return $output;
152
153
		$this->setError(-1);
154
		$this->setMessage('success_registed');
155
	}
156
157
	/**
158
	 * Delete a scrap
159
	 *
160
	 * @return void|Object (void : success, Object : fail)
161
	 */
162
	function procMemberDeleteScrap()
163
	{
164
		// Check login information
165
		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
166
		$logged_info = Context::get('logged_info');
167
168
		$document_srl = (int)Context::get('document_srl');
169
		if(!$document_srl) return new Object(-1,'msg_invalid_request');
170
		// Variables
171
		$args = new stdClass;
172
		$args->member_srl = $logged_info->member_srl;
173
		$args->document_srl = $document_srl;
174
		return executeQuery('member.deleteScrapDocument', $args);
175
	}
176
177
	/**
178
	 * Save posts
179
	 * @deprecated - instead Document Controller - procDocumentTempSave method use
180
	 * @return Object
181
	 */
182
	function procMemberSaveDocument()
183
	{
184
		return new Object(0, 'Deprecated method');
185
	}
186
187
	/**
188
	 * Delete the post
189
	 *
190
	 * @return void|Object (void : success, Object : fail)
191
	 */
192
	function procMemberDeleteSavedDocument()
193
	{
194
		// Check login information
195
		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
196
		$logged_info = Context::get('logged_info');
0 ignored issues
show
Unused Code introduced by
$logged_info is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
197
198
		$document_srl = (int)Context::get('document_srl');
199
		if(!$document_srl) return new Object(-1,'msg_invalid_request');
200
		// Variables
201
		$oDocumentController = getController('document');
202
		$oDocumentController->deleteDocument($document_srl, true);
203
	}
204
205
	/**
206
	 * Check values when member joining
207
	 *
208
	 * @return void|Object (void : success, Object : fail)
209
	 */
210
	function procMemberCheckValue()
211
	{
212
		$name = Context::get('name');
213
		$value = Context::get('value');
214
		if(!$value) return;
215
216
		$oMemberModel = getModel('member');
217
		// Check if logged-in
218
		$logged_info = Context::get('logged_info');
219
220
221
		switch($name)
222
		{
223
			case 'user_id' :
224
				// Check denied ID
225
				if($oMemberModel->isDeniedID($value)) return new Object(0,'denied_user_id');
226
				// Check if duplicated
227
				$member_srl = $oMemberModel->getMemberSrlByUserID($value);
228
				if($member_srl && $logged_info->member_srl != $member_srl ) return new Object(0,'msg_exists_user_id');
229
				break;
230
			case 'nick_name' :
231
				// Check denied ID
232
				if($oMemberModel->isDeniedNickName($value))
233
				{
234
					return new Object(0,'denied_nick_name');
235
				}
236
				// Check if duplicated
237
				$member_srl = $oMemberModel->getMemberSrlByNickName($value);
238
				if($member_srl && $logged_info->member_srl != $member_srl ) return new Object(0,'msg_exists_nick_name');
239
240
				break;
241
			case 'email_address' :
242
				// Check if duplicated
243
				$member_srl = $oMemberModel->getMemberSrlByEmailAddress($value);
244
				if($member_srl && $logged_info->member_srl != $member_srl ) return new Object(0,'msg_exists_email_address');
245
				break;
246
		}
247
	}
248
249
	/**
250
	 * Join Membership
251
	 *
252
	 * @return void|Object (void : success, Object : fail)
253
	 */
254
	function procMemberInsert()
255
	{
256
		if (Context::getRequestMethod () == "GET") return new Object (-1, "msg_invalid_request");
257
		$oMemberModel = &getModel ('member');
258
		$config = $oMemberModel->getMemberConfig();
259
260
		// call a trigger (before)
261
		$trigger_output = ModuleHandler::triggerCall ('member.procMemberInsert', 'before', $config);
262
		if(!$trigger_output->toBool ()) return $trigger_output;
263
		// Check if an administrator allows a membership
264
		if($config->enable_join != 'Y') return $this->stop ('msg_signup_disabled');
265
		// Check if the user accept the license terms (only if terms exist)
266
		if($config->agreement && Context::get('accept_agreement')!='Y') return $this->stop('msg_accept_agreement');
267
268
		// Extract the necessary information in advance
269
		$getVars = array();
270 View Code Duplication
		if($config->signupForm)
271
		{
272
			foreach($config->signupForm as $formInfo)
273
			{
274
				if($formInfo->isDefaultForm && ($formInfo->isUse || $formInfo->required || $formInfo->mustRequired))
275
				{
276
					$getVars[] = $formInfo->name;
277
				}
278
			}
279
		}
280
281
		$args = new stdClass;
282 View Code Duplication
		foreach($getVars as $val)
283
		{
284
			$args->{$val} = Context::get($val);
285
			if($val == 'birthday') $args->birthday_ui = Context::get('birthday_ui');
286
		}
287
		$args->birthday = intval(strtr($args->birthday, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
288 View Code Duplication
		if(!$args->birthday && $args->birthday_ui) $args->birthday = intval(strtr($args->birthday_ui, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
289
290
		$args->find_account_answer = Context::get('find_account_answer');
291
		$args->allow_mailing = Context::get('allow_mailing');
292
		$args->allow_message = Context::get('allow_message');
293
294
		if($args->password1) $args->password = $args->password1;
295
296
		// check password strength
297 View Code Duplication
		if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
298
		{
299
			$message = Context::getLang('about_password_strength');
300
			return new Object(-1, $message[$config->password_strength]);
301
		}
302
303
		// Remove some unnecessary variables from all the vars
304
		$all_args = Context::getRequestVars();
305
		unset($all_args->module);
306
		unset($all_args->act);
307
		unset($all_args->is_admin);
308
		unset($all_args->member_srl);
309
		unset($all_args->description);
310
		unset($all_args->group_srl_list);
311
		unset($all_args->body);
312
		unset($all_args->accept_agreement);
313
		unset($all_args->signature);
314
		unset($all_args->password);
315
		unset($all_args->password2);
316
		unset($all_args->mid);
317
		unset($all_args->error_return_url);
318
		unset($all_args->ruleset);
319
		unset($all_args->captchaType);
320
		unset($all_args->secret_text);
321
322
		// Set the user state as "denied" when using mail authentication
323
		if($config->enable_confirm == 'Y') $args->denied = 'Y';
324
		// Add extra vars after excluding necessary information from all the requested arguments
325
		$extra_vars = delObjectVars($all_args, $args);
326
		$args->extra_vars = serialize($extra_vars);
327
328
		// remove whitespace
329
		$checkInfos = array('user_id', 'user_name', 'nick_name', 'email_address');
330 View Code Duplication
		foreach($checkInfos as $val)
331
		{
332
			if(isset($args->{$val}))
333
			{
334
				$args->{$val} = preg_replace('/[\pZ\pC]+/u', '', $args->{$val});
335
			}
336
		}
337
		$output = $this->insertMember($args);
338
		if(!$output->toBool()) return $output;
339
340
		// insert ProfileImage, ImageName, ImageMark
341
		$profile_image = $_FILES['profile_image'];
342
		if(is_uploaded_file($profile_image['tmp_name']))
343
		{
344
			$this->insertProfileImage($args->member_srl, $profile_image['tmp_name']);
345
		}
346
347
		$image_mark = $_FILES['image_mark'];
348
		if(is_uploaded_file($image_mark['tmp_name']))
349
		{
350
			$this->insertImageMark($args->member_srl, $image_mark['tmp_name']);
351
		}
352
353
		$image_name = $_FILES['image_name'];
354
		if(is_uploaded_file($image_name['tmp_name']))
355
		{
356
			$this->insertImageName($args->member_srl, $image_name['tmp_name']);
357
		}
358
359
		// If a virtual site, join the site
360
		$site_module_info = Context::get('site_module_info');
361
		if($site_module_info->site_srl > 0)
362
		{
363
			$columnList = array('site_srl', 'group_srl');
364
			$default_group = $oMemberModel->getDefaultGroup($site_module_info->site_srl, $columnList);
365
			if($default_group->group_srl)
366
			{
367
				$this->addMemberToGroup($args->member_srl, $default_group->group_srl, $site_module_info->site_srl);
368
			}
369
370
		}
371
		// Log-in
372
		if($config->enable_confirm != 'Y')
373
		{
374
			if($config->identifier == 'email_address')
375
			{
376
				$output = $this->doLogin($args->email_address);
377
			}
378
			else
379
			{
380
				$output = $this->doLogin($args->user_id);
381
			}
382
			if(!$output->toBool()) {
383
				if($output->error == -9)
384
					$output->error = -11;
385
				return $this->setRedirectUrl(getUrl('', 'act', 'dispMemberLoginForm'), $output);
386
			}
387
		}
388
389
		// Results
390
		$this->add('member_srl', $args->member_srl);
391
		if($config->redirect_url) $this->add('redirect_url', $config->redirect_url);
392
		if($config->enable_confirm == 'Y')
393
		{
394
			$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $args->email_address);
395
			$this->setMessage($msg);
396
			return $this->setRedirectUrl(getUrl('', 'act', 'dispMemberLoginForm'), new Object(-12, $msg));
397
		}
398
		else $this->setMessage('success_registed');
399
		// Call a trigger (after)
400
		$trigger_output = ModuleHandler::triggerCall('member.procMemberInsert', 'after', $config);
401
		if(!$trigger_output->toBool()) return $trigger_output;
402
403
		if($config->redirect_url)
404
		{
405
			$returnUrl = $config->redirect_url;
406
		}
407
		else
408
		{
409
			if(Context::get('success_return_url'))
410
			{
411
				$returnUrl = Context::get('success_return_url');
412
			}
413
			else if($_COOKIE['XE_REDIRECT_URL'])
414
			{
415
				$returnUrl = $_COOKIE['XE_REDIRECT_URL'];
416
				setcookie("XE_REDIRECT_URL", '', 1);
417
			}
418
		}
419
420
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
421
422
		$this->setRedirectUrl($returnUrl);
0 ignored issues
show
Bug introduced by
The variable $returnUrl does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
423
	}
424
425
	function procMemberModifyInfoBefore()
426
	{
427
		if($_SESSION['rechecked_password_step'] != 'INPUT_PASSWORD')
428
		{
429
			return $this->stop('msg_invalid_request');
430
		}
431
432
		if(!Context::get('is_logged'))
433
		{
434
			return $this->stop('msg_not_logged');
435
		}
436
437
		$password = Context::get('password');
438
439
		if(!$password)
440
		{
441
			return $this->stop('msg_invalid_request');
442
		}
443
444
		$oMemberModel = getModel('member');
445
446
		if(!$this->memberInfo->password)
447
		{
448
			// Get information of logged-in user
449
			$logged_info = Context::get('logged_info');
450
			$member_srl = $logged_info->member_srl;
451
			
452
			$columnList = array('member_srl', 'password');
453
			$memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
454
			$this->memberInfo->password = $memberInfo->password;
455
		}
456
		// Verify the current password
457
		if(!$oMemberModel->isValidPassword($this->memberInfo->password, $password))
458
		{
459
			return new Object(-1, 'invalid_password');
460
		}
461
462
		$_SESSION['rechecked_password_step'] = 'VALIDATE_PASSWORD';
463
464
		if(Context::get('success_return_url'))
465
		{
466
			$redirectUrl = Context::get('success_return_url');
467
		}
468
		else
469
		{
470
			$redirectUrl = getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
471
		}
472
		$this->setRedirectUrl($redirectUrl);
473
	}
474
475
	/**
476
	 * Edit member profile
477
	 *
478
	 * @return void|Object (void : success, Object : fail)
479
	 */
480
	function procMemberModifyInfo()
481
	{
482
		if(!Context::get('is_logged'))
483
		{
484
			return $this->stop('msg_not_logged');
485
		}
486
487
		if($_SESSION['rechecked_password_step'] != 'INPUT_DATA')
488
		{
489
			return $this->stop('msg_invalid_request');
490
		}
491
		unset($_SESSION['rechecked_password_step']);
492
493
		// Extract the necessary information in advance
494
		$oMemberModel = &getModel ('member');
495
		$config = $oMemberModel->getMemberConfig ();
496
		$getVars = array('find_account_answer','allow_mailing','allow_message');
497 View Code Duplication
		if($config->signupForm)
498
		{
499
			foreach($config->signupForm as $formInfo)
500
			{
501
				if($formInfo->isDefaultForm && ($formInfo->isUse || $formInfo->required || $formInfo->mustRequired))
502
				{
503
					$getVars[] = $formInfo->name;
504
				}
505
			}
506
		}
507
508
		$args = new stdClass;
509 View Code Duplication
		foreach($getVars as $val)
510
		{
511
			$args->{$val} = Context::get($val);
512
			if($val == 'birthday') $args->birthday_ui = Context::get('birthday_ui');
513
		}
514
		// Login Information
515
		$logged_info = Context::get('logged_info');
516
		$args->member_srl = $logged_info->member_srl;
517
		$args->birthday = intval(strtr($args->birthday, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
518 View Code Duplication
		if(!$args->birthday && $args->birthday_ui) $args->birthday = intval(strtr($args->birthday_ui, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
519
		// Remove some unnecessary variables from all the vars
520
		$all_args = Context::getRequestVars();
521
		unset($all_args->module);
522
		unset($all_args->act);
523
		unset($all_args->member_srl);
524
		unset($all_args->is_admin);
525
		unset($all_args->description);
526
		unset($all_args->group_srl_list);
527
		unset($all_args->body);
528
		unset($all_args->accept_agreement);
529
		unset($all_args->signature);
530
		unset($all_args->_filter);
531
		unset($all_args->mid);
532
		unset($all_args->error_return_url);
533
		unset($all_args->ruleset);
534
		unset($all_args->password);
535
536
		// Add extra vars after excluding necessary information from all the requested arguments
537
		$extra_vars = delObjectVars($all_args, $args);
538
		$args->extra_vars = serialize($extra_vars);
539
540
		// remove whitespace
541
		$checkInfos = array('user_id', 'user_name', 'nick_name', 'email_address');
542 View Code Duplication
		foreach($checkInfos as $val)
543
		{
544
			if(isset($args->{$val}))
545
			{
546
				$args->{$val} = preg_replace('/[\pZ\pC]+/u', '', $args->{$val});
547
			}
548
		}
549
550
		// Execute insert or update depending on the value of member_srl
551
		$output = $this->updateMember($args);
552
		if(!$output->toBool()) return $output;
553
554
		$profile_image = $_FILES['profile_image'];
555
		if(is_uploaded_file($profile_image['tmp_name']))
556
		{
557
			$this->insertProfileImage($args->member_srl, $profile_image['tmp_name']);
558
		}
559
560
		$image_mark = $_FILES['image_mark'];
561
		if(is_uploaded_file($image_mark['tmp_name']))
562
		{
563
			$this->insertImageMark($args->member_srl, $image_mark['tmp_name']);
564
		}
565
566
		$image_name = $_FILES['image_name'];
567
		if(is_uploaded_file($image_name['tmp_name']))
568
		{
569
			$this->insertImageName($args->member_srl, $image_name['tmp_name']);
570
		}
571
572
		// Save Signature
573
		$signature = Context::get('signature');
574
		$this->putSignature($args->member_srl, $signature);
575
576
		// Get user_id information
577
		$this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
578
579
580
		// Call a trigger after successfully log-in (after)
581
		$trigger_output = ModuleHandler::triggerCall('member.procMemberModifyInfo', 'after', $this->memberInfo);
582
		if(!$trigger_output->toBool()) return $trigger_output;
583
584
		$this->setSessionInfo();
585
		// Return result
586
		$this->add('member_srl', $args->member_srl);
587
		$this->setMessage('success_updated');
588
589
		$site_module_info = Context::get('site_module_info');
590
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
591
592
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberInfo');
593
		$this->setRedirectUrl($returnUrl);
594
	}
595
596
	/**
597
	 * Change the user password
598
	 *
599
	 * @return void|Object (void : success, Object : fail)
600
	 */
601
	function procMemberModifyPassword()
602
	{
603
		if(!Context::get('is_logged')) return $this->stop('msg_not_logged');
604
		// Extract the necessary information in advance
605
		$current_password = trim(Context::get('current_password'));
606
		$password = trim(Context::get('password1'));
607
		// Get information of logged-in user
608
		$logged_info = Context::get('logged_info');
609
		$member_srl = $logged_info->member_srl;
610
		// Create a member model object
611
		$oMemberModel = getModel('member');
612
		// Get information of member_srl
613
		$columnList = array('member_srl', 'password');
614
615
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
616
		// Verify the cuttent password
617
		if(!$oMemberModel->isValidPassword($member_info->password, $current_password, $member_srl)) return new Object(-1, 'invalid_password');
618
619
		// Check if a new password is as same as the previous password
620
		if($current_password == $password) return new Object(-1, 'invalid_new_password');
621
622
		// Execute insert or update depending on the value of member_srl
623
		$args = new stdClass;
624
		$args->member_srl = $member_srl;
625
		$args->password = $password;
626
		$output = $this->updateMemberPassword($args);
627
		if(!$output->toBool()) return $output;
628
629
		$this->add('member_srl', $args->member_srl);
630
		$this->setMessage('success_updated');
631
632
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberInfo');
633
		$this->setRedirectUrl($returnUrl);
634
	}
635
636
	/**
637
	 * Membership withdrawal
638
	 *
639
	 * @return void|Object (void : success, Object : fail)
640
	 */
641
	function procMemberLeave()
642
	{
643
		if(!Context::get('is_logged')) return $this->stop('msg_not_logged');
644
		// Extract the necessary information in advance
645
		$password = trim(Context::get('password'));
646
		// Get information of logged-in user
647
		$logged_info = Context::get('logged_info');
648
		$member_srl = $logged_info->member_srl;
649
		// Create a member model object
650
		$oMemberModel = getModel('member');
651
		// Get information of member_srl
652
		if(!$this->memberInfo->password)
653
		{
654
			$columnList = array('member_srl', 'password');
655
			$memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
656
			$this->memberInfo->password = $memberInfo->password;
657
		}
658
		// Verify the cuttent password
659
		if(!$oMemberModel->isValidPassword($this->memberInfo->password, $password)) return new Object(-1, 'invalid_password');
660
661
		$output = $this->deleteMember($member_srl);
662
		if(!$output->toBool()) return $output;
663
		// Destroy all session information
664
		$this->destroySessionInfo();
665
		// Return success message
666
		$this->setMessage('success_leaved');
667
668
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
669
		$this->setRedirectUrl($returnUrl);
670
	}
671
672
	/**
673
	 * Add a profile image
674
	 *
675
	 * @return void|Object (void : success, Object : fail)
676
	 */
677 View Code Duplication
	function procMemberInsertProfileImage()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
678
	{
679
		// Check if the file is successfully uploaded
680
		$file = $_FILES['profile_image'];
681
		if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_profile_image');
682
		// Ignore if member_srl is invalid or doesn't exist.
683
		$member_srl = Context::get('member_srl');
684
		if(!$member_srl) return $this->stop('msg_not_uploaded_profile_image');
685
686
		$logged_info = Context::get('logged_info');
687
		if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_profile_image');
688
		// Return if member module is set not to use an image name or the user is not an administrator ;
689
		$oModuleModel = getModel('module');
690
		$config = $oModuleModel->getModuleConfig('member');
691
		if($logged_info->is_admin != 'Y' && $config->profile_image != 'Y') return $this->stop('msg_not_uploaded_profile_image');
692
693
		$this->insertProfileImage($member_srl, $file['tmp_name']);
694
		// Page refresh
695
		//$this->setRefreshPage();
696
697
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
698
		$this->setRedirectUrl($returnUrl);
699
	}
700
701
	/**
702
	 * Insert a profile image
703
	 *
704
	 * @param int $member_srl
705
	 * @param object $target_file
706
	 *
707
	 * @return void
708
	 */
709
	function insertProfileImage($member_srl, $target_file)
710
	{
711
712
		// Check uploaded file
713
		if(!checkUploadedFile($target_file)) return;
0 ignored issues
show
Documentation introduced by
$target_file is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
714
715
		$oMemberModel = getModel('member');
716
		$config = $oMemberModel->getMemberConfig();
717
718
		// Get an image size
719
		$max_width = $config->profile_image_max_width;
720
		if(!$max_width) $max_width = "90";
721
		$max_height = $config->profile_image_max_height;
722
		if(!$max_height) $max_height = "90";
723
		// Get a target path to save
724
		$target_path = sprintf('files/member_extra_info/profile_image/%s', getNumberingPath($member_srl));
725
		FileHandler::makeDir($target_path);
726
727
		// Get file information
728
		list($width, $height, $type, $attrs) = @getimagesize($target_file);
0 ignored issues
show
Unused Code introduced by
The assignment to $attrs is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
729
		if(IMAGETYPE_PNG == $type) $ext = 'png';
730
		elseif(IMAGETYPE_JPEG == $type) $ext = 'jpg';
731
		elseif(IMAGETYPE_GIF == $type) $ext = 'gif';
732
		else
733
		{
734
			return;
735
		}
736
737
		FileHandler::removeFilesInDir($target_path);
738
739
		$target_filename = sprintf('%s%d.%s', $target_path, $member_srl, $ext);
740
		// Convert if the image size is larger than a given size or if the format is not a gif
741
		if(($width > $max_width || $height > $max_height ) && $type != 1)
742
		{
743
			FileHandler::createImageFile($target_file, $target_filename, $max_width, $max_height, $ext);
0 ignored issues
show
Documentation introduced by
$target_file is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
744
		}
745
		else
746
		{
747
			@copy($target_file, $target_filename);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
748
		}
749
	}
750
751
	/**
752
	 * Add an image name
753
	 *
754
	 * @return void|Object (void : success, Object : fail)
755
	 */
756 View Code Duplication
	function procMemberInsertImageName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
757
	{
758
		// Check if the file is successfully uploaded
759
		$file = $_FILES['image_name'];
760
		if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_image_name');
761
		// Ignore if member_srl is invalid or doesn't exist.
762
		$member_srl = Context::get('member_srl');
763
		if(!$member_srl) return $this->stop('msg_not_uploaded_image_name');
764
765
		$logged_info = Context::get('logged_info');
766
		if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_image_name');
767
		// Return if member module is set not to use an image name or the user is not an administrator ;
768
		$oModuleModel = getModel('module');
769
		$config = $oModuleModel->getModuleConfig('member');
770
		if($logged_info->is_admin != 'Y' && $config->image_name != 'Y') return $this->stop('msg_not_uploaded_image_name');
771
772
		$this->insertImageName($member_srl, $file['tmp_name']);
773
		// Page refresh
774
		//$this->setRefreshPage();
775
776
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
777
		$this->setRedirectUrl($returnUrl);
778
	}
779
780
	/**
781
	 * Insert a image name
782
	 *
783
	 * @param int $member_srl
784
	 * @param object $target_file
785
	 *
786
	 * @return void
787
	 */
788 View Code Duplication
	function insertImageName($member_srl, $target_file)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
789
	{
790
		// Check uploaded file
791
		if(!checkUploadedFile($target_file)) return;
0 ignored issues
show
Documentation introduced by
$target_file is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
792
793
		$oModuleModel = getModel('module');
794
		$config = $oModuleModel->getModuleConfig('member');
795
		// Get an image size
796
		$max_width = $config->image_name_max_width;
797
		if(!$max_width) $max_width = "90";
798
		$max_height = $config->image_name_max_height;
799
		if(!$max_height) $max_height = "20";
800
		// Get a target path to save
801
		$target_path = sprintf('files/member_extra_info/image_name/%s/', getNumberingPath($member_srl));
802
		FileHandler::makeDir($target_path);
803
804
		$target_filename = sprintf('%s%d.gif', $target_path, $member_srl);
805
		// Get file information
806
		list($width, $height, $type, $attrs) = @getimagesize($target_file);
0 ignored issues
show
Unused Code introduced by
The assignment to $attrs is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
807
		// Convert if the image size is larger than a given size or if the format is not a gif
808
		if($width > $max_width || $height > $max_height || $type!=1) FileHandler::createImageFile($target_file, $target_filename, $max_width, $max_height, 'gif');
0 ignored issues
show
Documentation introduced by
$target_file is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
809
		else @copy($target_file, $target_filename);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
810
	}
811
812
	/**
813
	 * Delete profile image
814
	 *
815
	 * @return Object
816
	 */
817 View Code Duplication
	function procMemberDeleteProfileImage($_memberSrl = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
818
	{
819
		$member_srl = ($_memberSrl) ? $_memberSrl : Context::get('member_srl');
820
		if(!$member_srl)
821
		{
822
			return new Object(0,'success');
823
		}
824
825
		$logged_info = Context::get('logged_info');
826
827
		if($logged_info && ($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl))
828
		{
829
			$oMemberModel = getModel('member');
830
			$profile_image = $oMemberModel->getProfileImage($member_srl);
831
			FileHandler::removeFile($profile_image->file);
832
		}
833
		return new Object(0,'success');
834
	}
835
836
	/**
837
	 * Delete Image name
838
	 *
839
	 * @return void
840
	 */
841 View Code Duplication
	function procMemberDeleteImageName($_memberSrl = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
842
	{
843
		$member_srl = ($_memberSrl) ? $_memberSrl : Context::get('member_srl');
844
		if(!$member_srl)
845
		{
846
			return new Object(0,'success');
847
		}
848
849
		$logged_info = Context::get('logged_info');
850
851
		if($logged_info && ($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl))
852
		{
853
			$oMemberModel = getModel('member');
854
			$image_name = $oMemberModel->getImageName($member_srl);
855
			FileHandler::removeFile($image_name->file);
856
		}
857
		return new Object(0,'success');
858
	}
859
860
	/**
861
	 * Add an image to mark
862
	 *
863
	 * @return void|Object (void : success, Object : fail)
864
	 */
865 View Code Duplication
	function procMemberInsertImageMark()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
866
	{
867
		// Check if the file is successfully uploaded
868
		$file = $_FILES['image_mark'];
869
		if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_image_mark');
870
		// Ignore if member_srl is invalid or doesn't exist.
871
		$member_srl = Context::get('member_srl');
872
		if(!$member_srl) return $this->stop('msg_not_uploaded_image_mark');
873
874
		$logged_info = Context::get('logged_info');
875
		if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_image_mark');
876
		// Membership in the images mark the module using the ban was set by an administrator or return;
877
		$oModuleModel = getModel('module');
878
		$config = $oModuleModel->getModuleConfig('member');
879
		if($logged_info->is_admin != 'Y' && $config->image_mark != 'Y') return $this->stop('msg_not_uploaded_image_mark');
880
881
		$this->insertImageMark($member_srl, $file['tmp_name']);
882
		// Page refresh
883
		//$this->setRefreshPage();
884
885
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
886
		$this->setRedirectUrl($returnUrl);
887
	}
888
889
	/**
890
	 * Insert a image mark
891
	 *
892
	 * @param int $member_srl
893
	 * @param object $target_file
894
	 *
895
	 * @return void
896
	 */
897 View Code Duplication
	function insertImageMark($member_srl, $target_file)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
898
	{
899
		// Check uploaded file
900
		if(!checkUploadedFile($target_file)) return;
0 ignored issues
show
Documentation introduced by
$target_file is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
901
902
		$oModuleModel = getModel('module');
903
		$config = $oModuleModel->getModuleConfig('member');
904
		// Get an image size
905
		$max_width = $config->image_mark_max_width;
906
		if(!$max_width) $max_width = "20";
907
		$max_height = $config->image_mark_max_height;
908
		if(!$max_height) $max_height = "20";
909
910
		$target_path = sprintf('files/member_extra_info/image_mark/%s/', getNumberingPath($member_srl));
911
		FileHandler::makeDir($target_path);
912
913
		$target_filename = sprintf('%s%d.gif', $target_path, $member_srl);
914
		// Get file information
915
		list($width, $height, $type, $attrs) = @getimagesize($target_file);
0 ignored issues
show
Unused Code introduced by
The assignment to $attrs is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
916
917
		if($width > $max_width || $height > $max_height || $type!=1) FileHandler::createImageFile($target_file, $target_filename, $max_width, $max_height, 'gif');
0 ignored issues
show
Documentation introduced by
$target_file is of type object, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
918
		else @copy($target_file, $target_filename);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
919
	}
920
921
	/**
922
	 * Delete Image Mark
923
	 *
924
	 * @return Object
925
	 */
926 View Code Duplication
	function procMemberDeleteImageMark($_memberSrl = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
927
	{
928
		$member_srl = ($_memberSrl) ? $_memberSrl : Context::get('member_srl');
929
		if(!$member_srl)
930
		{
931
			return new Object(0,'success');
932
		}
933
934
		$logged_info = Context::get('logged_info');
935
936
		if($logged_info && ($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl))
937
		{
938
			$oMemberModel = getModel('member');
939
			$image_mark = $oMemberModel->getImageMark($member_srl);
940
			FileHandler::removeFile($image_mark->file);
941
		}
942
		return new Object(0,'success');
943
	}
944
945
	/**
946
	 * Find ID/Password
947
	 *
948
	 * @return Object
949
	 */
950
	function procMemberFindAccount()
951
	{
952
		$email_address = Context::get('email_address');
953
		if(!$email_address) return new Object(-1, 'msg_invalid_request');
954
955
		$oMemberModel = getModel('member');
956
		$oModuleModel = getModel('module');
957
958
		// Check if a member having the same email address exists
959
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
960
		if(!$member_srl) return new Object(-1, 'msg_email_not_exists');
961
962
		// Get information of the member
963
		$columnList = array('denied', 'member_srl', 'user_id', 'user_name', 'email_address', 'nick_name');
964
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
965
966
		// Check if possible to find member's ID and password
967
		if($member_info->denied == 'Y')
968
		{
969
			$chk_args = new stdClass;
970
			$chk_args->member_srl = $member_info->member_srl;
971
			$output = executeQuery('member.chkAuthMail', $chk_args);
972
			if($output->toBool() && $output->data->count != '0') return new Object(-1, 'msg_user_not_confirmed');
973
		}
974
975
		// Insert data into the authentication DB
976
		$oPassword = new Password();
977
		$args = new stdClass();
978
		$args->user_id = $member_info->user_id;
979
		$args->member_srl = $member_info->member_srl;
980
		$args->new_password = $oPassword->createTemporaryPassword(8);
981
		$args->auth_key = $oPassword->createSecureSalt(40);
982
		$args->is_register = 'N';
983
984
		$output = executeQuery('member.insertAuthMail', $args);
985
		if(!$output->toBool()) return $output;
986
		// Get content of the email to send a member
987
		Context::set('auth_args', $args);
0 ignored issues
show
Documentation introduced by
$args is of type object<stdClass>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
988
989
		$member_config = $oModuleModel->getModuleConfig('member');
990
		$memberInfo = array();
991
		global $lang;
992 View Code Duplication
		if(is_array($member_config->signupForm))
993
		{
994
			$exceptForm=array('password', 'find_account_question');
995
			foreach($member_config->signupForm as $form)
996
			{
997
				if(!in_array($form->name, $exceptForm) && $form->isDefaultForm && ($form->required || $form->mustRequired))
998
				{
999
					$memberInfo[$lang->{$form->name}] = $member_info->{$form->name};
1000
				}
1001
			}
1002
		}
1003
		else
1004
		{
1005
			$memberInfo[$lang->user_id] = $args->user_id;
1006
			$memberInfo[$lang->user_name] = $args->user_name;
1007
			$memberInfo[$lang->nick_name] = $args->nick_name;
1008
			$memberInfo[$lang->email_address] = $args->email_address;
1009
		}
1010
		Context::set('memberInfo', $memberInfo);
0 ignored issues
show
Documentation introduced by
$memberInfo is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1011
1012
		if(!$member_config->skin) $member_config->skin = "default";
1013
		if(!$member_config->colorset) $member_config->colorset = "white";
1014
1015
		Context::set('member_config', $member_config);
1016
1017
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1018
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1019
1020
		$find_url = getFullUrl ('', 'module', 'member', 'act', 'procMemberAuthAccount', 'member_srl', $member_info->member_srl, 'auth_key', $args->auth_key);
1021
		Context::set('find_url', $find_url);
1022
1023
		$oTemplate = &TemplateHandler::getInstance();
1024
		$content = $oTemplate->compile($tpl_path, 'find_member_account_mail');
1025
		// Get information of the Webmaster
1026
		$oModuleModel = getModel('module');
1027
		$member_config = $oModuleModel->getModuleConfig('member');
1028
		// Send a mail
1029
		$oMail = new Mail();
1030
		$oMail->setTitle( Context::getLang('msg_find_account_title') );
1031
		$oMail->setContent($content);
1032
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
1033
		$oMail->setReceiptor( $member_info->user_name, $member_info->email_address );
1034
		$oMail->send();
1035
		// Return message
1036
		$msg = sprintf(Context::getLang('msg_auth_mail_sent'), $member_info->email_address);
1037 View Code Duplication
		if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
1038
		{
1039
			$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberFindAccount');
1040
			$this->setRedirectUrl($returnUrl);
1041
		}
1042
		return new Object(0,$msg);
1043
	}
1044
1045
	/**
1046
	 * Generate a temp password by answering to the pre-determined question
1047
	 *
1048
	 * @return void|Object (void : success, Object : fail)
1049
	 */
1050
	function procMemberFindAccountByQuestion()
1051
	{
1052
		$oMemberModel = getModel('member');
1053
		$config = $oMemberModel->getMemberConfig();
1054
1055
		$email_address = Context::get('email_address');
1056
		$user_id = Context::get('user_id');
1057
		$find_account_question = trim(Context::get('find_account_question'));
1058
		$find_account_answer = trim(Context::get('find_account_answer'));
1059
1060
		if(($config->identifier == 'user_id' && !$user_id) || !$email_address || !$find_account_question || !$find_account_answer) return new Object(-1, 'msg_invalid_request');
1061
1062
		$oModuleModel = getModel('module');
0 ignored issues
show
Unused Code introduced by
$oModuleModel is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1063
		// Check if a member having the same email address exists
1064
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
1065
		if(!$member_srl) return new Object(-1, 'msg_email_not_exists');
1066
		// Get information of the member
1067
		$columnList = array('member_srl', 'find_account_question', 'find_account_answer');
1068
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
1069
1070
		// Display a message if no answer is entered
1071
		if(!$member_info->find_account_question || !$member_info->find_account_answer) return new Object(-1, 'msg_question_not_exists');
1072
1073
		if(trim($member_info->find_account_question) != $find_account_question || trim($member_info->find_account_answer) != $find_account_answer) return new Object(-1, 'msg_answer_not_matches');
1074
1075
		if($config->identifier == 'email_address')
1076
		{
1077
			$user_id = $email_address;
1078
		}
1079
1080
		// Update to a temporary password and set change_password_date to 1
1081
		$oPassword =  new Password();
1082
		$temp_password = $oPassword->createTemporaryPassword(8);
1083
1084
		$args = new stdClass();
1085
		$args->member_srl = $member_srl;
1086
		$args->password = $temp_password;
1087
		$args->change_password_date = '1';
1088
		$output = $this->updateMemberPassword($args);
1089
		if(!$output->toBool()) return $output;
1090
1091
		$_SESSION['xe_temp_password_' . $user_id] = $temp_password;
1092
1093
		$this->add('user_id',$user_id);
1094
1095
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
1096
		$this->setRedirectUrl($returnUrl.'&user_id='.$user_id);
1097
	}
1098
1099
	/**
1100
	 * Execute finding ID/Passoword
1101
	 * When clicking the link in the verification email, a method is called to change the old password and to authenticate it
1102
	 *
1103
	 * @return void|Object (void : success, Object : fail)
1104
	 */
1105
	function procMemberAuthAccount()
1106
	{
1107
		$oMemberModel = getModel('member');
1108
1109
		// Test user_id and authkey
1110
		$member_srl = Context::get('member_srl');
1111
		$auth_key = Context::get('auth_key');
1112
1113
		if(!$member_srl || !$auth_key)
1114
		{
1115
			return $this->stop('msg_invalid_request');
1116
		}
1117
1118
		// Test logs for finding password by user_id and authkey
1119
		$args = new stdClass;
1120
		$args->member_srl = $member_srl;
1121
		$args->auth_key = $auth_key;
1122
		$output = executeQuery('member.getAuthMail', $args);
1123
1124 View Code Duplication
		if(!$output->toBool() || $output->data->auth_key != $auth_key)
1125
		{
1126
			if(strlen($output->data->auth_key) !== strlen($auth_key))
1127
			{
1128
				executeQuery('member.deleteAuthMail', $args);
1129
			}
1130
1131
			return $this->stop('msg_invalid_auth_key');
1132
		}
1133
1134
		if(ztime($output->data->regdate) < $_SERVER['REQUEST_TIME'] + zgap() - 86400)
1135
		{
1136
			executeQuery('member.deleteAuthMail', $args);
1137
			return $this->stop('msg_invalid_auth_key');
1138
		}
1139
1140
		$args->password = $output->data->new_password;
1141
1142
		// If credentials are correct, change the password to a new one
1143
		if($output->data->is_register == 'Y')
1144
		{
1145
			$args->denied = 'N';
1146
		}
1147
		else
1148
		{
1149
			$args->password = $oMemberModel->hashPassword($args->password);
1150
		}
1151
1152
		// Back up the value of $Output->data->is_register
1153
		$is_register = $output->data->is_register;
1154
1155
		$output = executeQuery('member.updateMemberPassword', $args);
1156
		if(!$output->toBool())
1157
		{
1158
			return $this->stop($output->getMessage());
1159
		}
1160
1161
		// Remove all values having the member_srl from authentication table
1162
		executeQuery('member.deleteAuthMail',$args);
1163
1164
		$this->_clearMemberCache($args->member_srl);
1165
1166
		// Notify the result
1167
		Context::set('is_register', $is_register);
1168
		$this->setTemplatePath($this->module_path.'tpl');
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1169
		$this->setTemplateFile('msg_success_authed');
1170
	}
1171
1172
	/**
1173
	 * Request to re-send the authentication mail
1174
	 *
1175
	 * @return void|Object (void : success, Object : fail)
1176
	 */
1177
	function procMemberResendAuthMail()
1178
	{
1179
		// Get an email_address
1180
		$email_address = Context::get('email_address');
1181
		if(!$email_address) return new Object(-1, 'msg_invalid_request');
1182
		// Log test by using email_address
1183
		$oMemberModel = getModel('member');
1184
1185
		$args = new stdClass;
1186
		$args->email_address = $email_address;
1187
		$memberSrl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
1188
		if(!$memberSrl) return new Object(-1, 'msg_not_exists_member');
1189
1190
		$columnList = array('member_srl', 'user_id', 'user_name', 'nick_name', 'email_address');
1191
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($memberSrl, 0, $columnList);
1192
1193
		$oModuleModel = getModel('module');
1194
		$member_config = $oModuleModel->getModuleConfig('member');
1195
		if(!$member_config->skin) $member_config->skin = "default";
1196
		if(!$member_config->colorset) $member_config->colorset = "white";
1197
1198
		// Check if a authentication mail has been sent previously
1199
		$chk_args = new stdClass;
1200
		$chk_args->member_srl = $member_info->member_srl;
1201
		$output = executeQuery('member.chkAuthMail', $chk_args);
1202
		if($output->toBool() && $output->data->count == '0') return new Object(-1, 'msg_invalid_request');
1203
1204
		$auth_args = new stdClass;
1205
		$auth_args->member_srl = $member_info->member_srl;
1206
		$output = executeQueryArray('member.getAuthMailInfo', $auth_args);
1207
		if(!$output->data || !$output->data[0]->auth_key)  return new Object(-1, 'msg_invalid_request');
1208
		$auth_info = $output->data[0];
1209
1210
		// Update the regdate of authmail entry
1211
		$renewal_args = new stdClass;
1212
		$renewal_args->member_srl = $member_info->member_srl;
1213
		$renewal_args->auth_key = $auth_info->auth_key;
1214
		$output = executeQuery('member.updateAuthMail', $renewal_args);		
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1215
1216
		$memberInfo = array();
1217
		global $lang;
1218 View Code Duplication
		if(is_array($member_config->signupForm))
1219
		{
1220
			$exceptForm=array('password', 'find_account_question');
1221
			foreach($member_config->signupForm as $form)
1222
			{
1223
				if(!in_array($form->name, $exceptForm) && $form->isDefaultForm && ($form->required || $form->mustRequired))
1224
				{
1225
					$memberInfo[$lang->{$form->name}] = $member_info->{$form->name};
1226
				}
1227
			}
1228
		}
1229
		else
1230
		{
1231
			$memberInfo[$lang->user_id] = $member_info->user_id;
1232
			$memberInfo[$lang->user_name] = $member_info->user_name;
1233
			$memberInfo[$lang->nick_name] = $member_info->nick_name;
1234
			$memberInfo[$lang->email_address] = $member_info->email_address;
1235
		}
1236
1237
		// Get content of the email to send a member
1238
		Context::set('memberInfo', $memberInfo);
0 ignored issues
show
Documentation introduced by
$memberInfo is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1239
		Context::set('member_config', $member_config);
1240
1241
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1242
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1243
1244
		$auth_url = getFullUrl('','module','member','act','procMemberAuthAccount','member_srl',$member_info->member_srl, 'auth_key',$auth_info->auth_key);
1245
		Context::set('auth_url', $auth_url);
1246
1247
		$oTemplate = &TemplateHandler::getInstance();
1248
		$content = $oTemplate->compile($tpl_path, 'confirm_member_account_mail');
1249
		// Send a mail
1250
		$oMail = new Mail();
1251
		$oMail->setTitle( Context::getLang('msg_confirm_account_title') );
1252
		$oMail->setContent($content);
1253
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
1254
		$oMail->setReceiptor( $args->user_name, $args->email_address );
1255
		$oMail->send();
1256
1257
		$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $args->email_address);
1258
		$this->setMessage($msg);
1259
1260
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
1261
		$this->setRedirectUrl($returnUrl);
1262
	}
1263
1264
	function procMemberResetAuthMail()
1265
	{
1266
		$memberInfo = $_SESSION['auth_member_info'];
1267
		unset($_SESSION['auth_member_info']);
1268
1269
		if(!$memberInfo)
1270
		{
1271
			return $this->stop('msg_invalid_request');
1272
		}
1273
1274
		$newEmail = Context::get('email_address');
1275
1276
		if(!$newEmail)
1277
		{
1278
			return $this->stop('msg_invalid_request');
1279
		}
1280
1281
		$oMemberModel = getModel('member');
1282
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($newEmail);
1283
		if($member_srl)
1284
		{
1285
			return new Object(-1,'msg_exists_email_address');
1286
		}
1287
1288
		// remove all key by member_srl
1289
		$args = new stdClass;
1290
		$args->member_srl = $memberInfo->member_srl;
1291
		$output = executeQuery('member.deleteAuthMail', $args);
1292
1293
		if(!$output->toBool())
1294
		{
1295
			return $output;
1296
		}
1297
1298
		// update member info
1299
		$args->email_address = $newEmail;
1300
		list($args->email_id, $args->email_host) = explode('@', $newEmail);
1301
1302
		$output = executeQuery('member.updateMemberEmailAddress', $args);
1303
		if(!$output->toBool())
1304
		{
1305
			return $this->stop($output->getMessage());
1306
		}
1307
1308
		$this->_clearMemberCache($args->member_srl);
1309
1310
		// generate new auth key
1311
		$oPassword = new Password();
1312
		$auth_args = new stdClass();
1313
		$auth_args->user_id = $memberInfo->user_id;
1314
		$auth_args->member_srl = $memberInfo->member_srl;
1315
		$auth_args->new_password = $memberInfo->password;
1316
		$auth_args->auth_key = $oPassword->createSecureSalt(40);
1317
		$auth_args->is_register = 'Y';
1318
1319
		$output = executeQuery('member.insertAuthMail', $auth_args);
1320
		if(!$output->toBool()) return $output;
1321
1322
		$memberInfo->email_address = $newEmail;
1323
1324
		// resend auth mail.
1325
		$this->_sendAuthMail($auth_args, $memberInfo);
1326
1327
		$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $memberInfo->email_address);
1328
		$this->setMessage($msg);
1329
1330
		$returnUrl = getUrl('');
1331
		$this->setRedirectUrl($returnUrl);
1332
	}
1333
1334
	function _sendAuthMail($auth_args, $member_info)
1335
	{
1336
		$oMemberModel = getModel('member');
1337
		$member_config = $oMemberModel->getMemberConfig();
1338
		// Get content of the email to send a member
1339
		Context::set('auth_args', $auth_args);
1340
1341
		$memberInfo = array();
1342
1343
		global $lang;
1344 View Code Duplication
		if(is_array($member_config->signupForm))
1345
		{
1346
			$exceptForm=array('password', 'find_account_question');
1347
			foreach($member_config->signupForm as $form)
1348
			{
1349
				if(!in_array($form->name, $exceptForm) && $form->isDefaultForm && ($form->required || $form->mustRequired))
1350
				{
1351
					$memberInfo[$lang->{$form->name}] = $member_info->{$form->name};
1352
				}
1353
			}
1354
		}
1355
		else
1356
		{
1357
			$memberInfo[$lang->user_id] = $member_info->user_id;
1358
			$memberInfo[$lang->user_name] = $member_info->user_name;
1359
			$memberInfo[$lang->nick_name] = $member_info->nick_name;
1360
			$memberInfo[$lang->email_address] = $member_info->email_address;
1361
		}
1362
		Context::set('memberInfo', $memberInfo);
0 ignored issues
show
Documentation introduced by
$memberInfo is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1363
1364
		if(!$member_config->skin) $member_config->skin = "default";
1365
		if(!$member_config->colorset) $member_config->colorset = "white";
1366
1367
		Context::set('member_config', $member_config);
1368
1369
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1370
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
1371
1372
		$auth_url = getFullUrl('','module','member','act','procMemberAuthAccount','member_srl',$member_info->member_srl, 'auth_key',$auth_args->auth_key);
1373
		Context::set('auth_url', $auth_url);
1374
1375
		$oTemplate = &TemplateHandler::getInstance();
1376
		$content = $oTemplate->compile($tpl_path, 'confirm_member_account_mail');
1377
		// Send a mail
1378
		$oMail = new Mail();
1379
		$oMail->setTitle( Context::getLang('msg_confirm_account_title') );
1380
		$oMail->setContent($content);
1381
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
1382
		$oMail->setReceiptor( $member_info->user_name, $member_info->email_address );
1383
		$oMail->send();
1384
	}
1385
1386
	/**
1387
	 * Join a virtual site
1388
	 *
1389
	 * @return void|Object (void : success, Object : fail)
1390
	 */
1391
	function procMemberSiteSignUp()
1392
	{
1393
		$site_module_info = Context::get('site_module_info');
1394
		$logged_info = Context::get('logged_info');
1395 View Code Duplication
		if(!$site_module_info->site_srl || !Context::get('is_logged') || count($logged_info->group_srl_list) ) return new Object(-1,'msg_invalid_request');
1396
1397
		$oMemberModel = getModel('member');
1398
		$columnList = array('site_srl', 'group_srl', 'title');
1399
		$default_group = $oMemberModel->getDefaultGroup($site_module_info->site_srl, $columnList);
1400
		$this->addMemberToGroup($logged_info->member_srl, $default_group->group_srl, $site_module_info->site_srl);
1401
		$groups[$default_group->group_srl] = $default_group->title;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$groups was never initialized. Although not strictly required by PHP, it is generally a good practice to add $groups = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
1402
		$logged_info->group_list = $groups;
1403
	}
1404
1405
	/**
1406
	 * Leave the virtual site
1407
	 *
1408
	 * @return void|Object (void : success, Object : fail)
1409
	 */
1410
	function procMemberSiteLeave()
1411
	{
1412
		$site_module_info = Context::get('site_module_info');
1413
		$logged_info = Context::get('logged_info');
1414 View Code Duplication
		if(!$site_module_info->site_srl || !Context::get('is_logged') || count($logged_info->group_srl_list) ) return new Object(-1,'msg_invalid_request');
1415
1416
		$args = new stdClass;
1417
		$args->site_srl= $site_module_info->site_srl;
1418
		$args->member_srl = $logged_info->member_srl;
1419
		$output = executeQuery('member.deleteMembersGroup', $args);
1420
		if(!$output->toBool()) return $output;
1421
		$this->setMessage('success_deleted');
1422
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
1423
	}
1424
1425
	/**
1426
	 * Save the member configurations
1427
	 *
1428
	 * @param object $args
1429
	 *
1430
	 * @return void
1431
	 */
1432
	function setMemberConfig($args)
1433
	{
1434
		if(!$args->skin) $args->skin = "default";
1435
		if(!$args->colorset) $args->colorset = "white";
1436
		if(!$args->editor_skin) $args->editor_skin= "ckeditor";
1437
		if(!$args->editor_colorset) $args->editor_colorset = "moono";
1438
		if($args->enable_join!='Y') $args->enable_join = 'N';
1439
		$args->enable_openid= 'N';
1440
		if($args->profile_image !='Y') $args->profile_image = 'N';
1441
		if($args->image_name!='Y') $args->image_name = 'N';
1442
		if($args->image_mark!='Y') $args->image_mark = 'N';
1443
		if($args->group_image_mark!='Y') $args->group_image_mark = 'N';
1444
		if(!trim(strip_tags($args->agreement))) $args->agreement = null;
1445
		$args->limit_day = (int)$args->limit_day;
1446
1447
		$agreement = trim($args->agreement);
1448
		unset($args->agreement);
1449
1450
		$oModuleController = getController('module');
1451
		$output = $oModuleController->insertModuleConfig('member',$args);
1452
		if(!$output->toBool()) return $output;
1453
1454
		$agreement_file = _XE_PATH_.'files/member_extra_info/agreement.txt';
1455
		FileHandler::writeFile($agreement_file, $agreement);
1456
1457
		return new Object();
1458
	}
1459
1460
	/**
1461
	 * Save the signature as a file
1462
	 *
1463
	 * @param int $member_srl
1464
	 * @param string $signature
1465
	 *
1466
	 * @return void
1467
	 */
1468
	function putSignature($member_srl, $signature)
1469
	{
1470
		$signature = trim(removeHackTag($signature));
1471
		$signature = preg_replace('/<(\/?)(embed|object|param)/is', '&lt;$1$2', $signature);
1472
1473
		$check_signature = trim(str_replace(array('&nbsp;',"\n","\r"),'',strip_tags($signature,'<img><object>')));
1474
		$path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($member_srl));
1475
		$filename = sprintf('%s%d.signature.php', $path, $member_srl);
1476
1477
		if(!$check_signature) return FileHandler::removeFile($filename);
1478
1479
		$buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature);
1480
		FileHandler::makeDir($path);
1481
		FileHandler::writeFile($filename, $buff);
1482
	}
1483
1484
	/**
1485
	 * Delete the signature file
1486
	 *
1487
	 * @param string $member_srl
1488
	 *
1489
	 * @return void
1490
	 */
1491
	function delSignature($member_srl)
1492
	{
1493
		$filename = sprintf('files/member_extra_info/signature/%s%d.gif', getNumberingPath($member_srl), $member_srl);
1494
		FileHandler::removeFile($filename);
1495
	}
1496
1497
	/**
1498
	 * Add group_srl to member_srl
1499
	 *
1500
	 * @param int $member_srl
1501
	 * @param int $group_srl
1502
	 * @param int $site_srl
1503
	 *
1504
	 * @return Object
1505
	 */
1506
	function addMemberToGroup($member_srl, $group_srl, $site_srl=0)
1507
	{
1508
		$args = new stdClass();
1509
		$args->member_srl = $member_srl;
1510
		$args->group_srl = $group_srl;
1511
		if($site_srl) $args->site_srl = $site_srl;
1512
1513
		// Add
1514
		$output = executeQuery('member.addMemberToGroup',$args);
1515
		$output2 = ModuleHandler::triggerCall('member.addMemberToGroup', 'after', $args);
0 ignored issues
show
Unused Code introduced by
$output2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1516
1517
		$this->_clearMemberCache($member_srl, $site_srl);
1518
1519
		return $output;
1520
	}
1521
1522
	/**
1523
	 * Change a group of certain members
1524
	 * Available only when a member has a single group
1525
	 *
1526
	 * @param object $args
1527
	 *
1528
	 * @return Object
1529
	 */
1530
	function replaceMemberGroup($args)
1531
	{
1532
		$obj = new stdClass;
1533
		$obj->site_srl = $args->site_srl;
1534
		$obj->member_srl = implode(',',$args->member_srl);
1535
1536
		$output = executeQueryArray('member.getMembersGroup', $obj);
1537
		if($output->data) foreach($output->data as $key => $val) $date[$val->member_srl] = $val->regdate;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$date was never initialized. Although not strictly required by PHP, it is generally a good practice to add $date = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
1538
1539
		$output = executeQuery('member.deleteMembersGroup', $obj);
1540
		if(!$output->toBool()) return $output;
1541
1542
		$inserted_members = array();
1543
		foreach($args->member_srl as $key => $val)
1544
		{
1545
			if($inserted_members[$val]) continue;
1546
			$inserted_members[$val] = true;
1547
1548
			unset($obj);
1549
			$obj = new stdClass;
1550
			$obj->member_srl = $val;
1551
			$obj->group_srl = $args->group_srl;
1552
			$obj->site_srl = $args->site_srl;
1553
			$obj->regdate = $date[$obj->member_srl];
0 ignored issues
show
Bug introduced by
The variable $date does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
1554
			$output = executeQuery('member.addMemberToGroup', $obj);
1555
			if(!$output->toBool()) return $output;
1556
1557
			$this->_clearMemberCache($obj->member_srl, $args->site_srl);
1558
		}
1559
1560
		return new Object();
1561
	}
1562
1563
1564
	/**
1565
	 * Auto-login
1566
	 *
1567
	 * @return void
1568
	 */
1569
	function doAutologin()
1570
	{
1571
		// Get a key value of auto log-in
1572
		$args = new stdClass;
1573
		$args->autologin_key = $_COOKIE['xeak'];
1574
		// Get information of the key
1575
		$output = executeQuery('member.getAutologin', $args);
1576
		// If no information exists, delete a cookie
1577 View Code Duplication
		if(!$output->toBool() || !$output->data)
1578
		{
1579
			setCookie('xeak',null,$_SERVER['REQUEST_TIME']+60*60*24*365, '/');
1580
			return;
1581
		}
1582
1583
		$oMemberModel = getModel('member');
1584
		$config = $oMemberModel->getMemberConfig();
1585
1586
		$user_id = ($config->identifier == 'user_id') ? $output->data->user_id : $output->data->email_address;
1587
		$password = $output->data->password;
1588
1589 View Code Duplication
		if(!$user_id || !$password)
1590
		{
1591
			setCookie('xeak',null,$_SERVER['REQUEST_TIME']+60*60*24*365, '/');
1592
			return;
1593
		}
1594
1595
		$do_auto_login = false;
1596
1597
		// Compare key values based on the information
1598
		$check_key = strtolower($user_id).$password.$_SERVER['HTTP_USER_AGENT'];
1599
		$check_key = substr(hash_hmac('sha256', $check_key, substr($args->autologin_key, 0, 32)), 0, 32);
1600
1601
		if($check_key === substr($args->autologin_key, 32))
1602
		{
1603
			// Check change_password_date
1604
			$oModuleModel = getModel('module');
1605
			$member_config = $oModuleModel->getModuleConfig('member');
1606
			$limit_date = $member_config->change_password_date;
1607
1608
			// Check if change_password_date is set
1609
			if($limit_date > 0)
1610
			{
1611
				$oMemberModel = getModel('member');
1612
				$columnList = array('member_srl', 'change_password_date');
1613
1614
				if($config->identifier == 'user_id')
1615
				{
1616
					$member_info = $oMemberModel->getMemberInfoByUserID($user_id, $columnList);
1617
				}
1618
				else
1619
				{
1620
					$member_info = $oMemberModel->getMemberInfoByEmailAddress($user_id, $columnList);
1621
				}
1622
1623
				if($member_info->change_password_date >= date('YmdHis', strtotime('-'.$limit_date.' day')) ){
1624
					$do_auto_login = true;
1625
				}
1626
1627
			}
1628
			else
1629
			{
1630
				$do_auto_login = true;
1631
			}
1632
		}
1633
1634
		if($do_auto_login)
1635
		{
1636
			$output = $this->doLogin($user_id);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1637
		}
1638
		else
1639
		{
1640
			executeQuery('member.deleteAutologin', $args);
1641
			setCookie('xeak',null,$_SERVER['REQUEST_TIME']+60*60*24*365, '/');
1642
		}
1643
	}
1644
1645
	/**
1646
	 * Log-in
1647
	 *
1648
	 * @param string $user_id
1649
	 * @param string $password
1650
	 * @param boolean $keep_signed
1651
	 *
1652
	 * @return Object
1653
	 */
1654
	function doLogin($user_id, $password = '', $keep_signed = false)
1655
	{
1656
		$user_id = strtolower($user_id);
1657
		if(!$user_id) return new Object(-1, 'null_user_id');
1658
		// Call a trigger before log-in (before)
1659
		$trigger_obj = new stdClass();
1660
		$trigger_obj->user_id = $user_id;
1661
		$trigger_obj->password = $password;
1662
		$trigger_output = ModuleHandler::triggerCall('member.doLogin', 'before', $trigger_obj);
1663
		if(!$trigger_output->toBool()) return $trigger_output;
1664
		// Create a member model object
1665
		$oMemberModel = getModel('member');
1666
1667
		// check IP access count.
1668
		$config = $oMemberModel->getMemberConfig();
1669
		$args = new stdClass();
1670
		$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1671
1672
		// check identifier
1673
		if($config->identifier == 'email_address')
1674
		{
1675
			// Get user_id information
1676
			$this->memberInfo = $oMemberModel->getMemberInfoByEmailAddress($user_id);
1677
			// Set an invalid user if no value returned
1678
			if(!$user_id || strtolower($this->memberInfo->email_address) != strtolower($user_id)) return $this->recordLoginError(-1, 'invalid_email_address');
1679
1680
		}
1681
		else
1682
		{
1683
			// Get user_id information
1684
			$this->memberInfo = $oMemberModel->getMemberInfoByUserID($user_id);
1685
			// Set an invalid user if no value returned
1686
			if(!$user_id || strtolower($this->memberInfo->user_id) != strtolower($user_id)) return $this->recordLoginError(-1, 'invalid_user_id');
1687
		}
1688
1689
		$output = executeQuery('member.getLoginCountByIp', $args);
1690
		$errorCount = $output->data->count;
1691
		if($errorCount >= $config->max_error_count)
1692
		{
1693
			$last_update = strtotime($output->data->last_update);
1694
			$term = intval($_SERVER['REQUEST_TIME']-$last_update);
1695
			if($term < $config->max_error_count_time)
1696
			{
1697
				$term = $config->max_error_count_time - $term;
1698
				if($term < 60) $term = intval($term).Context::getLang('unit_sec');
1699
				elseif(60 <= $term && $term < 3600) $term = intval($term/60).Context::getLang('unit_min');
1700
				elseif(3600 <= $term && $term < 86400) $term = intval($term/3600).Context::getLang('unit_hour');
1701
				else $term = intval($term/86400).Context::getLang('unit_day');
1702
1703
				return new Object(-1, sprintf(Context::getLang('excess_ip_access_count'),$term));
1704
			}
1705
			else
1706
			{
1707
				$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1708
				$output = executeQuery('member.deleteLoginCountByIp', $args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1709
			}
1710
		}
1711
1712
		// Password Check
1713
		if($password && !$oMemberModel->isValidPassword($this->memberInfo->password, $password, $this->memberInfo->member_srl))
1714
		{
1715
			return $this->recordMemberLoginError(-1, 'invalid_password',$this->memberInfo);
1716
		}
1717
1718
		// If denied == 'Y', notify
1719
		if($this->memberInfo->denied == 'Y')
1720
		{
1721
			$args->member_srl = $this->memberInfo->member_srl;
1722
			$output = executeQuery('member.chkAuthMail', $args);
1723
			if ($output->toBool() && $output->data->count != '0')
1724
			{
1725
				$_SESSION['auth_member_srl'] = $this->memberInfo->member_srl;
1726
				$redirectUrl = getUrl('', 'act', 'dispMemberResendAuthMail');
1727
				return $this->setRedirectUrl($redirectUrl, new Object(-1,'msg_user_not_confirmed'));
1728
			}
1729
			return new Object(-1,'msg_user_denied');
1730
		}
1731
		// Notify if denied_date is less than the current time
1732
		if($this->memberInfo->limit_date && substr($this->memberInfo->limit_date,0,8) >= date("Ymd")) return new Object(-9,sprintf(Context::getLang('msg_user_limited'),zdate($this->memberInfo->limit_date,"Y-m-d")));
1733
		// Update the latest login time
1734
		$args->member_srl = $this->memberInfo->member_srl;
1735
		$output = executeQuery('member.updateLastLogin', $args);
1736
1737
		$site_module_info = Context::get('site_module_info');
1738
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
1739
1740
		// Check if there is recoding table.
1741
		$oDB = &DB::getInstance();
1742
		if($oDB->isTableExists('member_count_history') && $config->enable_login_fail_report != 'N')
1743
		{
1744
			// check if there is login fail records.
1745
			$output = executeQuery('member.getLoginCountHistoryByMemberSrl', $args);
1746
			if($output->data && $output->data->content)
1747
			{
1748
				$title = Context::getLang('login_fail_report');
1749
				$message = '<ul>';
1750
				$content = unserialize($output->data->content);
1751
				if(count($content) > $config->max_error_count)
1752
				{
1753
					foreach($content as $val)
1754
					{
1755
						$message .= '<li>'.Context::getLang('regdate').': '.date('Y-m-d h:i:sa',$val[2]).'<ul><li>'.Context::getLang('ipaddress').': '.$val[0].'</li><li>'.Context::getLang('message').': '.$val[1].'</li></ul></li>';
1756
					}
1757
					$message .= '</ul>';
1758
					$content = sprintf(Context::getLang('login_fail_report_contents'),$message,date('Y-m-d h:i:sa'));
1759
1760
					//send message
1761
					$oCommunicationController = getController('communication');
1762
					$oCommunicationController->sendMessage($args->member_srl, $args->member_srl, $title, $content, true);
1763
1764
					if($this->memberInfo->email_address && $this->memberInfo->allow_mailing == 'Y')
1765
					{
1766
						$view_url = Context::getRequestUri();
1767
						$content = sprintf("%s<hr /><p>From: <a href=\"%s\" target=\"_blank\">%s</a><br />To: %s(%s)</p>",$content, $view_url, $view_url, $this->memberInfo->nick_name, $this->memberInfo->email_id);
1768
						$oMail = new Mail();
1769
						$oMail->setTitle($title);
1770
						$oMail->setContent($content);
1771
						$oMail->setSender($config->webmaster_name?$config->webmaster_name:'webmaster', $config->webmaster_email);
1772
						$oMail->setReceiptor($this->memberInfo->email_id.'('.$this->memberInfo->nick_name.')', $this->memberInfo->email_address);
1773
						$oMail->send();
1774
					}
1775
					$output = executeQuery('member.deleteLoginCountHistoryByMemberSrl', $args);
1776
				}
1777
			}
1778
		}
1779
		// Call a trigger after successfully log-in (after)
1780
		$trigger_output = ModuleHandler::triggerCall('member.doLogin', 'after', $this->memberInfo);
1781
		if(!$trigger_output->toBool()) return $trigger_output;
1782
		// When user checked to use auto-login
1783
		if($keep_signed)
1784
		{
1785
			// Key generate for auto login
1786
			$oPassword = new Password();
1787
			$random_key = $oPassword->createSecureSalt(32, 'hex');
1788
			$extra_key = strtolower($user_id).$this->memberInfo->password.$_SERVER['HTTP_USER_AGENT'];
1789
			$extra_key = substr(hash_hmac('sha256', $extra_key, $random_key), 0, 32);
1790
			$autologin_args = new stdClass;
1791
			$autologin_args->autologin_key = $random_key.$extra_key;
1792
			$autologin_args->member_srl = $this->memberInfo->member_srl;
1793
			executeQuery('member.deleteAutologin', $autologin_args);
1794
			$autologin_output = executeQuery('member.insertAutologin', $autologin_args);
1795
			if($autologin_output->toBool()) setCookie('xeak',$autologin_args->autologin_key, $_SERVER['REQUEST_TIME']+31536000, '/');
1796
		}
1797
		if($this->memberInfo->is_admin == 'Y')
1798
		{
1799
			$oMemberAdminModel = getAdminModel('member');
1800
			if(!$oMemberAdminModel->getMemberAdminIPCheck())
1801
			{
1802
				$_SESSION['denied_admin'] = 'Y';
1803
			}
1804
		}
1805
1806
		$this->setSessionInfo();
1807
1808
		return $output;
1809
	}
1810
1811
	/**
1812
	 * Update or create session information
1813
	 */
1814
	function setSessionInfo()
1815
	{
1816
		$oMemberModel = getModel('member');
1817
		// If your information came through the current session information to extract information from the users
1818
		if(!$this->memberInfo && $_SESSION['member_srl'] && $oMemberModel->isLogged() )
1819
		{
1820
			$this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($_SESSION['member_srl']);
1821
			// If you do not destroy the session Profile
1822
			if($this->memberInfo->member_srl != $_SESSION['member_srl'])
1823
			{
1824
				$this->destroySessionInfo();
1825
				return;
1826
			}
1827
		}
1828
		// Stop using the session id is destroyed
1829
		if($this->memberInfo->denied=='Y')
1830
		{
1831
			$this->destroySessionInfo();
1832
			return;
1833
		}
1834
		// Log in for treatment sessions set
1835
		$_SESSION['is_logged'] = true;
1836
		$_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR'];
1837
		$_SESSION['member_srl'] = $this->memberInfo->member_srl;
1838
		$_SESSION['is_admin'] = '';
1839
		setcookie('xe_logged', 'true', 0, '/');
1840
		// Do not save your password in the session jiwojum;;
1841
		//unset($this->memberInfo->password);
1842
		// User Group Settings
1843
		/*
1844
		   if($this->memberInfo->group_list) {
1845
		   $group_srl_list = array_keys($this->memberInfo->group_list);
1846
		   $_SESSION['group_srls'] = $group_srl_list;
1847
		// If the group is designated as an administrator administrator
1848
		$oMemberModel = getModel('member');
1849
		$admin_group = $oMemberModel->getAdminGroup();
1850
		if($admin_group->group_srl && in_array($admin_group->group_srl, $group_srl_list)) $_SESSION['is_admin'] = 'Y';
1851
		}
1852
		 */
1853
1854
		// Information stored in the session login user
1855
		Context::set('is_logged', true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1856
		Context::set('logged_info', $this->memberInfo);
1857
1858
		// Only the menu configuration of the user (such as an add-on to the menu can be changed)
1859
		$this->addMemberMenu( 'dispMemberInfo', 'cmd_view_member_info');
1860
		$this->addMemberMenu( 'dispMemberScrappedDocument', 'cmd_view_scrapped_document');
1861
		$this->addMemberMenu( 'dispMemberSavedDocument', 'cmd_view_saved_document');
1862
		$this->addMemberMenu( 'dispMemberOwnDocument', 'cmd_view_own_document');
1863
	}
1864
1865
	/**
1866
	 * Logged method for providing a personalized menu
1867
	 * Login information is used in the output widget, or personalized page
1868
	 */
1869
	function addMemberMenu($act, $str)
1870
	{
1871
		$logged_info = Context::get('logged_info');
1872
1873
		$logged_info->menu_list[$act] = Context::getLang($str);
1874
1875
		Context::set('logged_info', $logged_info);
1876
	}
1877
1878
	/**
1879
	 * Nickname and click Log In to add a pop-up menu that appears when the method
1880
	 */
1881 View Code Duplication
	function addMemberPopupMenu($url, $str, $icon = '', $target = 'self')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1882
	{
1883
		$member_popup_menu_list = Context::get('member_popup_menu_list');
1884
		if(!is_array($member_popup_menu_list)) $member_popup_menu_list = array();
1885
1886
		$obj = new stdClass;
1887
		$obj->url = $url;
1888
		$obj->str = $str;
1889
		$obj->icon = $icon;
1890
		$obj->target = $target;
1891
		$member_popup_menu_list[] = $obj;
1892
1893
		Context::set('member_popup_menu_list', $member_popup_menu_list);
0 ignored issues
show
Documentation introduced by
$member_popup_menu_list is of type array<integer,object<stdClass>>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1894
	}
1895
1896
	/**
1897
	 * Add users to the member table
1898
	 */
1899
	function insertMember(&$args, $password_is_hashed = false)
1900
	{
1901
		// Call a trigger (before)
1902
		$output = ModuleHandler::triggerCall('member.insertMember', 'before', $args);
1903
		if(!$output->toBool()) return $output;
1904
		// Terms and Conditions portion of the information set up by members reaffirmed
1905
		$oModuleModel = getModel('module');
1906
		$config = $oModuleModel->getModuleConfig('member');
1907
1908
		$logged_info = Context::get('logged_info');
1909
		// If the date of the temporary restrictions limit further information on the date of
1910
		if($config->limit_day) $args->limit_date = date("YmdHis", $_SERVER['REQUEST_TIME']+$config->limit_day*60*60*24);
1911
1912
		$args->member_srl = getNextSequence();
1913
		$args->list_order = -1 * $args->member_srl;
1914
1915
		// Execute insert or update depending on the value of member_srl
1916
		if(!$args->user_id) $args->user_id = 't'.$args->member_srl;
1917
		// Enter the user's identity changed to lowercase
1918
		else $args->user_id = strtolower($args->user_id);
1919
		if(!$args->user_name) $args->user_name = $args->member_srl;
1920
		if(!$args->nick_name) $args->nick_name = $args->member_srl;
1921
1922
		// Control of essential parameters
1923
		if($args->allow_mailing!='Y') $args->allow_mailing = 'N';
1924
		if($args->denied!='Y') $args->denied = 'N';
1925
		$args->allow_message= 'Y';
1926
1927
		if($logged_info->is_admin == 'Y')
1928
		{
1929
			if($args->is_admin!='Y') $args->is_admin = 'N';
1930
		}
1931
		else
1932
		{
1933
			unset($args->is_admin);
1934
		}
1935
1936
		list($args->email_id, $args->email_host) = explode('@', $args->email_address);
1937
1938
		// Sanitize user ID, username, nickname, homepage, blog
1939
		$args->user_id = htmlspecialchars($args->user_id, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
1940
		$args->user_name = htmlspecialchars($args->user_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
1941
		$args->nick_name = htmlspecialchars($args->nick_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
1942
		$args->homepage = htmlspecialchars($args->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
1943
		$args->blog = htmlspecialchars($args->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
1944 View Code Duplication
		if($args->homepage && !preg_match("/^[a-z]+:\/\//i",$args->homepage)) $args->homepage = 'http://'.$args->homepage;
1945 View Code Duplication
		if($args->blog && !preg_match("/^[a-z]+:\/\//i",$args->blog)) $args->blog = 'http://'.$args->blog;
1946
1947
		// Create a model object
1948
		$oMemberModel = getModel('member');
1949
1950
		// Check password strength
1951
		if($args->password && !$password_is_hashed)
1952
		{
1953 View Code Duplication
			if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
1954
			{
1955
				$message = Context::getLang('about_password_strength');
1956
				return new Object(-1, $message[$config->password_strength]);
1957
			}
1958
			$args->password = $oMemberModel->hashPassword($args->password);
1959
		}
1960
		elseif(!$args->password)
1961
		{
1962
			unset($args->password);
1963
		}
1964
1965
		// Check if ID is prohibited
1966
		if($oMemberModel->isDeniedID($args->user_id))
1967
		{
1968
			return new Object(-1,'denied_user_id');
1969
		}
1970
1971
		// Check if ID is duplicate
1972
		$member_srl = $oMemberModel->getMemberSrlByUserID($args->user_id);
1973
		if($member_srl)
1974
		{
1975
			return new Object(-1,'msg_exists_user_id');
1976
		}
1977
1978
		// Check if nickname is prohibited
1979
		if($oMemberModel->isDeniedNickName($args->nick_name))
1980
		{
1981
			return new Object(-1,'denied_nick_name');
1982
		}
1983
1984
		// Check if nickname is duplicate
1985
		$member_srl = $oMemberModel->getMemberSrlByNickName($args->nick_name);
1986
		if($member_srl)
1987
		{
1988
			return new Object(-1,'msg_exists_nick_name');
1989
		}
1990
1991
		// Check if email address is duplicate
1992
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($args->email_address);
1993
		if($member_srl)
1994
		{
1995
			return new Object(-1,'msg_exists_email_address');
1996
		}
1997
1998
		// Insert data into the DB
1999
		$args->list_order = -1 * $args->member_srl;
2000
2001
		if(!$args->user_id) $args->user_id = 't'.$args->member_srl;
2002
		if(!$args->user_name) $args->user_name = $args->member_srl;
2003
2004
		$oDB = &DB::getInstance();
2005
		$oDB->begin();
2006
2007
		$output = executeQuery('member.insertMember', $args);
2008
		if(!$output->toBool())
2009
		{
2010
			$oDB->rollback();
2011
			return $output;
2012
		}
2013
2014 View Code Duplication
		if(is_array($args->group_srl_list)) $group_srl_list = $args->group_srl_list;
2015
		else $group_srl_list = explode('|@|', $args->group_srl_list);
2016
		// If no value is entered the default group, the value of group registration
2017
		if(!$args->group_srl_list)
2018
		{
2019
			$columnList = array('site_srl', 'group_srl');
2020
			$default_group = $oMemberModel->getDefaultGroup(0, $columnList);
2021
			if($default_group)
2022
			{
2023
				// Add to the default group
2024
				$output = $this->addMemberToGroup($args->member_srl,$default_group->group_srl);
2025
				if(!$output->toBool())
2026
				{
2027
					$oDB->rollback();
2028
					return $output;
2029
				}
2030
			}
2031
			// If the value is the value of the group entered the group registration
2032
		}
2033
		else
2034
		{
2035 View Code Duplication
			for($i=0;$i<count($group_srl_list);$i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
2036
			{
2037
				$output = $this->addMemberToGroup($args->member_srl,$group_srl_list[$i]);
2038
2039
				if(!$output->toBool())
2040
				{
2041
					$oDB->rollback();
2042
					return $output;
2043
				}
2044
			}
2045
		}
2046
2047
		$member_config = $oModuleModel->getModuleConfig('member');
0 ignored issues
show
Unused Code introduced by
$member_config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2048
		// When using email authentication mode (when you subscribed members denied a) certified mail sent
2049
		if($args->denied == 'Y')
2050
		{
2051
			// Insert data into the authentication DB
2052
			$oPassword = new Password();
2053
			$auth_args = new stdClass();
2054
			$auth_args->user_id = $args->user_id;
2055
			$auth_args->member_srl = $args->member_srl;
2056
			$auth_args->new_password = $args->password;
2057
			$auth_args->auth_key = $oPassword->createSecureSalt(40);
2058
			$auth_args->is_register = 'Y';
2059
2060
			$output = executeQuery('member.insertAuthMail', $auth_args);
2061
			if(!$output->toBool())
2062
			{
2063
				$oDB->rollback();
2064
				return $output;
2065
			}
2066
			$this->_sendAuthMail($auth_args, $args);
2067
		}
2068
		// Call a trigger (after)
2069 View Code Duplication
		if($output->toBool())
2070
		{
2071
			$trigger_output = ModuleHandler::triggerCall('member.insertMember', 'after', $args);
2072
			if(!$trigger_output->toBool())
2073
			{
2074
				$oDB->rollback();
2075
				return $trigger_output;
2076
			}
2077
		}
2078
2079
		$oDB->commit(true);
2080
2081
		$output->add('member_srl', $args->member_srl);
2082
		return $output;
2083
	}
2084
2085
	/**
2086
	 * Modify member information
2087
	 *
2088
	 * @param bool $is_admin , modified 2013-11-22
2089
	 */
2090
	function updateMember($args, $is_admin = FALSE)
2091
	{
2092
		// Call a trigger (before)
2093
		$output = ModuleHandler::triggerCall('member.updateMember', 'before', $args);
2094
		if(!$output->toBool()) return $output;
2095
		// Create a model object
2096
		$oMemberModel = getModel('member');
2097
2098
		$logged_info = Context::get('logged_info');
2099
		// Get what you want to modify the original information
2100
		if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
2101
		// Control of essential parameters
2102
		if($args->allow_mailing!='Y') $args->allow_mailing = 'N';
2103 View Code Duplication
		if($args->allow_message && !in_array($args->allow_message, array('Y','N','F'))) $args->allow_message = 'Y';
2104
2105
		if($logged_info->is_admin == 'Y')
2106
		{
2107
			if($args->denied!='Y') $args->denied = 'N';
2108
			if($args->is_admin!='Y' && $logged_info->member_srl != $args->member_srl) $args->is_admin = 'N';
2109
		}
2110
		else
2111
		{
2112
			unset($args->is_admin);
2113
			if($is_admin == false)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
2114
				unset($args->denied);
2115
			if($logged_info->member_srl != $args->member_srl && $is_admin == false)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
2116
			{
2117
				return $this->stop('msg_invalid_request');
2118
			}
2119
		}
2120
2121
		// Sanitize user ID, username, nickname, homepage, blog
2122
		if($args->user_id) $args->user_id = htmlspecialchars($args->user_id, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2123
		$args->user_name = htmlspecialchars($args->user_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2124
		$args->nick_name = htmlspecialchars($args->nick_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2125
		$args->homepage = htmlspecialchars($args->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2126
		$args->blog = htmlspecialchars($args->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2127 View Code Duplication
		if($args->homepage && !preg_match("/^[a-z]+:\/\//is",$args->homepage)) $args->homepage = 'http://'.$args->homepage;
2128 View Code Duplication
		if($args->blog && !preg_match("/^[a-z]+:\/\//is",$args->blog)) $args->blog = 'http://'.$args->blog;
2129
2130
		// check member identifier form
2131
		$config = $oMemberModel->getMemberConfig();
2132
2133
		$output = executeQuery('member.getMemberInfoByMemberSrl', $args);
2134
		$orgMemberInfo = $output->data;
2135
2136
		// Check if email address or user ID is duplicate
2137
		if($config->identifier == 'email_address')
2138
		{
2139
			$member_srl = $oMemberModel->getMemberSrlByEmailAddress($args->email_address);
2140
			if($member_srl && $args->member_srl != $member_srl)
2141
			{
2142
				return new Object(-1,'msg_exists_email_address');
2143
			}
2144
			$args->email_address = $orgMemberInfo->email_address;
2145
		}
2146 View Code Duplication
		else
2147
		{
2148
			$member_srl = $oMemberModel->getMemberSrlByUserID($args->user_id);
2149
			if($member_srl && $args->member_srl != $member_srl)
2150
			{
2151
				return new Object(-1,'msg_exists_user_id');
2152
			}
2153
2154
			$args->user_id = $orgMemberInfo->user_id;
2155
		}
2156
2157
		// Check if ID is prohibited
2158
		if($args->user_id && $oMemberModel->isDeniedID($args->user_id))
2159
		{
2160
			return new Object(-1,'denied_user_id');
2161
		}
2162
2163
		// Check if ID is duplicate
2164 View Code Duplication
		if($args->user_id)
2165
		{
2166
			$member_srl = $oMemberModel->getMemberSrlByUserID($args->user_id);
2167
			if($member_srl && $args->member_srl != $member_srl)
2168
			{
2169
				return new Object(-1,'msg_exists_user_id');
2170
			}
2171
		}
2172
2173
		// Check if nickname is prohibited
2174
		if($args->nick_name && $oMemberModel->isDeniedNickName($args->nick_name))
2175
		{
2176
			return new Object(-1, 'denied_nick_name');
2177
		}
2178
2179
		// Check if nickname is duplicate
2180
		$member_srl = $oMemberModel->getMemberSrlByNickName($args->nick_name);
2181
 		if($member_srl && $args->member_srl != $member_srl)
2182
 		{
2183
 			return new Object(-1,'msg_exists_nick_name');
2184
 		}
2185
2186
		list($args->email_id, $args->email_host) = explode('@', $args->email_address);
2187
2188
		$oDB = &DB::getInstance();
2189
		$oDB->begin();
2190
2191
		// Check password strength
2192
		if($args->password)
2193
		{
2194 View Code Duplication
			if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
2195
			{
2196
				$message = Context::getLang('about_password_strength');
2197
				return new Object(-1, $message[$config->password_strength]);
2198
			}
2199
			$args->password = $oMemberModel->hashPassword($args->password);
2200
		}
2201
		else
2202
		{
2203
			$args->password = $orgMemberInfo->password;
2204
		}
2205
		
2206
		if(!$args->user_name) $args->user_name = $orgMemberInfo->user_name;
2207
		if(!$args->user_id) $args->user_id = $orgMemberInfo->user_id;
2208
		if(!$args->nick_name) $args->nick_name = $orgMemberInfo->nick_name;
2209
		if(!$args->description) $args->description = '';
2210
		if(!$args->birthday) $args->birthday = '';
2211
2212
		$output = executeQuery('member.updateMember', $args);
2213
2214
		if(!$output->toBool())
2215
		{
2216
			$oDB->rollback();
2217
			return $output;
2218
		}
2219
2220
		if($args->group_srl_list)
2221
		{
2222 View Code Duplication
			if(is_array($args->group_srl_list)) $group_srl_list = $args->group_srl_list;
2223
			else $group_srl_list = explode('|@|', $args->group_srl_list);
2224
			// If the group information, group information changes
2225
			if(count($group_srl_list) > 0)
2226
			{
2227
				$args->site_srl = 0;
2228
				// One of its members to delete all the group
2229
				$output = executeQuery('member.deleteMemberGroupMember', $args);
2230
				if(!$output->toBool())
2231
				{
2232
					$oDB->rollback();
2233
					return $output;
2234
				}
2235
				// Enter one of the loop a
2236 View Code Duplication
				for($i=0;$i<count($group_srl_list);$i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
2237
				{
2238
					$output = $this->addMemberToGroup($args->member_srl,$group_srl_list[$i]);
2239
					if(!$output->toBool())
2240
					{
2241
						$oDB->rollback();
2242
						return $output;
2243
					}
2244
				}
2245
2246
				// if group is changed, point changed too.
2247
				$this->_updatePointByGroup($orgMemberInfo->member_srl, $group_srl_list);
2248
			}
2249
		}
2250
		// Call a trigger (after)
2251 View Code Duplication
		if($output->toBool()) {
2252
			$trigger_output = ModuleHandler::triggerCall('member.updateMember', 'after', $args);
2253
			if(!$trigger_output->toBool())
2254
			{
2255
				$oDB->rollback();
2256
				return $trigger_output;
2257
			}
2258
		}
2259
2260
		$oDB->commit();
2261
2262
		//remove from cache
2263
		$this->_clearMemberCache($args->member_srl, $args->site_srl);
2264
2265
		// Save Session
2266
		if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
2267
		$logged_info = Context::get('logged_info');
0 ignored issues
show
Unused Code introduced by
$logged_info is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2268
2269
		$output->add('member_srl', $args->member_srl);
2270
		return $output;
2271
	}
2272
2273
	/**
2274
	 * Modify member password
2275
	 */
2276
	function updateMemberPassword($args)
2277
	{
2278
		if($args->password)
2279
		{
2280
2281
			// check password strength
2282
			$oMemberModel = getModel('member');
2283
			$config = $oMemberModel->getMemberConfig();
2284
2285 View Code Duplication
			if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
2286
			{
2287
				$message = Context::getLang('about_password_strength');
2288
				return new Object(-1, $message[$config->password_strength]);
2289
			}
2290
2291
			$args->password = $oMemberModel->hashPassword($args->password);
2292
		}
2293
		else if($args->hashed_password)
2294
		{
2295
			$args->password = $args->hashed_password;
2296
		}
2297
2298
		$output = executeQuery('member.updateMemberPassword', $args);
2299
		if($output->toBool())
2300
		{
2301
			$result = executeQuery('member.updateChangePasswordDate', $args);
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2302
		}
2303
2304
		$this->_clearMemberCache($args->member_srl);
2305
2306
		return $output;
2307
	}
2308
2309
	/**
2310
	 * Delete User
2311
	 */
2312
	function deleteMember($member_srl)
2313
	{
2314
		// Call a trigger (before)
2315
		$trigger_obj = new stdClass();
2316
		$trigger_obj->member_srl = $member_srl;
2317
		$output = ModuleHandler::triggerCall('member.deleteMember', 'before', $trigger_obj);
2318
		if(!$output->toBool()) return $output;
2319
		// Create a model object
2320
		$oMemberModel = getModel('member');
2321
		// Bringing the user's information
2322
		if(!$this->memberInfo || $this->memberInfo->member_srl != $member_srl || !isset($this->memberInfo->is_admin))
2323
		{
2324
			$columnList = array('member_srl', 'is_admin');
2325
			$this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
2326
		}
2327
		if(!$this->memberInfo) return new Object(-1, 'msg_not_exists_member');
2328
		// If managers can not be deleted
2329
		if($this->memberInfo->is_admin == 'Y') return new Object(-1, 'msg_cannot_delete_admin');
2330
2331
		$oDB = &DB::getInstance();
2332
		$oDB->begin();
2333
2334
		$args = new stdClass();
2335
		$args->member_srl = $member_srl;
2336
		// Delete the entries in member_auth_mail
2337
		$output = executeQuery('member.deleteAuthMail', $args);
2338
		if(!$output->toBool())
2339
		{
2340
			$oDB->rollback();
2341
			return $output;
2342
		}
2343
2344
		// TODO: If the table is not an upgrade may fail.
2345
		/*
2346
		   if(!$output->toBool()) {
2347
		   $oDB->rollback();
2348
		   return $output;
2349
		   }
2350
		 */
2351
		// Delete the entries in member_group_member
2352
		$output = executeQuery('member.deleteMemberGroupMember', $args);
2353
		if(!$output->toBool())
2354
		{
2355
			$oDB->rollback();
2356
			return $output;
2357
		}
2358
		// member removed from the table
2359
		$output = executeQuery('member.deleteMember', $args);
2360
		if(!$output->toBool())
2361
		{
2362
			$oDB->rollback();
2363
			return $output;
2364
		}
2365
		// Call a trigger (after)
2366 View Code Duplication
		if($output->toBool())
2367
		{
2368
			$trigger_output = ModuleHandler::triggerCall('member.deleteMember', 'after', $trigger_obj);
2369
			if(!$trigger_output->toBool())
2370
			{
2371
				$oDB->rollback();
2372
				return $trigger_output;
2373
			}
2374
		}
2375
2376
		$oDB->commit();
2377
		// Name, image, image, mark, sign, delete
2378
		$this->procMemberDeleteImageName($member_srl);
2379
		$this->procMemberDeleteImageMark($member_srl);
2380
		$this->procMemberDeleteProfileImage($member_srl);
2381
		$this->delSignature($member_srl);
2382
2383
		$this->_clearMemberCache($member_srl);
2384
2385
		return $output;
2386
	}
2387
2388
	/**
2389
	 * Destroy all session information
2390
	 */
2391
	function destroySessionInfo()
2392
	{
2393
		if(!$_SESSION || !is_array($_SESSION)) return;
2394
2395
		$memberInfo = Context::get('logged_info');
2396
		$memberSrl = $memberInfo->member_srl;
2397
2398
		foreach($_SESSION as $key => $val)
2399
		{
2400
			$_SESSION[$key] = '';
2401
		}
2402
2403
		session_destroy();
2404
		setcookie(session_name(), '', $_SERVER['REQUEST_TIME']-42000, '/');
2405
		setcookie('sso','',$_SERVER['REQUEST_TIME']-42000, '/');
2406
		setcookie('xeak','',$_SERVER['REQUEST_TIME']-42000, '/');
2407
		setcookie('xe_logged', 'false', $_SERVER['REQUEST_TIME'] - 42000, '/');
2408
2409
		if($memberSrl || $_COOKIE['xeak'])
2410
		{
2411
			$args = new stdClass();
2412
			$args->member_srl = $memberSrl;
2413
			$args->autologin_key = $_COOKIE['xeak'];
2414
			$output = executeQuery('member.deleteAutologin', $args);
0 ignored issues
show
Unused Code introduced by
$output is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2415
		}
2416
	}
2417
2418
	function _updatePointByGroup($memberSrl, $groupSrlList)
2419
	{
2420
		$oModuleModel = getModel('module');
2421
		$pointModuleConfig = $oModuleModel->getModuleConfig('point');
2422
		$pointGroup = $pointModuleConfig->point_group;
2423
2424
		$levelGroup = array();
2425
		if(is_array($pointGroup) && count($pointGroup)>0)
2426
		{
2427
			$levelGroup = array_flip($pointGroup);
2428
			ksort($levelGroup);
2429
		}
2430
		$maxLevel = 0;
2431
		$resultGroup = array_intersect($levelGroup, $groupSrlList);
2432
		if(count($resultGroup) > 0)
2433
			$maxLevel = max(array_flip($resultGroup));
2434
2435
		if($maxLevel > 0)
2436
		{
2437
			$oPointModel = getModel('point');
2438
			$originPoint = $oPointModel->getPoint($memberSrl);
2439
2440
			if($pointModuleConfig->level_step[$maxLevel] > $originPoint)
2441
			{
2442
				$oPointController = getController('point');
2443
				$oPointController->setPoint($memberSrl, $pointModuleConfig->level_step[$maxLevel], 'update');
2444
			}
2445
		}
2446
	}
2447
2448
	function procMemberModifyEmailAddress()
2449
	{
2450
		if(!Context::get('is_logged')) return $this->stop('msg_not_logged');
2451
2452
		$member_info = Context::get('logged_info');
2453
		$newEmail = Context::get('email_address');
2454
2455
		if(!$newEmail) return $this->stop('msg_invalid_request');
2456
2457
		$oMemberModel = getModel('member');
2458
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($newEmail);
2459
		if($member_srl) return new Object(-1,'msg_exists_email_address');
2460
2461
		if($_SESSION['rechecked_password_step'] != 'INPUT_DATA')
2462
		{
2463
			return $this->stop('msg_invalid_request');
2464
		}
2465
		unset($_SESSION['rechecked_password_step']);
2466
2467
		$oPassword = new Password();
2468
		$auth_args = new stdClass();
2469
		$auth_args->user_id = $newEmail;
2470
		$auth_args->member_srl = $member_info->member_srl;
2471
		$auth_args->auth_key = $oPassword->createSecureSalt(40);
2472
		$auth_args->new_password = 'XE_change_emaill_address';
2473
2474
		$oDB = &DB::getInstance();
2475
		$oDB->begin();
2476
		$output = executeQuery('member.insertAuthMail', $auth_args);
2477
		if(!$output->toBool())
2478
		{
2479
			$oDB->rollback();
2480
			return $output;
2481
		}
2482
2483
		$oModuleModel = getModel('module');
2484
		$member_config = $oModuleModel->getModuleConfig('member');
2485
2486
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
2487
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
2488
2489
		global $lang;
2490
2491
		$memberInfo = array();
2492
		$memberInfo[$lang->email_address] = $member_info->email_address;
2493
		$memberInfo[$lang->nick_name] = $member_info->nick_name;
2494
2495
		Context::set('memberInfo', $memberInfo);
0 ignored issues
show
Documentation introduced by
$memberInfo is of type array<?,?>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
2496
2497
		Context::set('newEmail', $newEmail);
2498
2499
		$auth_url = getFullUrl('','module','member','act','procMemberAuthEmailAddress','member_srl',$member_info->member_srl, 'auth_key',$auth_args->auth_key);
2500
		Context::set('auth_url', $auth_url);
2501
2502
		$oTemplate = &TemplateHandler::getInstance();
2503
		$content = $oTemplate->compile($tpl_path, 'confirm_member_new_email');
2504
2505
		$oMail = new Mail();
2506
		$oMail->setTitle( Context::getLang('title_modify_email_address') );
2507
		$oMail->setContent($content);
2508
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
2509
		$oMail->setReceiptor( $member_info->nick_name, $newEmail );
2510
		$result = $oMail->send();
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2511
2512
		$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $newEmail);
2513
		$this->setMessage($msg);
2514
2515
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
2516
		$this->setRedirectUrl($returnUrl);
2517
	}
2518
2519
	function procMemberAuthEmailAddress()
2520
	{
2521
		$member_srl = Context::get('member_srl');
2522
		$auth_key = Context::get('auth_key');
2523
		if(!$member_srl || !$auth_key) return $this->stop('msg_invalid_request');
2524
2525
		// Test logs for finding password by user_id and authkey
2526
		$args = new stdClass;
2527
		$args->member_srl = $member_srl;
2528
		$args->auth_key = $auth_key;
2529
		$output = executeQuery('member.getAuthMail', $args);
2530 View Code Duplication
		if(!$output->toBool() || $output->data->auth_key != $auth_key)
2531
		{
2532
			if(strlen($output->data->auth_key) !== strlen($auth_key)) executeQuery('member.deleteAuthChangeEmailAddress', $args);
2533
			return $this->stop('msg_invalid_modify_email_auth_key');
2534
		}
2535
2536
		$newEmail = $output->data->user_id;
2537
		$args->email_address = $newEmail;
2538
		list($args->email_id, $args->email_host) = explode('@', $newEmail);
2539
2540
		$output = executeQuery('member.updateMemberEmailAddress', $args);
2541
		if(!$output->toBool()) return $this->stop($output->getMessage());
2542
2543
		// Remove all values having the member_srl and new_password equal to 'XE_change_emaill_address' from authentication table
2544
		executeQuery('member.deleteAuthChangeEmailAddress',$args);
2545
2546
		$this->_clearMemberCache($args->member_srl);
2547
2548
		// Notify the result
2549
		$this->setTemplatePath($this->module_path.'tpl');
0 ignored issues
show
Bug introduced by
The property module_path cannot be accessed from this context as it is declared private in class ModuleObject.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
2550
		$this->setTemplateFile('msg_success_modify_email_address');
2551
	}
2552
2553
	/**
2554
	 * trigger for document.getDocumentMenu. Append to popup menu a button for procMemberSpammerManage()
2555
	 *
2556
	 * @param array &$menu_list
2557
	 *
2558
	 * @return object
2559
	**/
2560 View Code Duplication
	function triggerGetDocumentMenu(&$menu_list)
0 ignored issues
show
Unused Code introduced by
The parameter $menu_list is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2561
	{
2562
		if(!Context::get('is_logged')) return new Object();
2563
2564
		$logged_info = Context::get('logged_info');
2565
		$document_srl = Context::get('target_srl');
2566
2567
		$oDocumentModel = getModel('document');
2568
		$columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress');
2569
		$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
2570
		$member_srl = $oDocument->get('member_srl');
2571
		$module_srl = $oDocument->get('module_srl');
2572
2573
		if(!$member_srl) return new Object();
2574
		if($oDocumentModel->grant->manager != 1 || $member_srl==$logged_info->member_srl) return new Object();
2575
2576
		$oDocumentController = getController('document');
2577
		$url = getUrl('','module','member','act','dispMemberSpammer','member_srl',$member_srl,'module_srl',$module_srl);
2578
		$oDocumentController->addDocumentPopupMenu($url,'cmd_spammer','','popup');
2579
2580
		return new Object();
2581
	}
2582
2583
	/**
2584
	 * trigger for comment.getCommentMenu. Append to popup menu a button for procMemberSpammerManage()
2585
	 *
2586
	 * @param array &$menu_list
2587
	 *
2588
	 * @return object
2589
	**/
2590 View Code Duplication
	function triggerGetCommentMenu(&$menu_list)
0 ignored issues
show
Unused Code introduced by
The parameter $menu_list is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
2591
	{
2592
		if(!Context::get('is_logged')) return new Object();
2593
2594
		$logged_info = Context::get('logged_info');
2595
		$comment_srl = Context::get('target_srl');
2596
2597
		$oCommentModel = getModel('comment');
2598
		$columnList = array('comment_srl', 'module_srl', 'member_srl', 'ipaddress');
2599
		$oComment = $oCommentModel->getComment($comment_srl, FALSE, $columnList);
2600
		$module_srl = $oComment->get('module_srl');
2601
		$member_srl = $oComment->get('member_srl');
2602
2603
		if(!$member_srl) return new Object();
2604
		if($oCommentModel->grant->manager != 1 || $member_srl==$logged_info->member_srl) return new Object();
2605
2606
		$oCommentController = getController('comment');
2607
		$url = getUrl('','module','member','act','dispMemberSpammer','member_srl',$member_srl,'module_srl',$module_srl);
2608
		$oCommentController->addCommentPopupMenu($url,'cmd_spammer','','popup');
2609
2610
		return new Object();
2611
	}
2612
2613
	/**
2614
	 * Spammer manage. Denied user login. And delete or trash all documents. Response Ajax string
2615
	 *
2616
	 * @return object
2617
	**/
2618
	function procMemberSpammerManage()
2619
	{
2620
		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2621
2622
		$logged_info = Context::get('logged_info');
2623
		$member_srl = Context::get('member_srl');
2624
		$module_srl = Context::get('module_srl');
2625
		$cnt_loop = Context::get('cnt_loop');
2626
		$proc_type = Context::get('proc_type');
2627
		$isMoveToTrash = true;
2628
		if($proc_type == "delete")
2629
			$isMoveToTrash = false;
2630
2631
		// check grant
2632
		$oModuleModel = getModel('module');
2633
		$columnList = array('module_srl', 'module');
2634
		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
2635
		$grant = $oModuleModel->getGrant($module_info, $logged_info);
2636
2637
		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
2638
2639
		$proc_msg = "";
0 ignored issues
show
Unused Code introduced by
$proc_msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
2640
2641
		$oDocumentModel = getModel('document');
2642
		$oCommentModel = getModel('comment');
2643
2644
		// delete or trash destination
2645
		// proc member
2646
		if($cnt_loop == 1)
2647
			$this->_spammerMember($member_srl);
2648
		// proc document and comment
2649
		elseif($cnt_loop>1)
2650
			$this->_spammerDocuments($member_srl, $isMoveToTrash);
2651
2652
		// get destination count
2653
		$cnt_document = $oDocumentModel->getDocumentCountByMemberSrl($member_srl);
2654
		$cnt_comment = $oCommentModel->getCommentCountByMemberSrl($member_srl);
2655
2656
		$total_count = Context::get('total_count');
2657
		$remain_count = $cnt_document + $cnt_comment;
2658
		if($cnt_loop == 1) $total_count = $remain_count;
2659
2660
		// get progress percent
2661
		if($total_count > 0)
2662
			$progress = intval( ( ( $total_count - $remain_count ) / $total_count ) * 100 );
2663
		else
2664
			$progress = 100;
2665
2666
		$this->add('total_count', $total_count);
2667
		$this->add('remain_count', $remain_count);
2668
		$this->add('progress', $progress);
2669
		$this->add('member_srl', $member_srl);
2670
		$this->add('module_srl', $module_srl);
2671
		$this->add('cnt_loop', ++$cnt_loop);
2672
		$this->add('proc_type', $proc_type);
2673
2674
		return new Object(0);
2675
	}
2676
2677
	/**
2678
	 * Denied user login and write description
2679
	 *
2680
	 * @param int $member_srl
2681
	 *
2682
	 * @return object
2683
	**/
2684
	private function _spammerMember($member_srl) {
2685
		$logged_info = Context::get('logged_info');
2686
		$spam_description = trim( Context::get('spam_description') );
2687
2688
		$oMemberModel = getModel('member');
2689
		$columnList = array('member_srl', 'email_address', 'user_id', 'nick_name', 'description');
2690
		// get member current infomation
2691
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
2692
2693
		$oDocumentModel = getModel('document');
2694
		$oCommentModel = getModel('comment');
2695
		$cnt_comment = $oCommentModel->getCommentCountByMemberSrl($member_srl);
2696
		$cnt_document = $oDocumentModel->getDocumentCountByMemberSrl($member_srl);
2697
		$total_count = $cnt_comment + $cnt_document;
2698
2699
		$args = new stdClass();
2700
		$args->member_srl = $member_info->member_srl;
2701
		$args->email_address = $member_info->email_address;
2702
		$args->user_id = $member_info->user_id;
2703
		$args->nick_name = $member_info->nick_name;
2704
		$args->denied = "Y";
2705
		$args->description = trim( $member_info->description );
2706
		if( $args->description != "" ) $args->description .= "\n";	// add new line
2707
2708
		$args->description .= Context::getLang('cmd_spammer') . "[" . date("Y-m-d H:i:s") . " from:" . $logged_info->user_id . " info:" . $spam_description . " docuemnts count:" . $total_count . "]";
2709
2710
		$output = $this->updateMember($args, true);
2711
2712
		$this->_clearMemberCache($args->member_srl);
2713
2714
		return $output;
2715
	}
2716
2717
	/**
2718
	 * Delete or trash all documents
2719
	 *
2720
	 * @param int $member_srl
2721
	 * @param bool $isMoveToTrash
2722
	 *
2723
	 * @return object
2724
	**/
2725
	private function _spammerDocuments($member_srl, $isMoveToTrash) {
2726
		$oDocumentController = getController('document');
2727
		$oDocumentModel = getModel('document');
2728
		$oCommentController = getController('comment');
2729
		$oCommentModel = getModel('comment');
2730
2731
		// delete count by one request
2732
		$getContentsCount = 10;
2733
2734
		// 1. proc comment, 2. proc document
2735
		$cnt_comment = $oCommentModel->getCommentCountByMemberSrl($member_srl);
2736
		$cnt_document = $oDocumentModel->getDocumentCountByMemberSrl($member_srl);
2737
		if($cnt_comment > 0)
2738
		{
2739
			$columnList = array();
2740
			$commentList = $oCommentModel->getCommentListByMemberSrl($member_srl, $columnList, 0, false, $getContentsCount);
2741
			if($commentList) {
2742
				foreach($commentList as $v) {
2743
					$oCommentController->deleteComment($v->comment_srl, true, $isMoveToTrash);
2744
				}
2745
			}
2746
		} elseif($cnt_document > 0) {
2747
			$columnList = array();
2748
			$documentList = $oDocumentModel->getDocumentListByMemberSrl($member_srl, $columnList, 0, false, $getContentsCount);
2749
			if($documentList) {
2750
				foreach($documentList as $v) {
2751
					if($isMoveToTrash) $oDocumentController->moveDocumentToTrash($v);
2752
					else $oDocumentController->deleteDocument($v->document_srl);
2753
				}
2754
			}
2755
		}
2756
2757
		return array();
2758
	}
2759
2760
	function _clearMemberCache($member_srl, $site_srl = 0)
2761
	{
2762
		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
2763
		if($oCacheHandler->isSupport())
2764
		{
2765
			$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_' . $site_srl;
2766
			$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
2767
			$oCacheHandler->delete($cache_key);
2768
2769
			if($site_srl !== 0)
2770
			{
2771
				$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_0';
2772
				$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
2773
				$oCacheHandler->delete($cache_key);
2774
			}
2775
		}
2776
2777
		$oCacheHandler = CacheHandler::getInstance('object');
2778
		if($oCacheHandler->isSupport())
2779
		{
2780
			$object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
2781
			$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
2782
			$oCacheHandler->delete($cache_key);
2783
		}
2784
	}
2785
}
2786
/* End of file member.controller.php */
2787
/* Location: ./modules/member/member.controller.php */
2788