public function feeds() { extract($this->definitions->pathoptions); $basedirs = fileaway_utility::feeds(); $excluded_dirs = fileaway_utility::feeds(true); $wp_excludes = array('wp-admin', 'wp-includes', 'wp-content/themes', 'wp-content/upgrade'); $startswith = array('fa-feed-logo', '_thumb_', 'fileaway-url-parser', 'fileaway-banner-parser', 'index.htm', 'index.php', '.ht'); $endswith = array('ini', 'php'); if (isset($this->options['feed_excluded_exts']) && !empty($this->options['feed_excluded_exts'])) { $endswith = array_unique(array_merge($endswith, preg_split('/(, |,)/', trim($this->options['feed_excluded_exts']), -1, PREG_SPLIT_NO_EMPTY))); } $excludestrings = array(); if (isset($this->options['feed_excluded_files']) && !empty($this->options['feed_excluded_files'])) { $excludestrings = preg_split('/(, |,)/', trim($this->options['feed_excluded_files']), -1, PREG_SPLIT_NO_EMPTY); } if (!isset($this->options['feeds']) || !$this->options['feeds'] || trim($this->options['feeds']) == '' || trim($this->options['feeds']) == '/') { return; } fileaway_utility::timezone(); $storage = $rootpath . trim(trim($this->options['feeds']), '/'); if (!is_dir($storage)) { if (mkdir($storage, 0775, true)) { fileaway_utility::indexmulti($storage, $chosenpath); } } $globallogo = false; if (is_file($storage . '/fa-feed-logo.png')) { $globallogo = $storage . '/fa-feed-logo.png'; } elseif (is_file($storage . '/fa-feed-logo.jpg')) { $globallogo = $storage . '/fa-feed-logo.jpg'; } elseif (is_file($storage . '/fa-feed-logo.gif')) { $globallogo = $storage . '/fa-feed-logo.gif'; } if ($globallogo) { $globallogo = fileaway_utility::urlesc(fileaway_utility::replacefirst($globallogo, rtrim($rootpath, '/'), rtrim($this->options['baseurl'], '/') . '/')); } $feedlimit = isset($this->options['feedlimit']) && is_numeric($this->options['feedlimit']) ? round($this->options['feedlimit'], 0) : false; $hardlinks = array(); $map = is_file($storage . '/fa-directory-map.csv') ? new fileaway_csv($storage . '/fa-directory-map.csv') : false; $now = time(); foreach ($basedirs as $basedir) { $basedir = $rootpath . trim(trim($basedir), '/'); $dirs = fileaway_utility::recursivedirs($basedir); array_unshift($dirs, $basedir); $datestring = $this->options['daymonth'] == 'md' ? 'm/d/Y H:i' : 'd/m/Y H:i'; foreach ($dirs as $k => $dir) { foreach ($wp_excludes as $wp) { if (stripos($dir, $wp) !== false) { continue 2; } } $feedfile = $dir . '/_fa.feed.id.ini'; if (!is_file($feedfile)) { $feedid = uniqid(true); $feedfile_contents = "; Do not move or delete this file, nor alter its contents \n" . "id = " . $feedid; file_put_contents($feedfile, $feedfile_contents); } else { $ini = parse_ini_file($feedfile); $feedid = $ini['id']; } $feed = $storage . '/_feed_' . $feedid . '.xml'; if (fileaway_utility::startswith(fileaway_utility::replacefirst($dir, $rootpath, ''), $excluded_dirs)) { if (is_file($feed)) { unlink($feed); } continue; } $feedlogo = false; if (is_file($dir . '/fa-feed-logo.png')) { $feedlogo = $dir . '/fa-feed-logo.png'; } elseif (is_file($dir . '/fa-feed-logo.jpg')) { $feedlogo = $dir . '/fa-feed-logo.jpg'; } elseif (is_file($dir . '/fa-feed-logo.gif')) { $feedlogo = $dir . '/fa-feed-logo.gif'; } $feedlogo = $feedlogo ? fileaway_utility::urlesc(fileaway_utility::replacefirst($feedlogo, rtrim($rootpath, '/'), rtrim($this->options['baseurl'], '/') . '/')) : $globallogo; $files = array(); $subxml = array(); $initfiles = array_filter(glob("{$dir}/*"), 'is_file'); if ($this->options['recursivefeeds'] == 'true') { $initdirs = glob("{$dir}/*", GLOB_ONLYDIR); if (is_array($initdirs) && count($initdirs) > 0) { foreach ($initdirs as $subdir) { if (in_array(fileaway_utility::replacefirst($subdir, $rootpath, ''), $excluded_dirs)) { continue; } $subfeedfile = $subdir . '/_fa.feed.id.ini'; if (!is_file($subfeedfile)) { continue; } $subini = parse_ini_file($subfeedfile); $subfeedid = $subini['id']; $subfeed = $storage . '/_feed_' . $subfeedid . '.xml'; if (!is_file($subfeed)) { continue; } $sublink = $map ? $this->csvsearch($map->data, $map->titles, trim(fileaway_utility::replacefirst($subdir, $rootpath, ''), '/')) : false; $sublink = $sublink ? $sublink : fileaway_utility::replacefirst($subfeed, $rootpath, rtrim($this->options['baseurl'], '/') . '/'); $subPubDate = $this->options['feeddates'] == 'false' ? null : "<pubDate>" . date($datestring, filemtime($subdir)) . "</pubDate>\n" . ($subxml[] = "<item>\n" . "<title>" . fileaway_utility::basename($subdir) . "</title>\n" . "<link>" . $sublink . "</link>\n" . "<description>RSS Feed</description>\n" . $subPubDate . "</item>\n"); } } } if (is_array($initfiles)) { foreach ($initfiles as $i => $file) { if (fileaway_utility::startswith(fileaway_utility::basename($file), $startswith)) { unset($initfiles[$i]); continue; } if (fileaway_utility::endswith(strtolower(fileaway_utility::basename($file)), $endswith)) { unset($initfiles[$i]); continue; } foreach ($excludestrings as $str) { if (strpos(fileaway_utility::basename($file), $str) !== false) { unset($initfiles[$i]); continue 2; } } $mime = false; $parts = fileaway_utility::pathinfo($file); $ext = strtolower($parts['extension']); if ($this->options['feedlinks'] != 'false') { if (in_array($ext, array('mp3', 'wav', 'ogg'))) { $mime = $ext == 'mp3' ? 'audio/mpeg' : ($ext == 'wav' ? 'audio/vnd.wave' : 'audio/ogg'); } elseif (in_array($ext, array('png', 'gif', 'jpg', 'jpeg'))) { $mime = $ext == 'png' ? 'image/png' : ($ext == 'gif' ? 'image/gif' : 'image/jpeg'); } elseif (in_array($ext, array('avi', 'mpeg', 'mp4', 'ogv', 'mov', 'webm', 'flv', 'wmv', 'mkv'))) { $mime = $ext == 'avi' ? 'video/avi' : ($ext == 'mp4' ? 'video/mp4' : ($ext == 'flv' ? 'video/x-flv' : ($ext == 'mpeg' ? 'video/mpeg' : ($ext == 'ogv' ? 'video/ogg' : ($ext == 'mov' ? 'video/quicktime' : ($ext == 'webm' ? 'video/webm' : ($ext == 'wmv' ? 'video/x-ms-wmv' : 'video/x-matroska'))))))); } if (stripos($file, 's2member-files/')) { $getsub = explode('s2member-files/', fileaway_utility::urlesc($file)); $fileurl = rtrim($this->options['baseurl'], '/') . '/?s2member_file_download=' . $getsub[1]; } else { $fileurl = fileaway_utility::urlesc(fileaway_utility::replacefirst($file, $rootpath, rtrim($this->options['baseurl'], '/') . '/')); } } else { $fileurl = false; } $files['dirname'][] = $parts['dirname']; $files['basename'][] = $parts['basename']; $files['filename'][] = $parts['filename']; $files['extension'][] = $parts['extension']; $files['mime'][] = $mime; $files['datemodified'][] = $this->options['feeddates'] != 'false' ? filemtime($file) : $now; $files['filesize'][] = $this->options['feedsize'] != 'false' ? filesize($file) : false; $files['url'][] = $fileurl; } if (isset($files['datemodified']) && count($files['datemodified']) > 0) { array_multisort($files['datemodified'], SORT_DESC, SORT_NUMERIC, $files['dirname'], $files['basename'], $files['filename'], $files['extension'], $files['mime'], $files['filesize'], $files['url']); } $directory = explode('/', $dir); $directory = array_pop($directory); $stripped_url = str_ireplace(array('http:', 'https:', 'www.', 'ww2.', '//'), '', rtrim($this->options['baseurl'], '/')); $ttl = $this->options['feedinterval'] == 'fifteenminutes' ? 15 : ($this->options['feedinterval'] == 'thirtyminutes' ? 30 : ($this->options['feedinterval'] == 'fortyfiveminutes' ? 45 : 60)); $channellink = $map ? $this->csvsearch($map->data, $map->titles, trim(fileaway_utility::replacefirst($dir, $rootpath, ''), '/')) : $this->options['baseurl']; $description = $channellink ? $channellink : fileaway_utility::replacefirst($dir, $rootpath, rtrim($this->options['baseurl'], '/') . '/'); $channellink = $channellink ? $channellink : $this->options['baseurl']; $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" . "<rss version=\"2.0\">\n" . "<channel>\n" . "<title>" . $stripped_url . " > " . $directory . "</title>\n" . "<link>" . $channellink . "</link>\n" . "<description>" . $description . "</description>\n" . "<lastBuildDate>" . date($datestring) . "</lastBuildDate>\n" . "<pubDate>" . date($datestring) . "</pubDate>\n" . "<ttl>" . $ttl . "</ttl>\n" . "<generator>File Away</generator>\n"; if ($feedlogo) { $xml .= "<image>\n" . "<url>" . $feedlogo . "</url>\n" . "<title>" . str_replace(array('http://', 'https://', 'www.'), '', $this->options['baseurl']) . " > " . $directory . "</title>\n" . "<link>" . $this->options['baseurl'] . "</link>\n" . "</image>\n"; } if (count($subxml > 0)) { $xml .= implode($subxml); } if (isset($files['datemodified']) && count($files['datemodified']) > 0) { foreach ($files['datemodified'] as $k => $file) { if ($feedlimit && $k >= $feedlimit) { break; } $rawname = str_replace('&', 'and', $files['filename'][$k]); if (preg_match('/\\[([^\\]]+)\\]/', $rawname)) { list($thename, $customvalue) = preg_split("/[\\[\\]]/", $rawname); $customvalue = str_replace(array('~', '--', '_', '.', '*'), ' ', $customvalue); $customvalue = preg_replace('/(?<=\\D)-(?=\\D)/', ' ', "{$customvalue}"); $customvalue = preg_replace('/(?<=\\d)-(?=\\D)/', ' ', "{$customvalue}"); $customvalue = preg_replace('/(?<=\\D)-(?=\\d)/', ' ', "{$customvalue}"); $thename = str_replace(array('~', '--', '_', '.', '*'), ' ', $thename); } else { $customvalue = false; $thename = str_replace(array('~', '--', '_', '.', '*'), ' ', $rawname); } $thename = preg_replace('/(?<=\\D)-(?=\\D)/', ' ', "{$thename}"); $thename = preg_replace('/(?<=\\d)-(?=\\D)/', ' ', "{$thename}"); $thename = preg_replace('/(?<=\\D)-(?=\\d)/', ' ', "{$thename}"); $showsize = $this->options['feedsize'] == 'false' ? null : "Size: " . fileaway_utility::formatBytes($files['filesize'][$k]) . "."; $filedescription = $customvalue ? $customvalue . ' (' . $files['extension'][$k] . " file. " . $showsize : $files['extension'][$k] . " file. " . $showsize; $pubDate = $this->options['feeddates'] == 'false' ? null : "<pubDate>" . date($datestring, $file) . "</pubDate>\n"; $filelink = $files['url'][$k] ? $files['url'][$k] : $channellink; $xml .= "<item>\n" . "<title>" . $thename . "</title>\n" . "<link>" . $filelink . "</link>\n" . "<description>" . $filedescription . "</description>\n" . $pubDate; if ($files['mime'][$k]) { $xml .= "<enclosure url=\"" . $files['url'][$k] . "\" length=\"" . $files['filesize'][$k] . "\" type=\"" . $files['mime'][$k] . "\" />\n"; } $xml .= "</item>\n"; } } $xml .= "</channel>\n" . "</rss>"; $oldfeed = file_get_contents($feed); if ($xml != $oldfeed) { file_put_contents($feed, $xml); } } } } date_default_timezone_set('UTC'); exit; }
$file_plus_custom = $rawname; list($salvaged_filename, $customvalue) = preg_split("/[\\[\\]]/", $file_plus_custom); if ($customvalue != '' && !$prettify) { $customvalue = str_replace(array('~', '--', '_', '.', '*'), ' ', $customvalue); $customvalue = preg_replace('/(?<=\\D)-(?=\\D)/', ' ', "{$customvalue}"); $customvalue = preg_replace('/(?<=\\d)-(?=\\D)/', ' ', "{$customvalue}"); $customvalue = preg_replace('/(?<=\\D)-(?=\\d)/', ' ', "{$customvalue}"); } $thename = $prettify ? $salvaged_filename : str_replace(array('~', '--', '_', '.', '*'), ' ', $salvaged_filename); } else { $file_plus_custom = null; $customvalue = null; $thename = $prettify ? $rawname : str_replace(array('~', '--', '_', '.', '*'), ' ', $rawname); $salvaged_filename = $rawname; } if (!$prettify) { $thename = preg_replace('/(?<=\\D)-(?=\\D)/', ' ', "{$thename}"); $thename = preg_replace('/(?<=\\d)-(?=\\D)/', ' ', "{$thename}"); $thename = preg_replace('/(?<=\\D)-(?=\\d)/', ' ', "{$thename}"); } $ext = !$ext ? '?' : $ext; $ext = substr($ext, 0, 4); $bytes = $dynamiclink || $size == 'no' ? 1 : filesize($dir . '/' . $file); if ($size != 'no') { $fsize = fileaway_utility::formatBytes($bytes, 1); $fsize = !preg_match('/[a-z]/i', $fsize) ? '1k' : ($fsize === 'NAN' ? '0' : $fsize); } $sortdatekey = date("YmdHis", $thetime); $sortdate = $this->op['daymonth'] === 'dm' ? date("d/m/Y " . $time_format, $thetime) : date($time_format . " m/d/Y", $thetime); $date = date($date_format, $thetime); $time = date($time_format, $thetime);
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->attachaway), $this->shortcodes['attachaway'], 'attachaway')); 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; } $attachaway = true; $statstatus = 'false'; $iss2 = false; $rsslink = null; $crumbies = null; $clearfix = $align == 'none' ? "<div class='ssfa-clearfix'></div>" : null; $boximages = array(); $flightbox = $get->is_mobile ? false : $flightbox; $randcolor = array("red", "green", "blue", "brown", "black", "orange", "silver", "purple", "pink"); $fb = 0; $count = 0; $thefiles = ''; $uid = rand(0, 9999); global $post, $is_IE, $is_safari; $ascdesc = $desc ? 'DESC' : 'ASC'; $id = $postid ? $postid : $post->ID; $attachments = get_posts(array('orderby' => $orderby, 'order' => $ascdesc, 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $id)); if ($debug === 'on' && is_user_logged_in()) { return $this->debug($id, $attachments); } 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#ssfa-meta-container-' . $uid . '")' . $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='ssfa-meta-container-{$uid}' data-uid='{$uid}' " . "{$flightbox_nonce} class='ssfa-meta-container {$mobileclass} {$class} {$flightbox_class}' style='margin: 10px 0 20px; {$fadeit} {$howshouldiputit}'>"; include fileaway_dir . '/lib/inc/inc.precontent.php'; if ($type === 'table') { $typesort = null; $filenamesort = null; $capsort = null; $dessort = null; $sizesort = null; if ($sortfirst === 'type') { $typesort = " data-sort-initial='true'"; } elseif ($sortfirst === 'type-desc') { $typesort = " data-sort-initial='descending'"; } elseif ($sortfirst === 'filename') { $filenamesort = " data-sort-initial='true'"; } elseif ($sortfirst === 'filename-desc') { $filenamesort = " data-sort-initial='descending'"; } elseif ($sortfirst === 'caption') { $capsort = " data-sort-initial='true'"; } elseif ($sortfirst === 'caption-desc') { $capsort = " data-sort-initial='descending'"; } elseif ($sortfirst === 'description') { $dessort = " data-sort-initial='true'"; } elseif ($sortfirst === 'description-desc') { $dessort = " data-sort-initial='descending'"; } elseif ($sortfirst === 'size') { $sizesort = " data-sort-initial='true'"; } elseif ($sortfirst === 'size-desc') { $sizesort = " data-sort-initial='descending'"; } else { $filenamesort = " data-sort-initial='true' "; } $disablesort = $sortfirst == 'disabled' ? "data-sort='false'" : false; $filenamesort = $disablesort ? null : $filenamesort; $filenamelabel = $filenamelabel ? $filenamelabel : _x('File Name', 'File Name Column', 'file-away'); $thefiles .= "<script type='text/javascript'>jQuery(function(){jQuery('.footable').footable();});</script>" . "<table id='ssfa-table' data-filter='#filter-{$uid}' {$disablesort} {$page} class='footable ssfa-sortable {$theme}{$textalign}'><thead><tr>" . "<th class='ssfa-sorttype {$theme}-first-column' title=\"" . _x('Click to Sort', 'Column Sort Message', 'file-away') . "\"" . $typesort . ">" . _x('Type', 'File Type Column', 'file-away') . "</th>" . "<th class='ssfa-sortname' title=\"" . _x('Click to Sort', 'Column Sort Message', 'file-away') . "\"" . $filenamesort . ">" . $filenamelabel . "</th>"; $thefiles .= $capcolumn ? "<th class='ssfa-sortcapcolumn' title=\"" . _x('Click to Sort', 'Column Sort Message', 'file-away') . "\"" . $capsort . ">" . $capcolumn . "</th>" : null; $thefiles .= $descolumn ? "<th class='ssfa-sortdescolumn' title=\"" . _x('Click to Sort', 'Column Sort Message', 'file-away') . "\"" . $dessort . ">" . $descolumn . "</th>" : null; $thefiles .= $size !== 'no' ? "<th class='ssfa-sortsize' data-type='numeric' title=\"" . _x('Click to Sort', 'Column Sort Message', 'file-away') . "\"" . $sizesort . ">" . _x('Size', 'File Size Column', 'file-away') . "</th>" : null; $thefiles .= "</tr></thead><tfoot><tr><td colspan='100'>{$pagearea}</td></tr></tfoot><tbody>"; } if (is_array($attachments)) { foreach ($attachments as $attachment) { extract(fileaway_utility::getattachment($attachment->ID)); $filetype = wp_check_filetype($filelink); $ext = $filetype['ext']; $extension = $ext; $oext = $ext; $basename = fileaway_utility::basename($filelink); $rawname = str_replace('.' . $ext, '', $basename); $filename = str_replace(array('~', '-', '--', '_', '.', '*'), ' ', $rawname); $title = $title ? $title : $filename; if ($caption === strtoupper($caption) || $caption === strtolower($caption)) { $caption = fileaway_utility::sentencecase($caption); } if ($description === strtoupper($description) || $description === strtolower($description)) { fileaway_utility::sentencecase($description); } $title = "<span class='ssfa-filename'>" . fileaway_utility::strtotitle(strtolower($title)) . "</span>"; $ext = !$ext ? '?' : $ext; $ext = strtolower($ext); $ext = substr($ext, 0, 4) . ''; $bytes = filesize(get_attached_file($attachment->ID)); if ($size !== 'no') { $fsize = fileaway_utility::formatBytes($bytes, 1); $fsize = !preg_match('/[a-z]/i', $fsize) ? '1k' : ($fsize === 'NAN' ? '0' : $fsize); } include fileaway_dir . '/lib/inc/inc.colors.php'; $listfilesize = $type !== 'table' && $size !== 'no' ? $theme === "ssfa-minimal-list" ? "<span class='ssfa-listfilesize'> ({$fsize})</span>" : "<span class='ssfa-listfilesize'>{$fsize}</span>" : null; $file = $basename; $manager = false; $onlyaudio = false; include fileaway_dir . '/lib/inc/inc.filters.php'; if ($excluded) { continue; } $getthumb = false; $thumbnails = false; include fileaway_dir . '/lib/inc/inc.icons.php'; $count += 1; $link = $filelink; $fulllink = 'href="' . $link . '"'; if ($flightbox) { include fileaway_dir . '/lib/inc/inc.flightbox.php'; } if ($type !== 'table') { $thefiles .= "<a id='ssfa' class='{$display}{$noicons}{$colors}' {$fulllink} {$linktype}>" . "<div class='ssfa-listitem {$ellipsis}'><span class='ssfa-topline'>{$icon} {$title} {$listfilesize}</span></div>" . "</a>"; } else { $thefiles .= "<tr><td id='filetype-ssfa-file-{$uid}-{$count}' class='ssfa-sorttype {$theme}-first-column'><a {$fulllink} {$linktype}>{$icon} {$ext}</a></td>" . "<td id='filename-ssfa-file-{$uid}-{$count}' class='ssfa-sortname'><a {$fulllink} class='{$colors}' {$linktype}>{$title}</a></td>"; $thefiles .= $capcolumn ? "<td class='ssfa-sortcapcolumn'>{$caption}</td>" : null; $thefiles .= $descolumn ? "<td class='ssfa-sortdescolumn'>{$description}</td>" : null; $thefiles .= $size !== 'no' ? "<td class='ssfa-sortsize' data-value='{$bytes}'>{$fsize}</td>" : null; $thefiles .= '</tr>'; } } $thefiles .= $type === 'table' ? '</tbody></table></div>' : '</div>'; $thefiles .= "</div>{$clearfix}"; } if ($flightbox && $fb) { $thefiles .= '<script>FlightBoxes[' . $uid . '] = ' . $fb . '; '; if (count($boximages) > 0) { $thefiles .= implode(' ', $boximages); } $thefiles .= '</script>'; } return $count > 0 ? $thefiles : null; }