9.10登入以及開機畫面[xsplash]篇

翻完以上的文章之後,老實說那些有些部份只適用9.04以前的,今天就研究了一下要如何修改,9.10的那些介面,因為9.10跟以往不大一樣的地方就是他們的gdm版本是比較新的(廢話),因為這個原因他們的登入以及Splash佈景待改笧用新版,而比較特別的就是Splash改用了xSplash。

修改登入畫面:

Read More ...
Fri Nov. 6 2009
Comments

moebuntu中文教學文件(開機畫面[splash]篇)

本文翻譯從http://moebuntu.web.fc2.com/moesplash.html 並符合正體中文語系的使用者介面之翻譯

注意:以下之方法只是用於9.04(含)以前的版本,於最新版的9.10不適用(譯者親身經歷)

準備工作:

  • StartUp-Manager(用於修改Splash的工具)
  • moebuntu Splash佈景

Read More ...
Thu Nov. 5 2009
Comments

moebuntu中文教學文件(介面篇)

本文翻譯從http://moebuntu.web.fc2.com/index.html 並符合正體中文語系的使用者介面之翻譯

moe_s_f_800 老實說看到這這東西雖然被了kagami萌了一下,但是我覺得粉紅色好噁心...Orz,但是這份文件太好了排除"萌"的要素之外根本就是給新手簡單的而且明瞭的介面轉換。廢話不多說:

Read More ...
Thu Nov. 5 2009
Comments

moebuntu中文教學文件(登入篇)

本文翻譯從http://moebuntu.web.fc2.com/moelogin.html 並符合正體中文語系的使用者介面之翻譯

注意:以下之方法只是用於9.04(含)以前的版本,於最新版的9.10不適用(譯者親身經歷)

方法如下:

Read More ...
Thu Nov. 5 2009
Comments

Google AJAX Libraries API

其實今天就是在google AJAX看到的鬼東西,而且是一個非常有趣的鬼東西,依照我淺薄的接觸以為javascript Libraries只有jQuery,竟然沒想到還有這麼多的種類,

網站:http://code.google.com/intl/en/apis/ajaxlibs/

其實這讓開發者真的可以非常的方便來使用一些javascript的Libraries,如果要使用jQuery的話只要

1
2
3
4
5
6
<script src="http://www.google.com/jsapi"></script> <!--先include google js api-->
<script> 
google.load("jquery", "1.3.2");
google.load("jqueryui", "1.7.2");
<!-- your js code -->
</script>

真是方便的東西...XDrz

Wed Oct. 28 2009
Comments

PHP產生bbs的rss(for server端)

這是一個利用php產生rss的script,就只是普通的實做...XDDrz

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include('uaocode.php');

$bbs_path='/home/bbs/brd/';
$brd_name=$_GET['brd'];
$filename=$bbs_path.$brd_name.'/.DIR';
if (!file_exists($filename)) {
    echo 'no such broad!';
    exit;
}

header('Content-type: application/rss+xml; charset=utf-8');
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";

$all_post=filesize($filename)/256;

$post_num=10;

for($i=1; $i <= $post_num ; ++$i){
    $fp=fopen($filename,'r');
    fseek($fp, ($all_post-$i)*256+12);
    $match[$i]['post_id']=trim(fread($fp,32));
    $post_path=$bbs_path.$brd_name.'/'.substr($match[$i]['post_id'], -1).'/'.$match[$i]['post_id'];
    $fpp=fopen($post_path,'r');
    $j=0;
    while($current_line = fgets($fpp)){
        ++$j;
        switch ($j){
            case 1:
                preg_match('/: (.*) \(/',$current_line,$match[$i]['post_userid']);
            case 2:
                $match[$i]['post_title']=trim(html_entity_decode(iconv("big5","UTF-8",uao_convert(substr($current_line,6))),ENT_QUOTES,"UTF-8"));
            case 3:
                $match[$i]['post_time']=date(DATE_RSS, strtotime(trim(substr($current_line,6))));
            default;
                $current_line=preg_replace('/\\x1b\\[([^m]*)m/i','',$current_line);
                $match[$i]['post_conten'] .= trim(html_entity_decode(iconv("big5","UTF-8",uao_convert($current_line)),ENT_QUOTES,"UTF-8"),'\0');
        }
    }
}
?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    >
    <channel>
    <title>夢之大地rsstest</title>
    <description>none</description>
    <link>http://140.116.250.9/</link>
    <atom:link href="http://140.116.250.9/paser.php" rel="self" type="application/rss+xml" />
    <language>en</language>
    <generator>http://www.renn999.twbbs.org/illustrator/RSS.php</generator>
