Code Duplication    Length = 20-20 lines in 2 locations

main/wiki/wiki.inc.php 2 locations

@@ 3048-3067 (lines=20) @@
3045
                WHERE c_id = $course_id AND ".$groupfilter.$condition_session."";
3046
        $allpages = Database::query($sql);
3047
3048
        while ($row = Database::fetch_array($allpages)) {
3049
            $total_words = $total_words + self::word_count($row['content']);
3050
            $total_links = $total_links + substr_count($row['content'], "href=");
3051
            $total_links_anchors = $total_links_anchors + substr_count($row['content'], 'href="#');
3052
            $total_links_mail = $total_links_mail + substr_count($row['content'], 'href="mailto');
3053
            $total_links_ftp = $total_links_ftp + substr_count($row['content'], 'href="ftp');
3054
            $total_links_irc = $total_links_irc + substr_count($row['content'], 'href="irc');
3055
            $total_links_news = $total_links_news + substr_count($row['content'], 'href="news');
3056
            $total_wlinks = $total_wlinks + substr_count($row['content'], "[[");
3057
            $total_images = $total_images + substr_count($row['content'], "<img");
3058
            $clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
3059
            $total_flash = $total_flash + substr_count($clean_total_flash, '.swf"');
3060
            //.swf" end quotes prevent insert swf through flvplayer (is not counted)
3061
            $total_mp3 = $total_mp3 + substr_count($row['content'], ".mp3");
3062
            $total_flv_p = $total_flv_p + substr_count($row['content'], ".flv");
3063
            $total_flv = $total_flv_p / 5;
3064
            $total_youtube = $total_youtube + substr_count($row['content'], "http://www.youtube.com");
3065
            $total_multimedia = $total_multimedia + substr_count($row['content'], "video/x-msvideo");
3066
            $total_tables = $total_tables + substr_count($row['content'], "<table");
3067
        }
3068
3069
        // Check only last version of all pages (current page)
3070
        $sql = ' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
@@ 3115-3134 (lines=20) @@
3112
                )';
3113
        $allpages = Database::query($sql);
3114
3115
        while ($row = Database::fetch_array($allpages)) {
3116
            $total_words_lv = $total_words_lv + self::word_count($row['content']);
3117
            $total_links_lv = $total_links_lv + substr_count($row['content'], "href=");
3118
            $total_links_anchors_lv = $total_links_anchors_lv + substr_count($row['content'], 'href="#');
3119
            $total_links_mail_lv = $total_links_mail_lv + substr_count($row['content'], 'href="mailto');
3120
            $total_links_ftp_lv = $total_links_ftp_lv + substr_count($row['content'], 'href="ftp');
3121
            $total_links_irc_lv = $total_links_irc_lv + substr_count($row['content'], 'href="irc');
3122
            $total_links_news_lv = $total_links_news_lv + substr_count($row['content'], 'href="news');
3123
            $total_wlinks_lv = $total_wlinks_lv + substr_count($row['content'], "[[");
3124
            $total_images_lv = $total_images_lv + substr_count($row['content'], "<img");
3125
            $clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
3126
            $total_flash_lv = $total_flash_lv + substr_count($clean_total_flash_lv, '.swf"');
3127
            //.swf" end quotes prevent insert swf through flvplayer (is not counted)
3128
            $total_mp3_lv = $total_mp3_lv + substr_count($row['content'], ".mp3");
3129
            $total_flv_p_lv = $total_flv_p_lv + substr_count($row['content'], ".flv");
3130
            $total_flv_lv = $total_flv_p_lv / 5;
3131
            $total_youtube_lv = $total_youtube_lv + substr_count($row['content'], "http://www.youtube.com");
3132
            $total_multimedia_lv = $total_multimedia_lv + substr_count($row['content'], "video/x-msvideo");
3133
            $total_tables_lv = $total_tables_lv + substr_count($row['content'], "<table");
3134
        }
3135
3136
        //Total pages edited at this time
3137
        $total_editing_now = 0;