예제 #1
0
파일: Ajax.php 프로젝트: noxian/WP-Filebase
 private static function tplSample($args)
 {
     global $current_user;
     if (!current_user_can('edit_posts')) {
         die('-1');
     }
     wpfb_loadclass('File', 'Category', 'TplLib', 'Output');
     if (isset($args['tpl']) && empty($args['tpl'])) {
         exit;
     }
     $cat = new WPFB_Category(array('cat_id' => 0, 'cat_name' => 'Example Category', 'cat_description' => 'This is a sample description.', 'cat_folder' => 'example', 'cat_num_files' => 0, 'cat_num_files_total' => 0));
     $cat->Lock();
     $file = new WPFB_File(array('file_name' => 'example.pdf', 'file_display_name' => 'Example Document', 'file_size' => 1024 * 1024 * 1.5, 'file_date' => gmdate('Y-m-d H:i:s', time()), 'file_hash' => md5(''), 'file_thumbnail' => 'thumb.png', 'file_description' => 'This is a sample description.', 'file_version' => WPFB_VERSION, 'file_author' => $current_user->display_name, 'file_hits' => 3, 'file_added_by' => $current_user->ID));
     $file->Lock();
     if (!empty($args['type']) && $args['type'] == 'cat') {
         $item = $cat;
     } elseif (!empty($args['type']) && $args['type'] == 'list') {
         wpfb_loadclass('ListTpl');
         $tpl = new WPFB_ListTpl('sample', $args['tpl']);
         echo $tpl->Sample($cat, $file);
         exit;
     } elseif (empty($args['file_id']) || ($item = WPFB_File::GetFile($args['file_id'])) == null || !$file->CurUserCanAccess(true)) {
         $item = $file;
     } else {
         die('-1');
     }
     $tpl = empty($args['tpl']) ? null : WPFB_TplLib::Parse($args['tpl']);
     echo do_shortcode($item->GenTpl($tpl, 'ajax'));
 }
예제 #2
0
파일: wpfb-ajax.php 프로젝트: parsonsc/dofe
     if (!current_user_can('upload_files') || $file_id <= 0 || ($file = WPFB_File::GetFile($file_id)) == null) {
         die('-1');
     }
     $file->Remove();
     die('1');
 case 'tpl-sample':
     global $current_user;
     if (!current_user_can('edit_posts')) {
         die('-1');
     }
     wpfb_loadclass('File', 'Category', 'TplLib', 'Output');
     if (isset($_POST['tpl']) && empty($_POST['tpl'])) {
         exit;
     }
     $cat = new WPFB_Category(array('cat_id' => 0, 'cat_name' => 'Example Category', 'cat_description' => 'This is a sample description.', 'cat_folder' => 'example', 'cat_num_files' => 0, 'cat_num_files_total' => 0));
     $cat->Lock();
     $file = new WPFB_File(array('file_name' => 'example.pdf', 'file_display_name' => 'Example Document', 'file_size' => 1024 * 1024 * 1.5, 'file_date' => gmdate('Y-m-d H:i:s', time()), 'file_hash' => md5(''), 'file_thumbnail' => 'thumb.png', 'file_description' => 'This is a sample description.', 'file_version' => WPFB_VERSION, 'file_author' => $user_identity, 'file_hits' => 3, 'file_added_by' => $current_user->ID));
     $file->Lock();
     if (!empty($_POST['type']) && $_POST['type'] == 'cat') {
         $item = $cat;
     } elseif (!empty($_POST['type']) && $_POST['type'] == 'list') {
         wpfb_loadclass('ListTpl');
         $tpl = new WPFB_ListTpl('sample', $_REQUEST['tpl']);
         echo $tpl->Sample($cat, $file);
         exit;
     } elseif (empty($_POST['file_id']) || ($item = WPFB_File::GetFile($_POST['file_id'])) == null || !$file->CurUserCanAccess(true)) {
         $item = $file;
     } else {
         die('-1');
     }
     $tpl = empty($_POST['tpl']) ? null : WPFB_TplLib::Parse($_POST['tpl']);