hitcount.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /****************************
  3. * File : hitcount.php
  4. * Author : Cygnusa
  5. * @2018
  6. ****************************/
  7. //SECURITY
  8. if ( ! defined('APPLICATION_PATH')) exit('No direct script access allowed');
  9. class hitcount
  10. {
  11. //FUNCTION LISTS
  12. function __construct($parent)
  13. {
  14. //GET PAGE MESSAGE
  15. $this->page_data=globalfunc::getMessage($parent,$parent->lang,'hitcount');
  16. if(count($parent->params)==0)
  17. {
  18. $this->hitcountfunc($parent);
  19. }
  20. $parent->response(array('response'=>'failed', 'message' => 'PAGE NOT FOUND'), 404);
  21. }
  22. /* /////////////////////////////// HITCOUNT LIST //////////////////////////////////////////////// */
  23. private function hitcountfunc($parent)
  24. {
  25. globalfunc::checkMethodType($parent,array('POST'));
  26. globalfunc::checkParamCount($parent,0);
  27. globalfunc::checkAuthrozation($parent,array('type'=>'user'));
  28. //FIELDS VALIDATION
  29. $REQUEST_KEYS=array('page'=>'string');
  30. globalfunc::mandatoryKey($parent,$REQUEST_KEYS);
  31. $page= escape_str($parent->_request["page"]);
  32. $cateid= escape_str($parent->_request["cateid"]);
  33. $assettopicid= escape_str($parent->_request["assettopicid"]);
  34. $contentid= escape_str($parent->_request["contentid"]);
  35. $viewtime= escape_str($parent->_request["viewtime"]);
  36. //if($parent->current_user_role>'7' && $parent->current_user_role!='14' && $parent->current_user_role!='16')
  37. if(in_array($parent->current_user_role, $parent->dse_roles))
  38. {
  39. if(strtolower($page)=='learning')
  40. {
  41. if($contentid!='')
  42. {
  43. $query_str="SELECT c.assettopicid,ca.cateid FROM `".TABLE_ASSET_CONTENT."` as c JOIN ".TABLE_ASSET_TOPIC." as t ON c.assettopicid=t.assettopicid JOIN ".TABLE_CATEGORY." as ca ON ca.cateid=t.cateid WHERE c.contentid ='".$contentid."' LIMIT 1";
  44. $query_arr=$parent->getQueryValue($query_str);
  45. if(count($query_arr)>0)
  46. {
  47. $cateid=$query_arr[0]->cateid;
  48. $assettopicid=$query_arr[0]->assettopicid;
  49. }
  50. }
  51. }
  52. //RESULT INSERT
  53. $parent->executeQuery("INSERT INTO ".TABLE_USER_ACCESSCOUNT." (device_type, `smpin`, `page`, `cateid`, `assettopicid`, `contentid`, `viewtime`, `created_on` )VALUES('".$parent->device_type."', '".$parent->current_user_data->smpin."','".$page."','".$cateid."', '".$assettopicid."', '".$contentid."', '".$viewtime."','".NOW."')");
  54. } else
  55. {
  56. if(strtolower($page)=='learning')
  57. {
  58. if($contentid!='')
  59. {
  60. $query_str="SELECT c.assettopicid,ca.cateid FROM `".TABLE_ASSET_CONTENT."` as c JOIN ".TABLE_ASSET_TOPIC." as t ON c.assettopicid=t.assettopicid JOIN ".TABLE_CATEGORY." as ca ON ca.cateid=t.cateid WHERE c.contentid ='".$contentid."' LIMIT 1";
  61. $query_arr=$parent->getQueryValue($query_str);
  62. if(count($query_arr)>0)
  63. {
  64. $cateid=$query_arr[0]->cateid;
  65. $assettopicid=$query_arr[0]->assettopicid;
  66. }
  67. }
  68. }
  69. //RESULT INSERT
  70. $parent->executeQuery("INSERT INTO ".TABLE_USER_ACCESSCOUNT." (device_type, `emp_code`, `page`, `cateid`, `assettopicid`, `contentid`, `viewtime`, `created_on` )VALUES('".$parent->device_type."', '".$parent->current_user_data->emp_code."','".$page."','".$cateid."', '".$assettopicid."', '".$contentid."', '".$viewtime."','".NOW."')");
  71. }
  72. $parent->response(array('response'=>'success' ,'message'=>$this->page_data['success1']),200);
  73. }
  74. /* //////////////////////////////////////////////////////////////////////////////////////////// */
  75. }
  76. ?>