示例#1
0
function module_upload_picture($picture_name)
{
    //tạo thư mục khi upload
    generate_dir_upload($picture_name, 'organic');
    $path_upload = '../../..' . get_picture_dir($picture_name) . '/' . $picture_name;
    return rename('../../../temp/' . $picture_name, $path_upload);
}
示例#2
0
$myform->add('pha_lieu_luong', 'pha_lieu_luong', 0, 0, '', 0);
$myform->add('pha_bao_quan', 'pha_bao_quan', 0, 0, '', 0);
$form_redirect = getValue('form_redirect', 'str', 'POST', '');
$action = getValue('action', 'str', 'POST', '');
if ($action == 'execute') {
    $bg_errorMsg = $myform->checkdata();
    /**
     * something code here
     */
    if (!$bg_errorMsg) {
        //update ảnh
        $pha_image = getValue('pha_image', 'str', 'POST', '');
        if ($pha_image) {
            $myform->add('pha_image', 'pha_image', 0, 1, '');
            //move ảnh
            generate_dir_upload($pha_image, 'organic');
            $path_upload = '../../..' . get_picture_dir($pha_image) . '/' . $pha_image;
            rename('../../../temp/' . $pha_image, $path_upload);
        }
        $db_update = new db_execute($myform->generate_update_SQL($id_field, $record_id));
        unset($db_update);
        /**
         * something code here
         */
        //redirect
        redirect($form_redirect);
    }
}
//lấy dữ liệu record cần sửa đổi
$pha_nhom_duoc_ly_id = 0;
$db_data = new db_query("SELECT * FROM " . $bg_table . " WHERE " . $id_field . " = " . $record_id);
示例#3
0
$myform->add('new_title', 'new_title', 0, 0, '', 1, 'Tiêu đề trống');
$myform->add('new_title_md5', 'new_title_md5', 0, 0, '', 1, '');
$myform->add('new_cat_id', 'new_cat_id', 1, 0, 0, 1);
$myform->add('new_lin_id', 'new_lin_id', 1, 0, 0, 1);
$myform->add('new_picture', 'new_picture', 0, 0, '');
$myform->add('new_teaser', 'new_teaser', 0, 0, '', 1);
$myform->add('new_tags', 'new_tags', 0, 0, '');
$myform->add('new_date', 'new_date', 1, 0, 0, 1);
$myform->add('new_active', 'new_active', 1, 0, 0, 1);
if (!$myform->checkdata()) {
    $db_insert = new db_execute_return();
    $last_id = $db_insert->db_execute($myform->generate_insert_SQL());
    unset($db_insert);
    //lưu ảnh
    if ($last_id) {
        $path_picture = generate_dir_upload($_POST['new_picture'], 'organic') . $_POST['new_picture'];
        move_uploaded_file($_FILES['data_picture']['tmp_name'], $path_picture);
        //lưu chi tiết tin
        $myform_dt = new generate_form();
        $myform_dt->addTable('news_detail');
        $myform_dt->add('ndt_id', 'last_id', 1, 1, 0);
        $myform_dt->add('ndt_content', 'ndt_content', 0, 0, '');
        $myform_dt->removeHTML(0);
        $db_insert = new db_execute($myform_dt->generate_insert_SQL());
        $total = $db_insert->total;
        unset($db_insert);
        if ($total) {
            echo $last_id;
        } else {
            echo 0;
        }
示例#4
0
function save_image_url($y)
{
    $ttttt = array('error' => 0, 'name' => '', 'ext' => '', 'path' => '');
    $yyyyyyyy = curl_get_content($y);
    $ppppppp = generate_picture_name();
    $hhhhh = generate_dir_upload($ppppppp, 'organic');
    $yyyy = get_header_type($y);
    if (!$yyyy) {
        $ttttt['error'] = 1;
        return $ttttt;
    }
    $ppppppp = $ppppppp . '.' . $yyyy;
    if (file_put_contents($hhhhh . $ppppppp, $yyyyyyyy)) {
        $ttttt = array('name' => $ppppppp, 'ext' => $yyyy, 'path' => $hhhhh . $ppppppp, 'error' => 0, 'link' => get_picture_path($ppppppp));
    }
    return $ttttt;
}
示例#5
0
     $curl = curl_get_content($api_download_url, array('action' => 'getProduct', 'record' => $record, 'username' => $admin, 'password' => $password, 'agency' => $agency_id));
     $data = json_decode($curl, 1);
     //insert vào product và product_quantity
     synchronize_data_table($data);
     //copy ảnh về
     $image_src = $data['products']['image_path'];
     @copy($domain_server_url . $image_src, generate_dir_upload($data['pro_image'], 'organic'));
     $array_return = array('success' => 1, 'step' => $record + 1);
     echo json_encode($array_return);
     break;
 case 'promotion':
     $curl = curl_get_content($api_download_url, array('action' => 'getPromotion', 'username' => $admin, 'password' => $password, 'agency' => $agency_id));
     $data = json_decode($curl, 1);
     synchronize_data_table($data);
     $array_return = array('success' => 1, 'step' => 1);
     echo json_encode($array_return);
     break;
 case 'supplier':
     $curl = curl_get_content($api_download_url, array('action' => 'getSupplier', 'username' => $admin, 'password' => $password, 'agency' => $agency_id));
     $data = json_decode($curl, 1);
     synchronize_data_table($data);
     //lấy ảnh về
     foreach ($data['suppliers'] as $k => $supplier) {
         if ($supplier['image_path'] && $supplier['sup_image']) {
             @copy($domain_server_url . $supplier['image_path'], generate_dir_upload($supplier['sup_image'], 'organic'));
         }
     }
     $array_return = array('success' => 1, 'step' => 1);
     echo json_encode($array_return);
     break;
 case 'customer':
示例#6
0
function save_image_url($url)
{
    $array_return = array('error' => 0, 'name' => '', 'ext' => '', 'path' => '');
    $image_content = curl_get_content($url);
    $filename = generate_picture_name();
    $path_dir = generate_dir_upload($filename, 'organic');
    $extension = get_header_type($url);
    if (!$extension) {
        $array_return['error'] = 1;
        return $array_return;
    }
    $filename = $filename . '.' . $extension;
    if (file_put_contents($path_dir . $filename, $image_content)) {
        $array_return = array('name' => $filename, 'ext' => $extension, 'path' => $path_dir . $filename, 'error' => 0, 'link' => get_picture_path($filename));
    }
    return $array_return;
}
示例#7
0
        $myform->add('que_title', 'que_title', 0, 0, '', 1, 'Tiêu đề trống', 1, 'Tiêu đề trùng');
        $myform->add('que_username', 'que_username', 0, 0, '', 1, 'User trống');
        $myform->add('que_cat_id', 'que_cat_id', 1, 0, 0);
        $myform->add('que_question_content', 'que_question_content', 0, 0, '', 1, 'Nội dung câu hỏi trống');
        $myform->add('que_answer_content', 'que_answer_content', 0, 0, '');
        $myform->add('que_professional', 'que_professional', 0, 0, '');
        $myform->add('que_disease', 'que_disease', 0, 0, '', 0, 'Tên bệnh trống');
        $myform->add('que_disease_id_local', 'que_disease_id_local', 1, 0, 0, 0, 'ID check bệnh local trống');
        $myform->add('que_disease_link', 'que_disease_link', 0, 0, '', 0, 'Link đến list bài viết về bệnh trống');
        $myform->add('que_link_origin', 'que_link_origin', 0, 0, '', 1, 'Link gốc của tin trống');
        $myform->add('que_image', 'que_image', 0, 0, '');
        $myform->add('que_image_profess', 'que_image_profess', 0, 0, '');
        $myform->add('que_type', 'que_type', 1, 0, 0);
        $myform->add('que_status', 'que_status', 1, 0, 0);
        $myform->add('que_date', 'time', 1, 1, 0);
        $myform->removeHTML(0);
        $error_msg = $myform->checkdata();
        if (!$error_msg) {
            foreach ($_FILES as $key => $image_file) {
                $path_picture = generate_dir_upload($image_file['name'], 'organic') . $image_file['name'];
                move_uploaded_file($image_file['tmp_name'], $path_picture);
            }
            $db_insert = new db_execute_return();
            $last_id = $db_insert->db_execute($myform->generate_insert_SQL());
            unset($db_insert);
            $api_result = array('success' => 1, 'id' => $last_id, 'sql' => $myform->generate_insert_SQL());
        } else {
            $api_result = array('error' => 1, 'msg' => $myform->checkdata() . $myform->generate_insert_SQL());
        }
        break;
}