Exemplo n.º 1
0
 /**
  * 异步发送邮件
  */
 protected static function putAsyncMail($filename)
 {
     $options = Typecho_Widget::widget('Widget_Options');
     $siteUrl = $options->rewrite ? $options->siteUrl : $options->siteUrl . 'index.php';
     $dmpt = parse_url($siteUrl);
     $host = $dmpt['host'];
     $port = isset($dmpt['port']) ? $dmpt['port'] : 80;
     if (substr($dmpt['path'], -1) != '/') {
         $dmpt['path'] .= '/';
     }
     $url = $dmpt['path'] . 'action/forum';
     $get = 'do=sendmail&name=' . $filename;
     $head = "GET " . $url . "?" . $get . " HTTP/1.0\r\n";
     $head .= "Host: " . $host . "\r\n";
     $head .= "\r\n";
     if (function_exists('fsockopen')) {
         $fp = @fsockopen($host, $port, $errno, $errstr, 30);
     } elseif (function_exists('pfsockopen')) {
         $fp = @pfsockopen($host, $port, $errno, $errstr, 30);
     } else {
         $fp = stream_socket_client($host . ":{$port}", $errno, $errstr, 30);
     }
     if ($fp) {
         fputs($fp, $head);
         fclose($fp);
     } else {
         file_put_contents('.' . self::getDIr . 'error_log.txt', "SOCKET错误," . $errno . ':' . $errstr);
     }
 }
Exemplo n.º 2
0
    /**
     * ajax执行action
     *
     * @access public
     * @param array $contents 文章输入信息
     * @return void
     */
    public static function ajax()
    {
        Typecho_Widget::widget('Widget_Options')->to($options);
        ?>
<script>
    
function baiduSlug() {
    var title = $('#title');
    var slug = $('#slug');

    if (slug.val().length > 0 || title.val().length == 0) {
        return;
    }

    $.ajax({
        url: '<?php 
        $options->index('/action/baidu-slug?q=');
        ?>
' + title.val(),
        success: function(data) {
            if (data.result.length > 0) {
                slug.val(data.result).focus();
                slug.siblings('pre').text(data.result);
            }
        }
    });
}

$(function() {
    $('#title').blur(baiduSlug);
    $('#slug').blur(baiduSlug);
});
</script>
<?php 
    }
Exemplo n.º 3
0
 /**
  * 输出尾部js
  * 
  * @access public
  * @param unknown $footer
  * @return unknown
  */
 public static function footer()
 {
     $jsUrl = Helper::options()->pluginUrl . '/LaTex/latex.js';
     echo '<script type="text/javascript" src="' . $jsUrl . '"></script>';
     $mark = Typecho_Widget::widget('Widget_Options')->plugin('LaTex')->mark;
     echo '<script type="text/javascript">latex.parse("' . $mark . '");</script>';
 }
