블로그 이미지
예진이와 고고씽!! 괴스트

카테고리

분류 전체보기 (385)
Yejin (247)
Life (44)
Dev (62)
Etc (28)
Total63,965
Today136
Yesterday177

달력

« » 2010.08
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        

태그목록

Tistory Cumulus Flash tag cloud by BLUEnLIVE requires Flash Player 9 or better.

크리에이티브 커먼즈 라이선스
Creative Commons License



Zend Lucene
- http://framework.zend.com/manual/en/zend.search.lucene.html

sphinxs
- http://www.sphinxsearch.com

Xapian
- http://xapian.org/

Solr
- http://lucene.apache.org/solr/



http://www.sphinxsearch.com/docs/current.html#conf-morphology


http://www.sphinxsearch.com/docs/current.html
http://www.sphinxsearch.com/wiki/doku.php?id=charset_tables
http://code.google.com/p/sphinxsearch/source/browse/
http://code.google.com/p/sphinxsearch/source/browse/branches/rel099/api/sphinxapi.php
http://code.google.com/p/sphinxsearch/source/browse/branches/rel099/api/test.php


1. 설치

정도는 알아서...-_-;
emerge app-misc/sphinx 하면 끝나는 환경에 있는 사람이 이 이상 자세하겐 무리~



2. sphinx.conf

다국어 검색을 위해 각각의 문자범위를 일일히 conf 에 적어줘야 한다.
게다가 한줄 길이 제한까지 있어서 정규식으로 대충 정리해 넣었다.
원본 테이블은
http://www.sphinxsearch.com/wiki/doku.php?id=charset_tables
요기 맨 앞의 txt 링크이다.
conf 파일은 첨부한다.



3. query

스핑크스는 인덱싱 할 데이터가 많을 경우를 위해 범위를 나눠 쿼리해 오는 것이 가능하고,
새 범위만 인덱싱을 한 후 기존 인덱스 정보에 병합하는 것이 가능하다.
본 예제는 새 범위 인덱싱 후 병합으로 설명한다.

스핑크스의 쿼리문은 맨 앞의 것이 반드시 고유번호(sequence) 여야 하며,
그 필드명이 무엇이 되었든 간에 스핑크스 내에서는 무조건 id 이다.


source main 중
    sql_query                = \
        SELECT seq, uid, author, subject, contents \
        FROM xenobb_sphinx_view \
        WHERE sphinx_indexed = TRUE

테이블에 sphinx_indexed 라는 필드를 추가했고, main 은 이미 인덱싱 된것만 쿼리하게 했다.

source delta : main 중
    sql_query                = \
        SELECT seq, uid, author, subject, contents \
        FROM xenobb_sphinx_view \
        WHERE sphinx_indexed = FALSE
    
    sql_query_post = UPDATE xenobb SET sphinx_indexed = TRUE WHERE sphinx_indexed = FALSE

인덱싱 되지 않은 것을 쿼리해 온 후 인덱싱 되었다고 표기해 준다.



4. indexer

conf 를 다 작성했으면 인덱스를 생성한다.
$ indexer main
$ indexer delta



5. crontab

searchd 가 대몬이라 알아서 계속 인덱싱 해 줄줄 알았는데 안되나보다.

#!/bin/bash
cd /home/xenoside/sphinx
if [ -f need_indexing ]; then
    rm need_indexing
    indexer delta --rotate
    indexer --merge main delta --rotate
    #if [[ "x`date +%H%M`" == "x0400" ]]; then
    #    indexer main --rotate
    #fi
fi

* * * * * (매분) 으로 걸어주자.

게시판에서 insert, update, delete 가 발생하면 /home/xenoside/sphinx/need_indexing 파일을 빈 파일로 생성해 주면 1분 내에 인덱싱 된다.

주석 부분은 찔끔찔끔 병합되는 main 인덱스가 혹 느려지면 새로 인덱싱 시키기 위한건데 전체가 재 인덱싱 되므로 굳이 자동으로 할 필요 없이 느려졌다 생각되면 한번 해 주면 된다.



6. searchd

/etc/init.d/searchd start
rc-update add searchd default
배포판 별로 알아서 시작 스크립트에 넣어주자~



7. php
http://code.google.com/p/sphinxsearch/source/browse/branches/rel099/api/sphinxapi.php
요거를 이용한다.
자세한 예제는
http://code.google.com/p/sphinxsearch/source/browse/branches/rel099/api/test.php
요기잉다.

