Changeset 16782
- Timestamp:
- 04/12/11 14:58:02 (2 years ago)
- Location:
- src/router/httpd/visuals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/router/httpd/visuals/dd-wrt.c
r16781 r16782 4787 4787 } 4788 4788 // same haeh? 4789 #ifdef HAVE_ATH9K4790 if(is_ath9k(prefix)4791 && ( nvram_nmatch("mixed", "%s_net_mode", prefix)4792 || nvram_nmatch("n-only", "%s_net_mode", prefix)4793 || nvram_nmatch("ng-only", "%s_net_mode", prefix)4794 || nvram_nmatch("n2-only", "%s_net_mode", prefix)4795 || nvram_nmatch("n5-only", "%s_net_mode", prefix)4796 || nvram_nmatch("na-only", "%s_net_mode", prefix)))4797 websWrite(wp,4798 "document.write(\"<option value=\\\"40\\\" %s >\" + share.ht40 + \"</option>\");\n",4799 nvram_match(wl_width,4800 "40") ? "selected=\\\"selected\\\"" : "");4801 else4802 #endif4803 4789 if (!is_ath11n(prefix) 4804 4790 || (is_ath11n(prefix) … … 4813 4799 nvram_match(wl_width, 4814 4800 "40") ? "selected=\\\"selected\\\"" : ""); 4815 #ifdef HAVE_ATH9K4816 if(is_ath9k(prefix))4817 websWrite(wp,4818 "document.write(\"<option value=\\\"20\\\" %s >\" + share.ht20 + \"</option>\");\n",4819 nvram_match(wl_width,4820 "20") ? "selected=\\\"selected\\\"" : "");4821 else4822 #endif4823 4801 websWrite(wp, 4824 4802 "document.write(\"<option value=\\\"20\\\" %s >\" + share.full + \"</option>\");\n", -
src/router/httpd/visuals/ejs.c
r16781 r16782 26 26 #include <revision.h> 27 27 #include <shutils.h> 28 #ifdef HAVE_SAMBA_SERVER29 #include <jansson.h>30 #endif31 28 32 29 void (*do_ej_buffer) (char *buffer, webs_t stream) = NULL; … … 545 542 #ifdef HAVE_SAMBA 546 543 "SAMBA", 547 #endif548 #ifdef HAVE_SAMBA3549 "SAMBA3",550 544 #endif 551 545 #ifdef HAVE_JFFS2 … … 2282 2276 ("/sys/devices/platform/IXP4XX-I2C.0/i2c-0/0-0028/temp1_input", 2283 2277 "rb"); 2278 2284 2279 #elif HAVE_LAGUNA 2285 2280 int TEMP_MUL = 10; … … 3099 3094 } 3100 3095 3101 #ifdef HAVE_SAMBA_SERVER3102 struct fsentry {3103 char fs[32];3104 char mp[64];3105 char fstype[16];3106 char perms[4];3107 struct fsentry *next;3108 };3109 3110 struct fsentry *parsefsentry(char line[256]) {3111 3112 struct fsentry *entry = calloc(1, sizeof(struct fsentry));3113 char *token, *perm;3114 int tokcount = 0;3115 3116 line[strlen(line) - 1] = '\0'; // replace new line with null3117 token = strtok(line, " ");3118 while(token != NULL) {3119 // check for values3120 if(tokcount == 0) {3121 strcpy(entry->fs, token);3122 } else if(tokcount == 2) {3123 strcpy(entry->mp, token);3124 } else if(tokcount == 4) {3125 strcpy(entry->fstype, token);3126 } else if(tokcount == 5) {3127 perm = strtok(token, ",");3128 strncpy(entry->perms, perm + 1, strlen(perm) - 1);3129 }3130 // next token3131 token = strtok(NULL, " ");3132 tokcount++;3133 }3134 return entry;3135 }3136 3137 struct fsentry *getfsentries() {3138 3139 char line[256];3140 FILE *fp;3141 struct fsentry *list, *current;3142 int count = 0;3143 3144 if ((fp = popen("mount", "r"))) {3145 //current = list;3146 while( fgets(line, sizeof(line), fp) ) {3147 //fprintf(stderr, "[MOUNTS] %s\n", line);3148 if(count == 0) {3149 list = parsefsentry(line);3150 current = list;3151 } else {3152 current->next = parsefsentry(line);3153 current = current->next;3154 }3155 count++;3156 }3157 pclose(fp);3158 }3159 return list;3160 }3161 3162 struct samba3_shareuser {3163 char username[64];3164 struct samba3_shareuser *next;3165 };3166 3167 struct samba3_share {3168 char mp[32];3169 char label[64];3170 char public_perms[4];3171 int public;3172 struct samba3_shareuser *users;3173 struct samba3_share *next;3174 };3175 3176 struct samba3_user {3177 char username[64];3178 char password[64];3179 struct samba3_user *next;3180 };3181 3182 struct samba3_shareuser *getsamba3shareuser(const char *username) {3183 3184 struct samba3_shareuser *user = calloc(1, sizeof(struct samba3_shareuser));3185 3186 strcpy(user->username, username);3187 3188 return user;3189 };3190 3191 struct samba3_shareuser *getsamba3shareusers( json_t *users ) {3192 3193 int count, entry_count;3194 const char *value;3195 struct samba3_shareuser *shareusers, *current;3196 3197 entry_count = json_array_size( users );3198 if(entry_count == 0) {3199 return NULL;3200 }3201 for( count = 0; count < entry_count; count++ ) {3202 value = json_string_value( json_array_get( users, count ) );3203 if( count == 0 ) {3204 current = getsamba3shareuser( value );3205 shareusers = current;3206 } else {3207 current->next = getsamba3shareuser( value );3208 current = current->next;3209 }3210 }3211 3212 return shareusers;3213 }3214 3215 struct samba3_user *getsamba3user(char *username, char *password) {3216 3217 struct samba3_user *user = calloc(1, sizeof(struct samba3_user));3218 3219 strcpy(user->username, username);3220 strcpy(user->password, password);3221 3222 return user;3223 }3224 3225 struct samba3_user *getsamba3users() {3226 3227 struct samba3_user *list, *current;3228 int count, entry_count;3229 json_t *json;3230 json_error_t error;3231 const char *key;3232 json_t *iterator, *entry, *value;3233 char username[64],password[64];3234 3235 // first create dummy entry3236 list = getsamba3user("", "");3237 current = list;3238 3239 json = json_loads( "[{\"user\":\"peter\",\"pass\":\"test\"},{\"user\":\"chris\",\"pass\":\"test\"}]", &error );3240 //json = json_loads( nvram_default_get( "samba3_users", "[]"), &error);3241 if( !json ) {3242 fprintf( stderr, "[JASON] ERROR\n");3243 } else {3244 entry_count = json_array_size(json);3245 for( count = 0; count < entry_count; count++ ) {3246 entry = json_array_get( json, count );3247 iterator = json_object_iter(entry);3248 3249 // reset3250 username[0] = 0;3251 password[0] = 0;3252 3253 while(iterator)3254 {3255 key = json_object_iter_key(iterator);3256 value = json_object_iter_value(iterator);3257 /* use key and value ... */3258 if( !strcmp( key, "user" ) ) {3259 strcpy( username, json_string_value( value ));3260 } else if( !strcmp( key, "pass" ) ) {3261 strcpy( password, json_string_value( value ));3262 }3263 iterator = json_object_iter_next(entry, iterator);3264 }3265 if( username[0] != 0 ) {3266 current->next = getsamba3user(username, password);3267 current = current->next;3268 }3269 }3270 }3271 3272 return list;3273 }3274 3275 struct samba3_share *getsamba3share(char *mp, char *label, char *public_perms, int public, struct samba3_shareuser *users) {3276 3277 struct samba3_share *share = calloc(1, sizeof(struct samba3_share));3278 3279 strcpy(share->mp, mp);3280 strcpy(share->label, label);3281 strcpy(share->public_perms, public_perms);3282 share->public = public;3283 if(users != NULL) {3284 fprintf(stderr, "[SHAREUSERS] add\n");3285 share->users = users;3286 }3287 3288 return share;3289 }3290 3291 struct samba3_share *samba3shares;3292 3293 struct samba3_share *getsamba3shares() {3294 3295 struct samba3_share *list, *current;3296 int public, count, entry_count;3297 struct samba3_shareuser *shareusers;3298 json_t *json;3299 json_error_t error;3300 const char *key;3301 json_t *iterator, *entry, *value;3302 char mp[64],label[32],public_perms[4];3303 3304 // first create dummy entry3305 list = getsamba3share("", "", "", 0, NULL);3306 current = list;3307 3308 // json = json_loads( "[{\"mp\":\"/jffs\",\"label\":\"testshare\",\"perms\":\"rw\",\"public\":0},{\"mp\":\"/mnt\",\"label\":\"othertest\",\"perms\":\"ro\",\"public\":1},{\"label\":\"blah\"}]", &error );3309 json = json_loads( nvram_default_get( "samba3_shares", "[]"), &error);3310 if( !json ) {3311 fprintf( stderr, "[JASON] ERROR\n");3312 } else {3313 entry_count = json_array_size(json);3314 for( count = 0; count < entry_count; count++ ) {3315 entry = json_array_get( json, count );3316 iterator = json_object_iter(entry);3317 3318 // reset3319 mp[0] = 0;3320 label[0] = 0;3321 public_perms[0] = 0;3322 public = 0;3323 shareusers = NULL;3324 3325 while(iterator)3326 {3327 key = json_object_iter_key(iterator);3328 value = json_object_iter_value(iterator);3329 /* use key and value ... */3330 if( !strcmp( key, "mp" ) ) {3331 strcpy( mp, json_string_value( value ));3332 } else if( !strcmp( key, "label" ) ) {3333 strcpy( label, json_string_value( value ));3334 } else if( !strcmp( key, "public_perms" ) ) {3335 strcpy( public_perms, json_string_value( value ));3336 } else if( !strcmp( key, "public") ) {3337 public = json_integer_value( value );3338 } else if( !strcmp( key, "users" ) ) {3339 //fprintf( stderr, "[SAMABA SHARES] users\n" );3340 shareusers = getsamba3shareusers( value );3341 }3342 iterator = json_object_iter_next(entry, iterator);3343 }3344 if( mp[0] != 0 && label != 0 && public_perms != 0 ) {3345 current->next = getsamba3share(mp, label, public_perms, public, shareusers);3346 current = current->next;3347 }3348 }3349 }3350 3351 /* current->next = getsamba3share("/jffs", "testshare", "rw", 0);3352 current = current->next;3353 current->next = getsamba3share("/mnt", "othertest", "ro", 1);3354 */3355 return list;3356 }3357 3358 void ej_samba3_sharepaths(webs_t wp, int argc, char_t ** argv) {3359 3360 struct fsentry *fs, *current;3361 struct samba3_share *cs;3362 char buffer[64], number[4], perms[16];3363 int found, rows = 0;3364 3365 fs = getfsentries();3366 samba3shares = getsamba3shares();3367 3368 // share count var3369 for(cs = samba3shares; cs; cs = cs->next) {3370 rows++;3371 }3372 rows--;3373 websWrite(wp, " <input type=\"hidden\" name=\"samba3_share_count\" id=\"share_count\" value=\"%d\">\n", rows);3374 rows = 0;3375 3376 // table header3377 websWrite(wp, " <table id=\"samba_shares\" class=\"table center\" summary=\"samba share table\">\n");3378 websWrite(wp, " <tr><th colspan=\"5\"><script type=\"text/javascript\">Capture(service.samba3_share_root)</script></th></tr>\n");3379 websWrite(wp, " <tr>\n");3380 websWrite(wp, " <th>path</th>\n");3381 websWrite(wp, " <th>name</th>\n");3382 websWrite(wp, " <th>public</th>\n");3383 websWrite(wp, " <th>access</th>\n");3384 websWrite(wp, " <th style=\"width: 50px;\"> </th>\n");3385 websWrite(wp, " </tr>\n");3386 3387 for(cs = samba3shares; cs; cs = cs->next) {3388 3389 if(rows == 0) {3390 // dummy entry3391 sprintf(buffer, "%s", "id=\"samba_shares_row_template\" style=\"display: none;\"");3392 //sprintf(number, '\0');3393 number[0] = '\0';3394 } else {3395 sprintf(buffer, "id=\"samba_shares_row_%d\"", rows);3396 sprintf(number, "_%d", rows);3397 }3398 3399 websWrite(wp, " <tr %s>\n", buffer);3400 3401 // display filesystems to mount3402 found = 0;3403 //sprintf( perms, "");3404 perms[0] = '\0';3405 websWrite(wp, " <td id=\"n_share_mp%s\" style=\"width: 17.816em;\"><select name=\"smbshare_mp%s\" id=\"smbshare_mp%s\" style=\"width: 100%%;\" onchange=\"setSambaShareAccessOptions(this);\">\n", number, number, number);3406 websWrite(wp, " <option value=\"\" rel=\"\">-</option>\n");3407 //fprintf(stderr, "[SAMBA] FS %s:%s public:%d\n", cs->label, cs->mp, cs->public );3408 for(current = fs; current; current = current->next) {3409 if( strcmp(current->fstype, "squashfs")3410 && strcmp(current->fstype, "rootfs")3411 && strcmp(current->fstype, "proc")3412 && strcmp(current->fstype, "sysfs")3413 && strcmp(current->fstype, "sysdebug")3414 && strcmp(current->fstype, "debugfs")3415 && strcmp(current->fstype, "ramfs")3416 && strcmp(current->fstype, "tmpfs")3417 && strcmp(current->fstype, "devpts")3418 && strcmp(current->fstype, "usbfs")) {3419 // adjust the rights3420 if( /*rows == 0 ||*/ !strcmp(current->mp, "") ) {3421 sprintf(buffer, "%s", "");3422 } else if( !strcmp(current->perms, "rw") ) {3423 sprintf(buffer, "%s", "\"rw\",\"ro\"");3424 } else {3425 sprintf(buffer, "%s", "\"ro\"");3426 }3427 3428 if( !strcmp( current->mp, cs->mp ) ) {3429 found = 1;3430 sprintf( perms, "%s", current->perms );3431 }3432 3433 websWrite(wp, " <option value=\"%s\" rel='{\"fstype\":\"%s\",\"perms\":[%s],\"avail\":1}' %s>%s</option>\n", current->mp, current->fstype, buffer, found == 0 ? "" : "selected=\"selected\"", current->mp);3434 }3435 }3436 // fs not available -> add stored entry for display3437 if( found == 0 && rows > 0) {3438 websWrite(wp, " <option value=\"%s\" rel='{\"fstype\":\"\",\"perms\":[\"%s\"],\"avail\":0}' selected>%s [not available!]</option>\n", cs->mp, cs->public_perms, cs->mp);3439 sprintf(perms, "%s", cs->public_perms );3440 }3441 websWrite(wp, " </select></td>\n");3442 websWrite(wp, " <td style=\"width: 1%%;\"><input type=\"text\" name=\"smbshare_label%s\" id=\"smbshare_label%s\" value=\"%s\" style=\"width: 150px;\" onChange=\"updateSambaUserShare(this);\" /></td>\n", number, number, cs->label);3443 websWrite(wp, " <td style=\"width: 25px; text-align: center;\"><input type=\"checkbox\" name=\"smbshare_public%s\" id=\"smbshare_public%s\" value=\"1\" %s></td>\n", number, number, cs->public == 1 ? "checked" : "");3444 websWrite(wp, " <td>\n");3445 websWrite(wp, " <select name=\"smbshare_public_perms%s\" id=\"smbshare_public_perms%s\" style=\"width: 100%%;\"%s>\n", number, number, !strcmp(perms, "") ? " disabled" : "" );3446 if( rows == 0 || !strcmp(perms, "rw" ) ) {3447 websWrite(wp, " <option value=\"rw\">Read/Write</option>\n");3448 }3449 if( rows == 0 || strcmp(perms, "" ) ) {3450 websWrite(wp, " <option value=\"ro\">Read Only</option>\n");3451 }3452 websWrite(wp, " </select>\n");3453 websWrite(wp, " <input type=\"hidden\" name=\"smbshare_public_perms_prev_%d\" value=\"%s\">\n", rows, cs->public_perms);3454 websWrite(wp, " <td style=\"width: 50px; text-align: center;\">\n");3455 websWrite(wp, " <input type=\"button\" class=\"button\" name=\"smbshare_del%s\" value=\"Remove\" style=\"width: 100%%;\" onclick=\"removeSambaShare(this);\">\n", number);3456 websWrite(wp, " </td>\n");3457 websWrite(wp, " </tr>\n");3458 3459 rows++;3460 }3461 3462 websWrite(wp, " </table>\n");3463 3464 // add button3465 websWrite(wp, "<div style=\"text-align: center;\"><input type=\"button\" class=\"button\" name=\"share_add\" value=\"Add Share\" onclick=\"addSambaShare();\" /></div>");3466 3467 for(current = fs; fs; current = fs) {3468 fs = current->next;3469 free(current);3470 }3471 }3472 3473 void ej_samba3_users(webs_t wp, int argc, char_t ** argv) {3474 3475 struct samba3_share *cs;3476 struct samba3_shareuser *csu;3477 struct samba3_user *samba3users, *cu;3478 char buffer[64], number[4];3479 int rows, usershares;3480 3481 samba3users = getsamba3users();3482 3483 // share count var3484 for(cu = samba3users; cu; cu = cu->next) {3485 rows++;3486 }3487 rows--;3488 websWrite(wp, " <input type=\"hidden\" name=\"samba3_user_count\" id=\"samba3_user_count\" value=\"%d\">\n", rows);3489 rows = 0;3490 3491 // table header3492 websWrite(wp, " <table id=\"samba_users\" class=\"table center\" summary=\"samba user table\">\n");3493 3494 websWrite(wp, " <tr><th colspan=\"4\"><script type=\"text/javascript\">Capture(service.samba3_user_root)</script></th></tr>\n");3495 websWrite(wp, " <tr>\n");3496 websWrite(wp, " <th style=\"width:120px;\">username</th>\n");3497 websWrite(wp, " <th style=\"width:120px;\">password</th>\n");3498 websWrite(wp, " <th>share access</th>\n");3499 websWrite(wp, " <th style=\"width:50px;\"> </th>\n");3500 websWrite(wp, " </tr>\n");3501 3502 for( cu = samba3users; cu; cu = cu->next ) {3503 3504 if(rows == 0) {3505 // dummy entry3506 sprintf(buffer, "%s", "id=\"n_smbuser_template\" style=\"display: none;\"");3507 //sprintf(number, '\0');3508 number[0] = '\0';3509 } else {3510 sprintf(buffer, "id=\"samba_users_row_%d\"", rows);3511 sprintf(number, "_%d", rows);3512 }3513 3514 websWrite(wp, " <tr %s>\n", buffer);3515 3516 websWrite(wp, " <td id=\"n_smbuser_user\" valign=\"top\" align=\"center\">\n");3517 websWrite(wp, " <input type=\"text\" name=\"smbuser_username%s\" value=\"%s\" style=\"width: 116px;\">\n", number, cu->username);3518 websWrite(wp, " </td>\n");3519 3520 websWrite(wp, " <td id=\"n_smbuser_pass\" valign=\"top\" align=\"center\">\n");3521 websWrite(wp, " <input type=\"password\" name=\"smbuser_password%s\" id=\"smbuser_password%s\" value=\"%s\" style=\"width: 116px;\"> \n", number, number, cu->password);3522 websWrite(wp, " <input type=\"checkbox\" name=\"smbuser_password%s_unmask\" value=\"0\" onclick=\"alert('unmask');setElementMask('smbuser_password%s', this.checked);\">\n", number, number);3523 websWrite(wp, " </td>\n");3524 3525 //fprintf( stderr, "[USERS] %s:%s\n", cu->username, cu->password );3526 websWrite(wp, " <td id=\"n_smbuser_shareaccess\">\n");3527 if( rows == 0 ) {3528 websWrite(wp, " <div id=\"n_smbuser_share\" style=\"padding: 2px 0;\"><input type=\"checkbox\"> <span> </span></div>\n");3529 } else {3530 usershares = 0;3531 for( cs = samba3shares; cs; cs = cs->next) {3532 buffer[0] = '\0';3533 for( csu = cs->users; csu; csu = csu->next ) {3534 if( !strcmp( csu->username, cu->username ) ) {3535 //fprintf( stderr, "[USERSHARES] %s: %s\n", cs->label, csu->username );3536 sprintf( buffer, " checked");3537 }3538 }3539 if(usershares > 0) {3540 websWrite(wp, " <div id=\"n_smbuser_share\" style=\"padding: 2px 0;\"><input type=\"checkbox\" name=\"smbshare_%d_user_%d\"%s> <span>%s</span></div>\n", usershares, rows, buffer, cs->label);3541 }3542 usershares++;3543 }3544 }3545 websWrite(wp, " </td>\n");3546 3547 websWrite(wp, " <td valign=\"top\" style=\"width: 50px; text-align: center;\">\n");3548 websWrite(wp, " <input type=\"button\" class=\"button\" name=\"smbuser_del%s\" value=\"Remove\" style=\"width: 100%%;\" onclick=\"removeTableEntry('samba_users', this);\">\n", number);3549 websWrite(wp, " </td>\n");3550 3551 websWrite(wp, " </tr>\n");3552 rows++;3553 }3554 3555 websWrite(wp, " </table>\n");3556 3557 // add button3558 websWrite(wp, "<div style=\"text-align: center;\"><input type=\"button\" class=\"button\" name=\"user_add\" value=\"Add User\" onclick=\"addSambaUser();\" /></div>");3559 3560 // free memory3561 3562 }3563 #endif3564 3565 3096 #ifdef HAVE_UPNP 3566 3097 // changed by steve -
src/router/httpd/visuals/site_survey.c
r16781 r16782 123 123 else if (site_survey_lists[i].rate_count == 300) 124 124 rates = "300(b/g/n)"; 125 else if (site_survey_lists[i].rate_count == 450)126 rates = "450(b/g/n)";127 125 else if (site_survey_lists[i].rate_count == 150) 128 126 rates = "150(b/g/n)"; … … 139 137 else if (site_survey_lists[i].rate_count == 300) 140 138 rates = "300(a/n)"; 141 else if (site_survey_lists[i].rate_count == 450)142 rates = "450(a/n)";143 139 else if (site_survey_lists[i].rate_count == 150) 144 140 rates = "150(a/n)";
Note: See TracChangeset
for help on using the changeset viewer.
