Example #1
0
function fv_wp_flowplayer_admin_init()
{
    if (isset($_GET['type'])) {
        if ($_GET['type'] == 'fvplayer_video' || $_GET['type'] == 'fvplayer_video_1' || $_GET['type'] == 'fvplayer_video_2' || $_GET['type'] == 'fvplayer_mobile') {
            $_GET['post_mime_type'] = 'video';
        } else {
            if ($_GET['type'] == 'fvplayer_splash' || $_GET['type'] == 'fvplayer_logo') {
                $_GET['post_mime_type'] = 'image';
            }
        }
    }
    if (isset($_POST['fv-wp-flowplayer-submit'])) {
        check_admin_referer('fv_flowplayer_settings_nonce', 'fv_flowplayer_settings_nonce');
        global $fv_fp;
        if (method_exists($fv_fp, '_set_conf')) {
            $fv_fp->_set_conf();
        } else {
            echo 'Error saving FV Flowplayer options.';
        }
    }
    if (isset($_GET['fv-licensing']) && $_GET['fv-licensing'] == "check") {
        delete_option("fv_wordpress_flowplayer_persistent_notices");
        //license will expire in 5 seconds in the function:
        fv_wp_flowplayer_admin_key_update();
    }
    global $fv_fp;
    global $fv_wp_flowplayer_ver, $fv_wp_flowplayer_core_ver;
    if (preg_match('!^\\$\\d+!', $fv_fp->conf['key']) && (isset($fv_fp->conf['key_automatic']) && $fv_fp->conf['key_automatic'] == 'true' || isset($fv_fp->conf['video_checker_agreement']) && $fv_fp->conf['video_checker_agreement'] == 'true')) {
        $version = get_option('fvwpflowplayer_core_ver');
        if (version_compare($fv_wp_flowplayer_core_ver, $version) == 1) {
            fv_wp_flowplayer_admin_key_update();
            fv_wp_flowplayer_delete_extensions_transients();
        }
    }
    if (isset($fv_fp->conf['disable_videochecker']) && $fv_fp->conf['disable_videochecker'] == 'false' && (!isset($fv_fp->conf['video_checker_agreement']) || $fv_fp->conf['video_checker_agreement'] != 'true') && (!isset($fv_fp->conf['key_automatic']) || $fv_fp->conf['key_automatic'] != 'true')) {
        $fv_fp->pointer_boxes['fv_flowplayer_video_checker_service'] = array('id' => '#wp-admin-bar-new-content', 'pointerClass' => 'fv_flowplayer_video_checker_service', 'heading' => __('FV Player Video Checker', 'fv_flowplayer'), 'content' => __("<p>FV Player includes a free video checker which will check your videos for any encoding errors and helps ensure smooth playback of all your videos. To work its magic, our video checker must contact our server.</p><p>Would you like to enable the video encoding checker?</p>", 'fv_flowplayer'), 'position' => array('edge' => 'top', 'align' => 'center'), 'button1' => __('Allow', 'fv_flowplayer'), 'button2' => __('Disable the video checker', 'fv_flowplayer'));
    } else {
        if (preg_match('!^\\$\\d+!', $fv_fp->conf['key']) && version_compare($fv_wp_flowplayer_core_ver, get_option('fvwpflowplayer_core_ver')) !== 0 && (!isset($fv_fp->conf['key_automatic']) || $fv_fp->conf['key_automatic'] != 'true') && (!isset($fv_fp->conf['video_checker_agreement']) || $fv_fp->conf['video_checker_agreement'] != 'true')) {
            $fv_fp->pointer_boxes['fv_flowplayer_key_automatic'] = array('id' => '#wp-admin-bar-new-content', 'pointerClass' => 'fv_flowplayer_key_automatic', 'pointerWidth' => 340, 'heading' => __('FV Flowplayer License Update', 'fv_flowplayer'), 'content' => __('New version of FV Flowplayer core has been installed for your licensed website. Please accept the automatic license key updating (connects to Foliovision servers) or update the key manually by loggin into your Foliovision account.', 'fv_flowplayer'), 'position' => array('edge' => 'top', 'align' => 'center'), 'button1' => __('Always auto-update', 'fv_flowplayer'), 'button2' => __("I'll update it manually", 'fv_flowplayer'));
        } else {
            if (version_compare($fv_wp_flowplayer_core_ver, get_option('fvwpflowplayer_core_ver')) !== 0 && preg_match('!^\\$\\d+!', $fv_fp->conf['key']) == 0) {
                update_option('fvwpflowplayer_core_ver', $fv_wp_flowplayer_core_ver);
            }
        }
    }
    if ((stripos($_SERVER['REQUEST_URI'], '/plugins.php') !== false || $_GET['page'] === 'fvplayer') && ($pnotices = get_option('fv_wordpress_flowplayer_persistent_notices'))) {
        $fv_fp->pointer_boxes['fv_flowplayer_license_expired'] = array('id' => '#wp-admin-bar-new-content', 'pointerClass' => 'fv_flowplayer_license_expired', 'pointerWidth' => 340, 'heading' => __('FV Flowplayer License Expired', 'fv_flowplayer'), 'content' => __($pnotices), 'position' => array('edge' => 'top', 'align' => 'center'), 'button1' => __('Hide this notice', 'fv_flowplayer'), 'button2' => __('I\'ll check this later', 'fv_flowplayer'));
    }
    $aOptions = get_option('fvwpflowplayer');
    if (!isset($aOptions['version']) || version_compare($fv_wp_flowplayer_ver, $aOptions['version'])) {
        //update_option( 'fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer upgraded - please click "Check template" and "Check videos" for automated check of your site at <a href="'.site_url().'/wp-admin/options-general.php?page=fvplayer">the settings page</a> for automated checks!' );
        $aOptions['version'] = $fv_wp_flowplayer_ver;
        update_option('fvwpflowplayer', $aOptions);
        $fv_fp->css_writeout();
        fv_wp_flowplayer_delete_extensions_transients();
        delete_option('fv_flowplayer_extension_install');
    }
    if (isset($_GET['page']) && $_GET['page'] == 'fvplayer') {
        wp_enqueue_script('common');
        wp_enqueue_script('wp-lists');
        wp_enqueue_script('postbox');
    }
    if (flowplayer::is_licensed()) {
        if (false === ($aCheck = get_transient('fv_flowplayer_license'))) {
            $aCheck = fv_wp_flowplayer_license_check(array('action' => 'check'));
            if ($aCheck) {
                set_transient('fv_flowplayer_license', $aCheck, 60 * 60 * 24);
            } else {
                set_transient('fv_flowplayer_license', json_decode(json_encode(array('error' => 'Error checking license')), FALSE), 60 * 60 * 24);
            }
        }
        $aCheck = get_transient('fv_flowplayer_license');
        $aInstalled = get_option('fv_flowplayer_extension_install');
        if (isset($aCheck->valid) && $aCheck->valid) {
            if (!isset($aInstalled['fv_player_pro']) || isset($_REQUEST['nonce_fv_player_pro_install']) && wp_verify_nonce($_REQUEST['nonce_fv_player_pro_install'], 'fv_player_pro_install')) {
                fv_wp_flowplayer_install_extension('fv_player_pro');
            }
            delete_option('fv_wordpress_flowplayer_persistent_notices');
        }
    }
}
 /**
  * Builds the HTML and JS code of single flowplayer instance on a page/post.
  * @param string $media URL or filename (in case it is in the /videos/ directory) of video file to be played.
  * @param array $args Array of arguments (name => value).
  * @return Returns array with 2 elements - 'html' => html code displayed anywhere on page/post, 'script' => javascript code displayed before </body> tag
  */
 function build_min_player($media, $args = array())
 {
     global $post;
     $this->hash = md5($media . $this->_salt());
     //  unique player id
     $this->aCurArgs = apply_filters('fv_flowplayer_args_pre', $args);
     $this->sHTMLAfter = false;
     $player_type = 'video';
     $rtmp = false;
     $youtube = false;
     $vimeo = false;
     $scripts_after = '';
     // returned array with new player's html and javascript content
     if (!isset($GLOBALS['fv_fp_scripts'])) {
         $GLOBALS['fv_fp_scripts'] = array();
     }
     $this->ret = array('html' => '', 'script' => $GLOBALS['fv_fp_scripts']);
     //	note: we need the white space here, it fails to add into the string on some hosts without it (???)
     /*
      *  Set common variables
      */
     $width = isset($this->conf['width']) && !empty($this->conf['width']) && intval($this->conf['width']) > 0 ? $this->conf['width'] : 320;
     $height = isset($this->conf['height']) && !empty($this->conf['height']) && intval($this->conf['height']) > 0 ? $this->conf['height'] : 240;
     if (isset($this->aCurArgs['width']) && !empty($this->aCurArgs['width'])) {
         $width = trim($this->aCurArgs['width']);
     }
     if (isset($this->aCurArgs['height']) && !empty($this->aCurArgs['height'])) {
         $height = trim($this->aCurArgs['height']);
     }
     $src1 = isset($this->aCurArgs['src1']) && !empty($this->aCurArgs['src1']) ? trim($this->aCurArgs['src1']) : false;
     $src2 = isset($this->aCurArgs['src2']) && !empty($this->aCurArgs['src2']) ? trim($this->aCurArgs['src2']) : false;
     $splash_img = $this->get_splash();
     foreach (array($media, $src1, $src2) as $media_item) {
         if (stripos($media_item, 'rtmp://') === 0) {
             $rtmp = $media_item;
         }
     }
     if ((!empty($this->aCurArgs['rtmp']) || !empty($this->conf['rtmp']) && $this->conf['rtmp'] != 'false') && !empty($this->aCurArgs['rtmp_path'])) {
         $rtmp = trim($this->aCurArgs['rtmp_path']);
     }
     list($media, $src1, $src2) = apply_filters('fv_flowplayer_media_pre', array($media, $src1, $src2), $this);
     /*
      *  Which player should be used
      */
     foreach (array($media, $src1, $src2) as $media_item) {
         if (preg_match('~\\.(mp3|wav|ogg)([?#].*?)?$~', $media_item)) {
             $player_type = 'audio';
             break;
         }
         global $post;
         if ($post) {
             $fv_flowplayer_meta = get_post_meta($post->ID, '_fv_flowplayer', true);
             if ($fv_flowplayer_meta && isset($fv_flowplayer_meta[sanitize_title($media_item)]['time'])) {
                 $this->expire_time = $fv_flowplayer_meta[sanitize_title($media_item)]['time'];
             }
         }
     }
     if (preg_match("~(youtu\\.be/|youtube\\.com/(watch\\?(.*&)?v=|(embed|v)/))([^\\?&\"'>]+)~i", $media, $aYoutube)) {
         if (isset($aYoutube[5])) {
             $youtube = $aYoutube[5];
             $player_type = 'youtube';
         }
     } else {
         if (preg_match("~^[a-zA-Z0-9-_]{11}\$~", $media, $aYoutube)) {
             if (isset($aYoutube[0])) {
                 $youtube = $aYoutube[0];
                 $player_type = 'youtube';
             }
         }
     }
     if (preg_match("~vimeo.com/(?:video/|moogaloop\\.swf\\?clip_id=)?(\\d+)~i", $media, $aVimeo)) {
         if (isset($aVimeo[1])) {
             $vimeo = $aVimeo[1];
             $player_type = 'vimeo';
         }
     } else {
         if (preg_match("~^[0-9]{8}\$~", $media, $aVimeo)) {
             if (isset($aVimeo[0])) {
                 $vimeo = $aVimeo[0];
                 $player_type = 'vimeo';
             }
         }
     }
     $aPlaylistItems = array();
     $aSplashScreens = array();
     $aCaptions = array();
     if (isset($this->aCurArgs['playlist']) && strlen(trim($this->aCurArgs['playlist'])) > 0) {
         list($playlist_items_external_html, $aPlaylistItems, $aSplashScreens, $aCaptions) = $this->build_playlist($this->aCurArgs, $media, $src1, $src2, $rtmp, $splash_img);
     }
     $this->aCurArgs = apply_filters('fv_flowplayer_args', $this->aCurArgs, $this->hash, $media, $aPlaylistItems);
     $player_type = apply_filters('fv_flowplayer_player_type', $player_type, $this->hash, $media, $aPlaylistItems, $this->aCurArgs);
     /*
      *  Video player tabs
      */
     if ($player_type == 'video' && $args['liststyle'] == 'tabs' && count($aPlaylistItems)) {
         return $this->get_tabs($aPlaylistItems, $aSplashScreens, $aCaptions);
     }
     $autoplay = false;
     //  todo: should be changed into a property
     if ($this->autoplay_count < 1) {
         if (isset($this->conf['autoplay']) && $this->conf['autoplay'] == 'true' && $this->aCurArgs['autoplay'] != 'false') {
             $this->autoplay_count++;
             $autoplay = true;
         }
         if (isset($this->aCurArgs['autoplay']) && $this->aCurArgs['autoplay'] == 'true') {
             $this->autoplay_count++;
             $autoplay = true;
         }
     }
     /*
      *  Video player
      */
     if ($player_type == 'video') {
         if (is_feed()) {
             $this->ret['html'] = '<p class="fv-flowplayer-feed"><a href="' . get_permalink() . '" title="' . __('Click to watch the video') . '">' . apply_filters('fv_flowplayer_rss_intro_splash', __('[This post contains video, click to play]'));
             if ($splash_img) {
                 $this->ret['html'] .= '<br /><img src="' . $splash_img . '" width="400" />';
             }
             $this->ret['html'] .= '</a></p>';
             $this->ret['html'] = apply_filters('fv_flowplayer_rss', $this->ret['html'], $this);
             return $this->ret;
         }
         foreach (array($media, $src1, $src2) as $media_item) {
             //if( ( strpos($media_item, 'amazonaws.com') !== false && stripos( $media_item, 'http://s3.amazonaws.com/' ) !== 0 && stripos( $media_item, 'https://s3.amazonaws.com/' ) !== 0  ) || stripos( $media_item, 'rtmp://' ) === 0 ) {  //  we are also checking amazonaws.com due to compatibility with older shortcodes
             if ($this->conf['engine'] == 'false' && stripos($media_item, '.m4v') !== false) {
                 $this->ret['script']['fv_flowplayer_browser_ff_m4v'][$this->hash] = true;
             }
             if ($this->conf['engine'] == 'false' && preg_match('~\\.(mp4|m4v|mov)~', $media_item) > 0) {
                 $this->ret['script']['fv_flowplayer_browser_chrome_mp4'][$this->hash] = true;
             }
         }
         if (!empty($media)) {
             $media = $this->get_video_url($media);
         }
         if (!empty($src1)) {
             $src1 = $this->get_video_url($src1);
         }
         if (!empty($src2)) {
             $src2 = $this->get_video_url($src2);
         }
         $mobile = isset($this->aCurArgs['mobile']) && !empty($this->aCurArgs['mobile']) ? trim($this->aCurArgs['mobile']) : false;
         if (!empty($mobile)) {
             $mobile = $this->get_video_url($mobile);
         }
         $popup = '';
         //check user agents
         $aUserAgents = array('iphone', 'ipod', 'iPad', 'aspen', 'incognito', 'webmate', 'android', 'android', 'dream', 'cupcake', 'froyo', 'blackberry9500', 'blackberry9520', 'blackberry9530', 'blackberry9550', 'blackberry9800', 'Palm', 'webos', 's8000', 'bada', 'Opera Mini', 'Opera Mobi', 'htc_touch_pro');
         $mobileUserAgent = false;
         foreach ($aUserAgents as $userAgent) {
             if (stripos($_SERVER['HTTP_USER_AGENT'], $userAgent)) {
                 $mobileUserAgent = true;
             }
         }
         $scaling = "scale";
         if (isset($this->conf['scaling']) && $this->conf['scaling'] == "true") {
             $scaling = "fit";
         } else {
             $scaling = "scale";
         }
         $subtitles = $this->get_subtitles();
         $show_splashend = false;
         if (isset($this->aCurArgs['splashend']) && $this->aCurArgs['splashend'] == 'show' && isset($this->aCurArgs['splash']) && !empty($this->aCurArgs['splash'])) {
             $show_splashend = true;
             $splashend_contents = '<div id="wpfp_' . $this->hash . '_custom_background" class="wpfp_custom_background" style="position: absolute; background: url(\'' . $splash_img . '\') no-repeat center center; background-size: contain; width: 100%; height: 100%; z-index: 1;"></div>';
         }
         $attributes = array();
         $attributes['class'] = 'flowplayer no-brand';
         if ($autoplay == false && !(isset($this->conf['auto_buffering']) && $this->conf['auto_buffering'] == 'trueDISABLED' && $this->autobuffer_count < apply_filters('fv_flowplayer_autobuffer_limit', 2))) {
             $attributes['class'] .= ' is-splash';
         }
         if (isset($this->aCurArgs['playlist_hide']) && strcmp($this->aCurArgs['playlist_hide'], 'true') == 0) {
             $attributes['class'] .= ' playlist-hidden';
         }
         //  Fixed control bar
         $bFixedControlbar = false;
         if (isset($this->conf['ui_fixed_controlbar']) && strcmp($this->conf['ui_fixed_controlbar'], 'true') == 0) {
             $bFixedControlbar = true;
         }
         if (isset($this->aCurArgs['controlbar'])) {
             if (strcmp($this->aCurArgs['controlbar'], 'yes') == 0 || strcmp($this->aCurArgs['controlbar'], 'show') == 0) {
                 $bFixedControlbar = true;
             } else {
                 if (strcmp($this->aCurArgs['controlbar'], 'no') == 0) {
                     $attributes['class'] .= ' no-controlbar';
                 }
             }
         }
         if ($bFixedControlbar) {
             $attributes['class'] .= ' fixed-controls';
         }
         //  Play button
         $bPlayButton = false;
         if (isset($this->conf['ui_play_button']) && strcmp($this->conf['ui_play_button'], 'true') == 0) {
             $bPlayButton = true;
         }
         if (isset($this->aCurArgs['play_button'])) {
             if (strcmp($this->aCurArgs['play_button'], 'yes') == 0) {
                 $bPlayButton = true;
             } else {
                 if (strcmp($this->aCurArgs['play_button'], 'no') == 0) {
                     $bPlayButton = false;
                 }
             }
         }
         if ($bPlayButton) {
             $attributes['class'] .= ' play-button';
         }
         //  Align
         if (isset($this->aCurArgs['align'])) {
             if ($this->aCurArgs['align'] == 'left') {
                 $attributes['class'] .= ' alignleft';
             } else {
                 if ($this->aCurArgs['align'] == 'right') {
                     $attributes['class'] .= ' alignright';
                 } else {
                     if ($this->aCurArgs['align'] == 'center') {
                         $attributes['class'] .= ' aligncenter';
                     }
                 }
             }
         }
         $attributes['class'] .= $this->get_align();
         if ($this->conf['engine'] == 'true' || $this->aCurArgs['engine'] == 'flash') {
             $attributes['data-engine'] = 'flash';
         }
         if (!empty($this->conf['integrations']['embed_iframe']) && $this->conf['integrations']['embed_iframe'] == 'true') {
             if ($this->aCurArgs['embed'] == 'false' || $this->conf['disableembedding'] == 'true' && $this->aCurArgs['embed'] != 'true') {
             } else {
                 $attributes['data-fv-embed'] = $this->get_embed_url();
             }
         } else {
             if ($this->aCurArgs['embed'] == 'false' || $this->conf['disableembedding'] == 'true' && $this->aCurArgs['embed'] != 'true') {
                 $attributes['data-embed'] = 'false';
             }
         }
         if (isset($this->aCurArgs['logo']) && $this->aCurArgs['logo']) {
             $attributes['data-logo'] = strcmp($this->aCurArgs['logo'], 'none') == 0 ? '' : $this->aCurArgs['logo'];
         }
         if ($this->conf['fixed_size'] == 'true') {
             $attributes['style'] = 'width: ' . $width . 'px; height: ' . $height . 'px; ';
         } else {
             $attributes['style'] = 'max-width: ' . $width . 'px; max-height: ' . $height . 'px; ';
         }
         global $fv_wp_flowplayer_ver;
         //$attributes['data-swf'] = FV_FP_RELATIVE_PATH.'/flowplayer/flowplayer.swf?ver='.$fv_wp_flowplayer_ver;  //  it's better to have this in flowplayer.conf
         //$attributes['data-flashfit'] = "true";
         if (isset($this->conf['googleanalytics']) && $this->conf['googleanalytics'] != 'false' && strlen($this->conf['googleanalytics']) > 0) {
             $attributes['data-analytics'] = $this->conf['googleanalytics'];
         }
         //  determine the RTMP server
         if (isset($this->aCurArgs['rtmp']) && !empty($this->aCurArgs['rtmp'])) {
             $attributes['data-rtmp'] = trim($this->aCurArgs['rtmp']);
         } else {
             if (isset($rtmp) && stripos($rtmp, 'rtmp://') === 0 && !(isset($this->conf['rtmp']) && $this->conf['rtmp'] != 'false' && stripos($rtmp, $this->conf['rtmp']) !== false)) {
                 if (preg_match('~/([a-zA-Z0-9]+)?:~', $rtmp)) {
                     $aTMP = preg_split('~/([a-zA-Z0-9]+)?:~', $rtmp, -1, PREG_SPLIT_DELIM_CAPTURE);
                     $attributes['data-rtmp'] = $aTMP[0];
                 } else {
                     $rtmp_info = parse_url($rtmp);
                     if (isset($rtmp_info['host']) && strlen(trim($rtmp_info['host'])) > 0) {
                         $attributes['data-rtmp'] = 'rtmp://' . $rtmp_info['host'] . '/cfx/st';
                     }
                 }
             } else {
                 if (!empty($this->conf['rtmp']) && $this->conf['rtmp'] != 'false') {
                     if (stripos($this->conf['rtmp'], 'rtmp://') === 0) {
                         $attributes['data-rtmp'] = $this->conf['rtmp'];
                         $rtmp = str_replace($this->conf['rtmp'], '', $rtmp);
                     } else {
                         $attributes['data-rtmp'] = 'rtmp://' . $this->conf['rtmp'] . '/cfx/st/';
                     }
                 }
             }
         }
         $this->get_video_checker_media($attributes, $media, $src1, $src2, $rtmp);
         if (isset($this->conf['allowfullscreen']) && $this->conf['allowfullscreen'] == 'false') {
             $attributes['data-fullscreen'] = 'false';
         }
         $ratio = round($height / $width, 4);
         $this->fRatio = $ratio;
         $attributes['data-ratio'] = str_replace(',', '.', $ratio);
         if ($scaling == "fit" && $this->conf['fixed_size'] == 'fixed') {
             $attributes['data-flashfit'] = 'true';
         }
         if (isset($this->aCurArgs['live']) && $this->aCurArgs['live'] == 'true') {
             $attributes['data-live'] = 'true';
         }
         $playlist = '';
         $is_preroll = false;
         if (isset($playlist_items_external_html)) {
             if (!isset($this->aCurArgs['playlist_hide']) || strcmp($this->aCurArgs['playlist_hide'], 'true') != 0) {
                 $this->sHTMLAfter .= $playlist_items_external_html;
             }
             $this->aPlaylists["wpfp_{$this->hash}"] = $aPlaylistItems;
             $attributes['style'] .= "background-image: url({$splash_img});";
             if ($autoplay) {
                 $this->ret['script']['fv_flowplayer_autoplay'][$this->hash] = true;
                 //  todo: any better way?
                 $attributes['class'] .= ' is-splash';
             }
         } else {
             if (!empty($this->aCurArgs['caption'])) {
                 $attributes['class'] .= ' has-caption';
                 $this->sHTMLAfter = apply_filters('fv_player_caption', "<p class='fp-caption'>" . $this->aCurArgs['caption'] . "</p>", $this);
             }
         }
         if (!empty($this->aCurArgs['redirect'])) {
             $attributes['data-fv_redirect'] = trim($this->aCurArgs['redirect']);
         }
         if (isset($this->aCurArgs['loop']) && $this->aCurArgs['loop'] == 'true') {
             $attributes['data-fv_loop'] = true;
         }
         if (isset($this->aCurArgs['admin_warning'])) {
             $this->sHTMLAfter .= wpautop($this->aCurArgs['admin_warning']);
         }
         $attributes_html = '';
         $attributes = apply_filters('fv_flowplayer_attributes', $attributes, $media, $this);
         foreach ($attributes as $attr_key => $attr_value) {
             $attributes_html .= ' ' . $attr_key . '="' . esc_attr($attr_value) . '"';
         }
         $this->ret['html'] .= '<div id="wpfp_' . $this->hash . '"' . $attributes_html . '>' . "\n";
         if (count($aPlaylistItems) == 0) {
             // todo: this stops subtitles, mobile video, preload etc.
             $this->ret['html'] .= "\t" . '<video';
             if (isset($splash_img) && !empty($splash_img)) {
                 $this->ret['html'] .= ' poster="' . flowplayer::get_encoded_url($splash_img) . '"';
             }
             if ($autoplay == true) {
                 $this->ret['html'] .= ' autoplay';
             }
             if (isset($this->conf['auto_buffering']) && $this->conf['auto_buffering'] == 'trueDISABLED' && $this->autobuffer_count < apply_filters('fv_flowplayer_autobuffer_limit', 2)) {
                 $this->ret['html'] .= ' preload';
                 //$this->ret['html'] .= ' id="wpfp_'.$this->hash.'_video"';
             } else {
                 if ($autoplay == false) {
                     $this->ret['html'] .= ' preload="none"';
                 }
             }
             $scripts_after .= $this->get_chrome_fail_code($media, $src1, $src2, $attributes_html);
             $this->ret['html'] .= ">\n";
             foreach (apply_filters('fv_player_media', array($media, $src1, $src2), $this) as $media_item) {
                 $this->ret['html'] .= $this->get_video_src($media_item, array('mobileUserAgent' => $mobileUserAgent, 'rtmp' => $rtmp));
             }
             if (!empty($mobile)) {
                 $this->ret['script']['fv_flowplayer_mobile_switch'][$this->hash] = true;
                 $this->ret['html'] .= $this->get_video_src($mobile, array('id' => 'wpfp_' . $this->hash . '_mobile', 'mobileUserAgent' => $mobileUserAgent, 'rtmp' => $rtmp));
             }
             if (isset($rtmp) && !empty($rtmp)) {
                 foreach (apply_filters('fv_player_media_rtmp', array($rtmp), $this) as $rtmp_item) {
                     $rtmp_item = apply_filters('fv_flowplayer_video_src', $rtmp_item, $this);
                     if (preg_match('~([a-zA-Z0-9]+)?:~', $rtmp)) {
                         $aTMP = preg_split('~([a-zA-Z0-9]+)?:~', $rtmp, -1, PREG_SPLIT_DELIM_CAPTURE);
                         if (isset($aTMP[1]) && isset($aTMP[2])) {
                             $rtmp_file = $aTMP[2];
                             $extension = $this->get_mime_type($rtmp_file, $aTMP[1], true);
                         } else {
                             $rtmp_file = $aTMP[1];
                             $extension = $this->get_mime_type($rtmp_file, false, true);
                         }
                     } else {
                         $rtmp_url = parse_url($rtmp_item);
                         $rtmp_file = $rtmp_url['path'] . (!empty($rtmp_url['query']) ? '?' . str_replace('&amp;', '&', $rtmp_url['query']) : '');
                         $extension = $this->get_mime_type($rtmp_url['path'], false, true);
                     }
                     if ($extension) {
                         $extension .= ':';
                     } else {
                         //$extension = 'mp4:';  //  https://github.com/flowplayer/flowplayer/search?q=rtmp&type=Issues&utf8=%E2%9C%93
                     }
                     $this->ret['html'] .= "\t" . "\t" . '<source src="' . $extension . trim($rtmp_file, " \t\n\r\v/") . '" type="video/flash" />' . "\n";
                 }
             }
             if (isset($subtitles) && !empty($subtitles)) {
                 $sExtra = isset($this->conf['subtitleOn']) && strcmp($this->conf['subtitleOn'], 'true') == 0 ? 'default ' : '';
                 $aLang = explode('-', get_bloginfo('language'));
                 $sExtra .= !empty($aLang[0]) ? 'srclang="' . $aLang[0] . '" ' : '';
                 $sCaption = false;
                 if (!empty($aLang[0]) && $aLang[0] == 'en') {
                     $sCaption = 'English';
                 } elseif (!empty($aLang[0])) {
                     $translations = get_site_transient('available_translations');
                     $sLangCode = str_replace('-', '_', get_bloginfo('language'));
                     if ($translations && isset($translations[$sLangCode]) && !empty($translations[$sLangCode]['native_name'])) {
                         $sCaption = $translations[$sLangCode]['native_name'];
                     }
                 }
                 $sExtra .= $sCaption ? 'label="' . $sCaption . '" ' : '';
                 $this->ret['html'] .= "\t" . "\t" . '<track ' . $sExtra . 'src="' . esc_attr($subtitles) . '" />' . "\n";
             }
             $this->ret['html'] .= "\t" . '</video>';
             //."\n";
         }
         $this->ret['html'] .= $this->get_buttons();
         if (isset($splashend_contents)) {
             $this->ret['html'] .= $splashend_contents;
         }
         if ($popup_contents = $this->get_popup_code()) {
             $this->aPopups["wpfp_{$this->hash}"] = $popup_contents;
         }
         if ($ad_contents = $this->get_ad_code()) {
             $this->aAds["wpfp_{$this->hash}"] = $ad_contents;
         }
         if (flowplayer::is_special_editor()) {
             $this->ret['html'] .= '<div class="fp-ui"></div>';
         } else {
             if (current_user_can('manage_options') && !isset($playlist_items_external_html)) {
                 $this->ret['html'] .= '<div id="wpfp_' . $this->hash . '_admin_error" class="fvfp_admin_error"><div class="fvfp_admin_error_content"><h4>Admin JavaScript warning:</h4><p>I\'m sorry, your JavaScript appears to be broken. Please use "Check template" in plugin settings, read our <a href="https://foliovision.com/player/installation#fixing-broken-javascript">troubleshooting guide</a> or <a href="http://foliovision.com/wordpress/pro-install">order our pro support</a> and we will get it fixed for you.</p></div></div>';
             }
         }
         $this->ret['html'] .= apply_filters('fv_flowplayer_inner_html', null, $this);
         $this->ret['html'] .= $this->get_sharing_html() . "\n";
         if (current_user_can('manage_options') && $this->conf['disable_videochecker'] != 'true') {
             $this->ret['html'] .= $this->get_video_checker_html() . "\n";
         }
         $this->ret['html'] .= '</div>' . "\n";
         $this->ret['html'] .= $this->sHTMLAfter . $scripts_after . "<!--fv player end-->";
         //  change engine for IE9 and 10
         if ($this->aCurArgs['engine'] == 'false') {
             $this->ret['script']['fv_flowplayer_browser_ie'][$this->hash] = true;
         }
     } else {
         if ($player_type == 'youtube') {
             $sAutoplay = $autoplay ? 'autoplay=1&amp;' : '';
             $this->ret['html'] .= "<iframe id='fv_ytplayer_{$this->hash}' type='text/html' width='{$width}' height='{$height}'\n\t  src='http://www.youtube.com/embed/{$youtube}?{$sAutoplay}origin=" . urlencode(get_permalink()) . "' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>\n";
         } else {
             if ($player_type == 'vimeo') {
                 $sAutoplay = $autoplay ? " autoplay='1'" : "";
                 $this->ret['html'] .= "<iframe id='fv_vimeo_{$this->hash}' src='//player.vimeo.com/video/{$vimeo}' width='{$width}' height='{$height}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen{$sAutoplay}></iframe>\n";
             } else {
                 //	$player_type == 'video' ends
                 $this->build_audio_player($media, $width, $autoplay);
             }
         }
     }
     $this->ret['html'] = apply_filters('fv_flowplayer_html', $this->ret['html'], $this);
     $this->ret['script'] = apply_filters('fv_flowplayer_scripts_array', $this->ret['script'], 'wpfp_' . $this->hash, $media);
     return $this->ret;
 }
