Example #1
0
 /**
  * Gets the full table name according to the table label and prefix
  * (everything according to the .xml config file)
  *
  * @param string $table name of DB table
  * @return string the table full name
  */
 static function getNameOfTable($table)
 {
     return CL::getConf('CLE_Ibdi/prefix') . $table;
 }
Example #2
0
 /**
  * This function resizes given image, if it has bigger dimensions, than we need and saves it (also makes chmod 0777 on the file) ...
  * It uses GD or ImageMagick, setting is available to change in CL's config file.
  *
  * @param string $inputFileName the input file to work with
  * @param string $outputFileName the file to write into the final (resized) image
  * @param integer $maxNewWidth maximal width of image
  * @param integer $maxNewHeight maximal height of image
  * @return bool TRUE, if everything was successful (resize and chmod), else FALSE
  */
 function resize($inputFileName, $outputFileName, $maxNewWidth, $maxNewHeight)
 {
     $imageInfo = getimagesize($inputFileName);
     $fileType = $imageInfo['mime'];
     $extension = strtolower(str_replace('.', '', substr($outputFileName, -4)));
     $originalWidth = $imageInfo[0];
     $originalHeight = $imageInfo[1];
     if ($originalWidth > $maxNewWidth or $originalHeight > $maxNewHeight) {
         $newWidth = $maxNewWidth;
         $newHeight = $originalHeight / ($originalWidth / $maxNewWidth);
         if ($newHeight > $maxNewHeight) {
             $newHeight = $maxNewHeight;
             $newWidth = $originalWidth / ($originalHeight / $maxNewHeight);
         }
         $newWidth = ceil($newWidth);
         $newHeight = ceil($newHeight);
     } else {
         $newWidth = $originalWidth;
         $newHeight = $originalHeight;
     }
     $ok = FALSE;
     if (CL::getConf('CL_Images/engine') == 'imagick-cli') {
         exec("convert -thumbnail " . $newWidth . "x" . $newHeight . " " . $inputFileName . " " . $outputFileName);
         $ok = TRUE;
     } elseif (CL::getConf('CL_Images/engine') == 'imagick-php') {
         $image = new Imagick($inputFileName);
         $image->thumbnailImage($newWidth, $newHeight);
         $ok = (bool) $image->writeImage($outputFileName);
         $image->clear();
         $image->destroy();
     } else {
         $out = imageCreateTrueColor($newWidth, $newHeight);
         switch (strtolower($fileType)) {
             case 'image/jpeg':
                 $source = imageCreateFromJpeg($inputFileName);
                 break;
             case 'image/png':
                 $source = imageCreateFromPng($inputFileName);
                 break;
             case 'image/gif':
                 $source = imageCreateFromGif($inputFileName);
                 break;
             default:
                 break;
         }
         imageCopyResized($out, $source, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
         switch (strtolower($extension)) {
             case 'jpg':
             case 'jpeg':
                 if (imageJpeg($out, $outputFileName)) {
                     $ok = TRUE;
                 }
                 break;
             case 'png':
                 if (imagePng($out, $outputFileName)) {
                     $ok = TRUE;
                 }
                 break;
             case 'gif':
                 if (imageGif($out, $outputFileName)) {
                     $ok = TRUE;
                 }
                 break;
             default:
                 break;
         }
         imageDestroy($out);
         imageDestroy($source);
     }
     if ($ok and chmod($outputFileName, 0777)) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Example #3
0
 /**
  * Obtain filename from configuration file, if there is any match with parameters in given URL
  *
  * @return string|bool filename or FALSE
  */
 function lookUpInXMLFile()
 {
     if (!$this->fileHandler) {
         $this->fileHandler = simplexml_load_file(CL::getConf('CL_SEO/fileName'));
     }
     return $this->checkSection($this->fileHandler, 0);
 }
Example #4
0
<?php

/**
 * @package CLE-Modules
 * @subpackage simpleStatic
 * @author Rene Kliment <*****@*****.**>
 * @version 1.1
 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License - Version 3, 19 November 2007
 *
 * This software is dual-licensed - it is also available under a commercial license,
 * so there's possibility to use this software or its parts in software which is not license-compatible.
 * For more information about licensing, contact the author.
 */
if (isset($_stringId) and $_stringId) {
    $dir = 'data/simpleStatic/';
    $urlArray = CL_SEO::getInstance()->URLArray;
    $h = dir($dir);
    while (false !== ($file = $h->read())) {
        if ($_stringId . '.html' == $file) {
            $navString = CL::getConf('simpleStatic/' . $_stringId) ? CL::getConf('simpleStatic/' . $_stringId) : $_stringId;
            $_CL->setNavigation($navString);
            $_CL_Templates->set(array('' => file_get_contents($dir . $_stringId . '.html'), 'simpleStatic-title' => $navString));
        }
    }
}
Example #5
0
/* Including of the CLE engine */
require_once './sys/CLE/class.cle.ibdi.php';
require_once './sys/CLE/class.cle.modules.php';
require_once './sys/CLE/class.cle.basemodule.php';
require_once './sys/CLE/class.cle.json.php';
/* CL base object */
$_CL = CL::getInstance();
/* Some object and arrays related to (auto)loading of modules */
$_autoloadArray = array();
$_setVarsArray = array();
$_addVarsArray = array();
/* Array of modules, that support SOAP | JSON */
$_jsonEnabledModules = array();
if (CL::getConf('CLE_Ibdi/enabled') == 1) {
    require_once './sys/external/dibi.min.php';
    if (!CLE_Ibdi::getInstance()->connect() and CL::getConf('CLE_Ibdi/terminateScriptOnError') == 1) {
        exit('
            CLE error message: Database connection failed, script execution terminated.
            <br /><br />
            Please check your database connection settings in conf/config.xml<br />
                (if you do not wish to automatically start DB connection, you can as well deactivate it).
            <br /><br />
            If you do not wish CLE to terminate script execution on DB connection error,<br />
                you can set that in configuration file as well.
            <br /><br />
        ');
    }
}
/* Autoload of classes */
function __autoload($class)
{
Example #6
0
<?php

/**
 * @package CLE
 * @subpackage SysFiles
 * @author Rene Kliment <*****@*****.**>
 * @version 1.1
 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License - Version 3, 19 November 2007
 *
 * This software is dual-licensed - it is also available under a commercial license,
 * so there's possibility to use this software or its parts in software which is not license-compatible.
 * For more information about licensing, contact the author.
 */
$_CL_Xety = $GLOBALS['_CL_Xety'] = CL_Xety::getInstance();
$_CL = $GLOBALS['_CL'];
/* And set default language (if not set other) */
if (!isset($_SESSION['language']) or empty($_SESSION['language'])) {
    $_SESSION['language'] = (string) CL::getConf('main/default_language');
}
if (isset($_SESSION['_sessionSetMessageBuffer']) and $_SESSION['_sessionSetMessageBuffer']) {
    $_CL->setMessage($_SESSION['_sessionSetMessageBuffer']);
    unset($_SESSION['_sessionSetMessageBuffer']);
}
if (isset($GLOBALS['_setMessageBuffer']) and $GLOBALS['_setMessageBuffer']) {
    $_CL->setMessage(constant($GLOBALS['_setMessageBuffer']));
}
/* Let's load default layout */
CL_Templates::setDirectory(CL::getConf('CL_Templates/dir_default'));
if (@(!defined(CLE_DONT_LOAD_LAYOUT))) {
    $_CL_Templates = $GLOBALS['_CL_Templates'] = CL_Templates::getInstance();
}
Example #7
0
        $_CL_Templates->add($v1);
    }
}
/* Are there any other variables to set? (for example from init stage of modules) */
if (count($_setVarsArray)) {
    $_CL_Templates->set($_setVarsArray);
}
/* Set some info to head tag, verification tokens, navigation, ... */
$_CL_Templates->set(array('footer' => CL::getConf('main/footer'), 'header-language' => CL::getConf('main/default_language'), 'header-title' => CL::getConf('main/website_name'), 'header-description' => CL::getConf('main/website_description'), 'header-keywords' => CL::getConf('main/website_keywords'), 'header-author' => CL::getConf('main/website_webmaster'), 'header-add' => '', '_id' => $_id, 'address_ssl' => CL::getConf('main/address_ssl'), 'nonRootPrefix' => CL::getConf('main/nonRootPrefix'), 'token' => $_SESSION['token'], 'token-name' => $_SESSION['token_name'], 'currentYear' => date('Y'), 'header-navigation' => strip_tags($_CL->getNavigation()), 'message' => $_CL->getMessage() ? str_replace('${message}', $_CL_Xety->basic($_CL->getMessage()), $_CL_Templates->getTpl('##base.tpl', 'MESSAGE')) : '', 'layout-directory' => $_CL_Templates->getDirectory(), 'layout-directory-fullpath' => CL::getConf('CL_Templates/dir') . $_CL_Templates->getDirectory(), 'layout-css' => CL::getConf('main/nonRootPrefix') . CL::getConf('CL_Templates/dir') . $_CL_Templates->getDirectory() . '/default.css'));
/* Any cookie variables to fill into layout vars? */
if (isset($_autoFillInCookieVars)) {
    $tempArray = array();
    foreach ($_autoFillInCookieVars as $var) {
        if (isset($_POST[$var]) and $_POST[$var]) {
            $_COOKIE[$var] = $_POST[$var];
            setcookie($var, $_POST[$var], time() + 3600 * 24 * 365, CL::getConf('main/nonRootPrefix'));
        }
        $tempArray['_autoFillInCookieVars-' . $var] = isset($_COOKIE[$var]) ? $_CL_Xety->plain($_COOKIE[$var]) : '';
    }
    $_CL_Templates->set($tempArray);
}
/* At last, any $_POST variables? */
if (isset($_autoFillInPostVars)) {
    $tempArray = array();
    foreach ($_autoFillInPostVars as $var) {
        $tempArray['_autoFillInPostVars-' . $var] = (isset($_POST[$var]) and $_POST[$var]) ? $_CL_Xety->plain($_POST[$var]) : '';
    }
    $_CL_Templates->set($tempArray);
}
/* Finally, send output to user ... */
echo $_CL_Templates->getContent();
Example #8
0
 /**
  * This function returns the path (according to the root of our website) of given file.
  * Example: "guestbook/form.tpl" -> "layouts/theBestWorldsTemplate/guestbook/form.tpl"
  *
  * @param string $file the file whom path we wanna know
  * @return string the file's path
  */
 function getFilePath($file)
 {
     if (substr($file, 0, 2) == '##') {
         $fileNew = CL::getConf('CL_Templates/dir') . self::$directory . substr($file, 2);
         if (!file_exists($fileNew)) {
             $fileNew = CL::getConf('CL_Templates/dir') . 'default/' . substr($file, 2);
         }
         $file = $fileNew;
     } elseif (substr($file, 0, 1) == '#') {
         $file = substr($file, 1);
     } elseif (substr($file, 0, 8) == 'modules/' or substr($this->moduleNamespace, 0, 8) == 'modules/') {
         $file = $this->moduleNamespace . $file;
     } else {
         $file = CL::getConf('CL_Templates/dir') . self::$directory . '/' . $file;
     }
     if (file_exists($file)) {
         return $file;
     } else {
         return FALSE;
     }
 }