歡迎光臨, 訪客. 請先 登入註冊一個帳號.
五月 17, 2024, 08:30:18 下午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
  列出文章
頁: 1 [2] 3 4 5
16  開發 / 外掛程式 / Re: LifeType 外掛: 新增迴響 MSN/Yahoo 即時通知 於: 四月 07, 2007, 11:02:49 上午
修正一下原本產生的訊息內容, 原本那個 Article 的 link 只能在我這兒用. 另外把 phpmsnclass 也包進去, 有需要的就重抓一次吧.
17  開發 / 外掛程式 / LifeType 外掛: 新增迴響 MSN/Yahoo 即時通知 於: 四月 06, 2007, 04:09:43 下午
轉自: http://blog.teatime.com.tw/1/post/226

這個外掛會在有人新增迴響的時候, 利用 msnbot 或 msn.class.php 發出 MSN/Yahoo 的訊息到你所指定的收件人. 當然, 要接受訊息的人必須把 msnbot 所用的帳號加入才可以收到訊息.

檔案放在: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_1.2_addcommentnotify.tgz 

在 LifeType 的 plugins 目錄中, 把檔案解開, 然後到 LifeType 的管理介面中, 把這個外掛加入, 並且設定好 msnbot 所用的 spool 路徑或者選擇使用 msn.class.php, 並設定登入帳號密碼, msn.class.php 的位置與要收取訊息的帳號列表 (以逗號分隔, 如果是 Yahoo 的即時通帳號, 記得在 email 後加上 @32 就可以), 然後把這個外掛啟用.

這樣子, 只要有人到這個 blog 發送新的迴響, 系統就把透過 msnbot 或 msn.class.php 送出訊息了.

PS: 你必須要安裝並設定好 msnbot 或 msn.class.php 之後, 才能正確的發現訊息. 請參考:
http://blog.teatime.com.tw/1/post/227
http://blog.teatime.com.tw/1/post/220
http://blog.teatime.com.tw/1/post/200

Submit to Mantis: http://bugs.lifetype.net/view.php?id=1264

18  開發 / 外掛程式 / 修正 LifeType 1.2 使用 Gallery 外掛無法顯示相簿的問題 於: 四月 05, 2007, 08:52:51 上午
原本之前改了 Gallery 的外掛給 LifeType 1.2 使用, 以為一切的正常, 結果今天才發現, 雖然可以顯示圖片, 不過一點選圖片或選擇進入相簿時, 並無法像之前在 1.1 時的運作一般, 可以進入 Gallery 系統中.

檢查一下程式, 發現在改成 1.2 使用時,  在註冊相關服務時, 變成只有 admin 才會去註冊, 一般的使用就沒有註冊 gallery 服務, 所以在執行 op=gallery 時, 就無法運作了.

這個 patch 可以修正這個問題: http://www.teatime.com.tw/~tommy/mypatch/lifetype12_gallery_plugin.patch
程式碼:
--- plugingallery.class.php.orig 2007-04-05 09:37:58.971689103 +0800
+++ plugingallery.class.php 2007-04-05 09:38:48.741881593 +0800
@@ -31,15 +31,23 @@
$this->id = "gallery";
$this->author = "Laurent Vauthrin";
$this->desc = "Integrates gallery into plog.";
- $this->version = "20070321";
+ $this->version = "20070405";
 
// Setup the locale
$this->locales = Array( "en_UK" );
 
if ($source == "admin")
$this->initAdmin();
+ else
+ $this->init();
}
 
