public function sc($atts) { if (isset($atts['style'])) { $atts['theme'] = $atts['style']; } $get = new fileaway_definitions(); extract($get->pathoptions); extract($this->correctatts(wp_parse_args($atts, $this->fileaway), $this->shortcodes['fileaway'], 'fileaway')); if ($devices == 'mobile' && !$get->is_mobile) { return; } elseif ($devices == 'desktop' && $get->is_mobile) { return; } if (!fileaway_utility::visibility($hidefrom, $showto)) { return; } if ($this->op['javascript'] == 'footer') { $GLOBALS['fileaway_add_scripts'] = true; } if ($this->op['stylesheet'] == 'footer') { $GLOBALS['fileaway_add_styles'] = true; } include fileaway_dir . '/lib/inc/inc.declarations.php'; include fileaway_dir . '/lib/inc/inc.base.php'; extract(fileaway_utility::dynamicpaths($dir, $playbackpath)); if ($debug == 'on' && $logged_in) { return $this->debug($rootpath . $dir); } if (isset($atts['tutorials'])) { $dir = fileaway_dir . '/lib/tts'; } if (!is_dir("{$dir}") && $makedir && (!$private_content || $private_content && $logged_in && stripos($dir, 'fa-nullmeta') === false)) { if (mkdir($rootpath . $dir, 0775, true)) { fileaway_utility::indexmulti($rootpath . $dir, $chosenpath); } } if (!is_dir("{$dir}")) { return; } $start = "{$dir}"; $uid = rand(0, 9999); $name = $name ? $name : "ssfa-meta-container-{$uid}"; $manager = $playback ? false : $manager; if ($manager) { include fileaway_dir . '/lib/inc/inc.manager-access.php'; } if ($manager) { $encryption = false; } if ($metadata) { global $wpdb; } if ($type != 'table') { $bulkdownload = false; } $limit = $manager ? false : $limit; $bulkclass = $bulkdownload ? 'bd-table' : ($manager ? 'mngr-table' : null); include fileaway_dir . '/lib/inc/inc.styles.php'; $fadeit = $fadein ? $fadein == 'opacity' ? 'opacity:0;' : 'display:none;' : null; if ($fadein) { $fadescript = $fadein == 'opacity' ? '.animate({opacity:"1"}, ' . $fadetime . ');' : '.fadeIn(' . $fadetime . ');'; $thefiles .= '<script> jQuery(document).ready(function($){ setTimeout(function(){ $("div#' . $name . '")' . $fadescript . ' }, 1000); }); </script>'; } $mobileclass = $get->is_mobile ? 'ssfa-mobile' : null; $flightbox_nonce = !empty($flightbox) ? 'data-fbn="' . wp_create_nonce('fileaway-flightbox-nonce') . '"' : ''; $flightbox_class = !empty($flightbox) ? 'flightbox-parent' : ''; $thefiles .= "{$clearfix}<div id='{$name}' class='ssfa-meta-container {$flightbox_class} {$mobileclass} {$class}' data-uid='{$uid}' {$flightbox_nonce} style='margin: 10px 0 20px; {$fadeit} {$howshouldiputit}'>"; if ($directories) { $recursive = false; include fileaway_dir . '/lib/inc/inc.open-drawer.php'; } if ($showrss) { include fileaway_dir . '/lib/inc/inc.rss-link.php'; } if ($directories) { include fileaway_dir . '/lib/inc/inc.directories-nav.php'; } include fileaway_dir . '/lib/inc/inc.stats-redirects.php'; include fileaway_dir . '/lib/inc/inc.precontent.php'; include fileaway_dir . '/lib/inc/inc.thead.php'; include fileaway_dir . '/lib/inc/inc.directories.php'; $files = $recursive ? fileaway_utility::recursefiles($dir, $onlydirs, $excludedirs) : scandir($dir); $count = 0; fileaway_utility::timezone(); include fileaway_dir . '/lib/inc/inc.file-array.php'; include fileaway_dir . '/lib/inc/inc.dynamic-links.php'; $fcount = count($rawnames); if ($fcount < 1 && !$directories) { return; } if ($playback) { $GLOBALS['fileaway_playback_script'] = true; if ($playback == 'compact') { $playaway = new playaway(); } $sources = $get->filegroups['audio'][2]; $used = array(); } include fileaway_dir . '/lib/inc/inc.thumbnails-setup.php'; if (is_array($rawnames)) { include fileaway_dir . '/lib/inc/inc.sort.php'; if ($type == 'table' && !$manager && $bannerize) { include fileaway_dir . '/lib/inc/inc.bannerize.php'; } foreach ($rawnames as $k => $rawname) { if ($playback && in_array($rawname, $used) && in_array($exts[$k], $sources)) { continue; } $link = $links[$k]; $loc = $locs[$k]; $ext = $exts[$k]; $oext = $ext; $extension = strtolower($ext); $full = $fulls[$k]; $dir = $dirs[$k]; $thetime = $times[$k]; $file = $full; $dynamiclink = $dynamics[$k]; $bannerad = isset($bannerads[$k]) ? $bannerads[$k] : false; if ($s2mem) { list($trash, $s2dir) = explode('s2member-files', $dir); $s2dir = trim($s2dir, '/'); $s2dir = $s2dir == '' ? $s2dir : $s2dir . '/'; } if ($onlydirs && is_array($onlydirs)) { foreach ($onlydirs as $only) { $keeper = 0; if (strpos("{$dir}", "{$only}") !== false) { $keeper = 1; break; } } if (!$keeper) { continue; } } if ($excludedirs && is_array($excludedirs)) { foreach ($excludedirs as $ex) { if (strpos("{$dir}", "{$ex}") !== false) { continue 2; } } } include fileaway_dir . '/lib/inc/inc.prettify.php'; if (!$dynamiclink && (is_dir($dir . '/' . $file) || $thename == '')) { continue; } $link = $encryption && !$dynamiclink && !$bannerad ? $encrypt->url($rootpath . $dir . '/' . $file) : $link; include fileaway_dir . '/lib/inc/inc.thumbnails.php'; include fileaway_dir . '/lib/inc/inc.colors.php'; $datemodified = $type != 'table' && $mod == 'yes' ? "<div class='ssfa-datemodified'>" . sprintf(_x('Last modified %s at %s', 'For List Types: *Date* at *Time*', 'file-away'), $date, $time) . "</div>" : null; $listfilesize = $type != 'table' && $size != 'no' ? $theme == 'ssfa-minimal-list' ? "<span class='ssfa-listfilesize'>({$fsize})</span>" : "<span class='ssfa-listfilesize'>{$fsize}</span>" : null; $link = $s2mem && !$manager ? $url . '/?s2member_file_download=' . $s2dir . $file . $s2skip : $link; $fulllink = 'href="' . $link . '"'; $redirect = $dynamiclink || $bannerad ? false : $redirect; $statstatus = $stats && !$dynamiclink && !$bannerad ? 'true' : 'false'; $fulllink = $redirect ? 'href="' . $this->op['redirect'] . '"' : $fulllink; include fileaway_dir . '/lib/inc/inc.icons.php'; $linktype = $s2mem || $encryption ? '' : $linktype; $linktype = $dynamiclink || $redirect ? 'target="_blank"' : $linktype; if ($flightbox && !$bannerad && !fileaway_utility::startswith($file, '_thumb_')) { include fileaway_dir . '/lib/inc/inc.flightbox.php'; } $audiocorrect = null; if ($playback) { include fileaway_dir . '/lib/inc/inc.playback.php'; } else { $player = null; $players = null; } $thename = $prettify ? $thename : fileaway_utility::strtotitle($thename); $thename = "<span class='ssfa-filename' {$audiocorrect}>" . $thename . "</span>"; $count += 1; if ($nolinks && !$dynamiclink) { $nolinkslist = "<a id='ssfa-{$uid}-{$count}' href='javascript:' class='{$display}{$noicons}{$colors}' style='cursor:default'>"; $nolinkstable = "<a id='ssfa-{$uid}-{$count}' href='javascript:' class='{$colors}' style='cursor:default'>"; $players = null; } else { $nolinkslist = "<a id='ssfa-{$uid}-{$count}' class='{$display}{$noicons}{$colors}' {$fulllink} {$linktype} data-stat='{$statstatus}'>"; $nolinkstable = "<a id='ssfa-{$uid}-{$count}' class='{$colors}' {$fulllink} {$linktype} data-stat='{$statstatus}'>"; } if (!$type || $type != 'table') { $thefiles .= "{$nolinkslist}" . "<div class='ssfa-listitem {$ellipsis}'>" . "<span class='ssfa-topline'>{$icon} {$thename} {$listfilesize}</span> " . "{$datemodified}" . "</div>" . "</a>"; } elseif ($type == 'table' && $bannerad) { $src = str_replace($rootpath . $dir, rtrim($url, '/') . '/' . $dir, $rootpath . $dir . '/' . $file); $thefiles .= "<tr id='ssfa-banner-{$uid}-{$count}' class='fileaway-dynamic fileaway-banner'>" . "<td id='filetype-ssfa-file-{$uid}-{$count}' colspan='100' class='ssfa-banner {$theme}-first-column'>" . "<a href=\"{$link}\" rel='nofollow' target='_blank'><img src=\"{$src}\" style='width:100%; border:0;'></a>" . "</td>" . "</tr>"; } elseif ($type == 'table') { $oext = $manager || $bulkdownload ? 'data-ext="' . $oext . '"' : null; $filepath = $manager || $bulkdownload ? 'data-path="' . $dir . '"' : null; $oldname = $manager || $bulkdownload ? 'data-name="' . $rawname . '"' : null; $salvaged_filename = $manager ? trim($salvaged_filename) : $salvaged_filename; if ($manager && $customdata) { $fileinput = '<input id="rawname-ssfa-file-' . $uid . '-' . $count . '" type="text" value="' . $salvaged_filename . '" ' . 'style="width:80%; height:26px; font-size:12px; text-align:center; display:none">'; } elseif ($manager && !$customdata) { $fileinput = '<input id="rawname-ssfa-file-' . $uid . '-' . $count . '" type="text" value="' . $rawname . '" ' . 'style="width:80%; height:26px; font-size:12px; text-align:center; display:none">'; } else { $fileinput = null; } if ($playback && in_array($rawname, $used)) { if ($has_sample && $playback === 'compact') { $iconarea = $player; $thefinalname = $thename; } elseif ($has_sample && $playback === 'extended') { $iconarea = "<br>{$nolinkstable}{$icon}</a>"; $thefinalname = $thename . $players . $player; $players = null; } elseif (!$has_sample && $has_multiple) { $thefinalname = $thename; $iconarea = "<br>{$nolinkstable}{$icon}</a>"; } elseif (!$has_sample && !$has_multiple) { $iconarea = "{$nolinkstable}{$icon} {$ext}</a>"; $thefinalname = "{$nolinkstable}{$thename}</a>"; $players = null; } } else { $iconarea = "{$nolinkstable}{$icon} {$ext}</a>"; $thefinalname = "{$nolinkstable}{$thename}</a>"; $players = null; } if ($getthumb) { $iconarea = "{$nolinkstable}{$icon}</a>"; } $dynamicclass = $dynamiclink ? 'fileaway-dynamic' : ''; $thefiles .= "<tr id='ssfa-file-{$uid}-{$count}' class='{$dynamicclass}'>" . "<td id='filetype-ssfa-file-{$uid}-{$count}' class='ssfa-sorttype {$theme}-first-column' {$oext}>{$iconarea}</td>" . "<td id='filename-ssfa-file-{$uid}-{$count}' class='ssfa-sortname' {$filepath} {$oldname}>{$thefinalname}{$players} {$fileinput}</td>"; if ($customdata && is_array($customarray)) { if ($metadata) { $customdataclassname = 'fileaway-metadata'; $mdata_value = $wpdb->get_row($wpdb->prepare("SELECT metadata FROM " . $wpdb->prefix . "fileaway_metadata WHERE file = %s", $dir . '/' . $file)); if ($mdata_value) { $customvalues = unserialize($mdata_value->metadata); } else { $customvalues = explode(',', $customvalue); } } else { $customvalues = explode(',', $customvalue); $customdataclassname = 'fileaway-customdata'; } foreach ($customarray as $z => $customdatum) { if ($customdatum !== ' ') { $value = !isset($customvalues[$z]) ? '' : ($prettify ? $customvalues[$z] : fileaway_utility::strtotitle(trim($customvalues[$z]))); $custominput[$z] = $manager ? '<input class="' . $customdataclassname . '" id="customdata-' . $z . '-ssfa-file-' . $uid . '-' . $count . '" type="text" value="' . $value . '" ' . 'style="width:80%; height:26px; font-size:12px; text-align:center; display:none">' : null; $thefiles .= "<td id='customadata-cell-{$z}-ssfa-file-{$uid}-{$count}' class='ssfa-sortcustomdata'>" . "<span id='customadata-{$z}-ssfa-file-{$uid}-{$count}'>" . "{$value}" . "</span>" . trim($custominput[$z]) . "</td>"; } } } $thefiles .= $mod !== 'no' ? "<td id='mod-ssfa-file-{$uid}-{$count}' class='ssfa-sortdate' data-value='{$sortdatekey}'>{$sortdate}</td>" : null; $thefiles .= $size !== 'no' ? "<td id='size-ssfa-file-{$uid}-{$count}' class='ssfa-sortsize' data-value='{$bytes}'>{$fsize}</td>" : null; if ($manager) { $thefiles .= "<td id='manager-ssfa-file-{$uid}-{$count}' class='ssfa-sortmanager'>"; if (!$dynamiclink) { $thefiles .= "<a href='' id='rename-ssfa-file-{$uid}-{$count}'>" . __('Rename', 'file-away') . "</a><br>" . "<a href='' id='delete-ssfa-file-{$uid}-{$count}'>" . __('Delete', 'file-away') . "</a>"; } $thefiles .= "</td>"; } $thefiles .= '</tr>'; } } } $thefiles .= $type == 'table' ? '</tbody></table>' : null; if ($manager) { include fileaway_dir . '/lib/inc/inc.bulk-action-content.php'; } elseif ($bulkdownload) { include fileaway_dir . '/lib/inc/inc.bulk-download-content.php'; } $thefiles .= "</div></div>{$clearfix}"; if ($flightbox && $fb) { $thefiles .= '<script>FlightBoxes[' . $uid . '] = ' . $fb . '; '; if (count($boximages) > 0) { $thefiles .= implode(' ', $boximages); } $thefiles .= '</script>'; } date_default_timezone_set('UTC'); if ($private_content && $logged_in && $count > 0) { return $thefiles; } elseif (!$private_content && $count > 0) { return $thefiles; } elseif ($directories && (!$private_content || $logged_in && $private_content)) { return $thefiles; } else { return; } }
public function sc($atts) { $uid = rand(0, 9999); $get = new fileaway_definitions(); if (isset($atts['style'])) { $atts['theme'] = $atts['style']; } // legacy if (isset($atts['uploader']) && $atts['uploader'] === 'true') { $atts['uploader'] = 'name'; } // legacy extract($get->pathoptions); extract($this->correct(wp_parse_args($atts, $this->fileup), $this->shortcodes['fileup'])); if ($devices == 'mobile' && !$get->is_mobile) { return; } elseif ($devices == 'desktop' && $get->is_mobile) { return; } if (!fileaway_utility::visibility($hidefrom, $showto)) { return; } if ($this->op['javascript'] == 'footer') { $GLOBALS['fileaway_add_scripts'] = true; } if ($this->op['stylesheet'] == 'footer') { $GLOBALS['fileaway_add_styles'] = true; } // Build Initial Directory $base = $base == 's2member-files' ? fileaway_utility::replacefirst(WP_PLUGIN_DIR . '/s2member-files', $chosenpath, '') : $this->op['base' . $base]; $base = trim($base, '/'); $base = trim($base, '/'); $sub = $sub ? trim($sub, '/') : false; $dir = $sub ? $base . '/' . $sub : $base; extract(fileaway_utility::dynamicpaths($dir)); $dir = str_replace('//', '/', "{$dir}"); $debugpath = $chosenpath . $dir; $dir = $problemchild ? $install . $dir : $dir; if (!is_dir("{$dir}") && $makedir && (!$private_content || $private_content && $logged_in && stripos($dir, 'fa-nullmeta') === false)) { if (mkdir($rootpath . $dir, 0775, true)) { fileaway_utility::indexmulti($rootpath . $dir, $chosenpath); } } if ($private_content && !is_dir("{$dir}")) { return; } $start = "{$dir}"; if ($matchdrawer) { $fixedlocation = true; $drawerid = $matchdrawer && $matchdrawer !== 'true' ? $matchdrawer : null; include fileaway_dir . '/lib/inc/inc.open-drawer.php'; $start = "{$dir}"; } $pathparts = explode('/', $start); $basename = end($pathparts); $fixed = $start; $fixed = $fixedlocation ? $problemchild ? fileaway_utility::replacefirst($fixed, $install, '') : $fixed : null; $path = '<input type="hidden" id="ssfa-upload-actionpath-' . $uid . '" value="' . $fixed . '" data-basename="' . $basename . '" data-start="' . $start . '" />'; // File Type Permissions $types = array(); if ($filetypes) { $filetypes = preg_split('/(, |,)/', $filetypes, -1, PREG_SPLIT_NO_EMPTY); if (is_array($filetypes)) { foreach ($filetypes as $type) { $types[] = strtolower(str_replace(array('.', ' '), '', $type)); } } } if ($filegroups) { $groups = preg_split('/(, |,)/', strtolower(str_replace(' ', '', $filegroups)), -1, PREG_SPLIT_NO_EMPTY); foreach ($get->filegroups as $group => $discard) { if (in_array($group, $groups)) { $types = array_merge($types, $get->filegroups[$group][2]); } } } if (count($types) > 0) { $types = array_unique($types); asort($types); $filetypes = '["' . implode('", "', $types) . '"]'; } else { $filetypes = false; } $permitted = ($filetypes || $filegroups) && $action == 'permit' ? $filetypes : 'false'; $prohibited = ($filetypes || $filegroups) && $action == 'prohibit' ? $filetypes : 'false'; // Configure Settings $name = $name ? $name : "ssfa-meta-container-{$uid}"; $width = is_numeric(preg_replace('[\\D]', '', $width)) ? preg_replace('[\\D]', '', $width) : '100'; $width = "width:{$width}{$perpx};"; if ($width == '100' && $perpx == '%') { $align = 'none'; } $clearfix = $align == 'none' ? '<div class="ssfa-clearfix"></div>' : null; $float = ' float:' . $align . ';'; $margin = $width !== 'width:100%;' ? $align === 'right' ? ' margin-left:15px;' : ' margin-right:15px;' : null; $inlinestyle = $width . $float . $margin; $multiple = $single ? '' : ' multiple=multiple'; $addfiles = $single ? __('+ Add File', 'file-away') : __('+ Add Files', 'file-away'); $overwrite = $overwrite == 'true' ? 'true' : 'false'; $uploadlabel = $uploadlabel ? $uploadlabel : __('File Up ➚', 'file-away'); $pathcheck = $problemchild ? fileaway_utility::replacefirst($start, $install, '') : $start; $uploadedby = $uploader ? get_current_user_id() : 0; $uploadtype = $uploader ? $uploader : 'false'; // Configure Max File Size Setting $max_file_size = trim(preg_replace('[\\D]', '', $maxsize)); $max_size_type = trim(strtolower($maxsizetype)); $max_file_size = is_numeric($max_file_size) ? $max_file_size : 10; $max_size_type = in_array($max_size_type, array('k', 'm', 'g')) ? $max_size_type : 'm'; $ms = $max_file_size . $max_size_type; $ms = fileaway_utility::ini(false, true, false, $ms); $pms = fileaway_utility::ini('post_max_size'); $ums = fileaway_utility::ini('upload_max_filesize'); $maxsize = $pms < $ms ? $pms : $ms; $maxsize = $ums < $maxsize ? $ums : $maxsize; // Initialize Settings $fixedsetting = $fixedlocation ? '"' . $fixed . '"' : 'false'; $initialize = '<script> ' . 'FileUpConfig[' . $uid . '] = { ' . 'form_id: "ssfa_fileup_form_' . $uid . '", ' . 'uid: ' . $uid . ', ' . 'nonce: "' . wp_create_nonce('fileaway-fileup-nonce') . '", ' . 'container: "' . $name . '", ' . 'table: "' . $theme . '", ' . 'iconcolor: "' . $iconcolor . '", ' . 'maxsize: ' . $maxsize . ', ' . 'permitted: ' . $permitted . ', ' . 'prohibited: ' . $prohibited . ', ' . 'fixed: ' . $fixedsetting . ', ' . 'pathcheck: "' . $pathcheck . '", ' . 'uploader: ' . $uploadedby . ', ' . 'identby: "' . $uploadtype . '", ' . 'overwrite: "' . $overwrite . '", ' . 'loading: "' . fileaway_url . '/lib/img/ajax.gif" ' . '}; ' . '</script>'; $fadeit = $fadein ? $fadein == 'opacity' ? 'opacity:0;' : 'display:none;' : null; if ($fadein) { $fadescript = $fadein == 'opacity' ? '.animate({opacity:"1"}, ' . $fadetime . ');' : '.fadeIn(' . $fadetime . ');'; $initialize .= '<script> jQuery(document).ready(function($){ setTimeout(function(){ $("div#ssfa_fileup_container_' . $uid . '")' . $fadescript . ' }, 1000); }); </script>'; } // Form Output if (!is_dir($debugpath)) { return current_user_can('administrator') ? __('File Up Admin Notice: The initial directory specified does not exist:', 'file-away') . '<br>' . $debugpath : null; } $dropdown = $fixedlocation ? null : '<div id="ssfa-fileup-path-container-' . $uid . '" style="display:inline-block; float:left;">' . '<div id="ssfa-fileup-directories-select-container-' . $uid . '">' . '<label for="ssfa-fileup-directories-select-' . $uid . '" ' . 'style="display:block!important; margin-bottom:5px!important; text-align:left;">' . __('Destination Directory', 'file-away') . '</label>' . '<select name="ssfa-fileup-directories-select-' . $uid . '" id="ssfa-fileup-directories-select-' . $uid . '" ' . 'class="chozed-select ssfa-fileup-directories-select" data-placeholder=" ">' . '<option></option>' . '<option value="' . $start . '">' . $basename . '</option>' . '</select>' . '<br>' . '<div id="ssfa-fileup-action-path-' . $uid . '" style="margin-top:5px; min-height:25px;">' . '<img id="ssfa-fileup-action-ajax-loading-' . $uid . '" src="' . fileaway_url . '/lib/img/ajax.gif" ' . 'style="width:15px; margin:0 0 0 5px!important; box-shadow:none!important; display:none;">' . '</div>' . '</div>' . '</div>'; $form = $clearfix . '<div id="ssfa_fileup_container_' . $uid . '" class="ssfa_fileup_container ' . $class . '" data-uid="' . $uid . '" data-mn="' . wp_create_nonce('fileaway-manager-nonce') . '" style="' . $inlinestyle . ' ' . $fadeit . '">' . '<form name="ssfa_fileup_form_' . $uid . '" id="ssfa_fileup_form_' . $uid . '" action="javascript:void(0);" enctype="multipart/form-data">' . $path . $dropdown . '<div class="ssfa_fileup_buttons_container" style="text-align:right;">' . '<span class="ssfa_fileup_wrapper" style="text-align:left;">' . '<input type="file" name="ssfa_fileup_files_' . $uid . '[]" id="ssfa_fileup_files_' . $uid . '" ' . 'class="ssfa_hidden_browse"' . $multiple . ' data-uid="' . $uid . '" />' . '<span class="ssfa_add_files">' . $addfiles . '</span>' . '<span id="ssfa_submit_upload_' . $uid . '" data-uid="' . $uid . '">' . $uploadlabel . '</span>' . '</span>' . '</div>' . '</form>' . '<div id="ssfa_fileup_files_container_' . $uid . '" class="ssfa_fileup_files_container"></div>' . '<span id="ssfa_rf_' . $uid . '" style="display:none;"></span>' . '</div>' . $clearfix; return $initialize . $form; }
public function sc($atts) { if (isset($atts['style'])) { $atts['theme'] = $atts['style']; } $get = new fileaway_definitions(); extract($get->pathoptions); extract($this->correct(wp_parse_args($atts, $this->fileaway_values), $this->shortcodes['fileaway_values'])); if ($devices == 'mobile' && !$get->is_mobile) { return; } elseif ($devices == 'desktop' && $get->is_mobile) { return; } if (!fileaway_utility::visibility($hidefrom, $showto)) { return; } if ($this->op['javascript'] == 'footer') { $GLOBALS['fileaway_add_scripts'] = true; } if ($this->op['stylesheet'] == 'footer') { $GLOBALS['fileaway_add_styles'] = true; } include fileaway_dir . '/lib/inc/inc.values-declarations.php'; global $is_IE, $is_safari; $uid = rand(0, 9999); $name = "ssfa-meta-container-{$uid}"; $randcolor = array("red", "green", "blue", "brown", "black", "orange", "silver", "purple", "pink"); $paginated = $paginate ? " data-page-navigation='.ssfa-pagination'" : null; $pagearea = $paginate ? "<div class='ssfa-pagination ssfa-pagination-centered hide-if-no-paging'></div>" : null; $pagesized = $paginate ? " data-page-size='{$pagesize}'" : null; $page = $paginate ? $paginated . $pagesized : "{$paginated} data-page-size='100000'"; $theme = "ssfa-{$theme}"; $textalign = $textalign ? ' ssfa-' . $textalign : null; $width = preg_replace('[\\D]', '', $width); $width = $width ? "width:{$width}{$perpx};" : null; $float = " float:{$align};"; $margin = $width !== 'width:100%;' ? $align === 'right' ? ' margin-left:15px;' : ' margin-right:15px;' : null; $howshouldiputit = $width . $float . $margin; if ($width == '100' && $perpx == '%') { $align = 'none'; } $clearfix = $align == 'none' ? "<div class='ssfa-clearfix'></div>" : null; include fileaway_dir . '/lib/inc/inc.base.php'; extract(fileaway_utility::dynamicpaths($dir, $playbackpath)); $makedir = $makecsv ? true : $makedir; $dir = rtrim($dir, '/'); if (!is_dir("{$dir}") && $makedir && (!$private_content || $private_content && $logged_in)) { if (mkdir($rootpath . $dir, 0775, true)) { fileaway_utility::indexmulti($rootpath . $dir, $chosenpath); } } if (!is_dir("{$dir}")) { return; } $nonce = wp_create_nonce('fileaway-values-nonce'); $start = "{$dir}"; if ($filename) { if (!fileaway_utility::endswith(strtolower($filename), '.csv')) { $filename = $filename . '.csv'; } $filename = str_replace('fa-userid', $fa_userid, $filename); $filename = str_replace('fa-userrole', $fa_userrole, $filename); $filename = str_replace('fa-firstlast', $fa_firstlast, $filename); $filename = str_replace('fa-username', $fa_username, $filename); if (stripos($filename, 'fa-usermeta(') !== false) { $umetas = array(); $countmetas = preg_match_all('/\\((.*)\\)/U', $filename, $umetas); if (is_array($umetas[1])) { foreach ($umetas[1] as $umeta) { $metavalue = get_user_meta($fa_userid, $umeta, true); if (!$metavalue || $metavalue == '') { $makecsv = false; } $filename = str_ireplace('fa-usermeta(' . $umeta . ')', $metavalue, $filename); } } } $showoptions = false; if (!is_file($rootpath . $dir . '/' . $filename) && $makecsv) { $csv = new fileaway_csv(); $csv->encoding($read, $write); $rows = array(); $cols = array(); $csv->titles = preg_split('/(, |,)/', $makecsv, -1, PREG_SPLIT_NO_EMPTY); foreach ($csv->titles as $header) { $cols[$header] = ''; } $rows[0] = $cols; $csv->data = $rows; $csv->save($rootpath . $dir . '/' . $filename); } } else { if ($recursive) { $globaldirexes = array(); $localdirexes = array(); if ($excludedirs) { $localdirexes = preg_split('/(, |,)/', $excludedirs, -1, PREG_SPLIT_NO_EMPTY); } if ($this->op['direxclusions']) { $globaldirexes = preg_split('/(, |,)/', $this->op['direxclusions'], -1, PREG_SPLIT_NO_EMPTY); } if (!is_array($globaldirexes)) { $globaldirexes = array(); } if (!is_array($localdirexes)) { $localdirexes = array(); } $direxes = array_unique(array_merge($localdirexes, $globaldirexes)); $excludedirs = count($direxes) > 0 ? $direxes : false; if ($onlydirs) { $onlydirs = $dir . ',' . rtrim($onlydirs); } $justthesedirs = $onlydirs ? preg_split('/(, |,)/', $onlydirs, -1, PREG_SPLIT_NO_EMPTY) : 0; $onlydirs = is_array($justthesedirs) && count($justthesedirs) > 0 ? $justthesedirs : 0; } $selected = false; $showoptions = false; if (isset($_REQUEST['fa_csv']) && isset($_REQUEST['fa_index'])) { $selected = $_GET['fa_csv']; $filename = base64_decode($selected); $file_index = $_GET['fa_index']; $selected = fileaway_utility::querystring(get_permalink(), $_SERVER['QUERY_STRING'], array('fa_csv' => $selected, 'fa_index' => $file_index)); } $dir = rtrim($dir, '/'); $files = $recursive ? fileaway_utility::recursefiles($dir, $onlydirs, $excludedirs, '[cC][sS][vV]') : glob("{$dir}/*.[cC][sS][vV]"); if (!$editor && !is_array($files)) { return; } $count = count($files); if ($count !== 1) { $showoptions = true; } elseif ($count === 1) { $showoptions = false; $filename = fileaway_utility::basename($files[0]); $file_index = 0; $dir = $recursive ? str_replace($filename, '', $files[0]) : $dir; $dir = rtrim($dir, '/'); } if ($showoptions) { $options = array(); $original_url = fileaway_utility::querystring(get_permalink(), $_SERVER['QUERY_STRING'], array('fa_csv', 'fa_index'), true); if (is_array($files)) { foreach ($files as $key => $file) { if (isset($file_index) && $file_index == $key) { $dir = $recursive ? str_replace(fileaway_utility::basename($file), '', $file) : $dir; $dir = rtrim($dir, '/'); } $is_selected = $file === $dir . '/' . $filename ? 'selected' : null; $link = fileaway_utility::querystring(get_permalink(), $_SERVER['QUERY_STRING'], array('fa_csv' => base64_encode(fileaway_utility::basename($file)), 'fa_index' => $key)); $option_display = $recursive ? $install ? fileaway_utility::replacefirst($file, $install, '') : $file : preg_replace('/.csv$/i', '', fileaway_utility::basename($file)); $option_display = $recursive ? str_replace('/', ' > ', $option_display) : $option_display; $options[] = '<option value="' . $link . '" ' . $is_selected . '>' . trim($option_display, '/') . '</option>'; } } $download_link = $filename && isset($file_index) && array_key_exists($file_index, $files) ? '<a href="' . fileaway_utility::urlesc($url . '/' . $dir . '/' . $filename) . '" ' . 'style="text-decoration:none!important; position:relative; top:4px; left:10px;" ' . 'class="ssfa-csv-download" download="' . $filename . '">' . '<span class="ssfa-icon-arrow-down-2" style="font-size:18px; color: #AAA;"></span>' . '</a>' : null; $is_recursive = $recursive ? 'true' : 'false'; $deletecsv = $editor && isset($file_index) && array_key_exists($file_index, $files) ? '<span id="ssfa-delete-csv-' . $uid . '" style="font-size:18px; position:relative; top:4px; left:20px; color:#AAA; cursor:pointer;" ' . 'class="ssfa-icon-remove" aria-hidden="true" data-uid="' . $uid . '"></span>' : null; $newcsvspace = $deletecsv == null ? 10 : 30; $newcsv = $editor ? '<span id="ssfa-new-csv-' . $uid . '" style="font-size:18px; position:relative; top:4px; left:' . $newcsvspace . 'px; color:#AAA; cursor:pointer;" ' . 'class="ssfa-icon-file-4" aria-hidden="true" data-uid="' . $uid . '" data-pg="' . $GLOBALS['post']->ID . '" data-path="' . base64_encode($dir) . '" ' . 'data-recurse="' . $is_recursive . '" data-read="' . $read . '" data-write="' . $write . '"></span>' : null; $select = "<div class='ssfa-clearfix' style='float:left; margin-bottom:15px;'>" . "<div id='ssfa-fileaway-values-{$uid}' style='text-align:left;'>" . "<div style='text-align:left; margin-top:5px;'>" . "<select class='chozed-select ssfa-fileaway-values-select' id='ssfa-fileaway-values-select-{$uid}' " . "data-placeholder=\"{$placeholder}\">" . "<option></option>" . implode(' ', $options) . "</select>" . $download_link . $deletecsv . $newcsv . "</div>" . "</div>" . "</div>"; $selectscript = "<script>" . "jQuery(document).ready(function(\$){ " . "var select = \$('select#ssfa-fileaway-values-select-{$uid}'); " . "\$(select).chozed({ " . "allow_single_deselect:true, " . "width: '300px', " . "inherit_select_classes:true, " . "no_results_text: fileaway_mgmt.no_results, " . "search_contains: true " . "}); " . "\$(select).on('change', function(){ " . "var shadow = \$('<div id=\"ssfa-values-shadow\" style=\"display:none;\" />'); " . "\$('body').append(shadow); " . "shadow.fadeIn(1000); " . "\$('body').css('cursor', 'progress'); " . "if(\$(this).val() == '') window.location.href = \"" . $original_url . "\"; " . "else window.location.href = \$(this).val(); " . "}); " . "}); " . "</script>"; } } if (!$filename && !$showoptions) { return 'No file found.'; } $edit = $editor ? 'true' : 'false'; $mobileclass = $get->is_mobile ? 'ssfa-mobile' : null; $thefiles .= $clearfix . "<div id='{$name}' class='ssfa-meta-container ssfa-fileaway-values {$mobileclass}' data-editor='{$edit}' data-uid='{$uid}' data-fvn=\"" . $nonce . "\" style='opacity:0; margin: 10px 0 20px; {$howshouldiputit}'>"; if ($filename && is_file($rootpath . $dir . '/' . $filename)) { $disablesort = $sorting ? false : "data-sort='false'"; $heading = $showoptions ? $select : '<a href="' . fileaway_utility::urlesc($url . '/' . $dir . '/' . $filename) . '" download="' . $filename . '" ' . 'style="text-decoration:none; color:inherit!important;">' . $filename . '</a>'; include fileaway_dir . '/lib/inc/inc.precontent.php'; $thefiles .= "<script type='text/javascript'>jQuery(function(){ jQuery('.footable').footable();});</script>" . "<table id='ssfa-table-{$uid}' class='ssfa-values-table footable ssfa-sortable {$theme} {$textalign}' data-filter='#filter-{$uid}' data-uid='{$uid}' " . "data-theme=\"{$theme}\" data-src=\"" . base64_encode($dir . '/' . $filename) . "\" data-filename=\"" . fileaway_utility::basename($filename) . "\" " . "data-read=\"{$read}\" data-write=\"{$write}\" {$disablesort} {$page}>" . "<thead><tr>"; ini_set('auto_detect_line_endings', TRUE); $filename = $rootpath . $dir . '/' . $filename; if (file_exists($filename) && is_readable($filename)) { $csv = new fileaway_csv(); $csv->encoding($read, $write); $csv->auto($filename); $rows = $csv->data; $headers = $csv->titles; $editorcursor = $editor ? 'style="cursor:cell"' : null; $editorcontext = $editor ? 'class="ssfa-values-context"' : null; foreach ($headers as $key => $header) { $sortinitial = $key < 1 ? " data-sort-initial='true'" : null; $initialclass = $key < 1 ? 'class="' . $theme . '-first-column"' : null; $thefiles .= "<th id='ssfa-values-header-{$uid}-{$key}' {$initialclass} data-colnum=\"{$key}\" data-col=\"{$header}\" {$sortinitial}>" . $header . "</th>"; } $thefiles .= "</tr></thead><tfoot><tr><td colspan='100'>{$pagearea}</td></tr></tfoot><tbody>"; foreach ($rows as $k => $row) { $thefiles .= "<tr id='ssfa-values-{$uid}-{$k}' {$editorcontext} data-row='{$k}'>"; foreach ($headers as $key => $header) { $col1class = $key < 1 ? "class='{$theme}-first-column'" : null; $input = $editor ? '<input type="text" id="input-ssfa-values-' . $uid . '-' . $k . '-' . $key . '" data-row="' . $k . '" data-col="' . $header . '" data-colnum="' . $key . '" ' . 'value="' . $row[$header] . '" style="display:none; width:90%">' : null; $thefiles .= '<td id="cell-ssfa-values-' . $uid . '-' . $k . '-' . $key . '" ' . $col1class . ' ' . $editorcursor . '>' . '<span id="value-ssfa-values-' . $uid . '-' . $k . '-' . $key . '" data-row="' . $k . '" data-col="' . $header . '" data-colnum="' . $key . '">' . $row[$header] . '</span> ' . $input . '</td>'; } $thefiles .= "</tr>"; } $thefiles .= "</tbody></table></div>"; } } elseif ($showoptions) { $thefiles .= $select; } $thefiles .= $showoptions ? $selectscript : null; $thefiles .= "<script> jQuery(document).ready(function(\$){ setTimeout(function(){ \$('div#" . $name . "').animate({opacity:'1'},1000); }, 1000 ); }); </script>"; $thefiles .= "</div>{$clearfix}"; return $thefiles; }