Index: Sitemap.fpr
==================================================================
--- Sitemap.fpr
+++ Sitemap.fpr
cannot compute difference between binary files
ADDED download.asm
Index: download.asm
==================================================================
--- /dev/null
+++ download.asm
@@ -0,0 +1,226 @@
+include "%lib%/freshlib.inc"
+
+@BinaryType console
+
+options.ShowSkipped = 0
+options.ShowSizes = 1
+options.DebugMode = 0
+options.AlignCode = 0
+
+HeapManager equ ASM
+
+
+include "%lib%/freshlib.asm"
+
+uglobal
+ hPath dd ?
+ hHost dd ?
+ hQuery dd ?
+
+ hFileName dd ?
+ hFileHash dd ?
+ hFileRepo dd ?
+ hRemoteIP dd ?
+endg
+
+
+start:
+ InitializeAll
+
+ stdcall GetEnvVariable, 'REMOTE_ADDR'
+ jc .error
+
+ mov [hRemoteIP], eax
+
+ stdcall GetEnvVariable, 'SCRIPT_FILENAME'
+ jc .error
+
+ mov [hPath], eax
+
+ stdcall StrSplitFilename, [hPath]
+ stdcall StrDel, eax
+
+ stdcall GetEnvVariable, 'HTTP_HOST'
+ jc .error
+
+ mov ecx, eax
+
+ stdcall StrDup, 'http://'
+
+ stdcall StrCat, eax, ecx
+ stdcall StrDel, ecx
+ stdcall FixTrailingSlash, eax
+ mov [hHost], eax
+
+ stdcall GetEnvVariable, 'QUERY_STRING'
+ jc .error
+
+ mov [hQuery], eax
+
+ stdcall GetQueryItem, [hQuery], 'repo='
+ jc .error
+
+ mov [hFileRepo], eax
+
+ stdcall StrCat, [hHost], 'fossil/repo/'
+ stdcall StrCat, [hHost], eax
+ stdcall StrCat, [hHost], '/raw/'
+
+ stdcall GetQueryItem, [hQuery], 'file='
+ jc .error
+
+ mov [hFileName], eax
+ stdcall StrCat, [hHost], eax
+
+ stdcall GetQueryItem, [hQuery], 'hash='
+ jc .error
+
+ mov [hFileHash], eax
+
+ stdcall StrCat, [hHost], '?name='
+ stdcall StrCat, [hHost], eax
+
+ stdcall LogTheDownload
+
+ stdcall FileWriteString, [STDOUT], cHeader303
+ stdcall FileWriteString, [STDOUT], 'Location: '
+ stdcall FileWriteString, [STDOUT], [hHost]
+ stdcall FileWriteString, [STDOUT], cCRLF2
+
+ jmp .exit
+
+.error:
+ stdcall FileWriteString, [STDOUT], cHeader404
+
+.exit:
+ FinalizeAll
+ stdcall TerminateAll, 0
+
+
+cContentType text 'Content-type: text/html', 13, 10
+cHeader303 text 'Status: 303 See Other', 13, 10
+cHeader404 text 'Status: 404 Not Found', 13, 10, 'Connection: close', 13, 10, 13, 10, '
404 Not Found
', 13, 10
+cCRLF text 13, 10
+cCRLF2 text 13, 10, 13, 10
+
+
+proc GetQueryItem, .hQuery, .itemname
+begin
+ push ecx esi
+
+ stdcall StrLen, [.itemname]
+ mov ecx, eax
+
+ stdcall StrPos, [.hQuery], [.itemname]
+ jnz .item_found
+
+ stc
+ pop esi ecx
+ return
+
+.item_found:
+ lea esi, [eax+ecx]
+ stdcall StrCharPos, esi, '&'
+ jnz .copy_item
+
+ stdcall StrLen, esi
+ lea eax, [esi+eax]
+
+.copy_item:
+ sub eax, esi
+ stdcall StrExtract, esi, 0, eax
+ stdcall StrURLDecode, eax
+ clc
+ pop esi ecx
+ return
+endp
+
+
+
+proc FixTrailingSlash, .hPath
+begin
+ push eax ecx
+ stdcall StrLen, [.hPath]
+ dec eax
+ mov ecx, eax
+ stdcall StrPtr, [.hPath]
+ cmp byte [eax+ecx], '/'
+ je .path_ok
+ stdcall StrCharCat, [.hPath], '/'
+.path_ok:
+ pop ecx eax
+ return
+endp
+
+
+
+proc LogTheDownload
+.time dd ?
+.now dq ?
+.date TDateTime
+begin
+ pushad
+
+ stdcall StrCat, [hPath], 'downloads.inc'
+
+ stdcall GetTimestamp
+ mov [.time], eax
+
+.loop:
+ stdcall FileOpenAccess, [hPath], faReadWrite or faOpenAlways
+ jnc .file_ok
+
+ stdcall Sleep, 20
+
+ stdcall GetTimestamp
+ sub eax, [.time]
+ cmp eax, 3000
+ jl .loop
+
+ stc
+ popad
+ return
+
+
+.file_ok:
+ mov ebx, eax
+ stdcall FileSeek, ebx, 0, fsFromEnd
+
+ stdcall GetTime
+ mov dword [.now], eax
+ mov dword [.now+4], edx
+
+ lea eax, [.now]
+ lea edx, [.date]
+ stdcall TimeToDateTime, eax, edx
+ stdcall DateTimeToStr, edx, 0
+ mov esi, eax
+
+ stdcall StrCharInsert, esi, '[', 0
+ stdcall StrCharCat, esi, ']:['
+ stdcall StrCat, esi, [hRemoteIP]
+ stdcall StrCharCat, esi, '],['
+ stdcall StrCat, esi, [hFileName]
+ stdcall StrCharCat, esi, '],['
+ stdcall StrCat, esi, [hFileRepo]
+ stdcall StrCharCat, esi, '],['
+ stdcall StrCat, esi, [hFileHash]
+ stdcall StrCharCat, esi, ']'
+
+ stdcall FileWriteString, ebx, esi
+ stdcall FileWriteString, ebx, cCRLF
+
+ stdcall FileClose, ebx
+
+ clc
+ popad
+ return
+endp
+
+
+
+
+
+
+
+
ADDED download.fpr
Index: download.fpr
==================================================================
--- /dev/null
+++ download.fpr
cannot compute difference between binary files
Index: feedback.asm
==================================================================
--- feedback.asm
+++ feedback.asm
@@ -292,9 +292,7 @@
cErrorNoPost text 'Error! feedback.cgi needs post data.'
-@AllImportEmbeded
-@AllDataSection
Index: get.asm
==================================================================
--- get.asm
+++ get.asm
@@ -6,39 +6,40 @@
hPageName dd ?
endg
cHackDir text '..'
-cBadPath text '.'
+cBadPath text './'
proc InitScriptVariables
begin
; first read document root.
- stdcall GetEnvVariable, 'DOCUMENT_ROOT'
+ stdcall GetEnvVariable, 'SCRIPT_FILENAME'
jnc .root_ok
stdcall StrDupMem, cBadPath
.root_ok:
mov [hPath], eax
-
-; fix the trailing slash
-
- stdcall StrLen, [hPath]
- dec eax
- mov ecx, eax
- stdcall StrPtr, [hPath]
- cmp byte [eax+ecx], DIR_SLASH
- je .path_ok
-
- stdcall StrCharCat, [hPath], DIR_SLASH
+ stdcall StrSplitFilename, eax
+ stdcall StrDel, eax
+
+; fix the trailing slash - NOT NEEDED if SCRIPT_FILENAME is used as a root directory.
+
+; stdcall StrLen, [hPath]
+; dec eax
+; mov ecx, eax
+; stdcall StrPtr, [hPath]
+; cmp byte [eax+ecx], DIR_SLASH
+; je .path_ok
+;
+; stdcall StrCharCat, [hPath], DIR_SLASH
; then read query string
.path_ok:
-; stdcall StrCat, [hPath], 'test/'
stdcall GetEnvVariable, 'QUERY_STRING'
jnc .query_ok
stdcall StrNew
.query_ok:
Index: index.asm
==================================================================
--- index.asm
+++ index.asm
@@ -48,10 +48,13 @@
mov [StartTime], eax
InitializeAll
stdcall InitScriptVariables
+
+; stdcall FileWriteString, [STDOUT], [hPath]
+; jmp .exit
stdcall GetPostData
jc .post_data_ok
stdcall StrDup, cSysMessagePreview
@@ -87,9 +90,7 @@
cLinkPage text ' href="index.cgi?page='
cScript text 'index.cgi?page='
-@AllImportEmbeded
-@AllDataSection
Index: save.asm
==================================================================
--- save.asm
+++ save.asm
@@ -40,10 +40,19 @@
InitializeAll
stdcall InitScriptVariables
+
+; in the case of "save.cgi" get the path one directory back.
+
+ stdcall StrLen, [hPath]
+ dec eax
+ stdcall StrTrim, [hPath], eax
+ stdcall StrSplitFilename, [hPath]
+ stdcall StrDel, eax
+
stdcall GetPostData
jc .no_post_data
; save the article
@@ -70,32 +79,37 @@
stdcall FileClose, ebx
jc .file_write_error
stdcall LogEvent, cArticleModified, [hPageName], [hFileTitle]
-
cArticleModified text 'edited.'
- stdcall StrDup, cSaveOKMessage
- mov [hSysMessage], eax
+ stdcall FileWriteString, [STDOUT], 'Location: '
+ stdcall FileWriteString, [STDOUT], '/index.cgi?page='
+ stdcall FileWriteString, [STDOUT], [hPageName]
+ stdcall FileWriteString, [STDOUT], cCRLF
+ stdcall FileWriteString, [STDOUT], cCRLF
+ jmp .exit
+
-.finish:
+.finish_error:
stdcall ReadTemplate, cTemplateFileName
- jc .template_ok
+ jc @f
mov [pHTMLTemplate], eax
-
-.template_ok:
+@@:
stdcall FileWrite, [STDOUT], cContentType, cContentType.length
stdcall WriteTemplate, [pHTMLTemplate], [STDOUT], SaveVarCallback
+.exit:
FinalizeAll
stdcall TerminateAll,0
+
.no_post_data:
stdcall StrDup, cErrorNoPost
mov [hSysMessage], eax
- jmp .finish
+ jmp .finish_error
.file_write_error:
push eax
stdcall FileClose, ebx
@@ -118,25 +132,21 @@
mov [hSysMessage], ecx
stdcall NumToStr, eax, ntsSigned or ntsDec
stdcall StrCat, ecx, eax
stdcall StrDel, eax
stdcall StrCharCat, ecx, $0a
- jmp .finish
+ jmp .finish_error
cCRLF text $0d, $0a
cTemplateFileName text 'save/save.inc'
cDefaultTemplate text '$sysmsg$
Home'
cContentType text 'Content-type: text/html', 13, 10, 13, 10
-
-
cErrorNoPost text 'Error! save.cgi needs post data.'
-cSaveOKMessage text 'The file was saved.'
+cSaveOKMessage text 'The file has been saved.'
-@AllImportEmbeded
-@AllDataSection
Index: sitemap.asm
==================================================================
--- sitemap.asm
+++ sitemap.asm
@@ -18,12 +18,10 @@
hPath dd ?
hHost dd ?
endg
- cBadPath text '.'
-
; rb 256 ; FASM ELF generator sometimes is buggy. Inserting some more bytes, fixes the problem.
start:
@@ -31,16 +29,15 @@
mov [StartTime], eax
InitializeAll
- stdcall GetEnvVariable, 'DOCUMENT_ROOT'
- jnc .root_ok
- stdcall StrDupMem, cBadPath
-.root_ok:
- stdcall FixTrailingSlash, eax
+; first read document root.
+ stdcall GetEnvVariable, 'SCRIPT_FILENAME'
mov [hPath], eax
+ stdcall StrSplitFilename, eax
+ stdcall StrDel, eax
stdcall GetEnvVariable, 'HTTP_HOST'
jnc .host_ok
stdcall StrDup, 'InvalidHost'
@@ -260,9 +257,7 @@
-@AllImportEmbeded
-@AllDataSection
Index: test_env.asm
==================================================================
--- test_env.asm
+++ test_env.asm
@@ -101,9 +101,6 @@
-@AllImportEmbeded
-@AllDataSection
-
Index: test_env.fpr
==================================================================
--- test_env.fpr
+++ test_env.fpr
cannot compute difference between binary files
ADDED www/content/0index.txt
Index: www/content/0index.txt
==================================================================
--- /dev/null
+++ www/content/0index.txt
@@ -0,0 +1,8 @@
+Test article
+# Test article
+
+РЕДАКТИРАНЕ2 The answer is 42
+
+This is test article to be used for experiments with saving and editing articles.
+
+another text
DELETED www/content/index.txt
Index: www/content/index.txt
==================================================================
--- www/content/index.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-Introduction
-# Introduction
-
-## What is MiniMagAsm?
-
-MiniMagAsm is minimalistic, but powerful and flexible content management system ( [CMS] ),
-implemented entirely in assembly language.
-
-[CMS] http://en.wikipedia.org/wiki/Content_management_system
-
-## Is it free?
-
-MiniMagAsm is free, open source project, distributed under the terms of ["The Fresh Artistic License"].
-
-["The Fresh Artistic License"] /index.cgi?page=content/docs/tfal.txt
-
-*"Author"* of MiniMagAsm is John Found.
-
-## How to get the source?
-
-The source code of MiniMagAsm is hosted in the [repository].
-
-The version control system used is [fossil-scm], but you can visit the above address
-and download .zip files with the latest version (or any of the previous versions as well).
-
-[repository] http://chiselapp.com/user/johnfound/repository/MiniMagAsm/index
-[fossil-scm] http://fossil-scm.org/
-
-## How to use MiniMagAsm?
-
-In order to use MiniMagAsm you will need а web server, supporting binary executables as CGI scripts.
-
-All decent hosting providers allows this feature. Usually they refer to it as CGI-BIN or simply mention
-C++ in one line with PHP, Perl, etc.
-
-The server hardware must be x86 compatible and the operating system Linux or Windows.
-
-About installation and use of MiniMagAsm you should read [docs/manual_en.txt][the user manual].
ADDED www/download.cgi
Index: www/download.cgi
==================================================================
--- /dev/null
+++ www/download.cgi
cannot compute difference between binary files
Index: www/feedback.cgi
==================================================================
--- www/feedback.cgi
+++ www/feedback.cgi
cannot compute difference between binary files
Index: www/index.cgi
==================================================================
--- www/index.cgi
+++ www/index.cgi
cannot compute difference between binary files
ADDED www/robots.txt
Index: www/robots.txt
==================================================================
--- /dev/null
+++ www/robots.txt
@@ -0,0 +1,5 @@
+User-agent: *
+Crawl-delay: 5
+Disallow: /archive.cgi/
+Sitemap: http://asm32.hopto.org/sitemap.cgi
+
Index: www/save/save.cgi
==================================================================
--- www/save/save.cgi
+++ www/save/save.cgi
cannot compute difference between binary files
Index: www/sitemap.cgi
==================================================================
--- www/sitemap.cgi
+++ www/sitemap.cgi
cannot compute difference between binary files
Index: www/test_env.cgi
==================================================================
--- www/test_env.cgi
+++ www/test_env.cgi
cannot compute difference between binary files