/web/htdocs/www.euroroma.net/home/zenphoto/zp-core/admin-refresh-metadata.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
/**
 * This template is used to reload metadata from images. Running it will process the entire gallery,
 * supplying an album name (ex: loadAlbums.php?album=newalbum) will only process the album named.
 * @package admin
 */
// force UTF-8 Ø

define('OFFSET_PATH'2); //     we don't want plugins loaded
require_once(dirname(__FILE__) . '/admin-globals.php');
require_once(
dirname(__FILE__) . '/template-functions.php');

// need the class plugins to handle video, etc.
foreach (getEnabledPlugins() as $extension => $plugin) {
    if (
$plugin['priority'] & CLASS_PLUGIN)
        require_once(
$plugin['path']);
}

if (isset(
$_REQUEST['album'])) {
    
$localrights ALBUM_RIGHTS;
} else {
    
$localrights NULL;
}
admin_securityChecks($localrights$return currentRelativeURL());

XSRFdefender('refresh');

$imageid '';
if (isset(
$_GET['refresh'])) {
    if (isset(
$_GET['id'])) {
        
$imageid sanitize_numeric($_GET['id']);
    }
    
$imageid $_zp_gallery->garbageCollect(truetrue$imageid);
}

if (isset(
$_GET['prune'])) {
    
$type 'prune&amp;';
    
$title gettext('Refresh Database');
    
$finished gettext('Finished refreshing the database');
    
$incomplete gettext('Database refresh is incomplete');
    
$allset gettext("We're all set to refresh the database");
    
$continue gettext('Continue refreshing the database.');
} else {
    
$type '';
    
$title gettext('Refresh Metadata');
    
$finished gettext('Finished refreshing the metadata');
    
$incomplete gettext('Metadata refresh is incomplete');
    
$allset gettext("We're all set to refresh the metadata");
    
$continue gettext('Continue refreshing the metadata.');
}

if (isset(
$_REQUEST['album'])) {
    
$tab 'edit';
} else {
    
$tab 'overview';
}
$albumparm $folder $albumwhere $imagewhere $id $r '';
if (isset(
$_REQUEST['return'])) {
    
$return $_REQUEST['return'];
    if (
$return == '*') {
        
$backurl 'admin-edit.php';
    } else {
        
$r '?page=edit&amp;album=' html_encode(pathurlencode($ret sanitize_path($return)));
        if (
strpos($return'*') === 0) {
            
$r .= '&amp;tab=subalbuminfo';
            
$star '*';
        } else {
            
$star '';
        }
        
$backurl 'admin-edit.php' $r '&amp;return=' $star html_encode(pathurlencode($ret));
    }
} else {
    
$ret '';
    
$backurl 'admin.php';
}

if (isset(
$_REQUEST['album'])) {
    if (isset(
$_POST['album'])) {
        
$folder sanitize_path(urldecode($_POST['album']));
    } else {
        
$folder sanitize_path($_GET['album']);
    }
    if (!empty(
$folder)) {
        
$album newAlbum($folder);
        if (!
$album->isMyItem(ALBUM_RIGHTS)) {
            if (!
zp_apply_filter('admin_managed_albums_access'false$return)) {
                
header('Location: ' FULLWEBPATH '/' ZENFOLDER '/admin.php');
                
exitZP();
            }
        }
    }
    
$albumparm '&amp;album=' pathurlencode($folder);
}
if (isset(
$_GET['refresh'])) {
    if (empty(
$imageid)) {
        
$metaURL $backurl;
    } else {
        if (!empty(
$ret))
            
$ret '&amp;return=' $ret;
        
$metaURL $redirecturl '?' $type 'refresh=continue&amp;id=' $imageid $albumparm $ret '&XSRFToken=' getXSRFToken('refresh');
    }
} else {
    if (
$type !== 'prune&amp;') {
        if (!empty(
$folder)) {
            
$album newAlbum($folder);
            if (!
$album->isMyItem(ALBUM_RIGHTS)) {
                if (!
zp_apply_filter('admin_managed_albums_access'false$return)) {
                    
header('Location: ' FULLWEBPATH '/' ZENFOLDER '/admin.php');
                    
exitZP();
                }
            }
            
$sql "SELECT `id` FROM " prefix('albums') . " WHERE `folder`=" db_quote($folder);
            
$row query_single_row($sql);
            
$id $row['id'];
        }

        if (!empty(
$id)) {
            
$imagewhere "WHERE `albumid`=$id";
            
$r $folder";
            
$albumwhere "WHERE `parentid`=$id";
        }
    }
    if (isset(
$_REQUEST['return']))
        
$ret sanitize($_REQUEST['return']);
    if (!empty(
$ret))
        
$ret '&amp;return=' $ret;
    
$metaURL $starturl '?' $type 'refresh=start' $albumparm '&amp;XSRFToken=' getXSRFToken('refresh') . $ret;
}

