ARAGO for Internet Wiki Project AkuAku

This web site is powered by Arago for Internet v7.0 UTF-8 edition on FreeBSD
SPC main menu Expand/Fold
Products 取扱商品 Expand/Fold
SouthWind  Expand/Fold
Q&A Technical support Expand/Fold
BBS 掲示板 Expand/Fold
Easy PC life Expand/Fold

Last Edit Date: 07/07/2008

ページの作成プログラム
index.prgで解説したところは省略

ページの作成では、そのページを現在のメニューの下位のページにするか、メインメニュを新規作成するかを選択できます。 メニューに表示しないオプションもあります。

ページのファイル名に"_"を入れると、"/"として表示されます。 例えば、 morining_sunriseは、 www.abc.com/morning/sunrise.htmlになります。 既存のディレクトリにあるhtmlファイルをAkuakuに取り込むことが簡単にできます。 元のhtmlファイルがあるときには、mod_rewriteははそのhtmlファイルを表示しますが、 削除されると、 akuakuのデーターベースから、 該当するファイルを表示します。

このcreateでは、 htmlで使用するgifファイルなどのアップロードの機能(同一ファイル名があるときには、 別にユニーク名に変更します)、 既存のimagesのディレクトリにあるイメージを表示することもできます( 未作業)。

また参照用のリンクなどのために、データベースの全てのレコードに対して検索し、 検索エンジンのように、見つかったファイル名と、前後の50文字を表示することができます。

文章の編集にopenWYSIWYGを利用していますが、 保存時の特別な処理はしていません。 画像などのファイルのTAG指定はTEXTモードで編集してください。

このプログラムはとても込み入っているように見えますが、それぞれが独立していますので、よく読めば理解しやすいと思います。


#!/usr/local/aragoi/aragoi.exe createpage.prg

THISPAGE = "createpage"
THISPAGETITLE = "Arago for Internet UTF-8 Wiki Project"
AUTHOR = "Southern Pacific Computer Inc."
WEBURL = "www.soupacific.com" && web url for  favicon .etc.
MAINMENUTITLE = "SPC main menu"
SUBDIR = "" && "en/" "tch/" "sch/"
CGINAME ="akuaku/"
*********above lines are added by createnew
***************************************************************************
**Copyright notice
**This program is copyrighted by southern pacific computer inc.  People can use, modify, distribute , publish
**this program freely withput any permission by southern pacific computer inc..
**Commercial use, with or without charge is allowed too No need to get permisiion by spc.
**Anybody who publish, distribte this program must keep this copyright notice.
**Exception ! Who violate human right, are not allowed using this program !
**SPC do not warrant this program for you usage, all risk is your own.
****************************************************************************
*******ordinary basic setting
SET COMPATIBLE OFF
SET LANGUAGE TO UTF8
SET DATE TO ANSI
SET CENTURY ON
SET DELETE ON
****Get premade FORM data
B1FORM= GETFORM("B1")
T1FORM =GETFORM("T1")
T2FORM=GETFORM("T2")
T3FORM=GETFORM("T3")
T4FORM=GETFORM("T4")
T5FORM =GETFORM("T5")
imagename = GETFORM("T6")
&&T6FORM=GETFORM("T6")
T7FORM=GETFORM("T7")
T8FORM=GETFORM("T8")
T9FORM =GETFORM("T9")
T10FORM=GETFORM("T10")
T11FORM=GETFORM("T11")
T12FORM=GETFORM("T12")
T13FORM =GETFORM("T13")
T14FORM=GETFORM("T14")
T15FORM=GETFORM("T15")
T16FORM=GETFORM("T16")
T17FORM=GETFORM("T17")
NAME = GETFORM("username")
USERIP =GETENV("REMOTE_ADDR")
&&language info, we select proper language page from db
REMOTELANG  =GETENV("HTTP_ACCEPT_LANGUAGE")
DATE=DATE()
CTIME = TIME()
**********pass page info***********
&&using this for security, where this call came and also set return page to
toppage = "index" &&top page is named as index.prg
gparents = GETFORM("parents")
parents = GETFORM("mypage")
mypage = thispage
***********************************
&&parents = "index"
&&name = "debug"
&&SUPERUSER = .T.
&&B1FORM = "GO"
***********************************************
***protect nobody can call this through upper page auth
***********************************************
IF EMPTY(parents)
    DO rewrite2.prg with "index"
    RETURN