Exemplo n.º 4
0
 public static function parseCallback($matches)
 {
     $no_html5 = array('www.letv.com', 'v.yinyuetai.com', 'v.ku6.com');
     $providers = array('v.youku.com' => array('#https?://v\\.youku\\.com/v_show/id_(?<video_id>[a-z0-9_=\\-]+)#i', 'http://player.youku.com/player.php/sid/{video_id}/v.swf', 'http://player.youku.com/embed/{video_id}'), 'www.tudou.com' => array('#https?://(?:www\\.)?tudou\\.com/(?:programs/view|listplay/(?<list_id>[a-z0-9_=\\-]+))/(?<video_id>[a-z0-9_=\\-]+)#i', 'http://www.tudou.com/v/{video_id}/&resourceId=0_05_05_99&bid=05/v.swf', 'http://www.tudou.com/programs/view/html5embed.action?type=0&code={video_id}'), 'www.56.com' => array('#https?://(?:www\\.)?56\\.com/[a-z0-9]+/(?:play_album\\-aid\\-[0-9]+_vid\\-(?<video_id>[a-z0-9_=\\-]+)|v_(?<video_id2>[a-z0-9_=\\-]+))#i', 'http://player.56.com/v_{video_id}.swf', 'http://www.56.com/iframe/{video_id}'), 'v.qq.com' => array('#https?://v\\.qq\\.com/(?:[a-z0-9_\\./]+\\?vid=(?<video_id>[a-z0-9_=\\-]+)|(?:[a-z0-9/]+)/(?<video_id2>[a-z0-9_=\\-]+))#i', 'http://static.video.qq.com/TPout.swf?vid={video_id}', 'http://v.qq.com/iframe/player.html?vid={video_id}'), 'my.tv.sohu.com' => array('#https?://my\\.tv\\.sohu\\.com/us/(?:\\d+)/(?<video_id>\\d+)#i', 'http://share.vrs.sohu.com/my/v.swf&topBar=1&id={video_id}&autoplay=false&xuid=&from=page', 'http://tv.sohu.com/upload/static/share/share_play.html#{video_id}_0_0_9001_0'), 'www.wasu.cn' => array('#https?://www\\.wasu\\.cn/play/show/id/(?<video_id>\\d+)#i', 'http://s.wasu.cn/portal/player/20141216/WsPlayer.swf?mode=3&vid={video_id}&auto=0&ad=4228', 'http://www.wasu.cn/Play/iframe/id/{video_id}'), 'www.letv.com' => array('#https?://www\\.letv\\.com/ptv/vplay/(?<video_id>\\d+)#i', 'http://i7.imgs.letv.com/player/swfPlayer.swf?id={video_id}&autoplay=0', ''), 'www.acfun.tv' => array('#https?://www\\.acfun\\.tv/v/ac(?<video_id>\\d+)#i', 'http://static.acfun.mm111.net/player/ACFlashPlayer.out.swf?type=page&url=http://www.acfun.tv/v/ac{video_id}', ''), 'www.bilibili.com' => array('#https?://www\\.bilibili\\.com/video/av(?<video_id>\\d+)#i', 'http://static.hdslb.com/miniloader.swf?aid={video_id}&page=1', ''), 'v.yinyuetai.com' => array('#https?://v\\.yinyuetai\\.com/video/(?<video_id>\\d+)#i', 'http://player.yinyuetai.com/video/player/{video_id}/v_0.swf', ''), 'v.ku6.com' => array('#https?://v\\.ku6\\.com/show/(?<video_id>[a-z0-9\\-_\\.]+).html#i', 'http://player.ku6.com/refer/{video_id}/v.swf', ''));
     $parse = parse_url($matches['video_url']);
     $site = $parse['host'];
     if (!in_array($site, array_keys($providers))) {
         return '<p><a href="' . $matches['video_url'] . '">' . $matches['video_url'] . '</a></p>';
     }
     preg_match_all($providers[$site][0], $matches['video_url'], $match);
     $id = $match['video_id'][0] == '' ? $match['video_id2'][0] : $match['video_id'][0];
     if (self::isMobile()) {
         $width = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->mobile_width;
         $height = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->mobile_height;
     } else {
         $width = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->width;
         $height = Typecho_Widget::widget('Widget_Options')->plugin('Typembed')->height;
     }
     if (self::isMobile() && !in_array($site, $no_html5)) {
         $url = str_replace('{video_id}', $id, $providers[$site][2]);
         $html = sprintf('<iframe src="%1$s" width="%2$s" height="%3$s" frameborder="0" allowfullscreen="true"></iframe>', $url, $width, $height);
     } else {
         $url = str_replace('{video_id}', $id, $providers[$site][1]);
         $html = sprintf('<embed src="%1$s" allowFullScreen="true" quality="high" width="%2$s" height="%3$s" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>', $url, $width, $height);
     }
     return '<div id="typembed">' . $html . '</div>';
 }
Exemplo n.º 5
0
 /**
  * 构造函数,初始化组件
  *
  * @access public
  * @param mixed $request request对象
  * @param mixed $response response对象
  * @param mixed $params 参数列表
  */
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     /** 初始化数据库 */
     $this->db = Typecho_Db::get();
     $this->options = $this->widget('Widget_Options');
 }
