You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TemplateMonster rd-search.php插件无法搜索PHP文件问题求助

Hey there! Let’s figure out why adding php to your $search_in array isn’t working, and get that plugin searching PHP files properly. I’ve dealt with similar TemplateMonster search scripts before, so here are the most likely issues and fixes:

1. There’s a second file type filter elsewhere in the code

The $search_in variable might not be the only place where file extensions are restricted. Many TemplateMonster scripts have a secondary check—often in the file-traversal loop—to validate allowed extensions.

  • Open up rd-search.php and search for other arrays or conditionals that check file extensions. Look for code like:
    $allowed_exts = array('html', 'htm');
    if (!in_array(strtolower($ext), $allowed_exts)) {
        continue; // Skip non-allowed files
    }
    
  • Add 'php' to this array too, just like you did with $search_in.

2. The script is filtering out PHP code from file content

Most search plugins strip or ignore PHP tags (<?php ... ?>) when reading file content, which means even if it scans PHP files, it won’t search the text inside those tags.

  • Look for code that processes the file content after reading it. You might see something like:
    $content = file_get_contents($file_path);
    // This line removes all PHP code
    $content = preg_replace('/<\?php.*?\?>/s', '', $content);
    
  • To include PHP content in searches, either comment out that preg_replace line or modify the regex to preserve the text inside the tags (if that’s what you want). For example, you could adjust it to only remove the opening/closing tags:
    $content = preg_replace('/<\?php|\?>/s', '', $content);
    

3. The script is skipping directories with PHP files

Some versions of this plugin are configured to ignore certain directories (like admin folders, includes, etc.). If your PHP files are in a directory that’s being excluded, they won’t be scanned at all.

  • Search for code that checks directory names, like:
    $excluded_dirs = array('admin', 'includes', 'assets');
    if (in_array($dir_name, $excluded_dirs)) {
        continue;
    }
    
  • Make sure the directory containing your PHP files isn’t in this excluded list.

4. Server or script caching is overriding your changes

Sometimes, server caching (like OPcache, or a CDN) can keep old versions of the script running.

  • Clear any server-side caches you have access to.
  • Double-check that you’ve saved the modified rd-search.php file and re-uploaded it to your server correctly.

Quick Troubleshooting Checklist

  • Confirm 'php' is added to all file extension allowlists in the code
  • Ensure PHP file content isn’t being stripped before search
  • Verify PHP file directories aren’t excluded from scanning
  • Clear caches and re-upload the modified script

If you still run into issues, feel free to share a snippet of the file-traversal or content-processing code from your rd-search.php—that’ll help narrow it down further!

内容的提问来源于stack exchange,提问作者Elisa Ltc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:21:47