PHP7 bug fix 4
[openemr.git] / interface / forms_admin / forms_admin.php
blob9ca752852b1f8bc6477d52bc0f4e34c098187e6b
1 <?php
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.
7 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
8 include_once("../globals.php");
9 include_once("$srcdir/registry.inc");
10 include_once("$srcdir/sql.inc");
11 if ($_GET['method'] == "enable"){
12 updateRegistered ( $_GET['id'], "state=1" );
14 elseif ($_GET['method'] == "disable"){
15 updateRegistered ( $_GET['id'], "state=0" );
17 elseif ($_GET['method'] == "install_db"){
18 $dir = getRegistryEntry ( $_GET['id'], "directory" );
19 if (installSQL ("$srcdir/../interface/forms/{$dir['directory']}"))
20 updateRegistered ( $_GET['id'], "sql_run=1" );
21 else
22 $err = xl('ERROR: could not open table.sql, broken form?');
24 elseif ($_GET['method'] == "register"){
25 registerForm ( $_GET['name'] ) or $err=xl('error while registering form!');
27 $bigdata = getRegistered("%") or $bigdata = false;
29 $formtarget = $GLOBALS['concurrent_layout'] ? "" : " target='Main'";
31 //START OUT OUR PAGE....
33 <html>
34 <head>
35 <?php html_header_show();?>
36 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
37 </head>
38 <body class="body_top">
39 <span class="title"><?php xl('Forms Administration','e');?></span>
40 <br><br>
41 <?php
42 foreach($_POST as $key=>$val) {
43 if (preg_match('/nickname_(\d+)/', $key, $matches)) {
44 $nickname_id = $matches[1];
45 sqlQuery("update registry set nickname='".$val."' where id=".$nickname_id);
47 if (preg_match('/category_(\d+)/', $key, $matches)) {
48 $category_id = $matches[1];
49 sqlQuery("update registry set category='".$val."' where id=".$category_id);
51 if (preg_match('/priority_(\d+)/', $key, $matches)) {
52 $priority_id = $matches[1];
53 sqlQuery("update registry set priority='".$val."' where id=".$priority_id);
59 <?php //ERROR REPORTING
60 if ($err)
61 echo "<span class=bold>$err</span><br><br>\n";
65 <?php //REGISTERED SECTION ?>
66 <span class=bold><?php xl('Registered','e');?></span><br>
67 <form method=POST action ='./forms_admin.php'<?php echo $formtarget; ?>>
68 <i><?php xl('click here to update priority, category and nickname settings','e'); ?></i>
69 <input type=submit name=update value='<?php xl('update','e'); ?>'><br>
70 <table border=0 cellpadding=1 cellspacing=2 width="500">
71 <tr>
72 <td> </td>
73 <td> </td>
74 <td> </td>
75 <td> </td>
76 <td> </td>
77 <td><?php xl('Priority ','e'); ?></td>
78 <td><?php xl('Category ','e'); ?></td>
79 <td><?php xl('Nickname','e'); ?></td>
80 </tr>
81 <?php
82 $color="#CCCCCC";
83 if ($bigdata != false)
84 foreach($bigdata as $registry)
86 $priority_category = sqlQuery("select priority, category, nickname from registry where id=".$registry['id']);
88 <tr>
89 <td bgcolor="<?php echo $color?>" width="2%">
90 <span class=text><?php echo $registry['id'];?></span>
91 </td>
92 <td bgcolor="<?php echo $color?>" width="30%">
93 <span class=bold><?php echo xl_form_title($registry['name']); ?></span>
94 </td>
95 <?php
96 if ($registry['sql_run'] == 0)
97 echo "<td bgcolor='$color' width='10%'><span class='text'>".xl('registered')."</span>";
98 elseif ($registry['state'] == "0")
99 echo "<td bgcolor='#FFCCCC' width='10%'><a class=link_submit href='./forms_admin.php?id={$registry['id']}&method=enable'$formtarget>".xl('disabled')."</a>";
100 else
101 echo "<td bgcolor='#CCFFCC' width='10%'><a class=link_submit href='./forms_admin.php?id={$registry['id']}&method=disable'$formtarget>".xl('enabled')."</a>";
102 ?></td>
103 <td bgcolor="<?php $color?>" width="10%">
104 <span class=text><?php
106 if ($registry['unpackaged'])
107 echo xl('PHP extracted','e');
108 else
109 echo xl('PHP compressed','e');
111 ?></span>
112 </td>
113 <td bgcolor="<?php echo $color?>" width="10%">
114 <?php
115 if ($registry['sql_run'])
116 echo "<span class=text>".xl('DB installed')."</span>";
117 else
118 echo "<a class=link_submit href='./forms_admin.php?id={$registry['id']}&method=install_db'$formtarget>".xl('install DB')."</a>";
120 </td>
121 <?php
122 echo "<td><input type=text size=4 name=priority_".$registry['id']." value='".$priority_category['priority']."'></td>";
123 echo "<td><input type=text size=8 name=category_".$registry['id']." value='".$priority_category['category']."'></td>";
124 echo "<td><input type=text size=8 name=nickname_".$registry['id']." value='".$priority_category['nickname']."'></td>";
126 </tr>
127 <?php
128 if ($color=="#CCCCCC")
129 $color="#999999";
130 else
131 $color="#CCCCCC";
132 } //end of foreach
134 </table>
135 <hr>
137 <?php //UNREGISTERED SECTION ?>
138 <span class=bold><?php xl('Unregistered','e');?></span><br>
139 <table border=0 cellpadding=1 cellspacing=2 width="500">
140 <?php
141 $dpath = "$srcdir/../interface/forms/";
142 $dp = opendir($dpath);
143 $color="#CCCCCC";
144 for ($i=0; false != ($fname = readdir($dp)); $i++)
145 if ($fname != "." && $fname != ".." && $fname != "CVS" && $fname != "LBF" &&
146 (is_dir($dpath.$fname) || stristr($fname, ".tar.gz") ||
147 stristr($fname, ".tar") || stristr($fname, ".zip") ||
148 stristr($fname, ".gz")))
149 $inDir[$i] = $fname;
151 // ballards 11/05/2005 fixed bug in removing registered form from the list
152 if ($bigdata != false)
154 foreach ( $bigdata as $registry )
156 $key = array_search($registry['directory'], $inDir) ; /* returns integer or FALSE */
157 unset($inDir[$key]);
161 foreach ( $inDir as $fname )
163 // added 8-2009 by BM - do not show the metric vitals form as option since deprecated
164 // also added a toggle in globals.php in case user wants the option to add this deprecated form
165 if (($fname == "vitalsM") && ($GLOBALS['disable_deprecated_metrics_form'])) continue;
167 if (stristr($fname, ".tar.gz") || stristr($fname, ".tar") || stristr($fname, ".zip") || stristr($fname, ".gz"))
168 $phpState = "PHP compressed";
169 else
170 $phpState = "PHP extracted";
172 <tr>
173 <td bgcolor="<?php echo $color?>" width="1%">
174 <span class=text> </span>
175 </td>
176 <td bgcolor="<?php echo $color?>" width="20%">
177 <?php
178 $form_title_file = @file($GLOBALS['srcdir']."/../interface/forms/$fname/info.txt");
179 if ($form_title_file)
180 $form_title = $form_title_file[0];
181 else
182 $form_title = $fname;
184 <span class=bold><?php echo xl_form_title($form_title); ?></span>
185 </td>
186 <td bgcolor="<?php echo $color?>" width="10%"><?php
187 if ($phpState == "PHP extracted")
188 echo '<a class=link_submit href="./forms_admin.php?name=' . urlencode($fname) . '&method=register"' . $formtarget . '>' . xl('register') . '</a>';
189 else
190 echo '<span class=text>' . xl('n/a') . '</span>';
191 ?></td>
192 <td bgcolor="<?php echo $color?>" width="20%">
193 <span class=text><?php echo xl($phpState); ?></span>
194 </td>
195 <td bgcolor="<?php echo $color?>" width="10%">
196 <span class=text><?php xl('n/a','e'); ?></span>
197 </td>
198 </tr>
199 <?php
200 if ($color=="#CCCCCC")
201 $color="#999999";
202 else
203 $color="#CCCCCC";
204 flush();
205 }//end of foreach
207 </table>
209 </body>
210 </html>