| 1 | <?php |
| 2 | switch($SUBPATH[0]) { |
| 3 | default: case 1: |
| 4 | $result = $this->db->safe_query_fetch("SELECT * FROM `lock`;"); |
| 5 | if(empty($result)) { |
| 6 | echo 'Not locked...'; |
| 7 | $user=$this->db->auth->get_user_id(); |
| 8 | $username=$this->db->auth->get_username_by_id($user); |
| 9 | echo $this->html->form("$URL/2", 'POST', array( |
| 10 | array('reason',$username,'textarea',false,'autofocus','reason:'), |
| 11 | array('lock','lock','submit') |
| 12 | )); |
| 13 | } else { |
| 14 | echo $this->html->render_item_table($result); |
| 15 | echo $this->html->form("$URL/2", 'POST', array( |
| 16 | array('unlock','unlock','submit') |
| 17 | )); |
| 18 | } |
| 19 | |
| 20 | break; |
| 21 | case 2: |
| 22 | if(isset($_POST['lock'])) { |
| 23 | $lock = $this->db->quote($_POST['reason']); |
| 24 | $this->db->safe_query("INSERT INTO `lock` (lock_name) VALUES ($lock);"); |
| 25 | $this->post_redirect_get("$URL_INTERNAL/1", T('Lock set')); |
| 26 | } |
| 27 | if(isset($_POST['unlock'])) { |
| 28 | $this->db->safe_query("TRUNCATE TABLE `lock`;"); |
| 29 | $this->post_redirect_get("$URL_INTERNAL/1", T('Lock unset')); |
| 30 | } |
| 31 | $this->post_redirect_get("$URL_INTERNAL/1","Lock: No value passed!", true); |
| 32 | break; |
| 33 | } |