예제 #1
0
 /**
  * Constructeur,
  * initialise le moteur smarty, définie le répertoire du cache, des plugins ....
  */
 function PPollenCms()
 {
     $this->cache_dir = SMARTY_CACHE_DIR . "cache";
     $this->compile_dir = SMARTY_CACHE_DIR . "compiled";
     $this->compile_id = SITENAME ? SITENAME : 'default';
     $this->template_dir = THEME_DIR . 'templates';
     $this->assign('THEME_URL', THEME_URL);
     $this->assign('CONFIG_FILE_SITE', CONFIG_FILE);
     $configDescr = SITE_PATH . 'core' . SLASH . 'default_config.ini';
     if (is_file($configDescr)) {
         $this->assign('DEFAULT_CONFIG_FILE_SITE', $configDescr);
     }
     //try to create the cache dir and compile dir if not exists!
     if (!is_dir($this->cache_dir)) {
         $pdirCache = new PDir($this->cache_dir);
         if (!$pdirCache->mkdir()) {
             printFatalError(sprintf(_('can not create the cache dir %s. Please check permissions.'), $pdirCache->getRelativePath()));
         }
     }
     if (!is_dir($this->compile_dir)) {
         $pdirComile = new PDir($this->compile_dir);
         $pdirComile->mkdir();
     }
     $this->caching = 1;
     $this->cache_lifetime = -1;
     $this->force_compile = isConnected();
     $this->plugins_dir[] = SITE_PATH . 'core' . SLASH . 'lib' . SLASH . 'smartyplugins' . SLASH;
     //filters defined in plugins
     $this->loadDefaultFilters();
 }
예제 #2
0
 function createThumb($iTSize, $bSquare = true, $bForce = false, $strThumbPath = false)
 {
     if (!$strThumbPath) {
         $objThumb = new PImage(CACHE_DIR . "thumbnails/" . $iTSize . "x" . $iTSize . "/" . $this->getRelativePath());
     } else {
         $objThumb = new PImage($strThumbPath);
     }
     //if objThumb exists
     if (is_file($objThumb->path)) {
         if (!$bForce) {
             return $objThumb;
         } else {
             if (!$objThumb->Delete()) {
                 return false;
             }
         }
     }
     //create the directory
     $oDirParent = new PDir($objThumb->getParentPath());
     if (!is_dir($oDirParent->path) && !$oDirParent->mkdir()) {
         return false;
     }
     if (!$this->Copy($this->getName(), $oDirParent->path)) {
         return false;
     }
     if (!$objThumb->ResizeMax($iTSize, $bSquare)) {
         $objThumb->Delete();
         //if error occured while resizing thumb, delete it.
         return false;
     }
     return $objThumb;
 }
