Poll stuff.

pull/193/head
Michael R Sweet 21 years ago
parent f367d28d41
commit cf3827d52a
  1. 72
      doc/basics.html
  2. 281
      doc/mxml.html
  3. BIN
      doc/mxml.pdf
  4. 91
      www/data/mxml.sql
  5. BIN
      www/images/graph.gif
  6. 31
      www/index.php
  7. 6
      www/phplib/common.php
  8. 5
      www/phplib/globals.php
  9. 39
      www/phplib/html.php
  10. 114
      www/phplib/poll.php
  11. 388
      www/poll.php

@ -36,22 +36,22 @@ for your installation:</p>
<p>Every piece of information in an XML file (elements, text, <p>Every piece of information in an XML file (elements, text,
numbers) is stored in memory in "nodes". Nodes are defined by numbers) is stored in memory in "nodes". Nodes are defined by
the <a the <a
href='reference.html#mxml_node_t'><tt>mxml_node_t</tt></a> href='#mxml_node_t'><tt>mxml_node_t</tt></a>
structure. The <a structure. The <a
href='reference.html#mxml_type_t'><tt>type</tt></a> member href='#mxml_type_t'><tt>type</tt></a> member
defines the node type (element, integer, opaque, real, or text) defines the node type (element, integer, opaque, real, or text)
which determines which value you want to look at in the <a which determines which value you want to look at in the <a
href='reference.html#mxml_value_t'><tt>value</tt></a> union.</p> href='#mxml_value_t'><tt>value</tt></a> union.</p>
<p>New nodes can be created using the <a <p>New nodes can be created using the <a
href='reference.html#mxmlNewElement'><tt>mxmlNewElement()</tt></a>, href='#mxmlNewElement'><tt>mxmlNewElement()</tt></a>,
<a <a
href='reference.html#mxmlNewInteger'><tt>mxmlNewInteger()</tt></a>, href='#mxmlNewInteger'><tt>mxmlNewInteger()</tt></a>,
<a <a
href='reference.html#mxmlNewOpaque'><tt>mxmlNewOpaque()</tt></a>, href='#mxmlNewOpaque'><tt>mxmlNewOpaque()</tt></a>,
<a href='reference.html#mxmlNewReal'><tt>mxmlNewReal()</tt></a>, <a href='#mxmlNewReal'><tt>mxmlNewReal()</tt></a>,
and <a and <a
href='reference.html#mxmlNewText'><tt>mxmlNewText()</tt></a> href='#mxmlNewText'><tt>mxmlNewText()</tt></a>
functions. Only elements can have child nodes, and the top node functions. Only elements can have child nodes, and the top node
must be an element, usually "?xml".</p> must be an element, usually "?xml".</p>
@ -98,7 +98,7 @@ like the following in memory:</p>
to the first child node.</p> to the first child node.</p>
<p>Once you are done with the XML data, use the <a <p>Once you are done with the XML data, use the <a
href='reference.html#mxmlDelete'><tt>mxmlDelete()</tt></a> href='#mxmlDelete'><tt>mxmlDelete()</tt></a>
function to recursively free the memory that is used for a function to recursively free the memory that is used for a
particular node or the entire tree:</p> particular node or the entire tree:</p>
@ -109,15 +109,15 @@ particular node or the entire tree:</p>
<h2>Loading and Saving XML Files</h2> <h2>Loading and Saving XML Files</h2>
<p>You load an XML file using the <a <p>You load an XML file using the <a
href='reference.html#mxmlLoadFile'><tt>mxmlLoadFile()</tt></a> href='#mxmlLoadFile'><tt>mxmlLoadFile()</tt></a>
function:</p> function:</p>
<pre> <pre>
FILE *fp; FILE *fp;
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *tree; <a href='#mxml_node_t'>mxml_node_t</a> *tree;
fp = fopen("filename.xml", "r"); fp = fopen("filename.xml", "r");
tree = <a href='reference.html#mxmlLoadFile'>mxmlLoadFile</a>(NULL, fp, MXML_NO_CALLBACK); tree = <a href='#mxmlLoadFile'>mxmlLoadFile</a>(NULL, fp, MXML_NO_CALLBACK);
fclose(fp); fclose(fp);
</pre> </pre>
@ -131,15 +131,15 @@ attribute values to determine the proper value type to return.
The default value type is MXML_TEXT if no callback is used.</p> The default value type is MXML_TEXT if no callback is used.</p>
<p>Similarly, you save an XML file using the <a <p>Similarly, you save an XML file using the <a
href='reference.html#mxmlSaveFile'><tt>mxmlSaveFile()</tt></a> href='#mxmlSaveFile'><tt>mxmlSaveFile()</tt></a>
function:</p> function:</p>
<pre> <pre>
FILE *fp; FILE *fp;
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *tree; <a href='#mxml_node_t'>mxml_node_t</a> *tree;
fp = fopen("filename.xml", "w"); fp = fopen("filename.xml", "w");
<a href='reference.html#mxmlSaveFile'>mxmlSaveFile</a>(tree, fp, MXML_NO_CALLBACK); <a href='#mxmlSaveFile'>mxmlSaveFile</a>(tree, fp, MXML_NO_CALLBACK);
fclose(fp); fclose(fp);
</pre> </pre>
@ -154,49 +154,49 @@ whitespace should be added and the string to insert (spaces,
tabs, carriage returns, and newlines) otherwise.</p> tabs, carriage returns, and newlines) otherwise.</p>
<p>The <a <p>The <a
href='reference.html#mxmlLoadString'><tt>mxmlLoadString()</tt></a>, href='#mxmlLoadString'><tt>mxmlLoadString()</tt></a>,
<a <a
href='reference.html#mxmlSaveAllocString'><tt>mxmlSaveAllocString()</tt></a>, href='#mxmlSaveAllocString'><tt>mxmlSaveAllocString()</tt></a>,
and <a and <a
href='reference.html#mxmlSaveString'><tt>mxmlSaveString()</tt></a> href='#mxmlSaveString'><tt>mxmlSaveString()</tt></a>
functions load XML node trees from and save XML node trees to functions load XML node trees from and save XML node trees to
strings:</p> strings:</p>
<pre> <pre>
char buffer[8192]; char buffer[8192];
char *ptr; char *ptr;
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *tree; <a href='#mxml_node_t'>mxml_node_t</a> *tree;
... ...
tree = <a href='reference.html#mxmlLoadString'>mxmlLoadString</a>(NULL, buffer, MXML_NO_CALLBACK); tree = <a href='#mxmlLoadString'>mxmlLoadString</a>(NULL, buffer, MXML_NO_CALLBACK);
... ...
<a href='reference.html#mxmlSaveString'>mxmlSaveString</a>(tree, buffer, sizeof(buffer), MXML_NO_CALLBACK); <a href='#mxmlSaveString'>mxmlSaveString</a>(tree, buffer, sizeof(buffer), MXML_NO_CALLBACK);
... ...
ptr = <a href='reference.html#mxmlSaveAllocString'>mxmlSaveAllocString</a>(tree, MXML_NO_CALLBACK); ptr = <a href='#mxmlSaveAllocString'>mxmlSaveAllocString</a>(tree, MXML_NO_CALLBACK);
</pre> </pre>
<h3>Finding and Iterating Nodes</h3> <h3>Finding and Iterating Nodes</h3>
<p>The <a <p>The <a
href='reference.html#mxmlWalkPrev'><tt>mxmlWalkPrev()</tt></a> href='#mxmlWalkPrev'><tt>mxmlWalkPrev()</tt></a>
and <a and <a
href='reference.html#mxmlWalkNext'><tt>mxmlWalkNext()</tt></a>functions href='#mxmlWalkNext'><tt>mxmlWalkNext()</tt></a>functions
can be used to iterate through the XML node tree:</p> can be used to iterate through the XML node tree:</p>
<pre> <pre>
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *node = <a href='reference.html#mxmlWalkPrev'>mxmlWalkPrev</a>(current, tree, MXML_DESCEND); <a href='#mxml_node_t'>mxml_node_t</a> *node = <a href='#mxmlWalkPrev'>mxmlWalkPrev</a>(current, tree, MXML_DESCEND);
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *node = <a href='reference.html#mxmlWalkNext'>mxmlWalkNext</a>(current, tree, MXML_DESCEND); <a href='#mxml_node_t'>mxml_node_t</a> *node = <a href='#mxmlWalkNext'>mxmlWalkNext</a>(current, tree, MXML_DESCEND);
</pre> </pre>
<p>In addition, you can find a named element/node using the <a <p>In addition, you can find a named element/node using the <a
href='reference.html#mxmlFindElement'><tt>mxmlFindElement()</tt></a> href='#mxmlFindElement'><tt>mxmlFindElement()</tt></a>
function:</p> function:</p>
<pre> <pre>
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "name", "attr", <a href='#mxml_node_t'>mxml_node_t</a> *node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "name", "attr",
"value", MXML_DESCEND); "value", MXML_DESCEND);
</pre> </pre>
@ -206,30 +206,30 @@ e.g.:</p>
<pre> <pre>
/* Find the first "a" element */ /* Find the first "a" element */
node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "a", NULL, NULL, MXML_DESCEND); node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "a", NULL, NULL, MXML_DESCEND);
/* Find the first "a" element with "href" attribute */ /* Find the first "a" element with "href" attribute */
node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "a", "href", NULL, MXML_DESCEND); node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "a", "href", NULL, MXML_DESCEND);
/* Find the first "a" element with "href" to a URL */ /* Find the first "a" element with "href" to a URL */
node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "a", "href", node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "a", "href",
"http://www.easysw.com/~mike/mxml/", MXML_DESCEND); "http://www.easysw.com/~mike/mxml/", MXML_DESCEND);
/* Find the first element with a "src" attribute*/ /* Find the first element with a "src" attribute*/
node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, NULL, "src", NULL, MXML_DESCEND); node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, NULL, "src", NULL, MXML_DESCEND);
/* Find the first element with a "src" = "foo.jpg" */ /* Find the first element with a "src" = "foo.jpg" */
node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, NULL, "src", "foo.jpg", MXML_DESCEND); node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, NULL, "src", "foo.jpg", MXML_DESCEND);
</pre> </pre>
<p>You can also iterate with the same function:</p> <p>You can also iterate with the same function:</p>
<pre> <pre>
<a href='reference.html#mxml_node_t'>mxml_node_t</a> *node; <a href='#mxml_node_t'>mxml_node_t</a> *node;
for (node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "name", NULL, NULL, MXML_DESCEND); for (node = <a href='#mxmlFindElement'>mxmlFindElement</a>(tree, tree, "name", NULL, NULL, MXML_DESCEND);
node != NULL; node != NULL;
node = <a href='reference.html#mxmlFindElement'>mxmlFindElement</a>(node, tree, "name", NULL, NULL, MXML_DESCEND)) node = <a href='#mxmlFindElement'>mxmlFindElement</a>(node, tree, "name", NULL, NULL, MXML_DESCEND))
{ {
... do something ... ... do something ...
} }

