function base64ToFile($_filename, $_content)
{
    administrationLog("base64ToFile", $_filename, CALLER_SYSTEM_ID);
    if (@file_exists($_filename)) {
        @unlink($_filename);
    }
    $handle = @fopen($_filename, "wb");
    @fputs($handle, base64_decode($_content));
    @fclose($handle);
}
function importButtons($_folder, $_prefix, $_connection)
{
    try {
        administrationLog("importButtons", serialize($_POST), CALLER_SYSTEM_ID);
        $buttons = getDirectory($_folder, ".php", true);
        foreach ($buttons as $button) {
            $parts = explode("_", $button);
            if (count($parts) == 3) {
                $type = $parts[0] == "overlay" ? $parts[0] : "inlay";
                $id = intval($parts[1]);
                $online = explode(".", $parts[2]);
                $online = $online[0];
                $parts = explode(".", $button);
                $itype = $parts[1];
                $_connection->Query(false, "INSERT INTO `" . DBManager::RealEscape($_prefix) . DATABASE_IMAGES . "` (`id`,`online`,`button_type`,`image_type`,`data`) VALUES ('" . DBManager::RealEscape($id) . "','" . DBManager::RealEscape($online) . "','" . DBManager::RealEscape($type) . "','" . DBManager::RealEscape($itype) . "','" . DBManager::RealEscape(fileToBase64($_folder . $button)) . "');");
            }
        }
    } catch (Exception $e) {
        logit(serialize($e));
    }
}