PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/findstudent2.php

https://bitbucket.org/itoxable/chiron-gaming
PHP | 226 lines | 177 code | 29 blank | 20 comment | 48 complexity | f15dd6441c919d1b4035a87bc529ab61 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?php
  2. /*include("general_include.php");
  3. $action_arr=array("list_order","list_search","list_paginate");
  4. if(in_array($action,$action_arr))
  5. {
  6. $IsProcess = 'Y';
  7. $smarty->assign('IsProcess',"Y");
  8. }
  9. if($IsProcess <> 'Y')
  10. include "top.php";
  11. $page_name='findstudent.php';
  12. $action=$_REQUEST['action'];
  13. */
  14. $page_name=basename($_SERVER['SCRIPT_FILENAME']);
  15. $IsPreserved = 'Y';
  16. $IsProcess = $_REQUEST['IsProcess'];
  17. $action = $_REQUEST['action'];
  18. $action_arr = array("getSrchResult");
  19. if(in_array($action,$action_arr))
  20. {
  21. $IsProcess = 'Y';
  22. }
  23. include "general_include.php";
  24. $sort_by = $_REQUEST['sorting_by'];
  25. $list_for = $_REQUEST['list_for'];
  26. $availability_country = $_REQUEST['availability_country'];
  27. $game_id = $_REQUEST['game_id'];
  28. $availability = $_REQUEST['availability'];
  29. $language_id = $_REQUEST['language_id'];
  30. $price = $_REQUEST['price'];
  31. if($price == '')
  32. $price = '0;100';
  33. if($game_id == '')
  34. $game_id =array();
  35. if($availability == '')
  36. $availability = array();
  37. if($language_id == '')
  38. $language_id = array();
  39. if(count($game_id)>0&& is_array($game_id)&& !empty($game_id))
  40. {
  41. $game_ids = implode(',',$game_id);
  42. $smarty->assign('games',$game_ids);
  43. $sqlPart .= " AND ug.game_id IN($game_ids) AND ug.user_id=u.user_id";
  44. }
  45. if(count($language_id)>0&& is_array($language_id)&& !empty($language_id))
  46. {
  47. $language_ids = implode(',',$language_id);
  48. $smarty->assign('languages',$language_ids);
  49. foreach($language_id as $val)
  50. $sqlPart .= " AND FIND_IN_SET($val,u.language_ids)";
  51. }
  52. if(!empty($price))
  53. {
  54. $price_range = explode(";",$price);
  55. $min_price = $price_range[0];
  56. $max_price = $price_range[1];
  57. if($min_price == '0' && $max_price == '100')
  58. $sqlPart .='';
  59. else if($min_price == '0' && $max_price <100)
  60. $sqlPart .=" AND u.rate <='$max_price'";
  61. else if($min_price >'0' && $max_price == '100')
  62. $sqlPart .=" AND u.rate >='$min_price'";
  63. else
  64. $sqlPart .=" AND u.rate BETWEEN '$min_price' AND '$max_price'";
  65. }
  66. if(count($availability)>0&& is_array($availability)&& !empty($availability))
  67. {
  68. $availabilitys = implode(',',$availability);
  69. $smarty->assign('availabilitys',$availabilitys);
  70. foreach($availability as $val)
  71. $sqlPart .= " AND FIND_IN_SET('$val',u.availability_type)";
  72. }
  73. if(!empty($availability_country))
  74. {
  75. $sqlPart .= " AND u.availability_country ='$availability_country'";
  76. }
  77. if($IsProcess <> 'Y')
  78. {
  79. // include "top.php";
  80. }
  81. $record_per_page = !empty($record_per_page)?$record_per_page:15;
  82. $paginationObj = new PaginationClassFrontAjax($record_per_page,3,1,'Next','Previous');
  83. function findlanguage($language_id)
  84. {
  85. if($language_id=='')
  86. return false;
  87. $SelectTypeSql = "SELECT language_name FROM ".TABLEPREFIX."_language WHERE language_id=$language_id";
  88. $SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
  89. return $SelectType[0];
  90. }
  91. function findvalue($table,$fld_name,$fld_value,$find_value)
  92. {
  93. if($fld_value=='')
  94. return false;
  95. $SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
  96. $SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
  97. return $SelectType[0];
  98. }
  99. if($IsProcess != 'Y')
  100. {
  101. unset($_SESSION['sql']);
  102. unset($_SESSION['sort']);
  103. if($list_for == 'sorting')
  104. {
  105. $sortBy = explode('-',$sort_by);
  106. if($sortBy[0] == 'rate')
  107. {
  108. if($sortBy[1]=="DESC")
  109. $sqlPart.=" ORDER BY u.rate DESC";
  110. else
  111. $sqlPart.=" ORDER BY u.rate ASC";
  112. }
  113. }
  114. else
  115. $sqlPart.=" ORDER BY u.name ASC";
  116. $smarty->assign('sort_by',$sort_by);
  117. $_SESSION['sql'] = $sqlPart;
  118. $_SESSION['sort'] = $sort_by;
  119. $SelectstudentSQL="SELECT DISTINCT u.*,ur.user_id FROM ".TABLEPREFIX."_user u ,".TABLEPREFIX."_user_type_user_relation ur,".TABLEPREFIX."_user_game ug WHERE
  120. ur.user_type_id=2 AND ur.user_id=u.user_id AND u.is_active='Y'".$sqlPart;
  121. }
  122. else
  123. {
  124. $studentSQl = $_SESSION['sql'];
  125. $smarty->assign('sort_by',$_SESSION['sort']);
  126. $SelectstudentSQL="SELECT DISTINCT u.*,ur.user_id FROM ".TABLEPREFIX."_user u ,".TABLEPREFIX."_user_type_user_relation ur,".TABLEPREFIX."_user_game ug
  127. WHERE ur.user_type_id=2 AND ur.user_id=u.user_id AND u.is_active='Y'".$studentSQl;
  128. }
  129. $pagination_arr = $paginationObj->PaginationFrontAjaxALL('PaginationSearch',$SelectstudentSQL,$page_name.'?'.$catLink);
  130. $StudentArr=$UserManagerObjAjax->GetRecords("All",$pagination_arr[0]);
  131. //echo $pagination_arr[0];
  132. $NumStudent=count($StudentArr);
  133. for($i=0;$i<$NumStudent;$i++)
  134. {
  135. $StudentArr[$i]['name']=show_to_control($StudentArr[$i]['name']);
  136. $StudentArr[$i]['about']=show_to_control($StudentArr[$i]['user_about']);
  137. $slanguage = explode(",",$StudentArr[$i]['language_ids']);
  138. $language='';
  139. for($l=0;$l<count($slanguage);$l++)
  140. {
  141. if($slanguage[$l]<>'')
  142. $language .=findlanguage($slanguage[$l]).' , ';
  143. }
  144. $StudentArr[$i]['language']=substr($language,0,-2);
  145. //$game='';
  146. $StudentgameSql = "SELECT * FROM ".TABLEPREFIX."_user_game where user_id='".$StudentArr[$i]['user_id']."' and is_active='Y'";
  147. $StudentgameArr[$i] = $UserManagerObjAjax->GetRecords("All",$StudentgameSql);
  148. $Numstudentgame=count($StudentgameArr[$i]);
  149. for($g=0;$g<$NumStudentGame;$g++)
  150. {
  151. $StudentGameArr[$i][$g]['game'] = findvalue(TABLEPREFIX."_game","game_id",$StudentGameArr[$i][$g]['game_id'],"game_name");
  152. }
  153. //$game = findvalue(TABLEPREFIX."_game","game_id",$StudentArr[$i]['game_id'],"game_name");
  154. //$StudentArr[$i]['game'] = substr($game,0,-1);
  155. $avail_type = explode(',',$StudentArr[$i]['availability_type']);
  156. if($avail_type[1]=='')
  157. {
  158. if($avail_type[0]=='O')
  159. $StudentArr[$i]['availability_type'] = 'Online';
  160. if($avail_type[0]=='L')
  161. {
  162. $StudentArr[$i]['availability_type'] = 'Local meet-up';
  163. $StudentArr[$i]['avail_local'] = 'Y';
  164. }
  165. }
  166. else
  167. {
  168. $StudentArr[$i]['availability_type'] = 'Online , Local meet-up';
  169. $StudentArr[$i]['avail_local'] = 'Y';
  170. }
  171. $StudentArr[$i]['availability_country'] = findvalue(TABLEPREFIX."_country","country_id",$StudentArr[$i]['availability_country'],"country_name");
  172. }
  173. $studentSql="SELECT u.*,ur.* FROM ".TABLEPREFIX."_user u ,".TABLEPREFIX."_user_type_user_relation ur WHERE ur.user_type_id=2 and ur.user_id=u.user_id
  174. and u.is_active='Y'".$searchSql;
  175. $smarty->assign('IsProcess',$IsProcess);
  176. $smarty->assign('SearchTxt',$SearchTxt);
  177. $smarty->assign('catLink',$catLink);
  178. $smarty->assign('page_name',$page_name);
  179. $smarty->assign('record_per_page',$record_per_page);
  180. $smarty->assign('price',$price);
  181. $smarty->assign('language_id',$language_id);
  182. $smarty->assign('game_id',$game_id);
  183. $smarty->assign('availability',$availability);
  184. $smarty->assign('availability_country',$availability_country);
  185. $smarty->assign('StudentArr',$StudentArr);
  186. $smarty->assign('pagination_arr',$pagination_arr);
  187. $smarty->assign('NumStudent',$NumStudent);
  188. $smarty->assign('NumStudentGame',$NumStudentGame);
  189. $smarty->assign('StudentGameArr',$StudentGameArr);
  190. $smarty->assign('totRec',$totRec);
  191. //$smarty->register_modifier("in_array","in_array");
  192. if($IsProcess <>'Y')
  193. include "student_leftpanel.php";
  194. $smarty->display('findstudent.tpl');
  195. //if($IsProcess <> 'Y') include "footer.php";
  196. ?>