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 CustomColumnTypeDate extends CustomColumnType |
||
|
0 ignored issues
–
show
|
|||
| 10 | { |
||
| 11 | 1 | protected function __construct($pcustomId) |
|
| 12 | { |
||
| 13 | 1 | parent::__construct($pcustomId, self::CUSTOM_TYPE_DATE); |
|
| 14 | 1 | } |
|
| 15 | |||
| 16 | /** |
||
| 17 | * Get the name of the sqlite table for this column |
||
| 18 | * |
||
| 19 | * @return string|null |
||
| 20 | */ |
||
| 21 | 5 | private function getTableName() |
|
| 22 | { |
||
| 23 | 5 | return "custom_column_{$this->customId}"; |
|
|
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $this 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...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | 2 | public function getQuery($id) |
|
| 27 | { |
||
| 28 | 2 | $date = new DateTime($id); |
|
| 29 | 2 | $query = str_format(Book::SQL_BOOKS_BY_CUSTOM_DATE, "{0}", "{1}", $this->getTableName()); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
{0} 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...
Coding Style
Comprehensibility
introduced
by
The string literal
{1} 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 | 2 | return array($query, array($date->format("Y-m-d"))); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Y-m-d 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...
|
|||
| 31 | } |
||
| 32 | |||
| 33 | 2 | public function getCustom($id) |
|
| 34 | { |
||
| 35 | 2 | $date = new DateTime($id); |
|
| 36 | |||
| 37 | 2 | return new CustomColumn($id, $date->format(localize("customcolumn.date.format")), $this); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
customcolumn.date.format 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...
|
|||
| 38 | } |
||
| 39 | |||
| 40 | 1 | protected function getAllCustomValuesFromDatabase() |
|
| 41 | { |
||
| 42 | 1 | $queryFormat = "SELECT date(value) AS datevalue, count(*) AS count FROM {0} GROUP BY datevalue"; |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
SELECT date(value) AS da... {0} GROUP BY datevalue 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...
|
|||
| 43 | 1 | $query = str_format($queryFormat, $this->getTableName()); |
|
| 44 | 1 | $result = Base::getDb()->query($query); |
|
| 45 | |||
| 46 | 1 | $entryArray = array(); |
|
| 47 | 1 | while ($post = $result->fetchObject()) { |
|
| 48 | 1 | $date = new DateTime($post->datevalue); |
|
| 49 | 1 | $id = $date->format("Y-m-d"); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Y-m-d 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...
|
|||
| 50 | |||
| 51 | 1 | $entryPContent = str_format(localize("bookword", $post->count), $post->count); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
bookword 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...
|
|||
| 52 | 1 | $entryPLinkArray = array(new LinkNavigation ($this->getUri($id))); |
|
| 53 | |||
| 54 | 1 | $entry = new Entry($date->format(localize("customcolumn.date.format")), $this->getEntryId($id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
customcolumn.date.format 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...
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...
|
|||
| 55 | |||
| 56 | 1 | array_push($entryArray, $entry); |
|
| 57 | 1 | } |
|
| 58 | |||
| 59 | 1 | return $entryArray; |
|
| 60 | } |
||
| 61 | |||
| 62 | 3 | public function getDescription() |
|
| 63 | { |
||
| 64 | 3 | $desc = $this->getDatabaseDescription(); |
|
| 65 | 3 | if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
customcolumn.description 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...
|
|||
| 66 | 3 | return $desc; |
|
| 67 | } |
||
| 68 | |||
| 69 | 2 | public function getCustomByBook($book) |
|
| 70 | { |
||
| 71 | 2 | $queryFormat = "SELECT date({0}.value) AS datevalue FROM {0} WHERE {0}.book = {1}"; |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
SELECT date({0}.value) A...0} WHERE {0}.book = {1} 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...
|
|||
| 72 | 2 | $query = str_format($queryFormat, $this->getTableName(), $book->id); |
|
| 73 | |||
| 74 | 2 | $result = Base::getDb()->query($query); |
|
| 75 | 2 | if ($post = $result->fetchObject()) { |
|
| 76 | 1 | $date = new DateTime($post->datevalue); |
|
| 77 | |||
| 78 | 1 | return new CustomColumn($date->format("Y-m-d"), $date->format(localize("customcolumn.date.format")), $this); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Y-m-d 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...
Coding Style
Comprehensibility
introduced
by
The string literal
customcolumn.date.format 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...
|
|||
| 79 | } |
||
| 80 | 1 | return new CustomColumn(NULL, localize("customcolumn.date.unknown"), $this); |
|
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
customcolumn.date.unknown 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 | } |
||
| 82 | |||
| 83 | 3 | public function isSearchable() |
|
| 84 | { |
||
| 85 | 3 | return true; |
|
| 86 | } |
||
| 87 | } |
||
| 88 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.