Example #3
0
function fv_flowplayer_the_content($c)
{
    if (flowplayer::is_special_editor()) {
        return $c;
    }
    $c = preg_replace('!<p[^>]*?>(\\[(?:fvplayer|flowplayer).*?[^\\\\]\\])</p>!', "\n" . '$1' . "\n", $c);
    $c = preg_replace_callback('!\\[(?:fvplayer|flowplayer).*?[^\\\\]\\]!', 'fv_flowplayer_shortfcode_fix_attrs', $c);
    return $c;
}
Example #4
0
function fv_flowplayer_admin_pro()
{
    global $fv_fp;
    if (flowplayer::is_licensed()) {
        $aCheck = get_transient('fv_flowplayer_license');
    }
    if (isset($aCheck->valid) && $aCheck->valid) {
        ?>
  
    <p>Valid license found, click the button at the top of the screen to install FV Player Pro!</p>
  <?php 
    } else {
        ?>
    <p><a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/download">Purchase FV Flowplayer license</a> to enable Pro features!</p>
  <?php 
    }
    ?>
  <table class="form-table2">
    <tr>
      <td><label>Advanced Vimeo embeding:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Use Vimeo as your video host and use all of FV Flowplayer features.
        </p>
      </td>
    </tr>
    <tr>
      <td><label>Advanced Youtube embeding:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Use Youtube as your video host and use all of FV Flowplayer features.
        </p>
      </td>
    </tr>
    <tr>
      <td><label>Enable user defined AB loop:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Let your users repeat the parts of the video which they like!
        </p>
      </td>
    </tr>    
    <tr>
      <td><label>Enable video lightbox:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Enables Lightbox video gallery to show videos in a lightbox popup!
        </p>
      </td>
    </tr>
    <tr>
      <td><label>Enable quality switching:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Upload your videos in multiple quality for best user experience with Youtube-like quality switching!
        </p>
      </td>
    </tr>
    <tr>
      <td><label>Amazon CloudFront protected content:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Protect your Amazon CDN hosted videos.
        </p>
      </td>
    </tr>        
    <tr>
      <td><label>Use video lightbox for images as well:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" disabled="true" />
          Will group images as well as videos into the same lightbox gallery.
        </p>
      </td>
    </tr>
    <tr>
      <td><label>Autoplay just once:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" disabled="true" />
          Makes sure each video autoplays only once for each visitor.
        </p>
      </td>
    </tr>    
  </table>
  <p>Upcoming pro features:</p>
  <table class="form-table2">
    <tr>
      <td><label>Enable PayWall:</label></td>
      <td>
        <p class="description">
          <input type="checkbox" checked="checked" disabled="true" />
          Monetize the video content on your membership site.
        </p>
      </td>
    </tr>  
  </table>  
  <?php 
}
Example #5
0
 public static function is_special_editor()
 {
     return flowplayer::is_optimizepress() || flowplayer::is_themify();
 }
