Code Duplication    Length = 30-90 lines in 2 locations

main/newscorm/learnpathItem.class.php 1 location

@@ 1109-1198 (lines=90) @@
1106
                                            continue;
1107
                                        } // Avoid code - that should help.
1108
1109
                                        if ($attr == 'value') {
1110
                                            if (strpos($source, 'mp3file')) {
1111
                                                $files_list[] = array(
1112
                                                    substr(
1113
                                                        $source,
1114
                                                        0,
1115
                                                        strpos(
1116
                                                            $source,
1117
                                                            '.swf'
1118
                                                        ) + 4
1119
                                                    ),
1120
                                                    'local',
1121
                                                    'abs'
1122
                                                );
1123
                                                $mp3file = substr(
1124
                                                    $source,
1125
                                                    strpos(
1126
                                                        $source,
1127
                                                        'mp3file='
1128
                                                    ) + 8
1129
                                                );
1130
                                                if (substr(
1131
                                                        $mp3file,
1132
                                                        0,
1133
                                                        1
1134
                                                    ) == '/'
1135
                                                ) {
1136
                                                    $files_list[] = array(
1137
                                                        $mp3file,
1138
                                                        'local',
1139
                                                        'abs'
1140
                                                    );
1141
                                                } else {
1142
                                                    $files_list[] = array(
1143
                                                        $mp3file,
1144
                                                        'local',
1145
                                                        'rel'
1146
                                                    );
1147
                                                }
1148
                                            } elseif (strpos(
1149
                                                    $source,
1150
                                                    'flv='
1151
                                                ) === 0
1152
                                            ) {
1153
1154
                                                $source = substr($source, 4);
1155
                                                if (strpos($source, '&') > 0) {
1156
                                                    $source = substr(
1157
                                                        $source,
1158
                                                        0,
1159
                                                        strpos($source, '&')
1160
                                                    );
1161
                                                }
1162
                                                if (strpos(
1163
                                                        $source,
1164
                                                        '://'
1165
                                                    ) > 0
1166
                                                ) {
1167
                                                    if (strpos(
1168
                                                            $source,
1169
                                                            api_get_path(
1170
                                                                WEB_PATH
1171
                                                            )
1172
                                                        ) !== false
1173
                                                    ) {
1174
                                                        // We found the current portal url.
1175
                                                        $files_list[] = array(
1176
                                                            $source,
1177
                                                            'local',
1178
                                                            'url'
1179
                                                        );
1180
                                                    } else {
1181
                                                        // We didn't find any trace of current portal.
1182
                                                        $files_list[] = array(
1183
                                                            $source,
1184
                                                            'remote',
1185
                                                            'url'
1186
                                                        );
1187
                                                    }
1188
                                                } else {
1189
                                                    $files_list[] = array(
1190
                                                        $source,
1191
                                                        'local',
1192
                                                        'abs'
1193
                                                    );
1194
                                                }
1195
                                                continue; // Skipping anything else to avoid two entries
1196
                                                //(while the others can have sub-files in their url, flv's can't).
1197
                                            }
1198
                                        }
1199
1200
                                        if (strpos($source, '://') > 0) {
1201

main/inc/lib/document.lib.php 1 location

@@ 2171-2200 (lines=30) @@
2168
                                continue; //avoid code - that should help
2169
                            }
2170
2171
                            if ($attr == 'value') {
2172
                                if (strpos($source, 'mp3file')) {
2173
                                    $files_list[] = array(substr($source, 0, strpos($source, '.swf') + 4), 'local', 'abs');
2174
                                    $mp3file = substr($source, strpos($source, 'mp3file=') + 8);
2175
                                    if (substr($mp3file, 0, 1) == '/') {
2176
                                        $files_list[] = array($mp3file, 'local', 'abs');
2177
                                    } else {
2178
                                        $files_list[] = array($mp3file, 'local', 'rel');
2179
                                    }
2180
                                } elseif (strpos($source, 'flv=') === 0) {
2181
                                    $source = substr($source, 4);
2182
                                    if (strpos($source, '&') > 0) {
2183
                                        $source = substr($source, 0, strpos($source, '&'));
2184
                                    }
2185
                                    if (strpos($source, '://') > 0) {
2186
                                        if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2187
                                            //we found the current portal url
2188
                                            $files_list[] = array($source, 'local', 'url');
2189
                                        } else {
2190
                                            //we didn't find any trace of current portal
2191
                                            $files_list[] = array($source, 'remote', 'url');
2192
                                        }
2193
                                    } else {
2194
                                        $files_list[] = array($source, 'local', 'abs');
2195
                                    }
2196
                                    /* skipping anything else to avoid two entries
2197
                                    (while the others can have sub-files in their url, flv's can't)*/
2198
                                    continue;
2199
                                }
2200
                            }
2201
                            if (strpos($source, '://') > 0) {
2202
                                //cut at '?' in a URL with params
2203
                                if (strpos($source, '?') > 0) {