Commit f713cd7d8dd3d4046716a965fdb083459f57be68
1 parent
49100a6f
Moved sanitize function to the util directory.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2916 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
47 additions
and
1 deletions
lib/util/sanitize.inc
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id$ | ||
| 5 | + * | ||
| 6 | + * This page is meant to provide functions to prevent XSS cracks. | ||
| 7 | + * | ||
| 8 | + * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 9 | + * | ||
| 10 | + * This program is free software; you can redistribute it and/or modify | ||
| 11 | + * it under the terms of the GNU General Public License as published by | ||
| 12 | + * the Free Software Foundation; either version 2 of the License, or | ||
| 13 | + * (at your option) any later version. | ||
| 14 | + * | ||
| 15 | + * This program is distributed in the hope that it will be useful, | ||
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | + * GNU General Public License for more details. | ||
| 19 | + * | ||
| 20 | + * You should have received a copy of the GNU General Public License | ||
| 21 | + * along with this program; if not, write to the Free Software | ||
| 22 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 23 | + * | ||
| 24 | + * @version $Revision$ | ||
| 25 | + * @author Andrew Glen-Young <andrew@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 26 | + */ | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * Accepts a web encoded string and outputs a "clean" string. | ||
| 30 | + */ | ||
| 31 | + | ||
| 32 | +function sanitize($string) { | ||
| 33 | + // This should be set if you've read the INSTALL instructions. | ||
| 34 | + // Better to be safe though. | ||
| 35 | + if (get_magic_quotes_gpc()) { | ||
| 36 | + $string = strip_tags(urldecode(trim($string))); | ||
| 37 | + } else { | ||
| 38 | + $string = addslashes(strip_tags(urldecode(trim($string)))); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + // This might be a little too aggressive | ||
| 42 | + $pattern = "([^[:alpha:]|^_\.\ \:-])"; | ||
| 43 | + return ereg_replace($pattern, '', $string); | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +?> |
presentation/login.php
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | // main library routines and defaults | 3 | // main library routines and defaults |
| 4 | require_once("../config/dmsDefaults.php"); | 4 | require_once("../config/dmsDefaults.php"); |
| 5 | -require_once("../lib/sanitize.inc"); | 5 | +require_once("../lib/util/sanitize.inc"); |
| 6 | /** | 6 | /** |
| 7 | * $Id$ | 7 | * $Id$ |
| 8 | * | 8 | * |