+ function init()
+ {
+ // Register the actions
+ $this->registerBlogAction( "gallery", "PluginGalleryShowAction" );
+ }
+
function initAdmin()
{
// Register the actions
經過修正之後, 果然可以正常運作了.

這個 patch 也送到官方的網站了: http://bugs.lifetype.net/view.php?id=1263   
19  開發 / 外掛程式 / Re: 讓 TinyMCE 也能有 Syntax Highlight 功能 於: 四月 04, 2007, 11:24:38 下午
查了一下, 是因為 TinyMCE 造成的問題, 在 tiny_mce-plog.js 中, 把
程式碼:
cleanup_on_startup : false 
上頭這個 cleanup_on_startup 設成 false 就不會有這個問題了.
20  開發 / 外掛程式 / 讓 TinyMCE 也能有 Syntax Highlight 功能 於: 四月 04, 2007, 11:02:57 下午
轉自: http://blog.teatime.com.tw/1/post/222

前不久就打算在 LifeType 中加上 Syntax Highlight 的功能, 也找了 dp.SyntaxHighlighter 回來研究了一下, 不過一直試不出來, 而且... 這個程式是用 Javascript 處理的, 在 LifeType 的 TinyMCE 中, 每次要使用, 必須要進到 html 模式, 自己修改程式碼之後, 才能顯示出來. 所以當初試了一下就放棄了.

今天又找了一下類似的軟體, 發現在 TinyMCE 中, 有個 3rd party 的 plugin: insertcode, 搭配 GeSHi, 可以做出類似的效果. 下載回來, 發現這個應該是配合 TinyMCE 2.0.1 或之前的版本使用, 在後續的版本需要做一些修改才能使用. 該討論串中, 也有人貼了一段程式碼, 應該是修改過後的版本, 不過, 我試了一下, 發現如果速度很快 (code 的內容不多的話), 可以正確的把產生的程式碼, 再放回 TinyMCE 中, 不過... 如果連線速度不快, code 很多的話, 通常就會無法把程式的內容再傳回給 TinyMCE 中.

查看了一下程式碼, 發現是利用 Ajax 的功能, 把程式碼傳回到伺服器去利用 GeSHi 來產生 Syntax Highlight 的效果, 然後再傳回到 client, 等收到之後, 再傳回給 TinyMCE. 利用 firebug 追了一下, 看起來在伺服器端並沒有問題, 可以正確的產生資料. 可是 client 端的 Javascript 就是無法取得資料. 因於原本程式的寫法, 執行 Ajax 與接收的地方, 都使用相同的函式來處理, 且程式在呼叫後, 並沒有判斷是否收到資料, 就繼續後頭的動作, 所以傳輸過程一慢, 就會有問題.

動手改了一下程式碼, 也順便把原本做的 "行號" 的功能移除 (因為我不喜歡有這個, 在複製時, 就不會是真的程式內容, 比較麻煩). 整個程式可以由這個地方抓取: http://www.teatime.com.tw/~tommy/files/lifetype/tinymce_insertcode.tgz

下載後, 在 TinyMCE 的 plugins 目錄中解開, 然後修改 insertcode/config/config.php 中的 IC_GESHI_PATH 的設定, 指到你的 GeSHi 的安裝目錄. 然後在 tiny_mce-plog.js 中, 在 plugins 與 theme_advanced_buttons2 中加上 insertcode 之後, 就可以使用這個功能了.

另外, 還需要修改 TinyMCE 的 themes/advanced/css/editor_content.css 的內容與你所使用的樣板的 style.css 的內容, 加上下面的 css 設定:
程式碼:
/* twu2 begin, code attribute */
pre {
border-style: outset;
border-width: thin;
overflow: auto;
font-family: Courier New,Courier,mono;
background-color: #ccffff;
width: 98%;
padding: 1px;
margin: 1px auto 1px auto;
max-height: 100em;
line-height: normal;
}
/* twu2 end, code attribute */
/* twu2 begin insert code */
pre .de1, pre .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;color: #000020;}
pre .imp {font-weight: bold; color: red;}
pre .kw1 {color: blue;}
pre .kw2 {color: #000000; font-weight: bold;}
pre .kw3 {color: #000066;}
pre .kw4 {color: #f63333;}
pre .co1, pre .co2, pre .coMULTI {color: #808080; font-style: italic;}
pre .es0 {color: #000099; font-weight: bold;}
pre .br0 {color: #66cc66;}
pre .st0 {color: #ff0000;}
pre .nu0 { color: #cc66cc; }
pre .me1 {color: #006600;}
pre .me2 {color: #006600;}
pre .re0 {color: #0000ff;}
pre .head {font-family: Verdana, Arial, sans-serif;color: #333333;font-weight: bold;background-color: #f0f0ff;border-bottom: 1px solid #d0d0d0;padding: 2px;font-size: 12px;}
pre li {font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;font: normal normal 95% 'Courier New', Courier, monospace; color: #003030;}
pre li.li2 {font-weight: bold;font-weight: bold; color: #006060;}
pre .foot {display: none;}
pre a:link {color: #000060;}
pre a:hover {background-color: #f0f000;}
/* twu2 end intercode */

這樣子就可以做到與我這邊相同的效果了. 當然... 如果顏色不喜歡, 請自行修改吧.

PS. 剛剛發現, 重新編輯文章時, 由 LifeType 再回傳過來的 HTML 中, 把那些 span 的 class 都移除了. 等等再找看看是 LifeType 還是 TinyMCE 造成的.
21  支援 / 使用與操作 / Re: 发表的文章中不能输入“\”,各个版本都有的问题 於: 三月 26, 2007, 01:44:12 下午
把 php 的 magic_quotes_gpc 關閉.
在 .htaccess 中加上
php_flag magic_quotes_gpc off
試看看.

我在 1.0.3 修正這個問題後, 就沒有碰過不能輸入 \ 的情形了.

另外 LiftType 的 xhtml_converter_enabled 這個設定最好設為 "否".
22  開發 / 核心補強 / 修正 LifeType 1.2 在編輯文章時無法正確處理 & 字元的問題 於: 三月 25, 2007, 08:02:18 下午
今天在修改文章時, 突然發現原本文章內的一些 html code 的內容, 在進入 TinyMCE 時, 就真的變成 html 的一部份, 而不是原本的原始碼內容. 原本以為是 TinyMCE 的問題, 特地換成 1.1.6 時使用的版本, 結果一樣. 所以特地再裝了一份 LifeType 1.1.6 版來測試, 發現在舊的版本是正常的, 而新的版本是不正常的. 看來是在 1.2 的處理上頭有了問題.

接著把 TinyMCE 的功能關閉, 使用內建的 html 編輯器, 然後比對了一下在 1.1.6 與 1.2 之間, 所產生的 html code 的差異, 果然發現在 1.2 之前的版本, 會把文章內容的 & 轉成 &amp; 然後再送出, 而 1.2 版並沒有這樣子處理, 所以後來的 TinyMCE 就直接把 &lt; 之類的碼, 直接轉成 < 之類的字元, 接著... 存回去時, 資料當然就與原本的內容有所不同了.

這個 patch 可以修正這個問題:
程式碼:
--- lifetype-1.2/class/view/admin/admineditpostview.class.php	2007-03-20 20:40:22.000000000 +0800
+++ blog/class/view/admin/admineditpostview.class.php 2007-03-25 20:21:39.027573368 +0800
@@ -50,7 +50,7 @@
             
              // set information about the post itself into the view
              $this->setValue( "postTopic", $this->_article->getTopic());
-                $this->setValue( "postText", $this->_article->getText( false ));
+                $this->setValue( "postText", str_replace('&', '&amp;', $this->_article->getText( false )));
              $this->setValue( "postSlug", $this->_article->getPostSlug());
              $this->setValue( "postId", $this->_article->getId());
              if( $this->_article->getCommentsEnabled())

patch 可以由這兒抓取: http://www.teatime.com.tw/~tommy/mypatch/lifetype_1.2_edit_and_problem.patch 

經過這樣子的修正之後, 目前看起來運作是正常的了.

本文同步發表於 http://blog.teatime.com.tw/1/post/215
修正也送到 mantis: http://bugs.lifetype.net/view.php?id=1235
23  開發 / 外掛程式 / AuthImage (中文數字), BlogLook, Gallery, Google Adsense for LifeType 1.2 於: 三月 21, 2007, 10:58:45 上午
修改部份我寫的或我改的外掛, 使用於 LifeType 1.2 中.

AuthImage 中文數字: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_1.2_authimage_chinese.tgz
BlogLook: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_1.2_bloglook.tgz
Gallery: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_1.2_gallery.tgz
Google Adsense: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_1.2_googleadsense.tgz
24  開發 / 外掛程式 / Re: Google AdSense plugin for LifeType 於: 三月 19, 2007, 12:46:05 下午
你說的用法, 應該有違 google 的規定吧?
25  開發 / 外掛程式 / Re: 讓 authimage 顯示中文的數字 於: 三月 14, 2007, 02:10:56 下午
加上動態使用背景圖案並把顯示的文字做些旋轉.

修改 pluginauthimage.class.php 裡頭的 showImage() 改成下頭的內容:
程式碼:
        function showImage() {
            // Delete those cached authimage files that never used
            $this->deleteExpiredAuthImage($this->expiredTime);

            $code = $this->generateCode();
            $encrypt = $this->encrypt($code, $this->key);
            $background = AUTHIMAGE_BACKGROUND_FOLDER.$this->default;
            if ($this->default == 'random.gif') {
                $files = glob(AUTHIMAGE_BACKGROUND_FOLDER.'*.gif');
                $cnt = count($files);
                $choose = rand(0, $cnt-1);
                $background = $files[$choose];
            }
            $tempFile = $this->cacheFolder."/".$encrypt.".gif";

            if (function_exists('ImageRotate'))
                $size = 36;
            else
                $size = 24;
            $len = strlen($code);
            $image = ImageCreate($size * $len, $size);
            $im_bg = ImageCreateFromGIF($background);
            if ($im_bg) {
                list($bg_width, $bg_height, $bg_type, $bg_attr) = @GetImageSize($background);
                if (function_exists('ImageCopyReSampled'))
                    ImageCopyReSampled($image, $im_bg, 0, 0, 0, 0, $size * $len, $size, $bg_width, $bg_height);
                else
                    ImageCopyReSized($image, $im_bg, 0, 0, 0, 0, $size * $len, $size, $bg_width, $bg_height);
                ImageDestroy($im_bg);
            }
            for ($i = 0; $i < $len; $i++)  {
                $im_num = @ImageCreateFromPNG(AUTHIMAGE_IMAGE_FOLDER.$code[$i].'.png');
                if (function_exists('ImageRotate')) {
                    $im_rotate = ImageRotate($im_num, rand(-45, 45), 0);
                    ImageDestroy($im_num);
                    $im_num = ImageCreate($size, $size);
                    if (function_exists('ImageCopyReSampled'))
                        ImageCopyReSampled($im_num, $im_rotate, 0, 0, 0, 0, $size, $size, imagesx($im_rotate), imagesy($im_rotate));
                    else
                        ImageCopyReSized($im_num, $im_rotate, 0, 0, 0, 0, $size, $size, imagesx($im_rotate), imagesy($im_rotate));
                    ImageDestroy($im_rotate);
                }
                if ($im_num) {
                    ImageColorTransparent($im_num, ImageColorAt($image,0, 0));
                    ImageCopy($image, $im_num, $size * $i, 0, 0, 0, $size, $size);
                    ImageDestroy($im_num);
                }
            }

            ImagePNG($image, $tempFile);

            ImageDestroy($image);

            $temp = fopen($tempFile,"rb");
            $buffer = fread($temp,filesize($tempFile));
            fclose($temp);

            // Now zero-length the file. No need for its content anymore.
            $temp = fopen($tempFile,"w");
            fwrite($temp, NULL);
            fclose($temp);

            // Now chmod it so it can be deleted later by the user
            chmod($tempFile, 0666);

            header("Content-type: image/png");
            echo $buffer;
        }


然後把 backgrounds 下頭的 transparent.gif 複製為 random.gif. 這樣子的話, 如果你在 LifeType 的設定裡頭, 選擇用 random.gif 的話, 每次會隨機決定要使用的背景圖案.
26  開發 / 外掛程式 / Re: 讓 authimage 顯示中文的數字 於: 三月 11, 2007, 03:17:23 下午
我有看到那篇, 不過, 我也是用 debian/etch, 並沒有自己重編 php, 都使用內建的模組, 並沒有與你一樣的問題.
27  開發 / 外掛程式 / Re: 讓 authimage 顯示中文的數字 於: 三月 11, 2007, 10:58:35 上午
那個顯示的是漢字, 但是輸入的要是阿拉伯數字才可以.
我的考慮是, 輸入漢字的數字, 對使用者來說, 比較不友善, 要打比較多的字. 而輸入阿拉伯數字就很容易了.

如果你需要使用者也輸入漢字的數字的話, 請自己修改程式的內容, 把檢查碼記算的部份也改成用漢字才可以.
28  開發 / 外掛程式 / Re: Google AdSense plugin for LifeType 於: 三月 07, 2007, 08:25:28 下午
v0.2:
讓 google_ad_width, google_ad_height, google_ad_format 等變數也改成可以由使用者自行設定.
檔案放在: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_googleadsense_plugin_0.2.tgz
或者抓最後的版本: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_googleadsense_plugin.tgz
如果要抓舊的版本: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_googleadsense_plugin_0.1.tgz
29  開發 / 外掛程式 / Google AdSense plugin for LifeType 於: 三月 07, 2007, 01:15:31 下午
前兩天申請了 Google AdSense 的帳號, 發現 LifeType 本身, 並沒有外掛程式提供這個服務, 只能自己在 template 中加入自己的程式碼. 不過, 對於一個多人使用的 blog 程式來說, 如果每個人都要去改 template, 似乎不太正確. 所以就寫了這個外掛程式來使用.

外掛針對 Google AdSense 的內容, 也提供了 Content, Suggestion 與 Search 這三個項目的設定, 可以獨立的啟用或停用.

檔案放於: http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_googleadsense_plugin.tgz 

下載之後, 在 LifeType 的 plugins 目錄中解開, 然後到管理中心把這個外掛加入並啟用, 當然別忘了填入你的相關資料. 接著修改你的 template, 在你想加入的地方, 放入相關的 template 就可以了.

程式碼授權方式以 GPL 釋出.
30  開發 / 外掛程式 / 讓 authimage 顯示中文的數字 於: 三月 01, 2007, 02:08:08 下午
之前雖然把 AuthImage 改成用 Better Captcha 的圖型來顯示, 效果不錯, 不過... Better Captcha 的圖有時仍會不太容易看的懂. 所以就想了另一種方式, 把這個改用中文字來顯示, 對於看不懂中文的外國 bot 來說, 應該就有足夠的效果. 當然... 對人來說, 如果看的懂中文, 也應該是很容易就可以看出結果來.

首先, 為了方便使用, 我們先用下頭的程式產生 0-9 的圖檔:
程式碼:
<?php

$aData
[0] = "零";
$aData[1] = "一";
$aData[2] = "二";
$aData[3] = "三";
$aData[4] = "四";
$aData[5] = "五";
$aData[6] = "六";
$aData[7] = "七";
$aData[8] = "八";
$aData[9] = "九";

$font "/usr/share/fonts/truetype/msjhbd.ttf";

foreach (
$aData as $num => $str) {
    
$im ImageCreate(2424);
    
$background ImageColorAllocate($im255255255);
    
$fontcolor ImageColorAllocate($im000);
    
ImageTTFText($im160221$fontcolor$font$str);
    
ImagePNG($im$num.'.png');
    
ImageDestroy($im);
}

?>
如果你要使用別的字型, 把 font 改成你喜歡的字型檔就可以. 把產生的 png 檔案, 在 authimage 的路徑下建立一個 image 的子目錄, 把檔案放到裡頭.

然後把原本的 pluginauthimage.class.php 裡頭的 showImage() 改成下頭的內容:
程式碼:
        function showImage() {
            // Delete those cached authimage files that never used
            $this->deleteExpiredAuthImage($this->expiredTime);

define( "AUTHIMAGE_IMAGE_FOLDER", PLOG_CLASS_PATH."plugins/authimage/image/" );

            $code = $this->generateCode();
            $encrypt = $this->encrypt($code, $this->key);
            $background = AUTHIMAGE_BACKGROUND_FOLDER.$this->default;
            $tempFile = $this->cacheFolder."/".$encrypt.".gif";

            $len = strlen($code);
            $image = ImageCreate(24 * $len, 24);
            $im_bg = ImageCreateFromGIF($background);
            if ($im_bg) {
                list($bg_width, $bg_height, $bg_type, $bg_attr) = @GetImageSize($background);
                if (function_exists('ImageCopyReSampled'))
                    ImageCopyReSampled($image, $im_bg, 0, 0, 0, 0, 24 * $len, 24, $bg_width, $bg_height);
                else
                    ImageCopyReSized($image, $im_bg, 0, 0, 0, 0, 24 * $len, 24, $bg_width, $bg_height);
                ImageDestroy($im_bg);

            }
            for ($i = 0; $i < $len; $i++)  {
                $im_num = @ImageCreateFromPNG(AUTHIMAGE_IMAGE_FOLDER.$code[$i].'.png');
                if ($im_num) {
                    ImageColorTransparent($im_num, ImageColorAt($im_num, 0, 0));
                    ImageCopy($image, $im_num, 24 * $i, 0, 0, 0, 24, 24);
                    ImageDestroy($im_num);
                }
            }

            ImagePNG($image, $tempFile);

            ImageDestroy($image);

            $temp = fopen($tempFile,"rb");
            $buffer = fread($temp,filesize($tempFile));
            fclose($temp);
            // Now zero-length the file. No need for its content anymore.
            $temp = fopen($tempFile,"w");
            fwrite($temp, NULL);
            fclose($temp);

            // Now chmod it so it can be deleted later by the user
            chmod($tempFile, 0666);

            header("Content-type: image/png");
            echo $buffer;
        }
這樣子就可以顯示中文數字的圖型了.

如果不知如何產生圖檔或修改程式, 可以抓這個檔案 http://www.teatime.com.tw/~tommy/files/lifetype/lifetype_authimage_chinese.tgz 回去, 在 authimage 的目錄解開來, 覆蓋原有的檔案就可以了.
頁: 1 [2] 3 4 5