Beispiel #1
0
 public function update($table, $arrItems, $where)
 {
     $response = $this->wpdb->update($table, $arrItems, $where);
     if ($response === false) {
         UniteFunctionsBanner::throwError("no update action taken!");
     }
     $this->checkForErrors("Update query error");
     return $this->wpdb->num_rows;
 }
 public function getFieldFromDB($name)
 {
     $arr = $this->db->fetch(GlobalsBannerRotator::$table_settings);
     if (empty($arr)) {
         return "";
     }
     $arr = $arr[0];
     if (array_key_exists($name, $arr) == false) {
         UniteFunctionsBanner::throwError("The settings db should cotnain field: {$name}");
     }
     $value = $arr[$name];
     return $value;
 }
 public static function isDBTableExists($tableName)
 {
     global $wpdb;
     if (empty($tableName)) {
         UniteFunctionsBanner::throwError("Empty table name!!!");
     }
     $sql = "show tables like '{$tableName}'";
     $table = $wpdb->get_var($sql);
     if ($table == $tableName) {
         return true;
     }
     return false;
 }
    public function draw($formID = null, $drawForm = false)
    {
        if (empty($formID)) {
            UniteFunctionsBanner::throwError("The form ID can't be empty. you must provide it");
        }
        $this->formID = $formID;
        ?>
				<div class="settings_wrapper unite_settings_wide">
			<?php 
        if ($drawForm == true) {
            ?>
				<form name="<?php 
            echo $formID;
            ?>
" id="<?php 
            echo $formID;
            ?>
">
					<?php 
            $this->drawSettings();
            ?>
				</form>
				<?php 
        } else {
            $this->drawSettings();
        }
        ?>
			</div>
			<?php 
    }
 public static function onAjaxAction()
 {
     $slider = new BannerRotator();
     $slide = new BannerSlide();
     $operations = new BannerOperations();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     $nonce = self::getPostGetVar("nonce");
     try {
         //Verify the nonce
         $isVerified = wp_verify_nonce($nonce, "bannerrotator_actions");
         if ($isVerified == false) {
             UniteFunctionsBanner::throwError("Wrong request");
         }
         switch ($action) {
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $dummy = self::getGetVar("dummy");
                 $slider->initByID($sliderID);
                 $slider->exportSlider($dummy);
                 break;
             case "import_slider":
                 self::importSliderHandle();
                 break;
             case "import_slider_slidersview":
                 $viewBack = self::getViewUrl(self::VIEW_SLIDERS);
                 self::importSliderHandle($viewBack);
                 break;
             case "create_slider":
                 $newSliderID = $slider->createSliderFromOptions($data);
                 self::ajaxResponseSuccessRedirect(__("The slider successfully created", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 $slider->updateSliderFromOptions($data);
                 self::ajaxResponseSuccess(__("Slider updated", BANNERROTATOR_TEXTDOMAIN));
                 break;
             case "delete_slider":
                 $slider->deleteSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The slider deleted", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The duplicate successfully, refreshing page...", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $numSlides = $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 if ($numSlides == 1) {
                     $responseText = __("Slide Created", BANNERROTATOR_TEXTDOMAIN);
                 } else {
                     $responseText = $numSlides . " " . __("Slides Created", BANNERROTATOR_TEXTDOMAIN);
                 }
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}");
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "add_slide_fromslideview":
                 $slideID = $slider->createSlideFromData($data, true);
                 $urlRedirect = self::getViewUrl(self::VIEW_SLIDE, "id={$slideID}");
                 $responseText = __("Slide Created, redirecting...", BANNERROTATOR_TEXTDOMAIN);
                 self::ajaxResponseSuccessRedirect($responseText, $urlRedirect);
                 break;
             case "update_slide":
                 $slide->updateSlideFromData($data);
                 self::ajaxResponseSuccess(__("Slide updated", BANNERROTATOR_TEXTDOMAIN));
                 break;
             case "delete_slide":
                 $slide->deleteSlideFromData($data);
                 $sliderID = UniteFunctionsBanner::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect(__("Slide Deleted Successfully", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("Slide Duplicated Successfully", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "copy_move_slide":
                 $sliderID = $slider->copyMoveSlideFromData($data);
                 self::ajaxResponseSuccessRedirect(__("The operation successfully, refreshing page...", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "get_captions_css":
                 $contentCSS = $operations->getCaptionsContent();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "update_captions_css":
                 $arrCaptions = $operations->updateCaptionsContentData($data);
                 self::ajaxResponseSuccess(__("CSS file saved succesfully!", BANNERROTATOR_TEXTDOMAIN), array("arrCaptions" => $arrCaptions));
                 break;
             case "restore_captions_css":
                 $operations->restoreCaptionsCss();
                 $contentCSS = $operations->getCaptionsContent();
                 self::ajaxResponseData($contentCSS);
                 break;
             case "update_slides_order":
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess(__("Order updated successfully", BANNERROTATOR_TEXTDOMAIN));
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 $sliderID = UniteFunctionsBanner::getVal($data, "slider_id");
                 self::ajaxResponseSuccessRedirect(__("Slide Changed Successfully", BANNERROTATOR_TEXTDOMAIN), self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsBanner::getPostVariable("sliderid");
                 $operations->previewOutput($sliderID);
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStateFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "slide_lang_operation":
                 $responseData = $slide->doSlideLangOperation($data);
                 self::ajaxResponseData($responseData);
                 break;
             case "update_plugin":
                 self::updatePlugin(self::DEFAULT_VIEW);
                 break;
             case "update_text":
                 self::updateSettingsText();
                 self::ajaxResponseSuccess("All files successfully updated");
                 break;
             case "update_general_settings":
                 $operations->updateGeneralSettings($data);
                 self::ajaxResponseSuccess(__("General settings updated"));
                 break;
             default:
                 self::ajaxResponseError("wrong ajax action: {$action} ");
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         self::ajaxResponseError($message);
     }
     //It's an ajax action, so exit
     self::ajaxResponseError("No response output on <b> {$action} </b> action. please check with the developer.");
     exit;
 }
    public function draw($formID = null)
    {
        if (empty($formID)) {
            UniteFunctionsBanner::throwError("You must provide formID to side settings.");
        }
        $this->formID = $formID;
        if (!empty($formID)) {
            ?>
				<form name="<?php 
            echo $formID;
            ?>
" id="<?php 
            echo $formID;
            ?>
">
					<?php 
            $this->drawSettings();
            ?>
				</form>
				<?php 
        } else {
            $this->drawSettings();
        }
        if ($this->isAccordion == true) {
            $this->putAccordionInit();
        }
    }
    private function putCreativeLayer(BannerSlide $slide)
    {
        $layers = $slide->getLayers();
        if (empty($layers)) {
            return false;
        }
        ?>
				<?php 
        foreach ($layers as $layer) {
            $type = UniteFunctionsBanner::getVal($layer, "type", "text");
            //Set if video full screen
            $isFullWidthVideo = false;
            if ($type == "video") {
                $videoData = UniteFunctionsBanner::getVal($layer, "video_data");
                if (!empty($videoData)) {
                    $videoData = (array) $videoData;
                    $isFullWidthVideo = UniteFunctionsBanner::getVal($videoData, "fullwidth");
                    $isFullWidthVideo = UniteFunctionsBanner::strToBool($isFullWidthVideo);
                } else {
                    $videoData = array();
                }
            }
            $class = UniteFunctionsBanner::getVal($layer, "style");
            $animation = UniteFunctionsBanner::getVal($layer, "animation", "fade");
            //Set output class
            $outputClass = "caption " . trim($class);
            $outputClass = trim($outputClass) . " ";
            $outputClass .= trim($animation);
            $left = UniteFunctionsBanner::getVal($layer, "left", 0);
            $top = UniteFunctionsBanner::getVal($layer, "top", 0);
            $speed = UniteFunctionsBanner::getVal($layer, "speed", 300);
            $time = UniteFunctionsBanner::getVal($layer, "time", 0);
            $easing = UniteFunctionsBanner::getVal($layer, "easing", "easeOutExpo");
            $randomRotate = UniteFunctionsBanner::getVal($layer, "random_rotation", "false");
            $randomRotate = UniteFunctionsBanner::boolToStr($randomRotate);
            $text = UniteFunctionsBanner::getVal($layer, "text");
            $htmlVideoAutoplay = "";
            $htmlVideoNextSlide = "";
            //Set html
            $html = "";
            switch ($type) {
                default:
                case "text":
                    $html = $text;
                    $html = do_shortcode($html);
                    break;
                case "image":
                    $urlImage = UniteFunctionsBanner::getVal($layer, "image_url");
                    $html = '<img src="' . $urlImage . '" alt="' . $text . '">';
                    $imageLink = UniteFunctionsBanner::getVal($layer, "link", "");
                    if (!empty($imageLink)) {
                        $openIn = UniteFunctionsBanner::getVal($layer, "link_open_in", "same");
                        $target = "";
                        if ($openIn == "new") {
                            $target = ' target="_blank"';
                        }
                        $html = '<a href="' . $imageLink . '"' . $target . '>' . $html . '</a>';
                    }
                    break;
                case "video":
                    $videoType = trim(UniteFunctionsBanner::getVal($layer, "video_type"));
                    $videoID = trim(UniteFunctionsBanner::getVal($layer, "video_id"));
                    $videoWidth = trim(UniteFunctionsBanner::getVal($layer, "video_width"));
                    $videoHeight = trim(UniteFunctionsBanner::getVal($layer, "video_height"));
                    $videoArgs = trim(UniteFunctionsBanner::getVal($layer, "video_args"));
                    if ($isFullWidthVideo == true) {
                        $videoWidth = "100%";
                        $videoHeight = "100%";
                    }
                    $setBase = is_ssl() ? "https://" : "http://";
                    switch ($videoType) {
                        case "youtube":
                            if (empty($videoArgs)) {
                                $videoArgs = GlobalsBannerRotator::DEFAULT_YOUTUBE_ARGUMENTS;
                            }
                            $videoArgs .= ';origin=' . $setBase . $_SERVER['SERVER_NAME'] . ';';
                            $html = "<iframe src='http://www.youtube.com/embed/{$videoID}?{$videoArgs}' width='{$videoWidth}' height='{$videoHeight}' style='width:{$videoWidth}px;height:{$videoHeight}px;'></iframe>";
                            break;
                        case "vimeo":
                            if (empty($videoArgs)) {
                                $videoArgs = GlobalsBannerRotator::DEFAULT_VIMEO_ARGUMENTS;
                            }
                            $html = "<iframe src='http://player.vimeo.com/video/{$videoID}?{$videoArgs}' width='{$videoWidth}' height='{$videoHeight}' style='width:{$videoWidth}px;height:{$videoHeight}px;'></iframe>";
                            break;
                        case "html5":
                            $html = $this->getHtml5LayerHtml($videoData);
                            break;
                        default:
                            UniteFunctionsBanner::throwError("wrong video type: {$videoType}");
                            break;
                    }
                    //Set video autoplay, with backward compatability
                    if (array_key_exists("autoplay", $videoData)) {
                        $videoAutoplay = UniteFunctionsBanner::getVal($videoData, "autoplay");
                    } else {
                        //Backward compatability
                        $videoAutoplay = UniteFunctionsBanner::getVal($layer, "video_autoplay");
                    }
                    $videoAutoplay = UniteFunctionsBanner::strToBool($videoAutoplay);
                    if ($videoAutoplay == true) {
                        $htmlVideoAutoplay = ' data-autoplay="true"';
                    }
                    $videoNextSlide = UniteFunctionsBanner::getVal($videoData, "nextslide");
                    $videoNextSlide = UniteFunctionsBanner::strToBool($videoNextSlide);
                    if ($videoNextSlide == true) {
                        $htmlVideoNextSlide = ' data-nextslideatend="true"';
                    }
                    break;
            }
            //Handle end transitions
            $endTime = trim(UniteFunctionsBanner::getVal($layer, "endtime"));
            $htmlEnd = "";
            if (!empty($endTime)) {
                $htmlEnd = "data-end=\"{$endTime}\"";
                $endSpeed = trim(UniteFunctionsBanner::getVal($layer, "endspeed"));
                if (!empty($endSpeed)) {
                    $htmlEnd .= " data-endspeed=\"{$endSpeed}\"";
                }
                $endEasing = trim(UniteFunctionsBanner::getVal($layer, "endeasing"));
                if (!empty($endSpeed) && $endEasing != "nothing") {
                    $htmlEnd .= " data-endeasing=\"{$endEasing}\"";
                }
                //Add animation to class
                $endAnimation = trim(UniteFunctionsBanner::getVal($layer, "endanimation"));
                if (!empty($endAnimation) && $endAnimation != "auto") {
                    $outputClass .= " " . $endAnimation;
                }
            }
            //Slide link
            $htmlLink = "";
            $slideLink = UniteFunctionsBanner::getVal($layer, "link_slide");
            if (!empty($slideLink) && $slideLink != "nothing" && $slideLink != "scroll_under") {
                //Get slide index from id
                if (is_numeric($slideLink)) {
                    $slideLink = UniteFunctionsBanner::getVal($this->slidesNumIndex, $slideLink);
                }
                if (!empty($slideLink)) {
                    $htmlLink = " data-linktoslide=\"{$slideLink}\"";
                }
            }
            //Scroll under the slider
            if ($slideLink == "scroll_under") {
                $outputClass .= " fb-scrollbelowslider";
                $scrollUnderOffset = UniteFunctionsBanner::getVal($layer, "scrollunder_offset");
                if (!empty($scrollUnderOffset)) {
                    $htmlLink .= " data-scrolloffset=\"{$scrollUnderOffset}\"";
                }
            }
            //Hidden under resolution
            $htmlHidden = "";
            $layerHidden = UniteFunctionsBanner::getVal($layer, "hiddenunder");
            if ($layerHidden == "true" || $layerHidden == "1") {
                $htmlHidden = ' data-captionhidden="on"';
            }
            $htmlParams = $htmlEnd . $htmlLink . $htmlVideoAutoplay . $htmlVideoNextSlide . $htmlHidden;
            //Set positioning options
            $alignHor = UniteFunctionsBanner::getVal($layer, "align_hor", "left");
            $alignVert = UniteFunctionsBanner::getVal($layer, "align_vert", "top");
            $htmlPosX = "";
            $htmlPosY = "";
            switch ($alignHor) {
                default:
                case "left":
                    $htmlPosX = "data-x=\"{$left}\" \n";
                    break;
                case "center":
                    $htmlPosX = "data-x=\"center\" data-hoffset=\"{$left}\" \n";
                    break;
                case "right":
                    $left = (int) $left * -1;
                    $htmlPosX = "data-x=\"right\" data-hoffset=\"{$left}\" \n";
                    break;
            }
            switch ($alignVert) {
                default:
                case "top":
                    $htmlPosY = "data-y=\"{$top}\" ";
                    break;
                case "middle":
                    $htmlPosY = "data-y=\"center\" data-voffset=\"{$top}\" ";
                    break;
                case "bottom":
                    $top = (int) $top * -1;
                    $htmlPosY = "data-y=\"bottom\" data-voffset=\"{$top}\" ";
                    break;
            }
            //Set corners
            $htmlCorners = "";
            if ($type == "text") {
                $cornerLeft = UniteFunctionsBanner::getVal($layer, "corner_left");
                $cornerRight = UniteFunctionsBanner::getVal($layer, "corner_right");
                switch ($cornerLeft) {
                    case "curved":
                        $htmlCorners .= "<div class='frontcorner'></div>";
                        break;
                    case "reverced":
                        $htmlCorners .= "<div class='frontcornertop'></div>";
                        break;
                }
                switch ($cornerRight) {
                    case "curved":
                        $htmlCorners .= "<div class='backcorner'></div>";
                        break;
                    case "reverced":
                        $htmlCorners .= "<div class='backcornertop'></div>";
                        break;
                }
                //Add resizeme class
                $resizeme = UniteFunctionsBanner::getVal($layer, "resizeme");
                if ($resizeme == "true" || $resizeme == "1") {
                    $outputClass .= ' fb-resizeme';
                }
            }
            //Make some modifications for the full screen video
            if ($isFullWidthVideo == true) {
                $htmlPosX = "data-x=\"0\"" . "\n";
                $htmlPosY = "data-y=\"0\"" . "\n";
                $outputClass .= " fullscreenvideo";
            }
            ?>
				<div class="<?php 
            echo $outputClass;
            ?>
"
					 <?php 
            echo $htmlPosX;
            ?>
					 <?php 
            echo $htmlPosY;
            ?>
					 data-speed="<?php 
            echo $speed;
            ?>
" 
					 data-start="<?php 
            echo $time;
            ?>
" 
					 data-easing="<?php 
            echo $easing;
            ?>
" <?php 
            echo $htmlParams;
            ?>
 ><?php 
            echo $html;
            ?>
					 <?php 
            echo $htmlCorners;
            ?>
					 </div>
				
				<?php 
        }
    }
 protected function drawCustomInputs($setting)
 {
     $customType = UniteFunctionsBanner::getVal($setting, "custom_type");
     switch ($customType) {
         case "sliderSize":
             $this->drawSliderSize($setting);
             break;
         case "responsitiveSettings":
             $this->drawResponsitiveSettings($setting);
             break;
         default:
             UniteFunctionsBanner::throwError("No handler function for type: {$customType}");
             break;
     }
 }
 public function updateArrSettingByName($name, $setting)
 {
     foreach ($this->arrSettings as $key => $settingExisting) {
         $settingName = UniteFunctionsBanner::getVal($settingExisting, "name");
         if ($settingName == $name) {
             $this->arrSettings[$key] = $setting;
             return false;
         }
     }
     UniteFunctionsBanner::throwError("Setting with name: {$name} don't exists");
 }
 public static function trimArrayItems($arr)
 {
     if (gettype($arr) != "array") {
         UniteFunctionsBanner::throwError("trimArrayItems error: The type must be array");
     }
     foreach ($arr as $key => $item) {
         $arr[$key] = trim($item);
     }
     return $arr;
 }
 public function restoreCaptionsCss()
 {
     if (!file_exists(GlobalsBannerRotator::$filepath_captions_original)) {
         UniteFunctionsBanner::throwError("The original css file: captions_original.css doesn't exists.");
     }
     $success = @copy(GlobalsBannerRotator::$filepath_captions_original, GlobalsBannerRotator::$filepath_captions);
     if ($success == false) {
         UniteFunctionsBanner::throwError("Failed to restore from the original captions file.");
     }
 }
Beispiel #12
0
<?php

$sliderID = self::getGetVar("id");
if (empty($sliderID)) {
    UniteFunctionsBanner::throwError("Slider ID not found");
}
$slider = new BannerRotator();
$slider->initByID($sliderID);
$sliderParams = $slider->getParams();
$arrSliders = $slider->getArrSlidersShort($sliderID);
$selectSliders = UniteFunctionsBanner::getHTMLSelect($arrSliders, "", "id='selectSliders'", true);
$numSliders = count($arrSliders);
//Set iframe parameters
$width = $sliderParams["width"];
$height = $sliderParams["height"];
$iframeWidth = $width + 60;
$iframeHeight = $height + 50;
$iframeStyle = "width:{$iframeWidth}px;height:{$iframeHeight}px;";
//Handle wpml
$isWpmlExists = UniteWpmlBanner::isWpmlExists();
$useWpml = $slider->getParam("useWpml", "false");
$wpmlActive = false;
if ($isWpmlExists && $useWpml == "true") {
    $wpmlActive = true;
    //Get langs floating menu
    $urlIconDelete = self::$url_plugin . "images/icon-trash.png";
    $urlIconEdit = self::$url_plugin . "images/icon-edit.png";
    $urlIconPreview = self::$url_plugin . "images/preview.png";
    $textDelete = __("Delete Slide", BANNERROTATOR_TEXTDOMAIN);
    $textEdit = __("Edit Slide", BANNERROTATOR_TEXTDOMAIN);
    $textPreview = __("Preview Slide", BANNERROTATOR_TEXTDOMAIN);
 private function validateInited()
 {
     if (empty($this->id)) {
         UniteFunctionsBanner::throwError("The slide is not inited!!!");
     }
 }
 private function throwError($message, $code = null)
 {
     UniteFunctionsBanner::throwError($message, $code);
 }
 protected static function updatePlugin($viewBack = false)
 {
     $linkBack = self::getViewUrl($viewBack);
     $htmlLinkBack = UniteFunctionsBanner::getHtmlLink($linkBack, "Go Back");
     $zip = new UniteZipBanner();
     try {
         if (function_exists("unzip_file") == false) {
             if (UniteZipBanner::isZipExists() == false) {
                 UniteFunctionsBanner::throwError("The ZipArchive php extension not exists, can't extract the update file. Please turn it on in php ini.");
             }
         }
         dmp("Update in progress...");
         $arrFiles = UniteFunctionsBanner::getVal($_FILES, "update_file");
         if (empty($arrFiles)) {
             UniteFunctionsBanner::throwError("Update file don't found.");
         }
         $filename = UniteFunctionsBanner::getVal($arrFiles, "name");
         if (empty($filename)) {
             UniteFunctionsBanner::throwError("Update filename not found.");
         }
         $fileType = UniteFunctionsBanner::getVal($arrFiles, "type");
         /*				
         $fileType = strtolower($fileType);
         
         if($fileType != "application/zip")
         	UniteFunctionsBanner::throwError("The file uploaded is not zip.");
         */
         $filepathTemp = UniteFunctionsBanner::getVal($arrFiles, "tmp_name");
         if (file_exists($filepathTemp) == false) {
             UniteFunctionsBanner::throwError("Can't find the uploaded file.");
         }
         //Crate temp folder
         UniteFunctionsBanner::checkCreateDir(self::$path_temp);
         //Create the update folder
         $pathUpdate = self::$path_temp . "update_extract/";
         UniteFunctionsBanner::checkCreateDir($pathUpdate);
         //Remove all files in the update folder
         if (is_dir($pathUpdate)) {
             $arrNotDeleted = UniteFunctionsBanner::deleteDir($pathUpdate, false);
             if (!empty($arrNotDeleted)) {
                 $strNotDeleted = print_r($arrNotDeleted, true);
                 UniteFunctionsBanner::throwError("Could not delete those files from the update folder: {$strNotDeleted}");
             }
         }
         //Copy the zip file
         $filepathZip = $pathUpdate . $filename;
         $success = move_uploaded_file($filepathTemp, $filepathZip);
         if ($success == false) {
             UniteFunctionsBanner::throwError("Can't move the uploaded file here: {$filepathZip}.");
         }
         if (function_exists("unzip_file") == true) {
             WP_Filesystem();
             $response = unzip_file($filepathZip, $pathUpdate);
         } else {
             $zip->extract($filepathZip, $pathUpdate);
         }
         //Get extracted folder
         $arrFolders = UniteFunctionsBanner::getFoldersList($pathUpdate);
         if (empty($arrFolders)) {
             UniteFunctionsBanner::throwError("The update folder is not extracted");
         }
         if (count($arrFolders) > 1) {
             UniteFunctionsBanner::throwError("Extracted folders are more then 1. Please check the update file.");
         }
         //Get product folder
         $productFolder = $arrFolders[0];
         if (empty($productFolder)) {
             UniteFunctionsBanner::throwError("Wrong product folder.");
         }
         if ($productFolder != self::$dir_plugin) {
             UniteFunctionsBanner::throwError("The update folder don't match the product folder, please check the update file.");
         }
         $pathUpdateProduct = $pathUpdate . $productFolder . "/";
         //Check some file in folder to validate it's the real one:
         $checkFilepath = $pathUpdateProduct . $productFolder . ".php";
         if (file_exists($checkFilepath) == false) {
             UniteFunctionsBanner::throwError("Wrong update extracted folder. The file: {$checkFilepath} not found.");
         }
         //Copy the plugin without the captions file
         $pathOriginalPlugin = self::$path_plugin;
         $arrBlackList = array();
         $arrBlackList[] = "css/caption.css";
         UniteFunctionsBanner::copyDir($pathUpdateProduct, $pathOriginalPlugin, "", $arrBlackList);
         //Delete the update
         UniteFunctionsBanner::deleteDir($pathUpdate);
         dmp("Updated Successfully, redirecting...");
         echo "<script>location.href='{$linkBack}'</script>";
     } catch (Exception $e) {
         $message = $e->getMessage();
         $message .= " <br> Please update the plugin manually via the ftp";
         echo "<div style='color:#B80A0A;font-size:18px;'><b>Update Error: </b> {$message}</div><br>";
         echo $htmlLinkBack;
         exit;
     }
 }
 public function copyMoveSlideFromData($data)
 {
     $sliderID = UniteFunctionsBanner::getVal($data, "sliderID");
     UniteFunctionsBanner::validateNotEmpty($sliderID, "Slider ID");
     $this->initByID($sliderID);
     $targetSliderID = UniteFunctionsBanner::getVal($data, "targetSliderID");
     UniteFunctionsBanner::validateNotEmpty($sliderID, "Target Slider ID");
     $this->initByID($sliderID);
     if ($targetSliderID == $sliderID) {
         UniteFunctionsBanner::throwError("The target slider can't be equal to the source slider");
     }
     $slideID = UniteFunctionsBanner::getVal($data, "slideID");
     UniteFunctionsBanner::validateNotEmpty($slideID, "Slide ID");
     $operation = UniteFunctionsBanner::getVal($data, "operation");
     $this->copyMoveSlide($slideID, $targetSliderID, $operation);
     return $sliderID;
 }
Beispiel #17
0
 private static function validateWpmlExists()
 {
     if (!self::isWpmlExists()) {
         UniteFunctionsBanner::throwError("The wpml plugin doesn't exist");
     }
 }