コード例 #1
0
ファイル: ext_mail.cpp プロジェクト: shixiao/hhvm
bool HHVM_FUNCTION(mail,
                   const String& to,
                   const String& subject,
                   const String& message,
                   const String& additional_headers /* = null_string */,
                   const String& additional_parameters /* = null_string */) {

  // replace \0 with spaces
  String to2 = string_replace(to, s_zero, s_space);
  String subject2 = string_replace(subject, s_zero, s_space);
  String message2 = string_replace(message, s_zero, s_space);
  String headers2;
  if (!additional_headers.empty()) {
    headers2 = string_replace(additional_headers, s_zero, s_space);
  }
  String params2;
  if (!additional_parameters.empty()) {
    params2 = string_replace(additional_parameters, s_zero, s_space);
  }

  to2 = php_trim(to2);
  subject2 = php_trim(subject2);

  if (!RuntimeOption::MailForceExtraParameters.empty()) {
    params2 = string_escape_shell_cmd(
      RuntimeOption::MailForceExtraParameters.c_str());
  } else {
    params2 = string_escape_shell_cmd(params2.c_str());
  }

  return php_mail(to2, subject2, message2, headers2, params2);
}
コード例 #2
0
ファイル: ext_mail.cpp プロジェクト: 292388900/hhvm
bool HHVM_FUNCTION(mail,
                   const String& to,
                   const String& subject,
                   const String& message,
                   const String& additional_headers /* = null_string */,
                   const String& additional_parameters /* = null_string */) {

  // replace \0 with spaces
  String to2 = string_replace(to, s_zero, s_space);
  String subject2 = string_replace(subject, s_zero, s_space);
  String message2 = string_replace(message, s_zero, s_space);
  String headers2;
  if (!additional_headers.empty()) {
    headers2 = string_replace(additional_headers, s_zero, s_space);
    headers2 = php_rtrim(headers2);

    if (php_mail_detect_multiple_crlf(headers2)) {
      raise_warning("Multiple or malformed newlines found in additional_headers");
      return false;
    }
  }
  String params2;
  if (!additional_parameters.empty()) {
    params2 = string_replace(additional_parameters, s_zero, s_space);
  }

  to2 = php_trim(to2);
  subject2 = php_trim(subject2);

  if (!RuntimeOption::MailForceExtraParameters.empty()) {
    params2 = string_escape_shell_cmd(
      RuntimeOption::MailForceExtraParameters.c_str());
  } else {
    params2 = string_escape_shell_cmd(params2.c_str());
  }

  return php_mail(to2, subject2, message2, headers2, params2);
}
コード例 #3
0
static void notifyerror_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) /* {{{ */
{
	va_list args_cp;
	char *buffer, *error_message, *header;
	int log_level = 0;
	va_copy(args_cp, args);
	vspprintf(&buffer, PG(log_errors_max_len), format, args);
	spprintf(&error_message, 0, "%s\nin %s on line %d", buffer, error_filename, error_lineno);
	efree(buffer);

	switch (type) {
		case E_CORE_ERROR:
		case E_ERROR:
		case E_COMPILE_ERROR:
		case E_USER_ERROR:
			header = "PHP Fatal Error";
			log_level = 1;
			break;
		case E_RECOVERABLE_ERROR:
			header = "PHP Recoverable Fatal Error";
			log_level = 2;
			break;
		case E_WARNING:
		case E_CORE_WARNING:
		case E_COMPILE_WARNING:
			header = "PHP Warning";
			log_level = 2;
			break;
		case E_PARSE:
			header = "PHP Parse Error";
			log_level = 1;
			break;
		case E_NOTICE:
		case E_USER_NOTICE:
			header = "PHP Notice";
			log_level = 2;
			break;
		case E_STRICT:
			header = "PHP Strict Error";
			log_level = 2;
			break;
#ifdef E_DEPRECATED
		case E_DEPRECATED:
		case E_USER_DEPRECATED:
			header = "PHP Deprecation";
			log_level = 3;
			break;
#endif
		default:
			header = "Unknown PHP Error";
			log_level = 3;
			break;
	}

	zend_bool enabled = INI_BOOL("errornotify.enable");
	char * email = INI_STR("errornotify.email");
	int currentLogLevel = INI_INT("errornotify.loglevel");
	
	

	
	if(enabled && email != "") {

		
		if(currentLogLevel >= log_level ) {
			
			char * subject;
			char hostname[1024];
			hostname[1023] = '\0';
			gethostname(hostname, 1023);
			php_sprintf(subject,"%s [%s]",hostname,header);
			php_mail(email,subject,error_message,NULL,NULL);
			//printf("\n\n Error => %s \n\n%s\n\n",subject,error_message);
		}
		
		efree(error_message);
		
	}
	orig_error_cb(type, error_filename, error_lineno, format, args);
}