1: <?php
2:
3: define("CACHE_HASH_LENGTH", strlen(sha1(HASH_SEED)));
4:
5: function getImageProcessorURIFromCacheName($match, $watermarks) {
6: $args = array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
7: $set = array();
8: $done = false;
9: $params = explode('_', stripSuffix($match));
10: while (!$done && count($params) > 1) {
11: $check = array_pop($params);
12: if (is_numeric($check) && !isset($set['w']) && !isset($set['h'])) {
13: $set['s'] = $check;
14: break;
15: } else {
16: $c = substr($check, 0, 1);
17: if ($c == 'w' || $c == 'h') {
18: if (is_numeric($v = substr($check, 1))) {
19: $set[$c] = (int) $v;
20: continue;
21: }
22: }
23: if ($c == 'c') {
24: $c = substr($check, 0, 2);
25: if (is_numeric($v = substr($check, 2))) {
26: $set[$c] = (int) $v;
27: continue;
28: }
29: }
30: if (!isset($set['w']) && !isset($set['h']) && !isset($set['s'])) {
31: if (!isset($set['wm']) && in_array($check, $watermarks)) {
32: $set['wmk'] = $check;
33: } else if ($check == 'thumb') {
34: $set['t'] = true;
35: } else {
36: $set['effects'] = $check;
37: }
38: } else {
39: array_push($params, $check);
40: break;
41: }
42: }
43: }
44: if (!isset($set['wmk'])) {
45: $set['wmk'] = '!';
46: }
47: $image = preg_replace('~.*/' . CACHEFOLDER . '/~', '', implode('_', $params)) . '.' . getSuffix($match);
48:
49: $album = dirname($image);
50: $image = preg_replace('~^[0-9a-f]{' . CACHE_HASH_LENGTH . '}\.~', '', basename($image));
51: $image = $album . '/' . $image;
52: return array($image, getImageArgs($set));
53: }
54:
55: function getTitle($table, $row) {
56: switch ($table) {
57: case 'images':
58: $album = query_single_row('SELECT `folder` FROM ' . prefix('albums') . ' WHERE `id`=' . $row[albumid]);
59: $title = sprintf(gettext('%1$s: image %2$s'), $album['folder'], $row[$filename]);
60: break;
61: case 'albums':
62: $title = sprintf(gettext('album %s'), $row[$folder]);
63: break;
64: case 'news':
65: case 'pages':
66: $title = sprintf(gettext('%1$s: %2$s'), $table, $row['titlelink']);
67: break;
68: }
69: return $title;
70: }
71:
72: function recordMissing($table, $row, $image) {
73: global $missingImages;
74: $obj = getItemByID($table, $row['id']);
75: $missingImages[] = '<a href="' . $obj->getLink() . '">' . $obj->getTitle() . '</a> (' . html_encode($image) . ')<br />';
76: }
77:
78: 79: 80: 81: 82: 83: 84:
85: function updateCacheName($text, $target, $update) {
86: if (is_string($text) && preg_match('/^a:[0-9]+:{/', $text)) {
87: $text = getSerializedArray($text);
88: $serial = true;
89: } else {
90: $serial = false;
91: }
92: if (is_array($text)) {
93: foreach ($text as $key => $textelement) {
94: $text[$key] = updateCacheName($textelement, $target, $update);
95: }
96: if ($serial) {
97: $text = serialize($text);
98: }
99: } else {
100: $text = str_replace($target, $update, $text);
101: }
102: return $text;
103: }
104:
105: ?>