Professional Documents
Culture Documents
http://www.cmsimple.dk/
I nstaller'sManual
I NSTALLI N GCM SimpleAnoverview .
ThesepagesexplainhowyouinstallCMSimpleonyourclientsmachine.Theyexplainhowto downloadthedistribution,customisethelayoutanduploadthefilestoaremoteserver.They explainhowtousethescriptinglanguageandhowtoincludesomewellknownandreliableadd ons. Userscontributetoasupportforumandaselectionofcommonlyaskedquestionsareansweredin theFAQs. CMSimpleisdesignedtorunonmanybrowsers,undermanyversionsofPHPundertwooperating systems.NotsurprisinglyCMSimplecannotanticipateallthechangesandrestrictionsthatmaybe imposedonyoubyyourwebserver. Pleasereportanybugsyoumayfindtohttp://www.cmsimple.com/forum/viewforum.php?f=8 Pleasegivefulldetailsofyourserver,php,andbrowserversion.
Submenu
Uploadingthefiles Updatingtonew est Filepermissions Securityissues W W W Authenticate Theeditingenvironment Theconfiguration Theonlineeditor Creatingyourpages Creatingamultilanguagesite Changingthelayout GettingXHTM Loutput CMSimpleScripting Literature FA Q
Uploadingthefiles
DownloadtheZIPfilefoundhereonthedownloadspageontoyourlocalmachine. Unzipit,andFTPallthefoldersandfilestoyourwebserver. Youwillusuallyputthefilesintothe'html'filesdirectory.Thismaybecalledhtmldocorsomething similar.SomeISPsmayrequireyoutouseaa'cgi'filesdirectory.
Thefilesandfoldersare:
config.phptheconfigurationofthesite image.phptheimagesusedforthemenuandeditorbuttons log.txttheloginlog cms.phpthecontentmanagementsystem WithCMSimple2.6cms.phphasbeensplitupintothesefiles: cms.phpitispossibletorunasastandaloneapplicationwithnoadmininterfaceetc. adm.phpadmininterface login.phploginprocedures mailform.phpthebuildinmailform gbook.phpthebuildinguestbookNOTSPAMPROOF! oedit.php thebuildineditor search.phpsearchprocedures SUBFOLDER:cmsimple/ languages Here,thelanguagefilesarekept.Eachlanguageisgivenatwoletternamewiththeextension 'php',ie.en.php.ThedefaultlanguageforthesiteisEnglish,butthismaybechangedinthe config.php.Eachofthesefilescontainslanguagespecifictextstrings,suchaserrormessages, andtextstubsfortheeditor. FOLDER:content content.htmthecontentisstoredinthisfile. guestbook.txtthecontentoftheguestbook .htaccessmakesthefolderunavailablethroughhttpbutONLYonLinux! Later,aseriesofbackupfileswillbestoredinthisdirectorytheywillhavenameslike 20040111003159thetimeoftheircreation. FOLDER:dow nloadsthefoldertoplacefilesavailablefordownload.Thefilesherewill automaticallybeavailablethroughthelinkselectboxintheeditor. FOLDER:imagesthefoldertoplacetheimagesforthesite.Thefilesherewillautomaticallybe availablethroughtheimageselectboxintheeditor. SUBFOLDER:images/ flagsneededforamultilanguagesetup. SUBFOLDER:images/ editor(optional)Ifasubfoldereditorissetupinimages,theeditor willtrytogetitsbuttonimagesfromthisfolderotherwisetheeditorwillgettheimages storedincmsimple/ image.php. FOLDER:templates Thelayouttemplatesarekepthere.Tocreateyourowntemplate,makeacopyofthedefault templatefolderandrenameittosomethingelse.Younoweditthenewfiles.Youmayalso downloadtemplatesfromthirdpartysources.Youmayselectthenewtemplatebyeditingthe cmsimple/ config.phpfile.Thiscanalsobechangedonlinebyselectingthe[SETTINGS]Edit Configuration,orevendynamicallyusingCMSimplescripting. SUBFOLDER:templates/ defaultthedefaultlayout stylesheet.cssthestylesheetforthetemplate template.htmtheHTMLlayouttemplate SUBFOLDER:SUBFOLDER:templates/ default/ imagesLayoutspecificimages. SUBFOLDER:SUBFOLDER:templates/ default/ menuUsedforthe(TOC)tableofcontent graphics.Ifthesubfolder
Updatingtonew est
Toupdatefrom2.02.5totoaversionhigherthanversion2.5youwillneedtoreplace ./cmsimple/cms.phpwiththesefiles,whichcms.phphasbeensplitinto: cms.phpitispossibletorunasastandaloneapplicationwithnoadmininterfaceetc. adm.phpadmininterface login.phploginprocedures mailform.phpthebuildinmailform
gbook.phpguestbookNOTSPAMPROOF!Removedfromv.2.8. oedit.php thebuildineditor search.phpsearchprocedures functions.phpadditionalfunctions(Fromversion2.8) Withtimetherehasbeenaddedandremovedsomeoptionalvariablesettingstotheconfig.php file: Version2.4: $cf['editor']['external']maybesettotinymce,htmlareaorfckeditor $cf['xhtml']['endtags']toturnonasign"true" $cf['xhtml']['amp']toturnonasign"true" Inversion2.4$cf['htmlarea']['folder']wasremovedfromdefaultconfig.php Inversion2.5$cf['meta']['imagetoolbar']="no"wasremovedfromdefaultconfig.php Version2.6 $cf['uri']['length']Maxuri(setto200) $cf['scripting']['regexp']ItispossibletochangetheregularexpressionusedforCMSimple scriptingifnotset,thisisused:"\#CMSimple(.*?)\#"
Otherchangeswith2.6:
ReadableURLsforothercharsets:Maybesetwith$tx['urichar']['new']and$tx['urichar']['org']in languagefile.Clickhereformoreinfo. Updatingfrom2.7to3.1 Therearelotsofchangesbetweenversion2.7and2.8. Youmayeasilyupdatefrom2.7byoverwritingthefilesin./cmsimplefolderexcept config.php(thefilewithyoursettingstherearenochangesinthisfileinthenewversion). Thereareseveralthingswhichshouldbechangedmanuallyinyourconfig.phpreadmorehere aboutthechangesinconfigfile. Variablesnotusedanymoretobedeletedinlanguagefiles: $tx['menu']['guestbook'] $tx['title']['guestbook'] $tx['guestbook']['maxlength'] $tx['guestbook']['posted'] $tx['guestbook']['dateformat'] $tx['guestbook']['from'] $tx['guestbook']['sendbutton'] $tx['filetype']['guestbook'] $tx['help']['guestbook_maxlength'] $tx['help']['security_wwwaut'] $tx['help']['files_ftp']
Tobeaddedinlanguagefiles(seeen.phpforlocation):
$tx['mailform']['message']
Tobeaddedin$tx['editor']['buttons']inlanguagefiles(seeen.phpforlocation):
["inserthorizontalrule","HorizontalRule","InsertHorizontalRule"], ["removeformat","RemoveFormat","Removefontstyleformats"], Updatingfrom2.8/ 2.9/ 3.0to3.1
Youmayeasilyupdatefrom2.8/2.9/3.0to3.1byoverwritingthefilesin./cmsimplefolderexcept config.php(thefilewithyoursettingstherearenochangesinthisfileinthenewversion).
Filepermissions
AllfoldersyouwishtobeabletoeditfromCMSimple,hastobesetwritable.Thecontentfolder(s) hastobesetexecuteableinordertocreatebackup. ForLinux:Ifyougivefullrights(chmod777orinWS_FTPbothread,writeandexecutefor Owner/Group/All)toboththefoldersandthefilesplacedinthesefolders :cmsimple, cmsimple/ languages,content(alsosubfolderstolocalizedfolders)andthe templates/ default,everythingshouldworkfine.Alsoimagesanddow nloadsshouldhavefull rightsifyouwanttheusertobeabletodofilemanagement. OnWin32theuserIUSR_[SERVERNAME]musthavefullrightstothefilesandfolderslistedabove. REM EMBER:Changetheloginsettingsintheconfig.phpfilethiscanbedoneunder[SETTINGS] afterlogin.Thedefaultloginis'test'(ifwwwautissettrue,theloginisadmin/test).
Securityissues
P ASSW ORD
Changetheloginsettingsintheconfig.phpfile! Thefirsttimeyoulogin,changetheloginsettingsintheconfig.phpfile. Fromtheeditor,choose[SETTINGS],chooseeditconfigurationfindthecorrectboxandtypein yourchangedpasswordandusername.[SAVE] Note:passwordisbeforeusername. Whenavailable,youshouldusewwwauttogetthebestprotectionavailablereadmoreabout wwwaut.
LOGI NLI NK
Forsecurityreasons,youcouldremovethe'login'linkintheHTMLtemplate.Whenyouwantto edit,youthentype'&login'attheendoftheURL.i.e. http://yoursite?yourpage&login Thismakesitlessapparent,thatyouareworkingwithanonlineeditingsystem. Asitisnow,thelogininformationisstoredinacookieincleartext,anditcould,intheory,be misusedbysomeevilpersonmonitoringyourinternettraffic. Securityistobeimprovedinfuturereleases,ie.passwordencryption.
.htaccess
ForApacheusers:Pleasecheck,thatthefolder/ cmsimple/ config.phpisprotectedbythe .htaccessfile! OnWin32youwillhavetoconfigureApachetouse.htaccess.ItisNOTpossibletouse.htaccess onMSIIS.
SUGGESTI ON S
Suggestionsonhowtoimprovesecurityondifferentsystemswillbe
W W W Authenticate
Forbetterpasswordprotectionitisadvisedtousesecuritytypewwwaut. OnLinuxwherePHPisinstalledasanApachemodule(notaCGI),thisfeaturewillworkjustby settingsecuritytypetow w w autundertheconfigurationsettingsofCMSimple. WithCMSimple2.7itisalsopossibletomakewwwautworkon:
How tocheckServerAP I
YoucancheckthatPHPisinstalledasanApachemodule,bylookingatphpinfo.Download phpinfo.phporcreateaphpfilewiththiscontent: <?phpechophpinfo()?> Runthefileoverthewebserver,bycallingie.http://www.yourdomain.com/phpinfo.php Theline"ServerAPI"intheresultingpagemustlooklikethis: ServerAP I Apache
RewriteEngineon RewriteRule.*[E=REMOTE_USER:%{HTTP:Authorization},L]
Setwwwautto'true'undertheconfigurationsettingsorbysetting $cf['security']['wwwaut']="true"incmsimple/config.php. Ifitgivesanerroronthewebsiteoritdoesnotallowyoutologin,youareprobablynotallowedto use.htaccessfilesand/ortheRewriteEngineatyourwebhotel.
W w w autw henI SS
1.InwebserveradmingotoWebSiteProperties>File/DirectorySecurity>AnonymousAccess dialogboxcheckthe"Anonymousaccess"checkboxanduncheckanyothercheckboxes(uncheck "Basicauthentication,""IntegratedWindowsauthentication,"and"Digest") 2.Inwebserveradminunder"CustomErrors"selecttherangeof"4011"through"4015"and select"SettoDefault". 3.Setsecuritytypetow w w autundertheconfigurationsettingsofCMSimpleandsave. Ifitdoesnotwork,checkthatPHP>4.3.3andinphp.inithat"cgi.rfc2616_headers=0"
Theeditingenvironment
CMSimpleincludesaIntegratedEditingEnvironmentthatisrevealedwhentheusersuccessfully logson. Inthemainpanelappearsthearowofchoicebuttonsandbelowthem,fullWYSIWYGeditor. Thechoicebuttonsare
NormalMode:totogglebacktotheNormalView. ValidateLinks:tocheckthesiteforbrokenlinks Images:Usedtoseealltheimagesyouhaveuploaded(andthepagethatusesthem), givinganoptiontodeleteunwantedimagesandthechancetouploadmore. Downloads:Listsfilesyouhaveavailabletodownload,withanoptiontodeleteunwanted filesandthechanceuploadfurtherfiles. Settings:Givesawaytoeditsystemfiles Editconfiguration Editlanguage Editstylesheet Edittemplate Editguestbook Viewlog Contentvieweditdownload
o o o o o o
Help:Displaysthesepages. Logout
Validatelinks.
Thewholesiteisparsedandcheckedandasinglereportisgenerated.Therearenofurther options.
I mages
Thisoptionallowsyoutoviewallthegraphicfilesyouhaveuploaded. FurtherOptions.
Youcandeletefilesontheserver. Youcanbrowseyourlocalmachine,andselectafiles.Thesemaybeuploaded.
Dow nloads
TheDownloadsfolderstoresallthefilesyouwishtomakeavailablefortheusertodownload.This optionlistsallthefilesyouhaveuploaded. FurtherOptions.
Youcandeletefilesontheserver. Youcanbrowseyourlocalmachine,andselectafiles.Thesemaybeuploaded.
Settings:EditConfiguration
PleaseseeTheconfiguration
Settings:EditLang
CMSimpleisamultilingualproductallthetextthatyouseewillchangewhenyouchange language.Togiveevengreaterflexibilityyoucaneditallthetextstringsinyourcurrentlanguage byselectingthisoption. Makethechangesyouwant,saveusingthebuttonattheverybottomofthepage.
View Log
Thisshowsatextfileofthelogons.Therearenooptions.
Theconfiguration
ThesettingsfortheCMSimpleinstallationcanbesetinthefile./CMSimple/config.phporbyusing the"Editconfiguration"formwhichisfoundunderthemenuitem"SETTINGS"(onlyvisiblewhen loggedin). Thesettingsnamesrefertovariablenamesintheconfig.php,ie.security_passwordissameas $cf['security']['password']
Explanationofthevariables
$cf['security']['passw ord']=" test" Thisistheloginpassword,defaultsetto"test".Ifyouchangeit,whenyouareloggedin,youneed tologinagainusingthenewpassword.Ifyourbrowser'scacheisturnedon,youmayneedto emptythebrowser'scookiecache. $cf['security']['type']="page" (Onlyavailablefromversion2.8replacesthe $cf['security']['w w w aut']) Thereare3optionsforsecuritytype: 1:pagegivesaloginpage(default) 2:javascriptgivesajavascriptloginprompt 3:w w w autgivesanWWWAuthenticatepromptdonotusethis,unlessyouknow,whatyou aredoing. Inallinstances,theloginprocessisstartedbyadding& logintotheURLandhittingENTER.
$cf['meta']['keyw ords']="CMSimple,ContentManagementSystem,php" KeywordsforSearchEngineOptimization. $cf['meta']['description']="CM Simpleisasimplecontentmanagementsystemforsmart maintainanceofsmallcommercialorprivatesites.I tissimplesmallsmart!I tisFree Softw arelicensedunderAGP L" Descriptionofthesiteusedbysomesearchengines. $cf['backup']['numberoffiles']="5" Thenumberofoldcontentfilestobestoredinthe./contentfolderasbackup.Pleasenote, thatbackupisonlyactivated,whenyouhit"LOGOUT"intheeditmenu. $cf['images']['maxsize']=" 150000" Themaximalsizeofimagesallowedtobeuploadedbytheuploadfunctionunder "IMAGES"(onlyadmin).Specifiedinbytesthedefaultsettingequalsto150KB. $cf['dow nloads']['maxsize']=" 1000000" Themaximalsizeoffilesallowedtobeuploadedbytheuploadfunctionunder"DOWNLOADS" (onlyadmin).Specifiedinbytesthedefaultsettingequalstoalmost1MB.Serverrestrictions mayalsoapplybothinphp.iniandinApachesetttings(moreinfo). $cf['mailform']['email']=" " Ifthisisset,themailformwillbesetactive.AfewwebhotelsdonotallowmailingthroughPHP. $cf['guestbook']['maxlength']=" " (Notusedanymorefromversion2.8) $cf['editor']['height']=" (screen.availHeight)400" TheheightoftheinbuildWYSIWYGeditor(OEdit)specifiedinjavascriptastheheightofthe browserwindowminus400px. $cf['editor']['external']=" " Ifyouwanttouseanexternaleditor,itmustbespecifiedherereadmorehere. $cf['menu']['color']=" 000000" IfyouusetheimagesfortheTableofContensstoredinthefile/cmsimple/images.phpyoucanset thecoloroftheiconsbyaHEXvaluehere.The'default'templateinCMSimpledistributionusesthis feature.(Instylesheet,lookforurl(../ ../ index.php?image=doc)) $cf['menu']['highlightcolor']=" 808080" Sameasabovethisisthecolorfortheiconfortheselectedpage. $cf['menu']['levels']=" 3" (Onlyavailablefromversion2.8) Theheadinglevelstosplitintoseperatepages.CMSimplewascreatedtoonlysplitinto3 levels,andnormalythisisalsothemostrecommendable.Makingadeeptreestructuremaynotbe goodusability.Ifyouchangefrom3to4,youwillhavetoreplaceallyourH4headingsusedfor internalheadingstosomeotherheadingformating.AdditionalHbuttonsforbuildineditorcanbe addedundereditor_buttonsinlanguageconfiguration.
$cf['uri']['seperator']=" :" ThecharacterusedforseperatepagenamesinURL. $cf['uri']['length']=" 200" ThelengthoftheURItomatchthisissettomakeiteasiertogetholdofapage,ifyouby mistakeformattheentirecontentsofapagetoaheading. $cf['xhtml']['endtags']=" " SettotrueifyouwantendtagsinCMSimplegeneratedoutput. ThisisNOTappliedtothecontentsgeneratedineditor. $cf['xhtml']['amp']=" true" Settotrueifyouwant&sinCMSimplegeneratedoutputtobewrittenas&ie.inURLs. ThisisNOTappliedtothecontentsgeneratedineditor. $cf['plugins']['folder']=" " Toactivateanaddonorpluginloaderyoumustspecifythepluginsfolder,normallywiththevalue plugins $cf['functions']['file']=" functions.php" (Onlyavailablefromversion2.8) BackwardcompatibilityforDHTMLmenus(frombeforeversion2.8)andfunctionsgeturl,geturlwp, autogalleryandnewsbox. Thiscanvariablemaybesetemptyor/andfilebedeletedforoptimization,ifnoneofthese functionsareused. $cf['scripting']['regexp']=" \ #CM Simple(.*?)\ #" TheregularexpressionusedforCMSimpleScripting.
Theonlineeditor
10
How HeaderTags<h1><h4>areused.
<H1>,<H2>,<H3> InCMSimple<H1>,<H2>,<H3>areusedtocreatenewvirtualpages,subpagesand subsubpages.Whenyousavethepage,anewvirtualpageiscreated.Thetextinthetagbecomes thepagetitleandappearsinthetableofcontentandtheinternallinkslist.Thistextmustall appearonthesameline. <H4> <H4>isanormalsubheadingformat,whichdoesnothaveanyspecialmeaning.<h5><h6>are notprovidedbytheeditorbutmaybeenteredinHTMLmode.
Beaware,Intheseexamplesdasheshavebeenaddedtothetagstofooltheparser,tostopthem reformattingthesepages.
I ssues
Thiseditorlackstableediting,andsomeformatting,ifyouneedthesefacilitiesthenyoumust installanalternativeeditor. Theonlineeditorworkswithmostbrowsersbutnotall.LookattheRequirements. Mozillapreventsthepastefunctionsintheeditorbutthe[Edit][Paste]optiononthebrowserstop barworks. Allstylesarecontrolledbythecurrentstylesheet.
Creatingyourpages
AllthetextcontentofCMSimpleisstoredinasingleHTMLfile.CMSimpledeliverstherelevant pagetoyouruser'sbrowser. Theheadingtags<H1>,<H2>and<H3>areusedtosplitupthecontentfile.Itmightbealittle hardtogetusedtothisconcept,butwhenyoudo,itisreallyeasytocreatenewpagesand subpages.
Usingtheheadings
AH1,H2orH3headingwilldynamicallysplitthetextinto'virtualpages'andputanewiteminto themenuatthecorrectlevel. Alistofthesubpagesisdisplayedatthebottomofthatpage.Themenuisdisplayedasatableof contents. AH4headingisusedasaheadingwithinapage.Noothertagshavespecialmeanings
11
Creatingamultilanguagesite
P leasenote:W henusingthedow nloadatCMSimple.COM youdefinethelanguagestobe setupinthedow nloadprocessandtheinstructiononthispageisnotrelevant. Ifyouwantpagesinotherlanguages,copythe2langfoldertotherootoftheCMSimple installation.Renamethefoldertoatwoletternameofthetargetlanguage.Checkthereisa languagefileincmsimple/languagesfolderwiththesametwoletternameandaflagfilein images/flags. The2langfolderalsohasaindex.phpthatcallscmsimple/cms.phpandasubfoldernamed contentwhichactslikethecontentfolderintherootofCMSimple. OncethisisdoneCMSimplewillautomaticallyfindthenewcontentfileandyoucanstartadding thetext.
Changingthelayout
Thelookandfeelofyoursiteiscontrolledbyafiletemplate.htmanditsassociatedstylesheet.css. Manyusersarehappytousethedefaulttemplate,butyoucanchooseothertemplatesorwrite yourown.Thenameoftheselectedtemplateisstoredintheconfig.phpfile.Choose[SETTINGS] chooseeditconfiguration. Youcanmakesmallchangesbyeditinganexistingtemplate.Choose[SETTINGS]chooseedit stylesheet,oredittemplate. YoucanwriteatemplatefromscratchusingyourfavouriteHTMLeditor.
Beaware:ItisalegalreqirementtoincludethePoweredbyCMSimplelinkinyourtemplatesource codeunlessalicencehasbeenpurchased.
12
template.htm
ThetemplateispureHTMLbuiltusingtables,andwithPHPfunctioncallstothecms.php.
Functioncalls
Someofthefunctioncallsareimportantandcan'tbeleftoutie.thehead(),onload(),toc(), editmenu()andcontent().Butifyouprefernottohaveadocumentsitemaplink(),printlink(), locator(),submenu()orpreviouspage()/top()/nextpage()youmayremovesomeofthesecodes.
head():necessary:printslinktostylesheet,metainformation andpagetitle onload():necessary:requiredinthebodytaginordertomakethe editorfunction toc():necessary:printsthetableofcontents editmenu():necessary:inadminmodeprintsthemenuoftheavailable adminfunctions content():necessary:themainpagecontent loginlink():advised:ifnotloggedtothesystem,displaysalogin link languagemenu():advised:printslinksforchangingthelanguage lastupdate(:advised:writesthedateandtimethecontentwaslast edited sitename() :optional:printsthesitename searchbox():optional:printsasearchbox sitemaplink():optional:printsthesitemapinthecontentfield printlink():optional:displaysthepageinaprinterfriendlyformat legallink():required:displaystheCMSimpleLegalNotices mailformlink():optional:printsalinktoamailformforgiving feedback submenu():optional:printsalinktothefollowingpagesif available previouspage():optional:printsalinktothepreviouspage top():optional:printsalinkto#TOP nextpage():optional:printsalinktothenextpage locator():optional:printsthelocationthread newsbox():additional:printsthecontentsofanamedhiddenpage
toc()function(TableOfContents)
toc()returnsalllevelsinTOC toc(x)returnsonlylevelxfromTOC,ie.toc(1) toc(x,y)returnsonlyxylevelsinTOC,ie.toc(2,3)
lastupdate()function
lastupdate(null,4)returnsstringwith4hourstimezonecorrection lastupdate("true")returnsthelastupdatestringwithoutlinebreak
ATemplateExample
Below,isanexamplethatshowsthecellsofatableandwherethefunctionscanbeplaced.
Tip:Studythetemplatesthatcomewiththedistributionbeforeyoustarttodesignyourown. top.jpgisstoredinthevariable$pth['folder']['templateimages']
13
Inhead:inserthead(). Inbodytag:insertonload()
top.jpg searchbox()
sitename()
toc()
sitemap link() printlink() mailfo rmlink() guestbooklink () languagem enu()
loginlink()
lastupdate()
P ow eredby CMSimple
previouspage() top()
nextpage()
stylesheet.css
Thestylesheetislocatedintemplatefolderforthelayout.Itisusedtohandleallthestylesonthe site. Thestylesheetdefinesthefontpropertiesofexistingtags.
.sitename .locator .navigator .menulevel1,.menulevel2,.menulevel3 .sitemaplevel1,.sitemaplevel2,.sitemaplevel3 .submenu .menu .login .edit .search .copyright
Thesecontainerclassesareused.
14
Tw oskeletontemplates
Atemplateusingtags.
Thistemplateservesasastartingpointforanyonewhowishestowriteatemplatefromscratch.It containssnippitsoftextthatwillappearinabrowserifitisrunonyourlocalmachine.Thereare manyhtmltutorialsandhtmleditorsontheweb.
Table1
Table2 Table3Search
Sitename: Table4
Table5
toc: sml: prl: mfl: gbl: lan: log: lup: Table6 P ow ered by CMSimple edit: cont: subm:
15
Atemplatenotusingtag s.
Ifyouwishtodoallyourformattingincssthistemplateisastartingpoint.Thecsscodeis includedbutwouldlaterberemovedtothestylesheetfile.
<pre> ... <style> body{ margin:9px9px09x padding:0} #level0{ background:#FC0} #level1{ marginleft:143px paddingleft:9px background:#FFF} #level2{ background:#FFF3AC <spanclass="note">position:relative</span>} #level3{ marginright:143px paddingright:9px background:#FFF} #main{ background:#CCC} #topBar{ background:#FC0} #advBar{ background:#FFF3AC} #tipDay{ float:right width:175px background:#FFF3AC} #lftBar{ position:absolute width:143px top:9px left:9px} #rgtBar{ position:absolute width:143px top:0 right:0} </style> ... <body> <divid="lftBar"> Thisistheleftnavigation... </div> <divid="level0"> <divid="level1"> <divid="topBar"> Thisisthetopnavigationbar. <divid="advBar"> Thisistheadvertisementbar. </div> </div> <divid="level2"> <divid="rgtBar"> Thisistherightnavigation... </div> <divid="level3"> <divid="main"> <divid="tipDay">
16
Thisisthe"Tipoftheday"... </div> Thecodeyouarereading. </div> </div> <spanclass="note">"rgtBar"couldgohereusingthesame style</span> </div> </div> </div> </body> ... </pre>
GettingXHTMLoutput
WithCMSimple2.4youmaysetxhtml_endtagsandxhtml_ampto'true'inordertogetvalid XHTMLoutput.ThisistobesetunderSettings>Configuration(orinconfig.php). Pleasenote,thatinadminmodesomenormalHTMLcodeisstillused.
CMSimpleScripting
W hatisCM SimpleScripting
Thisallowsyoutoaddscriptingtoyourcontentpages.Thescriptiswrittenonasingleline enclosedbetween#CMSimpleand#.Thecodeusedfor'CMSimplescripting'isnormalPHP. Twotechniquesarecommonlyused,thereplacementofavariable,andtheuseofthepreg_match function.Exceptionsarethehideandremovecommands,whicharehardcodedintothecms.php sourcecode. TheCMSimplecodewillbeshownonlyintheeditingmode,butonthesehelppagestheparserhas beentrickedbyinsertingafonttagaroundthefirst'#'numsign.Theexecutingcodeisnotshown inNormalmode,oronthefinishedpage. Normally,onlyone#CMSimplestringcanbeusedineachpagethoughthecontentsofseveral scriptsmaybemergedintoonescript.
# CMSimplesomecode#
CMSimpledetectsthestring'#CMSimple'andinterpretsallthecodeuntilthefinal'#'. Manyusefulexamplesareshownonthenextfewpagescopyandpastethemandthenremove thetags.
Forexample,thecodebelowhaschangedthesitetitleto'hidude'(butonlyonthispage). #CMSimple$GLOBALS['cf']['site']['title']='hidude!'#
17
Cutandpastethislineintoyourpage,removethetwo<font>tagssaveandchangetonormal modeandseehowitlooksforyou.
Important.Whenyoucopy'n'pasteCMSimplecodefromthesepages,youmustremovethefont tags!Dothisinediting(HTML)mode
Changingglobalvariables M etatags Hidepage Removepage Lastupdate P lacingaFunction Counter geturl() I nsertfromfile I nsertfromphpfile Entirecontent Bannerrotation Changingtheheading Changingthetemplateonthefly Custommailform P hotogallery Calendar Relocate
Changingglobalvariables
Thecodeonthispagehaschangedthesitetitleto'hidude'(butonlyonthispage). #CMSimple$GLOBALS['cf']['site']['title']='hidude!'# ItispossibletochangealmostallvariablesusedinCMSimplethisway! Lookatthefileconfig.phpandlanguages/ en.php.Furtherglobalvariablesaredefinedatthetopof thecms.phpsourcecode.
M etatags
Acommonaskedfeatureistheabilitytomakepagespecificmetatags.Forthispurposeyoumay setthevariables$keywordsand$descriptionwithCMSimplescripting. #CMSimple$keywords='some,words'$description='Apagedescription'#
Hidepage
Thefollowingcodehidesthispagefromthetableofcontentsand'thenavigationbar'onthe finishedpage.Thepagemaystillbeaccessedbytypinginthefullurl: #CMSimplehide# Thepagewillnotbesearchedanditwillnotbeshowninthesitemap.Thepagewillbevisibleto
18
edit,butnotintheeditor'snormalmode. The'locatorbar'onlyshowsthetitleofthatpage. ThetitleofthatpagewillstillbepartastheURLforsubpages.Youmaywantto'hide'allsubpages aswell. Whileineditmode,thepagestillappearsinthe'tableofcontent'. ItisnormallynotpossibletousetwoCMSimpleScriptingtagsonthesamepage,however #CMSimplehide#willworkwithanothertag,ifitisplacedasthefirsttagonthepage. HereisapagecontainingtheCMSimpleScriptingcodeusingthegeturl()function. #CMSimplehide# #CMSimple$output.=geturl('http://www.harteg.dk').chr(35).'CMSimple hide'.chr(35)# ThefirstpartofthecodeensuresthatthepagewillbehiddenfromtheTOCwhenviewed.
Removepage
Thepageistotallyremovedin'normalmode'.Itcanbeaccessedineditmode,shouldyouwishto reinstateit: #CMSimpleremove#
BeawarethattheURLofallsubpageswillchange!
Lastupdate
Youmayincludeafunctionlikelastupdate()fromcms.phplikethis: #CMSimple$output.=lastupdate()# PleasealsoseePlacingafunction. Thelatupdate()functionisdocumentedatthepageabouttemplate.htm.
Pleasenotice:Ifyoucopy'n'pastetheCMSimplecodefromthispage,pleaseremembertoremove thefonttag!
Lastupdate: July18.200809:29:15
P lacingaFunction
ToplacetheoutputfromtheCMSimpleScriptingfunctionataspecificplacewithinapage,you code'CMSimpleScripting'likethis: #CMSimple $output=preg_replace("/".chr(35)."CMSimple.*".chr(35)."/",lastupdate(),$c[$s])# Inthiscasethe#CMSimple....#isreplacedbytheoutputfromlastupdate()
19
*Target>Lastupdate: July18.200809:29:15<Target*
Counter
Toplaceapagecounteraspecificplacewithinapage,youcouldinsertacodelikethis: Numberofhits:#CMSimple$t="./count/".$u[$s].".inc" if($fh=fopen($t,"a+")){$i=fread($fh,filesize($t))fclose($fh)if($i<1)$i=0$i++if($fh=fopen($t,"w ")){fputs($fh,$i)fclose($fh)$output=preg_replace("/".chr(164)."CMSimple.*".chr(164)."/", $i,$c[$s])}}# Youmustcreatethefolder"./count"andgiveit777permissioninordertomakeitwork. Ifthatdoesn'twork,change"a+"to"r". Numberofhits: NOTE:Ononeserver(PHP4.3.9,CGI,Linux)thereisastrangeerrorwhenusingfopenwithouta spacebetweenfopenand(alsopreg_replacedoesnotworkinsteadthiscodemaybeused: #CMSimple$t="./count/".$u[$s].".inc"if($fh=fopen ($t,"a+")){$i=fread($fh,filesize($t))fclose($fh)if($i<1)$i=0$i++if($fh=fopen ($t,"w")){fputs($fh,$i)fclose($fh)$output.='Numberofhits:'.$i}}#
geturl()
SomefunctionshavebeenwrittenintoCMSimplesoCMSimplescriptingmayusethem,ie.the geturl()whichgrabsaexternallocatedwebpageandaddsittotheoutput: #CMSimple$output.=geturl('http://www.cmsimple.com/index.php?&print')# allow_url_fopenmustbeenabledinphp.iniforthistowork. Thereisalsoasimilarfunctionnamedgeturlw p()whichgetstheurlwithgivenparameters(eg. usedforthePhotogallery). FromCMSimpleversion2.8thisfunctionislocatedinthefilefunctions.php,whichisdefinedby $cf['functions']['file']intheconfiguration.
I nsertfromfile
Toplacethecontentsfromafilea specificplacewithinapage,youcould insertacodelikethis: #CMSimple $t="index.php"if($fh=fopen($t,"r ")){$output=preg_replace("/".chr( 35)."CMSimple.*".chr(35)."/",frea d($fh, filesize($t)),$c[$s])fclose($fh)}# (Tomakethecontentsofthisphpscriptviewable,therehasbeenatextareatagsetaroundit:)
20
I nsertfromphpfile
Toplacetheoutputfromaphpfileaspecificplacewithinapage,youcouldinsertacodelikethis: #CMSimple$output=preg_replace("/".chr(35)."CMSimple.*".chr(35)."/", geturl('http://www.cmsimple.dk/demo/?&print'),$c[$s])# ThisexamplereturnsthefrontpageoftheCMSimpledemoathttp://www.cmsimple.dk/?Demo
Entirecontent
Todisplaytheentirecontentofthesiteasasinglepage,youshouldinsertthisCMSimplecode: #CMSimple$output.=rf($pth['file']['content'])# Ifyoudon'twantittoeatCMSimplecode,use: #CMSimple
$output.=preg_replace("/".chr(35)."/s",chr(38).chr(35)."35",rf($pth['file' ]['content']))#
Bannerrotation
Toplaceabannerrotatoraspecificplacewithinapage,youcouldinsertacodelikethis: #CMSimple $t=array(array("bp_cmsimple.png","http://www.cmsimple.dk"),array("cms_powered.png", "http://www.cmsimple.dk/demo/"),array("cmsimple80x20.png","http://www.cmsimple.com/ forum"))$i=rand(0,count($t) 1)$output=preg_replace("/".chr(35)."CMSimple.*".chr(35)."/",chr(60).'a href="'.$t[$i][1].'"'.chr(62).chr(60).'img src="./images/'.$t[$i][0].'"'.chr(62).chr(60).'/a'.chr(62),$c[$s])#
N ew heading
#CMSimple$output=preg_replace('/(<h[13]>).*?(<\/h[13]>)/i','\\1Newheading\\2', $output)# Priortoversion2.4thiscodeshouldbeused: #CMSimple$output=preg_replace('/('.chr(60).'h[13]'.chr(62).').*.('.chr(60).'\/h[1 3]'.chr(62).')/i','\\1Newheading\\2',$output)#
Changingthetemplateonthefly
Makeacompletetemplate.htmandastylesheet,putthisinaseparatedirectoryinthetemplates folder. e.g.Makeadirectory'dandare'withitssubfoldersandthetwofilestemplate.htmand stylesheet.css.Designandsaveyourimages. Atthepagewhereyouwantthedifferentlayout,usethiscode: #CMSimple$cf['site']['template']="dandare" $pth['folder']['template']=$pth['folder']['templates'].$cf['site']['template'].'/' $pth['file']['template']=$pth['folder']['template'].'template.htm'$pth['file']['st ylesheet']=$pth['folder']['template'].'stylesheet.css'$pth['folder']['menubuttons' ]=$pth['folder']['template'].'menu/'$pth['folder']['templateimages']=$pth['folder' ]['template'].'images/'# Youhavetochange"dandare"tothenameofyourownfolder.
21
Custom mailform
AsimplemailformfunctionisprovidedinCMSimpleyouneedtoinsertanemailaddressunder Settingstoactivateit.
ThisCMSimpleScriptingcodewaswrittenforthebuildineditorandmaynotworkwithother editors.
Ifyouwishtocodeyourown,insertthisinHTMLmode: <TEXTAREAstyle="WIDTH:101.34%HEIGHT:275px"rows=14>#CMSimple//Custommailform forCMSimpleversion2.4 $reciever='somebody@somedomain.dk' $message="\n\nThisisanautomaticgeneratedmail.\n\nSincerely\nTheWebmaster" $recievermessage="\n\nThisisanautomaticgeneratedmail." //Defineyourfieldnamesandaddextralinesforselectoptions //Use_forspaces $fields=array('name','adress','zip','Define_your_own','email') $select['adress']=array('none','elephant','cow','tiger') $tx['mailform']['recieptnotsend']="Couldnotsendreciept." //DONOTCHANGECODEBELLOW! functionmtr($tk){if(is_array($GLOBALS['select'][$tk]))$t=select($tk)else$t='<input type="text"class="text"name="'.$tk.'"value="'.$GLOBALS[$tk].'">' return'<tr><td>*'.ucfirst(preg_replace('/\_/','',$tk)).'</td><td>'.$t.'</td></tr>'} functionselect($tk){$t=''foreach($GLOBALS['select'][$tk]as$i){$t.='<optionvalue="'.$i.'"' if($GLOBALS[$tk]==$i)$t.='selected' $t.='>'.$i.'</option>'}return'<selectclass="text"name="'.$tk.'">'.$t.'</select>'} $t=''$mailbody='' if($action=='send'){foreach($fieldsas$i){initvar($i)if($GLOBALS[$i]=='')$e.='<li>Youneedto write'.$ielse$mailbody.=$i.':'.$GLOBALS[$i]."\n"}if(!(eregi("^[_az09]+(\.[_az09 ]+)*@[_az09]+(\.[_az09]+)*(\.([a z]{2,4}))+$",$email)))$e.='<li>'.$tx['error']['mustwritemail'].'.'else if($e==''){initvar('txtarea')$mailbody.=$txtareaif(!(@mail($reciever,'Mailformfrom '.sv('SERVER_NAME'),$mailbody.$recievermessage,"From:".$email."\r\n"."XRemote: ".sv('REMOTE_ADDR')."\r\n")))$e.=tag('li').$tx['mailform']['notsend']else {$t=tag('p').$tx['mailform']['send'].tag('/p')if(!(@mail($email,'Copyofmailformfrom '.sv('SERVER_NAME'),$mailbody.$message,"From:".$reciever."\r\n"."XRemote: ".sv('REMOTE_ADDR')."\r\n")))$e.='<li>'.$tx['mailform']['recieptnotsend']}}}if($t==''||$e!=''){ $t='<formaction="'.$sn.'"method="post"><inputtype="hidden"name="selected" value="'.$u[$s].'"><inputtype="hidden"name="action"value="send"><tablecellpadding="5" cellspacing="0"border="0">' foreach($fieldsas$field)$t.=mtr($field) $t.='<tr><tdcolspan="2">Message:<br><t'.'extarearows="6"cols="40" name="t'.'xtarea"></t'.'extarea></td></tr>' $t.='</table><p><inputtype="submit"class="submit" value="'.$tx['mailform']['sendbutton'].'"></p></form>'} $output=preg_replace('/<textarea.*textarea>/is',$t,$c[$s])# </TEXTAREA>
P hotogallery
#CMSimple$output.=autogallery('http://www.cmsimple.dk/autogallery/')# allow_url_fopenmustbeenabledinphp.iniforthistowork. Autogalleryisavailablefromhttp://www.circle.ch/scripts/ Theautogalleryreadmefilegivesinstallationinstructionsthesehavebeencopiedandcustomised forCMSimpleuse.
22
./cache#./my_birthday_2002# ./templates/frame.jpg#"Birthday",3.10.2002
pointtoindex.phpandhavealookatthegallery. modifythecountofrows(6)andcolumns(3)ofthumbsintheindex.phpfile:
Calendar
CopythistextareainWYSIWYGmode: #CMSimple//CALENDAR //LISTYOURCALENDARITEMSBELOWINTHISFORMAT: //DDMMYYDescription //USE<BR>(SHIFT+ENTER)FORLINEBREAKINDESCRIPTION //ITEMSOLDERTHANCURRENTDATEWILLNOTBELISTED //Donotchangeincodebelowunlessyouknowwhatyouaredoing! //setlocale(LC_TIME,'da_DK') $empty=tag('p').'Thecalenderisempty.'.tag('/p') $t='' $reg="/((d*)(d*)(d*)(.*))/" $out="%A%e.%B%Y" functiontag($s){returnchr(60).$s.chr(62)} $arr=preg_split($reg,$c[$s],1,PREG_SPLIT_DELIM_CAPTURE)reset($arr)while (list($key,$value)=each($arr)){if(preg_match($reg,$value)){ $d=mktime(0,0,0,$arr[$key+2],$arr[$key+1],$arr[$key+3])$n=time()86400if(!preg_match("/ /",$d $n))$t.=tag('h4').ucfirst(strftime($out,$d)).tag('/h4').tag('p').preg_replace($reg,"$5",preg_replace ("/".tag('[/]?p')."/i","",$value)).tag('/p')}}
23
Relocate
Relocate HowcanIautomaticallyredirectavisitortopagexwhenhevisitspagey?Both,pagexandpage y,areCMSimplepages. Answer: Onpageyset #CMSimpleheader('Location:index.php?x')# aslinejustafternameofpage Sample1: <H1>Fromhere</h1> #CMSimpleheader('Location:index.php?To_here')# Sample2: Thiswillbring'Current_News'intheNewsbox #CMSimpleheader('Location:index.php?News:Current_News')#
Literature
Onlinearticles
ClemRutter:CMSimple.Maintainingtheschoolwebsiteandanexcusetoplaywithcss! PublishedintheACITTjournal,TeachingICT,No5:Winter2004.DownloadasPDF(185.5KB)
P rintedmaterial
BrittMalka:BygetwebsitemedCMSimple.ForlagetLibris.Purchase.(InDanishOnly)
FAQ
HereareareanswerstosomeofthequestionsthathavebeenaskedattheCMSimplesupport forum.
Submenu
Changingthemenu Stoppinguserschangingthesettings Hidingthelogin I ncludingfiles M akinganew sbox Addingaforumtoasite. I consforprintlinks I tdoesn'tw ork! P ricing
24
Changingthemenu
li.doc{lineheight:1.4paddingleft:15pxbackgroundimage: url(menu/ document.gif)backgroundrepeat:norepeat} li.docs{lineheight:1.4paddingleft:15pxbackgroundimage: url(menu/ documents.gif)backgroundrepeat:norepeat} li.sdoc{lineheight:1.4paddingleft:15pxbackgroundimage: url(menu/ sdocument.gif)backgroundrepeat:norepeat} li.sdocs{lineheight:1.4paddingleft:15pxbackgroundimage: url(menu/ sdocuments.gif)backgroundrepeat:norepeat}
TheURLisrelativetothetemplatespath,eg.templates/mytemply/menu/document.gif. Theimagesarenormallylocatedinthesubfoldermenuinlayoutfolder,ie. templates/ default/ menu. Ifthesubfoldermenuisdeletedfromthelayoutfolder,thedefaultmenuimagesstoredin cmsimple/image.phpwillbeusedforthetableofcontents. Ifyouwishtousecmsimple/image.phpimages,deletethemenufolderandchangethecolorsof thedocumenticonsintheconfiguration. TheHTMLfortheimagesissetinthetrfunctionincms.phpandmaybeeditedthere,ie.ifyou don'twantanyimagesatall. UsethisPHPcodetogetthebinaryvaluesofallgifpicturesplacedinthesamedirectoryasthe scriptandinsertthebinaryvaluesintheimagefunctioninimage.php:
$localdir='.' if(is_dir($localdir)){ $fd=@opendir($localdir) while(($part=@readdir($fd))==TRUE){ if(preg_match("/\.gif$/i",$part)){ $file_handler=fopen($part,"r") $contents=fread($file_handler,filesize($part)) fclose($file_handler) echo'if($image==\''.$part.'\')return\''.bin2hex($contents).'\''}} if($fd==TRUE){closedir($fd)} }else{echo"Couldnotopendir"}
Getthebinimg.phpscript(0.4KB) Alsoyoumayfindthisinteresting:http://php.holtsmark.no/base64img/
Stoppinguserschangingthesettings
CanI stopmyuserdamagingthesetup?
Youcan'tstopanotheruserwithadminrightsfromchangingthesettings,butyoucanmakeit difficultforthembyhidingthesettingsbutton.
25
Hidingthelogin
http://www.yourdomain.com/index.php/Welcome&login
Createahiddenpageandplacethiscodeonit.
I ncludingfiles
M akinganew sbox
26
Addingaforumtoasite.
Sorry.CMSimplewasnotdesignedforthispleasecheckoutphpnukewhichmaybesuitable.
I tdoesn'tw ork!
Functionsintemplatedonotexecute!
Onsomesystemsyou'llhavetochangetheextensionoffile_contentfrom.htmto.shtmlor.phpin ordertogetCMSimpletowork.
if($s=='QUERY_STRING')return$GLOBALS['QUERY_STRING']
inthebeginningoffunctionsv($s)
M yeditorhasdisappeared
Checkyourheaderstatements<h1><h2><h3>,etc.incontent.htm.Ifyouhavealinefeed characterthere,itcanupsettheEditor.Thisoftenhappenswhencut&pastingtextfromanother program,orswitchingmodeafterhavingpastedtext.
M yfilehasdisappeared
WindowsmachinesarecaseinsensitiveFOO.PHPinthssameasfoo.php.Yourremotehostcould berunningLinuxwhichiscasesensitive.foo.phpisdifferentfromFOO.PHP.
#CMSimpleremove#
27
P ricing
I sthisscripttotallyfree?
"Yes,Itdoesn'tmattertomeifonlytenpersonsareusingit,orhundredsIlikefreesoftware. Icouldn'tfindagoodfreeCMSformyneeds") Purchaseoflicencesarereallyappreciated,though,anditwillsupportthefuturedevelopmentof thissimpleCMS. However,ifyouwishtoremovethe"PoweredbyCMSimple"linkfromthesoftware,thenyoumust purchasealicence. CMSimpleisfreesoftware,andthelinkencouragesalargeruserbase,whichinturnencourages futuredevelopment.
28