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
Pull Request — develop (#1930)
by
unknown
13:51
created

member::member()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 3
nop 0
dl 0
loc 14
rs 9.2
c 0
b 0
f 0
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 Object
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 Object();
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');
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...
185
		// check member directory (11/08/2007 added)
186
		if(!is_dir("./files/member_extra_info")) return true;
187
		// check member directory (22/10/2007 added)
188
		if(!is_dir("./files/member_extra_info/profile_image")) return true;
189
		// Add a column(is_register) to "member_auth_mail" table (22/04/2008)
190
		$act = $oDB->isColumnExists("member_auth_mail", "is_register");
191
		if(!$act) return true;
192
		// Add a column(site_srl) to "member_group_member" table (11/15/2008)
193
		if(!$oDB->isColumnExists("member_group_member", "site_srl")) return true;
194
		if(!$oDB->isColumnExists("member_group", "site_srl")) return true;
195
		if($oDB->isIndexExists("member_group","uni_member_group_title")) return true;
196
197
		// Add a column for list_order (05/18/2011)
198
		if(!$oDB->isColumnExists("member_group", "list_order")) return true;
199
200
		// image_mark 추가 (2009. 02. 14)
201
		if(!$oDB->isColumnExists("member_group", "image_mark")) return true;
202
		// Add c column for password expiration date
203
		if(!$oDB->isColumnExists("member", "change_password_date")) return true;
204
205
		// Add columns of question and answer to verify a password
206
		if(!$oDB->isColumnExists("member", "find_account_question")) return true;
207
		if(!$oDB->isColumnExists("member", "find_account_answer")) return true;
208
209
		if(!$oDB->isColumnExists("member", "list_order")) return true;
210
		if(!$oDB->isIndexExists("member","idx_list_order")) return true;
211
212
		$oModuleModel = getModel('module');
213
		$config = $oModuleModel->getModuleConfig('member');
214
		// check signup form ordering info
215
		if(!$config->signupForm) return true;
216
217
		// check agreement field exist
218
		if($config->agreement) return true;
219
220
		if($config->skin)
221
		{
222
			$config_parse = explode('.', $config->skin);
223
			if(count($config_parse) > 1)
224
			{
225
				$template_path = sprintf('./themes/%s/modules/member/', $config_parse[0]);
226
				if(is_dir($template_path)) return true;
227
			}
228
		}
229
230
		// supprot multilanguage agreement.
231
		if(is_readable('./files/member_extra_info/agreement.txt')) return true;
232
233
		if(!is_readable('./files/ruleset/insertMember.xml')) return true;
234
		if(!is_readable('./files/ruleset/login.xml')) return true;
235
		if(!is_readable('./files/ruleset/find_member_account_by_question.xml')) return true;
236
237
		// 2013. 11. 22 add menu when popup document menu called
238
		if(!$oModuleModel->getTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after')) return true;
239
		if(!$oModuleModel->getTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after')) return true;
240
241
		return false;
242
	}
243
244
	/**
245
	 * Execute update
246
	 *
247
	 * @return Object
248
	 */
249
	function moduleUpdate()
250
	{
251
		$oDB = &DB::getInstance();
252
		$oModuleController = getController('module');
0 ignored issues
show
Unused Code introduced by
$oModuleController 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...
253
		// Check member directory
254
		FileHandler::makeDir('./files/member_extra_info/image_name');
255
		FileHandler::makeDir('./files/member_extra_info/image_mark');
256
		FileHandler::makeDir('./files/member_extra_info/signature');
257
		FileHandler::makeDir('./files/member_extra_info/profile_image');
258
		// Add a column
259
		if(!$oDB->isColumnExists("member_auth_mail", "is_register"))
260
		{
261
			$oDB->addColumn("member_auth_mail", "is_register", "char", 1, "N", true);
262
		}
263
		// Add a column(site_srl) to "member_group_member" table (11/15/2008)
264
		if(!$oDB->isColumnExists("member_group_member", "site_srl"))
265
		{
266
			$oDB->addColumn("member_group_member", "site_srl", "number", 11, 0, true);
267
			$oDB->addIndex("member_group_member", "idx_site_srl", "site_srl", false);
268
		}
269 View Code Duplication
		if(!$oDB->isColumnExists("member_group", "site_srl"))
270
		{
271
			$oDB->addColumn("member_group", "site_srl", "number", 11, 0, true);
272
			$oDB->addIndex("member_group","idx_site_title", array("site_srl","title"),true);
273
		}
274
		if($oDB->isIndexExists("member_group","uni_member_group_title"))
275
		{
276
			$oDB->dropIndex("member_group","uni_member_group_title",true);
277
		}
278
279
		// Add a column(list_order) to "member_group" table (05/18/2011)
280 View Code Duplication
		if(!$oDB->isColumnExists("member_group", "list_order"))
281
		{
282
			$oDB->addColumn("member_group", "list_order", "number", 11, '', true);
283
			$oDB->addIndex("member_group","idx_list_order", "list_order",false);
284
			$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...
285
		}
286
		// Add a column for image_mark (02/14/2009)
287
		if(!$oDB->isColumnExists("member_group", "image_mark"))
288
		{
289
			$oDB->addColumn("member_group", "image_mark", "text");
290
		}
291
		// Add a column for password expiration date
292
		if(!$oDB->isColumnExists("member", "change_password_date"))
293
		{
294
			$oDB->addColumn("member", "change_password_date", "date");
295
			executeQuery('member.updateAllChangePasswordDate');
296
		}
297
298
		// Add columns of question and answer to verify a password
299
		if(!$oDB->isColumnExists("member", "find_account_question"))
300
		{
301
			$oDB->addColumn("member", "find_account_question", "number", 11);
302
		}
303
		if(!$oDB->isColumnExists("member", "find_account_answer"))
304
		{
305
			$oDB->addColumn("member", "find_account_answer", "varchar", 250);
306
		}
307
308
		if(!$oDB->isColumnExists("member", "list_order"))
309
		{
310
			$oDB->addColumn("member", "list_order", "number", 11);
311
			@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...
312
			$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...
313
			executeQuery('member.updateMemberListOrderAll',$args);
314
			executeQuery('member.updateMemberListOrderAll');
315
		}
316
		if(!$oDB->isIndexExists("member","idx_list_order"))
317
		{
318
			$oDB->addIndex("member","idx_list_order", array("list_order"));
319
		}
320
321
		$oModuleModel = getModel('module');
322
		$config = $oModuleModel->getModuleConfig('member');
323
		$oModuleController = getController('module');
324
325
		// check agreement value exist
326
		if($config->agreement)
327
		{
328
			$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
329
			$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...
330
331
			$config->agreement = NULL;
332
			$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...
333
		}
334
335
		$oMemberAdminController = getAdminController('member');
336
		// check signup form ordering info
337
		if(!$config->signupForm || !is_array($config->signupForm))
338
		{
339
			$identifier = 'user_id';
340
341
			$config->signupForm = $oMemberAdminController->createSignupForm($identifier);
342
			$config->identifier = $identifier;
343
			unset($config->agreement);
344
			$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...
345
		}
346
347
		if($config->skin)
348
		{
349
			$config_parse = explode('.', $config->skin);
350
			if (count($config_parse) > 1)
351
			{
352
				$template_path = sprintf('./themes/%s/modules/member/', $config_parse[0]);
353
				if(is_dir($template_path))
354
				{
355
					$config->skin = implode('|@|', $config_parse);
356
					$oModuleController = getController('module');
357
					$oModuleController->updateModuleConfig('member', $config);
358
				}
359
			}
360
		}
361
362
		if(is_readable('./files/member_extra_info/agreement.txt'))
363
		{
364
			$source_file = _XE_PATH_.'files/member_extra_info/agreement.txt';
365
			$target_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt';
366
367
			FileHandler::rename($source_file, $target_file);
368
		}
369
370
		FileHandler::makeDir('./files/ruleset');
371
		if(!is_readable('./files/ruleset/insertMember.xml'))
372
			$oMemberAdminController->_createSignupRuleset($config->signupForm);
373
		if(!is_readable('./files/ruleset/login.xml'))
374
			$oMemberAdminController->_createLoginRuleset($config->identifier);
375
		if(!is_readable('./files/ruleset/find_member_account_by_question.xml'))
376
			$oMemberAdminController->_createFindAccountByQuestion($config->identifier);
377
378
		// 2013. 11. 22 add menu when popup document menu called
379
		if(!$oModuleModel->getTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after'))
380
			$oModuleController->insertTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after');
381
		if(!$oModuleModel->getTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after'))
382
			$oModuleController->insertTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after');
383
384
		return new Object(0, 'success_updated');
385
	}
386
387
	/**
388
	 * Re-generate the cache file
389
	 *
390
	 * @return void
391
	 */
392
	function recompileCache()
393
	{
394
	}
395
396
	/**
397
	 * @brief Record login error and return the error, about IPaddress.
398
	 */
399
	function recordLoginError($error = 0, $message = 'success')
400
	{
401
		if($error == 0) return new Object($error, $message);
402
403
		// Create a member model object
404
		$oMemberModel = getModel('member');
405
		$config = $oMemberModel->getMemberConfig();
406
407
		// Check if there is recoding table.
408
		$oDB = &DB::getInstance();
409
		if(!$oDB->isTableExists('member_login_count') || $config->enable_login_fail_report == 'N') return new Object($error, $message);
410
411
		$args = new stdClass();
412
		$args->ipaddress = $_SERVER['REMOTE_ADDR'];
413
414
		$output = executeQuery('member.getLoginCountByIp', $args);
415
		if($output->data && $output->data->count)
416
		{
417
			$last_update = strtotime($output->data->last_update);
418
			$term = intval($_SERVER['REQUEST_TIME']-$last_update);
419
			//update, if IP address access in a short time, update count. If not, make count 1.
420
			if($term < $config->max_error_count_time)
421
			{
422
				$args->count = $output->data->count + 1;
423
			}
424
			else
425
			{
426
				$args->count = 1;
427
			}
428
			unset($oMemberModel);
429
			unset($config);
430
			$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...
431
		}
432
		else
433
		{
434
			//insert
435
			$args->count = 1;
436
			$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...
437
		}
438
		return new Object($error, $message);
439
	}
440
441
	/**
442
	 * @brief Record login error and return the error, about MemberSrl.
443
	 */
444
	function recordMemberLoginError($error = 0, $message = 'success', $args = NULL)
445
	{
446
		if($error == 0 || !$args->member_srl) return new Object($error, $message);
447
448
		// Create a member model object
449
		$oMemberModel = getModel('member');
450
		$config = $oMemberModel->getMemberConfig();
451
452
		// Check if there is recoding table.
453
		$oDB = &DB::getInstance();
454
		if(!$oDB->isTableExists('member_count_history') || $config->enable_login_fail_report == 'N') return new Object($error, $message);
455
456
		$output = executeQuery('member.getLoginCountHistoryByMemberSrl', $args);
457
		if($output->data && $output->data->content)
458
		{
459
			//update
460
			$content = unserialize($output->data->content);
461
			$content[] = array($_SERVER['REMOTE_ADDR'],Context::getLang($message),$_SERVER['REQUEST_TIME']);
462
			$args->content = serialize($content);
463
			$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...
464
		}
465
		else
466
		{
467
			//insert
468
			$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...
469
			$args->content = serialize($content);
470
			$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...
471
		}
472
		return $this->recordLoginError($error, $message);
473
	}
474
}
475
/* End of file member.class.php */
476
/* Location: ./modules/member/member.class.php */
477