remove trailing whitespaces
[openemr.git] / contrib / util / dupecheck / Utils.php
blob6f5e9560d030a51b9a166a447daff2151193c9aa
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)
21 $strInfo = sprintf("%s&nbsp;", $strInfo);
22 $intN--;
25 return $strInfo;
30 * properly quote the passed value
31 * or return NULL if there is no value at all
33 function SQLQuote ($strValue)
35 /* are we quoting a number or string? */
37 if (is_string($strValue) == true) {
38 /* It's a string */
40 if (strlen($strValue) == 0) { return "NULL"; }
41 if ($strValue == NULL) { return "NULL"; }
42 /* remove any '\' values */
43 $strValue = preg_replace("/\\\/", '', $strValue);
44 return "'". preg_replace("/\'/", "''", $strValue) ."'";
46 else {
47 /* It's a number */
49 if (is_null($strValue)) { return "NULL"; }
50 if ($strValue == 0) { return "0"; }
51 else { return $strValue; }
57 * Get the HTML (GET or POST) parameters
60 function GetParameters ()
62 if ($_SERVER["REQUEST_METHOD"]=="POST") {
63 foreach ($_POST as $key => $value) {
64 // echo $key."=".$value."<br>\n";
65 $parameters[$key] = $value;
68 else if ($_SERVER["REQUEST_METHOD"]=="GET") {
69 foreach ($_GET as $key => $value) {
70 $parameters[$key] = $value;
73 return $parameters;