Changeset 804


Ignore:
Timestamp:
Jan 13, 2024 5:56:09 PM (4 months ago)
Author:
anonymous
Message:

Add trimFormData() function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r796 r804  
    13071307
    13081308    $_REQUEST[$key] = $val;
     1309}
     1310
     1311/*
     1312* Trims whitespace from request data.
     1313*
     1314* @access   public
     1315* @return   void
     1316* @author   Quinn Comendant <quinn@strangecode.com>
     1317* @version  1.0
     1318* @since    12 Jan 2024 13:15:02
     1319*/
     1320function trimFormData()
     1321{
     1322    switch (strtoupper(getenv('REQUEST_METHOD'))) {
     1323    case 'POST':
     1324        array_walk_recursive($_POST, function(&$v) { if (isset($v)) { $v = trim($v); } });
     1325        break;
     1326
     1327    case 'GET':
     1328        array_walk_recursive($_GET, function(&$v) { if (isset($v)) { $v = trim($v); } });
     1329        break;
     1330    }
     1331
     1332    array_walk_recursive($_REQUEST, function(&$v) { if (isset($v)) { $v = trim($v); } });
    13091333}
    13101334
Note: See TracChangeset for help on using the changeset viewer.