当前位置: 首页>>代码示例>>PHP>>正文


PHP img_resize函数代码示例

本文整理汇总了PHP中img_resize函数的典型用法代码示例。如果您正苦于以下问题:PHP img_resize函数的具体用法?PHP img_resize怎么用?PHP img_resize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了img_resize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload_file

function upload_file($file)
{
    if ($file['name'] == '') {
        echo 'Файл не выбран!';
        return;
    }
    //Проверяем расширения изображений, их размер и процесс копирования из временной директории
    if ($file['type'] == 'image/jpeg' || $file['type'] == 'image/png' || $file['type'] == 'image/pjpeg' || $file['type'] == 'image/gif') {
        if ($file['size'] <= GW_MAXFILESIZE) {
            if (copy($file['tmp_name'], 'img/' . $file['name'])) {
                echo 'Файл успешно загружен';
                img_resize('img/' . $file['name'], 'thumbs/thumb_' . $file['name'], '250', '150');
            } else {
                echo 'Ошибка загрузки файла';
                return;
            }
        } else {
            echo "Файл не должен превышать размер в 5 Мб!";
            return;
        }
    } else {
        echo "Файл должен иметь одно из известных расширений графических изображений (gif, jpeg или png)!";
        return;
    }
}
开发者ID:GonikDaniel,项目名称:php_study_project,代码行数:25,代码来源:index.bak.php

示例2: upload_file

function upload_file($file)
{
    if ($file['name'] == '') {
        echo 'Файл не выбран!';
        return;
    }
    //Проверяем расширения изображений, их размер и процесс копирования из временной директории
    $arr = explode(".", $file['name']);
    $ext = mb_strtolower($arr[count($arr) - 1]);
    $allowed = array('jpg', 'jpeg', 'png', 'gif');
    $img_name = htmlspecialchars(trim($file['name']));
    $thumb_name = 'thumb_' . $img_name;
    if (in_array($ext, $allowed)) {
        if ($file['size'] <= GW_MAXFILESIZE) {
            if (copy($file['tmp_name'], 'img/' . $img_name)) {
                echo 'Файл успешно загружен';
                img_resize('img/' . $img_name, 'thumbs/' . $thumb_name, '250', '150');
                $dbc = mysqli_connect(HOSTNAME, USERNAME, PASSWORD, DBNAME) or die('No connect with data base');
                $query = "INSERT INTO `images` (`image_name`, `thumb_name`) VALUES ('{$img_name}', '{$thumb_name}')";
                mysqli_query($dbc, $query) or die("Ошибка при отправке запроса<br>" . mysql_error());
                mysqli_close($dbc);
            } else {
                echo 'Ошибка загрузки файла';
                return;
            }
        } else {
            echo "Файл не должен превышать размер в 5 Мб!";
            return;
        }
    } else {
        echo "Файл должен иметь одно из известных расширений графических изображений (gif, jpeg или png)!";
        return;
    }
}
开发者ID:GonikDaniel,项目名称:php_study_project,代码行数:34,代码来源:functions.php

示例3: subirArchivo

/**
 * Sube un archivo a la carpeta uploads
 * @param unknown_type $arr_file_desc
 * @param unknown_type $destino
 * @param unknown_type $name
 */
