Esempio n. 1
0
 /**
  * Edit potfolio of providers
  *
  * Returns all programmers rating reviews
  *
  * @access	private
  * @param	string
  * @return	string
  */
 function editPortfolio()
 {
     //language file
     $this->lang->load('enduser/editProfile', $this->config->item('language_code'));
     //Check For Buyer Session
     if (!isProgrammer()) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You must be logged in as a Programmer')));
         redirect('info');
     }
     //load validation libraray
     $this->load->library('form_validation');
     //Load Form Helper
     $this->load->helper('form');
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     //Get Form Data
     if ($this->input->post('editPortfolio')) {
         //Set rules
         //echo $_FILES['attachment1']['name'];exit;
         $this->form_validation->set_rules('title', 'lang:portfolio_title_validation', 'required|trim|xss_clean');
         $this->form_validation->set_rules('description', 'lang:portfolio_description_validation', 'required|trim|xss_clean');
         $this->form_validation->set_rules('categories[]', 'lang:portfolio_categories_validation', 'required');
         if ($_FILES['thumbnail']['name'] != '') {
             $this->form_validation->set_rules('thumbnail', 'lang:portfolio_thumbnail_validation', 'callback__thumbnail_check');
         }
         if ($_FILES['attachment1']['name'] != '') {
             $this->form_validation->set_rules('attachment1', 'lang:portfolio_attachment1_validation', 'callback__attachment1_check');
         }
         if ($_FILES['attachment2']['name'] != '') {
             $this->form_validation->set_rules('attachment2', 'lang:portfolio_attachment2_validation', 'callback__attachment2_check');
         }
         if ($this->form_validation->run()) {
             if (check_form_token() === false) {
                 $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('token_error')));
                 redirect('info');
             }
             //pr($this->outputData['file']);exit;
             $categories = $this->input->post('categories');
             $ids = implode(',', $categories);
             $updateData = array();
             $updateData['title'] = $this->input->post('title');
             $updateData['description'] = $this->input->post('description');
             $updateData['categories'] = $ids;
             $updateData['user_id'] = $this->loggedInUser->id;
             $condition2 = array('portfolio.id' => $this->input->post('portid'));
             $port = $this->user_model->getPortfolio($condition2);
             $folio = $port->row();
             $path = $this->config->item('basepath') . 'files/portfolios/';
             if (isset($this->outputData['file'])) {
                 $files = array($folio->main_img);
                 //delete image files from server
                 delete_file($path, $files);
                 $updateData['main_img'] = $this->outputData['file']['file_name'];
             }
             if (isset($this->outputData['file1'])) {
                 $files = array($folio->attachment1);
                 //delete image files from server
                 delete_file($path, $files);
                 $updateData['attachment1'] = $this->outputData['file1']['file_name'];
                 $thumb1 = $this->outputData['file1']['file_path'] . $this->outputData['file1']['raw_name'] . "_thumb" . $this->outputData['file1']['file_ext'];
                 //createthumb($this->outputData['file1']['full_path'],$thumb1,120,90);
                 GenerateThumbFile($this->outputData['file1']['full_path'], $thumb1, 120, 90);
                 //$this->skills_model->cr_thumb($this->outputData['file1']['full_path']);
             }
             if (isset($this->outputData['file2'])) {
                 $files = array($folio->attachment2);
                 //delete image files from server
                 delete_file($path, $files);
                 $updateData['attachment2'] = $this->outputData['file2']['file_name'];
                 $thumb2 = $this->outputData['file2']['file_path'] . $this->outputData['file2']['raw_name'] . "_thumb" . $this->outputData['file2']['file_ext'];
                 GenerateThumbFile($this->outputData['file2']['full_path'], $thumb2, 120, 90);
                 //$this->skills_model->cr_thumb($this->outputData['file2']['full_path']);
             }
             $updateKey = array('portfolio.id' => $this->input->post('portid'));
             //Edit Portfolio
             $this->user_model->updatePortfolio($updateKey, $updateData);
             //Notification message
             $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('provider_portfolio_success')));
             redirect('programmer/managePortfolio');
         }
         //Form Validation End
     }
     //If - Form Submission End
     //Get Categories
     $this->outputData['categories'] = $this->skills_model->getCategories();
     //Get Portfolio
     $condition = array('portfolio.user_id' => $this->loggedInUser->id);
     $this->outputData['portfolio'] = $this->user_model->getPortfolio($condition);
     $condition2 = array('portfolio.id' => $this->uri->segment(3));
     $this->outputData['editPortfolio'] = $this->user_model->getPortfolio($condition2);
     //Get Categories
     $this->outputData['categories'] = $this->skills_model->getCategories();
     //pr($this->outputData['getPortfolio']->result());exit;
     $this->load->view('programmer/managePorfolio', $this->outputData);
 }
