-
Notifications
You must be signed in to change notification settings - Fork 15
/
connect.php
38 lines (29 loc) · 988 Bytes
/
connect.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
<?php
require_once( $_SERVER['DOCUMENT_ROOT'] . '/inc/setup.php' );
if ( ! iconic_verify_form_token( 'iconic-connect' ) ) {
iconic_add_notice( 'Could not verify form token.' );
header( "Location: " . iconic_get_app_url() );
die();
}
$url = filter_input( INPUT_POST, 'store_url', FILTER_SANITIZE_URL );
if ( empty( $url ) ) {
iconic_add_notice( 'The URL was invalid.' );
header( "Location: " . iconic_get_app_url() );
die();
}
$url = iconic_add_trailing_slash( $url );
$auth_url = $url . iconic_get_authorize_path();
$auth_url = iconic_add_auth_params( $auth_url );
if ( ! iconic_url_exists( $auth_url ) ) {
iconic_add_notice( 'The URL was invalid.' );
header( "Location: " . iconic_get_app_url() );
die();
}
$insert_store_url = iconic_db_insert_store_url( $url );
if ( ! $insert_store_url ) {
iconic_add_notice( 'The connection failed, please try again.', 'warning' );
header( "Location: " . iconic_get_app_url() );
die();
}
header( "Location: " . $auth_url );
die();