예제 #3
0
function images_tools_extrapage_imagestoolsresize($strPage, &$site)
{
    if ($strPage != 'imagestoolsresize.php') {
        return false;
    }
    require SITE_PATH . 'core/lib/pimage.php';
    if (!isset($_GET['img']) || !isset($_GET['width']) || !isset($_GET['height'])) {
        return false;
    }
    $strImgUrl = urldecode($_GET['img']);
    if (strstr($strImgUrl, '..') !== FALSE) {
        return false;
    }
    //check that image is a sub file of POLLEN MEDIAS directory
    if (!($oDirUpload = getFileObjectAndFind(MEDIAS_PATH))) {
        return false;
    }
    if (strstr($strImgUrl, $oDirUpload->getUrl()) === FALSE) {
        return false;
    }
    $strImgUrl = str_replace($oDirUpload->getUrl(), '', $strImgUrl);
    if (!($oImage = getFileObjectAndFind($oDirUpload->path . SLASH . str_replace('/', SLASH, $strImgUrl)))) {
        return false;
    }
    $iWidth = $_GET['width'];
    $iHeight = $_GET['height'];
    //generate the image resized, first copy the original image, then generate the resized image
    $oImageResize = new PImage(CACHE_DIR . 'thumbnails' . SLASH . $iWidth . 'x' . $iHeight . SLASH . $oImage->getRelativePath());
    //create resized image if not exits
    if (!is_file($oImageResize->path)) {
        if (!is_dir($oImageResize->getParentPath())) {
            $oDir = new PDir($oImageResize->getParentPath());
            if (!$oDir->mkdir()) {
                return false;
            }
        }
        if (!$oImage->Copy($oImageResize->getName(), $oImageResize->getParentPath())) {
            return false;
        }
        if (!$oImageResize->Resize($iWidth, $iHeight)) {
            return false;
        }
    }
    //at this point image must exists, if not return
    if (!is_file($oImageResize->path)) {
        return false;
    }
    //just set the header and read the image
    header('Content-type: image/' . $oImage->getExtension());
    readfile($oImageResize->path);
    return true;
}
예제 #4
0
 function toggleActivate($bSave = false)
 {
     global $configFile;
     $strToggleActive = $this->isActivated() ? "false" : "true";
     //check that the plugins conf dir exists, if not create it
     $strParentPath = $this->oConfig->getParentPath();
     if (!is_dir($strParentPath)) {
         $oParent = new PDir($strParentPath);
         if (!$oParent->mkdir()) {
             return false;
         }
     }
     return $configFile->setParam($this->getIdName(), $strToggleActive, 'PLUGINS', $bSave);
 }
예제 #5
0
 /**
  * function Save.
  * If the $strTextConfig is set, save the config file with this text.
  * Then launch the event manager for event savepage.
  * Finally call the parrent::Save fonction to save the text in the html file.
  *
  * @param string the text of the html file
  * @param string (optional, default false) the text of the config file
  * @return boolean true if suceed, false if an error occured
  */
 function Save($text, $strTextConfig = false)
 {
     $text = stripslashes($text);
     //		$text=str_replace('src="'.SITE_URL,'src="{#SITE_URL#}',$text);
     $strMediasUrl = POFile::getPathUrl(MEDIAS_PATH);
     $text = str_replace('src="' . $strMediasUrl, 'src="{$MEDIAS_URL}', $text);
     $text = str_replace('href="' . $strMediasUrl, 'href="{$MEDIAS_URL}', $text);
     //save the config file, if content has been changed
     $strContentConfig = is_file($this->oPConfigFile->path) ? file_get_contents($this->oPConfigFile->path) : '';
     if ($strTextConfig && $strTextConfig != $strContentConfig) {
         if (!$this->oPConfigFile->Save($strTextConfig)) {
             return false;
         }
     }
     //do not save the page, if content has not been changed
     $strContent = is_file($this->path) ? file_get_contents($this->path) : '';
     if ($text == $strContent) {
         return true;
     }
     //save the history if file exists
     if (is_file($this->path)) {
         // save history folder and file, only one backup per minute
         $iCTime = time();
         $iCTime = $iCTime - date('s', $iCTime);
         //calculate the timestamp for current minute whitout seconds
         $oDirHistoryCache = new PDir(CACHE_HIST_DIR . SLASH . $this->getId() . SLASH . $iCTime);
         //create the directory if not exists
         if (!is_dir($oDirHistoryCache->path)) {
             if (!$oDirHistoryCache->mkdir()) {
                 return false;
             }
         }
         /* html file */
         $oHTMLHistory = new PTextFile($oDirHistoryCache->path . SLASH . basename($this->path));
         if (!$oHTMLHistory->Save($strContent)) {
             return false;
         }
         /* ini file */
         if (is_file($this->oPConfigFile->path)) {
             $oConfigHistory = new PConfigfile($oDirHistoryCache->path . SLASH . basename($this->oPConfigFile->path));
             if (!$oConfigHistory->Save($strContentConfig)) {
                 return false;
             }
         }
     }
     //when saving must load the new file due to cache
     if (doEventAction('savepage', array(&$text, &$this)) === false) {
         return false;
     }
     return parent::Save($text);
 }
