====== WEB GUI Extension & Custom Configuration Parameters ====== Customized GUI extensions to display and change custom config paramters. Please use nb_userpage_register in stead of nb_page_register in case you want to show this page also to non-admin user /* 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, '
', ID); for (i = 0; i < length(fields); i++) // show all fields with actual value nb_page_respond(page, '%s

', fields[i].text, fields[i].value, fields[i].name); nb_page_respond(page, '
'); nb_page_finish(page); } }
{{:sdk:gui-extension1.png|}} {{:sdk:sdk_ftp1.png|}} Entering data into the fields: ---- {{:sdk:sdk_ftp.png|}} ---- will store the data in the user configuration paramters for further use: custom.var0=ftp.myserver.com custom.var1=myfile.txt custom.var2=admin custom.var3=adminpassword custom.var4=n In general following configuration parameters are free to use for customer applications (see router /etc/config/factory-config.cfg): # custom custom.status = custom.var0 = custom.var1 = custom.var2 = custom.var3 = custom.var4 = # custom table0 custom.table0.0.var0 = custom.table0.0.var1 = custom.table0.0.var2 = custom.table0.0.var3 = custom.table0.0.var4 = custom.table0.1.var0 = custom.table0.1.var1 = custom.table0.1.var2 = custom.table0.1.var3 = custom.table0.1.var4 = # custom table1 custom.table1.0.var0 = custom.table1.0.var1 = custom.table1.0.var2 = custom.table1.0.var3 = custom.table1.0.var4 = custom.table1.1.var0 = custom.table1.1.var1 = custom.table1.1.var2 = custom.table1.1.var3 = custom.table1.1.var4 = # custom table2 custom.table2.0.var0 = custom.table2.0.var1 = custom.table2.0.var2 = custom.table2.0.var3 = custom.table2.0.var4 = custom.table2.1.var0 = custom.table2.1.var1 = custom.table2.1.var2 = custom.table2.1.var3 = custom.table2.1.var4 = custom.table2.2.var0 = custom.table2.2.var1 = custom.table2.2.var2 = custom.table2.2.var3 = custom.table2.2.var4 = custom.table2.3.var0 = custom.table2.3.var1 = custom.table2.3.var2 = custom.table2.3.var3 = custom.table2.3.var4 = custom.table2.4.var0 = custom.table2.4.var1 = custom.table2.4.var2 = custom.table2.4.var3 = custom.table2.4.var4 = custom.table2.5.var0 = custom.table2.5.var1 = custom.table2.5.var2 = custom.table2.5.var3 = custom.table2.5.var4 = custom.table2.6.var0 = custom.table2.6.var1 = custom.table2.6.var2 = custom.table2.6.var3 = custom.table2.6.var4 = custom.table2.7.var0 = custom.table2.7.var1 = custom.table2.7.var2 = custom.table2.7.var3 = custom.table2.7.var4 =