ENDIF
***********************************************
**open database with index   index on pagename lastaccess
USE content INDEX pagename, laccess, topmenu ALIAS maindb
**master index is PAGENAME
***Locate right record
IF .NOT. SEEK(gparents)
  OUTPUT('Content-type: text/html;CHARSET=utf-8 ')
  OUTPUT("",1)
  OUTPUT("",1)
  OUTPUT("page not found")
  RETURN
ENDIF
&&B1FORM = "write"
PAGENAMEERROR = .F.
IF B1FORM = "write"
  SAVERECNO = RECN()
  IF SEEK(T1FORM)
    PAGENAMEERROR = .T.
    GO SAVERECNO
  ELSE  
    GO SAVERECNO
      DO WRITEMODE
      RETURN
    ENDIF
ENDIF
*****for giving happiness for Apache 2.x cgi
OUTPUT('Content-type: text/html;CHARSET=utf-8 ')
OUTPUT("",1)
OUTPUT("",1)
OUTPUT('<html>',2) &&here we need carriage return
OUTPUT("<HEAD>")
OUTPUT('<meta name="Robots" content="All">')
OUTPUT('<meta http-equiv="Content-Type" content="text/html; charset=utf-8">')
*****web name, page title set in above
OUTPUT('<meta name="author" content="' + AUTHOR  + '">')
OUTPUT('<link rel="SHORTCUT ICON" href="http://' + WEBURL + '/favicon.ico">')
OUTPUT("<TITLE>" + THISPAGETITLE + "</TITLE>")
****need to set location for css file and javascript file
OUTPUT('<link rel="stylesheet" type="text/css" href="http://' + WEBURL + '/spcneat.css" />') && for css link
OUTPUT('<script src="http://' + WEBURL + '/spcneat.js"></script>') && for javascript link
OUTPUT('<script src="http://' + WEBURL + '/wysiwyg.js"></script></HEAD>') && for javascript link
**********end of head
OUTPUT('<body class="spc_wiki">')
**Show project name
OUTPUT('<TABLE BORDER="1" CELLSPACING="1" WIDTH="100%" HEIGHT="24"><TR>')
OUTPUT('<TD WIDTH="100%" VALIGN="MIDDLE" BGCOLOR="#FFFF00"><H3 ALIGN="CENTER">ARAGO for Internet Wiki Project AkuAku</H3></TD></TR></TABLE>')
** define FORM action
OUTPUT('<FORM NAME = "' + THISPAGE + '" ACTION="http://' + WEBURL + '/'+ CGINAME  + SUBDIR +  'rewrite.prg?' + THISPAGE  + '" METHOD="POST" ENCTYPE="multipart/form-data">')

*************send parents information
OUTPUT('<INPUT TYPE="HIDDEN" NAME="parents" VALUE="'+ gparents + '">')
OUTPUT('<INPUT TYPE="HIDDEN" NAME="mypage" VALUE="'+ mypage + '">')
OUTPUT('<INPUT TYPE="HIDDEN" NAME="username" VALUE="'+ name + '">')
*************
**top site header
OUTPUT('<div id="siteheader">')
*** first header table
output('<div style="padding: 0pt 10px; background-color: #222222; color: #FFFFFF; font-weight: bold; font-size: 12px;"><b style="float: right; color: #33FF00;">Commercial Software is ALSO good for you</b>')
OUTPUT('<a href="http://' + WEBURL + '/" style="color: #FFFFFF; text-decoration: none;">Southern Pacific Computer Inc. </a> </div></div>')
OUTPUT('<div id="spc-top">This web site is powered by Arago for Internet v7.0 UTF-8  edition on FreeBSD </div>')
** end header table
OUTPUT('<tbody>')
IF B1FORM = "GO" .OR. B1FORM = "content" .OR. B1FORM = "title"
    DO EDITMODE
