예제 #1
0
 public static function mv_uploaded_file($file_array)
 {
     global $lasterror;
     global $language;
     $upload_path = GlobalFunc::get_stream_path(self::$_tid);
     if ($upload_path) {
         foreach ($file_array as $i => $a) {
             if (!move_uploaded_file($a['tmp_name'], "{$upload_path}" . self::$_tid . '.UP.' . "{$i}")) {
                 $lasterror[] = $a['tmp_name'] . ' move to: ' . "{$upload_path}" . self::$_tid . '.UP.' . "{$i}";
             }
         }
     } else {
         $lasterror[] = $language['fail_stream_path'];
     }
 }
예제 #2
0
     $query = 'update ' . $mysql_ini['prefix'] . 'online_task set status = ' . $status . ' where tid=\'' . $tid . '\' and status=1 and cid=' . $cid . ' limit 1';
     $db->query($query);
     HYP_IPC::task_response($tid, $cid . ':' . $status, ':', "");
     //mylog($query);
 } else {
     $query = 'select chunk,status,size,module from ' . $mysql_ini['prefix'] . 'online_task where tid=\'' . $tid . '\' and cid=' . $cid . ' limit 1';
     $result = $db->query($query);
     if (1 === mysqli_num_rows($result)) {
         $result = $result->fetch_assoc();
         if ($result['chunk']) {
             //stream
             if (1 == $result['status'] or 2 == $result['status']) {
                 $data = @file_get_contents('php://input');
                 $c_size = strlen($data);
                 if ($c_size) {
                     $c_stream_file = GlobalFunc::get_stream_path($tid);
                     if ($c_size === file_put_contents($c_stream_file . $tid . '.DOWN.' . $result['chunk'], $data)) {
                         $query = 'update ' . $mysql_ini['prefix'] . 'online_task set status = 2,chunk=chunk+1';
                         if ($stream_size and 0 == $result['size']) {
                             //以控制端请求长度为准
                             $query .= ',size= ' . $stream_size;
                         }
                         $query .= ' where tid=\'' . $tid . '\' and cid=' . $cid . ' limit 1';
                         $db->query($query);
                         $ret = 1;
                     }
                 }
             }
         } else {
             //normal
             if (1 == $result['status']) {
예제 #3
0
ignore_user_abort(true);
define("STREAM_TASK_END_OVERTIME", 51);
define("STREAM_TASK_END_BROWSERBROKE", 52);
define("STREAM_TASK_END_COMPLISHED", 53);
define("STREAM_TASK_END_UNKNOWN", 54);
define("STREAM_TASK_END_READFILE", 55);
define("STREAM_TASK_END_CONNMYSQL", 56);
$header_show = false;
$end_status = STREAM_TASK_END_UNKNOWN;
$streamWaitExpire = 60;
$waitSecPer = 2;
if (!$lasterror) {
    $chunked_size = 0;
    $chunk_output = 1;
    $waitSeconds = 0;
    $stream_file = GlobalFunc::get_stream_path($TaskId, false);
    $stream_file .= "{$TaskId}" . '.DOWN.';
    $query = 'select chunk,size,status from ' . $mysql_ini['prefix'] . 'online_task where tid=\'' . $TaskId . '\' limit 1';
    while (!$lasterror) {
        $result = $db->query($query);
        if (1 != mysqli_num_rows($result)) {
            $lasterror[] = 'select Task fail StreamLoop';
        } else {
            $tmp = $result->fetch_assoc();
            $chunk_input = $tmp['chunk'];
            $totalSize = $tmp['size'];
            if (1 != $tmp['status'] and 2 != $tmp['status'] and 0 != $tmp['status']) {
                $lasterror[] = 'status = ' . $tmp['status'];
                break;
            }
            while ($chunk_output < $chunk_input) {
예제 #4
0
<?php

ini_set('display_errors', 0);
include "../include/config.inc.php";
include "../library/global.func.php";
$tid = $_REQUEST['tid'];
$tNo = intval($_REQUEST['tno']);
$mid = $_REQUEST['mid'];
$os = intval($_REQUEST['os']);
$c_stream_file = false;
if (preg_match('/^[a-fA-F0-9]{32}$/', $mid)) {
    $c_stream_file = $repo_path . 'bin/' . $mid . '.' . $os;
} elseif (preg_match('/^[a-zA-Z0-9]{32}$/', $tid)) {
    $c_stream_file = GlobalFunc::get_stream_path($tid, false);
    $c_stream_file .= "{$tid}" . '.UP.' . "{$tNo}";
}
if ($c_stream_file and file_exists($c_stream_file)) {
    $a = file_get_contents($c_stream_file);
    $totalSize = strlen($a);
    header("Content-Length: " . $totalSize);
    exit($a);
}
exit;