| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- class admin_boxes_model extends Model {
-
-
- public function getBoxes() {
- $result = $this->query("select * from azonics_boxes where box_status<>'0';");
- return $result;
- }
-
-
- public function loadBox() {
- $box_id = $this->escapeString($_REQUEST['id']);
- $row = $this->query("select * from azonics_boxes where box_id='".$box_id."';");
- return $row[0];
- }
-
-
- public function saveBox() {
- $data = $this->escapeArray($_REQUEST);
-
- if ($data['box_id']!='') {
- if ($_FILES['box_banner']['tmp_name']!=='') {
- $fname = 'banner_'.time().'.jpg';
- $path = 'static/uploads/thumbs/';
- move_uploaded_file($_FILES['box_banner']['tmp_name'],$path.$fname);
- $this->execute("UPDATE azonics_boxes SET box_banner='".$path.$fname."' WHERE box_id='".$data['box_id']."';");
- }
- $this->execute("update azonics_boxes set "
- . "box_title='".$data['box_title']."', "
- . "box_subtitle='".$data['box_subtitle']."', "
- . "box_subtitle_en='".$data['box_subtitle_en']."', "
- . "box_button_text='".$data['box_button_text']."', "
- . "box_url='".$data['box_url']."' "
- . "where box_id='".$data['box_id']."';");
-
- return true;
- }
- else {
- if ($_FILES['box_banner']['tmp_name']!=='') {
- $fname = 'banner_'.time().'.jpg';
- $path = 'static/uploads/thumbs/';
- move_uploaded_file($_FILES['box_banner']['tmp_name'],$path.$fname);
- }
- $this->execute("insert into azonics_boxes set "
- . "box_title='".$data['box_title']."', "
- . "box_subtitle='".$data['box_subtitle']."', "
- . "box_subtitle_en='".$data['box_subtitle_en']."', "
- . "box_button_text='".$data['box_button_text']."', "
- . "box_url='".$data['box_url']."', "
- . "box_status='1', box_banner='".$path.$fname."', "
- . "box_user='".$_SESSION['admin_user']->admin_id."';");
- return true;
- }
- }
-
-
- public function deleteBox() {
- $box_id = $this->escapeString($_REQUEST['id']);
- $this->execute("update azonics_boxes set box_status='0' where box_id='".$box_id."';");
- return true;
- }
-
-
- }
|