PageRenderTime 40ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/app/controllers/users_controller.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 2812 lines | 2118 code | 480 blank | 214 comment | 424 complexity | 7abfd0156b5aa0d4caea3a595afe5acb MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. class UsersController extends AppController {
  3. var $name='Users';
  4. var $components = array('Pagination','Thumbnail','Thumbnailc','Sendmail'); // ,'Cakephpbb' for phpbb componrent - not need
  5. var $helpers = array('javascript', 'error', 'Pagination','Ajax','Friendsurl');
  6. //this function is used to display the comming soon page
  7. //delete this function along with LAYOUT = FALASE and VIEW - FALSEINDEX
  8. function falseindex() {
  9. $this->layout = 'false';
  10. }
  11. function index() {
  12. $this->layout = 'default';
  13. $this->checkSession();
  14. }
  15. function sendforgotpassword() {
  16. if(isset($this->data['User']['userForgotName']) && $this->data['User']['userForgotName']!='') {
  17. $forgotuser = "SELECT password,id from users where username='".mysql_escape_string($this->data['User']['userForgotName'])."' ";
  18. $forgotuser_res = mysql_query($forgotuser);
  19. if(mysql_num_rows($forgotuser_res)>0) {
  20. $forgotuser_arr = mysql_fetch_array($forgotuser_res);
  21. $userDetails=$this->getUserDetails($forgotuser_arr['id']);
  22. $this->set('receiptInfo',$userDetails);
  23. ####### MAIL TEMPLATE
  24. $this->Sendmail->Mail();
  25. $this->Sendmail->From(FROMMAIL);
  26. $this->Sendmail->To($userDetails['email']);
  27. //$this->Sendmail->Cc("sanjib@navsoft.in");
  28. $subject="XOIMAGES PASSWORD REQUEST";
  29. $this->Sendmail->Subject($subject);
  30. $this->Sendmail->layout='email';
  31. $this->Sendmail->view='mail_userpassword';
  32. $this->Sendmail->startup($this);
  33. $messageBody=$this->Sendmail->bodyText();
  34. $this->Sendmail->Body($messageBody); // set the body
  35. $this->Sendmail->Priority(1) ;
  36. $this->Sendmail->Send();
  37. $this->set('mailmsg','Your login information has been sent to your email.');
  38. #####
  39. }
  40. else {
  41. $this->set('mailmsg','Username is invalid. Please give A valid Username.');
  42. }
  43. }
  44. $this->render('validpasssending', 'ajax');
  45. }
  46. ################################################### PHOTOS SECTION #############################
  47. function indexnew() {
  48. $this->layout = 'xoindex';
  49. $this->homepageslideInfo('Home');
  50. ################################################ Auction Invitation ################
  51. if(isset($_REQUEST['key'])&& $_REQUEST['key']!='') {
  52. $this->Session->write('auctKey',$_REQUEST['key']);
  53. if(isset($_REQUEST['act'])&& $_REQUEST['act']=='auctiondonorsinvite')
  54. $this->Session->write('auctType',$_REQUEST['act']);
  55. }
  56. ############################################ /Auction Invitation ################
  57. }
  58. function photos() {
  59. $this->layout = 'userphotoinner_home';
  60. $this->homepageslideInfo('Photos');
  61. }
  62. function customprofile($savimgpath=null) {
  63. $this->layout = 'profile_blank';
  64. $this->set("saveimagepath",$savimgpath);
  65. }
  66. function myalbum() {
  67. $this->checkSession();
  68. $this->layout = 'userphotoinner';
  69. $this->pageTitle = 'My Album';
  70. }
  71. function allalbum() {
  72. $this->layout = 'userphotoinner';
  73. $this->pageTitle = 'All Album';
  74. $select = " Select Xalbum.id,Xalbum.user_id,Xalbum.album_bg,Xalbum.album_access,Xalbum.album_name,Xuser.username";
  75. $from=" FROM user_albums Xalbum
  76. LEFT JOIN users Xuser ON Xalbum.user_id = Xuser.id
  77. LEFT JOIN user_details Xuserdetail ON Xalbum.user_id = Xuserdetail.user_id";
  78. $where="WHERE 1 AND Xalbum.album_access='public'";
  79. $others=" ";
  80. $others=" order by Xalbum.id desc";
  81. $PassParameter='';
  82. $fltr='';
  83. $CountField="Xalbum.id";
  84. $this->set("controller","users");
  85. $this->set("action","allalbum");
  86. $this->set("parameter",$PassParameter);
  87. $this->set("fltr",$fltr);
  88. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  89. if(isset($this->params['url']['Page'])) {
  90. $this->render("allalbum2","ajax");
  91. }
  92. }
  93. function photolisting() {
  94. $this->layout = 'userphotoinner';
  95. if(isset($_REQUEST['listtype']) && $_REQUEST['listtype']!='')
  96. $catlisttype = $_REQUEST['listtype'];
  97. else
  98. $catlisttype = '';
  99. ############################### Page Title & Head ############################
  100. $pageheadArr = array();
  101. $pageheadArr['featured'] = 'Featured';
  102. $pageheadArr['recent'] = 'Recent';
  103. $pageheadArr['mostvoted'] = 'Most Voted';
  104. $pageheadArr['mostcomment'] = 'Most Discussed';
  105. $pageheadArr['random'] = 'Random';
  106. $pageheadArr['favorite'] = 'Most Favorited ';
  107. $pageheadArr['tag'] = 'Tagged ';
  108. $pageheadArr['search'] = 'Search Result';
  109. $pageheadArr['mostviewed'] = 'Most Viewed';
  110. $pageheadArr['albumview'] = 'Album';
  111. if (array_key_exists($catlisttype, $pageheadArr)) {
  112. if($catlisttype=='albumview') {
  113. /* Album Name*/
  114. $albumNameSql = "Select IFNULL(album_name,'') as albumName from user_albums where id='".base64_decode($_REQUEST['albumid'])."'";
  115. $albumNameSql_res = mysql_fetch_array(mysql_query($albumNameSql));
  116. $albumName = stripslashes($albumNameSql_res['albumName']) ;
  117. /**/
  118. $this->pageTitle = $pageheadArr[$catlisttype]. $albumName.' Photos';
  119. $this->set('pagehead',$pageheadArr[$catlisttype].' : '. $albumName. ' Photos');
  120. }
  121. else {
  122. if($catlisttype=='tag') {
  123. $this->pageTitle = $pageheadArr[$catlisttype].' Photos : '. substr($_REQUEST['sortby'],0,20);
  124. $this->set('pagehead',$pageheadArr[$catlisttype].' Photos : '.substr($_REQUEST['sortby'],0,20));
  125. }
  126. else {
  127. $this->pageTitle = $pageheadArr[$catlisttype].' Photos';
  128. $this->set('pagehead',$pageheadArr[$catlisttype].' Photos');
  129. }
  130. }
  131. }
  132. else {
  133. $this->pageTitle = 'Photos';
  134. $this->set('pagehead','Photos');
  135. }
  136. ############################### Page Title & Head ############################
  137. /* Pagination and PHOTO listing */
  138. $select = " Select X.id,X.user_id,X.pic_original_name,X.pic_title,X.pic_desc,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat,Xalbum.album_name ,Xalbum.id as albumid ,COUNT(Xfavorite.id) as photofavored ,X.is_featured , X.creation";
  139. $from=" FROM user_photo_albums X
  140. LEFT JOIN user_albums Xalbum ON X.user_album_id = Xalbum.id
  141. LEFT JOIN comments Xcomment ON X.id = Xcomment.user_photo_albums_id
  142. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  143. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  144. LEFT JOIN user_voting_images Xrating ON X.id = Xrating.image_id
  145. LEFT JOIN user_favorite_photo Xfavorite ON X.id=Xfavorite.favorite_photo_id ";
  146. $where="WHERE 1 AND X.is_blocked='0' AND X.is_temp='0' AND Xalbum.album_access='public'";
  147. if($catlisttype=='featured')
  148. $where.=" AND X.is_featured='1' ";
  149. if( $catlisttype=='albumview' && isset($_REQUEST['albumid']) && base64_decode($_REQUEST['albumid'])>0)
  150. $where.=" AND X.user_album_id='".base64_decode($_REQUEST['albumid'])."' ";
  151. if($catlisttype=='tag')
  152. $where.=" AND X.id IN (Select user_photo_album_id from user_photo_albums_tags where tagname Like '%".$_REQUEST['sortby']."%')";
  153. if($catlisttype=='search')
  154. $where.=" AND X.pic_title LIKE '%".$_REQUEST['srchtxt']."%' OR X.id IN (Select user_photo_album_id from user_photo_albums_tags where tagname Like '%".$_REQUEST['srchtxt']."%') ";
  155. $others=" group by X.id order by X.id desc ";
  156. if($catlisttype=='mostvoted')
  157. $others .=" ,photorat desc ";
  158. if($catlisttype=='mostcomment')
  159. $others .=" ,photoreview desc ";
  160. if($catlisttype=='mostviewed')
  161. $others .=" ,X.viewed desc ";
  162. if($catlisttype=='random')
  163. $others .=" , rand()";
  164. if($catlisttype=='favorite')
  165. $others .=" ,photofavored desc ";
  166. if($catlisttype=='recent')
  167. $others.=" ";
  168. if(isset($_REQUEST['sortby']) && $_REQUEST['sortby']!='')
  169. $PassParameter="listtype=".$catlisttype."&sortby=".$_REQUEST['sortby'];
  170. else {
  171. if(isset($catlisttype) && $catlisttype=='albumview')
  172. $PassParameter="listtype=".$catlisttype."&albumid=".$_REQUEST['albumid'];
  173. else {
  174. if(isset($_REQUEST['srchtxt']) && $_REQUEST['srchtxt']!='')
  175. $PassParameter="listtype=".$catlisttype."&srchtxt=".$_REQUEST['srchtxt'];
  176. else
  177. $PassParameter="listtype=".$catlisttype;
  178. }
  179. }
  180. $fltr='';
  181. $CountField="X.id";
  182. $this->set("controller","users");
  183. $this->set("action","photolisting");
  184. $this->set("parameter",$PassParameter);
  185. $this->set("fltr",$fltr);
  186. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  187. if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") ) {
  188. $this->set('pagehead','Most Recent');
  189. $this->render("photolisting2","ajax");
  190. }
  191. /**/
  192. }
  193. function featuredphoto($catlisttype=null) {
  194. $this->layout = 'profile_blank';
  195. /* Pagination and PHOTO listing */
  196. $select = " Select X.id,X.user_id,X.pic_original_name,X.pic_title,X.pic_desc,Xuser.username ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat,Xalbum.album_name ,Xalbum.id as albumid ,COUNT(Xfavorite.id) as photofavored ,X.is_featured,X.creation ";
  197. $from=" FROM user_photo_albums X
  198. LEFT JOIN user_albums Xalbum ON X.user_album_id = Xalbum.id
  199. LEFT JOIN comments Xcomment ON X.id = Xcomment.user_photo_albums_id
  200. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  201. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  202. LEFT JOIN user_voting_images Xrating ON X.id = Xrating.image_id
  203. LEFT JOIN user_favorite_photo Xfavorite ON X.id=Xfavorite.favorite_photo_id ";
  204. $where="WHERE 1 AND X.is_blocked='0' AND X.is_temp='0' AND Xalbum.album_access='public'";
  205. $moreUrl = $this->webroot.'users/photolisting?listtype=recent';
  206. if($catlisttype=='featured') {
  207. $where.=" AND X.is_featured='1' ";
  208. $moreUrl = $this->webroot.'users/photolisting?listtype=featured';
  209. }
  210. $others=" group by X.id ";
  211. if($catlisttype=='mostvoted') {
  212. $others .=" order by photorat desc ";
  213. $moreUrl = $this->webroot.'users/photolisting?listtype=mostvoted';
  214. }
  215. if($catlisttype=='')
  216. $others.=" order by X.id desc";
  217. $photoquery = mysql_query($select .$from .$where.$others .' LIMIT 12');
  218. $this->set('query',$photoquery) ;
  219. $this->set('morelink',$moreUrl) ;
  220. }
  221. function pagination($select,$from,$where,$others,$CountField,$arg,$PassParameter) {
  222. if(isset($arg['Page']))
  223. $pageFlag=$arg['Page'];
  224. $this->set("PassParameter",$PassParameter);
  225. $SetUserNumberOfVpsPerPage=SHOW_REC; /* Defined in config->paths.php*/
  226. $this->set("BackgroundClass",'pagination');
  227. $this->set("SelectedPage",'pagination_over');
  228. $this->set("Linkpage",'pagination_over');
  229. $this->set("FirstImage",'fdd.gif');
  230. $this->set("PreviousImage",'previous.gif');
  231. $this->set("NextImage",'next.gif');
  232. $this->set("LastImage",'rewd.gif');
  233. $UserNumberOfVpsPerPage=SHOW_REC; /* Defined in config->paths.php*/
  234. if(!is_numeric($UserNumberOfVpsPerPage)|| (intval($UserNumberOfVpsPerPage)!=$UserNumberOfVpsPerPage)||($UserNumberOfVpsPerPage<=0))
  235. $UserNumberOfVpsPerPage = $SetUserNumberOfVpsPerPage;
  236. if(!isset($arg['Page'])) $arg['Page']=1;
  237. if(!isset($arg['Offset'])) $arg['Offset']=0;
  238. ///echo "$select $from $where $others" ;
  239. $Query_ForNumber_Records=mysql_query("$select $from $where $others") or die('Line no 120' . mysql_error());
  240. //$Result_Query_ForNumber_Records=mysql_fetch_object($Query_ForNumber_Records);
  241. //$NoOfVps=$Result_Query_ForNumber_Records->NoOfVps;
  242. $NoOfVps=mysql_num_rows($Query_ForNumber_Records);
  243. $NumberOfVpsPerPage=$UserNumberOfVpsPerPage;
  244. $NoOfPages=ceil($NoOfVps/$NumberOfVpsPerPage); //3
  245. if($arg['Offset']==$NoOfVps) {
  246. if(isset($Offset)) {
  247. $Offset=$Offset-$NumberOfVpsPerPage;
  248. $Page--;
  249. if($Offset<0) {
  250. $Offset=0;
  251. $Page=1;
  252. }
  253. }else {
  254. $Offset=0;
  255. $Page=1;
  256. }
  257. }
  258. $this->set("Page",$arg['Page']);
  259. $this->set("Offset",$arg['Offset']);
  260. $this->set("NumberOfVpsPerPage",$NumberOfVpsPerPage);
  261. $this->set("NoOfPages",$NoOfPages);
  262. $this->set("UserNumberOfVpsPerPage",$UserNumberOfVpsPerPage);
  263. //print "$select $from $where $others";
  264. $this->set("qryOthr","$select $from $where");
  265. //echo "$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage";
  266. $SelectRecord = mysql_query("$select $from $where $others LIMIT ".$arg['Offset'].",$NumberOfVpsPerPage") or die('Line no '.__LINE__ . mysql_error());
  267. $this->set("query",$SelectRecord);
  268. }
  269. ################################################### PHOTOS SECTION #############################
  270. function aboutus() {
  271. $this->layout = 'default';
  272. ########### data from table ######
  273. $contectsql = "Select description from site_managements where id='1'";
  274. $contectsql_res = mysql_query($contectsql);
  275. $contectsql_arr = mysql_fetch_array($contectsql_res);
  276. $this->set('content',$contectsql_arr['description']);
  277. ######
  278. }
  279. function contactus($windowType=null) {
  280. $this->layout = 'default';
  281. ########### data from table ######
  282. $contectsql = "Select description from site_managements where id='2'";
  283. $contectsql_res = mysql_query($contectsql);
  284. $contectsql_arr = mysql_fetch_array($contectsql_res);
  285. $this->set('content',$contectsql_arr['description']);
  286. if($windowType)
  287. $this->set('windowcontent',$windowType);
  288. else
  289. $this->set('windowcontent','feedback');
  290. ######
  291. }
  292. function contactusajax($pageaction=null) {
  293. echo $pageaction;
  294. $this->set('pagecontentText',$pageaction);
  295. $this->render('contactusajax', 'ajax');
  296. }
  297. function terms() {
  298. $this->layout = 'default';
  299. ########### data from table ######
  300. $contectsql = "Select description from site_managements where id='3'";
  301. $contectsql_res = mysql_query($contectsql);
  302. $contectsql_arr = mysql_fetch_array($contectsql_res);
  303. $this->set('content',$contectsql_arr['description']);
  304. ######
  305. }
  306. function privacy() {
  307. $this->layout = 'default';
  308. ########### data from table ######
  309. $contectsql = "Select description from site_managements where id='4'";
  310. $contectsql_res = mysql_query($contectsql);
  311. $contectsql_arr = mysql_fetch_array($contectsql_res);
  312. $this->set('content',$contectsql_arr['description']);
  313. ######
  314. }
  315. function disclaimer() {
  316. $this->layout = 'default';
  317. ########### data from table ######
  318. $contectsql = "Select description from site_managements where id='5'";
  319. $contectsql_res = mysql_query($contectsql);
  320. $contectsql_arr = mysql_fetch_array($contectsql_res);
  321. $this->set('content',$contectsql_arr['description']);
  322. ######
  323. }
  324. function parents() {
  325. $this->layout = 'default';
  326. ########### data from table ######
  327. $contectsql = "Select description from site_managements where id='7'";
  328. $contectsql_res = mysql_query($contectsql);
  329. $contectsql_arr = mysql_fetch_array($contectsql_res);
  330. $this->set('content',$contectsql_arr['description']);
  331. ######
  332. }
  333. function home() {
  334. $this->layout = 'default';
  335. $this->pageTitle = 'Home';
  336. $this->pageTitle = 'User Login';
  337. if(isset($_SESSION['UserId']) && $_SESSION['UserId']!="") {
  338. $tempid = time();
  339. $tempsessid = session_id();
  340. $this->set('loggedUid',base64_encode($_SESSION['UserId']));
  341. $this->set('loggedId',$tempid);
  342. $this->set('loggedsid',$tempsessid);
  343. }
  344. }
  345. function login() {
  346. $this->layout = 'default';
  347. $this->pageTitle = 'User Login';
  348. if(!empty($this->data)) {
  349. $this->data['User']['username']=trim($this->data['User']['userLoginName']);
  350. $this->data['User']['password']=base64_encode(trim($this->data['User']['userLoginPass']));
  351. $someone = $this->User->findByUsername($this->data['User']['username']);
  352. $hRef = $_SERVER['HTTP_REFERER'];
  353. $this->Session->write('href', $hRef);
  354. if(!empty($someone['User']['password']) && $someone['User']['password'] == $this->data['User']['password'] && $someone['User']['user_status']==1) {
  355. if($someone['User']['user_status']==1) {
  356. $this->Session->write('User', $someone['User']['username']);
  357. $this->Session->write('UserId', $someone['User']['id']);
  358. $this->Session->write('GrpId', $someone['User']['user_group_master_id']);
  359. ########################## AUCTION INVITATION OPERATION #######
  360. if(isset($_SESSION['auctKey']))
  361. $this->auctInviteoperation() ;
  362. ############################# /AUCTION INVITATION OPERATION #######
  363. if(isset($_REQUEST['act_event']) && $_REQUEST['act_event'] != "") {
  364. $link = 'calendars/acceptinvitation?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evtid'].'&invitation='.$_REQUEST['invitation'];
  365. $this->redirect($link);
  366. }
  367. else if(isset($_REQUEST['act']) && $_REQUEST['act'] == "activityinvite") {
  368. $link = 'calendars/showactivity?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evtid'].'&invitation='.base64_decode($_REQUEST['invitation']);
  369. $this->redirect($link);
  370. }
  371. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "sharecal") {
  372. $qry = "insert into calendar_import values(".base64_decode($_REQUEST['calid']).", ".$someone['User']['id'].", 'y')";
  373. $res = mysql_query($qry);
  374. $link = 'users/user_home?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.base64_encode(1);
  375. $this->redirect($link);
  376. }
  377. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "eventinvite") {
  378. $link = 'calendars/acceptinvitation?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evidVal'].'&invitation='.$_REQUEST['invitationVal'];
  379. $this->redirect($link);
  380. }
  381. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "activityinvite") {
  382. $link = 'calendars/showactivity?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evidVal'].'&invitation='.$_REQUEST['invitationVal'];
  383. $this->redirect($link);
  384. }
  385. else {
  386. $this->flash('The username with id: '.$this->data['User']['username'].' has been submitted.', '/users');
  387. $link = 'users/user_home?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.base64_encode(1);
  388. $this->redirect($link);
  389. }
  390. }
  391. else {
  392. $msg = "Invalid Login";
  393. $this->redirect('/users/signup?msg=error');
  394. }
  395. }
  396. else {
  397. $msg = "Invalid Login";
  398. $this->redirect('/users/signup?msg=error');
  399. }
  400. }
  401. }
  402. function headerlogin() {
  403. $this->layout = 'default';
  404. $this->pageTitle = 'User Login';
  405. if(!empty($this->data)) {
  406. $this->data['User']['username']=trim($this->data['User']['headerLoginName']);
  407. $this->data['User']['password']=base64_encode(trim($this->data['User']['headerLoginPass']));
  408. $someone = $this->User->findByUsername($this->data['User']['username']);//"http://adserver:8088/xoimage-115-07/Nnew/"
  409. $hRef = $_SERVER['HTTP_REFERER'];
  410. $this->Session->write('href', $hRef);
  411. if(!empty($someone['User']['password']) && $someone['User']['password'] == $this->data['User']['password'] && $someone['User']['user_status']==1) {
  412. if($someone['User']['user_status']==1) {
  413. mysql_query("DELETE FROM xoevent_cart WHERE xoevent_pay_status='0' AND user_id='".$someone['User']['id']."' AND xoevent_sessionid!='".session_id()."'") or die(mysql_error());
  414. $_REQUEST['actVal'];
  415. $this->Session->write('User', $someone['User']['username']);
  416. $this->Session->write('UserId', $someone['User']['id']);
  417. $this->Session->write('GrpId', $someone['User']['user_group_master_id']);
  418. ##################### FORUM SESSION START
  419. /* $ch = curl_init();
  420. $scriptUrl = DOMAIN. 'phpbbcakelogin.php?userName='.$this->data['User']['username'].'&password='.$this->data['User']['password'];
  421. curl_setopt($ch, CURLOPT_URL, $scriptUrl);
  422. curl_setopt($ch, CURLOPT_HEADER, 0);
  423. $output =curl_exec($ch);
  424. curl_close($ch);
  425. echo $output ;/**/
  426. //$this->Cakephpbb->phpbbuserlogged($this->data['User']['username'],$this->data['User']['password']);*/
  427. ##################### FORUM SESSION START
  428. if($someone['User']['user_group_master_id']==2) {
  429. //echo "group id : 2";
  430. $_SESSION['pubSchool']='p';
  431. $_SESSION['is_public']=1;
  432. $_SESSION['categoryTab']=2;
  433. }
  434. if($someone['User']['user_group_master_id']==3) {
  435. //echo "group id : 3";
  436. $_SESSION['pubSchool']='s';
  437. $_SESSION['is_public']=2;
  438. $_SESSION['categoryTab']=3;
  439. }
  440. ########################## AUCTION INVITATION OPERATION #######
  441. if(isset($_SESSION['auctKey']))
  442. $this->auctInviteoperation() ;
  443. ############################# /AUCTION INVITATION OPERATION #######
  444. if(isset($_REQUEST['act']) && $_REQUEST['act'] == "activityinvite") {
  445. $link = 'calendars/showactivity?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evtid'].'&invitation='.base64_decode($_REQUEST['invitation']);
  446. $this->redirect($link);
  447. }
  448. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "sharecal") {
  449. $qry = "insert into calendar_import values(".base64_decode($_REQUEST['calid']).", ".$someone['User']['id'].", 'y')";
  450. $res = mysql_query($qry);
  451. $link = 'users/user_home?id='.time().'&uid='.base64_encode($someone['User']['id']);
  452. $this->redirect($link);
  453. }
  454. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "eventinvite") {
  455. $link = 'calendars/acceptinvitation?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evidVal'].'&invitation='.$_REQUEST['invitationVal'];
  456. $this->redirect($link);
  457. }
  458. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "activityinvite") {
  459. $link = 'calendars/showactivity?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evidVal'].'&invitation='.$_REQUEST['invitationVal'];
  460. $this->redirect($link);
  461. }
  462. else {
  463. $this->flash('The username with id: '.$this->data['User']['username'].' has been submitted.', '/users');
  464. $link = 'users/user_home?id='.time().'&uid='.base64_encode($someone['User']['id']);
  465. $this->redirect($link);
  466. }
  467. }
  468. }
  469. else {
  470. $msg = "Invalid Login";
  471. $this->redirect('/?msg=headererror');
  472. }
  473. }
  474. }
  475. ############## FOR POPUPLOGIN ######
  476. function checkpopuplogin() {
  477. if(!empty($this->data)) {
  478. $this->data['User']['username']=trim($this->data['User']['headerLoginName']);
  479. $this->data['User']['password']=base64_encode(trim($this->data['User']['headerLoginPass']));
  480. $someone = $this->User->findByUsername($this->data['User']['username']);//"http://adserver:8088/xoimage-115-07/Nnew/"
  481. if(!empty($someone['User']['password']) && $someone['User']['password'] == $this->data['User']['password']) {
  482. if($someone['User']['user_status']==1) {
  483. mysql_query("DELETE FROM xoevent_cart WHERE xoevent_pay_status='0' AND user_id='".$someone['User']['id']."' AND xoevent_sessionid!='".session_id()."'") or die(mysql_error());
  484. $this->Session->write('User', $someone['User']['username']);
  485. $this->Session->write('UserId', $someone['User']['id']);
  486. $this->Session->write('GrpId', $someone['User']['user_group_master_id']);
  487. if($someone['User']['user_group_master_id']==2) {
  488. $_SESSION['pubSchool']='p';
  489. $_SESSION['is_public']=1;
  490. $_SESSION['categoryTab']=2;
  491. }
  492. if($someone['User']['user_group_master_id']==3) {
  493. $_SESSION['pubSchool']='s';
  494. $_SESSION['is_public']=2;
  495. $_SESSION['categoryTab']=3;
  496. }
  497. $link = 'users/user_home?id='.time().'&uid='.base64_encode($someone['User']['id']);
  498. $this->set("validated",0); ///right Info
  499. $this->set('userHome',$link);
  500. }
  501. }
  502. else {
  503. $this->set("validated",1); /// Error Info
  504. }
  505. }
  506. $this->render('validpopuplogin', 'ajax');
  507. }
  508. ############## FOR POPUPLOGIN ######
  509. function auctInviteoperation() {
  510. $this->checkSession();
  511. if(isset($_SESSION['auctKey'])) {
  512. $updatesql = "UPDATE auctxon_donors_invite SET is_respond='1' , registered_invitee_userid='".$_SESSION['UserId']."' where is_respond='0' and hash_key='".$_SESSION['auctKey']."' ";
  513. @mysql_query($updatesql);
  514. }
  515. }
  516. function signup() {
  517. if(isset($_SESSION['UserId'])) {
  518. $this->redirect('/?id=1');
  519. }
  520. $group=base64_decode($_REQUEST['gr']);
  521. $this->set('group',$group);
  522. ################################################ Auction Invitation ################
  523. if(isset($_REQUEST['key'])&& $_REQUEST['key']!='') {
  524. $this->Session->write('auctKey',$_REQUEST['key']);
  525. if(isset($_REQUEST['act'])&& $_REQUEST['act']=='auctiondonorsinvite')
  526. $this->Session->write('auctType',$_REQUEST['act']);
  527. }
  528. ############################################ /Auction Invitation ################
  529. $this->layout = 'user_signup';
  530. $this->pageTitle = 'Xoimage Sign-up';
  531. if (!empty($this->data)) {
  532. if(isset($_REQUEST['userType']) && $_REQUEST['userType']!="") {
  533. $this->data['User']['user_group_master_id'] = $_REQUEST['userType'];
  534. //die();
  535. }
  536. $this->data['User']['user_status'] = 1;
  537. $this->data['User']['password'] = base64_encode($this->data['User']['password']);
  538. if ($this->User->save($this->data)) {
  539. $id = mysql_insert_id();
  540. $fname = addslashes(strtolower($this->data['User']['first_name']));
  541. $lname = addslashes(strtolower($this->data['User']['last_name']));
  542. $email = $this->data['User']['email'];
  543. $user_name = trim($this->data['User']['username']) ;
  544. $pass=base64_encode(trim($this->data['User']['password']));
  545. ################ FORUM INTEGRATION
  546. $pass=$this->data['User']['password'];
  547. $email_hash=crc32($email);
  548. $sql1="INSERT INTO phpbb_users (username, username_clean, user_password, user_pass_convert, user_email, user_email_hash, group_id, user_type, user_permissions, user_timezone, user_dateformat, user_lang, user_style, user_allow_pm, user_actkey, user_ip, user_regdate, user_passchg, user_options, user_inactive_reason, user_inactive_time, user_lastmark, user_lastvisit, user_lastpost_time, user_lastpage, user_posts, user_dst, user_colour, user_occ, user_interests, user_avatar, user_avatar_type, user_avatar_width, user_avatar_height, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_message_rules, user_full_folder, user_emailtime, user_notify, user_notify_pm, user_notify_type, user_allow_viewonline, user_allow_viewemail, user_allow_massemail, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_form_salt) VALUES ('$user_name', '$user_name', '$pass', 0, '$email', '$email_hash', 2, 0, '', 0, 'D M d, Y g:i a', 'en', '1', 1, '', '0.0.0.0', 1202106072, 1202106072, 895, 0, 0, 1202106072, 0, 0, '', 0, '0', '', '', '', '', 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 1, 0, 1, 1, 1, '', '', '', '39390ba638fe9a78')";
  549. //echo $sql1;
  550. @mysql_query($sql1);
  551. $new_query_group="select MAX(user_id) AS USERID FROM phpbb_users";
  552. $new_result_group=mysql_query($new_query_group);
  553. $new_data_group=mysql_fetch_array($new_result_group);
  554. $new_user_id=$new_data_group['USERID'];
  555. //echo $new_user_id;
  556. $new_query_insert="INSERT INTO phpbb_user_group (group_id,user_id,group_leader,user_pending) VALUES ('2','$new_user_id','0','0')";
  557. @mysql_query($new_query_insert);
  558. ################ FORUM INTEGRATION
  559. if(isset($_REQUEST['userFrndId'])) {
  560. $group = $_REQUEST['userType'];
  561. $frnd_id = base64_decode($_REQUEST['userFrndId']);
  562. $noOfFrndUsr = mysql_num_rows(mysql_query("select * from user_friends where user_id=".$id));
  563. $noFrnd = mysql_num_rows(mysql_query("select * from user_friends where user_id=".$frnd_id));
  564. $frnd_qry = mysql_query("INSERT INTO `user_friends` ( `id` , `user_id`,`friend_id`, `status` )VALUES ('',".$id.",".$frnd_id.",".($noOfFrndUsr+1).")") ;
  565. $frnd_qry = mysql_query("INSERT INTO `user_friends` ( `id` , `user_id`,`friend_id`, `status` )VALUES ('',".$frnd_id.",".$id.",".($noFrnd+1).")") ;
  566. }
  567. else
  568. $group = $this->data['User']['group_id'];
  569. $dob = $_REQUEST['year']."-".$_REQUEST['mon']."-".$_REQUEST['dob'];
  570. $gender=$_REQUEST['sex'];
  571. $city=$_REQUEST['city'];
  572. $state=$_REQUEST['province'];
  573. $country=$_REQUEST['country'];
  574. $qry = "INSERT INTO `user_details` ( `id` , `user_id`, `first_name`, `last_name`, `email`, `dob`,gender,city,state,c_id)VALUES ('',".$id.",'".$fname."','".$lname."','".$email."', '".$dob."','".$gender."','".$city."','".$state."','".$country."')" ;
  575. if($res = mysql_query($qry)) {
  576. $this->Session->write('User', $this->data['User']['username']);
  577. $this->Session->write('UserId', $id);
  578. $this->Session->write('GrpId', $this->data['User']['user_group_master_id']);
  579. //$this->flash('User has been saved.','/users');
  580. ########################## AUCTION INVITATION OPERATION #######
  581. if(isset($_SESSION['auctKey']))
  582. $this->auctInviteoperation() ;
  583. ############################# /AUCTION INVITATION OPERATION #######
  584. $this->sendVerifyemail();
  585. $this->redirect('/users/congratulations?id='.time().'&uid='.base64_encode($id).'&sessid='.session_id());
  586. }
  587. else {
  588. $id = mysql_insert_id();
  589. $this->Session->write('User', $this->data['User']['username']);
  590. $this->Session->write('UserId', $id);
  591. }
  592. if(isset($_REQUEST['act_event']) && $_REQUEST['act_event'] != "") {
  593. //echo $_REQUEST['act_event'].", ".$_REQUEST['evtid'].", ".$_REQUEST['invitation'];
  594. $link = 'calendars/acceptinvitation?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evtid'].'&invitation='.$_REQUEST['invitation'];
  595. $this->redirect($link);
  596. }
  597. else if(isset($_REQUEST['act']) && $_REQUEST['act'] == "activityinvite") {
  598. $link = 'calendars/showactivity?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evtid'].'&invitation='.$_REQUEST['invitation'];
  599. $this->redirect($link);
  600. }
  601. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "sharecal") {
  602. $checkCalIm = mysql_num_rows(mysql_query("select * from calendar_import where importer_id=".$someone['User']['id']." and import_cal_id=".base64_decode($_REQUEST['calid'])));
  603. if($checkCalIm<1) {
  604. $qry = "insert into calendar_import values(".base64_decode($_REQUEST['calid']).", ".$someone['User']['id'].", 'y')";
  605. $res = mysql_query($qry);
  606. }
  607. $link = 'users/user_home?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.base64_encode(1);
  608. $this->redirect($link);
  609. }
  610. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "eventinvite") {
  611. $link = 'calendars/acceptinvitation?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evidVal'].'&invitation='.$_REQUEST['invitationVal'];
  612. $this->redirect($link);
  613. }
  614. else if(isset($_REQUEST['actVal']) && $_REQUEST['actVal'] == "activityinvite") {
  615. $link = 'calendars/showactivity?id='.time().'&uid='.base64_encode($someone['User']['id']).'&sessid='.'&evid='.$_REQUEST['evidVal'].'&invitation='.$_REQUEST['invitationVal'];
  616. $this->redirect($link);
  617. }
  618. else {
  619. //$this->sendVerifyemail();
  620. $this->flash('The username with id: '.$this->data['User']['username'].' has been submitted.', '/users');
  621. $this->redirect('/users/congratulations?id='.time().'&uid='.base64_encode($id).'&sessid='.session_id());
  622. }
  623. }
  624. }
  625. $currentuser = array('topleft'=>'event-photo-tab-top-left.gif','topmiddle'=>'eventphoto-tab_topmidsml','topright'=>'event-photo-tab-top-right.gif','midleft'=>'eventphoto-tab_leftmid','midbgcolur'=>'fafeff','midright'=>'eventphoto-tab_rightmid','bottomleft'=>'event-photo-tab-bottom-left.gif','bottommid'=>'eventphoto-tab_botmid','bottomright'=>'event-photo-tab-bottom-right.gif') ;
  626. if(isset($_REQUEST['gr']) && base64_decode($_REQUEST['gr'])==2)
  627. $currentuser = array('topleft'=>'sponsor-tab-top-left.gif','topmiddle'=>'sponsor-tab_topmidsml','topright'=>'sponsor-tab-top-right.gif','midleft'=>'sponsor-tab_leftmid','midbgcolur'=>'fff6f6','midright'=>'sponsor-tab_rightmid','bottomleft'=>'sponsor-tab-bottom-left.gif','bottommid'=>'sponsor-tab_botmid','bottomright'=>'sponsor-tab-bottom-right.gif') ;
  628. if(isset($_REQUEST['gr']) && base64_decode($_REQUEST['gr'])==3)
  629. $currentuser = array('topleft'=>'tickets-tab-top-left.gif','topmiddle'=>'ticket-tab_topmidsml','topright'=>'tickets-tab-top-right.gif','midleft'=>'ticket-tab_leftmid','midbgcolur'=>'fdfff4','midright'=>'ticket-tab_rightmid','bottomleft'=>'tickets-tab-bottom-left.gif','bottommid'=>'ticket-tab_botmid','bottomright'=>'tickets-tab-bottom-right.gif') ;
  630. $this->set('currentStyle', $currentuser);
  631. }
  632. ################################## USERS PROFILE PAGE #####################
  633. function myprofile($userid=null) {
  634. $this->pageTitle = 'Profile';
  635. $this->layout = 'default';
  636. $this->checkSession();
  637. $userid = $_REQUEST['uid'];
  638. if($userid)
  639. $uid = base64_decode($userid);
  640. else
  641. $uid = $_SESSION['UserId'];
  642. $this->set('userprofileId',$uid) ;
  643. $this->data = $this->User->UserDetails->findByUserId($uid);
  644. $this->set('profiledetail',$this->data);
  645. }
  646. function social() {
  647. $this->layout = 'profile_blank';
  648. }
  649. function professional() {
  650. $this->layout = 'profile_blank';
  651. }
  652. function personalinfo() {
  653. $this->layout = 'profile_blank';
  654. }
  655. ###########################################################################
  656. function user_home() {
  657. $this->pageTitle = 'User Home';
  658. //$this->checkSession();
  659. $this->layout = 'userprofilevisit';
  660. $this->userProfileLeftPanel();
  661. $profilehomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($this->profileUserIdforQry)."&sessid=".session_id()."";
  662. $this->set('profilehomelink',$profilehomelink);
  663. //$someone = $this->User->findById($_SESSION['UserId']);
  664. ##################### Insert the recored for profile allingment #########
  665. if(isset($_SESSION['UserId'])) {
  666. $liitem=array('firstlist_1','firstlist_2','firstlist_3','firstlist_4','firstlist_5','firstlist_8','firstlist_9');
  667. $liitem2=array('secondlist_1','secondlist_2','secondlist_3','secondlist_4','secondlist_5','secondlist_6');
  668. if($_SESSION['GrpId']==2) /// Photographer
  669. array_push($liitem,'firstlist_6');
  670. if($_SESSION['GrpId']==3) /// Organisation
  671. array_push($liitem,'firstlist_7');
  672. $stleftpos=1;
  673. $strightpos=1;
  674. $maxLeftposition = "SELECT MAX(boxorder) as leftpos from profilemap where userid='".$_SESSION['UserId']."' and position='left'" ;
  675. $maxLeftposition_res = mysql_query($maxLeftposition);
  676. if(mysql_num_rows($maxLeftposition_res)>0) {
  677. $maxLeftposition_arr =mysql_fetch_array($maxLeftposition_res);
  678. $stleftpos = $maxLeftposition_arr['leftpos'];
  679. }
  680. $maxLeftposition = "SELECT MAX(boxorder) as rightpos from profilemap where userid='".$_SESSION['UserId']."' and position='right'" ;
  681. $maxLeftposition_res = mysql_query($maxLeftposition);
  682. if(mysql_num_rows($maxLeftposition_res)>0) {
  683. $maxLeftposition_arr =mysql_fetch_array($maxLeftposition_res);
  684. $strightpos = $maxLeftposition_arr['rightpos'];
  685. }
  686. foreach($liitem as $liitem_item=>$liitem_value) {
  687. $profilesql = "SELECT * from profilemap where boxname='".$liitem_value."' and userid='".$_SESSION['UserId']."'";
  688. $profilesql_res = mysql_query($profilesql);
  689. if(mysql_num_rows($profilesql_res)==0) {
  690. $stleftpos++;
  691. $insertleftinfo = "INSERT INTO profilemap SET boxname='".$liitem_value."' ,userid='".$_SESSION['UserId']."',display='block',position='left',boxorder='".$stleftpos."',boxid='".$stleftpos."' ";
  692. mysql_query($insertleftinfo);
  693. }
  694. }
  695. foreach($liitem2 as $liitem_item=>$liitem_value) {
  696. $profilesql = "SELECT * from profilemap where boxname='".$liitem_value."' and userid='".$_SESSION['UserId']."'";
  697. $profilesql_res = mysql_query($profilesql);
  698. if(mysql_num_rows($profilesql_res)==0) {
  699. $strightpos++;
  700. $insertleftinfo = "INSERT INTO profilemap SET boxname='".$liitem_value."' ,userid='".$_SESSION['UserId']."',display='block',position='right',boxorder='".$strightpos."',boxid='".$strightpos."' ";
  701. mysql_query($insertleftinfo);
  702. }
  703. }
  704. ##################### Insert the recored for profile allingment #########
  705. }
  706. if(isset($_REQUEST['uid'])) {
  707. $uid = base64_decode($_REQUEST['uid']);
  708. $mail = mysql_query("select * from emails where user_id=".$uid." and inbox_status='unread'");
  709. if($mail) {
  710. $mailQry = mysql_num_rows($mail);
  711. $this->set('mails', $mailQry);
  712. }
  713. if(empty($this->data)) {
  714. $this->data = $this->User->UserDetails->read(null, $uid);
  715. $this->set('user_det',$this->data);
  716. }
  717. }
  718. else {
  719. $this->redirect('../index');
  720. }
  721. $this->createStuffArray();
  722. $this->getMyComments($this->PROFILE_USER_ID);
  723. }
  724. function postcomment() {
  725. mysql_query("INSERT INTO user_comments(user_id,friend_id,comment) VALUES('".$this->params['form']['profileid']."','".$_SESSION['UserId']."','".mysql_escape_string($this->params['form']['comment'])."')");
  726. $this->getMyComments($this->params['form']['profileid']);
  727. $this->render("usercomment","ajax");
  728. }
  729. function congratulations() {
  730. $this->checkSession(1);
  731. $this->pageTitle = 'Invite Friend';
  732. $this->layout = 'userloggedin';
  733. $someone = $this->User->findById($_SESSION['UserId']);
  734. $this->set('firstname',$someone['UserDetails']['first_name']);
  735. $this->set('lasttname',$someone['UserDetails']['last_name']);
  736. /*if(empty($this->data))
  737. {
  738. $this->data = $this->User->read(null, $id);
  739. $this->set('data',$this->data);
  740. }*/
  741. }
  742. /**/
  743. /* function loading()
  744. {
  745. }
  746. */ function logout() {
  747. //$this->layout = 'default';
  748. //$this->session->delete('Admin');
  749. //$this->session->delete('Admin_id');
  750. unset($_SESSION);
  751. $this->Session->destroy();
  752. $this->Session->destroy('User');
  753. $this->Session->destroy('UserId');
  754. $this->redirect('/');
  755. /*if(session_destroy())
  756. $this->redirect('users/home');
  757. else
  758. $this->flash('session destruction unsuccessfull.','/users/home');*/
  759. }
  760. function forgotPass() {
  761. $this->layout = 'default';
  762. echo $_REQUEST['msg'];
  763. $this->set('data',$_REQUEST['msg']);
  764. }
  765. function forgotPassword() {
  766. /*$this->layout = 'default';
  767. echo $_REQUEST['msg'];
  768. $this->set('data',$_REQUEST['msg']);*/
  769. $this->render('forgotpassview', 'ajax');
  770. }
  771. function my_photo() {
  772. $this->checkSession();
  773. $this->layout = 'userloggedin';
  774. $this->pageTitle = 'My Photo';
  775. }
  776. /*function myphoto_top_old()
  777. {
  778. $this->checkSession();
  779. $this->layout = 'userloggedin';
  780. $this->pageTitle = 'My Friend Top';
  781. }
  782. */
  783. function sendinvite() {
  784. $this->checkSession();
  785. $this->layout = 'userloggedin';
  786. $someone = $this->User->findById($_SESSION['UserId']);
  787. $this->set('invitedGrp',$someone['User']['user_group_master_id']);
  788. $this->set('inviterId',$someone['User']['id']);
  789. $FriendInviteUrl = "http://www.xoimages.com/users/signup?id=".time()."&gr=".base64_encode($someone['User']['user_group_master_id'])."&sessid=".session_id()."&task=invite&taskbyId=".base64_encode($someone['User']['id'])."";
  790. $this->set('inviteMailUrl','<a href="'.$FriendInviteUrl.'">Click Here</a>');
  791. }
  792. ####################### TESTING##########
  793. function userprofile() {
  794. $this->checkSession();
  795. $this->layout = 'usertestprofile';
  796. $this->pageTitle = 'Edit Profile';
  797. $uid = $_SESSION['UserId'];
  798. ########################################### BASIC INFO #####################
  799. if(empty($this->data) || !empty($_SESSION['User'])) {
  800. if(isset($_REQUEST['pg']) && $_REQUEST['pg'] == "con") {
  801. $someone = $this->User->findById($uid);
  802. $this->Session->write('User', $someone['User']['username']);
  803. $this->Session->write('UserId', $someone['User']['id']);
  804. $this->data = $this->User->read(null, $uid);
  805. $this->set('data',$this->data);
  806. }
  807. else {
  808. $this->data = $this->User->read(null, $uid);
  809. $this->set('data',$this->data);
  810. }
  811. ########################################### BASIC INFO #####################
  812. }
  813. //Get Users payment Details
  814. $paymentInfo=$this->getPaymentMethodsUsers($_SESSION['UserId']);
  815. if(isset($paymentInfo['paypal_email']) && $paymentInfo['paypal_email']!='') {
  816. $this->set('paypalemailinfo' , $paymentInfo['paypal_email']) ;
  817. }
  818. if(isset($paymentInfo['gcheckout_email']) && $paymentInfo['gcheckout_email']!='') {
  819. $strgcheckout = $paymentInfo['gcheckout_email'] ;
  820. if(stristr($strgcheckout, 'break')) {
  821. $strgcheckoutexp = explode('break',$strgcheckout);
  822. $this->set('merchantId' , $strgcheckoutexp[0]) ;
  823. $this->set('merchantkey' , $strgcheckoutexp[1]) ;
  824. }
  825. if($strgcheckout!='')
  826. $this->set('gcheckoutinfo' , $paymentInfo['gcheckout_email']) ;
  827. }
  828. }
  829. function setpaypal() {
  830. $this->render("setpaypal","ajax");
  831. }
  832. function saveprofilebasic() {
  833. $this->checkSession();
  834. $this->set("postData",$this->params);
  835. $userInfo = $this->User->read(null,$_SESSION["UserId"]);
  836. $this->data['UserDetails']['id'] = $userInfo['UserDetails']['id'];
  837. $this->data['UserDetails']['user_id'] = $_SESSION['UserId'];
  838. $this->data['UserDetails']['first_name'] = addslashes($this->data['UserDetails']['first_name']);
  839. $this->data['UserDetails']['last_name'] = addslashes($this->data['UserDetails']['last_name']);
  840. $this->data['UserDetails']['gender'] = $_REQUEST['sex'];
  841. $this->data['UserDetails']['city'] = $_REQUEST['city'];
  842. $this->data['UserDetails']['state'] = $_REQUEST['province'];
  843. $this->data['UserDetails']['c_id'] = $_REQUEST['country'];
  844. $this->data['UserDetails']['dob'] = $_REQUEST['dob_Year'] .'-'.$_REQUEST['dob_Month'] .'-'.$_REQUEST['dob_Day'] ;
  845. $this->data['UserDetails']['mobile_phone'] = $this->data['UserDetails']['mobile_phone'];
  846. $this->data['UserDetails']['land_phone'] = $this->data['UserDetails']['land_phone'];
  847. $this->data['UserDetails']['address'] = $this->data['UserDetails']['address'];
  848. $this->data['UserDetails']['state'] = $_REQUEST['province'];
  849. $this->data['UserDetails']['city'] = $_REQUEST['city'];
  850. $this->data['UserDetails']['zip'] = $this->data['UserDetails']['zip'];
  851. if ($this->User->UserDetails->save($this->data)) {
  852. $this->flash('Your post has been Updated.','/users');
  853. $link = 'users/userprofile?basicsave=1#basic';
  854. }
  855. else
  856. $link = 'users/userprofile#basic';
  857. $this->redirect($link);
  858. }
  859. function saveschool() {
  860. $this->checkSession();
  861. $this->set("postData",$this->params);
  862. $userInfo = $this->User->read(null,$_SESSION["UserId"]);
  863. $this->data['UserDetails']['id'] = $userInfo['UserDetails']['id'];
  864. $this->data['UserDetails']['user_id'] = $_SESSION['UserId'];
  865. $this->data['UserDetails']['school_id'] =$this->data['UserDetails']['school_id'];
  866. $this->data['UserDetails']['grade_level'] =$this->data['UserDetails']['grade_level'];
  867. $this->data['UserDetails']['student_year_from'] =$_REQUEST['student_year_from'];
  868. $this->data['UserDetails']['student_year_to'] =$_REQUEST['student_year_to'];
  869. if ($this->User->UserDetails->save($this->data)) {
  870. $this->flash('Your post has been Updated.','/users');
  871. $link = 'users/userprofile?schoolsave=1#school';
  872. }
  873. else
  874. $link = 'users/userprofile#school';
  875. $this->redirect($link);
  876. }
  877. function savepersonal() {
  878. $this->checkSession();
  879. $this->set("postData",$this->params);
  880. $userInfo = $this->User->read(null,$_SESSION["UserId"]);
  881. $this->data['UserDetails']['id'] = $userInfo['UserDetails']['id'];
  882. $this->data['UserDetails']['user_id'] = $_SESSION['UserId'];
  883. if ($this->User->UserDetails->save($this->data)) {
  884. $this->flash('Your post has been Updated.','/users');
  885. $link = 'users/userprofile?personalsave=1#personal';
  886. }
  887. else
  888. $link = 'users/userprofile#personal';
  889. $this->redirect($link);
  890. }
  891. function savework() {
  892. $this->checkSession();
  893. $this->set("postData",$this->params);
  894. $userInfo = $this->User->read(null,$_SESSION["UserId"]);
  895. $this->data['UserDetails']['id'] = $userInfo['UserDetails']['id'];
  896. $this->data['UserDetails']['user_id'] = $_SESSION['UserId'];
  897. $this->data['UserDetails']['user_time'] = $_REQUEST['emp_mon'].'-'.$_REQUEST['emp_year'];
  898. if ($this->User->UserDetails->save($this->data)) {
  899. $this->flash('Your post has been Updated.','/users');
  900. $link = 'users/userprofile?worksave=1#work';
  901. }
  902. else
  903. $link = 'users/userprofile#work';
  904. $this->redirect($link);
  905. }
  906. function savenewpassword() {
  907. $this->checkSession();
  908. $id = $_SESSION['UserId'];
  909. if (empty($this->data)) {
  910. $this->data = $this->User->findById($id);
  911. }
  912. else {
  913. $this->User->id = $this->Session->read('UserId');
  914. $uid = $this->User->findById($this->User->id);
  915. if(base64_encode($this->data['User']['old_password'])!= $uid['User']['password']) {
  916. $this->redirect("users/userprofile?save=2&msg=Your old Password field didn't match#password");
  917. }
  918. else {
  919. if($this->data['User']['new_password'] != $this->data['User']['confirm_password'] ) {
  920. $this->redirect('users/userprofile?save=2&msg=New password and Confirm password field do not match#password');
  921. }
  922. else {
  923. $this->data['User']['password'] = base64_encode($this->data['User']['new_password']);
  924. $this->data['User']['id'] = $this->User->id;
  925. if($this->User->save($this->data)) {
  926. $updatesql = "UPDATE phpbb_users SET user_pass_convert='".$this->data['User']['password']."' WHERE username='".$uid['User']['username']."'";
  927. @mysql_query($sql1);
  928. $this->redirect('users/userprofile?passwordsave=1#password');
  929. }
  930. }
  931. }
  932. }
  933. }
  934. function savecompanyinfo() {
  935. $this->checkSession();
  936. $this->set("postData",$this->params);
  937. $userInfo = $this->User->read(null,$_SESSION["UserId"]);
  938. $this->data['UserDetails']['id'] = $userInfo['UserDetails']['id'];
  939. $this->data['UserDetails']['user_id'] = $_SESSION['UserId'];
  940. $this->data['UserDetails']['company_description'] = strip_html_tags($this->data['UserDetails']['company_description']);
  941. $this->data['UserDetails']['comp_name'] = strip_html_tags($this->data['UserDetails']['org_name']);
  942. ################### Company logo image ###############
  943. if(isset($_FILES['logoimage']['name']) && $_FILES['logoimage']['name']!='') {
  944. $fileName=time().$_FILES['logoimage']['name'];
  945. $broucherfile = $fileName ;
  946. $destination = "../app/webroot/company_logo/".$fileName;
  947. $result=move_uploaded_file($_FILES['logoimage']['tmp_name'],$destination);
  948. $this->data['UserDetails']['company_logo'] = $fileName;
  949. }
  950. #####################################################
  951. if ($this->User->UserDetails->save($this->data)) {
  952. $this->flash('Your post has been Updated.','/users');
  953. $link = 'users/userprofile?companysave=1#company';
  954. }
  955. else
  956. $link = 'users/userprofile#company';
  957. $this->redirect($link);
  958. }
  959. function deletecompanyimage() {
  960. $updatesql = "UPDATE user_details SET company_logo='' where user_id='".$_SESSION['UserId']."'";
  961. mysql_query($updatesql);
  962. $link = 'users/userprofile#company';
  963. $this->redirect($link);
  964. }
  965. ########################################
  966. function profile() {
  967. $this->checkSession();
  968. ############################### INTRODUCE THE NEW PROFILE PAGE ##################
  969. $this->redirect('users/userprofile');
  970. #############################
  971. //$this->layout = 'userloggedin';
  972. $this->layout = 'userloggedin_profile';
  973. $_SESSION['PARAM'] = '47897897897897225286';
  974. //$this->checkSession();
  975. $this->pageTitle = 'User Profile';
  976. if(isset($_REQUEST['uid']))
  977. $uid = base64_decode($_REQUEST['uid']);
  978. if(empty($this->data) || !empty($_SESSION['User'])) {
  979. //echo "test";exit();
  980. if(isset($_REQUEST['pg']) && $_REQUEST['pg'] == "con") {
  981. //echo "test1";exit();
  982. $someone = $this->User->findById($uid);
  983. $this->Session->write('User', $someone['User']['username']);
  984. $this->Session->write('UserId', $someone['User']['id']);
  985. //$this->data['UserDetails']['id'] = $this->data['User']['userId'];
  986. //$this->data['UserDetails']['user_id'] = base64_decode($_REQUEST['uid']);
  987. //if ($this->User->UserDetails->save($this->data))
  988. //{
  989. $this->data = $this->User->read(null, $uid);
  990. $this->set('data',$this->data);
  991. //}
  992. }
  993. else {
  994. $this->data = $this->User->read(null, $uid);
  995. $this->set('data',$this->data);
  996. }
  997. }
  998. else if(!empty($this->data)) {
  999. //pr($this->data);exit();
  1000. $this->data['UserDetails']['id'] = $this->data['User']['userId'];
  1001. $this->data['UserDetails']['user_id'] = base64_decode($_REQUEST['uid']);
  1002. $this->data['UserDetails']['first_name'] = addslashes($this->data['UserDetails']['first_name']);
  1003. $this->data['UserDetails']['last_name'] = addslashes($this->data['UserDetails']['last_name']);
  1004. $this->data['UserDetails']['gender'] = $_REQUEST['sex'];
  1005. $this->data['UserDetails']['city'] = $_REQUEST['city'];
  1006. $this->data['UserDetails']['state'] = $_REQUEST['province'];
  1007. $this->data['UserDetails']['c_id'] = $_REQUEST['country'];
  1008. if ($this->User->UserDetails->save($this->data)) {
  1009. $this->flash('Your post has been Updated.','/users');
  1010. $link = '/users/profile?id='.time().'&uid='.base64_encode($this->data['User']['userId']).'&sessid='.base64_encode(1).'&act=edit';
  1011. $this->redirect($link);
  1012. }
  1013. }
  1014. }
  1015. function school() {
  1016. $this->checkSession();
  1017. $this->layout = 'profile_blank';
  1018. $this->pageTitle = 'User School';
  1019. if(isset($_REQUEST['uid']))
  1020. $uid = base64_decode($_REQUEST['uid']);
  1021. if(empty($this->data) || $_REQUEST['act'] == "edit") {
  1022. $this->data = $this->User->read(null, $uid);
  1023. $this->set('data',$this->data);
  1024. }
  1025. else if($_REQUEST['act'] != "edit") {
  1026. $this->data['UserDetails']['id'] = $this->data['User']['userId'];
  1027. $this->data['UserDetails']['user_id'] = base64_decode($_REQUEST['uid']);
  1028. //pr($this->data);exit();
  1029. if ($this->User->UserDetails->save($this->data)) {
  1030. $this->flash('Your post has been Updated.','/users');
  1031. $link = '/users/school?id='.time().'&uid='.base64_encode($this->data['User']['userId']).'&sessid='.base64_encode(1).'&act=edit';
  1032. $this->redirect($link);
  1033. }
  1034. }
  1035. }
  1036. function work() {
  1037. $this->checkSession();
  1038. $this->layout = 'profile_blank';
  1039. $this->pageTitle = 'User Work';
  1040. if(isset($_REQUEST['uid']))
  1041. $uid = base64_decode($_REQUEST['uid']);
  1042. if(empty($this->data) || $_REQUEST['act'] == "edit") {
  1043. $this->data = $this->User->read(null, $uid);
  1044. $this->set('data',$this->data);
  1045. }
  1046. else if($_REQUEST['act'] != "edit") {
  1047. $this->data['UserDetails']['id'] = $this->data['User']['userId'];
  1048. $this->data['UserDetails']['user_id'] = base64_decode($_REQUEST['uid']);
  1049. $this->data['UserDetails']['user_time'] = $_REQUEST['emp_mon']."-".$_REQUEST['emp_year'];
  1050. //pr($this->data);exit();
  1051. if ($this->User->UserDetails->save($this->data)) {
  1052. $this->flash('Your post has been Updated.','/users');
  1053. $link = '/users/work?id='.time().'&uid='.base64_encode($this->data['User']['userId']).'&sessid='.base64_encode(1).'&act=edit';
  1054. $this->redirect($link);
  1055. }
  1056. }
  1057. }
  1058. function personal() {
  1059. $this->checkSession();
  1060. $this->layout = 'profile_blank';
  1061. $this->pageTitle = 'User Personal';
  1062. if(isset($_REQUEST['uid']))
  1063. $uid = base64_decode($_REQUEST['uid']);
  1064. if(empty($this->data) || $_REQUEST['act'] == "edit") {
  1065. $this->data = $this->User->read(null, $uid);
  1066. $this->set('data',$this->data);
  1067. }
  1068. else if($_REQUEST['act'] != "edit") {
  1069. $this->data['UserDetails']['id'] = $this->data['User']['userId'];
  1070. $this->data['UserDetails']['user_id'] = base64_decode($_REQUEST['uid']);
  1071. if ($this->User->UserDetails->save($this->data)) {
  1072. $this->flash('Your post has been Updated.','/users');
  1073. $link = '/users/profile?id='.time().'&uid='.base64_encode($this->data['User']['userId']).'&sessid='.base64_encode(1).'&act=edit';
  1074. $this->redirect($link);
  1075. }
  1076. }
  1077. }
  1078. function projects() {
  1079. $this->checkSession();
  1080. $this->layout = 'profile_blank';
  1081. $this->pageTitle = 'User Projects';
  1082. if(isset($_REQUEST['uid']))
  1083. $uid = base64_decode($_REQUEST['uid']);
  1084. if(empty($this->data) || $_REQUEST['act'] == "edit") {
  1085. $this->data = $this->User->read(null, $uid);
  1086. $this->set('data',$this->data);
  1087. }
  1088. else if($_REQUEST['act'] != "edit") {
  1089. $this->data['UserDetails']['id'] = $this->data['User']['userId'];
  1090. $this->data['UserDetails']['user_id'] = base64_decode($_REQUEST['uid']);
  1091. if ($this->User->UserDetails->save($this->data)) {
  1092. $this->flash('Your post has been Updated.','/users');
  1093. $link = '/users/profile?id='.time().'&uid='.base64_encode($this->data['User']['userId']).'&sessid='.base64_encode(1).'&act=edit';
  1094. $this->redirect($link);
  1095. }
  1096. }
  1097. }
  1098. function change_pwd() {
  1099. $this->checkSession();
  1100. $this->layout = 'profile_blank';
  1101. $this->pageTitle = 'User Change Pwd';
  1102. if(isset($_REQUEST['uid']))
  1103. $uid = base64_decode($_REQUEST['uid']);
  1104. if(empty($this->data) || $_REQUEST['act'] == "edit") {
  1105. $this->data = $this->User->read(null, $uid);
  1106. $this->set('data',$this->data);
  1107. }
  1108. else {
  1109. $this->data['User']['id'] = base64_decode($_REQUEST['uid']);
  1110. if ($this->User->save($this->data)) {
  1111. $this->flash('Your post has been Updated.','/users');
  1112. $link = '/users/signup?id='.time().'&uid='.base64_encode($this->data['User']['userId']).'&sessid='.base64_encode(1);
  1113. $this->redirect($link);
  1114. }
  1115. else
  1116. $this->flash('Not updated.','/users/signup');
  1117. }
  1118. }
  1119. function custom_profile() {
  1120. $this->checkSession();
  1121. $this->layout = 'profile_blank';
  1122. $this->pageTitle = 'User Customize Profile';
  1123. if(isset($_REQUEST['uid']))
  1124. $uid = base64_decode($_REQUEST['uid']);
  1125. if(empty($this->data) || $_REQUEST['act'] == "edit") {
  1126. $this->data = $this->User->read(null, $uid);
  1127. $this->set('data',$this->data);
  1128. }
  1129. //$this->set('profilePath', $_SERVER['REQUEST_URI']);
  1130. }
  1131. function myaccount() {
  1132. $this->checkSession();
  1133. $this->layout = 'user_signup';
  1134. $this->pageTitle = 'My Account';
  1135. if(isset($_SESSION['UserId']))
  1136. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1137. else
  1138. $userhomelink='javascript:history.back()';
  1139. $profilehomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($this->profileUserIdforQry)."&sessid=".session_id()."";
  1140. $this->set('userhomelink',$userhomelink);
  1141. $this->set('profilehomelink',$profilehomelink);
  1142. ####################################################### USER RELATED INFORMATOION
  1143. $userInformation = "SELECT CONCAT_WS(' ',user_details.first_name,user_details.last_name) as fullname , user_details.email ,users.user_group_master_id ,(SELECT DATE_FORMAT(users.user_join_date,GET_FORMAT(DATE,'USA'))) as sinceJOIN ,user_details.comp_name,
  1144. user_payment_setup.paypal_email , user_payment_setup.gcheckout_email
  1145. FROM user_details
  1146. LEFT JOIN users on(user_details.user_id = users.id)
  1147. LEFT JOIN user_payment_setup on (user_details.user_id=user_payment_setup.user_id)
  1148. where user_details.user_id='".$_SESSION['UserId']."'";
  1149. $userInformation_res = mysql_query($userInformation);
  1150. $userInformation_arr = mysql_fetch_array($userInformation_res);
  1151. $this->set('profilename',ucfirst($userInformation_arr['fullname']));
  1152. $this->set('profileemail',$userInformation_arr['email']);
  1153. $this->set('profilegroupid',$userInformation_arr['user_group_master_id']);
  1154. $this->set('profilejoin',$userInformation_arr['sinceJOIN']);
  1155. $this->set('profilpaypalemail',$userInformation_arr['paypal_email']);
  1156. $gprofileid = explode('break',$userInformation_arr['gcheckout_email']);
  1157. if(isset($gprofileid['0']))
  1158. $this->set('profilGmerchantID',$gprofileid['0']);
  1159. if(isset($gprofileid['1']))
  1160. $this->set('profilGmerchantKey',$gprofileid['1']);
  1161. $this->set('profilbusiness',ucfirst($userInformation_arr['comp_name']));
  1162. //Get the payment details
  1163. $getTotalPayment="
  1164. SELECT sum(amount * if(DrCr = '+1',1,-1)) totalPaymentAmount, amount, DrCr
  1165. FROM xouser_transaction_details
  1166. WHERE user_id = '".$_SESSION['UserId']."'
  1167. GROUP BY user_id";
  1168. $queryGetTotalPayment=mysql_fetch_assoc(mysql_query($getTotalPayment));
  1169. $this->set("totalPaymentAmount",$queryGetTotalPayment['totalPaymentAmount']);
  1170. ####################################################### USER RELATED INFORMATOION
  1171. ############################ Related activity ####################################
  1172. $accountrelatedsql = "SELECT IF (xotrandetail.DrCr = '+1', 'From', 'To') AS tranfromto,IF (xotrandetail.payment_to =1, 'admin', users.username) AS tranName, (SELECT DATE_FORMAT( xotran.transaction_date, GET_FORMAT( DATE, 'USA' ) )) AS trandate, xotrandetail.id, xotrandetail.amount AS tranfee,
  1173. xotrandetail.amount as tranAmount , xotran.transaction_head ,IF(xotrandetail.DrCr = '+1',1,-1) AS sumoperation
  1174. FROM xouser_transaction_details xotrandetail
  1175. LEFT JOIN users ON ( xotrandetail.payment_to = users.id )
  1176. LEFT JOIN xouser_transactions xotran ON ( xotrandetail.xouser_transaction_id = xotran.id )
  1177. WHERE xotrandetail.user_id='".$_SESSION['UserId']."'
  1178. order By xotrandetail.id desc
  1179. LIMIT 10
  1180. " ;
  1181. $accountrelatedsql_res = mysql_query($accountrelatedsql);
  1182. $accountrelatedsql_num = mysql_num_rows($accountrelatedsql_res);
  1183. $this->set('Numrelatedquery',$accountrelatedsql_num);
  1184. $relatedarr = array();
  1185. while($accountrelatedsql_array=mysql_fetch_array($accountrelatedsql_res)) {
  1186. $relatedarr[] = array('id'=>$accountrelatedsql_array['id'] , 'tranfromto'=>$accountrelatedsql_array['tranfromto'] ,'tranName'=>$accountrelatedsql_array['tranName'] ,'trandate'=>$accountrelatedsql_array['trandate'],'tranfee'=>$accountrelatedsql_array['tranfee'],'tranAmount'=>$accountrelatedsql_array['tranAmount'],'sumoperation'=>$accountrelatedsql_array['sumoperation']);
  1187. }
  1188. $this->set('relatedInfo',$relatedarr);
  1189. ############################ Related activity ####################################
  1190. }
  1191. function myaccounthistory() {
  1192. $this->checkSession();
  1193. $this->layout = 'user_signup';
  1194. ####################################################### USER RELATED INFORMATOION
  1195. $userInformation = "SELECT CONCAT_WS(' ',user_details.first_name,user_details.last_name) as fullname , user_details.email ,users.user_group_master_id ,(SELECT DATE_FORMAT(users.user_join_date,GET_FORMAT(DATE,'USA'))) as sinceJOIN ,user_details.comp_name,
  1196. user_payment_setup.paypal_email , user_payment_setup.gcheckout_email
  1197. FROM user_details
  1198. LEFT JOIN users on(user_details.user_id = users.id)
  1199. LEFT JOIN user_payment_setup on (user_details.user_id=user_payment_setup.user_id)
  1200. where user_details.user_id='".$_SESSION['UserId']."'";
  1201. $userInformation_res = mysql_query($userInformation);
  1202. $userInformation_arr = mysql_fetch_array($userInformation_res);
  1203. $this->set('profilename',ucfirst($userInformation_arr['fullname']));
  1204. $this->set('profileemail',$userInformation_arr['email']);
  1205. $this->set('profilegroupid',$userInformation_arr['user_group_master_id']);
  1206. $this->set('profilejoin',$userInformation_arr['sinceJOIN']);
  1207. $this->set('profilpaypalemail',$userInformation_arr['paypal_email']);
  1208. $gprofileid = explode('break',$userInformation_arr['gcheckout_email']);
  1209. if(isset($gprofileid['0']))
  1210. $this->set('profilGmerchantID',$gprofileid['0']);
  1211. if(isset($gprofileid['1']))
  1212. $this->set('profilGmerchantKey',$gprofileid['1']);
  1213. $this->set('profilbusiness',ucfirst($userInformation_arr['comp_name']));
  1214. // total_commission
  1215. $sql=" SELECT sum(commission) AS total_commission
  1216. FROM payment_transactions
  1217. WHERE seller_id='".$_SESSION['UserId']."' AND pay_status='1' ";
  1218. $result=mysql_fetch_assoc(mysql_query($sql));
  1219. $total_commission = $result['total_commission'];
  1220. // total_commission_received
  1221. $sql=" SELECT sum(total_amount) AS total_commission_received
  1222. FROM payment_transactions
  1223. WHERE receiver_id='".$_SESSION['UserId']."' AND pay_status='1' AND type_id='2' ";//type='2':paid commision
  1224. $result=mysql_fetch_assoc(mysql_query($sql));
  1225. $total_commission_received = $result['total_commission_received'];
  1226. $this->set("total_commission_unreceived",$total_commission-$total_commission_received);
  1227. //get creative commission minimum
  1228. $config = $this->getConfigAmount('creative commission minimum');
  1229. $this->set('commission_minimum',$config['config_value']);
  1230. ####################################################### USER RELATED INFORMATOION
  1231. $pagehead='My Account';
  1232. $urlshow='full';
  1233. if(isset($_REQUEST['show']) && $_REQUEST['show']=='sent') {
  1234. $pagehead = 'Payment Sent';
  1235. $urlshow='sent';
  1236. $extradd = " AND PM.user_id='".$_SESSION['UserId']."' ";
  1237. }else if(isset($_REQUEST['show']) && $_REQUEST['show']=='received') {
  1238. $pagehead = 'Payments received';
  1239. $urlshow='received';
  1240. $extradd = " AND (PM.receiver_id='".$_SESSION['UserId']."' OR PM.seller_id='".$_SESSION['UserId']."' ) ";
  1241. }else{//full
  1242. $pagehead = 'All Account Activity';
  1243. $extradd = " AND (PM.user_id='".$_SESSION['UserId']."' OR PM.receiver_id='".$_SESSION['UserId']."' OR PM.seller_id='".$_SESSION['UserId']."' ) ";
  1244. }
  1245. $this->pageTitle = $pagehead;
  1246. $this->set('pageHead',$pagehead);
  1247. $this->set('pageType',$urlshow);
  1248. $this->set('userId',$_SESSION['UserId']);
  1249. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1250. $profilehomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($this->profileUserIdforQry)."&sessid=".session_id()."";
  1251. $this->set('userhomelink',$userhomelink);
  1252. $this->set('profilehomelink',$profilehomelink);
  1253. $this->set('urlpayout',PAYMENT_REQUEST_PAYOUT_URL.'/'.$_SESSION['UserId'].'/'.md5(PAYMENT_KEY));
  1254. $select = "SELECT PM.*,
  1255. IF (PM.user_id='".$_SESSION['UserId']."', 'To', 'From') AS tranfromto,
  1256. IF (PM.user_id =1, 'admin', US1.username) AS payer,
  1257. IF (PM.receiver_id =1, 'admin', US2.username) AS receiver,
  1258. IF (PM.seller_id =1, 'admin', US3.username) AS seller,
  1259. IF (PM.user_id='".$_SESSION['UserId']."', 0.00, PM.commission) AS commission
  1260. ";
  1261. $from = "FROM payment_transactions as PM
  1262. LEFT JOIN users US1 ON ( PM.user_id = US1.id )
  1263. LEFT JOIN users US2 ON ( PM.receiver_id = US2.id )
  1264. LEFT JOIN users US3 ON ( PM.seller_id = US3.id ) ";
  1265. $where = "WHERE PM.pay_status='1' ".$extradd;
  1266. ################# SEARCH CRITERIA ########
  1267. if(isset($_REQUEST['serachtype']) && $_REQUEST['serachtype']=='within') {
  1268. $withinType=$this->data['User']['within'];
  1269. $week=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),(date("d")-7),date("Y")));
  1270. $month=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),(date("m")-1),date("d"),date("Y")));
  1271. $year=date("Y-m-d G:i:s",mktime(date("G"),date("i"),date("s"),date("m"),date("d"),(date("Y")-1)));
  1272. $date=date("Y-m-d G:i:s");
  1273. if($this->data['User']['within']=="past") {
  1274. $curDate=$date;
  1275. $this->set("curDate",$curDate);
  1276. }
  1277. if($this->data['User']['within']=="week") {
  1278. $past=$week;
  1279. $curDate=$date;
  1280. $this->set("past",$past);
  1281. $this->set("curDate",$curDate);
  1282. }
  1283. if($this->data['User']['within']=="month") {
  1284. $past=$month;
  1285. $curDate=$date;
  1286. $this->set("past",$past);
  1287. $this->set("curDate",$curDate);
  1288. }
  1289. if($this->data['User']['within']=="year") {
  1290. $past=$year;
  1291. $curDate=$date;
  1292. $this->set("past",$past);
  1293. $this->set("curDate",$curDate);
  1294. }
  1295. }
  1296. if(isset($_REQUEST['serachtype']) && $_REQUEST['serachtype']=='daterange') {
  1297. $this->set("past");
  1298. $past=0;
  1299. $curDate=0;
  1300. $this->set("curDate");
  1301. $fromDate=$_REQUEST['frmyear']."-".$_REQUEST['frmmonth']."-".$_REQUEST['frmday'];
  1302. $len=strlen($fromDate);
  1303. if($len==10) {
  1304. $dateF=date("Y-m-d",strtotime($fromDate));
  1305. $past=$dateF;
  1306. $this->set("past",$past);
  1307. }
  1308. else {
  1309. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1310. }
  1311. $toDate=$_REQUEST['toyear']."-".$_REQUEST['tomonth']."-".$_REQUEST['todate'];
  1312. $len=strlen($toDate);
  1313. if($len==10) {
  1314. $dateT=date("Y-m-d",strtotime($toDate));
  1315. $curDate=$dateT;
  1316. $this->set("curDate",$curDate);
  1317. }
  1318. else {
  1319. $this->set("dateErr","Date format should be : mm/dd/yyyy");
  1320. }
  1321. }
  1322. if(isset($this->params['url']['cdate']))
  1323. $curDate=$this->params['url']['cdate'];
  1324. if(isset($this->params['url']['past']))
  1325. $past=$this->params['url']['past'];
  1326. if(isset($_REQUEST['serachtype'])) {
  1327. if(isset($withinType) && $withinType=="past")
  1328. $where.=" AND PM.created < '".$curDate."'";
  1329. else
  1330. $where.=" AND PM.created BETWEEN '".$past."' AND '".$curDate."'";
  1331. }
  1332. if(isset($fDate) && $fDate!=0 && isset($tDate) && $tDate!=0)
  1333. $where.=" AND PM.created BETWEEN '".$fDate."' AND '".$tDate."'";
  1334. if(isset($_REQUEST['invoice']) && $_REQUEST['invoice']!=''){
  1335. $where.=" AND PM.invoice LIKE '%".$_REQUEST['invoice']."%' ";
  1336. }
  1337. ##########################################
  1338. //echo $select.$from.$where;
  1339. $others=" ORDER BY PM.created DESC";
  1340. $PassParameter="show=".$urlshow ;
  1341. if(isset($curDate))
  1342. $PassParameter.="&cdate=".$curDate."&";
  1343. if(isset($past))
  1344. $PassParameter.="&past=".$past."&";
  1345. if(isset($fDate))
  1346. $PassParameter.="&fd=".$fDate."&";
  1347. if(isset($tDate))
  1348. $PassParameter.="&td=".$tDate."&";
  1349. if(isset($_REQUEST['invoice']))
  1350. $PassParameter .= "&invoice=".$_REQUEST['invoice'];
  1351. if(isset($this->params['url']['serachtype']) || isset($_REQUEST['serachtype']))
  1352. $PassParameter.="&serachtype=".$radio."&";
  1353. $fltr='';
  1354. $CountField="PM.id";
  1355. $this->set("controller","users");
  1356. $this->set("action","myaccounthistory");
  1357. $this->set("parameter",$PassParameter);
  1358. $this->set("fltr",$fltr);
  1359. //echo $select.$from.$where.$others ;
  1360. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1361. $this->set("paymentMethods",$this->getPaymentMethods(1));
  1362. if(isset($this->params['url']['Page']) || (isset($fltr) && $fltr!="") || isset($_REQUEST['serachtype']) || isset($_REQUEST['invoice'])) {
  1363. $this->set('pagehead',$pagehead);
  1364. $this->render("myaccounthistory2","ajax");
  1365. }
  1366. }
  1367. //This is a common myPayment section
  1368. function mypayment() {
  1369. $this->redirect('/users/myaccounthistory');
  1370. $this->checkSession();
  1371. $this->layout = 'user_signup';
  1372. $this->pageTitle = 'My payment';
  1373. if(isset($_SESSION['UserId']))
  1374. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1375. else
  1376. $userhomelink='javascript:history.back()';
  1377. $profilehomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($this->profileUserIdforQry)."&sessid=".session_id()."";
  1378. $this->set('userhomelink',$userhomelink);
  1379. $this->set('profilehomelink',$profilehomelink);
  1380. //Get the payment details
  1381. $this->set("paymentMethods",$this->getPaymentMethods(1));
  1382. $select="SELECT XT. * , XTD. * ";
  1383. $from=" FROM xouser_transactions XT, xouser_transaction_details XTD ";
  1384. $where=" WHERE XT.id = XTD.xouser_transaction_id AND XTD.user_id = '".$_SESSION['UserId']."' ";
  1385. $others=" ORDER BY XT.transaction_date desc,XTD.id desc";
  1386. $PassParameter="";
  1387. $CountField="XT.id";
  1388. $this->set("controller","users");
  1389. $this->set("action","mypayment");
  1390. $this->pagination($select,$from,$where,$others,$CountField,$this->params['url'],$PassParameter);
  1391. $getTotalPayment="SELECT SUM( amount ) totalPaymentAmount
  1392. FROM xouser_transaction_details
  1393. WHERE xouser_transaction_id NOT
  1394. IN (
  1395. SELECT xouser_transaction_id
  1396. FROM xouser_transaction_details
  1397. WHERE DrCr = '+1'
  1398. AND user_id = '".$_SESSION['UserId']."'
  1399. )
  1400. AND DrCr = '-1'
  1401. AND user_id = '".$_SESSION['UserId']."'";
  1402. $queryGetTotalPayment=mysql_fetch_assoc(mysql_query($getTotalPayment));
  1403. $this->set("totalPaymentAmount",$queryGetTotalPayment['totalPaymentAmount']);
  1404. if(isset($this->params['url']['Page'])) {
  1405. $this->render("mypayment2","ajax");
  1406. }
  1407. }
  1408. function myfriend_top() {
  1409. $this->checkSession();
  1410. $this->layout = 'user_friends_start';
  1411. $this->pageTitle = 'My Friend Top';
  1412. $this->set('userId', $_SESSION['UserId']);
  1413. $this->set('idUrl', base64_decode($_REQUEST['uid']));
  1414. if(isset($_REQUEST['txtFrndid']) <> "") {
  1415. $top_order_no = $_REQUEST['cboTopfriend'];
  1416. if(isset($_REQUEST['page']) == "" || isset($_REQUEST['page']) == 1) {
  1417. $arry_frndid = explode("|",$_REQUEST['txtFrndid']);
  1418. $friendid_arr = str_replace("|",",",$_REQUEST['txtFrndid'] );
  1419. }
  1420. $j=0;
  1421. $frnd_id = explode(",",$_REQUEST['frnd_id']);
  1422. $frnd_order = explode("|",$_REQUEST['frndid_order']);
  1423. for($i=0;$i<count($arry_frndid);$i++) {
  1424. $j = $j+1;
  1425. $query_update = "UPDATE user_friends SET friend_order=".$j." WHERE user_id=".$_REQUEST['id']." AND friend_id=".$frnd_id[$frnd_order[$i]];
  1426. mysql_query($query_update)or die("Database Error: ".mysql_errno()." ".mysql_error());
  1427. }
  1428. }
  1429. else {
  1430. $fr_qry = "select * from user_friends where user_id= ". $_SESSION['UserId'] ." ORDER BY friend_order ASC ";
  1431. $SelectRecord=mysql_query($fr_qry);
  1432. $rows = mysql_num_rows($SelectRecord);
  1433. $this->set('friends_number', mysql_num_rows($SelectRecord));
  1434. $arr = mysql_fetch_array($SelectRecord);
  1435. $this->set('arr', $arr);
  1436. }
  1437. $pending_sql_num = mysql_num_rows(mysql_query("Select * From user_friend_requests Where invite_from = ".$_SESSION['UserId']." and invite_status ='pending'"));
  1438. $receive_sql_num = mysql_num_rows(mysql_query("Select * From user_friend_requests Where invite_to = ".$_SESSION['UserId']." and invite_status ='pending'"));
  1439. if($pending_sql_num==0)
  1440. $show_pending = "";
  1441. else
  1442. $show_pending = " (".$pending_sql_num.")";
  1443. if($receive_sql_num==0)
  1444. $show_receive = "";
  1445. else
  1446. $show_receive = " (".$receive_sql_num.")";
  1447. $this->set('Noofpending', $show_pending);
  1448. $this->set('Noofreceive', $show_receive);
  1449. }
  1450. function profilefriend() /// This function is used in the profile page
  1451. {
  1452. //$this->checkSession();
  1453. $this->layout = 'userprofilevisit';
  1454. $this->userProfileLeftPanel();
  1455. $this->pageTitle = $this->profileNameforTitle."'s Friend ";
  1456. $fr_qry = "select * from user_friends where user_id= ". $this->profileUserIdforQry ." ORDER BY friend_order ASC ";
  1457. $SelectRecord=mysql_query($fr_qry);
  1458. $rows = mysql_num_rows($SelectRecord);
  1459. $this->set('friends_number', mysql_num_rows($SelectRecord));
  1460. $this->set('SelectRecord', $SelectRecord);
  1461. ############################### Back Url ##############
  1462. if(isset($_SESSION['UserId']))
  1463. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1464. else
  1465. $userhomelink='javascript:history.back()';
  1466. $profilehomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($this->profileUserIdforQry)."&sessid=".session_id()."";
  1467. $this->set('userhomelink',$userhomelink);
  1468. $this->set('profilehomelink',$profilehomelink);
  1469. }
  1470. function profileinfo() {
  1471. //$this->checkSession();
  1472. $this->layout = 'user_signup';
  1473. $this->userProfileLeftPanel();
  1474. $this->pageTitle = $this->profileNameforTitle."'s Profile";
  1475. ############################### Back Url ##############
  1476. if(isset($_SESSION['UserId'])) {
  1477. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1478. }
  1479. else
  1480. $userhomelink ='javascript:history.back()';
  1481. $profilehomelink = $this->webroot."users/profileinfo?uid=".base64_encode($this->profileUserIdforQry);
  1482. $this->set('userhomelink',$userhomelink);
  1483. $this->set('profilehomelink',$profilehomelink);
  1484. ############LOCATION INFO #####
  1485. $locationstr = "select IFNULL(countries.country_name,'not set') as country ,IFNULL(state.Name,'not set') as state ,IFNULL(city_master.city_name,'not set') as city , users.user_group_master_id ,users.username from user_details
  1486. LEFT JOIN countries ON user_details.c_id=countries.id
  1487. LEFT JOIN state ON user_details.state=state.id
  1488. LEFT JOIN city_master ON user_details.city=city_master.city_id
  1489. LEFT JOIN users ON user_details.user_id=users.id
  1490. where user_details.user_id='".$this->profileUserIdforQry."'";
  1491. $locationstr_res =mysql_query($locationstr);
  1492. $locationstr_arr = mysql_fetch_array($locationstr_res);
  1493. $location='';
  1494. if($locationstr_arr['city']!='' && $locationstr_arr['city']!='not set')
  1495. $location .= $locationstr_arr['city'] . ', ';
  1496. if($locationstr_arr['state']!='' &&$locationstr_arr['state']!='not set')
  1497. $location .= $locationstr_arr['state'] . ', ';
  1498. if($locationstr_arr['country']!='' &&$locationstr_arr['country']!='not set')
  1499. $location .= $locationstr_arr['country'] . ', ';
  1500. if($location!='')
  1501. $this->set('profilelocation',substr($location,0,strlen($location)-2));
  1502. else
  1503. $this->set('profilelocation','not set');
  1504. $this->set('profilelocation','not set');
  1505. if($locationstr_arr['user_group_master_id']>1) {
  1506. $this->set('profileUrlforInfo','http://www.'.strtolower($locationstr_arr['username']).'.xoimages.com');
  1507. }
  1508. ################################
  1509. /* ####### CHECK FOR FRIEND STATUS ###########
  1510. $friendstatus = "select * from user_friends where user_id='".$_SESSION['UserId']."' and friend_id='".$this->profileUserIdforQry."'";
  1511. $friendstatus_res = mysql_query($friendstatus);
  1512. $this->set('friendNum',mysql_num_rows($friendstatus_res));
  1513. ################################################
  1514. ####### CHECK FOR FAVORITE STATUS ###########
  1515. $friendstatus = "select * from user_favorite_friends where user_id='".$_SESSION['UserId']."' and favorite_user_id='".$this->profileUserIdforQry."'";
  1516. $friendstatus_res = mysql_query($friendstatus);
  1517. $this->set('friendRequestNum',mysql_num_rows($friendstatus_res));
  1518. ################################################
  1519. */
  1520. $profileDetails = "Select user_details.* from user_details where user_details.user_id='".$this->profileUserIdforQry."'";
  1521. $profileDetails_res = mysql_query($profileDetails);
  1522. $profileDetails_arr = mysql_fetch_array($profileDetails_res);
  1523. $this->set('profileaboutme',$profileDetails_arr['abt_user']);
  1524. if($profileDetails_arr['user_profile_img']!="") {
  1525. $imgName = explode("/", $profileDetails_arr['user_profile_img']);
  1526. $imgSRC = "img/user_profile_img/profile_200/".$imgName[2];
  1527. }
  1528. else {
  1529. $imgSRC = "img/noimage.gif";
  1530. }
  1531. $this->set('profilelargepic',$imgSRC);
  1532. $this->set('profilegender',$profileDetails_arr['gender']);
  1533. }
  1534. function delfavorite() {
  1535. ####### CHECK FOR FAVORITE STATUS ###########
  1536. $friendstatus = "select * from user_favorite_friends where user_id='".$_SESSION['UserId']."' and favorite_user_id='".base64_decode($this->params['url']['friendid'])."'";
  1537. $friendstatus_res = mysql_query($friendstatus);
  1538. $del=0;
  1539. if(mysql_num_rows($friendstatus_res)>0) {
  1540. $delfavorite = "DELETE FROM user_favorite_friends where user_id='".$_SESSION['UserId']."' and favorite_user_id='".base64_decode($this->params['url']['friendid'])."'";
  1541. if(mysql_query($delfavorite)) {
  1542. $favmsg = 'User sucessfully deleted from favorite' ;
  1543. $del=1;
  1544. }
  1545. else
  1546. $favmsg = 'Error! user not deleted.' ;
  1547. }
  1548. $this->set('sucessmsg',$favmsg);
  1549. $this->set('profileuserid',$this->params['url']['friendid']);
  1550. $this->set('linkshow',$del);
  1551. $this->render('friendpage','ajax');
  1552. ################################################
  1553. }
  1554. function addfavorite() {
  1555. ####### CHECK FOR FAVORITE STATUS ###########
  1556. $friendstatus = "select * from user_favorite_friends where user_id='".$_SESSION['UserId']."' and favorite_user_id='".base64_decode($this->params['url']['friendid'])."'";
  1557. $friendstatus_res = mysql_query($friendstatus);
  1558. $del=1;
  1559. if(mysql_num_rows($friendstatus_res)>0) {
  1560. $insetfavorite = "INSERT INTO user_favorite_friends SET user_id='".$_SESSION['UserId']."', favorite_user_id='".base64_decode($this->params['url']['friendid'])."'";
  1561. if(mysql_query($insetfavorite)) {
  1562. $favmsg = 'User sucessfully added to your favorite' ;
  1563. $del=0;
  1564. }
  1565. else
  1566. $favmsg = 'Error! user not added.' ;
  1567. }
  1568. $this->set('sucessmsg',$favmsg);
  1569. $this->set('profileuserid',$this->params['url']['friendid']);
  1570. $this->set('linkshow',$del);
  1571. $this->render('friendpage','ajax');
  1572. ################################################
  1573. }
  1574. function addfriendrequest() {
  1575. ####### CHECK FOR FRIEND STATUS ###########
  1576. $friend=0;
  1577. $select_sql = "Select * from user_friend_requests where invite_to=".base64_decode($this->params['url']['friendid'])." and invite_from = ".$_SESSION['UserId']."";
  1578. if(mysql_num_rows(mysql_query($select_sql))==0) {
  1579. $friend_select_sql = "Select * from user_friends where friend_id=".base64_decode($this->params['url']['friendid'])." and user_id = ".$_SESSION['UserId']."";
  1580. if(mysql_num_rows(mysql_query($friend_select_sql))==0) {
  1581. $insert_sql = "Insert INTO user_friend_requests (invite_to,invite_from,invite_text,invite_denymsg) VALUES (".$this->params['url']['friendid']." , ".$_SESSION['UserId'].",'".$email_body."','')" ;
  1582. $runinsert_sql = mysql_query($insert_sql);
  1583. if($runinsert_sql) {
  1584. $friendreq = 'Friend request sucessfully posted';
  1585. $friend=1;
  1586. }else
  1587. $friendreq = 'Error ! friend request not posted';
  1588. }
  1589. }
  1590. ###################################
  1591. $this->set('linkshow',$friend);
  1592. $this->set('sucessmsg',$friendreq);
  1593. $this->set('profileuserid',$this->params['url']['friendid']);
  1594. $this->render('friendpage','ajax');
  1595. }
  1596. function delfriendrequest() {
  1597. ####### CHECK FOR FRIEND STATUS ###########
  1598. $friend=0;
  1599. $select_sql = "Select * from user_friend_requests where invite_to=".base64_decode($this->params['url']['friendid'])." and invite_from = ".$_SESSION['UserId']."";
  1600. if(mysql_num_rows(mysql_query($select_sql))==0) {
  1601. $friend_select_sql = "Select * from user_friends where friend_id=".base64_decode($this->params['url']['friendid'])." and user_id = ".$_SESSION['UserId']."";
  1602. if(mysql_num_rows(mysql_query($friend_select_sql))>0) {
  1603. $insert_sql = "DELETE FROM user_friends where friend_id=".base64_decode($this->params['url']['friendid'])." and user_id = ".$_SESSION['UserId']."" ;
  1604. $runinsert_sql = mysql_query($insert_sql);
  1605. if($runinsert_sql) {
  1606. $friendreq = 'Friend sucessfully deleted';
  1607. $friend=1;
  1608. }else
  1609. $friendreq = 'Error ! friend deletion not successfull';
  1610. }
  1611. }
  1612. ###################################
  1613. $this->set('linkshow',$friend);
  1614. $this->set('sucessmsg',$friendreq);
  1615. $this->set('profileuserid',$this->params['url']['friendid']);
  1616. $this->render('friendpage','ajax');
  1617. }
  1618. function sendmessage() {
  1619. $this->checkSession();
  1620. $this->layout = 'userprofilevisit';
  1621. $this->pageTitle = 'Send Message';
  1622. $this->userProfileLeftPanel();
  1623. if(isset($_REQUEST['sent']) && $_REQUEST['sent']== "email") {
  1624. $name =$_REQUEST['txtmailid'];
  1625. $usrQry = "select id from users where username='".$name."'";
  1626. $res = mysql_query($usrQry);
  1627. $rows = mysql_num_rows($res);
  1628. if($rows>0) {
  1629. $userId=$_SESSION['UserId'];
  1630. $UserDet = mysql_fetch_array($res);
  1631. $UserEmail = mysql_fetch_array(mysql_query("select email from user_details where user_id='".$UserDet['id']."'"));
  1632. $mailQry = "insert into sent_mails(user_id, reciever_id, email_subject, email_body) values(".$userId.", '".$UserDet['id']."', '".$_REQUEST['message_sub']."', '".$_REQUEST['msgBody']."')";
  1633. $emailUpdate = mysql_query($mailQry);
  1634. $mailQry = "insert into emails(user_id, email_creater, email_subject, email_body) values(".$UserDet['id'].", ".$userId.", '".$_REQUEST['message_sub']."', '".$_REQUEST['msgBody']."')";
  1635. $inboxUpdate = mysql_query($mailQry);
  1636. }
  1637. $commonurl = "?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&s=1";
  1638. $qryUrl=$commonurl."&friendid=".base64_encode($UserDet['id']);
  1639. $this->redirect("users/sendmessage".$qryUrl);
  1640. }
  1641. else {
  1642. $usrQry = mysql_query("SELECT username FROM users WHERE id='".base64_decode($this->params['url']['friendid'])."'");
  1643. $rwUsr=mysql_fetch_assoc($usrQry);
  1644. $this->set("userName",$rwUsr['username']);
  1645. if(isset($this->params['url']['s']))
  1646. $this->set("confirm","Your mail sent successfully.");
  1647. }
  1648. }
  1649. function editskin() {
  1650. $this->checkSession();
  1651. $this->layout = 'userprofilevisit';
  1652. $this->userProfileLeftPanel();
  1653. $this->pageTitle = $this->profileNameforTitle." Edit Profile";
  1654. ############################### Back Url ##############
  1655. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1656. $this->set('userhomelink',$userhomelink);
  1657. }
  1658. function managewebsite() {
  1659. $this->checkSession();
  1660. $this->layout = 'userprofilevisit';
  1661. $this->userProfileLeftPanel();
  1662. $this->pageTitle = $this->profileNameforTitle." Edit Profile";
  1663. ############################### Back Url ##############
  1664. $userhomelink = $this->webroot."users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1665. $this->set('userhomelink',$userhomelink);
  1666. ############################### About us Txt ##########################
  1667. $websiteQry = "SELECT IFNULL(aboutus,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1668. $websiteQry_res = mysql_query($websiteQry);
  1669. $websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1670. if($websiteQry_arr['abouttxt']=='')
  1671. $websitetxt = 'Text awaiting' ;
  1672. else
  1673. $websitetxt = $websiteQry_arr['abouttxt'] ;
  1674. $this->set('content',$websitetxt);
  1675. #####################################################################
  1676. $this->render('photoaboutus');
  1677. }
  1678. function view_project() {
  1679. $this->checkSession();
  1680. $this->layout = 'userloggedin';
  1681. $this->pageTitle = 'Bidded Project Details';
  1682. $qry = "SELECT * FROM `organization_project_bidders` AS bid, `organization_projects` AS projects WHERE projects.id =".base64_decode($_REQUEST['id']);
  1683. $bidDet = mysql_fetch_array(mysql_query($qry));
  1684. $this->set('prjName', $bidDet['project_name']);
  1685. $this->set('status', $bidDet['project_status']);
  1686. $this->set('budget', $bidDet['project_price']);
  1687. $pjDtArr = explode("-", $bidDet['project_date']);
  1688. $pjDayArr = explode(" ", $pjDtArr[2]);
  1689. $this->set('createDate', date("M d, Y l", mktime(0,0,0,$pjDtArr[1],$pjDayArr[0],$pjDtArr[0])));
  1690. $qryUser = "select username from users where id=".$bidDet['user_id'];
  1691. $created = mysql_fetch_array(mysql_query($qryUser));
  1692. $this->set('created', $created['username']);
  1693. $dtArr = explode("-", $bidDet['project_exp_date']);
  1694. $dateArr = explode(" ", $dtArr[2]);
  1695. $this->set('exp_date', date("M d, Y l", mktime(0,0,0,$dtArr[1],$dateArr[0],$dtArr[0])));
  1696. $qry = "SELECT DATEDIFF('".$bidDet['project_exp_date']."','".$bidDet['project_date']."') as date;";
  1697. $bidDateArr = mysql_fetch_array(mysql_query($qry));
  1698. $this->set('daysLeft', $bidDateArr['date']);
  1699. $this->set('desc', $bidDet['project_description']);
  1700. $this->set('type', $bidDet['project_name']);
  1701. $avgBid = mysql_fetch_array(mysql_query("select AVG(bid_value) as AVG from `organization_project_bidders` where organisation_project_id=".$bidDet['id']));
  1702. $bidcount = mysql_num_rows(mysql_query("select bid_value as AVG from `organization_project_bidders` where organisation_project_id=".$bidDet['id']));
  1703. $this->set('bidcount', $bidcount);
  1704. $this->set('avg_bid', round($avgBid['AVG'], 2));
  1705. }
  1706. function createStuffArray() {
  1707. $stuffarray = array();
  1708. if(isset($_SESSION['UserId'])) {
  1709. $stuffsql = "Select boxname from profilemap where userid='".$_SESSION['UserId']."' and display='block'";
  1710. $stuffsql_res = mysql_query($stuffsql);
  1711. while($stuffsql_arr = mysql_fetch_array($stuffsql_res)) {
  1712. array_push($stuffarray,$stuffsql_arr['boxname']);
  1713. }
  1714. }
  1715. $this->set("stuffarray",$stuffarray);
  1716. }
  1717. function saveaddstuff() {
  1718. ########## Manipulation of the element
  1719. if(isset($_REQUEST['button'])) {
  1720. if($_REQUEST['button']=='Remove') {
  1721. $updateQuery = "Update profilemap SET display='none' where userid='".$_SESSION['UserId']."' and boxname='".$this->params['url']['e']."'" ;
  1722. $updateQuery=mysql_query($updateQuery);
  1723. }
  1724. else {
  1725. echo $updateQuery = "Update profilemap SET display='block',position='".$_REQUEST['position']."' where userid='".$_SESSION['UserId']."' and boxname='".$this->params['url']['e']."'" ;
  1726. $updateQuery=mysql_query($updateQuery);
  1727. }
  1728. }
  1729. $this->createStuffArray();
  1730. $this->set("span",$this->params['url']['d']);
  1731. $this->set("elementInArray",$this->params['url']['e']);
  1732. $this->set("var",$this->params);
  1733. $this->render("saveaddstuff");
  1734. }
  1735. function saveskin() {
  1736. $this->checkSession();
  1737. if(isset($_REQUEST['theme'])) {
  1738. $updatetheme = "UPDATE user_details set theme='".$_REQUEST['theme']."' where user_id='".$_SESSION['UserId']."'";
  1739. mysql_query($updatetheme);
  1740. }
  1741. $userhomelink = "users/user_home?id=".time()."&uid=".base64_encode($_SESSION['UserId'])."&sessid=".session_id()."";
  1742. $this->redirect($userhomelink);
  1743. }
  1744. ###################################### Photographer Website section #################################
  1745. function photoaboutus() {
  1746. $this->checkSession();
  1747. $this->layout = 'userprofilevisit';
  1748. $this->userProfileLeftPanel();
  1749. $this->pageTitle = "About Us";
  1750. ############################### About us Txt ##########################
  1751. $websiteQry = "SELECT IFNULL(aboutus,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1752. $websiteQry_res = mysql_query($websiteQry);
  1753. $websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1754. if($websiteQry_arr['abouttxt']=='')
  1755. $websitetxt = 'Text awaiting' ;
  1756. else
  1757. $websitetxt = $websiteQry_arr['abouttxt'] ;
  1758. $this->set('content',$websitetxt);
  1759. #####################################################################
  1760. if(isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] == "aboutus") {
  1761. $websiteQry = "SELECT IFNULL(aboutus,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1762. $websiteQry_res = mysql_query($websiteQry);
  1763. if(mysql_num_rows($websiteQry_res)==0) {
  1764. $insetqry = "INSERT INTO photographer_website SET aboutus='".$_REQUEST['pagedesc']."' ,user_id='".$_SESSION['UserId']."' ";
  1765. mysql_query($insetqry);
  1766. }
  1767. else {
  1768. $insetqry = "UPDATE photographer_website SET aboutus='".$_REQUEST['pagedesc']."' where user_id='".$_SESSION['UserId']."'";
  1769. mysql_query($insetqry);
  1770. }
  1771. $this->redirect($_SERVER['HTTP_REFERER']);
  1772. }
  1773. }
  1774. function phototestimonial() {
  1775. $this->checkSession();
  1776. $this->layout = 'userprofilevisit';
  1777. $this->userProfileLeftPanel();
  1778. $this->pageTitle = 'Testimonial';
  1779. ############################### About us Txt ##########################
  1780. $websiteQry = "SELECT IFNULL(testimonial,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1781. $websiteQry_res = mysql_query($websiteQry);
  1782. $websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1783. if($websiteQry_arr['abouttxt']=='')
  1784. $websitetxt = 'Text awaiting' ;
  1785. else
  1786. $websitetxt = $websiteQry_arr['abouttxt'] ;
  1787. $this->set('content',$websitetxt);
  1788. #####################################################################
  1789. if(isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] == "testimonial") {
  1790. $websiteQry = "SELECT IFNULL(testimonial,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1791. $websiteQry_res = mysql_query($websiteQry);
  1792. if(mysql_num_rows($websiteQry_res)==0) {
  1793. $insetqry = "INSERT INTO photographer_website SET testimonial='".$_REQUEST['pagedesc']."' ,user_id='".$_SESSION['UserId']."' ";
  1794. mysql_query($insetqry);
  1795. }
  1796. else {
  1797. $insetqry = "UPDATE photographer_website SET testimonial='".$_REQUEST['pagedesc']."' where user_id='".$_SESSION['UserId']."'";
  1798. mysql_query($insetqry);
  1799. }
  1800. $this->redirect($_SERVER['HTTP_REFERER']);
  1801. }
  1802. }
  1803. function photoprice() {
  1804. $this->checkSession();
  1805. $this->layout = 'userprofilevisit';
  1806. $this->userProfileLeftPanel();
  1807. $this->pageTitle = 'Price';
  1808. ############################### About us Txt ##########################
  1809. $websiteQry = "SELECT IFNULL(price,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1810. $websiteQry_res = mysql_query($websiteQry);
  1811. $websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1812. if($websiteQry_arr['abouttxt']=='')
  1813. $websitetxt = 'Text awaiting' ;
  1814. else
  1815. $websitetxt = $websiteQry_arr['abouttxt'] ;
  1816. $this->set('content',$websitetxt);
  1817. #####################################################################
  1818. if(isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] == "price") {
  1819. $websiteQry = "SELECT IFNULL(price,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1820. $websiteQry_res = mysql_query($websiteQry);
  1821. if(mysql_num_rows($websiteQry_res)==0) {
  1822. $insetqry = "INSERT INTO photographer_website SET price='".$_REQUEST['pagedesc']."' ,user_id='".$_SESSION['UserId']."' ";
  1823. mysql_query($insetqry);
  1824. }
  1825. else {
  1826. $insetqry = "UPDATE photographer_website SET price='".$_REQUEST['pagedesc']."' where user_id='".$_SESSION['UserId']."'";
  1827. mysql_query($insetqry);
  1828. }
  1829. $this->redirect($_SERVER['HTTP_REFERER']);
  1830. }
  1831. }
  1832. function photocontact() {
  1833. $this->checkSession();
  1834. $this->layout = 'userprofilevisit';
  1835. $this->userProfileLeftPanel();
  1836. $this->pageTitle = 'Contact';
  1837. ############################### About us Txt ##########################
  1838. $websiteQry = "SELECT IFNULL(contactus,'Text awaiting') as abouttxt,googlelocation FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1839. $websiteQry_res = mysql_query($websiteQry);
  1840. $websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1841. if($websiteQry_arr['abouttxt']=='')
  1842. $websitetxt = 'Text awaiting' ;
  1843. else
  1844. $websitetxt = $websiteQry_arr['abouttxt'] ;
  1845. $this->set('content',$websitetxt);
  1846. $expgoogleloc = explode(':',$websiteQry_arr['googlelocation']);
  1847. if(isset($expgoogleloc[0]) &&$expgoogleloc[0]!=='')
  1848. $googlelat = $expgoogleloc[0] ;
  1849. else
  1850. $googlelat = 48.8567;
  1851. if(isset($expgoogleloc[1]) && $expgoogleloc[1]!=='')
  1852. $googlelong = $expgoogleloc[1] ;
  1853. else
  1854. $googlelong = 2.35099;
  1855. $this->set('googlelat',$googlelat);
  1856. $this->set('googlelong',$googlelong);
  1857. #####################################################################
  1858. if(isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] == "contact") {
  1859. $websiteQry = "SELECT IFNULL(contactus,'Text awaiting') as abouttxt FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1860. $websiteQry_res = mysql_query($websiteQry);
  1861. $googlelocation = $_REQUEST['lat'] .':'.$_REQUEST['lng'] ;
  1862. if(mysql_num_rows($websiteQry_res)==0) {
  1863. //$insetqry = "INSERT INTO photographer_website SET contactus='".$_REQUEST['pagedesc']."' ,user_id='".$_SESSION['UserId']."' ";
  1864. $insetqry = "INSERT INTO photographer_website SET contactus='".$_REQUEST['pagedesc']."' ,user_id='".$_SESSION['UserId']."',googlelocation='".$googlelocation."' ";
  1865. mysql_query($insetqry);
  1866. }
  1867. else {
  1868. //$insetqry = "UPDATE photographer_website SET contactus='".$_REQUEST['pagedesc']."' where user_id='".$_SESSION['UserId']."'";
  1869. $insetqry = "UPDATE photographer_website SET contactus='".$_REQUEST['pagedesc']."',googlelocation='".$googlelocation."' where user_id='".$_SESSION['UserId']."'";
  1870. mysql_query($insetqry);
  1871. }
  1872. $this->redirect($_SERVER['HTTP_REFERER']);
  1873. }
  1874. }
  1875. function photoappearence() {
  1876. $this->checkSession();
  1877. $this->layout = 'userprofilevisit';
  1878. $this->userProfileLeftPanel();
  1879. $this->pageTitle = 'Appearence';
  1880. ############################### About us Txt ##########################
  1881. $websiteQry = "SELECT layout , logoimage , backgroundimage , theme FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1882. $websiteQry_res = mysql_query($websiteQry);
  1883. $websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1884. /* LOGO IMAGE */
  1885. $logopath = $this->webroot.'img/logo.gif';
  1886. if($websiteQry_arr['logoimage']!='')
  1887. $logopath = $this->webroot.'photowebsite/logo/'.$websiteQry_arr['logoimage'] ;
  1888. /* LOGO IMAGE */
  1889. /* LAYOUT NUMBER */
  1890. $photolayout = 1;
  1891. if($websiteQry_arr['layout']!='')
  1892. $photolayout = $websiteQry_arr['layout'];
  1893. /* LAYOUT NUMBER */
  1894. /*STYLE THEME PAGE*/
  1895. $photostyle = 'blue';
  1896. if($websiteQry_arr['theme']!='')
  1897. $photostyle = $websiteQry_arr['theme'];
  1898. /*STYLE THEME PAGE*/
  1899. /* Background image */
  1900. if($websiteQry_arr['backgroundimage']=='' && $photostyle=='blue')
  1901. $backgrondpath = $this->webroot.'img/skin7.jpg';
  1902. if($websiteQry_arr['backgroundimage']=='' && $photostyle=='green')
  1903. $backgrondpath = $this->webroot.'img/skin2.gif';
  1904. if($websiteQry_arr['backgroundimage']=='' && $photostyle=='yellow')
  1905. $backgrondpath = $this->webroot.'img/skin4.gif';
  1906. if($websiteQry_arr['backgroundimage']=='' && $photostyle=='red')
  1907. $backgrondpath = $this->webroot.'img/skin1.gif';
  1908. if($websiteQry_arr['backgroundimage']=='' && $photostyle=='black')
  1909. $backgrondpath = $this->webroot.'img/skin7.jpg';
  1910. if($websiteQry_arr['backgroundimage']!='')
  1911. $backgrondpath = $this->webroot.'photowebsite/background/'.$websiteQry_arr['backgroundimage'] ;
  1912. /* Background image */
  1913. $this->set('photologoimage',$logopath);
  1914. $this->set('photobackimgpath',$backgrondpath);
  1915. $this->set('photolayout',$photolayout);
  1916. $this->set('phototemplate',$photostyle);
  1917. #####################################################################
  1918. }
  1919. function setlayout($layoutnumber) {
  1920. $websiteQry = "SELECT layout FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1921. $websiteQry_res = mysql_query($websiteQry);
  1922. if(mysql_num_rows($websiteQry_res)>0) {
  1923. $upadteLayout = "UPDATE photographer_website SET layout='".$layoutnumber."' WHERE user_id='".$_SESSION['UserId']."'";
  1924. mysql_query($upadteLayout);
  1925. //$websiteQry_arr = mysql_fetch_array($websiteQry_res);
  1926. }
  1927. else {
  1928. $upadteLayout = "INSERT INTO photographer_website SET layout='".$layoutnumber."',user_id='".$_SESSION['UserId']."'";
  1929. mysql_query($upadteLayout);
  1930. }
  1931. $this->set('layoutnumber',$layoutnumber);
  1932. $this->render('layoutlist','Ajax');
  1933. }
  1934. function setwebtheme($layoutype) {
  1935. $websiteQry = "SELECT theme FROM photographer_website WHERE user_id='".$_SESSION['UserId']."'";
  1936. $websiteQry_res = mysql_query($websiteQry);
  1937. if(mysql_num_rows($websiteQry_res)>0) {
  1938. $upadteLayout = "UPDATE photographer_website SET theme='".$layoutype."' WHERE user_id='".$_SESSION['UserId']."'";
  1939. mysql_query($upadteLayout);
  1940. }
  1941. else {
  1942. $upadteLayout = "INSERT INTO photographer_website SET theme='".$layoutype."',user_id='".$_SESSION['UserId']."'";
  1943. mysql_query($upadteLayout);
  1944. }
  1945. $this->set('layouttype',$layoutype);
  1946. $this->render('layoutlist','Ajax');
  1947. }
  1948. function editalbum($pageaction,$albumid) {
  1949. if($pageaction=='edit') {
  1950. $albumsql = "SELECT * from user_albums where user_id = '".$_SESSION['UserId']."' and id='".base64_decode($albumid)."'";
  1951. $albumsql_res = mysql_query($albumsql);
  1952. $albumsql_arr = mysql_fetch_array($albumsql_res);
  1953. $this->set('albumName',$albumsql_arr['album_name']);
  1954. $this->set('albumAccess',$albumsql_arr['album_access']);
  1955. }
  1956. else {
  1957. if($pageaction=='update') {
  1958. $updatealbum = "UPDATE user_albums SET album_name='".addslashes($_REQUEST['albumname'])."' , album_access='".$_REQUEST['access']."' where user_id = '".$_SESSION['UserId']."' and id='".base64_decode($albumid)."'";
  1959. mysql_query($updatealbum);
  1960. }
  1961. if($pageaction=='delete') {
  1962. /* DELETIng the image in the album */
  1963. $imgselect = "SELECT * from user_photo_albums where user_id = '".$_SESSION['UserId']."' and user_album_id='".base64_decode($albumid)."'";
  1964. $imgselect_res = mysql_query($imgselect);
  1965. while($imgselect_arr = mysql_fetch_array($imgselect_res)) {
  1966. $destination = realpath('../../app/webroot/user_img/t/') . '/'.$imgselect_arr['pic_original_name'];
  1967. unlink($destination);
  1968. $updatealbum = "DELETE FROM user_photo_albums where user_id = '".$_SESSION['UserId']."' and id='".$imgselect_arr['id']."'";
  1969. mysql_query($updatealbum);
  1970. }
  1971. /**/
  1972. $updatealbum = "DELETE FROM user_albums where user_id = '".$_SESSION['UserId']."' and id='".base64_decode($albumid)."'";
  1973. mysql_query($updatealbum);
  1974. }
  1975. }
  1976. $this->set('pageaction',$pageaction);
  1977. $this->set('pagealbumid',$albumid);
  1978. $this->render('editalbum2','ajax');
  1979. }
  1980. function photodetails() {
  1981. $this->verifyserverUrl($_SERVER['REQUEST_URI']);
  1982. $this->layout = 'userphotoinner_detail';
  1983. $this->set('photoid',$_REQUEST['pid']);
  1984. $select = " Select X.id,X.user_id,X.pic_original_name,X.pic_title,X.pic_desc,Xuser.username ,Xuser.id as photocreater ,COUNT(Xcomment.id) as photoreview , Xuserdetail.user_profile_img , IFNULL(ROUND(AVG(Xrating.vote),0),0) as photorat,Xalbum.album_name ,Xalbum.id as albumid ,COUNT(Xfavorite.id) as photofavored ";
  1985. $from=" FROM user_photo_albums X
  1986. LEFT JOIN user_albums Xalbum ON X.user_album_id = Xalbum.id
  1987. LEFT JOIN comments Xcomment ON X.id = Xcomment.user_photo_albums_id
  1988. LEFT JOIN users Xuser ON X.user_id = Xuser.id
  1989. LEFT JOIN user_details Xuserdetail ON X.user_id = Xuserdetail.user_id
  1990. LEFT JOIN user_voting_images Xrating ON X.id = Xrating.image_id
  1991. LEFT JOIN user_favorite_photo Xfavorite ON X.id=Xfavorite.favorite_photo_id ";
  1992. $where="WHERE X.is_blocked='0' AND X.is_temp='0' AND X.id='".base64_decode($_REQUEST['pid'])."' group by X.id";
  1993. $photo_sql = $select . $from .$where;
  1994. $photo_res = mysql_query($photo_sql);
  1995. $photores_arr = mysql_fetch_array($photo_res);
  1996. $photoUrl = DOMAIN."users/photodetails?pid=".$_REQUEST['pid'];
  1997. $this->set('photoUrl',$photoUrl);
  1998. $this->set('photoTitle', $photores_arr['pic_title']);
  1999. $this->set('photoDesc', $photores_arr['pic_desc']);
  2000. $this->set('photoImage', $photores_arr['pic_original_name']);
  2001. $this->set('photoImageId', $photores_arr['id']);
  2002. $this->set('photoImageAlbumId', $photores_arr['albumid']);
  2003. $this->set('photoUsername', $photores_arr['username']);
  2004. $this->set('photoUserId', $photores_arr['photocreater']);
  2005. $this->set('photototalRating', $photores_arr['photorat']);
  2006. $this->set('photototalReview', $photores_arr['photoreview']);
  2007. $checklover = "Select * from photo_lovers where user_photo_album_id='".base64_decode($_REQUEST['pid'])."'" ;
  2008. $checklover_res = mysql_query($checklover);
  2009. $checklover_res_num = mysql_num_rows($checklover_res);
  2010. $this->set('nooflover', $checklover_res_num);
  2011. ##### Check for the review already posted or not
  2012. $numberpreview=0;
  2013. if(isset($_SESSION['UserId'])) {
  2014. $checkbackdropreview = "SELECT * FROM comments where user_photo_albums_id='".base64_decode($_REQUEST['pid'])."' and user_id='".$_SESSION['UserId']."'";
  2015. $checkbackdropreview_res = mysql_query($checkbackdropreview);
  2016. $numberpreview = mysql_num_rows($checkbackdropreview_res);
  2017. }
  2018. $this->set('reviewposted', $numberpreview);
  2019. #####
  2020. ################################################### FOR NEXT AND PREVIOUS #######################
  2021. $Imgselect = " Select Xphotoalbum.id,Xalbum.user_id,Xphotoalbum.pic_original_name
  2022. FROM user_albums Xalbum
  2023. LEFT JOIN user_photo_albums Xphotoalbum ON Xalbum.id = Xphotoalbum.user_album_id
  2024. WHERE Xalbum.album_access='public'";
  2025. $Imgselect_res = mysql_query($Imgselect);
  2026. $Imgarray = array();
  2027. while($Imgselect_arr = mysql_fetch_array($Imgselect_res)) {
  2028. //$Imgarray['image'.$Imgselect_arr['id']] = $Imgselect_arr['id'] ;
  2029. $Imgarray[] = $Imgselect_arr['id'] ;
  2030. }
  2031. //pr($Imgarray);
  2032. //echo base64_decode($_REQUEST['pid']) ;
  2033. $searchKey = array_search(base64_decode($_REQUEST['pid']),$Imgarray) ;
  2034. // Next
  2035. $searchKeyNext = ($searchKey + 1);
  2036. $searchKeyPrev = ($searchKey - 1);
  2037. if (array_key_exists($searchKeyNext, $Imgarray)) {
  2038. $this->set('nxtImage',$Imgarray[$searchKeyNext]);
  2039. }
  2040. // Prev
  2041. if (array_key_exists($searchKeyPrev, $Imgarray)) {
  2042. $this->set('prevImage',$Imgarray[$searchKeyPrev]);
  2043. }
  2044. ################################################### FOR NEXT AND PREVIOUS #######################
  2045. ################################################### CHECKING FOR LARGE IMAGE #######################
  2046. $largeimgFilename = "../app/webroot/user_img/o/".$photores_arr['pic_original_name'];
  2047. $checklargeimgFilename = "../app/webroot/user_img/large/".$photores_arr['pic_original_name'];
  2048. if (!file_exists($checklargeimgFilename)) {
  2049. //$this->set('largeimagfile',$photores_arr['pic_original_name']);
  2050. $this->Thumbnail->fileName = $largeimgFilename;
  2051. $this->Thumbnail->quality = 100;
  2052. $this->Thumbnail->init();
  2053. $this->Thumbnail->percent = 0; //Percent has to be 0 for maxWidth and maxHeight to work;
  2054. $this->Thumbnail->maxWidth = 600;
  2055. $this->Thumbnail->maxHeight = 0;
  2056. $this->Thumbnail->resize();
  2057. $this->Thumbnail->cropSize =600;
  2058. $this->Thumbnail->cropX = ($this->Thumbnail->getCurrentWidth()/2)-($this->Thumbnail->cropSize/2);
  2059. $this->Thumbnail->cropY = ($this->Thumbnail->getCurrentHeight()/2)-($this->Thumbnail->cropSize/2);
  2060. $this->Thumbnail->crop();
  2061. $this->Thumbnail->save("../app/webroot/user_img/large/".$photores_arr['pic_original_name']);
  2062. }
  2063. ################################################### CHECKING FOR LARGE IMAGE #######################
  2064. }
  2065. function photolover($id=null) {
  2066. if(isset($_SESSION['UserId'])&& $id) {
  2067. $checklover = "Select * from photo_lovers where user_id='".$_SESSION['UserId']."' and user_photo_album_id='".$id."'" ;
  2068. $checklover_res = mysql_query($checklover);
  2069. $checklover_res_num = mysql_num_rows($checklover_res);
  2070. if($checklover_res_num==0) {
  2071. $insertlover = "INSERT INTO photo_lovers SET user_id='".$_SESSION['UserId']."', user_photo_album_id='".$id."' ";
  2072. $insertlover=mysql_query($insertlover);
  2073. }
  2074. }
  2075. $checklover = "Select * from photo_lovers where user_photo_album_id='".$id."'" ;
  2076. $checklover_res = mysql_query($checklover);
  2077. $checklover_res_num = mysql_num_rows($checklover_res);
  2078. $this->set('nooflover', $checklover_res_num);
  2079. $this->set('photoId', $id);
  2080. $this->render('photolover', 'ajax');
  2081. }
  2082. function addtag($photoId=null) {
  2083. /* */
  2084. $this->set('photoImageId',$_REQUEST['hfphotopid']);
  2085. if(isset($_REQUEST['hfphotopid']) && $_REQUEST['hfphotopid']>0 && isset($_SESSION['UserId']) && addslashes($_REQUEST['phototag'])!='Enter Tag') {
  2086. /* INSERT INTO TAGE TABLE */
  2087. $insersql = "INSERT INTO user_photo_albums_tags SET user_id='".$_SESSION['UserId']."',user_photo_album_id='".$_REQUEST['hfphotopid']."',tagname='".addslashes($_REQUEST['phototag'])."' ";
  2088. $insersql_res = mysql_query($insersql);
  2089. }
  2090. $this->set('photoImageId', $_REQUEST['hfphotopid']);
  2091. $this->render('taglist', 'ajax');
  2092. }
  2093. function savevendortag() {
  2094. $this->checkSession();
  2095. if(isset($_REQUEST['vendortag']) && $_REQUEST['vendortag']!='Enter Tag' ) {
  2096. $tagcheck = "SELECT * from vendor_usertag where user_id='".$_SESSION['UserId']."' and tagname='".addslashes($_REQUEST['vendortag'])."'";
  2097. $tagcheck_res = mysql_query($tagcheck);
  2098. if(mysql_num_rows($tagcheck)==0) {
  2099. $insersql = "INSERT INTO vendor_usertag SET user_id='".$_SESSION['UserId']."',tagname='".addslashes($_REQUEST['vendortag'])."' ";
  2100. $insersql_res = mysql_query($insersql);
  2101. }
  2102. }
  2103. $this->redirect($_SERVER['HTTP_REFERER'].'#tag');
  2104. }
  2105. function savepaymentinfo($entrytype=null) {
  2106. $this->checkSession();
  2107. //pr($_REQUEST);
  2108. if($entrytype) {
  2109. $paymentqry = "SELECT paypal_email,gcheckout_email FROM user_payment_setup WHERE user_id='".$_SESSION['UserId']."'";
  2110. $paymentqry_res = mysql_query($paymentqry);
  2111. $paymentqry_num = mysql_num_rows($paymentqry_res);
  2112. if($entrytype=='gcheckout') {
  2113. if($paymentqry_num==0) {
  2114. $insertsql ="INSERT INTO user_payment_setup SET gcheckout_email='".$_REQUEST['merchantId'].'break'.$_REQUEST['merchantkey']. "' ,user_id='".$_SESSION['UserId']."'";
  2115. mysql_query($insertsql);
  2116. }
  2117. else {
  2118. $insertsql ="UPDATE user_payment_setup SET gcheckout_email='".$_REQUEST['merchantId'].'break'.$_REQUEST['merchantkey'] ."' where user_id='".$_SESSION['UserId']."'";
  2119. mysql_query($insertsql);
  2120. }
  2121. }
  2122. if($entrytype=='paypal') {
  2123. //check paypal_email block
  2124. $result = mysql_query("SELECT * FROM user_payment_setup WHERE paypal_email='".$_REQUEST['paypaliid']. "' and is_blocked='1' ");
  2125. if(mysql_num_rows($result)<=0){
  2126. if($paymentqry_num==0) {
  2127. $insertsql ="INSERT INTO user_payment_setup SET paypal_email='".$_REQUEST['paypaliid']. "' ,user_id='".$_SESSION['UserId']."'";
  2128. mysql_query($insertsql);
  2129. }
  2130. else {
  2131. $insertsql ="UPDATE user_payment_setup SET paypal_email='".$_REQUEST['paypaliid']."' where user_id='".$_SESSION['UserId']."'";
  2132. mysql_query($insertsql);
  2133. }
  2134. }
  2135. }
  2136. }
  2137. $this->redirect($_SERVER['HTTP_REFERER'].'#payment');
  2138. }
  2139. ##################################################################
  2140. function sendVerifyemail() {
  2141. if(isset($_SESSION['UserId']) && $_SESSION['UserId']>0) {
  2142. $validateEmail = "SELECT email , CONCAT_WS(' ',first_name,last_name) as personName , users.is_validate ,users.validate_key FROM user_details
  2143. LEFT JOIN users On user_details.user_id=users.id
  2144. where user_details.user_id='".$_SESSION['UserId']."'";
  2145. $validateEmail_res = mysql_query($validateEmail);
  2146. $TempuserDetails = mysql_fetch_array($validateEmail_res);
  2147. //$userDetails = mysql_fetch_array($validateEmail_res);
  2148. $userMailAddress = $TempuserDetails['email'];
  2149. if(isset($TempuserDetails['email']) && $TempuserDetails['is_validate']=='0') {
  2150. $this->set('personName',$TempuserDetails['personName']);
  2151. if($TempuserDetails['validate_key']!='')
  2152. $validation_hash = $TempuserDetails['validate_key'] ;
  2153. else {
  2154. $validation_code = mktime().rand(10000, 90000);
  2155. $validation_hash = md5($validation_code.session_id());
  2156. $updatevalidkey = "UPDATE users SET validate_key='".$validation_hash."' where id='".$_SESSION['UserId']."' ";
  2157. @mysql_query($updatevalidkey);
  2158. }
  2159. $validationlink = '<a href="'.DOMAIN.'users/validemail/'.$validation_hash.'" style="font: normal 12px Arial, Helvetica, sans-serif; color: #0033CC;">Email verification</a>';
  2160. $this->set('varifyemailcontent',$validationlink);
  2161. $this->Sendmail->Mail();
  2162. $this->Sendmail->From(FROMMAIL);
  2163. $this->Sendmail->To($userMailAddress);
  2164. //$this->Sendmail->Cc("sujoy@navsoft.in");
  2165. //$this->Sendmail->Cc("sanjib@navsoft.in");
  2166. $subject="Xoimages Email Verifications";
  2167. $this->Sendmail->Subject($subject);
  2168. $this->Sendmail->layout='email';
  2169. $this->Sendmail->view='mail_emailverify';
  2170. $this->Sendmail->startup($this);
  2171. $messageBody=$this->Sendmail->bodyText();
  2172. $this->Sendmail->Body($messageBody); // set the body
  2173. $this->Sendmail->Priority(1) ; // set the priority to Low
  2174. $this->Sendmail->Send(); // send the mail
  2175. }
  2176. }
  2177. }
  2178. function validateemail($fromsignup=null) {
  2179. if(isset($_SESSION['UserId']) && $_SESSION['UserId']>0) {
  2180. $this->set('fromsignup',$fromsignup);
  2181. }
  2182. }
  2183. function validemail($validkey=null) {
  2184. if($validkey) {
  2185. $validateEmail = "SELECT * from users where validate_key ='".$validkey."'";
  2186. $validateEmail_res = mysql_query($validateEmail);
  2187. $validateEmail_num = mysql_num_rows($validateEmail_res);
  2188. //exit();
  2189. if($validateEmail_num>0) {
  2190. $userDetails = mysql_fetch_array($validateEmail_res);
  2191. $this->Session->write('User', $userDetails['username']);
  2192. $this->Session->write('UserId', $userDetails['id']);
  2193. $this->Session->write('GrpId', $userDetails['user_group_master_id']);
  2194. $updatevalidkey = "UPDATE users SET is_validate='1' where id='".$userDetails['id']."' ";
  2195. @mysql_query($updatevalidkey);
  2196. ######### ISSUE THE sucessfully verify mail
  2197. $userDetails=$this->getUserDetails($userDetails['id']);
  2198. $this->set('userInfo',$userDetails);
  2199. $this->Sendmail->Mail();
  2200. $this->Sendmail->From(FROMMAIL);
  2201. if(isset($userDetails['email']))
  2202. $this->Sendmail->To($userDetails['email']);
  2203. $subject="XOIMAGES REGISTRATION DETAILS";
  2204. $this->Sendmail->Subject($subject);
  2205. $this->Sendmail->layout='email';
  2206. $this->Sendmail->view='mail_userinformation';
  2207. $this->Sendmail->startup($this);
  2208. $messageBody=$this->Sendmail->bodyText();
  2209. $this->Sendmail->Body($messageBody); // set the body
  2210. $this->Sendmail->Priority(1) ; // set the priority to Low
  2211. $this->Sendmail->Send(); // send the mail
  2212. ######### ISSUE THE sucessfully verify mail
  2213. $this->redirect('/users/congratulations?id='.time().'&uid='.base64_encode($id).'&sessid='.session_id());
  2214. }
  2215. else
  2216. $this->checkSession();
  2217. }
  2218. else
  2219. $this->checkSession();
  2220. }
  2221. function verify_email() {
  2222. if(isset($_SESSION['UserId']) && $_SESSION['UserId']>0) {
  2223. $this->sendVerifyemail();
  2224. $this->set('mailmsg','Mail sent to your email address') ;
  2225. }
  2226. else {
  2227. $this->set('mailmsg','Please logged in or sign up') ;
  2228. }
  2229. $this->render('verify_email','ajax');
  2230. }
  2231. function viewalltag() {
  2232. $this->layout = 'userphotoinner_detail';
  2233. $this->pageTitle = 'Photo Tag';
  2234. }
  2235. function searchtag($alphasearch=null) {
  2236. if($alphasearch)
  2237. $searchtxt = "'".strtolower($alphasearch)."%'" ;
  2238. else {
  2239. if(isset($_REQUEST['txttagsearch']) && $_REQUEST['txttagsearch']!='')
  2240. $searchtxt = "'%". strip_html_tags($_REQUEST['txttagsearch'])."%'";
  2241. else
  2242. $searchtxt='a%';
  2243. }
  2244. $tagarray = array();
  2245. $tagsearchsql = "SELECT DISTINCT(tagname) FROM user_photo_albums_tags where tagname!='' and tagname like ". $searchtxt ."";
  2246. $tagsearchsql_res = mysql_query($tagsearchsql);
  2247. while($tagsearchsql_arr = mysql_fetch_array($tagsearchsql_res)) {
  2248. $tagarray[] = substr($tagsearchsql_arr['tagname'],0,20);
  2249. }
  2250. $this->set('tagsql',$tagsearchsql);
  2251. $this->set('tagarray',$tagarray);
  2252. $this->set('Numtagarray',mysql_num_rows($tagsearchsql_res));
  2253. $this->set('searchtxt',$alphasearch);
  2254. $this->render('searchtaglist', 'ajax');
  2255. }
  2256. function abusethisUrl($txtUrl=NULL) {
  2257. $this->layout="loginblank";
  2258. if(isset($_REQUEST['abuseurl']))
  2259. $this->set('abuseurl',$_REQUEST['abuseurl']);
  2260. if(isset($_SESSION['UserId'])) {
  2261. /* Check for the Abuse reportation */
  2262. $checkforabuse = "SELECT * from report_abuse where user_id='".$_SESSION['UserId']."' and abuse_url='".$_REQUEST['abuseurl']."'";
  2263. $checkforabuse_res = mysql_query($checkforabuse);
  2264. if(mysql_num_rows($checkforabuse_res)>0) {
  2265. $checkforabuse_arry = mysql_fetch_array($checkforabuse_res);
  2266. $statusmsg = "You have already report this as abused On " .date("M d, Y",strtotime($checkforabuse_arry['creation'])) ;
  2267. }
  2268. else {
  2269. $statusmsg ="showwindow";
  2270. }
  2271. }
  2272. else {
  2273. $statusmsg ="login";
  2274. }
  2275. $this->set('statusmsg',$statusmsg);
  2276. }
  2277. function savereportabuse() {
  2278. if(isset($_SESSION['UserId']) && isset($_REQUEST['hfabuseurl']) && $_REQUEST['hfabuseurl']!='') {
  2279. $checkforabuse = "SELECT * from report_abuse where user_id='".$_SESSION['UserId']."' and abuse_url='".$_REQUEST['hfabuseurl']."'";
  2280. $checkforabuse_res = mysql_query($checkforabuse);
  2281. if(mysql_num_rows($checkforabuse_res)==0) {
  2282. $insertintoReprt = "INSERT INTO report_abuse SET user_id='".$_SESSION['UserId']."' , abuse_url='".$_REQUEST['hfabuseurl']."' , user_comment='".$_REQUEST['usercomment']."' , typeofblock='".$_REQUEST['abusetype']."' , user_ip='".$_SERVER['REMOTE_ADDR']."' ";
  2283. @mysql_query($insertintoReprt);
  2284. ####################################### MAIL TO THE ADMINISTRATOR #########
  2285. $userDetails=$this->getUserDetails($_SESSION['UserId']);
  2286. $this->set('reprtUrl', $_REQUEST['hfabuseurl']);
  2287. $this->set('reprtabuseType',$_REQUEST['abusetype']);
  2288. $this->set('reprtabuseComment',$_REQUEST['usercomment']);
  2289. $this->set('reprtbyIp',$_SERVER['REMOTE_ADDR']);
  2290. $this->set('reprtondate',date('M d, Y'));
  2291. $this->set('reprtbyusername',$userDetails['username']);
  2292. $this->Sendmail->Mail();
  2293. $this->Sendmail->From(FROMMAIL);
  2294. $this->Sendmail->To("xoadmin@gmail.com");
  2295. $this->Sendmail->Cc("sujoy@navsoft.in");
  2296. $this->Sendmail->Cc("sanjib@navsoft.in");
  2297. $subject="Notification Report abuse ";
  2298. $this->Sendmail->Subject($subject);
  2299. $this->Sendmail->layout='email';
  2300. $this->Sendmail->view='mail_reportabuse';
  2301. $this->Sendmail->startup($this);
  2302. $messageBody=$this->Sendmail->bodyText();
  2303. $this->Sendmail->Body($messageBody); // set the body
  2304. $this->Sendmail->Priority(1) ; // set the priority to Low
  2305. $this->Sendmail->Send(); // send the mail
  2306. ##############################################
  2307. ####################################################### AUTOMATED BLOCKAGE OF THE URL ######
  2308. $today = getdate();
  2309. $startDateofmonth = $today['year'].'-'.$today['mon'].'-1';
  2310. $bannedquery = "SELECT count(id) as totalrec , DATEDIFF(CURDATE(),'".$startDateofmonth."') as Totalday from report_abuse where abuse_url='".$_REQUEST['hfabuseurl']."' and DATEDIFF(CURDATE(),'".$startDateofmonth."')<=30 group by abuse_url " ;
  2311. $bannedquery_res = mysql_query($bannedquery);
  2312. if(mysql_num_rows($bannedquery_res)>0) {
  2313. $bannedquery_array = mysql_fetch_array($bannedquery_res);
  2314. if($bannedquery_array['totalrec']>=3) {
  2315. $updateQuery = "UPDATE report_abuse SET admin_block='1' where abuse_url='".$_REQUEST['hfabuseurl']."' and admin_block='0' ";
  2316. @mysql_query($updateQuery);
  2317. }
  2318. }
  2319. ####################################
  2320. }
  2321. }
  2322. $this->render('reportabuse', 'ajax');
  2323. }
  2324. function errorpage() {
  2325. $this->pageTitle = 'Page not found';
  2326. }
  2327. }
  2328. ?>