public function avatar() { $uid = $this->request->get('uid'); $size = $this->request->get('s'); if (!is_numeric($uid)) { Typecho_Common::error(404); exit; } $path = __TYPECHO_ROOT_DIR__ . Widget_Common::getAvatarPath($uid); $path .= $uid . '.jpg'; if (!is_file($path)) { $path = __TYPECHO_ROOT_DIR__ . '/usr/avatar/default.jpg'; } require_once __TYPECHO_ROOT_DIR__ . '/var/Util/Image.php'; $image = new Image(); $image->open($path); $type = $image->type(); if (is_numeric($size)) { $image->thumb($size, $size); } header('Content-Type:image/' . $type . ';'); //输出图像 if ('jpeg' == $type || 'jpg' == $type) { // 采用jpeg方式输出 imagejpeg($image->showImg()); } elseif ('gif' == $type) { imagegif($image->showImg()); } else { $fun = 'image' . $type; $fun($image->showImg()); } }
public function render() { /** 初始化皮肤函数 */ $functionsFile = $this->_themeDir . 'functions.php'; if (file_exists($functionsFile)) { require_once $functionsFile; if (function_exists('themeInit')) { themeInit($this); } } /** 文件不存在 */ if (!file_exists($this->_themeDir . $this->_themeFile)) { Typecho_Common::error(500); } /** 输出模板 */ require_once $this->_themeDir . $this->_themeFile; }
/** * 输出视图 * * @access public * @return void */ public function render() { /** 处理静态链接跳转 */ $this->checkPermalink(); /** 添加Pingback */ $this->response->setHeader('X-Pingback', $this->options->xmlRpcUrl); $validated = false; //~ 自定义模板 if (!empty($this->_themeFile)) { if (file_exists($this->_themeDir . $this->_themeFile)) { $validated = true; } } if (!$validated && !empty($this->_archiveType)) { //~ 首先找具体路径, 比如 category/default.php if (!$validated && !empty($this->_archiveSlug)) { $themeFile = $this->_archiveType . '/' . $this->_archiveSlug . '.php'; if (file_exists($this->_themeDir . $themeFile)) { $this->_themeFile = $themeFile; $validated = true; } } //~ 然后找归档类型路径, 比如 category.php if (!$validated) { $themeFile = $this->_archiveType . '.php'; if (file_exists($this->_themeDir . $themeFile)) { $this->_themeFile = $themeFile; $validated = true; } } //针对attachment的hook if (!$validated && 'attachment' == $this->_archiveType) { if (file_exists($this->_themeDir . 'page.php')) { $this->_themeFile = 'page.php'; $validated = true; } else { if (file_exists($this->_themeDir . 'post.php')) { $this->_themeFile = 'post.php'; $validated = true; } } } //~ 最后找归档路径, 比如 archive.php 或者 single.php if (!$validated && 'index' != $this->_archiveType && 'front' != $this->_archiveType) { $themeFile = $this->_archiveSingle ? 'single.php' : 'archive.php'; if (file_exists($this->_themeDir . $themeFile)) { $this->_themeFile = $themeFile; $validated = true; } } if (!$validated) { $themeFile = 'index.php'; if (file_exists($this->_themeDir . $themeFile)) { $this->_themeFile = $themeFile; $validated = true; } } } /** 文件不存在 */ if (!$validated) { Typecho_Common::error(500); } /** 挂接插件 */ $this->pluginHandle()->beforeRender($this); /** 输出模板 */ require_once $this->_themeDir . $this->_themeFile; /** 挂接插件 */ $this->pluginHandle()->afterRender($this); }
public function render($themeFile) { /** 文件不存在 */ if (!file_exists($this->_themeDir . $themeFile)) { Typecho_Common::error(500); } /** 输出模板 */ require_once $this->_themeDir . $themeFile; }