Add text to an image
public text ( string $text, string $font_file, float | integer $font_size = 12, string $color = '#000000', string $position = 'center', integer $x_offset, integer $y_offset ) : SimpleImage | ||
$text | string | |
$font_file | string | |
$font_size | float | integer | |
$color | string | |
$position | string | |
$x_offset | integer | |
$y_offset | integer | |
return | SimpleImage |
function user_register_submit() { //print_r(); //die; //if(empty($this->input->post('first_name'))){ $this->form_validation->set_rules('username', 'User Name', 'required|is_unique[users.username]'); $this->form_validation->set_rules('password_new', 'New Password', 'required|trim|min_length[6]|regex_match[#.*^(?=.{8,20})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*\\W).*$#]'); // strong password include one letter,one number,one CAPS,one symbol $this->form_validation->set_rules('password_confirm', 'Confirm Password', 'required|trim|min_length[8]|matches[password_new]'); $this->form_validation->set_rules('user_email', 'User Email', 'required|valid_email|is_unique[users.email]'); $this->form_validation->set_rules('first_name', 'User First Name', 'required'); $this->form_validation->set_rules('last_name', 'User Last Name', 'required'); $this->form_validation->set_rules('phone', 'User Phone Number', 'required|numeric|xss_clean'); $this->form_validation->set_rules('user_role_id', 'User Type', 'required'); //$this->form_validation->set_rules('user_avatar', 'Image', 'required'); if ($this->form_validation->run() == FALSE) { //echo validation_errors('<div class="alert alert-danger">', '</div>'); //exit; } $data['error_post'] = ''; $data['succ_post'] = ''; $data['error_post'] = validation_errors(); //print_r($data['error_post']); //echo validation_errors(); //check_exist_country $chk_count = $this->UserManage_model->check_exist_user(); if ($chk_count > 0) { $data['error_post'] .= 'User already exists, please check email or username'; } //check file upload extension if (!empty($_FILES['user_avatar']['name'])) { $upload_file = $_FILES['user_avatar']['name']; $file_ar = explode('.', $upload_file); $new_file_name = $file_ar[0]; $new_file_ext = $file_ar[1]; $allowed_ext = array('jpg', 'jpeg', 'gif', 'png'); if (!in_array($new_file_ext, $allowed_ext)) { $data['error_post'] .= 'Upload Error: please upload jpg/jpeg/gif/png'; //array_push($data['error_post'],'Upload Error: please upload jpg/jpeg/gif/png'); } } if (empty($data['error_post'])) { //echo 'submit to register<hr>'; //Upload user avater if (!empty($_FILES['user_avatar']['name'])) { $real_site_path = str_replace('system/', '', BASEPATH); //$dir_folder = $real_site_path . 'media/upload/'; //$dir_folder1 = $real_site_path . 'media/upload/user-avatar/'; $dir_path_thumb = $real_site_path . 'media/upload/user-avatar/thumb_150x150/'; $dir_path = $real_site_path . 'media/upload/user-avatar/'; $upload_file = $_FILES['user_avatar']['name']; $file_ar = explode('.', $upload_file); $new_file_name = $file_ar[0]; $new_file_ext = $file_ar[1]; $new_upload_file_thumb = $new_file_name . '_' . time() . "." . $new_file_ext; $new_upload_file = $new_file_name . '_' . time() . "." . $new_file_ext; $uploaded_path_thumb = $dir_path_thumb . $new_upload_file_thumb; $uploaded_path_orig = $dir_path . $new_upload_file; $new_uploaded_path_orig = $dir_path . $new_upload_file; $font_path = $real_site_path . 'media/upload/'; //chmod($dir_folder,777); //chmod($dir_folder1,777); //chmod($dir_path,777); //chmod($dir_path_thumb,777); if (!empty($new_file_name)) { move_uploaded_file($_FILES['user_avatar']['tmp_name'], $uploaded_path_orig) or die('upload image error...'); $image = new SimpleImage(); $image->load($uploaded_path_orig); $image->resize(150, 150); $image->text($this->input->post('username'), $font_path . 'GILSANUB.TTF', 11, '#FFFFFF', 'top', 0, 20); $image->save($uploaded_path_thumb); //$image->watermark_text($uploaded_path_orig,$uploaded_path_thumb,$this->input->post('username'),$font_path); //watermark //$image_wt = new SimpleImage(); //$image_wt->load($uploaded_path_orig); //$image->resize(150,150); //$image_wt->watermark_text($uploaded_path_orig,$uploaded_path_thumb,$this->input->post('username'),$font_path); //save images data $image_data = array(); $image_data['user_avatar'] = $new_upload_file; //die; } } if (!isset($image_data)) { $image_data = NULL; } $ret_query = $this->UserManage_model->insert_data($image_data); } if (isset($ret_query)) { $data_list['query'] = $this->UserManage_model->init(); $data_list['listquery'] = $this->UserManage_model->listUserManage(); redirect("thank-you", "location"); return; } $meta_data['seo_title'] = ''; $meta_data['seo_desc'] = ''; $meta_data['seo_keywords'] = ''; $data['first_name'] = $this->input->post('first_name'); $data['last_name'] = $this->input->post('last_name'); $data['user_email'] = $this->input->post('user_email'); $data['username'] = $this->input->post('username'); $data['phone'] = $this->input->post('phone'); $data['password_new'] = $this->input->post('password_new'); $data['password_confirm'] = $this->input->post('password_confirm'); $data['prop_country_id'] = $this->input->post('prop_country_id'); $data['prop_state_id'] = $this->input->post('prop_state_id'); $data['prop_city_id'] = $this->input->post('prop_city_id'); $data['user_role_id'] = $this->input->post('user_role_id'); $country_record = $this->City_model->getCountryRecord(); $data['country_record'] = $country_record; $states_record = $this->City_model->getStateRecord($this->input->post('prop_country_id')); $data['states_record'] = $states_record; $city_record = $this->City_model->getCityRecord($this->input->post('prop_state_id'), $this->input->post('prop_country_id')); $data['city_record'] = $city_record; $user_role = $this->UserManage_model->get_user_roles(); $data['user_role_data'] = $user_role; $data['page_title'] = 'Sign up'; $this->breadcrumbcomponent->add('Home', base_url()); $this->breadcrumbcomponent->add('Sign Up', base_url() . '/'); $data['breadcrumbs'] = $this->breadcrumbcomponent->output(); $this->load->view('head_section', $meta_data); $this->load->view('user_register', $data); $this->load->view('foot_section'); /*}else{ //echo 'aaa';die; redirect("unauthorize-access", "location"); return; }*/ }