PageRenderTime 59ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/app/controllers/creativezones_controller_bakup.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 3851 lines | 2536 code | 783 blank | 532 comment | 396 complexity | 4a890db0242573c7d2df323b93eae2e4 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. <?
  2. class CreativezonesController extends AppController {
  3. var $name='Creativezones';
  4. var $helpers = array('Html','javascript','error','Ajax','Friendsurl','Common');
  5. var $uses=array('Creativezone','User','Creative_favorites','Creative_favorite_tags','Creative_tickets','Transaction_creatives');
  6. var $components = array('Newdir','Thumbnail','Thumbnailc','Zipfile','Download','Cartmail','Creative','Sendmail');
  7. //ok
  8. function index() {
  9. //$this->checkSession();
  10. $this->pageTitle = 'ScrapFOTO&trade; Home';
  11. //$this->layout = 'creativehome';
  12. $this->layout = 'creativedetail';
  13. $this->homepageslideInfo('ScrapFOTO');
  14. //Initializing all the bradcamp back again so that it all starts all over again
  15. unset($_SESSION['bradcamp_creative']);
  16. $this->set("filename","index"); //filename should contain the name of the file that should be selected
  17. //_________________________________________________________________________________________________
  18. unset($_SESSION['buyTemplate']);
  19. //check creative_carts
  20. if(isset($_SESSION['UserId'])) {
  21. $sql = "SELECT Cart.id FROM creative_carts as Cart
  22. LEFT JOIN creative_cart_details CartDetail ON Cart.id = CartDetail.creative_cart_id
  23. LEFT JOIN creative_favorites Favorite ON Favorite.id = CartDetail.creative_favorite_id
  24. WHERE Cart.user_id ='".$_SESSION['UserId']."' AND Cart.pay_status='0' AND Favorite.is_republished ='0' AND Favorite.is_temp='1' ";
  25. $result = mysql_query($sql) or die(mysql_error());
  26. if(mysql_num_rows($result)>0) {
  27. //delete cart
  28. while($row=mysql_fetch_array($result)) {
  29. mysql_query("DELETE FROM creative_carts WHERE id='".$row['id']."' ") or die(mysql_error());
  30. }
  31. }
  32. //check delete favorite
  33. //mysql_query("DELETE FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND is_republished ='0' AND is_temp='1' ") or die(mysql_error());
  34. }
  35. $this->creativeType();
  36. $this->countFavCart();
  37. $this->getRankScrap();
  38. $this->getFeaturedScrap();
  39. $this->getPublicScrap();
  40. $this->render('index');
  41. }
  42. //ok ajax call get scrap in tab "Featured","Hight Rated","Recent"
  43. function featuredscrap($catlisttype=null) {
  44. $this->layout = 'profile_blank';
  45. ///////////////////////////////////////////////////// SQL FOR FEATURED SCRAP
  46. /* Pagination and PHOTO listing */
  47. $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.price,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
  48. $from=" FROM creative_favorites X
  49. LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
  50. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  51. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  52. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  53. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  54. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  55. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' AND X.is_stop_sell='0' ";
  56. if($catlisttype=='featured') {
  57. $where.=" AND X.is_featured='1' ";
  58. $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=featured';
  59. }
  60. $others=" group by X.id ";
  61. if($catlisttype=='mostvoted') {
  62. $others .=" order by photorat desc ";
  63. $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=mostvoted';
  64. }
  65. if(!$catlisttype) {
  66. $others.=" order by X.id desc";
  67. $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=recent';
  68. }
  69. $tabsql = $select.$from.$where. $others . ' LIMIT 12';
  70. $tabsql_res = mysql_query($tabsql);
  71. $this->set('query',$tabsql_res) ;
  72. $this->set('tabsql',$tabsql) ;
  73. $this->set('morelink',$morelink);
  74. /////////////////////////////////////////////////////////////////
  75. }
  76. //ok scrap listing
  77. function scrapxonglisting() {
  78. $this->layout = 'creativeinner';
  79. $catlisttype = '';
  80. if(isset($_REQUEST['listtype']) && $_REQUEST['listtype']!='')
  81. $catlisttype = $_REQUEST['listtype'];
  82. //this section is used to check whether to show the list based on the category given in the header section
  83. $scrapType=0;
  84. if(isset($this->params['url']['cat'])) {
  85. $scrapType=base64_decode($this->params['url']['cat']);
  86. $this->set("selTab",$scrapType);
  87. }
  88. ############################### Page Title & Head ############################
  89. $pageheadArr = array();
  90. $pageheadArr['featured'] = 'Featured';
  91. $pageheadArr['recent'] = 'Recent';
  92. $pageheadArr['mostvoted'] = 'Most Voted';
  93. $pageheadArr['mostcomment'] = 'Most Discussed';
  94. $pageheadArr['random'] = 'Random';
  95. $pageheadArr['favorite'] = 'Most Favorited ';
  96. $pageheadArr['tag'] = 'Tagged ';
  97. $pageheadArr['search'] = 'Search Result';
  98. $pageheadArr['mostviewed'] = 'Most Viewed';
  99. $pageheadArr['albumview'] = 'Album';
  100. $pageheadArr['seller'] = 'Seller';
  101. $pageheadArr['popular'] = 'Popular';
  102. if (array_key_exists($catlisttype, $pageheadArr)) {
  103. if($catlisttype=='albumview') {
  104. /* Album Name*/
  105. $albumNameSql = "Select IFNULL(creative_name,'') as albumName from creative_type where id='".base64_decode($_REQUEST['albumid'])."'";
  106. $albumNameSql_res = mysql_fetch_array(mysql_query($albumNameSql));
  107. $albumName = stripslashes($albumNameSql_res['albumName']) ;
  108. /**/
  109. $this->pageTitle = $pageheadArr[$catlisttype]. $albumName.' ScrapFOTO&trade;';
  110. $this->set('pagehead',$pageheadArr[$catlisttype].' : '. $albumName. ' ScrapFOTO&trade;');
  111. }
  112. else {
  113. if($catlisttype=='tag') {
  114. $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO&trade; : '. $_REQUEST['sortby'];
  115. $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO&trade; : '.$_REQUEST['sortby']);
  116. }
  117. else {
  118. if($catlisttype=='seller') {
  119. /* SELLER INFO */
  120. $sellinfo = " SELECT username from users where id='".base64_decode($_REQUEST['resaleby'])."'";
  121. $sellinfo_res = mysql_query($sellinfo);
  122. $sellinfo_arr = mysql_fetch_array($sellinfo_res);
  123. $this->pageTitle = 'ScrapFOTO&trade; '.$pageheadArr[$catlisttype] .' : '.$sellinfo_arr['username'];
  124. $this->set('pagehead','ScrapFOTO&trade; '.$pageheadArr[$catlisttype].' : '.$sellinfo_arr['username']);
  125. }
  126. else {
  127. $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO&trade;';
  128. $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO&trade;');
  129. }
  130. }
  131. }
  132. }
  133. else {
  134. if($catlisttype=='category') {
  135. $scrapDetail=$this->getCreativeType($scrapType);
  136. $this->pageTitle = $scrapDetail['creative_name'];
  137. $this->set('pagehead',$scrapDetail['creative_name']);
  138. }
  139. else {
  140. $this->pageTitle = 'ScrapFOTO&trade;';
  141. $this->set('pagehead','ScrapFOTO&trade;');
  142. }
  143. }
  144. ############################### Page Title & Head ############################
  145. /* Pagination and PHOTO listing */
  146. $select = " Select X.is_featured,X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
  147. $from=" FROM creative_favorites X
  148. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  149. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  150. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  151. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  152. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  153. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' AND X.is_stop_sell='0'";
  154. if($catlisttype=='featured')
  155. $where.=" AND X.is_featured='1' ";
  156. if( $catlisttype=='albumview' && isset($_REQUEST['albumid']) && base64_decode($_REQUEST['albumid'])>0)
  157. $where.=" AND XCreativetype.id='".base64_decode($_REQUEST['albumid'])."' ";
  158. if($catlisttype=='tag')
  159. $where.=" AND X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['sortby']."%')";
  160. if($catlisttype=='search')
  161. $where.=" AND X.title LIKE '%".$_REQUEST['srchtxt']."%' OR X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['srchtxt']."%') ";
  162. if($catlisttype=='seller')
  163. $where.=" AND X.user_id='".base64_decode($_REQUEST['resaleby'])."' ";
  164. if($catlisttype=='category')
  165. $where.=" AND XCreativetype.id='".$scrapType."' ";
  166. $others=" group by X.id ";
  167. if($catlisttype=='mostvoted')
  168. $others .=" order by photorat desc ";
  169. if($catlisttype=='mostcomment')
  170. $others .=" order by photoreview desc ";
  171. if($catlisttype=='mostviewed')
  172. $others .=" order by X.viewed desc ";
  173. if($catlisttype=='random')
  174. $others .=" order by X.id desc , rand()";
  175. if($catlisttype=='favorite')
  176. $others .=" order by photofavored desc ";
  177. if($catlisttype=='')
  178. $others.=" order by X.id desc";
  179. if(isset($_REQUEST['sortby']) && $_REQUEST['sortby']!='')
  180. $PassParameter="listtype=".$catlisttype."&sortby=".$_REQUEST['sortby'];
  181. else {
  182. if(isset($catlisttype) && $catlisttype=='albumview')
  183. $PassParameter="listtype=".$catlisttype."&albumid=".$_REQUEST['albumid'];
  184. else {
  185. if(isset($_REQUEST['srchtxt']) && $_REQUEST['srchtxt']!='')
  186. $PassParameter="listtype=".$catlisttype."&srchtxt=".$_REQUEST['srchtxt'];
  187. else {
  188. if(isset($_REQUEST['resaleby']) && base64_decode($_REQUEST['resaleby'])>0)
  189. $PassParameter="listtype=".$catlisttype."&resaleby=".$_REQUEST['resaleby'];
  190. else {
  191. if($catlisttype=='category')
  192. $PassParameter="listtype=".$catlisttype.'&cat='.base64_encode($scrapType) ;
  193. else
  194. $PassParameter="listtype=".$catlisttype;
  195. }
  196. }
  197. }
  198. }
  199. $fltr='';
  200. $CountField="X.id";
  201. $this->set("controller","creativezones");
  202. $this->set("action","scrapxonglisting");
  203. $this->set("parameter",$PassParameter);
  204. $this->set("fltr",$fltr);
  205. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  206. if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") ) {
  207. $this->set('pagehead','Most Recent');
  208. $this->render("scrapxonglisting2","ajax");
  209. }
  210. /**/
  211. $this->creativeType();
  212. $this->countFavCart();
  213. $this->getPublicScrap();
  214. }
  215. //ok scrap detail
  216. function scrapxong() {
  217. //$this->verifyserverUrl($_SERVER['REQUEST_URI']);
  218. $this->pageTitle = 'ScrapFOTO&trade;';
  219. $this->layout = 'creativedetail';
  220. ############################################ SCRAP XONG DETAILS
  221. $this->creativeType();
  222. $this->countFavCart();
  223. $this->getPublicScrap();
  224. $this->set('photoid',$_REQUEST['sxid']);
  225. //update viewed
  226. $select = "UPDATE creative_favorites SET viewed=viewed+1 WHERE id='".base64_decode($_REQUEST['sxid'])."' ";
  227. mysql_query($select);
  228. $select = " Select X.fileThumb2 as template_img,X.price,X.viewed,X.ssn_id,X.width,X.height,X.id,X.user_id,X.title,X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
  229. $from=" FROM creative_favorites X
  230. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  231. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  232. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  233. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  234. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  235. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.id='".base64_decode($_REQUEST['sxid'])."' AND X.type='0' AND X.is_stop_sell='0' group by X.id";
  236. $photo_sql = $select . $from .$where;
  237. $photo_res = mysql_query($photo_sql);
  238. $photores_arr = mysql_fetch_array($photo_res);
  239. $photoUrl = FULL_BASE_URL.$this->webroot."creativezones/scrapxong?sxid=".$_REQUEST['sxid'];//DOMAIN
  240. $this->set('photoUrl',$photoUrl);
  241. $this->set('photoArr', $photores_arr);
  242. $this->set('photoTitle', $photores_arr['title']);
  243. $this->set('photoDesc', $photores_arr['description']);
  244. $this->set('photoImage', $photores_arr['template_img']);
  245. $this->set('photoImageId', $photores_arr['id']);
  246. $this->set('photoUsername', $photores_arr['username']);
  247. $this->set('photototalRating', $photores_arr['photorat']);
  248. $this->set('photototalReview', $photores_arr['photoreview']);
  249. $this->set('photoPrice', number_format($photores_arr['price'],2,'.',','));
  250. $checklover = "Select * from creative_favorite_lovers where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."'" ;
  251. $checklover_res = mysql_query($checklover);
  252. $checklover_res_num = mysql_num_rows($checklover_res);
  253. $this->set('nooflover', $checklover_res_num);
  254. ##### Check for the review already posted or not
  255. $numberpreview=0;
  256. if(isset($_SESSION['UserId'])) {
  257. $checkbackdropreview = "SELECT * FROM creative_favorite_comments where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."' and user_id='".$_SESSION['UserId']."'";
  258. $checkbackdropreview_res = mysql_query($checkbackdropreview);
  259. $numberpreview = mysql_num_rows($checkbackdropreview_res);
  260. }
  261. $this->set('reviewposted', $numberpreview);
  262. #####
  263. ################################################### FOR NEXT AND PREVIOUS #######################
  264. $Imgselect="
  265. SELECT CF.id,title,template_img
  266. FROM creative_favorites CF,creative_favorites_details CFDTL
  267. WHERE CF.id=CFDTL.creative_favorite_id AND CF.type='0'
  268. GROUP BY CF.id ORDER BY CF.id DESC
  269. " ;
  270. $Imgselect_res = mysql_query($Imgselect);
  271. $Imgarray = array();
  272. while($Imgselect_arr = mysql_fetch_array($Imgselect_res)) {
  273. //$Imgarray['image'.$Imgselect_arr['id']] = $Imgselect_arr['id'] ;
  274. $Imgarray[] = $Imgselect_arr['id'] ;
  275. }
  276. //pr($Imgarray);
  277. //echo base64_decode($_REQUEST['pid']) ;
  278. $searchKey = array_search(base64_decode($_REQUEST['sxid']),$Imgarray) ;
  279. // Next
  280. $searchKeyNext = ($searchKey + 1);
  281. $searchKeyPrev = ($searchKey - 1);
  282. if (array_key_exists($searchKeyNext, $Imgarray)) {
  283. $this->set('nxtImage',$Imgarray[$searchKeyNext]);
  284. }
  285. // Prev
  286. if (array_key_exists($searchKeyPrev, $Imgarray)) {
  287. $this->set('prevImage',$Imgarray[$searchKeyPrev]);
  288. }
  289. ################################################### FOR NEXT AND PREVIOUS #######################
  290. ########
  291. }
  292. //checking
  293. function creativetemplate() {
  294. //$this->checkSession();
  295. $this->pageTitle = 'ScrapFOTO&trade; - Create Template';
  296. $this->layout = 'creativehome';
  297. $this->creativeType();
  298. //This ct variable comes from INDEX page and CREATIVETEMPLATE page
  299. //This variable contains the category Id
  300. if(isset($this->params['url']['ct']))
  301. $id=base64_decode($this->params['url']['ct']);
  302. //This ct variable comes from CREATIVETEMPLATE page
  303. $tmpImg=0;
  304. if(isset($this->params['url']['pg']))
  305. $tmpImg=base64_decode($this->params['url']['pg']);
  306. $themeId=0;
  307. if(isset($this->params['url']['tmplate']))
  308. $themeId=base64_decode($this->params['url']['tmplate']);
  309. //this variable is used to show the selected section in the accordian tag
  310. $this->set("cType",$id);
  311. $this->set("cTemplate",$tmpImg);
  312. $this->set("themeId",$themeId);
  313. //Initializing all the bradcamp back again so that it all starts all over again
  314. $this->set("filename","creativetemplate"); //filename should contain the name of the file that should be selected
  315. $_SESSION['bradcamp_creative'][20]=$this->params['action']; //we are passing the name of the file to keep track which step is visited
  316. $this->set("nextpage","creativezone");
  317. //_________________________________________________________________________________________________
  318. $this->countFavCart();
  319. /*
  320. // getting out the template name under the type
  321. if(isset($id)) {
  322. $templateName = array();
  323. $tempname="
  324. SELECT CP.*
  325. FROM creative_type CT,creative_template_pages CP
  326. WHERE CT.id=CP.creative_type_id AND CT.id='".$id."' AND block='0'
  327. ORDER BY CP.template_type ASC,CP.title ASC
  328. ";
  329. $tempname_res = mysql_query($tempname) or die('Line number '.__LINE__. mysql_error());
  330. $tempNum = mysql_num_rows($tempname_res);
  331. if($tempNum > 0) {
  332. $i=0;
  333. while($rwTmp = mysql_fetch_assoc($tempname_res)) {
  334. if($i==0) {
  335. $defaultTmpId=$rwTmp['id'];
  336. $this->set("defaultTemplateId",$defaultTmpId);
  337. }
  338. $i++;
  339. $templateName[$rwTmp['id']]=array($rwTmp['title'],$rwTmp['template_img'],$rwTmp['price'],$rwTmp['template_type']);
  340. }
  341. }
  342. }
  343. $this->set('templateImg',$templateName);
  344. //Getting the large thimbnail image
  345. if(isset($tmpImg) && $tmpImg!=0) {
  346. $this->templateDetail($tmpImg);
  347. $this->render("template","ajax");
  348. }
  349. if(isset($this->params['url']['tpage'])) {
  350. //print "test";
  351. $tPage=base64_decode($this->params['url']['tpage']);
  352. $this->templateDetail($tPage);
  353. //exit;
  354. $this->render("template","ajax");
  355. }
  356. */
  357. }
  358. //checking
  359. function creativetemplatezone() {
  360. $this->checkSession();
  361. $this->pageTitle = 'ScrapFOTO&trade; - Creative Zone';
  362. $this->layout = 'creativehome';
  363. $this->creativeType();
  364. //Initializing all the bradcamp back again so that it all starts all over again
  365. $this->set("filename","creativetemplatezone"); //filename should contain the name of the file that should be selected
  366. $this->set("nextpage","creative_favorite");
  367. //_________________________________________________________________________________________________
  368. if(isset($this->params['url']['tmp'])) {
  369. $tmpImg=base64_decode($this->params['url']['tmp']);
  370. $tmpImg = $this->templateDetail($tmpImg);
  371. if($tmpImg==0) {
  372. $this->redirect('/creativezones/index');
  373. }else {
  374. //emty cart current
  375. $sql ="SELECT id FROM creative_carts WHERE pay_status='0' ";
  376. $result = mysql_query($sql) or die(mysql_error());
  377. if(mysql_num_rows($result)>0) {
  378. while($row=mysql_fetch_array($result)) {
  379. $sql ="DELETE FROM creative_cart_details WHERE creative_cart_id='".$row['id']."' ";
  380. mysql_query($sql) or die(mysql_error());
  381. }
  382. }
  383. //add favorite
  384. if(!isset($_SESSION['buyTemplate']['tmpId'])) {
  385. $_SESSION['buyTemplate']['tmpId'] = $tmpImg;
  386. //add to favorite
  387. $fav = $this->Creative_favorites->findById($tmpImg);
  388. $fav['Creative_favorites']['id'] = null;
  389. $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
  390. $fav['Creative_favorites']['is_temp'] = 1;
  391. $fav['Creative_favorites']['type'] = 1;
  392. $fav['Creative_favorites']['is_featured'] = 0;
  393. $fav['Creative_favorites']['is_republished'] = 0;
  394. $this->Creative_favorites->create();
  395. $this->Creative_favorites->save($fav);
  396. $idNew = $this->Creative_favorites->id;
  397. $_SESSION['buyTemplate']['idNew'] = $idNew;
  398. }
  399. }
  400. }
  401. $this->countFavCart();
  402. //case create form header
  403. if(isset($_POST['widthScrap'])) {
  404. $this->set('widthScrap',$_POST['widthScrap']);
  405. $this->set('heightScrap',$_POST['heightScrap']);
  406. $this->set('titleScrap',$_POST['titleScrap']);
  407. }
  408. }
  409. //checking
  410. function creative_favorite() {
  411. $this->checkSession();
  412. $this->pageTitle = 'ScrapFOTO&trade; - My Favorite';
  413. $this->layout = 'creativehome';
  414. $this->creativeType();
  415. //This ct variable comes from INDEX page and CREATIVETEMPLATE page
  416. $tmpImg=0;
  417. if(isset($this->params['url']['tmp'])) {
  418. $tmpImg=base64_decode($this->params['url']['tmp']);
  419. $tmpImg = $this->templateDetail($tmpImg);
  420. }else if(isset($_SESSION['buyTemplate']['tmpId'])) {
  421. $tmpImg = $_SESSION['buyTemplate']['tmpId'];
  422. $tmpImg = $this->templateDetail($tmpImg);
  423. }
  424. if(isset($_POST['ssn_id'])) {
  425. $ssn_id = $_POST['ssn_id'];
  426. $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
  427. if(!$fav) {//create
  428. $this->Creative_favorites->create();
  429. }
  430. else {//update
  431. $this->Creative_favorites->id = $fav['Creative_favorites']['id'];
  432. }
  433. $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
  434. $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
  435. $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
  436. $fav['Creative_favorites']['description'] = $_POST['description'];
  437. $fav['Creative_favorites']['price'] = $_POST['price'];
  438. $fav['Creative_favorites']['width'] = $_POST['width'];
  439. $fav['Creative_favorites']['height'] = $_POST['height'];
  440. $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
  441. $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
  442. $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
  443. $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
  444. $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
  445. $fav['Creative_favorites']['is_temp'] = 0;
  446. $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
  447. $fav['Creative_favorites']['type'] = $_POST['type'];
  448. $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
  449. $fav['Creative_favorites']['is_temp'] = $fav['Creative_favorites']['is_featured'];
  450. if($fav['Creative_favorites']['type']==0) {//public
  451. $featuredAmount=$this->getConfigAmount('creative artist price');
  452. $fav['Creative_favorites']['price'] = $featuredAmount['config_value'];
  453. }
  454. $resultSave = $this->Creative_favorites->save($fav);//return 1/null
  455. //insert tag
  456. if($resultSave && $_POST['tag']!='') {
  457. $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
  458. $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
  459. $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
  460. $this->Creative_favorite_tags->create();
  461. $this->Creative_favorite_tags->save($tag);
  462. }
  463. if($fav['Creative_favorites']['type']==0) {
  464. if($resultSave && $fav['Creative_favorites']['is_featured']==1) {
  465. $this->redirect("creativezones/creative_featured?lid=".base64_encode($this->Creative_favorites->id));
  466. exit();
  467. }else {
  468. $this->redirect("creativezones/featuredsuccess?lid=".base64_encode($this->Creative_favorites->id));
  469. }
  470. }
  471. }
  472. if(isset($_POST['actionCall']) && $_POST['actionCall']=='exit') {
  473. $this->redirect('/creativezones/index');
  474. }
  475. if($tmpImg==0) {
  476. unset($_SESSION['buyTemplate']);
  477. $favs = null;
  478. $result = mysql_query("SELECT * FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND is_temp='0' AND is_republished='1' ") or die("Error on line :".__LINE__.mysql_error());
  479. if(mysql_num_rows($result)>0) {
  480. $favs = $result;
  481. }
  482. $this->set("favs",$favs);
  483. }else if(isset($_SESSION['buyTemplate']['idNew'])) {
  484. $favs = null;
  485. $result = mysql_query("SELECT * FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND id='".$_SESSION['buyTemplate']['idNew']."' ") or die("Error on line :".__LINE__.mysql_error());
  486. if(mysql_num_rows($result)>0) {
  487. $favs = $result;
  488. }
  489. $this->set("favs",$favs);
  490. }
  491. $this->countFavCart();
  492. //Initializing all the bradcamp back again so that it all starts all over again
  493. $this->set("filename","creative_favorite");
  494. $this->set("nextpage","mycart");
  495. //_________________________________________________________________________________________________
  496. $this->set("recenttype","creative_favorite");
  497. $this->getCartDetails();
  498. }
  499. //ok
  500. function creative_favorite_ajax() {
  501. if(isset($_POST['ssn_id'])) {
  502. $ssn_id = $_POST['ssn_id'];
  503. $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
  504. if(!$fav) {
  505. $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
  506. $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
  507. $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
  508. $fav['Creative_favorites']['description'] = $_POST['description'];
  509. $fav['Creative_favorites']['price'] = $_POST['price'];
  510. $fav['Creative_favorites']['width'] = $_POST['width'];
  511. $fav['Creative_favorites']['height'] = $_POST['height'];
  512. $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
  513. $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
  514. $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
  515. $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
  516. $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
  517. $fav['Creative_favorites']['is_temp'] = 0;
  518. $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
  519. $fav['Creative_favorites']['type'] = $_POST['type'];
  520. $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
  521. $this->Creative_favorites->create();
  522. $resultSave = $this->Creative_favorites->save($fav);//return 1/null
  523. //insert tag
  524. if($resultSave && $_POST['tag']!='') {
  525. $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
  526. $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
  527. $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
  528. $this->Creative_favorite_tags->create();
  529. $this->Creative_favorite_tags->save($tag);
  530. }
  531. }
  532. }
  533. $this->countFavCart();
  534. $this->render("creative_favorite_ajax","ajax");
  535. }
  536. function creativeType() {
  537. $q1=mysql_query("SELECT * FROM creative_type WHERE is_delete='0' ORDER BY sequence ASC");
  538. $i=0;
  539. while($rwCr=mysql_fetch_array($q1)) {
  540. if($i==0)
  541. $defaultCat[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
  542. $i++;
  543. $creativeType[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
  544. }
  545. $this->set("defaultType",$defaultCat);
  546. $this->set("creativeType",$creativeType);
  547. $type = 0;
  548. foreach($defaultCat as $key=>$value) {
  549. $type = $key;
  550. break;
  551. }
  552. if(isset($this->params['url']['cat'])) {
  553. $scrapType=base64_decode($this->params['url']['cat']);
  554. $detail = $this->getCreativeType($scrapType);
  555. if($detail) {
  556. $type = $detail['id'];
  557. }
  558. }
  559. $this->set('defaultCate',$type);
  560. }
  561. //checking
  562. function templateDetail($tmpImg) {
  563. $q1=mysql_query("SELECT * FROM creative_favorites WHERE id='".$tmpImg."' AND is_blocked='0' AND is_temp='0' AND is_approved='1' AND type='0' ") or die(mysql_error());
  564. if(mysql_num_rows($q1)>0) {
  565. $rwTmpImg=mysql_fetch_assoc($q1);
  566. $this->set("tmpid",base64_encode($rwTmpImg['ssn_id']));
  567. $this->set("tmp",base64_encode($tmpImg));
  568. return $tmpImg;
  569. }
  570. return 0;
  571. }
  572. //ok
  573. function getPublicScrap() {
  574. $select = " Select X.price,X.fileThumb2 as imagename,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
  575. $from=" FROM creative_favorites X
  576. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  577. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  578. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  579. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  580. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  581. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' AND X.is_stop_sell='0'";
  582. $others=" group by X.id ";
  583. $others .=" order by photorat desc ";
  584. $queryCreative = $select . $from . $where .$others ;
  585. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  586. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  587. $this->set("publicScrap",$queryCreativeFavorites);
  588. $this->set("publicScrapSql",$queryCreative);
  589. }
  590. //ok
  591. function getRankScrap() {
  592. /*$select = " Select X.fileThumb2 as template_img,X.price,X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat";
  593. $from=" FROM creative_favorites X
  594. LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
  595. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  596. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  597. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  598. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  599. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' ";
  600. $others=" group by X.id ";
  601. $others .=" order by photorat desc LIMIT 21";
  602. $queryCreative = $select . $from . $where .$others ;
  603. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  604. $this->set("publicRank",$queryCreativeFavorites);
  605. $this->set("publicRankSql",$queryCreative);
  606. */
  607. }
  608. //ok
  609. function getFeaturedScrap() {
  610. /*$select = " Select X.width, X.height, X.price, X.id,X.creation,X.user_id,X.title,XCreativetype.creative_name ,XCreativetype.id as creativetypeid, X.description,XCreativetypeDetail.template_img,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat,Xalbum.price";
  611. $from=" FROM creative_favorites X
  612. LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
  613. LEFT JOIN creative_template_pages Xalbum ON X.creative_template_page_id = Xalbum.id
  614. LEFT JOIN creative_type XCreativetype ON Xalbum.creative_type_id = XCreativetype.id
  615. LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
  616. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  617. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  618. LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
  619. $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_featured='1' AND X.is_approved='1' ";
  620. $others=" group by X.id ";
  621. $others .=" order by photorat desc LIMIT 21";
  622. $queryCreative = $select . $from . $where .$others ;
  623. $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
  624. $this->set("publicFeatured",$queryCreativeFavorites);
  625. $this->set("publicFeaturedSql",$queryCreative);
  626. */
  627. }
  628. //ok
  629. function viewalltag() {
  630. $this->pageTitle = 'ScrapFOTO&trade; - View Tag';
  631. $this->layout = 'creativedetail';
  632. $this->creativeType();
  633. $this->getPublicScrap();
  634. }
  635. //ok
  636. function searchtag($alphasearch=null) {
  637. if($alphasearch)
  638. $searchtxt = "'".strtolower($alphasearch)."%'" ;
  639. else {
  640. if(isset($_REQUEST['txttagsearch']) && $_REQUEST['txttagsearch']!='')
  641. $searchtxt = "'%". strip_html_tags($_REQUEST['txttagsearch'])."%'";
  642. else
  643. $searchtxt='a%';
  644. }
  645. $tagarray = array();
  646. $tagsearchsql = "SELECT DISTINCT(tagname) FROM creative_favorite_tags where tagname!='' and tagname like ". $searchtxt ."";
  647. $tagsearchsql_res = mysql_query($tagsearchsql);
  648. while($tagsearchsql_arr = mysql_fetch_array($tagsearchsql_res)) {
  649. $tagarray[] = $tagsearchsql_arr['tagname'];
  650. }
  651. $this->set('tagsql',$tagsearchsql);
  652. $this->set('tagarray',$tagarray);
  653. $this->set('Numtagarray',mysql_num_rows($tagsearchsql_res));
  654. $this->set('searchtxt',$alphasearch);
  655. $this->render('searchtaglist', 'ajax');
  656. }
  657. //ok
  658. function scrapaddtocart($scrapxongid=null) {
  659. $queryCreativeFavorites=mysql_query("
  660. SELECT CF.title,CTP.price
  661. FROM creative_favorites CF,creative_template_pages CTP
  662. WHERE CF.id='".base64_decode($scrapxongid)."' AND CF.creative_template_page_id=CTP.id AND CF.type='0'");
  663. $fetchCreativeFavorites=mysql_fetch_assoc($queryCreativeFavorites);
  664. $productName=$fetchCreativeFavorites['title'];
  665. $price=$fetchCreativeFavorites['price'];
  666. if(isset($_SESSION['UserId'])) {
  667. $creativecartsql = "SELECT * from creative_carts WHERE user_id='".$_SESSION['UserId']."' and product_name='".$productName."' and ssn_id='".session_id()."' and pay_status='0'";
  668. $creativecartsql_res = mysql_query($creativecartsql);
  669. if(mysql_num_rows($creativecartsql_res)==0) {
  670. mysql_query("INSERT INTO
  671. creative_carts(user_id,product_name,price,qty,transaction_creative_id,pay_status,ssn_id)
  672. VALUES('".$_SESSION['UserId']."','".$productName."','".$price."','1','0','0','".session_id()."')") or die("Error on line : ".__LINE__.mysql_error());
  673. $lastId=mysql_insert_id();
  674. $queryCreativeFavoritesDetails=mysql_query("SELECT template_img FROM creative_favorites_details WHERE creative_favorite_id='".base64_decode($scrapxongid)."'");
  675. while($fetchCreativeFavoritesDetails=mysql_fetch_assoc($queryCreativeFavoritesDetails)) {
  676. mysql_query("INSERT INTO creative_cart_details(creative_cart_id,imagename) VALUES('".$lastId."','".$fetchCreativeFavoritesDetails['template_img']."')");
  677. }
  678. }
  679. }
  680. $this->countFavCart();
  681. $this->set('photoImageId',$scrapxongid);
  682. $this->render('cartitem', 'ajax');
  683. }
  684. function creative_login() {
  685. $uName=base64_decode($this->params['url']['u']);
  686. $password=$this->params['url']['p'];
  687. $id=0;
  688. if(isset($this->params['url']['ct']))
  689. $id=base64_decode($this->params['url']['ct']);
  690. //This ct variable comes from CREATIVETEMPLATE page
  691. $tmpImg=0;
  692. if(isset($this->params['url']['tmp']))
  693. $tmpImg=base64_decode($this->params['url']['tmp']);
  694. //This is the last iserted id in the favorite table
  695. $lastId=0;
  696. if(isset($this->params['url']['lid']))
  697. $lastId=base64_decode($this->params['url']['lid']);
  698. $someone=$this->userLogin($uName,$password);
  699. if(!empty($someone))
  700. $this->redirect("creativezones/creative_favorite?ct=".base64_encode($id)."&tmp=".base64_encode($tmpImg)."&lid=".base64_encode($lastId));
  701. }
  702. function featuredpayment() {
  703. /*
  704. $this->checkSession();
  705. $this->layout = 'previewpaymemnt';
  706. $this->render("paymentback");
  707. //This ct variable comes from INDEX page and CREATIVETEMPLATE page
  708. $id=0;
  709. if(isset($this->params['url']['ct']))
  710. $id=base64_decode($this->params['url']['ct']);
  711. //This ct variable comes from CREATIVETEMPLATE page
  712. $tmpImg=0;
  713. if(isset($this->params['url']['tmp']))
  714. $tmpImg=base64_decode($this->params['url']['tmp']);
  715. //This is the last iserted id in the favorite table
  716. //If lid means user comes to this page after saving the scrapbook
  717. //We are checking whether the user features the scrapblog or not if yes then ask for the payment
  718. $lastId=0;
  719. if(isset($this->params['url']['lid']))
  720. $lastId=base64_decode($this->params['url']['lid']);
  721. $this->set("cType",$id);
  722. $this->set("cTemplate",$tmpImg);
  723. $this->set("lastId",$lastId);
  724. if(!empty($this->data)) {
  725. $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
  726. $featuredAmount=$this->getConfigAmount('creative featured');
  727. $amountCharge=$this->data['creative']['amount'];
  728. if(isset($this->data['Event']['radiobutton'])) {
  729. if($this->data['Event']['radiobutton']=="paypal") {
  730. $this->itemName="ScrapFOTO&trade; fetaured";
  731. $this->amountPay=$amountCharge;
  732. $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
  733. $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
  734. $this->merchantEmail=$fetchAdminPaymentSetup['paypal_email'];
  735. $this->custom=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId;
  736. $this->paypal();
  737. }
  738. if($this->data['Event']['radiobutton']=="google") {
  739. $adminPayment=$fetchAdminPaymentSetup['gcheckout_email'];
  740. $adminPaymentDetails=explode("break",$adminPayment);
  741. $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
  742. $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
  743. $this->Gcheckout->gItemName="ScrapFOTO&trade; Featured";
  744. $this->Gcheckout->gItemDesc="ScrapFOTO&trade; Featured";
  745. $this->Gcheckout->gQuantity=1;
  746. $this->Gcheckout->gPrice=$amountCharge;
  747. $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
  748. $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
  749. $this->Gcheckout->customData=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId."^".$amountCharge;
  750. $this->Gcheckout->google();
  751. }
  752. }
  753. }*/
  754. }
  755. function creative_featured() {
  756. $this->checkSession();
  757. $this->pageTitle = 'ScrapFOTO&trade; - Featured ScrapFOTO&trade;';
  758. $this->layout = 'creativehome';
  759. $this->creativeType();
  760. $this->getPublicScrap();
  761. $cartCount=$this->countFavCart();
  762. $tmpImg =0;
  763. $id =0;
  764. $lastId=0;
  765. if(isset($this->params['url']['lid']))
  766. $lastId=base64_decode($this->params['url']['lid']);
  767. $this->set("lastId",$lastId);
  768. $this->set("filename","creative_cart");
  769. $this->set("recenttype","creative_favorite");
  770. $featuredAmount=$this->getConfigAmount('creative featured');
  771. $this->set("featuredAmount",$featuredAmount);
  772. //getCartDetails;
  773. $sql = "SELECT *,CF.fileThumb2 as imagename FROM creative_favorites as CF WHERE CF.id='".$lastId."' LIMIT 1";
  774. $queryCreativeCarts=mysql_query($sql);
  775. $this->set("queryCreativeCarts",$queryCreativeCarts);
  776. $this->getUserDetails();
  777. $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
  778. $this->set("paymentMethods",$fetchAdminPaymentSetup);
  779. }
  780. //checking
  781. function featured_payment_notify() {
  782. /*
  783. $this->Paypal->paypal_class();
  784. $this->Paypal->paypal_url = $this->paypalUrl; // testing paypal url
  785. //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
  786. $paypal=0;
  787. if ($this->Paypal->validate_ipn()) {
  788. $paypal=1;
  789. if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="") {
  790. $totalPay=$this->Paypal->ipn_data['payment_gross'];
  791. $custom=explode("^",$this->Paypal->ipn_data['custom']);
  792. $userId=$custom['0'];
  793. $lastId=$custom['1'];
  794. $invoice=$_POST['invoice'];
  795. $ticket=$custom['3'];
  796. }
  797. }
  798. //This section is used to catch from GOOGLE IPN data
  799. if(!$paypal) {
  800. //this section is used to update from google IPN data
  801. $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
  802. if($xml_response) {
  803. $gCustom=$this->parseXmlArray($xml_response);
  804. $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
  805. $ipnData=explode("^",$cData);
  806. $userId=$ipnData['0'];
  807. $lastId=$ipnData['1'];
  808. $invoice=$ipnData['2'];
  809. $ticket=$ipnData['3'];
  810. $totalPay=$ipnData['4'];
  811. }
  812. }
  813. */
  814. }
  815. //checking
  816. function featuredsuccess() {
  817. $is_featured = 1;
  818. $productId=0;
  819. if(isset($this->params['url']['lid']))
  820. $productId=base64_decode($this->params['url']['lid']);
  821. if($productId==0) {
  822. //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
  823. $paypal=0;
  824. if (isset($_POST['payment_gross']) && ($_POST['payment_gross'])!="") {
  825. $paypal=1;
  826. $totalPay=$_POST['payment_gross'];
  827. $custom=explode("^",$_POST['custom']);
  828. $userId=$custom['0'];
  829. $sellerId=$custom['1'];
  830. $isAdmin=$custom['2'];
  831. $rdPage=$custom['3'];
  832. $invoice=$custom['4'];
  833. $transactionId=$custom['5'];
  834. $ticket=$custom['6'];
  835. $productId=$custom['7'];
  836. }
  837. //This section is used to catch from GOOGLE IPN data
  838. if(!$paypal) {
  839. //this section is used to update from google IPN data
  840. $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
  841. if($xml_response) {
  842. $gCustom=$this->parseXmlArray($xml_response);
  843. $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
  844. $ipnData=explode("^",$cData);
  845. $userId=$ipnData['0'];
  846. $sellerId=$ipnData['1'];
  847. $isAdmin=$ipnData['2'];
  848. $rdPage=$ipnData['3'];
  849. $invoice=$ipnData['4'];
  850. $transactionId=$ipnData['5'];
  851. $totalPay=$ipnData['6'];
  852. $ticket=$ipnData['7'];
  853. $productId=$ipnData['8'];
  854. }
  855. }
  856. }else {
  857. $userId = $_SESSION['UserId'];
  858. $totalPay = 0;
  859. $ticket = $this->createTransactionNumber('SPTT');
  860. $is_featured = 0;
  861. }
  862. //________________________________________________XOIMAGE DATABASE UPDATION SECTION
  863. //update featured_time
  864. $featured_time = NULL;
  865. if($is_featured==1){
  866. $result = $this->getConfigAmount('creative featured days');
  867. $featureddays = $result['config_value'];
  868. $featured_time = date('Y-m-d G:i:s', strtotime("+".$featureddays." day"));
  869. }
  870. $queryCreativeFavorites=mysql_query("
  871. UPDATE creative_favorites
  872. SET is_featured='$is_featured',is_temp='0', featured_time='".$featured_time."'
  873. WHERE user_id='".$userId."' AND id='".$productId."'") or die("Error on line : ".__LINE__.mysql_error());
  874. if(isset($transactionId)) {
  875. //UPDATE date on TRANSACTION_CREATIVE TABLE
  876. $queryUpdateTransactionCreative="
  877. UPDATE transaction_creatives
  878. SET pay_status='1',invoice='".$invoice."'
  879. WHERE id='".$transactionId."' AND user_id='".$userId."'";
  880. mysql_query($queryUpdateTransactionCreative) or die("Error on line : ".__LINE__.mysql_error());
  881. //UPDATE data to the CREATIVE_CARTS TABLE after successful transaction
  882. $queryUpdateCreativeCart="
  883. UPDATE creative_carts
  884. SET pay_status='1', total_price='".$totalPay."'

Large files files are truncated, but you can click here to view the full file