本文整理匯總了PHP中Cx\Lib\FileSystem\FileSystem::sanitizePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileSystem::sanitizePath方法的具體用法?PHP FileSystem::sanitizePath怎麽用?PHP FileSystem::sanitizePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cx\Lib\FileSystem\FileSystem
的用法示例。
在下文中一共展示了FileSystem::sanitizePath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _getThumbs
/**
* Get thumbnails
*
* Get the thumbnails from a day in the archive.
* Create the thumbnails if they don't already exists.
*
* @return boolean TRUE if the thumbs have been loaded, otherwise FALSE
*/
protected function _getThumbs()
{
// set and sanitize the archive path
$path = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $this->camSettings['archivePath'] . '/' . $this->date . '/';
$path = \Cx\Lib\FileSystem\FileSystem::sanitizePath($path);
// set and sanitize the thumbnail path
$thumbPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $this->camSettings['thumbnailPath'];
$thumbPath = \Cx\Lib\FileSystem\FileSystem::sanitizePath($thumbPath);
if (!$path || !$thumbPath) {
return false;
}
$objDirectory = @opendir($path);
$chmoded = false;
if (!$objDirectory) {
return false;
}
while ($file = readdir($objDirectory)) {
if ($file != "." && $file != "..") {
//check and create thumbs
$thumb = $thumbPath . '/tn_' . $this->date . '_' . $file;
if (!\Cx\Lib\FileSystem\FileSystem::exists($thumb)) {
if (!$chmoded) {
\Cx\Lib\FileSystem\FileSystem::makeWritable($this->camSettings['thumbnailPath']);
$chmoded = true;
}
//create thumb
$im1 = @imagecreatefromjpeg($path . $file);
//erstellt ein Abbild im Speicher
if ($im1) {
/* Pr�fen, ob fehlgeschlagen */
// check_jpeg($thumb, $fix=false );
$size = getimagesize($path . $file);
//ermittelt die Gr��e des Bildes
$breite = $size[0];
//die Breite des Bildes
$hoehe = $size[1];
//die H�he des Bildes
$breite_neu = $this->camSettings['thumbMaxSize'];
//die breite des Thumbnails
$factor = $breite / $this->camSettings['thumbMaxSize'];
//berechnungsfaktor
$hoehe_neu = $size[1] / $factor;
//die H�he des Thumbnails
//$im2=imagecreate($breite_neu,$hoehe_neu); //Thumbnail im Speicher erstellen
$im2 = @imagecreatetruecolor($breite_neu, $hoehe_neu);
imagecopyresized($im2, $im1, 0, 0, 0, 0, $breite_neu, $hoehe_neu, $breite, $hoehe);
imagejpeg($im2, $thumb);
//Thumbnail speichern
imagedestroy($im1);
//Speicherabbild wieder l�schen
imagedestroy($im2);
//Speicherabbild wieder l�schen
}
}
//show pictures
$minHour = date('G', $this->camSettings['showFrom']);
$minMinutes = date('i', $this->camSettings['showFrom']);
$maxHour = date('G', $this->camSettings['showTill']);
$maxMinutes = date('i', $this->camSettings['showTill']);
$hour = substr($file, 4, 2);
$min = substr($file, 13, 2);
$min = !empty($min) ? $min : "00";
$time = $hour . ":" . $min . " Uhr";
$minTime = mktime($minHour, $minMinutes);
$maxTime = mktime($maxHour, $maxMinutes);
$nowTime = mktime($hour, $min);
/*
* only show archive images if they are in range
*/
if ($nowTime <= $maxTime && $nowTime >= $minTime) {
if ($this->camSettings['shadowboxActivate'] == 1) {
$linkUrl = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . $this->camSettings['archivePath'] . '/' . $this->date . '/' . $file;
} else {
$linkUrl = '[[NODE_LIVECAM]]?file=' . $this->date . '/' . $file;
}
$arrThumbnail = array('link_url' => $linkUrl, 'image_url' => $this->camSettings['thumbnailPath'] . "/tn_" . $this->date . "_" . $file, 'time' => $time);
array_push($this->_arrArchiveThumbs, $arrThumbnail);
}
}
}
closedir($objDirectory);
return true;
}
示例2: __construct
/**
* PHP5 constructor
* @param string $objTemplate
* @param array $_ARRAYLANG
* @access public
*/
function __construct()
{
global $_ARRAYLANG, $_FTPCONFIG, $objTemplate, $objDatabase;
// sigma template
$this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Media/View/Template/Backend');
\Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
$this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
$this->arrPaths = array(ASCMS_MEDIA1_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIA2_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIA3_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIA4_PATH . DIRECTORY_SEPARATOR, ASCMS_FILESHARING_PATH . DIRECTORY_SEPARATOR, ASCMS_CONTENT_IMAGE_PATH . DIRECTORY_SEPARATOR, ASCMS_SHOP_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_THEMES_PATH . DIRECTORY_SEPARATOR, ASCMS_ATTACH_PATH . DIRECTORY_SEPARATOR, ASCMS_ACCESS_PATH . DIRECTORY_SEPARATOR, ASCMS_BLOG_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_CALENDAR_IMAGE_PATH . DIRECTORY_SEPARATOR, ASCMS_DOWNLOADS_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_GALLERY_PATH . DIRECTORY_SEPARATOR, ASCMS_MEDIADIR_IMAGES_PATH . DIRECTORY_SEPARATOR, ASCMS_PODCAST_IMAGES_PATH . DIRECTORY_SEPARATOR);
$this->arrWebPaths = array('archive1' => ASCMS_MEDIA1_WEB_PATH . '/', 'archive2' => ASCMS_MEDIA2_WEB_PATH . '/', 'archive3' => ASCMS_MEDIA3_WEB_PATH . '/', 'archive4' => ASCMS_MEDIA4_WEB_PATH . '/', 'FileSharing' => ASCMS_FILESHARING_WEB_PATH . '/', 'content' => ASCMS_CONTENT_IMAGE_WEB_PATH . '/', 'Contact' => ASCMS_ATTACH_WEB_PATH . '/', 'Shop' => ASCMS_SHOP_IMAGES_WEB_PATH . '/', 'themes' => ASCMS_THEMES_WEB_PATH . '/', 'attach' => ASCMS_ATTACH_WEB_PATH . '/', 'Access' => ASCMS_ACCESS_WEB_PATH . '/', 'Blog' => ASCMS_BLOG_IMAGES_WEB_PATH . '/', 'Calendar' => ASCMS_CALENDAR_IMAGE_WEB_PATH . '/', 'Downloads' => ASCMS_DOWNLOADS_IMAGES_WEB_PATH . '/', 'Gallery' => ASCMS_GALLERY_WEB_PATH . '/', 'MediaDir' => ASCMS_MEDIADIR_IMAGES_WEB_PATH . '/', 'Podcast' => ASCMS_PODCAST_IMAGES_WEB_PATH . '/');
$moduleMatchTable = array('archive1' => 'Media1', 'archive2' => 'Media2', 'archive3' => 'Media3', 'archive4' => 'Media4', 'content' => 'core', 'themes' => 'core', 'attach' => 'core');
$license = \Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase);
$license->check();
foreach ($this->arrWebPaths as $module => $path) {
$moduleName = $module;
if (isset($moduleMatchTable[$module])) {
$moduleName = $moduleMatchTable[$module];
}
if (!$license->isInLegalComponents($moduleName)) {
\DBG::msg('Module "' . $module . '" is deactivated');
unset($this->arrWebPaths[$module]);
}
}
if (empty($this->arrWebPaths)) {
\Permission::noAccess();
}
if (isset($_REQUEST['archive']) && array_key_exists($_REQUEST['archive'], $this->arrWebPaths)) {
$this->archive = $_REQUEST['archive'];
} else {
$this->archive = 'content';
}
// get variables
$this->getAct = isset($_POST['deleteMedia']) && $_POST['deleteMedia'] ? 'delete' : (!empty($_GET['act']) ? trim($_GET['act']) : '');
$this->getPath = isset($_GET['path']) ? \Cx\Lib\FileSystem\FileSystem::sanitizePath($_GET['path']) : false;
if ($this->getPath === false) {
$this->getPath = $this->arrWebPaths[$this->archive];
}
$this->getFile = isset($_REQUEST['file']) ? \Cx\Lib\FileSystem\FileSystem::sanitizeFile($_REQUEST['file']) : false;
if ($this->getFile === false) {
$this->getFile = '';
}
$this->getData = !empty($_GET['data']) ? $_GET['data'] : '';
$this->sortBy = !empty($_GET['sort']) ? trim($_GET['sort']) : 'name';
$this->sortDesc = !empty($_GET['sort_desc']);
$this->shopEnabled = $this->checkModule('Shop');
if ($this->archive == 'themes') {
$_SESSION["skins"] = true;
} else {
$_SESSION["skins"] = false;
}
switch ($this->archive) {
case 'themes':
\Permission::checkAccess(21, 'static');
$objTemplate->setVariable("CONTENT_NAVIGATION", "<a href='index.php?cmd=Media&archive=content'>" . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . "</a>\n <a href='index.php?cmd=Media&archive=attach'>" . $_ARRAYLANG['TXT_MODULE'] . "</a>\n <a href='index.php?cmd=Media&archive=themes' class='active'>" . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . "</a>");
break;
case 'content':
\Permission::checkAccess(32, 'static');
$objTemplate->setVariable('CONTENT_NAVIGATION', '
<a href="index.php?cmd=Media&archive=content" class="active">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a>
<a href="index.php?cmd=Media&archive=attach">' . $_ARRAYLANG['TXT_MODULE'] . '</a>
<a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a>');
break;
case 'Contact':
\Permission::checkAccess(84, 'static');
$objTemplate->setVariable('CONTENT_NAVIGATION', '
<a href="index.php?cmd=Contact" title="' . $_ARRAYLANG['TXT_CONTACT_CONTACT_FORMS'] . '">' . $_ARRAYLANG['TXT_FORMS'] . '</a>
<a hreF="index.php?cmd=Media&archive=Contact" title="' . $_ARRAYLANG['TXT_FILE_UPLOADS'] . '" class="active">' . $_ARRAYLANG['TXT_FILE_UPLOADS'] . '</a>
<a href="index.php?cmd=Contact&act=settings" title="' . $_ARRAYLANG['TXT_CONTACT_SETTINGS'] . '">' . $_ARRAYLANG['TXT_CONTACT_SETTINGS'] . '</a>
');
break;
case 'FileSharing':
\Permission::checkAccess(8, 'static');
$objTemplate->setVariable('CONTENT_NAVIGATION', '
<a href="index.php?cmd=Media&archive=FileSharing"' . (!isset($_GET['act']) || $_GET['act'] == 'filesharing' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_FILESHARING_MODULE'] . '</a>
<a href="index.php?cmd=Media&archive=FileSharing&act=settings"' . (isset($_GET['act']) && $_GET['act'] == 'settings' ? ' class="active"' : '') . '>' . $_ARRAYLANG['TXT_MEDIA_SETTINGS'] . '</a>
');
break;
case 'attach':
\Permission::checkAccess(84, 'static');
$objTemplate->setVariable('CONTENT_NAVIGATION', '
<a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a>
<a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a>
<a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a>
');
break;
case 'Access':
\Permission::checkAccess(18, 'static');
$objTemplate->setVariable('CONTENT_NAVIGATION', '
<a href="index.php?cmd=Media&archive=content">' . $_ARRAYLANG['TXT_IMAGE_CONTENT'] . '</a>
<a href="index.php?cmd=Media&archive=attach" class="active">' . $_ARRAYLANG['TXT_MODULE'] . '</a>
<a href="index.php?cmd=Media&archive=themes">' . $_ARRAYLANG['TXT_MEDIA_LAYOUT'] . '</a>
');
break;
case 'Blog':
\Permission::checkAccess(119, 'static');
//.........這裏部分代碼省略.........
示例3: saveCam
/**
* Save the cam's settings
*
*/
function saveCam()
{
global $objDatabase;
$id = intval($_POST['id']);
if (!$id) {
return false;
}
$currentImagePath = \Cx\Lib\FileSystem\FileSystem::sanitizePath(contrexx_input2raw($_POST['currentImagePath']));
if (!\FWValidator::isUri($currentImagePath) && strpos($currentImagePath, '/') !== 0) {
$currentImagePath = '/' . $currentImagePath;
}
$maxImageWidth = intval($_POST['maxImageWidth']);
$archivePath = \Cx\Lib\FileSystem\FileSystem::sanitizePath(contrexx_input2raw($_POST['archivePath']));
if (!\FWValidator::isUri($archivePath) && strpos($archivePath, '/') !== 0) {
$archivePath = '/' . $archivePath;
}
$thumbnailPath = \Cx\Lib\FileSystem\FileSystem::sanitizePath(contrexx_input2raw($_POST['thumbnailPath']));
if (!\FWValidator::isUri($thumbnailPath) && strpos($thumbnailPath, '/') !== 0) {
$thumbnailPath = '/' . $thumbnailPath;
}
$thumbMaxSize = intval($_POST['thumbMaxSize']);
$shadowboxActivate = intval($_POST['shadowboxActivate']);
$hourFrom = intval($_POST['hourFrom']);
$hourTill = intval($_POST['hourTill']);
$minuteFrom = intval($_POST['minuteFrom']);
$minuteTill = intval($_POST['minuteTill']);
$showFrom = mktime($hourFrom, $minuteFrom);
$showTill = mktime($hourTill, $minuteTill);
$query = " UPDATE " . DBPREFIX . "module_livecam\n SET currentImagePath = '" . contrexx_raw2db($currentImagePath) . "',\n maxImageWidth = " . $maxImageWidth . ",\n archivePath = '" . contrexx_raw2db($archivePath) . "',\n thumbnailPath = '" . contrexx_raw2db($thumbnailPath) . "',\n thumbMaxSize = " . $thumbMaxSize . ",\n shadowboxActivate = '" . $shadowboxActivate . "',\n showFrom = {$showFrom},\n showTill = {$showTill}\n WHERE id = " . $id;
if ($objDatabase->Execute($query) === false) {
// return a 500 or so
header("HTTP/1.0 500 Internal Server Error");
die;
}
die;
}