From 795fa8d7701753ae7b9d6d8175e99600a768ed57 Mon Sep 17 00:00:00 2001 From: wainstead Date: Mon, 26 Jun 2000 03:55:27 +0000 Subject: [PATCH] This is in a completely transitional state, and should not be used in a production setting under penalty of death. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@108 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- wiki_msql.php3 | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/wiki_msql.php3 b/wiki_msql.php3 index 7dbf128f1..7a64c9495 100644 --- a/wiki_msql.php3 +++ b/wiki_msql.php3 @@ -1,4 +1,4 @@ - + \n"; return $dbi; } @@ -55,6 +54,8 @@ $pagehash["pagename"] = addslashes($pagename); if (!isset($pagehash["flags"])) $pagehash["flags"] = 0; + if (!isset($pagehash["content"])) + $pagehash["content"] = array(); $pagehash["author"] = addslashes($pagehash["author"]); $pagehash["refs"] = serialize($pagehash["refs"]); @@ -67,9 +68,6 @@ { // unserialize/explode content $dbhash['refs'] = unserialize($dbhash['refs']); - - // retrieve page lines from other table -// $dbhash['content'] = explode("\n", $dbhash['content']); return $dbhash; } @@ -77,12 +75,16 @@ // Return hash of page + attributes or default function RetrievePage($dbi, $pagename) { $pagename = addslashes($pagename); + $query = "select * from $dbi[table] where pagename='$pagename'"; + if ($res = msql_query($query, $dbi['dbc'])) { $dbhash = msql_fetch_array($res); + $query = "select lineno,line from $dbi[page_table] " . "where pagename='$pagename' " . "order by lineno"; + if ($res = msql_query($query, $dbi[dbc])) { $dbhash["content"] = array(); while ($row = msql_fetch_array($res)) { @@ -140,10 +142,11 @@ if ($retval == false) echo "Insert/update failed: ", msql_error(), "
\n"; + // second, insert the page data // remove old data from page_table $query = "delete from $dbi[page_table] where pagename='$pagename'"; - //echo "Delete query: $query
\n"; + echo "Delete query: $query
\n"; $retval = msql_query($query, $dbi['dbc']); if ($retval == false) echo "Delete on $dbi[page_table] failed: ", msql_error(), "
\n"; @@ -151,17 +154,40 @@ // insert the new lines reset($pagehash["content"]); + $tmparray = array(); + $y = 0; + for ($x = 0; $x < count($pagehash["content"]); $x++) { - $line = addslashes($pagehash["content"][$x]); + + // manage line length here, lines should not exceed the + // length MSQL_MAX_LINE_LENGTH or something + + if (strlen($pagehash["content"][$x]) > MSQL_MAX_LINE_LENGTH) { + $length = strlen($pagehash["content"][$x]); + echo "Must break up line ($length): " . $pagehash["content"][$x] ."
\n"; + // can I cheat and use preg_split to break the line up? + // match this line with: /(.{1,127})+/ + // in fact, split it on a zero-width metachar every 127th position + // take the returned array and add elements to $tmparray + } else { + $tmparray[$y] = $pagehash["content"][$x]; + $y++; + } + } + + reset($tmparray); + for ($x = 0; $x < count($tmparray); $x ++) { + $line = addslashes($tmparray[$x]); $query = "INSERT INTO $dbi[page_table] " . "(pagename, lineno, line) " . "VALUES('$pagename', $x, '$line')"; - //echo "Page line insert query: $query
\n"; + echo "Page line insert query: $query
\n"; $retval = msql_query($query, $dbi['dbc']); if ($retval == false) echo "Insert into $dbi[page_table] failed: ", msql_error(), "
\n";; } + //echo "

inserted $x lines for $pagename

\n"; } -- 2.45.0