아래는 랭킹이고 순서고 다 필요 없이 걍 검색해 오는 간단 예제이다.

if(isset($_GET['q'])) {
    $_GET['q'] = trim($_GET['q']);
    if($_GET['q'] != '') {
        require_once 'sphinxapi.php';
        $cl = new SphinxClient();
        $cl->SetServer('/var/run/searchd.sock', 5433);
        $cl->SetConnectTimeout(1);
        $cl->SetArrayResult(true);
        $cl->SetWeights(array(100, 1));
        $cl->SetMatchMode(SPH_MATCH_ALL);
        $cl->SetLimits(0, 100);
        $cl->SetRankingMode(SPH_RANK_NONE);
        if(false !== ($res = $cl->Query($_GET['q'], '*'))) {
            $seqs = array();
            foreach($res['matches'] as $row) {
                $seqs[] = $row['id'];
            }
            if(count($seqs) != 0) {
                $sel->wheres[] = 'bb.seq IN ('.implode(',', $seqs).')';
            }
        }
    }
}


매뉴얼 잘 보면 실제 쿼리문 처럼 순서 정하고 limit 해 오고 하는 것 다 된다.



Written by Song Hyo-Jin (shj at xenosi.de)
License : Creative Commons - Attribution (CC-BY)



출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=71173


저작자 표시
Posted by 예진이네집 괴스트
크리에이티브 커먼즈 라이선스
Creative Commons License





flash + xml + php + db 간의 상호작용과 관련 파일입니다.

테스트를 위해 flash + xml  연동관련 공개된 파일을 근거로 하였습니다.
==>> flash 소스의 출처가 생각나지 않는군요...  생각나면 적겠습니다.

------------------------- 전체원리설명 --------------
1.내용
- db + xml + php + flash 연동테스트

2. 파일설명
  ㄱ. xml_updata.php
     : db정보를 근거로 php에서 xml 파일을 신규 또는 기존 파일을 새로 갱신한다. (utf-8로 변환)

  ㄴ. gallery.xml
     : xml_updata.php에서 신규생성된파일

  ㄷ. gallery.swf
     : gallery.xml 정보를 불러와서 flash 구현.

3. 원리
  xml + flash 간의 연동파일을 근거로 php에서 xml 파일을 자동생성함.

4. 그누보드와 연결성
  ㄱ. 게시판에서 자료입력후 업데이트시 xml 갱신자료를 xml_updata.php 에 전달한다.

5. 활용
  - 상단 및 좌측 네비게이션(메뉴)
  - 최신갤러리스킨
  - 갤러리게시판스킨
  - 멀티적연동 템플릿
-----------------------------------------------------


--------------xml_updata.php-------------

<?php

######################환경변수#########################
$xml_dir  = "";  // 신규생성할 디렉토리 변수
$xml_path = "gallery.xml"; // 신규생성할 xml 파일
$laguage_ = "euc-kr";

#######################################################

 

//디렉토리가 존재하지 않는다면 신규생성한다
@mkdir($xml_dir, 0707);
@chmod($xml_dir, 0707);


// file open
//$xml_file = fopen($xml_path, "w+") or die("xml file open erro.");
$xml_file = fopen($xml_path, "w+");

//파일이 존재하지 않는다면 신규생성한다.
if(!$xml_file){
fwrite($xml_file, "");
fclose($xml_file);
@chmod($xml_path, 0707);
}

 

/**************************** xml data start**************************/
/**

<gallery title="Navdeeps Gallery" thumbDir="images/thumbs/" imageDir="images/" random="False">
 <category name="3차원포토사진">
  <image>
   <date>날짜입력하는곳</date>
   <title>사진제목출력1</title>
   <desc>사진간단설명</desc>
   <thumb>3d_01.jpg</thumb>
   <img>3d_01.jpg</img>
  </image>
  <image>
   <date>날짜입력하는곳1</date>
   <title>사진제목출력2</title>
   <desc>사진간단설명22</desc>
   <thumb>3d_02.jpg</thumb>
   <img>3d_02.jpg</img>
  </image>
 </category>
</gallery>

**/
$data[lauage]       = "<?xml version=\"1.0\"  encoding=\"{$laguage_}\" ?>"; 