Esempio n. 2
0
 public function userphoto()
 {
     $id = $this->uri->segment(3);
     $target_path = realpath(APPPATH . '../images/users');
     if (!is_dir(realpath(APPPATH . '../images/users') . '/' . $id)) {
         mkdir(realpath(APPPATH . '../images/users') . '/' . $id, 0777, true);
     }
     $target_path = $target_path . '/' . $id . '/userpic.jpg';
     if (move_uploaded_file($_FILES['upload123']['tmp_name'], $target_path)) {
     } else {
     }
     $thumb1 = realpath(APPPATH . '../images/users') . '/' . $id . '/userpic_thumb.jpg';
     GenerateThumbFile($target_path, $thumb1, 107, 78);
     $thumb2 = realpath(APPPATH . '../images/users') . '/' . $id . '/userpic_profile.jpg';
     GenerateThumbFile($target_path, $thumb2, 209, 209);
     redirect('/func/edituserprofile/' . $id, 'refresh');
 }
Esempio n. 3
0
 public function index($param = '')
 {
     //	$this->output->cache(3600);
     $title = $this->input->post('qtitle');
     $this->load->library('filter');
     $this->filter->filts($title, true);
     if ($title) {
         if ($this->uid) {
             $data['fUid'] = $this->uid;
             $data['title'] = $title;
             //$data['position'] = $this->input->post('position');
             $data['description'] = $this->input->post('qdes');
             $this->filter->filts($data['description'], true);
             //$data['sex'] = $this->input->post('sex');
             //$data['address'] = $this->input->post('address');
             //	$data['city'] = $this->input->post('city');
             //$data['toUid'] = "";
             $data['state'] = 1;
             $data['has_answer'] = 0;
             $data['cdate'] = time();
             $id = $this->common->insertData('wen_questions', $data);
             if (isset($_FILES['attachPic']['tmp_name']) && $_FILES['attachPic']['tmp_name'] && $id != 0) {
                 $target_path = realpath(APPPATH . '../upload');
                 //var_dump($target_path);die;
                 if (is_writable($target_path)) {
                     if (!is_dir($target_path . '/' . round($id / 1000))) {
                         mkdir($target_path . '/' . round($id / 1000), 0777, true);
                     }
                     $datas['name'] = time() . '.jpg';
                     $datas['savepath'] = round($id / 1000) . '/' . $datas['name'];
                     $target_path = $target_path . '/' . $datas['savepath'];
                     move_uploaded_file($_FILES['attachPic']['tmp_name'], $target_path);
                     GenerateThumbFile($target_path, $target_path, 550, 650);
                     $datas['userId'] = $this->uid;
                     $datas['uploadTime'] = time();
                     $datas['type'] = 'jpg';
                     $datas['private'] = 1;
                     $pictureid = $this->common->insertData('wen_attach', $datas);
                     $result['updatePictureState'] = '000';
                     $result['postState'] = '000';
                     $upicArr = array();
                     $upicArr[]['type'] = 'jpg';
                     $upicArr[]['id'] = $pictureid;
                     $wdata['uid'] = $this->uid;
                     $wdata['content'] = '';
                     $wdata['q_id'] = $id;
                     $wdata['type_data'] = serialize($upicArr);
                     $wdata['type'] = 4;
                     $wdata['ctime'] = time();
                     $this->common->insertData('wen_weibo', $wdata);
                 }
             }
             $this->session->set_flashdata('msg', $this->common->flash_message('sucess', '咨询已经发布!'));
             redirect('user/dashboard');
         } else {
             $this->session->set_flashdata('msg', $this->common->flash_message('error', '登入后才能发布咨询!'));
             redirect('user/login');
         }
     } else {
         $this->db->where('wen_questions.state', 1);
         $this->db->where('wen_answer.uid != ', "");
         $this->db->where('users.banned', 0);
         $this->db->select('wen_questions.title,wen_questions.id,wen_answer.uid,users.alias,users.alias,wen_answer.cdate,wen_questions.cdate,user_profile.company');
         $this->db->from('wen_questions');
         $this->db->join('wen_answer', 'wen_answer.qid = wen_questions.id', 'left');
         $this->db->join('users', 'wen_answer.uid = users.id', 'left');
         $this->db->join('user_profile', 'wen_answer.uid = user_profile.user_id', 'left');
         $this->db->order_by("wen_questions.id", "desc");
         $this->db->limit(5);
         //   Memcached::add('home','test');
         //  $data['results'] = $this->db->get()->result();
         if (!$this->uid) {
             foreach ($_COOKIE as $c_id => $c_value) {
                 setcookie($c_id, NULL, 1, "/", ".meilimei.name");
             }
         }
         $data['notlogin'] = $this->notlogin;
         $this->load->view('meili', $data);
     }
 }
