示例#1
0
 public function addmedia($parameter)
 {
     $media_type = $parameter[0];
     $this->data['media_type'] = $media_type;
     $this->data['album_categories'] = $this->category_model->get(array('category_slug' => 'album'));
     $category = $this->category_model->getColRow('category_title', $media_type);
     $this->data['title'] = 'Add ' . ucfirst($media_type);
     if (isset($_POST['title']) && !empty($_POST['title'])) {
         $title = $_POST['title'];
         $artist = $_POST['artist'];
         $description = $_POST['description'];
         $youtubelink = $_POST['youtubelink'];
         $category_id = $_POST['category'];
         // $status_id = $status->status_id;
         $slug = \helpers\url::generateSafeSlug($title);
         if (isset($youtubelink) && $youtubelink != '') {
             $exp = explode('=', $youtubelink);
             if (count($exp) > 1) {
                 $youtubelink = $exp[1];
             }
         }
         $insert_array = array('album_item_album_id' => \helpers\session::get('user')->user_album_id, 'album_item_category_id' => $category->category_id, 'album_item_user_id' => \helpers\session::get('user')->user_id, 'album_item_title' => $title, 'album_item_artist' => $artist, 'album_item_description' => $description, 'album_item_youtubelink' => $youtubelink, 'album_item_created' => time(), 'album_item_alias' => $slug);
         $insert_array = \helpers\gump::xss_clean($insert_array);
         $insert_array = \helpers\gump::sanitize($insert_array);
         $insert_id = $this->albumitem_model->create($insert_array);
         if ($insert_id > 0) {
             $message = 'ok';
         } else {
             $message = 'no';
         }
         //check if item is a video
         // $category_type = $this->category_model->find($_POST['category']);
         if ($media_type == 'video' && isset($youtubelink) && $youtubelink != '') {
             $youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/maxresdefault.jpg";
             if (!file_exists($youtube_url)) {
                 $youtube_url = "https://i.ytimg.com/vi/" . $youtubelink . "/hqdefault.jpg";
             }
             //resize youtube image into uploads folder
             \helpers\upload::setName(time());
             \helpers\upload::resizeUrl($youtube_url, UPLOAD_PATH, '480px');
             $image_name = \helpers\upload::getFileName('images');
             $update_data = array('album_item_file' => $image_name);
             $where_array = array('album_item_id' => $insert_id);
             $this->albumitem_model->update($update_data, $where_array);
         }
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             \helpers\upload::setName(uniqid());
             \helpers\upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '480px');
             $image_name = \helpers\upload::getFileName('images');
             $update_data = array('album_item_file' => $image_name);
             $where_array = array('album_item_id' => $insert_id);
             $this->albumitem_model->update($update_data, $where_array);
         }
     }
     if ($message == 'ok') {
         \helpers\session::set('success', 'record edited');
         $url = 'user/' . $media_type;
         \helpers\url::redirect($url);
     } else {
         if ($message == 'no') {
             $this->data['error'] = 'Operation Fails!';
         }
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('mobile-menu', $this->data);
     View::render('user/user.media', $this->data);
     View::rendertemplate('footer', $this->data);
 }