Exemplo n.º 6
0
 public function __construct()
 {
     $this->db = Typecho_Db::get();
     $this->prefix = $this->db->getPrefix();
     $this->table = $this->prefix . 'access';
     $this->config = Typecho_Widget::widget('Widget_Options')->plugin('Access');
     $this->request = Typecho_Request::getInstance();
     $this->pageSize = $this->config->pageSize;
     $this->isDrop = $this->config->isDrop;
     if ($this->pageSize == null || $this->isDrop == null) {
         throw new Typecho_Plugin_Exception('请先设置插件!');
     }
     switch ($this->request->get('action')) {
         case 'logs':
         default:
             $this->action = 'logs';
             $this->title = '访问日志';
             $this->parseLogs();
             break;
         case 'overview':
             $this->action = 'overview';
             $this->title = '访问概览';
             $this->parseOverview();
             break;
     }
 }
Exemplo n.º 7
0
 /**
  * 构造函数
  *
  * @access public
  * @param mixed $request request对象
  * @param mixed $response response对象
  * @param mixed $params 参数列表
  */
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     $this->notice = parent::widget('Widget_Notice');
     $this->options = parent::widget('Widget_Options');
     $this->config = $this->options->plugin('Passport');
 }
Exemplo n.º 8
0
 public static function insertStyle()
 {
     $custom = Typecho_Widget::widget('Widget_Options')->Plugin('ymplayer')->custom;
     if ($custom != '') {
         echo "<style id=\"ymplayer_custom_style\">\n" . $custom . "\n</style>";
     }
 }
Exemplo n.º 9
0
 public static function info()
 {
     $options = Typecho_Widget::widget('Widget_Options');
     $Ukagaka = $options->plugin('Ukagaka');
     $wcc['notice'] = stripslashes($Ukagaka->notice);
     $db = Typecho_Db::get();
     $select = $db->select()->from('table.options')->where('name = ?', 'Ukagaka_starttime');
     $lifetime = $db->fetchAll($select);
     $lifetime = self::get_wcc_lifetime($lifetime[0]['value']);
     $name = Typecho_Widget::widget('Widget_Options')->title;
     $wcc['showlifetime'] = '我已经与主人 ' . $name . ' 一起生存了 <font color="red">' . $lifetime["day"] . '</font> 天 <font color="red">' . $lifetime["hours"] . '</font> 小时 <font color="red">' . $lifetime["minutes"] . '</font> 分钟 <font color="red">' . $lifetime["seconds"] . '</font> 秒的快乐时光啦~*^_^*';
     $foods = explode("\r\n", $Ukagaka->foods);
     foreach ($foods as $key => $value) {
         $xx = explode("//", $value);
         $wcc['foods'][] = $xx[0];
         $wcc['eatsay'][] = $xx[1];
     }
     if ($Ukagaka->contact) {
         $contact = explode("\r\n", $Ukagaka->contact);
         foreach ($contact as $key => $value) {
             $xx = explode("//", $value);
             $wcc['ques'][] = $xx[0];
             $wcc['ans'][] = $xx[1];
         }
     } else {
         $wcc['contactapi'] = '1';
     }
     $wcc = json_encode($wcc);
     echo $wcc;
 }
Exemplo n.º 10
0
 /**
  * 插件实现方法
  *
  * @access public
  * @return void
  */
 public static function render($agent)
 {
     $options = Typecho_Widget::widget('Widget_Options');
     $url_plugin = $options->pluginUrl . '/UserAgent/';
     //插件地址  ->  http://domain.com/usr/plugins/UserAgent/
     global $url_img, $icons;
     $url_img = $url_plugin . "img/";
     $icons = Typecho_Widget::widget('Widget_Options')->plugin('UserAgent')->icons;
     $show = Typecho_Widget::widget('Widget_Options')->plugin('UserAgent')->show;
     require_once 'useragent-os.php';
     $os = detect_os($agent);
     $os_img = self::img($os['code'], "/os/", $os['title']);
     $os_title = $os['title'];
     require_once 'useragent-webbrowser.php';
     $wb = detect_webbrowser($agent);
     $wb_img = self::img($wb['code'], "/net/", $wb['title']);
     $wb_title = $wb['title'];
     switch ($show) {
         case 1:
             $ua = "&nbsp;&nbsp;" . $os_img . "&nbsp;" . $wb_img;
             break;
         case 2:
             $ua = "&nbsp;&nbsp;(" . $os_title . "&nbsp;/&nbsp;" . $wb_title . ")";
             break;
         case 3:
             $ua = "&nbsp;&nbsp;" . $os_img . "(" . $os_title . ")&nbsp;/&nbsp;" . $wb_img . "(" . $wb_title . ")";
             break;
         default:
             $ua = "&nbsp;&nbsp;" . $os_img . $wb_img;
             break;
     }
     echo $ua;
 }
