]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 28 Jan 2011 17:52:32 +0000 (17:52 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 28 Jan 2011 17:52:32 +0000 (17:52 +0000)
inc/config.inc.php
inc/ws/Controlleur/class.ws.secure.swf.php
inc/ws/Controlleur/class.ws.url.php

index 002432942ae11fd9c8efa20cece75779337a6bb2..1ca69c338fbdba470b0f94f21b1b989a5ce57578 100644 (file)
@@ -13,7 +13,7 @@ define('FONT_PATH', ROOT . '/fluidbook/fonts/');
 define('FTPROOT', '/home/extranet/ftp/');\r
 define('DEV', false);\r
 define('WINDOWS', false);\r
-define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/dev/fluidbook/tools:/usr/local/flex');\r
+define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/dev/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF');\r
 define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc');\r
 define('AS3_SOURCES', '/home/ws/sources/as3');\r
 \r
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e01891ff5078ccde30c60bb037e6986929e4384e 100644 (file)
@@ -0,0 +1,94 @@
+<?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
index 6805a0fcc404162ef376e777637f0384b5cf22c7..df597cdd46e906c6f8db7769f786c2112b4d6abd 100644 (file)
@@ -280,7 +280,7 @@ html{height:100%}' . "\n";
                $book_id = $e[0];\r
 \r
                self::checkDocumentVersionOfBook($book_id);\r
-               self::checkProtectedSWF();\r
+               wsSecureSWF::checkProtectedSWF();\r
 \r
                $book = $dao->selectById($book_id);\r
                if ($book->hash != $e[1]) {\r
@@ -372,7 +372,7 @@ html{height:100%}' . "\n";
                        $args[1] = 2964;\r
                }\r
                self::checkDocumentVersionOfBook($args[1]);\r
-               self::checkProtectedSWF();\r
+               wsSecureSWF::checkProtectedSWF();\r
                // cubePHP::neverStop();\r
                $dao = new wsDAOBook($core->con);\r
                header('Content-type: text/plain');\r