<?php 
        foreach($match as $item){
            echo "<item>\n";
            echo "\t\t\t<title><![CDATA[".stripslashes($item["post_title"])."]]]]><![CDATA[></title>\n";
            echo "\t\t\t<pubDate>".stripslashes($item["post_time"])."</pubDate>\n";
            echo "\t\t\t<link>http://140.116.250.9/</link>\n";
            //str_replace(' ','&nbsp;',nl2br(htmlspecialchars($item["post_conten"])));
            echo "\t\t\t<description><![CDATA[".nl2br(str_replace(' ','&nbsp;',htmlspecialchars($item["post_conten"])))."]]]]><![CDATA[></description>\n";
            echo "\t\t\t<guid isPermaLink=\"false\">",$item['post_id'],"</guid>";
            echo "</item>\n";
        }
    ?>
    </channel>
</rss>
Wed Oct. 14 2009
Comments

Apache修改執行user和Group和修改phpmyadmin預設網址

在Linux底下因為權限讀取的關係,要修改預設的apache user和group現在是很快又很簡單,因為最近正在實做一些BBS相關的小型PHP程式,第一個遇到的課題XDrz。如果進去BBS的資料夾裡面去看的話應改只會看到這樣

1
2
3
4
5
6
7
[bbs@localhost 3]$ ls -lt
total 20
-rw---- 2 bbs bbs 341 2009-09-01 12:53 A159PA63
-rw---- 1 bbs bbs 751 2009-05-02 00:20 A14VM573
-rw---- 1 bbs bbs 719 2009-04-27 12:06 A14VAAL3
-rw---- 1 bbs bbs 526 2009-02-09 12:10 A14OVB03
-rw---- 1 bbs bbs 255 2007-10-12 22:41 A13GV1S3

所以說必須要讓apache改變user和grup其實非常簡單只要修改/etc/apache2/envvars裡面的APACHE_RUN_USER及APACHE_RUN_GROUP為你要的user及group,並restart apache即可。

修改phpmyadmin的預設路徑,剛灌好的phpphpmyadmin預設路徑為 http://你的網址/phpmyadmin 以前的作法是在/var/www下面將phpmyadmin的Link修改名稱即可,現在就已經不一樣了,現在已經把設定檔寫在/etc/apache2/conf.d/phpmyadmin.conf,找到

1
Alias /phpmyadmin(修改這裡) /usr/share/phpmyadmin

修改完並restart apache即可。

Mon Oct. 12 2009
Comments

Perl版將UTF-8 -> big5 UAO

這是我第一個將PHP轉Perl的程式,也算是學一點Perl,Perl真是一個博大驚深的語言啊,老實說起來。某些方面比php簡單很多也直覺很多...XDrz

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl -w
#
# This perl script is using GNU General Public License v2.0
# renn999<AT>ccns.ncku.edu.tw
# http://renn999.twbbs.org
#
# USAGE:ucs2big5( $str );
#
# Big5 table(big5.txt)
# using from Ztrem
# http://zhouer.org/ZTerm/


print &ucs2big5('測試 試験 しけん');

sub ucs2big5 {
    my $ucs_str=shift;
    open FILE, "big5.txt";
    #binmode FILE; 
    my $len = length $ucs_str;
    my ($b1,$b2,$b3,$big5_code,$ucs_code,$big5_str);

    for( my $i = 0 ; $i < $len ; $i++ ) {
        $b1 = ord(substr $ucs_str, $i, 1);
        if( $b1 < 0x80 ) {
            $big5_str .= chr($b1);
        }
        elsif( $b1 >= 224 ) {
            #3code UTF-8
            $b1 -= 224;
            $b2 = ord(substr $ucs_str, ++$i, 1) - 128;
            $b3 = ord(substr $ucs_str, ++$i, 1) - 256;
            $ucs_code = $b1 * 4096 + $b2 * 64 + $b3;
            seek( FILE, $ucs_code * 2 , 0);
            read FILE, $big5_code, 2;
            $big5_str .= $big5_code;
        }
        elsif( $b1 >= 192 ) {
            #2code UTF-8
            $b1 -= 192;
            $b2 = ord(substr $ucs_str, ++$i, 1) - 256;
            $ucs_code = $b1 * 64 + $b2 ;
            seek( FILE, $ucs_code * 2 , 0 );
            read FILE, $big5_code, 2;
            $big5_str .= $big5_code;
        }else{
            $big5_str .= '?';
        }
    }

    if(length $big5_str != 0) {
        $big5_str;
    }
}

用pietty等UAO支援的程式應該可以看得出結果

Mon Oct. 12 2009
Comments

利用php將UTF-8 -> big5 UAO沒有PATCH iconv

最近因為嘗試要轉換一些HTML->BBS的文章會發生的問題,所以說就寫了一個這樣的程式,因為我完全不想要動到iconv的PATCH,所以說就先利用ZTerm src中的BIG5表格下去做轉換,結果還不錯。