function links($slug)
{
    $db = Typecho_Db::get();
    $Contents = Typecho_Widget::widget('Widget_Abstract_Contents');
    $value = $db->fetchRow($db->select()->from('table.contents')->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', 'page')->where('table.contents.slug = ?', $slug)->where('table.contents.password IS NULL')->limit(1));
    $value = $Contents->filter($value);
    if (0 === strpos($value['text'], '<!--markdown-->')) {
        $value['isMarkdown'] = 0;
    } else {
        $value['isMarkdown'] = 1;
    }
    if ($value['isMarkdown'] == 1) {
        $text = substr($value['text'], 15);
        $text = $Contents->markdown($text);
    } else {
        $text = $Contents->autoP($value['text']);
    }
    $search = '/<ul>(.*?)<\\/ul>/is';
    preg_match_all($search, $text, $matches);
    $result = '';
    foreach ($matches[1] as $v) {
        $result .= $v;
    }
    $result = str_replace('<li>', '', $result);
    $result = str_replace('</li>', '<br/>', $result);
    $result = rtrim($result, '<br/>');
    echo $result;
}
Exemplo n.º 12
0
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     /* 获取数据库对象、配置及用户 */
     $this->_db = Typecho_Db::get();
     $this->_options = Typecho_Widget::widget('Widget_Options');
 }
