本文整理汇总了PHP中JFile::raiseWarning方法的典型用法代码示例。如果您正苦于以下问题:PHP JFile::raiseWarning方法的具体用法?PHP JFile::raiseWarning怎么用?PHP JFile::raiseWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFile
的用法示例。
在下文中一共展示了JFile::raiseWarning方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quarantine
/**
* (non-PHPdoc)
* @see components/com_jdefender/lib/actions/JD_Action#quarantine()
*/
function quarantine()
{
jimport('joomla.filesystem.file');
$config =& $this->getConfig();
$quarantineDir = JPath::clean($config->get('dir_quarantine'));
if (!JFolder::exists($quarantineDir)) {
JFolder::create($quarantineDir);
}
if (empty($quarantineDir) || !JFolder::exists($quarantineDir)) {
JError::raiseWarning('ME_D', JText::_('Please set the Quarantine Directory'));
$this->setError(JText::_('Quarantine directory is not defined'));
$this->_quarantines = array();
return false;
}
// Get the files to quarantine
list($files, $ids) = $this->_getFilesAndIds($this->_quarantines);
// Move 'em all ;)
$quarantinedFiles = array();
$filesToRehash = array();
foreach ($files as $file) {
$file = JPath::clean($file);
if (JFile::exists($file)) {
$destFile = str_replace(JPATH_ROOT, '', $file);
$destFile = trim($destFile, DS . ' ');
$destFile = JPath::clean($quarantineDir . DS . $destFile);
$filesToRehash[] = $file;
$filesToRehash[] = $destFile;
if (JFile::exists($destFile)) {
JFile::raiseWarning(JText::_('The file has been already quarantined') . ': ' . $destFile);
$this->setError(JText::_('The file has been already quarantined') . ': ' . $destFile);
return false;
}
$info = new stdClass();
$info->original = $file;
$info->quarantined = $destFile;
$info->moved = false;
$quarantinedFiles[] = $info;
}
}
$rollback = false;
foreach ($quarantinedFiles as $k => $info) {
if (!JFolder::exists(dirname($info->quarantined))) {
JFolder::create(dirname($info->quarantined));
}
if (!JFile::move($info->original, $info->quarantined)) {
$rollback = true;
$this->setError(JText::_('Cannot move file') . ' ' . $info->original . ' ' . JText::_('to') . ' ' . $info->quarantined);
break;
}
$quarantinedFiles[$k]->moved = true;
}
if ($rollback) {
// Rollback the changes
foreach ($quarantinedFiles as $k => $info) {
if ($info->moved) {
JFile::move($info->quarantined, $info->original);
}
}
$this->_quarantines = array();
return false;
}
$this->setLogStatus($ids, 'deleted');
$this->refreshFilesystemTable($filesToRehash, true);
$this->_quarantines = array();
return true;
}