
SET PATH TO progs_cs, progs, forms, libs, include, speciality, views, progs_ftp ADDITIVE 
SET ENGINEBEHAVIOR 70
SET SAFETY OFF 

CLOSE DATA

STORE .F. TO slovenskaverzia, is_kongres
STORE .T. TO issql
STORE "" TO sqlserver, sqlmeno, sqlheslo, sqlprefix, sqldatabaza, sqltyp, sqlsuffix, sqladresa, sqlconnectstring, sqltypspojenia, sqlsslmode
STORE "" TO sqlconnectold, sqlport, sqldriver, sqlvyber, sqlmenospojenia, menospojenia
STORE 0  TO pocetsqlspojeni

gcpri_path = m.pri_path
gccollate  = "machine"
fn_hesla   = "neexistuje"

STORE 77 TO INTERNET_OPTION_IGNORE_OFFLINE

DO sql_ini

IF VARTYPE(vysledek) # "C"
    vysledek = ""
ENDIF 
vysledek = m.vysledek + " SQL Db: \\" + m.sqladresa + "\" + m.sqldatabaza + m.crlf

DO clos_data
DO open_database_food


*!*****************************************************************************
*!      Function: CODE_PWD
*!*****************************************************************************
FUNCTION code_pwd
LPARAMETERS c_vstup, dekodovat
PRIVATE ret, ii, jj, seed
seed = "#5)0% A+'@^&*("
ret = ""
FOR ii = 1 TO LEN(c_vstup)
    IF PARAMETERS() = 1
        c_vstup = UPPER(m.c_vstup)
        jj = ASC(SUBSTR(m.c_vstup, m.ii, 1)) + m.ii + ASC(SUBSTR(m.seed, MOD(m.ii,10), 1))
        jj = IIF(m.jj > 255, m.jj - 255, m.jj)
    ELSE
        jj = ASC(SUBSTR(m.c_vstup, m.ii, 1)) - m.ii - ASC(SUBSTR(m.seed, MOD(m.ii,10), 1))
        jj = IIF(m.jj < 0,   m.jj + 255, m.jj)
    ENDIF
    ret = ret + CHR(m.jj)
ENDFOR
RETURN ret

*!*****************************************************************************
FUNCTION put_ini (a,b,c,d,e)


*!*****************************************************************************
*!      Procedure: CLOS_DATA
*!*****************************************************************************
PROCEDURE clos_data
TRY
   CLOSE DATABASES
   CLOSE DATABASES
CATCH
ENDTRY


*!*****************************************************************************
PROCEDURE nastavsety
SET TALK        OFF
SET COLLATE TO (m.gccollate)
SET AUTOINCERROR OFF
SET SYSFORMATS    ON
SET BELL TO        888,1
SET BELL        OFF
SET CARRY        OFF
SET CLOCK        OFF
SET CENTURY        ON
SET CONFIRM        ON
SET ESCAPE        OFF
SET EXACT        OFF
SET MULTILOCKS    ON
SET MEMOWIDTH TO 100
SET ECHO        OFF
SET SAFETY        OFF
SET DELETED        ON
SET DATE TO        GERMAN
SET EXCLUSIVE    OFF
SET NEAR        ON
SET HOURS TO    24
SET REPROCESS TO AUTO
*set reprocess to 11 seconds
SET CPDIALOG    OFF
SET NULLDISPLAY TO ""
IF ".FXP"$UPPER(SYS(16,0))
    SET reportbehavior 80
ENDIF
_incseek=1


*!*****************************************************************************
PROCEDURE open_database_food
boladb = DBUSED("food600_ps")
IF m.boladb
    SET DATABASE TO food600_ps
ELSE
    IF .not. FILE(m.gcpri_path + "food600_ps.dbc")
        COPY FILE (m.gcini_path + "views\food600_ps.*") TO (gcpri_path + "food600_ps.*")
    ENDIF 
    OPEN DATABASE (m.gcpri_path + "food600_ps") EXCLUSIVE 
ENDIF


*!*****************************************************************************
PROCEDURE close_database
TRY
    CLOSE DATABASES
    CLOSE TABLES
CATCH
ENDTRY



*!*****************************************************************************
FUNCTION depwd
PARAMETERS txt
IF VARTYPE(txt) = "C" AND LEN(m.txt)>0
    detxt = ""
    delka = LEN(m.txt)

    FOR iii = 1 TO m.delka STEP 2
        cislo1 = ASC(SUBSTR(m.txt, m.iii  , 1)) - 97 - INT(m.iii/2 + .51) % 5
        cislo2 = ASC(SUBSTR(m.txt, m.iii+1, 1)) - 97 - INT(m.iii/2 + .51) % 4
        IF BETWEEN(cislo2*8+cislo1,0,255)
            TRY 
        detxt = m.detxt + CHR(cislo2*8 + cislo1)
            CATCH
            ENDTRY 
        ENDIF 
    ENDFOR
    RETURN ALLTRIM(m.detxt)
ELSE 
    RETURN "NO PASSWORD"
ENDIF 

*!*****************************************************************************
FUNCTION pwd
PARAMETERS untxt
IF VARTYPE(untxt) = "C"
    txt = ""
    delka = LEN(m.untxt)
    FOR iii = 1 TO m.delka
        pismenko = ASC(SUBSTR(m.untxt, m.iii, 1))
        txt = m.txt + ;
            CHR(97 + BITAND(m.pismenko, 7)    + m.iii % 5) + ;
            CHR(97 + BITRSHIFT(m.pismenko, 3) + m.iii % 4)
    ENDFOR
    RETURN m.txt
ELSE 
    RETURN "NO PASSWORD"
ENDIF 


*!*****************************************************************************
PROCEDURE backslash ( cesta )
cesta = ALLTRIM(m.cesta) + IIF(RIGHT(ALLTRIM(m.cesta), 1)="\", "", "\")

