function create_connection($host, $port)
{
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if (!is_resource($socket)) {
        echo 'Unable to create socket: ' . socket_strerror(socket_last_error()) . PHP_EOL;
    } else {
        echo "Socket created.\n";
    }
    if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) {
        echo 'Unable to set option on socket: ' . socket_strerror(socket_last_error()) . PHP_EOL;
    } else {
        echo "Set options on socket.\n";
    }
    if (!socket_bind($socket, $host, $port)) {
        echo 'Unable to bind socket: ' . socket_strerror(socket_last_error()) . PHP_EOL;
    } else {
        echo "Socket bound to port {$port}.\n";
    }
    if (!socket_listen($socket, SOMAXCONN)) {
        echo 'Unable to listen on socket: ' . socket_strerror(socket_last_error());
    } else {
        echo "Listening on the socket.\n";
    }
    while (true) {
        $connection = @socket_accept($socket);
        if ($connection) {
            echo "Client {$connection} connected!\n";
            send_data($connection);
        } else {
            echo "Bad connection.";
        }
    }
}
Beispiel #2
0
function refresh_nodes()
{
    $fetchinfo_dev1 = mysql_query("SELECT * FROM `nodes` WHERE 1");
    while ($row_dev1 = mysql_fetch_array($fetchinfo_dev1)) {
        ${$remote_ip} = $row_dev1['ip'];
        $remote_port = $row_dev1['port'];
        $remote_password = $row_dev1['sec_token'];
        $fetchinfo_dev = mysql_query("SELECT * FROM `channels` WHERE 1");
        while ($row_dev = mysql_fetch_array($fetchinfo_dev)) {
            $channel = $row_dev['channel'];
            $value = $row_dev['value'];
            $device_id = $row_dev['group_id'];
            $message = "";
            $message = $message . "<device>";
            $message = $message . "<config pass='******'></config>";
            $message = $message . "<pin channel='" . $channel . "' value='" . $value . "' pass='******' device='" . $device_id . "'></pin>";
            $message = $message . "</device>";
            $log_update = mysql_query("INSERT INTO `log`(`message`) VALUES (socket)");
            send_data($remote_ip, $remote_port, $message);
        }
    }
}
$time = date("Y-m-d");
if (empty($_SESSION["login_status"])) {
    send_data("err", "请登录后再发表文章!");
    exit;
}
if (empty($id)) {
    send_data("err", "请输入文章的id!");
    exit;
}
if (empty($title)) {
    send_data("err", "请输入文章的标题!");
    exit;
}
$title = htmlspecialchars($title);
if (empty($content)) {
    send_data("err", "请输入文章的内容!");
    exit;
}
$content = preg_replace('/<script.*>(.|\\n|\\r|\\t|<br\\/>|<br>)*(<\\/script>)*/', '', $content);
$html = new simple_html_dom();
$html->load(urldecode($content));
$part_content = $html->find("p", 0) . $html->find("p", 1) . $html->find("p", 2);
/*if(empty($artical_cls)) {
		send_data("err", "请输入文章的分类!");
		exit;
	}
	$artical_cls = htmlspecialchars($artical_cls);*/