@ -23,7 +23,7 @@ PRE { font-family: monospace }
Michael Sweet<BR> Michael Sweet<BR>
Copyright 2003-2004<BR> Copyright 2003-2004<BR>
</CENTER> </CENTER>
<HR> <HR NOSHADE>
<H1 ALIGN="CENTER"><A NAME="CONTENTS">Table of Contents</A></H1> <H1 ALIGN="CENTER"><A NAME="CONTENTS">Table of Contents</A></H1>
<BR> <BR>
<BR><B><A HREF="#INTRO">Introduction</A></B> <BR><B><A HREF="#INTRO">Introduction</A></B>
@ -101,9 +101,16 @@ Copyright 2003-2004<BR>
<LI><A HREF="#mxmlDelete">mxmlDelete()</A></LI> <LI><A HREF="#mxmlDelete">mxmlDelete()</A></LI>
<LI><A HREF="#mxmlElementGetAttr">mxmlElementGetAttr()</A></LI> <LI><A HREF="#mxmlElementGetAttr">mxmlElementGetAttr()</A></LI>
<LI><A HREF="#mxmlElementSetAttr">mxmlElementSetAttr()</A></LI> <LI><A HREF="#mxmlElementSetAttr">mxmlElementSetAttr()</A></LI>
<LI><A HREF="#mxmlEntityAddCallback">mxmlEntityAddCallback()</A></LI>
<LI><A HREF="#mxmlEntityGetName">mxmlEntityGetName()</A></LI> <LI><A HREF="#mxmlEntityGetName">mxmlEntityGetName()</A></LI>
<LI><A HREF="#mxmlEntityGetValue">mxmlEntityGetValue()</A></LI> <LI><A HREF="#mxmlEntityGetValue">mxmlEntityGetValue()</A></LI>
<LI><A HREF="#mxmlEntityRemoveCallback">mxmlEntityRemoveCallback()</A></LI>
<LI><A HREF="#mxmlFindElement">mxmlFindElement()</A></LI> <LI><A HREF="#mxmlFindElement">mxmlFindElement()</A></LI>
<LI><A HREF="#mxmlIndexDelete">mxmlIndexDelete()</A></LI>
<LI><A HREF="#mxmlIndexEnum">mxmlIndexEnum()</A></LI>
<LI><A HREF="#mxmlIndexFind">mxmlIndexFind()</A></LI>
<LI><A HREF="#mxmlIndexNew">mxmlIndexNew()</A></LI>
<LI><A HREF="#mxmlIndexReset">mxmlIndexReset()</A></LI>
<LI><A HREF="#mxmlLoadFile">mxmlLoadFile()</A></LI> <LI><A HREF="#mxmlLoadFile">mxmlLoadFile()</A></LI>
<LI><A HREF="#mxmlLoadString">mxmlLoadString()</A></LI> <LI><A HREF="#mxmlLoadString">mxmlLoadString()</A></LI>
<LI><A HREF="#mxmlNewElement">mxmlNewElement()</A></LI> <LI><A HREF="#mxmlNewElement">mxmlNewElement()</A></LI>
@ -129,6 +136,7 @@ Copyright 2003-2004<BR>
<LI><A HREF="#_structures">Structures</A></LI> <LI><A HREF="#_structures">Structures</A></LI>
<UL> <UL>
<LI><A HREF="#mxml_attr_s">mxml_attr_s</A></LI> <LI><A HREF="#mxml_attr_s">mxml_attr_s</A></LI>
<LI><A HREF="#mxml_index_s">mxml_index_s</A></LI>
<LI><A HREF="#mxml_node_s">mxml_node_s</A></LI> <LI><A HREF="#mxml_node_s">mxml_node_s</A></LI>
<LI><A HREF="#mxml_text_s">mxml_text_s</A></LI> <LI><A HREF="#mxml_text_s">mxml_text_s</A></LI>
<LI><A HREF="#mxml_value_s">mxml_value_s</A></LI> <LI><A HREF="#mxml_value_s">mxml_value_s</A></LI>
@ -137,6 +145,7 @@ Copyright 2003-2004<BR>
<UL> <UL>
<LI><A HREF="#mxml_attr_t">mxml_attr_t</A></LI> <LI><A HREF="#mxml_attr_t">mxml_attr_t</A></LI>
<LI><A HREF="#mxml_element_t">mxml_element_t</A></LI> <LI><A HREF="#mxml_element_t">mxml_element_t</A></LI>
<LI><A HREF="#mxml_index_t">mxml_index_t</A></LI>
<LI><A HREF="#mxml_node_t">mxml_node_t</A></LI> <LI><A HREF="#mxml_node_t">mxml_node_t</A></LI>
<LI><A HREF="#mxml_text_t">mxml_text_t</A></LI> <LI><A HREF="#mxml_text_t">mxml_text_t</A></LI>
<LI><A HREF="#mxml_type_t">mxml_type_t</A></LI> <LI><A HREF="#mxml_type_t">mxml_type_t</A></LI>
@ -146,8 +155,12 @@ Copyright 2003-2004<BR>
<UL> <UL>
<LI><A HREF="#mxml_value_u">mxml_value_u</A></LI> <LI><A HREF="#mxml_value_u">mxml_value_u</A></LI>
</UL> </UL>
<LI><A HREF="#_variables">Variables</A></LI>
<UL>
<LI><A HREF="#num_callbacks">num_callbacks</A></LI>
</UL>
</UL> </UL>
<HR> <HR NOSHADE>
<H1 align="right"><A name="INTRO">Introduction</A></H1> <H1 align="right"><A name="INTRO">Introduction</A></H1>
<P>This programmers manual describes Mini-XML version 2.0, a small XML <P>This programmers manual describes Mini-XML version 2.0, a small XML
parsing library that you can use to read and write XML and XML-like parsing library that you can use to read and write XML and XML-like
@ -307,7 +320,7 @@ File and directory names.</TD></TR>
<DD>The XML specification from the World Wide Web Consortium (W3C) <DD>The XML specification from the World Wide Web Consortium (W3C)
<BR />&nbsp;</DD> <BR />&nbsp;</DD>
</DL> </DL>
</BLOCKQUOTE><HR> </BLOCKQUOTE><HR NOSHADE>
<H1 align="right"><A name="INSTALL">1 - Building, Installing, and <H1 align="right"><A name="INSTALL">1 - Building, Installing, and
Packaging Mini-XML</A></H1> Packaging Mini-XML</A></H1>
<P>This chapter describes how to build, install, and package Mini-XML on <P>This chapter describes how to build, install, and package Mini-XML on
@ -370,7 +383,7 @@ epm(1)</TT> program to create software packages in a variety of formats.
<P>The native packages will be in the local OS's native format: RPM for <P>The native packages will be in the local OS's native format: RPM for
Red Hat Linux, DPKG for Debian Linux, PKG for Solaris, and so forth. Red Hat Linux, DPKG for Debian Linux, PKG for Solaris, and so forth.
Use the corresponding commands to install the native packages.</P> Use the corresponding commands to install the native packages.</P>
<HR> <HR NOSHADE>
<H1 align="right"><A name="BASICS">2 - Getting Started with Mini-XML</A></H1> <H1 align="right"><A name="BASICS">2 - Getting Started with Mini-XML</A></H1>
<P>This chapter describes how to write programs that use Mini-XML to <P>This chapter describes how to write programs that use Mini-XML to
access data in an XML file.</P> access data in an XML file.</P>
@ -592,7 +605,7 @@ mxmlSaveString()</TT></A> functions load XML node trees from and save
the order would be reversed, ending at &quot;?xml&quot;.</P> the order would be reversed, ending at &quot;?xml&quot;.</P>
</LI> </LI>
</UL> </UL>
<HR> <HR NOSHADE>
<H1 align="right"><A name="ADVANCED">3 - More Mini-XML Programming <H1 align="right"><A name="ADVANCED">3 - More Mini-XML Programming
Techniques</A></H1> Techniques</A></H1>
<P>This chapter shows additional ways to use the Mini-XML library in <P>This chapter shows additional ways to use the Mini-XML library in
@ -602,7 +615,7 @@ mxmlSaveString()</TT></A> functions load XML node trees from and save
<H2><A NAME="4_3">Changing Node Values</A></H2> <H2><A NAME="4_3">Changing Node Values</A></H2>
<H2><A NAME="4_4">Formatted Text</A></H2> <H2><A NAME="4_4">Formatted Text</A></H2>
<H2><A NAME="4_5">Indexing</A></H2> <H2><A NAME="4_5">Indexing</A></H2>
<HR> <HR NOSHADE>
<H1 align="right"><A name="MXMLDOC">4 - Using the mxmldoc Utility</A></H1> <H1 align="right"><A name="MXMLDOC">4 - Using the mxmldoc Utility</A></H1>
<P>This chapter describes how to use the <TT>mxmldoc(1)</TT> utility <P>This chapter describes how to use the <TT>mxmldoc(1)</TT> utility
that comes with Mini-XML to automatically generate documentation for that comes with Mini-XML to automatically generate documentation for
@ -957,7 +970,7 @@ align="bottom"><I> Listing 4-1, XML Schema File &quot;mxmldoc.xsd&quot; (con't)<
</TD></TR> </TD></TR>
</TABLE> </TABLE>
</CENTER> </CENTER>
<HR> <HR NOSHADE>
<H1 align="right"><A name="LICENSE">A - GNU Library General Public <H1 align="right"><A name="LICENSE">A - GNU Library General Public
License</A></H1> License</A></H1>
<P align="center">Version 2, June 1991 <P align="center">Version 2, June 1991
@ -1333,11 +1346,22 @@ align="bottom"><I> Listing 4-1, XML Schema File &quot;mxmldoc.xsd&quot; (con't)<
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.</P> DAMAGES.</P>
<P align="center"><BIG>END OF TERMS AND CONDITIONS</BIG></P> <P align="center"><BIG>END OF TERMS AND CONDITIONS</BIG></P>
<HR> <HR NOSHADE>
<H1 align="right"><A name="RELNOTES">B - Release Notes</A></H1> <H1 align="right"><A name="RELNOTES">B - Release Notes</A></H1>
<H2><A NAME="7_1">Changes in Mini-XML 2.0</A></H2> <H2><A NAME="7_1">Changes in Mini-XML 2.0</A></H2>
<UL> <UL>
<LI>New programmers manual.</LI> <LI>New programmers manual.</LI>
<LI>Added UTF-16 support (input only; all output is UTF-8)</LI>
<LI>Added index functions to build a searchable index of XML nodes.</LI>
<LI>Added character entity callback interface to support additional
character entities beyond those defined in the XHTML specification.</LI>
<LI>Added support for XHTML character entities.</LI>
<LI>The mxmldoc utility now produces XML output which conforms to an
updated XML schema, described in the file &quot;doc/mxmldoc.xsd&quot;.</LI>
<LI>Changed the whitespace callback interface to return strings instead
of a single character, allowing for greater control over the formatting
of XML files written using Mini-XML. THIS CHANGE WILL REQUIRE CHANGES
TO YOUR 1.x CODE IF YOU USE WHITESPACE CALLBACKS.</LI>
<LI>The mxmldoc utility now produces XML output which conforms to an <LI>The mxmldoc utility now produces XML output which conforms to an
updated XML schema, described in the file &quot;doc/mxmldoc.xsd&quot;.</LI> updated XML schema, described in the file &quot;doc/mxmldoc.xsd&quot;.</LI>
<LI>Changed the whitespace callback interface to return strings instead <LI>Changed the whitespace callback interface to return strings instead
@ -1456,7 +1480,7 @@ align="bottom"><I> Listing 4-1, XML Schema File &quot;mxmldoc.xsd&quot; (con't)<
<UL> <UL>
<LI>Initial public release.</LI> <LI>Initial public release.</LI>
</UL> </UL>
<HR> <HR NOSHADE>
<H1 align="right"><A name="REFERENCE">C - Library Reference</A></H1> <H1 align="right"><A name="REFERENCE">C - Library Reference</A></H1>
<H2><A NAME="8_1">Contents</A></H2> <H2><A NAME="8_1">Contents</A></H2>
<UL> <UL>
@ -1465,6 +1489,7 @@ align="bottom"><I> Listing 4-1, XML Schema File &quot;mxmldoc.xsd&quot; (con't)<
<LI><A href="#_structures">Structures</A></LI> <LI><A href="#_structures">Structures</A></LI>
<LI><A href="#_types">Types</A></LI> <LI><A href="#_types">Types</A></LI>
<LI><A href="#_unions">Unions</A></LI> <LI><A href="#_unions">Unions</A></LI>
<LI><A href="#_variables">Variables</A></LI>
</UL> </UL>
<!-- NEW PAGE --> <!-- NEW PAGE -->
@ -1498,9 +1523,18 @@ align="bottom"><I> Listing 4-1, XML Schema File &quot;mxmldoc.xsd&quot; (con't)<
<LI><A href="#mxmlDelete"><TT>mxmlDelete()</TT></A></LI> <LI><A href="#mxmlDelete"><TT>mxmlDelete()</TT></A></LI>
<LI><A href="#mxmlElementGetAttr"><TT>mxmlElementGetAttr()</TT></A></LI> <LI><A href="#mxmlElementGetAttr"><TT>mxmlElementGetAttr()</TT></A></LI>
<LI><A href="#mxmlElementSetAttr"><TT>mxmlElementSetAttr()</TT></A></LI> <LI><A href="#mxmlElementSetAttr"><TT>mxmlElementSetAttr()</TT></A></LI>
<LI><A href="#mxmlEntityAddCallback"><TT>mxmlEntityAddCallback()</TT></A>
</LI>
<LI><A href="#mxmlEntityGetName"><TT>mxmlEntityGetName()</TT></A></LI> <LI><A href="#mxmlEntityGetName"><TT>mxmlEntityGetName()</TT></A></LI>
<LI><A href="#mxmlEntityGetValue"><TT>mxmlEntityGetValue()</TT></A></LI> <LI><A href="#mxmlEntityGetValue"><TT>mxmlEntityGetValue()</TT></A></LI>
<LI><A href="#mxmlEntityRemoveCallback"><TT>mxmlEntityRemoveCallback()</TT>
</A></LI>
<LI><A href="#mxmlFindElement"><TT>mxmlFindElement()</TT></A></LI> <LI><A href="#mxmlFindElement"><TT>mxmlFindElement()</TT></A></LI>
<LI><A href="#mxmlIndexDelete"><TT>mxmlIndexDelete()</TT></A></LI>
<LI><A href="#mxmlIndexEnum"><TT>mxmlIndexEnum()</TT></A></LI>
<LI><A href="#mxmlIndexFind"><TT>mxmlIndexFind()</TT></A></LI>
<LI><A href="#mxmlIndexNew"><TT>mxmlIndexNew()</TT></A></LI>
<LI><A href="#mxmlIndexReset"><TT>mxmlIndexReset()</TT></A></LI>
<LI><A href="#mxmlLoadFile"><TT>mxmlLoadFile()</TT></A></LI> <LI><A href="#mxmlLoadFile"><TT>mxmlLoadFile()</TT></A></LI>
<LI><A href="#mxmlLoadString"><TT>mxmlLoadString()</TT></A></LI> <LI><A href="#mxmlLoadString"><TT>mxmlLoadString()</TT></A></LI>
<LI><A href="#mxmlNewElement"><TT>mxmlNewElement()</TT></A></LI> <LI><A href="#mxmlNewElement"><TT>mxmlNewElement()</TT></A></LI>
@ -1638,6 +1672,29 @@ mxmlElementSetAttr(
<H4>Returns</H4> <H4>Returns</H4>
<P>Nothing.</P> <P>Nothing.</P>
<!-- NEW PAGE -->
<H3><A name="mxmlEntityAddCallback">mxmlEntityAddCallback()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Add a callback to convert entities to Unicode.</P>
<H4>Syntax</H4>
<PRE>
void
mxmlEntityAddCallback(
int (*cb)(const char *name));
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>(*cb)(const char *name)</TT></TD><TD>Callback function to
add</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>Nothing.</P>
<!-- NEW PAGE --> <!-- NEW PAGE -->
<H3><A name="mxmlEntityGetName">mxmlEntityGetName()</A></H3> <H3><A name="mxmlEntityGetName">mxmlEntityGetName()</A></H3>
<HR noshade/> <HR noshade/>
@ -1685,6 +1742,29 @@ mxmlEntityGetValue(
<H4>Returns</H4> <H4>Returns</H4>
<P>Character value or -1 on error</P> <P>Character value or -1 on error</P>
<!-- NEW PAGE -->
<H3><A name="mxmlEntityRemoveCallback">mxmlEntityRemoveCallback()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Remove a callback.</P>
<H4>Syntax</H4>
<PRE>
void
mxmlEntityRemoveCallback(
int (*cb)(const char *name));
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>(*cb)(const char *name)</TT></TD><TD>Callback function to
remove</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>Nothing.</P>
<!-- NEW PAGE --> <!-- NEW PAGE -->
<H3><A name="mxmlFindElement">mxmlFindElement()</A></H3> <H3><A name="mxmlFindElement">mxmlFindElement()</A></H3>
<HR noshade/> <HR noshade/>
@ -1726,6 +1806,134 @@ mxmlFindElement(
<H4>Returns</H4> <H4>Returns</H4>
<P>Element node or NULL</P> <P>Element node or NULL</P>
<!-- NEW PAGE -->
<H3><A name="mxmlIndexDelete">mxmlIndexDelete()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Delete an index.</P>
<H4>Syntax</H4>
<PRE>
void
mxmlIndexDelete(
<A href="#mxml_index_t">mxml_index_t</A> * ind);
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>ind</TT></TD><TD>Index to delete</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>Nothing.</P>
<!-- NEW PAGE -->
<H3><A name="mxmlIndexEnum">mxmlIndexEnum()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Return the next node in the index. Nodes are returned in the sorted
order of the index.</P>
<H4>Syntax</H4>
<PRE>
<A href="#mxml_node_t">mxml_node_t</A> *
mxmlIndexEnum(
<A href="#mxml_index_t">mxml_index_t</A> * ind);
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>ind</TT></TD><TD>Index to enumerate</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>Next node or NULL if there is none</P>
<!-- NEW PAGE -->
<H3><A name="mxmlIndexFind">mxmlIndexFind()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Find the next matching node. You should call mxmlIndexReset() prior
to using this function for the first time with a particular set of
&quot;element&quot; and &quot;value&quot; strings. Passing NULL for both &quot;element&quot; and
&quot;value&quot; is equivalent to calling mxmlIndexEnum().</P>
<H4>Syntax</H4>
<PRE>
<A href="#mxml_node_t">mxml_node_t</A> *
mxmlIndexFind(
<A href="#mxml_index_t">mxml_index_t</A> * ind,
const char * element,
const char * value);
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>ind</TT></TD><TD>Index to search</TD></TR>
<TR><TD><TT>element</TT></TD><TD>Element name to find, if any</TD></TR>
<TR><TD><TT>value</TT></TD><TD>Attribute value, if any</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>Node or NULL if none found</P>
<!-- NEW PAGE -->
<H3><A name="mxmlIndexNew">mxmlIndexNew()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Create a new index. The index will contain all nodes that contain the
named element and/or attribute. If both &quot;element&quot; and &quot;attr&quot; are NULL,
then the index will contain a sorted list of the elements in the node
tree. Nodes are sorted by element name and optionally by attribute
value if the &quot;attr&quot; argument is not NULL.</P>
<H4>Syntax</H4>
<PRE>
<A href="#mxml_index_t">mxml_index_t</A> *
mxmlIndexNew(
<A href="#mxml_node_t">mxml_node_t</A> * node,
const char * element,
const char * attr);
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>node</TT></TD><TD>XML node tree</TD></TR>
<TR><TD><TT>element</TT></TD><TD>Element to index or NULL for all</TD></TR>
<TR><TD><TT>attr</TT></TD><TD>Attribute to index or NULL for none</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>New index</P>
<!-- NEW PAGE -->
<H3><A name="mxmlIndexReset">mxmlIndexReset()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Reset the enumeration/find pointer in the index and return the first
node in the index. This function should be called prior to using
mxmlIndexEnum() or mxmlIndexFind() for the first time.</P>
<H4>Syntax</H4>
<PRE>
<A href="#mxml_node_t">mxml_node_t</A> *
mxmlIndexReset(
<A href="#mxml_index_t">mxml_index_t</A> * ind);
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>ind</TT></TD><TD>Index to reset</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>First node or NULL if there is none</P>
<!-- NEW PAGE --> <!-- NEW PAGE -->
<H3><A name="mxmlLoadFile">mxmlLoadFile()</A></H3> <H3><A name="mxmlLoadFile">mxmlLoadFile()</A></H3>
<HR noshade/> <HR noshade/>
@ -2327,6 +2535,7 @@ mxmlWalkPrev(
<H2><A name="_structures">Structures</A></H2> <H2><A name="_structures">Structures</A></H2>
<UL> <UL>
<LI><A href="#mxml_attr_s"><TT>mxml_attr_s</TT></A></LI> <LI><A href="#mxml_attr_s"><TT>mxml_attr_s</TT></A></LI>
<LI><A href="#mxml_index_s"><TT>mxml_index_s</TT></A></LI>
<LI><A href="#mxml_node_s"><TT>mxml_node_s</TT></A></LI> <LI><A href="#mxml_node_s"><TT>mxml_node_s</TT></A></LI>
<LI><A href="#mxml_text_s"><TT>mxml_text_s</TT></A></LI> <LI><A href="#mxml_text_s"><TT>mxml_text_s</TT></A></LI>
<LI><A href="#mxml_value_s"><TT>mxml_value_s</TT></A></LI> <LI><A href="#mxml_value_s"><TT>mxml_value_s</TT></A></LI>
@ -2355,6 +2564,35 @@ struct mxml_attr_s
<TR><TD><TT>value</TT></TD><TD>Attribute value</TD></TR> <TR><TD><TT>value</TT></TD><TD>Attribute value</TD></TR>
</TABLE> </TABLE>
<!-- NEW PAGE -->
<H3><A name="mxml_index_s">mxml_index_s</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>An XML node index.</P>
<H4>Definition</H4>
<PRE>
struct mxml_index_s
{
int alloc_nodes;
char * attr;
int cur_node;
<A href="#mxml_node_t">mxml_node_t</A> ** nodes;
int num_nodes;
};
</PRE>
<H4>Members</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>alloc_nodes</TT></TD><TD>Allocated nodes in index</TD></TR>
<TR><TD><TT>attr</TT></TD><TD>Attribute used for indexing or NULL</TD></TR>
<TR><TD><TT>cur_node</TT></TD><TD>Current node</TD></TR>
<TR><TD><TT>nodes</TT></TD><TD>Node array</TD></TR>
<TR><TD><TT>num_nodes</TT></TD><TD>Number of nodes in index</TD></TR>
</TABLE>
<!-- NEW PAGE --> <!-- NEW PAGE -->
<H3><A name="mxml_node_s">mxml_node_s</A></H3> <H3><A name="mxml_node_s">mxml_node_s</A></H3>
<HR noshade/> <HR noshade/>
@ -2441,6 +2679,7 @@ struct mxml_value_s
<UL> <UL>
<LI><A href="#mxml_attr_t"><TT>mxml_attr_t</TT></A></LI> <LI><A href="#mxml_attr_t"><TT>mxml_attr_t</TT></A></LI>
<LI><A href="#mxml_element_t"><TT>mxml_element_t</TT></A></LI> <LI><A href="#mxml_element_t"><TT>mxml_element_t</TT></A></LI>
<LI><A href="#mxml_index_t"><TT>mxml_index_t</TT></A></LI>
<LI><A href="#mxml_node_t"><TT>mxml_node_t</TT></A></LI> <LI><A href="#mxml_node_t"><TT>mxml_node_t</TT></A></LI>
<LI><A href="#mxml_text_t"><TT>mxml_text_t</TT></A></LI> <LI><A href="#mxml_text_t"><TT>mxml_text_t</TT></A></LI>
<LI><A href="#mxml_type_t"><TT>mxml_type_t</TT></A></LI> <LI><A href="#mxml_type_t"><TT>mxml_type_t</TT></A></LI>
@ -2467,6 +2706,16 @@ typedef struct <A href="#mxml_attr_s">mxml_attr_s</A> mxml_attr_t;
typedef struct <A href="#mxml_value_s">mxml_value_s</A> mxml_element_t; typedef struct <A href="#mxml_value_s">mxml_value_s</A> mxml_element_t;
</PRE> </PRE>
<!-- NEW PAGE -->
<H3><A name="mxml_index_t">mxml_index_t</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>An XML node index.</P>
<H4>Definition</H4>
<PRE>
typedef struct <A href="#mxml_index_s">mxml_index_s</A> mxml_index_t;
</PRE>
<!-- NEW PAGE --> <!-- NEW PAGE -->
<H3><A name="mxml_node_t">mxml_node_t</A></H3> <H3><A name="mxml_node_t">mxml_node_t</A></H3>
<HR noshade/> <HR noshade/>
@ -2541,5 +2790,19 @@ union mxml_value_u
<TR><TD><TT>real</TT></TD><TD>Real number</TD></TR> <TR><TD><TT>real</TT></TD><TD>Real number</TD></TR>
<TR><TD><TT>text</TT></TD><TD>Text fragment</TD></TR> <TR><TD><TT>text</TT></TD><TD>Text fragment</TD></TR>
</TABLE> </TABLE>
<!-- NEW PAGE -->
<H2><A name="_variables">Variables</A></H2>
<UL>
<LI><A href="#num_callbacks"><TT>num_callbacks</TT></A></LI>
</UL>
<!-- NEW PAGE -->
<H3><A name="num_callbacks">num_callbacks</A></H3>
<HR noshade/>
<H4>Definition</H4>
<PRE>
static int num_callbacks = 1;
</PRE>
</BODY> </BODY>
</HTML> </HTML>

Binary file not shown.

@ -1,5 +1,5 @@
-- --
-- "$Id: mxml.sql,v 1.3 2004/05/17 21:00:42 mike Exp $" -- "$Id: mxml.sql,v 1.4 2004/05/20 03:38:42 mike Exp $"
-- --
-- Database schema for the Mini-XML web pages. -- Database schema for the Mini-XML web pages.
-- --
@ -10,6 +10,7 @@
-- Revision History: -- Revision History:
-- --
-- M. Sweet 05/17/2004 Initial revision. -- M. Sweet 05/17/2004 Initial revision.
-- M. Sweet 05/19/2004 Added link, poll, and vote tables.
-- --
@ -69,6 +70,80 @@ CREATE TABLE comment (
); );
--
-- Table structure for table 'link'
--
-- This table lists links to external applications, web pages, etc.
-- Basically, we end up providing a hierachical, searchable link list,
-- complete with comments from users...
--
CREATE TABLE link (
id INTEGER PRIMARY KEY, -- Link ID number
parent_id INTEGER, -- Parent link ID or 0 for top-level
is_category INTEGER, -- 0 = listing, 1 = category
is_published INTEGER, -- 0 = private, 1 = public
name VARCHAR(255), -- Link name
version VARCHAR(255), -- Current version number string
license VARCHAR(255), -- Current license
author VARCHAR(255), -- Current author
email VARCHAR(255), -- Public email address
homepage_url VARCHAR(255), -- Home page
download_url VARCHAR(255), -- Download page
description TEXT, -- HTML description of link
rating_total INTEGER, -- Total of all ratings
rating_count INTEGER, -- Number of ratings
homepage_visits INTEGER, -- Number of clicks to the home page
download_visits INTEGER, -- Number of clicks to the download page
create_date INTEGER, -- Creation time/date
create_user VARCHAR(255), -- User that created the link
modify_date INTEGER, -- Last time/date changed
modify_user VARCHAR(255) -- User that made the last change
);
--
-- Table structure for table 'poll'
--
-- This table provides a very simple single question, multiple choice poll
-- interface for the main page. Used successfully for a couple years now
-- on the CUPS and FLTK sites, the main twist is the new poll_type field
-- to control whether it is pick-one or pick-many poll.
--
CREATE TABLE poll (
id INTEGER PRIMARY KEY, -- Poll ID number
is_published INTEGER, -- 0 = private, 1 = public
poll_type INTEGER, -- 0 = pick one, 1 = pick many
question VARCHAR(255), -- Question plain text
answer0 VARCHAR(255), -- Answer #1 plain text
count0 INTEGER, -- Number of votes for #1
answer1 VARCHAR(255), -- Answer #2 plain text
count1 INTEGER, -- Number of votes for #2
answer2 VARCHAR(255), -- Answer #3 plain text
count2 INTEGER, -- Number of votes for #3
answer3 VARCHAR(255), -- Answer #4 plain text
count3 INTEGER, -- Number of votes for #4
answer4 VARCHAR(255), -- Answer #5 plain text
count4 INTEGER, -- Number of votes for #5
answer5 VARCHAR(255), -- Answer #6 plain text
count5 INTEGER, -- Number of votes for #6
answer6 VARCHAR(255), -- Answer #7 plain text
count6 INTEGER, -- Number of votes for #7
answer7 VARCHAR(255), -- Answer #8 plain text
count7 INTEGER, -- Number of votes for #8
answer8 VARCHAR(255), -- Answer #9 plain text
count8 INTEGER, -- Number of votes for #9
answer9 VARCHAR(255), -- Answer #10 plain text
count9 INTEGER, -- Number of votes for #10
votes INTEGER, -- Total votes
create_date INTEGER, -- Time/date of creation
create_user VARCHAR(255), -- User that created the poll
modify_date INTEGER, -- Time/date of last change
modify_user VARCHAR(255) -- User that made the last change
);
-- --
-- Schema for table 'str' -- Schema for table 'str'
-- --
@ -154,6 +229,18 @@ INSERT INTO users VALUES(NULL, 1, 'mike', 'Michael Sweet <mike@easysw.com>',
'195c416888c3151df53ae9f38c67afcc', 100, '195c416888c3151df53ae9f38c67afcc', 100,
1084823565, 'mike', 1084823565, 'mike'); 1084823565, 'mike', 1084823565, 'mike');
--
-- Table structure for table 'vote'
--
-- This table is used to track ratings, poll votes, etc. that are made on
-- the links and poll pages.
--
CREATE TABLE vote (
type_id_ip VARCHAR(255) PRIMARY KEY -- type_id_ip
);
-- --
-- End of "$Id: mxml.sql,v 1.3 2004/05/17 21:00:42 mike Exp $". -- End of "$Id: mxml.sql,v 1.4 2004/05/20 03:38:42 mike Exp $".
-- --

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 B

@ -1,12 +1,13 @@
<?php <?php
// //
// "$Id: index.php,v 1.4 2004/05/19 21:17:47 mike Exp $" // "$Id: index.php,v 1.5 2004/05/20 03:38:42 mike Exp $"
// //
// Mini-XML home page... // Mini-XML home page...
// //
include_once "phplib/html.php"; include_once "phplib/html.php";
include_once "phplib/common.php"; include_once "phplib/common.php";
include_once "phplib/poll.php";
html_header(); html_header();
@ -14,21 +15,29 @@ print("<h1 align='center'>Mini-XML Home Page</h1>");
print("<p><table width='100%' height='100%' border='0' cellpadding='0' " print("<p><table width='100%' height='100%' border='0' cellpadding='0' "
."cellspacing='0'>\n" ."cellspacing='0'>\n"
."<tr><td valign='top' width='40%'>"); ."<tr><td valign='top' width='33%'>");
html_start_table(array("Current Poll [&nbsp;<a href='poll.php'>"
."Show&nbsp;All</a>&nbsp;]"));
html_start_row();
print("<td>");
show_poll(get_recent_poll());
print("</td>");
html_end_row();
html_end_table();
html_start_table(array("Quick Info"), "100%", "100%"); html_start_table(array("Quick Info"), "100%", "100%");
html_start_row(); html_start_row();
print("<td>" print("<td>"
."<p align='center'>Stable Release: <a href='software.php?1.3'>v1.3, " ."<p align='center'>"
."December 21, 2003</a><br />" ."Stable Release: <a href='software.php?1.3'>v1.3</a><br />"
."Developer Release: <a href='software.php?2.0rc1'>v2.0rc1, " ."Developer Release: <a href='software.php?2.0rc1'>v2.0rc1</a></p>\n"
."May 20, 2004</a></p>\n"
."<small><p>Mini-XML is a small XML parsing library that you can use to " ."<small><p>Mini-XML is a small XML parsing library that you can use to "
."read XML and XML-like data files in your application without " ."read XML and XML-like data files in your application without "
."requiring large non-standard libraries. Mini-XML only requires " ."requiring large non-standard libraries. Mini-XML only requires "
."an ANSI C compatible compiler (GCC works, as do most vendors' " ."an ANSI C compatible compiler (GCC works, as do most vendors' "
."ANSI C compilers) and a 'make' program.</p>\n" ."ANSI C compilers) and a 'make' program.</p>\n"
."<p>Mini-XML provides the following functionality:</p>\n" ."<!--<p>Mini-XML provides the following functionality:</p>\n"
."<ul>\n" ."<ul>\n"
."<li>Reading of UTF-8 and UTF-16 and writing of UTF-8 encoded " ."<li>Reading of UTF-8 and UTF-16 and writing of UTF-8 encoded "
."XML files and strings.</li>\n" ."XML files and strings.</li>\n"
@ -42,14 +51,14 @@ print("<td>"
."<li>Functions for creating, indexing, and managing trees of data.</li>\n" ."<li>Functions for creating, indexing, and managing trees of data.</li>\n"
."<li>\"Find\" and \"walk\" functions for easily locating and " ."<li>\"Find\" and \"walk\" functions for easily locating and "
."navigating trees of data.</li>\n" ."navigating trees of data.</li>\n"
."</ul></small>\n" ."</ul>--></small>\n"
."</td>"); ."</td>");
html_end_row(); html_end_row();
html_end_table(); html_end_table();
print("</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>" print("</td><td>&nbsp;&nbsp;&nbsp;&nbsp;</td>"
."<td valign='top' width='60%'>" ."<td valign='top' width='67%'>"
."<h2>Recent Articles [&nbsp;<a href='articles.php'>View&nbsp;All</a>" ."<h2>Recent Articles [&nbsp;<a href='articles.php'>Show&nbsp;All</a>"
."&nbsp;]</h2>\n"); ."&nbsp;]</h2>\n");
$result = db_query("SELECT * FROM article WHERE is_published = 1 " $result = db_query("SELECT * FROM article WHERE is_published = 1 "
@ -88,6 +97,6 @@ print("</td></tr>\n"
html_footer(); html_footer();
// //
// End of "$Id: index.php,v 1.4 2004/05/19 21:17:47 mike Exp $". // End of "$Id: index.php,v 1.5 2004/05/20 03:38:42 mike Exp $".
// //
?> ?>

@ -1,6 +1,6 @@
<? <?
// //
// "$Id: common.php,v 1.10 2004/05/20 02:04:45 mike Exp $" // "$Id: common.php,v 1.11 2004/05/20 03:38:42 mike Exp $"
// //
// Common utility functions for PHP pages... // Common utility functions for PHP pages...
// //
@ -224,6 +224,8 @@ format_text($text) // I - Original string
else else
$ftext .= "<br />\n"; $ftext .= "<br />\n";
} }
else
$ftext .= "\n";
$col = 0; $col = 0;
break; break;
@ -671,6 +673,6 @@ validate_email($email) // I - Email address
// //
// End of "$Id: common.php,v 1.10 2004/05/20 02:04:45 mike Exp $". // End of "$Id: common.php,v 1.11 2004/05/20 03:38:42 mike Exp $".
// //
?> ?>

@ -1,6 +1,6 @@
<?php <?php
// //
// "$Id: globals.php,v 1.5 2004/05/19 22:45:23 mike Exp $" // "$Id: globals.php,v 1.6 2004/05/20 03:38:42 mike Exp $"
// //
// Global PHP constants and variables... // Global PHP constants and variables...
// //
@ -28,6 +28,7 @@ $argv = $_SERVER["argv"];
$PHP_SELF = $_SERVER["PHP_SELF"]; $PHP_SELF = $_SERVER["PHP_SELF"];
$REQUEST_METHOD = $_SERVER["REQUEST_METHOD"]; $REQUEST_METHOD = $_SERVER["REQUEST_METHOD"];
$SERVER_NAME = $_SERVER["SERVER_NAME"]; $SERVER_NAME = $_SERVER["SERVER_NAME"];
$REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
if (array_key_exists("ISHTTPS", $_SERVER)) if (array_key_exists("ISHTTPS", $_SERVER))
$PHP_URL = "https://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]$_SERVER[PHP_SELF]"; $PHP_URL = "https://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]$_SERVER[PHP_SELF]";
@ -35,6 +36,6 @@ else
$PHP_URL = "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]$_SERVER[PHP_SELF]"; $PHP_URL = "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]$_SERVER[PHP_SELF]";
// //
// End of "$Id: globals.php,v 1.5 2004/05/19 22:45:23 mike Exp $". // End of "$Id: globals.php,v 1.6 2004/05/20 03:38:42 mike Exp $".
// //
?> ?>

@ -1,6 +1,6 @@
<?php <?php
// //
// "$Id: html.php,v 1.10 2004/05/19 22:45:23 mike Exp $" // "$Id: html.php,v 1.11 2004/05/20 03:38:42 mike Exp $"
// //
// PHP functions for standardized HTML output... // PHP functions for standardized HTML output...
// //
@ -236,6 +236,7 @@ html_start_table($headings, // I - Array of heading strings
{ {
global $html_row, $html_cols; global $html_row, $html_cols;
print("<p><table"); print("<p><table");
if ($width != "") if ($width != "")
print(" width='$width'"); print(" width='$width'");
@ -246,12 +247,11 @@ html_start_table($headings, // I - Array of heading strings
."<img src='images/hdr-top-left.gif' width='16' height='16' " ."<img src='images/hdr-top-left.gif' width='16' height='16' "
."alt=''/></th>"); ."alt=''/></th>");
$add_html_cols = 0; // Add to html_cols after display if colspan is used.
$html_row = 0; $html_row = 0;
$html_cols = sizeof($headings); $html_cols = count($headings);
reset($headings); reset($headings);
for ($i = 0; $i < $html_cols; $i ++) for ($i = 0; $i < count($headings); $i ++)
{ {
// //
// Headings can be in the following forms: // Headings can be in the following forms:
@ -262,7 +262,7 @@ html_start_table($headings, // I - Array of heading strings
// "xxxxxxxx:aa" -- Heading with align. // "xxxxxxxx:aa" -- Heading with align.
// "xxxxxxxx::cc" -- Heading with a colspan. // "xxxxxxxx::cc" -- Heading with a colspan.
// "xxxxxxxx:::ww" -- Heading with a width. // "xxxxxxxx:::ww" -- Heading with a width.
// "xxxxxxxx:cc:ww" -- Heading with colspan and width. // "xxxxxxxx::cc:ww" -- Heading with colspan and width.
// "xxxxxxxx:aa:cc:ww" -- Heading with align, colspan and width. // "xxxxxxxx:aa:cc:ww" -- Heading with align, colspan and width.
// //
// etc, etc. // etc, etc.
@ -276,43 +276,30 @@ html_start_table($headings, // I - Array of heading strings
if (strstr($headings[$i], ":")) if (strstr($headings[$i], ":"))
{ {
$data = explode(":", $headings[$i]); $data = explode(":", $headings[$i]);
$s_header = $data[0]; $s_header = $data[0];
if (ISSET($data[1])) if ($data[1] != "")
{ $s_align = "align=$data[1]";
$align = $data[1];
$s_align = "align=$align";
}
if ($data[2] > 0) if ($data[2] > 1)
{ {
$colspan = $data[2]; $s_colspan = "colspan=$data[2]";
$s_colspan = "colspan=$colspan";
if ($colspan > 1) if ($data[2] > 1)
$add_html_cols += ($colspan - 1); $html_cols += $data[2] - 1;
} }
if ($data[3] > 0) if ($data[3] > 0)
{ $s_width = "width=$data[3]%";
$width = $data[3];
$s_width = "width=$width%";
}
} }
else else
$s_header = $headings[$i]; $s_header = $headings[$i];
if (strlen($s_header)) if (strlen($s_header))
{
print("<th $s_align $s_colspan $s_width>$s_header</th>"); print("<th $s_align $s_colspan $s_width>$s_header</th>");
}
else else
{
print("<th $s_colspan $s_width>&nbsp;</th>"); print("<th $s_colspan $s_width>&nbsp;</th>");
} }
}
$html_cols += $add_html_cols;
print("<th align='right' valign='top'>" print("<th align='right' valign='top'>"
."<img src='images/hdr-top-right.gif' " ."<img src='images/hdr-top-right.gif' "

@ -0,0 +1,114 @@
<?
//
// "$Id: poll.php,v 1.1 2004/05/20 03:38:42 mike Exp $"
//
// Common poll interface functions...
//
// This file should be included using "include_once"...
//
// Contents:
//
// get_recent_poll() - Get the most recent poll...
// show_poll() - Show a poll...
//
//
// Include necessary headers...
//
include_once "db.php";
//
// Constants for poll_type column...
//
$POLL_TYPE_PICKONE = 0;
$POLL_TYPE_PICKMANY = 1;
//
// 'get_recent_poll()' - Get the most recent poll...
//
function // O - Poll ID or 0
get_recent_poll()
{
$result = db_query("SELECT id FROM poll WHERE is_published = 1 "
."ORDER BY id DESC LIMIT 1");
$row = db_next($result);
$id = (int)$row['id'];
db_free($result);
return ($id);
}
//
// 'show_poll()' - Show a poll...
//
function
show_poll($id) // I - Poll ID
{
global $PHP_SELF, $POLL_TYPE_PICKONE, $POLL_TYPE_PICKMANY;
$result = db_query("SELECT * FROM poll WHERE is_published = 1 AND id = $id");
if (db_count($result) == 1)
{
$row = db_next($result);
$id = $row['id'];
$question = htmlspecialchars($row['question']);
print("<p><form method='POST' action='poll.php?v$row[id]'>"
."<b>$question</b>\n");
if ($row['poll_type'] == $POLL_TYPE_PICKONE)
print("(please pick one)\n");
else
print("(pick all that apply)\n");
for ($i = 0; $i < 10; $i ++)
{
$answer = htmlspecialchars($row["answer$i"]);
if ($answer != "")
{
if ($row['poll_type'] == $POLL_TYPE_PICKONE)
print("<br /><input type='radio' name='ANSWER'");
else
print("<br /><input type='checkbox' name='ANSWER$i'");
print(" value='$i'/>$answer\n");
}
}
$votes = $row['votes'];
if ($votes == 1)
$votes .= "&nbsp;vote";
else
$votes .= "&nbsp;votes";
$ccount = count_comments("poll.php_r$id");
if ($ccount == 1)
$ccount .= "&nbsp;comment";
else
$ccount .= "&nbsp;comments";
print("<br /><input type='submit' value='Vote'/>\n"
."[&nbsp;<a href='poll.php?r$id'>Results</a>&nbsp;]\n");
print("<br />($votes, $ccount)</form></p>\n");
}
db_free($result);
}
//
// End of "$Id: poll.php,v 1.1 2004/05/20 03:38:42 mike Exp $".
//
?>

@ -0,0 +1,388 @@
<?php
//
// "$Id: poll.php,v 1.1 2004/05/20 03:38:42 mike Exp $"
//
// Poll page...
//
//
// Include necessary headers...
//
include_once "phplib/html.php";
include_once "phplib/poll.php";
include_once "phplib/common.php";
// Get the operation code:
//
// cN = show poll N
// eN = edit poll N
// l = list all polls
// n = new poll
// rN = show results of poll N
// uN = update poll N (POST)
// vN = vote for poll N (POST)
$poll = 0;
if ($argc > 0)
{
$op = $argv[0][0];
$argv[0][0] = ' ';
$poll = (int)$argv[0];
}
else if ($LOGIN_LEVEL >= AUTH_DEVEL)
$op = 'l';
else
$op = 'c';
if ($poll == 0 && $op != 'u' && $op != 'n')
$poll = get_recent_poll();
// Do it!
switch ($op)
{
case 'c' : // Show a poll
html_header("Poll #$poll");
print("<h1>Poll #$poll</h1>\n");
show_poll($poll);
html_footer();
break;
case 'l' : // List all polls
html_header("Polls");
if ($LOGIN_LEVEL > AUTH_USER)
{
// Show all polls and allow poll creation...
$result = db_query("SELECT * FROM poll ORDER BY id DESC");
html_start_links(1);
html_link("Add New Poll", "$PHP_SELF?n");
html_end_links(1);
}
else
{
// Only show published polls...
$result = db_query("SELECT * FROM poll WHERE is_published = 1 "
."ORDER BY id DESC");
}
print("<h1>Polls</h1>\n");
html_start_table(array("ID", "Question::2"));
while ($row = db_next($result))
{
$id = $row['id'];
$votes = $row['votes'];
$question = htmlspecialchars($row['question']);
$ccount = count_comments("poll.php_r$id");
if ($ccount == 1)
$ccount .= " comment";
else
$ccount .= " comments";
html_start_row();
print("<td align='center'>#$row[id]</td>"
."<td align='center' width='67%'>$question");
if (!$row['is_published'])
print(" <img src='images/private.gif' width='16' height='16' "
."align='middle' alt='private'/>");
print("</td><td nowrap><a href='$PHP_SELF?c$id'>Vote</a> | "
."<a href='$PHP_SELF?r$id'>Results</a>");
if ($LOGIN_LEVEL > AUTH_USER)
print(" | <a href='$PHP_SELF?e$id'>Edit</a>");
print(" ($votes total votes, $ccount)</td>");
html_end_row();
}
html_end_table();
db_free($result);
html_footer();
break;
case 'r' : // Show results
html_header("Poll #$poll");
html_start_links(1);
html_link("Show All Polls", "$PHP_SELF?l");
html_link("Show Comments", "#_USER_COMMENTS");
html_link("Submit Comment", "comment.php?r0+ppoll.php_r$poll");
html_end_links(1);
print("<h1>Poll #$poll</h1>\n");
$result = db_query("SELECT * FROM poll WHERE id = $poll");
$row = db_next($result);
$votes = $row['votes'];
for ($max_count = 0, $i = 0; $i < 10; $i ++)
{
if ($row["count$i"] > $max_count)
$max_count = $row["count$i"];
}
if ($votes == 0)
print("<p>No votes for this poll yet...</p>\n");
else
{
$question = htmlspecialchars($row['question']);
print("<center><table>\n");
print("<tr><td></td><th align='left'>$question</th></tr>\n");
for ($i = 0; $i < 10; $i ++)
{
if ($row["answer$i"] != "")
{
$percent = (int)(100 * $row["count$i"] / $votes);
$size = (int)(300 * $row["count$i"] / $max_count);
$answer = htmlspecialchars($row["answer$i"]);
$count = $row["count$i"];
print("<tr><td align='right'>$answer</td><td>"
."<img src='${rootpath}images/graph.gif' width='$size' "
."height='12'> $count / $percent%</td></tr>\n");
}
}
print("<tr><td></td><th align='right'>$votes total votes.</th></tr>\n");
print("</table></center>\n");
}
print("<hr noshade/>\n"
."<h2><a name='_USER_COMMENTS'>User Comments</a></h2>\n");
html_start_links();
html_link("Submit Comment", "comment.php?r0+ppoll.php_r$poll");
html_end_links();
show_comments("poll.php_r$poll");
db_free($result);
html_footer();
break;
case 'v' : // Vote on a poll
$answers = "";
if ($REQUEST_METHOD == "POST")
{
if (array_key_exists("ANSWER", $_POST))
{
$answer = (int)$_POST["ANSWER"];
$answers = ",count$answer=count$answer+1";
}
else
{
for ($i = 0; $i < 10; $i ++)
{
if (array_key_exists("ANSWER$i", $_POST))
$answers .= ",count$i=count$i+1";
}
}
}
if ($answers != "")
{
if (!db_query("INSERT INTO vote VALUES('poll_${poll}_${REMOTE_ADDR}')")
&& $LOGIN_LEVEL < AUTH_DEVEL)
{
html_header("Poll Error");
print("<h1>Poll Error</h1>\n");
print("<p>Sorry, it appears that you or someone else using your IP "
."address has already voted for "
."<a href='$PHP_SELF?r$poll'>poll #$poll</a>.\n");
html_footer();
}
else
{
db_query("UPDATE poll SET votes=votes+1$answers WHERE id = $poll");
header("Location: $PHP_SELF?r$poll");
}
}
else
{
header("Location: $PHP_SELF?c$poll");
}
break;
case 'n' : // New poll
case 'e' : // Edit poll
if (!$LOGIN_USER)
{
header("Location:$PHP_SELF?r$poll");
break;
}
if ($poll)
{
html_header("Poll #$poll");
print("<h1>Poll #$poll</h1>\n");
$result = db_query("SELECT * FROM poll WHERE id = $poll");
$row = db_next($result);
$question = htmlspecialchars($row['question']);
$poll_type = $row['poll_type'];
for ($i = 0; $i < 10; $i ++)
{
if ($row["answer$i"])
$answer[$i] = htmlspecialchars($row["answer$i"], ENT_QUOTES);
else
$answer[$i] = "";
}
$is_published = $row['is_published'];
db_free($result);
}
else
{
html_header("New Poll");
print("<h1>New Poll</h1>\n");
$question = "";
$poll_type = $POLL_TYPE_PICKONE;
$answer[0] = "";
$answer[1] = "";
$answer[2] = "";
$answer[3] = "";
$answer[4] = "";
$answer[5] = "";
$answer[6] = "";
$answer[7] = "";
$answer[8] = "";
$answer[9] = "";
$is_published = 0;
}
print("<form method='POST' action='$PHP_SELF?u$poll'>\n");
print("<center><table>\n"
."<tr><th align='right' valign='top'>Question:</th><td>"
."<textarea name='QUESTION' wrap='virtual' cols='40' rows='4'>"
."$question</textarea></td></tr>\n");
print("<tr><th align='right'>Type:</th><td>"
."<select name='POLLTYPE'>");
print("<option value='$POLL_TYPE_PICKONE'");
if ($poll_type == $POLL_TYPE_PICKONE)
print(" selected");
print(">Pick One</option>");
print("<option value='$POLL_TYPE_PICKMANY'");
if ($poll_type == $POLL_TYPE_PICKMANY)
print(" selected");
print(">Pick Many</option>");
print("</select></td></tr>\n");
print("<tr><th align='right'>Published:</th><td>");
select_is_published($is_published);
print("</td></tr>\n");
for ($i = 0; $i < 10; $i ++)
{
$number = $i + 1;
print("<tr><TH ALIGN='RIGHT'>Answer #$number</th><td>"
."<INPUT NAME='ANSWER$i' SIZE='45' MAXLENGTH='255' "
."VALUE='$answer[$i]'></td></tr>\n");
}
if ($poll)
print("<tr><th></th><td><input type='SUBMIT' VALUE='Update Poll'></td></tr>\n");
else
print("<tr><th></th><td><input type='SUBMIT' VALUE='Create Poll'></td></tr>\n");
print("</table></center>\n");
print("</form>\n");
html_footer();
break;
case 'u' : // Update poll
header("Location:$PHP_SELF?l");
if ($LOGIN_LEVEL < AUTH_DEVEL)
break;
$is_published = (int)$_POST["IS_PUBLISHED"];
$question = db_escape($_POST["QUESTION"]);
$poll_type = (int)$_POST["POLLTYPE"];
$answer0 = db_escape($_POST["ANSWER0"]);
$answer1 = db_escape($_POST["ANSWER1"]);
$answer2 = db_escape($_POST["ANSWER2"]);
$answer3 = db_escape($_POST["ANSWER3"]);
$answer4 = db_escape($_POST["ANSWER4"]);
$answer5 = db_escape($_POST["ANSWER5"]);
$answer6 = db_escape($_POST["ANSWER6"]);
$answer7 = db_escape($_POST["ANSWER7"]);
$answer8 = db_escape($_POST["ANSWER8"]);
$answer9 = db_escape($_POST["ANSWER9"]);
$date = time();
if ($poll)
{
// Update an existing poll...
db_query("UPDATE poll SET "
."question='$question',"
."is_published=$is_published,"
."poll_type=$poll_type,"
."answer0='$answer0',"
."answer1='$answer1',"
."answer2='$answer2',"
."answer3='$answer3',"
."answer4='$answer4',"
."answer5='$answer5',"
."answer6='$answer6',"
."answer7='$answer7',"
."answer8='$answer8',"
."answer9='$answer9',"
."modify_date=$date,"
."modify_user='$LOGIN_USER' "
."WHERE id = $poll");
}
else
{
// Create a new poll...
db_query("INSERT INTO poll VALUES(NULL,"
."$is_published,"
."$poll_type,"
."'$question',"
."'$answer0',0,"
."'$answer1',0,"
."'$answer2',0,"
."'$answer3',0,"
."'$answer4',0,"
."'$answer5',0,"
."'$answer6',0,"
."'$answer7',0,"
."'$answer8',0,"
."'$answer9',0,"
."0,"
."$date,'$LOGIN_USER',"
."$date,'$LOGIN_USER')");
}
break;
}
db_close();
//
// End of "$Id: poll.php,v 1.1 2004/05/20 03:38:42 mike Exp $".
//
?>
Loading…
Cancel
Save