浏览代码

Add more countermeasures

Jordi Boggiano 6 年之前
父节点
当前提交
dcfbb6b3da

+ 1 - 1
src/Packagist/WebBundle/Entity/Package.php

@@ -287,7 +287,7 @@ class Package
                 return;
                 return;
             }
             }
 
 
-            if (preg_match('{(free.*watch|watch.*free|(stream|online).*anschauver.*pelicula|ver.*completa|pelicula.*completa|film.*(complet|entier)|(voir|regarder|guarda|assistir).*(film|complet)|full.*movie|(free|full|gratuit).*stream|movie.*free|free.*(movie|hack)|watch.*movie|watch.*full|generate.*resource|generate.*unlimited|hack.*coin|coin.*(hack|generat)|vbucks|hack.*cheat|hack.*generat|generat.*hack|hack.*unlimited|cheat.*(unlimited|generat)|(mod|cheat|apk).*(hack|cheat)|putlocker|generat.*free|coins.*generat|(download|telecharg).*album|album.*(download|telecharg)|album.*(free|gratuit)|generat.*coins|unlimited.*coins|(fortnite|pubg|apex.*legend|t[1i]k.*t[o0]k).*(free|gratuit|generat|unlimited|coins|mobile|hack|follow))}i', str_replace(array('.', '-'), '', $information['name']))) {
+            if (preg_match('{(free.*watch|watch.*free|(stream|online).*anschauver.*pelicula|ver.*completa|pelicula.*complet|season.*episode.*online|film.*(complet|entier)|(voir|regarder|guarda|assistir).*(film|complet)|full.*movie|online.*(free|tv|full.*hd)|(free|full|gratuit).*stream|movie.*free|free.*(movie|hack)|watch.*movie|watch.*full|generate.*resource|generate.*unlimited|hack.*coin|coin.*(hack|generat)|vbucks|hack.*cheat|hack.*generat|generat.*hack|hack.*unlimited|cheat.*(unlimited|generat)|(mod|cheat|apk).*(hack|cheat)|putlocker|generat.*free|coins.*generat|(download|telecharg).*album|album.*(download|telecharg)|album.*(free|gratuit)|generat.*coins|unlimited.*coins|(fortnite|pubg|apex.*legend|t[1i]k.*t[o0]k).*(free|gratuit|generat|unlimited|coins|mobile|hack|follow))}i', str_replace(array('.', '-'), '', $information['name']))) {
                 $context->buildViolation('The package name '.htmlentities($information['name'], ENT_COMPAT, 'utf-8').' is blocked, if you think this is a mistake please get in touch with us.')
                 $context->buildViolation('The package name '.htmlentities($information['name'], ENT_COMPAT, 'utf-8').' is blocked, if you think this is a mistake please get in touch with us.')
                     ->atPath($property)
                     ->atPath($property)
                     ->addViolation()
                     ->addViolation()

+ 1 - 0
src/Packagist/WebBundle/Model/DownloadManager.php

@@ -95,6 +95,7 @@ class DownloadManager
             'total' => $total,
             'total' => $total,
             'monthly' => $monthly,
             'monthly' => $monthly,
             'daily' => round(($redisData[0] ?? $dlData[$todayDate] ?? 0) + (($redisData[1] ?? $dlData[$yesterdayDate] ?? 0) * $dayRatio)),
             'daily' => round(($redisData[0] ?? $dlData[$todayDate] ?? 0) + (($redisData[1] ?? $dlData[$yesterdayDate] ?? 0) * $dayRatio)),
+            'views' => $this->redis->incr('views:'.$package),
         ];
         ];
     }
     }
 
 

+ 9 - 1
src/Packagist/WebBundle/Resources/views/package/view_package.html.twig

@@ -2,6 +2,11 @@
 
 
 {% set showSearchDesc = 'hide' %}
 {% set showSearchDesc = 'hide' %}
 
 
+{% set allowIndex = true %}
+{% if downloads.total is defined and downloads.views >= 100 and downloads.total <= 10 %}
+    {% set allowIndex = false %}
+{% endif %}
+
 {% block title %}{{ package.name }} - {{ parent() }}{% endblock %}
 {% block title %}{{ package.name }} - {{ parent() }}{% endblock %}
 
 
 {% block head_feeds %}
 {% block head_feeds %}
@@ -16,6 +21,9 @@
 
 
 {% block head_additions %}
 {% block head_additions %}
     <link rel="stylesheet" href="{{ asset('css/github/markdown.css') }}">
     <link rel="stylesheet" href="{{ asset('css/github/markdown.css') }}">
+    {% if not allowIndex %}
+        <meta name="robots" content="noindex, nofollow">
+    {% endif %}
 {% endblock %}
 {% endblock %}
 
 
 {% block scripts %}
 {% block scripts %}
@@ -284,7 +292,7 @@
             {% endif %}
             {% endif %}
         </div>
         </div>
 
 
-        {% if package.readme != null %}
+        {% if package.readme != null and allowIndex %}
             <hr class="clearfix">
             <hr class="clearfix">
             <div class="readme markdown-body">
             <div class="readme markdown-body">
                 <h1>README</h1>
                 <h1>README</h1>