Exemplo n.º 13
0
 public function action()
 {
     $this->db = Typecho_Db::get();
     $this->prefix = $this->db->getPrefix();
     $this->options = Typecho_Widget::widget('Widget_Options');
     $cid = $this->request->cid;
     if (!$cid) {
         $this->response->throwJson(array('status' => 0, 'msg' => '请选择喜欢的文章!'));
     }
     $likes = Typecho_Cookie::get('__post_likes');
     if (empty($likes)) {
         $likes = array();
     } else {
         $likes = explode(',', $likes);
     }
     if (!in_array($cid, $likes)) {
         $row = $this->db->fetchRow($this->db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
         $this->db->query($this->db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
         array_push($likes, $cid);
         $likes = implode(',', $likes);
         Typecho_Cookie::set('__post_likes', $likes);
         //记录查看cookie
         $this->response->throwJson(array('status' => 1, 'msg' => '成功点赞!'));
     }
     $this->response->throwJson(array('status' => 0, 'msg' => '你已经点赞过了!'));
 }
Exemplo n.º 14
0
function thumbnail($obj, $size = null, $link = false, $pattern = '<div class="post-thumb"><a class="thumb" href="{permalink}" title="{title}" style="background-image:url({thumb})"></a></div>')
{
    preg_match_all("/<[img|IMG].*?src=[\\'|\"](.*?)[\\'|\"].*?[\\/]?>/", $obj->content, $matches);
    $thumb = '';
    $options = Typecho_Widget::widget('Widget_Options');
    if (isset($matches[1][0])) {
        $thumb = $matches[1][0];
        if (!empty($options->src_add) && !empty($options->cdn_add)) {
            $thumb = str_ireplace($options->src_add, $options->cdn_add, $thumb);
        }
        if ($size != 'full') {
            $thumb_width = $options->thumb_width;
            $thumb_height = $options->thumb_height;
            if ($size != null) {
                $size = explode('x', $size);
                if (!empty($size[0]) && !empty($size[1])) {
                    list($thumb_width, $thumb_height) = $size;
                }
            }
            $thumb .= '?imageView2/4/w/' . $thumb_width . '/h/' . $thumb_height;
        }
    }
    if (empty($thumb) && empty($options->default_thumb)) {
        return '';
    } else {
        $thumb = empty($thumb) ? $options->default_thumb : $thumb;
    }
    if ($link) {
        return $thumb;
    }
    echo str_replace(array('{title}', '{thumb}', '{permalink}'), array($obj->title, $thumb, $obj->permalink), $pattern);
}
Exemplo n.º 15
0
 /**
  *判断用户是否已登录,未登录自动跳转到登录页面
  *@return void
  */
 public function checkLogin()
 {
     $user = Typecho_Widget::widget('Widget_User');
     if (!$user->hasLogin()) {
         Typecho_Widget::widget('Widget_Notice')->set(_t("未登录"), 'error');
         $this->response->redirect($this->options->adminUrl);
     }
 }
Exemplo n.º 16
0
 /**
  * 设置参数,并加入脚部
  * 
  * @access public
  * @return void
  */
 public static function Snowstorm()
 {
     $options = Typecho_Widget::widget('Widget_Options')->plugin('Snowstorm');
     $color = preg_match('/^#[0-9a-f]{3,6}$/is', $options->snowColor);
     //判断是否为颜色代码
     $color = $color ? $options->snowColor : '#fff';
     echo '<script>snowColor = "' . $color . '";freezeOnBlur = ' . $options->freezeOnBlur . ';followMouse = ' . $options->followMouse . ';animationInterval = ' . $options->animationInterval . ';snowColorRand=' . $options->snowColorRand . ';</script>' . "\n\r" . '<script type="text/javascript" src="/usr/plugins/Snowstorm/res/snowstorm.min.js"></script>';
 }
Exemplo n.º 17
0
 /**
  * 构造函数,初始化组件
  *
  * @access public
  * @param mixed $request request对象
  * @param mixed $response response对象
  * @param mixed $params 参数列表
  * @return void
  */
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     /** 初始化数据库 */
     $this->db = Typecho_Db::get();
     /** 初始化常用组件 */
     $this->user = $this->widget('Widget_User');
 }
Exemplo n.º 18
0
 /**
  * 插件实现方法
  *
  * @access public
  * @return void
  */
 public static function setTheme($widget)
 {
     $cookie = array('name' => '__typecho_theme', 'expire' => 86400);
     $options = Typecho_Widget::widget('Widget_Options');
     if (isset($widget->request->theme) && $widget->request->isGet()) {
         if ($widget->request->theme) {
             $theme = $widget->request->theme;
             if (static::check($theme)) {
                 Typecho_Cookie::set($cookie['name'], $widget->request->theme, $options->gmtTime + $cookie['expire'], $options->siteUrl);
             } else {
                 $widget->response->redirect(Typecho_Common::url($widget->request->getPathInfo(), $options->siteUrl));
             }
         } else {
             Typecho_Cookie::delete($cookie['name']);
             //直接提交?theme将删除cookie,恢复默认主题
             return;
         }
     } else {
         $theme = Typecho_Cookie::get($cookie['name']);
         if (!$theme) {
             return;
         }
         if (!static::check($theme)) {
             Typecho_Cookie::delete($cookie['name']);
             return;
         }
     }
     /** 删除旧主题的相关设置 */
     $themeRow = 'theme:' . $options->theme;
     if (isset($options->{$themeRow})) {
         $config = unserialize($options->{$themeRow});
         $options->{$themeRow} = '';
         foreach ($config as $row => $value) {
             $options->{$row} = '';
         }
     }
     /** 载入新主题的相关设置 参考var/Widget/Themes/Edit.php */
     $themeDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR;
     $configFile = $themeDir . 'functions.php';
     if (file_exists($configFile)) {
         require_once $configFile;
         if (function_exists('themeConfig')) {
             $form = new Typecho_Widget_Helper_Form();
             themeConfig($form);
             $config = $form->getValues();
             if ($config) {
                 $options->{'theme:' . $theme} = serialize($config);
                 foreach ($config as $row => $value) {
                     $options->{$row} = $value;
                 }
             }
         }
     }
     /** 修改$this->options->theme */
     $options->theme = $theme;
     /** 修改$this->_themeDir */
     $widget->setThemeDir($themeDir);
 }
Exemplo n.º 19
0
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     $this->db = Typecho_Db::get();
     $this->options = Helper::options();
     //$this->pluginRootUrl = Typecho_Common::url('Api/', $this->options->pluginUrl);
     require_once 'Twig/Autoloader.php';
     Twig_Autoloader::register();
 }
Exemplo n.º 20
0
 public static function deactivate()
 {
     $pluginOpts = Typecho_Widget::widget('Widget_Options')->plugin('TypechoXcache');
     if ($pluginOpts->clearCacheAfterDisable == 'true') {
         xcache_unset_by_prefix($pluginOpts->{$prefix});
         return '缓存清空,成功关闭';
     }
     return '成功关闭';
 }
