Exemplo n.º 1
0
 public static function locate($ip = null)
 {
     global $_SERVER;
     if (is_null($ip)) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $gp = new Geoplugin();
     $host = str_replace('{IP}', $ip, $gp->host);
     $host = str_replace('{CURRENCY}', $gp->currency, $host);
     $data = array();
     $response = $gp->fetch($host);
     $data = unserialize($response);
     //set the geoPlugin vars
     $gp->ip = $ip;
     $gp->city = isset($data['geoplugin_city']) ? $data['geoplugin_city'] : NULL;
     $gp->region = isset($data['geoplugin_region']) ? $data['geoplugin_region'] : NULL;
     $gp->areaCode = isset($data['geoplugin_areaCode']) ? $data['geoplugin_areaCode'] : NULL;
     $gp->dmaCode = isset($data['geoplugin_dmaCode']) ? $data['geoplugin_dmaCode'] : NULL;
     $gp->countryCode = isset($data['geoplugin_countryCode']) ? $data['geoplugin_countryCode'] : NULL;
     $gp->countryName = isset($data['geoplugin_countryName']) ? $data['geoplugin_countryName'] : NULL;
     $gp->continentCode = isset($data['geoplugin_continentCode']) ? $data['geoplugin_continentCode'] : NULL;
     $gp->latitude = isset($data['geoplugin_latitude']) ? $data['geoplugin_latitude'] : NULL;
     $gp->longitude = isset($data['geoplugin_longitude']) ? $data['geoplugin_longitude'] : NULL;
     $gp->currencyCode = isset($data['geoplugin_currencyCode']) ? $data['geoplugin_currencyCode'] : NULL;
     $gp->currencySymbol = isset($data['geoplugin_currencySymbol']) ? $data['geoplugin_currencySymbol'] : NULL;
     $gp->currencyConverter = isset($data['geoplugin_currencyConverter']) ? $data['geoplugin_currencyConverter'] : NULL;
     return $gp;
 }
Exemplo n.º 2
0
 public function daftar()
 {
     $this->recaptcha = new Recaptcha1();
     $captcha_answer["recaptcha_challenge_field"] = $this->input->post('recaptcha_challenge_field');
     $captcha_answer["recaptcha_response_field"] = $this->input->post('recaptcha_response_field');
     /*
     	Untuk captcha 2
     	$captcha_answer = $this->input->post('g-recaptcha-response');
     */
     $response = $this->recaptcha->verifyResponse($captcha_answer);
     $rule = $this->member_model->rules();
     $rule[] = array('field' => 'recaptcha_response_field', 'label' => 'Captcha', 'rules' => array('required', array('check_captcha', function ($str) use($response) {
         if ($response['success']) {
             return true;
         } else {
             return false;
         }
     })), 'errors' => array('check_captcha' => 'maaf captcha salah'));
     $this->form_validation->set_rules('accept_terms_checkbox', '', 'callback_accept_terms');
     $this->form_validation->set_rules($rule);
     // Form validation
     if ($this->form_validation->run() == FALSE) {
         //$data['cap_img'] = $this->captchalibrary->make_captcha();
         $bank = $this->db->query("SELECT * FROM bank")->result();
         $data['bank'] = object_to_array($bank, 'nama_bank');
         $country = $this->db->query("SELECT * FROM country")->result();
         $data['list_country'] = object_to_array($country, 'name', 'code');
         $gp = Geoplugin::locate("199.115.117.242");
         // edit bagian ini
         $data['country'] = in_array($gp->countryCode, $data['list_country']) ? "ID" : $gp->countryCode;
         $data['kode_referral'] = $this->uri->segment(3);
         $this->template->load('template/template_auth', 'auth/register', $data);
     } else {
         if ($this->member_model->register() === false) {
             echo "terjadi error di server";
         } else {
             $this->authlibrary->sendRegistrationMail($this->input->post('member[email]'), $this->input->post('member[username]'), $this->input->post('member[password]'));
             redirect(base_url() . "auth/success");
         }
     }
 }