|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
|
3
|
|
|
/** |
|
4
|
|
|
* @class memberModel |
|
5
|
|
|
* @author NAVER ([email protected]) |
|
6
|
|
|
* @brief Model class of the member module |
|
7
|
|
|
*/ |
|
8
|
|
|
class memberModel extends member |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @brief Keep data internally which may be frequently called ... |
|
12
|
|
|
*/ |
|
13
|
|
|
var $join_form_list = NULL; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @brief Initialization |
|
17
|
|
|
*/ |
|
18
|
|
|
function init() |
|
19
|
|
|
{ |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @brief Return member's configuration |
|
24
|
|
|
*/ |
|
25
|
|
|
function getMemberConfig() |
|
26
|
|
|
{ |
|
27
|
|
|
static $member_config; |
|
28
|
|
|
|
|
29
|
|
|
if($member_config) |
|
30
|
|
|
{ |
|
31
|
|
|
return $member_config; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// Get member configuration stored in the DB |
|
35
|
|
|
$oModuleModel = getModel('module'); |
|
36
|
|
|
$config = $oModuleModel->getModuleConfig('member'); |
|
37
|
|
|
|
|
38
|
|
|
if(!$config->signupForm || !is_array($config->signupForm)) |
|
39
|
|
|
{ |
|
40
|
|
|
$oMemberAdminController = getAdminController('member'); |
|
41
|
|
|
$identifier = ($config->identifier) ? $config->identifier : 'email_address'; |
|
42
|
|
|
$config->signupForm = $oMemberAdminController->createSignupForm($identifier); |
|
43
|
|
|
} |
|
44
|
|
|
//for multi language |
|
45
|
|
|
foreach($config->signupForm AS $key=>$value) |
|
46
|
|
|
{ |
|
47
|
|
|
$config->signupForm[$key]->title = ($value->isDefaultForm) ? Context::getLang($value->name) : $value->title; |
|
48
|
|
|
if($config->signupForm[$key]->isPublic != 'N') $config->signupForm[$key]->isPublic = 'Y'; |
|
49
|
|
|
if($value->name == 'find_account_question') $config->signupForm[$key]->isPublic = 'N'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
// Get terms of user |
|
53
|
|
|
$config->agreement = memberModel::_getAgreement(); |
|
54
|
|
|
|
|
55
|
|
|
if(!$config->webmaster_name) $config->webmaster_name = 'webmaster'; |
|
56
|
|
|
if(!$config->image_name_max_width) $config->image_name_max_width = 90; |
|
57
|
|
|
if(!$config->image_name_max_height) $config->image_name_max_height = 20; |
|
58
|
|
|
if(!$config->image_mark_max_width) $config->image_mark_max_width = 20; |
|
59
|
|
|
if(!$config->image_mark_max_height) $config->image_mark_max_height = 20; |
|
60
|
|
|
if(!$config->profile_image_max_width) $config->profile_image_max_width = 90; |
|
61
|
|
|
if(!$config->profile_image_max_height) $config->profile_image_max_height = 90; |
|
62
|
|
|
if(!$config->skin) $config->skin = 'default'; |
|
63
|
|
|
if(!$config->colorset) $config->colorset = 'white'; |
|
64
|
|
|
if(!$config->editor_skin || $config->editor_skin == 'default') $config->editor_skin = 'ckeditor'; |
|
65
|
|
|
if(!$config->group_image_mark) $config->group_image_mark = "N"; |
|
66
|
|
|
|
|
67
|
|
|
if(!$config->identifier) $config->identifier = 'user_id'; |
|
68
|
|
|
|
|
69
|
|
|
if(!$config->max_error_count) $config->max_error_count = 10; |
|
70
|
|
|
if(!$config->max_error_count_time) $config->max_error_count_time = 300; |
|
71
|
|
|
|
|
72
|
|
|
if(!$config->signature_editor_skin || $config->signature_editor_skin == 'default') $config->signature_editor_skin = 'ckeditor'; |
|
73
|
|
|
if(!$config->sel_editor_colorset) $config->sel_editor_colorset = 'moono'; |
|
74
|
|
|
|
|
75
|
|
|
$member_config = $config; |
|
76
|
|
|
|
|
77
|
|
|
return $config; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
function _getAgreement() |
|
81
|
|
|
{ |
|
82
|
|
|
$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt'; |
|
83
|
|
|
if(is_readable($agreement_file)) |
|
84
|
|
|
{ |
|
85
|
|
|
return FileHandler::readFile($agreement_file); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
$db_info = Context::getDBInfo(); |
|
89
|
|
|
$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . $db_info->lang_type . '.txt'; |
|
90
|
|
|
if(is_readable($agreement_file)) |
|
91
|
|
|
{ |
|
92
|
|
|
return FileHandler::readFile($agreement_file); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
$lang_selected = Context::loadLangSelected(); |
|
96
|
|
|
foreach($lang_selected as $key => $val) |
|
|
|
|
|
|
97
|
|
|
{ |
|
98
|
|
|
$agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . $key . '.txt'; |
|
99
|
|
|
if(is_readable($agreement_file)) |
|
100
|
|
|
{ |
|
101
|
|
|
return FileHandler::readFile($agreement_file); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
return null; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @brief Display menus of the member |
|
110
|
|
|
*/ |
|
111
|
|
|
function getMemberMenu() |
|
112
|
|
|
{ |
|
113
|
|
|
// Get member_srl of he target member and logged info of the current user |
|
114
|
|
|
$member_srl = Context::get('target_srl'); |
|
115
|
|
|
$mid = Context::get('cur_mid'); |
|
116
|
|
|
$logged_info = Context::get('logged_info'); |
|
117
|
|
|
$act = Context::get('cur_act'); |
|
|
|
|
|
|
118
|
|
|
// When click user's own nickname |
|
119
|
|
|
if($member_srl == $logged_info->member_srl) $member_info = $logged_info; |
|
120
|
|
|
// When click other's nickname |
|
121
|
|
|
else $member_info = $this->getMemberInfoByMemberSrl($member_srl); |
|
122
|
|
|
|
|
123
|
|
|
$member_srl = $member_info->member_srl; |
|
124
|
|
|
if(!$member_srl) return; |
|
125
|
|
|
// List variables |
|
126
|
|
|
$user_id = $member_info->user_id; |
|
|
|
|
|
|
127
|
|
|
$user_name = $member_info->user_name; |
|
|
|
|
|
|
128
|
|
|
|
|
129
|
|
|
ModuleHandler::triggerCall('member.getMemberMenu', 'before', $null); |
|
130
|
|
|
|
|
131
|
|
|
$oMemberController = getController('member'); |
|
132
|
|
|
// Display member information (Don't display to non-logged user) |
|
133
|
|
|
if($logged_info->member_srl) |
|
134
|
|
|
{ |
|
135
|
|
|
$url = getUrl('','mid',$mid,'act','dispMemberInfo','member_srl',$member_srl); |
|
136
|
|
|
$oMemberController->addMemberPopupMenu($url,'cmd_view_member_info',$icon_path,'self'); |
|
|
|
|
|
|
137
|
|
|
} |
|
138
|
|
|
// When click other's nickname |
|
139
|
|
|
if($member_srl != $logged_info->member_srl && $logged_info->member_srl) |
|
140
|
|
|
{ |
|
141
|
|
|
// Get email config |
|
142
|
|
|
foreach($this->module_config->signupForm as $field) |
|
143
|
|
|
{ |
|
144
|
|
|
if($field->name == 'email_address') |
|
145
|
|
|
{ |
|
146
|
|
|
$email_config = $field; |
|
147
|
|
|
break; |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
// Send an email only if email address is public |
|
152
|
|
|
if(($logged_info->is_admin == 'Y' || $email_config->isPublic == 'Y') && $member_info->email_address) |
|
|
|
|
|
|
153
|
|
|
{ |
|
154
|
|
|
$url = 'mailto:'.htmlspecialchars($member_info->email_address, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
|
155
|
|
|
$oMemberController->addMemberPopupMenu($url,'cmd_send_email',$icon_path); |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
// View homepage info |
|
159
|
|
|
if($member_info->homepage) |
|
160
|
|
|
$oMemberController->addMemberPopupMenu(htmlspecialchars($member_info->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 'homepage', '', 'blank'); |
|
161
|
|
|
// View blog info |
|
162
|
|
|
if($member_info->blog) |
|
163
|
|
|
$oMemberController->addMemberPopupMenu(htmlspecialchars($member_info->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 'blog', '', 'blank'); |
|
164
|
|
|
// Call a trigger (after) |
|
165
|
|
|
ModuleHandler::triggerCall('member.getMemberMenu', 'after', $null); |
|
166
|
|
|
// Display a menu for editting member info to a top administrator |
|
167
|
|
|
if($logged_info->is_admin == 'Y') |
|
168
|
|
|
{ |
|
169
|
|
|
$url = getUrl('','module','admin','act','dispMemberAdminInsert','member_srl',$member_srl); |
|
170
|
|
|
$oMemberController->addMemberPopupMenu($url,'cmd_manage_member_info',$icon_path,'MemberModifyInfo'); |
|
171
|
|
|
|
|
172
|
|
|
$url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','member_srl','search_keyword',$member_srl); |
|
173
|
|
|
$oMemberController->addMemberPopupMenu($url,'cmd_trace_document',$icon_path,'TraceMemberDocument'); |
|
174
|
|
|
|
|
175
|
|
|
$url = getUrl('','module','admin','act','dispCommentAdminList','search_target','member_srl','search_keyword',$member_srl); |
|
176
|
|
|
$oMemberController->addMemberPopupMenu($url,'cmd_trace_comment',$icon_path,'TraceMemberComment'); |
|
177
|
|
|
} |
|
178
|
|
|
// Change a language of pop-up menu |
|
179
|
|
|
$menus = Context::get('member_popup_menu_list'); |
|
180
|
|
|
$menus_count = count($menus); |
|
181
|
|
View Code Duplication |
for($i=0;$i<$menus_count;$i++) |
|
182
|
|
|
{ |
|
183
|
|
|
$menus[$i]->str = Context::getLang($menus[$i]->str); |
|
184
|
|
|
} |
|
185
|
|
|
// Get a list of finalized pop-up menu |
|
186
|
|
|
$this->add('menus', $menus); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @brief Check if logged-in |
|
191
|
|
|
*/ |
|
192
|
|
|
function isLogged() { |
|
193
|
|
|
if($_SESSION['is_logged']) |
|
194
|
|
|
{ |
|
195
|
|
|
if(Mobile::isFromMobilePhone()) |
|
196
|
|
|
{ |
|
197
|
|
|
return true; |
|
198
|
|
|
} |
|
199
|
|
|
elseif(filter_var($_SESSION['ipaddress'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) |
|
200
|
|
|
{ |
|
201
|
|
|
// IPv6: require same /48 |
|
202
|
|
|
if(strncmp(inet_pton($_SESSION['ipaddress']), inet_pton($_SERVER['REMOTE_ADDR']), 6) == 0) |
|
203
|
|
|
{ |
|
204
|
|
|
return true; |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
else |
|
208
|
|
|
{ |
|
209
|
|
|
// IPv4: require same /24 |
|
210
|
|
|
if(ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8) |
|
211
|
|
|
{ |
|
212
|
|
|
return true; |
|
213
|
|
|
} |
|
214
|
|
|
} |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
$_SESSION['is_logged'] = false; |
|
218
|
|
|
return false; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* @brief Return session information of the logged-in user |
|
223
|
|
|
*/ |
|
224
|
|
|
function getLoggedInfo() |
|
225
|
|
|
{ |
|
226
|
|
|
// Return session info if session info is requested and the user is logged-in |
|
227
|
|
|
if($this->isLogged()) |
|
228
|
|
|
{ |
|
229
|
|
|
$logged_info = Context::get('logged_info'); |
|
230
|
|
|
// Admin/Group list defined depending on site_module_info |
|
231
|
|
|
$site_module_info = Context::get('site_module_info'); |
|
232
|
|
|
if($site_module_info->site_srl) |
|
233
|
|
|
{ |
|
234
|
|
|
$logged_info->group_list = $this->getMemberGroups($logged_info->member_srl, $site_module_info->site_srl); |
|
235
|
|
|
// Add is_site_admin bool variable into logged_info if site_administrator is |
|
236
|
|
|
$oModuleModel = getModel('module'); |
|
237
|
|
|
if($oModuleModel->isSiteAdmin($logged_info)) $logged_info->is_site_admin = true; |
|
238
|
|
|
else $logged_info->is_site_admin = false; |
|
239
|
|
|
} |
|
240
|
|
|
else |
|
241
|
|
|
{ |
|
242
|
|
|
// Register a default group if the site doesn't have a member group |
|
243
|
|
|
if(count($logged_info->group_list) === 0) |
|
244
|
|
|
{ |
|
245
|
|
|
$default_group = $this->getDefaultGroup(0); |
|
246
|
|
|
$oMemberController = getController('member'); |
|
247
|
|
|
$oMemberController->addMemberToGroup($logged_info->member_srl, $default_group->group_srl, 0); |
|
248
|
|
|
$groups[$default_group->group_srl] = $default_group->title; |
|
|
|
|
|
|
249
|
|
|
$logged_info->group_list = $groups; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
$logged_info->is_site_admin = false; |
|
253
|
|
|
} |
|
254
|
|
|
Context::set('logged_info', $logged_info); |
|
255
|
|
|
|
|
256
|
|
|
return $logged_info; |
|
257
|
|
|
} |
|
258
|
|
|
return NULL; |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* @brief Return member information with user_id |
|
263
|
|
|
*/ |
|
264
|
|
|
function getMemberInfoByUserID($user_id, $columnList = array()) |
|
|
|
|
|
|
265
|
|
|
{ |
|
266
|
|
|
if(!$user_id) return; |
|
267
|
|
|
|
|
268
|
|
|
$args = new stdClass; |
|
269
|
|
|
$args->user_id = $user_id; |
|
270
|
|
|
$output = executeQuery('member.getMemberInfo', $args); |
|
271
|
|
|
if(!$output->toBool()) return $output; |
|
272
|
|
|
if(!$output->data) return; |
|
273
|
|
|
|
|
274
|
|
|
$member_info = $this->arrangeMemberInfo($output->data); |
|
275
|
|
|
|
|
276
|
|
|
return $member_info; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @brief Return member information with email_address |
|
281
|
|
|
*/ |
|
282
|
|
|
function getMemberInfoByEmailAddress($email_address) |
|
283
|
|
|
{ |
|
284
|
|
|
if(!$email_address) return; |
|
285
|
|
|
|
|
286
|
|
|
$args = new stdClass(); |
|
287
|
|
|
|
|
288
|
|
|
$db_info = Context::getDBInfo (); |
|
289
|
|
|
if($db_info->master_db['db_type'] == "cubrid") |
|
290
|
|
|
{ |
|
291
|
|
|
$args->email_address = strtolower($email_address); |
|
292
|
|
|
$output = executeQuery('member.getMemberInfoByEmailAddressForCubrid', $args); |
|
293
|
|
|
} |
|
294
|
|
|
else |
|
295
|
|
|
{ |
|
296
|
|
|
$args->email_address = $email_address; |
|
297
|
|
|
$output = executeQuery('member.getMemberInfoByEmailAddress', $args); |
|
298
|
|
|
} |
|
299
|
|
|
|
|
300
|
|
|
if(!$output->toBool()) return $output; |
|
301
|
|
|
if(!$output->data) return; |
|
302
|
|
|
|
|
303
|
|
|
$member_info = $this->arrangeMemberInfo($output->data); |
|
304
|
|
|
return $member_info; |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @brief Return member information with member_srl |
|
309
|
|
|
*/ |
|
310
|
|
|
function getMemberInfoByMemberSrl($member_srl, $site_srl = 0, $columnList = array()) |
|
311
|
|
|
{ |
|
312
|
|
|
if(!$member_srl) return; |
|
313
|
|
|
|
|
314
|
|
|
//columnList size zero... get full member info |
|
315
|
|
|
if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0) |
|
316
|
|
|
{ |
|
317
|
|
|
$GLOBALS['__member_info__'][$member_srl] = false; |
|
318
|
|
|
|
|
319
|
|
|
$oCacheHandler = CacheHandler::getInstance('object'); |
|
320
|
|
|
if($oCacheHandler->isSupport()) |
|
321
|
|
|
{ |
|
322
|
|
|
$columnList = array(); |
|
323
|
|
|
$object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl; |
|
324
|
|
|
$cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
|
325
|
|
|
$GLOBALS['__member_info__'][$member_srl] = $oCacheHandler->get($cache_key); |
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
if($GLOBALS['__member_info__'][$member_srl] === false) |
|
329
|
|
|
{ |
|
330
|
|
|
$args = new stdClass(); |
|
331
|
|
|
$args->member_srl = $member_srl; |
|
332
|
|
|
$output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList); |
|
333
|
|
|
if(!$output->data) |
|
334
|
|
|
{ |
|
335
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, new stdClass); |
|
|
|
|
|
|
336
|
|
|
return; |
|
337
|
|
|
} |
|
338
|
|
|
$this->arrangeMemberInfo($output->data, $site_srl); |
|
339
|
|
|
|
|
340
|
|
|
//insert in cache |
|
341
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $GLOBALS['__member_info__'][$member_srl]); |
|
342
|
|
|
} |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
return $GLOBALS['__member_info__'][$member_srl]; |
|
346
|
|
|
} |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* @brief Add member info from extra_vars and other information |
|
350
|
|
|
*/ |
|
351
|
|
|
function arrangeMemberInfo($info, $site_srl = 0) |
|
352
|
|
|
{ |
|
353
|
|
|
if(!$GLOBALS['__member_info__'][$info->member_srl]) |
|
354
|
|
|
{ |
|
355
|
|
|
$oModuleModel = getModel('module'); |
|
356
|
|
|
$config = $oModuleModel->getModuleConfig('member'); |
|
357
|
|
|
|
|
358
|
|
|
|
|
359
|
|
|
$info->profile_image = $this->getProfileImage($info->member_srl); |
|
360
|
|
|
$info->image_name = $this->getImageName($info->member_srl); |
|
361
|
|
|
$info->image_mark = $this->getImageMark($info->member_srl); |
|
362
|
|
|
if($config->group_image_mark=='Y') |
|
363
|
|
|
{ |
|
364
|
|
|
$info->group_mark = $this->getGroupImageMark($info->member_srl,$site_srl); |
|
365
|
|
|
} |
|
366
|
|
|
$info->signature = $this->getSignature($info->member_srl); |
|
367
|
|
|
$info->group_list = $this->getMemberGroups($info->member_srl, $site_srl); |
|
368
|
|
|
|
|
369
|
|
|
$extra_vars = unserialize($info->extra_vars); |
|
370
|
|
|
unset($info->extra_vars); |
|
371
|
|
|
if($extra_vars) |
|
372
|
|
|
{ |
|
373
|
|
|
foreach($extra_vars as $key => $val) |
|
374
|
|
|
{ |
|
375
|
|
View Code Duplication |
if(!is_array($val) && strpos($val, '|@|') !== FALSE) $val = explode('|@|', $val); |
|
376
|
|
|
if(!$info->{$key}) $info->{$key} = $val; |
|
377
|
|
|
} |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
if(strlen($info->find_account_answer) == 32 && preg_match('/[a-zA-Z0-9]+/', $info->find_account_answer)) |
|
381
|
|
|
{ |
|
382
|
|
|
$info->find_account_answer = null; |
|
383
|
|
|
} |
|
384
|
|
|
|
|
385
|
|
|
// XSS defence |
|
386
|
|
|
$oSecurity = new Security($info); |
|
387
|
|
|
$oSecurity->encodeHTML('user_id', 'user_name', 'nick_name', 'find_account_answer', 'description', 'address.', 'group_list..'); |
|
388
|
|
|
|
|
389
|
|
|
$info->homepage = strip_tags($info->homepage); |
|
390
|
|
|
$info->blog = strip_tags($info->blog); |
|
391
|
|
|
|
|
392
|
|
|
if($extra_vars) |
|
393
|
|
|
{ |
|
394
|
|
|
foreach($extra_vars as $key => $val) |
|
395
|
|
|
{ |
|
396
|
|
|
if(is_array($val)) |
|
397
|
|
|
{ |
|
398
|
|
|
$oSecurity->encodeHTML($key . '.'); |
|
399
|
|
|
} |
|
400
|
|
|
else |
|
401
|
|
|
{ |
|
402
|
|
|
$oSecurity->encodeHTML($key); |
|
403
|
|
|
} |
|
404
|
|
|
} |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
// Check format. |
|
408
|
|
|
$oValidator = new Validator(); |
|
409
|
|
|
if(!$oValidator->applyRule('url', $info->homepage)) |
|
410
|
|
|
{ |
|
411
|
|
|
$info->homepage = ''; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
if(!$oValidator->applyRule('url', $info->blog)) |
|
415
|
|
|
{ |
|
416
|
|
|
$info->blog = ''; |
|
417
|
|
|
} |
|
418
|
|
|
|
|
419
|
|
|
$GLOBALS['__member_info__'][$info->member_srl] = $info; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
return $GLOBALS['__member_info__'][$info->member_srl]; |
|
423
|
|
|
} |
|
424
|
|
|
|
|
425
|
|
|
/** |
|
426
|
|
|
* @brief Get member_srl corresponding to userid |
|
427
|
|
|
*/ |
|
428
|
|
|
function getMemberSrlByUserID($user_id) |
|
429
|
|
|
{ |
|
430
|
|
|
$args = new stdClass(); |
|
431
|
|
|
$args->user_id = $user_id; |
|
432
|
|
|
$output = executeQuery('member.getMemberSrl', $args); |
|
433
|
|
|
return $output->data->member_srl; |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
/** |
|
437
|
|
|
* @brief Get member_srl corresponding to EmailAddress |
|
438
|
|
|
*/ |
|
439
|
|
|
function getMemberSrlByEmailAddress($email_address) |
|
440
|
|
|
{ |
|
441
|
|
|
$args = new stdClass(); |
|
442
|
|
|
$args->email_address = $email_address; |
|
443
|
|
|
$output = executeQuery('member.getMemberSrl', $args); |
|
444
|
|
|
return $output->data->member_srl; |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* @brief Get member_srl corresponding to nickname |
|
449
|
|
|
*/ |
|
450
|
|
|
function getMemberSrlByNickName($nick_name) |
|
451
|
|
|
{ |
|
452
|
|
|
$args = new stdClass(); |
|
453
|
|
|
$args->nick_name = $nick_name; |
|
454
|
|
|
$output = executeQuery('member.getMemberSrl', $args); |
|
455
|
|
|
return $output->data->member_srl; |
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
/** |
|
459
|
|
|
* @brief Return member_srl of the current logged-in user |
|
460
|
|
|
*/ |
|
461
|
|
|
function getLoggedMemberSrl() |
|
462
|
|
|
{ |
|
463
|
|
|
if(!$this->isLogged()) return; |
|
464
|
|
|
return $_SESSION['member_srl']; |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* @brief Return user_id of the current logged-in user |
|
469
|
|
|
*/ |
|
470
|
|
|
function getLoggedUserID() |
|
471
|
|
|
{ |
|
472
|
|
|
if(!$this->isLogged()) return; |
|
473
|
|
|
$logged_info = Context::get('logged_info'); |
|
474
|
|
|
return $logged_info->user_id; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* @brief Get a list of groups which the member_srl belongs to |
|
479
|
|
|
*/ |
|
480
|
|
|
function getMemberGroups($member_srl, $site_srl = 0, $force_reload = false) |
|
481
|
|
|
{ |
|
482
|
|
|
static $member_groups = array(); |
|
483
|
|
|
|
|
484
|
|
|
// cache controll |
|
485
|
|
|
$group_list = false; |
|
486
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
|
487
|
|
View Code Duplication |
if($oCacheHandler->isSupport()) |
|
488
|
|
|
{ |
|
489
|
|
|
$object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_'.$site_srl; |
|
490
|
|
|
$cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
|
491
|
|
|
$group_list = $oCacheHandler->get($cache_key); |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
|
|
if(!$member_groups[$member_srl][$site_srl] || $force_reload) |
|
495
|
|
|
{ |
|
496
|
|
|
if($group_list === false) |
|
497
|
|
|
{ |
|
498
|
|
|
$args = new stdClass(); |
|
499
|
|
|
$args->member_srl = $member_srl; |
|
500
|
|
|
$args->site_srl = $site_srl; |
|
501
|
|
|
$output = executeQueryArray('member.getMemberGroups', $args); |
|
502
|
|
|
$group_list = $output->data; |
|
503
|
|
|
//insert in cache |
|
504
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list); |
|
|
|
|
|
|
505
|
|
|
} |
|
506
|
|
|
if(!$group_list) return array(); |
|
507
|
|
|
|
|
508
|
|
|
foreach($group_list as $group) |
|
509
|
|
|
{ |
|
510
|
|
|
$result[$group->group_srl] = $group->title; |
|
|
|
|
|
|
511
|
|
|
} |
|
512
|
|
|
$member_groups[$member_srl][$site_srl] = $result; |
|
|
|
|
|
|
513
|
|
|
} |
|
514
|
|
|
return $member_groups[$member_srl][$site_srl]; |
|
515
|
|
|
} |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
|
|
* @brief Get a list of groups which member_srls belong to |
|
519
|
|
|
*/ |
|
520
|
|
|
function getMembersGroups($member_srls, $site_srl = 0) |
|
521
|
|
|
{ |
|
522
|
|
|
$args->member_srls = implode(',',$member_srls); |
|
|
|
|
|
|
523
|
|
|
$args->site_srl = $site_srl; |
|
524
|
|
|
$args->sort_index = 'list_order'; |
|
525
|
|
|
$output = executeQueryArray('member.getMembersGroups', $args); |
|
526
|
|
|
if(!$output->data) return array(); |
|
527
|
|
|
|
|
528
|
|
|
$result = array(); |
|
529
|
|
|
foreach($output->data as $key=>$val) |
|
530
|
|
|
{ |
|
531
|
|
|
$result[$val->member_srl][] = $val->title; |
|
532
|
|
|
} |
|
533
|
|
|
return $result; |
|
534
|
|
|
} |
|
535
|
|
|
|
|
536
|
|
|
/** |
|
537
|
|
|
* @brief Get a default group |
|
538
|
|
|
*/ |
|
539
|
|
|
function getDefaultGroup($site_srl = 0, $columnList = array()) |
|
540
|
|
|
{ |
|
541
|
|
|
$default_group = false; |
|
542
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
|
543
|
|
|
if($oCacheHandler->isSupport()) |
|
544
|
|
|
{ |
|
545
|
|
|
$columnList = array(); |
|
546
|
|
|
$object_key = 'default_group_' . $site_srl; |
|
547
|
|
|
$cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
|
548
|
|
|
$default_group = $oCacheHandler->get($cache_key); |
|
549
|
|
|
} |
|
550
|
|
|
|
|
551
|
|
|
if($default_group === false) |
|
552
|
|
|
{ |
|
553
|
|
|
$args = new stdClass(); |
|
554
|
|
|
$args->site_srl = $site_srl; |
|
555
|
|
|
$output = executeQuery('member.getDefaultGroup', $args, $columnList); |
|
556
|
|
|
$default_group = $output->data; |
|
557
|
|
|
if($oCacheHandler->isSupport()) |
|
558
|
|
|
{ |
|
559
|
|
|
$oCacheHandler->put($cache_key, $default_group); |
|
|
|
|
|
|
560
|
|
|
} |
|
561
|
|
|
} |
|
562
|
|
|
|
|
563
|
|
|
return $default_group; |
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
/** |
|
567
|
|
|
* @brief Get an admin group |
|
568
|
|
|
*/ |
|
569
|
|
|
function getAdminGroup($columnList = array()) |
|
570
|
|
|
{ |
|
571
|
|
|
$output = executeQuery('member.getAdminGroup', $args, $columnList); |
|
|
|
|
|
|
572
|
|
|
return $output->data; |
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
/** |
|
576
|
|
|
* @brief Get group info corresponding to group_srl |
|
577
|
|
|
*/ |
|
578
|
|
|
function getGroup($group_srl, $columnList = array()) |
|
579
|
|
|
{ |
|
580
|
|
|
$args = new stdClass; |
|
581
|
|
|
$args->group_srl = $group_srl; |
|
582
|
|
|
$output = executeQuery('member.getGroup', $args, $columnList); |
|
583
|
|
|
return $output->data; |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
/** |
|
587
|
|
|
* @brief Get a list of groups |
|
588
|
|
|
*/ |
|
589
|
|
|
function getGroups($site_srl = 0) |
|
590
|
|
|
{ |
|
591
|
|
|
if(!$GLOBALS['__group_info__'][$site_srl]) |
|
592
|
|
|
{ |
|
593
|
|
|
$result = array(); |
|
594
|
|
|
|
|
595
|
|
|
if(!isset($site_srl)) |
|
596
|
|
|
{ |
|
597
|
|
|
$site_srl = 0; |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
$group_list = false; |
|
601
|
|
|
$oCacheHandler = CacheHandler::getInstance('object', null, true); |
|
602
|
|
|
if($oCacheHandler->isSupport()) |
|
603
|
|
|
{ |
|
604
|
|
|
$object_key = 'member_groups:site_'.$site_srl; |
|
605
|
|
|
$cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
|
606
|
|
|
$group_list = $oCacheHandler->get($cache_key); |
|
607
|
|
|
} |
|
608
|
|
|
|
|
609
|
|
|
if($group_list === false) |
|
610
|
|
|
{ |
|
611
|
|
|
$args = new stdClass(); |
|
612
|
|
|
$args->site_srl = $site_srl; |
|
613
|
|
|
$args->sort_index = 'list_order'; |
|
614
|
|
|
$args->order_type = 'asc'; |
|
615
|
|
|
$output = executeQueryArray('member.getGroups', $args); |
|
616
|
|
|
$group_list = $output->data; |
|
617
|
|
|
//insert in cache |
|
618
|
|
|
if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list); |
|
|
|
|
|
|
619
|
|
|
} |
|
620
|
|
|
|
|
621
|
|
|
if(!$group_list) |
|
622
|
|
|
{ |
|
623
|
|
|
return array(); |
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
|
|
627
|
|
|
foreach($group_list as $val) |
|
628
|
|
|
{ |
|
629
|
|
|
$result[$val->group_srl] = $val; |
|
630
|
|
|
} |
|
631
|
|
|
|
|
632
|
|
|
$GLOBALS['__group_info__'][$site_srl] = $result; |
|
633
|
|
|
} |
|
634
|
|
|
return $GLOBALS['__group_info__'][$site_srl]; |
|
635
|
|
|
} |
|
636
|
|
|
|
|
637
|
|
|
public function getApiGroups() |
|
638
|
|
|
{ |
|
639
|
|
|
$siteSrl = Context::get('siteSrl'); |
|
640
|
|
|
$groupInfo = $this->getGroups($siteSrl); |
|
641
|
|
|
|
|
642
|
|
|
$this->add($groupInfo); |
|
|
|
|
|
|
643
|
|
|
} |
|
644
|
|
|
|
|
645
|
|
|
/** |
|
646
|
|
|
* @brief Get a list of member join forms |
|
647
|
|
|
* |
|
648
|
|
|
* This method works as an extend filter of modules/member/tpl/filter/insert.xml. |
|
649
|
|
|
* To use as extend_filter, the argument should be boolean. |
|
650
|
|
|
* When the argument is true, it returns object result in type of filter. |
|
651
|
|
|
*/ |
|
652
|
|
|
function getJoinFormList($filter_response = false) |
|
653
|
|
|
{ |
|
654
|
|
|
global $lang; |
|
655
|
|
|
// Set to ignore if a super administrator. |
|
656
|
|
|
$logged_info = Context::get('logged_info'); |
|
657
|
|
|
|
|
658
|
|
|
if(!$this->join_form_list) |
|
659
|
|
|
{ |
|
660
|
|
|
// Argument setting to sort list_order column |
|
661
|
|
|
$args = new stdClass(); |
|
662
|
|
|
$args->sort_index = "list_order"; |
|
663
|
|
|
$output = executeQuery('member.getJoinFormList', $args); |
|
664
|
|
|
// NULL if output data deosn't exist |
|
665
|
|
|
$join_form_list = $output->data; |
|
666
|
|
|
if(!$join_form_list) return NULL; |
|
667
|
|
|
// Need to unserialize because serialized array is inserted into DB in case of default_value |
|
668
|
|
|
if(!is_array($join_form_list)) $join_form_list = array($join_form_list); |
|
669
|
|
|
$join_form_count = count($join_form_list); |
|
670
|
|
|
for($i=0;$i<$join_form_count;$i++) |
|
671
|
|
|
{ |
|
672
|
|
|
$join_form_list[$i]->column_name = strtolower($join_form_list[$i]->column_name); |
|
673
|
|
|
|
|
674
|
|
|
$member_join_form_srl = $join_form_list[$i]->member_join_form_srl; |
|
675
|
|
|
$column_type = $join_form_list[$i]->column_type; |
|
676
|
|
|
$column_name = $join_form_list[$i]->column_name; |
|
677
|
|
|
$column_title = $join_form_list[$i]->column_title; |
|
678
|
|
|
$default_value = $join_form_list[$i]->default_value; |
|
679
|
|
|
// Add language variable |
|
680
|
|
|
$lang->extend_vars[$column_name] = $column_title; |
|
681
|
|
|
// unserialize if the data type if checkbox, select and so on |
|
682
|
|
|
if(in_array($column_type, array('checkbox','select','radio'))) |
|
683
|
|
|
{ |
|
684
|
|
|
$join_form_list[$i]->default_value = unserialize($default_value); |
|
685
|
|
|
if(!$join_form_list[$i]->default_value[0]) $join_form_list[$i]->default_value = ''; |
|
686
|
|
|
} |
|
687
|
|
|
else |
|
688
|
|
|
{ |
|
689
|
|
|
$join_form_list[$i]->default_value = ''; |
|
690
|
|
|
} |
|
691
|
|
|
|
|
692
|
|
|
$list[$member_join_form_srl] = $join_form_list[$i]; |
|
|
|
|
|
|
693
|
|
|
} |
|
694
|
|
|
$this->join_form_list = $list; |
|
|
|
|
|
|
695
|
|
|
} |
|
696
|
|
|
// Get object style if the filter_response is true |
|
697
|
|
|
if($filter_response && count($this->join_form_list)) |
|
698
|
|
|
{ |
|
699
|
|
|
foreach($this->join_form_list as $key => $val) |
|
700
|
|
|
{ |
|
701
|
|
|
if($val->is_active != 'Y') continue; |
|
702
|
|
|
unset($obj); |
|
703
|
|
|
$obj->type = $val->column_type; |
|
|
|
|
|
|
704
|
|
|
$obj->name = $val->column_name; |
|
705
|
|
|
$obj->lang = $val->column_title; |
|
706
|
|
|
if($logged_info->is_admin != 'Y') $obj->required = $val->required=='Y'?true:false; |
|
707
|
|
|
else $obj->required = false; |
|
708
|
|
|
$filter_output[] = $obj; |
|
|
|
|
|
|
709
|
|
|
|
|
710
|
|
|
unset($open_obj); |
|
711
|
|
|
$open_obj->name = 'open_'.$val->column_name; |
|
|
|
|
|
|
712
|
|
|
$open_obj->required = false; |
|
713
|
|
|
$filter_output[] = $open_obj; |
|
714
|
|
|
|
|
715
|
|
|
} |
|
716
|
|
|
return $filter_output; |
|
|
|
|
|
|
717
|
|
|
} |
|
718
|
|
|
// Return the result |
|
719
|
|
|
return $this->join_form_list; |
|
720
|
|
|
} |
|
721
|
|
|
|
|
722
|
|
|
/** |
|
723
|
|
|
* get used join form list. |
|
724
|
|
|
* |
|
725
|
|
|
* @return array $joinFormList |
|
726
|
|
|
*/ |
|
727
|
|
|
function getUsedJoinFormList() |
|
728
|
|
|
{ |
|
729
|
|
|
$args = new stdClass(); |
|
730
|
|
|
$args->sort_index = "list_order"; |
|
731
|
|
|
$output = executeQueryArray('member.getJoinFormList', $args); |
|
732
|
|
|
|
|
733
|
|
|
if(!$output->toBool()) |
|
734
|
|
|
{ |
|
735
|
|
|
return array(); |
|
736
|
|
|
} |
|
737
|
|
|
|
|
738
|
|
|
$joinFormList = array(); |
|
739
|
|
|
foreach($output->data as $val) |
|
740
|
|
|
{ |
|
741
|
|
|
if($val->is_active != 'Y') |
|
742
|
|
|
{ |
|
743
|
|
|
continue; |
|
744
|
|
|
} |
|
745
|
|
|
|
|
746
|
|
|
$joinFormList[] = $val; |
|
747
|
|
|
} |
|
748
|
|
|
|
|
749
|
|
|
return $joinFormList; |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
/** |
|
753
|
|
|
* @brief Combine extend join form and member information (used to modify member information) |
|
754
|
|
|
*/ |
|
755
|
|
|
function getCombineJoinForm($member_info) |
|
756
|
|
|
{ |
|
757
|
|
|
$extend_form_list = $this->getJoinFormlist(); |
|
758
|
|
|
if(!$extend_form_list) return; |
|
759
|
|
|
// Member info is open only to an administrator and him/herself when is_private is true. |
|
760
|
|
|
$logged_info = Context::get('logged_info'); |
|
|
|
|
|
|
761
|
|
|
|
|
762
|
|
|
foreach($extend_form_list as $srl => $item) |
|
763
|
|
|
{ |
|
764
|
|
|
$column_name = $item->column_name; |
|
765
|
|
|
$value = $member_info->{$column_name}; |
|
766
|
|
|
|
|
767
|
|
|
// Change values depening on the type of extend form |
|
768
|
|
|
switch($item->column_type) |
|
769
|
|
|
{ |
|
770
|
|
|
case 'checkbox' : |
|
771
|
|
|
if($value && !is_array($value)) $value = array($value); |
|
772
|
|
|
break; |
|
773
|
|
|
case 'text' : |
|
774
|
|
|
case 'homepage' : |
|
775
|
|
|
case 'email_address' : |
|
776
|
|
|
case 'tel' : |
|
777
|
|
|
case 'textarea' : |
|
778
|
|
|
case 'select' : |
|
779
|
|
|
case 'kr_zip' : |
|
780
|
|
|
break; |
|
781
|
|
|
} |
|
782
|
|
|
|
|
783
|
|
|
$extend_form_list[$srl]->value = $value; |
|
784
|
|
|
|
|
785
|
|
|
if($member_info->{'open_'.$column_name}=='Y') $extend_form_list[$srl]->is_opened = true; |
|
786
|
|
|
else $extend_form_list[$srl]->is_opened = false; |
|
787
|
|
|
} |
|
788
|
|
|
return $extend_form_list; |
|
789
|
|
|
} |
|
790
|
|
|
|
|
791
|
|
|
/** |
|
792
|
|
|
* @brief Get a join form |
|
793
|
|
|
*/ |
|
794
|
|
|
function getJoinForm($member_join_form_srl) |
|
795
|
|
|
{ |
|
796
|
|
|
$args->member_join_form_srl = $member_join_form_srl; |
|
|
|
|
|
|
797
|
|
|
$output = executeQuery('member.getJoinForm', $args); |
|
798
|
|
|
$join_form = $output->data; |
|
799
|
|
|
if(!$join_form) return NULL; |
|
800
|
|
|
|
|
801
|
|
|
$column_type = $join_form->column_type; |
|
802
|
|
|
$default_value = $join_form->default_value; |
|
803
|
|
|
|
|
804
|
|
|
if(in_array($column_type, array('checkbox','select','radio'))) |
|
805
|
|
|
{ |
|
806
|
|
|
$join_form->default_value = unserialize($default_value); |
|
807
|
|
|
} |
|
808
|
|
|
else |
|
809
|
|
|
{ |
|
810
|
|
|
$join_form->default_value = ''; |
|
811
|
|
|
} |
|
812
|
|
|
|
|
813
|
|
|
return $join_form; |
|
814
|
|
|
} |
|
815
|
|
|
|
|
816
|
|
|
/** |
|
817
|
|
|
* @brief Get a list of denied IDs |
|
818
|
|
|
*/ |
|
819
|
|
|
function getDeniedIDList() |
|
820
|
|
|
{ |
|
821
|
|
|
if(!$this->denied_id_list) |
|
822
|
|
|
{ |
|
823
|
|
|
$args->sort_index = "list_order"; |
|
|
|
|
|
|
824
|
|
|
$args->page = Context::get('page'); |
|
825
|
|
|
$args->list_count = 40; |
|
826
|
|
|
$args->page_count = 10; |
|
827
|
|
|
|
|
828
|
|
|
$output = executeQuery('member.getDeniedIDList', $args); |
|
829
|
|
|
$this->denied_id_list = $output; |
|
|
|
|
|
|
830
|
|
|
} |
|
831
|
|
|
return $this->denied_id_list; |
|
832
|
|
|
} |
|
833
|
|
|
|
|
834
|
|
|
function getDeniedIDs() |
|
835
|
|
|
{ |
|
836
|
|
|
$output = executeQueryArray('member.getDeniedIDs'); |
|
837
|
|
|
if(!$output->toBool()) return array(); |
|
838
|
|
|
return $output->data; |
|
839
|
|
|
} |
|
840
|
|
|
|
|
841
|
|
|
function getDeniedNickNames() |
|
842
|
|
|
{ |
|
843
|
|
|
$output = executeQueryArray('member.getDeniedNickNames'); |
|
844
|
|
|
if(!$output->toBool()) |
|
845
|
|
|
{ |
|
846
|
|
|
return array(); |
|
847
|
|
|
} |
|
848
|
|
|
|
|
849
|
|
|
return $output->data; |
|
850
|
|
|
} |
|
851
|
|
|
|
|
852
|
|
|
/** |
|
853
|
|
|
* @brief Verify if ID is denied |
|
854
|
|
|
*/ |
|
855
|
|
|
function isDeniedID($user_id) |
|
856
|
|
|
{ |
|
857
|
|
|
$args = new stdClass(); |
|
858
|
|
|
$args->user_id = $user_id; |
|
859
|
|
|
$output = executeQuery('member.chkDeniedID', $args); |
|
860
|
|
|
if($output->data->count) return true; |
|
861
|
|
|
return false; |
|
862
|
|
|
} |
|
863
|
|
|
|
|
864
|
|
|
/** |
|
865
|
|
|
* @brief Verify if nick name is denied |
|
866
|
|
|
*/ |
|
867
|
|
View Code Duplication |
function isDeniedNickName($nickName) |
|
|
|
|
|
|
868
|
|
|
{ |
|
869
|
|
|
$args = new stdClass(); |
|
870
|
|
|
$args->nick_name = $nickName; |
|
871
|
|
|
$output = executeQuery('member.chkDeniedNickName', $args); |
|
872
|
|
|
if($output->data->count) return true; |
|
873
|
|
|
if(!$output->toBool()) |
|
874
|
|
|
{ |
|
875
|
|
|
return true; |
|
876
|
|
|
} |
|
877
|
|
|
return false; |
|
878
|
|
|
} |
|
879
|
|
|
/** |
|
880
|
|
|
* @brief Get information of the profile image |
|
881
|
|
|
*/ |
|
882
|
|
|
function getProfileImage($member_srl) |
|
883
|
|
|
{ |
|
884
|
|
|
if(!isset($GLOBALS['__member_info__']['profile_image'][$member_srl])) |
|
885
|
|
|
{ |
|
886
|
|
|
$GLOBALS['__member_info__']['profile_image'][$member_srl] = null; |
|
887
|
|
|
$exts = array('gif','jpg','png'); |
|
888
|
|
|
for($i=0;$i<3;$i++) |
|
889
|
|
|
{ |
|
890
|
|
|
$image_name_file = sprintf('files/member_extra_info/profile_image/%s%d.%s', getNumberingPath($member_srl), $member_srl, $exts[$i]); |
|
891
|
|
|
if(file_exists($image_name_file)) |
|
892
|
|
|
{ |
|
893
|
|
|
list($width, $height, $type, $attrs) = getimagesize($image_name_file); |
|
|
|
|
|
|
894
|
|
|
$info = new stdClass(); |
|
895
|
|
|
$info->width = $width; |
|
896
|
|
|
$info->height = $height; |
|
897
|
|
|
$info->src = Context::getRequestUri().$image_name_file . '?' . date('YmdHis', filemtime($image_name_file)); |
|
898
|
|
|
$info->file = './'.$image_name_file; |
|
899
|
|
|
$GLOBALS['__member_info__']['profile_image'][$member_srl] = $info; |
|
900
|
|
|
break; |
|
901
|
|
|
} |
|
902
|
|
|
} |
|
903
|
|
|
} |
|
904
|
|
|
|
|
905
|
|
|
return $GLOBALS['__member_info__']['profile_image'][$member_srl]; |
|
906
|
|
|
} |
|
907
|
|
|
|
|
908
|
|
|
/** |
|
909
|
|
|
* @brief Get the image name |
|
910
|
|
|
*/ |
|
911
|
|
View Code Duplication |
function getImageName($member_srl) |
|
|
|
|
|
|
912
|
|
|
{ |
|
913
|
|
|
if(!isset($GLOBALS['__member_info__']['image_name'][$member_srl])) |
|
914
|
|
|
{ |
|
915
|
|
|
$image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
|
916
|
|
|
if(file_exists($image_name_file)) |
|
917
|
|
|
{ |
|
918
|
|
|
list($width, $height, $type, $attrs) = getimagesize($image_name_file); |
|
|
|
|
|
|
919
|
|
|
$info = new stdClass; |
|
920
|
|
|
$info->width = $width; |
|
921
|
|
|
$info->height = $height; |
|
922
|
|
|
$info->src = Context::getRequestUri().$image_name_file. '?' . date('YmdHis', filemtime($image_name_file)); |
|
923
|
|
|
$info->file = './'.$image_name_file; |
|
924
|
|
|
$GLOBALS['__member_info__']['image_name'][$member_srl] = $info; |
|
925
|
|
|
} |
|
926
|
|
|
else $GLOBALS['__member_info__']['image_name'][$member_srl] = null; |
|
927
|
|
|
} |
|
928
|
|
|
return $GLOBALS['__member_info__']['image_name'][$member_srl]; |
|
929
|
|
|
} |
|
930
|
|
|
|
|
931
|
|
|
/** |
|
932
|
|
|
* @brief Get the image mark |
|
933
|
|
|
*/ |
|
934
|
|
View Code Duplication |
function getImageMark($member_srl) |
|
|
|
|
|
|
935
|
|
|
{ |
|
936
|
|
|
if(!isset($GLOBALS['__member_info__']['image_mark'][$member_srl])) |
|
937
|
|
|
{ |
|
938
|
|
|
$image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
|
939
|
|
|
if(file_exists($image_mark_file)) |
|
940
|
|
|
{ |
|
941
|
|
|
list($width, $height, $type, $attrs) = getimagesize($image_mark_file); |
|
|
|
|
|
|
942
|
|
|
$info->width = $width; |
|
|
|
|
|
|
943
|
|
|
$info->height = $height; |
|
944
|
|
|
$info->src = Context::getRequestUri().$image_mark_file . '?' . date('YmdHis', filemtime($image_mark_file)); |
|
945
|
|
|
$info->file = './'.$image_mark_file; |
|
946
|
|
|
$GLOBALS['__member_info__']['image_mark'][$member_srl] = $info; |
|
947
|
|
|
} |
|
948
|
|
|
else $GLOBALS['__member_info__']['image_mark'][$member_srl] = null; |
|
949
|
|
|
} |
|
950
|
|
|
|
|
951
|
|
|
return $GLOBALS['__member_info__']['image_mark'][$member_srl]; |
|
952
|
|
|
} |
|
953
|
|
|
|
|
954
|
|
|
|
|
955
|
|
|
/** |
|
956
|
|
|
* @brief Get the image mark of the group |
|
957
|
|
|
*/ |
|
958
|
|
|
function getGroupImageMark($member_srl,$site_srl=0) |
|
959
|
|
|
{ |
|
960
|
|
|
if(!isset($GLOBALS['__member_info__']['group_image_mark'][$member_srl])) |
|
961
|
|
|
{ |
|
962
|
|
|
$oModuleModel = getModel('module'); |
|
963
|
|
|
$config = $oModuleModel->getModuleConfig('member'); |
|
964
|
|
|
if($config->group_image_mark!='Y') |
|
965
|
|
|
{ |
|
966
|
|
|
return null; |
|
967
|
|
|
} |
|
968
|
|
|
$member_group = $this->getMemberGroups($member_srl,$site_srl); |
|
969
|
|
|
$groups_info = $this->getGroups($site_srl); |
|
970
|
|
|
if(count($member_group) > 0 && is_array($member_group)) |
|
971
|
|
|
{ |
|
972
|
|
|
$memberGroups = array_keys($member_group); |
|
973
|
|
|
|
|
974
|
|
|
foreach($groups_info as $group_srl=>$group_info) |
|
975
|
|
|
{ |
|
976
|
|
|
if(in_array($group_srl, $memberGroups)) |
|
977
|
|
|
{ |
|
978
|
|
|
if($group_info->image_mark) |
|
979
|
|
|
{ |
|
980
|
|
|
$info = new stdClass(); |
|
981
|
|
|
$info->title = $group_info->title; |
|
982
|
|
|
$info->description = $group_info->description; |
|
983
|
|
|
$info->src = $group_info->image_mark; |
|
984
|
|
|
$GLOBALS['__member_info__']['group_image_mark'][$member_srl] = $info; |
|
985
|
|
|
break; |
|
986
|
|
|
} |
|
987
|
|
|
} |
|
988
|
|
|
} |
|
989
|
|
|
} |
|
990
|
|
|
if (!$info) $GLOBALS['__member_info__']['group_image_mark'][$member_srl] == 'N'; |
|
|
|
|
|
|
991
|
|
|
} |
|
992
|
|
|
if ($GLOBALS['__member_info__']['group_image_mark'][$member_srl] == 'N') return null; |
|
993
|
|
|
|
|
994
|
|
|
return $GLOBALS['__member_info__']['group_image_mark'][$member_srl]; |
|
995
|
|
|
} |
|
996
|
|
|
|
|
997
|
|
|
/** |
|
998
|
|
|
* @brief Get user's signature |
|
999
|
|
|
*/ |
|
1000
|
|
|
function getSignature($member_srl) |
|
1001
|
|
|
{ |
|
1002
|
|
|
if(!isset($GLOBALS['__member_info__']['signature'][$member_srl])) |
|
1003
|
|
|
{ |
|
1004
|
|
|
$filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl); |
|
1005
|
|
|
if(file_exists($filename)) |
|
1006
|
|
|
{ |
|
1007
|
|
|
$buff = FileHandler::readFile($filename); |
|
1008
|
|
|
$signature = preg_replace('/<\?.*\?>/', '', $buff); |
|
1009
|
|
|
$GLOBALS['__member_info__']['signature'][$member_srl] = $signature; |
|
1010
|
|
|
} |
|
1011
|
|
|
else $GLOBALS['__member_info__']['signature'][$member_srl] = null; |
|
1012
|
|
|
} |
|
1013
|
|
|
return $GLOBALS['__member_info__']['signature'][$member_srl]; |
|
1014
|
|
|
} |
|
1015
|
|
|
|
|
1016
|
|
|
/** |
|
1017
|
|
|
* @brief Compare plain text password to the password saved in DB |
|
1018
|
|
|
* @param string $hashed_password The hash that was saved in DB |
|
1019
|
|
|
* @param string $password_text The password to check |
|
1020
|
|
|
* @param int $member_srl Set this to member_srl when comparing a member's password (optional) |
|
1021
|
|
|
* @return bool |
|
1022
|
|
|
*/ |
|
1023
|
|
|
function isValidPassword($hashed_password, $password_text, $member_srl=null) |
|
1024
|
|
|
{ |
|
1025
|
|
|
// False if no password in entered |
|
1026
|
|
|
if(!$password_text) |
|
1027
|
|
|
{ |
|
1028
|
|
|
return false; |
|
1029
|
|
|
} |
|
1030
|
|
|
|
|
1031
|
|
|
// Check the password |
|
1032
|
|
|
$oPassword = new Password(); |
|
1033
|
|
|
$current_algorithm = $oPassword->checkAlgorithm($hashed_password); |
|
1034
|
|
|
$match = $oPassword->checkPassword($password_text, $hashed_password, $current_algorithm); |
|
|
|
|
|
|
1035
|
|
|
if(!$match) |
|
1036
|
|
|
{ |
|
1037
|
|
|
return false; |
|
1038
|
|
|
} |
|
1039
|
|
|
|
|
1040
|
|
|
// Update the encryption method if necessary |
|
1041
|
|
|
$config = $this->getMemberConfig(); |
|
1042
|
|
|
if($member_srl > 0 && $config->password_hashing_auto_upgrade != 'N') |
|
1043
|
|
|
{ |
|
1044
|
|
|
$need_upgrade = false; |
|
1045
|
|
|
|
|
1046
|
|
|
if(!$need_upgrade) |
|
1047
|
|
|
{ |
|
1048
|
|
|
$required_algorithm = $oPassword->getCurrentlySelectedAlgorithm(); |
|
1049
|
|
|
if($required_algorithm !== $current_algorithm) $need_upgrade = true; |
|
1050
|
|
|
} |
|
1051
|
|
|
|
|
1052
|
|
|
if(!$need_upgrade) |
|
1053
|
|
|
{ |
|
1054
|
|
|
$required_work_factor = $oPassword->getWorkFactor(); |
|
1055
|
|
|
$current_work_factor = $oPassword->checkWorkFactor($hashed_password); |
|
1056
|
|
|
if($current_work_factor !== false && $required_work_factor > $current_work_factor) $need_upgrade = true; |
|
1057
|
|
|
} |
|
1058
|
|
|
|
|
1059
|
|
|
if($need_upgrade === true) |
|
1060
|
|
|
{ |
|
1061
|
|
|
$args = new stdClass(); |
|
1062
|
|
|
$args->member_srl = $member_srl; |
|
1063
|
|
|
$args->hashed_password = $this->hashPassword($password_text, $required_algorithm); |
|
|
|
|
|
|
1064
|
|
|
$oMemberController = getController('member'); |
|
1065
|
|
|
$oMemberController->updateMemberPassword($args); |
|
1066
|
|
|
} |
|
1067
|
|
|
} |
|
1068
|
|
|
|
|
1069
|
|
|
return true; |
|
1070
|
|
|
} |
|
1071
|
|
|
|
|
1072
|
|
|
/** |
|
1073
|
|
|
* @brief Create a hash of plain text password |
|
1074
|
|
|
* @param string $password_text The password to hash |
|
1075
|
|
|
* @param string $algorithm The algorithm to use (optional, only set this when you want to use a non-default algorithm) |
|
1076
|
|
|
* @return string |
|
1077
|
|
|
*/ |
|
1078
|
|
|
function hashPassword($password_text, $algorithm = null) |
|
1079
|
|
|
{ |
|
1080
|
|
|
$oPassword = new Password(); |
|
1081
|
|
|
return $oPassword->createHash($password_text, $algorithm); |
|
1082
|
|
|
} |
|
1083
|
|
|
|
|
1084
|
|
|
function checkPasswordStrength($password, $strength) |
|
1085
|
|
|
{ |
|
1086
|
|
|
$logged_info = Context::get('logged_info'); |
|
1087
|
|
|
if($logged_info->is_admin == 'Y') return true; |
|
1088
|
|
|
|
|
1089
|
|
|
if($strength == NULL) |
|
1090
|
|
|
{ |
|
1091
|
|
|
$config = $this->getMemberConfig(); |
|
1092
|
|
|
$strength = $config->password_strength?$config->password_strength:'normal'; |
|
1093
|
|
|
} |
|
1094
|
|
|
|
|
1095
|
|
|
$length = strlen($password); |
|
1096
|
|
|
|
|
1097
|
|
|
switch ($strength) { |
|
1098
|
|
|
case 'high': |
|
1099
|
|
|
if($length < 8 || !preg_match('/[^a-zA-Z0-9]/', $password)) return false; |
|
1100
|
|
|
/* no break */ |
|
1101
|
|
|
|
|
1102
|
|
|
case 'normal': |
|
1103
|
|
|
if($length < 6 || !preg_match('/[a-zA-Z]/', $password) || !preg_match('/[0-9]/', $password)) return false; |
|
1104
|
|
|
break; |
|
1105
|
|
|
|
|
1106
|
|
|
case 'low': |
|
1107
|
|
|
if($length < 4) return false; |
|
1108
|
|
|
break; |
|
1109
|
|
|
} |
|
1110
|
|
|
|
|
1111
|
|
|
return true; |
|
1112
|
|
|
} |
|
1113
|
|
|
|
|
1114
|
|
|
function getAdminGroupSrl($site_srl = 0) |
|
1115
|
|
|
{ |
|
1116
|
|
|
$groupSrl = 0; |
|
1117
|
|
|
$output = $this->getGroups($site_srl); |
|
1118
|
|
|
if(is_array($output)) |
|
1119
|
|
|
{ |
|
1120
|
|
|
foreach($output AS $key=>$value) |
|
1121
|
|
|
{ |
|
1122
|
|
|
if($value->is_admin == 'Y') |
|
1123
|
|
|
{ |
|
1124
|
|
|
$groupSrl = $value->group_srl; |
|
1125
|
|
|
break; |
|
1126
|
|
|
} |
|
1127
|
|
|
} |
|
1128
|
|
|
} |
|
1129
|
|
|
return $groupSrl; |
|
1130
|
|
|
} |
|
1131
|
|
|
} |
|
1132
|
|
|
/* End of file member.model.php */ |
|
1133
|
|
|
/* Location: ./modules/member/member.model.php */ |
|
1134
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.