21 | | echo "<ul> |
22 | | <li><a href='https://plugins.trac.wordpress.org/log/{$post->post_name}/'>" . __( 'Development Log', 'wporg-plugins' ) . "</a></li> |
23 | | <li><a href='https://plugins.svn.wordpress.org/{$post->post_name}/'>" . __( 'Subversion Repository', 'wporg-plugins' ) . "</a></li> |
24 | | <li><a href='https://plugins.trac.wordpress.org/browser/{$post->post_name}/'>" . __( 'Browse in Trac', 'wporg-plugins' ) . '</a></li> |
25 | | </ul>'; |
| 47 | $restricted_slugs = array ( |
| 48 | // High-value plugin genres due to their popularity, often abused by spammers |
| 49 | 'gallery', 'lightbox', 'sitemap', 'bookmark', 'social', 'cookie', 'slide', 'seo', |
| 50 | // Plugins we generally don't allow |
| 51 | 'autoblog', 'auto-blog', 'booking', 'plugin', 'spinning', 'framework', |
| 52 | ); |
| 53 | |
| 54 | // String length checks |
| 55 | if ( strlen($slug) < '5' ) array_push( $flagged['med'], __( 'slug is less than 5 characters', 'wporg-plugins' ) ); |
| 56 | if ( strlen($slug) > '50' ) array_push( $flagged['med'], __( 'slug is more than 50 characters', 'wporg-plugins' ) ); |
| 57 | |
| 58 | // Check if any term in the restricted/reserved is in the plugin slug |
| 59 | $slug_string = str_replace('-', ' ', $slug ); |
| 60 | $slug_restricted = $slug_reserved = array() ; |
| 61 | foreach ( $restricted_slugs as $badslug ) { |
| 62 | if ( stristr($slug_string, $badslug ) !== FALSE ) array_push( $slug_restricted, $badslug ); |
| 63 | } |
| 64 | foreach ( $reserved_slugs as $badslug ) { |
| 65 | if ( stristr($slug_string, $badslug ) !== FALSE ) array_push( $slug_reserved , $badslug ); |
| 66 | } |
| 67 | if ( !empty( $slug_restricted ) ) |
| 68 | array_push( $flagged['med'], __( 'plugin slug contains restricted term(s): ', 'wporg-plugins' ) . implode( ', ', $slug_restricted ) ); |
| 69 | if ( !empty( $slug_reserved ) ) |
| 70 | array_push( $flagged['high'], __( 'plugin slug contains reserved term(s): ', 'wporg-plugins' ) . implode( ', ', $slug_reserved ) ); |
| 71 | |
| 72 | // Check slug usage |
| 73 | $plugin_api_usage = '1000'; // this is a placeholder until we figure out how to do this. |
| 74 | if ( $plugin_api_usage >= '5000' ) { |
| 75 | array_push( $flagged['high'], __( 'slug used by more than 5000 users', 'wporg-plugins' ) ); |
| 76 | } elseif ( $plugin_api_usage >= '1000' ) { |
| 77 | array_push( $flagged['med'], __( 'slug used by 1000-5000 users', 'wporg-plugins' ) ); |
| 78 | } elseif ( $plugin_api_usage >= '500' ) { |
| 79 | array_push( $flagged['low'], __( 'slug used by 500-1000 users', 'wporg-plugins' ) ); |
| 80 | } |
| 82 | // User account was registered less than 2 weeks ago (but longer than 3 days) (user is still fairly new) |
| 83 | $twoweeksago = time() - (2 * 7 * 24 * 60 * 60); |
| 84 | $threedaysago = time() - (3 * 1 * 24 * 60 * 60); |
| 85 | if ( strtotime($author->user_registered) > $twoweeksago && strtotime($author->user_registered) < $threedaysago ) array_push( $flagged['low'], __( 'account registered less than 2 weeks ago', 'wporg-plugins' ) ); |
| 86 | if ( strtotime($author->user_registered) > $threedaysago ) array_push( $flagged['low'], __( 'account registered less than 3 days ago', 'wporg-plugins' ) ); |
| 87 | |
| 88 | // Username ends in numbers |
| 89 | if ( is_numeric(substr($author->user_login, -1, 1) ) ) array_push( $flagged['low'], __( 'username ends in numbers', 'wporg-plugins' ) ); |
| 90 | |
| 91 | // User has no URL |
| 92 | if ( empty( $author->user_url ) ) array_push( $flagged['low'], __( 'account has no URL', 'wporg-plugins' ) ); |
| 93 | |
| 94 | // URL matches the weird list |
| 95 | $weird_urls = array ( |
| 96 | 'blogger', 'blogspot', 'example.com', 'weebly', 'squarespace', 'medium.com', 'yahoo.com', |
| 97 | 'mail.com', 'example.org', |
| 98 | ); |
| 99 | foreach ( $weird_urls as $url ) { |
| 100 | if ( stripos( $author->user_url , $url ) !== false ) |
| 101 | array_push( $flagged['med'], __( 'account URL contains ', 'wporg-plugins' ) . $url ); |
| 102 | if ( stripos( $author->user_email , $url ) !== false ) |
| 103 | array_push( $flagged['med'], __( 'account email contains ', 'wporg-plugins' ) . $url ); |
| 104 | } |
| 105 | |
| 106 | // Reserved slugs are also often abused domain names (trademark law sucks) |
| 107 | foreach ( $reserved_slugs as $url ) { |
| 108 | if ( stripos( $author->user_url , $url ) !== false ) |
| 109 | array_push( $flagged['high'], __( 'account URL contains ', 'wporg-plugins' ) . $url ); |
| 110 | if ( stripos( $author->user_email , $url ) !== false ) |
| 111 | array_push( $flagged['med'], __( 'account email contains ', 'wporg-plugins' ) . $url ); |
| 112 | } |
| 113 | |
| 114 | // User Behavior |
| 115 | // If FORUM ROLE is blocked |
| 116 | if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) { |
| 117 | $user = new \WP_User( $post->post_author, '', WPORG_SUPPORT_FORUMS_BLOGID ); |
| 118 | if ( ! empty( $user->allcaps['bbp_blocked'] ) ) |
| 119 | array_push( $flagged['high'], __( 'user is blocked', 'wporg-plugins' ) ); |
| 120 | } |
| 121 | |
| 122 | // No plugins |
| 123 | if ( empty( $author_commit ) && empty( $author_plugins ) ) |
| 124 | array_push( $flagged['low'], __( 'user has no plugins', 'wporg-plugins' ) ); |
| 125 | |
| 126 | // Echo flag results (everyone pretty much has at least one) |
| 127 | echo "<ul class=\"plugin-flagged\">"; |
| 128 | $noflag = 0; |
| 129 | foreach ( $flagged as $flag => $reasons ) { |
| 130 | if (count($reasons) > '0') { |
| 131 | $allreasons = array(); |
| 132 | echo "<li class=\"plugin-flagged-".$flag."\"><strong>".strtoupper($flag)." (".count($reasons)."):</strong> "; |
| 133 | foreach( $reasons as $reason) { |
| 134 | $allreasons[] = $reason; |
| 135 | } |
| 136 | echo implode( '; ', $allreasons ) . "</li>"; |
| 137 | } else { |
| 138 | $noflag++; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if ($noflag == '3' ) { |
| 143 | ?><li><?php _e( 'Nothing flagged! You found Matt!', 'wporg-plugins' ); ?></li><?php |
| 144 | } |
| 145 | |
| 146 | echo "</ul>"; |
| 147 | |
| 148 | } else { |
| 149 | echo "<ul> |
| 150 | <li><a href='https://plugins.trac.wordpress.org/log/{$post->post_name}/'>" . __( 'Development Log', 'wporg-plugins' ) . "</a></li> |
| 151 | <li><a href='https://plugins.svn.wordpress.org/{$post->post_name}/'>" . __( 'Subversion Repository', 'wporg-plugins' ) . "</a></li> |
| 152 | <li><a href='https://plugins.trac.wordpress.org/browser/{$post->post_name}/'>" . __( 'Browse in Trac', 'wporg-plugins' ) . '</a></li> |
| 153 | </ul>'; |
| 154 | } |
| 155 | |