ENDIF
IF B1FORM = "Upload"
  DO SAVEIMG
  DO EDITMODE
ENDIF
OUTPUT('</tr></tbody></table></div>')
IF BOTTOM = .T.
  OUTPUT('<div id="spc-bot">')
  OUTPUT('<small>' + BMTXT + '</small></div>')
ENDIF
OUTPUT('</DIV></FORM></HTML>')
*****end of main program*******

*******************************
PROCEDURE EDITMODE                   コンテンツの編集 openWYSWYGを使用している
*******************************
OUTPUT('<div id="spc-mid"><table id="spc-midtbl" border="0" cellpadding="0" cellspacing="0"> ')
OUTPUT(' <td id="centercolumn" valign="top"> <div id="spc-center">')
OUTPUT('<P><h1>Crate new page </h1></p><BR>')
OUTPUT('<P><h3>Currently editing by:' + name + '  ip: ' + USERIP + '   ' + DTOC(DATE) + '  ' + CTIME + '</h3></p><BR>')
IF PAGENAMEERROR
  OUTPUT('<P><h3>Page name is already used:' + T1FORM + ' Choose other name again </h3></p><BR>')
ENDIF
OUTPUT('<br><table border=1 cellpadding="5"><tbody><tr><td>')
OUTPUT('<br><FONT COLOR="#0066FF"><B>Plese define name and style  MAX NAME lengtrh : 100bytes</B></FONT></P>')
OUTPUT('<br><table border=1 cellpadding="5"><tbody>')
OUTPUT('<P><tr><td>PAGE NAME</td><td><INPUT TYPE="TEXT" NAME="T1" SIZE="40" MAXLENGTH="40">no space, this became file name of new page</tr></td>')
OUTPUT('<P><tr><td>Page Title</td><td><INPUT TYPE="TEXT" NAME="T2" SIZE="60" MAXLENGTH="60">this appears Top of the browser</tr></td>')
OUTPUT('<P><tr><td>MENU NAME</td><td><INPUT TYPE="TEXT" NAME="T7" SIZE="40" MAXLENGTH="40">for menu name</tr></td>')
OUTPUT('</tbody></table>')
OUTPUT('<P>If You do not specify MENU title, PAGE NAME will be MENU title.  You can put space for PAGE or MENU name, Akuaku will take care of it. NOT YET!</tr></td>')
OUTPUT('</tr></td></tbody></table>')
OUTPUT('<P><br><INPUT TYPE=CHECKBOX NAME="T8" VALUE = "yes">If you do not need this page  in MENU, click checkbox <br>')
OUTPUT('<br><table border=1 cellpadding="5"><tbody><tr><td>')
OUTPUT('<p><INPUT TYPE=CHECKBOX NAME="T10" VALUE = "yes">Create a main menu group, click checkbox </p>')
OUTPUT('<style="margin-left : 5px;" >Spceify New Main menu group name<br>')
OUTPUT('<p><INPUT TYPE="TEXT" NAME="T11" SIZE="40" MAXLENGTH="40" ></p>')
OUTPUT('</tr></td></tbody></table>')
************************
OUTPUT('<br>Page Style')
OUTPUT('<table border=1><tbody>')
OUTPUT('<tr><td><INPUT TYPE=CHECKBOX NAME="T12" VALUE = "yes">HIDE Left Menu</td></tr>')
OUTPUT('<tr><td><INPUT TYPE=CHECKBOX NAME="T13" VALUE = "yes">HIDE Right Menu</td></tr>')
OUTPUT('<tr><td><INPUT TYPE=CHECKBOX NAME="T14" VALUE = "yes">HIDE Bottom Table</td></tr>')
OUTPUT('</tbody></table>')
OUTPUT('<br><INPUT TYPE=CHECKBOX NAME="T15" VALUE = "yes">Multi Lnaguage or specific Lnaguage<br><P>')
OUTPUT('NEED to put some selection for language')
OUTPUT('<br>You can start to edit new page content now or keep blank for later edit content.<br><br> ')

