Exemplo n.º 1
0
 function save($temp_name, $field_name = false, $table = false, $id = false, $dir = false, $img_sizes = false, $field_name_n = false)
 {
     global $CFG;
     if ($temp_name) {
         $temp_name1 = $temp_name;
         $temp_name = $CFG->dirroot . $CFG->temp_file_location . $temp_name;
         $dir1 = $dir;
         $dir = $dir ? $CFG->dirroot . $dir : $CFG->dirroot . $CFG->default_upload_location;
         $dir = !stristr($dir, '/') ? $dir . '/' : $dir;
         $file_parts = explode('.', $temp_name);
         $ext = strtolower(end($file_parts));
         DB::saveImageSizes($field_name, $_REQUEST['image_sizes'][$field_name]);
         $image_sizes = DB::getImageSizes($field_name);
         if ($id) {
             $ext1 = in_array($ext, $CFG->accepted_image_formats) ? 'jpg' : $ext;
             $i = DB::insert($table . '_files', array('f_id' => $id, 'ext' => $ext1, 'dir' => $dir1, 'old_name' => $temp_name1, 'field_name' => $field_name));
             self::saveDescriptions($table, $field_name_n, $i);
             if (in_array($ext, $CFG->accepted_image_formats)) {
                 $ir = new ImageResize($temp_name, false, false, false);
                 if ($_REQUEST['crop_images'][$field_name]) {
                     $ir->setAutoCrop(true);
                 }
                 $ir->setHighQuality();
                 if (!is_array($img_sizes)) {
                     $ir->save($dir . $table . '_' . $id . '_' . $i . '.' . $ext1, 'jpeg', 90);
                     if ($_REQUEST['encrypt_files'][$field_name]) {
                         File::encrypt($dir . $table . '_' . $id . '_' . $i . '.' . $ext1);
                     }
                 } else {
                     foreach ($image_sizes as $key => $size) {
                         $ir->setSize($size['width'], $size['height']);
                         $ir->save($dir . $table . '_' . $id . '_' . $i . '_' . $key . '.' . $ext1, 'jpeg', 90);
                         if ($_REQUEST['encrypt_files'][$field_name]) {
                             File::encrypt($dir . $table . '_' . $id . '_' . $i . '_' . $key . '.' . $ext1);
                         }
                     }
                 }
                 @unlink($temp_name);
                 return true;
             } else {
                 if (rename($temp_name, $dir . $table . '_' . $id . '_' . $i . '.' . $ext)) {
                     if ($_REQUEST['encrypt_files'][$field_name]) {
                         File::encrypt($dir . $table . '_' . $id . '_' . $i . '.' . $ext);
                     }
                     return true;
                 }
             }
         } else {
             if (@rename($temp_name, $dir . $temp_name)) {
                 if ($_REQUEST['encrypt_files'][$field_name]) {
                     File::encrypt($dir . $dir . $temp_name);
                 }
                 return $dir . $temp_name;
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * リサイズ
  */
 public function resize($fileName, $mimeType, $sizeType = 'normal')
 {
     // 画像のサイズを取得する。
     $imageSize = $this->sizes($fileName);
     // 画像の拡張性を設定スル。
     $mimeType = explode('/', $mimeType);
     App::uses('ImageResize', 'Vendor');
     // 切り抜きサイズを取得
     $resize = Configure::read('resize_info');
     $resize = $resize[$sizeType];
     //画像を幅100pxでリサイズして保存
     $newImgname = time() . rand(100000, 999999) . '.png';
     $thumb = new ImageResize($fileName, $mimeType[1]);
     $thumb->name($newImgname);
     if ($resize['height'] > $resize['width']) {
         $thumb->height($resize['height']);
     } else {
         $thumb->width($resize['width']);
     }
     $thumb->save();
     // サイズの中心から抜き取り。
     $tmp_dir = ini_get('upload_tmp_dir');
     if (empty($tmp_dir)) {
         $tmp_dir = '/tmp';
     }
     if ($resize['height'] != null) {
         $thumb = new ImageResize($tmp_dir . '/' . $newImgname, $mimeType[1]);
         $thumb->name($newImgname);
         $thumb->width($resize['width']);
         $thumb->height($resize['height']);
         $thumb->crop(0, 0);
         $thumb->save();
     }
     return $tmp_dir . '/' . $newImgname;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
function ResizeImage($x, $y, $imageurl)
{
    if ($x > 0 && $y > 0 && strlen($imageurl) > 3) {
        $data = parse_url(str_replace('/', '!', $imageurl));
        $newfilename = $data['scheme'] . '~' . $data['host'] . '~' . $x . '~' . $y . $data['path'];
        $newfilepath = 'temp/' . $newfilename;
        $newsavedfilepath = 'resized/' . $newfilename;
        $baseurl = 'http://futurestore.areality3d.com';
        if (!file_exists($newsavedfilepath)) {
            $handle = copy($imageurl, $newfilepath);
            $image = new ImageResize($newfilepath);
            $image->crop($x, $y);
            $image->save($newsavedfilepath);
            $newurl = $baseurl . '/' . $newsavedfilepath;
        } else {
            $newurl = $baseurl . '/' . $newsavedfilepath;
        }
        return $newurl;
    } else {
        return 'need x,y,imageurl';
    }
}
Exemplo n.º 5
0
<!DOCTYPE html>
<html lang="es">
<head>
	<meta charset="UTF-8">
	<title>Ejemplo</title>

</head>
<body>
	<h1 id="titulo">Ejemplo</h1>
	
	<div>
		
		<?php 
require "ImageResize.php";
$src = "archivo.jpg";
$dest = "archivo150x150.jpg";
$resize = new ImageResize($src);
$resize->resize(150, 150);
if (!@$resize->save($dest)) {
    echo "Archivo no fue generado. Error: " . error_get_last();
} else {
    echo "Archivo {$dest} generado.";
}
?>

	</div>
</body>
</html>

	function subirImagen($descripcion){
		include_once("imageresize.class.php");
		$f=new funciones();
		$pagina="mantenimiento.php?usuario=".$_GET["usuario"]."&tipo=".$_GET["tipo"]."&transaccion=picsGal&galPage=";
		$idFolder=$_GET["idFolder"];
		
		$ruta=$f->subir_archivos("galerias");
		if(mysql::consulta("INSERT INTO fotosgaleria(id,idGaleria,ruta,descripcion) VALUES(Null,'".$idFolder."','".$ruta."','".$descripcion."')")){
				
			////////////////////    Crear thumbnail     //////////////////////
			$source = $ruta;
			$dest = str_replace("galerias","galerias/thumbs",$ruta);
			$oResize = new ImageResize($source);
			//$oResize->resizeArea(8); //porcentaje
			//$oResize->resizeWidth(160);
			$oResize->resizeWidthHeight(130,130);
			$oResize->save($dest);
			//////////////////////////////////////////
			header("Location: ".$pagina."optFolder&idFolder=".$idFolder."");			
		}
	}
Exemplo n.º 7
0
     echo '<script>std_empty();</script>';
     echo "<meta http-equiv='refresh' content='1;url='>";
     exit;
 }
 $image_name = isset($_FILES['edit-students-image']['name']) ? $_FILES['edit-students-image']['name'] : NULL;
 $tmp_name = isset($_FILES['edit-students-image']['tmp_name']) ? $_FILES['edit-students-image']['tmp_name'] : NULL;
 $rand_img = !empty($image_name) ? rand(1000, 9999) . '.jpg' : '';
 if (!empty($image_name)) {
     $students_img_location = $plug_path . 'images/scl_students/' . $rand_img;
     if (!empty($image_name)) {
         $mime = getimagesize($tmp_name);
         if (in_array('image', explode('/', $mime['mime']))) {
             move_uploaded_file($tmp_name, $students_img_location);
             $image = new ImageResize($students_img_location);
             $image->resize(140, 140);
             $image->save();
             copy($students_img_location, 'img/admin/student_' . $rand_img);
         }
     }
 }
 $fields = array('id' => $_POST['id'], 'name' => $_POST['name'], 'class' => $_POST['class'], 'roll' => $_POST['roll'], 'gender' => $_POST['gender'], 'address' => $_POST['address'], 'date_of_birth' => $_POST['date_of_birth'], 'mobile' => $_POST['mobile'], 'email' => $_POST['email']);
 if (!empty($image_name)) {
     $fields['image'] = $rand_img;
 }
 $where = array('id' => $_POST['id']);
 if (db_update('scl_students', $fields, $where)) {
     $fields = array('full_name' => $_POST['name'], 'email' => $_POST['email']);
     $where = array('username' => 'student_' . $_POST['id']);
     if (isset($image_name)) {
         $student_acc_img = 'student_' . $rand_img;
         $fields['image'] = $student_acc_img;
								
								if($totalimagenes!=$totalthumbs){
								
									for($x=0;$x<$totalimagenes;$x++){
									
										$source = $rutafolder."/".$imagenes[$x];
										$dest = $rutafolder."/thumbs/".$imagenes[$x];
										
										if (!file_exists($dest)){
										
											@unlink($dest);
											$oResize = new ImageResize($source);
											//$oResize->resizeArea(8); //porcentaje
											//$oResize->resizeWidth(120);
											$oResize->resizeWidthHeight(120,90);
											$oResize->save($dest);
										
										}
									}
								}
								
								//////////////////////////////////////////////////////////////////////////////////////
								
								$totalxpagina=15;
								$totalpaginas=($totalimagenes/$totalxpagina);
								if(is_float($totalpaginas)){ $totalpaginas=ceil($totalpaginas);}
								
								if(isset($_GET["page"])){
									
									$pagina=$_GET["page"];
									
Exemplo n.º 9
0
    } 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'"));
    $smarty->assign('title', '修改密码 - 个人会员中心 - ' . $_CFG['site_name']);
    $smarty->display('member_personal/personal_password.htm');
Exemplo n.º 10
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);
         }
     }
 }
Exemplo n.º 11
0
<?php

include 'ImageResize.php';
?>

<?php 
//EJEMPLO DE USO DE LA CLASE ImageResize:
$nombreDeImagen = "imagenX";
$src = PATH_IMG . $nombreDeImagen . ".jpg";
$dest1 = PATH_IMG_R50x50 . $nombreDeImagen . ".jpg";
$dest2 = PATH_IMG_R150x150 . $nombreDeImagen . ".jpg";
$imagen = new ImageResize($src);
$imagen->resize(50, 50);
@$imagen->save($dest1);
$imagen->resize(150, 150);
if (!@$imagen->save($dest2)) {
    echo "Archivo no fue generado. Error: " . error_get_last();
} else {
    echo "Archivo {$dest2} generado.";
}
Exemplo n.º 12
0
 function save($temp_name, $field_name = false, $table = false, $id = false, $dir = false, $img_sizes = false, $field_name_n = false)
 {
     global $CFG;
     if ($temp_name) {
         $temp_name1 = $temp_name;
         $temp_name = $CFG->dirroot . $CFG->temp_file_location . $temp_name;
         $dir1 = $dir;
         $dir = $dir ? $CFG->dirroot . $dir : $CFG->dirroot . $CFG->default_upload_location;
         $dir = !stristr($dir, '/') ? $dir . '/' : $dir;
         $file_parts = explode('.', $temp_name);
         $ext = strtolower(end($file_parts));
         if (!empty($_REQUEST['tokenizers'])) {
             unset($_REQUEST['tokenizers']);
         }
         DB::saveImageSizes($field_name, $_REQUEST['image_sizes'][$field_name]);
         $image_sizes = DB::getImageSizes($field_name);
         if ($id) {
             $ext1 = $ext;
             $i = DB::insert($table . '_files', array('f_id' => $id, 'ext' => $ext1, 'dir' => $dir1, 'old_name' => $temp_name1, 'field_name' => $field_name));
             self::saveDescriptions($table, $field_name_n, $i);
             if (in_array($ext, $CFG->accepted_image_formats)) {
                 $factory = new \ImageOptimizer\OptimizerFactory(array('ignore_errors' => false, 'jpegoptim_options' => array('--strip-all', '--all-progressive', '--max=75')), $logger);
                 $optimizer = $factory->get('jpegoptim');
                 $ir = new ImageResize($temp_name, false, false, false);
                 $ir->setHighQuality();
                 if ($_REQUEST['crop_images'][$field_name]) {
                     $ir->setAutoCrop(true);
                 }
                 if (!is_array($img_sizes)) {
                     $ir->save($dir . $table . '_' . $id . '_' . $i . '.' . $ext1, $ext1, 100);
                     $optimizer->optimize($dir . $table . '_' . $id . '_' . $i . '.' . $ext1);
                     if ($_REQUEST['encrypt_files'][$field_name]) {
                         File::encrypt($dir . $table . '_' . $id . '_' . $i . '.' . $ext1);
                     }
                 } else {
                     foreach ($image_sizes as $key => $size) {
                         $ir->setSize($size['width'], $size['height']);
                         $ir->save($dir . $table . '_' . $id . '_' . $i . '_' . $key . '.' . $ext1, 'jpeg', 100);
                         $optimizer->optimize($dir . $table . '_' . $id . '_' . $i . '_' . $key . '.' . $ext1);
                         if ($_REQUEST['encrypt_files'][$field_name]) {
                             File::encrypt($dir . $table . '_' . $id . '_' . $i . '_' . $key . '.' . $ext1);
                         }
                     }
                 }
                 unlink($temp_name);
                 return true;
             } else {
                 if (rename($temp_name, $dir . $table . '_' . $id . '_' . $i . '.' . $ext)) {
                     if ($_REQUEST['encrypt_files'][$field_name]) {
                         File::encrypt($dir . $table . '_' . $id . '_' . $i . '.' . $ext);
                     }
                     return true;
                 }
             }
         } else {
             if (rename($temp_name, $dir . $temp_name)) {
                 if ($_REQUEST['encrypt_files'][$field_name]) {
                     File::encrypt($dir . $dir . $temp_name);
                 }
                 return $dir . $temp_name;
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 13
0
     //上传后需要裁剪
     //保存临时图片
     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');
     $jieqiUsers->unsetNew();
Exemplo n.º 14
0
    }
} 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']);
    $id = intval($_REQUEST['pid']);
    $tag = explode('|', $_POST['tag']);
Exemplo n.º 15
0
    } 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']);
    $smarty->assign('user', get_student_info(intval($_SESSION['uid'])));
    $smarty->display('member_personal/dasai_download.htm');
Exemplo n.º 16
0
        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)) {
        showmsg("参数错误!", 1);
    }
    $smarty->assign('title', '修改讲师资料 - 培训会员中心 - ' . $_CFG['site_name']);
    $smarty->assign('teachers', $teachers);
    $smarty->display('member_train/train_teachersshow.htm');
} elseif ($act == 'del_teachers') {
    $yid = !empty($_POST['y_id']) ? $_POST['y_id'] : $_GET['y_id'];
    if ($n = del_teachers($yid, $_SESSION['uid'])) {
        showmsg("删除成功!共删除 {$n} 行", 2);