/**
  * 
  * get filepath of settings file by name
  */
 public static function getFilepathSettings($settingsName)
 {
     self::validateInited();
     $filepathSettings = GlobalsUGGallery::$pathSettings . $settingsName . ".php";
     UniteFunctionsUG::validateFilepath($filepathSettings, "Settings file not found");
     return $filepathSettings;
 }
<?php

defined('_JEXEC') or die('Restricted access');
/**
 * gets $action, $data , and working framework, so globals and helper works
 * response from helperUG
 */
switch ($action) {
    case "get_skin_css":
        $skin = UniteFunctionsUG::getVal($data, "skin");
        $filepath = GlobalsUG::$path_media_ug . "themes/video/skin-{$skin}.css";
        $filepath_modified = GlobalsUG::$path_media_ug . "themes/video/skin-{$skin}-modified.css";
        UniteFunctionsUG::validateFilepath($filepath);
        //if exists modified version - get the modified
        if (file_exists($filepath_modified)) {
            $filepath = $filepath_modified;
        }
        $content = file_get_contents($filepath);
        $data = array();
        $data["content"] = $content;
        $relativePath = HelperUG::pathToRelative($filepath);
        $data["filepath"] = $relativePath;
        HelperUG::ajaxResponseData($data);
        break;
    case "update_skin_css":
        $skin = UniteFunctionsUG::getVal($data, "skin");
        $filepath_modified = GlobalsUG::$path_media_ug . "themes/video/skin-{$skin}-modified.css";
        $content = UniteFunctionsUG::getVal($data, "css");
        UniteFunctionsUG::writeFile($content, $filepath_modified);
        HelperUG::ajaxResponseSuccess("Content Updated");
        break;
 /**
  * 
  * inlcude some view file
  */
 protected static function requireView($view)
 {
     try {
         //require master view file, and
         if (!empty(self::$master_view) && !isset(self::$tempVars["is_masterView"])) {
             $masterViewFilepath = GlobalsUG::$pathViews . self::$master_view . ".php";
             UniteFunctionsUG::validateFilepath($masterViewFilepath, "Master View");
             self::$tempVars["is_masterView"] = true;
             require $masterViewFilepath;
         } else {
             //simple require the view file.
             $viewFilepath = GlobalsUG::$pathViews . $view . ".php";
             UniteFunctionsUG::validateFilepath($viewFilepath, "View");
             require $viewFilepath;
         }
     } catch (Exception $e) {
         echo "<br><br>View ({$view}) Error: <b>" . $e->getMessage() . "</b>";
         if (GlobalsUG::SHOW_TRACE == true) {
             dmp($e->getTraceAsString());
         }
     }
 }
 /**
  * make thumbnail from the image, and save to some path
  * return new path
  */
 public function makeThumb($filepathImage, $pathThumbs, $maxWidth = -1, $maxHeight = -1, $type = "")
 {
     //validate input
     UniteFunctionsUG::validateFilepath($filepathImage, "image not found");
     UniteFunctionsUG::validateDir($pathThumbs, "Thumbs folder don't exists.");
     if ($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP) {
         if ($maxHeight == -1) {
             $this->throwError("image with exact type must have height!");
         }
         if ($maxWidth == -1) {
             $this->throwError("image with exact type must have width!");
         }
     }
     //get filename
     $info = UniteFunctionsUG::getPathInfo($filepathImage);
     $filename = UniteFunctionsUG::getVal($info, "basename");
     UniteFunctionsUG::validateNotEmpty($filename, "image filename not given");
     //if gd library doesn't exists - output normal image without resizing.
     if (function_exists("gd_info") == false) {
         $this->throwError("php must support GD Library");
     }
     if ($maxWidth == -1 && $maxHeight == -1) {
         $this->throwError("Wrong thumb size");
     }
     if ($maxWidth == -1) {
         $maxWidth = 1000000;
     }
     if ($maxHeight == -1) {
         $maxHeight = 100000;
     }
     $this->filename = $filename;
     $this->maxWidth = $maxWidth;
     $this->maxHeight = $maxHeight;
     $this->type = $type;
     $this->pathCache = $pathThumbs;
     $filenameThumb = $this->getThumbFilename();
     $filepathNew = $this->pathCache . $filenameThumb;
     if (file_exists($filepathNew)) {
         return $filenameThumb;
     }
     if ($type == self::TYPE_EXACT || $type == self::TYPE_EXACT_TOP) {
         $isSaved = $this->cropImageSaveNew($filepathImage, $filepathNew);
     } else {
         $isSaved = $this->resizeImageSaveNew($filepathImage, $filepathNew);
     }
     if ($isSaved) {
         return $filenameThumb;
     } else {
         return "";
     }
 }
 /**
  * output some gallery by alias
  * mixed - alias or id
  * outputType - can be alias or ID
  * arrItems - alternative items
  */
 public static function outputGallery($mixed, $catID = null, $outputType = "alias", $arrItems = null)
 {
     try {
         if ($mixed instanceof UniteGalleryGallery) {
             $objGallery = $mixed;
         } else {
             //init the gallery enviropment
             $objGallery = new UniteGalleryGallery();
             if ($outputType == "alias") {
                 $objGallery->initByAlias($mixed);
             } else {
                 $objGallery->initByID($mixed);
             }
         }
         $galleryID = $objGallery->getID();
         $objType = $objGallery->getObjType();
         GlobalsUGGallery::init($objType, $objGallery, $galleryID);
         $filepathOutput = GlobalsUGGallery::$pathBase . "client_output.php";
         UniteFunctionsUG::validateFilepath($filepathOutput);
         //require the gallery includes
         $filepathIncludes = GlobalsUGGallery::$pathBase . "includes.php";
         if (file_exists($filepathIncludes)) {
             require_once $filepathIncludes;
         }
         $arrOptions = array();
         $arrOptions["categoryid"] = "";
         if ($catID && is_numeric($catID) && $catID > 0) {
             $arrOptions["categoryid"] = $catID;
         }
         if ($arrItems !== null) {
             $arrOptions["items"] = $arrItems;
         }
         //run the output
         require $filepathOutput;
         if (!isset($uniteGalleryOutput)) {
             UniteFunctionsUG::throwError("uniteGalleryOutput variable not found");
         }
         return $uniteGalleryOutput;
     } catch (Exception $e) {
         $message = "<b>Unite Gallery Error:</b><br><br> " . $e->getMessage();
         $operations = new UGOperations();
         $operations->putModuleErrorMessage($message);
     }
 }
 /**
  * call gallery action, include gallery framework first
  */
 public static function onGalleryAjaxAction($typeName, $action, $data, $galleryID)
 {
     if (empty($data)) {
         $data = array();
     }
     self::initGalleryFramework($typeName, $galleryID);
     $filepathAjax = GlobalsUGGallery::$pathBase . "ajax_actions.php";
     UniteFunctionsUG::validateFilepath($filepathAjax, "Ajax request error: ");
     require $filepathAjax;
     UniteFunctionsUG::throwError("No ajax response from gallery: <b>{$typeName} </b> to action <b>{$action}</b>");
 }