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 ( b130b6...8a2f54 )
by gyeong-won
07:36
created

member::moduleUpdate()   F

Complexity

Conditions 28
Paths > 20000

Size

Total Lines 160
Code Lines 87

Duplication

Lines 19
Ratio 11.88 %

Importance

Changes 0
Metric Value
cc 28
eloc 87
nc 12582928
nop 0
dl 19
loc 160
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* Copyright (C) NAVER <http://www.navercorp.com> */
3
/**
4
 * @class  member
5
 * @author NAVER ([email protected])
6
 * high class of the member module
7
 */
8
class member extends ModuleObject {
9
	/**
10
	 * Use sha1 encryption
11
	 *
12
	 * @var boolean
13
	 */
14
	var $useSha1 = false;
15
16
	/**
17
	 * constructor
18
	 *
19
	 * @return void
20
	 */
21
	function member()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
22
	{
23
		if(!Context::isInstalled()) return;
24
25
		$oModuleModel = getModel('module');
26
		$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...
27
28
		// Set to use SSL upon actions related member join/information/password and so on. 2013.02.15
29
		if(!Context::isExistsSSLAction('dispMemberModifyPassword') && Context::getSslStatus() == 'optional')
30
		{
31
			$ssl_actions = array('dispMemberModifyPassword', 'dispMemberSignUpForm', 'dispMemberModifyInfo', 'dispMemberModifyEmailAddress', 'dispMemberGetTempPassword', 'dispMemberResendAuthMail', 'dispMemberLoginForm', 'dispMemberFindAccount', 'dispMemberLeave', 'procMemberLogin', 'procMemberModifyPassword', 'procMemberInsert', 'procMemberModifyInfo', 'procMemberFindAccount', 'procMemberModifyEmailAddress', 'procMemberResendAuthMail', 'procMemberLeave'/*, 'getMemberMenu'*/, 'procMemberFindAccountByQuestion');
32
			Context::addSSLActions($ssl_actions);
33
		}
34
	}
35
36
	/**
37
	 * Implement if additional tasks are necessary when installing
38
	 *
39
	 * @return BaseObject
40
	 */
41
	function moduleInstall()
42
	{
43
		// Register action forward (to use in administrator mode)
44
		$oModuleController = getController('module');
45
46
		$oDB = &DB::getInstance();
47
		$oDB->addIndex("member_group","idx_site_title", array("site_srl","title"),true);
48
49
		$oModuleModel = getModel('module');
50
		$config = $oModuleModel->getModuleConfig('member');
51
52
		if(empty($config))
53
		{
54
			$isNotInstall = true;
55
			$config = new stdClass;
56
		}
57
58
		// Set the basic information
59
		$config->enable_join = 'Y';
60
		$config->enable_openid = 'N';
61
		if(!$config->enable_auth_mail) $config->enable_auth_mail = 'N';
62
		if(!$config->image_name) $config->image_name = 'Y';
63
		if(!$config->image_mark) $config->image_mark = 'Y';
64
		if(!$config->profile_image) $config->profile_image = 'Y';
65
		if(!$config->image_name_max_width) $config->image_name_max_width = '90';
66
		if(!$config->image_name_max_height) $config->image_name_max_height = '20';
67
		if(!$config->image_mark_max_width) $config->image_mark_max_width = '20';
68
		if(!$config->image_mark_max_height) $config->image_mark_max_height = '20';
69
		if(!$config->profile_image_max_width) $config->profile_image_max_width = '90';
70
		if(!$config->profile_image_max_height) $config->profile_image_max_height = '90';
71
		if($config->group_image_mark!='Y') $config->group_image_mark = 'N';
72
		if(!$config->password_strength) $config->password_strength = 'normal';
73
		
74
		if(!$config->password_hashing_algorithm)
75
		{
76
			$oPassword = new Password();
77
			$config->password_hashing_algorithm = $oPassword->getBestAlgorithm();
78
		}
79
		if(!$config->password_hashing_work_factor)
80
		{
81
			$config->password_hashing_work_factor = 8;
82
		}
83
		if(!$config->password_hashing_auto_upgrade)
84
		{
85
			$config->password_hashing_auto_upgrade = 'Y';
86
		}
87
		
88
		global $lang;
89
		$oMemberModel = getModel('member');
90
		// Create a member controller object
91
		$oMemberController = getController('member');
92
		$oMemberAdminController = getAdminController('member');
93
94
		if(!$config->signupForm || !is_array($config->signupForm))
95
		{
96
			$identifier = $isNotInstall ? 'email_address' : 'user_id';
0 ignored issues
show
Bug introduced by
The variable $isNotInstall 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...
97
98
			$config->signupForm = $oMemberAdminController->createSignupForm($identifier);
99
			$config->identifier = $identifier;
100
101
102
			// Create Ruleset File
103
			FileHandler::makeDir('./files/ruleset');
104
			$oMemberAdminController->_createSignupRuleset($config->signupForm);
105
			$oMemberAdminController->_createLoginRuleset($config->identifier);
106
			$oMemberAdminController->_createFindAccountByQuestion($config->identifier);
107
		}
108
		
109
		$oModuleController->insertModuleConfig('member',$config);
110
111
		$groups = $oMemberModel->getGroups();
112
		if(!count($groups))
113
		{
114
			// Set an administrator, regular member(group1), and associate member(group2)
115
			$group_args = new stdClass;
116
			$group_args->title = Context::getLang('admin_group');
117
			$group_args->is_default = 'N';
118
			$group_args->is_admin = 'Y';
119
			$output = $oMemberAdminController->insertGroup($group_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...
120
121
			$group_args = new stdClass;
122
			$group_args->title = Context::getLang('default_group_1');
123
			$group_args->is_default = 'Y';
124
			$group_args->is_admin = 'N';
125
			$output = $oMemberAdminController->insertGroup($group_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...
126
127
			$group_args = new stdClass;
128
			$group_args->title = Context::getLang('default_group_2');
129
			$group_args->is_default = 'N';
130
			$group_args->is_admin = 'N';
131
			$oMemberAdminController->insertGroup($group_args);
132
		}
133
134
		// Configure administrator information
135
		$admin_args = new stdClass;
136
		$admin_args->is_admin = 'Y';
137
		$output = executeQuery('member.getMemberList', $admin_args);
138
		if(!$output->data)
139
		{
140
			$admin_info = Context::gets('password','nick_name','email_address', 'user_id');
141
			if($admin_info->email_address)
142
			{
143
				$admin_info->user_name = 'admin';
144
				// Insert admin information
145
				$oMemberAdminController->insertAdmin($admin_info);
146
				// Log-in Processing
147
				$output = $oMemberController->doLogin($admin_info->email_address);
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...
148
			}
149
		}
150
		// Register denied ID(default + module name)
151
		$oModuleModel = getModel('module');
152
		$module_list = $oModuleModel->getModuleList();
153
		foreach($module_list as $key => $val)
154
		{
155
			$oMemberAdminController->insertDeniedID($val->module,'');
156
		}
157
		$oMemberAdminController->insertDeniedID('www','');
158
		$oMemberAdminController->insertDeniedID('root','');
159
		$oMemberAdminController->insertDeniedID('administrator','');
160
		$oMemberAdminController->insertDeniedID('telnet','');
161
		$oMemberAdminController->insertDeniedID('ftp','');
162
		$oMemberAdminController->insertDeniedID('http','');
163
		// Create cache directory to use in the member module
164
		FileHandler::makeDir('./files/member_extra_info/image_name');
165
		FileHandler::makeDir('./files/member_extra_info/image_mark');
166
		FileHandler::makeDir('./files/member_extra_info/profile_image');
167
		FileHandler::makeDir('./files/member_extra_info/signature');
168
169
		// 2013. 11. 22 add menu when popup document menu called
170
		$oModuleController->insertTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after');
171
		$oModuleController->insertTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after');
172
173
		return new BaseObject();
174
	}
175
176
	/**
177
	 * a method to check if successfully installed
178
	 *
179
	 * @return boolean
180
	 */
181
	function checkUpdate()
182
	{
183
		$oDB = &DB::getInstance();
184
		$oModuleModel = getModel('module');
185
		$oModuleController = getController('module');
186
		$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
187
		if($oModuleModel->needUpdate($version_update_id))
188
		{
189
			// check member directory (11/08/2007 added)
190
			if(!is_dir("./files/member_extra_info")) return true;
191
			// check member directory (22/10/2007 added)
192
			if(!is_dir("./files/member_extra_info/profile_image")) return true;
193
			// Add a column(is_register) to "member_auth_mail" table (22/04/2008)
194
			$act = $oDB->isColumnExists("member_auth_mail", "is_register");
195
			if(!$act) return true;
196
			// Add a column(site_srl) to "member_group_member" table (11/15/2008)
197
			if(!$oDB->isColumnExists("member_group_member", "site_srl")) return true;
198
			if(!$oDB->isColumnExists("member_group", "site_srl")) return true;
199
			if($oDB->isIndexExists("member_group","uni_member_group_title")) return true;
200
201
			// Add a column for list_order (05/18/2011)
202
			if(!$oDB->isColumnExists("member_group", "list_order")) return true;
203
204
			// image_mark 추가 (2009. 02. 14)
205
			if(!$oDB->isColumnExists("member_group", "image_mark")) return true;
206
			// Add c column for password expiration date
207
			if(!$oDB->isColumnExists("member", "change_password_date")) return true;
208
209
			// Add columns of question and answer to verify a password
210
			if(!$oDB->isColumnExists("member", "find_account_question")) return true;
211
			if(!$oDB->isColumnExists("member", "find_account_answer")) return true;
212
213
			if(!$oDB->isColumnExists("member", "list_order")) return true;
214
			if(!$oDB->isIndexExists("member","idx_list_order")) return true;
215
216
			$oModuleModel = getModel('module');
217
			$config = $oModuleModel->getModuleConfig('member');
218
			// check signup form ordering info
219
			if(!$config->signupForm) return true;
220
221
			foreach($config->signupForm as $form)
222
			{
223
				if($form->name === 'email_address' && $form->isPublic !== 'N')
224
				{
225
					return true;
226
				}
227
			}
228
229
			// check agreement field exist
230
			if($config->agreement) return true;
231
232
			if($config->skin)
233
			{
234
				$config_parse = explode('.', $config->skin);
235
				if(count($config_parse) > 1)
236
				{
237
					$template_path = sprintf('./themes/%s/modules/member/', $config_parse[0]);
238
					if(is_dir($template_path)) return true;
239
				}
240
			}
241
242
			// supprot multilanguage agreement.
243
			if(is_readable('./files/member_extra_info/agreement.txt')) return true;
244
245
			// 2013. 11. 22 add menu when popup document menu called
246
			if(!$oModuleModel->getTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after')) return true;
247
			if(!$oModuleModel->getTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after')) return true;
248
249
			$oModuleController->insertUpdatedLog($version_update_id);
250
		}
251
252
		if(!is_readable('./files/ruleset/insertMember.xml')) return true;
253
		if(!is_readable('./files/ruleset/login.xml')) return true;
254
		if(!is_readable('./files/ruleset/find_member_account_by_question.xml')) return true;
255
256
		if($oModuleModel->needUpdate('member.1.8.43.recreate_signup_ruleset')) return true;
257
258
		return false;
259
	}
260
261
	/**
262
	 * Execute update
263
	 *
264
	 * @return BaseObject
265
	 */
266
	function moduleUpdate()
267
	{
268
		$oDB = &DB::getInstance();
269
		$oModuleModel = getModel('module');
270
		$oModuleController = getController('module');
271
		$oMemberAdminController = getAdminController('member');
272
		$config = $oModuleModel->getModuleConfig('member');
273
		$version_update_id = implode('.', array(__CLASS__, __XE_VERSION__, 'updated'));
274
		if($oModuleModel->needUpdate($version_update_id))
275
		{
276
			// Check member directory
277
			FileHandler::makeDir('./files/member_extra_info/image_name');
278
			FileHandler::makeDir('./files/member_extra_info/image_mark');
279
			FileHandler::makeDir('./files/member_extra_info/signature');
280
			FileHandler::makeDir('./files/member_extra_info/profile_image');
281
			// Add a column
282
			if(!$oDB->isColumnExists("member_auth_mail", "is_register"))
283
			{
284
				$oDB->addColumn("member_auth_mail", "is_register", "char", 1, "N", true);
285
			}
286
			// Add a column(site_srl) to "member_group_member" table (11/15/2008)
287
			if(!$oDB->isColumnExists("member_group_member", "site_srl"))
288
			{
289
				$oDB->addColumn("member_group_member", "site_srl", "number", 11, 0, true);
290
				$oDB->addIndex("member_group_member", "idx_site_srl", "site_srl", false);
291
			}
292 View Code Duplication
			if(!$oDB->isColumnExists("member_group", "site_srl"))
293
			{
294
				$oDB->addColumn("member_group", "site_srl", "number", 11, 0, true);
295
				$oDB->addIndex("member_group","idx_site_title", array("site_srl","title"),true);
296
			}
297
			if($oDB->isIndexExists("member_group","uni_member_group_title"))
298
			{
299
				$oDB->dropIndex("member_group","uni_member_group_title",true);
300
			}
301
302
			// Add a column(list_order) to "member_group" table (05/18/2011)
303 View Code Duplication
			if(!$oDB->isColumnExists("member_group", "list_order"))
304
			{
305
				$oDB->addColumn("member_group", "list_order", "number", 11, '', true);
306
				$oDB->addIndex("member_group","idx_list_order", "list_order",false);
307
				$output = executeQuery('member.updateAllMemberGroupListOrder');
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...
308
			}
309
			// Add a column for image_mark (02/14/2009)
310
			if(!$oDB->isColumnExists("member_group", "image_mark"))
311
			{
312
				$oDB->addColumn("member_group", "image_mark", "text");
313
			}
314
			// Add a column for password expiration date
315
			if(!$oDB->isColumnExists("member", "change_password_date"))
316
			{
317
				$oDB->addColumn("member", "change_password_date", "date");
318
				executeQuery('member.updateAllChangePasswordDate');
319
			}
320
321
			// Add columns of question and answer to verify a password
322
			if(!$oDB->isColumnExists("member", "find_account_question"))
323
			{
324
				$oDB->addColumn("member", "find_account_question", "number", 11);
325
			}
326
			if(!$oDB->isColumnExists("member", "find_account_answer"))
327
			{
328
				$oDB->addColumn("member", "find_account_answer", "varchar", 250);
329
			}
330
331
			if(!$oDB->isColumnExists("member", "list_order"))
332
			{
333
				$oDB->addColumn("member", "list_order", "number", 11);
334
				@set_time_limit(0);
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...
335
				$args->list_order = 'member_srl';
0 ignored issues
show
Bug introduced by
The variable $args does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
336
				executeQuery('member.updateMemberListOrderAll',$args);
337
				executeQuery('member.updateMemberListOrderAll');
338
			}
339
			if(!$oDB->isIndexExists("member","idx_list_order"))
340
			{
341
				$oDB->addIndex("member","idx_list_order", array("list_order"));
342
			}
343
344
			$config = $oModuleModel->getModuleConfig('member');
345
346
			// check agreement value exist
347
			if($config->agreement)
348
			{
349
				$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
350
				$output = FileHandler::writeFile($agreement_file, $config->agreement);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $output is correct as \FileHandler::writeFile(...le, $config->agreement) (which targets FileHandler::writeFile()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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...
351
352
				$config->agreement = NULL;
353
				$output = $oModuleController->updateModuleConfig('member', $config);
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...
354
			}
355
356
			// check signup form ordering info
357 View Code Duplication
			if(!$config->signupForm || !is_array($config->signupForm))
358
			{
359
				$identifier = 'email_address';
360
361
				$config->signupForm = $oMemberAdminController->createSignupForm($identifier);
362
				$config->identifier = $identifier;
363
				unset($config->agreement);
364
			}
365
366
			// 회원정보에서 이메일 노출 제거
367
			// @see https://github.com/xpressengine/xe-core/issues/2177
368
			foreach($config->signupForm as $form)
369
			{
370
				if($form->name === 'email_address')
371
				{
372
					$form->isPublic = 'N';
373
					break;
374
				}
375
			}
376
			$oModuleController->updateModuleConfig('member', $config);
377
378
			if($config->skin)
379
			{
380
				$config_parse = explode('.', $config->skin);
381
				if (count($config_parse) > 1)
382
				{
383
					$template_path = sprintf('./themes/%s/modules/member/', $config_parse[0]);
384
					if(is_dir($template_path))
385
					{
386
						$config->skin = implode('|@|', $config_parse);
387
						$oModuleController = getController('module');
388
						$oModuleController->updateModuleConfig('member', $config);
389
					}
390
				}
391
			}
392
			
393
			// 2013. 11. 22 add menu when popup document menu called
394
			if(!$oModuleModel->getTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after'))
395
				$oModuleController->insertTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after');
396
			if(!$oModuleModel->getTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after'))
397
				$oModuleController->insertTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after');
398
399
			if(is_readable('./files/member_extra_info/agreement.txt'))
400
			{
401
				$source_file = _XE_PATH_.'files/member_extra_info/agreement.txt';
402
				$target_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
403
404
				FileHandler::rename($source_file, $target_file);
405
			}
406
407
			$oModuleController->insertUpdatedLog($version_update_id);
408
		}
409
410
		FileHandler::makeDir('./files/ruleset');
411
		if(!is_readable('./files/ruleset/insertMember.xml'))
412
			$oMemberAdminController->_createSignupRuleset($config->signupForm);
413
		if(!is_readable('./files/ruleset/login.xml'))
414
			$oMemberAdminController->_createLoginRuleset($config->identifier);
415
		if(!is_readable('./files/ruleset/find_member_account_by_question.xml'))
416
			$oMemberAdminController->_createFindAccountByQuestion($config->identifier);
417
418
		if($oModuleModel->needUpdate('member.1.8.43.recreate_signup_ruleset'))
419
		{
420
			$oMemberAdminController->_createSignupRuleset($config->signupForm);
421
			$oModuleController->insertUpdatedLog('member.1.8.43.recreate_signup_ruleset');
422
		}
423
424
		return new BaseObject(0, 'success_updated');
425
	}
426
427
	/**
428
	 * Re-generate the cache file
429
	 *
430
	 * @return void
431
	 */
432
	function recompileCache()
433
	{
434
	}
435
436
	/**
437
	 * @brief Record login error and return the error, about IPaddress.
438
	 */
439
	function recordLoginError($error = 0, $message = 'success')
440
	{
441
		if($error == 0) return new BaseObject($error, $message);
442
443
		// Create a member model object
444
		$oMemberModel = getModel('member');
445
		$config = $oMemberModel->getMemberConfig();
446
447
		// Check if there is recoding table.
448
		$oDB = &DB::getInstance();
449
		if(!$oDB->isTableExists('member_login_count') || $config->enable_login_fail_report == 'N') return new BaseObject($error, $message);
450
451
		$args = new stdClass();
452
		$args->ipaddress = $_SERVER['REMOTE_ADDR'];
453
454
		$output = executeQuery('member.getLoginCountByIp', $args);
455
		if($output->data && $output->data->count)
456
		{
457
			$last_update = strtotime($output->data->last_update);
458
			$term = intval($_SERVER['REQUEST_TIME']-$last_update);
459
			//update, if IP address access in a short time, update count. If not, make count 1.
460
			if($term < $config->max_error_count_time)
461
			{
462
				$args->count = $output->data->count + 1;
463
			}
464
			else
465
			{
466
				$args->count = 1;
467
			}
468
			unset($oMemberModel);
469
			unset($config);
470
			$output = executeQuery('member.updateLoginCountByIp', $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...
471
		}
472
		else
473
		{
474
			//insert
475
			$args->count = 1;
476
			$output = executeQuery('member.insertLoginCountByIp', $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...
477
		}
478
		return new BaseObject($error, $message);
479
	}
480
481
	/**
482
	 * @brief Record login error and return the error, about MemberSrl.
483
	 */
484
	function recordMemberLoginError($error = 0, $message = 'success', $args = NULL)
485
	{
486
		if($error == 0 || !$args->member_srl) return new BaseObject($error, $message);
487
488
		// Create a member model object
489
		$oMemberModel = getModel('member');
490
		$config = $oMemberModel->getMemberConfig();
491
492
		// Check if there is recoding table.
493
		$oDB = &DB::getInstance();
494
		if(!$oDB->isTableExists('member_count_history') || $config->enable_login_fail_report == 'N') return new BaseObject($error, $message);
495
496
		$output = executeQuery('member.getLoginCountHistoryByMemberSrl', $args);
497
		if($output->data && $output->data->content)
498
		{
499
			//update
500
			$content = unserialize($output->data->content);
501
			$content[] = array($_SERVER['REMOTE_ADDR'],Context::getLang($message),$_SERVER['REQUEST_TIME']);
502
			$args->content = serialize($content);
503
			$output = executeQuery('member.updateLoginCountHistoryByMemberSrl', $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...
504
		}
505
		else
506
		{
507
			//insert
508
			$content[0] = array($_SERVER['REMOTE_ADDR'],Context::getLang($message),$_SERVER['REQUEST_TIME']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$content was never initialized. Although not strictly required by PHP, it is generally a good practice to add $content = 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...
509
			$args->content = serialize($content);
510
			$output = executeQuery('member.insertLoginCountHistoryByMemberSrl', $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...
511
		}
512
		return $this->recordLoginError($error, $message);
513
	}
514
}
515
/* End of file member.class.php */
516
/* Location: ./modules/member/member.class.php */
517