新規作成なので、エスケープ記号での処理をしていない。

OUTPUT('<p><TEXTAREA id="textarea1" style="width :500px;margin-left : 10px; margin-right : 10px;" NAME="T3"  COL = "80" ROWS="30"></textarea></p>')
OUTPUT('<script language="javascript1.2">')
OUTPUT( " generate_wysiwyg('textarea1'); </script>")
OUTPUT('<a href="http://www.openwebware.com/products/openwysiwyg/"><img src="http://www.openwebware.com/images/openwysiwyg/32_x_88.gif" height="32" width="88" border="0" alt="openWYSIWYG - Free Open Source WYSIWYG Editor" /></a><br>')
OUTPUT('<a href="http://www.openwebware.com/products/openwysiwyg/" style="font-family: arial; font-size: 12px;">openWYSIWYG - Free Open Source WYSIWYG Editor</a><br>')
OUTPUT('<br><table border=1 cellpadding="5"><tbody><tr><td>')
OUTPUT("not yet worked out")
OUTPUT('<br><p>Invite people for this page as member to share edit or access</p>')
OUTPUT('<INPUT TYPE=CHECKBOX NAME="T16" VALUE = "yes">If you do not like page as open to public, click checkbox <br><P>',9)
OUTPUT('You can invite people, please put your friend mail address separater is , . <br> AkuAku automaticaly send email with new password to access this page, <br> These passwrod is not allowed to edit or modify the pages')
OUTPUT('<p><TEXTAREA  style="width :350px;margin-left : 10px; margin-right : 10px;" NAME="T17"  COL = "80" ROWS="10"></textarea></p>')
OUTPUT('</tr></td></tbody></table>')
OUTPUT('<BR><h3> Search result, Uploaded file info</h3><BR>')
IF .NOT. EMPTY(T5FORM)
IF B1FORM = "content"              全コンテンツからの検索 と 結果の表示
SAVERECNO = RECN()
OUTPUT('<table><tbody><tr><td>')
GOTIT = .F.
GO TOP
DO WHILE .NOT. EOF()
  IF T5FORM $ MMTXT
    POS = AT(T5FORM, MMTXT)
    IF POS < 40
      POS = 1
    ELSE
      POS = POS - 40
    ENDIF
    OUTPUT(PAGETITLE)
    OUTPUT(FILTER(SUBSTR(MMTXT, POS, 80), "<br>", " " ),9)
    OUTPUT(PAGENAME + ".html" + "<br>")
    GOTIT = .T.
  ENDIF     
  SKIP
ENDDO
IF GOTIT = .F.
  OUTPUT("Not found <br>")
ENDIF
GO SAVERECNO
OUTPUT('</td></tr></tbody></table>')
ENDIF
ENDIF
IF .NOT. EMPTY(T4FORM)
IF B1FORM = "title"                   データベースからタイトルの検索と表示
SAVERECNO = RECN()
OUTPUT('<table><tbody><tr><td>')
GOTIT = .F.
GO TOP
SET EXACT OFF
SEEK(T4FORM)
DO WHILE PAGETITLE = T4FORM
  OUTPUT(PAGETITLE)
  OUTPUT(PAGENAME + ".html" + "<br>")
  GOTIT = .T.
  SKIP
ENDDO
IF GOTIT = .F.
  OUTPUT("Not found <br>")
ENDIF
SET EXACT ON
GO SAVERECNO
OUTPUT('</td></tr></tbody></table>')
ENDIF
ENDIF
IF B1FORM = "Upload"              イメージファイルのアップロードでのアップロード結果としてファイル名を表示
  OUTPUT('<table><tbody><tr><td>')
  IF .NOT. EMPTY(imagename)
    OUTPUT("Cuurent upload file name :" + imagename)
  ELSE
    OUTPUT("Current upload was failed, please try to use .jpg file and try again")
  ENDIF
  OUTPUT('</td></tr></tbody></table>')
