本文整理汇总了PHP中CsviHelper::fileExistsRemote方法的典型用法代码示例。如果您正苦于以下问题:PHP CsviHelper::fileExistsRemote方法的具体用法?PHP CsviHelper::fileExistsRemote怎么用?PHP CsviHelper::fileExistsRemote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsviHelper
的用法示例。
在下文中一共展示了CsviHelper::fileExistsRemote方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createThumbnail
/**
* Create a thumbnail image
*
* @copyright
* @author RolandD
* @todo
* @see
* @access public
* @param string $original the full path and name of the large image
* @param string $output_path the path to store the thumbnail
* @param string $output_name the name of the thumbnail
* @return
* @since 4.0
*/
public function createThumbnail($original, $output_path, $output_name)
{
$jinput = JFactory::getApplication()->input;
$template = $jinput->get('template', null, null);
$csvilog = $jinput->get('csvilog', null, null);
$base = JPath::clean(JPATH_SITE, '/');
// Make sure the thumbnail is the same file type as the full image
if ($template->get('thumb_check_filetype', 'image') && JFile::getExt($original) != JFile::getExt($output_name)) {
$output_name = JFile::stripExt($output_name) . '.' . JFile::getExt($original);
}
$output_name = $this->_setCase($output_name);
// Check if the original is an external image
if (!$this->isRemote($original)) {
$original = $base . '/' . $original;
$file_exists = JFile::exists($original);
$remote = false;
} else {
$file_exists = CsviHelper::fileExistsRemote($original);
$remote = true;
}
// Check if thumbsize is greater than 0
if ($template->get('thumb_width', 'image') >= 1 && $template->get('thumb_height', 'image') >= 1) {
// Check if the image folders exists
$thumb_folder = JPATH_SITE . '/' . $output_path . dirname($output_name);
if (!JFolder::exists($thumb_folder)) {
$csvilog->addDebug(JText::sprintf('COM_CSVI_CREATE_THUMB_FOLDER', $thumb_folder));
JFolder::create($thumb_folder);
}
// Check if the target thumb exists, if yes delete it
if (JFile::exists($base . '/' . $output_path . $output_name)) {
JFile::delete($base . '/' . $output_path . $output_name);
}
// Check if the original file exists
$csvilog->addDebug(JText::sprintf('COM_CSVI_CHECK_ORIGINAL', $original));
if ($file_exists) {
// Collect all thumbnail details
$thumb_file_details = array();
$thumb_file_details['file'] = $original;
$thumb_file_details['file_extension'] = JFile::getExt($original);
$thumb_file_details['file_out'] = $base . '/' . $output_path . $output_name;
$thumb_file_details['maxsize'] = 0;
$thumb_file_details['bgred'] = 255;
$thumb_file_details['bggreen'] = 255;
$thumb_file_details['bgblue'] = 255;
$thumb_file_details['file_out_width'] = $template->get('thumb_width', 'image');
$thumb_file_details['file_out_height'] = $template->get('thumb_height', 'image');
$thumb_file_details['file_out_extension'] = JFile::getExt($output_name);
$thumb_file_details['mime_type'] = $this->findMimeType($original, $remote);
// We need to resize the image and Save the new one only if it is in a different location
$csvilog->addDebug(JText::sprintf('COM_CSVI_DEBUG_CREATING_A_THUMBNAIL', $original, $thumb_file_details['file_out']));
if ($original != $thumb_file_details['file_out']) {
$new_img = $this->convertImage($thumb_file_details);
// Check if an image was created
if ($new_img) {
// Get the details of the thumb image
if (JFile::exists($new_img)) {
$csvilog->addDebug(JText::_('COM_CSVI_DEBUG_THUMB_CREATED'));
return $output_path . $output_name;
} else {
$csvilog->addDebug(JText::_('COM_CSVI_THUMBNAIL_NOT_CREATED'));
return false;
}
} else {
$csvilog->addDebug(JText::_('COM_CSVI_THUMBNAIL_NOT_CREATED'));
return false;
}
} else {
$csvilog->addDebug('COM_CSVI_THUMB_SAME_AS_FULL');
$csvilog->AddStats('incorrect', 'COM_CSVI_THUMB_SAME_AS_FULL');
return false;
}
} else {
$csvilog->addDebug(JText::sprintf('COM_CSVI_FILE_DOES_NOT_EXIST_NOTHING_TO_DO', $original));
$csvilog->AddStats('nofiles', JText::sprintf('COM_CSVI_FILE_DOES_NOT_EXIST_NOTHING_TO_DO', $original));
return false;
}
} else {
$csvilog->addDebug('COM_CSVI_THUMBNAIL_SIZE_TOO_SMALL');
$csvilog->AddStats('incorrect', 'COM_CSVI_THUMBNAIL_SIZE_TOO_SMALL');
return false;
}
}
示例2: validateFile
//.........这里部分代码省略.........
}
return false;
}
}
break;
// Local file
// Local file
case 'fromserver':
$csv_file = JPath::clean($template->get('local_csv_file', 'general'), '/');
// Set the file name to use
$jinput->set('csv_file', $csv_file);
if (!JFile::exists($csv_file)) {
$csvilog->addDebug('[VALIDATEFILE] ' . JText::sprintf('COM_CSVI_LOCAL_FILE_DOESNT_EXIST', $csv_file));
$csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_LOCAL_FILE_DOESNT_EXIST', $csv_file));
return false;
} else {
$jinput->set('upload_file_error', false);
}
$fileinfo = pathinfo($csv_file);
if (isset($fileinfo["extension"])) {
$this->extension = strtolower($fileinfo["extension"]);
if ($this->extension == 'txt') {
$this->extension = 'csv';
}
}
break;
case 'fromurl':
// The temporary folder
$folder = $this->_unpackpath . '/' . time();
$urlfile = $template->get('urlfile', 'general', false);
$tempfile = basename($urlfile);
// Check if the remote file exists
if ($urlfile) {
if (CsviHelper::fileExistsRemote($urlfile)) {
// Copy the remote file to a local location
if (JFolder::create($folder)) {
if (touch($folder . '/' . $tempfile)) {
if (JFile::write($folder . '/' . $tempfile, JFile::read($urlfile))) {
$csvilog->addDebug(JText::sprintf('COM_CSVI_RETRIEVE_FROM_URL', $urlfile));
$jinput->set('csv_file', $folder . '/' . $tempfile);
$jinput->set('upload_file_error', false);
$this->extension = JFile::getExt($tempfile);
} else {
$csvilog->AddStats('incorrect', JText::_('COM_CSVI_CANNOT_READ_FROM_URL'));
return false;
}
} else {
$csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_CANNOT_CREATE_TEMP_FILE', $folder . '/' . $tempfile));
return false;
}
} else {
$csvilog->AddStats('incorrect', JText::sprintf('COM_CSVI_CANNOT_CREATE_TEMP_FOLDER', $folder));
return false;
}
} else {
$csvilog->AddStats('incorrect', JText::_('COM_CSVI_CANNOT_READ_FROM_URL'));
return false;
}
} else {
$csvilog->AddStats('incorrect', JText::_('COM_CSVI_NO_FILENAME_GIVEN'));
return false;
}
break;
case 'fromftp':
// The temporary folder
$folder = $this->_unpackpath . '/' . time();