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


PHP repository::antivir_scan_file方法代码示例

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


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

示例1: process_message_part_attachment

 /**
  * Process a message again to add body and attachment data.
  *
  * @param $messagedata The structure and part of the message body
  * @param $partdata The part data
  * @param $filename The filename of the attachment
  * @return \stdClass
  */
 private function process_message_part_attachment($messagedata, $partdata, $part, $filename)
 {
     global $CFG;
     // If a filename is present, assume that this part is an attachment.
     $attachment = new \stdClass();
     $attachment->filename = $filename;
     $attachment->type = $partdata->getType();
     $attachment->content = $partdata->getContents();
     $attachment->charset = $partdata->getCharset();
     $attachment->description = $partdata->getDescription();
     $attachment->contentid = $partdata->getContentId();
     $attachment->filesize = $messagedata->getBodyPartSize($part);
     if (empty($CFG->runclamonupload) or empty($CFG->pathtoclam)) {
         mtrace("--> Attempting virus scan of '{$attachment->filename}'");
         // Store the file on disk - it will need to be virus scanned first.
         $itemid = rand(1, 999999999);
         $directory = make_temp_directory("/messageinbound/{$itemid}", false);
         $filepath = $directory . "/" . $attachment->filename;
         if (!($fp = fopen($filepath, "w"))) {
             // Unable to open the temporary file to write this to disk.
             mtrace("--> Unable to save the file to disk for virus scanning. Check file permissions.");
             throw new \core\message\inbound\processing_failed_exception('attachmentfilepermissionsfailed', 'tool_messageinbound');
         }
         fwrite($fp, $attachment->content);
         fclose($fp);
         // Perform a virus scan now.
         try {
             \repository::antivir_scan_file($filepath, $attachment->filename, true);
         } catch (moodle_exception $e) {
             mtrace("--> A virus was found in the attachment '{$attachment->filename}'.");
             $this->inform_attachment_virus();
             return;
         }
     }
     return $attachment;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:44,代码来源:manager.php


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