-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole_convert.php
More file actions
52 lines (40 loc) · 1.25 KB
/
Copy pathconsole_convert.php
File metadata and controls
52 lines (40 loc) · 1.25 KB
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
<?php
// if we are running in the webserver, bail out
if (isset($_SERVER["REMOTE_ADDR"])) {
echo "This script cannot be run from a browser.";
return;
}
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
define('phorum_page', 'convert_file_storage');
chdir(dirname(__FILE__) . "/../../webroot");
require_once './common.php';
require_once './include/api/file.php';
if (! ini_get('safe_mode')) {
set_time_limit(0);
ini_set("memory_limit","64M");
}
print "\nConverting database file storage to disk based storage ...\n";
$files = phorum_api_file_list();
$count_total = count($files);
$size = strlen($count_total);
$count = 0;
foreach ($files as $file) {
// Retrieving is is enough to get the file converted, because the
// module has an on-the-fly conversion mechanism implemented.
phorum_api_file_retrieve(
$file['file_id'],
PHORUM_FLAG_GET | PHORUM_FLAG_IGNORE_PERMS
);
$count ++;
$perc = floor(($count/$count_total)*100);
$barlen = floor(20*($perc/100));
$bar = "[";
$bar .= str_repeat("=", $barlen);
$bar .= str_repeat(" ", (20-$barlen));
$bar .= "]";
printf("converting %{$size}d / %{$size}d %s (%d%%)\r",
$count, $count_total, $bar, $perc);
}
print "\n\n";
?>