Example #6
0
 public function check_mimetype($URLs = false, $meta = false)
 {
     add_action('http_api_curl', array('FV_Player_Checker', 'http_api_curl'));
     $tStart = microtime(true);
     global $fv_wp_flowplayer_ver, $fv_fp;
     if (!empty($meta)) {
         extract($meta, EXTR_SKIP);
     }
     if (defined('DOING_AJAX') && DOING_AJAX && isset($_POST['media']) && stripos($_SERVER['HTTP_REFERER'], home_url()) === 0) {
         $URLs = json_decode(stripslashes(trim($_POST['media'])));
     }
     if (isset($URLs)) {
         $all_sources = $URLs;
         foreach ($all_sources as $source) {
             if (preg_match('!^rtmp://!', $source, $match)) {
                 $found_rtmp = true;
             } else {
                 if (!isset($media) && !preg_match('!\\.(m3u8ALLOW|m3uALLOW|avi)$!', $source)) {
                     $media = $source;
                 }
             }
         }
         //$random = rand( 0, 10000 );
         $random = isset($_POST['hash']) ? trim($_POST['hash']) : false;
         if (isset($media)) {
             $remotefilename = $media;
             $remotefilename_encoded = flowplayer::get_encoded_url($remotefilename);
             if ($fv_fp->is_secure_amazon_s3($remotefilename_encoded) || 1 > 0) {
                 //	skip headers check for Amazon S3, as it's slow
                 $headers = false;
             } else {
                 $headers = wp_remote_head(trim(str_replace(' ', '%20', $remotefilename_encoded)), array('method' => 'GET', 'redirection' => 3));
             }
             $bValidFile = true;
             if (is_wp_error($headers)) {
                 $video_errors[] = 'Error checking ' . $media . '!<br />' . print_r($headers, true);
             } else {
                 if ($headers) {
                     list($aVideoErrors, $sContentType, $bFatal) = $this->check_headers($headers, $remotefilename, $random);
                     if ($bFatal) {
                         $bValidFile = false;
                     }
                     if ($aVideoErrors) {
                         $video_errors = array_merge($video_errors, $aVideoErrors);
                     }
                 }
                 if (function_exists('is_utf8') && is_utf8($remotefilename)) {
                     $video_errors[] = '<p><strong>UTF-8 error</strong>: Your file name is using non-latin characters, the file might not play in browsers using Flash for the video!</p>';
                 }
                 if (@ini_get('safe_mode')) {
                     $video_warnings[] = 'Detailed video check is not available with PHP Safe Mode On. Please contact your webhost support.';
                 } else {
                     if (!class_exists('getID3')) {
                         require ABSPATH . WPINC . '/ID3/getid3.php';
                     }
                     $getID3 = new getID3();
                     if (!function_exists('curl_init')) {
                         $video_errors[] = 'cURL for PHP not found, please contact your server administrator.';
                     } else {
                         $message = '<p>Analysis of <a class="bluelink" target="_blank" href="' . esc_attr($remotefilename_encoded) . '">' . $remotefilename_encoded . '</a></p>';
                         //	taken from: http://www.getid3.org/phpBB3/viewtopic.php?f=3&t=1141
                         $upload_dir = wp_upload_dir();
                         $localtempfilename = trailingslashit($upload_dir['basedir']) . 'fv_flowlayer_tmp_' . md5(rand(1, 999)) . '_' . basename(substr($remotefilename_encoded, 0, 32));
                         $out = fopen($localtempfilename, 'wb');
                         if ($out) {
                             $aArgs = array('file' => $localtempfilename);
                             if (!$this->is_cron) {
                                 $aArgs['quick_check'] = apply_filters('fv_flowplayer_checker_timeout_quick', 2);
                             }
                             list($header, $sHTTPError) = $this->http_request($remotefilename_encoded, $aArgs);
                             $video_errors = array();
                             if ($sHTTPError) {
                                 $video_errors[] = $sHTTPError;
                                 $bValidFile = false;
                             }
                             fclose($out);
                             if (!$headers) {
                                 $headers = WP_Http::processHeaders($header);
                                 list($aVideoErrors, $sContentType, $bFatal) = $this->check_headers($headers, $remotefilename, $random);
                                 if ($bFatal) {
                                     $bValidFile = false;
                                 }
                                 if ($aVideoErrors) {
                                     $video_errors = array_merge($video_errors, $aVideoErrors);
                                 }
                                 if (isset($hearders['headers']['server']) && $hearders['headers']['server'] == 'AmazonS3' && $headers['response']['code'] == '403') {
                                     $error = new SimpleXMLElement($body);
                                     if (stripos($error->Message, 'Request has expired') !== false) {
                                         $video_errors[] = '<p><strong>Amazon S3</strong>: Your secure link is expired, there might be problem with your Amazon S3 plugin. Please test if the above URL opens in your browser.</p>';
                                     } else {
                                         $video_errors[] = '<p><strong>Amazon S3</strong>: ' . $error->Message . '</p>';
                                     }
                                 }
                             }
                             if ($bValidFile) {
                                 $ThisFileInfo = $getID3->analyze($localtempfilename);
                             }
                             if (!@unlink($localtempfilename)) {
                                 $video_errors[] = 'Can\'t remove temporary file for video analysis in <tt>' . $localtempfilename . '</tt>!';
                             }
                         } else {
                             $video_errors[] = 'Can\'t create temporary file for video analysis in <tt>' . $localtempfilename . '</tt>!';
                         }
                     }
                     /*
                     Only check file length
                     */
                     if (isset($meta_action) && $meta_action == 'check_time') {
                         $time = false;
                         if (isset($ThisFileInfo) && isset($ThisFileInfo['playtime_seconds'])) {
                             $time = $ThisFileInfo['playtime_seconds'];
                         }
                         $time = apply_filters('fv_flowplayer_checker_time', $time, $meta_original);
                         global $post;
                         $fv_flowplayer_meta = get_post_meta($post->ID, flowplayer::get_video_key($meta_original), true);
                         $fv_flowplayer_meta = $fv_flowplayer_meta ? $fv_flowplayer_meta : array();
                         $fv_flowplayer_meta['duration'] = $time;
                         $fv_flowplayer_meta['etag'] = isset($headers['headers']['etag']) ? $headers['headers']['etag'] : false;
                         //  todo: check!
                         $fv_flowplayer_meta['date'] = time();
                         $fv_flowplayer_meta['check_time'] = microtime(true) - $tStart;
                         if ($time > 0 || $this->is_cron) {
                             update_post_meta($post->ID, flowplayer::get_video_key($meta_original), $fv_flowplayer_meta);
                             return true;
                         }
                         //} else {
                         //self::queue_add($post->ID);
                         //return false;
                         //}
                     }
                 }
             }
             //	end is_wp_error check
         }
         //	end isset($media)
     }
 }