예제 #6
0
include 'admin_top.php';
$tabMainTabs = array();
$oTextConfigFile = new PTextFile($configFile->path);
$tabMainTabs[] = array('FRAG_NAME' => 'frag_config', 'TAB_NAME' => _('Site Configuration'), 'TAB_CONTENT' => array_to_tabs(array(array('FRAG_NAME' => 'site_config', 'TAB_NAME' => _('Site Parameters'), 'TAB_CONTENT' => $configFile->DisplayEditor('actionClickOnSaveSiteConfig')), array('FRAG_NAME' => 'hotkeys_management', 'TAB_NAME' => _('Manage Hot Keys'), 'TAB_CONTENT' => $configFile->DisplayEditor('actionClickOnSaveConfig', 'HOTKEYS')), array('FRAG_NAME' => 'site_cache', 'TAB_NAME' => _('Cache Management'), 'TAB_CONTENT' => '
					<div style="padding-top:60px">
						<button onClick="clickOnClearCache(this,\'' . _('Clearing cache ....') . '\',\'site\');" class="ui-state-default ui-corner-all" type="button">' . _('clear site cache') . '</button>
						<button onClick="clickOnClearCache(this,\'' . _('Clearing cache ....') . '\',\'thumbs\');" class="ui-state-default ui-corner-all" type="button">' . _('clear thumbs cache') . '</button>
						<button onClick="clickOnClearCache(this,\'' . _('Clearing cache ....') . '\',\'history\');" class="ui-state-default ui-corner-all" type="button">' . _('clear history cache') . '</button>
					</div>
				'), array('FRAG_NAME' => 'site_file_config', 'TAB_NAME' => _('Config File'), 'TAB_CONTENT' => $oTextConfigFile->DisplayEditor())), 'tabConfiguratorLevel2'));
/**Models **/
$strModelContent = '';
$strUrltabModels = 'admin_file_management.php?current_dir=' . urlencode(POFile::getPathRelativePath(PAGES_MODELS_PATH));
if (!is_dir(PAGES_MODELS_PATH)) {
    $oDirModels = new PDir(PAGES_MODELS_PATH);
    if (!$oDirModels->mkdir()) {
        $strModelContent .= getError();
    }
}
if (is_dir(PAGES_MODELS_PATH)) {
    $oDirModels =& getFileObject(PAGES_MODELS_PATH);
    $tabListModels = $oDirModels->listDir($oDirModels->ONLY_FILES);
    foreach ($tabListModels as $filePath) {
        if (is_file($filePath)) {
            $oTemp =& getFileObject($filePath);
            //$strModelContent.=get_class($oTemp);
            $strModelContent .= $oTemp->Display(70, $url = false, $oDirModels);
        }
    }
}
$tabMainTabs[] = array('FRAG_NAME' => 'models_link', 'TAB_NAME' => _('Models Management'), 'TAB_CONTENT' => '
예제 #7
0
 function Copy($newname, $dirDest = false)
 {
     if (strlen($newname) == 0) {
         return setError(_("Can not copy directory with empty name"));
     }
     if (!$dirDest) {
         $dirDest = $this->getParentPath();
     }
     $newDir = new PDir($dirDest . SLASH . $newname);
     if (is_file($newDir->path) || is_dir($newDir->path)) {
         return setError(_("Directory or File exists") . ": " . $newname);
     }
     if (!$newDir->mkdir()) {
         return false;
     }
     $tabFiles = $this->listDir($this->ALL, $fullpath = true);
     foreach ($tabFiles as $file) {
         $objFile = getFileObject($file);
         if (!$objFile->Copy($objFile->getName(), $newDir->path)) {
             return false;
         }
     }
     //			if(!copy($this->path,$newfile)) return setError(_("Error occured while copying directory").". "._("Check file permissions").".");
     return true;
 }