<commit_before><?php
include 'emostore_admin_sqlsetting.php';
$keys = ["id","name","iconurl","postedon","introduction","creator","creatorurl","server","serverurl","dataformat","installurl","codeurl"];
@mysql_connect($db_host,$db_user,$db_password)
or die("ERROR=数据库连接失败");
@mysql_select_db($db_name)
or die("ERROR=选择数据库失败");
$sql = "select * from `emoticonstore`.`emostore`";
$query = @mysql_query($sql)
or die("ERROR=SQL语句执行失败，查询数据失败。");
while ($row=mysql_fetch_array($query)) {
	$arr[] = $row;
}
toXml($arr,$keys);

function toXml($arr,$keys)
{
	$data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	for ($i =  0; $i < count($arr); $i++) {
		$arri = $arr[$i];
		$data = $data."<source id=".$arri["id"].">";
		for ($j = 1; $j < count($keys); $j++)
		{
			$nowkey = $keys[$j];
			$nowvalue = $arri[$nowkey];
			$data = $data."<".$keys[$j].">".$nowvalue."</".$keys[$j].">";
		}
		$data = $data."</source>";
		echo $data;
	}
}
?><commit_msg>JSON输出<commit_after><?php
include 'emostore_admin_sqlsetting.php';
$keys = ["id","name","iconurl","postedon","introduction","creator","creatorurl","server","serverurl","dataformat","installurl","codeurl"];
@mysql_connect($db_host,$db_user,$db_password)
or die("ERROR=数据库连接失败");
@mysql_select_db($db_name)
or die("ERROR=选择数据库失败");
$sql = "select * from `emoticonstore`.`emostore`";
$query = @mysql_query($sql)
or die("ERROR=SQL语句执行失败，查询数据失败。");
while ($row=mysql_fetch_array($query)) {
	$arr[] = $row;
}
echo toXml($arr,$keys);
//echo toJson($arr,$keys);

//Extensible Markup Language
function toXml($arr,$keys)
{
	$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	for ($i =  0; $i < count($arr); $i++) {
		$arri = $arr[$i];
		$xml = $xml."<source id=".$arri["id"].">";
		for ($j = 1; $j < count($keys); $j++)
		{
			$nowkey = $keys[$j];
			$nowvalue = $arri[$nowkey];
			$xml = $xml."<".$keys[$j].">".$nowvalue."</".$keys[$j].">";
		}
		$xml = $xml."</source>";
		return $xml;
	}
}

//JavaScript Object Notation
function toJson($arr,$keys)
{
	$json = "[";
	for ($i =  0; $i < count($arr); $i++) {
		$arri = $arr[$i];
		$json = $json."{";
		for ($j = 1; $j < count($keys); $j++)
		{
			$nowkey = $keys[$j];
			$nowvalue = $arri[$nowkey];
			$json = $json."\"".$keys[$j]."\":\"".$nowvalue."\",";
		}
		$json = substr($json, 0, -1);
		$json = $json."},";
	}
	$json = substr($json, 0, -1);
	$json = $json."]";
	return $json;
}

//
?>
{'fraction_non_alphanumeric': 0.2895069532237674, 'fraction_numerical': 0.0067425200168563, 'mean_word_length': 5.134366925064599, 'pattern_counts': {'":': 1, '<': 21, '<?xml version=': 2, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3647891', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1033, 'n_words': 162}