Initial commit default tip
authorBrent Angeline <info@interos.org>
Sat May 01 16:19:36 2010 -0400
changeset 026ed165bdfba
Initial commit
c/access_interos.com_ssl.c
c/bottom_interos.com_ssl.c
c/browse_interos.com_ssl.c
c/content_interos.com_ssl.c
c/interos.c
c/interos.h
c/interos.org.h
c/interos.org_interos.org_ssl.h
c/interos_interos.com_ssl.c
c/interos_interos.com_ssl.h
c/login_interos.com_ssl.c
c/logout_interos.com_ssl.c
c/main_interos.com_ssl.c
c/menu_interos.com_ssl.c
c/new_interos.com_ssl.c
c/new_user_interos.com_ssl.c
c/next_interos.com_ssl.c
c/open_interos.com_ssl.c
c/settings_interos.com_ssl.c
c/template.c
c/top_interos.com_ssl.c
c/upload_interos.com_ssl.c
c/user_interos.com_ssl.c
c/welcome_back_interos.com_ssl.c
c/welcome_interos.com_ssl.c
c/xml/append_interos.com_ssl.c
c/xml/copy_interos.com_ssl.c
c/xml/delete_interos.com_ssl.c
c/xml/files_interos.com_ssl.c
c/xml/interos.h
c/xml/move_interos.com_ssl.c
c/xml/new_folder_interos.com_ssl.c
c/xml/persist_interos.com_ssl.c
c/xml/save_interos.com_ssl.c
c/xml/template_interos.com_ssl.c
c/xml/user_interos.com_ssl.c
conf/httpd.conf
dtd/xhtml1-borderless-frameset.dtd
images/buttons/new.gif
images/buttons/new_down.gif
images/buttons/new_faded.gif
images/buttons/new_up.gif
images/buttons/next.gif
images/buttons/next_faded.gif
images/buttons/next_up.gif
images/buttons/open.gif
images/buttons/open_down.gif
images/buttons/open_faded.gif
images/buttons/open_up.gif
images/buttons/settings.gif
images/buttons/settings_down.gif
images/buttons/settings_faded.gif
images/buttons/settings_up.gif
images/docs/flash/text_editor/spec/1.gif
images/docs/flash/text_editor/spec/2a-i.gif
images/docs/flash/text_editor/spec/2a-ii.gif
images/docs/flash/text_editor/spec/2a-iii.gif
images/docs/flash/text_editor/spec/2a-iv.gif
images/docs/flash/text_editor/spec/2b-i.gif
images/docs/flash/text_editor/spec/2b-ii.gif
images/favicon.gif-moved
images/favicon.ico
images/favicon.ico-moved
images/icons/browse/go.png
images/icons/browse/home.png
images/icons/browse/reload.png
images/icons/browse/stop.png
images/icons/new/alarm.png
images/icons/new/application.png
images/icons/new/bookmark.png
images/icons/new/chat.png
images/icons/new/copy.png
images/icons/new/document.png
images/icons/new/download.png
images/icons/new/e-mail.png
images/icons/new/folder.png
images/icons/new/image.png
images/icons/new/music.png
images/icons/new/phone_call.png
images/icons/new/search.png
images/icons/new/share.png
images/icons/new/text_file.png
images/icons/new/upload.png
images/icons/new/video.png
images/icons/new/web_page.png
images/icons/next/bookmark.png
images/icons/next/close.png
images/icons/next/logout.png
images/icons/next/save.png
images/icons/next/save_as.png
images/icons/open/alarm.png
images/icons/open/bookmark.png
images/icons/open/document.png
images/icons/open/e-mail.png
images/icons/open/image.png
images/icons/open/incoming.png
images/icons/open/music.png
images/icons/open/shared.png
images/icons/open/text_file.png
images/icons/open/video.png
images/icons/settings/audio.png
images/icons/settings/buttons.png
images/icons/settings/chat.png
images/icons/settings/clock.png
images/icons/settings/downloads.png
images/icons/settings/e-mail.png
images/icons/settings/images.png
images/icons/settings/phone.png
images/icons/settings/search.png
images/icons/settings/video.png
images/interos.org_logo.gif
images/interos.org_logo.png
images/login/arrow.gif
images/login/arrow_down.gif
images/login/i.gif
images/login/new.gif
images/login/new_faded.gif
images/login/next.gif
images/login/next_faded.gif
images/login/nteros.gif
images/login/open.gif
images/login/open_faded.gif
images/login/settings.gif
images/login/settings_faded.gif
images/menu/new_bottom.gif
images/menu/new_top.gif
images/menu/next_bottom.gif
images/menu/next_top.gif
images/menu/open_bottom.gif
images/menu/open_top.gif
images/menu/settings_bottom.gif
images/menu/settings_top.gif
images/panel/bottom.gif
images/panel/bottom_left.gif
images/panel/bottom_right.gif
images/panel/left.gif
images/panel/login.gif
images/panel/login/top.gif
images/panel/login/top_left.gif
images/panel/login/top_right.gif
images/panel/main/top.gif
images/panel/main/top_left.gif
images/panel/main/top_right.gif
images/panel/right.gif
images/panel/title/top.gif
images/panel/title/top_left.gif
images/panel/title/top_right.gif
images/panel/welcome/bottom.gif
images/panel/welcome/bottom_left.gif
images/panel/welcome/bottom_right.gif
images/panel/welcome/left.gif
images/panel/welcome/right.gif
images/panel/welcome/top.gif
images/panel/welcome/top_left.gif
images/panel/welcome/top_right.gif
images/toolbar.gif
js/bottom_interos.com_ssl.js
js/content_interos.com_ssl.js
js/default_interos.com.js
js/default_interos.com_ssl.js
js/default_interos.org.js
js/default_interos.org_ssl.js
js/home_interos.com.js
js/home_interos.com_ssl.js
js/login_interos.com_ssl.js
js/main_interos.com_ssl.js
js/menu_interos.com_ssl.js
js/new_interos.com_ssl.js
js/next_interos.com_ssl.js
js/open_interos.com_ssl.js
js/settings_interos.com_ssl.js
js/top_interos.com_ssl.js
js/welcome_interos.com_ssl.js
style/content_interos.com_ssl.css
style/default_interos.com.css
style/default_interos.com_ssl.css
style/default_interos.org.css
style/default_interos.org_ssl.css
style/images/box/head.gif
style/images/box/highlight.gif
style/images/buttons/new.gif
style/images/buttons/new_down.gif
style/images/buttons/new_faded.gif
style/images/buttons/new_up.gif
style/images/buttons/new_up_faded.gif
style/images/buttons/next.gif
style/images/buttons/next_down.gif
style/images/buttons/next_faded.gif
style/images/buttons/next_up.gif
style/images/buttons/next_up_faded.gif
style/images/buttons/open.gif
style/images/buttons/open_down.gif
style/images/buttons/open_faded.gif
style/images/buttons/open_up.gif
style/images/buttons/open_up_faded.gif
style/images/buttons/settings.gif
style/images/buttons/settings_down.gif
style/images/buttons/settings_faded.gif
style/images/buttons/settings_up.gif
style/images/buttons/settings_up_faded.gif
style/images/menu/active.gif
style/images/menu/new_hover.gif
style/images/menu/new_top.gif
style/images/menu/next_hover.gif
style/images/menu/next_top.gif
style/images/menu/open_hover.gif
style/images/menu/open_top.gif
style/images/menu/settings_hover.gif
style/images/menu/settings_top.gif
style/images/panel/main.gif
style/images/panel/title.gif
style/images/panel/welcome.gif
style/images/toolbar.gif
style/images/toolbar_shaded.gif
style/login_interos.com_ssl.css
style/main_interos.com_ssl.css
style/menu_interos.com_ssl.css
xhtml/cgi/bottom_interos.com_ssl.xhtml
xhtml/cgi/bottom_js_interos.com_ssl.xhtml
xhtml/cgi/bottom_new_interos.com_ssl.xhtml
xhtml/cgi/bottom_settings_interos.com_ssl.xhtml
xhtml/cgi/browse_interos.com_ssl.xhtml
xhtml/cgi/content_interos.com_ssl.xhtml
xhtml/cgi/login_interos.com_ssl.xhtml
xhtml/cgi/main_interos.com_ssl.xhtml
xhtml/cgi/main_js_interos.com_ssl.xhtml
xhtml/cgi/main_new_interos.com_ssl.xhtml
xhtml/cgi/main_next_interos.com_ssl.xhtml
xhtml/cgi/main_open_interos.com_ssl.xhtml
xhtml/cgi/main_settings_interos.com_ssl.xhtml
xhtml/cgi/menu_new_interos.com_ssl.xhtml
xhtml/cgi/menu_next_interos.com_ssl.xhtml
xhtml/cgi/menu_open_interos.com_ssl.xhtml
xhtml/cgi/menu_settings_interos.com_ssl.xhtml
xhtml/cgi/new_interos.com_ssl.xhtml
xhtml/cgi/new_js_interos.com_ssl.xhtml
xhtml/cgi/new_user_interos.com_ssl.xhtml
xhtml/cgi/next_interos.com_ssl.xhtml
xhtml/cgi/next_js_interos.com_ssl.xhtml
xhtml/cgi/open_interos.com_ssl.xhtml
xhtml/cgi/open_js_interos.com_ssl.xhtml
xhtml/cgi/settings_interos.com_ssl.xhtml
xhtml/cgi/settings_js_interos.com_ssl.xhtml
xhtml/cgi/top_interos.com_ssl.xhtml
xhtml/cgi/top_js_interos.com_ssl.xhtml
xhtml/cgi/top_next_interos.com_ssl.xhtml
xhtml/cgi/top_open_interos.com_ssl.xhtml
xhtml/cgi/welcome_back_interos.com_ssl.xhtml
xhtml/cgi/welcome_interos.com_ssl.xhtml
xhtml/cgi/welcome_js_interos.com_ssl.xhtml
xhtml/docs/flash/text_editor/spec_interos.org.xhtml
xhtml/page/about_interos.com.xhtml
xhtml/page/about_interos.com_ssl.xhtml
xhtml/page/about_interos.org.xhtml
xhtml/page/about_interos.org_ssl.xhtml
xhtml/page/blog_interos.com.xhtml
xhtml/page/blog_interos.com_ssl.xhtml
xhtml/page/blog_interos.org.xhtml
xhtml/page/blog_interos.org_ssl.xhtml
xhtml/page/code_interos.com.xhtml
xhtml/page/code_interos.com_ssl.xhtml
xhtml/page/code_interos.org.xhtml
xhtml/page/code_interos.org_ssl.xhtml
xhtml/page/default.xhtml
xhtml/page/default_ssl.xhtml
xhtml/page/demo_interos.com.xhtml
xhtml/page/demo_interos.com_ssl.xhtml
xhtml/page/e-mail_interos.com.xhtml
xhtml/page/e-mail_interos.com_ssl.xhtml
xhtml/page/e-mail_interos.org.xhtml
xhtml/page/e-mail_interos.org_ssl.xhtml
xhtml/page/faq_interos.com.xhtml
xhtml/page/faq_interos.com_ssl.xhtml
xhtml/page/faq_interos.org.xhtml
xhtml/page/faq_interos.org_ssl.xhtml
xhtml/page/gear_interos.com.xhtml
xhtml/page/gear_interos.com_ssl.xhtml
xhtml/page/gear_interos.org.xhtml
xhtml/page/gear_interos.org_ssl.xhtml
xhtml/page/help_interos.com.xhtml
xhtml/page/help_interos.com_ssl.xhtml
xhtml/page/help_interos.org.xhtml
xhtml/page/help_interos.org_ssl.xhtml
xhtml/page/home_interos.com.xhtml
xhtml/page/home_interos.com_ssl.xhtml
xhtml/page/home_interos.org.xhtml
xhtml/page/home_interos.org_old.xhtml
xhtml/page/home_interos.org_ssl.xhtml
xhtml/page/home_interos.org_ssl_old.xhtml
xhtml/template.xhtml
xml/c/access_interos.com_ssl.c
xml/c/bottom_interos.com_ssl.c
xml/c/browse_interos.com_ssl.c
xml/c/content_interos.com_ssl.c
xml/c/interos.c
xml/c/interos.h
xml/c/interos.org.h
xml/c/interos.org_interos.org_ssl.h
xml/c/interos_interos.com_ssl.c
xml/c/interos_interos.com_ssl.h
xml/c/login_interos.com_ssl.c
xml/c/logout_interos.com_ssl.c
xml/c/main_interos.com_ssl.c
xml/c/menu_interos.com_ssl.c
xml/c/new_interos.com_ssl.c
xml/c/new_user_interos.com_ssl.c
xml/c/next_interos.com_ssl.c
xml/c/open_interos.com_ssl.c
xml/c/settings_interos.com_ssl.c
xml/c/template.c
xml/c/top_interos.com_ssl.c
xml/c/upload_interos.com_ssl.c
xml/c/user_interos.com_ssl.c
xml/c/welcome_back_interos.com_ssl.c
xml/c/welcome_interos.com_ssl.c
xml/c/xml/append_interos.com_ssl.c
xml/c/xml/copy_interos.com_ssl.c
xml/c/xml/delete_interos.com_ssl.c
xml/c/xml/files_interos.com_ssl.c
xml/c/xml/interos.h
xml/c/xml/move_interos.com_ssl.c
xml/c/xml/new_folder_interos.com_ssl.c
xml/c/xml/persist_interos.com_ssl.c
xml/c/xml/save_interos.com_ssl.c
xml/c/xml/template_interos.com_ssl.c
xml/c/xml/user_interos.com_ssl.c
xml/conf/httpd.conf
xml/confirmation_interos.com_ssl.xml
xml/dtd/xhtml1-borderless-frameset.dtd
xml/error_interos.com_ssl.xml
xml/files_interos.com_ssl.xml
xml/images/buttons/new.gif
xml/images/buttons/new_down.gif
xml/images/buttons/new_faded.gif
xml/images/buttons/new_up.gif
xml/images/buttons/next.gif
xml/images/buttons/next_faded.gif
xml/images/buttons/next_up.gif
xml/images/buttons/open.gif
xml/images/buttons/open_down.gif
xml/images/buttons/open_faded.gif
xml/images/buttons/open_up.gif
xml/images/buttons/settings.gif
xml/images/buttons/settings_down.gif
xml/images/buttons/settings_faded.gif
xml/images/buttons/settings_up.gif
xml/images/docs/flash/text_editor/spec/1.gif
xml/images/docs/flash/text_editor/spec/2a-i.gif
xml/images/docs/flash/text_editor/spec/2a-ii.gif
xml/images/docs/flash/text_editor/spec/2a-iii.gif
xml/images/docs/flash/text_editor/spec/2a-iv.gif
xml/images/docs/flash/text_editor/spec/2b-i.gif
xml/images/docs/flash/text_editor/spec/2b-ii.gif
xml/images/favicon.gif-moved
xml/images/favicon.ico
xml/images/favicon.ico-moved
xml/images/icons/browse/go.png
xml/images/icons/browse/home.png
xml/images/icons/browse/reload.png
xml/images/icons/browse/stop.png
xml/images/icons/new/alarm.png
xml/images/icons/new/application.png
xml/images/icons/new/bookmark.png
xml/images/icons/new/chat.png
xml/images/icons/new/copy.png
xml/images/icons/new/document.png
xml/images/icons/new/download.png
xml/images/icons/new/e-mail.png
xml/images/icons/new/folder.png
xml/images/icons/new/image.png
xml/images/icons/new/music.png
xml/images/icons/new/phone_call.png
xml/images/icons/new/search.png
xml/images/icons/new/share.png
xml/images/icons/new/text_file.png
xml/images/icons/new/upload.png
xml/images/icons/new/video.png
xml/images/icons/new/web_page.png
xml/images/icons/next/bookmark.png
xml/images/icons/next/close.png
xml/images/icons/next/logout.png
xml/images/icons/next/save.png
xml/images/icons/next/save_as.png
xml/images/icons/open/alarm.png
xml/images/icons/open/bookmark.png
xml/images/icons/open/document.png
xml/images/icons/open/e-mail.png
xml/images/icons/open/image.png
xml/images/icons/open/incoming.png
xml/images/icons/open/music.png
xml/images/icons/open/shared.png
xml/images/icons/open/text_file.png
xml/images/icons/open/video.png
xml/images/icons/settings/audio.png
xml/images/icons/settings/buttons.png
xml/images/icons/settings/chat.png
xml/images/icons/settings/clock.png
xml/images/icons/settings/downloads.png
xml/images/icons/settings/e-mail.png
xml/images/icons/settings/images.png
xml/images/icons/settings/phone.png
xml/images/icons/settings/search.png
xml/images/icons/settings/video.png
xml/images/interos.org_logo.gif
xml/images/interos.org_logo.png
xml/images/login/arrow.gif
xml/images/login/arrow_down.gif
xml/images/login/i.gif
xml/images/login/new.gif
xml/images/login/new_faded.gif
xml/images/login/next.gif
xml/images/login/next_faded.gif
xml/images/login/nteros.gif
xml/images/login/open.gif
xml/images/login/open_faded.gif
xml/images/login/settings.gif
xml/images/login/settings_faded.gif
xml/images/menu/new_bottom.gif
xml/images/menu/new_top.gif
xml/images/menu/next_bottom.gif
xml/images/menu/next_top.gif
xml/images/menu/open_bottom.gif
xml/images/menu/open_top.gif
xml/images/menu/settings_bottom.gif
xml/images/menu/settings_top.gif
xml/images/panel/bottom.gif
xml/images/panel/bottom_left.gif
xml/images/panel/bottom_right.gif
xml/images/panel/left.gif
xml/images/panel/login.gif
xml/images/panel/login/top.gif
xml/images/panel/login/top_left.gif
xml/images/panel/login/top_right.gif
xml/images/panel/main/top.gif
xml/images/panel/main/top_left.gif
xml/images/panel/main/top_right.gif
xml/images/panel/right.gif
xml/images/panel/title/top.gif
xml/images/panel/title/top_left.gif
xml/images/panel/title/top_right.gif
xml/images/panel/welcome/bottom.gif
xml/images/panel/welcome/bottom_left.gif
xml/images/panel/welcome/bottom_right.gif
xml/images/panel/welcome/left.gif
xml/images/panel/welcome/right.gif
xml/images/panel/welcome/top.gif
xml/images/panel/welcome/top_left.gif
xml/images/panel/welcome/top_right.gif
xml/images/toolbar.gif
xml/js/bottom_interos.com_ssl.js
xml/js/content_interos.com_ssl.js
xml/js/default_interos.com.js
xml/js/default_interos.com_ssl.js
xml/js/default_interos.org.js
xml/js/default_interos.org_ssl.js
xml/js/home_interos.com.js
xml/js/home_interos.com_ssl.js
xml/js/login_interos.com_ssl.js
xml/js/main_interos.com_ssl.js
xml/js/menu_interos.com_ssl.js
xml/js/new_interos.com_ssl.js
xml/js/next_interos.com_ssl.js
xml/js/open_interos.com_ssl.js
xml/js/settings_interos.com_ssl.js
xml/js/top_interos.com_ssl.js
xml/js/welcome_interos.com_ssl.js
xml/state_interos.com_ssl.xml
xml/style/content_interos.com_ssl.css
xml/style/default_interos.com.css
xml/style/default_interos.com_ssl.css
xml/style/default_interos.org.css
xml/style/default_interos.org_ssl.css
xml/style/images/box/head.gif
xml/style/images/box/highlight.gif
xml/style/images/buttons/new.gif
xml/style/images/buttons/new_down.gif
xml/style/images/buttons/new_faded.gif
xml/style/images/buttons/new_up.gif
xml/style/images/buttons/new_up_faded.gif
xml/style/images/buttons/next.gif
xml/style/images/buttons/next_down.gif
xml/style/images/buttons/next_faded.gif
xml/style/images/buttons/next_up.gif
xml/style/images/buttons/next_up_faded.gif
xml/style/images/buttons/open.gif
xml/style/images/buttons/open_down.gif
xml/style/images/buttons/open_faded.gif
xml/style/images/buttons/open_up.gif
xml/style/images/buttons/open_up_faded.gif
xml/style/images/buttons/settings.gif
xml/style/images/buttons/settings_down.gif
xml/style/images/buttons/settings_faded.gif
xml/style/images/buttons/settings_up.gif
xml/style/images/buttons/settings_up_faded.gif
xml/style/images/menu/active.gif
xml/style/images/menu/new_hover.gif
xml/style/images/menu/new_top.gif
xml/style/images/menu/next_hover.gif
xml/style/images/menu/next_top.gif
xml/style/images/menu/open_hover.gif
xml/style/images/menu/open_top.gif
xml/style/images/menu/settings_hover.gif
xml/style/images/menu/settings_top.gif
xml/style/images/panel/main.gif
xml/style/images/panel/title.gif
xml/style/images/panel/welcome.gif
xml/style/images/toolbar.gif
xml/style/images/toolbar_shaded.gif
xml/style/login_interos.com_ssl.css
xml/style/main_interos.com_ssl.css
xml/style/menu_interos.com_ssl.css
xml/user_interos.com_ssl.xml
xml/xhtml/cgi/bottom_interos.com_ssl.xhtml
xml/xhtml/cgi/bottom_js_interos.com_ssl.xhtml
xml/xhtml/cgi/bottom_new_interos.com_ssl.xhtml
xml/xhtml/cgi/bottom_settings_interos.com_ssl.xhtml
xml/xhtml/cgi/browse_interos.com_ssl.xhtml
xml/xhtml/cgi/content_interos.com_ssl.xhtml
xml/xhtml/cgi/login_interos.com_ssl.xhtml
xml/xhtml/cgi/main_interos.com_ssl.xhtml
xml/xhtml/cgi/main_js_interos.com_ssl.xhtml
xml/xhtml/cgi/main_new_interos.com_ssl.xhtml
xml/xhtml/cgi/main_next_interos.com_ssl.xhtml
xml/xhtml/cgi/main_open_interos.com_ssl.xhtml
xml/xhtml/cgi/main_settings_interos.com_ssl.xhtml
xml/xhtml/cgi/menu_new_interos.com_ssl.xhtml
xml/xhtml/cgi/menu_next_interos.com_ssl.xhtml
xml/xhtml/cgi/menu_open_interos.com_ssl.xhtml
xml/xhtml/cgi/menu_settings_interos.com_ssl.xhtml
xml/xhtml/cgi/new_interos.com_ssl.xhtml
xml/xhtml/cgi/new_js_interos.com_ssl.xhtml
xml/xhtml/cgi/new_user_interos.com_ssl.xhtml
xml/xhtml/cgi/next_interos.com_ssl.xhtml
xml/xhtml/cgi/next_js_interos.com_ssl.xhtml
xml/xhtml/cgi/open_interos.com_ssl.xhtml
xml/xhtml/cgi/open_js_interos.com_ssl.xhtml
xml/xhtml/cgi/settings_interos.com_ssl.xhtml
xml/xhtml/cgi/settings_js_interos.com_ssl.xhtml
xml/xhtml/cgi/top_interos.com_ssl.xhtml
xml/xhtml/cgi/top_js_interos.com_ssl.xhtml
xml/xhtml/cgi/top_next_interos.com_ssl.xhtml
xml/xhtml/cgi/top_open_interos.com_ssl.xhtml
xml/xhtml/cgi/welcome_back_interos.com_ssl.xhtml
xml/xhtml/cgi/welcome_interos.com_ssl.xhtml
xml/xhtml/cgi/welcome_js_interos.com_ssl.xhtml
xml/xhtml/docs/flash/text_editor/spec_interos.org.xhtml
xml/xhtml/page/about_interos.com.xhtml
xml/xhtml/page/about_interos.com_ssl.xhtml
xml/xhtml/page/about_interos.org.xhtml
xml/xhtml/page/about_interos.org_ssl.xhtml
xml/xhtml/page/blog_interos.com.xhtml
xml/xhtml/page/blog_interos.com_ssl.xhtml
xml/xhtml/page/blog_interos.org.xhtml
xml/xhtml/page/blog_interos.org_ssl.xhtml
xml/xhtml/page/code_interos.com.xhtml
xml/xhtml/page/code_interos.com_ssl.xhtml
xml/xhtml/page/code_interos.org.xhtml
xml/xhtml/page/code_interos.org_ssl.xhtml
xml/xhtml/page/default.xhtml
xml/xhtml/page/default_ssl.xhtml
xml/xhtml/page/demo_interos.com.xhtml
xml/xhtml/page/demo_interos.com_ssl.xhtml
xml/xhtml/page/e-mail_interos.com.xhtml
xml/xhtml/page/e-mail_interos.com_ssl.xhtml
xml/xhtml/page/e-mail_interos.org.xhtml
xml/xhtml/page/e-mail_interos.org_ssl.xhtml
xml/xhtml/page/faq_interos.com.xhtml
xml/xhtml/page/faq_interos.com_ssl.xhtml
xml/xhtml/page/faq_interos.org.xhtml
xml/xhtml/page/faq_interos.org_ssl.xhtml
xml/xhtml/page/gear_interos.com.xhtml
xml/xhtml/page/gear_interos.com_ssl.xhtml
xml/xhtml/page/gear_interos.org.xhtml
xml/xhtml/page/gear_interos.org_ssl.xhtml
xml/xhtml/page/help_interos.com.xhtml
xml/xhtml/page/help_interos.com_ssl.xhtml
xml/xhtml/page/help_interos.org.xhtml
xml/xhtml/page/help_interos.org_ssl.xhtml
xml/xhtml/page/home_interos.com.xhtml
xml/xhtml/page/home_interos.com_ssl.xhtml
xml/xhtml/page/home_interos.org.xhtml
xml/xhtml/page/home_interos.org_old.xhtml
xml/xhtml/page/home_interos.org_ssl.xhtml
xml/xhtml/page/home_interos.org_ssl_old.xhtml
xml/xhtml/template.xhtml
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/c/access_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
     1.3 @@ -0,0 +1,315 @@
     1.4 +/******************************************************/
     1.5 +/*    interos Standard Document Header - CGI in C     */
     1.6 +/******************************************************/
     1.7 +/*         File:  access                              */
     1.8 +/*       Source:  access.c                            */
     1.9 +/*  Description:  FastCGI for interos access checker  */
    1.10 +/*       Author:  Brent Angeline                      */
    1.11 +/*          CGI:  FastCGI in ISO/ANSI C               */
    1.12 +/******************************************************/
    1.13 +
    1.14 +/* PREPROCESSOR DIRECTIVES */
    1.15 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen()                                */
    1.16 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
    1.17 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                               */
    1.18 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen(), strncmp()                        */
    1.19 +#include <unistd.h>         /*  F_OK, access()                                                           */
    1.20 +
    1.21 +/* FUNCTION PROTOTYPE DECLARATIONS */
    1.22 +static void DenyAccess(void);
    1.23 +static void GrantAccess(void);
    1.24 +
    1.25 +/* BEGIN MAIN PROGRAM */
    1.26 +int main(void) {
    1.27 +
    1.28 +  /* BEGIN FASTCGI */
    1.29 +  while (FCGI_Accept() >= 0) {
    1.30 +
    1.31 +    /* IF A URI REQUEST DOESN'T EXIST OR IS TOO LONG... */
    1.32 +    if (!getenv("REQUEST_URI") || (sizeof(strlen(getenv("REQUEST_URI"))) > sizeof(INT))) {
    1.33 +      /** ERROR | A URI REQUEST DOES NOT EXIST OR IS TOO LONG > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
    1.34 +      DenyAccess();
    1.35 +
    1.36 +    /* OTHERWISE, IF A URI REQUEST DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
    1.37 +    } else {
    1.38 +
    1.39 +      /* IF THE URI REQUEST IS FOR A PUBLIC FILE IN THE SERVER ROOT... */
    1.40 +      if (!(strcmp(getenv("REQUEST_URI"), "/") && strcmp(getenv("REQUEST_URI"), "/favicon.ico") &&
    1.41 +            strcmp(getenv("REQUEST_URI"), "/index.html") && strcmp(getenv("REQUEST_URI"), "/index.xhtml") &&
    1.42 +            strcmp(getenv("REQUEST_URI"), "/about") && strcmp(getenv("REQUEST_URI"), "/about/") &&
    1.43 +            strcmp(getenv("REQUEST_URI"), "/blog") && strcmp(getenv("REQUEST_URI"), "/blog/") &&
    1.44 +            strcmp(getenv("REQUEST_URI"), "/code") && strcmp(getenv("REQUEST_URI"), "/code/") &&
    1.45 +            strcmp(getenv("REQUEST_URI"), "/demo") && strcmp(getenv("REQUEST_URI"), "/demo/") &&
    1.46 +            strcmp(getenv("REQUEST_URI"), "/e-mail") && strcmp(getenv("REQUEST_URI"), "/e-mail/") &&
    1.47 +            strcmp(getenv("REQUEST_URI"), "/email") && strcmp(getenv("REQUEST_URI"), "/email/") &&
    1.48 +            strcmp(getenv("REQUEST_URI"), "/f.a.q.") && strcmp(getenv("REQUEST_URI"), "/f.a.q./") &&
    1.49 +            strcmp(getenv("REQUEST_URI"), "/faq") && strcmp(getenv("REQUEST_URI"), "/faq/") &&
    1.50 +            strcmp(getenv("REQUEST_URI"), "/gear") && strcmp(getenv("REQUEST_URI"), "/gear/") &&
    1.51 +            strcmp(getenv("REQUEST_URI"), "/help") && strcmp(getenv("REQUEST_URI"), "/help/") &&
    1.52 +            strcmp(getenv("REQUEST_URI"), "/home") && strcmp(getenv("REQUEST_URI"), "/home/") &&
    1.53 +            strcmp(getenv("REQUEST_URI"), "/bottom") && strcmp(getenv("REQUEST_URI"), "/bottom/") &&
    1.54 +            strcmp(getenv("REQUEST_URI"), "/browse") && strcmp(getenv("REQUEST_URI"), "/browse/") &&
    1.55 +            strcmp(getenv("REQUEST_URI"), "/content") && strcmp(getenv("REQUEST_URI"), "/content/") &&
    1.56 +            strcmp(getenv("REQUEST_URI"), "/login") && strcmp(getenv("REQUEST_URI"), "/login/") &&
    1.57 +            strcmp(getenv("REQUEST_URI"), "/logout") && strcmp(getenv("REQUEST_URI"), "/logout/") &&
    1.58 +            strcmp(getenv("REQUEST_URI"), "/main") && strcmp(getenv("REQUEST_URI"), "/main/") &&
    1.59 +            strcmp(getenv("REQUEST_URI"), "/interos") && strcmp(getenv("REQUEST_URI"), "/interos/") &&
    1.60 +            strcmp(getenv("REQUEST_URI"), "/menu") && strcmp(getenv("REQUEST_URI"), "/menu/") &&
    1.61 +            strcmp(getenv("REQUEST_URI"), "/new") && strcmp(getenv("REQUEST_URI"), "/new/") &&
    1.62 +            strcmp(getenv("REQUEST_URI"), "/new_user") && strcmp(getenv("REQUEST_URI"), "/new_user/") &&
    1.63 +            strcmp(getenv("REQUEST_URI"), "/newuser") && strcmp(getenv("REQUEST_URI"), "/newuser/") &&
    1.64 +            strcmp(getenv("REQUEST_URI"), "/next") && strcmp(getenv("REQUEST_URI"), "/next/") &&
    1.65 +            strcmp(getenv("REQUEST_URI"), "/open") && strcmp(getenv("REQUEST_URI"), "/open/") &&
    1.66 +            strcmp(getenv("REQUEST_URI"), "/settings") && strcmp(getenv("REQUEST_URI"), "/settings/") &&
    1.67 +            strcmp(getenv("REQUEST_URI"), "/top") && strcmp(getenv("REQUEST_URI"), "/top/") &&
    1.68 +            strcmp(getenv("REQUEST_URI"), "/upload") && strcmp(getenv("REQUEST_URI"), "/upload/") &&
    1.69 +            strcmp(getenv("REQUEST_URI"), "/user") && strcmp(getenv("REQUEST_URI"), "/user/") &&
    1.70 +            strcmp(getenv("REQUEST_URI"), "/welcome") && strcmp(getenv("REQUEST_URI"), "/welcome/") &&
    1.71 +            strcmp(getenv("REQUEST_URI"), "/welcome_back") && strcmp(getenv("REQUEST_URI"), "/welcome_back/") &&
    1.72 +            strcmp(getenv("REQUEST_URI"), "/welcomeback") && strcmp(getenv("REQUEST_URI"), "/welcomeback/"))) {
    1.73 +        /** STATUS | PUBLIC FILE > GRANT ACCESS **/
    1.74 +        GrantAccess();
    1.75 +
    1.76 +      /* OTHERWISE, IF THE URI REQUEST IS FOR A PUBLIC SYSTEM FILE... */
    1.77 +      } else if (!(strncmp(getenv("REQUEST_URI"), "/dtd/", 5) &&
    1.78 +                   strncmp(getenv("REQUEST_URI"), "/flash/", 7) &&
    1.79 +                   strncmp(getenv("REQUEST_URI"), "/flex/", 6) &&
    1.80 +                   strncmp(getenv("REQUEST_URI"), "/html/", 6) &&
    1.81 +                   strncmp(getenv("REQUEST_URI"), "/icons/", 7) &&
    1.82 +                   strncmp(getenv("REQUEST_URI"), "/images/", 8) &&
    1.83 +                   strncmp(getenv("REQUEST_URI"), "/java/", 6) &&
    1.84 +                   strncmp(getenv("REQUEST_URI"), "/javafx/", 8) &&
    1.85 +                   strncmp(getenv("REQUEST_URI"), "/js/", 4) &&
    1.86 +                   strncmp(getenv("REQUEST_URI"), "/markup/", 8) &&
    1.87 +                   strncmp(getenv("REQUEST_URI"), "/style/", 7) &&
    1.88 +                   strncmp(getenv("REQUEST_URI"), "/sys/", 5) &&
    1.89 +                   strncmp(getenv("REQUEST_URI"), "/xhtml/", 7) &&
    1.90 +                   strncmp(getenv("REQUEST_URI"), "/xml/", 5))) {
    1.91 +        /** STATUS | PUBLIC SYSTEM FILE > GRANT ACCESS **/
    1.92 +        GrantAccess();
    1.93 +
    1.94 +      /* OTHERWISE, THE PROPER COOKIES ARE REQUIRED FOR ACCESS... */
    1.95 +      } else {
    1.96 +
    1.97 +        /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
    1.98 +        if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
    1.99 +          /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
   1.100 +          DenyAccess();
   1.101 +
   1.102 +        /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
   1.103 +        } else {
   1.104 +
   1.105 +          /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
   1.106 +          char *cookie;
   1.107 +          INT cookieLength = strlen(getenv("HTTP_COOKIE"));
   1.108 +          if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
   1.109 +            /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.110 +            DenyAccess();
   1.111 +          } else {
   1.112 +            char *variableName;
   1.113 +            if (!(variableName = malloc(cookieLength + 1))) {
   1.114 +              /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.115 +              DenyAccess();
   1.116 +            } else {
   1.117 +              char *variableValue;
   1.118 +              if (!(variableValue = malloc(cookieLength + 1))) {
   1.119 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.120 +                DenyAccess();
   1.121 +
   1.122 +              /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
   1.123 +              } else {
   1.124 +
   1.125 +                /* PROCESS COOKIE DATA */
   1.126 +                char *login, *password;
   1.127 +                INT c, i;
   1.128 +                login = password = NULL;
   1.129 +                c = 0;
   1.130 +                strcpy(cookie, getenv("HTTP_COOKIE"));
   1.131 +                while ((c < cookieLength) && (cookie[c] != '\0')) {
   1.132 +                  i = 0;
   1.133 +                  while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
   1.134 +                    variableName[i] = cookie[c];
   1.135 +                    ++c;
   1.136 +                    ++i;
   1.137 +                  }
   1.138 +                  variableName[i] = '\0';
   1.139 +                  ++c;
   1.140 +                  i = 0;
   1.141 +                  while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
   1.142 +                    variableValue[i] = cookie[c];
   1.143 +                    ++c;
   1.144 +                    ++i;
   1.145 +                  }
   1.146 +                  variableValue[i] = '\0';
   1.147 +                  ++c;
   1.148 +                  while ((c < cookieLength) && (cookie[c] == ' ')) {
   1.149 +                    ++c;
   1.150 +                  }
   1.151 +                  if (!login && !strcmp(variableName, "login")) {
   1.152 +                    if ((login = malloc(strlen(variableValue) + 1)) != 0) {
   1.153 +                      strcpy(login, variableValue);
   1.154 +                    }
   1.155 +                  } else if (!password && !strcmp(variableName, "password")) {
   1.156 +                    if ((password = malloc(strlen(variableValue) + 1)) != 0) {
   1.157 +                      strcpy(password, variableValue);
   1.158 +                    }
   1.159 +                  }
   1.160 +                }
   1.161 +
   1.162 +                /* IF LOGIN VALUE IS MISSING... */
   1.163 +                if (!login) {
   1.164 +                  /** ERROR | LOGIN VALUE IS MISSING > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.165 +                  DenyAccess();
   1.166 +
   1.167 +                /* OTHERWISE, IF LOGIN VALUE EXISTS... */
   1.168 +                } else {
   1.169 +
   1.170 +                  /* VERIFY LOGIN AND PASSWORD */
   1.171 +                  char *directory;
   1.172 +                  if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
   1.173 +                    /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.174 +                    DenyAccess();
   1.175 +                  } else {
   1.176 +                    char *systemDirectory;
   1.177 +                    if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
   1.178 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.179 +                      DenyAccess();
   1.180 +                    } else {
   1.181 +                      strcpy(directory, DIRECTORY);
   1.182 +                      strcat(directory, login);
   1.183 +                      strcpy(systemDirectory, SYSTEM_DIRECTORY);
   1.184 +                      strcat(systemDirectory, login);
   1.185 +
   1.186 +                      /* IF DIRECTORY CAN'T BE ACCESSED... */
   1.187 +                      if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
   1.188 +                        /** ERROR | CANNOT ACCESS DIRECTORY > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.189 +                        DenyAccess();
   1.190 +
   1.191 +                      /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
   1.192 +                      } else {
   1.193 +
   1.194 +                        /* ATTEMPT TO ACCESS PASSWORD FILE */
   1.195 +                        char *passwordFileName;
   1.196 +                        if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
   1.197 +                          /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.198 +                          DenyAccess();
   1.199 +                        } else {
   1.200 +                          strcpy(passwordFileName, systemDirectory);
   1.201 +                          strcat(passwordFileName, PASSWORD_FILE_NAME);
   1.202 +
   1.203 +                          /* IF PASSWORD FILE CAN'T BE ACCESSED... */
   1.204 +                          if (access(passwordFileName, F_OK)) {
   1.205 +                            /** ERROR | CANNOT ACCESS FILE > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.206 +                            DenyAccess();
   1.207 +
   1.208 +                          /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
   1.209 +                          } else {
   1.210 +
   1.211 +                            /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
   1.212 +                            FILE *passwordFile;
   1.213 +
   1.214 +                            /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
   1.215 +                            if (!(passwordFile = fopen(passwordFileName, "r"))) {
   1.216 +                              /** ERROR | CANNOT READ FILE > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.217 +                              DenyAccess();
   1.218 +
   1.219 +                            /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
   1.220 +                            } else {
   1.221 +                              char *filePassword;
   1.222 +                              if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
   1.223 +                                /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE **/
   1.224 +                                /**       > DENY ACCESS AND REDIRECT TO LOGIN PANEL       **/
   1.225 +                                DenyAccess();
   1.226 +                              } else {
   1.227 +                                char c;
   1.228 +                                i = 0;
   1.229 +
   1.230 +                                /* READ PASSWORD FROM PASSWORD FILE */
   1.231 +                                while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
   1.232 +                                  filePassword[i] = c;
   1.233 +                                  ++i;
   1.234 +                                }
   1.235 +                                filePassword[i] = '\0';
   1.236 +                                fclose(passwordFile);
   1.237 +
   1.238 +                                /* IF PASSWORD FAILS COMPARISON... */
   1.239 +                                if (strcmp(filePassword, password)) {
   1.240 +                                  /** ERROR | PASSWORD FAILED > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.241 +                                  DenyAccess();
   1.242 +
   1.243 +                                /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
   1.244 +                                } else {
   1.245 +                                  char *loginDirectory;
   1.246 +                                  if (!(loginDirectory = malloc(strlen(login) + 3))) {
   1.247 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR LOGIN DIRECTORY NAME **/
   1.248 +                                    /**       > DENY ACCESS AND REDIRECT TO LOGIN PANEL         **/
   1.249 +                                    DenyAccess();
   1.250 +                                  } else {
   1.251 +                                    strcpy(loginDirectory, "/");
   1.252 +                                    strcat(loginDirectory, login);
   1.253 +                                    strcat(loginDirectory, "/");
   1.254 +                                    if (strncmp(loginDirectory, getenv("REQUEST_URI"), (strlen(login) + 2))) {
   1.255 +                                      /** STATUS | FILE DOES NOT BELONG TO USER > DENY ACCESS AND REDIRECT TO LOGIN PANEL **/
   1.256 +                                      DenyAccess();
   1.257 +                                    } else {
   1.258 +                                      /** STATUS | FILE DOES BELONG TO USER > GRANT ACCESS **/
   1.259 +                                      GrantAccess();
   1.260 +                                    }
   1.261 +                                    free(loginDirectory);
   1.262 +                                  }
   1.263 +                                }
   1.264 +                                free(filePassword);
   1.265 +                              }
   1.266 +                            }
   1.267 +                          }
   1.268 +                          free(passwordFileName);
   1.269 +                        }
   1.270 +                      }
   1.271 +                      free(systemDirectory);
   1.272 +                    }
   1.273 +                    free(directory);
   1.274 +                  }
   1.275 +                  free(login);
   1.276 +                }
   1.277 +                free(password);
   1.278 +                free(variableValue);
   1.279 +              }
   1.280 +              free(variableName);
   1.281 +            }
   1.282 +            free(cookie);
   1.283 +          }
   1.284 +        }
   1.285 +      }
   1.286 +    }
   1.287 +  }
   1.288 +  return 0;
   1.289 +}
   1.290 +
   1.291 +/* FUNCTION | DENY ACCESS */
   1.292 +static void DenyAccess(void) {
   1.293 +  printf("Status: 403\r\n\r\n");
   1.294 +}
   1.295 +
   1.296 +/* FUNCTION | GRANT ACCESS */
   1.297 +static void GrantAccess(void) {
   1.298 +  printf("Status: 200\r\n\r\n");
   1.299 +}
   1.300 +
   1.301 +/***********************************************************************/
   1.302 +/*                  Copyright and Trademark Statement                  */
   1.303 +/***********************************************************************/
   1.304 +/*                                                                     */
   1.305 +/*          All original textual and graphical site content:           */
   1.306 +/*                                                                     */
   1.307 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
   1.308 +/*  reserved.  Reproduction in whole or in part without written        */
   1.309 +/*  permission is prohibited.  interos and the interos logos are       */
   1.310 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
   1.311 +/*  product, and service names mentioned herein may be the properties  */
   1.312 +/*  of their respective owners.  Comments in the interos.org forums    */
   1.313 +/*  are the properties of their respective authors.  All software      */
   1.314 +/*  developed in the forums is open source and belongs to everyone.    */
   1.315 +/*                                                                     */
   1.316 +/***********************************************************************/
   1.317 +/*                      e-mail: info@interos.com                       */
   1.318 +/***********************************************************************/
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/c/bottom_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
     2.3 @@ -0,0 +1,514 @@
     2.4 +/******************************************************/
     2.5 +/*    interos Standard Document Header - CGI in C     */
     2.6 +/******************************************************/
     2.7 +/*         URIs:  https://interos.com/bottom          */
     2.8 +/*                https://www.interos.com/bottom      */
     2.9 +/*       Source:  bottom.c                            */
    2.10 +/*  Description:  FastCGI for interos bottom toolbar  */
    2.11 +/*       Author:  Brent Angeline                      */
    2.12 +/*          CGI:  FastCGI in ISO/ANSI C               */
    2.13 +/******************************************************/
    2.14 +
    2.15 +/* PREPROCESSOR DIRECTIVES */
    2.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), printf()                      */
    2.17 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
    2.18 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                               */
    2.19 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                   */
    2.20 +#include <unistd.h>         /*  F_OK, access()                                                           */
    2.21 +
    2.22 +/* FUNCTION PROTOTYPE DECLARATIONS */
    2.23 +static void RedirectToLoginPanel(void);
    2.24 +static void OutputBottom(char *status);
    2.25 +static void OutputNewMenuButton(void);
    2.26 +static void OutputSettingsMenuButton(void);
    2.27 +static void BeginXHTMLOutput(void);
    2.28 +static void BeginBottomOutput(void);
    2.29 +static void FinishXHTMLOutput(void);
    2.30 +
    2.31 +/* BEGIN MAIN PROGRAM */
    2.32 +int main(void) {
    2.33 +
    2.34 +  /* BEGIN FASTCGI */
    2.35 +  while (FCGI_Accept() >= 0) {
    2.36 +
    2.37 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
    2.38 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
    2.39 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
    2.40 +      RedirectToLoginPanel();
    2.41 +
    2.42 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
    2.43 +    } else {
    2.44 +
    2.45 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
    2.46 +      char *cookie;
    2.47 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
    2.48 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
    2.49 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
    2.50 +        RedirectToLoginPanel();
    2.51 +      } else {
    2.52 +        char *variableName;
    2.53 +        if (!(variableName = malloc(cookieLength + 1))) {
    2.54 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
    2.55 +          RedirectToLoginPanel();
    2.56 +        } else {
    2.57 +          char *variableValue;
    2.58 +          if (!(variableValue = malloc(cookieLength + 1))) {
    2.59 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
    2.60 +            RedirectToLoginPanel();
    2.61 +
    2.62 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
    2.63 +          } else {
    2.64 +
    2.65 +            /* PROCESS COOKIE DATA */
    2.66 +            char *login, *password;
    2.67 +            INT c, i;
    2.68 +            login = password = NULL;
    2.69 +            c = 0;
    2.70 +            strcpy(cookie, getenv("HTTP_COOKIE"));
    2.71 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
    2.72 +              i = 0;
    2.73 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
    2.74 +                variableName[i] = cookie[c];
    2.75 +                ++c;
    2.76 +                ++i;
    2.77 +              }
    2.78 +              variableName[i] = '\0';
    2.79 +              ++c;
    2.80 +              i = 0;
    2.81 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
    2.82 +                variableValue[i] = cookie[c];
    2.83 +                ++c;
    2.84 +                ++i;
    2.85 +              }
    2.86 +              variableValue[i] = '\0';
    2.87 +              ++c;
    2.88 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
    2.89 +                ++c;
    2.90 +              }
    2.91 +              if (!login && !strcmp(variableName, "login")) {
    2.92 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
    2.93 +                  strcpy(login, variableValue);
    2.94 +                }
    2.95 +              } else if (!password && !strcmp(variableName, "password")) {
    2.96 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
    2.97 +                  strcpy(password, variableValue);
    2.98 +                }
    2.99 +              }
   2.100 +            }
   2.101 +
   2.102 +            /* IF LOGIN VALUE IS MISSING... */
   2.103 +            if (!login) {
   2.104 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
   2.105 +              RedirectToLoginPanel();
   2.106 +
   2.107 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
   2.108 +            } else {
   2.109 +
   2.110 +              /* VERIFY LOGIN AND PASSWORD */
   2.111 +              char *directory;
   2.112 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
   2.113 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
   2.114 +                RedirectToLoginPanel();
   2.115 +              } else {
   2.116 +                char *systemDirectory;
   2.117 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
   2.118 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
   2.119 +                  RedirectToLoginPanel();
   2.120 +                } else {
   2.121 +                  strcpy(directory, DIRECTORY);
   2.122 +                  strcat(directory, login);
   2.123 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
   2.124 +                  strcat(systemDirectory, login);
   2.125 +
   2.126 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
   2.127 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
   2.128 +                    /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
   2.129 +                    RedirectToLoginPanel();
   2.130 +
   2.131 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
   2.132 +                  } else {
   2.133 +
   2.134 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
   2.135 +                    char *passwordFileName;
   2.136 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
   2.137 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
   2.138 +                      RedirectToLoginPanel();
   2.139 +                    } else {
   2.140 +                      strcpy(passwordFileName, systemDirectory);
   2.141 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
   2.142 +
   2.143 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
   2.144 +                      if (access(passwordFileName, F_OK)) {
   2.145 +                        /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
   2.146 +                        RedirectToLoginPanel();
   2.147 +
   2.148 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
   2.149 +                      } else {
   2.150 +
   2.151 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
   2.152 +                        FILE *passwordFile;
   2.153 +
   2.154 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
   2.155 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
   2.156 +                          /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
   2.157 +                          RedirectToLoginPanel();
   2.158 +
   2.159 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
   2.160 +                        } else {
   2.161 +                          char *filePassword;
   2.162 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
   2.163 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
   2.164 +                            RedirectToLoginPanel();
   2.165 +                          } else {
   2.166 +                            char c;
   2.167 +                            i = 0;
   2.168 +
   2.169 +                            /* READ PASSWORD FROM PASSWORD FILE */
   2.170 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
   2.171 +                              filePassword[i] = c;
   2.172 +                              ++i;
   2.173 +                            }
   2.174 +                            filePassword[i] = '\0';
   2.175 +                            fclose(passwordFile);
   2.176 +
   2.177 +                            /* IF PASSWORD FAILS COMPARISON... */
   2.178 +                            if (strcmp(filePassword, password)) {
   2.179 +                              /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
   2.180 +                              RedirectToLoginPanel();
   2.181 +
   2.182 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
   2.183 +                            } else {
   2.184 +
   2.185 +                              /* LOAD SETTINGS VALUES FROM FILES */
   2.186 +
   2.187 +                              /* LOAD interos BOTTOM COMPONENTS FROM FILES */
   2.188 +
   2.189 +                              /* DECLARE AND INITIALIZE QUERY VARIABLES */
   2.190 +                              char *status, *button;
   2.191 +                              status = button = NULL;
   2.192 +
   2.193 +                              /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
   2.194 +                              if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
   2.195 +                                char *query;
   2.196 +                                INT queryLength = strlen(getenv("QUERY_STRING"));
   2.197 +                                if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
   2.198 +                                  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
   2.199 +                                } else {
   2.200 +                                  strcpy(query, getenv("QUERY_STRING"));
   2.201 +                                  free(variableName);
   2.202 +                                  if (!(variableName = malloc(queryLength + 1))) {
   2.203 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
   2.204 +                                  } else {
   2.205 +                                    free(variableValue);
   2.206 +                                    if (!(variableValue = malloc(queryLength + 1))) {
   2.207 +                                      /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
   2.208 +
   2.209 +                                    /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
   2.210 +                                    } else {
   2.211 +
   2.212 +                                      /* PROCESS QUERY DATA */
   2.213 +                                      INT q = 0;
   2.214 +                                      i = 0;
   2.215 +                                      while ((q < queryLength) && (query[q] != '\0')) {
   2.216 +                                        while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
   2.217 +                                          variableName[i] = query[q];
   2.218 +                                          ++q;
   2.219 +                                          ++i;
   2.220 +                                        }
   2.221 +                                        variableName[i] = '\0';
   2.222 +                                        ++q;
   2.223 +                                        i = 0;
   2.224 +                                        while ((query[q] != '&') && (query[q] != '\0')) {
   2.225 +                                          variableValue[i] = query[q];
   2.226 +                                          ++q;
   2.227 +                                          ++i;
   2.228 +                                        }
   2.229 +                                        variableValue[i] = '\0';
   2.230 +                                        if (query[q] != '\0') {
   2.231 +                                          ++q;
   2.232 +                                        }
   2.233 +                                        if (!status && !strcmp(variableName, "status")) {
   2.234 +                                          if ((status = malloc(strlen(variableValue) + 1)) != 0) {
   2.235 +                                            strcpy(status, variableValue);
   2.236 +                                          }
   2.237 +                                        } else if (!button && !strcmp(variableName, "button")) {
   2.238 +                                          if ((button = malloc(strlen(variableValue) + 1)) != 0) {
   2.239 +                                            strcpy(button, variableValue);
   2.240 +                                          }
   2.241 +                                        }
   2.242 +                                      }
   2.243 +                                    }
   2.244 +                                  }
   2.245 +                                  free(query);
   2.246 +                                }
   2.247 +                              }
   2.248 +
   2.249 +                              /* OUTPUT GUI COMPONENT(S) BASED ON VARIABLES */
   2.250 +                              if (button) {
   2.251 +                                if (!strcmp(button, "new")) {
   2.252 +                                  OutputNewMenuButton();
   2.253 +                                } else if (!strcmp(button, "settings")) {
   2.254 +                                  OutputSettingsMenuButton();
   2.255 +                                } else {
   2.256 +
   2.257 +                                  /* OUTPUT XHTML FOR interos BOTTOM BAR */
   2.258 +                                  OutputBottom(status);
   2.259 +                                }
   2.260 +                              } else {
   2.261 +
   2.262 +                                /* OUTPUT XHTML FOR interos BOTTOM BAR */
   2.263 +                                OutputBottom(status);
   2.264 +                              }
   2.265 +                              free(button);
   2.266 +                              free(status);
   2.267 +                            }
   2.268 +                            free(filePassword);
   2.269 +                          }
   2.270 +                        }
   2.271 +                      }
   2.272 +                      free(passwordFileName);
   2.273 +                    }
   2.274 +                  }
   2.275 +                  free(systemDirectory);
   2.276 +                }
   2.277 +                free(directory);
   2.278 +              }
   2.279 +              free(login);
   2.280 +            }
   2.281 +            free(password);
   2.282 +            free(variableValue);
   2.283 +          }
   2.284 +          free(variableName);
   2.285 +        }
   2.286 +        free(cookie);
   2.287 +      }
   2.288 +    }
   2.289 +  }
   2.290 +  return 0;
   2.291 +}
   2.292 +
   2.293 +/* FUNCTION | REDIRECT TO LOGIN PANEL */
   2.294 +static void RedirectToLoginPanel(void) {
   2.295 +  BeginXHTMLOutput();
   2.296 +  BeginBottomOutput();
   2.297 +  printf("      <a href=\"/login\" \n");
   2.298 +  printf("         target=\"_top\">click here to login for interos bottom toolbar</a>\n");
   2.299 +  FinishXHTMLOutput();
   2.300 +}
   2.301 +
   2.302 +/* FUNCTION | OUTPUT XHTML FOR interos BOTTOM TOOLBAR */
   2.303 +static void OutputBottom(char *status) {
   2.304 +  BeginXHTMLOutput();
   2.305 +  BeginBottomOutput();
   2.306 +  printf("      <table id=\"bottomToolbar\" width=\"100%%\" \n");
   2.307 +  printf("             border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
   2.308 +  printf("        <tr>\n");
   2.309 +  printf("          <td width=\"72\" \n");
   2.310 +  printf("              height=\"72\"><center>\n");
   2.311 +  printf("                            <a id=\"newButton\" \n");
   2.312 +  printf("                               href=\"/interos?menu=new\" \n");
   2.313 +  printf("                               style=\"padding: 26px 0 27px\" \n");
   2.314 +  printf("                               target=\"_top\"><strong>new</strong></a>\n");
   2.315 +  printf("                          </center></td>\n");
   2.316 +  printf("          <td><center>\n");
   2.317 +  printf("                &nbsp;<span class=\"hidden\">|</span>&nbsp;\n");
   2.318 +  printf("              </center></td>\n");
   2.319 +  printf("          <td width=\"72\" \n");
   2.320 +  printf("              height=\"72\"><center>\n");
   2.321 +  printf("                            <a id=\"settingsButton\" \n");
   2.322 +  printf("                               href=\"/interos?menu=settings\" \n");
   2.323 +  printf("                               style=\"padding: 26px 0 27px\" \n");
   2.324 +  printf("                               target=\"_top\"><strong>settings</strong></a>\n");
   2.325 +  printf("                          </center></td>\n");
   2.326 +  printf("        </tr>\n");
   2.327 +  printf("      </table>\n");
   2.328 +  FinishXHTMLOutput();
   2.329 +}
   2.330 +
   2.331 +/* FUNCTION | OUTPUT XHTML FOR NEW MENU BUTTON */
   2.332 +static void OutputNewMenuButton(void) {
   2.333 +  BeginXHTMLOutput();
   2.334 +  printf("  <!--======================================================-->\n");
   2.335 +  printf("  <!--      interos Standard Document Header - Markup       -->\n");
   2.336 +  printf("  <!--======================================================-->\n");
   2.337 +  printf("  <!--    URIs:  https://interos.com/bottom?button=new      -->\n");
   2.338 +  printf("  <!--           https://www.interos.com/bottom?button=new  -->\n");
   2.339 +  printf("  <!--   Title:  interos new menu button                    -->\n");
   2.340 +  printf("  <!--  Author:  Brent Angeline                             -->\n");
   2.341 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional       -->\n");
   2.342 +  printf("  <!--======================================================-->\n");
   2.343 +  printf("  <head>\n");
   2.344 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
   2.345 +  printf("    <meta name=\"title\" content=\"interos new menu button\" />\n");
   2.346 +  printf("    <meta name=\"description\" content=\"button for interos new menu\" />\n");
   2.347 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
   2.348 +  printf("    <meta name=\"copyright\" \n");
   2.349 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
   2.350 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
   2.351 +  printf("    <title>interos new menu button</title>\n");
   2.352 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
   2.353 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
   2.354 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
   2.355 +  printf("          media=\"screen, projection\" />\n");
   2.356 +  printf("    <script type=\"text/javascript\" src=\"/js/bottom.js\"></script>\n");
   2.357 +  printf("  </head>\n");
   2.358 +  printf("  <body id=\"body\">\n");
   2.359 +  printf("    <center>\n");
   2.360 +  printf("      <table id=\"bottomToolbarFaded\" width=\"100%%\" \n");
   2.361 +  printf("             border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
   2.362 +  printf("        <tr>\n");
   2.363 +  printf("          <td width=\"72\" \n");
   2.364 +  printf("              height=\"72\"><center>\n");
   2.365 +  printf("                            <a id=\"newMenuButton\" \n");
   2.366 +  printf("                               href=\"/main\" \n");
   2.367 +  printf("                               style=\"padding: 26px 0 27px\" \n");
   2.368 +  printf("                               target=\"_top\"><strong>&laquo; back</strong></a>\n");
   2.369 +  printf("                          </center></td>\n");
   2.370 +  printf("          <td><center>\n");
   2.371 +  printf("                &nbsp;<span class=\"hidden\">|</span>&nbsp;\n");
   2.372 +  printf("              </center></td>\n");
   2.373 +  printf("          <td id=\"bottomToolbarCornerFaded\" \n");
   2.374 +  printf("              width=\"72\" \n");
   2.375 +  printf("              height=\"72\"><p>\n");
   2.376 +  printf("                            <br />\n");
   2.377 +  printf("                          </p></td>\n");
   2.378 +  printf("        </tr>\n");
   2.379 +  printf("      </table>\n");
   2.380 +  FinishXHTMLOutput();
   2.381 +}
   2.382 +
   2.383 +/* FUNCTION | OUTPUT XHTML FOR SETTINGS MENU BUTTON */
   2.384 +static void OutputSettingsMenuButton(void) {
   2.385 +  BeginXHTMLOutput();
   2.386 +  printf("  <!--===========================================================-->\n");
   2.387 +  printf("  <!--         interos Standard Document Header - Markup         -->\n");
   2.388 +  printf("  <!--===========================================================-->\n");
   2.389 +  printf("  <!--    URIs:  https://interos.com/bottom?button=settings      -->\n");
   2.390 +  printf("  <!--           https://www.interos.com/bottom?button=settings  -->\n");
   2.391 +  printf("  <!--   Title:  interos settings menu button                    -->\n");
   2.392 +  printf("  <!--  Author:  Brent Angeline                                  -->\n");
   2.393 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional            -->\n");
   2.394 +  printf("  <!--===========================================================-->\n");
   2.395 +  printf("  <head>\n");
   2.396 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
   2.397 +  printf("    <meta name=\"title\" content=\"interos settings menu button\" />\n");
   2.398 +  printf("    <meta name=\"description\" content=\"button for interos settings menu\" />\n");
   2.399 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
   2.400 +  printf("    <meta name=\"copyright\" \n");
   2.401 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
   2.402 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
   2.403 +  printf("    <title>interos settings menu button</title>\n");
   2.404 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
   2.405 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
   2.406 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
   2.407 +  printf("          media=\"screen, projection\" />\n");
   2.408 +  printf("    <script type=\"text/javascript\" src=\"/js/bottom.js\"></script>\n");
   2.409 +  printf("  </head>\n");
   2.410 +  printf("  <body id=\"body\">\n");
   2.411 +  printf("    <center>\n");
   2.412 +  printf("      <table id=\"bottomToolbarFaded\" width=\"100%%\" \n");
   2.413 +  printf("             border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
   2.414 +  printf("        <tr>\n");
   2.415 +  printf("          <td id=\"bottomToolbarCornerFaded\" \n");
   2.416 +  printf("              width=\"72\" \n");
   2.417 +  printf("              height=\"72\"><p>\n");
   2.418 +  printf("                            <br />\n");
   2.419 +  printf("                          </p></td>\n");
   2.420 +  printf("          <td><center>\n");
   2.421 +  printf("               &nbsp;<span class=\"hidden\">|</span>&nbsp;\n");
   2.422 +  printf("              </center></td>\n");
   2.423 +  printf("          <td width=\"72\" \n");
   2.424 +  printf("              height=\"72\"><center>\n");
   2.425 +  printf("                            <a id=\"settingsMenuButton\" \n");
   2.426 +  printf("                               href=\"/main\" \n");
   2.427 +  printf("                               style=\"padding: 26px 0 27px\" \n");
   2.428 +  printf("                               target=\"_top\"><strong>&laquo; back</strong></a>\n");
   2.429 +  printf("                          </center></td>\n");
   2.430 +  printf("        </tr>\n");
   2.431 +  printf("      </table>\n");
   2.432 +  FinishXHTMLOutput();
   2.433 +}
   2.434 +
   2.435 +/* FUNCTION | BEGIN XHTML OUTPUT */
   2.436 +static void BeginXHTMLOutput(void) {
   2.437 +  printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
   2.438 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
   2.439 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
   2.440 +  printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n");
   2.441 +  printf("                      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
   2.442 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
   2.443 +}
   2.444 +
   2.445 +/* FUNCTION | BEGIN interos BOTTOM TOOLBAR OUTPUT */
   2.446 +static void BeginBottomOutput(void) {
   2.447 +  printf("  <!--=================================================-->\n");
   2.448 +  printf("  <!--    interos Standard Document Header - Markup    -->\n");
   2.449 +  printf("  <!--=================================================-->\n");
   2.450 +  printf("  <!--    URIs:  https://interos.com/bottom            -->\n");
   2.451 +  printf("  <!--           https://www.interos.com/bottom        -->\n");
   2.452 +  printf("  <!--   Title:  interos bottom toolbar                 -->\n");
   2.453 +  printf("  <!--  Author:  Brent Angeline                        -->\n");
   2.454 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional  -->\n");
   2.455 +  printf("  <!--=================================================-->\n");
   2.456 +  printf("  <head>\n");
   2.457 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
   2.458 +  printf("    <meta name=\"title\" content=\"interos bottom toolbar\" />\n");
   2.459 +  printf("    <meta name=\"description\" content=\"bottom toolbar for interos\" />\n");
   2.460 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
   2.461 +  printf("    <meta name=\"copyright\" \n");
   2.462 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
   2.463 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
   2.464 +  printf("    <title>interos bottom</title>\n");
   2.465 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
   2.466 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
   2.467 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
   2.468 +  printf("          media=\"screen, projection\" />\n");
   2.469 +  printf("    <script type=\"text/javascript\" src=\"/js/bottom.js\"></script>\n");
   2.470 +  printf("  </head>\n");
   2.471 +  printf("  <body id=\"body\">\n");
   2.472 +  printf("    <center>\n");
   2.473 +}
   2.474 +
   2.475 +/* FUNCTION | FINISH XHTML OUTPUT */
   2.476 +static void FinishXHTMLOutput(void) {
   2.477 +  printf("    </center>\n");
   2.478 +  printf("  </body>\n");
   2.479 +  printf("  <!--=====================================================================-->\n");
   2.480 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
   2.481 +  printf("  <!--=====================================================================-->\n");
   2.482 +  printf("  <!--                                                                     -->\n");
   2.483 +  printf("  <!--          All original textual and graphical site content:           -->\n");
   2.484 +  printf("  <!--                                                                     -->\n");
   2.485 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
   2.486 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
   2.487 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
   2.488 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
   2.489 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
   2.490 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
   2.491 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
   2.492 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
   2.493 +  printf("  <!--                                                                     -->\n");
   2.494 +  printf("  <!--=====================================================================-->\n");
   2.495 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
   2.496 +  printf("  <!--=====================================================================-->\n");
   2.497 +  printf("</html>");
   2.498 +}
   2.499 +
   2.500 +/***********************************************************************/
   2.501 +/*                  Copyright and Trademark Statement                  */
   2.502 +/***********************************************************************/
   2.503 +/*                                                                     */
   2.504 +/*          All original textual and graphical site content:           */
   2.505 +/*                                                                     */
   2.506 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
   2.507 +/*  reserved.  Reproduction in whole or in part without written        */
   2.508 +/*  permission is prohibited.  interos and the interos logos are       */
   2.509 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
   2.510 +/*  product, and service names mentioned herein may be the properties  */
   2.511 +/*  of their respective owners.  Comments in the interos.org forums    */
   2.512 +/*  are the properties of their respective authors.  All software      */
   2.513 +/*  developed in the forums is open source and belongs to everyone.    */
   2.514 +/*                                                                     */
   2.515 +/***********************************************************************/
   2.516 +/*                      e-mail: info@interos.com                       */
   2.517 +/***********************************************************************/
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/c/browse_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
     3.3 @@ -0,0 +1,374 @@
     3.4 +/**************************************************/
     3.5 +/*  interos Standard Document Header - CGI in C   */
     3.6 +/**************************************************/
     3.7 +/*         URIs:  https://interos.com/browse      */
     3.8 +/*                https://www.interos.com/browse  */
     3.9 +/*       Source:  browse.c                        */
    3.10 +/*  Description:  FastCGI for interos browse      */
    3.11 +/*       Author:  Brent Angeline                  */
    3.12 +/*          CGI:  FastCGI in ISO/ANSI C           */
    3.13 +/**************************************************/
    3.14 +
    3.15 +/* PREPROCESSOR DIRECTIVES */
    3.16 +#include "fcgi_stdio.h"     /*  EOF, FCGI_Accept(), fclose(), fgetc(), fopen(), fread(), printf()        */
    3.17 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
    3.18 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                               */
    3.19 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                   */
    3.20 +#include <unistd.h>         /*  F_OK, access()                                                           */
    3.21 +
    3.22 +/* FUNCTION PROTOTYPE DECLARATIONS */
    3.23 +static void RedirectToLoginPanel(void);
    3.24 +static void BeginXHTMLOutput(void);
    3.25 +static void FinishXHTMLOutput(void);
    3.26 +
    3.27 +/* BEGIN MAIN PROGRAM */
    3.28 +int main(void) {
    3.29 +
    3.30 +  /* BEGIN FASTCGI */
    3.31 +  while (FCGI_Accept() >= 0) {
    3.32 +
    3.33 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
    3.34 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
    3.35 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
    3.36 +      RedirectToLoginPanel();
    3.37 +
    3.38 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
    3.39 +    } else {
    3.40 +
    3.41 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
    3.42 +      char *cookie;
    3.43 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
    3.44 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
    3.45 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
    3.46 +        RedirectToLoginPanel();
    3.47 +      } else {
    3.48 +        char *variableName;
    3.49 +        if (!(variableName = malloc(cookieLength + 1))) {
    3.50 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
    3.51 +          RedirectToLoginPanel();
    3.52 +        } else {
    3.53 +          char *variableValue;
    3.54 +          if (!(variableValue = malloc(cookieLength + 1))) {
    3.55 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
    3.56 +            RedirectToLoginPanel();
    3.57 +
    3.58 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
    3.59 +          } else {
    3.60 +
    3.61 +            /* PROCESS COOKIE DATA */
    3.62 +            char *login, *password;
    3.63 +            INT c, i;
    3.64 +            login = password = NULL;
    3.65 +            c = 0;
    3.66 +            strcpy(cookie, getenv("HTTP_COOKIE"));
    3.67 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
    3.68 +              i = 0;
    3.69 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
    3.70 +                variableName[i] = cookie[c];
    3.71 +                ++c;
    3.72 +                ++i;
    3.73 +              }
    3.74 +              variableName[i] = '\0';
    3.75 +              ++c;
    3.76 +              i = 0;
    3.77 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
    3.78 +                variableValue[i] = cookie[c];
    3.79 +                ++c;
    3.80 +                ++i;
    3.81 +              }
    3.82 +              variableValue[i] = '\0';
    3.83 +              ++c;
    3.84 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
    3.85 +                ++c;
    3.86 +              }
    3.87 +              if (!login && !strcmp(variableName, "login")) {
    3.88 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
    3.89 +                  strcpy(login, variableValue);
    3.90 +                }
    3.91 +              } else if (!password && !strcmp(variableName, "password")) {
    3.92 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
    3.93 +                  strcpy(password, variableValue);
    3.94 +                }
    3.95 +              }
    3.96 +            }
    3.97 +
    3.98 +            /* IF LOGIN VALUE IS MISSING... */
    3.99 +            if (!login) {
   3.100 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
   3.101 +              RedirectToLoginPanel();
   3.102 +
   3.103 +              /* OTHERWISE, IF LOGIN VALUE EXISTS... */
   3.104 +              } else {
   3.105 +
   3.106 +              /* VERIFY LOGIN AND PASSWORD */
   3.107 +              char *directory;
   3.108 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
   3.109 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
   3.110 +                RedirectToLoginPanel();
   3.111 +              } else {
   3.112 +                char *systemDirectory;
   3.113 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
   3.114 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
   3.115 +                  RedirectToLoginPanel();
   3.116 +                } else {
   3.117 +                  strcpy(directory, DIRECTORY);
   3.118 +                  strcat(directory, login);
   3.119 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
   3.120 +                  strcat(systemDirectory, login);
   3.121 +
   3.122 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
   3.123 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
   3.124 +                    /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
   3.125 +                    RedirectToLoginPanel();
   3.126 +
   3.127 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
   3.128 +                  } else {
   3.129 +
   3.130 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
   3.131 +                    char *passwordFileName;
   3.132 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
   3.133 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
   3.134 +                      RedirectToLoginPanel();
   3.135 +                    } else {
   3.136 +                      strcpy(passwordFileName, systemDirectory);
   3.137 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
   3.138 +
   3.139 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
   3.140 +                      if (access(passwordFileName, F_OK)) {
   3.141 +                        /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
   3.142 +                        RedirectToLoginPanel();
   3.143 +
   3.144 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
   3.145 +                      } else {
   3.146 +
   3.147 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
   3.148 +                        FILE *passwordFile;
   3.149 +
   3.150 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
   3.151 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
   3.152 +                          /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
   3.153 +                          RedirectToLoginPanel();
   3.154 +
   3.155 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
   3.156 +                        } else {
   3.157 +                          char *filePassword;
   3.158 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
   3.159 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
   3.160 +                            RedirectToLoginPanel();
   3.161 +                          } else {
   3.162 +                            char c;
   3.163 +                            i = 0;
   3.164 +
   3.165 +                            /* READ PASSWORD FROM PASSWORD FILE */
   3.166 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
   3.167 +                              filePassword[i] = c;
   3.168 +                              ++i;
   3.169 +                            }
   3.170 +                            filePassword[i] = '\0';
   3.171 +                            fclose(passwordFile);
   3.172 +
   3.173 +                            /* IF PASSWORD FAILS COMPARISON... */
   3.174 +                            if (strcmp(filePassword, password)) {
   3.175 +                              /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
   3.176 +                              RedirectToLoginPanel();
   3.177 +
   3.178 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
   3.179 +                            } else {
   3.180 +
   3.181 +                              /* LOAD SETTINGS VALUES FROM FILE(S) */
   3.182 +
   3.183 +                              /* DECLARE AND INITIALIZE QUERY VARIABLES */
   3.184 +                              char *address, *search;
   3.185 +                              address = search = NULL;
   3.186 +
   3.187 +                              /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
   3.188 +                              if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
   3.189 +                                char *query;
   3.190 +                                INT queryLength = strlen(getenv("QUERY_STRING"));
   3.191 +                                if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
   3.192 +                                  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
   3.193 +                                } else {
   3.194 +                                  strcpy(query, getenv("QUERY_STRING"));
   3.195 +                                  free(variableName);
   3.196 +                                  if (!(variableName = malloc(queryLength + 1))) {
   3.197 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
   3.198 +                                  } else {
   3.199 +                                    free(variableValue);
   3.200 +                                    if (!(variableValue = malloc(queryLength + 1))) {
   3.201 +                                      /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
   3.202 +
   3.203 +                                    /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
   3.204 +                                    } else {
   3.205 +
   3.206 +                                      /* PROCESS QUERY DATA */
   3.207 +                                      INT q = 0;
   3.208 +                                      i = 0;
   3.209 +                                      while ((q < queryLength) && (query[q] != '\0')) {
   3.210 +                                        while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
   3.211 +                                          variableName[i] = query[q];
   3.212 +                                          ++q;
   3.213 +                                          ++i;
   3.214 +                                        }
   3.215 +                                        variableName[i] = '\0';
   3.216 +                                        ++q;
   3.217 +                                        i = 0;
   3.218 +                                        while ((query[q] != '&') && (query[q] != '\0')) {
   3.219 +                                          variableValue[i] = query[q];
   3.220 +                                          ++q;
   3.221 +                                          ++i;
   3.222 +                                        }
   3.223 +                                        variableValue[i] = '\0';
   3.224 +                                        if (query[q] != '\0') {
   3.225 +                                          ++q;
   3.226 +                                        }
   3.227 +                                        if (!address && !strcmp(variableName, "address")) {
   3.228 +                                          if ((address = malloc(strlen(variableValue) + 1)) != 0) {
   3.229 +                                            strcpy(address, variableValue);
   3.230 +                                          }
   3.231 +                                        } else if (!search && !strcmp(variableName, "search")) {
   3.232 +                                          if ((search = malloc(strlen(variableValue) + 1)) != 0) {
   3.233 +                                            strcpy(search, variableValue);
   3.234 +                                            for (c = 0; c < strlen(search); ++c) {
   3.235 +                                              if (search[c] == ' ') {
   3.236 +                                                search[c] = '+';
   3.237 +                                              }
   3.238 +                                            }
   3.239 +                                          }
   3.240 +                                        }
   3.241 +                                      }
   3.242 +                                      free(variableValue);
   3.243 +                                      variableValue = NULL;
   3.244 +                                    }
   3.245 +                                    free(variableName);
   3.246 +                                    variableName = NULL;
   3.247 +                                  }
   3.248 +                                  free(query);
   3.249 +                                }
   3.250 +                              }
   3.251 +
   3.252 +                              /* IF THIS IS A CONTINUED SESSION... */
   3.253 +
   3.254 +                                /* LOAD SESSION FROM FILE */
   3.255 +
   3.256 +                              /* OUTPUT GUI COMPONENTS BASED ON VARIABLES */
   3.257 +                              printf("Content-type: text/html\n\n");
   3.258 +                              printf("<!--=======================================================-->\n");
   3.259 +                              printf("<!--  interos.com Standard Document Model Header - Markup  -->\n");
   3.260 +                              printf("<!--=======================================================-->\n");
   3.261 +                              printf("<!--      URIs:   https://www.interos.com/sys/browser      -->\n");
   3.262 +                              printf("<!--              interos.com/sys/browser                  -->\n");
   3.263 +                              printf("<!--      Title:  interos browser                          -->\n");
   3.264 +                              printf("<!--     Author:  Brent Angeline                           -->\n");
   3.265 +                              printf("<!--     Markup:  Dynamic XHTML                            -->\n");
   3.266 +                              printf("<!--=======================================================-->\n");
   3.267 +                              printf("<html>");
   3.268 +                                printf("<head>");
   3.269 +                                  printf("<title>interos > %s > browser</title>", login);
   3.270 +                                printf("</head>");
   3.271 +                                printf("<frameset rows=\"72,*,72\" border=\"0\">");
   3.272 +                                  printf("<frame name=\"top\" src=\"top\" scrolling=\"no\" noresize=\"noresize\">");
   3.273 +                                  if (address != NULL) {
   3.274 +                                    printf("<frame name=\"content\" src=\"http://%s\" scrolling=\"yes\" noresize=\"noresize\">", address);
   3.275 +                                  } else {
   3.276 +                                    printf("<frame name=\"content\" src=\"http://www.google.com/search?hl=en&q=%s&btnG=Google+Search\" scrolling=\"yes\" noresize=\"noresize\">", search);
   3.277 +                                  }
   3.278 +                                  printf("<frame name=\"bottom\" src=\"bottom\" scrolling=\"no\" noresize=\"noresize\">");
   3.279 +                                printf("</frameset>");
   3.280 +                                printf("<noframes>");
   3.281 +                                printf("</noframes>");
   3.282 +                              printf("</html>\n");
   3.283 +                              printf("<!--===========================================================================-->\n");
   3.284 +                              printf("<!--                   Copyright and Trademark Legal Notice                    -->\n");
   3.285 +                              printf("<!--===========================================================================-->\n");
   3.286 +                              printf("<!--                                                                           -->\n");
   3.287 +                              printf("<!--                  All textual and graphical site content:                  -->\n");
   3.288 +                              printf("<!--                                                                           -->\n");
   3.289 +                              printf("<!--  Copyright (C) 2001 - 2010 Brent Angeline / interos.com / interos.        -->\n");
   3.290 +                              printf("<!--  Reproduction in whole or part without written permission is prohibited.  -->\n");
   3.291 +                              printf("<!--  All rights reserved.  interos.com and the interos logos are              -->\n");
   3.292 +                              printf("<!--  trademarks of Brent Angeline / interos.com / interos.                    -->\n");
   3.293 +                              printf("<!--  All other company names, product names and services mentioned herein     -->\n");
   3.294 +                              printf("<!--  may be the property of their respective owners.                          -->\n");
   3.295 +                              printf("<!--                                                                           -->\n");
   3.296 +                              printf("<!--===========================================================================-->\n");
   3.297 +                              printf("<!--                         e-mail: info@interos.com                          -->\n");
   3.298 +                              printf("<!--===========================================================================-->");
   3.299 +
   3.300 +                              free(address);
   3.301 +                              free(search);
   3.302 +                            }
   3.303 +                            free(filePassword);
   3.304 +                          }
   3.305 +                        }
   3.306 +                      }
   3.307 +                      free(passwordFileName);
   3.308 +                    }
   3.309 +                  }
   3.310 +                  free(systemDirectory);
   3.311 +                }
   3.312 +                free(directory);
   3.313 +              }
   3.314 +              free(login);
   3.315 +            }
   3.316 +            free(password);
   3.317 +            free(variableValue);
   3.318 +          }
   3.319 +          free(variableName);
   3.320 +        }
   3.321 +        free(cookie);
   3.322 +      }
   3.323 +    }
   3.324 +  }
   3.325 +  return 0;
   3.326 +}
   3.327 +
   3.328 +/* FUNCTION | REDIRECT TO LOGIN PANEL */
   3.329 +static void RedirectToLoginPanel(void) {
   3.330 +  printf("Location: login\r\n\r\n");
   3.331 +}
   3.332 +
   3.333 +static void BeginXHTMLOutput(void) {
   3.334 +  printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
   3.335 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
   3.336 +}
   3.337 +
   3.338 +static void FinishXHTMLOutput(void) {
   3.339 +  printf("  <!--=====================================================================-->\n");
   3.340 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
   3.341 +  printf("  <!--=====================================================================-->\n");
   3.342 +  printf("  <!--                                                                     -->\n");
   3.343 +  printf("  <!--          All original textual and graphical site content:           -->\n");
   3.344 +  printf("  <!--                                                                     -->\n");
   3.345 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
   3.346 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
   3.347 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
   3.348 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
   3.349 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
   3.350 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
   3.351 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
   3.352 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
   3.353 +  printf("  <!--                                                                     -->\n");
   3.354 +  printf("  <!--=====================================================================-->\n");
   3.355 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
   3.356 +  printf("  <!--=====================================================================-->\n");
   3.357 +  printf("</html>");
   3.358 +}
   3.359 +
   3.360 +/***********************************************************************/
   3.361 +/*                  Copyright and Trademark Statement                  */
   3.362 +/***********************************************************************/
   3.363 +/*                                                                     */
   3.364 +/*          All original textual and graphical site content:           */
   3.365 +/*                                                                     */
   3.366 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
   3.367 +/*  reserved.  Reproduction in whole or in part without written        */
   3.368 +/*  permission is prohibited.  interos and the interos logos are       */
   3.369 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
   3.370 +/*  product, and service names mentioned herein may be the properties  */
   3.371 +/*  of their respective owners.  Comments in the interos.org forums    */
   3.372 +/*  are the properties of their respective authors.  All software      */
   3.373 +/*  developed in the forums is open source and belongs to everyone.    */
   3.374 +/*                                                                     */
   3.375 +/***********************************************************************/
   3.376 +/*                      e-mail: info@interos.com                       */
   3.377 +/***********************************************************************/
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/c/content_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
     4.3 @@ -0,0 +1,390 @@
     4.4 +/***************************************************/
     4.5 +/*   interos Standard Document Header - CGI in C   */
     4.6 +/***************************************************/
     4.7 +/*         URIs:  https://interos.com/content      */
     4.8 +/*                https://www.interos.com/content  */
     4.9 +/*       Source:  content.c                        */
    4.10 +/*  Description:  FastCGI for interos content      */
    4.11 +/*       Author:  Brent Angeline                   */
    4.12 +/*          CGI:  FastCGI in ISO/ANSI C            */
    4.13 +/***************************************************/
    4.14 +
    4.15 +/* PREPROCESSOR DIRECTIVES */
    4.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), printf()                      */
    4.17 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
    4.18 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                               */
    4.19 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                   */
    4.20 +#include <unistd.h>         /*  F_OK, access()                                                           */
    4.21 +
    4.22 +/* FUNCTION PROTOTYPE DECLARATIONS */
    4.23 +static void RedirectToLoginPanel(void);
    4.24 +static void OutputContent(const char *variableName, char *variableValue);
    4.25 +
    4.26 +/* BEGIN MAIN PROGRAM */
    4.27 +int main(void) {
    4.28 +
    4.29 +  /* BEGIN FASTCGI */
    4.30 +  while (FCGI_Accept() >= 0) {
    4.31 +
    4.32 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
    4.33 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
    4.34 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
    4.35 +      RedirectToLoginPanel();
    4.36 +
    4.37 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
    4.38 +    } else {
    4.39 +
    4.40 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
    4.41 +      char *cookie;
    4.42 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
    4.43 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
    4.44 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
    4.45 +        RedirectToLoginPanel();
    4.46 +      } else {
    4.47 +        char *variableName;
    4.48 +        if (!(variableName = malloc(cookieLength + 1))) {
    4.49 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
    4.50 +          RedirectToLoginPanel();
    4.51 +        } else {
    4.52 +          char *variableValue;
    4.53 +          if (!(variableValue = malloc(cookieLength + 1))) {
    4.54 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
    4.55 +            RedirectToLoginPanel();
    4.56 +
    4.57 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
    4.58 +          } else {
    4.59 +
    4.60 +            /* PROCESS COOKIE DATA */
    4.61 +            char *login, *password;
    4.62 +            INT c, i;
    4.63 +            login = password = NULL;
    4.64 +            c = 0;
    4.65 +            strcpy(cookie, getenv("HTTP_COOKIE"));
    4.66 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
    4.67 +              i = 0;
    4.68 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
    4.69 +                variableName[i] = cookie[c];
    4.70 +                ++c;
    4.71 +                ++i;
    4.72 +              }
    4.73 +              variableName[i] = '\0';
    4.74 +              ++c;
    4.75 +              i = 0;
    4.76 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
    4.77 +                variableValue[i] = cookie[c];
    4.78 +                ++c;
    4.79 +                ++i;
    4.80 +              }
    4.81 +              variableValue[i] = '\0';
    4.82 +              ++c;
    4.83 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
    4.84 +                ++c;
    4.85 +              }
    4.86 +              if (!login && !strcmp(variableName, "login")) {
    4.87 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
    4.88 +                  strcpy(login, variableValue);
    4.89 +                }
    4.90 +              } else if (!password && !strcmp(variableName, "password")) {
    4.91 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
    4.92 +                  strcpy(password, variableValue);
    4.93 +                }
    4.94 +              }
    4.95 +            }
    4.96 +
    4.97 +            /* IF LOGIN VALUE IS MISSING... */
    4.98 +            if (!login) {
    4.99 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
   4.100 +              RedirectToLoginPanel();
   4.101 +
   4.102 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
   4.103 +            } else {
   4.104 +
   4.105 +              /* VERIFY LOGIN AND PASSWORD */
   4.106 +              char *directory;
   4.107 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
   4.108 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
   4.109 +                RedirectToLoginPanel();
   4.110 +              } else {
   4.111 +                char *systemDirectory;
   4.112 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
   4.113 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
   4.114 +                  RedirectToLoginPanel();
   4.115 +                } else {
   4.116 +                  strcpy(directory, DIRECTORY);
   4.117 +                  strcat(directory, login);
   4.118 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
   4.119 +                  strcat(systemDirectory, login);
   4.120 +
   4.121 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
   4.122 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
   4.123 +                    /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
   4.124 +                    RedirectToLoginPanel();
   4.125 +
   4.126 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
   4.127 +                  } else {
   4.128 +
   4.129 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
   4.130 +                    char *passwordFileName;
   4.131 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
   4.132 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
   4.133 +                      RedirectToLoginPanel();
   4.134 +                    } else {
   4.135 +                      strcpy(passwordFileName, systemDirectory);
   4.136 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
   4.137 +
   4.138 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
   4.139 +                      if (access(passwordFileName, F_OK)) {
   4.140 +                        /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
   4.141 +                        RedirectToLoginPanel();
   4.142 +
   4.143 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
   4.144 +                      } else {
   4.145 +
   4.146 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
   4.147 +                        FILE *passwordFile;
   4.148 +
   4.149 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
   4.150 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
   4.151 +                          /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
   4.152 +                          RedirectToLoginPanel();
   4.153 +
   4.154 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
   4.155 +                        } else {
   4.156 +                          char *filePassword;
   4.157 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
   4.158 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
   4.159 +                            RedirectToLoginPanel();
   4.160 +                          } else {
   4.161 +                            char c;
   4.162 +                            i = 0;
   4.163 +
   4.164 +                            /* READ PASSWORD FROM PASSWORD FILE */
   4.165 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
   4.166 +                              filePassword[i] = c;
   4.167 +                              ++i;
   4.168 +                            }
   4.169 +                            filePassword[i] = '\0';
   4.170 +                            fclose(passwordFile);
   4.171 +
   4.172 +                            /* IF PASSWORD FAILS COMPARISON... */
   4.173 +                            if (strcmp(filePassword, password)) {
   4.174 +                              /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
   4.175 +                              RedirectToLoginPanel();
   4.176 +
   4.177 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
   4.178 +                            } else {
   4.179 +
   4.180 +                              /* LOAD SETTINGS VALUES FROM FILES */
   4.181 +
   4.182 +                              /* LOAD interos CONTENT COMPONENTS FROM FILES */
   4.183 +
   4.184 +                              /* DECLARE AND INITIALIZE QUERY VARIABLES */
   4.185 +                              char *new, *open, *text_file, *status;
   4.186 +                              new = open = text_file = status = NULL;
   4.187 +
   4.188 +                              /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
   4.189 +                              if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
   4.190 +                                char *query;
   4.191 +                                INT queryLength = strlen(getenv("QUERY_STRING"));
   4.192 +                                if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
   4.193 +                                  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
   4.194 +                                } else {
   4.195 +                                  free(variableName);
   4.196 +                                  strcpy(query, getenv("QUERY_STRING"));
   4.197 +                                  if (!(variableName = malloc(queryLength + 1))) {
   4.198 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
   4.199 +                                  } else {
   4.200 +                                    free(variableValue);
   4.201 +                                    if (!(variableValue = malloc(queryLength + 1))) {
   4.202 +                                      /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
   4.203 +
   4.204 +                                    /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
   4.205 +                                    } else {
   4.206 +
   4.207 +                                      /* PROCESS QUERY DATA */
   4.208 +                                      INT q = 0;
   4.209 +                                      i = 0;
   4.210 +                                      while ((q < queryLength) && (query[q] != '\0')) {
   4.211 +                                        while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
   4.212 +                                          variableName[i] = query[q];
   4.213 +                                          ++q;
   4.214 +                                          ++i;
   4.215 +                                        }
   4.216 +                                        variableName[i] = '\0';
   4.217 +                                        ++q;
   4.218 +                                        i = 0;
   4.219 +                                        while ((query[q] != '&') && (query[q] != '\0')) {
   4.220 +                                          variableValue[i] = query[q];
   4.221 +                                          ++q;
   4.222 +                                          ++i;
   4.223 +                                        }
   4.224 +                                        variableValue[i] = '\0';
   4.225 +                                        if (query[q] != '\0') {
   4.226 +                                          ++q;
   4.227 +                                        }
   4.228 +                                        if (!new && !strcmp(variableName, "new")) {
   4.229 +                                          if ((new = malloc(strlen(variableValue) + 1)) != 0) {
   4.230 +                                            strcpy(new, variableValue);
   4.231 +                                          }
   4.232 +                                        } else if (!open && !strcmp(variableName, "open")) {
   4.233 +                                          if ((open = malloc(strlen(variableValue) + 1)) != 0) {
   4.234 +                                            strcpy(open, variableValue);
   4.235 +                                          }
   4.236 +                                        } else if (!text_file && !strcmp(variableName, "text_file")) {
   4.237 +                                          if ((text_file = malloc(strlen(variableValue) + 1)) != 0) {
   4.238 +                                            strcpy(text_file, variableValue);
   4.239 +                                          }
   4.240 +                                        } else if (!status && !strcmp(variableName, "status")) {
   4.241 +                                          if ((status = malloc(strlen(variableValue) + 1)) != 0) {
   4.242 +                                            strcpy(status, variableValue);
   4.243 +                                          }
   4.244 +                                        }
   4.245 +                                      }
   4.246 +                                      free(variableValue);
   4.247 +                                      variableValue = NULL;
   4.248 +                                    }
   4.249 +                                    free(variableName);
   4.250 +                                    variableName = NULL;
   4.251 +                                  }
   4.252 +                                  free(query);
   4.253 +                                }
   4.254 +                              }
   4.255 +
   4.256 +                              /* OUTPUT XHTML FOR interos CONTENT */
   4.257 +                              if (new) {
   4.258 +                                OutputContent("new", new);
   4.259 +                              } else if (open) {
   4.260 +                                OutputContent("open", open);
   4.261 +                              } else if (text_file) {
   4.262 +                                OutputContent("text_file", text_file);
   4.263 +                              } else if (status) {
   4.264 +                                OutputContent("status", status);
   4.265 +                              } else {
   4.266 +                                OutputContent(NULL, NULL);
   4.267 +                              }
   4.268 +                              free(status);
   4.269 +                              free(text_file);
   4.270 +                              free(open);
   4.271 +                              free(new);
   4.272 +                            }
   4.273 +                            free(filePassword);
   4.274 +                          }
   4.275 +                        }
   4.276 +                      }
   4.277 +                      free(passwordFileName);
   4.278 +                    }
   4.279 +                  }
   4.280 +                  free(systemDirectory);
   4.281 +                }
   4.282 +                free(directory);
   4.283 +              }
   4.284 +              free(login);
   4.285 +            }
   4.286 +            free(password);
   4.287 +            free(variableValue);
   4.288 +          }
   4.289 +          free(variableName);
   4.290 +        }
   4.291 +        free(cookie);
   4.292 +      }
   4.293 +    }
   4.294 +  }
   4.295 +  return 0;
   4.296 +}
   4.297 +
   4.298 +/* FUNCTION | REDIRECT TO LOGIN PANEL */
   4.299 +static void RedirectToLoginPanel(void) {
   4.300 +  printf("Location: login\r\n\r\n");
   4.301 +}
   4.302 +
   4.303 +/* FUNCTION | OUTPUT XHTML FOR interos CONTENT */
   4.304 +static void OutputContent(const char *variableName, char *variableValue) {
   4.305 +  printf("Content-Type: text/html\r\n\r\n");
   4.306 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
   4.307 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/content.css\"?>\n");
   4.308 +  printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n");
   4.309 +  printf("                      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
   4.310 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
   4.311 +  printf("  <!--=================================================-->\n");
   4.312 +  printf("  <!--    interos Standard Document Header - Markup    -->\n");
   4.313 +  printf("  <!--=================================================-->\n");
   4.314 +  printf("  <!--    URIs:  https://interos.com/content           -->\n");
   4.315 +  printf("  <!--           https://www.interos.com/content       -->\n");
   4.316 +  printf("  <!--   Title:  interos content                       -->\n");
   4.317 +  printf("  <!--  Author:  Brent Angeline                        -->\n");
   4.318 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional  -->\n");
   4.319 +  printf("  <!--=================================================-->\n");
   4.320 +  printf("  <head>\n");
   4.321 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
   4.322 +  printf("    <meta name=\"title\" content=\"interos content\" />\n");
   4.323 +  printf("    <meta name=\"description\" content=\"middle frame for interos content\" />\n");
   4.324 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
   4.325 +  printf("    <meta name=\"copyright\" \n");
   4.326 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
   4.327 +  printf("    <meta name=\"robots\" content=\"noindex,nofollow,noarchive\" />\n");
   4.328 +  printf("    <title>interos content</title>\n");
   4.329 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
   4.330 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
   4.331 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/content.css\" />\n");
   4.332 +  printf("    <script type=\"text/javascript\" src=\"/js/content.js\"></script>\n");
   4.333 +  printf("  </head>\n");
   4.334 +  printf("  <body>\n");
   4.335 +  printf("    <div id=\"content\">\n");
   4.336 +  if (variableName && variableValue) {
   4.337 +    if (!strcmp(variableName, "new")) {
   4.338 +      if (!strcmp(variableValue, "text_file")) {
   4.339 +        printf("      <applet code=\"text_editor\" \n");
   4.340 +        printf("              archive=\"/java/text_editor.jar,/java/interos_connect.jar\" \n");
   4.341 +        printf("              width=\"100%%\" \n");
   4.342 +        printf("              height=\"100%%\"></applet>\n");
   4.343 +      }
   4.344 +    } else if (!strcmp(variableName, "text_file")) {
   4.345 +        printf("      <applet code=\"text_editor\" \n");
   4.346 +        printf("              archive=\"/java/text_editor.jar,/java/interos_connect.jar\" \n");
   4.347 +        printf("              width=\"100%%\" \n");
   4.348 +        printf("              height=\"100%%\">\n");
   4.349 +        printf("        <param name=\"text_file\" value=\"%s\" />\n", variableValue);
   4.350 +        printf("      </applet>\n");
   4.351 +    }
   4.352 +  }
   4.353 +  printf("    </div>\n");
   4.354 +  printf("  </body>\n");
   4.355 +  printf("  <!--=====================================================================-->\n");
   4.356 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
   4.357 +  printf("  <!--=====================================================================-->\n");
   4.358 +  printf("  <!--                                                                     -->\n");
   4.359 +  printf("  <!--          All original textual and graphical site content:           -->\n");
   4.360 +  printf("  <!--                                                                     -->\n");
   4.361 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
   4.362 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
   4.363 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
   4.364 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
   4.365 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
   4.366 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
   4.367 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
   4.368 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
   4.369 +  printf("  <!--                                                                     -->\n");
   4.370 +  printf("  <!--=====================================================================-->\n");
   4.371 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
   4.372 +  printf("  <!--=====================================================================-->\n");
   4.373 +  printf("</html>");
   4.374 +}
   4.375 +
   4.376 +/***********************************************************************/
   4.377 +/*                  Copyright and Trademark Statement                  */
   4.378 +/***********************************************************************/
   4.379 +/*                                                                     */
   4.380 +/*          All original textual and graphical site content:           */
   4.381 +/*                                                                     */
   4.382 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
   4.383 +/*  reserved.  Reproduction in whole or in part without written        */
   4.384 +/*  permission is prohibited.  interos and the interos logos are       */
   4.385 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
   4.386 +/*  product, and service names mentioned herein may be the properties  */
   4.387 +/*  of their respective owners.  Comments in the interos.org forums    */
   4.388 +/*  are the properties of their respective authors.  All software      */
   4.389 +/*  developed in the forums is open source and belongs to everyone.    */
   4.390 +/*                                                                     */
   4.391 +/***********************************************************************/
   4.392 +/*                      e-mail: info@interos.com                       */
   4.393 +/***********************************************************************/
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/c/interos.c	Sat May 01 16:19:36 2010 -0400
     5.3 @@ -0,0 +1,1 @@
     5.4 +interos_interos.com_ssl.c
     5.5 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/c/interos.h	Sat May 01 16:19:36 2010 -0400
     6.3 @@ -0,0 +1,1 @@
     6.4 +interos_interos.com_ssl.h
     6.5 \ No newline at end of file
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/c/interos.org.h	Sat May 01 16:19:36 2010 -0400
     7.3 @@ -0,0 +1,1 @@
     7.4 +interos.org_interos.org_ssl.h
     7.5 \ No newline at end of file
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/c/interos_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
     8.3 @@ -0,0 +1,229 @@
     8.4 +#include "fcgi_stdio.h"
     8.5 +#include "interos.h"
     8.6 +#include <stdlib.h>
     8.7 +#include <string.h>
     8.8 +#include <dirent.h>
     8.9 +#include <langinfo.h>
    8.10 +#include <sys/stat.h>
    8.11 +#include <unistd.h>
    8.12 +
    8.13 +/*  */
    8.14 +void outputErrorXML(const char *errorMessage) {
    8.15 +  printf("Content-Type: text/xml\r\n\r\n");
    8.16 +  printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    8.17 +  printf("<directory>\n");
    8.18 +  printf("  <errorCode error=\"true\">\n");
    8.19 +  printf("    <description>%s</description>\n", errorMessage);
    8.20 +  printf("  </errorCode>\n");
    8.21 +  printf("</directory>");
    8.22 +}
    8.23 +
    8.24 +POSTDATA *getPostData(){
    8.25 +    POSTDATA* postdata = (POSTDATA*)(malloc(sizeof(POSTDATA)));
    8.26 +	postdata->postData = NULL;
    8.27 +	postdata->length = 0;
    8.28 +	/* IF POST DATA DOESN'T EXIST OR IS TOO LONG... */
    8.29 +	if (!getenv("CONTENT_LENGTH") || (sizeof(STRING_TO_INT(getenv("CONTENT_LENGTH"), (char **) NULL, 10)) > sizeof(INT))) {
    8.30 +	/** ERROR | POST DATA DOES NOT EXIST OR IS TOO LONG > OUTPUT ERROR XML **/
    8.31 +	outputErrorXML("No post data was received by the web server.");
    8.32 +	free(postdata);
    8.33 +	postdata = NULL;
    8.34 +
    8.35 +	/* OTHERWISE, IF POST DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
    8.36 +	} else {
    8.37 +
    8.38 +		/* ATTEMPT TO ALLOCATE MEMORY FOR POST VARIABLES */
    8.39 +		void* post;
    8.40 +		INT postLength = STRING_TO_INT(getenv("CONTENT_LENGTH"), (char **) NULL, 10);
    8.41 +		if ((postLength < 1) || !(post = malloc(postLength + 1))) {
    8.42 +		  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR POST DATA! > OUTPUT ERROR XML **/
    8.43 +		  outputErrorXML("The length of the post data string received by the web server was indicated to be less than 1 byte.");
    8.44 +		  free(postdata);
    8.45 +		  postdata = NULL;
    8.46 +		} else {
    8.47 +			/* PROCESS POST DATA */
    8.48 +			fread(post, postLength, 1, stdin);
    8.49 +			postdata->postData = post;
    8.50 +			postdata->length = postLength;
    8.51 +		}
    8.52 +	}
    8.53 +	return postdata;
    8.54 +}
    8.55 +
    8.56 +char* validateCookie() {
    8.57 +	char *username = NULL;
    8.58 +
    8.59 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
    8.60 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
    8.61 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > OUTPUT ERROR XML **/
    8.62 +      outputErrorXML("No cookie data was received by the web server.");
    8.63 +
    8.64 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
    8.65 +    } else {
    8.66 +
    8.67 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
    8.68 +      char *cookie;
    8.69 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
    8.70 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
    8.71 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > OUTPUT ERROR XML **/
    8.72 +        outputErrorXML("The length of the cookie data string received by the web server was indicated to be less than 1 byte.");
    8.73 +      } else {
    8.74 +        char *variableName;
    8.75 +        if (!(variableName = malloc(cookieLength + 1))) {
    8.76 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > OUTPUT ERROR XML **/
    8.77 +          outputErrorXML("Sufficient memory could not be allocated on the server for cookie variable names.");
    8.78 +        } else {
    8.79 +          char *variableValue;
    8.80 +          if (!(variableValue = malloc(cookieLength + 1))) {
    8.81 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > OUTPUT ERROR XML **/
    8.82 +            outputErrorXML("Sufficient memory could not be allocated on the server for cookie variable values.");
    8.83 +
    8.84 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
    8.85 +          } else {
    8.86 +
    8.87 +            /* PROCESS COOKIE DATA */
    8.88 +            char *login, *password;
    8.89 +            INT i, c;
    8.90 +            login = password = NULL;
    8.91 +            c = 0;
    8.92 +            strcpy(cookie, getenv("HTTP_COOKIE"));
    8.93 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
    8.94 +              i = 0;
    8.95 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
    8.96 +                variableName[i] = cookie[c];
    8.97 +                ++c;
    8.98 +                ++i;
    8.99 +              }
   8.100 +              variableName[i] = '\0';
   8.101 +              ++c;
   8.102 +              i = 0;
   8.103 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
   8.104 +                variableValue[i] = cookie[c];
   8.105 +                ++c;
   8.106 +                ++i;
   8.107 +              }
   8.108 +              variableValue[i] = '\0';
   8.109 +              ++c;
   8.110 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
   8.111 +                ++c;
   8.112 +              }
   8.113 +              if (!login && !strcmp(variableName, "login")) {
   8.114 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
   8.115 +                  strcpy(login, variableValue);
   8.116 +                }
   8.117 +              } else if (!password && !strcmp(variableName, "password")) {
   8.118 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
   8.119 +                  strcpy(password, variableValue);
   8.120 +                }
   8.121 +              }
   8.122 +            }
   8.123 +
   8.124 +            /* IF LOGIN VALUE IS MISSING... */
   8.125 +            if (!login) {
   8.126 +              /** ERROR | LOGIN VALUE IS MISSING > OUTPUT ERROR XML */
   8.127 +              outputErrorXML("No login value was received.");
   8.128 +
   8.129 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
   8.130 +            } else {
   8.131 +
   8.132 +              /* VERIFY LOGIN AND PASSWORD */
   8.133 +              char *directory;
   8.134 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
   8.135 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > OUTPUT ERROR XML **/
   8.136 +                outputErrorXML("Sufficient memory could not be allocated on the server for the user's home directory name.");
   8.137 +              } else {
   8.138 +                char *systemDirectory;
   8.139 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
   8.140 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > OUTPUT ERROR XML **/
   8.141 +                  outputErrorXML("Sufficient memory could not be allocated on the server for the user's system directory name.");
   8.142 +                } else {
   8.143 +                  strcpy(directory, DIRECTORY);
   8.144 +                  strcat(directory, login);
   8.145 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
   8.146 +                  strcat(systemDirectory, login);
   8.147 +
   8.148 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
   8.149 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
   8.150 +                    /** ERROR | CANNOT ACCESS DIRECTORY > OUTPUT ERROR XML **/
   8.151 +                    outputErrorXML("The user's home directory on the server could not be accessed.");
   8.152 +
   8.153 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
   8.154 +                  } else {
   8.155 +
   8.156 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
   8.157 +                    char *passwordFileName;
   8.158 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
   8.159 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > OUTPUT ERROR XML **/
   8.160 +                      outputErrorXML("Sufficient memory could not be allocated on the server for the name of the user's password file.");
   8.161 +                    } else {
   8.162 +                      strcpy(passwordFileName, systemDirectory);
   8.163 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
   8.164 +
   8.165 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
   8.166 +                      if (access(passwordFileName, F_OK)) {
   8.167 +                        /** ERROR | CANNOT ACCESS FILE > OUTPUT ERROR XML **/
   8.168 +                        outputErrorXML("The user's password file on the server cannot be accessed.");
   8.169 +
   8.170 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
   8.171 +                      } else {
   8.172 +
   8.173 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
   8.174 +                        FILE *passwordFile;
   8.175 +
   8.176 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
   8.177 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
   8.178 +                          /** ERROR | CANNOT READ FILE > OUTPUT ERROR XML **/
   8.179 +                          outputErrorXML("The user's password file on the server cannot be opened for reading.");
   8.180 +
   8.181 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
   8.182 +                        } else {
   8.183 +                          char *filePassword;
   8.184 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
   8.185 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > OUTPUT ERROR XML **/
   8.186 +                            outputErrorXML("Sufficient memory could not be allocated on the server for reading the user's password.");
   8.187 +                          } else {
   8.188 +                            char c;
   8.189 +                            i = 0;
   8.190 +
   8.191 +                            /* READ PASSWORD FROM PASSWORD FILE */
   8.192 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
   8.193 +                              filePassword[i] = c;
   8.194 +                              ++i;
   8.195 +                            }
   8.196 +                            filePassword[i] = '\0';
   8.197 +                            fclose(passwordFile);
   8.198 +
   8.199 +                            /* IF PASSWORD FAILS COMPARISON... */
   8.200 +                            if (strcmp(filePassword, password)) {
   8.201 +                              /** ERROR | PASSWORD FAILED > OUTPUT ERROR XML **/
   8.202 +                              outputErrorXML("The password provided failed comparison with the password stored on the server.");
   8.203 +
   8.204 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
   8.205 +                            } else {
   8.206 +								username = login;
   8.207 +                            }
   8.208 +                            free(filePassword);
   8.209 +                          }
   8.210 +                        }
   8.211 +                      }
   8.212 +                      free(passwordFileName);
   8.213 +                    }
   8.214 +                  }
   8.215 +                  free(systemDirectory);
   8.216 +                }
   8.217 +                free(directory);
   8.218 +              }
   8.219 +			  if(!username && login)
   8.220 +				free(login);
   8.221 +
   8.222 +            }
   8.223 +            free(password);
   8.224 +            free(variableValue);
   8.225 +          }
   8.226 +          free(variableName);
   8.227 +        }
   8.228 +        free(cookie);
   8.229 +      }
   8.230 +    }
   8.231 +  return username;
   8.232 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/c/interos_interos.com_ssl.h	Sat May 01 16:19:36 2010 -0400
     9.3 @@ -0,0 +1,117 @@
     9.4 +/*************************************************************/
     9.5 +/*  interos Standard Document Header - CGI in C Header File  */
     9.6 +/*************************************************************/
     9.7 +/*              Source:  interos.h                           */
     9.8 +/*         Description:  FastCGI Header for interos          */
     9.9 +/*              Author:  Brent Angeline                      */
    9.10 +/*                 CGI:  FastCGI in ISO/ANSI C               */
    9.11 +/*************************************************************/
    9.12 +
    9.13 +/* PREPROCESSOR DIRECTIVES */
    9.14 +# ifndef INTEROS_H
    9.15 +
    9.16 +#   define INTEROS_H
    9.17 +
    9.18 +  /* HEADER FILES INCLUDED BY C SOURCE */
    9.19 +#   ifndef INTEROS_H
    9.20 +
    9.21 +#     include "fcgi_stdio.h"            /*  FCGI_Accept(), fclose(), fgetc(), fopen(), fread(), printf()  */
    9.22 +#     include <ctype.h>                 /*  tolower()                                                     */
    9.23 +#     include <stdlib.h>                /*  free(), getenv(), malloc(), strtoul()                         */
    9.24 +#     include <string.h>                /*  strcat(), strcmp(), strcpy(), strlen()                        */
    9.25 +#     include <unistd.h>                /*  F_OK, access()                                                */
    9.26 +
    9.27 +#   endif
    9.28 +
    9.29 +  /* DEFINITION DIRECTIVES */
    9.30 +#   define INT                          unsigned long
    9.31 +#   define STRING_TO_INT                strtoul
    9.32 +#   define DIRECTORY                    "/srv/https/interos.com/"
    9.33 +#   define SYSTEM_DIRECTORY             "/srv/data/interos/"
    9.34 +#   define PASSWORD_FILE_NAME           "/.htpasswd"
    9.35 +#   define MAX_PASSWORD_SIZE            16
    9.36 +
    9.37 +  /* NEW USER DEFINITION DIRECTIVES */
    9.38 +#   define SYSTEM_DIRECTORY_COMMAND     "cp -pRP /srv/data/interos/sys/data /srv/data/interos/"
    9.39 +#   define DIRECTORY_COMMAND            "cp -pRP /srv/data/interos/sys/user /srv/https/interos.com/"
    9.40 +#   define ECHO_COMMAND                 "echo "
    9.41 +#   define PASSWORD_OUT                 " > /srv/data/interos/"
    9.42 +
    9.43 +  /* TYPE DEFINITION */
    9.44 +  typedef struct {
    9.45 +    char *name;
    9.46 +    char *link;
    9.47 +    char *icon;
    9.48 +    struct MENU_ITEM *next;
    9.49 +  } MENU_ITEM;
    9.50 +
    9.51 +  /**
    9.52 +    Used by getPOSTData for storage of the POST data.
    9.53 +
    9.54 +
    9.55 +    length: The number of bytes allocated for postData.
    9.56 +
    9.57 +    postData: Allocated chunk of memory containing the POST data. The interpretation of that data
    9.58 +              depends on what the CGI program getting the data is expecting.
    9.59 +  */
    9.60 +  typedef struct{
    9.61 +      void *postData;
    9.62 +      INT length;
    9.63 +  }POSTDATA;
    9.64 +
    9.65 +  /**
    9.66 +    Obtains the POST data that was sent by the client connecting to the HTTP(S) server and stores it
    9.67 +    in POSTDATA struct. The POSTDATA->postData is a chunk of memory copied from the client. If the data
    9.68 +    is to be interpreted as a string, one should not expect it to be null terminated, which is why length
    9.69 +    is part of the POSTDATA struct.
    9.70 +
    9.71 +    One more byte of memory is allocated for POSTDATA->postData for conveniance. In the event that the
    9.72 +    POST data is interpreted as a string, one may set POSTDATA->postData[POSTDATA->length] = '\0' without
    9.73 +    having to use realloc.
    9.74 +
    9.75 +    @return An allocated struct POSTDATA with allocated postData of size length+1. If there is no POST data,
    9.76 +            it will return an allocated struct POSTDATA with length 0 and postData NULL. If there was an error
    9.77 +            getting the post data, it will call outputErrorXML() with the apropriate error and return NULL.
    9.78 +  */
    9.79 +  POSTDATA *getPOSTData();
    9.80 +
    9.81 +  /**
    9.82 +    Obtains cookie data from the HTTP header and validates it with the appropriate login.
    9.83 +    If the cookie data has the correct username and password, the function will return
    9.84 +    the username. If validation fails, it will automatically call outputErrorXML with
    9.85 +    the appropriate error information and return NULL.
    9.86 +
    9.87 +    @return An allocated string containing the username from the cookie data, or NULL
    9.88 +            if validation failed.
    9.89 +
    9.90 +  */
    9.91 +  char *validateCookie();
    9.92 +
    9.93 +  /**
    9.94 +    Prints an error XML.
    9.95 +
    9.96 +    @param errorMessage A string that contains the description of the error.
    9.97 +  */
    9.98 +  void outputErrorXML(const char *errorMessage);
    9.99 +
   9.100 +
   9.101 +# endif
   9.102 +
   9.103 +/***********************************************************************/
   9.104 +/*                  Copyright and Trademark Statement                  */
   9.105 +/***********************************************************************/
   9.106 +/*                                                                     */
   9.107 +/*          All original textual and graphical site content:           */
   9.108 +/*                                                                     */
   9.109 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
   9.110 +/*  reserved.  Reproduction in whole or in part without written        */
   9.111 +/*  permission is prohibited.  interos and the interos logos are       */
   9.112 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
   9.113 +/*  product, and service names mentioned herein may be the properties  */
   9.114 +/*  of their respective owners.  Comments in the interos.org forums    */
   9.115 +/*  are the properties of their respective authors.  All software      */
   9.116 +/*  developed in the forums is open source and belongs to everyone.    */
   9.117 +/*                                                                     */
   9.118 +/***********************************************************************/
   9.119 +/*                      e-mail: info@interos.com                       */
   9.120 +/***********************************************************************/
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/c/login_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
    10.3 @@ -0,0 +1,359 @@
    10.4 +/*************************************************/
    10.5 +/*  interos Standard Document Header - CGI in C  */
    10.6 +/*************************************************/
    10.7 +/*         URIs:  https://interos.com/login      */
    10.8 +/*                https://www.interos.com/login  */
    10.9 +/*       Source:  login.c                        */
   10.10 +/*  Description:  FastCGI for interos login      */
   10.11 +/*       Author:  Brent Angeline                 */
   10.12 +/*          CGI:  FastCGI in ISO/ANSI C          */
   10.13 +/*************************************************/
   10.14 +
   10.15 +/* PREPROCESSOR DIRECTIVES */
   10.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), fread(), printf()                            */
   10.17 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, PASSWORD_FILE_NAME, STRING_TO_INT, SYSTEM_DIRECTORY  */
   10.18 +#include <ctype.h>          /*  tolower()                                                                               */
   10.19 +#include <stdlib.h>         /*  free(), getenv(), malloc(), strtoul()                                                   */
   10.20 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                                  */
   10.21 +#include <unistd.h>         /*  F_OK, access()                                                                          */
   10.22 +
   10.23 +/* FUNCTION PROTOTYPE DECLARATION */
   10.24 +static void OutputLoginPanel(void);
   10.25 +
   10.26 +/* BEGIN MAIN PROGRAM */
   10.27 +int main(void) {
   10.28 +
   10.29 +  /* BEGIN FASTCGI */
   10.30 +  while (FCGI_Accept() >= 0) {
   10.31 +
   10.32 +    /* IF POST DATA DOESN'T EXIST OR IS TOO LONG... */
   10.33 +    if (!getenv("CONTENT_LENGTH") || (sizeof(STRING_TO_INT(getenv("CONTENT_LENGTH"), (char **) NULL, 10)) > sizeof(INT))) {
   10.34 +
   10.35 +      /* OUTPUT XHTML FOR LOGIN PANEL */
   10.36 +      OutputLoginPanel();
   10.37 +
   10.38 +    /* OTHERWISE, IF POST DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
   10.39 +    } else {
   10.40 +
   10.41 +      /* ATTEMPT TO ALLOCATE MEMORY FOR POST VARIABLES */
   10.42 +      char *post;
   10.43 +      INT postLength = STRING_TO_INT(getenv("CONTENT_LENGTH"), (char **) NULL, 10);
   10.44 +      if ((postLength < 1) || !(post = malloc(postLength + 1))) {
   10.45 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR POST DATA! > OUTPUT XHTML FOR LOGIN PANEL **/
   10.46 +        OutputLoginPanel();
   10.47 +      } else {
   10.48 +        char *variableName;
   10.49 +        if (!(variableName = malloc(postLength + 1))) {
   10.50 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR POST VARIABLE NAME > OUTPUT XHTML FOR LOGIN PANEL **/
   10.51 +          OutputLoginPanel();
   10.52 +        } else {
   10.53 +          char *variableValue;
   10.54 +          if (!(variableValue = malloc(postLength + 1))) {
   10.55 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR POST VARIABLE VALUE > OUTPUT XHTML FOR LOGIN PANEL **/
   10.56 +            OutputLoginPanel();
   10.57 +
   10.58 +          /* IF SUFFICIENT MEMORY FOR POST VARIABLES... */
   10.59 +          } else {
   10.60 +
   10.61 +            /* PROCESS POST DATA */
   10.62 +            char *login, *password;
   10.63 +            INT p, i;
   10.64 +            login = password = NULL;
   10.65 +            p = 0;
   10.66 +            fread(post, postLength, 1, stdin);
   10.67 +            post[postLength] = '\0';
   10.68 +            while ((p < postLength) && (post[p] != '\0')) {
   10.69 +              i = 0;
   10.70 +              while ((p < postLength) && (post[p] != '=') && (post[p] != '\0')) {
   10.71 +                variableName[i] = post[p];
   10.72 +                ++p;
   10.73 +                ++i;
   10.74 +              }
   10.75 +              variableName[i] = '\0';
   10.76 +              ++p;
   10.77 +              i = 0;
   10.78 +              while ((p < postLength) && (post[p] != '&') && (post[p] != '\0')) {
   10.79 +                variableValue[i] = post[p];
   10.80 +                ++p;
   10.81 +                ++i;
   10.82 +              }
   10.83 +              variableValue[i] = '\0';
   10.84 +              if (post[p] != '\0') {
   10.85 +                ++p;
   10.86 +              }
   10.87 +              if (!login && !strcmp(variableName, "login")) {
   10.88 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
   10.89 +                  strcpy(login, variableValue);
   10.90 +                  for (i = 0; i < strlen(login); ++i) {
   10.91 +                    login[i] = tolower(login[i]);
   10.92 +                  }
   10.93 +                }
   10.94 +              } else if (!password && !strcmp(variableName, "password")) {
   10.95 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
   10.96 +                  strcpy(password, variableValue);
   10.97 +                }
   10.98 +              }
   10.99 +            }
  10.100 +
  10.101 +            /* IF LOGIN VALUE IS MISSING... */
  10.102 +            if (!login) {
  10.103 +              /** ERROR | LOGIN VALUE IS MISSING > OUTPUT XHTML FOR LOGIN PANEL **/
  10.104 +              OutputLoginPanel();
  10.105 +
  10.106 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
  10.107 +            } else {
  10.108 +
  10.109 +              /* VERIFY LOGIN AND PASSWORD */
  10.110 +              char *directory;
  10.111 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
  10.112 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > OUTPUT XHTML FOR LOGIN PANEL **/
  10.113 +                OutputLoginPanel();
  10.114 +              } else {
  10.115 +                char *systemDirectory;
  10.116 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
  10.117 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > OUTPUT XHTML FOR LOGIN PANEL **/
  10.118 +                  OutputLoginPanel();
  10.119 +                } else {
  10.120 +                  strcpy(directory, DIRECTORY);
  10.121 +                  strcat(directory, login);
  10.122 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
  10.123 +                  strcat(systemDirectory, login);
  10.124 +
  10.125 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
  10.126 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
  10.127 +                    /** ERROR | CANNOT ACCESS DIRECTORY > OUTPUT XHTML FOR LOGIN PANEL **/
  10.128 +                    OutputLoginPanel();
  10.129 +
  10.130 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
  10.131 +                  } else {
  10.132 +
  10.133 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
  10.134 +                    char *passwordFileName;
  10.135 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
  10.136 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > OUTPUT XHTML FOR LOGIN PANEL **/
  10.137 +                      OutputLoginPanel();
  10.138 +                    } else {
  10.139 +                      strcpy(passwordFileName, systemDirectory);
  10.140 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
  10.141 +
  10.142 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
  10.143 +                      if (access(passwordFileName, F_OK)) {
  10.144 +                        /** ERROR | CANNOT ACCESS FILE > OUTPUT XHTML FOR LOGIN PANEL **/
  10.145 +                        OutputLoginPanel();
  10.146 +
  10.147 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
  10.148 +                      } else {
  10.149 +
  10.150 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
  10.151 +                        FILE *passwordFile;
  10.152 +
  10.153 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
  10.154 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
  10.155 +                          /** ERROR | CANNOT READ FILE > OUTPUT XHTML FOR LOGIN PANEL **/
  10.156 +                          OutputLoginPanel();
  10.157 +
  10.158 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
  10.159 +                        } else {
  10.160 +                          char *filePassword;
  10.161 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
  10.162 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > OUTPUT XHTML FOR LOGIN PANEL **/
  10.163 +                            OutputLoginPanel();
  10.164 +                          } else {
  10.165 +                            char c;
  10.166 +                            i = 0;
  10.167 +
  10.168 +                            /* READ PASSWORD FROM PASSWORD FILE */
  10.169 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
  10.170 +                              filePassword[i] = c;
  10.171 +                              ++i;
  10.172 +                            }
  10.173 +                            filePassword[i] = '\0';
  10.174 +                            fclose(passwordFile);
  10.175 +
  10.176 +                            /* IF NO PASSWORD FROM POST VARIABLES... */
  10.177 +                            if (!password) {
  10.178 +                              password = malloc(1);
  10.179 +                              password[0] = '\0';
  10.180 +                            }
  10.181 +
  10.182 +                            /* IF PASSWORD FAILS COMPARISON... */
  10.183 +                            if (strcmp(filePassword, password)) {
  10.184 +                              /** ERROR | PASSWORD FAILED > OUTPUT XHTML FOR LOGIN PANEL **/
  10.185 +                              OutputLoginPanel();
  10.186 +
  10.187 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
  10.188 +                            } else {
  10.189 +
  10.190 +                              /* SET COOKIES */
  10.191 +                              printf("Set-Cookie: login=%s; path=/; secure\r\n", login);
  10.192 +                              printf("Set-Cookie: password=%s; path=/; secure\r\n", password);
  10.193 +
  10.194 +                              /* REDIRECT LOGGED INTO interos */
  10.195 +                              printf("Location: welcome\r\n\r\n");
  10.196 +                            }
  10.197 +                            free(filePassword);
  10.198 +                          }
  10.199 +                        }
  10.200 +                      }
  10.201 +                      free(passwordFileName);
  10.202 +                    }
  10.203 +                  }
  10.204 +                  free(systemDirectory);
  10.205 +                }
  10.206 +                free(directory);
  10.207 +              }
  10.208 +              free(login);
  10.209 +            }
  10.210 +            free(password);
  10.211 +            free(variableValue);
  10.212 +          }
  10.213 +          free(variableName);
  10.214 +        }
  10.215 +        free(post);
  10.216 +      }
  10.217 +    }
  10.218 +  }
  10.219 +  return 0;
  10.220 +}
  10.221 +
  10.222 +/* FUNCTION | OUTPUT XHTML FOR LOGIN PANEL */
  10.223 +static void OutputLoginPanel(void) {
  10.224 +  printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
  10.225 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
  10.226 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/login.css\"?>\n");
  10.227 +  printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n");
  10.228 +  printf("                      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
  10.229 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  10.230 +  printf("  <!--=================================================-->\n");
  10.231 +  printf("  <!--    interos Standard Document Header - Markup    -->\n");
  10.232 +  printf("  <!--=================================================-->\n");
  10.233 +  printf("  <!--    URIs:  https://interos.com/login             -->\n");
  10.234 +  printf("  <!--           https://www.interos.com/login         -->\n");
  10.235 +  printf("  <!--   Title:  interos login                         -->\n");
  10.236 +  printf("  <!--  Author:  Brent Angeline                        -->\n");
  10.237 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional  -->\n");
  10.238 +  printf("  <!--=================================================-->\n");
  10.239 +  printf("  <head>\n");
  10.240 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  10.241 +  printf("    <meta name=\"title\" content=\"interos login\" />\n");
  10.242 +  printf("    <meta name=\"description\" content=\"enter into interos\" />\n");
  10.243 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  10.244 +  printf("    <meta name=\"copyright\" \n");
  10.245 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  10.246 +  printf("    <meta name=\"robots\" content=\"index, nofollow, noarchive\" />\n");
  10.247 +  printf("    <title>interos login</title>\n");
  10.248 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  10.249 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  10.250 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/login.css\" \n");
  10.251 +  printf("          media=\"screen, projection\" />\n");
  10.252 +  printf("    <script type=\"text/javascript\" src=\"/js/login.js\"></script>\n");
  10.253 +  printf("  </head>\n");
  10.254 +  printf("  <body id=\"body\">\n");
  10.255 +  printf("    <center>\n");
  10.256 +  printf("      <p id=\"navigation\">\n");
  10.257 +  printf("        <a href=\"/about\">about</a> | \n");
  10.258 +  printf("        <a href=\"/blog\">blog</a> | \n");
  10.259 +  printf("        <a href=\"/code\">code</a> | \n");
  10.260 +  printf("        <a href=\"https://interos.org/\">develop</a> | \n");
  10.261 +  printf("        <a href=\"/e-mail\">e-mail</a> | \n");
  10.262 +  printf("        <a href=\"/f.a.q.\">f.a.q.</a> | \n");
  10.263 +  printf("        <a href=\"/gear\">gear</a> | \n");
  10.264 +  printf("        <a href=\"/help\">help</a>\n");
  10.265 +  printf("      </p>\n");
  10.266 +  printf("      <form id=\"loginForm\" name=\"loginForm\" action=\"/login\" method=\"post\">\n");
  10.267 +  printf("        <table id=\"mainPanel\">\n");
  10.268 +  printf("          <thead>\n");
  10.269 +  printf("            <tr>\n");
  10.270 +  printf("              <th colspan=\"3\"><center>\n");
  10.271 +  printf("                                <div id=\"title\">\n");
  10.272 +  printf("                                  <h1>\n");
  10.273 +  printf("                                    <a href=\"/\">interos</a>\n");
  10.274 +  printf("                                  </h1>\n");
  10.275 +  printf("                                </div>\n");
  10.276 +  printf("                                <h2>\n");
  10.277 +  printf("                                  internet operating system\n");
  10.278 +  printf("                                </h2>\n");
  10.279 +  printf("                              </center></th>\n");
  10.280 +  printf("            </tr>\n");
  10.281 +  printf("          </thead>\n");
  10.282 +  printf("          <tfoot>\n");
  10.283 +  printf("            <tr>\n");
  10.284 +  printf("              <td colspan=\"3\"><br /></td>\n");
  10.285 +  printf("            </tr>\n");
  10.286 +  printf("          </tfoot>\n");
  10.287 +  printf("          <tbody>\n");
  10.288 +  printf("            <tr>\n");
  10.289 +  printf("              <td><label for=\"login\">login:</label>&nbsp;</td>\n");
  10.290 +  printf("              <td><input id=\"login\" name=\"login\" \n");
  10.291 +/*
  10.292 +  printf("                         value=\"guest\" readonly=\"readonly\" \n");
  10.293 +*/
  10.294 +  printf("                         value=\"guest\" \n");
  10.295 +  printf("                         size=\"16\" maxlength=\"16\" \n");
  10.296 +  printf("                         type=\"text\" /></td>\n");
  10.297 +  printf("            </tr>\n");
  10.298 +  printf("            <tr>\n");
  10.299 +  printf("              <td><label for=\"password\">password:</label>&nbsp;</td>\n");
  10.300 +  printf("              <td><input id=\"password\" name=\"password\" \n");
  10.301 +  printf("                         disabled=\"disabled\" \n");
  10.302 +  printf("                         size=\"16\" maxlength=\"16\" \n");
  10.303 +  printf("                         type=\"password\" /></td>\n");
  10.304 +  printf("              <td rowspan=\"2\"><div id=\"submitButton\">\n");
  10.305 +  printf("                                &nbsp;<input type=\"submit\" \n");
  10.306 +  printf("                                             value=\"login &raquo;\" />\n");
  10.307 +  printf("                              </div></td>\n");
  10.308 +  printf("            </tr>\n");
  10.309 +  printf("          </tbody>\n");
  10.310 +  printf("        </table>\n");
  10.311 +  printf("      </form>\n");
  10.312 +  printf("      <p id=\"newUser\">\n");
  10.313 +  printf("        <a href=\"/new_user\"><strong>new users click here</strong><br />\n");
  10.314 +  printf("        to create your login</a>\n");
  10.315 +  printf("      </p>\n");
  10.316 +  printf("      <p>\n");
  10.317 +  printf("        <br />\n");
  10.318 +  printf("      </p>\n");
  10.319 +  printf("      <p id=\"copyrightDates\">\n");
  10.320 +  printf("        &copy; 2001&#8211;2010 interos\n");
  10.321 +  printf("      </p>\n");
  10.322 +  printf("    </center>\n");
  10.323 +  printf("  </body>\n");
  10.324 +  printf("  <!--=====================================================================-->\n");
  10.325 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
  10.326 +  printf("  <!--=====================================================================-->\n");
  10.327 +  printf("  <!--                                                                     -->\n");
  10.328 +  printf("  <!--          All original textual and graphical site content:           -->\n");
  10.329 +  printf("  <!--                                                                     -->\n");
  10.330 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
  10.331 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
  10.332 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
  10.333 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
  10.334 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
  10.335 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
  10.336 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
  10.337 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
  10.338 +  printf("  <!--                                                                     -->\n");
  10.339 +  printf("  <!--=====================================================================-->\n");
  10.340 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
  10.341 +  printf("  <!--=====================================================================-->\n");
  10.342 +  printf("</html>");
  10.343 +}
  10.344 +
  10.345 +/***********************************************************************/
  10.346 +/*                  Copyright and Trademark Statement                  */
  10.347 +/***********************************************************************/
  10.348 +/*                                                                     */
  10.349 +/*          All original textual and graphical site content:           */
  10.350 +/*                                                                     */
  10.351 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
  10.352 +/*  reserved.  Reproduction in whole or in part without written        */
  10.353 +/*  permission is prohibited.  interos and the interos logos are       */
  10.354 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
  10.355 +/*  product, and service names mentioned herein may be the properties  */
  10.356 +/*  of their respective owners.  Comments in the interos.org forums    */
  10.357 +/*  are the properties of their respective authors.  All software      */
  10.358 +/*  developed in the forums is open source and belongs to everyone.    */
  10.359 +/*                                                                     */
  10.360 +/***********************************************************************/
  10.361 +/*                      e-mail: info@interos.com                       */
  10.362 +/***********************************************************************/
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/c/logout_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
    11.3 @@ -0,0 +1,48 @@
    11.4 +/**************************************************/
    11.5 +/*  interos Standard Document Header - CGI in C   */
    11.6 +/**************************************************/
    11.7 +/*         URIs:  https://interos.com/logout      */
    11.8 +/*                https://www.interos.com/logout  */
    11.9 +/*       Source:  logout.c                        */
   11.10 +/*  Description:  FastCGI for interos logout      */
   11.11 +/*       Author:  Brent Angeline                  */
   11.12 +/*          CGI:  FastCGI in ISO/ANSI C           */
   11.13 +/**************************************************/
   11.14 +
   11.15 +/* PREPROCESSOR DIRECTIVE */
   11.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), printf()  */
   11.17 +
   11.18 +/* BEGIN MAIN PROGRAM */
   11.19 +int main(void) {
   11.20 +
   11.21 +  /* BEGIN FASTCGI */
   11.22 +  while (FCGI_Accept() >= 0) {
   11.23 +
   11.24 +    /* SET COOKIES */
   11.25 +    printf("Set-Cookie: login=; path=/; secure\r\n");
   11.26 +    printf("Set-Cookie: password=; path=/; secure\r\n");
   11.27 +
   11.28 +    /* REDIRECT TO LOGIN PANEL */
   11.29 +    printf("Location: login\r\n\r\n");
   11.30 +  }
   11.31 +  return 0;
   11.32 +}
   11.33 +
   11.34 +/***********************************************************************/
   11.35 +/*                  Copyright and Trademark Statement                  */
   11.36 +/***********************************************************************/
   11.37 +/*                                                                     */
   11.38 +/*          All original textual and graphical site content:           */
   11.39 +/*                                                                     */
   11.40 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
   11.41 +/*  reserved.  Reproduction in whole or in part without written        */
   11.42 +/*  permission is prohibited.  interos and the interos logos are       */
   11.43 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
   11.44 +/*  product, and service names mentioned herein may be the properties  */
   11.45 +/*  of their respective owners.  Comments in the interos.org forums    */
   11.46 +/*  are the properties of their respective authors.  All software      */
   11.47 +/*  developed in the forums is open source and belongs to everyone.    */
   11.48 +/*                                                                     */
   11.49 +/***********************************************************************/
   11.50 +/*                      e-mail: info@interos.com                       */
   11.51 +/***********************************************************************/
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/c/main_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
    12.3 @@ -0,0 +1,724 @@
    12.4 +/*************************************************/
    12.5 +/*  interos Standard Document Header - CGI in C  */
    12.6 +/*************************************************/
    12.7 +/*         URIs:  https://interos.com/           */
    12.8 +/*                https://interos.com/main       */
    12.9 +/*                https://www.interos.com/       */
   12.10 +/*                https://www.interos.com/main   */
   12.11 +/*       Source:  main.c                         */
   12.12 +/*  Description:  FastCGI for interos main       */
   12.13 +/*       Author:  Brent Angeline                 */
   12.14 +/*          CGI:  FastCGI in ISO/ANSI C          */
   12.15 +/*************************************************/
   12.16 +
   12.17 +/* PREPROCESSOR DIRECTIVES */
   12.18 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), printf()                                 */
   12.19 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, MENU_ITEM, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
   12.20 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                                          */
   12.21 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                              */
   12.22 +#include <unistd.h>         /*  F_OK, access()                                                                      */
   12.23 +
   12.24 +#ifndef INTEROS_H
   12.25 +
   12.26 +  /* TYPE DEFINITION */
   12.27 +  typedef struct {
   12.28 +    char *name;
   12.29 +    char *link;
   12.30 +    char *icon;
   12.31 +    struct MENU_ITEM *next;
   12.32 +  } MENU_ITEM;
   12.33 +
   12.34 +#endif
   12.35 +
   12.36 +/* FUNCTION PROTOTYPE DECLARATIONS */
   12.37 +static void RedirectToLoginPanel(void);
   12.38 +static void OutputGUI(const char *variableName, char *variableValue);
   12.39 +static void OutputNewMenu(void);
   12.40 +static void OutputOpenMenu(char *open);
   12.41 +static void OutputNextMenu(char *next);
   12.42 +static void OutputSettingsMenu(char *settings);
   12.43 +static void BeginXHTMLOutput(void);
   12.44 +static void FinishXHTMLOutput(void);
   12.45 +
   12.46 +/* BEGIN MAIN PROGRAM */
   12.47 +int main(void) {
   12.48 +
   12.49 +  /* BEGIN FASTCGI */
   12.50 +  while (FCGI_Accept() >= 0) {
   12.51 +
   12.52 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
   12.53 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
   12.54 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
   12.55 +      RedirectToLoginPanel();
   12.56 +
   12.57 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
   12.58 +    } else {
   12.59 +
   12.60 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
   12.61 +      char *cookie;
   12.62 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
   12.63 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
   12.64 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
   12.65 +        RedirectToLoginPanel();
   12.66 +      } else {
   12.67 +        char *variableName;
   12.68 +        if (!(variableName = malloc(cookieLength + 1))) {
   12.69 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
   12.70 +          RedirectToLoginPanel();
   12.71 +        } else {
   12.72 +          char *variableValue;
   12.73 +          if (!(variableValue = malloc(cookieLength + 1))) {
   12.74 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
   12.75 +            RedirectToLoginPanel();
   12.76 +
   12.77 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
   12.78 +          } else {
   12.79 +
   12.80 +            /* PROCESS COOKIE DATA */
   12.81 +            char *login, *password;
   12.82 +            INT c, i;
   12.83 +            login = password = NULL;
   12.84 +            c = 0;
   12.85 +            strcpy(cookie, getenv("HTTP_COOKIE"));
   12.86 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
   12.87 +              i = 0;
   12.88 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
   12.89 +                variableName[i] = cookie[c];
   12.90 +                ++c;
   12.91 +                ++i;
   12.92 +              }
   12.93 +              variableName[i] = '\0';
   12.94 +              ++c;
   12.95 +              i = 0;
   12.96 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
   12.97 +                variableValue[i] = cookie[c];
   12.98 +                ++c;
   12.99 +                ++i;
  12.100 +              }
  12.101 +              variableValue[i] = '\0';
  12.102 +              ++c;
  12.103 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
  12.104 +                ++c;
  12.105 +              }
  12.106 +              if (!login && !strcmp(variableName, "login")) {
  12.107 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
  12.108 +                  strcpy(login, variableValue);
  12.109 +                }
  12.110 +              } else if (!password && !strcmp(variableName, "password")) {
  12.111 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
  12.112 +                  strcpy(password, variableValue);
  12.113 +                }
  12.114 +              }
  12.115 +            }
  12.116 +
  12.117 +            /* IF LOGIN VALUE IS MISSING... */
  12.118 +            if (!login) {
  12.119 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
  12.120 +              RedirectToLoginPanel();
  12.121 +
  12.122 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
  12.123 +            } else {
  12.124 +
  12.125 +              /* VERIFY LOGIN AND PASSWORD */
  12.126 +              char *directory;
  12.127 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
  12.128 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
  12.129 +                RedirectToLoginPanel();
  12.130 +              } else {
  12.131 +                char *systemDirectory;
  12.132 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
  12.133 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
  12.134 +                  RedirectToLoginPanel();
  12.135 +                } else {
  12.136 +                  strcpy(directory, DIRECTORY);
  12.137 +                  strcat(directory, login);
  12.138 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
  12.139 +                  strcat(systemDirectory, login);
  12.140 +
  12.141 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
  12.142 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
  12.143 +                    /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
  12.144 +                    RedirectToLoginPanel();
  12.145 +
  12.146 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
  12.147 +                  } else {
  12.148 +
  12.149 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
  12.150 +                    char *passwordFileName;
  12.151 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
  12.152 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
  12.153 +                      RedirectToLoginPanel();
  12.154 +                    } else {
  12.155 +                      strcpy(passwordFileName, systemDirectory);
  12.156 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
  12.157 +
  12.158 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
  12.159 +                      if (access(passwordFileName, F_OK)) {
  12.160 +                        /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
  12.161 +                        RedirectToLoginPanel();
  12.162 +
  12.163 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
  12.164 +                      } else {
  12.165 +
  12.166 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
  12.167 +                        FILE *passwordFile;
  12.168 +
  12.169 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
  12.170 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
  12.171 +                          /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
  12.172 +                          RedirectToLoginPanel();
  12.173 +
  12.174 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
  12.175 +                        } else {
  12.176 +                          char *filePassword;
  12.177 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
  12.178 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
  12.179 +                            RedirectToLoginPanel();
  12.180 +                          } else {
  12.181 +                            char c;
  12.182 +                            i = 0;
  12.183 +
  12.184 +                            /* READ PASSWORD FROM PASSWORD FILE */
  12.185 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
  12.186 +                              filePassword[i] = c;
  12.187 +                              ++i;
  12.188 +                            }
  12.189 +                            filePassword[i] = '\0';
  12.190 +                            fclose(passwordFile);
  12.191 +
  12.192 +                            /* IF PASSWORD FAILS COMPARISON... */
  12.193 +                            if (strcmp(filePassword, password)) {
  12.194 +                              /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
  12.195 +                              RedirectToLoginPanel();
  12.196 +
  12.197 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
  12.198 +                            } else {
  12.199 +
  12.200 +                              /* LOAD SETTINGS VALUES FROM FILE(S) */
  12.201 +
  12.202 +                              /* LOAD MENU ITEMS FROM FILES */
  12.203 +
  12.204 +                              /* READ NEW MENU FILE */
  12.205 +
  12.206 +                              /* READ OPEN MENU FILE */
  12.207 +
  12.208 +                              /* READ NEXT MENU FILE */
  12.209 +
  12.210 +                              /* READ SETTINGS MENU FILE */
  12.211 +
  12.212 +                              /* DECLARE AND INITIALIZE QUERY VARIABLES */
  12.213 +                              char *menu, *new, *open, *next, *settings, *text_file, *status;
  12.214 +                              menu = new = open = next = settings = text_file = status = NULL;
  12.215 +
  12.216 +                              /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
  12.217 +                              if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
  12.218 +                                char *query;
  12.219 +                                INT queryLength = strlen(getenv("QUERY_STRING"));
  12.220 +                                if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
  12.221 +                                  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
  12.222 +                                } else {
  12.223 +                                  free(variableName);
  12.224 +                                  strcpy(query, getenv("QUERY_STRING"));
  12.225 +                                  if (!(variableName = malloc(queryLength + 1))) {
  12.226 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
  12.227 +                                  } else {
  12.228 +                                    free(variableValue);
  12.229 +                                    if (!(variableValue = malloc(queryLength + 1))) {
  12.230 +                                      /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
  12.231 +
  12.232 +                                    /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
  12.233 +                                    } else {
  12.234 +
  12.235 +                                      /* PROCESS QUERY DATA */
  12.236 +                                      INT q = 0;
  12.237 +                                      i = 0;
  12.238 +                                      while ((q < queryLength) && (query[q] != '\0')) {
  12.239 +                                        while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
  12.240 +                                          variableName[i] = query[q];
  12.241 +                                          ++q;
  12.242 +                                          ++i;
  12.243 +                                        }
  12.244 +                                        variableName[i] = '\0';
  12.245 +                                        ++q;
  12.246 +                                        i = 0;
  12.247 +                                        while ((query[q] != '&') && (query[q] != '\0')) {
  12.248 +                                          variableValue[i] = query[q];
  12.249 +                                          ++q;
  12.250 +                                          ++i;
  12.251 +                                        }
  12.252 +                                        variableValue[i] = '\0';
  12.253 +                                        if (query[q] != '\0') {
  12.254 +                                          ++q;
  12.255 +                                        }
  12.256 +                                        if (!menu && !strcmp(variableName, "menu")) {
  12.257 +                                          if ((menu = malloc(strlen(variableValue) + 1)) != 0) {
  12.258 +                                            strcpy(menu, variableValue);
  12.259 +                                          }
  12.260 +                                        } else if (!new && !strcmp(variableName, "new")) {
  12.261 +                                          if ((new = malloc(strlen(variableValue) + 1)) != 0) {
  12.262 +                                            strcpy(new, variableValue);
  12.263 +                                          }
  12.264 +                                        } else if (!open && !strcmp(variableName, "open")) {
  12.265 +                                          if ((open = malloc(strlen(variableValue) + 1)) != 0) {
  12.266 +                                            strcpy(open, variableValue);
  12.267 +                                          }
  12.268 +                                        } else if (!next && !strcmp(variableName, "next")) {
  12.269 +                                          if ((next = malloc(strlen(variableValue) + 1)) != 0) {
  12.270 +                                            strcpy(next, variableValue);
  12.271 +                                          }
  12.272 +                                        } else if (!settings && !strcmp(variableName, "settings")) {
  12.273 +                                          if ((settings = malloc(strlen(variableValue) + 1)) != 0) {
  12.274 +                                            strcpy(settings, variableValue);
  12.275 +                                          }
  12.276 +                                        } else if (!text_file && !strcmp(variableName, "text_file")) {
  12.277 +                                          if ((text_file = malloc(strlen(variableValue) + 1)) != 0) {
  12.278 +                                            strcpy(text_file, variableValue);
  12.279 +                                          }
  12.280 +                                        } else if (!status && !strcmp(variableName, "says")) {
  12.281 +                                          if ((status = malloc(strlen(variableValue) + 1)) != 0) {
  12.282 +                                            strcpy(status, variableValue);
  12.283 +                                          }
  12.284 +                                        }
  12.285 +                                      }
  12.286 +                                      free(variableValue);
  12.287 +                                      variableValue = NULL;
  12.288 +                                    }
  12.289 +                                    free(variableName);
  12.290 +                                    variableName = NULL;
  12.291 +                                  }
  12.292 +                                  free(query);
  12.293 +                                }
  12.294 +                              }
  12.295 +
  12.296 +                              /* IF THIS IS A CONTINUED SESSION... */
  12.297 +
  12.298 +                                /* LOAD SESSION FROM FILE */
  12.299 +
  12.300 +                              /* OUTPUT GUI COMPONENT(S) BASED ON VARIABLES */
  12.301 +                              if (settings) {
  12.302 +                                OutputSettingsMenu(settings);
  12.303 +                              } else if (new) {
  12.304 +                                if (!strcmp(new, "text_file")) {
  12.305 +                                  OutputGUI("new", new);
  12.306 +                                } else {
  12.307 +                                  OutputNewMenu();
  12.308 +                                }
  12.309 +                              } else if (open) {
  12.310 +                                OutputOpenMenu(open);
  12.311 +                              } else if (next) {
  12.312 +                                if (!strcmp(next, "save_as")) {
  12.313 +
  12.314 +                                } else if (!strcmp(next, "save")) {
  12.315 +
  12.316 +                                } else if (!strcmp(next, "close")) {
  12.317 +
  12.318 +                                } else if (!strcmp(next, "bookmark")) {
  12.319 +
  12.320 +                                } else if (!strcmp(next, "logout")) {
  12.321 +
  12.322 +                                  /* SET COOKIES */
  12.323 +                                  printf("Set-Cookie: login=; path=/; secure\r\n");
  12.324 +                                  printf("Set-Cookie: password=; path=/; secure\r\n");
  12.325 +
  12.326 +                                  /* REDIRECT TO LOGIN PANEL */
  12.327 +                                  printf("Location: login\r\n\r\n");
  12.328 +                                } else if (status) {
  12.329 +                                  OutputGUI("status", status);
  12.330 +                                } else {
  12.331 +                                  OutputGUI(NULL, NULL);
  12.332 +                                }
  12.333 +                              } else if (menu) {
  12.334 +                                if (!strcmp(menu, "settings")) {
  12.335 +                                  OutputSettingsMenu(settings);
  12.336 +                                } else if (!strcmp(menu, "new")) {
  12.337 +                                  OutputNewMenu();
  12.338 +                                } else if (!strcmp(menu, "open")) {
  12.339 +                                  OutputOpenMenu(open);
  12.340 +                                } else if (!strcmp(menu, "next")) {
  12.341 +                                  OutputNextMenu(next);
  12.342 +                                } else if (status) {
  12.343 +                                  OutputGUI("status", status);
  12.344 +                                } else {
  12.345 +                                  OutputGUI(NULL, NULL);
  12.346 +                                }
  12.347 +                              } else if (text_file) {
  12.348 +                                OutputGUI("text_file", text_file);
  12.349 +                              } else {
  12.350 +                                if (status) {
  12.351 +                                  OutputGUI("status", status);
  12.352 +                                } else {
  12.353 +                                  OutputGUI(NULL, NULL);
  12.354 +                                }
  12.355 +                              }
  12.356 +                              free(status);
  12.357 +                              free(text_file);
  12.358 +                              free(settings);
  12.359 +                              free(next);
  12.360 +                              free(open);
  12.361 +                              free(new);
  12.362 +                              free(menu);
  12.363 +                            }
  12.364 +                            free(filePassword);
  12.365 +                          }
  12.366 +                        }
  12.367 +                      }
  12.368 +                      free(passwordFileName);
  12.369 +                    }
  12.370 +                  }
  12.371 +                  free(systemDirectory);
  12.372 +                }
  12.373 +                free(directory);
  12.374 +              }
  12.375 +              free(login);
  12.376 +            }
  12.377 +            free(password);
  12.378 +            free(variableValue);
  12.379 +          }
  12.380 +          free(variableName);
  12.381 +        }
  12.382 +        free(cookie);
  12.383 +      }
  12.384 +    }
  12.385 +  }
  12.386 +  return 0;
  12.387 +}
  12.388 +
  12.389 +/* FUNCTION | REDIRECT TO LOGIN PANEL */
  12.390 +static void RedirectToLoginPanel(void) {
  12.391 +  printf("Location: login\r\n\r\n");
  12.392 +}
  12.393 +
  12.394 +/* FUNCTION | OUTPUT XHTML FOR interos GRAPHICAL USER INTERFACE */
  12.395 +static void OutputGUI(const char *variableName, char *variableValue) {
  12.396 +  BeginXHTMLOutput();
  12.397 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  12.398 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  12.399 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  12.400 +  printf("  <!--========================================================-->\n");
  12.401 +  printf("  <!--       interos Standard Document Header - Markup        -->\n");
  12.402 +  printf("  <!--========================================================-->\n");
  12.403 +  printf("  <!--    URIs:  https://interos.com/                         -->\n");
  12.404 +  printf("  <!--           https://interos.com/main                     -->\n");
  12.405 +  printf("  <!--           https://www.interos.com/                     -->\n");
  12.406 +  printf("  <!--           https://www.interos.com/main                 -->\n");
  12.407 +  printf("  <!--   Title:  interos                                      -->\n");
  12.408 +  printf("  <!--  Author:  Brent Angeline                               -->\n");
  12.409 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
  12.410 +  printf("  <!--========================================================-->\n");
  12.411 +  printf("  <head>\n");
  12.412 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  12.413 +  printf("    <meta name=\"title\" content=\"interos\" />\n");
  12.414 +  printf("    <meta name=\"description\" content=\"internet operating system\" />\n");
  12.415 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  12.416 +  printf("    <meta name=\"copyright\" \n");
  12.417 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  12.418 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  12.419 +  printf("    <title>interos</title>\n");
  12.420 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  12.421 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  12.422 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  12.423 +  printf("          media=\"screen, projection\" />\n");
  12.424 +  printf("    <script type=\"text/javascript\" src=\"/js/interos.js\"></script>\n");
  12.425 +  printf("  </head>\n");
  12.426 +  printf("  <frameset rows=\"72,*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  12.427 +  printf("    <frame name=\"top\" src=\"/top\" \n");
  12.428 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.429 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.430 +  if (variableName && variableValue) {
  12.431 +    printf("    <frame name=\"content\" src=\"/content?%s=%s\" \n", variableName, variableValue);
  12.432 +    printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.433 +    printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.434 +  } else {
  12.435 +    printf("    <frame name=\"content\" src=\"/content\" \n");
  12.436 +    printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.437 +    printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.438 +  }
  12.439 +  printf("    <frame name=\"bottom\" src=\"/bottom\" \n");
  12.440 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.441 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.442 +  printf("    <noframes>\n");
  12.443 +  printf("      <body id=\"body\">\n");
  12.444 +  printf("        <h3>\n");
  12.445 +  printf("          menu\n");
  12.446 +  printf("        </h3>\n");
  12.447 +  printf("        <p>\n");
  12.448 +  printf("          <a id=\"newLink\" href=\"/main?menu=new\">new</a>\n");
  12.449 +  printf("        </p>\n");
  12.450 +  printf("        <p>\n");
  12.451 +  printf("          <a id=\"openLink\" href=\"/main?menu=open\">open</a>\n");
  12.452 +  printf("        </p>\n");
  12.453 +  printf("        <p>\n");
  12.454 +  printf("          <a id=\"nextLink\" href=\"/main?menu=next\">next</a>\n");
  12.455 +  printf("        </p>\n");
  12.456 +  printf("        <p>\n");
  12.457 +  printf("          <a id=\"settingsLink\" href=\"/main?menu=settings\">settings</a>");
  12.458 +  printf("        </p>\n");
  12.459 +  printf("      </body>\n");
  12.460 +  printf("    </noframes>\n");
  12.461 +  printf("  </frameset>\n");
  12.462 +  FinishXHTMLOutput();
  12.463 +}
  12.464 +
  12.465 +/* FUNCTION | OUTPUT XHTML FOR NEW MENU */
  12.466 +static void OutputNewMenu(void) {
  12.467 +  BeginXHTMLOutput();
  12.468 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  12.469 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  12.470 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  12.471 +  printf("  <!--========================================================-->\n");
  12.472 +  printf("  <!--       interos Standard Document Header - Markup        -->\n");
  12.473 +  printf("  <!--========================================================-->\n");
  12.474 +  printf("  <!--    URIs:  https://interos.com/main?menu=new            -->\n");
  12.475 +  printf("  <!--           https://interos.com/interos?menu=new         -->\n");
  12.476 +  printf("  <!--           https://www.interos.com/main?menu=new        -->\n");
  12.477 +  printf("  <!--           https://www.interos.com/interos?menu=new     -->\n");
  12.478 +  printf("  <!--   Title:  interos new                                  -->\n");
  12.479 +  printf("  <!--  Author:  Brent Angeline                               -->\n");
  12.480 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
  12.481 +  printf("  <!--========================================================-->\n");
  12.482 +  printf("  <head>\n");
  12.483 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  12.484 +  printf("    <meta name=\"title\" content=\"interos new\" />\n");
  12.485 +  printf("    <meta name=\"description\" content=\"new menu for interos\" />\n");
  12.486 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  12.487 +  printf("    <meta name=\"copyright\" \n");
  12.488 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  12.489 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  12.490 +  printf("    <title>interos new</title>\n");
  12.491 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  12.492 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  12.493 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  12.494 +  printf("          media=\"screen, projection\" />\n");
  12.495 +  printf("    <script type=\"text/javascript\" src=\"/js/interos_new.js\"></script>\n");
  12.496 +  printf("  </head>\n");
  12.497 +  printf("  <frameset rows=\"*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  12.498 +  printf("    <frame name=\"menu\" src=\"/menu?name=new\" \n");
  12.499 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.500 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.501 +  printf("    <frame name=\"button\" src=\"/bottom?button=new\" \n");
  12.502 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.503 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.504 +  printf("    <noframes>\n");
  12.505 +  printf("      <body id=\"body\">\n");
  12.506 +  printf("        <div id=\"newEntries\">\n");
  12.507 +  printf("          <p>\n");
  12.508 +  printf("            <a href=\"/main?new=text_file\">text file</a>\n");
  12.509 +  printf("          </p>\n");
  12.510 +  printf("        </div>\n");
  12.511 +  printf("        <div id=\"newLink\"><a href=\"/main\">new</a></div>\n");
  12.512 +  printf("      </body>\n");
  12.513 +  printf("    </noframes>\n");
  12.514 +  printf("  </frameset>\n");
  12.515 +  FinishXHTMLOutput();
  12.516 +}
  12.517 +
  12.518 +/* FUNCTION | OUTPUT XHTML FOR OPEN MENU */
  12.519 +static void OutputOpenMenu(char *open) {
  12.520 +  BeginXHTMLOutput();
  12.521 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  12.522 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  12.523 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  12.524 +  printf("  <!--========================================================-->\n");
  12.525 +  printf("  <!--       interos Standard Document Header - Markup        -->\n");
  12.526 +  printf("  <!--========================================================-->\n");
  12.527 +  printf("  <!--    URIs:  https://interos.com/main?menu=open           -->\n");
  12.528 +  printf("  <!--           https://interos.com/interos?menu=open        -->\n");
  12.529 +  printf("  <!--           https://www.interos.com/main?menu=open       -->\n");
  12.530 +  printf("  <!--           https://www.interos.com/interos?menu=open    -->\n");
  12.531 +  printf("  <!--   Title:  interos open                                 -->\n");
  12.532 +  printf("  <!--  Author:  Brent Angeline                               -->\n");
  12.533 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
  12.534 +  printf("  <!--========================================================-->\n");
  12.535 +  printf("  <head>\n");
  12.536 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  12.537 +  printf("    <meta name=\"title\" content=\"interos open\" />\n");
  12.538 +  printf("    <meta name=\"description\" content=\"open menu for interos\" />\n");
  12.539 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  12.540 +  printf("    <meta name=\"copyright\" \n");
  12.541 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  12.542 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  12.543 +  printf("    <title>interos open</title>\n");
  12.544 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  12.545 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  12.546 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  12.547 +  printf("          media=\"screen, projection\" />\n");
  12.548 +  printf("    <script type=\"text/javascript\" src=\"/js/interos_open.js\"></script>\n");
  12.549 +  printf("  </head>\n");
  12.550 +  printf("  <frameset rows=\"72,*\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  12.551 +  printf("    <frame name=\"button\" src=\"/top?button=open\" \n");
  12.552 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.553 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.554 +  if (open) {
  12.555 +    if (!strcmp(open, "text_file")) {
  12.556 +      printf("    <frame name=\"menu\" src=\"/menu?open=text_file\" \n");
  12.557 +      printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.558 +      printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.559 +    } else {
  12.560 +      printf("    <frame name=\"menu\" src=\"/menu?name=open\" \n");
  12.561 +      printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.562 +      printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.563 +    }
  12.564 +  } else {
  12.565 +    printf("    <frame name=\"menu\" src=\"/menu?name=open\" \n");
  12.566 +    printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.567 +    printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.568 +  }
  12.569 +  printf("    <noframes>\n");
  12.570 +  printf("      <body id=\"body\">\n");
  12.571 +  printf("        <div id=\"openLink\"><a href=\"/main\">open</a></div>\n");
  12.572 +  printf("        <div id=\"openEntries\">\n");
  12.573 +  printf("          <p><a href=\"/main?open=text_file\">text file</a></p>\n");
  12.574 +  printf("        </div>\n");
  12.575 +  printf("      </body>\n");
  12.576 +  printf("    </noframes>\n");
  12.577 +  printf("  </frameset>\n");
  12.578 +  FinishXHTMLOutput();
  12.579 +}
  12.580 +
  12.581 +/* FUNCTION | OUTPUT XHTML FOR NEXT MENU */
  12.582 +static void OutputNextMenu(char *next) {
  12.583 +  BeginXHTMLOutput();
  12.584 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  12.585 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  12.586 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  12.587 +  printf("  <!--========================================================-->\n");
  12.588 +  printf("  <!--       interos Standard Document Header - Markup        -->\n");
  12.589 +  printf("  <!--========================================================-->\n");
  12.590 +  printf("  <!--    URIs:  https://interos.com/main?menu=next           -->\n");
  12.591 +  printf("  <!--           https://interos.com/interos?menu=next        -->\n");
  12.592 +  printf("  <!--           https://www.interos.com/main?menu=next       -->\n");
  12.593 +  printf("  <!--           https://www.interos.com/interos?menu=next    -->\n");
  12.594 +  printf("  <!--   Title:  interos next                                 -->\n");
  12.595 +  printf("  <!--  Author:  Brent Angeline                               -->\n");
  12.596 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
  12.597 +  printf("  <!--========================================================-->\n");
  12.598 +  printf("  <head>\n");
  12.599 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  12.600 +  printf("    <meta name=\"title\" content=\"interos next\" />\n");
  12.601 +  printf("    <meta name=\"description\" content=\"next menu for interos\" />\n");
  12.602 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  12.603 +  printf("    <meta name=\"copyright\" \n");
  12.604 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  12.605 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  12.606 +  printf("    <title>interos next</title>\n");
  12.607 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  12.608 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  12.609 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  12.610 +  printf("          media=\"screen, projection\" />\n");
  12.611 +  printf("    <script type=\"text/javascript\" src=\"/js/interos_next.js\"></script>\n");
  12.612 +  printf("  </head>\n");
  12.613 +  printf("  <frameset rows=\"72,*\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  12.614 +  printf("    <frame name=\"button\" src=\"/top?button=next\" \n");
  12.615 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.616 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.617 +  printf("    <frame name=\"menu\" src=\"/menu?name=next\" \n");
  12.618 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.619 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.620 +  printf("    <noframes>\n");
  12.621 +  printf("      <body id=\"body\">\n");
  12.622 +  printf("        <div id=\"nextLink\"><a href=\"/main\">next</a></div>\n");
  12.623 +  printf("        <div id=\"nextEntries\">\n");
  12.624 +  printf("          <p><a href=\"/logout\">logout</a></p>\n");
  12.625 +  printf("        </div>\n");
  12.626 +  printf("      </body>\n");
  12.627 +  printf("    </noframes>\n");
  12.628 +  printf("  </frameset>\n");
  12.629 +  FinishXHTMLOutput();
  12.630 +}
  12.631 +
  12.632 +/* FUNCTION | OUTPUT XHTML FOR SETTINGS MENU */
  12.633 +void OutputSettingsMenu(char *settings) {
  12.634 +  BeginXHTMLOutput();
  12.635 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  12.636 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  12.637 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  12.638 +  printf("  <!--==========================================================-->\n");
  12.639 +  printf("  <!--        interos Standard Document Header - Markup         -->\n");
  12.640 +  printf("  <!--==========================================================-->\n");
  12.641 +  printf("  <!--    URIs:  https://interos.com/main?menu=settings         -->\n");
  12.642 +  printf("  <!--           https://interos.com/interos?menu=settings      -->\n");
  12.643 +  printf("  <!--           https://www.interos.com/menu?menu=settings     -->\n");
  12.644 +  printf("  <!--           https://www.interos.com/interos?menu=settings  -->\n");
  12.645 +  printf("  <!--   Title:  interos settings                               -->\n");
  12.646 +  printf("  <!--  Author:  Brent Angeline                                 -->\n");
  12.647 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset    -->\n");
  12.648 +  printf("  <!--==========================================================-->\n");
  12.649 +  printf("  <head>\n");
  12.650 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  12.651 +  printf("    <meta name=\"title\" content=\"interos - settings\" />\n");
  12.652 +  printf("    <meta name=\"description\" content=\"interos settings menu\" />\n");
  12.653 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  12.654 +  printf("    <meta name=\"copyright\" \n");
  12.655 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  12.656 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  12.657 +  printf("    <title>interos settings</title>\n");
  12.658 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  12.659 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  12.660 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  12.661 +  printf("          media=\"screen, projection\" />\n");
  12.662 +  printf("    <script type=\"text/javascript\" src=\"/js/interos_settings.js\"></script>\n");
  12.663 +  printf("  </head>\n");
  12.664 +  printf("  <frameset rows=\"*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  12.665 +  printf("    <frame name=\"menu\" src=\"/menu?name=settings\" \n");
  12.666 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.667 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.668 +  printf("    <frame name=\"button\" src=\"/bottom?button=settings\" \n");
  12.669 +  printf("           frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" \n");
  12.670 +  printf("           noresize=\"noresize\" scrolling=\"auto\" />\n");
  12.671 +  printf("    <noframes>\n");
  12.672 +  printf("      <body id=\"body\">\n");
  12.673 +  printf("        <div id=\"settingsEntries\">\n");
  12.674 +  printf("          <p><a href=\"/main?settings=button_size\">button size</a></p>\n");
  12.675 +  printf("        </div>\n");
  12.676 +  printf("        <div id=\"settingsLink\"><a href=\"/main\">settings</a></div>\n");
  12.677 +  printf("      </body>\n");
  12.678 +  printf("    </noframes>\n");
  12.679 +  printf("  </frameset>\n");
  12.680 +  FinishXHTMLOutput();
  12.681 +}
  12.682 +
  12.683 +static void BeginXHTMLOutput(void) {
  12.684 +  printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
  12.685 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
  12.686 +}
  12.687 +
  12.688 +static void FinishXHTMLOutput(void) {
  12.689 +  printf("  <!--=====================================================================-->\n");
  12.690 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
  12.691 +  printf("  <!--=====================================================================-->\n");
  12.692 +  printf("  <!--                                                                     -->\n");
  12.693 +  printf("  <!--          All original textual and graphical site content:           -->\n");
  12.694 +  printf("  <!--                                                                     -->\n");
  12.695 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
  12.696 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
  12.697 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
  12.698 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
  12.699 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
  12.700 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
  12.701 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
  12.702 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
  12.703 +  printf("  <!--                                                                     -->\n");
  12.704 +  printf("  <!--=====================================================================-->\n");
  12.705 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
  12.706 +  printf("  <!--=====================================================================-->\n");
  12.707 +  printf("</html>");
  12.708 +}
  12.709 +
  12.710 +/***********************************************************************/
  12.711 +/*                  Copyright and Trademark Statement                  */
  12.712 +/***********************************************************************/
  12.713 +/*                                                                     */
  12.714 +/*          All original textual and graphical site content:           */
  12.715 +/*                                                                     */
  12.716 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
  12.717 +/*  reserved.  Reproduction in whole or in part without written        */
  12.718 +/*  permission is prohibited.  interos and the interos logos are       */
  12.719 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
  12.720 +/*  product, and service names mentioned herein may be the properties  */
  12.721 +/*  of their respective owners.  Comments in the interos.org forums    */
  12.722 +/*  are the properties of their respective authors.  All software      */
  12.723 +/*  developed in the forums is open source and belongs to everyone.    */
  12.724 +/*                                                                     */
  12.725 +/***********************************************************************/
  12.726 +/*                      e-mail: info@interos.com                       */
  12.727 +/***********************************************************************/
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/c/menu_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
    13.3 @@ -0,0 +1,812 @@
    13.4 +/*************************************************/
    13.5 +/*  interos Standard Document Header - CGI in C  */
    13.6 +/*************************************************/
    13.7 +/*         URIs:  https://interos.com/menu       */
    13.8 +/*                https://www.interos.com/menu   */
    13.9 +/*       Source:  menu.c                         */
   13.10 +/*  Description:  FastCGI for interos menu       */
   13.11 +/*       Author:  Brent Angeline                 */
   13.12 +/*          CGI:  FastCGI in ISO/ANSI C          */
   13.13 +/*************************************************/
   13.14 +
   13.15 +/* PREPROCESSOR DIRECTIVES */
   13.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), printf()                                 */
   13.17 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, MENU_ITEM, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
   13.18 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                                          */
   13.19 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                              */
   13.20 +#include <unistd.h>         /*  F_OK, access()                                                                      */
   13.21 +
   13.22 +#ifndef INTEROS_H
   13.23 +
   13.24 +  /* TYPE DEFINITION */
   13.25 +  typedef struct {
   13.26 +    char *name;
   13.27 +    char *link;
   13.28 +    char *icon;
   13.29 +    struct MENU_ITEM *next;
   13.30 +  } MENU_ITEM;
   13.31 +
   13.32 +#endif
   13.33 +
   13.34 +/* FUNCTION PROTOTYPE DECLARATIONS */
   13.35 +static void RedirectToLoginPanel(void);
   13.36 +static void OutputNewMenu(void);
   13.37 +static void OutputOpenMenu(char *open);
   13.38 +static void OutputNextMenu(char *next);
   13.39 +static void OutputSettingsMenu(char *settings);
   13.40 +static void BeginXHTMLOutput(void);
   13.41 +static void FinishXHTMLOutput(void);
   13.42 +
   13.43 +/* BEGIN MAIN PROGRAM */
   13.44 +int main(void) {
   13.45 +
   13.46 +  /* BEGIN FASTCGI */
   13.47 +  while (FCGI_Accept() >= 0) {
   13.48 +
   13.49 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
   13.50 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
   13.51 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
   13.52 +      RedirectToLoginPanel();
   13.53 +
   13.54 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
   13.55 +    } else {
   13.56 +
   13.57 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
   13.58 +      char *cookie;
   13.59 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
   13.60 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
   13.61 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
   13.62 +        RedirectToLoginPanel();
   13.63 +      } else {
   13.64 +        char *variableName;
   13.65 +        if (!(variableName = malloc(cookieLength + 1))) {
   13.66 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
   13.67 +          RedirectToLoginPanel();
   13.68 +        } else {
   13.69 +          char *variableValue;
   13.70 +          if (!(variableValue = malloc(cookieLength + 1))) {
   13.71 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
   13.72 +            RedirectToLoginPanel();
   13.73 +
   13.74 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
   13.75 +          } else {
   13.76 +
   13.77 +            /* PROCESS COOKIE DATA */
   13.78 +            char *login, *password;
   13.79 +            INT c, i;
   13.80 +            login = password = NULL;
   13.81 +            c = 0;
   13.82 +            strcpy(cookie, getenv("HTTP_COOKIE"));
   13.83 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
   13.84 +              i = 0;
   13.85 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
   13.86 +                variableName[i] = cookie[c];
   13.87 +                ++c;
   13.88 +                ++i;
   13.89 +              }
   13.90 +              variableName[i] = '\0';
   13.91 +              ++c;
   13.92 +              i = 0;
   13.93 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
   13.94 +                variableValue[i] = cookie[c];
   13.95 +                ++c;
   13.96 +                ++i;
   13.97 +              }
   13.98 +              variableValue[i] = '\0';
   13.99 +              ++c;
  13.100 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
  13.101 +                ++c;
  13.102 +              }
  13.103 +              if (!login && !strcmp(variableName, "login")) {
  13.104 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
  13.105 +                  strcpy(login, variableValue);
  13.106 +                }
  13.107 +              } else if (!password && !strcmp(variableName, "password")) {
  13.108 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
  13.109 +                  strcpy(password, variableValue);
  13.110 +                }
  13.111 +              }
  13.112 +            }
  13.113 +
  13.114 +            /* IF LOGIN VALUE IS MISSING... */
  13.115 +            if (!login) {
  13.116 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
  13.117 +              RedirectToLoginPanel();
  13.118 +
  13.119 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
  13.120 +            } else {
  13.121 +
  13.122 +              /* VERIFY LOGIN AND PASSWORD */
  13.123 +              char *directory;
  13.124 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
  13.125 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
  13.126 +                RedirectToLoginPanel();
  13.127 +              } else {
  13.128 +                char *systemDirectory;
  13.129 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
  13.130 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
  13.131 +                  RedirectToLoginPanel();
  13.132 +                } else {
  13.133 +                  strcpy(directory, DIRECTORY);
  13.134 +                  strcat(directory, login);
  13.135 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
  13.136 +                  strcat(systemDirectory, login);
  13.137 +
  13.138 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
  13.139 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
  13.140 +                    /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
  13.141 +                    RedirectToLoginPanel();
  13.142 +
  13.143 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
  13.144 +                  } else {
  13.145 +
  13.146 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
  13.147 +                    char *passwordFileName;
  13.148 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 11))) {
  13.149 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
  13.150 +                      RedirectToLoginPanel();
  13.151 +                    } else {
  13.152 +                      strcpy(passwordFileName, systemDirectory);
  13.153 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
  13.154 +
  13.155 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
  13.156 +                      if (access(passwordFileName, F_OK)) {
  13.157 +                        /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
  13.158 +                        RedirectToLoginPanel();
  13.159 +
  13.160 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
  13.161 +                      } else {
  13.162 +
  13.163 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
  13.164 +                        FILE *passwordFile;
  13.165 +
  13.166 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
  13.167 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
  13.168 +                          /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
  13.169 +                          RedirectToLoginPanel();
  13.170 +
  13.171 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
  13.172 +                        } else {
  13.173 +                          char *filePassword;
  13.174 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
  13.175 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
  13.176 +                            RedirectToLoginPanel();
  13.177 +                          } else {
  13.178 +                            char c;
  13.179 +                            i = 0;
  13.180 +
  13.181 +                            /* READ PASSWORD FROM PASSWORD FILE */
  13.182 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
  13.183 +                              filePassword[i] = c;
  13.184 +                              ++i;
  13.185 +                            }
  13.186 +                            filePassword[i] = '\0';
  13.187 +                            fclose(passwordFile);
  13.188 +
  13.189 +                            /* IF PASSWORD FAILS COMPARISON... */
  13.190 +                            if (strcmp(filePassword, password)) {
  13.191 +                              /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
  13.192 +                              RedirectToLoginPanel();
  13.193 +
  13.194 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
  13.195 +                            } else {
  13.196 +
  13.197 +                              /* LOAD SETTINGS VALUES FROM FILES */
  13.198 +
  13.199 +                              /* LOAD COMPONENTS FROM FILES */
  13.200 +
  13.201 +                              /* DECLARE AND INITIALIZE QUERY VARIABLES */
  13.202 +                              char *name, *open;
  13.203 +                              name = open = NULL;
  13.204 +
  13.205 +                              /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
  13.206 +                              if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
  13.207 +                                char *query;
  13.208 +                                INT queryLength = strlen(getenv("QUERY_STRING"));
  13.209 +                                if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
  13.210 +                                  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
  13.211 +                                } else {
  13.212 +                                  strcpy(query, getenv("QUERY_STRING"));
  13.213 +                                  free(variableName);
  13.214 +                                  if (!(variableName = malloc(queryLength + 1))) {
  13.215 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
  13.216 +                                  } else {
  13.217 +                                    free(variableValue);
  13.218 +                                    if (!(variableValue = malloc(queryLength + 1))) {
  13.219 +                                      /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
  13.220 +
  13.221 +                                    /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
  13.222 +                                    } else {
  13.223 +
  13.224 +                                      /* PROCESS QUERY DATA */
  13.225 +                                      INT q = 0;
  13.226 +                                      i = 0;
  13.227 +                                      while ((q < queryLength) && (query[q] != '\0')) {
  13.228 +                                        while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
  13.229 +                                          variableName[i] = query[q];
  13.230 +                                          ++q;
  13.231 +                                          ++i;
  13.232 +                                        }
  13.233 +                                        variableName[i] = '\0';
  13.234 +                                        ++q;
  13.235 +                                        i = 0;
  13.236 +                                        while ((query[q] != '&') && (query[q] != '\0')) {
  13.237 +                                          variableValue[i] = query[q];
  13.238 +                                          ++q;
  13.239 +                                          ++i;
  13.240 +                                        }
  13.241 +                                        variableValue[i] = '\0';
  13.242 +                                        if (query[q] != '\0') {
  13.243 +                                          ++q;
  13.244 +                                        }
  13.245 +                                        if (!name && !strcmp(variableName, "name")) {
  13.246 +                                          if ((name = malloc(strlen(variableValue) + 1)) != 0) {
  13.247 +                                            strcpy(name, variableValue);
  13.248 +                                          }
  13.249 +                                        } else if (!open && !strcmp(variableName, "open")) {
  13.250 +                                          if ((open = malloc(strlen(variableValue) + 1)) != 0) {
  13.251 +                                            strcpy(open, variableValue);
  13.252 +                                          }
  13.253 +                                        }
  13.254 +                                      }
  13.255 +                                      free(variableValue);
  13.256 +                                      variableValue = NULL;
  13.257 +                                    }
  13.258 +                                    free(variableName);
  13.259 +                                    variableName = NULL;
  13.260 +                                  }
  13.261 +                                  free(query);
  13.262 +                                }
  13.263 +                              }
  13.264 +
  13.265 +                              /* OUTPUT GUI COMPONENT(S) BASED ON VARIABLES */
  13.266 +                              if (name) {
  13.267 +                                if (!strcmp(name, "settings")) {
  13.268 +                                  OutputSettingsMenu(NULL);
  13.269 +                                } else if (!strcmp(name, "new")) {
  13.270 +                                  OutputNewMenu();
  13.271 +                                } else if (!strcmp(name, "open")) {
  13.272 +                                  OutputOpenMenu(NULL);
  13.273 +                                } else if (!strcmp(name, "next")) {
  13.274 +                                  OutputNextMenu(NULL);
  13.275 +                                } else {
  13.276 +                                  RedirectToLoginPanel();
  13.277 +                                }
  13.278 +                              } else if (open) {
  13.279 +                                if (!strcmp(open, "text_file")) {
  13.280 +                                  OutputOpenMenu(open);
  13.281 +                                } else {
  13.282 +                                  OutputOpenMenu(NULL);
  13.283 +                                }
  13.284 +                              } else {
  13.285 +                                RedirectToLoginPanel();
  13.286 +                              }
  13.287 +                              free(name);
  13.288 +                              free(open);
  13.289 +                            }
  13.290 +                            free(filePassword);
  13.291 +                          }
  13.292 +                        }
  13.293 +                      }
  13.294 +                      free(passwordFileName);
  13.295 +                    }
  13.296 +                  }
  13.297 +                  free(systemDirectory);
  13.298 +                }
  13.299 +                free(directory);
  13.300 +              }
  13.301 +              free(login);
  13.302 +            }
  13.303 +            free(password);
  13.304 +            free(variableValue);
  13.305 +          }
  13.306 +          free(variableName);
  13.307 +        }
  13.308 +        free(cookie);
  13.309 +      }
  13.310 +    }
  13.311 +  }
  13.312 +  return 0;
  13.313 +}
  13.314 +
  13.315 +/* FUNCTION | REDIRECT TO LOGIN PANEL */
  13.316 +static void RedirectToLoginPanel(void) {
  13.317 +  printf("Location: login\r\n\r\n");
  13.318 +}
  13.319 +
  13.320 +static void OutputNewMenu(void) {
  13.321 +  BeginXHTMLOutput();
  13.322 +  printf("      class=\"newMenu\">\n");
  13.323 +  printf("  <!--==================================================-->\n");
  13.324 +  printf("  <!--    interos Standard Document Header - Markup     -->\n");
  13.325 +  printf("  <!--==================================================-->\n");
  13.326 +  printf("  <!--    URIs:  https://interos.com/menu?name=new      -->\n");
  13.327 +  printf("  <!--           https://www.interos.com/menu?name=new  -->\n");
  13.328 +  printf("  <!--   Title:  interos new menu                       -->\n");
  13.329 +  printf("  <!--  Author:  Brent Angeline                         -->\n");
  13.330 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional   -->\n");
  13.331 +  printf("  <!--==================================================-->\n");
  13.332 +  printf("  <head>\n");
  13.333 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  13.334 +  printf("    <meta name=\"title\" content=\"interos new menu\" />\n");
  13.335 +  printf("    <meta name=\"description\" content=\"new menu for interos\" />\n");
  13.336 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  13.337 +  printf("    <meta name=\"copyright\" \n");
  13.338 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  13.339 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  13.340 +  printf("    <title>interos new menu</title>\n");
  13.341 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  13.342 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  13.343 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/menu.css\" \n");
  13.344 +  printf("          media=\"screen, projection\" />\n");
  13.345 +  printf("    <script type=\"text/javascript\" src=\"/js/menu.js\"></script>\n");
  13.346 +  printf("  </head>\n");
  13.347 +  printf("  <body id=\"body\">\n");
  13.348 +  printf("    <center>\n");
  13.349 +  printf("      <div id=\"newMenu\">\n");
  13.350 +  printf("        <div id=\"newMenuContent\">\n");
  13.351 +  printf("          <table>\n");
  13.352 +  printf("            <thead>\n");
  13.353 +  printf("              <tr>\n");
  13.354 +  printf("                <th><h1>new menu</h1></th>\n");
  13.355 +  printf("              </tr>\n");
  13.356 +  printf("            </thead>\n");
  13.357 +  printf("            <tbody>\n");
  13.358 +  printf("              <tr>\n");
  13.359 +  printf("                <td><a href=\"/new?alarm\" target=\"_top\">\n");
  13.360 +  printf("                      <img src=\"/images/icons/new/alarm.png\" \n");
  13.361 +  printf("                           alt=\"alarm\" /><br /><span>alarm</span><br />\n");
  13.362 +  printf("                      <br />\n");
  13.363 +  printf("                    </a></td>\n");
  13.364 +  printf("              </tr>\n");
  13.365 +  printf("              <tr>\n");
  13.366 +  printf("                <td><a href=\"/new?bookmark\" target=\"_top\">\n");
  13.367 +  printf("                     <img src=\"/images/icons/new/bookmark.png\" \n");
  13.368 +  printf("                           alt=\"bookmark\" /><br /><span>bookmark</span><br />\n");
  13.369 +  printf("                      <br />\n");
  13.370 +  printf("                   </a></td>\n");
  13.371 +  printf("              </tr>\n");
  13.372 +  printf("             <tr>\n");
  13.373 +  printf("                <td><a href=\"/new?chat\" target=\"_top\">\n");
  13.374 +  printf("                      <img src=\"/images/icons/new/chat.png\" \n");
  13.375 +  printf("                           alt=\"chat\" /><br /><span>chat</span><br />\n");
  13.376 +  printf("                      <br />\n");
  13.377 +  printf("                    </a></td>\n");
  13.378 +  printf("              </tr>\n");
  13.379 +  printf("              <tr>\n");
  13.380 +  printf("                <td><a href=\"/new?copy\" target=\"_top\">\n");
  13.381 +  printf("                     <img src=\"/images/icons/new/copy.png\" \n");
  13.382 +  printf("                          alt=\"copy\" /><br /><span>copy</span><br />\n");
  13.383 +  printf("                      <br />\n");
  13.384 +  printf("                    </a></td>\n");
  13.385 +  printf("              </tr>\n");
  13.386 +  printf("              <tr>\n");
  13.387 +  printf("                <td><a href=\"/new?document\" target=\"_top\">\n");
  13.388 +  printf("                     <img src=\"/images/icons/new/document.png\" \n");
  13.389 +  printf("                           alt=\"document\" /><br /><span>document</span><br />\n");
  13.390 +  printf("                      <br />\n");
  13.391 +  printf("                    </a></td>\n");
  13.392 +  printf("              </tr>\n");
  13.393 +  printf("              <tr>\n");
  13.394 +  printf("                <td><a href=\"/new?download\" target=\"_top\">\n");
  13.395 +  printf("                      <img src=\"/images/icons/new/download.png\" \n");
  13.396 +  printf("                           alt=\"download\" /><br /><span>download</span><br />\n");
  13.397 +  printf("                      <br />\n");
  13.398 +  printf("                    </a></td>\n");
  13.399 +  printf("              </tr>\n");
  13.400 +  printf("              <tr>\n");
  13.401 +  printf("                <td><a href=\"/new?e-mail\" target=\"_top\">\n");
  13.402 +  printf("                     <img src=\"/images/icons/new/e-mail.png\" \n");
  13.403 +  printf("                          alt=\"e-mail\" /><br /><span>e-mail</span><br />\n");
  13.404 +  printf("                      <br />\n");
  13.405 +  printf("                    </a></td>\n");
  13.406 +  printf("              </tr>\n");
  13.407 +  printf("              <tr>\n");
  13.408 +  printf("                <td><a href=\"/new?folder\" target=\"_top\">\n");
  13.409 +  printf("                      <img src=\"/images/icons/new/folder.png\" \n");
  13.410 +  printf("                          alt=\"folder\" /><br /><span>folder</span><br />\n");
  13.411 +  printf("                      <br />\n");
  13.412 +  printf("                    </a></td>\n");
  13.413 +  printf("              </tr>\n");
  13.414 +  printf("              <tr>\n");
  13.415 +  printf("                <td><a href=\"/new?phone_call\" target=\"_top\">\n");
  13.416 +  printf("                     <img src=\"/images/icons/new/phone_call.png\" \n");
  13.417 +  printf("                          alt=\"phone call\" /><br /><span>phone call</span><br />\n");
  13.418 +  printf("                     <br />\n");
  13.419 +  printf("                   </a></td>\n");
  13.420 +  printf("              </tr>\n");
  13.421 +  printf("              <tr>\n");
  13.422 +  printf("                <td><a href=\"/new?search\" target=\"_top\">\n");
  13.423 +  printf("                      <img src=\"/images/icons/new/search.png\" \n");
  13.424 +  printf("                          alt=\"search\" /><br /><span>search</span><br />\n");
  13.425 +  printf("                     <br />\n");
  13.426 +  printf("                    </a></td>\n");
  13.427 +  printf("             </tr>\n");
  13.428 +  printf("              <tr>\n");
  13.429 +  printf("                <td><a href=\"/new?share\" target=\"_top\">\n");
  13.430 +  printf("                      <img src=\"/images/icons/new/share.png\" \n");
  13.431 +  printf("                           alt=\"share\" /><br /><span>share</span><br />\n");
  13.432 +  printf("                      <br />\n");
  13.433 +  printf("                    </a></td>\n");
  13.434 +  printf("              </tr>\n");
  13.435 +  printf("              <tr>\n");
  13.436 +  printf("               <td><a href=\"/new?text_file\" target=\"_top\">\n");
  13.437 +  printf("                     <img src=\"/images/icons/new/text_file.png\" \n");
  13.438 +  printf("                           alt=\"text file\" /><br /><span>text file</span><br />\n");
  13.439 +  printf("                     <br />\n");
  13.440 +  printf("                   </a></td>\n");
  13.441 +  printf("              </tr>\n");
  13.442 +  printf("              <tr>\n");
  13.443 +  printf("                <td><a href=\"/new?upload\" target=\"_top\">\n");
  13.444 +  printf("                     <img src=\"/images/icons/new/upload.png\" \n");
  13.445 +  printf("                          alt=\"upload\" /><br /><span>upload</span><br />\n");
  13.446 +  printf("                     <br />\n");
  13.447 +  printf("                   </a></td>\n");
  13.448 +  printf("              </tr>\n");
  13.449 +  printf("           </tbody>\n");
  13.450 +  printf("          </table>\n");
  13.451 +  printf("        </div>\n");
  13.452 +  FinishXHTMLOutput();
  13.453 +}
  13.454 +
  13.455 +static void OutputOpenMenu(char *open) {
  13.456 +  BeginXHTMLOutput();
  13.457 +  printf("      class=\"openMenu\">\n");
  13.458 +  printf("  <!--===================================================-->\n");
  13.459 +  printf("  <!--       interos Standard Document Header - Markup   -->\n");
  13.460 +  printf("  <!--===================================================-->\n");
  13.461 +  printf("  <!--    URIs:  https://interos.com/menu?name=open      -->\n");
  13.462 +  printf("  <!--           https://www.interos.com/menu?name=open  -->\n");
  13.463 +  printf("  <!--   Title:  interos open menu                       -->\n");
  13.464 +  printf("  <!--  Author:  Brent Angeline                          -->\n");
  13.465 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional    -->\n");
  13.466 +  printf("  <!--===================================================-->\n");
  13.467 +  printf("  <head>\n");
  13.468 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  13.469 +  printf("    <meta name=\"title\" content=\"interos open menu\" />\n");
  13.470 +  printf("    <meta name=\"description\" content=\"open menu for interos\" />\n");
  13.471 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  13.472 +  printf("    <meta name=\"copyright\" \n");
  13.473 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  13.474 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  13.475 +  printf("    <title>interos - open menu</title>\n");
  13.476 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  13.477 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  13.478 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/menu.css\" \n");
  13.479 +  printf("          media=\"screen, projection\" />\n");
  13.480 +  printf("    <script type=\"text/javascript\" src=\"/js/menu.js\"></script>\n");
  13.481 +  printf("  </head>\n");
  13.482 +  printf("  <body id=\"body\">\n");
  13.483 +  printf("    <center>\n");
  13.484 +  printf("      <div id=\"openMenu\">\n");
  13.485 +  printf("        <div id=\"openMenuContent\">\n");
  13.486 +  printf("          <table>\n");
  13.487 +  printf("            <thead>\n");
  13.488 +  printf("              <tr>\n");
  13.489 +  printf("                <th><h1>open menu</h1></th>\n");
  13.490 +  printf("              </tr>\n");
  13.491 +  printf("            </thead>\n");
  13.492 +  printf("            <tbody>\n");
  13.493 +  printf("              <tr>\n");
  13.494 +  if (open && !strcmp(open, "text_file")) {
  13.495 +    printf("                <td><a href=\"/interos?text_file=empty.txt\" target=\"_top\">\n");
  13.496 +    printf("                      <img src=\"/images/icons/open/text_file.png\" \n");
  13.497 +    printf("                           alt=\"empty.txt\" /><br /><span>empty.txt</span><br />\n");
  13.498 +    printf("                      <br />\n");
  13.499 +    printf("                    </a></td>\n");
  13.500 +  } else {
  13.501 +    printf("                <td><a href=\"/interos?open=alarm\" target=\"_top\">\n");
  13.502 +    printf("                      <img src=\"/images/icons/open/alarm.png\" \n");
  13.503 +    printf("                           alt=\"alarm\" /><br /><span>alarm</span><br />\n");
  13.504 +    printf("                     <br />\n");
  13.505 +    printf("                   </a></td>\n");
  13.506 +    printf("              </tr>\n");
  13.507 +    printf("              <tr>\n");
  13.508 +    printf("                <td><a href=\"/interos?open=bookmark\" target=\"_top\">\n");
  13.509 +    printf("                      <img src=\"/images/icons/open/bookmark.png\" \n");
  13.510 +    printf("                           alt=\"bookmark\" /><br /><span>bookmark</span><br />\n");
  13.511 +    printf("                      <br />\n");
  13.512 +    printf("                    </a></td>\n");
  13.513 +    printf("              </tr>\n");
  13.514 +    printf("              <tr>\n");
  13.515 +    printf("                <td><a href=\"/interos?open=document\" target=\"_top\">\n");
  13.516 +    printf("                      <img src=\"/images/icons/open/document.png\" \n");
  13.517 +    printf("                           alt=\"document\" /><br /><span>document</span><br />\n");
  13.518 +    printf("                      <br />\n");
  13.519 +    printf("                    </a></td>\n");
  13.520 +    printf("              </tr>\n");
  13.521 +    printf("              <tr>\n");
  13.522 +    printf("                <td><a href=\"/interos?open=e-mail\" target=\"_top\">\n");
  13.523 +    printf("                      <img src=\"/images/icons/open/e-mail.png\" \n");
  13.524 +    printf("                           alt=\"e-mail\" /><br /><span>e-mail</span><br />\n");
  13.525 +    printf("                      <br />\n");
  13.526 +    printf("                    </a></td>\n");
  13.527 +    printf("              </tr>\n");
  13.528 +    printf("              <tr>\n");
  13.529 +    printf("                <td><a href=\"/interos?open=image\" target=\"_top\">\n");
  13.530 +    printf("                      <img src=\"/images/icons/open/image.png\" \n");
  13.531 +    printf("                           alt=\"image\" /><br /><span>image</span><br />\n");
  13.532 +    printf("                      <br />\n");
  13.533 +    printf("                   </a></td>\n");
  13.534 +    printf("              </tr>\n");
  13.535 +    printf("              <tr>\n");
  13.536 +    printf("                <td><a href=\"/interos?open=incoming\" target=\"_top\">\n");
  13.537 +    printf("                      <img src=\"/images/icons/open/incoming.png\" \n");
  13.538 +    printf("                           alt=\"incoming\" /><br /><span>incoming</span><br />\n");
  13.539 +    printf("                      <br />\n");
  13.540 +    printf("                    </a></td>\n");
  13.541 +    printf("              </tr>\n");
  13.542 +    printf("              <tr>\n");
  13.543 +    printf("                <td><a href=\"/interos?open=music\" target=\"_top\">\n");
  13.544 +    printf("                      <img src=\"/images/icons/open/music.png\" \n");
  13.545 +    printf("                           alt=\"music\" /><br /><span>music</span><br />\n");
  13.546 +    printf("                     <br />\n");
  13.547 +    printf("                    </a></td>\n");
  13.548 +    printf("              </tr>\n");
  13.549 +    printf("              <tr>\n");
  13.550 +    printf("                <td><a href=\"/interos?open=shared\" target=\"_top\">\n");
  13.551 +    printf("                      <img src=\"/images/icons/open/shared.png\" \n");
  13.552 +    printf("                           alt=\"shared\" /><br /><span>shared</span><br />\n");
  13.553 +    printf("                      <br />\n");
  13.554 +    printf("                    </a></td>\n");
  13.555 +    printf("              </tr>\n");
  13.556 +    printf("              <tr>\n");
  13.557 +    printf("                <td><a href=\"/interos?open=text_file\" target=\"_top\">\n");
  13.558 +    printf("                      <img src=\"/images/icons/open/text_file.png\" \n");
  13.559 +    printf("                           alt=\"text file\" /><br /><span>text file</span><br />\n");
  13.560 +    printf("                      <br />\n");
  13.561 +    printf("                    </a></td>\n");
  13.562 +    printf("              </tr>\n");
  13.563 +    printf("              <tr>\n");
  13.564 +    printf("                <td><a href=\"/interos?open=video\" target=\"_top\">\n");
  13.565 +    printf("                      <img src=\"/images/icons/open/video.png\" \n");
  13.566 +    printf("                           alt=\"video\" /><br /><span>video</span><br />\n");
  13.567 +    printf("                      <br />\n");
  13.568 +    printf("                    </a></td>\n");
  13.569 +  }
  13.570 +  printf("              </tr>\n");
  13.571 +  printf("            </tbody>\n");
  13.572 +  printf("          </table>\n");
  13.573 +  printf("        </center>\n");
  13.574 +  printf("      </div>\n");
  13.575 +  FinishXHTMLOutput();
  13.576 +}
  13.577 +
  13.578 +static void OutputNextMenu(char *next) {
  13.579 +  BeginXHTMLOutput();
  13.580 +  printf("      class=\"nextMenu\">\n");
  13.581 +  printf("  <!--===================================================-->\n");
  13.582 +  printf("  <!--       interos Standard Document Header - Markup   -->\n");
  13.583 +  printf("  <!--===================================================-->\n");
  13.584 +  printf("  <!--    URIs:  https://interos.com/menu?name=next      -->\n");
  13.585 +  printf("  <!--           https://www.interos.com/menu?name=next  -->\n");
  13.586 +  printf("  <!--   Title:  interos next menu                       -->\n");
  13.587 +  printf("  <!--  Author:  Brent Angeline                          -->\n");
  13.588 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional    -->\n");
  13.589 +  printf("  <!--===================================================-->\n");
  13.590 +  printf("  <head>\n");
  13.591 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  13.592 +  printf("    <meta name=\"title\" content=\"interos next menu\" />\n");
  13.593 +  printf("    <meta name=\"description\" content=\"next menu for interos\" />\n");
  13.594 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  13.595 +  printf("    <meta name=\"copyright\" \n");
  13.596 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  13.597 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  13.598 +  printf("    <title>interos next menu</title>\n");
  13.599 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  13.600 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  13.601 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/menu.css\" \n");
  13.602 +  printf("          media=\"screen, projection\" />\n");
  13.603 +  printf("    <script type=\"text/javascript\" src=\"/js/menu.js\"></script>\n");
  13.604 +  printf("  </head>\n");
  13.605 +  printf("  <body id=\"body\">\n");
  13.606 +  printf("    <center>\n");
  13.607 +  printf("      <div id=\"nextMenu\">\n");
  13.608 +  printf("        <div id=\"nextMenuContent\">\n");
  13.609 +  printf("          <table>\n");
  13.610 +  printf("            <thead>\n");
  13.611 +  printf("              <th><h1>next menu</h1></th>\n");
  13.612 +  printf("            </thead>\n");
  13.613 +  printf("            <tbody>\n");
  13.614 +  printf("              <tr>\n");
  13.615 +  printf("                <td><a href=\"/interos?next=bookmark\" target=\"_top\">\n");
  13.616 +  printf("                      <img src=\"/images/icons/next/bookmark.png\" \n");
  13.617 +  printf("                           alt=\"bookmark\" /><br /><span>bookmark</span><br />\n");
  13.618 +  printf("                      <br />\n");
  13.619 +  printf("                    </a></td>\n");
  13.620 +  printf("              </tr>\n");
  13.621 +  printf("              <tr>\n");
  13.622 +  printf("                <td><a href=\"/interos?next=close\" target=\"_top\">\n");
  13.623 +  printf("                      <img src=\"/images/icons/next/close.png\" \n");
  13.624 +  printf("                           alt=\"close\" /><br /><span>close</span><br />\n");
  13.625 +  printf("                      <br />\n");
  13.626 +  printf("                    </a></td>\n");
  13.627 +  printf("              </tr>\n");
  13.628 +  printf("              <tr>\n");
  13.629 +  printf("                <td><a href=\"/logout\" target=\"_top\">\n");
  13.630 +  printf("                      <img src=\"/images/icons/next/logout.png\" \n");
  13.631 +  printf("                           alt=\"logout\" /><br /><span>logout</span><br />\n");
  13.632 +  printf("                      <br />\n");
  13.633 +  printf("                    </a></td>\n");
  13.634 +  printf("              </tr>\n");
  13.635 +  printf("              <tr>\n");
  13.636 +  printf("                <td><a href=\"/interos?next=save\" target=\"_top\">\n");
  13.637 +  printf("                      <img src=\"/images/icons/next/save.png\" \n");
  13.638 +  printf("                           alt=\"save\" /><br /><span>save</span><br />\n");
  13.639 +  printf("                      <br />\n");
  13.640 +  printf("                    </a></td>\n");
  13.641 +  printf("              </tr>\n");
  13.642 +  printf("              <tr>\n");
  13.643 +  printf("                <td><a href=\"/interos?next=save_as\" target=\"_top\">\n");
  13.644 +  printf("                      <img src=\"/images/icons/next/save_as.png\" \n");
  13.645 +  printf("                           alt=\"save as\" /><br /><span>save as</span><br />\n");
  13.646 +  printf("                      <br />\n");
  13.647 +  printf("                    </a></td>\n");
  13.648 +  printf("              </tr>\n");
  13.649 +  printf("            </tbody>\n");
  13.650 +  printf("          </table>\n");
  13.651 +  printf("        </div>\n");
  13.652 +  FinishXHTMLOutput();
  13.653 +}
  13.654 +
  13.655 +static void OutputSettingsMenu(char *settings) {
  13.656 +  BeginXHTMLOutput();
  13.657 +  printf("      class=\"settingsMenu\">\n");
  13.658 +  printf("  <!--=======================================================-->\n");
  13.659 +  printf("  <!--         interos Standard Document Header - Markup     -->\n");
  13.660 +  printf("  <!--=======================================================-->\n");
  13.661 +  printf("  <!--    URIs:  https://interos.com/menu?name=settings      -->\n");
  13.662 +  printf("  <!--           https://www.interos.com/menu?name=settings  -->\n");
  13.663 +  printf("  <!--   Title:  interos settings menu                       -->\n");
  13.664 +  printf("  <!--  Author:  Brent Angeline                              -->\n");
  13.665 +  printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional        -->\n");
  13.666 +  printf("  <!--=======================================================-->\n");
  13.667 +  printf("  <head>\n");
  13.668 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  13.669 +  printf("    <meta name=\"title\" content=\"interos settings menu\" />\n");
  13.670 +  printf("    <meta name=\"description\" content=\"settings menu for interos\" />\n");
  13.671 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  13.672 +  printf("    <meta name=\"copyright\" \n");
  13.673 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  13.674 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  13.675 +  printf("    <title>interos settings menu</title>\n");
  13.676 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  13.677 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  13.678 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/menu.css\" \n");
  13.679 +  printf("          media=\"screen, projection\" />\n");
  13.680 +  printf("    <script type=\"text/javascript\" src=\"/js/menu.js\"></script>\n");
  13.681 +  printf("  </head>\n");
  13.682 +  printf("  <body id=\"body\">\n");
  13.683 +  printf("    <center>\n");
  13.684 +  printf("      <div id=\"settingsMenu\">\n");
  13.685 +  printf("        <div id=\"settingsMenuContent\">\n");
  13.686 +  printf("          <table>\n");
  13.687 +  printf("            <thead>\n");
  13.688 +  printf("              <tr>\n");
  13.689 +  printf("                <th><h1>settings menu</h1></th>\n");
  13.690 +  printf("              </tr>\n");
  13.691 +  printf("            </thead>\n");
  13.692 +  printf("            <tbody>\n");
  13.693 +  printf("              <tr>\n");
  13.694 +  printf("                <td><a href=\"/interos?settings=audio\" target=\"_top\">\n");
  13.695 +  printf("                      <img src=\"/images/icons/settings/audio.png\" \n");
  13.696 +  printf("                           alt=\"audio\" /><br /><span>audio</span><br />\n");
  13.697 +  printf("                      <br />\n");
  13.698 +  printf("                    </a></td>\n");
  13.699 +  printf("              </tr>\n");
  13.700 +  printf("              <tr>\n");
  13.701 +  printf("                <td><a href=\"/interos?settings=buttons\" target=\"_top\">\n");
  13.702 +  printf("                      <img src=\"/images/icons/settings/buttons.png\" \n");
  13.703 +  printf("                           alt=\"buttons\" /><br /><span>buttons</span><br />\n");
  13.704 +  printf("                      <br />\n");
  13.705 +  printf("                    </a></td>\n");
  13.706 +  printf("              </tr>\n");
  13.707 +  printf("              <tr>\n");
  13.708 +  printf("                <td><a href=\"/interos?settings=chat\" target=\"_top\">\n");
  13.709 +  printf("                      <img src=\"/images/icons/settings/chat.png\" \n");
  13.710 +  printf("                           alt=\"chat\" /><br /><span>chat</span><br />\n");
  13.711 +  printf("                      <br />\n");
  13.712 +  printf("                    </a></td>\n");
  13.713 +  printf("              </tr>\n");
  13.714 +  printf("              <tr>\n");
  13.715 +  printf("                <td><a href=\"/interos?settings=clock\" target=\"_top\">\n");
  13.716 +  printf("                      <img src=\"/images/icons/settings/clock.png\" \n");
  13.717 +  printf("                           alt=\"clock\" /><br /><span>clock</span><br />\n");
  13.718 +  printf("                      <br />\n");
  13.719 +  printf("                    </a></td>\n");
  13.720 +  printf("              </tr>\n");
  13.721 +  printf("              <tr>\n");
  13.722 +  printf("                <td><a href=\"/interos?settings=e-mail\" target=\"_top\">\n");
  13.723 +  printf("                      <img src=\"/images/icons/settings/e-mail.png\" \n");
  13.724 +  printf("                           alt=\"e-mail\" /><br /><span>e-mail</span><br />\n");
  13.725 +  printf("                      <br />\n");
  13.726 +  printf("                    </a></td>\n");
  13.727 +  printf("              </tr>\n");
  13.728 +  printf("              <tr>\n");
  13.729 +  printf("                <td><a href=\"/interos?settings=images\" target=\"_top\">\n");
  13.730 +  printf("                      <img src=\"/images/icons/settings/images.png\" \n");
  13.731 +  printf("                           alt=\"images\" /><br /><span>images</span><br />\n");
  13.732 +  printf("                      <br />\n");
  13.733 +  printf("                    </a></td>\n");
  13.734 +  printf("              </tr>\n");
  13.735 +  printf("              <tr>\n");
  13.736 +  printf("                <td><a href=\"/interos?settings=phone\" target=\"_top\">\n");
  13.737 +  printf("                      <img src=\"/images/icons/settings/phone.png\" \n");
  13.738 +  printf("                           alt=\"phone\" /><br /><span>phone</span><br />\n");
  13.739 +  printf("                      <br />\n");
  13.740 +  printf("                    </a></td>\n");
  13.741 +  printf("              </tr>\n");
  13.742 +  printf("              <tr>\n");
  13.743 +  printf("                <td><a href=\"/interos?settings=search\" target=\"_top\">\n");
  13.744 +  printf("                      <img src=\"/images/icons/settings/search.png\" \n");
  13.745 +  printf("                           alt=\"search\" /><br /><span>search</span><br />\n");
  13.746 +  printf("                      <br />\n");
  13.747 +  printf("                    </a></td>\n");
  13.748 +  printf("              </tr>\n");
  13.749 +  printf("              <tr>\n");
  13.750 +  printf("                <td><a href=\"/interos?settings=video\" target=\"_top\">\n");
  13.751 +  printf("                      <img src=\"/images/icons/settings/video.png\" \n");
  13.752 +  printf("                           alt=\"video\" /><br /><span>video</span><br />\n");
  13.753 +  printf("                      <br />\n");
  13.754 +  printf("                    </a></td>\n");
  13.755 +  printf("              </tr>\n");
  13.756 +  printf("          </tbody>\n");
  13.757 +  printf("        </table>\n");
  13.758 +  printf("      </div>\n");
  13.759 +  FinishXHTMLOutput();
  13.760 +}
  13.761 +
  13.762 +/* FUNCTION | BEGIN XHTML OUTPUT */
  13.763 +static void BeginXHTMLOutput(void) {
  13.764 +  printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
  13.765 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
  13.766 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/menu.css\"?>\n");
  13.767 +  printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n");
  13.768 +  printf("                      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
  13.769 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\" \n");
  13.770 +}
  13.771 +
  13.772 +/* FUNCTION | FINISH XHTML OUTPUT */
  13.773 +static void FinishXHTMLOutput(void) {
  13.774 +  printf("      </div>\n");
  13.775 +  printf("    </center>\n");
  13.776 +  printf("  </body>\n");
  13.777 +  printf("  <!--=====================================================================-->\n");
  13.778 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
  13.779 +  printf("  <!--=====================================================================-->\n");
  13.780 +  printf("  <!--                                                                     -->\n");
  13.781 +  printf("  <!--          All original textual and graphical site content:           -->\n");
  13.782 +  printf("  <!--                                                                     -->\n");
  13.783 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
  13.784 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
  13.785 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
  13.786 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
  13.787 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
  13.788 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
  13.789 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
  13.790 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
  13.791 +  printf("  <!--                                                                     -->\n");
  13.792 +  printf("  <!--=====================================================================-->\n");
  13.793 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
  13.794 +  printf("  <!--=====================================================================-->\n");
  13.795 +  printf("</html>");
  13.796 +}
  13.797 +
  13.798 +/***********************************************************************/
  13.799 +/*                  Copyright and Trademark Statement                  */
  13.800 +/***********************************************************************/
  13.801 +/*                                                                     */
  13.802 +/*          All original textual and graphical site content:           */
  13.803 +/*                                                                     */
  13.804 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
  13.805 +/*  reserved.  Reproduction in whole or in part without written        */
  13.806 +/*  permission is prohibited.  interos and the interos logos are       */
  13.807 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
  13.808 +/*  product, and service names mentioned herein may be the properties  */
  13.809 +/*  of their respective owners.  Comments in the interos.org forums    */
  13.810 +/*  are the properties of their respective authors.  All software      */
  13.811 +/*  developed in the forums is open source and belongs to everyone.    */
  13.812 +/*                                                                     */
  13.813 +/***********************************************************************/
  13.814 +/*                      e-mail: info@interos.com                       */
  13.815 +/***********************************************************************/
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/c/new_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
    14.3 @@ -0,0 +1,452 @@
    14.4 +/*************************************************/
    14.5 +/*  interos Standard Document Header - CGI in C  */
    14.6 +/*************************************************/
    14.7 +/*         URIs:  https://interos.com/new        */
    14.8 +/*                https://www.interos.com/new    */
    14.9 +/*       Source:  new.c                          */
   14.10 +/*  Description:  FastCGI for interos new menu   */
   14.11 +/*       Author:  Brent Angeline                 */
   14.12 +/*          CGI:  FastCGI in ISO/ANSI C          */
   14.13 +/*************************************************/
   14.14 +
   14.15 +/* PREPROCESSOR DIRECTIVES */
   14.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fclose(), fgetc(), fopen(), printf()                                 */
   14.17 +#include "interos.h"        /*  DIRECTORY, INT, MAX_PASSWORD_SIZE, MENU_ITEM, PASSWORD_FILE_NAME, SYSTEM_DIRECTORY  */
   14.18 +#include <stdlib.h>         /*  free(), getenv(), malloc()                                                          */
   14.19 +#include <string.h>         /*  strcat(), strcmp(), strcpy, strlen()                                                */
   14.20 +#include <unistd.h>         /*  F_OK, access()                                                                      */
   14.21 +
   14.22 +#ifndef INTEROS_H
   14.23 +
   14.24 +  /* TYPE DEFINITION */
   14.25 +  typedef struct {
   14.26 +    char *name;
   14.27 +    char *link;
   14.28 +    char *icon;
   14.29 +    struct MENU_ITEM *next;
   14.30 +  } MENU_ITEM;
   14.31 +
   14.32 +#endif
   14.33 +
   14.34 +/* FUNCTION PROTOTYPE DECLARATIONS */
   14.35 +static void RedirectToLoginPanel(void);
   14.36 +static void OutputNewMenu(void);
   14.37 +static void OutputGUI(const char *variableName, const char *variableValue);
   14.38 +static void BeginXHTMLOutput(void);
   14.39 +static void FinishXHTMLOutput(void);
   14.40 +
   14.41 +/* BEGIN MAIN PROGRAM */
   14.42 +int main(void) {
   14.43 +
   14.44 +  /* BEGIN FASTCGI */
   14.45 +  while (FCGI_Accept() >= 0) {
   14.46 +
   14.47 +    /* IF COOKIE DATA DOESN'T EXIST OR IS TOO LONG... */
   14.48 +    if (!getenv("HTTP_COOKIE") || (sizeof(strlen(getenv("HTTP_COOKIE"))) > sizeof(INT))) {
   14.49 +      /** ERROR | COOKIE DATA DOES NOT EXIST OR IS TOO LONG > REDIRECT TO LOGIN PANEL **/
   14.50 +      RedirectToLoginPanel();
   14.51 +
   14.52 +    /* OTHERWISE, IF COOKIE DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
   14.53 +    } else {
   14.54 +
   14.55 +      /* ATTEMPT TO ALLOCATE MEMORY FOR COOKIE VARIABLES */
   14.56 +      char *cookie;
   14.57 +      INT cookieLength = strlen(getenv("HTTP_COOKIE"));
   14.58 +      if ((cookieLength < 1) || !(cookie = malloc(cookieLength + 1))) {
   14.59 +        /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR COOKIE DATA! > REDIRECT TO LOGIN PANEL **/
   14.60 +        RedirectToLoginPanel();
   14.61 +      } else {
   14.62 +        char *variableName;
   14.63 +        if (!(variableName = malloc(cookieLength + 1))) {
   14.64 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE NAME > REDIRECT TO LOGIN PANEL **/
   14.65 +          RedirectToLoginPanel();
   14.66 +        } else {
   14.67 +          char *variableValue;
   14.68 +          if (!(variableValue = malloc(cookieLength + 1))) {
   14.69 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR COOKIE VARIABLE VALUE > REDIRECT TO LOGIN PANEL **/
   14.70 +            RedirectToLoginPanel();
   14.71 +
   14.72 +          /* IF SUFFICIENT MEMORY FOR COOKIE VARIABLES... */
   14.73 +          } else {
   14.74 +
   14.75 +            /* PROCESS COOKIE DATA */
   14.76 +            char *login, *password;
   14.77 +            INT c, i;
   14.78 +            login = password = NULL;
   14.79 +            c = 0;
   14.80 +            strcpy(cookie, getenv("HTTP_COOKIE"));
   14.81 +            while ((c < cookieLength) && (cookie[c] != '\0')) {
   14.82 +              i = 0;
   14.83 +              while ((c < cookieLength) && (cookie[c] != '=') && (cookie[c] != '\0')) {
   14.84 +                variableName[i] = cookie[c];
   14.85 +                ++c;
   14.86 +                ++i;
   14.87 +              }
   14.88 +              variableName[i] = '\0';
   14.89 +              ++c;
   14.90 +              i = 0;
   14.91 +              while ((c < cookieLength) && (cookie[c] != ';') && (cookie[c] != '\0')) {
   14.92 +                variableValue[i] = cookie[c];
   14.93 +                ++c;
   14.94 +                ++i;
   14.95 +              }
   14.96 +              variableValue[i] = '\0';
   14.97 +              ++c;
   14.98 +              while ((c < cookieLength) && (cookie[c] == ' ')) {
   14.99 +                ++c;
  14.100 +              }
  14.101 +              if (!login && !strcmp(variableName, "login")) {
  14.102 +                if ((login = malloc(strlen(variableValue) + 1)) != 0) {
  14.103 +                  strcpy(login, variableValue);
  14.104 +                }
  14.105 +              } else if (!password && !strcmp(variableName, "password")) {
  14.106 +                if ((password = malloc(strlen(variableValue) + 1)) != 0) {
  14.107 +                  strcpy(password, variableValue);
  14.108 +                }
  14.109 +              }
  14.110 +            }
  14.111 +
  14.112 +            /* IF LOGIN VALUE IS MISSING... */
  14.113 +            if (!login) {
  14.114 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN PANEL **/
  14.115 +              RedirectToLoginPanel();
  14.116 +
  14.117 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
  14.118 +            } else {
  14.119 +
  14.120 +              /* VERIFY LOGIN AND PASSWORD */
  14.121 +              char *directory;
  14.122 +              if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
  14.123 +                /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
  14.124 +                RedirectToLoginPanel();
  14.125 +              } else {
  14.126 +                char *systemDirectory;
  14.127 +                if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
  14.128 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR SYSTEM DIRECTORY NAME > REDIRECT TO LOGIN PANEL **/
  14.129 +                  RedirectToLoginPanel();
  14.130 +                } else {
  14.131 +                  strcpy(directory, DIRECTORY);
  14.132 +                  strcat(directory, login);
  14.133 +                  strcpy(systemDirectory, SYSTEM_DIRECTORY);
  14.134 +                  strcat(systemDirectory, login);
  14.135 +
  14.136 +                  /* IF DIRECTORY CAN'T BE ACCESSED... */
  14.137 +                  if (access(directory, F_OK) || access(systemDirectory, F_OK)) {
  14.138 +                    /** ERROR | CANNOT ACCESS DIRECTORY > REDIRECT TO LOGIN PANEL **/
  14.139 +                    RedirectToLoginPanel();
  14.140 +
  14.141 +                  /* OTHERWISE, IF DIRECTORY CAN BE ACCESSED... */
  14.142 +                  } else {
  14.143 +
  14.144 +                    /* ATTEMPT TO ACCESS PASSWORD FILE */
  14.145 +                    char *passwordFileName;
  14.146 +                    if (!(passwordFileName = malloc(strlen(systemDirectory) + strlen(PASSWORD_FILE_NAME) + 1))) {
  14.147 +                      /** ERROR | CANNOT ALLOCATE MEMORY FOR FILE NAME > REDIRECT TO LOGIN PANEL **/
  14.148 +                      RedirectToLoginPanel();
  14.149 +                    } else {
  14.150 +                      strcpy(passwordFileName, systemDirectory);
  14.151 +                      strcat(passwordFileName, PASSWORD_FILE_NAME);
  14.152 +
  14.153 +                      /* IF PASSWORD FILE CAN'T BE ACCESSED... */
  14.154 +                      if (access(passwordFileName, F_OK)) {
  14.155 +                        /** ERROR | CANNOT ACCESS FILE > REDIRECT TO LOGIN PANEL **/
  14.156 +                        RedirectToLoginPanel();
  14.157 +
  14.158 +                      /* OTHERWISE, IF PASSWORD FILE CAN BE ACCESSED... */
  14.159 +                      } else {
  14.160 +
  14.161 +                        /* ATTEMPT TO OPEN PASSWORD FILE FOR READING */
  14.162 +                        FILE *passwordFile;
  14.163 +
  14.164 +                        /* IF PASSWORD FILE CAN'T BE OPENED FOR READING... */
  14.165 +                        if (!(passwordFile = fopen(passwordFileName, "r"))) {
  14.166 +                          /** ERROR | CANNOT READ FILE > REDIRECT TO LOGIN PANEL **/
  14.167 +                          RedirectToLoginPanel();
  14.168 +
  14.169 +                        /* OTHERWISE, IF PASSWORD FILE CAN BE OPENED FOR READING... */
  14.170 +                        } else {
  14.171 +                          char *filePassword;
  14.172 +                          if (!(filePassword = malloc(MAX_PASSWORD_SIZE + 1))) {
  14.173 +                            /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD FROM FILE > REDIRECT TO LOGIN PANEL **/
  14.174 +                            RedirectToLoginPanel();
  14.175 +                          } else {
  14.176 +                            char c;
  14.177 +                            i = 0;
  14.178 +
  14.179 +                            /* READ PASSWORD FROM PASSWORD FILE */
  14.180 +                            while (((c = fgetc(passwordFile)) != '\n') && (i < MAX_PASSWORD_SIZE)) {
  14.181 +                              filePassword[i] = c;
  14.182 +                              ++i;
  14.183 +                            }
  14.184 +                            filePassword[i] = '\0';
  14.185 +                            fclose(passwordFile);
  14.186 +
  14.187 +                            /* IF PASSWORD FAILS COMPARISON... */
  14.188 +                            if (strcmp(filePassword, password)) {
  14.189 +                              /** ERROR | PASSWORD FAILED > REDIRECT TO LOGIN PANEL **/
  14.190 +                              RedirectToLoginPanel();
  14.191 +
  14.192 +                            /* OTHERWISE, IF PASSWORD PASSES COMPARISON... */
  14.193 +                            } else {
  14.194 +
  14.195 +                              /* LOAD SETTINGS VALUES FROM FILE(S) */
  14.196 +
  14.197 +                              /* LOAD MENU ITEMS FROM FILES */
  14.198 +
  14.199 +                              /* READ NEW MENU FILE */
  14.200 +
  14.201 +                              /* DECLARE AND INITIALIZE QUERY VARIABLES */
  14.202 +                              char *text_file;
  14.203 +                              text_file = NULL;
  14.204 +
  14.205 +                              /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
  14.206 +                              if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
  14.207 +                                char *query;
  14.208 +                                INT queryLength = strlen(getenv("QUERY_STRING"));
  14.209 +                                if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
  14.210 +                                  /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
  14.211 +                                } else {
  14.212 +                                  strcpy(query, getenv("QUERY_STRING"));
  14.213 +                                  free(variableName);
  14.214 +                                  if (!(variableName = malloc(queryLength + 1))) {
  14.215 +                                    /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
  14.216 +                                  } else {
  14.217 +                                    free(variableValue);
  14.218 +                                    if (!(variableValue = malloc(queryLength + 1))) {
  14.219 +                                      /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
  14.220 +
  14.221 +                                    /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
  14.222 +                                    } else {
  14.223 +
  14.224 +                                      /* PROCESS QUERY DATA */
  14.225 +                                      INT q = 0;
  14.226 +                                      i = 0;
  14.227 +                                      while ((q < queryLength) && (query[q] != '\0')) {
  14.228 +                                        while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
  14.229 +                                          variableName[i] = query[q];
  14.230 +                                          ++q;
  14.231 +                                          ++i;
  14.232 +                                        }
  14.233 +                                        variableName[i] = '\0';
  14.234 +                                        ++q;
  14.235 +                                        i = 0;
  14.236 +                                        while ((query[q] != '&') && (query[q] != '\0')) {
  14.237 +                                          variableValue[i] = query[q];
  14.238 +                                          ++q;
  14.239 +                                          ++i;
  14.240 +                                        }
  14.241 +                                        variableValue[i] = '\0';
  14.242 +                                        if (query[q] != '\0') {
  14.243 +                                          ++q;
  14.244 +                                        }
  14.245 +                                        if (!text_file && !strcmp(variableName, "text_file")) {
  14.246 +                                          if ((text_file = malloc(strlen(variableValue) + 1)) != 0) {
  14.247 +                                            strcpy(text_file, variableValue);
  14.248 +                                          }
  14.249 +                                        }
  14.250 +                                      }
  14.251 +                                      free(variableValue);
  14.252 +                                      variableValue = NULL;
  14.253 +                                    }
  14.254 +                                    free(variableName);
  14.255 +                                    variableName = NULL;
  14.256 +                                  }
  14.257 +                                  free(query);
  14.258 +                                }
  14.259 +                              }
  14.260 +                              /* IF THIS IS A CONTINUED SESSION... */
  14.261 +
  14.262 +                                /* LOAD SESSION FROM FILE */
  14.263 +
  14.264 +                              /* OUTPUT GUI COMPONENT(S) BASED ON VARIABLES */
  14.265 +                              if (text_file) {
  14.266 +                                OutputGUI("text_file", text_file);
  14.267 +                              } else {
  14.268 +
  14.269 +                                /* OUTPUT XHTML FOR NEW MENU */
  14.270 +                                OutputNewMenu();
  14.271 +                              }
  14.272 +                            }
  14.273 +                            free(filePassword);
  14.274 +                          }
  14.275 +                        }
  14.276 +                      }
  14.277 +                      free(passwordFileName);
  14.278 +                    }
  14.279 +                  }
  14.280 +                  free(systemDirectory);
  14.281 +                }
  14.282 +                free(directory);
  14.283 +              }
  14.284 +              free(login);
  14.285 +            }
  14.286 +            free(password);
  14.287 +            free(variableValue);
  14.288 +          }
  14.289 +          free(variableName);
  14.290 +        }
  14.291 +        free(cookie);
  14.292 +      }
  14.293 +    }
  14.294 +  }
  14.295 +  return 0;
  14.296 +}
  14.297 +
  14.298 +/* FUNCTION | OUTPUT XHTML FOR interos FRAMESET GRAPHICAL USER INTERFACE */
  14.299 +static void OutputGUI(const char *variableName, const char *variableValue) {
  14.300 +  BeginXHTMLOutput();
  14.301 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  14.302 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  14.303 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  14.304 +  printf("  <!--========================================================-->\n");
  14.305 +  printf("  <!--       interos Standard Document Header - Markup        -->\n");
  14.306 +  printf("  <!--========================================================-->\n");
  14.307 +  printf("  <!--    URIs:  https://interos.com/new?                     -->\n");
  14.308 +  printf("  <!--           https://www.interos.com/new?                 -->\n");
  14.309 +  printf("  <!--   Title:  interos                                      -->\n");
  14.310 +  printf("  <!--  Author:  Brent Angeline                               -->\n");
  14.311 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
  14.312 +  printf("  <!--========================================================-->\n");
  14.313 +  printf("  <head>\n");
  14.314 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  14.315 +  printf("    <meta name=\"title\" content=\"interos\" />\n");
  14.316 +  printf("    <meta name=\"description\" content=\"internet operating system\" />\n");
  14.317 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  14.318 +  printf("    <meta name=\"copyright\" \n");
  14.319 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  14.320 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  14.321 +  printf("    <title>interos</title>\n");
  14.322 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  14.323 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  14.324 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  14.325 +  printf("          media=\"screen, projection\" />\n");
  14.326 +  printf("    <script type=\"text/javascript\" src=\"/js/interos.js\"></script>\n");
  14.327 +  printf("  </head>\n");
  14.328 +  printf("  <frameset rows=\"72,*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  14.329 +  printf("    <frame name=\"top\" src=\"/top\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" noresize=\"noresize\" scrolling=\"no\" />\n");
  14.330 +  if (variableName && variableValue) {
  14.331 +    printf("    <frame name=\"content\" src=\"/content?%s=%s\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" noresize=\"noresize\" scrolling=\"no\" />\n", variableName, variableValue);
  14.332 +  } else {
  14.333 +    printf("    <frame name=\"content\" src=\"/content\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" noresize=\"noresize\" scrolling=\"no\" />\n");
  14.334 +  }
  14.335 +  printf("    <frame name=\"bottom\" src=\"/bottom\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" noresize=\"noresize\" scrolling=\"no\" />\n");
  14.336 +  printf("    <noframes>\n");
  14.337 +  printf("      <body id=\"body\">\n");
  14.338 +  printf("        <div id=\"interosContainer\">\n");
  14.339 +  printf("          <div id=\"interosContent\">\n");
  14.340 +  printf("            <h1>interos menu</h1>\n");
  14.341 +  printf("            <ol>\n");
  14.342 +  printf("              <li><a id=\"newLink\" href=\"/interos?menu=new\">new</a></li>\n");
  14.343 +  printf("              <li><a id=\"openLink\" href=\"/interos?menu=open\">open</a></li>\n");
  14.344 +  printf("              <li><a id=\"nextLink\" href=\"/interos?menu=next\">next</a></li>\n");
  14.345 +  printf("              <li><a id=\"settingsLink\" href=\"/interos?menu=settings\">settings</a></li>\n");
  14.346 +  printf("            </ol>\n");
  14.347 +  printf("          </div>\n");
  14.348 +  printf("        </div>\n");
  14.349 +  printf("      </body>\n");
  14.350 +  printf("    </noframes>\n");
  14.351 +  printf("  </frameset>\n");
  14.352 +  FinishXHTMLOutput();
  14.353 +}
  14.354 +
  14.355 +/* FUNCTION | OUTPUT XHTML FOR NEW MENU */
  14.356 +static void OutputNewMenu(void) {
  14.357 +  BeginXHTMLOutput();
  14.358 +  printf("<?xml-stylesheet type=\"text/css\" href=\"/style/main.css\"?>\n");
  14.359 +  printf("<!DOCTYPE html SYSTEM \"http://interos.org/dtd/xhtml1-borderless-frameset.dtd\">\n");
  14.360 +  printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
  14.361 +  printf("  <!--========================================================-->\n");
  14.362 +  printf("  <!--       interos Standard Document Header - Markup        -->\n");
  14.363 +  printf("  <!--========================================================-->\n");
  14.364 +  printf("  <!--    URIs:  https://interos.com/new                      -->\n");
  14.365 +  printf("  <!--           https://www.interos.com/new                  -->\n");
  14.366 +  printf("  <!--   Title:  interos new                                  -->\n");
  14.367 +  printf("  <!--  Author:  Brent Angeline                               -->\n");
  14.368 +  printf("  <!--  Markup:  WDG-Validated XHTML 1.0 Borderless Frameset  -->\n");
  14.369 +  printf("  <!--========================================================-->\n");
  14.370 +  printf("  <head>\n");
  14.371 +  printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  14.372 +  printf("    <meta name=\"title\" content=\"interos new\" />\n");
  14.373 +  printf("    <meta name=\"description\" content=\"new menu for interos\" />\n");
  14.374 +  printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  14.375 +  printf("    <meta name=\"copyright\" \n");
  14.376 +  printf("          content=\"Copyright &copy; 2001-2010 Brent Angeline and interos LLC\" />\n");
  14.377 +  printf("    <meta name=\"robots\" content=\"noindex, nofollow, noarchive\" />\n");
  14.378 +  printf("    <title>interos new</title>\n");
  14.379 +  printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  14.380 +  printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  14.381 +  printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/main.css\" \n");
  14.382 +  printf("          media=\"screen, projection\" />\n");
  14.383 +  printf("    <script type=\"text/javascript\" src=\"/js/interos_new.js\"></script>\n");
  14.384 +  printf("  </head>\n");
  14.385 +  printf("  <frameset rows=\"*,72\" border=\"0\" frameborder=\"0\" framespacing=\"0\">\n");
  14.386 +  printf("    <frame name=\"menu\" src=\"/menu?name=new\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" noresize=\"noresize\" scrolling=\"no\" />\n");
  14.387 +  printf("    <frame name=\"button\" src=\"/bottom?button=new\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" noresize=\"noresize\" scrolling=\"no\" />\n");
  14.388 +  printf("    <noframes>\n");
  14.389 +  printf("      <body id=\"body\">\n");
  14.390 +  printf("        <div id=\"newContainer\">\n");
  14.391 +  printf("          <div id=\"newContent\">\n");
  14.392 +  printf("            <div id=\"newEntries\">\n");
  14.393 +  printf("              <p><a href=\"/interos?new=text_file\">text file</a></p>\n");
  14.394 +  printf("            </div>\n");
  14.395 +  printf("            <div id=\"newLink\"><a href=\"/interos\">new</a></div>\n");
  14.396 +  printf("          </div>\n");
  14.397 +  printf("        </div>\n");
  14.398 +  printf("      </body>\n");
  14.399 +  printf("    </noframes>\n");
  14.400 +  printf("  </frameset>\n");
  14.401 +  FinishXHTMLOutput();
  14.402 +}
  14.403 +
  14.404 +/* FUNCTION | BEGIN XHTML OUTPUT */
  14.405 +static void BeginXHTMLOutput(void) {
  14.406 +  printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
  14.407 +  printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
  14.408 +}
  14.409 +
  14.410 +/* FUNCTION | FINISH XHTML OUTPUT */
  14.411 +static void FinishXHTMLOutput(void) {
  14.412 +  printf("  <!--=====================================================================-->\n");
  14.413 +  printf("  <!--                  Copyright and Trademark Statement                  -->\n");
  14.414 +  printf("  <!--=====================================================================-->\n");
  14.415 +  printf("  <!--                                                                     -->\n");
  14.416 +  printf("  <!--          All original textual and graphical site content:           -->\n");
  14.417 +  printf("  <!--                                                                     -->\n");
  14.418 +  printf("  <!--  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    -->\n");
  14.419 +  printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
  14.420 +  printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
  14.421 +  printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
  14.422 +  printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
  14.423 +  printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
  14.424 +  printf("  <!--  are the properties of their respective authors.  All software      -->\n");
  14.425 +  printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
  14.426 +  printf("  <!--                                                                     -->\n");
  14.427 +  printf("  <!--=====================================================================-->\n");
  14.428 +  printf("  <!--                      e-mail: info@interos.com                       -->\n");
  14.429 +  printf("  <!--=====================================================================-->\n");
  14.430 +  printf("</html>");
  14.431 +}
  14.432 +
  14.433 +/* FUNCTION | REDIRECT TO LOGIN PANEL */
  14.434 +static void RedirectToLoginPanel(void) {
  14.435 +  printf("Location: login\r\n\r\n");
  14.436 +}
  14.437 +
  14.438 +/***********************************************************************/
  14.439 +/*                  Copyright and Trademark Statement                  */
  14.440 +/***********************************************************************/
  14.441 +/*                                                                     */
  14.442 +/*          All original textual and graphical site content:           */
  14.443 +/*                                                                     */
  14.444 +/*  Copyright 2001-2010 Brent Angeline and interos LLC.  All rights    */
  14.445 +/*  reserved.  Reproduction in whole or in part without written        */
  14.446 +/*  permission is prohibited.  interos and the interos logos are       */
  14.447 +/*  trademarks of Brent Angeline and interos LLC.  All other company,  */
  14.448 +/*  product, and service names mentioned herein may be the properties  */
  14.449 +/*  of their respective owners.  Comments in the interos.org forums    */
  14.450 +/*  are the properties of their respective authors.  All software      */
  14.451 +/*  developed in the forums is open source and belongs to everyone.    */
  14.452 +/*                                                                     */
  14.453 +/***********************************************************************/
  14.454 +/*                      e-mail: info@interos.com                       */
  14.455 +/***********************************************************************/
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/c/new_user_interos.com_ssl.c	Sat May 01 16:19:36 2010 -0400
    15.3 @@ -0,0 +1,826 @@
    15.4 +/****************************************************/
    15.5 +/*   interos Standard Document Header - CGI in C    */
    15.6 +/****************************************************/
    15.7 +/*         URIs:  https://interos.com/new_user      */
    15.8 +/*                https://www.interos.com/new_user  */
    15.9 +/*       Source:  new_user.c                        */
   15.10 +/*  Description:  FastCGI for interos new_user      */
   15.11 +/*       Author:  Brent Angeline                    */
   15.12 +/*          CGI:  FastCGI in ISO/ANSI C             */
   15.13 +/****************************************************/
   15.14 +
   15.15 +/* PREPROCESSOR DIRECTIVES */
   15.16 +#include "fcgi_stdio.h"     /*  FCGI_Accept(), fread(), printf()                                                                           */
   15.17 +#include "interos.h"        /*  DIRECTORY, INT, DIRECTORY_COMMAND, ECHO_COMMAND, PASSWORD_OUT, SYSTEM_DIRECTORY, SYSTEM_DIRECTORY_COMMAND  */
   15.18 +#include <ctype.h>          /*  tolower()                                                                                                  */
   15.19 +#include <stdlib.h>         /*  free(), getenv(), malloc(), system()                                                                       */
   15.20 +#include <string.h>         /*  strcat(), strcmp(), strcpy(), strlen()                                                                     */
   15.21 +#include <unistd.h>         /*  F_OK, access()                                                                                             */
   15.22 +
   15.23 +static void Old(void);
   15.24 +
   15.25 +/* BEGIN MAIN PROGRAM */
   15.26 +int main(void) {
   15.27 +
   15.28 +  /* BEGIN FASTCGI */
   15.29 +  while (FCGI_Accept() >= 0) {
   15.30 +
   15.31 +    /* IF POST DATA DOESN'T EXIST OR IS TOO LONG... */
   15.32 +    if (!getenv("CONTENT_LENGTH") || (sizeof(STRING_TO_INT(getenv("CONTENT_LENGTH"), (char **) NULL, 10)) > sizeof(INT))) {
   15.33 +      char *status = NULL;
   15.34 +
   15.35 +      /* IF QUERY DATA EXISTS AND IS OF ACCEPTABLE LENGTH... */
   15.36 +      if (getenv("QUERY_STRING") && (sizeof(strlen(getenv("QUERY_STRING"))) <= sizeof(INT))) {
   15.37 +
   15.38 +        /* ATTEMPT TO ALLOCATE MEMORY FOR QUERY VARIABLES */
   15.39 +        char *query;
   15.40 +        INT queryLength = strlen(getenv("QUERY_STRING"));
   15.41 +        if ((queryLength < 1) || !(query = malloc(queryLength + 1))) {
   15.42 +          /** ERROR | CRUCIAL MEMORY ALLOCATION ERROR FOR QUERY DATA! > CONTINUE WITHOUT QUERY **/
   15.43 +        } else {
   15.44 +          char *variableName;
   15.45 +          strcpy(query, getenv("QUERY_STRING"));
   15.46 +          if (!(variableName = malloc(queryLength + 1))) {
   15.47 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > CONTINUE WITHOUT QUERY **/
   15.48 +          } else {
   15.49 +            char *variableValue;
   15.50 +            if (!(variableValue = malloc(queryLength + 1))) {
   15.51 +              /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > CONTINUE WITHOUT QUERY **/
   15.52 +
   15.53 +            /* IF SUFFICIENT MEMORY FOR QUERY VARIABLES... */
   15.54 +            } else {
   15.55 +
   15.56 +              /* PROCESS QUERY DATA */
   15.57 +              INT q = 0;
   15.58 +              i = 0;
   15.59 +              while ((q < queryLength) && (query[q] != '\0')) {
   15.60 +                while ((q < queryLength) && (query[q] != '=') && (query[q] != '\0')) {
   15.61 +                  variableName[i] = query[q];
   15.62 +                  ++q;
   15.63 +                  ++i;
   15.64 +                }
   15.65 +                variableName[i] = '\0';
   15.66 +                ++q;
   15.67 +                i = 0;
   15.68 +                while ((query[q] != '&') && (query[q] != '\0')) {
   15.69 +                  variableValue[i] = query[q];
   15.70 +                  ++q;
   15.71 +                  ++i;
   15.72 +                }
   15.73 +                variableValue[i] = '\0';
   15.74 +                if (query[q] != '\0') {
   15.75 +                  ++q;
   15.76 +                }
   15.77 +                if (!status && !strcmp(variableName, "status")) {
   15.78 +                  if ((status = malloc(strlen(variableValue) + 1)) != 0) {
   15.79 +                    strcpy(status, variableValue);
   15.80 +                  }
   15.81 +                }
   15.82 +              }
   15.83 +              free(variableValue);
   15.84 +            }
   15.85 +            free(variableName);
   15.86 +          }
   15.87 +          free(query);
   15.88 +        }
   15.89 +      }
   15.90 +
   15.91 +      /* DISPLAY CREATE LOGIN PANEL */
   15.92 +      printf("Content-Type: text/html; charset=utf-8\r\n\r\n");
   15.93 +      printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
   15.94 +      printf("<?xml-stylesheet type=\"text/css\" href=\"/style/login.css\"?>\n");
   15.95 +      printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n");
   15.96 +      printf("                      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
   15.97 +      printf("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n");
   15.98 +      printf("  <!--=================================================-->\n");
   15.99 +      printf("  <!--    interos Standard Document Header - Markup    -->\n");
  15.100 +      printf("  <!--=================================================-->\n");
  15.101 +      printf("  <!--    URIs:  https://interos.com/new_user          -->\n");
  15.102 +      printf("  <!--           https://www.interos.com/new_user      -->\n");
  15.103 +      printf("  <!--   Title:  new interos user                      -->\n");
  15.104 +      printf("  <!--  Author:  Brent Angeline                        -->\n");
  15.105 +      printf("  <!--  Markup:  W3C-Validated XHTML 1.0 Transitional  -->\n");
  15.106 +      printf("  <!--=================================================-->\n");
  15.107 +      printf("  <head>\n");
  15.108 +      printf("    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  15.109 +      printf("    <meta name=\"title\" content=\"new interos user\" />\n");
  15.110 +      printf("    <meta name=\"description\" content=\"create your login\" />\n");
  15.111 +      printf("    <meta name=\"author\" content=\"Brent Angeline\" />\n");
  15.112 +      printf("    <meta name=\"copyright\" \n");
  15.113 +      printf("          content=\"Copyright &copy; 2001-2008 Brent Angeline and interos LLC\" />\n");
  15.114 +      printf("    <meta name=\"robots\" content=\"index, nofollow, noarchive\" />\n");
  15.115 +      printf("    <title>new interos user</title>\n");
  15.116 +      printf("    <link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />\n");
  15.117 +      printf("    <link rel=\"icon\" type=\"image/gif\" href=\"/images/favicon.gif\" />\n");
  15.118 +      printf("    <link rel=\"stylesheet\" type=\"text/css\" href=\"/style/login.css\" \n");
  15.119 +      printf("          media=\"screen, projection\" />\n");
  15.120 +      printf("    <script type=\"text/javascript\" src=\"/js/login.js\"></script>\n");
  15.121 +      printf("  </head>\n");
  15.122 +      printf("  <body id=\"body\">\n");
  15.123 +      printf("    <center>\n");
  15.124 +      printf("      <p id=\"navigation\">\n");
  15.125 +      printf("        <a href=\"/about\">about</a> | \n");
  15.126 +      printf("        <a href=\"/blog\">blog</a> | \n");
  15.127 +      printf("        <a href=\"/code\">code</a> | \n");
  15.128 +      printf("        <a href=\"https://interos.org/\">develop</a> | \n");
  15.129 +      printf("        <a href=\"/e-mail\">e-mail</a> | \n");
  15.130 +      printf("        <a href=\"/f.a.q.\">f.a.q.</a> | \n");
  15.131 +      printf("        <a href=\"/gear\">gear</a> | \n");
  15.132 +      printf("        <a href=\"/help\">help</a>\n");
  15.133 +      printf("      </p>\n");
  15.134 +      printf("      <form id=\"loginForm\" name=\"loginForm\" action=\"new_user\" method=\"post\">\n");
  15.135 +      printf("        <table id=\"mainPanel\">\n");
  15.136 +      printf("          <thead>\n");
  15.137 +      printf("            <tr>\n");
  15.138 +      printf("              <th colspan=\"3\"><center>\n");
  15.139 +      printf("                                <div id=\"title\">\n");
  15.140 +      printf("                                  <h1>\n");
  15.141 +      printf("                                    <a href=\"/\">interos</a>\n");
  15.142 +      printf("                                  </h1>\n");
  15.143 +      printf("                                  <h2>\n");
  15.144 +      printf("                                    create your login\n");
  15.145 +      printf("                                  </h2>\n");
  15.146 +      printf("                                </div>\n");
  15.147 +      printf("                              </center></th>\n");
  15.148 +      printf("            </tr>\n");
  15.149 +      printf("          </thead>\n");
  15.150 +      printf("          <tfoot>\n");
  15.151 +      printf("            <tr>\n");
  15.152 +      printf("              <td colspan=\"3\"><br /></td>\n");
  15.153 +      printf("            </tr>\n");
  15.154 +      printf("          </tfoot>\n");
  15.155 +      printf("          <tbody>\n");
  15.156 +      printf("            <tr>\n");
  15.157 +      printf("              <td><label for=\"login\">login:</label>&nbsp;</td>\n");
  15.158 +      printf("              <td><input id=\"login\" name=\"login\" type=\"text\" \n");
  15.159 +      printf("                         size=\"16\"  maxlength=\"16\" /></td>\n");
  15.160 +      printf("            </tr>\n");
  15.161 +      printf("            <tr>\n");
  15.162 +      printf("              <td><label for=\"password\">password:</label>&nbsp;</td>\n");
  15.163 +      printf("              <td><input id=\"password\" name=\"password\" type=\"password\" \n");
  15.164 +      printf("                         size=\"16\"     maxlength=\"16\" /></td>\n");
  15.165 +      printf("            </tr>\n");
  15.166 +      printf("            <tr>\n");
  15.167 +      printf("              <td><label for=\"verify\">password:</label>&nbsp;</td>\n");
  15.168 +      printf("              <td><input id=\"verify\" name=\"verify\" type=\"password\" \n");
  15.169 +      printf("                         size=\"16\"   maxlength=\"16\" /></td>\n");
  15.170 +      printf("              <td rowspan=\"2\"><div id=\"submitButton\">\n");
  15.171 +      printf("                                &nbsp;<input type=\"submit\" \n");
  15.172 +      printf("                                             value=\"login &raquo;\" />\n");
  15.173 +      printf("                              </div></td>\n");
  15.174 +      printf("            </tr>\n");
  15.175 +      printf("          </tbody>\n");
  15.176 +      printf("        </table>\n");
  15.177 +      printf("      </form>\n");
  15.178 +      printf("      <p id=\"newUser\">\n");
  15.179 +      printf("        <strong>* enter password twice</strong><br />\n");
  15.180 +      printf("        to create your login<br />\n");
  15.181 +      printf("        <a href=\"/login\">&laquo; back to login</a>\n");
  15.182 +      printf("      </p>\n");
  15.183 +      printf("      <p>\n");
  15.184 +      printf("        <br />\n");
  15.185 +      printf("      </p>\n");
  15.186 +      printf("      <p id=\"copyrightDates\">\n");
  15.187 +      printf("        &copy; 2001&#8211;2008 interos\n");
  15.188 +      printf("      </p>\n");
  15.189 +      printf("    </center>\n");
  15.190 +      printf("  </body>\n");
  15.191 +      printf("  <!--=====================================================================-->\n");
  15.192 +      printf("  <!--                  Copyright and Trademark Statement                  -->\n");
  15.193 +      printf("  <!--=====================================================================-->\n");
  15.194 +      printf("  <!--                                                                     -->\n");
  15.195 +      printf("  <!--          All original textual and graphical site content:           -->\n");
  15.196 +      printf("  <!--                                                                     -->\n");
  15.197 +      printf("  <!--  Copyright 2001-2008 Brent Angeline and interos LLC.  All rights    -->\n");
  15.198 +      printf("  <!--  reserved.  Reproduction in whole or in part without written        -->\n");
  15.199 +      printf("  <!--  permission is prohibited.  interos and the interos logos are       -->\n");
  15.200 +      printf("  <!--  trademarks of Brent Angeline and interos LLC.  All other company,  -->\n");
  15.201 +      printf("  <!--  product, and service names mentioned herein may be the properties  -->\n");
  15.202 +      printf("  <!--  of their respective owners.  Comments in the interos.org forums    -->\n");
  15.203 +      printf("  <!--  are the properties of their respective authors.  All software      -->\n");
  15.204 +      printf("  <!--  developed in the forums is open source and belongs to everyone.    -->\n");
  15.205 +      printf("  <!--                                                                     -->\n");
  15.206 +      printf("  <!--=====================================================================-->\n");
  15.207 +      printf("  <!--                      e-mail: info@interos.com                       -->\n");
  15.208 +      printf("  <!--=====================================================================-->\n");
  15.209 +      printf("</html>");
  15.210 +
  15.211 +      /* CLEAN UP AFTER QUERY DATA PROCESSING */
  15.212 +      free(status);
  15.213 +
  15.214 +    /* OTHERWISE, IF POST DATA DOES EXIST AND IS OF ACCEPTABLE LENGTH... */
  15.215 +    } else {
  15.216 +
  15.217 +      /* SET VARIABLES BASED ON POST DATA */
  15.218 +
  15.219 +      /* ATTEMPT TO ALLOCATE MEMORY FOR POST VARIABLES */
  15.220 +      char *post;
  15.221 +      INT postLength = STRING_TO_INT(getenv("CONTENT_LENGTH"), (char **) NULL, 10);
  15.222 +      if ((postLength < 1) || !(post = malloc(postLength + 1))) {
  15.223 +        /** ERROR | CANNOT ALLOCATE MEMORY FOR POST DATA > REDIRECT TO LOGIN CREATION PANEL **/
  15.224 +        printf("Location: new_user?status=try_again\r\n\r\n");
  15.225 +      } else {
  15.226 +        char *variableName;
  15.227 +        if (!(variableName = malloc(postLength + 1))) {
  15.228 +          /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE NAME > REDIRECT TO LOGIN CREATION PANEL **/
  15.229 +            printf("Location: new_user?status=try_again\r\n\r\n");
  15.230 +        } else {
  15.231 +          char *variableValue;
  15.232 +          if (!(variableValue = malloc(postLength + 1))) {
  15.233 +            /** ERROR | CANNOT ALLOCATE MEMORY FOR VARIABLE VALUE > REDIRECT TO LOGIN CREATION PANEL **/
  15.234 +            printf("Location: new_user?status=try_again\r\n\r\n");
  15.235 +          } else {
  15.236 +
  15.237 +            /* PROCESS POST DATA */
  15.238 +            char *login, *password, *verify;
  15.239 +            INT  i, j, p;
  15.240 +            login = password = verify = NULL;
  15.241 +            j = p = 0;
  15.242 +            fread(post, postLength, 1, stdin);
  15.243 +            post[postLength] = '\0';
  15.244 +            while ((p < postLength) && (post[p] != '\0')) {
  15.245 +              i = 0;
  15.246 +              while ((p < postLength) && (post[p] != '=') && (post[p] != '\0')) {
  15.247 +                variableName[i] = post[p];
  15.248 +                ++p;
  15.249 +                ++i;
  15.250 +              }
  15.251 +              variableName[i] = '\0';
  15.252 +              ++p;
  15.253 +              i = 0;
  15.254 +              while ((p < postLength) && (post[p] != '&') && (post[p] != '\0')) {
  15.255 +                variableValue[i] = post[p];
  15.256 +                ++p;
  15.257 +                ++i;
  15.258 +              }
  15.259 +              variableValue[i] = '\0';
  15.260 +              if (post[p] != '\0') {
  15.261 +                ++p;
  15.262 +              }
  15.263 +              if (!login && !strcmp(variableName, "login")) {
  15.264 +                if (!(login = malloc(strlen(variableValue) + 1))) {
  15.265 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR LOGIN VARIABLE > REDIRECT TO LOGIN CREATION PANEL **/
  15.266 +                  printf("Location: new_user?status=try_again\r\n\r\n");
  15.267 +                } else {
  15.268 +                  strcpy(login, variableValue);
  15.269 +                  for (j = 0; j < strlen(login); ++j) {
  15.270 +                    login[j] = tolower(login[j]);
  15.271 +                  }
  15.272 +                }
  15.273 +              } else if (!password && !strcmp(variableName, "password")) {
  15.274 +                if (!(password = malloc(strlen(variableValue) + 1))) {
  15.275 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD VARIABLE > REDIRECT TO LOGIN CREATION PANEL **/
  15.276 +                  printf("Location: new_user?status=try_again\r\n\r\n");
  15.277 +                } else {
  15.278 +                  strcpy(password, variableValue);
  15.279 +                }
  15.280 +              } else if (!verify && !strcmp(variableName, "verify")) {
  15.281 +                if (!(verify = malloc(strlen(variableValue) + 1))) {
  15.282 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR PASSWORD CONFIRM VARIABLE > REDIRECT TO LOGIN CREATION PANEL **/
  15.283 +                  printf("Location: new_user?status=try_again\r\n\r\n");
  15.284 +                } else {
  15.285 +                  strcpy(verify, variableValue);
  15.286 +                }
  15.287 +              }
  15.288 +            }
  15.289 +
  15.290 +            /* IF LOGIN VALUE IS MISSING... */
  15.291 +            if (!login) {
  15.292 +              /** ERROR | LOGIN VALUE IS MISSING > REDIRECT TO LOGIN CREATION PANEL **/
  15.293 +              printf("Location: new_user?status=try_again\r\n\r\n");
  15.294 +
  15.295 +            /* OTHERWISE, IF LOGIN VALUE EXISTS... */
  15.296 +            } else {
  15.297 +
  15.298 +              /* CHECK LOGIN FOR ILLEGAL CHARACTERS */
  15.299 +              char illegalCharacter = 0;
  15.300 +              for (i = 0; i < strlen(login); ++i) {
  15.301 +                if (!(((login[i] >= 'a') && (login[i] <= 'z')) || ((login[i] >= '0') && (login[i] <= '9')))) {
  15.302 +                  illegalCharacter = 1;
  15.303 +                }
  15.304 +              }
  15.305 +              if (illegalCharacter) {
  15.306 +                /** ERROR | LOGIN OR PASSWORD CONTAINS ILLEGAL CHARACTERS > REDIRECT TO LOGIN CREATION PANEL **/ 
  15.307 +                printf("Location: new_user?status=illegal_characters\r\n\r\n");
  15.308 +              } else {
  15.309 +
  15.310 +                /* CHECK LOGIN AVAILABILITY */
  15.311 +                char *directory;
  15.312 +                if (!(directory = malloc(strlen(login) + strlen(DIRECTORY) + 1))) {
  15.313 +                  /** ERROR | CANNOT ALLOCATE MEMORY FOR DIRECTORY NAME > REDIRECT TO LOGIN CREATION PANEL **/
  15.314 +                  printf("Location: new_user?status=try_again\r\n\r\n");
  15.315 +                } else {
  15.316 +                  char *systemDirectory;
  15.317 +                  if (!(systemDirectory = malloc(strlen(login) + strlen(SYSTEM_DIRECTORY) + 1))) {
  15.318 +                    /** ERROR | CANNOT ALLOC