$zenphoto_tabs['overview']['subtabs'] = array(gettext('Refresh') => '');

printAdminHeader($tab'Refresh');
if (!empty(
$metaURL)) {
    
?>
    <meta http-equiv="refresh" content="1; url=<?php echo $metaURL?>" />
    <?php
}
echo 
"\n</head>";
echo 
"\n<body>";
printLogoAndLinks();
echo 
"\n" '<div id="main">';
printTabs();
?>
<div id="content">
    <?php printSubtabs(); ?>
    <div class="tabbox">
        <h1><?php echo $title?></h1>
        <?php
        
if (isset($_GET['refresh'])) {
            if (empty(
$imageid)) {
                
?>
                <h3><?php echo $finished?></h3>
                <p><?php echo gettext('you should return automatically. If not press: '); ?></p>
                <p><a href="<?php echo $backurl?>">&laquo; <?php echo gettext('Back'); ?></a></p>
                <?php
            
} else {
                
?>
                <h3><?php echo $incomplete?></h3>
                <p><?php echo gettext('This process should continue automatically. If not press: '); ?></p>
                <p><a href="<?php echo $redirecturl?>" title="<?php echo $continue?>" style="font-size: 15pt; font-weight: bold;">
                        <?php echo gettext("Continue!"); ?></a>
                </p>
                <?php
            
}
        } else {
            if (
$type !== 'prune&amp;') {
                if (!empty(
$id)) {
                    
$sql "UPDATE " prefix('albums') . " SET `mtime`=0" . ($_zp_gallery->getAlbumUseImagedate() ? ", `date`=NULL" '') . " WHERE `id`=$id";
                    
query($sql);
                }
                
$sql "UPDATE " prefix('albums') . " SET `mtime`=0 $albumwhere";
                
query($sql);
                
$sql "UPDATE " prefix('images') . " SET `mtime`=0 $imagewhere;";
                
query($sql);
            }
            if (!empty(
$folder) && empty($id)) {
                echo 
"<p> " sprintf(gettext("<em>%s</em> not found"), $folder) . "</p>";
            } else {
                if (empty(
$r)) {
                    echo 
"<p>" $allset "</p>";
                } else {
                    echo 
"<p>" sprintf(gettext("We're all set to refresh the metadata for <em>%s</em>"), $r) . "</p>";
                }
                echo 
'<p>' gettext('This process should start automatically. If not press: ') . '</p>';
                
?>
                <p><a href="<?php echo $starturl '&amp;XSRFToken=' getXSRFToken('refresh'); ?>"
                            title="<?php echo gettext("Refresh image metadata."); ?>" style="font-size: 15pt; font-weight: bold;">
                        <?php echo gettext("Go!"); ?></a>
                </p>
                <?php
            
}
        }

        echo 
"\n" '</div>';
        echo 
"\n" '</div>';
        echo 
"\n" '</div>';

        
printAdminFooter();

        echo 
"\n</body>";
        echo 
"\n</html>";
        
?>