function subirArchivo($arr_file_desc, $destino = null, $name = null)
{
    $arr_file = array();
    $file_extension = file_extension($arr_file_desc['name']);
    if ($destino == null) {
        $dia = date("j");
        $mes = date("n");
        $anyo = date("Y");
        $new_relative_path = $anyo . BARRA_SERVIDOR . $mes . BARRA_SERVIDOR . $dia;
    } else {
        $new_relative_path = $destino;
    }
    if ($name != null) {
        $new_file_name = $name;
    } else {
        $new_file_name = str_replace("." . $file_extension, "", $arr_file_desc['name']);
    }
    // Creamos la ruta de carpetas
    createPath($new_relative_path);
    // Si existe el archivo, con un contador cambio el nombre hasta que deje de existir
    $cont = 0;
    while (file_exists(UPLOAD_DIR . BARRA_SERVIDOR . $new_relative_path . BARRA_SERVIDOR . $new_file_name . "." . $file_extension)) {
        $cont++;
        $new_file_name .= $cont;
    }
    if (file_exists($arr_file_desc['tmp_name'])) {
        if (!copy($arr_file_desc['tmp_name'], UPLOAD_DIR . BARRA_SERVIDOR . $new_relative_path . BARRA_SERVIDOR . $new_file_name . "." . $file_extension)) {
            print "Error, no ha sido posible la copia del archivo";
        } else {
            //borro el archivo temporal
            unlink($arr_file_desc['tmp_name']);
        }
    } else {
        header('Content-type: application/json');
        //objeto json que devolverá la respuesta
        $jsondata = array();
        $jsondata['error'] = true;
        $jsondata['msg'] = "No se ha podido subir el archivo, intentelo de nuevo o contacte con su administrador.";
        echo json_encode($jsondata);
        exit;
    }
    $new_file_path = $new_relative_path . BARRA_SERVIDOR . $new_file_name . "." . $file_extension;
    $origen_dir = UPLOAD_DIR . BARRA_SERVIDOR . substr($new_file_path, 0, strrpos($new_file_path, BARRA_SERVIDOR)) . BARRA_SERVIDOR;
    $nombre_archivo = substr($new_file_path, strrpos($new_file_path, BARRA_SERVIDOR) + 1);
    $nombre_sin_extension = substr($nombre_archivo, 0, strrpos($nombre_archivo, "."));
    $extension = substr($new_file_path, strrpos($new_file_path, ".") + 1);
    //si es una imagen, creo una más pequeña para agilizar la carga con thumbnails
    if ($extension == "jpg" || $extension == "gif" || $extension == "png") {
        //$info = getimagesize ($new_file_path);
        img_resize($origen_dir . $nombre_archivo, THUMBNAIL_WIDTH, $origen_dir, $nombre_sin_extension . "." . $extension, THUMBNAIL_HEIGHT);
    }
    // Devuelvo la ruta sin la carpeta padre por si se cambia en la configuracion
    return $new_file_path;
}
开发者ID:migumuno,项目名称:Core,代码行数:60,代码来源:functions.php

示例4: file_upload

function file_upload($file, $gallery_path, $link, $galleryid)
{
    if ($file['name'] == '') {
        return 'Файл не выбран!';
    }
    $format = strtolower(substr($file['type'], strpos($file['type'], '/') + 1));
    if (!($format == 'jpeg' || $format == 'png')) {
        return 'Формат ' . $format . ' не поддерживается';
    }
    $size = (int) $file['size'];
    if ($size > 1000000) {
        return 'Максимально допустимый размер файла 1Мб!';
    }
    $sides = getimagesize($file['tmp_name']);
    $width = $sides[0];
    $height = $sides[1];
    if ($width < 150 || $height < 150) {
        return 'Ширина и высота изображения должны быть не меньше 150 пикселей';
    }
    $index = time() . '_';
    // для уникального имени файла
    $new_name = $index . translit_space($file['name']);
    $path_full = $gallery_path . 'full/' . $new_name;
    $path_min = $gallery_path . 'min/' . $new_name;
    // добавляем файл на сервер
    if (copy($file['tmp_name'], $path_full)) {
        if (img_resize($file['tmp_name'], $path_min, 150, 150)) {
            //Добавляем в БД
            // if(isset($_POST['img_name'])){
            // 	$img_name = $_POST['img_name'];
            // } else{
            // 	$img_name = '';
            // }
            isset($_POST['img_name']) ? $img_name = $_POST['img_name'] : ($img_name = '');
            isset($_POST['img_alt']) ? $img_alt = $_POST['img_alt'] : ($img_alt = '');
            isset($_POST['img_title']) ? $img_title = $_POST['img_title'] : ($img_title = '');
            if (mysqli_query($link, "INSERT Image(Name, FileName, Alt, Title, GalleryID) \n\t\t\t\t\t\t\t\t\tSELECT '{$img_name}', '{$new_name}', '{$img_alt}', '{$img_title}', {$galleryid}")) {
                return 'Файл <b>&quot;' . $file['name'] . '&quot;</b> успешно загружен';
            } else {
                return 'Ошибка работы  с базой данных';
                // Код для удаления загруженного и preview-файла
                // ...
            }
        } else {
            return 'Ошибка при создании preview-файла';
            // Код для удаления загруженного файла
            // ...
        }
    } else {
        return 'Ошибка загрузки файла';
    }
}
开发者ID:alexxxiy,项目名称:geekbrains-homework-php01-gallery,代码行数:52,代码来源:model_image_insert.php

