'newpage'); $cont = addContinuationsEntry('editdoc', $cdata); print "[ "; print "New page "; print "]
\n"; } if(count($docs)) { print "

Main Documentation

\n"; foreach($docs as $key => $val) { print ""; print "$val
\n"; } } if(in_array($user['id'], $docreaders)) { print "

API Documentation

\n"; print ""; print "XML RPC API
\n"; print ""; print "XML RPC API Example Code
\n"; } } //////////////////////////////////////////////////////////////////////////////// /// /// \fn showXmlrpcapi() /// /// \brief prints XML RPC API docs /// //////////////////////////////////////////////////////////////////////////////// function showXmlrpcapi() { $text = file_get_contents(".ht-inc/xmlrpcdocs/xmlrpcWrappers_8php.html"); $text = preg_replace('/xmlrpcWrappers_8php.html/', '', $text); $replace = BASEURL . SCRIPT . "?mode=viewdocs&item=xmlrpcexample"; $text = preg_replace('/xmlrpc__example_8php-example.html/', $replace, $text); $text = preg_replace('~^<\!DOCTYPE.*~s', '', $text); $text = preg_replace('~

/afs.*

~', '', $text); $text = preg_replace('~\n$~', '', $text); print $text; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn showXmlrpcExample() /// /// \brief prints XML RPC API example /// //////////////////////////////////////////////////////////////////////////////// function showXmlrpcExample() { $text = file_get_contents(".ht-inc/xmlrpcdocs/xmlrpc__example_8php-example.html"); $replace = BASEURL . SCRIPT . "?mode=viewdocs&item=xmlrpcapi"; $text = preg_replace('/xmlrpcWrappers_8php.html/', $replace, $text); $text = preg_replace('~^<\!DOCTYPE.*~s', '', $text); $text = preg_replace('~

xmlrpc_example\.php

~', '', $text); $text = preg_replace('~\n$~', '', $text); print $text; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn showDatabaseDoc($item) /// /// \param $item - name of a documentation item /// /// \brief prints out documentation for $item /// //////////////////////////////////////////////////////////////////////////////// function showDatabaseDoc($item) { global $viewmode, $user; $query = "SELECT title, data FROM documentation WHERE name = '$item'"; $qh = doQuery($query, 101); if(! ($row = mysql_fetch_assoc($qh))) { print "

Online Documentation

\n"; print "Failed to retrieve documentation for \"$item\".
\n"; return; } if($viewmode == ADMIN_DEVELOPER || in_array($user['id'], $doceditors)) { $cdata = array('item' => $item, 'submode' => 'newpage'); $cont = addContinuationsEntry('editdoc', $cdata); print "[ "; print "New page "; $cdata = array('item' => $item, 'submode' => 'editpage'); $cont = addContinuationsEntry('editdoc', $cdata); print "| "; print "Edit page "; $cdata = array('item' => $item); $cont = addContinuationsEntry('confirmdeletedoc', $cdata); print "| "; print "Delete page "; print "]
\n"; } print "
\n"; print "

{$row['title']}

\n"; print $row['data']; print "Online Documentation\n"; print "Failed to retrieve documentation for \"$item\".
\n"; return; } $newedit = 'edit'; } else { $row['title'] = ""; $row['data'] = ""; $newedit = 'new'; } print "
\n"; print "

\n"; print "Title:"; if($submode == 'titleerror') { print "Title cannot be empty"; } print "
\n"; $edit = new FCKeditor('data'); $edit->BasePath = BASEURL . '/fckeditor/'; $edit->Value = $row['data']; $edit->Height = '600'; $edit->ToolbarSet = 'VCLDocs'; $edit->Create(); $cdata = array('item' => $item, 'newedit' => $newedit); $cont = addContinuationsEntry('confirmeditdoc', $cdata); print "\n"; print "\n"; print "
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn confirmEditDoc() /// /// \brief prints a page asking the user to confirm the changes to the page; /// includes a link to go back and edit further /// //////////////////////////////////////////////////////////////////////////////// function confirmEditDoc() { global $viewmode, $mysql_link_vcl, $contdata; $item = getContinuationVar('item'); $newedit = getContinuationVar('newedit'); if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) { showDatabaseDoc($item); return; } $title = processInputVar('title', ARG_STRING); if(get_magic_quotes_gpc()) { $data = stripslashes($_POST['data']); $submitdata = rawurlencode(mysql_real_escape_string($data, $mysql_link_vcl)); } else { $submitdata = rawurlencode(mysql_real_escape_string($_POST['data'], $mysql_link_vcl)); $data = $_POST['data']; } if(empty($title)) { $contdata['title'] = ""; $contdata['data'] = rawurlencode($data); $contdata['submode'] = 'titleerror'; editDoc(); return; } $cdata = array('item' => $item, 'title' => $title, 'data' => $submitdata, 'newedit' => $newedit); $cont = addContinuationsEntry('submiteditdoc', $cdata, SECINDAY, 0, 0); print "[ "; print "Save Changes "; $cdata['data'] = rawurlencode($data); $cdata['submode'] = 'editfurther'; $cont = addContinuationsEntry('editdoc', $cdata, SECINDAY, 0, 0); print "| "; print "Edit Further ]
\n"; print "

