stuppid_bot

Untitled

May 9th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. $response = array();
  5. ob_start();
  6. // тут прверяем права доступа
  7. $action = @$_GET['action'];
  8. $filename = @$_GET['filename'];
  9.  
  10. switch ($action) {
  11.     case 'read':
  12.         if ( $data = file_get_contents($filename) ) {
  13.             $response['data'] = $data;
  14.         }
  15.        
  16.         break;
  17.        
  18.     case 'write':
  19.         $append = @$_GET['append'];
  20.         $lock = @$_GET['lock'];      
  21.         ( $data = file_get_contents('php://input') ) && file_put_contents( $filename, $data, ($append ? FILE_APPEND : 0) | ($lock ? LOCK_EX : 0) );
  22. }
  23.  
  24. $response['error'] = ob_get_clean();
  25. echo( json_encode($response) );
  26.    
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment