Files
Testing/createchatroom.php

44 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2026-11-17 16:15:01 -05:00
<?php
$page = "general";
include "header.php";
if(isset($_POST["submit"])){
$host = "127.0.0.1";
$port = 51127;
$apiCommand = '<?xml version="1.0" encoding="UTF-8"?><Command group="default" api_pwd="3874-3459-9293-2194" type="add_room" name="'.addslashes($_POST["name"]).'" owner="'.$user->user_info["user_username"].'" desc="'.addslashes($_POST["desc"]).'" max="'.$_POST["limit"].'" pwd="'.addslashes($_POST["password"]).'" />';
$result = "";
$resultDoc = "";
$fp = @fsockopen($host, $port, &$errno, &$errstr, 2);
if(!$fp)
{
echo "Failed to excute api command,maybe host chat server is not started";
}
else
{
fputs($fp,$apiCommand."\0");
while (!feof($fp))
{
$resultDoc .= fgets($fp, 1024);
$resultDoc = rtrim($resultDoc);
}
$parser = xml_parser_create("UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
if (!xml_parse_into_struct($parser, $resultDoc, $values, $tags))
{
printf("XML error: %s at line %d while parsing entity n",
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser));
echo "xml parse error";
}
else
{
print_r($values);
xml_parser_free($parser);
fclose($fp);
}
}
}
header("Location: vidchat.php");
exit;
?>