메신저 여기 좀 엉망입니다. 나는 내 컴퓨터 (wamp)에 쓴 스크립트를 테스트 중이지만 preg_match_all()을 사용하면 아무 이유없이 작동한다. 나는 간섭하는 것이 있는지 알아보기 위해 대부분의 다른 코드를 주석 처리하지만, 여전히 동일합니다. preg_match_all()을 사용하면 오류는 표시되지만 표시되지 않습니다.preg_match_all()이 아무것도 반환하지 않습니다!
도움을 주시면 감사하겠습니다.
<?php
define("DB_USERNAME", "root");
define("DB_PASSWORD", "");
define("DB_SERVER", "localhost");
define("DB_NAME", "s_framework");
$CON = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die (mysql_error());
$DB = mysql_select_db(DB_NAME, $CON);
$query = "SELECT * FROM `files` ORDER BY ID";
$query = mysql_query($query, $CON) or die (mysql_error());
$remove_comments = true;
$remove_white_space = false;
$new_folder = 'new_encrypt/';
$encryption_code = 'foobar';
$path_array = array();
$user_defined_functions = array('name' => array(), 'encode' => array());
$user_defined_variables = array('name' => array(), 'encode' => array());
$user_defined_constants = array('name' => array(), 'encode' => array());
if(! file_exists($new_folder)) {
mkdir($new_folder, 0700);
}
while($rows = mysql_fetch_array($query)){
$name = $rows['NAME'];
$location = $rows['LOCATION'];
$path = $location . $name;
$path_array['path'][] = $path;
$path_array['name'][] = $name;
$path_array['location'][] = $location;
$lines = file($path);
$data = implode("", $lines);
preg_match_all("#<\?php*((?!\?>).)*\?>#Us", $data, $matches);
print_r($matches);
#foreach ($lines as $line_num => $line) {
# if(preg_match("#function\s+([^\s\(]+)\s?\([^\)]+\)#is", $line, $match)){
# if(! in_array($match[1], $user_defined_functions['name'])) {
# $user_defined_functions['name'][] = $match[1];
# $user_defined_functions['encode'][] = "v" . md5($match[1].$encryption_code);
# }
# }
# if(preg_match('#\$([a-zA-Z_][a-zA-Z0-9_]*)#is', $line, $match)){
# if(! in_array($match[1], $user_defined_variables['name'])) {
# $user_defined_variables['name'][] = $match[1];
# $user_defined_variables['encode'][] = "v" . md5($match[1].$encryption_code);
# }
# }
# if(preg_match('#define\s?\(\s?[\'\"]([^\s\"\']+)#is', $line, $match)){
# if(! in_array($match[1], $user_defined_constants['name'])) {
# $user_defined_constants['name'][] = $match[1];
# $user_defined_constants['encode'][] = "v" . md5($match[1].$encryption_code);
# }
# }
#}
}
#foreach($path_array['location'] as $key => $folder) {
# if(! file_exists($new_folder . $folder)) {
# mkdir($new_folder . ltrim($folder, "./"), 0700);
# }
# $lines = file($path_array['path'][$key]);
# $data = implode("", $lines);
# foreach($user_defined_functions['name'] as $key2 => $f_name) {
# $data = str_replace($f_name, $user_defined_functions['encode'][$key2], $data);
# }
# foreach($user_defined_variables['name'] as $key2 => $f_name) {
# $data = preg_replace('#\$' . $f_name . "(\;|\s|\,|\[|-|\))#", '$' . $user_defined_variables['encode'][$key2] . "$1", $data);
# }
# foreach($user_defined_constants['name'] as $key2 => $f_name) {
# $data = preg_replace("#([\"\']\s?\.\s?)" . $f_name . "#", "$1" . $user_defined_constants['encode'][$key2], $data);
# }
#
# $fp = fopen($new_folder . ltrim($folder, "./") . $path_array['name'][$key], 'w');
# fwrite($fp, $data);
# fclose($fp);
#
#}
?>
어서 오세요. 이 일을 올바르게 수행하는 방법을 알기에 충분히 오랫동안 탑승 해 왔습니다. 일치하는 문자열의 예를 게시하십시오 (일치하지 않는 이유를 알 수있는 다른 방법은 무엇입니까?). 코드에는 일치 항목 만 포함되며 앞뒤 5 줄이 포함될 수 있습니다. –
당신이 그것을 얻지 못하면 "아무것도 아닌"Array()를 반환합니다 –
@ 필 식에 오류가있을 때 정상적인 동작이라고 생각합니다. 오류보고 기능이 켜져 있습니까? –