示例#1
0
 public function UploadImage($imgdata, $folder = 'Temp')
 {
     $base_dir = WWW_ROOT . DS . 'files/' . $folder;
     if (!is_dir($base_dir)) {
         mkdir($base_dir, 0755, true);
     }
     $arr_img = explode(".", $imgdata["name"]);
     $ext = strtolower($arr_img[count($arr_img) - 1]);
     if ($imgdata['error'] == 0 && in_array($ext, array('jpg', 'gif', 'png'))) {
         $fname = removeSpecialChar($imgdata['name']);
         $file = time() . "_" . $fname;
         if (upload_my_file($imgdata['tmp_name'], $base_dir . '/' . $file)) {
             $save_path = "thumb_" . $file;
             create_thumb($base_dir . '/' . $file, 150, $base_dir . '/' . $save_path);
             $array = array('image' => $file, 'thumb' => $save_path);
             return $array;
         } else {
             return '0';
         }
     } else {
         return '0';
     }
 }
 public function upload_img_file($arr, $id)
 {
     $fileUpload = WWW_ROOT . 'files' . DS . $id;
     if (!is_dir($fileUpload)) {
         mkdir($fileUpload, 0777);
     }
     if (!is_dir($fileUpload . '/thumb')) {
         mkdir($fileUpload . '/thumb', 0777);
     }
     if (!is_dir($fileUpload . '/minithumb')) {
         mkdir($fileUpload . '/minithumb', 0777);
     }
     $fname = removeSpecialChar($arr['name']);
     $file = time() . "_" . $fname;
     if (upload_my_file($arr['tmp_name'], $fileUpload . '/' . $file)) {
         $save_path = "thumb_" . $file;
         $min_save_path = "mini_thumb_" . $file;
         create_thumb($fileUpload . '/' . $file, 150, $fileUpload . '/thumb/' . $save_path);
         create_thumb($fileUpload . '/' . $file, 42, $fileUpload . '/minithumb/' . $min_save_path);
         return $file;
     } else {
         return 0;
     }
 }
示例#3
0
 $cdi_doi_tuong = implode(',', $cdi_doi_tuong);
 $myform->add('cdi_doi_tuong', 'cdi_doi_tuong', 0, 1, '');
 $cdi_theo_mua = getValue('cdi_theo_mua', 'arr', 'POST', array());
 $cdi_theo_mua = array_unique($cdi_theo_mua);
 $cdi_theo_mua = implode(',', $cdi_theo_mua);
 $myform->add('cdi_theo_mua', 'cdi_theo_mua', 0, 1, '');
 //update trường keyword search
 $cdi_search = '';
 $field_search = getValue('cdi_name', 'str', 'POST', '', 3);
 $cdi_search .= $field_search;
 $field_search = getValue('cdi_name_alias', 'str', 'POST', '', 3);
 $cdi_search .= $field_search;
 $field_search = getValue('cdi_tag', 'str', 'POST', '', 3);
 $cdi_search .= $field_search;
 $cdi_search = mb_strtolower($cdi_search, 'utf8');
 $cdi_search = removeSpecialChar($cdi_search);
 $cdi_search = $cdi_search . ' ' . removeAccent($cdi_search);
 $myform->add('cdi_search', 'cdi_search', 0, 1, '');
 //Count word và count char từ trường tên
 $cdi_name = getValue('cdi_name', 'str', 'POST', '', 3);
 $cdi_count_word = count(explode(' ', $cdi_name));
 $cdi_count_char = strlen($cdi_name);
 $myform->add('cdi_count_word', 'cdi_count_word', 1, 1, 0);
 $myform->add('cdi_count_char', 'cdi_count_char', 1, 1, 0);
 if (!$bg_errorMsg) {
     $db_update = new db_execute($myform->generate_update_SQL($id_field, $record_id));
     unset($db_update);
     /**
      * something code here
      */
     //update to disease_section
示例#4
0
 public function upload_doc_file($arr, $id)
 {
     $fileUpload = WWW_ROOT . 'files' . DS . 'Agents' . DS . $id;
     if (!is_dir($fileUpload)) {
         mkdir($fileUpload, 0777);
     }
     $fname = removeSpecialChar($arr['name']);
     $file = time() . "_" . $fname;
     if (upload_my_file($arr['tmp_name'], $fileUpload . '/' . $file)) {
         return $file;
     } else {
         return 0;
     }
 }
function removeSpecialChars($str)
{
    $search = array("–", "´", "‹", "›", "‘", "’", "‚", "“", "”", "„", "‟", "•", "‒", "―", "—", "™", "¼", "½", "¾");
    $replace = array("-", "'", "<", ">", "'", "'", ",", '"', '"', '"', '"', "-", "-", "-", "-", "TM", "1/4", "1/2", "3/4");
    return removeSpecialChar($search, $replace, $str);
}
示例#6
0
/**
 * Replaces special chars from string
 *
 * @param String  $str        String
 * return function
 */
function removeSpecialCharsforLog($str)
{
      $search = array("&lt;", "&gt;", "'",);
      $replace = array("<", ">", "&acute;");
      return removeSpecialChar($search, $replace, $str);
}