Esempio n. 4
0
 /**
  * editProfile for both buyer and programmer for edit his profile
  *
  * @access	public
  * @param	nil
  * @return	void
  */
 function editProfile()
 {
     //language file
     $this->lang->load('enduser/editProfile', $this->config->item('language_code'));
     //Check Whether User Logged In Or Not
     if (!isset($this->loggedInUser->id)) {
         $this->session->set_flashdata('flash_message', $this->common_model->flash_message('error', $this->lang->line('You must be login access to this page')));
         redirect('info');
     }
     //load validation libraray
     $this->load->library('form_validation');
     //Load Form Helper
     $this->load->helper('form');
     //Intialize values for library and helpers
     $this->form_validation->set_error_delimiters($this->config->item('field_error_start_tag'), $this->config->item('field_error_end_tag'));
     if ($this->input->post('updateBuyerProfile', TRUE)) {
         //Set rules
         $this->form_validation->set_rules('logo', 'lang:logo_validation', 'callback__logo_check');
         $this->form_validation->set_rules('name', 'lang:programmer_name_validation', 'required|trim|min_length[5]|xss_clean');
         $this->form_validation->set_rules('email', 'Email', 'required|trim|min_length[5]|xss_clean');
         if ($this->form_validation->run()) {
             $updateData = array();
             if ($this->input->post('pwd', TRUE) != '') {
                 $updateData['password'] = md5($this->input->post('pwd', TRUE));
             }
             $updateData['name'] = $this->input->post('name', TRUE);
             $updateData['email'] = $this->input->post('email', TRUE);
             $updateData['profile_desc'] = $this->input->post('profile', TRUE);
             $updateData['project_notify'] = $this->input->post('notify_project', TRUE);
             $updateData['message_notify'] = $this->input->post('notify_message', TRUE);
             //echo $this->loggedInUser->logo;exit;
             if ($this->loggedInUser->logo != '' and isset($this->outputData['file']['file_name'])) {
                 $filepath = $this->config->item('basepath') . 'files/logos/' . $this->loggedInUser->logo;
                 //pr($this->outputData['file']);exit;
                 @unlink($filepath);
                 if (isset($this->outputData['file']['file_name'])) {
                     $updateData['logo'] = $this->outputData['file']['file_name'];
                     $thumb1 = $this->outputData['file']['file_path'] . $this->outputData['file']['raw_name'] . "_thumb" . $this->outputData['file']['file_ext'];
                     GenerateThumbFile($this->outputData['file']['full_path'], $thumb1, 49, 48);
                 }
             } else {
                 if (isset($this->outputData['file']['file_name'])) {
                     $updateData['logo'] = $this->outputData['file']['file_name'];
                     $thumb1 = $this->outputData['file']['file_path'] . $this->outputData['file']['raw_name'] . "_thumb" . $this->outputData['file']['file_ext'];
                     GenerateThumbFile($this->outputData['file']['full_path'], $thumb1, 49, 48);
                 }
             }
             $updateData['country_symbol'] = $this->input->post('country', TRUE);
             $updateData['state'] = $this->input->post('state', TRUE);
             $updateData['city'] = $this->input->post('city', TRUE);
             //Create User
             $updateKey = array('id' => $this->loggedInUser->id);
             $this->user_model->updateUser($updateKey, $updateData);
             $updateKey1 = array('users.activation_key' => $this->input->post('confirmKey'));
             $query = $this->user_model->getUsers($updateKey1);
             $row = $query->row();
             $userid = $row->id;
             $updateKey2 = array('user_contacts.user_id' => $this->loggedInUser->id);
             $query2 = $this->user_model->getUserContacts($updateKey2);
             $userDetails = $query2->row();
             if ($query2->num_rows() == 0) {
                 $insertData = array();
                 $insertData['user_id'] = $this->loggedInUser->id;
                 $insertData['msn'] = $this->input->post('contact_msn', TRUE);
                 $insertData['gtalk'] = $this->input->post('contact_gtalk', TRUE);
                 $insertData['yahoo'] = $this->input->post('contact_yahoo', TRUE);
                 $insertData['skype'] = $this->input->post('contact_skype', TRUE);
                 $this->user_model->insertUserContacts($insertData);
             } else {
                 //update data's in userContacts table
                 $userContacts['msn'] = $this->input->post('contact_msn', TRUE);
                 $userContacts['gtalk'] = $this->input->post('contact_gtalk', TRUE);
                 $userContacts['yahoo'] = $this->input->post('contact_yahoo', TRUE);
                 $userContacts['skype'] = $this->input->post('contact_skype', TRUE);
                 // update process for Content
                 $this->user_model->updateUserContacts($userContacts, $updateKey2);
             }
             //Send email to the buyer with the update profile details
             if ($this->input->post('pwd', TRUE)) {
                 $data1 = 'Password :'******'pwd') . '\\n';
             } else {
                 $data1 = '';
             }
             if ($this->input->post('name', TRUE)) {
                 $data2 = 'Company Name :' . $this->input->post('name', TRUE) . '\\n';
             } else {
                 $data2 = '';
             }
             if ($this->input->post('email', TRUE)) {
                 $data3 = 'Email Id :' . $this->input->post('email') . '\\n';
             } else {
                 $data3 = '';
             }
             if ($this->input->post('profile', TRUE)) {
                 $data4 = 'Profile Description :' . $this->input->post('profile') . '\\n';
             } else {
                 $data4 = '';
             }
             if ($this->input->post('notify_project', TRUE)) {
                 $data5 = 'Project Notify :' . $this->input->post('notify_project') . '\\n';
             } else {
                 $data5 = '';
             }
             if ($this->input->post('notify_message', TRUE)) {
                 $data6 = 'Message Notify :' . $this->input->post('notify_message') . '\\n';
             } else {
                 $data6 = '';
             }
             if ($this->input->post('country', TRUE)) {
                 $condition = array('country.country_symbol' => $this->input->post('country'));
                 $country = $this->common_model->getCountries($condition);
                 $country = $country->row();
                 $data7 = 'Country             :' . $country->country_name . '\\n';
             } else {
                 $data7 = '';
             }
             if ($this->input->post('city', TRUE)) {
                 $data8 = 'City :' . $this->input->post('city') . '\\n';
             } else {
                 $data8 = '';
             }
             if ($this->input->post('state', TRUE)) {
                 $data9 = 'State :' . $this->input->post('state') . '\\n';
             } else {
                 $data9 = '';
             }
             if ($this->input->post('contact_msn', TRUE)) {
                 $data10 = 'MSN ID :' . $this->input->post('contact_msn') . '\\n';
             } else {
                 $data10 = '';
             }
             if ($this->input->post('contact_gtalk', TRUE)) {
                 $data11 = 'Gtalk ID :' . $this->input->post('contact_gtalk') . '\\n';
             } else {
                 $data11 = '';
             }
             if ($this->input->post('contact_yahoo', TRUE)) {
                 $data12 = 'Yahoo Id :' . $this->input->post('contact_yahoo') . '\\n';
             } else {
                 $data12 = '';
             }
             if ($this->input->post('contact_skype', TRUE)) {
                 $data12 = 'Skype Id :' . $this->input->post('contact_skype') . '\\n';
             } else {
                 $data12 = '';
             }
             //Send email to the user after update profile
             $conditionUserMail = array('email_templates.type' => 'profile_update');
             $result = $this->email_model->getEmailSettings($conditionUserMail);
             $rowUserMailConent = $result->row();
             $splVars = array("!site_name" => $this->config->item('site_title'), "!username" => $this->loggedInUser->user_name, "!siteurl" => site_url(), "!contact_url" => site_url('contact'), "!data1" => $data1, "!data2" => $data2, "!data3" => $data3, "!data4" => $data4, "!data5" => $data5, "!data6" => $data6, "!data7" => $data7, "!data8" => $data8, "!data9" => $data9, "!data10" => $data10, "!data11" => $data11, "!data12" => $data12);
             $mailSubject = strtr($rowUserMailConent->mail_subject, $splVars);
             $mailContent = strtr($rowUserMailConent->mail_body, $splVars);
             $toEmail = $this->loggedInUser->email;
             $fromEmail = $this->config->item('site_admin_mail');
             $this->email_model->sendHtmlMail($toEmail, $fromEmail, $mailSubject, $mailContent);
             //Notification message
             $this->session->set_flashdata('flash_message', $this->common_model->flash_message('success', $this->lang->line('update_buyer_confirm_success')));
             redirect('info/index/success');
         }
         //Form Validation End
     }
     //If - Form Submission End
     //Get Categories
     $this->outputData['categories'] = $this->skills_model->getCategories();
     //Get Countries
     $this->outputData['countries'] = $this->common_model->getCountries();
     //Conditions
     $conditions = array('users.id' => $this->loggedInUser->id);
     $this->outputData['userInfo'] = $this->user_model->getUsers($conditions);
     $conditions = array('user_contacts.user_id' => $this->loggedInUser->id);
     $this->outputData['userContactInfo'] = $this->user_model->getUserContacts($conditions);
     $this->outputData['userContact'] = $this->outputData['userContactInfo']->row();
     $this->load->view('buyer/editBuyerProfile', $this->outputData);
 }
