2011-01-07 11:42:38 +01:00
{
"name" : "chmod" ,
"info" : {
"syntax" : "chmod <perms> <file|directory>" ,
2011-01-07 22:54:07 +01:00
"brief" : "Change the access permissions to a file or directory for one or more users or groups, example: \"chmod user1,user2,@group1,@group2+r /path\", \"chmod @all+rw /path\""
2011-01-07 11:42:38 +01:00
} ,
"action" : f u n c t i o n ( a r g )
{
v a r o u t = ' ' ;
i f ( ! a r g . m a t c h ( / ^ \ s * ( [ ^ + | - ] * ) ( \ + | \ - ) ( ( r | w ) + ) \ s + ( . + ) \ s * $ / ) )
{
r e t u r n "Usage: " + t h i s . i n f o . s y n t a x + "<br/>\n" ;
}
s h e l l . a u t o _ p r o m p t _ r e f r e s h = false ;
v a r u s e r l i s t = R e g E x p . $ 1 ;
v a r r e s o u r c e = R e g E x p . $ 5 ;
v a r p e r m _ s t r i n g = R e g E x p . $ 3 ;
v a r p e r m s = 0 ;
// Unset R/W perms: 011. Unset R perms: 010. Unset W perms: 001
// Set R/W perms: 111. Set R perms: 110. Set W perms: 101
p e r m s | = ( ( R e g E x p . $ 2 = = ' + ' ) ? 4 : 0 ) ;
p e r m s | = ( ( p e r m _ s t r i n g . m a t c h ( ' r ' ) ) ? 2 : 0 ) ;
p e r m s | = ( ( p e r m _ s t r i n g . m a t c h ( ' w ' ) ) ? 1 : 0 ) ;
r e s o u r c e = s h e l l . e x p a n d P a t h ( r e s o u r c e ) ;
v a r u s e r s _ p h p = w i n d o w . l o c a t i o n . h r e f ;
u s e r s _ p h p = u s e r s _ p h p . r e p l a c e ( / \ / ( [ a - z A - Z \ . ] + ) $ / , ' / m o d u l e s / u s e r s / u s e r s . p h p ' ) ;
p a r a m s = ' a c t i o n = c h m o d & r e s o u r c e = ' + e s c a p e ( r e s o u r c e ) + ' & p e r m s = ' + e s c a p e ( p e r m s . t o S t r i n g ( ) ) ;
i f ( u s e r l i s t )
{
p a r a m s + = ' & u s e r l i s t = ' + e s c a p e ( u s e r l i s t ) ;
}
v a r h t t p = n e w X M L H t t p R e q u e s t ( ) ;
h t t p . o p e n ( "POST" , u s e r s _ p h p , true ) ;
h t t p . s e t R e q u e s t H e a d e r ( "Content-type" , "application/x-www-form-urlencoded" ) ;
h t t p . s e t R e q u e s t H e a d e r ( "Content-length" , p a r a m s . l e n g t h ) ;
h t t p . s e t R e q u e s t H e a d e r ( "Connection" , "close" ) ;
h t t p . o n r e a d y s t a t e c h a n g e = f u n c t i o n ( )
{
i f ( h t t p . r e a d y S t a t e = = 4 & & h t t p . s t a t u s = = 200 )
{
i f ( h t t p . r e s p o n s e T e x t . l e n g t h > 0 )
{
s h e l l . c m d O u t . i n n e r H T M L = h t t p . r e s p o n s e T e x t ;
}
s h e l l . a u t o _ p r o m p t _ r e f r e s h = true ;
s h e l l . r e f r e s h P r o m p t ( false , false ) ;
}
}
h t t p . s e n d ( p a r a m s ) ;
s h e l l . c m d O u t . i n n e r H T M L = ' ' ;
r e t u r n o u t ;
}
}