@@ -15,15 +15,15 @@ discard block |
||
| 15 | 15 | * @return ciphertext as byte-array (16 bytes) |
| 16 | 16 | */ |
| 17 | 17 | public static function cipher($input, $w) { // main cipher function [é5.1] |
| 18 | - $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) |
|
| 19 | - $Nr = count($w)/$Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys |
|
| 18 | + $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) |
|
| 19 | + $Nr = count($w) / $Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys |
|
| 20 | 20 | |
| 21 | - $state = array(); // initialise 4xNb byte-array 'state' with input [é3.4] |
|
| 22 | - for ($i=0; $i<4*$Nb; $i++) $state[$i%4][floor($i/4)] = $input[$i]; |
|
| 21 | + $state = array(); // initialise 4xNb byte-array 'state' with input [é3.4] |
|
| 22 | + for ($i = 0; $i < 4 * $Nb; $i++) $state[$i % 4][floor($i / 4)] = $input[$i]; |
|
| 23 | 23 | |
| 24 | 24 | $state = self::addRoundKey($state, $w, 0, $Nb); |
| 25 | 25 | |
| 26 | - for ($round=1; $round<$Nr; $round++) { // apply Nr rounds |
|
| 26 | + for ($round = 1; $round < $Nr; $round++) { // apply Nr rounds |
|
| 27 | 27 | $state = self::subBytes($state, $Nb); |
| 28 | 28 | $state = self::shiftRows($state, $Nb); |
| 29 | 29 | $state = self::mixColumns($state, $Nb); |
@@ -34,23 +34,23 @@ discard block |
||
| 34 | 34 | $state = self::shiftRows($state, $Nb); |
| 35 | 35 | $state = self::addRoundKey($state, $w, $Nr, $Nb); |
| 36 | 36 | |
| 37 | - $output = array(4*$Nb); // convert state to 1-d array before returning [é3.4] |
|
| 38 | - for ($i=0; $i<4*$Nb; $i++) $output[$i] = $state[$i%4][floor($i/4)]; |
|
| 37 | + $output = array(4 * $Nb); // convert state to 1-d array before returning [é3.4] |
|
| 38 | + for ($i = 0; $i < 4 * $Nb; $i++) $output[$i] = $state[$i % 4][floor($i / 4)]; |
|
| 39 | 39 | |
| 40 | 40 | return $output; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | private static function addRoundKey($state, $w, $rnd, $Nb) { // xor Round Key into state S [é5.1.4] |
| 44 | - for ($r=0; $r<4; $r++) { |
|
| 45 | - for ($c=0; $c<$Nb; $c++) $state[$r][$c] ^= $w[$rnd*4+$c][$r]; |
|
| 44 | + for ($r = 0; $r < 4; $r++) { |
|
| 45 | + for ($c = 0; $c < $Nb; $c++) $state[$r][$c] ^= $w[$rnd * 4 + $c][$r]; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | return $state; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | private static function subBytes($s, $Nb) { // apply SBox to state S [é5.1.1] |
| 52 | - for ($r=0; $r<4; $r++) { |
|
| 53 | - for ($c=0; $c<$Nb; $c++) $s[$r][$c] = self::$sBox[$s[$r][$c]]; |
|
| 52 | + for ($r = 0; $r < 4; $r++) { |
|
| 53 | + for ($c = 0; $c < $Nb; $c++) $s[$r][$c] = self::$sBox[$s[$r][$c]]; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return $s; |
@@ -58,20 +58,20 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private static function shiftRows($s, $Nb) { // shift row r of state S left by r bytes [é5.1.2] |
| 60 | 60 | $t = array(4); |
| 61 | - for ($r=1; $r<4; $r++) { |
|
| 62 | - for ($c=0; $c<4; $c++) $t[$c] = $s[$r][($c+$r)%$Nb]; // shift into temp copy |
|
| 63 | - for ($c=0; $c<4; $c++) $s[$r][$c] = $t[$c]; // and copy back |
|
| 61 | + for ($r = 1; $r < 4; $r++) { |
|
| 62 | + for ($c = 0; $c < 4; $c++) $t[$c] = $s[$r][($c + $r) % $Nb]; // shift into temp copy |
|
| 63 | + for ($c = 0; $c < 4; $c++) $s[$r][$c] = $t[$c]; // and copy back |
|
| 64 | 64 | } // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES): |
| 65 | - return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf |
|
| 65 | + return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private static function mixColumns($s, $Nb) { // combine bytes of each col of state S [é5.1.3] |
| 69 | - for ($c=0; $c<4; $c++) { |
|
| 70 | - $a = array(4); // 'a' is a copy of the current column from 's' |
|
| 71 | - $b = array(4); // 'b' is aé{02} in GF(2^8) |
|
| 72 | - for ($i=0; $i<4; $i++) { |
|
| 69 | + for ($c = 0; $c < 4; $c++) { |
|
| 70 | + $a = array(4); // 'a' is a copy of the current column from 's' |
|
| 71 | + $b = array(4); // 'b' is aé{02} in GF(2^8) |
|
| 72 | + for ($i = 0; $i < 4; $i++) { |
|
| 73 | 73 | $a[$i] = $s[$i][$c]; |
| 74 | - $b[$i] = $s[$i][$c]&0x80 ? $s[$i][$c]<<1 ^ 0x011b : $s[$i][$c]<<1; |
|
| 74 | + $b[$i] = $s[$i][$c] & 0x80 ? $s[$i][$c] << 1 ^ 0x011b : $s[$i][$c] << 1; |
|
| 75 | 75 | } |
| 76 | 76 | // a[n] ^ b[n] is aé{03} in GF(2^8) |
| 77 | 77 | $s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3 |
@@ -91,42 +91,42 @@ discard block |
||
| 91 | 91 | * @return key schedule as 2D byte-array (Nr+1 x Nb bytes) |
| 92 | 92 | */ |
| 93 | 93 | public static function keyExpansion($key) { // generate Key Schedule from Cipher Key [é5.2] |
| 94 | - $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) |
|
| 95 | - $Nk = count($key)/4; // key length (in words): 4/6/8 for 128/192/256-bit keys |
|
| 96 | - $Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys |
|
| 94 | + $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) |
|
| 95 | + $Nk = count($key) / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys |
|
| 96 | + $Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys |
|
| 97 | 97 | |
| 98 | 98 | $w = array(); |
| 99 | 99 | $temp = array(); |
| 100 | 100 | |
| 101 | - for ($i=0; $i<$Nk; $i++) { |
|
| 102 | - $r = array($key[4*$i], $key[4*$i+1], $key[4*$i+2], $key[4*$i+3]); |
|
| 101 | + for ($i = 0; $i < $Nk; $i++) { |
|
| 102 | + $r = array($key[4 * $i], $key[4 * $i + 1], $key[4 * $i + 2], $key[4 * $i + 3]); |
|
| 103 | 103 | $w[$i] = $r; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - for ($i=$Nk; $i<($Nb*($Nr+1)); $i++) { |
|
| 106 | + for ($i = $Nk; $i < ($Nb * ($Nr + 1)); $i++) { |
|
| 107 | 107 | $w[$i] = array(); |
| 108 | - for ($t=0; $t<4; $t++) $temp[$t] = $w[$i-1][$t]; |
|
| 108 | + for ($t = 0; $t < 4; $t++) $temp[$t] = $w[$i - 1][$t]; |
|
| 109 | 109 | if ($i % $Nk == 0) { |
| 110 | 110 | $temp = self::subWord(self::rotWord($temp)); |
| 111 | - for ($t=0; $t<4; $t++) $temp[$t] ^= self::$rCon[$i/$Nk][$t]; |
|
| 112 | - } elseif ($Nk > 6 && $i%$Nk == 4) { |
|
| 111 | + for ($t = 0; $t < 4; $t++) $temp[$t] ^= self::$rCon[$i / $Nk][$t]; |
|
| 112 | + } elseif ($Nk > 6 && $i % $Nk == 4) { |
|
| 113 | 113 | $temp = self::subWord($temp); |
| 114 | 114 | } |
| 115 | - for ($t=0; $t<4; $t++) $w[$i][$t] = $w[$i-$Nk][$t] ^ $temp[$t]; |
|
| 115 | + for ($t = 0; $t < 4; $t++) $w[$i][$t] = $w[$i - $Nk][$t] ^ $temp[$t]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | return $w; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | private static function subWord($w) { // apply SBox to 4-byte word w |
| 122 | - for ($i=0; $i<4; $i++) $w[$i] = self::$sBox[$w[$i]]; |
|
| 122 | + for ($i = 0; $i < 4; $i++) $w[$i] = self::$sBox[$w[$i]]; |
|
| 123 | 123 | |
| 124 | 124 | return $w; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | private static function rotWord($w) { // rotate 4-byte word w left by one byte |
| 128 | 128 | $tmp = $w[0]; |
| 129 | - for ($i=0; $i<3; $i++) $w[$i] = $w[$i+1]; |
|
| 129 | + for ($i = 0; $i < 3; $i++) $w[$i] = $w[$i + 1]; |
|
| 130 | 130 | $w[3] = $tmp; |
| 131 | 131 | |
| 132 | 132 | return $w; |
@@ -134,22 +134,22 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | // sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [é5.1.1] |
| 136 | 136 | private static $sBox = array( |
| 137 | - 0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76, |
|
| 138 | - 0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0, |
|
| 139 | - 0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15, |
|
| 140 | - 0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75, |
|
| 141 | - 0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84, |
|
| 142 | - 0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf, |
|
| 143 | - 0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8, |
|
| 144 | - 0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2, |
|
| 145 | - 0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73, |
|
| 146 | - 0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb, |
|
| 147 | - 0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79, |
|
| 148 | - 0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08, |
|
| 149 | - 0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a, |
|
| 150 | - 0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e, |
|
| 151 | - 0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf, |
|
| 152 | - 0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16); |
|
| 137 | + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, |
|
| 138 | + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, |
|
| 139 | + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, |
|
| 140 | + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, |
|
| 141 | + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, |
|
| 142 | + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, |
|
| 143 | + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, |
|
| 144 | + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, |
|
| 145 | + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, |
|
| 146 | + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, |
|
| 147 | + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, |
|
| 148 | + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, |
|
| 149 | + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, |
|
| 150 | + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, |
|
| 151 | + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, |
|
| 152 | + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16); |
|
| 153 | 153 | |
| 154 | 154 | // rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [é5.2] |
| 155 | 155 | private static $rCon = array( |
@@ -20,55 +20,55 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public static function encrypt($plaintext, $password, $nBits) |
| 22 | 22 | { |
| 23 | - $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
|
| 24 | - if (!($nBits==128 || $nBits==192 || $nBits==256)) return ''; // standard allows 128/192/256 bit keys |
|
| 23 | + $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
|
| 24 | + if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys |
|
| 25 | 25 | // note PHP (5) gives us plaintext and password in UTF8 encoding! |
| 26 | 26 | |
| 27 | 27 | // use AES itself to encrypt password to get cipher key (using plain password as source for |
| 28 | 28 | // key expansion) - gives us well encrypted key |
| 29 | - $nBytes = $nBits/8; // no bytes in key |
|
| 29 | + $nBytes = $nBits / 8; // no bytes in key |
|
| 30 | 30 | $pwBytes = array(); |
| 31 | - for ($i=0; $i<$nBytes; $i++) $pwBytes[$i] = ord(substr($password,$i,1)) & 0xff; |
|
| 31 | + for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff; |
|
| 32 | 32 | $key = Aes::cipher($pwBytes, Aes::keyExpansion($pwBytes)); |
| 33 | - $key = array_merge($key, array_slice($key, 0, $nBytes-16)); // expand key to 16/24/32 bytes long |
|
| 33 | + $key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long |
|
| 34 | 34 | |
| 35 | 35 | // initialise counter block (NIST SP800-38A §B.2): millisecond time-stamp for nonce in |
| 36 | 36 | // 1st 8 bytes, block counter in 2nd 8 bytes |
| 37 | 37 | $counterBlock = array(); |
| 38 | - $nonce = floor(microtime(true)*1000); // timestamp: milliseconds since 1-Jan-1970 |
|
| 39 | - $nonceSec = floor($nonce/1000); |
|
| 40 | - $nonceMs = $nonce%1000; |
|
| 38 | + $nonce = floor(microtime(true) * 1000); // timestamp: milliseconds since 1-Jan-1970 |
|
| 39 | + $nonceSec = floor($nonce / 1000); |
|
| 40 | + $nonceMs = $nonce % 1000; |
|
| 41 | 41 | // encode nonce with seconds in 1st 4 bytes, and (repeated) ms part filling 2nd 4 bytes |
| 42 | - for ($i=0; $i<4; $i++) $counterBlock[$i] = self::urs($nonceSec, $i*8) & 0xff; |
|
| 43 | - for ($i=0; $i<4; $i++) $counterBlock[$i+4] = $nonceMs & 0xff; |
|
| 42 | + for ($i = 0; $i < 4; $i++) $counterBlock[$i] = self::urs($nonceSec, $i * 8) & 0xff; |
|
| 43 | + for ($i = 0; $i < 4; $i++) $counterBlock[$i + 4] = $nonceMs & 0xff; |
|
| 44 | 44 | // and convert it to a string to go on the front of the ciphertext |
| 45 | 45 | $ctrTxt = ''; |
| 46 | - for ($i=0; $i<8; $i++) $ctrTxt .= chr($counterBlock[$i]); |
|
| 46 | + for ($i = 0; $i < 8; $i++) $ctrTxt .= chr($counterBlock[$i]); |
|
| 47 | 47 | |
| 48 | 48 | // generate key schedule - an expansion of the key into distinct Key Rounds for each round |
| 49 | 49 | $keySchedule = Aes::keyExpansion($key); |
| 50 | 50 | //print_r($keySchedule); |
| 51 | 51 | |
| 52 | - $blockCount = ceil(strlen($plaintext)/$blockSize); |
|
| 53 | - $ciphertxt = array(); // ciphertext as array of strings |
|
| 52 | + $blockCount = ceil(strlen($plaintext) / $blockSize); |
|
| 53 | + $ciphertxt = array(); // ciphertext as array of strings |
|
| 54 | 54 | |
| 55 | - for ($b=0; $b<$blockCount; $b++) { |
|
| 55 | + for ($b = 0; $b < $blockCount; $b++) { |
|
| 56 | 56 | // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) |
| 57 | 57 | // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB) |
| 58 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c] = self::urs($b, $c*8) & 0xff; |
|
| 59 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = self::urs($b/0x100000000, $c*8); |
|
| 58 | + for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff; |
|
| 59 | + for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs($b / 0x100000000, $c * 8); |
|
| 60 | 60 | |
| 61 | - $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block -- |
|
| 61 | + $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block -- |
|
| 62 | 62 | |
| 63 | 63 | // block size is reduced on final block |
| 64 | - $blockLength = $b<$blockCount-1 ? $blockSize : (strlen($plaintext)-1)%$blockSize+1; |
|
| 64 | + $blockLength = $b < $blockCount - 1 ? $blockSize : (strlen($plaintext) - 1) % $blockSize + 1; |
|
| 65 | 65 | $cipherByte = array(); |
| 66 | 66 | |
| 67 | - for ($i=0; $i<$blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte -- |
|
| 68 | - $cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b*$blockSize+$i, 1)); |
|
| 67 | + for ($i = 0; $i < $blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte -- |
|
| 68 | + $cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b * $blockSize + $i, 1)); |
|
| 69 | 69 | $cipherByte[$i] = chr($cipherByte[$i]); |
| 70 | 70 | } |
| 71 | - $ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext |
|
| 71 | + $ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // implode is more efficient than repeated string concatenation |
@@ -88,45 +88,45 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public static function decrypt($ciphertext, $password, $nBits) |
| 90 | 90 | { |
| 91 | - $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
|
| 92 | - if (!($nBits==128 || $nBits==192 || $nBits==256)) return ''; // standard allows 128/192/256 bit keys |
|
| 91 | + $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES |
|
| 92 | + if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys |
|
| 93 | 93 | $ciphertext = base64_decode($ciphertext); |
| 94 | 94 | |
| 95 | 95 | // use AES to encrypt password (mirroring encrypt routine) |
| 96 | - $nBytes = $nBits/8; // no bytes in key |
|
| 96 | + $nBytes = $nBits / 8; // no bytes in key |
|
| 97 | 97 | $pwBytes = array(); |
| 98 | - for ($i=0; $i<$nBytes; $i++) $pwBytes[$i] = ord(substr($password,$i,1)) & 0xff; |
|
| 98 | + for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff; |
|
| 99 | 99 | $key = Aes::cipher($pwBytes, Aes::keyExpansion($pwBytes)); |
| 100 | - $key = array_merge($key, array_slice($key, 0, $nBytes-16)); // expand key to 16/24/32 bytes long |
|
| 100 | + $key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long |
|
| 101 | 101 | |
| 102 | 102 | // recover nonce from 1st element of ciphertext |
| 103 | 103 | $counterBlock = array(); |
| 104 | 104 | $ctrTxt = substr($ciphertext, 0, 8); |
| 105 | - for ($i=0; $i<8; $i++) $counterBlock[$i] = ord(substr($ctrTxt,$i,1)); |
|
| 105 | + for ($i = 0; $i < 8; $i++) $counterBlock[$i] = ord(substr($ctrTxt, $i, 1)); |
|
| 106 | 106 | |
| 107 | 107 | // generate key schedule |
| 108 | 108 | $keySchedule = Aes::keyExpansion($key); |
| 109 | 109 | |
| 110 | 110 | // separate ciphertext into blocks (skipping past initial 8 bytes) |
| 111 | - $nBlocks = ceil((strlen($ciphertext)-8) / $blockSize); |
|
| 111 | + $nBlocks = ceil((strlen($ciphertext) - 8) / $blockSize); |
|
| 112 | 112 | $ct = array(); |
| 113 | - for ($b=0; $b<$nBlocks; $b++) $ct[$b] = substr($ciphertext, 8+$b*$blockSize, 16); |
|
| 114 | - $ciphertext = $ct; // ciphertext is now array of block-length strings |
|
| 113 | + for ($b = 0; $b < $nBlocks; $b++) $ct[$b] = substr($ciphertext, 8 + $b * $blockSize, 16); |
|
| 114 | + $ciphertext = $ct; // ciphertext is now array of block-length strings |
|
| 115 | 115 | |
| 116 | 116 | // plaintext will get generated block-by-block into array of block-length strings |
| 117 | 117 | $plaintxt = array(); |
| 118 | 118 | |
| 119 | - for ($b=0; $b<$nBlocks; $b++) { |
|
| 119 | + for ($b = 0; $b < $nBlocks; $b++) { |
|
| 120 | 120 | // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) |
| 121 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c] = self::urs($b, $c*8) & 0xff; |
|
| 122 | - for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = self::urs(($b+1)/0x100000000-1, $c*8) & 0xff; |
|
| 121 | + for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff; |
|
| 122 | + for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs(($b + 1) / 0x100000000 - 1, $c * 8) & 0xff; |
|
| 123 | 123 | |
| 124 | - $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // encrypt counter block |
|
| 124 | + $cipherCntr = Aes::cipher($counterBlock, $keySchedule); // encrypt counter block |
|
| 125 | 125 | |
| 126 | 126 | $plaintxtByte = array(); |
| 127 | - for ($i=0; $i<strlen($ciphertext[$b]); $i++) { |
|
| 127 | + for ($i = 0; $i < strlen($ciphertext[$b]); $i++) { |
|
| 128 | 128 | // -- xor plaintext with ciphered counter byte-by-byte -- |
| 129 | - $plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b],$i,1)); |
|
| 129 | + $plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b], $i, 1)); |
|
| 130 | 130 | $plaintxtByte[$i] = chr($plaintxtByte[$i]); |
| 131 | 131 | |
| 132 | 132 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // join array of blocks into single plaintext string |
| 137 | - $plaintext = implode('',$plaintxt); |
|
| 137 | + $plaintext = implode('', $plaintxt); |
|
| 138 | 138 | |
| 139 | 139 | return $plaintext; |
| 140 | 140 | } |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private static function urs($a, $b) |
| 150 | 150 | { |
| 151 | - $a &= 0xffffffff; $b &= 0x1f; // (bounds check) |
|
| 152 | - if ($a&0x80000000 && $b>0) { // if left-most bit set |
|
| 153 | - $a = ($a>>1) & 0x7fffffff; // right-shift one bit & clear left-most bit |
|
| 154 | - $a = $a >> ($b-1); // remaining right-shifts |
|
| 151 | + $a &= 0xffffffff; $b &= 0x1f; // (bounds check) |
|
| 152 | + if ($a & 0x80000000 && $b > 0) { // if left-most bit set |
|
| 153 | + $a = ($a >> 1) & 0x7fffffff; // right-shift one bit & clear left-most bit |
|
| 154 | + $a = $a >> ($b - 1); // remaining right-shifts |
|
| 155 | 155 | } else { // otherwise |
| 156 | - $a = ($a>>$b); // use normal right-shift |
|
| 156 | + $a = ($a >> $b); // use normal right-shift |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return $a; |
@@ -18,42 +18,42 @@ discard block |
||
| 18 | 18 | global $k; |
| 19 | 19 | //ENGLISH |
| 20 | 20 | $english_vals = array( |
| 21 | - array('at_modification',"Modification"), |
|
| 22 | - array('at_creation',"Creation"), |
|
| 23 | - array('at_delete',"Deletion"), |
|
| 24 | - array('at_pw',"Password changed."), |
|
| 25 | - array('at_category',"Group"), |
|
| 26 | - array('at_personnel',"Personnal"), |
|
| 27 | - array('at_description',"Description"), |
|
| 28 | - array('at_url',"Url"), |
|
| 29 | - array('at_login',"Login"), |
|
| 30 | - array('at_label',"Label") |
|
| 21 | + array('at_modification', "Modification"), |
|
| 22 | + array('at_creation', "Creation"), |
|
| 23 | + array('at_delete', "Deletion"), |
|
| 24 | + array('at_pw', "Password changed."), |
|
| 25 | + array('at_category', "Group"), |
|
| 26 | + array('at_personnel', "Personnal"), |
|
| 27 | + array('at_description', "Description"), |
|
| 28 | + array('at_url', "Url"), |
|
| 29 | + array('at_login', "Login"), |
|
| 30 | + array('at_label', "Label") |
|
| 31 | 31 | ); |
| 32 | 32 | //FRENCH |
| 33 | 33 | $french_vals = array( |
| 34 | - array('at_modification',"Modification"), |
|
| 35 | - array('at_creation',"Création"), |
|
| 36 | - array('at_delete',"Suppression"), |
|
| 37 | - array('at_pw',"Mot de passe changé."), |
|
| 38 | - array('at_category',"Group"), |
|
| 39 | - array('at_personnel',"Personnel"), |
|
| 40 | - array('at_description',"Description."), |
|
| 41 | - array('at_url',"Url"), |
|
| 42 | - array('at_login',"Login"), |
|
| 43 | - array('at_label',"Label") |
|
| 34 | + array('at_modification', "Modification"), |
|
| 35 | + array('at_creation', "Création"), |
|
| 36 | + array('at_delete', "Suppression"), |
|
| 37 | + array('at_pw', "Mot de passe changé."), |
|
| 38 | + array('at_category', "Group"), |
|
| 39 | + array('at_personnel', "Personnel"), |
|
| 40 | + array('at_description', "Description."), |
|
| 41 | + array('at_url', "Url"), |
|
| 42 | + array('at_login', "Login"), |
|
| 43 | + array('at_label', "Label") |
|
| 44 | 44 | ); |
| 45 | 45 | //SPANISH |
| 46 | 46 | $spanish_vals = array( |
| 47 | - array('at_modification',"Modificacion"), |
|
| 48 | - array('at_creation',"Creacion"), |
|
| 49 | - array('at_delete',"Borrado"), |
|
| 50 | - array('at_pw',"Contraseéa cambiada."), |
|
| 51 | - array('at_category',"Grupo"), |
|
| 52 | - array('at_personnel',"Personal"), |
|
| 53 | - array('at_description',"Descripcion."), |
|
| 54 | - array('at_url',"Url"), |
|
| 55 | - array('at_login',"Login"), |
|
| 56 | - array('at_label',"Etiqueta") |
|
| 47 | + array('at_modification', "Modificacion"), |
|
| 48 | + array('at_creation', "Creacion"), |
|
| 49 | + array('at_delete', "Borrado"), |
|
| 50 | + array('at_pw', "Contraseéa cambiada."), |
|
| 51 | + array('at_category', "Grupo"), |
|
| 52 | + array('at_personnel', "Personal"), |
|
| 53 | + array('at_description', "Descripcion."), |
|
| 54 | + array('at_url', "Url"), |
|
| 55 | + array('at_login', "Login"), |
|
| 56 | + array('at_label', "Etiqueta") |
|
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | changeDB(); |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data['action']."'"); |
| 80 | 80 | $found = true; |
| 81 | 81 | } else |
| 82 | - if ($lang[1] == trim(substr($data['raison'],0,strpos($data['raison'],":"))) && !empty($data['raison'])) { |
|
| 83 | - $data1= mysqli_fetch_row(mysqli_query($dbTmp, "SELECT action FROM ".$_SESSION['pre']."log_items WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$action."'")); |
|
| 84 | - mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]." ".substr($data['raison'],strpos($data['raison'],":"))."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data1[0]."'"); |
|
| 82 | + if ($lang[1] == trim(substr($data['raison'], 0, strpos($data['raison'], ":"))) && !empty($data['raison'])) { |
|
| 83 | + $data1 = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT action FROM ".$_SESSION['pre']."log_items WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$action."'")); |
|
| 84 | + mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]." ".substr($data['raison'], strpos($data['raison'], ":"))."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data1[0]."'"); |
|
| 85 | 85 | $found = true; |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data['action']."'"); |
| 99 | 99 | $found = true; |
| 100 | 100 | } else |
| 101 | - if ($lang[1] == trim(substr($data['raison'],0,strpos($data['raison'],":"))) && !empty($data['raison'])) { |
|
| 102 | - $data1= mysqli_fetch_row(mysqli_query($dbTmp, "SELECT action FROM ".$_SESSION['pre']."log_items WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$action."'")); |
|
| 103 | - mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]." ".substr($data['raison'],strpos($data['raison'],":"))."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data1[0]."'"); |
|
| 101 | + if ($lang[1] == trim(substr($data['raison'], 0, strpos($data['raison'], ":"))) && !empty($data['raison'])) { |
|
| 102 | + $data1 = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT action FROM ".$_SESSION['pre']."log_items WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$action."'")); |
|
| 103 | + mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]." ".substr($data['raison'], strpos($data['raison'], ":"))."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data1[0]."'"); |
|
| 104 | 104 | $found = true; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data['action']."'"); |
| 118 | 118 | $found = true; |
| 119 | 119 | } else |
| 120 | - if ($lang[1] == trim(substr($data['raison'],0,strpos($data['raison'],":"))) && !empty($data['raison'])) { |
|
| 121 | - $data1= mysqli_fetch_row(mysqli_query($dbTmp, "SELECT action FROM ".$_SESSION['pre']."log_items WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$action."'")); |
|
| 122 | - mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]." ".substr($data['raison'],strpos($data['raison'],":"))."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data1[0]."'"); |
|
| 120 | + if ($lang[1] == trim(substr($data['raison'], 0, strpos($data['raison'], ":"))) && !empty($data['raison'])) { |
|
| 121 | + $data1 = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT action FROM ".$_SESSION['pre']."log_items WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$action."'")); |
|
| 122 | + mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."log_items SET raison = '".$lang[0]." ".substr($data['raison'], strpos($data['raison'], ":"))."' WHERE id_item=".$data['id_item']." AND date =".$data['date']." AND id_user =".$data['id_user']." AND raison ='".$data['raison']."' AND action ='".$data1[0]."'"); |
|
| 123 | 123 | $found = true; |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | function chmod_r($dir, $dirPermissions, $filePermissions) { |
| 23 | 23 | $dp = opendir($dir); |
| 24 | 24 | $res = true; |
| 25 | - while($file = readdir($dp)) { |
|
| 25 | + while ($file = readdir($dp)) { |
|
| 26 | 26 | if (($file == ".") || ($file == "..")) |
| 27 | 27 | continue; |
| 28 | 28 | |
| 29 | 29 | $fullPath = $dir."/".$file; |
| 30 | 30 | |
| 31 | - if(is_dir($fullPath)) { |
|
| 31 | + if (is_dir($fullPath)) { |
|
| 32 | 32 | if ($res = @chmod($fullPath, $dirPermissions)) |
| 33 | 33 | $res = @chmod_r($fullPath, $dirPermissions, $filePermissions); |
| 34 | 34 | } else { |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | if (function_exists('openssl_random_pseudo_bytes')) { |
| 58 | 58 | $salt .= bin2hex(openssl_random_pseudo_bytes(11)); |
| 59 | 59 | } else { |
| 60 | - $chars='./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 61 | - for ($i=0; $i<22; $i++) { |
|
| 62 | - $salt.=$chars[mt_rand(0, 63)]; |
|
| 60 | + $chars = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 61 | + for ($i = 0; $i < 22; $i++) { |
|
| 62 | + $salt .= $chars[mt_rand(0, 63)]; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | return crypt($password, $salt); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | switch ($_POST['type']) { |
| 70 | 70 | case "step_2": |
| 71 | 71 | //decrypt |
| 72 | - require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 72 | + require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 73 | 73 | $json = Encryption\Crypt\aesctr::decrypt($_POST['data'], "cpm", 128); |
| 74 | 74 | $data = json_decode($json, true); |
| 75 | 75 | $json = Encryption\Crypt\aesctr::decrypt($_POST['activity'], "cpm", 128); |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | $data = array_merge($data, array("task" => $json)); |
| 79 | 79 | |
| 80 | 80 | $abspath = str_replace('\\', '/', $data['root_path']); |
| 81 | - if (substr($abspath, strlen($abspath)-1) == "/") { |
|
| 82 | - $abspath = substr($abspath, 0, strlen($abspath)-1); |
|
| 81 | + if (substr($abspath, strlen($abspath) - 1) == "/") { |
|
| 82 | + $abspath = substr($abspath, 0, strlen($abspath) - 1); |
|
| 83 | 83 | } |
| 84 | 84 | $_SESSION['abspath'] = $abspath; |
| 85 | 85 | $_SESSION['url_path'] = $data['url_path']; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if (isset($data['activity']) && $data['activity'] == "ini") { |
| 124 | - if (ini_get($data['task'])>=60) { |
|
| 124 | + if (ini_get($data['task']) >= 60) { |
|
| 125 | 125 | echo '[{"error" : "", "index" : "'.$_POST['index'].'"}]'; |
| 126 | 126 | } else { |
| 127 | 127 | echo '[{"error" : "PHP \"Maximum execution time\" is set to '.ini_get('max_execution_time').' seconds. Please try to set to 60s at least during installation.", "index" : "'.$_POST['index'].'", "multiple" : "'.$_POST['multiple'].'"}]'; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | case "step_3": |
| 134 | 134 | //decrypt |
| 135 | - require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 135 | + require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 136 | 136 | $json = Encryption\Crypt\aesctr::decrypt($_POST['data'], "cpm", 128); |
| 137 | 137 | $data = json_decode($json, true); |
| 138 | 138 | $json = Encryption\Crypt\aesctr::decrypt($_POST['db'], "cpm", 128); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | ) CHARSET=utf8;" |
| 149 | 149 | ); |
| 150 | 150 | // store values |
| 151 | - foreach($data as $key=>$value) { |
|
| 151 | + foreach ($data as $key=>$value) { |
|
| 152 | 152 | $_SESSION[$key] = $value; |
| 153 | 153 | $tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `_install` WHERE `key` = '".$key."'")); |
| 154 | 154 | if ($tmp[0] == 0 || empty($tmp[0])) { |
@@ -161,13 +161,13 @@ discard block |
||
| 161 | 161 | if ($tmp[0] == 0 || empty($tmp[0])) { |
| 162 | 162 | mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('url_path', '", empty($_SESSION['url_path']) ? $db['url_path'] : $_SESSION['url_path'], "');"); |
| 163 | 163 | } else { |
| 164 | - mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '", empty($_SESSION['url_path']) ? $db['url_path'] : $_SESSION['url_path'],"' WHERE `key` = 'url_path';"); |
|
| 164 | + mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '", empty($_SESSION['url_path']) ? $db['url_path'] : $_SESSION['url_path'], "' WHERE `key` = 'url_path';"); |
|
| 165 | 165 | } |
| 166 | 166 | $tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `_install` WHERE `key` = 'abspath'")); |
| 167 | 167 | if ($tmp[0] == 0 || empty($tmp[0])) { |
| 168 | - mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('abspath', '", empty($_SESSION['abspath']) ? $db['abspath'] : $_SESSION['abspath'],"');"); |
|
| 168 | + mysqli_query($dbTmp, "INSERT INTO `_install` (`key`, `value`) VALUES ('abspath', '", empty($_SESSION['abspath']) ? $db['abspath'] : $_SESSION['abspath'], "');"); |
|
| 169 | 169 | } else { |
| 170 | - mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '", empty($_SESSION['abspath']) ? $db['abspath'] : $_SESSION['abspath'],"' WHERE `key` = 'abspath';"); |
|
| 170 | + mysqli_query($dbTmp, "UPDATE `_install` SET `value` = '", empty($_SESSION['abspath']) ? $db['abspath'] : $_SESSION['abspath'], "' WHERE `key` = 'abspath';"); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | echo '[{"error" : "", "result" : "Connection is successful", "multiple" : ""}]'; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | case "step_4": |
| 181 | 181 | //decrypt |
| 182 | - require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 182 | + require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 183 | 183 | $json = Encryption\Crypt\aesctr::decrypt($_POST['data'], "cpm", 128); |
| 184 | 184 | $data = json_decode($json, true); |
| 185 | 185 | $json = Encryption\Crypt\aesctr::decrypt($_POST['db'], "cpm", 128); |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | $dbTmp = mysqli_connect($db['db_host'], $db['db_login'], $db['db_pw'], $db['db_bdd'], $db['db_port']); |
| 189 | 189 | |
| 190 | 190 | // prepare data |
| 191 | - foreach($data as $key=>$value) { |
|
| 192 | - $data[$key] = str_replace(array('"', '\'), array('""','\\\\'), $value); |
|
| 191 | + foreach ($data as $key=>$value) { |
|
| 192 | + $data[$key] = str_replace(array('"', '\'), array('""', '\\\\'), $value); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // check skpath |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | } else { |
| 199 | 199 | $data['sk_path'] = str_replace("\", "/", $data['sk_path']); |
| 200 | 200 | } |
| 201 | - if (substr($data['sk_path'], strlen($data['sk_path'])-1) == "/" || substr($data['sk_path'], strlen($data['sk_path'])-1) == "\"") { |
|
| 202 | - $data['sk_path'] = substr($data['sk_path'], 0, strlen($data['sk_path'])-1); |
|
| 201 | + if (substr($data['sk_path'], strlen($data['sk_path']) - 1) == "/" || substr($data['sk_path'], strlen($data['sk_path']) - 1) == "\"") { |
|
| 202 | + $data['sk_path'] = substr($data['sk_path'], 0, strlen($data['sk_path']) - 1); |
|
| 203 | 203 | } |
| 204 | 204 | if (is_dir($data['sk_path'])) { |
| 205 | 205 | if (is_writable($data['sk_path'])) { |
| 206 | 206 | // store all variables in SESSION |
| 207 | - foreach($data as $key=>$value) { |
|
| 207 | + foreach ($data as $key=>$value) { |
|
| 208 | 208 | $_SESSION[$key] = $value; |
| 209 | 209 | $tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `_install` WHERE `key` = '".$key."'")); |
| 210 | 210 | if ($tmp[0] == 0 || empty($tmp[0])) { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | case "step_5": |
| 227 | 227 | //decrypt |
| 228 | - require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 228 | + require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 229 | 229 | $activity = Encryption\Crypt\aesctr::decrypt($_POST['activity'], "cpm", 128); |
| 230 | 230 | $task = Encryption\Crypt\aesctr::decrypt($_POST['task'], "cpm", 128); |
| 231 | 231 | $json = Encryption\Crypt\aesctr::decrypt($_POST['db'], "cpm", 128); |
@@ -341,97 +341,97 @@ discard block |
||
| 341 | 341 | array('admin', 'path_to_files_folder', $var['abspath'].'/files'), |
| 342 | 342 | array('admin', 'url_to_files_folder', $var['url_path'].'/files'), |
| 343 | 343 | array('admin', 'activate_expiration', '0'), |
| 344 | - array('admin','pw_life_duration','0'), |
|
| 345 | - array('admin','maintenance_mode','1'), |
|
| 346 | - array('admin','enable_sts','0'), |
|
| 347 | - array('admin','encryptClientServer','1'), |
|
| 348 | - array('admin','cpassman_version',$k['version']), |
|
| 349 | - array('admin','ldap_mode','0'), |
|
| 350 | - array('admin','ldap_type','0'), |
|
| 351 | - array('admin','ldap_suffix','0'), |
|
| 352 | - array('admin','ldap_domain_dn','0'), |
|
| 353 | - array('admin','ldap_domain_controler','0'), |
|
| 354 | - array('admin','ldap_user_attribute','0'), |
|
| 355 | - array('admin','ldap_ssl','0'), |
|
| 356 | - array('admin','ldap_tls','0'), |
|
| 357 | - array('admin','ldap_elusers','0'), |
|
| 358 | - array('admin','ldap_search_base','0'), |
|
| 359 | - array('admin','richtext','0'), |
|
| 360 | - array('admin','allow_print','0'), |
|
| 361 | - array('admin','roles_allowed_to_print','0'), |
|
| 362 | - array('admin','show_description','1'), |
|
| 363 | - array('admin','anyone_can_modify','0'), |
|
| 364 | - array('admin','anyone_can_modify_bydefault','0'), |
|
| 365 | - array('admin','nb_bad_authentication','0'), |
|
| 366 | - array('admin','utf8_enabled','1'), |
|
| 367 | - array('admin','restricted_to','0'), |
|
| 368 | - array('admin','restricted_to_roles','0'), |
|
| 369 | - array('admin','enable_send_email_on_user_login','0'), |
|
| 370 | - array('admin','enable_user_can_create_folders','0'), |
|
| 371 | - array('admin','insert_manual_entry_item_history','0'), |
|
| 372 | - array('admin','enable_kb','0'), |
|
| 373 | - array('admin','enable_email_notification_on_item_shown','0'), |
|
| 374 | - array('admin','enable_email_notification_on_user_pw_change','0'), |
|
| 375 | - array('admin','custom_logo',''), |
|
| 376 | - array('admin','custom_login_text',''), |
|
| 377 | - array('admin','default_language','english'), |
|
| 378 | - array('admin','send_stats', '0'), |
|
| 379 | - array('admin','send_statistics_items', 'stat_country;stat_users;stat_items;stat_items_shared;stat_folders;stat_folders_shared;stat_admins;stat_managers;stat_ro;stat_mysqlversion;stat_phpversion;stat_teampassversion;stat_languages;stat_kb;stat_suggestion;stat_customfields;stat_api;stat_2fa;stat_agses;stat_duo;stat_ldap;stat_syslog;stat_stricthttps;stat_fav;stat_pf;'), |
|
| 380 | - array('admin','send_stats_time', time()-2592000), |
|
| 381 | - array('admin','get_tp_info', '1'), |
|
| 382 | - array('admin','send_mail_on_user_login', '0'), |
|
| 344 | + array('admin', 'pw_life_duration', '0'), |
|
| 345 | + array('admin', 'maintenance_mode', '1'), |
|
| 346 | + array('admin', 'enable_sts', '0'), |
|
| 347 | + array('admin', 'encryptClientServer', '1'), |
|
| 348 | + array('admin', 'cpassman_version', $k['version']), |
|
| 349 | + array('admin', 'ldap_mode', '0'), |
|
| 350 | + array('admin', 'ldap_type', '0'), |
|
| 351 | + array('admin', 'ldap_suffix', '0'), |
|
| 352 | + array('admin', 'ldap_domain_dn', '0'), |
|
| 353 | + array('admin', 'ldap_domain_controler', '0'), |
|
| 354 | + array('admin', 'ldap_user_attribute', '0'), |
|
| 355 | + array('admin', 'ldap_ssl', '0'), |
|
| 356 | + array('admin', 'ldap_tls', '0'), |
|
| 357 | + array('admin', 'ldap_elusers', '0'), |
|
| 358 | + array('admin', 'ldap_search_base', '0'), |
|
| 359 | + array('admin', 'richtext', '0'), |
|
| 360 | + array('admin', 'allow_print', '0'), |
|
| 361 | + array('admin', 'roles_allowed_to_print', '0'), |
|
| 362 | + array('admin', 'show_description', '1'), |
|
| 363 | + array('admin', 'anyone_can_modify', '0'), |
|
| 364 | + array('admin', 'anyone_can_modify_bydefault', '0'), |
|
| 365 | + array('admin', 'nb_bad_authentication', '0'), |
|
| 366 | + array('admin', 'utf8_enabled', '1'), |
|
| 367 | + array('admin', 'restricted_to', '0'), |
|
| 368 | + array('admin', 'restricted_to_roles', '0'), |
|
| 369 | + array('admin', 'enable_send_email_on_user_login', '0'), |
|
| 370 | + array('admin', 'enable_user_can_create_folders', '0'), |
|
| 371 | + array('admin', 'insert_manual_entry_item_history', '0'), |
|
| 372 | + array('admin', 'enable_kb', '0'), |
|
| 373 | + array('admin', 'enable_email_notification_on_item_shown', '0'), |
|
| 374 | + array('admin', 'enable_email_notification_on_user_pw_change', '0'), |
|
| 375 | + array('admin', 'custom_logo', ''), |
|
| 376 | + array('admin', 'custom_login_text', ''), |
|
| 377 | + array('admin', 'default_language', 'english'), |
|
| 378 | + array('admin', 'send_stats', '0'), |
|
| 379 | + array('admin', 'send_statistics_items', 'stat_country;stat_users;stat_items;stat_items_shared;stat_folders;stat_folders_shared;stat_admins;stat_managers;stat_ro;stat_mysqlversion;stat_phpversion;stat_teampassversion;stat_languages;stat_kb;stat_suggestion;stat_customfields;stat_api;stat_2fa;stat_agses;stat_duo;stat_ldap;stat_syslog;stat_stricthttps;stat_fav;stat_pf;'), |
|
| 380 | + array('admin', 'send_stats_time', time() - 2592000), |
|
| 381 | + array('admin', 'get_tp_info', '1'), |
|
| 382 | + array('admin', 'send_mail_on_user_login', '0'), |
|
| 383 | 383 | array('cron', 'sending_emails', '0'), |
| 384 | - array('admin','nb_items_by_query', 'auto'), |
|
| 385 | - array('admin','enable_delete_after_consultation', '0'), |
|
| 386 | - array('admin','enable_personal_saltkey_cookie', '0'), |
|
| 387 | - array('admin','personal_saltkey_cookie_duration', '31'), |
|
| 388 | - array('admin','email_smtp_server', ''), |
|
| 389 | - array('admin','email_smtp_auth', ''), |
|
| 390 | - array('admin','email_auth_username', ''), |
|
| 391 | - array('admin','email_auth_pwd', ''), |
|
| 392 | - array('admin','email_port', ''), |
|
| 393 | - array('admin','email_security',''), |
|
| 394 | - array('admin','email_server_url', ''), |
|
| 395 | - array('admin','email_from', ''), |
|
| 396 | - array('admin','email_from_name', ''), |
|
| 397 | - array('admin','pwd_maximum_length', '40'), |
|
| 398 | - array('admin','google_authentication', '0'), |
|
| 399 | - array('admin','delay_item_edition', '0'), |
|
| 400 | - array('admin','allow_import','0'), |
|
| 401 | - array('admin','proxy_ip',''), |
|
| 402 | - array('admin','proxy_port',''), |
|
| 403 | - array('admin','upload_maxfilesize','10mb'), |
|
| 404 | - array('admin','upload_docext','doc,docx,dotx,xls,xlsx,xltx,rtf,csv,txt,pdf,ppt,pptx,pot,dotx,xltx'), |
|
| 405 | - array('admin','upload_imagesext','jpg,jpeg,gif,png'), |
|
| 406 | - array('admin','upload_pkgext','7z,rar,tar,zip'), |
|
| 407 | - array('admin','upload_otherext','sql,xml'), |
|
| 408 | - array('admin','upload_imageresize_options','1'), |
|
| 409 | - array('admin','upload_imageresize_width','800'), |
|
| 410 | - array('admin','upload_imageresize_height','600'), |
|
| 411 | - array('admin','upload_imageresize_quality','90'), |
|
| 412 | - array('admin','use_md5_password_as_salt','0'), |
|
| 413 | - array('admin','ga_website_name','TeamPass for ChangeMe'), |
|
| 414 | - array('admin','api','0'), |
|
| 415 | - array('admin','subfolder_rights_as_parent','0'), |
|
| 416 | - array('admin','show_only_accessible_folders','0'), |
|
| 417 | - array('admin','enable_suggestion','0'), |
|
| 418 | - array('admin','otv_expiration_period','7'), |
|
| 419 | - array('admin','default_session_expiration_time','60'), |
|
| 420 | - array('admin','duo','0'), |
|
| 421 | - array('admin','enable_server_password_change','0'), |
|
| 422 | - array('admin','ldap_object_class','0'), |
|
| 423 | - array('admin','bck_script_path', $var['abspath']."/backups"), |
|
| 424 | - array('admin','bck_script_filename', 'bck_teampass'), |
|
| 425 | - array('admin','syslog_enable','0'), |
|
| 426 | - array('admin','syslog_host','localhost'), |
|
| 427 | - array('admin','syslog_port','514'), |
|
| 428 | - array('admin','manager_move_item','0'), |
|
| 429 | - array('admin','create_item_without_password','0'), |
|
| 430 | - array('admin','otv_is_enabled','0'), |
|
| 431 | - array('admin','agses_authentication_enabled','0'), |
|
| 432 | - array('admin','item_extra_fields','0'), |
|
| 433 | - array('admin','saltkey_ante_2127','none'), |
|
| 434 | - array('admin','migration_to_2127','done') |
|
| 384 | + array('admin', 'nb_items_by_query', 'auto'), |
|
| 385 | + array('admin', 'enable_delete_after_consultation', '0'), |
|
| 386 | + array('admin', 'enable_personal_saltkey_cookie', '0'), |
|
| 387 | + array('admin', 'personal_saltkey_cookie_duration', '31'), |
|
| 388 | + array('admin', 'email_smtp_server', ''), |
|
| 389 | + array('admin', 'email_smtp_auth', ''), |
|
| 390 | + array('admin', 'email_auth_username', ''), |
|
| 391 | + array('admin', 'email_auth_pwd', ''), |
|
| 392 | + array('admin', 'email_port', ''), |
|
| 393 | + array('admin', 'email_security', ''), |
|
| 394 | + array('admin', 'email_server_url', ''), |
|
| 395 | + array('admin', 'email_from', ''), |
|
| 396 | + array('admin', 'email_from_name', ''), |
|
| 397 | + array('admin', 'pwd_maximum_length', '40'), |
|
| 398 | + array('admin', 'google_authentication', '0'), |
|
| 399 | + array('admin', 'delay_item_edition', '0'), |
|
| 400 | + array('admin', 'allow_import', '0'), |
|
| 401 | + array('admin', 'proxy_ip', ''), |
|
| 402 | + array('admin', 'proxy_port', ''), |
|
| 403 | + array('admin', 'upload_maxfilesize', '10mb'), |
|
| 404 | + array('admin', 'upload_docext', 'doc,docx,dotx,xls,xlsx,xltx,rtf,csv,txt,pdf,ppt,pptx,pot,dotx,xltx'), |
|
| 405 | + array('admin', 'upload_imagesext', 'jpg,jpeg,gif,png'), |
|
| 406 | + array('admin', 'upload_pkgext', '7z,rar,tar,zip'), |
|
| 407 | + array('admin', 'upload_otherext', 'sql,xml'), |
|
| 408 | + array('admin', 'upload_imageresize_options', '1'), |
|
| 409 | + array('admin', 'upload_imageresize_width', '800'), |
|
| 410 | + array('admin', 'upload_imageresize_height', '600'), |
|
| 411 | + array('admin', 'upload_imageresize_quality', '90'), |
|
| 412 | + array('admin', 'use_md5_password_as_salt', '0'), |
|
| 413 | + array('admin', 'ga_website_name', 'TeamPass for ChangeMe'), |
|
| 414 | + array('admin', 'api', '0'), |
|
| 415 | + array('admin', 'subfolder_rights_as_parent', '0'), |
|
| 416 | + array('admin', 'show_only_accessible_folders', '0'), |
|
| 417 | + array('admin', 'enable_suggestion', '0'), |
|
| 418 | + array('admin', 'otv_expiration_period', '7'), |
|
| 419 | + array('admin', 'default_session_expiration_time', '60'), |
|
| 420 | + array('admin', 'duo', '0'), |
|
| 421 | + array('admin', 'enable_server_password_change', '0'), |
|
| 422 | + array('admin', 'ldap_object_class', '0'), |
|
| 423 | + array('admin', 'bck_script_path', $var['abspath']."/backups"), |
|
| 424 | + array('admin', 'bck_script_filename', 'bck_teampass'), |
|
| 425 | + array('admin', 'syslog_enable', '0'), |
|
| 426 | + array('admin', 'syslog_host', 'localhost'), |
|
| 427 | + array('admin', 'syslog_port', '514'), |
|
| 428 | + array('admin', 'manager_move_item', '0'), |
|
| 429 | + array('admin', 'create_item_without_password', '0'), |
|
| 430 | + array('admin', 'otv_is_enabled', '0'), |
|
| 431 | + array('admin', 'agses_authentication_enabled', '0'), |
|
| 432 | + array('admin', 'item_extra_fields', '0'), |
|
| 433 | + array('admin', 'saltkey_ante_2127', 'none'), |
|
| 434 | + array('admin', 'migration_to_2127', 'done') |
|
| 435 | 435 | ); |
| 436 | 436 | foreach ($aMiscVal as $elem) { |
| 437 | 437 | //Check if exists before inserting |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | (`type`, `intitule`, `valeur`) VALUES |
| 449 | 449 | ('".$elem[0]."', '".$elem[1]."', '". |
| 450 | 450 | str_replace("'", "", $elem[2])."');" |
| 451 | - ); // or die(mysqli_error($dbTmp)) |
|
| 451 | + ); // or die(mysqli_error($dbTmp)) |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | // append new setting in config file |
@@ -843,10 +843,10 @@ discard block |
||
| 843 | 843 | $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `".$var['tbl_prefix']."users` WHERE login = 'admin'")); |
| 844 | 844 | if ($tmp === "0") { |
| 845 | 845 | $mysqli_result = mysqli_query($dbTmp, |
| 846 | - "INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `admin`, `gestionnaire`, `personal_folder`, `groupes_visibles`, `email`, `encrypted_psk`) VALUES ('1', 'admin', '".bCrypt($var['admin_pwd'],'13' )."', '1', '0', '0', '', '', '')" |
|
| 846 | + "INSERT INTO `".$var['tbl_prefix']."users` (`id`, `login`, `pw`, `admin`, `gestionnaire`, `personal_folder`, `groupes_visibles`, `email`, `encrypted_psk`) VALUES ('1', 'admin', '".bCrypt($var['admin_pwd'], '13')."', '1', '0', '0', '', '', '')" |
|
| 847 | 847 | ); |
| 848 | 848 | } else { |
| 849 | - $mysqli_result = mysqli_query($dbTmp, "UPDATE `".$var['tbl_prefix']."users` SET `pw` = '".bCrypt($var['admin_pwd'],'13' )."' WHERE login = 'admin' AND id = '1'"); |
|
| 849 | + $mysqli_result = mysqli_query($dbTmp, "UPDATE `".$var['tbl_prefix']."users` SET `pw` = '".bCrypt($var['admin_pwd'], '13')."' WHERE login = 'admin' AND id = '1'"); |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | // check that API doesn't exist |
@@ -878,13 +878,13 @@ discard block |
||
| 878 | 878 | |
| 879 | 879 | mysqli_close($dbTmp); |
| 880 | 880 | // Destroy session without writing to disk |
| 881 | - define('NODESTROY_SESSION','true'); |
|
| 881 | + define('NODESTROY_SESSION', 'true'); |
|
| 882 | 882 | session_destroy(); |
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case "step_6": |
| 886 | 886 | //decrypt |
| 887 | - require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 887 | + require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 888 | 888 | $activity = Encryption\Crypt\aesctr::decrypt($_POST['activity'], "cpm", 128); |
| 889 | 889 | $data_sent = Encryption\Crypt\aesctr::decrypt($_POST['data'], "cpm", 128); |
| 890 | 890 | $data_sent = json_decode($data_sent, true); |
@@ -995,9 +995,9 @@ discard block |
||
| 995 | 995 | if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { |
| 996 | 996 | // Change directory permissions |
| 997 | 997 | $result = chmod_r($_SESSION['abspath'], 0770, 0740); |
| 998 | - if ($result ) |
|
| 998 | + if ($result) |
|
| 999 | 999 | $result = chmod_r($_SESSION['abspath'].'/files', 0770, 0770); |
| 1000 | - if ($result) |
|
| 1000 | + if ($result) |
|
| 1001 | 1001 | $result = chmod_r($_SESSION['abspath'].'/upload', 0770, 0770); |
| 1002 | 1002 | } |
| 1003 | 1003 | |
@@ -1039,8 +1039,8 @@ discard block |
||
| 1039 | 1039 | $events .= "The file $csrfp_file already exist. A copy has been created.<br />"; |
| 1040 | 1040 | } |
| 1041 | 1041 | } |
| 1042 | - unlink($csrfp_file); // delete existing csrfp.config file |
|
| 1043 | - copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file |
|
| 1042 | + unlink($csrfp_file); // delete existing csrfp.config file |
|
| 1043 | + copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file |
|
| 1044 | 1044 | $data = file_get_contents($csrfp_file); |
| 1045 | 1045 | $newdata = str_replace('"CSRFP_TOKEN" => ""', '"CSRFP_TOKEN" => "'.bin2hex(openssl_random_pseudo_bytes(25)).'"', $data); |
| 1046 | 1046 | $jsUrl = $data_sent['url_path'].'/includes/libraries/csrfp/js/csrfprotector.js'; |
@@ -1053,13 +1053,13 @@ discard block |
||
| 1053 | 1053 | |
| 1054 | 1054 | mysqli_close($dbTmp); |
| 1055 | 1055 | // Destroy session without writing to disk |
| 1056 | - define('NODESTROY_SESSION','true'); |
|
| 1056 | + define('NODESTROY_SESSION', 'true'); |
|
| 1057 | 1057 | session_destroy(); |
| 1058 | 1058 | break; |
| 1059 | 1059 | case "step_7": |
| 1060 | 1060 | |
| 1061 | 1061 | //decrypt |
| 1062 | - require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 1062 | + require_once 'libs/aesctr.php'; // AES Counter Mode implementation |
|
| 1063 | 1063 | $activity = Encryption\Crypt\aesctr::decrypt($_POST['activity'], "cpm", 128); |
| 1064 | 1064 | $task = Encryption\Crypt\aesctr::decrypt($_POST['task'], "cpm", 128); |
| 1065 | 1065 | // launch |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | if ($activity == "file") { |
| 1069 | 1069 | if ($task == "deleteInstall") { |
| 1070 | 1070 | function delTree($dir) { |
| 1071 | - $files = array_diff(scandir($dir), array('.','..')); |
|
| 1071 | + $files = array_diff(scandir($dir), array('.', '..')); |
|
| 1072 | 1072 | |
| 1073 | 1073 | foreach ($files as $file) { |
| 1074 | 1074 | (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | return rmdir($dir); |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - $result=true; |
|
| 1079 | + $result = true; |
|
| 1080 | 1080 | $errorMsg = "Cannot delete installation directory"; |
| 1081 | 1081 | if (file_exists($_SESSION['abspath'].'/install')) { |
| 1082 | 1082 | // set the permissions on the install directory and delete |
@@ -1102,7 +1102,7 @@ discard block |
||
| 1102 | 1102 | // |
| 1103 | 1103 | mysqli_close($dbTmp); |
| 1104 | 1104 | // Destroy session without writing to disk |
| 1105 | - define('NODESTROY_SESSION','true'); |
|
| 1105 | + define('NODESTROY_SESSION', 'true'); |
|
| 1106 | 1106 | session_destroy(); |
| 1107 | 1107 | break; |
| 1108 | 1108 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | function getSettingValue($val) |
| 41 | 41 | { |
| 42 | 42 | $val = trim(strstr($val, "=")); |
| 43 | - return trim(str_replace('"', '', substr($val, 1, strpos($val, ";")-1))); |
|
| 43 | + return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1))); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | ################ |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | global $dbTmp; |
| 52 | 52 | $exists = false; |
| 53 | 53 | $columns = mysqli_query($dbTmp, "show columns from $db"); |
| 54 | - while ($c = mysqli_fetch_assoc( $columns)) { |
|
| 54 | + while ($c = mysqli_fetch_assoc($columns)) { |
|
| 55 | 55 | if ($c['Field'] == $column) { |
| 56 | 56 | $exists = true; |
| 57 | 57 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -function addIndexIfNotExist($table, $index, $sql ) { |
|
| 67 | +function addIndexIfNotExist($table, $index, $sql) { |
|
| 68 | 68 | global $dbTmp; |
| 69 | 69 | |
| 70 | 70 | $mysqli_result = mysqli_query($dbTmp, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\""); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // if index does not exist, then add it |
| 74 | 74 | if (!$res) { |
| 75 | - $res = mysqli_query($dbTmp, "ALTER TABLE `$table` " . $sql); |
|
| 75 | + $res = mysqli_query($dbTmp, "ALTER TABLE `$table` ".$sql); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $res; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // if yes, then don't execute re-encryption |
| 129 | 129 | $_SESSION['tp_defuse_installed'] = false; |
| 130 | 130 | $columns = mysqli_query($dbTmp, "show columns from ".$_SESSION['pre']."items"); |
| 131 | -while ($c = mysqli_fetch_assoc( $columns)) { |
|
| 131 | +while ($c = mysqli_fetch_assoc($columns)) { |
|
| 132 | 132 | if ($c['Field'] === "encryption_type") { |
| 133 | 133 | $_SESSION['tp_defuse_installed'] = true; |
| 134 | 134 | } |
@@ -137,49 +137,49 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | ## Populate table MISC |
| 139 | 139 | $val = array( |
| 140 | - array('admin', 'max_latest_items', '10',0), |
|
| 141 | - array('admin', 'enable_favourites', '1',0), |
|
| 142 | - array('admin', 'show_last_items', '1',0), |
|
| 143 | - array('admin', 'enable_pf_feature', '0',0), |
|
| 144 | - array('admin', 'menu_type', 'context',0), |
|
| 145 | - array('admin', 'log_connections', '0',0), |
|
| 146 | - array('admin', 'time_format', 'H:i:s',0), |
|
| 147 | - array('admin', 'date_format', 'd/m/Y',0), |
|
| 148 | - array('admin', 'duplicate_folder', '0',0), |
|
| 149 | - array('admin', 'duplicate_item', '0',0), |
|
| 150 | - array('admin', 'item_duplicate_in_same_folder', '0',0), |
|
| 151 | - array('admin', 'number_of_used_pw', '3',0), |
|
| 152 | - array('admin', 'manager_edit', '1',0), |
|
| 153 | - array('admin', 'cpassman_dir', '',0), |
|
| 154 | - array('admin', 'cpassman_url', '',0), |
|
| 155 | - array('admin', 'favicon', '',0), |
|
| 156 | - array('admin', 'activate_expiration', '0',0), |
|
| 157 | - array('admin', 'pw_life_duration','30',0), |
|
| 140 | + array('admin', 'max_latest_items', '10', 0), |
|
| 141 | + array('admin', 'enable_favourites', '1', 0), |
|
| 142 | + array('admin', 'show_last_items', '1', 0), |
|
| 143 | + array('admin', 'enable_pf_feature', '0', 0), |
|
| 144 | + array('admin', 'menu_type', 'context', 0), |
|
| 145 | + array('admin', 'log_connections', '0', 0), |
|
| 146 | + array('admin', 'time_format', 'H:i:s', 0), |
|
| 147 | + array('admin', 'date_format', 'd/m/Y', 0), |
|
| 148 | + array('admin', 'duplicate_folder', '0', 0), |
|
| 149 | + array('admin', 'duplicate_item', '0', 0), |
|
| 150 | + array('admin', 'item_duplicate_in_same_folder', '0', 0), |
|
| 151 | + array('admin', 'number_of_used_pw', '3', 0), |
|
| 152 | + array('admin', 'manager_edit', '1', 0), |
|
| 153 | + array('admin', 'cpassman_dir', '', 0), |
|
| 154 | + array('admin', 'cpassman_url', '', 0), |
|
| 155 | + array('admin', 'favicon', '', 0), |
|
| 156 | + array('admin', 'activate_expiration', '0', 0), |
|
| 157 | + array('admin', 'pw_life_duration', '30', 0), |
|
| 158 | 158 | //array('admin', 'maintenance_mode','1',1), |
| 159 | - array('admin', 'cpassman_version',$k['version'],1), |
|
| 160 | - array('admin', 'ldap_mode','0',0), |
|
| 161 | - array('admin','ldap_type','0',0), |
|
| 162 | - array('admin','ldap_suffix','0',0), |
|
| 163 | - array('admin','ldap_domain_dn','0',0), |
|
| 164 | - array('admin','ldap_domain_controler','0',0), |
|
| 165 | - array('admin','ldap_user_attribute','0',0), |
|
| 166 | - array('admin','ldap_ssl','0',0), |
|
| 167 | - array('admin','ldap_tls','0',0), |
|
| 168 | - array('admin','ldap_elusers','0',0), |
|
| 169 | - array('admin', 'richtext',0,0), |
|
| 170 | - array('admin', 'allow_print',0,0), |
|
| 171 | - array('admin', 'roles_allowed_to_print',0,0), |
|
| 172 | - array('admin', 'show_description',1,0), |
|
| 173 | - array('admin', 'anyone_can_modify',0,0), |
|
| 174 | - array('admin', 'anyone_can_modify_bydefault',0,0), |
|
| 175 | - array('admin', 'nb_bad_authentication',0,0), |
|
| 176 | - array('admin', 'restricted_to',0,0), |
|
| 177 | - array('admin', 'restricted_to_roles',0,0), |
|
| 178 | - array('admin', 'utf8_enabled',1,0), |
|
| 179 | - array('admin', 'custom_logo','',0), |
|
| 180 | - array('admin', 'custom_login_text','',0), |
|
| 181 | - array('admin', 'log_accessed', '1',1), |
|
| 182 | - array('admin', 'default_language', 'english',0), |
|
| 159 | + array('admin', 'cpassman_version', $k['version'], 1), |
|
| 160 | + array('admin', 'ldap_mode', '0', 0), |
|
| 161 | + array('admin', 'ldap_type', '0', 0), |
|
| 162 | + array('admin', 'ldap_suffix', '0', 0), |
|
| 163 | + array('admin', 'ldap_domain_dn', '0', 0), |
|
| 164 | + array('admin', 'ldap_domain_controler', '0', 0), |
|
| 165 | + array('admin', 'ldap_user_attribute', '0', 0), |
|
| 166 | + array('admin', 'ldap_ssl', '0', 0), |
|
| 167 | + array('admin', 'ldap_tls', '0', 0), |
|
| 168 | + array('admin', 'ldap_elusers', '0', 0), |
|
| 169 | + array('admin', 'richtext', 0, 0), |
|
| 170 | + array('admin', 'allow_print', 0, 0), |
|
| 171 | + array('admin', 'roles_allowed_to_print', 0, 0), |
|
| 172 | + array('admin', 'show_description', 1, 0), |
|
| 173 | + array('admin', 'anyone_can_modify', 0, 0), |
|
| 174 | + array('admin', 'anyone_can_modify_bydefault', 0, 0), |
|
| 175 | + array('admin', 'nb_bad_authentication', 0, 0), |
|
| 176 | + array('admin', 'restricted_to', 0, 0), |
|
| 177 | + array('admin', 'restricted_to_roles', 0, 0), |
|
| 178 | + array('admin', 'utf8_enabled', 1, 0), |
|
| 179 | + array('admin', 'custom_logo', '', 0), |
|
| 180 | + array('admin', 'custom_login_text', '', 0), |
|
| 181 | + array('admin', 'log_accessed', '1', 1), |
|
| 182 | + array('admin', 'default_language', 'english', 0), |
|
| 183 | 183 | array( |
| 184 | 184 | 'admin', |
| 185 | 185 | 'send_stats', |
@@ -195,16 +195,16 @@ discard block |
||
| 195 | 195 | 'admin', |
| 196 | 196 | 'path_to_upload_folder', |
| 197 | 197 | strrpos($_SERVER['DOCUMENT_ROOT'], "/") == 1 ? |
| 198 | - (strlen($_SERVER['DOCUMENT_ROOT'])-1).substr( |
|
| 198 | + (strlen($_SERVER['DOCUMENT_ROOT']) - 1).substr( |
|
| 199 | 199 | $_SERVER['PHP_SELF'], |
| 200 | 200 | 0, |
| 201 | - strlen($_SERVER['PHP_SELF'])-25 |
|
| 201 | + strlen($_SERVER['PHP_SELF']) - 25 |
|
| 202 | 202 | ).'/upload' |
| 203 | 203 | : |
| 204 | 204 | $_SERVER['DOCUMENT_ROOT'].substr( |
| 205 | 205 | $_SERVER['PHP_SELF'], |
| 206 | 206 | 0, |
| 207 | - strlen($_SERVER['PHP_SELF'])-25 |
|
| 207 | + strlen($_SERVER['PHP_SELF']) - 25 |
|
| 208 | 208 | ).'/upload', |
| 209 | 209 | 0 |
| 210 | 210 | ), |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | 'http://'.$_SERVER['HTTP_HOST'].substr( |
| 215 | 215 | $_SERVER['PHP_SELF'], |
| 216 | 216 | 0, |
| 217 | - strrpos($_SERVER['PHP_SELF'], '/')-8 |
|
| 217 | + strrpos($_SERVER['PHP_SELF'], '/') - 8 |
|
| 218 | 218 | ).'/upload', |
| 219 | 219 | 0 |
| 220 | 220 | ), |
@@ -224,16 +224,16 @@ discard block |
||
| 224 | 224 | 'admin', |
| 225 | 225 | 'path_to_files_folder', |
| 226 | 226 | strrpos($_SERVER['DOCUMENT_ROOT'], "/") == 1 ? |
| 227 | - (strlen($_SERVER['DOCUMENT_ROOT'])-1).substr( |
|
| 227 | + (strlen($_SERVER['DOCUMENT_ROOT']) - 1).substr( |
|
| 228 | 228 | $_SERVER['PHP_SELF'], |
| 229 | 229 | 0, |
| 230 | - strlen($_SERVER['PHP_SELF'])-25 |
|
| 230 | + strlen($_SERVER['PHP_SELF']) - 25 |
|
| 231 | 231 | ).'/files' |
| 232 | 232 | : |
| 233 | 233 | $_SERVER['DOCUMENT_ROOT'].substr( |
| 234 | 234 | $_SERVER['PHP_SELF'], |
| 235 | 235 | 0, |
| 236 | - strlen($_SERVER['PHP_SELF'])-25 |
|
| 236 | + strlen($_SERVER['PHP_SELF']) - 25 |
|
| 237 | 237 | ).'/files', |
| 238 | 238 | 0 |
| 239 | 239 | ), |
@@ -243,12 +243,12 @@ discard block |
||
| 243 | 243 | 'http://'.$_SERVER['HTTP_HOST'].substr( |
| 244 | 244 | $_SERVER['PHP_SELF'], |
| 245 | 245 | 0, |
| 246 | - strrpos($_SERVER['PHP_SELF'], '/')-8 |
|
| 246 | + strrpos($_SERVER['PHP_SELF'], '/') - 8 |
|
| 247 | 247 | ).'/files', |
| 248 | 248 | 0 |
| 249 | 249 | ), |
| 250 | - array('admin', 'pwd_maximum_length','40',0), |
|
| 251 | - array('admin', 'ga_website_name','TeamPass for ChangeMe',0), |
|
| 250 | + array('admin', 'pwd_maximum_length', '40', 0), |
|
| 251 | + array('admin', 'ga_website_name', 'TeamPass for ChangeMe', 0), |
|
| 252 | 252 | array('admin', 'email_smtp_server', @$_SESSION['smtp_server'], 0), |
| 253 | 253 | array('admin', 'email_smtp_auth', @$_SESSION['smtp_auth'], 0), |
| 254 | 254 | array('admin', 'email_auth_username', @$_SESSION['smtp_auth_username'], 0), |
@@ -259,43 +259,43 @@ discard block |
||
| 259 | 259 | array('admin', 'email_from_name', @$_SESSION['email_from_name'], 0), |
| 260 | 260 | array('admin', 'google_authentication', 0, 0), |
| 261 | 261 | array('admin', 'delay_item_edition', 0, 0), |
| 262 | - array('admin', 'allow_import',0,0), |
|
| 263 | - array('admin', 'proxy_port',0,0), |
|
| 264 | - array('admin', 'proxy_port',0,0), |
|
| 265 | - array('admin','upload_maxfilesize','10mb',0), |
|
| 262 | + array('admin', 'allow_import', 0, 0), |
|
| 263 | + array('admin', 'proxy_port', 0, 0), |
|
| 264 | + array('admin', 'proxy_port', 0, 0), |
|
| 265 | + array('admin', 'upload_maxfilesize', '10mb', 0), |
|
| 266 | 266 | array( |
| 267 | 267 | 'admin', |
| 268 | 268 | 'upload_docext', |
| 269 | 269 | 'doc,docx,dotx,xls,xlsx,xltx,rtf,csv,txt,pdf,ppt,pptx,pot,dotx,xltx', |
| 270 | 270 | 0 |
| 271 | 271 | ), |
| 272 | - array('admin','upload_imagesext','jpg,jpeg,gif,png',0), |
|
| 273 | - array('admin','upload_pkgext','7z,rar,tar,zip',0), |
|
| 274 | - array('admin','upload_otherext','sql,xml',0), |
|
| 275 | - array('admin','upload_imageresize_options','1',0), |
|
| 276 | - array('admin','upload_imageresize_width','800',0), |
|
| 277 | - array('admin','upload_imageresize_height','600',0), |
|
| 278 | - array('admin','upload_imageresize_quality','90',0), |
|
| 279 | - array('admin','enable_send_email_on_user_login','0', 0), |
|
| 280 | - array('admin','enable_user_can_create_folders','0', 0), |
|
| 281 | - array('admin','insert_manual_entry_item_history','0', 0), |
|
| 282 | - array('admin','enable_kb','0', 0), |
|
| 283 | - array('admin','enable_email_notification_on_item_shown','0', 0), |
|
| 284 | - array('admin','enable_email_notification_on_user_pw_change','0', 0), |
|
| 285 | - array('admin','enable_sts','0', 0), |
|
| 286 | - array('admin','encryptClientServer','1', 0), |
|
| 287 | - array('admin','use_md5_password_as_salt','0', 0), |
|
| 288 | - array('admin','api','0', 0), |
|
| 272 | + array('admin', 'upload_imagesext', 'jpg,jpeg,gif,png', 0), |
|
| 273 | + array('admin', 'upload_pkgext', '7z,rar,tar,zip', 0), |
|
| 274 | + array('admin', 'upload_otherext', 'sql,xml', 0), |
|
| 275 | + array('admin', 'upload_imageresize_options', '1', 0), |
|
| 276 | + array('admin', 'upload_imageresize_width', '800', 0), |
|
| 277 | + array('admin', 'upload_imageresize_height', '600', 0), |
|
| 278 | + array('admin', 'upload_imageresize_quality', '90', 0), |
|
| 279 | + array('admin', 'enable_send_email_on_user_login', '0', 0), |
|
| 280 | + array('admin', 'enable_user_can_create_folders', '0', 0), |
|
| 281 | + array('admin', 'insert_manual_entry_item_history', '0', 0), |
|
| 282 | + array('admin', 'enable_kb', '0', 0), |
|
| 283 | + array('admin', 'enable_email_notification_on_item_shown', '0', 0), |
|
| 284 | + array('admin', 'enable_email_notification_on_user_pw_change', '0', 0), |
|
| 285 | + array('admin', 'enable_sts', '0', 0), |
|
| 286 | + array('admin', 'encryptClientServer', '1', 0), |
|
| 287 | + array('admin', 'use_md5_password_as_salt', '0', 0), |
|
| 288 | + array('admin', 'api', '0', 0), |
|
| 289 | 289 | array('admin', 'subfolder_rights_as_parent', '0', 0), |
| 290 | 290 | array('admin', 'show_only_accessible_folders', '0', 0), |
| 291 | 291 | array('admin', 'enable_suggestion', '0', 0), |
| 292 | 292 | array('admin', 'email_server_url', '', 0), |
| 293 | - array('admin','otv_expiration_period','7', 0), |
|
| 294 | - array('admin','default_session_expiration_time','60', 0), |
|
| 295 | - array('admin','duo','0', 0), |
|
| 296 | - array('admin','enable_server_password_change','0', 0), |
|
| 297 | - array('admin','bck_script_path', $_SESSION['abspath']."/backups", 0), |
|
| 298 | - array('admin','bck_script_filename', 'bck_cpassman', 0) |
|
| 293 | + array('admin', 'otv_expiration_period', '7', 0), |
|
| 294 | + array('admin', 'default_session_expiration_time', '60', 0), |
|
| 295 | + array('admin', 'duo', '0', 0), |
|
| 296 | + array('admin', 'enable_server_password_change', '0', 0), |
|
| 297 | + array('admin', 'bck_script_path', $_SESSION['abspath']."/backups", 0), |
|
| 298 | + array('admin', 'bck_script_filename', 'bck_cpassman', 0) |
|
| 299 | 299 | ); |
| 300 | 300 | $res1 = "na"; |
| 301 | 301 | foreach ($val as $elem) { |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | ); |
| 606 | 606 | |
| 607 | 607 | // Clean timestamp for users table |
| 608 | -mysqli_query($dbTmp,"UPDATE ".$_SESSION['pre']."users SET timestamp = ''"); |
|
| 608 | +mysqli_query($dbTmp, "UPDATE ".$_SESSION['pre']."users SET timestamp = ''"); |
|
| 609 | 609 | |
| 610 | 610 | ## Alter nested_tree table |
| 611 | 611 | $res2 = addColumnIfNotExist( |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | ); |
| 700 | 700 | |
| 701 | 701 | ## TABLE CACHE |
| 702 | -mysqli_query($dbTmp,"DROP TABLE IF EXISTS `".$_SESSION['pre']."cache`"); |
|
| 702 | +mysqli_query($dbTmp, "DROP TABLE IF EXISTS `".$_SESSION['pre']."cache`"); |
|
| 703 | 703 | $res8 = mysqli_query($dbTmp, |
| 704 | 704 | "CREATE TABLE IF NOT EXISTS `".$_SESSION['pre']."cache` ( |
| 705 | 705 | `id` int(12) NOT NULL, |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | INNER JOIN ".$_SESSION['pre']."log_items as l ON (l.id_item = i.id) |
| 723 | 723 | AND l.action = 'at_creation' |
| 724 | 724 | WHERE i.inactif=0"; |
| 725 | - $rows = mysqli_query($dbTmp,$sql); |
|
| 725 | + $rows = mysqli_query($dbTmp, $sql); |
|
| 726 | 726 | while ($reccord = mysqli_fetch_array($rows)) { |
| 727 | 727 | //Get all TAGS |
| 728 | 728 | $tags = ""; |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | if (!empty($itemTags)) { |
| 735 | 735 | foreach ($itemTags as $itemTag) { |
| 736 | 736 | if (!empty($itemTag['tag'])) { |
| 737 | - $tags .= $itemTag['tag']. " "; |
|
| 737 | + $tags .= $itemTag['tag']." "; |
|
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | } |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | ); |
| 869 | 869 | |
| 870 | 870 | //Drop old table |
| 871 | - mysqli_query($dbTmp,"DROP TABLE ".$_SESSION['pre']."functions"); |
|
| 871 | + mysqli_query($dbTmp, "DROP TABLE ".$_SESSION['pre']."functions"); |
|
| 872 | 872 | } elseif ($tableFunctionExists == false) { |
| 873 | 873 | echo '[{"finish":"1", "msg":"", "error":"An error appears on table ROLES! '.addslashes(mysqli_error($dbTmp)).'"}]'; |
| 874 | 874 | mysqli_close($dbTmp); |
@@ -962,9 +962,9 @@ discard block |
||
| 962 | 962 | exit(); |
| 963 | 963 | } |
| 964 | 964 | $resTmp = mysqli_fetch_row( |
| 965 | - mysqli_query($dbTmp,"SELECT COUNT(*) FROM ".$_SESSION['pre']."languages") |
|
| 965 | + mysqli_query($dbTmp, "SELECT COUNT(*) FROM ".$_SESSION['pre']."languages") |
|
| 966 | 966 | ); |
| 967 | -mysqli_query($dbTmp,"TRUNCATE TABLE ".$_SESSION['pre']."languages"); |
|
| 967 | +mysqli_query($dbTmp, "TRUNCATE TABLE ".$_SESSION['pre']."languages"); |
|
| 968 | 968 | mysqli_query($dbTmp, |
| 969 | 969 | "INSERT IGNORE INTO `".$_SESSION['pre']."languages` |
| 970 | 970 | (`id`, `name`, `label`, `code`, `flag`) VALUES |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | function getSettingValue($val) |
| 55 | 55 | { |
| 56 | 56 | $val = trim(strstr($val, "=")); |
| 57 | - return trim(str_replace('"', '', substr($val, 1, strpos($val, ";")-1))); |
|
| 57 | + return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1))); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | ################ |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | global $dbTmp; |
| 66 | 66 | $exists = false; |
| 67 | 67 | $columns = mysqli_query($dbTmp, "show columns from $db"); |
| 68 | - while ($c = mysqli_fetch_assoc( $columns)) { |
|
| 68 | + while ($c = mysqli_fetch_assoc($columns)) { |
|
| 69 | 69 | if ($c['Field'] == $column) { |
| 70 | 70 | $exists = true; |
| 71 | 71 | return true; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -function addIndexIfNotExist($table, $index, $sql ) { |
|
| 81 | +function addIndexIfNotExist($table, $index, $sql) { |
|
| 82 | 82 | global $dbTmp; |
| 83 | 83 | |
| 84 | 84 | $mysqli_result = mysqli_query($dbTmp, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\""); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | // if index does not exist, then add it |
| 88 | 88 | if (!$res) { |
| 89 | - $res = mysqli_query($dbTmp, "ALTER TABLE `$table` " . $sql); |
|
| 89 | + $res = mysqli_query($dbTmp, "ALTER TABLE `$table` ".$sql); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $res; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | // change to 0 if auto_update_pwd_next_date empty in ITEMS table |
| 251 | 251 | $result = mysqli_query($dbTmp, "SELECT id FROM `".$_SESSION['pre']."items` WHERE auto_update_pwd_next_date = ''"); |
| 252 | -while($row = mysqli_fetch_assoc($result)) { |
|
| 252 | +while ($row = mysqli_fetch_assoc($result)) { |
|
| 253 | 253 | mysqli_query($dbTmp, |
| 254 | 254 | "UPDATE `".$_SESSION['pre']."items` |
| 255 | 255 | SET `auto_update_pwd_next_date` = '0' |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | // "The file $csrfp_file already exist. A copy has been created.<br />"; |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | - unlink($csrfp_file); // delete existing csrfp.config file |
|
| 287 | - copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file |
|
| 286 | + unlink($csrfp_file); // delete existing csrfp.config file |
|
| 287 | + copy($csrfp_file_sample, $csrfp_file); // make a copy of csrfp.config.sample file |
|
| 288 | 288 | $data = file_get_contents("../includes/libraries/csrfp/libs/csrfp.config.php"); |
| 289 | 289 | $newdata = str_replace('"CSRFP_TOKEN" => ""', '"CSRFP_TOKEN" => "'.bin2hex(openssl_random_pseudo_bytes(25)).'"', $data); |
| 290 | 290 | $newdata = str_replace('"tokenLength" => "25"', '"tokenLength" => "50"', $newdata); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | \$SETTINGS = array ("; |
| 314 | 314 | |
| 315 | 315 | $result = mysqli_query($dbTmp, "SELECT * FROM `".$_SESSION['pre']."misc` WHERE type = 'admin'"); |
| 316 | - while($row = mysqli_fetch_assoc($result)) { |
|
| 316 | + while ($row = mysqli_fetch_assoc($result)) { |
|
| 317 | 317 | // append new setting in config file |
| 318 | 318 | $config_text .= " |
| 319 | 319 | '".$row['intitule']."' => '".$row['valeur']."',"; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | // clean duplicate ldap_object_class from bad update script version |
| 335 | 335 | $tmp = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class'")); |
| 336 | -if ($tmp[0] > 1 ) { |
|
| 336 | +if ($tmp[0] > 1) { |
|
| 337 | 337 | mysqli_query($dbTmp, "DELETE FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'ldap_object_class' AND `valeur` = 0"); |
| 338 | 338 | } |
| 339 | 339 | // add new setting - ldap_object_class |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | $tmp_googlecount = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'google_authentication'")); |
| 347 | 347 | $tmp_twocount = mysqli_fetch_row(mysqli_query($dbTmp, "SELECT COUNT(*) FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = '2factors_authentication'")); |
| 348 | 348 | |
| 349 | -if ($tmp_googlecount[0] > 0 ) { |
|
| 349 | +if ($tmp_googlecount[0] > 0) { |
|
| 350 | 350 | mysqli_query($dbTmp, "DELETE FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = '2factors_authentication'"); |
| 351 | 351 | } else { |
| 352 | - if ($tmp_twocount[0] > 0 ) { |
|
| 352 | + if ($tmp_twocount[0] > 0) { |
|
| 353 | 353 | mysqli_query($dbTmp, "UPDATE `".$_SESSION['pre']."misc` SET intitule = 'google_authentication' WHERE intitule = '2factors_authentication' "); |
| 354 | 354 | } else { |
| 355 | 355 | mysqli_query($dbTmp, "INSERT INTO `".$_SESSION['pre']."misc` VALUES ('admin', 'google_authentication', '0')"); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | FROM `".$_SESSION['pre']."nested_tree` |
| 366 | 366 | WHERE personal_folder = '1' AND nlevel = '1' AND parent_id = '0'" |
| 367 | 367 | ); |
| 368 | -while($row = mysqli_fetch_assoc($result)) { |
|
| 368 | +while ($row = mysqli_fetch_assoc($result)) { |
|
| 369 | 369 | // only change non numeric folder title |
| 370 | 370 | if (!is_numeric($row['title'])) { |
| 371 | 371 | mysqli_query( |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | function getSettingValue($val) |
| 35 | 35 | { |
| 36 | 36 | $val = trim(strstr($val, "=")); |
| 37 | - return trim(str_replace('"', '', substr($val, 1, strpos($val, ";")-1))); |
|
| 37 | + return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1))); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | ################ |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | global $dbTmp; |
| 46 | 46 | $exists = false; |
| 47 | 47 | $columns = mysqli_query($dbTmp, "show columns from $db"); |
| 48 | - while ($c = mysqli_fetch_assoc( $columns)) { |
|
| 48 | + while ($c = mysqli_fetch_assoc($columns)) { |
|
| 49 | 49 | if ($c['Field'] == $column) { |
| 50 | 50 | $exists = true; |
| 51 | 51 | return true; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -function addIndexIfNotExist($table, $index, $sql ) { |
|
| 61 | +function addIndexIfNotExist($table, $index, $sql) { |
|
| 62 | 62 | global $dbTmp; |
| 63 | 63 | |
| 64 | 64 | $mysqli_result = mysqli_query($dbTmp, "SHOW INDEX FROM $table WHERE key_name LIKE \"$index\""); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | // if index does not exist, then add it |
| 68 | 68 | if (!$res) { |
| 69 | - $res = mysqli_query($dbTmp, "ALTER TABLE `$table` " . $sql); |
|
| 69 | + $res = mysqli_query($dbTmp, "ALTER TABLE `$table` ".$sql); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return $res; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // if yes, then don't execute re-encryption |
| 153 | 153 | $_SESSION['tp_defuse_installed'] = false; |
| 154 | 154 | $columns = mysqli_query($dbTmp, "show columns from ".$_SESSION['pre']."items"); |
| 155 | -while ($c = mysqli_fetch_assoc( $columns)) { |
|
| 155 | +while ($c = mysqli_fetch_assoc($columns)) { |
|
| 156 | 156 | if ($c['Field'] === "encryption_type") { |
| 157 | 157 | $_SESSION['tp_defuse_installed'] = true; |
| 158 | 158 | } |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | // do clean of users table |
| 212 | 212 | $fieldsToUpdate = ['groupes_visibles', 'fonction_id', 'groupes_interdits']; |
| 213 | 213 | $result = mysqli_query($dbTmp, "SELECT id, groupes_visibles, fonction_id, groupes_interdits FROM `".$_SESSION['pre']."users`"); |
| 214 | -while($row = mysqli_fetch_assoc($result)) { |
|
| 214 | +while ($row = mysqli_fetch_assoc($result)) { |
|
| 215 | 215 | // check if field contains , instead of ; |
| 216 | - foreach($fieldsToUpdate as $field) { |
|
| 216 | + foreach ($fieldsToUpdate as $field) { |
|
| 217 | 217 | $tmp = cleanFields($row[$field]); |
| 218 | 218 | if ($tmp !== $row[$field]) { |
| 219 | 219 | mysqli_query($dbTmp, |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | if (!isset($_SESSION['tp_defuse_installed']) || $_SESSION['tp_defuse_installed'] === false) { |
| 335 | 335 | $filename = "../includes/config/settings.php"; |
| 336 | 336 | $settingsFile = file($filename); |
| 337 | - while (list($key,$val) = each($settingsFile)) { |
|
| 338 | - if (substr_count($val, 'require_once "')>0 && substr_count($val, 'sk.php')>0) { |
|
| 339 | - $_SESSION['sk_file'] = substr($val, 14, strpos($val, '";')-14); |
|
| 337 | + while (list($key, $val) = each($settingsFile)) { |
|
| 338 | + if (substr_count($val, 'require_once "') > 0 && substr_count($val, 'sk.php') > 0) { |
|
| 339 | + $_SESSION['sk_file'] = substr($val, 14, strpos($val, '";') - 14); |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | $dbTmp, |
| 381 | 381 | "SELECT id FROM `".$_SESSION['pre']."users`" |
| 382 | 382 | ); |
| 383 | - while($row_user = mysqli_fetch_assoc($result)) { |
|
| 383 | + while ($row_user = mysqli_fetch_assoc($result)) { |
|
| 384 | 384 | $result_items = mysqli_query( |
| 385 | 385 | $dbTmp, |
| 386 | 386 | "SELECT i.id AS item_id |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $tmp = mysqli_num_rows(mysqli_query($dbTmp, "SELECT * FROM `".$_SESSION['pre']."misc` WHERE type = 'admin' AND intitule = 'send_stats_time'")); |
| 455 | 455 | if ($tmp === "0") { |
| 456 | 456 | mysqli_query($dbTmp, |
| 457 | - "INSERT INTO `".$_SESSION['pre']."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'send_stats_time', '".(time()-2592000)."')" |
|
| 457 | + "INSERT INTO `".$_SESSION['pre']."misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'send_stats_time', '".(time() - 2592000)."')" |
|
| 458 | 458 | ); |
| 459 | 459 | } |
| 460 | 460 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | function getSettingValue($val) |
| 11 | 11 | { |
| 12 | 12 | $val = trim(strstr($val, "=")); |
| 13 | - return trim(str_replace('"', '', substr($val, 1, strpos($val, ";")-1))); |
|
| 13 | + return trim(str_replace('"', '', substr($val, 1, strpos($val, ";") - 1))); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | //get infos from SETTINGS.PHP file |
@@ -19,41 +19,41 @@ discard block |
||
| 19 | 19 | if (file_exists($filename)) { |
| 20 | 20 | //copy some constants from this existing file |
| 21 | 21 | $settings_file = file($filename); |
| 22 | - while (list($key,$val) = each($settings_file)) { |
|
| 23 | - if (substr_count($val,'charset')>0) { |
|
| 22 | + while (list($key, $val) = each($settings_file)) { |
|
| 23 | + if (substr_count($val, 'charset') > 0) { |
|
| 24 | 24 | $_SESSION['charset'] = getSettingValue($val); |
| 25 | - } elseif (substr_count($val,'@define(')>0 && substr_count($val, 'SALT')>0) { |
|
| 26 | - $_SESSION['encrypt_key'] = substr($val,17,strpos($val,"')")-17); |
|
| 27 | - } elseif (substr_count($val,'$smtp_server = ')>0) { |
|
| 25 | + } elseif (substr_count($val, '@define(') > 0 && substr_count($val, 'SALT') > 0) { |
|
| 26 | + $_SESSION['encrypt_key'] = substr($val, 17, strpos($val, "')") - 17); |
|
| 27 | + } elseif (substr_count($val, '$smtp_server = ') > 0) { |
|
| 28 | 28 | $_SESSION['smtp_server'] = getSettingValue($val); |
| 29 | - } elseif (substr_count($val,'$smtp_auth = ')>0) { |
|
| 29 | + } elseif (substr_count($val, '$smtp_auth = ') > 0) { |
|
| 30 | 30 | $_SESSION['smtp_auth'] = getSettingValue($val); |
| 31 | - } elseif (substr_count($val,'$smtp_port = ')>0) { |
|
| 31 | + } elseif (substr_count($val, '$smtp_port = ') > 0) { |
|
| 32 | 32 | $_SESSION['smtp_port'] = getSettingValue($val); |
| 33 | - } elseif (substr_count($val,'$smtp_security = ')>0) { |
|
| 33 | + } elseif (substr_count($val, '$smtp_security = ') > 0) { |
|
| 34 | 34 | $_SESSION['smtp_security'] = getSettingValue($val); |
| 35 | - } elseif (substr_count($val,'$smtp_auth_username = ')>0) { |
|
| 35 | + } elseif (substr_count($val, '$smtp_auth_username = ') > 0) { |
|
| 36 | 36 | $_SESSION['smtp_auth_username'] = getSettingValue($val); |
| 37 | - } elseif (substr_count($val,'$smtp_auth_password = ')>0) { |
|
| 37 | + } elseif (substr_count($val, '$smtp_auth_password = ') > 0) { |
|
| 38 | 38 | $_SESSION['smtp_auth_password'] = getSettingValue($val); |
| 39 | - } elseif (substr_count($val,'$email_from = ')>0) { |
|
| 39 | + } elseif (substr_count($val, '$email_from = ') > 0) { |
|
| 40 | 40 | $_SESSION['email_from'] = getSettingValue($val); |
| 41 | - } elseif (substr_count($val,'$email_from_name = ')>0) { |
|
| 41 | + } elseif (substr_count($val, '$email_from_name = ') > 0) { |
|
| 42 | 42 | $_SESSION['email_from_name'] = getSettingValue($val); |
| 43 | - } elseif (substr_count($val,'$server = ')>0) { |
|
| 43 | + } elseif (substr_count($val, '$server = ') > 0) { |
|
| 44 | 44 | $_SESSION['server'] = getSettingValue($val); |
| 45 | - } elseif (substr_count($val,'$user = ')>0) { |
|
| 45 | + } elseif (substr_count($val, '$user = ') > 0) { |
|
| 46 | 46 | $_SESSION['user'] = getSettingValue($val); |
| 47 | - } elseif (substr_count($val,'$pass = ')>0) { |
|
| 47 | + } elseif (substr_count($val, '$pass = ') > 0) { |
|
| 48 | 48 | $_SESSION['pass'] = getSettingValue($val); |
| 49 | - } elseif (substr_count($val,'$port = ')>0) { |
|
| 49 | + } elseif (substr_count($val, '$port = ') > 0) { |
|
| 50 | 50 | $_SESSION['port'] = getSettingValue($val); |
| 51 | - } elseif (substr_count($val,'$database = ')>0) { |
|
| 51 | + } elseif (substr_count($val, '$database = ') > 0) { |
|
| 52 | 52 | $_SESSION['database'] = getSettingValue($val); |
| 53 | - } elseif (substr_count($val,'$pre = ')>0) { |
|
| 53 | + } elseif (substr_count($val, '$pre = ') > 0) { |
|
| 54 | 54 | $_SESSION['pre'] = getSettingValue($val); |
| 55 | - } elseif (substr_count($val,'require_once "')>0 && substr_count($val, 'sk.php')>0) { |
|
| 56 | - $_SESSION['sk_path'] = substr($val,14,strpos($val,'";')-14); |
|
| 55 | + } elseif (substr_count($val, 'require_once "') > 0 && substr_count($val, 'sk.php') > 0) { |
|
| 56 | + $_SESSION['sk_path'] = substr($val, 14, strpos($val, '";') - 14); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | ) { |
| 64 | 64 | //copy some constants from this existing file |
| 65 | 65 | $skFile = file($_SESSION['sk_file']); |
| 66 | - while (list($key,$val) = each($skFile)) { |
|
| 67 | - if (substr_count($val, '@define(')>0) { |
|
| 68 | - $_SESSION['encrypt_key'] = substr($val, 17, strpos($val, "')")-17); |
|
| 66 | + while (list($key, $val) = each($skFile)) { |
|
| 67 | + if (substr_count($val, '@define(') > 0) { |
|
| 68 | + $_SESSION['encrypt_key'] = substr($val, 17, strpos($val, "')") - 17); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -310,8 +310,8 @@ discard block |
||
| 310 | 310 | |
| 311 | 311 | |
| 312 | 312 | //define root path |
| 313 | -$abs_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF'])-20); |
|
| 314 | -if( isset($_SERVER['HTTPS'] ) ) { |
|
| 313 | +$abs_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/').substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF']) - 20); |
|
| 314 | +if (isset($_SERVER['HTTPS'])) { |
|
| 315 | 315 | $protocol = 'https://'; |
| 316 | 316 | } else { |
| 317 | 317 | $protocol = 'http://'; |
@@ -334,12 +334,12 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | //HIDDEN THINGS |
| 336 | 336 | echo ' |
| 337 | - <input type="hidden" id="step" name="step" value="', isset($_POST['step']) ? $_POST['step']:'', '" /> |
|
| 338 | - <input type="hidden" id="actual_cpm_version" name="actual_cpm_version" value="', isset($_POST['actual_cpm_version']) ? $_POST['actual_cpm_version']:'', '" /> |
|
| 339 | - <input type="hidden" id="cpm_isUTF8" name="cpm_isUTF8" value="', isset($_POST['cpm_isUTF8']) ? $_POST['cpm_isUTF8']:'', '" /> |
|
| 337 | + <input type="hidden" id="step" name="step" value="', isset($_POST['step']) ? $_POST['step'] : '', '" /> |
|
| 338 | + <input type="hidden" id="actual_cpm_version" name="actual_cpm_version" value="', isset($_POST['actual_cpm_version']) ? $_POST['actual_cpm_version'] : '', '" /> |
|
| 339 | + <input type="hidden" id="cpm_isUTF8" name="cpm_isUTF8" value="', isset($_POST['cpm_isUTF8']) ? $_POST['cpm_isUTF8'] : '', '" /> |
|
| 340 | 340 | <input type="hidden" name="menu_action" id="menu_action" value="" /> |
| 341 | 341 | <input type="hidden" name="user_granted" id="user_granted" value="" /> |
| 342 | - <input type="hidden" name="session_salt" id="session_salt" value="', (isset($_POST['session_salt']) && !empty($_POST['session_salt'])) ? $_POST['session_salt']:@$_SESSION['encrypt_key'], '" />'; |
|
| 342 | + <input type="hidden" name="session_salt" id="session_salt" value="', (isset($_POST['session_salt']) && !empty($_POST['session_salt'])) ? $_POST['session_salt'] : @$_SESSION['encrypt_key'], '" />'; |
|
| 343 | 343 | |
| 344 | 344 | if (!isset($_GET['step']) && !isset($_POST['step'])) { |
| 345 | 345 | //ETAPE O |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | echo '<br /><br /> |
| 572 | 572 | <label for="sk_path" style="width:300px;">Absolute path to SaltKey : |
| 573 | 573 | <img src="images/information-white.png" alt="" title="The SaltKey is stored in a file called sk.php. But for security reasons, this file should be stored in a folder outside the www folder of your server. So please, indicate here the path to this folder."> |
| 574 | - </label><input type="text" id="sk_path" name="sk_path" value="'.substr($_SESSION['sk_path'], 0, strlen($_SESSION['sk_path'])-7).'" size="75" /><br /> |
|
| 574 | + </label><input type="text" id="sk_path" name="sk_path" value="'.substr($_SESSION['sk_path'], 0, strlen($_SESSION['sk_path']) - 7).'" size="75" /><br /> |
|
| 575 | 575 | '; |
| 576 | 576 | } |
| 577 | 577 | echo ' |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | <div style="width:900px;margin:auto;margin-top:30px;"> |
| 603 | 603 | <div id="progressbar" style="float:left;margin-top:9px;"></div> |
| 604 | 604 | <div id="buttons_bottom"> |
| 605 | - <input type="button" id="but_next" target_id="'. (intval($_POST['step'])+1).'" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="NEXT" /> |
|
| 605 | + <input type="button" id="but_next" target_id="'. (intval($_POST['step']) + 1).'" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="NEXT" /> |
|
| 606 | 606 | </div> |
| 607 | 607 | </div>'; |
| 608 | 608 | } elseif ($_POST['step'] == 3 && $conversion_utf8 == true && $_SESSION['user_granted'] === "1") { |
@@ -610,22 +610,22 @@ discard block |
||
| 610 | 610 | <div style="width:900px;margin:auto;margin-top:30px;"> |
| 611 | 611 | <div id="progressbar" style="float:left;margin-top:9px;"></div> |
| 612 | 612 | <div id="buttons_bottom"> |
| 613 | - <input type="button" id="but_launch" onclick="Check(\'step'.$_POST['step'] .'\')" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="LAUNCH" /> |
|
| 614 | - <input type="button" id="but_next" target_id="'. (intval($_POST['step'])+1).'" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="NEXT" disabled="disabled" /> |
|
| 613 | + <input type="button" id="but_launch" onclick="Check(\'step'.$_POST['step'].'\')" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="LAUNCH" /> |
|
| 614 | + <input type="button" id="but_next" target_id="'. (intval($_POST['step']) + 1).'" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="NEXT" disabled="disabled" /> |
|
| 615 | 615 | </div> |
| 616 | 616 | </div>'; |
| 617 | 617 | } elseif ($_POST['step'] == 6 && $_SESSION['user_granted'] === "1") { |
| 618 | 618 | echo ' |
| 619 | 619 | <div style="margin-top:30px; text-align:center; width:100%; font-size:24px;"> |
| 620 | - <a href="#" onclick="javascript:window.location.href=\'', (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'https' : 'http', '://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],'/')-8).'\';"><b>Open TeamPass</b></a> |
|
| 620 | + <a href="#" onclick="javascript:window.location.href=\'', (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'https' : 'http', '://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/') - 8).'\';"><b>Open TeamPass</b></a> |
|
| 621 | 621 | </div>'; |
| 622 | 622 | } else { |
| 623 | 623 | echo ' |
| 624 | 624 | <div style="width:900px;margin:auto;margin-top:30px;"> |
| 625 | 625 | <div id="progressbar" style="float:left;margin-top:9px;"></div> |
| 626 | 626 | <div id="buttons_bottom"> |
| 627 | - <input type="button" id="but_launch" onclick="Check(\'step'.$_POST['step'] .'\')" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="LAUNCH" /> |
|
| 628 | - <input type="button" id="but_next" target_id="'. (intval($_POST['step'])+1).'" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="NEXT" disabled="disabled" /> |
|
| 627 | + <input type="button" id="but_launch" onclick="Check(\'step'.$_POST['step'].'\')" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="LAUNCH" /> |
|
| 628 | + <input type="button" id="but_next" target_id="'. (intval($_POST['step']) + 1).'" style="padding:3px;cursor:pointer;font-size:20px;" class="ui-state-default ui-corner-all" value="NEXT" disabled="disabled" /> |
|
| 629 | 629 | </div> |
| 630 | 630 | </div>'; |
| 631 | 631 | } |
@@ -18,8 +18,8 @@ |
||
| 18 | 18 | <body> |
| 19 | 19 | <?php |
| 20 | 20 | // define root path |
| 21 | -$abs_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF']) - 20); |
|
| 22 | -if( isset($_SERVER['HTTPS'] ) ) { |
|
| 21 | +$abs_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/').substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF']) - 20); |
|
| 22 | +if (isset($_SERVER['HTTPS'])) { |
|
| 23 | 23 | $protocol = 'https://'; |
| 24 | 24 | } else { |
| 25 | 25 | $protocol = 'http://'; |