<?php
require_once(ROOT."./inc/common.php");
require_once(ROOT.'./inc/filedb.php');
require_once(ROOT.'./_config.php');

function str2int(&$arr){
	for($i=0;$i<count($arr);$i++){
		$arr[$i] = (int)$arr[$i];
	}
	return $arr;
}

function replaces(&$data,$keys,$str){
	foreach($keys as $k){
		$data[$k] = str_replace($str,'',$data[$k]);
	}
}


function gameGameListSelect($domid='',$html='select',$href='###'){
	//游戏列表
	global $GAMES;
	$lists = $GAMES;
	
	if($html=='select'){
		$html = '<select id="'. (isn($domid)?"gamelistselect":$domid) .'">';
		$html .= '<option value="">选择游戏</option>';
		foreach($lists as $game){
			$html .= '<option value="'. $game .'">'. $game .'</option>';
		}
		$html .= '</select>';
	}
	return $html;
}


//获取文件列表
function list_dir($dir){
	$result = array();
	if (is_dir($dir)){
		$file_dir = scandir($dir);
		foreach($file_dir as $file){
			if ($file == '.' || $file == '..'){
				continue;
			}
			elseif (is_dir($dir.$file)){
				$result = array_merge($result, list_dir($dir.$file.'/'));
			}
			else{
				array_push($result, $dir.$file);
			}
		}
	}
	return $result;
}


?>