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 movefile() { if (!isset($_POST['FILE_RELATIVE_PATH'])) { return setError('Internal error in movefile, FILE_RELATIVE_PATH is not set'); } if (!isset($_POST['TARGET_DIR'])) { return setError('Internal error in movefile, TARGET_DIR is not set'); } if (!($oFileToMove =& getFileObjectAndFind(SITE_PATH . urljsdecode($_POST['FILE_RELATIVE_PATH'])))) { return setError('Internal error in movefile, can not find file to move'); } if (!($oDirTarget =& getFileObjectAndFind(SITE_PATH . urljsdecode($_POST['TARGET_DIR'])))) { return setError('Internal error in movefile, can not find file target dir'); } if (!$oFileToMove->Move($oDirTarget->path)) { return false; } return true; }
function PLink($strPath) { parent::PPage($strPath); $strContent = file_get_contents($this->path); $this->oLinkedPage = getFileObjectAndFind(PAGES_PATH . SLASH . $strContent); }
if (!isset($_GET["rootpath"]) || $_GET["rootpath"] == '' || preg_match("/\\.\\./", urldecode($_GET["rootpath"]))) { 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());
/** * Copy a page. Check the name of the new copy, then copy the html file and the inifile. * Also set the virtual name, and reset the MENU NAME and the MENU_ORDER * * @param string $strNewName, the new name of the file. If the file extension is not set use the original one. * @param string $strParentPath, path of the dire where will be but the copy. If not set use the parent path of the * copied page. * @return boolean true if succeed, else false. */ function Copy($strNewName, $strParentPath = false) { $strCPageName = $strNewName; $strCFileName = $this->getUnixName($strNewName); if (strlen($strCFileName) == 0) { return setError(_("Can not copy page with empty name.")); } if (!$this->checkname($strCPageName)) { return false; } if (!$strParentPath) { $strParentPath = $this->getParentPath(); } $strCFileName .= "." . $this->getExtension(); $strCFilePath = $strParentPath . SLASH . $strCFileName; if (getFileObjectAndFind($strCFilePath)) { return setError(sprintf(_('Page %s ever exists.'), $strNewName)); } //Copy the html file if (!parent::Copy($strCFileName, $strParentPath)) { return false; } //then copy the ini file if exists if (!($oCPage =& getFileObject($strCFilePath))) { return setError(_('Internal Error. In copy, page not exists')); } if (is_file($this->oPConfigFile->path)) { if (!$this->oPConfigFile->Copy($oCPage->oPConfigFile->getName(), $strParentPath)) { return false; } } //reset the MENU NAME for the newfile, set the menu order and set the virtual name if (!$oCPage->oPConfigFile->setParam('MENU_NAME', '')) { return false; } if (!$oCPage->oPConfigFile->setParam('MENU_ORDER', '99')) { return false; } if (!$oCPage->setVirtualName($strCPageName)) { return false; } return true; }
function createLink($strLinkName = false) { if (!$strLinkName) { $strLinkName = _('link ') . $this->getMenuName() . '.lnk'; } $oDirParent = getFileObject($this->getParentPath()); if (!$oDirParent->createFile($strLinkName)) { return false; } if (!($oLink = getFileObjectAndFind($oDirParent->path . SLASH . $oDirParent->getUnixName($strLinkName)))) { return setError('Internale Error. Can not find the created link file'); } if (!$oLink->setLinkedPage($this)) { return false; } return true; }
}); </script> '; } require "../config.inc.php"; require SITE_PATH . 'core/lib/pdir.php'; require SITE_PATH . 'core/lib/pimage.php'; require SITE_PATH . 'core/lib/ppage.php'; require SITE_PATH . 'core/lib/lib_functions.php'; define("EDIT_FILE", true); /*Security, can't browse .. directory*/ if (!isset($_GET["file"]) || $_GET["file"] == '' || eregi("\\.\\.", $_GET["file"])) { printFatalError(_('You should specified a file to edit')); } $pFileTemp =& getFileObject(SITE_PATH . urldecode($_GET["file"])); $pfile =& getFileObjectAndFind($pFileTemp->path, 'file'); if ($pfile === false) { if ($pFileTemp->is_configfile()) { //must create it $pfile =& $pFileTemp; } else { if (preg_match('/index\\.htm[l]?$/', basename($pFileTemp->path)) !== false) { //if index file create it $pfile =& $pFileTemp; } else { printFatalError(); } } } //url back $pdirparent =& getFileObject($pfile->getParentPath());
/** * Function: getFirstPage * return the first page of the current web site * * * param: $dirSearch, the directory where to search, if not set, search in the PAGES_PATH * return: false if not found, the first page */ function getFirstPage($dirSearch = false, $adminMode = false) { $dirSearch = $dirSearch == false ? PAGES_PATH : $dirSearch; if (!is_dir($dirSearch)) { return false; } $oDirParent =& getFileObjectAndFind($dirSearch, 'dir'); if (!$oDirParent) { return false; } if (!($adminMode || $oDirParent->isPublished())) { return false; } //Try to find the index file, if found and is publised, return $file =& getFileObjectAndFind($dirSearch . SLASH . "index.html"); if ($file !== false && ($adminMode || $file->isPublished())) { return $file; } else { $file =& getFileObjectAndFind($dirSearch . SLASH . "index.php"); if ($file !== false && ($adminMode || $file->isPublished())) { return $file; } } $tab = $oDirParent->listDir($oDirParent->ALL, $fullpath = true); if (sizeof($tab) == 0) { return false; } foreach ($tab as $file) { //bug d'une image placée à l'index du site if (!(is_file($file) && !preg_match('/\\.htm[l]?$/', $file))) { $oFile =& getFileObject($file); if ($adminMode !== false || $oFile->isPublished()) { if (is_file($oFile->path)) { return $oFile; } else { $oFind =& $this->getFirstPage($oFile->path, $adminMode); if ($oFind && $oFind->isPublished()) { return $oFind; } } } } } return setError(__('No page found in the directory') . ': ' . $dirSearch); }