function user_update_user_base($uid, $need_online = 0) { global $zeit, $g_sunrise; $sql = "SELECT * FROM u_user WHERE uid={$uid}"; $rst = mysql_w_query($sql); $row_user_base = array(); //if($row_user_base=mysql_fetch_assoc($rst)){ // //}else{ // return false; //} //set_cache($uid,'user_base_info',$row_user_base,$need_online); return $row_user_base; }
function get_online_info($uid, $sid, $zeit) { //在线统计 $v_online = get_cache($uid, 'online', 1); if ($v_online == -1) { $online_id = gen_online_id($uid, $sid, $zeit); $online['online_id'] = $online_id; $online['sid'] = $sid; $online['last_update_db_online'] = $zeit; set_cache($uid, 'online', $online); $v_online = $online; } elseif ($v_online == -2) { $sql = "SELECT MAX(`id`) as max_id FROM `st_online_details` WHERE `uid`='{$uid}'"; $rst = mysql_query($sql); if ($row = mysql_fetch_assoc($rst)) { $online['online_id'] = $row['max_id']; } else { $online_id = gen_online_id($uid, $sid, $zeit); $online['online_id'] = $online_id; } $online['sid'] = $sid; $online['last_update_db_online'] = $zeit; set_cache($uid, 'online', $online); $v_online = $online; } elseif ($v_online['sync_memcache'] == 1) { $v_online = $v_online['data']; $sql = "UPDATE st_online_details SET last_online={$zeit} WHERE id={$v_online['online_id']}"; $rst = mysql_w_query($sql); $sql = "UPDATE u_user SET last_online={$zeit} WHERE uid={$uid}"; $rst = mysql_w_query($sql); } else { $v_online = $v_online['data']; } if ($v_online['sid'] != $sid) { set_cookie($uid, $v_online['sid'], 0); $sid = $v_online['sid']; } return $v_online; }
function import_per_item($path, $file, $file_name, $file_ext, $key, $value) { global $lang; global $g_supply_lang; if ($lang == 'cn') { //看是否存在这个Key $sql = "SELECT i.t_value,k.id as key_id,i.id as value_id\r\n FROM `trans_file_key` k\r\n LEFT JOIN `trans_item` i ON i.`t_key_id` = k.`id` AND i.`lang`='cn'\r\n WHERE `filename`='{$file_name}' AND `filetyp`='{$file_ext}' AND `t_key`='{$key}'"; $rst = mysql_x_query($sql); if ($row = mysql_fetch_array($rst)) { //KEY存在,比对VALUE是否更新 if ($row['t_value'] == $value) { return; } else { $key_id = $row['key_id']; $value_id = $row['value_id']; //更新了,更新LANG=CN的T_VALUE,and update all lang!=cn ,set flag=1 $sql = "UPDATE trans_item\r\n SET `t_value`='{$value}',`flag`=2\r\n WHERE id={$value_id}"; mysql_w_query($sql); $sql = "UPDATE trans_item\r\n SET `flag`=1\r\n WHERE lang!='cn' AND `t_key_id`={$key_id}"; mysql_w_query($sql); } } else { //insert the key //insert the value of lang=cn //insert the value of lang!=cn with flag=0 and value=null $sql = "INSERT INTO trans_file_key\r\n (`dir`,`filename`,`filetyp`,`t_key`)\r\n VALUES\r\n ('','{$file_name}','{$file_ext}','{$key}')"; mysql_w_query($sql); $key_id = mysql_insert_id(); $sql = "INSERT INTO trans_item\r\n (`lang`,`t_key_id`,`t_value`,`flag`)\r\n VALUES\r\n "; $sql_plus[] = "('cn','{$key_id}','{$value}','2')"; foreach ($g_supply_lang as $this_lang) { if ($this_lang == 'cn') { continue; } $sql_plus[] = "('{$this_lang}','{$key_id}','','0')"; } if (count($sql_plus) > 0) { $sql = $sql . join(',', $sql_plus); } mysql_w_query($sql); } } else { //lang!=cn not allow insert new key //read key table $sql = "SELECT i.t_value,k.id as key_id,i.id as value_id\r\n FROM `trans_file_key` k\r\n LEFT JOIN `trans_item` i ON i.`t_key_id` = k.`id` AND i.`lang`='{$lang}'\r\n WHERE `filename`='{$file_name}' AND `filetyp`='{$file_ext}' AND `t_key`='{$key}'"; $rst = mysql_x_query($sql); if ($row = mysql_fetch_array($rst)) { //KEY存在,比对VALUE是否更新 if ($row['t_value'] == $value) { return; } else { $key_id = $row['key_id']; $value_id = $row['value_id']; //更新了,更新LANG=$lang的T_VALUE,and update lang=$lang with flag=1 $sql = "UPDATE trans_item\r\n SET `flag`=1,`t_value`='{$value}'\r\n WHERE id = {$value_id}"; mysql_w_query($sql); } } else { return; } } }
function base_check_user_online($uid, $typ = 1) { global $g_config, $zeit; if ($typ == 1) { $sql = "SELECT id FROM st_online_details WHERE last_online>={$zeit}-30*60 AND last_online<={$zeit}"; $rst = mysql_w_query($sql); if (mysql_num_rows($rst) > 0) { return true; } else { return false; } } else { if ($typ == 2) { $user_name = $g_config['srv_id'] . $uid; $chat_server = $g_config['chat']['server']; $url = "http://{$chat_server}:5280/api/status/online?key=secret&username={$user_name}&host={$chat_server}&resource=xiff"; $rst = call_remote_by_curl($url); if ($rst >= 1) { return true; } else { return false; } } } }
function pickup_name_by($nid, $name_num) { $sql = "SELECT rand_value FROM s_lastname ORDER BY rand_value limit"; $rst = mysql_w_query($sql); $row = mysql_fetch_assoc($rst); $mix_rand = $row['rand_value']; $sql = "SELECT rand_value FROM s_lastname ORDER BY rand_value limit DESC"; $rst = mysql_w_query($sql); $row = mysql_fetch_assoc($rst); $max_rand = $row['rand_value']; $index = mt_rand($mix_rand, $max_rand); $sql = "SELECT * FROM s_lastname WHERE rand_value = {$index}"; $rst = mysql_w_query($sql); $row = mysql_fetch_assoc($rst); $lastname = $row['simplified_chinese']; $sql = "SELECT rand_value FROM s_firstname ORDER BY rand_value limit"; $rst = mysql_w_query($sql); $row = mysql_fetch_assoc($rst); $mix_first_rand = $row['rand_value']; $sql = "SELECT rand_value FROM s_firstname ORDER BY rand_value limit DESC"; $rst = mysql_w_query($sql); $row = mysql_fetch_assoc($rst); $max_first_rand = $row['rand_value']; $first_index = mt_rand($mix_first_rand, $max_first_rand); $sql = "SELECT * FROM s_firstname WHERE rand_value = {$first_index}"; $rst = mysql_w_query($sql); $row = mysql_fetch_assoc($rst); $firstname = $row['simplified_chinese']; $name = $firstname . $lastname; return $name; }