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


PHP CRM_Utils_File::restrictBrowsing方法代码示例

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


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

示例1: checkDirectoriesAreNotBrowseable

 /**
  * Check if our uploads or ConfigAndLog directories have browseable
  * listings.
  *
  * Retrieve a listing of files from the local filesystem, and the
  * corresponding path via HTTP. Then check and see if the local
  * files are represented in the HTTP result; if so then warn. This
  * MAY trigger false positives (if you have files named 'a', 'e'
  * we'll probably match that).
  *
  * @return array
  *   Array of messages
  * @see CRM-14091
  *
  * @todo Test with WordPress, Joomla.
  */
 public function checkDirectoriesAreNotBrowseable()
 {
     $messages = array();
     $config = CRM_Core_Config::singleton();
     $publicDirs = array($config->imageUploadDir => $config->imageUploadURL);
     // Setup index.html files to prevent browsing
     foreach ($publicDirs as $publicDir => $publicUrl) {
         CRM_Utils_File::restrictBrowsing($publicDir);
     }
     // Test that $publicDir is not browsable
     foreach ($publicDirs as $publicDir => $publicUrl) {
         if ($this->isBrowsable($publicDir, $publicUrl)) {
             $msg = 'Directory <a href="%1">%2</a> should not be browseable via the web.' . '<br />' . '<a href="%3">Read more about this warning</a>';
             $docs_url = $this->createDocUrl('checkDirectoriesAreNotBrowseable');
             $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts($msg, array(1 => $publicDir, 2 => $publicDir, 3 => $docs_url)), ts('Browseable Directories'), \Psr\Log\LogLevel::ERROR, 'fa-lock');
         }
     }
     return $messages;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:35,代码来源:Security.php


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