Code Duplication    Length = 41-41 lines in 4 locations

src/app/controllers/arvr_workshop.php 1 location

@@ 108-148 (lines=41) @@
105
        }
106
    }
107
108
    public function success() {
109
        $this->load_library('http_lib', 'http');
110
        if (!isset($_GET['payment_id'])) {
111
            $this->http->response_code( 400 );
112
            exit();
113
        }
114
        global $payment_cfg;
115
        $proxy = 'http://proxy.iiit.ac.in:8080';
116
117
        $nick      = $this->auth->get_user();
118
        $id             = urlencode($_GET['payment_request_id']);
119
        $payment_id     = urlencode($_GET['payment_id']);
120
        $url            = $payment_cfg['arvr']['api_url'] . $id . '/' . $payment_id . '/';
121
        $api_headers    = $payment_cfg['arvr']['api_headers'];
122
123
        $ch = curl_init();
124
125
        curl_setopt($ch, CURLOPT_URL, $url);
126
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
127
        curl_setopt($ch, CURLOPT_HEADER, false);
128
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
129
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
130
        curl_setopt($ch, CURLOPT_HTTPHEADER, $api_headers);
131
        $response = curl_exec($ch);
132
        curl_close($ch);
133
        $response_array = json_decode($response, true);
134
135
        if (@$response_array['success']) {
136
            $status = $response_array['payment_request']['payment']['status'];
137
            $payment_id = $_GET['payment_id'];
138
            $payment_data = $response;
139
            $this->model->arvr_payment_success($payment_id, $nick, $status == 'Credit' ? 'success' : 'failed', $payment_data);
140
        } else {
141
            if ( is_array( $response_array ) ) {
142
                $this->model->arvr_dump_data('unknown', 'callback', json_encode( [ '$_GET' => $_GET, 'response' => $response_array ] ));
143
            } else {
144
                $this->model->arvr_dump_data('unknown', 'callback', json_encode($_GET));
145
            }
146
        }
147
        $this->http->redirect(base_url() . "talks-and-workshops/arvr/register/");
148
    }
149
150
    public function webhook() {
151
        global $payment_cfg;

src/app/controllers/riderofstorms.php 1 location

@@ 116-156 (lines=41) @@
113
        }
114
    }
115
116
    public function success() {
117
        $this->load_library('http_lib', 'http');
118
        if (!isset($_GET['payment_id'])) {
119
            $this->http->response_code( 400 );
120
            exit();
121
        }
122
        global $payment_cfg;
123
        $proxy = 'http://proxy.iiit.ac.in:8080';
124
125
        $nick      = $this->auth->get_user();
126
        $id             = urlencode($_GET['payment_request_id']);
127
        $payment_id     = urlencode($_GET['payment_id']);
128
        $url            = $payment_cfg['riderofstorms']['api_url'] . $id . '/' . $payment_id . '/';
129
        $api_headers    = $payment_cfg['riderofstorms']['api_headers'];
130
131
        $ch = curl_init();
132
133
        curl_setopt($ch, CURLOPT_URL, $url);
134
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
135
        curl_setopt($ch, CURLOPT_HEADER, false);
136
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
137
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
138
        curl_setopt($ch, CURLOPT_HTTPHEADER, $api_headers);
139
        $response = curl_exec($ch);
140
        curl_close($ch);
141
        $response_array = json_decode($response, true);
142
143
        if (@$response_array['success']) {
144
            $status = $response_array['payment_request']['payment']['status'];
145
            $payment_id = $_GET['payment_id'];
146
            $payment_data = $response;
147
            $this->model->riderofstorms_payment_success($payment_id, $nick, $status == 'Credit' ? 'success' : 'failed', $payment_data);
148
        } else {
149
            if ( is_array( $response_array ) ) {
150
                $this->model->riderofstorms_dump_data('unknown', 'callback', json_encode( [ '$_GET' => $_GET, 'response' => $response_array ] ));
151
            } else {
152
                $this->model->riderofstorms_dump_data('unknown', 'callback', json_encode($_GET));
153
            }
154
        }
155
        $this->http->redirect(base_url() . "cultural-Colosseum/bob/register/");
156
    }
