コード例 #1
0
ファイル: LamPI-daemon.php プロジェクト: RobQuistNL/LamPI-2.0
* 3. We read the timers database to see if there are timers that fire. 
*	- If a timer expires, we lookup the corresponding scene
*	- We decompose/explode the commandstring of the scene into separate command/time pairs
*	- Each command/timer pair is inserted in the queue
*/
/*	==============================================================================	*/
$ret = 0;
set_time_limit(0);
// NO execution time limit imposed
ob_implicit_flush();
$log = new Logging();
// Logging class initialization, maybe init at declaration
$sensor = new Sensor();
// Weather Log
$queue = new Queue();
$sock = new Sock();
$dlist = new Device();
// Class for handling of device specific commands
$wthr = new Weather();
// Class for Weather handling in database
// set path and name of log file (optional)
$log->lfile($log_dir . '/LamPI-daemon.log');
$log->lwrite("-------------- STARTING DAEMON ----------------------");
sleep(2);
// Open the SQL handler to the mysql daemon
$pisql = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($pisql->connect_errno) {
    $log->lwrite("LamPI-daemon:: Failed to connect to MySQL: (" . $pisql->connect_errno . ") " . $pisql->connect_error, 1);
    exit(1);
}
// Some variables that are probably (re)set by get_parse();
コード例 #2
0
ファイル: ServerSocket.php プロジェクト: xswolf/baihey
<?php

error_reporting(E_ALL ^ E_NOTICE);
ob_implicit_flush();
$sk = new Sock('120.76.84.162', 8080);
//$sk = new Sock( '127.0.0.1' , 8080 );
$sk->run();
class Sock
{
    public $sockets;
    public $users;
    public $master;
    public $client;
    private $sda = [];
    //已接收的数据
    private $slen = [];
    //数据总长度
    private $sjen = [];
    //接收数据的长度
    private $ar = [];
    //加密key
    private $n = [];
    public function __construct($address, $port)
    {
        $this->master = $this->WebSocket($address, $port);
        $this->sockets = [$this->master];
    }
    function run()
    {
        while (true) {
            $changes = $this->sockets;
コード例 #3
0
ファイル: index.php プロジェクト: jechx/study
<?php

require './http.class.php';
header('Content-type:text/html;charset=utf-8');
/*
 * 反防盗链
 */
$url = 'http://168.192.8.35/a.jpg';
$sock = new Sock($url);
$sock->setHead('Referer:http://localhost');
$res = $sock->get();
file_put_contents('d.jpg', substr(strstr($res, "\r\n\r\n"), 4));
/**
 *获取a.jpg,  并保存为c.jpg
 *
$url = 'http://localhost/a.jpg';
$sock = new Sock($url);
$res = $sock->get();

file_put_contents('c.jpg',substr(strstr($res,"\r\n\r\n"),4));
*/
//get 测试
//echo $sock->get();
/* post 测试
$url = 'http://news.163.com/15/0625/04/ASU94A9P0001124J.html';
$sock = new Sock($url);

$postContent = array(
	'title' => 'a',
	'content'=>'i am the test !'
);