�빫�� ����� ���

Archive for the ‘PHP’ Category.

PHP 유감


6월부터인가 낚시를 시작한 이후로 정신없이 11월까지 왔네요. 낚시에 빠져 산 건 아닌데, 평소 생활에 취미 하나 더해지니 이건 뭐.. 생활이 24시간 중에 20시간이 소요되네요. 대낚시, 루어낚시 다 재미있더군요, 평생 취미로 좋다 싶어요.
그건 그거고.

요새 알바로 웹페이지를 한군데 만들고, 다음 일을 준비하고자 프레임웍과 관리시스템을 혼자서 만들고 있는데, 이 php라는 놈의 특성이 저하고 잘 맞지 않는건지 모듈화해서 구조적이며 쉽게 사용할 수 있는 방법을 찾기가 꽤 어렵더군요. 좋은 프레임웍은 많습니다. 특히 CodeIngniter가 간결하고 깔끔해서 눈에 확 띄었는데, 그걸 쓰자니 제가 프레임웍에 끌려다닐까 하는 옹졸한 기우로 프레임웍을 만들기로 했죠.

모든 uri 요청은 웹 root의 index.php에서만 받도록해서 파라미터를 파싱해서 필요한 모듈을 불러오는 방법으로 구현하기로 했습니다. php는 다른 모듈(파일)을 불러오기 위해 include 함수(replace, replace_once)를 사용하는데, 이 함수는 다른 언어와는 다르게 요청된 파일을 요청한 파일의 일부분으로 합쳐지게 되는 동작을 합니다. index.php 에서 include “config.php”를 하면 config.php와 index.php가 index.php 하나인 것 처럼 동작을 하지요. php의 특성이고, 따라서 좋은 점도 있는데요, class 또는 function을 만들어서 include해서 사용하자니 덩치가 점점 커지는 것 같고, 안그래도 debug하기 어려운 웹환경에서 에러를 잡아나가는게 너무 더디더군요. java 환경에서 작업할 때 원격 디버그 등의 환경이 없다면 작성한 함수 또는 클래스를 main함수를 포함한 어플리케이션에 붙여서 디버깅하는 방법을 쓰곤 하는데, php는 그것도 어렵죠.

php가 5.0 이후로부터는 보안상의 이유로 에러메세지를 뱉어내는 옵션이 기본적으로 disable 되어 있지요. php를 선택한 이유가 거의 모든 호스팅업체에서 사용할 수 있다는 대중성인데, php를 5년만에 사용해서 그런지, 개발속도가 c/c++이나 java 어플리케이션을 제작할 때 보다 훨씬 더디게 진행되는게, 조금씩 지쳐갑니다. 5년 전에는 php가 배열처리하거나 문자열 처리할 때 참 편하다고 느꼈었는데, 요새 거의 모든 언어와 라이브러리가 php보다 훨씬 상회하는 기능을 갖고 있어서 불편하게만 느껴지는군요. 특히 연관배열과 index 배열이 제가 코딩하면서도 저를 헷갈리게 만드네요. 매번 함수 레퍼런스 보는 것 때문에 개발속도가 쳐지는 건지도 모르겠습니다.

내일은 python으로 웹개발할 때 웹페이지와 파이썬 코드가 어느정도까지 잘 분리되는지 확인해봐야겠습니다. 그것 말고도 하스켈을 주목하고 있긴 한데, 보통 호스팅 업체에서는 지원하지 않으니 좀 어렵네요. 제가 서비스하면 또 모르지요. -_-; 아직 투자할 만큼 주머니가 넉넉하지는 않아서 음..

분명 PHP가 좋은 언어이긴 하지만 요즘들어서는 너무 불편하게만 느껴집니다. /아쉽

Warning: file_get_contents() 에러


이 블로그는 나야나에서 유료 웹호스팅으로 사용하고 있는 중인데요, 플러그인을 설치해서 사용하려고 하는 도중
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration … 과 같은 에러가 나오는 군요.
구글링해보니 PHP 설정을 변경하여야 한답니다. 그래서 나야나측에 변경요청을 문의한 상태인데 만약 변경이 안된다면 바로 호스팅을 다른 곳으로 옮겨버릴까 하는 생각을 하고 있습니다.
기다려봐야죠.

워드프레스(2.7.1)에서 내 트랙백 보이게 하기


저도 한참 찾았었는데 아무리봐도 제 포스트에 트랙백 URL이 나타나질 않았습니다. 찾느라 한참 걸렸어요. 여기저기 다른 분들의 글을 보고 참조한건데 감사의 말씀을 드리려고 했다가 퇴근때가 되어서 어쩔 수 없이 그냥 브라우져를 닫아야 했습니다.

제 워드프레스는 2.7.1입니다. 테마 디자인에 편집기를 열어서 index.php(또는 테마에 알맞는 context가 나오는 페이지)파일을 엽니다. content가 나오는 부분의 다음 div 태그에 하단의 코드를 넣어주시면 됩니다.

					<br>
					<?php post_comments_feed_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?> | 
					<a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Universal Resource Locator">URL</abbr>'); ?> : <?php trackback_url() ?></a>

