0

ちょっと厄介な問題に出くわしました。

プログラムでphpファイルから特定のテキスト行を引き出す必要があります。(コメント内のプラグインのバージョン番号)

簡単に思えますが、読み取ろうとしているファイルには、それを開こうとするスクリプトに関する限り未定義の関数が含まれています。

とにかく、PHP の組み込み関数を使用してファイルを読み取ることができますか?これまでのところ、file_get_contents()、file()、および readfile() はすべて同じ問題に悩まされています。

どんな助けでも大歓迎です。

- - - - - - - - - - - - - - - - - - - - - - アップデート

さて、以前のエラーはキャッシングの問題が原因だったようですが、未定義関数エラーなしで動作しているように見えますが、現在は戻り配列が空のように見えますか?

リーダー スクリプト

<?php

//some other code

//lines in question
$lines = file('path/to/file.php');          
$data['Version']=$lines[6];

?>

読み取り中のファイル

<?php
/*
Plugin Name: Wordfence Security
Plugin URI: http://www.wordfence.com/
Description: Wordfence Security - Anti-virus, Firewal and Site Speedup
Author: Wordfence
Version: 5.0.6
Author URI: http://www.wordfence.com/
*/
if(defined('WP_INSTALLING') && WP_INSTALLING){
    return;
}
define('WORDFENCE_VERSION', '5.0.6');
if(get_option('wordfenceActivated') != 1){
    add_action('activated_plugin','wordfence_save_activation_error'); function wordfence_save_activation_error(){ update_option('wf_plugin_act_error',  ob_get_contents()); }
}
if(! defined('WORDFENCE_VERSIONONLY_MODE')){
    if((int) @ini_get('memory_limit') < 64){
        if(strpos(ini_get('disable_functions'), 'ini_set') === false){
            @ini_set('memory_limit', '64M'); //Some hosts have ini set at as little as 32 megs. 64 is the min sane amount of memory.
        }
    }
    require_once('lib/wordfenceConstants.php');
    require_once('lib/wordfenceClass.php');
    wordfence::install_actions();
}

?>
4

0 に答える 0