@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @see Net_SSH1::interactiveRead() |
733 | 733 | * @see Net_SSH1::interactiveWrite() |
734 | 734 | * @param String $cmd |
735 | - * @return mixed |
|
735 | + * @return boolean|string |
|
736 | 736 | * @access public |
737 | 737 | */ |
738 | 738 | function exec($cmd, $block = true) |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | * |
1246 | 1246 | * @see Net_SSH1::Net_SSH1() |
1247 | 1247 | * @param Math_BigInteger $m |
1248 | - * @param Array $key |
|
1249 | - * @return Math_BigInteger |
|
1248 | + * @param Math_BigInteger[] $key |
|
1249 | + * @return string |
|
1250 | 1250 | * @access private |
1251 | 1251 | */ |
1252 | 1252 | function _rsa_crypt($m, $key) |
@@ -1298,7 +1298,6 @@ discard block |
||
1298 | 1298 | * named constants from it, using the value as the name of the constant and the index as the value of the constant. |
1299 | 1299 | * If any of the constants that would be defined already exists, none of the constants will be defined. |
1300 | 1300 | * |
1301 | - * @param Array $array |
|
1302 | 1301 | * @access private |
1303 | 1302 | */ |
1304 | 1303 | function _define_array() |
@@ -1491,8 +1490,9 @@ discard block |
||
1491 | 1490 | * |
1492 | 1491 | * Makes sure that only the last 1MB worth of packets will be logged |
1493 | 1492 | * |
1494 | - * @param String $data |
|
1495 | 1493 | * @access private |
1494 | + * @param string $protocol_flags |
|
1495 | + * @param string $message |
|
1496 | 1496 | */ |
1497 | 1497 | function _append_log($protocol_flags, $message) |
1498 | 1498 | { |
@@ -1364,12 +1364,12 @@ |
||
1364 | 1364 | } |
1365 | 1365 | $fragment = $this->_string_shift($current_log, $short_width); |
1366 | 1366 | $hex = substr( |
1367 | - preg_replace( |
|
1368 | - '#(.)#es', |
|
1369 | - '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
1370 | - $fragment), |
|
1371 | - strlen($boundary) |
|
1372 | - ); |
|
1367 | + preg_replace( |
|
1368 | + '#(.)#es', |
|
1369 | + '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
1370 | + $fragment), |
|
1371 | + strlen($boundary) |
|
1372 | + ); |
|
1373 | 1373 | // replace non ASCII printable characters with dots |
1374 | 1374 | // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters |
1375 | 1375 | // also replace < with a . since < messes up the output on web browsers |
@@ -76,23 +76,23 @@ discard block |
||
76 | 76 | * |
77 | 77 | * Not supported. |
78 | 78 | */ |
79 | -define('NET_SSH1_CIPHER_NONE', 0); |
|
79 | +define('NET_SSH1_CIPHER_NONE', 0); |
|
80 | 80 | /** |
81 | 81 | * IDEA in CFB mode |
82 | 82 | * |
83 | 83 | * Not supported. |
84 | 84 | */ |
85 | -define('NET_SSH1_CIPHER_IDEA', 1); |
|
85 | +define('NET_SSH1_CIPHER_IDEA', 1); |
|
86 | 86 | /** |
87 | 87 | * DES in CBC mode |
88 | 88 | */ |
89 | -define('NET_SSH1_CIPHER_DES', 2); |
|
89 | +define('NET_SSH1_CIPHER_DES', 2); |
|
90 | 90 | /** |
91 | 91 | * Triple-DES in CBC mode |
92 | 92 | * |
93 | 93 | * All implementations are required to support this |
94 | 94 | */ |
95 | -define('NET_SSH1_CIPHER_3DES', 3); |
|
95 | +define('NET_SSH1_CIPHER_3DES', 3); |
|
96 | 96 | /** |
97 | 97 | * TRI's Simple Stream encryption CBC |
98 | 98 | * |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * This library currently only supports encryption when the same key is being used for both directions. This is |
116 | 116 | * because there's only one $crypto object. Two could be added ($encrypt and $decrypt, perhaps). |
117 | 117 | */ |
118 | -define('NET_SSH1_CIPHER_RC4', 5); |
|
118 | +define('NET_SSH1_CIPHER_RC4', 5); |
|
119 | 119 | /** |
120 | 120 | * Blowfish |
121 | 121 | * |
122 | 122 | * Not supported nor is it defined in the official SSH1 specs. OpenSSH, however, defines it (see cipher.h) and |
123 | 123 | * uses it (see cipher.c) |
124 | 124 | */ |
125 | -define('NET_SSH1_CIPHER_BLOWFISH', 6); |
|
125 | +define('NET_SSH1_CIPHER_BLOWFISH', 6); |
|
126 | 126 | /**#@-*/ |
127 | 127 | |
128 | 128 | /**#@+ |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * .rhosts or /etc/hosts.equiv |
136 | 136 | */ |
137 | -define('NET_SSH1_AUTH_RHOSTS', 1); |
|
137 | +define('NET_SSH1_AUTH_RHOSTS', 1); |
|
138 | 138 | /** |
139 | 139 | * pure RSA authentication |
140 | 140 | */ |
141 | -define('NET_SSH1_AUTH_RSA', 2); |
|
141 | +define('NET_SSH1_AUTH_RSA', 2); |
|
142 | 142 | /** |
143 | 143 | * password authentication |
144 | 144 | * |
145 | 145 | * This is the only method that is supported by this library. |
146 | 146 | */ |
147 | -define('NET_SSH1_AUTH_PASSWORD', 3); |
|
147 | +define('NET_SSH1_AUTH_PASSWORD', 3); |
|
148 | 148 | /** |
149 | 149 | * .rhosts with RSA host authentication |
150 | 150 | */ |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @link http://3sp.com/content/developer/maverick-net/docs/Maverick.SSH.PseudoTerminalModesMembers.html |
158 | 158 | * @access private |
159 | 159 | */ |
160 | -define('NET_SSH1_TTY_OP_END', 0); |
|
160 | +define('NET_SSH1_TTY_OP_END', 0); |
|
161 | 161 | /**#@-*/ |
162 | 162 | |
163 | 163 | /** |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | * @access private |
184 | 184 | */ |
185 | 185 | define('NET_SSH1_MASK_CONSTRUCTOR', 0x00000001); |
186 | -define('NET_SSH1_MASK_LOGIN', 0x00000002); |
|
187 | -define('NET_SSH1_MASK_SHELL', 0x00000004); |
|
186 | +define('NET_SSH1_MASK_LOGIN', 0x00000002); |
|
187 | +define('NET_SSH1_MASK_SHELL', 0x00000004); |
|
188 | 188 | /**#@-*/ |
189 | 189 | |
190 | 190 | /**#@+ |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | /** |
195 | 195 | * Returns the message numbers |
196 | 196 | */ |
197 | -define('NET_SSH1_LOG_SIMPLE', 1); |
|
197 | +define('NET_SSH1_LOG_SIMPLE', 1); |
|
198 | 198 | /** |
199 | 199 | * Returns the message content |
200 | 200 | */ |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * Returns when a string matching $expect exactly is found |
218 | 218 | */ |
219 | -define('NET_SSH1_READ_SIMPLE', 1); |
|
219 | +define('NET_SSH1_READ_SIMPLE', 1); |
|
220 | 220 | /** |
221 | 221 | * Returns when a string matching the regular expression $expect is found |
222 | 222 | */ |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | |
493 | 493 | if (defined('NET_SSH1_LOGGING')) { |
494 | 494 | $this->_append_log('<-', $this->server_identification); |
495 | - $this->_append_log('->', $this->identifier . "\r\n"); |
|
495 | + $this->_append_log('->', $this->identifier."\r\n"); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | if (!preg_match('#SSH-([0-9\.]+)-(.+)#', $init_line, $parts)) { |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | - $session_id = pack('H*', md5($host_key_public_modulus->toBytes() . $server_key_public_modulus->toBytes() . $anti_spoofing_cookie)); |
|
555 | + $session_id = pack('H*', md5($host_key_public_modulus->toBytes().$server_key_public_modulus->toBytes().$anti_spoofing_cookie)); |
|
556 | 556 | |
557 | 557 | $session_key = crypt_random_string(32); |
558 | 558 | $double_encrypted_session_key = $session_key ^ str_pad($session_id, 32, chr(0)); |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | $this->crypto = new Crypt_DES(); |
609 | 609 | $this->crypto->disablePadding(); |
610 | 610 | $this->crypto->enableContinuousBuffer(); |
611 | - $this->crypto->setKey(substr($session_key, 0, 8)); |
|
611 | + $this->crypto->setKey(substr($session_key, 0, 8)); |
|
612 | 612 | break; |
613 | 613 | case NET_SSH1_CIPHER_3DES: |
614 | 614 | if (!class_exists('Crypt_TripleDES')) { |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | |
759 | 759 | if ($response !== false) { |
760 | 760 | do { |
761 | - $output.= substr($response[NET_SSH1_RESPONSE_DATA], 4); |
|
761 | + $output .= substr($response[NET_SSH1_RESPONSE_DATA], 4); |
|
762 | 762 | $response = $this->_get_binary_packet(); |
763 | 763 | } while (is_array($response) && $response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_EXITSTATUS); |
764 | 764 | } |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | if ($response === true) { |
873 | 873 | return $this->_string_shift($this->interactiveBuffer, strlen($this->interactiveBuffer)); |
874 | 874 | } |
875 | - $this->interactiveBuffer.= substr($response[NET_SSH1_RESPONSE_DATA], 4); |
|
875 | + $this->interactiveBuffer .= substr($response[NET_SSH1_RESPONSE_DATA], 4); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 | |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | return true; |
1029 | 1029 | } |
1030 | 1030 | $elapsed = strtok(microtime(), ' ') + strtok('') - $start; |
1031 | - $this->curTimeout-= $elapsed; |
|
1031 | + $this->curTimeout -= $elapsed; |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
@@ -1039,8 +1039,8 @@ discard block |
||
1039 | 1039 | |
1040 | 1040 | while ($length > 0) { |
1041 | 1041 | $temp = fread($this->fsock, $length); |
1042 | - $raw.= $temp; |
|
1043 | - $length-= strlen($temp); |
|
1042 | + $raw .= $temp; |
|
1043 | + $length -= strlen($temp); |
|
1044 | 1044 | } |
1045 | 1045 | $stop = strtok(microtime(), ' ') + strtok(''); |
1046 | 1046 | |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | |
1064 | 1064 | if (defined('NET_SSH1_LOGGING')) { |
1065 | 1065 | $temp = isset($this->protocol_flags[$type]) ? $this->protocol_flags[$type] : 'UNKNOWN'; |
1066 | - $temp = '<- ' . $temp . |
|
1067 | - ' (' . round($stop - $start, 4) . 's)'; |
|
1066 | + $temp = '<- '.$temp. |
|
1067 | + ' ('.round($stop - $start, 4).'s)'; |
|
1068 | 1068 | $this->_append_log($temp, $data); |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1096,8 +1096,8 @@ discard block |
||
1096 | 1096 | $padding = crypt_random_string(8 - ($length & 7)); |
1097 | 1097 | |
1098 | 1098 | $orig = $data; |
1099 | - $data = $padding . $data; |
|
1100 | - $data.= pack('N', $this->_crc($data)); |
|
1099 | + $data = $padding.$data; |
|
1100 | + $data .= pack('N', $this->_crc($data)); |
|
1101 | 1101 | |
1102 | 1102 | if ($this->crypto !== false) { |
1103 | 1103 | $data = $this->crypto->encrypt($data); |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | if (defined('NET_SSH1_LOGGING')) { |
1113 | 1113 | $temp = isset($this->protocol_flags[ord($orig[0])]) ? $this->protocol_flags[ord($orig[0])] : 'UNKNOWN'; |
1114 | - $temp = '-> ' . $temp . |
|
1115 | - ' (' . round($stop - $start, 4) . 's)'; |
|
1114 | + $temp = '-> '.$temp. |
|
1115 | + ' ('.round($stop - $start, 4).'s)'; |
|
1116 | 1116 | $this->_append_log($temp, $orig); |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | $crc = 0x00000000; |
1207 | 1207 | $length = strlen($data); |
1208 | 1208 | |
1209 | - for ($i=0;$i<$length;$i++) { |
|
1209 | + for ($i = 0; $i < $length; $i++) { |
|
1210 | 1210 | // We AND $crc >> 8 with 0x00FFFFFF because we want the eight newly added bits to all |
1211 | 1211 | // be zero. PHP, unfortunately, doesn't always do this. 0x80000000 >> 8, as an example, |
1212 | 1212 | // yields 0xFF800000 - not 0x00800000. The following link elaborates: |
@@ -1281,9 +1281,9 @@ discard block |
||
1281 | 1281 | while (strlen($random) != $length) { |
1282 | 1282 | $block = crypt_random_string($length - strlen($random)); |
1283 | 1283 | $block = str_replace("\x00", '', $block); |
1284 | - $random.= $block; |
|
1284 | + $random .= $block; |
|
1285 | 1285 | } |
1286 | - $temp = chr(0) . chr(2) . $random . chr(0) . $m; |
|
1286 | + $temp = chr(0).chr(2).$random.chr(0).$m; |
|
1287 | 1287 | |
1288 | 1288 | $m = new Math_BigInteger($temp, 256); |
1289 | 1289 | $m = $m->modPow($key[0], $key[1]); |
@@ -1355,18 +1355,18 @@ discard block |
||
1355 | 1355 | |
1356 | 1356 | $output = ''; |
1357 | 1357 | for ($i = 0; $i < count($message_log); $i++) { |
1358 | - $output.= $message_number_log[$i] . "\r\n"; |
|
1358 | + $output .= $message_number_log[$i]."\r\n"; |
|
1359 | 1359 | $current_log = $message_log[$i]; |
1360 | 1360 | $j = 0; |
1361 | 1361 | do { |
1362 | 1362 | if (strlen($current_log)) { |
1363 | - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; |
|
1363 | + $output .= str_pad(dechex($j), 7, '0', STR_PAD_LEFT).'0 '; |
|
1364 | 1364 | } |
1365 | 1365 | $fragment = $this->_string_shift($current_log, $short_width); |
1366 | 1366 | $hex = substr( |
1367 | 1367 | preg_replace( |
1368 | 1368 | '#(.)#es', |
1369 | - '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
1369 | + '"'.$boundary.'" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
1370 | 1370 | $fragment), |
1371 | 1371 | strlen($boundary) |
1372 | 1372 | ); |
@@ -1374,10 +1374,10 @@ discard block |
||
1374 | 1374 | // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters |
1375 | 1375 | // also replace < with a . since < messes up the output on web browsers |
1376 | 1376 | $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); |
1377 | - $output.= str_pad($hex, $long_width - $short_width, ' ') . $raw . "\r\n"; |
|
1377 | + $output .= str_pad($hex, $long_width - $short_width, ' ').$raw."\r\n"; |
|
1378 | 1378 | $j++; |
1379 | 1379 | } while (strlen($current_log)); |
1380 | - $output.= "\r\n"; |
|
1380 | + $output .= "\r\n"; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | return $output; |
@@ -1505,10 +1505,10 @@ discard block |
||
1505 | 1505 | case NET_SSH1_LOG_COMPLEX: |
1506 | 1506 | $this->protocol_flags_log[] = $protocol_flags; |
1507 | 1507 | $this->_string_shift($message); |
1508 | - $this->log_size+= strlen($message); |
|
1508 | + $this->log_size += strlen($message); |
|
1509 | 1509 | $this->message_log[] = $message; |
1510 | 1510 | while ($this->log_size > NET_SSH2_LOG_MAX_SIZE) { |
1511 | - $this->log_size-= strlen(array_shift($this->message_log)); |
|
1511 | + $this->log_size -= strlen(array_shift($this->message_log)); |
|
1512 | 1512 | array_shift($this->protocol_flags_log); |
1513 | 1513 | } |
1514 | 1514 | break; |
@@ -1516,7 +1516,7 @@ discard block |
||
1516 | 1516 | // passwords won't be filtered out and select other packets may not be correctly |
1517 | 1517 | // identified |
1518 | 1518 | case NET_SSH1_LOG_REALTIME: |
1519 | - echo "<pre>\r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n</pre>\r\n"; |
|
1519 | + echo "<pre>\r\n".$this->_format_log(array($message), array($protocol_flags))."\r\n</pre>\r\n"; |
|
1520 | 1520 | @flush(); |
1521 | 1521 | @ob_flush(); |
1522 | 1522 | break; |
@@ -1537,10 +1537,10 @@ discard block |
||
1537 | 1537 | $entry = $this->_format_log(array($message), array($protocol_flags)); |
1538 | 1538 | if ($this->realtime_log_wrap) { |
1539 | 1539 | $temp = "<<< START >>>\r\n"; |
1540 | - $entry.= $temp; |
|
1540 | + $entry .= $temp; |
|
1541 | 1541 | fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); |
1542 | 1542 | } |
1543 | - $this->realtime_log_size+= strlen($entry); |
|
1543 | + $this->realtime_log_size += strlen($entry); |
|
1544 | 1544 | if ($this->realtime_log_size > NET_SSH1_LOG_MAX_SIZE) { |
1545 | 1545 | fseek($this->realtime_log_file, 0); |
1546 | 1546 | $this->realtime_log_size = strlen($entry); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @param String $host |
736 | 736 | * @param optional Integer $port |
737 | 737 | * @param optional Integer $timeout |
738 | - * @return Net_SSH2 |
|
738 | + * @return null|false |
|
739 | 739 | * @access public |
740 | 740 | */ |
741 | 741 | function Net_SSH2($host, $port = 22, $timeout = 10) |
@@ -1588,9 +1588,7 @@ discard block |
||
1588 | 1588 | * The $password parameter can be a plaintext password, a Crypt_RSA object or an array |
1589 | 1589 | * |
1590 | 1590 | * @param String $username |
1591 | - * @param Mixed $password |
|
1592 | - * @param Mixed $... |
|
1593 | - * @return Boolean |
|
1591 | + * @return boolean|null |
|
1594 | 1592 | * @see _login_helper |
1595 | 1593 | * @access public |
1596 | 1594 | */ |
@@ -1614,7 +1612,7 @@ discard block |
||
1614 | 1612 | * |
1615 | 1613 | * @param String $username |
1616 | 1614 | * @param optional String $password |
1617 | - * @return Boolean |
|
1615 | + * @return boolean|null |
|
1618 | 1616 | * @access private |
1619 | 1617 | * @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} |
1620 | 1618 | * by sending dummy SSH_MSG_IGNORE messages. |
@@ -1779,7 +1777,6 @@ discard block |
||
1779 | 1777 | /** |
1780 | 1778 | * Handle the keyboard-interactive requests / responses. |
1781 | 1779 | * |
1782 | - * @param String $responses... |
|
1783 | 1780 | * @return Boolean |
1784 | 1781 | * @access private |
1785 | 1782 | */ |
@@ -1896,7 +1893,6 @@ discard block |
||
1896 | 1893 | * Login with an RSA private key |
1897 | 1894 | * |
1898 | 1895 | * @param String $username |
1899 | - * @param Crypt_RSA $password |
|
1900 | 1896 | * @return Boolean |
1901 | 1897 | * @access private |
1902 | 1898 | * @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} |
@@ -2131,7 +2127,7 @@ discard block |
||
2131 | 2127 | * |
2132 | 2128 | * @see Net_SSH2::read() |
2133 | 2129 | * @see Net_SSH2::write() |
2134 | - * @return Boolean |
|
2130 | + * @return boolean|null |
|
2135 | 2131 | * @access private |
2136 | 2132 | */ |
2137 | 2133 | function _initShell() |
@@ -2427,6 +2423,7 @@ discard block |
||
2427 | 2423 | * Because some binary packets need to be ignored... |
2428 | 2424 | * |
2429 | 2425 | * @see Net_SSH2::_get_binary_packet() |
2426 | + * @param string $payload |
|
2430 | 2427 | * @return String |
2431 | 2428 | * @access private |
2432 | 2429 | */ |
@@ -2556,7 +2553,7 @@ discard block |
||
2556 | 2553 | * |
2557 | 2554 | * Returns the data as a string if it's available and false if not. |
2558 | 2555 | * |
2559 | - * @param $client_channel |
|
2556 | + * @param integer $client_channel |
|
2560 | 2557 | * @return Mixed |
2561 | 2558 | * @access private |
2562 | 2559 | */ |
@@ -2795,8 +2792,9 @@ discard block |
||
2795 | 2792 | * |
2796 | 2793 | * Makes sure that only the last 1MB worth of packets will be logged |
2797 | 2794 | * |
2798 | - * @param String $data |
|
2799 | 2795 | * @access private |
2796 | + * @param string $message_number |
|
2797 | + * @param string $message |
|
2800 | 2798 | */ |
2801 | 2799 | function _append_log($message_number, $message) |
2802 | 2800 | { |
@@ -2894,7 +2892,7 @@ discard block |
||
2894 | 2892 | * for SCP more than anything. |
2895 | 2893 | * |
2896 | 2894 | * @param Integer $client_channel |
2897 | - * @return Boolean |
|
2895 | + * @return boolean|null |
|
2898 | 2896 | * @access private |
2899 | 2897 | */ |
2900 | 2898 | function _close_channel($client_channel) |
@@ -2920,7 +2918,7 @@ discard block |
||
2920 | 2918 | * Disconnect |
2921 | 2919 | * |
2922 | 2920 | * @param Integer $reason |
2923 | - * @return Boolean |
|
2921 | + * @return false|null |
|
2924 | 2922 | * @access private |
2925 | 2923 | */ |
2926 | 2924 | function _disconnect($reason) |
@@ -2958,7 +2956,6 @@ discard block |
||
2958 | 2956 | * named constants from it, using the value as the name of the constant and the index as the value of the constant. |
2959 | 2957 | * If any of the constants that would be defined already exists, none of the constants will be defined. |
2960 | 2958 | * |
2961 | - * @param Array $array |
|
2962 | 2959 | * @access private |
2963 | 2960 | */ |
2964 | 2961 | function _define_array() |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | array(60 => 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'), |
823 | 823 | array(60 => 'NET_SSH2_MSG_USERAUTH_PK_OK'), |
824 | 824 | array(60 => 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', |
825 | - 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE') |
|
825 | + 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE') |
|
826 | 826 | ); |
827 | 827 | |
828 | 828 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | 'twofish192-cbc', // OPTIONAL Twofish with a 192-bit key |
971 | 971 | 'twofish256-cbc', |
972 | 972 | 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" |
973 | - // (this is being retained for historical reasons) |
|
973 | + // (this is being retained for historical reasons) |
|
974 | 974 | '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode |
975 | 975 | |
976 | 976 | '3des-cbc', // REQUIRED three-key 3DES in CBC mode |
@@ -1000,8 +1000,8 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | static $str_kex_algorithms, $str_server_host_key_algorithms, |
1003 | - $encryption_algorithms_server_to_client, $mac_algorithms_server_to_client, $compression_algorithms_server_to_client, |
|
1004 | - $encryption_algorithms_client_to_server, $mac_algorithms_client_to_server, $compression_algorithms_client_to_server; |
|
1003 | + $encryption_algorithms_server_to_client, $mac_algorithms_server_to_client, $compression_algorithms_server_to_client, |
|
1004 | + $encryption_algorithms_client_to_server, $mac_algorithms_client_to_server, $compression_algorithms_client_to_server; |
|
1005 | 1005 | |
1006 | 1006 | if (empty($str_kex_algorithms)) { |
1007 | 1007 | $str_kex_algorithms = implode(',', $kex_algorithms); |
@@ -1171,20 +1171,20 @@ discard block |
||
1171 | 1171 | // http://tools.ietf.org/html/rfc2412, appendex E |
1172 | 1172 | case 'diffie-hellman-group1-sha1': |
1173 | 1173 | $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . |
1174 | - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
1175 | - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
1176 | - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; |
|
1174 | + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
1175 | + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
1176 | + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; |
|
1177 | 1177 | break; |
1178 | 1178 | // see http://tools.ietf.org/html/rfc3526#section-3 |
1179 | 1179 | case 'diffie-hellman-group14-sha1': |
1180 | 1180 | $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . |
1181 | - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
1182 | - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
1183 | - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' . |
|
1184 | - '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' . |
|
1185 | - '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' . |
|
1186 | - 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' . |
|
1187 | - '3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'; |
|
1181 | + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
1182 | + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
1183 | + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' . |
|
1184 | + '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' . |
|
1185 | + '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' . |
|
1186 | + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' . |
|
1187 | + '3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'; |
|
1188 | 1188 | break; |
1189 | 1189 | } |
1190 | 1190 | |
@@ -2413,7 +2413,7 @@ discard block |
||
2413 | 2413 | $current = strtok(microtime(), ' ') + strtok(''); |
2414 | 2414 | $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; |
2415 | 2415 | $message_number = '<- ' . $message_number . |
2416 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2416 | + ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2417 | 2417 | $this->_append_log($message_number, $payload); |
2418 | 2418 | $this->last_packet = $current; |
2419 | 2419 | } |
@@ -2782,7 +2782,7 @@ discard block |
||
2782 | 2782 | $current = strtok(microtime(), ' ') + strtok(''); |
2783 | 2783 | $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; |
2784 | 2784 | $message_number = '-> ' . $message_number . |
2785 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2785 | + ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2786 | 2786 | $this->_append_log($message_number, $data); |
2787 | 2787 | $this->last_packet = $current; |
2788 | 2788 | } |
@@ -3024,12 +3024,12 @@ discard block |
||
3024 | 3024 | } |
3025 | 3025 | $fragment = $this->_string_shift($current_log, $short_width); |
3026 | 3026 | $hex = substr( |
3027 | - preg_replace( |
|
3028 | - '#(.)#es', |
|
3029 | - '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
3030 | - $fragment), |
|
3031 | - strlen($boundary) |
|
3032 | - ); |
|
3027 | + preg_replace( |
|
3028 | + '#(.)#es', |
|
3029 | + '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
3030 | + $fragment), |
|
3031 | + strlen($boundary) |
|
3032 | + ); |
|
3033 | 3033 | // replace non ASCII printable characters with dots |
3034 | 3034 | // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters |
3035 | 3035 | // also replace < with a . since < messes up the output on web browsers |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @access private |
75 | 75 | */ |
76 | 76 | define('NET_SSH2_MASK_CONSTRUCTOR', 0x00000001); |
77 | -define('NET_SSH2_MASK_LOGIN_REQ', 0x00000002); |
|
78 | -define('NET_SSH2_MASK_LOGIN', 0x00000004); |
|
79 | -define('NET_SSH2_MASK_SHELL', 0x00000008); |
|
77 | +define('NET_SSH2_MASK_LOGIN_REQ', 0x00000002); |
|
78 | +define('NET_SSH2_MASK_LOGIN', 0x00000004); |
|
79 | +define('NET_SSH2_MASK_SHELL', 0x00000008); |
|
80 | 80 | /**#@-*/ |
81 | 81 | |
82 | 82 | /**#@+ |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @access private |
97 | 97 | */ |
98 | 98 | define('NET_SSH2_CHANNEL_EXEC', 0); // PuTTy uses 0x100 |
99 | -define('NET_SSH2_CHANNEL_SHELL',1); |
|
99 | +define('NET_SSH2_CHANNEL_SHELL', 1); |
|
100 | 100 | /**#@-*/ |
101 | 101 | |
102 | 102 | /**#@+ |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * Returns the message numbers |
108 | 108 | */ |
109 | -define('NET_SSH2_LOG_SIMPLE', 1); |
|
109 | +define('NET_SSH2_LOG_SIMPLE', 1); |
|
110 | 110 | /** |
111 | 111 | * Returns the message content |
112 | 112 | */ |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | /** |
129 | 129 | * Returns when a string matching $expect exactly is found |
130 | 130 | */ |
131 | -define('NET_SSH2_READ_SIMPLE', 1); |
|
131 | +define('NET_SSH2_READ_SIMPLE', 1); |
|
132 | 132 | /** |
133 | 133 | * Returns when a string matching the regular expression $expect is found |
134 | 134 | */ |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | } |
834 | 834 | $elapsed = strtok(microtime(), ' ') + strtok('') - $start; |
835 | 835 | |
836 | - $timeout-= $elapsed; |
|
836 | + $timeout -= $elapsed; |
|
837 | 837 | |
838 | 838 | if ($timeout <= 0) { |
839 | 839 | user_error(rtrim("Cannot connect to $host. Timeout error")); |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | $extra = ''; |
865 | 865 | while (!feof($this->fsock) && !preg_match('#^SSH-(\d\.\d+)#', $temp, $matches)) { |
866 | 866 | if (substr($temp, -2) == "\r\n") { |
867 | - $extra.= $temp; |
|
867 | + $extra .= $temp; |
|
868 | 868 | $temp = ''; |
869 | 869 | } |
870 | - $temp.= fgets($this->fsock, 255); |
|
870 | + $temp .= fgets($this->fsock, 255); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | if (feof($this->fsock)) { |
@@ -886,12 +886,12 @@ discard block |
||
886 | 886 | } |
887 | 887 | |
888 | 888 | if (!empty($ext)) { |
889 | - $this->identifier.= ' (' . implode(', ', $ext) . ')'; |
|
889 | + $this->identifier .= ' ('.implode(', ', $ext).')'; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | if (defined('NET_SSH2_LOGGING')) { |
893 | - $this->_append_log('<-', $extra . $temp); |
|
894 | - $this->_append_log('->', $this->identifier . "\r\n"); |
|
893 | + $this->_append_log('<-', $extra.$temp); |
|
894 | + $this->_append_log('->', $this->identifier."\r\n"); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | $this->server_identifier = trim($temp, "\r\n"); |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | return; |
905 | 905 | } |
906 | 906 | |
907 | - fputs($this->fsock, $this->identifier . "\r\n"); |
|
907 | + fputs($this->fsock, $this->identifier."\r\n"); |
|
908 | 908 | |
909 | 909 | $response = $this->_get_binary_packet(); |
910 | 910 | if ($response === false) { |
@@ -947,41 +947,41 @@ discard block |
||
947 | 947 | 'arcfour256', |
948 | 948 | 'arcfour128', |
949 | 949 | |
950 | - 'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key |
|
950 | + 'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key |
|
951 | 951 | |
952 | 952 | // CTR modes from <http://tools.ietf.org/html/rfc4344#section-4>: |
953 | - 'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key |
|
954 | - 'aes192-ctr', // RECOMMENDED AES with 192-bit key |
|
955 | - 'aes256-ctr', // RECOMMENDED AES with 256-bit key |
|
953 | + 'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key |
|
954 | + 'aes192-ctr', // RECOMMENDED AES with 192-bit key |
|
955 | + 'aes256-ctr', // RECOMMENDED AES with 256-bit key |
|
956 | 956 | |
957 | - 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode |
|
957 | + 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode |
|
958 | 958 | |
959 | 959 | 'twofish128-ctr', // OPTIONAL Twofish in SDCTR mode, with 128-bit key |
960 | 960 | 'twofish192-ctr', // OPTIONAL Twofish with 192-bit key |
961 | 961 | 'twofish256-ctr', // OPTIONAL Twofish with 256-bit key |
962 | 962 | |
963 | - 'aes128-cbc', // RECOMMENDED AES with a 128-bit key |
|
964 | - 'aes192-cbc', // OPTIONAL AES with a 192-bit key |
|
965 | - 'aes256-cbc', // OPTIONAL AES in CBC mode, with a 256-bit key |
|
963 | + 'aes128-cbc', // RECOMMENDED AES with a 128-bit key |
|
964 | + 'aes192-cbc', // OPTIONAL AES with a 192-bit key |
|
965 | + 'aes256-cbc', // OPTIONAL AES in CBC mode, with a 256-bit key |
|
966 | 966 | |
967 | - 'blowfish-cbc', // OPTIONAL Blowfish in CBC mode |
|
967 | + 'blowfish-cbc', // OPTIONAL Blowfish in CBC mode |
|
968 | 968 | |
969 | 969 | 'twofish128-cbc', // OPTIONAL Twofish with a 128-bit key |
970 | 970 | 'twofish192-cbc', // OPTIONAL Twofish with a 192-bit key |
971 | 971 | 'twofish256-cbc', |
972 | - 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" |
|
972 | + 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" |
|
973 | 973 | // (this is being retained for historical reasons) |
974 | - '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode |
|
974 | + '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode |
|
975 | 975 | |
976 | - '3des-cbc', // REQUIRED three-key 3DES in CBC mode |
|
976 | + '3des-cbc', // REQUIRED three-key 3DES in CBC mode |
|
977 | 977 | 'none' // OPTIONAL no encryption; NOT RECOMMENDED |
978 | 978 | ); |
979 | 979 | |
980 | 980 | static $mac_algorithms = array( |
981 | 981 | 'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20) |
982 | - 'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20) |
|
983 | - 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) |
|
984 | - 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) |
|
982 | + 'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20) |
|
983 | + 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) |
|
984 | + 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) |
|
985 | 985 | 'none' // OPTIONAL no MAC; NOT RECOMMENDED |
986 | 986 | ); |
987 | 987 | |
@@ -1170,20 +1170,20 @@ discard block |
||
1170 | 1170 | // see http://tools.ietf.org/html/rfc2409#section-6.2 and |
1171 | 1171 | // http://tools.ietf.org/html/rfc2412, appendex E |
1172 | 1172 | case 'diffie-hellman-group1-sha1': |
1173 | - $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . |
|
1174 | - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
1175 | - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
1173 | + $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74'. |
|
1174 | + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437'. |
|
1175 | + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED'. |
|
1176 | 1176 | 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; |
1177 | 1177 | break; |
1178 | 1178 | // see http://tools.ietf.org/html/rfc3526#section-3 |
1179 | 1179 | case 'diffie-hellman-group14-sha1': |
1180 | - $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . |
|
1181 | - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . |
|
1182 | - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . |
|
1183 | - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' . |
|
1184 | - '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' . |
|
1185 | - '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' . |
|
1186 | - 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' . |
|
1180 | + $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74'. |
|
1181 | + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437'. |
|
1182 | + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED'. |
|
1183 | + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05'. |
|
1184 | + '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB'. |
|
1185 | + '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B'. |
|
1186 | + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718'. |
|
1187 | 1187 | '3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'; |
1188 | 1188 | break; |
1189 | 1189 | } |
@@ -1454,15 +1454,15 @@ discard block |
||
1454 | 1454 | $this->encrypt->enableContinuousBuffer(); |
1455 | 1455 | $this->encrypt->disablePadding(); |
1456 | 1456 | |
1457 | - $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'A' . $this->session_id); |
|
1457 | + $iv = $kexHash->hash($keyBytes.$this->exchange_hash.'A'.$this->session_id); |
|
1458 | 1458 | while ($this->encrypt_block_size > strlen($iv)) { |
1459 | - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); |
|
1459 | + $iv .= $kexHash->hash($keyBytes.$this->exchange_hash.$iv); |
|
1460 | 1460 | } |
1461 | 1461 | $this->encrypt->setIV(substr($iv, 0, $this->encrypt_block_size)); |
1462 | 1462 | |
1463 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'C' . $this->session_id); |
|
1463 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'C'.$this->session_id); |
|
1464 | 1464 | while ($encryptKeyLength > strlen($key)) { |
1465 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
1465 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
1466 | 1466 | } |
1467 | 1467 | $this->encrypt->setKey(substr($key, 0, $encryptKeyLength)); |
1468 | 1468 | } |
@@ -1471,15 +1471,15 @@ discard block |
||
1471 | 1471 | $this->decrypt->enableContinuousBuffer(); |
1472 | 1472 | $this->decrypt->disablePadding(); |
1473 | 1473 | |
1474 | - $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'B' . $this->session_id); |
|
1474 | + $iv = $kexHash->hash($keyBytes.$this->exchange_hash.'B'.$this->session_id); |
|
1475 | 1475 | while ($this->decrypt_block_size > strlen($iv)) { |
1476 | - $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); |
|
1476 | + $iv .= $kexHash->hash($keyBytes.$this->exchange_hash.$iv); |
|
1477 | 1477 | } |
1478 | 1478 | $this->decrypt->setIV(substr($iv, 0, $this->decrypt_block_size)); |
1479 | 1479 | |
1480 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'D' . $this->session_id); |
|
1480 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'D'.$this->session_id); |
|
1481 | 1481 | while ($decryptKeyLength > strlen($key)) { |
1482 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
1482 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
1483 | 1483 | } |
1484 | 1484 | $this->decrypt->setKey(substr($key, 0, $decryptKeyLength)); |
1485 | 1485 | } |
@@ -1553,15 +1553,15 @@ discard block |
||
1553 | 1553 | $this->hmac_size = 12; |
1554 | 1554 | } |
1555 | 1555 | |
1556 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'E' . $this->session_id); |
|
1556 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'E'.$this->session_id); |
|
1557 | 1557 | while ($createKeyLength > strlen($key)) { |
1558 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
1558 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
1559 | 1559 | } |
1560 | 1560 | $this->hmac_create->setKey(substr($key, 0, $createKeyLength)); |
1561 | 1561 | |
1562 | - $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'F' . $this->session_id); |
|
1562 | + $key = $kexHash->hash($keyBytes.$this->exchange_hash.'F'.$this->session_id); |
|
1563 | 1563 | while ($checkKeyLength > strlen($key)) { |
1564 | - $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); |
|
1564 | + $key .= $kexHash->hash($keyBytes.$this->exchange_hash.$key); |
|
1565 | 1565 | } |
1566 | 1566 | $this->hmac_check->setKey(substr($key, 0, $checkKeyLength)); |
1567 | 1567 | |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | $this->message_number_log[count($this->message_number_log) - 1] = 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'; |
1727 | 1727 | } |
1728 | 1728 | extract(unpack('Nlength', $this->_string_shift($response, 4))); |
1729 | - $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . utf8_decode($this->_string_shift($response, $length)); |
|
1729 | + $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: '.utf8_decode($this->_string_shift($response, $length)); |
|
1730 | 1730 | return $this->_disconnect(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER); |
1731 | 1731 | case NET_SSH2_MSG_USERAUTH_FAILURE: |
1732 | 1732 | // can we use keyboard-interactive authentication? if not then either the login is bad or the server employees |
@@ -1858,8 +1858,8 @@ discard block |
||
1858 | 1858 | // see http://tools.ietf.org/html/rfc4256#section-3.4 |
1859 | 1859 | $packet = $logged = pack('CN', NET_SSH2_MSG_USERAUTH_INFO_RESPONSE, count($responses)); |
1860 | 1860 | for ($i = 0; $i < count($responses); $i++) { |
1861 | - $packet.= pack('Na*', strlen($responses[$i]), $responses[$i]); |
|
1862 | - $logged.= pack('Na*', strlen('dummy-answer'), 'dummy-answer'); |
|
1861 | + $packet .= pack('Na*', strlen($responses[$i]), $responses[$i]); |
|
1862 | + $logged .= pack('Na*', strlen('dummy-answer'), 'dummy-answer'); |
|
1863 | 1863 | } |
1864 | 1864 | |
1865 | 1865 | if (!$this->_send_binary_packet($packet)) { |
@@ -1924,7 +1924,7 @@ discard block |
||
1924 | 1924 | ); |
1925 | 1925 | $part2 = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publickey), $publickey); |
1926 | 1926 | |
1927 | - $packet = $part1 . chr(0) . $part2; |
|
1927 | + $packet = $part1.chr(0).$part2; |
|
1928 | 1928 | if (!$this->_send_binary_packet($packet)) { |
1929 | 1929 | return false; |
1930 | 1930 | } |
@@ -1940,7 +1940,7 @@ discard block |
||
1940 | 1940 | switch ($type) { |
1941 | 1941 | case NET_SSH2_MSG_USERAUTH_FAILURE: |
1942 | 1942 | extract(unpack('Nlength', $this->_string_shift($response, 4))); |
1943 | - $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: ' . $this->_string_shift($response, $length); |
|
1943 | + $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: '.$this->_string_shift($response, $length); |
|
1944 | 1944 | return false; |
1945 | 1945 | case NET_SSH2_MSG_USERAUTH_PK_OK: |
1946 | 1946 | // we'll just take it on faith that the public key blob and the public key algorithm name are as |
@@ -1954,11 +1954,11 @@ discard block |
||
1954 | 1954 | } |
1955 | 1955 | } |
1956 | 1956 | |
1957 | - $packet = $part1 . chr(1) . $part2; |
|
1957 | + $packet = $part1.chr(1).$part2; |
|
1958 | 1958 | $privatekey->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); |
1959 | 1959 | $signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet)); |
1960 | 1960 | $signature = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($signature), $signature); |
1961 | - $packet.= pack('Na*', strlen($signature), $signature); |
|
1961 | + $packet .= pack('Na*', strlen($signature), $signature); |
|
1962 | 1962 | |
1963 | 1963 | if (!$this->_send_binary_packet($packet)) { |
1964 | 1964 | return false; |
@@ -2120,7 +2120,7 @@ discard block |
||
2120 | 2120 | if (is_callable($callback)) { |
2121 | 2121 | $callback($temp); |
2122 | 2122 | } else { |
2123 | - $output.= $temp; |
|
2123 | + $output .= $temp; |
|
2124 | 2124 | } |
2125 | 2125 | } |
2126 | 2126 | } |
@@ -2248,7 +2248,7 @@ discard block |
||
2248 | 2248 | return $response ? $this->_string_shift($this->interactiveBuffer, strlen($this->interactiveBuffer)) : false; |
2249 | 2249 | } |
2250 | 2250 | |
2251 | - $this->interactiveBuffer.= $response; |
|
2251 | + $this->interactiveBuffer .= $response; |
|
2252 | 2252 | } |
2253 | 2253 | } |
2254 | 2254 | |
@@ -2384,12 +2384,12 @@ discard block |
||
2384 | 2384 | $buffer = ''; |
2385 | 2385 | while ($remaining_length > 0) { |
2386 | 2386 | $temp = fread($this->fsock, $remaining_length); |
2387 | - $buffer.= $temp; |
|
2388 | - $remaining_length-= strlen($temp); |
|
2387 | + $buffer .= $temp; |
|
2388 | + $remaining_length -= strlen($temp); |
|
2389 | 2389 | } |
2390 | 2390 | $stop = strtok(microtime(), ' ') + strtok(''); |
2391 | 2391 | if (strlen($buffer)) { |
2392 | - $raw.= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; |
|
2392 | + $raw .= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; |
|
2393 | 2393 | } |
2394 | 2394 | |
2395 | 2395 | $payload = $this->_string_shift($raw, $packet_length - $padding_length - 1); |
@@ -2397,7 +2397,7 @@ discard block |
||
2397 | 2397 | |
2398 | 2398 | if ($this->hmac_check !== false) { |
2399 | 2399 | $hmac = fread($this->fsock, $this->hmac_size); |
2400 | - if ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload . $padding))) { |
|
2400 | + if ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload.$padding))) { |
|
2401 | 2401 | user_error('Invalid HMAC'); |
2402 | 2402 | return false; |
2403 | 2403 | } |
@@ -2411,9 +2411,9 @@ discard block |
||
2411 | 2411 | |
2412 | 2412 | if (defined('NET_SSH2_LOGGING')) { |
2413 | 2413 | $current = strtok(microtime(), ' ') + strtok(''); |
2414 | - $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; |
|
2415 | - $message_number = '<- ' . $message_number . |
|
2416 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2414 | + $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN ('.ord($payload[0]).')'; |
|
2415 | + $message_number = '<- '.$message_number. |
|
2416 | + ' (since last: '.round($current - $this->last_packet, 4).', network: '.round($stop - $start, 4).'s)'; |
|
2417 | 2417 | $this->_append_log($message_number, $payload); |
2418 | 2418 | $this->last_packet = $current; |
2419 | 2419 | } |
@@ -2436,7 +2436,7 @@ discard block |
||
2436 | 2436 | case NET_SSH2_MSG_DISCONNECT: |
2437 | 2437 | $this->_string_shift($payload, 1); |
2438 | 2438 | extract(unpack('Nreason_code/Nlength', $this->_string_shift($payload, 8))); |
2439 | - $this->errors[] = 'SSH_MSG_DISCONNECT: ' . $this->disconnect_reasons[$reason_code] . "\r\n" . utf8_decode($this->_string_shift($payload, $length)); |
|
2439 | + $this->errors[] = 'SSH_MSG_DISCONNECT: '.$this->disconnect_reasons[$reason_code]."\r\n".utf8_decode($this->_string_shift($payload, $length)); |
|
2440 | 2440 | $this->bitmask = 0; |
2441 | 2441 | return false; |
2442 | 2442 | case NET_SSH2_MSG_IGNORE: |
@@ -2445,7 +2445,7 @@ discard block |
||
2445 | 2445 | case NET_SSH2_MSG_DEBUG: |
2446 | 2446 | $this->_string_shift($payload, 2); |
2447 | 2447 | extract(unpack('Nlength', $this->_string_shift($payload, 4))); |
2448 | - $this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode($this->_string_shift($payload, $length)); |
|
2448 | + $this->errors[] = 'SSH_MSG_DEBUG: '.utf8_decode($this->_string_shift($payload, $length)); |
|
2449 | 2449 | $payload = $this->_get_binary_packet(); |
2450 | 2450 | break; |
2451 | 2451 | case NET_SSH2_MSG_UNIMPLEMENTED: |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 |
2475 | 2475 | $this->_string_shift($payload, 1); |
2476 | 2476 | extract(unpack('Nlength', $this->_string_shift($payload))); |
2477 | - $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . utf8_decode($this->_string_shift($payload, $length)); |
|
2477 | + $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: '.utf8_decode($this->_string_shift($payload, $length)); |
|
2478 | 2478 | |
2479 | 2479 | if (!$this->_send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) { |
2480 | 2480 | return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); |
@@ -2485,7 +2485,7 @@ discard block |
||
2485 | 2485 | case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1 |
2486 | 2486 | $this->_string_shift($payload, 1); |
2487 | 2487 | extract(unpack('N', $this->_string_shift($payload, 4))); |
2488 | - $this->errors[] = 'SSH_MSG_CHANNEL_OPEN: ' . utf8_decode($this->_string_shift($payload, $length)); |
|
2488 | + $this->errors[] = 'SSH_MSG_CHANNEL_OPEN: '.utf8_decode($this->_string_shift($payload, $length)); |
|
2489 | 2489 | |
2490 | 2490 | $this->_string_shift($payload, 4); // skip over client channel |
2491 | 2491 | extract(unpack('Nserver_channel', $this->_string_shift($payload, 4))); |
@@ -2585,7 +2585,7 @@ discard block |
||
2585 | 2585 | return true; |
2586 | 2586 | } |
2587 | 2587 | $elapsed = strtok(microtime(), ' ') + strtok('') - $start; |
2588 | - $this->curTimeout-= $elapsed; |
|
2588 | + $this->curTimeout -= $elapsed; |
|
2589 | 2589 | } |
2590 | 2590 | |
2591 | 2591 | $response = $this->_get_binary_packet(); |
@@ -2598,13 +2598,13 @@ discard block |
||
2598 | 2598 | } |
2599 | 2599 | |
2600 | 2600 | // resize the window, if appropriate |
2601 | - $this->window_size_server_to_client[$client_channel]-= strlen($response); |
|
2601 | + $this->window_size_server_to_client[$client_channel] -= strlen($response); |
|
2602 | 2602 | if ($this->window_size_server_to_client[$client_channel] < 0) { |
2603 | 2603 | $packet = pack('CNN', NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST, $this->server_channels[$client_channel], $this->window_size); |
2604 | 2604 | if (!$this->_send_binary_packet($packet)) { |
2605 | 2605 | return false; |
2606 | 2606 | } |
2607 | - $this->window_size_server_to_client[$client_channel]+= $this->window_size; |
|
2607 | + $this->window_size_server_to_client[$client_channel] += $this->window_size; |
|
2608 | 2608 | } |
2609 | 2609 | |
2610 | 2610 | extract(unpack('Ctype/Nchannel', $this->_string_shift($response, 5))); |
@@ -2688,11 +2688,11 @@ discard block |
||
2688 | 2688 | case 'exit-signal': |
2689 | 2689 | $this->_string_shift($response, 1); |
2690 | 2690 | extract(unpack('Nlength', $this->_string_shift($response, 4))); |
2691 | - $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): ' . $this->_string_shift($response, $length); |
|
2691 | + $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): '.$this->_string_shift($response, $length); |
|
2692 | 2692 | $this->_string_shift($response, 1); |
2693 | 2693 | extract(unpack('Nlength', $this->_string_shift($response, 4))); |
2694 | 2694 | if ($length) { |
2695 | - $this->errors[count($this->errors)].= "\r\n" . $this->_string_shift($response, $length); |
|
2695 | + $this->errors[count($this->errors)] .= "\r\n".$this->_string_shift($response, $length); |
|
2696 | 2696 | } |
2697 | 2697 | case 'exit-status': |
2698 | 2698 | extract(unpack('Cfalse/Nexit_status', $this->_string_shift($response, 5))); |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | $this->curTimeout = 0; |
2714 | 2714 | |
2715 | 2715 | if ($this->bitmap & NET_SSH2_MASK_SHELL) { |
2716 | - $this->bitmap&= ~NET_SSH2_MASK_SHELL; |
|
2716 | + $this->bitmap &= ~NET_SSH2_MASK_SHELL; |
|
2717 | 2717 | } |
2718 | 2718 | if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) { |
2719 | 2719 | $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); |
@@ -2757,13 +2757,13 @@ discard block |
||
2757 | 2757 | // 4 (packet length) + 1 (padding length) + 4 (minimal padding amount) == 9 |
2758 | 2758 | $packet_length = strlen($data) + 9; |
2759 | 2759 | // round up to the nearest $this->encrypt_block_size |
2760 | - $packet_length+= (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; |
|
2760 | + $packet_length += (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; |
|
2761 | 2761 | // subtracting strlen($data) is obvious - subtracting 5 is necessary because of packet_length and padding_length |
2762 | 2762 | $padding_length = $packet_length - strlen($data) - 5; |
2763 | 2763 | $padding = crypt_random_string($padding_length); |
2764 | 2764 | |
2765 | 2765 | // we subtract 4 from packet_length because the packet_length field isn't supposed to include itself |
2766 | - $packet = pack('NCa*', $packet_length - 4, $padding_length, $data . $padding); |
|
2766 | + $packet = pack('NCa*', $packet_length - 4, $padding_length, $data.$padding); |
|
2767 | 2767 | |
2768 | 2768 | $hmac = $this->hmac_create !== false ? $this->hmac_create->hash(pack('Na*', $this->send_seq_no, $packet)) : ''; |
2769 | 2769 | $this->send_seq_no++; |
@@ -2772,7 +2772,7 @@ discard block |
||
2772 | 2772 | $packet = $this->encrypt->encrypt($packet); |
2773 | 2773 | } |
2774 | 2774 | |
2775 | - $packet.= $hmac; |
|
2775 | + $packet .= $hmac; |
|
2776 | 2776 | |
2777 | 2777 | $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 |
2778 | 2778 | $result = strlen($packet) == fputs($this->fsock, $packet); |
@@ -2780,9 +2780,9 @@ discard block |
||
2780 | 2780 | |
2781 | 2781 | if (defined('NET_SSH2_LOGGING')) { |
2782 | 2782 | $current = strtok(microtime(), ' ') + strtok(''); |
2783 | - $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; |
|
2784 | - $message_number = '-> ' . $message_number . |
|
2785 | - ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; |
|
2783 | + $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN ('.ord($data[0]).')'; |
|
2784 | + $message_number = '-> '.$message_number. |
|
2785 | + ' (since last: '.round($current - $this->last_packet, 4).', network: '.round($stop - $start, 4).'s)'; |
|
2786 | 2786 | $this->_append_log($message_number, $data); |
2787 | 2787 | $this->last_packet = $current; |
2788 | 2788 | } |
@@ -2809,10 +2809,10 @@ discard block |
||
2809 | 2809 | case NET_SSH2_LOG_COMPLEX: |
2810 | 2810 | $this->message_number_log[] = $message_number; |
2811 | 2811 | $this->_string_shift($message); |
2812 | - $this->log_size+= strlen($message); |
|
2812 | + $this->log_size += strlen($message); |
|
2813 | 2813 | $this->message_log[] = $message; |
2814 | 2814 | while ($this->log_size > NET_SSH2_LOG_MAX_SIZE) { |
2815 | - $this->log_size-= strlen(array_shift($this->message_log)); |
|
2815 | + $this->log_size -= strlen(array_shift($this->message_log)); |
|
2816 | 2816 | array_shift($this->message_number_log); |
2817 | 2817 | } |
2818 | 2818 | break; |
@@ -2820,7 +2820,7 @@ discard block |
||
2820 | 2820 | // passwords won't be filtered out and select other packets may not be correctly |
2821 | 2821 | // identified |
2822 | 2822 | case NET_SSH2_LOG_REALTIME: |
2823 | - echo "<pre>\r\n" . $this->_format_log(array($message), array($message_number)) . "\r\n</pre>\r\n"; |
|
2823 | + echo "<pre>\r\n".$this->_format_log(array($message), array($message_number))."\r\n</pre>\r\n"; |
|
2824 | 2824 | @flush(); |
2825 | 2825 | @ob_flush(); |
2826 | 2826 | break; |
@@ -2841,10 +2841,10 @@ discard block |
||
2841 | 2841 | $entry = $this->_format_log(array($message), array($message_number)); |
2842 | 2842 | if ($this->realtime_log_wrap) { |
2843 | 2843 | $temp = "<<< START >>>\r\n"; |
2844 | - $entry.= $temp; |
|
2844 | + $entry .= $temp; |
|
2845 | 2845 | fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); |
2846 | 2846 | } |
2847 | - $this->realtime_log_size+= strlen($entry); |
|
2847 | + $this->realtime_log_size += strlen($entry); |
|
2848 | 2848 | if ($this->realtime_log_size > NET_SSH2_LOG_MAX_SIZE) { |
2849 | 2849 | fseek($this->realtime_log_file, 0); |
2850 | 2850 | $this->realtime_log_size = strlen($entry); |
@@ -2912,7 +2912,7 @@ discard block |
||
2912 | 2912 | while (!is_bool($this->_get_channel_packet($client_channel))); |
2913 | 2913 | |
2914 | 2914 | if ($this->bitmap & NET_SSH2_MASK_SHELL) { |
2915 | - $this->bitmap&= ~NET_SSH2_MASK_SHELL; |
|
2915 | + $this->bitmap &= ~NET_SSH2_MASK_SHELL; |
|
2916 | 2916 | } |
2917 | 2917 | } |
2918 | 2918 | |
@@ -3015,18 +3015,18 @@ discard block |
||
3015 | 3015 | |
3016 | 3016 | $output = ''; |
3017 | 3017 | for ($i = 0; $i < count($message_log); $i++) { |
3018 | - $output.= $message_number_log[$i] . "\r\n"; |
|
3018 | + $output .= $message_number_log[$i]."\r\n"; |
|
3019 | 3019 | $current_log = $message_log[$i]; |
3020 | 3020 | $j = 0; |
3021 | 3021 | do { |
3022 | 3022 | if (strlen($current_log)) { |
3023 | - $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; |
|
3023 | + $output .= str_pad(dechex($j), 7, '0', STR_PAD_LEFT).'0 '; |
|
3024 | 3024 | } |
3025 | 3025 | $fragment = $this->_string_shift($current_log, $short_width); |
3026 | 3026 | $hex = substr( |
3027 | 3027 | preg_replace( |
3028 | 3028 | '#(.)#es', |
3029 | - '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
3029 | + '"'.$boundary.'" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', |
|
3030 | 3030 | $fragment), |
3031 | 3031 | strlen($boundary) |
3032 | 3032 | ); |
@@ -3034,10 +3034,10 @@ discard block |
||
3034 | 3034 | // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters |
3035 | 3035 | // also replace < with a . since < messes up the output on web browsers |
3036 | 3036 | $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); |
3037 | - $output.= str_pad($hex, $long_width - $short_width, ' ') . $raw . "\r\n"; |
|
3037 | + $output .= str_pad($hex, $long_width - $short_width, ' ').$raw."\r\n"; |
|
3038 | 3038 | $j++; |
3039 | 3039 | } while (strlen($current_log)); |
3040 | - $output.= "\r\n"; |
|
3040 | + $output .= "\r\n"; |
|
3041 | 3041 | } |
3042 | 3042 | |
3043 | 3043 | return $output; |
@@ -3219,8 +3219,7 @@ discard block |
||
3219 | 3219 | |
3220 | 3220 | if ($this->signature_validated) { |
3221 | 3221 | return $this->bitmap ? |
3222 | - $this->signature_format . ' ' . base64_encode($this->server_public_host_key) : |
|
3223 | - false; |
|
3222 | + $this->signature_format.' '.base64_encode($this->server_public_host_key) : false; |
|
3224 | 3223 | } |
3225 | 3224 | |
3226 | 3225 | $this->signature_validated = true; |
@@ -3320,7 +3319,7 @@ discard block |
||
3320 | 3319 | $s = $s->toBytes(); |
3321 | 3320 | |
3322 | 3321 | $h = pack('N4H*', 0x00302130, 0x0906052B, 0x0E03021A, 0x05000414, sha1($this->exchange_hash)); |
3323 | - $h = chr(0x01) . str_repeat(chr(0xFF), $nLength - 3 - strlen($h)) . $h; |
|
3322 | + $h = chr(0x01).str_repeat(chr(0xFF), $nLength - 3 - strlen($h)).$h; |
|
3324 | 3323 | |
3325 | 3324 | if ($s != $h) { |
3326 | 3325 | user_error('Bad server signature'); |
@@ -3332,7 +3331,7 @@ discard block |
||
3332 | 3331 | return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); |
3333 | 3332 | } |
3334 | 3333 | |
3335 | - return $this->signature_format . ' ' . base64_encode($this->server_public_host_key); |
|
3334 | + return $this->signature_format.' '.base64_encode($this->server_public_host_key); |
|
3336 | 3335 | } |
3337 | 3336 | |
3338 | 3337 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Returns the contents of the CSS defined by the plugin |
146 | - * @return array |
|
146 | + * @return string |
|
147 | 147 | */ |
148 | 148 | public function get_css() |
149 | 149 | { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Returns an HTML form (generated by FormValidator) of the plugin settings |
164 | - * @return string FormValidator-generated form |
|
164 | + * @return FormValidator FormValidator-generated form |
|
165 | 165 | */ |
166 | 166 | public function get_settings_form() |
167 | 167 | { |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param boolean $add_tool_link Whether to add a tool link or not |
384 | 384 | * (some tools might just offer a configuration section and act on the backend) |
385 | 385 | * |
386 | - * @return boolean False on error, null otherwise |
|
386 | + * @return boolean|null False on error, null otherwise |
|
387 | 387 | */ |
388 | 388 | public function install_course_fields($courseId, $add_tool_link = true) |
389 | 389 | { |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * tool on the course's homepage |
492 | 492 | * @param int $courseId |
493 | 493 | * |
494 | - * @return void |
|
494 | + * @return false|null |
|
495 | 495 | */ |
496 | 496 | public function uninstall_course_fields($courseId) |
497 | 497 | { |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * @param string $tabName |
597 | 597 | * @param string $url |
598 | 598 | * |
599 | - * @return boolean |
|
599 | + * @return false|string |
|
600 | 600 | */ |
601 | 601 | public function addTab($tabName, $url) |
602 | 602 | { |
@@ -591,13 +591,13 @@ |
||
591 | 591 | |
592 | 592 | } |
593 | 593 | |
594 | - /** |
|
595 | - * Add a tab to platform |
|
596 | - * @param string $tabName |
|
597 | - * @param string $url |
|
598 | - * |
|
599 | - * @return boolean |
|
600 | - */ |
|
594 | + /** |
|
595 | + * Add a tab to platform |
|
596 | + * @param string $tabName |
|
597 | + * @param string $url |
|
598 | + * |
|
599 | + * @return boolean |
|
600 | + */ |
|
601 | 601 | public function addTab($tabName, $url) |
602 | 602 | { |
603 | 603 | $sql = "SELECT * FROM settings_current |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $this->fields = $settings; |
61 | 61 | |
62 | 62 | global $language_files; |
63 | - $language_files[] = 'plugin_' . $this->get_name(); |
|
63 | + $language_files[] = 'plugin_'.$this->get_name(); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | { |
267 | 267 | $settings = $this->get_settings(); |
268 | 268 | foreach ($settings as $setting) { |
269 | - if ($setting['variable'] == ($this->get_name() . '_' . $name)) { |
|
269 | + if ($setting['variable'] == ($this->get_name().'_'.$name)) { |
|
270 | 270 | return $setting['selected_value']; |
271 | 271 | } |
272 | 272 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | $interfaceLanguageId = api_get_language_id($language_interface); |
323 | 323 | $interfaceLanguageInfo = api_get_language_info($interfaceLanguageId); |
324 | - $languageParentId = (!empty($interfaceLanguageInfo['parent_id'])?intval($interfaceLanguageInfo['parent_id']):0); |
|
324 | + $languageParentId = (!empty($interfaceLanguageInfo['parent_id']) ? intval($interfaceLanguageInfo['parent_id']) : 0); |
|
325 | 325 | |
326 | 326 | //1. Loading english if exists |
327 | 327 | $english_path = $root.$plugin_name."/lang/english.php"; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | if (!empty($this->course_settings)) { |
400 | 400 | foreach ($this->course_settings as $setting) { |
401 | 401 | $variable = $setting['name']; |
402 | - $value =''; |
|
402 | + $value = ''; |
|
403 | 403 | if (isset($setting['init_value'])) { |
404 | 404 | $value = ($setting['init_value']); |
405 | 405 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | |
612 | 612 | //Avoid Tab Name Spaces |
613 | 613 | $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName); |
614 | - $subkeytext = "Tabs" . $tabNameNoSpaces; |
|
614 | + $subkeytext = "Tabs".$tabNameNoSpaces; |
|
615 | 615 | |
616 | 616 | //Check if it is already added |
617 | 617 | $checkCondition = array( |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | return false; |
628 | 628 | } |
629 | 629 | //End Check |
630 | - $subkey = 'custom_tab_' . $tabNum; |
|
630 | + $subkey = 'custom_tab_'.$tabNum; |
|
631 | 631 | $attributes = array( |
632 | 632 | 'variable' => 'show_tabs', |
633 | 633 | 'subkey' => $subkey, |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | |
646 | 646 | //Save the id |
647 | 647 | $settings = $this->get_settings(); |
648 | - $setData = array ( |
|
648 | + $setData = array( |
|
649 | 649 | 'comment' => $subkey |
650 | 650 | ); |
651 | 651 | $whereCondition = array( |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | $i = 1; |
687 | 687 | foreach ($tabs as $row) { |
688 | 688 | $attributes = array( |
689 | - 'subkey' => 'custom_tab_' . $i |
|
689 | + 'subkey' => 'custom_tab_'.$i |
|
690 | 690 | ); |
691 | 691 | $this->updateTab($row['subkey'], $attributes); |
692 | 692 | $i++; |
@@ -626,7 +626,7 @@ |
||
626 | 626 | |
627 | 627 | /** |
628 | 628 | * Get first SMS plugin name |
629 | - * @return string|boolean |
|
629 | + * @return string|false |
|
630 | 630 | */ |
631 | 631 | public function getSMSPluginName() |
632 | 632 | { |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @param string $pluginName |
|
177 | - * @param int $urlId |
|
178 | - */ |
|
176 | + * @param string $pluginName |
|
177 | + * @param int $urlId |
|
178 | + */ |
|
179 | 179 | public function uninstall($pluginName, $urlId = null) |
180 | 180 | { |
181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @param string $region |
|
256 | - * @param string $template |
|
257 | - * @param bool $forced |
|
258 | - * |
|
259 | - * @return null|string |
|
260 | - */ |
|
255 | + * @param string $region |
|
256 | + * @param string $template |
|
257 | + * @param bool $forced |
|
258 | + * |
|
259 | + * @return null|string |
|
260 | + */ |
|
261 | 261 | public function load_region($region, $template, $forced = false) |
262 | 262 | { |
263 | 263 | if ($region == 'course_tool_plugin') { |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | //extra options |
426 | 426 | $plugin_settings = api_get_settings_params( |
427 | 427 | array( |
428 | - "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting') |
|
428 | + "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting') |
|
429 | 429 | ) |
430 | 430 | ); |
431 | 431 | $settings_filtered = array(); |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | if (!empty($obj->course_settings)) { |
531 | 531 | if (is_file(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_SMALL.'/'.$plugin_name.'.png')) { |
532 | 532 | $icon = Display::return_icon( |
533 | - $plugin_name . '.png', |
|
533 | + $plugin_name.'.png', |
|
534 | 534 | Security::remove_XSS($pluginTitle), |
535 | 535 | '', |
536 | 536 | ICON_SIZE_SMALL |
@@ -126,6 +126,7 @@ discard block |
||
126 | 126 | * Returns a temporary url to download files and/or folders. |
127 | 127 | * |
128 | 128 | * @param string|array $ids |
129 | + * @param string $tool |
|
129 | 130 | * @return string |
130 | 131 | */ |
131 | 132 | public static function download_url($ids, $tool) |
@@ -293,7 +294,7 @@ discard block |
||
293 | 294 | /** |
294 | 295 | * The name of the porfolio where to send. |
295 | 296 | * |
296 | - * @return type |
|
297 | + * @return string |
|
297 | 298 | */ |
298 | 299 | function get_portfolio() |
299 | 300 | { |
@@ -391,7 +392,6 @@ discard block |
||
391 | 392 | * Create a "send to portfolio" button |
392 | 393 | * |
393 | 394 | * @param string $tool The name of the tool: document, work. |
394 | - * @param int $c_id The id of the course |
|
395 | 395 | * @param int $id The id of the object |
396 | 396 | * @param array $attributes Html attributes |
397 | 397 | * @return \PortfolioShare |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | /** |
406 | 406 | * Returns the current secuirty token. Used to avoid see surfing attacks. |
407 | 407 | * |
408 | - * @return type |
|
408 | + * @return string |
|
409 | 409 | */ |
410 | 410 | static function security_token() |
411 | 411 | { |
@@ -420,6 +420,10 @@ discard block |
||
420 | 420 | protected $attributes = array(); |
421 | 421 | protected $tool = ''; |
422 | 422 | |
423 | + /** |
|
424 | + * @param string $tool |
|
425 | + * @param integer $id |
|
426 | + */ |
|
423 | 427 | function __construct($tool, $id, $attributes = array()) |
424 | 428 | { |
425 | 429 | $this->tool = $tool; |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | $attributes['z-index'] = 100000; |
483 | 483 | $s = ' '; |
484 | 484 | foreach ($attributes as $key => $value) { |
485 | - $s .= $key . '="' . $value . '" '; |
|
485 | + $s .= $key.'="'.$value.'" '; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $result = array(); |
489 | - $result[] = '<span ' . $s . ' >'; |
|
489 | + $result[] = '<span '.$s.' >'; |
|
490 | 490 | $result[] = '<span class="dropdown" >'; |
491 | 491 | $result[] = '<a href="#" data-toggle="dropdown" class="dropdown-toggle">'; |
492 | - $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL) . '<b class="caret"></b>'; |
|
492 | + $result[] = Display::return_icon('document_send.png', get_lang('Send'), array(), ICON_SIZE_SMALL).'<b class="caret"></b>'; |
|
493 | 493 | $result[] = '</a>'; |
494 | 494 | $result[] = '<ul class="dropdown-menu">'; |
495 | 495 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $parameters[PortfolioController::PARAM_TOOL] = $tool; |
506 | 506 | $url = api_get_path(WEB_CODE_PATH).'portfolio/share.php?'; |
507 | 507 | $result[] = '<li>'; |
508 | - $result[] = '<a href="' . $url . '">' . $portfolio->get_title() . '</a>'; |
|
508 | + $result[] = '<a href="'.$url.'">'.$portfolio->get_title().'</a>'; |
|
509 | 509 | $result[] = '</li>'; |
510 | 510 | } |
511 | 511 | $result[] = '</ul>'; |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function __construct($portfolio) |
566 | 566 | { |
567 | - $this->name = md5(__CLASS__) . '_' . $portfolio->get_name(); |
|
568 | - $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo') . ' ' . $portfolio->get_name(); |
|
567 | + $this->name = md5(__CLASS__).'_'.$portfolio->get_name(); |
|
568 | + $this->title = $portfolio->get_title() ? $portfolio->get_title() : get_lang('SendTo').' '.$portfolio->get_name(); |
|
569 | 569 | $this->portfolio = $portfolio; |
570 | 570 | } |
571 | 571 |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * @return array |
|
132 | + * @return string[] |
|
133 | 133 | */ |
134 | 134 | public function get_status_list() |
135 | 135 | { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * @param int $id |
274 | 274 | * |
275 | - * @return bool |
|
275 | + * @return null|false |
|
276 | 276 | */ |
277 | 277 | public function delete($id) |
278 | 278 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | case 'updated_at': |
58 | 58 | break; |
59 | 59 | case 'name': |
60 | - $val .= ' ' . get_lang('CopyLabelSuffix'); |
|
60 | + $val .= ' '.get_lang('CopyLabelSuffix'); |
|
61 | 61 | $new[$key] = $val; |
62 | 62 | break; |
63 | 63 | case 'created_at': |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | break; |
67 | 67 | case 'career_id': |
68 | 68 | if (!empty($career_id)) { |
69 | - $val = (int)$career_id; |
|
69 | + $val = (int) $career_id; |
|
70 | 70 | } |
71 | 71 | $new[$key] = $val; |
72 | 72 | break; |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | { |
148 | 148 | // Action links |
149 | 149 | echo '<div class="actions" style="margin-bottom:20px">'; |
150 | - echo '<a href="career_dashboard.php">' . Display::return_icon('back.png', |
|
151 | - get_lang('Back'), '', '32') . '</a>'; |
|
152 | - echo '<a href="' . api_get_self() . '?action=add">' . Display::return_icon('new_promotion.png', |
|
153 | - get_lang('Add'), '', '32') . '</a>'; |
|
154 | - echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'session/session_add.php">' . Display::return_icon('new_session.png', |
|
155 | - get_lang('AddSession'), '', '32') . '</a>'; |
|
150 | + echo '<a href="career_dashboard.php">'.Display::return_icon('back.png', |
|
151 | + get_lang('Back'), '', '32').'</a>'; |
|
152 | + echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_promotion.png', |
|
153 | + get_lang('Add'), '', '32').'</a>'; |
|
154 | + echo '<a href="'.api_get_path(WEB_CODE_PATH).'session/session_add.php">'.Display::return_icon('new_session.png', |
|
155 | + get_lang('AddSession'), '', '32').'</a>'; |
|
156 | 156 | echo '</div>'; |
157 | 157 | echo Display::grid_html('promotions'); |
158 | 158 | } |
@@ -15,6 +15,10 @@ |
||
15 | 15 | |
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | + |
|
19 | + /** |
|
20 | + * @param string $handler |
|
21 | + */ |
|
18 | 22 | public static function hasRight($handler) { |
19 | 23 | if (array_key_exists($handler, self::$rights_cache)) |
20 | 24 | return self::$rights_cache[$handler]; |
@@ -5,42 +5,42 @@ |
||
5 | 5 | * @deprecated Don't use this class |
6 | 6 | */ |
7 | 7 | class Rights { |
8 | - private static $rights_cache = array(); |
|
9 | - private static $rights = array ( |
|
10 | - 'show_tabs:reports' => |
|
11 | - array ( |
|
12 | - 'type' => 'const', |
|
13 | - 'const' => 'true' ) |
|
14 | - ); |
|
8 | + private static $rights_cache = array(); |
|
9 | + private static $rights = array ( |
|
10 | + 'show_tabs:reports' => |
|
11 | + array ( |
|
12 | + 'type' => 'const', |
|
13 | + 'const' => 'true' ) |
|
14 | + ); |
|
15 | 15 | |
16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | - // thus default return value is always true |
|
18 | - public static function hasRight($handler) { |
|
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | + // thus default return value is always true |
|
18 | + public static function hasRight($handler) { |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | 21 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
22 | + if (!array_key_exists($handler, self::$rights)) |
|
23 | + return true; // handler does not exists |
|
24 | 24 | |
25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
36 | - return true; |
|
37 | - self::$rights_cache[$handler] = $result; |
|
38 | - return $result; |
|
39 | - } |
|
25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | + if (Database::num_rows($result) > 0) |
|
28 | + $result = true; |
|
29 | + else |
|
30 | + $result = false; |
|
31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | + $result = self::$rights[$handler]['const']; |
|
33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
34 | + $result = self::$rights[$handler]['func'](); |
|
35 | + else // handler type not implemented |
|
36 | + return true; |
|
37 | + self::$rights_cache[$handler] = $result; |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - public static function hasRightClosePageWithError($handler) { |
|
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
44 | - } |
|
41 | + public static function hasRightClosePageWithError($handler) { |
|
42 | + if (hasRight($handler) == false) |
|
43 | + die("You are not allowed here"); //FIXME |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | */ |
7 | 7 | class Rights { |
8 | 8 | private static $rights_cache = array(); |
9 | - private static $rights = array ( |
|
9 | + private static $rights = array( |
|
10 | 10 | 'show_tabs:reports' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'type' => 'const', |
13 | 13 | 'const' => 'true' ) |
14 | 14 | ); |
@@ -16,31 +16,39 @@ |
||
16 | 16 | // warning the goal of this function is to enforce rights managment in Chamilo |
17 | 17 | // thus default return value is always true |
18 | 18 | public static function hasRight($handler) { |
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) { |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | + } |
|
21 | 22 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
23 | + if (!array_key_exists($handler, self::$rights)) { |
|
24 | + return true; |
|
25 | + } |
|
26 | + // handler does not exists |
|
24 | 27 | |
25 | 28 | if (self::$rights[$handler]['type'] == 'sql') { |
26 | 29 | $result = Database::query(self::$rights[$handler]['sql']); |
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
30 | + if (Database::num_rows($result) > 0) { |
|
31 | + $result = true; |
|
32 | + } else { |
|
33 | + $result = false; |
|
34 | + } |
|
35 | + } else if (self::$rights[$handler]['type'] == 'const') { |
|
36 | + $result = self::$rights[$handler]['const']; |
|
37 | + } else if (self::$rights[$handler]['type'] == 'func') { |
|
38 | + $result = self::$rights[$handler]['func'](); |
|
39 | + } else { |
|
40 | + // handler type not implemented |
|
36 | 41 | return true; |
42 | + } |
|
37 | 43 | self::$rights_cache[$handler] = $result; |
38 | 44 | return $result; |
39 | 45 | } |
40 | 46 | |
41 | 47 | public static function hasRightClosePageWithError($handler) { |
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
48 | + if (hasRight($handler) == false) { |
|
49 | + die("You are not allowed here"); |
|
50 | + } |
|
51 | + //FIXME |
|
44 | 52 | } |
45 | 53 | |
46 | 54 | } |
@@ -71,6 +71,10 @@ |
||
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Get the terms stored at database |
74 | + * @param string $prefix |
|
75 | + * @param string $course_code |
|
76 | + * @param string $tool_id |
|
77 | + * @param integer $ref_id |
|
74 | 78 | * @return array Array of terms |
75 | 79 | */ |
76 | 80 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * code |
9 | 9 | */ |
10 | -require_once dirname(__FILE__) . '/../../global.inc.php'; |
|
10 | +require_once dirname(__FILE__).'/../../global.inc.php'; |
|
11 | 11 | include_once 'xapian/XapianIndexer.class.php'; |
12 | 12 | |
13 | 13 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
40 | 40 | return FALSE; |
41 | 41 | |
42 | - require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
|
42 | + require_once api_get_path(LIBRARY_PATH).'search/xapian/XapianQuery.php'; |
|
43 | 43 | |
44 | 44 | // compare terms |
45 | 45 | $doc = $this->get_document($search_did); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | |
56 | 56 | // save it to search engine |
57 | 57 | foreach ($missing_terms as $term) { |
58 | - $this->add_term_to_doc($prefix . $term, $doc); |
|
58 | + $this->add_term_to_doc($prefix.$term, $doc); |
|
59 | 59 | } |
60 | 60 | foreach ($deprecated_terms as $term) { |
61 | - $this->remove_term_from_doc($prefix . $term, $doc); |
|
61 | + $this->remove_term_from_doc($prefix.$term, $doc); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | // don't do anything if no change |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return array Array of terms |
75 | 75 | */ |
76 | 76 | function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id) { |
77 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
77 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
78 | 78 | $terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id); |
79 | 79 | $prefix_terms = array(); |
80 | 80 | foreach ($terms as $term) { |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | $stored_terms = $this->get_terms_on_db($prefix, $course_code, $tool_id, $ref_id_high_level); |
37 | 37 | |
38 | 38 | // don't do anything if no change, verify only at DB, not the search engine |
39 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
40 | - return FALSE; |
|
39 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
40 | + return FALSE; |
|
41 | + } |
|
41 | 42 | |
42 | 43 | require_once api_get_path(LIBRARY_PATH) . 'search/xapian/XapianQuery.php'; |
43 | 44 | |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | $doc = $this->get_document($search_did); |
46 | 47 | $xapian_terms = xapian_get_doc_terms($doc, $prefix); |
47 | 48 | $xterms = array(); |
48 | - foreach ($xapian_terms as $xapian_term) |
|
49 | - $xterms[] = substr($xapian_term['name'], 1); |
|
49 | + foreach ($xapian_terms as $xapian_term) { |
|
50 | + $xterms[] = substr($xapian_term['name'], 1); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $dterms = $terms; |
52 | 54 |
@@ -23,6 +23,9 @@ discard block |
||
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | +/** |
|
27 | + * @param string $query_string |
|
28 | + */ |
|
26 | 29 | function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
27 | 30 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 31 | } |
@@ -30,7 +33,7 @@ discard block |
||
30 | 33 | /** |
31 | 34 | * Wrapper for getting boolean queries |
32 | 35 | * |
33 | - * @param string $query_string The term string |
|
36 | + * @param string $term |
|
34 | 37 | */ |
35 | 38 | function chamilo_get_boolean_query($term) { |
36 | 39 | return xapian_get_boolean_query($term); |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | * @param array extra Extra queries to join with. Optional |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function chamilo_query_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
21 | +function chamilo_query_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
22 | 22 | list($count, $results) = xapian_query($query_string, NULL, $offset, $length, $extra); |
23 | 23 | return chamilo_preprocess_results($results); |
24 | 24 | } |
25 | 25 | |
26 | -function chamilo_query_simple_query($query_string, $offset=0, $length=10, $extra=NULL) { |
|
26 | +function chamilo_query_simple_query($query_string, $offset = 0, $length = 10, $extra = NULL) { |
|
27 | 27 | return xapian_query($query_string, NULL, $offset, $length, $extra); |
28 | 28 | } |
29 | 29 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | function chamilo_preprocess_results($results) { |
43 | 43 | // group by toolid |
44 | 44 | $results_by_tool = array(); |
45 | - if (count($results)>0) { |
|
45 | + if (count($results) > 0) { |
|
46 | 46 | |
47 | 47 | foreach ($results as $key => $row) { |
48 | 48 | $results_by_tool[$row['toolid']][] = $row; |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $processed_results = array(); |
52 | 52 | foreach ($results_by_tool as $toolid => $rows) { |
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
53 | + $tool_processor_class = $toolid.'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH).'search/tool_processors/'.$tool_processor_class.'.class.php'; |
|
55 | 55 | if (file_exists($tool_processor_path)) { |
56 | 56 | require_once($tool_processor_path); |
57 | 57 | $tool_processor = new $tool_processor_class($rows); |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | * @param string $op |
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | -function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
|
74 | +function chamilo_join_queries($query1, $query2 = NULL, $op = 'or') { |
|
75 | 75 | return xapian_join_queries($query1, $query2, $op); |
76 | 76 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string $query_string The term string |
34 | 34 | */ |
35 | 35 | function chamilo_get_boolean_query($term) { |
36 | - return xapian_get_boolean_query($term); |
|
36 | + return xapian_get_boolean_query($term); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | $results_by_tool = array(); |
45 | 45 | if (count($results)>0) { |
46 | 46 | |
47 | - foreach ($results as $key => $row) { |
|
48 | - $results_by_tool[$row['toolid']][] = $row; |
|
49 | - } |
|
47 | + foreach ($results as $key => $row) { |
|
48 | + $results_by_tool[$row['toolid']][] = $row; |
|
49 | + } |
|
50 | 50 | |
51 | - $processed_results = array(); |
|
52 | - foreach ($results_by_tool as $toolid => $rows) { |
|
53 | - $tool_processor_class = $toolid .'_processor'; |
|
54 | - $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | - if (file_exists($tool_processor_path)) { |
|
56 | - require_once($tool_processor_path); |
|
57 | - $tool_processor = new $tool_processor_class($rows); |
|
58 | - $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | - } |
|
60 | - } |
|
51 | + $processed_results = array(); |
|
52 | + foreach ($results_by_tool as $toolid => $rows) { |
|
53 | + $tool_processor_class = $toolid .'_processor'; |
|
54 | + $tool_processor_path = api_get_path(LIBRARY_PATH) .'search/tool_processors/'. $tool_processor_class .'.class.php'; |
|
55 | + if (file_exists($tool_processor_path)) { |
|
56 | + require_once($tool_processor_path); |
|
57 | + $tool_processor = new $tool_processor_class($rows); |
|
58 | + $processed_results = array_merge($tool_processor->process(), $processed_results); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return array(count($processed_results), $processed_results); |
|
62 | + return array(count($processed_results), $processed_results); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -72,5 +72,5 @@ discard block |
||
72 | 72 | * @return XapianQuery query joined |
73 | 73 | */ |
74 | 74 | function chamilo_join_queries($query1, $query2=NULL, $op='or') { |
75 | - return xapian_join_queries($query1, $query2, $op); |
|
75 | + return xapian_join_queries($query1, $query2, $op); |
|
76 | 76 | } |