제 테마에서는 layout-default.php와 single.php 파일을 수정했는데요, 전체를 보여드리면
layout-default.php

<?php
/**
 * @package WordPress
 * @subpackage construtor
 */
?>
<div id="wrapper" class="box shadow opacity">
    <div id="container" >
    <?php get_constructor_slideshow() ?>
 
    <?php if (have_posts()) : ?>
        <div id="posts">
        <?php while (have_posts()) : the_post(); ?>
            <div <?php post_class(); ?> id="post-<?php the_ID() ?>">
                <div class="title opacity box">
                    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'construtor'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
                </div>
                <div class="entry">
                    <?php the_content(__('Read the rest of this entry &raquo;', 'construtor')) ?>
                    <script type='text/javascript'>document.write("<scr"+"ipt type='text/javascript' src='http://www.mixsh.com/widget/mixup/loader.js?muid=67567&guid=<?echo(urlencode($post->guid))?>&rdate=<?echo(urlencode($post->post_date))?>&rawhtml=&skin=1&showhitcnt=1&platform=5'></scr"+"ipt>");</script>
                </div>
                <div class="footer">
                    <div class="links right">
                    <?php the_time(__('F jS, Y', 'construtor')) ?> |
                    <?php get_constructor_author('', ' |') ?>
                    <?php the_tags(__('Tags', 'construtor') . ': ', ', ', '|'); ?>
                    <?php edit_post_link(__('Edit', 'construtor'), '', ' | '); ?>
                    <?php comments_popup_link(__('No Comments &#187;', 'construtor'), __('1 Comment &#187;', 'construtor'), __('% Comments &#187;', 'construtor'), '', __('Comments Closed', 'construtor') ); ?>                    </div>
                    <div class="line clear">
					<br>
					<?php post_comments_feed_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?> | 
					<a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Universal Resource Locator">URL</abbr>'); ?> : <?php trackback_url() ?></a>
 
</div>
 
                </div>
            </div>
        <?php endwhile; ?>
        </div>
        <div class="navigation">
            <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries', 'construtor')) ?></div>
            <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;', 'construtor')) ?></div>
            <div class="clear">&nbsp;</div>
        </div>
    <?php endif; ?>
 
    </div><!-- id='container' -->
</div><!-- id='wrapper' -->
<?php get_constructor_sidebar(); ?>

single.php

<?php
/**
 * @package WordPress
 * @subpackage Constructor
 */
 
wp_enqueue_script( 'comment-reply' );
?>
<?php get_header(); ?>
<div id="wrapper" class="box shadow opacity">
    <div id="container" >
    <?php get_constructor_slideshow() ?>
 
    <?php if (have_posts()) : ?>
        <div id="posts">
        <?php while (have_posts()) : the_post(); ?>
            <div <?php post_class(); ?> id="post-<?php the_ID() ?>">
                <div class="title opacity box">
                    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'constructor'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
                </div>
                <div class="entry">
                    <?php the_content(__('Read the rest of this entry &raquo;', 'constructor')) ?>
				    <?php wp_link_pages(array('before' => '<p class="pages"><strong>'.__('Pages', 'constructor').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                                <script type='text/javascript'>document.write("<scr"+"ipt type='text/javascript' src='http://www.mixsh.com/widget/mixup/loader.js?muid=67567&guid=<?echo(urlencode($post->guid))?>&rdate=<?echo(urlencode($post->post_date))?>&rawhtml=&skin=1&showhitcnt=1&platform=5'></scr"+"ipt>");</script>
                </div>
                <div class="footer">
                    <div class="links right">
                    <?php the_time(__('F jS, Y', 'constructor')) ?> |
                    <?php the_tags(__('Tags', 'constructor') . ': ', ', ', '|'); ?>
                    <?php edit_post_link(__('Edit', 'constructor'), '', ' | '); ?>
                    <?php comments_popup_link(__('No Comments &#187;', 'constructor'), __('1 Comment &#187;', 'constructor'), __('% Comments &#187;', 'constructor'), '', __('Comments Closed', 'constructor') ); ?>                    </div>
                    <div class="line clear">
					<br>
					<?php post_comments_feed_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?> | 
					<a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Universal Resource Locator">URL</abbr>'); ?> : <?php trackback_url() ?></a>
</div>
                </div>
            </div>
        <?php endwhile; ?>
        </div>
        <div id='comments'>
           <?php comments_template(); ?>
        </div>
        <div class="navigation">
            <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries', 'construtor')) ?></div>
            <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;', 'construtor')) ?></div>
            <div class="clear">&nbsp;</div>
        </div>
    <?php endif; ?>
 
    </div><!-- id='container' -->
</div><!-- id='wrapper' -->
<?php get_constructor_sidebar(); ?>
<?php get_footer(); ?>
</php>

이렇게 되네요. 그러면

이 글의 댓글을 위한 RSS 피드 | 트랙백 URL : http://defree.co.kr/blog/wp-trackback.php?p=354

와 같이 나오게 됩니다.