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 — master ( 423fe8...f48289 )
by gyeong-won
15:56 queued 08:14
created

memberController::updateFindAccountAnswer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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
		$oModuleModel = &getModel('module');
128
129
		// Check login information
130
		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
131
		$logged_info = Context::get('logged_info');
132
133
		$document_srl = (int)Context::get('document_srl');
134
		if(!$document_srl) $document_srl = (int)Context::get('target_srl');
135
		if(!$document_srl) return new Object(-1,'msg_invalid_request');
136
137
		// Get document
138
		$oDocumentModel = getModel('document');
139
		$oDocument = $oDocumentModel->getDocument($document_srl);
140
141
		if($oDocument->isSecret() && !$oDocument->isGranted())
142
		{
143
			return new Object(-1, 'msg_is_secret');
144
		}
145
146
		// 모듈 권한 확인
147
		$module_info = $oModuleModel->getModuleInfoByModuleSrl($oDocument->get('module_srl'));
148
		$grant = $oModuleModel->getGrant($module_info, $logged_info);
149
150
		if(!$grant->access)
151
		{
152
			return new Object(-1, 'msg_not_permitted');
153
		}
154
155
		// 게시판 모듈에서 글 목록 보기 권한이 없으면 스크랩 제한
156
		if($module_info->module === 'board' && isset($grant->list) && !$grant->list)
157
		{
158
			return new Object(-1, 'msg_not_permitted');
159
		}
160
161
		// 게시판 모듈에서 상담 기능 사용 시 권한이 없는 게시물(타인의 게시물) 스크랩 제한
162
		if($module_info->module === 'board' &&
163
			$module_info->consultation === 'Y' &&
164
			isset($grant->consultation_read) &&
165
			!$grant->consultation_read && !$oDocument->isGranted()
166
		)
167
		{
168
			return new Object(-1, 'msg_not_permitted');
169
		}
170
171
		// Variables
172
		$args = new stdClass();
173
		$args->document_srl = $document_srl;
174
		$args->member_srl = $logged_info->member_srl;
175
		$args->user_id = $oDocument->get('user_id');
176
		$args->user_name = $oDocument->get('user_name');
177
		$args->nick_name = $oDocument->get('nick_name');
178
		$args->target_member_srl = $oDocument->get('member_srl');
179
		$args->title = $oDocument->get('title');
180
181
		// Check if already scrapped
182
		$output = executeQuery('member.getScrapDocument', $args);
183
		if($output->data->count) return new Object(-1, 'msg_alreay_scrapped');
184
185
		// Insert
186
		$output = executeQuery('member.addScrapDocument', $args);
187
		if(!$output->toBool()) return $output;
188
189
		$this->setError(-1);
190
		$this->setMessage('success_registed');
191
	}
192
193
	/**
194
	 * Delete a scrap
195
	 *
196
	 * @return void|Object (void : success, Object : fail)
197
	 */
198
	function procMemberDeleteScrap()
199
	{
200
		// Check login information
201
		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
202
		$logged_info = Context::get('logged_info');
203
204
		$document_srl = (int)Context::get('document_srl');
205
		if(!$document_srl) return new Object(-1,'msg_invalid_request');
206
		// Variables
207
		$args = new stdClass;
208
		$args->member_srl = $logged_info->member_srl;
209
		$args->document_srl = $document_srl;
210
		return executeQuery('member.deleteScrapDocument', $args);
211
	}
212
213
	/**
214
	 * Save posts
215
	 * @deprecated - instead Document Controller - procDocumentTempSave method use
216
	 * @return Object
217
	 */
218
	function procMemberSaveDocument()
219
	{
220
		return new Object(0, 'Deprecated method');
221
	}
222
223
	/**
224
	 * Delete the post
225
	 *
226
	 * @return void|Object (void : success, Object : fail)
227
	 */
228
	function procMemberDeleteSavedDocument()
229
	{
230
		// Check login information
231
		if(!Context::get('is_logged')) return new Object(-1, 'msg_not_logged');
232
		$logged_info = Context::get('logged_info');
233
234
		$document_srl = (int)Context::get('document_srl');
235
		if(!$document_srl) return new Object(-1,'msg_invalid_request');
236
237
		$oDocumentModel = getModel('document');
238
		$oDocument = $oDocumentModel->getDocument($document_srl);
239
		if ($oDocument->get('member_srl') != $logged_info->member_srl)
240
		{
241
			return new Object(-1,'msg_invalid_request');
242
		}
243
244
		$configStatusList = $oDocumentModel->getStatusList();
245
		if ($oDocument->get('status') != $configStatusList['temp'])
246
		{
247
			return new Object(-1,'msg_invalid_request');
248
		}
249
250
		$oDocumentController = getController('document');
251
		$oDocumentController->deleteDocument($document_srl);
252
	}
253
254
	/**
255
	 * Check values when member joining
256
	 *
257
	 * @return void|Object (void : success, Object : fail)
258
	 */
259
	function procMemberCheckValue()
260
	{
261
		$name = Context::get('name');
262
		$value = Context::get('value');
263
		if(!$value) return;
264
265
		$oMemberModel = getModel('member');
266
		// Check if logged-in
267
		$logged_info = Context::get('logged_info');
268
269
270
		switch($name)
271
		{
272
			case 'user_id' :
273
				// Check denied ID
274
				if($oMemberModel->isDeniedID($value)) return new Object(0,'denied_user_id');
275
				// Check if duplicated
276
				$member_srl = $oMemberModel->getMemberSrlByUserID($value);
277
				if($member_srl && $logged_info->member_srl != $member_srl ) return new Object(0,'msg_exists_user_id');
278
				break;
279
			case 'nick_name' :
280
				// Check denied ID
281
				if($oMemberModel->isDeniedNickName($value))
282
				{
283
					return new Object(0,'denied_nick_name');
284
				}
285
				// Check if duplicated
286
				$member_srl = $oMemberModel->getMemberSrlByNickName($value);
287
				if($member_srl && $logged_info->member_srl != $member_srl ) return new Object(0,'msg_exists_nick_name');
288
289
				break;
290
			case 'email_address' :
291
				// Check if duplicated
292
				$member_srl = $oMemberModel->getMemberSrlByEmailAddress($value);
293
				if($member_srl && $logged_info->member_srl != $member_srl ) return new Object(0,'msg_exists_email_address');
294
				break;
295
		}
296
	}
297
298
	/**
299
	 * Join Membership
300
	 *
301
	 * @return void|Object (void : success, Object : fail)
302
	 */
303
	function procMemberInsert()
