Пример #1
0
    }
    if ($options) {
        $settings_content = '<?php ' . "\n";
        foreach ($options as $option) {
            $option = trim($option);
            $value = trim($_POST[$option]);
            $flag->options[$option] = $value;
            $settings_content .= '$' . $option . ' = \'' . str_replace('#', '', $value) . "';\n";
        }
        $settings_content .= '?>' . "\n";
        // the path should always end with a slash
        $flag->options['galleryPath'] = trailingslashit($flag->options['galleryPath']);
    }
    // Save options
    update_option('flag_options', $flag->options);
    if (flagGallery::saveFile($flag_options['skinsDirABS'] . $flag_options['flashSkin'] . '_settings.php', $settings_content, 'w')) {
        flagGallery::show_message(__('Update Successfully', 'flash-album-gallery'));
    }
}
if (isset($_POST['license_key'])) {
    check_admin_referer('skin-api');
    $license_key = esc_sql($_POST['license_key']);
    $flag_options['license_key'] = trim($license_key);
    update_option('flag_options', $flag_options);
    flagGallery::show_message(__('License Key Updated', 'flash-album-gallery'));
}
if (!empty($flag_options['license_key'])) {
    if (function_exists('curl_init')) {
        $ch = curl_init('http://mypgc.co/app/account_st.php');
        curl_setopt($ch, CURLOPT_REFERER, home_url());
        curl_setopt($ch, CURLOPT_POST, 1);
Пример #2
0
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/"');
        }
    }
}
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/"');
        }
    }
}