<?php require 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc < 4 || $argc % 2 == 0 || $argv[1] !== '-' && is_readable($argv[1]) === false) { fprintf(STDERR, "Usage: php swfreplaceactionstrings.php <swf_file> <from_str> <to_str> [<from_str2> <to_str2> [...]]\n"); fprintf(STDERR, "ex) php swfreplaceactionstrings.php test.swf foo baa\n"); exit(1); } if ($argv[1] === '-') { $swfdata = "php://stdin"; } else { $swfdata = file_get_contents($argv[1]); } $trans_table = array(); for ($i = 2; $i < $argc; $i += 2) { $trans_table[$argv[$i]] = $argv[$i + 1]; } $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $swf->replaceActionStrings($trans_table); echo $swf->build(); exit(0);
<?php require_once 'IO/SWF/Editor.php'; if ($argc != 3) { echo "Usage: php swfgetpng.php <swf_file> <bitmap_id>\n"; echo "ex) php swfgetpng.php colorformat.swf 2\n"; exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); $swfdata = file_get_contents($argv[1]); $bitmap_id = $argv[2]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $pngdata = $swf->getPNGData($bitmap_id); if ($pngdata === false) { echo "getPNGData({$bitmap_id}) failed\n"; exit(1); } echo $pngdata; exit(0);
<?php require_once 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc != 4) { echo "Usage: php swfreplaceeditstring.php <swf_file> <id> <initial_text>\n"; echo "ex) php swfreplaceeditstring.php test.swf 1 baa\n"; echo "ex) php swfreplaceeditstring.php test.swf foo baa\n"; exit(1); } assert(is_readable($argv[1])); $swfdata = file_get_contents($argv[1]); $id = $argv[2]; $initialText = $argv[3]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $ret = $swf->replaceEditString($id, $initialText); if ($ret === false) { echo "failed to replaceEditString({$id}, {$initialText})\n"; exit(1); } echo $swf->build(); exit(0);
<?php require 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc != 4) { fprintf(STDERR, "Usage: php swfsetactiovaribles.phpp <swf_file> <from_str> <to_str>\n"); fprintf(STDERR, "ex) php swfactionvariables.php test.swf foo baa\n"); exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); assert(isset($argv[3])); $swfdata = file_get_contents($argv[1]); $from_str = $argv[2]; $to_str = $argv[3]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $swf->setActionVariables($from_str, $to_str); echo $swf->build(); exit(0);
<?php require_once 'IO/SWF/Editor.php'; if ($argc != 3) { echo "Usage: php swfgeteditstring.php <swf_file> <id>\n"; echo "ex) php swfgeteditstring.php test.swf 1\n"; echo "ex) php swfgeteditstring.php test.swf foo\n"; exit(1); } assert(is_readable($argv[1])); $swfdata = file_get_contents($argv[1]); $id = $argv[2]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); echo $swf->getEditString($id) . "\n"; exit(0);
<?php require 'IO/SWF/Editor.php'; if ($argc != 2) { echo "Usage: php swflistaction.php <swf_file>\n"; echo "ex) php swflistaction.php test.swf\n"; exit(1); } assert(is_readable($argv[1])); $swfdata = file_get_contents($argv[1]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $currentFrame = 1; foreach ($swf->_tags as $idx => $tag) { $tag_code = $tag->code; if ($tag_code == 1) { // ShowFrame $currentFrame++; continue; } if ($tag_code == 12 || $tag_code == 59) { // DoAction, DoInitAction try { if ($tag->parseTagContent() === false) { echo "Unknown Action Tag\n"; exit(1); } $action_num = count($tag->tag->_actions); } catch (IO_Bit_Exception $e) { if (isset($tag_in_sprite->tag->_actions)) { $action_num = count($tag_in_sprite->tag->_actions);
<?php require_once 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc != 4) { echo "Usage: php swfreplacemovieclip.php <swf_file> <target_path> <mc_swf_file>\n"; echo "ex) php swfreplacemovieclip.php negimiku2_mcnest.swf miku/negi saitama3.swf\n"; exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); assert(is_readable($argv[3])); $swfdata = file_get_contents($argv[1]); $target_path = $argv[2]; $mc_swfdata = file_get_contents($argv[3]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $ret = $swf->replaceMovieClip($target_path, $mc_swfdata); if ($ret === false) { echo "replaceMovieClip({$target_path}, mc_swfdata) failed\n"; exit(1); } echo $swf->build(); exit(0);
<?php require 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc < 2) { echo "Usage: php swfcountshapeedges.php <swf_file> [<shape_id> <start> <end>]\n"; echo "ex) php swfcountshapeedges.php test.swf\n"; echo "ex) php swfcountshapeedges.php test.swf 1 0 32\n"; exit(1); } $swfdata = file_get_contents($argv[1]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); if ($argc < 3) { $count_table = $swf->countShapeRecords(); if ($count_table === false) { printf("countShapeEdges return false\n"); exit(1); } foreach ($count_table as $shape_id => $counts) { echo "shape_id: {$shape_id}:\n"; foreach ($counts as $idx => $records) { echo "\t[{$idx}]:"; foreach ($records as $name => $value) { if ($value > 0) { echo " {$name}:{$value}"; } } echo "\n"; } }
<?php require_once 'IO/SWF/Editor.php'; if ($argc != 3) { echo "Usage: php swfgetmovieclip.php <swf_file> <target_path>\n"; echo "ex) php swfgetmovieclip.php negimiku2_mcnest.swf miku/negi\n"; exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); $swfdata = file_get_contents($argv[1]); $target_path = $argv[2]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $ret = $swf->getMovieClip($target_path); if ($ret === false) { echo "getMovieClip({$target_path}) failed\n"; exit(1); } echo $ret; exit(0);
<?php require_once 'IO/SWF/Editor.php'; if ($argc != 3) { echo "Usage: php swfgetsound.php <swf_file> <sound_id>\n"; echo "ex) php swfgetsound.php sound.swf 2\n"; exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); $swfdata = file_get_contents($argv[1]); $sound_id = $argv[2]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $sounddata = $swf->getSoundData($sound_id); if ($sounddata === false) { echo "getSOUNDData({$sound_id}) failed\n"; exit(1); } echo $sounddata; exit(0);
<?php require 'IO/SWF/Editor.php'; if ($argc != 5) { echo "Usage: php swfsetbgcolor.php <swf_file> <red> <green> <blue>\n"; echo "ex) php swfsetbgcolor.php test.swf 0 0 255\n"; exit(1); } assert(is_readable($argv[1])); assert(is_numeric($argv[2])); assert(is_numeric($argv[3])); assert(is_numeric($argv[4])); $swfdata = file_get_contents($argv[1]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $color = pack('CCC', $argv[2], $argv[3], $argv[4]); $swf->replaceTagContent(9, $color); echo $swf->build(); exit(0);
<?php require 'IO/SWF/Editor.php'; $tagMap = IO_SWF_Tag::$tagMap; $options = getopt("f:p:m"); if (isset($options['f']) === false || is_readable($options['f']) === false || isset($options['p']) === false) { echo "Usage: php swfextract.php [-m] -f <swf_file> -p <outfile_prefix>\n"; echo "ex) php swfextract.php -m -f test.swf -p test-\n"; exit(1); } $mc_extract = isset($options['m']) ? true : false; $swffile = $options['f']; $outfile_prefix = $options['p']; $swfdata = file_get_contents($swffile); $swf = new IO_SWF_Editor(); try { $swf->parse($swfdata); } catch (Exception $e) { echo "ERROR: {$swffile} parse failed\n"; exit(1); } $jpegTables = false; foreach ($swf->_tags as $tag) { $code = $tag->code; $length = strlen($tag->content); $tagName = $tagMap[$code]['name']; $cid = false; $ext = false; $data2 = false; $data3 = false; switch ($code) {
<?php require 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF.php'; if ($argc != 2) { echo "Usage: php swflistmovieclip.php <swf_file>\n"; exit(1); } $swfdata = file_get_contents($argv[1]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $mc_list = $swf->listMovieClip(); if ($mc_list === false) { echo "mc_list === false\n"; exit(1); } foreach ($mc_list as $spriteId => $mc) { echo "SpriteId:{$spriteId} FrameCount:{$mc['FrameCount']} TagCount:{$mc['TagCount']}"; if (isset($mc['name'])) { echo ' name:' . $mc['name']; } echo PHP_EOL; if (isset($mc['path_list'])) { foreach ($mc['path_list'] as $path) { echo "\t" . $path['path']; if (count($path['parent_cids']) > 0) { echo ' (' . implode(',', $path['parent_cids']) . ')'; } echo PHP_EOL; } }
<?php require 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc != 3) { fprintf(STDERR, "Usage: php swfdeformeshape.php <swf_file> <threshold>\n"); fprintf(STDERR, "ex) php swfdeformeshape.php test.swf 10 \n"); exit(1); } assert(is_readable($argv[1])); assert(is_numeric($argv[2])); $swfdata = file_get_contents($argv[1]); $threshold = $argv[2]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $swf->deformeShape($threshold); echo $swf->build(); exit(0);
<?php require_once 'IO/SWF/Editor.php'; if ($argc != 3) { echo "Usage: php swfgetjpeg.php <swf_file> <bitmap_id>\n"; echo "ex) php swfgetjpeg.php colorformat.swf 2\n"; exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); $swfdata = file_get_contents($argv[1]); $bitmap_id = $argv[2]; $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $jpegdata = $swf->getJpegData($bitmap_id); if ($jpegdata === false) { echo "getJpegData({$bitmap_id}) failed\n"; exit(1); } echo $jpegdata; exit(0);
<?php require_once 'IO/SWF/Editor.php'; if ($argc < 3) { echo "Usage: php swfselectbycids.php <swf_file> <cid> [<cid2> [...]]\n"; echo "ex) php swfselectbycids.php negimiku2_mcnest.swf 1\n"; exit(1); } assert(is_readable($argv[1])); assert(isset($argv[2])); $swfdata = file_get_contents($argv[1]); $cids = array_slice($argv, 2); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $ret = $swf->selectByCIDs($cids); if ($ret === false) { echo "selectByCIDs(Array(" . join(',', $cids) . ")) failed\n"; exit(1); } echo $ret; exit(0);
<?php require_once 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc != 4 && $argc != 5) { echo "Usage: php swfreplacebitmapdata.php <swf_file> <bitmap_id> <bitmap_file> [<alpha_file>]\n"; echo "ex) php swfreplacebitmapdata.php test.swf 1 test.jpg test.alpha\n"; echo "ex) php swfreplacebitmapdata.php test.swf 1 test.png\n"; echo "ex) php swfreplacebitmapdata.php test.swf 1 test.git\n"; exit(1); } assert(is_readable($argv[1])); assert(is_numeric($argv[2])); assert(is_readable($argv[3])); $swfdata = file_get_contents($argv[1]); $bitmap_id = (int) $argv[2]; $bitmapdata = file_get_contents($argv[3]); if (isset($argv[4])) { // with jpeg alphadata assert(is_readable($argv[4])); $jpeg_alphadata = file_get_contents($argv[4]); } else { $jpeg_alphadata = null; } $swf = new IO_SWF_Editor(); $swf->parse($swfdata); // $swf->setShapeAdjustMode(IO_SWF_Editor::SHAPE_BITMAP_RECT_RESIZE); $ret = $swf->replaceBitmapData($bitmap_id, $bitmapdata, $jpeg_alphadata); echo $swf->build(); exit(0);
<?php require 'IO/SWF/Editor.php'; if ($argc != 2) { echo "Usage: php swfrebuild.php <swf_file>\n"; echo "ex) php swfrebuild.php test.swf\n"; exit(1); } assert(is_readable($argv[1])); $swfdata = file_get_contents($argv[1]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $swf->rebuild(); echo $swf->build(); exit(0);
<?php require 'IO/SWF/Editor.php'; // require dirname(__FILE__).'/../IO/SWF/Editor.php'; if ($argc != 2) { echo "Usage: php swfcountshapeedges.php <swf_file>\n"; echo "ex) php swfcountshapeedges.php test.swf\n"; exit(1); } $swfdata = file_get_contents($argv[1]); $swf = new IO_SWF_Editor(); $swf->parse($swfdata); $count_table = $swf->countShapeEdges(); if ($count_table === false) { printf("countShapeEdges return false\n"); exit(1); } foreach ($count_table as $shape_id => $count) { echo "shape_id: {$shape_id} => edges_count: {$count}\n"; } exit(0);