Rev 13532 | Rev 13567 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('Controller', 'Controller');/*** Application Controller** Add your application-wide methods in the class below, your controllers* will inherit them.** @package app.Controller* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller*/class AppController extends Controller {public $components = array('Session','Auth' => array('loginAction' => array('controller' => 'users', 'action' => 'login'),'allowedActions' => array('index', 'view', 'display')));var $helpers = array('Session', 'Form', 'Html');var $keywords = array('instagram followers','instagram button','instagram follow back','instagram tool','instagram automation','free istagram followers','instagram stats','instagram follow button');function beforeFilter() {$this->Auth->autoRedirect = false;$this->set('logged_user', $this->Auth->user());/*App::import('Vendor','NewEpiCurl',array('file' =>'NewEpiCurl.php'));App::import('Vendor','NewEpiOAuth',array('file' =>'NewEpiOAuth.php'));App::import('Vendor','NewEpiTwitter',array('file' =>'NewEpiTwitter.php'));*///Set api keys according to domain// get host name from URLpreg_match('@^(?:http://)?([^/]+)@i',$_SERVER['HTTP_HOST'], $matches);$host = $matches[1];switch($host){case 'localhost':case 'localhost/hotbhojpuri':Configure::load('dev');break;default:case 'www.instafollow.in':case 'instafollow.in':Configure::load('live');break;}Configure::load('live');$facebookConfig = Configure::read("Facebook");/*//Twitter configuration$twitterConfig = Configure::read("Twitter");$this->set('consumer_key', $twitterConfig['consumer_key']);$this->set('consumer_secret', $twitterConfig['consumer_secret']);$this->twitterObj = new EpiTwitter($twitterConfig['consumer_key'], $twitterConfig['consumer_secret']);$this->twitterObj->useApiVersion('1.1');$this->set('twitterObj',$this->twitterObj);*///Facebook configuration$this->set('fbappid', $facebookConfig['fbappid']);$sessionState = $this->Session->read('state');if(!isset($sessionState)){$this->Session->write('state' , md5(uniqid(rand(), TRUE))); // CSRF protection}$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=". $facebookConfig['fbappid'] . "&redirect_uri=" . urlencode($facebookConfig['base_url'].'/users/checkfbuser/') . "&state=". $this->Session->read('state').'&scope=publish_stream,email,user_birthday,publish_actions,user_location';$this->set('dialog_url', $dialog_url);$this->set('description','Why spend money when you can get something for free');if(isset($this->params['admin'])) {$this->layout = 'admin';}}function generateucadcode($ip,$ua){$url = "http://slot.union.ucweb.com/?pub=Darshit@SnapChum&format_type=json&ip=$ip&ua=$ua";$ch = curl_init();// Now set some options (most are optional)// Set URL to downloadcurl_setopt($ch, CURLOPT_URL, $url);// Include header in result? (0 = yes, 1 = no)curl_setopt($ch, CURLOPT_HEADER, 0);// Should cURL return or print out the data? (true = return, false = print)curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);// Timeout in secondscurl_setopt($ch, CURLOPT_TIMEOUT, 10);// Download the given URL, and return output$output = curl_exec($ch);// Close the cURL resource, and free system resourcescurl_close($ch);return $output;}function isAuthorized() {return $this->Auth->user('id');}function isFbAuthorized() {return $this->Session->read('facebook_id');}function afterFilter() {$result['ucadcode'] = $this->ucadcode;}function beforeRender() {// $this->set('base_url', 'http://' . $_SERVER['SERVER_NAME'] . Router::url('/'));$this->set('base_url', 'http://api.profittill.com/');}}if (!function_exists('getallheaders')){function getallheaders(){$headers = '';foreach ($_SERVER as $name => $value){if (substr($name, 0, 5) == 'HTTP_'){$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;}}return $headers;}}