[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: wiki/lib category.php,1.1.1.1,1.2 db.php,1.1.1.
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: wiki/lib category.php,1.1.1.1,1.2 db.php,1.1.1.1,1.2 defaults.php,1.1.1.1,1.2 diff.php,1.1.1.1,1.2 headers.php,1.1.1.1,1.2 init.php,1.1.1.1,1.2 main.php,1.1.1.1,1.2 messages.php,1.1.1.1,1.2 page.php,1.1.1.1,1.2 pagestore.php,1.1.1.1,1.2 rate.php,1.1.1.1,1.2 url.php,1.1.1.1,1.2 |
Date: |
Mon, 03 Mar 2003 08:37:08 -0500 |
Update of /cvsroot/phpgroupware/wiki/lib
In directory subversions:/tmp/cvs-serv23134/lib
Modified Files:
category.php db.php defaults.php diff.php headers.php init.php
main.php messages.php page.php pagestore.php rate.php url.php
Log Message:
make Axis-0.44 the new head-version
Index: category.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/category.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** category.php 3 Mar 2003 13:00:38 -0000 1.1.1.1
--- category.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,53 ****
! <?php
! // $Id$
!
! require('parse/main.php');
!
! // Add a page to a list of categories.
! function add_to_category($page, $catlist)
! {
! global $pagestore, $Entity, $UserName, $REMOTE_ADDR, $FlgChr;
!
! // Parse the category list for category names.
! $parsed = parseText($catlist, array('parse_wikiname', 'parse_freelink'),
'');
! $pagenames = array();
! preg_replace('/' . $FlgChr . '(\\d+)' . $FlgChr . '/e',
! '$pagenames[]=$Entity[\\1][1]', $parsed);
!
! if(validate_page($page) == 2)
! { $page = '((' . $page . '))'; }
!
! // Add it to each category.
! foreach($pagenames as $category)
! {
! $pg = $pagestore->page($category);
!
! $pg->read();
! if($pg->exists)
! {
! if(preg_match('/\\[\\[!.*\\]\\]/', $pg->text))
! {
! if(!preg_match("/\\[\\[!.*$page.*\\]\\]/", $pg->text))
! {
! $pg->text = preg_replace('/(\\[\\[!.*)\\]\\]/',
! "\\1 $page]]", $pg->text);
! }
! else
! { continue; }
! }
! else
! { $pg->text = $pg->text . "\n[[! $page]]\n"; }
!
! $pg->text = str_replace("\\", "\\\\", $pg->text);
! $pg->text = str_replace("'", "\\'", $pg->text);
!
! $pg->version++;
! $pg->comment = '';
! $pg->hostname = gethostbyaddr($REMOTE_ADDR);
! $pg->username = $UserName;
!
! $pg->write();
! }
! }
! }
! ?>
--- 1,53 ----
! <?php
! // $Id$
!
! require('parse/main.php');
!
! // Add a page to a list of categories.
! function add_to_category($page, $catlist)
! {
! global $pagestore, $Entity, $UserName, $REMOTE_ADDR, $FlgChr;
!
! // Parse the category list for category names.
! $parsed = parseText($catlist, array('parse_wikiname', 'parse_freelink'),
'');
! $pagenames = array();
! preg_replace('/' . $FlgChr . '(\\d+)' . $FlgChr . '/e',
! '$pagenames[]=$Entity[\\1][1]', $parsed);
!
! if(validate_page($page) == 2)
! { $page = '((' . $page . '))'; }
!
! // Add it to each category.
! foreach($pagenames as $category)
! {
! $pg = $pagestore->page($category);
!
! $pg->read();
! if($pg->exists)
! {
! if(preg_match('/\\[\\[!.*\\]\\]/', $pg->text))
! {
! if(!preg_match("/\\[\\[!.*$page.*\\]\\]/", $pg->text))
! {
! $pg->text = preg_replace('/(\\[\\[!.*)\\]\\]/',
! "\\1 $page]]", $pg->text);
! }
! else
! { continue; }
! }
! else
! { $pg->text = $pg->text . "\n[[! $page]]\n"; }
!
! $pg->text = str_replace("\\", "\\\\", $pg->text);
! $pg->text = str_replace("'", "\\'", $pg->text);
!
! $pg->version++;
! $pg->comment = '';
! $pg->hostname = gethostbyaddr($REMOTE_ADDR);
! $pg->username = $UserName;
!
! $pg->write();
! }
! }
! }
! ?>
Index: db.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/db.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** db.php 3 Mar 2003 13:00:38 -0000 1.1.1.1
--- db.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,40 ****
! <?php
! // $Id$
!
! // MySQL database abstractor. It should be easy to port this to other
! // databases, such as PostgreSQL.
! class WikiDB
! {
! var $handle;
!
! function WikiDB($persistent, $server, $user, $pass, $database)
! {
! global $ErrorDatabaseConnect, $ErrorDatabaseSelect;
!
! if($persistent)
! { $this->handle = mysql_pconnect($server, $user, $pass); }
! else
! { $this->handle = mysql_connect($server, $user, $pass); }
!
! if($this->handle <= 0)
! { die($ErrorDatabaseConnect); }
!
! if(mysql_select_db($database, $this->handle) == false)
! { die($ErrorDatabaseSelect); }
! }
!
! function query($text)
! {
! global $ErrorDatabaseQuery;
!
! if(!($qid = mysql_query($text, $this->handle)))
! { die($ErrorDatabaseQuery); }
! return $qid;
! }
!
! function result($qid)
! {
! return mysql_fetch_row($qid);
! }
! }
! ?>
--- 1,40 ----
! <?php
! // $Id$
!
! // MySQL database abstractor. It should be easy to port this to other
! // databases, such as PostgreSQL.
! class WikiDB
! {
! var $handle;
!
! function WikiDB($persistent, $server, $user, $pass, $database)
! {
! global $ErrorDatabaseConnect, $ErrorDatabaseSelect;
!
! if($persistent)
! { $this->handle = mysql_pconnect($server, $user, $pass); }
! else
! { $this->handle = mysql_connect($server, $user, $pass); }
!
! if($this->handle <= 0)
! { die($ErrorDatabaseConnect); }
!
! if(mysql_select_db($database, $this->handle) == false)
! { die($ErrorDatabaseSelect); }
! }
!
! function query($text)
! {
! global $ErrorDatabaseQuery;
!
! if(!($qid = mysql_query($text, $this->handle)))
! { die($ErrorDatabaseQuery); }
! return $qid;
! }
!
! function result($qid)
! {
! return mysql_fetch_row($qid);
! }
! }
! ?>
Index: defaults.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/defaults.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** defaults.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- defaults.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,264 ****
! <?php
! // $Id$
!
! //**********************************************************************
! // DO NOT EDIT THIS FILE.
! //
! // This file contains configuration defaults for 'Tavi that are over-
! // written on installation. Instead, you should edit 'config.php' to
! // re-set these options, or use the 'configure.pl' script to create a
! // 'config.php' for yourself.
! //
! // If you see options in here that are not present in 'config.php',
! // you can safely copy them to 'config.php' and set them to a new
! // value. This will override the default set here.
! //**********************************************************************
!
! // The following variables establish the format for WikiNames in this wiki.
! // Note that changing this might require a change to parse/transforms.php so
! // that parse_wikiname knows how many parentheses are included in $LinkPtn.
! $UpperPtn = "[A-Z\xc0-\xde]";
! $LowerPtn = "[a-z\xdf-\xff]";
! $AlphaPtn = "[A-Za-z\xc0-\xff]";
! $LinkPtn = $UpperPtn . $AlphaPtn . '*' . $LowerPtn . '+' .
! $UpperPtn . $AlphaPtn . '*(\\/' . $UpperPtn . $AlphaPtn . '*)?';
!
! // $UrlPtn establishes the format for URLs in this wiki.
! // Note that changing this requires a change to parse/transforms.php so
! // that parse_hyperlinkxxx know how many parentheses are included in
$UrlPtn.
! $UrlPtn = "(http:|mailto:|https:|ftp:|gopher:|news:)" .
! "([^ \\/\"\']*\\/)*[^ \\t\\n\\/\"\']*[A-Za-z0-9\\/?=&~_]";
!
! // $InterWikiPtn establishes the format for InterWiki links in this wiki.
! // Note that changing this requires a change to parse/transforms.php so
! // that parse_interwiki knows how many parentheses are in $InterwikiPtn.
! $InterwikiPtn = "([A-Za-z0-9]+):" .
! "(([^ \\/\"\']*\\/)*[^ \\t\\n\\/\"\']*[\\/=&~A-Za-z0-9])";
!
! // !!!WARNING!!!
! // If $AdminEnabled is set to 1, the script admin/index.php will be
accessible.
! // This allows administrators to lock pages and block IP addresses. If you
! // want to use this feature, YOU SHOULD FIRST BLOCK ACCESS TO THE admin/
! // DIRECTORY BY OTHER MEANS, such as Apache's authorization directives.
! // If you do not do so, any visitor to your wiki will be able to lock pages
! // and block others from accessing the wiki.
! // If $AdminEnabled is set to 0, administrator control will be disallowed.
! $AdminEnabled = 0;
!
! // Old versions of pages will be deleted after $ExpireLen days. If $ExpireLen
! // is set to 0, old versions of pages (and pages set to empty) will never
! // be removed from the database.
! $ExpireLen = 14;
!
! // Set $Charset to indicate the character set used for storage, editing,
! // and display in your wiki. The default is "ISO-8859-1" (Latin-1).
! // "utf-8" is supported, and is recommended for international text;
! // however you should be cautioned that Netscape does not behave correctly
! // when editing utf-8 text. Hence, "utf-8" is not currently the default.
! $Charset = 'ISO-8859-1';
!
! // $SeparateTitleWords determines whether spaces should be inserted in page
! // titles. If nonzero, the page title (but not header) of WikiName would
! // show 'Wiki Name' instead. Pages that have free link titles will not
! // be changed.
! $SeparateTitleWords = 1;
!
! // $SeparateHeaderWords determines whether spaces should be inserted in page
! // headers. If nonzero, the page header of WikiName would show 'Wiki Name'
! // instead. Pages that have free link names would not have changed headers.
! $SeparateHeaderWords = 0;
!
! // $SeparateLinkWords determines whether spaces should be inserted in links
! // to pages. If nonzero, all links to pages such as WikiName would display
! // as 'Wiki Name'. Pages that have free link names would not have changed
! // links.
! $SeparateLinkWords = 0;
!
! // $CookieName determines the name of the cookie that browser preferences
! // (like user name, etc.) are stored in.
! $CookieName = 'prefs';
!
! // $EditRows and $EditCols determine the default dimensions of the wiki edit
! // box for users that have not set their preferences.
! $EditRows = 20;
! $EditCols = 65;
!
! // Initialize the default user name to empty.
! $UserName = '';
!
! // Default time zone offset (in minutes) for visitors who haven't yet set
their
! // preferences.
! $TimeZoneOff = 0;
!
! // $AuthorDiff indicates whether history pages should show a diff for the last
! // edit (zero), or for all edits made by the same author (not zero). The
! // default here is used if the user has not set their preferences.
! $AuthorDiff = 1;
!
! // $DayLimit determines how many days worth of changes show in a category
list.
! // This default is used if the user has not set their preferences.
! $DayLimit = 14;
!
! // $MinEntries determines the absolute minimum size of a category list (unless
! // there are fewer pages *in* the category). This default is used if the
! // user has not set their preferences.
! $MinEntries = 20;
!
! // $HistMax determines the maximum number of entries on a page's history list.
! // This default is used if the user has not set their preferences.
! $HistMax = 8;
!
! // $RatePeriod determines how many seconds of time to record a visitor's
access
! // to the site. If it is set to zero, ALL RATE CHECKING AND IP ADDRESS
! // BLOCKING WILL BE DISABLED.
! $RatePeriod = 300;
!
! // $RateView determines how many pages a visitor can view in $RatePeriod
! // amount of time.
! $RateView = 100;
!
! // $RateSearch determines how many processor-intensive operations (search,
! // diff, etc.) a visitor can perform in $RatePeriod amount of time.
! $RateSearch = 50;
!
! // $RateEdit determines how many edits a visitor can make in $RatePeriod
! // amount of time.
! $RateEdit = 20;
!
! // $TempDir determines the location of temp files used for computing diffs.
! $TempDir = '/tmp';
!
! // $DiffCmd determines what command to run to compute diffs.
! $DiffCmd = '/usr/bin/diff';
!
! // $MaxPostLen determines the size, in bytes, of the largest edit allowed.
! $MaxPostLen = 204800;
!
! // $MaxNesting determines the maximum allowed nesting of lists.
! $MaxNesting = 20;
!
! // $MaxHeading determines the maximum allowed heading level in headings.
! $MaxHeading = 6;
!
! // $ParseEngine indicates what parsing rules will be run when displaying a
! // wiki page. To disable a particular rule, you can place a comment at the
! // beginning of its line. The order of this list is important.
! // Note that free links and wiki names are disabled above, using config
! // variables. This is because wiki names are parsed in other places than
! // just the wiki page.
! // Raw HTML parsing is turned off by default, since this is a potential
! // security hole.
! $ParseEngine = array(
! 'parse_elem_flag',
! // 'parse_raw_html',
! 'parse_htmlisms',
! 'parse_code',
! 'parse_nowiki',
! 'parse_hyperlink_ref',
! 'parse_hyperlink_description',
! 'parse_hyperlink',
! 'parse_macros',
! 'parse_transclude',
! 'parse_freelink',
! 'parse_interwiki',
! 'parse_wikiname',
! 'parse_bold',
! 'parse_italic',
! 'parse_teletype',
! 'parse_heading',
! 'parse_table',
! 'parse_horiz',
! 'parse_indents',
! 'parse_newline',
! 'parse_elements'
! );
!
! // $DiffEngine indicates what parsing rules will be run to display differences
! // between versions. This should be a shorter list than $ParseEngine,
! // since we just want minimal things like bold and italic and wiki links.
! $DiffEngine = array(
! 'parse_elem_flag',
! 'parse_diff_skip',
! 'parse_diff_message',
! 'parse_diff_color',
! 'parse_htmlisms',
! 'parse_nowiki',
! 'parse_hyperlink_ref',
! 'parse_hyperlink_description',
! 'parse_hyperlink',
! 'parse_freelink',
! 'parse_interwiki',
! 'parse_wikiname',
! 'parse_bold',
! 'parse_italic',
! 'parse_teletype',
! 'parse_newline',
! 'parse_elements'
! );
!
! // $DisplayEngine indicates what functions will be used to translate wiki
! // markup elements into actual HTML. See parse/html.php
! $DisplayEngine = array(
! 'bold_start' => 'html_bold_start',
! 'bold_end' => 'html_bold_end',
! 'italic_start' => 'html_italic_start',
! 'italic_end' => 'html_italic_end',
! 'tt_start' => 'html_tt_start',
! 'tt_end' => 'html_tt_end',
! 'head_start' => 'html_head_start',
! 'head_end' => 'html_head_end',
! 'newline' => 'html_newline',
! 'ref' => 'html_ref',
! 'url' => 'html_url',
! 'interwiki' => 'html_interwiki',
! 'raw' => 'html_raw',
! 'code' => 'html_code',
! 'hr' => 'html_hr',
! 'nowiki' => 'html_nowiki',
! 'anchor' => 'html_anchor',
! 'bullet_list_start' => 'html_ul_start',
! 'bullet_list_end' => 'html_ul_end',
! 'bullet_item_start' => 'html_li_start',
! 'bullet_item_end' => 'html_li_end',
! 'indent_list_start' => 'html_dl_start',
! 'indent_list_end' => 'html_dl_end',
! 'indent_item_start' => 'html_dd_start',
! 'indent_item_end' => 'html_dd_end',
! 'term_item_start' => 'html_dt_start',
! 'term_item_end' => 'html_dt_end',
! 'numbered_list_start' => 'html_ol_start',
! 'numbered_list_end' => 'html_ol_end',
! 'numbered_item_start' => 'html_li_start',
! 'numbered_item_end' => 'html_li_end',
! 'diff_old_start' => 'html_diff_old_start',
! 'diff_old_end' => 'html_diff_end',
! 'diff_new_start' => 'html_diff_new_start',
! 'diff_new_end' => 'html_diff_end',
! 'diff_change' => 'html_diff_change',
! 'diff_add' => 'html_diff_add',
! 'diff_delete' => 'html_diff_delete'
! );
!
! // $ViewMacroEngine determines what macro names will be processed when
! // displaying a page. For each name, a function must be provided.
! // See parse/macros.php
! $ViewMacroEngine = array(
! '!' => 'view_macro_category',
! 'Anchor' => 'view_macro_anchor',
! 'Transclude' => 'view_macro_transclude',
! 'PageSize' => 'view_macro_pagesize',
! 'LinkTable' => 'view_macro_linktab',
! 'OrphanedPages' => 'view_macro_orphans',
! 'WantedPages' => 'view_macro_wanted',
! 'PageLinks' => 'view_macro_outlinks',
! 'PageRefs' => 'view_macro_refs'
! );
!
! // $SaveMacroEngine determines what save macros will be called after a
! // page is saved. See parse/save.php
! $SaveMacroEngine = array(
! 'parse_define_interwiki',
! 'parse_define_sisterwiki',
! 'parse_define_links'
! );
! ?>
--- 1,268 ----
! <?php
! // $Id$
!
! //**********************************************************************
! // DO NOT EDIT THIS FILE.
! //
! // This file contains configuration defaults for 'Tavi that are over-
! // written on installation. Instead, you should edit 'config.php' to
! // re-set these options, or use the 'configure.pl' script to create a
! // 'config.php' for yourself.
! //
! // If you see options in here that are not present in 'config.php',
! // you can safely copy them to 'config.php' and set them to a new
! // value. This will override the default set here.
! //**********************************************************************
!
! // The following variables establish the format for WikiNames in this wiki.
! // Note that changing this might require a change to parse/transforms.php so
! // that parse_wikiname knows how many parentheses are included in $LinkPtn.
! $UpperPtn = "[A-Z\xc0-\xde]";
! $LowerPtn = "[a-z\xdf-\xff]";
! $AlphaPtn = "[A-Za-z\xc0-\xff]";
! $LinkPtn = $UpperPtn . $AlphaPtn . '*' . $LowerPtn . '+' .
! $UpperPtn . $AlphaPtn . '*(\\/' . $UpperPtn . $AlphaPtn . '*)?';
!
! // $UrlPtn establishes the format for URLs in this wiki.
! // Note that changing this requires a change to parse/transforms.php so
! // that parse_hyperlinkxxx know how many parentheses are included in
$UrlPtn.
! $UrlPtn = "(http:|mailto:|https:|ftp:|gopher:|news:)" .
! "([^ \\/\"\']*\\/)*[^ \\t\\n\\/\"\']*[A-Za-z0-9\\/?=&~_]";
!
! // $InterWikiPtn establishes the format for InterWiki links in this wiki.
! // Note that changing this requires a change to parse/transforms.php so
! // that parse_interwiki knows how many parentheses are in $InterwikiPtn.
! $InterwikiPtn = "([A-Za-z0-9]+):" .
! "(([^ \\/\"\']*\\/)*[^ \\t\\n\\/\"\']*[\\/=&~A-Za-z0-9])";
!
! // !!!WARNING!!!
! // If $AdminEnabled is set to 1, the script admin/index.php will be
accessible.
! // This allows administrators to lock pages and block IP addresses. If you
! // want to use this feature, YOU SHOULD FIRST BLOCK ACCESS TO THE admin/
! // DIRECTORY BY OTHER MEANS, such as Apache's authorization directives.
! // If you do not do so, any visitor to your wiki will be able to lock pages
! // and block others from accessing the wiki.
! // If $AdminEnabled is set to 0, administrator control will be disallowed.
! $AdminEnabled = 0;
!
! // Old versions of pages will be deleted after $ExpireLen days. If $ExpireLen
! // is set to 0, old versions of pages (and pages set to empty) will never
! // be removed from the database.
! $ExpireLen = 14;
!
! // Set $Charset to indicate the character set used for storage, editing,
! // and display in your wiki. The default is "ISO-8859-1" (Latin-1).
! // "utf-8" is supported, and is recommended for international text;
! // however you should be cautioned that Netscape does not behave correctly
! // when editing utf-8 text. Hence, "utf-8" is not currently the default.
! $Charset = 'ISO-8859-1';
!
! // $SeparateTitleWords determines whether spaces should be inserted in page
! // titles. If nonzero, the page title (but not header) of WikiName would
! // show 'Wiki Name' instead. Pages that have free link titles will not
! // be changed.
! $SeparateTitleWords = 1;
!
! // $SeparateHeaderWords determines whether spaces should be inserted in page
! // headers. If nonzero, the page header of WikiName would show 'Wiki Name'
! // instead. Pages that have free link names would not have changed headers.
! $SeparateHeaderWords = 0;
!
! // $SeparateLinkWords determines whether spaces should be inserted in links
! // to pages. If nonzero, all links to pages such as WikiName would display
! // as 'Wiki Name'. Pages that have free link names would not have changed
! // links.
! $SeparateLinkWords = 0;
!
! // $CookieName determines the name of the cookie that browser preferences
! // (like user name, etc.) are stored in.
! $CookieName = 'prefs';
!
! // $EditRows and $EditCols determine the default dimensions of the wiki edit
! // box for users that have not set their preferences.
! $EditRows = 20;
! $EditCols = 65;
!
! // Initialize the default user name to empty.
! $accountid = get_account_id();
! $result = mysql_query("SELECT account_lid FROM phpgw_accounts WHERE
account_id='$accountid'");
! $row = mysql_fetch_array($result);
! $UserName = $row["account_lid"];
! #$UserName = '';
!
! // Default time zone offset (in minutes) for visitors who haven't yet set
their
! // preferences.
! $TimeZoneOff = 0;
!
! // $AuthorDiff indicates whether history pages should show a diff for the last
! // edit (zero), or for all edits made by the same author (not zero). The
! // default here is used if the user has not set their preferences.
! $AuthorDiff = 1;
!
! // $DayLimit determines how many days worth of changes show in a category
list.
! // This default is used if the user has not set their preferences.
! $DayLimit = 14;
!
! // $MinEntries determines the absolute minimum size of a category list (unless
! // there are fewer pages *in* the category). This default is used if the
! // user has not set their preferences.
! $MinEntries = 20;
!
! // $HistMax determines the maximum number of entries on a page's history list.
! // This default is used if the user has not set their preferences.
! $HistMax = 8;
!
! // $RatePeriod determines how many seconds of time to record a visitor's
access
! // to the site. If it is set to zero, ALL RATE CHECKING AND IP ADDRESS
! // BLOCKING WILL BE DISABLED.
! $RatePeriod = 300;
!
! // $RateView determines how many pages a visitor can view in $RatePeriod
! // amount of time.
! $RateView = 100;
!
! // $RateSearch determines how many processor-intensive operations (search,
! // diff, etc.) a visitor can perform in $RatePeriod amount of time.
! $RateSearch = 50;
!
! // $RateEdit determines how many edits a visitor can make in $RatePeriod
! // amount of time.
! $RateEdit = 20;
!
! // $TempDir determines the location of temp files used for computing diffs.
! $TempDir = '/tmp';
!
! // $DiffCmd determines what command to run to compute diffs.
! $DiffCmd = '/usr/bin/diff';
!
! // $MaxPostLen determines the size, in bytes, of the largest edit allowed.
! $MaxPostLen = 204800;
!
! // $MaxNesting determines the maximum allowed nesting of lists.
! $MaxNesting = 20;
!
! // $MaxHeading determines the maximum allowed heading level in headings.
! $MaxHeading = 6;
!
! // $ParseEngine indicates what parsing rules will be run when displaying a
! // wiki page. To disable a particular rule, you can place a comment at the
! // beginning of its line. The order of this list is important.
! // Note that free links and wiki names are disabled above, using config
! // variables. This is because wiki names are parsed in other places than
! // just the wiki page.
! // Raw HTML parsing is turned off by default, since this is a potential
! // security hole.
! $ParseEngine = array(
! 'parse_elem_flag',
! 'parse_raw_html',
! 'parse_htmlisms',
! 'parse_code',
! 'parse_nowiki',
! 'parse_hyperlink_ref',
! 'parse_hyperlink_description',
! 'parse_hyperlink',
! 'parse_macros',
! 'parse_transclude',
! 'parse_freelink',
! 'parse_interwiki',
! 'parse_wikiname',
! 'parse_bold',
! 'parse_italic',
! 'parse_teletype',
! 'parse_heading',
! 'parse_table',
! 'parse_horiz',
! 'parse_indents',
! 'parse_newline',
! 'parse_elements'
! );
!
! // $DiffEngine indicates what parsing rules will be run to display differences
! // between versions. This should be a shorter list than $ParseEngine,
! // since we just want minimal things like bold and italic and wiki links.
! $DiffEngine = array(
! 'parse_elem_flag',
! 'parse_diff_skip',
! 'parse_diff_message',
! 'parse_diff_color',
! 'parse_htmlisms',
! 'parse_nowiki',
! 'parse_hyperlink_ref',
! 'parse_hyperlink_description',
! 'parse_hyperlink',
! 'parse_freelink',
! 'parse_interwiki',
! 'parse_wikiname',
! 'parse_bold',
! 'parse_italic',
! 'parse_teletype',
! 'parse_newline',
! 'parse_elements'
! );
!
! // $DisplayEngine indicates what functions will be used to translate wiki
! // markup elements into actual HTML. See parse/html.php
! $DisplayEngine = array(
! 'bold_start' => 'html_bold_start',
! 'bold_end' => 'html_bold_end',
! 'italic_start' => 'html_italic_start',
! 'italic_end' => 'html_italic_end',
! 'tt_start' => 'html_tt_start',
! 'tt_end' => 'html_tt_end',
! 'head_start' => 'html_head_start',
! 'head_end' => 'html_head_end',
! 'newline' => 'html_newline',
! 'ref' => 'html_ref',
! 'url' => 'html_url',
! 'interwiki' => 'html_interwiki',
! 'raw' => 'html_raw',
! 'code' => 'html_code',
! 'hr' => 'html_hr',
! 'nowiki' => 'html_nowiki',
! 'anchor' => 'html_anchor',
! 'bullet_list_start' => 'html_ul_start',
! 'bullet_list_end' => 'html_ul_end',
! 'bullet_item_start' => 'html_li_start',
! 'bullet_item_end' => 'html_li_end',
! 'indent_list_start' => 'html_dl_start',
! 'indent_list_end' => 'html_dl_end',
! 'indent_item_start' => 'html_dd_start',
! 'indent_item_end' => 'html_dd_end',
! 'term_item_start' => 'html_dt_start',
! 'term_item_end' => 'html_dt_end',
! 'numbered_list_start' => 'html_ol_start',
! 'numbered_list_end' => 'html_ol_end',
! 'numbered_item_start' => 'html_li_start',
! 'numbered_item_end' => 'html_li_end',
! 'diff_old_start' => 'html_diff_old_start',
! 'diff_old_end' => 'html_diff_end',
! 'diff_new_start' => 'html_diff_new_start',
! 'diff_new_end' => 'html_diff_end',
! 'diff_change' => 'html_diff_change',
! 'diff_add' => 'html_diff_add',
! 'diff_delete' => 'html_diff_delete'
! );
!
! // $ViewMacroEngine determines what macro names will be processed when
! // displaying a page. For each name, a function must be provided.
! // See parse/macros.php
! $ViewMacroEngine = array(
! '!' => 'view_macro_category',
! 'Anchor' => 'view_macro_anchor',
! 'Transclude' => 'view_macro_transclude',
! 'PageSize' => 'view_macro_pagesize',
! 'LinkTable' => 'view_macro_linktab',
! 'OrphanedPages' => 'view_macro_orphans',
! 'WantedPages' => 'view_macro_wanted',
! 'PageLinks' => 'view_macro_outlinks',
! 'PageRefs' => 'view_macro_refs'
! );
!
! // $SaveMacroEngine determines what save macros will be called after a
! // page is saved. See parse/save.php
! $SaveMacroEngine = array(
! 'parse_define_interwiki',
! 'parse_define_sisterwiki',
! 'parse_define_links'
! );
! ?>
Index: diff.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/diff.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** diff.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- diff.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,40 ****
! <?php
! // $Id$
!
! // Compute the difference between two sets of text.
! function diff_compute($text1, $text2)
! {
! global $TempDir, $DiffCmd, $ErrorCreatingTemp, $ErrorWritingTemp;
!
! $num = posix_getpid(); // Comment if running on Windows.
! // $num = rand(); // Uncomment if running on Windows.
!
! $temp1 = $TempDir . '/wiki_' . $num . '_1.txt';
! $temp2 = $TempDir . '/wiki_' . $num . '_2.txt';
!
! if(!($h1 = fopen($temp1, 'w')) || !($h2 = fopen($temp2, 'w')))
! { die($ErrorCreatingTemp); }
!
! if(fwrite($h1, $text1) < 0 || fwrite($h2, $text2) < 0)
! { die($ErrorWritingTemp); }
!
! fclose($h1);
! fclose($h2);
!
! $diff = `$DiffCmd $temp1 $temp2`;
!
! unlink($temp1);
! unlink($temp2);
!
! return $diff;
! }
!
! // Parse diff output into nice HTML.
! function diff_parse($text)
! {
! global $DiffEngine;
!
! return parseText($text, $DiffEngine, '');
! }
!
! ?>
--- 1,40 ----
! <?php
! // $Id$
!
! // Compute the difference between two sets of text.
! function diff_compute($text1, $text2)
! {
! global $TempDir, $DiffCmd, $ErrorCreatingTemp, $ErrorWritingTemp;
!
! $num = posix_getpid(); // Comment if running on Windows.
! // $num = rand(); // Uncomment if running on Windows.
!
! $temp1 = $TempDir . '/wiki_' . $num . '_1.txt';
! $temp2 = $TempDir . '/wiki_' . $num . '_2.txt';
!
! if(!($h1 = fopen($temp1, 'w')) || !($h2 = fopen($temp2, 'w')))
! { die($ErrorCreatingTemp); }
!
! if(fwrite($h1, $text1) < 0 || fwrite($h2, $text2) < 0)
! { die($ErrorWritingTemp); }
!
! fclose($h1);
! fclose($h2);
!
! $diff = `$DiffCmd $temp1 $temp2`;
!
! unlink($temp1);
! unlink($temp2);
!
! return $diff;
! }
!
! // Parse diff output into nice HTML.
! function diff_parse($text)
! {
! global $DiffEngine;
!
! return parseText($text, $DiffEngine, '');
! }
!
! ?>
Index: headers.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/headers.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** headers.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- headers.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 15,20 ****
$now = gmdate("D, d M Y H:i:s");
! header("Expires: $now GMT");
! header("Last-Modified: $now GMT");
// header("Cache-Control: no-cache, must-revalidate");
// header("Pragma: no-cache");
--- 15,20 ----
$now = gmdate("D, d M Y H:i:s");
! #header("Expires: $now GMT");
! #header("Last-Modified: $now GMT");
// header("Cache-Control: no-cache, must-revalidate");
// header("Pragma: no-cache");
Index: init.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/init.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** init.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- init.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 60,65 ****
}
! if($Charset != '')
! { header("Content-Type: text/html; charset=$Charset"); }
?>
--- 60,65 ----
}
! #if($Charset != '')
! # { header("Content-Type: text/html; charset=$Charset"); }
?>
Index: main.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/main.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** main.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- main.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,115 ****
! <?php
! // $Id$
!
! // Harvest script parameters and other variables. We do this even if
! // register_globals=on; this way, we force the variables to be defined.
! // (Which is better form in case the admin has warnings cranked all the
! // way up).
!
! $HTTP_REFERER = isset($HTTP_SERVER_VARS['HTTP_REFERER'])
! ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '';
! $QUERY_STRING = isset($HTTP_SERVER_VARS['QUERY_STRING'])
! ? $HTTP_SERVER_VARS['QUERY_STRING'] : '';
! $REMOTE_ADDR = isset($HTTP_SERVER_VARS['REMOTE_ADDR'])
! ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : '';
!
! $action = isset($HTTP_GET_VARS['action'])
! ? $HTTP_GET_VARS['action'] : '';
! $page = isset($HTTP_GET_VARS['page'])
! ? $HTTP_GET_VARS['page'] : '';
! $ver1 = isset($HTTP_GET_VARS['ver1'])
! ? $HTTP_GET_VARS['ver1'] : '';
! $ver2 = isset($HTTP_GET_VARS['ver2'])
! ? $HTTP_GET_VARS['ver2'] : '';
! $find = isset($HTTP_GET_VARS['find'])
! ? $HTTP_GET_VARS['find'] : '';
! $version = isset($HTTP_GET_VARS['version'])
! ? $HTTP_GET_VARS['version'] : '';
! $full = isset($HTTP_GET_VARS['full'])
! ? $HTTP_GET_VARS['full'] : '';
! $min = isset($HTTP_GET_VARS['min'])
! ? $HTTP_GET_VARS['min'] : '';
! $days = isset($HTTP_GET_VARS['days'])
! ? $HTTP_GET_VARS['days'] : '';
!
! $Preview = isset($HTTP_POST_VARS['Preview'])
! ? $HTTP_POST_VARS['Preview'] : '';
! $Save = isset($HTTP_POST_VARS['Save'])
! ? $HTTP_POST_VARS['Save'] : '';
! $archive = isset($HTTP_POST_VARS['archive'])
! ? $HTTP_POST_VARS['archive'] : '';
! $auth = isset($HTTP_POST_VARS['auth'])
! ? $HTTP_POST_VARS['auth'] : '';
! $categories = isset($HTTP_POST_VARS['categories'])
! ? $HTTP_POST_VARS['categories'] : '';
! $cols = isset($HTTP_POST_VARS['cols'])
! ? $HTTP_POST_VARS['cols'] : '';
! $comment = isset($HTTP_POST_VARS['comment'])
! ? $HTTP_POST_VARS['comment'] : '';
! $days = isset($HTTP_POST_VARS['days'])
! ? $HTTP_POST_VARS['days'] : $days;
! $discard = isset($HTTP_POST_VARS['discard'])
! ? $HTTP_POST_VARS['discard'] : '';
! $document = isset($HTTP_POST_VARS['document'])
! ? $HTTP_POST_VARS['document'] : '';
! $hist = isset($HTTP_POST_VARS['hist'])
! ? $HTTP_POST_VARS['hist'] : '';
! $min = isset($HTTP_POST_VARS['min'])
! ? $HTTP_POST_VARS['min'] : $min;
! $nextver = isset($HTTP_POST_VARS['nextver'])
! ? $HTTP_POST_VARS['nextver'] : '';
! $rows = isset($HTTP_POST_VARS['rows'])
! ? $HTTP_POST_VARS['rows'] : '';
! $tzoff = isset($HTTP_POST_VARS['tzoff'])
! ? $HTTP_POST_VARS['tzoff'] : '';
! $user = isset($HTTP_POST_VARS['user'])
! ? $HTTP_POST_VARS['user'] : '';
! $referrer = isset($HTTP_POST_VARS['referrer'])
! ? $HTTP_POST_VARS['referrer'] : '';
!
! require('lib/init.php');
! require('parse/transforms.php');
!
! // To add an action=x behavior, add an entry to this array. First column
! // is the file to load, second is the function to call, and third is how
! // to treat it for rate-checking purposes ('view', 'edit', or 'search').
! $ActionList = array(
! 'view' => array('action/view.php', 'action_view', 'view'),
! 'edit' => array('action/edit.php', 'action_edit', 'view'),
! 'save' => array('action/save.php', 'action_save', 'edit'),
! 'diff' => array('action/diff.php', 'action_diff', 'search'),
! 'find' => array('action/find.php', 'action_find', 'search'),
! 'history' => array('action/history.php', 'action_history',
! 'search'),
! 'prefs' => array('action/prefs.php', 'action_prefs',
'view'),
! 'macro' => array('action/macro.php', 'action_macro',
'search'),
! 'rss' => array('action/rss.php', 'action_rss', 'view'),
! 'style' => array('action/style.php', 'action_style', '')
! );
!
! // Default action and page names.
! if(empty($page) && empty($action))
! { $page = $QUERY_STRING; }
! if(empty($action))
! { $action = 'view'; }
! if(empty($page))
! { $page = $HomePage; }
!
! // Confirm we have a valid page name.
! if(!validate_page($page))
! { die($ErrorInvalidPage); }
!
! // Don't let people do too many things too quickly.
! if($ActionList[$action][2] != '')
! { rateCheck($pagestore->dbh, $ActionList[$action][2]); }
!
! // Dispatch the appropriate action.
! if(!empty($ActionList[$action]))
! {
! include($ActionList[$action][0]);
! $ActionList[$action][1]();
! }
!
! // Expire old versions, etc.
! $pagestore->maintain();
! ?>
--- 1,115 ----
! <?php
! // $Id$
!
! // Harvest script parameters and other variables. We do this even if
! // register_globals=on; this way, we force the variables to be defined.
! // (Which is better form in case the admin has warnings cranked all the
! // way up).
!
! $HTTP_REFERER = isset($HTTP_SERVER_VARS['HTTP_REFERER'])
! ? $HTTP_SERVER_VARS['HTTP_REFERER'] : '';
! $QUERY_STRING = isset($HTTP_SERVER_VARS['QUERY_STRING'])
! ? $HTTP_SERVER_VARS['QUERY_STRING'] : '';
! $REMOTE_ADDR = isset($HTTP_SERVER_VARS['REMOTE_ADDR'])
! ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : '';
!
! $action = isset($HTTP_GET_VARS['action'])
! ? $HTTP_GET_VARS['action'] : '';
! $page = isset($HTTP_GET_VARS['page'])
! ? $HTTP_GET_VARS['page'] : '';
! $ver1 = isset($HTTP_GET_VARS['ver1'])
! ? $HTTP_GET_VARS['ver1'] : '';
! $ver2 = isset($HTTP_GET_VARS['ver2'])
! ? $HTTP_GET_VARS['ver2'] : '';
! $find = isset($HTTP_GET_VARS['find'])
! ? $HTTP_GET_VARS['find'] : '';
! $version = isset($HTTP_GET_VARS['version'])
! ? $HTTP_GET_VARS['version'] : '';
! $full = isset($HTTP_GET_VARS['full'])
! ? $HTTP_GET_VARS['full'] : '';
! $min = isset($HTTP_GET_VARS['min'])
! ? $HTTP_GET_VARS['min'] : '';
! $days = isset($HTTP_GET_VARS['days'])
! ? $HTTP_GET_VARS['days'] : '';
!
! $Preview = isset($HTTP_POST_VARS['Preview'])
! ? $HTTP_POST_VARS['Preview'] : '';
! $Save = isset($HTTP_POST_VARS['Save'])
! ? $HTTP_POST_VARS['Save'] : '';
! $archive = isset($HTTP_POST_VARS['archive'])
! ? $HTTP_POST_VARS['archive'] : '';
! $auth = isset($HTTP_POST_VARS['auth'])
! ? $HTTP_POST_VARS['auth'] : '';
! $categories = isset($HTTP_POST_VARS['categories'])
! ? $HTTP_POST_VARS['categories'] : '';
! $cols = isset($HTTP_POST_VARS['cols'])
! ? $HTTP_POST_VARS['cols'] : '';
! $comment = isset($HTTP_POST_VARS['comment'])
! ? $HTTP_POST_VARS['comment'] : '';
! $days = isset($HTTP_POST_VARS['days'])
! ? $HTTP_POST_VARS['days'] : $days;
! $discard = isset($HTTP_POST_VARS['discard'])
! ? $HTTP_POST_VARS['discard'] : '';
! $document = isset($HTTP_POST_VARS['document'])
! ? $HTTP_POST_VARS['document'] : '';
! $hist = isset($HTTP_POST_VARS['hist'])
! ? $HTTP_POST_VARS['hist'] : '';
! $min = isset($HTTP_POST_VARS['min'])
! ? $HTTP_POST_VARS['min'] : $min;
! $nextver = isset($HTTP_POST_VARS['nextver'])
! ? $HTTP_POST_VARS['nextver'] : '';
! $rows = isset($HTTP_POST_VARS['rows'])
! ? $HTTP_POST_VARS['rows'] : '';
! $tzoff = isset($HTTP_POST_VARS['tzoff'])
! ? $HTTP_POST_VARS['tzoff'] : '';
! $user = isset($HTTP_POST_VARS['user'])
! ? $HTTP_POST_VARS['user'] : '';
! $referrer = isset($HTTP_POST_VARS['referrer'])
! ? $HTTP_POST_VARS['referrer'] : '';
!
! require('lib/init.php');
! require('parse/transforms.php');
!
! // To add an action=x behavior, add an entry to this array. First column
! // is the file to load, second is the function to call, and third is how
! // to treat it for rate-checking purposes ('view', 'edit', or 'search').
! $ActionList = array(
! 'view' => array('action/view.php', 'action_view', 'view'),
! 'edit' => array('action/edit.php', 'action_edit', 'view'),
! 'save' => array('action/save.php', 'action_save', 'edit'),
! 'diff' => array('action/diff.php', 'action_diff', 'search'),
! 'find' => array('action/find.php', 'action_find', 'search'),
! 'history' => array('action/history.php', 'action_history',
! 'search'),
! 'prefs' => array('action/prefs.php', 'action_prefs',
'view'),
! 'macro' => array('action/macro.php', 'action_macro',
'search'),
! 'rss' => array('action/rss.php', 'action_rss', 'view'),
! 'style' => array('action/style.php', 'action_style', '')
! );
!
! // Default action and page names.
! if(empty($page) && empty($action))
! { $page = $QUERY_STRING; }
! if(empty($action))
! { $action = 'view'; }
! if(empty($page))
! { $page = $HomePage; }
!
! // Confirm we have a valid page name.
! if(!validate_page($page))
! { die($ErrorInvalidPage); }
!
! // Don't let people do too many things too quickly.
! if($ActionList[$action][2] != '')
! { rateCheck($pagestore->dbh, $ActionList[$action][2]); }
!
! // Dispatch the appropriate action.
! if(!empty($ActionList[$action]))
! {
! include($ActionList[$action][0]);
! $ActionList[$action][1]();
! }
!
! // Expire old versions, etc.
! $pagestore->maintain();
! ?>
Index: messages.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/messages.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** messages.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- messages.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,24 ****
! <?php
! // $Id$
!
! // Error messages.
! $ErrorSuffix = '<br /><br />Please contact the ' .
! '<a href="mailto:' . $Admin . '">administrator</a> ' .
! 'for assistance.';
! $ErrorDatabaseConnect = 'Error connecting to database.' . $ErrorSuffix;
! $ErrorDatabaseSelect = 'Error selecting database.' . $ErrorSuffix;
! $ErrorDatabaseQuery = 'Error executing database query.' . $ErrorSuffix;
! $ErrorCreatingTemp = 'Error creating temporary file.' . $ErrorSuffix;
! $ErrorWritingTemp = 'Error writing to temporary file.' . $ErrorSuffix;
! $ErrorDeniedAccess = 'You have been denied access to this site.' .
! $ErrorSuffix;
! $ErrorRateExceeded = 'You have exeeded the number of pages you are ' .
! 'allowed to visit in a given period of time. Please
' .
! 'return later.' . $ErrorSuffix;
! $ErrorNameMatch = 'You have entered an invalid user name.' .
$ErrorSuffix;
! $ErrorInvalidPage = 'Invalid page name.' . $ErrorSuffix;
! $ErrorAdminDisabled = 'Administration features are disabled for this wiki.'
.
! $ErrorSuffix;
! $ErrorPageLocked = 'The page you have tried to edit is locked.' .
! $ErrorSuffix;
! ?>
--- 1,24 ----
! <?php
! // $Id$
!
! // Error messages.
! $ErrorSuffix = '<br /><br />Please contact the ' .
! '<a href="mailto:' . $Admin . '">administrator</a> ' .
! 'for assistance.';
! $ErrorDatabaseConnect = 'Error connecting to database.' . $ErrorSuffix;
! $ErrorDatabaseSelect = 'Error selecting database.' . $ErrorSuffix;
! $ErrorDatabaseQuery = 'Error executing database query.' . $ErrorSuffix;
! $ErrorCreatingTemp = 'Error creating temporary file.' . $ErrorSuffix;
! $ErrorWritingTemp = 'Error writing to temporary file.' . $ErrorSuffix;
! $ErrorDeniedAccess = 'You have been denied access to this site.' .
! $ErrorSuffix;
! $ErrorRateExceeded = 'You have exeeded the number of pages you are ' .
! 'allowed to visit in a given period of time. Please
' .
! 'return later.' . $ErrorSuffix;
! $ErrorNameMatch = 'You have entered an invalid user name.' .
$ErrorSuffix;
! $ErrorInvalidPage = 'Invalid page name.' . $ErrorSuffix;
! $ErrorAdminDisabled = 'Administration features are disabled for this wiki.'
.
! $ErrorSuffix;
! $ErrorPageLocked = 'The page you have tried to edit is locked.' .
! $ErrorSuffix;
! ?>
Index: page.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/page.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** page.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- page.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,97 ****
! <?php
! // $Id$
!
! // Abstractor to read and write wiki pages.
! class WikiPage
! {
! var $name = ''; // Name of page.
! var $dbname = ''; // Name used in DB queries.
! var $text = ''; // Page's text in wiki markup form.
! var $time = ''; // Page's modification time.
! var $hostname = ''; // Hostname of last editor.
! var $username = ''; // Username of last editor.
! var $comment = ''; // Description of last edit.
! var $version = -1; // Version number of page.
! var $mutable = 1; // Whether page may be edited.
! var $exists = 0; // Whether page already exists.
! var $db; // Database object.
!
! function WikiPage($db_, $name_ = '')
! {
! $this->db = $db_;
! $this->name = $name_;
! $this->dbname = str_replace('\\', '\\\\', $name_);
! $this->dbname = str_replace('\'', '\\\'', $this->dbname);
! }
!
! // Check whether a page exists.
! // Returns: nonzero if page exists in database.
!
! function exists()
! {
! global $PgTbl;
!
! $qid = $this->db->query("SELECT MAX(version) FROM $PgTbl " .
! "WHERE title='$this->dbname'");
! return !!(($result = $this->db->result($qid)) && $result[0]);
! }
!
! // Read in a page's contents.
! // Returns: contents of the page.
!
! function read()
! {
! global $PgTbl;
!
! $query = "SELECT title, time, author, body, mutable, version, " .
! "username, comment " .
! "FROM $PgTbl WHERE title = '$this->dbname' ";
! if($this->version != -1)
! { $query = $query . "AND version = '$this->version'"; }
! else
! { $query = $query . "ORDER BY version DESC"; }
!
! $qid = $this->db->query($query);
!
! if(!($result = $this->db->result($qid)))
! { return ""; }
!
! $this->time = $result[1];
! $this->hostname = $result[2];
! $this->exists = 1;
! $this->version = $result[5];
! $this->mutable = ($result[4] == 'on');
! $this->username = $result[6];
! $this->text = $result[3];
! $this->comment = $result[7];
!
! return $this->text;
! }
!
! // Write out a page's contents.
! // Note: caller is responsible for performing locking.
! // Note: it is assumed that the 'time' member actually contains the
! // modification-time for the *previous* version. It is expected that
! // the previous version will have been read into the same object.
! // Yes, this is a tiny kludge. :-)
!
! function write()
! {
! global $PgTbl;
!
! $this->db->query("INSERT INTO $PgTbl (title, version, time, supercede, " .
! "mutable, username, author, comment, body) " .
! "VALUES('$this->dbname', $this->version, NULL, NULL, '" .
! ($this->mutable ? 'on' : 'off') . "', " .
! "'$this->username', '$this->hostname', " .
! "'$this->comment', '$this->text')");
!
! if($this->version > 1)
! {
! $this->db->query("UPDATE $PgTbl SET time=$this->time, " .
! "supercede=NULL WHERE title='$this->dbname' " .
! "AND version=" . ($this->version - 1));
! }
! }
! }
! ?>
--- 1,97 ----
! <?php
! // $Id$
!
! // Abstractor to read and write wiki pages.
! class WikiPage
! {
! var $name = ''; // Name of page.
! var $dbname = ''; // Name used in DB queries.
! var $text = ''; // Page's text in wiki markup form.
! var $time = ''; // Page's modification time.
! var $hostname = ''; // Hostname of last editor.
! var $username = ''; // Username of last editor.
! var $comment = ''; // Description of last edit.
! var $version = -1; // Version number of page.
! var $mutable = 1; // Whether page may be edited.
! var $exists = 0; // Whether page already exists.
! var $db; // Database object.
!
! function WikiPage($db_, $name_ = '')
! {
! $this->db = $db_;
! $this->name = $name_;
! $this->dbname = str_replace('\\', '\\\\', $name_);
! $this->dbname = str_replace('\'', '\\\'', $this->dbname);
! }
!
! // Check whether a page exists.
! // Returns: nonzero if page exists in database.
!
! function exists()
! {
! global $PgTbl;
!
! $qid = $this->db->query("SELECT MAX(version) FROM $PgTbl " .
! "WHERE title='$this->dbname'");
! return !!(($result = $this->db->result($qid)) && $result[0]);
! }
!
! // Read in a page's contents.
! // Returns: contents of the page.
!
! function read()
! {
! global $PgTbl;
!
! $query = "SELECT title, time, author, body, mutable, version, " .
! "username, comment " .
! "FROM $PgTbl WHERE title = '$this->dbname' ";
! if($this->version != -1)
! { $query = $query . "AND version = '$this->version'"; }
! else
! { $query = $query . "ORDER BY version DESC"; }
!
! $qid = $this->db->query($query);
!
! if(!($result = $this->db->result($qid)))
! { return ""; }
!
! $this->time = $result[1];
! $this->hostname = $result[2];
! $this->exists = 1;
! $this->version = $result[5];
! $this->mutable = ($result[4] == 'on');
! $this->username = $result[6];
! $this->text = $result[3];
! $this->comment = $result[7];
!
! return $this->text;
! }
!
! // Write out a page's contents.
! // Note: caller is responsible for performing locking.
! // Note: it is assumed that the 'time' member actually contains the
! // modification-time for the *previous* version. It is expected that
! // the previous version will have been read into the same object.
! // Yes, this is a tiny kludge. :-)
!
! function write()
! {
! global $PgTbl;
!
! $this->db->query("INSERT INTO $PgTbl (title, version, time, supercede, " .
! "mutable, username, author, comment, body) " .
! "VALUES('$this->dbname', $this->version, NULL, NULL, '" .
! ($this->mutable ? 'on' : 'off') . "', " .
! "'$this->username', '$this->hostname', " .
! "'$this->comment', '$this->text')");
!
! if($this->version > 1)
! {
! $this->db->query("UPDATE $PgTbl SET time=$this->time, " .
! "supercede=NULL WHERE title='$this->dbname' " .
! "AND version=" . ($this->version - 1));
! }
! }
! }
! ?>
Index: pagestore.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/pagestore.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** pagestore.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- pagestore.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,326 ****
! <?php
! // $Id$
!
! require('lib/db.php');
! require('lib/page.php');
!
! // Abstractor for the page database. Note that page.php contains the actual
! // code to read/write pages; this serves more general query functions.
! class PageStore
! {
! var $dbh;
!
! function PageStore()
! {
! global $DBPersist, $DBServer, $DBUser, $DBPasswd, $DBName;
!
! $this->dbh = new WikiDB($DBPersist, $DBServer, $DBUser, $DBPasswd,
$DBName);
! }
!
! // Create a page object.
! function page($name = '')
! {
! return new WikiPage($this->dbh, $name);
! }
!
! // Find text in the database.
! function find($text)
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT t1.title, t1.body, t1.version, " .
! "MAX(t2.version) " .
! "FROM $PgTbl AS t1, $PgTbl AS t2 " .
! "WHERE t1.title = t2.title " .
! "GROUP BY t2.title, t1.version " .
! "HAVING t1.version = MAX(t2.version) " .
! "AND (body LIKE '%$text%' OR title LIKE
'%$text%')");
!
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = $result[0];
! }
!
! return $list;
! }
!
! // Retrieve a page's edit history.
! function history($page)
! {
! global $PgTbl;
!
! $page = addslashes($page);
! $qid = $this->dbh->query("SELECT time, author, version, username, " .
! "comment " .
! "FROM $PgTbl WHERE title='$page' " .
! "ORDER BY version DESC");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[0], $result[1], $result[2], $result[3],
! $result[4]);
! }
!
! return $list;
! }
!
! // Look up an interwiki prefix.
! function interwiki($name)
! {
! global $IwTbl;
!
! $name = addslashes($name);
! $qid = $this->dbh->query("SELECT url FROM $IwTbl WHERE prefix='$name'");
! if(($result = $this->dbh->result($qid)))
! { return $result[0]; }
! return '';
! }
!
! // Clear all the links cached for a particular page.
! function clear_link($page)
! {
! global $LkTbl;
!
! $page = addslashes($page);
! $this->dbh->query("DELETE FROM $LkTbl WHERE page='$page'");
! }
!
! // Clear all the interwiki definitions for a particular page.
! function clear_interwiki($page)
! {
! global $IwTbl;
!
! $page = addslashes($page);
! $this->dbh->query("DELETE FROM $IwTbl WHERE where_defined='$page'");
! }
!
! // Clear all the sisterwiki definitions for a particular page.
! function clear_sisterwiki($page)
! {
! global $SwTbl;
!
! $page = addslashes($page);
! $this->dbh->query("DELETE FROM $SwTbl WHERE where_defined='$page'");
! }
!
! // Add a link for a given page to the link table.
! function new_link($page, $link)
! {
! // Assumption: this will only ever be called with one page per
! // script invocation. If this assumption should change, $links should
! // be made a 2-dimensional array.
!
! global $LkTbl;
! static $links = array();
!
! $page = addslashes($page);
! $link = addslashes($link);
!
! if(empty($links[$link]))
! {
! $this->dbh->query("INSERT INTO $LkTbl VALUES('$page', '$link', 1)");
! $links[$link] = 1;
! }
! else
! {
! $links[$link]++;
! $this->dbh->query("UPDATE $LkTbl SET count=" . $links[$link] .
! " WHERE page='$page' AND link='$link'");
! }
! }
!
! // Add an interwiki definition for a particular page.
! function new_interwiki($where_defined, $prefix, $url)
! {
! global $IwTbl;
!
! $url = str_replace("'", "\\'", $url);
! $url = str_replace("&", "&", $url);
!
! $where_defined = addslashes($where_defined);
!
! $qid = $this->dbh->query("SELECT where_defined FROM $IwTbl " .
! "WHERE prefix='$prefix'");
! if($this->dbh->result($qid))
! {
! $this->dbh->query("UPDATE $IwTbl SET where_defined='$where_defined', " .
! "url='$url' WHERE prefix='$prefix'");
! }
! else
! {
! $this->dbh->query("INSERT INTO $IwTbl(prefix, where_defined, url) " .
! "VALUES('$prefix', '$where_defined', '$url')");
! }
! }
!
! // Add a sisterwiki definition for a particular page.
! function new_sisterwiki($where_defined, $prefix, $url)
! {
! global $SwTbl;
!
! $url = str_replace("'", "\\'", $url);
! $url = str_replace("&", "&", $url);
!
! $where_defined = addslashes($where_defined);
!
! $qid = $this->dbh->query("SELECT where_defined FROM $SwTbl " .
! "WHERE prefix='$prefix'");
! if($this->dbh->result($qid))
! {
! $this->dbh->query("UPDATE $SwTbl SET where_defined='$where_defined', " .
! "url='$url' WHERE prefix='$prefix'");
! }
! else
! {
! $this->dbh->query("INSERT INTO $SwTbl(prefix, where_defined, url) " .
! "VALUES('$prefix', '$where_defined', '$url')");
! }
! }
!
! // Find all twins of a page at sisterwiki sites.
! function twinpages($page)
! {
! global $RemTbl;
!
! $list = array();
! $page = addslashes($page);
! $q2 = $this->dbh->query("SELECT site, page FROM $RemTbl " .
! "WHERE page LIKE '$page'");
! while(($twin = $this->dbh->result($q2)))
! { $list[] = array($twin[0], $twin[1]); }
!
! return $list;
! }
!
! // Lock the database tables.
! function lock()
! {
! global $PgTbl, $IwTbl, $SwTbl, $LkTbl;
!
! $this->dbh->query("LOCK TABLES $PgTbl WRITE, $IwTbl WRITE, $SwTbl WRITE,
" .
! "$LkTbl WRITE");
! }
!
! // Unlock the database tables.
! function unlock()
! {
! $this->dbh->query("UNLOCK TABLES");
! }
!
! // Retrieve a list of all of the pages in the wiki.
! function allpages()
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT t1.title, t1.version, t1.author,
t1.time, " .
! "t1.username, LENGTH(t1.body), t1.comment, " .
! "t1.mutable, MAX(t2.version) " .
! "FROM $PgTbl AS t1, $PgTbl AS t2 " .
! "WHERE t1.title = t2.title " .
! "GROUP BY t2.title, t1.version " .
! "HAVING t1.version = MAX(t2.version)");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[3], $result[0], $result[2], $result[4],
! $result[5], $result[6], $result[7] == 'on', $result[1]);
! }
!
! return $list;
! }
!
! // Retrieve a list of all new pages in the wiki.
! function newpages()
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT title, author, time, username, " .
! "LENGTH(body), comment " .
! "FROM $PgTbl WHERE version=1");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[2], $result[0], $result[1], $result[3],
! $result[4], $result[5]);
! }
!
! return $list;
! }
!
! // Return a list of all empty (deleted) pages in the wiki.
! function emptypages()
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT t1.title, t1.version, t1.author, " .
! "t1.time, t1.username, t1.comment, t1.body, " .
! "MAX(t2.version) " .
! "FROM $PgTbl AS t1, $PgTbl AS t2 " .
! "WHERE t1.title = t2.title " .
! "GROUP BY t2.title, t1.version " .
! "HAVING t1.version = MAX(t2.version) " .
! "AND t1.body=''");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[3], $result[0], $result[2],
! $result[4], 0, $result[5]);
! }
!
! return $list;
! }
!
! // Return a list of information about a particular set of pages.
! function givenpages($names)
! {
! global $PgTbl;
!
! $list = array();
! foreach($names as $page)
! {
! $esc_page = addslashes($page);
! $qid = $this->dbh->query("SELECT time, author, username, LENGTH(body),
" .
! "comment FROM $PgTbl WHERE title='$esc_page' "
.
! "ORDER BY version DESC");
!
! if(!($result = $this->dbh->result($qid)))
! { continue; }
!
! $list[] = array($result[0], $page, $result[1], $result[2],
! $result[3], $result[4]);
! }
!
! return $list;
! }
!
! // Expire old versions of pages.
! function maintain()
! {
! global $PgTbl, $RtTbl, $ExpireLen, $RatePeriod;
!
! $qid = $this->dbh->query("SELECT title, MAX(version) FROM $PgTbl " .
! "GROUP BY title");
!
! while(($result = $this->dbh->result($qid)))
! {
! $result[0] = addslashes($result[0]);
! $this->dbh->query("DELETE FROM $PgTbl WHERE title='$result[0]' AND " .
! "(version < $result[1] OR body='') AND " .
! "TO_DAYS(NOW()) - TO_DAYS(supercede) > $ExpireLen");
! }
!
! if($RatePeriod)
! {
! $this->dbh->query("DELETE FROM $RtTbl " .
! "WHERE ip NOT LIKE '%.*' " .
! "AND TO_DAYS(NOW()) > TO_DAYS(time)");
! }
! }
! }
! ?>
--- 1,326 ----
! <?php
! // $Id$
!
! require('lib/db.php');
! require('lib/page.php');
!
! // Abstractor for the page database. Note that page.php contains the actual
! // code to read/write pages; this serves more general query functions.
! class PageStore
! {
! var $dbh;
!
! function PageStore()
! {
! global $DBPersist, $DBServer, $DBUser, $DBPasswd, $DBName;
!
! $this->dbh = new WikiDB($DBPersist, $DBServer, $DBUser, $DBPasswd,
$DBName);
! }
!
! // Create a page object.
! function page($name = '')
! {
! return new WikiPage($this->dbh, $name);
! }
!
! // Find text in the database.
! function find($text)
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT t1.title, t1.body, t1.version, " .
! "MAX(t2.version) " .
! "FROM $PgTbl AS t1, $PgTbl AS t2 " .
! "WHERE t1.title = t2.title " .
! "GROUP BY t2.title, t1.version " .
! "HAVING t1.version = MAX(t2.version) " .
! "AND (body LIKE '%$text%' OR title LIKE
'%$text%')");
!
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = $result[0];
! }
!
! return $list;
! }
!
! // Retrieve a page's edit history.
! function history($page)
! {
! global $PgTbl;
!
! $page = addslashes($page);
! $qid = $this->dbh->query("SELECT time, author, version, username, " .
! "comment " .
! "FROM $PgTbl WHERE title='$page' " .
! "ORDER BY version DESC");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[0], $result[1], $result[2], $result[3],
! $result[4]);
! }
!
! return $list;
! }
!
! // Look up an interwiki prefix.
! function interwiki($name)
! {
! global $IwTbl;
!
! $name = addslashes($name);
! $qid = $this->dbh->query("SELECT url FROM $IwTbl WHERE prefix='$name'");
! if(($result = $this->dbh->result($qid)))
! { return $result[0]; }
! return '';
! }
!
! // Clear all the links cached for a particular page.
! function clear_link($page)
! {
! global $LkTbl;
!
! $page = addslashes($page);
! $this->dbh->query("DELETE FROM $LkTbl WHERE page='$page'");
! }
!
! // Clear all the interwiki definitions for a particular page.
! function clear_interwiki($page)
! {
! global $IwTbl;
!
! $page = addslashes($page);
! $this->dbh->query("DELETE FROM $IwTbl WHERE where_defined='$page'");
! }
!
! // Clear all the sisterwiki definitions for a particular page.
! function clear_sisterwiki($page)
! {
! global $SwTbl;
!
! $page = addslashes($page);
! $this->dbh->query("DELETE FROM $SwTbl WHERE where_defined='$page'");
! }
!
! // Add a link for a given page to the link table.
! function new_link($page, $link)
! {
! // Assumption: this will only ever be called with one page per
! // script invocation. If this assumption should change, $links should
! // be made a 2-dimensional array.
!
! global $LkTbl;
! static $links = array();
!
! $page = addslashes($page);
! $link = addslashes($link);
!
! if(empty($links[$link]))
! {
! $this->dbh->query("INSERT INTO $LkTbl VALUES('$page', '$link', 1)");
! $links[$link] = 1;
! }
! else
! {
! $links[$link]++;
! $this->dbh->query("UPDATE $LkTbl SET count=" . $links[$link] .
! " WHERE page='$page' AND link='$link'");
! }
! }
!
! // Add an interwiki definition for a particular page.
! function new_interwiki($where_defined, $prefix, $url)
! {
! global $IwTbl;
!
! $url = str_replace("'", "\\'", $url);
! $url = str_replace("&", "&", $url);
!
! $where_defined = addslashes($where_defined);
!
! $qid = $this->dbh->query("SELECT where_defined FROM $IwTbl " .
! "WHERE prefix='$prefix'");
! if($this->dbh->result($qid))
! {
! $this->dbh->query("UPDATE $IwTbl SET where_defined='$where_defined', " .
! "url='$url' WHERE prefix='$prefix'");
! }
! else
! {
! $this->dbh->query("INSERT INTO $IwTbl(prefix, where_defined, url) " .
! "VALUES('$prefix', '$where_defined', '$url')");
! }
! }
!
! // Add a sisterwiki definition for a particular page.
! function new_sisterwiki($where_defined, $prefix, $url)
! {
! global $SwTbl;
!
! $url = str_replace("'", "\\'", $url);
! $url = str_replace("&", "&", $url);
!
! $where_defined = addslashes($where_defined);
!
! $qid = $this->dbh->query("SELECT where_defined FROM $SwTbl " .
! "WHERE prefix='$prefix'");
! if($this->dbh->result($qid))
! {
! $this->dbh->query("UPDATE $SwTbl SET where_defined='$where_defined', " .
! "url='$url' WHERE prefix='$prefix'");
! }
! else
! {
! $this->dbh->query("INSERT INTO $SwTbl(prefix, where_defined, url) " .
! "VALUES('$prefix', '$where_defined', '$url')");
! }
! }
!
! // Find all twins of a page at sisterwiki sites.
! function twinpages($page)
! {
! global $RemTbl;
!
! $list = array();
! $page = addslashes($page);
! $q2 = $this->dbh->query("SELECT site, page FROM $RemTbl " .
! "WHERE page LIKE '$page'");
! while(($twin = $this->dbh->result($q2)))
! { $list[] = array($twin[0], $twin[1]); }
!
! return $list;
! }
!
! // Lock the database tables.
! function lock()
! {
! global $PgTbl, $IwTbl, $SwTbl, $LkTbl;
!
! $this->dbh->query("LOCK TABLES $PgTbl WRITE, $IwTbl WRITE, $SwTbl WRITE,
" .
! "$LkTbl WRITE");
! }
!
! // Unlock the database tables.
! function unlock()
! {
! $this->dbh->query("UNLOCK TABLES");
! }
!
! // Retrieve a list of all of the pages in the wiki.
! function allpages()
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT t1.title, t1.version, t1.author,
t1.time, " .
! "t1.username, LENGTH(t1.body), t1.comment, " .
! "t1.mutable, MAX(t2.version) " .
! "FROM $PgTbl AS t1, $PgTbl AS t2 " .
! "WHERE t1.title = t2.title " .
! "GROUP BY t2.title, t1.version " .
! "HAVING t1.version = MAX(t2.version)");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[3], $result[0], $result[2], $result[4],
! $result[5], $result[6], $result[7] == 'on', $result[1]);
! }
!
! return $list;
! }
!
! // Retrieve a list of all new pages in the wiki.
! function newpages()
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT title, author, time, username, " .
! "LENGTH(body), comment " .
! "FROM $PgTbl WHERE version=1");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[2], $result[0], $result[1], $result[3],
! $result[4], $result[5]);
! }
!
! return $list;
! }
!
! // Return a list of all empty (deleted) pages in the wiki.
! function emptypages()
! {
! global $PgTbl;
!
! $qid = $this->dbh->query("SELECT t1.title, t1.version, t1.author, " .
! "t1.time, t1.username, t1.comment, t1.body, " .
! "MAX(t2.version) " .
! "FROM $PgTbl AS t1, $PgTbl AS t2 " .
! "WHERE t1.title = t2.title " .
! "GROUP BY t2.title, t1.version " .
! "HAVING t1.version = MAX(t2.version) " .
! "AND t1.body=''");
!
! $list = array();
! while(($result = $this->dbh->result($qid)))
! {
! $list[] = array($result[3], $result[0], $result[2],
! $result[4], 0, $result[5]);
! }
!
! return $list;
! }
!
! // Return a list of information about a particular set of pages.
! function givenpages($names)
! {
! global $PgTbl;
!
! $list = array();
! foreach($names as $page)
! {
! $esc_page = addslashes($page);
! $qid = $this->dbh->query("SELECT time, author, username, LENGTH(body),
" .
! "comment FROM $PgTbl WHERE title='$esc_page' "
.
! "ORDER BY version DESC");
!
! if(!($result = $this->dbh->result($qid)))
! { continue; }
!
! $list[] = array($result[0], $page, $result[1], $result[2],
! $result[3], $result[4]);
! }
!
! return $list;
! }
!
! // Expire old versions of pages.
! function maintain()
! {
! global $PgTbl, $RtTbl, $ExpireLen, $RatePeriod;
!
! $qid = $this->dbh->query("SELECT title, MAX(version) FROM $PgTbl " .
! "GROUP BY title");
!
! while(($result = $this->dbh->result($qid)))
! {
! $result[0] = addslashes($result[0]);
! $this->dbh->query("DELETE FROM $PgTbl WHERE title='$result[0]' AND " .
! "(version < $result[1] OR body='') AND " .
! "TO_DAYS(NOW()) - TO_DAYS(supercede) > $ExpireLen");
! }
!
! if($RatePeriod)
! {
! $this->dbh->query("DELETE FROM $RtTbl " .
! "WHERE ip NOT LIKE '%.*' " .
! "AND TO_DAYS(NOW()) > TO_DAYS(time)");
! }
! }
! }
! ?>
Index: rate.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/rate.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** rate.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- rate.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 1,114 ****
! <?php
! // $Id$
!
! // Perform a lookup on an IP addresses edit-rate.
! function rateCheck($db, $type)
! {
! global $RatePeriod, $RateView, $RateSearch, $RateEdit, $REMOTE_ADDR;
! global $ErrorDeniedAccess, $ErrorRateExceeded, $RtTbl;
!
! $fields = explode(".", $REMOTE_ADDR);
! if($RatePeriod == 0)
! { return; }
!
! $db->query("LOCK TABLES $RtTbl WRITE");
!
! // Make sure this IP address hasn't been excluded.
!
! $qid = $db->query("SELECT * FROM $RtTbl WHERE ip='$fields[0].*'");
! if($db->result($qid))
! { die($ErrorDeniedAccess); }
! $qid = $db->query("SELECT * FROM $RtTbl WHERE
ip='$fields[0].$fields[1].*'");
! if($db->result($qid))
! { die($ErrorDeniedAccess); }
! $qid = $db->query("SELECT * FROM $RtTbl " .
! "WHERE ip='$fields[0].$fields[1].$fields[2].*'");
! if($db->result($qid))
! { die($ErrorDeniedAccess); }
!
! // Now check how many more actions we can perform.
!
! $qid = $db->query("SELECT TIME_TO_SEC(NOW()) - TIME_TO_SEC(time), " .
! "viewLimit, searchLimit, editLimit FROM $RtTbl " .
! "WHERE ip='$REMOTE_ADDR'");
! if(!($result = $db->result($qid)))
! { $result = array(-1, $RateView, $RateSearch, $RateEdit); }
! else
! {
! if($result[0] < 0)
! { $result[0] = $RatePeriod; }
! $result[1] = min($result[1] + $result[0] * $RateView / $RatePeriod,
! $RateView);
! $result[2] = min($result[2] + $result[0] * $RateSearch / $RatePeriod,
! $RateSearch);
! $result[3] = min($result[3] + $result[0] * $RateEdit / $RatePeriod,
! $RateEdit);
! }
!
! if($type == 'view')
! { $result[1]--; }
! else if($type == 'search')
! { $result[2]--; }
! else if($type == 'edit')
! { $result[3]--; }
!
! if($result[1] < 0 || $result[2] < 0 || $result[3] < 0)
! { die($ErrorRateExceeded); }
!
! // Record this action.
!
! if($result[0] == -1)
! {
! $db->query("INSERT INTO $RtTbl VALUES('$REMOTE_ADDR', " .
! "NULL, $result[1], $result[2], $result[3])");
! }
! else
! {
! $db->query("UPDATE $RtTbl SET viewLimit=$result[1], " .
! "searchLimit=$result[2], editLimit=$result[3] " .
! "WHERE ip='$REMOTE_ADDR'");
! }
!
! $db->query("UNLOCK TABLES");
! }
!
! // Return a list of blocked address ranges.
! function rateBlockList($db)
! {
! global $RatePeriod, $RtTbl;
!
! $list = array();
!
! if($RatePeriod == 0)
! { return $list; }
!
! $qid = $db->query("SELECT ip FROM $RtTbl");
! while(($result = $db->result($qid)))
! {
! if(preg_match('/^\\d+\\.(\\d+\\.(\\d+\\.)?)?\\*$/', $result[0]))
! { $list[] = $result[0]; }
! }
!
! return $list;
! }
!
! // Block an address range.
! function rateBlockAdd($db, $address)
! {
! global $RtTbl;
!
! if(!preg_match('/^\\d+\\.(\\d+\\.(\\d+\\.)?)?\\*$/', $address))
! { return; }
! $qid = $db->query("SELECT * FROM $RtTbl WHERE ip='$address'");
! if($db->result($qid))
! { return; }
! $db->query("INSERT INTO $RtTbl(ip) VALUES('$address')");
! }
!
! function rateBlockRemove($db, $address)
! {
! global $RtTbl;
!
! $db->query("DELETE FROM $RtTbl WHERE ip='$address'");
! }
! ?>
--- 1,114 ----
! <?php
! // $Id$
!
! // Perform a lookup on an IP addresses edit-rate.
! function rateCheck($db, $type)
! {
! global $RatePeriod, $RateView, $RateSearch, $RateEdit, $REMOTE_ADDR;
! global $ErrorDeniedAccess, $ErrorRateExceeded, $RtTbl;
!
! $fields = explode(".", $REMOTE_ADDR);
! if($RatePeriod == 0)
! { return; }
!
! $db->query("LOCK TABLES $RtTbl WRITE");
!
! // Make sure this IP address hasn't been excluded.
!
! $qid = $db->query("SELECT * FROM $RtTbl WHERE ip='$fields[0].*'");
! if($db->result($qid))
! { die($ErrorDeniedAccess); }
! $qid = $db->query("SELECT * FROM $RtTbl WHERE
ip='$fields[0].$fields[1].*'");
! if($db->result($qid))
! { die($ErrorDeniedAccess); }
! $qid = $db->query("SELECT * FROM $RtTbl " .
! "WHERE ip='$fields[0].$fields[1].$fields[2].*'");
! if($db->result($qid))
! { die($ErrorDeniedAccess); }
!
! // Now check how many more actions we can perform.
!
! $qid = $db->query("SELECT TIME_TO_SEC(NOW()) - TIME_TO_SEC(time), " .
! "viewLimit, searchLimit, editLimit FROM $RtTbl " .
! "WHERE ip='$REMOTE_ADDR'");
! if(!($result = $db->result($qid)))
! { $result = array(-1, $RateView, $RateSearch, $RateEdit); }
! else
! {
! if($result[0] < 0)
! { $result[0] = $RatePeriod; }
! $result[1] = min($result[1] + $result[0] * $RateView / $RatePeriod,
! $RateView);
! $result[2] = min($result[2] + $result[0] * $RateSearch / $RatePeriod,
! $RateSearch);
! $result[3] = min($result[3] + $result[0] * $RateEdit / $RatePeriod,
! $RateEdit);
! }
!
! if($type == 'view')
! { $result[1]--; }
! else if($type == 'search')
! { $result[2]--; }
! else if($type == 'edit')
! { $result[3]--; }
!
! if($result[1] < 0 || $result[2] < 0 || $result[3] < 0)
! { die($ErrorRateExceeded); }
!
! // Record this action.
!
! if($result[0] == -1)
! {
! $db->query("INSERT INTO $RtTbl VALUES('$REMOTE_ADDR', " .
! "NULL, $result[1], $result[2], $result[3])");
! }
! else
! {
! $db->query("UPDATE $RtTbl SET viewLimit=$result[1], " .
! "searchLimit=$result[2], editLimit=$result[3] " .
! "WHERE ip='$REMOTE_ADDR'");
! }
!
! $db->query("UNLOCK TABLES");
! }
!
! // Return a list of blocked address ranges.
! function rateBlockList($db)
! {
! global $RatePeriod, $RtTbl;
!
! $list = array();
!
! if($RatePeriod == 0)
! { return $list; }
!
! $qid = $db->query("SELECT ip FROM $RtTbl");
! while(($result = $db->result($qid)))
! {
! if(preg_match('/^\\d+\\.(\\d+\\.(\\d+\\.)?)?\\*$/', $result[0]))
! { $list[] = $result[0]; }
! }
!
! return $list;
! }
!
! // Block an address range.
! function rateBlockAdd($db, $address)
! {
! global $RtTbl;
!
! if(!preg_match('/^\\d+\\.(\\d+\\.(\\d+\\.)?)?\\*$/', $address))
! { return; }
! $qid = $db->query("SELECT * FROM $RtTbl WHERE ip='$address'");
! if($db->result($qid))
! { return; }
! $db->query("INSERT INTO $RtTbl(ip) VALUES('$address')");
! }
!
! function rateBlockRemove($db, $address)
! {
! global $RtTbl;
!
! $db->query("DELETE FROM $RtTbl WHERE ip='$address'");
! }
! ?>
Index: url.php
===================================================================
RCS file: /cvsroot/phpgroupware/wiki/lib/url.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** url.php 3 Mar 2003 13:00:39 -0000 1.1.1.1
--- url.php 3 Mar 2003 13:37:05 -0000 1.2
***************
*** 11,23 ****
{ $ViewBase = $ScriptBase . '?page='; }
if(!isset($EditBase))
! { $EditBase = $ScriptBase . '?action=edit&page='; }
if(!isset($HistoryBase))
! { $HistoryBase = $ScriptBase . '?action=history&page='; }
if(!isset($FindScript))
{ $FindScript = $ScriptBase . '?action=find'; }
if(!isset($FindBase))
! { $FindBase = $FindScript . '&find='; }
if(!isset($SaveBase))
! { $SaveBase = $ScriptBase . '?action=save&page='; }
if(!isset($DiffScript))
{ $DiffScript = $ScriptBase . '?action=diff'; }
--- 11,23 ----
{ $ViewBase = $ScriptBase . '?page='; }
if(!isset($EditBase))
! { $EditBase = $ScriptBase . '?action=edit&page='; }
if(!isset($HistoryBase))
! { $HistoryBase = $ScriptBase . '?action=history&page='; }
if(!isset($FindScript))
{ $FindScript = $ScriptBase . '?action=find'; }
if(!isset($FindBase))
! { $FindBase = $FindScript . '&find='; }
if(!isset($SaveBase))
! { $SaveBase = $ScriptBase . '?action=save&page='; }
if(!isset($DiffScript))
{ $DiffScript = $ScriptBase . '?action=diff'; }
***************
*** 34,39 ****
return $ViewBase . urlencode($page) .
! ($version == '' ? '' : "&version=$version") .
! ($full == '' ? '' : '&full=1');
}
}
--- 34,39 ----
return $ViewBase . urlencode($page) .
! ($version == '' ? '' : "&version=$version") .
! ($full == '' ? '' : '&full=1');
}
}
***************
*** 46,50 ****
return $EditBase . urlencode($page) .
! ($version == '' ? '' : "&version=$version");
}
}
--- 46,50 ----
return $EditBase . urlencode($page) .
! ($version == '' ? '' : "&version=$version");
}
}
***************
*** 57,61 ****
return $HistoryBase . urlencode($page) .
! ($full == '' ? '' : '&full=1');
}
}
--- 57,61 ----
return $HistoryBase . urlencode($page) .
! ($full == '' ? '' : '&full=1');
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: wiki/lib category.php,1.1.1.1,1.2 db.php,1.1.1.1,1.2 defaults.php,1.1.1.1,1.2 diff.php,1.1.1.1,1.2 headers.php,1.1.1.1,1.2 init.php,1.1.1.1,1.2 main.php,1.1.1.1,1.2 messages.php,1.1.1.1,1.2 page.php,1.1.1.1,1.2 pagestore.php,1.1.1.1,1.2 rate.php,1.1.1.1,1.2 url.php,1.1.1.1,1.2,
Ralf Becker <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: wiki/template admin.php,1.1.1.1,1.2 common.php,1.1.1.1,1.2 conflict.php,1.1.1.1,1.2 diff.php,1.1.1.1,1.2 edit.php,1.1.1.1,1.2 find.php,1.1.1.1,1.2 history.php,1.1.1.1,1.2 prefs.php,1.1.1.1,1.2 preview.php,1.1.1.1,1.2 rss.php,1.1.1.1,1.2 save.php,1.1.1.1,1.2 view.php,1.1.1.1,1.2 wiki.css,1.1.1.1,1.2
- Next by Date:
[Phpgroupware-cvs] CVS: wiki/parse html.php,1.1.1.1,1.2 macros.php,1.1.1.1,1.2 main.php,1.1.1.1,1.2 save.php,1.1.1.1,1.2transforms.php,1.1.1.1,1.2
- Previous by thread:
[Phpgroupware-cvs] CVS: wiki/template admin.php,1.1.1.1,1.2 common.php,1.1.1.1,1.2 conflict.php,1.1.1.1,1.2 diff.php,1.1.1.1,1.2 edit.php,1.1.1.1,1.2 find.php,1.1.1.1,1.2 history.php,1.1.1.1,1.2 prefs.php,1.1.1.1,1.2 preview.php,1.1.1.1,1.2 rss.php,1.1.1.1,1.2 save.php,1.1.1.1,1.2 view.php,1.1.1.1,1.2 wiki.css,1.1.1.1,1.2
- Next by thread:
[Phpgroupware-cvs] CVS: wiki/parse html.php,1.1.1.1,1.2 macros.php,1.1.1.1,1.2 main.php,1.1.1.1,1.2 save.php,1.1.1.1,1.2transforms.php,1.1.1.1,1.2
- Index(es):