304
	{
305
		if (Context::getRequestMethod () == "GET") return new Object (-1, "msg_invalid_request");
306
		$oMemberModel = &getModel ('member');
307
		$config = $oMemberModel->getMemberConfig();
308
309
		// call a trigger (before)
310
		$trigger_output = ModuleHandler::triggerCall ('member.procMemberInsert', 'before', $config);
311
		if(!$trigger_output->toBool ()) return $trigger_output;
312
		// Check if an administrator allows a membership
313
		if($config->enable_join != 'Y') return $this->stop ('msg_signup_disabled');
314
		// Check if the user accept the license terms (only if terms exist)
315
		if($config->agreement && Context::get('accept_agreement')!='Y') return $this->stop('msg_accept_agreement');
316
317
		// Extract the necessary information in advance
318
		$getVars = array();
319 View Code Duplication
		if($config->signupForm)
320
		{
321
			foreach($config->signupForm as $formInfo)
322
			{
323
				if($formInfo->isDefaultForm && ($formInfo->isUse || $formInfo->required || $formInfo->mustRequired))
324
				{
325
					$getVars[] = $formInfo->name;
326
				}
327
			}
328
		}
329
330
		$args = new stdClass;
331
		foreach($getVars as $val)
332
		{
333
			$args->{$val} = Context::get($val);
334
			if($val == 'birthday') $args->birthday_ui = Context::get('birthday_ui');
335
		}
336
		$args->birthday = intval(strtr($args->birthday, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
337 View Code Duplication
		if(!$args->birthday && $args->birthday_ui) $args->birthday = intval(strtr($args->birthday_ui, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
338
339
		$args->find_account_answer = Context::get('find_account_answer');
340
		$args->allow_mailing = Context::get('allow_mailing');
341
		$args->allow_message = Context::get('allow_message');
342
343
		if($args->password1) $args->password = $args->password1;
344
345
		// check password strength
346 View Code Duplication
		if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
347
		{
348
			$message = Context::getLang('about_password_strength');
349
			return new Object(-1, $message[$config->password_strength]);
350
		}
351
352
		// Remove some unnecessary variables from all the vars
353
		$all_args = Context::getRequestVars();
354
		unset($all_args->module);
355
		unset($all_args->act);
356
		unset($all_args->is_admin);
357
		unset($all_args->member_srl);
358
		unset($all_args->description);
359
		unset($all_args->group_srl_list);
360
		unset($all_args->body);
361
		unset($all_args->accept_agreement);
362
		unset($all_args->signature);
363
		unset($all_args->password);
364
		unset($all_args->password2);
365
		unset($all_args->mid);
366
		unset($all_args->error_return_url);
367
		unset($all_args->ruleset);
368
		unset($all_args->captchaType);
369
		unset($all_args->secret_text);
370
371
		// Set the user state as "denied" when using mail authentication
372
		if($config->enable_confirm == 'Y') $args->denied = 'Y';
373
		// Add extra vars after excluding necessary information from all the requested arguments
374
		$extra_vars = delObjectVars($all_args, $args);
375
		$args->extra_vars = serialize($extra_vars);
376
377
		// remove whitespace
378
		$checkInfos = array('user_id', 'user_name', 'nick_name', 'email_address');
379 View Code Duplication
		foreach($checkInfos as $val)
380
		{
381
			if(isset($args->{$val}))
382
			{
383
				$args->{$val} = preg_replace('/[\pZ\pC]+/u', '', $args->{$val});
384
			}
385
		}
386
		$output = $this->insertMember($args);
387
		if(!$output->toBool()) return $output;
388
389
		// insert ProfileImage, ImageName, ImageMark
390
		$profile_image = $_FILES['profile_image'];
391
		if(is_uploaded_file($profile_image['tmp_name']))
392
		{
393
			$this->insertProfileImage($args->member_srl, $profile_image['tmp_name']);
394
		}
395
396
		$image_mark = $_FILES['image_mark'];
397
		if(is_uploaded_file($image_mark['tmp_name']))
398
		{
399
			$this->insertImageMark($args->member_srl, $image_mark['tmp_name']);
400
		}
401
402
		$image_name = $_FILES['image_name'];
403
		if(is_uploaded_file($image_name['tmp_name']))
404
		{
405
			$this->insertImageName($args->member_srl, $image_name['tmp_name']);
406
		}
407
408
		// If a virtual site, join the site
409
		$site_module_info = Context::get('site_module_info');
410
		if($site_module_info->site_srl > 0)
411
		{
412
			$columnList = array('site_srl', 'group_srl');
413
			$default_group = $oMemberModel->getDefaultGroup($site_module_info->site_srl, $columnList);
414
			if($default_group->group_srl)
415
			{
416
				$this->addMemberToGroup($args->member_srl, $default_group->group_srl, $site_module_info->site_srl);
417
			}
418
419
		}
420
		// Log-in
421
		if($config->enable_confirm != 'Y')
422
		{
423
			if($config->identifier == 'email_address')
424
			{
425
				$output = $this->doLogin($args->email_address);
426
			}
427
			else
428
			{
429
				$output = $this->doLogin($args->user_id);
430
			}
431
			if(!$output->toBool()) {
432
				if($output->error == -9)
433
					$output->error = -11;
434
				return $this->setRedirectUrl(getUrl('', 'act', 'dispMemberLoginForm'), $output);
435
			}
436
		}
437
438
		// Results
439
		$this->add('member_srl', $args->member_srl);
440
		if($config->redirect_url) $this->add('redirect_url', $config->redirect_url);
441
		if($config->enable_confirm == 'Y')
442
		{
443
			$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $args->email_address);
444
			$this->setMessage($msg);
445
			return $this->setRedirectUrl(getUrl('', 'act', 'dispMemberLoginForm'), new Object(-12, $msg));
446
		}
447
		else $this->setMessage('success_registed');
448
		// Call a trigger (after)
449
		$trigger_output = ModuleHandler::triggerCall('member.procMemberInsert', 'after', $config);
450
		if(!$trigger_output->toBool()) return $trigger_output;
451
452
		if($config->redirect_url)
453
		{
454
			$returnUrl = $config->redirect_url;
455
		}
456
		else
457
		{
458
			if(Context::get('success_return_url'))
459
			{
460
				$returnUrl = Context::get('success_return_url');
461
			}
462
			else if($_COOKIE['XE_REDIRECT_URL'])
463
			{
464
				$returnUrl = $_COOKIE['XE_REDIRECT_URL'];
465
				setcookie("XE_REDIRECT_URL", '', 1);
466
			}
467
		}
468
469
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
470
471
		$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...
472
	}
473
474
	function procMemberModifyInfoBefore()
475
	{
476
		if($_SESSION['rechecked_password_step'] != 'INPUT_PASSWORD')
477
		{
478
			return $this->stop('msg_invalid_request');
479
		}
480
481
		if(!Context::get('is_logged'))
482
		{
483
			return $this->stop('msg_not_logged');
484
		}
485
486
		$password = Context::get('password');
487
488
		if(!$password)
489
		{
490
			return $this->stop('msg_invalid_request');
491
		}
492
493
		$oMemberModel = getModel('member');
494
495
		if(!$this->memberInfo->password)
496
		{
497
			// Get information of logged-in user
498
			$logged_info = Context::get('logged_info');
499
			$member_srl = $logged_info->member_srl;
500
501
			$columnList = array('member_srl', 'password');
502
			$memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
503
			$this->memberInfo->password = $memberInfo->password;
504
		}
505
		// Verify the current password
506
		if(!$oMemberModel->isValidPassword($this->memberInfo->password, $password))
507
		{
508
			return new Object(-1, 'invalid_password');
509
		}
510
511
		$_SESSION['rechecked_password_step'] = 'VALIDATE_PASSWORD';
512
513
		if(Context::get('success_return_url'))
514
		{
515
			$redirectUrl = Context::get('success_return_url');
516
		}
517
		else
518
		{
519
			$redirectUrl = getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
520
		}
521
		$this->setRedirectUrl($redirectUrl);
522
	}
523
524
	/**
525
	 * Edit member profile
526
	 *
527
	 * @return void|Object (void : success, Object : fail)
528
	 */
529
	function procMemberModifyInfo()
530
	{
531
		if(!Context::get('is_logged'))
532
		{
533
			return $this->stop('msg_not_logged');
534
		}
535
536
		if($_SESSION['rechecked_password_step'] != 'INPUT_DATA')
537
		{
538
			return $this->stop('msg_invalid_request');
539
		}
540
		unset($_SESSION['rechecked_password_step']);
541
542
		// Extract the necessary information in advance
543
		$oMemberModel = getModel('member');
544
		$config = $oMemberModel->getMemberConfig ();
545
		$getVars = array('find_account_answer','allow_mailing','allow_message');
546 View Code Duplication
		if($config->signupForm)
547
		{
548
			foreach($config->signupForm as $formInfo)
549
			{
550
				if($formInfo->isDefaultForm && ($formInfo->isUse || $formInfo->required || $formInfo->mustRequired))
551
				{
552
					$getVars[] = $formInfo->name;
553
				}
554
			}
555
		}
556
557
		$args = new stdClass;
558
		foreach($getVars as $val)
559
		{
560
			$args->{$val} = Context::get($val);
561
			if($val == 'birthday') $args->birthday_ui = Context::get('birthday_ui');
562
			if($val == 'find_account_answer' && !Context::get($val)) {
563
				unset($args->{$val});
564
			}
565
		}
566
567
		// Login Information
568
		$logged_info = Context::get('logged_info');
569
		$args->member_srl = $logged_info->member_srl;
570
		$args->birthday = intval(strtr($args->birthday, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
571 View Code Duplication
		if(!$args->birthday && $args->birthday_ui) $args->birthday = intval(strtr($args->birthday_ui, array('-'=>'', '/'=>'', '.'=>'', ' '=>'')));
572
573
		// Remove some unnecessary variables from all the vars
574
		$all_args = Context::getRequestVars();
575
		unset($all_args->module);
576
		unset($all_args->act);
577
		unset($all_args->member_srl);
578
		unset($all_args->is_admin);
579
		unset($all_args->description);
580
		unset($all_args->group_srl_list);
581
		unset($all_args->body);
582
		unset($all_args->accept_agreement);
583
		unset($all_args->signature);
584
		unset($all_args->_filter);
585
		unset($all_args->mid);
586
		unset($all_args->error_return_url);
587
		unset($all_args->ruleset);
588
		unset($all_args->password);
589
590
		// Add extra vars after excluding necessary information from all the requested arguments
591
		$extra_vars = delObjectVars($all_args, $args);
592
		$args->extra_vars = serialize($extra_vars);
593
594
		// remove whitespace
595
		$checkInfos = array('user_id', 'user_name', 'nick_name', 'email_address');
596 View Code Duplication
		foreach($checkInfos as $val)
597
		{
598
			if(isset($args->{$val}))
599
			{
600
				$args->{$val} = preg_replace('/[\pZ\pC]+/u', '', $args->{$val});
601
			}
602
		}
603
604
		// Execute insert or update depending on the value of member_srl
605
		$output = $this->updateMember($args);
606
		if(!$output->toBool()) return $output;
607
608
		$profile_image = $_FILES['profile_image'];
609
		if(is_uploaded_file($profile_image['tmp_name']))
610
		{
611
			$this->insertProfileImage($args->member_srl, $profile_image['tmp_name']);
612
		}
613
614
		$image_mark = $_FILES['image_mark'];
615
		if(is_uploaded_file($image_mark['tmp_name']))
616
		{
617
			$this->insertImageMark($args->member_srl, $image_mark['tmp_name']);
618
		}
619
620
		$image_name = $_FILES['image_name'];
621
		if(is_uploaded_file($image_name['tmp_name']))
622
		{
623
			$this->insertImageName($args->member_srl, $image_name['tmp_name']);
624
		}
625
626
		// Save Signature
627
		$signature = Context::get('signature');
628
		$this->putSignature($args->member_srl, $signature);
629
630
		// Get user_id information
631
		$this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
632
633
634
		// Call a trigger after successfully log-in (after)
635
		$trigger_output = ModuleHandler::triggerCall('member.procMemberModifyInfo', 'after', $this->memberInfo);
636
		if(!$trigger_output->toBool()) return $trigger_output;
637
638
		$this->setSessionInfo();
639
		// Return result
640
		$this->add('member_srl', $args->member_srl);
641
		$this->setMessage('success_updated');
642
643
		$site_module_info = Context::get('site_module_info');
644
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
645
646
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberInfo');
647
		$this->setRedirectUrl($returnUrl);
648
	}
649
650
	/**
651
	 * Change the user password
652
	 *
653
	 * @return void|Object (void : success, Object : fail)
654
	 */
655
	function procMemberModifyPassword()
656
	{
657
		if(!Context::get('is_logged')) return $this->stop('msg_not_logged');
658
		// Extract the necessary information in advance
659
		$current_password = trim(Context::get('current_password'));
660
		$password = trim(Context::get('password1'));
661
		// Get information of logged-in user
662
		$logged_info = Context::get('logged_info');
663
		$member_srl = $logged_info->member_srl;
664
		// Create a member model object
665
		$oMemberModel = getModel('member');
666
		// Get information of member_srl
667
		$columnList = array('member_srl', 'password');
668
669
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
670
		// Verify the cuttent password
671
		if(!$oMemberModel->isValidPassword($member_info->password, $current_password, $member_srl)) return new Object(-1, 'invalid_password');
672
673
		// Check if a new password is as same as the previous password
674
		if($current_password == $password) return new Object(-1, 'invalid_new_password');
675
676
		// Execute insert or update depending on the value of member_srl
677
		$args = new stdClass;
678
		$args->member_srl = $member_srl;
679
		$args->password = $password;
680
		$output = $this->updateMemberPassword($args);
681
		if(!$output->toBool()) return $output;
682
683
		$this->add('member_srl', $args->member_srl);
684
		$this->setMessage('success_updated');
685
686
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberInfo');
687
		$this->setRedirectUrl($returnUrl);
688
	}
689
690
	/**
691
	 * Membership withdrawal
692
	 *
693
	 * @return void|Object (void : success, Object : fail)
694
	 */
695
	function procMemberLeave()
696
	{
697
		if(!Context::get('is_logged')) return $this->stop('msg_not_logged');
698
		// Extract the necessary information in advance
699
		$password = trim(Context::get('password'));
700
		// Get information of logged-in user
701
		$logged_info = Context::get('logged_info');
702
		$member_srl = $logged_info->member_srl;
703
		// Create a member model object
704
		$oMemberModel = getModel('member');
705
		// Get information of member_srl
706
		if(!$this->memberInfo->password)
707
		{
708
			$columnList = array('member_srl', 'password');
709
			$memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
710
			$this->memberInfo->password = $memberInfo->password;
711
		}
712
		// Verify the cuttent password
713
		if(!$oMemberModel->isValidPassword($this->memberInfo->password, $password)) return new Object(-1, 'invalid_password');
714
715
		$output = $this->deleteMember($member_srl);
716
		if(!$output->toBool()) return $output;
717
		// Destroy all session information
718
		$this->destroySessionInfo();
719
		// Return success message
720
		$this->setMessage('success_leaved');
721
722
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
723
		$this->setRedirectUrl($returnUrl);
724
	}
725
726
	/**
727
	 * Add a profile image
728
	 *
729
	 * @return void|Object (void : success, Object : fail)
730
	 */
731 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...
732
	{
733
		// Check if the file is successfully uploaded
734
		$file = $_FILES['profile_image'];
735
		if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_profile_image');
736
		// Ignore if member_srl is invalid or doesn't exist.
737
		$member_srl = Context::get('member_srl');
738
		if(!$member_srl) return $this->stop('msg_not_uploaded_profile_image');
739
740
		$logged_info = Context::get('logged_info');
741
		if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_profile_image');
742
		// Return if member module is set not to use an image name or the user is not an administrator ;
743
		$oModuleModel = getModel('module');
744
		$config = $oModuleModel->getModuleConfig('member');
745
		if($logged_info->is_admin != 'Y' && $config->profile_image != 'Y') return $this->stop('msg_not_uploaded_profile_image');
746
747
		$this->insertProfileImage($member_srl, $file['tmp_name']);
748
		// Page refresh
749
		//$this->setRefreshPage();
750
751
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
752
		$this->setRedirectUrl($returnUrl);
753
	}
754
755
	/**
756
	 * Insert a profile image
757
	 *
758
	 * @param int $member_srl
759
	 * @param object $target_file
760
	 *
761
	 * @return void
762
	 */
763
	function insertProfileImage($member_srl, $target_file)
764
	{
765
766
		// Check uploaded file
767
		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...
768
769
		$oMemberModel = getModel('member');
770
		$config = $oMemberModel->getMemberConfig();
771
772
		// Get an image size
773
		$max_width = $config->profile_image_max_width;
774
		if(!$max_width) $max_width = "90";
775
		$max_height = $config->profile_image_max_height;
776
		if(!$max_height) $max_height = "90";
777
		// Get a target path to save
778
		$target_path = sprintf('files/member_extra_info/profile_image/%s', getNumberingPath($member_srl));
779
		FileHandler::makeDir($target_path);
780
781
		// Get file information
782
		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...
783
		if(IMAGETYPE_PNG == $type) $ext = 'png';
784
		elseif(IMAGETYPE_JPEG == $type) $ext = 'jpg';
785
		elseif(IMAGETYPE_GIF == $type) $ext = 'gif';
786
		else
787
		{
788
			return;
789
		}
790
791
		FileHandler::removeFilesInDir($target_path);
792
793
		$target_filename = sprintf('%s%d.%s', $target_path, $member_srl, $ext);
794
		// Convert if the image size is larger than a given size or if the format is not a gif
795
		if(($width > $max_width || $height > $max_height ) && $type != 1)
796
		{
797
			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...
798
		}
799
		else
800
		{
801
			@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...
802
		}
803
	}
804
805
	/**
806
	 * Add an image name
807
	 *
808
	 * @return void|Object (void : success, Object : fail)
809
	 */
810 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...
811
	{
812
		// Check if the file is successfully uploaded
813
		$file = $_FILES['image_name'];
814
		if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_image_name');
815
		// Ignore if member_srl is invalid or doesn't exist.
816
		$member_srl = Context::get('member_srl');
817
		if(!$member_srl) return $this->stop('msg_not_uploaded_image_name');
818
819
		$logged_info = Context::get('logged_info');
820
		if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_image_name');
821
		// Return if member module is set not to use an image name or the user is not an administrator ;
822
		$oModuleModel = getModel('module');
823
		$config = $oModuleModel->getModuleConfig('member');
824
		if($logged_info->is_admin != 'Y' && $config->image_name != 'Y') return $this->stop('msg_not_uploaded_image_name');
825
826
		$this->insertImageName($member_srl, $file['tmp_name']);
827
		// Page refresh
828
		//$this->setRefreshPage();
829
830
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
831
		$this->setRedirectUrl($returnUrl);
832
	}
833
834
	/**
835
	 * Insert a image name
836
	 *
837
	 * @param int $member_srl
838
	 * @param object $target_file
839
	 *
840
	 * @return void
841
	 */
842 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...
843
	{
844
		// Check uploaded file
845
		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...
846
847
		$oModuleModel = getModel('module');
848
		$config = $oModuleModel->getModuleConfig('member');
849
		// Get an image size
850
		$max_width = $config->image_name_max_width;
851
		if(!$max_width) $max_width = "90";
852
		$max_height = $config->image_name_max_height;
853
		if(!$max_height) $max_height = "20";
854
		// Get a target path to save
855
		$target_path = sprintf('files/member_extra_info/image_name/%s/', getNumberingPath($member_srl));
856
		FileHandler::makeDir($target_path);
857
858
		$target_filename = sprintf('%s%d.gif', $target_path, $member_srl);
859
		// Get file information
860
		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...
861
		// Convert if the image size is larger than a given size or if the format is not a gif
862
		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...
863
		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...
864
	}
865
866
	/**
867
	 * Delete profile image
868
	 *
869
	 * @return Object
870
	 */
871 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...
872
	{
873
		$member_srl = ($_memberSrl) ? $_memberSrl : Context::get('member_srl');
874
		if(!$member_srl)
875
		{
876
			return new Object(0,'success');
877
		}
878
879
		$logged_info = Context::get('logged_info');
880
881
		if($logged_info && ($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl))
882
		{
883
			$oMemberModel = getModel('member');
884
			$profile_image = $oMemberModel->getProfileImage($member_srl);
885
			FileHandler::removeFile($profile_image->file);
886
		}
887
		return new Object(0,'success');
888
	}
889
890
	/**
891
	 * Delete Image name
892
	 *
893
	 * @return void
894
	 */
895 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...
896
	{
897
		$member_srl = ($_memberSrl) ? $_memberSrl : Context::get('member_srl');
898
		if(!$member_srl)
899
		{
900
			return new Object(0,'success');
901
		}
902
903
		$logged_info = Context::get('logged_info');
904
905
		if($logged_info && ($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl))
906
		{
907
			$oMemberModel = getModel('member');
908
			$image_name = $oMemberModel->getImageName($member_srl);
909
			FileHandler::removeFile($image_name->file);
910
		}
911
		return new Object(0,'success');
912
	}
913
914
	/**
915
	 * Add an image to mark
916
	 *
917
	 * @return void|Object (void : success, Object : fail)
918
	 */
919 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...
920
	{
921
		// Check if the file is successfully uploaded
922
		$file = $_FILES['image_mark'];
923
		if(!is_uploaded_file($file['tmp_name'])) return $this->stop('msg_not_uploaded_image_mark');
924
		// Ignore if member_srl is invalid or doesn't exist.
925
		$member_srl = Context::get('member_srl');
926
		if(!$member_srl) return $this->stop('msg_not_uploaded_image_mark');
927
928
		$logged_info = Context::get('logged_info');
929
		if($logged_info->is_admin != 'Y' && $logged_info->member_srl != $member_srl) return $this->stop('msg_not_uploaded_image_mark');
930
		// Membership in the images mark the module using the ban was set by an administrator or return;
931
		$oModuleModel = getModel('module');
932
		$config = $oModuleModel->getModuleConfig('member');
933
		if($logged_info->is_admin != 'Y' && $config->image_mark != 'Y') return $this->stop('msg_not_uploaded_image_mark');
934
935
		$this->insertImageMark($member_srl, $file['tmp_name']);
936
		// Page refresh
937
		//$this->setRefreshPage();
938
939
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberModifyInfo');
940
		$this->setRedirectUrl($returnUrl);
941
	}
942
943
	/**
944
	 * Insert a image mark
945
	 *
946
	 * @param int $member_srl
947
	 * @param object $target_file
948
	 *
949
	 * @return void
950
	 */
951 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...
952
	{
953
		// Check uploaded file
954
		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...
955
956
		$oModuleModel = getModel('module');
957
		$config = $oModuleModel->getModuleConfig('member');
958
		// Get an image size
959
		$max_width = $config->image_mark_max_width;
960
		if(!$max_width) $max_width = "20";
961
		$max_height = $config->image_mark_max_height;
962
		if(!$max_height) $max_height = "20";
963
964
		$target_path = sprintf('files/member_extra_info/image_mark/%s/', getNumberingPath($member_srl));
965
		FileHandler::makeDir($target_path);
966
967
		$target_filename = sprintf('%s%d.gif', $target_path, $member_srl);
968
		// Get file information
969
		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...
970
971
		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...
972
		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...
973
	}
974
975
	/**
976
	 * Delete Image Mark
977
	 *
978
	 * @return Object
979
	 */
980 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...
981
	{
982
		$member_srl = ($_memberSrl) ? $_memberSrl : Context::get('member_srl');
983
		if(!$member_srl)
984
		{
985
			return new Object(0,'success');
986
		}
987
988
		$logged_info = Context::get('logged_info');
989
990
		if($logged_info && ($logged_info->is_admin == 'Y' || $logged_info->member_srl == $member_srl))
991
		{
992
			$oMemberModel = getModel('member');
993
			$image_mark = $oMemberModel->getImageMark($member_srl);
994
			FileHandler::removeFile($image_mark->file);
995
		}
996
		return new Object(0,'success');
997
	}
998
999
	/**
1000
	 * Find ID/Password
1001
	 *
1002
	 * @return Object
1003
	 */
1004
	function procMemberFindAccount()
1005
	{
1006
		$email_address = Context::get('email_address');
1007
		if(!$email_address) return new Object(-1, 'msg_invalid_request');
1008
1009
		$oMemberModel = getModel('member');
1010
		$oModuleModel = getModel('module');
1011
1012
		// Check if a member having the same email address exists
1013
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
1014
		if(!$member_srl) return new Object(-1, 'msg_email_not_exists');
1015
1016
		// Get information of the member
1017
		$columnList = array('denied', 'member_srl', 'user_id', 'user_name', 'email_address', 'nick_name');
1018
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
1019
1020
		// Check if possible to find member's ID and password
1021
		if($member_info->denied == 'Y')
1022
		{
1023
			$chk_args = new stdClass;
1024
			$chk_args->member_srl = $member_info->member_srl;
1025
			$output = executeQuery('member.chkAuthMail', $chk_args);
1026
			if($output->toBool() && $output->data->count != '0') return new Object(-1, 'msg_user_not_confirmed');
1027
		}
1028
1029
		// Insert data into the authentication DB
1030
		$oPassword = new Password();
1031
		$args = new stdClass();
1032
		$args->user_id = $member_info->user_id;
1033
		$args->member_srl = $member_info->member_srl;
1034
		$args->new_password = $oPassword->createTemporaryPassword(8);
1035
		$args->auth_key = $oPassword->createSecureSalt(40);
1036
		$args->is_register = 'N';
1037
1038
		$output = executeQuery('member.insertAuthMail', $args);
1039
		if(!$output->toBool()) return $output;
1040
		// Get content of the email to send a member
1041
		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...
1042
1043
		$member_config = $oModuleModel->getModuleConfig('member');
1044
		$memberInfo = array();
1045
		global $lang;
1046 View Code Duplication
		if(is_array($member_config->signupForm))
1047
		{
1048
			$exceptForm=array('password', 'find_account_question');
1049
			foreach($member_config->signupForm as $form)
1050
			{
1051
				if(!in_array($form->name, $exceptForm) && $form->isDefaultForm && ($form->required || $form->mustRequired))
1052
				{
1053
					$memberInfo[$lang->{$form->name}] = $member_info->{$form->name};
1054
				}
1055
			}
1056
		}
1057
		else
1058
		{
1059
			$memberInfo[$lang->user_id] = $args->user_id;
1060
			$memberInfo[$lang->user_name] = $args->user_name;
1061
			$memberInfo[$lang->nick_name] = $args->nick_name;
1062
			$memberInfo[$lang->email_address] = $args->email_address;
1063
		}
1064
		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...
1065
1066
		if(!$member_config->skin) $member_config->skin = "default";
1067
		if(!$member_config->colorset) $member_config->colorset = "white";
1068
1069
		Context::set('member_config', $member_config);
1070
1071
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
1072
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
1073
1074
		$find_url = getFullUrl ('', 'module', 'member', 'act', 'procMemberAuthAccount', 'member_srl', $member_info->member_srl, 'auth_key', $args->auth_key);
1075
		Context::set('find_url', $find_url);
1076
1077
		$oTemplate = &TemplateHandler::getInstance();
1078
		$content = $oTemplate->compile($tpl_path, 'find_member_account_mail');
1079
		// Get information of the Webmaster
1080
		$oModuleModel = getModel('module');
1081
		$member_config = $oModuleModel->getModuleConfig('member');
1082
		// Send a mail
1083
		$oMail = new Mail();
1084
		$oMail->setTitle( Context::getLang('msg_find_account_title') );
1085
		$oMail->setContent($content);
1086
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
1087
		$oMail->setReceiptor( $member_info->user_name, $member_info->email_address );
1088
		$oMail->send();
1089
		// Return message
1090
		$msg = sprintf(Context::getLang('msg_auth_mail_sent'), $member_info->email_address);
1091 View Code Duplication
		if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON')))
1092
		{
1093
			$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', 'dispMemberFindAccount');
1094
			$this->setRedirectUrl($returnUrl);
1095
		}
1096
		return new Object(0,$msg);
1097
	}
1098
1099
	/**
1100
	 * Generate a temp password by answering to the pre-determined question
1101
	 *
1102
	 * @return void|Object (void : success, Object : fail)
1103
	 */
1104
	function procMemberFindAccountByQuestion()
1105
	{
1106
		$oMemberModel = getModel('member');
1107
		$oPassword =  new Password();
1108
		$config = $oMemberModel->getMemberConfig();
1109
1110
		$email_address = Context::get('email_address');
1111
		$user_id = Context::get('user_id');
1112
		$find_account_question = trim(Context::get('find_account_question'));
1113
		$find_account_answer = trim(Context::get('find_account_answer'));
1114
1115
		if(($config->identifier == 'user_id' && !$user_id) || !$email_address || !$find_account_question || !$find_account_answer) return new Object(-1, 'msg_invalid_request');
1116
1117
		$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...
1118
		// Check if a member having the same email address exists
1119
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
1120
		if(!$member_srl) return new Object(-1, 'msg_email_not_exists');
1121
1122
		// Get information of the member
1123
		$columnList = array('member_srl', 'find_account_question', 'find_account_answer');
1124
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
1125
1126
		// Display a message if no answer is entered
1127
		if(!$member_info->find_account_question || !$member_info->find_account_answer) return new Object(-1, 'msg_question_not_exists');
1128
1129
		// 답변 확인
1130
		$hashed = $oPassword->checkAlgorithm($member_info->find_account_answer);
1131
		$authed = true;
1132
		$member_info->find_account_question = trim($member_info->find_account_question);
1133
		if($member_info->find_account_question != $find_account_question)
1134
		{
1135
			$authed = false;
1136
		}
1137
		else if($hashed && !$oPassword->checkPassword($find_account_answer, $member_info->find_account_answer))
0 ignored issues
show
Bug Best Practice introduced by
The expression $hashed of type string|false is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false 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...
1138
		{
1139
			$authed = false;
1140
		}
1141
		else if(!$hashed && $find_account_answer != $member_info->find_account_answer)
0 ignored issues
show
Bug Best Practice introduced by
The expression $hashed of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false 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...
1142
		{
1143
			$authed = false;
1144
		}
1145
1146
		if(!$authed)
1147
		{
1148
			return new Object(-1, 'msg_answer_not_matches');
1149
		}
1150
1151
		// answer가 동일하고 hash 되지 않았으면 hash 값으로 저장
1152
		if($authed && !$hashed)
0 ignored issues
show
Bug Best Practice introduced by
The expression $hashed of type string|false is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === false 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...
1153
		{
1154
			$this->updateFindAccountAnswer($member_srl, $find_account_answer);
1155
		}
1156
1157
		if($config->identifier == 'email_address')
1158
		{
1159
			$user_id = $email_address;
1160
		}
1161
1162
		// Update to a temporary password and set change_password_date to 1
1163
		$temp_password = $oPassword->createTemporaryPassword(8);
1164
1165
		$args = new stdClass();
1166
		$args->member_srl = $member_srl;
1167
		$args->password = $temp_password;
1168
		$args->change_password_date = '1';
1169
		$output = $this->updateMemberPassword($args);
1170
		if(!$output->toBool()) return $output;
1171
1172
		$_SESSION['xe_temp_password_' . $user_id] = $temp_password;
1173
1174
		$this->add('user_id',$user_id);
1175
1176
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
1177
		$this->setRedirectUrl($returnUrl.'&user_id='.$user_id);
1178
	}
1179
1180
	/**
1181
	 * Execute finding ID/Passoword
1182
	 * When clicking the link in the verification email, a method is called to change the old password and to authenticate it
1183
	 *
1184
	 * @return void|Object (void : success, Object : fail)
1185
	 */
1186
	function procMemberAuthAccount()
1187
	{
1188
		$oMemberModel = getModel('member');
1189
1190
		// Test user_id and authkey
1191
		$member_srl = Context::get('member_srl');
1192
		$auth_key = Context::get('auth_key');
1193
1194
		if(!$member_srl || !$auth_key)
1195
		{
1196
			return $this->stop('msg_invalid_request');
1197
		}
1198
1199
		// Test logs for finding password by user_id and authkey
1200
		$args = new stdClass;
1201
		$args->member_srl = $member_srl;
1202
		$args->auth_key = $auth_key;
1203
		$output = executeQuery('member.getAuthMail', $args);
1204
1205 View Code Duplication
		if(!$output->toBool() || $output->data->auth_key != $auth_key)
1206
		{
1207
			if(strlen($output->data->auth_key) !== strlen($auth_key))
1208
			{
1209
				executeQuery('member.deleteAuthMail', $args);
1210
			}
1211
1212
			return $this->stop('msg_invalid_auth_key');
1213
		}
1214
1215
		if(ztime($output->data->regdate) < $_SERVER['REQUEST_TIME'] + zgap() - 86400)
1216
		{
1217
			executeQuery('member.deleteAuthMail', $args);
1218
			return $this->stop('msg_invalid_auth_key');
1219
		}
1220
1221
		$args->password = $output->data->new_password;
1222
1223
		// If credentials are correct, change the password to a new one
1224
		if($output->data->is_register == 'Y')
1225
		{
1226
			$args->denied = 'N';
1227
		}
1228
		else
1229
		{
1230
			$args->password = $oMemberModel->hashPassword($args->password);
1231
		}
1232
1233
		// Back up the value of $Output->data->is_register
1234
		$is_register = $output->data->is_register;
1235
1236
		$output = executeQuery('member.updateMemberPassword', $args);
1237
		if(!$output->toBool())
1238
		{
1239
			return $this->stop($output->getMessage());
1240
		}
1241
1242
		// Remove all values having the member_srl from authentication table
1243
		executeQuery('member.deleteAuthMail',$args);
1244
1245
		$this->_clearMemberCache($args->member_srl);
1246
1247
		// Notify the result
1248
		Context::set('is_register', $is_register);
1249
		$this->setTemplatePath($this->module_path.'tpl');
1250
		$this->setTemplateFile('msg_success_authed');
1251
	}
1252
1253
	/**
1254
	 * Request to re-send the authentication mail
1255
	 *
1256
	 * @return void|Object (void : success, Object : fail)
1257
	 */
1258
	function procMemberResendAuthMail()
1259
	{
1260
		// Get an email_address
1261
		$email_address = Context::get('email_address');
1262
		if(!$email_address) return new Object(-1, 'msg_invalid_request');
1263
		// Log test by using email_address
1264
		$oMemberModel = getModel('member');
1265
1266
		$args = new stdClass;
1267
		$args->email_address = $email_address;
1268
		$memberSrl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
1269
		if(!$memberSrl) return new Object(-1, 'msg_not_exists_member');
1270
1271
		$columnList = array('member_srl', 'user_id', 'user_name', 'nick_name', 'email_address');
1272
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($memberSrl, 0, $columnList);
1273
1274
		$oModuleModel = getModel('module');
1275
		$member_config = $oModuleModel->getModuleConfig('member');
1276
		if(!$member_config->skin) $member_config->skin = "default";
1277
		if(!$member_config->colorset) $member_config->colorset = "white";
1278
1279
		// Check if a authentication mail has been sent previously
1280
		$chk_args = new stdClass;
1281
		$chk_args->member_srl = $member_info->member_srl;
1282
		$output = executeQuery('member.chkAuthMail', $chk_args);
1283
		if($output->toBool() && $output->data->count == '0') return new Object(-1, 'msg_invalid_request');
1284
1285
		$auth_args = new stdClass;
1286
		$auth_args->member_srl = $member_info->member_srl;
1287
		$output = executeQueryArray('member.getAuthMailInfo', $auth_args);
1288
		if(!$output->data || !$output->data[0]->auth_key)  return new Object(-1, 'msg_invalid_request');
1289
		$auth_info = $output->data[0];
1290
1291
		// Update the regdate of authmail entry
1292
		$renewal_args = new stdClass;
1293
		$renewal_args->member_srl = $member_info->member_srl;
1294
		$renewal_args->auth_key = $auth_info->auth_key;
1295
		$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...
1296
1297
		$memberInfo = array();
1298
		global $lang;
1299 View Code Duplication
		if(is_array($member_config->signupForm))
1300
		{
1301
			$exceptForm=array('password', 'find_account_question');
1302
			foreach($member_config->signupForm as $form)
1303
			{
1304
				if(!in_array($form->name, $exceptForm) && $form->isDefaultForm && ($form->required || $form->mustRequired))
1305
				{
1306
					$memberInfo[$lang->{$form->name}] = $member_info->{$form->name};
1307
				}
1308
			}
1309
		}
1310
		else
1311
		{
1312
			$memberInfo[$lang->user_id] = $member_info->user_id;
1313
			$memberInfo[$lang->user_name] = $member_info->user_name;
1314
			$memberInfo[$lang->nick_name] = $member_info->nick_name;
1315
			$memberInfo[$lang->email_address] = $member_info->email_address;
1316
		}
1317
1318
		// Get content of the email to send a member
1319
		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...
1320
		Context::set('member_config', $member_config);
1321
1322
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
1323
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
1324
1325
		$auth_url = getFullUrl('','module','member','act','procMemberAuthAccount','member_srl',$member_info->member_srl, 'auth_key',$auth_info->auth_key);
1326
		Context::set('auth_url', $auth_url);
1327
1328
		$oTemplate = &TemplateHandler::getInstance();
1329
		$content = $oTemplate->compile($tpl_path, 'confirm_member_account_mail');
1330
		// Send a mail
1331
		$oMail = new Mail();
1332
		$oMail->setTitle( Context::getLang('msg_confirm_account_title') );
1333
		$oMail->setContent($content);
1334
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
1335
		$oMail->setReceiptor( $args->user_name, $args->email_address );
1336
		$oMail->send();
1337
1338
		$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $args->email_address);
1339
		$this->setMessage($msg);
1340
1341
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
1342
		$this->setRedirectUrl($returnUrl);
1343
	}
1344
1345
	function procMemberResetAuthMail()
1346
	{
1347
		$memberInfo = $_SESSION['auth_member_info'];
1348
		unset($_SESSION['auth_member_info']);
1349
1350
		if(!$memberInfo)
1351
		{
1352
			return $this->stop('msg_invalid_request');
1353
		}
1354
1355
		$newEmail = Context::get('email_address');
1356
1357
		if(!$newEmail)
1358
		{
1359
			return $this->stop('msg_invalid_request');
1360
		}
1361
1362
		$oMemberModel = getModel('member');
1363
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($newEmail);
1364
		if($member_srl)
1365
		{
1366
			return new Object(-1,'msg_exists_email_address');
1367
		}
1368
1369
		// remove all key by member_srl
1370
		$args = new stdClass;
1371
		$args->member_srl = $memberInfo->member_srl;
1372
		$output = executeQuery('member.deleteAuthMail', $args);
1373
1374
		if(!$output->toBool())
1375
		{
1376
			return $output;
1377
		}
1378
1379
		// update member info
1380
		$args->email_address = $newEmail;
1381
		list($args->email_id, $args->email_host) = explode('@', $newEmail);
1382
1383
		$output = executeQuery('member.updateMemberEmailAddress', $args);
1384
		if(!$output->toBool())
1385
		{
1386
			return $this->stop($output->getMessage());
1387
		}
1388
1389
		$this->_clearMemberCache($args->member_srl);
1390
1391
		// generate new auth key
1392
		$oPassword = new Password();
1393
		$auth_args = new stdClass();
1394
		$auth_args->user_id = $memberInfo->user_id;
1395
		$auth_args->member_srl = $memberInfo->member_srl;
1396
		$auth_args->new_password = $memberInfo->password;
1397
		$auth_args->auth_key = $oPassword->createSecureSalt(40);
1398
		$auth_args->is_register = 'Y';
1399
1400
		$output = executeQuery('member.insertAuthMail', $auth_args);
1401
		if(!$output->toBool()) return $output;
1402
1403
		$memberInfo->email_address = $newEmail;
1404
1405
		// resend auth mail.
1406
		$this->_sendAuthMail($auth_args, $memberInfo);
1407
1408
		$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $memberInfo->email_address);
1409
		$this->setMessage($msg);
1410
1411
		$returnUrl = getUrl('');
1412
		$this->setRedirectUrl($returnUrl);
1413
	}
1414
1415
	function _sendAuthMail($auth_args, $member_info)
1416
	{
1417
		$oMemberModel = getModel('member');
1418
		$member_config = $oMemberModel->getMemberConfig();
1419
		// Get content of the email to send a member
1420
		Context::set('auth_args', $auth_args);
1421
1422
		$memberInfo = array();
1423
1424
		global $lang;
1425 View Code Duplication
		if(is_array($member_config->signupForm))
1426
		{
1427
			$exceptForm=array('password', 'find_account_question');
1428
			foreach($member_config->signupForm as $form)
1429
			{
1430
				if(!in_array($form->name, $exceptForm) && $form->isDefaultForm && ($form->required || $form->mustRequired))
1431
				{
1432
					$memberInfo[$lang->{$form->name}] = $member_info->{$form->name};
1433
				}
1434
			}
1435
		}
1436
		else
1437
		{
1438
			$memberInfo[$lang->user_id] = $member_info->user_id;
1439
			$memberInfo[$lang->user_name] = $member_info->user_name;
1440
			$memberInfo[$lang->nick_name] = $member_info->nick_name;
1441
			$memberInfo[$lang->email_address] = $member_info->email_address;
1442
		}
1443
		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...
1444
1445
		if(!$member_config->skin) $member_config->skin = "default";
1446
		if(!$member_config->colorset) $member_config->colorset = "white";
1447
1448
		Context::set('member_config', $member_config);
1449
1450
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
1451
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
1452
1453
		$auth_url = getFullUrl('','module','member','act','procMemberAuthAccount','member_srl',$member_info->member_srl, 'auth_key',$auth_args->auth_key);
1454
		Context::set('auth_url', $auth_url);
1455
1456
		$oTemplate = &TemplateHandler::getInstance();
1457
		$content = $oTemplate->compile($tpl_path, 'confirm_member_account_mail');
1458
		// Send a mail
1459
		$oMail = new Mail();
1460
		$oMail->setTitle( Context::getLang('msg_confirm_account_title') );
1461
		$oMail->setContent($content);
1462
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
1463
		$oMail->setReceiptor( $member_info->user_name, $member_info->email_address );
1464
		$oMail->send();
1465
	}
1466
1467
	/**
1468
	 * Join a virtual site
1469
	 *
1470
	 * @return void|Object (void : success, Object : fail)
1471
	 */
1472
	function procMemberSiteSignUp()
1473
	{
1474
		$site_module_info = Context::get('site_module_info');
1475
		$logged_info = Context::get('logged_info');
1476 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');
1477
1478
		$oMemberModel = getModel('member');
1479
		$columnList = array('site_srl', 'group_srl', 'title');
1480
		$default_group = $oMemberModel->getDefaultGroup($site_module_info->site_srl, $columnList);
1481
		$this->addMemberToGroup($logged_info->member_srl, $default_group->group_srl, $site_module_info->site_srl);
1482
		$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...
1483
		$logged_info->group_list = $groups;
1484
	}
1485
1486
	/**
1487
	 * Leave the virtual site
1488
	 *
1489
	 * @return void|Object (void : success, Object : fail)
1490
	 */
1491
	function procMemberSiteLeave()
1492
	{
1493
		$site_module_info = Context::get('site_module_info');
1494
		$logged_info = Context::get('logged_info');
1495 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');
1496
1497
		$args = new stdClass;
1498
		$args->site_srl= $site_module_info->site_srl;
1499
		$args->member_srl = $logged_info->member_srl;
1500
		$output = executeQuery('member.deleteMembersGroup', $args);
1501
		if(!$output->toBool()) return $output;
1502
		$this->setMessage('success_deleted');
1503
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
1504
	}
1505
1506
	/**
1507
	 * Save the member configurations
1508
	 *
1509
	 * @param object $args
1510
	 *
1511
	 * @return void
1512
	 */
1513
	function setMemberConfig($args)
1514
	{
1515
		if(!$args->skin) $args->skin = "default";
1516
		if(!$args->colorset) $args->colorset = "white";
1517
		if(!$args->editor_skin) $args->editor_skin= "ckeditor";
1518
		if(!$args->editor_colorset) $args->editor_colorset = "moono";
1519
		if($args->enable_join!='Y') $args->enable_join = 'N';
1520
		$args->enable_openid= 'N';
1521
		if($args->profile_image !='Y') $args->profile_image = 'N';
1522
		if($args->image_name!='Y') $args->image_name = 'N';
1523
		if($args->image_mark!='Y') $args->image_mark = 'N';
1524
		if($args->group_image_mark!='Y') $args->group_image_mark = 'N';
1525
		if(!trim(strip_tags($args->agreement))) $args->agreement = null;
1526
		$args->limit_day = (int)$args->limit_day;
1527
1528
		$agreement = trim($args->agreement);
1529
		unset($args->agreement);
1530
1531
		$oModuleController = getController('module');
1532
		$output = $oModuleController->insertModuleConfig('member',$args);
1533
		if(!$output->toBool()) return $output;
1534
1535
		$agreement_file = _XE_PATH_.'files/member_extra_info/agreement.txt';
1536
		FileHandler::writeFile($agreement_file, $agreement);
1537
1538
		return new Object();
1539
	}
1540
1541
	/**
1542
	 * Save the signature as a file
1543
	 *
1544
	 * @param int $member_srl
1545
	 * @param string $signature
1546
	 *
1547
	 * @return void
1548
	 */
1549
	function putSignature($member_srl, $signature)
1550
	{
1551
		$signature = trim(removeHackTag($signature));
1552
		$signature = preg_replace('/<(\/?)(embed|object|param)/is', '&lt;$1$2', $signature);
1553
1554
		$check_signature = trim(str_replace(array('&nbsp;',"\n","\r"), '', strip_tags($signature, '<img><object>')));
1555
		$path = sprintf('files/member_extra_info/signature/%s/', getNumberingPath($member_srl));
1556
		$filename = sprintf('%s%d.signature.php', $path, $member_srl);
1557
1558
		if(!$check_signature) return FileHandler::removeFile($filename);
1559
1560
		$buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature);
1561
		FileHandler::makeDir($path);
1562
		FileHandler::writeFile($filename, $buff);
1563
	}
1564
1565
	/**
1566
	 * Delete the signature file
1567
	 *
1568
	 * @param string $member_srl
1569
	 *
1570
	 * @return void
1571
	 */
1572
	function delSignature($member_srl)
1573
	{
1574
		$filename = sprintf('files/member_extra_info/signature/%s%d.gif', getNumberingPath($member_srl), $member_srl);
1575
		FileHandler::removeFile($filename);
1576
	}
1577
1578
	/**
1579
	 * Add group_srl to member_srl
1580
	 *
1581
	 * @param int $member_srl
1582
	 * @param int $group_srl
1583
	 * @param int $site_srl
1584
	 *
1585
	 * @return Object
1586
	 */
1587
	function addMemberToGroup($member_srl, $group_srl, $site_srl=0)
1588
	{
1589
		$args = new stdClass();
1590
		$args->member_srl = $member_srl;
1591
		$args->group_srl = $group_srl;
1592
		if($site_srl) $args->site_srl = $site_srl;
1593
1594
		// Add
1595
		$output = executeQuery('member.addMemberToGroup',$args);
1596
		$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...
1597
1598
		$this->_clearMemberCache($member_srl, $site_srl);
1599
1600
		return $output;
1601
	}
1602
1603
	/**
1604
	 * Change a group of certain members
1605
	 * Available only when a member has a single group
1606
	 *
1607
	 * @param object $args
1608
	 *
1609
	 * @return Object
1610
	 */
1611
	function replaceMemberGroup($args)
1612
	{
1613
		$obj = new stdClass;
1614
		$obj->site_srl = $args->site_srl;
1615
		$obj->member_srl = implode(',',$args->member_srl);
1616
1617
		$output = executeQueryArray('member.getMembersGroup', $obj);
1618
		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...
1619
1620
		$output = executeQuery('member.deleteMembersGroup', $obj);
1621
		if(!$output->toBool()) return $output;
1622
1623
		$inserted_members = array();
1624
		foreach($args->member_srl as $key => $val)
1625
		{
1626
			if($inserted_members[$val]) continue;
1627
			$inserted_members[$val] = true;
1628
1629
			unset($obj);
1630
			$obj = new stdClass;
1631
			$obj->member_srl = $val;
1632
			$obj->group_srl = $args->group_srl;
1633
			$obj->site_srl = $args->site_srl;
1634
			$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...
1635
			$output = executeQuery('member.addMemberToGroup', $obj);
1636
			if(!$output->toBool()) return $output;
1637
1638
			$this->_clearMemberCache($obj->member_srl, $args->site_srl);
1639
		}
1640
1641
		return new Object();
1642
	}
1643
1644
1645
	/**
1646
	 * Auto-login
1647
	 *
1648
	 * @return void
1649
	 */
1650
	function doAutologin()
1651
	{
1652
		// Get a key value of auto log-in
1653
		$args = new stdClass;
1654
		$args->autologin_key = $_COOKIE['xeak'];
1655
		// Get information of the key
1656
		$output = executeQuery('member.getAutologin', $args);
1657
		// If no information exists, delete a cookie
1658 View Code Duplication
		if(!$output->toBool() || !$output->data)
1659
		{
1660
			setCookie('xeak',null,$_SERVER['REQUEST_TIME']+60*60*24*365);
1661
			return;
1662
		}
1663
1664
		$oMemberModel = getModel('member');
1665
		$config = $oMemberModel->getMemberConfig();
1666
1667
		$user_id = ($config->identifier == 'user_id') ? $output->data->user_id : $output->data->email_address;
1668
		$password = $output->data->password;
1669
1670 View Code Duplication
		if(!$user_id || !$password)
1671
		{
1672
			setCookie('xeak',null,$_SERVER['REQUEST_TIME']+60*60*24*365);
1673
			return;
1674
		}
1675
1676
		$do_auto_login = false;
1677
1678
		// Compare key values based on the information
1679
		$check_key = strtolower($user_id).$password.$_SERVER['HTTP_USER_AGENT'];
1680
		$check_key = substr(hash_hmac('sha256', $check_key, substr($args->autologin_key, 0, 32)), 0, 32);
1681
1682
		if($check_key === substr($args->autologin_key, 32))
1683
		{
1684
			// Check change_password_date
1685
			$oModuleModel = getModel('module');
1686
			$member_config = $oModuleModel->getModuleConfig('member');
1687
			$limit_date = $member_config->change_password_date;
1688
1689
			// Check if change_password_date is set
1690
			if($limit_date > 0)
1691
			{
1692
				$oMemberModel = getModel('member');
1693
				$columnList = array('member_srl', 'change_password_date');
1694
1695
				if($config->identifier == 'user_id')
1696
				{
1697
					$member_info = $oMemberModel->getMemberInfoByUserID($user_id, $columnList);
1698
				}
1699
				else
1700
				{
1701
					$member_info = $oMemberModel->getMemberInfoByEmailAddress($user_id, $columnList);
1702
				}
1703
1704
				if($member_info->change_password_date >= date('YmdHis', strtotime('-'.$limit_date.' day')) ){
1705
					$do_auto_login = true;
1706
				}
1707
1708
			}
1709
			else
1710
			{
1711
				$do_auto_login = true;
1712
			}
1713
		}
1714
1715
		if($do_auto_login)
1716
		{
1717
			$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...
1718
		}
1719
		else
1720
		{
1721
			executeQuery('member.deleteAutologin', $args);
1722
			setCookie('xeak',null,$_SERVER['REQUEST_TIME']+60*60*24*365);
1723
		}
1724
	}
1725
1726
	/**
1727
	 * Log-in
1728
	 *
1729
	 * @param string $user_id
1730
	 * @param string $password
1731
	 * @param boolean $keep_signed
1732
	 *
1733
	 * @return Object
1734
	 */
1735
	function doLogin($user_id, $password = '', $keep_signed = false)
1736
	{
1737
		$user_id = strtolower($user_id);
1738
		if(!$user_id) return new Object(-1, 'null_user_id');
1739
		// Call a trigger before log-in (before)
1740
		$trigger_obj = new stdClass();
1741
		$trigger_obj->user_id = $user_id;
1742
		$trigger_obj->password = $password;
1743
		$trigger_output = ModuleHandler::triggerCall('member.doLogin', 'before', $trigger_obj);
1744
		if(!$trigger_output->toBool()) return $trigger_output;
1745
		// Create a member model object
1746
		$oMemberModel = getModel('member');
1747
1748
		// check IP access count.
1749
		$config = $oMemberModel->getMemberConfig();
1750
		$args = new stdClass();
1751
		$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1752
1753
		// check identifier
1754
		if($config->identifier == 'email_address')
1755
		{
1756
			// Get user_id information
1757
			$this->memberInfo = $oMemberModel->getMemberInfoByEmailAddress($user_id);
1758
			// Set an invalid user if no value returned
1759
			if(!$user_id || strtolower($this->memberInfo->email_address) != strtolower($user_id)) return $this->recordLoginError(-1, 'invalid_email_address');
1760
1761
		}
1762
		else
1763
		{
1764
			// Get user_id information
1765
			$this->memberInfo = $oMemberModel->getMemberInfoByUserID($user_id);
1766
			// Set an invalid user if no value returned
1767
			if(!$user_id || strtolower($this->memberInfo->user_id) != strtolower($user_id)) return $this->recordLoginError(-1, 'invalid_user_id');
1768
		}
1769
1770
		$output = executeQuery('member.getLoginCountByIp', $args);
1771
		$errorCount = $output->data->count;
1772
		if($errorCount >= $config->max_error_count)
1773
		{
1774
			$last_update = strtotime($output->data->last_update);
1775
			$term = intval($_SERVER['REQUEST_TIME']-$last_update);
1776
			if($term < $config->max_error_count_time)
1777
			{
1778
				$term = $config->max_error_count_time - $term;
1779
				if($term < 60) $term = intval($term).Context::getLang('unit_sec');
1780
				elseif(60 <= $term && $term < 3600) $term = intval($term/60).Context::getLang('unit_min');
1781
				elseif(3600 <= $term && $term < 86400) $term = intval($term/3600).Context::getLang('unit_hour');
1782
				else $term = intval($term/86400).Context::getLang('unit_day');
1783
1784
				return new Object(-1, sprintf(Context::getLang('excess_ip_access_count'),$term));
1785
			}
1786
			else
1787
			{
1788
				$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1789
				$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...
1790
			}
1791
		}
1792
1793
		// Password Check
1794
		if($password && !$oMemberModel->isValidPassword($this->memberInfo->password, $password, $this->memberInfo->member_srl))
1795
		{
1796
			return $this->recordMemberLoginError(-1, 'invalid_password',$this->memberInfo);
1797
		}
1798
1799
		// If denied == 'Y', notify
1800
		if($this->memberInfo->denied == 'Y')
1801
		{
1802
			$args->member_srl = $this->memberInfo->member_srl;
1803
			$output = executeQuery('member.chkAuthMail', $args);
1804
			if ($output->toBool() && $output->data->count != '0')
1805
			{
1806
				$_SESSION['auth_member_srl'] = $this->memberInfo->member_srl;
1807
				$redirectUrl = getUrl('', 'act', 'dispMemberResendAuthMail');
1808
				return $this->setRedirectUrl($redirectUrl, new Object(-1,'msg_user_not_confirmed'));
1809
			}
1810
			return new Object(-1,'msg_user_denied');
1811
		}
1812
		// Notify if denied_date is less than the current time
1813
		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")));
1814
		// Update the latest login time
1815
		$args->member_srl = $this->memberInfo->member_srl;
1816
		$output = executeQuery('member.updateLastLogin', $args);
1817
1818
		$site_module_info = Context::get('site_module_info');
1819
		$this->_clearMemberCache($args->member_srl, $site_module_info->site_srl);
1820
1821
		// Check if there is recoding table.
1822
		$oDB = &DB::getInstance();
1823
		if($oDB->isTableExists('member_count_history') && $config->enable_login_fail_report != 'N')
1824
		{
1825
			// check if there is login fail records.
1826
			$output = executeQuery('member.getLoginCountHistoryByMemberSrl', $args);
1827
			if($output->data && $output->data->content)
1828
			{
1829
				$title = Context::getLang('login_fail_report');
1830
				$message = '<ul>';
1831
				$content = unserialize($output->data->content);
1832
				if(count($content) > $config->max_error_count)
1833
				{
1834
					foreach($content as $val)
1835
					{
1836
						$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>';
1837
					}
1838
					$message .= '</ul>';
1839
					$content = sprintf(Context::getLang('login_fail_report_contents'),$message,date('Y-m-d h:i:sa'));
1840
1841
					//send message
1842
					$oCommunicationController = getController('communication');
1843
					$oCommunicationController->sendMessage($args->member_srl, $args->member_srl, $title, $content, true);
1844
1845
					if($this->memberInfo->email_address && $this->memberInfo->allow_mailing == 'Y')
1846
					{
1847
						$view_url = Context::getRequestUri();
1848
						$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);
1849
						$oMail = new Mail();
1850
						$oMail->setTitle($title);
1851
						$oMail->setContent($content);
1852
						$oMail->setSender($config->webmaster_name?$config->webmaster_name:'webmaster', $config->webmaster_email);
1853
						$oMail->setReceiptor($this->memberInfo->email_id.'('.$this->memberInfo->nick_name.')', $this->memberInfo->email_address);
1854
						$oMail->send();
1855
					}
1856
					$output = executeQuery('member.deleteLoginCountHistoryByMemberSrl', $args);
1857
				}
1858
			}
1859
		}
1860
		// Call a trigger after successfully log-in (after)
1861
		$trigger_output = ModuleHandler::triggerCall('member.doLogin', 'after', $this->memberInfo);
1862
		if(!$trigger_output->toBool()) return $trigger_output;
1863
		// When user checked to use auto-login
1864
		if($keep_signed)
1865
		{
1866
			// Key generate for auto login
1867
			$oPassword = new Password();
1868
			$random_key = $oPassword->createSecureSalt(32, 'hex');
1869
			$extra_key = strtolower($user_id).$this->memberInfo->password.$_SERVER['HTTP_USER_AGENT'];
1870
			$extra_key = substr(hash_hmac('sha256', $extra_key, $random_key), 0, 32);
1871
			$autologin_args = new stdClass;
1872
			$autologin_args->autologin_key = $random_key.$extra_key;
1873
			$autologin_args->member_srl = $this->memberInfo->member_srl;
1874
			executeQuery('member.deleteAutologin', $autologin_args);
1875
			$autologin_output = executeQuery('member.insertAutologin', $autologin_args);
1876
			if($autologin_output->toBool()) setCookie('xeak',$autologin_args->autologin_key, $_SERVER['REQUEST_TIME']+31536000);
1877
		}
1878
		if($this->memberInfo->is_admin == 'Y')
1879
		{
1880
			$oMemberAdminModel = getAdminModel('member');
1881
			if(!$oMemberAdminModel->getMemberAdminIPCheck())
1882
			{
1883
				$_SESSION['denied_admin'] = 'Y';
1884
			}
1885
		}
1886
1887
		$this->setSessionInfo();
1888
1889
		return $output;
1890
	}
1891
1892
	/**
1893
	 * Update or create session information
1894
	 */
1895
	function setSessionInfo()
1896
	{
1897
		$oMemberModel = getModel('member');
1898
		// If your information came through the current session information to extract information from the users
1899
		if(!$this->memberInfo && $_SESSION['member_srl'] && $oMemberModel->isLogged() )
1900
		{
1901
			$this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($_SESSION['member_srl']);
1902
			// If you do not destroy the session Profile
1903
			if($this->memberInfo->member_srl != $_SESSION['member_srl'])
1904
			{
1905
				$this->destroySessionInfo();
1906
				return;
1907
			}
1908
		}
1909
		// Stop using the session id is destroyed
1910
		if($this->memberInfo->denied=='Y')
1911
		{
1912
			$this->destroySessionInfo();
1913
			return;
1914
		}
1915
		// Log in for treatment sessions set
1916
		$_SESSION['is_logged'] = true;
1917
		$_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR'];
1918
		$_SESSION['member_srl'] = $this->memberInfo->member_srl;
1919
		$_SESSION['is_admin'] = '';
1920
		setcookie('xe_logged', 'true');
1921
		// Do not save your password in the session jiwojum;;
1922
		//unset($this->memberInfo->password);
1923
		// User Group Settings
1924
		/*
1925
		   if($this->memberInfo->group_list) {
1926
		   $group_srl_list = array_keys($this->memberInfo->group_list);
1927
		   $_SESSION['group_srls'] = $group_srl_list;
1928
		// If the group is designated as an administrator administrator
1929
		$oMemberModel = getModel('member');
1930
		$admin_group = $oMemberModel->getAdminGroup();
1931
		if($admin_group->group_srl && in_array($admin_group->group_srl, $group_srl_list)) $_SESSION['is_admin'] = 'Y';
1932
		}
1933
		 */
1934
1935
		// Information stored in the session login user
1936
		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...
1937
		Context::set('logged_info', $this->memberInfo);
1938
1939
		// Only the menu configuration of the user (such as an add-on to the menu can be changed)
1940
		$this->addMemberMenu( 'dispMemberInfo', 'cmd_view_member_info');
1941
		$this->addMemberMenu( 'dispMemberScrappedDocument', 'cmd_view_scrapped_document');
1942
		$this->addMemberMenu( 'dispMemberSavedDocument', 'cmd_view_saved_document');
1943
		$this->addMemberMenu( 'dispMemberOwnDocument', 'cmd_view_own_document');
1944
	}
1945
1946
	/**
1947
	 * Logged method for providing a personalized menu
1948
	 * Login information is used in the output widget, or personalized page
1949
	 */
1950
	function addMemberMenu($act, $str)
1951
	{
1952
		$logged_info = Context::get('logged_info');
1953
1954
		$logged_info->menu_list[$act] = Context::getLang($str);
1955
1956
		Context::set('logged_info', $logged_info);
1957
	}
1958
1959
	/**
1960
	 * Nickname and click Log In to add a pop-up menu that appears when the method
1961
	 */
1962 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...
1963
	{
1964
		$member_popup_menu_list = Context::get('member_popup_menu_list');
1965
		if(!is_array($member_popup_menu_list)) $member_popup_menu_list = array();
1966
1967
		$obj = new stdClass;
1968
		$obj->url = $url;
1969
		$obj->str = $str;
1970
		$obj->icon = $icon;
1971
		$obj->target = $target;
1972
		$member_popup_menu_list[] = $obj;
1973
1974
		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...
1975
	}
1976
1977
	/**
1978
	 * Add users to the member table
1979
	 */
1980
	function insertMember(&$args, $password_is_hashed = false)
1981
	{
1982
		// Call a trigger (before)
1983
		$output = ModuleHandler::triggerCall('member.insertMember', 'before', $args);
1984
		if(!$output->toBool()) return $output;
1985
		// Terms and Conditions portion of the information set up by members reaffirmed
1986
		$oModuleModel = getModel('module');
1987
		$config = $oModuleModel->getModuleConfig('member');
1988
1989
		$logged_info = Context::get('logged_info');
1990
		// If the date of the temporary restrictions limit further information on the date of
1991
		if($config->limit_day) $args->limit_date = date("YmdHis", $_SERVER['REQUEST_TIME']+$config->limit_day*60*60*24);
1992
1993
		$args->member_srl = getNextSequence();
1994
		$args->list_order = -1 * $args->member_srl;
1995
1996
		// Execute insert or update depending on the value of member_srl
1997
		if(!$args->user_id) $args->user_id = 't'.$args->member_srl;
1998
		// Enter the user's identity changed to lowercase
1999
		else $args->user_id = strtolower($args->user_id);
2000
		if(!$args->user_name) $args->user_name = $args->member_srl;
2001
		if(!$args->nick_name) $args->nick_name = $args->member_srl;
2002
2003
		// Control of essential parameters
2004
		if($args->allow_mailing!='Y') $args->allow_mailing = 'N';
2005
		if($args->denied!='Y') $args->denied = 'N';
2006 View Code Duplication
		if(!$args->allow_message || ($args->allow_message && !in_array($args->allow_message, array('Y','N','F')))) $args->allow_message = 'Y';
2007
2008
		if($logged_info->is_admin == 'Y')
2009
		{
2010
			if($args->is_admin!='Y') $args->is_admin = 'N';
2011
		}
2012
		else
2013
		{
2014
			unset($args->is_admin);
2015
		}
2016
2017
		list($args->email_id, $args->email_host) = explode('@', $args->email_address);
2018
2019
		// Sanitize user ID, username, nickname, homepage, blog
2020
		$args->user_id = htmlspecialchars($args->user_id, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2021
		$args->user_name = htmlspecialchars($args->user_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2022
		$args->nick_name = htmlspecialchars($args->nick_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2023
		$args->homepage = htmlspecialchars($args->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2024
		$args->blog = htmlspecialchars($args->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2025 View Code Duplication
		if($args->homepage && !preg_match("/^[a-z]+:\/\//i",$args->homepage)) $args->homepage = 'http://'.$args->homepage;
2026 View Code Duplication
		if($args->blog && !preg_match("/^[a-z]+:\/\//i",$args->blog)) $args->blog = 'http://'.$args->blog;
2027
2028
		// Create a model object
2029
		$oMemberModel = getModel('member');
2030
2031
		// Check password strength
2032
		if($args->password && !$password_is_hashed)
2033
		{
2034 View Code Duplication
			if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
2035
			{
2036
				$message = Context::getLang('about_password_strength');
2037
				return new Object(-1, $message[$config->password_strength]);
2038
			}
2039
			$args->password = $oMemberModel->hashPassword($args->password);
2040
		}
2041
		elseif(!$args->password)
2042
		{
2043
			unset($args->password);
2044
		}
2045
2046
		if($args->find_account_answer && !$password_is_hashed)
2047
		{
2048
			$args->find_account_answer = $oMemberModel->hashPassword($args->find_account_answer);
2049
		}
2050
		elseif(!$args->find_account_answer)
2051
		{
2052
			unset($args->find_account_answer);
2053
		}
2054
2055
		// Check if ID is prohibited
2056
		if($oMemberModel->isDeniedID($args->user_id))
2057
		{
2058
			return new Object(-1,'denied_user_id');
2059
		}
2060
2061
		// Check if ID is duplicate
2062
		$member_srl = $oMemberModel->getMemberSrlByUserID($args->user_id);
2063
		if($member_srl)
2064
		{
2065
			return new Object(-1,'msg_exists_user_id');
2066
		}
2067
2068
		// Check if nickname is prohibited
2069
		if($oMemberModel->isDeniedNickName($args->nick_name))
2070
		{
2071
			return new Object(-1,'denied_nick_name');
2072
		}
2073
2074
		// Check if nickname is duplicate
2075
		$member_srl = $oMemberModel->getMemberSrlByNickName($args->nick_name);
2076
		if($member_srl)
2077
		{
2078
			return new Object(-1,'msg_exists_nick_name');
2079
		}
2080
2081
		// Check if email address is duplicate
2082
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($args->email_address);
2083
		if($member_srl)
2084
		{
2085
			return new Object(-1,'msg_exists_email_address');
2086
		}
2087
2088
		// Insert data into the DB
2089
		$args->list_order = -1 * $args->member_srl;
2090
2091
		if(!$args->user_id) $args->user_id = 't'.$args->member_srl;
2092
		if(!$args->user_name) $args->user_name = $args->member_srl;
2093
2094
		$oDB = &DB::getInstance();
2095
		$oDB->begin();
2096
2097
		$output = executeQuery('member.insertMember', $args);
2098
		if(!$output->toBool())
2099
		{
2100
			$oDB->rollback();
2101
			return $output;
2102
		}
2103
2104 View Code Duplication
		if(is_array($args->group_srl_list)) $group_srl_list = $args->group_srl_list;
2105
		else $group_srl_list = explode('|@|', $args->group_srl_list);
2106
		// If no value is entered the default group, the value of group registration
2107
		if(!$args->group_srl_list)
2108
		{
2109
			$columnList = array('site_srl', 'group_srl');
2110
			$default_group = $oMemberModel->getDefaultGroup(0, $columnList);
2111
			if($default_group)
2112
			{
2113
				// Add to the default group
2114
				$output = $this->addMemberToGroup($args->member_srl,$default_group->group_srl);
2115
				if(!$output->toBool())
2116
				{
2117
					$oDB->rollback();
2118
					return $output;
2119
				}
2120
			}
2121
			// If the value is the value of the group entered the group registration
2122
		}
2123
		else
2124
		{
2125 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...
2126
			{
2127
				$output = $this->addMemberToGroup($args->member_srl,$group_srl_list[$i]);
2128
2129
				if(!$output->toBool())
2130
				{
2131
					$oDB->rollback();
2132
					return $output;
2133
				}
2134
			}
2135
		}
2136
2137
		$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...
2138
		// When using email authentication mode (when you subscribed members denied a) certified mail sent
2139
		if($args->denied == 'Y')
2140
		{
2141
			// Insert data into the authentication DB
2142
			$oPassword = new Password();
2143
			$auth_args = new stdClass();
2144
			$auth_args->user_id = $args->user_id;
2145
			$auth_args->member_srl = $args->member_srl;
2146
			$auth_args->new_password = $args->password;
2147
			$auth_args->auth_key = $oPassword->createSecureSalt(40);
2148
			$auth_args->is_register = 'Y';
2149
2150
			$output = executeQuery('member.insertAuthMail', $auth_args);
2151
			if(!$output->toBool())
2152
			{
2153
				$oDB->rollback();
2154
				return $output;
2155
			}
2156
			$this->_sendAuthMail($auth_args, $args);
2157
		}
2158
		// Call a trigger (after)
2159 View Code Duplication
		if($output->toBool())
2160
		{
2161
			$trigger_output = ModuleHandler::triggerCall('member.insertMember', 'after', $args);
2162
			if(!$trigger_output->toBool())
2163
			{
2164
				$oDB->rollback();
2165
				return $trigger_output;
2166
			}
2167
		}
2168
2169
		$oDB->commit(true);
2170
2171
		$output->add('member_srl', $args->member_srl);
2172
		return $output;
2173
	}
2174
2175
	/**
2176
	 * Modify member information
2177
	 *
2178
	 * @param bool $is_admin , modified 2013-11-22
2179
	 */
2180
	function updateMember($args, $is_admin = FALSE)
2181
	{
2182
		// Call a trigger (before)
2183
		$output = ModuleHandler::triggerCall('member.updateMember', 'before', $args);
2184
		if(!$output->toBool()) return $output;
2185
		// Create a model object
2186
		$oMemberModel = getModel('member');
2187
2188
		$logged_info = Context::get('logged_info');
2189
		// Get what you want to modify the original information
2190
		if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
2191
		// Control of essential parameters
2192
		if($args->allow_mailing!='Y') $args->allow_mailing = 'N';
2193 View Code Duplication
		if($args->allow_message && !in_array($args->allow_message, array('Y','N','F'))) $args->allow_message = 'Y';
2194
2195
		if($logged_info->is_admin == 'Y')
2196
		{
2197
			if($args->denied!='Y') $args->denied = 'N';
2198
			if($args->is_admin!='Y' && $logged_info->member_srl != $args->member_srl) $args->is_admin = 'N';
2199
		}
2200
		else
2201
		{
2202
			unset($args->is_admin);
2203
			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...
2204
				unset($args->denied);
2205
			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...
2206
			{
2207
				return $this->stop('msg_invalid_request');
2208
			}
2209
		}
2210
2211
		// Sanitize user ID, username, nickname, homepage, blog
2212
		if($args->user_id) $args->user_id = htmlspecialchars($args->user_id, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2213
		$args->user_name = htmlspecialchars($args->user_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2214
		$args->nick_name = htmlspecialchars($args->nick_name, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2215
		$args->homepage = htmlspecialchars($args->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2216
		$args->blog = htmlspecialchars($args->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2217 View Code Duplication
		if($args->homepage && !preg_match("/^[a-z]+:\/\//is",$args->homepage)) $args->homepage = 'http://'.$args->homepage;
2218 View Code Duplication
		if($args->blog && !preg_match("/^[a-z]+:\/\//is",$args->blog)) $args->blog = 'http://'.$args->blog;
2219
2220
		// check member identifier form
2221
		$config = $oMemberModel->getMemberConfig();
2222
2223
		$output = executeQuery('member.getMemberInfoByMemberSrl', $args);
2224
		$orgMemberInfo = $output->data;
2225
2226
		// Check if email address or user ID is duplicate
2227
		if($config->identifier == 'email_address')
2228
		{
2229
			$member_srl = $oMemberModel->getMemberSrlByEmailAddress($args->email_address);
2230
			if($member_srl && $args->member_srl != $member_srl)
2231
			{
2232
				return new Object(-1,'msg_exists_email_address');
2233
			}
2234
			$args->email_address = $orgMemberInfo->email_address;
2235
		}
2236 View Code Duplication
		else
2237
		{
2238
			$member_srl = $oMemberModel->getMemberSrlByUserID($args->user_id);
2239
			if($member_srl && $args->member_srl != $member_srl)
2240
			{
2241
				return new Object(-1,'msg_exists_user_id');
2242
			}
2243
2244
			$args->user_id = $orgMemberInfo->user_id;
2245
		}
2246
2247
		if($logged_info->is_admin !== 'Y')
2248
		{
2249
			// Check if ID is prohibited
2250
			if($args->user_id && $oMemberModel->isDeniedID($args->user_id))
2251
			{
2252
				return new Object(-1,'denied_user_id');
2253
			}
2254
2255
			// Check if nickname is prohibited
2256
			if($args->nick_name && $oMemberModel->isDeniedNickName($args->nick_name))
2257
			{
2258
				return new Object(-1, 'denied_nick_name');
2259
			}
2260
		}
2261
2262
		// Check if ID is duplicate
2263 View Code Duplication
		if($args->user_id)
2264
		{
2265
			$member_srl = $oMemberModel->getMemberSrlByUserID($args->user_id);
2266
			if($member_srl && $args->member_srl != $member_srl)
2267
			{
2268
				return new Object(-1,'msg_exists_user_id');
2269
			}
2270
		}
2271
2272
		// Check if nickname is duplicate
2273
		$member_srl = $oMemberModel->getMemberSrlByNickName($args->nick_name);
2274
 		if($member_srl && $args->member_srl != $member_srl)
2275
 		{
2276
 			return new Object(-1,'msg_exists_nick_name');
2277
 		}
2278
2279
		list($args->email_id, $args->email_host) = explode('@', $args->email_address);
2280
2281
		$oDB = &DB::getInstance();
2282
		$oDB->begin();
2283
2284
		// Check password strength
2285
		if($args->password)
2286
		{
2287 View Code Duplication
			if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
2288
			{
2289
				$message = Context::getLang('about_password_strength');
2290
				return new Object(-1, $message[$config->password_strength]);
2291
			}
2292
			$args->password = $oMemberModel->hashPassword($args->password);
2293
		}
2294
		else
2295
		{
2296
			$args->password = $orgMemberInfo->password;
2297
		}
2298
2299
		if($args->find_account_answer) {
2300
			$args->find_account_answer = $oMemberModel->hashPassword($args->find_account_answer);
2301
		}
2302
		else
2303
		{
2304
			$oPassword =  new Password();
2305
			$hashed = $oPassword->checkAlgorithm($orgMemberInfo->find_account_answer);
2306
2307
			if($hashed) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $hashed of type string|false is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false 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...
2308
				$args->find_account_answer = $orgMemberInfo->find_account_answer;
2309
			} else {
2310
				$args->find_account_answer = $oPassword->createHash($orgMemberInfo->find_account_answer);
2311
			}
2312
		}
2313
2314
		if(!$args->user_name) $args->user_name = $orgMemberInfo->user_name;
2315
		if(!$args->user_id) $args->user_id = $orgMemberInfo->user_id;
2316
		if(!$args->nick_name) $args->nick_name = $orgMemberInfo->nick_name;
2317
		if(!$args->description) $args->description = $orgMemberInfo->description;
2318
		if(!$args->birthday) $args->birthday = '';
2319
2320
		$output = executeQuery('member.updateMember', $args);
2321
2322
		if(!$output->toBool())
2323
		{
2324
			$oDB->rollback();
2325
			return $output;
2326
		}
2327
2328
		if($args->group_srl_list)
2329
		{
2330 View Code Duplication
			if(is_array($args->group_srl_list)) $group_srl_list = $args->group_srl_list;
2331
			else $group_srl_list = explode('|@|', $args->group_srl_list);
2332
			// If the group information, group information changes
2333
			if(count($group_srl_list) > 0)
2334
			{
2335
				$args->site_srl = 0;
2336
				// One of its members to delete all the group
2337
				$output = executeQuery('member.deleteMemberGroupMember', $args);
2338
				if(!$output->toBool())
2339
				{
2340
					$oDB->rollback();
2341
					return $output;
2342
				}
2343
				// Enter one of the loop a
2344 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...
2345
				{
2346
					$output = $this->addMemberToGroup($args->member_srl,$group_srl_list[$i]);
2347
					if(!$output->toBool())
2348
					{
2349
						$oDB->rollback();
2350
						return $output;
2351
					}
2352
				}
2353
2354
				// if group is changed, point changed too.
2355
				$this->_updatePointByGroup($orgMemberInfo->member_srl, $group_srl_list);
2356
			}
2357
		}
2358
		// Call a trigger (after)
2359 View Code Duplication
		if($output->toBool()) {
2360
			$trigger_output = ModuleHandler::triggerCall('member.updateMember', 'after', $args);
2361
			if(!$trigger_output->toBool())
2362
			{
2363
				$oDB->rollback();
2364
				return $trigger_output;
2365
			}
2366
		}
2367
2368
		$oDB->commit();
2369
2370
		//remove from cache
2371
		$this->_clearMemberCache($args->member_srl, $args->site_srl);
2372
2373
		// Save Session
2374
		if(!$this->memberInfo) $this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($args->member_srl);
2375
		$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...
2376
2377
		$output->add('member_srl', $args->member_srl);
2378
		return $output;
2379
	}
2380
2381
	/**
2382
	 * Modify member password
2383
	 */
2384
	function updateMemberPassword($args)
2385
	{
2386
		if($args->password)
2387
		{
2388
2389
			// check password strength
2390
			$oMemberModel = getModel('member');
2391
			$config = $oMemberModel->getMemberConfig();
2392
2393 View Code Duplication
			if(!$oMemberModel->checkPasswordStrength($args->password, $config->password_strength))
2394
			{
2395
				$message = Context::getLang('about_password_strength');
2396
				return new Object(-1, $message[$config->password_strength]);
2397
			}
2398
2399
			$args->password = $oMemberModel->hashPassword($args->password);
2400
		}
2401
		else if($args->hashed_password)
2402
		{
2403
			$args->password = $args->hashed_password;
2404
		}
2405
2406
		$output = executeQuery('member.updateMemberPassword', $args);
2407
		if($output->toBool())
2408
		{
2409
			$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...
2410
		}
2411
2412
		$this->_clearMemberCache($args->member_srl);
2413
2414
		return $output;
2415
	}
2416
2417
	function updateFindAccountAnswer($member_srl, $answer)
2418
	{
2419
		$oPassword =  new Password();
2420
2421
		$args = new stdClass();
2422
		$args->member_srl = $member_srl;
2423
		$args->find_account_answer = $oPassword->createHash($answer);
2424
		$output = executeQuery('member.updateFindAccountAnswer', $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...
2425
	}
2426
2427
	/**
2428
	 * Delete User
2429
	 */
2430
	function deleteMember($member_srl)
2431
	{
2432
		// Call a trigger (before)
2433
		$trigger_obj = new stdClass();
2434
		$trigger_obj->member_srl = $member_srl;
2435
		$output = ModuleHandler::triggerCall('member.deleteMember', 'before', $trigger_obj);
2436
		if(!$output->toBool()) return $output;
2437
		// Create a model object
2438
		$oMemberModel = getModel('member');
2439
		// Bringing the user's information
2440
		if(!$this->memberInfo || $this->memberInfo->member_srl != $member_srl || !isset($this->memberInfo->is_admin))
2441
		{
2442
			$columnList = array('member_srl', 'is_admin');
2443
			$this->memberInfo = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
2444
		}
2445
		if(!$this->memberInfo) return new Object(-1, 'msg_not_exists_member');
2446
		// If managers can not be deleted
2447
		if($this->memberInfo->is_admin == 'Y') return new Object(-1, 'msg_cannot_delete_admin');
2448
2449
		$oDB = &DB::getInstance();
2450
		$oDB->begin();
2451
2452
		$args = new stdClass();
2453
		$args->member_srl = $member_srl;
2454
		// Delete the entries in member_auth_mail
2455
		$output = executeQuery('member.deleteAuthMail', $args);
2456
		if(!$output->toBool())
2457
		{
2458
			$oDB->rollback();
2459
			return $output;
2460
		}
2461
2462
		// TODO: If the table is not an upgrade may fail.
2463
		/*
2464
		   if(!$output->toBool()) {
2465
		   $oDB->rollback();
2466
		   return $output;
2467
		   }
2468
		 */
2469
		// Delete the entries in member_group_member
2470
		$output = executeQuery('member.deleteMemberGroupMember', $args);
2471
		if(!$output->toBool())
2472
		{
2473
			$oDB->rollback();
2474
			return $output;
2475
		}
2476
		// member removed from the table
2477
		$output = executeQuery('member.deleteMember', $args);
2478
		if(!$output->toBool())
2479
		{
2480
			$oDB->rollback();
2481
			return $output;
2482
		}
2483
		// Call a trigger (after)
2484 View Code Duplication
		if($output->toBool())
2485
		{
2486
			$trigger_output = ModuleHandler::triggerCall('member.deleteMember', 'after', $trigger_obj);
2487
			if(!$trigger_output->toBool())
2488
			{
2489
				$oDB->rollback();
2490
				return $trigger_output;
2491
			}
2492
		}
2493
2494
		$oDB->commit();
2495
		// Name, image, image, mark, sign, delete
2496
		$this->procMemberDeleteImageName($member_srl);
2497
		$this->procMemberDeleteImageMark($member_srl);
2498
		$this->procMemberDeleteProfileImage($member_srl);
2499
		$this->delSignature($member_srl);
2500
2501
		$this->_clearMemberCache($member_srl);
2502
2503
		return $output;
2504
	}
2505
2506
	/**
2507
	 * Destroy all session information
2508
	 */
2509
	function destroySessionInfo()
2510
	{
2511
		if(!$_SESSION || !is_array($_SESSION)) return;
2512
2513
		$memberInfo = Context::get('logged_info');
2514
		$memberSrl = $memberInfo->member_srl;
2515
2516
		foreach($_SESSION as $key => $val)
2517
		{
2518
			$_SESSION[$key] = '';
2519
		}
2520
2521
		session_destroy();
2522
		setcookie(session_name(), '', $_SERVER['REQUEST_TIME']-42000);
2523
		setcookie('sso','',$_SERVER['REQUEST_TIME']-42000);
2524
		setcookie('xeak','',$_SERVER['REQUEST_TIME']-42000);
2525
		setcookie('xe_logged', 'false', $_SERVER['REQUEST_TIME'] - 42000);
2526
2527
		if($memberSrl || $_COOKIE['xeak'])
2528
		{
2529
			$args = new stdClass();
2530
			$args->member_srl = $memberSrl;
2531
			$args->autologin_key = $_COOKIE['xeak'];
2532
			$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...
2533
		}
2534
	}
2535
2536
	function _updatePointByGroup($memberSrl, $groupSrlList)
2537
	{
2538
		$oModuleModel = getModel('module');
2539
		$pointModuleConfig = $oModuleModel->getModuleConfig('point');
2540
		$pointGroup = $pointModuleConfig->point_group;
2541
2542
		$levelGroup = array();
2543
		if(is_array($pointGroup) && count($pointGroup)>0)
2544
		{
2545
			$levelGroup = array_flip($pointGroup);
2546
			ksort($levelGroup);
2547
		}
2548
		$maxLevel = 0;
2549
		$resultGroup = array_intersect($levelGroup, $groupSrlList);
2550
		if(count($resultGroup) > 0)
2551
			$maxLevel = max(array_flip($resultGroup));
2552
2553
		if($maxLevel > 0)
2554
		{
2555
			$oPointModel = getModel('point');
2556
			$originPoint = $oPointModel->getPoint($memberSrl);
2557
2558
			if($pointModuleConfig->level_step[$maxLevel] > $originPoint)
2559
			{
2560
				$oPointController = getController('point');
2561
				$oPointController->setPoint($memberSrl, $pointModuleConfig->level_step[$maxLevel], 'update');
2562
			}
2563
		}
2564
	}
2565
2566
	function procMemberModifyEmailAddress()
2567
	{
2568
		if(!Context::get('is_logged')) return $this->stop('msg_not_logged');
2569
2570
		$member_info = Context::get('logged_info');
2571
		$newEmail = Context::get('email_address');
2572
2573
		if(!$newEmail) return $this->stop('msg_invalid_request');
2574
2575
		$oMemberModel = getModel('member');
2576
		$member_srl = $oMemberModel->getMemberSrlByEmailAddress($newEmail);
2577
		if($member_srl) return new Object(-1,'msg_exists_email_address');
2578
2579
		if($_SESSION['rechecked_password_step'] != 'INPUT_DATA')
2580
		{
2581
			return $this->stop('msg_invalid_request');
2582
		}
2583
		unset($_SESSION['rechecked_password_step']);
2584
2585
		$oPassword = new Password();
2586
		$auth_args = new stdClass();
2587
		$auth_args->user_id = $newEmail;
2588
		$auth_args->member_srl = $member_info->member_srl;
2589
		$auth_args->auth_key = $oPassword->createSecureSalt(40);
2590
		$auth_args->new_password = 'XE_change_emaill_address';
2591
2592
		$oDB = &DB::getInstance();
2593
		$oDB->begin();
2594
		$output = executeQuery('member.insertAuthMail', $auth_args);
2595
		if(!$output->toBool())
2596
		{
2597
			$oDB->rollback();
2598
			return $output;
2599
		}
2600
2601
		$oModuleModel = getModel('module');
2602
		$member_config = $oModuleModel->getModuleConfig('member');
2603
2604
		$tpl_path = sprintf('%sskins/%s', $this->module_path, $member_config->skin);
2605
		if(!is_dir($tpl_path)) $tpl_path = sprintf('%sskins/%s', $this->module_path, 'default');
2606
2607
		global $lang;
2608
2609
		$memberInfo = array();
2610
		$memberInfo[$lang->email_address] = $member_info->email_address;
2611
		$memberInfo[$lang->nick_name] = $member_info->nick_name;
2612
2613
		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...
2614
2615
		Context::set('newEmail', $newEmail);
2616
2617
		$auth_url = getFullUrl('','module','member','act','procMemberAuthEmailAddress','member_srl',$member_info->member_srl, 'auth_key',$auth_args->auth_key);
2618
		Context::set('auth_url', $auth_url);
2619
2620
		$oTemplate = &TemplateHandler::getInstance();
2621
		$content = $oTemplate->compile($tpl_path, 'confirm_member_new_email');
2622
2623
		$oMail = new Mail();
2624
		$oMail->setTitle( Context::getLang('title_modify_email_address') );
2625
		$oMail->setContent($content);
2626
		$oMail->setSender( $member_config->webmaster_name?$member_config->webmaster_name:'webmaster', $member_config->webmaster_email);
2627
		$oMail->setReceiptor( $member_info->nick_name, $newEmail );
2628
		$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...
2629
2630
		$msg = sprintf(Context::getLang('msg_confirm_mail_sent'), $newEmail);
2631
		$this->setMessage($msg);
2632
2633
		$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
2634
		$this->setRedirectUrl($returnUrl);
2635
	}
2636
2637
	function procMemberAuthEmailAddress()
2638
	{
2639
		$member_srl = Context::get('member_srl');
2640
		$auth_key = Context::get('auth_key');
2641
		if(!$member_srl || !$auth_key) return $this->stop('msg_invalid_request');
2642
2643
		// Test logs for finding password by user_id and authkey
2644
		$args = new stdClass;
2645
		$args->member_srl = $member_srl;
2646
		$args->auth_key = $auth_key;
2647
		$output = executeQuery('member.getAuthMail', $args);
2648 View Code Duplication
		if(!$output->toBool() || $output->data->auth_key != $auth_key)
2649
		{
2650
			if(strlen($output->data->auth_key) !== strlen($auth_key)) executeQuery('member.deleteAuthChangeEmailAddress', $args);
2651
			return $this->stop('msg_invalid_modify_email_auth_key');
2652
		}
2653
2654
		$newEmail = $output->data->user_id;
2655
		$args->email_address = $newEmail;
2656
		list($args->email_id, $args->email_host) = explode('@', $newEmail);
2657
2658
		$output = executeQuery('member.updateMemberEmailAddress', $args);
2659
		if(!$output->toBool()) return $this->stop($output->getMessage());
2660
2661
		// Remove all values having the member_srl and new_password equal to 'XE_change_emaill_address' from authentication table
2662
		executeQuery('member.deleteAuthChangeEmailAddress',$args);
2663
2664
		$this->_clearMemberCache($args->member_srl);
2665
2666
		// Notify the result
2667
		$this->setTemplatePath($this->module_path.'tpl');
2668
		$this->setTemplateFile('msg_success_modify_email_address');
2669
	}
2670
2671
	/**
2672
	 * trigger for document.getDocumentMenu. Append to popup menu a button for procMemberSpammerManage()
2673
	 *
2674
	 * @param array &$menu_list
2675
	 *
2676
	 * @return object
2677
	**/
2678 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...
2679
	{
2680
		if(!Context::get('is_logged')) return new Object();
2681
2682
		$logged_info = Context::get('logged_info');
2683
		$document_srl = Context::get('target_srl');
2684
2685
		$oDocumentModel = getModel('document');
2686
		$columnList = array('document_srl', 'module_srl', 'member_srl', 'ipaddress');
2687
		$oDocument = $oDocumentModel->getDocument($document_srl, false, false, $columnList);
2688
		$member_srl = $oDocument->get('member_srl');
2689
		$module_srl = $oDocument->get('module_srl');
2690
2691
		if(!$member_srl) return new Object();
2692
		if($oDocumentModel->grant->manager != 1 || $member_srl==$logged_info->member_srl) return new Object();
2693
2694
		$oDocumentController = getController('document');
2695
		$url = getUrl('','module','member','act','dispMemberSpammer','member_srl',$member_srl,'module_srl',$module_srl);
2696
		$oDocumentController->addDocumentPopupMenu($url,'cmd_spammer','','popup');
2697
2698
		return new Object();
2699
	}
2700
2701
	/**
2702
	 * trigger for comment.getCommentMenu. Append to popup menu a button for procMemberSpammerManage()
2703
	 *
2704
	 * @param array &$menu_list
2705
	 *
2706
	 * @return object
2707
	**/
2708 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...
2709
	{
2710
		if(!Context::get('is_logged')) return new Object();
2711
2712
		$logged_info = Context::get('logged_info');
2713
		$comment_srl = Context::get('target_srl');
2714
2715
		$oCommentModel = getModel('comment');
2716
		$columnList = array('comment_srl', 'module_srl', 'member_srl', 'ipaddress');
2717
		$oComment = $oCommentModel->getComment($comment_srl, FALSE, $columnList);
2718
		$module_srl = $oComment->get('module_srl');
2719
		$member_srl = $oComment->get('member_srl');
2720
2721
		if(!$member_srl) return new Object();
2722
		if($oCommentModel->grant->manager != 1 || $member_srl==$logged_info->member_srl) return new Object();
2723
2724
		$oCommentController = getController('comment');
2725
		$url = getUrl('','module','member','act','dispMemberSpammer','member_srl',$member_srl,'module_srl',$module_srl);
2726
		$oCommentController->addCommentPopupMenu($url,'cmd_spammer','','popup');
2727
2728
		return new Object();
2729
	}
2730
2731
	/**
2732
	 * Spammer manage. Denied user login. And delete or trash all documents. Response Ajax string
2733
	 *
2734
	 * @return object
2735
	**/
2736
	function procMemberSpammerManage()
2737
	{
2738
		if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
2739
2740
		$logged_info = Context::get('logged_info');
2741
		$member_srl = Context::get('member_srl');
2742
		$module_srl = Context::get('module_srl');
2743
		$cnt_loop = Context::get('cnt_loop');
2744
		$proc_type = Context::get('proc_type');
2745
		$isMoveToTrash = true;
2746
		if($proc_type == "delete")
2747
			$isMoveToTrash = false;
2748
2749
		// check grant
2750
		$oModuleModel = getModel('module');
2751
		$columnList = array('module_srl', 'module');
2752
		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
2753
		$grant = $oModuleModel->getGrant($module_info, $logged_info);
2754
2755
		if(!$grant->manager) return new Object(-1,'msg_not_permitted');
2756
2757
		$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...
2758
2759
		$oDocumentModel = getModel('document');
2760
		$oCommentModel = getModel('comment');
2761
2762
		// delete or trash destination
2763
		// proc member
2764
		if($cnt_loop == 1)
2765
			$this->_spammerMember($member_srl);
2766
		// proc document and comment
2767
		elseif($cnt_loop>1)
2768
			$this->_spammerDocuments($member_srl, $isMoveToTrash);
2769
2770
		// get destination count
2771
		$cnt_document = $oDocumentModel->getDocumentCountByMemberSrl($member_srl);
2772
		$cnt_comment = $oCommentModel->getCommentCountByMemberSrl($member_srl);
2773
2774
		$total_count = Context::get('total_count');
2775
		$remain_count = $cnt_document + $cnt_comment;
2776
		if($cnt_loop == 1) $total_count = $remain_count;
2777
2778
		// get progress percent
2779
		if($total_count > 0)
2780
			$progress = intval( ( ( $total_count - $remain_count ) / $total_count ) * 100 );
2781
		else
2782
			$progress = 100;
2783
2784
		$this->add('total_count', $total_count);
2785
		$this->add('remain_count', $remain_count);
2786
		$this->add('progress', $progress);
2787
		$this->add('member_srl', $member_srl);
2788
		$this->add('module_srl', $module_srl);
2789
		$this->add('cnt_loop', ++$cnt_loop);
2790
		$this->add('proc_type', $proc_type);
2791
2792
		return new Object(0);
2793
	}
2794
2795
	/**
2796
	 * Denied user login and write description
2797
	 *
2798
	 * @param int $member_srl
2799
	 *
2800
	 * @return object
2801
	**/
2802
	private function _spammerMember($member_srl) {
2803
		$logged_info = Context::get('logged_info');
2804
		$spam_description = trim( Context::get('spam_description') );
2805
2806
		$oMemberModel = getModel('member');
2807
		$columnList = array('member_srl', 'email_address', 'user_id', 'nick_name', 'description');
2808
		// get member current infomation
2809
		$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
2810
2811
		$oDocumentModel = getModel('document');
2812
		$oCommentModel = getModel('comment');
2813
		$cnt_comment = $oCommentModel->getCommentCountByMemberSrl($member_srl);
2814
		$cnt_document = $oDocumentModel->getDocumentCountByMemberSrl($member_srl);
2815
		$total_count = $cnt_comment + $cnt_document;
2816
2817
		$args = new stdClass();
2818
		$args->member_srl = $member_info->member_srl;
2819
		$args->email_address = $member_info->email_address;
2820
		$args->user_id = $member_info->user_id;
2821
		$args->nick_name = $member_info->nick_name;
2822
		$args->denied = "Y";
2823
		$args->description = trim( $member_info->description );
2824
		if( $args->description != "" ) $args->description .= "\n";	// add new line
2825
2826
		$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 . "]";
2827
2828
		$output = $this->updateMember($args, true);
2829
2830
		$this->_clearMemberCache($args->member_srl);
2831
2832
		return $output;
2833
	}
2834
2835
	/**
2836
	 * Delete or trash all documents
2837
	 *
2838
	 * @param int $member_srl
2839
	 * @param bool $isMoveToTrash
2840
	 *
2841
	 * @return object
2842
	**/
2843
	private function _spammerDocuments($member_srl, $isMoveToTrash) {
2844
		$oDocumentController = getController('document');
2845
		$oDocumentModel = getModel('document');
2846
		$oCommentController = getController('comment');
2847
		$oCommentModel = getModel('comment');
2848
2849
		// delete count by one request
2850
		$getContentsCount = 10;
2851
2852
		// 1. proc comment, 2. proc document
2853
		$cnt_comment = $oCommentModel->getCommentCountByMemberSrl($member_srl);
2854
		$cnt_document = $oDocumentModel->getDocumentCountByMemberSrl($member_srl);
2855
		if($cnt_comment > 0)
2856
		{
2857
			$columnList = array();
2858
			$commentList = $oCommentModel->getCommentListByMemberSrl($member_srl, $columnList, 0, false, $getContentsCount);
2859
			if($commentList) {
2860
				foreach($commentList as $v) {
2861
					$oCommentController->deleteComment($v->comment_srl, true, $isMoveToTrash);
2862
				}
2863
			}
2864
		} elseif($cnt_document > 0) {
2865
			$columnList = array();
2866
			$documentList = $oDocumentModel->getDocumentListByMemberSrl($member_srl, $columnList, 0, false, $getContentsCount);
2867
			if($documentList) {
2868
				foreach($documentList as $v) {
2869
					if($isMoveToTrash) $oDocumentController->moveDocumentToTrash($v);
2870
					else $oDocumentController->deleteDocument($v->document_srl);
2871
				}
2872
			}
2873
		}
2874
2875
		return array();
2876
	}
2877
2878
	function _clearMemberCache($member_srl, $site_srl = 0)
2879
	{
2880
		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
2881
		if($oCacheHandler->isSupport())
2882
		{
2883
			$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_' . $site_srl;
2884
			$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
2885
			$oCacheHandler->delete($cache_key);
2886
2887
			if($site_srl !== 0)
2888
			{
2889
				$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_0';
2890
				$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
2891
				$oCacheHandler->delete($cache_key);
2892
			}
2893
		}
2894
2895
		$oCacheHandler = CacheHandler::getInstance('object');
2896
		if($oCacheHandler->isSupport())
2897
		{
2898
			$object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl;
2899
			$cache_key = $oCacheHandler->getGroupKey('member', $object_key);
2900
			$oCacheHandler->delete($cache_key);
2901
		}
2902
	}
2903
}
2904
/* End of file member.controller.php */
2905
/* Location: ./modules/member/member.controller.php */
2906