public function index() { $this->load->library('facebook'); $user = getAuthorizedUser(true); $isAuthorized = $user ? true : false; $sr = $this->facebook->getSignedRequest(); if ($isAuthorized) { $redirect_url = site_url('home'); } else { $sr = $this->facebook->getSignedRequest(); $redirect_url = isset($sr['page']) ? $this->config->item('APP_FANPAGE') . "&app_data=redirect|" . site_url('home') : "http://apps.facebook.com/" . $this->config->item('APP_APPLICATION_ID') . "/"; } if (!($user = getAuthorizedUser(true))) { redirect(site_url('home/authorize') . '?ref=' . $redirect_url); } $this->load->helper('form'); $this->load->library('form_validation'); $this->form_validation->set_rules('contestant1', 'Contestant', 'callback__ajax'); $this->form_validation->set_message('_ajax', 'Please wait for a minute to vote again'); if ($this->form_validation->run()) { $id = $this->input->post('contestant1'); $data = array('uid' => $user['id'], 'contestant_id' => $id, 'date' => date('Y-m-d H:i:s')); $this->db->insert('votes', $data); } /* generate 10 id and value for hidden input field */ for ($i = 1; $i <= 10; $i++) { $hidden[$i] = array('contestant' . $i => $i); } $this->load->view('vote', array('is_authorized' => $isAuthorized, 'redirectURL' => $redirect_url, 'hidden' => $hidden)); }
function customer_register($action = null) { $campaign = $this->campaign_m->getActiveCampaign(); $this->load->library('facebook'); $action = $action ? $action : menu_url('register'); $form = new HTMLQuickForm2('customer_register', 'POST', 'data-ajax="false"'); $form->setAttribute('action', $action); $user = getAuthorizedUser(); $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('FIRSTNAME' => isset($user['first_name']) ? $user['first_name'] : "", 'LASTNAME' => isset($user['last_name']) ? $user['last_name'] : "", 'EMAIL' => isset($user['email']) ? $user['email'] : ""))); //$form->addElement('static','','',array('content'=>'Your Firstname :')); $firstname = $form->addElement('text', 'FIRSTNAME', ''); $firstname->setLabel('First Name'); $firstname->addRule('required', 'Firstname is required', null, HTML_QuickForm2_Rule::SERVER); //$form->addElement('static','','',array('content'=>'Your Lastname :')); $lastname = $form->addElement('text', 'LASTNAME', ''); $lastname->setLabel('Last Name'); $lastname->addRule('required', 'Lastname is required', null, HTML_QuickForm2_Rule::SERVER); //$form->addElement('static','','',array('content'=>'Email :')); $email = $form->addElement('text', 'EMAIL', ''); $email->setLabel('Email'); $email->addRule('required', 'Email is required', null, HTML_QuickForm2_Rule::SERVER); //$form->addElement('static','','',array('content'=>'Phone no :')); $areacode = $this->config->item('PHONE_INTL_CODE'); $form->addElement('static', '', '', array('content' => 'Phone prefixed with country (' . $areacode . ') & area code: ex. ' . $areacode . '21... ,' . $areacode . '812...')); $mobile = $form->addElement('text', 'MOBILE', ''); $mobile->setLabel('Phone'); $mobile->addRule('required', 'Phone no. is required', null, HTML_QuickForm2_Rule::SERVER); $mobile->addRule('regex', 'Phone number does not Valid', '/^' . $areacode . '[0-9]+$/', HTML_QuickForm2_Rule::SERVER); $address = $form->addElement('textarea', 'ADDRESS', ''); $address->setLabel('Address'); $address->addRule('required', 'Address is required', null, HTML_QuickForm2_Rule::SERVER); $terms = $form->addElement('group')->setLabel(" "); $terms->addElement('checkbox', 'TERMS')->setContent('I accept Terms & Conditions'); $terms->addRule('required', 'Please Agreed The Terms and Condition', 1); $SUBSCRIPTION = $form->addElement('group')->setLabel(" "); $SUBSCRIPTION->addElement('checkbox', 'SUBSCRIPTIONID1', array('value' => $this->config->item('APP_APPLICATION_ID') . '|S"'))->setContent('Please send me news & updates'); $button = $form->addElement('submit', 'submit', 'data-role="none" value="Register"'); $button->setLabel(' '); if ($form->validate()) { $form->toggleFrozen(true); $data = $form->getValue(); unset($data['submit'], $data['_qf__customer_register'], $data['TERMS']); $data['GID'] = $campaign['GID'] . "_" . $this->config->item('APP_APPLICATION_ID'); if ($registered = $this->customer_m->add($data)) { return "success"; } else { return "error"; } unset($data['submit'], $data['_qf__customer_register']); $form->removeChild($button); } $renderer = HTML_QuickForm2_Renderer::factory('default'); $form_layout = $form->render($renderer); return $form_layout; }
public function rules() { $this->load->library('facebook'); /** BEGIN REQUIRED VALIDATION **/ if (!($campaign = $this->campaign->getActiveCampaign())) { show_404(); } $sr = $this->facebook->getSignedRequest(); $redirect_url = isset($sr['page']) ? $this->config->item('APP_FANPAGE') . "&app_data=redirect|" . current_url() : "http://apps.facebook.com/" . $this->config->item('APP_APPLICATION_ID') . "/rules"; if (!($user = getAuthorizedUser(true))) { redirect(mobile_menu_url('authorize') . '?ref=' . $redirect_url); } /** END REQUIRED VALIDATION **/ $this->load->view('mobile/mobile_rules', array('campaign' => $campaign, 'rules' => $campaign['campaign_rules'])); }
function graphRequireLogin($redirect_uri, $display = 'popup') { $CI =& get_instance(); $CI->load->library('facebook'); $CI->load->model('setting_m'); $facebook = $CI->facebook; $code = $_REQUEST["code"]; $dialog_options = array('client_id' => $CI->setting_m->get('APP_APPLICATION_ID'), 'redirect_uri' => $redirect_uri, 'display' => $display, 'scope' => $CI->setting_m->get('APP_EXT_PERMISSIONS')); $token_options = array('client_id' => $CI->setting_m->get('APP_APPLICATION_ID'), 'redirect_uri' => $redirect_uri, 'client_secret' => $CI->setting_m->get('APP_SECRET_KEY'), 'code' => $code); $dialog_url = "http://www.facebook.com/dialog/oauth?" . http_build_query($dialog_options); $token_url = "https://graph.facebook.com/oauth/access_token?" . http_build_query($token_options); if (!($user = getAuthorizedUser())) { if (empty($code)) { redirect($dialog_url); } elseif (isset($code) && !empty($code)) { $access_token = file_get_contents_curl($token_url); parse_str($access_token); } } }