function recursive_stripslashes(&$value) { if (is_string($value)) { $value = stripslashes($value); } else { if (is_array($value)) { foreach ($value as $key => &$sub_value) { recursive_stripslashes($sub_value); } } } }
include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php"; $groups = $xoopsUser->getGroups(); $mid = getFormulizeModId(); $permissionToCheck = "module_admin"; $itemToCheck = $mid; $moduleToCheck = 1; // system module if (!$gperm_handler->checkRight($permissionToCheck, $itemToCheck, $groups, $moduleToCheck)) { print "Error: you do not have permission to save this data"; return; } // process all the submitted form values, looking for ones that can be immediately assigned to objects $processedValues = array(); foreach ($_POST as $k => $v) { if (!strstr($k, "-")) { // ignore fields with no hyphen continue; } list($class, $property) = explode("-", $k); $v = recursive_stripslashes($v); if (is_array($v) and $class != "elements") { // elements class is written using cleanVars so arrays are serialized automagically $v = serialize($v); } $processedValues[$class][$property] = $v; } $popupSave = isset($_GET['popupsave']) ? "_popup" : ""; // include the form-specific handler to invoke the necessary objects and insert them all in the DB if (file_exists(XOOPS_ROOT_PATH . "/modules/formulize/admin/save/" . str_replace(array("\\", "/"), "", $_POST['formulize_admin_handler']) . "_save" . $popupSave . ".php")) { include XOOPS_ROOT_PATH . "/modules/formulize/admin/save/" . str_replace(array("\\", "/"), "", $_POST['formulize_admin_handler']) . "_save" . $popupSave . ".php"; }
function recursive_stripslashes(&$var) { foreach ($var as $key => $value) { if (is_array($value)) { recursive_stripslashes($value); } else { $var[$key] = stripslashes($value); } } }
/** * Recursively calls stripslashes() on strings, arrays, and objects * * @param mixed $value Value to be processed * @return mixed Resulting value */ function recursive_stripslashes($value) { if (is_string($value)) { $value = stripslashes($value); } elseif (is_array($value)) { foreach ($value as &$tmp) { $tmp = $this->object->recursive_stripslashes($tmp); } } elseif (is_object($value)) { foreach (get_object_vars($value) as $key => $data) { $value->{$key} = recursive_stripslashes($data); } } return $value; }