From: vincent@cubedesigners.com Date: Tue, 2 May 2023 14:34:45 +0000 (+0000) Subject: wip #5903 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=557a111cfbc52ae9b27c31ee0285320fdd6e658a;p=cubeextranet.git wip #5903 @0.5 --- diff --git a/inc/ws/Util/class.ws.links.php b/inc/ws/Util/class.ws.links.php index 89d90bf08..17bf87686 100644 --- a/inc/ws/Util/class.ws.links.php +++ b/inc/ws/Util/class.ws.links.php @@ -15,6 +15,9 @@ class wsLinks protected static $_testLinkCache = null; protected static $_linksKey = null; + protected static $_encryptedTypes = [14,15,35,39]; + protected static $_encryptedAttributes = ['image_rollover']; + public static function linksToExcel($links, $rulers, $pages = null) { set_time_limit(0); @@ -319,54 +322,51 @@ class wsLinks public static function encryptLinkAttrs($link) { - if (is_array($link)) { - $link = CubeIT_Util_Object::asObject($link); + if (!is_array($link)) { + $link = CubeIT_Util_Array::asArray($link); } - $crypted = [13, 14, 35]; - - if (!in_array($link->type, $crypted)) { - return CubeIT_Util_Array::asArray($link); + if (!in_array($link->type, self::$_encryptedTypes)) { + return $link; } - $attrs = ['image_rollover']; - foreach ($attrs as $attr) { + foreach (self::$_encryptedAttributes as $attr) { if (!isset($link->$attr)) { continue; } - $link->$attr = trim($link->$attr); - if (strpos($link->$attr, '///') === 0 || $link->$attr == '') { + $link->$attr = trim($link[$attr]); + if (strpos($link[$attr], '///') === 0 || $link[$attr] == '') { continue; } - $link->$attr = '///' . CubeIT_Crypt::safeEncrypt($link->uid . '|||' . $link->$attr, self::_getLinkKey()); + $link[$attr] = '///' . CubeIT_Crypt::safeEncrypt($link['uid'] . '|||' . $link[$attr], self::_getLinkKey()); } - return CubeIT_Util_Array::asArray($link); + return $link; } public static function decryptLink($link) { - $array = false; - if (is_array($link)) { - $array = true; - $link = CubeIT_Util_Object::asObject($link); + if (!is_array($link)) { + $link = CubeIT_Util_Array::asArray($link); + } + if (!in_array($link['type'], self::$_encryptedTypes)) { + return $link; } - foreach ($link as $attr => $item) { - if (strpos($item, '///') !== 0) { + foreach (self::$_encryptedAttributes as $attr) { + $value=$link[$attr]; + if (strpos($value, '///') !== 0) { continue; } - $v = CubeIT_Crypt::safeDecrypt(substr($item, 3), self::_getLinkKey()); + $v = CubeIT_Crypt::safeDecrypt(substr($value, 3), self::_getLinkKey()); $e = explode('|||', $v); - if ($e[0] === $link->uid) { - $link->$attr = $e[1]; + if ($e[0] === $link['uid']) { + $link[$attr] = $e[1]; } else { - $link->$attr = ''; + $link[$attr] = ''; } } - if (!$array) { - return $link; - } - return CubeIT_Util_Array::asArray($link); + + return $link; } public static function decryptLinks($links) @@ -394,7 +394,7 @@ class wsLinks public static function getLinksDir($book_id) { - $dir = wsBook::getDir($book_id,'links'); + $dir = wsBook::getDir($book_id, 'links'); if (!file_exists($dir)) { mkdir($dir, 0777, true); } diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 436a5fc79..d25fa138d 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -85,8 +85,6 @@ class wsHTML5Link $init = wsLinks::decryptLink($init); $init = CubeIT_Util_Array::asArray($init); - $wdir = wsBook::getDir($id, 'working'); - $init['scorm'] = self::isScorm($init); $init['to'] = self::replaceCustomURL($init['to']); @@ -115,8 +113,6 @@ class wsHTML5Link $init['video_controls'] = true; copy($file, $compiler->wdir . $fname); } - - } switch ($init['type']) {