小编mik*_*ols的帖子

65
推荐指数
1
解决办法
12万
查看次数

如何使用PHP readdir排除某些文件类型?

我正在使用一个php扫描目录脚本,它将扫描目录的内容,然后使用指向目录内容的链接填充页面.

<?php
$count = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
    if ($file != "." && $file != "..") {$count++;
        print("<a href=\"".$file."\">".$file."</a><br />\n");
    }
}
echo '<br /><br /><a href="..">Return</a>';
closedir($handle);
}
?
Run Code Online (Sandbox Code Playgroud)

我想知道如何排除某些文件或文件类型,如test.xml,durka.xslt或.html显示在填充页面上.我有一些代码,但不知道如何集成它.任何帮助将非常感谢...

?php
if ($handle = opendir(‘.’)) {
while (false !== ($file = readdir($handle)))
{
if ($file != “.” && $file != “..”
&& $file != “NOT-TO-BE-IN-1.php”
&& $file != “NOT-TO-BE-IN-2.html”
&& $file != “NOT-TO-BE-IN-3.jpg”
&& $file != “”
&& $file != …
Run Code Online (Sandbox Code Playgroud)

php

3
推荐指数
1
解决办法
1万
查看次数

为新用户每15天加载一次Magnific Popup

我有一个简报注册表单,我想每15天加载一次(弹出),否则可能会有点恼人.我目前正在使用此jquery代码在页面加载时加载弹出窗体.

<div id="test-popup" class="white-popup mfp-hide">
Popup Form
</div>

<script>
jQuery(window).load(function(){
jQuery.magnificPopup.open({
items: {src: '#test-popup'},type: 'inline'}, 0);
});
</script>
Run Code Online (Sandbox Code Playgroud)

这在每次访问页面时加载表单时工作正常,但我想限制这一点,以便新用户每15天看一次.不确定15天是最好的做法我想出的东西?

javascript jquery jquery-cookie magnific-popup

3
推荐指数
1
解决办法
2160
查看次数

如何使用 PHP opendir 读取当前目录之外的目录?

我似乎无法使粗体文件路径起作用。我希望脚本扫描 Dir_3。任何帮助将不胜感激。

 <?php

  // These files will be ignored
  $excludedFiles = array (
'excludeMe.file',
'excludeMeAs.well'
);

// These file extensions will be ignored
$excludedExtensions = array (
  'html',
'xslt',
'htm',
'ahk',
'xsl',
'txt',
'xml'
);

// Make sure we ignore . and ..
$excludedFiles = array_merge($excludedFiles,array('.','..')); 

 // Convert to lower case so we are not case-sensitive
 for ($i = 0; isset($excludedFiles[$i]); $i++) $excludedFiles[$i] =        
 strtolower(ltrim($excludedFiles[$i],'.'));
  for ($i = 0; isset($excludedExtensions[$i]); $i++) $excludedExtensions[$i] =    
 strtolower($excludedExtensions[$i]);

  // Loop through directory
  $count = …
Run Code Online (Sandbox Code Playgroud)

php

0
推荐指数
1
解决办法
5119
查看次数