Exemplo n.º 21
0
    public static function buildCalendar()
    {
        //判断当前插件是否已被启用
        $options = Typecho_Widget::widget('Widget_Options');
        if (!isset($options->plugins['activated']['Calendar'])) {
            return '日历插件未被激活';
        }
        $mdays = date("t");
        //当月总天数
        $datenow = date("j");
        //当日日期
        $monthnow = date("n");
        //当月月份
        $yearnow = date("Y");
        //当年年份
        //计算当月第一天是星期几
        $wk1st = date("w", mktime(0, 0, 0, $monthnow, 1, $yearnow)) - 1;
        $trnum = ceil(($mdays + $wk1st) / 7);
        //计算表格行数
        $out = <<<HEAD
        <div id="cal_switcher" class="list-group-item clearfix">
        \t<a href="javascript:move('left')"><i class="fa fa-angle-left"></i></a>
            <div id="cal_yearmonth">
\t            <span id="cal_year"><b>{$yearnow}</b>年</span>
\t            <span id="cal_month"><b>{$monthnow}</b>月</span>
            </div>
            <a href="javascript:move('right')"><i class="fa fa-angle-right"></i></a>
        </div>
HEAD;
        //以下是表格字串
        $out .= "<table id=cal_plugin class=\"table table-bordered\"><tr class=cal-header><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th><th>日</th></tr>";
        for ($i = 0; $i < $trnum; $i++) {
            $out .= "<tr class=cal-body>";
            for ($k = 0; $k < 7; $k++) {
                //每行七个单元格
                $tabidx = $i * 7 + $k;
                //取得单元格自身序号
                //若单元格序号小于当月第一天的星期数($wk1st)或大于(月总数+$wk1st)
                //只填写空格,反之,写入日期
                ($tabidx < $wk1st or $tabidx > $mdays + $wk1st - 1) ? $dayecho = "&nbsp" : ($dayecho = $tabidx - $wk1st + 1);
                //突出标明今日日期
                // $dayecho="<span style=\"background-color:red;color:#fff;\">$dayecho</span>";
                $todayclass = "";
                if ($k > 4) {
                    $todayclass .= " weekend";
                }
                if ($dayecho == $datenow) {
                    $todayclass .= " current";
                }
                $todaybg = empty($todayclass) ? "" : " class=\"{$todayclass}\"";
                $out .= "<td" . $todaybg . ">{$dayecho}</td>";
            }
            $out .= "</tr>";
        }
        $out .= "</table>" . PHP_EOL;
        return $out;
    }
Exemplo n.º 22
0
 /**
  * 插件实现方法
  * 
  * @access public
  * @return void
  */
 public static function render($post)
 {
     $options = Helper::options();
     $plugin_options = Typecho_Widget::widget('Widget_Options')->plugin('KEditor');
     $newlineTag = $plugin_options->newlineTag;
     $themesTab = $plugin_options->themesTab;
     $editor_path = Typecho_Common::url('KEditor/editor', $options->pluginUrl);
     echo "\n<script type=\"text/javascript\" charset=\"utf-8\" src=\"{$editor_path}/kindeditor.js\"></script> \n<script type=\"text/javascript\">\n    KE.show({\n\t\tresizeMode : 1,\n\t    themesPath : '{$themesTab}',\n\t\tlangPath : 'zh_CN',\n\t    newlineTag : '{$newlineTag}',\n        id : 'text'\n    });\n\t\$('btn-save').addEvent('mouseover', function (e) {\n\t\tKE.util.setData('text'); \n\t});\n\t\$('btn-submit').addEvent('mouseover', function (e) {\n\t\tKE.util.setData('text'); \n\t});\n    function insertHtml(id, html) {\n        KE.util.focus(id);\n        KE.util.selection(id);\n        KE.util.insertHtml(id, html);\n    }\n    /** 附件插入实现 */\n    var insertImageToEditor = function (title, url, link) {\n        insertHtml('text', '<a href=\"' + link + '\" title=\"' + title + '\"><img src=\"' + url + '\" alt=\"' + title + '\" /></a>');\n    };\n    var insertLinkToEditor = function (title, url, link) {\n        insertHtml('text', '<a href=\"' + url + '\" title=\"' + title + '\">' + title + '</a>');\n    };\n</script>";
 }
