当前位置: 首页>>代码示例>>PHP>>正文


PHP JUDownloadHelper::generateRandomString方法代码示例

本文整理汇总了PHP中JUDownloadHelper::generateRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::generateRandomString方法的具体用法?PHP JUDownloadHelper::generateRandomString怎么用?PHP JUDownloadHelper::generateRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUDownloadHelper的用法示例。


在下文中一共展示了JUDownloadHelper::generateRandomString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addFileInfo

 public function addFileInfo(&$file, $filePath, $destDir)
 {
     $params = JUDownloadHelper::getParams();
     if (function_exists('finfo_open')) {
         $finfo = finfo_open(FILEINFO_MIME);
         $file['mime_type'] = finfo_file($finfo, $filePath);
         finfo_close($finfo);
     } elseif (function_exists('mime_content_type')) {
         $file['mime_type'] = mime_content_type($filePath);
     }
     $file['size'] = filesize($filePath);
     if ($params->get('auto_generate_md5_checksum', 2) == 2 && $file['size'] <= $params->get("max_filesize_auto_generate_checksum", 100) * 1024 * 1024 || $params->get('auto_generate_md5_checksum', 2) == 1) {
         $file['md5_checksum'] = hash_file('md5', $filePath);
     } else {
         $file['md5_checksum'] = '';
     }
     if ($params->get('auto_generate_crc32_checksum', 2) == 2 && $file['size'] <= $params->get("max_filesize_auto_generate_checksum", 100) * 1024 * 1024 || $params->get('auto_generate_crc32_checksum', 2) == 1) {
         return $file['crc32_checksum'] = hash_file('crc32b', $filePath);
     } else {
         $file['crc32_checksum'] = '';
     }
     do {
         $file['file_name'] = md5($file['file_name'] . JUDownloadHelper::generateRandomString(10)) . "." . JFile::getExt($file['file_name']);
         $dest = $destDir . $file['doc_id'] . "/" . $file['file_name'];
     } while (JFile::exists($dest));
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:26,代码来源:csvprocess.php

示例2: remoteFile

 public function remoteFile()
 {
     $app = JFactory::getApplication();
     if (!$this->isValidUploadURL() || !JUDownloadFrontHelperPermission::canUploadFromUrl($app->input->get('doc_id', null))) {
         $result = array();
         $result['success'] = 0;
         $result['alert'] = JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_UPLOAD_FILE');
         JUDownloadHelper::obCleanData();
         echo json_encode($result);
         exit;
     }
     $type = $app->input->get('type', '');
     $result = array();
     $file_directory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
     $file_directory_tmp = $file_directory . "tmp/";
     if (!JFolder::exists($file_directory_tmp)) {
         JFolder::create($file_directory_tmp);
         $file_index = $file_directory_tmp . 'index.html';
         $buffer = "<!DOCTYPE html><title></title>";
         JFile::write($file_index, $buffer);
     }
     if (!is_writable($file_directory_tmp)) {
         $file_directory_tmp = sys_get_temp_dir() . "/plupload/";
     }
     if ($type === 'loadtransfer') {
         $source_url = $app->input->get('source_url', '', 'string');
         if (!$source_url) {
             $result['success'] = 0;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_SOURCE_URL_IS_MISSING');
         }
         $file = $this->loadTransfer($source_url);
         if ($file) {
             $file_name = end(explode("/", $source_url));
             $file_extension = end(explode(".", $file_name));
             do {
                 $target_name = md5(JUDownloadHelper::generateRandomString(10)) . "." . $file_extension;
             } while (JFile::exists($file_directory_tmp . $target_name));
             $result['success'] = 1;
             $result['size'] = (int) $file[1];
             $result['type'] = (string) $file[2];
             $result['name'] = $file_name;
             $result['target_name'] = $target_name;
         } else {
             $result['success'] = 0;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_INVALID_FILE');
         }
     } elseif ($type === 'transferfile') {
         $target_name = $app->input->get('target_name', '', 'string');
         $source_url = $app->input->get('source_url', '', 'string');
         if (!$source_url) {
             $result['success'] = 0;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_INVALID_SOURCE_URL');
         } elseif (!$target_name) {
             $result['success'] = 0;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_INVALID_TARGET_NAME');
         } elseif ($this->remoteDownload($source_url, $file_directory_tmp . $target_name, 1024)) {
             $result['success'] = 1;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_DOWNLOAD_REMOTE_FILE_SUCCESSFULLY');
         } else {
             $result['success'] = 0;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_FAIL_TO_DOWNLOAD_REMOTE_FILE');
         }
     } elseif ($type === 'getprocess') {
         $target_name = $app->input->get('target_name', '', 'string');
         $file_size = $app->input->getInt('file_size', 0);
         $current_size = filesize($file_directory_tmp . $target_name);
         if ($current_size === false || !$file_size) {
             $result['success'] = 0;
             $result['alert'] = JText::_('COM_JUDOWNLOAD_FAIL_TO_GET_FILE_TRANSFER_STATUS');
         } else {
             if ($current_size >= $file_size) {
                 $percent = 100;
             } else {
                 $percent = round($current_size / $file_size * 100);
             }
             $result['success'] = 1;
             $result['alert'] = '';
             $result['percent'] = $percent;
         }
     }
     if ($type === 'cancel') {
         $target_name = $app->input->get('target_name', '', 'string');
         if (JFile::exists($file_directory_tmp . $target_name)) {
             JFile::delete($file_directory_tmp . $target_name);
         }
     }
     JUDownloadHelper::obCleanData();
     echo json_encode($result);
     exit;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:90,代码来源:document.php

示例3: generateImageNameByDocument

 public static function generateImageNameByDocument($doc_id, $file_name)
 {
     if (!$doc_id || !$file_name) {
         return "";
     }
     $dir_document_ori = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_original_image_directory", "media/com_judownload/images/gallery/original/") . $doc_id . "/";
     $info = pathinfo($file_name);
     $document = JUDownloadHelper::getDocumentById($doc_id);
     $replace = array('id' => $document->id, 'category' => '', 'document' => $document->title, 'image_name' => $info['filename']);
     $base_file_name = JUDownloadHelper::parseImageNameByTags($replace, 'document', null, $document->id) . "." . $info['extension'];
     $img_file_name = $base_file_name;
     $img_path_ori = $dir_document_ori . $img_file_name;
     while (JFile::exists($img_path_ori)) {
         $img_file_name = JUDownloadHelper::generateRandomString(3) . "-" . $base_file_name;
         $img_path_ori = $dir_document_ori . $img_file_name;
     }
     return $img_file_name;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:18,代码来源:judownload.php


注:本文中的JUDownloadHelper::generateRandomString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。