These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * COPS (Calibre OPDS PHP Server) main script |
||
4 | * |
||
5 | * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
||
6 | * @author Sébastien Lucas <[email protected]> |
||
7 | * |
||
8 | */ |
||
9 | |||
10 | require_once 'config.php'; |
||
11 | require_once 'base.php'; |
||
12 | |||
13 | header('Content-Type:application/xml'); |
||
14 | $page = getURLParam('page', Base::PAGE_INDEX); |
||
15 | $query = getURLParam('query'); |
||
16 | $n = getURLParam('n', '1'); |
||
17 | if ($query) { |
||
18 | $page = Base::PAGE_OPENSEARCH_QUERY; |
||
19 | } |
||
20 | $qid = getURLParam('id'); |
||
21 | |||
22 | View Code Duplication | if ($config ['cops_fetch_protect'] == '1') { |
|
0 ignored issues
–
show
|
|||
23 | session_start(); |
||
24 | if (!isset($_SESSION['connected'])) { |
||
25 | $_SESSION['connected'] = 0; |
||
26 | } |
||
27 | } |
||
28 | |||
29 | $OPDSRender = new OPDSRenderer(); |
||
30 | |||
31 | switch ($page) { |
||
32 | case Base::PAGE_OPENSEARCH : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
33 | echo $OPDSRender->getOpenSearch(); |
||
34 | return; |
||
35 | default: |
||
36 | $currentPage = Page::getPage($page, $qid, $query, $n); |
||
37 | $currentPage->InitializeContent(); |
||
38 | echo $OPDSRender->render($currentPage); |
||
39 | return; |
||
40 | } |
||
41 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.