knowledgeroot-0.9.9.5/0000755000175000017500000000000011273105241015537 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/doc/0000755000175000017500000000000011273105241016304 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/doc/BUGS0000644000175000017500000000027710462674233017010 0ustar fhabermannfhabermannKNOWN BUGS For new Bugs send a email to bugs@knowledgeroot.de or use forum or mailinglist! Forum: http://forum.linuxdelta.de Mailinglist: http://lists.linuxdelta.de/cgi-bin/mailman/listinfoknowledgeroot-0.9.9.5/doc/CHANGELOG-OLD0000644000175000017500000004644310615201757020155 0ustar fhabermannfhabermann03062006 - frank - add new theme green - add changelog - add defaultpage if pageid not exists or is not set - add 'class="button"' to all buttons for customizing with css - add navigation to tree: working slide in and slide out 05062006 - frank - add reload function in tree, does not work correctly at this moment. need to check why - fixed bug: it was not possible to set rigts recursiv - fixed bug: it was not possible to set rights as admin to content that was created by nobody/anonymes - fixed: expand all from config should only work on firtrun - fixed: setrecursiveRights -> add DELETED=0 to sqlstatement --- - reload tree works now fine in firefox - add expand and collapse to tree 06062006 - michael - fixed display problems with IE browser (moved container td styles to stylesheet, added IE hack) - changed image tooltips to use title attribute (works in both IE and Firefox) - pull image tooltip text from language file (need translations) 07062006 - frank - make own array in language for treenavi tooltips - make loading messagebox ready languagetranslation - fixed not always working collapse/expand all tree - fixed logout: make a turnarround with relocation to index.php so that session and all will be new initilized after logout 10062006 - frank - fixed the expand and collapse tree again 11062006 - frank - add contentmoving 14062006 - frank - change up and down arrow to gif - add some information about up and downarrow to other themes 16062006 - frank - fixed last_id at create page - translate word to german - user can change his language (db update is needed) - fixed: empty rootname is no more possible - fixed: rightproblem in tree 19062006 - frank - bugfix: admin cannot see all content - thats fixed now 23062006 - michael - added email notification support (need translations) - fixed image/text alignment for uploads, added css definition - changed tree class caching to cache raw tree data only to be more flexible 25062006 - frank - enable mail notification as text or html mail - make modification on mail notification for better work - add file BUGS 26062006 - michael - fckeditor updated to new version 2.3 27062006 - michael - partial fix for content moving bug - check for null session cache to fix expand/collapse ajax error 28062006 - frank - fixed search: path to files were wrong and deleted files were show - fixed download - file informations are shown after file and at search - searchfield is filled up with the searchword after searching - confirmation is need if you want to delete a file - .cvsignore was removed from cvsthis->CLASS['vars']['knowledgeroot']['charset'] - fixed conflicts with fckeditor-binary and the files for fckeditor 03072006 - frank - add id to mail notification - fixed lastPart of Tree - do some dirty fix for IE in tree at closing elements - fixed problem with tree if session is empty 05072006 - frank - fixed tree at moving; could not open/close tree elements 07072006 - michael - include fckeditor styles within each theme (use "Formatted" format setting for blocks of source code, looks much better than "Code" style setting) - allow easy configuration of fckeditor image uploads using new knowledgeroot:uploadserverpath config setting 09072006 - frank - fixed delete_content to get the right name/id of page - fixed static content moving 10072006 - frank - make tree static for opera and konqueror 12072006 - frank - fixed "automatically open created page" at page creation - fixed open/close/expand/collapse/reload at moving in ajaxtree 13072006 - frank - make some documentation and tag cvs for RC1 version 14072006 - michael - fix for login not working with PHP version 4.1.2 and Apache 1.3.23 17072006 - frank - fixed: treecache was not saved if tree collapse or expand 18072006 - michael - fixed: extra slash was being inserted into fckeditor generated URLs for uploaded files - fixed: bottom set of submit buttons on content editor were not named properly and did not function as labeled 18072006 - frank - fixed: download with mysqli could not work - if tinymce is used the js files are only loaded if you want to create or edit content - changed coloumtype of file from blob to longblob in dumps - modify english and german for delpagefailed - fixed: new user page does not show user rights selections in the configured language - fixed: HTML email notification links are not composed as HTTPS when the server is HTTPS-only - fixed: Delete page (HTML) email contains a link to the deleted page, which is not valid 19072006 - michael - fixed: fckeditor file uploads made from image or hyperlink popup not working 20072006 - michael - fixed: "moved" language entry for emails missing ... check translations used babelfish to translate - changed Knowledgeroot link in header to point to www.knowledgeroot.de 20072006 - frank - add french translation to knowledgeroot - thanks to Emmanuel BOUEDO 22072006 - frank - fixed mysqli wrapper connect to database - fixed problems with php5 -> some while loops are overwrite the $res that are used in the head of while - removed white spaces in some files at the end of file -> after "?>" should be the last line - added charset in htmlrequestheader 23072006 - michael - fixed email notificaiton html links missing base URL prefix - fixed htmlrequestheader charset changes caused execution error on windows server - fixed fckeditor title CSS class clashed with existing class in IE 24072006 - michael - fixed CSS issues caused font and spacing differences in IE - fixed htmlrequestheader charset changes caused execution error on windows server (missed file move.php) 26072006 - frank - made changes for release 0.9.7rc2 20072006 - frank - prepare knowledgeroot for the official release - modify the contenttype in the head of the htmlsource - move the BUGS, TODO, CHANGELOG... to folder doc - security fix: if you use more then one knowledgeroot installation on one domain the cookie work for all installation 03.08.2006 - frank - fixed a bugs with the rightmanagement in tree 06.08.2006 - frank - tag version as stable 0.9.7 06.08.2006 - frank - change version to 0.9.8 07.08.2006 - michael - add light version of iBrowser plugin to tinyMCE, allows upload and browsing of images - style class added to tree bullet images to better support dark background themes - added new midnight theme - added gzip compression plugin for tinyMCE to improve page loading time - changed Code style in fckeditor to insert a "pre" tag, rather than apply Code style class 07.08.2006 - frank - add developer toolbar 08.08.2006 - frank - add extension interface - add extension register for first tests 10.08.2006 - frank - finished work to show menu items, only the content area must be changed at this point 13.08.2006 - frank - make a lot of modification at the extension interface - make the default menu dynamic with a own class 14.08.2006 - frank - extension can now create own content elements - database update is needed - tree navi is also full dynamic now - added new language dutch from "Luuk Hansma" 15.08.2006 - frank - made update on scriptaculous version 1.6.2 16.08.2006 - frank - added japan language, thanks to SENRI 20.08.2006 - frank - modified extension interface 21.08.2006 - frank - include config functions to extension interface - create the real extension register with the first functions 22.08.2006 - frank - finished work at register extension - added extension dbcleaner - missing errormsg at failed login was fixed 25.08.2006 - frank - preparing for pagealias at create root/edit page/create page 28.08.2006 - frank - create db_insert in database class for easy sql insert statement to all databases 29.08.2006 - frank - add 2 helper functions to extension_base; function getTextbox to show rte textbox or textbox only; function getRightpanel to show the rightpanel 30.08.2006 - frank - add next 2 functions to extension_base - optimize tree class - modify tree class for usage of aliases - create function makeLink in treeclass - make some small modifikations to the db wrapper classes 31.08.2006 - michael - removed css references to missing footer image 31.08.2006 - frank - added function to make from xyz.html a pageid and set pageid -> pagealias work now 03.09.2006 - frank - make checks for alias so that alias is unique 12.09.2006 - frank - update of scriptacolous javascripts 21.09.2006 - michael - added ability to collapse/expand content sections - added title, lastupdated, and lastupdatedby fields to content table - fixed bug where move content popup shows "Array" as the name for each page 22.09.2006 - michael - when editing content, if email notification turned on, allow marking edit as a minor change, which will prevent an email being sent - add full configuration options for content title bar features: show title, enable collapse, show lastupdated 22.09.2006 - frank - created admin interface in subfolder admin - created file init_admin for admin interface - added new functions in extension-class to load admin extensions - added new functions to extension-class to manage extensions - changed init[_admin],extension-class to load files with absolute paths - created admin config file in conf folder 23.09.2006 - frank - created login for admininterface - created extension admin_extension for extension handling 25.09.2006 - michael - added root image favicon 25.09.2006 - frank - added empty extensions for admin_config,admin_install,admin_update 27.09.2006 - michael - moved require_once include for phpmailer to init class (needed for future livediagram extension email notifications) 07.10.2006 - michael - added content versioning support via new history table - added version history page for each content showing changes - email notifications for edited content now include detail of changes - improved look of html email notifications - added per-page setting to initially show all content items collapsed 09.10.2006 - michael - stylesheet work for some broken styles in IE browser 10.10.2006 - michael - fixed grouprights content display bug (fixed query) 14.10.2006 - frank - added logout to admininterface - created table settings for config vars - added functions for handling with table settings to class knowledgeroot - fix sqldump of history in postgresql - removed plain mysqlfunctions in historyfunctions 15.10.2006 - frank - change mysqldumps for history tables because of a problem with default values 18.10.2006 - frank - fixed bug: content was not shown if users is in subgroups and the content has rights for this subgroup - added scrollbars to popup for moving content/page 21.10.2006 - frank - extensions are now loaded over database table extensions - beginning of install of extensions with sqlcommands 27.10.2006 - sven - check variables with isset() - add comments 27.10.2006 - frank - moving to svn - fixing small error in extension menu creation - fixing small error with isset - make some css styling to extension repository 28.10.2006 - frank 29.10.2006 - frank - added error class - fixing small error with isset in show_menu - fixing problem with lastpart in tree 29.10.2006 - sven - check variables with isset() - add comments - replace $HTTP_SERVER_VARS with $_SERVER - not necessary if deleted - auto fokus() of username - $_SESSION['firstrun'] is now boolean value - new_content() has no title 30.10.2006 - sven - variable name write error fixed - add a function (example): getFormattedSize($size) 30.10.2006 - frank - admin_extion can now install extensions and could run sql commands 31.10.2006 - michael - fixed tree error - UI tweaks for IE 7 02.11.2006 - frank - fixing with isset - fixing errors in admin_extension - modify dumps for database - porting extension_repository to mysql 05.11.2006 - frank - fixing problem with isset - fixing 2 problems with rights at treeclose - fixing problem with rights at search - repair image in admin_extension - fixing problem with show_menu at content/contentline - added new fckeditor 2.3.2 06.11.2006 - sven - new class class-auth.php 07.11.2006 - michael - updated tinymce to version 2.0.8 ... gzip compression and ibrowser plugin working 11.11.2006 - frank - create empty functions for logging in class error - create class hooks 12.11.2006 - frank - create extension history - removed sql statements from base dumps that are required by ext history - removed source code from base that are required for history - added hooks that are required for the ext history 14.11.2006 - frank - fixing some problems with hooks - history extension is now working (except email notify) - modified languages 18.11.2006 - frank - fixed problem that the sql is not executed at install of history - make cleanup of class notification - fixing problem with notification in extension history 19.11.2006 - frank - as admin moving of page to root are allowed - warning is shown if more than one user want to edit the same content - added hooks in knowledgeroot_header 20.11.2006 - sven - new config vars: $CONFIG['RELOGINDELAY'] and $CONFIG['MAXLOGINS'] - class-mysql.php - Fehlerausgabe verbessert; muss aber noch ausgebaut werden! - class-knowledgeroot-header.php - login()-Funktion angepasst - new error message if login fail - class auth now with more function (basic edition) 21.11.2006 - sven - class-auth: garbage collector implemented 23.11.2006 - frank - fixing problem with collapse ajax tree - adding hooks to knowledgeroot-content - using sprintf for sql in knowledgeroot-content 26.11.2006 - frank - using sprintf for sql 27.11.2006 - sven - isset-contentcollapsed problem fixed - problems with DATE_FORMAT and sprintf fixed - mysql-dumps - problems with timestamp fixed 28.11.2006 - frank - fixed problems with the static and ajaxtree 30.11.2006 - frank - fixed problem with open_content -> sessionid is used if user is not logged in 01.12.2006 - frank - adding some sqlcaching to class-knowledgeroot and class-tree 02.12.2006 - frank - fixing problem: guest was not shown -> problem with if-condition and isset - added db_insert,db_update,db_delete to database wrapper class 03.12.2006 - sven - added comments to db_insert,db_update,db_delete to database wrapper class 07.12.2006 - frank - add dropdown for language 13.12.2006 - frank - create js to languagedropdown and create a configval to enable/disable it - update of scriptaculous version 1.6.5 - working on admin_config 15.12.2006 - frank - working on admin_config - fixing some html-syntax probs 23.12.2006 - frank - added install.php and update.php - not useable at the moment 27.12.2006 - michael - added knowledgeroot page linking plugin for fckeditor 28.12.2006 - michael - added knowledgeroot page linking plugin for tinyMCE 04.01.2007 - frank - doing some work at the installer 12.01.2007 - sven - translations - new language vars - set "HTML/text" to '' 13.01.2007 - sven - missing isset() supplemented - class-knowledgeroot: //echo "##"; 17.01.2007 - sven - fix an error in JS code for language dropdown 21.01.2007 - frank - added spanish translation - working on install 22.01.2007 - frank - changes order of class definition to get no errors at loading settings from db 25.01.2007 - frank - fixes problems with expand tree - fixes problems with ajax xml class - install and update should now work but not tested. it is also disabled. make a backup if you want to use it. 28.01.2007 - frank - menu will be opened if you click on an menu item - tree in fckeditor and in tinymce is now dynamic 30.01.2007 - frank - fixes a small mistake in the dumps 04.02.2007 - frank - change "#" to "javascript:;" in the javascript menu - set a missing isset in init.php 05.02.2007 - frank - created class knowledgeroot-installer 07.02.2007 - frank - created functions in class knowledgeroot-installer and do install over the class - not finished 15.02.2007 - frank - installation should be finished - update is not full included to installer class 18.02.2007 - frank - install/update should now work - removed extensions admin_install and admin_update from repository - they are not needed - updated scriptaculous to version 1.7.0 - fixed small bug in init_admin - added small info text to admin_info 19.02.2007 - frank - internal linking should be complete. the tree in the editors shows now also contentelements - fixed small bug with the right functions in class-knowledgeroot 22.02.2007 - frank - update of fckeditor to version 2.4 - update of tinymce to version 2.1 23.02.2007 - frank - fixed small bug with page alias - added notification at user_delete and group_delete - user_delete and group_delete delete no more used entries from table user_group - updated docs - fixed bug at content moving - if a static page was opend and does not exists the defaultpage will be shown or welcomescreen. not the last page you have opened 24.02.2007 - frank - fixed small error in install-class 25.02.2007 - frank - added new feature: inherit rights are now possible for pages and contents (status: should work but not tested and langtokens are missing) - removed "back"-link at new_content and edit_content - doing small changes to admin_config - added field description and selection to table settings 27.02.2007 - frank - fixed downloadbug in ie7 (thanks vago) - added field description and selection to table settings 05.03.2007 - michael - fixed javascript errors with fckeditor + IE and tinymce + IE, krootlink still not showing in tinymce 06.03.2007 - frank - fixed the missing krootlink in tinymce 08.03.2007 - frank - setting the suffix to nothing at tinymcegzipcompressor so it should really work 10.03.2007 - frank - search also search in the title of contents - resize the krootlink popup - removed not used table history from dumps - fixed small error with ajax tree close - content was removed 11.03.2007 - frank - added indexes to dumps - fixed postgresql dumps - added translation russian - after rc1 15.03.2007 - frank - fixed missing isset - changed css for devtoolbar 17.03.2007 - frank - add language zh-tw - updated language pt-br - added maxfilesize at upload 18.03.2007 - frank - add a disable for subinheritrights - fixed bug: no more used delete on history was deleted - changed dateformat - fixed problem with langdropdown - added close button to moving window 20.03.2007 - frank - fixed search for normal users - change language for ext:admin_config - fixed small error in lang pt-br 25.03.2007 - frank - fixed some hardcoded texts - fixed problems with subinheritrights - fixed themes - added german translation 31.03.2007 - frank - added error msg on missing config file - added warning colors to install and update - added infotext to admin interface after login - added debug.php 01.04.2007 - frank - fixed small error with index - added better error message to installer - added welcome message to installer - modified dumps with descriptions for settings - setting right repository server in admin_extension - display description in admin_config 08.04.2007 - frank - version 0.9.8 was official released - changed version in svn to 0.9.9 15.04.2007 - frank - fixed problem with subinheritrights - fixed problems with rights 17.04.2007 - frank - fixed problems with rights ( bugreport from sven ) - fixed a problem with non alphanumeric chars in alias 18.04.2007 - frank - fixed problem with extensions import and openbasedir - fixed problem with libsecure and whitelist 20.04.2007 - frank - fixed and testet problem with extension import and openbasedir - added addslashes for COOKIE/REQUEST/SERVER - fixed some problems with libsecure - changed version to 0.9.8.2 - fixed a small css error - making fileupload more secure knowledgeroot-0.9.9.5/doc/README0000644000175000017500000000133010567434011017166 0ustar fhabermannfhabermannKnowledgeroot ############# Homepage: http://www.linuxdelta.de/knowledgeroot.html License: GPL For install read INSTALL. For License read LICENSE. For Questions use the forum or the Mailinglist. Forum: http://forum.linuxdelta.de Mailinglist: http://lists.linuxdelta.de/cgi-bin/mailman/listinfo Requirements ############ - Apache Webserver (not tested with ISS) - PHP >4.1.x (better >4.3) - Mysql > 4.0.x or PostgreSQL >7.4.x For editor Tinymce: IE,Mozilla based browsers, Opera For editor Fckeditor: IE, Mozilla based browsers Hints ##### Ajax tree will not work in Konqueror or Opera so it will be forced to static tree! Documentation ############# For documentation check our website on: http://www.knowledgeroot.deknowledgeroot-0.9.9.5/doc/UPGRADE0000644000175000017500000000236411232405172017324 0ustar fhabermannfhabermannUpgrading from Knowledgeroot 0.9.9.x #################################### * Make a backup of your data * Keep in mind what extra extensions you have installed! * Replace all files with the files in the archiv * Copy your existing configs from the conf folder to the new installation * Copy your extra extensions from system/extension/ to the new installation * Copy your existing upload folder to the new installation * DO NOT RUN THE UPDATE SCRIPT * Delete install.php and update.php ATTENTION: It is recommended that you install the extension libsecure! Upgrading from Knowledgeroot 0.9.8.x #################################### * Make a backup of your data * Keep in mind what extra extensions you have installed! * Replace all files with the files in the archiv * Copy your existing configs from the conf folder to the new installation * Copy your extra extensions from system/extension/ to the new installation * Copy your existing upload folder to the new installation * Open the following location with your browser and run update: http://your.location/update.php * Delete install.php and update.php ATTENTION: It is recommended that you install the extension libsecure! More Informations ################# For more information go to www.knowledgeroot.de knowledgeroot-0.9.9.5/doc/LICENSE0000644000175000017500000003560510436333720017327 0ustar fhabermannfhabermann GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS knowledgeroot-0.9.9.5/doc/TODO0000644000175000017500000000324710512051025016775 0ustar fhabermannfhabermannTODO --------------- - test with mysqli databasewrapper - crypt files or content with a password or a keyfile - file uploads should be make with ajax - it should be able to use also icons for navigation (icon for edit content or create content) - better errorhandling -> create LOGS if errors are produced - import from: xml, html, rtf(?), pdf(?) - export to: xml, html, rtf, pdf - print preview (?) - include other translations - edit/include metatags on every page for google and co. - page should be available over an alias so that we can create static links with apache rewrite -> so: www.domain.org/index.php?id=32 could be www.domain.org/hello.html - list of content(overview) of new and recently modified content on homepage - list with content titles on each page for faster content selection - user comments for every contentelement (should be discuessed ;) ) - link from one content to other internal content - move tree elements by grabbing them and drop them where it should move to - move content by grabbing them and moving the content vertical and drop them - interface for thirdparty extensions in knowledgeroot ? - autoupdate for admin - grammar correction (rechtschreibpruefung) DONE ------------------ - user-registration form that could be en/disabled by config - database cleaner - admin should be able to delete deleted pages/content/files - versioning - email notification if content is created or modified - allow modify of welcome page - user can change his language - "expand all" and "collapse all" under tree - tree should be make with ajax - tree should be able to slide in and out - it should be possible to move a content on a page up or down. (save that in database)knowledgeroot-0.9.9.5/doc/CHANGELOG0000644000175000017500000003410011273072135017521 0ustar fhabermannfhabermann20.04.2007 - frank - fixed and testet problem with extension import and openbasedir - added addslashes for COOKIE/REQUEST/SERVER - fixed some problems with libsecure - changed version to 0.9.8.2 - fixed a small css error - making fileupload more secure 21.04.2007 - frank - added version.php with version number. that file was included bei init.php and init_admin.php - added fullscreenmode to tinymce - fixed mistake of language in tinymce - added underline to active tree item 22.04.2007 - frank - add hr line to top of root items in tree (config: menu.hrrootline) 27.04.2007 - frank - added it translation 29.04.2007 - sven - change Knowledgeroot.de to Knowledgeroot.org - set focus() for name fields - order user and group by name - added it translation and order translations by name in *.sql files - insert asort for $this->CLASS['vars']['knowledgeroot']['availablelanguages'] - moved old content in changelog to changelog-old - doing some work on extension history -> see changelog of extension 30.04.2007 - frank - adding GET, POST and getLang to extension-base - changed repository server in extension admin_extension to knowledgeroot.org - building of .krx extension is ignoring .svn and CVS folders - doing some worh at extension_repository 04.05.2007 - sven - added php-gettext - first code 04.05.2007 - frank - added gettext to admin interface - added gettext for extensions - extension can use $this->T_('hello'); - added runtime values to index.php -> enable over settings: dev.runtime = 1 - added a runtimeclass that can be used with $CLASS['runtime'] - added smarty template engine - available over $CLASS['smarty'] - not configured at the moment 06.05.2007 - frank - added mdb2 database layer - not tested enough but could be used 06.05.2007 - sven - runtimeclass: getTime can print the time without an extra stop()-call bevore - init.php: load only code for the editor that is set in config (FCK or Tiny) - use $CLASS['vars']['htmleditor']['use'] instead of $CLASS['oFCKeditor']->use 08.05.2007 - frank - fixed problem with ext history 10.05.2007 - frank - moved all not necessary extensions to own folder trunk/extension 12.05.2007 - sven - load gettext langfiles for extensions only if directory exists 13.05.2007 - frank - modified default configs - modified error class 13.05.2007 - sven - path in extension class corrected (base_path end with a '/') - any change with *.pot files 13.05.2007 - frank - after changing base_path in class-extension the admin interface is not working - correct the init_admin to work right - added downloadlink for extensions to admin_extension at import list 20.05.2007 - sven - changes for gettext - change lang folder for extensions to language - new file for creation of language files 20.05.2007 - frank - added hook to init_admin 22.05.2007 - sven - fix small bug in generate_locale.sh - changes for gettext 22.05.2007 - frank - changed version - changed knowledgeroot link in index.php - fixed problems with mdb2 25.05.2007 - frank - changing class loading in init.php - cleanup of databaselayers: mysql,mysqli,pgsql - added errormsg to databaselayers - doing some changes to mdb2 - modifie config.inc.php.dist with examples of how to use the database layers and the errors - added highlighting at contentshow - GET['highlight'] parameter is be used - different words are separeted by comma - added browser back for search - added highlight to searchlinks 26.05.2007 - frank - added protection to admin_info,admin_extension,admin_config so that they could not be disabled 27.05.2007 - frank - ajaxtree is now working with opera 28.05.2007 - frank - fixed a mall error in class-language - added myPath to extension-base - make own extension of tinymce - added support for themes as extension - make own extension of fckeditor 02.06.2007 - sven - small fixes - changes for gettext 03.06.2007 - sven - changes for gettext 03.06.2007 - frank - removed themes: default and midnight as own extension - set green as default theme in the knowledgeroot-theme class 07.06.2007 - frank - fixed small problem with rte class - modified class runtime for using names 12.06.2007 - frank - add titel of content to search results - fixed problem with initial load of knowledgeroot 15.06.2007 - frank - added native support sqlite db wrapper to knowledgeroot 17.06.2007 - frank - added phpmailer from debian that fixes security bugs - removed quotes in sql queries and use now the db function quoteIdentifier for this 27.06.2007 - sven - $dbtype == "sqlite" ergaenzt 13.07.2007 - frank - changed rte handling in extension-base - add system extensions to folder system/sysext/ - extensions can also be located in extension/ or in system/extension/ - new folder of imported extensions will be extension/ 14.07.2007 - frank - fixed wrong processing of adding languages to extension - added new functions to class knowledgeroot to get better environment vars - try to fix the problem with images in the tree and the krootlink from rte 15.07.2007 - frank - fixed small problem with imageprefix in class tree 23.07.2007 - frank - added some more features to errorlog - setting php error reporting is possible 24.07.2007 - frank - fixed php notice 27.07.2007 - frank - added full support for sqlite (need to be tested for last errors) 29.07.2007 - frank - added first stuff for multiple rights - phperrors will not be changed at default 10.08.2007 - frank - removed old comments with old language get token method - fixed bug: #39 - Internet Explorer doesn't send the submit=GO when hitting Enter * added a hidden intput type in index.php * thanks to vago and paul - removed old languages with arrays as language - changed class language so that it will not more load any system languagefile 11.08.2007 - frank - added downloadcounter * updates to database are needed - added static links for downloads * can be set over table settings value download.static = 1 - added id to every responsible link - show_menu will now replace {$PAGEID} with the id of the page in links 17.08.2007 - frank - added patch from kzhk.iwm * ticket #41 - try to fix the problems with highlighting in search for japanese * need to betested 21.08.2007 - frank - added first stuff for symlinks - added first stuff for self ordering tree elements 22.08.2007 - frank - try to fix wrong email notifications * ticket #33 - added new function squery to database wrappers - added function that checks multiple rights on element 24.08.2007 - frank - added missing return in squery function - changed functions rightPanel and editRightPanel for multiple rights - added multiplerights * is not working with inheritrights at the moment 01.09.2007 - frank - added patch from sven to fix problems with language files from extensions 08.09.2007 - frank - added session handle that make checks on session and on lifetime 15.09.2007 - frank - added multiplerights to subinheritrights 16.09.2007 - frank - added missing statements to sqlite dump - modified setrightsrecursiv for multiplerights 13.10.2007 - frank - added missing multiplerights then you create a root element 27.10.2007 - frank - added search with multiple words (#46) - fixed some problems with multple rights 28.10.2007 - frank - added multiple rights and subinherit rights to content elements - setting recursiv rights with multiple and subinherit rights are working 03.10.2007 - frank - added first stuff for rightclickcontextmenu 04.10.2007 - frank - remove contextmenu from move and editor tree window - fixed some problems with the menu - added wrap for menus - added styles for contextmenu - added contextmenu for content elements 10.10.2007 - frank - added hr line to contextmenu - added option to enable/disable contextmenus 11.11.2007 - frank - added first drag and drop in tree - added recusriv delete (CLose: #45) - make it possible to edit tooltip for tree elements (Close: #44) 15.11.2007 - frank - fixed problem with menuvalue in extension admin_config - fixed small performance problem in filelisting (Closes: #47) - added new drag&drop icon - fixed wrong contentdisplay of disabled extensions (Closes: #48) 02.01.2008 - frank - added first stuff for drag and drop for content 03.01.2008 - frank - change style of drag and drop for content elements 04.01.2008 - frank - changed some stuff for content drag and drop - try to fix a small problem with css and the contentline 06.03.2008 - fhabermann - changed class auth to class knowledgeroot_auth so that other auth classes could be used like pear auth 20080316 - fhabermann - changed date style in changelog ;) - removed twice loaded js files from scriptaculous - added stuff for content moving by ajax 20080410 - fhabermann - added new class db_core for core functions that will extends als db classes - added new class db_result for better result informations - integration of new classes - added new db function data_seek to set pointer in result 20080412 - fhabermann - added tree counter (Closes: #53) - added content counter (Closes: #52) 20080414 - fhabermann - added missing tree itemcounter to non-ajax tree 20080415 - fhabermann - added more OOP style in class db_result 20080422 - fhabermann - added new menutype called treebottom - added new styles for treebottom menu - changed column value in table settings from varchar to text to save bigger values - added new function defaultlayoutfortree (Closes: #56) 20080424 - fhabermann - fixed small css problem - added option to show sourceforgelogo - added knowledgeroot logo and option to display the logo - added first testclass for oracle 20080621 - fhabermann - added missing sound.js 20080621 - sven - fix some HTML problems (& > & ...) 20080623 - fhabermann - fix https download of files for ie 20080906 - fhabermann - fixed problem with show_menu if extension is deleted but enabled 20090211 - fhabermann - added new highlight function with own class (Closes: #66) 20090212 - fhabermann - added content collapse if content is direct opened (Closes: #60) - fixed layout problems with small browser window in admin interface (Closes: #1) 20090213 - fhabermann - added prototype 1.6.0.3 - added scriptaculous 1.8.2 20090215 - fhabermann - enabled javascript drag and drop only in firefox 20090221 - fhabermann - fixed problems with sqlite dump - removed symlink for libhttps that is not used here 20090222 - fhabermann - removed unused smarty source (Closes: #85) - fixed problem with sqlite dump (Closes: #84) 20090223 - fhabermann - added .htaccess file 20090301 - fhabermann - changed function to get base_path 20090318 - fhabermann - popup for movecontent is now scrollable (Closes: #91) 20090319 - fhabermann - pages and content can only with javascript enabled deleted (Closes: #90) 20090322 - fhabermann - added new pot template for knowledgeroot - moved german locale folder from de to de_DE.UTF8 - lang dropdown now search for gettext languages 20090402 - fhabermann - enabled drag and drop in tree and for contents for ie8 (Closes #92) 20090403 - fhabermann - added prototypejs 1.6.1rc2 20090404 - fhabermann - added two settings to dumps: version and baseurl - cleanup of init.php - installer saves now baseurl 20090405 - fhabermann - added english translation (en_US) 20090408 - fhabermann - added french translation (fr_FR) - make dumps and update process clean - fixed problem with option language change 20090410 - fhabermann - cleanup of sqlite dump - added missing statements to sqlite dump - changed version to 0.9.9rc2 20090419 - fhabermann - added missing diff dumps 20090427 - fhabermann - added two new hooks to login screen: before_submit and after_submit (Closes: #94) 20090512 - fhabermann - changed version to 0.9.9 (stable) 20090705 - fhabermann - changed version to 0.9.9.1 - fixed db handling with mysql that has problems with some files (Closes: #108) - fixed windows problems with gettext (Closes: #109) 20090707 - fhabermann - fixed mistake with filehandling 20090708 - fhabermann - update prototypejs to version 1.6.1rc3 (Closes: #112) - fixed problems with link in mail notification (Closes: #113) - fixed problem with title style (Closes: #116) 20090712 - fhabermann - fixed notices (Closes: #117) 20090720 - fhabermann - fixed problem with var and notice (Closes: #122) - fixed problem with user creation (Closes: #124) - added rte extensions in dump and active fckeditor for default (Closes: #123) - set version of database at install or update (Closes: #114) - added showlogo option to upgrade_diff 20090724 - fhabermann - fixed mysql download problem (Closes: #129) - update the upgrade doc (Closes: #128) - fixed search problems with whitespaces (Closes: #121) 20090731 - fhabermann - added new search group option with that you can search for multiple words with an and condition (Closes: #126) 20090801 - fhabermann - fixed a sql dump problem with value for download.static 20090802 - fhabermann - fixed sql dump problems - changed version to 0.9.9.2 - fixed problem with tooltip notice - that was a update problem (Closes: #130) 20090806 - fhabermann - added nl_NL translation 20090812 - fhabermann - added missing counter field to sqlite dump (Closes: #134) - fixed download problems with sqlite as database (Closes: #134) - date in download is now chown for sqlite as database (Closes: #137) 20090820 - fhabermann - fixed collapsing problems if you come from search to content element (Closes: #135) - fixed search problem with multiple rights (Closes: #136) - fixed problem with move content (Closes: #133) 20090821 - fhabermann - fixed problem with search and multiple rights 20090825 - fhabermann - add italian translation (Closes: #140) 20090908 - fhabermann - added prototype 1.6.1 (Closes: #142) 20090910 - fhabermann - fixed js problem with ie (Closes: #145) - fixed js problem with tree expand in ie (Closes: #141) 20090920 - fhabermann - fixed highlight problem (Closes: #148) - changed version to 0.9.9.4 20090922 - fhabermann - fixed gettext warning in admin interface on windows (Closes: #152) 20091021 - fhabermann - add spanish translation (Closes: #157) 20091030 - fhabermann - fixed contextmenu problems with extensions (Closes: #151) - make different classnames for extensions possible (Closes: #158) 20091031 - fhabermann - make direct search with content ids possible (Closes: #147) - changed version to 0.9.9.5 knowledgeroot-0.9.9.5/doc/INSTALL0000644000175000017500000000104710567434011017344 0ustar fhabermannfhabermannInstall of Knowledgeroot ######################## 1. Unpack your knowledgeroot package 2. Open your browser with URL http://your.location/install.php 3. Enter all required settings to finish the installation 4. Check that config.inc.php and admin_config.inc.php are written to folder conf/ 5. DELETE install.php AND update.php AFTER INSTALLATION!!! 6. Now the installation is complete. You can now enter Knowledgeroot. If you have questions contact us! Knowledgeroot http://www.linuxdelta.de/knowledgeroot.html http://www.knowledgeroot.de knowledgeroot-0.9.9.5/install.php0000644000175000017500000000125010566043432017723 0ustar fhabermannfhabermann' . "\n"; ?> Knowledgeroot Installation mainInstall(); ?> knowledgeroot-0.9.9.5/dumps/0000755000175000017500000000000011273105236016673 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/dumps/upgrade_postgre_diff.sql0000644000175000017500000000546211235362247023612 0ustar fhabermannfhabermannBEGIN; CREATE TABLE access ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), table_name varchar(255) DEFAULT '', belongs_to integer DEFAULT 0, owner_group varchar(5) DEFAULT '', owner_group_id integer DEFAULT 0, rights integer DEFAULT 0 ); ALTER TABLE files ADD COLUMN counter integer; ALTER TABLE files ALTER COLUMN counter SET DEFAULT 0; ALTER TABLE tree ADD COLUMN symlink integer; ALTER TABLE tree ALTER COLUMN symlink SET DEFAULT 0; ALTER TABLE tree ADD COLUMN sorting integer; ALTER TABLE tree ALTER COLUMN sorting SET DEFAULT 0; ALTER TABLE settings ALTER COLUMN value TYPE text; INSERT INTO extensions (keyname, active, admin) VALUES ('fckeditor', 1, 0); INSERT INTO extensions (keyname, active, admin) VALUES ('tinymce', 0, 0); INSERT INTO settings (name, value, description, selection) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.order.self', '0', 'enable self ordering of tree elments', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.context', '1', 'enable/disable contextmenus', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayout', '0', 'enable/disable a default layout of the tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayoutarray', '', 'serialized array with default layout of tree - should not be edit', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO settings (name, value, description, selection) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); COMMIT; knowledgeroot-0.9.9.5/dumps/upgrade_mysql.sql0000644000175000017500000000644311235127064022300 0ustar fhabermannfhabermannCREATE TABLE `access` ( `id` int(11) NOT NULL auto_increment, `table_name` varchar(255) NOT NULL DEFAULT '', `belongs_to` int(11) NOT NULL DEFAULT 0, `owner_group` varchar(5) NOT NULL DEFAULT '', `owner_group_id` int(11) NOT NULL DEFAULT 0, `rights` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; ALTER TABLE `files` ADD `counter` int(11) DEFAULT '0' NOT NULL; ALTER TABLE `tree` ADD `symlink` int(11) DEFAULT '0' NOT NULL; ALTER TABLE `tree` ADD `sorting` int(11) DEFAULT '0' NOT NULL; ALTER TABLE `tree` ADD `tooltip` varchar(255) DEFAULT '' NOT NULL; ALTER TABLE `settings` CHANGE `value` `value` TEXT NOT NULL; INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('fckeditor', 1, 0); INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('tinymce', 0, 0); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.order.self', '0', 'enable self order of tree elements', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.context', '1', 'enable/disable context menus', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.edittooltiptext', '0', 'enable/disable edit of tooltiptext of tree element', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.showcounter', '0', 'enable/disable counting of tree items', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('content.showcounter', '1', 'enable/disable counting of content items', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.showlogo', '0', 'show knowledgeroot logo instead of text title', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); knowledgeroot-0.9.9.5/dumps/sqlite.sql0000644000175000017500000003304111241107407020713 0ustar fhabermannfhabermannCREATE TABLE access ( id integer PRIMARY KEY DEFAULT auto_incrementing, table_name text DEFAULT '', belongs_to integer DEFAULT 0, owner_group text DEFAULT '', owner_group_id integer DEFAULT 0, rights integer DEFAULT 0 ); CREATE TABLE content ( id integer PRIMARY KEY DEFAULT auto_incrementing, title text DEFAULT '', belongs_to integer DEFAULT 0, content text DEFAULT '', type text DEFAULT 'text', sorting integer DEFAULT 0, owner integer DEFAULT 0, "group" integer DEFAULT 0, lastupdatedby integer DEFAULT 0, lastupdated datetime DEFAULT '0000-00-00 00:00:00', userrights integer DEFAULT 0, grouprights integer DEFAULT 0, otherrights integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE content_open ( id integer PRIMARY KEY DEFAULT auto_incrementing, contentid integer DEFAULT 0, userid text DEFAULT '', opened integer DEFAULT 0 ); CREATE TABLE tree ( id integer PRIMARY KEY DEFAULT auto_incrementing, belongs_to integer DEFAULT 0, title text DEFAULT '', tooltip text DEFAULT '', alias text DEFAULT '', contentcollapsed integer DEFAULT 0, owner integer DEFAULT 0, "group" integer DEFAULT 0, userrights integer DEFAULT 0, grouprights integer DEFAULT 0, otherrights integer DEFAULT 0, subinheritrights integer DEFAULT 0, subinheritrightseditable integer DEFAULT 0, subinheritrightsdisable integer DEFAULT 0, subinheritowner integer DEFAULT 0, subinheritgroup integer DEFAULT 0, subinherituserrights integer DEFAULT 0, subinheritgrouprights integer DEFAULT 0, subinheritotherrights integer DEFAULT 0, symlink integer DEFAULT 0, sorting integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE files ( id integer PRIMARY KEY DEFAULT auto_incrementing, belongs_to integer DEFAULT 0, file blob, filename text DEFAULT '', filesize integer DEFAULT 0, filetype text DEFAULT 'application/octet-stream', owner integer DEFAULT 0, "date" datetime DEFAULT '0000-00-00 00:00:00', counter integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE users ( id integer PRIMARY KEY DEFAULT auto_incrementing, name text DEFAULT '', "password" text DEFAULT '', theme text DEFAULT '', language text DEFAULT '', enabled integer DEFAULT 0, defaultgroup integer DEFAULT 0, defaultrights text DEFAULT '211', admin integer DEFAULT 0, rightedit integer DEFAULT 0, treecache text, deleted integer DEFAULT 0 ); CREATE TABLE groups ( id integer PRIMARY KEY DEFAULT auto_incrementing, name text DEFAULT '', enabled integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE user_group ( id integer PRIMARY KEY DEFAULT auto_incrementing, userid integer DEFAULT 0, groupid integer DEFAULT 0 ); CREATE TABLE extensions ( id integer PRIMARY KEY DEFAULT auto_incrementing, keyname text DEFAULT '', active integer DEFAULT 0, admin integer DEFAULT 0, version text DEFAULT '' ); CREATE TABLE settings ( id integer PRIMARY KEY DEFAULT auto_incrementing, name text NOT NULL, value text DEFAULT '', description text NOT NULL DEFAULT '', selection text NOT NULL DEFAULT '', UNIQUE (name) ); CREATE TABLE users_login ( usersid integer default 0, login_trial integer default 0, lasttrydate integer default 0, session_id text default '', UNIQUE (usersid) ); INSERT INTO groups (name, enabled) VALUES ('admin', 1); INSERT INTO groups (name, enabled) VALUES ('users', 1); INSERT INTO users (name, password, enabled, admin, rightedit, defaultgroup, defaultrights) VALUES ('admin', '21232f297a57a5a743894a0e4a801fc3', 1, 1, 1, (SELECT id FROM groups WHERE name='admin'), 210); INSERT INTO extensions (keyname, active, admin) VALUES ('admin_extension', 1, 1); INSERT INTO extensions (keyname, active, admin) VALUES ('admin_info', 1, 1); -- INSERT INTO extensions (keyname, active, admin) VALUES ('admin_install', 1, 1); -- INSERT INTO extensions (keyname, active, admin) VALUES ('admin_update', 1, 1); INSERT INTO extensions (keyname, active, admin) VALUES ('admin_config', 1, 1); INSERT INTO extensions (keyname, active, admin) VALUES ('fckeditor', 1, 0); INSERT INTO extensions (keyname, active, admin) VALUES ('tinymce', 0, 0); INSERT INTO settings (name, value, description, selection) VALUES ('login.delay', '30', 'setting login delay', ''); INSERT INTO settings (name, value, description, selection) VALUES ('login.max', '50', 'setting max login', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.charset', 'UTF-8', 'set charset', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.language', 'en', 'set default language', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.language_dropdown', '0', 'show language dropdown', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.use', '1', 'enable rte editor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.editor', 'fckeditor', 'choose fckeditor or tinymce', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.tinymce.cols', '75' , 'set cols for textarea in tinymce', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.tinymce.rows', '20', 'set rows for textarea in tinymce', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.width', '600', 'set widht of fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.height', '450', 'set height of fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.langdefault', 'en', 'set default lang in default fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.langdetect', 'false', 'enable autodetection of language in fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.toolbar', 'Default', 'choose toolbar in fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.skin', 'default', 'choose skin in fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.title', 'Knowledgeroot', 'set title for knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.expandall', '1', 'expand menu at default', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.type', 'static', 'set menu type', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.ajax', 'yes', 'use ajax menu', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.default_theme', 'green', 'set theme in knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showtitle', 'yes', 'show title of contents', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.collapsecontent', 'yes', 'enable collapse content', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showlastupdated', 'yes', 'show lastupdate of content', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.uploadfolder', 'uploads/', 'set upload folder', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.uploadserverpath', 'auto', 'set upload server path', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.defaultpage', '', 'set id of default page', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.notification', '0', 'enable email notification', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.recipients', '', 'set recipients', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.type', 'html', 'enable html mails', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.from_name', 'Knowledgeroot', 'set from name', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.from_email', 'knowledgeroot@mydomain.tld', 'set from email', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_mode', '0', 'enable to use smtp instead of mail', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_host', '', 'set smtp host', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_port', '25', 'set port of host', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_username', '', 'set username for authentification', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_password', '', 'set password for authentification', ''); INSERT INTO settings (name, value, description, selection) VALUES ('dev.toolbar', '0', 'show developer toolbar', ''); INSERT INTO settings (name, value, description, selection) VALUES ('pagealias.use', '1', 'enable pagealias', ''); INSERT INTO settings (name, value, description, selection) VALUES ('pagealias.rights', '2', 'set rights to edit the alias', ''); INSERT INTO settings (name, value, description, selection) VALUES ('pagealias.static', '0', 'enable of using static links', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.maxfilesize', '5242880', 'set maxfilesize for uploads', ''); INSERT INTO settings (name, value, description, selection) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.order.self', '0', 'enable self ordering of tree elments', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.context', '1', 'enable/disable contextmenus', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.edittooltiptext', '0', 'enable/disable edit of tooltiptext of tree element', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showcounter', '1', 'enable/disable counting of tree items', ''); INSERT INTO settings (name, value, description, selection) VALUES ('content.showcounter', '1', 'enable/disable counting of content items', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayout', '0', 'enable/disable a default layout of the tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayoutarray', '', 'serialized array with default layout of tree - should not be edit', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showlogo', '0', 'show knowledgeroot logo instead of texttitle', ''); INSERT INTO settings (name, value, description, selection) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); /* CREATE INDEX idx_content ON content USING btree (belongs_to); CREATE INDEX idx_content_owner ON content USING btree (owner); CREATE INDEX idx_content_group ON content USING btree ("group"); CREATE INDEX idx_content_userrights ON content USING btree (userrights); CREATE INDEX idx_content_grouprights ON content USING btree (grouprights); CREATE INDEX idx_content_otherrights ON content USING btree (otherrights); CREATE INDEX idx_content_deleted ON content USING btree (deleted); CREATE INDEX idx_content_open_contentid ON content_open USING btree (contentid); CREATE INDEX idx_content_open_userid ON content_open USING btree (userid); CREATE INDEX idx_files ON files USING btree (belongs_to); CREATE INDEX idx_files_deleted ON files USING btree (deleted); CREATE INDEX idx_groups_deleted ON groups USING btree (deleted); CREATE INDEX idx_tree ON tree USING btree (belongs_to); CREATE INDEX idx_tree_owner ON tree USING btree (owner); CREATE INDEX idx_tree_group ON tree USING btree ("group"); CREATE INDEX idx_tree_userrights ON tree USING btree (userrights); CREATE INDEX idx_tree_grouprights ON tree USING btree (grouprights); CREATE INDEX idx_tree_otherrights ON tree USING btree (otherrights); CREATE INDEX idx_tree_deleted ON tree USING btree (deleted); CREATE INDEX idx_user_group_userid ON user_group USING btree (userid); CREATE INDEX idx_user_group_groupid ON user_group USING btree (groupid); CREATE INDEX idx_users ON users USING btree (name); CREATE INDEX idx_users_password ON users USING btree (password); CREATE INDEX idx_users_deleted ON users USING btree (deleted); CREATE INDEX idx_extensions ON extensions USING btree (active); */ knowledgeroot-0.9.9.5/dumps/mysql.sql0000644000175000017500000003542111235127064020567 0ustar fhabermannfhabermannCREATE TABLE `access` ( `id` int(11) NOT NULL auto_increment, `table_name` varchar(255) NOT NULL DEFAULT '', `belongs_to` int(11) NOT NULL DEFAULT 0, `owner_group` varchar(5) NOT NULL DEFAULT '', `owner_group_id` int(11) NOT NULL DEFAULT 0, `rights` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `content` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) default NULL, `belongs_to` int(11) NOT NULL default '0', `content` mediumtext NOT NULL, `type` varchar(255) NOT NULL default 'text', `sorting` int(11) NOT NULL default '0', `owner` int(11) NOT NULL default '0', `lastupdatedby` int(11) NOT NULL default '0', `lastupdated` timestamp NOT NULL, `group` int(11) NOT NULL default '0', `userrights` int(11) NOT NULL default '0', `grouprights` int(11) NOT NULL default '0', `otherrights` int(11) NOT NULL default '0', `deleted` int(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `belongs_to` (`belongs_to`), KEY `owner` (`owner`), KEY `group` (`group`), KEY `userrights` (`userrights`), KEY `grouprights` (`grouprights`), KEY `otherrights` (`otherrights`), KEY `deleted` (`deleted`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `content_open` ( `id` int(11) NOT NULL auto_increment, `contentid` int(11) NOT NULL default '0', `userid`varchar(32) NOT NULL default '', `opened` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `contentid` (`contentid`), KEY `userid` (`userid`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `files` ( `id` int(11) NOT NULL auto_increment, `belongs_to` int(11) default NULL, `file` longblob, `filename` varchar(255) default NULL, `filesize` int(11) default NULL, `filetype` varchar(255) default 'application/octet-stream', `owner` int(11) NOT NULL default '0', `date` timestamp NOT NULL, `counter` int(11) NOT NULL default '0', `deleted` int(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `belongs_to` (`belongs_to`), KEY `deleted` (`deleted`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `groups` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '', `enabled` int(1) NOT NULL default '0', `deleted` int(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `deleted` (`deleted`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `tree` ( `id` int(11) NOT NULL auto_increment, `belongs_to` int(11) NOT NULL default '0', `title` varchar(255) NOT NULL default '', `tooltip` varchar(255) NOT NULL default '', `alias` varchar(255) NOT NULL default '', `contentcollapsed` int(1) NOT NULL default '0', `owner` int(11) NOT NULL default '0', `group` int(11) NOT NULL default '0', `userrights` int(11) NOT NULL default '0', `grouprights` int(11) NOT NULL default '0', `otherrights` int(11) NOT NULL default '0', `subinheritrights` int(1) NOT NULL default '0', `subinheritrightseditable` int(1) NOT NULL default '0', `subinheritrightsdisable` int(1) NOT NULL default '0', `subinheritowner` int(11) NOT NULL default '0', `subinheritgroup` int(11) NOT NULL default '0', `subinherituserrights` int(11) NOT NULL default '0', `subinheritgrouprights` int(11) NOT NULL default '0', `subinheritotherrights` int(11) NOT NULL default '0', `symlink` int(11) NOT NULL default '0', `sorting` int(11) NOT NULL default '0', `deleted` int(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `belongs_to` (`belongs_to`), KEY `owner` (`owner`), KEY `group` (`group`), KEY `userrights` (`userrights`), KEY `grouprights` (`grouprights`), KEY `otherrights` (`otherrights`), KEY `deleted` (`deleted`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `user_group` ( `id` int(11) NOT NULL auto_increment, `userid` int(11) NOT NULL default '0', `groupid` int(11) NOT NULL default '0', PRIMARY KEY (`id`), KEY `userid` (`userid`), KEY `groupid` (`groupid`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `users` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL default '', `password` varchar(32) NOT NULL default '', `theme` varchar(255) NOT NULL default '', `language` varchar(255) NOT NULL default '', `enabled` int(1) NOT NULL default '0', `defaultgroup` int(11) NOT NULL default '0', `defaultrights` int(3) NOT NULL default '0', `admin` int(1) NOT NULL default '0', `rightedit` int(1) NOT NULL default '0', `treecache` text NOT NULL, `deleted` int(1) NOT NULL default '0', PRIMARY KEY (`id`), KEY `password` (`password`), KEY `deleted` (`deleted`) ) TYPE=MyISAM AUTO_INCREMENT=3 ; CREATE TABLE `extensions` ( `id` INT NOT NULL AUTO_INCREMENT , `keyname` VARCHAR( 255 ) NOT NULL , `active` INT NOT NULL , `admin` INT NOT NULL DEFAULT '0', `version` VARCHAR(30) NOT NULL DEFAULT '', PRIMARY KEY ( `id` ), KEY `active` (`active`) ); CREATE TABLE `settings` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) NOT NULL , `value` text NOT NULL , `description` VARCHAR( 255) NOT NULL DEFAULT '', `selection` VARCHAR(255) NOT NULL DEFAULT '', PRIMARY KEY ( `id` ) , UNIQUE (`name`) ); CREATE TABLE `users_login` ( `usersid` int(10) unsigned NOT NULL default '0', `login_trial` int(10) unsigned NOT NULL default '0', `lasttrydate` int(11) unsigned NOT NULL default '0', `session_id` varchar(100) NOT NULL default '', UNIQUE KEY `usersid` (`usersid`) ); INSERT INTO `users` ( `id` , `name` , `password` , `enabled` , `defaultgroup` , `defaultrights` , `admin` , `rightedit` , `treecache` ) VALUES ( '1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '1', '1', '210', '1', '1', '' ); INSERT INTO `groups` ( `id` , `name` , `enabled` ) VALUES ( '1', 'admin', '1' ); INSERT INTO `groups` ( `id` , `name` , `enabled` ) VALUES ( '2', 'users', '1' ); # Enable extensions INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('admin_extension', 1, 1); INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('admin_info', 1, 1); # INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('admin_install', 1, 1); # INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('admin_update', 1, 1); INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('admin_config', 1, 1); INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('fckeditor', 1, 0); INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('tinymce', 0, 0); # insert default settings INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('login.delay', '30', 'setting login delay', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('login.max', '50', 'setting max login', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.charset', 'UTF-8', 'set charset', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.language', 'en', 'set default language', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.language_dropdown', '0', 'show language dropdown', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.use', '1', 'enable rte editor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.editor', 'fckeditor', 'choose fckeditor or tinymce', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.tinymce.cols', '75' , 'set cols for textarea in tinymce', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.tinymce.rows', '20', 'set rows for textarea in tinymce', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.fckeditor.width', '600', 'set widht of fckeditor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.fckeditor.height', '450', 'set height of fckeditor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.fckeditor.langdefault', 'en', 'set default lang in default fckeditor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.fckeditor.langdetect', 'false', 'enable autodetection of language in fckeditor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.fckeditor.toolbar', 'Default', 'choose toolbar in fckeditor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('htmleditor.fckeditor.skin', 'default', 'choose skin in fckeditor', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.title', 'Knowledgeroot', 'set title for knowledgeroot', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.expandall', '1', 'expand menu at default', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.type', 'static', 'set menu type', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.ajax', 'yes', 'use ajax menu', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.default_theme', 'green', 'set theme in knowledgeroot', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.showtitle', 'yes', 'show title of contents', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.collapsecontent', 'yes', 'enable collapse content', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.showlastupdated', 'yes', 'show lastupdate of content', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.uploadfolder', 'uploads/', 'set upload folder', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.uploadserverpath', 'auto', 'set upload server path', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.defaultpage', '', 'set id of default page', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.notification', '0', 'enable email notification', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.recipients', '', 'set recipients', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.type', 'html', 'enable html mails', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.from_name', 'Knowledgeroot', 'set from name', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.from_email', 'knowledgeroot@mydomain.tld', 'set from email', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.smtp_mode', '0', 'enable to use smtp instead of mail', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.smtp_host', '', 'set smtp host', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.smtp_port', '25', 'set port of host', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.smtp_username', '', 'set username for authentification', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('email.smtp_password', '', 'set password for authentification', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('dev.toolbar', '0', 'show developer toolbar', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('pagealias.use', '1', 'enable pagealias', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('pagealias.rights', '2', 'set rights to edit the alias', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('pagealias.static', '0', 'enable of using static links', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.maxfilesize', '5242880', 'set maxfilesize for uploads', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.order.self', '0', 'enable self order of tree elements', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.context', '1', 'enable/disable context menus', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.edittooltiptext', '0', 'enable/disable edit of tooltiptext of tree element', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.showcounter', '1', 'enable/disable counting of tree items', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('content.showcounter', '1', 'enable/disable counting of content items', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.defaultlayout', '0', 'enable/disable a default layout of the tree', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.defaultlayoutarray', '', 'serialized array with default layout of tree - should not be edit', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.showlogo', '0', 'show knowledgeroot logo instead of texttitle', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); knowledgeroot-0.9.9.5/dumps/upgrade_mysql_diff.sql0000644000175000017500000000515311235362247023271 0ustar fhabermannfhabermannCREATE TABLE `access` ( `id` int(11) NOT NULL auto_increment, `table_name` varchar(255) NOT NULL DEFAULT '', `belongs_to` int(11) NOT NULL DEFAULT 0, `owner_group` varchar(5) NOT NULL DEFAULT '', `owner_group_id` int(11) NOT NULL DEFAULT 0, `rights` int(11) NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; ALTER TABLE `files` ADD `counter` int(11) DEFAULT '0' NOT NULL; ALTER TABLE `tree` ADD `symlink` int(11) DEFAULT '0' NOT NULL; ALTER TABLE `tree` ADD `sorting` int(11) DEFAULT '0' NOT NULL; ALTER TABLE `settings` CHANGE `value` `value` TEXT NOT NULL; INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('fckeditor', 1, 0); INSERT INTO `extensions` (`keyname`, `active`, `admin`) VALUES ('tinymce', 0, 0); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.order.self', '0', 'enable self order of tree elements', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.context', '1', 'enable/disable context menus', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO `settings` (`name`, `value`, `description`, `selection`) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); knowledgeroot-0.9.9.5/dumps/postgre.sql0000644000175000017500000003341411231141132021071 0ustar fhabermannfhabermannBEGIN; CREATE SEQUENCE seq_knowledge; CREATE TABLE access ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), table_name varchar(255) DEFAULT '', belongs_to integer DEFAULT 0, owner_group varchar(5) DEFAULT '', owner_group_id integer DEFAULT 0, rights integer DEFAULT 0 ); CREATE TABLE content ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), title varchar(255) DEFAULT '', belongs_to integer DEFAULT 0, content text DEFAULT '', type varchar(255) DEFAULT 'text', sorting integer DEFAULT 0, owner integer DEFAULT 0, "group" integer DEFAULT 0, lastupdatedby integer DEFAULT 0, lastupdated timestamp DEFAULT now(), userrights integer DEFAULT 0, grouprights integer DEFAULT 0, otherrights integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE content_open ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), contentid integer DEFAULT 0, userid varchar(32) DEFAULT '', opened integer DEFAULT 0 ); CREATE TABLE tree ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), belongs_to integer DEFAULT 0, title varchar(255) DEFAULT '', tooltip varchar(255) DEFAULT '', alias varchar(255) DEFAULT '', contentcollapsed integer DEFAULT 0, owner integer DEFAULT 0, "group" integer DEFAULT 0, userrights integer DEFAULT 0, grouprights integer DEFAULT 0, otherrights integer DEFAULT 0, subinheritrights integer DEFAULT 0, subinheritrightseditable integer DEFAULT 0, subinheritrightsdisable integer DEFAULT 0, subinheritowner integer DEFAULT 0, subinheritgroup integer DEFAULT 0, subinherituserrights integer DEFAULT 0, subinheritgrouprights integer DEFAULT 0, subinheritotherrights integer DEFAULT 0, symlink integer DEFAULT 0, sorting integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE files ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), belongs_to integer DEFAULT 0, object oid, filename varchar(255) DEFAULT '', filesize integer DEFAULT 0, filetype varchar(255) DEFAULT 'application/octet-stream', owner integer DEFAULT 0, date timestamp DEFAULT now(), counter integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE users ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), name varchar(255) DEFAULT '', "password" varchar(32) DEFAULT '', theme varchar(255) DEFAULT '', language varchar(255) DEFAULT '', enabled integer DEFAULT 0, defaultgroup integer DEFAULT 0, defaultrights varchar(3) DEFAULT '211', admin integer DEFAULT 0, rightedit integer DEFAULT 0, treecache text, deleted integer DEFAULT 0 ); CREATE TABLE groups ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), name varchar(255) DEFAULT '', enabled integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE user_group ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), userid integer DEFAULT 0, groupid integer DEFAULT 0 ); CREATE TABLE extensions ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), keyname varchar(255) DEFAULT '', active integer DEFAULT 0, admin integer DEFAULT 0, version varchar(30) DEFAULT '' ); CREATE TABLE settings ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), name varchar(255) NOT NULL, value text DEFAULT '', description varchar(255) NOT NULL DEFAULT '', selection varchar(255) NOT NULL DEFAULT '', UNIQUE (name) ); CREATE TABLE users_login ( usersid integer default 0, login_trial integer default 0, lasttrydate integer default 0, session_id varchar(100) default '', UNIQUE (usersid) ); INSERT INTO groups (name, enabled) VALUES ('admin', 1); INSERT INTO groups (name, enabled) VALUES ('users', 1); INSERT INTO users (name, password, enabled, admin, rightedit, defaultgroup, defaultrights) VALUES ('admin', '21232f297a57a5a743894a0e4a801fc3', 1, 1, 1, (SELECT id FROM groups WHERE name='admin'), 210); INSERT INTO extensions (keyname, active, admin) VALUES ('admin_extension', 1, 1); INSERT INTO extensions (keyname, active, admin) VALUES ('admin_info', 1, 1); -- INSERT INTO extensions (keyname, active, admin) VALUES ('admin_install', 1, 1); -- INSERT INTO extensions (keyname, active, admin) VALUES ('admin_update', 1, 1); INSERT INTO extensions (keyname, active, admin) VALUES ('admin_config', 1, 1); INSERT INTO extensions (keyname, active, admin) VALUES ('fckeditor', 1, 0); INSERT INTO extensions (keyname, active, admin) VALUES ('tinymce', 0, 0); INSERT INTO settings (name, value, description, selection) VALUES ('login.delay', '30', 'setting login delay', ''); INSERT INTO settings (name, value, description, selection) VALUES ('login.max', '50', 'setting max login', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.charset', 'UTF-8', 'set charset', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.language', 'en', 'set default language', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.language_dropdown', '0', 'show language dropdown', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.use', '1', 'enable rte editor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.editor', 'fckeditor', 'choose fckeditor or tinymce', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.tinymce.cols', '75' , 'set cols for textarea in tinymce', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.tinymce.rows', '20', 'set rows for textarea in tinymce', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.width', '600', 'set widht of fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.height', '450', 'set height of fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.langdefault', 'en', 'set default lang in default fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.langdetect', 'false', 'enable autodetection of language in fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.toolbar', 'Default', 'choose toolbar in fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('htmleditor.fckeditor.skin', 'default', 'choose skin in fckeditor', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.title', 'Knowledgeroot', 'set title for knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.expandall', '1', 'expand menu at default', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.type', 'static', 'set menu type', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.ajax', 'yes', 'use ajax menu', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.default_theme', 'green', 'set theme in knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showtitle', 'yes', 'show title of contents', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.collapsecontent', 'yes', 'enable collapse content', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showlastupdated', 'yes', 'show lastupdate of content', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.uploadfolder', 'uploads/', 'set upload folder', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.uploadserverpath', 'auto', 'set upload server path', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.defaultpage', '', 'set id of default page', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.notification', '0', 'enable email notification', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.recipients', '', 'set recipients', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.type', 'html', 'enable html mails', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.from_name', 'Knowledgeroot', 'set from name', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.from_email', 'knowledgeroot@mydomain.tld', 'set from email', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_mode', '0', 'enable to use smtp instead of mail', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_host', '', 'set smtp host', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_port', '25', 'set port of host', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_username', '', 'set username for authentification', ''); INSERT INTO settings (name, value, description, selection) VALUES ('email.smtp_password', '', 'set password for authentification', ''); INSERT INTO settings (name, value, description, selection) VALUES ('dev.toolbar', '0', 'show developer toolbar', ''); INSERT INTO settings (name, value, description, selection) VALUES ('pagealias.use', '1', 'enable pagealias', ''); INSERT INTO settings (name, value, description, selection) VALUES ('pagealias.rights', '2', 'set rights to edit the alias', ''); INSERT INTO settings (name, value, description, selection) VALUES ('pagealias.static', '0', 'enable of using static links', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.maxfilesize', '5242880', 'set maxfilesize for uploads', ''); INSERT INTO settings (name, value, description, selection) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.order.self', '0', 'enable self ordering of tree elments', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.context', '1', 'enable/disable contextmenus', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.edittooltiptext', '0', 'enable/disable edit of tooltiptext of tree element', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showcounter', '1', 'enable/disable counting of tree items', ''); INSERT INTO settings (name, value, description, selection) VALUES ('content.showcounter', '1', 'enable/disable counting of content items', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayout', '0', 'enable/disable a default layout of the tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayoutarray', '', 'serialized array with default layout of tree - should not be edit', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showlogo', '0', 'show knowledgeroot logo instead of texttitle', ''); INSERT INTO settings (name, value, description, selection) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); CREATE INDEX idx_content ON content USING btree (belongs_to); CREATE INDEX idx_content_owner ON content USING btree (owner); CREATE INDEX idx_content_group ON content USING btree ("group"); CREATE INDEX idx_content_userrights ON content USING btree (userrights); CREATE INDEX idx_content_grouprights ON content USING btree (grouprights); CREATE INDEX idx_content_otherrights ON content USING btree (otherrights); CREATE INDEX idx_content_deleted ON content USING btree (deleted); CREATE INDEX idx_content_open_contentid ON content_open USING btree (contentid); CREATE INDEX idx_content_open_userid ON content_open USING btree (userid); CREATE INDEX idx_files ON files USING btree (belongs_to); CREATE INDEX idx_files_deleted ON files USING btree (deleted); CREATE INDEX idx_groups_deleted ON groups USING btree (deleted); CREATE INDEX idx_tree ON tree USING btree (belongs_to); CREATE INDEX idx_tree_owner ON tree USING btree (owner); CREATE INDEX idx_tree_group ON tree USING btree ("group"); CREATE INDEX idx_tree_userrights ON tree USING btree (userrights); CREATE INDEX idx_tree_grouprights ON tree USING btree (grouprights); CREATE INDEX idx_tree_otherrights ON tree USING btree (otherrights); CREATE INDEX idx_tree_deleted ON tree USING btree (deleted); CREATE INDEX idx_user_group_userid ON user_group USING btree (userid); CREATE INDEX idx_user_group_groupid ON user_group USING btree (groupid); CREATE INDEX idx_users ON users USING btree (name); CREATE INDEX idx_users_password ON users USING btree (password); CREATE INDEX idx_users_deleted ON users USING btree (deleted); CREATE INDEX idx_extensions ON extensions USING btree (active); COMMIT; knowledgeroot-0.9.9.5/dumps/upgrade_postgre.sql0000644000175000017500000000674711231141132022611 0ustar fhabermannfhabermannBEGIN; CREATE TABLE access ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), table_name varchar(255) DEFAULT '', belongs_to integer DEFAULT 0, owner_group varchar(5) DEFAULT '', owner_group_id integer DEFAULT 0, rights integer DEFAULT 0 ); ALTER TABLE files ADD COLUMN counter integer; ALTER TABLE files ALTER COLUMN counter SET DEFAULT 0; ALTER TABLE tree ADD COLUMN symlink integer; ALTER TABLE tree ALTER COLUMN symlink SET DEFAULT 0; ALTER TABLE tree ADD COLUMN sorting integer; ALTER TABLE tree ALTER COLUMN sorting SET DEFAULT 0; ALTER TABLE tree ADD COLUMN tooltip varchar(255); ALTER TABLE tree ALTER COLUMN tooltip SET DEFAULT ''; ALTER TABLE settings ALTER COLUMN value TYPE text; INSERT INTO extensions (keyname, active, admin) VALUES ('fckeditor', 1, 0); INSERT INTO extensions (keyname, active, admin) VALUES ('tinymce', 0, 0); INSERT INTO settings (name, value, description, selection) VALUES ('downloads.static', '0', 'enable static download links', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.order.self', '0', 'enable self ordering of tree elments', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.handle', '0', 'enable handling of sessin', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.lifetime', '60', 'lifetime of session in minutes', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkIP', '0', 'check ip of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.checkBrowser', '0', 'check browser of session', ''); INSERT INTO settings (name, value, description, selection) VALUES ('session.onlyCookies', '0', 'allow only cookie sessions', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.context', '1', 'enable/disable contextmenus', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.dragdrop', '1', 'enable/disable drag and drop in tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.recursivdelete', '2', 'set recusriv delete, 2 - only admins; 1 - all users with login, 0 - all users', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.edittooltiptext', '0', 'enable/disable edit of tooltiptext of tree element', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showcounter', '1', 'enable/disable counting of tree items', ''); INSERT INTO settings (name, value, description, selection) VALUES ('content.showcounter', '1', 'enable/disable counting of content items', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayout', '0', 'enable/disable a default layout of the tree', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.defaultlayoutarray', '', 'serialized array with default layout of tree - should not be edit', ''); INSERT INTO settings (name, value, description, selection) VALUES ('menu.showsourceforgelogo', '0', 'show sourceforge logo', ''); INSERT INTO settings (name, value, description, selection) VALUES ('knowledgeroot.showlogo', '0', 'show knowledgeroot logo instead of texttitle', ''); INSERT INTO settings (name, value, description, selection) VALUES ('version', '0.9.9', 'knowledgeroot version - do not edit! - it only shows the database version of knowledgeroot', ''); INSERT INTO settings (name, value, description, selection) VALUES ('baseurl', '', 'base url for knowledgeroot', ''); COMMIT; knowledgeroot-0.9.9.5/dumps/postgre-ref.sql0000644000175000017500000000505510436333720021657 0ustar fhabermannfhabermannBEGIN; CREATE SEQUENCE seq_knowledge; CREATE TABLE users ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), name varchar(255) DEFAULT '', "password" varchar(255) DEFAULT '', enabled integer DEFAULT 0, defaultgroup integer DEFAULT 0, defaultrights varchar(3) DEFAULT '211', admin integer DEFAULT 0, rightedit integer DEFAULT 0, treecache text, deleted integer DEFAULT 0 ); CREATE TABLE groups ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), name varchar(255) DEFAULT '', enabled integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE user_group ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), userid integer DEFAULT 0 REFERENCES users (id) ON DELETE RESTRICT, groupid integer DEFAULT 0 REFERENCES groups (id) ON DELETE RESTRICT ); CREATE TABLE tree ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), belongs_to integer DEFAULT 0, title varchar(255) DEFAULT '', owner integer DEFAULT 0 REFERENCES users (id) ON DELETE RESTRICT, "group" integer DEFAULT 0 REFERENCES groups (id) ON DELETE RESTRICT, userrights integer DEFAULT 0, grouprights integer DEFAULT 0, otherrights integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE content ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), belongs_to integer DEFAULT 0 REFERENCES tree (id) ON DELETE RESTRICT, content text DEFAULT '', owner integer DEFAULT 0 REFERENCES users (id) ON DELETE RESTRICT, "group" integer DEFAULT 0 REFERENCES groups (id) ON DELETE RESTRICT, userrights integer DEFAULT 0, grouprights integer DEFAULT 0, otherrights integer DEFAULT 0, deleted integer DEFAULT 0 ); CREATE TABLE files ( id integer PRIMARY KEY DEFAULT nextval('seq_knowledge'), belongs_to integer DEFAULT 0 REFERENCES content (id) ON DELETE RESTRICT, object oid, filename varchar(255) DEFAULT '', filesize integer DEFAULT 0, filetype varchar(255) DEFAULT 'application/octet-stream', owner integer DEFAULT 0 REFERENCES users (id) ON DELETE RESTRICT, date timestamp DEFAULT now(), deleted integer DEFAULT 0 ); CREATE INDEX idx_content ON content USING btree (belongs_to); CREATE INDEX idx_tree ON tree USING btree (belongs_to); CREATE INDEX idx_files ON files USING btree (belongs_to); CREATE INDEX idx_users ON users USING btree (name); INSERT INTO groups (name, enabled) VALUES ('admin', 1); INSERT INTO groups (name, enabled) VALUES ('users', 1); INSERT INTO users (name, password, enabled, admin, rightedit, defaultgroup, defaultrights) VALUES ('admin', '21232f297a57a5a743894a0e4a801fc3', 1, 1, 1, (SELECT id FROM groups WHERE name='admin'), 210); COMMIT;knowledgeroot-0.9.9.5/include/0000755000175000017500000000000011273105226017165 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/include/class-knowledgeroot-themes.php0000644000175000017500000000571610630611666025166 0ustar fhabermannfhabermannCLASS =& $CLASS; if(isset($this->CLASS['vars']['include_prefix']) && $this->CLASS['vars']['include_prefix'] != "") { $this->theme_folder = $this->CLASS['vars']['include_prefix'] . $this->theme_folder; } $this->search_themes(); if(isset($this->CLASS['vars']['knowledgeroot']['default_theme'])) { $this->use_theme = $this->CLASS['vars']['knowledgeroot']['default_theme']; } } /** * */ function search_themes() { if($handle = opendir($this->theme_folder)) { while(false !== ($file = readdir($handle))) { if($file != "." && $file != "..") { $infofile = $this->theme_folder.$file."/info.php"; if(is_file($infofile)) { $theme = array(); include($infofile); $cssfile = $this->theme_folder.$file."/".$theme['css_file']; if(is_file($cssfile)) { $this->themes[$theme['name']] = $theme; } } } } } } /** * load a theme to internal theme array */ function load_ext_theme($themeArr) { if($themeArr['name'] != "") { $this->themes[$themeArr['name']] = $themeArr; } } /** * return path to css_file */ function load_theme() { if (isset ($_SESSION['theme']) and $_SESSION['theme'] != "") { $this->use_theme = $_SESSION['theme']; } if(isset($this->themes[$this->default_theme]['path']) && is_file($this->themes[$this->default_theme]['path']."/".$this->themes[$this->default_theme]['css_file'])) { $default_css_file = $this->themes[$this->default_theme]['path']."/".$this->themes[$this->default_theme]['css_file']; } else { $default_css_file = $this->theme_folder . $this->default_theme . "/" . $this->themes[$this->default_theme]['css_file']; } if(isset($this->themes[$this->use_theme]['path']) && is_file($this->themes[$this->use_theme]['path']."/".$this->themes[$this->use_theme]['css_file'])) { $use_css_file = $this->themes[$this->use_theme]['path']."/".$this->themes[$this->use_theme]['css_file']; } else { $use_css_file = $this->theme_folder . $this->use_theme . "/" . $this->themes[$this->use_theme]['css_file']; } if(is_file($use_css_file)) { $css = $use_css_file; } else { $css = $default_css_file; } return $css; } /** * return dropdown with themes */ function theme_dropdown($default = "", $name = "theme") { $out = "\n"; return $out; } } ?>knowledgeroot-0.9.9.5/include/class-error.php0000644000175000017500000001535710653210547022151 0ustar fhabermannfhabermannCLASS =& $CLASS; if(isset($this->CLASS['vars']['log'])) $this->CONF = $this->CLASS['vars']['log']; if(isset($this->CONF['setPhpError']) && is_bool($this->CONF['setPhpError'])) { $this->setPhpError = $this->CONF['setPhpError']; } if(isset($this->CONF['setPhpErrorReporting']) && $this->CONF['setPhpErrorReporting'] != "") { $this->setPhpErrorReporting = $this->CONF['setPhpErrorReporting']; } if($this->setPhpError == true) { // set error reporting ini_set('error_reporting', $this->setPhpErrorReporting); if(isset($this->CONF['type']) && $this->CONF['type'] != "" && $this->CONF['type'] != "none") { $type = explode(",", $this->CONF['type']); $found_screen = false; $found_apache = false; $found_logfile = false; foreach($type as $key => $value) { if(trim($value) == "screen") { ini_set('display_errors', 1); $found_screen = true; } if(trim($value) == "apache") { ini_set('error_log', 'syslog'); $found_apache = true; } if(trim($value) == "logfile") { if(isset($this->CONF['logfile']) && $this->CONF['logfile'] != "") { ini_set('error_log', $this->CONF['logfile']); } else { ini_set('error_log', 'syslog'); } $found_logfile = true; } } // at default disable error msg to screen if($found_screen == false) { ini_set('display_errors', 0); } // at default disable error msg to syslog or logfile if($found_apache == false && $found_logfile == false) { ini_set('error_log', ''); } } } } /** * Debug_Out gibt Variableninfos aus * * Aufrufbeispiel: * $a = array(1, 2, array("a", "b", "c")); * Debug_Out($a); * * Aufruf in Knowledgeroot: * $this->CLASS['error']->DebugOut($foo) * * @param mixed auszugebene Variablendaten * @param mixed Anweisungen fuer die switch-Abfrage * 'sql' - speziell formatierte Ausgabe * @param bool 0 (default): Ausgabe erfolgt per var_export() * 1: Ausgabe erfolgt per var_dump() */ function Debug_Out($input, $spezial = '', $dumpexport = 0) { //echo '
'; $return = ''; switch ($spezial) { case 'sql': if ($spezial == 'sql') { $return .= "\n".nl2br($input)."

\n"; } break; default: if (is_array($input) or is_object($input)) { ob_start(); if ($dumpexport) { var_dump ($input); } else { var_export ($input); } $return .= "\n
".ob_get_contents().'

'."\n"; ob_end_clean(); } if (!is_array($input)) { $return .= $input.'
'."\n"; } break; } // switch ($spezial) flush(); // setze vor die Ausgabe einen deutlichen Hinweis auf die Debug-Ausgabe $return = 'DEBUGOUT: '. $return."\n"; // gib die Debuginfos aus echo $return; return true; } /** * DebugOut * * @see Debug_Out */ function DebugOut($input, $spezial = '', $dumpexport = 0) { return $this->Debug_Out($input, $spezial, $dumpexport); } /** * Returns HTML-code, which is a visual representation of a multidimensional array * use $this->print_array() in order to print an array * Returns false if $array_in is not an array * Usage: * echo $this->CLASS['error']->view_array($foo) * * @param array Array to view * @return string HTML output */ function view_array($array_in) { if (is_array($array_in)) { $result=''; if (!count($array_in)) {$result.= '';} while (list($key,$val)=each($array_in)) { $result.= ''; } $result.= '
'.htmlspecialchars("EMPTY!").'
'.htmlspecialchars((string)$key).''; if (is_array($array_in[$key])) { $result.=$this->view_array($array_in[$key]); } else $result.= ''.nl2br(htmlspecialchars((string)$val)).'
'; $result.= '
'; } else { echo "noarray"; $result = false; } return $result; } /** * save message to logfile * Usage: $this-CLASS['error']->log("mymessage"); * * @param string string to log * @param string sourcefile */ function log($msg,$level = 1,$backtrackarr = "") { if($level > 0 || (isset($this->CONF['level']) && $this->CONF['level'] > 0)) { if(isset($this->CONF['type']) && $this->CONF['type'] != "" && $this->CONF['type'] != "none") { $type = explode(",", $this->CONF['type']); $time = date("Y-m-d H:i:s", time()); // build message $out = "[" . $time . "] [ERROR]: " . $msg . "\n"; $backtrack = ""; if(is_array($backtrackarr)) { foreach($backtrackarr as $keyb => $valueb) { if(!is_array($valueb)) { $backtrack .= "[" . $time . "] [BACKTRACK]: " . $backtrackarr[$keyb] . "\n"; } } } elseif($backtrackarr != "") { $backtrack .= "[" . $time . "] [BACKTRACK]: " . $backtrackarr . "\n"; } foreach($type as $key => $value) { $value = trim($value); if($value == "screen") { echo $out . (($this->showBrOnScreen == true) ? "
" : "") . "\n"; if($backtrack != "") echo $backtrack . (($this->showBrOnScreen == true) ? "
" : "") . "\n"; } if($value == "apache") { error_log($out . $backtrack); } if($value == "mail") { if(isset($this->CONF['mail']) && $this->CONF['mail'] != "" && $this->CONF['mail_extra_header'] != "") { error_log($out . $backtrack,1,$this->CONF['mail'],$this->CONF['mail_extra_header']); } elseif(isset($this->CONF['mail']) && $this->CONF['mail'] != "") { error_log($out . $backtrack,1,$this->CONF['mail']); } } if($value == "logfile") { if(isset($this->CONF['logfile']) && $this->CONF['logfile'] != "") { error_log($out . $backtrack,3,$this->CONF['logfile']); } else { error_log($out . $backtrack); } } } } } } } ?> knowledgeroot-0.9.9.5/include/function.php0000644000175000017500000000254610521456545021542 0ustar fhabermannfhabermann 1024) { $byte = round($byte / 1024,$precision); $a++; } if($a == 0) $size = "B"; elseif($a == 1) $size = "KB"; elseif($a == 2) $size = "MB"; elseif($a == 3) $size = "GB"; else return "Wrong Size"; $bsize = "$byte $size"; return $bsize; } /** * Liefert eine Ziffer mit angehangener Groessenangabe zurueck * * @access public * @param int $size * @return mix Ziffer+Groessenangabe */ function getFormattedSize($size) { // Setup some common file size measurements. $kb = 1024; // Kilobyte $mb = 1024 * $kb; // Megabyte $gb = 1024 * $mb; // Gigabyte $tb = 1024 * $gb; // Terabyte // Get the file size in bytes. // If it's less than a kb we just return the size, otherwise we keep going until // the size is in the appropriate measurement range. switch ($size) { case $size < $mb: return round($size / $kb, 2)." KBytes"; break; case $size < $gb: return round($size / $mb, 2)." MBytes"; break; case $size < $tb: return round($size / $gb, 2)." GBytes"; break; case $size >= $tb: return round($size / $tb, 2)." TBytes"; break; default: case $size < $kb: return $size." Bytes"; break; } } ?>knowledgeroot-0.9.9.5/include/class-mysql.php0000644000175000017500000000647611000753003022151 0ustar fhabermannfhabermannCLASS['vars']['db']['pconnect']) && $this->CLASS['vars']['db']['pconnect'] == 1) { $this->connection = mysql_pconnect($host,$user,$pass); } else { $this->connection = mysql_connect($host,$user,$pass); } if(!$this->connection) { $this->CLASS['error']->log("Cannnot connect to host!",1,"class-mysql.php::connect"); exit(); } $conndb = mysql_select_db($db); if(!$conndb) { $this->CLASS['error']->log("Wrong Database!",1,"class-mysql.php::connect"); exit(); } return $this->connection; } /** * Close mysql connection * @return bool */ function close() { return mysql_close($this->connection); } /** * Will make a query with the mysql server * @param string $query * @return mixed return query result */ function query($query) { $this->lastquery = $query; $this->query_cache[] = $query; $this->querys += 1; $res = new db_result($this->CLASS); $res->setQuery($query); $res->setResult(mysql_query($query, $this->connection)); if($res->getResult() === false) { $this->CLASS['error']->log("ERROR IN QUERY: \"$query\"",1,mysql_errno() . ":".mysql_errno()); } return $res; } /** * Will count the rows of a resultset * @param mixed $result * @return int */ function num_rows($result) { return mysql_num_rows($result->getResult()); } /** * Fetch a Result as Object * @param mixed $result * @return object */ function fetch_object($result) { return mysql_fetch_object($result->getResult()); } /** * Return Result as Array * @param mixed $result * @return array */ function fetch_row($result) { return mysql_fetch_row($result->getResult()); } /** * Return Result as hash array * @param mixed result * @return array */ function fetch_assoc($result) { return mysql_fetch_assoc($result->getResult()); } /** * Return affected rows of a result * @param mixed $result * @return int */ function affected_rows($result) { return mysql_affected_rows($result->getResult()); } /** * Returns the text of the error message from previous MySQL operation * @return string */ function error() { return mysql_error($this->connection); } /** * Return the last inserted id from a query * @param string $name not required * @return int */ function last_id($name = "") { return mysql_insert_id(); } /** * Quote a String with Mysql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return "`" . $string . "`"; } /** * do data seek on result * @param resource $result * @param integer $number * @return bool */ function data_seek($result, $number) { return mysql_data_seek($result->getResult(), $number); } } ?> knowledgeroot-0.9.9.5/include/class-db-result.php0000644000175000017500000000347211000753003022676 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * constructor for php4 * @param array $CLASS */ function db_result(&$CLASS) { $this->CLASS =& $CLASS; } /** * get result * @return resource */ function getResult() { return $this->result; } /** * set result * @param resource $result */ function setResult($result) { $this->result = $result; } /** * get query * @return string $query */ function getQuery() { return $this->query; } /** * set query * @param string $query */ function setQuery($query) { $this->query = $query; } /** * fetch as assoc * @return array */ function fetch_assoc() { return $this->CLASS['db']->fetch_assoc($this); } /** * fetch as object * @return object */ function fetch_object() { return $this->CLASS['db']->fetch_object($this); } /** * fetch as row * @return array */ function fetch_row() { return $this->CLASS['db']->fetch_row($this); } /** * count rows * @return integer */ function num_rows() { return $this->CLASS['db']->num_rows($this); } /** * get affected rows * @return integer */ function affected_rows() { return $this->CLASS['db']->affected_rows($this); } /** * move pointer on result * @param integer $number * @return bool */ function data_seek($number) { return $this->CLASS['db']->data_seek($this, $number); } } ?> knowledgeroot-0.9.9.5/include/class-ajax-xml.php0000644000175000017500000003640011272651147022534 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * check what to do */ function check_vars() { //check if userid and groupid is set, if not set to 0 if($_SESSION['userid'] == "" || $_SESSION['groupid'] == "") { $_SESSION['userid'] = 0; $_SESSION['groupid'] = 0; } // try to work only with POST if (isset ($_POST['ajaxopen']) and $_POST['ajaxopen'] != "") { $this->tree_open($_POST['ajaxopen']); } elseif (isset ($_POST['ajaxclose']) and $_POST['ajaxclose'] != "") { $this->tree_close($_POST['ajaxclose']); } elseif (isset ($_POST['reloadtree']) and $_POST['reloadtree'] != "") { $this->tree_reload(); } elseif (isset ($_POST['expandtree']) and $_POST['expandtree'] != "") { $this->tree_expand(); } elseif (isset ($_POST['collapsetree']) and $_POST['collapsetree'] != "") { $this->tree_collapse(); } elseif (isset ($_POST['ajaxmenu']) and isset ($_POST['id']) and $_POST['ajaxmenu'] != "" and $_POST['id'] != "") { if(isset($_POST['contentid']) && $_POST['contentid'] != "") { $this->tree_contextmenu($_POST['ajaxmenu'], $_POST['id'], $_POST['contentid']); } else { $this->tree_contextmenu($_POST['ajaxmenu'], $_POST['id']); } } elseif (isset($_POST['action']) && $_POST['action'] == "ajaxmove" && isset($_POST['source']) && $_POST['source'] != "" && isset($_POST['destination']) && $_POST['destination'] != "") { $this->tree_move($_POST['source'], $_POST['destination']); } elseif (isset($_POST['action']) && $_POST['action'] == "ajaxmovecontent" && isset($_POST['source']) && $_POST['source'] != "" && isset($_POST['destination']) && $_POST['destination'] != "") { $this->tree_move_content($_POST['source'], $_POST['destination']); } } /** * generate xml to open tree part * @param integer $id id of element to open */ function tree_open($id) { // get all elements to open $elements = $this->getOpenTreeElements($id); // generate xmloutput $this->xmlcode = '' . "\n"; $this->xmlcode .= "\n"; $this->xmlcode .= "\t".$id."\n"; $this->xmlcode .= "\t\n"; $this->xmlcode .= "xmlcode .= htmlentities($elements); $this->xmlcode .= $elements; $this->xmlcode .= "]]>\n"; $this->xmlcode .= "\t\n"; $this->xmlcode .= "\n"; // save tree status to session and to db $_SESSION['open'][$id] = 1; if(!empty($_SESSION['userid'])) { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET treecache='%s' WHERE id=%d",serialize($_SESSION['open']),$_SESSION['userid'])); } } /** * generate xml to close treepart * @param integer $id id of element to close */ function tree_close($id) { // get all elements to close $elements = $this->getCloseTreeElements($id); // generate xmloutput $this->xmlcode = '' . "\n"; $this->xmlcode .= "\n"; $this->xmlcode .= $elements; $this->xmlcode .= "\n"; // save tree status to session and to db $_SESSION['open'][$id] = 0; if(!empty($_SESSION['userid'])) { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET treecache='%s' WHERE id=%d",serialize($_SESSION['open']),$_SESSION['userid'])); } } /** * returns elements to close of an treeparentelement * @param integer $id id of element * @return string return part of xml string */ function getCloseTreeElements($id) { $line = ""; // check if the user have permissions if($this->CLASS['knowledgeroot']->checkRecursivPerm($id, $_SESSION['userid']) != 0) { //if(isset($_SESSION['admin']) and $_SESSION['admin'] == 1) { // enable all because of multiple rights if(1) { $query = sprintf("SELECT id FROM tree WHERE belongs_to=%d AND deleted=0 ORDER BY title ASC",$id); } else { // get groups from user $res = $this->CLASS['db']->query(sprintf("SELECT groupid FROM user_group WHERE userid=%d",$_SESSION['userid'])); $orclause = ""; while($rowuser = $this->CLASS['db']->fetch_assoc($res)) { $orclause .= sprintf("OR (".$this->CLASS['db']->quoteIdentifier("group")."=%d AND grouprights > 0) ",$rowuser['groupid']); } $query = sprintf("SELECT id FROM tree WHERE belongs_to=%d AND deleted=0 AND ((otherrights > 0) OR (".$this->CLASS['db']->quoteIdentifier("group")."=%d AND grouprights > 0) %sOR (owner=%d AND userrights>0)) ORDER BY title ASC",$id,$_SESSION['groupid'],$orclause,$_SESSION['userid']); } $line = ""; $line .= $this->getCloseContentElements($id); // get all elements to close in tree $res = $this->CLASS['db']->query($query); while($row = $this->CLASS['db']->fetch_assoc($res)) { if($this->CLASS['knowledgeroot']->checkRecursivPerm($row['id'],$_SESSION['userid']) > 0) { $line .= "".$row['id']."\n"; // get content elements to close $line .= $this->getCloseContentElements($row['id']); // try to get childs of this element if(isset($_SESSION['open'][$row['id']]) && $_SESSION['open'][$row['id']] == 1) { $line .= $this->getCloseTreeElements($row['id']); } } } } return $line; } /** * return elements that should be closed * @param integer $pageid id of element * @return string return part of xml */ function getCloseContentElements($pageid) { $out = ""; // select the content in table content with userrights if (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { if($this->CLASS['db']->dbtype == "pgsql") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, to_char(ct.lastupdated,'DD. Mon YYYY HH24:MI:SS') as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC",$pageid); } elseif($this->CLASS['db']->dbtype == "sqlite") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, strftime('%%d.%%m.%%Y %%H:%%M:%%S',ct.lastupdated) as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC",$pageid); } else { $query = "SELECT ct.id AS id, ct.content AS content, ct.title AS title, ct.type AS type, u.name AS lastupdatedby, DATE_FORMAT(ct.lastupdated,'%d. %M %Y %H:%i:%s') as lastupdated FROM content ct"; $query .= sprintf(" LEFT OUTER JOIN users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC", $pageid); } } else { // get groups from user $res = $this->CLASS['db']->query(sprintf("SELECT groupid FROM user_group WHERE userid=%d",$_SESSION['userid'])); $orclause = ""; while($rowuser = $this->CLASS['db']->fetch_assoc($res)) { $orclause .= sprintf("OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) ",$rowuser['groupid']); } if($this->CLASS['db']->dbtype == "pgsql") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, to_char(ct.lastupdated,'DD. Mon YYYY HH24:MI:SS') as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %sOR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC",$pageid,$_SESSION['groupid'],$orclause,$_SESSION['userid']); } elseif($this->CLASS['db']->dbtype == "sqlite") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, strftime('%%d.%%m.%%Y %%H:%%M:%%S',ct.lastupdated) as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %sOR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC",$pageid,$_SESSION['groupid'],$orclause,$_SESSION['userid']); } else { $query = "SELECT ct.id AS id, ct.content AS content, ct.title AS title, ct.type AS type, u.name AS lastupdatedby, DATE_FORMAT(ct.lastupdated,'%d. %M %Y %H:%i:%s') AS lastupdated FROM content ct"; $query .= sprintf(" LEFT OUTER JOIN users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %s OR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC", $pageid, $_SESSION['groupid'], $orclause,$_SESSION['userid']); } } $res = $this->CLASS['db']->query($query); while($row = $this->CLASS['db']->fetch_assoc($res)) { $out .= "".$row['id']."\n"; } return $out; } /** * returns elements to open in tree * @oaram integer $id id of element * @return string return htmlpart of tree */ function getOpenTreeElements($id) { $this->CLASS['tree'] = new categoryTree(); // check if page is movingpage if($_POST['move'] == "1") { $this->CLASS['tree']->start($this->CLASS,'move',"#"); } else if (isset ($_POST['editor']) && $_POST['editor'] == "1") { $this->CLASS['tree']->start($this->CLASS,'editor',"#"); } else { $this->CLASS['tree']->start($this->CLASS); } $lines = $this->CLASS['tree']->buildAjaxTreePart($id); return $lines; } /** * return xmlcode * @return string return the internal xmlcache of this class */ function get_xml() { return $this->xmlcode; } /** * returns the hole tree for reloading * @param string $expand * @return string return xmlcode */ function tree_reload($expand = "") { $this->CLASS['tree'] = new categoryTree(); // check if page is movingpage if(isset($_POST['move']) && $_POST['move'] == "1") { $this->CLASS['tree']->start($this->CLASS,'move',"#"); } else if (isset ($_POST['editor']) && $_POST['editor'] == "1") { $this->CLASS['tree']->start($this->CLASS,'editor',"#"); } else { $this->CLASS['tree']->start($this->CLASS); } if($expand != "") { $this->CLASS['tree']->doexpand = $expand; $this->CLASS['tree']->expand = $expand; } $lines = $this->CLASS['tree']->buildAjaxTreePart("0"); // generate tree $tree = "\n"; $tree .= $lines; $tree .= "
\n"; // generate xmloutput $this->xmlcode = '' . "\n"; $this->xmlcode .= "\n"; $this->xmlcode .= "\t\n"; $this->xmlcode .= "xmlcode .= $tree; $this->xmlcode .= "]]>\n"; $this->xmlcode .= "\t\n"; $this->xmlcode .= "\n"; } /** * expand tree */ function tree_expand() { $_SESSION['firstrun'] = 0; if (isset($_SESSION['open']) && $_SESSION['open'] != null) { foreach($_SESSION['open'] as $key => $value) { $_SESSION['open'][$key] = 1; } } // save treecache if(!empty($_SESSION['userid'])) { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET treecache='%s' WHERE id=%d",serialize($_SESSION['open']),$_SESSION['userid'])); } $this->tree_reload("1"); } /** * collapse tree */ function tree_collapse() { $_SESSION['firstrun'] = 0; if (isset($_SESSION['open']) && $_SESSION['open'] != null) { foreach($_SESSION['open'] as $key => $value) { $_SESSION['open'][$key] = 0; } } // save treecache if(!empty($_SESSION['userid'])) { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET treecache='%s' WHERE id=%d",serialize($_SESSION['open']),$_SESSION['userid'])); } $this->tree_reload(); } /** * get contextmenu for tree elements * @param string $menuname * @param integer $pageid * @param integer $contentid optional */ function tree_contextmenu($menuname, $pageid, $contentid = null) { if($contentid != null) { // fetch content type $res = $this->CLASS['db']->query(sprintf("SELECT type FROM content WHERE id=%d",$contentid)); $cnt = $this->CLASS['db']->num_rows($res); $type = ""; if($cnt == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $type = $row['type']; } $menu = $this->CLASS['kr_extension']->show_menu($menuname, $contentid, $this->CLASS['knowledgeroot']->getPageRights($pageid,$_SESSION['userid']), $this->CLASS['knowledgeroot']->getContentRights($contentid,$_SESSION['userid']), $type); } else { $menu = $this->CLASS['kr_extension']->show_menu($menuname, $pageid, $this->CLASS['knowledgeroot']->getPageRights($pageid,$_SESSION['userid'])); } // generate xmloutput $this->xmlcode = '' . "\n"; $this->xmlcode .= "\n"; //$this->xmlcode .= "\t".$menuname."\n"; $this->xmlcode .= "\t\n"; $this->xmlcode .= "xmlcode .= $menu; $this->xmlcode .= "]]>\n"; $this->xmlcode .= "\t\n"; $this->xmlcode .= "\n"; } /** * move tree element * @param integer $source * @param integer $destionation */ function tree_move($source, $destination) { if($this->CLASS['knowledgeroot']->getPageRights($source,$_SESSION['userid']) == 2 && $this->CLASS['knowledgeroot']->getPageRights($destination,$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("ajax","move_page","start"); // check if element is a kind of element to move -> if yes than abort if(!$this->CLASS['tree']->isParentelement($destination,$source)) { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET belongs_to=%d WHERE id=%d",$destination,$source)); $pagename = $this->CLASS['path']->getTreePageTitle($source); // email notification $this->CLASS['notification']->send_email_notification($source,"page","moved",$pagename,$source); $this->CLASS['hooks']->setHook("ajax","move_page","success"); } $this->CLASS['hooks']->setHook("ajax","move_page","end"); } // make reload tree $this->tree_reload(); } /** * move content element * @param integer $source * @param integer $destionation */ function tree_move_content($source, $destination) { if($this->CLASS['knowledgeroot']->getContentRights($source,$_SESSION['userid']) == 2 && $this->CLASS['knowledgeroot']->getPageRights($destination,$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("ajax","move_content","start"); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET belongs_to=%d WHERE id=%d",$destination,$source)); $pagename = $this->CLASS['path']->getTreePageTitle($source); // email notification $this->CLASS['notification']->send_email_notification($source,"content","moved",$pagename,$source); $this->CLASS['hooks']->setHook("ajax","move_page","success"); $this->CLASS['hooks']->setHook("ajax","move_content","end"); } // generate xmloutput $this->xmlcode = '' . "\n"; $this->xmlcode .= "\n"; $this->xmlcode .= "\tcontentremove\n"; $this->xmlcode .= "\t".$source."\n"; $this->xmlcode .= "\n"; } } ?> knowledgeroot-0.9.9.5/include/class-knowledgeroot-extension.php0000644000175000017500000005404011272664615025714 0ustar fhabermannfhabermannCLASS =& $CLASS; // load extensions $this->loading_extensions($adminext); return 0; } /** * get list of extensions to load them * @param integer $adminext */ function loading_extensions($adminext = 0) { if($adminext) { $query = "SELECT * FROM extensions WHERE active=1 AND admin=1"; } else { $query = "SELECT * FROM extensions WHERE active=1 AND admin=0"; } $res = $this->CLASS['db']->query($query); while($row = $this->CLASS['db']->fetch_assoc($res)) { // set default extension folder $folder = "system/extension/"; $this->load_extension($row['keyname'], $this->checkExtensionFolder($row['keyname'])); } return 0; } /** * will check in which folder is extension located * @param string $extension keyname of extension * @return string relativ path of extension */ function checkExtensionFolder($extension) { $path = ""; /* * check folders in that order * 1. extension/ * 2. system/extension/ * 3. system/sysext/ */ if(is_file($this->CLASS['vars']['base_path'] . "extension/" . $extension . "/info.php")) { $path = "extension/"; } elseif(is_file($this->CLASS['vars']['base_path'] . "system/extension/" . $extension . "/info.php")) { $path = "system/extension/"; } elseif(is_file($this->CLASS['vars']['base_path'] . "system/sysext/" . $extension . "/info.php")) { $path = "system/sysext/"; } else { $path = "extension/"; } return $path; } /** * load a extension to knowledgeroot * @param string $extension name of extension * @param string $ext_folder folder of extension */ function load_extension($extension, $ext_folder = "") { if (!isset ($this->CLASS['extension'][$extension]['init']) or $this->CLASS['extension'][$extension]['init'] != TRUE) { $classname = $extension; $classfile = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/class-" . $extension . ".php"; $infofile = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/info.php"; $langfile = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/language.php"; $configfile = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/config.php"; $langfolder = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/language"; if(is_file($infofile)) { $CONF = array(); include($infofile); $this->CLASS['extension'][$extension]['info'] = $CONF; unset($CONF); // check for different classname if(isset($this->CLASS['extension'][$extension]['info']['classname']) && $this->CLASS['extension'][$extension]['info']['classname'] != '') { $classname = $this->CLASS['extension'][$extension]['info']['classname']; } // check for different classfile if(isset($this->CLASS['extension'][$extension]['info']['classfile']) && $this->CLASS['extension'][$extension]['info']['classfile'] != '') { $classfile = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/" . $this->CLASS['extension'][$extension]['info']['classfile']; } // check for dependencies if($this->CLASS['extension'][$extension]['info']['dependencies'] != "") { $ext_list = explode(",",$this->CLASS['extension'][$extension]['info']['dependencies']); if(!is_array($ext_list)) { $ext_list = array(); } foreach($ext_list as $ext_key => $ext_val) { if((!isset($this->CLASS['extension'][$ext_val]['init'])) || (isset($this->CLASS['extension'][$ext_val]['init']) && $this->CLASS['extension'][$ext_val]['init'] != TRUE)) { // load dependend extension if(!$this->load_extension($ext_val)) { return 0; } } } } } if(is_file($classfile)) { include($classfile); $this->CLASS['extension'][$extension]['class_file'] = $classfile; $this->CLASS['extension'][$extension]['init'] = TRUE; $this->CLASS['extension'][$extension]['class'] = new $classname($this->CLASS); $this->CLASS['extension'][$extension]['class']->myPath = $ext_folder . $extension . "/"; $this->CLASS['extension'][$extension]['class']->myAbsolutePath = $this->CLASS['vars']['base_path'] . $ext_folder . $extension . "/"; if(is_file($configfile)) { include($configfile); // load default config from the extension config $this->CLASS['extension'][$extension]['class']->CONF = $CONF; // load config from global config file and replace values if (isset ($this->CLASS['vars']['ext'][$extension]) and is_array($this->CLASS['vars']['ext'][$extension])) { $this->CLASS['extension'][$extension]['class']->CONF = $this->CLASS['knowledgeroot']->replace_array($this->CLASS['extension'][$extension]['class']->CONF,$this->CLASS['vars']['ext'][$extension]); } unset($CONF); } // load gettext langfiles if directory exists if (@is_dir ($langfolder)) { //$this->CLASS['error']->DebugOut(DEFAULT_LOCALE); T_bindtextdomain($extension, $langfolder); } else { // ToDo: Von hier aus koennte eine interne Fehlermeldung in eine Logdatei geschrieben // werden (wenn diese Funktion einmal zur Verfuegung steht). } // load language from language.php if(is_file($langfile)) { $LANG = array(); include($langfile); $this->CLASS['language']->load_ext_lang($extension, $LANG); unset($LANG); } return 1; } return 0; } } /** * this function start all extensions with the function main */ function start_extensions() { if (isset ($this->CLASS['extension']) and is_array($this->CLASS['extension'])) { foreach($this->CLASS['extension'] as $key => $value) { if(isset($this->CLASS['extension'][$key]['init']) && $this->CLASS['extension'][$key]['init'] == TRUE) { $content = $this->CLASS['extension'][$key]['class']->main(); if($content != "0" && $content != "1" && $content != "") { $this->content .= $content; } } } } // loading menus $this->load_menus(); } /** * load the menues from the extensions */ function load_menus() { if (isset ($this->CLASS['extension']) and is_array($this->CLASS['extension'])) { foreach($this->CLASS['extension'] as $key => $value) { if(isset($this->CLASS['extension'][$key]['init']) && $this->CLASS['extension'][$key]['init'] == TRUE) { $this->menu = array_merge_recursive($this->menu, $this->CLASS['extension'][$key]['class']->menu); } } } } /** * Create a menu * * @param string $name name of menu * @param integer $id id of page * @param integer $pagerights rights of the page * @param integer $contentrights rights of the content * @param string $extension name of extension * @return string return menu as html */ function show_menu($name,$id = "", $pagerights = null, $contentrights = null,$extension = "") { $out = ""; $menuarr = array(); if(!isset($this->menu[$name])) $this->menu[$name] = array(); if(!is_array($this->menu[$name])) { $this->menu[$name] = array(); } foreach($this->menu[$name] as $key => $value) { // check for config - config is no real menu if($key == "config") { continue; } // check for extension to display the navi if($name == "content" || $name == "contentline" || $name == "contentcontext") { $show = 0; if (isset($this->menu[$name][$key]['contenttype'])) { $list = explode(",", $this->menu[$name][$key]['contenttype']); if(!is_array($list)) { $list = array(); } foreach($list as $listkey => $listvalue) { // check if menu item should be displayed at this content $listvalue = trim($listvalue); $extension = trim($extension); if(($listvalue == $extension) || (($listvalue == "" || $listvalue == "text") && ($extension == "" || $extension == "text"))) { $show = 1; continue; } } } else { // no contenttype is set so menuitem will be shown at every content/contentline $show = 1; } // check if item showed be shown, if not go to next item if($show == 0) { continue; } } // check for tooltip if (isset ($this->menu[$name][$key]['tooltip']) and $this->menu[$name][$key]['tooltip'] != "") { $title = " title=\"" . $this->menu[$name][$key]['tooltip'] . "\""; } else { $title = " title=\"" . $this->menu[$name][$key]['name'] . "\""; } // check for target if (isset ($this->menu[$name][$key]['target']) and $this->menu[$name][$key]['target'] != "") { $target = " target=\"" . $this->menu[$name][$key]['target'] . "\""; } else { $target = ""; } // check for extra a tag parameter if (isset ($this->menu[$name][$key]['atagparams']) and $this->menu[$name][$key]['atagparams'] != "") { $atagparams = " " . trim($this->menu[$name][$key]['atagparams']); } else { $atagparams = ""; } // check if id should be added if (isset ($this->menu[$name][$key]['addid']) and $this->menu[$name][$key]['addid'] == "1") { $href = $this->menu[$name][$key]['link'] . $id; } else { $href = $this->menu[$name][$key]['link']; } // check imagewidth if (isset ($this->menu[$name][$key]['imagewidth']) and $this->menu[$name][$key]['imagewidth'] != "") { $imagewidth = " width=\"" . $this->menu[$name][$key]['imagewidth'] . "\""; } else { $imagewidth = ""; } // check imageheight if (isset ($this->menu[$name][$key]['imageheight']) and $this->menu[$name][$key]['imageheight'] != "") { $imageheight = " height=\"" . $this->menu[$name][$key]['imageheight'] . "\""; } else { $imageheight = ""; } // make image link or normal link if (isset ($this->menu[$name][$key]['image']) and $this->menu[$name][$key]['image'] != "") { $link = "menu[$name][$key]['image'] . "\" border=\"0\"" . $imagewidth . $imageheight . $title . " alt=\"". $this->menu[$name][$key]['name'] ."\"/>"; } else { $link = "" . $this->menu[$name][$key]['name'] . ""; } // check for toolbar of for image if ($name != "toolbar" && (!isset ($this->menu[$name][$key]['image']) or $this->menu[$name][$key]['image'] == "") && (!isset ($this->menu[$name][$key]['wrap']) or $this->menu[$name][$key]['wrap'] == "") && (!isset ($this->menu[$name]['config']['defaultelementwrap']) or $this->menu[$name]['config']['defaultelementwrap'] == "")) { $link = "[" . $link . "]"; } // set wrap if (isset ($this->menu[$name][$key]['wrap']) and $this->menu[$name][$key]['wrap'] != "") { $link = $this->CLASS['knowledgeroot']->setWrap($link,$this->menu[$name][$key]['wrap']); } elseif(isset ($this->menu[$name]['config']['defaultelementwrap']) and $this->menu[$name]['config']['defaultelementwrap'] != "") { $link = $this->CLASS['knowledgeroot']->setWrap($link,$this->menu[$name]['config']['defaultelementwrap']); } // check for dynamic vars and replace them $link = str_replace('{$ID}', $id, $link); if(isset($_SESSION['cid'])) $link = str_replace('{$PAGEID}', $_SESSION['cid'], $link); // check for adminrights if ((!isset ($_SESSION['admin']) or $_SESSION['admin'] != "1") && isset ($this->menu[$name][$key]['admin']) and $this->menu[$name][$key]['admin'] == "1") { // do not display item continue; } // check pagerights if ($pagerights != null && isset ($this->menu[$name][$key]['pagerights']) and $pagerights < $this->menu[$name][$key]['pagerights']) { // do not display item continue; } // check contenrights if ($contentrights != null && isset ($this->menu[$name][$key]['contentrights']) and $contentrights < $this->menu[$name][$key]['contentrights']) { // do not display item continue; } // check if login is required if (isset ($this->menu[$name][$key]['login']) and $this->menu[$name][$key]['login'] == "1" && (!isset ($_SESSION['userid']) or $_SESSION['userid'] == "0" || $_SESSION['userid'] == "" || !isset ($_SESSION['groupid']) or $_SESSION['groupid'] == "0" || $_SESSION['groupid'] == "")) { // do not display item continue; } // check if logout is required if (isset ($this->menu[$name][$key]['logout']) and $this->menu[$name][$key]['logout'] == "1" && (!isset ($_SESSION['userid']) or $_SESSION['userid'] != "0" || $_SESSION['userid'] != "" || !isset ($_SESSION['groupid']) or $_SESSION['groupid'] != "0" || $_SESSION['groupid'] != "")) { // do not display item continue; } // set priority if(isset($this->menu[$name][$key]['priority']) && $this->menu[$name][$key]['priority'] != "") { $priority = $this->menu[$name][$key]['priority']; } else { $priority = "90"; } // build menu array $menuarr[] = array( "pri" => $priority, "link" => $link . "\n"); } // sort menu array for priority array_multisort($menuarr); // display menu foreach($menuarr as $key => $value) { $out .= $menuarr[$key]['link']; } // check for wrap in this menu if(isset($this->menu[$name]['config']['wrap']) && $this->menu[$name]['config']['wrap'] != "") { if(isset($this->menu[$name]['config']['admin']) && $this->menu[$name]['config']['admin'] == "1") { if(isset($_SESSION['admin']) && $_SESSION['admin'] == 1) { $out = $this->CLASS['knowledgeroot']->setWrap($out,$this->menu[$name]['config']['wrap']); } } else { $out = $this->CLASS['knowledgeroot']->setWrap($out,$this->menu[$name]['config']['wrap']); } } return $out; } /** * Create admin menu * @param string $name name of menu * @param integer $parent */ function show_admin_menu($name, $parent = "") { $menuarr = array(); if(!is_array($this->menu[$name])) { $this->menu[$name] = array(); } $count_items = 0; foreach($this->menu[$name] as $key => $value) { // check for config - config is no real menu if($key == "config") { continue; } if($parent != "") { if (!isset ($this->menu[$name][$key]['parent']) or $this->menu[$name][$key]['parent'] != $parent) { continue; } } if ($parent == "" && isset ($this->menu[$name][$key]['parent']) and $this->menu[$name][$key]['parent'] != "") { continue; } // check for tooltip if (isset ($this->menu[$name][$key]['tooltip']) and $this->menu[$name][$key]['tooltip'] != "") { $title = " alt=\"" . $this->menu[$name][$key]['tooltip'] . "\" title=\"" . $this->menu[$name][$key]['tooltip'] . "\""; } else { $title = " alt=\"" . $this->menu[$name][$key]['name'] . "\" title=\"" . $this->menu[$name][$key]['name'] . "\""; } // check for target if (isset ($this->menu[$name][$key]['target']) and $this->menu[$name][$key]['target'] != "") { $target = " target=\"" . $this->menu[$name][$key]['target'] . "\""; } else { $target = ""; } // check for extra a tag parameter if (isset ($this->menu[$name][$key]['atagparams']) and $this->menu[$name][$key]['atagparams'] != "") { $atagparams = " " . trim($this->menu[$name][$key]['atagparams']); } else { $atagparams = ""; } // make normal link if($parent != "") { $link = ""; } else { $link = ""; } // set priority if($this->menu[$name][$key]['priority'] != "") { $priority = $this->menu[$name][$key]['priority']; } else { $priority = "90"; } // build menu array $menuarr[] = array( "pri" => $priority, "link" => $link . "\n", "name" => $key); // count items $count_items++; } // sort menu array for priority array_multisort($menuarr); if($count_items > 0 && $parent != "") { echo "
\n"; } // display menu foreach($menuarr as $key => $value) { echo $menuarr[$key]['link']; $this->show_admin_menu($name, $menuarr[$key]['name']); } if($count_items > 0 && $parent != "") { echo "
\n"; } } /** * show extension content */ function show_ext_content() { if($this->content != "") { echo $this->content; } else { echo $this->default_content; } } /* * now the functions for extension handling follows */ /** * return an array with all files and folders from a directory * @param string $path * @param string $filepath * @return array */ function getFileArr($path, $filepath = "") { if($filepath != "" && substr($filepath,-1,1) != "/") { $filepath .= "/"; } $fileArr = array(); $handle = opendir($path); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != ".svn" && $file != "CVS") { if(is_dir($path."/".$file)) { $fileArr[$file]['type'] = "dir"; $fileArr[$file]['content'] = $this->getFileArr($path."/".$file,$file); } else { $filecontent = $this->getFileContent($path."/".$file); $fileArr[$file]['type'] = "file"; $fileArr[$file]['content'] = $filecontent; $fileArr[$file]['md5'] = md5($filecontent); } } } closedir($handle); return $fileArr; } /** * return content of a file * @param string $file * @return string */ function getFileContent($file) { $content = ""; if(function_exists('file_get_contents')) { $content = file_get_contents($file); } else { $lines = file($file); foreach($lines as $line_num => $line) { $content .= $line; } } return $content; } /** * return a full extension as string * @param string $keyname * @param string $path * @return string */ function makeExtension($keyname, $path) { //print_r(gzcompress(base64_encode(serialize($this->getFileArr("/www/projekte/knowledgeroot/system/extension/livediagram/"))))); //print_r($this->getFileArr("/tmp/test2/")); $ext_arr = array(); $ext_arr['keyname'] = $keyname; $ext_arr['files'] = $this->getFileArr($path); $CONF = ''; if(is_file($path . "info.php")) { include($path . "info.php"); $ext_arr['info'] = $CONF; unset($CONF); } $hash = serialize($ext_arr); $md5sum = md5($hash); if(function_exists('gzcompress')) { $ext = $md5sum . ":gzcompress:" . base64_encode(gzcompress($hash)); } else { $ext = $md5sum . ":text:" . base64_encode($hash); } return $ext; } /** * fetch extension from repository * url is url to extension repository * @param string $url */ function fetchExtension($url) { } /** * return filearray from a extensionfilecontent * @param string $content * @return array */ function getExtensionData($content) { $parts = explode(":", $content); $md5sum = $parts[0]; $method = $parts[1]; $fileArr = array(); if($method == "gzcompress") { if(function_exists('gzuncompress')) { $data = gzuncompress(base64_decode($parts[2])); } else { echo "gzuncompress is not available"; } } else { $data = base64_decode($parts[2]); } if(md5($data) == $md5sum) { $fileArr = unserialize($data); } else { echo "wrong md5sum"; } return $fileArr; } /** * write content to a file * @param string $file * @param string $content * @return bool */ function putFileContent($file,$content="") { //echo "$file\n"; $f=@fopen($file,"w"); if (!$f) { return false; } else { fwrite($f,$content); fclose($f); return true; } } /** * save a extension to a path * @param array $extArr * @param string $path */ function saveExtension($extArr,$path) { $this->createExtFolders($extArr,$path); $this->createExtFiles($extArr,$path); } /** * create files from a extension array to a path * @param array $extArr * @param string $path */ function createExtFiles($extArr,$path) { if(substr($path,-1,1) != "/") { $path .= "/"; } foreach($extArr as $key => $value) { if($extArr[$key]['type'] == "dir") { $this->createExtFiles($extArr[$key]['content'],$path.$key); } else { $this->putFileContent($path.$key,$extArr[$key]['content']); } } } /** * create folders from a extension array to a path * @param array $extArr * @param string $path */ function createExtFolders($extArr, $path) { if(substr($path,-1,1) != "/") { $path .= "/"; } foreach($extArr as $key => $value) { if($extArr[$key]['type'] == "dir") { if(!is_dir($path.$key)) { $this->mkdir_r($path.$key); } $this->createExtFolders($extArr[$key]['content'],$path.$key); } } } /** * create folders recursiv * @param string $dirname * @param integer $rights * @return bool */ function mkdir_r($dirName, $rights=0777){ $dirs = explode('/', $dirName); $dir=''; foreach ($dirs as $part) { $dir.=$part.'/'; if (!@is_dir($dir) && strlen($dir)>1) @mkdir($dir, $rights); } // check if folder was created if(@is_dir($dirName)) { return true; } return false; } /** * enable a extension * @param string $keyname */ function enableExtension($keyname) { $res = $this->CLASS['db']->query(sprintf("UPDATE extensions SET active=1 WHERE keyname='%s'",$keyname)); } /** * disable a extension * @param string $keyname */ function disableExtension($keyname) { $res = $this->CLASS['db']->query(sprintf("UPDATE extensions SET active=0 WHERE keyname='%s'",$keyname)); } // /** * install a extension in database table * not on disk * @param string $keyname * @param integer $admin */ function installExtension($keyname, $admin = 0) { $res = $this->CLASS['db']->query(sprintf("SELECT id FROM extensions WHERE keyname='%s'",$keyname)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 0) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO extensions (keyname, active, admin) VALUES ('%s', 0, %d)",$keyname,$admin)); } } } ?> knowledgeroot-0.9.9.5/include/class-default-menu.php0000644000175000017500000005215411165235400023374 0ustar fhabermannfhabermannCLASS =& $CLASS; $this->set_default_menu(); $this->load_default_menu(); } /** * */ function load_default_menu() { $this->CLASS['kr_extension']->menu = array_merge_recursive($this->CLASS['kr_extension']->menu, $this->defaultmenu); } /** * */ function set_default_menu() { // BEGIN TOP MENU // login $this->defaultmenu['top']['login']['name'] = T_('login'); $this->defaultmenu['top']['login']['link'] = "index.php?action=login"; $this->defaultmenu['top']['login']['tooltip'] = "login"; $this->defaultmenu['top']['login']['logout'] = "1"; $this->defaultmenu['top']['login']['priority'] = "10"; // logout $this->defaultmenu['top']['logout']['name'] = T_('logout'); $this->defaultmenu['top']['logout']['link'] = "index.php?action=logout"; $this->defaultmenu['top']['logout']['tooltip'] = "logout"; $this->defaultmenu['top']['logout']['login'] = "1"; $this->defaultmenu['top']['logout']['priority'] = "90"; // roots $this->defaultmenu['top']['roots']['name'] = T_('roots'); $this->defaultmenu['top']['roots']['link'] = "index.php?action=createroot"; $this->defaultmenu['top']['roots']['tooltip'] = "create root"; $this->defaultmenu['top']['roots']['login'] = "1"; $this->defaultmenu['top']['roots']['priority'] = "10"; $this->defaultmenu['top']['roots']['admin'] = "1"; // user $this->defaultmenu['top']['user']['name'] = T_('user'); $this->defaultmenu['top']['user']['link'] = "index.php?action=users"; $this->defaultmenu['top']['user']['tooltip'] = "create users"; $this->defaultmenu['top']['user']['login'] = "1"; $this->defaultmenu['top']['user']['priority'] = "20"; $this->defaultmenu['top']['user']['admin'] = "1"; // options $this->defaultmenu['top']['options']['name'] = T_('options'); $this->defaultmenu['top']['options']['link'] = "index.php?action=options"; $this->defaultmenu['top']['options']['tooltip'] = "edit options"; $this->defaultmenu['top']['options']['login'] = "1"; $this->defaultmenu['top']['options']['priority'] = "30"; // END TOP MENU // BEGIN TREE NAVI // hide button $this->defaultmenu['tree']['hide']['name'] = T_('hide menu'); $this->defaultmenu['tree']['hide']['image'] = "images/left.gif"; $this->defaultmenu['tree']['hide']['imagewidth'] = "22"; $this->defaultmenu['tree']['hide']['link'] = "javascript:;"; $this->defaultmenu['tree']['hide']['atagparams'] = "onclick=\"HideTree();\""; $this->defaultmenu['tree']['hide']['wrap'] = "|"; $this->defaultmenu['tree']['hide']['priority'] = "10"; // expand all $this->defaultmenu['tree']['expand']['name'] = T_('expand menu'); $this->defaultmenu['tree']['expand']['image'] = "images/plus.gif"; $this->defaultmenu['tree']['expand']['imagewidth'] = "22"; $this->defaultmenu['tree']['expand']['link'] = "javascript:;"; $this->defaultmenu['tree']['expand']['atagparams'] = "onclick=\"TreeExpand(".'{$ID}'.");\""; $this->defaultmenu['tree']['expand']['wrap'] = "|"; $this->defaultmenu['tree']['expand']['priority'] = "20"; // reload all $this->defaultmenu['tree']['reload']['name'] = T_('reload menu'); $this->defaultmenu['tree']['reload']['image'] = "images/reload.gif"; $this->defaultmenu['tree']['reload']['imagewidth'] = "22"; $this->defaultmenu['tree']['reload']['link'] = "javascript:;"; $this->defaultmenu['tree']['reload']['atagparams'] = "onclick=\"TreeReload(".'{$ID}'.");\""; $this->defaultmenu['tree']['reload']['wrap'] = "|"; $this->defaultmenu['tree']['reload']['priority'] = "30"; // collapse all $this->defaultmenu['tree']['collapse']['name'] = T_('collapse menu'); $this->defaultmenu['tree']['collapse']['image'] = "images/minus.gif"; $this->defaultmenu['tree']['collapse']['imagewidth'] = "22"; $this->defaultmenu['tree']['collapse']['link'] = "javascript:;"; $this->defaultmenu['tree']['collapse']['atagparams'] = "onclick=\"TreeCollapse(".'{$ID}'.");\""; $this->defaultmenu['tree']['collapse']['wrap'] = "|"; $this->defaultmenu['tree']['collapse']['priority'] = "40"; // checking treestyle and slide if($this->CLASS['vars']['menu']['type'] == "static") { $fixedstyle = "style=\"display:none;\""; $slidestyle = "style=\"display:block;\""; } else { $fixedstyle = "style=\"display:block;\""; $slidestyle = "style=\"display:none;\""; } // tree fixed $this->defaultmenu['tree']['fixed']['name'] = T_('show menu'); $this->defaultmenu['tree']['fixed']['image'] = "images/fixed.gif"; $this->defaultmenu['tree']['fixed']['imagewidth'] = "22"; $this->defaultmenu['tree']['fixed']['link'] = "javascript:;"; $this->defaultmenu['tree']['fixed']['atagparams'] = "onclick=\"TreeFixed();\""; $this->defaultmenu['tree']['fixed']['wrap'] = "
|
"; $this->defaultmenu['tree']['fixed']['priority'] = "40"; // tree slide $this->defaultmenu['tree']['slide']['name'] = T_('close menu'); $this->defaultmenu['tree']['slide']['image'] = "images/close.gif"; $this->defaultmenu['tree']['slide']['imagewidth'] = "22"; $this->defaultmenu['tree']['slide']['link'] = "javascript:;"; $this->defaultmenu['tree']['slide']['atagparams'] = "onclick=\"TreeSlide();\""; $this->defaultmenu['tree']['slide']['wrap'] = "
|
"; $this->defaultmenu['tree']['slide']['priority'] = "41"; // END TREE NAVI // BEGIN PAGE NAVI // new page $this->defaultmenu['page']['newpage']['name'] = T_('add new page'); $this->defaultmenu['page']['newpage']['link'] = 'index.php?id={$PAGEID}&action=newpage'; $this->defaultmenu['page']['newpage']['pagerights'] = "2"; $this->defaultmenu['page']['newpage']['priority'] = "10"; // edit page $this->defaultmenu['page']['editpage']['name'] = T_('edit page'); $this->defaultmenu['page']['editpage']['link'] = 'index.php?id={$PAGEID}&action=editpage'; $this->defaultmenu['page']['editpage']['pagerights'] = "2"; $this->defaultmenu['page']['editpage']['priority'] = "20"; // move page $this->defaultmenu['page']['movepage']['name'] = T_('move page'); $this->defaultmenu['page']['movepage']['link'] = "#"; $this->defaultmenu['page']['movepage']['atagparams'] = "onclick=\"window.document.forms.move.move.value='move'; window.open('move.php?type=page','Knowledgeroot','width=310,height=400,menubar=yes,resizable=yes,scrollbars=yes');\""; $this->defaultmenu['page']['movepage']['pagerights'] = "2"; $this->defaultmenu['page']['movepage']['priority'] = "30"; // delete page $this->defaultmenu['page']['deletepage']['name'] = T_('delete page'); $this->defaultmenu['page']['deletepage']['link'] = "javascript:;"; $this->defaultmenu['page']['deletepage']['atagparams'] = "onclick=\"if(confirm('" . T_('Do you really want to delete this page?') . "')) { location.href='index.php?delpage={\$PAGEID}'; } else { return false; }\""; $this->defaultmenu['page']['deletepage']['pagerights'] = "2"; $this->defaultmenu['page']['deletepage']['priority'] = "40"; // create new content $this->defaultmenu['page']['createcontent']['name'] = T_('add new content'); $this->defaultmenu['page']['createcontent']['link'] = 'index.php?id={$PAGEID}&action=newcontent'; $this->defaultmenu['page']['createcontent']['pagerights'] = "2"; $this->defaultmenu['page']['createcontent']['priority'] = "50"; // END PAGE NAVI // BEGIN CONTENT NAVI // edit content $this->defaultmenu['content']['editcontent']['name'] = T_('edit content'); $this->defaultmenu['content']['editcontent']['link'] = 'index.php?id={$PAGEID}&eid='; $this->defaultmenu['content']['editcontent']['addid'] = "1"; $this->defaultmenu['content']['editcontent']['contentrights'] = "2"; $this->defaultmenu['content']['editcontent']['priority'] = "10"; $this->defaultmenu['content']['editcontent']['contenttype'] = "text"; // delete content $this->defaultmenu['content']['deletecontent']['name'] = T_('delete content'); $this->defaultmenu['content']['deletecontent']['link'] = 'javascript:;'; $this->defaultmenu['content']['deletecontent']['atagparams'] = "onclick=\"if(confirm('" . T_('Do you really want to delete?') . "')) { location.href='index.php?id={\$PAGEID}&delid={\$ID}'; } else { return false; }\""; $this->defaultmenu['content']['deletecontent']['contentrights'] = "2"; $this->defaultmenu['content']['deletecontent']['priority'] = "20"; $this->defaultmenu['content']['deletecontent']['contenttype'] = "text"; // move content $this->defaultmenu['content']['movecontent']['name'] = T_('move content'); $this->defaultmenu['content']['movecontent']['link'] = "#"; $this->defaultmenu['content']['movecontent']['atagparams'] = "onclick=\"window.document.forms.move.contentid.value='".'{$ID}'."'; window.document.forms.move.move.value='cmove'; window.open('move.php','Knowledgeroot','width=310,height=400,menubar=yes,resizable=yes,scrollbars=yes');\""; $this->defaultmenu['content']['movecontent']['contentrights'] = "2"; $this->defaultmenu['content']['movecontent']['pagerights'] = "2"; $this->defaultmenu['content']['movecontent']['priority'] = "30"; $this->defaultmenu['content']['movecontent']['contenttype'] = "text"; // content history /* $this->defaultmenu['content']['contenthistory']['name'] = $this->CLASS['language']->get['contenthistory']; $this->defaultmenu['content']['contenthistory']['link'] = "index.php?action=contenthistory&historyof="; $this->defaultmenu['content']['contenthistory']['addid'] = "1"; $this->defaultmenu['content']['contenthistory']['priority'] = "35"; $this->defaultmenu['content']['contenthistory']['contenttype'] = "text"; */ // add file $this->defaultmenu['content']['addfile']['name'] = T_('add file'); $this->defaultmenu['content']['addfile']['link'] = "#"; $this->defaultmenu['content']['addfile']['addid'] = "1"; $this->defaultmenu['content']['addfile']['atagparams'] = "onclick=\"return ShowById('fileform_".'{$ID}'."');\""; $this->defaultmenu['content']['addfile']['contentrights'] = "2"; $this->defaultmenu['content']['addfile']['priority'] = "40"; $this->defaultmenu['content']['addfile']['contenttype'] = "text"; // END CONTENT NAVI // BEGIN CONTENT_LINE NAVI $this->defaultmenu['contentline']['top']['name'] = T_('Top'); $this->defaultmenu['contentline']['top']['link'] = "#top"; $this->defaultmenu['contentline']['top']['tooltip'] = T_('Goto Top'); $this->defaultmenu['contentline']['top']['priority'] = "20"; $this->defaultmenu['contentline']['move']['name'] = T_('move'); $this->defaultmenu['contentline']['move']['link'] = "javascript:;"; $this->defaultmenu['contentline']['move']['image'] = "images/drag.gif"; $this->defaultmenu['contentline']['move']['atagparams'] = "id=\"contentdragicon_{\$ID}\""; $this->defaultmenu['contentline']['move']['wrap'] = "|"; $this->defaultmenu['contentline']['move']['tooltip'] = T_('move content'); $this->defaultmenu['contentline']['move']['priority'] = "10"; // END CONTENT_LINE NAVI // BEGIN TREEBOTTOM MENU $this->defaultmenu['treebottom']['config']['wrap'] = "
    |
"; $this->defaultmenu['treebottom']['config']['admin'] = "1"; // save default tree layout if(isset($this->CLASS['vars']['menu']['defaultlayout']) && $this->CLASS['vars']['menu']['defaultlayout'] == "1") { $this->defaultmenu['treebottom']['defaulttree']['name'] = T_('save as default tree'); $this->defaultmenu['treebottom']['defaulttree']['link'] = 'index.php?action=savedefaulttree'; $this->defaultmenu['treebottom']['defaulttree']['wrap'] = "
  • » |
  • "; $this->defaultmenu['treebottom']['defaulttree']['priority'] = "20"; $this->defaultmenu['treebottom']['defaulttree']['admin'] = "1"; } if(isset($this->CLASS['vars']['menu']['showsourceforgelogo']) && $this->CLASS['vars']['menu']['showsourceforgelogo'] == "1") { $this->defaultmenu['treebottom']['sourceforge']['name'] = T_('Sourceforge'); $this->defaultmenu['treebottom']['sourceforge']['link'] = 'http://sourceforge.net'; $this->defaultmenu['treebottom']['sourceforge']['wrap'] = "
  • |
  • "; $this->defaultmenu['treebottom']['sourceforge']['image'] = "http://sflogo.sourceforge.net/sflogo.php?group_id=157374&type=1"; $this->defaultmenu['treebottom']['sourceforge']['priority'] = "90"; } // END TREEBOTTOM MENU // BEGIN TREE CONTEXT MENU // configure menu $this->defaultmenu['pagecontext']['config']['wrap'] = "|
    "; // new page $this->defaultmenu['pagecontext']['newpage']['name'] = T_('add new page'); $this->defaultmenu['pagecontext']['newpage']['link'] = 'index.php?id={$PAGEID}&action=newpage'; $this->defaultmenu['pagecontext']['newpage']['pagerights'] = "2"; $this->defaultmenu['pagecontext']['newpage']['priority'] = "10"; $this->defaultmenu['pagecontext']['newpage']['wrap'] = "|"; // edit page $this->defaultmenu['pagecontext']['editpage']['name'] = T_('edit page'); $this->defaultmenu['pagecontext']['editpage']['link'] = 'index.php?id={$PAGEID}&action=editpage'; $this->defaultmenu['pagecontext']['editpage']['pagerights'] = "2"; $this->defaultmenu['pagecontext']['editpage']['priority'] = "20"; $this->defaultmenu['pagecontext']['editpage']['wrap'] = "|"; // move page $this->defaultmenu['pagecontext']['movepage']['name'] = T_('move page'); $this->defaultmenu['pagecontext']['movepage']['link'] = "#"; $this->defaultmenu['pagecontext']['movepage']['atagparams'] = "onclick=\"window.document.forms.move.move.value='move'; window.open('move.php?type=page','Knowledgeroot','width=310,height=400,menubar=yes,resizable=yes,scrollbars=yes');\""; $this->defaultmenu['pagecontext']['movepage']['pagerights'] = "2"; $this->defaultmenu['pagecontext']['movepage']['priority'] = "30"; $this->defaultmenu['pagecontext']['movepage']['wrap'] = "|"; // delete page $this->defaultmenu['pagecontext']['deletepage']['name'] = T_('delete page'); $this->defaultmenu['pagecontext']['deletepage']['link'] = "javascript:;"; $this->defaultmenu['pagecontext']['deletepage']['atagparams'] = "onclick=\"if(confirm('" . T_('Do you really want to delete this page?') . "')) { location.href='index.php?delpage={\$PAGEID}'; } else { return false; }\""; $this->defaultmenu['pagecontext']['deletepage']['pagerights'] = "2"; $this->defaultmenu['pagecontext']['deletepage']['priority'] = "40"; $this->defaultmenu['pagecontext']['deletepage']['wrap'] = "|"; // add empty line $this->defaultmenu['pagecontext']['line']['name'] = ""; $this->defaultmenu['pagecontext']['line']['link'] = ''; $this->defaultmenu['pagecontext']['line']['pagerights'] = "2"; $this->defaultmenu['pagecontext']['line']['priority'] = "45"; $this->defaultmenu['pagecontext']['line']['wrap'] = "|"; // create new content $this->defaultmenu['pagecontext']['createcontent']['name'] = T_('add new content'); $this->defaultmenu['pagecontext']['createcontent']['link'] = 'index.php?id={$PAGEID}&action=newcontent'; $this->defaultmenu['pagecontext']['createcontent']['pagerights'] = "2"; $this->defaultmenu['pagecontext']['createcontent']['priority'] = "50"; $this->defaultmenu['pagecontext']['createcontent']['wrap'] = "|"; // END TREE CONTEXT MENU // BEGIN CONTENT CONTEXT MENU // configure menu $this->defaultmenu['contentcontext']['config']['wrap'] = "|
    "; // create new content $this->defaultmenu['contentcontext']['createcontent']['name'] = T_('add new content'); $this->defaultmenu['contentcontext']['createcontent']['link'] = 'index.php?id={$PAGEID}&action=newcontent'; $this->defaultmenu['contentcontext']['createcontent']['pagerights'] = "2"; $this->defaultmenu['contentcontext']['createcontent']['priority'] = "10"; $this->defaultmenu['contentcontext']['createcontent']['wrap'] = "|"; // edit content $this->defaultmenu['contentcontext']['editcontent']['name'] = T_('edit content'); $this->defaultmenu['contentcontext']['editcontent']['link'] = 'index.php?id={$PAGEID}&eid='; $this->defaultmenu['contentcontext']['editcontent']['addid'] = "1"; $this->defaultmenu['contentcontext']['editcontent']['contentrights'] = "2"; $this->defaultmenu['contentcontext']['editcontent']['priority'] = "20"; $this->defaultmenu['contentcontext']['editcontent']['contenttype'] = "text"; $this->defaultmenu['contentcontext']['editcontent']['wrap'] = "|"; // delete content $this->defaultmenu['contentcontext']['deletecontent']['name'] = T_('delete content'); $this->defaultmenu['contentcontext']['deletecontent']['link'] = 'javascript:;'; $this->defaultmenu['contentcontext']['deletecontent']['atagparams'] = "onclick=\"if(confirm('" . T_('Do you really want to delete?') . "')) { location.href='index.php?id={\$PAGEID}&delid={\$ID}'; } else { return false; }\""; $this->defaultmenu['contentcontext']['deletecontent']['contentrights'] = "2"; $this->defaultmenu['contentcontext']['deletecontent']['priority'] = "30"; $this->defaultmenu['contentcontext']['deletecontent']['contenttype'] = "text"; $this->defaultmenu['contentcontext']['deletecontent']['wrap'] = "|"; // move content $this->defaultmenu['contentcontext']['movecontent']['name'] = T_('move content'); $this->defaultmenu['contentcontext']['movecontent']['link'] = "#"; $this->defaultmenu['contentcontext']['movecontent']['atagparams'] = "onclick=\"window.document.forms.move.contentid.value='".'{$ID}'."'; window.document.forms.move.move.value='cmove'; window.open('move.php','Knowledgeroot','width=310,height=400,menubar=yes,resizable=no');\""; $this->defaultmenu['contentcontext']['movecontent']['contentrights'] = "2"; $this->defaultmenu['contentcontext']['movecontent']['pagerights'] = "2"; $this->defaultmenu['contentcontext']['movecontent']['priority'] = "40"; $this->defaultmenu['contentcontext']['movecontent']['contenttype'] = "text"; $this->defaultmenu['contentcontext']['movecontent']['wrap'] = "|"; // add file $this->defaultmenu['contentcontext']['addfile']['name'] = T_('add file'); $this->defaultmenu['contentcontext']['addfile']['link'] = "#"; $this->defaultmenu['contentcontext']['addfile']['addid'] = "1"; $this->defaultmenu['contentcontext']['addfile']['atagparams'] = "onclick=\"return ShowById('fileform_".'{$ID}'."');\""; $this->defaultmenu['contentcontext']['addfile']['contentrights'] = "2"; $this->defaultmenu['contentcontext']['addfile']['priority'] = "40"; $this->defaultmenu['contentcontext']['addfile']['contenttype'] = "text"; $this->defaultmenu['contentcontext']['addfile']['wrap'] = "|"; // END CONTENT CONTEXT MENU } } ?> knowledgeroot-0.9.9.5/include/init_admin.php0000644000175000017500000001656311256126014022023 0ustar fhabermannfhabermannstart($CLASS); $CLASS['session']->startSession(md5($url_arr[1])); if(!$CLASS['session']->checkSession()) { die("SESSION WAS WRONG!"); } // define runtimer $CLASS['runtime'] = new runtime(); // define global variables $CLASS['vars'] = $CONFIG; $CLASS['admin_vars'] = $ADMIN_CONFIG; // init error $CLASS['error'] = new knowledgeroot_error(); $CLASS['error']->start($CLASS); // set base paths //$CLASS['vars']['base_path'] = dirname(KNOWLEDGEROOT_PATH) . "/"; $CLASS['vars']['base_path'] = $base_path; //$CLASS['vars']['admin_base_path'] = dirname(KNOWLEDGEROOT_ADMIN_PATH) . "/"; $CLASS['vars']['admin_base_path'] = $base_path . "admin/"; // load databaseclass if($CLASS['vars']['db']['type'] == "mysql") { require_once($base_path."include/class-mysql.php"); } if($CLASS['vars']['db']['type'] == "mysqli") { require_once($base_path."include/class-mysqli.php"); } if($CLASS['vars']['db']['type'] == "pgsql") { require_once($base_path."include/class-pgsql.php"); } if($CLASS['vars']['db']['type'] == "mdb2") { require_once($base_path."include/class-mdb2.php"); } if($CLASS['vars']['db']['type'] == "sqlite") { require_once($base_path."include/class-sqlite.php"); } if($CLASS['vars']['db']['type'] == "oracle") { require_once($base_path."include/class-oracle.php"); } if($KNOWLEDGEROOTDB != "PGSQL" && $KNOWLEDGEROOTDB != "MYSQL" && $KNOWLEDGEROOTDB != "MDB2" && $KNOWLEDGEROOTDB != "SQLITE" && $KNOWLEDGEROOTDB != "OCI") { echo "WRONG DBTYPE SELECTED!\n"; exit(); } // init hooks $CLASS['hooks'] = new hooks(); $CLASS['hooks']->start($CLASS); // init databaseclass $CLASS['db'] = new db(); $CLASS['db']->start($CLASS); // connect to database $CLASS['db']->connect($CLASS['vars']['db']['host'],$CLASS['vars']['db']['user'],$CLASS['vars']['db']['pass'],$CLASS['vars']['db']['database'],$CLASS['vars']['db']['schema'],$CLASS['vars']['db']['encoding']); // init knowledgerootclass $CLASS['knowledgeroot'] = new knowledgeroot(); $CLASS['knowledgeroot']->start($CLASS); // load config from db $CLASS['vars'] = $CLASS['knowledgeroot']->replace_array($CLASS['vars'], $CLASS['knowledgeroot']->getConfigArr()); /** * PHP-Gettext */ define('LOCALE_DIR', $base_path.'system/language'); require_once ($base_path."system/php-gettext/gettext.inc.php"); if ($CLASS['vars']['knowledgeroot']['charset'] != '') { $encoding = $CLASS['vars']['knowledgeroot']['charset']; } else { $encoding = 'utf-8'; } if ($CLASS['vars']['knowledgeroot']['language'] != '') { define('DEFAULT_LOCALE', $CLASS['vars']['knowledgeroot']['language']); } else { define('DEFAULT_LOCALE', 'en'); } $locale = (isset($_SESSION['language']))? $_SESSION['language'] : DEFAULT_LOCALE; //$CLASS['error']->DebugOut($_SESSION['language']); // gettext setup putenv('LANG='.$locale); T_setlocale(LC_ALL, $locale); // Set the text domain as 'knowledgeroot' $domain = 'knowledgeroot'; //$domain = $locale; T_bindtextdomain($domain, LOCALE_DIR); // bind_textdomain_codeset is supported only in PHP 4.2.0+ if (function_exists('T_bind_textdomain_codeset')) T_bind_textdomain_codeset($domain, $encoding); T_textdomain($domain); /** * PHP-Gettext */ // init language $CLASS['language'] = new language(); $CLASS['language']->start($CLASS,$CLASS['vars']['knowledgeroot']['language']); // check for opera and konqueror // this is a short fix beacause the ajaxtree does not work in opera and konqueror if($CLASS['vars']['menu']['ajax'] == "yes") { // if(preg_match("/.*[Kk]onqueror.*/",$_SERVER['HTTP_USER_AGENT']) || preg_match("/.*[Oo]pera.*/",$_SERVER['HTTP_USER_AGENT'])) { // $CLASS['vars']['menu']['ajax'] = "no"; // } } // addslashes on GET/POST $CLASS['knowledgeroot']->addSlashesOnArray($_GET); $CLASS['knowledgeroot']->addSlashesOnArray($_POST); $CLASS['knowledgeroot']->addSlashesOnArray($_COOKIE); $CLASS['knowledgeroot']->addSlashesOnArray($_REQUEST); $CLASS['knowledgeroot']->addSlashesOnArray($_SERVER); // init header $CLASS['kr_header'] = new knowledgeroot_header(); $CLASS['kr_header']->start($CLASS); // load extensions $CLASS['kr_extension'] = new knowledgeroot_extension(); $CLASS['kr_extension']->start($CLASS,1); // add favicon pointer $CLASS['kr_header']->addheader(""); // add generator $CLASS['kr_header']->addheader(""); // set charset if($CLASS['vars']['knowledgeroot']['charset'] != "") { if($CLASS['vars']['knowledgeroot']['charset'] == "utf8") { $charset = "utf-8"; } else { $charset = $CLASS['vars']['knowledgeroot']['charset']; } header("Content-Type: text/html; charset=".$charset.""); $CLASS['kr_header']->addheader(""); } // add javascript to htmlheader $CLASS['kr_header']->addjssrc("../system/javascript/prototype.js"); $CLASS['kr_header']->addjssrc("../system/javascript/scriptaculous.js"); $CLASS['kr_header']->addjssrc("../system/javascript/effects.js"); $CLASS['kr_header']->addjssrc("../system/javascript/dragdrop.js"); $CLASS['kr_header']->addjssrc("../system/javascript/showhide.js"); $CLASS['kr_header']->addjssrc("../system/javascript/ajax-tree.js"); $CLASS['kr_header']->addjssrc("../system/javascript/messagebox.js"); // start all extensions $CLASS['kr_extension']->start_extensions(); // add hook $CLASS['hooks']->setHook("init_admin","init","end"); ?> knowledgeroot-0.9.9.5/include/class-mysqli.php0000644000175000017500000000660211240364352022324 0ustar fhabermannfhabermannCLASS['vars']['db']['pconnect']) && $this->CLASS['vars']['db']['pconnect'] == 1) { $this->connection = mysqli_pconnect($host,$user,$pass); } else { $this->connection = mysqli_connect($host,$user,$pass); } if(!$this->connection) { $this->CLASS['error']->log("Cannnot connect to host!",1,"class-mysqli.php::connect"); exit(); } $conndb = mysqli_select_db($this->connection, $db); if(!$conndb) { $this->CLASS['error']->log("Wrong Database!",1,"class-mysqli.php::connect"); exit(); } return $this->connection; } /** * Close mysql connection * @return bool */ function close() { return mysqli_close($this->connection); } /** * Will make a query with the mysql server * @param string $query * @return mixed return query result */ function query($query) { $this->lastquery = $query; $this->query_cache[] = $query; $this->querys += 1; $res = new db_result($this->CLASS); $res->setQuery($query); $res->setResult(mysqli_query($this->connection, $query)); if($res->getResult() === false) { $this->CLASS['error']->log("ERROR IN QUERY: \"$query\"",1,mysqli_errno() . ":".mysqli_errno()); } return $res; } /** * Will count the rows of a resultset * @param mixed $result * @return int */ function num_rows($result) { return mysqli_num_rows($result->getResult()); } /** * Fetch a Result as Object * @param mixed $result * @return object */ function fetch_object($result) { return mysqli_fetch_object($result->getResult()); } /** * Return Result as Array * @param mixed $result * @return array */ function fetch_row($result) { return mysqli_fetch_row($result->getResult()); } /** * Return Result as hash array * @param mixed result * @return array */ function fetch_assoc($result) { return mysqli_fetch_assoc($result->getResult()); } /** * Return affected rows of a result * @param mixed $result * @return int */ function affected_rows($result) { return mysqli_affected_rows($result->getResult()); } /** * Returns the text of the error message from previous MySQL operation * @return string */ function error() { return mysqli_error($this->connection); } /** * Return the last inserted id from a query * @param string $name not required * @return int */ function last_id($name = "") { return mysqli_insert_id($this->connection); } /** * Quote a String with Mysql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return "`" . $string . "`"; } /** * do data seek on result * @param resource $result * @param integer $number * @return bool */ function data_seek($result, $number) { return mysqli_data_seek($result->getResult(), $number); } } ?> knowledgeroot-0.9.9.5/include/class-extension-base.php0000644000175000017500000000623710646232017023737 0ustar fhabermannfhabermannCLASS =& $CLASS; // load GET and POST if(isset($_GET[get_class($this)])) $this->GET = $_GET[get_class($this)]; if(isset($_POST[get_class($this)])) $this->GET = $_POST[get_class($this)]; return 0; } /** * */ function extension_base(&$CLASS) { $this->CLASS =& $CLASS; // load GET and POST if(isset($_GET[get_class($this)])) $this->GET = $_GET[get_class($this)]; if(isset($_POST[get_class($this)])) $this->GET = $_POST[get_class($this)]; return 0; } /** * default functon for start */ function main() { return ""; } /** * Alias function for T_(modul,langtoken) */ function T_($langtoken) { return T_dgettext(get_class($this), $langtoken); } /** * default function do display content */ function show_content($id = "") { return ""; } /** * display textbox and load rte if possible */ function getTextbox($value = "", $use_rte = TRUE) { $out = ""; if ($use_rte == TRUE) { $out .= $this->CLASS['rte']->show($value); } else { $out .= "\n"; } return $out; } /** * display rightpanel if possible */ function getRightpanel($user=0,$group=0,$userrights=0,$grouprights=0,$otherrights=0) { $panel = ""; if(!empty($_SESSION['userid'])) { $panel = $this->CLASS['knowledgeroot']->editRightPanel($user,$group,$userrights,$grouprights,$otherrights); } return $panel; } /** * get rightpanel by contentid */ function getRightpanelByID($contentid) { $panel = ""; if(!empty($_SESSION['userid'])) { $res = $this->CLASS['db']->query(sprintf("SELECT * FROM content WHERE id=%d AND deleted=0",$contentid)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $panel = $this->CLASS['knowledgeroot']->editRightPanel($row['owner'],$row['group'],$row['userrights'],$row['grouprights'],$row['otherrights']); } } return $panel; } /** * display users default right panel * used for creation of new content */ function getDefaultRightpanel() { return $this->CLASS['knowledgeroot']->rightpanel($_SESSION['userid']); } } ?> knowledgeroot-0.9.9.5/include/class-db-core.php0000644000175000017500000001337611145636215022333 0ustar fhabermannfhabermannCLASS =& $CLASS; } function connect() { } function close() { } function query() { } /** * secure query * this function will wrap all over sprintf - so see sprintf for help * the result of sprintf will be send as query to database * @return resource resource of query */ function squery() { $args = func_num_args(); if($args > 0) { $param = func_get_args(); return $this->query(call_user_func_array('sprintf', $param)); } } /** * query format * this function will wrap all over sprintf - so see sprintf for help * the result of sprintf will be send as query to database * @return resource resource of query */ function queryf() { $args = func_num_args(); if($args > 0) { $param = func_get_args(); return $this->query(call_user_func_array('sprintf', $param)); } } /** * Quote a String with Postgresql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return "\"" . $string . "\""; } /** * create database insert with array * * @param string $table * @param array $values * @return mixed will return the result from the query */ function db_insert($table, $values) { if($table != "" && is_array($values)) { $sql = "INSERT INTO " . $this->quoteIdentifier($table) . " "; $coloum = "("; $coloumval = "("; foreach($values as $key => $value) { if(isset($values[$key]['value'])) { $coloum .= $this->quoteIdentifier($key) . ", "; if(isset($values[$key]['type'])) { switch($values[$key]['type']) { case "integer": case "INTEGER": if(isset($values[$key]['format'])) { $coloumval .= sprintf($values[$key]['format'].", ",$values[$key]['value']); } else { $coloumval .= sprintf("%d, ",$values[$key]['value']); } break; case "float": case "FLOAT": if(isset($values[$key]['format'])) { $coloumval .= sprintf($values[$key]['format'].", ",$values[$key]['value']); } else { $coloumval .= sprintf("%f, ",$values[$key]['value']); } break; default: if(isset($values[$key]['format'])) { $coloumval .= sprintf("'".$values[$key]['format']."', ",$values[$key]['value']); } else { $coloumval .= sprintf("'%s', ",$values[$key]['value']); } } } else { $coloumval .= sprintf("'%s', ",$values[$key]['value']); } } elseif(isset($values[$key]) && !is_array($values[$key]) && $values[$key] != "") { $coloum .= $this->quoteIdentifier($key) . ", "; $coloumval .= sprintf("'%s', ",$values[$key]); } } // remove last comma $coloum = substr($coloum,0,strlen($coloum)-2); $coloumval = substr($coloumval,0,strlen($coloumval)-2); $coloum .= ")"; $coloumval .= ")"; $sql .= $coloum . " VALUES " . $coloumval; return $this->query($sql); } else { $this->CLASS['error']->log('$table not set or $values are not a array',2,'class-db-core.php::db_insert'); return false; } } /** * create database update with array * * @param string $table * @param array $values * @param string $where * @return mixed will return the result from the query */ function db_update($table, $values, $where) { if($table != "" && is_array($values)) { $sql = "UPDATE " . $this->quoteIdentifier($table) . " SET "; $coloum = ""; foreach($values as $key => $value) { if(isset($values[$key]['value'])) { if(isset($values[$key]['type'])) { switch($values[$key]['type']) { case "integer": case "INTEGER": if(isset($values[$key]['format'])) { $coloum .= sprintf($this->quoteIdentifier('%s')."=".$values[$key]['format'].", ",$key,$values[$key]['value']); } else { $coloum .= sprintf($this->quoteIdentifier('%s')."=%d, ",$key,$values[$key]['value']); } break; case "float": case "FLOAT": if(isset($values[$key]['format'])) { $coloum .= sprintf($this->quoteIdentifier('%s')."=".$values[$key]['format'].", ",$key,$values[$key]['value']); } else { $coloum .= sprintf($this->quoteIdentifier('%s')."=%f, ",$key,$values[$key]['value']); } break; default: if(isset($values[$key]['format'])) { $coloum .= sprintf($this->quoteIdentifier('%s')."=".$values[$key]['format'].", ",$key,$values[$key]['value']); } else { $coloum .= sprintf($this->quoteIdentifier('%s')."='%s', ",$key,$values[$key]['value']); } } } else { $coloum .= sprintf($this->quoteIdentifier('%s')."='%s'",$key,$values[$key]['value']); } } elseif(isset($values[$key]) && !is_array($values[$key]) && $values[$key] != "") { $coloum .= sprintf("\"%s\"='%s'",$key,$values[$key]); } } // remove last comma $coloum = substr($coloum,0,strlen($coloum)-2); if($where == "") $where = "1"; $sql .= $coloum . " WHERE " . $where; return $this->query($sql); } else { $this->CLASS['error']->log('$table not set or $values are not a array',2,'class-db-core.php::db_update'); return false; } } /** * create a database delete * * @param string $table * @param string $where * @return mixed will return the result from the query */ function db_delete($table, $where) { if($table != "" && $where != "") { $sql = "DELETE FROM ".$this->quoteIdentifier($table); if($where != "") { $sql .= " WHERE " . $where; } return $this->query($sql); } else { $this->CLASS['error']->log('$table not set or $where are not a array',2,'class-db-core.php::db_delete'); return false; } } } ?> knowledgeroot-0.9.9.5/include/version.php0000644000175000017500000000004011273072135021357 0ustar fhabermannfhabermann knowledgeroot-0.9.9.5/include/class-knowledgeroot.php0000644000175000017500000017765411165504352023713 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * FROM Typo3 * AddSlash array * This function traverses a multidimentional array and adds slashes to the values. * NOTE that the input array is and argument by reference.!! * Twin-function to stripSlashesOnArray * Usage: 8 * * @param array Multidimensional input array, (REFERENCE!) * @return array */ function addSlashesOnArray(&$theArray) { if(get_magic_quotes_gpc() == 0) { if (is_array($theArray)) { reset($theArray); while(list($Akey,$AVal)=each($theArray)) { if (is_array($AVal)) { $this->addSlashesOnArray($theArray[$Akey]); } else { $theArray[$Akey] = addslashes($AVal); } } reset($theArray); } } } /** * return rightpanel for new content or page * @param integer $userid * @return string return rightpanel as html */ function rightpanel($userid = "") { // check if user have rights to set rights if(empty($userid)) { // user have no rights to see the panel return ""; } $res = $this->CLASS['db']->squery("SELECT u.id as uid, g.id as gid, u.name as user,g.name as ".$this->CLASS['db']->quoteIdentifier("group").", u.defaultrights as rights, u.rightedit as rightedit FROM users u, groups g WHERE g.id=u.defaultgroup AND u.id=%d",$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); if($row['rightedit'] == 0) { return ""; } } // get user dropdowns $users = $this->userSelectDropDown("user",$row['uid']); $musers = $this->userSelectDropDown("users[{ID}]"); // get group dropdowns $groups = $this->groupSelectDropDown("group",$row['gid']); $mgroups = $this->groupSelectDropDown("groups[{ID}]"); if(strlen($row['rights']) == 3) { $userright = substr($row['rights'],0,1); $groupright = substr($row['rights'],1,1); $otherright = substr($row['rights'],2,1); // Userrechte Dropdown $userrights = $this->rightDropDown("userrights",$userright); $muserrights = $this->rightDropDown("muserrights[{ID}]"); // Gruppenrechte Dropdown $grouprights = $this->rightDropDown("grouprights",$groupright); $mgrouprights = $this->rightDropDown("mgrouprights[{ID}]"); // Otherrechte Dropdown $otherrights = $this->rightDropDown("otherrights",$otherright); } $userrightsline = "".T_('user')."".$musers."".T_('userrights')."".$muserrights." \"\""; $grouprightsline = "".T_('group')."".$mgroups."".T_('grouprights')."".$mgrouprights." \"\""; $userrightsline = str_replace("\n","", $userrightsline); $grouprightsline = str_replace("\n","", $grouprightsline); $out = ""; $out .= ' '; $out .= "
    \n"; $out .= '
    '.T_('user').':' . $users . ''.T_('userrights').':' . $userrights . '
    '.T_('group').':' . $groups . ''.T_('grouprights').':' . $grouprights . '
     '.T_('otherrights').':' . $otherrights . '
     
    '; $out .= "
    \n"; return $out; } /** * show rightpanel with subinherit rights * @param integer $userid id of user * @return string return html */ function rightpanelsubinherit($userid = "") { // check if user have rights to set rights if(empty($userid)) { // user have no rights to see the panel return ""; } else { $res = $this->CLASS['db']->squery("SELECT u.id as uid, g.id as gid, u.name as user,g.name as ".$this->CLASS['db']->quoteIdentifier("group").", u.defaultrights as rights, u.rightedit as rightedit FROM users u, groups g WHERE g.id=u.defaultgroup AND u.id=%d",$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); if($row['rightedit'] == 0) { return ""; } } } // get user dropdowns $users = $this->userSelectDropDown("subinherituser",$row['uid']); $musers = $this->userSelectDropDown("subinheritusers[{ID}]"); // get group dropdowns $groups = $this->groupSelectDropDown("subinheritgroup",$row['gid']); $mgroups = $this->groupSelectDropDown("subinheritgroups[{ID}]"); if(strlen($row['rights']) == 3) { $userright = substr($row['rights'],0,1); $groupright = substr($row['rights'],1,1); $otherright = substr($row['rights'],2,1); // Userrechte Dropdown $userrights = $this->rightDropDown("subinherituserrights",$userright); $muserrights = $this->rightDropDown("subinheritmuserrights[{ID}]"); // Gruppenrechte Dropdown $grouprights = $this->rightDropDown("subinheritgrouprights",$groupright); $mgrouprights = $this->rightDropDown("subinheritmgrouprights[{ID}]"); // Otherrechte Dropdown $otherrights = $this->rightDropDown("subinheritotherrights",$otherright); } $userrightsline = "".T_('user')."".$musers."".T_('userrights')."".$muserrights." \"\""; $grouprightsline = "".T_('group')."".$mgroups."".T_('grouprights')."".$mgrouprights." \"\""; $userrightsline = str_replace("\n","", $userrightsline); $grouprightsline = str_replace("\n","", $grouprightsline); $out = ""; $out .= ' '; $out .= "".T_('enable inherit rights for subpages and contents')."
    \n"; $out .= "".T_('enable edit of rights for these pages and contents')."
    \n"; $out .= "".T_('disable inherit rights for subpages and contents')."
    \n"; $out .= "
    \n"; $out .= '
    '.T_('user').':' . $users . ''.T_('userrights').':' . $userrights . '
    '.T_('group').':' . $groups . ''.T_('grouprights').':' . $grouprights . '
     '.T_('otherrights').':' . $otherrights . '
     
    '; $out .= "
    \n"; return $out; } /** * return panel with dropdowns to set rights * @param string $table tablename * @param integer $belongsto * @param integer $userid * @param integer $groupid * @param integer $rights * @param integer $recursiv * @return string return rightpanel as html */ function editRightPanel($table,$belongsto,$userid,$groupid,$rights,$recursiv = 0) { //if(empty($userid)) { if($userid == "") { // you have no rights return ""; } $res = $this->CLASS['db']->squery("SELECT rightedit FROM users WHERE id=%d",$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); } if($_SESSION['rightedit'] != 1 && $_SESSION['admin'] == 0) { //you have no rights return ""; } //user $users = $this->userSelectDropDown("user",$userid); $musers = $this->userSelectDropDown("users[{ID}]"); //group $groups = $this->groupSelectDropDown("group",$groupid); $mgroups = $this->groupSelectDropDown("groups[{ID}]"); //userrights $userrights = $this->rightDropDown("userrights",substr($rights,0,1)); //grouprights $grouprights = $this->rightDropDown("grouprights",substr($rights,1,1)); //otherrights $otherrights = $this->rightDropDown("otherrights",substr($rights,2,1)); $muserrights = $this->rightDropDown("muserrights[{ID}]"); $mgrouprights = $this->rightDropDown("mgrouprights[{ID}]"); $recursivhtml = ''; if($recursiv == 1) { $recursivhtml = "".T_('set recursiv')."? \n"; $recursivhtml .= "\n"; $recursivhtml .= "\n"; } $multiplerights = ""; $multiplerightsid = 0; $userrightsline = "".T_('user')."".$musers."".T_('userrights')."".$muserrights." \"\""; $grouprightsline = "".T_('group')."".$mgroups."".T_('grouprights')."".$mgrouprights." \"\""; $userrightsline = str_replace("\n","", $userrightsline); $grouprightsline = str_replace("\n","", $grouprightsline); // get multiple rights $mrightsout = ""; $counterid = 0; $mrights = $this->getMultipleRights($table,$belongsto); if(is_array($mrights)) { foreach($mrights as $key => $value) { // check if right is for user if($value['owner_group'] == "o") { $mrightsout .= "".T_('user')."".$this->userSelectDropDown("users[".$counterid."]",$value['owner_group_id'])."".T_('userrights')."".$this->rightDropDown("muserrights[".$counterid."]",$value['rights'])." \"\"\n"; } // check if right is for group if($value['owner_group'] == "g") { $mrightsout .= "".T_('group')."".$this->groupSelectDropDown("groups[".$counterid."]",$value['owner_group_id'])."".T_('grouprights')."".$this->rightDropDown("mgrouprights[".$counterid."]",$value['rights'])." \"\"\n"; } // inc counterid $counterid++; } } $out = ""; $out .= ' '; $out .= "
    \n"; $out .= ' '.$mrightsout.' '.$recursivhtml.'
    '.T_('user').':' . $users . ''.T_('userrights').':' . $userrights . '
    '.T_('group').':' . $groups . ''.T_('grouprights').':' . $grouprights . '
     '.T_('otherrights').':' . $otherrights . '
     
    '; $out .= "
    \n"; return $out; } /** * return panel with dropdowns to set rights * @param string $table * @param integer $belongsto * @param integer $subinheritrights * @param integer $subinheritsrightsenable * @param integer $subinheritsrightsdisable * @param integer $userid * @param integer $groupid * @param integer $subuserrights * @param integer $subgrouprights * @param integer $subotherrights * @return string return rightpanel as html */ function editRightPanelSubInherit($table,$belongsto,$subinheritrights,$subinheritsrightsenable,$subinheritsrightsdisable,$userid,$groupid,$subuserrights,$subgrouprights,$subotherrights) { //if(empty($userid)) { if((isset($_SESSION['admin']) && $_SESSION['admin'] != 1) || $userid == "") { // you have no rights return ""; } $res = $this->CLASS['db']->squery("SELECT rightedit FROM users WHERE id=%d",$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); } if($_SESSION['rightedit'] != 1 && $_SESSION['admin'] == 0) { //you have no rights return ""; } //user $users = $this->userSelectDropDown("subinherituser",$userid); $musers = $this->userSelectDropDown("subinheritusers[{ID}]"); //group $groups = $this->groupSelectDropDown("subinheritgroup",$groupid); $mgroups = $this->groupSelectDropDown("subinheritgroups[{ID}]"); //userrights $userrights = $this->rightDropDown("subinherituserrights",$subuserrights); //grouprights $grouprights = $this->rightDropDown("subinheritgrouprights",$subgrouprights); //otherrights $otherrights = $this->rightDropDown("subinheritotherrights",$subotherrights); $muserrights = $this->rightDropDown("subinheritmuserrights[{ID}]"); $mgrouprights = $this->rightDropDown("subinheritmgrouprights[{ID}]"); if($subinheritrights == 1) $subinheritscheck = "checked=\"checked\" "; else $subinheritscheck = ""; if($subinheritsrightsenable == 1) $subinheritsenablecheck = "checked=\"checked\" "; else $subinheritsenablecheck = ""; if($subinheritsrightsdisable == 1) $subinheritsdisablecheck = "checked=\"checked\" "; else $subinheritsdisablecheck = ""; $multiplerights = ""; $multiplerightsid = 0; $userrightsline = "".T_('user')."".$musers."".T_('userrights')."".$muserrights." \"\""; $grouprightsline = "".T_('group')."".$mgroups."".T_('grouprights')."".$mgrouprights." \"\""; $userrightsline = str_replace("\n","", $userrightsline); $grouprightsline = str_replace("\n","", $grouprightsline); // get multiple rights $mrightsout = ""; $counterid = 0; $mrights = $this->getMultipleRights($table,$belongsto); if(is_array($mrights)) { foreach($mrights as $key => $value) { // check if right is for user if($value['owner_group'] == "so") { $mrightsout .= "".T_('user')."".$this->userSelectDropDown("subinheritusers[".$counterid."]",$value['owner_group_id'])."".T_('userrights')."".$this->rightDropDown("subinheritmuserrights[".$counterid."]",$value['rights'])." \"\"\n"; } // check if right is for group if($value['owner_group'] == "sg") { $mrightsout .= "".T_('group')."".$this->groupSelectDropDown("subinheritgroups[".$counterid."]",$value['owner_group_id'])."".T_('grouprights')."".$this->rightDropDown("subinheritmgrouprights[".$counterid."]",$value['rights'])." \"\"\n"; } // inc counterid $counterid++; } } $out = ""; $out .= ' '; $out .= "".T_('enable inherit rights for subpages and contents')."
    \n"; $out .= "".T_('enable edit of rights for these pages and contents')."
    \n"; $out .= "".T_('disable inherit rights for subpages and contents')."
    \n"; $out .= "
    \n"; $out .= ' '.$mrightsout.'
    '.T_('user').':' . $users . ''.T_('userrights').':' . $userrights . '
    '.T_('group').':' . $groups . ''.T_('grouprights').':' . $grouprights . '
     '.T_('otherrights').':' . $otherrights . '
     
    '; $out .= "
    \n"; return $out; } /** * new function that check page rights with multiple rights * @param integer $pageid * @param integer $userid * @return integer return rights of object */ function getPageRights($pageid, $userid) { $pagerights = $this->_getPageRights($pageid, $userid); // check if pagerights are already full then return if($pagerights == 2) return 2; $mrights = $this->checkMultipleRights($userid, "tree", $pageid); if($mrights > $pagerights) { return $mrights; } else { return $pagerights; } } /** * return rights on a page by userid * @param integer $pageid * @param integer $userid * @return integer return rights of object */ function _getPageRights($pageid, $userid) { if(!isset($pageid) || !isset($userid)) { return 0; } // get userrights if(!isset($this->user_cache_rights[$userid])) { $res = $this->CLASS['db']->squery("SELECT * FROM users WHERE id=%d AND deleted=0",$userid); $anz = $this->CLASS['db']->num_rows($res); // check if user exists, if not - no rights if($anz == 0 && $userid != 0) { return 0; } // userrow $rowuser = $this->CLASS['db']->fetch_assoc($res); // set cache $this->user_cache_rights[$userid] = $rowuser; } else { // get from cache $rowuser = $this->user_cache_rights[$userid]; } // check if user is admin, if yes then give full rights if($rowuser['admin'] == 1) { return 2; } // get pagerights if(!isset($this->tree_cache_rights[$pageid])) { $res = $this->CLASS['db']->squery("SELECT * FROM tree WHERE id=%d AND deleted=0",$pageid); $anz = $this->CLASS['db']->num_rows($res); // check if page exists, if not - no rights if($anz == 0) { return 0; } // pagerow $rowpage = $this->CLASS['db']->fetch_assoc($res); // set cache $this->tree_cache_rights[$pageid] = $rowpage; } else { // get from cache $rowpage = $this->tree_cache_rights[$pageid]; } if($rowpage['owner'] == $rowuser['id']) { return $rowpage['userrights']; } if($rowpage['group'] == $rowuser['defaultgroup']) { return $rowpage['grouprights']; } // check for caching if(!isset($this->user_group_cache[$userid])) { $this->user_group_cache[$userid] = array(); $found = 0; $res = $this->CLASS['db']->squery("SELECT groupid FROM user_group WHERE userid=%d",$userid); while($row = $this->CLASS['db']->fetch_assoc($res)) { if($row['groupid'] == $rowpage['group']) { $found = 1; } // set cache $this->user_group_cache[$userid][] = $row; } if($found == 1) return $rowpage['grouprights']; } else { if(is_array($this->user_group_cache[$userid])) { // get from cache foreach($this->user_group_cache[$userid] as $key => $value) { if($this->user_group_cache[$userid][$key]['groupid'] == $rowpage['group']) { return $rowpage['grouprights']; } } } } return $rowpage['otherrights']; } /** * new function that check content rights with multiple rights * @param integer $contentid * @param integer $userid * @return integer return rights of object */ function getContentRights($contentid, $userid) { $contentrights = $this->_getContentRights($contentid, $userid); // check if pagerights are already full then return if($contentrights == 2) return 2; $mrights = $this->checkMultipleRights($userid, "content", $contentid); if($mrights > $contentrights) { return $mrights; } else { return $contentrights; } } /** * return rights on a content by userid * @param integer $contentid * @param integer $userid * @return integer return rights of object */ function _getContentRights($contentid, $userid) { if(!isset($contentid) || !isset($userid)) { return 0; } // get userrights if(!isset($this->user_cache_rights[$userid])) { $res = $this->CLASS['db']->squery("SELECT * FROM users WHERE id=%d AND deleted=0",$userid); $anz = $this->CLASS['db']->num_rows($res); // check if user exists, if not - no rights if($anz == 0 && $userid != 0) { return 0; } // userrow $rowuser = $this->CLASS['db']->fetch_assoc($res); // set cache $this->user_cache_rights[$userid] = $rowuser; } else { // get from cache $rowuser = $this->user_cache_rights[$userid]; } // check if user is admin, if yes then give full rights if($rowuser['admin'] == 1) { return 2; } // get contentrights if(!isset($this->content_cache_rights[$contentid])) { $res = $this->CLASS['db']->squery("SELECT * FROM content WHERE id=%d AND deleted=0",$contentid); $anz = $this->CLASS['db']->num_rows($res); // check if content exists, if not - no rights if($anz == 0) { return 0; } // pagerow $rowcontent = $this->CLASS['db']->fetch_assoc($res); // set cache $this->content_cache_rights[$contentid] = $rowcontent; } else { // get from cache $rowcontent = $this->content_cache_rights[$contentid]; } if($rowcontent['owner'] == $rowuser['id']) { return $rowcontent['userrights']; } if($rowcontent['group'] == $rowuser['defaultgroup']) { return $rowcontent['grouprights']; } // check for caching if(!isset($this->user_group_cache[$userid])) { $this->user_group_cache[$userid] = array(); $found = 0; $res = $this->CLASS['db']->squery("SELECT groupid FROM user_group WHERE userid=%d",$userid); while($row = $this->CLASS['db']->fetch_assoc($res)) { if($row['groupid'] == $rowcontent['group']) { $found = 1; } // set cache $this->user_group_cache[$userid][] = $row; } if($found == 1) return $rowcontent['grouprights']; } else { if(is_array($this->user_group_cache[$userid])) { // get from cache foreach($this->user_group_cache[$userid] as $key => $value) { if($this->user_group_cache[$userid][$key]['groupid'] == $rowcontent['group']) { return $rowcontent['grouprights']; } } } } return $rowcontent['otherrights']; } /** * return yes or no * @param integer $value * @return string return yes or no */ function yesno($value) { if($value == "1" || $value == true) { return T_('yes'); } return T_('no'); } /** * return a yes/no dropdown * @param string $name name of dropdown * @param integer $default if yes or no is selected by default * @return string return html dropdown */ function yesnodropdown($name, $default = 0) { $defaultno = ($default==0) ? " selected" : ""; $defaultyes = ($default==1) ? " selected" : ""; $out = "\n"; return $out; } /** * return groupname * @param integer $id id of group * @return string return name of group */ function getGroup($id) { if($id == "") { return ""; } if(!isset($this->group_cache[$id])) { $res = $this->CLASS['db']->squery("SELECT name FROM groups WHERE id=%d",$id); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $this->group_cache[$id] = $row; } } else { $row = $this->group_cache[$id]; } if(!isset($row['name'])) $row['name'] = ""; return $row['name']; } /** * return id of groupname * @param string $name name of group * @return integer return id of groupname */ function getGroupID($name) { if($name == "") { return 0; } if(!isset($this->groups_cache[$name])) { $res = $this->CLASS['db']->squery("SELECT id FROM groups WHERE name='%s'",$name); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $this->groups_cache[$name] = $row; return $row['id']; } } else { return $this->groups_cache[$name]['id']; } return 0; } /** * returns name of userid * @param integer $id id of user * @return string return name of user */ function getOwner($id) { if($id == "") { return ""; } $res = $this->CLASS['db']->squery("SELECT name FROM users WHERE id=%d",$id); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); return $row['name']; } return ""; } /** * returns a dropdown of grouprights * @param string $name name of dropdown * @param integer $default id of default group * @param bool $multiple dropdown is multiple * @param array $defaultgroups array with defaultgroups that are selected * @return string return html dropdown */ function groupDropDown($name, $default = "", $multiple = false, $defaultgroups = array()) { if($multiple == true) { $out = "\""; } $res = $this->CLASS['db']->query("SELECT id,name FROM groups"); while($row = $this->CLASS['db']->fetch_assoc($res)) { if($default == $row['id'] || $this->foundIDinArray($row['id'],$defaultgroups)) { $out .= ""; } else { $out .= ""; } } $out .= "\n"; return $out; } /** * search for id in array * @param integer $id id that should be found * @param array $arr array with elements * @return bool */ function foundIDinArray($id,$arr) { if(!is_array($arr)) { $arr = array(); } foreach($arr as $key => $value) { if($value == $id) { return true; } } return false; } /** * returns a dropdown with rights * @param string $name name of dropdown * @param integer $default rights that are selected * @return string return html dropdown with rights */ function rightDropDown($name,$default = "") { $out = "\n"; return $out; } /** * check if a user have recursiv permissions on pageid * @param integer $pageid id of page * @param integer $userid id of user * @return integer return rights (0,1,2) */ function checkRecursivPerm($pageid, $userid) { if($userid == "") { $userid = 0; } if(strlen($pageid) > 0 && strlen($userid) > 0) { if(!isset($this->recursiv_page_perm_cache[$pageid])) { $res = $this->CLASS['db']->squery("SELECT id,belongs_to FROM tree WHERE id=%d and deleted=0",$pageid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $this->recursiv_page_perm_cache[$pageid] = $row; } else { return 0; } } else { $row = $this->recursiv_page_perm_cache[$pageid]; } if($row['belongs_to'] == 0) { return $this->getPageRights($row['id'],$userid); } else { $rights = $this->getPageRights($row['id'],$userid); if($rights == 0) { return 0; } else { return $this->checkRecursivPerm($row['belongs_to'],$userid); } } } return 0; } /** * set rights recursiv on pages and content * @param integer $pageid id of page * @param integer $userid id of user * @param integer $user id of user that will be set * @param integer $group id of group that will be set * @param integer $rights rights * @param array $mrights array with multiple rights * @return bool */ function setRightsRecursiv($pageid,$userid,$user,$group,$rights,$mrights = null) { $userrights = substr($rights,0,1); $grouprights = substr($rights,1,1); $otherrights = substr($rights,2,1); // get multiplerights if(!is_array($mrights)) { $mrights = $this->getMultipleRights("tree", $pageid); } // set rights for contents $res = $this->CLASS['db']->squery("SELECT id FROM content WHERE belongs_to=%d AND deleted=0",$pageid); while($row = $this->CLASS['db']->fetch_assoc($res)) { if($this->getContentRights($row['id'],$userid) == 2) { $ressub = $this->CLASS['db']->squery("UPDATE content SET owner=%d, ".$this->CLASS['db']->quoteIdentifier("group")."=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$user,$group,$userrights,$grouprights,$otherrights,$row['id']); // delete all existing multiple rights on this element $this->deleteMultipleRightsAll("content", $row['id']); // set multiple rights on content foreach($mrights as $key => $value) { if($value['owner_group'] == "o" || $value['owner_group'] == "g") { $this->saveMultipleRights("content", $row['id'], $value['owner_group'], $value['owner_group_id'], $value['rights']); } } } } // set rights for subpages $res = $this->CLASS['db']->squery("SELECT id FROM tree WHERE belongs_to=%d AND deleted=0",$pageid); while($row = $this->CLASS['db']->fetch_assoc($res)) { if($this->getPageRights($row['id'],$userid) == 2) { $ressub = $this->CLASS['db']->squery("UPDATE tree SET owner=%d, ".$this->CLASS['db']->quoteIdentifier("group")."=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$user,$group,$userrights,$grouprights,$otherrights,$row['id']); // delete all existing multiple rights on this element $this->deleteMultipleRightsAll("tree", $row['id']); // set multiple rights on content foreach($mrights as $key => $value) { $this->saveMultipleRights("tree", $row['id'], $value['owner_group'], $value['owner_group_id'], $value['rights']); } $this->setRightsRecursiv($row['id'],$userid,$user,$group,$rights, $mrights); } } return true; } /** * replace values from $arr1 with the values in arr2 * @param array $arr1 * @param array $arr2 * @return array */ function replace_array($arr1, $arr2) { foreach($arr2 as $key => $value) { if(is_array($arr2[$key])) { if(isset($arr1[$key])) $arr1[$key] = $this->replace_array($arr1[$key],$arr2[$key]); else $arr1[$key] = $this->replace_array("",$arr2[$key]); } else { $arr1[$key] = $value; } } return $arr1; } /** * IMPORTET FROM TYPO3 * Wrapping a string. * Implements the TypoScript "wrap" property. * Example: $content = "HELLO WORLD" and $wrap = " | ", result: "HELLO WORLD" * * @param string The content to wrap * @param string The wrap value, eg. " | " * @param string The char used to split the wrapping value, default is "|" * @return string Wrapped input string * @see noTrimWrap() */ function setWrap($content = "",$wrap = "",$char = "|") { if ($wrap) { // fix for || replacings $wrap = str_replace('||', '[NOT_TO_BE_REPLACED]', $wrap); $wrapArr = explode($char, $wrap); $content = $wrapArr[0].$content.$wrapArr[1]; $content = str_replace('[NOT_TO_BE_REPLACED]', '||', $content); return $content; } else return $content; } /** * check for alias and returns a good alias * @param string $alias * @return string */ function checkAlias($alias) { // replace all chars that are not a-z A-Z 0-9 $alias = preg_replace("/[^a-zA-Z0-9]*/s","",$alias); $res = $this->CLASS['db']->squery("SELECT count(*) AS anz FROM tree WHERE alias='%s' AND deleted=0",$alias); $row = $this->CLASS['db']->fetch_assoc($res); $x = 0; while($row['anz'] >= 1) { $x++; $alias_new = $alias . $x; $res = $this->CLASS['db']->squery("SELECT count(*) AS anz FROM tree WHERE alias='%s' AND deleted=0",$alias_new); $row = $this->CLASS['db']->fetch_assoc($res); } if($x == 0) { return $alias; } else { return $alias_new; } } /** * create array from path and set value * @param array &$arr * @param string $path * @param string $value */ function createArr(&$arr, $path, $value) { $p =& $arr; $path_arr = explode(".",$path); foreach($path_arr as $key) { $key = trim($key); if(!isset($p[$key])) { $p[$key] = array(); } $p =& $p[$key]; } $p = trim($value); unset($p); } /** * save config value with a path * @param string $path * @param string $value */ function setConfig($path,$value) { $path_arr = explode(".", $path); if($path_arr[0] == "db") { return ""; } $res = $this->CLASS['db']->squery("SELECT id FROM settings WHERE name='%s'",$path); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $res = $this->CLASS['db']->squery("UPDATE settings SET name='%s', value='%s' WHERE name='%s'",$path,$value,$path); } else { $res = $this->CLASS['db']->squery("INSERT INTO settings (name, value) VALUES ('%s', '%s')",$path,$value); } } /** * get configvalue from a path * @param string $path * @return string */ function getConfig($path) { $res = $this->CLASS['db']->squery("SELECT value FROM settings WHERE name='%s'",$path); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); return $row['value']; } else { return ""; } } /** * save array to config * @param array $arr * @param string $path */ function setConfigArr($arr, $path = "") { $path = $path == "" ? "" : $path . "."; foreach($arr as $key => $value) { // db should not be converted if($key == "db" && $path == "") { continue; } if(is_array($arr[$key])) { $this->setConfigArr($arr[$key], $path.$key); } else { $name = $path . $key; $this->setConfig($name, $value); } } } /** * get config as array with path * @param string $path * @return array */ function getConfigArr($path = "") { $CONFIG = array(); $res = $this->CLASS['db']->query("SELECT * FROM settings"); while($row = $this->CLASS['db']->fetch_assoc($res)) { $this->createArr($CONFIG, $row['name'], $row['value']); } if($path == "") { return $CONFIG; } $p =& $CONFIG; $path_arr = explode(".", $path); foreach($path_arr as $key) { $key = trim($key); if(!isset($p[$key])) { $p[$key] = array(); } $p =& $p[$key]; } return $p; } /** * delete a config value with a path * @param string $path * @param bool $recursiv */ function delConfig($path, $recursiv = false) { if($recursiv == true) { $res = $this->CLASS['db']->squery("DELETE FROM settings WHERE name like '%s%%'",$path); } else { $res = $this->CLASS['db']->squery("DELETE FROM settings WHERE name='%s'",$path); } } /** * mark content as opened * @param integer $contentid * @param integer $userid */ function openContent($contentid, $userid) { $this->clearOpenContent(); if(strlen($contentid) > 0 && strlen($userid) > 0) { $time = time(); if(sprintf("%d",$userid) == "0") { $userid = session_id(); } else { //echo "##"; } $res = $this->CLASS['db']->squery("SELECT id FROM content_open WHERE contentid=%d AND userid='%s'",$contentid,$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz != 0) { $res = $this->CLASS['db']->squery("UPDATE content_open SET opened=%d WHERE contentid=%d and userid='%s'",$time,$contentid,$userid); } else { $res = $this->CLASS['db']->squery("INSERT INTO content_open (contentid, userid, opened) VALUES (%d, '%s', %d)",$_GET['eid'],$userid,$time); } } } /** * close opened contents * @param integer $contentid * @param integer $userid */ function closeOpenContent($contentid, $userid) { $this->clearOpenContent(); if(sprintf("%d",$userid) == "0") { $userid = session_id(); } if(strlen($contentid) > 0 && strlen($userid) > 0) { $res = $this->CLASS['db']->squery("DELETE FROM content_open WHERE contentid=%d AND userid='%s'",$contentid,$userid); } } /** * clear old opened contents */ function clearOpenContent() { $timeout = 1800; $time = time() - $timeout; $res = $this->CLASS['db']->squery("DELETE FROM content_open WHERE opened <= %d",$time); } /** * show if content is already opened by other user * @param integer $contentid * @param integer $userid * @return bool */ function isOpenContent($contentid, $userid) { $this->clearOpenContent(); if(strlen($contentid) > 0 && strlen($userid) > 0) { if(sprintf("%d",$userid) == "0") { $userid = session_id(); } $res = $this->CLASS['db']->squery("SELECT id FROM content_open WHERE contentid=%d AND userid!='%s'",$contentid,$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz > 0) { return true; } else { return false; } } else { return false; } } /** * returns an array with rights if the pageid should inherit rights - if not it returns false * @param integer $pageid * @return array will return false if no rights are found */ function getInheritRights($pageid) { if($this->isInheritRights($pageid)) { // check internal cache that was build by function isInheritRights if(isset($this->inerhitpagerights_cache[$pageid]) && is_array($this->inerhitpagerights_cache[$pageid])) { $row = $this->inerhitpagerights_cache[$pageid]; if($row['subinheritrights'] == 1) { return $row; } elseif($row['subinheritrightsdisable'] == 1) { return $row; } else { return $this->getInheritRights($row['belongs_to']); } } } return false; } /** * return true or false if the pageid should inherit rights * @param integer $pageid * @return bool */ function isInheritRights($pageid) { if(isset($this->inerhitpagerights_cache[$pageid]) && is_array($this->inerhitpagerights_cache[$pageid])) { $row = $this->inerhitpagerights_cache[$pageid]; if($row['subinheritrights'] == 1) { return true; } elseif($row['subinheritrightsdisable'] == 1) { return false; } else { if($pageid != 0) { return $this->isInheritRights($row['belongs_to']); } } } else { $res = $this->CLASS['db']->squery("SELECT id, belongs_to, subinheritrights, subinheritrightseditable, subinheritrightsdisable, subinheritowner, subinheritgroup, subinherituserrights, subinheritgrouprights, subinheritotherrights FROM tree WHERE id=%d AND deleted=0",$pageid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $this->inerhitpagerights_cache[$pageid] = $row; if($row['subinheritrights'] == 1) { return true; } elseif($row['subinheritrightsdisable'] == 1) { return false; } else { if($pageid != 0) { return $this->isInheritRights($row['belongs_to']); } } } } return false; } /** * This function will return environment variables * * This function was used from typo3 and was modified * * @param string $name name of the environment * @return string value of this environment */ function getEnv($name) { switch((string)$name) { case 'SCRIPT_NAME': return (php_sapi_name()=='cgi'||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) : ((isset($_SERVER['ORIG_SCRIPT_NAME']) && $_SERVER['ORIG_SCRIPT_NAME'])?$_SERVER['ORIG_SCRIPT_NAME']:$_SERVER['SCRIPT_NAME']); break; case 'SCRIPT_FILENAME': return str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME']))); break; case 'REQUEST_URI': // Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode($this->getIndpEnv('REQUEST_URI')) if (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available. return '/'.ereg_replace('^/','',$this->getEnv('SCRIPT_NAME')). ($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:''); } else return $_SERVER['REQUEST_URI']; break; case 'PATH_INFO': // $_SERVER['PATH_INFO']!=$_SERVER['SCRIPT_NAME'] is necessary because some servers (Windows/CGI) are seen to set PATH_INFO equal to script_name // Further, there must be at least one '/' in the path - else the PATH_INFO value does not make sense. // IF 'PATH_INFO' never works for our purpose in TYPO3 with CGI-servers, then 'php_sapi_name()=='cgi'' might be a better check. Right now strcmp($_SERVER['PATH_INFO'],$this->getIndpEnv('SCRIPT_NAME')) will always return false for CGI-versions, but that is only as long as SCRIPT_NAME is set equal to PATH_INFO because of php_sapi_name()=='cgi' (see above) // if (strcmp($_SERVER['PATH_INFO'],$this->getIndpEnv('SCRIPT_NAME')) && count(explode('/',$_SERVER['PATH_INFO']))>1) { if (php_sapi_name()!='cgi'&&php_sapi_name()!='cgi-fcgi') { return $_SERVER['PATH_INFO']; } else return ''; break; // These are let through without modification case 'REMOTE_ADDR': case 'REMOTE_HOST': case 'HTTP_REFERER': case 'HTTP_HOST': case 'HTTP_USER_AGENT': case 'HTTP_ACCEPT_LANGUAGE': case 'QUERY_STRING': return $_SERVER[$getEnvName]; break; case 'DOCUMENT_ROOT': // Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a 'wrong' DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well. // Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME. $SFN = $this->getEnv('SCRIPT_FILENAME'); $SN_A = explode('/',strrev($this->getEnv('SCRIPT_NAME'))); $SFN_A = explode('/',strrev($SFN)); $acc = array(); while(list($kk,$vv)=each($SN_A)) { if (!strcmp($SFN_A[$kk],$vv)) { $acc[] = $vv; } else break; } $commonEnd=strrev(implode('/',$acc)); if (strcmp($commonEnd,'')) { $DR = substr($SFN,0,-(strlen($commonEnd)+1)); } return $DR; break; case 'HOST_ONLY': $p = explode(':',$_SERVER['HTTP_HOST']); return $p[0]; break; case 'PORT': $p = explode(':',$_SERVER['HTTP_HOST']); return $p[1]; break; case 'REQUEST_HOST': return ($this->getEnv('SSL') ? 'https://' : 'http://'). $_SERVER['HTTP_HOST']; break; case 'REQUEST_URL': return $this->getEnv('REQUEST_HOST').$this->getEnv('REQUEST_URI'); break; case 'REQUEST_SCRIPT': return $this->getEnv('REQUEST_HOST').$this->getEnv('SCRIPT_NAME'); break; case 'REQUEST_DIR': return $this->getEnv('REQUEST_HOST').$this->dirname($this->getEnv('SCRIPT_NAME')).'/'; break; case 'SITE_URL': if (defined('PATH_thisScript') && defined('PATH_site')) { $lPath = substr(dirname(PATH_thisScript),strlen(PATH_site)).'/'; $url = $this->getEnv('REQUEST_DIR'); $siteUrl = substr($url,0,-strlen($lPath)); if (substr($siteUrl,-1)!='/') $siteUrl.='/'; return $siteUrl; } else return ''; break; case 'SITE_SCRIPT': return substr($this->getEnv('REQUEST_URL'),strlen($this->getEnv('SITE_URL'))); break; case 'SSL': return (isset($_SERVER['SSL_SESSION_ID']) && $_SERVER['SSL_SESSION_ID']) || (isset($_SERVER['HTTPS']) && !strcmp($_SERVER['HTTPS'],'on')) ? TRUE : FALSE; break; case '_ALL_': $out = array(); // Here, list ALL possible keys to this function for debug display. $envTestVars = explode(',','HTTP_HOST,HOST_ONLY,PORT,PATH_INFO,QUERY_STRING,REQUEST_URI,HTTP_REFERER,REQUEST_HOST,REQUEST_URL,REQUEST_SCRIPT,REQUEST_DIR,SITE_URL,SITE_SCRIPT,SSL,SCRIPT_NAME,DOCUMENT_ROOT,SCRIPT_FILENAME,REMOTE_ADDR,REMOTE_HOST,HTTP_USER_AGENT,HTTP_ACCEPT_LANGUAGE'); foreach($envTestVars as $key => $v) { $out[trim($v)]=$this->getEnv(trim($v)); } reset($out); return $out; break; } } /** * FROM TYPO3 * Returns the directory part of a path without trailing slash * If there is no dir-part, then an empty string is returned. * Behaviour: * * '/dir1/dir2/script.php' => '/dir1/dir2' * '/dir1/' => '/dir1' * 'dir1/script.php' => 'dir1' * 'd/script.php' => 'd' * '/script.php' => '' * '' => '' * Usage: 5 * * @param string Directory name / path * @return string Processed input value. See function description. */ function dirname($path) { $p=$this->revExplode('/',$path,2); return count($p)==2?$p[0]:''; } /** * FROM TYPO3 * Reverse explode which explodes the string counting from behind. * Thus t3lib_div::revExplode(':','my:words:here',2) will return array('my:words','here') * Usage: 8 * * @param string Delimiter string to explode with * @param string The string to explode * @param integer Number of array entries * @return array Exploded values */ function revExplode($delim, $string, $count=0) { $temp = explode($delim,strrev($string),$count); while(list($key,$val)=each($temp)) { $temp[$key]=strrev($val); } $temp=array_reverse($temp); reset($temp); return $temp; } /** * save multiple rights to table access * @param string $table tablename * @param integer $belongs_to id to that the rights belongs * @param string $owner_group owner or group as o or g * @param integer $owner_group_id id of owner or group * @param integer $rights rights for that id - could be 0, 1, 2 * @return boolean return bool or resultset of sqlquery */ function saveMultipleRights($table_name, $belongs_to, $owner_group, $owner_group_id, $rights) { // first check if rights for this user/group exists on this id on this table $res = $this->CLASS['db']->squery("SELECT id,rights FROM access WHERE table_name='%s' AND belongs_to=%d AND owner_group='%s' AND owner_group_id=%d",$table_name, $belongs_to, $owner_group, $owner_group_id); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); // check if rights are different - if not no update is needed if($row['rights'] != $rights) { $res = $this->CLASS['db']->squery("UPDATE access SET rights=%d WHERE table_name='%s' AND belongs_to=%d AND owner_group='%s' AND owner_group_id=%d",$rights,$table_name, $belongs_to, $owner_group, $owner_group_id); return $res; } else { return true; } } else { $res = $this->CLASS['db']->squery("INSERT INTO access (table_name, belongs_to, owner_group, owner_group_id, rights) VALUES ('%s', %d, '%s', %d, %d)",$table_name, $belongs_to, $owner_group, $owner_group_id, $rights); return $res; } return false; } /** * save multiple rights to table access with array * * array must contain the following elements * $arr[1] = array( * 'table_name' => 'name', * 'belongs_to' => 'id', * 'owner_group' => 'o', * 'owner_group_id' => 'id', * 'rights' => '2', * ); * * @param array $arr multiple rights as array * @return array return bool or result in each array element */ function saveMultipleRightsArr($arr) { if(is_array($arr)) { $arr_out = array(); foreach($arr as $key => $value) { if(isset($value['table_name']) && isset($value['belongs_to']) && isset($value['owner_group']) && isset($value['owner_group_id']) && isset($value['rights'])) { $arr_out[$key] = $this->saveMultipleRights($value['table_name'],$value['belongs_to'],$value['owner_group'],$value['owner_group_id'],$value['rights']); } else { $arr_out[$key] = false; } } return $arr_out; } else { return false; } } /** * delete all existing multiple rights for an object * @param string $table_name name of table * @param integer $belongsto id of object * @return resource return resultset of query */ function deleteMultipleRightsAll($table_name, $belongs_to) { // clear old rights $res = $this->CLASS['db']->squery("DELETE FROM access WHERE table_name='%s' AND belongs_to=%d",$table_name, $belongs_to); return $res; } /** * delete multiple rights from table access */ function deleteMultipleRights($table_name, $belongs_to, $owner_group, $owner_group_id) { $res = $this->CLASS['db']->squery("DELETE FROM access WHERE table_name='%s' AND belongs_to=%d AND owner_group='%s' AND owner_group_id=%d",$table_name, $belongs_to, $owner_group, $owner_group_id); return $res; } /** * get all rights for an element * @param string $table tablename * @param integer $belongsto id of element * @return array array with all rights */ function getMultipleRights($table, $belongsto) { $out = array(); $res = $this->CLASS['db']->squery("SELECT * FROM access WHERE table_name='%s' AND belongs_to=%d",$table,$belongsto); while($row = $this->CLASS['db']->fetch_assoc($res)) { $out[] = $row; } return $out; } /** * check rights for an user on element * @param integer $userid id of user * @param string $table tablename * @param integer $belongsto id of element * @return integer will return rights on element (0,1,2) */ function checkMultipleRights($userid, $table, $belongsto) { // default rights for user - no rights $rights = 0; // get rights from element $element = $this->getMultipleRights($table,$belongsto); // array with id of groups $groupids = array(); // get default groupid from user $res = $this->CLASS['db']->squery("SELECT admin,defaultgroup FROM users WHERE id=%d AND deleted=0",$userid); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); // check if admin then return 2 if($row['admin'] == 1) return 2; $groupids[$row['defaultgroup']] = $row['defaultgroup']; } // get group ids $res = $this->CLASS['db']->squery("SELECT groupid FROM user_group WHERE userid=%d",$userid); while($row = $this->CLASS['db']->fetch_assoc($res)) { $groupids[$row['groupid']] = $row['groupid']; } // now check the rights foreach($element as $key => $value) { // check if rights are for owner or for group if($value['owner_group'] == "o") { // check if id of element is id of user if($value['owner_group_id'] == $userid) { // rights are for this user // now set rights if they are not high enough if($value['rights'] > $rights) { // set new rights $rights = $value['rights']; } } } elseif($value['owner_group'] == "g") { // now we must run for every groupid for this user to check the rights foreach($groupids as $gkey => $gvalue) { // check if groupid is the same as the rightid if($gvalue == $value['owner_group_id']) { // now set rights if they are not high enough if($value['rights'] > $rights) { // set new rights $rights = $value['rights']; } } } } } return $rights; } /** * return dropdown for users * @param string $name name of dropdown * @param integer $userid optional userid that would be selected * @return string return html dropdown */ function userSelectDropDown($name, $userid = "") { $cache = array(); if(is_array($this->userdropdowncache)) { $cache = $this->userdropdowncache; } else { $res = $this->CLASS['db']->query("SELECT id,name FROM users WHERE deleted=0 ORDER BY name ASC"); while($row = $this->CLASS['db']->fetch_assoc($res)) { $cache[$row['id']] = $row['name']; } $this->userdropdowncache = $cache; } $users = "\n\n"; return $users; } /** * return dropdown for groups * @param string $name name of dropdown * @param integer $groupid optional groupid that would be selected * @return string return html dropdown */ function groupSelectDropDown($name, $groupid = "") { $cache = array(); if(is_array($this->groupdropdowncache)) { $cache = $this->groupdropdowncache; } else { $res = $this->CLASS['db']->query("SELECT id,name FROM groups WHERE deleted=0 ORDER BY name ASC"); while($row = $this->CLASS['db']->fetch_assoc($res)) { $cache[$row['id']] = $row['name']; } $this->groupdropdowncache = $cache; } $groups = "\n\n"; return $groups; } /** * save a form with multiple rights that are sended * @param string $table table name * @param integer $belongsto id of object * @param bool $deleteExisting should exisitings rights are deleted */ function saveMultipleRightsForm($table, $belongsto, $deleteExisting = false) { if (isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1) { // delete existing rights if($deleteExisting == true) $this->CLASS['knowledgeroot']->deleteMultipleRightsAll($table,$belongsto); if(isset($_POST['users']) && isset($_POST['muserrights']) && is_array($_POST['users']) && is_array($_POST['muserrights'])) { $rights = array(); foreach($_POST['users'] as $key => $value) { $rights[] = array( 'table_name' => $table, 'belongs_to' => $belongsto, 'owner_group' => 'o', 'owner_group_id' => $value, 'rights' => $_POST['muserrights'][$key], ); } $res = $this->CLASS['knowledgeroot']->saveMultipleRightsArr($rights); } if(isset($_POST['groups']) && isset($_POST['mgrouprights']) && is_array($_POST['groups']) && is_array($_POST['mgrouprights'])) { $rights = array(); foreach($_POST['groups'] as $key => $value) { $rights[] = array( 'table_name' => $table, 'belongs_to' => $belongsto, 'owner_group' => 'g', 'owner_group_id' => $value, 'rights' => $_POST['mgrouprights'][$key], ); } $res = $this->CLASS['knowledgeroot']->saveMultipleRightsArr($rights); } } } /** * save a form with multiple subinheritrights that are sended * @param string $table table name * @param integer $belongsto id of object * @param bool $deleteExisting should exisitings rights are deleted */ function saveSubinheritMultipleRightsForm($table, $belongsto, $deleteExisting = false) { if (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { // delete existing rights if($deleteExisting == true) $this->CLASS['knowledgeroot']->deleteMultipleRightsAll($table,$belongsto); if(isset($_POST['subinheritusers']) && isset($_POST['subinheritmuserrights']) && is_array($_POST['subinheritusers']) && is_array($_POST['subinheritmuserrights'])) { $rights = array(); foreach($_POST['subinheritusers'] as $key => $value) { $rights[] = array( 'table_name' => $table, 'belongs_to' => $belongsto, 'owner_group' => 'so', 'owner_group_id' => $value, 'rights' => $_POST['subinheritmuserrights'][$key], ); } $res = $this->CLASS['knowledgeroot']->saveMultipleRightsArr($rights); } if(isset($_POST['subinheritgroups']) && isset($_POST['subinheritmgrouprights']) && is_array($_POST['subinheritgroups']) && is_array($_POST['subinheritmgrouprights'])) { $rights = array(); foreach($_POST['subinheritgroups'] as $key => $value) { $rights[] = array( 'table_name' => $table, 'belongs_to' => $belongsto, 'owner_group' => 'sg', 'owner_group_id' => $value, 'rights' => $_POST['subinheritmgrouprights'][$key], ); } $res = $this->CLASS['knowledgeroot']->saveMultipleRightsArr($rights); } } } /** * get and save multiplerights from a page to another * @param string $table * @param integer $sourceId * @param integer $destinationId * @param bool $subinherit should also inherit subinheritrights? */ function saveInheritMultipleRightsFrom($table, $sourceId, $destinationId, $subinherit = false) { $sourceArr = array(); // get rights from source $res = $this->CLASS['db']->squery("SELECT * FROM access WHERE belongs_to=%d", $sourceId); while($row = $this->CLASS['db']->fetch_assoc($res)) { $sourceArr[] = $row; } // make addslashes $this->addSlashesOnArray($sourceArr); foreach($sourceArr as $key => $value) { if($subinherit == true) { if($value['owner_group'] == "so") { $res = $this->CLASS['db']->squery("INSERT INTO access (table_name, belongs_to, owner_group, owner_group_id, rights) VALUES ('%s', %d, '%s', %d, %d)", $table, $destinationId, "o", $value['owner_group_id'], $value['rights']); } elseif($value['owner_group'] == "sg") { $res = $this->CLASS['db']->squery("INSERT INTO access (table_name, belongs_to, owner_group, owner_group_id, rights) VALUES ('%s', %d, '%s', %d, %d)", $table, $destinationId, "g", $value['owner_group_id'], $value['rights']); } } else { if($value['owner_group'] == "o" || $value['owner_group'] == "g") { $res = $this->CLASS['db']->squery("INSERT INTO access (table_name, belongs_to, owner_group, owner_group_id, rights) VALUES ('%s', %d, '%s', %d, %d)", $table, $destinationId, $value['owner_group'], $value['owner_group_id'], $value['rights']); } } } } /** * get and save subinherit multiple rights from the inheritpage to another page * @param string $table * @param integer $sourceId * @param integer $destinationId * @param bool $subinherit should also inherit subinheritrights? */ function saveSubInheritMultipleRightsFrom($table, $sourceId, $destinationId, $subinherit = false) { $iRights = $this->getInheritRights($sourceId); if(is_array($iRights) && isset($iRights['id']) && $iRights['id'] != "") { return $this->saveInheritMultipleRightsFrom($table, $iRights['id'], $destinationId, $subinherit); } else { return $this->saveInheritMultipleRightsFrom($table, $sourceId, $destinationId, $subinherit); } } } ?> knowledgeroot-0.9.9.5/include/class-rte.php0000644000175000017500000000155110632070705021576 0ustar fhabermannfhabermannid != "") ? "id=\"".$this->id."\" ": "").(($this->name != "") ? "name=\"".$this->name."\" " : "")."rows=\"".$this->rows."\" cols=\"".$this->cols."\">\n"; $out .= $text; $out .= ""; return $out; } } ?> knowledgeroot-0.9.9.5/include/class-knowledgeroot-header.php0000644000175000017500000024367311273031440025125 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * will check all required vars and do right actions */ function check_vars() { $this->CLASS['hooks']->setHook("kr_header","check_vars","start"); //check if userid and groupid is set, if not set to 0 if ((!isset ($_SESSION['userid']) or $_SESSION['userid'] == '') || (!isset ($_SESSION['groupid']) or $_SESSION['groupid'] == '')) { $_SESSION['userid'] = 0; $_SESSION['groupid'] = 0; } // check for first run in this session and do expand all or not if ((!isset ($_SESSION['firstrun']) or $_SESSION['firstrun'] == 0) && $this->CLASS['vars']['menu']['expandall'] == 1) { $this->CLASS['vars']['menu']['doexpand'] = 1; } else { $this->CLASS['vars']['menu']['doexpand'] = 0; } // load default tree layout $this->loadDefaultTreeLayout(); // check if content should be shown directly $this->getIDFromContent(); // get id from alias $this->getIDFromAlias(); // if GET[id] not set use POST[id] if (isset ($_GET['id']) and $_GET['id'] != '') { $id = $_GET['id']; } else if (isset ($_POST['id']) and $_POST['id'] != '') { $id = $_POST['id']; } else { $id = ''; } // set siteid to session if($id != "") { $_SESSION['cid'] = $id; // check if page is available $res = $this->CLASS['db']->query(sprintf("SELECT count(id) as anz FROM tree WHERE id=%d",$_SESSION['cid'])); $row = $this->CLASS['db']->fetch_assoc($res); // if page is not available set to defaultpage if($row['anz'] == 0) { $id = $this->CLASS['vars']['knowledgeroot']['defaultpage']; $_SESSION['cid'] = $this->CLASS['vars']['knowledgeroot']['defaultpage']; } } else { if (!isset ($_SESSION['cid']) or $_SESSION['cid'] == '') { $id = $this->CLASS['vars']['knowledgeroot']['defaultpage']; $_SESSION['cid'] = $this->CLASS['vars']['knowledgeroot']['defaultpage']; } } // open current menu item if(isset($_SESSION['cid']) && $_SESSION['cid'] != "") { $_SESSION['open'][$_SESSION['cid']] = 1; } // do logout if (isset ($_GET['action']) and $_GET['action'] == "logout") { $this->logout(); } // check usersession $this->check_loged_in_userrights(); // do login if (isset ($_POST['login']) and $_POST['login'] != "") { $this->login(); } // save default tree layout if(isset($_GET['action']) && $_GET['action'] == "savedefaulttree") { $this->saveDefaultTreeLayout(); } // edit content? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['editid']) and $_POST['editid']) { $this->edit_content(); } // create new content? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['neditid']) and $_POST['neditid']) { $this->new_content(); } // create new page? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['newpage']) and $_POST['newpage']) { $this->new_page(); } // file upload? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['upload']) and $_POST['upload']) { $this->upload_file(); } // delete content? if (isset ($_GET['delid']) and $_GET['delid'] != "") { $this->delete_content(); } // delete page? if (isset ($_GET['delpage']) and $_GET['delpage'] != "") { $this->delete_page(); } // edit page? if (isset ($_POST['editpage']) and $_POST['editpage'] != "") { $this->edit_page(); } // delete file? if (isset ($_GET['delfile']) and $_GET['delfile'] != "") { $this->delete_file(); } // create root? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['action']) and $_POST['action'] == "createroot") { $this->create_root(); } // add user? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['action']) and $_POST['action'] == "adduser" && isset ($_POST['name']) and $_POST['name'] != "") { $this->add_user(); } // edit user? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['action']) and $_POST['action'] == "edituser" && isset ($_POST['name']) and $_POST['name'] != "") { $this->edit_user(); } // add group? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['action']) and $_POST['action'] == "addgroup" && isset ($_POST['name']) and $_POST['name'] != "") { $this->add_group(); } // edit group? if (isset ($_POST['submit']) and $_POST['submit'] && isset ($_POST['action']) and $_POST['action'] == "editgroup" && isset ($_POST['name']) and $_POST['name'] != "") { $this->edit_group(); } // delete user? if (isset ($_GET['action']) and $_GET['action'] == "deluser" && isset ($_GET['uid']) and $_GET['uid'] != "") { $this->delete_user(); } // delete group? if (isset ($_GET['action']) and $_GET['action'] == "delgroup" && isset ($_GET['gid']) and $_GET['gid'] != "") { $this->delete_group(); } // edit options? if (isset ($_POST['action']) and $_POST['action'] == "options") { $this->edit_options(); } // change language if (isset ($_POST['action']) and $_POST['action'] == "change_language") { $this->change_language(); } // move page? if (isset ($_POST['move']) and $_POST['move'] == "move" && isset ($_POST['to']) and $_POST['to'] != $_SESSION['cid']) { $this->move_page(); } // move content? if (isset ($_POST['move']) and $_POST['move'] == "cmove" && isset ($_POST['to']) and $_POST['to'] != $_SESSION['cid'] && isset ($_POST['contentid']) and $_POST['contentid'] != "") { $this->move_content(); } // will move content up on the page if (isset ($_GET['moveup']) and $_GET['moveup'] != "") { $this->move_content_up(); } // will move content down on the page if (isset ($_GET['movedown']) and $_GET['movedown'] != "") { $this->move_content_down(); } // open tree element? if (isset ($_GET['openid']) and $_GET['openid'] != "") { $this->open_tree_element(); } // create search if (isset($_POST['submit']) and $_POST['submit'] && isset ($_POST['search']) and $_POST['search'] != "") { $this->create_search(); } // add title to htmlheader $this->addtitle(); // set charset if($this->CLASS['vars']['knowledgeroot']['charset'] != "") { if($this->CLASS['vars']['knowledgeroot']['charset'] == "utf8") { $charset = "utf-8"; } else { $charset = $this->CLASS['vars']['knowledgeroot']['charset']; } $this->addheader(""); } $this->CLASS['hooks']->setHook("kr_header","check_vars","end"); return 0; } /** * */ function saveDefaultTreeLayout() { if(isset($_SESSION['admin']) && $_SESSION['admin'] == 1 && isset($this->CLASS['vars']['menu']['defaultlayout']) && $this->CLASS['vars']['menu']['defaultlayout'] == 1) { $layout = serialize($_SESSION['open']); $this->CLASS['db']->queryf("UPDATE settings SET value='%s' WHERE name='%s'", $layout, "menu.defaultlayoutarray"); } } /** * load default tree layout to session for new users */ function loadDefaultTreeLayout() { if(isset($this->CLASS['vars']['menu']['defaultlayout']) && $this->CLASS['vars']['menu']['defaultlayout'] == 1 && isset($this->CLASS['vars']['menu']['defaultlayoutarray']) && $this->CLASS['vars']['menu']['defaultlayoutarray'] != "" && (!isset($_SESSION['open']) || (isset($_SESSION['open']) && !is_array($_SESSION['open'])))) { $layout = @unserialize($this->CLASS['vars']['menu']['defaultlayoutarray']); if(is_array($layout)) { $_SESSION['open'] = $layout; $this->CLASS['vars']['menu']['doexpand'] = 0; $this->CLASS['vars']['menu']['expandall'] = 0; } } } /** * make login */ function login() { $this->CLASS['hooks']->setHook("kr_header","login","start"); if ($this->CLASS['auth']->login()) { // clean treecache unset($this->CLASS['tree']); $this->CLASS['tree'] = new categoryTree(); $this->CLASS['tree']->start($this->CLASS); $this->CLASS['hooks']->setHook("kr_header","login","success"); // do a reload for a new clean initialisation after logout header("Location: index.php?".session_name(). "=" .session_id()); exit(); } else { if ($this->CLASS['auth']->wartezeit) { $this->addwarning(str_replace('#RELOGINDELAY#', $this->CLASS['vars']['login']['delay'], T_('You can login after #RELOGINDELAY# seconds!'))); } else if ($this->CLASS['auth']->loginblock) { $this->addwarning(T_('This account is disabled!')); } else { // vermerke fehlgeschlagenen Loginversuch $this->CLASS['auth']->writeFalseLogin(); $this->addwarning(T_('You have entered the wrong user or password!')); } $_SESSION['user'] = "guest"; $_SESSION['password'] = "guest"; $this->CLASS['hooks']->setHook("kr_header","login","failed"); } return 0; } /** * destroy session and make clean logout */ function logout() { $this->CLASS['hooks']->setHook("kr_header","logout","start"); if(isset($_SESSION['open'])) $treecache = $_SESSION['open']; $_SESSION = array(); $_SESSION['user'] = "guest"; $_SESSION['password'] = "guest"; $_SESSION['md5hash'] = ""; $_SESSION['cid'] = ""; $_SESSION['userid'] = ""; $_SESSION['groupid'] = ""; $_SESSION['admin'] = "0"; //$_SESSION['theme'] = ""; if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } session_destroy(); // will not work perhaps session is destroyed if(isset($_SESSION['open'])) $_SESSION['open'] = $treecache; $this->CLASS['hooks']->setHook("kr_header","logout","end"); // do a reload for a new clean initialisation after logout header("Location: index.php"); exit(); return 0; } /** * check usersession * if session wrong give guest rights */ function check_loged_in_userrights() { if(!isset($_SESSION['user'])) $_SESSION['user'] = ""; if(!isset($_SESSION['password'])) $_SESSION['password'] = ""; if(!isset($_SESSION['md5hash'])) $_SESSION['md5hash'] = ""; if ($_SESSION['user'] != "guest" && $_SESSION['password'] != "guest" && $_SESSION['md5hash'] != md5($_SESSION['user'] . $_SESSION['password'])) { $_SESSION['user'] = "guest"; $_SESSION['password'] = "guest"; $_SESSION['md5hash'] = ""; $_SESSION['admin'] = "0"; } return 0; } /** * download files from knowledgeroot */ function check_download() { if(preg_match("/download\/([0-9]+)\/.*/",$this->getIndpEnv("TYPO3_SITE_SCRIPT"),$found)) { if($_SERVER["REQUEST_METHOD"] == "GET") { $_GET['download'] = $found[1]; } } if (isset ($_GET['download']) and $_GET['download'] != "") { $this->CLASS['hooks']->setHook("kr_header","check_download","start"); $rs = $this->CLASS['db']->query(sprintf("select f.*, c.belongs_to as cid, f.counter as counter from files f, content c where f.belongs_to = c.id AND f.deleted=0 AND f.id =%d",$_GET['download'])); $anz = $this->CLASS['db']->num_rows($rs); if($anz != 1) { $this->CLASS['error']->log(T_("WRONG DOWNLOADFILE!")); exit(); } $row = $this->CLASS['db']->fetch_assoc($rs); if($this->CLASS['knowledgeroot']->checkRecursivPerm($row['cid'], $_SESSION['userid']) == 0) { $this->CLASS['error']->log(T_("No File for you!")); exit(); } $row['counter']++; $res = $this->CLASS['db']->query(sprintf("UPDATE files SET counter=%d WHERE id=%d", $row['counter'], $_GET['download'])); $filename = $row['filename']; header("Content-Type: " . $row['filetype'] . "; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\";"); header("Pragma: private"); header("Expires: 0"); header("Cache-Control: private, must-revalidate, post-check=0, pre-check=0"); header("Content-Transfer-Encoding: binary"); if($this->CLASS['db']->dbtype == "pgsql") { $this->CLASS['db']->query ("begin"); $loid = $this->CLASS['db']->lo_open($row['object'], "r"); $this->CLASS['db']->lo_read_all ($loid); $this->CLASS['db']->lo_close ($loid); $this->CLASS['db']->query ("commit"); $this->CLASS['db']->close(); } if($this->CLASS['db']->dbtype == "mysql" || $this->CLASS['db']->dbtype == "mysqli") { // check for new upload method that uses base64 if(substr($row['file'],0,7) == 'base64:') { echo base64_decode(substr($row['file'],7)); } else { echo unserialize($row['file']); } } if($this->CLASS['db']->dbtype == "sqlite") { echo base64_decode($row['file']); } $this->CLASS['hooks']->setHook("kr_header","check_download","end"); exit(); } } /** * this will edit a content */ function edit_content() { if ($this->CLASS['knowledgeroot']->checkRecursivPerm($_SESSION['cid'],$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getContentRights($_POST['editid'],$_SESSION['userid']) == 2) { if (!isset ($_POST['close']) or $_POST['close'] == '') { $this->CLASS['hooks']->setHook("kr_header","edit_content","start"); // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } if ((isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) || (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1)) { // change content record $res = $this->CLASS['db']->query(sprintf("UPDATE content SET content='%s', title='%s', owner=%d, lastupdatedby=%d, lastupdated=".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", ".$this->CLASS['db']->quoteIdentifier("group")."=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$_POST['content'],$_POST['title'],$_POST['user'],$_SESSION['userid'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'],$_POST['editid'])); } else { $res = $this->CLASS['db']->query(sprintf("UPDATE content SET content='%s', title='%s', lastupdatedby=%d, lastupdated=".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") ." WHERE id=%d",$_POST['content'],$_POST['title'],$_SESSION['userid'],$_POST['editid'])); } // is content closed or should be shown again if (isset ($_POST['save']) and $_POST['save'] != "") { $_GET['eid'] = $_POST['editid']; } else { // close content $this->CLASS['knowledgeroot']->closeOpenContent($_POST['editid'],$_SESSION['userid']); } // save multiple rights if ((isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) || (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1)) { $this->CLASS['knowledgeroot']->saveMultipleRightsForm("content", $_POST['editid'], true); } $pagename = $this->CLASS['path']->getTreePageTitle($_SESSION['cid']); // email notification $this->CLASS['notification']->send_email_notification($_SESSION['cid'],"content","edited",$pagename,$_POST['editid']); $this->CLASS['hooks']->setHook("kr_header","edit_content","end"); } else { // close content $this->CLASS['knowledgeroot']->closeOpenContent($_POST['editid'],$_SESSION['userid']); } } } /** * this will create a new content */ function new_content() { if ($this->CLASS['knowledgeroot']->checkRecursivPerm($_POST['belongsto'],$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getPageRights($_POST['belongsto'],$_SESSION['userid']) == 2) { if (!isset ($_POST['close']) or $_POST['close'] == '') { $this->CLASS['hooks']->setHook("kr-header","new_content","start"); // get next sorting value $res = $this->CLASS['db']->query(sprintf("SELECT max(sorting) as sorting FROM content WHERE belongs_to=%d",$_POST['belongsto'])); $sort = $this->CLASS['db']->fetch_assoc($res); $sorting = $sort['sorting'] + 1; // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } if (isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, title, lastupdatedby, lastupdated, owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, ".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$_POST['content'],$_POST['title'],$_SESSION['userid'],$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); $contentid = $this->CLASS['db']->last_id("seq_knowledge"); } else { if(!empty($_SESSION['userid'])) { if(is_array($inheritrights) && $inheritrights['subinheritrights'] == 1) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, title, lastupdatedby, lastupdated, owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, ".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$_POST['content'],$_POST['title'],$_SESSION['userid'],$inheritrights['subinheritowner'],$inheritrights['subinheritgroup'],$inheritrights['subinherituserrights'],$inheritrights['subinheritgrouprights'],$inheritrights['subinheritotherrights'])); $contentid = $this->CLASS['db']->last_id("seq_knowledge"); $this->CLASS['knowledgeroot']->saveSubInheritMultipleRightsFrom("content", $_POST['belongsto'], $contentid, true); } else { // user logged in but have no rightedit -> use defaultrights $res = $this->CLASS['db']->query(sprintf("SELECT id,defaultgroup,defaultrights FROM users WHERE id=%s",$_SESSION['userid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, title, lastupdatedby, lastupdated, owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, ".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$_POST['content'],$_POST['title'],$_SESSION['userid'],$row['id'],$row['defaultgroup'],substr($row['defaultrights'],0,1),substr($row['defaultrights'],1,1),substr($row['defaultrights'],2,1))); $contentid = $this->CLASS['db']->last_id("seq_knowledge"); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, title, lastupdatedby, lastupdated, owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, ".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", 0, 0, 2, 2, 2)",$_POST['belongsto'],$sorting,$_POST['content'],$_POST['title'],$_SESSION['userid'])); $contentid = $this->CLASS['db']->last_id("seq_knowledge"); } } } else { // no user logged in if(is_array($inheritrights) && $inheritrights['subinheritrights'] == 1) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, title, lastupdatedby, lastupdated, owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, ".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", %d, %d, %d, %d, %d)",$_POST['belongsto'],$sorting,$_POST['content'],$_POST['title'],$_SESSION['userid'],$inheritrights['subinheritowner'],$inheritrights['subinheritgroup'],$inheritrights['subinherituserrights'],$inheritrights['subinheritgrouprights'],$inheritrights['subinheritotherrights'])); $contentid = $this->CLASS['db']->last_id("seq_knowledge"); $this->CLASS['knowledgeroot']->saveSubInheritMultipleRightsFrom("content", $_POST['belongsto'], $contentid, true); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO content (belongs_to, sorting, content, title, lastupdatedby, lastupdated, owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES(%d, %d, '%s', '%s', %d, ".(($this->CLASS['db']->dbtype == "sqlite") ? "date('now')" : "NOW()") .", 0, 0, 2, 2, 2)",$_POST['belongsto'],$sorting,$_POST['content'],$_POST['title'],$_SESSION['userid'])); $contentid = $this->CLASS['db']->last_id("seq_knowledge"); $this->CLASS['knowledgeroot']->saveInheritMultipleRightsFrom("content", $_POST['belongsto'], $contentid); } } } //$contentid = $this->CLASS['db']->last_id("seq_knowledge"); if (isset ($_POST['save']) and $_POST['save'] != "") { $_GET['eid'] = $contentid; } else { $_GET['eid'] = ''; } // save multiple rights if (isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) { $this->CLASS['knowledgeroot']->saveMultipleRightsForm("content", $contentid); } $pagename = $this->CLASS['path']->getTreePageTitle($_POST['belongsto']); // email notification $this->CLASS['notification']->send_email_notification($_POST['belongsto'],"content","created",$pagename, $_GET['eid']); $this->CLASS['hooks']->setHook("kr-header","new_content","end"); } } } /** * this will create a new page */ function new_page() { if($this->CLASS['knowledgeroot']->checkRecursivPerm($_POST['belongsto'],$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getPageRights($_POST['belongsto'],$_SESSION['userid']) == 2 && $_POST['title'] != "") { $this->CLASS['hooks']->setHook("kr_header","new_page","start"); // check if alias already exists if (isset ($_POST['alias']) && $_POST['alias'] != "") { $_POST['alias'] = $this->CLASS['knowledgeroot']->checkAlias($_POST['alias']); } // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } // set tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1 && isset($_POST['tooltip']) && $_POST['tooltip'] != "") { $tooltip = $_POST['tooltip']; } else { $tooltip = ""; } if (isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,alias,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['alias'],$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); } $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } else { if(!empty($_SESSION['userid'])) { // user logged in but have no rightedit -> use defaultrights if(is_array($inheritrights) && $inheritrights['subinheritrights'] == 1) { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,alias,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['alias'],$inheritrights['subinheritowner'],$inheritrights['subinheritgroup'],$inheritrights['subinherituserrights'],$inheritrights['subinheritgrouprights'],$inheritrights['subinheritotherrights'])); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$inheritrights['subinheritowner'],$inheritrights['subinheritgroup'],$inheritrights['subinherituserrights'],$inheritrights['subinheritgrouprights'],$inheritrights['subinheritotherrights'])); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } $this->CLASS['knowledgeroot']->saveSubInheritMultipleRightsFrom("tree", $_POST['belongsto'], $new_page_id, true); } else { $res = $this->CLASS['db']->query(sprintf("SELECT id,defaultgroup,defaultrights FROM users WHERE id=%d",$_SESSION['userid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,alias,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['alias'],$row['id'],$row['defaultgroup'],substr($row['defaultrights'],0,1),substr($row['defaultrights'],1,1),substr($row['defaultrights'],2,1))); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$row['id'],$row['defaultgroup'],substr($row['defaultrights'],0,1),substr($row['defaultrights'],1,1),substr($row['defaultrights'],2,1))); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } } else { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,alias,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', '%s', 0, 0, 2, 2, 2)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['alias'])); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', 0, 0, 2, 2, 2)",$_POST['belongsto'],$_POST['title'], $tooltip)); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } } } } else { // no user logged in if(is_array($inheritrights) && $inheritrights['subinheritrights'] == 1) { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,alias,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['alias'],$inheritrights['subinheritowner'],$inheritrights['subinheritgroup'],$inheritrights['subinherituserrights'],$inheritrights['subinheritgrouprights'],$inheritrights['subinheritotherrights'])); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', %d, %d, %d, %d, %d)",$_POST['belongsto'],$_POST['title'],$tooltip,$inheritrights['subinheritowner'],$inheritrights['subinheritgroup'],$inheritrights['subinherituserrights'],$inheritrights['subinheritgrouprights'],$inheritrights['subinheritotherrights'])); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } $this->CLASS['knowledgeroot']->saveSubInheritMultipleRightsFrom("tree", $_POST['belongsto'], $new_page_id, true); } else { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,alias,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', '%s', 0, 0, 2, 2, 2)",$_POST['belongsto'],$_POST['title'],$tooltip,$_POST['alias'])); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to,title,tooltip,owner,".$this->CLASS['db']->quoteIdentifier("group").",userrights,grouprights,otherrights) VALUES (%d,'%s', '%s', 0, 0, 2, 2, 2)",$_POST['belongsto'],$_POST['title'],$tooltip)); $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); } $this->CLASS['knowledgeroot']->saveInheritMultipleRightsFrom("tree", $_POST['belongsto'], $new_page_id); } } } // get pageid of the created page //$new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); // check for subinheritsrights if(isset ($_SESSION['admin']) && $_SESSION['admin'] == 1 && ((isset($_POST['subinheritrights']) && $_POST['subinheritrights'] == 1) || (isset($_POST['subinheritrightsdisable']) && $_POST['subinheritrightsdisable'] == 1))) { if(!isset($_POST['subinheritrightseditable']) || $_POST['subinheritrightseditable'] != 1) { $_POST['subinheritrightseditable'] = 0; } if(!isset($_POST['subinheritrights']) || $_POST['subinheritrights'] != 1) { $_POST['subinheritrights'] = 0; } if(!isset($_POST['subinheritrightsdisable']) || $_POST['subinheritrightsdisable'] != 1) { $_POST['subinheritrightsdisable'] = 0; } $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET subinheritrights=%d, subinheritrightseditable=%d, subinheritrightsdisable=%d, subinheritowner=%d, subinheritgroup=%d, subinherituserrights=%d, subinheritgrouprights=%d, subinheritotherrights=%d WHERE id=%d",$_POST['subinheritrights'],$_POST['subinheritrightseditable'],$_POST['subinheritrightsdisable'],$_POST['subinherituser'],$_POST['subinheritgroup'],$_POST['subinherituserrights'],$_POST['subinheritgrouprights'],$_POST['subinheritotherrights'],$new_page_id)); // save multiple subinheritrights $this->CLASS['knowledgeroot']->saveSubinheritMultipleRightsForm("tree", $new_page_id); } // save multiple rights if ((isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) || (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1)) { $this->CLASS['knowledgeroot']->saveMultipleRightsForm("tree", $new_page_id); } // email notification $this->CLASS['notification']->send_email_notification($new_page_id,"page","created",$_POST['title'],$new_page_id); $_SESSION['open'][$_POST['belongsto']] = 1; // simply redirect if the user select "automatically open the created page" if (isset($_POST['auto_open']) && $_POST['auto_open'] == "true") { $_SESSION['auto_open'] = true; header("Location: index.php?id=$new_page_id"); exit(); } else { $_SESSION['auto_open'] = false; } $this->CLASS['hooks']->setHook("kr_header","new_page","end"); } } /** * make file upload */ function upload_file() { // check size of file if(isset($this->CLASS['vars']['knowledgeroot']['maxfilesize']) && $this->CLASS['vars']['knowledgeroot']['maxfilesize'] != "" && $_FILES['datei']['size'] > $this->CLASS['vars']['knowledgeroot']['maxfilesize']) { $this->addwarning(T_('Cannot add file. File is to big!')); return ""; } if($this->CLASS['knowledgeroot']->getContentRights($_POST['contentid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","upload_file","start"); $uploaddir = $this->CLASS['vars']['knowledgeroot']['uploadfolder']; if(!is_dir($uploaddir)) { $this->addwarning(T_('No upload folder found!')); return 0; } if($_FILES['datei']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['datei']['tmp_name']) && is_file($_FILES['datei']['tmp_name'])) { $fp = fopen($_FILES['datei']['tmp_name'],"r"); $buffer = fread($fp,filesize($_FILES['datei']['tmp_name'])); fclose($fp); //import for postgresql if($this->CLASS['db']->dbtype == "pgsql") { $this->CLASS['db']->query ("begin"); $oid = $this->CLASS['db']->lo_create (); $rs = $this->CLASS['db']->query(sprintf("insert into files (belongs_to,object,filename,filesize,filetype,owner) values(%d, %d,'%s', %d, '%s',%d)",$_POST['contentid'],$oid,addslashes($_FILES['datei']['name']),$_FILES['datei']['size'],addslashes($_FILES['datei']['type']),$_SESSION['userid']));//object field type must be "oid" $handle = $this->CLASS['db']->lo_open ($oid, "w"); $this->CLASS['db']->lo_write ($handle, $buffer); $this->CLASS['db']->lo_close ($handle); $this->CLASS['db']->query ("commit"); } //import for mysql if($this->CLASS['db']->dbtype == "mysql" || $this->CLASS['db']->dbtype == "mysqli") { $res = $this->CLASS['db']->query(sprintf("INSERT INTO files(belongs_to,file,filename,filesize,filetype,owner) VALUES (%d,'%s','%s', %d,'%s',%d)",$_POST['contentid'],'base64:'.base64_encode($buffer),addslashes($_FILES['datei']['name']),$_FILES['datei']['size'],addslashes($_FILES['datei']['type']),$_SESSION['userid'])); } //import for sqlite if($this->CLASS['db']->dbtype == "sqlite") { $res = $this->CLASS['db']->query(sprintf("INSERT INTO files(belongs_to,file,filename,filesize,filetype,owner,date) VALUES (%d,'%s','%s', %d,'%s',%d,'%s')",$_POST['contentid'],base64_encode($buffer),addslashes($_FILES['datei']['name']),$_FILES['datei']['size'],addslashes($_FILES['datei']['type']),$_SESSION['userid'],date('Y-m-d H:i:s', time()))); } // email notification $this->CLASS['notification']->send_email_notification($_SESSION['cid'],"file","created",addslashes($_FILES['datei']['name'])); unlink($_FILES['datei']['tmp_name']); // should be translated in the future //$this->addwarning($this->CLASS['language']->get['fileuploadsuccess']); $this->CLASS['hooks']->setHook("kr_header","upload_file","uploaded"); } else { // should be translated in the future //$this->addwarning($this->CLASS['language']->get['fileuploaderror']); } $this->CLASS['hooks']->setHook("kr_header","upload_file","end"); } } /** * delete content */ function delete_content() { // delete the content $this->_delete_content($_SESSION['cid'], $_GET['delid']); } /** * delete content element * for internal use * @param integer $contentid */ function _delete_content($pageid, $contentid) { if($this->CLASS['knowledgeroot']->checkRecursivPerm($pageid,$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getContentRights($contentid,$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","delete_content","start"); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET deleted=1 WHERE id=%d",$contentid)); $res = $this->CLASS['db']->query(sprintf("UPDATE files SET deleted=1 WHERE belongs_to=%d",$contentid)); // get id of page $res = $this->CLASS['db']->query(sprintf("SELECT belongs_to FROM content WHERE id=%d",$contentid)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $pagename = $this->CLASS['path']->getTreePageTitle($row['belongs_to']); $id = $row['belongs_to']; } else { $pagename = $this->CLASS['path']->getTreePageTitle($pageid); $id = $pageid; } // email notification $this->CLASS['notification']->send_email_notification($id,"content","deleted",$pagename,$contentid); $this->CLASS['hooks']->setHook("kr_header","delete_content","end"); } } /** * delete page */ function delete_page() { // make delete of page $this->_delete_page($_GET['delpage']); } /** * make a delete of a page * will also check for recursiv deletion * for internal use * @param integer $pageid */ function _delete_page($pageid) { if($this->CLASS['knowledgeroot']->checkRecursivPerm($pageid,$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getPageRights($pageid,$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","delete_page","start"); // check for recusriv delete if(($this->CLASS['vars']['knowledgeroot']['recursivdelete'] == 2 && $_SESSION['admin'] == 1) || ($this->CLASS['vars']['knowledgeroot']['recursivdelete'] == 1 && !empty($userid)) || ($this->CLASS['vars']['knowledgeroot']['recursivdelete'] == 0)) { // get all subpages for delete $res = $this->CLASS['db']->query(sprintf("SELECT id FROM tree WHERE belongs_to=%d and deleted=0",$pageid)); while($row = $this->CLASS['db']->fetch_assoc($res)) { $this->_delete_page($row['id']); } // get all contents for delete $res = $this->CLASS['db']->query(sprintf("SELECT id FROM content WHERE belongs_to=%d and deleted=0",$pageid)); while($row = $this->CLASS['db']->fetch_assoc($res)) { $this->_delete_content($pageid, $row['id']); } } $res = $this->CLASS['db']->query(sprintf("SELECT count(*) AS anz FROM content WHERE belongs_to=%d and deleted=0",$pageid)); $row = $this->CLASS['db']->fetch_object($res); $anz = $row->anz; $res = $this->CLASS['db']->query(sprintf("SELECT count(*) AS anz FROM tree WHERE belongs_to=%d and deleted=0",$pageid)); $row = $this->CLASS['db']->fetch_object($res); $anz = $anz + $row->anz; if($anz == "0") { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET deleted=1 WHERE id=%d",$pageid)); $_SESSION['cid'] = $this->CLASS['path']->getParent($pageid); $pagename = $this->CLASS['path']->getTreePageTitle($pageid); $res = $this->CLASS['db']->query(sprintf("SELECT belongs_to FROM tree WHERE id=%d",$pageid)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $id = $row['belongs_to']; } else { $id = $pageid; } // email notification $this->CLASS['notification']->send_email_notification($pageid,"page","deleted",$pagename,$pageid); $this->CLASS['hooks']->setHook("kr_header","delete_page","success"); } else { $this->addwarning(T_('Cannot delete page. Check if content is on the page!')); $this->CLASS['hooks']->setHook("kr_header","delete_page","failed"); } $this->CLASS['hooks']->setHook("kr_header","delete_page","end"); } } /** * edit page */ function edit_page() { if($this->CLASS['knowledgeroot']->checkRecursivPerm($_SESSION['cid'],$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2 && $_POST['title'] != "") { $this->CLASS['hooks']->setHook("kr_header","edit_page","start"); // check if alias is already used $res = $this->CLASS['db']->query(sprintf("SELECT alias FROM tree WHERE id=%d",$_SESSION['cid'])); $anz = $this->CLASS['db']->num_rows($res); if (!isset ($_POST['contentcollapsed']) or $_POST['contentcollapsed'] == "") { $collapsed = 0; } else { $collapsed = 1; } if (!isset ($_POST['alias'])) { $_POST['alias'] = ''; } if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); if ($row['alias'] != $_POST['alias'] && $_POST['alias'] != "") { $_POST['alias'] = $this->CLASS['knowledgeroot']->checkAlias($_POST['alias']); } } else { if($_POST['alias'] != "") { $_POST['alias'] = $this->CLASS['knowledgeroot']->checkAlias($_POST['alias']); } } // set tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1 && isset($_POST['tooltip']) && $_POST['tooltip'] != "") { $tooltip = $_POST['tooltip']; } else { $tooltip = ""; } // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } if ((isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) || (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1)) { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET title='%s', tooltip='%s', contentcollapsed=%d, alias='%s', owner=%d, ".$this->CLASS['db']->quoteIdentifier("group")."=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$_POST['title'],$tooltip,$collapsed,$_POST['alias'],$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'],$_SESSION['cid'])); } else { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET title='%s', tooltip='%s', contentcollapsed=%d, owner=%d, ".$this->CLASS['db']->quoteIdentifier("group")."=%d, userrights=%d, grouprights=%d, otherrights=%d WHERE id=%d",$_POST['title'],$tooltip,$collapsed,$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'],$_SESSION['cid'])); } } else { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET title='%s', tooltip='%s', contentcollapsed=%d, alias='%s' WHERE id=%d",$_POST['title'],$tooltip,$collapsed,$_POST['alias'],$_SESSION['cid'])); } else { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET title='%s', tooltip='%s', contentcollapsed=%d WHERE id=%d",$_POST['title'],$tooltip,$collapsed,$_SESSION['cid'])); } } // used var for check if multiple rights in table access are already deleted $deleted = false; // check for subinheritsrights if(isset ($_SESSION['admin']) && $_SESSION['admin'] == 1) { if(!isset($_POST['subinheritrightseditable']) || $_POST['subinheritrightseditable'] != 1) { $_POST['subinheritrightseditable'] = 0; } if(!isset($_POST['subinheritrights']) || $_POST['subinheritrights'] != 1) { $_POST['subinheritrights'] = 0; } if(!isset($_POST['subinheritrightsdisable']) || $_POST['subinheritrightsdisable'] != 1) { $_POST['subinheritrightsdisable'] = 0; } $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET subinheritrights=%d, subinheritrightseditable=%d, subinheritrightsdisable=%d, subinheritowner=%d, subinheritgroup=%d, subinherituserrights=%d, subinheritgrouprights=%d, subinheritotherrights=%d WHERE id=%d",$_POST['subinheritrights'],$_POST['subinheritrightseditable'],$_POST['subinheritrightsdisable'],$_POST['subinherituser'],$_POST['subinheritgroup'],$_POST['subinherituserrights'],$_POST['subinheritgrouprights'],$_POST['subinheritotherrights'],$_SESSION['cid'])); // save multiple subinheritrights $this->CLASS['knowledgeroot']->saveSubinheritMultipleRightsForm("tree", $_SESSION['cid'], true); $deleted = true; } // save multiple rights if ((isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) || (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1)) { $this->CLASS['knowledgeroot']->saveMultipleRightsForm("tree", $_SESSION['cid'], (($deleted == true) ? false : true)); } // set rights recursiv if (((isset ($_SESSION['rightedit']) and $_SESSION['rightedit'] == 1 && $show_rights == 1) || (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1)) && $_POST['recursiv'] == 1) { $this->CLASS['knowledgeroot']->setRightsRecursiv($_SESSION['cid'],$_SESSION['userid'],$_POST['user'],$_POST['group'],$_POST['userrights'].$_POST['grouprights'].$_POST['otherrights']); } $pagename = $this->CLASS['path']->getTreePageTitle($_SESSION['cid']); // email notification $this->CLASS['notification']->send_email_notification($_SESSION['cid'],"page","edited",$pagename,$_SESSION['cid']); $this->CLASS['hooks']->setHook("kr_header","edit_page","end"); } } /** * delete file */ function delete_file() { $res = $this->CLASS['db']->query(sprintf("SELECT belongs_to FROM files WHERE id=%d AND deleted=0",$_GET['delfile'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $belongs_to = $row['belongs_to']; if($this->CLASS['knowledgeroot']->checkRecursivPerm($_SESSION['cid'],$_SESSION['userid']) > 0 && $this->CLASS['knowledgeroot']->getContentRights($belongs_to,$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","delete_file","start"); if($this->CLASS['db']->dbtype == "pgsql") { $res = $this->CLASS['db']->query(sprintf("SELECT object FROM files WHERE id=%d",$_GET['delfile'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $this->CLASS['db']->lo_unlink($row['object']); } } //$res = $this->CLASS['db']->query("DELETE FROM files WHERE id='".$_GET['delfile']."'"); $res = $this->CLASS['db']->query(sprintf("UPDATE files SET deleted=1 WHERE id=%d",$_GET['delfile'])); // get filename $res = $this->CLASS['db']->query(sprintf("SELECT filename FROM files WHERE id=%d",$_GET['delfile'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); } // email notification $this->CLASS['notification']->send_email_notification($_SESSION['cid'],"file","deleted",$row['filename'],$_GET['delfile']); $this->CLASS['hooks']->setHook("kr_header","delete_file","end"); } } } /** * create root */ function create_root() { // rechte checken -> adminrechte if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","create_root","start"); // check if alias already exists if(isset($_POST['alias']) && $_POST['alias'] != "") { $_POST['alias'] = $this->CLASS['knowledgeroot']->checkAlias($_POST['alias']); } if($_POST['title'] == "") { $this->addwarning(T_('name for root cannot be empty')); } else { if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { $val = array( "belongs_to" => array( "value" => 0, "type" => "integer", ), "title" => array( "value" => $_POST['title'], "type" => "string", ), "alias" => array( "value" => $_POST['alias'], "type" => "string", ), "owner" => array( "value" => $_POST['user'], "type" => "integer", ), "group" => array( "value" => $_POST['group'], "type" => "integer", ), "userrights" => array( "value" => $_POST['userrights'], "type" => "integer", ), "grouprights" => array( "value" => $_POST['grouprights'], "type" => "integer", ), "otherrights" => array( "value" => $_POST['otherrights'], "type" => "integer", ), ); // check for tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1 && isset($_POST['tooltip']) && $_POST['tooltip'] != "") { $val['tooltip'] = array( "value" => $_POST['tooltip'], "type" => "string", ); } $res = $this->CLASS['db']->db_insert("tree",$val); //$res = $this->CLASS['db']->query("INSERT INTO tree (belongs_to, title, alias, owner, \"group\", userrights, grouprights, otherrights) VALUES (0, '".$_POST['title']."', '".$_POST['alias']."', '".$_POST['user']."', '".$_POST['group']."', '".$_POST['userrights']."', '".$_POST['grouprights']."', '".$_POST['otherrights']."')"); } else { // check for tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1 && isset($_POST['tooltip']) && $_POST['tooltip'] != "") { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to, title, tooltip, owner, ".$this->CLASS['db']->quoteIdentifier("group").", userrights, grouprights, otherrights) VALUES (0, '%s', '%s', %d, %d, %d, %d, %d)",$_POST['title'],$_POST['tooltip'],$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); } else { $res = $this->CLASS['db']->query(sprintf("INSERT INTO tree (belongs_to, title, owner, ".$this->CLASS['db']->quoteIdentifier("group").", userrights, grouprights, otherrights) VALUES (0, '%s', %d, %d, %d, %d, %d)",$_POST['title'],$_POST['user'],$_POST['group'],$_POST['userrights'],$_POST['grouprights'],$_POST['otherrights'])); } } // get pageid of the created page $new_page_id = $this->CLASS['db']->last_id("seq_knowledge"); // check for subinheritsrights if(isset($_POST['subinheritrights']) && $_POST['subinheritrights'] == 1) { if(!isset($_POST['subinheritrightseditable']) || $_POST['subinheritrightseditable'] != 1) { $_POST['subinheritrightseditable'] = 0; } $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET subinheritrights=%d, subinheritrightseditable=%d, subinheritowner=%d, subinheritgroup=%d, subinherituserrights=%d, subinheritgrouprights=%d, subinheritotherrights=%d WHERE id=%d",$_POST['subinheritrights'],$_POST['subinheritrightseditable'],$_POST['subinherituser'],$_POST['subinheritgroup'],$_POST['subinherituserrights'],$_POST['subinheritgrouprights'],$_POST['subinheritotherrights'],$new_page_id)); // save multiple subinheritrights $this->CLASS['knowledgeroot']->saveSubinheritMultipleRightsForm("tree", $new_page_id); } // save multiple rights $this->CLASS['knowledgeroot']->saveMultipleRightsForm("tree", $new_page_id); // email notification $this->CLASS['notification']->send_email_notification($this->CLASS['db']->last_id("seq_knowledge"),"page","created",$_POST['title'],$new_page_id); $this->CLASS['hooks']->setHook("kr_header","create_root","success"); } $this->CLASS['hooks']->setHook("kr_header","create_root","end"); } } /** * add user */ function add_user() { if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","add_user","start"); $res = $this->CLASS['db']->query(sprintf("INSERT INTO users (name, password, theme, enabled, defaultgroup, defaultrights, admin, rightedit, treecache) VALUES ('%s','%s','%s', %d, %d, '%d', %d, %d, '')",$_POST['name'],md5($_POST['password']),$_POST['theme'],$_POST['enabled'],$_POST['defaultgroup'],$_POST['userrights'].$_POST['grouprights'].$_POST['otherrights'],$_POST['admin'],$_POST['rightedit'])); $res = $this->CLASS['db']->query(sprintf("SELECT id FROM users WHERE name='%s'",$_POST['name'])); while($row = $this->CLASS['db']->fetch_assoc($res)) { if (isset ($_POST['groups']) and is_array($_POST['groups'])) { foreach ($_POST['groups'] as $key => $value) { $ressub = $this->CLASS['db']->query(sprintf("INSERT INTO user_group (userid, groupid) VALUES (%d,%d)",$row['id'],$value)); } } } $_GET['action'] = "users"; $this->CLASS['hooks']->setHook("kr_header","add_user","end"); } } /** * edit user */ function edit_user() { if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","edit_user","start"); //print_r($_POST['groups']); if($_POST['password'] == "") { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET name='%s', theme='%s', enabled=%d, defaultgroup=%d, defaultrights='%d', admin=%d, rightedit=%d WHERE id=%d",$_POST['name'],$_POST['theme'],$_POST['enabled'],$_POST['defaultgroup'],$_POST['userrights'].$_POST['grouprights'].$_POST['otherrights'],$_POST['admin'],$_POST['rightedit'],$_POST['uid'])); } else { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET name='%s', theme='%s', password='%s', enabled=%d, defaultgroup=%d, defaultrights='%d', admin=%d, rightedit=%d WHERE id=%d",$_POST['name'],$_POST['theme'],md5($_POST['password']),$_POST['enabled'],$_POST['defaultgroup'],$_POST['userrights'].$_POST['grouprights'].$_POST['otherrights'],$_POST['admin'],$_POST['rightedit'],$_POST['uid'])); } if(!isset($_POST['groups']) || !is_array($_POST['groups'])) { $_POST['groups'] = array(); } $res = $this->CLASS['db']->query(sprintf("DELETE FROM user_group WHERE userid=%d",$_POST['uid'])); foreach($_POST['groups'] as $key => $value) { $res = $this->CLASS['db']->query(sprintf("INSERT INTO user_group (userid, groupid) VALUES (%d, %d)",$_POST['uid'],$value)); } $_GET['action'] = "users"; $this->CLASS['hooks']->setHook("kr_header","edit_user","end"); } } /** * add group */ function add_group() { if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","add_group","start"); $res = $this->CLASS['db']->query(sprintf("INSERT INTO groups (name,enabled) VALUES ('%s', 1)",$_POST['name'])); $_GET['action'] = "users"; $this->CLASS['hooks']->setHook("kr_header","add_group","end"); } } /** * edit group */ function edit_group() { if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","edit_group","start"); $res = $this->CLASS['db']->query(sprintf("UPDATE groups SET name='%s' WHERE id=%d",$_POST['name'],$_POST['gid'])); $_GET['action'] = "users"; $this->CLASS['hooks']->setHook("kr_header","edit_group","end"); } } /** * delete user */ function delete_user() { if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","delete_user","start"); $res = $this->CLASS['db']->query(sprintf("DELETE FROM users WHERE id =%d",$_GET['uid'])); $res = $this->CLASS['db']->query(sprintf("DELETE FROM user_group WHERE userid =%d",$_GET['uid'])); $this->addmessage(T_('User was deleted!')); $_GET['action'] = "users"; $this->CLASS['hooks']->setHook("kr_header","delete_user","end"); } } /** * delete group */ function delete_group() { if($_SESSION['admin'] == 1) { $this->CLASS['hooks']->setHook("kr_header","delete_group","start"); // check only in user table for defaultgroup - if a user use this group as defaultgroup then delete fail $res = $this->CLASS['db']->query(sprintf("SELECT id FROM users WHERE defaultgroup=%d",$_GET['gid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 0) { $res = $this->CLASS['db']->query(sprintf("DELETE FROM groups WHERE id =%d",$_GET['gid'])); $res = $this->CLASS['db']->query(sprintf("DELETE FROM user_group WHERE groupid =%d",$_GET['gid'])); $this->addmessage(T_('Group was deleted!')); $this->CLASS['hooks']->setHook("kr_header","delete_group","success"); } else { $this->addwarning(T_('Could not delete group. Group is in use as defaultgroup!')); $this->CLASS['hooks']->setHook("kr_header","delete_group","fail"); } $_GET['action'] = "users"; $this->CLASS['hooks']->setHook("kr_header","delete_group","end"); } } /** * edit options */ function edit_options() { $this->CLASS['hooks']->setHook("kr_header","edit_options","start"); if($_POST['language'] != $_SESSION['language']) { $_SESSION['language'] = $_POST['language']; // PHP GETTEXT if (isset($CLASS['vars']['knowledgeroot']['charset']) && $CLASS['vars']['knowledgeroot']['charset'] != '') { $encoding = $CLASS['vars']['knowledgeroot']['charset']; } else { $encoding = 'utf-8'; } // gettext setup T_setlocale(LC_MESSAGES, $_POST['language']); // Set the text domain as 'knowledgeroot' $domain = 'knowledgeroot'; T_bindtextdomain($domain, LOCALE_DIR); // bind_textdomain_codeset is supported only in PHP 4.2.0+ if (function_exists('T_bind_textdomain_codeset')) T_bind_textdomain_codeset($domain, $encoding); T_textdomain($domain); // PHP-Gettext end $res = $this->CLASS['db']->query(sprintf("UPDATE users SET language='%s' WHERE id=%d",$_POST['language'],$_SESSION['userid'])); $this->addmessage(T_('Language changed.')); } if($_POST['password'] == $_POST['password1'] && $_POST['password'] != "" && $_SESSION['userid'] != 0) { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET password='%s' WHERE id=%d",md5($_POST['password']),$_SESSION['userid'])); $this->addmessage(T_('Password changed!')); } else { if($_POST['password'] != "") { $this->addwarning(T_('Failed to change password!')); } } if($_POST['theme'] != $_SESSION['theme']) { $_SESSION['theme'] = $_POST['theme']; $res = $this->CLASS['db']->query(sprintf("UPDATE users SET theme='%s' WHERE id=%d",$_POST['theme'],$_SESSION['userid'])); $this->addmessage(T_('Theme was changed.')); } else { //$this->messages .= "
    ".$this->CLASS['language']->get['optionform']['themefailed']."
    "; } $this->CLASS['hooks']->setHook("kr_header","edit_options","end"); } /** * change language for current session */ function change_language() { if(isset($_POST['language'])) { $_SESSION['language'] = $_POST['language']; header("Location: index.php"); exit(); } } /** * move page */ function move_page() { if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2 && $this->CLASS['knowledgeroot']->getPageRights($_POST['to'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","move_page","start"); // check if element is a kind of element to move -> if yes than abort if(!$this->CLASS['tree']->isParentelement($_POST['to'],$_SESSION['cid'])) { $res = $this->CLASS['db']->query(sprintf("UPDATE tree SET belongs_to=%d WHERE id=%d",$_POST['to'],$_SESSION['cid'])); $pagename = $this->CLASS['path']->getTreePageTitle($_SESSION['cid']); // email notification $this->CLASS['notification']->send_email_notification($_SESSION['cid'],"page","moved",$pagename,$_SESSION['cid']); $this->CLASS['hooks']->setHook("kr_header","move_page","success"); } $this->CLASS['hooks']->setHook("kr_header","move_page","end"); } } /** * move content */ function move_content() { if($this->CLASS['knowledgeroot']->getPageRights($_POST['to'],$_SESSION['userid']) == 2 && $this->CLASS['knowledgeroot']->getContentRights($_POST['contentid'],$_SESSION['userid']) == 2 && $_POST['to'] != 0) { $this->CLASS['hooks']->setHook("kr_header","move_content","start"); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET belongs_to=%d WHERE id=%d",$_POST['to'],$_POST['contentid'])); $pagename = $this->CLASS['path']->getTreePageTitle($_SESSION['cid']); // email notification $this->CLASS['notification']->send_email_notification($_SESSION['cid'],"content","moved",$pagename,$_POST['contentid']); $this->CLASS['hooks']->setHook("kr_header","move_content","end"); } } /** * open tree element */ function open_tree_element() { $this->CLASS['hooks']->setHook("kr_header","open_tree_element","start"); //echo "#$#".$_SESSION['open'][$openid]."#"; if(isset($_SESSION['open'][$_GET['openid']]) && $_SESSION['open'][$_GET['openid']] == 0) { $_SESSION['open'][$_GET['openid']] = 1; } else { $_SESSION['open'][$_GET['openid']] = 0; } // save treecache if(!empty($_SESSION['userid'])) { $res = $this->CLASS['db']->query(sprintf("UPDATE users SET treecache='%s' WHERE id=%d",serialize($_SESSION['open']),$_SESSION['userid'])); } $this->CLASS['hooks']->setHook("kr_header","open_tree_element","end"); } /** * show messages */ function show_messages() { $this->CLASS['hooks']->setHook("kr_header","show_messages","start"); if($this->messages != "") { $js = ' '; echo $js; } $this->CLASS['hooks']->setHook("kr_header","show_messages","end"); } /** * addmessage to top * @param string $msg messagetext */ function addmessage($msg) { $this->CLASS['hooks']->setHook("kr_header","addmessage","start"); $this->messagetype = "notice"; $this->messages .= $msg . " "; $this->CLASS['hooks']->setHook("kr_header","addmessage","end"); } /** * add warning to top * @param string $msg message */ function addwarning($msg) { $this->CLASS['hooks']->setHook("kr_header","addwarning","start"); $this->messagetype = "error"; $this->messages .= $msg . " "; $this->CLASS['hooks']->setHook("kr_header","addwarning","end"); } /** * add text to htmlheader * @param string $msg */ function addheader($msg) { $this->CLASS['hooks']->setHook("kr_header","addheader","start"); $this->htmlheader .= $msg . "\n"; $this->CLASS['hooks']->setHook("kr_header","addheader","end"); } /** * show htmlheader */ function show_header() { $this->CLASS['hooks']->setHook("kr_header","show_header","start"); echo $this->htmlheader; $this->CLASS['hooks']->setHook("kr_header","show_header","end"); } /** * add plain javascriptcode to header * @param string $code */ function addjs($code="") { $this->CLASS['hooks']->setHook("kr_header","addjs","start"); $this->addheader("\t"); $this->CLASS['hooks']->setHook("kr_header","addjs","end"); } /** * add source javascript sourcefile to header * @param string $src */ function addjssrc($src) { $this->CLASS['hooks']->setHook("kr_header","addjssrc","start"); $this->addheader("\t"); $this->CLASS['hooks']->setHook("kr_header","addjssrc","end"); } /** * add css file to header */ function addcsssrc($src) { $this->CLASS['hooks']->setHook("kr_header","addcsssrc","start"); $this->addheader(""); $this->CLASS['hooks']->setHook("kr_header","addcsssrc","end"); } /** * add title to header */ function addtitle() { $this->CLASS['hooks']->setHook("kr_header","addtitle","start"); $this->addheader("".$this->CLASS['vars']['knowledgeroot']['title'].""); $this->CLASS['hooks']->setHook("kr_header","addtitle","end"); } /** * moves content up */ function move_content_up() { $contentid = $_GET['moveup']; $pageid = $_SESSION['cid']; if($contentid == "") { return 0; } // user can only move if he have pagerights if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","move_content_up","start"); $res = $this->CLASS['db']->query(sprintf("SELECT id, sorting FROM content WHERE id=%d",$contentid)); $count = $this->CLASS['db']->num_rows($res); if($count == 1) { $row = $this->CLASS['db']->fetch_assoc($res); if($row['sorting'] == 0 || $row['sorting'] == null) { //$res = $this->CLASS['db']->query("UPDATE content SET sorting=0 WHERE sorting IS NULL AND deleted=0"); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=sorting+1 WHERE belongs_to=%d AND id<>%d AND deleted=0",$pageid,$contentid)); $this->addmessage(T_('content moved')); } else { $res = $this->CLASS['db']->query(sprintf("SELECT id, max(sorting) as sorting FROM content WHERE belongs_to=%d AND sorting<=%d AND id<>%d AND deleted=0 GROUP BY id ORDER BY sorting DESC LIMIT 1",$pageid,$row['sorting'],$contentid)); $count = $this->CLASS['db']->num_rows($res); if($count == 1) { $rowelement = $this->CLASS['db']->fetch_assoc($res); if($row['sorting'] == $rowelement['sorting']) { //$res = $this->CLASS['db']->query("UPDATE content SET sorting=0 WHERE sorting IS NULL AND deleted=0"); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=sorting+1 WHERE belongs_to=%d AND id<>%d AND sorting>=%d AND deleted=0",$pageid,$contentid,$row['sorting'])); } else { $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=%d WHERE id=%d",$row['sorting'],$rowelement['id'])); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=%d WHERE id=%d",$rowelement['sorting'],$row['id'])); } $this->addmessage(T_('content moved')); $this->CLASS['hooks']->setHook("kr_header","move_content_up","success"); } // else - do nothing } } $this->CLASS['hooks']->setHook("kr_header","move_content_up","end"); } } /** * move content down on page */ function move_content_down() { $contentid = $_GET['movedown']; $pageid = $_SESSION['cid']; if($contentid == "") { return 0; } // user can only move if he have pagerights if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_header","move_content_down","start"); $res = $this->CLASS['db']->query(sprintf("SELECT id, sorting FROM content WHERE id=%d",$contentid)); $count = $this->CLASS['db']->num_rows($res); if($count == 1) { $row = $this->CLASS['db']->fetch_assoc($res); // needed if fields have content "null" //$res = $this->CLASS['db']->query("UPDATE content SET sorting=0 WHERE sorting IS NULL AND deleted=0"); $res = $this->CLASS['db']->query(sprintf("SELECT id, min(sorting) as sorting FROM content WHERE belongs_to=%d AND sorting>=%d AND id<>%d AND deleted=0 GROUP BY id ORDER BY sorting ASC LIMIT 1",$pageid,$row['sorting'],$contentid)); $count = $this->CLASS['db']->num_rows($res); if($count == 1) { $rowelement = $this->CLASS['db']->fetch_assoc($res); if($row['sorting'] == $rowelement['sorting']) { $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=sorting+1 WHERE belongs_to=%d AND id<>%d AND sorting>=%d AND deleted=0",$pageid,$contentid,$row['sorting'])); } else { $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=%d WHERE id=%d",$row['sorting'],$rowelement['id'])); $res = $this->CLASS['db']->query(sprintf("UPDATE content SET sorting=%d WHERE id=%d",$rowelement['sorting'],$row['id'])); } $this->addmessage(T_('content moved')); $this->CLASS['hooks']->setHook("kr_header","move_content_down","success"); } } $this->CLASS['hooks']->setHook("kr_header","move_content_down","end"); } } /** * This function will add the searchwords to your session and will redirect you to the search */ function create_search() { $this->CLASS['hooks']->setHook("kr_content","create_search","start"); // if user search for special content the searchword is #[0-9]+ if(preg_match('/#([0-9]+)/', $_POST['search'], $match)) { $res = $this->CLASS['db']->query(sprintf('SELECT belongs_to FROM content WHERE id=%d',$match[1])); $cnt = $this->CLASS['db']->num_rows($res); if($cnt == 1) { $row = $this->CLASS['db']->fetch_assoc($res); header('Location: index.php?id='.$row['belongs_to'].'#'.$match[1]); exit(); } } // generete uniqu key for search $sum = md5($_POST['search']); // save searchword to key in the session $_SESSION['search'][$sum] = $_POST['search']; $this->CLASS['hooks']->setHook("kr_content","create_search","end"); // redirect to show search header("Location: index.php?action=showsearch&key=".$sum.""); exit(); } /** * return baseurl * @return string */ function get_base_url() { if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") { $scheme = "https://"; } else { $scheme = "http://"; } $baseURL = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $pos = strpos( $baseURL, "index.php" ); if($pos == 0) { $pos = strpos( $baseURL, "ajax-xml.php" ); } return substr( $baseURL, 0, $pos ); } /** * This functions checks if a content should be shown directly to display it! */ function getIDFromContent() { if(isset($_GET['contentid']) && $_GET['contentid'] != "") { $mycontentrights = $this->CLASS['knowledgeroot']->getContentRights($_GET['contentid'],$_SESSION['userid']); if($mycontentrights >= 1) { $res = $this->CLASS['db']->query(sprintf("SELECT id,belongs_to FROM content WHERE id=%d",$_GET['contentid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $_GET['id'] = $row['belongs_to']; } } } } /** * get ID from the alias in url */ function getIDFromAlias() { if(preg_match("/.*\/([a-zA-Z0-9]+)\.html.*/",$this->getIndpEnv("TYPO3_SITE_SCRIPT"),$found)) { if($_SERVER["REQUEST_METHOD"] == "GET") { $_SESSION['cid'] = ""; $_GET['id'] = $this->getAliasID($found[1]); } if($_SERVER["REQUEST_METHOD"] == "POST") { $_SESSION['cid'] = ""; $_POST['id'] = $this->getAliasID($found[1]); } } } /** * get id for alias */ function getAliasID($alias) { if($alias != "") { $res = $this->CLASS['db']->query(sprintf("SELECT id FROM tree WHERE alias='%s' AND deleted=0",$alias)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); return $row['id']; } } return ""; } /** * FROM TYPO3 - class.tslib_fe.php * Abstraction method which returns System Environment Variables regardless of server OS, CGI/MODULE version etc. Basically this is SERVER variables for most of them. * This should be used instead of getEnv() and $_SERVER/ENV_VARS to get reliable values for all situations. * Usage: 221 * * @param string Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, _ARRAY * @return string Value based on the input key, independent of server/os environment. */ function getIndpEnv($getEnvName) { /* Conventions: output from parse_url(): URL: http://username:password@192.168.1.4:8080/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value#link1 [scheme] => 'http' [user] => 'username' [pass] => 'password' [host] => '192.168.1.4' [port] => '8080' [path] => '/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/' [query] => 'arg1,arg2,arg3&p1=parameter1&p2[key]=value' [fragment] => 'link1' Further definition: [path_script] = '/typo3/32/temp/phpcheck/index.php' [path_dir] = '/typo3/32/temp/phpcheck/' [path_info] = '/arg1/arg2/arg3/' [path] = [path_script/path_dir][path_info] Keys supported: URI______: REQUEST_URI = [path]?[query] = /typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value HTTP_HOST = [host][:[port]] = 192.168.1.4:8080 SCRIPT_NAME = [path_script]++ = /typo3/32/temp/phpcheck/index.php // NOTICE THAT SCRIPT_NAME will return the php-script name ALSO. [path_script] may not do that (eg. '/somedir/' may result in SCRIPT_NAME '/somedir/index.php')! PATH_INFO = [path_info] = /arg1/arg2/arg3/ QUERY_STRING = [query] = arg1,arg2,arg3&p1=parameter1&p2[key]=value HTTP_REFERER = [scheme]://[host][:[port]][path] = http://192.168.1.4:8080/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value (Notice: NO username/password + NO fragment) CLIENT____: REMOTE_ADDR = (client IP) REMOTE_HOST = (client host) HTTP_USER_AGENT = (client user agent) HTTP_ACCEPT_LANGUAGE = (client accept language) SERVER____: SCRIPT_FILENAME = Absolute filename of script (Differs between windows/unix). On windows 'C:\\blabla\\blabl\\' will be converted to 'C:/blabla/blabl/' Special extras: TYPO3_HOST_ONLY = [host] = 192.168.1.4 TYPO3_PORT = [port] = 8080 (blank if 80, taken from host value) TYPO3_REQUEST_HOST = [scheme]://[host][:[port]] TYPO3_REQUEST_URL = [scheme]://[host][:[port]][path]?[query] (sheme will by default be 'http' until we can detect if it's https - TYPO3_REQUEST_SCRIPT = [scheme]://[host][:[port]][path_script] TYPO3_REQUEST_DIR = [scheme]://[host][:[port]][path_dir] TYPO3_SITE_URL = [scheme]://[host][:[port]][path_dir] of the TYPO3 website frontend TYPO3_SITE_SCRIPT = [script / Speaking URL] of the TYPO3 website TYPO3_DOCUMENT_ROOT = Absolute path of root of documents: TYPO3_DOCUMENT_ROOT.SCRIPT_NAME = SCRIPT_FILENAME (typically) Notice: [fragment] is apparently NEVER available to the script! Testing suggestions: - Output all the values. - In the script, make a link to the script it self, maybe add some parameters and click the link a few times so HTTP_REFERER is seen - ALSO TRY the script from the ROOT of a site (like 'http://www.mytest.com/' and not 'http://www.mytest.com/test/' !!) */ // if ($getEnvName=='HTTP_REFERER') return ''; switch((string)$getEnvName) { case 'SCRIPT_NAME': return (php_sapi_name()=='cgi'||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO']?$_SERVER['ORIG_PATH_INFO']:$_SERVER['PATH_INFO']) : ($_SERVER['ORIG_SCRIPT_NAME']?$_SERVER['ORIG_SCRIPT_NAME']:$_SERVER['SCRIPT_NAME']); break; case 'SCRIPT_FILENAME': return str_replace('//','/', str_replace('\\','/', (php_sapi_name()=='cgi'||php_sapi_name()=='isapi' ||php_sapi_name()=='cgi-fcgi')&&($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED'])? ($_SERVER['ORIG_PATH_TRANSLATED']?$_SERVER['ORIG_PATH_TRANSLATED']:$_SERVER['PATH_TRANSLATED']):($_SERVER['ORIG_SCRIPT_FILENAME']?$_SERVER['ORIG_SCRIPT_FILENAME']:$_SERVER['SCRIPT_FILENAME']))); break; case 'REQUEST_URI': // Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode($this->getIndpEnv('REQUEST_URI')) if (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available. return '/'.ereg_replace('^/','',$this->getIndpEnv('SCRIPT_NAME')). ($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:''); } else return $_SERVER['REQUEST_URI']; break; case 'PATH_INFO': // $_SERVER['PATH_INFO']!=$_SERVER['SCRIPT_NAME'] is necessary because some servers (Windows/CGI) are seen to set PATH_INFO equal to script_name // Further, there must be at least one '/' in the path - else the PATH_INFO value does not make sense. // IF 'PATH_INFO' never works for our purpose in TYPO3 with CGI-servers, then 'php_sapi_name()=='cgi'' might be a better check. Right now strcmp($_SERVER['PATH_INFO'],$this->getIndpEnv('SCRIPT_NAME')) will always return false for CGI-versions, but that is only as long as SCRIPT_NAME is set equal to PATH_INFO because of php_sapi_name()=='cgi' (see above) // if (strcmp($_SERVER['PATH_INFO'],$this->getIndpEnv('SCRIPT_NAME')) && count(explode('/',$_SERVER['PATH_INFO']))>1) { if (php_sapi_name()!='cgi'&&php_sapi_name()!='cgi-fcgi') { return $_SERVER['PATH_INFO']; } else return ''; break; // These are let through without modification case 'REMOTE_ADDR': case 'REMOTE_HOST': case 'HTTP_REFERER': case 'HTTP_HOST': case 'HTTP_USER_AGENT': case 'HTTP_ACCEPT_LANGUAGE': case 'QUERY_STRING': return $_SERVER[$getEnvName]; break; case 'TYPO3_DOCUMENT_ROOT': // Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a 'wrong' DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well. // Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME. $SFN = $this->getIndpEnv('SCRIPT_FILENAME'); $SN_A = explode('/',strrev($this->getIndpEnv('SCRIPT_NAME'))); $SFN_A = explode('/',strrev($SFN)); $acc = array(); while(list($kk,$vv)=each($SN_A)) { if (!strcmp($SFN_A[$kk],$vv)) { $acc[] = $vv; } else break; } $commonEnd=strrev(implode('/',$acc)); if (strcmp($commonEnd,'')) { $DR = substr($SFN,0,-(strlen($commonEnd)+1)); } return $DR; break; case 'TYPO3_HOST_ONLY': $p = explode(':',$_SERVER['HTTP_HOST']); return $p[0]; break; case 'TYPO3_PORT': $p = explode(':',$_SERVER['HTTP_HOST']); return $p[1]; break; case 'TYPO3_REQUEST_HOST': return ($this->getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://'). $_SERVER['HTTP_HOST']; break; case 'TYPO3_REQUEST_URL': return $this->getIndpEnv('TYPO3_REQUEST_HOST').$this->getIndpEnv('REQUEST_URI'); break; case 'TYPO3_REQUEST_SCRIPT': return $this->getIndpEnv('TYPO3_REQUEST_HOST').$this->getIndpEnv('SCRIPT_NAME'); break; case 'TYPO3_REQUEST_DIR': return $this->getIndpEnv('TYPO3_REQUEST_HOST').$this->dirname($this->getIndpEnv('SCRIPT_NAME')).'/'; break; case 'TYPO3_SITE_URL': if (defined('PATH_thisScript') && defined('PATH_site')) { $lPath = substr(dirname(PATH_thisScript),strlen(PATH_site)).'/'; $url = $this->getIndpEnv('TYPO3_REQUEST_DIR'); $siteUrl = substr($url,0,-strlen($lPath)); if (substr($siteUrl,-1)!='/') $siteUrl.='/'; return $siteUrl; } else return ''; break; case 'TYPO3_SITE_SCRIPT': return substr($this->getIndpEnv('TYPO3_REQUEST_URL'),strlen($this->getIndpEnv('TYPO3_SITE_URL'))); break; case 'TYPO3_SSL': return (isset ($_SERVER['SSL_SESSION_ID']) and $_SERVER['SSL_SESSION_ID']) || (isset ($_SERVER['HTTPS']) and !strcmp($_SERVER['HTTPS'],'on')) ? TRUE : FALSE; break; case '_ARRAY': $out = array(); // Here, list ALL possible keys to this function for debug display. $envTestVars = explode(',',' HTTP_HOST, TYPO3_HOST_ONLY, TYPO3_PORT, PATH_INFO, QUERY_STRING, REQUEST_URI, HTTP_REFERER, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, TYPO3_SITE_SCRIPT, TYPO3_SSL, SCRIPT_NAME, TYPO3_DOCUMENT_ROOT, SCRIPT_FILENAME, REMOTE_ADDR, REMOTE_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE'); reset($envTestVars); while(list(,$v)=each($envTestVars)) { $out[trim($v)]=$this->getIndpEnv(trim($v)); } reset($out); return $out; break; } } /** * FROM TYPO3 * Returns the directory part of a path without trailing slash * If there is no dir-part, then an empty string is returned. * Behaviour: * * '/dir1/dir2/script.php' => '/dir1/dir2' * '/dir1/' => '/dir1' * 'dir1/script.php' => 'dir1' * 'd/script.php' => 'd' * '/script.php' => '' * '' => '' * Usage: 5 * * @param string Directory name / path * @return string Processed input value. See function description. */ function dirname($path) { $p=$this->revExplode('/',$path,2); return count($p)==2?$p[0]:''; } /** * FROM TYPO3 * Reverse explode which explodes the string counting from behind. * Thus t3lib_div::revExplode(':','my:words:here',2) will return array('my:words','here') * Usage: 8 * * @param string Delimiter string to explode with * @param string The string to explode * @param integer Number of array entries * @return array Exploded values */ function revExplode($delim, $string, $count=0) { $temp = explode($delim,strrev($string),$count); while(list($key,$val)=each($temp)) { $temp[$key]=strrev($val); } $temp=array_reverse($temp); reset($temp); return $temp; } /** * FROM TYPO3 * Splits a reference to a file in 5 parts * Usage: 43 * * @param string Filename/filepath to be analysed * @return array Contains keys [path], [file], [filebody], [fileext], [realFileext] */ function split_fileref($fileref) { if ( ereg('(.*/)(.*)$',$fileref,$reg) ) { $info['path'] = $reg[1]; $info['file'] = $reg[2]; } else { $info['path'] = ''; $info['file'] = $fileref; } $reg=''; if ( ereg('(.*)\.([^\.]*$)',$info['file'],$reg) ) { $info['filebody'] = $reg[1]; $info['fileext'] = strtolower($reg[2]); $info['realFileext'] = $reg[2]; } else { $info['filebody'] = $info['file']; $info['fileext'] = ''; } reset($info); return $info; } } ?> knowledgeroot-0.9.9.5/include/class-runtime.php0000644000175000017500000000377510632073655022510 0ustar fhabermannfhabermannstart(); * @example echo $contenttime = $CLASS['runtime']->getTime('stop'); * or * @example $contenttime = $CLASS['runtime']->stop(); * @example echo $contenttime = $CLASS['runtime']->getTime(); */ class runtime { var $starttime = 0; var $stoptime = 0; var $runtime = 0; var $startArr = array(); var $stopArr = array(); var $runArr = array(); /** * start timer * @param string $name */ function start($name = "") { $this->reset($name); $timer = microtime(); if($name != "") { $this->startArr[$name] = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' '))); } else { $this->starttime = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' '))); } } /** * stop timer * @param string $name */ function stop($name = "") { $timer = microtime(); if($name != "") { $this->stopArr[$name] = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' '))); } else { $this->stoptime = ((double)strstr($timer, ' ') + (double)substr($timer,0,strpos($timer,' '))); } } /** * return runtime value * * @param string $name * @param mixed $stop - is this set, call stop() * @return float */ function getTime($name = "", $stop = '') { if ($stop != '') { $this->stop($name); } if($name != "") { return sprintf('%2.3f', $this->stopArr[$name] - $this->startArr[$name]); } else { return sprintf('%2.3f', $this->stoptime - $this->starttime); } } /** * reset all runtime vars * @param string $name * @param bool $clearAll */ function reset($name = "", $clearAll = false) { if($name != "" || $clearAll == true) { $this->startArr = array(); $this->stopArr = array(); $this->runArr = array(); } if($name == "" || $clearAll == true) { $this->starttime = 0; $this->stoptime = 0; $this->runtime = 0; } } } ?> knowledgeroot-0.9.9.5/include/class-mdb2.php0000644000175000017500000000575711000753003021631 0ustar fhabermannfhabermannCLASS =& $CLASS; require_once('MDB2.php'); } /** * */ function connect($host,$user,$pass,$db,$schema="public",$encoding="LATIN1") { $dsn = array(); $options = array(); if(isset($this->CLASS['vars']['db']['dsn'])) $dsn = $this->CLASS['vars']['db']['dsn']; if(isset($this->CLASS['vars']['db']['options'])) $options = $this->CLASS['vars']['db']['options']; // do connect $this->mdb2 =& MDB2::factory($dsn, $options); if (PEAR::isError($this->mdb2)) { $this->CLASS['error']->log($this->mdb2->getMessage(),1,"class-mdb2.php::connect"); exit(); } // set dbname und dbdriver $dsn = $this->mdb2->getDSN("array"); if($dsn['phptype'] == "pgsql") { $this->dbname = "postgresql"; } else { $this->dbname = $dsn['phptype']; } $this->dbtype = $dsn['phptype']; return true; } /** * Close connection * @return bool */ function close() { return $this->mdb2->disconnect(); } /** * Will make a query with the server * @param string $query * @return resource return query result */ function query($query) { $this->lastquery = $query; $this->query_cache[] = $query; $this->querys += 1; $res = new db_result($this->CLASS); $res->setQuery($query); $res->setResult($this->mdb2->query($query)); // if error in query if (PEAR::isError($res->getResult())) { $this->CLASS['error']->log("ERROR IN QUERY: \"$query\"",1,$res->getResult()->getMessage()); } return $res; } /** * Fetch a Result as assoc * @param mixed $result * @return array */ function fetch_assoc($result) { return $result->getResult()->fetchRow(MDB2_FETCHMODE_ASSOC); } /** * Fetch a Result as Object * @param mixed $result * @return object */ function fetch_object($result) { return $result->getResult()->fetchRow(MDB2_FETCHMODE_OBJECT); } /** * Fetch a Result as array * @param mixed $result * @return array */ function fetch_row($result) { return $result->getResult()->fetchRow(MDB2_FETCHMODE_ORDERED); } /** * Will count the rows of a resultset * @param mixed $result * @return int */ function num_rows($result) { return $result->getResult()->numRows(); } /** * Returns the text of the error message from previous PostgreSQL operation * @return string */ function error() { return ""; } /** * Return the last inserted id from a query * @param string $name not required * @return int */ function last_id($name) { return $this->mdb2->lastInsertID(); } /** * Quote a String with Postgresql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return $this->mdb2->quoteIdentifier($string); } /** * do data seek on result * @param resource $result * @param integer $number * @return bool */ function data_seek($result, $number) { return $result->getResult()->seek($number); } } ?> knowledgeroot-0.9.9.5/include/class-tree.php0000644000175000017500000006164711165235400021754 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * return path of a treeid with htmlcontent */ function getPath($id = "0", $urlPrefix = '') { if($id == "") { $id = "0"; } $treeRecord = $this->getTreeRecord($id); if($treeRecord != null) { if($treeRecord->belongs_to == "0") { return "/ ".$treeRecord->title.""; } else { $path = $this->getPath($treeRecord->belongs_to, $urlPrefix); return $path . " / " . $treeRecord->title.""; } } else { return "/ "; } } /** * return path of a treeid without htmlcontent */ function getTextPath($id = "0", $urlPrefix = '') { if($id == "") { $id = "0"; } $treeRecord = $this->getTreeRecord($id); if($treeRecord != null) { if($treeRecord->belongs_to == "0") { return "/ ".$treeRecord->title; } else { $path = $this->getTextPath($treeRecord->belongs_to, $urlPrefix); return $path . " / " . $treeRecord->title; } } else { return "/ "; } } /** * */ function getUnlinkedPath($id = "0") { if($id == "") { $id = "0"; } $treeRecord = $this->getTreeRecord($id); if($treeRecord != null) { if($treeRecord->belongs_to == "0") { return "/ ".$treeRecord->title; } else { $path = $this->getUnlinkedPath($treeRecord->belongs_to); return $path . " / " . $treeRecord->title; } } else { return "/ "; } } /** * */ function getTreePageTitle($id) { $treeRecord = $this->getTreeRecord($id); if($treeRecord != null) { return $treeRecord->title; } else { return ""; } } /** * */ function getTreeRecord($id = "0") { $treeRecord = null; $no_rows = false; if(isset ($this->cache[$id]) and $this->cache[$id] != null) { $treeRecord = $this->cache[$id]; } else { $res = $this->CLASS['db']->query(sprintf("SELECT * FROM tree WHERE id=%d",$id)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_object($res); $treeRecord = $row; $this->cache[$id] = $treeRecord; } else { return null; } } return $treeRecord; } /** * */ function isTree($id) { if(isset($this->cache[$id]) and $this->cache[$id] != null) { return TRUE; } return FALSE; } /** * return parent of element in tree */ function getParent($treeid) { $res = $this->CLASS['db']->query(sprintf("SELECT belongs_to FROM tree WHERE id=%d",$treeid)); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); return $row['belongs_to']; } else { return 0; } } } /** * * * @package Knowledgeroot * @author Frank Habermann * @version $Id: class-tree.php 679 2009-04-02 22:24:00Z lordlamer $ */ class categoryTree { var $out = array(); // elemts for the user var $allelements = array(); // all elements in the table var $myelements = array(); var $open = array(); var $firstrun = 0; var $expand = 0; var $doexpand = 0; var $targetfile = "index.php"; var $move = FALSE; var $editor = FALSE; var $CLASS; var $category = array(); var $userid = 0; var $groupid = 0; var $admin = 0; var $firstrootelement = 1; // used to check if the first rootelement is shown /** * init/start class */ function start(&$CLASS,$specialCase='',$targetfile="index.php") { $this->CLASS =& $CLASS; if(!isset($_SESSION['firstrun']) || (isset($_SESSION['firstrun']) && $_SESSION['firstrun'] == 1)) { $this->doexpand =& $this->CLASS['vars']['menu']['expandall']; } else { $this->doexpand = 0; } $this->move = ($specialCase == 'move'); $this->editor = ($specialCase == 'editor'); $this->targetfile = $targetfile; if (isset ($_SESSION['admin']) and $_SESSION['admin'] != '') { $this->admin = $_SESSION['admin']; } $this->readAllCategories(); } /** * */ function readCategories() { if (isset ($this->category[0]) and $this->category[0] != "") { return $this->category; } // get order by if(isset($this->CLASS['vars']['menu']['order']['self']) && $this->CLASS['vars']['menu']['order']['self'] == 1) { $orderby = "sorting"; } else { $orderby = "title"; } //fr mysql umschreiben //if($this->admin == 1) { // enable all because of multiple rights if(1) { $query = sprintf("SELECT * FROM tree WHERE deleted=0 ORDER BY %s ASC", $orderby); } else { if($_SESSION['groupid'] == 0) { $query = sprintf("SELECT * FROM tree WHERE deleted=0 AND ((otherrights > 0) OR (".$this->CLASS['db']->quoteIdentifier("group")."=%d AND grouprights > 0) OR (owner=%d AND userrights>0)) ORDER BY %s ASC",$_SESSION['groupid'],$_SESSION['userid'],$orderby); } else { $query_part = sprintf(" OR (".$this->CLASS['db']->quoteIdentifier("group")."=%d AND grouprights > 0)",$_SESSION['groupid']); $res = $this->CLASS['db']->query(sprintf("SELECT groupid FROM user_group WHERE userid=%d",$_SESSION['userid'])); while($row = $this->CLASS['db']->fetch_assoc($res)) { $query_part .= sprintf(" OR (".$this->CLASS['db']->quoteIdentifier("group")."=%d AND grouprights > 0)",$row['groupid']); } $query = sprintf("SELECT * FROM tree WHERE deleted=0 AND ((otherrights > 0) %s OR (owner=%d AND userrights>0)) ORDER BY %s ASC",$query_part,$_SESSION['userid'],$orderby); } } $res = $this->CLASS['db']->query($query); while ( $var = $this->CLASS['db']->fetch_assoc($res) ) { if($this->CLASS['knowledgeroot']->checkRecursivPerm($var['id'],$_SESSION['userid']) > 0) { $out[ $var['belongs_to'] ][ $var['id'] ]['title'] = $var['title']; $out[ $var['belongs_to'] ][ $var['id'] ]['tooltip'] = $var['tooltip']; $out[ $var['belongs_to'] ][ $var['id'] ]['alias'] = $var['alias']; $out[ $var['belongs_to'] ][ $var['id'] ]['id'] = $var['id']; $out[ $var['belongs_to'] ][ $var['id'] ]['belongs_to'] = $var['belongs_to']; $out[ $var['belongs_to'] ][ $var['id'] ]['symlink'] = $var['symlink']; $myout[ $var['id'] ]['id'] = $var['belongs_to']; $myout[ $var['id'] ]['symlink'] = $var['symlink']; if($this->firstrun == 1) { $this->open[$var['id'] ] = 0; $_SESSION['open'][$var['id']] = 0; } } } $this->out = &$out; $this->myelements = &$myout; return $out; } /** * */ function readAllCategories() { // get order by if(isset($this->CLASS['vars']['menu']['order']['self']) && $this->CLASS['vars']['menu']['order']['self'] == 1) { $orderby = "sorting"; } else { $orderby = "title"; } $query = sprintf("SELECT * FROM tree WHERE deleted=0 ORDER BY %s ASC",$orderby); $res = $this->CLASS['db']->query($query); while ( $var = $this->CLASS['db']->fetch_assoc($res) ) { $out[ $var['id'] ] = $var['belongs_to']; } $this->allelements = &$out; } /** * */ function isParentelement($element, $parent) { $query = sprintf("SELECT belongs_to FROM tree WHERE id='%s'",$element); $res = $this->CLASS['db']->query($query); $anz = $this->CLASS['db']->num_rows($res); if($anz != 1) { return FALSE; } $row = $this->CLASS['db']->fetch_assoc($res); if($row['belongs_to'] == $parent) { return TRUE; } else { return $this->isParentelement($row['belongs_to'],$parent); } } /** * */ function buildTree( $rec_id ) { echo "\n"; $cats = $this->readCategories(); $moveparam = ''; if($this->CLASS['vars']['menu']['ajax'] == "yes") { if($this->CLASS['vars']['menu']['type'] == "static") { $fixedstyle = "style=\"display:none;\""; $slidestyle = "style=\"display:block;\""; } else { $fixedstyle = "style=\"display:block;\""; $slidestyle = "style=\"display:none;\""; } if($this->move == TRUE) { $moveparam = "1"; } echo ' '; echo "\n"; } else { echo $this->showTreePart( $this->getTreePart(0) ); } echo "
    '; // show tree menu echo $this->CLASS['kr_extension']->show_menu("tree",$moveparam); echo '
    \n"; echo "
    \n"; //echo "
    \n"; echo "\n"; echo $this->showAjaxTreePart( $this->getTreePart(0) ); echo "
    \n"; echo "
    \n"; echo "
    \n"; // treebottom navi echo $this->CLASS['kr_extension']->show_menu("treebottom"); } /** * */ function buildAjaxTreePart($id) { if(isset($_SESSION['open'])) { $this->open = $_SESSION['open']; } else { $this->open = array(); } $cats = $this->readCategories(); if($id == "0") { $depth = 0; } else { $depth = 1; } $spaces = $this->getDeepPart($id) + $depth; $out = ""; if($this->editor == TRUE) { $out .= $this->getContentTitleOfPage($id,$depth+1); } $out .= $this->showAjaxTreePart( $this->getTreePart($id), $spaces ); return $out; } /** * */ function showTreePart( $arr, $indent = 0 ) { $space = ""; $open = array(); for ( $i=0; $i<$indent; $i++ ) { $space .= " \"\" "; } $out = ""; if( count( $arr ) > 0 ) { foreach( $arr as $id => $title ) { if($title == "") { $title = "[EMPTY]"; } //if($this->visible[$id] == 1) { if($this->move == TRUE) { $indexfile = "move.php"; } else { $indexfile = "index.php"; } if($this->lastPart($id) == 0) { if ((isset ($_SESSION['open'][$id]) and $_SESSION['open'][$id] == 1) || $this->expand == 1 || $this->doexpand == 1) { $spaces = $space . " \"\" "; } else { $spaces = $space . " \"\" "; } } else { $spaces = $space . " \"\" "; } // check if link a actual element if($id == $_SESSION['cid']) { $class_act = "class=\"active_tree_item\" "; } else { $class_act = ""; } if($this->move == TRUE) { $out .= "".$spaces . ((isset($this->CLASS['vars']['menu']['showcounter']) && $this->CLASS['vars']['menu']['showcounter'] == 1) ? "" . $itemcounter . ". " : "") . "" . $title['title'] . "\n"; } else { $out .= "".$spaces . ((isset($this->CLASS['vars']['menu']['showcounter']) && $this->CLASS['vars']['menu']['showcounter'] == 1) ? "" . $itemcounter . ". " : "") . "makeLink($title) . "\">" . (($this->isSymlink($id) != 0) ? "#" : "") . $title['title'] . "\n"; } if ((isset ($this->open[$id]) and $this->open[$id] == 1) || $this->expand == 1 || $this->doexpand == 1) { $_SESSION['open'][$id] = 1; $this->open[$id] = 1; $out .= $this->showTreePart( $this->getTreePart( $id ), $indent+1 ); } //} } } return $out; } /** * return html that shows the part of a tree */ function showAjaxTreePart( $arr, $indent = 0 ) { $space = ""; $open = array(); $imagePrefix = ""; $minusImage = "minus.jpg"; $plusImage = "plus.jpg"; $imagePrefix = $this->CLASS['knowledgeroot']->getEnv("REQUEST_DIR"); for ( $i=0; $i<$indent; $i++ ) { $space .= " \"\" "; } $out = ""; $itemcounter = 0; if( count( $arr ) > 0 ) { foreach( $arr as $id => $title ) { $itemcounter++; if($title == "") { $title = "[EMPTY]"; } if($this->lastPart($id) == 0) { $moveparam = ""; // check if page is movingpage if($this->move == TRUE) { $moveparam = "1"; } else { $moveparam = "0"; } $useeditor = ""; if($this->editor == TRUE) $useeditor = 1; else $useeditor = 0; if ((isset ($_SESSION['open'][$id]) and $_SESSION['open'][$id] == 1) || $this->expand == 1 || $this->doexpand == 1) { $spaces = $space . " \"\" "; } else { $spaces = $space . " \"\" "; } } else { $spaces = $space . " \"\" "; } // check if link a actual element if($id == $_SESSION['cid']) { $class_act = "class=\"active_tree_item\" "; } else { $class_act = ""; } // check for rootelement if(isset($this->CLASS['vars']['menu']['hrrootline']) && $this->CLASS['vars']['menu']['hrrootline'] == 1 && isset($title['belongs_to']) && $title['belongs_to'] == 0) { if($this->firstrootelement == 1) { $this->firstrootelement = 0; $class_root_item = "class=\"tree\""; } else { $class_root_item = "class=\"treeRootItem\""; } } else { $class_root_item = "class=\"tree\""; } $mousecontext = ""; // check if contextmenu are enabled if($this->CLASS['vars']['menu']['context'] == 1) { // set mousecontext for rightclick menu $mousecontext = " oncontextmenu=\"KnowledgerootMenu.show('mousemenu','pagecontext', ".$id."); return false;\""; } // set tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1 && $title['tooltip'] != "") { $tooltip = " title=\"".$title['tooltip']."\""; } else { $tooltip = " title=\"".$title['title']."\""; } if($this->move == TRUE) { $out .= "".$spaces . ((isset($this->CLASS['vars']['menu']['showcounter']) && $this->CLASS['vars']['menu']['showcounter'] == 1) ? "" . $itemcounter . ". " : "") . "" . $title['title'] . "\n"; } else if ($this->editor == TRUE) { $out .= "".$spaces . ((isset($this->CLASS['vars']['menu']['showcounter']) && $this->CLASS['vars']['menu']['showcounter'] == 1) ? "" . $itemcounter . ". " : "") . "" .$title['title'] . "\n"; } else { $out .= "".$spaces . ((isset($this->CLASS['vars']['menu']['showcounter']) && $this->CLASS['vars']['menu']['showcounter'] == 1) ? "" . $itemcounter . ". " : "") . "makeLink($title) . "\"" . $mousecontext . $tooltip . ">" . (($this->isSymlink($id) != 0) ? "#" : "") .$title['title'] . "\n"; } // check if drag and drop is enabled if($this->CLASS['vars']['menu']['dragdrop'] == "1" && $this->move != TRUE && $this->editor != TRUE) { // add javascript for drag and drop $out .= '\n"; } if ((isset ($this->open[$id]) && $this->open[$id] == 1) || $this->expand == 1 || $this->doexpand == 1) { if($this->editor == TRUE) { $out .= $this->getContentTitleOfPage($id,$indent+1,$imagePrefix); } $_SESSION['open'][$id] = 1; $this->open[$id] = 1; $out .= $this->showAjaxTreePart( $this->getTreePart( $id ), $indent+1 ); } } } return $out; } /** * create a link * @param array $link * @return string return url */ function makeLink($link = array()) { if(is_array($link)) { if($link['alias'] != "" && $this->CLASS['vars']['pagealias']['use'] == 1 && $this->CLASS['vars']['pagealias']['static'] == 1) { return $link['alias'] . ".html"; } else { return "index.php?id=" . $link['id']; } } return ""; } /** * return number of parents to root * needed for tree to show subelements * @param integer $id * @return integer */ function getDeepPart($id) { if (isset ($this->allelements[$id]) and $this->allelements[$id] != "" && isset ($this->allelements[$id]) and $this->allelements[$id] != 0) { return 1 + $this->getDeepPart($this->allelements[$id]); } else { return "0"; } } /** * get part of tree * @param integer $belongs_to * @return array */ function getTreePart( $belongs_to ) { // WAAH! ueberfluessig haeufiger Aufruf...mir jetzt egal :) $cats = $this->out; $out = array(); if($this->isSymlink($belongs_to) != 0) { $out = $this->getTreePart($this->isSymlink($belongs_to)); } else { if (isset ($cats[ $belongs_to ]) and count( $cats[ $belongs_to ] ) > 0 ) { foreach ( $cats[ $belongs_to ] as $id => $entry ) { $out[$id] = $entry; } } } return $out; } /** * check if the id is an symlink * @param integer $id treeitemid * @return integer */ function isSymlink($id) { if(isset($this->myelements[$id]['symlink']) && $this->myelements[$id]['symlink'] != "" && $this->myelements[$id]['symlink'] != "0") { return $this->myelements[$id]['symlink']; } return 0; } /** * check if the id is the last part in tree * @param integer $id * @return bool */ function lastPart($id) { foreach($this->myelements as $key => $value) { if($this->myelements[$key]['id'] == $id) { return 0; } } // check for symlink if($this->isSymlink($id) != 0) { return 0; } return 1; } /** * get all content titels of a tree element * @param integer $pageid * @param integer $indent * @param string $imagePrefix * @return string */ function getContentTitleOfPage($pageid, $indent = 0,$imagePrefix = "") { //$imagePrefix == ""; //if(isset($this->CLASS['vars']['include_prefix'])) $imagePrefix = $this->CLASS['vars']['include_prefix']; $imagePrefix = $this->CLASS['knowledgeroot']->getEnv("REQUEST_DIR"); $out = ""; // select the content in table content with userrights if (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { if($this->CLASS['db']->dbtype == "pgsql") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, to_char(ct.lastupdated,'DD. Mon YYYY HH24:MI:SS') as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC",$pageid); } elseif($this->CLASS['db']->dbtype == "sqlite") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, strftime('%%d.%%m.%%Y %%H:%%M:%%S',ct.lastupdated) as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC",$pageid); } else { $query = "SELECT ct.id AS id, ct.content AS content, ct.title AS title, ct.type AS type, u.name AS lastupdatedby, DATE_FORMAT(ct.lastupdated,'%d. %M %Y %H:%i:%s') as lastupdated FROM content ct"; $query .= sprintf(" LEFT OUTER JOIN users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC", $pageid); } } else { // get groups from user $res = $this->CLASS['db']->query(sprintf("SELECT groupid FROM user_group WHERE userid=%d",$_SESSION['userid'])); $orclause = ""; while($rowuser = $this->CLASS['db']->fetch_assoc($res)) { $orclause .= sprintf("OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) ",$rowuser['groupid']); } if($this->CLASS['db']->dbtype == "pgsql") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, to_char(ct.lastupdated,'DD. Mon YYYY HH24:MI:SS') as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %sOR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC",$pageid,$_SESSION['groupid'],$orclause,$_SESSION['userid']); } elseif($this->CLASS['db']->dbtype == "sqlite") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, strftime('%%d.%%m.%%Y %%H:%%M:%%S',ct.lastupdated) as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %sOR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC",$pageid,$_SESSION['groupid'],$orclause,$_SESSION['userid']); } else { $query = "SELECT ct.id AS id, ct.content AS content, ct.title AS title, ct.type AS type, u.name AS lastupdatedby, DATE_FORMAT(ct.lastupdated,'%d. %M %Y %H:%i:%s') AS lastupdated FROM content ct"; $query .= sprintf(" LEFT OUTER JOIN users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %s OR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC", $pageid, $_SESSION['groupid'], $orclause,$_SESSION['userid']); } } $res = $this->CLASS['db']->query($query); $space = ""; for ( $i=0; $i<$indent; $i++ ) { $space .= " \"\" "; } $spaces = $space . " \"\" "; while($row = $this->CLASS['db']->fetch_assoc($res)) { if($row['title'] == "") $row['title'] = $row['type'] . " (ID:".$row['id'].")"; $out .= "" . $spaces . "" . $row['title']."\n"; } return $out; } } ?> knowledgeroot-0.9.9.5/include/class-highlight.php0000644000175000017500000000400711144652632022756 0ustar fhabermannfhabermann\1'; } // Select pattern to use if ($options & $this->STR_HIGHLIGHT_SIMPLE) { $pattern = '#(%s)#'; $sl_pattern = '#(%s)#'; } else { $pattern = '#(?!<.*?)(%s)(?![^<>]*?>)#'; $sl_pattern = '#(%s)#'; } // Case sensitivity if (!($options & $this->STR_HIGHLIGHT_CASESENS)) { $pattern .= 'i'; $sl_pattern .= 'i'; } $needle = (array) $needle; foreach ($needle as $needle_s) { $needle_s = preg_quote($needle_s); // Escape needle with optional whole word check if ($options & $this->STR_HIGHLIGHT_WHOLEWD) { $needle_s = '\b' . $needle_s . '\b'; } // Strip links if ($options & $this->STR_HIGHLIGHT_STRIPLINKS) { $sl_regex = sprintf($sl_pattern, $needle_s); $text = preg_replace($sl_regex, '\1', $text); } $regex = sprintf($pattern, $needle_s); $text = preg_replace($regex, $highlight, $text); } return $text; } } ?> knowledgeroot-0.9.9.5/include/class-metatags.php0000644000175000017500000000001110436333720022600 0ustar fhabermannfhabermannknowledgeroot-0.9.9.5/include/class-knowledgeroot-content.php0000644000175000017500000015226311255507277025361 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * this function show the content */ function show_content() { $this->CLASS['hooks']->setHook("kr_content","show_content","start"); if(isset ($_GET['action']) and $_GET['action'] == "newcontent") { $this->new_content(); } elseif(isset ($_GET['action']) and $_GET['action'] == "newpage") { $this->new_page(); } elseif(isset ($_GET['action']) and $_GET['action'] == "editpage") { $this->edit_page(); } elseif(isset ($_GET['eid']) and $_GET['eid'] != "") { $this->edit_content(); } elseif (isset($_GET['action']) and $_GET['action'] == "showsearch" && isset($_GET['key']) and $_GET['key'] != "") { $this->show_search(); } elseif(isset ($_GET['action']) and $_GET['action'] == "login") { $this->show_login(); } elseif(isset ($_GET['action']) and $_GET['action'] == "createroot" && isset ($_SESSION['admin']) and $_SESSION['admin']) { $this->create_root(); } elseif(((isset ($_GET['action']) and $_GET['action'] == "options") || (isset ($_POST['action']) and $_POST['action'] == "options")) && !empty($_SESSION['userid'])) { $this->show_options(); } elseif(isset ($_GET['action']) and $_GET['action'] == "users" && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { $this->list_users(); } elseif(isset ($_GET['action']) and $_GET['action'] == "adduser" && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { $this->add_user(); } elseif(isset ($_GET['action']) and $_GET['action'] == "edituser" && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { $this->edit_user(); } elseif(isset ($_GET['action']) and $_GET['action'] == "addgroup" && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { $this->add_group(); } elseif(isset ($_GET['action']) and $_GET['action'] == "editgroup" && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { $this->edit_group(); } elseif(isset ($_GET['action']) and $_GET['action'] == "error") { $this->show_error(); } elseif($this->CLASS['kr_extension']->content != "") { $this->CLASS['kr_extension']->show_ext_content(); } else { $this->show_tree_content(); } $this->CLASS['hooks']->setHook("kr_content","show_content","end"); } /** * create form for new content */ function new_content() { if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_content","new_content","start"); //echo "[".$this->CLASS['language']->get['back']."]

    "; echo "
    "; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
    "; if ($this->CLASS['vars']['knowledgeroot']['showtitle'] == "yes") echo '
    '.T_('Title of content (optional)').' 
    '; echo "
    \n"; $this->CLASS['hooks']->setHook("kr_content","new_content","show"); // show empty content in rte editor echo $this->CLASS['rte']->show(""); // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } //check rights!!! if((!empty($_SESSION['userid']) && $show_rights == 1) || (isset($_SESSION['admin']) && $_SESSION['admin'] == 1)) { echo "

    \n"; echo $this->CLASS['knowledgeroot']->rightpanel($_SESSION['userid']); } echo "

    \n"; echo ""; echo ""; echo ""; echo "
    "; $this->CLASS['hooks']->setHook("kr_content","new_content","end"); } } /** * this function create form for newpage */ function new_page() { if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_content","new_page","start"); echo "[".T_('back')."]

    "; echo "
    "; echo ""; echo "
    \n"; echo "\t".T_('create page')."\n"; echo "
    ".T_('Here you can create a new page.')."
    \n"; echo "\n"; echo "\n"; // check for rights to show/edit alias if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { echo "\n"; } // check for tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1) { echo "\n"; } $this->CLASS['hooks']->setHook("kr_content","new_page","show"); echo "
    " .T_('page name') . ":"; // automatically open the created page $auto_open = isset($_SESSION['auto_open']) && $_SESSION['auto_open'] == true ? "checked='checked'" : ""; echo "   ".T_('automatically open the created page') . "
    " . T_('page alias') . ":
    " . T_('tooltip') . ":
    "; echo "
    \n"; // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } //check rights!!! if((!empty($_SESSION['userid']) && $show_rights == 1) || (isset($_SESSION['admin']) && $_SESSION['admin'] == 1)) { $panel = $this->CLASS['knowledgeroot']->rightpanel($_SESSION['userid']); if($panel != "") { echo "
    ".T_('pagerights')."\n"; echo $panel; echo "
    \n"; } } if(isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { echo "
    ".T_('pagerights for subpages (inherit rights)')."\n"; echo $this->CLASS['knowledgeroot']->rightpanelsubinherit($_SESSION['userid']); echo "
    \n"; } echo "
    \n"; echo "
    "; $this->CLASS['hooks']->setHook("kr_content","new_page","end"); } } /** * this function create form for edit page */ function edit_page() { if($this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_content","edit_page","start"); $res = $this->CLASS['db']->query(sprintf("SELECT * FROM tree WHERE id=%d",$_SESSION['cid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); echo "[".T_('back')."]

    "; echo "
    "; echo "\n"; echo "
    \n"; echo "\t".T_('edit page')."\n"; echo "
    ".T_('Here you can modify page settings.')."
    \n"; echo "\n"; echo "\n"; // check for rights to show/edit alias if($this->CLASS['vars']['pagealias']['use'] == 1 && (($this->CLASS['vars']['pagealias']['rights'] == 2 && isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) || ($this->CLASS['vars']['pagealias']['rights'] == 1 && $_SESSION['userid'] != 0) || ($this->CLASS['vars']['pagealias']['rights'] == 0))) { echo "\n"; } // check for tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1) { echo "\n"; } if ($this->CLASS['vars']['knowledgeroot']['collapsecontent'] == "yes") { echo "\n"; } $this->CLASS['hooks']->setHook("kr_content","edit_page","show"); echo "\n"; echo "
    ".T_('page name').":
    ".T_('page alias').":
    ".T_('tooltip').":
      ".T_('Initially show all content on this page collapsed?')."
    \n"; // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } //check rights if((!empty($_SESSION['userid']) && $show_rights == 1) || (isset($_SESSION['admin']) && $_SESSION['admin'] == 1)) { $panel = $this->CLASS['knowledgeroot']->editRightPanel("tree",$row['id'],$row['owner'],$row['group'],$row['userrights'].$row['grouprights'].$row['otherrights'],1); if($panel != "") { echo "
    ".T_('pagerights')."\n"; echo $panel; echo "
    \n"; } } if(isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { echo "
    ".T_('pagerights for subpages (inherit rights)')."\n"; echo $this->CLASS['knowledgeroot']->editRightPanelSubInherit("tree",$row['id'],$row['subinheritrights'],$row['subinheritrightseditable'],$row['subinheritrightsdisable'],$row['subinheritowner'],$row['subinheritgroup'],$row['subinherituserrights'],$row['subinheritgrouprights'],$row['subinheritotherrights']); echo "
    \n"; } echo "
    \n"; echo "
    "; } $this->CLASS['hooks']->setHook("kr_content","edit_page","end"); } } /** * this function create form for edit content */ function edit_content() { if($this->CLASS['knowledgeroot']->getContentRights($_GET['eid'],$_SESSION['userid']) == 2) { $this->CLASS['hooks']->setHook("kr_content","edit_content","start"); // save that this content is edited $this->CLASS['knowledgeroot']->openContent($_GET['eid'],$_SESSION['userid']); // show warning if another user is editing this content if($this->CLASS['knowledgeroot']->isOpenContent($_GET['eid'],$_SESSION['userid'])) { echo '
    '.T_('Another user is already editing this content!').'
    '; } // show content //echo "[".$this->CLASS['language']->get['back']."]

    "; echo "
    "; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $res = $this->CLASS['db']->query(sprintf("SELECT * FROM content WHERE id=%d ORDER BY id ASC",$_GET['eid'])); while($row = $this->CLASS['db']->fetch_assoc($res)) { echo "
    "; if ($this->CLASS['vars']['knowledgeroot']['showtitle'] == "yes") echo "
    ".T_('Title of content (optional)')." 
    \n"; $this->CLASS['hooks']->setHook("kr_content","edit_content","show"); echo "
    \n"; // show content in rte editor echo $this->CLASS['rte']->show($row['content']); // check for inheritrights $inheritrights = $this->CLASS['knowledgeroot']->getInheritRights($_SESSION['cid']); $show_rights = 0; if((is_array($inheritrights) && $inheritrights['subinheritrightseditable'] == 1) || $inheritrights == false) { $show_rights = 1; } //check rights if((!empty($_SESSION['userid']) && $show_rights == 1) || (isset($_SESSION['admin']) && $_SESSION['admin'] == 1)) { echo "

    \n"; echo $this->CLASS['knowledgeroot']->editRightPanel("content",$_GET['eid'],$row['owner'],$row['group'],$row['userrights'].$row['grouprights'].$row['otherrights']); } } $this->CLASS['hooks']->setHook("kr_content","edit_content","show_after"); echo "

    \n"; echo "\n"; echo "\n"; echo "\n"; echo "
    \n"; $this->CLASS['hooks']->setHook("kr_content","edit_content","end"); } } /** * this function shows search */ function show_search() { $this->CLASS['hooks']->setHook("kr_content","show_search","start"); if(!isset($_SESSION['search'][$_GET['key']])) $searchword = ""; else $searchword = trim($_SESSION['search'][$_GET['key']]); if($this->CLASS['vars']['knowledgeroot']['charset'] == "utf8") { $charset = "UTF-8"; } else { $charset = $this->CLASS['vars']['knowledgeroot']['charset']; } // searchword in html //$searchwordhtml = @htmlentities($searchword,ENT_NOQUOTES,$charset); // get searchwords $searchword = str_replace('"','\"',$searchword); $originalsearchword = $searchword; preg_match_all('/"(.*)"/U', stripslashes($searchword), $arrSearchGroup); if(isset($arrSearchGroup[1]) && is_array($arrSearchGroup[1])) { // replace groups with empty foreach($arrSearchGroup[1] as $key => $value) { $searchword = str_replace('\"'.$value.'\"','',$searchword); } } $arrSearchWord = explode(" ",$searchword); if(isset($arrSearchGroup[1]) && is_array($arrSearchGroup[1])) { foreach($arrSearchGroup[1] as $key => $value) { array_push($arrSearchWord, $value); } } echo T_('Search for') . " '" . stripslashes($originalsearchword) . "'

    "; // contentsearch echo "

    " . T_('Content') . ":

    \n"; $this->CLASS['hooks']->setHook("kr_content","show_search","content_search_start"); $_SESSION['userid'] = $_SESSION['userid'] == "" ? 0 : $_SESSION['userid']; $_SESSION['groupid'] = $_SESSION['userid'] == "" ? 0 : $_SESSION['groupid']; // create whereclause for search of content $where = ""; foreach($arrSearchWord as $key => $value) { if(trim($value) != '') { $valueHtml = @htmlentities($value,ENT_NOQUOTES,$charset); if($this->CLASS['db']->dbtype == "pgsql") { $where .= sprintf("content ilike '%%%s%%' OR content ilike '%%%s%%' OR title ilike '%%%s%%' OR title ilike '%%%s%%' OR ", $value, $valueHtml, $value, $valueHtml); } else { $where .= sprintf("content like '%%%s%%' OR content like '%%%s%%' OR title like '%%%s%%' OR title like '%%%s%%' OR ", $value, $valueHtml, $value, $valueHtml); } } } $where = substr($where, 0, strlen($where)-3); if(isset($_SESSION['admin']) && $_SESSION['admin'] == 1) { if($this->CLASS['db']->dbtype == "pgsql") { $sql = sprintf("SELECT id,belongs_to,content,title FROM content WHERE (%s) AND deleted=0",$where); } else { $sql = sprintf("SELECT id,belongs_to,content,title FROM content WHERE (%s) AND deleted=0",$where); } } else { // get groups from user $res = $this->CLASS['db']->query(sprintf("SELECT groupid FROM user_group WHERE userid=%d",$_SESSION['userid'])); $orclause = ""; while($rowuser = $this->CLASS['db']->fetch_assoc($res)) { $orclause .= sprintf("OR (c.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND c.grouprights > 0) ",$rowuser['groupid']); $orclause .= sprintf("OR (a.owner_group_id=%d AND a.owner_group='g' AND a.rights > 0) ",$rowuser['groupid']); } // add orclause for userright $orclause .= sprintf("OR (a.owner_group_id=%d AND owner_group='o' AND a.rights > 0) ",$_SESSION['userid']); $sql = sprintf("SELECT c.id,c.belongs_to,c.content,c.title FROM content c LEFT JOIN access a ON a.belongs_to=c.id AND a.table_name='content' WHERE (%s) AND c.deleted=0 AND ((c.otherrights > 0) OR (c.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND c.grouprights > 0) %sOR (c.owner=%d AND c.userrights>0))",$where,$_SESSION['groupid'],$orclause,$_SESSION['userid']); } $res = $this->CLASS['db']->query($sql); $anz = $this->CLASS['db']->num_rows($res); if($anz != 0) { $x = 0; while($row = $this->CLASS['db']->fetch_assoc($res)) { if($this->CLASS['knowledgeroot']->checkRecursivPerm($row['belongs_to'],$_SESSION['userid']) != 0) { echo $this->CLASS['path']->getPath($row['belongs_to']) . " / ". (($row['title'] != "") ? "\"".$row['title']."\" " : "") ."[" . T_('show') . "]
    \n"; $x++; } } if($x == 0) { echo T_('Nothing found') . "
    \n"; } } else { echo T_('Nothing found'); } $this->CLASS['hooks']->setHook("kr_content","show_search","content_search_end"); echo "
    \n"; // tree search echo "

    " . T_('Menu') . ":

    \n"; $this->CLASS['hooks']->setHook("kr_content","show_search","tree_search_start"); // create whereclause for search of tree $where = ""; foreach($arrSearchWord as $key => $value) { if(trim($value) != '') { if($this->CLASS['db']->dbtype == "pgsql") { $where .= sprintf("title ilike '%%%s%%' OR ", $value); } else { $where .= sprintf("title like '%%%s%%' OR ", $value); } } } $where = substr($where, 0, strlen($where)-3); if($this->CLASS['db']->dbtype == "pgsql") { $sql = sprintf("SELECT id,belongs_to,title FROM tree WHERE %s",$where); } else { $sql = sprintf("SELECT id,belongs_to,title FROM tree WHERE %s",$where); } $res = $this->CLASS['db']->query($sql); $anz = $this->CLASS['db']->num_rows($res); if($anz != 0) { $x = 0; while($row = $this->CLASS['db']->fetch_assoc($res)) { if($this->CLASS['knowledgeroot']->checkRecursivPerm($row['id'], $_SESSION['userid']) != 0) { echo $this->CLASS['path']->getPath($row['id']) . "
    \n"; $x++; } } if($x == 0) { echo T_('Nothing found') . "
    \n"; } } else { echo T_('Nothing found') . "
    \n"; } $this->CLASS['hooks']->setHook("kr_content","show_search","tree_search_end"); echo "
    \n"; // file search echo "

    " . T_('Files') . ":

    \n"; $this->CLASS['hooks']->setHook("kr_content","show_search","file_search_start"); // create whereclause for search of tree $where = ""; foreach($arrSearchWord as $key => $value) { if(trim($value) != '') { if($this->CLASS['db']->dbtype == "pgsql") { $where .= sprintf("filename ilike '%%%s%%' OR ", $value); } else { $where .= sprintf("filename like '%%%s%%' OR ", $value); } } } $where = substr($where, 0, strlen($where)-3); if($this->CLASS['db']->dbtype == "pgsql") { $sql = sprintf("SELECT f.id as id,t.id as tid,f.filename,f.filesize, to_char(f.date,'DD.MM.YYYY HH24:MI:SS') AS dateform, f.owner AS owner FROM files f, tree t, content c WHERE f.belongs_to = c.id AND c.belongs_to = t.id AND f.deleted=0 AND %s",$where); } elseif($this->CLASS['db']->dbtype == "sqlite") { $sql = sprintf("SELECT f.id as id,t.id as tid,f.filename,f.filesize, strftime('%%d.%%m.%%Y %%H:%%M:%%S',f.date) AS dateform, f.owner AS owner FROM files f, tree t, content c WHERE f.belongs_to = c.id AND c.belongs_to = t.id AND f.deleted=0 AND %s",$where); } else { $query = "SELECT f.id AS id, t.id AS tid, f.filename, f.filesize, DATE_FORMAT(f.date,'%d.%m.%Y %H:%i:%s') AS dateform, f.owner AS owner FROM (files f, tree t, content c)"; $sql = $query.sprintf(" WHERE f.belongs_to = c.id AND c.belongs_to = t.id AND f.deleted=0 AND %s", $where); } $res = $this->CLASS['db']->query($sql); $anz = $this->CLASS['db']->num_rows($res); if($anz != 0) { $x = 0; while($row = $this->CLASS['db']->fetch_assoc($res)) { // get file information $title = ""; if($row['owner'] == NULL || $row['owner'] == 0 || $row['owner'] == "") { $title = $row['dateform']; } else { $title = $this->CLASS['knowledgeroot']->getOwner($row['owner']) . " - " . $row['dateform']; } // show file if($this->CLASS['knowledgeroot']->checkRecursivPerm($row['tid'], $_SESSION['userid']) != 0) { echo $this->CLASS['path']->getPath($row['tid']) . " /\n"; echo " ".$row['filename']." [".getfilesize($row['filesize'])."] [".$title."]
    \n"; $x++; } } if($x == 0) { echo T_('Nothing found') . "
    \n"; } } else { echo T_('Nothing found') . "
    \n"; } $this->CLASS['hooks']->setHook("kr_content","show_search","file_search_end"); $this->CLASS['hooks']->setHook("kr_content","show_search","end"); } /** * form for login */ function show_login() { $this->CLASS['hooks']->setHook("kr_content","show_login","start"); echo '
    '.T_('login').'
    '; $this->CLASS['hooks']->setHook("kr_content","show_login","before_submit"); echo ' '; $this->CLASS['hooks']->setHook("kr_content","show_login","after_submit"); echo '
    Login
    '.T_('user').':
    '.T_('password').':
    '; echo ''."\n"; $this->CLASS['hooks']->setHook("kr_content","show_login","end"); } /** * form for create root */ function create_root() { $this->CLASS['hooks']->setHook("kr_content","create_root","start"); // rechte checken -> adminrechte echo '

    '.T_('create root').'

    '.T_('create root').' '; echo ' '; // check for tooltip if($this->CLASS['vars']['menu']['edittooltiptext'] == 1) { echo ' '; } echo '
    '.T_('name').':
    '.T_('alias').':
    '.T_('tooltip').':

    '; if(!empty($_SESSION['userid'])) { echo "

    ".T_('pagerights')."\n"; echo $this->CLASS['knowledgeroot']->rightpanel($_SESSION['userid']); echo "
    \n"; echo "
    ".T_('pagerights for subpages (inherit rights)')."\n"; echo $this->CLASS['knowledgeroot']->rightpanelsubinherit($_SESSION['userid']); echo "
    \n"; } echo '
    '; $this->CLASS['hooks']->setHook("kr_content","create_root","end"); } /** * form for options */ function show_options() { $this->CLASS['hooks']->setHook("kr_content","show_options","start"); echo '

    '.T_('options').'

    '.T_('change options').'
    '.T_('new password').':
    '.T_('confirm password').':
    '.T_('theme').':'.$this->CLASS['themes']->theme_dropdown($_SESSION['theme']).'
    '.T_('language').':'.$this->CLASS['language']->lang_dropdown("language",$_SESSION['language']).'
    '; $this->CLASS['hooks']->setHook("kr_content","show_options","end"); } /** * list users */ function list_users() { $this->CLASS['hooks']->setHook("kr_content","list_users","start"); // list users echo '

    '.T_('user').'

    ['.T_('add user').']
    '; $res = $this->CLASS['db']->query("SELECT * FROM users ORDER BY name"); while($row = $this->CLASS['db']->fetch_assoc($res)) { echo " \n"; } echo '
    '.T_('name').' '.T_('default group').' '.T_('default rights').' '.T_('admin').' '.T_('edit rights').' '.T_('enabled').' '.T_('action').'
    ".$row['name']." ".$this->CLASS['knowledgeroot']->getGroup($row['defaultgroup'])." ".$row['defaultrights']." ".$this->CLASS['knowledgeroot']->yesno($row['admin'])." ".$this->CLASS['knowledgeroot']->yesno($row['rightedit'])." ".$this->CLASS['knowledgeroot']->yesno($row['enabled'])." [".T_('edit')."] [".T_('delete')."]
    '; // list groups echo '

    '.T_('groups').'

    ['.T_('add group').']
    '; $res = $this->CLASS['db']->query("SELECT * FROM groups ORDER BY name"); while($row = $this->CLASS['db']->fetch_assoc($res)) { echo " \n"; } echo '
    '.T_('name').''.T_('action').'
    ".$row['name']." [".T_('edit')."] [".T_('delete')."]
    '; $this->CLASS['hooks']->setHook("kr_content","list_users","end"); } /** * add user */ function add_user() { $this->CLASS['hooks']->setHook("kr_content","add_user","start"); echo '

    '.T_('add user').'

    '.T_('new user').' '; $this->CLASS['hooks']->setHook("kr_content","add_user","show"); echo '
    '.T_('name').':
    '.T_('password').':
    '.T_('theme').': ' . $this->CLASS['themes']->theme_dropdown() . '
    '.T_('default group').': ' . $this->CLASS['knowledgeroot']->groupdropdown("defaultgroup") . '
    '.T_('admin').': ' . $this->CLASS['knowledgeroot']->yesnodropdown("admin") . '
    '.T_('edit rights').': ' . $this->CLASS['knowledgeroot']->yesnodropdown("rightedit") . '
    '.T_('enabled').': ' . $this->CLASS['knowledgeroot']->yesnodropdown("enabled") . '
    '.T_('groups').': ' . $this->CLASS['knowledgeroot']->groupDropDown("groups[]","",true) . '
    '.T_('default rights').':
     '.T_('user').': '.$this->CLASS['knowledgeroot']->rightDropDown("userrights",2).'
     '.T_('group').': '.$this->CLASS['knowledgeroot']->rightDropDown("grouprights",1).'
     '.T_('others').': '.$this->CLASS['knowledgeroot']->rightDropDown("otherrights",1).'
    '; echo ''."\n"; $this->CLASS['hooks']->setHook("kr_content","add_user","end"); } /** * edit user */ function edit_user() { $this->CLASS['hooks']->setHook("kr_content","edit_user","start"); $res = $this->CLASS['db']->query(sprintf("SELECT * FROM users WHERE id=%d",$_GET['uid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); //fetch groups $res = $this->CLASS['db']->query(sprintf("SELECT * FROM user_group WHERE userid=%d",$row['id'])); $x = 0; $grouparr = array(); while($rowgroup = $this->CLASS['db']->fetch_assoc($res)) { $grouparr[$x] = $rowgroup['groupid']; $x++; } echo '

    '.T_('edit user').'

    '.T_('edit user').' '; $this->CLASS['hooks']->setHook("kr_content","edit_user","show"); echo '
    '.T_('name').':
    '.T_('password').':
    '.T_('theme').': ' . $this->CLASS['themes']->theme_dropdown($row['theme']) . '
    '.T_('default group').': ' . $this->CLASS['knowledgeroot']->groupdropdown("defaultgroup",$row['defaultgroup']) . '
    '.T_('admin').': ' . $this->CLASS['knowledgeroot']->yesnodropdown("admin", $row['admin']) . '
    '.T_('edit rights').': ' . $this->CLASS['knowledgeroot']->yesnodropdown("rightedit",$row['rightedit']) . '
    '.T_('enabled').': ' . $this->CLASS['knowledgeroot']->yesnodropdown("enabled",$row['enabled']) . '
    '.T_('groups').': ' . $this->CLASS['knowledgeroot']->groupDropDown("groups[]","",true,$grouparr) . '
    '.T_('default rights').':
      '.T_('user').': '.$this->CLASS['knowledgeroot']->rightDropDown("userrights",substr($row['defaultrights'],0,1)).'
      '.T_('group').': '.$this->CLASS['knowledgeroot']->rightDropDown("grouprights",substr($row['defaultrights'],1,1)).'
      '.T_('others').': '.$this->CLASS['knowledgeroot']->rightDropDown("otherrights",substr($row['defaultrights'],2,1)).'
    '; } $this->CLASS['hooks']->setHook("kr_content","edit_user","end"); } /** * add group */ function add_group() { $this->CLASS['hooks']->setHook("kr_content","add_group","start"); echo '

    '.T_('add group').'

    '.T_('add group').'
    '; $this->CLASS['hooks']->setHook("kr_content","add_group","show"); echo '
    '.T_('name').':
    '; echo ''."\n"; $this->CLASS['hooks']->setHook("kr_content","add_group","end"); } /** * edit group */ function edit_group() { $this->CLASS['hooks']->setHook("kr_content","edit_group","start"); $res = $this->CLASS['db']->query(sprintf("SELECT * FROM groups WHERE id=%d",$_GET['gid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); echo '

    '.T_('edit group').'

    '.T_('edit group').'
    '; $this->CLASS['hooks']->setHook("kr_content","edit_group","show"); echo '
    '.T_('name').':
    '; } $this->CLASS['hooks']->setHook("kr_content","edit_group","end"); } /** * show tree content */ function show_tree_content($count = 0) { // check if page is a symlink $res = $this->CLASS['db']->query(sprintf("SELECT symlink FROM tree WHERE id=%d",$_SESSION['cid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); if($row['symlink'] != "" && $row['symlink'] != 0) { $_SESSION['orginial_cid'] = $_SESSION['cid']; $_SESSION['cid'] = $row['symlink']; } } // isTree removed for symlink //if($_SESSION['cid'] != "" && $this->CLASS['path']->isTree($_SESSION['cid']) && $this->CLASS['knowledgeroot']->checkRecursivPerm($_SESSION['cid'], $_SESSION['userid']) != 0) { if($_SESSION['cid'] != "" && $this->CLASS['knowledgeroot']->checkRecursivPerm($_SESSION['cid'], $_SESSION['userid']) != 0) { $this->CLASS['hooks']->setHook("kr_content","show_tree_content","start"); // get my rights - possible is 0,1,2 $mypagerights = $this->CLASS['knowledgeroot']->getPageRights($_SESSION['cid'],$_SESSION['userid']); $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_page_menu_start"); // show page menu echo $this->CLASS['kr_extension']->show_menu("page", $_SESSION['cid'], $mypagerights); $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_page_menu_end"); //check if userid and groupid is set, if not set to 0 if($_SESSION['userid'] == "" || $_SESSION['groupid'] == "") { $_SESSION['userid'] = 0; $_SESSION['groupid'] = 0; } // get page content collapse info $res = $this->CLASS['db']->query(sprintf("SELECT contentcollapsed FROM tree WHERE id=%d",$_SESSION['cid'])); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $treedata = $this->CLASS['db']->fetch_assoc($res); } // select the content in table content with userrights //if (isset ($_SESSION['admin']) and $_SESSION['admin'] == 1) { // always go this way because of multiple rights if(1) { if($this->CLASS['db']->dbtype == "pgsql") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, to_char(ct.lastupdated,'DD.MM.YYYY HH24:MI:SS') as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC",$_SESSION['cid']); } elseif($this->CLASS['db']->dbtype == "sqlite") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, strftime('%%d.%%m.%%Y %%H:%%M:%%S',ct.lastupdated) as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC",$_SESSION['cid']); } else { $query = "SELECT ct.id AS id, ct.content AS content, ct.title AS title, ct.type AS type, u.name AS lastupdatedby, DATE_FORMAT(ct.lastupdated,'%d.%m.%Y %H:%i:%s') as lastupdated FROM content ct"; $query .= sprintf(" LEFT OUTER JOIN users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 ORDER BY ct.sorting ASC", $_SESSION['cid']); } } else { // get groups from user $res = $this->CLASS['db']->query(sprintf("SELECT groupid FROM user_group WHERE userid=%d",$_SESSION['userid'])); $orclause = ""; while($rowuser = $this->CLASS['db']->fetch_assoc($res)) { $orclause .= sprintf("OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) ",$rowuser['groupid']); } if($this->CLASS['db']->dbtype == "pgsql") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, to_char(ct.lastupdated,'DD.MM.YYYY HH24:MI:SS') as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %sOR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC",$_SESSION['cid'],$_SESSION['groupid'],$orclause,$_SESSION['userid']); } elseif($this->CLASS['db']->dbtype == "sqlite") { $query = sprintf("SELECT ct.id as id, ct.content as content, ct.title as title, ct.type as type, u.name as lastupdatedby, strftime('%%d.%%m.%%Y %%H:%%M:%%S',ct.lastupdated) as lastupdated FROM content ct left outer join users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %sOR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC",$_SESSION['cid'],$_SESSION['groupid'],$orclause,$_SESSION['userid']); } else { $query = "SELECT ct.id AS id, ct.content AS content, ct.title AS title, ct.type AS type, u.name AS lastupdatedby, DATE_FORMAT(ct.lastupdated,'%d.%m.%Y %H:%i:%s') AS lastupdated FROM content ct"; $query .= sprintf(" LEFT OUTER JOIN users u ON ct.lastupdatedby = u.id WHERE belongs_to=%d AND ct.deleted=0 AND ((ct.otherrights > 0) OR (ct.".$this->CLASS['db']->quoteIdentifier("group")."=%d AND ct.grouprights > 0) %s OR (ct.owner=%d AND ct.userrights>0)) ORDER BY ct.sorting ASC", $_SESSION['cid'], $_SESSION['groupid'], $orclause,$_SESSION['userid']); } } $res = $this->CLASS['db']->query($query); $anz = $this->CLASS['db']->num_rows($res); // needed for up and down arrows $firstcontent = 1; $maxcontent = $anz; $contentcounter = 0; // check if some table is on the page if($anz != 0) { while($row = $this->CLASS['db']->fetch_assoc($res)) { // check if it is an extension and if it is enabled if(($row['type'] != "" && $row['type'] != "text") && (!isset($this->CLASS['extension'][$row['type']]) || (isset($this->CLASS['extension'][$row['type']]) && $this->CLASS['extension'][$row['type']]['init'] == FALSE))) { $maxcontent--; continue; } $contentcounter++; if ($row['title'] == null || $row['title'] == "") { if($row['type'] == "" || $row['type'] == "text") { //$contentType = "HTML/text"; $contentType = ''; } else { $contentType = $row['type'] . " " . "content"; } $titleText = $contentType; } else { $titleText = $row['title']; } // init booleans $show_files = 1; $showtitle = ($this->CLASS['vars']['knowledgeroot']['showtitle'] == "yes"); $collapse = ($this->CLASS['vars']['knowledgeroot']['collapsecontent'] == "yes"); $showlastupdated = ($this->CLASS['vars']['knowledgeroot']['showlastupdated'] == "yes"); // get content rights $mycontentrights = $this->CLASS['knowledgeroot']->getContentRights($row['id'],$_SESSION['userid']); $mousecontext = ""; // check if contextmenu are enabled if($this->CLASS['vars']['menu']['context'] == 1) { // set mousecontext for rightclick menu $mousecontext = " oncontextmenu=\"KnowledgerootMenu.show('mousemenu','contentcontext', ".$_SESSION['cid'].", ".$row['id']."); return false;\""; } echo "
    \n
    \n"; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_title_start"); // display content header based on configuration if ($collapse) echo " \n"; if ($collapse && $showtitle) echo ""; if (isset($this->CLASS['vars']['content']['showcounter']) && $this->CLASS['vars']['content']['showcounter'] == 1) echo "" . $contentcounter . "."; if ($showtitle) echo "".$titleText.""; if ($collapse && $showtitle) echo "\n"; if ($showlastupdated) echo "   (".T_('Last modified by')." ". ($row['lastupdatedby'] != null ? $row['lastupdatedby'] : T_('guest')) ." ".T_('on')." ".$row['lastupdated'].")\n"; if (!$collapse && !$showtitle && !$showlastupdated) echo " "; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_title_end"); echo "
    \n"; if ($collapse) { echo "\n"; } // check if content is an extension if($row['type'] == "" || $row['type'] == "text") { // show content $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_content_start"); // adding colored highlighting if(isset($_GET['highlight']) && $_GET['highlight'] != "") { $highlight = str_replace('"','\"',$_GET['highlight']); $highlight = explode(",", $highlight); foreach($highlight as $hkey => $hvalue) { $hvalue = preg_replace('/[^a-zA-Z0-9 \-_]/mu', '', $hvalue); //$row['content'] = preg_replace("/(.*)(".$hvalue.")(.*)/mUu","$1$2$3",$row['content']); $row['content'] = $this->CLASS['highlight']->str_highlight($row['content'], $hvalue, $this->CLASS['highlight']->STR_HIGHLIGHT_STRIPLINKS, '\1'); } } echo "\n"; echo "
    \n"; echo $row['content']; echo "
    \n"; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_content_end"); } else { // check if extension is loaded if(isset($this->CLASS['extension'][$row['type']]) and $this->CLASS['extension'][$row['type']]['init'] == TRUE) { $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_extension_start"); // run extension echo $this->CLASS['extension'][$row['type']]['class']->show_content($row['id']); $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_extension_end"); // check if added files should be shown if($this->CLASS['extension'][$row['type']]['class']->show_addedfiles != 1) { $show_files = 0; } } else { $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_extension_not_loaded"); continue; } } echo "
    \n"; if($show_files == 1) { $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_content_files_start"); // select added files if($this->CLASS['db']->dbtype == "pgsql") { $result = $this->CLASS['db']->query(sprintf("SELECT id,filename,filesize,owner, to_char(date,'DD. Mon YYYY HH24:MI:SS') AS dateform FROM files WHERE belongs_to=%d AND deleted=0 ORDER BY id ASC",$row['id'])); } elseif($this->CLASS['db']->dbtype == "sqlite") { $result = $this->CLASS['db']->query(sprintf("SELECT id,filename,filesize,owner, strftime('%%d.%%m.%%Y %%H:%%M:%%S',date) AS dateform FROM files WHERE belongs_to=%d AND deleted=0 ORDER BY id ASC",$row['id'])); } else { $query = "SELECT id,filename,filesize,owner, DATE_FORMAT(date,'%d. %M %Y %H:%i:%s') AS dateform FROM files"; $query .= sprintf(" WHERE belongs_to=%d AND deleted=0 ORDER BY id ASC", $row['id']); $result = $this->CLASS['db']->query($query); } // read all select files while($zeile = $this->CLASS['db']->fetch_assoc($result)) { $title = ""; if($zeile['owner'] == NULL || $zeile['owner'] == 0 || $zeile['owner'] == "") { $title = $zeile['dateform']; } else { $title = $this->CLASS['knowledgeroot']->getOwner($zeile['owner']) . " - " . $zeile['dateform']; } // check for static file download if(isset($this->CLASS['vars']['downloads']['static']) && $this->CLASS['vars']['downloads']['static'] == 1) { $downloadlink = "download/".$zeile['id']."/".$zeile['filename']; } else { $downloadlink = "index.php?download=".$zeile['id']; } if($mycontentrights == 2) { echo "  ".$zeile['filename']." [".getfilesize($zeile['filesize'])."] [".$title."]
    \n"; } else { echo " ".$zeile['filename']." [".getfilesize($zeile['filesize'])."] [".$title."]
    \n"; } } $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_content_files_end"); } $includeFileLink = false; if($show_files == 1) { // show form for adding new files if($mycontentrights == 2) { $includeFileLink = true; echo "
    \n ".T_('add file')."\n  \n
    "; } } echo '
    '; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_content_menu_start"); // show content menu echo $this->CLASS['kr_extension']->show_menu("content",$row['id'],$mypagerights,$mycontentrights,$row['type']); $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_content_menu_end"); echo "
    \n"; echo "
    \n"; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_contentline_menu_start"); // show contentline menu echo $this->CLASS['kr_extension']->show_menu("contentline",$row['id'],$mypagerights,$mycontentrights,$row['type']); $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_contentline_menu_end"); echo "
    "; if($mycontentrights == 2 && $mypagerights == 2) { if ($maxcontent != $contentcounter) { echo "\n"; } if ($firstcontent != 1) { echo "\n"; } $firstcontent = 0; } echo "

    \n"; } // end of while $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_page_menu_start"); // show page menu if($contentcounter != 0) echo $this->CLASS['kr_extension']->show_menu("page", $_SESSION['cid'], $mypagerights); $this->CLASS['hooks']->setHook("kr_content","show_tree_content","show_page_menu_end"); echo "

    "; } else { $this->CLASS['hooks']->setHook("kr_content","show_tree_content","no_content_start"); // show notification if no content is present echo "

    " . T_('No content here.') . "

    \n"; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","no_content_end"); } // form for move page echo "
    \n"; echo "\n"; echo "\n"; echo "\n"; // use for move pagecontent echo "
    \n"; } else { $this->CLASS['hooks']->setHook("kr_content","show_tree_content","welcome_msg_start"); // show welcome message echo "
    ".T_('Welcome to Knowledgeroot')."
    \n"; $this->CLASS['hooks']->setHook("kr_content","show_tree_content","welcome_msg_end"); } // check if symlink was set if(isset($_SESSION['original_cid']) && $_SESSION['original_cid'] != "") { $_SESSION['cid'] = $_SESSION['original_cid']; $_SESSION['original_cid'] = ""; } $this->CLASS['hooks']->setHook("kr_content","show_tree_content","end"); } } ?> knowledgeroot-0.9.9.5/include/class-sqlite.php0000644000175000017500000000702211000753003022271 0ustar fhabermannfhabermannCLASS['vars']['db']['pconnect']) && $this->CLASS['vars']['db']['pconnect'] == 1) { $this->connection = sqlite_popen($db, $this->mode); } else { $this->connection = sqlite_open($db, $this->mode); } if(!$this->connection) { $this->CLASS['error']->log("Cannnot connect to host!",1,"class-sqlite.php::connect"); exit(); } return $this->connection; } /** * Close mysql connection * @return bool */ function close() { return sqlite_close($this->connection); } /** * Will make a query with the mysql server * @param string $query * @return mixed return query result */ function query($query) { $this->lastquery = $query; $this->query_cache[] = $query; $this->querys += 1; $res = new db_result($this->CLASS); $res->setQuery($query); $res->setResult(sqlite_query($query, $this->connection)); if($res->getResult() === false) { $this->CLASS['error']->log("ERROR IN QUERY: \"$query\"",1,sqlite_errno() . ":".sqlite_errno()); } return $res; } /** * Will count the rows of a resultset * @param mixed $result * @return int */ function num_rows($result) { return sqlite_num_rows($result->getResult()); } function _cleanName($array) { if(is_array($array)) { foreach ($array as $key => $value) { unset($array[$key]); if(strpos($key, '.') > 0) { $key = substr($key, strpos($key, '.')+1); } $array[$key] = $value; } } return $array; } /** * Fetch a Result as Object * @param mixed $result * @return object */ function fetch_object($result) { return sqlite_fetch_object($result->getResult()); } /** * Return Result as Array * @param mixed $result * @return array */ function fetch_row($result) { $row = sqlite_fetch_array($result->getResult(), SQLITE_NUM); return $this->_cleanName($row); } /** * Return Result as hash array * @param mixed result * @return array */ function fetch_assoc($result) { $row = sqlite_fetch_array($result->getResult(), SQLITE_ASSOC); return $this->_cleanName($row); } /** * Return affected rows of a result * @param mixed $result * @return int */ function affected_rows($result) { return false; } /** * Returns the text of the error message from previous MySQL operation * @return string */ function error() { return sqlite_last_error($this->connection); } /** * Return the last inserted id from a query * @param string $name not required * @return int */ function last_id($name = "") { return sqlite_last_insert_rowid($this->connection); } /** * Quote a String with Mysql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return "\"" . $string . "\""; } /** * do data seek on result * @param resource $result * @param integer $number * @return bool */ function data_seek($result, $number) { return sqlite_seek($result->getResult(), $number); } } ?> knowledgeroot-0.9.9.5/include/init.php0000644000175000017500000002007711224217213020643 0ustar fhabermannfhabermannstart($CLASS); // define runtimer $CLASS['runtime'] = new runtime(); // set base paths $CLASS['vars']['base_path'] = $base_path; // load databaseclass if($CLASS['vars']['db']['type'] == "mysql") { require_once($base_path."include/class-mysql.php"); } if($CLASS['vars']['db']['type'] == "mysqli") { require_once($base_path."include/class-mysqli.php"); } if($CLASS['vars']['db']['type'] == "pgsql") { require_once($base_path."include/class-pgsql.php"); } if($CLASS['vars']['db']['type'] == "mdb2") { require_once($base_path."include/class-mdb2.php"); } if($CLASS['vars']['db']['type'] == "sqlite") { require_once($base_path."include/class-sqlite.php"); } if($CLASS['vars']['db']['type'] == "oracle") { require_once($base_path."include/class-oracle.php"); } if(isset($KNOWLEDGEROOTDB) && $KNOWLEDGEROOTDB != "PGSQL" && $KNOWLEDGEROOTDB != "MYSQL" && $KNOWLEDGEROOTDB != "MDB2" && $KNOWLEDGEROOTDB != "SQLITE" && $KNOWLEDGEROOTDB != "OCI") { echo "WRONG DBTYPE SELECTED!\n"; exit(); } // init hooks $CLASS['hooks'] = new hooks(); $CLASS['hooks']->start($CLASS); // init error $CLASS['auth'] = new knowledgeroot_auth(); $CLASS['auth']->start($CLASS); // init databaseclass $CLASS['db'] = new db(); $CLASS['db']->start($CLASS); // connect to database $CLASS['db']->connect($CLASS['vars']['db']['host'],$CLASS['vars']['db']['user'],$CLASS['vars']['db']['pass'],$CLASS['vars']['db']['database'],$CLASS['vars']['db']['schema'],$CLASS['vars']['db']['encoding']); // init knowledgerootclass $CLASS['knowledgeroot'] = new knowledgeroot(); $CLASS['knowledgeroot']->start($CLASS); // addslashes on GET/POST/COOKIE/REQUEST/SERVER $CLASS['knowledgeroot']->addSlashesOnArray($_GET); $CLASS['knowledgeroot']->addSlashesOnArray($_POST); $CLASS['knowledgeroot']->addSlashesOnArray($_COOKIE); $CLASS['knowledgeroot']->addSlashesOnArray($_REQUEST); $CLASS['knowledgeroot']->addSlashesOnArray($_SERVER); // load config from db $CLASS['vars'] = $CLASS['knowledgeroot']->replace_array($CLASS['vars'], $CLASS['knowledgeroot']->getConfigArr()); // init session $CLASS['session'] = new session(); $CLASS['session']->start($CLASS); $CLASS['session']->startSession(md5($CLASS['vars']['baseurl'])); if(!$CLASS['session']->checkSession()) { die("SESSION WAS WRONG!"); } // PHP-Gettext start define('LOCALE_DIR', $base_path.'system/language'); require_once ($base_path."system/php-gettext/gettext.inc.php"); if ($CLASS['vars']['knowledgeroot']['charset'] != '') { $encoding = $CLASS['vars']['knowledgeroot']['charset']; } else { $encoding = 'utf-8'; } if ($CLASS['vars']['knowledgeroot']['language'] != '') { define('DEFAULT_LOCALE', $CLASS['vars']['knowledgeroot']['language']); } else { define('DEFAULT_LOCALE', 'en'); } $locale = (isset($_SESSION['language']))? $_SESSION['language'] : DEFAULT_LOCALE; // gettext setup putenv('LANG='.$locale); T_setlocale(LC_ALL, $locale); // Set the text domain as 'knowledgeroot' $domain = 'knowledgeroot'; T_bindtextdomain($domain, LOCALE_DIR); // bind_textdomain_codeset is supported only in PHP 4.2.0+ if (function_exists('T_bind_textdomain_codeset')) T_bind_textdomain_codeset($domain, $encoding); T_textdomain($domain); // PHP-Gettext end // init language $CLASS['language'] = new language(); $CLASS['language']->start($CLASS,$CLASS['vars']['knowledgeroot']['language']); // init themes $CLASS['themes'] = new knowledgeroot_themes(); $CLASS['themes']->start($CLASS); // init email notification class $CLASS['notification'] = new knowledgeroot_notification($CLASS); // check for safari and konqueror // this is a short fix beacause the ajaxtree does not work in opera and konqueror if($CLASS['vars']['menu']['ajax'] == "yes") { if(isset($_SERVER['HTTP_USER_AGENT']) && (preg_match("/.*[Kk]onqueror.*/",$_SERVER['HTTP_USER_AGENT']) || preg_match("/.*[Ss]afari.*/",$_SERVER['HTTP_USER_AGENT']))) { $CLASS['vars']['menu']['ajax'] = "no"; } } // load rte editor class $CLASS['rte'] = new rte($CLASS); // load string-highlight class $CLASS['highlight'] = new highlight(); // load extensions $CLASS['kr_extension'] = new knowledgeroot_extension(); $CLASS['kr_extension']->start($CLASS); // init tree $CLASS['tree'] = new categoryTree(); $CLASS['tree']->start($CLASS); // init tree_path $CLASS['path'] = new pathTree(); $CLASS['path']->start($CLASS); // init header $CLASS['kr_header'] = new knowledgeroot_header(); $CLASS['kr_header']->start($CLASS); // init content $CLASS['kr_content'] = new knowledgeroot_content(); $CLASS['kr_content']->start($CLASS); // start all extensions $CLASS['kr_extension']->start_extensions(); // check header variables $CLASS['kr_header']->check_vars(); // check if site is a download $CLASS['kr_header']->check_download(); // load default menu $CLASS['default_menu'] = new default_menu(); $CLASS['default_menu']->start($CLASS); // add javascript to htmlheader if(!isset($CONFIG['include_prefix'])) { $CONFIG['include_prefix'] = ""; } $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/prototype.js"); $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/scriptaculous.js"); //$CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/effects.js"); //$CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/dragdrop.js"); $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/showhide.js"); $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/ajax-tree.js"); $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/messagebox.js"); // check if contextmenus are enabled if($CLASS['vars']['menu']['context'] == 1) { // load js for contextmenus $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/knowledgeroot-menu.js"); } // add js for dragbox if dragdrop is enabled if($CLASS['vars']['menu']['dragdrop'] == "1") { $CLASS['kr_header']->addjssrc($CONFIG['include_prefix']."system/javascript/dragbox.js"); } // add loadingmessage for messagebox $CLASS['kr_header']->addjs("var msgboxloading = '".T_('loading...')."';"); // add theme $CLASS['kr_header']->addcsssrc($CLASS['themes']->load_theme()); // add favicon pointer $CLASS['kr_header']->addheader(""); // add generator if(isset($version)) $CLASS['kr_header']->addheader(""); // add hook $CLASS['hooks']->setHook("init","init","end"); ?> knowledgeroot-0.9.9.5/include/class-oracle.php0000644000175000017500000000604111004170021022232 0ustar fhabermannfhabermannCLASS['vars']['db']['pconnect']) && $this->CLASS['vars']['db']['pconnect'] == 1) { $this->connection = oci_pconnect($user, $pass, $db, $encoding); } else { $this->connection = oci_connect($user, $pass, $db, $encoding); } if(!$this->connection) { $this->CLASS['error']->log("Cannnot connect to host!",1,"class-oracle.php::connect"); exit(); } return $this->connection; } /** * Close oracle connection * @return bool */ function close() { return oci_close($this->connection); } /** * Will make a query with the oracle server * @param string $query * @return mixed return query result */ function query($query) { $this->lastquery = $query; $this->query_cache[] = $query; $this->querys += 1; $res = new db_result($this->CLASS); $res->setQuery($query); $res->setResult(oci_parse($this->connection, $query)); oci_execute($res->getResult()); // if error in query if($res->getResult() === false) { //$this->CLASS['error']->log("ERROR IN QUERY: \"$query\"",1,oci_last_error($this->connection)); } return $res; } /** * Will count the rows of a resultset * @param mixed $result * @return int */ function num_rows($result) { return oci_num_rows($result->getResult()); } /** * Fetch a Result as Object * @param mixed $result * @return object */ function fetch_object($result) { return oci_fetch_object($result->getResult()); } /** * Return Result as Array * @param mixed $result * @return array */ function fetch_row($result) { return oci_fetch_row($result->getResult()); } /** * Return Result as hash array * @param mixed result * @return array */ function fetch_assoc($result) { return oci_fetch_assoc($result->getResult()); } /** * Return affected rows of a result * @param mixed $result * @return int */ function affected_rows($result) { return null; } /** * Returns the text of the error message from previous oracle operation * @return string */ function error() { return null; } /** * Return the last inserted id from a query * @param string $name not required * @return int */ function last_id($name) { $res = $this->query("select last_value FROM $name"); $row = $this->fetch_assoc($res); return $row['last_value']; } /** * Quote a String with Postgresql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return "\"" . $string . "\""; } } ?> knowledgeroot-0.9.9.5/include/class-pgsql.php0000644000175000017500000001123711000753003022121 0ustar fhabermannfhabermannCLASS['vars']['db']['pconnect']) && $this->CLASS['vars']['db']['pconnect'] == 1) { $this->connection = pg_pconnect("host=$host dbname=$db user=$user password=$pass"); } else { $this->connection = pg_connect("host=$host dbname=$db user=$user password=$pass"); } if(!$this->connection) { $this->CLASS['error']->log("Cannnot connect to host!",1,"class-pgsql.php::connect"); exit(); } if(!$this->schema($schema)) { $this->CLASS['error']->log("Could not set schema!",1,"class-pgsql.php::connect"); exit(); } if($this->set_client_encoding($encoding) == -1) { $this->CLASS['error']->log("Could not set client encoding!",1,"class-pgsql.php::connect"); exit(); } return $this->connection; } /** * Close postgresql connection * @return bool */ function close() { return pg_close($this->connection); } /** * Set schema that should we use for the session * @param string $schema * @return resource */ function schema($schema = "") { if($schema != "") { $res = $this->query("SET search_path TO ".$schema); return $res; } return true; } /** * Set client encoding * @param string $encoding * @return int 0 on success or -1 on error */ function set_client_encoding($encoding = "") { if($encoding != "") { return pg_set_client_encoding($this->connection, $encoding); } return 0; } /** * Will make a query with the postgresql server * @param string $query * @return mixed return query result */ function query($query) { $this->lastquery = $query; $this->query_cache[] = $query; $this->querys += 1; $res = new db_result($this->CLASS); $res->setQuery($query); $res->setResult(pg_query($this->connection, $query)); // if error in query if($res->getResult() === false) { $this->CLASS['error']->log("ERROR IN QUERY: \"$query\"",1,pg_last_error($this->connection)); } return $res; } /** * Will count the rows of a resultset * @param mixed $result * @return int */ function num_rows($result) { return pg_num_rows($result->getResult()); } /** * Fetch a Result as Object * @param mixed $result * @return object */ function fetch_object($result) { return pg_fetch_object($result->getResult()); } /** * Return Result as Array * @param mixed $result * @return array */ function fetch_row($result) { return pg_fetch_row($result->getResult()); } /** * Return Result as hash array * @param mixed result * @return array */ function fetch_assoc($result) { return pg_fetch_assoc($result->getResult()); } /** * Return affected rows of a result * @param mixed $result * @return int */ function affected_rows($result) { return pg_affected_rows($this->connection, $result->getResult()); } /** * Returns the text of the error message from previous PostgreSQL operation * @return string */ function error() { return pg_last_error($this->connection); } /** * */ function lo_open($oid,$mode) { return pg_lo_open($this->connection,$oid,$mode); } /** * */ function lo_close($handle) { return pg_lo_close($handle); } /** * */ function lo_read_all($handle) { return pg_lo_read_all($handle); } /** * */ function lo_create() { return pg_lo_create($this->connection); } /** * */ function lo_write($handle,$buffer) { return pg_lo_write($handle,$buffer); } /** * */ function lo_unlink($oid) { return pg_lo_unlink($this->connection,$oid); } /** * Return the last inserted id from a query * @param string $name not required * @return int */ function last_id($name) { $res = $this->query("select last_value FROM $name"); $row = $this->fetch_assoc($res); return $row['last_value']; } /** * Quote a String with Postgresql Quotes * @param string $name * @return string */ function quoteIdentifier($string) { return "\"" . $string . "\""; } /** * do data seek on result * @param resource $result * @param integer $number * @return bool */ function data_seek($result, $number) { return pg_result_seek($result->getResult(), $number); } } ?> knowledgeroot-0.9.9.5/include/class-knowledgeroot-auth.php0000644000175000017500000001345110775516235024643 0ustar fhabermannfhabermann X */ var $CLASS; /** * Benutzername * @access protected */ var $user = ''; /** * Benutzer-ID * @access protected */ var $userid = 0; /** * lasttrydate * mittels PHP-Funktion time() gespeicherter Wert * @access protected */ var $lasttrydate = 0; /** * Wartezeit * Wird bei fehlerhaften Login gesetzt, wenn die Zeit zwischen erstem * Versuch und zweitem Versuch < lasttrydate + $CONFIG['login']['delay'] ist. * @access protected */ var $wartezeit = false; /** * Account Sperre * Ist $this->login_trial >= $this->CLASS['vars']['login']['max'] wird kein Login * mehr ermoeglicht. * @access protected */ var $loginblock = false; /** * Loginversucheszaehler * @access protected */ var $login_trial = 0; /** * garbage collector time * entrys in table 'users_login' will be delete after * this time: * time() - ($this->gc_time + $this->CLASS['vars']['login']['delay']) * * @access private * @param int time in seconds */ var $gc_time = 6000; /** * init/start class */ function start(&$CLASS) { $this->CLASS =& $CLASS; } /** * check login * * @public * @return boolean */ function login() { $this->user = $_POST['user']; // war der Benutzer fr�her schon mal angemeldet, // pruefe lasttrydate if ($this->checkUsersLogin()) { if ($this->lasttrydate + $this->CLASS['vars']['login']['delay'] > time() and $this->login_trial > 0) { $this->wartezeit = true; return false; } if ($this->login_trial >= $this->CLASS['vars']['login']['max']) { $this->loginblock = true; return false; } } $user = addslashes($this->user); $pass = md5(addslashes($_POST['password'])); $query = sprintf("SELECT id, defaultgroup, admin, rightedit, treecache, theme, language FROM users WHERE name='%s' AND password='%s' AND enabled=1", $user, $pass); $res = $this->CLASS['db']->query($query); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $_SESSION['userid'] = $row['id']; $_SESSION['groupid'] = $row['defaultgroup']; $_SESSION['user'] = $user; $_SESSION['password'] = $pass; $_SESSION['md5hash'] = md5($user . $pass); $_SESSION['admin'] = $row['admin']; $_SESSION['rightedit'] = $row['rightedit']; $_SESSION['open'] = array(); $_SESSION['open'] = ($row['treecache'] == "") ? array() : unserialize($row['treecache']); $_SESSION['theme'] = $row['theme']; $_SESSION['language'] = $row['language']; if (isset($_POST['language'])) { $this->CLASS['language']->load_language($_POST['language']); } $this->CLASS['auth']->writeTrueLogin(); $this->CLASS['auth']->gc(); return true; } else { return false; } } /** * vermerkt einen fehlgeschlagenen Anmeldeversuch in der DB * * @access public */ function writeFalseLogin() { // gibt es berreits einen Eintrag in der Tabelle users_login, // dann mache ein Update, sonst ein Insert if ($this->checkUsersLogin()) { // fehlversuch speichern | login_trial++ $query = sprintf("UPDATE users_login SET login_trial=login_trial+1, lasttrydate=%u WHERE usersid=%u", time(), $this->userid); $res_check = $this->CLASS['db']->query($query); } else if ($this->userid != 0) { // fehlversuch speichern | login_trial++ $query = sprintf("INSERT INTO users_login (usersid, login_trial, lasttrydate) VALUES (%u, 1, %u)", $this->userid, time()); $res_check = $this->CLASS['db']->query($query); } } /** * setzt bei gelungener Anmeldung die Werte auf Null * * @access public */ function writeTrueLogin() { // gibt es bereits einen Eintrag in der Tabelle users_login, // dann mache ein Update, sonst ein Insert if ($this->checkUsersLogin()) { // fehlversuch speichern | login_trial++ $query = sprintf("UPDATE users_login SET login_trial=0, lasttrydate=%u WHERE usersid=%u", time(), $this->userid); $res_check = $this->CLASS['db']->query($query); } } /** * prueft vorhandensein eines Eintrages in der Tabelle users_login * * @access private * @return bool */ function checkUsersLogin() { $query = sprintf("SELECT users_login.usersid, users_login.lasttrydate, users_login.login_trial FROM users_login JOIN users ON (users.id = users_login.usersid) WHERE users.name='%s' AND users.enabled=1", addslashes($this->user)); $res_check = $this->CLASS['db']->query($query); $anz = $this->CLASS['db']->num_rows($res_check); if ($anz == 1) { $row_check = $this->CLASS['db']->fetch_assoc($res_check); $this->userid = $row_check['usersid']; $this->lasttrydate = $row_check['lasttrydate']; $this->login_trial = $row_check['login_trial']; return true; } else { $this->userId(); return false; } } /** * Liest die UserID aus der Tabelle users aus. * * @access public * @return bool */ function userId() { $query = sprintf("SELECT id FROM users WHERE name='%s' AND enabled=1", addslashes($this->user)); $res = $this->CLASS['db']->query($query); $anz = $this->CLASS['db']->num_rows($res); if($anz == 1) { $row = $this->CLASS['db']->fetch_assoc($res); $this->userid = $row['id']; return true; } else { return false; } } /** * garbage collector * */ function gc() { if(isset($this->CLASS['vars']['login']['delay'])) { $this->gc_time = time() - ($this->gc_time + $this->CLASS['vars']['login']['delay']); $query = sprintf("DELETE FROM users_login WHERE lasttrydate<%d", $this->gc_time); $this->CLASS['db']->query($query); } } } ?> knowledgeroot-0.9.9.5/include/class-knowledgeroot-installer.php0000644000175000017500000007561511240363415025675 0ustar fhabermannfhabermanndoInstallConnect()) { $out .= $this->doInstall(); } else { $out .= $this->error_msg; $out .= $this->getInstallForm(); } } else { $out .= $this->getInstallForm(); } return $out; } function mainUpdate() { $out = ""; if(isset($_POST['submit']) && $_POST['submit']) { if($this->doUpdateConnect()) { $out .= $this->doUpdate(); } else { $out .= $this->error_msg; $out .= $this->getUpdateForm(); } } else { $out .= $this->getUpdateForm(); } return $out; } function doInstallConnect() { if($_POST['db_type'] == "pgsql") { if($_POST['db_create'] == 1) { if($this->isPgsqlConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],"template1",$_POST['db_schema'],$_POST['db_encoding'])) { $res = pg_query($this->db_connection,"CREATE DATABASE \"" . $_POST['db_database'] . "\"" . ($_POST['db_encoding'] != "" ? " WITH ENCODING='".$_POST['db_encoding']."'" : "")); pg_close($this->db_connection); if(!$res ) { $this->error_msg = "Could not create database!"; return 0; } if(!$this->isPgsqlConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'],$_POST['db_schema'],$_POST['db_encoding'])) { $this->error_msg = "Could not connect to database!"; return 0; } } else { $this->error_msg = "Could not connect to database!"; return 0; } } else { if(!$this->isPgsqlConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'],$_POST['db_schema'],$_POST['db_encoding'])) { $this->error_msg = "Could not connect to database!"; return 0; } } } elseif($_POST['db_type'] == "mysql") { if($_POST['db_create'] == 1) { if(!$this->isMysqlConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'])) { $this->error_msg = "Could not connect to database!"; return 0; } $res = mysql_query("CREATE DATABASE `".$_POST['db_database']."`", $this->db_connection); if(!$res) { $this->error_msg = "Could not create database!"; return 0; } if(!$this->isMysqlConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'])) { $this->error_msg = "Could not connect to database!"; return 0; } } else { if(!$this->isMysqlConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'])) { $this->error_msg = "Could not connect to database!"; return 0; } } } elseif($_POST['db_type'] == "mysqli") { if($_POST['db_create'] == 1) { if(!$this->isMysqliConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'])) { $this->error_msg = "Could not connect to database!"; return 0; } $res = mysqli_query($this->db_connection, "CREATE DATABASE `".$_POST['db_database']."`"); if(!$res) { $this->error_msg = "Could not create database!"; return 0; } if(!$this->isMysqliConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'])) { $this->error_msg = "Could not connect to database!"; return 0; } } else { if(!$this->isMysqliConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'])) { $this->error_msg = "Could not connect to database!"; return 0; } } } elseif($_POST['db_type'] == "sqlite") { if(!$this->isSqliteConnect($_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'])) { return 0; } } else { return 0; } return 1; } function doUpdateConnect() { $CONFIG = ''; require_once($this->file_config); require_once($this->file_class_knowledgeroot); // set config $this->CLASS['vars'] = $CONFIG; require_once($this->file_class_db_result); require_once($this->file_class_db_core); // load databaseclass if($CONFIG['db']['type'] == "mysql") { require_once($this->file_class_mysql); } if($CONFIG['db']['type'] == "mysqli") { require_once($this->file_class_mysqli); } if($CONFIG['db']['type'] == "pgsql") { require_once($this->file_class_pgsql); } if (!isset ($KNOWLEDGEROOTDB) || ($KNOWLEDGEROOTDB != 'PGSQL' && $KNOWLEDGEROOTDB != 'MYSQL')) { return 0; } // init databaseclass $this->CLASS['db'] = new db(); // connect to database $this->CLASS['db']->connect($CONFIG['db']['host'],$CONFIG['db']['user'],$CONFIG['db']['pass'],$CONFIG['db']['database'],$CONFIG['db']['schema'],$CONFIG['db']['encoding']); if(!$this->CLASS['db']->connection) { $this->error_msg = "Could not connect to database!"; return 0; } $this->db_connection =& $this->CLASS['db']->connection; $this->CLASS['knowledgeroot'] = new knowledgeroot(); $this->CLASS['knowledgeroot']->start($this->CLASS); return 1; } function doInstall() { $out = ""; $out .= '
    '; if($_POST['db_type'] == "pgsql") { $dump_file = $this->file_pgsql_dump; } else if($_POST['db_type'] == "mysql" || $_POST['db_type'] == "mysqli") { $dump_file = $this->file_mysql_dump; } else if($_POST['db_type'] == "sqlite") { $dump_file = $this->file_sqlite_dump; } else { return "Wrong dbtype!"; } $this->doSql($this->readSqlDump($dump_file),$_POST['db_type']); // set baseurl $this->setBaseUrl($_POST['baseurl'], $_POST['db_type']); // set version in database $this->setVersion($_POST['db_type']); // write config.php if($this->isFileWriteable($this->file_config) && $_POST['write_config'] == 1 && $this->writeFileContent($this->getConfigContent($_POST['db_type'],$_POST['db_host'],$_POST['db_user'],$_POST['db_pass'],$_POST['db_database'],$_POST['db_schema'],$_POST['db_encoding']),$this->file_config)) { $out .= "\n"; } else { $out .= '\n"; } // write admin_config.php if($this->isFileWriteable($this->file_admin_config) && $_POST['write_adminconfig'] == 1 && $this->writeFileContent($this->getAdminConfigContent($_POST['admin_user'],$_POST['admin_pass']),$this->file_admin_config)) { $out .= "\n"; } else { $out .= '\n"; } // delete install if(isset($_POST['delete_install']) && $_POST['delete_install'] == 1 && $this->isFileDeleteable($this->file_install) && @unlink($this->file_install)) { $out .= "\n"; } else { $out .= "\n"; } // delete update if(isset($_POST['delete_update']) && $_POST['delete_update'] == 1 && $this->isFileDeleteable($this->file_update) && @unlink($this->file_update)) { $out .= "\n"; } else { $out .= "\n"; } $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "
    Config (".$this->file_config.") was written!
    Create ' . $this->file_config . ' and put the following content in it:
    Config (".$this->file_admin_config.") was written!
    Create ' . $this->file_admin_config . ' and put the following content in it:
    Install file (".$this->file_install.") was deleted!
    Delete installation file (".$this->file_install.")!
    Update file (".$this->file_update.") was deleted!
    Delete update file (".$this->file_update.")!
    Congratulation you have installed Knowledgeroot successfully!
    For help and more documentation visit the Knowledgeroot project page or the forum.
    Link to Frontend: Frontend
    Link to Backend: Backend
    \n"; return $out; } function doUpdate() { $out = ""; $out .= ' '; if($this->CLASS['vars']['db']['type'] == "pgsql") { $dump_file = $this->file_pgsql_upgrade_dump; $dump_file_diff = $this->file_pgsql_upgrade_dump_diff; } else if($this->CLASS['vars']['db']['type'] == "mysql" || $this->CLASS['vars']['db']['type'] == "mysqli") { $dump_file = $this->file_mysql_upgrade_dump; $dump_file_diff = $this->file_mysql_upgrade_dump_diff; } else { return "Wrong dbtype!"; } if($this->shouldRunSmallUpdate($this->CLASS['vars']['db']['type'])) { // delete install if(isset($_POST['delete_install']) && $_POST['delete_install'] == 1 && $this->isFileDeleteable($this->file_install) && @unlink($this->file_install)) { $out .= "\n"; } else { $out .= "\n"; } // delete update if(isset($_POST['delete_update']) && $_POST['delete_update'] == 1 && $this->isFileDeleteable($this->file_update) && @unlink($this->file_update)) { $out .= "\n"; } else { $out .= "\n"; } $this->doSql($this->readSqlDump($dump_file_diff),$this->CLASS['vars']['db']['type']); // set baseurl $this->setBaseUrl($_POST['baseurl'], $this->CLASS['vars']['db']['type']); // set version in database $this->setVersion($this->CLASS['vars']['db']['type']); $out .= ""; $out .= ""; } elseif($this->shouldRunUpdate($this->CLASS['vars']['db']['type'])) { $this->doSql($this->readSqlDump($dump_file),$this->CLASS['vars']['db']['type']); // set baseurl $this->setBaseUrl($_POST['baseurl'], $this->CLASS['vars']['db']['type']); // set version in database $this->setVersion($this->CLASS['vars']['db']['type']); // copy all config vars to table settings $this->CLASS['knowledgeroot']->setConfigArr($this->CLASS['vars']); // write config.php if($this->isFileWriteable($this->file_config) && $_POST['write_config'] == 1 && $this->writeFileContent($this->getConfigContent($this->CLASS['vars']['db']['type'],$this->CLASS['vars']['db']['host'],$this->CLASS['vars']['db']['user'],$this->CLASS['vars']['db']['pass'],$this->CLASS['vars']['db']['database'],$this->CLASS['vars']['db']['schema'],$this->CLASS['vars']['db']['encoding']),$this->file_config)) { $out .= "\n"; } else { $out .= '\n"; } // write admin_config.php if($this->isFileWriteable($this->file_admin_config) && $_POST['write_adminconfig'] == 1 && $this->writeFileContent($this->getAdminConfigContent($_POST['admin_user'],$_POST['admin_pass']),$this->file_admin_config)) { $out .= "\n"; } else { $out .= '\n"; } // delete install if(isset($_POST['delete_install']) && $_POST['delete_install'] == 1 && $this->isFileDeleteable($this->file_install) && @unlink($this->file_install)) { $out .= "\n"; } else { $out .= "\n"; } // delete update if(isset($_POST['delete_update']) && $_POST['delete_update'] == 1 && $this->isFileDeleteable($this->file_update) && @unlink($this->file_update)) { $out .= "\n"; } else { $out .= "\n"; } $out .= ""; $out .= ""; } else { $out .= ""; } $out .= "
    Install file (".$this->file_install.") was deleted!
    Delete installation file (".$this->file_install.")!
    Update file (".$this->file_update.") was deleted!
    Delete update file (".$this->file_update.")!
    Congratulation you have updated Knowledgeroot successfully!
    For help and more documentation visit the Knowledgeroot project page or the forum.
    Config (".$this->file_config.") was written!
    Create ' . $this->file_config . ' and put the following content in it:
    Config (".$this->file_admin_config.") was written!
    Create ' . $this->file_admin_config . ' and put the following content in it:
    Install file (".$this->file_install.") was deleted!
    Delete installation file (".$this->file_install.")!
    Update file (".$this->file_update.") was deleted!
    Delete update file (".$this->file_update.")!
    Congratulation you have updated Knowledgeroot successfully!
    For help and more documentation visit the Knowledgeroot project page or the forum.
    No updates are needed!
    \n"; return $out; } function isFileWriteable($file) { if(is_file($file)) { if(is_writeable($file)) { return 1; } else { return 0; } } elseif(is_writeable(dirname($file))) { return 1; } else { return 0; } } function isFileDeleteable($file) { if(is_file($file)) { return $this->isFileWriteable($file); } return 0; } function writeFileContent($content,$file) { if($this->isFileWriteable($file)) { if(($handle = fopen($file,"w+")) === FALSE) return 0; if((fwrite($handle, $content)) === FALSE) return 0; fclose($handle); return 1; } return 0; } function getConfigContent($db_type="", $db_host="", $db_user="", $db_pass="", $db_database="", $db_schema="", $db_encoding="") { $content = ""; return $content; } function getAdminConfigContent($user, $pass) { $content = ""; return $content; } function getInstallForm() { $content = ''; $content .= ' '; if($this->isFileWriteable($this->file_config)) { $content .= ''; } else { $content .= ''; } if($this->isFileWriteable($this->file_admin_config)) { $content .= ''; } else { $content .= ''; } $content .= ''; $content .= ''; $content .= '

    Welcome to the installation of Knowledgeroot.

    Now, we need some informations from you to install Knowledgeroot. Fill out the following form and click "Start Installation" to install Knowledgeroot.
    Base URL:
    Type of database:
    Database host:
    Database user:
    Database password:
    Database name:
    Create database?
    Database schema (only Postgresql):
    Database encoding (only Postgresql):
    Username for Adminbackend:
    Password for Adminbackend:
    Write config?
    Write config?cannot write config file
    Write adminconfig?
    Write adminconfig?cannot write admin config
    Delete install.php?
    Delete update.php?
    '; return $content; } function getUpdateForm() { $content = ''; $content .= ' '; if($this->isFileWriteable($this->file_config)) { $content .= ''; } else { $content .= ''; } if($this->isFileWriteable($this->file_admin_config)) { $content .= ''; } else { $content .= ''; } $content .= ''; $content .= ''; $content .= '

    Welcome to the update of Knowledgeroot.

    Now, we need some informations from you to update Knowledgeroot. Fill out the following form an click "Start Update" to update Knowledgeroot.
    Base URL:
    Write config?
    Write config?cannot write config file
    Write adminconfig?
    Write adminconfig?cannot write admin config
    Delete install.php?
    Delete update.php?
    '; return $content; } function isPgsqlConnect($host,$user,$pass,$db,$schema="",$encoding="") { $this->db_connection = pg_connect("host=".$host." dbname=" . $db . " user=".$user." password=".$pass.""); if($this->db_connection) { if($schema != "") { pg_query("SET search_path TO ".$schema); } if($encoding != "") { pg_set_client_encoding($this->db_connection, $encoding); } return 1; } return 0; } function isMysqlConnect($host,$user,$pass,$db="") { $this->db_connection = mysql_connect($host,$user,$pass); if($this->db_connection) { if($db != "") { $db_conn = mysql_select_db($db, $this->db_connection); if($db_conn) { return 1; } } else { return 1; } } return 0; } function isMysqliConnect($host,$user,$pass,$db="") { $this->db_connection = mysqli_connect($host,$user,$pass); if($this->db_connection) { if($db != "") { $db_conn = mysqli_select_db($this->db_connection, $db); if($db_conn) { return 1; } } else { return 1; } } return 0; } function isSqliteConnect($host,$user,$pass,$db="") { $this->db_connection = sqlite_open($db, "0666"); if($this->db_connection) { return 1; } return 0; } /** * Check if a update is required * @param string $dbtype * @return bool */ function shouldRunUpdate($dbtype) { if($dbtype == "mysql") { $res = @mysql_query("SELECT count(id) as anz FROM settings WHERE name='version'"); $count = mysql_fetch_assoc($res); } elseif($dbtype == "mysqli") { $res = @mysqli_query("SELECT count(id) as anz FROM settings WHERE name='version'"); $count = mysqli_fetch_assoc($res); } elseif($dbtype == "pgsql") { $res = @pg_query("SELECT count(id) as anz FROM settings WHERE name='version'"); $count = pg_fetch_assoc($res); } elseif($dbtype == "sqlite") { $res = @sqlite_query("SELECT count(id) as anz FROM settings WHERE name='version'"); $count = sqlite_fetch_array("SELECT count(id) as anz FROM settings WHERE name='version'", SQLITE_ASSOC); } if($count['anz'] == 0) { // should run update return true; } else { // do not run update return false; } } /** * Removes comment lines and splits up large sql files into individual queries * * Last revision: September 23, 2001 - gandon * * @param array the splitted sql commands * @param string the sql commands * @param integer the MySQL release number (because certains php3 versions * can't get the value of a constant from within a function) * * @return boolean always true * * @access public */ function PMA_splitSqlFile(&$ret, $sql, $release) { // do not trim, see bug #1030644 //$sql = trim($sql); $sql = rtrim($sql, "\n\r"); $sql_len = strlen($sql); $char = ''; $string_start = ''; $in_string = FALSE; $nothing = TRUE; $time0 = time(); for ($i = 0; $i < $sql_len; ++$i) { $char = $sql[$i]; // We are in a string, check for not escaped end of strings except for // backquotes that can't be escaped if ($in_string) { for (;;) { $i = strpos($sql, $string_start, $i); // No end of string found -> add the current substring to the // returned array if (!$i) { $ret[] = array('query' => $sql, 'empty' => $nothing); return TRUE; } // Backquotes or no backslashes before quotes: it's indeed the // end of the string -> exit the loop elseif ($string_start == '`' || $sql[$i-1] != '\\') { $string_start = ''; $in_string = FALSE; break; } // one or more Backslashes before the presumed end of string... else { // ... first checks for escaped backslashes $j = 2; $escaped_backslash = FALSE; while ($i-$j > 0 && $sql[$i-$j] == '\\') { $escaped_backslash = !$escaped_backslash; $j++; } // ... if escaped backslashes: it's really the end of the // string -> exit the loop if ($escaped_backslash) { $string_start = ''; $in_string = FALSE; break; } // ... else loop else { $i++; } } // end if...elseif...else } // end for } // end if (in string) // lets skip comments (/*, -- and #) elseif (($char == '-' && $sql_len > $i + 2 && $sql[$i + 1] == '-' && $sql[$i + 2] <= ' ') || $char == '#' || ($char == '/' && $sql_len > $i + 1 && $sql[$i + 1] == '*')) { $i = strpos($sql, $char == '/' ? '*/' : "\n", $i); // didn't we hit end of string? if ($i === FALSE) { break; } if ($char == '/') { $i++; } } // We are not in a string, first check for delimiter... elseif ($char == ';') { // if delimiter found, add the parsed part to the returned array $ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing); $nothing = TRUE; $sql = ltrim(substr($sql, min($i + 1, $sql_len))); $sql_len = strlen($sql); if ($sql_len) { $i = -1; } else { // The submited statement(s) end(s) here return TRUE; } } // end elseif (is delimiter) // ... then check for start of a string,... elseif (($char == '"') || ($char == '\'') || ($char == '`')) { $in_string = TRUE; $nothing = FALSE; $string_start = $char; } // end elseif (is start of string) elseif ($nothing) { $nothing = FALSE; } // loic1: send a fake header each 30 sec. to bypass browser timeout $time1 = time(); if ($time1 >= $time0 + 30) { $time0 = $time1; header('X-pmaPing: Pong'); } // end if } // end for // add any rest to the returned array if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) { $ret[] = array('query' => $sql, 'empty' => $nothing); } return TRUE; } // end of the 'PMA_splitSqlFile()' function /** * Reads a file and split all statements in it. * * @param $file String Path to the SQL-dump-file */ function readSqlDump($file) { if (is_file($file) && is_readable($file)) { $ret = array (); $sqlsplit = ''; $fileContent = file_get_contents($file); $this->PMA_splitSqlFile($sqlsplit, $fileContent, ''); if (is_array($sqlsplit)) { foreach ($sqlsplit as $qry) { $ret[] = $qry['query']; } } return $ret; } return false; } function doSql($arr, $dbtype) { if(is_array($arr)) { foreach($arr as $key => $value) { if($dbtype == "pgsql") { pg_query($this->db_connection, $value); } if($dbtype == "mysql") { mysql_query($value, $this->db_connection); } if($dbtype == "mysqli") { mysqli_query($this->db_connection, $value); } if($dbtype == "sqlite") { sqlite_query($this->db_connection, $value); } } } return ""; } /** * FROM Typo3 * AddSlash array * This function traverses a multidimentional array and adds slashes to the values. * NOTE that the input array is and argument by reference.!! * Twin-function to stripSlashesOnArray * Usage: 8 * * @param array Multidimensional input array, (REFERENCE!) * @return array */ function addSlashesOnArray(&$theArray) { if(get_magic_quotes_gpc() == 0) { if (is_array($theArray)) { reset($theArray); while(list($Akey,$AVal)=each($theArray)) { if (is_array($AVal)) { $this->addSlashesOnArray($theArray[$Akey]); } else { $theArray[$Akey] = addslashes($AVal); } } reset($theArray); } } } /** * try to get the baseurl * * @return string */ function getBaseUrl() { $baseurl = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; preg_match("/(.*\/).*/", $baseurl, $url_arr); if($url_arr[1] == "") $url_arr[1] = $_SERVER['HTTP_HOST']; return $url_arr[1]; } /** * write baseurl to database * * @param string $baseurl base url * @param string $dbtype db type */ function setBaseUrl($baseurl, $dbtype) { $sql = "UPDATE settings SET value='".$baseurl."' WHERE name='baseurl'"; $this->doSql(array($sql), $dbtype); } /** * Check if a small update is required * @param string $dbtype * @return bool */ function shouldRunSmallUpdate($dbtype) { if($dbtype == "mysql") { $res = @mysql_query("SELECT id FROM settings WHERE name='knowledgeroot.showlogo'"); } elseif($dbtype == "mysqli") { $res = @mysqli_query("SELECT id FROM settings WHERE name='knowledgeroot.showlogo'"); } elseif($dbtype == "pgsql") { $res = @pg_query("SELECT id FROM settings WHERE name='knowledgeroot.showlogo'"); } else { return false; } if(!$res) { // should run normal update return false; } else { if($dbtype == "mysql") $count = mysql_num_rows($res); elseif($dbtype == "mysqli") $count = mysqli_num_rows($res); else $count = pg_num_rows($res); if($count == 1) return true; // do not run update return false; } } function setVersion($dbtype) { require_once('version.php'); if($dbtype == "pgsql") { pg_query($this->db_connection, "UPDATE settings SET value='".$version."' WHERE name='version'"); } if($dbtype == "mysql") { mysql_query("UPDATE settings SET value='".$version."' WHERE name='version'", $this->db_connection); } if($dbtype == "mysqli") { mysqli_query($this->db_connection, "UPDATE settings SET value='".$version."' WHERE name='version'"); } if($dbtype == "sqlite") { sqlite_query($this->db_connection, "UPDATE settings SET value='".$version."' WHERE name='version'"); } } } ?> knowledgeroot-0.9.9.5/include/class-language.php0000644000175000017500000000655411240354563022602 0ustar fhabermannfhabermannCLASS =& $CLASS; // search for locales $this->searchLocales(); // set userlanguage if available if (isset ($_SESSION['language']) and $_SESSION['language'] != "") { $language = $_SESSION['language']; } else if (!isset ($_SESSION['language']) or $_SESSION['language'] == '') { $_SESSION['language'] = $language; } $this->lang = $language; return true; } /** * search for locales in language folder */ function searchLocales() { if ($handle = opendir($this->CLASS['vars']['base_path'] . 'system/language')) { while (false !== ($file = readdir($handle))) { if(is_file($this->CLASS['vars']['base_path'] . 'system/language/' . $file . '/LC_MESSAGES/knowledgeroot.mo')) { $this->locales[] = $file; } } closedir($handle); } } /** * load extension language file * @param string $extension * @param string $lang */ function load_ext_lang($extension,$lang) { if(isset($lang[$this->lang])) { $this->get['ext'][$extension] = $lang[$this->lang]; if(isset($this->CLASS['extension'][$extension]['class']->getLang) && is_array($this->CLASS['extension'][$extension]['class']->getLang)) $this->CLASS['extension'][$extension]['class']->getLang = $lang[$this->lang]; } elseif(isset($lang[$this->default_lang])) { $this->get['ext'][$extension] = $lang[$this->default_lang]; if(isset($this->CLASS['extension'][$extension]['class']->getLang) && is_array($this->CLASS['extension'][$extension]['class']->getLang)) $this->CLASS['extension'][$extension]['class']->getLang = $lang[$this->default_lang]; } } /** * dropdown with available languages * @param string $name * @param string $default * @param string $optionparams * @return string */ function lang_dropdown($name = "language",$default = "", $optionparams = "") { if(isset($this->CLASS['vars']['knowledgeroot']['availablelanguages']) && !is_array($this->CLASS['vars']['knowledgeroot']['availablelanguages'])) { $this->CLASS['vars']['knowledgeroot']['availablelanguages'] = array($this->CLASS['vars']['knowledgeroot']['language']); } if($default == "") { $default = $this->CLASS['vars']['knowledgeroot']['language']; } if($this->CLASS['vars']['menu']['ajax'] == "yes") { $jsscript = 'onchange="this.form.submit();"'; } else { $jsscript = ""; } $out = '\n"; return $out; } } ?> knowledgeroot-0.9.9.5/include/class-email-notification.php0000644000175000017500000001304210661371076024564 0ustar fhabermannfhabermannhtml_mail_header .= $content; } /** * start mailnotification */ function knowledgeroot_notification(&$CLASS) { $this->CLASS =& $CLASS; $config = $this->CLASS['vars']; if($config['email']['smtp_mode'] == 1) { $this->Host = $config['email']['smtp_host']; $this->Port = $config['email']['smtp_port']; if($config['email']['smtp_username'] != '') { $this->SMTPAuth = true; $this->Username = $config['email']['smtp_username']; $this->Password = $config['email']['smtp_password']; } $this->Mailer = "smtp"; } if(!$this->From) { $this->From = $config['email']['from_email']; } if(!$this->FromName) { $this-> FromName = $config['email']['from_name']; } if(!$this->Sender) { $this->Sender = $config['email']['from_email']; } $parts = explode( ",", $config['email']['recipients']); foreach ( $parts as $part ) { $this->AddAddress($part, null); } // uncomment this for verbose SMTP debugging // $this->SMTPDebug = true; $this->SetLanguage($config['knowledgeroot']['language'], "system/phpmailer/language/"); $this->Priority = $this->priority; if($config['email']['type'] == "html") { $this->isHTML(true); $this->html = true; } } /** * send email notification * id show the id of the modified element * @param integer $pageid id of page * @param string $elementType type of element * @param string $action action * @param string $name name of element * @param integer $id id of element * @param string $extratext some optional extra text */ function send_email_notification($pageid, $elementType, $action, $name = "", $id = "", $extratext = "") { if($this->CLASS['vars']['email']['notification'] == 1) { // get pagetitle $pageTitle = $this->CLASS['path']->getTreePageTitle($pageid); // check custom format if (T_($elementType.'_text') != $elementType.'_text'){ $fmt = T_($elementType.'_text'); } else { $fmt = '#elementType# "#name#" #was# #action#'; } $subject_str = $fmt; $subject_str = str_replace('#elementType#', T_($elementType), $subject_str); $subject_str = str_replace('#name#', $name, $subject_str); $subject_str = str_replace('#was#', T_('was'), $subject_str); $subject_str = str_replace('#action#', T_($action), $subject_str); // set emailsubject $this->Subject = T_('Knowledgeroot notification') . ' (' . $subject_str . ')'; // make html mail or not if($this->html == true) { // get path $path = $this->CLASS['path']->getPath($pageid, $this->CLASS['kr_header']->get_base_url()); // check custom format if (T_($elementType.'_html') != $elementType.'_html'){ $fmt = T_($elementType.'_html'); } elseif (T_($elementType.'_text') != $elementType.'_text'){ $fmt = T_($elementType.'_text'); } else { $fmt = '#elementType# "#name#" #was# #action#'; } $action_str = $fmt; $action_str = str_replace('#elementType#', T_($elementType), $action_str); $action_str = str_replace('#name#', $name, $action_str); $action_str = str_replace('#was#', T_('was'), $action_str); $action_str = str_replace('#action#', T_($action), $action_str); $mailBody = ' '. $this->html_mail_header .' ' . T_('Knowledgeroot notification') . '
    ' . T_('Path') . '
    ' . $path . '
    ' . T_('Action') . '
    ' . $action_str . ($id != "" ? " (ID: " . $id . ")
    \n" : "") . '
    ' . T_('author') . '
    ' . $_SESSION['user'] . '
    ' . T_('date') . '
    ' . date("D, j M Y H:i:s") . '
    '; if ($extratext != "") { $mailBody .= $extratext; } $mailBody .= ' '; } else { // get path $path = $this->CLASS['path']->getTextPath($pageid, $this->CLASS['kr_header']->get_base_url()); $mailBody = T_('Path') . ': ' . $path."\n"; $mailBody .= T_('Action') . ': ' . $subject_str . ($id != "" ? " (ID: " . $id . ")\n" : "\n"); $mailBody .= T_('Author'). ': ' . $_SESSION['user']."\n"; $mailBody .= T_('Date') . ': ' . date("D, j M Y H:i:s")."\n"; if ($extratext != "") { $mailBody .= "\n" . T_('Detail of Changes') . ": \n\n" . $extratext . "\n"; } } // set emailbody $this->Body = $mailBody; // send email if (!$this->Send()) { $this->CLASS['kr_header']->addwarning(T_('Unable to send email notification') . ': ' . $this->ErrorInfo); } // do some cleanup $this->ClearAddresses(); $this->ClearAttachments(); } } } ?> knowledgeroot-0.9.9.5/include/class-hooks.php0000644000175000017500000000426410671553550022142 0ustar fhabermannfhabermannCLASS =& $CLASS; } /** * set hook in a function and will run functions that are registered for this hook * @param string $classname class name for hook * @param string $functionname function name for hook * @param string $position position in this function for hook */ function setHook($classname,$functionname,$position) { if(isset($this->hooks[$classname][$functionname][$position]) && is_array($this->hooks[$classname][$functionname][$position])) { foreach($this->hooks[$classname][$functionname][$position] as $key => $value) { if(isset($this->hooks[$classname][$functionname][$position][$key]) && $this->hooks[$classname][$functionname][$position][$key] != "") { if(isset($this->CLASS[$key]) && is_object($this->CLASS[$key]) && $value != "") { if(method_exists($this->CLASS[$key],$value)) { $this->CLASS[$key]->$value(); } } elseif(isset($this->CLASS['extension'][$key]) && is_object($this->CLASS['extension'][$key]['class']) && $value != "") { if(method_exists($this->CLASS['extension'][$key]['class'],$value)) { $this->CLASS['extension'][$key]['class']->$value(); } } } } } } /** * register a specific function in a class at a hook * @param string $classname class name for hook * @param string $functionname function name for hook * @param string $position position in this function for hook * @param string $myclass class that should be run if hook is called * @param string $myfunction function that will be started if hook is called */ function execAtHook($classname,$functionname,$position,$myclass,$myfunction) { $this->hooks[$classname][$functionname][$position][$myclass] = $myfunction; } } ?> knowledgeroot-0.9.9.5/include/class-session.php0000644000175000017500000001211010670574060022465 0ustar fhabermannfhabermannCLASS =& $CLASS; // check if session lifetime and session checking should be enabled if(isset($this->CLASS['vars']['session']['handle']) && $this->CLASS['vars']['session']['handle'] == 1) { // check for lifetime if(isset($this->CLASS['vars']['session']['lifetime']) && is_int($this->CLASS['vars']['session']['lifetime'])) { $this->lifetime = $this->CLASS['vars']['session']['lifetime']; } // check for checkBrowser if(isset($this->CLASS['vars']['session']['checkBrowser']) && $this->CLASS['vars']['session']['checkBrowser'] == 1) { $this->checkBrowser = true; } // check for checkIP if(isset($this->CLASS['vars']['session']['checkIP']) && $this->CLASS['vars']['session']['checkIP'] == 1) { $this->checkIP = true; } // check for only allow cookies if(isset($this->CLASS['vars']['session']['onlyCookies']) && $this->CLASS['vars']['session']['onlyCookies'] == 1) { $this->onlyCookies = true; } } // set lifetime of session $this->setLifeTime(); } /** * start session * @param string $name name of session * @return bool */ function startSession($name) { // check for only allow cookies if($this->onlyCookies) { ini_set('session.use_trans_sid',0); } // set session name $this->name = session_name($name); // set session id $this->id = session_id(); return session_start(); } /** * check session for user * @return bool will return true if session is ok and false if not */ function checkSession() { // for default session is not ok $out = false; // check if lastAccess is set if(!isset($_SESSION['session']['lastAccess'])) { $_SESSION['session']['lastAccess'] = time(); } // check if browser is set if(!isset($_SESSION['session']['browser']) && isset($_SERVER["HTTP_USER_AGENT"])) { $_SESSION['session']['browser'] = md5($_SERVER["HTTP_USER_AGENT"]); } // check if ip is set if(!isset($_SESSION['session']['ip']) && isset($_SERVER["REMOTE_ADDR"])) { $_SESSION['session']['ip'] = $_SERVER["REMOTE_ADDR"]; } // now check session if($this->checkLifeTime() && $this->checkBrowser() && $this->checkIP()) { $out = true; } // at the end set lastAccess time new $_SESSION['session']['lastAccess'] = time(); return $out; } /** * check lifetime of session * @return bool */ function checkLifeTime() { $out = false; if($this->handle) { if(isset($_SESSION['session']['lastAccess']) && $_SESSION['session']['lastAccess'] >= (time() - $this->lifetime*60)) { $out = true; } } else { // no session lifetime check so session is ok $out = true; } return $out; } /** * check for browser in session * @return bool */ function checkBrowser() { $out = false; // now check for browser if($this->checkBrowser) { if(isset($_SESSION['session']['browser']) && isset($_SERVER["HTTP_USER_AGENT"]) && $_SESSION['session']['browser'] = md5($_SERVER["HTTP_USER_AGENT"])) { $out = true; } } else { // no session browser check is needed so session is ok $out = true; } return $out; } /** * check for ip in session * @return bool */ function checkIP() { $out = false; // now check for browser if($this->checkIP) { if(isset($_SESSION['session']['ip']) && isset($_SERVER["REMOTE_ADDR"]) && $_SESSION['session']['ip'] = $_SERVER["REMOTE_ADDR"]) { $out = true; } } else { // no session ip check is need so session is ok $out = true; } return $out; } /** * set session lifetime * @param integer $time time for session timeout in seconds * @return integer return lifetime of session */ function setLifeTime($time = null) { if($time != null && is_int($time)) { $this->lifetime = $time; } ini_set("session.gc_maxlifetime", $this->lifetime); return ini_get("session.gc_maxlifetime"); } } ?> knowledgeroot-0.9.9.5/config/0000755000175000017500000000000011273105241017004 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/config/admin_config.inc.php.dist0000644000175000017500000000016110621452077023652 0ustar fhabermannfhabermann knowledgeroot-0.9.9.5/config/config.inc.php.dist0000644000175000017500000000276410651177057022522 0ustar fhabermannfhabermann 2, 'result_buffering' => true, // this should always be enabled!!! if not no num_rows is available ); */ /** * Settings for errorlog */ $CONFIG['log']['level'] = ""; /* 0 - no errors are shown 1 - errors are shown 2 - errors and notices are shown */ $CONFIG['log']['type'] = "none,apache,logfile,mail,screen"; // list with type of notifications $CONFIG['log']['logfile'] = ""; // path to logfile if logfile is used $CONFIG['log']['mail'] = ""; // set email to that notification will be send $CONFIG['log']['mail_extra_header'] = ""; // set extra mail headers $CONFIG['log']['setPhpError'] = true; // boolean - enable or disable to set php error by knowledgeroot $CONFIG['log']['setPhpErrorReporting'] = E_ALL & ~ E_NOTICE; // set php error type ?> knowledgeroot-0.9.9.5/extension/0000755000175000017500000000000011273106025017554 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/extension/tinymce/0000755000175000017500000000000011273106051021223 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/extension/tinymce/doc/0000755000175000017500000000000011273106051021770 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/extension/tinymce/doc/changelog0000644000175000017500000000076511273103220023645 0ustar fhabermannfhabermann20091031 - fhabermann * added tinymce version 3.2.7 20090821 - fhabermann * added tinymce version 3.2.6 20090707 - fhabermann * added tinymce version 3.2.5 20090618 - fhabermann * added tinymce version 3.2.4.1 20090503 - fhabermann * added tinymce version 3.2.3 20090410 - fhabermann * fixed problem with info file - history entries are set in dependencies 20090330 - fhabermann * added tinymce version 3.2.2.3 20090319 - fhabermann * added new tinymce version 3.2.2.1 * fixed cache problems knowledgeroot-0.9.9.5/extension/tinymce/info.php0000755000175000017500000000053411224635034022700 0ustar fhabermannfhabermann "tinymce for knowledgeroot", "description" => "tinymce for knowledgeroot", "version" => "3.2.5", "history" => "3.2.2.1;3.2.2.3;3.2.3;3.2.3.1;3.2.5", "dependencies" => "", "state" => "stable", "author" => "Frank Habermann", "author_email" => "lordlamer@lordlamer.de", "author_company" => "LordLamer", ); ?> knowledgeroot-0.9.9.5/extension/tinymce/jscripts/0000755000175000017500000000000011273106025023065 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/extension/tinymce/jscripts/tiny_mce/0000755000175000017500000000000011273106051024673 5ustar fhabermannfhabermannknowledgeroot-0.9.9.5/extension/tinymce/jscripts/tiny_mce/tiny_mce_src.js0000644000175000017500000117667511273103220027731 0ustar fhabermannfhabermannvar tinymce = { majorVersion : '3', minorVersion : '2.7', releaseDate : '2009-09-22', _init : function() { var t = this, d = document, w = window, na = navigator, ua = na.userAgent, i, nl, n, base, p, v; t.isOpera = w.opera && opera.buildNumber; t.isWebKit = /WebKit/.test(ua); t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(na.appName); t.isIE6 = t.isIE && /MSIE [56]/.test(ua); t.isGecko = !t.isWebKit && /Gecko/.test(ua); t.isMac = ua.indexOf('Mac') != -1; t.isAir = /adobeair/i.test(ua); // TinyMCE .NET webcontrol might be setting the values for TinyMCE if (w.tinyMCEPreInit) { t.suffix = tinyMCEPreInit.suffix; t.baseURL = tinyMCEPreInit.base; t.query = tinyMCEPreInit.query; return; } // Get suffix and base t.suffix = ''; // If base element found, add that infront of baseURL nl = d.getElementsByTagName('base'); for (i=0; i : s = /^((static) )?([\w.]+)(:([\w.]+))?/.exec(s); cn = s[3].match(/(^|\.)(\w+)$/i)[2]; // Class name // Create namespace for new class ns = t.createNS(s[3].replace(/\.\w+$/, '')); // Class already exists if (ns[cn]) return; // Make pure static class if (s[2] == 'static') { ns[cn] = p; if (this.onCreate) this.onCreate(s[2], s[3], ns[cn]); return; } // Create default constructor if (!p[cn]) { p[cn] = function() {}; de = 1; } // Add constructor and methods ns[cn] = p[cn]; t.extend(ns[cn].prototype, p); // Extend if (s[5]) { sp = t.resolve(s[5]).prototype; scn = s[5].match(/\.(\w+)$/i)[1]; // Class name // Extend constructor c = ns[cn]; if (de) { // Add passthrough constructor ns[cn] = function() { return sp[scn].apply(this, arguments); }; } else { // Add inherit constructor ns[cn] = function() { this.parent = sp[scn]; return c.apply(this, arguments); }; } ns[cn].prototype[cn] = ns[cn]; // Add super methods t.each(sp, function(f, n) { ns[cn].prototype[n] = sp[n]; }); // Add overridden methods t.each(p, function(f, n) { // Extend methods if needed if (sp[n]) { ns[cn].prototype[n] = function() { this.parent = sp[n]; return f.apply(this, arguments); }; } else { if (n != cn) ns[cn].prototype[n] = f; } }); } // Add static methods t.each(p['static'], function(f, n) { ns[cn][n] = f; }); if (this.onCreate) this.onCreate(s[2], s[3], ns[cn].prototype); }, walk : function(o, f, n, s) { s = s || this; if (o) { if (n) o = o[n]; tinymce.each(o, function(o, i) { if (f.call(s, o, i, n) === false) return false; tinymce.walk(o, f, n, s); }); } }, createNS : function(n, o) { var i, v; o = o || window; n = n.split('.'); for (i=0; i= items.length) { for (i = 0, l = base.length; i < l; i++) { if (i >= items.length || base[i] != items[i]) { bp = i + 1; break; } } } if (base.length < items.length) { for (i = 0, l = items.length; i < l; i++) { if (i >= base.length || base[i] != items[i]) { bp = i + 1; break; } } } if (bp == 1) return path; for (i = 0, l = base.length - (bp - 1); i < l; i++) out += "../"; for (i = bp - 1, l = items.length; i < l; i++) { if (i != bp - 1) out += "/" + items[i]; else out += items[i]; } return out; }, toAbsPath : function(base, path) { var i, nb = 0, o = [], tr, outPath; // Split paths tr = /\/$/.test(path) ? '/' : ''; base = base.split('/'); path = path.split('/'); // Remove empty chunks each(base, function(k) { if (k) o.push(k); }); base = o; // Merge relURLParts chunks for (i = path.length - 1, o = []; i >= 0; i--) { // Ignore empty or . if (path[i].length == 0 || path[i] == ".") continue; // Is parent if (path[i] == '..') { nb++; continue; } // Move up if (nb > 0) { nb--; continue; } o.push(path[i]); } i = base.length - nb; // If /a/b/c or / if (i <= 0) outPath = o.reverse().join('/'); else outPath = base.slice(0, i).join('/') + '/' + o.reverse().join('/'); // Add front / if it's needed if (outPath.indexOf('/') !== 0) outPath = '/' + outPath; // Add traling / if it's needed if (tr && outPath.lastIndexOf('/') !== outPath.length - 1) outPath += tr; return outPath; }, getURI : function(nh) { var s, t = this; // Rebuild source if (!t.source || nh) { s = ''; if (!nh) { if (t.protocol) s += t.protocol + '://'; if (t.userInfo) s += t.userInfo + '@'; if (t.host) s += t.host; if (t.port) s += ':' + t.port; } if (t.path) s += t.path; if (t.query) s += '?' + t.query; if (t.anchor) s += '#' + t.anchor; t.source = s; } return t.source; } }); })(); (function() { var each = tinymce.each; tinymce.create('static tinymce.util.Cookie', { getHash : function(n) { var v = this.get(n), h; if (v) { each(v.split('&'), function(v) { v = v.split('='); h = h || {}; h[unescape(v[0])] = unescape(v[1]); }); } return h; }, setHash : function(n, v, e, p, d, s) { var o = ''; each(v, function(v, k) { o += (!o ? '' : '&') + escape(k) + '=' + escape(v); }); this.set(n, o, e, p, d, s); }, get : function(n) { var c = document.cookie, e, p = n + "=", b; // Strict mode if (!c) return; b = c.indexOf("; " + p); if (b == -1) { b = c.indexOf(p); if (b != 0) return null; } else b += 2; e = c.indexOf(";", b); if (e == -1) e = c.length; return unescape(c.substring(b + p.length, e)); }, set : function(n, v, e, p, d, s) { document.cookie = n + "=" + escape(v) + ((e) ? "; expires=" + e.toGMTString() : "") + ((p) ? "; path=" + escape(p) : "") + ((d) ? "; domain=" + d : "") + ((s) ? "; secure" : ""); }, remove : function(n, p) { var d = new Date(); d.setTime(d.getTime() - 1000); this.set(n, '', d, p, d); } }); })(); tinymce.create('static tinymce.util.JSON', { serialize : function(o) { var i, v, s = tinymce.util.JSON.serialize, t; if (o == null) return 'null'; t = typeof o; if (t == 'string') { v = '\bb\tt\nn\ff\rr\""\'\'\\\\'; return '"' + o.replace(/([\u0080-\uFFFF\x00-\x1f\"])/g, function(a, b) { i = v.indexOf(b); if (i + 1) return '\\' + v.charAt(i + 1); a = b.charCodeAt().toString(16); return '\\u' + '0000'.substring(a.length) + a; }) + '"'; } if (t == 'object') { if (o.hasOwnProperty && o instanceof Array) { for (i=0, v = '['; i 0 ? ',' : '') + s(o[i]); return v + ']'; } v = '{'; for (i in o) v += typeof o[i] != 'function' ? (v.length > 1 ? ',"' : '"') + i + '":' + s(o[i]) : ''; return v + '}'; } return '' + o; }, parse : function(s) { try { return eval('(' + s + ')'); } catch (ex) { // Ignore } } }); tinymce.create('static tinymce.util.XHR', { send : function(o) { var x, t, w = window, c = 0; // Default settings o.scope = o.scope || this; o.success_scope = o.success_scope || o.scope; o.error_scope = o.error_scope || o.scope; o.async = o.async === false ? false : true; o.data = o.data || ''; function get(s) { x = 0; try { x = new ActiveXObject(s); } catch (ex) { } return x; }; x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Microsoft.XMLHTTP') || get('Msxml2.XMLHTTP'); if (x) { if (x.overrideMimeType) x.overrideMimeType(o.content_type); x.open(o.type || (o.data ? 'POST' : 'GET'), o.url, o.async); if (o.content_type) x.setRequestHeader('Content-Type', o.content_type); x.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); x.send(o.data); function ready() { if (!o.async || x.readyState == 4 || c++ > 10000) { if (o.success && c < 10000 && x.status == 200) o.success.call(o.success_scope, '' + x.responseText, x, o); else if (o.error) o.error.call(o.error_scope, c > 10000 ? 'TIMED_OUT' : 'GENERAL', x, o); x = null; } else w.setTimeout(ready, 10); }; // Syncronous request if (!o.async) return ready(); // Wait for response, onReadyStateChange can not be used since it leaks memory in IE t = w.setTimeout(ready, 10); } } }); (function() { var extend = tinymce.extend, JSON = tinymce.util.JSON, XHR = tinymce.util.XHR; tinymce.create('tinymce.util.JSONRequest', { JSONRequest : function(s) { this.settings = extend({ }, s); this.count = 0; }, send : function(o) { var ecb = o.error, scb = o.success; o = extend(this.settings, o); o.success = function(c, x) { c = JSON.parse(c); if (typeof(c) == 'undefined') { c = { error : 'JSON Parse error.' }; } if (c.error) ecb.call(o.error_scope || o.scope, c.error, x); else scb.call(o.success_scope || o.scope, c.result); }; o.error = function(ty, x) { ecb.call(o.error_scope || o.scope, ty, x); }; o.data = JSON.serialize({ id : o.id || 'c' + (this.count++), method : o.method, params : o.params }); // JSON content type for Ruby on rails. Bug: #1883287 o.content_type = 'application/json'; XHR.send(o); }, 'static' : { sendRPC : function(o) { return new tinymce.util.JSONRequest().send(o); } } }); }());(function(tinymce) { // Shorten names var each = tinymce.each, is = tinymce.is; var isWebKit = tinymce.isWebKit, isIE = tinymce.isIE; tinymce.create('tinymce.dom.DOMUtils', { doc : null, root : null, files : null, pixelStyles : /^(top|left|bottom|right|width|height|borderWidth)$/, props : { "for" : "htmlFor", "class" : "className", className : "className", checked : "checked", disabled : "disabled", maxlength : "maxLength", readonly : "readOnly", selected : "selected", value : "value", id : "id", name : "name", type : "type" }, DOMUtils : function(d, s) { var t = this; t.doc = d; t.win = window; t.files = {}; t.cssFlicker = false; t.counter = 0; t.boxModel = !tinymce.isIE || d.compatMode == "CSS1Compat"; t.stdMode = d.documentMode === 8; t.settings = s = tinymce.extend({ keep_values : false, hex_colors : 1, process_html : 1 }, s); // Fix IE6SP2 flicker and check it failed for pre SP2 if (tinymce.isIE6) { try { d.execCommand('BackgroundImageCache', false, true); } catch (e) { t.cssFlicker = true; } } tinymce.addUnload(t.destroy, t); }, getRoot : function() { var t = this, s = t.settings; return (s && t.get(s.root_element)) || t.doc.body; }, getViewPort : function(w) { var d, b; w = !w ? this.win : w; d = w.document; b = this.boxModel ? d.documentElement : d.body; // Returns viewport size excluding scrollbars return { x : w.pageXOffset || b.scrollLeft, y : w.pageYOffset || b.scrollTop, w : w.innerWidth || b.clientWidth, h : w.innerHeight || b.clientHeight }; }, getRect : function(e) { var p, t = this, sr; e = t.get(e); p = t.getPos(e); sr = t.getSize(e); return { x : p.x, y : p.y, w : sr.w, h : sr.h }; }, getSize : function(e) { var t = this, w, h; e = t.get(e); w = t.getStyle(e, 'width'); h = t.getStyle(e, 'height'); // Non pixel value, then force offset/clientWidth if (w.indexOf('px') === -1) w = 0; // Non pixel value, then force offset/clientWidth if (h.indexOf('px') === -1) h = 0; return { w : parseInt(w) || e.offsetWidth || e.clientWidth, h : parseInt(h) || e.offsetHeight || e.clientHeight }; }, getParent : function(n, f, r) { return this.getParents(n, f, r, false); }, getParents : function(n, f, r, c) { var t = this, na, se = t.settings, o = []; n = t.get(n); c = c === undefined; if (se.strict_root) r = r || t.getRoot(); // Wrap node name as func if (is(f, 'string')) { na = f; if (f === '*') { f = function(n) {return n.nodeType == 1;}; } else { f = function(n) { return t.is(n, na); }; } } while (n) { if (n == r || !n.nodeType || n.nodeType === 9) break; if (!f || f(n)) { if (c) o.push(n); else return n; } n = n.parentNode; } return c ? o : null; }, get : function(e) { var n; if (e && this.doc && typeof(e) == 'string') { n = e; e = this.doc.getElementById(e); // IE and Opera returns meta elements when they match the specified input ID, but getElementsByName seems to do the trick if (e && e.id !== n) return this.doc.getElementsByName(n)[1]; } return e; }, getNext : function(node, selector) { return this._findSib(node, selector, 'nextSibling'); }, getPrev : function(node, selector) { return this._findSib(node, selector, 'previousSibling'); }, select : function(pa, s) { var t = this; return tinymce.dom.Sizzle(pa, t.get(s) || t.get(t.settings.root_element) || t.doc, []); }, is : function(n, patt) { return tinymce.dom.Sizzle.matches(patt, n.nodeType ? [n] : n).length > 0; }, add : function(p, n, a, h, c) { var t = this; return this.run(p, function(p) { var e, k; e = is(n, 'string') ? t.doc.createElement(n) : n; t.setAttribs(e, a); if (h) { if (h.nodeType) e.appendChild(h); else t.setHTML(e, h); } return !c ? p.appendChild(e) : e; }); }, create : function(n, a, h) { return this.add(this.doc.createElement(n), n, a, h, 1); }, createHTML : function(n, a, h) { var o = '', t = this, k; o += '<' + n; for (k in a) { if (a.hasOwnProperty(k)) o += ' ' + k + '="' + t.encode(a[k]) + '"'; } if (tinymce.is(h)) return o + '>' + h + ''; return o + ' />'; }, remove : function(n, k) { var t = this; return this.run(n, function(n) { var p, g, i; p = n.parentNode; if (!p) return null; if (k) { for (i = n.childNodes.length - 1; i >= 0; i--) t.insertAfter(n.childNodes[i], n); //each(n.childNodes, function(c) { // p.insertBefore(c.cloneNode(true), n); //}); } // Fix IE psuedo leak if (t.fixPsuedoLeaks) { p = n.cloneNode(true); k = 'IELeakGarbageBin'; g = t.get(k) || t.add(t.doc.body, 'div', {id : k, style : 'display:none'}); g.appendChild(n); g.innerHTML = ''; return p; } return p.removeChild(n); }); }, setStyle : function(n, na, v) { var t = this; return t.run(n, function(e) { var s, i; s = e.style; // Camelcase it, if needed na = na.replace(/-(\D)/g, function(a, b){ return b.toUpperCase(); }); // Default px suffix on these if (t.pixelStyles.test(na) && (tinymce.is(v, 'number') || /^[\-0-9\.]+$/.test(v))) v += 'px'; switch (na) { case 'opacity': // IE specific opacity if (isIE) { s.filter = v === '' ? '' : "alpha(opacity=" + (v * 100) + ")"; if (!n.currentStyle || !n.currentStyle.hasLayout) s.display = 'inline-block'; } // Fix for older browsers s[na] = s['-moz-opacity'] = s['-khtml-opacity'] = v || ''; break; case 'float': isIE ? s.styleFloat = v : s.cssFloat = v; break; default: s[na] = v || ''; } // Force update of the style data if (t.settings.update_styles) t.setAttrib(e, 'mce_style'); }); }, getStyle : function(n, na, c) { n = this.get(n); if (!n) return false; // Gecko if (this.doc.defaultView && c) { // Remove camelcase na = na.replace(/[A-Z]/g, function(a){ return '-' + a; }); try { return this.doc.defaultView.getComputedStyle(n, null).getPropertyValue(na); } catch (ex) { // Old safari might fail return null; } } // Camelcase it, if needed na = na.replace(/-(\D)/g, function(a, b){ return b.toUpperCase(); }); if (na == 'float') na = isIE ? 'styleFloat' : 'cssFloat'; // IE & Opera if (n.currentStyle && c) return n.currentStyle[na]; return n.style[na]; }, setStyles : function(e, o) { var t = this, s = t.settings, ol; ol = s.update_styles; s.update_styles = 0; each(o, function(v, n) { t.setStyle(e, n, v); }); // Update style info s.update_styles = ol; if (s.update_styles) t.setAttrib(e, s.cssText); }, setAttrib : function(e, n, v) { var t = this; // Whats the point if (!e || !n) return; // Strict XML mode if (t.settings.strict) n = n.toLowerCase(); return this.run(e, function(e) { var s = t.settings; switch (n) { case "style": if (!is(v, 'string')) { each(v, function(v, n) { t.setStyle(e, n, v); }); return; } // No mce_style for elements with these since they might get resized by the user if (s.keep_values) { if (v && !t._isRes(v)) e.setAttribute('mce_style', v, 2); else e.removeAttribute('mce_style', 2); } e.style.cssText = v; break; case "class": e.className = v || ''; // Fix IE null bug break; case "src": case "href": if (s.keep_values) { if (s.url_converter) v = s.url_converter.call(s.url_converter_scope || t, v, n, e); t.setAttrib(e, 'mce_' + n, v, 2); } break; case "shape": e.setAttribute('mce_style', v); break; } if (is(v) && v !== null && v.length !== 0) e.setAttribute(n, '' + v, 2); else e.removeAttribute(n, 2); }); }, setAttribs : function(e, o) { var t = this; return this.run(e, function(e) { each(o, function(v, n) { t.setAttrib(e, n, v); }); }); }, getAttrib : function(e, n, dv) { var v, t = this; e = t.get(e); if (!e || e.nodeType !== 1) return false; if (!is(dv)) dv = ''; // Try the mce variant for these if (/^(src|href|style|coords|shape)$/.test(n)) { v = e.getAttribute("mce_" + n); if (v) return v; } if (isIE && t.props[n]) { v = e[t.props[n]]; v = v && v.nodeValue ? v.nodeValue : v; } if (!v) v = e.getAttribute(n, 2); // Check boolean attribs if (/^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)$/.test(n)) { if (e[t.props[n]] === true && v === '') return n; return v ? n : ''; } // Inner input elements will override attributes on form elements if (e.nodeName === "FORM" && e.getAttributeNode(n)) return e.getAttributeNode(n).nodeValue; if (n === 'style') { v = v || e.style.cssText; if (v) { v = t.serializeStyle(t.parseStyle(v)); if (t.settings.keep_values && !t._isRes(v)) e.setAttribute('mce_style', v); } } // Remove Apple and WebKit stuff if (isWebKit && n === "class" && v) v = v.replace(/(apple|webkit)\-[a-z\-]+/gi, ''); // Handle IE issues if (isIE) { switch (n) { case 'rowspan': case 'colspan': // IE returns 1 as default value if (v === 1) v = ''; break; case 'size': // IE returns +0 as default value for size if (v === '+0' || v === 20 || v === 0) v = ''; break; case 'width': case 'height': case 'vspace': case 'checked': case 'disabled': case 'readonly': if (v === 0) v = ''; break; case 'hspace': // IE returns -1 as default value if (v === -1) v = ''; break; case 'maxlength': case 'tabindex': // IE returns default value if (v === 32768 || v === 2147483647 || v === '32768') v = ''; break; case 'multiple': case 'compact': case 'noshade': case 'nowrap': if (v === 65535) return n; return dv; case 'shape': v = v.toLowerCase(); break; default: // IE has odd anonymous function for event attributes if (n.indexOf('on') === 0 && v) v = ('' + v).replace(/^function\s+\w+\(\)\s+\{\s+(.*)\s+\}$/, '$1'); } } return (v !== undefined && v !== null && v !== '') ? '' + v : dv; }, getPos : function(n, ro) { var t = this, x = 0, y = 0, e, d = t.doc, r; n = t.get(n); ro = ro || d.body; if (n) { // Use getBoundingClientRect on IE, Opera has it but it's not perfect if (isIE && !t.stdMode) { n = n.getBoundingClientRect(); e = t.boxModel ? d.documentElement : d.body; x = t.getStyle(t.select('html')[0], 'borderWidth'); // Remove border x = (x == 'medium' || t.boxModel && !t.isIE6) && 2 || x; n.top += t.win.self != t.win.top ? 2 : 0; // IE adds some strange extra cord if used in a frameset return {x : n.left + e.scrollLeft - x, y : n.top + e.scrollTop - x}; } r = n; while (r && r != ro && r.nodeType) { x += r.offsetLeft || 0; y += r.offsetTop || 0; r = r.offsetParent; } r = n.parentNode; while (r && r != ro && r.nodeType) { x -= r.scrollLeft || 0; y -= r.scrollTop || 0; r = r.parentNode; } } return {x : x, y : y}; }, parseStyle : function(st) { var t = this, s = t.settings, o = {}; if (!st) return o; function compress(p, s, ot) { var t, r, b, l; // Get values and check it it needs compressing t = o[p + '-top' + s]; if (!t) return; r = o[p + '-right' + s]; if (t != r) return; b = o[p + '-bottom' + s]; if (r != b) return; l = o[p + '-left' + s]; if (b != l) return; // Compress o[ot] = l; delete o[p + '-top' + s]; delete o[p + '-right' + s]; delete o[p + '-bottom' + s]; delete o[p + '-left' + s]; }; function compress2(ta, a, b, c) { var t; t = o[a]; if (!t) return; t = o[b]; if (!t) return; t = o[c]; if (!t) return; // Compress o[ta] = o[a] + ' ' + o[b] + ' ' + o[c]; delete o[a]; delete o[b]; delete o[c]; }; st = st.replace(/&(#?[a-z0-9]+);/g, '&$1_MCE_SEMI_'); // Protect entities each(st.split(';'), function(v) { var sv, ur = []; if (v) { v = v.replace(/_MCE_SEMI_/g, ';'); // Restore entities v = v.replace(/url\([^\)]+\)/g, function(v) {ur.push(v);return 'url(' + ur.length + ')';}); v = v.split(':'); sv = tinymce.trim(v[1]); sv = sv.replace(/url\(([^\)]+)\)/g, function(a, b) {return ur[parseInt(b) - 1];}); sv = sv.replace(/rgb\([^\)]+\)/g, function(v) { return t.toHex(v); }); if (s.url_converter) { sv = sv.replace(/url\([\'\"]?([^\)\'\"]+)[\'\"]?\)/g, function(x, c) { return 'url(' + s.url_converter.call(s.url_converter_scope || t, t.decode(c), 'style', null) + ')'; }); } o[tinymce.trim(v[0]).toLowerCase()] = sv; } }); compress("border", "", "border"); compress("border", "-width", "border-width"); compress("border", "-color", "border-color"); compress("border", "-style", "border-style"); compress("padding", "", "padding"); compress("margin", "", "margin"); compress2('border', 'border-width', 'border-style', 'border-color'); if (isIE) { // Remove pointless border if (o.border == 'medium none') o.border = ''; } return o; }, serializeStyle : function(o) { var s = ''; each(o, function(v, k) { if (k && v) { if (tinymce.isGecko && k.indexOf('-moz-') === 0) return; switch (k) { case 'color': case 'background-color': v = v.toLowerCase(); break; } s += (s ? ' ' : '') + k + ': ' + v + ';'; } }); return s; }, loadCSS : function(u) { var t = this, d = t.doc, head; if (!u) u = ''; head = t.select('head')[0]; each(u.split(','), function(u) { var link; if (t.files[u]) return; t.files[u] = true; link = t.create('link', {rel : 'stylesheet', href : tinymce._addVer(u)}); // IE 8 has a bug where dynamically loading stylesheets would produce a 1 item remaining bug // This fix seems to resolve that issue by realcing the document ones a stylesheet finishes loading // It's ugly but it seems to work fine. if (isIE && d.documentMode) { link.onload = function() { d.recalc(); link.onload = null; }; } head.appendChild(link); }); }, addClass : function(e, c) { return this.run(e, function(e) { var o; if (!c) return 0; if (this.hasClass(e, c)) return e.className; o = this.removeClass(e, c); return e.className = (o != '' ? (o + ' ') : '') + c; }); }, removeClass : function(e, c) { var t = this, re; return t.run(e, function(e) { var v; if (t.hasClass(e, c)) { if (!re) re = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g"); v = e.className.replace(re, ' '); return e.className = tinymce.trim(v != ' ' ? v : ''); } return e.className; }); }, hasClass : function(n, c) { n = this.get(n); if (!n || !c) return false; return (' ' + n.className + ' ').indexOf(' ' + c + ' ') !== -1; }, show : function(e) { return this.setStyle(e, 'display', 'block'); }, hide : function(e) { return this.setStyle(e, 'display', 'none'); }, isHidden : function(e) { e = this.get(e); return !e || e.style.display == 'none' || this.getStyle(e, 'display') == 'none'; }, uniqueId : function(p) { return (!p ? 'mce_' : p) + (this.counter++); }, setHTML : function(e, h) { var t = this; return this.run(e, function(e) { var x, i, nl, n, p, x; h = t.processHTML(h); if (isIE) { function set() { try { // IE will remove comments from the beginning // unless you padd the contents with something e.innerHTML = '
    ' + h; e.removeChild(e.firstChild); } catch (ex) { // IE sometimes produces an unknown runtime error on innerHTML if it's an block element within a block element for example a div inside a p // This seems to fix this problem // Remove all child nodes while (e.firstChild) e.firstChild.removeNode(); // Create new div with HTML contents and a BR infront to keep comments x = t.create('div'); x.innerHTML = '
    ' + h; // Add all children from div to target each (x.childNodes, function(n, i) { // Skip br element if (i) e.appendChild(n); }); } }; // IE has a serious bug when it comes to paragraphs it can produce an invalid // DOM tree if contents like this

    • Item 1

    is inserted // It seems to be that IE doesn't like a root block element placed inside another root block element if (t.settings.fix_ie_paragraphs) h = h.replace(/

    <\/p>|]+)><\/p>|/gi, ' 

    '); set(); if (t.settings.fix_ie_paragraphs) { // Check for odd paragraphs this is a sign of a broken DOM nl = e.getElementsByTagName("p"); for (i = nl.length - 1, x = 0; i >= 0; i--) { n = nl[i]; if (!n.hasChildNodes()) { if (!n.mce_keep) { x = 1; // Is broken break; } n.removeAttribute('mce_keep'); } } } // Time to fix the madness IE left us if (x) { // So if we replace the p elements with divs and mark them and then replace them back to paragraphs // after we use innerHTML we can fix the DOM tree h = h.replace(/

    ]+)>|

    /ig, '

    '); h = h.replace(/<\/p>/g, '
    '); // Set the new HTML with DIVs set(); // Replace all DIV elements with he mce_tmp attibute back to paragraphs // This is needed since IE has a annoying bug see above for details // This is a slow process but it has to be done. :( if (t.settings.fix_ie_paragraphs) { nl = e.getElementsByTagName("DIV"); for (i = nl.length - 1; i >= 0; i--) { n = nl[i]; // Is it a temp div if (n.mce_tmp) { // Create new paragraph p = t.doc.createElement('p'); // Copy all attributes n.cloneNode(false).outerHTML.replace(/([a-z0-9\-_]+)=/gi, function(a, b) { var v; if (b !== 'mce_tmp') { v = n.getAttribute(b); if (!v && b === 'class') v = n.className; p.setAttribute(b, v); } }); // Append all children to new paragraph for (x = 0; x|]+)>/gi, '<$1b$2>'); h = h.replace(/<(\/?)em>|]+)>/gi, '<$1i$2>'); } else if (isIE) { h = h.replace(/'/g, '''); // IE can't handle apos h = h.replace(/\s+(disabled|checked|readonly|selected)\s*=\s*[\"\']?(false|0)[\"\']?/gi, ''); // IE doesn't handle default values correct } // Fix some issues h = h.replace(/]+)\/>|/gi, ''); // Force open // Store away src and href in mce_src and mce_href since browsers mess them up if (s.keep_values) { // Wrap scripts and styles in comments for serialization purposes if (/)/g, '\n'); s = s.replace(/^[\r\n]*|[\r\n]*$/g, ''); s = s.replace(/^\s*(\/\/\s*|\]\]>|-->|\]\]-->)\s*$/g, ''); return s; }; // Wrap the script contents in CDATA and keep them from executing h = h.replace(/]+|)>([\s\S]*?)<\/script>/gi, function(v, attribs, text) { // Force type attribute if (!attribs) attribs = ' type="text/javascript"'; // Convert the src attribute of the scripts attribs = attribs.replace(/src=\"([^\"]+)\"?/i, function(a, url) { if (s.url_converter) url = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(url), 'src', 'script')); return 'mce_src="' + url + '"'; }); // Wrap text contents if (tinymce.trim(text)) { codeBlocks.push(trim(text)); text = ''; } return '' + text + ''; }); // Wrap style elements h = h.replace(/]+|)>([\s\S]*?)<\/style>/gi, function(v, attribs, text) { // Wrap text contents if (text) { codeBlocks.push(trim(text)); text = ''; } return '' + text + ''; }); // Wrap noscript elements h = h.replace(/]+|)>([\s\S]*?)<\/noscript>/g, function(v, attribs, text) { return ''; }); } h = h.replace(//g, ''); // Remove false bool attributes and force attributes into xhtml style attr="attr" h = h.replace(/<([\w:]+) [^>]*(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)[^>]*>/gi, function(val) { function handle(val, name, value) { // Remove false/0 attribs if (value === 'false' || value === '0') return ''; return ' ' + name + '="' + name + '"'; }; val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=[\"]([^\"]+)[\"]/gi, handle); // W3C val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=[\']([^\']+)[\']/gi, handle); // W3C val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)=([^\s\"\'>]+)/gi, handle); // IE val = val.replace(/ (checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)([\s>])/gi, ' $1="$1"$2'); // Force attr="attr" return val; }); // Process all tags with src, href or style h = h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi, function(a, n) { function handle(m, b, c) { var u = c; // Tag already got a mce_ version if (a.indexOf('mce_' + b) != -1) return m; if (b == 'style') { // No mce_style for elements with these since they might get resized by the user if (t._isRes(c)) return m; // Parse and serialize the style to convert for example uppercase styles like "BORDER: 1px" u = t.encode(t.serializeStyle(t.parseStyle(u))); } else if (b != 'coords' && b != 'shape') { if (s.url_converter) u = t.encode(s.url_converter.call(s.url_converter_scope || t, t.decode(c), b, n)); } return ' ' + b + '="' + c + '" mce_' + b + '="' + u + '"'; }; a = a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi, handle); // W3C a = a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi, handle); // W3C return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi, handle); // IE }); // Restore script blocks h = h.replace(/MCE_SCRIPT:([0-9]+)/g, function(val, idx) { return codeBlocks[idx]; }); } return h; }, getOuterHTML : function(e) { var d; e = this.get(e); if (!e) return null; if (e.outerHTML !== undefined) return e.outerHTML; d = (e.ownerDocument || this.doc).createElement("body"); d.appendChild(e.cloneNode(true)); return d.innerHTML; }, setOuterHTML : function(e, h, d) { var t = this; function setHTML(e, h, d) { var n, tp; tp = d.createElement("body"); tp.innerHTML = h; n = tp.lastChild; while (n) { t.insertAfter(n.cloneNode(true), e); n = n.previousSibling; } t.remove(e); }; return this.run(e, function(e) { e = t.get(e); // Only set HTML on elements if (e.nodeType == 1) { d = d || e.ownerDocument || t.doc; if (isIE) { try { // Try outerHTML for IE it sometimes produces an unknown runtime error if (isIE && e.nodeType == 1) e.outerHTML = h; else setHTML(e, h, d); } catch (ex) { // Fix for unknown runtime error setHTML(e, h, d); } } else setHTML(e, h, d); } }); }, decode : function(s) { var e, n, v; // Look for entities to decode if (/&[^;]+;/.test(s)) { // Decode the entities using a div element not super efficient but less code e = this.doc.createElement("div"); e.innerHTML = s; n = e.firstChild; v = ''; if (n) { do { v += n.nodeValue; } while (n.nextSibling); } return v || s; } return s; }, encode : function(s) { return s ? ('' + s).replace(/[<>&\"]/g, function (c, b) { switch (c) { case '&': return '&'; case '"': return '"'; case '<': return '<'; case '>': return '>'; } return c; }) : s; }, insertAfter : function(n, r) { var t = this; r = t.get(r); return this.run(n, function(n) { var p, ns; p = r.parentNode; ns = r.nextSibling; if (ns) p.insertBefore(n, ns); else p.appendChild(n); return n; }); }, isBlock : function(n) { if (n.nodeType && n.nodeType !== 1) return false; n = n.nodeName || n; return /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TH|TBODY|TR|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n); }, replace : function(n, o, k) { var t = this; if (is(o, 'array')) n = n.cloneNode(true); return t.run(o, function(o) { if (k) { each(o.childNodes, function(c) { n.appendChild(c.cloneNode(true)); }); } // Fix IE psuedo leak for elements since replacing elements if fairly common // Will break parentNode for some unknown reason if (t.fixPsuedoLeaks && o.nodeType === 1) { o.parentNode.insertBefore(n, o); t.remove(o); return n; } return o.parentNode.replaceChild(n, o); }); }, findCommonAncestor : function(a, b) { var ps = a, pe; while (ps) { pe = b; while (pe && ps != pe) pe = pe.parentNode; if (ps == pe) break; ps = ps.parentNode; } if (!ps && a.ownerDocument) return a.ownerDocument.documentElement; return ps; }, toHex : function(s) { var c = /^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s); function hex(s) { s = parseInt(s).toString(16); return s.length > 1 ? s : '0' + s; // 0 -> 00 }; if (c) { s = '#' + hex(c[1]) + hex(c[2]) + hex(c[3]); return s; } return s; }, getClasses : function() { var t = this, cl = [], i, lo = {}, f = t.settings.class_filter, ov; if (t.classes) return t.classes; function addClasses(s) { // IE style imports each(s.imports, function(r) { addClasses(r); }); each(s.cssRules || s.rules, function(r) { // Real type or fake it on IE switch (r.type || 1) { // Rule case 1: if (r.selectorText) { each(r.selectorText.split(','), function(v) { v = v.replace(/^\s*|\s*$|^\s\./g, ""); // Is internal or it doesn't contain a class if (/\.mce/.test(v) || !/\.[\w\-]+$/.test(v)) return; // Remove everything but class name ov = v; v = v.replace(/.*\.([a-z0-9_\-]+).*/i, '$1'); // Filter classes if (f && !(v = f(v, ov))) return; if (!lo[v]) { cl.push({'class' : v}); lo[v] = 1; } }); } break; // Import case 3: addClasses(r.styleSheet); break; } }); }; try { each(t.doc.styleSheets, addClasses); } catch (ex) { // Ignore } if (cl.length > 0) t.classes = cl; return cl; }, run : function(e, f, s) { var t = this, o; if (t.doc && typeof(e) === 'string') e = t.get(e); if (!e) return false; s = s || this; if (!e.nodeType && (e.length || e.length === 0)) { o = []; each(e, function(e, i) { if (e) { if (typeof(e) == 'string') e = t.doc.getElementById(e); o.push(f.call(s, e, i)); } }); return o; } return f.call(s, e); }, getAttribs : function(n) { var o; n = this.get(n); if (!n) return []; if (isIE) { o = []; // Object will throw exception in IE if (n.nodeName == 'OBJECT') return n.attributes; // IE doesn't keep the selected attribute if you clone option elements if (n.nodeName === 'OPTION' && this.getAttrib(n, 'selected')) o.push({specified : 1, nodeName : 'selected'}); // It's crazy that this is faster in IE but it's because it returns all attributes all the time n.cloneNode(false).outerHTML.replace(/<\/?[\w:]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=\w+|>/gi, '').replace(/[\w:]+/gi, function(a) { o.push({specified : 1, nodeName : a}); }); return o; } return n.attributes; }, destroy : function(s) { var t = this; if (t.events) t.events.destroy(); t.win = t.doc = t.root = t.events = null; // Manual destroy then remove unload handler if (!s) tinymce.removeUnload(t.destroy); }, createRng : function() { var d = this.doc; return d.createRange ? d.createRange() : new tinymce.dom.Range(this); }, split : function(pe, e, re) { var t = this, r = t.createRng(), bef, aft, pa; // W3C valid browsers tend to leave empty nodes to the left/right side of the contents, this makes sence // but we don't want that in our code since it serves no purpose // For example if this is chopped: //

    text 1CHOPtext 2

    // would produce: //

    text 1

    CHOP

    text 2

    // this function will then trim of empty edges and produce: //

    text 1

    CHOP

    text 2

    function trimEdge(n, na) { n = n[na]; if (n && n[na] && n[na].nodeType == 1 && isEmpty(n[na])) t.remove(n[na]); }; function isEmpty(n) { n = t.getOuterHTML(n); n = n.replace(/<(img|hr|table)/gi, '-'); // Keep these convert them to - chars n = n.replace(/<[^>]+>/g, ''); // Remove all tags return n.replace(/[ \t\r\n]+| | /g, '') == ''; }; // Added until Gecko can create real HTML documents using implementation.createHTMLDocument // this is to future proof it if Gecko decides to implement the error checking for range methods. function nodeIndex(n) { var i = 0; while (n.previousSibling) { i++; n = n.previousSibling; } return i; }; if (pe && e) { // Get before chunk r.setStart(pe.parentNode, nodeIndex(pe)); r.setEnd(e.parentNode, nodeIndex(e)); bef = r.extractContents(); // Get after chunk r = t.createRng(); r.setStart(e.parentNode, nodeIndex(e) + 1); r.setEnd(pe.parentNode, nodeIndex(pe) + 1); aft = r.extractContents(); // Insert chunks and remove parent pa = pe.parentNode; // Remove right side edge of the before contents trimEdge(bef, 'lastChild'); if (!isEmpty(bef)) pa.insertBefore(bef, pe); if (re) pa.replaceChild(re, e); else pa.insertBefore(e, pe); // Remove left site edge of the after contents trimEdge(aft, 'firstChild'); if (!isEmpty(aft)) pa.insertBefore(aft, pe); t.remove(pe); return re || e; } }, bind : function(target, name, func, scope) { var t = this; if (!t.events) t.events = new tinymce.dom.EventUtils(); return t.events.add(target, name, func, scope || this); }, unbind : function(target, name, func) { var t = this; if (!t.events) t.events = new tinymce.dom.EventUtils(); return t.events.remove(target, name, func); }, _findSib : function(node, selector, name) { var t = this, f = selector; if (node) { // If expression make a function of it using is if (is(f, 'string')) { f = function(node) { return t.is(node, selector); }; } // Loop all siblings for (node = node[name]; node; node = node[name]) { if (f(node)) return node; } } return null; }, _isRes : function(c) { // Is live resizble element return /^(top|left|bottom|right|width|height)/i.test(c) || /;\s*(top|left|bottom|right|width|height)/i.test(c); } /* walk : function(n, f, s) { var d = this.doc, w; if (d.createTreeWalker) { w = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); while ((n = w.nextNode()) != null) f.call(s || this, n); } else tinymce.walk(n, f, 'childNodes', s); } */ /* toRGB : function(s) { var c = /^\s*?#([0-9A-F]{2})([0-9A-F]{1,2})([0-9A-F]{2})?\s*?$/.exec(s); if (c) { // #FFF -> #FFFFFF if (!is(c[3])) c[3] = c[2] = c[1]; return "rgb(" + parseInt(c[1], 16) + "," + parseInt(c[2], 16) + "," + parseInt(c[3], 16) + ")"; } return s; } */ }); tinymce.DOM = new tinymce.dom.DOMUtils(document, {process_html : 0}); })(tinymce); (function(ns) { // Traverse constants var EXTRACT = 0, CLONE = 1, DELETE = 2, extend = tinymce.extend; function indexOf(child, parent) { var i, node; if (child.parentNode != parent) return -1; for (node = parent.firstChild, i = 0; node != child; node = node.nextSibling) i++; return i; }; function nodeIndex(n) { var i = 0; while (n.previousSibling) { i++; n = n.previousSibling; } return i; }; function getSelectedNode(container, offset) { var child; if (container.nodeType == 3 /* TEXT_NODE */) return container; if (offset < 0) return container; child = container.firstChild; while (child != null && offset > 0) { --offset; child = child.nextSibling; } if (child != null) return child; return container; }; // Range constructor function Range(dom) { var d = dom.doc; extend(this, { dom : dom, // Inital states startContainer : d, startOffset : 0, endContainer : d, endOffset : 0, collapsed : true, commonAncestorContainer : d, // Range constants START_TO_START : 0, START_TO_END : 1, END_TO_END : 2, END_TO_START : 3 }); }; // Add range methods extend(Range.prototype, { setStart : function(n, o) { this._setEndPoint(true, n, o); }, setEnd : function(n, o) { this._setEndPoint(false, n, o); }, setStartBefore : function(n) { this.setStart(n.parentNode, nodeIndex(n)); }, setStartAfter : function(n) { this.setStart(n.parentNode, nodeIndex(n) + 1); }, setEndBefore : function(n) { this.setEnd(n.parentNode, nodeIndex(n)); }, setEndAfter : function(n) { this.setEnd(n.parentNode, nodeIndex(n) + 1); }, collapse : function(ts) { var t = this; if (ts) { t.endContainer = t.startContainer; t.endOffset = t.startOffset; } else { t.startContainer = t.endContainer; t.startOffset = t.endOffset; } t.collapsed = true; }, selectNode : function(n) { this.setStartBefore(n); this.setEndAfter(n); }, selectNodeContents : function(n) { this.setStart(n, 0); this.setEnd(n, n.nodeType === 1 ? n.childNodes.length : n.nodeValue.length); }, compareBoundaryPoints : function(h, r) { var t = this, sc = t.startContainer, so = t.startOffset, ec = t.endContainer, eo = t.endOffset; // Check START_TO_START if (h === 0) return t._compareBoundaryPoints(sc, so, sc, so); // Check START_TO_END if (h === 1) return t._compareBoundaryPoints(sc, so, ec, eo); // Check END_TO_END if (h === 2) return t._compareBoundaryPoints(ec, eo, ec, eo); // Check END_TO_START if (h === 3) return t._compareBoundaryPoints(ec, eo, sc, so); }, deleteContents : function() { this._traverse(DELETE); }, extractContents : function() { return this._traverse(EXTRACT); }, cloneContents : function() { return this._traverse(CLONE); }, insertNode : function(n) { var t = this, nn, o; // Node is TEXT_NODE or CDATA if (n.nodeType === 3 || n.nodeType === 4) { nn = t.startContainer.splitText(t.startOffset); t.startContainer.parentNode.insertBefore(n, nn); } else { // Insert element node if (t.startContainer.childNodes.length > 0) o = t.startContainer.childNodes[t.startOffset]; t.startContainer.insertBefore(n, o); } }, surroundContents : function(n) { var t = this, f = t.extractContents(); t.insertNode(n); n.appendChild(f); t.selectNode(n); }, cloneRange : function() { var t = this; return extend(new Range(t.dom), { startContainer : t.startContainer, startOffset : t.startOffset, endContainer : t.endContainer, endOffset : t.endOffset, collapsed : t.collapsed, commonAncestorContainer : t.commonAncestorContainer }); }, /* detach : function() { // Not implemented }, */ // Internal methods _isCollapsed : function() { return (this.startContainer == this.endContainer && this.startOffset == this.endOffset); }, _compareBoundaryPoints : function (containerA, offsetA, containerB, offsetB) { var c, offsetC, n, cmnRoot, childA, childB; // In the first case the boundary-points have the same container. A is before B // if its offset is less than the offset of B, A is equal to B if its offset is // equal to the offset of B, and A is after B if its offset is greater than the // offset of B. if (containerA == containerB) { if (offsetA == offsetB) { return 0; // equal } else if (offsetA < offsetB) { return -1; // before } else { return 1; // after } } // In the second case a child node C of the container of A is an ancestor // container of B. In this case, A is before B if the offset of A is less than or // equal to the index of the child node C and A is after B otherwise. c = containerB; while (c && c.parentNode != containerA) { c = c.parentNode; } if (c) { offsetC = 0; n = containerA.firstChild; while (n != c && offsetC < offsetA) { offsetC++; n = n.nextSibling; } if (offsetA <= offsetC) { return -1; // before } else { return 1; // after } } // In the third case a child node C of the container of B is an ancestor container // of A. In this case, A is before B if the index of the child node C is less than // the offset of B and A is after B otherwise. c = containerA; while (c && c.parentNode != containerB) { c = c.parentNode; } if (c) { offsetC = 0; n = containerB.firstChild; while (n != c && offsetC < offsetB) { offsetC++; n = n.nextSibling; } if (offsetC < offsetB) { return -1; // before } else { return 1; // after } } // In the fourth case, none of three other cases hold: the containers of A and B // are siblings or descendants of sibling nodes. In this case, A is before B if // the container of A is before the container of B in a pre-order traversal of the // Ranges' context tree and A is after B otherwise. cmnRoot = this.dom.findCommonAncestor(containerA, containerB); childA = containerA; while (childA && childA.parentNode != cmnRoot) { childA = childA.parentNode; } if (!childA) { childA = cmnRoot; } childB = containerB; while (childB && childB.parentNode != cmnRoot) { childB = childB.parentNode; } if (!childB) { childB = cmnRoot; } if (childA == childB) { return 0; // equal } n = cmnRoot.firstChild; while (n) { if (n == childA) { return -1; // before } if (n == childB) { return 1; // after } n = n.nextSibling; } }, _setEndPoint : function(st, n, o) { var t = this, ec, sc; if (st) { t.startContainer = n; t.startOffset = o; } else { t.endContainer = n; t.endOffset = o; } // If one boundary-point of a Range is set to have a root container // other than the current one for the Range, the Range is collapsed to // the new position. This enforces the restriction that both boundary- // points of a Range must have the same root container. ec = t.endContainer; while (ec.parentNode) ec = ec.parentNode; sc = t.startContainer; while (sc.parentNode) sc = sc.parentNode; if (sc != ec) { t.collapse(st); } else { // The start position of a Range is guaranteed to never be after the // end position. To enforce this restriction, if the start is set to // be at a position after the end, the Range is collapsed to that // position. if (t._compareBoundaryPoints(t.startContainer, t.startOffset, t.endContainer, t.endOffset) > 0) t.collapse(st); } t.collapsed = t._isCollapsed(); t.commonAncestorContainer = t.dom.findCommonAncestor(t.startContainer, t.endContainer); }, // This code is heavily "inspired" by the Apache Xerces implementation. I hope they don't mind. :) _traverse : function(how) { var t = this, c, endContainerDepth = 0, startContainerDepth = 0, p, depthDiff, startNode, endNode, sp, ep; if (t.startContainer == t.endContainer) return t._traverseSameContainer(how); for (c = t.endContainer, p = c.parentNode; p != null; c = p, p = p.parentNode) { if (p == t.startContainer) return t._traverseCommonStartContainer(c, how); ++endContainerDepth; } for (c = t.startContainer, p = c.parentNode; p != null; c = p, p = p.parentNode) { if (p == t.endContainer) return t._traverseCommonEndContainer(c, how); ++startContainerDepth; } depthDiff = startContainerDepth - endContainerDepth; startNode = t.startContainer; while (depthDiff > 0) { startNode = startNode.parentNode; depthDiff--; } endNode = t.endContainer; while (depthDiff < 0) { endNode = endNode.parentNode; depthDiff++; } // ascend the ancestor hierarchy until we have a common parent. for (sp = startNode.parentNode, ep = endNode.parentNode; sp != ep; sp = sp.parentNode, ep = ep.parentNode) { startNode = sp; endNode = ep; } return t._traverseCommonAncestors(startNode, endNode, how); }, _traverseSameContainer : function(how) { var t = this, frag, s, sub, n, cnt, sibling, xferNode; if (how != DELETE) frag = t.dom.doc.createDocumentFragment(); // If selection is empty, just return the fragment if (t.startOffset == t.endOffset) return frag; // Text node needs special case handling if (t.startContainer.nodeType == 3 /* TEXT_NODE */) { // get the substring s = t.startContainer.nodeValue; sub = s.substring(t.startOffset, t.endOffset); // set the original text node to its new value if (how != CLONE) { t.startContainer.deleteData(t.startOffset, t.endOffset - t.startOffset); // Nothing is partially selected, so collapse to start point t.collapse(true); } if (how == DELETE) return null; frag.appendChild(t.dom.doc.createTextNode(sub)); return frag; } // Copy nodes between the start/end offsets. n = getSelectedNode(t.startContainer, t.startOffset); cnt = t.endOffset - t.startOffset; while (cnt > 0) { sibling = n.nextSibling; xferNode = t._traverseFullySelected(n, how); if (frag) frag.appendChild( xferNode ); --cnt; n = sibling; } // Nothing is partially selected, so collapse to start point if (how != CLONE) t.collapse(true); return frag; }, _traverseCommonStartContainer : function(endAncestor, how) { var t = this, frag, n, endIdx, cnt, sibling, xferNode; if (how != DELETE) frag = t.dom.doc.createDocumentFragment(); n = t._traverseRightBoundary(endAncestor, how); if (frag) frag.appendChild(n); endIdx = indexOf(endAncestor, t.startContainer); cnt = endIdx - t.startOffset; if (cnt <= 0) { // Collapse to just before the endAncestor, which // is partially selected. if (how != CLONE) { t.setEndBefore(endAncestor); t.collapse(false); } return frag; } n = endAncestor.previousSibling; while (cnt > 0) { sibling = n.previousSibling; xferNode = t._traverseFullySelected(n, how); if (frag) frag.insertBefore(xferNode, frag.firstChild); --cnt; n = sibling; } // Collapse to just before the endAncestor, which // is partially selected. if (how != CLONE) { t.setEndBefore(endAncestor); t.collapse(false); } return frag; }, _traverseCommonEndContainer : function(startAncestor, how) { var t = this, frag, startIdx, n, cnt, sibling, xferNode; if (how != DELETE) frag = t.dom.doc.createDocumentFragment(); n = t._traverseLeftBoundary(startAncestor, how); if (frag) frag.appendChild(n); startIdx = indexOf(startAncestor, t.endContainer); ++startIdx; // Because we already traversed it.... cnt = t.endOffset - startIdx; n = startAncestor.nextSibling; while (cnt > 0) { sibling = n.nextSibling; xferNode = t._traverseFullySelected(n, how); if (frag) frag.appendChild(xferNode); --cnt; n = sibling; } if (how != CLONE) { t.setStartAfter(startAncestor); t.collapse(true); } return frag; }, _traverseCommonAncestors : function(startAncestor, endAncestor, how) { var t = this, n, frag, commonParent, startOffset, endOffset, cnt, sibling, nextSibling; if (how != DELETE) frag = t.dom.doc.createDocumentFragment(); n = t._traverseLeftBoundary(startAncestor, how); if (frag) frag.appendChild(n); commonParent = startAncestor.parentNode; startOffset = indexOf(startAncestor, commonParent); endOffset = indexOf(endAncestor, commonParent); ++startOffset; cnt = endOffset - startOffset; sibling = startAncestor.nextSibling; while (cnt > 0) { nextSibling = sibling.nextSibling; n = t._traverseFullySelected(sibling, how); if (frag) frag.appendChild(n); sibling = nextSibling; --cnt; } n = t._traverseRightBoundary(endAncestor, how); if (frag) frag.appendChild(n); if (how != CLONE) { t.setStartAfter(startAncestor); t.collapse(true); } return frag; }, _traverseRightBoundary : function(root, how) { var t = this, next = getSelectedNode(t.endContainer, t.endOffset - 1), parent, clonedParent, prevSibling, clonedChild, clonedGrandParent; var isFullySelected = next != t.endContainer; if (next == root) return t._traverseNode(next, isFullySelected, false, how); parent = next.parentNode; clonedParent = t._traverseNode(parent, false, false, how); while (parent != null) { while (next != null) { prevSibling = next.previousSibling; clonedChild = t._traverseNode(next, isFullySelected, false, how); if (how != DELETE) clonedParent.insertBefore(clonedChild, clonedParent.firstChild); isFullySelected = true; next = prevSibling; } if (parent == root) return clonedParent; next = parent.previousSibling; parent = parent.parentNode; clonedGrandParent = t._traverseNode(parent, false, false, how); if (how != DELETE) clonedGrandParent.appendChild(clonedParent); clonedParent = clonedGrandParent; } // should never occur return null; }, _traverseLeftBoundary : function(root, how) { var t = this, next = getSelectedNode(t.startContainer, t.startOffset); var isFullySelected = next != t.startContainer, parent, clonedParent, nextSibling, clonedChild, clonedGrandParent; if (next == root) return t._traverseNode(next, isFullySelected, true, how); parent = next.parentNode; clonedParent = t._traverseNode(parent, false, true, how); while (parent != null) { while (next != null) { nextSibling = next.nextSibling; clonedChild = t._traverseNode(next, isFullySelected, true, how); if (how != DELETE) clonedParent.appendChild(clonedChild); isFullySelected = true; next = nextSibling; } if (parent == root) return clonedParent; next = parent.nextSibling; parent = parent.parentNode; clonedGrandParent = t._traverseNode(parent, false, true, how); if (how != DELETE) clonedGrandParent.appendChild(clonedParent); clonedParent = clonedGrandParent; } // should never occur return null; }, _traverseNode : function(n, isFullySelected, isLeft, how) { var t = this, txtValue, newNodeValue, oldNodeValue, offset, newNode; if (isFullySelected) return t._traverseFullySelected(n, how); if (n.nodeType == 3 /* TEXT_NODE */) { txtValue = n.nodeValue; if (isLeft) { offset = t.startOffset; newNodeValue = txtValue.substring(offset); oldNodeValue = txtValue.substring(0, offset); } else { offset = t.endOffset; newNodeValue = txtValue.substring(0, offset); oldNodeValue = txtValue.substring(offset); } if (how != CLONE) n.nodeValue = oldNodeValue; if (how == DELETE) return null; newNode = n.cloneNode(false); newNode.nodeValue = newNodeValue; return newNode; } if (how == DELETE) return null; return n.cloneNode(false); }, _traverseFullySelected : function(n, how) { var t = this; if (how != DELETE) return how == CLONE ? n.cloneNode(true) : n; n.parentNode.removeChild(n); return null; } }); ns.Range = Range; })(tinymce.dom); (function() { function Selection(selection) { var t = this, invisibleChar = '\uFEFF', range, lastIERng; function compareRanges(rng1, rng2) { if (rng1 && rng2) { // Both are control ranges and the selected element matches if (rng1.item && rng2.item && rng1.item(0) === rng2.item(0)) return 1; // Both are text ranges and the range matches if (rng1.isEqual && rng2.isEqual && rng2.isEqual(rng1)) return 1; } return 0; }; function getRange() { var dom = selection.dom, ieRange = selection.getRng(), domRange = dom.createRng(), startPos, endPos, element, sc, ec, collapsed; function findIndex(element) { var nl = element.parentNode.childNodes, i; for (i = nl.length - 1; i >= 0; i--) { if (nl[i] == element) return i; } return -1; }; function findEndPoint(start) { var rng = ieRange.duplicate(), parent, i, nl, n, offset = 0, index = 0, pos, tmpRng; // Insert marker character rng.collapse(start); parent = rng.parentElement(); rng.pasteHTML(invisibleChar); // Needs to be a pasteHTML instead of .text = since IE has a bug with nodeValue // Find marker character nl = parent.childNodes; for (i = 0; i < nl.length; i++) { n = nl[i]; // Calculate node index excluding text node fragmentation if (i > 0 && (n.nodeType !== 3 || nl[i - 1].nodeType !== 3)) index++; // If text node then calculate offset if (n.nodeType === 3) { // Look for marker pos = n.nodeValue.indexOf(invisibleChar); if (pos !== -1) { offset += pos; break; } offset += n.nodeValue.length; } else offset = 0; } // Remove marker character rng.moveStart('character', -1); rng.text = ''; return {index : index, offset : offset, parent : parent}; }; // If selection is outside the current document just return an empty range element = ieRange.item ? ieRange.item(0) : ieRange.parentElement(); if (element.ownerDocument != dom.doc) return domRange; // Handle control selection or text selection of a image if (ieRange.item || !element.hasChildNodes()) { domRange.setStart(element.parentNode, findIndex(element)); domRange.setEnd(domRange.startContainer, domRange.startOffset + 1); return domRange; } // Check collapsed state collapsed = selection.isCollapsed(); // Find start and end pos index and offset startPos = findEndPoint(true); endPos = findEndPoint(false); // Normalize the elements to avoid fragmented dom startPos.parent.normalize(); endPos.parent.normalize(); // Set start container and offset sc = startPos.parent.childNodes[Math.min(startPos.index, startPos.parent.childNodes.length - 1)]; if (sc.nodeType != 3) domRange.setStart(startPos.parent, startPos.index); else domRange.setStart(startPos.parent.childNodes[startPos.index], startPos.offset); // Set end container and offset ec = endPos.parent.childNodes[Math.min(endPos.index, endPos.parent.childNodes.length - 1)]; if (ec.nodeType != 3) { if (!collapsed) endPos.index++; domRange.setEnd(endPos.parent, endPos.index); } else domRange.setEnd(endPos.parent.childNodes[endPos.index], endPos.offset); // If not collapsed then make sure offsets are valid if (!collapsed) { sc = domRange.startContainer; if (sc.nodeType == 1) domRange.setStart(sc, Math.min(domRange.startOffset, sc.childNodes.length)); ec = domRange.endContainer; if (ec.nodeType == 1) domRange.setEnd(ec, Math.min(domRange.endOffset, ec.childNodes.length)); } // Restore selection to new range t.addRange(domRange); return domRange; }; this.addRange = function(rng) { var ieRng, body = selection.dom.doc.body, startPos, endPos, sc, so, ec, eo; // Setup some shorter versions sc = rng.startContainer; so = rng.startOffset; ec = rng.endContainer; eo = rng.endOffset; ieRng = body.createTextRange(); // Find element sc = sc.nodeType == 1 ? sc.childNodes[Math.min(so, sc.childNodes.length - 1)] : sc; ec = ec.nodeType == 1 ? ec.childNodes[Math.min(so == eo ? eo : eo - 1, ec.childNodes.length - 1)] : ec; // Single element selection if (sc == ec && sc.nodeType == 1) { // Make control selection for some elements if (/^(IMG|TABLE)$/.test(sc.nodeName) && so != eo) { ieRng = body.createControlRange(); ieRng.addElement(sc); } else { ieRng = body.createTextRange(); // Padd empty elements with invisible character if (!sc.hasChildNodes() && sc.canHaveHTML) sc.innerHTML = invisibleChar; // Select element contents ieRng.moveToElementText(sc); // If it's only containing a padding remove it so the caret remains if (sc.innerHTML == invisibleChar) { ieRng.collapse(true); sc.removeChild(sc.firstChild); } } if (so == eo) ieRng.collapse(eo <= rng.endContainer.childNodes.length - 1); ieRng.select(); return; } function getCharPos(container, offset) { var nodeVal, rng, pos; if (container.nodeType != 3) return -1; nodeVal = container.nodeValue; rng = body.createTextRange(); // Insert marker at offset position container.nodeValue = nodeVal.substring(0, offset) + invisibleChar + nodeVal.substring(offset); // Find char pos of marker and remove it rng.moveToElementText(container.parentNode); rng.findText(invisibleChar); pos = Math.abs(rng.moveStart('character', -0xFFFFF)); container.nodeValue = nodeVal; return pos; }; // Collapsed range if (rng.collapsed) { pos = getCharPos(sc, so); ieRng = body.createTextRange(); ieRng.move('character', pos); ieRng.select(); return; } else { // If same text container if (sc == ec && sc.nodeType == 3) { startPos = getCharPos(sc, so); ieRng = body.createTextRange(); ieRng.move('character', startPos); ieRng.moveEnd('character', eo - so); ieRng.select(); return; } // Get caret positions startPos = getCharPos(sc, so); endPos = getCharPos(ec, eo); ieRng = body.createTextRange(); // Move start of range to start character position or start element if (startPos == -1) { ieRng.moveToElementText(sc); startPos = 0; } else ieRng.move('character', startPos); // Move end of range to end character position or end element tmpRng = body.createTextRange(); if (endPos == -1) tmpRng.moveToElementText(ec); else tmpRng.move('character', endPos); ieRng.setEndPoint('EndToEnd', tmpRng); ieRng.select(); return; } }; this.getRangeAt = function() { // Setup new range if the cache is empty if (!range || !compareRanges(lastIERng, selection.getRng())) { range = getRange(); // Store away text range for next call lastIERng = selection.getRng(); } // Return cached range return range; }; this.destroy = function() { // Destroy cached range and last IE range to avoid memory leaks lastIERng = range = null; }; }; // Expose the selection object tinymce.dom.TridentSelection = Selection; })(); /* * Sizzle CSS Selector Engine - v1.0 * Copyright 2009, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * More information: http://sizzlejs.com/ */ (function(){ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, done = 0, toString = Object.prototype.toString, hasDuplicate = false; var Sizzle = function(selector, context, results, seed) { results = results || []; var origContext = context = context || document; if ( context.nodeType !== 1 && context.nodeType !== 9 ) { return []; } if ( !selector || typeof selector !== "string" ) { return results; } var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); // Reset the position of the chunker regexp (start from head) chunker.lastIndex = 0; while ( (m = chunker.exec(selector)) !== null ) { parts.push( m[1] ); if ( m[2] ) { extra = RegExp.rightContext; break; } } if ( parts.length > 1 && origPOS.exec( selector ) ) { if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { set = posProcess( parts[0] + parts[1], context ); } else { set = Expr.relative[ parts[0] ] ? [ context ] : Sizzle( parts.shift(), context ); while ( parts.length ) { selector = parts.shift(); if ( Expr.relative[ selector ] ) selector += parts.shift(); set = posProcess( selector, set ); } } } else { // Take a shortcut and set the context if the root selector is an ID // (but not if it'll be faster if the inner selector is an ID) if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { var ret = Sizzle.find( parts.shift(), context, contextXML ); context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; } if ( context ) { var ret = seed ? { expr: parts.pop(), set: makeArray(seed) } : Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; if ( parts.length > 0 ) { checkSet = makeArray(set); } else { prune = false; } while ( parts.length ) { var cur = parts.pop(), pop = cur; if ( !Expr.relative[ cur ] ) { cur = ""; } else { pop = parts.pop(); } if ( pop == null ) { pop = context; } Expr.relative[ cur ]( checkSet, pop, contextXML ); } } else { checkSet = parts = []; } } if ( !checkSet ) { checkSet = set; } if ( !checkSet ) { throw "Syntax error, unrecognized expression: " + (cur || selector); } if ( toString.call(checkSet) === "[object Array]" ) { if ( !prune ) { results.push.apply( results, checkSet ); } else if ( context && context.nodeType === 1 ) { for ( var i = 0; checkSet[i] != null; i++ ) { if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { results.push( set[i] ); } } } else { for ( var i = 0; checkSet[i] != null; i++ ) { if ( checkSet[i] && checkSet[i].nodeType === 1 ) { results.push( set[i] ); } } } } else { makeArray( checkSet, results ); } if ( extra ) { Sizzle( extra, origContext, results, seed ); Sizzle.uniqueSort( results ); } return results; }; Sizzle.uniqueSort = function(results){ if ( sortOrder ) { hasDuplicate = false; results.sort(sortOrder); if ( hasDuplicate ) { for ( var i = 1; i < results.length; i++ ) { if ( results[i] === results[i-1] ) { results.splice(i--, 1); } } } } }; Sizzle.matches = function(expr, set){ return Sizzle(expr, null, null, set); }; Sizzle.find = function(expr, context, isXML){ var set, match; if ( !expr ) { return []; } for ( var i = 0, l = Expr.order.length; i < l; i++ ) { var type = Expr.order[i], match; if ( (match = Expr.match[ type ].exec( expr )) ) { var left = RegExp.leftContext; if ( left.substr( left.length - 1 ) !== "\\" ) { match[1] = (match[1] || "").replace(/\\/g, ""); set = Expr.find[ type ]( match, context, isXML ); if ( set != null ) { expr = expr.replace( Expr.match[ type ], "" ); break; } } } } if ( !set ) { set = context.getElementsByTagName("*"); } return {set: set, expr: expr}; }; Sizzle.filter = function(expr, set, inplace, not){ var old = expr, result = [], curLoop = set, match, anyFound, isXMLFilter = set && set[0] && isXML(set[0]); while ( expr && set.length ) { for ( var type in Expr.filter ) { if ( (match = Expr.match[ type ].exec( expr )) != null ) { var filter = Expr.filter[ type ], found, item; anyFound = false; if ( curLoop == result ) { result = []; } if ( Expr.preFilter[ type ] ) { match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); if ( !match ) { anyFound = found = true; } else if ( match === true ) { continue; } } if ( match ) { for ( var i = 0; (item = curLoop[i]) != null; i++ ) { if ( item ) { found = filter( item, match, i, curLoop ); var pass = not ^ !!found; if ( inplace && found != null ) { if ( pass ) { anyFound = true; } else { curLoop[i] = false; } } else if ( pass ) { result.push( item ); anyFound = true; } } } } if ( found !== undefined ) { if ( !inplace ) { curLoop = result; } expr = expr.replace( Expr.match[ type ], "" ); if ( !anyFound ) { return []; } break; } } } // Improper expression if ( expr == old ) { if ( anyFound == null ) { throw "Syntax error, unrecognized expression: " + expr; } else { break; } } old = expr; } return curLoop; }; var Expr = Sizzle.selectors = { order: [ "ID", "NAME", "TAG" ], match: { ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ }, attrMap: { "class": "className", "for": "htmlFor" }, attrHandle: { href: function(elem){ return elem.getAttribute("href"); } }, relative: { "+": function(checkSet, part, isXML){ var isPartStr = typeof part === "string", isTag = isPartStr && !/\W/.test(part), isPartStrNotTag = isPartStr && !isTag; if ( isTag && !isXML ) { part = part.toUpperCase(); } for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { if ( (elem = checkSet[i]) ) { while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? elem || false : elem === part; } } if ( isPartStrNotTag ) { Sizzle.filter( part, checkSet, true ); } }, ">": function(checkSet, part, isXML){ var isPartStr = typeof part === "string"; if ( isPartStr && !/\W/.test(part) ) { part = isXML ? part : part.toUpperCase(); for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { var parent = elem.parentNode; checkSet[i] = parent.nodeName === part ? parent : false; } } } else { for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { checkSet[i] = isPartStr ? elem.parentNode : elem.parentNode === part; } } if ( isPartStr ) { Sizzle.filter( part, checkSet, true ); } } }, "": function(checkSet, part, isXML){ var doneName = done++, checkFn = dirCheck; if ( !part.match(/\W/) ) { var nodeCheck = part = isXML ? part : part.toUpperCase(); checkFn = dirNodeCheck; } checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); }, "~": function(checkSet, part, isXML){ var doneName = done++, checkFn = dirCheck; if ( typeof part === "string" && !part.match(/\W/) ) { var nodeCheck = part = isXML ? part : part.toUpperCase(); checkFn = dirNodeCheck; } checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); } }, find: { ID: function(match, context, isXML){ if ( typeof context.getElementById !== "undefined" && !isXML ) { var m = context.getElementById(match[1]); return m ? [m] : []; } }, NAME: function(match, context, isXML){ if ( typeof context.getElementsByName !== "undefined" ) { var ret = [], results = context.getElementsByName(match[1]); for ( var i = 0, l = results.length; i < l; i++ ) { if ( results[i].getAttribute("name") === match[1] ) { ret.push( results[i] ); } } return ret.length === 0 ? null : ret; } }, TAG: function(match, context){ return context.getElementsByTagName(match[1]); } }, preFilter: { CLASS: function(match, curLoop, inplace, result, not, isXML){ match = " " + match[1].replace(/\\/g, "") + " "; if ( isXML ) { return match; } for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { if ( elem ) { if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { if ( !inplace ) result.push( elem ); } else if ( inplace ) { curLoop[i] = false; } } } return false; }, ID: function(match){ return match[1].replace(/\\/g, ""); }, TAG: function(match, curLoop){ for ( var i = 0; curLoop[i] === false; i++ ){} return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); }, CHILD: function(match){ if ( match[1] == "nth" ) { // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); // calculate the numbers (first)n+(last) including if they are negative match[2] = (test[1] + (test[2] || 1)) - 0; match[3] = test[3] - 0; } // TODO: Move to normal caching system match[0] = done++; return match; }, ATTR: function(match, curLoop, inplace, result, not, isXML){ var name = match[1].replace(/\\/g, ""); if ( !isXML && Expr.attrMap[name] ) { match[1] = Expr.attrMap[name]; } if ( match[2] === "~=" ) { match[4] = " " + match[4] + " "; } return match; }, PSEUDO: function(match, curLoop, inplace, result, not){ if ( match[1] === "not" ) { // If we're dealing with a complex expression, or a simple one if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { match[3] = Sizzle(match[3], null, null, curLoop); } else { var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); if ( !inplace ) { result.push.apply( result, ret ); } return false; } } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { return true; } return match; }, POS: function(match){ match.unshift( true ); return match; } }, filters: { enabled: function(elem){ return elem.disabled === false && elem.type !== "hidden"; }, disabled: function(elem){ return elem.disabled === true; }, checked: function(elem){ return elem.checked === true; }, selected: function(elem){ // Accessing this property makes selected-by-default // options in Safari work properly elem.parentNode.selectedIndex; return elem.selected === true; }, parent: function(elem){ return !!elem.firstChild; }, empty: function(elem){ return !elem.firstChild; }, has: function(elem, i, match){ return !!Sizzle( match[3], elem ).length; }, header: function(elem){ return /h\d/i.test( elem.nodeName ); }, text: function(elem){ return "text" === elem.type; }, radio: function(elem){ return "radio" === elem.type; }, checkbox: function(elem){ return "checkbox" === elem.type; }, file: function(elem){ return "file" === elem.type; }, password: function(elem){ return "password" === elem.type; }, submit: function(elem){ return "submit" === elem.type; }, image: function(elem){ return "image" === elem.type; }, reset: function(elem){ return "reset" === elem.type; }, button: function(elem){ return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; }, input: function(elem){ return /input|select|textarea|button/i.test(elem.nodeName); } }, setFilters: { first: function(elem, i){ return i === 0; }, last: function(elem, i, match, array){ return i === array.length - 1; }, even: function(elem, i){ return i % 2 === 0; }, odd: function(elem, i){ return i % 2 === 1; }, lt: function(elem, i, match){ return i < match[3] - 0; }, gt: function(elem, i, match){ return i > match[3] - 0; }, nth: function(elem, i, match){ return match[3] - 0 == i; }, eq: function(elem, i, match){ return match[3] - 0 == i; } }, filter: { PSEUDO: function(elem, match, i, array){ var name = match[1], filter = Expr.filters[ name ]; if ( filter ) { return filter( elem, i, match, array ); } else if ( name === "contains" ) { return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; } else if ( name === "not" ) { var not = match[3]; for ( var i = 0, l = not.length; i < l; i++ ) { if ( not[i] === elem ) { return false; } } return true; } }, CHILD: function(elem, match){ var type = match[1], node = elem; switch (type) { case 'only': case 'first': while (node = node.previousSibling) { if ( node.nodeType === 1 ) return false; } if ( type == 'first') return true; node = elem; case 'last': while (node = node.nextSibling) { if ( node.nodeType === 1 ) return false; } return true; case 'nth': var first = match[2], last = match[3]; if ( first == 1 && last == 0 ) { return true; } var doneName = match[0], parent = elem.parentNode; if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { var count = 0; for ( node = parent.firstChild; node; node = node.nextSibling ) { if ( node.nodeType === 1 ) { node.nodeIndex = ++count; } } parent.sizcache = doneName; } var diff = elem.nodeIndex - last; if ( first == 0 ) { return diff == 0; } else { return ( diff % first == 0 && diff / first >= 0 ); } } }, ID: function(elem, match){ return elem.nodeType === 1 && elem.getAttribute("id") === match; }, TAG: function(elem, match){ return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; }, CLASS: function(elem, match){ return (" " + (elem.className || elem.getAttribute("class")) + " ") .indexOf( match ) > -1; }, ATTR: function(elem, match){ var name = match[1], result = Expr.attrHandle[ name ] ? Expr.attrHandle[ name ]( elem ) : elem[ name ] != null ? elem[ name ] : elem.getAttribute( name ), value = result + "", type = match[2], check = match[4]; return result == null ? type === "!=" : type === "=" ? value === check : type === "*=" ? value.indexOf(check) >= 0 : type === "~=" ? (" " + value + " ").indexOf(check) >= 0 : !check ? value && result !== false : type === "!=" ? value != check : type === "^=" ? value.indexOf(check) === 0 : type === "$=" ? value.substr(value.length - check.length) === check : type === "|=" ? value === check || value.substr(0, check.length + 1) === check + "-" : false; }, POS: function(elem, match, i, array){ var name = match[2], filter = Expr.setFilters[ name ]; if ( filter ) { return filter( elem, i, match, array ); } } } }; var origPOS = Expr.match.POS; for ( var type in Expr.match ) { Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); } var makeArray = function(array, results) { array = Array.prototype.slice.call( array ); if ( results ) { results.push.apply( results, array ); return results; } return array; }; // Perform a simple check to determine if the browser is capable of // converting a NodeList to an array using builtin methods. try { Array.prototype.slice.call( document.documentElement.childNodes ); // Provide a fallback method if it does not work } catch(e){ makeArray = function(array, results) { var ret = results || []; if ( toString.call(array) === "[object Array]" ) { Array.prototype.push.apply( ret, array ); } else { if ( typeof array.length === "number" ) { for ( var i = 0, l = array.length; i < l; i++ ) { ret.push( array[i] ); } } else { for ( var i = 0; array[i]; i++ ) { ret.push( array[i] ); } } } return ret; }; } var sortOrder; if ( document.documentElement.compareDocumentPosition ) { sortOrder = function( a, b ) { var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; if ( ret === 0 ) { hasDuplicate = true; } return ret; }; } else if ( "sourceIndex" in document.documentElement ) { sortOrder = function( a, b ) { var ret = a.sourceIndex - b.sourceIndex; if ( ret === 0 ) { hasDuplicate = true; } return ret; }; } else if ( document.createRange ) { sortOrder = function( a, b ) { var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); aRange.setStart(a, 0); aRange.setEnd(a, 0); bRange.setStart(b, 0); bRange.setEnd(b, 0); var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); if ( ret === 0 ) { hasDuplicate = true; } return ret; }; } // Check to see if the browser returns elements by name when // querying by getElementById (and provide a workaround) (function(){ // We're going to inject a fake input element with a specified name var form = document.createElement("div"), id = "script" + (new Date).getTime(); form.innerHTML = ""; // Inject it into the root element, check its status, and remove it quickly var root = document.documentElement; root.insertBefore( form, root.firstChild ); // The workaround has to do additional checks after a getElementById // Which slows things down for other browsers (hence the branching) if ( !!document.getElementById( id ) ) { Expr.find.ID = function(match, context, isXML){ if ( typeof context.getElementById !== "undefined" && !isXML ) { var m = context.getElementById(match[1]); return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; } }; Expr.filter.ID = function(elem, match){ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); return elem.nodeType === 1 && node && node.nodeValue === match; }; } root.removeChild( form ); })(); (function(){ // Check to see if the browser returns only elements // when doing getElementsByTagName("*") // Create a fake element var div = document.createElement("div"); div.appendChild( document.createComment("") ); // Make sure no comments are found if ( div.getElementsByTagName("*").length > 0 ) { Expr.find.TAG = function(match, context){ var results = context.getElementsByTagName(match[1]); // Filter out possible comments if ( match[1] === "*" ) { var tmp = []; for ( var i = 0; results[i]; i++ ) { if ( results[i].nodeType === 1 ) { tmp.push( results[i] ); } } results = tmp; } return results; }; } // Check to see if an attribute returns normalized href attributes div.innerHTML = ""; if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && div.firstChild.getAttribute("href") !== "#" ) { Expr.attrHandle.href = function(elem){ return elem.getAttribute("href", 2); }; } })(); if ( document.querySelectorAll ) (function(){ var oldSizzle = Sizzle, div = document.createElement("div"); div.innerHTML = "

    "; // Safari can't handle uppercase or unicode characters when // in quirks mode. if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { return; } Sizzle = function(query, context, extra, seed){ context = context || document; // Only use querySelectorAll on non-XML documents // (ID selectors don't work in non-HTML documents) if ( !seed && context.nodeType === 9 && !isXML(context) ) { try { return makeArray( context.querySelectorAll(query), extra ); } catch(e){} } return oldSizzle(query, context, extra, seed); }; for ( var prop in oldSizzle ) { Sizzle[ prop ] = oldSizzle[ prop ]; } })(); if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ var div = document.createElement("div"); div.innerHTML = "
    "; // Opera can't find a second classname (in 9.6) if ( div.getElementsByClassName("e").length === 0 ) return; // Safari caches class attributes, doesn't catch changes (in 3.2) div.lastChild.className = "e"; if ( div.getElementsByClassName("e").length === 1 ) return; Expr.order.splice(1, 0, "CLASS"); Expr.find.CLASS = function(match, context, isXML) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { return context.getElementsByClassName(match[1]); } }; })(); function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { var sibDir = dir == "previousSibling" && !isXML; for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { if ( sibDir && elem.nodeType === 1 ){ elem.sizcache = doneName; elem.sizset = i; } elem = elem[dir]; var match = false; while ( elem ) { if ( elem.sizcache === doneName ) { match = checkSet[elem.sizset]; break; } if ( elem.nodeType === 1 && !isXML ){ elem.sizcache = doneName; elem.sizset = i; } if ( elem.nodeName === cur ) { match = elem; break; } elem = elem[dir]; } checkSet[i] = match; } } } function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { var sibDir = dir == "previousSibling" && !isXML; for ( var i = 0, l = checkSet.length; i < l; i++ ) { var elem = checkSet[i]; if ( elem ) { if ( sibDir && elem.nodeType === 1 ) { elem.sizcache = doneName; elem.sizset = i; } elem = elem[dir]; var match = false; while ( elem ) { if ( elem.sizcache === doneName ) { match = checkSet[elem.sizset]; break; } if ( elem.nodeType === 1 ) { if ( !isXML ) { elem.sizcache = doneName; elem.sizset = i; } if ( typeof cur !== "string" ) { if ( elem === cur ) { match = true; break; } } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { match = elem; break; } } elem = elem[dir]; } checkSet[i] = match; } } } var contains = document.compareDocumentPosition ? function(a, b){ return a.compareDocumentPosition(b) & 16; } : function(a, b){ return a !== b && (a.contains ? a.contains(b) : true); }; var isXML = function(elem){ return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; }; var posProcess = function(selector, context){ var tmpSet = [], later = "", match, root = context.nodeType ? [context] : context; // Position selectors must be done after the filter // And so must :not(positional) so we move all PSEUDOs to the end while ( (match = Expr.match.PSEUDO.exec( selector )) ) { later += match[0]; selector = selector.replace( Expr.match.PSEUDO, "" ); } selector = Expr.relative[selector] ? selector + "*" : selector; for ( var i = 0, l = root.length; i < l; i++ ) { Sizzle( selector, root[i], tmpSet ); } return Sizzle.filter( later, tmpSet ); }; // EXPOSE window.tinymce.dom.Sizzle = Sizzle; })(); (function(tinymce) { // Shorten names var each = tinymce.each, DOM = tinymce.DOM, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit, Event; tinymce.create('tinymce.dom.EventUtils', { EventUtils : function() { this.inits = []; this.events = []; }, add : function(o, n, f, s) { var cb, t = this, el = t.events, r; if (n instanceof Array) { r = []; each(n, function(n) { r.push(t.add(o, n, f, s)); }); return r; } // Handle array if (o && o.hasOwnProperty && o instanceof Array) { r = []; each(o, function(o) { o = DOM.get(o); r.push(t.add(o, n, f, s)); }); return r; } o = DOM.get(o); if (!o) return; // Setup event callback cb = function(e) { // Is all events disabled if (t.disabled) return; e = e || window.event; // Patch in target, preventDefault and stopPropagation in IE it's W3C valid if (e && isIE) { if (!e.target) e.target = e.srcElement; // Patch in preventDefault, stopPropagation methods for W3C compatibility tinymce.extend(e, t._stoppers); } if (!s) return f(e); return f.call(s, e); }; if (n == 'unload') { tinymce.unloads.unshift({func : cb}); return cb; } if (n == 'init') { if (t.domLoaded) cb(); else t.inits.push(cb); return cb; } // Store away listener reference el.push({ obj : o, name : n, func : f, cfunc : cb, scope : s }); t._add(o, n, cb); return f; }, remove : function(o, n, f) { var t = this, a = t.events, s = false, r; // Handle array if (o && o.hasOwnProperty && o instanceof Array) { r = []; each(o, function(o) { o = DOM.get(o); r.push(t.remove(o, n, f)); }); return r; } o = DOM.get(o); each(a, function(e, i) { if (e.obj == o && e.name == n && (!f || (e.func == f || e.cfunc == f))) { a.splice(i, 1); t._remove(o, n, e.cfunc); s = true; return false; } }); return s; }, clear : function(o) { var t = this, a = t.events, i, e; if (o) { o = DOM.get(o); for (i = a.length - 1; i >= 0; i--) { e = a[i]; if (e.obj === o) { t._remove(e.obj, e.name, e.cfunc); e.obj = e.cfunc = null; a.splice(i, 1); } } } }, cancel : function(e) { if (!e) return false; this.stop(e); return this.prevent(e); }, stop : function(e) { if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; return false; }, prevent : function(e) { if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }, destroy : function() { var t = this; each(t.events, function(e, i) { t._remove(e.obj, e.name, e.cfunc); e.obj = e.cfunc = null; }); t.events = []; t = null; }, _add : function(o, n, f) { if (o.attachEvent) o.attachEvent('on' + n, f); else if (o.addEventListener) o.addEventListener(n, f, false); else o['on' + n] = f; }, _remove : function(o, n, f) { if (o) { try { if (o.detachEvent) o.detachEvent('on' + n, f); else if (o.removeEventListener) o.removeEventListener(n, f, false); else o['on' + n] = null; } catch (ex) { // Might fail with permission denined on IE so we just ignore that } } }, _pageInit : function(win) { var t = this; // Keep it from running more than once if (t.domLoaded) return; t.domLoaded = true; each(t.inits, function(c) { c(); }); t.inits = []; }, _wait : function(win) { var t = this, doc = win.document; // No need since the document is already loaded if (win.tinyMCE_GZ && tinyMCE_GZ.loaded) { t.domLoaded = 1; return; } // Use IE method if (doc.attachEvent) { doc.attachEvent("onreadystatechange", function() { if (doc.readyState === "complete") { doc.detachEvent("onreadystatechange", arguments.callee); t._pageInit(win); } }); if (doc.documentElement.doScroll && win == win.top) { (function() { if (t.domLoaded) return; try { // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ doc.documentElement.doScroll("left"); } catch (ex) { setTimeout(arguments.callee, 0); return; } t._pageInit(win); })(); } } else if (doc.addEventListener) { t._add(win, 'DOMContentLoaded', function() { t._pageInit(win); }); } t._add(win, 'load', function() { t._pageInit(win); }); }, _stoppers : { preventDefault : function() { this.returnValue = false; }, stopPropagation : function() { this.cancelBubble = true; } } }); Event = tinymce.dom.Event = new tinymce.dom.EventUtils(); // Dispatch DOM content loaded event for IE and Safari Event._wait(window); tinymce.addUnload(function() { Event.destroy(); }); })(tinymce); (function(tinymce) { var each = tinymce.each; tinymce.create('tinymce.dom.Element', { Element : function(id, s) { var t = this, dom, el; s = s || {}; t.id = id; t.dom = dom = s.dom || tinymce.DOM; t.settings = s; // Only IE leaks DOM references, this is a lot faster if (!tinymce.isIE) el = t.dom.get(t.id); each([ 'getPos', 'getRect', 'getParent', 'add', 'setStyle', 'getStyle', 'setStyles', 'setAttrib', 'setAttribs', 'getAttrib', 'addClass', 'removeClass', 'hasClass', 'getOuterHTML', 'setOuterHTML', 'remove', 'show', 'hide', 'isHidden', 'setHTML', 'get' ], function(k) { t[k] = function() { var a = [id], i; for (i = 0; i < arguments.length; i++) a.push(arguments[i]); a = dom[k].apply(dom, a); t.update(k); return a; }; }); }, on : function(n, f, s) { return tinymce.dom.Event.add(this.id, n, f, s); }, getXY : function() { return { x : parseInt(this.getStyle('left')), y : parseInt(this.getStyle('top')) }; }, getSize : function() { var n = this.dom.get(this.id); return { w : parseInt(this.getStyle('width') || n.clientWidth), h : parseInt(this.getStyle('height') || n.clientHeight) }; }, moveTo : function(x, y) { this.setStyles({left : x, top : y}); }, moveBy : function(x, y) { var p = this.getXY(); this.moveTo(p.x + x, p.y + y); }, resizeTo : function(w, h) { this.setStyles({width : w, height : h}); }, resizeBy : function(w, h) { var s = this.getSize(); this.resizeTo(s.w + w, s.h + h); }, update : function(k) { var t = this, b, dom = t.dom; if (tinymce.isIE6 && t.settings.blocker) { k = k || ''; // Ignore getters if (k.indexOf('get') === 0 || k.indexOf('has') === 0 || k.indexOf('is') === 0) return; // Remove blocker on remove if (k == 'remove') { dom.remove(t.blocker); return; } if (!t.blocker) { t.blocker = dom.uniqueId(); b = dom.add(t.settings.container || dom.getRoot(), 'iframe', {id : t.blocker, style : 'position:absolute;', frameBorder : 0, src : 'javascript:""'}); dom.setStyle(b, 'opacity', 0); } else b = dom.get(t.blocker); dom.setStyle(b, 'left', t.getStyle('left', 1)); dom.setStyle(b, 'top', t.getStyle('top', 1)); dom.setStyle(b, 'width', t.getStyle('width', 1)); dom.setStyle(b, 'height', t.getStyle('height', 1)); dom.setStyle(b, 'display', t.getStyle('display', 1)); dom.setStyle(b, 'zIndex', parseInt(t.getStyle('zIndex', 1) || 0) - 1); } } }); })(tinymce); (function(tinymce) { function trimNl(s) { return s.replace(/[\n\r]+/g, ''); }; // Shorten names var is = tinymce.is, isIE = tinymce.isIE, each = tinymce.each; tinymce.create('tinymce.dom.Selection', { Selection : function(dom, win, serializer) { var t = this; t.dom = dom; t.win = win; t.serializer = serializer; // Add events each([ 'onBeforeSetContent', 'onBeforeGetContent', 'onSetContent', 'onGetContent' ], function(e) { t[e] = new tinymce.util.Dispatcher(t); }); // No W3C Range support if (!t.win.getSelection) t.tridentSel = new tinymce.dom.TridentSelection(t); // Prevent leaks tinymce.addUnload(t.destroy, t); }, getContent : function(s) { var t = this, r = t.getRng(), e = t.dom.create("body"), se = t.getSel(), wb, wa, n; s = s || {}; wb = wa = ''; s.get = true; s.format = s.format || 'html'; t.onBeforeGetContent.dispatch(t, s); if (s.format == 'text') return t.isCollapsed() ? '' : (r.text || (se.toString ? se.toString() : '')); if (r.cloneContents) { n = r.cloneContents(); if (n) e.appendChild(n); } else if (is(r.item) || is(r.htmlText)) e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText; else e.innerHTML = r.toString(); // Keep whitespace before and after if (/^\s/.test(e.innerHTML)) wb = ' '; if (/\s+$/.test(e.innerHTML)) wa = ' '; s.getInner = true; s.content = t.isCollapsed() ? '' : wb + t.serializer.serialize(e, s) + wa; t.onGetContent.dispatch(t, s); return s.content; }, setContent : function(h, s) { var t = this, r = t.getRng(), c, d = t.win.document; s = s || {format : 'html'}; s.set = true; h = s.content = t.dom.processHTML(h); // Dispatch before set content event t.onBeforeSetContent.dispatch(t, s); h = s.content; if (r.insertNode) { // Make caret marker since insertNode places the caret in the beginning of text after insert h += '_'; // Delete and insert new node r.deleteContents(); r.insertNode(t.getRng().createContextualFragment(h)); // Move to caret marker c = t.dom.get('__caret'); // Make sure we wrap it compleatly, Opera fails with a simple select call r = d.createRange(); r.setStartBefore(c); r.setEndAfter(c); t.setRng(r); // Delete the marker, and hopefully the caret gets placed in the right location // Removed this since it seems to remove   in FF and simply deleting it // doesn't seem to affect the caret position in any browser //d.execCommand('Delete', false, null); // Remove the caret position t.dom.remove('__caret'); } else { if (r.item) { // Delete content and get caret text selection d.execCommand('Delete', false, null); r = t.getRng(); } r.pasteHTML(h); } // Dispatch set content event t.onSetContent.dispatch(t, s); }, getStart : function() { var t = this, r = t.getRng(), e; if (isIE) { if (r.item) return r.item(0); r = r.duplicate(); r.collapse(1); e = r.parentElement(); if (e && e.nodeName == 'BODY') return e.firstChild; return e; } else { e = r.startContainer; if (e.nodeName == 'BODY') return e.firstChild; return t.dom.getParent(e, '*'); } }, getEnd : function() { var t = this, r = t.getRng(), e; if (isIE) { if (r.item) return r.item(0); r = r.duplicate(); r.collapse(0); e = r.parentElement(); if (e && e.nodeName == 'BODY') return e.lastChild; return e; } else { e = r.endContainer; if (e.nodeName == 'BODY') return e.lastChild; return t.dom.getParent(e, '*'); } }, getBookmark : function(si) { var t = this, r = t.getRng(), tr, sx, sy, vp = t.dom.getViewPort(t.win), e, sp, bp, le, c = -0xFFFFFF, s, ro = t.dom.getRoot(), wb = 0, wa = 0, nv; sx = vp.x; sy = vp.y; // Simple bookmark fast but not as persistent if (si) return {rng : r, scrollX : sx, scrollY : sy}; // Handle IE if (isIE) { // Control selection if (r.item) { e = r.item(0); each(t.dom.select(e.nodeName), function(n, i) { if (e == n) { sp = i; return false; } }); return { tag : e.nodeName, index : sp, scrollX : sx, scrollY : sy }; } // Text selection tr = t.dom.doc.body.createTextRange(); tr.moveToElementText(ro); tr.collapse(true); bp = Math.abs(tr.move('character', c)); tr = r.duplicate(); tr.collapse(true); sp = Math.abs(tr.move('character', c)); tr = r.duplicate(); tr.collapse(false); le = Math.abs(tr.move('character', c)) - sp; return { start : sp - bp, length : le, scrollX : sx, scrollY : sy }; } // Handle W3C e = t.getNode(); s = t.getSel(); if (!s) return null; // Image selection if (e && e.nodeName == 'IMG') { return { scrollX : sx, scrollY : sy }; } // Text selection function getPos(r, sn, en) { var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; while ((n = w.nextNode()) != null) { if (n == sn) d.start = p; if (n == en) { d.end = p; return d; } p += trimNl(n.nodeValue || '').length; } return null; }; // Caret or selection if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) { e = getPos(ro, s.anchorNode, s.focusNode); if (!e) return {scrollX : sx, scrollY : sy}; // Count whitespace before trimNl(s.anchorNode.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;}); return { start : Math.max(e.start + s.anchorOffset - wb, 0), end : Math.max(e.end + s.focusOffset - wb, 0), scrollX : sx, scrollY : sy, beg : s.anchorOffset - wb == 0 }; } else { e = getPos(ro, r.startContainer, r.endContainer); // Count whitespace before start and end container //(r.startContainer.nodeValue || '').replace(/^\s+/, function(a) {wb = a.length;}); //(r.endContainer.nodeValue || '').replace(/^\s+/, function(a) {wa = a.length;}); if (!e) return {scrollX : sx, scrollY : sy}; return { start : Math.max(e.start + r.startOffset - wb, 0), end : Math.max(e.end + r.endOffset - wa, 0), scrollX : sx, scrollY : sy, beg : r.startOffset - wb == 0 }; } }, moveToBookmark : function(b) { var t = this, r = t.getRng(), s = t.getSel(), ro = t.dom.getRoot(), sd, nvl, nv; function getPos(r, sp, ep) { var w = t.dom.doc.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}, o, v, wa, wb; while ((n = w.nextNode()) != null) { wa = wb = 0; nv = n.nodeValue || ''; //nv.replace(/^\s+[^\s]/, function(a) {wb = a.length - 1;}); //nv.replace(/[^\s]\s+$/, function(a) {wa = a.length - 1;}); nvl = trimNl(nv).length; p += nvl; if (p >= sp && !d.startNode) { o = sp - (p - nvl); // Fix for odd quirk in FF if (b.beg && o >= nvl) continue; d.startNode = n; d.startOffset = o + wb; } if (p >= ep) { d.endNode = n; d.endOffset = ep - (p - nvl) + wb; return d; } } return null; }; if (!b) return false; t.win.scrollTo(b.scrollX, b.scrollY); // Handle explorer if (isIE) { t.tridentSel.destroy(); // Handle simple if (r = b.rng) { try { r.select(); } catch (ex) { // Ignore } return true; } t.win.focus(); // Handle control bookmark if (b.tag) { r = ro.createControlRange(); each(t.dom.select(b.tag), function(n, i) { if (i == b.index) r.addElement(n); }); } else { // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs try { // Incorrect bookmark if (b.start < 0) return true; r = s.createRange(); r.moveToElementText(ro); r.collapse(true); r.moveStart('character', b.start); r.moveEnd('character', b.length); } catch (ex2) { return true; } } try { r.select(); } catch (ex) { // Needed for some odd IE bug #1843306 } return true; } // Handle W3C if (!s) return false; // Handle simple if (b.rng) { s.removeAllRanges(); s.addRange(b.rng); } else { if (is(b.start) && is(b.end)) { try { sd = getPos(ro, b.start, b.end); if (sd) { r = t.dom.doc.createRange(); r.setStart(sd.startNode, sd.startOffset); r.setEnd(sd.endNode, sd.endOffset); s.removeAllRanges(); s.addRange(r); } if (!tinymce.isOpera) t.win.focus(); } catch (ex) { // Ignore } } } }, select : function(n, c) { var t = this, r = t.getRng(), s = t.getSel(), b, fn, ln, d = t.win.document; function find(n, start) { var walker, o; if (n) { walker = d.createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false); // Find first/last non empty text node while (n = walker.nextNode()) { o = n; if (tinymce.trim(n.nodeValue).length != 0) { if (start) return n; else o = n; } } } return o; }; if (isIE) { try { b = d.body; if (/^(IMG|TABLE)$/.test(n.nodeName)) { r = b.createControlRange(); r.addElement(n); } else { r = b.createTextRange(); r.moveToElementText(n); } r.select(); } catch (ex) { // Throws illigal agrument in IE some times } } else { if (c) { fn = find(n, 1) || t.dom.select('br:first', n)[0]; ln = find(n, 0) || t.dom.select('br:last', n)[0]; if (fn && ln) { r = d.createRange(); if (fn.nodeName == 'BR') r.setStartBefore(fn); else r.setStart(fn, 0); if (ln.nodeName == 'BR') r.setEndBefore(ln); else r.setEnd(ln, ln.nodeValue.length); } else r.selectNode(n); } else r.selectNode(n); t.setRng(r); } return n; }, isCollapsed : function() { var t = this, r = t.getRng(), s = t.getSel(); if (!r || r.item) return false; return !s || r.boundingWidth == 0 || r.collapsed; }, collapse : function(b) { var t = this, r = t.getRng(), n; // Control range on IE if (r.item) { n = r.item(0); r = this.win.document.body.createTextRange(); r.moveToElementText(n); } r.collapse(!!b); t.setRng(r); }, getSel : function() { var t = this, w = this.win; return w.getSelection ? w.getSelection() : w.document.selection; }, getRng : function(w3c) { var t = this, s, r; // Found tridentSel object then we need to use that one if (w3c && t.tridentSel) return t.tridentSel.getRangeAt(0); try { if (s = t.getSel()) r = s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : t.win.document.createRange()); } catch (ex) { // IE throws unspecified error here if TinyMCE is placed in a frame/iframe } // No range found then create an empty one // This can occur when the editor is placed in a hidden container element on Gecko // Or on IE when there was an exception if (!r) r = isIE ? t.win.document.body.createTextRange() : t.win.document.createRange(); return r; }, setRng : function(r) { var s, t = this; if (!t.tridentSel) { s = t.getSel(); if (s) { s.removeAllRanges(); s.addRange(r); } } else { // Is W3C Range if (r.cloneRange) { t.tridentSel.addRange(r); return; } // Is IE specific range try { r.select(); } catch (ex) { // Needed for some odd IE bug #1843306 } } }, setNode : function(n) { var t = this; t.setContent(t.dom.getOuterHTML(n)); return n; }, getNode : function() { var t = this, r = t.getRng(), s = t.getSel(), e; if (!isIE) { // Range maybe lost after the editor is made visible again if (!r) return t.dom.getRoot(); e = r.commonAncestorContainer; // Handle selection a image or other control like element such as anchors if (!r.collapsed) { // If the anchor node is a element instead of a text node then return this element if (tinymce.isWebKit && s.anchorNode && s.anchorNode.nodeType == 1) return s.anchorNode.childNodes[s.anchorOffset]; if (r.startContainer == r.endContainer) { if (r.startOffset - r.endOffset < 2) { if (r.startContainer.hasChildNodes()) e = r.startContainer.childNodes[r.startOffset]; } } } return t.dom.getParent(e, '*'); } return r.item ? r.item(0) : r.parentElement(); }, getSelectedBlocks : function(st, en) { var t = this, dom = t.dom, sb, eb, n, bl = []; sb = dom.getParent(st || t.getStart(), dom.isBlock); eb = dom.getParent(en || t.getEnd(), dom.isBlock); if (sb) bl.push(sb); if (sb && eb && sb != eb) { n = sb; while ((n = n.nextSibling) && n != eb) { if (dom.isBlock(n)) bl.push(n); } } if (eb && sb != eb) bl.push(eb); return bl; }, destroy : function(s) { var t = this; t.win = null; if (t.tridentSel) t.tridentSel.destroy(); // Manual destroy then remove unload handler if (!s) tinymce.removeUnload(t.destroy); } }); })(tinymce); (function(tinymce) { tinymce.create('tinymce.dom.XMLWriter', { node : null, XMLWriter : function(s) { // Get XML document function getXML() { var i = document.implementation; if (!i || !i.createDocument) { // Try IE objects try {return new ActiveXObject('MSXML2.DOMDocument');} catch (ex) {} try {return new ActiveXObject('Microsoft.XmlDom');} catch (ex) {} } else return i.createDocument('', '', null); }; this.doc = getXML(); // Since Opera and WebKit doesn't escape > into > we need to do it our self to normalize the output for all browsers this.valid = tinymce.isOpera || tinymce.isWebKit; this.reset(); }, reset : function() { var t = this, d = t.doc; if (d.firstChild) d.removeChild(d.firstChild); t.node = d.appendChild(d.createElement("html")); }, writeStartElement : function(n) { var t = this; t.node = t.node.appendChild(t.doc.createElement(n)); }, writeAttribute : function(n, v) { if (this.valid) v = v.replace(/>/g, '%MCGT%'); this.node.setAttribute(n, v); }, writeEndElement : function() { this.node = this.node.parentNode; }, writeFullEndElement : function() { var t = this, n = t.node; n.appendChild(t.doc.createTextNode("")); t.node = n.parentNode; }, writeText : function(v) { if (this.valid) v = v.replace(/>/g, '%MCGT%'); this.node.appendChild(this.doc.createTextNode(v)); }, writeCDATA : function(v) { this.node.appendChild(this.doc.createCDATASection(v)); }, writeComment : function(v) { // Fix for bug #2035694 if (tinymce.isIE) v = v.replace(/^\-|\-$/g, ' '); this.node.appendChild(this.doc.createComment(v.replace(/\-\-/g, ' '))); }, getContent : function() { var h; h = this.doc.xml || new XMLSerializer().serializeToString(this.doc); h = h.replace(/<\?[^?]+\?>||<\/html>||]+>/g, ''); h = h.replace(/ ?\/>/g, ' />'); if (this.valid) h = h.replace(/\%MCGT%/g, '>'); return h; } }); })(tinymce); (function(tinymce) { tinymce.create('tinymce.dom.StringWriter', { str : null, tags : null, count : 0, settings : null, indent : null, StringWriter : function(s) { this.settings = tinymce.extend({ indent_char : ' ', indentation : 0 }, s); this.reset(); }, reset : function() { this.indent = ''; this.str = ""; this.tags = []; this.count = 0; }, writeStartElement : function(n) { this._writeAttributesEnd(); this.writeRaw('<' + n); this.tags.push(n); this.inAttr = true; this.count++; this.elementCount = this.count; }, writeAttribute : function(n, v) { var t = this; t.writeRaw(" " + t.encode(n) + '="' + t.encode(v) + '"'); }, writeEndElement : function() { var n; if (this.tags.length > 0) { n = this.tags.pop(); if (this._writeAttributesEnd(1)) this.writeRaw(''); if (this.settings.indentation > 0) this.writeRaw('\n'); } }, writeFullEndElement : function() { if (this.tags.length > 0) { this._writeAttributesEnd(); this.writeRaw(''); if (this.settings.indentation > 0) this.writeRaw('\n'); } }, writeText : function(v) { this._writeAttributesEnd(); this.writeRaw(this.encode(v)); this.count++; }, writeCDATA : function(v) { this._writeAttributesEnd(); this.writeRaw(''); this.count++; }, writeComment : function(v) { this._writeAttributesEnd(); this.writeRaw(''); this.count++; }, writeRaw : function(v) { this.str += v; }, encode : function(s) { return s.replace(/[<>&"]/g, function(v) { switch (v) { case '<': return '<'; case '>': return '>'; case '&': return '&'; case '"': return '"'; } return v; }); }, getContent : function() { return this.str; }, _writeAttributesEnd : function(s) { if (!this.inAttr) return; this.inAttr = false; if (s && this.elementCount == this.count) { this.writeRaw(' />'); return false; } this.writeRaw('>'); return true; } }); })(tinymce); (function(tinymce) { // Shorten names var extend = tinymce.extend, each = tinymce.each, Dispatcher = tinymce.util.Dispatcher, isIE = tinymce.isIE, isGecko = tinymce.isGecko; function wildcardToRE(s) { return s.replace(/([?+*])/g, '.$1'); }; tinymce.create('tinymce.dom.Serializer', { Serializer : function(s) { var t = this; t.key = 0; t.onPreProcess = new Dispatcher(t); t.onPostProcess = new Dispatcher(t); try { t.writer = new tinymce.dom.XMLWriter(); } catch (ex) { // IE might throw exception if ActiveX is disabled so we then switch to the slightly slower StringWriter t.writer = new tinymce.dom.StringWriter(); } // Default settings t.settings = s = extend({ dom : tinymce.DOM, valid_nodes : 0, node_filter : 0, attr_filter : 0, invalid_attrs : /^(mce_|_moz_|sizset|sizcache)/, closed : /^(br|hr|input|meta|img|link|param|area)$/, entity_encoding : 'named', entities : '160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro', valid_elements : '*[*]', extended_valid_elements : 0, valid_child_elements : 0, invalid_elements : 0, fix_table_elements : 1, fix_list_elements : true, fix_content_duplication : true, convert_fonts_to_spans : false, font_size_classes : 0, font_size_style_values : 0, apply_source_formatting : 0, indent_mode : 'simple', indent_char : '\t', indent_levels : 1, remove_linebreaks : 1, remove_redundant_brs : 1, element_format : 'xhtml' }, s); t.dom = s.dom; if (s.remove_redundant_brs) { t.onPostProcess.add(function(se, o) { // Remove single BR at end of block elements since they get rendered o.content = o.content.replace(/(
    \s*)+<\/(p|h[1-6]|div|li)>/gi, function(a, b, c) { // Check if it's a single element if (/^
    \s*<\//.test(a)) return ''; return a; }); }); } // Remove XHTML element endings i.e. produce crap :) XHTML is better if (s.element_format == 'html') { t.onPostProcess.add(function(se, o) { o.content = o.content.replace(/<([^>]+) \/>/g, '<$1>'); }); } if (s.fix_list_elements) { t.onPreProcess.add(function(se, o) { var nl, x, a = ['ol', 'ul'], i, n, p, r = /^(OL|UL)$/, np; function prevNode(e, n) { var a = n.split(','), i; while ((e = e.previousSibling) != null) { for (i=0; i= 1767) { each(t.dom.select('p table', o.node).reverse(), function(n) { var parent = t.dom.getParent(n.parentNode, 'table,p'); if (parent.nodeName != 'TABLE') { try { t.dom.split(parent, n); } catch (ex) { // IE can sometimes fire an unknown runtime error so we just ignore it } } }); } }); } }, setEntities : function(s) { var t = this, a, i, l = {}, re = '', v; // No need to setup more than once if (t.entityLookup) return; // Build regex and lookup array a = s.split(','); for (i = 0; i < a.length; i += 2) { v = a[i]; // Don't add default & " etc. if (v == 34 || v == 38 || v == 60 || v == 62) continue; l[String.fromCharCode(a[i])] = a[i + 1]; v = parseInt(a[i]).toString(16); re += '\\u' + '0000'.substring(v.length) + v; } if (!re) { t.settings.entity_encoding = 'raw'; return; } t.entitiesRE = new RegExp('[' + re + ']', 'g'); t.entityLookup = l; }, setValidChildRules : function(s) { this.childRules = null; this.addValidChildRules(s); }, addValidChildRules : function(s) { var t = this, inst, intr, bloc; if (!s) return; inst = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment'; intr = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment'; bloc = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; each(s.split(','), function(s) { var p = s.split(/\[|\]/), re; s = ''; each(p[1].split('|'), function(v) { if (s) s += '|'; switch (v) { case '%itrans': v = intr; break; case '%itrans_na': v = intr.substring(2); break; case '%istrict': v = inst; break; case '%istrict_na': v = inst.substring(2); break; case '%btrans': v = bloc; break; case '%bstrict': v = bloc; break; } s += v; }); re = new RegExp('^(' + s.toLowerCase() + ')$', 'i'); each(p[0].split('/'), function(s) { t.childRules = t.childRules || {}; t.childRules[s] = re; }); }); // Build regex s = ''; each(t.childRules, function(v, k) { if (s) s += '|'; s += k; }); t.parentElementsRE = new RegExp('^(' + s.toLowerCase() + ')$', 'i'); /*console.debug(t.parentElementsRE.toString()); each(t.childRules, function(v) { console.debug(v.toString()); });*/ }, setRules : function(s) { var t = this; t._setup(); t.rules = {}; t.wildRules = []; t.validElements = {}; return t.addRules(s); }, addRules : function(s) { var t = this, dr; if (!s) return; t._setup(); each(s.split(','), function(s) { var p = s.split(/\[|\]/), tn = p[0].split('/'), ra, at, wat, va = []; // Extend with default rules if (dr) at = tinymce.extend([], dr.attribs); // Parse attributes if (p.length > 1) { each(p[1].split('|'), function(s) { var ar = {}, i; at = at || []; // Parse attribute rule s = s.replace(/::/g, '~'); s = /^([!\-])?([\w*.?~_\-]+|)([=:<])?(.+)?$/.exec(s); s[2] = s[2].replace(/~/g, ':'); // Add required attributes if (s[1] == '!') { ra = ra || []; ra.push(s[2]); } // Remove inherited attributes if (s[1] == '-') { for (i = 0; i = 1767)) { // Create an empty HTML document doc = impl.createHTMLDocument(""); // Add the element or it's children if it's a body element to the new document each(n.nodeName == 'BODY' ? n.childNodes : [n], function(node) { doc.body.appendChild(doc.importNode(node, true)); }); // Grab first child or body element for serialization if (n.nodeName != 'BODY') n = doc.body.firstChild; else n = doc.body; // set the new document in DOMUtils so createElement etc works oldDoc = t.dom.doc; t.dom.doc = doc; } t.key = '' + (parseInt(t.key) + 1); // Pre process if (!o.no_events) { o.node = n; t.onPreProcess.dispatch(t, o); } // Serialize HTML DOM into a string t.writer.reset(); t._serializeNode(n, o.getInner); // Post process o.content = t.writer.getContent(); // Restore the old document if it was changed if (oldDoc) t.dom.doc = oldDoc; if (!o.no_events) t.onPostProcess.dispatch(t, o); t._postProcess(o); o.node = null; return tinymce.trim(o.content); }, // Internal functions _postProcess : function(o) { var t = this, s = t.settings, h = o.content, sc = [], p; if (o.format == 'html') { // Protect some elements p = t._protect({ content : h, patterns : [ {pattern : /(]*>)(.*?)(<\/script>)/g}, {pattern : /(]*>)(.*?)(<\/noscript>)/g}, {pattern : /(]*>)(.*?)(<\/style>)/g}, {pattern : /(]*>)(.*?)(<\/pre>)/g, encode : 1}, {pattern : /()/g} ] }); h = p.content; // Entity encode if (s.entity_encoding !== 'raw') h = t._encode(h); // Use BR instead of   padded P elements inside editor and use

     

    outside editor /* if (o.set) h = h.replace(/

    \s+( | |\u00a0|
    )\s+<\/p>/g, '


    '); else h = h.replace(/

    \s+( | |\u00a0|
    )\s+<\/p>/g, '

    $1

    ');*/ // Since Gecko and Safari keeps whitespace in the DOM we need to // remove it inorder to match other browsers. But I think Gecko and Safari is right. // This process is only done when getting contents out from the editor. if (!o.set) { // We need to replace paragraph whitespace with an nbsp before indentation to keep the \u00a0 char h = h.replace(/

    \s+<\/p>|]+)>\s+<\/p>/g, s.entity_encoding == 'numeric' ? ' 

    ' : ' 

    '); if (s.remove_linebreaks) { h = h.replace(/\r?\n|\r/g, ' '); h = h.replace(/(<[^>]+>)\s+/g, '$1 '); h = h.replace(/\s+(<\/[^>]+>)/g, ' $1'); h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object) ([^>]+)>\s+/g, '<$1 $2>'); // Trim block start h = h.replace(/<(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>\s+/g, '<$1>'); // Trim block start h = h.replace(/\s+<\/(p|h[1-6]|blockquote|hr|div|table|tbody|tr|td|body|head|html|title|meta|style|pre|script|link|object)>/g, ''); // Trim block end } // Simple indentation if (s.apply_source_formatting && s.indent_mode == 'simple') { // Add line breaks before and after block elements h = h.replace(/<(\/?)(ul|hr|table|meta|link|tbody|tr|object|body|head|html|map)(|[^>]+)>\s*/g, '\n<$1$2$3>\n'); h = h.replace(/\s*<(p|h[1-6]|blockquote|div|title|style|pre|script|td|li|area)(|[^>]+)>/g, '\n<$1$2>'); h = h.replace(/<\/(p|h[1-6]|blockquote|div|title|style|pre|script|td|li)>\s*/g, '\n'); h = h.replace(/\n\n/g, '\n'); } } h = t._unprotect(h, p); // Restore CDATA sections h = h.replace(//g, ''); // Restore the \u00a0 character if raw mode is enabled if (s.entity_encoding == 'raw') h = h.replace(/

     <\/p>|]+)> <\/p>/g, '\u00a0

    '); // Restore noscript elements h = h.replace(/]+|)>([\s\S]*?)<\/noscript>/g, function(v, attribs, text) { return '' + t.dom.decode(text.replace(//g, '')) + ''; }); } o.content = h; }, _serializeNode : function(n, inn) { var t = this, s = t.settings, w = t.writer, hc, el, cn, i, l, a, at, no, v, nn, ru, ar, iv, closed; if (!s.node_filter || s.node_filter(n)) { switch (n.nodeType) { case 1: // Element if (n.hasAttribute ? n.hasAttribute('mce_bogus') : n.getAttribute('mce_bogus')) return; iv = false; hc = n.hasChildNodes(); nn = n.getAttribute('mce_name') || n.nodeName.toLowerCase(); // Add correct prefix on IE if (isIE) { if (n.scopeName !== 'HTML' && n.scopeName !== 'html') nn = n.scopeName + ':' + nn; } // Remove mce prefix on IE needed for the abbr element if (nn.indexOf('mce:') === 0) nn = nn.substring(4); // Check if valid if (!t.validElementsRE || !t.validElementsRE.test(nn) || (t.invalidElementsRE && t.invalidElementsRE.test(nn)) || inn) { iv = true; break; } if (isIE) { // Fix IE content duplication (DOM can have multiple copies of the same node) if (s.fix_content_duplication) { if (n.mce_serialized == t.key) return; n.mce_serialized = t.key; } // IE sometimes adds a / infront of the node name if (nn.charAt(0) == '/') nn = nn.substring(1); } else if (isGecko) { // Ignore br elements if (n.nodeName === 'BR' && n.getAttribute('type') == '_moz') return; } // Check if valid child if (t.childRules) { if (t.parentElementsRE.test(t.elementName)) { if (!t.childRules[t.elementName].test(nn)) { iv = true; break; } } t.elementName = nn; } ru = t.findRule(nn); nn = ru.name || nn; closed = s.closed.test(nn); // Skip empty nodes or empty node name in IE if ((!hc && ru.noEmpty) || (isIE && !nn)) { iv = true; break; } // Check required if (ru.requiredAttribs) { a = ru.requiredAttribs; for (i = a.length - 1; i >= 0; i--) { if (this.dom.getAttrib(n, a[i]) !== '') break; } // None of the required was there if (i == -1) { iv = true; break; } } w.writeStartElement(nn); // Add ordered attributes if (ru.attribs) { for (i=0, at = ru.attribs, l = at.length; i-1; i--) { no = at[i]; if (no.specified) { a = no.nodeName.toLowerCase(); if (s.invalid_attrs.test(a) || !ru.validAttribsRE.test(a)) continue; ar = t.findAttribRule(ru, a); v = t._getAttrib(n, ar, a); if (v !== null) w.writeAttribute(a, v); } } } // Write text from script if (nn === 'script' && tinymce.trim(n.innerHTML)) { w.writeText('// '); // Padd it with a comment so it will parse on older browsers w.writeCDATA(n.innerHTML.replace(/|<\[CDATA\[|\]\]>/g, '')); // Remove comments and cdata stuctures hc = false; break; } // Padd empty nodes with a   if (ru.padd) { // If it has only one bogus child, padd it anyway workaround for
    bug if (hc && (cn = n.firstChild) && cn.nodeType === 1 && n.childNodes.length === 1) { if (cn.hasAttribute ? cn.hasAttribute('mce_bogus') : cn.getAttribute('mce_bogus')) w.writeText('\u00a0'); } else if (!hc) w.writeText('\u00a0'); // No children then padd it } break; case 3: // Text // Check if valid child if (t.childRules && t.parentElementsRE.test(t.elementName)) { if (!t.childRules[t.elementName].test(n.nodeName)) return; } return w.writeText(n.nodeValue); case 4: // CDATA return w.writeCDATA(n.nodeValue); case 8: // Comment return w.writeComment(n.nodeValue); } } else if (n.nodeType == 1) hc = n.hasChildNodes(); if (hc && !closed) { cn = n.firstChild; while (cn) { t._serializeNode(cn); t.elementName = nn; cn = cn.nextSibling; } } // Write element end if (!iv) { if (!closed) w.writeFullEndElement(); else w.writeEndElement(); } }, _protect : function(o) { var t = this; o.items = o.items || []; function enc(s) { return s.replace(/[\r\n\\]/g, function(c) { if (c === '\n') return '\\n'; else if (c === '\\') return '\\\\'; return '\\r'; }); }; function dec(s) { return s.replace(/\\[\\rn]/g, function(c) { if (c === '\\n') return '\n'; else if (c === '\\\\') return '\\'; return '\r'; }); }; each(o.patterns, function(p) { o.content = dec(enc(o.content).replace(p.pattern, function(x, a, b, c) { b = dec(b); if (p.encode) b = t._encode(b); o.items.push(b); return a + '' + c; })); }); return o; }, _unprotect : function(h, o) { h = h.replace(/\')); } // Add toolbar end before list box and after the previous button // This is to fix the o2k7 editor skins if (pr && co.ListBox) { if (pr.Button || pr.SplitButton) h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '')); } // Render control HTML // IE 8 quick fix, needed to propertly generate a hit area for anchors if (dom.stdMode) h += '' + co.renderHTML() + ''; else h += '' + co.renderHTML() + ''; // Add toolbar start after list box and before the next button // This is to fix the o2k7 editor skins if (nx && co.ListBox) { if (nx.Button || nx.SplitButton) h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '')); } } c = 'mceToolbarEnd'; if (co.Button) c += ' mceToolbarEndButton'; else if (co.SplitButton) c += ' mceToolbarEndSplitButton'; else if (co.ListBox) c += ' mceToolbarEndListBox'; h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '')); return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || ''}, '' + h + ''); } }); (function(tinymce) { var Dispatcher = tinymce.util.Dispatcher, each = tinymce.each; tinymce.create('tinymce.AddOnManager', { items : [], urls : {}, lookup : {}, onAdd : new Dispatcher(this), get : function(n) { return this.lookup[n]; }, requireLangPack : function(n) { var u, s = tinymce.EditorManager.settings; if (s && s.language) { u = this.urls[n] + '/langs/' + s.language + '.js'; if (!tinymce.dom.Event.domLoaded && !s.strict_mode) tinymce.ScriptLoader.load(u); else tinymce.ScriptLoader.add(u); } }, add : function(id, o) { this.items.push(o); this.lookup[id] = o; this.onAdd.dispatch(this, id, o); return o; }, load : function(n, u, cb, s) { var t = this; if (t.urls[n]) return; if (u.indexOf('/') != 0 && u.indexOf('://') == -1) u = tinymce.baseURL + '/' + u; t.urls[n] = u.substring(0, u.lastIndexOf('/')); tinymce.ScriptLoader.add(u, cb, s); } }); // Create plugin and theme managers tinymce.PluginManager = new tinymce.AddOnManager(); tinymce.ThemeManager = new tinymce.AddOnManager(); }(tinymce)); (function(tinymce) { // Shorten names var each = tinymce.each, extend = tinymce.extend, DOM = tinymce.DOM, Event = tinymce.dom.Event, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, explode = tinymce.explode; tinymce.create('static tinymce.EditorManager', { editors : {}, i18n : {}, activeEditor : null, preInit : function() { var t = this, lo = window.location; // Setup some URLs where the editor API is located and where the document is tinymce.documentBaseURL = lo.href.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, ''); if (!/[\/\\]$/.test(tinymce.documentBaseURL)) tinymce.documentBaseURL += '/'; tinymce.baseURL = new tinymce.util.URI(tinymce.documentBaseURL).toAbsolute(tinymce.baseURL); tinymce.EditorManager.baseURI = new tinymce.util.URI(tinymce.baseURL); // Add before unload listener // This was required since IE was leaking memory if you added and removed beforeunload listeners // with attachEvent/detatchEvent so this only adds one listener and instances can the attach to the onBeforeUnload event t.onBeforeUnload = new tinymce.util.Dispatcher(t); // Must be on window or IE will leak if the editor is placed in frame or iframe Event.add(window, 'beforeunload', function(e) { t.onBeforeUnload.dispatch(t, e); }); }, init : function(s) { var t = this, pl, sl = tinymce.ScriptLoader, c, e, el = [], ed; function execCallback(se, n, s) { var f = se[n]; if (!f) return; if (tinymce.is(f, 'string')) { s = f.replace(/\.\w+$/, ''); s = s ? tinymce.resolve(s) : 0; f = tinymce.resolve(f); } return f.apply(s || this, Array.prototype.slice.call(arguments, 2)); }; s = extend({ theme : "simple", language : "en", strict_loading_mode : document.contentType == 'application/xhtml+xml' }, s); t.settings = s; // If page not loaded and strict mode isn't enabled then load them if (!Event.domLoaded && !s.strict_loading_mode) { // Load language if (s.language) sl.add(tinymce.baseURL + '/langs/' + s.language + '.js'); // Load theme if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme]) ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js'); // Load plugins if (s.plugins) { pl = explode(s.plugins); // Load rest if plugins each(pl, function(v) { if (v && v.charAt(0) != '-' && !PluginManager.urls[v]) { // Skip safari plugin for other browsers if (!tinymce.isWebKit && v == 'safari') return; PluginManager.load(v, 'plugins/' + v + '/editor_plugin' + tinymce.suffix + '.js'); } }); } sl.loadQueue(); } // Legacy call Event.add(document, 'init', function() { var l, co; execCallback(s, 'onpageload'); // Verify that it's a valid browser if (s.browsers) { l = false; each(explode(s.browsers), function(v) { switch (v) { case 'ie': case 'msie': if (tinymce.isIE) l = true; break; case 'gecko': if (tinymce.isGecko) l = true; break; case 'safari': case 'webkit': if (tinymce.isWebKit) l = true; break; case 'opera': if (tinymce.isOpera) l = true; break; } }); // Not a valid one if (!l) return; } switch (s.mode) { case "exact": l = s.elements || ''; if(l.length > 0) { each(explode(l), function(v) { if (DOM.get(v)) { ed = new tinymce.Editor(v, s); el.push(ed); ed.render(1); } else { c = 0; each(document.forms, function(f) { each(f.elements, function(e) { if (e.name === v) { v = 'mce_editor_' + c; DOM.setAttrib(e, 'id', v); ed = new tinymce.Editor(v, s); el.push(ed); ed.render(1); } }); }); } }); } break; case "textareas": case "specific_textareas": function hasClass(n, c) { return c.constructor === RegExp ? c.test(n.className) : DOM.hasClass(n, c); }; each(DOM.select('textarea'), function(v) { if (s.editor_deselector && hasClass(v, s.editor_deselector)) return; if (!s.editor_selector || hasClass(v, s.editor_selector)) { // Can we use the name e = DOM.get(v.name); if (!v.id && !e) v.id = v.name; // Generate unique name if missing or already exists if (!v.id || t.get(v.id)) v.id = DOM.uniqueId(); ed = new tinymce.Editor(v.id, s); el.push(ed); ed.render(1); } }); break; } // Call onInit when all editors are initialized if (s.oninit) { l = co = 0; each (el, function(ed) { co++; if (!ed.initialized) { // Wait for it ed.onInit.add(function() { l++; // All done if (l == co) execCallback(s, 'oninit'); }); } else l++; // All done if (l == co) execCallback(s, 'oninit'); }); } }); }, get : function(id) { return this.editors[id]; }, getInstanceById : function(id) { return this.get(id); }, add : function(e) { this.editors[e.id] = e; this._setActive(e); return e; }, remove : function(e) { var t = this; // Not in the collection if (!t.editors[e.id]) return null; delete t.editors[e.id]; // Select another editor since the active one was removed if (t.activeEditor == e) { t._setActive(null); each(t.editors, function(e) { t._setActive(e); return false; // Break }); } e.destroy(); return e; }, execCommand : function(c, u, v) { var t = this, ed = t.get(v), w; // Manager commands switch (c) { case "mceFocus": ed.focus(); return true; case "mceAddEditor": case "mceAddControl": if (!t.get(v)) new tinymce.Editor(v, t.settings).render(); return true; case "mceAddFrameControl": w = v.window; // Add tinyMCE global instance and tinymce namespace to specified window w.tinyMCE = tinyMCE; w.tinymce = tinymce; tinymce.DOM.doc = w.document; tinymce.DOM.win = w; ed = new tinymce.Editor(v.element_id, v); ed.render(); // Fix IE memory leaks if (tinymce.isIE) { function clr() { ed.destroy(); w.detachEvent('onunload', clr); w = w.tinyMCE = w.tinymce = null; // IE leak }; w.attachEvent('onunload', clr); } v.page_window = null; return true; case "mceRemoveEditor": case "mceRemoveControl": if (ed) ed.remove(); return true; case 'mceToggleEditor': if (!ed) { t.execCommand('mceAddControl', 0, v); return true; } if (ed.isHidden()) ed.show(); else ed.hide(); return true; } // Run command on active editor if (t.activeEditor) return t.activeEditor.execCommand(c, u, v); return false; }, execInstanceCommand : function(id, c, u, v) { var ed = this.get(id); if (ed) return ed.execCommand(c, u, v); return false; }, triggerSave : function() { each(this.editors, function(e) { e.save(); }); }, addI18n : function(p, o) { var lo, i18n = this.i18n; if (!tinymce.is(p, 'string')) { each(p, function(o, lc) { each(o, function(o, g) { each(o, function(o, k) { if (g === 'common') i18n[lc + '.' + k] = o; else i18n[lc + '.' + g + '.' + k] = o; }); }); }); } else { each(o, function(o, k) { i18n[p + '.' + k] = o; }); } }, // Private methods _setActive : function(e) { this.selectedInstance = this.activeEditor = e; } }); tinymce.EditorManager.preInit(); })(tinymce); var tinyMCE = window.tinyMCE = tinymce.EditorManager; (function(tinymce) { var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, Dispatcher = tinymce.util.Dispatcher; var each = tinymce.each, isGecko = tinymce.isGecko, isIE = tinymce.isIE, isWebKit = tinymce.isWebKit; var is = tinymce.is, ThemeManager = tinymce.ThemeManager, PluginManager = tinymce.PluginManager, EditorManager = tinymce.EditorManager; var inArray = tinymce.inArray, grep = tinymce.grep, explode = tinymce.explode; tinymce.create('tinymce.Editor', { Editor : function(id, s) { var t = this; t.id = t.editorId = id; t.execCommands = {}; t.queryStateCommands = {}; t.queryValueCommands = {}; t.isNotDirty = false; t.plugins = {}; // Add events to the editor each([ 'onPreInit', 'onBeforeRenderUI', 'onPostRender', 'onInit', 'onRemove', 'onActivate', 'onDeactivate', 'onClick', 'onEvent', 'onMouseUp', 'onMouseDown', 'onDblClick', 'onKeyDown', 'onKeyUp', 'onKeyPress', 'onContextMenu', 'onSubmit', 'onReset', 'onPaste', 'onPreProcess', 'onPostProcess', 'onBeforeSetContent', 'onBeforeGetContent', 'onSetContent', 'onGetContent', 'onLoadContent', 'onSaveContent', 'onNodeChange', 'onChange', 'onBeforeExecCommand', 'onExecCommand', 'onUndo', 'onRedo', 'onVisualAid', 'onSetProgressState' ], function(e) { t[e] = new Dispatcher(t); }); t.settings = s = extend({ id : id, language : 'en', docs_language : 'en', theme : 'simple', skin : 'default', delta_width : 0, delta_height : 0, popup_css : '', plugins : '', document_base_url : tinymce.documentBaseURL, add_form_submit_trigger : 1, submit_patch : 1, add_unload_trigger : 1, convert_urls : 1, relative_urls : 1, remove_script_host : 1, table_inline_editing : 0, object_resizing : 1, cleanup : 1, accessibility_focus : 1, custom_shortcuts : 1, custom_undo_redo_keyboard_shortcuts : 1, custom_undo_redo_restore_selection : 1, custom_undo_redo : 1, doctype : '', visual_table_class : 'mceItemTable', visual : 1, inline_styles : true, convert_fonts_to_spans : true, font_size_style_values : 'xx-small,x-small,small,medium,large,x-large,xx-large', apply_source_formatting : 1, directionality : 'ltr', forced_root_block : 'p', valid_elements : '@[id|class|style|title|dir