} } } /* 取得配送费用 */ $total = order_weight_price($order_id); foreach ($shipping_list as $key => $shipping) { $shipping_fee = shipping_fee($shipping['shipping_code'], unserialize($shipping['configure']), $total['weight'], $total['amount'], $total['number']); //计算运费 $free_price = free_price($shipping['configure']); //免费额度 $shipping_list[$key]['shipping_fee'] = $shipping_fee; $shipping_list[$key]['format_shipping_fee'] = price_format($shipping_fee); $shipping_list[$key]['free_money'] = price_format($free_price['configure']['free_money']); } $smarty->assign('shipping_list', $shipping_list); /* 其他处理 */ $order['order_time'] = local_date($_CFG['time_format'], $order['add_time']); $order['pay_time'] = $order['pay_time'] > 0 ? local_date($_CFG['time_format'], $order['pay_time']) : $_LANG['ps'][PS_UNPAYED]; $order['shipping_time'] = $order['shipping_time'] > 0 ? local_date($_CFG['time_format'], $order['shipping_time']) : $_LANG['ss'][SS_UNSHIPPED]; $order['status'] = $_LANG['os'][$order['order_status']] . ',' . $_LANG['ps'][$order['pay_status']] . ',' . $_LANG['ss'][$order['shipping_status']]; $order['invoice_no'] = $order['shipping_status'] == SS_UNSHIPPED || $order['shipping_status'] == SS_PREPARING ? $_LANG['ss'][SS_UNSHIPPED] : $order['invoice_no']; $order['sign_time'] = local_date($_CFG['time_format'], $order['sign_time']); /* 取得操作记录 */ $action_list = get_return_action($ret_id); $smarty->assign('action_list', $action_list); /*服务详情*/ $service = get_service_info($back_order['service_id']); /* 模板赋值 */ $smarty->assign('back_order', $back_order); $smarty->assign('order', $order); $smarty->assign('service', $service);
if ($component == "fw_core") { continue; } foreach (array_keys($json_struct["pois"]) as $uuid) { // print $uuid; $comp_data = getComponentMongoDB($mongodb, $component, $uuid, false); if ($comp_data != NULL) { $json_struct["pois"][$uuid][$component] = $comp_data; } } } } else { // no view permission, show empty list $json_struct['pois'] = array(); } $json_struct['service_info'] = get_service_info(SERVICE_NAME); //Language filtering $accept_lang = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $langs = parse_accept_language($accept_lang); filter_poi_intl_properties($json_struct, array_keys($langs)); $return_val = json_encode($json_struct); header("Content-type: application/json"); header("Access-Control-Allow-Origin: *"); echo $return_val; } else { header("HTTP/1.0 400 Bad Request"); echo "'lat' and 'lon' parameters must be specified!"; return; } } else { if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
$email = $user_data['email']; $db_opts = get_db_options(); $user_id = poi_new_uuid_v4(); $timestamp = time(); $mongodb = connectMongoDB($db_opts['mongo_db_name']); $registration_key = poi_new_key(); $user_data["_id"] = $user_id; $user_data['last_update'] = array(); $user_data['last_update']['timestamp'] = $timestamp; $user_data['last_update']['responsible'] = $operator_id; $user_data['reg_call'] = $registration_key; $user_data['identifications'] = array(); $collection = $mongodb->_users; $collection->insert($user_data); $ret_val_arr = array('description' => 'User added.'); $ret_val_arr['service_info'] = get_service_info(SERVICE_NAME); $registration_call = array(); $registration_call['_id'] = $registration_key; $registration_call['user_id'] = $user_id; $registration_call['timestamp'] = $timestamp; $_reg_calls = $mongodb->_reg_calls; $_reg_calls->insert($registration_call); $registration_url = getDirUrl() . '/register_me.php?key=' . $registration_key; $ret_val_arr['registration_call'] = call_to_register($email, $user_data['name'], $registration_url, $site_info['name'], !$no_mail); $ret_val_arr['name'] = $user_data['name']; $ret_val_arr['user_id'] = $user_id; $ret_val_arr['email'] = $email; $ret_val_arr['registration_url'] = $registration_url; $ret_val_arr['mail_sent'] = $ret_vall_arr['registration_call']['sent']; $ret_val = json_encode($ret_val_arr); header("Access-Control-Allow-Origin: *");
echo "*ERROR: Exception when updating " . $uuid . "." . $comp_name . "\n"; echo " message: " . $e->getMessage() . "\n"; echo " code: " . $e->getCode() . "\n"; } } } } } } // end for each dyn_data component } // end if dynamic POI } // end for each requested POI $pois_data = array("pois" => $data); $pois_data['service_info'] = get_service_info(SERVICE_NAME); // Uncomment, if needed // $pois_data['service_info']['log'] = $dlog; $get_for_update = false; if (isset($_GET['get_for_update'])) { if ($_GET['get_for_update'] == "true") { $get_for_update = true; } } if (!$get_for_update) { $accept_lang = $_SERVER['HTTP_ACCEPT_LANGUAGE']; $langs = parse_accept_language($accept_lang); filter_poi_intl_properties($pois_data, array_keys($langs)); } $return_val = json_encode($pois_data); header("Content-type: application/json");
/** * returns run options represents as a hash * @return array */ public function getRunOptions() { if (!isset($this->options)) { if ($this->dir) { $this->options = self::getSerializedOptions($this->dir); $this->verbose = isset($this->options['verbose']); } else { // default run argument values $sysInfo = get_sys_info(); $defaults = array('collectd_rrd_dir' => '/var/lib/collectd/rrd', 'dns_retry' => 2, 'dns_samples' => 10, 'dns_timeout' => 5, 'geo_regions' => 'us_west us_central us_east canada eu_west eu_central eu_east oceania asia america_south africa', 'latency_interval' => 0.2, 'latency_samples' => 100, 'latency_timeout' => 3, 'meta_cpu' => $sysInfo['cpu'], 'meta_memory' => $sysInfo['memory_gb'] > 0 ? $sysInfo['memory_gb'] . ' GB' : $sysInfo['memory_mb'] . ' MB', 'meta_os' => $sysInfo['os_info'], 'output' => trim(shell_exec('pwd')), 'spacing' => 200, 'test' => 'latency', 'throughput_size' => 5, 'throughput_threads' => 2, 'throughput_uri' => '/web-probe'); $opts = array('abort_threshold:', 'collectd_rrd', 'collectd_rrd_dir:', 'discard_fastest:', 'discard_slowest:', 'dns_one_server', 'dns_retry:', 'dns_samples:', 'dns_tcp', 'dns_timeout:', 'geoiplookup', 'geo_regions:', 'latency_interval:', 'latency_samples:', 'latency_skip:', 'latency_timeout:', 'max_runtime:', 'max_tests:', 'meta_compute_service:', 'meta_compute_service_id:', 'meta_cpu:', 'meta_instance_id:', 'meta_location:', 'meta_memory:', 'meta_os:', 'meta_provider:', 'meta_provider_id:', 'meta_region:', 'meta_resource_id:', 'meta_run_id:', 'meta_test_id:', 'min_runtime:', 'min_runtime_in_save', 'output:', 'params_url:', 'params_url_service_type:', 'params_url_header:', 'randomize', 'same_continent_only', 'same_country_only', 'same_geo_region', 'same_provider_only', 'same_region_only', 'same_service_only', 'same_state_only', 'service_lookup', 'sleep_before_start:', 'spacing:', 'suppress_failed', 'test:', 'test_endpoint:', 'test_instance_id:', 'test_location:', 'test_private_network_type:', 'test_provider:', 'test_provider_id:', 'test_region:', 'test_service:', 'test_service_id:', 'test_service_type:', 'throughput_header:', 'throughput_https', 'throughput_inverse', 'throughput_keepalive', 'throughput_same_continent:', 'throughput_same_country:', 'throughput_same_geo_region:', 'throughput_same_provider:', 'throughput_same_region:', 'throughput_same_service:', 'throughput_same_state:', 'throughput_samples:', 'throughput_size:', 'throughput_slowest_thread', 'throughput_small_file', 'throughput_threads:', 'throughput_time', 'throughput_timeout:', 'throughput_uri:', 'throughput_use_mean', 'throughput_webpage:', 'throughput_webpage_check', 'traceroute', 'v' => 'verbose'); $this->options = parse_args($opts, array('latency_skip', 'params_url_service_type', 'params_url_header', 'test', 'test_endpoint', 'test_instance_id', 'test_location', 'test_provider', 'test_provider_id', 'test_region', 'test_service', 'test_service_id', 'test_service_type', 'throughput_header', 'throughput_webpage')); $this->options['run_start'] = time(); $this->verbose = isset($this->options['verbose']); // set default same size constraints if --throughput_size is not set if (!isset($this->options['throughput_size'])) { foreach (array('throughput_same_continent' => 10, 'throughput_same_country' => 20, 'throughput_same_geo_region' => 30, 'throughput_same_provider' => 10, 'throughput_same_region' => 100, 'throughput_same_state' => 50) as $k => $v) { $defaults[$k] = $v; } } foreach ($defaults as $key => $val) { if (!isset($this->options[$key])) { $this->options[$key] = $val; $this->defaultsSet[] = $key; } } if (isset($this->options['throughput_size']) && $this->options['throughput_size'] == 0) { $this->options['throughput_time'] = TRUE; } if (!isset($this->options['throughput_samples'])) { $this->options['throughput_samples'] = isset($this->options['throughput_small_file']) || isset($this->options['throughput_time']) ? 10 : 5; } if (!isset($this->options['throughput_timeout'])) { $this->options['throughput_timeout'] = isset($this->options['throughput_small_file']) || isset($this->options['throughput_time']) ? 5 : 180; } // expand geo_regions if (isset($this->options['geo_regions'])) { $geoRegions = array(); foreach (explode(',', $this->options['geo_regions']) as $r1) { foreach (explode(' ', $r1) as $r2) { $r2 = strtolower(trim($r2)); if ($r2 && !in_array($r2, $geoRegions)) { $geoRegions[] = $r2; } } } if ($geoRegions) { $this->options['geo_regions'] = $geoRegions; } } // expand tests if (!is_array($this->options['test'])) { $this->options['test'] = array($this->options['test']); } foreach ($this->options['test'] as $i => $test) { $tests = array(); foreach (explode(',', $test) as $t1) { foreach (explode(' ', $t1) as $t2) { $t2 = strtolower(trim($t2)); if ($t2 && !in_array($t2, $tests)) { $tests[] = $t2; } } } if ($tests) { $this->options['test'][$i] = $tests; } else { unset($this->options['test'][$i]); } } // get parameters from a URL if (isset($this->options['params_url'])) { $headers = array(); if (isset($this->options['params_url_header'])) { foreach ($this->options['params_url_header'] as $header) { if (preg_match('/^(.*):(.*)$/', $header, $m)) { $headers[trim($m[1])] = trim($m[2]); } else { print_msg(sprintf('Skipping header %s because it is not properly formatted ([key]:[val])', $header), $this->verbose, __FILE__, __LINE__, TRUE); } } } if ($params = json_decode($json = ch_curl($this->options['params_url'], 'GET', $headers, NULL, NULL, '200-299', TRUE), TRUE)) { print_msg(sprintf('Successfully retrieved %d runtime parameters from the URL %s', count($params), $this->options['params_url']), $this->verbose, __FILE__, __LINE__); foreach ($params as $key => $val) { if (!isset($this->options[$key]) || in_array($key, $this->defaultsSet)) { print_msg(sprintf('Added runtime parameter %s=%s from --params_url', $key, is_array($val) ? implode(',', $val) : $val), $this->verbose, __FILE__, __LINE__); $this->options[$key] = $val; } else { print_msg(sprintf('Skipping runtime parameter %s=%s from --params_url because it was set on the command line', $key, $val), $this->verbose, __FILE__, __LINE__); } } // remove test endpoints that are not of the --params_url_service_type // specified if (isset($this->options['params_url_service_type'])) { foreach ($this->options['test_endpoint'] as $i => $endpoint) { if (!isset($this->options['test_service_type'][$i]) || !in_array($this->options['test_service_type'][$i], $this->options['params_url_service_type'])) { print_msg(sprintf('Removing test endpoint %s because it is not included in the allowed service types: %s', $endpoint, implode(', ', $this->options['params_url_service_type'])), $this->verbose, __FILE__, __LINE__); unset($this->options['test_endpoint'][$i]); } } } } else { return array('params_url' => is_string($json) ? sprintf('Response from --params_url %s is not valid JSON: %s', $this->options['params_url'], $json) : sprintf('Unable to retrieve data from --params_url %s', $this->options['params_url'])); } } // expand test endpoints: first element is public hostname/IP; second is private if (isset($this->options['test_endpoint'])) { foreach ($this->options['test_endpoint'] as $i => $endpoint) { $endpoints = array(); foreach (explode(',', $endpoint) as $e1) { foreach (explode(' ', $e1) as $e2) { $e2 = trim($e2); if ($e2 && !in_array($e2, $endpoints)) { $endpoints[] = $e2; } if (count($endpoints) == 2) { break; } } if (count($endpoints) == 2) { break; } } if ($endpoints) { $this->options['test_endpoint'][$i] = $endpoints; } else { unset($this->options['test_endpoint'][$i]); } } } // perform service lookups using CloudHarmony 'Identify Service' API if (isset($this->options['service_lookup'])) { foreach ($this->options['test_endpoint'] as $i => $endpoints) { $hostname = str_replace('*', rand(), get_hostname($endpoints[0])); if (!isset($this->options['test_service_id'][$i]) && ($response = get_service_info($hostname, $this->verbose))) { if (!isset($this->options['test_provider_id'][$i])) { $this->options['test_provider_id'][$i] = $response['providerId']; } if (!isset($this->options['test_service_id'][$i])) { $this->options['test_service_id'][$i] = $response['serviceId']; } if (!isset($this->options['test_service_type'][$i])) { $this->options['test_service_type'][$i] = $response['serviceType']; } if (!isset($this->options['test_region'][$i]) && isset($response['region'])) { $this->options['test_region'][$i] = $response['region']; } if (!isset($this->options['test_location'][$i]) && isset($response['country'])) { $this->options['test_location'][$i] = sprintf('%s%s', isset($response['state']) ? $response['state'] . ',' : '', $response['country']); } } } if (!isset($this->options['meta_compute_service_id']) && ($hostname = trim(shell_exec('hostname'))) && ($response = get_service_info($hostname, $this->verbose))) { if (!isset($this->options['meta_provider_id'])) { $this->options['meta_provider_id'] = $response['providerId']; } if (!isset($this->options['meta_compute_service_id'])) { $this->options['meta_compute_service_id'] = $response['serviceId']; } if (!isset($this->options['meta_region']) && isset($response['region'])) { $this->options['meta_region'] = $response['region']; } if (!isset($this->options['meta_location']) && isset($response['country'])) { $this->options['meta_location'] = sprintf('%s%s', isset($response['state']) ? $response['state'] . ',' : '', $response['country']); } } } // perform geo ip lookups to determine endpoint locations if (isset($this->options['geoiplookup'])) { foreach ($this->options['test_endpoint'] as $i => $endpoints) { $hostname = str_replace('*', rand(), get_hostname($endpoints[0])); if (!isset($this->options['test_location'][$i]) && (!isset($this->options['test_service_type'][$i]) || $this->options['test_service_type'][$i] != 'cdn' && $this->options['test_service_type'][$i] != 'dns') && ($geoip = geoiplookup($hostname, $this->verbose))) { $this->options['test_location'][$i] = sprintf('%s%s', isset($geoip['state']) ? $geoip['state'] . ', ' : '', $geoip['country']); } } if (!isset($this->options['meta_location']) && ($hostname = trim(shell_exec('hostname'))) && ($geoip = geoiplookup($hostname, $this->verbose))) { $this->options['meta_location'] = sprintf('%s%s', isset($geoip['state']) ? $geoip['state'] . ', ' : '', $geoip['country']); } } // expand meta_location to meta_location_country and meta_location_state if (isset($this->options['meta_location'])) { $pieces = explode(',', $this->options['meta_location']); $this->options['meta_location_country'] = strtoupper(trim($pieces[count($pieces) - 1])); if (count($pieces) > 1) { $this->options['meta_location_state'] = trim($pieces[0]); } } // expand test_location to test_location_country and test_location_state if (isset($this->options['test_location'])) { $this->options['test_location_country'] = array(); $this->options['test_location_state'] = array(); foreach ($this->options['test_location'] as $i => $location) { $pieces = explode(',', $location); $this->options['test_location_country'][$i] = strtoupper(trim($pieces[count($pieces) - 1])); $this->options['test_location_state'][$i] = count($pieces) > 1 ? trim($pieces[0]) : NULL; } } // expand throughput_webpage if (isset($this->options['throughput_webpage'])) { foreach ($this->options['throughput_webpage'] as $i => $resource) { $resources = array(); foreach (explode(',', $resource) as $e1) { foreach (explode(' ', $e1) as $e2) { $e2 = trim($e2); $resources[] = $e2; } } if ($resources) { $this->options['throughput_webpage'][$i] = $resources; } else { unset($this->options['throughput_webpage'][$i]); } } } // set meta_geo_region if (isset($this->options['meta_location'])) { $pieces = explode(',', $this->options['meta_location']); $this->options['meta_location_country'] = strtoupper(trim($pieces[count($pieces) - 1])); $this->options['meta_location_state'] = count($pieces) > 1 ? trim($pieces[0]) : NULL; if ($geoRegion = $this->getGeoRegion($this->options['meta_location_country'], isset($this->options['meta_location_state']) ? $this->options['meta_location_state'] : NULL)) { $this->options['meta_geo_region'] = $geoRegion; } } } } return $this->options; }