2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
10 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
11 require_once("../globals.php");
12 require_once("$srcdir/acl.inc");
13 require_once("$phpgacl_location/gacl_api.class.php");
14 require_once("$srcdir/registry.inc");
16 if ($_GET['method'] == "enable") {
17 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
20 updateRegistered($_GET['id'], "state=1");
21 } elseif ($_GET['method'] == "disable") {
22 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
25 updateRegistered($_GET['id'], "state=0");
26 } elseif ($_GET['method'] == "install_db") {
27 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
30 $dir = getRegistryEntry($_GET['id'], "directory");
31 if (installSQL("$srcdir/../interface/forms/{$dir['directory']}")) {
32 updateRegistered($_GET['id'], "sql_run=1");
34 $err = xl('ERROR: could not open table.sql, broken form?');
36 } elseif ($_GET['method'] == "register") {
37 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
40 registerForm($_GET['name']) or $err=xl('error while registering form!');
43 $bigdata = getRegistered("%") or $bigdata = false;
45 //START OUT OUR PAGE....
49 <?php
html_header_show();?
>
50 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
52 <body
class="body_top">
53 <span
class="title"><?php
echo xlt('Forms Administration');?
></span
>
57 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
60 foreach ($_POST as $key => $val) {
61 if (preg_match('/nickname_(\d+)/', $key, $matches)) {
62 sqlQuery("update registry set nickname = ? where id = ?", array($val, $matches[1]));
63 } else if (preg_match('/category_(\d+)/', $key, $matches)) {
64 sqlQuery("update registry set category = ? where id = ?", array($val, $matches[1]));
65 } else if (preg_match('/priority_(\d+)/', $key, $matches)) {
66 sqlQuery("update registry set priority = ? where id = ?", array($val, $matches[1]));
67 } else if (preg_match('/aco_spec_(\d+)/', $key, $matches)) {
68 sqlQuery("update registry set aco_spec = ? where id = ?", array($val, $matches[1]));
75 <?php
//ERROR REPORTING
77 echo "<span class=bold>" . text($err) . "</span><br><br>\n";
81 <?php
//REGISTERED SECTION ?>
82 <span
class=bold
><?php
echo xlt('Registered');?
></span
><br
>
83 <form method
=POST action
='./forms_admin.php'>
84 <i
><?php
echo xlt('click here to update priority, category, nickname and access control settings'); ?
></i
>
85 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
86 <input type
='submit' name
='update' value
='<?php echo xla('update
'); ?>'><br
>
87 <table border
=0 cellpadding
=1 cellspacing
=2 width
="500">
94 <td
><?php
echo xlt('Priority'); ?
> </td
>
95 <td
><?php
echo xlt('Category'); ?
> </td
>
96 <td
><?php
echo xlt('Nickname'); ?
> </td
>
97 <td
><?php
echo xlt('Access Control'); ?
></td
>
101 if ($bigdata != false) {
102 foreach ($bigdata as $registry) {
103 $priority_category = sqlQuery(
104 "select priority, category, nickname, aco_spec from registry where id = ?",
105 array($registry['id'])
109 <td bgcolor
="<?php echo $color; ?>" width
="2%">
110 <span
class='text'><?php
echo text($registry['id']); ?
></span
>
112 <td bgcolor
="<?php echo attr($color); ?>" width
="30%">
113 <span
class='bold'><?php
echo text(xl_form_title($registry['name'])); ?
></span
>
116 if ($registry['sql_run'] == 0) {
117 echo "<td bgcolor='" . attr($color) . "' width='10%'><span class='text'>" . xlt('registered') . "</span>";
118 } elseif ($registry['state'] == "0") {
119 echo "<td bgcolor='#FFCCCC' width='10%'><a class='link_submit' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=enable&csrf_token_form=" . attr_url(collectCsrfToken()) . "'>" . xlt('disabled') . "</a>";
121 echo "<td bgcolor='#CCFFCC' width='10%'><a class='link_submit' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=disable&csrf_token_form=" . attr_url(collectCsrfToken()) . "'>" . xlt('enabled') . "</a>";
124 <td bgcolor
="<?php echo attr($color); ?>" width
="10%">
125 <span
class='text'><?php
126 if ($registry['unpackaged']) {
127 echo xlt('PHP extracted');
129 echo xlt('PHP compressed');
133 <td bgcolor
="<?php echo attr($color); ?>" width
="10%">
135 if ($registry['sql_run']) {
136 echo "<span class='text'>" . xlt('DB installed') . "</span>";
138 echo "<a class='link_submit' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=install_db&csrf_token_form=" . attr_url(collectCsrfToken()) . "'>" . xlt('install DB') . "</a>";
143 echo "<td><input type='text' size='4' name='priority_" . attr($registry['id']) . "' value='" . attr($priority_category['priority']) . "'></td>";
144 echo "<td><input type='text' size='10' name='category_" . attr($registry['id']) . "' value='" . attr($priority_category['category']) . "'></td>";
145 echo "<td><input type='text' size='10' name='nickname_" . attr($registry['id']) . "' value='" . attr($priority_category['nickname']) . "'></td>";
147 echo "<select name='aco_spec_" . attr($registry['id']) . "'>";
148 echo "<option value=''></option>";
149 echo gen_aco_html_options($priority_category['aco_spec']);
155 if ($color=="#CCCCCC") {
166 <?php
//UNREGISTERED SECTION ?>
167 <span
class='bold'><?php
echo xlt('Unregistered'); ?
></span
><br
>
168 <table border
=0 cellpadding
=1 cellspacing
=2 width
="500">
170 $dpath = "$srcdir/../interface/forms/";
171 $dp = opendir($dpath);
173 for ($i=0; false != ($fname = readdir($dp)); $i++
) {
174 if ($fname != "." && $fname != ".." && $fname != "CVS" && $fname != "LBF" &&
175 (is_dir($dpath.$fname) ||
stristr($fname, ".tar.gz") ||
176 stristr($fname, ".tar") ||
stristr($fname, ".zip") ||
177 stristr($fname, ".gz"))) {
182 // ballards 11/05/2005 fixed bug in removing registered form from the list
183 if ($bigdata != false) {
184 foreach ($bigdata as $registry) {
185 $key = array_search($registry['directory'], $inDir) ; /* returns integer or FALSE */
190 foreach ($inDir as $fname) {
191 if (stristr($fname, ".tar.gz") ||
stristr($fname, ".tar") ||
stristr($fname, ".zip") ||
stristr($fname, ".gz")) {
192 $phpState = "PHP compressed";
194 $phpState = "PHP extracted";
198 <td bgcolor
="<?php echo $color?>" width
="1%">
199 <span
class=text
> </span
>
201 <td bgcolor
="<?php echo $color?>" width
="20%">
203 $form_title_file = @file
($GLOBALS['srcdir']."/../interface/forms/$fname/info.txt");
204 if ($form_title_file) {
205 $form_title = $form_title_file[0];
207 $form_title = $fname;
210 <span
class=bold
><?php
echo text(xl_form_title($form_title)); ?
></span
>
212 <td bgcolor
="<?php echo $color?>" width
="10%"><?php
213 if ($phpState == "PHP extracted") {
214 echo '<a class=link_submit href="./forms_admin.php?name=' . attr_url($fname) . '&method=register&csrf_token_form=' . attr_url(collectCsrfToken()) . '">' . xlt('register') . '</a>';
216 echo '<span class=text>' . xlt('n/a') . '</span>';
219 <td bgcolor
="<?php echo $color?>" width
="20%">
220 <span
class=text
><?php
echo xlt($phpState); ?
></span
>
222 <td bgcolor
="<?php echo $color?>" width
="10%">
223 <span
class=text
><?php
echo xlt('n/a'); ?
></span
>
227 if ($color=="#CCCCCC") {