[perf]strstr() 불린 검사를 strpos() !== false 로 교체
strstr()은 일치하는 부분 문자열 전체를 반환하므로 존재 여부만 체크할 때는 메모리 할당이 낭비됨. strpos()는 위치(int) 또는 false만 반환하여 메모리 할당 없이 더 빠르게 동일 동작 수행. 적용 파일 (19개, 약 25곳): - lib/common.lib.php: wr_option html1/html2/secret 검사 3곳 - lib/shop.lib.php: de_taxsave_types 검사 2곳 - lib/latest.lib.php: wr_option secret 검사 1곳 - lib/thumbnail.lib.php: wr_option secret 검사 1곳 - lib/URI/uri.class.php: URI 확장자 검사 1곳 - bbs/view.php: subject/wr_option/content 검사 4곳 - bbs/view_comment.php: wr_option secret 검사 1곳 - bbs/search.php: wr_option/sfl 검사 3곳 - bbs/rss.php: wr_option html 검사 1곳 - bbs/write_update.php: html1/html2 검사 2곳 - bbs/move_update.php: wr_option html 검사 1곳 - adm/admin.lib.php: auth 권한 검사 1곳 - adm/admin.head.php: 메뉴 권한 검사 1곳 - adm/session_file_delete.php: sess_ prefix 검사 1곳 - adm/point_list.php, adm/auth_list.php: sfl mb_id 검사 2곳 - adm/sms_admin/_common.php: install.php 검사 1곳 - adm/shop_admin/configform.php: de_taxsave_types 검사 3곳 - head.sub.php: admin dir 검사 1곳 규칙: strstr($a, $b) → strpos($a, $b) !== false !strstr($a, $b) → strpos($a, $b) === false 제외: - theme/, skin/, plugin/ (사용자 커스터마이징/서드파티) - strstr() 반환값을 실제로 사용하는 케이스 (예: lib/common.lib.php:4135 if( \$freg = strstr(\$ori_params, '#') ), extend/gif2mp4.extend.php)
This commit is contained in:
1 parent
a612e69d3e
commit
31ef78e916
19 files changed
+31
-31
No files matched your search
@@ -25,7 +25,7 @@ class G5_URI {
|
||||
$ext = end($script_names);
|
||||
|
||||
/* if extension is found in URL, eliminate it */
|
||||
if(strstr($uri,".")) {
|
||||
if(strpos($uri,".") !== false) {
|
||||
$arr_uri = explode('.', $uri);
|
||||
/* get last part */
|
||||
$last = end($arr_uri);
|
||||
|
||||
+3
-3
@@ -462,9 +462,9 @@ function get_list($write_row, $board, $skin_url, $subject_len=40)
|
||||
if ($board['bo_use_list_content'])
|
||||
{
|
||||
$html = 0;
|
||||
if (strstr($list['wr_option'], 'html1'))
|
||||
if (strpos($list['wr_option'], 'html1') !== false)
|
||||
$html = 1;
|
||||
else if (strstr($list['wr_option'], 'html2'))
|
||||
else if (strpos($list['wr_option'], 'html2') !== false)
|
||||
$html = 2;
|
||||
|
||||
$list['content'] = conv_content($list['wr_content'], $html);
|
||||
@@ -525,7 +525,7 @@ function get_list($write_row, $board, $skin_url, $subject_len=40)
|
||||
$list['icon_hot'] = '<i class="fa fa-heart" aria-hidden="true"></i> ';
|
||||
|
||||
$list['icon_secret'] = '';
|
||||
if (strstr($list['wr_option'], 'secret'))
|
||||
if (strpos($list['wr_option'], 'secret') !== false)
|
||||
$list['icon_secret'] = '<i class="fa fa-lock" aria-hidden="true"></i> ';
|
||||
|
||||
// 링크
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ function latest($skin_dir='', $bo_table='', $rows=10, $subject_len=40, $cache_ti
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
$row['wr_email'] = ''; //이메일 저장 안함
|
||||
if (strstr($row['wr_option'], 'secret')){ // 비밀글일 경우 내용, 링크, 파일 저장 안함
|
||||
if (strpos($row['wr_option'], 'secret') !== false){ // 비밀글일 경우 내용, 링크, 파일 저장 안함
|
||||
$row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';
|
||||
$row['file'] = array('count'=>0);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2502,12 +2502,12 @@ function shop_is_taxsave($od, $is_view_receipt=false){
|
||||
}
|
||||
|
||||
if( $od_pay_type ) {
|
||||
if( $default['de_taxsave_use'] && strstr( $default['de_taxsave_types'], $od_pay_type ) ){
|
||||
if( $default['de_taxsave_use'] && strpos( $default['de_taxsave_types'], $od_pay_type ) !== false ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// 아직 현금영수증 받기전 상태일때만
|
||||
if( $is_view_receipt && ! $od['od_cash'] && in_array($od['od_settle_case'], array('계좌이체', '가상계좌')) && ! strstr( $default['de_taxsave_types'], $od_pay_type ) ){
|
||||
if( $is_view_receipt && ! $od['od_cash'] && in_array($od['od_settle_case'], array('계좌이체', '가상계좌')) && strpos( $default['de_taxsave_types'], $od_pay_type ) === false ){
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_
|
||||
$write = get_thumbnail_find_cache($bo_table, $wr_id, 'content');
|
||||
|
||||
// 비밀글이면 썸네일을 노출하지 않습니다.
|
||||
if (isset($write['wr_option']) && strstr($write['wr_option'], "secret")) {
|
||||
if (isset($write['wr_option']) && strpos($write['wr_option'], "secret") !== false) {
|
||||
return run_replace('is_secret_list_thumbnail', $empty_array, $bo_table, $write);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user