예제 #1
0
 /**
  * move the template sliders and add the slides to corresponding post based slider or simply move them and change them to post based slider if no slider is using them
  * @since 5.0
  */
 public static function move_template_slider()
 {
     $db = new RevSliderDB();
     $used_templates = array();
     //will store all template IDs that are used by post based Sliders, these can be deleted after the progress.
     $sr = new RevSlider();
     $sl = new RevSliderSlide();
     $arrSliders = $sr->getArrSliders(false, false);
     $tempSliders = $sr->getArrSliders(false, true);
     if (empty($tempSliders) || !is_array($tempSliders)) {
         return true;
     }
     //as we do not have any template sliders, we do not need to run further here
     if (!empty($arrSliders) && is_array($arrSliders)) {
         foreach ($arrSliders as $slider) {
             if ($slider->getParam('source_type', 'gallery') !== 'posts') {
                 continue;
             }
             //only check Slider with type of posts
             $slider_id = $slider->getID();
             $template_id = $slider->getParam('slider_template_id', 0);
             if ($template_id > 0) {
                 //initialize slider to see if it exists. Then copy over the Template Sliders Slides to the Post Based Slider
                 foreach ($tempSliders as $t_slider) {
                     if ($t_slider->getID() === $template_id) {
                         //copy over the slides
                         //get all slides from template, then copy to Slider
                         $slides = $t_slider->getSlides();
                         if (!empty($slides) && is_array($slides)) {
                             foreach ($slides as $slide) {
                                 $slide_id = $slide->getID();
                                 $slider->copySlideToSlider(array('slider_id' => $slider_id, 'slide_id' => $slide_id));
                             }
                         }
                         $static_id = $sl->getStaticSlideID($template_id);
                         if ($static_id !== false) {
                             $record = $db->fetchSingle(RevSliderGlobals::$table_static_slides, $db->prepare("id = %s", array($static_id)));
                             unset($record['id']);
                             $record['slider_id'] = $slider_id;
                             $db->insert(RevSliderGlobals::$table_static_slides, $record);
                         }
                         $used_templates[$template_id] = $t_slider;
                         break;
                     }
                 }
             }
         }
     }
     if (!empty($used_templates)) {
         foreach ($used_templates as $tid => $t_slider) {
             $t_slider->deleteSlider();
         }
     }
     //translate all other template Sliders to normal sliders and set them to post based
     $temp_sliders = $sr->getArrSliders(false, true);
     if (!empty($temp_sliders) && is_array($temp_sliders)) {
         foreach ($temp_sliders as $slider) {
             $slider->updateParam(array('template' => 'false'));
             $slider->updateParam(array('source_type' => 'posts'));
         }
     }
 }
 public static function get_captions_sorted()
 {
     $db = new RevSliderDB();
     $styles = $db->fetch(RevSliderGlobals::$table_css, '', 'handle ASC');
     $arr = array('5.0' => array(), 'Custom' => array(), '4' => array());
     foreach ($styles as $style) {
         $setting = json_decode($style['settings'], true);
         if (!isset($setting['type'])) {
             $setting['type'] = 'text';
         }
         if (array_key_exists('version', $setting) && isset($setting['version'])) {
             $arr[ucfirst($setting['version'])][] = array('label' => trim(str_replace('.tp-caption.', '', $style['handle'])), 'type' => $setting['type']);
         }
     }
     $sorted = array();
     foreach ($arr as $version => $class) {
         foreach ($class as $name) {
             $sorted[] = array('label' => $name['label'], 'version' => $version, 'type' => $name['type']);
         }
     }
     return $sorted;
 }
예제 #3
0
 /**
  * onAjax action handler
  */
 public static function onFrontAjaxAction()
 {
     $db = new RevSliderDB();
     $slider = new RevSlider();
     $slide = new RevSlide();
     $operations = new RevSliderOperations();
     $token = self::getPostVar("token", false);
     //verify the token
     $isVerified = wp_verify_nonce($token, 'RevSlider_Front');
     $error = false;
     if ($isVerified) {
         $data = self::getPostVar('data', false);
         switch (self::getPostVar('client_action', false)) {
             case 'get_slider_html':
                 $id = intval(self::getPostVar('id', 0));
                 if ($id > 0) {
                     $html = '';
                     add_filter('revslider_add_js_delay', array('RevSliderAdmin', 'rev_set_js_delay'));
                     ob_start();
                     $slider_class = RevSliderOutput::putSlider($id);
                     $html = ob_get_contents();
                     //add styling
                     $custom_css = RevSliderOperations::getStaticCss();
                     $custom_css = RevSliderCssParser::compress_css($custom_css);
                     $styles = $db->fetch(RevSliderGlobals::$table_css);
                     $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n");
                     $styles = RevSliderCssParser::compress_css($styles);
                     $html .= '<style type="text/css">' . $custom_css . '</style>';
                     $html .= '<style type="text/css">' . $styles . '</style>';
                     ob_clean();
                     ob_end_clean();
                     $result = !empty($slider_class) && $html !== '' ? true : false;
                     if (!$result) {
                         $error = __('Slider not found', 'revslider');
                     } else {
                         if ($html !== false) {
                             self::ajaxResponseData($html);
                         } else {
                             $error = __('Slider not found', 'revslider');
                         }
                     }
                 } else {
                     $error = __('No Data Received', 'revslider');
                 }
                 break;
         }
     } else {
         $error = true;
     }
     if ($error !== false) {
         $showError = __('Loading Error', 'revslider');
         if ($error !== true) {
             $showError = __('Loading Error: ', 'revslider') . $error;
         }
         self::ajaxResponseError($showError, false);
     }
     exit;
 }
예제 #4
0
 /**
  * Check if Slide Exists with given ID
  * @since: 5.0
  */
 public static function isSlideByID($slideid)
 {
     $db = new RevSliderDB();
     try {
         if (strpos($slideid, 'static_') !== false) {
             $sliderID = str_replace('static_', '', $slideid);
             RevSliderFunctions::validateNumeric($sliderID, "Slider ID");
             $sliderID = $db->escape($sliderID);
             $record = $db->fetch(RevSliderGlobals::$table_static_slides, "slider_id={$sliderID}");
             if (empty($record)) {
                 return false;
             }
             return true;
         } else {
             $slideid = $db->escape($slideid);
             $record = $db->fetchSingle(RevSliderGlobals::$table_slides, "id={$slideid}");
             if (empty($record)) {
                 return false;
             }
             return true;
         }
     } catch (Exception $e) {
         return false;
     }
 }
    /**
     *
     * preview slider output
     * if output object is null - create object
     */
    public function previewOutput($sliderID, $output = null)
    {
        if ($sliderID == "empty_output") {
            $this->loadingMessageOutput();
            exit;
        }
        if ($output == null) {
            $output = new RevSliderOutput();
        }
        $slider = new RevSlider();
        $slider->initByID($sliderID);
        $isWpmlExists = RevSliderWpml::isWpmlExists();
        $useWpml = $slider->getParam("use_wpml", "off");
        $wpmlActive = false;
        if ($isWpmlExists && $useWpml == "on") {
            $wpmlActive = true;
            $arrLanguages = RevSliderWpml::getArrLanguages(false);
            //set current lang to output
            $currentLang = RevSliderFunctions::getPostGetVariable("lang");
            if (empty($currentLang)) {
                $currentLang = RevSliderWpml::getCurrentLang();
            }
            if (empty($currentLang)) {
                $currentLang = $arrLanguages[0];
            }
            $output->setLang($currentLang);
            $selectLangChoose = RevSliderFunctions::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true);
        }
        $output->setPreviewMode();
        //put the output html
        $urlPlugin = RS_PLUGIN_URL . 'public/assets/';
        $urlPreviewPattern = RevSliderBase::$url_ajax_actions . "&client_action=preview_slider&sliderid=" . $sliderID . "&lang=[lang]&nonce=[nonce]";
        $nonce = wp_create_nonce("revslider_actions");
        $setBase = is_ssl() ? "https://" : "http://";
        ?>
			<html>
				<head>
					<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/settings.css?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
					<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
fonts/font-awesome/css/font-awesome.css?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
					<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
					<?php 
        $db = new RevSliderDB();
        $styles = $db->fetch(RevSliderGlobals::$table_css);
        $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n");
        $styles = RevSliderCssParser::compress_css($styles);
        echo '<style type="text/css">' . $styles . '</style>';
        //.$stylesinnerlayers
        $http = is_ssl() ? 'https' : 'http';
        $operations = new RevSliderOperations();
        $arrValues = $operations->getGeneralSettingsValues();
        $set_diff_font = RevSliderFunctions::getVal($arrValues, "change_font_loading", '');
        if ($set_diff_font !== '') {
            $font_url = $set_diff_font;
        } else {
            $font_url = $http . '://fonts.googleapis.com/css?family=';
        }
        $custom_css = RevSliderOperations::getStaticCss();
        echo '<style type="text/css">' . RevSliderCssParser::compress_css($custom_css) . '</style>';
        ?>

					<script type='text/javascript' src='<?php 
        echo $setBase;
        ?>
code.jquery.com/jquery-latest.min.js'></script>

					<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.tools.min.js?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
'></script>
					<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.revolution.min.js?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
'></script>
					
				</head>
				<body style="padding:0px;margin:0px;width:100%;height:100%;position:relative;">
					<?php 
        if ($wpmlActive == true) {
            ?>
						<div style="margin-bottom:10px;text-align:center;">
						<?php 
            _e("Choose language", REVSLIDER_TEXTDOMAIN);
            ?>
: <?php 
            echo $selectLangChoose;
            ?>
						</div>

						<script type="text/javascript">
							var g_previewPattern = '<?php 
            echo $urlPreviewPattern;
            ?>
';
							jQuery("#select_langs").change(function(){
								var lang = this.value;
								var nonce = "<?php 
            echo $nonce;
            ?>
";
								var pattern = g_previewPattern;
								var urlPreview = pattern.replace("[lang]",lang).replace("[nonce]",nonce);
								location.href = urlPreview;
							});
						</script>
						<?php 
        }
        ?>

					<?php 
        $output->putSliderBase($sliderID);
        ?>
				</body>
			</html>
		<?php 
        exit;
    }
