本文整理汇总了PHP中JFolder::makeSafe方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::makeSafe方法的具体用法?PHP JFolder::makeSafe怎么用?PHP JFolder::makeSafe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::makeSafe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setGalleryPath
private function setGalleryPath($galleryPath)
{
// TODO handle if absolute path is used as input
$this->relativeGalleryPath = JFolder::makeSafe($galleryPath);
// TODO safe enough?
$this->galleryPath = JPATH_BASE . DS . $this->relativeGalleryPath;
}
示例2: get
public function get()
{
$app = JFactory::getApplication();
jimport('joomla.filesystem.folder');
JPluginHelper::importPlugin('api');
$result = $app->triggerEvent('register_api_plugin');
$plugins = array();
foreach ($result as $plugin) {
if (!isset($plugin->title) || !isset($plugin->plugin)) {
continue;
}
$path = JFolder::makeSafe(JPATH_ROOT . "/plugins/api/{$plugin->plugin}/html");
if (!JFolder::exists($path)) {
continue;
}
$files = JFolder::files($path, '.', true, true);
// Remove absolute path
foreach ($files as &$file) {
$file = str_replace(JPATH_ROOT . '/', '', $file);
}
$plugins[$plugin->plugin] = array('title' => $plugin->title, 'type' => $plugin->plugin, 'version' => $plugin->version, 'files' => $files);
}
ksort($plugins);
$this->plugin->setResponse($plugins);
}
示例3: save
function save($data)
{
$row =& JTable::getInstance('categories', 'Table');
$id = $data['id'];
if (!$row->bind($data)) {
JError::raiseError(500, $row->getError());
return false;
}
if (!$row->check()) {
JError::raiseError(500, $row->getError());
}
if (!$row->store()) {
JError::raiseError(500, $row->getError());
return false;
}
if (!$id) {
$row->load($row->{$id});
jimport('joomla.filesystem.file');
$baseFolder = JPATH_SITE . DS . 'codefile';
$baseFolder = JFolder::makeSafe($path);
if (!JFolder::exists($baseFolder)) {
JFolder::create($baseFolder);
echo "<br>" . $baseFolder;
}
$codeFolder = JPATH_SITE . DS . 'codefile' . DS . 'category_' . $row->id;
echo "<br>" . $codeFolder;
JFolder::create($codeFolder);
} else {
echo "The old row" . $id;
}
return true;
}
示例4: __construct
function __construct($name, $type)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$this->_name = JFolder::makeSafe($name);
$this->_type = JFolder::makeSafe($type);
$model =& JModel::getInstance('Configuration', 'JDefenderModel');
$this->_params = new JParameter($model->getIni());
$this->_rules =& JD_Rule_Manager::getRules($name);
}
示例5: splitPath
public static function splitPath($path, $makeRelative = true)
{
if ($makeRelative) {
$path = GalleryHelper::makeRelative($path);
}
$parts = explode('/', $path);
$object = new ArrayObject();
$object->filename = JFile::makeSafe(array_pop($parts));
// last element is filename
$object->folderPath = JFolder::makeSafe(implode(DS, $parts));
// use rest as path
return $object;
}
示例6: loadHandlers
/**
* Load the handlers :)
* @static
* @return void
*/
function loadHandlers($type)
{
static $loaded = array();
if (!empty($loaded[$type])) {
return;
}
$type = JFolder::makeSafe($type);
$basePath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'lib' . DS . 'handlers' . DS . $type;
$files = JFolder::files($basePath, 'jd_.+handler\\.php', false, false);
foreach ($files as $file) {
$path = $basePath . DS . $file;
if (JFile::exists($path)) {
require_once $path;
}
}
$loaded[$type] = true;
}
示例7: display
function display($tpl = null)
{
// params
$params = JFactory::getApplication()->getParams();
$galleryPath = $params->get('gallery_path');
// TODO not safe
// validate
$folderPath = JFolder::makeSafe(JRequest::getString('path'));
$filename = JFile::makeSafe(JRequest::getString('filename'));
// ---
$folder = new Folder($galleryPath, $folderPath);
$photo = new Photo($folder, $filename);
// add css
$document =& JFactory::getDocument();
$document->addStyleSheet('media/com_gallery/css/gallery.style.css');
// assign Variables
$this->assignRef('photo', $photo);
parent::display($tpl);
}
示例8: getFiles
public function getFiles($fullPath, $path)
{
$path = JFolder::makeSafe($path);
$data = array();
$extensions = $this->_config->get('file_types');
if (!$extensions) {
$extensions = 'jpeg,gif,png,jpg';
}
$arrayExtension = explode(',', $extensions);
$results = JFolder::files($fullPath, '.', false, false);
foreach ($results as $result) {
//get file's extension
$extension = JFile::getExt($result);
if (in_array($extension, $arrayExtension) && JFile::exists($fullPath . '/' . $result)) {
array_push($data, array('filename' => basename($result), 'type' => 'file', 'url' => preg_replace('!/+!', '/', JSNES_IMAGES_URL . $path . '/' . basename($result))));
}
}
return $data;
}
示例9: array
/**
* @static
* @param unknown_type $type
* @return JD_Action instance :0
*/
function &getInstance($type = null)
{
static $instances = array();
if (empty($type)) {
return $instances;
}
$type = JFolder::makeSafe($type);
if (empty($instances[$type])) {
JD_Action::_loadActions();
$className = 'JD_' . $type . '_Action';
if (class_exists($className)) {
$instances[$type] = new $className();
} else {
JError::raiseWarning(0, JText::_('Cannot instanciate action class') . ': ' . 'jd_' . $type . '_action');
return null;
}
}
return $instances[$type];
}
示例10: execute
public function execute()
{
$this->out('Hello. What do you want to build today:' . "\n" . '1 - Component; 2 - Plugin; 3 - Module');
$choice = $this->in();
switch ($choice) {
case 1:
case 2:
$this->out('Sorry but we can offer you only Modules :)');
break;
case 3:
default:
$this->type = 'module';
}
$this->out('Please enter an extension name in lower case e.g. "testmodule"');
$extName = JFolder::makeSafe($this->in());
$this->out('Do you want to install the extension on completion?');
$this->out("1 - Yes\n2 - No\n");
$install = $this->in();
$extInstall = $install == 1 ? true : false;
$manifestPath = 'scaffold/module/';
$this->builder = new JBuilder($extName, 'module', $extInstall);
$this->builder->build();
}
示例11: saveDocumentVersions
public function saveDocumentVersions($dataInput, $table, $fieldsData, $isNew, $newMainCatId, $tableBeforeSave = null)
{
$versions = $dataInput['versions'];
$docId = $table->id;
$app = JFactory::getApplication();
$params = JUDownloadHelper::getParams($newMainCatId);
$db = JFactory::getDbo();
$file_directory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
$file_directory_tmp = $file_directory . "tmp/";
if (!is_writable($file_directory_tmp)) {
$file_directory_tmp = sys_get_temp_dir() . "/plupload/";
}
if (JUDLPROVERSION && !$isNew && $params->get('store_old_file_versions', 1)) {
$versionField = new JUDownloadFieldCore_version();
if (version_compare($tableBeforeSave->version, $fieldsData[$versionField->id]) != 0) {
$query = "SELECT * FROM #__judownload_files WHERE doc_id = " . $docId;
$db->setQuery($query);
$fileObjectList = $db->loadObjectList();
foreach ($fileObjectList as $fileObj) {
$query = $db->getQuery(true);
$query->select('*')->from('#__judownload_versions')->where('file_id = ' . $fileObj->id)->where('date < ' . $db->quote($table->updated))->where('file_path != ""')->order('date DESC, version DESC');
$db->setQuery($query, 0, 1);
$nearestVersion = $db->loadObject();
$storeFile = false;
if (!$nearestVersion) {
$storeFile = true;
} else {
$currentVersionFile = $file_directory . $docId . '/' . $fileObj->file_name;
$nearestVersionFile = $file_directory . $docId . '/' . $nearestVersion->file_path;
if (hash_file('md5', $currentVersionFile) != hash_file('md5', $nearestVersionFile)) {
$storeFile = true;
}
}
if ($storeFile) {
$versionFolder = JFolder::makeSafe($table->version);
if (!$versionFolder) {
$versionFolder = 'versions';
}
if (!JFolder::exists($file_directory . $docId . "/" . $versionFolder . "/")) {
$file_index = $file_directory . $docId . "/" . $versionFolder . "/index.html";
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
$src = $file_directory . $docId . "/" . $fileObj->file_name;
$fileName = $fileObj->file_name;
$dest = $file_directory . $docId . "/" . $versionFolder . "/" . $fileName;
while (JFile::exists($dest)) {
$fileName = md5($fileObj->file_name . JUDownloadHelper::generateRandomString(10)) . "." . JFile::getExt($fileObj->file_name);
$dest = $file_directory . $docId . "/" . $versionFolder . "/" . $fileName;
}
JFile::copy($src, $dest);
$versionTable = JTable::getInstance("Version", "JUDownloadTable");
$version_downloads_check_arr = array('doc_id' => $docId, 'file_id' => $fileObj->id, 'version' => $table->version);
if ($versionTable->load($version_downloads_check_arr)) {
$versionTable->date = intval($table->updated) ? $table->updated : $table->created;
$versionTable->size = $fileObj->size;
$versionTable->md5_checksum = $fileObj->md5_checksum;
$versionTable->crc32_checksum = $fileObj->crc32_checksum;
$versionTable->file_path = $versionFolder . "/" . $fileName;
$versionTable->store();
} else {
$versionTable->bind($version_downloads_check_arr);
$versionTable->id = 0;
$versionTable->date = intval($table->updated) ? $table->updated : $table->created;
$versionTable->size = $fileObj->size;
$versionTable->md5_checksum = $fileObj->md5_checksum;
$versionTable->crc32_checksum = $fileObj->crc32_checksum;
$versionTable->file_path = $versionFolder . "/" . $fileName;
$versionTable->store();
}
}
}
}
}
if (JUDLPROVERSION && $app->isAdmin()) {
$versionTable = JTable::getInstance("Version", "JUDownloadTable");
foreach ($versions as $versionKey => $version) {
if ($versionTable->load($versionKey)) {
if ($version['remove']) {
$srcFile = $file_directory . $versionTable->doc_id . '/' . $versionTable->file_path;
JFile::delete($srcFile);
$versionTable->delete();
if ($version['replace']) {
$filePath = $file_directory_tmp . $version['replace'];
if (JFile::exists($filePath)) {
JFile::delete($filePath);
}
}
} elseif ($version['replace']) {
$oldFile = $file_directory . $versionTable->doc_id . '/' . $versionTable->file_path;
JFile::delete($oldFile);
$versionFolder = JFolder::makeSafe($versionTable->version);
if (!$versionFolder) {
$versionFolder = 'versions';
}
if (!JFolder::exists($file_directory . $versionTable->doc_id . "/" . $versionFolder . "/")) {
$file_index = $file_directory . $versionTable->doc_id . "/" . $versionFolder . "/index.html";
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
//.........这里部分代码省略.........
示例12: makeSafe
/**
* Helper wrapper method for makeSafe
*
* @param string $path The full path to sanitise.
*
* @return string The sanitised string
*
* @see JFolder::makeSafe()
* @since 3.4
*/
public function makeSafe($path)
{
return JFolder::makeSafe($path);
}
示例13: fileupdload
function fileupdload($id)
{
if (!$_FILES['cfile']['size'] || $_FILES['cfile']['size'] > 6000000) {
return false;
} else {
$permitted = array('application/zip', 'application/x-rar-compressed');
$typeOK = false;
foreach ($permitted as $type) {
if ($type == $_FILES['cfile']['type']) {
$typeOK = true;
break;
}
}
if ($typeOK) {
$cate = 'category_' . JRequest::getVar('category');
jimport('joomla.filesystem.folder');
$folder = JPATH_SITE . DS . 'codefile';
$folder = JFolder::makeSafe($folder);
if (!JFolder::exists($folder)) {
JFolder::create($folder);
}
$folder = JPATH_SITE . DS . 'codefile' . DS . $cate;
$folder = JFolder::makeSafe($folder);
if (!JFolder::exists($folder)) {
JFolder::create($folder);
}
$name = $_FILES['cfile']['name'];
$filename = 'devzone_' . $id . '_' . $name;
$newname = JPATH_SITE . DS . 'codefile' . DS . $cate . DS . $filename;
if (!move_uploaded_file($_FILES['cfile']['tmp_name'], $newname)) {
return false;
} else {
if ($this->filenameupdate($id, $filename)) {
return false;
} else {
return true;
}
}
} else {
return false;
}
}
}
示例14: testMakeSafe
/**
* Tests the JFolder::makeSafe method.
*
* @return void
*
* @since 12.1
*
* @covers JFolder::makeSafe
*/
public function testMakeSafe()
{
$actual = JFolder::makeSafe('test1/testdirectory');
$this->assertEquals('test1/testdirectory', $actual);
}
示例15: createZipArchive
protected function createZipArchive($archiveName = '', $filesPath = '', $files = array())
{
$archiveName = JPATH_TMP . $this->extPrefix . $this->extName . '.zip';
JFolder::makeSafe($archiveName);
if (JFile::exists($archiveName)) {
return false;
}
$zipAdapter =& JArchive::getAdapter('zip');
$result = $zipAdapter->create($archiveName, $this->filesArray);
return $result;
}