本文整理汇总了PHP中Upload::get_cache_relative_dir方法的典型用法代码示例。如果您正苦于以下问题:PHP Upload::get_cache_relative_dir方法的具体用法?PHP Upload::get_cache_relative_dir怎么用?PHP Upload::get_cache_relative_dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Upload
的用法示例。
在下文中一共展示了Upload::get_cache_relative_dir方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_summary
function print_summary($link = 0, $length = 0, $single_link = true)
{
global $current_user, $globals;
if (!$this->read) {
return;
}
if (!$link && $this->link > 0) {
$link = new Link();
$link->id = $this->link;
$link->read();
$this->link_object = $link;
}
$this->link_permalink = $link->get_relative_permalink();
$this->check_visibility();
if ($this->hidden) {
$comment_meta_class = 'comment-meta-hidden';
$comment_class = 'comment-body-hidden';
} else {
$comment_meta_class = 'comment-meta';
$comment_class = 'comment-body';
if ($this->karma > $globals['comment_highlight_karma']) {
$comment_class .= ' high';
}
}
$this->truncate($length);
$this->txt_content = $this->to_html($this->content);
if ($this->type == 'admin') {
$author = '<strong>' . _('admin') . '</strong> ';
} else {
$author = '<a href="' . get_user_uri($this->username) . '" title="karma: ' . $this->user_karma . '">' . $this->username . '</a> ';
}
if ($this->media_size > 0) {
$this->media_thumb_dir = Upload::get_cache_relative_dir($this->id);
}
$vars = compact('comment_meta_class', 'comment_class', 'author');
$vars['self'] = $this;
return Haanga::Load('mobile/comment_summary.html', $vars);
}
示例2: url
function url()
{
global $globals;
return $globals['base_url'] . Upload::get_cache_relative_dir($this->id) . '/' . $this->filename();
}
示例3: get_post
function get_post($time, $type, $postid, $userid)
{
global $db, $current_user, $events, $last_timestamp, $foo_link, $max_items;
$event = $db->get_row("select user_login, post_user_id, post_content, media.size as media_size from posts LEFT JOIN media ON (media.type='post' and media.id = posts.post_id and media.version = 0), users where post_id = {$postid} and user_id={$userid}");
if (!$event) {
return;
}
$json['link'] = post_get_base_url($postid);
$json['ts'] = $time;
$json['type'] = $type;
$json['who'] = $event->user_login;
$json['status'] = _('nótame');
$json['title'] = put_smileys(text_to_summary(preg_replace('/(@[\\S.-]+)(,\\d+)/', '$1', $event->post_content), 130));
if (mb_strlen(trim($json['title'])) == 0) {
$json['title'] = '...';
}
$json['votes'] = 0;
$json['com'] = 0;
$json['uid'] = $userid;
$json['id'] = $postid;
if ($userid > 0) {
$json['icon'] = get_avatar_url($userid, -1, 20);
}
if ($event->media_size > 0) {
$json['thumb'] = $globals['base_static'] . Upload::get_cache_relative_dir($postid) . "/media_thumb-post-{$postid}.jpg";
}
$key = $time . ':' . $type . ':' . $postid;
$events[$key] = $json;
if ($time > $last_timestamp) {
$last_timestamp = $time;
}
}
示例4: prepare_summary_text
function prepare_summary_text($length = 0)
{
global $current_user, $globals;
if (empty($this->basic_summary) && ($this->author == $current_user->user_id && time() - $this->date < $globals['posts_edit_time'] || $current_user->user_level == 'god' && time() - $this->date < $globals['posts_edit_time_admin'])) {
// Admins can edit up to 10 days
$this->can_edit = true;
} else {
$this->can_edit = false;
}
if ($length > 0) {
$this->content = text_to_summary($this->content, $length);
}
$this->content = $this->to_html($this->content) . $expand;
if ($this->media_size > 0) {
$this->media_thumb_dir = Upload::get_cache_relative_dir($this->id);
$this->media_url = Upload::get_url('post', $this->id, 0, $this->media_date, $this->media_mime);
}
}
示例5: do_header
function do_header($title, $id = 'home', $options = false)
{
global $current_user, $dblang, $globals, $db;
header('Content-Type: text/html; charset=utf-8');
// Security headers
header('X-Frame-Options: SAMEORIGIN');
header('X-UA-Compatible: IE=edge,chrome=1');
if ($globals['force_ssl'] && $globals['https']) {
header('Strict-Transport-Security: max-age=15638400');
// 181 days, ssllabs doesn't like less than 180
}
http_cache();
$globals['security_key'] = get_security_key();
setcookie('k', $globals['security_key'], 0, $globals['base_url_general']);
if (!empty($_REQUEST['q'])) {
$globals['q'] = $_REQUEST['q'];
}
if ($current_user->user_id > 0) {
$globals['extra_js'][] = 'jquery.form.min.js';
}
$sites = $db->get_results("select * from subs where visible order by id asc");
$this_site = SitesMgr::get_info();
$this_site_properties = SitesMgr::get_extended_properties();
if ($this_site->sub) {
$this_site->url = $this_site->base_url . 'm/' . $this_site->name;
} else {
$this_site->url = $this_site->base_url;
}
// Check if the sub has a logo and calculate the width
if ($this_site->media_id > 0 && $this_site->media_dim1 > 0 && $this_site->media_dim2 > 0) {
$r = $this_site->media_dim1 / $this_site->media_dim2;
if ($globals['mobile']) {
$this_site->logo_height = $globals['media_sublogo_height_mobile'];
} else {
$this_site->logo_height = $globals['media_sublogo_height'];
}
$this_site->logo_width = round($r * $this_site->logo_height);
$this_site->logo_url = Upload::get_cache_relative_dir($this_site->id) . '/media_thumb-sub_logo-' . $this_site->id . '.' . $this_site->media_extension . '?' . $this_site->media_date;
}
if ($this_site->nsfw) {
$globals['ads'] = false;
}
if (!empty($this_site_properties['post_html'])) {
$globals['post_html'] = $this_site_properties['post_html'];
}
if (!is_array($options)) {
$left_options = array();
if ($this_site->enabled && empty($this_site_properties['new_disabled'])) {
$left_options[] = new MenuOption(_('enviar historia'), $globals['base_url'] . 'submit', $id, _('enviar nueva historia'));
}
$left_options[] = new MenuOption(_('portada'), $globals['base_url'], $id, _('página principal'));
$left_options[] = new MenuOption(_('nuevas'), $globals['base_url'] . 'queue', $id, _('menear noticias pendientes'));
$left_options[] = new MenuOption(_('populares'), $globals['base_url'] . 'popular', $id, _('historias más votadas'));
$left_options[] = new MenuOption(_('más visitadas'), $globals['base_url'] . 'top_visited', $id, _('historias más visitadas/leídas'));
$left_options[] = new MenuOption(_('destacadas'), $globals['base_url'] . 'top_active', $id, _('historias más activas'));
$right_options = array();
$right_options[] = new MenuOption(_('m/'), $globals['base_url_general'] . 'subs', $id, _('sub menéames'));
$right_options[] = new MenuOption(_('fisgona'), $globals['base_url'] . 'sneak', $id, _('visualizador en tiempo real'));
$right_options[] = new MenuOption(_('nótame'), post_get_base_url(), $id, _('leer o escribir notas y mensajes privados'));
$right_options[] = new MenuOption(_('galería'), 'javascript:fancybox_gallery(\'all\');', false, _('las imágenes subidas por los usuarios'));
} else {
$left_options = $options;
$right_options = array();
//$right_options[] = new MenuOption(_('portada'), $globals['base_url'], '', _('página principal'));
$right_options[] = new MenuOption(_('nuevas'), $globals['base_url'] . 'queue', '', _('menear noticias pendientes'));
$right_options[] = new MenuOption(_('m/'), $globals['base_url_general'] . 'subs', $id, _('sub menéames'));
$right_options[] = new MenuOption(_('fisgona'), $globals['base_url'] . 'sneak', $id, _('visualizador en tiempo real'));
$right_options[] = new MenuOption(_('nótame'), post_get_base_url(), $id, _('leer o escribir notas y mensajes privados'));
$right_options[] = new MenuOption(_('galería'), 'javascript:fancybox_gallery(\'all\');', false, _('las imágenes subidas por los usuarios'));
}
$vars = compact('title', 'greeting', 'id', 'left_options', 'right_options', 'sites', 'this_site', 'this_site_properties');
return Haanga::Load('header.html', $vars);
}
示例6: prepare_summary_text
function prepare_summary_text($length = 0)
{
global $globals, $current_user;
if ($this->single_link) {
$this->html_id = $this->order;
} else {
$this->html_id = $this->id;
}
$this->can_edit = (!isset($this->basic_summary) || !$this->basic_summary) && ($this->author == $current_user->user_id && $globals['now'] - $this->date < $globals['comment_edit_time'] || ($this->author != $current_user->user_id || $this->type == 'admin') && $current_user->user_level == 'god');
if ($length > 0) {
$this->truncate($length);
}
$this->txt_content = $this->to_html($this->content);
if ($this->media_size > 0) {
$this->media_thumb_dir = Upload::get_cache_relative_dir($this->id);
$this->media_url = Upload::get_url('comment', $this->id, 0, $this->media_date, $this->media_mime);
}
}
示例7: uniqid
}
}
}
$tmpfile = $dir . '/' . $current_user->user_id . '-' . $current_user->user_login . '-' . uniqid();
if (file_put_contents($tmpfile, $source)) {
$info = getimagesize($tmpfile);
if (!$info) {
@unlink($tmpfile);
$r->error = _('imagen no soportada');
echo json_encode($r);
die;
}
$ext = image_type_to_extension($info[2]);
$uploadfile = $tmpfile . $ext;
@rename($tmpfile, $uploadfile);
require_once mnminclude . "simpleimage.php";
$image = new SimpleImage();
if ($image->rotate_exif($uploadfile)) {
$image->save($uploadfile);
}
$r->type = $info['mime'];
$r->name = basename($uploadfile);
$r->url = $globals['base_static'] . Upload::get_cache_relative_dir() . '/tmp/' . $r->name;
$r->thumb = $globals['base_static'] . Upload::get_cache_relative_dir() . "/tmp/tmp_thumb-{$r->name}";
// Creates the thumbnail
$thumb = new SimpleImage();
$thumb->load($uploadfile);
$thumb->resize($globals['media_thumb_size'], $globals['media_thumb_size'], true);
$thumb->save(dirname($uploadfile) . "/tmp_thumb-{$r->name}", -1);
echo json_encode($r);
}
示例8: has_thumb
function has_thumb()
{
global $globals;
if (!empty($this->thumb_url)) {
return $this->thumb_url;
}
if ($this->media_size > 0) {
// New format
$base = $globals['base_static_noversion'];
$this->thumb_uri = Upload::get_cache_relative_dir($this->id) . "/media_thumb-link-{$this->id}.{$this->media_extension}?{$this->media_date}";
$this->thumb_url = $base . $this->thumb_uri;
$this->media_url = Upload::get_url('link', $this->id, 0, $this->media_date, $this->media_mime);
$this->thumb_x = $this->thumb_y = $globals['thumb_size'];
return $this->thumb_url;
}
$this->thumb_url = false;
return false;
}
示例9: thumb_download
function thumb_download($basename = 'thumb', $delete = true)
{
global $globals;
$file = Upload::get_cache_relative_dir($this->id) . "/{$basename}-{$this->id}.jpg";
$filepath = mnmpath . "/{$file}";
if ($basename == "thumb_medium") {
$s3_base = "medium_";
$s3_filename = "medium_{$this->id}.jpg";
} elseif ($basename == "thumb_2x") {
$s3_base = "2x_";
$s3_filename = "2x_{$this->id}.jpg";
} else {
$s3_base = "";
$s3_filename = "{$this->id}.jpg";
}
if ($this->thumb_x > 0 && $this->thumb_y > 0 && $globals['Amazon_S3_media_bucket'] && $globals['Amazon_S3_local_cache']) {
Upload::create_cache_dir($this->id);
// Get thumbnail from S3
if (Media::get($s3_filename, 'thumbs', $filepath)) {
return $filepath;
} elseif ($delete) {
// Do extra check, if S3 is working, mark thumb as deleted
if (($buckets = Media::buckets(false)) && in_array($globals['Amazon_S3_media_bucket'], $buckets) && is_writable(mnmpath . '/' . $globals['cache_dir'])) {
// Double check
syslog(LOG_NOTICE, "Meneame, deleting unexisting thumb for {$base}_{$this->id}");
$this->delete_thumb($s3_base);
}
}
}
return false;
}