Subversion Repositories SmartDukaan

Rev

Rev 15311 | Rev 15378 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 {
13808 anikendra 14
 
15
	public $limit;
16
	public $apihost;
15311 anikendra 17
	public $acls;
13808 anikendra 18
 
13532 anikendra 19
	public $components = array(
14970 anikendra 20
		'Session','Resize','Cookie',
13532 anikendra 21
		'Auth' => array(
22
			'loginAction' => array('controller' => 'users', 'action' => 'login'),
23
			'allowedActions' => array('index', 'view', 'display')
24
		)			
25
	);
13808 anikendra 26
 
13532 anikendra 27
	var $helpers = array('Session', 'Form', 'Html');
28
	var $keywords = array('instagram followers','instagram button','instagram follow back','instagram tool','instagram automation','free istagram followers','instagram stats','instagram follow button');
29
 
30
	function beforeFilter() {
13659 anikendra 31
		$this->Auth->autoRedirect = false;		
13579 anikendra 32
 
33
		//Set config settings according to domain
13532 anikendra 34
		// get host name from URL
35
		preg_match('@^(?:http://)?([^/]+)@i',$_SERVER['HTTP_HOST'], $matches);
36
		$host = $matches[1];
37
		switch($host){			
13567 anikendra 38
			case 'localdtr':
13532 anikendra 39
				Configure::load('dev');
40
				break;
13946 anikendra 41
			case 'staging.profittill.com':
42
			case 'www.staging.profittill.com':
13944 anikendra 43
				Configure::load('staging');
44
				break;
13532 anikendra 45
			default:
13567 anikendra 46
			case 'www.profittill.com':
47
			case 'profittill.com':
13633 anikendra 48
			case 'api.profittill.com':
13532 anikendra 49
				Configure::load('live');
50
				break;
51
		}
13579 anikendra 52
		$facebookConfig = Configure::read("Facebook");		
53
		$categories = Configure::read('Categories');
13532 anikendra 54
		//Facebook configuration
55
		$this->set('fbappid', $facebookConfig['fbappid']);
13579 anikendra 56
		$this->set('apihost', Configure::read('apihost'));
57
 
13532 anikendra 58
	   	$sessionState = $this->Session->read('state');
59
		if(!isset($sessionState)){
60
			$this->Session->write('state' , md5(uniqid(rand(), TRUE))); // CSRF protection
61
		}
62
	 	$dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
63
		   . $facebookConfig['fbappid'] . "&redirect_uri=" . urlencode($facebookConfig['base_url'].'/users/checkfbuser/') . "&state="
64
		   . $this->Session->read('state').'&scope=publish_stream,email,user_birthday,publish_actions,user_location';
65
	   	$this->set('dialog_url', $dialog_url);
66
		$this->set('description','Why spend money when you can get something for free');
13579 anikendra 67
		$this->set('categories',$categories);
13532 anikendra 68
		if(isset($this->params['admin'])) {
13739 anikendra 69
			$this->layout = 'admin';
13808 anikendra 70
		}	
71
		$this->apihost = Configure::read('pythonapihost');
72
		$this->limit = Configure::read('dealsperpage');	
13685 anikendra 73
		$staticVersion = Configure::read('staticversion');
74
		$this->set('staticversion',$staticVersion);
14929 anikendra 75
		$this->set('requiremobileverification',Configure::read('requiremobileverification'));			
14970 anikendra 76
		$debugusers = Configure::read('debugusers');
77
		if($id = $this->isAuthorized()){
78
			if(in_array($id, $debugusers)){
79
				$this->Cookie->write('debuguser',1);
80
			}else{
81
				$this->Cookie->delete('debuguser');
82
			}
83
		}
15188 anikendra 84
		//acl
85
		$cachekey = 'acls';
86
		$acls = Cache::read($cachekey,'month');
87
		if(empty($acls)) {
88
			$acls = array();
89
			$this->loadModel('Acl');
90
			$result = $this->Acl->find('all');
91
			foreach ($result as $key => $value) {
92
				if($value['Acl']['access']) {
93
					$acls[$value['Acl']['group_id']]['allowed'][] = $value['Acl']['action'];
94
				}else{
95
					$acls[$value['Acl']['group_id']]['disallowed'][] = $value['Acl']['action'];
96
				}				
97
			}
98
			Cache::write($cachekey,$acls,'month');
99
		}
15311 anikendra 100
		$this->acls = $acls;
15188 anikendra 101
		$this->set('acls',$acls);
13532 anikendra 102
    }
103
 
15311 anikendra 104
	function checkAcl() {		
105
    	if(!in_array($this->here,$this->acls[$this->Session->read('Auth.User.group_id')]['allowed'])){
15227 anikendra 106
    		$this->Session->setFlash(__('You are not authorized to access this page.'));
107
    		return $this->redirect(array('controller'=>'administration','action' => 'dashboard','admin'=>false));
108
    	}
109
    }
110
 
13532 anikendra 111
    function isAuthorized() {
112
        return $this->Auth->user('id');
113
    }
114
 
115
    function isFbAuthorized() {
116
        return $this->Session->read('facebook_id');
117
    }
118
 
119
    function afterFilter() {
13579 anikendra 120
		$result['ucadcode'] = $this->ucadcode;
13532 anikendra 121
    }
122
 
13659 anikendra 123
    function beforeRender() {   
13736 anikendra 124
    	$logged_user = $this->Auth->user();
125
    	$this->set('logged_user', $logged_user); 	
13579 anikendra 126
        $this->set('base_url', 'http://' . $_SERVER['SERVER_NAME'] . Router::url('/'));
13532 anikendra 127
    }
128
 
13736 anikendra 129
    function checkMobileNumber() {
130
    	$logged_user = $this->Auth->user();
131
    	if(empty($logged_user['mobile_verified']) && $this->params['controller'] !='users') {
132
			$skipmobileverification = $this->Session->read('skipmobileverification');
133
			if(!isset($skipmobileverification) || empty($skipmobileverification)) {
134
				$this->redirect('/users/verifymobile');
135
			}
136
		}
137
    }
138
 
15335 anikendra 139
    function checkToken($userId = null) {
140
        $headers =  $this->getallheaders();
14890 anikendra 141
        $this->log(print_r($headers,1),'headers');
14897 anikendra 142
        $token = $_COOKIE['token'];
15188 anikendra 143
        $checkToken = $_COOKIE['walletAuthentication'];
14894 anikendra 144
        $this->log("Token : $token",'headers');
15188 anikendra 145
        $this->log("CheckToken : $checkToken",'headers');
146
        if(isset($checkToken) && !empty($checkToken) && isset($token) && !empty($token)) {
15335 anikendra 147
                $this->loadModel('SocialProfile');
148
                $options = array('conditions'=>array('access_token'=>$token),'fields'=>array('user_id'),'recursive'=>-1);
149
                $user = $this->SocialProfile->find('first',$options);
150
                $this->log(print_r($user['SocialProfile'],1),'headers');
151
                if(!$userId){
152
                	$userId = $this->request->query('user_id');
153
                }                
154
                if(isset($userId) && !empty($userId)){
155
                    if($userId == $user['SocialProfile']['user_id']){
156
                        return true;
157
                    } else{
158
                    	// token mismatch, so maybe hack attempt
159
                        return false;
160
                    }
161
                } else {
162
                	// userId is not sent so maybe hack attempt
163
                	return false;
164
                }
165
        } else {                
166
            return true;
14890 anikendra 167
        }
15335 anikendra 168
        // return true;
14890 anikendra 169
    }
170
 
13659 anikendra 171
    function getallheaders() { 
172
	   $headers = ''; 
173
       foreach ($_SERVER as $name => $value) 
174
       { 
175
	   if (substr($name, 0, 5) == 'HTTP_') 
176
	   { 
177
	       $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; 
178
	   } 
179
       } 
180
       return $headers; 
181
    } 
13633 anikendra 182
 
15015 anikendra 183
    public function getDealsApiUrl($page=1,$userId = null,$categoryId=0,$sort=null,$direction=null,$filter=null,$brands=null){
13808 anikendra 184
    	$this->log('categoryId '.$categoryId,'api');
185
    	$this->log('page '.$page,'api');
186
    	$offset = ($page - 1) * $this->limit;
187
    	if(isset($sort) && !empty($sort) && $sort!=-1){
188
    		$url = $this->apihost.'deals/'.$userId.'?categoryId='.$categoryId.'&sort='.$sort.'&direction='.$direction.'&limit='.$this->limit.'&offset='.$offset;
189
    	}else{
190
    		$url = $this->apihost.'deals/'.$userId.'?categoryId='.$categoryId.'&limit='.$this->limit.'&offset='.$offset;
191
    	}    	
15015 anikendra 192
    	if(isset($filter) && !empty($filter)){
193
    		$url .= "&filterData=brandFilter:".$brands;
194
    	}
13808 anikendra 195
    	return $url;
196
    }
197
 
13633 anikendra 198
	function make_request($url,$fields,$format='json'){
13683 anikendra 199
		$this->log("[url] $url",'api');
200
		$this->log("[fields] ".print_r($fields,1),'api');
13633 anikendra 201
		$fields_string = '';
202
		//open connection
203
		$ch = curl_init();
204
		//set the url, number of POST vars, POST data
205
		curl_setopt($ch,CURLOPT_URL, $url);
206
		curl_setopt($ch,CURLOPT_RETURNTRANSFER , true);
207
		if(!empty($fields)) {
208
			curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
209
			curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
210
			    'Content-Type: application/json',                                                                                
13994 anikendra 211
			    // 'Content-Length: ' . sizeof($fields))                                                                       
212
			    'Content-Length: ' . strlen($fields))                                                                       
13633 anikendra 213
			);   
214
		}
