Server IP : 104.21.38.3 / Your IP : 172.70.147.106 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/coircraft.com/wp-content/plugins/caldera-forms/classes/email/ |
Upload File : |
<?php /** * Class Caldera_Forms_Email_Prepare * * Methods for preparing email address strings. * Useful when dealing with strings that may be in the rfc822 format -- "name <[email protected]>" */ class Caldera_Forms_Email_Prepare{ /** * Get email from rfc822 string * * @since 1.6.0 * * @param string $rfc rfc822 (or not) email string * @return string|null */ public static function email_rfc822($rfc){ $regs = self::match_rfc($rfc); if ( ! empty( $regs )) { $parsed = $regs[0]; return $parsed; } return null; } /** * If possible, get name from rfc_822 string * * @since 1.6.0 * * @param string $rfc Email and name. SHOULD be in rfc_822 form * @return string|null Name only, if string was rfc_822. Null if not */ public static function email_from_rfc($rfc){ if (self::is_rfc822( $rfc)) { $regs = self::match_rfc($rfc); return str_replace(array($regs[0], '<', '>'), '', $rfc); } return null; } /** * Check if email is in rfc822 format * * @since 1.6.0 * * @param string $email Email to test * @return bool */ public static function is_rfc822($email){ return ! is_null( self::email_rfc822( $email)); } /** * Formats one or more emails into well formed array * * @since 1.6.0 * * NOTE: This array form is intentionally the same structure as expected by the fromArray() method for recipients in CF Pro and caldera-interop * * @param array|string $emails Emails to prepare * @return array */ public static function prepare_email_array( $emails ){ $prepared = array(); if( is_string( $emails ) ){ $emails = array( $emails ); } foreach ( $emails as &$email ){ if( self::is_rfc822( $email ) ){ $prepared[] = array( 'name' => self::email_from_rfc( $email ), 'email' => self::email_rfc822( $email ) ); }else{ $prepared[] = array( 'name' => '', 'email' => $email ); } } return $prepared; } /** * Check if string has comma and therefore is probably a list of email addresses * * @since 1.6.0 * * @param string $email_string Email address(s) * @return bool */ public static function is_list($email_string){ if( false !== strpos($email_string, ',' ) ){ return true; } return false; } /** * Use pregmatch to detech emails in rfc_822 string * * @since 1.6.0 * * @param string $rfc Email string * @return array */ protected static function match_rfc($rfc) { preg_match('/[\w\.\-+=*_]*@[\w\.\-+=*_]*/', $rfc, $regs); return $regs; } }