示例#2
0
 public function add()
 {
     $action = $_GET['action'];
     $sms_model = new \models\sms();
     $smsgroup_model = new \models\smsgroup();
     $this->data['groups'] = $smsgroup_model->all();
     $this->data['title'] = 'SMS';
     if (isset($_GET['edit'])) {
         $find_id = $_GET['ed_id'];
     }
     if (isset($_POST) && !empty($_POST)) {
         $group_id = $_POST['group_id'];
         if (!empty($_POST['firstname']) && !empty($_POST['lastname'])) {
             $firstname = $_POST['firstname'];
             $lastname = $_POST['lastname'];
             $phone = $_POST['phone'];
             $insert_single_sms_array = array('group_id' => $group_id, 'firstname' => $firstname, 'lastname' => $lastname, 'phone' => $phone);
             if (isset($_GET['edit'])) {
                 // EDIT OLD RECORD
                 // $update_sms_array = array('');
                 $where_sms_array = array('id' => $_GET['ed_id']);
                 $update_sms = $sms_model->update($insert_single_sms_array, $where_sms_array);
                 $find_id = $_GET['ed_id'];
                 if ($update_sms > 0) {
                     $this->data['success'] = 'Record edited successfully!';
                 } else {
                     $this->data['error'] = 'Operation Fails';
                 }
             } else {
                 $insert_single_sms_id = $sms_model->create($insert_single_sms_array);
                 if ($insert_single_sms_id > 0) {
                     $this->data['success'] = 'Record added successfully!';
                 } else {
                     $this->data['error'] = 'Operation Fails';
                 }
                 $find_id = $insert_single_sms_id;
             }
         }
         if (isset($_FILES) && !empty($_FILES)) {
             if ($_FILES["excel"]["tmp_name"] != '') {
                 //upload excel into uploads folder
                 \helpers\upload::setName(uniqid());
                 \helpers\upload::upload_file($_FILES["excel"], EXCEL_PATH);
                 // $exc = APPPATH.DS.'nfiu.xls';
                 $excelpath = EXCEL_PATH . \helpers\upload::$filename;
                 $excel_reader = new \helpers\excel\Excel_reader();
                 $excel_reader->setOutputEncoding('CP1251');
                 $excel_reader->read($excelpath);
                 // Get the contents of the first worksheet
                 $worksheet = $excel_reader->sheets[0];
                 $numRows = $worksheet['numRows'];
                 // ex: 14
                 $numCols = $worksheet['numCols'];
                 // ex: 4
                 $cells = $worksheet['cells'];
                 // the 1st row are usually the field's name
                 //ADD 1 TO numRows
                 $loop_rows = 1 + $numRows;
                 $i = 2;
                 while ($i < $loop_rows) {
                     $firstname = $cells[$i][1];
                     $lastname = $cells[$i][2];
                     $phone = $cells[$i][3];
                     $insert_array = array('group' => $group, 'firstname' => $firstname, 'lastname' => $lastname, 'phone' => $phone);
                     $insert_sms_id = $sms_model->create($insert_array);
                     //INCREMENT COUNTER
                     $i++;
                 }
                 if ($insert_sms_id > 0) {
                     $this->data['success'] = 'Excel Uploaded successfully!';
                 } else {
                     $this->data['error'] = 'Operation Fails';
                 }
             }
             //CLOSE FILE UPLOAD SCRIPT
         }
     }
     $this->data['smsdata'] = $sms_model->find($find_id);
     View::rendertemplate('home_header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('sms/sms.addphone', $this->data);
     View::rendertemplate('footer', $this->data);
 }
示例#3
0
 public function edituser($param)
 {
     $edit_id = $param[0];
     $user = new \models\users();
     $user_roles = new \models\roles();
     $this->data['groups'] = $user->userByrole('group');
     $this->data['user_roles'] = $user_roles->all();
     if (isset($_POST) && !empty($_POST)) {
         $fname = $_POST['fname'];
         $lname = $_POST['lname'];
         $gender = $_POST['gender'];
         $email = $_POST['email'];
         $phone = $_POST['phone'];
         $password = md5('pass');
         $institution = $_POST['institution'];
         $role = $_POST['role'];
         $groupid = $_POST['groupid'];
         if ($groupid == '') {
             $groupid = 0;
         }
         $update_array = array('firstname' => $fname, 'lastname' => $lname, 'email' => $email, 'phone' => $phone, 'password' => $password, 'institution' => $institution, 'role' => $role, 'groupid' => $groupid);
         $where_array = array('id' => $edit_id);
         $update_id = $user->update($update_array, $where_array);
         if ($update_id > 0) {
             $this->data['success'] = 'User Edited!';
         } else {
             $this->data['error'] = 'Operation Fails!';
         }
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             \helpers\upload::setName(uniqid());
             \helpers\upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $image_name = 'gallery/' . \helpers\upload::$filename;
             $update_data = array('image' => $image_name);
             $user->update($update_data, $where_array);
         }
         //GET INSERTED ID
     }
     $this->data['user_data'] = $user->find($edit_id);
     View::rendertemplate('home_header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('dashboard/adduser', $this->data);
     View::rendertemplate('footer', $this->data);
 }
示例#4
0
 public function edit($param)
 {
     $edit_id = $param[0];
     $this->data['title'] = 'Edit Settings';
     if (isset($_POST) && !empty($_POST)) {
         $title = $_POST['title'];
         $value = $_POST['value'];
         $slug = \helpers\url::generateSafeSlug($title);
         $update_array = array('site_preference' => $title, 'site_value' => $value);
         // $update_id = $settings->update($update_array,array('id'=>$edit_id));
         $update_id = $this->site_model->updateId($update_array, $edit_id);
         if ($update_id > 0) {
             $this->data['success'] = 'Record Updated!';
         } else {
             ${$this}->data['error'] = 'Operation Fails!';
         }
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             \helpers\upload::setName(time());
             \helpers\upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $image_name = \helpers\upload::getFileName('images');
             $update_data = array('site_file' => $image_name);
             $update_id = $this->site_model->updateId($update_data, $edit_id);
             if ($update_id > 0) {
                 $this->data['success'] = 'Record Updated!';
             } else {
                 ${$this}->data['error'] = 'Operation Fails!';
             }
         }
     }
     $this->data['site_data'] = $this->site_model->find($edit_id);
     $this->data['settings'] = $this->site_model->all();
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('settings/settings.index', $this->data);
     View::rendertemplate('footer', $this->data);
 }
示例#5
0
 public function pageedit($param)
 {
     $edit_id = $param[0];
     //INITIALIZE MODEL
     $newsletterpage_model = new \models\newsletterpage();
     $this->data['title'] = 'Newsletter Page: Edit';
     if (isset($_POST) && !empty($_POST)) {
         //PAGE DATA
         $author = $_POST['author'];
         $title = $_POST['title'];
         $content = $_POST['content'];
         $meta_keywords = $_POST['meta_keywords'];
         $meta_title = $_POST['meta_title'];
         $meta_description = $_POST['meta_description'];
         $sort_order = $_POST['sort_order'];
         $slug = \helpers\url::generateSafeSlug($title);
         $update_array = array('author' => $author, 'title' => $title, 'content' => $content, 'meta_keywords' => $meta_keywords, 'meta_title' => $meta_title, 'meta_description' => $meta_description, 'sort_order' => $sort_order, 'slug' => $slug);
         $where_array = array('id' => $edit_id);
         $update_id = $newsletterpage_model->update($update_array, $where_array);
         //UPLOAD IMAGE
         if ($_FILES["image"]["tmp_name"] != '') {
             \helpers\upload::setName($slug . uniqid());
             \helpers\upload::upload_file($_FILES["image"], UPLOAD_PATH);
             $image_name = 'gallery/' . \helpers\upload::$filename;
             $update_data = array('image' => $image_name);
             $update = $newsletterpage_model->update($update_data, $where_array);
         }
         if ($update_id > 0) {
             $this->data['success'] = 'page edited!';
         } else {
             $this->data['error'] = 'operation Fails!';
         }
     }
     $this->data['page_data'] = $newsletterpage_model->find($edit_id);
     View::rendertemplate('home_header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('newsletter/newsletter.pageedit', $this->data);
     View::rendertemplate('footer', $this->data);
 }