/* DESC: This script will generate a page which can be viewed in the Web Manager * Some custom config vars are displayed and can be changed * All custom.* in /etc/config/factory-config.cfg are free to use * Copyright (C) 2014 NetModule AG, Switzerland, rfa */ ID = 1; if (is_void(page = nb_page_register(ID, "FTP upload", "Hotspot"))) exit(1); template entry { name; configvar; value; text; int entry(string n, c, t) { this.name = n; this.configvar = c; this.value = nb_config_get(c); // load inital value from config this.text = t; return 0; } }; fields = mkarray(); // fill up array fields[i=0] = new entry ("server", "custom.var0", "FTP server"); fields[++i] = new entry ("serverpath", "custom.var1", "Path"); fields[++i] = new entry ("user", "custom.var2", "user"); fields[++i] = new entry ("password", "custom.var3", "Password"); fields[++i] = new entry ("remove", "custom.var4", "Remove after upload (y/n)"); for (;;) { if (request = nb_page_request(page)) { post = struct_get(request, "POST"); // is empty on GET for (i = 0; i < length(post); i++) // get POST parameters and store in array and config nb_config_set(sprintf("%s=%s", fields[i].configvar, fields[i].value = post[i].value)); nb_page_respond(page, '
'); nb_page_finish(page); } }