$__autoload['wsStats'] = dirname(__FILE__) . '/class.ws.stats.php';\r
$__autoload['wsServices'] = dirname(__FILE__) . '/class.ws.services.php';\r
$__autoload['wsUsersTree'] = dirname(__FILE__) . '/class.ws.users.tree.php';\r
-$__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php';\r
$__autoload['wsMaintenance'] = dirname(__FILE__) . '/class.ws.maintenance.php';\r
\r
?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsSecureSWF {\r
- public static $files = array('index.swf', 'player.swf');\r
- public static $configOriginal;\r
- public static $configLocal;\r
- public static $protected;\r
- public static $unprotected;\r
-\r
- public static function checkProtectedSWF()\r
- {\r
- self::$protected = WS_COMPILE_ASSETS . '/';\r
- self::$unprotected = WS_COMPILE_ASSETS . '/_unprotected/';\r
- self::$configOriginal = WS_COMPILE_ASSETS . '/_protect/fluidbook.sspj';\r
- self::$configLocal = WS_COMPILE_ASSETS . '/_protect/_fluidbook.sspj';\r
-\r
- $protect = false;\r
-\r
- self::checkConfigFile();\r
-\r
- $configmtime = filemtime(self::$configLocal);\r
-\r
- foreach(self::$files as $f) {\r
- $p = self::$protected . '/' . $f;\r
- $u = self::$unprotected . '/' . $f;\r
- $pfilemtime = filemtime($p);\r
- if (!file_exists($p) || $pfilemtime < filemtime($u) || $pfilemtime < $configmtime) {\r
- $protect = true;\r
- break;\r
- }\r
- }\r
-\r
- if (!$protect) {\r
- return;\r
- }\r
-\r
- self::protectFiles();\r
- }\r
-\r
- public static function checkConfigFile()\r
- {\r
- if (!file_exists(self::$configLocal) || filemtime(self::$configOriginal) > filemtime(self::$configLocal)) {\r
- self::updateConfigFile();\r
- }\r
- }\r
-\r
- protected static function updateConfigFile()\r
- {\r
- $x = simplexml_load_file(self::$configOriginal);\r
- // Remplace les chemins par les chemins des fichiers sur le serveur\r
- self::replacePathFiles($x, 'inputFiles', self::$unprotected);\r
- self::replacePathFiles($x, 'outputFiles', self::$protected);\r
-\r
- foreach($x->xpath("//void[@property='fileFullName']") as $f) {\r
- $fname = trim((string)$f->string);\r
- $fname = str_replace('\\', '/', $fname);\r
-\r
- $e = explode('/', $fname);\r
- $file = array_pop($e);\r
- $r = simplexml_load_string('<void property="fileFullName"><string>' . self::$unprotected . $file . '</string></void>');\r
- cubeXML::replace($f, $r);\r
- }\r
-\r
- file_put_contents(self::$configLocal, $x->asXML());\r
- }\r
-\r
- protected static function replacePathFiles($x, $property, $dir)\r
- {\r
- $o1 = $x->xpath("//void[@property='$property']");\r
- $o = array_pop($o1);\r
- $l = simplexml_load_string('<void property="' . $property . '" />');\r
- $a = $l->addChild('array');\r
- $a->addAttribute('class', 'java.lang.String');\r
- $a->addAttribute('length', count(self::$files));\r
- foreach(self::$files as $k => $f) {\r
- $v = $a->addChild('void');\r
- $v->addAttribute('index', $k);\r
- $s = $v->addChild('string', $dir . $f);\r
- }\r
- cubeXML::replace($o, $l);\r
- }\r
-\r
- protected static function protectFiles()\r
- {\r
- $secureSWF = new cubeCommandLine('secureSWF', null, true);\r
- $secureSWF->setPath(CONVERTER_PATH);\r
- $secureSWF->setManualArg(self::$configLocal);\r
- $secureSWF->setManualArg(self::$protected);\r
- $secureSWF->execute();\r
-\r
- file_put_contents(WS_COMPILE_ASSETS . '/_protect/secure.log', $secureSWF->commande . "\n\n\n" . $secureSWF->output);\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
if (!file_exists($out)) {\r
mkdir($out, 0777, true);\r
}\r
-\r
+ // Extract fonts from PDF\r
$gs = new cubeCommandLine('gs');\r
$gs->setPath(CONVERTER_PATH);\r
$gs->cd($out);\r
$ttf2eot->setPath(CONVERTER_PATH);\r
$ttf2eot->setManualArg('< ' . $this->out . '/fonts/web/' . $fname . '.ttf');\r
$ttf2eot->execute();\r
+ $this->addToLog($ttf2eot);\r
} else {\r
$fontforge = new cubeCommandLine('convert.pe');\r
$fontforge->setPath(CONVERTER_PATH);\r
$fontforge->setArg(null, $out . '/' . $file);\r
$fontforge->setArg(null, $this->out . '/fonts/web/' . $fname . '.' . $format);\r
$fontforge->execute();\r
+ $this->addToLog($fontforge);\r
}\r
}\r
-\r
- $this->addToLog($fontforge);\r
}\r
}\r
\r
// First, make swf with polytobitmap to rasterize bitmap & vectors\r
$this->pdf2swf($page, 150, 90, true, self::POLY2BITMAP, 'h');\r
$dump = $this->dumpSWF($page, 'h');\r
- // Analyse du dump\r
- $fonts = array();\r
+ $swf2html = new wsSWF2HTML($dump);\r
+ $swf2html->process();\r
\r
- $lines = explode("\n", $dump);\r
- foreach($lines as $line) {\r
- }\r
+ $this->addToLog(print_r($swf2html, true), true, $page);\r
}\r
\r
protected function checkObjectsNumber($file, $maxObjects, $page)\r
--- /dev/null
+<?php\r
+\r
+$__autoload['wsSWF2HTML'] = dirname(__FILE__) . '/class.ws.swf2html.php';\r
+$__autoload['wsSWF2HTMLTag'] = dirname(__FILE__) . '/class.ws.swf2html.php';\r
+$__autoload['wsSWF2HTMLText'] = dirname(__FILE__) . '/class.ws.swf2html.php';\r
+$__autoload['wsSWF2HTMLFont'] = dirname(__FILE__) . '/class.ws.swf2html.php';\r
+$__autoload['wsSWF2HTMLParagraph'] = dirname(__FILE__) . '/class.ws.swf2html.php';\r
+$__autoload['wsSWF2HTMLMatrix'] = dirname(__FILE__) . '/class.ws.swf2html.php';\r
+$__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php';\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsSecureSWF {\r
+ public static $files = array('index.swf', 'player.swf');\r
+ public static $configOriginal;\r
+ public static $configLocal;\r
+ public static $protected;\r
+ public static $unprotected;\r
+\r
+ public static function checkProtectedSWF()\r
+ {\r
+ self::$protected = WS_COMPILE_ASSETS . '/';\r
+ self::$unprotected = WS_COMPILE_ASSETS . '/_unprotected/';\r
+ self::$configOriginal = WS_COMPILE_ASSETS . '/_protect/fluidbook.sspj';\r
+ self::$configLocal = WS_COMPILE_ASSETS . '/_protect/_fluidbook.sspj';\r
+\r
+ $protect = false;\r
+\r
+ self::checkConfigFile();\r
+\r
+ $configmtime = filemtime(self::$configLocal);\r
+\r
+ foreach(self::$files as $f) {\r
+ $p = self::$protected . '/' . $f;\r
+ $u = self::$unprotected . '/' . $f;\r
+ $pfilemtime = filemtime($p);\r
+ if (!file_exists($p) || $pfilemtime < filemtime($u) || $pfilemtime < $configmtime) {\r
+ $protect = true;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (!$protect) {\r
+ return;\r
+ }\r
+\r
+ self::protectFiles();\r
+ }\r
+\r
+ public static function checkConfigFile()\r
+ {\r
+ if (!file_exists(self::$configLocal) || filemtime(self::$configOriginal) > filemtime(self::$configLocal)) {\r
+ self::updateConfigFile();\r
+ }\r
+ }\r
+\r
+ protected static function updateConfigFile()\r
+ {\r
+ $x = simplexml_load_file(self::$configOriginal);\r
+ // Remplace les chemins par les chemins des fichiers sur le serveur\r
+ self::replacePathFiles($x, 'inputFiles', self::$unprotected);\r
+ self::replacePathFiles($x, 'outputFiles', self::$protected);\r
+\r
+ foreach($x->xpath("//void[@property='fileFullName']") as $f) {\r
+ $fname = trim((string)$f->string);\r
+ $fname = str_replace('\\', '/', $fname);\r
+\r
+ $e = explode('/', $fname);\r
+ $file = array_pop($e);\r
+ $r = simplexml_load_string('<void property="fileFullName"><string>' . self::$unprotected . $file . '</string></void>');\r
+ cubeXML::replace($f, $r);\r
+ }\r
+\r
+ file_put_contents(self::$configLocal, $x->asXML());\r
+ }\r
+\r
+ protected static function replacePathFiles($x, $property, $dir)\r
+ {\r
+ $o1 = $x->xpath("//void[@property='$property']");\r
+ $o = array_pop($o1);\r
+ $l = simplexml_load_string('<void property="' . $property . '" />');\r
+ $a = $l->addChild('array');\r
+ $a->addAttribute('class', 'java.lang.String');\r
+ $a->addAttribute('length', count(self::$files));\r
+ foreach(self::$files as $k => $f) {\r
+ $v = $a->addChild('void');\r
+ $v->addAttribute('index', $k);\r
+ $s = $v->addChild('string', $dir . $f);\r
+ }\r
+ cubeXML::replace($o, $l);\r
+ }\r
+\r
+ protected static function protectFiles()\r
+ {\r
+ $secureSWF = new cubeCommandLine('secureSWF', null, true);\r
+ $secureSWF->setPath(CONVERTER_PATH);\r
+ $secureSWF->setManualArg(self::$configLocal);\r
+ $secureSWF->setManualArg(self::$protected);\r
+ $secureSWF->execute();\r
+\r
+ file_put_contents(WS_COMPILE_ASSETS . '/_protect/secure.log', $secureSWF->commande . "\n\n\n" . $secureSWF->output);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsSWF2HTML {\r
+ const FONT_TAG = '04b';\r
+ const TEXT_TAG = '021';\r
+\r
+ public $lines;\r
+ public $tags = array();\r
+\r
+ protected $currentTag;\r
+\r
+ protected $processed = false;\r
+\r
+ public function __construct($dump)\r
+ {\r
+ $this->lines = explode("\n", $dump);\r
+ $this->lastIndex = count($this->lines)-1;\r
+ }\r
+\r
+ public function process()\r
+ {\r
+ if ($this->processed) {\r
+ return;\r
+ }\r
+\r
+ foreach($lines as $line) {\r
+ if (preg_match('|^\[([0-9A-Z]{3})\]\s+(.*)$|i', $line, $matches)) {\r
+ $currentTag = $this->addTag($matches[1], $matches[2]);\r
+ } else {\r
+ $currentTag->addLine($line);\r
+ }\r
+ }\r
+ }\r
+\r
+ protected function addTag($tag, $line)\r
+ {\r
+ $tag = wsSWF2HTMLTag::factory($tag, $line);\r
+ $this->tags[] = $tag;\r
+ return $tag;\r
+ }\r
+\r
+ public function getHTML()\r
+ {\r
+ $this->process();\r
+ }\r
+\r
+ public function getCSS()\r
+ {\r
+ $this->process();\r
+ }\r
+}\r
+\r
+class wsSWF2HTMLTag {\r
+ public static function factory($tag, $line)\r
+ {\r
+ if ($tag == wsSWF2HTML::FONT_TAG) {\r
+ return new wsSWF2HTMLFont($line);\r
+ } else if ($tag == wsSWF2HTML::TEXT_TAG) {\r
+ return new wsSWF2HTMLParagraph($line);\r
+ } else {\r
+ return new wsSWF2HTMLTag($line);\r
+ }\r
+ }\r
+ public $complete = false;\r
+\r
+ public function __construct($line)\r
+ {\r
+ $this->addLine($line);\r
+ }\r
+\r
+ public function addLine($line)\r
+ {\r
+ $line = trim($line);\r
+ return $line;\r
+ }\r
+}\r
+\r
+class wsSWF2HTMLFont extends wsSWF2HTMLTag {\r
+ public $id = null;\r
+ public $name = null;\r
+\r
+ public function __construct($line)\r
+ {\r
+ parent::__construct($line);\r
+ }\r
+\r
+ public function addLine($line)\r
+ {\r
+ $line = parent::addLine($line);\r
+ $e = explode(':', $line);\r
+ if (count($e) < 2) {\r
+ return;\r
+ }\r
+ if ($e[0] == 'ID') {\r
+ $this->id = trim($e[1]);\r
+ $this->testComplete();\r
+ } elseif ($e[0] == 'name') {\r
+ $ef = explode('-', trim($e[1]));\r
+ array_pop($ef);\r
+ array_pop($ef);\r
+ $this->name = implode('-', $ef);\r
+ $this->testComplete();\r
+ }\r
+ }\r
+\r
+ protected function testComplete()\r
+ {\r
+ $this->complete = !is_null($this->id) && !is_null($this->name);\r
+ }\r
+}\r
+\r
+class wsSWF2HTMLParagraph extends wsSWF2HTMLTag {\r
+ public $matrix;\r
+ public $textes = array();\r
+\r
+ public function __construct($line)\r
+ {\r
+ $this->matrix = new wsSWF2HTMLMatrix();\r
+ parent::__construct($line);\r
+ }\r
+\r
+ public function addLine($line)\r
+ {\r
+ $line = parent::addLine($line);\r
+ if (substr($line, 0, 1) == '|') {\r
+ if (preg_match('|^\|\s([0-9.]*)\s([0-9.]*)\s([0-9.]*)$|i', $line, $m)) {\r
+ if (is_null($this->matrix->a)) {\r
+ $this->matrix->a = parseFloat($m[1]);\r
+ $this->matrix->c = parseFloat($m[2]);\r
+ $this->matrix->tx = parseFloat($m[3]);\r
+ } else {\r
+ $this->matrix->b = parseFloat($m[1]);\r
+ $this->matrix->d = parseFloat($m[2]);\r
+ $this->matrix->ty = parseFloat($m[3]);\r
+ }\r
+ }\r
+ } else if (substr($line, 0, 1) == '<') {\r
+ $text = new wsSWF2HTMLText($line);\r
+ if ($text->valid) {\r
+ $this->textes[] = $text;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+class wsSWF2HTMLText {\r
+ public $x;\r
+ public $y;\r
+ public $color;\r
+ public $font;\r
+ public $size;\r
+ public $text;\r
+\r
+ public $valid = false;\r
+ public function __construct($line)\r
+ {\r
+ if (preg_match('|^\<\d+ glyphs in font (\d+) size (\d+), color (#[0-9a-f]+) at ([0-9.]+),([0-9.]+)\>\s(.*)|i', $line, $matches)) {\r
+ $this->font = intval($matches[1]);\r
+ $this->size = intval($matches[2]);\r
+ $this->color = $matches[3];\r
+ $this->x = floatval($matches[4]);\r
+ $this->y = floatval($matches[5]);\r
+ $this->text = $matches[6];\r
+ $this->valid = true;\r
+ } else {\r
+ $this->valid = false;\r
+ }\r
+ }\r
+}\r
+\r
+class wsSWF2HTMLMatrix {\r
+ public $a = null;\r
+ public $b = null;\r
+ public $c = null;\r
+ public $d = null;\r
+ public $tx = null;\r
+ public $ty = null;\r
+}\r
+\r
+?>
\ No newline at end of file
require_once(dirname(__FILE__) . '/Metier/_common.php');\r
require_once(dirname(__FILE__) . '/Controlleur/_common.php');\r
require_once(dirname(__FILE__) . '/DAO/_common.php');\r
+require_once(dirname(__FILE__) . '/Util/_common.php');\r
\r
$GLOBALS['ajaxClasses'][] = 'wsAjax';\r
\r