Esempio n. 5
0
 public function photo($id = "")
 {
     $target_path = realpath(APPPATH . '../images/users');
     if (!is_writable(dirname($target_path))) {
         $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Sorry! Destination folder is not writable.')));
         redirect('users/edit', 'refresh');
     } else {
         if (!is_dir(realpath(APPPATH . '../images/users') . '/' . $id)) {
             mkdir(realpath(APPPATH . '../images/users') . '/' . $id, 0777, true);
         }
         $target_path = $target_path . '/' . $id . '/userpic.jpg';
         if ($_FILES['upload123']['name'] != '') {
             move_uploaded_file($_FILES['upload123']['tmp_name'], $target_path);
             $thumb1 = realpath(APPPATH . '../images/users') . '/' . $id . '/userpic_thumb.jpg';
             GenerateThumbFile($target_path, $thumb1, 107, 78);
             $thumb2 = realpath(APPPATH . '../images/users') . '/' . $id . '/userpic_profile.jpg';
             GenerateThumbFile($target_path, $thumb2, 209, 209);
             $thumb3 = realpath(APPPATH . '../images/users') . '/' . $id . '/userpic_home.jpg';
             GenerateThumbFile($target_path, $thumb3, 40, 40);
             $this->db->query('update users set photo_status = 1 where id = ' . $id);
             $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('success', translate('Your profile photo updated successfully.')));
             redirect('users/edit', 'refresh');
         } else {
             $this->session->set_flashdata('flash_message', $this->Common_model->flash_message('error', translate('Please browse your profile photo.')));
             redirect('users/edit', 'refresh');
         }
     }
 }
