From 6d26935f40b3909099f0c27f8440f0c7afb7c01e Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 17 May 2004 02:14:54 +0000 Subject: [PATCH] Initial revision --- www/data/.htaccess | 3 + www/data/mxml.db | Bin 0 -> 11264 bytes www/index.php | 412 +++++++++ www/phplib/.htaccess | 3 + www/phplib/db.php | 210 +++++ www/phplib/html.php | 363 ++++++++ www/str.php | 1913 ++++++++++++++++++++++++++++++++++++++++++ www/style.css | 30 + 8 files changed, 2934 insertions(+) create mode 100644 www/data/.htaccess create mode 100644 www/data/mxml.db create mode 100644 www/index.php create mode 100644 www/phplib/.htaccess create mode 100644 www/phplib/db.php create mode 100644 www/phplib/html.php create mode 100644 www/str.php create mode 100644 www/style.css diff --git a/www/data/.htaccess b/www/data/.htaccess new file mode 100644 index 0000000..0a35203 --- /dev/null +++ b/www/data/.htaccess @@ -0,0 +1,3 @@ +Order deny,allow +Allow from none + diff --git a/www/data/mxml.db b/www/data/mxml.db new file mode 100644 index 0000000000000000000000000000000000000000..f6e25a14b1f1321fda3890c66b8214740a8c5153 GIT binary patch literal 11264 zcmeH}L2DX86vv;@7!P|WA(Rk8Is_@Jtfi(UO>VWpl2993E2TM^aUGKZca@#BXit8F zKo9vO{U|;4+Aq*!k9{+)E_8)nB5cW%*?-rM*8y?xG<%dB-R73;~qVD7*Vx%3s| zKKt;#Aw$6qo>WCh z_z%(-#!lNlhm&T#)~d5s?Ny`BbUa&j+1YuEy=$Jmtu-&$oBD<0aTSW7J$vFv)gF#I zeW|X6F?CeP!;#Wn&M=UJK!y`DQSM+UX1_+B$AbwA#W-}-sG}wr&|@EK&6Cqw)2<#I zl`u-s{wx9|2Y&qEu;ldQcm36IOZ@mSZwapb^3ezxY7%UkTRZO6P^H$lvG z;V|+$Mb4MnFPpbEw|6cVw9p3g!|RI#F^ss3nU)g)i!+>yEk*C!$^tn0efhk#Uv`{0 zPqPpFU0b~fN0IL@%=K3LuIH_--M!mIuEq*qZ|=v5d`;wkWSl55ZauR~CbeLJ`oia) zh^vO>M1{vX(VWS)qVp_hjg?BQQGX4IYUo9%K7}vt`OIJU!j1Od&^jO8EOZ)6)H(C0 zCWM;scPUhF%fb&8Yt=usO7OB_wB6;U0Kf5zpg{zPz + +

Mini-XML Home Page

+ +

Current Release: v1.3, December 21, 2003
+[ Download Source (.tar.gz 82k) +| Download Linux RPM (.i386.rpm 76k) +| Change Log | Documentation | Rate/Make Comments ]

+ +

Introduction

+ +

Mini-XML is a small XML parsing library that you can use to +read XML and XML-like data files in your application without +requiring large non-standard libraries. Mini-XML only requires +an ANSI C compatible compiler (GCC works, as do most vendors' +ANSI C compilers) and a "make" program.

+ +

Mini-XML provides the following functionality:

+ +
    +
  • Reading and writing of UTF-8 encoded XML files and + strings.
  • +
  • Data is stored in a linked-list tree structure, + preserving the XML data hierarchy.
  • +
  • Supports arbitrary element names, attributes, and + attribute values with no preset limits, just available + memory.
  • +
  • Supports integer, real, opaque ("cdata"), and text + data types in "leaf" nodes.
  • +
  • Functions for creating and managing trees of data.
  • +
  • "Find" and "walk" functions for easily locating and + navigating trees of data.
  • +
+ +

Mini-XML doesn't do validation or other types of processing +on the data based upon schema files or other sources of +definition information, nor does it support character entities +other than those required by the XML specification. Also, since +Mini-XML does not support the UTF-16 encoding, it is technically +not a conforming XML consumer/client.

+ +

Building Mini-XML

+ +

Mini-XML comes with an autoconf-based configure script; just +type the following command to get things going:

+ +
+./configure
+
+ +

The default install prefix is /usr/local, which can be +overridden using the --prefix option:

+ +
+./configure --prefix=/foo
+
+ +

Other configure options can be found using the --help +option:

+ +
+./configure --help
+
+ +

Once you have configured the software, type "make" to do the +build and run the test program to verify that things are +working, as follows:

+ +
+make
+
+ +

Installing Mini-XML

+ +

The "install" target will install Mini-XML in the lib and +include directories:

+ +
+make install
+
+ +

Once you have installed it, use the "-lmxml" option to link +your application against it.

+ +

Documentation

+ +

The documentation is currently a work in progress. Aside from +the information that follows, the documentation page provides a +handy reference and is automatically generated using Mini-XML. +You can also look at the testmxml.c and mxmldoc.c source files for examples of +using Mini-XML.

+ +

The Basics

+ +

Mini-XML provides a single header file which you include:

+ +
+#include <mxml.h>
+
+ +

Nodes are defined by the mxml_node_t +structure; the type member +defines the node type (element, integer, opaque, real, or text) +which determines which value you want to look at in the value +union. New nodes can be created using the mxmlNewElement(), +mxmlNewInteger(), +mxmlNewOpaque(), +mxmlNewReal(), +and mxmlNewText() +functions. Only elements can have child nodes, and the top node +must be an element, usually "?xml".

+ +

Each node has pointers for the node above (parent), below (child), +to the left (prev), and to the right (next) of the current +node. If you have an XML file like the following:

+ +
+    <?xml version="1.0"?>
+    <data>
+        <node>val1</node>
+        <node>val2</node>
+        <node>val3</node>
+        <group>
+            <node>val4</node>
+            <node>val5</node>
+            <node>val6</node>
+        </group>
+        <node>val7</node>
+        <node>val8</node>
+        <node>val9</node>
+    </data>
+
+ +

the node tree returned by mxmlLoadFile() would look +like the following in memory:

+ +
+    ?xml
+      |
+    data
+      |
+    node - node - node - group - node - node - node
+      |      |      |      |       |      |      |
+    val1   val2   val3     |     val7   val8   val9
+                           |
+                         node - node - node
+                           |      |      |
+                         val4   val5   val6
+
+ +

where "-" is a pointer to the next node and "|" is a pointer +to the first child node.

+ +

Once you are done with the XML data, use the mxmlDelete() +function to recursively free the memory that is used for a +particular node or the entire tree:

+ +
+mxmlDelete(tree);
+
+ +

Loading and Saving XML Files

+ +

You load an XML file using the mxmlLoadFile() +function:

+ +
+FILE *fp;
+mxml_node_t *tree;
+
+fp = fopen("filename.xml", "r");
+tree = mxmlLoadFile(NULL, fp, MXML_NO_CALLBACK);
+fclose(fp);
+
+ +

The third argument specifies a callback function which +returns the value type of the immediate children for a new +element node: MXML_INTEGER, MXML_OPAQUE, +MXML_REAL, or MXML_TEXT. This function is +called after the element and its attributes have been +read, so you can look at the element name, attributes, and +attribute values to determine the proper value type to return. +The default value type is MXML_TEXT if no callback is used.

+ +

Similarly, you save an XML file using the mxmlSaveFile() +function:

+ +
+FILE *fp;
+mxml_node_t *tree;
+
+fp = fopen("filename.xml", "w");
+mxmlSaveFile(tree, fp, MXML_NO_CALLBACK);
+fclose(fp);
+
+ +

Callback functions for saving are used to optionally insert +whitespace before and after elements in the node tree. Your +function will be called up to four times for each element node +with a pointer to the node and a "where" value of +MXML_WS_BEFORE_OPEN, MXML_WS_AFTER_OPEN, +MXML_WS_BEFORE_CLOSE, or MXML_WS_AFTER_CLOSE. +The callback function should return 0 if no whitespace should be +added and the character to insert (space, tab, newline) +otherwise.

+ +

The mxmlLoadString(), +mxmlSaveAllocString(), +and mxmlSaveString() +functions load XML node trees from and save XML node trees to +strings:

+ +
+char buffer[8192];
+char *ptr;
+mxml_node_t *tree;
+
+...
+tree = mxmlLoadString(NULL, buffer, MXML_NO_CALLBACK);
+
+...
+mxmlSaveString(tree, buffer, sizeof(buffer), MXML_NO_CALLBACK);
+
+...
+ptr = mxmlSaveAllocString(tree, MXML_NO_CALLBACK);
+
+ +

Finding and Iterating Nodes

+ +

The mxmlWalkPrev() +and mxmlWalkNext()functions +can be used to iterate through the XML node tree:

+ +
+mxml_node_t *node = mxmlWalkPrev(current, tree, MXML_DESCEND);
+
+mxml_node_t *node = mxmlWalkNext(current, tree, MXML_DESCEND);
+
+ +

In addition, you can find a named element/node using the mxmlFindElement() +function:

+ +
+mxml_node_t *node = mxmlFindElement(tree, tree, "name", "attr",
+                                    "value", MXML_DESCEND);
+
+ +

The name, attr, and value +arguments can be passed as NULL to act as wildcards, +e.g.:

+ +
+/* Find the first "a" element */
+node = mxmlFindElement(tree, tree, "a", NULL, NULL, MXML_DESCEND);
+
+/* Find the first "a" element with "href" attribute */
+node = mxmlFindElement(tree, tree, "a", "href", NULL, MXML_DESCEND);
+
+/* Find the first "a" element with "href" to a URL */
+node = mxmlFindElement(tree, tree, "a", "href",
+                       "http://www.easysw.com/~mike/mxml/", MXML_DESCEND);
+
+/* Find the first element with a "src" attribute*/
+node = mxmlFindElement(tree, tree, NULL, "src", NULL, MXML_DESCEND);
+
+/* Find the first element with a "src" = "foo.jpg" */
+node = mxmlFindElement(tree, tree, NULL, "src", "foo.jpg", MXML_DESCEND);
+
+ +

You can also iterate with the same function:

+ +
+mxml_node_t *node;
+
+for (node = mxmlFindElement(tree, tree, "name", NULL, NULL, MXML_DESCEND);
+     node != NULL;
+     node = mxmlFindElement(node, tree, "name", NULL, NULL, MXML_DESCEND))
+{
+  ... do something ...
+}
+
+ +

The MXML_DESCEND argument can actually be one of three constants:

+ +
    + +
  • MXML_NO_DESCEND means to not to look at any + child nodes in the element hierarchy, just look at + siblings at the same level or parent nodes until the top + node or top-of-tree is reached. The previous node from + "group" would be the "node" element to the left, while + the next node from "group" would be the "node" element + to the right.
  • + +
  • MXML_DESCEND_FIRST means that it is OK to + descend to the first child of a node, but not to descend + further when searching. You'll normally use this when + iterating through direct children of a parent node, e.g. + all of the "node" elements under the "?xml" parent node + in the example above. This mode is only applicable to + the search function; the walk functions treat this as + MXML_DESCEND since every call is a first + time.
  • + +
  • MXML_DESCEND means to keep descending until + you hit the bottom of the tree. The previous node from + "group" would be the "val3" node and the next node would + be the first node element under "group". If you were to + walk from the root node "?xml" to the end of the + tree with mxmlWalkNext(), the order would be: + +
    +    ?xml
    +    data
    +    node
    +    val1
    +    node
    +    val2
    +    node
    +    val3
    +    group
    +    node
    +    val4
    +    node
    +    val5
    +    node
    +    val6
    +    node
    +    val7
    +    node
    +    val8
    +    node
    +    val9
    +
    + +

    If you started at "val9" and walked using + mxmlWalkPrev(), the order would be reversed, + ending at "?xml".

  • + +
+ +

Getting Help and Reporting Problems

+ +

You can email me at "mxml at easysw dot com" to +report problems and/or ask for help. Just don't expect an +instant response, as I get a lot of email...

+ +

Legal Stuff

+ +

The Mini-XML library is Copyright 2003-2004 by Michael Sweet.

+ +

This library is free software; you can redistribute it +and/or modify it under the terms of the GNU Library General +Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any +later version.

+ +

This library is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied +warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU Library General Public License for +more details.

+ +

You should have received a copy of the GNU Library General +Public License along with this library; if not, write to the +Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA +02139, USA.

+ + diff --git a/www/phplib/.htaccess b/www/phplib/.htaccess new file mode 100644 index 0000000..0a35203 --- /dev/null +++ b/www/phplib/.htaccess @@ -0,0 +1,3 @@ +Order deny,allow +Allow from none + diff --git a/www/phplib/db.php b/www/phplib/db.php new file mode 100644 index 0000000..9d79b68 --- /dev/null +++ b/www/phplib/db.php @@ -0,0 +1,210 @@ +Database error $sqlerr

\n"); + print("

Please report the problem to " + ."webmaster@easysw.com.

\n"); + exit(1); +} + + +// +// 'db_close()' - Close the database. +// + +function +db_close() +{ + global $DB_CONN; + + + sqlite_close($DB_CONN); + $DB_CONN = false; +} + + +// +// 'db_count()' - Return the number of rows in a query result. +// + +function // O - Number of rows in result +db_count($result) // I - Result of query +{ + if ($result) + return (sqlite_num_rows($result)); + else + return (0); +} + + +// +// 'db_escape()' - Escape special chars in string for query. +// + +function // O - Quoted string +db_escape($str) // I - String +{ + return (sqlite_escape_string($str)); +} + + +// +// 'db_free()' - Free a database query result... +// + +function +db_free($result) // I - Result of query +{ + // Nothing to do, as SQLite doesn't free results... +} + + +// +// 'db_insert_id()' - Return the ID of the last inserted record. +// + +function // O - ID number +db_insert_id() +{ + global $DB_CONN; + + return (sqlite_last_insert_rowid($DB_CONN)); +} + + +// +// 'db_next()' - Fetch the next row of a result set and return it as an object. +// + +function // O - Row object or NULL at end +db_next($result) // I - Result of query +{ + if ($result) + return (sqlite_fetch_array($result, SQLITE_ASSOC)); + else + return (NULL); +} + + +// +// 'db_query()' - Run a SQL query and return the result or 0 on error. +// + +function // O - Result of query or NULL +db_query($SQL_QUERY) // I - SQL query string +{ + global $DB_CONN; + + return (sqlite_query($DB_CONN, $SQL_QUERY)); +} + + +// +// 'db_seek()' - Seek to a specific row within a result. +// + +function // O - TRUE on success, FALSE otherwise +db_seek($result, // I - Result of query + $index = 0) // I - Row number (0 = first row) +{ + if ($result) + return (sqlite_seek($result, $index)); + else + return (FALSE); +} + + +// +// End of "$Id: db.php,v 1.1 2004/05/17 02:14:55 mike Exp $". +// +?> diff --git a/www/phplib/html.php b/www/phplib/html.php new file mode 100644 index 0000000..0875839 --- /dev/null +++ b/www/phplib/html.php @@ -0,0 +1,363 @@ +\n"); + print("\n"); + print("\n"); + + // Title... + if ($title != "") + $html_title = "$title -"; + else + $html_title = ""; + + print(" $html_title Mini-XML\n" + ." \n" + ." \n" + ." \n"); + + // Search engine keywords... + reset($html_keywords); + + list($key, $val) = each($html_keywords); + print("\n"); + + print("\n" + ."\n"); + + // Standard navigation stuff... + print("

\n" + ."" + ."" + ."\n"); + + print("" + ."\n"); + print("" + ."" + ."\n"); + print("
[ " + ."Home | " + ."Documentation | " + ."Download | " + ."FAQ | " + ."Support" + ." ]
\n"); +} + + +// +// 'html_footer()' - Show the standard footer for a page. +// + +function +html_footer() +{ + print("
Copyright 2003-2004 by Michael Sweet. This library is free " + ."software; you can redistribute it and/or modify it " + ."under the terms of the GNU Library General Public " + ."License as published by the Free Software Foundation; " + ."either version 2 of the License, or (at your option) " + ."any later version.

\n"); + print("\n" + ."\n"); +} + + +// +// 'html_start_links()' - Start of series of hyperlinks. +// + +function +html_start_links($center = 0) // I - 1 for centered, 0 for in-line +{ + global $html_firstlink; + + $html_firstlink = 1; + + if ($center) + print("

"); +} + + +// +// 'html_end_links()' - End of series of hyperlinks. +// + +function +html_end_links($center = 0) // I - 1 for centered, 0 for in-line +{ + if ($center) + print("

\n"); +} + + +// +// 'html_link()' - Show a single hyperlink. +// + +function +html_link($text, // I - Text for hyperlink + $link) // I - URL for hyperlink +{ + global $html_firstlink; + + if ($html_firstlink) + $html_firstlink = 0; + else + print(" | "); + + $safetext = str_replace(" ", " ", $text); + + print("$safetext"); +} + + +// +// 'html_links()' - Show an array of links. +// + +function +html_links($links, // I - Associated array of hyperlinks + $path = "") // I - Relative path to add to root +{ + reset($links); + while (list($key, $val) = each($links)) + html_link($key, $path . $val); +} + + +// +// 'html_start_box()' - Start a rounded, shaded box. +// + +function +html_start_box($title = "", // I - Title for box + $path = "") // I - Relative path to root +{ + print("

" + ."" + ."" + ."\n" + ."" + ."" + ."\n" + ."
" + ."$title
" + .""); +} + + +// +// 'html_end_box()' - End a rounded, shaded box. +// + +function +html_end_box($path = "") // I - Relative path to root +{ + print("

\n"); +} + + +// +// 'html_start_table()' - Start a rounded, shaded table. +// + +function +html_start_table($headings, // I - Array of heading strings + $path = "") // I - Relative path to root +{ + global $html_row, $html_cols; + + print("

" + .""); + + $add_html_cols; // Add to html_cols after display if colspan is used. + $html_row = 0; + $html_cols = sizeof($headings); + + reset($headings); + for ($i = 0; $i < $html_cols; $i ++) + { + // + // Headings can be in the following forms: + // + // Mix and match as needed: + // + // "xxxxxxxx" -- Just a column heading. + // "xxxxxxxx:aa" -- Heading with align. + // "xxxxxxxx::cc" -- Heading with a colspan. + // "xxxxxxxx:::ww" -- Heading with a width. + // "xxxxxxxx:cc:ww" -- Heading with colspan and width. + // "xxxxxxxx:aa:cc:ww" -- Heading with align, colspan and width. + // + // etc, etc. + // + + $s_header = ""; + $s_colspan = ""; + $s_width = ""; + $s_align = ""; + + if (strstr( $headings[$i], ":" )) + { + $data = explode( ":", $headings[$i] ); + + $s_header = $data[0]; + + if (ISSET($data[1])) + { + $align = $data[1]; + $s_align = "align=$align"; + } + if ($data[2] > 0) + { + $colspan = $data[2]; + $s_colspan = "colspan=$colspan"; + if ($colspan > 1) + $add_html_cols += ($colspan-1); + } + if ($data[3] > 0) + { + $width = $data[3]; + $s_width = "width=$width%"; + } + } + else $s_header = $headings[$i]; + + if (strlen($s_header)) + { + print(""); + } + else + { + print(""); + } + } + $html_cols += $add_html_cols; + + print("\n"); +} + + +// +// 'html_end_table()' - End a rounded, shaded table. +// + +function +html_end_table($path = "") // I - Relative path to root +{ + global $html_cols; + + print("" + ."" + ."\n" + ."
" + ."" + ."$s_header " + ."
" + ." 

\n"); +} + + +// +// 'html_start_row()' - Start a table row. +// + +function +html_start_row() +{ + global $html_row; + + print(" "); +} + + +// +// 'html_end_row()' - End a table row. +// + +function +html_end_row() +{ + global $html_row; + + $html_row = 1 - $html_row; + + print(" \n"); +} + + +?> diff --git a/www/str.php b/www/str.php new file mode 100644 index 0000000..1942817 --- /dev/null +++ b/www/str.php @@ -0,0 +1,1913 @@ + "Michael Sweet " +); + +$messages = array( + "Fixed in CVS" => + "Fixed in CVS - the anonymous CVS repository will be updated at " + ."midnight EST.", + "Old STR" => + "This STR has not been updated by the submitter for two or more weeks " + ."and has been closed as required by the Mini-XML Configuration Management " + ."Plan. If the issue still requires resolution, please re-submit a new " + ."STR.", + "Unresolvable" => + "We are unable to resolve this problem with the information provided. " + ."If you discover new information, please file a new STR referencing " + ."this one." +); + +$subsystems = array( + "Build Files", + "Config Files", + "Core API", + "Documentation", + "Multiple", + "mxmldoc", + "Sample Programs", + "Web Site" +); + +$versions = array( + "2.0cvs", + "1.3", + "1.2", + "1.1.2", + "1.1.1", + "1.1", + "1.0", + "Web Site" +); + +$status_text = array( + 1 => "Resolved", + 2 => "Unresolved", + 3 => "Active", + 4 => "Pending", + 5 => "New" +); + +$status_long = array( + 1 => "1 - Closed w/Resolution", + 2 => "2 - Closed w/o Resolution", + 3 => "3 - Active", + 4 => "4 - Pending", + 5 => "5 - New" +); + +$priority_text = array( + 1 => "RFE", + 2 => "LOW", + 3 => "MODERATE", + 4 => "HIGH", + 5 => "CRITICAL" +); + +$priority_long = array( + 1 => "1 - Request for Enhancement, e.g. asking for a feature", + 2 => "2 - Low, e.g. a documentation error or undocumented side-effect", + 3 => "3 - Moderate, e.g. unable to compile the software", + 4 => "4 - High, e.g. key functionality not working", + 5 => "5 - Critical, e.g. nothing working at all" +); + +$scope_text = array( + 1 => "M/P", + 2 => "OS", + 3 => "ALL" +); + +$scope_long = array( + 1 => "1 - Specific to a machine", + 2 => "2 - Specific to an operating system", + 3 => "3 - Applies to all machines and operating systems" +); + +// Global web vars... +global $PHP_SELF; +global $HTTP_COOKIE_VARS; +global $HTTP_POST_FILES; +global $HTTP_POST_VARS; +global $REMOTE_USER; +global $REQUEST_METHOD; +global $SERVER_NAME; + +// Function to abbreviate long strings... +function abbreviate($text, $maxlen = 32) +{ + if (strlen($text) > $maxlen) + return (substr($text, 0, $maxlen) . "..."); + else + return ($text); +} + + +// Function to notify creator of an STR of changes... +function notify_creator($id, $what = "updated", $contents = "") +{ + global $priority_long; + global $scope_long; + global $status_long; + + $result = db_query("SELECT * FROM str WHERE id = $id"); + if ($result) + { + $contents = wordwrap($contents); + $row = db_next($result); + $prtext = $priority_long[$row->priority]; + $sttext = $status_long[$row->status]; + $sctext = $scope_long[$row->scope]; + + if ($row->subsystem != "") + $subsystem = $row->subsystem; + else + $subsystem = "Unassigned"; + + if ($row->fix_version != "") + $fix_version = $row->fix_version; + else + $fix_version = "Unassigned"; + + if ($row->create_email != $row->modify_email && + $row->create_email != $manager) + mail($row->create_email, "Mini-XML STR #$id $what", + "Your software trouble report #$id has been $what. You can check\n" + ."the status of the report and add additional comments and/or files\n" + ."at the following URL:\n" + ."\n" + ." http://www.easysw.com/str.php?L$id\n" + ."\n" + ." Summary: $row->summary\n" + ." Version: $row->str_version\n" + ." Status: $sttext\n" + ." Priority: $prtext\n" + ." Scope: $sctext\n" + ." Subsystem: $subsystem\n" + ."Fix Version: $fix_version\n" + ."\n$contents" + ."________________________________________________________________\n" + ."Thank you for using the Mini-XML Software Trouble Report page!", + "From: noreply@easysw.com\r\n"); + + $ccresult = db_query("SELECT email FROM strcc WHERE str_id = $id"); + if ($ccresult) + { + while ($ccrow = db_next($ccresult)) + { + mail($ccrow->email, "Mini-XML STR #$id $what", + "Software trouble report #$id has been $what. You can check\n" + ."the status of the report and add additional comments and/or files\n" + ."at the following URL:\n" + ."\n" + ." http://www.easysw.com/str.php?L$id\n" + ."\n" + ." Summary: $row->summary\n" + ." Version: $row->str_version\n" + ." Status: $sttext\n" + ." Priority: $prtext\n" + ." Scope: $sctext\n" + ." Subsystem: $subsystem\n" + ."Fix Version: $fix_version\n" + ."\n$contents" + ."________________________________________________________________\n" + ."Thank you for using the Mini-XML Software Trouble Report page!", + "From: noreply@easysw.com\r\n"); + } + + db_free($ccresult); + } + + if ($row->manager_email != "") + $manager = $row->manager_email; + else + $manager = "mxml"; + + if ($row->modify_email != $manager) + mail($manager, "Mini-XML STR #$id $what", + "The software trouble report #$id assigned to you has been $what.\n" + ."You can manage the report and add additional comments and/or files\n" + ."at the following URL:\n" + ."\n" + ." http://www.easysw.com/private/str.php?L$id\n" + ."\n" + ." Summary: $row->summary\n" + ." Version: $row->str_version\n" + ." Status: $sttext\n" + ." Priority: $prtext\n" + ." Scope: $sctext\n" + ." Subsystem: $subsystem\n" + ."Fix Version: $fix_version\n" + ."\n$contents", + "From: noreply@easysw.com\r\n"); + + db_free($result); + } +} + +// Get command-line options... +// +// Usage: str.php [operation] [options] +// +// Operations: +// +// B = Batch update selected STRs +// L = List all STRs +// L# = List STR # +// M# = Modify STR # +// T# = Post text for STR # +// F# = Post file for STR # +// N = Post new STR +// U# = Update notification for STR # +// +// Options: +// +// I# = Set first STR +// P# = Set priority filter +// S# = Set status filter +// C# = Set scope filter +// E# = Set email filter +// Qtext = Set search text + +$priority = 0; +$status = -2; +$scope = 0; +$search = ""; +$index = 0; +$femail = 0; + +global $argc, $argv; + +print("

argc=$argc

\n"); +print("

argv=$argv

\n"); + +if ($argc) +{ + $op = $argv[0][0]; + $id = (int)substr($argv[0], 1); + + if ($op != 'L' && $op != 'M' && $op != 'T' && $op != 'F' && + $op != 'N' && $op != 'U' && $op != 'B') + { + html_header("STR Error"); + print("

Bad command '$op'!

\n"); + html_footer(); + exit(); + } + + if (($op == 'M' || $op == 'B') && !$REMOTE_USER) + { + html_header("STR Error"); + print("

The '$op' command is not available to you!

\n"); + html_footer(); + exit(); + } + + if (($op == 'M' || $op == 'T' || $op == 'F') && !$id) + { + html_header("STR Error"); + print("

Command '$op' requires an STR number!

\n"); + html_footer(); + exit(); + } + + if ($op == 'N' && $id) + { + html_header("STR Error"); + print("

Command '$op' cannot have an STR number!

\n"); + html_footer(); + exit(); + } + + for ($i = 1; $i < $argc; $i ++) + { + $option = substr($argv[$i], 1); + + switch ($argv[$i][0]) + { + case 'P' : // Set priority filter + $priority = (int)$option; + break; + case 'S' : // Set status filter + $status = (int)$option; + break; + case 'C' : // Set scope filter + $scope = (int)$option; + break; + case 'Q' : // Set search text + $search = $option; + $i ++; + while ($i < $argc) + { + $search .= " $argv[$i]"; + $i ++; + } + break; + case 'I' : // Set first STR + $index = (int)$option; + if ($index < 0) + $index = 0; + break; + case 'E' : // Show only problem reports matching the current email + $femail = (int)$option; + break; + default : + html_header("STR Error"); + print("

Bad option '$argv[$i]'!

\n"); + html_footer(); + exit(); + break; + } + } +} +else +{ + $op = 'L'; + $id = 0; +} + +if ($REQUEST_METHOD == "POST") +{ + if (array_key_exists("FPRIORITY", $HTTP_POST_VARS)) + $priority = (int)$HTTP_POST_VARS["FPRIORITY"]; + if (array_key_exists("FSTATUS", $HTTP_POST_VARS)) + $status = (int)$HTTP_POST_VARS["FSTATUS"]; + if (array_key_exists("FSCOPE", $HTTP_POST_VARS)) + $scope = (int)$HTTP_POST_VARS["FSCOPE"]; + if (array_key_exists("FEMAIL", $HTTP_POST_VARS)) + $femail = (int)$HTTP_POST_VARS["FEMAIL"]; + if (array_key_exists("SEARCH", $HTTP_POST_VARS)) + $search = $HTTP_POST_VARS["SEARCH"]; +} + +$options = "+P$priority+S$status+C$scope+I$index+E$femail+Q" . urlencode($search); + +// B = Batch update selected STRs +// L = List all STRs +// L# = List STR # +// M# = Modify STR # +// T# = Post text for STR # +// F# = Post file for STR # +// N = Post new STR +// U# = Update notification for STR # + +switch ($op) +{ + case 'B' : // Batch update selected STRs + if ($REQUEST_METHOD != "POST") + { + header("Location: $PHP_SELF?L$options"); + break; + } + + if (array_key_exists("STATUS", $HTTP_POST_VARS) && + ($HTTP_POST_VARS["STATUS"] != "" || + $HTTP_POST_VARS["PRIORITY"] != "" || + $HTTP_POST_VARS["MANAGER_EMAIL"] != "" || + $HTTP_POST_VARS["MESSAGE"] != "")) + { + $time = time(); + $manager_email = db_escape_string($HTTP_POST_VARS["MANAGER_EMAIL"]); + $modify_email = db_escape_string($managers[$REMOTE_USER]); + $message = $HTTP_POST_VARS["MESSAGE"]; + + if ($message != "") + { + $contents = db_escape_string($messages[$message]); + $mailmsg = $messages[$message] . "\n\n"; + } + else + { + $contents = ""; + $mailmsg = ""; + } + + $query = "modify_date = $time, modify_email = '$modify_email'"; + + if ($HTTP_POST_VARS["STATUS"] != "") + $query .= ", status = $HTTP_POST_VARS[STATUS]"; + if ($HTTP_POST_VARS["PRIORITY"] != "") + $query .= ", priority = $HTTP_POST_VARS[PRIORITY]"; + if ($manager_email != "") + $query .= ", manager_email = '$manager_email'"; + + reset($HTTP_POST_VARS); + while (list($key, $val) = each($HTTP_POST_VARS)) + if (substr($key, 0, 3) == "ID_") + { + $id = (int)substr($key, 3); + + db_query("UPDATE str SET $query WHERE id = $id"); + + if ($contents != "") + { + db_query("INSERT INTO strtext VALUES(0,$id,1,$time," + ."'$modify_email','$contents')"); + + notify_creator($id, "updated", $mailmsg); + } + } + } + + header("Location: $PHP_SELF?L$options"); + break; + + case 'L' : // List (all) STR(s) + if ($id) + { + html_header("STR #$id"); + + $result = db_query("SELECT * FROM str WHERE id = $id"); + if (db_count($result) != 1) + { + print("

Error: STR #$id was not found!

\n"); + html_footer(); + exit(); + } + + $row = db_next($result); + + print("

" + ."[ Return to STR List"); + + if ($row->status >= $STR_STATUS_ACTIVE) + print(" | Post Text" + ." | Post File"); + + if ($REMOTE_USER) + print(" | Modify STR"); + + print(" ]


\n"); + + $create_email = sanitize_email($row->create_email); + $manager_email = sanitize_email($row->manager_email); + $subsystem = $row->subsystem; + $summary = htmlspecialchars($row->summary, ENT_QUOTES); + $prtext = $priority_long[$row->priority]; + $sttext = $status_long[$row->status]; + $sctext = $scope_long[$row->scope]; + $str_version = $row->str_version; + $fix_version = $row->fix_version; + + if ($manager_email == "") + $manager_email = "Unassigned"; + + if ($subsystem == "") + $subsystem = "Unassigned"; + + if ($fix_version == "") + $fix_version = "Unassigned"; + + print("

\n"); + + if ($row->master_id > 0) + print("" + ."\n"); + + if (!$row->is_published) + print("\n"); + + print("\n"); + + print("\n"); + print("\n"); + print("\n"); + print("\n"); + print("\n"); + print("\n"); + print("\n"); + print("\n"); + + if ($REMOTE_USER) + $email = htmlspecialchars($managers[$REMOTE_USER]); + else if (array_key_exists("FROM", $HTTP_COOKIE_VARS)) + $email = htmlspecialchars($HTTP_COOKIE_VARS["FROM"]); + else + $email = ""; + + print("\n"); + print("
Duplicate Of:STR " + ."#$row->master_id
This STR is " + ."currently hidden from public view.
Status:$sttext
Priority:$prtext
Scope:$sctext
Subsystem:$subsystem
Summary:$summary
Version:$str_version
Created By:$create_email
Assigned To:$manager_email
Fix Version:$fix_version
Update Notification:" + ."
" + ."" + ."" + ."
Receive EMails " + ."Don't Receive EMails" + ."
" + ."

\n"); + + db_free($result); + + print("

Trouble Report Files:"); + if ($row->status >= $STR_STATUS_ACTIVE) + print(" [ Post File ]"); + print("

\n"); + + $result = db_query("SELECT * FROM strfile WHERE " + ."str_id = $id AND is_published = 1"); + + if (db_count($result) == 0) + print("

No files

\n"); + else + { + print("

\n" + ."" + ."\n"); + + $bgcolor = "#eeeebb"; + while ($row = db_next($result)) + { + $date = date("M d, Y", $row->date); + $time = date("H:m", $row->date); + $email = sanitize_email($row->email); + $filename = htmlspecialchars($row->filename); + + print("" + ."" + ."" + ."\n"); + + if ($bgcolor == "#ddddaa") + $bgcolor = "#eeeebb"; + else + $bgcolor = "#ddddaa"; + } + print("
Name/Time/DateFilename
$email
$time $date
" + ."$filename

\n"); + } + + db_free($result); + + print("

Trouble Report Dialog:"); + if ($row->status >= $STR_STATUS_ACTIVE) + print(" [ Post Text ]"); + print("

\n"); + + $result = db_query("SELECT * FROM strtext WHERE " + ."str_id = $id AND is_published = 1"); + + if (db_count($result) == 0) + print("

No text

\n"); + else + { + print("

\n" + ."" + ."\n"); + + $bgcolor = "#eeeebb"; + + while ($row = db_next($result)) + { + $date = date("M d, Y", $row->date); + $time = date("H:m", $row->date); + $email = sanitize_email($row->email); + $contents = quote_text($row->contents); + + print("" + ."" + ."" + ."\n"); + + if ($bgcolor == "#ddddaa") + $bgcolor = "#eeeebb"; + else + $bgcolor = "#ddddaa"; + } + print("
Name/Time/DateText
$email
$time $date
$contents

\n"); + } + + db_free($result); + } + else + { + html_header("STR List"); + + print("

[ Post " + ."New Software Trouble Report ]

\n"); + + print("

" + ."Search Words:  " + ."

\n"); + + print("

Priority: \n"); + + print("Status: \n"); + + print("Scope: \n"); + + if ($REMOTE_USER || array_key_exists("FROM", $HTTP_COOKIE_VARS)) + { + print("Show: \n"); + } + + print("

\n"); + print("
\n"); + + $query = ""; + $prefix = "WHERE "; + + if ($priority > 0) + { + $query .= "${prefix}priority = $priority"; + $prefix = " AND "; + } + + if ($status > 0) + { + $query .= "${prefix}status = $status"; + $prefix = " AND "; + } + else if ($status == -1) // Show closed + { + $query .= "${prefix}status <= $STR_STATUS_UNRESOLVED"; + $prefix = " AND "; + } + else if ($status == -2) // Show open + { + $query .= "${prefix}status >= $STR_STATUS_ACTIVE"; + $prefix = " AND "; + } + + if ($scope > 0) + { + $query .= "${prefix}scope = $scope"; + $prefix = " AND "; + } + + if (!$REMOTE_USER) + { + $query .= "${prefix}is_published = 1"; + $prefix = " AND "; + } + + if ($femail) + { + if ($REMOTE_USER) + { + $query .= "${prefix}(manager_email = '' OR " + ." manager_email = '$managers[$REMOTE_USER]')"; + $prefix = " AND "; + } + else if (array_key_exists("FROM", $HTTP_COOKIE_VARS)) + { + $email = db_escape_string($HTTP_COOKIE_VARS["FROM"]); + $query .= "${prefix}create_email = '$email'"; + $prefix = " AND "; + } + } + + if ($search) + { + $search_string = str_replace("'", " ", $search); + $search_string = str_replace("\"", " ", $search_string); + $search_string = str_replace("\\", " ", $search_string); + $search_string = str_replace("%20", " ", $search_string); + $search_string = str_replace("%27", " ", $search_string); + $search_string = str_replace(" ", " ", $search_string); + $search_words = explode(' ', $search_string); + + // Loop through the array of words, adding them to the + $query .= "${prefix}("; + $prefix = ""; + $next = " OR"; + $logic = ""; + + reset($search_words); + while ($keyword = current($search_words)) + { + next($search_words); + $keyword = db_escape_string(ltrim(rtrim($keyword))); + + if (strcasecmp($keyword, 'or') == 0) + { + $next = ' OR'; + if ($prefix != '') + $prefix = ' OR'; + } + else if (strcasecmp($keyword, 'and') == 0) + { + $next = ' AND'; + if ($prefix != '') + $prefix = ' AND'; + } + else if (strcasecmp($keyword, 'not') == 0) + { + $logic = ' NOT'; + } + else + { + if ($keyword == (int)$keyword) + $idsearch = " OR id = " . (int)$keyword; + else + $idsearch = ""; + + $query .= "$prefix$logic (summary LIKE \"%$keyword%\"$idsearch" + ." OR subsystem LIKE \"%$keyword%\"" + ." OR str_version LIKE \"%$keyword%\"" + ." OR fix_version LIKE \"%$keyword%\"" + ." OR manager_email LIKE \"%$keyword%\"" + ." OR create_email LIKE \"%$keyword%\")"; + $prefix = $next; + $logic = ''; + } + } + + $query .= ")"; + } + + $result = db_query("SELECT * FROM str $query " + ."ORDER BY status DESC, priority DESC, scope DESC, " + ."modify_date"); + $count = db_count($result); + + if ($count == 0) + { + print("

No STRs found.

\n"); + + if (($priority || $status || $scope) && $search != "") + print("

[ Search for \"$search\" in all STRs ]

\n"); + + html_footer(); + exit(); + } + + if ($index >= $count) + $index = $count - ($count % $STR_PAGE_MAX); + if ($index < 0) + $index = 0; + + $start = $index + 1; + $end = $index + $STR_PAGE_MAX; + if ($end > $count) + $end = $count; + + $prev = $index - $STR_PAGE_MAX; + if ($prev < 0) + $prev = 0; + $next = $index + $STR_PAGE_MAX; + + print("

$count STR(s) found, showing $start to $end:

\n"); + + if ($REMOTE_USER) + print("
\n"); + + print("

\n"); + + if ($count > $STR_PAGE_MAX) + { + print("\n"); + } + + print("" + ."" + .""); + if ($REMOTE_USER) + print(""); + print("\n"); + + $bgcolor = "#eeeebb"; + + if ($REMOTE_USER) + $sumlen = 80; + else + $sumlen = 40; + + db_data_seek($result, $index); + for ($i = 0; $i < $STR_PAGE_MAX && $row = db_next($result); $i ++) + { + $date = date("M d, Y", $row->modify_date); + $summary = htmlspecialchars($row->summary, ENT_QUOTES); + $summabbr = htmlspecialchars(abbreviate($row->summary, $sumlen), ENT_QUOTES); + $prtext = $priority_text[$row->priority]; + $sttext = $status_text[$row->status]; + $sctext = $scope_text[$row->scope]; + + if ($row->is_published) + print(""); + else if ($bgcolor == "#eeeebb") + print(""); + else + print(""); + print("" + ."" + ."" + ."" + ."" + ."" + .""); + if ($REMOTE_USER) + { + if ($row->manager_email != "") + $email = sanitize_email($row->manager_email); + else + $email = "Unassigned"; + + print(""); + } + print("\n"); + + if ($REMOTE_USER && $row->status >= $STR_STATUS_PENDING) + { + $textresult = db_query("SELECT * FROM strtext " + ."WHERE str_id = $row->id " + ."ORDER BY id DESC LIMIT 1"); + if ($textresult && db_count($textresult) > 0) + { + $textrow = db_next($textresult); + + if ($row->is_published) + print(""); + else if ($bgcolor == "#eeeebb") + print(""); + else + print(""); + + $email = sanitize_email($textrow->email); + $contents = quote_text(abbreviate($textrow->contents, 128)); + + print("" + ."" + ."\n"); + + db_free($textresult); + } + } + + if ($bgcolor == "#ddddaa") + $bgcolor = "#eeeebb"; + else + $bgcolor = "#ddddaa"; + } + + db_free($result); + + if ($REMOTE_USER) + { + print("\n"); + } + else + print("\n"); + + if ($count > $STR_PAGE_MAX) + { + print("\n"); + } + + print("
"); + if ($index > 0) + print("[ Previous $STR_PAGE_MAX ]"); + if ($REMOTE_USER) + print(""); + else + print(""); + if ($end < $count) + print("[ Next $STR_PAGE_MAX ]"); + print("
IdPriorityStatusScopeSummaryVersionLast UpdatedAssigned To
"); + if ($REMOTE_USER) + print(""); + print("" + ."$row->id$prtext$sttext$sctext$summabbr$row->str_version$date$email
$email$contents
"); + + print("Status: \n"); + + print("Priority: \n"); + + print("Assigned To: \n"); + + print("
Text: \n"); + + print(""); + print("
" + ."
"); + if ($index > 0) + print("[ Previous $STR_PAGE_MAX ]"); + if ($REMOTE_USER) + print(""); + else + print(""); + if ($end < $count) + print("[ Next $STR_PAGE_MAX ]"); + print("
"); + + if ($REMOTE_USER) + print("

"); + + print("

" + ."M/P = Machine/Printer, " + ."OS = Operating System." + ."

\n"); + } + + html_footer(); + break; + + case 'M' : // Modify STR + if ($REQUEST_METHOD == "POST") + { + if (array_key_exists("STATUS", $HTTP_POST_VARS)) + { + $time = time(); + $master_id = (int)$HTTP_POST_VARS["MASTER_ID"]; + $summary = db_escape_string($HTTP_POST_VARS["SUMMARY"]); + $subsystem = db_escape_string($HTTP_POST_VARS["SUBSYSTEM"]); + $create_email = db_escape_string($HTTP_POST_VARS["CREATE_EMAIL"]); + $manager_email = db_escape_string($HTTP_POST_VARS["MANAGER_EMAIL"]); + $modify_email = db_escape_string($managers[$REMOTE_USER]); + $contents = db_escape_string(trim($HTTP_POST_VARS["CONTENTS"])); + $message = $HTTP_POST_VARS["MESSAGE"]; + + db_query("UPDATE str SET " + ."master_id = $master_id, " + ."is_published = $HTTP_POST_VARS[IS_PUBLISHED], " + ."status = $HTTP_POST_VARS[STATUS], " + ."priority = $HTTP_POST_VARS[PRIORITY], " + ."scope = $HTTP_POST_VARS[SCOPE], " + ."summary = '$summary', " + ."subsystem = '$subsystem', " + ."str_version = '$HTTP_POST_VARS[STR_VERSION]', " + ."fix_version = '$HTTP_POST_VARS[FIX_VERSION]', " + ."create_email = '$create_email', " + ."manager_email = '$manager_email', " + ."modify_date = $time, " + ."modify_email = '$modify_email' " + ."WHERE id = $id"); + + if ($contents != "") + { + db_query("INSERT INTO strtext VALUES(0,$id,1,$time," + ."'$modify_email','$contents')"); + $contents = trim($HTTP_POST_VARS["CONTENTS"]) . "\n\n"; + } + + if ($message != "") + { + $contents = db_escape_string($messages[$message]); + + db_query("INSERT INTO strtext VALUES(0,$id,1,$time," + ."'$modify_email','$contents')"); + + $contents = $messages[$message] . "\n\n"; + } + + header("Location: $PHP_SELF?L$id$options"); + + notify_creator($id, "updated", $contents); + } + else if (array_key_exists("FILE_ID", $HTTP_POST_VARS)) + { + db_query("UPDATE strfile SET " + ."is_published = $HTTP_POST_VARS[IS_PUBLISHED] " + ."WHERE id = $HTTP_POST_VARS[FILE_ID]"); + + header("Location: $PHP_SELF?M$id$options"); + } + else if (array_key_exists("TEXT_ID", $HTTP_POST_VARS)) + { + db_query("UPDATE strtext SET " + ."is_published = $HTTP_POST_VARS[IS_PUBLISHED] " + ."WHERE id = $HTTP_POST_VARS[TEXT_ID]"); + + header("Location: $PHP_SELF?M$id$options"); + } + else + header("Location: $PHP_SELF?M$id$options"); + } + else + { + html_header("STR #$id"); + + print("

" + ."[ Return to STR List" + ." | Return to STR #$id" + ." | Post Text" + ." | Post File" + ." ]


\n"); + + $result = db_query("SELECT * FROM str WHERE id = $id"); + if (db_count($result) != 1) + { + print("

Error: STR #$id was not found!

\n"); + html_footer(); + exit(); + } + + $row = db_next($result); + + $create_email = htmlspecialchars($row->create_email); + $manager_email = htmlspecialchars($row->manager_email); + $summary = htmlspecialchars($row->summary, ENT_QUOTES); + + print("
" + ."

\n"); + + print("" + ."\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("" + ."\n"); + + print("" + ."\n"); + + print("" + ."\n"); + + print("" + ."\n"); + + print("" + ."\n"); + + print("" + ."\n"); + + print("\n"); + + print("\n"); + print("
Duplicate Of:
Published:"); + print("
Status:"); + print("\n"); + print("
Priority:"); + print("
Scope:"); + print("
Subsystem:
Summary:
Version:
Created By:
Assigned To:
Fix Version:
Text:"); + + print("
\n"); + + print("
" + ."

\n"); + + print("

Trouble Report Files: " + ."[ Post File ]" + ."

\n"); + + $result = db_query("SELECT * FROM strfile WHERE str_id = $id"); + + if (db_count($result) == 0) + print("

No files

\n"); + else + { + print("

\n" + ."" + ."\n"); + + $bgcolor = "#eeeebb"; + while ($row = db_next($result)) + { + $date = date("M d, Y", $row->date); + $time = date("H:m", $row->date); + $email = sanitize_email($row->email); + $filename = htmlspecialchars($row->filename); + + print("" + ."" + ."" + ."\n"); + + if ($bgcolor == "#ddddaa") + $bgcolor = "#eeeebb"; + else + $bgcolor = "#ddddaa"; + } + print("
Name/Time/DateFilename
$email
$time $date
" + ."
" + .""); + + if ($row->is_published) + print("" + .""); + else + print("" + .""); + + print("
" + ."$filename

\n"); + } + + db_free($result); + + print("

Trouble Report Dialog: " + ."[ Post Text ]" + ."

\n"); + + $result = db_query("SELECT * FROM strtext WHERE " + ."str_id = $id"); + + if (db_count($result) == 0) + print("

No text

\n"); + else + { + print("

\n" + ."" + ."\n"); + + $bgcolor = "#eeeebb"; + + while ($row = db_next($result)) + { + $date = date("M d, Y", $row->date); + $time = date("H:m", $row->date); + $email = sanitize_email($row->email); + $contents = quote_text($row->contents); + + print("" + ."" + ."" + ."\n"); + + if ($bgcolor == "#ddddaa") + $bgcolor = "#eeeebb"; + else + $bgcolor = "#ddddaa"; + } + print("
Name/Time/DateText
$email
$time $date
" + ."
" + .""); + + if ($row->is_published) + print("" + .""); + else + print("" + .""); + + print("
$contents

\n"); + } + + db_free($result); + + html_footer(); + } + break; + + case 'T' : // Post text for STR # + if ($REQUEST_METHOD == "POST") + { + $contents = $HTTP_POST_VARS["CONTENTS"]; + + if (array_key_exists("EMAIL", $HTTP_POST_VARS)) + { + $email = $HTTP_POST_VARS["EMAIL"]; + setcookie("FROM", "$email", time() + 57600, $PHP_SELF, $SERVER_NAME); + } + else if ($REMOTE_USER) + $email = $managers[$REMOTE_USER]; + else if (array_key_exists("FROM", $HTTP_COOKIE_VARS)) + $email = $HTTP_COOKIE_VARS["FROM"]; + else + $email = ""; + + if (ereg("Anonymous.*", $email)) + $email = ""; + + if ($email != "" && $contents != "") + $havedata = 1; + } + else + { + if ($REMOTE_USER) + $email = $managers[$REMOTE_USER]; + else + $email = $HTTP_COOKIE_VARS["FROM"]; + + $contents = ""; + + if (ereg("Anonymous.*", $email)) + $email = ""; + } + + if ($REQUEST_METHOD == "POST" && $havedata) + { + $time = time(); + $temail = db_escape_string($email); + $tcontents = db_escape_string($contents); + + db_query("INSERT INTO strtext VALUES(0,$id,1,$time,'$temail'," + ."'$tcontents')"); + + db_query("UPDATE str SET modify_date=$time, modify_email='$temail' " + ."WHERE id = $id"); + db_query("UPDATE str SET status=$STR_STATUS_PENDING WHERE " + ."id = $id AND status >= $STR_STATUS_ACTIVE AND " + ."status < $STR_STATUS_NEW"); + + header("Location: $PHP_SELF?L$id$options"); + + notify_creator($id, "updated", "$contents\n\n"); + } + else + { + html_header("Post Text For STR #$id"); + + print("

[ Return to " + ."STR #$id ]

\n"); + + if ($REQUEST_METHOD == "POST") + { + print("

Error: Please fill in the fields marked in " + ."bold red below and resubmit " + ."your trouble report.


\n"); + + $hstart = ""; + $hend = ""; + } + else + { + print("
\n"); + + $hstart = ""; + $hend = ""; + } + + print("
" + ."

\n"); + + print("\n"); + + print("\n"); + + print("\n"); + print("
"); + if ($email != "") + print("EMail:"); + else + print("${hstart}EMail:$hend"); + + $temp = htmlspecialchars($email); + print("
"); + if ($contents != "") + print("Text:"); + else + print("${hstart}Text:$hend"); + + $temp = htmlspecialchars($contents); + print("
" + ."

\n"); + html_footer(); + } + break; + + case 'F' : // Post file for STR # + if ($REQUEST_METHOD == "POST") + { + if (array_key_exists("EMAIL", $HTTP_POST_VARS)) + { + $email = $HTTP_POST_VARS["EMAIL"]; + setcookie("FROM", "$email", time() + 57600, $PHP_SELF, $SERVER_NAME); + } + else if ($REMOTE_USER) + $email = $managers[$REMOTE_USER]; + else if (array_key_exists("FROM", $HTTP_COOKIE_VARS)) + $email = $HTTP_COOKIE_VARS["FROM"]; + else + $email = ""; + + if (ereg("Anonymous.*", $email)) + $email = ""; + + if (array_key_exists("STRFILE", $HTTP_POST_FILES)) + { + $filename = $HTTP_POST_FILES['STRFILE']['name']; + if ($filename[0] == '.' || $filename[0] == '/') + $filename = ""; + } + else + $filename = ""; + + if ($email != "" && $filename != "") + $havedata = 1; + } + else + { + if ($REMOTE_USER) + $email = $managers[$REMOTE_USER]; + else + $email = $HTTP_COOKIE_VARS["FROM"]; + + $filename = ""; + + if (ereg("Anonymous.*", $email)) + $email = ""; + } + + if ($REQUEST_METHOD == "POST" && $havedata) + { + $time = time(); + $temail = db_escape_string($email); + $tmp_name = $HTTP_POST_FILES['STRFILE']['tmp_name']; + $name = $HTTP_POST_FILES['STRFILE']['name']; + $tname = db_escape_string($name); + + $infile = fopen($tmp_name, "rb"); + + if (!$infile) + { + html_header("Error"); + print("

Error! Unable to open file attachment!

\n"); + html_footer(); + exit(); + } + + mkdir("strfiles/$id"); + $outfile = fopen("strfiles/$id/$name", "wb"); + + if (!$outfile) + { + html_header("Error"); + print("

Error! Unable to save file attachment!

\n"); + html_footer(); + exit(); + } + + while ($data = fread($infile, 8192)) + fwrite($outfile, $data); + + fclose($infile); + fclose($outfile); + + db_query("INSERT INTO strfile VALUES(0,$id,1,$time,'$temail'," + ."'$tname')"); + + db_query("UPDATE str SET modify_date=$time, modify_email='$temail' " + ."WHERE id = $id"); + db_query("UPDATE str SET status=$STR_STATUS_PENDING WHERE " + ."id = $id AND status >= $STR_STATUS_ACTIVE AND " + ."status < $STR_STATUS_NEW"); + + header("Location: $PHP_SELF?L$id$options"); + + notify_creator($id, "updated", "Added file $name\n\n"); + } + else + { + html_header("Post File For STR #$id"); + + print("

[ Return to " + ."STR #$id ]

\n"); + + if ($REQUEST_METHOD == "POST") + { + print("

Error: Please fill in the fields marked in " + ."bold red below and resubmit " + ."your trouble report.


\n"); + + $hstart = ""; + $hend = ""; + } + else + { + print("
\n"); + + $hstart = ""; + $hend = ""; + } + + print("
" + .""); + + print("

\n"); + + print("\n"); + + print("\n"); + + print("\n"); + print("
"); + if ($email != "") + print("EMail:"); + else + print("${hstart}EMail:$hend"); + + $temp = htmlspecialchars($email); + print("
"); + if (array_key_exists("STRFILE", $HTTP_POST_FILES)) + print("File:"); + else + print("${hstart}File:$hend"); + + print("
" + ."

\n"); + html_footer(); + } + break; + + case 'N' : // Post new STR + $havedata = 0; + + if ($REQUEST_METHOD == "POST") + { + $npriority = $HTTP_POST_VARS["PRIORITY"]; + $nscope = $HTTP_POST_VARS["SCOPE"]; + $summary = $HTTP_POST_VARS["SUMMARY"]; + $version = $HTTP_POST_VARS["VERSION"]; + $contents = $HTTP_POST_VARS["CONTENTS"]; + + if (array_key_exists("EMAIL", $HTTP_POST_VARS)) + { + $email = $HTTP_POST_VARS["EMAIL"]; + setcookie("FROM", "$email", time() + 57600, $PHP_SELF, $SERVER_NAME); + } + else if ($REMOTE_USER) + $email = $managers[$REMOTE_USER]; + else if (array_key_exists("FROM", $HTTP_COOKIE_VARS)) + $email = $HTTP_COOKIE_VARS["FROM"]; + else + $email = ""; + + if (array_key_exists("STRFILE", $HTTP_POST_FILES)) + { + $filename = $HTTP_POST_FILES['STRFILE']['name']; + if ($filename[0] == '.' || $filename[0] == '/') + $filename = ""; + } + else + $filename = ""; + + if ($npriority && $nscope && $summary != "" && $email != "" && + $version != "" && $contents != "") + $havedata = 1; + } + else + { + if ($REMOTE_USER) + $email = $managers[$REMOTE_USER]; + else + $email = $HTTP_COOKIE_VARS["FROM"]; + + $npriority = 0; + $nscope = 0; + $summary = ""; + $version = ""; + $contents = ""; + $filename = ""; + } + + if (ereg("Anonymous.*", $email)) + $email = ""; + + if ($REQUEST_METHOD == "POST" && $havedata) + { + $time = time(); + $temail = db_escape_string($email); + $tsummary = db_escape_string($summary); + $tcontents = db_escape_string($contents); + + db_query("INSERT INTO str VALUES(0,0," + ."$HTTP_POST_VARS[IS_PUBLISHED],$STR_STATUS_NEW," + ."$npriority,$nscope,'$tsummary','','$version','',''," + ."$time,'$temail',$time,'$temail')"); + + $id = db_insertID(); + + db_query("INSERT INTO strtext VALUES(0,$id,1,$time,'$temail'," + ."'$tcontents')"); + + if ($filename != "") + { + $tmp_name = $HTTP_POST_FILES['STRFILE']['tmp_name']; + $name = $HTTP_POST_FILES['STRFILE']['name']; + $tname = db_escape_string($name); + + $infile = fopen($tmp_name, "rb"); + + if (!$infile) + { + html_header("Error"); + print("

Error! Unable to open file attachment!

\n"); + html_footer(); + exit(); + } + + mkdir("strfiles/$id"); + $outfile = fopen("strfiles/$id/$name", "wb"); + + if (!$outfile) + { + html_header("Error"); + print("

Error! Unable to save file attachment!

\n"); + html_footer(); + exit(); + } + + while ($data = fread($infile, 8192)) + fwrite($outfile, $data); + + fclose($infile); + fclose($outfile); + + db_query("INSERT INTO strfile VALUES(0,$id,1,$time,'$temail'," + ."'$tname')"); + } + + header("Location: $PHP_SELF?L$id$options"); + notify_creator($id, "created", "$contents\n\n"); + } + else + { + html_header("New STR"); + + print("

[ Return to " + ."STR List ]

\n"); + + if ($REQUEST_METHOD == "POST") + { + print("

Error: Please fill in the fields marked in " + ."bold red below and resubmit " + ."your trouble report.


\n"); + + $hstart = ""; + $hend = ""; + } + else + { + print("

This form is for reporting bugs and requesting features " + ."in the Mini-XML software. Thank you for helping us " + ."to make Mini-XML a better product!


\n"); + + $hstart = ""; + $hend = ""; + } + + print("
" + .""); + + print("

\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + + print("\n"); + print("
Security Advisory:" + ."
Status:5 - New
"); + if ($npriority > 0) + print("Priority:"); + else + print("${hstart}Priority:$hend"); + for ($i = 1; $i <= 5; $i ++) + { + print("$priority_long[$i]
"); + } + print("
"); + if ($nscope > 0) + print("Scope:"); + else + print("${hstart}Scope:$hend"); + for ($i = 1; $i <= 3; $i ++) + { + print("$scope_long[$i]
"); + } + print("
Subsystem:Unassigned
"); + if ($summary != "") + print("Summary:"); + else + print("${hstart}Summary:$hend"); + + $temp = htmlspecialchars($summary, ENT_QUOTES); + print("
"); + if ($version != "") + print("Version:"); + else + print("${hstart}Version:$hend"); + + print("
"); + if ($email != "") + print("EMail:"); + else + print("${hstart}EMail:$hend"); + + $temp = htmlspecialchars($email); + print("
Assigned To:Unassigned
Fix Version:Unassigned
"); + if ($contents != "") + print("Detailed Description of Problem:"); + else + print("${hstart}Detailed Description of Problem:$hend"); + + $temp = htmlspecialchars($contents); + print("
File:"); + + print("
" + ."

\n"); + html_footer(); + } + break; + + case 'U' : // Update notification status + // EMAIL and NOTIFICATION variables hold status; add/delete from strcc... + $havedata = 0; + + if ($REQUEST_METHOD != "POST") + { + html_header("STR Error"); + print("

The '$op' command requires a POST request!\n"); + html_footer(); + exit(); + } + + $notification = $HTTP_POST_VARS["NOTIFICATION"]; + $email = $HTTP_POST_VARS["EMAIL"]; + + if (($notification != "ON" && $notification != "OFF") || $email == "") + { + html_header("STR Error"); + print("

Please press your browsers back button and enter an " + ."EMail address and choose whether to receive notification " + ."messages.

\n"); + html_footer(); + exit(); + } + + setcookie("FROM", "$email", time() + 57600, $PHP_SELF, $SERVER_NAME); + + $result = db_query("SELECT * FROM strcc WHERE str_id = $id AND email = '$email'"); + + html_header("STR #$id Notifications"); + + if ($notification == "ON") + { + if ($result && db_count($result) > 0) + print("

Your email address has already been added to the " + ."notification list for STR #$id!

\n"); + else + { + db_query("INSERT INTO strcc VALUES(0,$id,'$email')"); + + print("

Your email address has been added to the notification list " + ."for STR #$id.

\n"); + } + } + else if ($result && db_count($result) > 0) + { + db_query("DELETE FROM strcc WHERE str_id = $id AND email = '$email'"); + + print("

Your email address has been removed from the notification list " + ."for STR #$id.

\n"); + } + else + { + print("

Your email address is not on the notification list for " + ."STR #$id!

\n"); + } + + if ($result) + db_free($result); + + print("

[ Return to STR #$id ]

\n"); + + html_footer(); + break; +} + +?> diff --git a/www/style.css b/www/style.css new file mode 100644 index 0000000..1bb21db --- /dev/null +++ b/www/style.css @@ -0,0 +1,30 @@ +BODY { + background: #ffffff; + font-family: sans-serif; + text-align: justify; +} + +A:link { + font-weight: bold; + text-decoration: none; + color: #00007f; +} + +A:visited { + font-weight: bold; + text-decoration: none; + color: #0000ff; +} + +A:hover { + font-weight: bold; + text-decoration: none; + color: #7f0000; +} + +A:active { + font-weight: bold; + text-decoration: underline; + color: #ff0000; +} +