157
158
    public function webhook() {
159
        global $payment_cfg;

src/app/controllers/webdev_workshop.php 1 location

@@ 112-152 (lines=41) @@
109
        }
110
    }
111
112
    public function success() {
113
        $this->load_library('http_lib', 'http');
114
        if (!isset($_GET['payment_id'])) {
115
            $this->http->response_code( 400 );
116
            exit();
117
        }
118
        global $payment_cfg;
119
        $proxy = 'http://proxy.iiit.ac.in:8080';
120
121
        $nick      = $this->auth->get_user();
122
        $id             = urlencode($_GET['payment_request_id']);
123
        $payment_id     = urlencode($_GET['payment_id']);
124
        $url            = $payment_cfg['webdev']['api_url'] . $id . '/' . $payment_id . '/';
125
        $api_headers    = $payment_cfg['webdev']['api_headers'];
126
127
        $ch = curl_init();
128
129
        curl_setopt($ch, CURLOPT_URL, $url);
130
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
131
        curl_setopt($ch, CURLOPT_HEADER, false);
132
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
133
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
134
        curl_setopt($ch, CURLOPT_HTTPHEADER, $api_headers);
135
        $response = curl_exec($ch);
136
        curl_close($ch);
137
        $response_array = json_decode($response, true);
138
139
        if (@$response_array['success']) {
140
            $status = $response_array['payment_request']['payment']['status'];
141
            $payment_id = $_GET['payment_id'];
142
            $payment_data = $response;
143
            $this->model->webdev_payment_success($payment_id, $nick, $status == 'Credit' ? 'success' : 'failed', $payment_data);
144
        } else {
145
            if ( is_array( $response_array ) ) {
146
                $this->model->webdev_dump_data('unknown', 'callback', json_encode( [ '$_GET' => $_GET, 'response' => $response_array ] ));
147
            } else {
148
                $this->model->webdev_dump_data('unknown', 'callback', json_encode($_GET));
149
            }
150
        }
151
        $this->http->redirect(base_url() . "talks-and-workshops/web-development/register/");
152
    }
153
154
    public function webhook() {
155
        global $payment_cfg;

src/app/controllers/mun.php 1 location

@@ 121-161 (lines=41) @@
118
        }
119
    }
120
121
    public function success() {
122
        $this->load_library('http_lib', 'http');
123
        if (!isset($_GET['payment_id'])) {
124
            $this->http->response_code( 400 );
125
            exit();
126
        }
127
        global $payment_cfg;
128
        $proxy = 'http://proxy.iiit.ac.in:8080';
129
130
        $nick      = $this->auth->get_user();
131
        $id             = urlencode($_GET['payment_request_id']);
132
        $payment_id     = urlencode($_GET['payment_id']);
133
        $url            = $payment_cfg['mun']['api_url'] . $id . '/' . $payment_id . '/';
134
        $api_headers    = $payment_cfg['mun']['api_headers'];
135
136
        $ch = curl_init();
137
138
        curl_setopt($ch, CURLOPT_URL, $url);
139
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
140
        curl_setopt($ch, CURLOPT_HEADER, false);
141
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
142
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
143
        curl_setopt($ch, CURLOPT_HTTPHEADER, $api_headers);
144
        $response = curl_exec($ch);
145
        curl_close($ch);
146
        $response_array = json_decode($response, true);
147
148
        if (@$response_array['success']) {
149
            $status = $response_array['payment_request']['payment']['status'];
150
            $payment_id = $_GET['payment_id'];
151
            $payment_data = $response;
152
            $this->model->mun_payment_success($payment_id, $nick, $status == 'Credit' ? 'success' : 'failed', $payment_data);
153
        } else {
154
            if ( is_array( $response_array ) ) {
155
                $this->model->mun_dump_data('unknown', 'callback', json_encode( [ '$_GET' => $_GET, 'response' => $response_array ] ));
156
            } else {
157
                $this->model->mun_dump_data('unknown', 'callback', json_encode($_GET));
158
            }
159
        }
160
        $this->http->redirect(base_url() . "talks-and-workshops/mun/register/");
161
    }
162
163
    public function webhook() {
164
        global $payment_cfg;