示例5: resizeImage

 protected function resizeImage($file)
 {
     require_once "includes/img_resize.php";
     $tmpname = $this->tempdestination;
     $tmpname .= isset($this->newName) ? $this->newName : $file['name'];
     $size = 400;
     $save_dir = "img/temp/thumbs/";
     $save_name = "thumb_";
     $save_name .= isset($this->newName) ? $this->newName : $file['name'];
     $resize = img_resize($tmpname, $size, $save_dir, $save_name);
     if (!$resize) {
         $this->messages[] = "Gat ekki gert smámynd.";
     }
 }
开发者ID:GudniNatan,项目名称:Myndavefur-VEF2A3U,代码行数:14,代码来源:Upload.php

示例6: createDefaultImages

 public function createDefaultImages($preset)
 {
     if ($preset['is_internal']) {
         return false;
     }
     $default_root = cmsConfig::get('upload_path') . 'default/';
     foreach ($this->default_images_types as $image_type) {
         $file_name = $image_type . '_' . $preset['name'] . '.png';
         $original_file = $image_type . '_original.png';
         $create = true;
         // если такой файл есть, смотрим размер изображения, если изменился, удаляем и создаем новый
         if (file_exists($default_root . $file_name)) {
             $create = false;
             $size = getimagesize($default_root . $file_name);
             // проверяем только заданные в пресете размеры
             if ($preset['width'] && $preset['width'] != $size[0]) {
                 $create = true;
             }
             if ($preset['height'] && $preset['height'] != $size[1]) {
                 $create = true;
             }
             if ($create) {
                 @unlink($default_root . $file_name);
             }
         }
         if ($create) {
             if (!file_exists($default_root . $original_file)) {
                 return false;
             }
             if (!isset($preset['height'])) {
                 $preset['height'] = $preset['width'];
             }
             img_resize($default_root . $original_file, $default_root . $file_name, $preset['width'], $preset['height'], $preset['is_square'], 30);
         }
         return true;
     }
 }
开发者ID:pin-git,项目名称:icms2,代码行数:37,代码来源:backend.php

示例7: pathinfo

    $path_parts = pathinfo($realfile);
    $ext = mb_strtolower($path_parts['extension']);
    if ($ext != 'jpg' && $ext != 'jpeg' && $ext != 'gif' && $ext != 'png' && $ext != 'bmp') {
        exit(0);
    }
    $lid = $inDB->get_fields('cms_user_photos', 'id>0', 'id', 'id DESC');
    $lastid = $lid['id'] + 1;
    $filename = md5($lastid . $realfile) . '.jpg';
    $uploadphoto = $uploaddir . $filename;
    $uploadthumb['small'] = $uploaddir . 'small/' . $filename;
    $uploadthumb['medium'] = $uploaddir . 'medium/' . $filename;
    $source = $_FILES['Filedata']['tmp_name'];
    $errorCode = $_FILES['Filedata']['error'];
    if ($inCore->moveUploadedFile($source, $uploadphoto, $errorCode)) {
        @img_resize($uploadphoto, $uploadthumb['small'], 96, 96, true);
        @img_resize($uploadphoto, $uploadthumb['medium'], 600, 600, false, false);
        if ($model->config['watermark']) {
            @img_add_watermark($uploadthumb['medium']);
        }
        @unlink($uploadphoto);
        $model->addUploadedPhoto($user_id, array('filename' => $realfile, 'imageurl' => $filename));
        if (cmsCore::inRequest('upload')) {
            cmsCore::redirect('/users/' . $inUser->login . '/photos/submit');
        }
    } else {
        header("HTTP/1.1 500 Internal Server Error");
        echo cmsCore::uploadError();
    }
    exit(0);
}
if ($pdo == 'submitphotos') {
开发者ID:vicktorwork,项目名称:cms1,代码行数:31,代码来源:photos.php

示例8: pathinfo

    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    $newName = $Auth->generateCode(20);
    $data = array('old' => $filename, 'new' => $newName . '.' . $ext, 'small' => $newName . '_s.' . $ext, 'size' => $_FILES['file']['size'], 'status' => -1, 'errorMsg' => '');
    $destination = _UPLOAD_RIR . $data['new'];
    $destinationSmall = _UPLOAD_RIR . $data['small'];
    if (move_uploaded_file($_FILES['file']['tmp_name'], $destination)) {
        $rows = array('category', 'src_large', 'src_small', 'oldname', 'newname', 'folder', 'size', 'user');
        $queryData = array($_POST['category'], $data['new'], $data['small'], $data['old'], $newName, _UPLOAD_RIR, $data['size'], $_COOKIE['id']);
        $id = $Db->insert('galary_images', $rows, $queryData);
        if ($id > 0) {
            $data['status'] = 1;
            $data['id'] = $id;
        }
    }
    echo json_encode($data);
    img_resize($destination, $destinationSmall, 200, 0);
} else {
    $data = array('status' => -1, 'errorMsg' => 'Недостаточно прав');
    echo json_encode($data);
}
/*
    Функция img_resize(): генерация thumbnails
    Параметры:
      $src             - имя исходного файла
      $dest            - имя генерируемого файла
      $width, $height  - ширина и высота генерируемого изображения, в пикселях
    Необязательные параметры:
      $rgb             - цвет фона, по умолчанию - белый
      $quality         - качество генерируемого JPEG, по умолчанию - максимальное (100)
    ***********************************************************************************/
