/** * */ public function index() { $this->load->helper("form"); $this->load->library('form_validation'); $this->load->model("LoginRegistreModel"); $this->load->model("EmailModel"); $data = array(); // Displaying Errors In Div $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); $this->form_validation->set_rules('inputEmail', 'Email', 'trim|required|valid_email'); $this->form_validation->set_rules('inputNick', 'Username', 'trim|required|min_length[5]|max_length[12]'); // si posava |xxs_clean no donava valid mai $this->form_validation->set_rules('inputPassword', 'Password', 'trim|required|matches[inputPasswordConfirm]'); $this->form_validation->set_rules('inputPasswordConfirm', 'Password Confirmation', 'trim|required'); if ($this->form_validation->run() == FALSE) { // si algun camp es erroni torna al formulari (de registre), omplint els camps $data['actiu'] = 2; $this->load->view('templates/header', $data); $this->load->view('pages/index'); $this->load->view('templates/footer'); } else { //agafar totes les dades del formulari $data[0] = $this->input->post("inputEmail"); $data[1] = $this->input->post("inputNick"); $data[2] = $this->input->post("inputPassword"); //$usu_existeix es un boolean, true existeix, false no $usu_existeix = $this->LoginRegistreModel->existeix($data[0]); if ($usu_existeix == true) { // indica q usuari ja existeix a la bd , tornar al formulari de registre i avisar de l'errror $data['errores'] = 1; // = 1 per avisar q l'usuari ja existeix $this->load->view('templates/header', $data); $this->load->view('pages/index'); $this->load->view('templates/footer'); } else { //usuari no existeix a la bd, guardar usuari. //crear carpeta usuari dins de avatars, $this->load->helper('path'); //para dentro de application //set_realpath('./application/uploads/peliculas/'.$idp."/"); $dir = set_realpath('./application/avatars/' . $data[0] . "/"); if (!is_dir($dir)) { mkdir($dir, 777); } //generar aleatori, q sera el codi d'activacio $data[3] = rand(1000, 9999); $this->LoginRegistreModel->fer_registre($data); //enviar email $this->EmailModel->enviar_email_valid_reg($data[0], $data[3]); //tornar al form indicant q s'ha registrat correctament i per entrar a de validar per email $data['reg_correcte'] = true; //variable per mostrar missatge de registre correcte i avisar q ha de validar $this->load->view('templates/header', $data); $this->load->view('pages/index'); $this->load->view('templates/footer'); } } }
function elfinder_init() { $this->load->helper('path'); // die('lib'); $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => set_realpath('/'), 'URL' => site_url() . '/'))); $this->load->library('elfinder/elfinder_lib', $opts); }
public function connector() { $this->load->helper('path'); $opts = array('debug' => true, 'bind' => array('mkdir.pre mkfile.pre rename.pre' => array('Plugin.Slugifier.cmdPreprocess'), 'upload.presave' => array('Plugin.Slugifier.onUpLoadPreSave')), 'plugin' => array('Sanitizer' => array('enable' => true, 'targets' => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), 'replace' => '_'), 'Slugifier' => array('enable' => true))); $opts['roots'] = array(array('driver' => 'LocalFileSystem', 'alias' => 'Racine', 'path' => set_realpath('assets/files'), 'URL' => site_url('assets/files') . '/', 'mimeDetect' => 'internal', 'uploadOverwrite' => false, 'uploadAllow' => array('image', 'application/pdf', "application/vnd.openxmlformats-officedocument.wordprocessingml.document"), 'attributes' => array(array('pattern' => '/\\.tmb$/', 'read' => false, 'write' => false, 'hidden' => true, 'locked' => false), array('pattern' => '/\\.quarantine$/', 'read' => false, 'write' => false, 'hidden' => true, 'locked' => false), array('pattern' => '/\\.html$/', 'read' => false, 'write' => false, 'hidden' => true, 'locked' => false)))); $this->load->library('elfinder_lib', $opts); }
public function index() { ee()->view->cp_page_title = lang('reelocate_module_name'); $data = array('submit_url' => REELOCATE_CP . AMP . 'method=preview', 'current_site_url' => rtrim(ee()->config->item('site_url'), '/\\'), 'current_site_path' => rtrim(dirname(dirname(ee()->config->item('avatar_path'))), '/\\'), 'site_path' => rtrim(set_realpath('..'), '/\\'), 'cp_url' => ee()->config->item('site_url')); $data['current_site_url'] = preg_replace('/http[s]?:\\/\\//i', '', $data['current_site_url']); $data['site_url'] = $data['current_site_url']; return ee()->load->view('index', $data, true); }
public function elfinder($extension_regex = NULL, $root = '') { $this->load->helper('path'); //default attributes $attributes = array(array('pattern' => '/error_log|iu-application|iu-resources|iu-system|install|license\\.txt|installed\\.txt|\\.htaccess|\\.htpasswd|\\.tmb|\\.quarantine/i', 'read' => false, 'write' => false, 'hidden' => true, 'locked' => false)); if (!empty($extension_regex)) { $attributes[] = array('pattern' => $extension_regex, 'read' => false, 'write' => false, 'hidden' => true, 'locked' => false); } $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'alias' => __("Assets"), 'path' => set_realpath('./' . (empty($root) ? '' : $root)), 'URL' => site_url(empty($root) ? '' : $root), 'attributes' => $attributes, '' => ''))); $this->load->library('elfinderlib', $opts); }
public function get_Diploma() { $config = array(); $config['useragent'] = "CodeIgniter"; //$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail" $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.googlemail.com"; $config['smtp_port'] = "465"; $config['smtp_user'] = "******"; $config['smtp_pass'] = "******"; $config['mailtype'] = 'html'; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n"; $config['wordwrap'] = TRUE; $this->load->library('email'); $this->email->initialize($config); $this->load->helper('path'); $id = $_POST['id']; //establecemos la carpeta en la que queremos guardar los pdfs, //si no existen las creamos y damos permisos $this->createFolder(); //importante el slash del final o no funcionará correctamente $this->html2pdf->folder('./files/pdfs/'); //establecemos el nombre del archivo $this->html2pdf->filename('Diploma.pdf'); //establecemos el tipo de papel $this->html2pdf->paper('Letter', 'landscape'); //datos que queremos enviar a la vista, lo mismo de siempre $fila = $this->personal_model->getUsuario($id); $imgPDF = set_realpath('vendor/img') . 'ambientesA.png'; $imgDet = set_realpath('vendor/img') . 'ambientesB.png'; $data = array('title' => 'Datos personal en pdf', 'contenido' => $fila, 'imag' => $imgPDF, 'imagDet' => $imgDet); //hacemos que coja la vista como datos a imprimir //importante utf8_decode para mostrar bien las tildes, ñ y demás $this->html2pdf->html(utf8_decode($this->load->view('diplomas/pdf', $data, true))); //si el pdf se guarda correctamente lo mostramos en pantalla if ($this->html2pdf->create('save')) { $this->email->from('*****@*****.**', 'Test From'); $this->email->to('*****@*****.**'); $this->email->subject('Email PDF Test'); $this->email->message("<div style='width: 50% 50%;' align='center'>\n <table width='100%' border='0' cellspacing='0' cellpadding='0'>\n <tr>\n <td align='center' valign='top' style=''>\n <table width='600' border='0' cellspacing='0' cellpadding='0'>\n <tr>\n <td width='20' align='left' valign='top' \n style='background-color:#F5F5F5;'> </td>\n <td align='center' valign='top' \n style='background-color:#F5F5F5; color:#000000; font-family:Arial, Helvetica, sans-serif; font-size:14px;'><br>\n <br><br>\n <div style='color:#030369; font-family:Georgia, Times New Roman, Times, serif; font-size:24px;'>\n Laboratorio Nacional de la Informatica Avanzada\n LANIA A.C<br>\n </div>\n <br>\n <div style='color:#000000; font-style: oblique; font-family:Arial, Helvetica, sans-serif; font-size:16px;'>\n <p><b>De parte de UNETE te felicitamos por </b><br>\n haber concluido satisfactoriamente nuestro curso</p>\n </div>\n <br>\n <table width='100%' border='0' cellspacing='0' cellpadding='0'>\n <tr>\n <td align='center' valign='middle'>\n <hr style='height: 3px; background-color:#030369; border: 0 none;'>\n </td>\n </tr>\n <tr>\n <td height='30' align='center' valign='middle'>\n <div style='color:#030369; font-style: oblique; font-size:18px; font-family: Comic Sans MS, Cursive;'>Descripción diplomado</div>\n </td>\n </tr>\n <tr>\n <td align='center' valign='middle'>\n <hr style='height: 3px; background-color:#030369; border: 0 none;'>\n </td>\n </tr>\n </table>\n <br>\n <div style='color:#000000; font-style: oblique; font-family:Arial, Helvetica, sans-serif; font-size:16px;'>\n <p><b>Te damos un fuerte abrazo!</b><br>\n Descarga tu Diploma adjunto</p>\n </div>\n <br><br>\n <div style='color:#000000; font-family:Arial, Helvetica, sans-serif; font-size:14px;'><b>Dirección Lania</b> <br>\n Contacto <br>\n Telefono: (123) 456-789 <br>\n Email: email@email.com <br>\n Sitio Web: http://www.lania.mx/\n </div>\n <br><br>\n </td>\n <td width='20' align='left' valign='top' \n style='background-color:#F5F5F5;'> </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </div>"); //$this->email->attach($path); $path = set_realpath('files/pdfs'); $this->email->attach($path . 'Diploma.pdf'); if ($this->email->send()) { echo "Se envio email"; } else { echo $this->email->print_debugger(); } //echo $path; //echo $this->email->print_debugger(); } }
function get_logo($logo = 'logo.jpg', $context = 'web') { $CI =& get_instance(); // if they don't have a logo in the database, just default to logo.jpg if ($logo == '0' || $logo == NULL) { $logo = 'logo.jpg'; } if ($context == 'web' or $CI->config->item('logo_base_url') === TRUE) { $path = base_url() . 'img/logo/'; } else { $path = set_realpath('./img/logo/'); } return "<img src='{$path}{$logo}' />"; }
function updateDBConfigFile($strDBName, $strDBHost, $strUserName, $strPWord) { //--------------------------------------------------------------------- // //--------------------------------------------------------------------- $strDBConfigFN = set_realpath('.') . 'application/config/database.php'; $fInfo = get_file_info($strDBConfigFN); if ($fInfo === false) { $this->bError = true; $this->strErrMsg = 'Can not find the database configuration file ' . $strDBConfigFN . '<br>'; return; } $strDBConfig = '<?php' . "\n" . '/* ----------------------------' . "\n" . ' Database configuration entries updated on ' . date('Y-m-d H:i:s') . ' for the ' . "\n" . ' Delightful Labor installation. ' . "\n\n" . ' Updates can be found at the bottom of this file.' . "\n" . ' ----------------------------*/' . "\n" . "?>" . read_file($strDBConfigFN) . "\n\n" . '/* ----------------------------' . "\n" . ' Delightful Labor database settings. ' . "\n" . ' ----------------------------*/' . "\n" . "\$db['default']['hostname'] = '{$strDBHost}';\n" . "\$db['default']['username'] = '******';\n" . "\$db['default']['password'] = '******';\n" . "\$db['default']['database'] = '{$strDBName}';\n"; write_file($strDBConfigFN, $strDBConfig); }
public function index() { $this->EE->cp->set_variable('cp_page_title', lang('reelocate_module_name')); $data = array( 'submit_url' => REELOCATE_CP.AMP.'method=preview', 'current_site_url' => rtrim($this->EE->config->item('site_url'), '/\\'), 'current_site_path' => rtrim(dirname(dirname($this->EE->config->item('avatar_path'))), '/\\'), 'site_path' => rtrim(set_realpath('..'), '/\\'), 'cp_url' => $this->EE->config->item('site_url'), ); $data['current_site_url'] = preg_replace('/http[s]?:\/\//i', '', $data['current_site_url']); $data['site_url'] = $data['current_site_url']; return $this->EE->load->view('index', $data, TRUE); }
/** * Get the admin lang codes from the language folder * * @return array Array of lang code * */ function get_admin_langs() { $path = set_realpath(APPPATH . 'language/'); $lang_dirs = array(); if ($dirs = scandir($path)) { foreach ($dirs as $dir) { if (is_dir($path . $dir)) { $file_path = set_realpath($path . $dir) . 'admin_lang' . EXT; if (is_file($file_path)) { $lang_dirs[] = $dir; } } } // $callback = create_function('$el', 'return is_file(realpath("'.$path.'$el'.'/admin_lang'.EXT.'"));'); // return $lang_dirs = array_values(array_filter($dirs, $callback)); } return $lang_dirs; }
function create_asset($assetID, $creatorID, $contentType, $filename) { $CI =& get_instance(); $CI->load->library('Curl'); $CI->load->helper('path'); $filename = rtrim(set_realpath($filename), '/'); $params = array('AssetID' => $assetID, 'CreatorID' => $creatorID, 'Asset' => "@{$filename};type={$contentType}"); echo 'Posting ' . $filename . ' to ' . $CI->config->item('asset_service') . '<br/>'; $curl = new Curl(); $curl->create($CI->config->item('asset_service')); $curl->option(CURLOPT_POST, TRUE); $curl->option(CURLOPT_POSTFIELDS, $params); $curl->http_method('post'); $response = json_decode($curl->execute(), TRUE); if (!isset($response)) { $response = array('Message' => 'Invalid or missing response. ' . $curl->error_string); } return $response; }
function ipn() { // error_log("--IPN VERIFIED--", 3, "my-errors.log"); $this->load->library('email'); $this->load->helper('path'); $this->email->from('*****@*****.**', 'Landlord'); $this->email->to('*****@*****.**'); // $this->email->cc('*****@*****.**'); // $this->email->bcc('*****@*****.**'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); /* This function will return a server path without symbolic links or relative directory structures. */ $path = set_realpath('upload/'); $this->email->attach($path . 'module.zip'); /* Enables you to send an attachment */ $this->email->send(); $this->email->print_debugger(); //error_log("--IPN VERIFIED--", 3, $report); }
public function init($config) { $this->load->helper('path'); // configure options switch ($config) { case 'image': $options = $this->image; break; case 'audio': $options = $this->audio; break; case 'video': $options = $this->video; break; default: $options = array(); break; } $filePath = isset($options['filePath']) ? $options['filePath'] : 'assets/uploads'; $allowedTypes = isset($options['allowedTypes']) ? $options['allowedTypes'] : array(); $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => set_realpath('./' . $filePath), 'URL' => site_url($filePath), 'tmbPath' => 'thumbs', 'uploadAllow' => $allowedTypes, 'uploadDeny' => 'all'))); $connector = new elFinderConnector(new elFinder($opts)); $connector->run(); }
public function elfinder_init() { $this->load->helper(array("path", "modulo/direccion/region")); $this->load->library(array("module/archivo/archivo_permiso", "module/usuario/usuario_configuracion")); if (!is_dir(FCPATH . "media/usuario")) { mkdir(FCPATH . "media/usuario", 0755); } //******************* carpeta de usuario *************************************** $dir = FCPATH . "media/usuario/" . $this->session->userdata('session_idUsuario') . "/"; if (!is_dir($dir)) { mkdir($dir, 0755); } $dir .= "Disco/"; if (!is_dir($dir)) { mkdir($dir, 0755); } $dir .= "Mis archivos"; if (!is_dir($dir)) { mkdir($dir, 0755); } $disabled = array(); if (!$this->archivo_permiso->permiso("eliminar", $this->session->userdata('session_idUsuario'))) { $disabled[] = "rm"; $disabled[] = "cut"; } if (!$this->archivo_permiso->permiso("editar", $this->session->userdata('session_idUsuario'))) { $disabled[] = "rename"; } //****************************************************************************** $discos = array(array('driver' => 'LocalFileSystem', 'path' => set_realpath($dir), 'disabled' => $disabled, 'attributes' => array(array('pattern' => '!^/.tmb!', 'hidden' => true)))); //****************** archivos regionales *************************************** if (!is_dir(FCPATH . "media/usuario/regiones")) { mkdir(FCPATH . "media/usuario/regiones", 0755); } $lista_regiones = $this->usuario_configuracion->listaRegiones(); foreach ($lista_regiones as $region) { $dir_region = FCPATH . "media/usuario/regiones/" . $region; if (!is_dir($dir_region)) { mkdir($dir_region, 0755); } $dir_region .= "/" . str_replace("'", "", nombreRegion($region)); if (!is_dir($dir_region)) { mkdir($dir_region, 0755); } $discos[] = array('driver' => 'LocalFileSystem', 'path' => set_realpath($dir_region), 'disabled' => $disabled, 'attributes' => array(array('pattern' => '!^/.tmb!', 'hidden' => true), array('pattern' => '/^.+/', 'read' => true, 'write' => true, 'locked' => false))); } //****************************************************************************** //****************** archivos nacionales *************************************** $disabled_general = array(); $generales_edicion = true; $generales_locked = false; if (!$this->archivo_permiso->permiso("generales", $this->session->userdata('session_idUsuario'))) { $generales_edicion = false; $generales_locked = true; $disabled_general = array("rename", "rm", "cut"); } //****************************************************************************** $dir_nacional = FCPATH . "media/usuario/Nacional"; if (!is_dir($dir_nacional)) { mkdir($dir_nacional, 0755); } $discos[] = array('driver' => 'LocalFileSystem', 'path' => set_realpath($dir_nacional), 'disabled' => $disabled_general, 'attributes' => array(array('pattern' => '!^/.tmb!', 'hidden' => true), array('pattern' => '/^.+/', 'read' => true, 'write' => $generales_edicion, 'locked' => $generales_locked))); $opts = array('roots' => $discos); $this->load->library('core/archivo/elfinderlib', $opts); }
/** * Get the admin lang codes from the language folder * * @return array Array of lang code * */ function get_admin_langs() { $path = set_realpath(APPPATH . 'language/'); $lang_dirs = array(); if ($dirs = scandir($path)) { foreach ($dirs as $dir) { if (is_dir($path . $dir)) { $file_path = set_realpath($path . $dir) . 'admin_lang.php'; if (is_file($file_path)) { $lang_dirs[] = $dir; } } } } return $lang_dirs; }
public function guardar_imagen() { //el true al final es para convertirlo a Array de lo contrario será objeto //datos de la imagen cropeada //$data['datoimagen'] = json_decode($_POST['datoimagen'],true); //$data['datocanvas'] = json_decode($_POST['datocanvas'],true); //$data['datos'] = json_decode($_POST['datos'],true); //$data['datocropbox'] = json_decode($_POST['datocropbox'],true); $data['datoimagen'] = json_decode(stripslashes($this->input->post('datoimagen')), true); $data['datocanvas'] = json_decode(stripslashes($this->input->post('datocanvas')), true); $data['datos'] = json_decode(stripslashes($this->input->post('datos')), true); $data['datocropbox'] = json_decode(stripslashes($this->input->post('datocropbox')), true); //print_r($data['datoimagen']); //die; $data['id_session'] = $_POST['id_session']; $data['id_diseno'] = $_POST['id_diseno']; $data['variation_id'] = $_POST['variation_id']; $data['consecutivo'] = $_POST['consecutivo']; $data['nombre'] = $_POST['nombre']; $data['tipo_archivo'] = $_POST['tipo_archivo']; $data['tipo'] = $_POST['tipo']; $data['ext'] = $_POST['ext']; $data['tamano'] = $_POST['tamano']; $data['ancho'] = $_POST['ancho']; $data['alto'] = $_POST['alto']; $data['ano'] = $_POST['ano']; $data['mes'] = $_POST['mes']; $idp = $data['id_session']; $dir = set_realpath('./uploads/' . $idp . "/"); if (!is_dir($dir)) { mkdir($dir, 0755, TRUE); } //http://www.re-cycledair.com/html-5-canvas-saving-to-a-file-with-php //guardar la imagen recortada $dato = substr($_POST['croppedImage'], strpos($_POST['croppedImage'], ",") + 1); $nombre = $data['nombre']; $decodedData = base64_decode($dato); $fp = fopen("uploads/" . $idp . "/" . "rec_" . substr($nombre, 5), 'wb'); //$fp = fopen("uploads/".$idp."/"."rec_".$nombre, 'wb'); fwrite($fp, $decodedData); fclose($fp); /////////////////////////////*****************/////////////////////////////////////// $data['uid_imagen'] = 'uid_' . date('d') . date('m') . date('Y') . '_' . random_string('alpha', 4) . random_string('numeric', 3); $checar = $this->modelo_fotoimagen->check_existente_imagen($data); //si existe ya registros borrarlos para crear nuevo if ($checar != false) { $eliminar = $this->modelo_fotoimagen->eliminar_imagenes($checar); $eliminar = $this->modelo_fotoimagen->eliminar_imagenes_original($checar); $eliminar = $this->modelo_fotoimagen->eliminar_imagenes_recorte($checar); } $guardar = $this->modelo_fotoimagen->anadir_imagenes($data); $guardar = $this->modelo_fotoimagen->anadir_imagenes_original($data); $guardar = $this->modelo_fotoimagen->anadir_imagenes_recorte($data); }
function go_upload_wav() { $campaign_id = $this->input->post('campaign_id'); $config['upload_path'] = '/tmp/'; $config['allowed_types'] = 'wav|x-wav'; $config['overwrite'] = true; $this->load->library('upload', $config); //$this->upload->initialize($config); $upload_path = set_realpath("/var/lib/asterisk/sounds"); foreach ($_FILES as $fileName => $file) { if (!empty($file['name'])) { if (!$this->upload->do_upload($fileName)) { $error = array('error' => $this->upload->display_errors()); $result .= "ERROR: File " . $file['name'] . " not uploaded.\n"; $result .= "\t" . $error['error'] . "\n"; //$this->load->view('upload_form', $error); } else { //$data = array('upload_data' => $this->upload->data()); $prefix = $this->commonhelper->checkIfTenant($this->session->userdata('user_group')) ? $this->session->userdata('user_group') . "_" : ""; $fname = str_replace(' ', '_', $file['name']); copy($config['upload_path'] . $fname, "{$upload_path}/go_{$prefix}" . $fname); chmod("{$upload_path}/go_{$prefix}" . $fname, 0777); $result .= "SUCCESS: File " . $fname . " uploaded.\n"; $fn .= "{$fileName}\n"; $files .= "go_{$prefix}" . str_replace(".wav", '', $fname) . " "; $this->go_campaign->rsync_file($fname); } } } echo "wav|{$result}|{$fn}|" . trim($files); }
public function elfinder_init($edMode = false) { $this->load->helper('path'); if (!$edMode) { $path = 'uploads'; } else { $path = 'templates'; } if ($this->input->get('path')) { $path = $this->input->get('path'); } $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => set_realpath($path), 'URL' => site_url() . $path, 'accessControl' => 'access', 'attributes' => array(array('pattern' => '/administrator/', 'read' => false, 'write' => false, 'locked' => true))))); $this->load->library('elfinder_lib', $opts); }
public function edit($id) { $config['upload_path'] = './upload/'; // โฟลเดอร์ ตำแหน่งเดียวกับ root ของโปรเจ็ค $config['allowed_types'] = 'gif|jpg|png'; // ปรเเภทไฟล์ $config['max_size'] = '0'; // ขนาดไฟล์ (kb) 0 คือไม่จำกัด ขึ้นกับกำหนดใน php.ini ปกติไม่เกิน 2MB $config['max_width'] = '1024'; // ความกว้างรูปไม่เกิน $config['max_height'] = '768'; // ความสูงรูปไม่เกิน $config['file_name'] = 'mypicture'; // ชื่อไฟล์ ถ้าไม่กำหนดจะเป็นตามชื่อเพิม $this->upload->initialize($config); // เรียกใช้การตั้งค่า $fileExist = $this->input->post('d_service_image'); if (file_exists($fileExist) && is_file($fileExist)) { unlink($fileExist); $file_upload = ""; } else { $file_upload = $this->input->post('h_service_image'); // เก็บชื่อไฟล์เพิมถ้ามี $fileCheck = './upload/' . $file_upload; $full_fileCheck = set_realpath($fileCheck); if (!file_exists($full_fileCheck) || !is_file($full_fileCheck)) { $file_upload = ""; } } $this->upload->do_upload('service_image'); // ทำการอัพโหลดไฟล์จาก input file ชื่อ service_image if (!$this->upload->display_errors()) { // ถ้าไม่มี error อัพไฟล์ได้ ให้เอาใช้ไฟล์ใส่ตัวแปร ไว้บันทึกลงฐานข้อมูล $file_upload = $this->upload->data('file_name'); // เก็บชื่อไฟล์ใหม่ } else { // ถ้า error ในกรณีเลือกไฟล์แล้วไม่ผ่าน if ($this->upload->data('file_type')) { // เช่น ประเภทไม่ถูกต้อง return; // ต้อง return เพื่อให้แสดง error } } $newdata = array('service_title' => $this->input->post('service_title'), 'service_detail' => $this->input->post('service_detail'), 'service_img' => $file_upload, 'service_update' => date("Y-m-d H:i:s")); return $this->db->update('tbl_service', $newdata, array('service_id' => $id)); }
public function subjectQuerySend() { $data = $this->input->post(); $ci = CI::get_instance(); /* echo $data['upload']; die();*/ /* $this->load->view('profile_quote',$data);*/ $message = $this->load->view('other_subject_send', $data, TRUE); $config['upload_path'] = 'uploads/'; $config['allowed_types'] = 'docx|pdf|ppt|doc|pptx|pdf|jpeg|png'; $config['max_size'] = 5000; $config['encrypt_name'] = TRUE; $this->upload->initialize($config); if ($_FILES['uploadfile']['name']) { if (!$this->upload->do_upload('uploadfile')) { $error = array('error' => $ci->upload->display_errors()); setInformUser('error', $error['error'] . ' please import file formate only'); redirect(base_url('users/profile')); } else { /*$admin_mail='*****@*****.**';*/ /* $admin_mail='*****@*****.**';*/ $this->email->from(setEmail(), 'Eduworkers'); $this->email->to($this->adminEmail()); $path = set_realpath('uploads'); $file = $this->upload->data(); /* echo $file['file_name']; echo $path; die;*/ $this->email->subject('Order Query'); $this->email->message($message); $this->email->attach($path . $file['file_name']); if ($this->email->send()) { $this->email->from(setEmail(), 'Eduworkers'); $this->email->to($data['email']); $this->email->subject('Order Query'); $this->email->message($message); $this->email->attach($path . $file['file_name']); if ($this->email->send()) { setInformUser('success', "Send Quote successfully"); redirect(base_url('users/profile')); } else { setInformUser('error', "Some Error Occurred."); redirect(base_url('users/profile')); } } else { setInformUser('error', "Some Error Occurred."); redirect(base_url('users/profile')); } } } else { /* $admin_mail='*****@*****.**';*/ $this->email->from(setEmail(), 'Eduworkers'); $this->email->to($this->adminEmail()); $this->email->subject('Order Query'); $this->email->message($message); /* echo $data['subject']; die; */ if ($this->email->send()) { $this->email->from(setEmail(), 'Eduworkers'); $this->email->to($data['email']); $this->email->subject('Order Query'); $this->email->message($message); if ($this->email->send()) { setInformUser('success', "Send Quote successfully"); redirect(base_url('users/profile')); } else { setInformUser('error', "Some Error Occurred."); redirect(base_url('users/profile')); } } else { setInformUser('error', "Some Error Occurred."); redirect(base_url('users/profile')); } } }
echo $row['service_detail']; ?> </textarea> </td> </tr> <tr> <th width="120">Images:</th> <td> <input type="file" name="service_image" > <input type="hidden" name="h_service_image" value="<?php echo $row['service_img']; ?> "> <?php $fileCheck = './upload/' . $row['service_img']; $full_fileCheck = set_realpath($fileCheck); if (file_exists($full_fileCheck) && is_file($full_fileCheck)) { ?> <img src="<?php echo base_url('upload/' . $row['service_img']); ?> " style="width:150px;"> <br> <input type="checkbox" name="d_service_image" value="<?php echo $full_fileCheck; ?> "> คลิกเลือกหากต้องการลบไฟล์ <br> <?php }
function Fastreport() { parent::Controller(); $this->thisdir = set_realpath('./assets/fr'); }
/** * METAWEBLOG API: new media object * * @access public * @param parameter list * @return void */ function newMediaObject($plist) { $parameters = $plist->output_parameters(); if ($this->upload_dir == '') { return $this->EE->xmlrpc->send_error_message('801', $this->EE->lang->line('invalid_access')); } if ( ! $this->fetch_member_data($parameters['1'], $parameters['2'])) { return $this->EE->xmlrpc->send_error_message('802', $this->EE->lang->line('invalid_access')); } if ($this->userdata['group_id'] != '1' && ! in_array($parameters['0'], $this->userdata['assigned_channels'])) { return $this->EE->xmlrpc->send_error_message('803', $this->EE->lang->line('invalid_channel')); } if ($this->userdata['group_id'] != '1') { $this->EE->db->where('upload_id', $this->upload_dir); $this->EE->db->where('member_group', $this->userdata['group_id']); if ($this->EE->db->count_all_results('upload_no_access') != 0) { return $this->EE->xmlrpc->send_error_message('803', $this->EE->lang->line('invalid_access')); } } $this->EE->db->select('server_path, url'); $query = $this->EE->db->get_where('upload_prefs', array('id' => $this->upload_dir)); if ($query->num_rows() == 0) { return $this->EE->xmlrpc->send_error_message('803', $this->EE->lang->line('invalid_access')); } /** ------------------------------------- /** File name and security /** -------------------------------------*/ $this->EE->load->library('security'); $filename = preg_replace("/\s+/", "_", $parameters['3']['name']); $filename = $this->EE->security->sanitize_filename($filename); if ($this->EE->security->xss_clean($parameters['3']['bits'], TRUE) === FALSE) { return $this->EE->xmlrpc->send_error_message('810', $this->EE->lang->line('invalid_file_content')); } /** ------------------------------------- /** Upload the image /** -------------------------------------*/ $this->EE->load->helper('path'); $upload_path = set_realpath($this->EE->functions->remove_double_slashes($query->row('server_path') .'/')); $filename = $this->unique_filename($filename, $upload_path); if ( ! $fp = @fopen($upload_path.$filename,FOPEN_WRITE_CREATE_DESTRUCTIVE)) { return $this->EE->xmlrpc->send_error_message('810', $this->EE->lang->line('unable_to_upload')); } @fwrite($fp, $parameters['3']['bits']);// Data base64 decoded by XML-RPC library @fclose($fp); @chmod($upload_path.$filename, FILE_WRITE_MODE); $response = array(array( 'url' => array($this->EE->functions->remove_double_slashes($query->row('url') .'/').$filename,'string'), ), 'struct'); return $this->EE->xmlrpc->send_response($response); }
function send_email($subject = '', $to = '', $body = '', $attachment = '') { $CI =& get_instance(); $CI->load->library('email'); $CI->load->helper('path'); // Configure email library if(config('smtp_host')!="" and config('smtp_port')!="" and config('smtp_user')!="" and config('smtp_pass')!="" ) { $config['protocol'] = 'smtp'; $config['smtp_host'] = config('smtp_host'); $config['smtp_port'] = config('smtp_port'); $config['smtp_user'] = config('smtp_user'); $config['smtp_pass'] = config('smtp_pass'); } $config['charset'] = 'utf-8'; $config['mailtype'] = 'html'; $CI->email->initialize($config); $CI->email->set_newline("\r\n"); $CI->email->from( config('site_email') , config('site_name')); $CI->email->to( $to ); $CI->email->subject( $subject ); $CI->email->message( $body ); $path = set_realpath('pdfs/'); $CI->email->attach($path . $attachment); //$CI->email->attach($attachment); if($CI->email->send()){ return true; } }
public function imagen_encontrada() { //crear carpeta $data['session'] = $_POST['session']; $data['uid_original'] = $_POST['uid_original']; $idp = $data['session']; $dir = set_realpath('./uploads/' . $idp . "/"); if (!is_dir($dir)) { mkdir($dir, 0755, TRUE); } if (!empty($_FILES)) { $config_adjunto['upload_path'] = './uploads/' . $data['session'] . '/'; $config_adjunto['allowed_types'] = 'jpg|png|gif|jpeg'; $config_adjunto['max_size'] = '20480'; $config_adjunto['file_name'] = 'Orig_' . $data['uid_original']; $config_adjunto['overwrite'] = true; $this->load->library('upload', $config_adjunto); foreach ($_FILES as $key => $value) { if ($this->upload->do_upload($key)) { $data['logo'] = $this->upload->data(); //print_r($_FILES); //print_r($data['logo']); $nombre = $data['logo']['file_name']; $tipo_archivo = $data['logo']['file_type']; $tipo = $data['logo']['image_type']; $ext = $data['logo']['file_ext']; $tamano = $data['logo']['file_size']; $ancho = $data['logo']['image_width']; $alto = $data['logo']['image_height']; /* [file_name] => foco.jpg [file_type] => image/jpeg [image_type] => jpeg [file_ext] => .jpg [file_size] => 106.74 [image_width] => 2048 [image_height] => 1365 */ } } $targetPath = base_url() . 'uploads/' . $data['session'] . '/' . $data['logo']['file_name']; echo '<div id="cont_img">'; echo '<img alto="' . $alto . '" ancho="' . $ancho . '" tamano="' . $tamano . '" ext="' . $ext . '" tipo="' . $tipo . '" tipo_archivo="' . $tipo_archivo . '" nombre="' . $nombre . '" id="image" src="' . $targetPath . '" style="max-width: 100%;" alt="Picture"/>'; echo '</div>'; } echo '<script src="' . base_url() . 'js/fotoimagen/main.js" type="text/javascript"></script>'; }
public function test_set_realpath_error_trigger() { $this->setExpectedException('RuntimeException', 'CI Error: Not a valid path: /path/to/nowhere'); set_realpath('/path/to/nowhere', TRUE); }