本文整理汇总了PHP中cmsCore::includeGraphics方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::includeGraphics方法的具体用法?PHP cmsCore::includeGraphics怎么用?PHP cmsCore::includeGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::includeGraphics方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: users
//.........这里部分代码省略.........
}
$avatars_dir = PATH . "/images/users/avatars/library";
$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);
示例2: session_destroy
if ($sess_id != session_id()) {
session_destroy();
}
session_id($sess_id);
session_start();
}
$user_id = $_SESSION['user']['id'];
if (!$user_id) {
header("HTTP/1.1 500 Internal Server Error");
exit(0);
}
if ($model->config['photosize'] > 0 && $model->getUserPhotoCount($user_id) >= $model->config['photosize'] && !$inUser->is_admin) {
header("HTTP/1.1 500 Internal Server Error");
exit(0);
}
cmsCore::includeGraphics();
$uploaddir = PATH . '/images/users/photos/';
$realfile = $inDB->escape_string($_FILES['Filedata']['name']);
$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'];
示例3: uploadPhoto
/**
* Загружает фото файл
* @return array $file (filename, realfile)
*/
public function uploadPhoto($old_file = '')
{
// если каталог загрузки не определен, возвращаем ложь
if (!$this->upload_dir) {
return false;
}
if (!empty($_FILES[$this->input_name]['name'])) {
cmsCore::includeGraphics();
$input_name = preg_replace('/[^a-zA-Zа-яёЁА-Я0-9\\.\\-_ ]/ui', '', mb_substr(basename(strval($_FILES[$this->input_name]['name'])), 0, 160));
// расширение
$ext = mb_strtolower(pathinfo($input_name, PATHINFO_EXTENSION));
// имя файла без расширения
$realfile = str_replace('.' . $ext, '', $input_name);
if (!in_array($ext, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) {
return false;
}
$this->filename = $this->filename ? $this->filename : md5(time() . $realfile) . '.' . $ext;
$uploadphoto = $this->upload_dir . $this->filename;
$uploadthumb['small'] = $this->upload_dir . $this->dir_small . $this->filename;
$uploadthumb['medium'] = $this->upload_dir . $this->dir_medium . $this->filename;
$uploadphoto = $this->upload_dir . $this->filename;
$source = $_FILES[$this->input_name]['tmp_name'];
$errorCode = $_FILES[$this->input_name]['error'];
if (cmsCore::moveUploadedFile($source, $uploadphoto, $errorCode)) {
// удаляем предыдущий файл если необходимо
$this->deletePhotoFile($old_file);
if (!$this->isImage($uploadphoto)) {
$this->deletePhotoFile($this->filename);
return false;
}
if (!$this->small_size_h) {
$this->small_size_h = $this->small_size_w;
}
if (!$this->medium_size_h) {
$this->medium_size_h = $this->medium_size_w;
}
// Гененрируем маленькое и среднее изображения
if (!$this->only_medium) {
if (!is_dir($this->upload_dir . $this->dir_small)) {
@mkdir($this->upload_dir . $this->dir_small);
}
@img_resize($uploadphoto, $uploadthumb['small'], $this->small_size_w, $this->small_size_h, $this->thumbsqr);
}
if (!is_dir($this->upload_dir . $this->dir_medium)) {
@mkdir($this->upload_dir . $this->dir_medium);
}
@img_resize($uploadphoto, $uploadthumb['medium'], $this->medium_size_w, $this->medium_size_h, false, false);
// Накладывать ватермарк
if ($this->is_watermark) {
@img_add_watermark($uploadthumb['medium']);
}
if ($this->is_watermark) {
@img_add_watermark($uploadthumb['small']);
}
// сохранять оригинал
if (!$this->is_saveorig) {
@unlink($uploadphoto);
} elseif ($this->is_watermark) {
@img_add_watermark($uploadphoto);
}
$file['filename'] = $this->filename;
$file['realfile'] = $realfile;
} else {
return false;
}
} else {
return false;
}
return $file;
}
示例4: 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;
}