Esempio n. 1
0
 public static function postImage($file, $filename, $uploadDir, $isThumb = false, $width = 800, $uploadThumb = "", $widthThumb = 150)
 {
     $destinationPath = $uploadDir;
     if (!file_exists($destinationPath)) {
         mkdir($destinationPath, 0777);
     }
     if ($uploadThumb != "") {
         if (!file_exists($uploadThumb)) {
             mkdir($uploadThumb, 0777);
         }
     }
     $extension = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
     $filename = $filename . "." . $extension;
     $uploadSuccess = "";
     if ($extension == "jpg" || $extension == "jpeg" || $extension == "gif" || $extension == "png" || $extension == "tiff") {
         $uploadSuccess1 = move_uploaded_file($file['tmp_name'], $destinationPath . "/" . $filename);
         if (!$uploadSuccess1) {
             return;
         }
         if ($isThumb === true) {
             $uploadSuccess2 = copy($destinationPath . "/" . $filename, $uploadThumb . "/" . $filename);
         }
     }
     ImageResize::load($destinationPath . "/" . $filename);
     ImageResize::resizeToWidth($width);
     ImageResize::save();
     if ($isThumb === true) {
         ImageResize::load($uploadThumb . "/" . $filename);
         ImageResize::resizeToWidth($widthThumb);
         ImageResize::save();
     }
     return $filename;
 }
