PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/findstudent_test.php

https://bitbucket.org/itoxable/chiron-gaming
PHP | 173 lines | 138 code | 20 blank | 15 comment | 41 complexity | 016f942c45426bb7457a57a8308d5353 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  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. $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. $game_id = $_REQUEST['game_id'];
  25. $availability = $_REQUEST['availability'];
  26. $language_id = $_REQUEST['language_id'];
  27. $price = $_REQUEST['price'];
  28. if($price == '')
  29. $price = '0;100';
  30. if($game_id == '')
  31. $game_id =array();
  32. if($availability == '')
  33. $availability = array();
  34. if($language_id == '')
  35. $language_id = array();
  36. if(count($game_id)>0&& is_array($game_id)&& !empty($game_id))
  37. {
  38. $game_ids = implode(',',$game_id);
  39. $smarty->assign('games',$game_ids);
  40. $sqlPart .= " AND ug.game_id IN($game_ids) AND ug.user_id=u.user_id";
  41. }
  42. if(count($language_id)>0&& is_array($language_id)&& !empty($language_id))
  43. {
  44. $language_ids = implode(',',$language_id);
  45. $smarty->assign('languages',$language_ids);
  46. foreach($language_id as $val)
  47. $sqlPart .= " AND FIND_IN_SET($val,u.language_ids)";
  48. }
  49. if(!empty($price))
  50. {
  51. $price_range = explode(";",$price);
  52. $min_price = $price_range[0];
  53. $max_price = $price_range[1];
  54. if($min_price == '0' && $max_price == '100')
  55. $sqlPart .='';
  56. else if($min_price == '0' && $max_price <100)
  57. $sqlPart .=" AND u.rate <='$max_price'";
  58. else if($min_price >'0' && $max_price == '100')
  59. $sqlPart .=" AND u.rate >='$min_price'";
  60. else
  61. $sqlPart .=" AND u.rate BETWEEN '$min_price' AND '$max_price'";
  62. }
  63. if(count($availability)>0&& is_array($availability)&& !empty($availability))
  64. {
  65. $availabilitys = implode(',',$availability);
  66. $smarty->assign('availabilitys',$availabilitys);
  67. for($v=0;$v<count($availability);$v++)
  68. {
  69. if($v==1)
  70. $Part .=" AND u.availability_type = '".$availability[$v]."'";
  71. else
  72. $Part .="u.availability_type = '".$availability[$v]."'";
  73. }
  74. $sqlPart .=" AND $Part";
  75. }
  76. if($IsProcess <> 'Y')
  77. {
  78. include "top.php";
  79. }
  80. $record_per_page = !empty($record_per_page)?$record_per_page:2;
  81. $paginationObj = new PaginationClassFrontAjax($record_per_page,4,1,'Next','Previous');
  82. function findlanguage($language_id)
  83. {
  84. if($language_id=='')
  85. return false;
  86. $SelectTypeSql = "SELECT language_name FROM ".TABLEPREFIX."_language WHERE language_id=$language_id";
  87. $SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
  88. return $SelectType[0];
  89. }
  90. function findvalue($table,$fld_name,$fld_value,$find_value)
  91. {
  92. if($fld_value=='')
  93. return false;
  94. $SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
  95. $SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
  96. return $SelectType[0];
  97. }
  98. $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." ORDER BY u.name ASC";
  99. $item_per_page_selected=6;
  100. $PaginationObjAjaxLatest=new PaginationClassAjax($item_per_page_selected,"prev",'',"next","active",$adodbcon);
  101. $pagination_arr = $PaginationObjAjaxLatest->PaginationAjax($SelectstudentSQL,$page_name."?action=".$action,"ManagerGeneral");
  102. $StudentArr=$UserManagerObjAjax->GetRecords("All",$pagination_arr[0]);
  103. //echo $pagination_arr[0];
  104. $NumStudent=count($StudentArr);
  105. for($i=0;$i<$NumStudent;$i++)
  106. {
  107. $StudentArr[$i]['name']=show_to_control($StudentArr[$i]['name']);
  108. $StudentArr[$i]['about']=show_to_control($StudentArr[$i]['user_about']);
  109. $slanguage = explode(",",$StudentArr[$i]['language_ids']);
  110. $language='';
  111. for($l=0;$l<count($slanguage);$l++)
  112. {
  113. if($slanguage[$l]<>'')
  114. $language .=findlanguage($slanguage[$l]).',';
  115. }
  116. $StudentArr[$i]['language']=substr($language,0,-1);
  117. $game='';
  118. $studentGame = "SELECT * FROM ".TABLEPREFIX."_user_game WHERE user_id='".$StudentArr[$i]['user_id']."'";
  119. $StudentGameArr = $UserManagerObjAjax->GetRecords("All",$studentGame);
  120. for($g=0;$g<count($StudentGameArr);$g++)
  121. {
  122. $game .= findvalue(TABLEPREFIX."_game","game_id",$StudentGameArr[$g]['game_id'],"game_name").",";
  123. }
  124. $StudentArr[$i]['game'] = substr($game,0,-1);
  125. if($StudentArr[$i]['availability_type'] == 'O')
  126. $StudentArr[$i]['availability_type'] = 'Online';
  127. if($StudentArr[$i]['availability_type'] == 'L')
  128. $StudentArr[$i]['availability_type'] = 'Local meet-up';
  129. }
  130. $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
  131. and u.is_active='Y'".$searchSql;
  132. $smarty->assign("IsProcess",$IsProcess);
  133. $smarty->assign("SearchTxt",$SearchTxt);
  134. $smarty->assign('catLink',$catLink);
  135. $smarty->assign('page_name',$page_name);
  136. $smarty->assign('record_per_page',$record_per_page);
  137. $smarty->assign('price',$price);
  138. $smarty->assign('language_id',$language_id);
  139. $smarty->assign('game_id',$game_id);
  140. $smarty->assign('availability',$availability);
  141. $smarty->assign("StudentArr",$StudentArr);
  142. $smarty->assign('pagination_arr',$pagination_arr);
  143. $smarty->assign("NumStudent",$NumStudent);
  144. $smarty->assign("totRec",$totRec);
  145. //$smarty->register_modifier("in_array","in_array");
  146. if($IsProcess <>'Y')
  147. include "student_leftpanel.php";
  148. $smarty->display('findstudent_test.tpl');
  149. if($IsProcess <> 'Y')
  150. include "footer.php";
  151. ?>