$username = $_SESSION["username"];
//$userid = $_SESSION["userid"];
$dbc = mysql_connect("localhost", "songgenlei_root", "19850903song");
if ($dbc) {
Beispiel #4
0
<?php

session_start();
unset($_SESSION);
$_SESSION = array();
session_destroy();
function send_data($status, $data)
{
    $arr = array();
    $arr["status"] = $status;
    $arr["data"] = $data;
    echo json_encode($arr);
}
send_data("ok", "登出成功!");
Beispiel #5
0
        foreach ($a as $key => $val) {
            $arr[$key] = htmlspecialchars($val);
        }
        return $arr;
    }
}
if (!isset($_SESSION["login_status"])) {
    header("location: http://happyonly.com.cn");
}
header("Content-type: text/html; charset=utf-8");
$data = html_encode($_POST);
$read = isset($data["read"]) ? $data["read"] : "";
$time = date("Y-m-d");
if (empty($read)) {
    send_data("err", "请填写内容!");
    exit;
}
$dbc = mysql_connect("localhost", "songgenlei_root", "19850903song");
if ($dbc) {
    mysql_select_db("songgenlei_blog", $dbc);
    mysql_query("SET NAMES 'UTF8'");
    $sql = "CREATE TABLE bookread (\n\t\t\treadID int NOT NULL AUTO_INCREMENT, \n\t\t\tPRIMARY KEY(readID),\n\t\t\tuserid varchar(10),\n\t\t\trd varchar(300),\n\t\t\ttime date\n\t\t)TYPE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
    mysql_query($sql, $dbc);
    $sql = "INSERT INTO bookread (\n\t\t\t`userid`, \n\t\t\t`rd`,\n\t\t\t`time`\n\t\t) VALUES (\n\t\t\t'" . $_SESSION["userid"] . "', \n\t\t\t'" . $read . "',\n\t\t\t'" . $time . "'\n\t\t)";
    if (mysql_query($sql, $dbc)) {
        send_data("ok", "保存成功");
    } else {
        send_data("err", "参数错误");
    }
    mysql_close($dbc);
}
        $familyname = $row["familyname"];
        $faceimg = $row["faceimg"];
        if (!isset($familyname)) {
            $familyname = "";
        }
        //读取所评论的评论数据
        $result = mysql_query("SELECT * FROM comment where commentID=" . $commentID);
        $row = mysql_fetch_array($result);
        $parentid = $row["userid"];
        //所评论的内容作者的ID
        $parent_name = $row["username"];
        //向评论的内容作者的用户名
        $parent_nickname = $row["nickname"];
        //向评论的内容作者的姓名
        $parent_faceimg = $row["faceimg"];
        //向评论的内容作者的头像
        $corder = substr($row["corder"], 0, 10) . $n;
        if (!isset($parent_familyname)) {
            $parent_familyname = "";
        }
        $sql = "INSERT INTO comment (\n\t\t\t\t`articalid`, \n\t\t\t\t`content`,\n\t\t\t\t`userid`,\n\t\t\t\t`username`,\n\t\t\t\t`nickname`,\n\t\t\t\t`faceimg`,\n\t\t\t\t`parentId`,\n\t\t\t\t`parent_name`,\n\t\t\t\t`parent_nickname`,\n\t\t\t\t`parent_faceimg`,\n\t\t\t\t`corder`,\n\t\t\t\t`time`\n\t\t\t) VALUES (\n\t\t\t\t'" . $articalid . "', \n\t\t\t\t'" . $content . "',\n\t\t\t\t'" . $userid . "', \n\t\t\t\t'" . $username . "',\n\t\t\t\t'" . $nickname . "',\n\t\t\t\t'" . $faceimg . "',\n\t\t\t\t'" . $parentid . "', \n\t\t\t\t'" . $parent_name . "', \n\t\t\t\t'" . $parent_nickname . "', \n\t\t\t\t'" . $parent_faceimg . "', \n\t\t\t\t'" . $corder . "',\n\t\t\t\t'" . $time . "'\n\t\t\t)";
        if (mysql_query($sql)) {
            send_data("ok", "评论发表成功");
        } else {
            send_data("err", "插入数据失败!");
        }
        mysql_close($dbc);
    }
} else {
    send_data("err", "请登录后再评论!");
}
Beispiel #7
0
<?php

function send_data($host, $port = '80', $data = '')
{
    $_err = 'lib sockets::' . __FUNCTION__ . '(): ';
    $str = $_POST['name'];
    $fp = fsockopen($host, $port, $errno, $errstr, $timeout = 30);
    if (!$fp) {
        die($_err . $errstr . $errno);
    } else {
        fputs($fp, $str . "\r\n");
        $d .= fgets($fp, 1024);
        fclose($fp);
    }
    return $d;
}
if ($_POST) {
    send_data('127.0.0.1', '8199', array('name' => $_POST['name']));
}
?>

<form method="post" name="sampleform" action="">
    
    <input type="text" name="name" value="" />
    <input type="submit" />
    