function img_resize($src, $dest, $width, $height, $rgb = 0xffffff, $quality = 100)
开发者ID:bustEXZ,项目名称:AdministrationPanel,代码行数:31,代码来源:upload.php

示例9: getimagesize

			$temp_name=$_SERVER['DOCUMENT_ROOT']."/userfiles/tmp/".$_FILES["filename"]["name"];
//			print_r($_SERVER['DOCUMENT_ROOT']);
//			exit;
	//перемещаем на сервак файлик
			if(move_uploaded_file($_FILES["filename"]["tmp_name"],$temp_name))
			{
	//смотрим параметры файла
				
				$name_file=$temp_name;
				$name_files="/userfiles/tmp/".$_FILES["filename"]["name"];
				$path_image="../../userfiles/tmp/";
				$size = getimagesize($name_file);
				if (($size[0]<120) && ($size[1]<100)) {$x=$size[0];$y=$size[1];} else {$x=120;$y=100;}
	//делаем резайз файла под нужные размеры
//				require ('image_resize.php');
				if (img_resize($name_file,$name_file, $x, $y))
				{
						echo "<br><b><p class=blue1 align=center>Преобразование прошло успешно</p></b>";
						?><div align='center'><a href="#" class="blue1" align="center" onClick="image_mag_up('<?echo $name_files;?>','<?echo $_FILES["filename"]["type"];?>'); window.close(); ">Дальше</a></div><?
					}
					else
						echo 'Файл не смог быть преобразован'; 
			}
			else {echo "Не удалось переместить файл";}
		}
		else {echo "<p width='400' height='70' class='blue1'><div align='center' class='mmsel'>ОШИБКА.<br>Выбран файл не подходящего содержимого</p>";?><a href="javascript:history.go(-1)" mce_href="javascript:history.go(-1)" class="blue1">Вернуться назад</a><?}
	}
	else echo ("Размер файла превышает три мегабайта");
}
else {echo "<p width='400' height='70' class='blue1'><div align='center' class='mmsel'>ОШИБКА.<br>Не выбран файл</p>";?><a href="javascript:history.go(-1)" mce_href="javascript:history.go(-1)" class="blue1">Вернуться назад</a><?}
?>
开发者ID:Romerohub,项目名称:Kohana-admin,代码行数:31,代码来源:save_img.tpl.php

示例10: users