$data[xml_start]    = "<gallery title=\"Navdeeps Gallery\" thumbDir=\"images/thumbs/\" imageDir=\"images/\" random=\"False\">";
$data[xml_end]      = "</gallery>";

$get_xml   = "";
//$get_xml  .= $data[lauage];
$get_xml  .= $data[xml_start];

 

$get_xml  .= "<category name=\"제목변환입니다1\">";

$count_num    = 7;
for($i=1;$i<$count_num;$i++){

$get_xml    .= "<image>";
$get_xml    .= "<date>날자변경".$i."</date>";
$get_xml    .= "<title>사진제목을 출력합니다".$i."</title>";
$get_xml    .= "<desc>사진설명에 대한 정의입니다.".$i."</desc>";
$get_xml    .= "<thumb>3d_0".$i.".jpg</thumb>";
$get_xml    .= "<img>3d_0".$i.".jpg</img>";
$get_xml    .= "</image>";

 

}
$get_xml  .= "</category>";


$get_xml      .= $data[xml_end];

/****************************xml data end**************************/

//변환
$get_xml = iconv("EUC-KR", "UTF-8",$get_xml);

// write action
if(!fwrite($xml_file, $get_xml)) echo "file wite erro.";

// file close
fclose($xml_file);

 

?>

------------------------------------------------


테스트

==>> 웹서버에 업로드후 접속

fla파일 : http://www.smashingmagazine.com/2007/10/12/flash-based-galleries-for-your-images/


출처: http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=14963

저작자 표시
Posted by 예진이네집 괴스트
크리에이티브 커먼즈 라이선스
Creative Commons License

제목 그대로 긴 문자열을 css로 자르는 것입니다.

(보통은 개발자가 글자수를 조절 하지만 css로 처리 할 수도 있습니다. ^^ )

 



  1. style="text-overflow:clip;overflow:hidden" 
    style="text-overflow:ellipsis;overflow:hidden" 
    style="text-overflow:ellipsis;overflow:visible"
  2. <div style="width:200; text-overflow:clip; overflow:hidden;">
        <nobr>제목이 긴 문자열로 이루어진 글을 테이블의 폭에 알맞게 잘라줍니다.</nobr>
    </div>
    <div style="width:200; text-overflow:ellipsis; overflow:hidden;">
        <nobr>제목이 긴 문자열로 이루어진 글을 테이블의 폭에 알맞게 잘라줍니다.</nobr>
    </div>
    <div style="width:200; text-overflow:ellipsis; overflow:visible;">
       <nobr>제목이 긴 문자열로 이루어진 글을 테이블의 폭에 알맞게 잘라줍니다.</nobr>
    </div>
  3. <table border=1>
      <tr style="padding-top:3">
        <td height=20 style="padding-left:5"><div style="overflow:hidden; text-overflow:ellipsis; width:180;"><nobr><a href="">제목이 긴 문자열로 이루어진 글을 테이블의 폭에 알맞게 잘라줍니다.</nobr></div></td>
        <td class=s>2006.12.26</td>
      </tr> 
    </table>

 

// 결과화면

제목이 긴 문자열로 이루어진 글을 테
제목이 긴 문자열로 이루어진 글을..
제목이 긴 문자열로 이루어진 글을 테이블의 폭에 알맞게 잘라줍니다.

// IE에서는 정상작동하고 파이어폭스에서는 ellipsis를 줘도 clip처럼 됩니다.

 

 관련스트일 3개를 class로 추가 해 놓고 필요한 부분에 css를 적용해 주는 방법을 쓰면 편할 듯 합니다. ^^


http://blog.naver.com/kchan12/70015808241

http://blog.empas.com/sm5679/18929127

위에 두 글을 참고 했으니 원본글을 보시려면 윗 링크를 보세요

저작자 표시
Posted by 예진이네집 괴스트
크리에이티브 커먼즈 라이선스
Creative Commons License



네트웍이 안되는 특수환경에서 프로젝트를 진행하다 복귀해 보니 최신정보에 상당히 둔감해졌다는 생각이 많이 든다.
그래서 꿈춰두었던 내용들을 살포시 꺼내본다.

Internet Explorer 8 출시 이후  이미 모든 포털에서 웹조각(Web Slice)기능들을  많이들 구현해 놓았는데
혹시나 모르시는 분들이 계실것 같아서 웹조각 만드는 방법에 대해서 공유한다.


