From 22de8c3b298601951b213b3d6612e33f8fdf968a Mon Sep 17 00:00:00 2001
From: Michael R Sweet Command '\$op' requires an ID!\\n\");\n");
+print(" html_footer();\n");
+print(" exit();\n");
+print(" }\n");
+print("\n");
+print(" if (\$op == 'N' && \$id)\n");
+print(" {\n");
+print(" html_header(\"$tname Error\");\n");
+print(" print(\" Command '\$op' may not have an ID!\\n\");\n");
+print(" html_footer();\n");
+print(" exit();\n");
+print(" }\n");
+print("}\n");
+print("else\n");
+print("{\n");
+print(" \$op = 'L';\n");
+print(" \$id = 0;\n");
+print("}\n");
+print("\n");
+print("switch (\$op)\n");
+print("{\n");
+print(" case 'D' : // Delete $tname\n");
+print(" if (\$REQUEST_METHOD == \"POST\")\n");
+print(" {\n");
+print(" db_query(\"DELETE FROM $table WHERE id = \$id\");\n");
+print("\n");
+print(" header(\"Location: \$PHP_SELF?L\");\n");
+print(" }\n");
+print(" else\n");
+print(" {\n");
+print(" \$result = db_query(\"SELECT * FROM $table WHERE id = \$id\");\n");
+print(" if (db_count(\$result) != 1)\n");
+print(" {\n");
+print(" print(\" Error: $tname #\$id was not found!
Error: $tname #\$id was not found!
\\n\");\n"); +print(" html_footer();\n"); +print(" exit();\n"); +print(" }\n"); +print("\n"); +print(" \$row = db_next(\$result);\n"); +print("\n"); +print(" html_startlinks(1);\n"); +print(" html_link(\"Return to $tname List\", \"\$PHP_SELF?L\");\n"); +print(" html_link(\"Modify $tname\", \"\$PHP_SELF?M\$id\");\n"); +print(" html_link(\"Delete $tname #\$id\", \"\$PHP_SELF?D\$id\");\n"); +print(" html_endlinks();\n"); +print("\n"); +print(" print(\"This $tname is \"\n"); +print(" .\"currently hidden from public view. | |
---|---|
$name: | " + ."\$temp |
No ${tname}s found.
\\n\");\n"); +print("\n"); +print(" html_footer();\n"); +print(" exit();\n"); +print(" }\n"); +print("\n"); +print(" html_start_table(array("); + +sqlite_seek($result, 0); +$firsttime = 1; +while ($row = sqlite_fetch_array($result)) + switch ($row['name']) + { + case "id" : + case "create_date" : + case "create_user" : + case "modify_date" : + case "modify_user" : + case "is_published" : + break; + + default : + $name = ucwords(str_replace('_', ' ', $row['name'])); + if ($firsttime) + { + print(",\"$name\""); + $firsttime = 0; + } + else + print(",\"$name\""); + break; + } + +print("));\n"); +print("\n"); +print(" while (\$row = db_next(\$result))\n"); +print(" {\n"); +print(" html_start_row();\n"); +print("\n"); + +sqlite_seek($result, 0); +while ($row = sqlite_fetch_array($result)) + switch ($row['name']) + { + case "id" : + case "create_date" : + case "create_user" : + case "modify_date" : + case "modify_user" : + case "is_published" : + break; + + default : + print(" \$temp = htmlspecialchars(\$row['$row[name]']);\n"); + print(" print(\"Error: $tname #\$id was not found!
\\n\");\n"); +print(" html_footer();\n"); +print(" exit();\n"); +print(" }\n"); +print("\n"); +print(" \$row = db_next(\$result);\n"); +print("\n"); +print(" print(\"\\n\");\n"); +print("\n"); +print(" html_footer();\n"); +print(" }\n"); +print(" break;\n"); +print("\n"); +print(" case 'N' : // Post new $tname\n"); +print(" if (\$REQUEST_METHOD == \"POST\")\n"); +print(" {\n"); +print(" \$date = time();\n"); + +sqlite_seek($result, 0); +while ($row = sqlite_fetch_array($result)) + switch ($row['name']) + { + case "id" : + case "create_date" : + case "create_user" : + case "modify_date" : + case "modify_user" : + break; + + default : + $form = strtoupper($row['name']); + if ($row['type'] == "INTEGER") + print(" \$$row[name] = db_escape(\$_POST[\"$form\"]);\n"); + else + print(" \$$row[name] = db_escape(\$_POST[\"$form\"]);\n"); + break; + } + +print("\n"); +print(" db_query(\"INSERT INTO $table VALUES(0,\"\n"); + +sqlite_seek($result, 0); +while ($row = sqlite_fetch_array($result)) + switch ($row['name']) + { + case "id" : + case "create_date" : + case "create_user" : + case "modify_date" : + case "modify_user" : + break; + + default : + if ($row['type'] == "INTEGER") + print(" .\"\$$row[name],\"\n"); + else + print(" .\"'\$$row[name]',\"\n"); + break; + } + +print(" .\"\$date,'\$LOGIN_USER',\$date,'\$LOGIN_USER')\");\n"); +print("\n"); +print(" \$id = db_insert_id();\n"); +print("\n"); +print(" header(\"Location: \$PHP_SELF?L\$id\");\n"); +print(" break;\n"); +print(" }\n"); +print("\n"); +print(" html_header(\"New $tname\");\n"); +print("\n"); +print(" html_startlinks(1);\n"); +print(" html_link(\"Return to $tname List\", \"\$PHP_SELF?L\");\n"); +print(" html_endlinks();\n"); +print("\n"); +print(" print(\"\\n\");\n"); +print("\n"); +print(" html_footer();\n"); +print(" break;\n"); +print("}\n"); +print("\n"); +print("\n"); +print("//\n"); +print("// End of \"\$Id\$\".\n"); +print("//\n"); +print("?>\n"); + +?> diff --git a/www/phplib/html.php b/www/phplib/html.php index d235ea7..eb4371c 100644 --- a/www/phplib/html.php +++ b/www/phplib/html.php @@ -1,6 +1,6 @@ " ."