File tree Expand file tree Collapse file tree 2 files changed +41
-9
lines changed Expand file tree Collapse file tree 2 files changed +41
-9
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
- /**
3
- * Created by PhpStorm.
4
- * User: Emmy
5
- * Date: 11/30/2016
6
- * Time: 2:28 AM
7
- */
8
-
9
2
return [
10
3
4
+ /*
5
+ |--------------------------------------------------------------------------
6
+ | File path
7
+ |--------------------------------------------------------------------------
8
+ |
9
+ | File name and path to save the indexed words
10
+ |
11
+ |
12
+ |
13
+ */
11
14
'file_path ' => public_path ("restricted-usernames.txt " ),
12
15
16
+ /*
17
+ |--------------------------------------------------------------------------
18
+ | Index level
19
+ |--------------------------------------------------------------------------
20
+ |
21
+ | How deep do u want us to crawl your routes?
22
+ | Ex www.mywebsite.com/segment1/segmen2/segment3
23
+ | setting this value to '2', will allow indexing of segment1 and segment2
24
+ | and exclude segment3
25
+ |
26
+ */
13
27
'index_level ' => 2 ,
14
28
29
+ /*
30
+ |--------------------------------------------------------------------------
31
+ | Should merge
32
+ |--------------------------------------------------------------------------
33
+ |
34
+ | Do you want to merge the new result with the old one?
35
+ |
36
+ |
37
+ */
38
+ 'merge ' => true ,
39
+
15
40
];
Original file line number Diff line number Diff line change @@ -95,16 +95,23 @@ public function crawl()
95
95
}
96
96
}
97
97
98
- $ data = collect ($ data )->unique ()-> sort () ;
98
+ $ data = collect ($ data )->unique ();
99
99
$ this ->store ($ data );
100
100
101
101
return $ data ->count ();
102
102
}
103
103
104
104
function store ($ routes ){
105
105
$ fileName = $ this ->fileName ;
106
+ if (config ('restricted.merge ' ) && file_exists ($ fileName )){
107
+ $ old = collect (explode ("\r\n" , file_get_contents ($ fileName )))
108
+ ->map (function ($ value ){
109
+ return preg_replace ("/\s/ " , '' , $ value );
110
+ })->all ();
111
+ $ routes ->merge ($ old );
112
+ }
106
113
107
- $ input = $ routes ->implode ("\r\n" );
114
+ $ input = $ routes ->unique ()-> sort ()-> implode ("\r\n" );
108
115
$ file = fopen ($ fileName , 'w+ ' );
109
116
fwrite ($ file , $ input );
110
117
fclose ($ file );
You can’t perform that action at this time.
0 commit comments