예제 #6
0
    public function previewOutputMarkup($sliderID, $output = null)
    {
        if ($sliderID == "empty_output") {
            $this->loadingMessageOutput();
            exit;
        }
        if ($output == null) {
            $output = new RevSliderOutput();
        }
        $slider = new RevSlider();
        $slider->initByID($sliderID);
        $isWpmlExists = RevSliderWpml::isWpmlExists();
        $useWpml = $slider->getParam("use_wpml", "off");
        $wpmlActive = false;
        if ($isWpmlExists && $useWpml == "on") {
            $wpmlActive = true;
            $arrLanguages = RevSliderWpml::getArrLanguages(false);
            //set current lang to output
            $currentLang = RevSliderFunctions::getPostGetVariable("lang");
            if (empty($currentLang)) {
                $currentLang = RevSliderWpml::getCurrentLang();
            }
            if (empty($currentLang)) {
                $currentLang = $arrLanguages[0];
            }
            $output->setLang($currentLang);
            $selectLangChoose = RevSliderFunctions::getHTMLSelect($arrLanguages, $currentLang, "id='select_langs'", true);
        }
        $output->setPreviewMode();
        //put the output html
        $urlPlugin = "http://yourpluginpath/";
        $urlPreviewPattern = RevSliderBase::$url_ajax_actions . "&client_action=preview_slider&only_markup=true&sliderid=" . $sliderID . "&lang=[lang]&nonce=[nonce]";
        $nonce = wp_create_nonce("revslider_actions");
        $setBase = is_ssl() ? "https://" : "http://";
        $http = is_ssl() ? 'https' : 'http';
        $operations = new RevSliderOperations();
        $arrValues = $operations->getGeneralSettingsValues();
        $set_diff_font = RevSliderFunctions::getVal($arrValues, "change_font_loading", '');
        if ($set_diff_font !== '') {
            $font_url = $set_diff_font;
        } else {
            $font_url = $http . '://fonts.googleapis.com/css?family=';
        }
        ?>
		<html>
		<head>
			<script type='text/javascript' src='<?php 
        echo $setBase;
        ?>
ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
		</head>
		<body style="padding:0px;margin:0px;">
			<?php 
        if ($wpmlActive == true) {
            ?>
				<div style="margin-bottom:10px;text-align:center;">
				<?php 
            _e("Choose language", REVSLIDER_TEXTDOMAIN);
            ?>
: <?php 
            echo $selectLangChoose;
            ?>
				</div>

				<script type="text/javascript">
					var g_previewPattern = '<?php 
            echo $urlPreviewPattern;
            ?>
';
					jQuery("#select_langs").change(function(){
						var lang = this.value;
						var nonce = "<?php 
            echo $nonce;
            ?>
";
						var pattern = g_previewPattern;
						var urlPreview = pattern.replace("[lang]",lang).replace("[nonce]",nonce);
						location.href = urlPreview;
					});

					jQuery('body').on('click', '#rev_replace_images', function(){
						var from = jQuery('input[name="orig_image_path"]').val();
						var to = jQuery('input[name="replace_image_path"]').val();

						jQuery('#rev_script_content').val(jQuery('#rev_script_content').val().replace(from, to));
						jQuery('#rev_the_content').val(jQuery('#rev_the_content').val().replace(from, to));
						jQuery('#rev_style_content').val(jQuery('#rev_style_content').val().replace(from, to));
						jQuery('#rev_head_content').val(jQuery('#rev_head_content').val().replace(from, to));
					});

				</script>
			<?php 
        }
        ?>
		<?php 
        ob_start();
        ?>
<link rel='stylesheet' href='<?php 
        echo $urlPlugin;
        ?>
css/settings.css?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
' type='text/css' media='all' />
		<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.tools.min.js?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
'></script>
		<script type='text/javascript' src='<?php 
        echo $urlPlugin;
        ?>
js/jquery.themepunch.revolution.min.js?rev=<?php 
        echo RevSliderGlobals::SLIDER_REVISION;
        ?>
'></script>
		<?php 
        $head_content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        ob_start();
        $custom_css = RevSliderOperations::getStaticCss();
        echo $custom_css . "\n\n";
        echo '/*****************' . "\n";
        echo ' ** ' . __('CAPTIONS CSS', REVSLIDER_TEXTDOMAIN) . "\n";
        echo ' ****************/' . "\n\n";
        $db = new RevSliderDB();
        $styles = $db->fetch(RevSliderGlobals::$table_css);
        echo RevSliderCssParser::parseDbArrayToCss($styles, "\n");
        $style_content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        ob_start();
        $output->putSliderBase($sliderID);
        $content = ob_get_contents();
        ob_clean();
        ob_end_clean();
        $script_content = substr($content, strpos($content, '<script type="text/javascript">'), strpos($content, '</script>') + 9 - strpos($content, '<script type="text/javascript">'));
        $content = htmlentities(str_replace($script_content, '', $content));
        $script_content = str_replace('				', '', $script_content);
        $script_content = str_replace(array('<script type="text/javascript">', '</script>'), '', $script_content);
        ?>
		<style>
			body 	 { font-family:sans-serif; font-size:12px;}
			textarea { background:#f1f1f1; border:#ddd; font-size:10px; line-height:16px; margin-bottom:40px; padding:10px;}
			.rev_cont_title { color:#000; text-decoration:none;font-size:14px; line-height:24px; font-weight:800;background: #D5D5D5;padding: 10px;}
			.rev_cont_title a, .rev_cont_title a:visited { margin-left:25px;font-size:12px;line-height:12px;float:right;background-color:#8e44ad; color:#fff; padding:8px 10px;text-decoration:none;}
			.rev_cont_title a:hover	  { background-color:#9b59b6;}
		</style>
		<p><?php 
        $dir = wp_upload_dir();
        if (!isset($dir['baseurl'])) {
            $dir['baseurl'] = '';
        }
        ?>
			<?php 
        _e('Replace image path:', REVSLIDER_TEXTDOMAIN);
        ?>
 <?php 
        _e('From:', REVSLIDER_TEXTDOMAIN);
        ?>
 <input type="text" name="orig_image_path" value="<?php 
        echo $dir['baseurl'];
        ?>
" /> <?php 
        _e('To:', REVSLIDER_TEXTDOMAIN);
        ?>
 <input type="text" name="replace_image_path" value="" /> <input id="rev_replace_images" type="button" name="replace_images" value="<?php 
        _e('Replace', REVSLIDER_TEXTDOMAIN);
        ?>
" />
		</p>

		<div class="rev_cont_title"><?php 
        _e('Header', REVSLIDER_TEXTDOMAIN);
        ?>
 <a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_head_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a><div style="clear:both"></div></div>
		<textarea id="rev_head_content" readonly="true" style="width: 100%; height: 100px; color:#3498db"><?php 
        echo $head_content;
        ?>
</textarea>
		<div class="rev_cont_title"><?php 
        _e('CSS', REVSLIDER_TEXTDOMAIN);
        ?>
<a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_style_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a></div>
		<textarea id="rev_style_content" readonly="true" style="width: 100%; height: 100px;"><?php 
        echo $style_content;
        ?>
</textarea>
		<div class="rev_cont_title"><?php 
        _e('Body', REVSLIDER_TEXTDOMAIN);
        ?>
<a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_the_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a></div>
		<textarea id="rev_the_content" readonly="true" style="width: 100%; height: 100px;"><?php 
        echo $content;
        ?>
</textarea>
		<div class="rev_cont_title"><?php 
        _e('Script', REVSLIDER_TEXTDOMAIN);
        ?>
<a class="button-primary revpurple export_slider_standalone copytoclip" data-idt="rev_script_content"  href="javascript:void(0);" original-title=""><?php 
        _e('Mark to Copy', REVSLIDER_TEXTDOMAIN);
        ?>
</a></div>
		<textarea id="rev_script_content" readonly="true" style="width: 100%; height: 100px;"><?php 
        echo $script_content;
        ?>
</textarea>

		<script>
			jQuery('body').on('click','.copytoclip',function() {
				jQuery("#"+jQuery(this).data('idt')).select();
			});
		</script>
		</body>
		</html>
		<?php 
        exit;
    }
예제 #7
0
 /**
  * 
  * import slider from multipart form
  */
 public function importSliderFromPost($updateAnim = true, $updateStatic = true, $exactfilepath = false, $is_template = false, $single_slide = false)
 {
     try {
         $sliderID = RevSliderFunctions::getPostVariable("sliderid");
         $sliderExists = !empty($sliderID);
         if ($sliderExists) {
             $this->initByID($sliderID);
         }
         if ($exactfilepath !== false) {
             $filepath = $exactfilepath;
         } else {
             switch ($_FILES['import_file']['error']) {
                 case UPLOAD_ERR_OK:
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     RevSliderFunctions::throwError(__('No file sent.', REVSLIDER_TEXTDOMAIN));
                 case UPLOAD_ERR_INI_SIZE:
                 case UPLOAD_ERR_FORM_SIZE:
                     RevSliderFunctions::throwError(__('Exceeded filesize limit.', REVSLIDER_TEXTDOMAIN));
                 default:
                     break;
             }
             $filepath = $_FILES["import_file"]["tmp_name"];
         }
         if (file_exists($filepath) == false) {
             RevSliderFunctions::throwError("Import file not found!!!");
         }
         //check if zip file or fallback to old, if zip, check if all files exist
         if (!class_exists("ZipArchive")) {
             $importZip = false;
         } else {
             $zip = new ZipArchive();
             $importZip = $zip->open($filepath, ZIPARCHIVE::CREATE);
         }
         // Added by ThemeFuzz ( Stefan )
         if ($importZip === 0 || !$zip->getStream('slider_export.txt')) {
             if (!$zip->getStream('slider_export.txt')) {
                 $upload_dir = wp_upload_dir();
                 $new_path = $upload_dir['basedir'] . '/' . $_FILES['import_file']['name'];
                 move_uploaded_file($_FILES["import_file"]["tmp_name"], $new_path);
                 $importZip = $zip->open($new_path, ZIPARCHIVE::CREATE);
             }
         }
         if ($is_template !== false && $importZip !== true) {
             return array("success" => false, "error" => __('Please select the correct zip file', REVSLIDER_TEXTDOMAIN));
         }
         if ($importZip === true) {
             //true or integer. If integer, its not a correct zip file
             //check if files all exist in zip
             $slider_export = $zip->getStream('slider_export.txt');
             $custom_animations = $zip->getStream('custom_animations.txt');
             $dynamic_captions = $zip->getStream('dynamic-captions.css');
             $static_captions = $zip->getStream('static-captions.css');
             $uid_file = $zip->getStream('info.cfg');
             $uid_check = '';
             if ($uid_file) {
                 while (!feof($uid_file)) {
                     $uid_check .= fread($uid_file, 1024);
                 }
             }
             if ($is_template !== false) {
                 if ($uid_check != $is_template) {
                     return array("success" => false, "error" => __('Please select the correct zip file, checksum failed!', REVSLIDER_TEXTDOMAIN));
                 }
             } else {
                 //someone imported a template base Slider, check if it is existing in Base Sliders, if yes, check if it was imported
                 if ($uid_check !== '') {
                     $tmpl = new RevSliderTemplate();
                     $tmpl_slider = $tmpl->getThemePunchTemplateSliders();
                     foreach ($tmpl_slider as $tp_slider) {
                         if (!isset($tp_slider['installed'])) {
                             continue;
                         }
                         if ($tp_slider['uid'] == $uid_check) {
                             $is_template = $uid_check;
                             break;
                         }
                     }
                 }
             }
             if (!$slider_export) {
                 RevSliderFunctions::throwError("slider_export.txt does not exist!");
             }
             $content = '';
             $animations = '';
             $dynamic = '';
             $static = '';
             while (!feof($slider_export)) {
                 $content .= fread($slider_export, 1024);
             }
             if ($custom_animations) {
                 while (!feof($custom_animations)) {
                     $animations .= fread($custom_animations, 1024);
                 }
             }
             if ($dynamic_captions) {
                 while (!feof($dynamic_captions)) {
                     $dynamic .= fread($dynamic_captions, 1024);
                 }
             }
             if ($static_captions) {
                 while (!feof($static_captions)) {
                     $static .= fread($static_captions, 1024);
                 }
             }
             fclose($slider_export);
             if ($custom_animations) {
                 fclose($custom_animations);
             }
             if ($dynamic_captions) {
                 fclose($dynamic_captions);
             }
             if ($static_captions) {
                 fclose($static_captions);
             }
             //check for images!
         } else {
             //check if fallback
             //get content array
             $content = @file_get_contents($filepath);
         }
         if ($importZip === true) {
             //we have a zip
             $db = new RevSliderDB();
             //update/insert custom animations
             $animations = @unserialize($animations);
             if (!empty($animations)) {
                 foreach ($animations as $key => $animation) {
                     //$animation['id'], $animation['handle'], $animation['params']
                     $exist = $db->fetch(RevSliderGlobals::$table_layer_anims, "handle = '" . $animation['handle'] . "'");
                     if (!empty($exist)) {
                         //update the animation, get the ID
                         if ($updateAnim == "true") {
                             //overwrite animation if exists
                             $arrUpdate = array();
                             $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params'])));
                             $db->update(RevSliderGlobals::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle']));
                             $anim_id = $exist['0']['id'];
                         } else {
                             //insert with new handle
                             $arrInsert = array();
                             $arrInsert["handle"] = 'copy_' . $animation['handle'];
                             $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params'])));
                             $anim_id = $db->insert(RevSliderGlobals::$table_layer_anims, $arrInsert);
                         }
                     } else {
                         //insert the animation, get the ID
                         $arrInsert = array();
                         $arrInsert["handle"] = $animation['handle'];
                         $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params'])));
                         $anim_id = $db->insert(RevSliderGlobals::$table_layer_anims, $arrInsert);
                     }
                     //and set the current customin-oldID and customout-oldID in slider params to new ID from $id
                     $content = str_replace(array('customin-' . $animation['id'] . '"', 'customout-' . $animation['id'] . '"'), array('customin-' . $anim_id . '"', 'customout-' . $anim_id . '"'), $content);
                 }
                 dmp(__("animations imported!", REVSLIDER_TEXTDOMAIN));
             } else {
                 dmp(__("no custom animations found, if slider uses custom animations, the provided export may be broken...", REVSLIDER_TEXTDOMAIN));
             }
             //overwrite/append static-captions.css
             if (!empty($static)) {
                 if ($updateStatic == "true") {
                     //overwrite file
                     RevSliderOperations::updateStaticCss($static);
                 } elseif ($updateStatic == 'none') {
                     //do nothing
                 } else {
                     //append
                     $static_cur = RevSliderOperations::getStaticCss();
                     $static = $static_cur . "\n" . $static;
                     RevSliderOperations::updateStaticCss($static);
                 }
             }
             //overwrite/create dynamic-captions.css
             //parse css to classes
             $dynamicCss = RevSliderCssParser::parseCssToArray($dynamic);
             if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) {
                 foreach ($dynamicCss as $class => $styles) {
                     //check if static style or dynamic style
                     $class = trim($class);
                     if (strpos($class, ',') !== false && strpos($class, '.tp-caption') !== false) {
                         //we have something like .tp-caption.redclass, .redclass
                         $class_t = explode(',', $class);
                         foreach ($class_t as $k => $cl) {
                             if (strpos($cl, '.tp-caption') !== false) {
                                 $class = $cl;
                             }
                         }
                     }
                     if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) {
                         //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img
                         continue;
                     }
                     //is a dynamic style
                     if (strpos($class, ':hover') !== false) {
                         $class = trim(str_replace(':hover', '', $class));
                         $arrInsert = array();
                         $arrInsert["hover"] = json_encode($styles);
                         $arrInsert["settings"] = json_encode(array('hover' => 'true'));
                     } else {
                         $arrInsert = array();
                         $arrInsert["params"] = json_encode($styles);
                         $arrInsert["settings"] = '';
                     }
                     //check if class exists
                     $result = $db->fetch(RevSliderGlobals::$table_css, "handle = '" . $class . "'");
                     if (!empty($result)) {
                         //update
                         $db->update(RevSliderGlobals::$table_css, $arrInsert, array('handle' => $class));
                     } else {
                         //insert
                         $arrInsert["handle"] = $class;
                         $db->insert(RevSliderGlobals::$table_css, $arrInsert);
                     }
                 }
                 dmp(__("dynamic styles imported!", REVSLIDER_TEXTDOMAIN));
             } else {
                 dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...", REVSLIDER_TEXTDOMAIN));
             }
         }
         //$content = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $content); //clear errors in string //deprecated in newest php version
         $content = preg_replace_callback('!s:(\\d+):"(.*?)";!', array('RevSlider', 'clear_error_in_string'), $content);
         //clear errors in string
         $arrSlider = @unserialize($content);
         if (empty($arrSlider)) {
             RevSliderFunctions::throwError("Wrong export slider file format! This could be caused because the ZipArchive extension is not enabled.");
         }
         //update slider params
         $sliderParams = $arrSlider["params"];
         if ($sliderExists) {
             $sliderParams["title"] = $this->arrParams["title"];
             $sliderParams["alias"] = $this->arrParams["alias"];
             $sliderParams["shortcode"] = $this->arrParams["shortcode"];
         }
         if (isset($sliderParams["background_image"])) {
             $sliderParams["background_image"] = RevSliderFunctionsWP::getImageUrlFromPath($sliderParams["background_image"]);
         }
         $import_statics = true;
         if (isset($sliderParams['enable_static_layers'])) {
             if ($sliderParams['enable_static_layers'] == 'off') {
                 $import_statics = false;
             }
             unset($sliderParams['enable_static_layers']);
         }
         $json_params = json_encode($sliderParams);
         //update slider or create new
         if ($sliderExists) {
             $arrUpdate = array("params" => $json_params);
             $this->db->update(RevSliderGlobals::$table_sliders, $arrUpdate, array("id" => $sliderID));
         } else {
             //new slider
             $arrInsert = array();
             $arrInsert['params'] = $json_params;
             //check if Slider with title and/or alias exists, if yes change both to stay unique
             $arrInsert['title'] = RevSliderFunctions::getVal($sliderParams, 'title', 'Slider1');
             $arrInsert['alias'] = RevSliderFunctions::getVal($sliderParams, 'alias', 'slider1');
             if ($is_template === false) {
                 //we want to stay at the given alias if we are a template
                 $talias = $arrInsert['alias'];
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $arrInsert['alias'] . $ti;
                     $ti++;
                 }
                 if ($talias !== $arrInsert['alias']) {
                     $arrInsert['title'] = $talias;
                     $arrInsert['alias'] = $talias;
                 }
             }
             if ($is_template !== false) {
                 //add that we are an template
                 $arrInsert['type'] = 'template';
             }
             $sliderID = $this->db->insert(RevSliderGlobals::$table_sliders, $arrInsert);
         }
         //-------- Slides Handle -----------
         //delete current slides
         if ($sliderExists) {
             $this->deleteAllSlides();
         }
         //create all slides
         $arrSlides = $arrSlider["slides"];
         $alreadyImported = array();
         //wpml compatibility
         $slider_map = array();
         foreach ($arrSlides as $sl_key => $slide) {
             $params = $slide["params"];
             $layers = $slide["layers"];
             $settings = @$slide["settings"];
             //convert params images:
             if ($importZip === true) {
                 //we have a zip, check if exists
                 if (isset($params["image"])) {
                     $params["image"] = RevSliderBase::check_file_in_zip($zip, $params["image"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
                 }
                 if (isset($params["background_image"])) {
                     $params["background_image"] = RevSliderBase::check_file_in_zip($zip, $params["background_image"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["background_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["background_image"]);
                 }
                 if (isset($params["slide_thumb"])) {
                     $params["slide_thumb"] = RevSliderBase::check_file_in_zip($zip, $params["slide_thumb"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["slide_thumb"] = RevSliderFunctionsWP::getImageUrlFromPath($params["slide_thumb"]);
                 }
                 if (isset($params["show_alternate_image"])) {
                     $params["show_alternate_image"] = RevSliderBase::check_file_in_zip($zip, $params["show_alternate_image"], $filepath, $sliderParams["alias"], $alreadyImported);
                     $params["show_alternate_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["show_alternate_image"]);
                 }
                 if (isset($params['background_type']) && $params['background_type'] == 'html5') {
                     if (isset($params['slide_bg_html_mpeg']) && $params['slide_bg_html_mpeg'] != '') {
                         $params['slide_bg_html_mpeg'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $params["slide_bg_html_mpeg"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_webm']) && $params['slide_bg_html_webm'] != '') {
                         $params['slide_bg_html_webm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $params["slide_bg_html_webm"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_ogv']) && $params['slide_bg_html_ogv'] != '') {
                         $params['slide_bg_html_ogv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $params["slide_bg_html_ogv"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                     }
                 }
             }
             //convert layers images:
             foreach ($layers as $key => $layer) {
                 //import if exists in zip folder
                 if ($importZip === true) {
                     //we have a zip, check if exists
                     if (isset($layer["image_url"])) {
                         $layer["image_url"] = RevSliderBase::check_file_in_zip($zip, $layer["image_url"], $filepath, $sliderParams["alias"], $alreadyImported);
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                     }
                     if (isset($layer['type']) && $layer['type'] == 'video') {
                         $video_data = isset($layer['video_data']) ? (array) $layer['video_data'] : array();
                         if (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] == 'html5') {
                             if (isset($video_data['urlPoster']) && $video_data['urlPoster'] != '') {
                                 $video_data['urlPoster'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlPoster"], $filepath, $sliderParams["alias"], $alreadyImported));
                             }
                             if (isset($video_data['urlMp4']) && $video_data['urlMp4'] != '') {
                                 $video_data['urlMp4'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlMp4"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlWebm']) && $video_data['urlWebm'] != '') {
                                 $video_data['urlWebm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlWebm"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlOgv']) && $video_data['urlOgv'] != '') {
                                 $video_data['urlOgv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["urlOgv"], $filepath, $sliderParams["alias"], $alreadyImported, true));
                             }
                         } elseif (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] != 'html5') {
                             //video cover image
                             if (isset($video_data['previewimage']) && $video_data['previewimage'] != '') {
                                 $video_data['previewimage'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($zip, $video_data["previewimage"], $filepath, $sliderParams["alias"], $alreadyImported));
                             }
                         }
                         $layer['video_data'] = $video_data;
                     }
                 }
                 $layer['text'] = stripslashes($layer['text']);
                 $layers[$key] = $layer;
             }
             $arrSlides[$sl_key]['layers'] = $layers;
             //create new slide
             $arrCreate = array();
             $arrCreate["slider_id"] = $sliderID;
             $arrCreate["slide_order"] = $slide["slide_order"];
             $my_layers = json_encode($layers);
             if (empty($my_layers)) {
                 $my_layers = stripslashes(json_encode($layers));
             }
             $my_params = json_encode($params);
             if (empty($my_params)) {
                 $my_params = stripslashes(json_encode($params));
             }
             $my_settings = json_encode($settings);
             if (empty($my_settings)) {
                 $my_settings = stripslashes(json_encode($settings));
             }
             $arrCreate["layers"] = $my_layers;
             $arrCreate["params"] = $my_params;
             $arrCreate["settings"] = $my_settings;
             $last_id = $this->db->insert(RevSliderGlobals::$table_slides, $arrCreate);
             if (isset($slide['id'])) {
                 $slider_map[$slide['id']] = $last_id;
             }
         }
         //change for WPML the parent IDs if necessary
         if (!empty($slider_map)) {
             foreach ($arrSlides as $sl_key => $slide) {
                 if (isset($slide['params']['parentid']) && isset($slider_map[$slide['params']['parentid']])) {
                     $update_id = $slider_map[$slide['id']];
                     $parent_id = $slider_map[$slide['params']['parentid']];
                     $arrCreate = array();
                     $arrCreate["params"] = $slide['params'];
                     $arrCreate["params"]['parentid'] = $parent_id;
                     $my_params = json_encode($arrCreate["params"]);
                     if (empty($my_params)) {
                         $my_params = stripslashes(json_encode($arrCreate["params"]));
                     }
                     $arrCreate["params"] = $my_params;
                     $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $update_id));
                 }
                 $did_change = false;
                 foreach ($slide['layers'] as $key => $value) {
                     if (isset($value['layer_action'])) {
                         if (isset($value['layer_action']->jump_to_slide) && !empty($value['layer_action']->jump_to_slide)) {
                             $value['layer_action']->jump_to_slide = (array) $value['layer_action']->jump_to_slide;
                             foreach ($value['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $slide['layers'][$key]['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                     $did_change = true;
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($value, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($slide['layers'][$key]['layer_action'])) {
                             $slide['layers'][$key]['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($value, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($value, 'link_open_in');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'link');
                                 $slide['layers'][$key]['layer_action']->link_type = array('a' => 'a');
                                 $slide['layers'][$key]['layer_action']->image_link = array('a' => $link);
                                 $slide['layers'][$key]['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($slide['layers'][$key]['link']);
                                 unset($slide['layers'][$key]['link_open_in']);
                             case 'next':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'scroll_under');
                                 $slide['layers'][$key]['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($slide['layers'][$key]['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'jumpto');
                                 $slide['layers'][$key]['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $slide['layers'][$key]['layer_action']->tooltip_event = array('a' => 'click');
                         unset($slide['layers'][$key]['link_slide']);
                         $did_change = true;
                     }
                     if ($did_change === true) {
                         $arrCreate = array();
                         $my_layers = json_encode($slide['layers']);
                         if (empty($my_layers)) {
                             $my_layers = stripslashes(json_encode($layers));
                         }
                         $arrCreate['layers'] = $my_layers;
                         $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $slider_map[$slide['id']]));
                     }
                 }
             }
         }
         //check if static slide exists and import
         if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides']) && $import_statics) {
             $static_slide = $arrSlider['static_slides'];
             foreach ($static_slide as $slide) {
                 $params = $slide["params"];
                 $layers = $slide["layers"];
                 $settings = @$slide["settings"];
                 //convert params images:
                 if (isset($params["image"])) {
                     //import if exists in zip folder
                     if (strpos($params["image"], 'http') !== false) {
                     } else {
                         if (trim($params["image"]) !== '') {
                             if ($importZip === true) {
                                 //we have a zip, check if exists
                                 $image = $zip->getStream('images/' . $params["image"]);
                                 if (!$image) {
                                     echo $params["image"] . __(' not found!<br>', REVSLIDER_TEXTDOMAIN);
                                 } else {
                                     if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]])) {
                                         $importImage = RevSliderFunctionsWP::import_media('zip://' . $filepath . "#" . 'images/' . $params["image"], $sliderParams["alias"] . '/');
                                         if ($importImage !== false) {
                                             $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]] = $importImage['path'];
                                             $params["image"] = $importImage['path'];
                                         }
                                     } else {
                                         $params["image"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $params["image"]];
                                     }
                                 }
                             }
                         }
                         $params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
                     }
                 }
                 //convert layers images:
                 foreach ($layers as $key => $layer) {
                     if (isset($layer["image_url"])) {
                         //import if exists in zip folder
                         if (trim($layer["image_url"]) !== '') {
                             if (strpos($layer["image_url"], 'http') !== false) {
                             } else {
                                 if ($importZip === true) {
                                     //we have a zip, check if exists
                                     $image_url = $zip->getStream('images/' . $layer["image_url"]);
                                     if (!$image_url) {
                                         echo $layer["image_url"] . __(' not found!<br>');
                                     } else {
                                         if (!isset($alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]])) {
                                             $importImage = RevSliderFunctionsWP::import_media('zip://' . $filepath . "#" . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/');
                                             if ($importImage !== false) {
                                                 $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]] = $importImage['path'];
                                                 $layer["image_url"] = $importImage['path'];
                                             }
                                         } else {
                                             $layer["image_url"] = $alreadyImported['zip://' . $filepath . "#" . 'images/' . $layer["image_url"]];
                                         }
                                     }
                                 }
                             }
                         }
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                         $layer['text'] = stripslashes($layer['text']);
                     }
                     if (isset($layer['layer_action'])) {
                         if (isset($layer['layer_action']->jump_to_slide) && !empty($layer['layer_action']->jump_to_slide)) {
                             foreach ($layer['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $layer['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($value, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($layer['layer_action'])) {
                             $layer['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($value, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($value, 'link_open_in');
                                 $layer['layer_action']->action = array('a' => 'link');
                                 $layer['layer_action']->link_type = array('a' => 'a');
                                 $layer['layer_action']->image_link = array('a' => $link);
                                 $layer['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($layer['link']);
                                 unset($layer['link_open_in']);
                             case 'next':
                                 $layer['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $layer['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $layer['layer_action']->action = array('a' => 'scroll_under');
                                 $layer['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($layer['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $layer['layer_action']->action = array('a' => 'jumpto');
                                 $layer['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $layer['layer_action']->tooltip_event = array('a' => 'click');
                         unset($layer['link_slide']);
                         $did_change = true;
                     }
                     $layers[$key] = $layer;
                 }
                 //create new slide
                 $arrCreate = array();
                 $arrCreate["slider_id"] = $sliderID;
                 $my_layers = json_encode($layers);
                 if (empty($my_layers)) {
                     $my_layers = stripslashes(json_encode($layers));
                 }
                 $my_params = json_encode($params);
                 if (empty($my_params)) {
                     $my_params = stripslashes(json_encode($params));
                 }
                 $my_settings = json_encode($settings);
                 if (empty($my_settings)) {
                     $my_settings = stripslashes(json_encode($settings));
                 }
                 $arrCreate["layers"] = $my_layers;
                 $arrCreate["params"] = $my_params;
                 $arrCreate["settings"] = $my_settings;
                 if ($sliderExists) {
                     unset($arrCreate["slider_id"]);
                     $this->db->update(RevSliderGlobals::$table_static_slides, $arrCreate, array("slider_id" => $sliderID));
                 } else {
                     $this->db->insert(RevSliderGlobals::$table_static_slides, $arrCreate);
                 }
             }
         }
         $c_slider = new RevSliderSlider();
         $c_slider->initByID($sliderID);
         //check to convert styles to latest versions
         RevSliderPluginUpdate::update_css_styles();
         //set to version 5
         RevSliderPluginUpdate::add_animation_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_style_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::change_settings_on_layers($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_general_settings($c_slider);
         //set to version 5
         $cus_js = $c_slider->getParam('custom_javascript', '');
         if (strpos($cus_js, 'revapi') !== false) {
             if (preg_match_all('/revapi[0-9]*./', $cus_js, $results)) {
                 if (isset($results[0]) && !empty($results[0])) {
                     foreach ($results[0] as $replace) {
                         $cus_js = str_replace($replace, 'revapi' . $sliderID . '.', $cus_js);
                     }
                 }
                 $c_slider->updateParam(array('custom_javascript' => $cus_js));
             }
         }
         if ($is_template !== false) {
             //duplicate the slider now, as we just imported the "template"
             if ($single_slide !== false) {
                 //add now one Slide to the current Slider
                 $mslider = new RevSlider();
                 //change slide_id to correct, as it currently is just a number beginning from 0 as we did not have a correct slide ID yet.
                 $i = 0;
                 $changed = false;
                 foreach ($slider_map as $value) {
                     if ($i == $single_slide['slide_id']) {
                         $single_slide['slide_id'] = $value;
                         $changed = true;
                         break;
                     }
                     $i++;
                 }
                 if ($changed) {
                     $return = $mslider->copySlideToSlider($single_slide);
                 } else {
                     return array("success" => false, "error" => __('could not find correct Slide to copy, please try again.', REVSLIDER_TEXTDOMAIN), "sliderID" => $sliderID);
                 }
             } else {
                 $mslider = new RevSlider();
                 $title = RevSliderFunctions::getVal($sliderParams, 'title', 'slider1');
                 $talias = $title;
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $title . $ti;
                     $ti++;
                 }
                 $mslider->duplicateSliderFromData(array('sliderid' => $sliderID, 'title' => $talias));
             }
         }
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
         return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID);
     }
     return array("success" => true, "sliderID" => $sliderID);
 }
예제 #8
0
    /**
     * Output Dynamic Inline Styles
     */
    public function add_inline_styles()
    {
        if (!is_admin()) {
            echo '<script>var htmlDiv = document.getElementById("rs-plugin-settings-inline-css"); var htmlDivCss="';
        } else {
            echo "<style>";
        }
        $db = new RevSliderDB();
        $styles = $db->fetch(RevSliderGlobals::$table_css);
        foreach ($styles as $key => $style) {
            $handle = str_replace('.tp-caption', '', $style['handle']);
            if (!isset($this->class_include[$handle])) {
                unset($styles[$key]);
            }
        }
        $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n");
        $styles = RevSliderCssParser::compress_css($styles);
        if (!is_admin()) {
            echo addslashes($styles) . '";
				if(htmlDiv) {
					htmlDiv.innerHTML = htmlDiv.innerHTML + htmlDivCss;
				}else{
					var htmlDiv = document.createElement("div");
					htmlDiv.innerHTML = "<style>" + htmlDivCss + "</style>";
					document.getElementsByTagName("head")[0].appendChild(htmlDiv.childNodes[0]);
				}
			</script>' . "\n";
        } else {
            echo $styles . '</style>';
        }
    }
예제 #9
0
 /**
  * 
  * import slider from multipart form
  */
 public function importSliderFromPost($updateAnim = true, $updateStatic = true, $exactfilepath = false, $is_template = false, $single_slide = false, $updateNavigation = true)
 {
     try {
         $sliderID = RevSliderFunctions::getPostVariable("sliderid");
         $sliderExists = !empty($sliderID);
         if ($sliderExists) {
             $this->initByID($sliderID);
         }
         if ($exactfilepath !== false) {
             $filepath = $exactfilepath;
         } else {
             switch ($_FILES['import_file']['error']) {
                 case UPLOAD_ERR_OK:
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     RevSliderFunctions::throwError(__('No file sent.', 'revslider'));
                 case UPLOAD_ERR_INI_SIZE:
                 case UPLOAD_ERR_FORM_SIZE:
                     RevSliderFunctions::throwError(__('Exceeded filesize limit.', 'revslider'));
                 default:
                     break;
             }
             $filepath = $_FILES["import_file"]["tmp_name"];
         }
         if (file_exists($filepath) == false) {
             RevSliderFunctions::throwError(__('Import file not found!!!', 'revslider'));
         }
         $importZip = false;
         WP_Filesystem();
         global $wp_filesystem;
         $upload_dir = wp_upload_dir();
         $d_path = $upload_dir['basedir'] . '/rstemp/';
         $unzipfile = unzip_file($filepath, $d_path);
         if (is_wp_error($unzipfile)) {
             define('FS_METHOD', 'direct');
             //lets try direct.
             WP_Filesystem();
             //WP_Filesystem() needs to be called again since now we use direct !
             //@chmod($filepath, 0775);
             $unzipfile = unzip_file($filepath, $d_path);
             if (is_wp_error($unzipfile)) {
                 $d_path = RS_PLUGIN_PATH . 'rstemp/';
                 $unzipfile = unzip_file($filepath, $d_path);
                 if (is_wp_error($unzipfile)) {
                     $f = basename($filepath);
                     $d_path = str_replace($f, '', $filepath);
                     $unzipfile = unzip_file($filepath, $d_path);
                 }
             }
         }
         if (!is_wp_error($unzipfile)) {
             $importZip = true;
             //raus damit..
             //read all files needed
             $content = $wp_filesystem->exists($d_path . 'slider_export.txt') ? $wp_filesystem->get_contents($d_path . 'slider_export.txt') : '';
             if ($content == '') {
                 RevSliderFunctions::throwError(__('slider_export.txt does not exist!', 'revslider'));
             }
             $animations = $wp_filesystem->exists($d_path . 'custom_animations.txt') ? $wp_filesystem->get_contents($d_path . 'custom_animations.txt') : '';
             $dynamic = $wp_filesystem->exists($d_path . 'dynamic-captions.css') ? $wp_filesystem->get_contents($d_path . 'dynamic-captions.css') : '';
             $static = $wp_filesystem->exists($d_path . 'static-captions.css') ? $wp_filesystem->get_contents($d_path . 'static-captions.css') : '';
             $navigations = $wp_filesystem->exists($d_path . 'navigation.txt') ? $wp_filesystem->get_contents($d_path . 'navigation.txt') : '';
             $uid_check = $wp_filesystem->exists($d_path . 'info.cfg') ? $wp_filesystem->get_contents($d_path . 'info.cfg') : '';
             $version_check = $wp_filesystem->exists($d_path . 'version.cfg') ? $wp_filesystem->get_contents($d_path . 'version.cfg') : '';
             if ($is_template !== false) {
                 if ($uid_check != $is_template) {
                     return array("success" => false, "error" => __('Please select the correct zip file, checksum failed!', 'revslider'));
                 }
             } else {
                 //someone imported a template base Slider, check if it is existing in Base Sliders, if yes, check if it was imported
                 if ($uid_check !== '') {
                     $tmpl = new RevSliderTemplate();
                     $tmpl_slider = $tmpl->getThemePunchTemplateSliders();
                     foreach ($tmpl_slider as $tp_slider) {
                         if (!isset($tp_slider['installed'])) {
                             continue;
                         }
                         if ($tp_slider['uid'] == $uid_check) {
                             $is_template = $uid_check;
                             break;
                         }
                     }
                 }
             }
             $db = new RevSliderDB();
             //update/insert custom animations
             $animations = @unserialize($animations);
             if (!empty($animations)) {
                 foreach ($animations as $key => $animation) {
                     //$animation['id'], $animation['handle'], $animation['params']
                     $exist = $db->fetch(RevSliderGlobals::$table_layer_anims, $db->prepare("handle = %s", array($animation['handle'])));
                     if (!empty($exist)) {
                         //update the animation, get the ID
                         if ($updateAnim == "true") {
                             //overwrite animation if exists
                             $arrUpdate = array();
                             $arrUpdate['params'] = stripslashes(json_encode(str_replace("'", '"', $animation['params'])));
                             $db->update(RevSliderGlobals::$table_layer_anims, $arrUpdate, array('handle' => $animation['handle']));
                             $anim_id = $exist['0']['id'];
                         } else {
                             //insert with new handle
                             $arrInsert = array();
                             $arrInsert["handle"] = 'copy_' . $animation['handle'];
                             $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params'])));
                             $anim_id = $db->insert(RevSliderGlobals::$table_layer_anims, $arrInsert);
                         }
                     } else {
                         //insert the animation, get the ID
                         $arrInsert = array();
                         $arrInsert["handle"] = $animation['handle'];
                         $arrInsert["params"] = stripslashes(json_encode(str_replace("'", '"', $animation['params'])));
                         $anim_id = $db->insert(RevSliderGlobals::$table_layer_anims, $arrInsert);
                     }
                     //and set the current customin-oldID and customout-oldID in slider params to new ID from $id
                     $content = str_replace(array('customin-' . $animation['id'] . '"', 'customout-' . $animation['id'] . '"'), array('customin-' . $anim_id . '"', 'customout-' . $anim_id . '"'), $content);
                 }
                 dmp(__("animations imported!", 'revslider'));
             }
             //overwrite/append static-captions.css
             if (!empty($static)) {
                 if ($updateStatic == "true") {
                     //overwrite file
                     RevSliderOperations::updateStaticCss($static);
                 } elseif ($updateStatic == 'none') {
                     //do nothing
                 } else {
                     //append
                     $static_cur = RevSliderOperations::getStaticCss();
                     $static = $static_cur . "\n" . $static;
                     RevSliderOperations::updateStaticCss($static);
                 }
             }
             //overwrite/create dynamic-captions.css
             //parse css to classes
             $dynamicCss = RevSliderCssParser::parseCssToArray($dynamic);
             if (is_array($dynamicCss) && $dynamicCss !== false && count($dynamicCss) > 0) {
                 foreach ($dynamicCss as $class => $styles) {
                     //check if static style or dynamic style
                     $class = trim($class);
                     if (strpos($class, ',') !== false && strpos($class, '.tp-caption') !== false) {
                         //we have something like .tp-caption.redclass, .redclass
                         $class_t = explode(',', $class);
                         foreach ($class_t as $k => $cl) {
                             if (strpos($cl, '.tp-caption') !== false) {
                                 $class = $cl;
                             }
                         }
                     }
                     if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) {
                         //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img
                         continue;
                     }
                     //is a dynamic style
                     if (strpos($class, ':hover') !== false) {
                         $class = trim(str_replace(':hover', '', $class));
                         $arrInsert = array();
                         $arrInsert["hover"] = json_encode($styles);
                         $arrInsert["settings"] = json_encode(array('hover' => 'true'));
                     } else {
                         $arrInsert = array();
                         $arrInsert["params"] = json_encode($styles);
                         $arrInsert["settings"] = '';
                     }
                     //check if class exists
                     $result = $db->fetch(RevSliderGlobals::$table_css, $db->prepare("handle = %s", array($class)));
                     if (!empty($result)) {
                         //update
                         $db->update(RevSliderGlobals::$table_css, $arrInsert, array('handle' => $class));
                     } else {
                         //insert
                         $arrInsert["handle"] = $class;
                         $db->insert(RevSliderGlobals::$table_css, $arrInsert);
                     }
                 }
                 dmp(__("dynamic styles imported!", 'revslider'));
             }
             //update/insert custom animations
             $navigations = @unserialize($navigations);
             if (!empty($navigations)) {
                 foreach ($navigations as $key => $navigation) {
                     $exist = $db->fetch(RevSliderGlobals::$table_navigation, $db->prepare("handle = %s", array($navigation['handle'])));
                     unset($navigation['id']);
                     $rh = $navigation["handle"];
                     if (!empty($exist)) {
                         //create new navigation, get the ID
                         if ($updateNavigation == "true") {
                             //overwrite navigation if exists
                             unset($navigation['handle']);
                             $db->update(RevSliderGlobals::$table_navigation, $navigation, array('handle' => $rh));
                         } else {
                             //insert with new handle
                             $navigation["handle"] = $navigation['handle'] . '-' . date('is');
                             $navigation["name"] = $navigation['name'] . '-' . date('is');
                             $content = str_replace($rh . '"', $navigation["handle"] . '"', $content);
                             $navigation["css"] = str_replace('.' . $rh, '.' . $navigation["handle"], $navigation["css"]);
                             //change css class to the correct new class
                             $navi_id = $db->insert(RevSliderGlobals::$table_navigation, $navigation);
                         }
                     } else {
                         $navi_id = $db->insert(RevSliderGlobals::$table_navigation, $navigation);
                     }
                 }
                 dmp(__("navigations imported!", 'revslider'));
             }
         } else {
             $message = $unzipfile->get_error_message();
             $wp_filesystem->delete($d_path, true);
             return array("success" => false, "error" => $message);
         }
         //$content = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $content); //clear errors in string //deprecated in newest php version
         $content = preg_replace_callback('!s:(\\d+):"(.*?)";!', array('RevSliderSlider', 'clear_error_in_string'), $content);
         //clear errors in string
         $arrSlider = @unserialize($content);
         if (empty($arrSlider)) {
             $wp_filesystem->delete($d_path, true);
             RevSliderFunctions::throwError(__('Wrong export slider file format! Please make sure that the uploaded file is either a zip file with a correct slider_export.txt in the root of it or an valid slider_export.txt file.', 'revslider'));
         }
         //update slider params
         $sliderParams = $arrSlider["params"];
         if ($sliderExists) {
             $sliderParams["title"] = $this->arrParams["title"];
             $sliderParams["alias"] = $this->arrParams["alias"];
             $sliderParams["shortcode"] = $this->arrParams["shortcode"];
         }
         if (isset($sliderParams["background_image"])) {
             $sliderParams["background_image"] = RevSliderFunctionsWP::getImageUrlFromPath($sliderParams["background_image"]);
         }
         $import_statics = true;
         if (isset($sliderParams['enable_static_layers'])) {
             if ($sliderParams['enable_static_layers'] == 'off') {
                 $import_statics = false;
             }
             unset($sliderParams['enable_static_layers']);
         }
         $sliderParams['version'] = $version_check;
         $json_params = json_encode($sliderParams);
         //update slider or create new
         if ($sliderExists) {
             $arrUpdate = array("params" => $json_params);
             $this->db->update(RevSliderGlobals::$table_sliders, $arrUpdate, array("id" => $sliderID));
         } else {
             //new slider
             $arrInsert = array();
             $arrInsert['params'] = $json_params;
             //check if Slider with title and/or alias exists, if yes change both to stay unique
             $arrInsert['title'] = RevSliderFunctions::getVal($sliderParams, 'title', 'Slider1');
             $arrInsert['alias'] = RevSliderFunctions::getVal($sliderParams, 'alias', 'slider1');
             if ($is_template === false) {
                 //we want to stay at the given alias if we are a template
                 $talias = $arrInsert['alias'];
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $arrInsert['alias'] . $ti;
                     $ti++;
                 }
                 if ($talias !== $arrInsert['alias']) {
                     $sliderParams['title'] = $talias;
                     $sliderParams['alias'] = $talias;
                     $arrInsert['title'] = $talias;
                     $arrInsert['alias'] = $talias;
                     $json_params = json_encode($sliderParams);
                     $arrInsert['params'] = $json_params;
                 }
             }
             if ($is_template !== false) {
                 //add that we are an template
                 $arrInsert['type'] = 'template';
                 $sliderParams['uid'] = $is_template;
                 $json_params = json_encode($sliderParams);
                 $arrInsert['params'] = $json_params;
             }
             $sliderID = $this->db->insert(RevSliderGlobals::$table_sliders, $arrInsert);
         }
         //-------- Slides Handle -----------
         //delete current slides
         if ($sliderExists) {
             $this->deleteAllSlides();
         }
         //create all slides
         $arrSlides = $arrSlider["slides"];
         $alreadyImported = array();
         //$content_url = content_url();
         $upload_dir = wp_upload_dir();
         $content_url = $upload_dir['baseurl'] . '/revslider/assets/svg/';
         //wpml compatibility
         $slider_map = array();
         foreach ($arrSlides as $sl_key => $slide) {
             $params = $slide["params"];
             $layers = $slide["layers"];
             $settings = isset($slide["settings"]) ? $slide["settings"] : '';
             //convert params images:
             if ($importZip === true) {
                 //we have a zip, check if exists
                 //remove image_id as it is not needed in import
                 if (isset($params['image_id'])) {
                     unset($params['image_id']);
                 }
                 if (isset($params["image"])) {
                     $params["image"] = RevSliderBase::check_file_in_zip($d_path, $params["image"], $sliderParams["alias"], $alreadyImported);
                     $params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
                 }
                 if (isset($params["background_image"])) {
                     $params["background_image"] = RevSliderBase::check_file_in_zip($d_path, $params["background_image"], $sliderParams["alias"], $alreadyImported);
                     $params["background_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["background_image"]);
                 }
                 if (isset($params["slide_thumb"])) {
                     $params["slide_thumb"] = RevSliderBase::check_file_in_zip($d_path, $params["slide_thumb"], $sliderParams["alias"], $alreadyImported);
                     $params["slide_thumb"] = RevSliderFunctionsWP::getImageUrlFromPath($params["slide_thumb"]);
                 }
                 if (isset($params["show_alternate_image"])) {
                     $params["show_alternate_image"] = RevSliderBase::check_file_in_zip($d_path, $params["show_alternate_image"], $sliderParams["alias"], $alreadyImported);
                     $params["show_alternate_image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["show_alternate_image"]);
                 }
                 if (isset($params['background_type']) && $params['background_type'] == 'html5') {
                     if (isset($params['slide_bg_html_mpeg']) && $params['slide_bg_html_mpeg'] != '') {
                         $params['slide_bg_html_mpeg'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $params["slide_bg_html_mpeg"], $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_webm']) && $params['slide_bg_html_webm'] != '') {
                         $params['slide_bg_html_webm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $params["slide_bg_html_webm"], $sliderParams["alias"], $alreadyImported, true));
                     }
                     if (isset($params['slide_bg_html_ogv']) && $params['slide_bg_html_ogv'] != '') {
                         $params['slide_bg_html_ogv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $params["slide_bg_html_ogv"], $sliderParams["alias"], $alreadyImported, true));
                     }
                 }
             }
             //convert layers images:
             foreach ($layers as $key => $layer) {
                 //import if exists in zip folder
                 if ($importZip === true) {
                     //we have a zip, check if exists
                     if (isset($layer["image_url"])) {
                         $layer["image_url"] = RevSliderBase::check_file_in_zip($d_path, $layer["image_url"], $sliderParams["alias"], $alreadyImported);
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                     }
                     if (isset($layer['type']) && ($layer['type'] == 'video' || $layer['type'] == 'audio')) {
                         $video_data = isset($layer['video_data']) ? (array) $layer['video_data'] : array();
                         if (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] == 'html5') {
                             if (isset($video_data['urlPoster']) && $video_data['urlPoster'] != '') {
                                 $video_data['urlPoster'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlPoster"], $sliderParams["alias"], $alreadyImported));
                             }
                             if (isset($video_data['urlMp4']) && $video_data['urlMp4'] != '') {
                                 $video_data['urlMp4'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlMp4"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlWebm']) && $video_data['urlWebm'] != '') {
                                 $video_data['urlWebm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlWebm"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlOgv']) && $video_data['urlOgv'] != '') {
                                 $video_data['urlOgv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlOgv"], $sliderParams["alias"], $alreadyImported, true));
                             }
                         } elseif (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] != 'html5') {
                             //video cover image
                             if ($video_data['video_type'] == 'audio') {
                                 if (isset($video_data['urlAudio']) && $video_data['urlAudio'] != '') {
                                     $video_data['urlAudio'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlAudio"], $sliderParams["alias"], $alreadyImported, true));
                                 }
                             } else {
                                 if (isset($video_data['previewimage']) && $video_data['previewimage'] != '') {
                                     $video_data['previewimage'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["previewimage"], $sliderParams["alias"], $alreadyImported));
                                 }
                             }
                         }
                         $layer['video_data'] = $video_data;
                     }
                     if (isset($layer['type']) && $layer['type'] == 'svg') {
                         if (isset($layer['svg']) && isset($layer['svg']->src)) {
                             if (strpos($layer['svg']->src, 'revslider-whiteboard-addon') !== false) {
                                 $layer['svg']->src = content_url() . $layer['svg']->src;
                             } else {
                                 $layer['svg']->src = str_replace('/plugins/revslider/public/assets/assets/svg/', '', $content_url . $layer['svg']->src);
                             }
                         }
                     }
                 }
                 $layer['text'] = stripslashes($layer['text']);
                 $layers[$key] = $layer;
             }
             $arrSlides[$sl_key]['layers'] = $layers;
             //create new slide
             $arrCreate = array();
             $arrCreate["slider_id"] = $sliderID;
             $arrCreate["slide_order"] = $slide["slide_order"];
             $my_layers = json_encode($layers);
             if (empty($my_layers)) {
                 $my_layers = stripslashes(json_encode($layers));
             }
             $my_params = json_encode($params);
             if (empty($my_params)) {
                 $my_params = stripslashes(json_encode($params));
             }
             $my_settings = json_encode($settings);
             if (empty($my_settings)) {
                 $my_settings = stripslashes(json_encode($settings));
             }
             $arrCreate["layers"] = $my_layers;
             $arrCreate["params"] = $my_params;
             $arrCreate["settings"] = $my_settings;
             $last_id = $this->db->insert(RevSliderGlobals::$table_slides, $arrCreate);
             if (isset($slide['id'])) {
                 $slider_map[$slide['id']] = $last_id;
             }
         }
         //change for WPML the parent IDs if necessary
         if (!empty($slider_map)) {
             foreach ($arrSlides as $sl_key => $slide) {
                 if (isset($slide['params']['parentid']) && isset($slider_map[$slide['params']['parentid']])) {
                     $update_id = $slider_map[$slide['id']];
                     $parent_id = $slider_map[$slide['params']['parentid']];
                     $arrCreate = array();
                     $arrCreate["params"] = $slide['params'];
                     $arrCreate["params"]['parentid'] = $parent_id;
                     $my_params = json_encode($arrCreate["params"]);
                     if (empty($my_params)) {
                         $my_params = stripslashes(json_encode($arrCreate["params"]));
                     }
                     $arrCreate["params"] = $my_params;
                     $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $update_id));
                 }
                 $did_change = false;
                 foreach ($slide['layers'] as $key => $value) {
                     if (isset($value['layer_action'])) {
                         if (isset($value['layer_action']->jump_to_slide) && !empty($value['layer_action']->jump_to_slide)) {
                             $value['layer_action']->jump_to_slide = (array) $value['layer_action']->jump_to_slide;
                             foreach ($value['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $slide['layers'][$key]['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                     $did_change = true;
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($value, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($slide['layers'][$key]['layer_action'])) {
                             $slide['layers'][$key]['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($value, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($value, 'link_open_in');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'link');
                                 $slide['layers'][$key]['layer_action']->link_type = array('a' => 'a');
                                 $slide['layers'][$key]['layer_action']->image_link = array('a' => $link);
                                 $slide['layers'][$key]['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($slide['layers'][$key]['link']);
                                 unset($slide['layers'][$key]['link_open_in']);
                             case 'next':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'scroll_under');
                                 $slide['layers'][$key]['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($slide['layers'][$key]['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $slide['layers'][$key]['layer_action']->action = array('a' => 'jumpto');
                                 $slide['layers'][$key]['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $slide['layers'][$key]['layer_action']->tooltip_event = array('a' => 'click');
                         unset($slide['layers'][$key]['link_slide']);
                         $did_change = true;
                     }
                     if ($did_change === true) {
                         $arrCreate = array();
                         $my_layers = json_encode($slide['layers']);
                         if (empty($my_layers)) {
                             $my_layers = stripslashes(json_encode($layers));
                         }
                         $arrCreate['layers'] = $my_layers;
                         $this->db->update(RevSliderGlobals::$table_slides, $arrCreate, array("id" => $slider_map[$slide['id']]));
                     }
                 }
             }
         }
         //check if static slide exists and import
         if (isset($arrSlider['static_slides']) && !empty($arrSlider['static_slides']) && $import_statics) {
             $static_slide = $arrSlider['static_slides'];
             foreach ($static_slide as $slide) {
                 $params = $slide["params"];
                 $layers = $slide["layers"];
                 $settings = isset($slide["settings"]) ? $slide["settings"] : '';
                 //remove image_id as it is not needed in import
                 if (isset($params['image_id'])) {
                     unset($params['image_id']);
                 }
                 //convert params images:
                 if (isset($params["image"])) {
                     //import if exists in zip folder
                     if (strpos($params["image"], 'http') !== false) {
                     } else {
                         if (trim($params["image"]) !== '') {
                             if ($importZip === true) {
                                 //we have a zip, check if exists
                                 $image = $wp_filesystem->exists($d_path . 'images/' . $params["image"]);
                                 if (!$image) {
                                     echo $params["image"] . __(' not found!<br>', 'revslider');
                                 } else {
                                     if (!isset($alreadyImported['images/' . $params["image"]])) {
                                         $importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $params["image"], $sliderParams["alias"] . '/');
                                         if ($importImage !== false) {
                                             $alreadyImported['images/' . $params["image"]] = $importImage['path'];
                                             $params["image"] = $importImage['path'];
                                         }
                                     } else {
                                         $params["image"] = $alreadyImported['images/' . $params["image"]];
                                     }
                                 }
                             }
                         }
                         $params["image"] = RevSliderFunctionsWP::getImageUrlFromPath($params["image"]);
                     }
                 }
                 //convert layers images:
                 foreach ($layers as $key => $layer) {
                     if (isset($layer["image_url"])) {
                         //import if exists in zip folder
                         if (trim($layer["image_url"]) !== '') {
                             if (strpos($layer["image_url"], 'http') !== false) {
                             } else {
                                 if ($importZip === true) {
                                     //we have a zip, check if exists
                                     $image_url = $wp_filesystem->exists($d_path . 'images/' . $layer["image_url"]);
                                     if (!$image_url) {
                                         echo $layer["image_url"] . __(' not found!<br>');
                                     } else {
                                         if (!isset($alreadyImported['images/' . $layer["image_url"]])) {
                                             $importImage = RevSliderFunctionsWP::import_media($d_path . 'images/' . $layer["image_url"], $sliderParams["alias"] . '/');
                                             if ($importImage !== false) {
                                                 $alreadyImported['images/' . $layer["image_url"]] = $importImage['path'];
                                                 $layer["image_url"] = $importImage['path'];
                                             }
                                         } else {
                                             $layer["image_url"] = $alreadyImported['images/' . $layer["image_url"]];
                                         }
                                     }
                                 }
                             }
                         }
                         $layer["image_url"] = RevSliderFunctionsWP::getImageUrlFromPath($layer["image_url"]);
                     }
                     $layer['text'] = stripslashes($layer['text']);
                     if (isset($layer['type']) && ($layer['type'] == 'video' || $layer['type'] == 'audio')) {
                         $video_data = isset($layer['video_data']) ? (array) $layer['video_data'] : array();
                         if (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] == 'html5') {
                             if (isset($video_data['urlPoster']) && $video_data['urlPoster'] != '') {
                                 $video_data['urlPoster'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlPoster"], $sliderParams["alias"], $alreadyImported));
                             }
                             if (isset($video_data['urlMp4']) && $video_data['urlMp4'] != '') {
                                 $video_data['urlMp4'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlMp4"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlWebm']) && $video_data['urlWebm'] != '') {
                                 $video_data['urlWebm'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlWebm"], $sliderParams["alias"], $alreadyImported, true));
                             }
                             if (isset($video_data['urlOgv']) && $video_data['urlOgv'] != '') {
                                 $video_data['urlOgv'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlOgv"], $sliderParams["alias"], $alreadyImported, true));
                             }
                         } elseif (!empty($video_data) && isset($video_data['video_type']) && $video_data['video_type'] != 'html5') {
                             //video cover image
                             if ($video_data['video_type'] == 'audio') {
                                 if (isset($video_data['urlAudio']) && $video_data['urlAudio'] != '') {
                                     $video_data['urlAudio'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["urlAudio"], $sliderParams["alias"], $alreadyImported, true));
                                 }
                             } else {
                                 if (isset($video_data['previewimage']) && $video_data['previewimage'] != '') {
                                     $video_data['previewimage'] = RevSliderFunctionsWP::getImageUrlFromPath(RevSliderBase::check_file_in_zip($d_path, $video_data["previewimage"], $sliderParams["alias"], $alreadyImported));
                                 }
                             }
                         }
                         $layer['video_data'] = $video_data;
                     }
                     if (isset($layer['type']) && $layer['type'] == 'svg') {
                         if (isset($layer['svg']) && isset($layer['svg']->src)) {
                             $layer['svg']->src = str_replace('/plugins/revslider/public/assets/assets/svg/', '', $content_url . $layer['svg']->src);
                         }
                     }
                     if (isset($layer['layer_action'])) {
                         if (isset($layer['layer_action']->jump_to_slide) && !empty($layer['layer_action']->jump_to_slide)) {
                             foreach ($layer['layer_action']->jump_to_slide as $jtsk => $jtsval) {
                                 if (isset($slider_map[$jtsval])) {
                                     $layer['layer_action']->jump_to_slide[$jtsk] = $slider_map[$jtsval];
                                 }
                             }
                         }
                     }
                     $link_slide = RevSliderFunctions::getVal($layer, 'link_slide', false);
                     if ($link_slide != false && $link_slide !== 'nothing') {
                         //link to slide/scrollunder is set, move it to actions
                         if (!isset($layer['layer_action'])) {
                             $layer['layer_action'] = new stdClass();
                         }
                         switch ($link_slide) {
                             case 'link':
                                 $link = RevSliderFunctions::getVal($layer, 'link');
                                 $link_open_in = RevSliderFunctions::getVal($layer, 'link_open_in');
                                 $layer['layer_action']->action = array('a' => 'link');
                                 $layer['layer_action']->link_type = array('a' => 'a');
                                 $layer['layer_action']->image_link = array('a' => $link);
                                 $layer['layer_action']->link_open_in = array('a' => $link_open_in);
                                 unset($layer['link']);
                                 unset($layer['link_open_in']);
                             case 'next':
                                 $layer['layer_action']->action = array('a' => 'next');
                                 break;
                             case 'prev':
                                 $layer['layer_action']->action = array('a' => 'prev');
                                 break;
                             case 'scroll_under':
                                 $scrollunder_offset = RevSliderFunctions::getVal($value, 'scrollunder_offset');
                                 $layer['layer_action']->action = array('a' => 'scroll_under');
                                 $layer['layer_action']->scrollunder_offset = array('a' => $scrollunder_offset);
                                 unset($layer['scrollunder_offset']);
                                 break;
                             default:
                                 //its an ID, so its a slide ID
                                 $layer['layer_action']->action = array('a' => 'jumpto');
                                 $layer['layer_action']->jump_to_slide = array('a' => $slider_map[$link_slide]);
                                 break;
                         }
                         $layer['layer_action']->tooltip_event = array('a' => 'click');
                         unset($layer['link_slide']);
                         $did_change = true;
                     }
                     $layers[$key] = $layer;
                 }
                 //create new slide
                 $arrCreate = array();
                 $arrCreate["slider_id"] = $sliderID;
                 $my_layers = json_encode($layers);
                 if (empty($my_layers)) {
                     $my_layers = stripslashes(json_encode($layers));
                 }
                 $my_params = json_encode($params);
                 if (empty($my_params)) {
                     $my_params = stripslashes(json_encode($params));
                 }
                 $my_settings = json_encode($settings);
                 if (empty($my_settings)) {
                     $my_settings = stripslashes(json_encode($settings));
                 }
                 $arrCreate["layers"] = $my_layers;
                 $arrCreate["params"] = $my_params;
                 $arrCreate["settings"] = $my_settings;
                 if ($sliderExists) {
                     unset($arrCreate["slider_id"]);
                     $this->db->update(RevSliderGlobals::$table_static_slides, $arrCreate, array("slider_id" => $sliderID));
                 } else {
                     $this->db->insert(RevSliderGlobals::$table_static_slides, $arrCreate);
                 }
             }
         }
         $c_slider = new RevSliderSlider();
         $c_slider->initByID($sliderID);
         //check to convert styles to latest versions
         RevSliderPluginUpdate::update_css_styles();
         //set to version 5
         RevSliderPluginUpdate::add_animation_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_style_settings_to_layer($c_slider);
         //set to version 5
         RevSliderPluginUpdate::change_settings_on_layers($c_slider);
         //set to version 5
         RevSliderPluginUpdate::add_general_settings($c_slider);
         //set to version 5
         RevSliderPluginUpdate::change_general_settings_5_0_7($c_slider);
         //set to version 5.0.7
         RevSliderPluginUpdate::change_layers_svg_5_2_5_4($c_slider);
         //set to version 5.2.5.4
         $cus_js = $c_slider->getParam('custom_javascript', '');
         if (strpos($cus_js, 'revapi') !== false) {
             if (preg_match_all('/revapi[0-9]*/', $cus_js, $results)) {
                 if (isset($results[0]) && !empty($results[0])) {
                     foreach ($results[0] as $replace) {
                         $cus_js = str_replace($replace, 'revapi' . $sliderID, $cus_js);
                     }
                 }
                 $c_slider->updateParam(array('custom_javascript' => $cus_js));
             }
         }
         if ($is_template !== false) {
             //duplicate the slider now, as we just imported the "template"
             if ($single_slide !== false) {
                 //add now one Slide to the current Slider
                 $mslider = new RevSlider();
                 //change slide_id to correct, as it currently is just a number beginning from 0 as we did not have a correct slide ID yet.
                 $i = 0;
                 $changed = false;
                 foreach ($slider_map as $value) {
                     if ($i == $single_slide['slide_id']) {
                         $single_slide['slide_id'] = $value;
                         $changed = true;
                         break;
                     }
                     $i++;
                 }
                 if ($changed) {
                     $return = $mslider->copySlideToSlider($single_slide);
                 } else {
                     return array("success" => false, "error" => __('could not find correct Slide to copy, please try again.', 'revslider'), "sliderID" => $sliderID);
                 }
             } else {
                 $mslider = new RevSlider();
                 $title = RevSliderFunctions::getVal($sliderParams, 'title', 'slider1');
                 $talias = $title;
                 $ti = 1;
                 while ($this->isAliasExistsInDB($talias)) {
                     //set a new alias and title if its existing in database
                     $talias = $title . $ti;
                     $ti++;
                 }
                 $mslider->duplicateSliderFromData(array('sliderid' => $sliderID, 'title' => $talias));
             }
         }
         $wp_filesystem->delete($d_path, true);
     } catch (Exception $e) {
         $errorMessage = $e->getMessage();
         if (isset($d_path)) {
             $wp_filesystem->delete($d_path, true);
         }
         return array("success" => false, "error" => $errorMessage, "sliderID" => $sliderID);
     }
     return array("success" => true, "sliderID" => $sliderID);
 }
예제 #10
0
 /**
  * Output Dynamic Inline Styles
  */
 public function add_inline_styles()
 {
     if (!is_admin()) {
         echo '<script>var htmlDiv = document.getElementById("rs-plugin-settings-inline-css");htmlDiv.innerHTML = htmlDiv.innerHTML + unescape("';
     } else {
         echo "<style>";
     }
     $db = new RevSliderDB();
     $styles = $db->fetch(RevSliderGlobals::$table_css);
     foreach ($styles as $key => $style) {
         $handle = str_replace('.tp-caption', '', $style['handle']);
         if (!isset($this->class_include[$handle])) {
             unset($styles[$key]);
         }
     }
     $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n");
     $styles = RevSliderCssParser::compress_css($styles);
     if (!is_admin()) {
         echo addslashes($styles) . '");</script>' . "\n";
     } else {
         echo $styles . '</style>';
     }
 }
예제 #11
0
 /**
  *
  * import contents of the css file
  */
 public static function importCaptionsCssContentArray()
 {
     $db = new RevSliderDB();
     $css = self::getCaptionsCssContentArray();
     $static = array();
     if (is_array($css) && $css !== false && count($css) > 0) {
         foreach ($css as $class => $styles) {
             //check if static style or dynamic style
             $class = trim($class);
             if (strpos($class, ':hover') === false && strpos($class, ':') !== false || strpos($class, " ") !== false || strpos($class, ".tp-caption") === false || (strpos($class, ".") === false || strpos($class, "#") !== false) || strpos($class, ">") !== false) {
                 //.tp-caption>.imageclass or .tp-caption.imageclass>img or .tp-caption.imageclass .img
                 $static[$class] = $styles;
                 continue;
             }
             //is a dynamic style
             if (strpos($class, ':hover') !== false) {
                 $class = trim(str_replace(':hover', '', $class));
                 $arrInsert = array();
                 $arrInsert["hover"] = json_encode($styles);
                 $arrInsert["settings"] = json_encode(array('hover' => 'true'));
             } else {
                 $arrInsert = array();
                 $arrInsert["params"] = json_encode($styles);
             }
             //check if class exists
             $result = $db->fetch(RevSliderGlobals::$table_css, $db->prepare("handle = %s", array($class)));
             if (!empty($result)) {
                 //update
                 $db->update(RevSliderGlobals::$table_css, $arrInsert, array('handle' => $class));
             } else {
                 //insert
                 $arrInsert["handle"] = $class;
                 $db->insert(RevSliderGlobals::$table_css, $arrInsert);
             }
         }
     }
     if (!empty($static)) {
         //save static into static-captions.css
         $css = RevSliderCssParser::parseStaticArrayToCss($static);
         $static_cur = RevSliderOperations::getStaticCss();
         //get the open sans line!
         $css = $static_cur . "\n" . $css;
         self::updateStaticCss($css);
     }
 }
예제 #12
0
 /**
  * Output Dynamic Inline Styles
  */
 public function add_inline_styles()
 {
     if (!is_admin()) {
         echo '<script>document.write("<style type=\\"text/css\\">';
     } else {
         echo "<style>";
     }
     $db = new RevSliderDB();
     $styles = $db->fetch(RevSliderGlobals::$table_css);
     foreach ($styles as $key => $style) {
         $handle = str_replace('.tp-caption', '', $style['handle']);
         if (!isset($this->class_include[$handle])) {
             unset($styles[$key]);
         }
     }
     $styles = RevSliderCssParser::parseDbArrayToCss($styles, "\n");
     $styles = RevSliderCssParser::compress_css($styles);
     if (!is_admin()) {
         echo addslashes($styles) . '</style>");</script>' . "\n";
     } else {
         echo $styles . '</style>';
     }
 }
예제 #13
0
function ts_show_page_slider()
{
    global $ts_page_datas;
    $revolution_exists = class_exists('RevSlider') && class_exists('UniteFunctionsRev');
    switch ($ts_page_datas['ts_page_slider']) {
        case 'revslider':
            if ($revolution_exists && $ts_page_datas['ts_rev_slider']) {
                $rev_db = new RevSliderDB();
                $response = $rev_db->fetch(RevSliderGlobals::$table_sliders, 'id=' . $ts_page_datas['ts_rev_slider']);
                if (!empty($response)) {
                    RevSliderOutput::putSlider($ts_page_datas['ts_rev_slider'], '');
                }
            }
            break;
        default:
            break;
    }
}