PageRenderTime 63ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/admin/app/controllers/stoxfoto_controller.php

https://bitbucket.org/fxrialab/tickets
PHP | 1304 lines | 1129 code | 136 blank | 39 comment | 90 complexity | 38aa3320bf5619e22b5e7cfe59bf2a3f MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT

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

  1. <?php
  2. class StoxfotoController extends AppController
  3. {
  4. var $name='Stoxfotos';
  5. var $helpers = array('Html','Javascript','Ajax','Pagination','error');
  6. var $components = array('Pagination','Sendmail','Download','Image');
  7. function managestoxitem()
  8. {
  9. $this->checkSession();
  10. $this->pageTitle = 'Manage Stoxfoto';
  11. $this->layout = 'default_user';
  12. ################################################ SUBMISSION ######################
  13. $photoQuery = "SELECT * from stoxfotos WHERE media_type='Photos' and is_approved='0' and is_temp='0' ";
  14. $photoQuery_res = mysql_query($photoQuery);
  15. $this->set('Numofphoto',mysql_num_rows($photoQuery_res));
  16. $photoQuery = "SELECT * from stoxfotos WHERE media_type='PhotoElement' and is_approved='0' and is_temp='0' ";
  17. $photoQuery_res = mysql_query($photoQuery);
  18. $this->set('NumofphotoElement',mysql_num_rows($photoQuery_res));
  19. $photoQuery = "SELECT * from stoxfotos WHERE media_type='Illustration' and is_approved='0' and is_temp='0' ";
  20. $photoQuery_res = mysql_query($photoQuery);
  21. $this->set('Numofillustration',mysql_num_rows($photoQuery_res));
  22. $photoQuery = "SELECT * from stoxfotos WHERE media_type='Flash' and is_approved='0' and is_temp='0' ";
  23. $photoQuery_res = mysql_query($photoQuery);
  24. $this->set('Numofflash',mysql_num_rows($photoQuery_res));
  25. $photoQuery = "SELECT * from stoxfotos WHERE media_type='Movie' and is_approved='0' and is_temp='0' ";
  26. $photoQuery_res = mysql_query($photoQuery);
  27. $this->set('Numofmovie',mysql_num_rows($photoQuery_res));
  28. $photoQuery = "SELECT * from stoxfotos WHERE media_type='Web' and is_approved='0' and is_temp='0' ";
  29. $photoQuery_res = mysql_query($photoQuery);
  30. $this->set('Numofweb',mysql_num_rows($photoQuery_res));
  31. ################################################ SUBMISSION ######################
  32. }
  33. function managestoxsubmission($viewType=null)
  34. {
  35. $this->checkSession();
  36. $this->pageTitle = 'Manage Stoxfoto '.ucfirst($viewType);
  37. $this->layout = 'default_user';
  38. $this->set('pageView',$viewType);
  39. if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
  40. $viewSearchType=$_REQUEST['hfsearch'];
  41. $select = "SELECT stoxfotos.id,stoxfotos.title ,users.username , stoxfoto_categories.category_name,stoxfotos.stoxfoto_category_id ,stoxfotos.media_type ,stoxfotos.is_featured,stoxfotos.numofview,stoxfotos.posted_date,stoxfotos.is_adultcontent ,stoxfotos.stoxfoto_code ,stoxfotos.is_blocked ,stoxfotos.is_republished,stoxfotos.exclusive,
  42. IF(stoxfotos.media_type='Photos',stoxfoto_photo.photo_name ,IF(stoxfotos.media_type='PhotoElement',stoxfoto_photoelement.photo_name,IF(stoxfotos.media_type='Illustration',stoxfoto_illustration.sale_imagefile,IF(stoxfotos.media_type='Flash',stoxfoto_flash.sale_imagefile,IF(stoxfotos.media_type='Movie',stoxfoto_movie.sale_imagefile,IF(stoxfotos.media_type='Web',stoxfoto_web.sale_imagefile,'nostoximage.jpg')))))) as photoname ,
  43. stoxfotos_tickets.msg_to_user ,stoxfotos_tickets.ticket_number,stoxfotos_tickets.status ";
  44. $from="from stoxfotos
  45. LEFT JOIN stoxfoto_categories ON (stoxfotos.stoxfoto_category_id=stoxfoto_categories.id)
  46. LEFT JOIN users ON (stoxfotos.user_id=users.id)
  47. LEFT JOIN stoxfoto_photo ON(stoxfotos.media_type='Photos' and stoxfoto_photo.stoxfoto_id =stoxfotos.id )
  48. LEFT JOIN stoxfoto_photoelement ON(stoxfotos.media_type='PhotoElement' and stoxfoto_photoelement.stoxfoto_id =stoxfotos.id )
  49. LEFT JOIN stoxfoto_illustration ON(stoxfotos.media_type='Illustration' and stoxfoto_illustration.stoxfoto_id =stoxfotos.id )
  50. LEFT JOIN stoxfoto_flash ON(stoxfotos.media_type='Flash' and stoxfoto_flash.stoxfoto_id =stoxfotos.id )
  51. LEFT JOIN stoxfoto_movie ON(stoxfotos.media_type='Movie' and stoxfoto_movie.stoxfoto_id =stoxfotos.id )
  52. LEFT JOIN stoxfoto_web ON(stoxfotos.media_type='Web' and stoxfoto_web.stoxfoto_id =stoxfotos.id )
  53. LEFT JOIN stoxfotos_tickets ON stoxfotos.id=stoxfotos_tickets.stoxfoto_id
  54. ";
  55. $where="WHERE 1 AND stoxfotos.is_temp='0' AND stoxfotos.is_approved='0' ";
  56. $searchpass='';
  57. if(isset($viewSearchType) && $viewSearchType=='title' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='')
  58. {
  59. $where.=" AND stoxfotos.title like '%".$_REQUEST['txtsrch']."%' ";
  60. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  61. }
  62. if(isset($viewSearchType) && $viewSearchType=='exclusive')
  63. {
  64. $where.=" AND stoxfotos.exclusive='Yes'";
  65. //$searchexclusive = 'Yes';
  66. $searchpass = "&exclusive=yes" ;
  67. }
  68. if(isset($viewSearchType) && $viewSearchType=='daterange')
  69. {
  70. if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY')
  71. {
  72. $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
  73. $urlfromdate = $_REQUEST['inpdatefrom'];
  74. }
  75. else
  76. {
  77. $eventFromDate=date("Y-m-d");
  78. $urlfromdate = $_REQUEST['inpdatefrom'];
  79. }
  80. if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY')
  81. {
  82. $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
  83. $urltodate = $_REQUEST['inpdateto'];
  84. }
  85. else
  86. {
  87. $eventToDate=date("Y-m-d");
  88. $urltodate = $_REQUEST['inpdateto'];
  89. }
  90. $where.=" AND stoxfotos.posted_date between '".$eventFromDate."' and '".$eventToDate."' ";
  91. $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
  92. }
  93. $this->set('searchpass',$where);
  94. $others=" ";
  95. if($viewType || (isset($_REQUEST['listview']) && $_REQUEST['listview']!='') )
  96. {
  97. if($viewType)
  98. $listView = $viewType ;
  99. if(isset($_REQUEST['listview']) && $_REQUEST['listview']!='')
  100. $listView = $_REQUEST['listview'] ;
  101. }
  102. $where.=" and stoxfotos.media_type='".$listView."' ";
  103. $others.=" order by stoxfotos.id desc ";
  104. if(isset($viewSearchType) && $viewSearchType!='')
  105. {
  106. $PassParameter="listview=".$listView."&hfsearch=".$viewSearchType.$searchpass;
  107. }
  108. else
  109. $PassParameter="listview=".$listView;
  110. $CountField="stoxfotos.id";
  111. $this->set("controller","stoxfoto");
  112. $this->set("action","managestoxsubmission");
  113. //echo $select.$from.$where.$others ;
  114. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  115. if(isset($this->params['url']['Page']) || isset($viewSearchType))
  116. {
  117. $this->render("managestoxsubmission2","ajax");
  118. }
  119. }
  120. function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter)
  121. {
  122. if(isset($arg['Page']))
  123. $pageFlag=$arg['Page'];
  124. $this->set("PassParameter",$PassParameter);
  125. $SetUserNumberOfVpsPerPage=50; /* Defined in config->paths.php*/
  126. $this->set("BackgroundClass",'pagination');
  127. $this->set("SelectedPage",'pagination_over');
  128. $this->set("Linkpage",'pagination_over');
  129. $this->set("FirstImage",'fdd.gif');
  130. $this->set("PreviousImage",'previous.gif');
  131. $this->set("NextImage",'next.gif');
  132. $this->set("LastImage",'rewd.gif');
  133. $UserNumberOfVpsPerPage=50; /* Defined in config->paths.php*/
  134. if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
  135. $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
  136. if(!isset($arg['Page'])) $arg['Page']=1;
  137. if(!isset($arg['Offset'])) $arg['Offset']=0;
  138. //echo "$select $from $where $others" ;
  139. $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
  140. //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
  141. //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
  142. $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
  143. $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
  144. $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
  145. if($arg['Offset']==$NoOfVps)
  146. {
  147. if(isset($Offset))
  148. {
  149. $Offset=$Offset-$NumberOfVpsPerPage;
  150. $Page--;
  151. if($Offset<0)
  152. {
  153. $Offset=0;$Page=1;
  154. }
  155. }else{
  156. $Offset=0;$Page=1;
  157. }
  158. }
  159. $this->set("Page",$arg['Page']);
  160. $this->set("Offset",$arg['Offset']);
  161. $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
  162. $this->set("NoOfPages",$NoOfPages);
  163. $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
  164. //print "$select $from $where $others";
  165. $this->set("qryOthr","$select $from $where)");
  166. $this->set("tesrqryOthr","$where $others)");
  167. //echo "$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage" ;
  168. $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
  169. $this->set("query",$SelectRecord);
  170. }
  171. function approvestoxitem($stocxid=null)
  172. {
  173. $this->layout="loginblank";
  174. $stoxInfo = $this->stoxitemInfo($stocxid);
  175. $this->set('mediatype',$stoxInfo['media_type']);
  176. $this->set('Stoxinfo',$stoxInfo);
  177. if($stoxInfo['media_type']=='Photos')
  178. {
  179. ###### PHOTO INFORMATION
  180. $selectImageinfo = "SELECT photo_name,orginal_photo_name from stoxfoto_photo where stoxfoto_id='".$stoxInfo['id']."' ";
  181. $selectImageinfo_query = mysql_query($selectImageinfo);
  182. if(mysql_num_rows($selectImageinfo_query)>0)
  183. {
  184. $selectImageinfo_arr = mysql_fetch_array($selectImageinfo_query);
  185. $this->set('stoxItemImage','../../app/webroot/stoxfoto_media/photo/medium/'.$selectImageinfo_arr['photo_name']);
  186. $this->set('OrgstoxItemImage',$selectImageinfo_arr['photo_name']);
  187. }
  188. $stoxinfosql = "
  189. SELECT stoxfoto_photo_pricing.* ,stoxfoto_photosize.printable_size ,if(stoxfoto_photosize.caption='Original size','Special Usage License',stoxfoto_photosize.caption)as caption,
  190. if(stoxfoto_photosize.width_size>0,CONCAT_WS(' X ',stoxfoto_photosize.width_size,stoxfoto_photosize.height_size),'Original size') as Photpixelsize
  191. from stoxfoto_photo_pricing
  192. LEFT JOIN stoxfoto_photosize ON (stoxfoto_photo_pricing.stoxfoto_photosize_id=stoxfoto_photosize.id)
  193. where stoxfoto_photo_pricing.stoxfoto_id='".$stocxid."' order by stoxfoto_photosize.id";
  194. $noofdownload_res = mysql_query($stoxinfosql);
  195. $tempUploadingarray=array();
  196. while($noofdownload_arr = mysql_fetch_array($noofdownload_res))
  197. {
  198. $tempUploadingarray[] = array('id'=>$noofdownload_arr['id'],'is_donate'=>$noofdownload_arr['donate'],'caption'=>$noofdownload_arr['caption'],'printsize'=>$noofdownload_arr['printable_size'],'pixels'=>$noofdownload_arr['Photpixelsize'],'pixelprice'=>$noofdownload_arr['price']);
  199. }
  200. $this->set('Uploadpricearray',$tempUploadingarray);
  201. $this->set('fileformat','JPEG');
  202. ###### PHOTO INFORMATION
  203. $this->set('pricelistElement','show_stoxprice_photos');
  204. ###### Freee sample file ###########
  205. $sampleimgFile = "SELECT * from stoxfoto_photo_pricing where stoxfoto_id='".$stocxid."' and donate='Yes'";
  206. $sampleimgFile_res = mysql_query($sampleimgFile);
  207. if(mysql_num_rows($sampleimgFile_res)>0)
  208. $SampleFile = 'photo/'.$stocxid;
  209. else
  210. $SampleFile = '';
  211. #################################
  212. }
  213. if($stoxInfo['media_type']=='PhotoElement')
  214. {
  215. ###### PHOTO INFORMATION
  216. $selectImageinfo = "SELECT photo_name,orginal_photo_name from stoxfoto_photoelement where stoxfoto_id='".$stoxInfo['id']."' ";
  217. $selectImageinfo_query = mysql_query($selectImageinfo);
  218. if(mysql_num_rows($selectImageinfo_query)>0)
  219. {
  220. $selectImageinfo_arr = mysql_fetch_array($selectImageinfo_query);
  221. $this->set('stoxItemImage','../../app/webroot/stoxfoto_media/element/medium/'.$selectImageinfo_arr['photo_name']);
  222. $this->set('OrgstoxItemImage',$selectImageinfo_arr['photo_name']);
  223. }
  224. $stoxinfosql = "
  225. SELECT stoxfoto_photo_pricing.* ,stoxfoto_photosize.printable_size ,if(stoxfoto_photosize.caption='Original size','Special Usage License',stoxfoto_photosize.caption)as caption,
  226. if(stoxfoto_photosize.width_size>0,CONCAT_WS(' X ',stoxfoto_photosize.width_size,stoxfoto_photosize.height_size),'Original size') as Photpixelsize
  227. from stoxfoto_photo_pricing
  228. LEFT JOIN stoxfoto_photosize ON (stoxfoto_photo_pricing.stoxfoto_photosize_id=stoxfoto_photosize.id)
  229. where stoxfoto_photo_pricing.stoxfoto_id='".$stocxid."' order by stoxfoto_photosize.id";
  230. $noofdownload_res = mysql_query($stoxinfosql);
  231. $tempUploadingarray=array();
  232. while($noofdownload_arr = mysql_fetch_array($noofdownload_res))
  233. {
  234. $tempUploadingarray[] = array('id'=>$noofdownload_arr['id'],'is_donate'=>$noofdownload_arr['donate'],'caption'=>$noofdownload_arr['caption'],'printsize'=>$noofdownload_arr['printable_size'],'pixels'=>$noofdownload_arr['Photpixelsize'],'pixelprice'=>$noofdownload_arr['price']);
  235. }
  236. $this->set('Uploadpricearray',$tempUploadingarray);
  237. $this->set('fileformat','PNG');
  238. $this->set('pricelistElement','show_stoxprice_photos');
  239. ###### PHOTO INFORMATION
  240. ###### Freee sample file ###########
  241. $sampleimgFile = "SELECT * from stoxfoto_photo_pricing where stoxfoto_id='".$stocxid."' and donate='Yes'";
  242. $sampleimgFile_res = mysql_query($sampleimgFile);
  243. if(mysql_num_rows($sampleimgFile_res)>0)
  244. $SampleFile = 'element/'.$stocxid;
  245. else
  246. $SampleFile = '';
  247. #################################
  248. }
  249. if($stoxInfo['media_type']=='Illustration')
  250. {
  251. ###### PHOTO INFORMATION
  252. $selectImageinfo = "SELECT sale_epsfile,donate_epsfile,sale_imagefile,sale_orginal_imagefile,donate_epsfile from stoxfoto_illustration where stoxfoto_id='".$stoxInfo['id']."' ";
  253. $selectImageinfo_query = mysql_query($selectImageinfo);
  254. if(mysql_num_rows($selectImageinfo_query)>0)
  255. {
  256. $selectImageinfo_arr = mysql_fetch_array($selectImageinfo_query);
  257. $this->set('stoxItemImage','../../app/webroot/stoxfoto_media/illustration/preview/medium/'.$selectImageinfo_arr['sale_imagefile']);
  258. $this->set('OrgstoxItemImage',$selectImageinfo_arr['sale_imagefile']);
  259. $this->set('OrgstoxFile',$selectImageinfo_arr['sale_epsfile']);
  260. $this->set('OrgstoxDownloadFile',$selectImageinfo_arr['donate_epsfile']);
  261. ###### Freee sample file ###########
  262. if($selectImageinfo_arr['donate_epsfile']!='')
  263. $SampleFile = 'illustration/'.$stocxid;
  264. else
  265. $SampleFile = '';
  266. #################################
  267. }
  268. $stoxinfosql = "SELECT stoxfoto_illustration_pricing.* From stoxfoto_illustration_pricing
  269. where stoxfoto_illustration_pricing.stoxfoto_id='".$stocxid."' order by stoxfoto_illustration_pricing.id";
  270. $noofdownload_res = mysql_query($stoxinfosql);
  271. $tempUploadingarray=array();
  272. while($noofdownload_arr = mysql_fetch_array($noofdownload_res))
  273. {
  274. $tempUploadingarray[] = array('id'=>$noofdownload_arr['id'],'caption'=>$noofdownload_arr['licence_type'],'price'=>$noofdownload_arr['licence_fee']);
  275. }
  276. $this->set('Uploadpricearray',$tempUploadingarray);
  277. $this->set('fileformat','AI');
  278. $this->set('pricelistElement','show_stoxprice_illustration');
  279. ###### PHOTO INFORMATION
  280. }
  281. if($stoxInfo['media_type']=='Flash')
  282. {
  283. ###### PHOTO INFORMATION
  284. $selectImageinfo = "SELECT sale_imagefile,original_sale_imagefile,donate_zipfile,sale_zipfile from stoxfoto_flash where stoxfoto_id='".$stoxInfo['id']."' ";
  285. $selectImageinfo_query = mysql_query($selectImageinfo);
  286. if(mysql_num_rows($selectImageinfo_query)>0)
  287. {
  288. $selectImageinfo_arr = mysql_fetch_array($selectImageinfo_query);
  289. $this->set('stoxItemImage','../../app/webroot/stoxfoto_media/flash/image/medium/'.$selectImageinfo_arr['sale_imagefile']);
  290. $this->set('OrgstoxItemImage',$selectImageinfo_arr['sale_zipfile']);
  291. $this->set('OrgstoxFile',$selectImageinfo_arr['sale_zipfile']);
  292. $this->set('OrgstoxDownloadFile',$selectImageinfo_arr['donate_zipfile']);
  293. ###### Freee sample file ###########
  294. if($selectImageinfo_arr['donate_zipfile']!='')
  295. $SampleFile = 'flash/'.$stocxid;
  296. else
  297. $SampleFile = '';
  298. #################################
  299. }
  300. $stoxinfosql = "SELECT stoxfoto_flash_pricing.* From stoxfoto_flash_pricing
  301. where stoxfoto_flash_pricing.stoxfoto_id='".$stocxid."' order by stoxfoto_flash_pricing.id";
  302. $noofdownload_res = mysql_query($stoxinfosql);
  303. $tempUploadingarray=array();
  304. while($noofdownload_arr = mysql_fetch_array($noofdownload_res))
  305. {
  306. $tempUploadingarray[] = array('id'=>$noofdownload_arr['id'],'caption'=>$noofdownload_arr['licence_type'],'price'=>$noofdownload_arr['licence_fee']);
  307. }
  308. $this->set('Uploadpricearray',$tempUploadingarray);
  309. $this->set('fileformat','ZIP');
  310. $this->set('pricelistElement','show_stoxprice_illustration');
  311. ###### PHOTO INFORMATION
  312. }
  313. if($stoxInfo['media_type']=='Movie')
  314. {
  315. ###### PHOTO INFORMATION
  316. $selectImageinfo = "SELECT sale_imagefile,original_sale_imagefile,movie_type,CONCAT_WS(' X ',moviesizeX,moviesizeY) as stxfileXY , moviefilesize , moviesizefps ,movielength , donate_moviefile,sale_moviefile from stoxfoto_movie where stoxfoto_id='".$stoxInfo['id']."' ";
  317. $selectImageinfo_query = mysql_query($selectImageinfo);
  318. if(mysql_num_rows($selectImageinfo_query)>0)
  319. {
  320. $selectImageinfo_arr = mysql_fetch_array($selectImageinfo_query);
  321. $this->set('stoxItemImage','../../app/webroot/stoxfoto_media/movie/image/medium/'.$selectImageinfo_arr['sale_imagefile']);
  322. $this->set('OrgstoxItemImage',$selectImageinfo_arr['sale_moviefile']);
  323. $this->set('fileformat',$selectImageinfo_arr['movie_type']);
  324. $this->set('fileXY',$selectImageinfo_arr['stxfileXY']);
  325. $this->set('movfilesize',$selectImageinfo_arr['moviefilesize']);
  326. $this->set('movfilefps',$selectImageinfo_arr['moviesizefps']);
  327. $this->set('movfilelength',$selectImageinfo_arr['movielength']);
  328. $this->set('OrgstoxFile',$selectImageinfo_arr['sale_moviefile']);
  329. $this->set('OrgstoxDownloadFile',$selectImageinfo_arr['donate_moviefile']);
  330. ###### Freee sample file ###########
  331. if($selectImageinfo_arr['donate_moviefile']!='')
  332. $SampleFile = 'movie/'.$stocxid;
  333. else
  334. $SampleFile = '';
  335. #################################
  336. }
  337. $stoxinfosql = "SELECT stoxfoto_movie_pricing.* From stoxfoto_movie_pricing
  338. where stoxfoto_movie_pricing.stoxfoto_id='".$stocxid."' order by stoxfoto_movie_pricing.id";
  339. $noofdownload_res = mysql_query($stoxinfosql);
  340. $tempUploadingarray=array();
  341. while($noofdownload_arr = mysql_fetch_array($noofdownload_res))
  342. {
  343. $tempUploadingarray[] = array('id'=>$noofdownload_arr['id'],'caption'=>$noofdownload_arr['licence_type'],'price'=>$noofdownload_arr['licence_fee']);
  344. }
  345. $this->set('Uploadpricearray',$tempUploadingarray);
  346. $this->set('pricelistElement','show_stoxprice_illustration');
  347. ###### PHOTO INFORMATION
  348. }
  349. if($stoxInfo['media_type']=='Web')
  350. {
  351. ###### PHOTO INFORMATION
  352. $selectImageinfo = "SELECT sale_imagefile,original_sale_imagefile,movie_type,sale_zipfile from stoxfoto_web where stoxfoto_id='".$stoxInfo['id']."' ";
  353. $selectImageinfo_query = mysql_query($selectImageinfo);
  354. if(mysql_num_rows($selectImageinfo_query)>0)
  355. {
  356. $selectImageinfo_arr = mysql_fetch_array($selectImageinfo_query);
  357. $this->set('stoxItemImage','../../app/webroot/stoxfoto_media/web/image/medium/'.$selectImageinfo_arr['sale_imagefile']);
  358. $this->set('OrgstoxItemImage',$selectImageinfo_arr['sale_imagefile']);
  359. $this->set('fileformat',$selectImageinfo_arr['movie_type']);
  360. $this->set('OrgstoxFile',$selectImageinfo_arr['sale_zipfile']);
  361. }
  362. $stoxinfosql = "SELECT stoxfoto_web_pricing.* From stoxfoto_web_pricing
  363. where stoxfoto_web_pricing.stoxfoto_id='".$stocxid."' order by stoxfoto_web_pricing.id";
  364. $noofdownload_res = mysql_query($stoxinfosql);
  365. $tempUploadingarray=array();
  366. while($noofdownload_arr = mysql_fetch_array($noofdownload_res))
  367. {
  368. $tempUploadingarray[] = array('id'=>$noofdownload_arr['id'],'caption'=>$noofdownload_arr['licence_type'],'price'=>$noofdownload_arr['licence_fee']);
  369. }
  370. $this->set('Uploadpricearray',$tempUploadingarray);
  371. $this->set('pricelistElement','show_stoxprice_illustration');
  372. ###### PHOTO INFORMATION
  373. }
  374. $this->set('sampledownload',$SampleFile);
  375. }
  376. function stoxitemInfo($stoxfotoid=null)
  377. {
  378. $getInfo = "
  379. SELECT stoxfotos.id,stoxfotos.stoxfoto_code,stoxfotos.is_featured,stoxfotos.title,stoxfoto_categories.category_name ,stoxfotos.stoxfoto_category_id,GROUP_CONCAT(stoxfoto_tag.tagname) as taglist ,stoxfotos.media_type,stoxfotos.exclusive,stoxfotos.model_release,stoxfotos.property_release,stoxfotos.orginal_model_release,stoxfotos.orginal_property_release,stoxfotos.posted_date,users.username,stoxfotos.user_id,stoxfotos.numofview , stoxfotos.is_adultcontent ,stoxfotos.is_approved
  380. ,stoxfotos_tickets.ticket_number , stoxfotos_tickets.msg_to_user
  381. from stoxfotos
  382. LEFT JOIN stoxfoto_tag ON (stoxfoto_tag.stoxfoto_id=stoxfotos.id)
  383. LEFT JOIN stoxfoto_categories ON(stoxfotos.stoxfoto_category_id=stoxfoto_categories.id)
  384. LEFT Join users On (stoxfotos.user_id=users.id)
  385. LEFT JOIN stoxfotos_tickets ON (stoxfotos_tickets.stoxfoto_id=stoxfotos.id)
  386. where stoxfotos.id='".$stoxfotoid."'
  387. GROUP BY stoxfotos.id
  388. " ;
  389. $getInfo_res = mysql_query($getInfo);
  390. $getInfo_array = mysql_fetch_array($getInfo_res);
  391. //$this->set('firstSteparray',$getInfo_array);
  392. return $getInfo_array ;
  393. }
  394. function downloadstoxfotophoto()
  395. {
  396. $fileName=$this->params['url']['f'];
  397. $fileType=$this->params['url']['type'];
  398. $basePath='../../app/webroot/stoxfoto_media/photo/';
  399. $this->Download->downloadFile($basePath,$fileName);
  400. }
  401. function downloadstoxfotophotoelement()
  402. {
  403. $fileName=$this->params['url']['f'];
  404. $fileType=$this->params['url']['type'];
  405. $basePath='../../app/webroot/stoxfoto_media/element/';
  406. $this->Download->downloadFile($basePath,$fileName);
  407. }
  408. function downloadstoxfotoillustration()
  409. {
  410. $fileName=$this->params['url']['f'];
  411. $fileType=$this->params['url']['type'];
  412. $basePath='../../app/webroot/stoxfoto_media/illustration/eps/';
  413. $this->Download->downloadFile($basePath,$fileName);
  414. }
  415. function downloadstoxfotoflash()
  416. {
  417. $fileName=$this->params['url']['f'];
  418. $fileType=$this->params['url']['type'];
  419. $basePath='../../app/webroot/stoxfoto_media/flash/zip/';
  420. $this->Download->downloadFile($basePath,$fileName);
  421. }
  422. function downloadstoxfotoweb()
  423. {
  424. $fileName=$this->params['url']['f'];
  425. $fileType=$this->params['url']['type'];
  426. $basePath='../../app/webroot/stoxfoto_media/web/zip/';
  427. $this->Download->downloadFile($basePath,$fileName);
  428. }
  429. function downloadstoxfotomovie()
  430. {
  431. $fileName=$this->params['url']['f'];
  432. $fileType=$this->params['url']['type'];
  433. $basePath='../../app/webroot/stoxfoto_media/movie/video/';
  434. $this->Download->downloadFile($basePath,$fileName);
  435. }
  436. function downloadstoxrelease()
  437. {
  438. $fileName=$this->params['url']['f'];
  439. $fileType=$this->params['url']['type'];
  440. $basePath='../../app/webroot/stoxfoto_licence/'.$fileType.'/';
  441. $this->Download->downloadFile($basePath,$fileName);
  442. }
  443. function savesubmission($stoxid=null)
  444. {
  445. $ticketstatus='';
  446. if(isset($_REQUEST['stxstatus']) && $_REQUEST['stxstatus']!='')
  447. {
  448. $txtstxstatus = $_REQUEST['stxstatus'];
  449. }
  450. else
  451. $txtstxstatus=0;
  452. if(isset($_REQUEST['stxstatus']) && $_REQUEST['stxstatus']==1)
  453. $ticketstatus = 'approve';
  454. if(isset($_REQUEST['stxstatus']) && $_REQUEST['stxstatus']==-1)
  455. $ticketstatus = 'reject';
  456. $this->set('stxticstatus',$ticketstatus);
  457. $updateStocx = "UPDATE stoxfotos SET is_approved='".$txtstxstatus."' , is_adultcontent='".$_REQUEST['stxadult']."' where id='".$stoxid."' and is_temp='0'";
  458. @mysql_query($updateStocx);
  459. $updateTickets = "Update stoxfotos_tickets SET status='".$ticketstatus."' , msg_to_user ='".$_REQUEST['txtmsg']."' where stoxfoto_id='".$stoxid."'";
  460. @mysql_query($updateTickets);
  461. ##################################### MAil to the user for the approval or disapproval
  462. $stoxInfo = $this->stoxitemInfo($stoxid);
  463. $this->set('stoxinfo',$stoxInfo);
  464. ##### USER EMAIL ADDRESS
  465. $selectBackdropuser = "Select user_details.email , user_details.first_name ,user_details.last_name from user_details where user_id='".$stoxInfo['user_id']."'" ;
  466. $selectBackdropuser_res = mysql_query($selectBackdropuser);
  467. $selectBackdropuser_arr = mysql_fetch_array($selectBackdropuser_res);
  468. $this->set('stoxfotoFirst',$selectBackdropuser_arr['first_name']);
  469. $this->set('stoxfotoLast',$selectBackdropuser_arr['last_name']);
  470. if($ticketstatus!='')
  471. {
  472. $this->Sendmail->Mail();
  473. $this->Sendmail->From('xoadmin@gmail.com');
  474. $this->Sendmail->To($selectBackdropuser_arr['email']);
  475. $this->Sendmail->Cc("sanjib@navsoft.in");
  476. $this->Sendmail->Cc("sujoy@navsoft.in");
  477. $subject="Stoxfoto Ticket ".$stoxInfo['ticket_number']." status";
  478. $this->Sendmail->Subject($subject);
  479. $this->Sendmail->layout='email';
  480. $this->Sendmail->view='mail_stoxstatus';
  481. $this->Sendmail->startup($this);
  482. $messageBody=$this->Sendmail->bodyText();
  483. $this->Sendmail->Body($messageBody); // set the body
  484. $this->Sendmail->Priority(1) ; // set the priority to Low
  485. $this->Sendmail->Send(); /**/
  486. }
  487. ##################################### MAil to the user for the approval or disapproval
  488. }
  489. function viewstoxsales($viewType=null)
  490. {
  491. $this->checkSession();
  492. $this->pageTitle = 'Manage Stoxfoto '.ucfirst($viewType);
  493. $this->layout = 'default_user';
  494. $this->set('pageView',$viewType);
  495. if((isset($this->params['url']['hfsearch']) && $this->params['url']['hfsearch']!='') || isset($_REQUEST['hfsearch']) )
  496. $viewSearchType=$_REQUEST['hfsearch'];
  497. $select = "SELECT stoxfotos.id,stoxfotos.title ,stoxfotos.media_type ,stoxfotos.stoxfoto_code ,stoxfotos.exclusive,
  498. IF(stoxfotos.media_type='Photos',stoxfoto_photosize.caption ,IF(stoxfotos.media_type='PhotoElement',stoxfoto_photosize.caption,IF(stoxfotos.media_type='Illustration',stoxfoto_illustration_pricing.licence_type,IF(stoxfotos.media_type='Flash',stoxfoto_flash_pricing.licence_type,IF(stoxfotos.media_type='Movie',stoxfoto_movie_pricing.licence_type,IF(stoxfotos.media_type='Web',stoxfoto_web_pricing.licence_type,'-')))))) as photoLicense ,
  499. transaction_stoxfoto.total_amount,transaction_stoxfoto.date,transaction_stoxfoto.invoice ,transaction_stoxfoto.admin_comission ,transaction_stoxfoto.admin_comission_paid ";
  500. $from=" FROM stoxfoto_cart
  501. LEFT JOIN stoxfotos On (stoxfoto_cart.stoxfoto_id = stoxfotos.id)
  502. LEFT JOIN stoxfoto_photo_pricing ON((stoxfotos.media_type='Photos' or stoxfotos.media_type='PhotoElement') and stoxfoto_photo_pricing.stoxfoto_id =stoxfotos.id )
  503. LEFT JOIN stoxfoto_photosize ON(stoxfoto_photosize.id =stoxfoto_photo_pricing.stoxfoto_photosize_id)
  504. LEFT JOIN stoxfoto_illustration_pricing ON(stoxfotos.media_type='Illustration' and stoxfoto_illustration_pricing.stoxfoto_id =stoxfotos.id )
  505. LEFT JOIN stoxfoto_flash_pricing ON(stoxfotos.media_type='Flash' and stoxfoto_flash_pricing.stoxfoto_id =stoxfotos.id )
  506. LEFT JOIN stoxfoto_movie_pricing ON(stoxfotos.media_type='Movie' and stoxfoto_movie_pricing.stoxfoto_id =stoxfotos.id )
  507. LEFT JOIN stoxfoto_web_pricing ON(stoxfotos.media_type='Web' and stoxfoto_web_pricing.stoxfoto_id =stoxfotos.id )
  508. LEFT JOIN transaction_stoxfoto ON (stoxfoto_cart.transaction_stoxfoto_id=transaction_stoxfoto.id)
  509. ";
  510. $where="WHERE 1 AND stoxfotos.is_temp='0' AND stoxfotos.is_approved='1' and stoxfoto_cart.payflag='1'";
  511. $searchpass='';
  512. if(isset($viewSearchType) && $viewSearchType=='title' && isset($_REQUEST['txtsrch']) && $_REQUEST['txtsrch']!='')
  513. {
  514. $where.=" AND stoxfotos.title like '%".$_REQUEST['txtsrch']."%' ";
  515. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  516. }
  517. if(isset($viewSearchType) && $viewSearchType=='invoice')
  518. {
  519. $where.=" AND transaction_stoxfoto.invoice='".$_REQUEST['txtsrch']."'";
  520. //$searchexclusive = 'Yes';
  521. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  522. }
  523. if(isset($viewSearchType) && $viewSearchType=='daterange')
  524. {
  525. if($_REQUEST['inpdatefrom'] && $_REQUEST['inpdatefrom']!='mm/dd/YY')
  526. {
  527. $eventFromDate=date("Y-m-d",strtotime($_REQUEST['inpdatefrom']));
  528. $urlfromdate = $_REQUEST['inpdatefrom'];
  529. }
  530. else
  531. {
  532. $eventFromDate=date("Y-m-d");
  533. $urlfromdate = $_REQUEST['inpdatefrom'];
  534. }
  535. if($_REQUEST['inpdateto'] && $_REQUEST['inpdateto']!='mm/dd/YY')
  536. {
  537. $eventToDate=date("Y-m-d",strtotime($_REQUEST['inpdateto']));
  538. $urltodate = $_REQUEST['inpdateto'];
  539. }
  540. else
  541. {
  542. $eventToDate=date("Y-m-d");
  543. $urltodate = $_REQUEST['inpdateto'];
  544. }
  545. $where.=" AND transaction_stoxfoto.status_date between '".$eventFromDate."' and '".$eventToDate."' ";
  546. $searchpass = "&inpdatefrom=".$urlfromdate."&inpdateto=".$urltodate ;
  547. }
  548. if(isset($viewSearchType) && $viewSearchType=='license')
  549. {
  550. $where.=" and (IF(stoxfotos.media_type='Photos',stoxfoto_photosize.caption ,IF(stoxfotos.media_type='PhotoElement',stoxfoto_photosize.caption,IF(stoxfotos.media_type='Illustration',stoxfoto_illustration_pricing.licence_type,IF(stoxfotos.media_type='Flash',stoxfoto_flash_pricing.licence_type,IF(stoxfotos.media_type='Movie',stoxfoto_movie_pricing.licence_type,IF(stoxfotos.media_type='Web',stoxfoto_web_pricing.licence_type,'-')))))) ) like '% ".$_REQUEST['txtsrch']."%'";
  551. //$searchexclusive = 'Yes';
  552. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  553. }
  554. if(isset($viewSearchType) && $viewSearchType=='license')
  555. {
  556. //$where.=" AND transaction_stoxfoto.invoice='".$_REQUEST['txtsrch']."'";
  557. //$searchexclusive = 'Yes';
  558. $searchpass = "&license=".$_REQUEST['txtsrch'] ;
  559. }
  560. if(isset($viewSearchType) && $viewSearchType=='payment')
  561. {
  562. $where.=" AND transaction_stoxfoto.admin_comission_paid>=0'";
  563. //$searchexclusive = 'Yes';
  564. $searchpass = "&txtsrch=".$_REQUEST['txtsrch'] ;
  565. }
  566. $this->set('searchpass',$where);
  567. // $others=" ";
  568. $others=" GROUP BY transaction_stoxfoto.id ";
  569. if($viewType || (isset($_REQUEST['listview']) && $_REQUEST['listview']!='') )
  570. {
  571. if($viewType)
  572. $listView = $viewType ;
  573. if(isset($_REQUEST['listview']) && $_REQUEST['listview']!='')
  574. $listView = $_REQUEST['listview'] ;
  575. }
  576. $where.=" and stoxfotos.media_type='".$listView."' ";
  577. $others.=" order by transaction_stoxfoto.id desc ";
  578. if(isset($viewSearchType) && $viewSearchType!='')
  579. {
  580. $PassParameter="listview=".$listView."&hfsearch=".$viewSearchType.$searchpass;
  581. }
  582. else
  583. $PassParameter="listview=".$listView;
  584. $CountField="stoxfotos.id";
  585. $this->set("controller","stoxfoto");
  586. $this->set("action","viewstoxsales");
  587. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  588. if(isset($this->params['url']['Page']) || isset($viewSearchType))
  589. {
  590. $this->render("viewstoxsales2","ajax");
  591. }
  592. }
  593. ############################### For the Sizes mnagement ##########
  594. function managestoxsize()
  595. {
  596. $this->checkSession();
  597. $this->pageTitle = 'Manage Stoxfoto Sizes';
  598. $this->layout = 'default_user';
  599. $stoxsize = array();
  600. $stoxquery = "SELECT * from stoxfoto_photosize where is_delete='0'";
  601. $stoxquery_res = mysql_query($stoxquery);
  602. while($stoxquery_res_arr = mysql_fetch_assoc($stoxquery_res))
  603. {
  604. $stoxsize[] = $stoxquery_res_arr;
  605. }
  606. //pr($stoxsize);
  607. $this->set('stoxsizes',$stoxsize);
  608. }
  609. function editstoxsize($show=null,$sizeid=null)
  610. {
  611. $stoxinfo_res = "SELECT * from stoxfoto_photosize where id='".base64_decode($sizeid)."' ";
  612. $stoxinfo_res_query = mysql_query($stoxinfo_res);
  613. $stoxinfo_res_array = mysql_fetch_array($stoxinfo_res_query);
  614. $this->set('stoxinfo',$stoxinfo_res_array);
  615. $this->set('stoxview',$show);
  616. $this->render('editstoxsize', 'ajax');
  617. }
  618. function addstoxsize()
  619. {
  620. $this->render('addstoxsize', 'ajax');
  621. }
  622. function saveditstoxsize($stoxsize=null)
  623. {
  624. if($stoxsize)
  625. {
  626. //pr($_REQUEST);
  627. $stoxinfo_res = "UPDATE stoxfoto_photosize SET " ;
  628. if(isset($_REQUEST['txtcaption']) && $_REQUEST['txtcaption']!='')
  629. $stoxinfo_res .= " caption='".$_REQUEST['txtcaption']."' " ;
  630. if(isset($_REQUEST['txtheight']) && $_REQUEST['txtheight']>0)
  631. $stoxinfo_res .= " ,height_size='".$_REQUEST['txtheight']."' " ;
  632. if(isset($_REQUEST['txtwidth']) && $_REQUEST['txtwidth']>0)
  633. $stoxinfo_res .= " ,width_size='".$_REQUEST['txtwidth']."' " ;
  634. if(isset($_REQUEST['txtprint']) && $_REQUEST['txtprint']!='')
  635. $stoxinfo_res .= " ,printable_size='".addslashes($_REQUEST['txtprint'])."' " ;
  636. $stoxinfo_res .=" where id='".$stoxsize."' ";
  637. $stoxinfo_res_query = mysql_query($stoxinfo_res);
  638. }
  639. $this->redirect('/stoxfoto/managestoxsize');
  640. }
  641. function savestoxsize($stoxsize=null)
  642. {
  643. //pr($_REQUEST);
  644. $stoxinfo_res = "INSERT INTO stoxfoto_photosize SET " ;
  645. if(isset($_REQUEST['txtcaption']) && $_REQUEST['txtcaption']!='')
  646. $stoxinfo_res .= " caption='".$_REQUEST['txtcaption']."' " ;
  647. if(isset($_REQUEST['txtheight']) && $_REQUEST['txtheight']>0)
  648. $stoxinfo_res .= " ,height_size='".$_REQUEST['txtheight']."' " ;
  649. if(isset($_REQUEST['txtwidth']) && $_REQUEST['txtwidth']>0)
  650. $stoxinfo_res .= " ,width_size='".$_REQUEST['txtwidth']."' " ;
  651. if(isset($_REQUEST['txtprint']) && $_REQUEST['txtprint']!='')
  652. $stoxinfo_res .= " ,printable_size='".addslashes($_REQUEST['txtprint'])."' " ;
  653. //$stoxinfo_res .=" where id='".$stoxsize."' ";
  654. $stoxinfo_res_query = mysql_query($stoxinfo_res);
  655. $this->redirect('/stoxfoto/managestoxsize');
  656. }
  657. function delstoxsize($sizeid=null)
  658. {
  659. $stoxinfo_res = "UPDATE stoxfoto_photosize SET is_delete='1' where id='".base64_decode($sizeid)."' ";
  660. $stoxinfo_res_query = mysql_query($stoxinfo_res);
  661. $this->redirect('/stoxfoto/managestoxsize');
  662. }
  663. function managestoxpayout()
  664. {
  665. $this->checkSession();
  666. $this->pageTitle = 'Manage Stoxfoto Payouts';
  667. $this->layout = 'default_user';
  668. $stoxsize = array();
  669. $stoxquery = "SELECT * from stoxfoto_commission";
  670. $stoxquery_res = mysql_query($stoxquery);
  671. while($stoxquery_res_arr = mysql_fetch_assoc($stoxquery_res))
  672. {
  673. $stoxsize[] = $stoxquery_res_arr;
  674. }
  675. //pr($stoxsize);
  676. $this->set('stoxInfo',$stoxsize);
  677. }
  678. function addpayoutcomm()
  679. {
  680. }
  681. function savestoxpayoutsize()
  682. {
  683. //pr($_REQUEST);
  684. $tempStDown = 0;
  685. $tempwEndDown = 0;
  686. $startNumberofdown=0;
  687. $endNumberofdown=0;
  688. if(isset($_REQUEST['txtstnumofdownloads']) && $_REQUEST['txtstnumofdownloads']>0)
  689. {
  690. $startNumberofdown = $_REQUEST['txtstnumofdownloads'] ;
  691. $checkfordownload = "SELECT * from stoxfoto_commission where
  692. (if(end_no_sale=0,1=1,'".$startNumberofdown."' between start_no_sale and end_no_sale))
  693. " ;
  694. //echo $checkfordownload;
  695. //$checkfordownload_res = mysql_query($checkfordownload);
  696. if(mysql_num_rows($checkfordownload_res)>0)
  697. $tempStDown=1;
  698. }
  699. if(isset($_REQUEST['txtstnumofdownloads']) && $_REQUEST['txtstnumofdownloads']>0)
  700. {
  701. $endNumberofdown = $_REQUEST['txtendnumofdownloads'] ;
  702. //$checkfordownload = "SELECT * from stoxfoto_commission where '".$endNumberofdown."' between start_no_sale and end_no_sale " ;
  703. $checkfordownload = "SELECT * from stoxfoto_commission where
  704. (if(end_no_sale=0,1=1,'".$endNumberofdown."' between start_no_sale and end_no_sale))
  705. " ;
  706. $checkfordownload_res = mysql_query($checkfordownload);
  707. if(mysql_num_rows($checkfordownload_res)>0)
  708. $tempwEndDown=1;
  709. }
  710. if($tempStDown==0 && $tempwEndDown ==0)
  711. {
  712. if($startNumberofdown>0 && $endNumberofdown>=0 && (isset($_REQUEST['txtexclusive']) && $_REQUEST['txtexclusive']>0) && (isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0))
  713. {
  714. $savetopayroll ="INSERT INTO stoxfoto_commission SET start_no_sale='".$startNumberofdown."' , end_no_sale='".$endNumberofdown."' , exclusive_commission='".$_REQUEST['txtexclusive']."' , non_exclusive_commission='".$_REQUEST['txtnonexclusive']."' ";
  715. @mysql_query($savetopayroll);
  716. }
  717. } else {
  718. /*if($startNumberofdown>0 && $endNumberofdown>=0 && (isset($_REQUEST['txtexclusive']) && $_REQUEST['txtexclusive']>0) && (isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0))
  719. {
  720. $savetopayroll ="update stoxfoto_commission SET start_no_sale='".$startNumberofdown."' , end_no_sale='".$endNumberofdown."' , exclusive_commission='".$_REQUEST['txtexclusive']."' , non_exclusive_commission='".$_REQUEST['txtnonexclusive']."' where ";
  721. @mysql_query($savetopayroll);
  722. }*/
  723. }
  724. //$this->redirect('/stoxfoto/managestoxpayout');
  725. }
  726. function editstoxpayout($show=null,$sizeid=null)
  727. {
  728. $stoxinfo_res = "SELECT * from stoxfoto_commission where id='".base64_decode($sizeid)."' ";
  729. $stoxinfo_res_query = mysql_query($stoxinfo_res);
  730. $stoxinfo_res_array = mysql_fetch_array($stoxinfo_res_query);
  731. $this->set('stoxinfo',$stoxinfo_res_array);
  732. $this->set('stoxview',$show);
  733. $this->render('editstoxpayout', 'ajax');
  734. }
  735. function saveeditstoxpayoutsize($stoxsize=null)
  736. {
  737. $tempStDown = 0;
  738. $tempwEndDown = 0;
  739. $startNumberofdown=0;
  740. $endNumberofdown=0;
  741. if(isset($_REQUEST['txtstnumofdownloads']) && $_REQUEST['txtstnumofdownloads']>=0)
  742. {
  743. $startNumberofdown = $_REQUEST['txtstnumofdownloads'] ;
  744. $checkfordownload = "SELECT * from stoxfoto_commission where
  745. (if(end_no_sale=0,1=1,'".$startNumberofdown."' between start_no_sale and end_no_sale))
  746. " ;
  747. $checkfordownload_res = mysql_query($checkfordownload);
  748. if(mysql_num_rows($checkfordownload_res)>0)
  749. $tempStDown=1;
  750. }
  751. if(isset($_REQUEST['txtstnumofdownloads']) && $_REQUEST['txtstnumofdownloads']>=0)
  752. {
  753. $endNumberofdown = $_REQUEST['txtendnumofdownloads'] ;
  754. //$checkfordownload = "SELECT * from stoxfoto_commission where '".$endNumberofdown."' between start_no_sale and end_no_sale " ;
  755. $checkfordownload = "SELECT * from stoxfoto_commission where
  756. (if(end_no_sale=0,1=1,'".$endNumberofdown."' between start_no_sale and end_no_sale))
  757. " ;
  758. $checkfordownload_res = mysql_query($checkfordownload);
  759. if(mysql_num_rows($checkfordownload_res)>0)
  760. $tempwEndDown=1;
  761. }
  762. if($tempStDown==1 && $tempwEndDown ==1)
  763. {
  764. if($startNumberofdown>=0 && $endNumberofdown>=0 && (isset($_REQUEST['txtexclusive']) && $_REQUEST['txtexclusive']>0) && (isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0))
  765. {
  766. $savetopayroll ="UPDATE stoxfoto_commission SET start_no_sale='".$startNumberofdown."' , end_no_sale='".$endNumberofdown."' , exclusive_commission='".$_REQUEST['txtexclusive']."' , non_exclusive_commission='".$_REQUEST['txtnonexclusive']."' where id='".$stoxsize."' ";
  767. @mysql_query($savetopayroll);
  768. }
  769. }
  770. /*if($startNumberofdown>=0 && $endNumberofdown>=0 && (isset($_REQUEST['txtexclusive']) && $_REQUEST['txtexclusive']>0) && (isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0))
  771. {
  772. $savetopayroll ="UPDATE stoxfoto_commission SET start_no_sale='".$startNumberofdown."' , end_no_sale='".$endNumberofdown."' , exclusive_commission='".$_REQUEST['txtexclusive']."' , non_exclusive_commission='".$_REQUEST['txtnonexclusive']."' where id='".$stoxsize."' ";
  773. @mysql_query($savetopayroll);
  774. }*/
  775. $this->redirect('/stoxfoto/managestoxpayout');
  776. }
  777. function delstoxpayout($stoxsize=null)
  778. {
  779. $delquery = "DELETE from stoxfoto_commission where id='".$stoxsize."'";
  780. @mysql_query($delquery);
  781. $this->redirect('/stoxfoto/managestoxpayout');
  782. }
  783. ##########################################
  784. function managestoxprice()
  785. {
  786. $this->checkSession();
  787. $this->pageTitle = 'Manage Stox Price';
  788. $this->layout = 'default_user';
  789. $stoxsize = array();
  790. $stoxquery = "SELECT stoxfoto_photopngprice.*,stoxfoto_photosize.caption from stoxfoto_photopngprice
  791. LEFT JOIN stoxfoto_photosize ON (stoxfoto_photopngprice.stoxfoto_photosize_id=stoxfoto_photosize.id and stoxfoto_photosize.is_delete='0')
  792. ORDER BY stoxfoto_photopngprice.id asc ,stoxfoto_photopngprice.file_type
  793. ";
  794. $stoxquery_res = mysql_query($stoxquery);
  795. while($stoxquery_res_arr = mysql_fetch_assoc($stoxquery_res))
  796. {
  797. $stoxsize[] = $stoxquery_res_arr;
  798. }
  799. //pr($stoxsize);
  800. $this->set('stoxInfo',$stoxsize);
  801. }
  802. function addstoxpricing()
  803. {
  804. ########## PHOTO SUIZE #####
  805. $stoxsize = array();
  806. $stoxquery = "SELECT * from stoxfoto_photosize where is_delete='0'";
  807. $stoxquery_res = mysql_query($stoxquery);
  808. while($stoxquery_res_arr = mysql_fetch_assoc($stoxquery_res))
  809. {
  810. $stoxsize[$stoxquery_res_arr['id']] = $stoxquery_res_arr['caption'];
  811. }
  812. $this->set('photosizes',$stoxsize);
  813. ########## PHOTO SUIZE #####
  814. $filetype = array('Photos'=>'Photos','PhotoElement'=>'PhotoElement') ;
  815. $this->set('photofileType',$filetype);
  816. }
  817. function savestoxprice()
  818. {
  819. //pr($_REQUEST);
  820. //echo $this->data['stoxpricing']['filetype'] ;
  821. //exit();
  822. $tempStDown = 0;
  823. $tempwEndDown = 0;
  824. $startNumberofdown=0;
  825. $endNumberofdown=0;
  826. if(isset($_REQUEST['txtstnumofdownloads']) && $_REQUEST['txtstnumofdownloads']>0)
  827. {
  828. $startNumberofdown = $_REQUEST['txtstnumofdownloads'] ;
  829. $checkfordownload = " SELECT * from stoxfoto_photopngprice where file_type='".$this->data['stoxpricing']['filetype']."' and stoxfoto_photosize_id='".$this->data['stoxpricing']['filesize']."' and
  830. (if(end_no_downloads=0,1=1,'".$startNumberofdown."' between start_no_downloads and end_no_downloads))
  831. " ;
  832. $checkfordownload_res = mysql_query($checkfordownload);
  833. if(mysql_num_rows($checkfordownload_res)>0)
  834. $tempStDown=1;
  835. }
  836. if(isset($_REQUEST['txtendnumofdownloads']) && $_REQUEST['txtendnumofdownloads']>0)
  837. {
  838. $endNumberofdown = $_REQUEST['txtendnumofdownloads'] ;
  839. //$checkfordownload = "SELECT * from stoxfoto_commission where '".$endNumberofdown."' between start_no_sale and end_no_sale " ;
  840. $checkfordownload = " SELECT * from stoxfoto_photopngprice where file_type='".$this->data['stoxpricing']['filetype']."' and stoxfoto_photosize_id='".$this->data['stoxpricing']['filesize']."' and
  841. (if(end_no_downloads=0,1=1,'".$endNumberofdown."' between start_no_downloads and end_no_downloads))
  842. " ;
  843. $checkfordownload_res = mysql_query($checkfordownload);
  844. if(mysql_num_rows($checkfordownload_res)>0)
  845. $tempwEndDown=1;
  846. }
  847. if($tempStDown==0 && $tempwEndDown ==0)
  848. {
  849. if($startNumberofdown>0 && $endNumberofdown>=0 && (isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0))
  850. {
  851. $savetopayroll ="INSERT INTO stoxfoto_photopngprice SET start_no_downloads='".$startNumberofdown."' , end_no_downloads='".$endNumberofdown."' , file_type='".$this->data['stoxpricing']['filetype']."' , stoxfoto_photosize_id='".$this->data['stoxpricing']['filesize']."' , price='".$_REQUEST['txtnonexclusive']."' ";
  852. @mysql_query($savetopayroll);
  853. }
  854. }
  855. $this->redirect('/stoxfoto/managestoxprice');
  856. }
  857. function editstoxprice($show=null,$sizeid=null)
  858. {
  859. $stoxinfo_res = "SELECT * from stoxfoto_photopngprice where id='".base64_decode($sizeid)."' ";
  860. $stoxinfo_res_query = mysql_query($stoxinfo_res);
  861. $stoxinfo_res_array = mysql_fetch_array($stoxinfo_res_query);
  862. $this->set('stoxinfo',$stoxinfo_res_array);
  863. $this->set('stoxview',$show);
  864. ########## PHOTO SUIZE #####
  865. $stoxsize = array();
  866. $stoxquery = "SELECT * from stoxfoto_photosize where is_delete='0'";
  867. $stoxquery_res = mysql_query($stoxquery);
  868. while($stoxquery_res_arr = mysql_fetch_assoc($stoxquery_res))
  869. {
  870. $stoxsize[$stoxquery_res_arr['id']] = $stoxquery_res_arr['caption'];
  871. }
  872. $this->set('photosizes',$stoxsize);
  873. ########## PHOTO SUIZE #####
  874. $filetype = array('Photos'=>'Photos','PhotoElement'=>'PhotoElement') ;
  875. $this->set('photofileType',$filetype);
  876. $this->render('editstoxprice', 'ajax');
  877. }
  878. function saveeditstoxprice($stoxsize=null)
  879. {
  880. $tempStDown = 0;
  881. $tempwEndDown = 0;
  882. $startNumberofdown=0;
  883. $endNumberofdown=0;
  884. if(isset($_REQUEST['txtstnumofdownloads']) && $_REQUEST['txtstnumofdownloads']>0)
  885. {
  886. $startNumberofdown = $_REQUEST['txtstnumofdownloads'] ;
  887. $checkfordownload = " SELECT * from stoxfoto_photopngprice where file_type='".$this->data['stoxpricing']['filetype']."' and stoxfoto_photosize_id='".$this->data['stoxpricing']['filesize']."' and
  888. (if(end_no_downloads=0,1=1,'".$startNumberofdown."' between start_no_downloads and end_no_downloads))
  889. " ;
  890. $checkfordownload_res = mysql_query($checkfordownload);
  891. if(mysql_num_rows($checkfordownload_res)>0)
  892. $tempStDown=1;
  893. }
  894. if(isset($_REQUEST['txtendnumofdownloads']) && $_REQUEST['txtendnumofdownloads']>0)
  895. {
  896. $endNumberofdown = $_REQUEST['txtendnumofdownloads'] ;
  897. //$checkfordownload = "SELECT * from stoxfoto_commission where '".$endNumberofdown."' between start_no_sale and end_no_sale " ;
  898. $checkfordownload = " SELECT * from stoxfoto_photopngprice where file_type='".$this->data['stoxpricing']['filetype']."' and stoxfoto_photosize_id='".$this->data['stoxpricing']['filesize']."' and
  899. (if(end_no_downloads=0,1=1,'".$endNumberofdown."' between start_no_downloads and end_no_downloads))
  900. " ;
  901. $checkfordownload_res = mysql_query($checkfordownload);
  902. if(mysql_num_rows($checkfordownload_res)>0)
  903. $tempwEndDown=1;
  904. }
  905. echo $tempStDown ;
  906. echo $tempwEndDown ;
  907. if($tempStDown==0 && $tempwEndDown ==0)
  908. {
  909. if($startNumberofdown>0 && $endNumberofdown>=0 && (isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0))
  910. {
  911. $savetopayroll ="UPDATE stoxfoto_photopngprice SET start_no_downloads='".$startNumberofdown."' , end_no_downloads='".$endNumberofdown."' , file_type='".$this->data['stoxpricing']['filetype']."' , stoxfoto_photosize_id='".$this->data['stoxpricing']['filesize']."' , price='".$_REQUEST['txtnonexclusive']."' where id='".$stoxsize."' ";
  912. @mysql_query($savetopayroll);
  913. }
  914. }
  915. else
  916. {
  917. $savetopayroll ="UPDATE stoxfoto_photopngprice SET ";
  918. if(isset($_REQUEST['txtnonexclusive']) && $_REQUEST['txtnonexclusive']>0)
  919. $savetopayroll .=" price='".$_REQUEST['txtnonexclusive']."' ";
  920. $savetopayroll .=" where id='".$stoxsize."'";
  921. @mysql_query($savetopayroll);
  922. }
  923. $this->redirect('/stoxfoto/managestoxprice');
  924. }
  925. function delstoxprice($stoxsize=null)
  926. {
  927. $delquery = "DELETE from stoxfoto_photopngprice where id='".base64_decode($stoxsize)."' ";
  928. @mysql_query($delquery);
  929. $this->redirect('/stoxfoto/managestoxprice');
  930. }
  931. function stoximagehome()
  932. {
  933. $this->checkSession();
  934. $this->layout = 'default_user_cat';
  935. $selectTextimg = " SELECT id,helpimage,helptitle FROM homepage_texts where category='stoxfoto'";
  936. $categorysql_res = mysql_query($selectTextimg);
  937. $categorysql_num = mysql_num_rows($categorysql_res);
  938. if($categorysql_num>0)
  939. {
  940. $listarr=array();
  941. while($categorysql_array = mysql_fetch_array($categorysql_res))
  942. {
  943. $listarr[]=array('id'=>$categorysql_array['id'],'helpimage'=>$categorysql_array['helpimage'],'helptitle'=>$categorysql_array['helptitle']) ;
  944. }
  945. $this->set('slidearr',$listarr);
  946. }
  947. $this->set('slideNumber',$categorysql_num);
  948. }
  949. function editslide($slideId=null)
  950. {
  951. $this->checkSession();
  952. $this->layout = 'default_user_cat';
  953. $selectTextimg = " SELECT * FROM homepage_texts where id='".$slideId."' ";
  954. $categorysql_res = mysql_query($selectTextimg);
  955. $categorysql_num = mysql_num_rows($categorysql_res);
  956. if($categorysql_num>0)
  957. {
  958. $listarr=array();
  959. $categorysql_array = mysql_fetch_array($categorysql_res);
  960. $listarr[]=array('id'=>$categorysql_array['id'],'categoryName'=>$categorysql_array['category'],'helpimage'=>$categorysql_array['helpimage'],'helptitle'=>$categorysql_array['helptitle'],'helpdescription'=>$categorysql_array['helpdescription'],'morelink'=>$categorysql_array['morelink']) ;
  961. }
  962. $this->set('slidearr',$listarr);
  963. $this->set('slideNumber',$categorysql_num);
  964. }
  965. function saveslide($slideid=null)
  966. {
  967. if($slideid)
  968. {
  969. $destinatio

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