@@ -433,7 +433,7 @@ |
||
433 | 433 | /** |
434 | 434 | * Validate attached file with the real hash |
435 | 435 | * |
436 | - * @return boolean |
|
436 | + * @return boolean|null |
|
437 | 437 | */ |
438 | 438 | public function validate() |
439 | 439 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return PMF_Attachment_Abstract |
133 | 133 | */ |
134 | - public function __construct ($id = null) |
|
134 | + public function __construct($id = null) |
|
135 | 135 | { |
136 | 136 | $this->db = PMF_Db::getInstance(); |
137 | 137 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - public function buildUrl ($forHTML = true) |
|
151 | + public function buildUrl($forHTML = true) |
|
152 | 152 | { |
153 | 153 | $amp = true == $forHTML ? '&' : '&'; |
154 | 154 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return void |
165 | 165 | */ |
166 | - public function setKey ($key, $default = true) |
|
166 | + public function setKey($key, $default = true) |
|
167 | 167 | { |
168 | 168 | $this->key = $key; |
169 | 169 | $this->encrypted = null !== $key; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * Not default means the key was set explicitly |
173 | 173 | * for this attachment, so lets hash it |
174 | 174 | */ |
175 | - if($this->encrypted && !$default) { |
|
175 | + if ($this->encrypted && !$default) { |
|
176 | 176 | $this->passwordHash = sha1($key); |
177 | 177 | } |
178 | 178 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return null |
186 | 186 | */ |
187 | - public function setRecordId ($id) |
|
187 | + public function setRecordId($id) |
|
188 | 188 | { |
189 | 189 | $this->recordId = $id; |
190 | 190 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return null |
198 | 198 | */ |
199 | - public function setRecordLang ($lang) |
|
199 | + public function setRecordLang($lang) |
|
200 | 200 | { |
201 | 201 | $this->recordLang = $lang; |
202 | 202 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | */ |
371 | 371 | protected function mkVirtualHash() |
372 | 372 | { |
373 | - if($this->encrypted) { |
|
374 | - if(null === $this->id || null === $this->recordId || |
|
373 | + if ($this->encrypted) { |
|
374 | + if (null === $this->id || null === $this->recordId || |
|
375 | 375 | null === $this->realHash || null === $this->filename || |
376 | 376 | null === $this->key) { |
377 | - throw new PMF_Attachment_Exception('All of id, ' . |
|
378 | - 'recordId, hash, filename, ' . |
|
379 | - 'key is needed to generate ' . |
|
377 | + throw new PMF_Attachment_Exception('All of id, '. |
|
378 | + 'recordId, hash, filename, '. |
|
379 | + 'key is needed to generate '. |
|
380 | 380 | 'fs hash for encrypted files'); |
381 | 381 | } |
382 | 382 | |
383 | - $src = $this->id . $this->recordId . $this->realHash . |
|
384 | - $this->filename . $this->key; |
|
383 | + $src = $this->id.$this->recordId.$this->realHash. |
|
384 | + $this->filename.$this->key; |
|
385 | 385 | $this->virtualHash = md5($src); |
386 | 386 | } else { |
387 | 387 | $this->virtualHash = $this->realHash; |
@@ -375,9 +375,9 @@ |
||
375 | 375 | null === $this->realHash || null === $this->filename || |
376 | 376 | null === $this->key) { |
377 | 377 | throw new PMF_Attachment_Exception('All of id, ' . |
378 | - 'recordId, hash, filename, ' . |
|
379 | - 'key is needed to generate ' . |
|
380 | - 'fs hash for encrypted files'); |
|
378 | + 'recordId, hash, filename, ' . |
|
379 | + 'key is needed to generate ' . |
|
380 | + 'fs hash for encrypted files'); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | $src = $this->id . $this->recordId . $this->realHash . |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Delete attachment |
51 | 51 | * |
52 | - * @return boolean |
|
52 | + * @return boolean|null |
|
53 | 53 | */ |
54 | 54 | function delete() |
55 | 55 | { |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * Save current attachment to the appropriate storage |
61 | 61 | * |
62 | - * @return boolean |
|
62 | + * @return boolean|null |
|
63 | 63 | */ |
64 | 64 | public function save() |
65 | 65 | { |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * |
41 | 41 | * @param int $id attachment id |
42 | 42 | */ |
43 | - public function __construct ($id = null) |
|
43 | + public function __construct($id = null) |
|
44 | 44 | { |
45 | 45 | // TODO implement this |
46 | 46 | throw new PMF_Attachment_Exception('The database attachment storage type is not yet implemented'); |
@@ -108,7 +108,7 @@ |
||
108 | 108 | * @param PMF_Configuration $config |
109 | 109 | * @param integer $recordId ID of the record |
110 | 110 | * |
111 | - * @return array |
|
111 | + * @return integer|null |
|
112 | 112 | */ |
113 | 113 | public static function fetchByRecordId(PMF_Configuration $config, $recordId) |
114 | 114 | { |
@@ -51,9 +51,9 @@ |
||
51 | 51 | protected $aes; |
52 | 52 | |
53 | 53 | /** |
54 | - * @param $filepath |
|
55 | - * @param $mode |
|
56 | - * @param $key |
|
54 | + * @param string $filepath |
|
55 | + * @param string $mode |
|
56 | + * @param string $key |
|
57 | 57 | * |
58 | 58 | * @return PMF_Attachment_Filesystem_File_Encrypted |
59 | 59 | */ |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | exit(); |
22 | 22 | } |
23 | 23 | |
24 | -require PMF_ROOT_DIR . '/inc/libs/phpseclib/Crypt/AES.php'; |
|
24 | +require PMF_ROOT_DIR.'/inc/libs/phpseclib/Crypt/AES.php'; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * PMF_Attachment_Abstract |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $chunk = ''; |
78 | 78 | $chunkDelimLen = strlen(self::chunkDelimiter); |
79 | 79 | |
80 | - while(!$readEnd && !$this->eof()) { |
|
80 | + while (!$readEnd && !$this->eof()) { |
|
81 | 81 | $chunk .= fread($this->handle, 1); |
82 | 82 | $readEnd = self::chunkDelimiter == substr($chunk, -$chunkDelimLen); |
83 | 83 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function putChunk($chunk) |
103 | 103 | { |
104 | - $content = $this->aes->encrypt($chunk) . self::chunkDelimiter; |
|
104 | + $content = $this->aes->encrypt($chunk).self::chunkDelimiter; |
|
105 | 105 | |
106 | 106 | return fwrite($this->handle, $content); |
107 | 107 | } |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | { |
114 | 114 | $retval = false; |
115 | 115 | |
116 | - if(is_string($target)) { |
|
116 | + if (is_string($target)) { |
|
117 | 117 | $target = new PMF_Attachment_Filesystem_File_Vanilla($target, self::MODE_WRITE); |
118 | 118 | } else { |
119 | 119 | $target->setMode(self::MODE_WRITE); |
120 | 120 | } |
121 | 121 | |
122 | - if($target->isOk()) { |
|
123 | - while(!$this->eof()) { |
|
122 | + if ($target->isOk()) { |
|
123 | + while (!$this->eof()) { |
|
124 | 124 | $target->putChunk($this->getChunk()); |
125 | 125 | } |
126 | 126 |
@@ -89,7 +89,7 @@ |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | - * @param $dir |
|
92 | + * @param boolean $dir |
|
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | protected function getOldFileList($dir) |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | $records = $faq->faqRecords; |
102 | 102 | |
103 | 103 | reset($records); |
104 | - while(list(,$record) = each($records)) { |
|
104 | + while (list(,$record) = each($records)) { |
|
105 | 105 | |
106 | 106 | $recordDir = "$dir/$record[id]"; |
107 | - if(file_exists($recordDir) && is_dir($recordDir)) { |
|
107 | + if (file_exists($recordDir) && is_dir($recordDir)) { |
|
108 | 108 | |
109 | 109 | $list[$record['id']]['files'] = array(); |
110 | - foreach(new DirectoryIterator($recordDir) as $entry) { |
|
111 | - if(!$entry->isDot() && $entry->isFile()) { |
|
110 | + foreach (new DirectoryIterator($recordDir) as $entry) { |
|
111 | + if (!$entry->isDot() && $entry->isFile()) { |
|
112 | 112 | $list[$record['id']]['files'][] = "$recordDir/{$entry->getFilename()}"; |
113 | 113 | } |
114 | 114 | } |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | { |
130 | 130 | $list = $this->getOldFileList(PMF_ATTACHMENTS_DIR); |
131 | 131 | |
132 | - foreach($list as $recordId => $item) { |
|
132 | + foreach ($list as $recordId => $item) { |
|
133 | 133 | $recordLang = $item['lang']; |
134 | - foreach($item['files'] as $file) { |
|
134 | + foreach ($item['files'] as $file) { |
|
135 | 135 | $att = PMF_Attachment_Factory::create(); |
136 | 136 | $att->setRecordId($recordId); |
137 | 137 | $att->setRecordLang($recordLang); |
138 | 138 | |
139 | - if(!$att->save($file)) { |
|
139 | + if (!$att->save($file)) { |
|
140 | 140 | $this->error[] = "File $file couldn't be migrated"; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - $recordDir = PMF_ATTACHMENTS_DIR . "/$recordId"; |
|
145 | - if(!@rmdir(PMF_ATTACHMENTS_DIR . "/$file")) { |
|
144 | + $recordDir = PMF_ATTACHMENTS_DIR."/$recordId"; |
|
145 | + if (!@rmdir(PMF_ATTACHMENTS_DIR."/$file")) { |
|
146 | 146 | $this->warning[] = "Couldn't remove dir $recordDir after migration"; |
147 | 147 | } |
148 | 148 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function doMigrate($migrationType, $options) |
160 | 160 | { |
161 | - switch($migrationType) { |
|
161 | + switch ($migrationType) { |
|
162 | 162 | case PMF_Attachment_Migration::MIGRATION_TYPE1: |
163 | 163 | |
164 | 164 | PMF_Attachment_Factory::init(PMF_Attachment::STORAGE_TYPE_FILESYSTEM, |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * Awaiting new default key here |
175 | 175 | */ |
176 | - if(isset($options['defaultKey']) && !empty($options['defaultKey'])) { |
|
176 | + if (isset($options['defaultKey']) && !empty($options['defaultKey'])) { |
|
177 | 177 | PMF_Attachment_Factory::init(PMF_Attachment::STORAGE_TYPE_FILESYSTEM, |
178 | 178 | $options['defaultKey'], |
179 | 179 | true); |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | case self::MIGRATION_TYPE1: |
160 | 160 | |
161 | 161 | PMF_Attachment_Factory::init(PMF_Attachment::STORAGE_TYPE_FILESYSTEM, |
162 | - '', |
|
163 | - false); |
|
162 | + '', |
|
163 | + false); |
|
164 | 164 | $this->migrateFromOldFormatToFs(); |
165 | 165 | // FIXME should attachment settings update be triggered here? |
166 | 166 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | */ |
173 | 173 | if (isset($options['defaultKey']) && !empty($options['defaultKey'])) { |
174 | 174 | PMF_Attachment_Factory::init(PMF_Attachment::STORAGE_TYPE_FILESYSTEM, |
175 | - $options['defaultKey'], |
|
176 | - true); |
|
175 | + $options['defaultKey'], |
|
176 | + true); |
|
177 | 177 | $this->migrateFromOldFormatToFs(); |
178 | 178 | } else { |
179 | 179 | $this->error[] = 'Default key required to be set for this option'; |
@@ -114,7 +114,7 @@ |
||
114 | 114 | * |
115 | 115 | * @param string $login Loginname |
116 | 116 | * @param array $optionalData Optional data |
117 | - * @return integer |
|
117 | + * @return boolean |
|
118 | 118 | */ |
119 | 119 | public function checkLogin($login, Array $optionalData = null) |
120 | 120 | { |
@@ -108,7 +108,7 @@ |
||
108 | 108 | * @param string $login Loginname |
109 | 109 | * @param string $pass Password |
110 | 110 | * @return boolean |
111 | - */ |
|
111 | + */ |
|
112 | 112 | public function changePassword($login, $pass) |
113 | 113 | { |
114 | 114 | $change = sprintf(" |
@@ -60,7 +60,7 @@ |
||
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @static |
63 | - * @return null|PMF_Cache |
|
63 | + * @return PMF_Cache |
|
64 | 64 | */ |
65 | 65 | public static function getInstance() |
66 | 66 | { |
@@ -126,7 +126,7 @@ |
||
126 | 126 | /** |
127 | 127 | * Returns date formatted according to user defined format |
128 | 128 | * |
129 | - * @param string $date |
|
129 | + * @param string $unformattedDate |
|
130 | 130 | * @return string |
131 | 131 | */ |
132 | 132 | public function format($unformattedDate) |
@@ -68,10 +68,10 @@ |
||
68 | 68 | { |
69 | 69 | if ($pmfFormat) { |
70 | 70 | $dateString = strtotime( |
71 | - substr($date, 0, 4) . '-' . |
|
72 | - substr($date, 4, 2) . '-' . |
|
73 | - substr($date, 6, 2) . ' ' . |
|
74 | - substr($date, 8, 2) . ':' . |
|
71 | + substr($date, 0, 4).'-'. |
|
72 | + substr($date, 4, 2).'-'. |
|
73 | + substr($date, 6, 2).' '. |
|
74 | + substr($date, 8, 2).':'. |
|
75 | 75 | substr($date, 10, 2) |
76 | 76 | ); |
77 | 77 | } else { |
@@ -14,7 +14,6 @@ |
||
14 | 14 | * @author Matteo Scaramuccia <[email protected]> |
15 | 15 | * @copyright 2009-2016 phpMyFAQ Team |
16 | 16 | * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
17 | - |
|
18 | 17 | * @link http://www.phpmyfaq.de |
19 | 18 | * @since 2009-09-24 |
20 | 19 | */ |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * @param string $query |
60 | 60 | * @param string $table |
61 | 61 | * |
62 | - * @return array |
|
62 | + * @return string[] |
|
63 | 63 | */ |
64 | 64 | public function buildInsertQueries($query, $table) |
65 | 65 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function __construct(PMF_Configuration $config) |
52 | 52 | { |
53 | - $this->_config = $config; |
|
53 | + $this->_config = $config; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
88 | - $ret[] = "INSERT INTO " . $table . " (" . implode(",", $p1) . ") VALUES (" . implode(",", $p2) . ");"; |
|
88 | + $ret[] = "INSERT INTO ".$table." (".implode(",", $p1).") VALUES (".implode(",", $p2).");"; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $ret; |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | $return = $query; |
135 | 135 | $matches = array(); |
136 | 136 | |
137 | - PMF_String::preg_match_all("/^" . $startPattern . "\s+(\w+)(\s+|$)/i", $query, $matches); |
|
137 | + PMF_String::preg_match_all("/^".$startPattern."\s+(\w+)(\s+|$)/i", $query, $matches); |
|
138 | 138 | |
139 | 139 | if (isset($matches[1][0])) { |
140 | 140 | $oldTableFullName = $matches[1][0]; |
141 | - $newTableFullName = $newValue . PMF_String::substr($oldTableFullName, PMF_String::strlen($oldValue)); |
|
141 | + $newTableFullName = $newValue.PMF_String::substr($oldTableFullName, PMF_String::strlen($oldValue)); |
|
142 | 142 | $return = str_replace($oldTableFullName, $newTableFullName, $query); |
143 | 143 | } |
144 | 144 |