메인화면에서, 최신글 스킨으로 첨부파일을 출력하도록 했으나 '잘못된 접근' 이라는 오류가 발생..

 

세션체크와 같이 들어가는 부분이라, 세션체크도 해줘야함.

 

메인에서 불러오는 최신글 스킨 for문 안에 코드 추가했더니 해결.

 

$ss_name = "ss_view_{$bo_table}_{$list[ $i]['wr_id']}";

if (!get_session($ss_name)); set_session($ss_name, TRUE);

 

 

1. #instagram-feed 영역 추가

          <div id="instagram-feed"></div>

 

2. 스크립트 임포트 / 스크립트 추가

<script src="js/jquery.instagramFeed.min.js"></script>
    <script >
    (function($){
        $(window).on('load', function(){
            $.instagramFeed({
                'tag': '해시태그',
                'container': "#instagram-feed",
                'display_profile': false,
                'display_gallery': true,
                'items': 10,
                'items_per_row': 5,
                'margin': 0,
                'callback': null,
                'styling': true
            });
        });
    })(jQuery);
</script>

3. 반응형 소스 추가

<style>
  @media (max-width: 375px){
  .instagram_gallery a, .instagram_gallery a img{ width: calc(50% - 0px) !important; }
  }
  @media (min-width: 375px){
    .instagram_gallery a, .instagram_gallery a img{ width: calc(33.3333% - 0px) !important; }
    #insta-box{min-height:810px;}

  }
  @media ( min-width: 768px){
    .instagram_gallery a, .instagram_gallery a img{ width: calc(33.3333% - 0px) !important; }

  }
  @media (min-width: 768px){
    .instagram_gallery a, .instagram_gallery a img{ width: calc(25% - 0px) !important; }
    #insta-box{min-height:620px;}
  }
  @media (min-width: 992px) {
    .instagram_gallery a, .instagram_gallery a img{ width: calc(20% - 0px) !important; }
    #insta-box{min-height:560px;}
  }
</style>

 

 

scontent-ssn1-1.cdninstagram.com/v/t51.2885-15/sh0.08/e35/s640x640/107457615_309015266907659_5616632477996359043_n.jpg?_nc_ht=scontent-ssn1-1.cdninstagram.com&_nc_cat=111&_nc_ohc=lv5XcFez34MAX9JJyfj&oh=f21a6e16cfb8892934386fa114f9ff7f&oe=5F38E659

 

$nano /etc/ssh/sshd_config

주석처리된 PermitRootLogin Yes를 주석처리 해제 및 No로 변경

PermitRootLogin no

해당 단락(?) 밑에 AllowUser 추가 하고 접근 허락할 아이디를 써줌

#MaxAuthTries 6
#MaxSessions 10
AllowUsers admin user2 user3 user ..

저장 후 재시작

service sshd restart

 

500 OOPS vsftpd: refusing to run with writable root inside chroot()

에러, 530에러 등등 각종 에러가 뜨길래... 

chroot_list 방법도  해봤다가 안되길래, pasv 모드를 설정해줬더니 바로됨.

 

# yum install vsftpd
# nano /etc/vsftpd/vsftpd.conf
.
.
anonymous_enable=NO  (YES → NO 변경)
.
.
100 chroot_local_user=YES  (# 주석 제거 / 또는 추가)
.
.
pasv_enable=YES   (추가)

pasv_min_port=50001   (추가)
pasv_max_port=50005   (추가)

allow_writeable_chroot=YES  (추가)

 

<?php

/* root/about.php */
include_once('./common.php');

/* root/theme/basic/dir/about.php */
include_once('../../../common.php');


/* root/sub/about.php 의 경우 ../common.php로 */

$g5['title'] = "새로운 페이지";
include_once(G5_PATH.'/head.php');

?>

<!-- 새로운 페이지 내용 작성 부분 -->

<!-- 새로운 페이지 내용 작성 부분 -->


<?php

include_once(G5_PATH.'/tail.php');

?>

 

.line-clamp
{
	display            : block;
	display            : -webkit-box;
	-webkit-box-orient : vertical;
	position           : relative;
 
	line-height        : 1.2;
	overflow           : hidden;
	text-overflow      : ellipsis;
	padding            : 0 !important;
}
.line-clamp:after
{
	content    : '...';
	text-align : right;
	bottom     : 0;
	right      : 0;
	width      : 25%;
	display    : block;
	position   : absolute;
	height     : calc(1em * 1.2);
	background : linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 75%);
}
@supports (-webkit-line-clamp: 1)
{
	.line-clamp:after
	{
		display : none !important;
	}
}
 