215
		//execute post
216
		$result = curl_exec($ch);
15335 anikendra 217
		$this->log("[response] ".print_r($result,1),'api');
13633 anikendra 218
		//close connection
219
		curl_close($ch);
220
		switch($format){
221
			case 'json':
222
			$response = json_decode($result,1);
223
			break;
224
		}
225
		return $response;	
226
	}
13901 anikendra 227
 
14016 anikendra 228
	function post_request($url,$fields,$format='json'){
229
		$this->log("[url] $url",'api');
230
		$this->log("[fields] ".print_r($fields,1),'api');
231
		$fields_string = '';
232
		//open connection
233
		$ch = curl_init();
234
		//execute post
235
		foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
236
		rtrim($fields_string, '&');
237
		//set the url, number of POST vars, POST data
238
		curl_setopt($ch,CURLOPT_URL, $url);
239
		curl_setopt($ch,CURLOPT_POST, count($fields));
240
		curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
241
		$result = curl_exec($ch);
242
		$this->log("[response] ".print_r($result,1),'api');
243
		//close connection
244
		curl_close($ch);
245
		switch($format){
246
			case 'json':
247
			$response = json_decode($result,1);
248
			break;
249
		}
250
		return $response;	
251
	}
14215 anikendra 252
 
13901 anikendra 253
	public function get_solr_result($q,$page) {
254
		$dealsperpage = Configure::read('dealsperpage');
255
		$offset = ($page - 1)*$dealsperpage;
13993 anikendra 256
		$cond = "$q";
13901 anikendra 257
	 	$sort = "store desc";
258
 
259
		$params = array(
260
			'conditions' =>array(
261
		 	'solr_query' => $cond
262
	 	),
263
		 	//'order' => $sort,
264
		 	'offset' => $offset,
265
		 	'limit' => $dealsperpage
266
	 	);
14215 anikendra 267
		$this->loadModel('Solr');		
13901 anikendra 268
		$solroutput = $this->Solr->find('all', $params);
269
		$result = array();
14215 anikendra 270
		if(sizeof($solroutput)<$dealsperpage){
271
			$hasMore = false;
272
		}else{
273
			$hasMore = true;
274
		}
13901 anikendra 275
		if(!empty($solroutput['Solr'])) {			
276
			$skuMap = array();
14215 anikendra 277
			foreach ($solroutput['Solr'] as $key => $value) {
14432 anikendra 278
				// if(!$value['in_stock'])continue;
13901 anikendra 279
				$skuMap[$value['id']] = $value;
280
				$result[$value['skuBundleId']][$value['id']] = $value['available_price'];
14215 anikendra 281
			}	
282
			if(!empty($result)) {
283
				foreach ($result as $key => $value) {					
284
					asort($value);
285
					$lowestPriceSku = key($value);
286
					$result[$key] = $skuMap[$lowestPriceSku];
287
				}
13901 anikendra 288
			}
14215 anikendra 289
		}		
290
		$result['hasMore'] = $hasMore;
13901 anikendra 291
		return $result;
292
	}
