PageRenderTime 72ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/app/controllers/users_controller.php

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