최종 HTML소스
webSlice.rar


결과화면 : 로컬에서 해서 안되서 서버를 띄웠답니다. ㅡ.,ㅡ;





웹조각 추가하기



실제 적용예



웹조각 삭제하기




원본소스 나갑니다.
    <div id="bugslice" class="hslice">
     <div class="entry-title">데꾸벅 웹조각 테스트 제목</div>
     <div class="entry-content">
         웹조각 내용이 들어가는곳입니다.<br />
         .entry-title을 display:none이나 화면에 필요한걸로 바꾸면 되겠죠<br />
         <!--[if gte IE 7]>IE8에서 되는기능이므로 로도 처리해 되겠죠<![endif]-->
         아이디값은 나중에 버튼으로 추가하려면 좋아요~
        </div>
    </div> 


<html>
<head>
<title>Web Slice Example</title>
</head>
<body>
   <div class="hslice" id="SliceID">
      <span class="entry-title">Slice Title</span>
      <a rel="entry-content" href="http://techbug.tistory.com/" style="display:none;">
        실시간 웹조각 컨텐츠
      </a>
 
      <a rel="bookmark" href="http://techbug.tistory.com/" style="display:none;">북마크할때</a>
      <a href="http://techbug.tistory.com/" target="_blank">웹조각의 링크를 다른창으로 열때</a>
      <span class="endtime" title="25 Jul 2008 17:30:00 PST" style="display:none;">캐쉬없앨때</span>
   </div>
</body>
</html>











이벤트핸들러로 달기

<input type="button" value="웹조각 추가"  
       onclick="external.AddToFavoritesBar('http://localhost/webSlice.html#bugslice','설명','slice')" /> 


DIV대신 a태그 사용시 (웹조각에서 보여줄 페이지 지정하기)

<a rel="entry-content" href="http://techbug.tistory.com"> </a>


<div class="hslice" id="아이디값">
    <span class="entry-title">링크로처리할때</span>
    <a rel="entry-content" href="링크주소.html" style="display:none;"></a>
</div>

Feed용

<a rel="feedUrl" href=http://techbug.tistory.com/script/powerEditor/pages/">

<div class="hslice" id="아이디값">
    <span class="entry-title">링크로처리할때</span>
    <a rel="feedurl" href="피드주소.html" style="display:none;"></a>
</div>


북마크용

<div class="hslice" id="아이디값">
    <span class="entry-title">링크로처리할때</span>
    <a rel="bookmark" href="북마크.html" style="display:none;"></a>
</div>



웹조각 아이콘 바꾸기


원래의 웹조각 아이콘을 바꾸는 방법입니다. 기존 파비콘(favicon)을 바꾸는 방법과 마찬가지로 아래와 같은 방법으로 바꿀수 있습니다.
<link
    rel="default-slice"
    type="application/x-hatom"
    href="#웹조각아이디값" />




웹조각기능끄기
이미지툴바기능끄기와 같은 방법으로 웹조각 기능끄기 태그는 아래와 같습니다.

<meta name="slice" scheme="IE" content="off"/>



웹조각캐쉬없애기  (다음글을 참조하세요)

<span class="endtime" title="25 Jul 2008 17:30:00 PST" style="display:none;">캐쉬없앨때쓰기</span>











파이억폭스에서도 IE의 웹조각기능 사용하기
Firefox용 플러그인 WebChunks 3.5에서도 되네요
IE8에 새로 도입되는 WebSlices 기능을 파이어폭스에서 구현한 확장기능입니다.
툴바에서 Webslices 기능이 지원되는 사이트의 업데이트를 보기 좋게 확인 할 수 있습니다.
다운로드
    
 











다음글도 참조하세요 :




즐코딩하시길... 간만에 데꾸벅이였습니다.


저작자 표시
Posted by 예진이네집 괴스트
크리에이티브 커먼즈 라이선스
Creative Commons License
PHP 엑셀로변경 저장시 한글일 깨질 경우




<?php
    header("Content-type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename=test.xls");
    header("Content-Description: PHP4 Generated Data");
    header( "Content-charset=euc-kr" );
?>

<html>

<head>

 

<meta http-equiv="Content-Type" content="application/vnd.ms-excel;charset=euc-kr">

 

</head>
<body>
<table border="1">
.

.

.


</table>
</body>
</html>

저작자 표시
Posted by 예진이네집 괴스트