14098 anikendra 293
 
294
	public function admin_update(){
295
		$this->response->type('json');
296
		$this->layout = 'ajax';
297
		$data[$this->request->data['id']] = $this->request->data['value'];
298
		$data['oid'] = $this->request->data['oid'];
14584 anikendra 299
		$id = $this->request->data['id'];
300
		$multi = $this->request->data['multi'];
14098 anikendra 301
		if($this->modelClass == 'Exceptionalskudiscount') {
302
			$data['class'] = 'SkuDiscountInfo';	
303
		}elseif($this->modelClass == 'Skuscheme'){
14584 anikendra 304
			if($id == 'dp'){
305
				$data['class'] = 'SkuDealerPrices';
306
			}else{
307
				$data['class'] = 'SkuSchemeDetails';
308
			}
14426 anikendra 309
		}elseif($this->modelClass == 'Exceptionalnlc'){
310
			$data['class'] = 'ExceptionalNlc';
311
		}
312
		else{
14098 anikendra 313
			$data['class'] = $this->modelClass;
314
		}		
14584 anikendra 315
		$data_string = json_encode($data,JSON_NUMERIC_CHECK);		
14098 anikendra 316
		$ch = curl_init();
317
		$url = $this->apihost.'Catalog/updateCollection';
14584 anikendra 318
		if(isset($multi) && $multi==1){
319
			$url .= "/?multi=1";
320
		}		
14098 anikendra 321
		$this->log("[url] $url",'api');
322
		$this->log("[fields] ".print_r($data_string,1),'api');
323
		curl_setopt($ch, CURLOPT_URL, $url);
324
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
325
		curl_setopt($ch, CURLOPT_POST, true);
326
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // note the PUT here
327
 
328
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
329
		curl_setopt($ch, CURLOPT_HEADER, true);
330
 
331
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
332
		    'Content-Type: application/json',                                                                                
333
		    'Content-Length: ' . strlen($data_string)                                                                       
334
		));       
