-
Notifications
You must be signed in to change notification settings - Fork 3
/
not-enrolled.php
168 lines (118 loc) · 4.34 KB
/
not-enrolled.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
/**
* Template Name: Not Enrolled Template
*
* Description: Handle logins that are not linked to any account in HC
*
* @since HCommons
*/
$errors = false;
$success = false;
$mail_error = false;
if( $_SERVER['REQUEST_METHOD'] == 'POST' && wp_verify_nonce($_POST['cu_nonce'], 'contact-us-nonce' ) ) {
//sanitize post data first
//$subject = filter_var( $_POST['subject'], FILTER_SANITIZE_STRIPPED );
$msg = filter_var( $_POST['msg'], FILTER_SANITIZE_STRIPPED );
$email = filter_var( $_POST['uemail'], FILTER_SANITIZE_EMAIL );
$uname = filter_var( $_POST['uname'], FILTER_SANITIZE_STRIPPED );
if( ! empty( $email ) && ! empty( $msg ) ) {
if( !empty( $uname ) ) {
$content .= "<p>User's name: {$uname}</p>";
}
$content .= "<p>User's E-mail: {$email}</p>";
$content .= "<p>Message: {$msg}</p>";
$mail = wp_mail( '[email protected]', 'User is not enrolled', $content, "\r\nReply-to: <" . $email . ">" );
if( $mail == true ) {
$success = 'Mail sent! Please give us some time to respond back';
} else {
$mail_error = 'Uh oh! Something went wrong..';
}
} else {
$errors = true;
}
}
//must set cookies before header
setcookie( '_saml_idp', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), false, true );
setcookie( 'stickyIdPSelection', false, time()-3600, '/', '.' . getenv('WP_DOMAIN'), true, true );
wp_destroy_current_session();
wp_clear_auth_cookie();
$shib_urls = [
// IDPs
getenv('GOOGLE_IDP_URL') . '/idp/profile/Logout',
getenv('TWITTER_IDP_URL') . '/idp/profile/Logout',
getenv('MLA_IDP_URL') . '/idp/profile/Logout',
getenv('HC_IDP_URL') . '/idp/profile/Logout',
// SPs
getenv('REGISTRY_SP_URL') . '/Shibboleth.sso/Logout',
get_site_url() . '/Shibboleth.sso/Logout',
];
get_header(); ?>
<style type="text/css">
#cu-container {
width: 50%;
margin: 40px auto;
}
#cu-container h3 {
margin-bottom: 10px;
}
#cu-container h4 {
margin-bottom: 10px;
}
#contact-us input[type="text"], #contact-us input[type="email"], #contact-us textarea {
width: 70%;
margin-bottom: 20px;
}
#contact-us span {
margin-bottom: 3px;
color: red;
}
#contact-us .error {
border: 1px solid red;
}
</style>
<?php foreach( $shib_urls as $shib_url ): ?>
<iframe src="<?php echo $shib_url ?>" style="display:none" title="Log Out" ></iframe>
<?php endforeach ?>
<div class="page-full-width">
<?php if( empty( $success ) ) : ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
</article><!-- #post -->
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
<?php endif ?>
<div id="cu-container">
<?php if( ! empty( $success ) ) : ?>
<h4><?php echo $success; ?></h4>
<?php endif; ?>
<?php if( ! empty( $mail_error ) ) : ?>
<h4><?php echo $success; ?></h4>
<?php endif;
if( empty( $success ) ) :
?>
<h3>Contact Us</h3>
<form id="contact-us" action="/not-enrolled" method="POST">
<p><input type="text" placeholder="Your Name" name="uname" /></p>
<?php if( ! empty( $errors ) ) : ?>
<p><span>Please enter your E-mail!</span><br/>
<input type="email" class="error" placeholder="Your E-mail" name="uemail" /></p>
<p><span>Please enter message!</span><br />
<textarea class="error" placeholder="message" name="msg"></textarea></p>
<?php else : ?>
<p><input type="email" placeholder="Your E-mail" name="uemail" /></p>
<!--<p><input type="text" placeholder="Subject" name="subject" /></p>-->
<p><textarea placeholder="Message" name="msg"></textarea></p>
<?php endif; ?>
<input type="hidden" name="cu_nonce" value="<?php echo wp_create_nonce('contact-us-nonce'); ?>" />
<p><button>Submit</button></p>
</form> <!-- /contact-us -->
<?php endif;?>
</div> <!-- /#cu-container -->
</div><!-- #primary -->
</div><!-- .page-full-width -->
<?php get_footer(); ?>