/app/controllers/creativezones_controller_bakup.php
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
- <?
- class CreativezonesController extends AppController {
- var $name='Creativezones';
- var $helpers = array('Html','javascript','error','Ajax','Friendsurl','Common');
- var $uses=array('Creativezone','User','Creative_favorites','Creative_favorite_tags','Creative_tickets','Transaction_creatives');
- var $components = array('Newdir','Thumbnail','Thumbnailc','Zipfile','Download','Cartmail','Creative','Sendmail');
-
-
- //ok
- function index() {
- //$this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ Home';
- //$this->layout = 'creativehome';
- $this->layout = 'creativedetail';
- $this->homepageslideInfo('ScrapFOTO');
-
- //Initializing all the bradcamp back again so that it all starts all over again
- unset($_SESSION['bradcamp_creative']);
- $this->set("filename","index"); //filename should contain the name of the file that should be selected
-
- //_________________________________________________________________________________________________
-
- unset($_SESSION['buyTemplate']);
- //check creative_carts
- if(isset($_SESSION['UserId'])) {
- $sql = "SELECT Cart.id FROM creative_carts as Cart
- LEFT JOIN creative_cart_details CartDetail ON Cart.id = CartDetail.creative_cart_id
- LEFT JOIN creative_favorites Favorite ON Favorite.id = CartDetail.creative_favorite_id
- WHERE Cart.user_id ='".$_SESSION['UserId']."' AND Cart.pay_status='0' AND Favorite.is_republished ='0' AND Favorite.is_temp='1' ";
-
- $result = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($result)>0) {
- //delete cart
- while($row=mysql_fetch_array($result)) {
- mysql_query("DELETE FROM creative_carts WHERE id='".$row['id']."' ") or die(mysql_error());
- }
- }
-
- //check delete favorite
- //mysql_query("DELETE FROM creative_favorites WHERE user_id='".$_SESSION['UserId']."' AND is_republished ='0' AND is_temp='1' ") or die(mysql_error());
- }
-
- $this->creativeType();
- $this->countFavCart();
- $this->getRankScrap();
- $this->getFeaturedScrap();
- $this->getPublicScrap();
-
- $this->render('index');
- }
-
- //ok ajax call get scrap in tab "Featured","Hight Rated","Recent"
- function featuredscrap($catlisttype=null) {
- $this->layout = 'profile_blank';
- ///////////////////////////////////////////////////// SQL FOR FEATURED SCRAP
- /* Pagination and PHOTO listing */
- $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";
-
- $from=" FROM creative_favorites X
-
- LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $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' ";
-
-
- if($catlisttype=='featured') {
- $where.=" AND X.is_featured='1' ";
- $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=featured';
- }
-
- $others=" group by X.id ";
-
- if($catlisttype=='mostvoted') {
- $others .=" order by photorat desc ";
- $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=mostvoted';
-
- }
-
- if(!$catlisttype) {
- $others.=" order by X.id desc";
- $morelink=$this->webroot.'creativezones/scrapxonglisting?listtype=recent';
-
- }
-
- $tabsql = $select.$from.$where. $others . ' LIMIT 12';
- $tabsql_res = mysql_query($tabsql);
- $this->set('query',$tabsql_res) ;
- $this->set('tabsql',$tabsql) ;
- $this->set('morelink',$morelink);
- /////////////////////////////////////////////////////////////////
- }
-
- //ok scrap listing
- function scrapxonglisting() {
- $this->layout = 'creativeinner';
-
- $catlisttype = '';
- if(isset($_REQUEST['listtype']) && $_REQUEST['listtype']!='')
- $catlisttype = $_REQUEST['listtype'];
-
- //this section is used to check whether to show the list based on the category given in the header section
- $scrapType=0;
- if(isset($this->params['url']['cat'])) {
- $scrapType=base64_decode($this->params['url']['cat']);
- $this->set("selTab",$scrapType);
- }
-
- ############################### Page Title & Head ############################
-
- $pageheadArr = array();
- $pageheadArr['featured'] = 'Featured';
- $pageheadArr['recent'] = 'Recent';
- $pageheadArr['mostvoted'] = 'Most Voted';
- $pageheadArr['mostcomment'] = 'Most Discussed';
- $pageheadArr['random'] = 'Random';
- $pageheadArr['favorite'] = 'Most Favorited ';
- $pageheadArr['tag'] = 'Tagged ';
- $pageheadArr['search'] = 'Search Result';
- $pageheadArr['mostviewed'] = 'Most Viewed';
- $pageheadArr['albumview'] = 'Album';
- $pageheadArr['seller'] = 'Seller';
- $pageheadArr['popular'] = 'Popular';
- if (array_key_exists($catlisttype, $pageheadArr)) {
- if($catlisttype=='albumview') {
- /* Album Name*/
- $albumNameSql = "Select IFNULL(creative_name,'') as albumName from creative_type where id='".base64_decode($_REQUEST['albumid'])."'";
- $albumNameSql_res = mysql_fetch_array(mysql_query($albumNameSql));
- $albumName = stripslashes($albumNameSql_res['albumName']) ;
- /**/
- $this->pageTitle = $pageheadArr[$catlisttype]. $albumName.' ScrapFOTO™';
- $this->set('pagehead',$pageheadArr[$catlisttype].' : '. $albumName. ' ScrapFOTO™');
-
- }
- else {
- if($catlisttype=='tag') {
- $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO™ : '. $_REQUEST['sortby'];
- $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO™ : '.$_REQUEST['sortby']);
- }
- else {
- if($catlisttype=='seller') {
- /* SELLER INFO */
- $sellinfo = " SELECT username from users where id='".base64_decode($_REQUEST['resaleby'])."'";
- $sellinfo_res = mysql_query($sellinfo);
- $sellinfo_arr = mysql_fetch_array($sellinfo_res);
-
- $this->pageTitle = 'ScrapFOTO™ '.$pageheadArr[$catlisttype] .' : '.$sellinfo_arr['username'];
- $this->set('pagehead','ScrapFOTO™ '.$pageheadArr[$catlisttype].' : '.$sellinfo_arr['username']);
-
- }
- else {
- $this->pageTitle = $pageheadArr[$catlisttype].' ScrapFOTO™';
- $this->set('pagehead',$pageheadArr[$catlisttype].' ScrapFOTO™');
- }
- }
- }
- }
- else {
- if($catlisttype=='category') {
- $scrapDetail=$this->getCreativeType($scrapType);
- $this->pageTitle = $scrapDetail['creative_name'];
- $this->set('pagehead',$scrapDetail['creative_name']);
- }
- else {
- $this->pageTitle = 'ScrapFOTO™';
- $this->set('pagehead','ScrapFOTO™');
- }
- }
- ############################### Page Title & Head ############################
- /* Pagination and PHOTO listing */
- $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";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $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'";
-
-
- if($catlisttype=='featured')
- $where.=" AND X.is_featured='1' ";
- if( $catlisttype=='albumview' && isset($_REQUEST['albumid']) && base64_decode($_REQUEST['albumid'])>0)
- $where.=" AND XCreativetype.id='".base64_decode($_REQUEST['albumid'])."' ";
- if($catlisttype=='tag')
- $where.=" AND X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['sortby']."%')";
- if($catlisttype=='search')
- $where.=" AND X.title LIKE '%".$_REQUEST['srchtxt']."%' OR X.id IN (Select creative_favorite_id from creative_favorite_tags where tagname Like '%".$_REQUEST['srchtxt']."%') ";
- if($catlisttype=='seller')
- $where.=" AND X.user_id='".base64_decode($_REQUEST['resaleby'])."' ";
-
- if($catlisttype=='category')
- $where.=" AND XCreativetype.id='".$scrapType."' ";
-
-
- $others=" group by X.id ";
-
- if($catlisttype=='mostvoted')
- $others .=" order by photorat desc ";
-
- if($catlisttype=='mostcomment')
- $others .=" order by photoreview desc ";
-
- if($catlisttype=='mostviewed')
- $others .=" order by X.viewed desc ";
- if($catlisttype=='random')
- $others .=" order by X.id desc , rand()";
-
- if($catlisttype=='favorite')
- $others .=" order by photofavored desc ";
-
- if($catlisttype=='')
- $others.=" order by X.id desc";
-
-
- if(isset($_REQUEST['sortby']) && $_REQUEST['sortby']!='')
- $PassParameter="listtype=".$catlisttype."&sortby=".$_REQUEST['sortby'];
- else {
- if(isset($catlisttype) && $catlisttype=='albumview')
- $PassParameter="listtype=".$catlisttype."&albumid=".$_REQUEST['albumid'];
- else {
- if(isset($_REQUEST['srchtxt']) && $_REQUEST['srchtxt']!='')
- $PassParameter="listtype=".$catlisttype."&srchtxt=".$_REQUEST['srchtxt'];
- else {
- if(isset($_REQUEST['resaleby']) && base64_decode($_REQUEST['resaleby'])>0)
- $PassParameter="listtype=".$catlisttype."&resaleby=".$_REQUEST['resaleby'];
- else {
- if($catlisttype=='category')
- $PassParameter="listtype=".$catlisttype.'&cat='.base64_encode($scrapType) ;
- else
- $PassParameter="listtype=".$catlisttype;
- }
- }
- }
- }
-
-
-
- $fltr='';
- $CountField="X.id";
- $this->set("controller","creativezones");
- $this->set("action","scrapxonglisting");
- $this->set("parameter",$PassParameter);
- $this->set("fltr",$fltr);
-
- $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
- if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") ) {
- $this->set('pagehead','Most Recent');
- $this->render("scrapxonglisting2","ajax");
- }
-
- /**/
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
- }
-
- //ok scrap detail
- function scrapxong() {
- //$this->verifyserverUrl($_SERVER['REQUEST_URI']);
- $this->pageTitle = 'ScrapFOTO™';
- $this->layout = 'creativedetail';
-
- ############################################ SCRAP XONG DETAILS
- $this->creativeType();
- $this->countFavCart();
- $this->getPublicScrap();
-
- $this->set('photoid',$_REQUEST['sxid']);
-
- //update viewed
- $select = "UPDATE creative_favorites SET viewed=viewed+1 WHERE id='".base64_decode($_REQUEST['sxid'])."' ";
- mysql_query($select);
-
- $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";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $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";
-
- $photo_sql = $select . $from .$where;
- $photo_res = mysql_query($photo_sql);
- $photores_arr = mysql_fetch_array($photo_res);
- $photoUrl = FULL_BASE_URL.$this->webroot."creativezones/scrapxong?sxid=".$_REQUEST['sxid'];//DOMAIN
- $this->set('photoUrl',$photoUrl);
-
- $this->set('photoArr', $photores_arr);
- $this->set('photoTitle', $photores_arr['title']);
- $this->set('photoDesc', $photores_arr['description']);
- $this->set('photoImage', $photores_arr['template_img']);
- $this->set('photoImageId', $photores_arr['id']);
- $this->set('photoUsername', $photores_arr['username']);
- $this->set('photototalRating', $photores_arr['photorat']);
- $this->set('photototalReview', $photores_arr['photoreview']);
- $this->set('photoPrice', number_format($photores_arr['price'],2,'.',','));
-
- $checklover = "Select * from creative_favorite_lovers where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."'" ;
- $checklover_res = mysql_query($checklover);
- $checklover_res_num = mysql_num_rows($checklover_res);
- $this->set('nooflover', $checklover_res_num);
-
- ##### Check for the review already posted or not
- $numberpreview=0;
- if(isset($_SESSION['UserId'])) {
- $checkbackdropreview = "SELECT * FROM creative_favorite_comments where creative_favorite_id='".base64_decode($_REQUEST['sxid'])."' and user_id='".$_SESSION['UserId']."'";
- $checkbackdropreview_res = mysql_query($checkbackdropreview);
- $numberpreview = mysql_num_rows($checkbackdropreview_res);
- }
- $this->set('reviewposted', $numberpreview);
- #####
-
- ################################################### FOR NEXT AND PREVIOUS #######################
-
- $Imgselect="
- SELECT CF.id,title,template_img
- FROM creative_favorites CF,creative_favorites_details CFDTL
- WHERE CF.id=CFDTL.creative_favorite_id AND CF.type='0'
- GROUP BY CF.id ORDER BY CF.id DESC
- " ;
-
-
- $Imgselect_res = mysql_query($Imgselect);
- $Imgarray = array();
-
- while($Imgselect_arr = mysql_fetch_array($Imgselect_res)) {
- //$Imgarray['image'.$Imgselect_arr['id']] = $Imgselect_arr['id'] ;
- $Imgarray[] = $Imgselect_arr['id'] ;
- }
- //pr($Imgarray);
- //echo base64_decode($_REQUEST['pid']) ;
- $searchKey = array_search(base64_decode($_REQUEST['sxid']),$Imgarray) ;
- // Next
- $searchKeyNext = ($searchKey + 1);
- $searchKeyPrev = ($searchKey - 1);
-
- if (array_key_exists($searchKeyNext, $Imgarray)) {
- $this->set('nxtImage',$Imgarray[$searchKeyNext]);
- }
- // Prev
- if (array_key_exists($searchKeyPrev, $Imgarray)) {
- $this->set('prevImage',$Imgarray[$searchKeyPrev]);
- }
-
- ################################################### FOR NEXT AND PREVIOUS #######################
-
- ########
- }
-
- //checking
- function creativetemplate() {
-
- //$this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Create Template';
- $this->layout = 'creativehome';
- $this->creativeType();
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
- //This variable contains the category Id
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['pg']))
- $tmpImg=base64_decode($this->params['url']['pg']);
-
- $themeId=0;
- if(isset($this->params['url']['tmplate']))
- $themeId=base64_decode($this->params['url']['tmplate']);
-
- //this variable is used to show the selected section in the accordian tag
-
- $this->set("cType",$id);
- $this->set("cTemplate",$tmpImg);
- $this->set("themeId",$themeId);
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creativetemplate"); //filename should contain the name of the file that should be selected
- $_SESSION['bradcamp_creative'][20]=$this->params['action']; //we are passing the name of the file to keep track which step is visited
- $this->set("nextpage","creativezone");
-
- //_________________________________________________________________________________________________
-
- $this->countFavCart();
- /*
- // getting out the template name under the type
- if(isset($id)) {
-
- $templateName = array();
- $tempname="
- SELECT CP.*
- FROM creative_type CT,creative_template_pages CP
- WHERE CT.id=CP.creative_type_id AND CT.id='".$id."' AND block='0'
- ORDER BY CP.template_type ASC,CP.title ASC
- ";
- $tempname_res = mysql_query($tempname) or die('Line number '.__LINE__. mysql_error());
- $tempNum = mysql_num_rows($tempname_res);
- if($tempNum > 0) {
- $i=0;
- while($rwTmp = mysql_fetch_assoc($tempname_res)) {
- if($i==0) {
- $defaultTmpId=$rwTmp['id'];
- $this->set("defaultTemplateId",$defaultTmpId);
- }
-
- $i++;
- $templateName[$rwTmp['id']]=array($rwTmp['title'],$rwTmp['template_img'],$rwTmp['price'],$rwTmp['template_type']);
- }
-
- }
-
- }
-
- $this->set('templateImg',$templateName);
-
- //Getting the large thimbnail image
- if(isset($tmpImg) && $tmpImg!=0) {
- $this->templateDetail($tmpImg);
- $this->render("template","ajax");
- }
-
-
- if(isset($this->params['url']['tpage'])) {
- //print "test";
- $tPage=base64_decode($this->params['url']['tpage']);
- $this->templateDetail($tPage);
- //exit;
- $this->render("template","ajax");
- }
- */
- }
- //checking
- function creativetemplatezone() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Creative Zone';
- $this->layout = 'creativehome';
- $this->creativeType();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creativetemplatezone"); //filename should contain the name of the file that should be selected
- $this->set("nextpage","creative_favorite");
-
- //_________________________________________________________________________________________________
-
-
-
- if(isset($this->params['url']['tmp'])) {
- $tmpImg=base64_decode($this->params['url']['tmp']);
- $tmpImg = $this->templateDetail($tmpImg);
-
- if($tmpImg==0) {
- $this->redirect('/creativezones/index');
- }else {
- //emty cart current
- $sql ="SELECT id FROM creative_carts WHERE pay_status='0' ";
- $result = mysql_query($sql) or die(mysql_error());
- if(mysql_num_rows($result)>0) {
- while($row=mysql_fetch_array($result)) {
- $sql ="DELETE FROM creative_cart_details WHERE creative_cart_id='".$row['id']."' ";
- mysql_query($sql) or die(mysql_error());
- }
- }
- //add favorite
- if(!isset($_SESSION['buyTemplate']['tmpId'])) {
- $_SESSION['buyTemplate']['tmpId'] = $tmpImg;
- //add to favorite
- $fav = $this->Creative_favorites->findById($tmpImg);
-
- $fav['Creative_favorites']['id'] = null;
- $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
- $fav['Creative_favorites']['is_temp'] = 1;
- $fav['Creative_favorites']['type'] = 1;
- $fav['Creative_favorites']['is_featured'] = 0;
- $fav['Creative_favorites']['is_republished'] = 0;
-
- $this->Creative_favorites->create();
- $this->Creative_favorites->save($fav);
-
- $idNew = $this->Creative_favorites->id;
- $_SESSION['buyTemplate']['idNew'] = $idNew;
- }
- }
- }
-
- $this->countFavCart();
-
- //case create form header
- if(isset($_POST['widthScrap'])) {
- $this->set('widthScrap',$_POST['widthScrap']);
- $this->set('heightScrap',$_POST['heightScrap']);
- $this->set('titleScrap',$_POST['titleScrap']);
- }
-
- }
- //checking
- function creative_favorite() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - My Favorite';
- $this->layout = 'creativehome';
- $this->creativeType();
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
-
- $tmpImg=0;
- if(isset($this->params['url']['tmp'])) {
- $tmpImg=base64_decode($this->params['url']['tmp']);
- $tmpImg = $this->templateDetail($tmpImg);
- }else if(isset($_SESSION['buyTemplate']['tmpId'])) {
- $tmpImg = $_SESSION['buyTemplate']['tmpId'];
- $tmpImg = $this->templateDetail($tmpImg);
- }
-
-
- if(isset($_POST['ssn_id'])) {
- $ssn_id = $_POST['ssn_id'];
- $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
-
- if(!$fav) {//create
- $this->Creative_favorites->create();
- }
- else {//update
- $this->Creative_favorites->id = $fav['Creative_favorites']['id'];
- }
- $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
- $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
- $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
- $fav['Creative_favorites']['description'] = $_POST['description'];
- $fav['Creative_favorites']['price'] = $_POST['price'];
- $fav['Creative_favorites']['width'] = $_POST['width'];
- $fav['Creative_favorites']['height'] = $_POST['height'];
- $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
- $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
- $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
- $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
- $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
- $fav['Creative_favorites']['is_temp'] = 0;
-
- $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
- $fav['Creative_favorites']['type'] = $_POST['type'];
- $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
-
- $fav['Creative_favorites']['is_temp'] = $fav['Creative_favorites']['is_featured'];
-
- if($fav['Creative_favorites']['type']==0) {//public
- $featuredAmount=$this->getConfigAmount('creative artist price');
- $fav['Creative_favorites']['price'] = $featuredAmount['config_value'];
- }
-
- $resultSave = $this->Creative_favorites->save($fav);//return 1/null
-
-
- //insert tag
- if($resultSave && $_POST['tag']!='') {
- $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
- $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
- $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
- $this->Creative_favorite_tags->create();
- $this->Creative_favorite_tags->save($tag);
- }
-
- if($fav['Creative_favorites']['type']==0) {
- if($resultSave && $fav['Creative_favorites']['is_featured']==1) {
- $this->redirect("creativezones/creative_featured?lid=".base64_encode($this->Creative_favorites->id));
- exit();
- }else {
- $this->redirect("creativezones/featuredsuccess?lid=".base64_encode($this->Creative_favorites->id));
- }
- }
-
- }
-
- if(isset($_POST['actionCall']) && $_POST['actionCall']=='exit') {
- $this->redirect('/creativezones/index');
- }
-
- if($tmpImg==0) {
- unset($_SESSION['buyTemplate']);
- $favs = null;
- $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());
- if(mysql_num_rows($result)>0) {
- $favs = $result;
- }
- $this->set("favs",$favs);
- }else if(isset($_SESSION['buyTemplate']['idNew'])) {
- $favs = null;
- $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());
- if(mysql_num_rows($result)>0) {
- $favs = $result;
- }
- $this->set("favs",$favs);
- }
-
- $this->countFavCart();
-
- //Initializing all the bradcamp back again so that it all starts all over again
- $this->set("filename","creative_favorite");
- $this->set("nextpage","mycart");
-
- //_________________________________________________________________________________________________
-
- $this->set("recenttype","creative_favorite");
- $this->getCartDetails();
- }
- //ok
- function creative_favorite_ajax() {
- if(isset($_POST['ssn_id'])) {
- $ssn_id = $_POST['ssn_id'];
- $fav = $this->Creative_favorites->findBySsn_id(base64_decode($_POST['ssn_id']));
-
- if(!$fav) {
- $fav['Creative_favorites']['ssn_id'] = base64_decode($_POST['ssn_id']);
- $fav['Creative_favorites']['user_id'] = $_SESSION['UserId'];
- $fav['Creative_favorites']['title'] = base64_decode($_POST['title']);
- $fav['Creative_favorites']['description'] = $_POST['description'];
- $fav['Creative_favorites']['price'] = $_POST['price'];
- $fav['Creative_favorites']['width'] = $_POST['width'];
- $fav['Creative_favorites']['height'] = $_POST['height'];
- $fav['Creative_favorites']['fileThumb'] = base64_decode($_POST['fileThumb']);
- $fav['Creative_favorites']['fileThumb2'] = base64_decode($_POST['fileThumb2']);
- $fav['Creative_favorites']['fileThumb3'] = base64_decode($_POST['fileThumb3']);
- $fav['Creative_favorites']['fileData'] = base64_decode($_POST['fileData']);
- $fav['Creative_favorites']['fileZip'] = base64_decode($_POST['fileZip']);
- $fav['Creative_favorites']['is_temp'] = 0;
-
- $fav['Creative_favorites']['creative_type_id'] = $_POST['creative_type_id'];
- $fav['Creative_favorites']['type'] = $_POST['type'];
- $fav['Creative_favorites']['is_featured'] = $_POST['is_featured'];
-
- $this->Creative_favorites->create();
- $resultSave = $this->Creative_favorites->save($fav);//return 1/null
-
-
- //insert tag
- if($resultSave && $_POST['tag']!='') {
- $tag['Creative_favorite_tags']['creative_favorite_id'] = $this->Creative_favorites->id;
- $tag['Creative_favorite_tags']['user_id'] = $_SESSION['UserId'];
- $tag['Creative_favorite_tags']['tagname'] = $_POST['tag'];
- $this->Creative_favorite_tags->create();
- $this->Creative_favorite_tags->save($tag);
- }
- }
- }
-
- $this->countFavCart();
- $this->render("creative_favorite_ajax","ajax");
-
- }
-
- function creativeType() {
- $q1=mysql_query("SELECT * FROM creative_type WHERE is_delete='0' ORDER BY sequence ASC");
- $i=0;
- while($rwCr=mysql_fetch_array($q1)) {
- if($i==0)
- $defaultCat[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
- $i++;
-
- $creativeType[$rwCr['id']]=array($rwCr['creative_name'],$rwCr['creative_description'],$rwCr['creative_image']);
- }
-
- $this->set("defaultType",$defaultCat);
- $this->set("creativeType",$creativeType);
-
- $type = 0;
- foreach($defaultCat as $key=>$value) {
- $type = $key;
- break;
- }
-
- if(isset($this->params['url']['cat'])) {
- $scrapType=base64_decode($this->params['url']['cat']);
- $detail = $this->getCreativeType($scrapType);
- if($detail) {
- $type = $detail['id'];
- }
- }
-
- $this->set('defaultCate',$type);
- }
- //checking
-
- function templateDetail($tmpImg) {
- $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());
- if(mysql_num_rows($q1)>0) {
- $rwTmpImg=mysql_fetch_assoc($q1);
- $this->set("tmpid",base64_encode($rwTmpImg['ssn_id']));
- $this->set("tmp",base64_encode($tmpImg));
- return $tmpImg;
- }
- return 0;
- }
- //ok
- function getPublicScrap() {
-
- $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";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $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'";
- $others=" group by X.id ";
- $others .=" order by photorat desc ";
-
- $queryCreative = $select . $from . $where .$others ;
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
-
-
-
-
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
- $this->set("publicScrap",$queryCreativeFavorites);
- $this->set("publicScrapSql",$queryCreative);
-
- }
- //ok
- function getRankScrap() {
- /*$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";
-
- $from=" FROM creative_favorites X
- LEFT JOIN creative_type XCreativetype ON X.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $where=" WHERE X.is_blocked='0' AND X.is_temp='0' AND X.type='0' AND X.is_approved='1' ";
- $others=" group by X.id ";
- $others .=" order by photorat desc LIMIT 21";
-
- $queryCreative = $select . $from . $where .$others ;
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
- $this->set("publicRank",$queryCreativeFavorites);
- $this->set("publicRankSql",$queryCreative);
- */
- }
- //ok
- function getFeaturedScrap() {
- /*$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";
-
- $from=" FROM creative_favorites X
-
- LEFT JOIN creative_favorites_details XCreativetypeDetail ON X.id = XCreativetypeDetail.creative_favorite_id
- LEFT JOIN creative_template_pages Xalbum ON X.creative_template_page_id = Xalbum.id
- LEFT JOIN creative_type XCreativetype ON Xalbum.creative_type_id = XCreativetype.id
-
- LEFT JOIN creative_favorite_comments Xcomment ON X.id = Xcomment.creative_favorite_id
- LEFT JOIN users Xuser ON X.user_id = Xuser.id
- LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
- LEFT JOIN creative_favorite_voting Xrating ON X.id = Xrating.creative_favorite_id";
-
- $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' ";
- $others=" group by X.id ";
- $others .=" order by photorat desc LIMIT 21";
-
- $queryCreative = $select . $from . $where .$others ;
-
- $queryCreativeFavorites=mysql_query($queryCreative) or die("Error on line :".__LINE__.mysql_error());
-
- $this->set("publicFeatured",$queryCreativeFavorites);
- $this->set("publicFeaturedSql",$queryCreative);
- */
- }
- //ok
- function viewalltag() {
- $this->pageTitle = 'ScrapFOTO™ - View Tag';
- $this->layout = 'creativedetail';
- $this->creativeType();
- $this->getPublicScrap();
-
- }
- //ok
- function searchtag($alphasearch=null) {
-
- if($alphasearch)
- $searchtxt = "'".strtolower($alphasearch)."%'" ;
- else {
- if(isset($_REQUEST['txttagsearch']) && $_REQUEST['txttagsearch']!='')
- $searchtxt = "'%". strip_html_tags($_REQUEST['txttagsearch'])."%'";
- else
- $searchtxt='a%';
- }
-
- $tagarray = array();
- $tagsearchsql = "SELECT DISTINCT(tagname) FROM creative_favorite_tags where tagname!='' and tagname like ". $searchtxt ."";
- $tagsearchsql_res = mysql_query($tagsearchsql);
- while($tagsearchsql_arr = mysql_fetch_array($tagsearchsql_res)) {
- $tagarray[] = $tagsearchsql_arr['tagname'];
- }
- $this->set('tagsql',$tagsearchsql);
- $this->set('tagarray',$tagarray);
- $this->set('Numtagarray',mysql_num_rows($tagsearchsql_res));
- $this->set('searchtxt',$alphasearch);
- $this->render('searchtaglist', 'ajax');
-
- }
- //ok
- function scrapaddtocart($scrapxongid=null) {
-
- $queryCreativeFavorites=mysql_query("
- SELECT CF.title,CTP.price
- FROM creative_favorites CF,creative_template_pages CTP
- WHERE CF.id='".base64_decode($scrapxongid)."' AND CF.creative_template_page_id=CTP.id AND CF.type='0'");
- $fetchCreativeFavorites=mysql_fetch_assoc($queryCreativeFavorites);
- $productName=$fetchCreativeFavorites['title'];
- $price=$fetchCreativeFavorites['price'];
-
- if(isset($_SESSION['UserId'])) {
- $creativecartsql = "SELECT * from creative_carts WHERE user_id='".$_SESSION['UserId']."' and product_name='".$productName."' and ssn_id='".session_id()."' and pay_status='0'";
- $creativecartsql_res = mysql_query($creativecartsql);
- if(mysql_num_rows($creativecartsql_res)==0) {
- mysql_query("INSERT INTO
- creative_carts(user_id,product_name,price,qty,transaction_creative_id,pay_status,ssn_id)
- VALUES('".$_SESSION['UserId']."','".$productName."','".$price."','1','0','0','".session_id()."')") or die("Error on line : ".__LINE__.mysql_error());
-
- $lastId=mysql_insert_id();
-
- $queryCreativeFavoritesDetails=mysql_query("SELECT template_img FROM creative_favorites_details WHERE creative_favorite_id='".base64_decode($scrapxongid)."'");
- while($fetchCreativeFavoritesDetails=mysql_fetch_assoc($queryCreativeFavoritesDetails)) {
- mysql_query("INSERT INTO creative_cart_details(creative_cart_id,imagename) VALUES('".$lastId."','".$fetchCreativeFavoritesDetails['template_img']."')");
- }
- }
- }
-
-
- $this->countFavCart();
- $this->set('photoImageId',$scrapxongid);
- $this->render('cartitem', 'ajax');
- }
-
- function creative_login() {
- $uName=base64_decode($this->params['url']['u']);
- $password=$this->params['url']['p'];
-
- $id=0;
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['tmp']))
- $tmpImg=base64_decode($this->params['url']['tmp']);
-
-
- //This is the last iserted id in the favorite table
- $lastId=0;
- if(isset($this->params['url']['lid']))
- $lastId=base64_decode($this->params['url']['lid']);
-
- $someone=$this->userLogin($uName,$password);
- if(!empty($someone))
- $this->redirect("creativezones/creative_favorite?ct=".base64_encode($id)."&tmp=".base64_encode($tmpImg)."&lid=".base64_encode($lastId));
-
- }
-
- function featuredpayment() {
- /*
- $this->checkSession();
- $this->layout = 'previewpaymemnt';
- $this->render("paymentback");
-
- //This ct variable comes from INDEX page and CREATIVETEMPLATE page
- $id=0;
- if(isset($this->params['url']['ct']))
- $id=base64_decode($this->params['url']['ct']);
-
- //This ct variable comes from CREATIVETEMPLATE page
- $tmpImg=0;
- if(isset($this->params['url']['tmp']))
- $tmpImg=base64_decode($this->params['url']['tmp']);
-
- //This is the last iserted id in the favorite table
- //If lid means user comes to this page after saving the scrapbook
- //We are checking whether the user features the scrapblog or not if yes then ask for the payment
- $lastId=0;
- if(isset($this->params['url']['lid']))
- $lastId=base64_decode($this->params['url']['lid']);
-
-
- $this->set("cType",$id);
- $this->set("cTemplate",$tmpImg);
- $this->set("lastId",$lastId);
-
- if(!empty($this->data)) {
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $featuredAmount=$this->getConfigAmount('creative featured');
-
- $amountCharge=$this->data['creative']['amount'];
- if(isset($this->data['Event']['radiobutton'])) {
- if($this->data['Event']['radiobutton']=="paypal") {
- $this->itemName="ScrapFOTO™ fetaured";
- $this->amountPay=$amountCharge;
- $this->returnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
- $this->notifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
- $this->merchantEmail=$fetchAdminPaymentSetup['paypal_email'];
- $this->custom=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId;
- $this->paypal();
- }
-
- if($this->data['Event']['radiobutton']=="google") {
- $adminPayment=$fetchAdminPaymentSetup['gcheckout_email'];
- $adminPaymentDetails=explode("break",$adminPayment);
- $this->Gcheckout->gMerchantId=$adminPaymentDetails['0'];
- $this->Gcheckout->gMerchantKey=$adminPaymentDetails['1'];
- $this->Gcheckout->gItemName="ScrapFOTO™ Featured";
- $this->Gcheckout->gItemDesc="ScrapFOTO™ Featured";
- $this->Gcheckout->gQuantity=1;
- $this->Gcheckout->gPrice=$amountCharge;
- $this->Gcheckout->gReturnUrl=FULL_BASE_URL.$this->webroot."creativezones/creative_favorite";
- $this->Gcheckout->gNotifyUrl=FULL_BASE_URL.$this->webroot."creativezones/featuredsuccess";
- $this->Gcheckout->customData=$_SESSION['UserId']."^".$id."^".$tmpImg."^".$lastId."^".$amountCharge;
- $this->Gcheckout->google();
-
- }
- }
-
- }*/
-
- }
-
- function creative_featured() {
- $this->checkSession();
- $this->pageTitle = 'ScrapFOTO™ - Featured ScrapFOTO™';
- $this->layout = 'creativehome';
- $this->creativeType();
- $this->getPublicScrap();
- $cartCount=$this->countFavCart();
-
- $tmpImg =0;
- $id =0;
-
- $lastId=0;
- if(isset($this->params['url']['lid']))
- $lastId=base64_decode($this->params['url']['lid']);
-
- $this->set("lastId",$lastId);
-
- $this->set("filename","creative_cart");
- $this->set("recenttype","creative_favorite");
-
- $featuredAmount=$this->getConfigAmount('creative featured');
- $this->set("featuredAmount",$featuredAmount);
-
- //getCartDetails;
- $sql = "SELECT *,CF.fileThumb2 as imagename FROM creative_favorites as CF WHERE CF.id='".$lastId."' LIMIT 1";
- $queryCreativeCarts=mysql_query($sql);
- $this->set("queryCreativeCarts",$queryCreativeCarts);
-
- $this->getUserDetails();
-
-
-
- $fetchAdminPaymentSetup=$this->getPaymentMethods(1); // that means payment will go to the admin paymenbt id
- $this->set("paymentMethods",$fetchAdminPaymentSetup);
- }
- //checking
- function featured_payment_notify() {
- /*
- $this->Paypal->paypal_class();
- $this->Paypal->paypal_url = $this->paypalUrl; // testing paypal url
-
- //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
- $paypal=0;
- if ($this->Paypal->validate_ipn()) {
- $paypal=1;
- if(isset($this->Paypal->ipn_data['payment_gross']) && ($this->Paypal->ipn_data['payment_gross'])!="") {
- $totalPay=$this->Paypal->ipn_data['payment_gross'];
- $custom=explode("^",$this->Paypal->ipn_data['custom']);
- $userId=$custom['0'];
- $lastId=$custom['1'];
- $invoice=$_POST['invoice'];
- $ticket=$custom['3'];
-
- }
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
- $userId=$ipnData['0'];
- $lastId=$ipnData['1'];
- $invoice=$ipnData['2'];
- $ticket=$ipnData['3'];
- $totalPay=$ipnData['4'];
- }
-
- }
- */
- }
- //checking
- function featuredsuccess() {
-
- $is_featured = 1;
- $productId=0;
- if(isset($this->params['url']['lid']))
- $productId=base64_decode($this->params['url']['lid']);
-
- if($productId==0) {
- //_______________________________________________IPN data received from PAYPAL and GOOGLE payment methods
- $paypal=0;
- if (isset($_POST['payment_gross']) && ($_POST['payment_gross'])!="") {
- $paypal=1;
-
- $totalPay=$_POST['payment_gross'];
- $custom=explode("^",$_POST['custom']);
-
- $userId=$custom['0'];
- $sellerId=$custom['1'];
- $isAdmin=$custom['2'];
- $rdPage=$custom['3'];
- $invoice=$custom['4'];
- $transactionId=$custom['5'];
- $ticket=$custom['6'];
- $productId=$custom['7'];
- }
-
- //This section is used to catch from GOOGLE IPN data
- if(!$paypal) {
- //this section is used to update from google IPN data
- $xml_response = isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:file_get_contents("php://input");
- if($xml_response) {
- $gCustom=$this->parseXmlArray($xml_response);
- $cData=$gCustom['http://checkout.google.com/schema/2']['SHOPPING-CART']['ITEMS']['ITEM']['MERCHANT-PRIVATE-ITEM-DATA'];
- $ipnData=explode("^",$cData);
-
- $userId=$ipnData['0'];
- $sellerId=$ipnData['1'];
- $isAdmin=$ipnData['2'];
- $rdPage=$ipnData['3'];
- $invoice=$ipnData['4'];
- $transactionId=$ipnData['5'];
- $totalPay=$ipnData['6'];
- $ticket=$ipnData['7'];
- $productId=$ipnData['8'];
- }
- }
- }else {
- $userId = $_SESSION['UserId'];
- $totalPay = 0;
- $ticket = $this->createTransactionNumber('SPTT');
- $is_featured = 0;
- }
-
- //________________________________________________XOIMAGE DATABASE UPDATION SECTION
-
- //update featured_time
- $featured_time = NULL;
- if($is_featured==1){
- $result = $this->getConfigAmount('creative featured days');
- $featureddays = $result['config_value'];
- $featured_time = date('Y-m-d G:i:s', strtotime("+".$featureddays." day"));
- }
-
- $queryCreativeFavorites=mysql_query("
- UPDATE creative_favorites
- SET is_featured='$is_featured',is_temp='0', featured_time='".$featured_time."'
- WHERE user_id='".$userId."' AND id='".$productId."'") or die("Error on line : ".__LINE__.mysql_error());
-
-
- if(isset($transactionId)) {
- //UPDATE date on TRANSACTION_CREATIVE TABLE
- $queryUpdateTransactionCreative="
- UPDATE transaction_creatives
- SET pay_status='1',invoice='".$invoice."'
- WHERE id='".$transactionId."' AND user_id='".$userId."'";
- mysql_query($queryUpdateTransactionCreative) or die("Error on line : ".__LINE__.mysql_error());
-
- //UPDATE data to the CREATIVE_CARTS TABLE after successful transaction
- $queryUpdateCreativeCart="
- UPDATE creative_carts
- SET pay_status='1', total_price='".$totalPay."'
- …
Large files files are truncated, but you can click here to view the full file