コード例 #1
0
ファイル: functions_1.php プロジェクト: virutmath/crm_local
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
ファイル: resize_image.php プロジェクト: virutmath/suckhoe
function resizeImage()
{
    //lay duong dan file duoc request
    $request = $_SERVER['REQUEST_URI'];
    //lay ten file
    $tmp_request = explode('/', $request);
    $case = count($tmp_request);
    $image_name = $tmp_request[$case - 1];
    //type resize
    $resize_type = $tmp_request[$case - 2];
    //echo $image_name;
    $resource_img = get_picture_dir($image_name) . '/' . $image_name;
    $resource_img = '..' . $resource_img;
    if (!file_exists($resource_img)) {
        error_404_document();
    }
    //echo file_get_contents($resource_img);exit();
    $images = new Image($resource_img);
    $imageinfo = $images->getImageInfo();
    if ($imageinfo['height'] == null || $imageinfo['height'] == 0) {
        error_404_document();
    }
    //kich thuoc resize
    $array_resize = array('large' => array(480, 360), 'medium' => array(240, 180), 'medium2' => array(145, 95), 'small' => array(106, 80), 'thumb' => array(50, 50), 'mobile' => array(640, 400), 'mobile_medium' => array(320, 200), 'mobile_small' => array(120, 75), 'mobile_low' => array(640, 400, 30), 'mobile_medium_low' => array(320, 200, 30), 'mobile_small_low' => array(120, 75, 30));
    if (!isset($array_resize[$resize_type])) {
        error_404_document();
    }
    //image name file no extension
    $filesavename = explode('.', $image_name);
    $count3 = count($filesavename);
    if ($count3 > 1) {
        unset($filesavename[$count3 - 1]);
    }
    $filesavename = implode('.', $filesavename);
    $pathsave = '..' . get_picture_dir($image_name, $resize_type);
    //nếu thư mục ảnh không tồn tại thì tạo mới
    if (!file_exists($pathsave)) {
        mkdir($pathsave, 0755, 1);
    }
    //echo $pathsave;die();
    //kich thuoc resize ok -> tao file voi kich thuoc phu hop
    $r_width = $array_resize[$resize_type][0];
    $r_height = $array_resize[$resize_type][1];
    if (isset($array_resize[$resize_type][2])) {
        $r_quality = $array_resize[$resize_type][2];
    } else {
        $r_quality = 100;
    }
    if ($resize_type == 'organic') {
        $images->resize($r_width, $r_height, 'fit', 'c', 'c', $r_quality);
    } else {
        $images->resize($r_width, $r_height, 'crop', 'c', 'c', $r_quality);
    }
    $images->save($filesavename, $pathsave);
    header("HTTP/1.0 200 OK");
    $images->display();
}
コード例 #3
0
ファイル: edit.php プロジェクト: virutmath/suckhoe
$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);
if ($row = mysqli_fetch_assoc($db_data->result)) {
コード例 #4
0
ファイル: add.php プロジェクト: virutmath/suckhoe
$myform->add('new_title', 'new_title', 0, 0, '', 1, 'Bạn chưa nhập tiêu đề');
$myform->add('new_active', 'new_active', 1, 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
        $new_picture = getValue('new_picture', 'str', 'POST', '');
        if ($new_picture) {
            $myform->add('new_picture', 'new_picture', 0, 1, '');
            //move ảnh
            $path_upload = '../../..' . get_picture_dir($new_picture) . '/' . $new_picture;
            rename('../../../temp/' . $new_picture, $path_upload);
        }
        $db_insert = new db_execute_return();
        $last_id = $db_insert->db_execute($myform->generate_insert_SQL());
        unset($db_insert);
        /**
         * something code here
         */
        //redirect
        if ($last_id) {
            redirect($form_redirect);
        }
    }
}
#Phần hiển thị
コード例 #5
0
ファイル: add.php プロジェクト: virutmath/suckhoe
 * Something here ...
 * insert, update...
 */
$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) {
        //chuyển ảnh đại diện từ thư mục temp sang nếu là ảnh được upload
        $get_from_link = getValue('get_from_link', 'int', 'POST', 0);
        if (!$get_from_link) {
            $picture_temp = getValue('ndi_picture', 'str', 'POST', 1);
            $path_upload = '../../..' . get_picture_dir($picture_temp) . '/' . $picture_temp;
            rename('../../../temp/' . $picture_temp, $path_upload);
        }
        $db_insert = new db_execute_return();
        $last_id = $db_insert->db_execute($myform->generate_insert_SQL());
        unset($db_insert);
        /**
         * something code here
         */
        //redirect
        if ($last_id) {
            //insert detail
            $myform_detail = new generate_form();
            $myform_detail->addTable('news_disease_detail');
            $myform_detail->add('ndi_id', 'last_id', 1, 1, 0);
            $myform_detail->add('ndi_detail', 'ndi_detail', 0, 0, '', 1);