forked from coppermine-gallery/cpg1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.php
135 lines (119 loc) · 4.01 KB
/
util.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
<?php
/**
* Coppermine Photo Gallery
*
* v1.0 originally written by Gregory Demar
*
* @copyright Copyright (c) 2003-2020 Coppermine Dev Team
* @license GNU General Public License version 3 or later; see LICENSE
*
* util.php
* @since 1.6.09
*/
/*
TODO:
update filesize in db when thumbs are updated
change use of string 'true' and 'false' to booleans for resize_image parameter
add checks for is_image() to functions that only apply to images
remove extract() from refresh_db()
*/
define('IN_COPPERMINE', true);
define('UTIL_PHP', true);
require 'include/init.inc.php';
require 'include/picmgmt.inc.php';
require 'include/tool.class.php';
if (!GALLERY_ADMIN_MODE) {
cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
$icon_array = array(
'back' => cpg_fetch_icon('leftleft', 2),
'util' => cpg_fetch_icon('util', 2)
);
js_include('js/util.js');
$bottomScript = '';
$css = '<style>
/* Styles for the admin tools. */
.toolwrap {
padding: 1em;
padding-left: 3em;
display: none;
}
#toolpdsp, #toolmsgs {
margin-bottom: 1em;
}
#toolpdsp img {
vertical-align: middle;
cursor: pointer;
}
#toolprgb {
width: 50%;
margin: 0 0 0 6px;
border: 1px solid #BBB;
display: inline-block;
border-radius: 3px;
background-image: url("images/indeterm.gif");
}
#toolprog {
width: 0;
padding: 2px 0;
white-space: nowrap;
background-color: #AAD7FD;
}
</style>';
pageheader($lang_util_php['title'], $css);
if ($superCage->post->keyExists('action') && $matches = $superCage->post->getMatched('action', '/^[A-Za-z0-9_]+$/')) {
$action = $matches[0];
} elseif ($superCage->get->keyExists('action') && $matches = $superCage->get->getMatched('action', '/^[A-Za-z0-9_]+$/')) {
$action = $matches[0];
} else {
$action = '';
}
if ($action && file_exists('tools/'.$action.'/'.$action.'.php')) {
$bt_style = '';
$tobj = AdminTool::getTool($action);
if ($tobj) {
if ($tobj->progressive) {
$stpbut = '<img src="images/icons/stop.png" title="Cancel" alt="" onclick="_toolAbort=true" />';
echo '<div id="toolpdsp">'.$stpbut.'<div id="toolprgb" class="progrbar"><div id="toolprog"><span> '.$tobj->procWords().'</span></div></div></div><div id="toolmsgs"></div>';
$jsn = json_encode($superCage->post->_source);
$bottomScript .= 'processTool('.$tobj->total().','.$jsn.');';
$bt_style = ' style="display:none"';
} else {
echo $tobj->action() . '<br> <br>';
}
}
echo '<div id="backtool"'.$bt_style.'><a href="util.php?t=' . date('His') . floor(rand(0, 1000)) . '#admin_tools" class="admin_menu">' . $icon_array['back'] . ' ' . $lang_util_php['back'] . '</a></div>';
} else {
$help = ' '.cpg_display_help('f=admin-tools.htm&as=admin_tools&ae=admin_tools_end&top=1', '600', '400');
print '<br><form name="cpgform" id="cpgform" action="util.php?t=' . date('His') . floor(rand(0, 1000)) . '#admin_tools" method="post">';
print '<a name="admin_tools"></a>';
starttable('100%', $icon_array['util'] . $lang_util_php['title'] . $help, 1);
$toolsdir = scandir('tools');
foreach ($toolsdir as $tool) {
if ($tool[0] != '.' && is_dir('tools/'.$tool)) {
$tobj = AdminTool::getTool($tool);
if ($tobj) {
echo '<tr><td class="tableb"><input type="radio" name="action" value="'.$tool.'" id="'.$tool.'" class="nobg" /><label for="'.$tool.'" class="clickable_option">'.$tobj->describe().'</label></td></tr>';
echo'<tr><td class="tableb"><div id="'.$tool.'_wrapper" class="toolwrap"></div></td></tr>';
}
}
}
endtable();
$help_select = ' ' . cpg_display_help('f=admin-tools.htm&as=admin_tools_usage&ae=admin_tools_usage_end&top=1', '600', '400');
starttable('100%', $lang_common['select_album'] . $help_select);
echo '<tr><td class="tablef">';
$cpg_udb->util_filloptions();
echo '</td></tr>';
endtable();
list($timestamp, $form_token) = getFormToken();
echo <<<EOT
<input type="hidden" name="form_token" value="{$form_token}" />
<input type="hidden" name="timestamp" value="{$timestamp}" />
</form>
EOT;
}
if ($bottomScript) {
echo '<script>'.$bottomScript.'</script>';
}
pagefooter();
//EOF