OSDN Git Service

add delete routine condaction_list
[swfed/swfed.git] / www / index.php
1 <?php
2
3 require_once('define.php');
4
5 function multiply_unit($str) {
6    $str = preg_replace('/(\d+)G/ei', "$1*1024*1024*1024", $str);
7    $str = preg_replace('/(\d+)M/ei', "$1*1024*1024", $str);
8    $str = preg_replace('/(\d+)K/ei', "$1*1024", $str);
9    $str = preg_replace('/(\d+)B/ei', "$1", $str);
10    return $str;
11 }
12 $upload_max_filesize  = ini_get('upload_max_filesize');
13 $upload_max_filesize_bytes = multiply_unit($upload_max_filesize);
14
15
16 if (! empty($_FILES['swffile']['tmp_name'])) {
17     $filename = $_FILES['swffile']['tmp_name'];
18     $swfdata = file_get_contents($filename);
19     $upload_max_filesize  = ini_get('upload_max_filesize');
20     if (strlen($swfdata) > $upload_max_filesize_bytes) {
21         echo "$upload_max_filesize Bytes 以内のファイルしか受け付けません。\n";
22         exit(0);
23     }
24     $tmp_name = sha1($swfdata, false);
25     $id = substr($tmp_name, 0, 16); // XXX
26     $tmp_filename = "$tmp_prefix$id.swf";
27     if ((! is_readable($tmp_filename)) &&
28         (! file_put_contents($tmp_filename, $swfdata))) {
29         fprintf(stderr, "index.php: file_put_contents failed. zero size?\n");
30         unlink($tmp_filename);
31         exit(0);
32     }
33     header("Location: ./index.php?id=$id");
34     exit(0);
35 }
36
37 ?>
38 <html>
39 <head>
40 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
41 </head>
42 <body bgcolor="#f0fff0">
43 <form enctype="multipart/form-data" action="" method="POST">
44     <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $upload_max_filesize_bytes ?>" />
45     SWF ファイルをアップロード: <input name="swffile" type="file" />
46     <input type="submit" value="ファイルを送信" />
47 </form>
48
49 <?php
50     
51 if (empty($_REQUEST['id']))  {
52      echo "ファイルを指定してください。($upload_max_filesize Bytes 以内に限定してます)";
53      exit(0);
54 }
55 $id = $_REQUEST['id'];
56 $tmp_filename = "$tmp_prefix$id.swf";
57 $swfdata = file_get_contents($tmp_filename);
58
59 echo "<a href=\"./swfimagelist.php?id=$id&noshape=y\" target=\"_blank\"> ビットマップ画像一覧 </a> - ";
60 echo "<a href=\"./swfimagelist.php?id=$id\" target=\"_blank\"> ベクター画像含む(重たいので注意) </a> <br />\n";
61
62 $swf = new SWFEditor();
63 $swf->input($swfdata);
64
65 $header_info = $swf->getHeaderInfo();
66
67 if ($header_info['compress']) {
68     $compress = 'true';
69 } else {
70     $compress = 'false';
71
72 }
73 echo "<table border=1>\n";
74 echo "<tr> <th> compress </th> </tr>\n";
75 echo "<tr> <td> $compress </td> </tr>\n";
76 echo "</table>\n";
77
78 echo "<table border=1>\n";
79 echo "<th> tag </th> <th> length </th> <th> detail </th>\n";
80 foreach ($swf->getTagList() as $tag_seqno => $tagblock) {
81     $tag= $tagblock['tag'];
82     if (empty($tagblock['tagName'])) {
83         $name = "Unknown";
84     } else {
85         $name = $tagblock['tagName'];
86     }
87     $length = $tagblock['length'];
88     $detail = @$tagblock['detail'];
89     echo "<tr>\n";
90     echo "<td> $name($tag) </td> ";
91     echo "<td> $length </td>\n";
92     if ($detail) {
93         $detail_info = $swf->getTagDetail($tag_seqno);
94         $detail_str = '';
95         if (is_array($detail_info)) {
96             foreach ($detail_info as $key => $value) {
97                 if (is_array($value)) {
98                     $value = implode(',', $value);
99                     }
100                     $detail_str .= "$key($value) ";
101             }
102         } else {
103             $detail_str .= var_export($detail_info, true);
104         }
105
106         if (@$header_info['version'] < 6) { // for flash lite
107             $detail_str = mb_convert_encoding($detail_str, "UTF-8", "SJIS-win");
108         }
109         $detail_str = htmlspecialchars($detail_str);
110         switch ($tag) {
111           case 6:  // 'DefineBitsJPEG'
112           case 21: // 'DefineBitsJPEG2'
113           case 35: // 'DefineBitsJPEG3'
114           case 20: // 'DefineBitsLossless'
115           case 36: // 'DefineBitsLossless2'
116             $image_id = $detail_info['image_id'];
117             $detail_str .= " <a href=\"swfimagereplace.php?id=$id&image_id=$image_id\"> replace </a>";
118             break;
119         }
120         echo "<td> $detail_str </td>";
121     } else {
122         echo "<td> - </td>";
123     }
124     echo "</tr>\n";
125 }
126 echo "</table>\n";
127
128 ?>
129 </body>
130 </html>