PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/app_controller.php

https://bitbucket.org/fxrialab/spsp_editor
PHP | 772 lines | 541 code | 135 blank | 96 comment | 81 complexity | fe48a5b19afcac01bc514ccf4d5bb74f MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. /* SVN FILE: $Id: app_controller.php 4409 2007-02-02 13:20:59Z phpnut $ */
  3. /**
  4. * Short description for file.
  5. *
  6. * This file is application-wide controller file. You can put all
  7. * application-wide controller-related methods here.
  8. *
  9. * PHP versions 4 and 5
  10. *
  11. * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
  12. * Copyright 2005-2007, Cake Software Foundation, Inc.
  13. * 1785 E. Sahara Avenue, Suite 490-204
  14. * Las Vegas, Nevada 89104
  15. *
  16. * Licensed under The MIT License
  17. * Redistributions of files must retain the above copyright notice.
  18. *
  19. * @filesource
  20. * @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
  21. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  22. * @package cake
  23. * @subpackage cake.cake
  24. * @since CakePHP(tm) v 0.2.9
  25. * @version $Revision: 4409 $
  26. * @modifiedby $LastChangedBy: phpnut $
  27. * @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
  28. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  29. */
  30. /**
  31. * This is a placeholder class.
  32. * Create the same file in app/app_controller.php
  33. *
  34. * Add your application-wide methods in the class below, your controllers
  35. * will inherit them.
  36. *
  37. * @package cake
  38. * @subpackage cake.cake
  39. */
  40. class AppController extends Controller {
  41. var $components = array('RequestHandler','Gcheckout','Paypal');
  42. public $profileNameforTitle="";
  43. public $profileUserIdforQry = '';
  44. public $PROFILE_USER_ID = '';
  45. public $PROFILE_THEME = '';
  46. //the public variables are used for PAYPAL
  47. //put tha clock of code in
  48. public $returnUrl="";
  49. public $cancelUrl="";
  50. public $notifyUrl="";
  51. public $amountPay=NULL;
  52. public $userEmail=NULL;
  53. public $eventId=NULL;
  54. public $userId=NULL;
  55. public $merchantEmail=NULL;
  56. public $itemName=NULL;
  57. public $itemNumber=NULL;
  58. public $itemQuantity=NULL;
  59. public $invoice=NULL;
  60. public $custom=NULL;
  61. public $paypalUrl='https://www.paypal.com/cgi-bin/webscr';
  62. //public $paypalUrl='https://www.sandbox.paypal.com/cgi-bin/webscr';
  63. public $ticketPaymentMsg=NULL;
  64. function paypal() {
  65. //echo $this->merchantEmail;die();
  66. if(isset($this->ticketPaymentMsg))
  67. $this->Paypal->ticketPayment=$this->ticketPaymentMsg;
  68. $this->Paypal->paypal_class();
  69. $this->Paypal->paypal_url = $this->paypalUrl;
  70. $this->Paypal->add_field('business', $this->merchantEmail);
  71. $this->Paypal->add_field('return', $this->returnUrl);
  72. //$this->Paypal->add_field('cancel_return', $this->cancelUrl);
  73. $this->Paypal->add_field('notify_url', $this->notifyUrl);
  74. $this->Paypal->add_field('item_name', $this->itemName);
  75. $this->Paypal->add_field('amount', $this->amountPay);
  76. $this->Paypal->add_field('quantity', $this->itemQuantity);
  77. $this->Paypal->add_field('custom', $this->custom);
  78. $this->Paypal->add_field('invoice',$this->invoice);
  79. $this->Paypal->add_field('cbt','Return to Xoimages.com to complete your purchase');
  80. $this->Paypal->submit_paypal_post(); // submit the fields to paypal
  81. }
  82. //-----
  83. function transactionMaster($transactionDesc = null,$transactionHead = null,$transactionTitle = null, $invoice = null,$invoiceId = null) {
  84. mysql_query("
  85. INSERT INTO
  86. xouser_transactions(transaction_desc,transaction_head,transaction_title,invoice,invoice_id)
  87. VALUES('".$transactionDesc."','".$transactionHead."','".$transactionTitle."','".$invoice."','".$invoiceId."')") or die("Error on line ".__LINE__.mysql_error());
  88. return $xouserTransactionId=mysql_insert_id();
  89. }
  90. //'-1' entry implies that buyer has been charged
  91. //'+1' entry implies thar he has paid the amount that is charged
  92. //At the time of commission calculation we will make the charged entry against the user
  93. function transactionDetail($buyer = null,$amount = null,$DbCr = null,$lastTransactionId = null, $receipient = null,$statusoffee="",$pay_status=0,$paymentstatus="pending") {
  94. mysql_query("INSERT INTO
  95. xouser_transaction_details(user_id,amount,DrCr,xouser_transaction_id,payment_to,paystatus,statusfee,paymentstatus)
  96. VALUES('".$buyer."','".$amount."','".$DbCr."','".$lastTransactionId."','".$receipient."','".$pay_status."','".$statusoffee."','".$paymentstatus."')");
  97. }
  98. /* this function still not in use now. this you will use from notify_eventcommissionpayment() function of xoevents_controller instead of transactionDetail function call, as to make pending status finished */
  99. function transactionDetailPaid($buyer = null,$amount = null,$DbCr = null,$lastTransactionId = null, $receipient = null,$statusoffee="",$pay_status=0,$paymentstatus="pending") {
  100. /* for changing status to finished from pending */
  101. $query_check= mysql_query("select * from xouser_transaction_details where user_id='".$buyer."' and payment_to='".$receipient."' and statusfee='transactionfee' and paymentstatus='pending' order by id asc");
  102. $nuamt = $amount;
  103. while($result_check = mysql_fetch_array($query_check)) {
  104. if($result_check['amount'] < $nuamt) {
  105. //mysql_query("update xouser_transaction_details set paymentstatus='finished' where id='".$result_check['id']."'");
  106. $nuamt = $nuamt - $result_check['amount'];
  107. }
  108. }
  109. /* end */
  110. mysql_query("INSERT INTO
  111. xouser_transaction_details(user_id,amount,DrCr,xouser_transaction_id,payment_to,paystatus,statusfee,paymentstatus)
  112. VALUES('".$buyer."','".$amount."','".$DbCr."','".$lastTransactionId."','".$receipient."','".$pay_status."','".$statusoffee."','".$paymentstatus."')");
  113. }
  114. /* end of the function */
  115. function checkSession($signin=null) {
  116. // If the session info hasn't been set...
  117. if (!$this->Session->check('User')) {
  118. $this->redirect('/?id=1');
  119. }
  120. else {
  121. ######################################## CHECKING FOR VALIDATE EMAIL ############################
  122. $validateEmail = "SELECT is_validate FROM users where id='".$_SESSION['UserId']."'";
  123. $validateEmail_res = mysql_query($validateEmail);
  124. if($validateEmail_arr = mysql_fetch_array($validateEmail_res)) {
  125. if($validateEmail_arr['is_validate']=='0') {
  126. $this->redirect('users/validateemail/'.$signin);
  127. }
  128. }
  129. ######################################## CHECKING FOR VALIDATE EMAIL ############################
  130. }
  131. }
  132. function userProfileLeftPanel($userId=0) {
  133. //echo $userId ;
  134. ########################################## BELOW CODE IS TO GET THE PROFILE DATA ######
  135. if(isset($_REQUEST['uid']) && $userId==0)
  136. $userId=$_REQUEST['uid'];
  137. if(isset($userId) && base64_decode($userId)>0) {
  138. $uid = base64_decode($userId);
  139. ##### Validate the user
  140. $string = addcslashes($uid,';%_:$&?-+=*[]()��"�`'); // step for stopping sql injection
  141. $validuser = "Select * from users where id='".$string."'";
  142. $validuser_res = mysql_query($validuser);
  143. if(mysql_num_rows($validuser_res) > 0) {
  144. $user_det_qry = "select user_details.* , users.username , users.user_group_master_id from user_details , users where user_details.user_id = ".$uid." and user_details.user_id = users.id";
  145. $user_det = mysql_fetch_array(mysql_query($user_det_qry));
  146. $profileName = ucfirst(stripslashes($user_det['username'])) ;
  147. $profiletheme = $user_det['theme'] ;
  148. $profilebackimg = $user_det['theme'] ;
  149. $profileskype = $user_det['skype'] ;
  150. ################################################ BG IMAGE ###################################################################
  151. $user_imge = "select * from profile_background where bg_user=".$uid."" ;
  152. $user_imge_sql = mysql_query($user_imge);
  153. $res_user_img = mysql_fetch_array($user_imge_sql);
  154. if($res_user_img['bg_status']=='admin') {
  155. $profilebackimg = "img/default_profile/".$res_user_img['bg_image_path'] ;
  156. }
  157. else {
  158. if($res_user_img['bg_status']=='upload') {
  159. $profilebackimg = "img/default_profile/".$res_user_img['bg_image_path'] ;
  160. }
  161. else {
  162. if($res_user_img['bg_status']=='url') {
  163. $profilebackimg = $res_user_img['bg_image_path'];
  164. }
  165. }
  166. }
  167. #####################################################################################
  168. $this->profileNameforTitle = $profileName ;
  169. $this->profileUserIdforQry = $uid ;
  170. $this->set('user_detail',$user_det);
  171. ############################### SCHOOL NAME #########################
  172. $this->set('profileskype',$profileskype);
  173. $this->set('profileName',$profileName);
  174. $this->set('profileuserid',$uid);
  175. if($profiletheme=='')
  176. $profiletheme='blue';
  177. $this->set('profileusertheme',$profiletheme);
  178. $this->set('profilebackgroundImg',$profilebackimg);
  179. $this->PROFILE_THEME = $profiletheme;
  180. $this->PROFILE_USER_ID=$uid;
  181. $this->generateMusicList($this->profileUserIdforQry);
  182. if(isset($_SESSION['UserId']) && $_SESSION['UserId']!=$this->profileUserIdforQry) {
  183. ####### CHECK FOR FRIEND STATUS ###########
  184. $friendstatus = "select * from user_friends where user_id='".$_SESSION['UserId']."' and friend_id='".$this->profileUserIdforQry."'";
  185. $friendstatus_res = mysql_query($friendstatus);
  186. $this->set('friendNum',mysql_num_rows($friendstatus_res));
  187. ################################################
  188. ####### CHECK FOR FAVORITE STATUS ###########
  189. $friendstatus = "select * from user_favorite_friends where user_id='".$_SESSION['UserId']."' and favorite_user_id='".$this->profileUserIdforQry."'";
  190. $friendstatus_res = mysql_query($friendstatus);
  191. $this->set('friendRequestNum',mysql_num_rows($friendstatus_res));
  192. ################################################
  193. }
  194. ############LOCATION INFO #####
  195. $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 from user_details
  196. LEFT JOIN countries ON user_details.c_id=countries.id
  197. LEFT JOIN state ON user_details.state=state.id
  198. LEFT JOIN city_master ON user_details.city=city_master.city_id
  199. where user_details.user_id='".$this->profileUserIdforQry."'";
  200. $locationstr_res =mysql_query($locationstr);
  201. $locationstr_arr = mysql_fetch_array($locationstr_res);
  202. $this->set('countryName',$locationstr_arr['country']);
  203. $this->set('stateName',$locationstr_arr['state']);
  204. $this->set('cityName',$locationstr_arr['city']);
  205. ################################
  206. }
  207. else
  208. $this->redirect('/?id=1&access=denied');
  209. }
  210. if(isset($_SESSION['UserId'])) {
  211. $myphotolink = $this->webroot.'user_albums/viewphoto?id='.time().'&uid='.base64_encode($_SESSION['UserId']).'&sessid='.base64_encode(1).'&act=edit';
  212. $myfriendlink = $this->webroot.'users/myfriend_top?id='.time().'&uid='.base64_encode($_SESSION['UserId']).'&sessid='.base64_encode(1).'&act=edit';
  213. $myinboxlink = $this->webroot.'emails/inbox?id='.time().'&uid='.base64_encode($_SESSION['UserId']).'&sessid='.base64_encode(1).'&act=edit';
  214. $mycalendarlink = $this->webroot.'calendars/today?id='.time().'&uid='.base64_encode($_SESSION['UserId']).'&sessid='.base64_encode(1).'&act=edit';
  215. $myfavlink = $this->webroot.'user_friends/myfavFriends?id='.time().'&uid='.base64_encode($_SESSION['UserId']).'&sessid='.base64_encode(1).'&act=edit';
  216. $mycustomprofile = $this->webroot.'users/editskin?uid='.base64_encode($_SESSION['UserId']);
  217. $managewebsite = $this->webroot.'users/managewebsite?uid='.base64_encode($_SESSION['UserId']);
  218. $this->set('myphotolink',$myphotolink);
  219. $this->set('myfriendlink',$myfriendlink);
  220. $this->set('myinboxlink',$myinboxlink);
  221. $this->set('mycalendarlink',$mycalendarlink);
  222. $this->set('myfavlink',$myfavlink);
  223. $this->set('editskin',$mycustomprofile);
  224. $this->set('managewebsite',$managewebsite);
  225. #### Unread Mail
  226. $mail = mysql_query("select * from emails where user_id=".$_SESSION['UserId']." and inbox_status='unread'");
  227. if($mail) {
  228. $mailQry = mysql_num_rows($mail);
  229. }
  230. $this->set('Noofunread',$mailQry);
  231. ###
  232. }
  233. }
  234. function checkSessionForPreview() {
  235. if (!$this->Session->check('User'))
  236. return true;
  237. else
  238. return false;
  239. }
  240. function generateMusicList($profileuserid) {
  241. $musicSQL = "Select music_path,music_title from musics where user_id='".$profileuserid."'";
  242. $musicSQL_res = mysql_query($musicSQL);
  243. if(mysql_num_rows($musicSQL_res) >0) {
  244. $mp3list = '';
  245. $mp3title ='';
  246. $confiG='';
  247. while($musicSQL_arr = mysql_fetch_array($musicSQL_res)) {
  248. if($musicSQL_arr['music_path']!='')
  249. $mp3list .= $this->webroot.'user_music/'.$musicSQL_arr['music_path'].'|';
  250. if($musicSQL_arr['music_title']!='')
  251. $mp3title .= $musicSQL_arr['music_title'].'|';
  252. else
  253. $mp3title .= 'xoimages music'.'|';
  254. }
  255. if($this->PROFILE_THEME=='green')
  256. $confiG='mp3= '.substr($mp3list,0,(strlen($mp3list)-1)).'&amp;title= '.substr($mp3title,0,(strlen($mp3title)-1)).'^^'.'&amp;width=140&amp;height=150&amp;bgcolor=63A41D&amp;bgcolor1=AEB873&amp;bgcolor2=72CC11&amp;buttoncolor=325E04&amp;buttonovercolor=A3FF02&amp;slidercolor1=3B670D&amp;slidercolor2=cccccc&amp;sliderovercolor=f9bf37&amp;textcolor=2C5006&amp;playlistcolor=848181&amp;currentmp3color=AEFF00&amp;scrollbarcolor=69B135&amp;scrollbarovercolor=f9bf37&amp;showvolume=1';
  257. if($this->PROFILE_THEME=='black')
  258. $confiG='mp3= '.substr($mp3list,0,(strlen($mp3list)-1)).'&amp;title= '.substr($mp3title,0,(strlen($mp3title)-1)).'^^'.'&amp;width=140&amp;height=150&amp;bgcolor=000000&amp;bgcolor1=484848&amp;bgcolor2=000000&amp;buttoncolor=dddddd&amp;buttonovercolor=f9bf37&amp;slidercolor1=dddddd&amp;slidercolor2=cccccc&amp;sliderovercolor=f9bf37&amp;textcolor=dddddd&amp;playlistcolor=848181&amp;currentmp3color=f9bf37&amp;scrollbarcolor=cccccc&amp;scrollbarovercolor=f9bf37&amp;showvolume=1';
  259. if($this->PROFILE_THEME=='yellow')
  260. $confiG='mp3= '.substr($mp3list,0,(strlen($mp3list)-1)).'&amp;title= '.substr($mp3title,0,(strlen($mp3title)-1)).'^^'.'&amp;width=140&amp;height=150&amp;bgcolor=FFCE58&amp;bgcolor1=FFDC83&amp;bgcolor2=D4A22C&amp;buttoncolor=987D2A&amp;buttonovercolor=FF8A00&amp;slidercolor1=FFDC83&amp;slidercolor2=DDA52B&amp;sliderovercolor=f9bf37&amp;textcolor=685312&amp;playlistcolor=B1903C&amp;currentmp3color=FFE7A9&amp;scrollbarcolor=69B135&amp;scrollbarovercolor=f9bf37&amp;showvolume=1';
  261. if($this->PROFILE_THEME=='blue')
  262. $confiG='mp3= '.substr($mp3list,0,(strlen($mp3list)-1)).'&amp;title= '.substr($mp3title,0,(strlen($mp3title)-1)).'^^'.'&amp;width=140&amp;height=150&amp;bgcolor=4094CF&amp;bgcolor1=BEE4FF&amp;bgcolor2=4094CF&amp;buttoncolor=537993&amp;buttonovercolor=09D4FF&amp;slidercolor1=FFDC83&amp;slidercolor2=DDA52B&amp;sliderovercolor=f9bf37&amp;textcolor=134264&amp;playlistcolor=3F6F91&amp;currentmp3color=D8EFFF&amp;scrollbarcolor=69B135&amp;scrollbarovercolor=f9bf37&amp;showvolume=1';
  263. if($this->PROFILE_THEME=='red')
  264. $confiG='mp3= '.substr($mp3list,0,(strlen($mp3list)-1)).'&amp;title= '.substr($mp3title,0,(strlen($mp3title)-1)).'^^'.'&amp;width=140&amp;height=150&amp;bgcolor=EF7E34&amp;bgcolor1=F5B245&amp;bgcolor2=EF7E34&amp;buttoncolor=8C5F30&amp;buttonovercolor=FEE11B&amp;slidercolor1=FFDC83&amp;slidercolor2=DDA52B&amp;sliderovercolor=f9bf37&amp;textcolor=7E4819&amp;playlistcolor=BB7C53&amp;currentmp3color=FFD053&amp;scrollbarcolor=69B135&amp;scrollbarovercolor=f9bf37&amp;showvolume=1';
  265. $this->set("confiG",$confiG);
  266. $this->set("musicnum",mysql_num_rows($musicSQL_res));
  267. }
  268. }
  269. function getMyComments($profile_user_comment) {
  270. $this->set("test",1);
  271. $queryUserComments=mysql_query("
  272. SELECT UC.comment,UC.dt_time,U.username,USR.user_profile_img
  273. FROM user_comments UC
  274. LEFT JOIN user_details USR ON(UC.friend_id=USR.user_id)
  275. LEFT JOIN users U ON(UC.friend_id=U.id)
  276. WHERE UC.user_id='".$profile_user_comment."'
  277. ") or die("Error on line ".__LINE__.mysql_error());
  278. $this->set("queryUserComments",$queryUserComments);
  279. }
  280. function previewFeePayment($data) {
  281. $query="
  282. SELECT *
  283. FROM xoevent_user_list
  284. WHERE xoevent_id='".$data['Event']['headerEventId']."' AND user_id='".$_SESSION['UserId']."' AND pflag='1'";
  285. $qtemp=mysql_query($query) or die(mysql_error()." on 514");
  286. if(mysql_num_rows($qtemp)>0) {
  287. $this->redirect("xoevents/eventlist?id=".$data['Event']['headerEventId']."&uid=".base64_encode($_SESSION['UserId']));
  288. exit;
  289. }
  290. else {
  291. $q1="SELECT id,photo_preview_list_id FROM xoevents WHERE id=".$data['Event']['headerEventId'];
  292. $rsEvent=mysql_query($q1);
  293. $rowEvent=mysql_fetch_assoc($rsEvent);
  294. if($rowEvent['photo_preview_list_id']) {
  295. $q2="SELECT preview_fee FROM photo_preview_list WHERE id=".$rowEvent['photo_preview_list_id'];
  296. $rsPrev=mysql_query($q2);
  297. if(mysql_num_rows($rsPrev)>0) {
  298. $rowPreview=mysql_fetch_assoc($rsPrev);
  299. $this->set("previewFee",$rowPreview['preview_fee']);
  300. $this->set("paymentMethods",$this->getPaymentMethodsEvent($data['Event']['headerEventId']));
  301. }
  302. $this->set("payment",1);
  303. $this->set("restricted",0);
  304. $this->set("wintype","pay");
  305. $this->set("returnController",1);
  306. }
  307. else {
  308. $this->redirect("xoevents/eventlist?id=".$data['Event']['headerEventId']."&uid=".base64_encode($_SESSION['UserId']));
  309. exit;
  310. }
  311. }
  312. }
  313. //this is the payment setup fetch against each events
  314. function getPaymentMethodsEvent($eventId) {
  315. $qPay=mysql_query("
  316. SELECT P.paypal_email,P.gcheckout_email
  317. FROM user_payment_setup P,xoevents E
  318. WHERE P.user_id=E.user_id AND E.id=".$eventId) or die(mysql_error());
  319. $rowPayment=mysql_fetch_assoc($qPay);
  320. return $rowPayment;
  321. }
  322. //this is the payment method set against each ticket
  323. function getPaymentMethodTicket($eventId) {
  324. $qPay=mysql_query("
  325. SELECT P.paypal_email,P.gcheckout_email
  326. FROM user_payment_setup P,tickets T
  327. WHERE P.user_id=T.user_id AND T.id=".$eventId) or die(mysql_error());
  328. $rowPayment=mysql_fetch_assoc($qPay);
  329. return $rowPayment;
  330. }
  331. //this function check whether to show the tooltip or not for the left panel of the photographer and organisations
  332. //control panel
  333. function checktooltip() {
  334. //Check whether to show tooltip or not
  335. if(isset($_SESSION['UserId'])) {
  336. $chkTooltip=mysql_query("SELECT id,tooltip FROM user_tooltip WHERE user_id='".$_SESSION['UserId']."'");
  337. $toolTip=0;
  338. if(mysql_num_rows($chkTooltip)>0) {
  339. $rwTooltip=mysql_fetch_assoc($chkTooltip);
  340. if($rwTooltip['tooltip']==1)
  341. $toolTip=1;
  342. }
  343. $this->Session->write("toolTipSes",$toolTip);
  344. }
  345. }
  346. function userLogin($userName,$password) {
  347. $someone = $this->User->findByUsername($userName);//"http://adserver:8088/xoimage-115-07/Nnew/"
  348. if(!empty($someone['User']['password']) && $someone['User']['password'] == $password && $someone['User']['user_status']==1) {
  349. 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());
  350. $this->Session->write('User', $someone['User']['username']);
  351. $this->Session->write('UserId', $someone['User']['id']);
  352. $this->Session->write('GrpId', $someone['User']['user_group_master_id']);
  353. $this->checktooltip();
  354. return $someone;
  355. }
  356. else {
  357. return false;
  358. }
  359. }
  360. function Login($data) {
  361. $eventId=$data['Event']['headerEventId'];
  362. $this->set("eventId",$eventId);
  363. $data['Event']['username']=trim($data['Event']['headerLoginName']);
  364. $data['Event']['password']=base64_encode(trim($data['Event']['headerLoginPass']));
  365. $someone=$this->userLogin($data['Event']['username'],$data['Event']['password']);
  366. if($someone) {
  367. //This section is for the project section NOTHING TO DO WITH EVENT SECTION
  368. if($data['Event']['headerFav']=="EVENTACT") {
  369. $this->redirect("calendars/editevent?id=".time()."&uid=&sessid=".base64_encode(1)."&evid=".base64_encode($eventId));
  370. exit;
  371. }
  372. if($data['Event']['headerFav']=="ACTIVITY") {
  373. $this->redirect("calendars/showactivity?id=".time()."&uid=&sessid=".base64_encode(1)."&evid=".base64_encode($eventId));
  374. exit;
  375. }
  376. if($data['Event']['headerFav']=="PROJECT") {
  377. if($someone['User']['user_group_master_id']==1) {
  378. return "NOT AUTH";
  379. exit;
  380. }
  381. else {
  382. $this->redirect("organization_projects/project_detail?id=".base64_encode($eventId)."=&uid=".base64_encode($someone['User']['id'])."&sessid=MQ==&project=uij4");
  383. exit;
  384. }
  385. }
  386. ################### ORGANISATION WEBPAGE Calender event and activity
  387. if($data['Event']['headerFav']=="Calevent" || $data['Event']['headerFav']=="Calactivity") {
  388. if($data['Event']['headerFav']=="Calevent")
  389. $this->redirect("calendars/editevent?id=".time()."&uid=&sessid=MQ==&evid=".base64_encode($eventId));
  390. if($data['Event']['headerFav']=="Calactivity")
  391. $this->redirect("calendars/showactivity?id=".time()."&uid=&sessid=MQ==&evid=".base64_encode($eventId));
  392. exit;
  393. }
  394. ################### ORGANISATION WEBPAGE Calender event and activity
  395. if($data['Event']['headerFav']!="FAV") {
  396. $q1=mysql_query("SELECT access_password,photo_preview_list_id FROM xoevents WHERE id=".$data['Event']['headerEventId']);
  397. if(mysql_num_rows($q1)>0) {
  398. $row=mysql_fetch_assoc($q1);
  399. if($row['access_password']=="") {
  400. $eventUserList=0;
  401. if(isset($row['photo_preview_list_id']) && $row['photo_preview_list_id']!=0) {
  402. $query="SELECT * FROM xoevent_user_list WHERE xoevent_id=".$data['Event']['headerEventId']." AND user_id=".$someone['User']['id'];
  403. $qtemp=mysql_query($query) or die(mysql_error()." on 300");
  404. if(mysql_num_rows($qtemp)>0)
  405. $eventUserList=1;
  406. }
  407. else
  408. $eventUserList=1;
  409. if(isset($eventUserList) && $eventUserList==1) {
  410. $this->redirect("xoevents/eventlist?id=".$data['Event']['headerEventId']."&uid=".base64_encode($someone['User']['id']));
  411. exit;
  412. }
  413. }
  414. }
  415. }
  416. else {
  417. $wintype="DONT";
  418. return $wintype;
  419. }
  420. }
  421. else {
  422. $this->set("wrongPwd","Please provide a valid username and password.");
  423. $wintype="pwd";
  424. $this->set("returnController",1);
  425. return $wintype;
  426. }
  427. }
  428. function winType($eventId) {
  429. //print "From function winType - ".$eventId;
  430. $this->set("restricted",0);
  431. $this->set("payment",0);
  432. $this->set("previewFee",0);
  433. $this->set("accessDenied",0);
  434. $this->set("eventId",$eventId);
  435. $q1=mysql_query("SELECT access_password FROM xoevents WHERE id='".$eventId."'");
  436. if(mysql_num_rows($q1)>0) {
  437. $row=mysql_fetch_assoc($q1);
  438. if($row['access_password']!="" || $row['access_password']!=0) {
  439. $this->set("wintype","pevt");
  440. $this->set("restricted",1);
  441. $this->set("returnController",1);
  442. }
  443. else {
  444. if(isset($_SESSION['UserId'])) {
  445. $this->set("paymentMethods",$this->getPaymentMethodsEvent($eventId));
  446. }
  447. $this->set("payment",1);
  448. $this->set("restricted",0);
  449. $this->set("wintype","pay");
  450. $this->set("returnController",1);
  451. }
  452. }
  453. //print "from wintype".$eventId;
  454. }
  455. function paymentWindow($data) {
  456. //print "from payment window";
  457. $payment=0;
  458. if(isset($data['Event']['password1'])) {
  459. //print "From payment function";
  460. $this->set("eventId",$data['Event']['headerEventId']);
  461. $q1="
  462. SELECT id,photo_preview_list_id
  463. FROM xoevents
  464. WHERE access_password='".base64_encode(strtoupper($data['Event']['password1']))."' AND id=".$data['Event']['headerEventId'];
  465. $rsEvent=mysql_query($q1) or die("Error on line :".__LINE__.mysql_error());
  466. if(mysql_num_rows($rsEvent)>0) {
  467. $payment=1;
  468. $this->previewFeePayment($data);
  469. }
  470. else {
  471. $this->set("wrongPwd","Event password provided does not match.");
  472. $this->set("wintype","pevt");
  473. $this->set("returnController",1);
  474. }
  475. }
  476. //
  477. // if(isset($_SESSION['UserId']) && $payment==0)
  478. // {
  479. // $this->previewFeePayment($data);
  480. // $this->set("paymentMethods",$this->getPaymentMethods($data['Event']['headerEventId']));
  481. // }
  482. }
  483. function notautho() {
  484. $userName="testorganisation";
  485. $queryUsers=mysql_query("SELECT UDTL.user_id userId,U.user_group_master_id GrpId FROM users U,user_details UDTL WHERE U.id=UDTL.user_id AND U.username='".$userName."'") or die(" Error on line ".__LINE__.mysql_error());
  486. $fetchUsers=mysql_fetch_array($queryUsers);
  487. $this->pageTitle = ucfirst($userName) .' Projects';
  488. $this->Websitetemplateinfo($fetchUsers['userId']);
  489. $this->layout=$this->filelayoutName;
  490. $this->set('profileviewUid',$fetchUsers['userId']);
  491. $this->set('profileviewUgrpId',$fetchUsers['GrpId']);
  492. }
  493. //This function can be removesd when all the testing completes
  494. //we can use getConfigAmount instead of this function
  495. function getFeaturedAmount($configName) {
  496. $queryAdminPaymentConfig=mysql_query("SELECT config_value FROM admin_payment_config WHERE config_name='".$configName."'") or die("Error on line :".__LINE__.mysql_error());
  497. $fetchAdminPaymentConfig=mysql_fetch_assoc($queryAdminPaymentConfig);
  498. return $fetchAdminPaymentConfig;
  499. }
  500. function getConfigAmount($config) {
  501. $queryAdminPaymentConfig=mysql_query("SELECT config_value FROM admin_payment_config WHERE config_name='".$config."'") or die("Error on line : ".__LINE__.mysql_error());
  502. $fetchAdminPaymentConfig=mysql_fetch_assoc($queryAdminPaymentConfig);
  503. return $fetchAdminPaymentConfig;
  504. }
  505. function getPaymentMethods($userId) {
  506. /*$queryAdminPaymentSetup=mysql_query("SELECT paypal_email,gcheckout_email FROM admin_payment_setup WHERE admin_id='".$userId."'") or die("Error on line :".__LINE__.mysql_error());*/
  507. $queryAdminPaymentSetup=mysql_query("SELECT paypal_email FROM admin_payment_setup WHERE admin_id='".$userId."'") or die("Error on line :".__LINE__.mysql_error());
  508. $fetchAdminPaymentSetup=mysql_fetch_assoc($queryAdminPaymentSetup);
  509. return $fetchAdminPaymentSetup;
  510. }
  511. function getPaymentMethodsUsers($userId) {
  512. $fetchAdminPaymentSetup=array();
  513. $queryAdminPaymentSetup=mysql_query("SELECT paypal_email,gcheckout_email FROM user_payment_setup WHERE user_id='".$userId."'") or die("Error on line :".__LINE__.mysql_error());
  514. if(mysql_num_rows($queryAdminPaymentSetup)>0)
  515. $fetchAdminPaymentSetup=mysql_fetch_assoc($queryAdminPaymentSetup);
  516. return $fetchAdminPaymentSetup;
  517. }
  518. function parseXmlArray($xmlData) {
  519. $data = $xmlData;
  520. $xml_parser = xml_parser_create();
  521. xml_parse_into_struct($xml_parser, $data, $vals, $index);
  522. xml_parser_free($xml_parser);
  523. $params = array();
  524. $level = array();
  525. foreach ($vals as $xml_elem) {
  526. if ($xml_elem['type'] == 'open') {
  527. if (array_key_exists('attributes',$xml_elem)) {
  528. list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
  529. }
  530. else {
  531. $level[$xml_elem['level']] = $xml_elem['tag'];
  532. }
  533. }
  534. if ($xml_elem['type'] == 'complete') {
  535. $start_level = 1;
  536. $php_stmt = '$params';
  537. while($start_level < $xml_elem['level']) {
  538. $php_stmt .= '[$level['.$start_level.']]';
  539. $start_level++;
  540. }
  541. $php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
  542. eval($php_stmt);
  543. }
  544. }
  545. return $params;
  546. }
  547. function getCityList($stateId) {
  548. $cityList=array();
  549. $cityList['0']="Select a city";
  550. $qryCityMaster = mysql_query("SELECT * FROM city_master WHERE state_id='".$stateId."' order by city_name ");
  551. while($fetchCityMaster = mysql_fetch_array($qryCityMaster)) {
  552. $cityList[$fetchCityMaster['city_id']]=preg_replace('/[^0-9a-z ]+/i', '', $fetchCityMaster['city_name']);
  553. }
  554. return $cityList;
  555. }
  556. function getStateList($countryId) {
  557. $stateSList=array();
  558. $stateSList['0']="Select a state";
  559. $qry3 = mysql_query("SELECT * FROM state WHERE c_id='".$countryId."' order by Name");
  560. while($state = mysql_fetch_array($qry3)) {
  561. $stateSList[$state['id']]=preg_replace('/[^0-9a-z ]+/i', '', $state['Name']);
  562. }
  563. return $stateSList;
  564. }
  565. function getCountryList() {
  566. $coutryList=array();
  567. $countryList['0']="Select Country";
  568. $qry = mysql_query("SELECT * FROM countries");
  569. while($country = mysql_fetch_array($qry)) {
  570. $countryList[$country['id']]=preg_replace('/[^0-9a-z ]+/i', '', $country['country_name']);
  571. }
  572. return $countryList;
  573. }
  574. function getUserDetails($userId) {
  575. $qry2=mysql_query("SELECT UD.*,U.* FROM user_details UD,users U WHERE UD.user_id=U.id AND U.id='".$userId."'");
  576. $rowQry=mysql_fetch_assoc($qry2);
  577. return $rowQry;
  578. }
  579. function getSiteownerDetails() {
  580. $qry2=mysql_query("SELECT U.* FROM admins U WHERE U.role_id='1'");
  581. $rowQry=mysql_fetch_assoc($qry2);
  582. return $rowQry;
  583. }
  584. function getStateMaster($stateId) {
  585. $queryStateMaster=mysql_query("SELECT Name FROM state WHERE id='".$stateId."' order by Name") or die(mysql_error());
  586. $fetchStateMaster=mysql_fetch_assoc($queryStateMaster);
  587. return $fetchStateMaster;
  588. }
  589. function getCityMaster($cityId) {
  590. $queryCityMaster=mysql_query("SELECT city_name FROM city_master WHERE city_id='".$cityId."' order by city_name") or die(mysql_error());
  591. $fetchCityMaster=mysql_fetch_assoc($queryCityMaster);
  592. return $fetchCityMaster;
  593. }
  594. function senderMail($sender=null,$receiver=null,$subject=null,$body=null) {
  595. $mailQry = "
  596. INSERT INTO sent_mails(user_id, reciever_id, email_subject, email_body)
  597. VALUES(".$sender.", ".$receiver.", '".$subject."', '".addslashes($body)."')";
  598. $sentMailUpdate = mysql_query($mailQry) or die("1 - ".mysql_error());
  599. }
  600. function receiverMail($receiver=null,$sender=null,$subject=null,$body=null) {
  601. $eMailQry = "
  602. INSERT INTO
  603. emails(user_id, email_creater, email_subject, email_body)
  604. VALUES(".$receiver.", ".$sender.", '".$subject."', '".addslashes($body)."')";
  605. $inboxUpdate = mysql_query($eMailQry) or die("2 - ".mysql_error());
  606. }
  607. ############################ home page slide ######################
  608. function homepageslideInfo($catName=null) {
  609. //$catName = 'Projects';
  610. $selectTextimg = " SELECT * FROM homepage_texts where category='".$catName."'";
  611. $categorysql_res = mysql_query($selectTextimg);
  612. $categorysql_num = mysql_num_rows($categorysql_res);
  613. if($categorysql_num>0) {
  614. $listarr=array();
  615. while($categorysql_array = mysql_fetch_array($categorysql_res)) {
  616. $listarr[]=array('categoryName'=>$categorysql_array['category'],'helpimage'=>$categorysql_array['helpimage'],'helptitle'=>$categorysql_array['helptitle'],'helpdescription'=>$categorysql_array['helpdescription'],'morelink'=>$categorysql_array['morelink']) ;
  617. }
  618. $this->set('slideInfo',$listarr);
  619. }
  620. $this->set('slideNumber',$categorysql_num);
  621. $this->set('categoryslide',$catName);
  622. }
  623. ##################################################################
  624. ##################################################################
  625. ###### FOR INAPPROPRIATE URL ######
  626. function verifyserverUrl($txturl=NULL) {
  627. if($txturl) {
  628. $selectUrl = "SELECT * from report_abuse where abuse_url='".$txturl."' and admin_block='1' ";
  629. $selectUrl_res = mysql_query($selectUrl);
  630. if(mysql_num_rows($selectUrl_res)>0) {
  631. $this->redirect('/error');
  632. }
  633. }
  634. }
  635. ###############################
  636. }
  637. ?>