$title

\n"; print $data; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitEditDoc() /// /// \brief saves submitted changes to a documentation item /// //////////////////////////////////////////////////////////////////////////////// function submitEditDoc() { global $viewmode, $mysql_link_vcl; $item = getContinuationVar('item'); $newedit = getContinuationVar('newedit'); if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) { showDatabaseDoc($item); return; } $title = getContinuationVar('title'); $data = rawurldecode(getContinuationVar('data')); $name = preg_replace('/[^-A-Za-z0-9_]/', '', $title); $query = "SELECT name FROM documentation WHERE name = '$name'"; $qh = doQuery($query, 101); $count = 1; $basename = $name; while(mysql_num_rows($qh)) { $name = $basename . $count; $count++; $query = "SELECT name FROM documentation WHERE name = '$name'"; $qh = doQuery($query, 101); } if($newedit == 'edit') { $query = "SELECT name FROM documentation WHERE name = '$item'"; $qh = doQuery($query, 101); if(! ($row = mysql_fetch_assoc($qh))) { print "

Online Documentation

\n"; print "Failed to retrieve documentation for \"$item\".
\n"; return; } $query = "UPDATE documentation " . "SET name = '$name', " . "title = '$title', " . "data = '$data' " . "WHERE name = '$item'"; } else { $query = "INSERT INTO documentation " . "(name, " . "title, " . "data) " . "VALUES " . "('$name', " . "'$title', " . "'$data')"; } doQuery($query, 101); if(mysql_affected_rows($mysql_link_vcl)) { print "Page successfully updated.
\n"; } else print "No changes were made to the page.
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn confirmDeleteDoc() /// /// \brief prints a confirmation page about deleting a documentation item /// //////////////////////////////////////////////////////////////////////////////// function confirmDeleteDoc() { global $viewmode; $item = getContinuationVar('item'); if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) { showDatabaseDoc($item); return; } $query = "SELECT title, data FROM documentation WHERE name = '$item'"; $qh = doQuery($query, 101); if(! ($row = mysql_fetch_assoc($qh))) { print "

Online Documentation

\n"; print "Failed to retrieve documentation for \"$item\".
\n"; return; } print "Are you sure you want to delete the following documentation "; print "page?
\n"; print "Note: the document will be unrecoverable"; print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; $cdata = array('item' => $item); $cont = addContinuationsEntry('submitdeletedoc', $cdata, SECINDAY, 0, 0); print "\n"; print "\n"; print "
\n"; print "
\n"; print "
\n"; $cont = addContinuationsEntry('viewdocs', $cdata); print "\n"; print "\n"; print "
\n"; print "
\n"; print "

{$row['title']}

\n"; print $row['data']; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitDeleteDoc() /// /// \brief deletes a documentation item /// //////////////////////////////////////////////////////////////////////////////// function submitDeleteDoc() { global $viewmode; $item = getContinuationVar('item'); if($viewmode != ADMIN_DEVELOPER && ! in_array($user['id'], $doceditors)) { showDatabaseDoc($item); return; } $query = "SELECT title FROM documentation WHERE name = '$item'"; $qh = doQuery($query, 101); if(! ($row = mysql_fetch_assoc($qh))) { print "

Online Documentation

\n"; print "Failed to retrieve documentation for \"$item\".
\n"; return; } $query = "DELETE FROM documentation WHERE name = '$item'"; doQuery($query, 101); print "The page titled {$row['title']} has been deleted."; print "
\n"; } ?>