/**
  * 
  * get field from db
  */
 public function getFieldFromDB($name)
 {
     $arr = $this->db->fetch(GlobalsShowBiz::$table_settings);
     //dmp("maxim");exit();
     if (empty($arr)) {
         return "";
     }
     $arr = $arr[0];
     if (array_key_exists($name, $arr) == false && $name !== 'general') {
         UniteFunctionsBiz::throwError("The settings db should cotnain field: {$name}");
     }
     $value = @$arr[$name];
     return $value;
 }
 /**
  * 
  * delete post
  */
 public static function deletePost($postID)
 {
     $success = wp_delete_post($postID, true);
     if ($success == false) {
         UniteFunctionsBiz::throwError("Could not delete post: {$postID}");
     }
 }
 public function checkPurchaseVerification($data)
 {
     global $wp_version;
     $response = wp_remote_post('http://updates.themepunch.com/activate.php', array('user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'), 'body' => array('name' => urlencode($data['username']), 'api' => urlencode($data['api_key']), 'code' => urlencode($data['code']), 'product' => urlencode('showbiz'))));
     $response_code = wp_remote_retrieve_response_code($response);
     $version_info = wp_remote_retrieve_body($response);
     if ($response_code != 200 || is_wp_error($version_info)) {
         return false;
     }
     if ($version_info == 'valid') {
         update_option('showbiz-valid', 'true');
         update_option('showbiz-api-key', $data['api_key']);
         update_option('showbiz-username', $data['username']);
         update_option('showbiz-code', $data['code']);
         return true;
     } elseif ($version_info == 'exist') {
         UniteFunctionsBiz::throwError(__('Purchase Code already registered!'));
     } else {
         return false;
     }
 }
示例#4
0
 /**
  * 
  * do "trim" operation on all array items.
  */
 public static function trimArrayItems($arr)
 {
     if (gettype($arr) != "array") {
         UniteFunctionsBiz::throwError("trimArrayItems error: The type must be array");
     }
     foreach ($arr as $key => $item) {
         $arr[$key] = trim($item);
     }
     return $arr;
 }
示例#5
0
<?php