Esempio n. 6
0
 private function thumb($uid, $file)
 {
     $target_path = realpath(APPPATH . '../images/users');
     if (!is_writable($target_path)) {
         return false;
     } else {
         if (!is_dir($target_path . '/' . $uid)) {
             mkdir($target_path . '/' . $uid, 0777, true);
         }
         $target_path = $target_path . '/' . $uid . '/';
         if ($file != '') {
             $get_content = file_get_contents($file);
             @file_put_contents($target_path . 'userpic.jpg', $get_content);
             $this->load->library('upload');
             GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic_thumb.jpg', 36, 36);
             GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic_profile.jpg', 120, 120);
             GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic.jpg', 250, 250);
             return true;
         } else {
             return false;
         }
     }
 }
 private function sendqs()
 {
     if ($this->uid) {
         $data['fUid'] = $this->uid;
         $data['title'] = $this->input->post('qtitle');
         //$data['position'] = $this->input->post('position');
         $data['description'] = $this->input->post('qdes');
         //$data['sex'] = $this->input->post('sex');
         //$data['address'] = $this->input->post('address');
         //	$data['city'] = $this->input->post('city');
         //$data['toUid'] = "";
         $data['state'] = 1;
         $data['has_answer'] = 0;
         $data['cdate'] = time();
         $id = $this->common->insertData('wen_questions', $data);
         if (isset($_FILES['attachPic']['tmp_name']) && $_FILES['attachPic']['tmp_name'] && $id != 0) {
             $target_path = realpath(APPPATH . '../upload');
             if (is_writable($target_path)) {
                 if (!is_dir($target_path . '/' . round($id / 1000))) {
                     mkdir($target_path . '/' . round($id / 1000), 0777, true);
                 }
                 $datas['name'] = time() . '.jpg';
                 $datas['savepath'] = round($id / 1000) . '/' . $datas['name'];
                 $target_path = $target_path . '/' . $datas['savepath'];
                 move_uploaded_file($_FILES['attachPic']['tmp_name'], $target_path);
                 GenerateThumbFile($target_path, $target_path, 550, 650);
                 $datas['userId'] = $this->uid;
                 $datas['uploadTime'] = time();
                 $datas['type'] = 'jpg';
                 $datas['private'] = 1;
                 $pictureid = $this->common->insertData('wen_attach', $datas);
                 $result['updatePictureState'] = '000';
                 $result['postState'] = '000';
                 $upicArr = array();
                 $upicArr[]['type'] = 'jpg';
                 $upicArr[]['id'] = $pictureid;
                 $wdata['uid'] = $this->uid;
                 $wdata['content'] = '';
                 $wdata['q_id'] = $id;
                 $wdata['type_data'] = serialize($upicArr);
                 $wdata['type'] = 4;
                 $wdata['ctime'] = time();
                 $this->common->insertData('wen_weibo', $wdata);
             }
         }
         $this->session->set_flashdata('msg', $this->common->flash_message('sucess', '咨询已经发布!'));
         redirect('user/dashboard');
     } else {
         $this->session->set_flashdata('msg', $this->common->flash_message('error', '登入后才能发布咨询!'));
         redirect('user/login');
     }
 }
