Guest User

Untitled

a guest
Apr 5th, 2022
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <?php
  2. /**
  3. * ../../ext/pok4/magic_rows/ext.php
  4. *
  5. * @package default
  6. */
  7. namespace ext\pok4;
  8. use \PDO;
  9. if (count(get_included_files()) == 1) exit("Direct access not permitted."); //Don't edit
  10. //Your Extension Script
  11. class magic_rows extends \App\Controllers\BaseController {
  12.  
  13.  
  14.  
  15. /**
  16. *
  17. */
  18. public function __construct() {
  19. parent::__construct();
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26. /**
  27. *
  28. * @return unknown
  29. */
  30. public function custom_page() {
  31.  
  32. if (strpos($_SERVER['REQUEST_URI'], '/pages/magic_rows') !== false) {
  33.  
  34. //check for 24 hours is expired
  35. $user_id = $this->user_id; //user id
  36. $expired = "";//globalize
  37. $go = $this->db->query("SELECT expire FROM `".$this->argos_db_prefix."magic_rows` WHERE user_id='$user_id'");
  38. if($go->rowCount() > 0) {
  39. $row = $go->fetch(PDO::FETCH_ASSOC);
  40. if($row['expire'] > time()) {
  41. $expired = false;
  42. } else {
  43. $expired = true;
  44. }
  45. } else {
  46. $expired = true;
  47. }
  48.  
  49.  
  50.  
  51. return $this->m->render(file_get_contents("ext/pok4/magic_rows/template/magic_rows.html"),
  52. [
  53. 'is_anony'=>$this->is_anonymous,
  54. 'ext_magic_rows_lang_reg_need'=>$this->lang['ext_magic_rows_lang_reg_need'],
  55. 'ext_magic_rows_lang_next24'=>$this->lang['ext_magic_rows_lang_next24'],
  56. 'ext_magic_rows_explain1'=>$this->lang['ext_magic_rows_explain1'],
  57. 'ext_magic_rows_explain2'=>$this->lang['ext_magic_rows_explain2'],
  58. 'ext_magic_rows_explain3'=>$this->lang['ext_magic_rows_explain3'],
  59. 'expired'=>$expired,
  60. ]);
  61. }
  62.  
  63. }
  64.  
  65. public function ajax() {
  66. if(is_ajax()) {
  67. $user_id = $this->user_id; //user id
  68. $username = $this->username;
  69. $expire = time() + 86400; //after 24 hours the user can roll again
  70. //if user is not in db, we insert him
  71. if(isset($_POST['add_to_db'])) {
  72.  
  73. //select some info
  74. $go = $this->db->query("SELECT user_id FROM `".$this->argos_db_prefix."magic_rows` WHERE user_id='$user_id'");
  75. if($go->rowCount() < 1) {
  76. $this->db->query("INSERT INTO `".$this->argos_db_prefix."magic_rows` (user_id,expire) VALUES('$user_id','$expire')");
  77. }
  78. }
  79.  
  80. //if user is in db and he roll 6, we add some credits
  81. if(isset($_POST['update_db']) && $_POST['update_db'] == 1) {
  82.  
  83. //add +1 credit to this user
  84. $this->db->query("UPDATE `".$this->argos_db_prefix."members` SET credits=credits+1 WHERE user_id='$user_id'");
  85.  
  86. //update magic rows db
  87. $this->db->query("UPDATE `".$this->argos_db_prefix."magic_rows` SET expire='$expire' WHERE user_id='$user_id'");
  88.  
  89. //make log
  90. make_log("$username has row 6 and win","user");
  91. }
  92. else if(isset($_POST['update_db']) && $_POST['update_db'] == 2) {
  93. //update magic rows db, if user is not roll 6
  94. $this->db->query("UPDATE `".$this->argos_db_prefix."magic_rows` SET expire='$expire' WHERE user_id='$user_id'");
  95. }
  96. }
  97.  
  98. }
  99.  
  100.  
  101. /**
  102. *
  103. */
  104. public function load() {
  105.  
  106. if (strpos($_SERVER['REQUEST_URI'], '/pages/magic_rows') !== false) {
  107. $this->dispatcher->emit('core_event_inside_head_ready_front', [
  108. $this->m->render(file_get_contents("ext/pok4/magic_rows/template/magic_rows.js"),[
  109. 'ext_magic_row_set'=>$this->lang['ext_magic_row_set'],
  110. 'ext_magic_row_no_win'=>$this->lang['ext_magic_row_no_win'],
  111. 'ext_magic_row_you_win'=>$this->lang['ext_magic_row_you_win'],
  112. ])
  113. ]);
  114. $this->dispatcher->emit('core_event_head_append', ['<link rel="stylesheet" href="ext/pok4/magic_rows/css/magic_rows.css">']);
  115. }
  116.  
  117. $this->dispatcher->emit('core_event_inside_custom_menu', [$this->custom_page()]);
  118.  
  119. }
  120.  
  121.  
  122. };
  123.  
  124. $load_ext = new magic_rows;
  125. $load_ext->load();
  126.  
Advertisement
Add Comment
Please, Sign In to add comment