Code Duplication    Length = 29-29 lines in 2 locations

sources/main.functions.php 2 locations

@@ 1908-1936 (lines=29) @@
1905
1906
        // Now perform action on the file
1907
        $err = '';
1908
        if ($type === 'decrypt') {
1909
            try {
1910
                \Defuse\Crypto\File::decryptFile(
1911
                    $source_file,
1912
                    $target_file,
1913
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1914
                );
1915
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1916
                $err = "decryption_not_possible";
1917
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1918
                $err = $ex;
1919
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1920
                $err = $ex;
1921
            }
1922
        } elseif ($type === 'encrypt') {
1923
            try {
1924
                \Defuse\Crypto\File::encryptFile(
1925
                    $source_file,
1926
                    $target_file,
1927
                    \Defuse\Crypto\Key::loadFromAsciiSafeString($ascii_key)
1928
                );
1929
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1930
                $err = "encryption_not_possible";
1931
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1932
                $err = $ex;
1933
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1934
                $err = $ex;
1935
            }
1936
        }
1937
    } else {
1938
    /*
1939
    File encryption/decryption is done with special password and not the SALTKEY
@@ 1943-1971 (lines=29) @@
1940
     */
1941
1942
        $err = '';
1943
        if ($type === 'decrypt') {
1944
            try {
1945
                \Defuse\Crypto\File::decryptFileWithPassword(
1946
                    $source_file,
1947
                    $target_file,
1948
                    $password
1949
                );
1950
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1951
                $err = "wrong_key";
1952
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1953
                $err = $ex;
1954
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1955
                $err = $ex;
1956
            }
1957
        } elseif ($type === 'encrypt') {
1958
            try {
1959
                \Defuse\Crypto\File::encryptFileWithPassword(
1960
                    $source_file,
1961
                    $target_file,
1962
                    $password
1963
                );
1964
            } catch (Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException $ex) {
1965
                $err = "wrong_key";
1966
            } catch (Defuse\Crypto\Exception\EnvironmentIsBrokenException $ex) {
1967
                $err = $ex;
1968
            } catch (Defuse\Crypto\Exception\IOException $ex) {
1969
                $err = $ex;
1970
            }
1971
        }
1972
    }
1973
1974
    // return error