Esempio n. 8
0
 private function thumb($uid)
 {
     $target_path = realpath(APPPATH . '../images/users');
     if (!is_writable($target_path)) {
         return false;
     } else {
         if (!is_dir($target_path . '/' . $uid)) {
             mkdir($target_path . '/' . $uid, 0777, true);
         }
         $target_path = $target_path . '/' . $uid . '/';
         GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic_thumb.jpg', 36, 36);
         GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic_profile.jpg', 120, 120);
         return true;
     }
 }
function generateThumbNail($src, $dest, $x, $y)
{
    global $save_to_file, $image_quality, $image_type, $max_x, $max_y, $from_name, $to_name;
    // Below are default values (if parameter is not passed)
    // save to file (true) or output to browser (false)
    $save_to_file = true;
    // quality
    $image_quality = 100;
    // resulting image type (1 = GIF, 2 = JPG, 3 = PNG)
    // enter code of the image type if you want override it
    // or set it to -1 to determine automatically
    $image_type = -1;
    // maximum thumb side size
    $max_x = 100;
    $max_y = 100;
    ///////////////////////////////////////////////////
    /////////////// DO NOT EDIT BELOW
    ///////////////////////////////////////////////////
    $to_name = '';
    $from_name = str_replace(" ", "%20", $src);
    $to_name = $dest;
    $max_x = $x;
    $max_y = $y;
    // generate
    return GenerateThumbFile($from_name, $to_name, $max_x, $max_y);
}
Esempio n. 10
0
 public function index()
 {
     if (!$this->session->userdata('random_key')) {
         $this->session->set_userdata('random_key', strtotime(date('Y-m-d H:i:s')));
         $this->session->set_userdata('user_file_ext', '');
     }
     $data = array();
     $data['error'] = '';
     $tmpext = '.jpg';
     $data['current_large_image_width'] = 0;
     $data['current_large_image_height'] = 0;
     $data['upload_dir'] = 'tmp';
     // The directory for the images to be saved in
     $data['upload_path'] = $data['upload_dir'] . "/";
     // The path to where the image will be saved
     $large_image_prefix = "resize_";
     // The prefix name to large image
     $thumb_image_prefix = "thumbnail_";
     // The prefix name to the thumb image
     $data['large_image_name'] = $this->uid;
     // New name of the large image (append the timestamp to the filename)
     $thumb_image_name = $this->uid . '_userpic';
     // New name of the thumbnail image (append the timestamp to the filename)
     $max_file = "3";
     // Maximum file size in MB
     $max_width = "1200";
     // Max width allowed for the large image
     $data['thumb_width'] = "250";
     // Width of thumbnail image
     $data['thumb_height'] = "250";
     // Height of thumbnail image
     // Only one of these image types should be allowed for upload
     $allowed_image_types = array('image/pjpeg' => "jpg", 'image/jpeg' => "jpg", 'image/jpg' => "jpg", 'image/png' => "png", 'image/x-png' => "png", 'image/gif' => "gif");
     $allowed_image_ext = array_unique($allowed_image_types);
     // do not change this
     $image_ext = "";
     // initialise variable, do not change this.
     foreach ($allowed_image_ext as $mime_type => $ext) {
         $image_ext .= strtoupper($ext) . " ";
     }
     //Image Locations
     $large_image_location = $data['upload_path'] . $data['large_image_name'] . $tmpext;
     $thumb_image_location = $data['upload_path'] . $thumb_image_name . $tmpext;
     if (file_exists($large_image_location)) {
         $data['current_large_image_width'] = $this->getWidth($large_image_location);
         $data['current_large_image_height'] = $this->getHeight($large_image_location);
     }
     //Create the upload directory with the right permissions if it doesn't exist
     if (!is_dir($data['upload_dir'])) {
         mkdir($data['upload_dir'], 0777);
         chmod($data['upload_dir'], 0777);
     }
     //Check to see if any images with the same name already exist
     if (file_exists($large_image_location)) {
         if (file_exists($thumb_image_location)) {
             $data['thumb_photo_exists'] = "<img src=\"" . site_url() . $data['upload_path'] . $thumb_image_name . $tmpext . '?' . time() . "\" alt=\"Thumbnail Image\"/>";
         } else {
             $data['thumb_photo_exists'] = "";
         }
         $data['large_photo_exists'] = "<img src=\"" . site_url() . $data['upload_path'] . $data['large_image_name'] . $tmpext . '?' . time() . "\" alt=\"Large Image\"/>";
     } else {
         $data['large_photo_exists'] = "";
         $data['thumb_photo_exists'] = "";
     }
     if (isset($_POST["upload"])) {
         //Get the file information
         $userfile_name = $_FILES['image']['name'];
         $userfile_tmp = $_FILES['image']['tmp_name'];
         $userfile_size = $_FILES['image']['size'];
         $userfile_type = $_FILES['image']['type'];
         $filename = basename($_FILES['image']['name']);
         $file_ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
         //Only process if the file is a JPG, PNG or GIF and below the allowed limit
         if (!empty($_FILES["image"]) && $_FILES['image']['error'] == 0) {
             foreach ($allowed_image_types as $mime_type => $ext) {
                 //loop through the specified image types and if they match the extension then break out
                 //everything is ok so go and check file size
                 if ($file_ext == $ext && $userfile_type == $mime_type) {
                     $data['error'] = "";
                     break;
                 } else {
                     $data['error'] = "Only <strong>" . $image_ext . "</strong> images accepted for upload<br />";
                 }
             }
             //check if the file size is above the allowed limit
             if ($userfile_size > $max_file * 1048576) {
                 $data['error'] .= "Images must be under " . $max_file . "MB in size";
             }
         } else {
             $data['error'] = "Select an image for upload";
         }
         //Everything is ok, so we can upload the image.
         if (strlen($data['error']) == 0) {
             if (isset($_FILES['image']['name'])) {
                 //this file could now has an unknown file extension (we hope it's one of the ones set above!)
                 $large_image_location = $large_image_location;
                 $thumb_image_location = $thumb_image_location;
                 //put the file ext in the session so we know what file to look for once its uploaded
                 $this->session->set_userdata('user_file_ext', "." . $file_ext);
                 move_uploaded_file($userfile_tmp, $large_image_location);
                 GenerateThumbFile($large_image_location, $large_image_location, 370, 650);
                 chmod($large_image_location, 0777);
                 $width = $this->getWidth($large_image_location);
                 $height = $this->getHeight($large_image_location);
                 //Scale the image if it is greater than the width set above
                 if ($width > $max_width) {
                     $scale = $max_width / $width;
                     $uploaded = $this->resizeImage($large_image_location, $width, $height, $scale);
                 } else {
                     $scale = 1;
                     $uploaded = $this->resizeImage($large_image_location, $width, $height, $scale);
                 }
                 //Delete the thumbnail file so the user can create a new one
                 if (file_exists($thumb_image_location)) {
                     unlink($thumb_image_location);
                 }
             }
             //Refresh the page to show the new uploaded image
             header("location:" . $_SERVER["PHP_SELF"]);
             exit;
         }
     }
     if (isset($_POST["upload_thumbnail"]) && strlen($data['large_photo_exists']) > 0) {
         //Get the new coordinates to crop the image.
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         //Scale the image to the thumb_width set above
         $scale = $data['thumb_width'] / $w;
         $cropped = $this->resizeThumbnailImage($thumb_image_location, $large_image_location, $w, $h, $x1, $y1, $scale);
         $this->thumb($thumb_image_location, $large_image_location, $this->uid);
         //Reload the page again to view the thumbnail
         //redirect('thumbplug');
     }
     $data['notlogin'] = $this->notlogin;
     $this->load->view('theme/include/thumbplug', $data);
 }
Esempio n. 11
0
 private function thumb($uid)
 {
     $this->load->library('upload');
     $this->load->helper('file');
     $target_path = realpath(APPPATH . '../images/users');
     $target_path = $target_path . '/' . $uid . '/';
     GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic_thumb.jpg', 36, 36);
     GenerateThumbFile($target_path . 'userpic.jpg', $target_path . 'userpic_profile.jpg', 120, 120);
     echo 'file of folder ' . $uid . ' success!';
 }