設定 .htaccess 讓 網址比較短

CodeIgniter – Open source PHP web application framework

設定 .htaccess 讓 網址比較短

codeigniter 網頁提到
http://codeigniter.com/user_guide/general/urls.html

可以把www.your-site.com/index.php/news/article/my_article
變成
www.your-site.com/news/article/my_article

步驟:
改 apache 的 virtual host file
Options FollowSymLinks
在 /xxx/username/ci/ 下建 .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /rimmon/ci/index.php/$1 [L]
</IfModule>

check email 存不存在

if ($_SERVER[argc]<2) {
  printf("Usage : %s filename\n",$_SERVER['argv'][0]);
  exit;
}

$filename=strftime("%H%M.txt");
$out=fopen($filename,"a");

$counter=0;
$fp=fopen($_SERVER['argv'][1],"r");
while ($data=fgets($fp,2000)) {
  $data=str_replace("\r","",$data);
  $data=str_replace("\n","",$data);
  if (checkmail($data)==TRUE) {
    printf("%s : %s \tGOOD_EMAIL!\n",$counter,$data);
    fputs($out,$data."\n");
  } else printf("%s : %s \tBAD_EMAIL!\n",$counter,$data);
  $counter++;
}
fclose($fp);
fclose($out);
exit;

// -------

function checkmail($mail){
  $host = explode('@',$mail);
  list($account,$host) = $host;

  if (!getmxrr($host,$mxa)) $mxa = array($host);
  while (list ($key, $mx) = each($mxa)) {
    if ($mxg = @fsockopen ($mx,25,$ir,$sr,5)) {
      $out = fgets($mxg, 1024);
      if (substr($out,0,3) == "220") {
        fputs ($mxg, "HELO example.com\r\n");

        $out = fgets ( $mxg, 1024 );
        fputs ($mxg, "MAIL FROM: <{$mail}>\r\n");
        $from = fgets ( $mxg, 1024 );
        fputs ($mxg, "RCPT TO: <{$mail}>\r\n");
        $to = fgets ($mxg, 1024);
        fputs ($mxg, "QUIT\r\n");
        fclose($mxg);
        if (ereg ("^250", $from) && ereg ( "^250", $to )) return TRUE;
        return FALSE;
      }
      return FALSE;
    }
    return FALSE;
  }
  return FALSE;
}

用 apache 的 setenv module 在程式中加入判斷 developer 是誰

<VirtualHost 172.30.0.35:80>
        ServerName rimmon.goods.dev.xxx.com.tw
        ServerAdmin webmsater@staff.xxx.com.tw
        DocumentRoot /home/rimmon/bid/goods/www
        SetEnv DEVELOPER rimmon
        alias /js/ /home/rimmon/bid/www/www/js/
        alias /css/ /home/rimmon/bid/www/www/css/
        <Directory “/home/rimmon/bid/goods/www”>
          Options  FollowSymLinks
          AllowOverride None
          Allow from all
        </Directory>
</VirtualHost>

[sparc] solve gentoo blocking problem

emerge -pv
……
[ebuild     U ] app-shells/bash-3.2_p33 [3.1_p17] USE=”nls -afs -bashlogger
-plugins% -vanilla” 2,564 kB
[blocks B     ] <sys-apps/portage-2.1.4_rc1 (is blocking
app-shells/bash-3.2_p33)
[blocks B     ] sys-apps/mktemp (is blocking sys-apps/coreutils-6.10-r2)
[blocks B     ] >=sys-apps/coreutils-6.10 (is blocking sys-apps/mktemp-1.5)
emerge -1 =bash-3.2_p17*
emerge -1 portage
emerge -1 bash
emerge -C mktemp
emerge -C sys-apps/util-linux
emerge –oneshot coreutils

emerge -1 sys-apps/util-linux

ncurses sample

A Simple scanw example

compile:

gcc sample.c -lncurses

[code language=’c’]
#include /* ncurses.h includes stdio.h */
#include

int main()
{
char mesg[]=”Enter a string: “; /* message to be appeared on the screen */
char str[80];
int row,col; /* to store the number of rows and *
* the number of colums of the screen */
initscr(); /* start the curses mode */
getmaxyx(stdscr,row,col); /* get the number of rows and columns */
mvprintw(row/2,(col-strlen(mesg))/2,”%s”,mesg);
/* print the message at the center of the screen */
getstr(str);
mvprintw(LINES – 2, 0, “You Entered: %s”, str);
getch();
endwin();

return 0;
}
[/code]