/** * @usage Fetch link/page template and return generated html * @param $template * @param $vars * @param string $type * @return mixed|string|void */ public static function fetchTemplate($template, $vars, $type = 'link') { if (!is_array($vars) && is_int($vars) && $vars > 0) { $vars = array('ID' => $vars); } if (!isset($vars['ID']) || intval($vars['ID']) < 1) { return ''; } $default['link'] = 'link-template-default.php'; $default['page'] = 'page-template-default.php'; if (!isset($vars['formatted'])) { $pack = new \WPDM\Package($vars['ID']); $pack->Prepare(); $vars = $pack->PackageData; } if ($template == '') { if (!isset($vars['page_template'])) { $vars['page_template'] = 'page-template-default.php'; } $template = $type == 'page' ? $vars['page_template'] : $vars['template']; } if ($template == '') { $template = $default[$type]; } $templates = maybe_unserialize(get_option("_fm_" . $type . "_templates", true)); if (isset($templates[$template]) && isset($templates[$template]['content'])) { $template = $templates[$template]['content']; } else { if (!strpos(strip_tags($template), "]")) { $ltpldir = get_stylesheet_directory() . '/download-manager/' . $type . '-templates/'; if (!file_exists($ltpldir) || !file_exists($ltpldir . $template)) { $ltpldir = WPDM_BASE_DIR . '/tpls/' . $type . '-templates/'; } if (file_exists(TEMPLATEPATH . '/' . $template)) { $template = file_get_contents(TEMPLATEPATH . '/' . $template); } else { if (file_exists($ltpldir . $template)) { $template = file_get_contents($ltpldir . $template); } else { if (file_exists($ltpldir . $template . '.php')) { $template = file_get_contents($ltpldir . $template . '.php'); } else { if (file_exists($ltpldir . $type . "-template-" . $template . '.php')) { $template = file_get_contents($ltpldir . $type . "-template-" . $template . '.php'); } } } } } } preg_match_all("/\\[cf ([^\\]]+)\\]/", $template, $cfmatches); preg_match_all("/\\[thumb_([0-9]+)x([0-9]+)\\]/", $template, $matches); preg_match_all("/\\[thumb_url_([0-9]+)x([0-9]+)\\]/", $template, $umatches); preg_match_all("/\\[thumb_gallery_([0-9]+)x([0-9]+)\\]/", $template, $gmatches); preg_match_all("/\\[excerpt_([0-9]+)\\]/", $template, $xmatches); preg_match_all("/\\[pdf_thumb_([0-9]+)x([0-9]+)\\]/", $template, $pmatches); $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($vars['ID']), 'full'); $vars['preview'] = $thumb['0']; $pdf = isset($vars['files'][0]) ? $vars['files'][0] : ''; $ext = explode(".", $pdf); $ext = end($ext); // Parse [pdf_thumb] tag in link/page template if (strpos($template, 'pdf_thumb')) { if ($ext == 'pdf') { $vars['pdf_thumb'] = "<img alt='{$vars['title']}' src='" . wpdm_pdf_thumbnail($pdf, $vars['ID']) . "' />"; } else { $vars['pdf_thumb'] = $vars['preview'] != '' ? "<img alt='{$vars['title']}' src='{$vars['preview']}' />" : ""; } } // Parse [pdf_thumb_WxH] tag in link/page template foreach ($pmatches[0] as $nd => $scode) { $keys[] = $scode; $imsrc = wpdm_dynamic_thumb(wpdm_pdf_thumbnail($pdf, $vars['ID']), array($pmatches[1][$nd], $pmatches[2][$nd])); $values[] = $imsrc != '' ? "<img src='" . $imsrc . "' alt='{$vars['title']}' />" : ''; } // Parse [file_type] tag in link/page template if (strpos($template, 'file_type')) { $vars['file_types'] = self::fileTypes($vars['ID'], false); $vars['file_type_icons'] = self::fileTypes($vars['ID']); } foreach ($matches[0] as $nd => $scode) { $keys[] = $scode; $imsrc = wpdm_dynamic_thumb($vars['preview'], array($matches[1][$nd], $matches[2][$nd])); $values[] = $vars['preview'] != '' ? "<img src='" . $imsrc . "' alt='{$vars['title']}' />" : ''; } foreach ($umatches[0] as $nd => $scode) { $keys[] = $scode; $values[] = $vars['preview'] != '' ? wpdm_dynamic_thumb($vars['preview'], array($umatches[1][$nd], $umatches[2][$nd])) : ''; } foreach ($gmatches[0] as $nd => $scode) { $keys[] = $scode; $values[] = wpdm_get_additional_preview_images($vars, $gmatches[1][$nd], $gmatches[2][$nd]); } foreach ($xmatches[0] as $nd => $scode) { $keys[] = $scode; $ss = substr(strip_tags($vars['description']), 0, intval($xmatches[1][$nd])); $tmp = explode(" ", substr(strip_tags($vars['description']), intval($xmatches[1][$nd]))); $bw = array_shift($tmp); $ss .= $bw; $values[] = $ss . '...'; } if ($type == 'page' && (strpos($template, '[similar_downloads]') || strpos($vars['description'], '[similar_downloads]'))) { $vars['similar_downloads'] = wpdm_similar_packages($vars, 5); } if (strpos($template, 'doc_preview')) { $vars['doc_preview'] = self::docPreview($vars); } // If need to re-process any data before fetch template $vars = apply_filters("wdm_before_fetch_template", $vars); foreach ($vars as $key => $value) { if (!is_array($value)) { $keys[] = "[{$key}]"; $values[] = $value; } } $loginform = wpdm_login_form(array('redirect' => get_permalink($vars['ID']))); $hide_all_message = get_option('__wpdm_login_form', 0) == 1 ? $loginform : stripcslashes(str_replace(array("[loginform]", "[this_url]"), array($loginform, get_permalink($vars['ID'])), get_option('wpdm_login_msg'))); if ($vars['download_link'] == 'blocked' && $type == 'link') { return ""; } if ($vars['download_link'] == 'blocked' && $type == 'page') { return get_option('wpdm_permission_msg'); } if ($vars['download_link'] == 'loginform' && $type == 'link') { return ""; } if ($vars['download_link'] == 'loginform' && $type == 'page') { return $hide_all_message; } return @str_replace($keys, $values, @stripcslashes($template)); }
function FetchTemplate($template, $vars, $type = 'link') { if ($vars['ID'] == '') { return ''; } $default['link'] = file_get_contents(dirname(__FILE__) . '/templates/link-template-default.php'); $default['popup'] = file_get_contents(dirname(__FILE__) . '/templates/page-template-default.php'); $default['page'] = file_get_contents(dirname(__FILE__) . '/templates/page-template-default.php'); $vars = wpdm_setup_package_data($vars); if ($template == '') { $template = $type == 'page' ? $vars['page_template'] : $vars['template']; } if ($template == '') { $template = $default[$type]; } if (file_exists(TEMPLATEPATH . '/' . $template)) { $template = file_get_contents(TEMPLATEPATH . '/' . $template); } else { if (file_exists(dirname(__FILE__) . '/templates/' . $template)) { $template = file_get_contents(dirname(__FILE__) . '/templates/' . $template); } else { if (file_exists(dirname(__FILE__) . '/templates/' . $template . '.php')) { $template = file_get_contents(dirname(__FILE__) . '/templates/' . $template . '.php'); } } } preg_match_all("/\\[thumb_([0-9]+)x([0-9]+)\\]/", $template, $matches); preg_match_all("/\\[thumb_url_([0-9]+)x([0-9]+)\\]/", $template, $umatches); preg_match_all("/\\[thumb_gallery_([0-9]+)x([0-9]+)\\]/", $template, $gmatches); preg_match_all("/\\[excerpt_([0-9]+)\\]/", $template, $xmatches); //preg_match_all("/\[download_link ([^\]]+)\]/", $template, $cmatches); $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($vars['ID']), 'full'); $vars['preview'] = $thumb['0']; if (isset($vars['quota']) && $vars['quota'] == 0) { $vars['quota'] = __('Unlimited', 'wpdm'); } foreach ($matches[0] as $nd => $scode) { $keys[] = $scode; $values[] = $vars['preview'] != '' ? "<img src='" . wpdm_dynamic_thumb($vars['preview'], array($matches[1][$nd], $matches[2][$nd])) . "' alt='{$vars['title']}' />" : ''; } foreach ($umatches[0] as $nd => $scode) { $keys[] = $scode; $values[] = $vars['preview'] != '' ? wpdm_dynamic_thumb($vars['preview'], array($umatches[1][$nd], $umatches[2][$nd])) : ''; } foreach ($gmatches[0] as $nd => $scode) { $keys[] = $scode; $values[] = wpdm_get_additional_preview_images($vars, $gmatches[1][$nd], $gmatches[2][$nd]); } foreach ($xmatches[0] as $nd => $scode) { $keys[] = $scode; $ss = substr(strip_tags($vars['description']), 0, intval($xmatches[1][$nd])); $tmp = explode(" ", substr(strip_tags($vars['description']), intval($xmatches[1][$nd]))); $bw = array_shift($tmp); $ss .= $bw; $values[] = $ss . '...'; } if ($type == 'page' && (strpos($template, '[similar_downloads]') || strpos($vars['description'], '[similar_downloads]'))) { $vars['similar_downloads'] = wpdm_similar_packages($vars, 5); } foreach ($vars as $key => $value) { $keys[] = "[{$key}]"; $values[] = $value; } if ($vars['download_link'] == 'blocked' && $type == 'link') { return ""; } if ($vars['download_link'] == 'blocked' && $type == 'page') { return get_option('wpdm_permission_msg'); } //if($vars['password']=='') $template = $template."<script>jQuery('body').on('click','.wpdm-link-tpl', function(){ var durl = jQuery(this).data('durl'); location.href=durl; });</script>"; $data = @str_replace($keys, $values, @stripcslashes($template)); $data = str_replace(array("\r", "\n"), "", $data); return $data; }
/** * @param $pid * @param $w * @param $h * @param bool $echo * @return string * @usage Generates thumbnail html from PDF file attached with a Package. [ From v4.1.3 ] */ function wpdm_pdf_preview($pid, $w, $h, $echo = true) { $post = get_post($pid); $files = get_post_meta($pid, '__wpdm_files', true); $pdf = $files[0]; $ext = explode(".", $pdf); $ext = end($ext); $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($pid), 'full'); $preview = $thumb['0']; if ($ext == 'pdf') { $pdf_thumb = wpdm_pdf_thumbnail($pdf, $pid); } else { $pdf_thumb = $preview; } $imsrc = wpdm_dynamic_thumb($pdf_thumb, array($w, $h)); if (!$echo) { return "<img src='{$imsrc}' alt='{$post->post_title}'/>"; } echo "<img src='{$imsrc}' alt='{$post->post_title}'/>"; }
function wpdm_get_additional_preview_images($file, $w, $h) { $file['additional_previews'] = maybe_unserialize(get_post_meta($file['ID'], '__wpdm_additional_previews', true)); $k = 0; $img = ''; $id = uniqid(); if ($file['additional_previews']) { foreach ($file['additional_previews'] as $p) { ++$k; $img .= "<a href='{$p}' id='more_previews_a_{$k}' class='more_previews_a imgpreview wpdm-lightbox' data-lightbox-gallery='gallery_{$id}' rel='previews' ><img id='more_previews_{$k}' class='more_previews img-rounded' src='" . wpdm_dynamic_thumb($p, array($w, $h)) . "'/></a>"; } } $js = ""; // "<script>jQuery(function($){ $('a.more_previews_a').nivoLightbox(); });</script>"; return $img . $js; }
function wpdm_slider($params = array()) { $ids = array(); $n = 0; extract($params); $ids = explode(",", $ids); ob_start(); ?> <div class="w3eden"> <div id="myCarousel" class="carousel slide"> <!--<ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol>--> <!-- Carousel items --> <div class="carousel-inner"> <?php foreach ($ids as $id) { $file = wpdm_get_package($id); ?> <div class="<?php if ($n++ == 0) { echo 'active'; } ?> item"> <img alt="" src='<?php echo wpdm_dynamic_thumb($file['preview'], array(1000, 400)); ?> '/> <div class="carousel-caption"> <div class="media"> <div class="media-body"> <h4><?php echo $file['title']; ?> </h4> <p><?php echo substr(strip_tags($file['post_content']), 0, 100); ?> ...</p> <a class="btn btn-bordered btn-gpls" style="color: #fff" href="<?php echo $file['page_url']; ?> ">More Details</a> </div> </div> </div> </div> <?php } ?> </div> <a class="carousel-control left" href="#myCarousel" data-slide="prev"><span class="icon icon-chevron-left"></span></a> <a class="carousel-control right" href="#myCarousel" data-slide="next"><span class="icon icon-chevron-right"></span></a> </div> </div> <style> .carousel-inner { border-radius: 6px !important; } .carousel-control { border-radius: 0 !important; border: 0 !important; background: transparent !important; padding: 10px 5px 18px 5px; } .carousel-control .icon { top: 47%; position: absolute; } .carousel-caption { background: rgba(0, 0, 0, 0.6); border-radius: 0 !important; bottom: 0 !important; color: #FFFFFF; padding-top: 20px; position: absolute; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); width: 100%; z-index: 10; left: 0 !important; } .btn-bordered { background: transparent !important; color: #ffffff !important; border: 1px solid rgba(255, 255, 255, 0.7) !important; border-radius: 5px !important; } </style> <script> jQuery(function ($) { $('.carousel').carousel(); }); </script> <?php $data = ob_get_contents(); ob_clean(); return $data; }
function Prepare($ID) { if (isset($this->PackageData['formatted'])) { return $this; } $vars = get_post($ID, ARRAY_A); $vars['title'] = stripcslashes($vars['post_title']); $vars['description'] = stripcslashes($vars['post_content']); $vars['description'] = wpautop(stripslashes($vars['description'])); $vars['description'] = do_shortcode(stripslashes($vars['description'])); $vars['excerpt'] = stripcslashes(strip_tags($vars['post_excerpt'])); $src = wp_get_attachment_image_src(get_post_thumbnail_id($vars['ID']), 'full', false, ''); $vars['preview'] = $src['0']; $vars['create_date'] = isset($vars['post_date']) ? date_i18n(get_option('date_format'), strtotime($vars['post_date'])) : ''; $vars['categories'] = get_the_term_list($vars['ID'], 'wpdmcategory', '', ', ', ''); //print_r($vars); die(); $data = wpdm_custom_data($vars['ID']); $vars = array_merge($vars, $data); $vars['update_date'] = isset($vars['post_modified']) ? date_i18n(get_option('date_format'), strtotime($vars['post_modified'])) : ''; //$vars['description'] = apply_filters('the_content',stripslashes($wpdm_package['description'])); $vars['files'] = get_post_meta($vars['ID'], '__wpdm_files', true); $vars['file_count'] = count($vars['files']); $vars['file_list'] = wpdm_package_file_list($vars); $vars['file_list_extended'] = wpdm_package_file_list_alt($vars); $vars['link_label'] = isset($vars['link_label']) ? $vars['link_label'] : __('Download', 'wpdmpro'); $vars['page_link'] = "<a href='" . get_permalink($vars['ID']) . "'>{$vars['title']}</a>"; $vars['page_url'] = get_permalink($vars['ID']); $tags = get_the_tags($vars['ID']); $taghtml = ""; if (is_array($tags)) { foreach ($tags as $tag) { $taghtml .= "<a class='btn btn-default btn-xs' style='margin:0 5px 5px 0' href=\"" . get_tag_link($tag->term_id) . "\"><i class='fa fa-tag'></i> " . $tag->name . "</a> "; } } $vars['tags'] = $taghtml; if (count($vars['files']) > 1) { $vars['file_ext'] = 'zip'; } if (is_array($vars['files']) && count($vars['files']) == 1) { $tmpdata = explode(".", $vars['files'][0]); $vars['file_ext'] = end($tmpdata); } $vars['file_size'] = wpdm_package_size($vars['ID']); //$vars['create_date'] = $vars['create_date']?@date(get_option('date_format'),$vars['create_date']):@date(get_option('date_format'),get_wpdm_meta($vars['ID'],'create_date')); //$vars['update_date'] = $vars['update_date']?@date(get_option('date_format'),$vars['update_date']):@date(get_option('date_format'),get_wpdm_meta($vars['ID'],'update_date')); $type = get_post_type() != 'wpdmpro' || !array_key_exists(get_option('__wpdm_purl_base', 'download'), $wp_query->query_vars) ? 'link' : 'page'; $vars['audio_player'] = wpdm_audio_playlist($vars, true); $vars['audio_player_single'] = wpdm_audio_player($vars, true); //$vars['quick_download'] = wpdm_ddl_button($vars,$type=='link'); //$vars['email_download'] = wpdm_email_button($vars,$type=='link'); if (!isset($vars['icon']) || $vars['icon'] == '') { if (is_array($vars['files'])) { $ifn = @end($vars['files']); $ifn = @explode('.', $ifn); $ifn = @end($ifn); } else { $ifn = '_blank'; } $vars['icon'] = '<img class="wpdm_icon" src="' . plugins_url('download-manager/file-type-icons/') . (@count($vars['files']) <= 1 ? $ifn : 'zip') . '.png" onError=\'this.src="' . plugins_url('download-manager/file-type-icons/_blank.png') . '";\' />'; } else { if (!strpos($vars['icon'], '://')) { $vars['icon'] = '<img class="wpdm_icon" src="' . plugins_url($vars['icon']) . '" />'; } else { if (!strpos($vars['icon'], ">")) { $vars['icon'] = '<img class="wpdm_icon" src="' . $vars['icon'] . '" />'; } } } if (isset($vars['preview']) && $vars['preview'] != '') { $vars['thumb'] = "<img title='' src='" . wpdm_dynamic_thumb($vars['preview'], array(400, 300)) . "'/>"; } else { $vars['thumb'] = $vars['thumb_page'] = $vars['thumb_gallery'] = $vars['thumb_widget'] = ""; } $k = 1; $vars['additional_previews'] = isset($vars['more_previews']) ? $vars['more_previews'] : array(); $img = "<img id='more_previews_{$k}' title='' class='more_previews' src='" . wpdm_dynamic_thumb($vars['preview'], array(575, 170)) . "'/>\n"; $tmb = "<a href='#more_previews_{$k}' class='spt'><img title='' src='" . wpdm_dynamic_thumb($vars['preview'], array(100, 45)) . "'/></a>\n"; //WPMS fix global $blog_id; if (defined('MULTISITE')) { $vars['thumb'] = str_replace(home_url('/files'), ABSPATH . 'wp-content/blogs.dir/' . $blog_id . '/files', $vars['thumb']); } if (!isset($vars['download_link_called'])) { $tmpvar = DownloadLink($vars, 0, array('btnclass' => '[btnclass]')); $tmpvar1 = DownloadLink($vars, 1); $vars['download_link'] = $tmpvar; $vars['download_link_extended'] = $tmpvar1; $vars['download_link_called'] = 1; } $vars = apply_filters("wdm_before_fetch_template", $vars); if (!isset($vars['formatted'])) { $vars['formatted'] = 0; } ++$vars['formatted']; $this->PackageData = $vars; return $this; }
/** * @usage Callback function for [file_list_extended] tag * @param $file * @return string * @usage Generate file list with preview */ public static function Box($file) { global $current_user; $file['files'] = maybe_unserialize($file['files']); $fhtml = ''; $idvdl = \WPDM\Package::isSingleFileDownloadAllowed($file['ID']); //isset($file['individual_file_download']) ? $file['individual_file_download'] : 0; $pd = isset($file['publish_date']) && $file['publish_date'] != "" ? strtotime($file['publish_date']) : 0; $xd = isset($file['expire_date']) && $file['expire_date'] != "" ? strtotime($file['expire_date']) : 0; $cur = is_user_logged_in() ? $current_user->roles : array('guest'); $_SESSION['wpdmfilelistcd_' . $file['ID']] = 1; if ($xd > 0 && $xd < time() || $pd > 0 && $pd > time()) { $idvdl = 0; } $dir = isset($file['package_dir']) ? $file['package_dir'] : ''; $dfiles = array(); if ($dir != '') { $dfiles = wpdm_get_files($dir, false); } $file['access'] = wpdm_allowed_roles($file['ID']); if (count($file['files']) > 0 || count($dfiles) > 0) { $fileinfo = isset($file['fileinfo']) ? $file['fileinfo'] : array(); $pwdlock = isset($file['password_lock']) ? $file['password_lock'] : 0; //Check if any other lock option apllied for this package $olock = wpdm_is_locked($file['ID']) ? 1 : 0; $swl = 0; if (!isset($file['quota']) || $file['quota'] <= 0) { $file['quota'] = 9999999999999; } if (is_user_logged_in()) { $cur[] = 'guest'; } if (!isset($file['access']) || count($file['access']) == 0 || !wpdm_user_has_access($file['ID']) || wpdm_is_download_limit_exceed($file['ID']) || $file['quota'] <= $file['download_count']) { $olock = 1; } $pwdcol = $dlcol = ''; if ($pwdlock && $idvdl) { $pwdcol = "<th>" . __("Password", "wpdmpro") . "</th>"; } if ($idvdl && ($pwdlock || !$olock)) { $dlcol = "<th align=center>" . __("Download", "wpdmpro") . "</th>"; $swl = 1; } $allfiles = is_array($file['files']) ? $file['files'] : array(); //$allfiles = array_merge($allfiles, $dfiles); $fhtml = "<div class='row' id='xfilelist'>"; if (is_array($allfiles)) { foreach ($allfiles as $fileID => $sfile) { $fhtml .= "<div class='col-md-4 col-sm-6 col-xs-6'><div class='panel panel-default'>"; $ind = \WPDM_Crypt::Encrypt($sfile); if (!isset($fileinfo[$sfile]) || !@is_array($fileinfo[$sfile])) { $fileinfo[$sfile] = array(); } if (!@is_array($fileinfo[$fileID])) { $fileinfo[$fileID] = array(); } $filePass = isset($fileinfo[$sfile]['password']) ? $fileinfo[$sfile]['password'] : (isset($fileinfo[$fileID]['password']) ? $fileinfo[$fileID]['password'] : ''); $fileTitle = isset($fileinfo[$sfile]['title']) && $fileinfo[$sfile]['title'] != '' ? $fileinfo[$sfile]['title'] : (isset($fileinfo[$fileID]['title']) && $fileinfo[$fileID]['title'] != '' ? $fileinfo[$fileID]['title'] : preg_replace("/([0-9]+)_/", "", wpdm_basename($sfile))); if ($filePass == '' && $pwdlock) { $filePass = $file['password']; } $fhtml .= "<div class='panel-heading ttip' title='{$fileTitle}'>{$fileTitle}</div>"; $imgext = array('png', 'jpg', 'jpeg', 'gif'); $ext = explode(".", $sfile); $ext = end($ext); $ext = strtolower($ext); $filepath = file_exists($sfile) ? $sfile : UPLOAD_DIR . $sfile; $thumb = ""; if ($ext == '' || !file_exists(WPDM_BASE_DIR . 'assets/file-type-icons/' . $ext . '.png')) { $ext = '_blank'; } if (in_array($ext, $imgext)) { $thumb = wpdm_dynamic_thumb($filepath, array(88, 88)); } if ($thumb) { $fhtml .= "<div class='panel-body text-center'><img class='file-thumb' src='{$thumb}' alt='{$fileTitle}' /></div><div class='panel-footer footer-info'>" . wpdm_file_size($sfile) . "</div><div class='panel-footer'>"; } else { $fhtml .= "<div class='panel-body text-center'><img class='file-ico' src='" . WPDM_BASE_URL . 'assets/file-type-icons/' . $ext . '.png' . "' alt='{$fileTitle}' /></div><div class='panel-footer footer-info'>" . wpdm_file_size($sfile) . "</div><div class='panel-footer'>"; } if ($swl) { if ($filePass != '' && $pwdlock) { $fhtml .= "<div class='input-group'><input onkeypress='jQuery(this).removeClass(\"input-error\");' size=10 type='password' value='' id='pass_{$file['ID']}_{$ind}' placeholder='Password' name='pass' class='form-control input-sm inddlps' />"; } if ($filePass != '' && $pwdlock) { $fhtml .= "<span class='input-group-btn'><button class='inddl btn btn-primary btn-sm' file='{$sfile}' rel='" . wpdm_download_url($file) . "&ind=" . $ind . "' pass='******'ID']}_{$ind}'><i class='fa fa-download'></i></button></span></div>"; } else { $fhtml .= "<a class='btn btn-primary btn-sm btn-block' href='" . wpdm_download_url($file) . "&ind=" . $ind . "'><span class='pull-left'><i class='fa fa-download'></i></span> " . __("Download", "wpdmpro") . "</a>"; } } $fhtml .= "</div></div></div>"; } } if (is_array($dfiles)) { foreach ($dfiles as $ind => $sfile) { $ind = \WPDM_Crypt::Encrypt($sfile); $fhtml .= "<div class='col-md-4 col-sm-6 col-xs-6'><div class='panel panel-default'>"; if (!isset($fileinfo[$sfile]) || !@is_array($fileinfo[$sfile])) { $fileinfo[$sfile] = array(); } if (!isset($fileinfo[$sfile]['password'])) { $fileinfo[$sfile]['password'] = ""; } if ($fileinfo[$sfile]['password'] == '' && $pwdlock) { $fileinfo[$sfile]['password'] = $file['password']; } $ttl = isset($fileinfo[$sfile]['title']) && $fileinfo[$sfile]['title'] != "" ? $fileinfo[$sfile]['title'] : preg_replace("/([0-9]+)_/", "", wpdm_basename($sfile)); $cttl = is_dir($sfile) ? "<a href='#' class='wpdm-indir' data-dir='{$ttl}' data-pid='{$file['ID']}'>{$ttl}/</a>" : $ttl; $fhtml .= "<div class='panel-heading ttip' title='{$ttl}'>{$cttl}</div>"; $imgext = array('png', 'jpg', 'jpeg', 'gif'); $ext = explode(".", $sfile); $ext = end($ext); $ext = strtolower($ext); if (is_dir($sfile)) { $ext = 'folder'; } $filepath = file_exists($sfile) ? $sfile : UPLOAD_DIR . $sfile; $thumb = ""; $showt = 1; if (in_array($ext, $imgext) && apply_filters('file_list_extended_show_thumbs', $showt)) { $thumb = wpdm_dynamic_thumb($filepath, array(88, 88)); } $fticon = WPDM_BASE_URL . 'assets/file-type-icons/' . $ext . '.png'; if (!file_exists(WPDM_BASE_DIR . 'assets/file-type-icons/' . $ext . '.png')) { $fticon = WPDM_BASE_URL . 'assets/file-type-icons/ini.png'; } if ($thumb) { $fhtml .= "<div class='panel-body text-center'><img class='file-thumb' src='{$thumb}' alt='{$ttl}' /></div><div class='panel-footer footer-info'>" . wpdm_file_size($sfile) . "</div><div class='panel-footer'>"; } else { $fhtml .= "<div class='panel-body text-center'><img class='file-ico' src='" . $fticon . "' alt='{$ttl}' /></div><div class='panel-footer footer-info'>" . wpdm_file_size($sfile) . "</div><div class='panel-footer'>"; } if ($swl) { $fileinfo[$sfile]['password'] = $fileinfo[$sfile]['password'] == '' ? $file['password'] : $fileinfo[$sfile]['password']; if ($fileinfo[$sfile]['password'] != '' && $pwdlock && !is_dir($sfile)) { $fhtml .= "<div class='input-group'><input onkeypress='jQuery(this).removeClass(\"input-error\");' size=10 type='password' value='' id='pass_{$file['ID']}_{$ind}' placeholder='Password' name='pass' class='form-control input-sm inddlps' />"; } if ($fileinfo[$sfile]['password'] != '' && $pwdlock && !is_dir($sfile)) { $fhtml .= "<span class='input-group-btn'><button class='inddl btn btn-primary btn-sm' file='{$sfile}' rel='" . wpdm_download_url($file) . "&ind=" . $ind . "' pass='******'ID']}_{$ind}'><i class='fa fa-download'></i></button></span></div>"; } else { if (!is_dir($sfile)) { $fhtml .= "<a class='btn btn-primary btn-sm btn-block' href='" . wpdm_download_url($file) . "&ind=" . $ind . "'><span class='pull-left'><i class='fa fa-download'></i></span> " . __("Download", "wpdmpro") . "</a>"; } else { $fhtml .= "<a class='btn btn-primary btn-sm btn-block wpdm-indir' href='#' data-dir='{$ttl}' data-pid='{$file['ID']}'><span class='pull-left'><i class='fa fa-folder'></i></span> " . __("Browse", "wpdmpro") . "</a>"; } } } $fhtml .= "</div></div></div>"; } } $fhtml .= "</div>"; $siteurl = home_url('/'); $fhtml .= "<script type='text/javascript' language='JavaScript'> jQuery('.inddl').click(function(){ var tis = this; jQuery.post('{$siteurl}',{wpdmfileid:'{$file['ID']}',wpdmfile:jQuery(this).attr('file'),actioninddlpvr:1,filepass:jQuery(jQuery(this).attr('pass')).val()},function(res){ res = res.split('|'); var ret = res[1]; if(ret=='error') jQuery(jQuery(tis).attr('pass')).addClass('input-error'); if(ret=='ok') location.href=jQuery(tis).attr('rel')+'&_wpdmkey='+res[2];});}); </script> "; } return $fhtml; }
++$file_index; if (!isset($fileinfo[$value]) || !@is_array($fileinfo[$value])) { $fileinfo[$value] = array('title' => '', 'password' => ''); } $svalue = $value; if (strlen($value) > 50) { $svalue = substr($value, 0, 23) . "..." . substr($value, strlen($value) - 27); } $imgext = array('png', 'jpg', 'jpeg', 'gif'); $ext = explode(".", $value); $ext = end($ext); $ext = strtolower($ext); $filepath = file_exists($value) ? $value : UPLOAD_DIR . $value; $thumb = ""; if (in_array($ext, $imgext)) { $thumb = wpdm_dynamic_thumb($filepath, array(48, 48)); } if ($ext == '' || !file_exists(WPDM_BASE_DIR . 'assets/file-type-icons/' . $ext . '.png')) { $ext = '_blank'; } ?> <div class="cfile"> <div class="panel panel-default"> <input class="faz" type="hidden" value="<?php echo $value; ?> " name="file[files][<?php echo $id; ?> ]"> <div class="panel-heading"><button type="button" class="btn btn-xs btn-default pull-right" rel="del"><i class="fa fa-times text-danger"></i></button> <span title="<?php
function wpdm_get_additional_preview_images($file, $w, $h) { $file['additional_previews'] = maybe_unserialize(get_post_meta($file['ID'], '__wpdm_additional_previews', true)); $k = 0; $img = ''; if ($file['additional_previews']) { foreach ($file['additional_previews'] as $p) { ++$k; $img .= "<a href='{$p}' id='more_previews_a_{$k}' class='more_previews_a imgpreview' rel='previews' ><img id='more_previews_{$k}' class='more_previews img-rounded' src='" . wpdm_dynamic_thumb($p, array($w, $h)) . "'/></a>"; } } return $img; }
function FetchTemplate($template, $vars, $type = 'link') { if (!isset($vars['ID']) || intval($vars['ID']) < 1) { return ''; } $default['link'] = file_get_contents(dirname(__FILE__) . '/templates/link-template-default.php'); $default['popup'] = file_get_contents(dirname(__FILE__) . '/templates/page-template-default.php'); $default['page'] = file_get_contents(dirname(__FILE__) . '/templates/page-template-default.php'); $vars = wpdm_setup_package_data($vars); if ($template == '') { $template = $type == 'page' ? $vars['page_template'] : $vars['template']; } if ($template == '') { $template = $default[$type]; } if (file_exists(TEMPLATEPATH . '/' . $template)) { $template = file_get_contents(TEMPLATEPATH . '/' . $template); } else { if (file_exists(dirname(__FILE__) . '/templates/' . $template)) { $template = file_get_contents(dirname(__FILE__) . '/templates/' . $template); } else { if (file_exists(dirname(__FILE__) . '/templates/' . $template . '.php')) { $template = file_get_contents(dirname(__FILE__) . '/templates/' . $template . '.php'); } else { if (file_exists(dirname(__FILE__) . '/templates/' . $type . "-template-" . $template . '.php')) { $template = file_get_contents(dirname(__FILE__) . '/templates/' . $type . "-template-" . $template . '.php'); } } } } $templates = maybe_unserialize(get_option("_fm_link_templates", true)); if (isset($templates[$template]) && isset($templates[$template]['content'])) { $template = $templates[$template]['content']; } preg_match_all("/\\[cf ([^\\]]+)\\]/", $template, $cfmatches); preg_match_all("/\\[thumb_([0-9]+)x([0-9]+)\\]/", $template, $matches); preg_match_all("/\\[thumb_url_([0-9]+)x([0-9]+)\\]/", $template, $umatches); preg_match_all("/\\[thumb_gallery_([0-9]+)x([0-9]+)\\]/", $template, $gmatches); preg_match_all("/\\[excerpt_([0-9]+)\\]/", $template, $xmatches); //preg_match_all("/\[download_link ([^\]]+)\]/", $template, $cmatches); $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($vars['ID']), 'full'); $vars['preview'] = $thumb['0']; $vars['wpdm_custom_field_table'] = wpdm_custom_fields_table($vars); foreach ($matches[0] as $nd => $scode) { $keys[] = $scode; $imsrc = wpdm_dynamic_thumb($vars['preview'], array($matches[1][$nd], $matches[2][$nd])); $values[] = $vars['preview'] != '' ? "<img src='" . $imsrc . "' alt='{$vars['title']}' />" : ''; } foreach ($umatches[0] as $nd => $scode) { $keys[] = $scode; $values[] = $vars['preview'] != '' ? wpdm_dynamic_thumb($vars['preview'], array($umatches[1][$nd], $umatches[2][$nd])) : ''; } foreach ($gmatches[0] as $nd => $scode) { $keys[] = $scode; $values[] = wpdm_get_additional_preview_images($vars, $gmatches[1][$nd], $gmatches[2][$nd]); } /** * Depracated for premium package add-on * foreach ($cmatches[0] as $nd => $scode) { * $keys[] = $scode; * //die($vars['download_link']) ; * $tmpvar = explode(".", $cmatches[1][$nd]); * if (in_array(end($tmpvar), array('png', 'jpg', 'jpeg', 'gif'))) { * $cmatches[1][$nd] = trim($cmatches[1][$nd]); * $vars['link_label'] = "<img class='wpdm-thumb' src='{$cmatches[1][$nd]}' alt='" . __('Download', 'wpdmpro') . "' />"; * $values[] = DownloadLink($vars, 0); * } //preg_replace("/>.+?<\/a>/","/><img src='".$cmatches[1][$nd].'"/></a>', $vars['download_link']); * else * $values[] = str_replace('[btnclass]', $cmatches[1][$nd], $vars['download_link']); * } */ foreach ($xmatches[0] as $nd => $scode) { $keys[] = $scode; $ss = substr(strip_tags($vars['description']), 0, intval($xmatches[1][$nd])); $tmp = explode(" ", substr(strip_tags($vars['description']), intval($xmatches[1][$nd]))); $bw = array_shift($tmp); $ss .= $bw; $values[] = $ss . '...'; } if ($type == 'page' && (strpos($template, '[similar_downloads]') || strpos($vars['description'], '[similar_downloads]'))) { $vars['similar_downloads'] = wpdm_similar_packages($vars, 5); } $vars['doc_preview'] = wpdm_doc_preview($vars); foreach ($vars as $key => $value) { $keys[] = "[{$key}]"; $values[] = $value; } if ($vars['download_link'] == 'blocked' && $type == 'link') { return ""; } if ($vars['download_link'] == 'blocked' && $type == 'page') { return get_option('wpdm_permission_msg'); } if ($vars['download_link'] == 'loginform' && $type == 'link') { return ""; } if ($vars['download_link'] == 'loginform' && $type == 'page') { return wpdm_loginform(); } return @str_replace($keys, $values, @stripcslashes($template)); }