Esempio n. 1
0
function main()
{
    $fp = fsockopen("unix://../unixsocket.socket", -1, $errno, $errstr, 0.1);
    echo "got fp\n";
    if (!$fp) {
        echo "{$errstr} ({$errno})\n";
    } else {
        $str = "我就是觉得现在互联网的限制太过无耻了!我擦,到底网络防火墙是谁搞出来的.为什么现在互联网什么都不给用?广电总局到底要封杀网络影音到什么时候。什么时候中国的网络环境能变好?我们要更开放的网络!";
        for ($i = 0; $i < 5; ++$i) {
            $str .= $str;
        }
        echo "original strlen [" . strlen($str) . "]\n";
        $arrDataPackets = pack_data($str);
        $syn_packet = pack_syn(count($arrDataPackets));
        $fin_packet = pack_fin();
        echo "syn_packet is [{$syn_packet}], length is [" . strlen($syn_packet) . "]\n";
        fwrite($fp, $syn_packet, strlen($syn_packet));
        foreach ($arrDataPackets as $data_packet) {
            fwrite($fp, $data_packet, strlen($data_packet));
        }
        fwrite($fp, $fin_packet, strlen($fin_packet));
        echo "written something\n";
        $arrPackets = read_packets($fp);
        fclose($fp);
        if (false === $arrPackets) {
            echo "Error reading packets\n";
            die(-1);
        }
        //print_r($arrPackets);
        $server_data = implode($arrPackets['data']);
        echo "server data strlen [" . strlen($server_data) . "]\n";
        echo $server_data . "\n";
        echo "done\n";
    }
}
Esempio n. 2
0
function mysave()
{
    global $id, $er;
    global $auth, $site_path;
    global $tournamentId;
    $orderData = pack_data();
    $ermess = checkorderBuilder($orderData);
    if ($ermess) {
        print "<script>alert('Ошибка сохранения ордера: " . $ermess . "')</script>";
        $er = 1;
        return;
    }
    if ($id) {
        $file = fopen($site_path . "files/ord/" . $id . "-" . $auth->user . ".ord", "w");
        fputs($file, $orderData);
        fclose($file);
    } else {
        $file = fopen($site_path . "files/preord/" . $auth->user . ".ord", "w");
        fputs($file, $orderData);
        fclose($file);
    }
}
 public function ajaxReturn($code, $msg = '', $data = array())
 {
     return parent::ajaxReturn(pack_data($code, $msg, $data));
 }
Esempio n. 4
0
function mysave()
{
    global $id;
    global $auth;
    global $tournamentId;
    echo "test";
    $orderData = pack_data();
    $ermess = checkorderBuilder($tournamentId, $orderData);
    if ($ermess) {
        print "<script>alert('Ошибка сохранения ордера: " . $ermess . "')</script>";
        return;
    }
    if ($id > 0) {
        $orderData = addslashes($orderData);
        $q = select("select TournamentID from ut_matches where MatchID='{$id}'");
        $tournamentId = $q[0];
        $ip = $_SERVER['REMOTE_ADDR'];
        mysql_query("delete from ut_orders where TeamID='{$auth->team}' and TournamentID='{$tournamentId}'");
        mysql_query("insert into ut_orders(TeamID,Name,Date,IP,OrderFile,TournamentID,Tour) values(" . $auth->team . ",'" . $name . "',UNIX_TIMESTAMP(),'{$ip}','{$orderData}',{$tournamentId}," . "(1+ coalesce((\nselect Tour from ut_maxtour where TournamentID='{$tournamentId}' limit 0,1\n) ,0)))");
        //mysql_query("update ut_matches set OrderTeam1='$orderData',DateOrder1=unix_timestamp() where MatchID='$id' and TeamID1='$auth->team'");
        //mysql_query("update ut_matches set OrderTeam2='$orderData',DateOrder2=unix_timestamp() where MatchID='$id' and TeamID2='$auth->team'");
    } else {
        if ($tournamentId > 0) {
            echo "TOUR";
            mysql_query("delete from ut_orders where TeamID='{$auth->team}' and TournamentID='{$tournamentId}'");
            mysql_query("insert into ut_orders(TeamID,Name,Date,IP,OrderFile,TournamentID,Tour) values(" . $auth->team . ",'" . $name . "',UNIX_TIMESTAMP(),'{$ip}','{$orderData}',{$tournamentId}," . "(1+ coalesce(\n(select Tour from ut_maxtour where TournamentID='{$tournamentId}' limit 0,1) ,0)))");
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
            $name = $_POST["filename"];
            $res = mysql_query("select OrderID from ut_orders where IP='" . $ip . "' and Name='" . $name . "'");
            if ($data = mysql_fetch_row($res)) {
                $res = mysql_query("update ut_orders set TeamID=" . $auth->team . ",Name='{$name}',Date=UNIX_TIMESTAMP(),IP='{$ip}',OrderFile='{$orderData}' where OrderID = " . $data[0]);
            } else {
                $res = mysql_query("insert into ut_orders(TeamID,Name,Date,IP,OrderFile)values(" . $auth->team . ",'" . $name . "',UNIX_TIMESTAMP(),'{$ip}','{$orderData}')");
                $res = mysql_query("select Name,OrderID from ut_orders where TeamID=" . $auth->team . " and Name='{$name}'");
                $data = mysql_fetch_row($res);
                echo "<script>window.parent.appendNewFileName('{$data['0']}',{$data['1']});</script>";
            }
        }
    }
}