335
 
336
		// execute the request
337
 
338
		$output = curl_exec($ch);
339
		$result = $this->request->data['value'];
340
		$this->log("[response] ".print_r($output,1),'api');
341
		curl_close($ch);
342
		$this->set(array(
343
		    'result' => $result,
344
		    '_serialize' => array('result')
345
		));
346
		$this->render('/Elements/json');
347
	}
14150 anikendra 348
 
14509 anikendra 349
	public function remove($id,$class){
350
		$data['oid'] = $id;
351
		$data['class'] = $class;
352
 
353
		$data_string = json_encode($data,JSON_NUMERIC_CHECK);
354
		$ch = curl_init();
355
		$url = $this->apihost.'Catalog/deleteDocument';
356
		$this->log("[url] $url",'api');
357
		$this->log("[fields] ".print_r($data_string,1),'api');
358
		curl_setopt($ch, CURLOPT_URL, $url);
359
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
360
		curl_setopt($ch, CURLOPT_POST, true);
361
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); // note the PUT here
362
 
363
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
364
		curl_setopt($ch, CURLOPT_HEADER, true);
365
 
366
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
367
		    'Content-Type: application/json',                                                                                
368
		    'Content-Length: ' . strlen($data_string)                                                                       
369
		));       
370
 
371
		// execute the request
372
 
373
		$output = curl_exec($ch);
374
		$result = $this->request->data['value'];
375
		$this->log("[response] ".print_r($output,1),'api');
376
		curl_close($ch);
377
		// $this->set(array(
378
		    // 'result' => $result,
379
		    // '_serialize' => array('result')
380
		// ));
381
		// $this->render('/Elements/json');
382
		return $result;
383
	}
