XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
member.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
8 class member extends ModuleObject {
14  var $useSha1 = false;
15 
21  function __construct()
22  {
23  if(!Context::isInstalled()) return;
24 
25  $oModuleModel = getModel('module');
26  $member_config = $oModuleModel->getModuleConfig('member');
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 
41  function moduleInstall()
42  {
43  // Register action forward (to use in administrator mode)
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';
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);
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);
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);
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 
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 
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  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  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');
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);
335  $args->list_order = 'member_srl';
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);
351 
352  $config->agreement = NULL;
353  $output = $oModuleController->updateModuleConfig('member', $config);
354  }
355 
356  // check signup form ordering info
357  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 
432  function recompileCache()
433  {
434  }
435 
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);
471  }
472  else
473  {
474  //insert
475  $args->count = 1;
476  $output = executeQuery('member.insertLoginCountByIp', $args);
477  }
478  return new BaseObject($error, $message);
479  }
480 
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);
504  }
505  else
506  {
507  //insert
508  $content[0] = array($_SERVER['REMOTE_ADDR'],Context::getLang($message),$_SERVER['REQUEST_TIME']);
509  $args->content = serialize($content);
510  $output = executeQuery('member.insertLoginCountHistoryByMemberSrl', $args);
511  }
512  return $this->recordLoginError($error, $message);
513  }
514 }
515 /* End of file member.class.php */
516 /* Location: ./modules/member/member.class.php */
$oModuleModel
Definition: ko.install.php:236
getController($module_name)
Definition: func.inc.php:90
const __XE_VERSION__
Definition: config.inc.php:32
$template_path
a path of directory where template files reside
$output
Definition: ko.install.php:193
$act
a string value to contain the action name
writeFile($filename, $buff, $mode="w")
recompileCache()
moduleUpdate()
moduleInstall()
addSSLActions($action_array)
recordLoginError($error=0, $message= 'success')
Record login error and return the error, about IPaddress.
rename($source, $target)
$args
Definition: ko.install.php:185
getInstance($db_type=NULL)
Definition: DB.class.php:142
makeDir($path_string)
getLang($code)
const _XE_PATH_
Definition: config.inc.php:49
getModel($module_name)
Definition: func.inc.php:145
__construct()
getAdminController($module_name)
Definition: func.inc.php:101
executeQuery($query_id, $args=NULL, $arg_columns=NULL)
Definition: func.inc.php:203
$oModuleController
Definition: ko.install.php:287
recordMemberLoginError($error=0, $message= 'success', $args=NULL)
Record login error and return the error, about MemberSrl.
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23
isExistsSSLAction($action)