Esempio n. 2
0
        write_memberslog($_SESSION['uid'], 2, 1006, $_SESSION['username'], "修改了个人头像");
        updatetable(table('members'), $setsqlarr, $wheresql) ? exit($setsqlarr['avatars']) : showmsg('保存失败!', 1);
    } else {
        showmsg('保存失败!', 1);
    }
} elseif ($act == 'avatars_save') {
    require_once QISHI_ROOT_PATH . 'include/cut_upload.php';
    require_once QISHI_ROOT_PATH . 'include/imageresize.class.php';
    $imgresize = new ImageResize();
    $userinfomation = get_user_info($_SESSION['uid']);
    if ($userinfomation['avatars']) {
        $up_dir_original = "../../data/avatar/original/";
        $up_dir_100 = "../../data/avatar/100/";
        $up_dir_48 = "../../data/avatar/48/";
        $up_dir_thumb = "../../data/avatar/thumb/";
        $imgresize->load($up_dir_thumb . $userinfomation['avatars']);
        $imgresize->cut(intval($_POST['w']), intval($_POST['h']), intval($_POST['x']), intval($_POST['y']));
        $imgresize->save($up_dir_thumb . $userinfomation['avatars']);
        makethumb($up_dir_thumb . $userinfomation['avatars'], $up_dir_100 . date("Y/m/d/"), 100, 100);
        makethumb($up_dir_thumb . $userinfomation['avatars'], $up_dir_48 . date("Y/m/d/"), 48, 48);
        @unlink($up_dir_original . $userinfomation['avatars']);
        @unlink($up_dir_thumb . $userinfomation['avatars']);
        $wheresql = " uid='" . $_SESSION['uid'] . "'";
        write_memberslog($_SESSION['uid'], 2, 1006, $_SESSION['username'], "修改了个人头像");
        showmsg('保存成功!', 2);
    } else {
        showmsg('请上传图片!', 1);
    }
} elseif ($act == 'password_edit') {
    $uid = intval($_SESSION['uid']);
    $smarty->assign('total', $db->get_total("SELECT COUNT(*) AS num FROM " . table('pms') . " WHERE (msgfromuid='{$uid}' OR msgtouid='{$uid}') AND `new`='1'"));
Esempio n. 3
0
 public function doUpload()
 {
     // removeFilesBeforeUpload
     if ($this->removeFilesBeforeUpload) {
         $this->removeFiles();
     }
     if (!isset($_FILES[$this->campo]['name'])) {
         return false;
     }
     $this->file = $_FILES[$this->campo]['name'];
     $this->file_tmp = $_FILES[$this->campo]['tmp_name'];
     $this->file_type = $_FILES[$this->campo]['type'];
     $this->file_size = $_FILES[$this->campo]['size'];
     $this->cantidad = count($this->file);
     // ITERATE FILES
     for ($x = 0; $x <= $this->cantidad; $x++) {
         // IF NOT SET FILENAME, EXIT
         if (!isset($this->file[$x])) {
             return false;
         }
         // IF FILENAME EMPTY, EXIT
         if (empty($this->file[$x])) {
             return false;
         }
         // FORMATEO DE LA FOTO
         $f = $this->cleanUploadFileName($this->file[$x]);
         // CHECK 10 min chars of file name (1-ee-a.jpg)
         if (strlen($f) < 6) {
             if (DEBUGIN == true) {
                 $msg = "filename " . $f . " < 6 min chars";
             }
             die($msg);
         }
         // GET REAL EXTENSION
         $ext = $this->extension($this->file[$x]);
         // CHECK EXTENCION AND MIME TYPE
         if (!in_array($ext, $this->acceptedExtencions) || !in_array($this->file_type[$x], $this->acceptedFileTypes)) {
             if (DEBUGIN == true) {
                 $msg = "not allowed filetype: " . $this->file_type[$x] . " or extencion: " . $ext;
             }
             die($msg);
         }
         // RESIZE IMG
         if ($this->resizeToWidth || $this->resizeToHeight) {
             $imageSize = getimagesize($this->file_tmp[$x]);
             $image = new ImageResize();
             $image->load($this->file_tmp[$x]);
             if ($this->resizeToWidth && $imageSize[0] >= $this->resizeToWidth) {
                 $image->resizeToWidth($this->resizeToWidth);
             }
             if ($this->resizeToHeight && $imageSize[1] >= $this->resizeToHeight) {
                 $image->resizeToHeight($this->resizeToHeight);
             }
             $image->save($this->file_tmp[$x]);
         }
         // CHMOD
         chmod($this->file_tmp[$x], $this->fileCHMOD);
         // UPLOADED
         if (!is_uploaded_file($this->file_tmp[$x])) {
             if (DEBUGIN == true) {
                 $msg = "file not uploaded";
             }
             die($msg);
         }
         // MOVE ALT FILE
         if ($this->copyToAltPath) {
             // MAKE ALT DIR
             $this->mkdir_recursive($this->altPath);
             // COPY
             $sufix = $x;
             if (!copy($this->file_tmp[$x], $this->altPath . $this->altPathFileName . $sufix . '.jpg')) {
                 if (DEBUGIN == true) {
                     $msg = "alt file not copied";
                 }
                 die($msg);
             }
         }
         // MAKE DIR
         $this->mkdir_recursive('uploads/' . $this->tabla . '/', $this->dirCHMOD);
         // MOVE FILE
         if (!move_uploaded_file($this->file_tmp[$x], 'uploads/' . $this->tabla . '/' . $f . '.' . $ext)) {
             if (DEBUGIN == true) {
                 $msg = "file not moved";
             }
             die($msg);
         }
         // INSERT FILES EN OTRA TABLA SI HAY ID Y SI SE LOGRO SUBIR
         if (isset($this->id) && $this->id != 0) {
             sq("INSERT INTO files SET item_id=" . $this->id . ", nombre='" . $f . "." . $ext . "', size='" . $this->file_size[$x] . "', tabla='" . $this->tabla . "', cat_id='" . $this->cat_id . "', subcat_id='" . $this->subcat_id . "', tipo='" . $this->campo . "', titulo='" . $this->titulo . "', type='" . $this->file_type[$x] . "', dateLastUpdate=NOW(), dateInsert=NOW() ");
         } else {
             if (DEBUGIN == true) {
                 $msg = "id is empty";
             }
             die($msg);
         }
     }
 }
Esempio n. 4
0
 if (function_exists('gd_info') && $jieqiConfigs['system']['avatarcut']) {
     //上传后需要裁剪
     //保存临时图片
     if (!empty($_FILES['avatarimage']['name'])) {
         //$imagefile=jieqi_uploadpath($jieqiConfigs['system']['avatardir'], 'system');
         //if (!file_exists($retdir)) jieqi_createdir($imagefile);
         //$imagefile.=jieqi_getsubdir($jieqiUsers->getVar('uid','n'));
         //if (!file_exists($retdir)) jieqi_createdir($imagefile);
         $tmpfile = dirname($_FILES['avatarimage']['tmp_name']) . '/tmp_' . $_FILES['avatarimage']['name'];
         //$tmpfile=$imagefile.'/tmp_'.$_FILES['avatarimage']['name'];
         @move_uploaded_file($_FILES['avatarimage']['tmp_name'], $tmpfile);
         //默认转换成jpg
         $imagefile = dirname($_FILES['avatarimage']['tmp_name']) . '/' . $jieqiUsers->getVar('uid', 'n') . '_tmp' . $jieqiConfigs['system']['avatardt'];
         include_once JIEQI_ROOT_PATH . '/lib/image/imageresize.php';
         $imgresize = new ImageResize();
         $imgresize->load($tmpfile);
         $imgresize->save($imagefile, true, substr(strrchr(trim(strtolower($imagefile)), "."), 1));
         @chmod($imagefile, 0777);
         jieqi_delfile($tmpfile);
     }
     header('Location: ' . JIEQI_URL . '/setavatar.php?action=cutavatar');
 } else {
     //直接保存
     $image_type = 0;
     foreach ($jieqi_image_type as $k => $v) {
         if ($image_postfix == $v) {
             $image_type = $k;
             break;
         }
     }
     $old_avatar = $jieqiUsers->getVar('avatar', 'n');
Esempio n. 5
0
    } else {
        showmsg('保存失败!', 1);
    }
} elseif ($act == 'make2_photo_save') {
    $resume_basic = get_resume_basic(intval($_SESSION['uid']), intval($_REQUEST['pid']));
    if (empty($resume_basic)) {
        showmsg("请先填写简历基本信息!", 0);
    }
    require_once QISHI_ROOT_PATH . 'include/cut_upload.php';
    require_once QISHI_ROOT_PATH . 'include/imageresize.class.php';
    $imgresize = new ImageResize();
    if ($resume_basic['photo_img']) {
        $up_res_original = "../../data/photo/original/";
        $up_res_120 = "../../data/photo/120/";
        $up_res_thumb = "../../data/photo/thumb/";
        $imgresize->load($up_res_thumb . $resume_basic['photo_img']);
        $imgresize->cut(intval($_POST['w']), intval($_POST['h']), intval($_POST['x']), intval($_POST['y']));
        $imgresize->save($up_res_thumb . $resume_basic['photo_img']);
        makethumb($up_res_thumb . $resume_basic['photo_img'], $up_res_120 . date("Y/m/d/"), 120, 150);
        @unlink($up_res_original . $resume_basic['photo_img']);
        // @unlink($up_res_thumb.$resume_basic['photo_img']);
        check_resume($_SESSION['uid'], intval($_REQUEST['pid']));
        showmsg("保存成功!", 2);
    } else {
        showmsg("请上传图片!", 1);
    }
} elseif ($act == "tag_save") {
    if (intval($_POST['pid']) == 0) {
        showmsg('参数错误!', 1);
    }
    $setsqlarr['tag'] = trim($_POST['tag']);
Esempio n. 6
0
        write_memberslog($_SESSION['uid'], 2, 1006, $_SESSION['username'], "修改了个人照片");
        updatetable(table('dasai_student'), $setsqlarr, $wheresql) ? exit($setsqlarr['photo']) : showmsg('保存失败!', 1);
    } else {
        showmsg('保存失败!', 1);
    }
} elseif ($act == 'photo_save') {
    require_once QISHI_ROOT_PATH . 'include/cut_upload.php';
    require_once QISHI_ROOT_PATH . 'include/imageresize.class.php';
    $imgresize = new ImageResize();
    $userinfomation = get_student_info($_SESSION['uid']);
    if ($userinfomation['photo']) {
        $up_dir_original = "../../../dasai/photo/original/";
        $up_dir_166 = "../../../dasai/photo/166/";
        $up_dir_71 = "../../../dasai/photo/71/";
        $up_dir_thumb = "../../../dasai/photo/thumb/";
        $imgresize->load($up_dir_thumb . $userinfomation['photo']);
        $imgresize->cut(intval($_POST['w']), intval($_POST['h']), intval($_POST['x']), intval($_POST['y']));
        $imgresize->save($up_dir_thumb . $userinfomation['photo']);
        makethumb($up_dir_thumb . $userinfomation['photo'], $up_dir_166, 166, 235);
        makethumb($up_dir_thumb . $userinfomation['photo'], $up_dir_71, 71, 100);
        @unlink($up_dir_original . $userinfomation['photo']);
        @unlink($up_dir_thumb . $userinfomation['photo']);
        $wheresql = " uid='" . $_SESSION['uid'] . "'";
        write_memberslog($_SESSION['uid'], 2, 1006, $_SESSION['username'], "修改了个人头像");
        showmsg('保存成功!', 2);
    } else {
        showmsg('请上传图片!', 1);
    }
} elseif ($act == 'download') {
    require_once QISHI_ROOT_PATH . 'include/fun_user.php';
    $smarty->assign('title', '下载/打印报名表 - 会员中心 - ' . $_CFG['site_name']);
Esempio n. 7
0
    $smarty->assign('act', $act);
    $smarty->assign('teachers', $teachers);
    $smarty->assign('teachers_photo', $teachers['photo_img']);
    $smarty->assign('pid', $_REQUEST['pid']);
    $smarty->assign('title', '裁切照片 - 培训会员中心 - ' . $_CFG['site_name']);
    $smarty->display('member_train/train_teachers_photo_cutting.htm');
} elseif ($act == 'save_teachers_photo_cutting') {
    $teachers = get_teachers_one(intval($_REQUEST['pid']), intval($_SESSION['uid']));
    if (empty($teachers)) {
        showmsg("请先填写讲师基本信息!", 0);
    }
    require_once QISHI_ROOT_PATH . 'include/imageresize.class.php';
    $imgresize = new ImageResize();
    $photo_dir = QISHI_ROOT_PATH . substr($_CFG['teacher_photo_dir'], strlen($_CFG['site_dir']));
    $photo_thumb_dir = QISHI_ROOT_PATH . substr($_CFG['teacher_photo_dir_thumb'], strlen($_CFG['site_dir']));
    $imgresize->load($photo_dir . $teachers['photo_img']);
    $posary = explode(',', $_POST['cut_pos']);
    foreach ($posary as $k => $v) {
        $posary[$k] = intval($v);
    }
    if ($posary[2] > 0 && $posary[3] > 0) {
        $imgresize->resize($posary[2], $posary[3]);
    }
    $imgresize->cut(120, 150, intval($posary[0]), intval($posary[1]));
    $imgresize->save($photo_thumb_dir . $teachers['photo_img']);
    header('Location: ?act=photo_cutting&show=ok&pid=' . $_REQUEST['pid']);
} elseif ($act == 'edit_photo_display') {
    header('Location: ?act=teachers_show&id=' . intval($_REQUEST['pid']));
} elseif ($act == 'teachers_show') {
    $teachers = get_teachers_one(intval($_GET['id']), $_SESSION['uid']);
    if (empty($teachers)) {