} if ( ! preg_match( '/;\s*samesite\s*=/i', $cookie_header ) ) { $cookie_header .= '; SameSite=Lax'; } header( 'Set-Cookie: ' . $cookie_header, false ); } } // Configure PHP session cookies before a session is started, if the site uses // PHP sessions. WordPress itself does not require PHP sessions for login. if ( ! headers_sent() && function_exists( 'session_status' ) && PHP_SESSION_NONE === session_status() ) { @ini_set( 'session.cookie_httponly', '1' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged @ini_set( 'session.cookie_samesite', 'Lax' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged @ini_set( 'session.use_only_cookies', '1' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged if ( function_exists( 'is_ssl' ) && is_ssl() ) { @ini_set( 'session.cookie_secure', '1' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } } // Ensure WordPress authentication cookies use Secure when HTTPS is detected. // WordPress retains responsibility for HttpOnly on its authentication cookies. add_filter( 'secure_auth_cookie', function ( $secure ) { return ( function_exists( 'is_ssl' ) && is_ssl() ) ? true : $secure; }, 99 ); add_filter( 'secure_logged_in_cookie', function ( $secure ) { return ( function_exists( 'is_ssl' ) && is_ssl() ) ? true : $secure; }, 99 ); // Modify outgoing cookies at the final header stage. if ( function_exists( 'header_register_callback' ) ) { header_register_callback( 'neo_vapt_harden_set_cookie_headers' ); } /* ------------------------------------------------------------------------- * W3: Contact Form 7 server-side validation * ---------------------------------------------------------------------- */ /** * CF7 field names covered by this validation. * * Ensure the actual Contact Form 7 form tags use one of these exact names. * * @return array */ function neo_vapt_cf7_validated_field_names() { return array( 'organisation', 'organization', 'job-title', 'designation', ); } /** * Validate organisation, job title, and designation text fields. * * Empty values are left to Contact Form 7's required-field validation. * * @param WPCF7_Validation $result Validation result. * @param WPCF7_FormTag $tag Current form tag. * @return WPCF7_Validation */ function neo_vapt_validate_cf7_business_fields( $result, $tag ) { if ( ! is_object( $tag ) || empty( $tag->name ) ) { return $result; } $field_name = (string) $tag->name; if ( ! in_array( $field_name, neo_vapt_cf7_validated_field_names(), true ) ) { return $result; } $raw_value = isset( $_POST[ $field_name ] ) ? wp_unslash( $_POST[ $field_name ] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( ! is_scalar( $raw_value ) ) { $result->invalidate( $tag, 'Please enter a valid value.' ); return $result; } $value = trim( (string) $raw_value ); // Required-field validation remains the responsibility of CF7 text* tags. if ( '' === $value ) { return $result; } $length = function_exists( 'mb_strlen' ) ? mb_strlen( $value, 'UTF-8' ) : strlen( $value ); if ( $length < 2 || $length > 100 ) { $result->invalidate( $tag, 'Please enter between 2 and 100 characters.' ); return $result; } // Reject markup, URL-like input, and common domain-name patterns. if ( preg_match( '/[<>"{}]/u', $value ) || preg_match( '~(https?://|www\.|ftp://|//)~i', $value ) || preg_match( '/\b[a-z0-9-]+\.(com|net|org|in|io|ru|xyz|info|biz|co)\b/i', $value ) ) { $result->invalidate( $tag, 'Links and special characters are not allowed in this field.' ); return $result; } // Permit letters (including Unicode), marks, numbers, spaces and basic // business-name punctuation. if ( ! preg_match( '/^[\p{L}\p{M}0-9 .,&()\'\/-]+$/u', $value ) ) { $result->invalidate( $tag, 'Please use letters, numbers and basic punctuation only.' ); } return $result; } add_filter( 'wpcf7_validate_text', 'neo_vapt_validate_cf7_business_fields', 20, 2 ); https://www.neosofttech.com/post-sitemap.xml 2026-11-02T10:57:43+00:00 https://www.neosofttech.com/page-sitemap.xml 2026-11-02T08:32:55+00:00 https://www.neosofttech.com/neosoft-services-sitemap.xml 2026-10-28T05:56:02+00:00 https://www.neosofttech.com/news-sitemap.xml 2025-01-27T09:01:08+00:00 https://www.neosofttech.com/casestudies-sitemap.xml 2026-11-09T11:06:04+00:00 https://www.neosofttech.com/offices-sitemap.xml 2026-06-02T09:31:54+00:00 https://www.neosofttech.com/article-sitemap.xml 2026-11-05T10:34:19+00:00 https://www.neosofttech.com/client-sitemap.xml 2026-04-17T08:04:54+00:00 https://www.neosofttech.com/pressrelease-sitemap.xml 2026-11-05T07:12:49+00:00 https://www.neosofttech.com/event-sitemap.xml 2026-11-06T10:18:42+00:00 https://www.neosofttech.com/clientstories-sitemap.xml 2026-07-08T06:31:19+00:00 https://www.neosofttech.com/category-sitemap.xml 2026-11-02T10:57:43+00:00 https://www.neosofttech.com/casestudycategory-sitemap.xml 2026-11-09T11:06:04+00:00 https://www.neosofttech.com/officelocation-sitemap.xml 2026-06-02T09:31:54+00:00 https://www.neosofttech.com/servicescategory-sitemap.xml 2026-10-28T05:56:02+00:00 https://www.neosofttech.com/technology_products-sitemap.xml 2026-11-05T10:34:19+00:00 https://www.neosofttech.com/casestudyindustries-sitemap.xml 2026-11-09T11:06:04+00:00 https://www.neosofttech.com/author-sitemap.xml 2026-10-22T10:50:30+00:00