Changeset 3700
- Timestamp:
- 07/07/07 11:42:50 (1 year ago)
- Files:
-
- trunk/Plug-Ins/Web Interface/JVWebInterfacePlugin.m (modified) (8 diffs)
- trunk/Plug-Ins/Web Interface/nanohttpd/http_resp.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Plug-Ins/Web Interface/JVWebInterfacePlugin.m
r3699 r3700 365 365 366 366 http_req_t *req = [[arguments objectForKey:JVWebInterfaceRequest] pointerValue]; 367 if( ! req || ! req->content ) return; 367 if( ! req || ! req->content ) { 368 resp -> status_code = 500; 369 resp -> reason_phrase = "Insufficient Information"; 370 return; 371 } 368 372 369 373 NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; … … 396 400 397 401 if( passwordMatches ) { 398 if( rememberMe ) 399 resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/; expires=Wed, 1 Jan 2014 23:59:59 UTC", identifier] UTF8String] ); 400 else 401 resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/", identifier] UTF8String] ); 402 @synchronized( _clients ) { 403 [_clients setObject:[NSMutableDictionary dictionary] forKey:identifier]; 404 } 405 406 if( rememberMe ) resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/; expires=Wed, 1 Jan 2014 23:59:59 UTC", identifier] UTF8String] ); 407 else resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/", identifier] UTF8String] ); 408 402 409 resp -> content_type = "text/plain"; 403 410 resp -> write( resp, "authenticated", 13 ); … … 409 416 if( ! resp ) return; 410 417 411 NSMutableDictionary *info = [NSMutableDictionary dictionary];412 418 NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 413 if( ! identifier ) return; 414 415 NSXMLDocument *doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"queue"]]; 416 [info setObject:doc forKey:@"activityQueue"]; 417 418 NSMutableDictionary *styles = [NSMutableDictionary dictionary]; 419 [info setObject:styles forKey:@"styles"]; 420 421 NSString *overrideStyle = [arguments objectForKey:JVWebInterfaceOverrideStyle]; 422 if( [overrideStyle length] ) 423 [info setObject:overrideStyle forKey:@"overrideStyle"]; 424 425 doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"setup"]]; 419 if( ! identifier ) { 420 resp -> status_code = 403; 421 resp -> reason_phrase = "Access Forbidden"; 422 return; 423 } 424 425 @synchronized( _clients ) { 426 NSMutableDictionary *info = [_clients objectForKey:identifier]; 427 if( ! info ) { 428 resp -> status_code = 403; 429 resp -> reason_phrase = "Access Forbidden"; 430 return; 431 } 432 433 // reset everything 434 [info removeAllObjects]; 435 436 NSXMLDocument *doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"queue"]]; 437 [info setObject:doc forKey:@"activityQueue"]; 438 439 NSMutableDictionary *styles = [NSMutableDictionary dictionary]; 440 [info setObject:styles forKey:@"styles"]; 441 442 NSString *overrideStyle = [arguments objectForKey:JVWebInterfaceOverrideStyle]; 443 if( [overrideStyle length] ) 444 [info setObject:overrideStyle forKey:@"overrideStyle"]; 445 } 446 447 NSXMLDocument *doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"setup"]]; 426 448 NSXMLElement *node = [NSXMLElement elementWithName:@"panels"]; 427 449 [[doc rootElement] addChild:node]; … … 453 475 } 454 476 455 @synchronized( _clients ) {456 [_clients setObject:info forKey:identifier];457 }458 459 477 resp -> content_type = "text/xml"; 460 478 … … 472 490 @synchronized( _clients ) { 473 491 NSDictionary *info = [_clients objectForKey:identifier]; 474 if( ! info ) return; 492 if( ! info ) { 493 resp -> status_code = 403; 494 resp -> reason_phrase = "Access Forbidden"; 495 return; 496 } 475 497 476 498 JVDirectChatPanel *panel = [self panelForIdentifier:[arguments objectForKey:@"panel"]]; … … 503 525 504 526 NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 505 if( ! identifier ) return; 527 if( ! identifier ) { 528 resp -> status_code = 403; 529 resp -> reason_phrase = "Access Forbidden"; 530 return; 531 } 506 532 507 533 @synchronized( _clients ) { … … 515 541 516 542 NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 517 if( ! identifier ) return; 543 if( ! identifier ) { 544 resp -> status_code = 403; 545 resp -> reason_phrase = "Access Forbidden"; 546 return; 547 } 548 549 @synchronized( _clients ) { 550 NSDictionary *info = [_clients objectForKey:identifier]; 551 if( ! info ) { 552 resp -> status_code = 403; 553 resp -> reason_phrase = "Access Forbidden"; 554 return; 555 } 556 } 518 557 519 558 JVDirectChatPanel *panel = [self panelForIdentifier:[arguments objectForKey:@"panel"]]; … … 560 599 561 600 NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 562 if( ! identifier ) return; 601 if( ! identifier ) { 602 resp -> status_code = 403; 603 resp -> reason_phrase = "Access Forbidden"; 604 return; 605 } 563 606 564 607 @synchronized( _clients ) { 565 608 NSDictionary *info = [_clients objectForKey:identifier]; 566 if( ! info ) return; 609 if( ! info ) { 610 resp -> status_code = 403; 611 resp -> reason_phrase = "Access Forbidden"; 612 return; 613 } 567 614 568 615 NSXMLDocument *doc = [info objectForKey:@"activityQueue"]; trunk/Plug-Ins/Web Interface/nanohttpd/http_resp.c
r3552 r3700 124 124 http_resp_send_headers( me ); 125 125 126 me -> netbuf -> printf( me -> netbuf, "The document can be found here: <a href =\"%s\">%s</a>", location, location );126 me -> netbuf -> printf( me -> netbuf, "The document can be found here: <a href=\"%s\">%s</a>", location, location ); 127 127 128 128 return 0;
