setFetchMode(DB_FETCHMODE_ASSOC); $gb = &new GreenBox(&$dbc, $config); $token = $_REQUEST['token']; function http_error($code, $err){ header("HTTP/1.1 $code"); header("Content-type: text/plain; charset=UTF-8"); echo "$err\r\n"; exit; } $tc = $gb->bsCheckToken($token, 'put'); if(PEAR::isError($tc)){ echo "ERR".$tc->getMessage()."\n"; exit; } if(!$tc){ http_error(410, "Token not valid."); } #var_dump($tc); exit; header("Content-type: text/plain"); #var_dump($_SERVER); var_dump($_REQUEST); exit; #$destfile = $_SERVER['PATH_TRANSLATED']; $destfile = "{$config['accessDir']}/{$token}"; /* PUT data comes in on the input stream */ $putdata = @fopen("php://input", "r") or http_error(500, "put.php: Can't read input"); /* Open a file for writing */ $fp = @fopen($destfile, "ab") or http_error(500, "put.php: Can't write to destination file (token=$token)"); /* Read the data 1 KB at a time and write to the file */ while ($data = fread($putdata, 1024)){ fwrite($fp, $data); } /* Close the streams */ fclose($fp); fclose($putdata); header("HTTP/1.1 200"); ?>