Exemplo n.º 23
0
 /**
  * 高亮处理器
  * @access public
  * @param string $content 文章正文
  * @param Widget_Abstract_Contents $opt 
  */
 public static function qiniucdn($content, $opt)
 {
     $options = Typecho_Widget::widget('Widget_Options');
     $config = $options->plugin('QiniuCDN');
     $beforeadd = $config->bad;
     $afteradd = $config->aad;
     $result = str_ireplace($beforeadd, $afteradd, $content);
     return trim($result);
 }
Exemplo n.º 24
0
 /**
  * 缓存清空
  *
  * @access private
  * @return void
  */
 private function deletefile()
 {
     $path = __TYPECHO_ROOT_DIR__ . '/usr/plugins/cPlayer/cache/';
     foreach (glob($path . '*') as $filename) {
         unlink($filename);
     }
     Typecho_Widget::widget('Widget_Notice')->set(_t('歌词缓存已清空!'), NULL, 'success');
     Typecho_Response::getInstance()->goBack();
 }
Exemplo n.º 25
0
 public function action()
 {
     $this->db = Typecho_Db::get();
     $this->options = Typecho_Widget::widget('Widget_Options');
     $this->on($this->request->is('do=insert'))->insertLink();
     $this->on($this->request->is('do=update'))->updateLink();
     $this->on($this->request->is('do=delete'))->deleteLink();
     $this->on($this->request->is('do=sort'))->sortLink();
     $this->response->redirect($this->options->adminUrl);
 }
Exemplo n.º 26
0
 public static function insertStyle()
 {
     if (self::$flag) {
         $font_awesome_option = Typecho_Widget::widget('Widget_Options')->Plugin('ymplayer')->font_awesome;
         if ($font_awesome_option == 'yes') {
             echo "<link href=\"" . Helper::options()->pluginUrl . "/ymplayer/dist/font-awesome.css\" rel=\"stylesheet\">\n";
         }
         echo "<link href=\"" . Helper::options()->pluginUrl . "/ymplayer/dist/ymplayer.css\" rel=\"stylesheet\">\n";
     }
 }
Exemplo n.º 27
0
function getTagCount()
{
    $tags = Typecho_Widget::widget('Widget_Metas_Tag_Cloud');
    // 获取标签数目
    $count = 0;
    while ($tags->next()) {
        $count++;
    }
    return $count;
}
Exemplo n.º 28
0
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     $this->_dir = '.' . __TYPECHO_PLUGIN_DIR__ . '/Update/';
     if (method_exists($this, $this->request->step)) {
         call_user_func(array($this, $this->request->step));
     } else {
         $this->zero();
     }
 }
Exemplo n.º 29
0
 public function __construct($request, $response, $params = NULL)
 {
     parent::__construct($request, $response, $params);
     $pluginOpts = Typecho_Widget::widget('Widget_Options')->plugin('TeStore');
     $this->server = $pluginOpts->server;
     $this->cacheTime = $pluginOpts->cache_time;
     $this->cacheDir = dirname(__FILE__) . '/data/';
     $this->pluginRoot = __TYPECHO_ROOT_DIR__ . __TYPECHO_PLUGIN_DIR__ . '/';
     $this->getAppData();
     define('TYPEHO_ADMIN_PATH', __TYPECHO_ROOT_DIR__ . __TYPECHO_ADMIN_DIR__ . '/');
 }
