mbirth /
cops
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
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) class file |
||
| 4 | * |
||
| 5 | * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
||
| 6 | * @author Sébastien Lucas <[email protected]> |
||
| 7 | */ |
||
| 8 | |||
| 9 | class PageCustomize extends Page |
||
| 10 | { |
||
| 11 | private function isChecked ($key, $testedValue = 1) { |
||
| 12 | $value = getCurrentOption ($key); |
||
| 13 | if (is_array ($value)) { |
||
| 14 | if (in_array ($testedValue, $value)) { |
||
| 15 | return "checked='checked'"; |
||
| 16 | } |
||
| 17 | } else { |
||
| 18 | if ($value == $testedValue) { |
||
| 19 | return "checked='checked'"; |
||
| 20 | } |
||
| 21 | } |
||
| 22 | return ""; |
||
|
0 ignored issues
–
show
|
|||
| 23 | } |
||
| 24 | |||
| 25 | private function isSelected ($key, $value) { |
||
| 26 | if (getCurrentOption ($key) == $value) { |
||
| 27 | return "selected='selected'"; |
||
| 28 | } |
||
| 29 | return ""; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 30 | } |
||
| 31 | |||
| 32 | private function getStyleList () { |
||
| 33 | $result = array (); |
||
| 34 | foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
||
| 35 | if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
||
| 36 | array_push ($result, $m [1]); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | return $result; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function InitializeContent () |
||
|
0 ignored issues
–
show
This method is not in camel caps format.
This check looks for method names that are not written in camelCase. In camelCase names are written without any punctuation, the start of each new
word being marked by a capital letter. Thus the name
database connection seeker becomes Loading history...
|
|||
| 43 | { |
||
| 44 | $this->title = localize ("customize.title"); |
||
| 45 | $this->entryArray = array (); |
||
| 46 | |||
| 47 | $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
||
| 48 | PageQueryResult::SCOPE_TAG, |
||
| 49 | PageQueryResult::SCOPE_SERIES, |
||
| 50 | PageQueryResult::SCOPE_PUBLISHER, |
||
| 51 | PageQueryResult::SCOPE_RATING, |
||
| 52 | "language"); |
||
| 53 | |||
| 54 | $content = ""; |
||
| 55 | array_push ($this->entryArray, new Entry ("Template", "", |
||
| 56 | "<span style='cursor: pointer;' onclick='$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text", |
||
| 57 | array ())); |
||
| 58 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
||
| 59 | $content .= '<select id="style" onchange="updateCookie (this);">'; |
||
| 60 | View Code Duplication | foreach ($this-> getStyleList () as $filename) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. Loading history...
|
|||
| 61 | $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>"; |
||
| 62 | } |
||
| 63 | $content .= '</select>'; |
||
| 64 | } else { |
||
| 65 | View Code Duplication | foreach ($this-> getStyleList () as $filename) { |
|
| 66 | $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | array_push ($this->entryArray, new Entry (localize ("customize.style"), "", |
||
| 70 | $content, "text", |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
text does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 71 | array ())); |
||
| 72 | if (!useServerSideRendering ()) { |
||
| 73 | $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />'; |
||
| 74 | array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "", |
||
| 75 | $content, "text", |
||
| 76 | array ())); |
||
| 77 | } |
||
| 78 | $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption ("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
||
| 79 | array_push ($this->entryArray, new Entry (localize ("customize.paging"), "", |
||
| 80 | $content, "text", |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
text does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 81 | array ())); |
||
| 82 | $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />'; |
||
| 83 | array_push ($this->entryArray, new Entry (localize ("customize.email"), "", |
||
| 84 | $content, "text", |
||
| 85 | array ())); |
||
| 86 | $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />'; |
||
| 87 | array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", |
||
| 88 | $content, "text", |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
text does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 89 | array ())); |
||
| 90 | $content = ""; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 91 | foreach ($ignoredBaseArray as $key) { |
||
| 92 | $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); |
||
| 93 | $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> '; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
ignored_categories does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
As per coding-style, please use concatenation or
sprintf for the variable $keyPlural instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
|
|||
| 94 | } |
||
| 95 | |||
| 96 | array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", |
||
| 97 | $content, "text", |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
text does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. Loading history...
|
|||
| 98 | array ())); |
||
| 99 | } |
||
| 100 | } |
||
| 101 |
PHP provides two ways to mark string literals. Either with single quotes
'literal'or with double quotes"literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (
\') and the backslash (\\). Every other character is displayed as is.Double quoted string literals may contain other variables or more complex escape sequences.
will print an indented:
Single is ValueIf your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.
For more information on PHP string literals and available escape sequences see the PHP core documentation.