</form>
Beispiel #8
0
function post_method($url, $data, $header = '')
{
    global $key;
    if ($header == '') {
        $header = "Content-Type: application/x-www-form-urlencoded\r\n" . "U-ApiKey: {$key}\r\n" . "Content-Length: " . strlen($data) . "\r\n" . "User-Agent:MyAgent/1.0\r\n";
    }
    $options = array('http' => array('header' => $header, 'method' => 'POST', 'content' => $data));
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    //file_put_contents('/tmp/solid.log',$result."\n",FILE_APPEND);
    return $result;
}
function send_to_slack($msg)
{
    global $slack_rot;
    if ($msg > 20) {
        return;
    }
    $msg = '当前土壤湿度为:' . $msg . '%';
    $data = 'payload={"channel": "#mynotice", "text": "' . $msg . '"}';
    $command = "curl -X POST --data-urlencode '" . $data . "' {$slack_rot} > /dev/null 2>&1";
    exec($command);
}
//send_notify($argv[1]*100);
$result = send_data($argv[1] * 100);
file_put_contents('/tmp/solid_result.log', $result . "\n", FILE_APPEND);
$command = 'cat /sys/class/thermal/thermal_zone0/temp';
exec($command, $r1, $r2);
$val = $r1[0] / 1000;
send_data($val, 343089, 380665, false);
//send_to_slack($argv[1]*100);
Beispiel #9
0
function send_footer(&$exportPlugin)
{
    if (method_exists($exportPlugin, 'file_footer')) {
        send_data($exportPlugin->file_footer());
    }
}
}
if (empty($title)) {
    send_data("err", "请输入文章的标题!");
    exit;
}
$title = htmlspecialchars($title);
if (empty($content)) {
    send_data("err", "请输入文章的内容!");
    exit;
}
$content = preg_replace('/<script.*>(.|\\n|\\r|\\t|<br\\/>|<br>)*(<\\/script>)*/', '', $content);
$html = new simple_html_dom();
$html->load(urldecode($content));
$part_content = $html->find("p", 0) . $html->find("p", 1) . $html->find("p", 2);
if (empty($time)) {
    send_data("err", "请输入文章的文章的发表日期!");
    exit;
}
$username = $_SESSION["username"];
$userid = $_SESSION["userid"];
$dbc = mysql_connect("localhost", "songgenlei_root", "19850903song");
if ($dbc) {
    mysql_select_db("songgenlei_blog", $dbc);
    mysql_query("SET NAMES 'UTF8'");
    $sql = "CREATE TABLE artical (\n\t\t\tarticalID int NOT NULL AUTO_INCREMENT, \n\t\t\tPRIMARY KEY(articalID),\n\t\t\ttitle varchar(100),\n\t\t\tpart_content varchar(10000),\n\t\t\tcontent varchar(60000),\n\t\t\tartical_cls varchar(60),\n\t\t\tauthor varchar(60),\n\t\t\tuserid varchar(30),\n\t\t\tcomment_num varchar(30),\n\t\t\ttime date\n\t\t)TYPE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
    mysql_query($sql, $dbc);
    $sql = "INSERT INTO artical (\n\t\t\t`title`, \n\t\t\t`part_content`,\n\t\t\t`content`,\n\t\t\t`artical_cls`,\n\t\t\t`author`,\n\t\t\t`userid`,\n\t\t\t`comment_num`,\n\t\t\t`time`\n\t\t) VALUES (\n\t\t\t'" . $title . "', \n\t\t\t'" . $part_content . "', \n\t\t\t'" . $content . "',\n\t\t\t'" . $artical_cls . "',\n\t\t\t'" . $username . "',\n\t\t\t'" . $_SESSION["userid"] . "',\n\t\t\t'" . $comment_num . "',\n\t\t\t'" . $time . "'\n\t\t)";
    mysql_query($sql, $dbc);
    $result = mysql_query("SELECT * FROM artical order by articalID desc");
    $row = mysql_fetch_array($result);
    $arr["status"] = "ok";
Beispiel #11
0
<?php

session_start();
header("Content-type: text/html; charset=utf-8");
function send_data($status, $data)
{
    $arr = array();
    $arr["status"] = $status;
    $arr["data"] = $data;
    echo json_encode($arr);
}
if (isset($_SESSION["login_status"]) && $_SESSION["login_status"] == 1) {
    $data = array('username' => $_SESSION["username"], 'nickname' => $_SESSION["nickname"], 'userid' => $_SESSION["userid"]);
    send_data("ok", $data);
} else {
    send_data("err", "用户当前没登录!");
}
Beispiel #12
0
    mysql_query($sql, $dbc);
    //判断用户是否已经存在
    $isexit = 0;
    if ($result = mysql_query("SELECT * FROM user where username='******' OR nickname='{$nickname}'")) {
        while ($row = mysql_fetch_array($result)) {
            $isexit = 1;
        }
        if ($isexit == 1) {
            send_data("err", "用户名或昵称已存在!");
        } else {
            //添加用户
            $sql = "INSERT INTO user (\n\t\t\t\t\t`username`, \n\t\t\t\t\t`nickname`, \n\t\t\t\t\t`password`,\n\t\t\t\t\t`faceimg`,\n                    `login_time`\n\t\t\t\t) VALUES (\n\t\t\t\t\t'" . $username . "', \n\t\t\t\t\t'" . $nickname . "', \n\t\t\t\t\t'" . $password . "',\n\t\t\t\t\t'http://happyonly.com.cn/images/112.jpg',\n                    '" . $time . "',\n\t\t\t\t)";
            mysql_query($sql);
            $result = mysql_query("SELECT * FROM user where username='******' and password='******'");
            $row = mysql_fetch_array($result);
            if ($row) {
                $userid = $row["userID"];
            }
            $_SESSION["login_status"] = 1;
            $_SESSION["username"] = $username;
            $_SESSION["nickname"] = $nickname;
            $_SESSION["userid"] = $userid;
            send_data("ok", array('username' => $username, 'userid' => $userid));
        }
    } else {
        send_data("err", "查询数据库错误!");
    }
    mysql_close($dbc);
} else {
    send_data("err", "数据库连接错误!");
}
Beispiel #13
0
    send_data("err", "用户名格式不对!");
    return;
}
if (empty($password)) {
    send_data("err", "缺少密码!");
    return;
}
$dbc = mysql_connect("localhost", "songgenlei_root", "19850903song");
if ($dbc) {
    mysql_select_db("songgenlei_blog", $dbc);
    mysql_query("set names 'utf8'");
    $result = mysql_query("SELECT * FROM user where username='******' and password='******'");
    $row = mysql_fetch_array($result);
    if ($row) {
        $userid = $row["userID"];
        $nickname = $row["nickname"];
    }
    if (isset($userid)) {
        $_SESSION["login_status"] = 1;
        $_SESSION["username"] = $username;
        $_SESSION["nickname"] = $nickname;
        $_SESSION["userid"] = $userid;
        $data = array('username' => $username, 'userid' => $userid);
        $sql = "UPDATE user SET login_time='{$time}' where username='******'";
        mysql_query($sql);
        send_data("ok", $data);
    } else {
        send_data("err", "用户名或密码错误!");
    }
    mysql_close($dbc);
}
Beispiel #14
0
<?php

