?
Current Path : /home1/savoy/www/savoyeducation.com/Backup23-11-16/backup/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/www/savoyeducation.com/Backup23-11-16/backup/application/models/adminmodel.php |
<?php class Adminmodel extends CI_Model { function __construct() { parent::__construct(); } function authenticate($username,$password) { $passwordmd5=md5($password); $query= $this->db->query("select * from user where username='$username' and password='$passwordmd5'"); $data['numrows']=$query->num_rows(); if($query->num_rows()>0) { $result= $query->row(); $data['userid']= $result->user_id; $data['username']=$username; return $data; } else return 0; } function add_news($postdata) { $this->db->trans_begin(); $tbl1Values=array('news_title'=>$postdata['news_title'], 'news_content'=>$postdata['news_content'], 'news_date'=>$postdata['news_date'], 'news_file'=>$postdata['attach_news'] ); $this->db->insert('news', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; return $data; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function update_news($postdata) { $this->db->trans_begin(); $tbl1Values=array('news_title'=>$postdata['news_title'], 'news_content'=>$postdata['news_content'], 'news_date'=>$postdata['news_date'], ); $this->db->where('news_id', $postdata['news_id']); $this->db->update('news', $tbl1Values); if($postdata['attach_news']!='') { $tbl1Values=array('news_file'=>$postdata['attach_news'], ); $this->db->where('news_id', $postdata['news_id']); $this->db->update('news', $tbl1Values); } if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; return $data; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function add_gallery($postdata) { $this->db->trans_begin(); $this->db->query("update gallery set `sort`=`sort`+1 where `sort`>=".$postdata['sort']); $tbl1Values=array('thumbnail'=>$postdata['filename'], 'image'=>$postdata['filename'], 'title'=>$postdata['title'], 'sort'=>$postdata['sort'], 'directory_id'=>$postdata['directory_id'], ); $this->db->insert('gallery', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; return $data; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function add_folder($postdata) { $this->db->trans_begin(); $this->db->query("update directory set `sort`=`sort`+1 where `sort`>=".$postdata['sort']); $tbl1Values=array('directory_name'=>$postdata['directory_name'], 'directory_image'=>$postdata['directory_image'], 'sort'=>$postdata['sort'], ); $this->db->insert('directory', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; return $data; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function update_gallery($postdata) { $this->db->trans_begin(); if($postdata['actsort']<$postdata['sort']) { $this->db->query("update gallery set `sort`=`sort`-1 where `sort`>".$postdata['actsort']." and `sort`<=".$postdata['sort']); } else { $this->db->query("update gallery set `sort`=`sort`+1 where `sort`<".$postdata['actsort']." and `sort`>=".$postdata['sort']); } $tbl1Values=array( 'title'=>$postdata['title'], 'sort'=>$postdata['sort'], 'directory_id'=>$postdata['directory_id'], ); $this->db->where('id', $postdata['id']); $this->db->update('gallery', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; return $data; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function update_folder($postdata) { $this->db->trans_begin(); if($postdata['actsort']<$postdata['sort']) { $this->db->query("update directory set `sort`=`sort`-1 where `sort`>".$postdata['actsort']." and `sort`<=".$postdata['sort']); } else { $this->db->query("update directory set `sort`=`sort`+1 where `sort`<".$postdata['actsort']." and `sort`>=".$postdata['sort']); } $tbl1Values=array( 'directory_name'=>$postdata['directory_name'], 'sort'=>$postdata['sort'], ); $this->db->where('directory_id', $postdata['directory_id']); $this->db->update('directory', $tbl1Values); if($postdata['directory_image']!='') { $tbl1Values=array( 'directory_image'=>$postdata['directory_image'], ); $this->db->where('directory_id', $postdata['directory_id']); $this->db->update('directory', $tbl1Values); } if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; return $data; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function update_password($postdata) { $tbl1Values=array('password'=>md5($postdata['password'])); $this->db->where('user_id', '1'); $this->db->update('user', $tbl1Values); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } } ?>