//.........这里部分代码省略.........
        $avatars_dir_rel = "/images/users/avatars/library";
        $avatars_dir_handle = opendir($avatars_dir);
        $avatars = array();
        while ($nextfile = readdir($avatars_dir_handle)) {
            if ($nextfile != '.' && $nextfile != '..' && (mb_strstr($nextfile, '.gif') || mb_strstr($nextfile, '.jpg') || mb_strstr($nextfile, '.jpeg') || mb_strstr($nextfile, '.png'))) {
                $avatars[] = $nextfile;
            }
        }
        closedir($avatars_dir_handle);
        if (!cmsCore::inRequest('set_avatar')) {
            $inPage->setTitle($_LANG['SELECT_AVATAR']);
            $inPage->addPathway($inUser->nickname, cmsUser::getProfileURL($inUser->login));
            $inPage->addPathway($_LANG['SELECT_AVATAR']);
            $perpage = 20;
            $total = sizeof($avatars);
            $avatars = array_slice($avatars, ($page - 1) * $perpage, $perpage);
            cmsPage::initTemplate('components', 'com_users_avatars')->assign('userid', $id)->assign('avatars', $avatars)->assign('avatars_dir', $avatars_dir_rel)->assign('page', $page)->assign('perpage', $perpage)->assign('pagebar', cmsPage::getPagebar($total, $page, $perpage, '/users/%user_id%/select-avatar-%page%.html', array('user_id' => $id)))->display('com_users_avatars.tpl');
        } else {
            $avatar_id = cmsCore::request('avatar_id', 'int', 0);
            $file = $avatars[$avatar_id];
            if (file_exists($avatars_dir . '/' . $file)) {
                $uploaddir = PATH . '/images/users/avatars/';
                $realfile = $file;
                $filename = md5($realfile . '-' . $id . '-' . time()) . '.jpg';
                $uploadfile = $avatars_dir . '/' . $realfile;
                $uploadavatar = $uploaddir . $filename;
                $uploadthumb = $uploaddir . 'small/' . $filename;
                if ($inUser->orig_imageurl && $inUser->orig_imageurl != 'nopic.jpg') {
                    @unlink(PATH . '/images/users/avatars/' . $inUser->orig_imageurl);
                    @unlink(PATH . '/images/users/avatars/small/' . $inUser->orig_imageurl);
                }
                cmsCore::includeGraphics();
                copy($uploadfile, $uploadavatar);
                @img_resize($uploadfile, $uploadthumb, $model->config['smallw'], $model->config['smallw']);
                $sql = "UPDATE cms_user_profiles SET imageurl = '{$filename}' WHERE user_id = '{$id}' LIMIT 1";
                $inDB->query($sql);
                // очищаем предыдущую запись о смене аватара
                cmsActions::removeObjectLog('add_avatar', $id);
                // выводим сообщение в ленту
                cmsActions::log('add_avatar', array('object' => '', 'object_url' => '', 'object_id' => $id, 'target' => '', 'target_url' => '', 'description' => '<a href="' . cmsUser::getProfileURL($inUser->login) . '" class="act_usr_ava">
										<img border="0" src="/images/users/avatars/small/' . $filename . '">
									</a>'));
            }
            cmsCore::redirect(cmsUser::getProfileURL($inUser->login));
        }
    }
    //============================================================================//
    //======================== Работа с фотографиями  ============================//
    //============================================================================//
    if ($do == 'photos') {
        if (!$model->config['sw_photo']) {
            cmsCore::error404();
        }
        $pdo = cmsCore::request('pdo', 'str', '');
        include 'components/users/photos.php';
    }
    //============================================================================//
    //============================= Друзья пользователя  =========================//
    //============================================================================//
    if ($do == 'friendlist') {
        if (!$inUser->id) {
            cmsUser::goToLogin();
        }
        $usr = cmsUser::getShortUserData($id);
        if (!$usr) {
            cmsCore::error404();
开发者ID:deltas1,项目名称:icms1,代码行数:67,代码来源:frontend.php

示例11: createUser

 private function createUser($profile)
 {
     $inCore = cmsCore::getInstance();
     $inDB = cmsDatabase::getInstance();
     $inUser = cmsUser::getInstance();
     cmsCore::loadClass('actions');
     $nickname = $email = $birthdate = '';
     $advanced = array();
     // для вконтакте поолучаем большой аватар, статус и город
     if (strstr($profile->identity, '//vk.com')) {
         $vk = $this->callVk($profile->uid);
         if ($vk) {
             $advanced = array('city' => $vk->city->title, 'status' => $vk->status, 'photo' => $vk->photo_max_orig);
         }
     }
     if (!empty($profile->name->full_name)) {
         // указано полное имя
         $nickname = $profile->name->full_name;
     } elseif (!empty($profile->name->first_name)) {
         // указано имя и фамилия по-отдельности
         $nickname = $profile->name->first_name;
         if (!empty($profile->name->last_name)) {
             $nickname .= ' ' . $profile->name->last_name;
         }
     } elseif (preg_match('/^(http:\\/\\/)([a-zA-Z0-9\\-_]+)\\.([a-zA-Z0-9\\-_]+)\\.([a-zA-Z]{2,6})([\\/]?)$/i', $profile->identity)) {
         // не указано имя, но передан идентификатор в виде домена
         $nickname = parse_url($profile->identity, PHP_URL_HOST);
     }
     $nickname = cmsCore::strClear($nickname);
     $login = substr(str_replace('-', '', cmsCore::strToURL($nickname)), 0, 15);
     if (!$nickname || !$login) {
         // не указано вообще ничего
         $max = $inDB->get_fields('cms_users', 'id>0', 'id', 'id DESC');
         $nickname = $login = 'user' . ($max['id'] + 1);
     }
     // генерируем пароль
     $pass = md5(substr(md5(microtime() . uniqid()), 0, 8));
     if (!empty($profile->email)) {
         $email = cmsCore::strClear($profile->email);
         $already_email = $inDB->get_field('cms_users', "email='{$email}' AND is_deleted=0", 'email');
         if ($already_email == $email) {
             cmsCore::redirect('/auth/error.html');
         }
     }
     if (!empty($profile->dob)) {
         $birthdate = cmsCore::strClear($profile->dob);
     }
     // проверяем занятость логина
     if ($inDB->get_field('cms_users', "login='{$login}' AND is_deleted=0", 'login') == $login) {
         // если логин занят, добавляем к нему ID
         $max = $inDB->get_fields('cms_users', 'id>0', 'id', 'id DESC');
         $login .= $max['id'] + 1;
     }
     $user_array = cmsCore::callEvent('USER_BEFORE_REGISTER', array('status' => !empty($advanced['status']) ? $advanced['status'] : '', 'status_date' => date('Y-m-d H:i:s'), 'login' => $login, 'nickname' => $nickname, 'password' => $pass, 'email' => $email, 'birthdate' => $birthdate, 'group_id' => $this->reg_model->config['default_gid'], 'regdate' => date('Y-m-d H:i:s'), 'logdate' => date('Y-m-d H:i:s'), 'invited_by' => 0, 'openid' => md5($profile->identity)));
     $user_array['id'] = $user_id = $inDB->insert('cms_users', $user_array);
     // создаем профиль пользователя
     if ($user_id) {
         $filename = 'nopic.jpg';
         // если есть аватар, пробуем скачать
         if (!empty($profile->photo) || !empty($advanced['photo'])) {
             $photo_path = $this->downloadAvatar(!empty($advanced['photo']) ? $advanced['photo'] : $profile->photo);
             if ($photo_path) {
                 cmsCore::includeGraphics();
                 $uploaddir = PATH . '/images/users/avatars/';
                 $filename = md5($photo_path . '-' . $user_id . '-' . time()) . '.jpg';
                 $uploadavatar = $uploaddir . $filename;
                 $uploadthumb = $uploaddir . 'small/' . $filename;
                 $cfg = $inCore->loadComponentConfig('users');
                 @img_resize($photo_path, $uploadavatar, $cfg['medw'], $cfg['medh']);
                 @img_resize($photo_path, $uploadthumb, $cfg['smallw'], $cfg['smallw']);
                 @unlink($photo_path);
             }
         }
         $inUser->loadUserGeo();
         $inDB->insert('cms_user_profiles', array('city' => !empty($advanced['city']) ? $advanced['city'] : $inUser->city, 'user_id' => $user_id, 'imageurl' => $filename, 'gender' => !empty($profile->gender) ? strtolower($profile->gender) : 'm'));
         cmsCore::callEvent('USER_REGISTER', $user_array);
         cmsActions::log('add_user', array('object' => '', 'user_id' => $user_id, 'object_url' => '', 'object_id' => $user_id, 'target' => '', 'target_url' => '', 'target_id' => 0, 'description' => ''));
         if ($this->reg_model->config['send_greetmsg']) {
             $this->reg_model->sendGreetsMessage($user_id);
         }
         return $user_id;
     }
     return false;
 }
开发者ID:4uva4ek,项目名称:svato,代码行数:84,代码来源:plugin.php

示例12: upload_file

function upload_file($file_name, $name_file_destination)
{
    echo $name_file_destination;
    global $max_image_width;
    global $max_image_height;
    global $max_image_size;
    global $valid_types;
    global $_upload_dir;
    global $upload_dir;
    global $max_width;
    global $max_width_big_photo;
    //echo "<br>---".$max_width_big_photo;
    $err_str = '';
    if (isset($_FILES[$file_name])) {
        if (is_uploaded_file($_FILES[$file_name]['tmp_name'])) {
            $filename = $_FILES[$file_name]['tmp_name'];
            $ext = substr($_FILES[$file_name]['name'], 1 + strrpos($_FILES[$file_name]['name'], "."));
            if (filesize($filename) > $max_image_size * 1024) {
                return $err_str = 'Error: File size > ' . $max_image_size . 'K.';
            } elseif (!in_array($ext, $valid_types)) {
                return $err_str = 'Error: Invalid file type.';
            } else {
                $size = GetImageSize($filename);
                if ($size && $size[0] < $max_image_width && $size[1] < $max_image_height) {
                    //                            if (move_uploaded_file($filename, $_upload_dir .$_FILES[$file_name]['name']))
                    //							$box=imagettftext($filename, $max_image_size, 45, 30, 90, $colorblack, $font, "TEST") ;
                    if (move_uploaded_file($filename, $upload_dir . $name_file_destination)) {
                        //return $err_str = 'File successful uploaded.';
                        //$err_str = img_resize($_FILES[$file_name]['name']);
                        if ($size[0] > $max_width) {
                            $_size = $max_width;
                        } else {
                            $_size = $size[0];
                        }
                        $err_str = img_resize($name_file_destination, $_size);
                        if ($size[0] > $max_width_big_photo) {
                            //echo "<br>--";
                            $err_str = img_resize_big($name_file_destination, $max_width_big_photo);
                        }
                        return $err_str;
                    } else {
                        return $err_str = 'Error: moving fie failed.';
                    }
                } else {
                    return $err_str = 'Error: invalid image properties.';
                }
            }
        } else {
            //return $err_str = 'Error: empty file.';
            return $err_str = '';
        }
    }
    return $err_str;
}
开发者ID:AngelWayfarer,项目名称:prizvanie,代码行数:54,代码来源:image.class.php

示例13: md5

 //upload logo
 if ($_FILES['picture']['name']) {
     require PATH . '/includes/graphic.inc.php';
     $uploaddir = PATH . '/images/clubs/';
     if (!is_dir($uploaddir)) {
         @mkdir($uploaddir);
     }
     $filename = md5($id) . '.jpg';
     $uploadphoto = $uploaddir . $filename;
     $uploadthumb = $uploaddir . 'small/' . $filename;
     if ($inCore->moveUploadedFile($_FILES['picture']['tmp_name'], $uploadphoto, $_FILES['picture']['error'])) {
         if (!isset($cfg['watermark'])) {
             $cfg['watermark'] = 0;
         }
         @img_resize($uploadphoto, $uploadthumb, $cfg['thumb1'], $cfg['thumb1'], $cfg['thumbsqr']);
         @img_resize($uploadphoto, $uploadphoto, $cfg['thumb2'], $cfg['thumb2'], $cfg['thumbsqr']);
     } else {
         $msg = $inCore->uploadError();
     }
     $sql = "UPDATE cms_clubs SET imageurl = '{$filename}' WHERE id={$id}";
     dbQuery($sql);
 }
 //insert into db
 $sql = "UPDATE cms_clubs\r\n                    SET admin_id = '{$admin_id}',\r\n                        title = '{$title}',\r\n                        description = '{$description}',\r\n                        clubtype = '{$clubtype}',\r\n                        published = '{$published}',\r\n                        maxsize = '{$maxsize}',\r\n                        enabled_blogs = '{$enabled_blogs}',\r\n                        enabled_photos = '{$enabled_photos}'\r\n                    WHERE id = {$id}";
 dbQuery($sql);
 $moders = $_POST['moderslist'];
 $members = $_POST['memberslist'];
 if (array_search($admin_id, $moders)) {
     unset($moders[array_search($admin_id, $moders)]);
 }
 if (array_search($admin_id, $members)) {
开发者ID:ratmir-by,项目名称:icms-calendar,代码行数:31,代码来源:backend.php

示例14: pathinfo

            }
            $file = $_FILES["imgfile"]["name"];
            $path_parts = pathinfo($file);
            $ext = $path_parts['extension'];
            if (strstr($ext, 'php')) {
                die;
            }
            $file = md5($file . time()) . '.' . $ext;
            $item['imageurl'] = $file;
            if (@move_uploaded_file($tmp_name, PATH . "/images/catalog/{$file}")) {
                //create image thumbnails
                if ($cfg['watermark']) {
                    @img_add_watermark(PATH . "/images/catalog/{$file}");
                }
                @img_resize(PATH . "/images/catalog/{$file}", PATH . "/images/catalog/small/{$file}.jpg", 100, 100);
                @img_resize(PATH . "/images/catalog/{$file}", PATH . "/images/catalog/medium/{$file}.jpg", 250, 250);
                @chmod(PATH . "/images/catalog/{$file}", 0644);
                @chmod(PATH . "/images/catalog/small/{$file}.jpg", 0644);
                @chmod(PATH . "/images/catalog/medium/{$file}.jpg", 0644);
            } else {
                $msg = 'Ошибка загрузки изображения!';
            }
        }
        $model->updateItem($id, $item);
    }
    if (!isset($_SESSION['editlist']) || @sizeof($_SESSION['editlist']) == 0) {
        $inCore->redirect('?view=components&do=config&id=' . $_REQUEST['id'] . '&opt=list_items');
    } else {
        $inCore->redirect('?view=components&do=config&id=' . $_REQUEST['id'] . '&opt=edit_item');
    }
}
开发者ID:ratmir-by,项目名称:icms-calendar,代码行数:31,代码来源:backend.php