session_start();
header("Content-type: text/html; charset=utf-8");
function send_data($status, $data)
{
    $arr = array();
    $arr["status"] = $status;
    $arr["data"] = $data;
    echo json_encode($arr);
}
$data = $_GET;
$arr = array();
$id = $data["id"];
if (empty($id)) {
    send_data("err", "缺少文章id!");
    exit;
}
$username = $_SESSION["username"];
$userid = $_SESSION["userid"];
$dbc = mysql_connect("localhost", "songgenlei_root", "19850903song");
if ($dbc) {
    mysql_select_db("songgenlei_blog", $dbc);
    mysql_query("SET NAMES 'UTF8'");
    $result = mysql_query("SELECT * FROM artical where articalID='{$id}'");
    $row = mysql_fetch_array($result);
    if ($row) {
        $arr["status"] = "ok";
        $arr["data"] = array('articalid' => $row['articalID'], 'title' => $row['title'], 'part_content' => $row['part_content'], 'content' => $row['content'], 'artical_cls' => $row['artical_cls'], 'author' => $row['author'], 'userid' => $row['userid'], 'comment_num' => $row['comment_num'], 'comment_num' => $row['comment_num']);
        echo json_encode($arr);
    } else {
Beispiel #15
0
    $s = enumerate_w1_sensors(0, $keep);
    passthru("cat " . SENSORMAPFILE);
    exit(0);
}
$ltt = time() - SENSORPOLLTIME - 1;
$minmax = array();
xap_connect();
while (1) {
    if ($must_exit) {
        break;
    }
    //send xAP heartbeat periodically
    $t = floor(xap_check_send_heartbeat());
    //and return time in secs
    if ($t - $ltt >= SENSORPOLLTIME) {
        $tsent = send_data();
        $ltt = $t;
    }
    if ($must_exit) {
        break;
    }
    sleep(1);
    if ($must_exit) {
        break;
    }
    sleep(1);
    if ($must_exit) {
        break;
    }
    sleep(1);
    if ($must_exit) {
function do_flash()
{
    if (!isset($_REQUEST['target']) || !isset($_REQUEST['pattern'])) {
        echo "target,pattern required.";
        return;
    }
    $target = intval($_REQUEST['target']);
    $pattern = $_REQUEST['pattern'];
    //echo "pattern=[$pattern]";
    if ($target == 1) {
        send_data(PORT_ARD1, array(ord($pattern)));
    } elseif ($target == 2) {
        send_data(PORT_ARD2, array(ord($pattern)));
    } else {
        send_data(PORT_ARD1, array(ord($pattern)));
        send_data(PORT_ARD2, array(ord($pattern)));
    }
}
Beispiel #17
0
        $value = $row_dev10['value'];
        $fetchinfo_dev = mysql_query("SELECT * FROM `nodes` WHERE `active`='1'");
        while ($row_dev = mysql_fetch_array($fetchinfo_dev)) {
            $ip = $row_dev['ip'];
            $port = $row_dev['port'];
            $token = $row_dev['token'];
            /*
            $fetchinfo_dev1 = mysql_query("SELECT * FROM `channels` WHERE `active`='1'");
            while($row_dev1 = mysql_fetch_array($fetchinfo_dev1)) {
            	$channel = $row_dev1['channel'];
            	$value = $row_dev1['value'];
            	$device_id = $row_dev1['group_id'];
            */
            $request_message = "<pin output='" . $channel . "' value='" . $value . "' token='" . $token . "'></pin>";
            //$log_update = mysql_query("INSERT INTO `log`(`message`) VALUES ('".$ip."')");
            send_data($ip, $port, $request_message);
        }
    }
}
function send_data($_remote_ip, $_remote_port, $_message)
{
    if (preg_match('/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/', $_remote_ip)) {
        //  echo 'IP ist gültig.';
    } else {
        $_remote_ip = gethostbyname($_remote_ip);
    }
    if (!($sock = socket_create(AF_INET, SOCK_STREAM, 0))) {
        $errorcode = socket_last_error();
        $errormsg = socket_strerror($errorcode);
        die("Couldn't create socket: [{$errorcode}] {$errormsg} \n");
        $log_update = mysql_query("INSERT INTO `log`(`message`) VALUES ('" . $errormsg . "')");
Beispiel #18
0
if (isset($_POST["name"])) {
    $con = @mysql_connect($mysql_host, $mysql_user, $mysql_pass);
    if (!($con and mysql_select_db($mysql_db))) {
        echo "Fatal Error. Could not Connect to Database.";
        flush();
        die;
    }
    $regdata = mysql_query("SELECT * FROM `registry` WHERE `handle` = '{$_POST["name"]}'", $con);
    if (@mysql_num_rows($regdata) == 0) {
        $tosend .= "User Existiert nicht.";
        send_data();
    }
    $zoidberg = @mysql_fetch_array($regdata);
    if ($zoidberg["password"] != md5($_POST["pw"])) {
        $tosend .= "Falsches Passwort.";
        send_data();
    }
    // Change password only if the form is filed
    if (isset($_POST["pw2"])) {
        if ($_POST["pw2"] != $_POST["pw3"]) {
            $tosend .= "Passwörter stimmen nicht Ueberein.";
            send_data();
        }
        mysql_query("UPDATE `registry` SET `password`=MD5('{$_POST["pw2"]}') WHERE `handle`='{$_POST["name"]}'", $con);
        $tosend .= "Passwort geändert.<br />";
    }
} else {
    $tosend .= $actform;
}
send_data();
Beispiel #19
0
function sendmail($rcpt)
{
    global $mail;
    $fp = @fsockopen($mail["server"][rand(0, 2)], 25, $errno, $errstr, 20);
    $ret_msg = get_data($fp);
    $ret_code = substr($ret_msg, 0, 3);
    if (!$fp || $ret_code != "220") {
        $mail["msg"] = $ret_msg;
        return 0;
    } else {
        send_data($fp, "HELO " . $mail["urlKey"]);
        $ret_msg = get_data($fp);
        send_data($fp, "MAIL FROM: <" . $mail["fostMail"] . ">");
        $ret_msg = get_data($fp);
        send_data($fp, "RCPT TO: <" . $rcpt . ">");
        $ret_msg = get_data($fp);
        send_data($fp, "DATA");
        $ret_msg = get_data($fp);
        //			$header	= "From: \"".encode_2047($mail["fromName"])."\" <".$mail["fostMail"].">\r\n";
        $header = "From: \"" . $mail["fromName"] . "\" <" . $mail["fostMail"] . ">\r\n";
        $header .= "To: " . $rcpt . "\r\n";
        //			$header .= "Subject: ".encode_2047($mail["subject"])." \r\n";
        $header .= "Subject: " . $mail["subject"] . " \r\n";
        $header .= "Date: " . date("r") . "\r\n";
        $header .= "MIME-Version: 1.0\r\n";
        $header .= "Content-Type: text/html; \r\n              charset=\"euc-kr\"\r\n";
        $header .= "Content-transfer-encoding: base64 \r\n";
        send_data($fp, $header);
        $data = base64_encode($mail["body"]);
        send_data($fp, $data);
        send_data($fp, "");
        send_data($fp, "");
        send_data($fp, ".");
        $ret_msg = get_data($fp);
        $ret_code = substr($ret_msg, 0, 3);
        send_data($fp, "quit");
        get_data($fp);
        $mail["msg"] = $ret_msg;
        if ($ret_code == "250") {
            return 1;
        } else {
            return 0;
        }
    }
}
Beispiel #20
0
    //$header .= "X-LIST_TABLE: <".$word->word.">\r\n";
    //$header .= "X-Mailer: $xmailer\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $word = new rand_word(rand(13, 15), 0, 0, 0, 1);
    //$header .= "Message-ID: <".rnd_string(13,"number")."@".rnd_string(9,"word").".com>\r\n";
    $header .= "Content-Type: text/html; \r\n              charset=\"euc-kr\"\r\n";
    //$header .= "Content-transfer-encoding: 8bit \r\n";
    $header .= "Content-transfer-encoding: base64 \r\n";
    send_data($header);
    $data = base64_encode($data);
    send_data($data);
    send_data("");
    send_data("");
    send_data(".");
    get_data();
    send_data("quit");
    get_data();
    echo "ok!";
    exit;
}
/***************************************
 ** Function to generate boundary string.
 ***************************************/
function get_boundary()
{
    $one = sprintf("%03d", rand(1, 999));
    $two = sprintf("%03d", rand(1, 9999));
    $three = strtoupper(substr(md5(rand(1, 9999)), 0, 8));
    $four = strtoupper(substr(md5(rand(1, 9999)), -8));
    $word = new rand_word(rand(5, 15), false, true);
    return "----------------==" . $word->word . $one . "_" . $two . "_" . $three . "." . $four;
Beispiel #21
0
    $room->flag_active_member($Users->get_auth_email());
}
function get_members_list($room)
{
    global $config_server_poll_max_executing_time;
    return $room->get_members($config_server_poll_max_executing_time);
}
function get_admin_volume($room)
{
    return $room->get_admin_volume();
}
function get_admin_radio($room)
{
    return $room->get_admin_random_radio();
}
$room = $Rooms->get_room($room_id);
update_member_flag($room);
// add user to the room members list
//update admin flag
// check for admin presence
//$room->set_admin($Users->get_auth_id());
while (!is_timeout($start_time, $config_server_poll_max_executing_time)) {
    if (new_playlist_data($room_id, $update_version)) {
        $data = fetch_data($room);
        send_data((object) ["timeout" => false, "room_id" => $room_id, "room_options" => $data["room_options"], "update_version" => $data["update_version"], "currently_playing_id" => $data["currently_playing_id"], "playlist" => $data["playlist"], "history" => $data["history"], "chat" => $data["chat"], "stats" => $room->get_stats(), "members" => $data["members"], "admin_volume" => $data["admin_volume"], "admin_radio" => $data["admin_radio"]]);
    }
    usleep(1000);
}
//timeout data:
send_data((object) ["timeout" => true, "room_id" => $room_id, "members" => get_members_list($room)]);
function _stop()
{
    $data = array(255, AGB_ID, 1, 0);
    // 全モーターOFF
    send_data(PORT_AGB, $data);
}
Beispiel #23
0
}
if ($flush_header_with_x_bytes) {
    send_data($flush_header_with_x_bytes);
    full_flush();
}
if ($wait_after_headers_packet) {
    usleep($wait_after_headers_packet * 1000);
}
while ($sent_data_size < $size) {
    $flush_size = $flush_every_x_bytes - $sent_data_size % $flush_every_x_bytes;
    $wait_size = $wait_every_x_bytes - $sent_data_size % $wait_every_x_bytes;
    $send_size = min($flish_size, $wait_size);
    if (!$send_size) {
        $send_size = max($flish_size, $wait_size);
    }
    send_data($send_size);
    if ($sent_data_size % $flush_every_x_bytes === 0) {
        full_flush();
    }
    if ($sent_data_size % $wait_every_x_bytes === 0) {
        usleep($wait_duration_every_x_bytes * 1000);
    }
}
function send_data($size)
{
    global $sent_data_size;
    echo str_repeat("a", $size);
    $sent_data_size += $size;
}
function full_flush()
{