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);
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)
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);
}