/** * 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(); }
function se_get_config($strParam, &$strValue) { global $seConfigFile; if (!$seConfigFile) { $oDir = new PDir(dirname(__FILE__)); $oPlugin = new PPluginDir($oDir->getParentPath()); $seConfigFile = $oPlugin->oConfig; } if ($strParam == 'tablename') { if (!$seConfigFile->getParam('PREFIX', $strPrefix)) { return false; } $strValue = $strPrefix . 'searchengine'; } else { if (!$seConfigFile->getParam($strParam, $strValue)) { return false; } } if ($strValue === "true") { $strValue = true; } if ($strValue === "false") { $strValue = false; } return true; }
function seAdminHeader() { $oDir = new PDir(dirname(__FILE__)); $strCurrUrl = $oDir->getUrl(); $strReturn = ' <!-- Add By Plugin seAdminHeader --> <script language="JavaScript" src="' . $strCurrUrl . 'include/js/apply-se.js" ></script> <!-- // --> '; return $strReturn; }
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; }
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); }
function __getEditorFormItem($strParam, $strValue, $idForm) { $strType = $this->getParamDescr($strParam, "TYPE", "text"); $bEditable = $this->getParamDescr($strParam, "EDITABLE", "true") == "false" ? false : true; $strEditable = $bEditable ? "" : " style=\"display:none;\" "; $strReturn = '<div class="params"' . $strEditable . ' >' . "\n"; $strReturn .= '<label class="param" >' . _($this->getVarPrintName($strParam)) . ':</label>'; switch ($strType) { case 'boolean': $strChecked = $strValue == "true" ? 'checked' : ''; $strTpl = '<input class="paramvalue" {STYLE} type="checkbox" name="{PARAM_NAME}" id="field_{PARAM_NAME}" value="{PARAM_VALUE}" {CHECKED} onClick="javascript:if(this.checked){this.value=true;}else{this.value=false;} reloadFileConfigTextArea(\'{ID_FORM}\'); "/><br /> <div class="reset"></div> '; $strReturn .= str_replace(array('{CHECKED}', '{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strChecked, $strEditable, $strParam, $strValue, $idForm), $strTpl); break; case 'list': $strTpl = '<select name="{PARAM_NAME}" class="paramvalue" {STYLE} id="field_{PARAM_NAME}" onChange="reloadFileConfigTextArea(\'{ID_FORM}\');"> {LIST_ITEMS} </select> <br /><div class="reset"></div> '; $strList = ''; $strListTpl = ' <option value="{PARAM_VALUE}" {SELECTED}>{PARAM_NAME}</option> '; $tabValues = explode(",", $this->getParamDescr($strParam, "LIST_VALUES", $strValue)); foreach ($tabValues as $val) { $strListVal = ''; $strListParam = ''; if (preg_match('/=>/', $val)) { $tabPV = explode('=>', $val); $strListVal = $tabPV[1]; $strListParam = $tabPV[0]; if ($strListParam == 'list_files') { //first search in theme dir then in medias path $strDirPath = is_dir($strListVal) ? $strListVal : SITE_PATH . THEME_DIR . $strListVal; $strDirPath = is_dir($strDirPath) ? $strDirPath : MEDIAS_PATH . SLASH . $strListVal; if (is_dir($strDirPath)) { $pDirList = new PDir($strDirPath); $tabListFiles = $pDirList->listDir($pDirList->ONLY_FILES, false); foreach ($tabListFiles as $strFile) { $oFile = new PFile($strFile); $strSelected = $strFile == $strValue ? 'SELECTED' : ''; $strList .= str_replace(array('{SELECTED}', '{PARAM_NAME}', '{PARAM_VALUE}'), array($strSelected, $oFile->getNameWithoutExt(), $strFile), $strListTpl); } } } else { $strSelected = $strListVal == $strValue ? 'SELECTED' : ''; $strList .= str_replace(array('{SELECTED}', '{PARAM_NAME}', '{PARAM_VALUE}'), array($strSelected, $strListParam, $strListVal), $strListTpl); } } else { $strListParam = $val; $strListVal = $val; $strSelected = $strListVal == $strValue ? 'SELECTED' : ''; $strList .= str_replace(array('{SELECTED}', '{PARAM_NAME}', '{PARAM_VALUE}'), array($strSelected, $strListParam, $strListVal), $strListTpl); } } $strReturn .= str_replace(array('{LIST_ITEMS}', '{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strList, $strEditable, $strParam, $strValue, $idForm), $strTpl); break; case 'password': $strTpl = '<input class="paramvalueText paramvalue" {STYLE} onChange="reloadFileConfigTextArea(\'{ID_FORM}\');" type="password" name="{PARAM_NAME}" id="field_{PARAM_NAME}" value="{PARAM_VALUE}" /><br /> <div class="reset"></div> '; $strReturn .= str_replace(array('{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strEditable, $strParam, $strValue, $idForm), $strTpl); break; case 'textarea': $strTpl = '<textarea name="{PARAM_NAME}" id="field_{PARAM_NAME}" class="paramvalue paramvalueTextArea" wrap="off" onChange="reloadFileConfigTextArea(\'{ID_FORM}\');" >{PARAM_VALUE}</textarea> <br /><div class="reset"></div> '; $strReturn .= str_replace(array('{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strEditable, $strParam, $strValue, $idForm), $strTpl); break; case 'text': $strTpl = '<input class="paramvalueText paramvalue" {STYLE} onChange="reloadFileConfigTextArea(\'{ID_FORM}\');" type="text" name="{PARAM_NAME}" id="field_{PARAM_NAME}" value="{PARAM_VALUE}" /><br /> <div class="reset"></div> '; $strReturn .= str_replace(array('{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strEditable, $strParam, $strValue, $idForm), $strTpl); break; } //end switch return $strReturn . "\n</div>\n"; }
function _deleteCache() { //find thumbnails and delete all $oDirThumb = new PDir(CACHE_DIR . "thumbnails"); $tabDirSize = $oDirThumb->listDir($oDirThumb->ONLY_DIR, $fullpath = true); $strRelativePath = $this->getRelativePath(); foreach ($tabDirSize as $strDirPath) { if (is_file($strThumbPath = $strDirPath . SLASH . $strRelativePath)) { $oFileThumb = new PFile($strThumbPath); if (!$oFileThumb->Delete()) { return false; } } } return true; }
if (isset($_GET["current_dir"]) && $_GET["current_dir"] != '' && !preg_match("/\\.\\./", urldecode($_GET["current_dir"]))) { $rootpath = SITE_PATH . urldecode($_GET["current_dir"]); $_GET["current_dir"] = ''; } else { $rootpath = SITE_PATH; } } else { $rootpath = SITE_PATH . (isset($_GET["rootpath"]) ? urldecode($_GET["rootpath"]) : ''); } if (!isset($_GET["current_dir"]) || $_GET["current_dir"] == '' || preg_match("/\\.\\./", urldecode($_GET["current_dir"]))) { $current_dir = $rootpath; } else { $current_dir = $rootpath . SLASH . urldecode($_GET["current_dir"]); } $pcurrent_dir =& getFileObjectAndFind($current_dir); $proot_dir = new PDir($rootpath); //NOW WE HAVE OUR ROOT DIR AND CURR DIR if (!is_dir($rootpath)) { die('root path: ' . $_GET["rootpath"] . ' not found.'); } if (!$pcurrent_dir) { die('current directory not found'); } ?> <!-- FILE PATH --> <div id="path" style="margin-top:40px;"> <div style='float:right;margin-top:-10px'> <a id="btnNewFolderSmall" class="btnNewSmall" href="javascript:createDir('<?php echo urljsencode($pcurrent_dir->getRelativePath()); ?>
function getHistoryList() { if (!is_file($this->path)) { return array(); } $oDirHistory = new PDir(CACHE_HIST_DIR . $this->getId()); $tabReturn = array(); //the current version, before editing $tabReturn[] = array('PATH' => $this->path, 'PRINTNAME' => _('Last Version')); if ($oDirHistory->isDir()) { $tabList = array_reverse($oDirHistory->listDir($oDirHistory->ONLY_DIR)); foreach ($tabList as $strDirHistoryVersion) { $pDirVersion = new PDir($strDirHistoryVersion); $listFiles = $pDirVersion->listDir($oDirHistory->ONLY_FILES, true, $filter = '\\.htm[l]?$'); if (sizeof($listFiles) > 0) { $iFileTime = basename($pDirVersion->path); $strDay = date('Y-m-d', time()) == date('Y-m-d', $iFileTime) ? _('today at') : date(_('Y-m-d'), $iFileTime); $strPrintName = $strDay . ' ' . date(_('H:i'), $iFileTime); $tabReturn[] = array('PATH' => $listFiles[0], 'PRINTNAME' => $strPrintName); } } } return $tabReturn; }
if (isset($_GET["current_dir"]) && $_GET["current_dir"] != '' && !preg_match("/\\.\\./", urldecode($_GET["current_dir"]))) { $rootpath = SITE_PATH . urljsdecode($_GET["current_dir"]); $_GET["current_dir"] = ''; } else { $rootpath = SITE_PATH; } } else { $rootpath = SITE_PATH . (isset($_GET["rootpath"]) ? urldecode($_GET["rootpath"]) : ''); } if (!isset($_GET["current_dir"]) || $_GET["current_dir"] == '' || preg_match("/\\.\\./", urldecode($_GET["current_dir"]))) { $current_dir = $rootpath; } else { $current_dir = $rootpath . SLASH . urljsdecode($_GET["current_dir"]); } $pcurrent_dir =& getFileObject($current_dir); $proot_dir = new PDir($rootpath); if (!is_dir($rootpath)) { die('root path not exists.'); } if (!$pcurrent_dir) { die('current directory not found'); } $rootpathdir = $proot_dir->getRelativePath(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="noindex, nofollow" />
/** * Rename a file. If the newname has no file extension, use the current file extension. * If destDir not set, use the current file directory. If set move the file to the * destdir. * * @param string $strNewName, the new name of the file. * @param string $destDir, the path of the destination directory, if false, the parent path * @return true if succeed, else false */ function Rename($strNewName, $destDir = false) { $strNewName = $this->getUnixName($strNewName); $strActionName = !$destDir || $destDir == $this->getParentPath() ? 'rename' : 'move'; //check name if (!$this->checkname($strNewName)) { return false; } //check extension $oFile = new PFile($strNewName); $strNewName .= $oFile->getExtension() == '' ? '.' . $this->getExtension() : ''; if (strlen($oFile->getNameWithoutExt()) == 0) { return setError(_("Can not {$strActionName} with empty name.")); } //check destDir $destDir = !$destDir ? $this->getParentPath() : $destDir; $objDstDir = new PDir($destDir); if (!$objDstDir->isDir()) { return setError(sprintf(_("Can not {$strActionName} file.\nDirectory not %s exists."), $objDstDir->getRelativePath())); } if (!is_writable($objDstDir->path)) { return setError(sprintf(_("Can not {$strActionName} file %s.\nDirectory is not %s writable."), $objDstDir->getRelativePath())); } //check write accesses if (!is_writable($this->path)) { return setError(sprintf(_("Can not {$strActionName} file %s.\n"), $this->getRelativePath())); } $newfile = $destDir . SLASH . $strNewName; if ($this->path == $newfile) { return true; } if (file_exists($newfile)) { return setError(sprintf(_("File: %s exists."), basename($newfile))); } if (!@rename($this->path, $newfile)) { return setError(_("An error occured while renaming file")); } $this->path = $newfile; return true; }
function createDir($strDirName) { $strDirName = trim($strDirName); if (!$this->checkName($strDirName)) { return false; } $strPageName = $strDirName; $strDirName = $this->getUnixName($strPageName); if (getFileObjectAndFind($this->path . SLASH . $strDirName, 'dir') !== false) { return setError(sprintf(_('The directory %s exists.'), $strDirName)); } //on supprime le cache du menu if (!deleteMenuCache()) { return false; } if (!parent::createDir($strDirName)) { return false; } //set the virtual name if (!($oDir = getFileObject($this->path . SLASH . basename($strDirName)))) { return setError('internal error, pdircategory, createDir'); } if (!$oDir->setVirtualName($strPageName)) { return false; } return true; }
//if index file create it $pfile =& $pFileTemp; } else { printFatalError(); } } } //url back $pdirparent =& getFileObject($pfile->getParentPath()); if (isConnected()) { echo ' <div id="path"> <div id="imgHome"></div> '; $strPath = $pfile->path; $oRoot = new PDir(strstr($pfile->path, PAGES_PATH) !== false ? PAGES_PATH : (strpos($pfile->path, PAGES_MODELS_PATH) !== false ? PAGES_MODELS_PATH : SITE_PATH)); $tabGuid = array(); while ($oRoot->path != $strPath && strlen($strPath) > 1) { $o =& getFileObject($strPath); if (is_dir($o->path)) { $fileMangementUrl = 'admin_file_management.php?rootpath=' . rawurlencode(str_replace(SITE_PATH, '', PAGES_PATH)) . '¤t_dir=' . rawurlencode($o->getRelativePath(PAGES_PATH)); $tabGuid[] = array('NAME' => $o->getName(), 'URL' => $fileMangementUrl); } $strPath = $o->getParentPath(); } $tabGuid[] = array('NAME' => str_replace('languages', _('Site Pages'), $oRoot->getName()), 'URL' => 'admin_file_management.php?rootpath=' . rawurlencode(str_replace(SITE_PATH, '', $oRoot->path))); $tabGuid = array_reverse($tabGuid); foreach ($tabGuid as $strUrlGuid) { echo '<a href="' . $strUrlGuid['URL'] . '">' . $strUrlGuid['NAME'] . '</a> > '; } echo $pfile->getShortName();
function getLinkPath($rootpath = false) { $oDir = new PDir($this->path); $root = $rootpath != false ? $rootpath : SITE_PATH . SITE . PAGES; $tabPath = explode(SLASH, $oDir->getRelativePath($root)); $pdirroot = new PDir($rootpath); $rootpath = $pdirroot->getRelativePath(); $parent = ''; $isize = sizeof($tabPath); for ($i = 0; $i < $isize; $i++) { $path = $tabPath[$i]; if ($path != '') { $parent .= $path; $obj = getFileObject($root . SLASH . $parent); echo " > <a href=\"" . $_SERVER["PHP_SELF"] . "?current_dir=" . urlencode($parent) . ($rootpath == false ? "" : "&rootpath=" . $rootpath) . "\" >" . $obj->getPrintedName(); echo "</a>"; $parent .= SLASH; } } }
/** * Function sortpages * This fonction is call by the sortfile javascript plugins. * It renames the files. The file begin with a number are ordered. * * If an object file not begin with a number, it is not ordered. * * @return: true if suceed, else return false. */ function sortpages() { if (!isset($_REQUEST['filename'])) { return setError('Internal error in sortfiles, filename not defined'); } $tabFilesNew = $_REQUEST['filename']; //if less than two files no need to sort if (sizeof($tabFilesNew) < 2) { return true; } //get the dir to order, take the second element because in some cas the first element is ../ $pTemp = new PFile(SITE_PATH . urljsdecode($tabFilesNew[1])); $oDirToOrder = new PDir($pTemp->getParentPath()); $i = 0; foreach ($tabFilesNew as $strFile) { $strFile = urljsdecode($strFile); //if not parent file if (SITE_PATH . $strFile != $oDirToOrder->getParentPath()) { //get the file number, if number exist reorder it //this is the original file number, if modified twice it change in php but not in html $oFileTest = new PFile($oDirToOrder->path . SLASH . basename($strFile)); if ($oFileTest->is_page() || $oFileTest->is_dircategory() || $oFileTest->is_link()) { $oFile = getFileObject($oFileTest->path); $iCurrOrder = $oFile->getMenuOrder(); $i++; if ($iCurrOrder != $i) { //print('reorder '.$oFile->getName().' from '.$iCurrOrder.' to '.$i); if (!$oFile->setMenuOrder($i)) { return false; } } //if file order has changed } //end if filenumber is set } //end if ofile not parent dir } //end foreach return true; }
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); } } }
function pcms_clearcache($strType = 'site') { $cacheDir = false; switch ($strType) { case 'site': $cacheDir = new PDir(SMARTY_CACHE_DIR); break; case 'thumbs': $cacheDir = new PDir(CACHE_DIR . 'thumbnails/'); break; case 'history': $cacheDir = new PDir(CACHE_HIST_DIR); break; default: $cacheDir = new PDir(SMARTY_CACHE_DIR); break; } if (is_dir($cacheDir->path) && !$cacheDir->Delete()) { return false; } setError(_('Error deleting cache.')); return true; }