function brian_showdistrict($values, $elems = array(), $container = 'districtbox', $showlevel = null, $containertype = '') { $html = ''; if (!preg_match("/^[A-Za-z0-9_]+\$/", $container)) { return $html; } $showlevel = !empty($showlevel) ? intval($showlevel) : count($values); $showlevel = $showlevel <= 4 ? $showlevel : 4; $upids = array(0); for ($i = 0; $i < $showlevel; $i++) { if (!empty($values[$i])) { $upids[] = intval($values[$i]); } else { for ($j = $i; $j < $showlevel; $j++) { $values[$j] = ''; } break; } } $options = array(1 => array(), 2 => array(), 3 => array(), 4 => array()); if ($upids && is_array($upids)) { foreach (table_brian_district::fetch_all_by_upid($upids, 'displayorder', 'ASC') as $value) { $options[$value['level']][] = array($value['id'], $value['name']); } } $names = array('province', 'city', 'district', 'community'); for ($i = 0; $i < 4; $i++) { if (!empty($elems[$i])) { $elems[$i] = dhtmlspecialchars(preg_replace("/[^\\[A-Za-z0-9_\\]]/", '', $elems[$i])); } else { $elems[$i] = $names[$i]; } } for ($i = 0; $i < $showlevel; $i++) { $level = $i + 1; if (!empty($options[$level])) { $jscall = "brian_showdistrict('{$container}', ['{$elems['0']}', '{$elems['1']}', '{$elems['2']}', '{$elems['3']}'], {$showlevel}, {$level}, '')"; $html .= '<select name="' . $elems[$i] . '" id="' . $elems[$i] . '" class="ps" onchange="' . $jscall . '" tabindex="1">'; $html .= '<option value="">' . lang('spacecp', 'district_level_' . $level) . '</option>'; foreach ($options[$level] as $option) { $selected = $option[0] == $values[$i] ? ' selected="selected"' : ''; $html .= '<option did="' . $option[0] . '" value="' . $option[1] . '"' . $selected . '>' . $option[1] . '</option>'; } $html .= '</select>'; $html .= ' '; } } return $html; }
} elseif ($op == 'district') { $container = addslashes($_GET['container']); $_GET['pid'] = !empty($_GET['pid']) ? intval($_GET['pid']) : $sale_config['upid']; $_GET['level'] = !empty($_GET['level']) ? intval($_GET['level']) : $sale_config['level']; $showlevel = intval($_GET['level']); $showlevel = $showlevel >= 1 && $showlevel <= 4 ? $showlevel : 4; $values = array(intval($_GET['pid']), intval($_GET['cid']), intval($_GET['did']), intval($_GET['coid'])); $level = 1; if ($values[0]) { $level++; } else { if ($_G['uid'] && !empty($_GET['showdefault'])) { space_merge($_G['member'], 'profile'); $district = array(); if (!empty($district)) { foreach (table_brian_district::fetch_all_by_name($district) as $value) { $key = $value['level'] - 1; $values[$key] = $value['id']; } $level++; } } } if ($values[1]) { $level++; } if ($values[2]) { $level++; } if ($values[3]) { $level++;