Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * ../../ext/pok4/magic_rows/ext.php
- *
- * @package default
- */
- namespace ext\pok4;
- use \PDO;
- if (count(get_included_files()) == 1) exit("Direct access not permitted."); //Don't edit
- //Your Extension Script
- class magic_rows extends \App\Controllers\BaseController {
- /**
- *
- */
- public function __construct() {
- parent::__construct();
- }
- /**
- *
- * @return unknown
- */
- public function custom_page() {
- if (strpos($_SERVER['REQUEST_URI'], '/pages/magic_rows') !== false) {
- //check for 24 hours is expired
- $user_id = $this->user_id; //user id
- $expired = "";//globalize
- $go = $this->db->query("SELECT expire FROM `".$this->argos_db_prefix."magic_rows` WHERE user_id='$user_id'");
- if($go->rowCount() > 0) {
- $row = $go->fetch(PDO::FETCH_ASSOC);
- if($row['expire'] > time()) {
- $expired = false;
- } else {
- $expired = true;
- }
- } else {
- $expired = true;
- }
- return $this->m->render(file_get_contents("ext/pok4/magic_rows/template/magic_rows.html"),
- [
- 'is_anony'=>$this->is_anonymous,
- 'ext_magic_rows_lang_reg_need'=>$this->lang['ext_magic_rows_lang_reg_need'],
- 'ext_magic_rows_lang_next24'=>$this->lang['ext_magic_rows_lang_next24'],
- 'ext_magic_rows_explain1'=>$this->lang['ext_magic_rows_explain1'],
- 'ext_magic_rows_explain2'=>$this->lang['ext_magic_rows_explain2'],
- 'ext_magic_rows_explain3'=>$this->lang['ext_magic_rows_explain3'],
- 'expired'=>$expired,
- ]);
- }
- }
- public function ajax() {
- if(is_ajax()) {
- $user_id = $this->user_id; //user id
- $username = $this->username;
- $expire = time() + 86400; //after 24 hours the user can roll again
- //if user is not in db, we insert him
- if(isset($_POST['add_to_db'])) {
- //select some info
- $go = $this->db->query("SELECT user_id FROM `".$this->argos_db_prefix."magic_rows` WHERE user_id='$user_id'");
- if($go->rowCount() < 1) {
- $this->db->query("INSERT INTO `".$this->argos_db_prefix."magic_rows` (user_id,expire) VALUES('$user_id','$expire')");
- }
- }
- //if user is in db and he roll 6, we add some credits
- if(isset($_POST['update_db']) && $_POST['update_db'] == 1) {
- //add +1 credit to this user
- $this->db->query("UPDATE `".$this->argos_db_prefix."members` SET credits=credits+1 WHERE user_id='$user_id'");
- //update magic rows db
- $this->db->query("UPDATE `".$this->argos_db_prefix."magic_rows` SET expire='$expire' WHERE user_id='$user_id'");
- //make log
- make_log("$username has row 6 and win","user");
- }
- else if(isset($_POST['update_db']) && $_POST['update_db'] == 2) {
- //update magic rows db, if user is not roll 6
- $this->db->query("UPDATE `".$this->argos_db_prefix."magic_rows` SET expire='$expire' WHERE user_id='$user_id'");
- }
- }
- }
- /**
- *
- */
- public function load() {
- if (strpos($_SERVER['REQUEST_URI'], '/pages/magic_rows') !== false) {
- $this->dispatcher->emit('core_event_inside_head_ready_front', [
- $this->m->render(file_get_contents("ext/pok4/magic_rows/template/magic_rows.js"),[
- 'ext_magic_row_set'=>$this->lang['ext_magic_row_set'],
- 'ext_magic_row_no_win'=>$this->lang['ext_magic_row_no_win'],
- 'ext_magic_row_you_win'=>$this->lang['ext_magic_row_you_win'],
- ])
- ]);
- $this->dispatcher->emit('core_event_head_append', ['<link rel="stylesheet" href="ext/pok4/magic_rows/css/magic_rows.css">']);
- }
- $this->dispatcher->emit('core_event_inside_custom_menu', [$this->custom_page()]);
- }
- };
- $load_ext = new magic_rows;
- $load_ext->load();
Advertisement
Add Comment
Please, Sign In to add comment