(修正了幾個bug 091006 21:00)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*  
 *  This php is using GNU General Public License v2.0
 *  renn999<AT>ccns.ncku.edu.tw
 *  http://renn999.twbbs.org
 *
 *  USAGE:ucs2big5( $str );
 *  
 *  Big5 table(big5.txt)
 *  using from Ztrem
 *  http://zhouer.org/ZTerm/
 */

function ucs2big5($ucs_str) {
    $fp = fopen( 'big5.txt', 'r' );
    $len = strlen($ucs_str);
    unset($big5_str);

    $x = 0;
    for( $i = 0 ; $i < $len ; $i++ ) {
        $b1 = ord($ucs_str[$i]);
        if( $b1 < 0x80 ) {
            $big5_str[$x++] = chr($b1);
        }
        elseif( $b1 >= 224 ) {
            #3code UTF-8
            $b1 -= 224;
            $b2 = ord($ucs_str[++$i]) - 128;
            $b3 = ord($ucs_str[++$i]) - 256;
            $ucs_code = $b1 * 4096 + $b2 * 64 + $b3;
            fseek( $fp, $ucs_code * 2);
            $big5_code = fread( $fp, 2 );
            $big5_str[$x++] = $big5_code[0];
            $big5_str[$x++] = $big5_code[1];
        }
        elseif( $b1 >= 192 ) {
            #2code UTF-8
            $b1 -= 192;
            $b2 = ord($ucs_str[++$i]) - 256;
            $ucs_code = $b1 * 64 + $b2 ;
            fseek( $fp, $ucs_code * 2 );
            $big5_code = fread( $fp, 2 );
            $big5_str[$x++] = $big5_code[0];
            $big5_str[$x++] = $big5_code[1];
        }else{
            $big5_str[$x++] = '?';
        }
    }

    fclose($fp);
    if(isset($big5_str)) {
        return join( '', $big5_str);
    }
}
?>

至於BIG5.txt可以到http://zterm.googlecode.com/svn/trunk/org/zhouer/utils/conv/中去下載 這裡就不附上了

Tue Oct. 6 2009
Comments

PHP備份Pixiv的bookmark(お気に入りユーザー)修正版

基本上之前的程式一定不能用了,但是phpQuery在備份的時候都會吐出亂碼來,可能是內部的編碼偵測出了問題。

所以基本上我就用了simple html dom但是這個有一個缺點,就是需要比較多的記憶體空間。 (這是Memory Leaks的問題已經解決)

以下為修改完的程式碼。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
    require 'simplehtmldom/simple_html_dom.php';

    $loginurl='http://www.pixiv.net/index.php';
    $pixiv_id='';
    $password='';

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.5); InfoPath.2)');
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_COOKIESESSION,true);
    curl_setopt($curl, CURLOPT_URL, $loginurl);
    curl_setopt($curl, CURLOPT_POSTFIELDS, 'mode=login&pixiv_id='.$pixiv_id.'&pass='.$password );
    curl_exec($curl);

    $p=1;
    $bookmark_rest='show';//show
    do{
        $url='http://www.pixiv.net/bookmark.php?type=user&rest='.$bookmark_rest.'&p='.$p;
        curl_setopt($curl, CURLOPT_URL, $url);
        $profile=curl_exec($curl);
        $dom1 = new simple_html_dom();
        $dom1 = str_get_html($profile);

        $test=$dom1->find('div#content2 div[align="right"]',0)->plaintext;

        preg_match('/次の(.*?)件/',$test,$match);

        $title2 = $dom1->find('div#content2 form#f div[style="width:140px;height:130px;float:left;text-align:center;"]');

        foreach($title2 as $illsthtml){
        $illst = $illsthtml->outertext;
        $illst=preg_replace('/<div(.*?)"><input(.*?)><\/div>/','',$illst);
        $illst=preg_replace('/\n/', '',$illst);
        $illst=preg_replace('/<img(.*?)>/', '',$illst);
        preg_match_all('/<a href="member.php\?id=(.*?)"><\/a><div style=\"padding-top:5px;\">(.*?)<\/div>(<a href="jump.php\?(.*?)" target="_blank"><\/a>)?/', $illst,$match2,PREG_SET_ORDER);
            foreach ($match2 as $val) {
                echo 'http://www.pixiv.net/member.php?id='.$val[1].' - '.$val[2];
                if(!empty($val[4])){echo ' - '.$val[4];}
                echo "<br />\n";
            }
        }
        $dom1->__destruct();//解決Memory Leaks的問題
        unset($profile,$dom1,$test);
        $p++;
    }while(!empty($match));

    curl_close($curl);
?>
Wed Sep. 30 2009
Comments