0) { foreach ($array as $l) { fwrite($f, trim(join('%%', $l))); fwrite($f, "\n"); } } fclose($f); } // ------------------------------------- // write an index // ------------------------------------- function use_index($file) { if (!file_exists($file)) { $f = fopen($file, 'w'); update_next_index($f, 0); fclose($f); } } // ------------------------------------- // write an index // ------------------------------------- function read_next_index($f, &$index) { fseek($f, 0, SEEK_SET); $index = (int)fgets($f, 512); } // ------------------------------------- // write an index // ------------------------------------- function update_next_index($f, $index) { fseek($f, 0, SEEK_SET); fwrite($f, str_pad($index, 256)); fwrite($f, "\n"); } // ------------------------------------- // write an index // ------------------------------------- function append_to_index($f, $line) { fseek($f, 0, SEEK_END); fwrite($f, $line, 8192); fwrite($f, "\n"); } // ------------------------------------- // write html prolog // ------------------------------------- function write_prolog($f, $title) { fwrite($f, "$title\n"); } // ------------------------------------- // write html epilog // ------------------------------------- function write_epilog($f) { fwrite($f, "\n"); } // ------------------------------------- // read template file // ------------------------------------- function read_template($file, &$template) { global $TEMPLATE_DIR; $filename = $TEMPLATE_DIR.'/'.$file; $f = fopen($filename, 'r'); $template = fread($f, filesize($filename)); fclose($f); } // ------------------------------------- // redirect // ------------------------------------- function redirect($url, $time=0) { echo "Redirecting...\n"; echo "\n"; echo "\n"; echo "\n"; } // ------------------------------------- // convert to forum name // ------------------------------------- function convert_forum_name($str) { return ucfirst(strtr($str, '_', ' ')); } // ------------------------------------- // clean string // ------------------------------------- function clean_string($str) { return strtr($str, array("\n" => '', '%' => '\%')); } // ------------------------------------- // clean content // ------------------------------------- function clean_content($str) { return strtr($str, array("\n" => '\n', '%' => '\%')); } // ------------------------------------- // displayable string // ------------------------------------- function displayable_string($str) { return nl2br(htmlspecialchars(stripslashes($str), ENT_QUOTES)); } // ------------------------------------- // displayable string // ------------------------------------- function displayable_content($str) { return htmlspecialchars(stripcslashes($str), ENT_QUOTES); } // ------------------------------------- // displayable string // ------------------------------------- function displayable_date() { return "date#".date("y/m/d")." ".date("H:i"); } function matchParam($var, $param, &$value) { $plen = strlen($param); if (!strncmp($param, $var, $plen)) { $value = trim(substr($var, $plen)); return true; } return false; } function nameToFile($name) { $r = ''; for ($i=0; $i= chr(127)) $r .= sprintf("%%%02x", ord($name[$i])); else $r .= $name[$i]; } return $r; } function nameToURL($name) { $r = ''; for ($i=0; $i ring_live.characters[user_login].guild_id // test ring_live.guilds[guild_id].guild_name == $forum // ------------------------------------- function check_character_belongs_to_guild($charName, $guildName) { connect_to_ring_db(); $res = mysql_query( "SELECT guilds.guild_name FROM guilds JOIN characters ON characters.guild_id=guilds.guild_id WHERE char_name='$charName'") or die("Can't query guild for $charName in DB"); if (false === ($row = mysql_fetch_row($res))) die("Guild not found for char $charName in DB"); if ($row[0] != $guildName) die("ACCESS DENIED: $charName is not a member of $guildName"); } $remote_addr = $HTTP_SERVER_VARS['REMOTE_ADDR']; if ($remote_addr == "213.208.119.226" || $remote_addr == "38.117.236.132") { importParam('internal_check'); if ($internal_check) { echo "INTERNAL CHECK\n"; die("$internal_check:1"); } } /* * check user is valid */ if ($user_login == "support" && ($remote_addr == "192.168.1.153" || $remote_addr == "192.168.3.1") || $remote_addr == "127.0.0.1" ) { echo "SUPPORT MODE!"; // do not check "support" email that come from rsweb //echo $HTTP_SERVER_VARS['REMOTE_ADDR']; //die(); importParam('translate_user_login'); if ($translate_user_login) $user_login = $translate_user_login; } else { if (!strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'Ryzom')) die("ERROR: Bad parameters"); $udir = get_user_dir($user_login, $shard); $ufile = $udir.'session'; if (is_dir($udir) && file_exists($ufile)) { $file = fopen($ufile, 'r'); if (!$file) die("ERROR: Not logged"); $server_cookie = trim(fgets($file, 1024)); if ($server_cookie != $session_cookie) die("ERROR: Authentication failed"); } else { die("ERROR: Directory not found: ".$udir); } } } ?>