$sliderID = self::getGetVar("id");
if (empty($sliderID)) {
    UniteFunctionsBiz::throwError("Slider ID not found");
}
$slider = new ShowBizSlider();
$slider->initByID($sliderID);
$sliderParams = $slider->getParams();
$arrSlides = $slider->getSlides();
$numSlides = count($arrSlides);
$linksSliderSettings = self::getViewUrl(ShowBizAdmin::VIEW_SLIDER, "id={$sliderID}");
$templateName = "slides_gallery";
//set posts params
if ($slider->isSourceFromPosts()) {
    $templateName = "slides_posts";
    $params = $slider->getParams();
    $postCatID = $slider->getPostCategory();
    $isMultiple = strpos($postCatID, ",") !== false;
    //get category name
    $isMultiple = true;
    /*
    if($isMultiple == false){
    	$catData = UniteFunctionsWPBiz::getCategoryData($postCatID);
    	if(empty($catData))
    		UniteFunctionsBiz::throwError("Category with id: $postCatID not found");
    	
    	$catName = $catData["cat_name"];
    	
    	$urlCatPosts = UniteFunctionsWPBiz::getUrlSlidesEditByCatID($postCatID);		
    	$linkCatPosts = UniteFunctionsBiz::getHtmlLink($urlCatPosts, $catName,"","",true);
 /**
  * 
  * get cats and taxanomies data from the input
  */
 private function getCatAndTaxData($catIDs)
 {
     if (is_string($catIDs)) {
         $catIDs = trim($catIDs);
         if (empty($catIDs)) {
             return array("tax" => "", "cats" => "");
         }
         $catIDs = explode(",", $catIDs);
     }
     $strCats = "";
     $arrTax = array();
     foreach ($catIDs as $cat) {
         if (strpos($cat, "option_disabled") === 0) {
             continue;
         }
         $pos = strrpos($cat, "_");
         if ($pos === false) {
             UniteFunctionsBiz::throwError("The category is in wrong format");
         }
         $taxName = substr($cat, 0, $pos);
         $catID = substr($cat, $pos + 1, strlen($cat) - $pos - 1);
         //translate catID to current language if wpml exists
         $catID = UniteWpmlBiz::changeCatIdByLang($catID, $taxName);
         $arrTax[$taxName] = $taxName;
         if (!empty($strCats)) {
             $strCats .= ",";
         }
         $strCats .= $catID;
     }
     $strTax = "";
     foreach ($arrTax as $taxName) {
         if (!empty($strTax)) {
             $strTax .= ",";
         }
         $strTax .= $taxName;
     }
     $output = array("tax" => $strTax, "cats" => $strCats);
     return $output;
 }
示例#7
0
 /**
  * 
  * valdiate that wpml exists
  */
 private static function validateWpmlExists()
 {
     if (!self::isWpmlExists()) {
         UniteFunctionsBiz::throwError("The wpml plugin don't exists");
     }
 }
    /**
     * 
     * put the slider slides
     */
    private function putSlides()
    {
        $slides = $this->slider->getSlides(true);
        if (empty($slides)) {
            UniteFunctionsBiz::throwError("No Slides Found, Please add some slides");
        }
        $templateHtml = $this->template->getContent();
        //$templateHtml = $this->getDemoTemplate();
        $this->slidesNumIndex = $this->slider->getSlidesNumbersByIDs(true);
        $hide_if_empty_img = $this->slider->getParam('hide_if_no_image', 'off');
        $image_source_type = $this->slider->getParam('img_source_type', 'full');
        $image_ratio = $this->slider->getParam('img_ratio', 'none');
        if (empty($slides)) {
            ?>
					<div class="no-slides-text">
						No items found, please add some items
					</div>
					<?php 
        }
        echo "<ul>";
        foreach ($slides as $slide) {
            $params = $slide->getParams();
            $text = $slide->getParam("slide_text", "");
            $title = $slide->getParam("title", "");
            $urlImage = $slide->getImageUrl();
            $urlImage = trim($urlImage);
            if (empty($urlImage) && $hide_if_empty_img == 'on') {
                continue;
            }
            $link = $slide->getParam("link", "");
            //get the html from the local or global template
            $templateID = $slide->getParam("template_id", "0");
            if (!empty($templateID) && $templateID != "0" && $templateID != 0) {
                $template = new ShowBizTemplate();
                $template->initById($templateID);
                $html = $template->getContent();
            } else {
                $html = $templateHtml;
            }
            $html = UniteFunctionsBiz::add_height_auto($html);
            $html = $slide->processTemplateHtml($html);
            //add height/width attribute
            $html = UniteFunctionsBiz::add_height_width($html, $image_source_type, $image_ratio);
            $customStyles = '';
            if ($this->slider->getParam("custom_offset_control", "false") == "true") {
                $customOffset = $this->slider->getParam("custom_offset", "0");
                $customStyles = ' style="margin-right: ' . $customOffset . 'px;"';
            }
            ?>
					<li<?php 
            echo $customStyles;
            ?>
>
						<?php 
            echo $html;
            ?>
					</li>
					
				<?php 
        }
        echo "</ul>";
    }
示例#9
0
 /**
  * 
  * onAjax action handler
  */
 public static function onAjaxAction()
 {
     $slider = new ShowBizSlider();
     $slide = new BizSlide();
     $templates = new ShowBizTemplate();
     $operations = new BizOperations();
     $wildcards = new ShowBizWildcards();
     $action = self::getPostGetVar("client_action");
     $data = self::getPostGetVar("data");
     $nonce = self::getPostGetVar("nonce");
     try {
         //verify the nonce
         $isVerified = wp_verify_nonce($nonce, "showbiz_actions");
         if ($isVerified == false) {
             UniteFunctionsBiz::throwError("Wrong request");
         }
         switch ($action) {
             case "update_general_settings":
                 $operations->updateGeneralSettings($data);
                 self::ajaxResponseSuccess(__("General settings updated", SHOWBIZ_TEXTDOMAIN));
                 break;
             case "export_slider":
                 $sliderID = self::getGetVar("sliderid");
                 $slider->initByID($sliderID);
                 $slider->exportSlider();
                 break;
             case "import_slider":
                 self::importSliderHandle();
                 break;
             case "create_slider":
                 $newSliderID = $slider->createSliderFromOptions($data);
                 self::ajaxResponseSuccessRedirect("The slider successfully created", self::getViewUrl("sliders"));
                 break;
             case "update_slider":
                 $slider->updateSliderFromOptions($data);
                 self::ajaxResponseSuccess("Slider updated");
                 break;
             case "delete_slider":
                 $slider->deleteSliderFromData($data);
                 self::ajaxResponseSuccessRedirect("The slider deleted", self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "duplicate_slider":
                 $slider->duplicateSliderFromData($data);
                 self::ajaxResponseSuccessRedirect("The duplicate successfully, refreshing page...", self::getViewUrl(self::VIEW_SLIDERS));
                 break;
             case "add_slide":
                 $slider->createSlideFromData($data);
                 $sliderID = $data["sliderid"];
                 self::ajaxResponseSuccessRedirect("Slide Created, refreshing...", self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "update_slide":
                 $slide->updateSlideFromData($data);
                 self::ajaxResponseSuccess("Slide updated");
                 break;
             case "delete_slide":
                 $slide->deleteSlideFromData($data);
                 $sliderID = UniteFunctionsBiz::getVal($data, "sliderID");
                 self::ajaxResponseSuccessRedirect("Slide Deleted Successfully", self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "duplicate_slide":
                 $sliderID = $slider->duplicateSlideFromData($data);
                 self::ajaxResponseSuccessRedirect("Slide Duplicated Successfully", self::getViewUrl(self::VIEW_SLIDES, "id={$sliderID}"));
                 break;
             case "update_slides_order":
                 $slider->updateSlidesOrderFromData($data);
                 self::ajaxResponseSuccess("Order updated successfully");
                 break;
             case "preview_slide":
                 $operations->putSlidePreviewByData($data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsBiz::getPostVariable("sliderid");
                 $operations->previewOutput($sliderID);
                 break;
             case "preview_template":
                 $templateID = UniteFunctionsBiz::getPostGetVariable("templateid");
                 $operations->previewTemplateOutput($templateID);
                 break;
             case "toggle_slide_state":
                 $currentState = $slide->toggleSlideStatFromData($data);
                 self::ajaxResponseData(array("state" => $currentState));
                 break;
             case "update_plugin":
                 self::updateShowbizPlugin();
                 break;
             case "create_template":
                 $templates->addFromData($data);
                 self::ajaxResponseSuccess("Template Added Successfully");
                 break;
             case "delete_template":
                 $templates->deleteFromData($data);
                 self::ajaxResponseSuccess("Template Deleted Successfully");
                 break;
             case "duplicate_template":
                 $templates->duplicateFromData($data);
                 self::ajaxResponseSuccess("Template Duplicated Successfully");
                 break;
             case "get_template_content":
                 $content = $templates->getContentFromData($data);
                 $arrData = array("content" => $content);
                 self::ajaxResponseData($arrData);
                 break;
             case "get_template_css":
                 $css = $templates->getCssFromData($data);
                 $arrData = array("css" => $css);
                 self::ajaxResponseData($arrData);
                 break;
             case "update_template_content":
                 $templates->updateContentFromData($data);
                 self::ajaxResponseSuccess("Content Updated Successfully");
                 break;
             case "update_template_title":
                 $templates->updateTitleFromData($data);
                 self::ajaxResponseSuccess("Title Updated Successfully");
                 break;
             case "update_template_css":
                 $templates->updateCssFromData($data);
                 self::ajaxResponseSuccess("Css Updated Successfully");
                 break;
             case "restore_original_template":
                 $templates->restoreOriginalFromData($data);
                 self::ajaxResponseSuccess("Template Restored");
                 break;
             case "update_posts_sortby":
                 $slider->updatePostsSortbyFromData($data);
                 self::ajaxResponseSuccess("Sortby updated");
                 break;
             case "change_slide_image":
                 $slide->updateSlideImageFromData($data);
                 self::ajaxResponseSuccess("Image Changed");
                 break;
             case "add_wildcard":
                 $response = $wildcards->addFromData($data);
                 self::ajaxResponseSuccess("Added successfully", $response);
                 break;
             case "remove_wildcard":
                 $response = $wildcards->removeFromData($data);
                 self::ajaxResponseSuccess("Removed successfully", $response);
                 break;
             case "activate_purchase_code":
                 $result = false;
                 if (!empty($data['username']) && !empty($data['api_key']) && !empty($data['code'])) {
                     $result = $operations->checkPurchaseVerification($data);
                 } else {
                     UniteFunctionsBiz::throwError(__('The API key, the Purchase Code and the Username need to be set!'));
                     exit;
                 }
                 if ($result) {
                     self::ajaxResponseSuccessRedirect(__("Purchase Code Successfully Activated"), self::getViewUrl(self::VIEW_SLIDERS));
                 } else {
                     UniteFunctionsBiz::throwError(__('Purchase Code is invalid'));
                 }
                 break;
             case "deactivate_purchase_code":
                 $result = $operations->doPurchaseDeactivation($data);
                 if ($result) {
                     self::ajaxResponseSuccessRedirect(__("Successfully removed validation"), self::getViewUrl(self::VIEW_SLIDERS));
                 } else {
                     UniteFunctionsBiz::throwError(__('Could not remove Validation!'));
                 }
                 break;
             case "dismiss_notice":
                 update_option('showbiz-valid-notice', 'false');
                 self::ajaxResponseSuccess(__("."));
                 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;
 }
 /**
  * 
  * validate that the slide is inited and the id exists.
  */
 private function validateInited()
 {
     if (empty($this->id)) {
         UniteFunctionsBiz::throwError("The slide is not inited!!!");
     }
 }
    /**
     * 
     * draw settings function
     * @param $drawForm draw the form yes / no
     */
    public function draw($formID = null, $drawForm = false)
    {
        if (empty($formID)) {
            UniteFunctionsBiz::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 
    }
示例#12
0
 /**
  * 
  * Enter description here ...
  */
 protected static function updatePlugin($viewBack = null, $isRedirect = true)
 {
     $linkBack = self::getViewUrl($viewBack);
     $htmlLinkBack = UniteFunctionsBiz::getHtmlLink($linkBack, "Go Back");
     $zip = new UniteZipBiz();
     try {
         if (function_exists("unzip_file") == false) {
             if (UniteZipBiz::isZipExists() == false) {
                 UniteFunctionsBiz::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 = UniteFunctionsBiz::getVal($_FILES, "update_file");
         if (empty($arrFiles)) {
             UniteFunctionsBiz::throwError("Update file don't found.");
         }
         $filename = UniteFunctionsBiz::getVal($arrFiles, "name");
         if (empty($filename)) {
             UniteFunctionsBiz::throwError("Update filename not found.");
         }
         $fileType = UniteFunctionsBiz::getVal($arrFiles, "type");
         /*				
         $fileType = strtolower($fileType);
         
         if($fileType != "application/zip")
         	UniteFunctionsBiz::throwError("The file uploaded is not zip.");
         */
         $filepathTemp = UniteFunctionsBiz::getVal($arrFiles, "tmp_name");
         if (file_exists($filepathTemp) == false) {
             UniteFunctionsBiz::throwError("Can't find the uploaded file.");
         }
         //crate temp folder
         UniteFunctionsBiz::checkCreateDir(self::$path_temp);
         //create the update folder
         $pathUpdate = self::$path_temp . "update_extract/";
         UniteFunctionsBiz::checkCreateDir($pathUpdate);
         //remove all files in the update folder
         if (is_dir($pathUpdate)) {
             $arrNotDeleted = UniteFunctionsBiz::deleteDir($pathUpdate, false);
             if (!empty($arrNotDeleted)) {
                 $strNotDeleted = print_r($arrNotDeleted, true);
                 UniteFunctionsBiz::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) {
             UniteFunctionsBiz::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 = UniteFunctionsBiz::getFoldersList($pathUpdate);
         if (empty($arrFolders)) {
             UniteFunctionsBiz::throwError("The update folder is not extracted");
         }
         if (count($arrFolders) > 1) {
             UniteFunctionsBiz::throwError("Extracted folders are more then 1. Please check the update file.");
         }
         //get product folder
         $productFolder = $arrFolders[0];
         if (empty($productFolder)) {
             UniteFunctionsBiz::throwError("Wrong product folder.");
         }
         if ($productFolder != self::$dir_plugin) {
             UniteFunctionsBiz::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) {
             UniteFunctionsBiz::throwError("Wrong update extracted folder. The file: {$checkFilepath} not found.");
         }
         //copy the plugin without the captions file.
         //$pathOriginalPlugin = $pathUpdate."copy/";
         $pathOriginalPlugin = self::$path_plugin;
         $arrBlackList = array();
         //$arrBlackList[] = "showbiz-plugin/css/captions.css";
         UniteFunctionsBiz::copyDir($pathUpdateProduct, $pathOriginalPlugin, "", $arrBlackList);
         //delete the update
         UniteFunctionsBiz::deleteDir($pathUpdate);
         if ($isRedirect == true) {
             dmp("Updated Successfully, redirecting...");
             echo "<script>location.href='{$linkBack}'</script>";
         }
         return true;
     } 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;
     }
 }
示例#13
0
 /**
  * 
  * throw error
  */
 private function throwError($message, $code = null)
 {
     UniteFunctionsBiz::throwError($message, $code);
 }
 /**
  * 
  * draw custom inputs for rev slider
  * @param $setting
  */
 protected function drawCustomInputs($setting)
 {
     $customType = UniteFunctionsBiz::getVal($setting, "custom_type");
     switch ($customType) {
         case "slider_size":
             $this->drawSliderSize($setting);
             break;
         default:
             UniteFunctionsBiz::throwError("No handler function for type: {$customType}");
             break;
     }
 }
示例#15
0
 /**
  * 
  * insert variables to some table
  */
 public function update($table, $arrItems, $where)
 {
     global $wpdb;
     $response = $wpdb->update($table, $arrItems, $where);
     if ($response === false) {
         UniteFunctionsBiz::throwError("no update action taken!");
     }
     $this->checkForErrors("Update query error");
     return $wpdb->num_rows;
 }
示例#16
0
 /**
  * 
  * update setting array by name
  */
 public function updateArrSettingByName($name, $setting)
 {
     foreach ($this->arrSettings as $key => $settingExisting) {
         $settingName = UniteFunctionsBiz::getVal($settingExisting, "name");
         if ($settingName == $name) {
             $this->arrSettings[$key] = $setting;
             return false;
         }
     }
     UniteFunctionsBiz::throwError("Setting with name: {$name} don't exists");
 }