Exemplo n.º 30
0
    /**
     * 输出底部
     * 
     * @access public
     * @return void
     */
    public static function footer()
    {
        $options = Typecho_Widget::widget('Widget_Options')->plugin('Snow');
        $jsUrl = Helper::options()->pluginUrl . '/Snow/js/three.js';
        $imgUrl = Helper::options()->pluginUrl . '/Snow/img/Snow.png';
        echo '<script type="text/javascript" src="' . $jsUrl . '"></script>' . "\n";
        echo '<script type="text/javascript">
		function randomRange(t,i){return Math.random()*(i-t)+t}Particle3D=function(t){THREE.Particle.call(this,t),this.velocity=new THREE.Vector3(0,-' . $options->snowspeed . ',0),this.velocity.rotateX(randomRange(-45,45)),this.velocity.rotateY(randomRange(0,360)),this.gravity=new THREE.Vector3(0,-' . $options->snowgravity . ',0),this.drag=1},Particle3D.prototype=new THREE.Particle,Particle3D.prototype.constructor=Particle3D,Particle3D.prototype.updatePhysics=function(){this.velocity.multiplyScalar(this.drag),this.velocity.addSelf(this.gravity),this.position.addSelf(this.velocity)};var TO_RADIANS=Math.PI/180;THREE.Vector3.prototype.rotateY=function(t){cosRY=Math.cos(t*TO_RADIANS),sinRY=Math.sin(t*TO_RADIANS);var i=this.z,o=this.x;this.x=o*cosRY+i*sinRY,this.z=o*-sinRY+i*cosRY},THREE.Vector3.prototype.rotateX=function(t){cosRY=Math.cos(t*TO_RADIANS),sinRY=Math.sin(t*TO_RADIANS);var i=this.z,o=this.y;this.y=o*cosRY+i*sinRY,this.z=o*-sinRY+i*cosRY},THREE.Vector3.prototype.rotateZ=function(t){cosRY=Math.cos(t*TO_RADIANS),sinRY=Math.sin(t*TO_RADIANS);var i=this.x,o=this.y;this.y=o*cosRY+i*sinRY,this.x=o*-sinRY+i*cosRY};
		$(function(){var container=document.querySelector(".Snow");if(/MSIE 6|MSIE 7|MSIE 8/.test(navigator.userAgent)){return}else{if(/MSIE 9|MSIE 10/.test(navigator.userAgent)){$(container).css("height",$(window).height()).bind("click",function(){$(this).fadeOut(1000, function(){$(this).remove()})})}}var containerWidth=$(container).width();var containerHeight=$(container).height();var particle;var camera;var scene;var renderer;var mouseX=0;var mouseY=0;var windowHalfX=window.innerWidth/2;var windowHalfY=window.innerHeight/2;var particles=[];var particleImage=new Image();particleImage.src="' . $imgUrl . '";var snowNum=' . $options->snownum . ';function init(){camera=new THREE.PerspectiveCamera(75,containerWidth/containerHeight,1,10000);camera.position.z=1000;scene=new THREE.Scene();scene.add(camera);renderer=new THREE.CanvasRenderer();renderer.setSize(containerWidth,containerHeight);var material=new THREE.ParticleBasicMaterial({map:new THREE.Texture(particleImage)});for(var i=0;i<snowNum;i++){particle=new Particle3D(material);particle.position.x=Math.random()*2000-1000;particle.position.y=Math.random()*2000-1000;particle.position.z=Math.random()*2000-1000;particle.scale.x=particle.scale.y=1;scene.add(particle);particles.push(particle)}container.appendChild(renderer.domElement);document.addEventListener("mousemove",onDocumentMouseMove,false);document.addEventListener("touchstart",onDocumentTouchStart,false);document.addEventListener("touchmove",onDocumentTouchMove,false);setInterval(loop,1000/40)}function onDocumentMouseMove(event){mouseX=event.clientX-windowHalfX;mouseY=event.clientY-windowHalfY}function onDocumentTouchStart(event){if(event.touches.length==1){event.preventDefault();mouseX=event.touches[0].pageX-windowHalfX;mouseY=event.touches[0].pageY-windowHalfY}}function onDocumentTouchMove(event){if(event.touches.length==1){event.preventDefault();mouseX=event.touches[0].pageX-windowHalfX;mouseY=event.touches[0].pageY-windowHalfY}}function loop(){for(var i=0;i<particles.length;i++){var particle=particles[i];particle.updatePhysics();with(particle.position){if(y<-1000){y+=2000}if(x>1000){x-=2000}else{if(x<-1000){x+=2000}}if(z>1000){z-=2000}else{if(z<-1000){z+=2000}}}}camera.position.x+=(mouseX-camera.position.x)*0.005;camera.position.y+=(-mouseY-camera.position.y)*0.005;camera.lookAt(scene.position);renderer.render(scene,camera)}init()});</script>' . "\n";
        echo '<div class="Snow"></div>' . "\n";
    }