Code Duplication    Length = 30-90 lines in 2 locations

main/lp/learnpathItem.class.php 1 location

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

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

@@ 2227-2256 (lines=30) @@
2224
                                continue; //avoid code - that should help
2225
                            }
2226
2227
                            if ($attr == 'value') {
2228
                                if (strpos($source, 'mp3file')) {
2229
                                    $files_list[] = array(substr($source, 0, strpos($source, '.swf') + 4), 'local', 'abs');
2230
                                    $mp3file = substr($source, strpos($source, 'mp3file=') + 8);
2231
                                    if (substr($mp3file, 0, 1) == '/') {
2232
                                        $files_list[] = array($mp3file, 'local', 'abs');
2233
                                    } else {
2234
                                        $files_list[] = array($mp3file, 'local', 'rel');
2235
                                    }
2236
                                } elseif (strpos($source, 'flv=') === 0) {
2237
                                    $source = substr($source, 4);
2238
                                    if (strpos($source, '&') > 0) {
2239
                                        $source = substr($source, 0, strpos($source, '&'));
2240
                                    }
2241
                                    if (strpos($source, '://') > 0) {
2242
                                        if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2243
                                            //we found the current portal url
2244
                                            $files_list[] = array($source, 'local', 'url');
2245
                                        } else {
2246
                                            //we didn't find any trace of current portal
2247
                                            $files_list[] = array($source, 'remote', 'url');
2248
                                        }
2249
                                    } else {
2250
                                        $files_list[] = array($source, 'local', 'abs');
2251
                                    }
2252
                                    /* skipping anything else to avoid two entries
2253
                                    (while the others can have sub-files in their url, flv's can't)*/
2254
                                    continue;
2255
                                }
2256
                            }
2257
                            if (strpos($source, '://') > 0) {
2258
                                //cut at '?' in a URL with params
2259
                                if (strpos($source, '?') > 0) {