/findstudent.php

https://bitbucket.org/itoxable/chiron-gaming · PHP · 212 lines · 170 code · 25 blank · 17 comment · 46 complexity · 5468042dbf05eab3442f7a6734002f3c MD5 · raw file

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