/**
 *This function resets all the configuration options to the default
 */
function ResetPostieConfig()
{
    global $wpdb;
    //Get rid of old values
    $query = "delete from  " . POSTIE_TABLE . "  WHERE label NOT IN ('MAIL_PASSWORD', 'MAIL_SERVER', 'MAIL_SERVER_PORT', 'MAIL_USERID', 'INPUT_PROTOCOL');";
    $results = $wpdb->query($wpdb->prepare($query));
    $config = GetConfig();
    $key_arrays = GetListOfArrayConfig();
    foreach ($key_arrays as $key) {
        $config[$key] = join("\n", $config[$key]);
    }
    UpdatePostieConfig($config);
}
Example #2
0
/**
 *This function resets all the configuration options to the default
 */
function ResetPostieConfig()
{
    global $wpdb;
    //Get rid of the old table
    $wpdb->query("DROP TABLE " . POSTIE_TABLE . ";");
    $config = GetConfig();
    $key_arrays = GetListOfArrayConfig();
    foreach ($key_arrays as $key) {
        $config[$key] = join("\n", $config[$key]);
    }
    UpdatePostieConfig($config);
}
Example #3
0
/**
 * validates the config form output, fills in any gaps by using the defaults,
 * and ensures that arrayed items are stored as such
 */
function postie_validate_settings($in)
{
    if (defined('POSTIE_DEBUG')) {
        var_dump($in);
    }
    $out = array();
    // use the default as a template:
    // if a field is present in the defaults, we want to store it; otherwise we discard it
    $allowed_keys = get_postie_config_defaults();
    foreach ($allowed_keys as $key => $default) {
        $out[$key] = array_key_exists($key, $in) ? $in[$key] : $default;
    }
    // some fields are always forced to lower case:
    $lowercase = array('authorized_addresses', 'smtp', 'supported_file_types', 'video1types', 'video2types', 'audiotypes');
    foreach ($lowercase as $field) {
        $out[$field] = is_array($out[$field]) ? array_map(strtolower, $out[$field]) : strtolower($out[$field]);
    }
    $arrays = get_arrayed_settings();
    foreach ($arrays as $sep => $fields) {
        foreach ($fields as $field) {
            if (!is_array($out[$field])) {
                $out[$field] = explode($sep, trim($out[$field]));
            }
            foreach ($out[$field] as $key => $val) {
                $tst = trim($val);
                if (empty($tst)) {
                    unset($out[$field][$key]);
                } else {
                    $out[$field][$key] = $tst;
                }
            }
        }
    }
    UpdatePostieConfig($out);
    return $out;
}
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php";
if (isset($_POST["action"])) {
    switch ($_POST["action"]) {
        case "reset":
            ResetPostieConfig();
            $message = 1;
            break;
        case "cronless":
            check_postie();
            $message = 1;
            break;
        case "test":
            $location = get_option('siteurl') . '/wp-admin/options-general.php?page=postie/postie_test.php';
            header("Location: {$location}\n\n");
            exit;
            break;
        case "config":
            if (UpdatePostieConfig($_POST)) {
                $message = 1;
            } else {
                $message = 2;
            }
            break;
        default:
            $message = 2;
            break;
    }
    $location = get_option('siteurl') . '/wp-admin/options-general.php?page=postie/postie.php';
    header("Location: {$location}&message={$message}\n\n");
    exit;
}