Highway to PSR2
[openemr.git] / contrib / util / dupecheck / Utils.php
blobd5ab148890d0198f043febd8626815c20c5a3f91
1 <?php
3 /*
4 * These are a handful of useful utilities
5 * Functions that don't belong anyplace else at
6 * the moment end up here
7 */
11 * Pad the end of a string with &nbsp; up to
12 * the max length of the string
15 function NBSPPadSuffix($strInfo, $intMaxLength)
17 $intN = $intMaxLength - strlen($strInfo);
19 while ($intN > 0) {
20 $strInfo = sprintf("%s&nbsp;", $strInfo);
21 $intN--;
24 return $strInfo;
29 * properly quote the passed value
30 * or return NULL if there is no value at all
32 function SQLQuote($strValue)
34 /* are we quoting a number or string? */
36 if (is_string($strValue) == true) {
37 /* It's a string */
39 if (strlen($strValue) == 0) {
40 return "NULL";
43 if ($strValue == null) {
44 return "NULL";
47 /* remove any '\' values */
48 $strValue = preg_replace("/\\\/", '', $strValue);
49 return "'". preg_replace("/\'/", "''", $strValue) ."'";
50 } else {
51 /* It's a number */
53 if (is_null($strValue)) {
54 return "NULL";
57 if ($strValue == 0) {
58 return "0";
59 } else {
60 return $strValue;
67 * Get the HTML (GET or POST) parameters
70 function GetParameters()
72 if ($_SERVER["REQUEST_METHOD"]=="POST") {
73 foreach ($_POST as $key => $value) {
74 // echo $key."=".$value."<br>\n";
75 $parameters[$key] = $value;
77 } else if ($_SERVER["REQUEST_METHOD"]=="GET") {
78 foreach ($_GET as $key => $value) {
79 $parameters[$key] = $value;
83 return $parameters;