GetUploadProgress.php
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <?php 
  2. /*
  3.  * FCKeditor - The text editor for internet
  4.  * Copyright (C) 2003-2005 Frederico Caldeira Knabben
  5.  * 
  6.  * Licensed under the terms of the GNU Lesser General Public License:
  7.  *  http://www.opensource.org/licenses/lgpl-license.php
  8.  * 
  9.  * For further information visit:
  10.  *  http://www.fckeditor.net/
  11.  * 
  12.  * File Name: GetUploadProgress.php
  13.  *  Implements the GetFolders command, to list the folders 
  14.  *  in the current directory. Output is in XML
  15.  * 
  16.  * File Authors:
  17.  *  Grant French (grant@mcpuk.net)
  18.  */
  19. class GetUploadProgress {
  20. var $fckphp_config;
  21. var $type;
  22. var $cwd;
  23. var $actual_cwd;
  24. var $uploadID;
  25. function GetUploadProgress($fckphp_config,$type,$cwd) {
  26. $this->fckphp_config=$fckphp_config;
  27. $this->type=$type;
  28. $this->raw_cwd=$cwd;
  29. $this->actual_cwd=str_replace("//","/",($fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
  30. $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
  31. $this->uploadID=$_GET['uploadID'];
  32. $this->refreshURL=$_GET['refreshURL'];
  33. }
  34. function run() {
  35. if (isset($this->refreshURL)&&($this->refreshURL!="")) {
  36. //Continue monitoring
  37. $uploadProgress=file($this->refreshURL);
  38. $url=$this->refreshURL;
  39. } else {
  40. //New download
  41. $uploadProgressHandler=$this->fckphp_config['uploadProgressHandler'];
  42. if ($uploadProgressHandler=='') {
  43. //Progresshandler not specified, return generic response
  44. ?>
  45. <Connector command="GetUploadProgress" resourceType="<?php echo $this->type; ?>">
  46. <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  47. <Progress max="2" value="1" />
  48. <RefreshURL url="" />
  49. </Connector>
  50. <?php
  51. exit(0);
  52. }
  53. $url=$uploadProgressHandler."?iTotal=0&iRead=0&iStatus=1&sessionid=".$this->uploadID."&dtnow=".time()."&dtstart=".time();
  54. $_SESSION[$this->uploadID]=$url;
  55. $uploadProgress=file($url);
  56. }
  57. $uploadProgress2=implode("n",$uploadProgress);
  58. $parser = xml_parser_create();
  59. xml_parse_into_struct($parser, $uploadProgress2, $vals, $index);
  60. $refreshURL=isset($vals[$index['REFRESHURL'][0]]['value'])?$vals[$index['REFRESHURL'][0]]['value']:"";
  61. $totalBytes=isset($vals[$index['TOTALBYTES'][0]]['value'])?$vals[$index['TOTALBYTES'][0]]['value']:0;
  62. $readBytes=isset($vals[$index['READBYTES'][0]]['value'])?$vals[$index['READBYTES'][0]]['value']:0;
  63. $status=isset($vals[$index['STATUS'][0]]['value'])?$vals[$index['STATUS'][0]]['value']:1;
  64. header ("content-type: text/xml");
  65. echo "<?xml version="1.0" encoding="utf-8" ?>n";
  66. ?>
  67. <Connector command="GetUploadProgress" resourceType="<?php echo $this->type; ?>">
  68. <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  69. <Progress max="<?php echo $totalBytes; ?>" value="<?php echo $readBytes; ?>" />
  70. <RefreshURL url="<?php echo htmlentities($refreshURL); ?>" />
  71. </Connector>
  72. <?php
  73. xml_parser_free($parser);
  74. }
  75. }
  76. ?>