示例#1
0
$USER->mustHavePerm("admin");
$smarty = new GeographPage();
$db = NewADOConnection($GLOBALS['DSN']);
$from = isset($_POST['from']) ? $_POST['from'] : $CONF['photo_hashing_secret'];
$to = isset($_POST['to']) ? $_POST['to'] : $CONF['photo_hashing_secret'];
//do some processing?
if (isset($_POST['go'])) {
    //this takes a long time, so we output a header first of all
    $smarty->display('_std_begin.tpl');
    echo "<h3><a href=\"hashchanger.php\">&lt;&lt;</a> Changing image hashes...</h3>";
    flush();
    set_time_limit(3600 * 24);
    $recordSet =& $db->Execute("select * from gridimage");
    while (!$recordSet->EOF) {
        $image = new GridImage();
        $image->loadFromRecordset($recordSet);
        $CONF['photo_hashing_secret'] = $from;
        $oldfile = $image->_getFullpath();
        if ($oldfile != '/photos/error.jpg' && file_exists($_SERVER['DOCUMENT_ROOT'] . $oldfile)) {
            $CONF['photo_hashing_secret'] = $to;
            $image->storeImage($_SERVER['DOCUMENT_ROOT'] . $oldfile, true);
            $newfile = $image->_getFullpath();
            echo "<li>renamed {$oldfile}<br>to {$newfile}</li>";
            flush();
        } else {
            echo "<li>skipping {$oldfile} (not found)</li>";
        }
        $recordSet->MoveNext();
    }
    $recordSet->Close();
    $smarty->display('_std_end.tpl');