phpAds_SettingsWriteAdd('type_html_auto', isset($type_html_auto));
    phpAds_SettingsWriteAdd('type_html_php', isset($type_html_php));
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-admin.php");
            exit;
        }
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2"));
phpAds_SettingsSelection("banner");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
// Split FTP settings
if (!empty($phpAds_config['type_web_ftp'])) {
    if ($ftpserver = @parse_url($phpAds_config['type_web_ftp'])) {
        // Decode URL parts
        $ftpserver['user'] = urldecode($ftpserver['user']);
        $ftpserver['pass'] = urldecode($ftpserver['pass']);
        $ftpserver['path'] = urldecode($ftpserver['path']);
        $ftpserver['path'] = preg_replace('#^/#', '', $ftpserver['path']);
        $ftpserver['path'] = preg_replace('#/$#', '', $ftpserver['path']);
        $phpAds_config['type_web_ftp_host'] = $ftpserver['host'] . (isset($ftpserver['port']) && $ftpserver['port'] != '' ? ':' . $ftpserver['port'] : '');
        $phpAds_config['type_web_ftp_user'] = $ftpserver['user'];
        $phpAds_config['type_web_ftp_password'] = $ftpserver['pass'];
            phpAds_SettingsWriteAdd('auto_clean_userlog_interval', $auto_clean_userlog_interval);
        }
    }
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-banner.php");
            exit;
        }
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2"));
phpAds_SettingsSelection("stats");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
// Change ignore_hosts into a string, so the function handles it good
$phpAds_config['ignore_hosts'] = join("\n", $phpAds_config['ignore_hosts']);
$settings = array(array('text' => $strStatisticsFormat, 'items' => array(array('type' => 'select', 'name' => 'compact_stats', 'text' => $strCompactStats, 'items' => array($strVerbose, $strCompact)), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'log_adviews', 'text' => $strLogAdviews), array('type' => 'checkbox', 'name' => 'log_adclicks', 'text' => $strLogAdclicks), array('type' => 'break', 'size' => 'large'), array('type' => 'checkbox', 'name' => 'log_source', 'text' => $strLogSource, 'depends' => 'log_adclicks==true || log_adviews==true'), array('type' => 'checkbox', 'name' => 'geotracking_stats', 'text' => $strGeoLogStats, 'visible' => $phpAds_config['geotracking_type'] != '', 'depends' => '(log_adclicks==true || log_adviews==true) && compact_stats==0'), array('type' => 'checkbox', 'name' => 'log_hostname', 'text' => $strLogHostnameOrIP, 'visible' => isset($_SERVER['REMOTE_HOST']) || $phpAds_config['reverse_lookup'], 'depends' => '(log_adclicks==true || log_adviews==true) && compact_stats==0'), array('type' => 'checkbox', 'name' => 'log_iponly', 'text' => $strLogIPOnly, 'indent' => true, 'visible' => isset($_SERVER['REMOTE_HOST']) || $phpAds_config['reverse_lookup'], 'depends' => '(log_adclicks==true || log_adviews==true) && compact_stats==0 && log_hostname==true'), array('type' => 'checkbox', 'name' => 'log_hostname', 'text' => $strLogIP, 'visible' => !isset($_SERVER['REMOTE_HOST']) && !$phpAds_config['reverse_lookup'], 'depends' => '(log_adclicks==true || log_adviews==true) && compact_stats==0'), array('type' => 'break', 'size' => 'large'), array('type' => 'checkbox', 'name' => 'log_beacon', 'text' => $strLogBeacon))), array('text' => $strPreventLogging, 'items' => array(array('type' => 'textarea', 'name' => 'ignore_hosts', 'text' => $strIgnoreHosts), array('type' => 'break'), array('type' => 'text', 'name' => 'block_adviews', 'text' => $strBlockAdviews, 'size' => 12, 'depends' => 'log_adviews==true', 'check' => 'number+'), array('type' => 'break'), array('type' => 'text', 'name' => 'block_adclicks', 'text' => $strBlockAdclicks, 'size' => 12, 'depends' => 'log_adclicks==true', 'check' => 'number+'))), array('text' => $strEmailWarnings, 'items' => array(array('type' => 'checkbox', 'name' => 'warn_admin', 'text' => $strWarnAdmin), array('type' => 'checkbox', 'name' => 'warn_client', 'text' => $strWarnClient), array('type' => 'break'), array('type' => 'text', 'name' => 'warn_limit', 'text' => $strWarnLimit, 'size' => 12, 'depends' => 'warn_client==true || warn_admin==true', 'check' => 'number+20', 'req' => true), array('type' => 'break'), array('type' => 'text', 'name' => 'warn_limit_days', 'text' => $strWarnLimitDays, 'size' => 12, 'depends' => 'warn_client==true || warn_admin==true', 'check' => 'number+', 'req' => true), array('type' => 'break'), array('type' => 'textarea', 'name' => 'admin_email_headers', 'text' => $strAdminEmailHeaders), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'qmail_patch', 'text' => $strQmailPatch))), array('text' => $strAutoCleanTables, 'items' => array(array('type' => 'checkbox', 'name' => 'auto_clean_tables', 'text' => $strAutoCleanStats), array('type' => 'break'), array('type' => 'text', 'name' => 'auto_clean_tables_interval', 'text' => $strAutoCleanStatsWeeks, 'size' => 25, 'depends' => 'auto_clean_tables==true', 'check' => 'number+3', 'req' => true), array('type' => 'break', 'size' => 'large'), array('type' => 'checkbox', 'name' => 'auto_clean_userlog', 'text' => $strAutoCleanUserlog), array('type' => 'break'), array('type' => 'text', 'name' => 'auto_clean_userlog_interval', 'text' => $strAutoCleanUserlogWeeks, 'size' => 25, 'depends' => 'auto_clean_userlog==true', 'check' => 'number+3', 'req' => true))));
/*********************************************************/
/* Main code                                             */
/*********************************************************/
phpAds_ShowSettings($settings, $errormessage);
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PageFooter();
        phpAds_SettingsWriteFlush();
        header("Location: settings-host.php");
        exit;
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
if (phpAds_isUser(phpAds_Admin)) {
    phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2", "5.5"));
} elseif (phpAds_isUser(phpAds_Agency)) {
    phpAds_ShowSections(array("5.1"));
}
phpAds_SettingsSelection("invocation");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
// Determine delivery cache methods
$delivery_cache_methods['none'] = $strNone;
$delivery_cache_methods['db'] = $strCacheDatabase;
if ($fp = @fopen(phpAds_path . '/cache/available', 'wb')) {
    @fclose($fp);
    @unlink(phpAds_path . '/cache/available');
    $delivery_cache_methods['file'] = $strCacheFiles;
}
if (function_exists('shmop_open')) {
    $delivery_cache_methods['shm'] = $strCacheShmop . " (" . $strExperimental . ")";
}
if (function_exists('shm_attach')) {
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
if (isset($message)) {
    phpAds_ShowMessage($message);
}
phpAds_PageHeader("5.1");
if (phpAds_isUser(phpAds_Admin)) {
    phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2", "5.5"));
} elseif (phpAds_isUser(phpAds_Agency)) {
    phpAds_ShowSections(array("5.1"));
}
phpAds_SettingsSelection("admin");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
$unique_users = array();
$res = phpAds_dbQuery("SELECT LOWER(clientusername) as used" . " FROM " . $phpAds_config['tbl_clients'] . " WHERE clientusername != ''");
while ($row = phpAds_dbFetchArray($res)) {
    $unique_users[] = $row['used'];
}
$res = phpAds_dbQuery("SELECT LOWER(username) as used FROM " . $phpAds_config['tbl_affiliates'] . " WHERE username != ''");
while ($row = phpAds_dbFetchArray($res)) {
    $unique_users[] = $row['used'];
}
$settings = array(array('text' => $strLoginCredentials, 'items' => array(array('type' => 'text', 'name' => 'admin', 'text' => $strAdminUsername, 'check' => 'unique', 'unique' => $unique_users), array('type' => 'break'), array('type' => 'password', 'name' => 'pwold', 'text' => $strOldPassword), array('type' => 'break'), array('type' => 'password', 'name' => 'pw', 'text' => $strNewPassword, 'depends' => 'pwold!=""'), array('type' => 'break'), array('type' => 'password', 'name' => 'pw2', 'text' => $strRepeatPassword, 'depends' => 'pwold!=""', 'check' => 'compare:pw'))), array('text' => $strBasicInformation, 'items' => array(array('type' => 'text', 'name' => 'admin_fullname', 'text' => $strAdminFullName, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'admin_email', 'text' => $strAdminEmail, 'size' => 35, 'check' => 'email'), array('type' => 'break'), array('type' => 'text', 'name' => 'company_name', 'text' => $strCompanyName, 'size' => 35))), array('text' => $strPreferences, 'items' => array(array('type' => 'select', 'name' => 'language', 'text' => $strLanguage, 'items' => phpAds_AvailableLanguages()), array('type' => 'break'), array('type' => 'select', 'name' => 'updates_frequency', 'text' => $strAdminCheckUpdates, 'items' => array('0' => $strAdminCheckEveryLogin, '1' => $strAdminCheckDaily, '7' => $strAdminCheckWeekly, '30' => $strAdminCheckMonthly, '-1' => $strAdminCheckNever)), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'admin_novice', 'text' => $strAdminNovice), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'userlog_email', 'text' => $strUserlogEmail), array('type' => 'checkbox', 'name' => 'userlog_priority', 'text' => $strUserlogPriority), array('type' => 'checkbox', 'name' => 'userlog_autoclean', 'text' => $strUserlogAutoClean))));
/*********************************************************/
/* Main code                                             */
        }
    }
    phpAds_SettingsWriteAdd('insert_delayed', isset($insert_delayed));
    phpAds_SettingsWriteAdd('compatibility_mode', isset($compatibility_mode));
    phpAds_SettingsWriteAdd('mysql4_compatibility', isset($mysql4_compatibility));
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-invocation.php");
            exit;
        }
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2"));
phpAds_SettingsSelection("db");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
$settings = array(array('text' => $strDatabaseServer, 'items' => array(array('type' => 'checkbox', 'name' => 'dblocal', 'text' => $strDbLocal, 'req' => true), array('type' => 'break'), array('type' => 'text', 'name' => 'dbhost', 'text' => $strDbHost, 'req' => true), array('type' => 'break'), array('type' => 'text', 'name' => 'dbport', 'text' => $strDbPort, 'req' => false, 'depends' => 'dblocal==false'), array('type' => 'break'), array('type' => 'text', 'name' => 'dbuser', 'text' => $strDbUser, 'req' => true), array('type' => 'break'), array('type' => 'password', 'name' => 'dbpassword', 'text' => $strDbPassword), array('type' => 'break'), array('type' => 'text', 'name' => 'dbname', 'text' => $strDbName, 'req' => true))), array('text' => $strDatabaseOptimalisations, 'items' => array(array('type' => 'checkbox', 'name' => 'persistent_connections', 'text' => $strPersistentConnections), array('type' => 'checkbox', 'name' => 'insert_delayed', 'text' => $strInsertDelayed, 'visible' => $phpAds_dbmsname == 'MySQL' && $phpAds_config['table_type'] == 'MYISAM'), array('type' => 'checkbox', 'name' => 'compatibility_mode', 'text' => $strCompatibilityMode, 'visible' => $phpAds_dbmsname == 'MySQL'), array('type' => 'checkbox', 'name' => 'mysql4_compatibility', 'text' => $strMysql4Compatibility, 'visible' => $phpAds_dbmsname == 'MySQL' && phpAds_dbQuery("SET SESSION sql_mode='MYSQL40'")), array('type' => 'checkbox', 'name' => 'auto_clean_tables_vacuum', 'text' => $strAutoCleanVacuum, 'visible' => $phpAds_dbmsname == 'PostgreSQL'))));
/*********************************************************/
/* Main code                                             */
/*********************************************************/
phpAds_ShowSettings($settings, $errormessage);
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PageFooter();
        phpAds_SettingsWriteAdd('default_campaign_weight', $default_campaign_weight);
    }
    if (!count($errormessage)) {
        phpAds_SettingsWriteFlush();
        header("Location: settings-defaults.php");
        exit;
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
if (phpAds_isUser(phpAds_Admin)) {
    phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2", "5.5"));
} elseif (phpAds_isUser(phpAds_Agency)) {
    phpAds_ShowSections(array("5.1"));
}
phpAds_SettingsSelection("defaults");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
$settings = array(array('text' => $strInventory, 'items' => array(array('type' => 'checkbox', 'name' => 'gui_show_campaign_info', 'text' => $strShowCampaignInfo), array('type' => 'checkbox', 'name' => 'gui_show_banner_info', 'text' => $strShowBannerInfo), array('type' => 'checkbox', 'name' => 'gui_show_campaign_preview', 'text' => $strShowCampaignPreview), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'gui_show_banner_html', 'text' => $strShowBannerHTML), array('type' => 'checkbox', 'name' => 'gui_show_banner_preview', 'text' => $strShowBannerPreview), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'gui_hide_inactive', 'text' => $strHideInactive), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'gui_show_matching', 'text' => $strGUIShowMatchingBanners), array('type' => 'checkbox', 'name' => 'gui_show_parents', 'text' => $strGUIShowParentCampaigns), array('type' => 'break'), array('type' => 'text', 'name' => 'gui_link_compact_limit', 'text' => $strGUILinkCompactLimit, 'size' => 12, 'check' => 'number+'))), array('text' => $strStatisticsDefaults, 'items' => array(array('type' => 'select', 'name' => 'begin_of_week', 'text' => $strBeginOfWeek, 'items' => array($strDayFullNames[0], $strDayFullNames[1])), array('type' => 'break'), array('type' => 'select', 'name' => 'percentage_decimals', 'text' => $strPercentageDecimals, 'items' => array(0, 1, 2, 3)))), array('text' => $strWeightDefaults, 'items' => array(array('type' => 'text', 'name' => 'default_banner_weight', 'text' => $strDefaultBannerWeight, 'size' => 12, 'check' => 'number+'), array('type' => 'break'), array('type' => 'text', 'name' => 'default_campaign_weight', 'text' => $strDefaultCampaignWeight, 'size' => 12, 'check' => 'number+'))));
/*********************************************************/
/* Main code                                             */
/*********************************************************/
phpAds_ShowSettings($settings, $errormessage);
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PageFooter();
    phpAds_SettingsWriteAdd('content_gzip_compression', isset($content_gzip_compression));
    phpAds_SettingsWriteAdd('client_welcome', isset($client_welcome));
    if (isset($client_welcome_msg)) {
        phpAds_SettingsWriteAdd('client_welcome_msg', $client_welcome_msg);
    }
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-defaults.php");
            exit;
        }
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2"));
phpAds_SettingsSelection("interface");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
$settings = array(array('text' => $strGeneralSettings, 'items' => array(array('type' => 'text', 'name' => 'name', 'text' => $strAppName, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'my_header', 'text' => $strMyHeader, 'size' => 35), array('type' => 'break'), array('type' => 'text', 'name' => 'my_footer', 'text' => $strMyFooter, 'size' => 35), array('type' => 'break'), array('type' => 'checkbox', 'name' => 'content_gzip_compression', 'text' => $strGzipContentCompression))), array('text' => $strClientInterface, 'items' => array(array('type' => 'checkbox', 'name' => 'client_welcome', 'text' => $strClientWelcomeEnabled), array('type' => 'break'), array('type' => 'textarea', 'name' => 'client_welcome_msg', 'text' => $strClientWelcomeText, 'depends' => 'client_welcome==true'))));
/*********************************************************/
/* Main code                                             */
/*********************************************************/
phpAds_ShowSettings($settings, $errormessage);
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PageFooter();
    }
    phpAds_SettingsWriteAdd('geotracking_cookie', isset($geotracking_cookie));
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-stats.php");
            exit;
        }
    }
}
/*********************************************************/
/* HTML framework                                        */
/*********************************************************/
phpAds_PrepareHelp();
phpAds_PageHeader("5.1");
phpAds_ShowSections(array("5.1", "5.3", "5.4", "5.2"));
phpAds_SettingsSelection("host");
/*********************************************************/
/* Cache settings fields and get help HTML Code          */
/*********************************************************/
// Prepare geotargeting options
$geo_plugins = array();
$geo_plugin_dir = opendir(phpAds_path . '/libraries/geotargeting/');
while ($geo_plugin = readdir($geo_plugin_dir)) {
    if (preg_match('|geo-.*\\.inc\\.php|i', $geo_plugin) && file_exists(phpAds_path . '/libraries/geotargeting/' . $geo_plugin)) {
        include_once phpAds_path . '/libraries/geotargeting/' . $geo_plugin;
        eval("\$" . "geo_plugin_info = phpAds_" . $phpAds_geoPluginID . "_getInfo();");
        $geo_plugins_info[$phpAds_geoPluginID] = $geo_plugin_info;
        $geo_plugins[$phpAds_geoPluginID] = $geo_plugin_info['name'];
    }
}
closedir($geo_plugin_dir);