| 13532 |
anikendra |
1 |
<?php
|
|
|
2 |
App::uses('Controller', 'Controller');
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
* Application Controller
|
|
|
6 |
*
|
|
|
7 |
* Add your application-wide methods in the class below, your controllers
|
|
|
8 |
* will inherit them.
|
|
|
9 |
*
|
|
|
10 |
* @package app.Controller
|
|
|
11 |
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
|
|
12 |
*/
|
|
|
13 |
class AppController extends Controller {
|
|
|
14 |
public $components = array(
|
|
|
15 |
'Session',
|
|
|
16 |
'Auth' => array(
|
|
|
17 |
'loginAction' => array('controller' => 'users', 'action' => 'login'),
|
|
|
18 |
'allowedActions' => array('index', 'view', 'display')
|
|
|
19 |
)
|
|
|
20 |
);
|
|
|
21 |
var $helpers = array('Session', 'Form', 'Html');
|
|
|
22 |
var $keywords = array('instagram followers','instagram button','instagram follow back','instagram tool','instagram automation','free istagram followers','instagram stats','instagram follow button');
|
|
|
23 |
|
|
|
24 |
function beforeFilter() {
|
|
|
25 |
$this->Auth->autoRedirect = false;
|
|
|
26 |
$this->set('logged_user', $this->Auth->user());
|
|
|
27 |
/*
|
|
|
28 |
App::import('Vendor','NewEpiCurl',array('file' =>'NewEpiCurl.php'));
|
|
|
29 |
App::import('Vendor','NewEpiOAuth',array('file' =>'NewEpiOAuth.php'));
|
|
|
30 |
App::import('Vendor','NewEpiTwitter',array('file' =>'NewEpiTwitter.php'));
|
|
|
31 |
*/
|
|
|
32 |
//Set api keys according to domain
|
|
|
33 |
// get host name from URL
|
|
|
34 |
preg_match('@^(?:http://)?([^/]+)@i',$_SERVER['HTTP_HOST'], $matches);
|
|
|
35 |
$host = $matches[1];
|
|
|
36 |
switch($host){
|
|
|
37 |
case 'localhost':
|
|
|
38 |
case 'localhost/hotbhojpuri':
|
|
|
39 |
Configure::load('dev');
|
|
|
40 |
break;
|
|
|
41 |
default:
|
|
|
42 |
case 'www.instafollow.in':
|
|
|
43 |
case 'instafollow.in':
|
|
|
44 |
Configure::load('live');
|
|
|
45 |
break;
|
|
|
46 |
}
|
|
|
47 |
Configure::load('live');
|
|
|
48 |
$facebookConfig = Configure::read("Facebook");
|
|
|
49 |
/*
|
|
|
50 |
//Twitter configuration
|
|
|
51 |
$twitterConfig = Configure::read("Twitter");
|
|
|
52 |
$this->set('consumer_key', $twitterConfig['consumer_key']);
|
|
|
53 |
$this->set('consumer_secret', $twitterConfig['consumer_secret']);
|
|
|
54 |
$this->twitterObj = new EpiTwitter($twitterConfig['consumer_key'], $twitterConfig['consumer_secret']);
|
|
|
55 |
$this->twitterObj->useApiVersion('1.1');
|
|
|
56 |
$this->set('twitterObj',$this->twitterObj);
|
|
|
57 |
*/
|
|
|
58 |
//Facebook configuration
|
|
|
59 |
$this->set('fbappid', $facebookConfig['fbappid']);
|
|
|
60 |
$sessionState = $this->Session->read('state');
|
|
|
61 |
if(!isset($sessionState)){
|
|
|
62 |
$this->Session->write('state' , md5(uniqid(rand(), TRUE))); // CSRF protection
|
|
|
63 |
}
|
|
|
64 |
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
|
|
|
65 |
. $facebookConfig['fbappid'] . "&redirect_uri=" . urlencode($facebookConfig['base_url'].'/users/checkfbuser/') . "&state="
|
|
|
66 |
. $this->Session->read('state').'&scope=publish_stream,email,user_birthday,publish_actions,user_location';
|
|
|
67 |
$this->set('dialog_url', $dialog_url);
|
|
|
68 |
$this->set('description','Why spend money when you can get something for free');
|
|
|
69 |
if(isset($this->params['admin'])) {
|
|
|
70 |
$this->layout = 'admin';
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
function generateucadcode($ip,$ua){
|
|
|
75 |
$url = "http://slot.union.ucweb.com/?pub=Darshit@SnapChum&format_type=json&ip=$ip&ua=$ua";
|
|
|
76 |
$ch = curl_init();
|
|
|
77 |
|
|
|
78 |
// Now set some options (most are optional)
|
|
|
79 |
|
|
|
80 |
// Set URL to download
|
|
|
81 |
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
82 |
|
|
|
83 |
// Include header in result? (0 = yes, 1 = no)
|
|
|
84 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
85 |
|
|
|
86 |
// Should cURL return or print out the data? (true = return, false = print)
|
|
|
87 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
88 |
|
|
|
89 |
// Timeout in seconds
|
|
|
90 |
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
|
|
91 |
|
|
|
92 |
// Download the given URL, and return output
|
|
|
93 |
$output = curl_exec($ch);
|
|
|
94 |
|
|
|
95 |
// Close the cURL resource, and free system resources
|
|
|
96 |
curl_close($ch);
|
|
|
97 |
|
|
|
98 |
return $output;
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
function isAuthorized() {
|
|
|
102 |
return $this->Auth->user('id');
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
function isFbAuthorized() {
|
|
|
106 |
return $this->Session->read('facebook_id');
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
function afterFilter() {
|
|
|
110 |
$result['ucadcode'] = $this->ucadcode;
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
function beforeRender() {
|
| 13565 |
anikendra |
114 |
// $this->set('base_url', 'http://' . $_SERVER['SERVER_NAME'] . Router::url('/'));
|
|
|
115 |
$this->set('base_url', 'http://api.profittill.com/');
|
| 13532 |
anikendra |
116 |
}
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
if (!function_exists('getallheaders'))
|
|
|
120 |
{
|
|
|
121 |
function getallheaders()
|
|
|
122 |
{
|
|
|
123 |
$headers = '';
|
|
|
124 |
foreach ($_SERVER as $name => $value)
|
|
|
125 |
{
|
|
|
126 |
if (substr($name, 0, 5) == 'HTTP_')
|
|
|
127 |
{
|
|
|
128 |
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
|
|
|
129 |
}
|
|
|
130 |
}
|
|
|
131 |
return $headers;
|
|
|
132 |
}
|
|
|
133 |
}
|