2010年12月24日 星期五

[php] 利用 Discuz 去做學校消息和相片發佈

首先去http://www.discuz.net/ 下載你要的版本, 通常都會下最新
下載完,要把discuz 安裝在你linux server 或 其他可以運行php 的上面

安裝好之後 在管理中心去選好你要的內容和版面
這樣就已經完成50%


因為學校有自己版面,所以要在自己版面顯示出
新有消息等等
所以要寫一個頁面,再用ifame 內陷這個頁面
這就我完成圖

當然在新的消息,要做一個會閃動的new 會更加好看



2010年12月23日 星期四

[JAVA] 中位數

import java.util.Scanner;
public class midnum {
public static void main{
Scanner numa = new Scanner(System.in);
Scanner numb = new Scanner(System.in);
Scanner numc = new Scanner(System.in);

int a=numa.nextInt();
int b=numb.nextInt();
int c=numc.nextInt();

if (a=>b){
    if (a<=c)
        System.out.println(a + "為中位數");
    else{
        if (b>=c)
            System.out.println(b + "為中位數");
        else
            System.out.println(c + "為中位數");
      }
}
else{
    if (b<=c)
        System.out.println(b + "為中位數");
    else{
        if (a>=c)
            System.out.println(a + "為中位數");
        else
            System.out.println(c + "為中位數");
     }
}
}


如果用>= 和<=  三數可以相同
如果用> 和 < 三數不可以相同

2010年12月12日 星期日

2010年11月25日 星期四

[html] fame 背景透明方法



iframe.htm


<iframe src="SourcePage.htm" allowtransparency="true"></iframe>


▪ SourcePage.htm


加在<body …..之後。

<body style="background-color:transparent">

2010年11月5日 星期五

[BAT] 建立虛擬磁碟機和複製資料

@echo off
echo MC_BACKUP_BAT
net use i: \\smallnas\mcdocument /user:mcbackup 123456
xcopy D:\man i:\man /E /Y /R /I /H /D
net use i: /del /y
echo backup_complete
pause

2010年9月15日 星期三

[電腦小工具]FlexRena8.2 改名小工具

簡介 :
Flexible Renamer 是一款非常不錯的檔案及資料夾名稱修改工具,檔案小巧、免安裝、內建多國語言,支援 Unicode,並且可使用 Regexp 做名稱之搜尋及匹配,內建多項之命名規則,更可更改時間戳記…等特色。
軟體說明

如果需要大量地更改檔案或是資料夾名稱,透過專門的檔名修改軟體,可以節省我們許多的時間。例如 Flexible Renamer 就是大量修改名稱的專門軟體。
Flexible Renamer 是一個日本人所開發的檔名修改軟體,它擁有檔案小巧、支援 Unicode、支援 Regexp…等特色,內建多國語言,不用擔心看不懂英文或是日文。
我們除了可以利用一般的更名方式之外,若熟悉 Regexp,我們還可利用 Regexp 來為我們做檔名上的匹配修改,讓我們在使用上更加地靈活。
而且,它還具有即時預覽的功能,可以讓我們馬上得知新檔名是否符合我們心裡所想的。
將圖片放大將圖片放大

2010年6月11日 星期五

[postfix] - mailbox size limit and message size limit

postfix - mailbox size limit and message size limit

postfix is my MTA of choice. I use it for my mailserver because its simplicity , security and sendmail-compatible (the widely used smtp in the world but not as secure). It is also extensible by plugging other servers for various purposes (antispam, antivirus,database etc).

I had one problem with file attachment larger than 10MB. Users couldn't send it although I have setup squirrelmail (SM) to be able to attach files summed up more than 20MB and I had modified php settings as per here. The problem was not in SM setting. It was postfix. By default, attachment size that can be sent by postfix is 10MB ~ 10240000 byte. How did I know it? I looked in log file (for my system it is in /var/log/mail/errors. For other system, the file to look is /var/log/maillog). The line looked like this:

Feb 26 16:30:53 webmail postfix/sendmail[30775]: fatal: me@mymailserver.org(74): Message file too big

Solution
Open /etc/postfix/main.cf with a text editor of choice and find message_size_limit directive and change accordingly. If it is not there, add the directive like this:

message_size_limit = 20480000

This sets limit to 20MB.

Some other parameters you need to change are in file php.ini which is usually located in dir /etc. Set their parameters as above or higher values as below:
post_max_size = 20M
upload_max_filesize = 20M

reload or restart postfix when you're done: 


service postfix reload 

or 

service postfix restart

There's also mailbox_size_limit directive. You need to change this if SM can not open mailbox sized more than 10 MB.

reference :
http://www.tek-tips.com/viewthread.cfm?qid=1073614&page=1

2010年6月3日 星期四

[PHP] php 對使用者密碼的加密

$salt = substr($enteredPassword, 0, 2);
$userPswd = crypt($enteredPassword, $salt);   

2010年6月2日 星期三

[PHP] php連mySQL 資料庫

$host="localhost"; // Host name
$username="emmuser"; // Mysql username
$password="emmpass"; // Mysql password
$db_name="emmuser"; // Database name
$tbl_name="userID"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// To protect MySQL injection (more detail about MySQL injection)
$myusername = $login_username;
$mypassword = $secretkey;
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT IDnumber FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$row = mysql_fetch_array($result)
$login_username= $row['username'];
}