function flagSavePlaylist($title, $descr, $data, $file = '', $skinaction = '') { global $wpdb; if (!trim($title)) { $title = 'default'; } $title = htmlspecialchars_decode(stripslashes($title), ENT_QUOTES); $descr = htmlspecialchars_decode(stripslashes($descr), ENT_QUOTES); if (!$file) { $file = sanitize_flagname($title); } if (!is_array($data)) { $data = explode(',', $data); } $flag_options = get_option('flag_options'); $skin = isset($_POST['skinname']) ? sanitize_flagname($_POST['skinname']) : 'music_default'; if (!$skinaction) { $skinaction = isset($_POST['skinaction']) ? sanitize_key($_POST['skinaction']) : 'update'; } $skinpath = trailingslashit($flag_options['skinsDirABS']) . $skin; $playlistPath = ABSPATH . $flag_options['galleryPath'] . 'playlists/' . $file . '.xml'; $settings = ''; if (file_exists($playlistPath) && $skin == $skinaction) { $settings = file_get_contents($playlistPath); } elseif (file_exists($skinpath . "/settings/settings.xml")) { $settings = file_get_contents($skinpath . "/settings/settings.xml"); } else { flagGallery::show_message(__("Can't find skin settings", 'flag')); return; } $properties = flagGallery::flagGetBetween($settings, '<properties>', '</properties>'); if (empty($properties)) { flagGallery::show_message(__("Can't find skin settings", 'flag')); return; } if (count($data)) { $content = '<gallery> <properties>' . $properties . '</properties> <category id="' . $file . '"> <properties> <title><![CDATA[' . $title . ']]></title> <description><![CDATA[' . $descr . ']]></description> <skin><![CDATA[' . $skin . ']]></skin> </properties> <items>'; foreach ((array) $data as $id) { $mp3 = get_post($id); if ($mp3->post_mime_type == 'audio/mpeg') { $thumb = get_post_meta($id, 'thumbnail', true); $content .= ' <item id="' . $mp3->ID . '"> <track>' . wp_get_attachment_url($mp3->ID) . '</track> <title><![CDATA[' . $mp3->post_title . ']]></title> <description><![CDATA[' . $mp3->post_content . ']]></description> <thumbnail>' . $thumb . '</thumbnail> </item>'; } } $content .= ' </items> </category> </gallery>'; // Save options $flag_options = get_option('flag_options'); if (wp_mkdir_p(ABSPATH . $flag_options['galleryPath'] . 'playlists/')) { if (flagGallery::saveFile($playlistPath, $content, 'w')) { flagGallery::show_message(__('Playlist Saved Successfully', 'flag')); } } else { flagGallery::show_message(__('Create directory please:', 'flag') . '"/' . $flag_options['galleryPath'] . 'playlists/"'); } } }
<?php // Create XML output header("content-type:text/xml;charset=utf-8"); preg_match('|^(.*?/)(wp-content)/|i', str_replace('\\', '/', __FILE__), $_m); require_once $_m[1] . 'wp-load.php'; $flag_options = get_option('flag_options'); $file = $_GET['playlist']; $playlistPath = $_m[1] . $flag_options['galleryPath'] . 'playlists/banner/' . $file . '.xml'; if (file_exists($playlistPath)) { require_once FLAG_ABSPATH . 'admin/banner.functions.php'; $settings = file_get_contents(dirname(__FILE__) . '/settings/settings.xml'); $properties = '<properties>' . flagGallery::flagGetBetween($settings, '<properties>', '</properties>') . '</properties> <category'; $xml = file_get_contents($playlistPath); $playlist = get_b_playlist_data($playlistPath); if (count($playlist['items'])) { $content = '<items>'; foreach ($playlist['items'] as $id) { $ban = get_post($id); if ($ban->ID) { $track = wp_get_attachment_url($ban->ID); $thumbnail = get_post_meta($id, 'thumbnail', true); $link = get_post_meta($id, 'link', true); $preview = get_post_meta($id, 'preview', true); $content .= ' <item id="' . $ban->ID . '"> <track__>' . $track . '</track__> <title><![CDATA[' . $ban->post_title . ']]></title> <link>' . $link . '</link> <preview>' . $preview . '</preview>
function flagSave_bPlaylist($title, $descr, $data, $file = '', $skinaction = '') { require_once ABSPATH . '/wp-admin/includes/image.php'; if (!trim($title)) { $title = 'default'; } $title = htmlspecialchars_decode(stripslashes($title), ENT_QUOTES); $descr = htmlspecialchars_decode(stripslashes($descr), ENT_QUOTES); if (!$file) { $file = sanitize_flagname($title); } if (!is_array($data)) { $data = explode(',', $data); } $flag_options = get_option('flag_options'); $skin = isset($_POST['skinname']) ? sanitize_flagname($_POST['skinname']) : 'rotator_default'; if (!$skinaction) { $skinaction = isset($_POST['skinaction']) ? sanitize_key($_POST['skinaction']) : 'update'; } $skinpath = trailingslashit($flag_options['skinsDirABS']) . $skin; $playlistPath = ABSPATH . $flag_options['galleryPath'] . 'playlists/banner/' . $file . '.xml'; $settings = ''; if (file_exists($playlistPath) && $skin == $skinaction) { $settings = file_get_contents($playlistPath); } elseif (file_exists($skinpath . "/settings/settings.xml")) { $settings = file_get_contents($skinpath . "/settings/settings.xml"); } else { flagGallery::show_message(__("Can't find skin settings", 'flash-album-gallery')); return; } $properties = flagGallery::flagGetBetween($settings, '<properties>', '</properties>'); if (empty($properties)) { flagGallery::show_message(__("Can't find skin settings", 'flash-album-gallery')); return; } $w = flagGallery::flagGetBetween($properties, '<width><![CDATA[', ']]></width>'); $h = flagGallery::flagGetBetween($properties, '<height><![CDATA[', ']]></height>'); $suffix = $w . 'x' . $h; if (count($data)) { $content = '<gallery> <properties>' . $properties . '</properties> <category id="' . $file . '"> <properties> <title><![CDATA[' . $title . ']]></title> <description><![CDATA[' . $descr . ']]></description> <skin><![CDATA[' . $skin . ']]></skin> </properties> <items>'; foreach ((array) $data as $id) { $ban = get_post($id); if ($ban->ID) { $url = wp_get_attachment_url($ban->ID); if ($skin == 'rotator_default') { $path = get_attached_file($ban->ID); $info = pathinfo($path); $dir = $info['dirname']; $ext = $info['extension']; $name = urldecode(basename(str_replace('%2F', '/', urlencode($path)), ".{$ext}")); $img_file = "{$dir}/{$name}-{$suffix}.{$ext}"; if (!file_exists($img_file)) { if (function_exists('wp_get_image_editor')) { $editor = wp_get_image_editor($path); $editor->resize($w, $h, $cut = true); $dest_file = $editor->generate_filename($suffix); $thumb = $editor->save($dest_file); } else { $thumb = image_resize($path, $w, $h, $cut = true, $suffix); } if (is_string($thumb)) { $img = substr($thumb, strpos($thumb, basename(WP_CONTENT_DIR))); $track = get_bloginfo('wpurl') . '/' . $img; } else { $track = $url; } } else { $track = dirname($url) . "/{$name}-{$suffix}.{$ext}"; } } else { $track = $url; } $thumbnail = get_post_meta($id, 'thumbnail', true); $link = get_post_meta($id, 'link', true); $preview = get_post_meta($id, 'preview', true); $content .= ' <item id="' . $ban->ID . '"> <track>' . $track . '</track> <title><![CDATA[' . $ban->post_title . ']]></title> <link>' . $link . '</link> <preview>' . $preview . '</preview> <description><![CDATA[' . $ban->post_content . ']]></description> <thumbnail>' . $thumbnail . '</thumbnail> </item>'; } } $content .= ' </items> </category> </gallery>'; //$content = str_replace(array('\\\'','\"'), array('\'','"'), $content); // Save options $flag_options = get_option('flag_options'); if (wp_mkdir_p(ABSPATH . $flag_options['galleryPath'] . 'playlists/banner/')) { if (flagGallery::saveFile($playlistPath, $content, 'w')) { flagGallery::show_message(__('Playlist Saved Successfully', 'flash-album-gallery')); } } else { flagGallery::show_message(__('Create directory please:', 'flash-album-gallery') . '"/' . $flag_options['galleryPath'] . 'playlists/banner/"'); } } }