function_profile.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: function_profile.php 36354 2017-01-17 07:52:44Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function profile_setting($fieldid, $space=array(), $showstatus=false, $ignoreunchangable = false, $ignoreshowerror = false) {
  12. global $_G;
  13. if(empty($_G['cache']['profilesetting'])) {
  14. loadcache('profilesetting');
  15. }
  16. $field = $_G['cache']['profilesetting'][$fieldid];
  17. if(empty($field) || !$field['available'] || in_array($fieldid, array('uid', 'constellation', 'zodiac', 'birthmonth', 'birthyear', 'birthprovince', 'birthdist', 'birthcommunity', 'resideprovince', 'residedist', 'residecommunity'))) {
  18. return '';
  19. }
  20. if($showstatus) {
  21. $uid = intval($space['uid']);
  22. if($uid && !isset($_G['profile_verifys'][$uid])) {
  23. $_G['profile_verifys'][$uid] = array();
  24. if($value = C::t('common_member_verify_info')->fetch_by_uid_verifytype($uid, 0)) {
  25. $fields = dunserialize($value['field']);
  26. foreach($fields as $key => $fvalue) {
  27. if($_G['cache']['profilesetting'][$key]['needverify']) {
  28. $_G['profile_verifys'][$uid][$key] = $fvalue;
  29. }
  30. }
  31. }
  32. }
  33. $verifyvalue = NULL;
  34. if(isset($_G['profile_verifys'][$uid][$fieldid])) {
  35. if($fieldid=='gender') {
  36. $verifyvalue = lang('space', 'gender_'.intval($_G['profile_verifys'][$uid][$fieldid]));
  37. } elseif($fieldid=='birthday') {
  38. $verifyvalue = $_G['profile_verifys'][$uid]['birthyear'].'-'.$_G['profile_verifys'][$uid]['birthmonth'].'-'.$_G['profile_verifys'][$uid]['birthday'];
  39. } else {
  40. $verifyvalue = $_G['profile_verifys'][$uid][$fieldid];
  41. }
  42. }
  43. }
  44. $html = '';
  45. $field['unchangeable'] = !$ignoreunchangable && $field['unchangeable'] ? 1 : 0;
  46. if($fieldid == 'birthday') {
  47. if($field['unchangeable'] && !empty($space[$fieldid])) {
  48. return '<span>'.$space['birthyear'].'-'.$space['birthmonth'].'-'.$space['birthday'].'</span>';
  49. }
  50. $birthyeayhtml = '';
  51. $nowy = dgmdate($_G['timestamp'], 'Y');
  52. for ($i=0; $i<100; $i++) {
  53. $they = $nowy - $i;
  54. $selectstr = $they == $space['birthyear']?' selected':'';
  55. $birthyeayhtml .= "<option value=\"$they\"$selectstr>$they</option>";
  56. }
  57. $birthmonthhtml = '';
  58. for ($i=1; $i<13; $i++) {
  59. $selectstr = $i == $space['birthmonth']?' selected':'';
  60. $birthmonthhtml .= "<option value=\"$i\"$selectstr>$i</option>";
  61. }
  62. $birthdayhtml = '';
  63. if(empty($space['birthmonth']) || in_array($space['birthmonth'], array(1, 3, 5, 7, 8, 10, 12))) {
  64. $days = 31;
  65. } elseif(in_array($space['birthmonth'], array(4, 6, 9, 11))) {
  66. $days = 30;
  67. } elseif($space['birthyear'] && (($space['birthyear'] % 400 == 0) || ($space['birthyear'] % 4 == 0 && $space['birthyear'] % 400 != 0))) {
  68. $days = 29;
  69. } else {
  70. $days = 28;
  71. }
  72. for ($i=1; $i<=$days; $i++) {
  73. $selectstr = $i == $space['birthday']?' selected':'';
  74. $birthdayhtml .= "<option value=\"$i\"$selectstr>$i</option>";
  75. }
  76. $html = '<select name="birthyear" id="birthyear" class="ps" onchange="showbirthday();" tabindex="1">'
  77. .'<option value="">'.lang('space', 'year').'</option>'
  78. .$birthyeayhtml
  79. .'</select>'
  80. .'&nbsp;&nbsp;'
  81. .'<select name="birthmonth" id="birthmonth" class="ps" onchange="showbirthday();" tabindex="1">'
  82. .'<option value="">'.lang('space', 'month').'</option>'
  83. .$birthmonthhtml
  84. .'</select>'
  85. .'&nbsp;&nbsp;'
  86. .'<select name="birthday" id="birthday" class="ps" tabindex="1">'
  87. .'<option value="">'.lang('space', 'day').'</option>'
  88. .$birthdayhtml
  89. .'</select>';
  90. } elseif($fieldid=='gender') {
  91. if($field['unchangeable'] && $space[$fieldid] > 0) {
  92. return '<span>'.lang('space', 'gender_'.intval($space[$fieldid])).'</span>';
  93. }
  94. $selected = array($space[$fieldid]=>' selected="selected"');
  95. $html = '<select name="gender" id="gender" class="ps" tabindex="1">';
  96. if($field['unchangeable']) {
  97. $html .= '<option value="">'.lang('space', 'gender').'</option>';
  98. } else {
  99. $html .= '<option value="0"'.($space[$fieldid]=='0' ? ' selected="selected"' : '').'>'.lang('space', 'gender_0').'</option>';
  100. }
  101. $html .= '<option value="1"'.($space[$fieldid]=='1' ? ' selected="selected"' : '').'>'.lang('space', 'gender_1').'</option>'
  102. .'<option value="2"'.($space[$fieldid]=='2' ? ' selected="selected"' : '').'>'.lang('space', 'gender_2').'</option>'
  103. .'</select>';
  104. } elseif($fieldid=='birthcity') {
  105. if($field['unchangeable'] && !empty($space[$fieldid])) {
  106. return '<span>'.$space['birthprovince'].'-'.$space['birthcity'].'</span>';
  107. }
  108. $values = array(0,0,0,0);
  109. $elems = array('birthprovince', 'birthcity', 'birthdist', 'birthcommunity');
  110. if(!empty($space['birthprovince'])) {
  111. $html = profile_show('birthcity', $space);
  112. $html .= '&nbsp;(<a href="javascript:;" onclick="showdistrict(\'birthdistrictbox\', [\'birthprovince\', \'birthcity\', \'birthdist\', \'birthcommunity\'], 4, \'\', \'birth\'); return false;">'.lang('spacecp', 'profile_edit').'</a>)';
  113. $html .= '<p id="birthdistrictbox"></p>';
  114. } else {
  115. $html = '<p id="birthdistrictbox">'.showdistrict($values, $elems, 'birthdistrictbox', 1, 'birth').'</p>';
  116. }
  117. } elseif($fieldid=='residecity') {
  118. if($field['unchangeable'] && !empty($space[$fieldid])) {
  119. return '<span>'.$space['resideprovince'].'-'.$space['residecity'].'</span>';
  120. }
  121. $values = array(0,0,0,0);
  122. $elems = array('resideprovince', 'residecity', 'residedist', 'residecommunity');
  123. if(!empty($space['resideprovince'])) {
  124. $html = profile_show('residecity', $space);
  125. $html .= '&nbsp;(<a href="javascript:;" onclick="showdistrict(\'residedistrictbox\', [\'resideprovince\', \'residecity\', \'residedist\', \'residecommunity\'], 4, \'\', \'reside\'); return false;">'.lang('spacecp', 'profile_edit').'</a>)';
  126. $html .= '<p id="residedistrictbox"></p>';
  127. } else {
  128. $html = '<p id="residedistrictbox">'.showdistrict($values, $elems, 'residedistrictbox', 1, 'reside').'</p>';
  129. }
  130. } elseif($fieldid=='qq') {
  131. $html = "<input type=\"text\" name=\"$fieldid\" id=\"$fieldid\" class=\"px\" value=\"$space[$fieldid]\" tabindex=\"1\" /><p><a href=\"\" class=\"xi2\" onclick=\"this.href='http://wp.qq.com/set.html?from=discuz&uin='+$('$fieldid').value\" target=\"_blank\">".lang('spacecp', 'qq_set_status')."</a></p>";
  132. } else {
  133. if($field['unchangeable'] && $space[$fieldid]!='') {
  134. if($field['formtype']=='file') {
  135. $imgurl = getglobal('setting/attachurl').'./profile/'.$space[$fieldid];
  136. return '<span><a href="'.$imgurl.'" target="_blank"><img src="'.$imgurl.'" style="max-width: 500px;" /></a></span>';
  137. } else {
  138. return '<span>'.nl2br($space[$fieldid]).'</span>';
  139. }
  140. }
  141. if($field['formtype']=='textarea') {
  142. $html = "<textarea name=\"$fieldid\" id=\"$fieldid\" class=\"pt\" rows=\"3\" cols=\"40\" tabindex=\"1\">$space[$fieldid]</textarea>";
  143. } elseif($field['formtype']=='select') {
  144. $field['choices'] = explode("\n", $field['choices']);
  145. $html = "<select name=\"$fieldid\" id=\"$fieldid\" class=\"ps\" tabindex=\"1\">";
  146. foreach($field['choices'] as $op) {
  147. $html .= "<option value=\"$op\"".($op==$space[$fieldid] ? 'selected="selected"' : '').">$op</option>";
  148. }
  149. $html .= '</select>';
  150. } elseif($field['formtype']=='list') {
  151. $field['choices'] = explode("\n", $field['choices']);
  152. $html = "<select name=\"{$fieldid}[]\" id=\"$fieldid\" class=\"ps\" multiple=\"multiplue\" tabindex=\"1\">";
  153. $space[$fieldid] = explode("\n", $space[$fieldid]);
  154. foreach($field['choices'] as $op) {
  155. $html .= "<option value=\"$op\"".(in_array($op, $space[$fieldid]) ? 'selected="selected"' : '').">$op</option>";
  156. }
  157. $html .= '</select>';
  158. } elseif($field['formtype']=='checkbox') {
  159. $field['choices'] = explode("\n", $field['choices']);
  160. $space[$fieldid] = explode("\n", $space[$fieldid]);
  161. foreach($field['choices'] as $op) {
  162. $html .= ''
  163. ."<label class=\"lb\"><input type=\"checkbox\" name=\"{$fieldid}[]\" id=\"$fieldid\" class=\"pc\" value=\"$op\" tabindex=\"1\"".(in_array($op, $space[$fieldid]) ? ' checked="checked"' : '')." />"
  164. ."$op</label>";
  165. }
  166. } elseif($field['formtype']=='radio') {
  167. $field['choices'] = explode("\n", $field['choices']);
  168. foreach($field['choices'] as $op) {
  169. $html .= ''
  170. ."<label class=\"lb\"><input type=\"radio\" name=\"{$fieldid}\" class=\"pr\" value=\"$op\" tabindex=\"1\"".($op == $space[$fieldid] ? ' checked="checked"' : '')." />"
  171. ."$op</label>";
  172. }
  173. } elseif($field['formtype']=='file') {
  174. $html = "<input type=\"file\" value=\"\" name=\"$fieldid\" id=\"$fieldid\" tabindex=\"1\" class=\"pf\" style=\"height:26px;\" /><input type=\"hidden\" name=\"$fieldid\" value=\"$space[$fieldid]\" />";
  175. if(!empty($space[$fieldid])) {
  176. $url = getglobal('setting/attachurl').'./profile/'.$space[$fieldid];
  177. $html .= "&nbsp;<label><input type=\"checkbox\" class=\"checkbox\" tabindex=\"1\" name=\"deletefile[$fieldid]\" id=\"$fieldid\" value=\"yes\" />".lang('spacecp', 'delete')."</label><br /><a href=\"$url\" target=\"_blank\"><img src=\"$url\" width=\"200\" class=\"mtm\" /></a>";
  178. }
  179. } else {
  180. $html = "<input type=\"text\" name=\"$fieldid\" id=\"$fieldid\" class=\"px\" value=\"$space[$fieldid]\" tabindex=\"1\" />";
  181. }
  182. }
  183. $html .= !$ignoreshowerror ? "<div class=\"rq mtn\" id=\"showerror_$fieldid\"></div>" : '';
  184. if($showstatus) {
  185. $html .= "<p class=\"d\">$value[description]";
  186. if($space[$fieldid]=='' && $value['unchangeable']) {
  187. $html .= lang('spacecp', 'profile_unchangeable');
  188. }
  189. if($verifyvalue !== null) {
  190. if($field['formtype'] == 'file') {
  191. $imgurl = getglobal('setting/attachurl').'./profile/'.$verifyvalue;
  192. $verifyvalue = "<img src='$imgurl' alt='$imgurl' style='max-width: 500px;'/>";
  193. }
  194. $html .= "<strong>".lang('spacecp', 'profile_is_verifying')." (<a href=\"#\" onclick=\"display('newvalue_$fieldid');return false;\">".lang('spacecp', 'profile_mypost')."</a>)</strong>"
  195. ."<p id=\"newvalue_$fieldid\" style=\"display:none\">".$verifyvalue."</p>";
  196. } elseif($field['needverify']) {
  197. $html .= lang('spacecp', 'profile_need_verifying');
  198. }
  199. $html .= '</p>';
  200. }
  201. return $html;
  202. }
  203. function profile_check($fieldid, &$value, $space=array()) {
  204. global $_G;
  205. if(empty($_G['cache']['profilesetting'])) {
  206. loadcache('profilesetting');
  207. }
  208. if(empty($_G['profilevalidate'])) {
  209. include libfile('spacecp/profilevalidate', 'include');
  210. $_G['profilevalidate'] = $profilevalidate;
  211. }
  212. $field = $_G['cache']['profilesetting'][$fieldid];
  213. if(empty($field) || !$field['available']) {
  214. return false;
  215. }
  216. if($value=='') {
  217. if($field['required']) {
  218. if(in_array($fieldid, array('birthprovince', 'birthcity', 'birthdist', 'birthcommunity', 'resideprovince', 'residecity', 'residedist', 'residecommunity'))) {
  219. if(substr($fieldid, 0, 5) == 'birth') {
  220. if(!empty($_GET['birthprovince']) || !empty($_GET['birthcity']) || !empty($_GET['birthdist']) || !empty($_GET['birthcommunity'])) {
  221. return true;
  222. }
  223. } elseif(!empty($_GET['resideprovince']) || !empty($_GET['residecity']) || !empty($_GET['residedist']) || !empty($_GET['residecommunity'])) {
  224. return true;
  225. }
  226. }
  227. return false;
  228. } else {
  229. return true;
  230. }
  231. }
  232. if($field['unchangeable'] && !empty($space[$fieldid])) {
  233. return false;
  234. }
  235. include_once libfile('function/home');
  236. if(in_array($fieldid, array('birthday', 'birthmonth', 'birthyear', 'gender'))) {
  237. $value = intval($value);
  238. return true;
  239. } elseif(in_array($fieldid, array('birthprovince', 'birthcity', 'birthdist', 'birthcommunity', 'resideprovince', 'residecity', 'residedist', 'residecommunity'))) {
  240. $value = getstr($value);
  241. return true;
  242. }
  243. if($field['choices']) {
  244. $field['choices'] = explode("\n", $field['choices']);
  245. }
  246. if($field['formtype'] == 'text' || $field['formtype'] == 'textarea') {
  247. $value = getstr($value);
  248. if($field['size'] && strlen($value) > $field['size']) {
  249. return false;
  250. } else {
  251. $field['validate'] = !empty($field['validate']) ? $field['validate'] : ($_G['profilevalidate'][$fieldid] ? $_G['profilevalidate'][$fieldid] : '');
  252. if($field['validate'] && !preg_match($field['validate'], $value)) {
  253. return false;
  254. }
  255. }
  256. } elseif($field['formtype'] == 'checkbox' || $field['formtype'] == 'list') {
  257. $arr = array();
  258. foreach ($value as $op) {
  259. if(in_array($op, $field['choices'])) {
  260. $arr[] = $op;
  261. }
  262. }
  263. $value = implode("\n", $arr);
  264. if($field['size'] && count($arr) > $field['size']) {
  265. return false;
  266. }
  267. } elseif($field['formtype'] == 'radio' || $field['formtype'] == 'select') {
  268. if(!in_array($value, $field['choices'])){
  269. return false;
  270. }
  271. }
  272. return true;
  273. }
  274. function profile_show($fieldid, $space=array(), $getalone = false) {
  275. global $_G;
  276. if(empty($_G['cache']['profilesetting'])) {
  277. loadcache('profilesetting');
  278. }
  279. if($fieldid == 'qqnumber') {
  280. $_G['cache']['profilesetting'][$fieldid] = $_G['cache']['profilesetting']['qq'];
  281. }
  282. $field = $_G['cache']['profilesetting'][$fieldid];
  283. if(empty($field) || !$field['available'] || (!$getalone && in_array($fieldid, array('uid', 'birthmonth', 'birthyear', 'birthprovince', 'resideprovince')))) {
  284. return false;
  285. }
  286. if($fieldid=='gender') {
  287. return lang('space', 'gender_'.intval($space['gender']));
  288. } elseif($fieldid=='birthday' && !$getalone) {
  289. $return = $space['birthyear'] ? $space['birthyear'].' '.lang('space', 'year').' ' : '';
  290. if($space['birthmonth'] && $space['birthday']) {
  291. $return .= $space['birthmonth'].' '.lang('space', 'month').' '.$space['birthday'].' '.lang('space', 'day');
  292. }
  293. return $return;
  294. } elseif($fieldid=='birthcity' && !$getalone) {
  295. return $space['birthprovince']
  296. .(!empty($space['birthcity']) ? ' '.$space['birthcity'] : '')
  297. .(!empty($space['birthdist']) ? ' '.$space['birthdist'] : '')
  298. .(!empty($space['birthcommunity']) ? ' '.$space['birthcommunity'] : '');
  299. } elseif($fieldid=='residecity' && !$getalone) {
  300. return $space['resideprovince']
  301. .(!empty($space['residecity']) ? ' '.$space['residecity'] : '')
  302. .(!empty($space['residedist']) ? ' '.$space['residedist'] : '')
  303. .(!empty($space['residecommunity']) ? ' '.$space['residecommunity'] : '');
  304. } elseif($fieldid == 'site') {
  305. $url = str_replace('"', '\\"', $space[$fieldid]);
  306. return "<a href=\"$url\" target=\"_blank\">$url</a>";
  307. } elseif($fieldid == 'position') {
  308. return nl2br($space['office'] ? $space['office'] : $space['position']);
  309. } elseif($fieldid == 'qq') {
  310. return '<a href="http://wpa.qq.com/msgrd?v=3&uin='.$space[$fieldid].'&site='.$_G['setting']['bbname'].'&menu=yes&from=discuz" target="_blank" title="'.lang('spacecp', 'qq_dialog').'"><img src="'.STATICURL.'/image/common/qq.gif" alt="QQ" style="margin:0px;"/></a>';
  311. } elseif($fieldid == 'qqnumber') {
  312. return $space['qq'];
  313. } else {
  314. return nl2br($space[$fieldid]);
  315. }
  316. }
  317. function showdistrict($values, $elems=array(), $container='districtbox', $showlevel=null, $containertype = 'birth') {
  318. $html = '';
  319. if(!preg_match("/^[A-Za-z0-9_]+$/", $container)) {
  320. return $html;
  321. }
  322. $showlevel = !empty($showlevel) ? intval($showlevel) : count($values);
  323. $showlevel = $showlevel <= 4 ? $showlevel : 4;
  324. $upids = array(0);
  325. for($i=0;$i<$showlevel;$i++) {
  326. if(!empty($values[$i])) {
  327. $upids[] = intval($values[$i]);
  328. } else {
  329. for($j=$i; $j<$showlevel; $j++) {
  330. $values[$j] = '';
  331. }
  332. break;
  333. }
  334. }
  335. $options = array(1=>array(), 2=>array(), 3=>array(), 4=>array());
  336. if($upids && is_array($upids)) {
  337. foreach(C::t('common_district')->fetch_all_by_upid($upids, 'displayorder', 'ASC') as $value) {
  338. if($value['level'] == 1 && ($value['id'] != $values[0] && ($value['usetype'] == 0 || !(($containertype == 'birth' && in_array($value['usetype'], array(1, 3))) || ($containertype != 'birth' && in_array($value['usetype'], array(2, 3))))))) {
  339. continue;
  340. }
  341. $options[$value['level']][] = array($value['id'], $value['name']);
  342. }
  343. }
  344. $names = array('province', 'city', 'district', 'community');
  345. for($i=0; $i<4;$i++) {
  346. if(!empty($elems[$i])) {
  347. $elems[$i] = dhtmlspecialchars(preg_replace("/[^\[A-Za-z0-9_\]]/", '', $elems[$i]));
  348. } else {
  349. $elems[$i] = ($containertype == 'birth' ? 'birth' : 'reside').$names[$i];
  350. }
  351. }
  352. for($i=0;$i<$showlevel;$i++) {
  353. $level = $i+1;
  354. if(!empty($options[$level])) {
  355. $jscall = "showdistrict('$container', ['$elems[0]', '$elems[1]', '$elems[2]', '$elems[3]'], $showlevel, $level, '$containertype')";
  356. $html .= '<select name="'.$elems[$i].'" id="'.$elems[$i].'" class="ps" onchange="'.$jscall.'" tabindex="1">';
  357. $html .= '<option value="">'.lang('spacecp', 'district_level_'.$level).'</option>';
  358. foreach($options[$level] as $option) {
  359. $selected = $option[0] == $values[$i] ? ' selected="selected"' : '';
  360. $html .= '<option did="'.$option[0].'" value="'.$option[1].'"'.$selected.'>'.$option[1].'</option>';
  361. }
  362. $html .= '</select>';
  363. $html .= '&nbsp;&nbsp;';
  364. }
  365. }
  366. return $html;
  367. }
  368. function countprofileprogress($uid = 0) {
  369. global $_G;
  370. $uid = intval(!$uid ? $_G['uid'] : $uid);
  371. if(($profilegroup = C::t('common_setting')->fetch('profilegroup', true))) {
  372. $fields = array();
  373. foreach($profilegroup as $type => $value) {
  374. foreach($value['field'] as $key => $field) {
  375. $fields[$key] = $field;
  376. }
  377. }
  378. if(isset($fields['sightml']) && empty($_G['group']['maxsigsize'])) {
  379. unset($fields['sightml']);
  380. }
  381. if(isset($fields['customstatus']) && empty($_G['group']['allowcstatus'])) {
  382. unset($fields['customstatus']);
  383. }
  384. loadcache('profilesetting');
  385. $allowcstatus = !empty($_G['group']['allowcstatus']) ? true : false;
  386. $complete = 0;
  387. $profile = array_merge(C::t('common_member_profile')->fetch($uid), C::t('common_member_field_forum')->fetch($uid));
  388. foreach($fields as $key) {
  389. if((!isset($_G['cache']['profilesetting'][$key]) || !$_G['cache']['profilesetting'][$key]['available']) && !in_array($key, array('sightml', 'customstatus'))) {
  390. unset($fields[$key]);
  391. continue;
  392. }
  393. if(in_array($key, array('birthday', 'birthyear', 'birthprovince', 'birthcity', 'birthdist', 'birthcommunity', 'resideprovince', 'residecity', 'residedist', 'residecommunity'))) {
  394. if($key=='birthday') {
  395. if(!empty($profile['birthyear']) || !empty($profile[$key])) {
  396. $complete++;
  397. }
  398. unset($fields['birthyear']);
  399. } elseif($key=='birthcity') {
  400. if(!empty($profile['birthprovince']) || !empty($profile[$key]) || !empty($profile['birthdist']) || !empty($profile['birthcommunity'])) {
  401. $complete++;
  402. }
  403. unset($fields['birthprovince']);
  404. unset($fields['birthdist']);
  405. unset($fields['birthcommunity']);
  406. } elseif($key=='residecity') {
  407. if(!empty($profile['resideprovince']) || !empty($profile[$key]) || !empty($profile['residedist']) || !empty($profile['residecommunity'])) {
  408. $complete++;
  409. }
  410. unset($fields['resideprovince']);
  411. unset($fields['residedist']);
  412. unset($fields['residecommunity']);
  413. }
  414. } else if($profile[$key] != '') {
  415. $complete++;
  416. }
  417. }
  418. $progress = floor($complete / count($fields) * 100);
  419. C::t('common_member_status')->update($uid, array('profileprogress' => $progress > 100 ? 100 : $progress), 'UNBUFFERED');
  420. return $progress;
  421. }
  422. }
  423. function get_constellation($birthmonth,$birthday) {
  424. $birthmonth = intval($birthmonth);
  425. $birthday = intval($birthday);
  426. $idx = $birthmonth;
  427. if ($birthday <= 22) {
  428. if (1 == $birthmonth) {
  429. $idx = 12;
  430. } else {
  431. $idx = $birthmonth - 1;
  432. }
  433. }
  434. return $idx > 0 && $idx <= 12 ? lang('space', 'constellation_'.$idx) : '';
  435. }
  436. function get_zodiac($birthyear) {
  437. $birthyear = intval($birthyear);
  438. $idx = (($birthyear - 1900) % 12) + 1;
  439. return $idx > 0 && $idx <= 12 ? lang('space', 'zodiac_'. $idx) : '';
  440. }
  441. ?>