ENDIF    
*********Right menu
OUTPUT('<td id="rightcolumn" valign="top"><div class="box box-upcoming_events"><div class="box-title"> <table class="box-title"> <tbody> <tr>')
**********Right menu protion
OUTPUT('<td =""><span class="box-titletext">AkuAku l</span></td>')
OUTPUT('</tbody> </table></div></div>')
OUTPUT('<P><INPUT TYPE="submit"name="b1" VALUE="write"><BR></P>')
OUTPUT('Serach Menu Title<BR><INPUT TYPE="TEXT" NAME="T4" SIZE="14" MAXLENGTH="40">')
OUTPUT('<a><INPUT TYPE="submit"name="b1" VALUE="title"></a>')
OUTPUT('<P>Serach content<BR><INPUT TYPE="TEXT" NAME="T5" SIZE="19" MAXLENGTH="40">')
OUTPUT('<INPUT TYPE="submit"name="b1" VALUE="content"></P>')
OUTPUT('<P>Upload image file <input type="file" size="20" name="T6"><BR>')
OUTPUT('<INPUT TYPE="submit"name="b1" VALUE="Upload"></P>')
OUTPUT('<P>Show Image files <INPUT TYPE="submit"name="b1" VALUE="showimg"></P></td>')
OUTPUT('<div id="right_box" style="display: block;" class="box-data">' + RMTXT + '</div>')
RETURN
*****************************
*****************************
PROCEDURE WRITEMODE                コンテンツの編集結果の保存
*****************************
***send email
&&IF LEN(RTRIM(T17FORM)) > 0
&&send emal
&&ENDIF
**create new page program
DO SAVEIMG
SELECT 5
USE lmenu
MAINTITLE = ""
TOPNAME = ""

LOCATE FOR PAGENAMEII = GPARENTS           メニュー処理の始まり
IF PAGENAMEII = GPARENTS
    MAINTITLE = TOPTITLE
    TOPNAME = TOPMENU
ENDIF
**Read skeltonn program
**need to check same name
prgname = LOWER(RTRIM(T1FORM))
Header = ""
Header = "#!/usr/local/aragoi/aragoi.exe " + prgname  + CHR(10)
Header = Header + 'THISPAGE = "'+ prgname +'"' + CHR(10)
Header = Header + 'PAGETITLE = "' + RTRIM(T2FORM) + '"'  + CHR(10)
Header = Header + 'AUTHOR = "' + AUTHOR  + '"'  + CHR(10)
Header = Header + 'WEBURL = "' + WEBURL + '"'  + CHR(10)
IF T10FORM = "yes" &&Create new group
    Header = Header + 'MAINMENUTITLE = "' + RTRIM(T11FORM)  + '"'  + CHR(10)
ELSE IF EMPTY(TOPNAME)
    Header = Header + 'MAINMENUTITLE = "' + MAINMENUTITLE + '"'  + CHR(10)
ELSE
    Header = Header + 'MAINMENUTITLE = "' + RTRIM(MAINTITLE)  + '"'  + CHR(10)
ENDIF
SELECT 1
USE content INDEX pagename, laccess, topmenu ALIAS maindb
SEEK("skelton")
Header2 = Header + pagesource
APPEND BLANK                 && add record
**need to check space
REPLACE PAGENAME WITH prgname     
REPLACE PAGETITLE WITH RTRIM(T2FORM)
REPLACE PAGESOURCE WITH Header2
REPLACE MMTXT WITH T3FORM
IF T12FORM = 'yes'     && Leftmenu no
REPLACE LEFT WITH .F.
ELSE
REPLACE LEFT WITH .T.
ENDIF
IF T13FORM = 'yes'
REPLACE RIGHT WITH .F.
ELSE
REPLACE RIGHT WITH .T.
ENDIF
IF T14FORM = "yes"
REPLACE BOTTOM WITH .F.
ELSE
REPLACE BOTTOM WITH .T.
ENDIF
IF T16FORM = 'yes'
    REPLACE PRIVATE WITH .T.
