/** * Validate admin level webservices token, with or without username * * @param $h Webservices * token (admin users only) * @param $u Username * (admin users only) * @return boolean FALSE if invalid, string username if valid */ function webservices_validate_admin($h, $u) { $ret = false; $c_u = webservices_validate($h, $u); if ($u) { $status = user_getfieldbyusername($c_u, 'status'); if ($status == 2) { $ret = $c_u; } } return $ret; }
/** * Validate admin level webservices token, with or without username * * @param $h Webservices * token (admin users only) * @param $u Username * (admin users only) * @return boolean FALSE if invalid, string username if valid */ function webservices_validate_admin($h, $u) { $ret = false; if (preg_match('/^(.+)@(.+)\\.(.+)$/', $u)) { $u = user_email2username($u); } $c_u = webservices_validate($h, $u); if ($u) { $status = user_getfieldbyusername($c_u, 'status'); if ($status == 2) { $ret = $c_u; } } return $ret; }
_log("webservices logged in u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices"); } else { _log("webservices invalid login u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices"); } } else { _log("webservices error unable to remove registry u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices"); } } else { _log("webservices invalid user u:" . $u . " ip:" . $_SERVER['REMOTE_ADDR'] . " op:" . _OP_, 3, "webservices"); } // redirect to index.php no matter what header('Location: index.php'); exit; break; case "QUERY": if ($u = webservices_validate($h, $u)) { $json = webservices_query($u); } else { $json['status'] = 'ERR'; $json['error'] = '100'; } $log_this = FALSE; break; default: if (_OP_) { // output do not require valid login // output must not be empty $ret = webservices_output(_OP_, $_REQUEST, $returns); if ($ret['modified'] && $ret['param']['content']) { ob_end_clean(); if ($ret['param']['content-type'] && $ret['param']['charset']) {