@@ -35,15 +35,15 @@ |
||
35 | 35 | |
36 | 36 | public function trackUser(string $user): void |
37 | 37 | { |
38 | - echo "**** TRACK " . $user . "*****\n"; |
|
38 | + echo "**** TRACK ".$user."*****\n"; |
|
39 | 39 | |
40 | 40 | $titles = $this->getLastEditsbyUser($user); |
41 | 41 | |
42 | 42 | // filter titles already in edited.txt |
43 | 43 | $edited = file(__DIR__.'/resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
44 | 44 | $filtered = array_diff($titles, $edited); |
45 | - $list = new PageList( $filtered ); |
|
46 | - echo ">" . $list->count() . " dans liste\n"; |
|
45 | + $list = new PageList($filtered); |
|
46 | + echo ">".$list->count()." dans liste\n"; |
|
47 | 47 | |
48 | 48 | $this->consumeList($list); |
49 | 49 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | // idn_to_ascii('teßt.com',IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46) |
61 | 61 | // checkdnsrr($string, "A") // check DNS record |
62 | 62 | if (!self::isHttpURL($url)) { |
63 | - throw new DomainException('URL not compatible : ' . $url); |
|
63 | + throw new DomainException('URL not compatible : '.$url); |
|
64 | 64 | } |
65 | 65 | $response = $this->client->get($url); |
66 | 66 | |
67 | 67 | if (200 !== $response->getStatusCode()) { |
68 | - echo 'HTTP error ' . $response->getStatusCode(); |
|
69 | - $this->log->error('HTTP error ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
68 | + echo 'HTTP error '.$response->getStatusCode(); |
|
69 | + $this->log->error('HTTP error '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
70 | 70 | |
71 | 71 | return null; |
72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public static function isHttpURL(string $url): bool |
84 | 84 | { |
85 | - return (bool)preg_match('#^https?://[^ ]+$#i', $url); |
|
85 | + return (bool) preg_match('#^https?://[^ ]+$#i', $url); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $charset = $this->extractCharset($html) ?? 'WINDOWS-1252'; |
105 | 105 | |
106 | 106 | if (empty($charset)) { |
107 | - throw new DomainException('normalized html error and no charset found : ' . $url); |
|
107 | + throw new DomainException('normalized html error and no charset found : '.$url); |
|
108 | 108 | } |
109 | 109 | try { |
110 | 110 | $html2 = iconv($charset, 'UTF-8//TRANSLIT', $html); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return ''; |
114 | 114 | } |
115 | 115 | } catch (Throwable $e) { |
116 | - throw new DomainException("error converting : $charset to UTF-8 on " . $url, $e->getCode(), $e); |
|
116 | + throw new DomainException("error converting : $charset to UTF-8 on ".$url, $e->getCode(), $e); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $html2; |
@@ -37,7 +37,7 @@ |
||
37 | 37 | // Attention : pas de post-processing (sanitize title, etc.) |
38 | 38 | $result = $trans->process($url, $summary); |
39 | 39 | } catch (Exception $e) { |
40 | - $result = "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine(); |
|
40 | + $result = "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine(); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | echo $result."\n"; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ) |
70 | 70 | { |
71 | 71 | if (!ExternHttpClient::isHttpURL($url)) { |
72 | - throw new Exception('string is not an URL ' . $url); |
|
72 | + throw new Exception('string is not an URL '.$url); |
|
73 | 73 | } |
74 | 74 | $this->url = $url; |
75 | 75 | $this->html = $html; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | { |
190 | 190 | try { |
191 | 191 | if (!ExternHttpClient::isHttpURL($this->url)) { |
192 | - throw new Exception('string is not an URL ' . $this->url); |
|
192 | + throw new Exception('string is not an URL '.$this->url); |
|
193 | 193 | } |
194 | 194 | if (!$this->domainParser instanceof InternetDomainParserInterface) { |
195 | 195 | $this->log->notice('InternetDomainParser is not set'); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | return $this->domainParser->getRegistrableDomainFromURL($this->url); |
201 | 201 | } catch (Exception $e) { |
202 | 202 | if ($this->log !== null) { |
203 | - $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL ' . $this->url); |
|
203 | + $this->log->warning('InternetDomainParser->getRegistrableDomainFromURL NULL '.$this->url); |
|
204 | 204 | } |
205 | 205 | throw new Exception('InternetDomainParser->getRegistrableDomainFromURL NULL', $e->getCode(), $e); |
206 | 206 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | /** |
24 | 24 | * @throws Exception |
25 | 25 | */ |
26 | - public static function fromURL($url, ExternHttpClientInterface $httpClient,LoggerInterface $logger = null): ExternPage |
|
26 | + public static function fromURL($url, ExternHttpClientInterface $httpClient, LoggerInterface $logger = null): ExternPage |
|
27 | 27 | { |
28 | 28 | if (!ExternHttpClient::isHttpURL($url)) { |
29 | 29 | throw new Exception('string is not an URL '.$url); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | class ExternHttpErrorLogic |
16 | 16 | { |
17 | - public const LOG_REQUEST_ERROR = __DIR__ . '/../../Application/resources/external_request_error.log'; |
|
17 | + public const LOG_REQUEST_ERROR = __DIR__.'/../../Application/resources/external_request_error.log'; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var LoggerInterface |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | } |
47 | 47 | return $url; |
48 | 48 | } elseif (preg_match('#401 Unauthorized#i', $errorMessage)) { |
49 | - $this->log->notice('401 Unauthorized : skip ' . $url); |
|
49 | + $this->log->notice('401 Unauthorized : skip '.$url); |
|
50 | 50 | |
51 | 51 | return $url; |
52 | 52 | } else { |
53 | 53 | // autre : ne pas générer de {lien brisé}, car peut-être 404 temporaire |
54 | - $this->log->warning('erreur sur extractWebData ' . $errorMessage); |
|
54 | + $this->log->warning('erreur sur extractWebData '.$errorMessage); |
|
55 | 55 | |
56 | 56 | //file_put_contents(self::LOG_REQUEST_ERROR, $this->domain."\n", FILE_APPEND); |
57 | 57 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | $text = str_replace(['https://', 'http://', 'www.'], '', $url); |
80 | 80 | if (strlen($text) > 30) { |
81 | - $text = substr($text, 0, 30) . '…'; |
|
81 | + $text = substr($text, 0, 30).'…'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | return $text; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function log403(string $url): void |
88 | 88 | { |
89 | - $this->log->warning('403 Forbidden : ' . $url); |
|
90 | - file_put_contents(self::LOG_REQUEST_ERROR, '403 Forbidden : ' . $url . "\n", FILE_APPEND); |
|
89 | + $this->log->warning('403 Forbidden : '.$url); |
|
90 | + file_put_contents(self::LOG_REQUEST_ERROR, '403 Forbidden : '.$url."\n", FILE_APPEND); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | use SummaryExternTrait, RobotsRulesTrait, PublisherLogicTrait; |
32 | 32 | |
33 | 33 | public const HTTP_REQUEST_LOOP_DELAY = 10; |
34 | - public const SKIP_DOMAIN_FILENAME = __DIR__ . '/../resources/config_skip_domain.txt'; |
|
34 | + public const SKIP_DOMAIN_FILENAME = __DIR__.'/../resources/config_skip_domain.txt'; |
|
35 | 35 | public const REPLACE_404 = true; |
36 | - public const CONFIG_PRESSE = __DIR__ . '/../resources/config_presse.yaml'; |
|
37 | - public const CONFIG_NEWSPAPER_JSON = __DIR__ . '/../resources/data_newspapers.json'; |
|
38 | - public const CONFIG_SCIENTIFIC_JSON = __DIR__ . '/../resources/data_scientific_domain.json'; |
|
39 | - public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__ . '/../resources/data_scientific_wiki.json'; |
|
36 | + public const CONFIG_PRESSE = __DIR__.'/../resources/config_presse.yaml'; |
|
37 | + public const CONFIG_NEWSPAPER_JSON = __DIR__.'/../resources/data_newspapers.json'; |
|
38 | + public const CONFIG_SCIENTIFIC_JSON = __DIR__.'/../resources/data_scientific_domain.json'; |
|
39 | + public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__.'/../resources/data_scientific_wiki.json'; |
|
40 | 40 | |
41 | 41 | public $skipSiteBlacklisted = true; |
42 | 42 | public $skipRobotNoIndex = true; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | protected function isSiteBlackListed(): bool |
161 | 161 | { |
162 | 162 | if ($this->skipSiteBlacklisted && in_array($this->registrableDomain, $this->skip_domain)) { |
163 | - $this->log->notice("Skip web site " . $this->registrableDomain); |
|
163 | + $this->log->notice("Skip web site ".$this->registrableDomain); |
|
164 | 164 | return true; |
165 | 165 | } |
166 | 166 | return false; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->config[$domain] = is_array($this->config[$domain]) ? $this->config[$domain] : []; |
179 | 179 | |
180 | 180 | if ($this->config[$domain] === 'deactivated' || isset($this->config[$domain]['deactivated'])) { |
181 | - $this->log->info("Domain " . $domain . " disabled\n"); |
|
181 | + $this->log->info("Domain ".$domain." disabled\n"); |
|
182 | 182 | |
183 | 183 | return false; |
184 | 184 | } |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | protected function logDebugConfigWebDomain(string $domain): void |
193 | 193 | { |
194 | 194 | if (!isset($this->config[$domain])) { |
195 | - $this->log->debug("Domain " . $domain . " non configuré"); |
|
195 | + $this->log->debug("Domain ".$domain." non configuré"); |
|
196 | 196 | } else { |
197 | - $this->log->debug("Domain " . $domain . " configuré"); |
|
197 | + $this->log->debug("Domain ".$domain." configuré"); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | if ($pageData === [] |
220 | 220 | || (empty($pageData['JSON-LD']) && empty($pageData['meta'])) |
221 | 221 | ) { |
222 | - $this->log->notice('No metadata : ' . $url); |
|
222 | + $this->log->notice('No metadata : '.$url); |
|
223 | 223 | |
224 | 224 | return true; |
225 | 225 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | protected function emptyMapData(array $mapData, string $url): bool |
235 | 235 | { |
236 | 236 | if ($mapData === [] || empty($mapData['url']) || empty($mapData['titre'])) { |
237 | - $this->log->info('Mapping incomplet : ' . $url); |
|
237 | + $this->log->info('Mapping incomplet : '.$url); |
|
238 | 238 | |
239 | 239 | return true; |
240 | 240 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | $template = WikiTemplateFactory::create($templateName); |
293 | 293 | $template->userSeparator = " |"; |
294 | - $this->summary->memo['count ' . $templateName] = 1 + ($this->summary->memo['count ' . $templateName] ?? 0); |
|
294 | + $this->summary->memo['count '.$templateName] = 1 + ($this->summary->memo['count '.$templateName] ?? 0); |
|
295 | 295 | |
296 | 296 | return $template; |
297 | 297 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $templateOptimized = $optimizer->getOptiTemplate(); |
350 | 350 | |
351 | 351 | $serialized = $templateOptimized->serialize(true); |
352 | - $this->log->info('Serialized 444: ' . $serialized . "\n"); |
|
352 | + $this->log->info('Serialized 444: '.$serialized."\n"); |
|
353 | 353 | return $serialized; |
354 | 354 | } |
355 | 355 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | || stripos($robots, 'none') !== false |
28 | 28 | ) |
29 | 29 | ) { |
30 | - $this->log->notice('robots NOINDEX : ' . $url); |
|
30 | + $this->log->notice('robots NOINDEX : '.$url); |
|
31 | 31 | |
32 | 32 | return !$this->isNoIndexDomainWhitelisted($pageData['meta']['prettyDomainName']); |
33 | 33 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | protected function isNoIndexDomainWhitelisted(?string $prettyDomain): bool |
39 | 39 | { |
40 | 40 | if (in_array($prettyDomain ?? '', $this->noindexWhitelist)) { |
41 | - $this->log->notice('ROBOT_NOINDEX_WHITELIST ' . $prettyDomain); |
|
41 | + $this->log->notice('ROBOT_NOINDEX_WHITELIST '.$prettyDomain); |
|
42 | 42 | |
43 | 43 | return true; |
44 | 44 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->url = $url; |
45 | 45 | $this->registrableDomain = null; |
46 | 46 | if (!ExternHttpClient::isHttpURL($url)) { |
47 | - $this->log->debug('Skip : not a valid URL : ' . $url); |
|
47 | + $this->log->debug('Skip : not a valid URL : '.$url); |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return false; |
53 | 53 | } |
54 | 54 | if (!ExternHttpClient::isHttpURL($url)) { |
55 | - throw new Exception('string is not an URL ' . $url); |
|
55 | + throw new Exception('string is not an URL '.$url); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $this->findRegistrableDomain(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | try { |
75 | 75 | $this->registrableDomain = (new InternetDomainParser())->getRegistrableDomainFromURL($this->url); |
76 | 76 | } catch (Exception $e) { |
77 | - $this->log->warning('Skip : not a valid URL : ' . $this->url); |
|
77 | + $this->log->warning('Skip : not a valid URL : '.$this->url); |
|
78 | 78 | return null; |
79 | 79 | } |
80 | 80 | return $this->registrableDomain; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function hasForbiddenFilenameExtension(): bool |
93 | 93 | { |
94 | - return (bool)preg_match( |
|
94 | + return (bool) preg_match( |
|
95 | 95 | '#\.(pdf|jpg|jpeg|gif|png|xls|xlsx|xlr|xml|xlt|txt|csv|js|docx|exe|gz|zip|ini|movie|mp3|mp4|ogg|raw|rss|tar|tgz|wma)$#i', |
96 | 96 | $this->url |
97 | 97 | ); |