ENDIF
REPLACE CREATEDATE WITH DATE()
REPLACE LASTMODIFY WITH DATE()
REPLACE CRUSERNAME WITH "ADMIN "
REPLACE CRREMOTEIP WITH USERIP
&&REPLACE CMAIL WITH "admin@soupacific.com"
REPLACE LMUSERNAME WITH "ADMIN"
REPLACE LMREMOTEIP WITH USERIP
REPLACE LMMAIL WITH "admin@soupacific.com"
REPLACE LASTACCESS WITH DATE()
REPLACE MAINMENU WITH .T.
REPLACE LANGUAGE WITH "MULTI"
&&REPLACE TOPGROUP WITH  
&&REPLACE SUBGROUP WITH  
&&REPLACE PAGEGROUP WITH  
&&REPLACE BELONGTO WITH
USE

**Add menu item                 サブメニュの作成
SELECT 5

GO BOTTOM
NUMOFTOP = NUMTOPMENU
APPEND BLANK
REPLACE PAGENAMEII WITH prgname
IF T10FORM = "yes" &&Create new group
    REPLACE TOPMENU WITH prgname  
    REPLACE TOPTITLE WITH RTRIM(T11FORM)
    REPLACE NUMTOPMENU WITH (NUMOFTOP + 1)
ELSE IF EMPTY(TOPNAME)
    REPLACE TOPMENU WITH gparents
    REPLACE TOPTITLE WITH MAINMENUTITLE
    REPLACE NUMTOPMENU WITH NUMOFTOP
ELSE
    REPLACE TOPMENU WITH TOPNAME  
    REPLACE TOPTITLE WITH RTRIM(MAINTITLE )
    REPLACE NUMTOPMENU WITH NUMOFTOP
ENDIF
REPLACE MENU WITH RTRIM(T7FORM)
IF T10FORM = "yes" &&Create new group       新規メインメニュの作成
USE menuorder
GO BOTTOM
TOPMENUNUM = MENUORDER
APPEND BLANK
REPLACE MENUORDER WITH (TOPMENUNUM + 1)
REPLACE MENUTITLE WITH RTRIM(T11FORM)
REPLACE PAGENAME WITH prgname
REPLACE CREATEDATE WITH DATE()
REPLACE LASTMODIFY WITH DATE()
&&REPLACE CRUSERNAME WITH "ADMIN "
REPLACE CRREMOTEIP WITH USERIP
REPLACE CMAIL WITH "admin@soupacific.com"
REPLACE LMUSERNAME WITH NAME
REPLACE LMREMOTEIP WITH USERIP
REPLACE LMMAIL WITH "admin@soupacific.com"
&&&REPLACE LASTACCESS WITH DATE()
USE
ENDIF

DO rewrite2.prg with prgname
RETURN
********************************
*****************************
PROCEDURE SAVEIMG            イメージファイルの保存 "../httpddocs/images/"  はディレクトリ、 ここではaragoiの処理なので
                             www........では記述しない。
*****************************
IF EMPTY(imagename)
  RETURN
ENDIF  
maxfilesize = 10000000
size = GETENV("CONTENT_LENGTH")
IF VAL(size)< maxfilesize
  IF .NOT. FILE("../httpddocs/images/" + imagename)
    GETPUT("T6", "../httpddocs/images/" + imagename)
  ELSE
    IF "jpg" $ imagename .OR. "JPG" $ imagename
      tempname = FUNIQUE("../httpddocs/images/????????.jpg")
      GETPUT("T6", tempname)
    ELSEIF "png" $ imagename .OR. "PNG" $ imagename
      tempname = FUNIQUE("../httpddocs/images/????????.png")
      GETPUT("T6", tempname)
    ELSEIF "gif" $ imagename .OR. "GIF" $ imagename
      tempname = FUNIQUE("../httpddocs/images/????????.gif")
      GETPUT("T6", tempname)
    ELSEIF "bmp" $ imagename .OR. "BMP" $ imagename
      tempname = FUNIQUE("../httpddocs/images/????????.bmp")
    ENDIF
    IF EMPTY(tempname)
      imagename = "This uploaded file type is not supported!"
    ELSE
      imagename = tempname
    ENDIF  
  ENDIF  
ENDIF
RETURN
*****************************
Advertisement Expand/Fold