.line-clamp-5
{
	-webkit-line-clamp : 2;
	height             : calc(1em * 1.2 * 2);
}
.line-clamp{
	line-height        : 1.2;
}

이 부분 적당히 조절해가면서 사용

일반적으로 만들어진 홈페이지에 게시판이 갑자기 추가되는 번거로워지는 경우가 생겼다.

그래서 크게 구조 등을 변경하지 않고 아이프레임으로 삽입을 하면 될 거라 생각했는데

<iframe id="iframe-import" src="http://domain.com/external-board" frameborder="0" scolling="no" width="100%" height="900"></iframe>

높이가 고정이다보니 안예쁨.

따라서 아래 코드로 변경(onLoad 부분)

<iframe id="iframe-import" src="http://domain.com/external-board" frameborder="0" scolling="no" width="100%" height="900" onload="autoResize(this)"></iframe>

autoResize 라는 자바스크립트 함수도 추가

<script type="text/javascript">

// iFrame Resizing Funcgtion

function autoResize(i){
    var iframeHeight=
    (i).contentWindow.document.body.scrollHeight;
    (i).height=iframeHeight+20;
}

</script>

ini_set('display_errors', 1);

ini_set('error_reporting', E_ALL);

 

페이지 상단에 삽입

config.php 파일

 

1. /bbs/list_num_update.php 생성

* Mysql DB 의 데이터베이스 이름하고 접두사를 잘 확인할것(g5_XXXX)

<?php
include_once('./_common.php');
// 게시판 관리자 이상 복사, 이동 가능 
if ($is_admin != "board" && $is_admin != "group" && $is_admin != "super") 
    alert_close("게시판 관리자 이상 접근이 가능합니다."); 

$wr_id=$_POST[chk_wr_id][0]; 
if($_POST[chk_wr_id][1]) $wr_id2=$_POST[chk_wr_id][1]; 