示例15: preg_replace

     if (isset($delpic) && $delpic->getChecked()) {
         $filename = "";
         if (file_exists($_SESSION['site_class_catpicdir'] . '/' . $oldpic)) {
             @unlink($_SESSION['site_class_catpicdir'] . '/' . $oldpic);
             @unlink($_SESSION['site_class_catpicdir'] . '/tn_' . $oldpic);
         }
     }
     //kep feltoltese
     if ($file->isUploadedFile()) {
         $filevalues = $file->getValue();
         $sdir = preg_replace('|/$|', '', $_SESSION['site_class_catpicdir']) . '/';
         $filename = time() . preg_replace('|[^\\d\\w_\\.]|', '_', change_hunchar($filevalues['name']));
         $tn_name = 'tn_' . $filename;
         //kep atmeretezese
         include_once 'includes/function.images.php';
         if (($pic = img_resize($filevalues['tmp_name'], $sdir . $filename, $_SESSION['site_class_catpicwidth'], $_SESSION['site_class_catpicheight'])) && ($tn = img_resize($filevalues['tmp_name'], $sdir . $tn_name, $_SESSION['site_class_catpictwidth'], $_SESSION['site_class_catpictheight']))) {
             @chmod($sdir . $filename, 0664);
             @chmod($sdir . $tn_name, 0664);
             @unlink($filevalues['tmp_name']);
             //ha volt regi kep, akkor toroljuk
             if ($oldpic != "") {
                 if (file_exists($_SESSION['site_class_catpicdir'] . '/' . $oldpic)) {
                     @unlink($_SESSION['site_class_catpicdir'] . '/' . $oldpic);
                     @unlink($_SESSION['site_class_catpicdir'] . '/tn_' . $oldpic);
                 }
             }
             //regi kep torlesenek vege
         }
         $form_class->setElementError('picture', $locale->get('category_error_category_picupload'));
     }
 }
开发者ID:span20,项目名称:Kallay,代码行数:31,代码来源:classifieds_categories.php


注:本文中的img_resize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。