2015/06/24

[php] increase max upload size (wordpress)




PHP_INI_PERDIR Entry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)

php.ini

upload_max_filesize = 32M
post_max_size = 32M

then httpd restart




http://stackoverflow.com/questions/13442270/ini-setupload-max-filesize-200m-not-working-in-php

[apache] change run user, group

cakephp3 Permission denied error




/etc/apache2/envvars

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.

##export APACHE_RUN_USER=www-data
##export APACHE_RUN_GROUP=www-data
## 아파치 유저 변경
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data


service apache restart







[cakephp] not found the requested url (apache)



/etc/apache2/sites-available/default


<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>



http://book.cakephp.org/3.0/en/installation.html#url-rewriting



[vagrant] synced folder owner change (apache)




vagrant file edit

## 공유 폴더 권한 변경

#config.vm.synced_folder "./source", "/var/www/source", create: true
config.vm.synced_folder "./source", "/var/www/source", create: true,
      :owner => "vagrant",
      :group => "www-data",
      :mount_options => ["dmode=775","fmode=664"]



$ vagrant reload



2015/05/13

[php] 기본 페이징 코드


// 전체 게시물수
$totalCnt = $row['cnt'];
// 한 페이지 게시글 수 
$onePagePer = 15;
// 전체 페이지 수
$totalPageCnt = ceil($totalCnt / $onePagePer);
if ($page < 1 && $page > $totalPageCnt) {
?>
 <script type="text/javascript">
 alert('존재하지 않는 페이지 입니다.');
 history.back();
 </script>
<?php
 exit;
}
// 한번에 보여줄 총 페이지 개수
$oneSectionPer = 10;
// 현재 섹션
$currentSection = ceil($page / $oneSectionPer);
// 전체 섹션의 수
$totalSectionCnt = ceil($totalPageCnt / $oneSectionPer);
// 현재 섹션의 처음 페이지
$firstPage = ($currentSection * $oneSectionPer) - ($oneSectionPer - 1);
if ($currentSection == $totalSectionCnt) {
 // 현재 섹션이 마지막 섹션이라면 $totalPageCnt가 마지막 페이지가 된다
 $lastPage = $totalPageCnt;
} else {
 $lastPage = $currentSection * $oneSectionPer;
}
// 이전페이지
$prevPage = (($currentSection - 1) * $oneSectionPer);
// 다음 페이지
$nextPage = (($currentSection + 1) * $oneSectionPer) - ($oneSectionPer - 1);
// 페이징을 저장할 변수
$paging = '<ul>';
// 첫페이지가 아니라면 처음 버튼을 생성
if ($page != 1) {
 $paging .= '<li class="page page_start"><a href="./index.php?page=1">처음</a></li>';
}
// 첫 섹션이 아니라면 이전 버튼을 생성
if ($currentSection != 1) {
 $paging .= '<li class="page page_prev"><a href="./index.php?page=' .$prevPage. '">이전</a></li>';
}

for ($i = $firstPage; $i <= $lastPage; $i++) {
 if ($i == $page) {
  $paging .= '<li class="page current">' .$i. '</li>';
 } else {
  $paging .= '<li class="page"><a href="./index.php?page=' .$i. '">' .$i. '</a></li>';
 }
}
//마지막 섹션이 아니라면 다음 버튼을 생성
if ($currentSection != $totalSectionCnt) {
 $paging .= '<li class="page page_next"><a href="./index.php?page=' .$nextPage. '">다음</a></li>';
}
// 마지막 페이지가 아니라면 끝 버튼을 생성
if ($page != $totalPageCnt) {
 $paging .= '<li class="page page_end"><a href="./index.php?page='.$totalPageCnt.'">끝</a></li>';
}
$paging .= '</ul>';
/* 페이징 끝 */
$currentLimit = ($onePagePer * $page) - $onePagePer;
$sqlLimit = ' LIMIT ' .$currentLimit. ', '.$onePagePer;
$sql = 'SELECT * FROM board_free ORDER BY b_no DESC' .$sqlLimit;
$result = $db->query($sql);

2014/12/16

[MyBatis] parametertype string test (There is no getter for property named 'xxxx' in 'class java.lang.String')


Mybatis에서 parametertype이 String이나 int 같은 기본형인 경우

=============================
<if test="abc == null ">
    ...
</if>
=============================
위와 같이 사용시

There is no getter for property named 'abc' in 'class java.lang.String'
라는 에러 발생

...
이럴때는

=============================
<if test="_parameter == null ">
    ...
</if>
=============================
위와 같이 테스트할 파라미터 이름을 '_parameter' 로 바꿔주면
정상적으로 동작한다.





참고 :
http://devwa.com/47




2014/11/26

[JavaScript] 팝업창 열기, 닫기 (popup window open and close)

  
function fnPopup() {
    var popupOption = 'directories=no, toolbar=no, location=no, menubar=no, status=no, scrollbars=no, resizable=no, left=400, top=200, width=440, height=550';
    window.open(URL, name, popupOption);
}


function fnClose() {
    window.opener.location.href = URL;
    window.close();
}



참고 :
http://www.w3schools.com/jsref/met_win_open.asp

2014/11/19

[RegExp] Non-breaking space (char code 160) replace

- Non-breaking space
- ASCII character 160
- char code 160
- &#160
- \u00A0
- %A0
- &nbsp; 

볼때는 일반적인 공백으로 보이지만 따로 처리해줘야 할 경우가 생겼다.
 

RegExp = /\u00A0/  or  /&#160;/

value = value.replace(/\u00A0/g, ' ');
or
value = value.replace(/&#160;/g, ' ');
 
 
출처 :
http://stackoverflow.com/questions/3794919/replace-all-spaces-in-a-string-with
http://www.adamkoch.com/2009/07/25/white-space-and-character-160/

2014/11/17

[SQL] VARCHAR 필드 숫자로 정렬 (SORT A VARCHAR2 FIELD AS A NUMERIC FIELD)


- 해당 필드에 숫자만 있는 경우
ORDER BY TO_NUMBER(FIELD);

- 해당 필드에 숫자 이외의 값도 있는 경우
ORDER BY LPAD(FIELD, 10);
// 10 == FIELD.length

 
 
출처 :
http://www.techonthenet.com/oracle/questions/sort1.php

[RegExp] 8자리 이상 16자리 이하 영문, 숫자, 특수문자 조합

암호규칙 정규식

var pwReg = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,16}$/;

if (pwReg.test(pw)) {
    return true;
} else {
    return false;

}