function flowplayer_styles()
{
    flowplayer::load_styles();
}
    /**
     * main routine to convert old school module data into new controller format
     * @global db the exponent database object
     * @param  $iloc
     * @param  $module
     * @param int $hc
     * @return
     */
    private function convert($iloc, $module, $hc = 0)
    {
        if (!array_key_exists($iloc->mod, $this->params['migrate'])) {
            return $module;
        }
        global $db;
        $old_db = $this->connect();
        $linked = false;
        $loc = null;
        switch ($iloc->mod) {
            case 'textmodule':
                @($module->view = 'showall');
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'textmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'textmodule';
                $textitems = $old_db->selectObjects('textitem', "location_data='" . serialize($iloc) . "'");
                if ($textitems) {
                    foreach ($textitems as $ti) {
                        $text = new text();
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "text";
                        $text->location_data = serialize($loc);
                        $text->body = $ti->text;
                        $text->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'rotatormodule':
                $module->action = 'showRandom';
                $module->view = 'showRandom';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'rotatormodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'rotatormodule';
                $textitems = $old_db->selectObjects('rotator_item', "location_data='" . serialize($iloc) . "'");
                if ($textitems) {
                    foreach ($textitems as $ti) {
                        $text = new text();
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "text";
                        $text->location_data = serialize($loc);
                        $text->body = $ti->text;
                        $text->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'snippetmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "snippet";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'snippetmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'snippetmodule';
                $textitems = $old_db->selectObjects('textitem', "location_data='" . serialize($iloc) . "'");
                if ($textitems) {
                    foreach ($textitems as $ti) {
                        $text = new snippet();
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "snippet";
                        $text->location_data = serialize($loc);
                        $text->body = $ti->text;
                        // if the item exists in the current db, we won't save it
                        $te = $text->find('first', "location_data='" . $text->location_data . "'");
                        if (empty($te)) {
                            $text->save();
                            @$this->msg['migrated'][$iloc->mod]['count']++;
                            @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        }
                    }
                }
                break;
            case 'linklistmodule':
                switch ($module->view) {
                    case 'Quick Links':
                        @($module->view = "showall_quicklinks");
                        break;
                    default:
                        @($module->view = 'showall');
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "links";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'linklistmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'linklistmodule';
                $links = $old_db->selectArrays('linklist_link', "location_data='" . serialize($iloc) . "'");
                if ($links) {
                    foreach ($links as $link) {
                        $lnk = new links();
                        $loc = expUnserialize($link['location_data']);
                        $loc->mod = "links";
                        $lnk->title = !empty($link['name']) ? $link['name'] : 'Untitled';
                        $lnk->body = $link['description'];
                        $lnk->new_window = $link['opennew'];
                        $lnk->url = !empty($link['url']) ? $link['url'] : '#';
                        $lnk->rank = $link['rank'];
                        $lnk->poster = 1;
                        $lnk->editor = 1;
                        $lnk->location_data = serialize($loc);
                        $lnk->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'linkmodule':
                // user mod, not widely distributed
                switch ($module->view) {
                    case 'Summary':
                        @($module->view = "showall_quicklinks");
                        break;
                    default:
                        @($module->view = 'showall');
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "links";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'linkmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'linkmodule';
                $links = $old_db->selectArrays('link', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('linkmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($links) {
                    foreach ($links as $link) {
                        $lnk = new links();
                        $loc = expUnserialize($link['location_data']);
                        $loc->mod = "links";
                        $lnk->title = !empty($link['name']) ? $link['name'] : 'Untitled';
                        $lnk->body = $link['description'];
                        $lnk->new_window = $link['opennew'];
                        $lnk->url = !empty($link['url']) ? $link['url'] : '#';
                        $lnk->rank = $link['rank'];
                        $lnk->poster = 1;
                        $lnk->editor = 1;
                        $lnk->location_data = serialize($loc);
                        $lnk->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                    if ($oldconfig->enable_rss == 1) {
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newconfig = new expConfig();
                        $newconfig->config = $config;
                        $newconfig->location_data = $loc;
                        $newconfig->save();
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        $newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                }
                break;
            case 'swfmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'swfmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'swfmodule';
                $swfitems = $old_db->selectObjects('swfitem', "location_data='" . serialize($iloc) . "'");
                if ($swfitems) {
                    foreach ($swfitems as $ti) {
                        $text = new text();
                        $file = new expFile($ti->swf_id);
                        $loc = expUnserialize($ti->location_data);
                        $loc->mod = "text";
                        $text->location_data = serialize($loc);
                        $text->title = $ti->name;
                        $swfcode = '
							<p>
							 <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" height="' . $ti->height . '" width="' . $ti->width . '">
								 <param name="bgcolor" value="' . $ti->bgcolor . '" />
									' . ($ti->transparentbg ? "<param name=\"wmode\" value=\"transparent\" />" : "") . '
								 <param name="quality" value="high" />
								 <param name="movie" value="' . $file->path_relative . '" />
								 <embed bgcolor= "' . $ti->bgcolor . '" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="' . $file->path_relative . '" type="application/x-shockwave-flash" height="' . $ti->height . '" width="' . $ti->width . '"' . ($ti->transparentbg ? " wmode=\"transparent\"" : "") . '>
								 </embed>
							 </object>
							</p>
						';
                        $text->body = $swfcode;
                        $text->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'newsmodule':
                if ($module->view == 'Featured News') {
                    $only_featured = true;
                }
                switch ($module->view) {
                    case 'Headlines':
                        $module->view = 'showall_headlines';
                        break;
                    case 'Summary':
                        $module->view = 'showall_summary';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "news";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'newsmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'newsmodule';
                $newsitems = $old_db->selectArrays('newsitem', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('newsmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($newsitems) {
                    $files_attached = false;
                    foreach ($newsitems as $ni) {
                        unset($ni['id']);
                        $news = new news($ni);
                        $loc = expUnserialize($ni['location_data']);
                        $loc->mod = "news";
                        $news->location_data = serialize($loc);
                        $news->title = !empty($ni['title']) ? $ni['title'] : gt('Untitled');
                        $news->body = !empty($ni['body']) ? $ni['body'] : gt('(empty)');
                        $news->save();
                        // default is to create with current time
                        $news->created_at = $ni['posted'];
                        $news->edited_at = $ni['edited'];
                        $news->update();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        if (!empty($ni['file_id'])) {
                            $file = new expFile($ni['file_id']);
                            $news->attachitem($file, '');
                            $files_attached = true;
                        }
                    }
                    $newconfig = new expConfig();
                    if ($files_attached) {
                        // fudge a config to get attached files to appear
                        $newconfig->config = 'a:14:{s:9:"feedmaker";s:0:"";s:11:"filedisplay";s:7:"Gallery";s:6:"ffloat";s:4:"Left";s:6:"fwidth";s:3:"120";s:7:"fmargin";s:1:"5";s:7:"piwidth";s:3:"100";s:5:"thumb";s:3:"100";s:7:"spacing";s:2:"10";s:10:"floatthumb";s:8:"No Float";s:6:"tclass";s:0:"";s:5:"limit";s:0:"";s:9:"pagelinks";s:14:"Top and Bottom";s:10:"feed_title";s:0:"";s:9:"feed_desc";s:0:"";}';
                    }
                    if ($oldconfig->enable_rss == 1) {
                        if ($newconfig->config != null) {
                            $config = expUnserialize($newconfig->config);
                        }
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newconfig->config = $config;
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        $newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                    if ($only_featured) {
                        $newconfig->config['only_featured'] = true;
                    }
                    if ($newconfig != null) {
                        $newconfig->location_data = $loc;
                        $newconfig->save();
                    }
                }
                break;
            case 'resourcesmodule':
                switch ($module->view) {
                    case 'One Click Download - Descriptive':
                        $module->view = 'showall_quick_download_with_description';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "filedownload";
                if ($db->countObjects('filedownloads', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'resourcesmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'resourcesmodule';
                $resourceitems = $old_db->selectArrays('resourceitem', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('resourcesmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($resourceitems) {
                    foreach ($resourceitems as $ri) {
                        unset($ri['id']);
                        $filedownload = new filedownload($ri);
                        $loc = expUnserialize($ri['location_data']);
                        $loc->mod = "filedownload";
                        $filedownload->title = !empty($ri['name']) ? $ri['name'] : 'Untitled';
                        $filedownload->body = $ri['description'];
                        $filedownload->downloads = $ri['num_downloads'];
                        $filedownload->location_data = serialize($loc);
                        if (!empty($ri['file_id'])) {
                            $filedownload->save();
                            @$this->msg['migrated'][$iloc->mod]['count']++;
                            @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                            $file = new expFile($ri['file_id']);
                            $filedownload->attachitem($file, 'downloadable');
                            // default is to create with current time
                            $filedownload->created_at = $ri['posted'];
                            $filedownload->edited_at = $ri['edited'];
                            $filedownload->update();
                        }
                    }
                    if (isset($oldconfig->enable_rss)) {
                        $dorss = $oldconfig->enable_rss;
                    } elseif (isset($oldconfig->enable_podcasting)) {
                        $dorss = $oldconfig->enable_podcasting;
                    } else {
                        $dorss = false;
                    }
                    if ($dorss) {
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newconfig = new expConfig();
                        $newconfig->config = $config;
                        $newconfig->location_data = $loc;
                        $newconfig->save();
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        //						$newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->enable_rss = true;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                }
                break;
            case 'imagegallerymodule':
                switch ($module->view) {
                    case 'Slideshow':
                        $module->action = 'slideshow';
                        $module->view = 'showall';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "photos";
                if ($db->countObjects('photo', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'imagegallerymodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'imagegallerymodule';
                $galleries = $old_db->selectArrays('imagegallery_gallery', "location_data='" . serialize($iloc) . "'");
                if ($galleries) {
                    foreach ($galleries as $gallery) {
                        $gis = $old_db->selectArrays('imagegallery_image', "gallery_id='" . $gallery['id'] . "'");
                        foreach ($gis as $gi) {
                            $photo = new photo();
                            $loc = expUnserialize($gallery['location_data']);
                            $loc->mod = "photos";
                            $photo->title = !empty($gi['name']) ? $gi['name'] : 'Untitled';
                            $photo->body = $gi['description'];
                            $photo->alt = $gi['alt'];
                            $photo->location_data = serialize($loc);
                            if (!empty($gi['file_id'])) {
                                $photo->save();
                                @$this->msg['migrated'][$iloc->mod]['count']++;
                                @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                                $file = new expFile($gi['file_id']);
                                $photo->attachitem($file, '');
                                $photo->created_at = $gi['posted'];
                                $photo->edited_at = $gi['posted'];
                                $photo->update(array("validate" => false));
                            }
                        }
                    }
                }
                break;
            case 'slideshowmodule':
                $module->action = 'slideshow';
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "photos";
                if ($db->countObjects('photo', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'slideshowmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'slideshowmodule';
                $galleries = $old_db->selectArrays('imagegallery_gallery', "location_data='" . serialize($iloc) . "'");
                if ($galleries) {
                    foreach ($galleries as $gallery) {
                        $gis = $old_db->selectArrays('imagegallery_image', "gallery_id='" . $gallery['id'] . "'");
                        foreach ($gis as $gi) {
                            $photo = new photo();
                            $loc = expUnserialize($gallery['location_data']);
                            $loc->mod = "photos";
                            $photo->title = !empty($gi['name']) ? $gi['name'] : 'Untitled';
                            $photo->body = $gi['description'];
                            $photo->alt = $gi['alt'];
                            $photo->location_data = serialize($loc);
                            $te = $photo->find('first', "location_data='" . $photo->location_data . "'");
                            if (empty($te)) {
                                if (!empty($gi['file_id'])) {
                                    $photo->save();
                                    @$this->msg['migrated'][$iloc->mod]['count']++;
                                    @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                                    $file = new expFile($gi['file_id']);
                                    $photo->attachitem($file, '');
                                    $photo->created_at = $gi['posted'];
                                    $photo->edited_at = $gi['posted'];
                                    $photo->update();
                                }
                            }
                        }
                    }
                }
                break;
            case 'headlinemodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "text";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'headlinemodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'headlinemodule';
                $headlines = $old_db->selectObjects('headline', "location_data='" . serialize($iloc) . "'");
                if ($headlines) {
                    foreach ($headlines as $hl) {
                        $headline = new text();
                        $loc = expUnserialize($hl->location_data);
                        $loc->mod = "text";
                        $headline->location_data = serialize($loc);
                        $headline->title = $hl->headline;
                        $headline->poster = 1;
                        //                        $headline->created_at = time();
                        //                        $headline->edited_at = time();
                        $headline->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'weblogmodule':
                switch ($module->view) {
                    case 'By Author':
                        $module->action = 'authors';
                        $module->view = 'authors';
                        break;
                    case 'By Tag':
                        $module->action = 'tags';
                        $module->view = 'tags_list';
                        break;
                    case 'Monthly':
                        $module->action = 'dates';
                        $module->view = 'dates';
                        break;
                    default:
                        $module->view = 'showall';
                        break;
                }
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "blog";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'weblogmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'weblogmodule';
                $blogitems = $old_db->selectArrays('weblog_post', "location_data='" . serialize($iloc) . "'");
                $oldconfig = $old_db->selectObject('weblogmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($blogitems) {
                    foreach ($blogitems as $bi) {
                        unset($bi['id']);
                        $post = new blog($bi);
                        $loc = expUnserialize($bi['location_data']);
                        $loc->mod = "blog";
                        $post->location_data = serialize($loc);
                        $post->title = !empty($bi['title']) ? $bi['title'] : gt('Untitled');
                        $post->body = !empty($bi['body']) ? $bi['body'] : gt('(empty)');
                        $post->save();
                        // default is to create with current time
                        $post->created_at = $bi['posted'];
                        $post->edited_at = $bi['edited'];
                        $post->update();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        // this next section is moot since there are no attachments to blogs
                        // if (!empty($bi['file_id'])) {
                        // $file = new expFile($bi['file_id']);
                        // $post->attachitem($file,'downloadable');
                        // }
                        if (isset($oldconfig->enable_tags) && ($oldconfig->enable_tags = true)) {
                            $params = null;
                            $oldtags = expUnserialize($bi['tags']);
                            foreach ($oldtags as $oldtag) {
                                $tagtitle = strtolower(trim($old_db->selectValue('tags', 'name', 'id = ' . $oldtag)));
                                $tag = new expTag($tagtitle);
                                //								$tag->title = $old_db->selectValue('tags','name','id = '.$oldtag);
                                if (empty($tag->id)) {
                                    $tag->update(array('title' => $tagtitle));
                                }
                                $params['expTag'][] = $tag->id;
                            }
                            $post->update($params);
                        }
                        $comments = $old_db->selectArrays('weblog_comment', "parent_id='" . $post->id . "'");
                        foreach ($comments as $comment) {
                            unset($comment['id']);
                            $newcomment = new expComment($comment);
                            $newcomment->created_at = $comment['posted'];
                            $newcomment->edited_at = $comment['edited'];
                            $newcomment->update();
                            // attach the comment to the blog post it belongs to
                            $obj->content_type = 'blog';
                            $obj->content_id = $post->id;
                            $obj->expcomments_id = $newcomment->id;
                            if (isset($this->params['subtype'])) {
                                $obj->subtype = $this->params['subtype'];
                            }
                            $db->insertObject($obj, $newcomment->attachable_table);
                        }
                    }
                    $newconfig = new expConfig();
                    $config['add_source'] = '1';
                    if ($oldconfig->enable_rss == 1) {
                        $config['enable_rss'] = true;
                        $config['feed_title'] = $oldconfig->feed_title;
                        $config['feed_desc'] = $oldconfig->feed_desc;
                        $config['rss_limit'] = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $config['rss_cachetime'] = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss = new expRss();
                        $newrss->module = $loc->mod;
                        $newrss->src = $loc->src;
                        $newrss->enable_rss = $oldconfig->enable_rss;
                        $newrss->feed_title = $oldconfig->feed_title;
                        $newrss->feed_desc = $oldconfig->feed_desc;
                        $newrss->rss_limit = isset($oldconfig->rss_limit) ? $oldconfig->rss_limit : 24;
                        $newrss->rss_cachetime = isset($oldconfig->rss_cachetime) ? $oldconfig->rss_cachetime : 1440;
                        $newrss->save();
                    }
                    $newconfig->config = $config;
                    $newconfig->location_data = $loc;
                    $newconfig->save();
                }
                break;
            case 'faqmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "faq";
                if ($db->countObjects('faqs', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'faqmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'faqmodule';
                $faqs = $old_db->selectArrays('faq', "location_data='" . serialize($iloc) . "'");
                if ($faqs) {
                    foreach ($faqs as $fqi) {
                        unset($fqi['id']);
                        $faq = new faq($fqi);
                        $loc = expUnserialize($fqi['location_data']);
                        $loc->mod = "faq";
                        $faq->location_data = serialize($loc);
                        $faq->question = !empty($fqi['question']) ? $fqi['question'] : 'Untitled?';
                        $faq->answer = $fqi['answer'];
                        $faq->rank = $fqi['rank'];
                        $faq->include_in_faq = 1;
                        $faq->submitter_name = 'Unknown';
                        $faq->submitter_email = '*****@*****.**';
                        $faq->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'listingmodule':
                $module->view = 'showall';
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "portfolio";
                if ($db->countObjects($ploc->mod, "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'listingmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'listingmodule';
                $listingitems = $old_db->selectArrays('listing', "location_data='" . serialize($iloc) . "'");
                if ($listingitems) {
                    $files_attached = false;
                    foreach ($listingitems as $li) {
                        unset($li['id']);
                        $listing = new portfolio($li);
                        $listing->title = !empty($li['name']) ? $li['name'] : 'Untitled?';
                        $loc = expUnserialize($li['location_data']);
                        $loc->mod = "portfolio";
                        $listing->location_data = serialize($loc);
                        $listing->featured = true;
                        $listing->poster = 1;
                        $listing->body = "<p>" . $li['summary'] . "</p>" . $li['body'];
                        $listing->save();
                        // default is to create with current time
                        $listing->created_at = time();
                        $listing->edited_at = time();
                        $listing->update();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                        if (!empty($li['file_id'])) {
                            $file = new expFile($li['file_id']);
                            $listing->attachitem($file, '');
                            $files_attached = true;
                        }
                    }
                    if ($files_attached) {
                        // fudge a config to get attached files to appear
                        $config = new expConfig();
                        $config->location_data = $loc;
                        $config->config = 'a:11:{s:11:"filedisplay";s:7:"Gallery";s:6:"ffloat";s:4:"Left";s:6:"fwidth";s:3:"120";s:7:"fmargin";s:1:"5";s:7:"piwidth";s:3:"100";s:5:"thumb";s:3:"100";s:7:"spacing";s:2:"10";s:10:"floatthumb";s:8:"No Float";s:6:"tclass";s:0:"";s:5:"limit";s:0:"";s:9:"pagelinks";s:14:"Top and Bottom";}';
                        $config->save();
                    }
                }
                break;
            case 'contactmodule':
                // convert to an old school form
                $module->view == "Default";
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "formmodule";
                if ($db->countObjects('formbuilder_form', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'contactmodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'contactmodule';
                $contactform = $old_db->selectObject('contactmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($contactform) {
                    $loc = expUnserialize($contactform->location_data);
                    $loc->mod = 'formmodule';
                    $contactform->location_data = serialize($loc);
                    //				$replyto_address = $contactform->replyto_address;
                    unset($contactform->replyto_address);
                    //				$from_address = $contactform->from_address;
                    unset($contactform->from_address);
                    //				$from_name = $contactform->from_name;
                    unset($contactform->from_name);
                    unset($contactform->use_captcha);
                    $contactform->name = 'Send us an e-mail';
                    $contactform->description = '';
                    $contactform->response = $contactform->final_message;
                    unset($contactform->final_message);
                    $contactform->table_name = '';
                    $contactform->is_email = true;
                    $contactform->is_saved = false;
                    $contactform->submitbtn = 'Send Message';
                    $contactform->resetbtn = 'Reset';
                    unset($contactform->id);
                    $contactform->id = $db->insertObject($contactform, 'formbuilder_form');
                    $addresses = $old_db->selectObjects('contact_contact', "location_data='" . serialize($iloc) . "'");
                    foreach ($addresses as $address) {
                        unset($address->addressbook_contact_id);
                        unset($address->contact_info);
                        unset($address->location_data);
                        $address->form_id = $contactform->id;
                        $db->insertObject($address, 'formbuilder_address');
                    }
                    $report = null;
                    $report->name = $contactform->subject;
                    $report->location_data = $contactform->location_data;
                    $report->form_id = $contactform->id;
                    $db->insertObject($report, 'formbuilder_report');
                    // now add the controls to the form
                    $control = null;
                    $control->name = 'name';
                    $control->caption = 'Your Name';
                    $control->form_id = $contactform->id;
                    $control->data = 'O:11:"textcontrol":12:{s:4:"size";i:0;s:9:"maxlength";i:0;s:7:"caption";s:9:"Your Name";s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:1;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:6:"filter";s:0:"";s:10:"identifier";s:4:"name";}';
                    $control->rank = 0;
                    $control->is_readonly = 0;
                    $control->is_static = 0;
                    $db->insertObject($control, 'formbuilder_control');
                    $control->name = 'email';
                    $control->caption = 'Your Email';
                    $control->data = 'O:11:"textcontrol":12:{s:4:"size";i:0;s:9:"maxlength";i:0;s:7:"caption";s:18:"Your Email Address";s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:1;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:6:"filter";s:0:"";s:10:"identifier";s:5:"email";}';
                    $control->rank = 1;
                    $db->insertObject($control, 'formbuilder_control');
                    $control->name = 'subject';
                    $control->caption = 'Subject';
                    $control->data = 'O:11:"textcontrol":12:{s:4:"size";i:0;s:9:"maxlength";i:0;s:7:"caption";s:7:"Subject";s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:1;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:6:"filter";s:0:"";s:10:"identifier";s:7:"subject";}';
                    $control->rank = 2;
                    $db->insertObject($control, 'formbuilder_control');
                    $control->name = 'message';
                    $control->caption = 'Message';
                    $control->data = 'O:17:"texteditorcontrol":12:{s:4:"cols";i:60;s:4:"rows";i:8;s:9:"accesskey";s:0:"";s:7:"default";s:0:"";s:8:"disabled";b:0;s:8:"required";b:0;s:8:"tabindex";i:-1;s:7:"inError";i:0;s:4:"type";s:4:"text";s:8:"maxchars";i:0;s:10:"identifier";s:7:"message";s:7:"caption";s:7:"Message";}';
                    $control->rank = 3;
                    $db->insertObject($control, 'formbuilder_control');
                    @$this->msg['migrated'][$iloc->mod]['count']++;
                    @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                }
                break;
            case 'youtubemodule':
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "youtube";
                if ($db->countObjects('youtube', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'youtubemodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'youtubemodule';
                $videos = $old_db->selectArrays('youtube', "location_data='" . serialize($iloc) . "'");
                if ($videos) {
                    foreach ($videos as $vi) {
                        unset($vi['id']);
                        $video = new youtube($vi);
                        $loc = expUnserialize($vi['location_data']);
                        $loc->mod = "youtube";
                        $video->title = $vi['name'];
                        if (empty($video->title)) {
                            $video->title = 'Untitled';
                        }
                        $video->location_data = serialize($loc);
                        $yt = explode("watch?v=", $vi['url']);
                        if (empty($yt[1])) {
                            break;
                        } else {
                            $ytid = $yt[1];
                        }
                        unset($video->url);
                        $video->embed_code = '<iframe title="YouTube video player" width="' . $vi['width'] . '" height="' . $vi['height'] . '" src="http://www.youtube.com/embed/' . $ytid . '" frameborder="0" allowfullscreen></iframe>';
                        $video->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'mediaplayermodule':
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "flowplayer";
                if ($db->countObjects('flowplayer', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'mediaplayermodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'mediaplayermodule';
                $movies = $old_db->selectArrays('mediaitem', "location_data='" . serialize($iloc) . "'");
                if ($movies) {
                    foreach ($movies as $mi) {
                        unset($mi['id']);
                        $movie = new flowplayer($mi);
                        $loc = expUnserialize($mi['location_data']);
                        $loc->mod = "flowplayer";
                        $movie->title = $mi['name'];
                        if (empty($movie->title)) {
                            $movie->title = 'Untitled';
                        }
                        unset($mi['bgcolor']);
                        unset($mi['alignment']);
                        unset($mi['loop_media']);
                        unset($mi['auto_rewind']);
                        unset($mi['autoplay']);
                        unset($mi['hide_controls']);
                        $movie->location_data = serialize($loc);
                        $movie->poster = 1;
                        $movie->rank = 1;
                        if (!empty($mi['media_id'])) {
                            $movie->save();
                            @$this->msg['migrated'][$iloc->mod]['count']++;
                            @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                            $file = new expFile($mi['media_id']);
                            $movie->attachitem($file, 'video');
                            if (!empty($mi['alt_image_id'])) {
                                $file = new expFile($mi['alt_image_id']);
                                $movie->attachitem($file, 'splash');
                            }
                        }
                    }
                }
                break;
            case 'bannermodule':
                //check to see if it's already pulled in (circumvent !is_original)
                $ploc = $iloc;
                $ploc->mod = "banner";
                if ($db->countObjects('banner', "location_data='" . serialize($ploc) . "'")) {
                    $iloc->mod = 'bannermodule';
                    $linked = true;
                    break;
                }
                $iloc->mod = 'bannermodule';
                $banners = $old_db->selectArrays('banner_ad', "location_data='" . serialize($iloc) . "'");
                if ($banners) {
                    foreach ($banners as $bi) {
                        $oldclicks = $old_db->selectObjects('banner_click', "ad_id='" . $bi['id'] . "'");
                        $oldcompany = $old_db->selectObject('banner_affiliate', "id='" . $bi['affiliate_id'] . "'");
                        unset($bi['id']);
                        $banner = new banner($bi);
                        $loc = expUnserialize($bi['location_data']);
                        $loc->mod = "banner";
                        $banner->title = $bi['name'];
                        $banner->url = !empty($bi['url']) ? $bi['url'] : '#';
                        if (empty($banner->title)) {
                            $banner->title = 'Untitled';
                        }
                        $banner->location_data = serialize($loc);
                        $newcompany = $db->selectObject('companies', "title='" . $oldcompany->name . "'");
                        if ($newcompany == null) {
                            $newcompany = new company();
                            $newcompany->title = !empty($oldcompany->name) ? $oldcompany->name : 'Untitled';
                            $newcompany->body = $oldcompany->contact_info;
                            $newcompany->location_data = $banner->location_data;
                            $newcompany->save();
                        }
                        $banner->companies_id = $newcompany->id;
                        $banner->clicks = 0;
                        foreach ($oldclicks as $click) {
                            $banner->clicks += $click->clicks;
                        }
                        if (!empty($bi['file_id'])) {
                            $file = new expFile($bi['file_id']);
                            $banner->attachitem($file, '');
                        }
                        $banner->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'addressbookmodule':
                // user mod, not widely distributed
                @($module->view = 'myaddressbook');
                @($module->action = 'myaddressbook');
                //check to see if it's already pulled in (circumvent !is_original)
                // $ploc = $iloc;
                // $ploc->mod = "addresses";
                // if ($db->countObjects($ploc->mod, "location_data='".serialize($ploc)."'")) {
                // $iloc->mod = 'addressbookmodule';
                // $linked = true;
                // break;
                // }
                //                $iloc->mod = 'addressbookmodule';
                $addresses = $old_db->selectArrays('addressbook_contact', "location_data='" . serialize($iloc) . "'");
                if ($addresses) {
                    foreach ($addresses as $address) {
                        //						unset($address['id']);
                        $addr = new address();
                        $addr->user_id = 1;
                        $addr->is_default = 1;
                        $addr->is_billing = 1;
                        $addr->is_shipping = 1;
                        $addr->firstname = !empty($address['firstname']) ? $address['firstname'] : 'blank';
                        $addr->lastname = !empty($address['lastname']) ? $address['lastname'] : 'blank';
                        $addr->address1 = !empty($address['address1']) ? $address['address1'] : 'blank';
                        $addr->city = !empty($address['city']) ? $address['city'] : 'blank';
                        $address['state'] = !empty($address['state']) ? $address['state'] : 'CA';
                        $state = $db->selectObject('geo_region', 'code="' . strtoupper($address['state']) . '"');
                        $addr->state = $state->id;
                        $addr->zip = !empty($address['zip']) ? $address['zip'] : '99999';
                        $addr->phone = !empty($address['phone']) ? $address['phone'] : '800-555-1212';
                        $addr->email = !empty($address['email']) ? $address['email'] : '*****@*****.**';
                        $addr->organization = $address['business'];
                        $addr->phone2 = $address['cell'];
                        $addr->save();
                        @$this->msg['migrated'][$iloc->mod]['count']++;
                        @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                    }
                }
                break;
            case 'feedlistmodule':
                @($module->view = 'showall');
                $iloc->mod = 'feedlistmodule';
                $feedlist = $old_db->selectObject('feedlistmodule_config', "location_data='" . serialize($iloc) . "'");
                if ($feedlist->enable_rss == 1) {
                    $loc = expUnserialize($feedlist->location_data);
                    $loc->mod = "rssController";
                    $config['enable_rss'] = true;
                    $config['feed_title'] = $feedlist->feed_title;
                    $config['feed_desc'] = $feedlist->feed_desc;
                    $config['rss_limit'] = isset($feedlist->rss_limit) ? $feedlist->rss_limit : 24;
                    $config['rss_cachetime'] = isset($feedlist->rss_cachetime) ? $feedlist->rss_cachetime : 1440;
                    $newconfig = new expConfig();
                    $newconfig->config = $config;
                    $newconfig->location_data = $loc;
                    $newconfig->save();
                    $newrss = new expRss();
                    $newrss->module = $loc->mod;
                    $newrss->src = $loc->src;
                    $newrss->enable_rss = $feedlist->enable_rss;
                    $newrss->feed_title = $feedlist->feed_title;
                    $newrss->feed_desc = $feedlist->feed_desc;
                    $newrss->rss_limit = isset($feedlist->rss_limit) ? $feedlist->rss_limit : 24;
                    $newrss->rss_cachetime = isset($feedlist->rss_cachetime) ? $feedlist->rss_cachetime : 1440;
                    $newrss->save();
                    @$this->msg['migrated'][$iloc->mod]['count']++;
                    @($this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod]);
                }
                break;
            default:
                @$this->msg['noconverter'][$iloc->mod]++;
                break;
        }
        // quick check for non hard coded modules
        // We add a container if they're not hard coded.
        !$hc ? $this->add_container($iloc, $module, $linked) : "";
        return $module;
    }
    function build_player($width, $height, $media)
    {
        /*
         * Fix #2 
         * @see http://trac.saiweb.co.uk/saiweb/ticket/2
         */
        $list = explode('|', $media);
        $hash = md5($media . flowplayer::_salt());
        $html = '<div id="saiweb_' . $hash . '" style="width:' . $width . 'px; height:' . $height . 'px;" class="flowplayer"></div>';
        $html .= '<script language="Javascript" type="text/javascript">
	WPFP(document).ready(function() {
		//load player
		$f("saiweb_' . $hash . '", "' . (flowplayer::_getkey() ? flowplayer::commercial_url() : flowplayer::gpl_url()) . '", {
				plugins: {
  					 controls: {    					
      					' . (flowplayer::_getbuttonOverColor() != '' ? 'buttonOverColor: \'' . flowplayer::_getbuttonOverColor() . '\',' : '') . '
      					' . (flowplayer::_getsliderColor() != '' ? 'sliderColor: \'' . flowplayer::_getsliderColor() . '\',' : '') . '
      					' . (flowplayer::_getbufferColor() != '' ? 'bufferColor: \'' . flowplayer::_getbufferColor() . '\',' : '') . '
      					sliderGradient: \'none\',
      					progressGradient: \'medium\',
      					' . (flowplayer::_getdurationColor() != '' ? 'durationColor: \'' . flowplayer::_getdurationColor() . '\',' : '') . '
      					' . (flowplayer::_getprogressColor() != '' ? 'progressColor: \'' . flowplayer::_getprogressColor() . '\',' : '') . '
      					' . (flowplayer::_getbackgroundColor() != '' ? 'backgroundColor: \'' . flowplayer::_getbackgroundColor() . '\',' : '') . '
      					' . (flowplayer::_gettimeColor() != '' ? 'timeColor: \'' . flowplayer::_gettimeColor() . '\',' : '') . '
      					' . (flowplayer::_getbuttonColor() != '' ? 'buttonColor: \'' . flowplayer::_getbuttonColor() . '\',' : '') . '
      					backgroundGradient: \'none\',
      					bufferGradient: \'none\',
   						opacity:1.0' . (count($list) > 1 ? ',
						playlist: true' : '') . '
   						}
				},';
        if (count($list) > 1) {
            //splash image code, adapted from user contributed code from James P
            $iRegex = '/\\.(jpe?g|gif|png)$/';
            $splash = preg_match($iRegex, $list[0]) && !preg_match($iRegex, $list[1]);
            $html .= '
			clip: {
					autoPlay: ' . ($splash == true ? 'true' : (flowplayer::_getautoplay() == 'true' ? 'true' : 'false')) . ',
       				autoBuffering: ' . (flowplayer::_getautobuffer() == 'true' ? 'true' : 'false') . '
				},';
            $html .= 'playlist:[
				 
				';
            $i = 0;
            foreach ($list as $item) {
                if (!$splash) {
                    $html .= '{url: \'' . $item . '\'},' . "\n";
                } else {
                    if ($i == 0) {
                        //this is the splash image
                        $html .= '{url: \'' . $item . '\', autoPlay: true},' . "\n";
                    } else {
                        //next items are not the splash image
                        $html .= '{url: \'' . $item . '\', autoPlay: false},' . "\n";
                    }
                }
                $i++;
            }
            $html .= '],' . "\n";
        } else {
            $html .= '
			clip: {
					url:\'' . $media . '\',
					autoPlay: ' . (flowplayer::_getautoplay() == 'true' ? 'true' : 'false') . ',
       				autoBuffering: ' . (flowplayer::_getautobuffer() == 'true' ? 'true' : 'false') . '
				},';
        }
        $html .= flowplayer::_getkey() ? 'key:\'' . flowplayer::_getkey() . '\',' : '';
        if (strlen(flowplayer::_getlogo()) > 0) {
            $html .= '
		logo: {  
        url: \'' . flowplayer::_getlogo() . '\',  
        displayTime: 0,
        fullscreenOnly: false,
        linkUrl: \'' . flowplayer::_getlogolink() . '\' 
    },';
        }
        $html .= '
				canvas: {
					backgroundColor:\'' . flowplayer::_getcanvas() . '\'
				}})
			});</script>
				';
        return $html;
    }
Example #10
0
function fv_player_time()
{
    global $post, $fv_fp;
    if ($post->ID > 0 && isset($fv_fp->aCurArgs['src'])) {
        return flowplayer::get_duration($post->ID, $fv_fp->aCurArgs['src']);
    } else {
        return flowplayer::get_duration_post();
    }
}