/**
  * @param $package
  * @return string
  * @usage Generate Google Doc Preview
  */
 public static function docPreview($package)
 {
     $files = $package['files'];
     if (!is_array($files)) {
         return "";
     }
     $ind = -1;
     foreach ($files as $i => $sfile) {
         $ifile = $sfile;
         $sfile = explode(".", $sfile);
         if (in_array(end($sfile), array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'))) {
             $ind = \WPDM_Crypt::Encrypt($ifile);
             break;
         }
     }
     if ($ind == -1) {
         return "";
     }
     $url = wpdm_download_url($package, 'ind=' . $ind);
     if (strpos($ifile, "://")) {
         $url = $ifile;
     }
     return \WPDM\FileSystem::docPreview($url);
 }
 /**
  * @usage Protect Download Dir using .htaccess rules
  */
 public static function setHtaccess()
 {
     \WPDM\FileSystem::blockHTTPAccess(UPLOAD_DIR);
 }
function wpdm_dir_browser()
{
    if (!isset($_GET['task']) || $_GET['task'] != 'wpdm_dir_browser') {
        return;
    }
    if (!current_user_can('access_server_browser')) {
        echo "<ul><li>" . __('Not Allowed!', 'wpdmpro') . "</li></ul>";
        die;
    }
    $root = get_option('_wpdm_file_browser_root', $_SERVER['DOCUMENT_ROOT']);
    $dirs = \WPDM\FileSystem::subDirs($root);
    ?>

        <style>

         .dirs .col-md-4{

         }

         .dirs .dir{
         border-radius: 3px;
         margin-bottom: 15px;
         margin-top: 15px;
         display: block;
             font-size: 11px;
             text-decoration: none;
             color: #444;
             font-family: 'Courier', monospace;
         }
         #dpath, #routs, #routs a{ font-family: 'Courier', monospace; }
        .dirs .fa{
            color: #00A99D;
        }
         .dirs .dir:hover{ text-decoration: none; }
            .dirs .col-md-4{
                border: 1px solid #eee;
                margin-left: -1px;
                margin-top: -1px;
            }
            #TB_ajaxContent{ min-width: calc(100% - 30px); height:100% !important; }
</style>
        <div class='w3eden'>
        <div class='row dirs'>
        <div class="col-md-12 selc"><br/>
            <div class="input-group"><input type="text" id="dpath" class="form-control">
                <div class="input-group-btn">
                    <button type="button" id="slctdir" class="btn btn-default">Insert</button>
                </div>
            </div>
            <br/>
            <div class="breadcrumb" id="routs" style="margin: 0 0 15px 0"><a href="#" onclick="return explore('<?php 
    echo $root;
    ?>
')">root$</a> / </div>
        </div>
        </div>
        <div class="dirs" style="padding: 15px">
        <div class="row" id="dirs-body">
        <?php 
    foreach ($dirs as $dir) {
        $dirname = trim($dir, '/');
        $dirname = explode('/', $dirname);
        $dirname = end($dirname);
        ?>

            <div class="col-md-4">
            <a class="dir" href="#" onclick="return explore('<?php 
        echo $dir;
        ?>
', this)">
                <i class="fa fa-folder-open"></i> &nbsp;<?php 
        echo $dirname;
        ?>
            </a>
            </div>

            <?php 
    }
    ?>
    </div></div></div>
    <script>

            function explore(dir, a) {
                jQuery(a).find('.fa-folder-open').removeClass('fa-folder-open').addClass('fa-spin fa-spinner');
                dir = dir.replace(/\/+$/,'');
                jQuery('#dpath').val(dir);
                jQuery('#dirs-body').load('admin.php?task=wpdm_odir_grid&dir='+dir);
                var root = '<?php 
    echo $root;
    ?>
';
                var dirp = dir.replace(root, '');
                dirp = dirp.split('/');
                var path = '', proot = root.replace(/\/+$/,'');
                jQuery.each(dirp, function (i, d) {
                   var  name = d == ''?'root$ ':d;
                    path += "<a href='#' onclick=\"return explore('"+proot+'/'+d+"')\">"+name+"</a>/";
                    if(d != '')
                    proot = proot+'/'+d;

                });
                jQuery('#routs').html(path);
                return false;
            }

            jQuery('#slctdir').click(function(){
                jQuery('#srvdir').val(jQuery('#dpath').val());
                tb_remove();
            });

    </script>
    <?php 
    die;
}
/**
 * @param $pdf
 * @param $id
 * @return string
 * @usage Generates thumbnail from PDF file. [ From v4.1.3 ]
 */
function wpdm_pdf_thumbnail($pdf, $id)
{
    return \WPDM\FileSystem::pdfThumbnail($pdf, $id);
}
예제 #5
0
 function clearCache()
 {
     if (!current_user_can('manage_options')) {
         return;
     }
     \WPDM\FileSystem::deleteFiles(WPDM_CACHE_DIR, false);
     die('ok');
 }