if($sw=="change"){ 
    if(count($_POST[chk_wr_id])==2){
    
    $act = "순서변경"; 

    $sql = " select wr_num from g5_write_{$bo_table} where wr_id='$wr_id'"; //절대값이 높은(위쪽) wr_num값을 구한다.
    $result = sql_query($sql); 
    $forth_wr_num_array=sql_fetch_array($result); 
    $wr_id;
    $forth_wr_num = $forth_wr_num_array['wr_num']; //절대값이 높은 wr_num값
    $sql = " select wr_num from g5_write_{$bo_table} where wr_id='$wr_id2'"; //절대값이 낮은(아래쪽) wr_num값을 구한다.
    $result = sql_query($sql); 
    $back_wr_num_array=sql_fetch_array($result); 
    $wr_id2;
    $back_wr_num = $back_wr_num_array['wr_num']; //절대값이 낮은 wr_num값

    sql_query(" update g5_write_{$bo_table} set wr_num = '$back_wr_num' where wr_id = '$wr_id'"); //위쪽 게시물 wr_num을 아래쪽 wr_num으로 수정
    sql_query(" update g5_write_{$bo_table} set wr_num = '$forth_wr_num' where wr_id = '$wr_id2'"); //아래쪽 게시물 wr_num을 위쪽 wr_num으로 수정

    }else{
        alert_close("2개의 게시물을 선택해주세요."); 
    }

}else if($sw == "prev"){ 
    if(count($_POST[chk_wr_id])>=2){alert_close("1개의 게시물만 선택해주세요."); }


    $act = "앞으로 이동"; 

    $sql = " select wr_num from g5_write_{$bo_table} where wr_id='$wr_id'"; //선택된 wr_num값을 구한다.
    $result = sql_query($sql); 
    $selected_wr_num_array=sql_fetch_array($result); 
    $selected_wr_num = $selected_wr_num_array['wr_num']; //선택된 wr_num값
    if($selected_wr_num=='-1') alert_close("가장 앞선 게시물입니다."); 
    $prev_wr_num = $selected_wr_num+1; //앞의 wr_num 값
    $sql = " select wr_id from g5_write_{$bo_table} where wr_num='{$prev_wr_num}'"; //앞의 wr_num값을 갖는 wr_id를 구한다.
    $result = sql_query($sql); 
    $prev_wr_id_array=sql_fetch_array($result);
    $prev_wr_id = $prev_wr_id_array['wr_id']; //앞의 wr_id 값

    sql_query(" update g5_write_{$bo_table} set wr_num = '$prev_wr_num' where wr_id = '$wr_id'"); //선택된 게시물을 앞번으로 수정
    sql_query(" update g5_write_{$bo_table} set wr_num = '$selected_wr_num' where wr_id = '$prev_wr_id'"); //앞번 게시물을 선택된번으로 수정

}else if ($sw == "next") { 
    if(count($_POST[chk_wr_id])>=2){alert_close("1개의 게시물만 선택해주세요."); }
    
    $act = "뒤로 이동"; 

    $sql = " select wr_num from g5_write_{$bo_table} where wr_id='$wr_id'"; //선택된 wr_num값을 구한다.
    $result = sql_query($sql); 
    $selected_wr_num_array=sql_fetch_array($result); 
    $selected_wr_num = $selected_wr_num_array['wr_num']; //선택된 wr_num값
    $latest_wr_num_array = sql_fetch(" select min(wr_num) as latest from g5_write_{$bo_table} where 1");
    if($selected_wr_num == $latest_wr_num_array['latest']) alert_close("가장 뒤선 게시물입니다.");
    $next_wr_num = $selected_wr_num-1; //뒤의 wr_num 값
    $sql = " select wr_id from g5_write_{$bo_table} where wr_num='{$next_wr_num}'"; //뒤의 wr_num값을 갖는 wr_id를 구한다.
    $result = sql_query($sql); 
    $next_wr_id_array=sql_fetch_array($result);
    $next_wr_id = $next_wr_id_array['wr_id']; //뒤의 wr_id 값

    sql_query(" update g5_write_{$bo_table} set wr_num = '$next_wr_num' where wr_id = '$wr_id'"); //선택된 게시물을 뒷번으로 수정
    sql_query(" update g5_write_{$bo_table} set wr_num = '$selected_wr_num' where wr_id = '$next_wr_id'"); //뒷번 게시물을 선택된번으로 수정


}else { 
    alert("수행 값이 제대로 넘어오지 않았습니다."); 
} 

$msg = "순서변경완료!"; 
$opener_href = "./board.php?bo_table=$bo_table&page=$page&$qstr"; 

?>
<script language="javascript"> 
//alert("<?php echo $msg?>"); 
opener.document.location.href = "<?php echo $opener_href?>"; 
window.close(); 
</script> 

2. 게시판 테마 리스트 파일 수정( /skin/board/boardtheme/list.skin.php)

2-1 하단에 아래 코드 추가(스크립트 영역)

function list_changer(sw) 
{ 
    /*
    var chk_count = 0;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
            chk_count++;
    }

    if (!chk_count) {
        alert(document.pressed + "할 게시물을 하나 이상 선택하세요.");
        return false;
    }
    */

    var f = document.fboardlist; 

    var sub_win = window.open("", "move", "width=0, height=0, scrollbars=1"); 

    f.sw.value = sw; 
    f.target = "move"; 
    f.action = "./list_num_update.php"; 
    f.submit(); 
} 

2-2 위치 변경 버튼 추가

   <li><a href="javascript:list_changer('prev');" >위로 이동</a></li>
   <li><a href="javascript:list_changer('change');" >상호 변경</a> </li>
   <li><a href="javascript:list_changer('next');" >아래로 이동</a> </li>

 

 

