wip: convert to cmdline
This commit is contained in:
parent
8c76b976bb
commit
e56dad405c
Binary file not shown.
|
@ -21,9 +21,8 @@ program main
|
|||
call request(form_data, length)
|
||||
|
||||
if (length .gt. 0) then
|
||||
inquire (file=db_path, exist=exist)
|
||||
inquire (file=trim(adjustl(db_path)), exist=exist)
|
||||
if (.not. exist) then
|
||||
write (12, *) trim(adjustl(db_path))
|
||||
call create_db(db_path)
|
||||
end if
|
||||
|
||||
|
@ -42,12 +41,13 @@ contains
|
|||
character(len=128), intent(in) :: db_path
|
||||
character(len=:), allocatable :: command
|
||||
|
||||
command = 'CREATE TABLE users ' &
|
||||
command = 'sqlite3 '//trim(adjustl(db_path)) &
|
||||
//' ''CREATE TABLE users ' &
|
||||
//'(id INTEGER PRIMARY KEY ASC, ' &
|
||||
//'username TEXT, password TEXT, ' &
|
||||
//'apperance TEXT, x_pos INTEGER, ' &
|
||||
//'y_pos INTEGER, last_login INTEGER, ' &
|
||||
//' created INTEGER);'
|
||||
//' created INTEGER);'''
|
||||
write (12, *) command
|
||||
call execute_command_line(command)
|
||||
|
||||
|
@ -59,50 +59,53 @@ contains
|
|||
integer, intent(in) :: length
|
||||
|
||||
character(len=:), allocatable :: command
|
||||
character(len=24) :: username
|
||||
character(len=24) :: password
|
||||
character(len=32) :: encrypted_password
|
||||
character(len=32) :: created
|
||||
character(len=8) :: appearance
|
||||
integer :: i, s_idx, e_idx
|
||||
integer :: i, s_u_idx, e_u_idx, s_p_idx, e_p_idx, s_a_idx
|
||||
|
||||
get_username: do i = 1, length
|
||||
if (request(i) .eq. '=') then
|
||||
s_idx = i + 1
|
||||
s_u_idx = i + 1
|
||||
end if
|
||||
|
||||
if (request(i) .eq. '&') then
|
||||
e_idx = i - 1
|
||||
e_u_idx = i - 1
|
||||
exit get_username
|
||||
end if
|
||||
end do get_username
|
||||
username = transfer(request(s_idx:e_idx), username)
|
||||
! username = transfer(request(s_idx:e_idx), username)
|
||||
|
||||
get_password: do i = e_idx + 2, length
|
||||
get_password: do i = e_u_idx + 2, length
|
||||
if (request(i) .eq. '=') then
|
||||
s_idx = i + 1
|
||||
s_p_idx = i + 1
|
||||
end if
|
||||
|
||||
if (request(i) .eq. '&') then
|
||||
e_idx = i - 1
|
||||
e_p_idx = i - 1
|
||||
exit get_password
|
||||
end if
|
||||
end do get_password
|
||||
password = transfer(request(s_idx:e_idx), password)
|
||||
! password = transfer(request(s_idx:e_idx), password)
|
||||
|
||||
get_appearance: do i = e_idx + 2, length
|
||||
get_appearance: do i = e_p_idx + 2, length
|
||||
if (request(i) .eq. '=') then
|
||||
s_idx = i + 1
|
||||
s_a_idx = i + 1
|
||||
end if
|
||||
end do get_appearance
|
||||
appearance = transfer(request(s_idx:length), appearance)
|
||||
! appearance = transfer(request(s_a_idx:length), appearance)
|
||||
|
||||
write (created, *) time()
|
||||
|
||||
command = 'sqlite3 '//trim(adjustl(db_path))//' "INSERT INTO users (username, password' &
|
||||
//', apperance, x_pos, y_pos, last_login, created) VALUES ('''//username &
|
||||
//''', '''//trim(adjustl(password))//''', '''//trim(adjustl(appearance)) &
|
||||
//''',0, 0, 0,'//trim(adjustl(created))//');"'
|
||||
command = 'sqlite3 ' &
|
||||
//trim(adjustl(db_path)) &
|
||||
//' "INSERT INTO users (username,password' &
|
||||
//',apperance,x_pos,y_pos,last_login,created) VALUES (''' &
|
||||
//request(s_u_idx:e_u_idx) &
|
||||
//''',''' &
|
||||
//request(s_p_idx:e_p_idx) &
|
||||
//''',''' &
|
||||
//request(s_a_idx:length) &
|
||||
//''',0,0,0,' &
|
||||
//created//');"'
|
||||
write (12, *) command
|
||||
call execute_command_line(command)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ contains
|
|||
integer, intent(in) :: length
|
||||
|
||||
write (output_unit, '(A)') "HTTP/1.1 200 OK"
|
||||
write (output_unit, '(A)') "Server: fortran-µhttpd"
|
||||
write (output_unit, '(A)') "Server: fortran-micro-httpd"
|
||||
write (output_unit, '(A)') "Content-Type: text/html; charset=UTF-8"
|
||||
write (output_unit, '(A)', advance='no') "Content-length: "
|
||||
write (output_unit, *) length
|
||||
|
|
Loading…
Reference in New Issue