コード例 #1
0
ファイル: files.ctrl.php プロジェクト: Ariflaw/b2evolution
     }
     // Note: we should have EXITED here. In case we don't (error, or sth...)
     // Reset stuff so it doesn't interfere with upcomming display
     unset($edited_Item);
     unset($edited_Link);
     $selected_Filelist = new Filelist($fm_Filelist->get_FileRoot(), false);
     break;
 case 'edit_file':
     // TODO: We don't need the Filelist, move UP!
     // Edit Text File
     // Check that this action request is not a CSRF hacked request:
     $Session->assert_received_crumb('file');
     // Check permission!
     $current_User->check_perm('files', 'edit_allowed', true, $blog ? $blog : NULL);
     // Get the file we want to edit:
     $edited_File =& $selected_Filelist->get_by_idx(0);
     // Check that the file is editable:
     if (!$edited_File->is_editable($current_User->check_perm('files', 'all'))) {
         $Messages->add(sprintf(T_('You are not allowed to edit «%s».'), $edited_File->dget('name')), 'error');
         // Leave special display mode:
         $action = 'list';
         break;
     }
     $full_path = $edited_File->get_full_path();
     if ($size = filesize($full_path)) {
         $rsc_handle = fopen($full_path, 'r');
         $edited_File->content = fread($rsc_handle, $size);
         fclose($rsc_handle);
     } else {
         // Empty file
         $edited_File->content = '';