1. ismobile_module.php 

<?php
	class module {
		function mobileConcertCheck() {
            $mobileArray = array(
                  "iphone"
                , "lgtelecom"
                , "skt"
                , "mobile"
                , "samsung"
                , "nokia"
                , "blackberry"
                , "android"
                , "sony"
                , "phone"
            );

			$checkCount = 0;

			for($num = 0; $num < sizeof($mobileArray); $num++) {
				if(preg_match("/$mobileArray[$num]/", strtolower($_SERVER['HTTP_USER_AGENT']))) {

                                        $checkCount++;

                                        break;

                        	}

			}
			return ($checkCount >= 1) ? "mobile" : "computer";

		}

	}

?>

2. index.php

<?php include("ismobile_module.php"); ?>
<?php $obj = new module(); ?>
<?php  if($obj -> mobileConcertCheck() == "mobile") { 
	// 모바일 영역
 } else { 
 	// PC 영역 } 
?>

 

#php #모바일 #pc #모바일,PC구분하기 

'공부 > Php' 카테고리의 다른 글

[Centos] crontab 를 이용한 php 자동실행, DB 모니터링구현  (0) 2024.02.18
[PHP] If 조건문 한줄로 축약  (0) 2023.12.29
트위터 OAuth Sign in 튜토리얼  (0) 2013.07.22
트위터 oauth with php  (0) 2013.07.22
php 파일 include  (0) 2013.01.11

필요에의해 갤러리형태의 게시판의 리스트를 무한으로 구현해야 했다.

잘 찾아보니 http://webpaper.kr/show/98&page=1&stx=%EC%8A%A4%ED%81%AC%EB%A1%A4 에서 

개발 후 방법을 공유하신게 있어서 커스터마이징 후 기록을 위해 남김

 

 

게시판 스킨/list.skin.php 하단에 아래 코드를 넣어준다. 

물론 게시판 형태에 따라 일부 수정은 해야한다. 

게시판에 리스트 영역의 다음페이지를 불러와 코드를 붙이는 방식.

<script>
var total_page = "<?=$total_page?>";
var now_page = "<?=$page?>";
var roll_page = now_page;


$(window).scroll(function() {
    var chkBtm = parseInt($(document).height()) - parseInt($(window).height());

    if (chkBtm == $(window).scrollTop()) {
        roll_page++;
        if (roll_page <= total_page) {
            callContent(roll_page, 'append');
        }
    } else if ($(window).scrollTop() == 0) {
        now_page--;
        if (now_page > 0) {
            callContent(now_page, 'prepend');
        }
    }
});

function callContent(a, b) {

    var url = "<?=G5_BBS_URL?>/board.php?bo_table=<?=$bo_table?>&page=" + a;
    var tbody = "";
    var thtml = "";
    $.ajax({
        type: "POST",
        url: url,
        dataType: "html",
        success: function(html) {
            tbody = html.split('<article>');
            thtml = tbody[1].split('</article>');
            setTimeout(function() {
                if (b == 'append') {
                    // $(".tbl_head01").find('tbody').append(thtml[0]);
                    $("#fboardlist").append(thtml[0]);

                } 
            }, 1000);

        },
        error: function(xhr, status, error) {
            alert(error);
        }
    });
}
</script>

아래는 최하단 스크롤 부분. 

$(window).scroll(function(){
     
    // 최하단일 경우를 체크하기 위해 최하단 위치값을 지정
    // 화면 문서전체의 길이에서, 현재 창 높이를 뺀 것이 최하단 값
    var chkBtm = parseInt($(document).height()) - parseInt($(window).height());
     
    if(chkBtm == $(window).scrollTop()){        
        // 최하단으로 도달했을 경우
        console.log('바닥입니다!');
    }else if($(window).scrollTop() == 0){
        // 최상단으로 도달했을 경우
        console.log('꼭대기입니다!');
    }
});

+ Recent posts