Exemplo n.º 1
0
$tmpl->setvar('SuperAdminLink9', getSuperAdminLink('?a=9', '<font class="adminlink">version</font></a>'));
// message section
$message = tfb_getRequestVar('m');
if ($message != "") {
    $tmpl->setvar('message', urldecode($message));
}
// check the needed bins
// python
if (@file_exists($cfg['pythonCmd']) !== true) {
    $tmpl->setvar('pythonMissing', 1);
}
// fluazu status
if (FluAzu::isRunning()) {
    $tmpl->setvar('fluazuRunning', 1);
    $tmpl->setvar('fluazuPid', FluAzu::getPid());
    $status = FluAzu::getStatus();
    $statusKeys = FluAzu::getStatusKeys();
    foreach ($statusKeys as $statusKey) {
        $tmpl->setvar($statusKey, $status[$statusKey]);
    }
} else {
    $tmpl->setvar('fluazuRunning', 0);
}
// settings
$tmpl->setvar('fluazu_host', $cfg['fluazu_host']);
$tmpl->setvar('fluazu_port', $cfg['fluazu_port']);
$tmpl->setvar('fluazu_secure', $cfg['fluazu_secure']);
$tmpl->setvar('fluazu_user', $cfg['fluazu_user']);
$tmpl->setvar('fluazu_pw', $cfg['fluazu_pw']);
// templ-calls
tmplSetTitleBar("Administration - fluazu Settings");
/**
 * updateAzureusSettings
 */
function admin_updateAzureusSettings()
{
    global $cfg;
    // FluAzu
    require_once "inc/classes/FluAzu.php";
    $message = "";
    // fluazu Running?
    if (FluAzu::isRunning()) {
        $status = FluAzu::getStatus();
        $statusKeys = FluAzu::getStatusKeys();
        // current settings
        $settingsCurrent = array();
        foreach ($statusKeys as $statusKey) {
            $settingsCurrent[$statusKey] = $status[$statusKey];
        }
        // new settings
        $settingsNew = array();
        foreach ($statusKeys as $statusKey) {
            $settingsNew[$statusKey] = tfb_getRequestVar($statusKey);
            if ($settingsNew[$statusKey] == "") {
                $settingsNew[$statusKey] = $settingsCurrent[$statusKey];
            }
        }
        // customize settings
        if ($cfg['transfer_customize_settings'] == 2) {
            $customize_settings = 1;
        } elseif ($cfg['transfer_customize_settings'] == 1 && $cfg['isAdmin']) {
            $customize_settings = 1;
        } else {
            $customize_settings = 0;
        }
        // get changes
        $settingsChanged = array();
        foreach ($statusKeys as $statusKey) {
            if ($settingsNew[$statusKey] != $settingsCurrent[$statusKey]) {
                if ($customize_settings == 1) {
                    array_push($settingsChanged, $statusKey);
                }
            }
        }
        if (empty($settingsChanged)) {
            /* no changes */
            $message = 'no changes.';
        } else {
            /* something changed */
            // set
            foreach ($settingsChanged as $statusKey) {
                FluAzu::setAzu($statusKey, $settingsNew[$statusKey], false);
            }
            // send
            FluAzu::sendCommands();
            // give fluazu some time
            sleep(2);
            $message = 'Settings changed.';
            // log
            AuditAction($cfg["constants"]["admin"], "Updating azureus Settings");
        }
    } else {
        $message = 'fluazu/azureus not running.';
    }
    if ($message != "") {
        @header("Location: admin.php?op=fluazuSettings&m=" . urlencode($message));
    } else {
        @header("Location: admin.php?op=fluazuSettings");
    }
    exit;
}