本文整理汇总了PHP中CFile::resizeImage方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::resizeImage方法的具体用法?PHP CFile::resizeImage怎么用?PHP CFile::resizeImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::resizeImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: users
break;
case 'real_name_splash':
// сохранение имени, фамилии и юзерпика с соответствующего сплэш-скрина
require_once ABS_PATH . "/classes/users.php";
require_once ABS_PATH . "/classes/attachedfiles.php";
require_once ABS_PATH . "/classes/CFile.php";
$userObj = new users();
$userID = get_uid();
$aFiles = new attachedfiles($_POST['attachedfiles_session']);
$userpics = $aFiles->getFiles(array(1));
if (is_array($userpics) && !empty($userpics)) {
$userpic = array_pop($userpics);
$aFiles->setStatusTo3($userpic['id']);
$foto = new CFile($userpic['id']);
$to = $foto->path . 'sm_' . $foto->name;
$foto->resizeImage($to, 50, 50, 'auto', true);
$userObj->photo = $userpic['name'];
}
$name = change_q(substr(trim($_POST['name']), 0, 21), true);
$surname = change_q(substr(trim($_POST['surname']), 0, 21), true);
if ($name && !preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $name)) {
$error_flag = 1;
$alert[1] = "Поле заполнено некорректно";
}
if ($surname && !preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $surname)) {
$error_flag = 1;
$alert[2] = "Поле заполнено некорректно";
}
if (!$error_flag) {
if ($name) {
$userObj->uname = $name;
示例2: addAttachedFiles
/**
* Связывает файлы загруженные ассинхронно с сообщением
*
* @param array $files Список загруженных файлов
* @param string $login Логин пользователя
* @param integer $msg_id ID сообщения
* @param boolean $from_draft Файлы из черновика
*/
function addAttachedFiles($files, $msg_id, $login = NULL, $from_draft = false)
{
global $DB;
if (!$login) {
$login = $_SESSION['login'];
}
$bModeration = false;
$old_files = $this->getAttachedFiles($msg_id);
if ($from_draft) {
$notdeleted_files = array();
if ($files) {
foreach ($files as $f) {
if ($f['status'] == 3 || in_array($f['id'], $old_files)) {
array_push($notdeleted_files, $f['id']);
}
}
}
$attaches = CFile::selectFilesBySrc(self::FILE_TABLE, $msg_id);
if ($attaches) {
foreach ($attaches as $attach) {
if (in_array($attach['id'], $notdeleted_files)) {
continue;
}
$cFile = new CFile($attach['id']);
$cFile->table = self::FILE_TABLE;
if ($cFile->id) {
$cFile->Delete($cFile->id);
}
}
}
}
$max_image_size = array('width' => blogs::MAX_IMAGE_WIDTH, 'height' => blogs::MAX_IMAGE_HEIGHT, 'less' => 0);
if ($files) {
foreach ($files as $file) {
switch ($file['status']) {
case 4:
// Удаляем файл
$cFile = new CFile($file['id']);
$cFile->table = self::FILE_TABLE;
if ($cFile->id) {
$cFile->Delete($cFile->id);
}
break;
case 1:
if (in_array($file['id'], $old_files)) {
$need_copy = false;
} else {
$bModeration = true;
$need_copy = true;
}
// Добавляем файл
$cFile = new CFile($file['id']);
$cFile->proportional = 1;
$cFile->table = self::FILE_TABLE;
$ext = $cFile->getext();
if ($need_copy) {
$tmp_dir = "users/" . substr($login, 0, 2) . "/" . $login . "/upload/";
$tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext);
$tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir));
$cFile->_remoteCopy($tmp_dir . $tmp_name, true);
}
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = TRUE;
} else {
$is_image = FALSE;
}
if ($is_image && $ext != 'swf' && $ext != 'flv') {
if ($cFile->image_size['width'] > $max_image_size['width'] || $cFile->image_size['height'] > $max_image_size['height']) {
if ($need_copy) {
if ($cFile->resizeImage($cFile->path . 'sm_' . $cFile->name, $max_image_size['width'], $cFile->image_size['height'], 'landscape')) {
$cFile->small = 2;
}
} else {
$cFile->small = 2;
}
} else {
$cFile->small = 1;
}
} else {
$cFile->small = $ext == 'flv' ? 2 : 0;
}
$cFile->updateFileParams(array('src_id' => $msg_id, 'small' => $cFile->small), false);
break;
}
}
}
if ($bModeration && $login == $_SESSION['login'] && !hasPermissions('blogs')) {
// отравляем сообщение на модерирование сразу по факту создания или редактирования
// появились новые файлы и это правит автор, и он не админ и не ПРО - отправить на модерирование
/*require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php' );
$DB->query( 'UPDATE blogs_msgs SET moderator_status = 0 WHERE id = ?i', $msg_id );
$DB->insert( 'moderation', array('rec_id' => $msg_id, 'rec_type' => user_content::MODER_BLOGS) );*/
//.........这里部分代码省略.........
示例3: addAttachedFiles
/**
* Связывает файлы загруженные ассинхронно с сообщением
*
* @param array $files Список загруженных файлов
* @param string $login Логин пользователя
* @param integer $msg_id ID сообщения
* @param boolean $from_draft Файлы из черновика
*/
function addAttachedFiles($files, $msg_id, $login, $from_draft = false)
{
global $DB;
if (!$login) {
$login = $_SESSION['login'];
}
$bModeration = false;
$where = " inline != TRUE";
$attaches = CFile::selectFilesBySrc(self::FILE_TABLE, $msg_id, NULL, $where);
//$DB->rows($sql, $msg_id);
$old_files = array();
if ($attaches) {
foreach ($attaches as $f) {
array_push($old_files, $f['fid']);
}
}
if ($from_draft) {
$notdeleted_files = array();
if ($files) {
foreach ($files as $f) {
if ($f['status'] == 3) {
array_push($notdeleted_files, $f['id']);
}
}
}
if ($attaches) {
$cfile = new CFile();
foreach ($attaches as $attach) {
if (in_array($attach['id'], $notdeleted_files)) {
continue;
}
$cfile->Delete(0, "users/" . substr($login, 0, 2) . "/" . $login . "/upload/", $attach['fname']);
//if ($attach['small'] == 't') {
// $cfile->Delete(0, "users/" . substr($login, 0, 2) . "/" . $login . "/upload/", "sm_" . $attach['fname']);
//}
}
}
}
$max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0);
if ($files) {
$cfile = new CFile();
$num = 0;
foreach ($files as $file) {
switch ($file['status']) {
case 3:
$num++;
break;
case 4:
// Удаляем файл
$cFile = new CFile($file['id']);
$cFile->table = self::FILE_TABLE;
if ($cFile->id) {
$cFile->updateFileParams(array('src_id' => null), false);
// Удаляем связь
$cFile->Delete($cFile->id);
}
break;
case 1:
$num++;
if (in_array($file['id'], $old_files)) {
$need_copy = false;
} else {
$bModeration = true;
$need_copy = true;
}
// Добавляем файл
$cFile = new CFile($file['id']);
$cFile->proportional = 1;
$cFile->table = self::FILE_TABLE;
$ext = $cFile->getext();
if ($need_copy) {
$tmp_dir = "users/" . substr($login, 0, 2) . "/" . $login . "/upload/";
$tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext);
$tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir));
$cFile->_remoteCopy($tmp_dir . $tmp_name, true);
}
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = TRUE;
} else {
$is_image = FALSE;
}
if ($is_image && $ext != 'swf' && $ext != 'flv') {
if ($cFile->image_size['width'] > $max_image_size['width'] || $cFile->image_size['height'] > $max_image_size['height']) {
if ($need_copy) {
if ($cFile->resizeImage($cFile->path . 'sm_' . $cFile->name, $max_image_size['width'], $cFile->image_size['height'], 'landscape')) {
$cFile->small = true;
}
} else {
$cFile->small = true;
}
} else {
$cFile->small = false;
//.........这里部分代码省略.........
示例4: DelPict
/**
* Удаляет картинку или превьюху работы.
*
* @param string $login Логин пользователя
* @param integer $prj_id ИД превью
* @param integer $pict_type Тип картинки (1-картинка, 0-портфолио)
*
* @return integer 1 - если все ок, иначе 0
*/
public function DelPict($login, $prj_id, $pict_type = 1)
{
global $DB;
if ($pict_type == 1) {
$pict = $this->GetField($prj_id, 'pict');
} else {
$pict = $this->GetField($prj_id, 'prev_pict');
}
if ($pict) {
$sql = 'UPDATE portfolio SET ' . ($pict_type == 1 ? 'pict' : 'prev_pict') . ' = NULL WHERE id = ?i';
if ($DB->query($sql, $prj_id)) {
$dir = substr($login, 0, 2) . '/' . $login;
$cfile = new CFile();
$cfile->Delete(0, "users/{$dir}/upload/", $pict);
if ($pict_type != 1) {
$sm_pict = new CFile();
$pict = $this->GetField($prj_id, 'pict');
$sm_pict->GetInfo("users/{$dir}/upload/" . $pict);
if ($sm_pict->size > 0) {
$ext = $sm_pict->getext();
if (in_array($ext, $GLOBALS['graf_array']) && $ext != 'swf') {
$sm_pict->table = 'file_template';
$sm_pict->quality = 100;
$sm_pict->resizeImage("users/{$dir}/upload/" . 'tn_' . $sm_pict->name, 200, 200, 'auto', true);
}
}
}
return 1;
}
}
return 0;
}
示例5: addAttachedFiles
/**
* Связывает файлы загруженные ассинхронно с комментарием
*
* @param array $files Список загруженных файлов @see attachedfiles::getFiles
* @param string $login Логин пользователя
* @param integer $msg_id ID комментария
* @return bool
*/
function addAttachedFiles($files = array(), $msg_id = 0, $login = '')
{
global $DB;
$model = $this->model();
if (!isset($model['attaches'])) {
return false;
}
if (!$login) {
$login = $_SESSION['login'];
}
$sql = 'SELECT ' . $model['attaches']['fields']['file'] . ' AS fid FROM ' . $model['attaches']['table'] . ' WHERE ' . $model['attaches']['fields']['comment'] . ' = ?i AND ' . $model['attaches']['fields']['inline'] . ' != TRUE';
$attaches = $DB->rows($sql, $msg_id);
$old_files = array();
if ($attaches) {
foreach ($attaches as $f) {
array_push($old_files, $f['fid']);
}
}
$max_image_size = array('width' => 390, 'height' => 1000, 'less' => 0);
if ($files) {
$num = 0;
foreach ($files as $file) {
switch ($file['status']) {
case 4:
// Удаляем файл
$cFile = new CFile($file['id']);
$cFile->table = $model['attaches']['file_table'];
if ($cFile->id) {
$sql = 'DELETE FROM ' . $model['attaches']['table'] . ' WHERE ' . $model['attaches']['fields']['file'] . ' = ?i';
$DB->query($sql, $cFile->id);
$cFile->Delete($cFile->id);
}
break;
case 1:
$num++;
if (in_array($file['id'], $old_files)) {
$need_copy = false;
} else {
$need_copy = true;
}
// Добавляем файл
$cFile = new CFile($file['id']);
$cFile->proportional = 1;
$cFile->table = $model['attaches']['file_table'];
$ext = $cFile->getext();
if ($need_copy) {
$tmp_dir = 'users/' . substr($login, 0, 2) . '/' . $login . '/upload/';
$tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext);
$tmp_name = substr_replace($tmp_name, '', 0, strlen($tmp_dir));
$cFile->_remoteCopy($tmp_dir . $tmp_name, true);
}
if (in_array($ext, $GLOBALS['graf_array'])) {
$is_image = TRUE;
} else {
$is_image = FALSE;
}
if ($is_image && $ext != 'swf' && $ext != 'flv') {
if ($cFile->image_size['width'] > $max_image_size['width'] || $cFile->image_size['height'] > $max_image_size['height']) {
if ($need_copy) {
if ($cFile->resizeImage($cFile->path . 'sm_' . $cFile->name, $max_image_size['width'], $cFile->image_size['height'], 'landscape')) {
$cFile->small = true;
}
} else {
$cFile->small = true;
}
} else {
$cFile->small = false;
}
} else {
$cFile->small = false;
}
$aData = array($model['attaches']['fields']['comment'] => $msg_id, $model['attaches']['fields']['file'] => $cFile->id);
if (isset($model['attaches']['fields']['small'])) {
$aData[$model['attaches']['fields']['small']] = $cFile->small;
}
if (isset($model['attaches']['fields']['sort'])) {
$aData[$model['attaches']['fields']['sort']] = $num;
}
$DB->insert($model['attaches']['table'], $aData);
break;
}
}
}
return true;
}