| 33 |
$fname = $name.".txt"; |
$fname = $name.".txt"; |
| 34 |
} |
} |
| 35 |
|
|
| 36 |
if(!$cmd || $cmd=='get'){ |
if( $cmd=='get'){ |
| 37 |
$res = file_get_contents($dirname.$fname); |
$res = file_get_contents($dirname.$fname); |
| 38 |
echo $res; |
echo $res; |
| 39 |
}else if($cmd=='list'){ |
}else if($cmd=='list'){ |
| 46 |
}else{ |
}else{ |
| 47 |
echo "Fail to upload."; |
echo "Fail to upload."; |
| 48 |
} |
} |
| 49 |
|
}else if($cmd=='download'){ |
| 50 |
|
download_file($dirname.$fname, $fname, $filetype); |
| 51 |
|
exit(); |
| 52 |
}else { |
}else { |
| 53 |
echo "No such command: $cmd."; |
echo "No such command: $cmd.<br>"; |
| 54 |
|
echo "name: $name.<br>"; |
| 55 |
|
echo "filetype: $filetype.<br>"; |
| 56 |
|
print_r($_POST); |
| 57 |
} |
} |
| 58 |
|
|
|
|
|
| 59 |
function save_content($filename, $content){ |
function save_content($filename, $content){ |
| 60 |
$res = false; |
$res = false; |
| 61 |
$fp = fopen($filename, "w+"); |
$fp = fopen($filename, "w+"); |
| 81 |
return $filenames; |
return $filenames; |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
|
/////////////////////////////////////// |
| 85 |
|
// download file |
| 86 |
|
function download_file($file, $fname, $ftype){ |
| 87 |
|
if(!file_exists($file)) return 0; |
| 88 |
|
if(!($fp = fopen($file,"r"))) return 0; |
| 89 |
|
fclose($fp); |
| 90 |
|
|
| 91 |
|
if(($content_len = filesize($file)) == 0) return 0; |
| 92 |
|
|
| 93 |
|
|
| 94 |
|
header("Pragma: private"); |
| 95 |
|
header("Cache-control: private, must-revalidate"); |
| 96 |
|
|
| 97 |
|
$k_code="UTF-8"; |
| 98 |
|
|
| 99 |
|
if(chkBrowser() == "windows"){ |
| 100 |
|
$k_code="SJIS"; |
| 101 |
|
}else{ |
| 102 |
|
$k_code="UTF-8"; |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
if(chkBrowser() == "safari"){ |
| 106 |
|
header("Content-Disposition: attachment; filename=\"\""); |
| 107 |
|
}else if(chkBrowser() == "osx"){ |
| 108 |
|
header("Content-Disposition: attachment; filename=\"".mb_convert_encoding($fname,$k_code,"UTF-8,EUC-JP,SJIS")."\""); |
| 109 |
|
}else{ |
| 110 |
|
header("Content-Disposition: attachment; filename=\"".mb_convert_encoding($fname,$k_code,"SJIS,UTF-8,EUC-JP")."\""); |
| 111 |
|
} |
| 112 |
|
header("Content-Type: applicaion/octet-stream"); |
| 113 |
|
|
| 114 |
|
if($ftype == "svg"){ |
| 115 |
|
$content = file_get_contents($file); |
| 116 |
|
|
| 117 |
|
$contents =<<<_XML |
| 118 |
|
<?xml version="1.0" ?> |
| 119 |
|
<svg:svg width="100%" height="100%" |
| 120 |
|
xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 121 |
|
$content |
| 122 |
|
</svg:svg> |
| 123 |
|
_XML; |
| 124 |
|
|
| 125 |
|
$content_len = strlen($contents); |
| 126 |
|
header("Content-Length: ".$content_len); |
| 127 |
|
|
| 128 |
|
print $contents; |
| 129 |
|
|
| 130 |
|
}else if($ftype = "slide_html"){ |
| 131 |
|
|
| 132 |
|
header("Content-Length: ".$content_len); |
| 133 |
|
if(! readfile($file)) return 0; |
| 134 |
|
}else{ |
| 135 |
|
header("Content-Length: ".$content_len); |
| 136 |
|
if(! readfile($file)) return 0; |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
return 1; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
function chkBrowser(){ |
| 143 |
|
if (preg_match("/^DoCoMo/",$_SERVER['HTTP_USER_AGENT'])){ |
| 144 |
|
return "imode"; |
| 145 |
|
}else if(preg_match("/NetFront/",$_SERVER['HTTP_USER_AGENT'])){ |
| 146 |
|
return "netfront"; |
| 147 |
|
}else if(preg_match("/Windows/",$_SERVER['HTTP_USER_AGENT'])){ |
| 148 |
|
return "windows"; |
| 149 |
|
}else if(preg_match("/Mac OS X/",$_SERVER['HTTP_USER_AGENT'])){ |
| 150 |
|
return "osx"; |
| 151 |
|
}else if(preg_match("/Safari/",$_SERVER['HTTP_USER_AGENT'])){ |
| 152 |
|
return "safari"; |
| 153 |
|
}else return "unix"; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|
| 157 |
?> |
?> |