Subversion Repositories SmartDukaan

Rev

Rev 13739 | Rev 13901 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13739 Rev 13808
Line 9... Line 9...
9
 *
9
 *
10
 * @package       app.Controller
10
 * @package       app.Controller
11
 * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
11
 * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
12
 */
12
 */
13
class AppController extends Controller {
13
class AppController extends Controller {
-
 
14
 
-
 
15
	public $limit;
-
 
16
	public $apihost;
-
 
17
 
14
	public $components = array(
18
	public $components = array(
15
		'Session',
19
		'Session',
16
		'Auth' => array(
20
		'Auth' => array(
17
			'loginAction' => array('controller' => 'users', 'action' => 'login'),
21
			'loginAction' => array('controller' => 'users', 'action' => 'login'),
18
			'allowedActions' => array('index', 'view', 'display')
22
			'allowedActions' => array('index', 'view', 'display')
19
		)			
23
		)			
20
	);
24
	);
-
 
25
 
21
	var $helpers = array('Session', 'Form', 'Html');
26
	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');
27
	var $keywords = array('instagram followers','instagram button','instagram follow back','instagram tool','instagram automation','free istagram followers','instagram stats','instagram follow button');
23
 
28
 
24
	function beforeFilter() {
29
	function beforeFilter() {
25
		$this->Auth->autoRedirect = false;		
30
		$this->Auth->autoRedirect = false;		
Line 55... Line 60...
55
	   	$this->set('dialog_url', $dialog_url);
60
	   	$this->set('dialog_url', $dialog_url);
56
		$this->set('description','Why spend money when you can get something for free');
61
		$this->set('description','Why spend money when you can get something for free');
57
		$this->set('categories',$categories);
62
		$this->set('categories',$categories);
58
		if(isset($this->params['admin'])) {
63
		if(isset($this->params['admin'])) {
59
			$this->layout = 'admin';
64
			$this->layout = 'admin';
60
		}		
65
		}	
-
 
66
		$this->apihost = Configure::read('pythonapihost');
-
 
67
		$this->limit = Configure::read('dealsperpage');	
61
		$staticVersion = Configure::read('staticversion');
68
		$staticVersion = Configure::read('staticversion');
62
		$this->set('staticversion',$staticVersion);
69
		$this->set('staticversion',$staticVersion);
63
		$this->set('requiremobileverification',Configure::read('requiremobileverification'));
70
		$this->set('requiremobileverification',Configure::read('requiremobileverification'));
64
    }
71
    }
65
	
72
	
Line 101... Line 108...
101
	   } 
108
	   } 
102
       } 
109
       } 
103
       return $headers; 
110
       return $headers; 
104
    } 
111
    } 
105
 
112
 
-
 
113
    public function getDealsApiUrl($page=1,$userId = null,$categoryId=0,$sort=null,$direction=null){
-
 
114
    	$this->log('categoryId '.$categoryId,'api');
-
 
115
    	$this->log('page '.$page,'api');
-
 
116
    	$offset = ($page - 1) * $this->limit;
-
 
117
    	if(isset($sort) && !empty($sort) && $sort!=-1){
-
 
118
    		$url = $this->apihost.'deals/'.$userId.'?categoryId='.$categoryId.'&sort='.$sort.'&direction='.$direction.'&limit='.$this->limit.'&offset='.$offset;
-
 
119
    	}else{
-
 
120
    		$url = $this->apihost.'deals/'.$userId.'?categoryId='.$categoryId.'&limit='.$this->limit.'&offset='.$offset;
-
 
121
    	}    	
-
 
122
    	return $url;
-
 
123
    }
-
 
124
 
106
	function make_request($url,$fields,$format='json'){
125
	function make_request($url,$fields,$format='json'){
107
		$this->log("[url] $url",'api');
126
		$this->log("[url] $url",'api');
108
		$this->log("[fields] ".print_r($fields,1),'api');
127
		$this->log("[fields] ".print_r($fields,1),'api');
109
		$fields_string = '';
128
		$fields_string = '';
110
		//open connection
129
		//open connection
Line 119... Line 138...
119
			    'Content-Length: ' . strlen($fields))                                                                       
138
			    'Content-Length: ' . strlen($fields))                                                                       
120
			);   
139
			);   
121
		}
140
		}
122
		//execute post
141
		//execute post
123
		$result = curl_exec($ch);
142
		$result = curl_exec($ch);
124
		$this->log("[response] ".print_r($result,1),'api');
143
		// $this->log("[response] ".print_r($result,1),'api');
125
		//close connection
144
		//close connection
126
		curl_close($ch);
145
		curl_close($ch);
127
		switch($format){
146
		switch($format){
128
			case 'json':
147
			case 'json':
129
			$response = json_decode($result,1);
148
			$response = json_decode($result,1);