スクリプトファイルを追加

This commit is contained in:
2026-04-03 18:22:33 +09:00
commit 809d3bc3e4
14 changed files with 1956 additions and 0 deletions

24
hensu.py Normal file
View File

@@ -0,0 +1,24 @@
import chardet
import re
def detect_encoding(file_path):
with open(file_path, 'rb') as f:
raw_data = f.read()
result = chardet.detect(raw_data)
return result['encoding']
def extract_php_variables(file_path):
encoding = detect_encoding(file_path)
with open(file_path, 'r', encoding=encoding) as f:
content = f.read()
variables = re.findall(r'\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*', content)
unique_vars = sorted(set(variables))
return unique_vars
# 使用例
php_file = 'OfficeChusenTourakuKakutei.php'
variables = extract_php_variables(php_file)
print("PHPファイル内の変数一覧:")
for var in variables:
print(var)