384
 
14150 anikendra 385
	function getAutoLoginUrl($userId,$next) {
14996 anikendra 386
		$saholicoffline = Configure::read('saholicoffline');
387
		if($saholicoffline) {
388
			$url = "/abouts/saholicoffline";
389
			return $url;
390
		}
14150 anikendra 391
		$this->loadModel('User');
392
		$this->User->Behaviors->attach('Containable');
14166 anikendra 393
		$options = array('contain'=>array('UserAccount'), 'conditions'=>array('User.id'=>$userId),'fields'=>array('username','email'),'recursive'=>-1);
14150 anikendra 394
		$user = $this->User->find('first',$options);
14166 anikendra 395
		$this->log("user_accounts ".print_r($user,1));
14441 anikendra 396
		$data = array('email'=>$user['User']['email'],'Id'=>$user['UserAccount'][0]['account_key'],'cartId' => $user['UserAccount'][1]['account_key'],'isPrivateDealUser'=>1,'next'=>$next);
14150 anikendra 397
		$data = '?data='.base64_encode(serialize($data));
398
		$token = '&token='.md5(Configure::read('saholicapikey').'|'.$user['UserAccount'][0]['account_key']);		
15335 anikendra 399
		$url = Configure::read('saholicapihost')."login!authorizeProfitMandiUser?userId=".$user['UserAccount'][0]['account_key']."&source=ProfitMandi";
400
		$result = $this->make_request($url);
401
		if(!empty($result['tokenString'])){
402
			$token = '&token='.$result['tokenString'];
403
			return Configure::read('saholicauthurl').$data.$token.'&v=2';
404
		}
14441 anikendra 405
		return Configure::read('saholicauthurl').$data.$token;
14150 anikendra 406
	}
14509 anikendra 407
 
408
 	function createUploadDirectory($modelClass) {
409
        //Create directory
410
        if (!is_dir(WWW_ROOT.'uploads'.DS.$modelClass)) {            
411
            $this->log("making directory for $modelClass". WWW_ROOT.DS.'uploads'.DS.$modelClass);
412
            mkdir(WWW_ROOT.'uploads'.DS.$modelClass,0777);
413
        }
414
        if (!is_dir(WWW_ROOT.'uploads'.DS.$modelClass)) {
415
            $this->log("failed to create directory for $modelClass");
416
            return false; 
417
        } else {
418
            return true;
419
        }
420
    }
421
 
422
    public function upload() {
423
        $result['status'] = 0; 
424
        $result['success'] = false;
425
        $result['message'] = __('Unable to upload');
426
 
427
        App::import('Vendor','qqFileUploader',array('file' =>'qqFileUploader.php'));
428
 
429
        $uploader = new qqFileUploader();
430
 
431
        // Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp")
432
        $uploader->allowedExtensions = array('jpeg','png','jpg','gif','bmp');
433
 
434
        // Specify max file size in bytes.
435
        $uploader->sizeLimit = 10 * 1024 * 1024;
436
 
437
        // Specify the input name set in the javascript.
438
        $uploader->inputName = 'qqfile';
439
 
440
        // If you want to use resume feature for uploader, specify the folder to save parts.
441
        $uploader->chunksFolder = 'chunks';
442
 
443
        // $min_width = isset($this->request->data['minwidth']) ? $this->request->data['minwidth'] : 0; 
444
        // $min_height = isset($this->request->data['minheight']) ? $this->request->data['minheight'] : 0; 
445
        $modelClass = $this->modelClass; 
446
 
447
        $this->log($this->request);
448
        $folderName = Inflector::pluralize(strtolower($modelClass));
449
 
450
        if (!$this->createUploadDirectory($folderName)) {
451
            $result['message'] = 'Failed to create directory :'.$modelClass.
452
            '.  Sorry we are having trouble.  Please try again, or email help@profittill.com';
453
        } else {
454
            // To save the upload with a specified name, set the second parameter
455
            $result = $uploader->handleUpload('uploads'.DS.$folderName.DS, $uploader->getName());
456
            if($result){
457
                //Resize and create thumbnail
458
                $inFile = WWW_ROOT.'uploads'.DS.$folderName.DS. $uploader->getName();
459
 
460
                $largeOutFile = WWW_ROOT.'uploads'.DS.$folderName.DS.'large-'.basename($inFile);
461
                $this->resizeImage($inFile,$largeOutFile,800,800);
462
 
463
                $outFile = WWW_ROOT.'uploads'.DS.$folderName.DS.'small-'.basename($inFile);
464
                $this->resizeImage($inFile,$outFile,200,200);
465
 
466
                $newUrl = '/uploads/'.$folderName.'/'.basename($inFile);
467
                // To return a name used for uploaded file you can use the following line.
468
                $result['uploadName'] = $newUrl;
469
 
470
                $result['status'] = 1;
471
                $result['success'] = true;
472
                // $result['filesize'] = $filesize;
473
                $result['message'] = __('Uploaded');
474
            }
475
        }
476
        $this->log($result);
477
        return new CakeResponse(array('body' => json_encode($result)));
478
    }
