-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec.php
82 lines (79 loc) · 2.01 KB
/
exec.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
* 这里是底层和php连接的中间件
*/
//获得目标目录所有文件
function get_all_result() {
include("config.php");
$dir = $dcopyfind_file_dir;
$array = array();
$directory = "files\\";
$result = array();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$array[] = $file;
//echo "$file\n";
}
}
closedir($handle);
}
}
//递归对比
$i = 0;
$j = 0;
$length = count($array);
for($i = 0; $i < $length; $i++) {
for($j = $i+1; $j < $length; $j++) {
$sp = exec($sim_dir." -e -p -s -r100 files\\".$array[$i].' files\\'.$array[$j], $out, $info);
//这里是标准out输出项
//print_r($out);//print '\n\n';
$result[] = $out;
}
}
return $result;
}
function get_comparison_by_file($filename) {
require("config.php");
$result = array();
$array = get_dir_files($dcopyfind);
for($i = 0; $i < count($array); $i++) {
if($filename != $array[$i]) {
$result[] = get_info_by_two_file($filename, $array[$i]);
}
}
return $result;
}
function get_dir_files($dir) {
//$dir = 'd:\wamp\www\TestAlpagrism\files';
$array = array();
$directory = "files\\";
$result = array();
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$file = iconv("GB2312", "UTF-8", $file);
$array[] = $file;
//echo "$file\n";
}
}
closedir($handle);
}
}
return $array;
}
/**
* 获得两个文件的测试信息
* @param unknown_type $filenameSource
* @param unknown_type $filenameDestination
* @return unknown
*/
function get_info_by_two_file($filenameSource, $filenameDestination) {
require("config.php");
$prompt = exec($sim_dir." -e -p -s files\\".$filenameSource.' files\\'.$filenameDestination, $out, $info);
return $out;
}
//system("d:\wamp\www\TestAlpagrism\sim_text.exe -e -p -s -r100 files/*", $info);
?>