479
 
480
    function cropImage ($url, $height, $width, $x1, $x2, $y1, $y2) {
481
        ini_set('memory_limit', '2G');
482
        $result['status'] = 0; 
483
        $result['message'] = __('Unable to crop');
484
 
485
        $image_type = substr($url, strrpos($url, '.', -1)); 
486
        $filepath = WWW_ROOT.substr($url, strlen(FULL_BASE_URL)+1);
487
        $croppedfile = substr($filepath, 0, strrpos($filepath, '/', -1)).
488
            '/C_'.substr($filepath, strrpos($filepath, '/', -1)+1);
489
 
490
        // Create image instances
491
        $dest = imagecreatetruecolor($x2,$y2);
492
 
493
        switch ($image_type) {
494
            case '.jpg':
495
            case '.jpeg':
496
            case '.JPEG':
497
            case '.JPG':
498
                $src = imagecreatefromjpeg($filepath);
499
                imagecopyresampled($dest,$src,0,0,$x1,$y1,$x2,$y2,$width,$height);
500
                imagejpeg($dest, $croppedfile);
501
                $ext = '.jpg';
502
                break;
503
            case '.gif':
504
                $src = imagecreatefromgif($filepath);
505
                imagecopyresampled($dest,$src,0,0,$x1,$y1,$x2,$y2,$width,$height);
506
                imagegif($dest, $croppedfile);
507
                $ext = '.gif';
508
                break;
509
            case '.png':
510
                $src = imagecreatefrompng($filepath);
511
                imagecopyresampled($dest,$src,0,0,$x1,$y1,$x2,$y2,$width,$height);
512
                imagepng($dest, $croppedfile);
513
                $ext = '.png';
514
                break;
515
            default: 
516
                $result['message'] = __('Unsupported image format.');   
517
                return $result;
518
        }
519
        $result['status'] = 1; 
520
        $result['message'] = __('Cropped');
521
        $result['data'] = substr($url, 0, strrpos($url, '/', -1)).'/C_'.substr($url, strrpos($url, '/', -1)+1);
522
        return $result;
523
    }
524
 
525
    function resizeImage ($inFile, $outFile, $w, $h) {
526
        $image = $this->Resize;
527
        $image->load($inFile);                       
528
        $image->crop($w,$h);
529
        $image->save($outFile);
530
    }
531
 
532
    public function crop() {
533
        $url = $this->request->data['file_url'];
534
        $height = $this->request->data['h']; 
535
        $width = $this->request->data['w']; 
536
        $x1 = $this->request->data['x'];
537
        $x2 = $this->request->data['x2'];
538
        $y1 = $this->request->data['y'];
539
        $y2 = $this->request->data['y2'];
540
 
541
        $result = $this->cropImage($url, $height, $width, $x1, $x2, $y1, $y2);
542
 
543
        $this->set('result', $result);
544
        $this->set('_serialize', array('result'));
545
    }
14561 anikendra 546
 
547
    public function generateMultiUrl($url,&$data){
548
    	if(!empty($data['multi']) && $data['multi']==1){
549
    		$url .= '/?multi=1';    		
550
    	}
551
    	unset($data['multi']);
552
    	return $url;
553
    }
13532 anikendra 554
}