[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
-1
@@ -42,7 +42,7 @@ function print_menu2($key, $no = '')
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($is_admin != 'super' && (!array_key_exists($menu[$key][$i][0], $auth) || !strstr($auth[$menu[$key][$i][0]], 'r'))) {
|
||||
if ($is_admin != 'super' && (!array_key_exists($menu[$key][$i][0], $auth) || strpos($auth[$menu[$key][$i][0]], 'r') === false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -281,7 +281,7 @@ function auth_check($auth, $attr, $return = false)
|
||||
|
||||
$attr = strtolower($attr);
|
||||
|
||||
if (!strstr($auth, $attr)) {
|
||||
if (strpos($auth, $attr) === false) {
|
||||
if ($attr == 'r') {
|
||||
$msg = '읽을 권한이 없습니다.';
|
||||
if ($return) {
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ $colspan = 5;
|
||||
//if (isset($stx))
|
||||
// echo '<script>document.fsearch.sfl.value = "'.$sfl.'";</script>'."\n";
|
||||
|
||||
if (strstr($sfl, 'mb_id')) {
|
||||
if (strpos($sfl, 'mb_id') !== false) {
|
||||
$mb_id = $stx;
|
||||
} else {
|
||||
$mb_id = '';
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ if ($config['cf_point_term'] > 0) {
|
||||
$po_expire_term = $config['cf_point_term'];
|
||||
}
|
||||
|
||||
if (strstr($sfl, "mb_id")) {
|
||||
if (strpos($sfl, "mb_id") !== false) {
|
||||
$mb_id = $stx;
|
||||
} else {
|
||||
$mb_id = "";
|
||||
|
||||
@@ -31,7 +31,7 @@ include_once("./admin.head.php");
|
||||
echo $list_tag_st;
|
||||
while($file=readdir($dir)) {
|
||||
|
||||
if (!strstr($file,'sess_')) continue;
|
||||
if (strpos($file,'sess_') === false) continue;
|
||||
if (strpos($file,'sess_')!=0) continue;
|
||||
|
||||
$session_file = G5_DATA_PATH.'/session/'.$file;
|
||||
|
||||
@@ -715,13 +715,13 @@ if(!$default['de_kakaopay_cancelpwd']){
|
||||
<?php
|
||||
$account_checked = $vbank_checked = $transfer_checked = '';
|
||||
|
||||
if (strstr($default['de_taxsave_types'], 'account')) {
|
||||
if (strpos($default['de_taxsave_types'], 'account') !== false) {
|
||||
$account_checked = 'checked="checked"';
|
||||
}
|
||||
if (strstr($default['de_taxsave_types'], 'vbank')) {
|
||||
if (strpos($default['de_taxsave_types'], 'vbank') !== false) {
|
||||
$vbank_checked = 'checked="checked"';
|
||||
}
|
||||
if (strstr($default['de_taxsave_types'], 'transfer')) {
|
||||
if (strpos($default['de_taxsave_types'], 'transfer') !== false) {
|
||||
$transfer_checked = 'checked="checked"';
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -4,7 +4,7 @@ include_once ('../../common.php');
|
||||
include_once(G5_ADMIN_PATH.'/admin.lib.php');
|
||||
include_once(G5_SMS5_PATH.'/sms5.lib.php');
|
||||
|
||||
if (!strstr($_SERVER['SCRIPT_NAME'], 'install.php')) {
|
||||
if (strpos($_SERVER['SCRIPT_NAME'], 'install.php') === false) {
|
||||
// SMS5 테이블 G5_TABLE_PREFIX 적용
|
||||
if($g5['sms5_prefix'] != 'sms5_' && sql_num_rows(sql_query("show tables like 'sms5_config'")))
|
||||
{
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ while ($row = sql_fetch_array($result))
|
||||
|
||||
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
|
||||
if (!$row2['wr_is_comment'] && $config['cf_use_copy_log']) {
|
||||
if(strstr($row2['wr_option'], 'html')) {
|
||||
if(strpos($row2['wr_option'], 'html') !== false) {
|
||||
$log_tag1 = '<div class="content_'.$sw.'">';
|
||||
$log_tag2 = '</div>';
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ $result = sql_query($sql);
|
||||
for ($i=0; $row=sql_fetch_array($result); $i++) {
|
||||
$file = '';
|
||||
|
||||
if (strstr($row['wr_option'], 'html'))
|
||||
if (strpos($row['wr_option'], 'html') !== false)
|
||||
$html = 1;
|
||||
else
|
||||
$html = 0;
|
||||
|
||||
+3
-3
@@ -187,11 +187,11 @@ if ($stx) {
|
||||
}
|
||||
|
||||
// 비밀글은 검색 불가
|
||||
if (strstr($row['wr_option'].(isset($row2['wr_option']) ? $row2['wr_option'] : ''), 'secret'))
|
||||
if (strpos($row['wr_option'].(isset($row2['wr_option']) ? $row2['wr_option'] : ''), 'secret') !== false)
|
||||
$row['wr_content'] = '[비밀글 입니다.]';
|
||||
|
||||
$subject = get_text($row['wr_subject']);
|
||||
if (strstr($sfl, 'wr_subject'))
|
||||
if (strpos($sfl, 'wr_subject') !== false)
|
||||
$subject = search_font($stx, $subject);
|
||||
|
||||
if ($read_level[$idx] <= $member['mb_level'])
|
||||
@@ -203,7 +203,7 @@ if ($stx) {
|
||||
$content = str_replace(' ', '', $content);
|
||||
$content = cut_str($content, 300, "…");
|
||||
|
||||
if (strstr($sfl, 'wr_content'))
|
||||
if (strpos($sfl, 'wr_content') !== false)
|
||||
$content = search_font($stx, $content);
|
||||
}
|
||||
else
|
||||
|
||||
+4
-4
@@ -111,17 +111,17 @@ if ($is_member) {
|
||||
|
||||
$view = get_view($write, $board, $board_skin_path);
|
||||
|
||||
if (strstr($sfl, 'subject'))
|
||||
if (strpos($sfl, 'subject') !== false)
|
||||
$view['subject'] = search_font($stx, $view['subject']);
|
||||
|
||||
$html = 0;
|
||||
if (strstr($view['wr_option'], 'html1'))
|
||||
if (strpos($view['wr_option'], 'html1') !== false)
|
||||
$html = 1;
|
||||
else if (strstr($view['wr_option'], 'html2'))
|
||||
else if (strpos($view['wr_option'], 'html2') !== false)
|
||||
$html = 2;
|
||||
|
||||
$view['content'] = conv_content($view['wr_content'], $html);
|
||||
if (strstr($sfl, 'content'))
|
||||
if (strpos($sfl, 'content') !== false)
|
||||
$view['content'] = search_font($stx, $view['content']);
|
||||
|
||||
//$view['rich_content'] = preg_replace("/{이미지\:([0-9]+)[:]?([^}]*)}/ie", "view_image(\$view, '\\1', '\\2')", $view['content']);
|
||||
|
||||
@@ -40,7 +40,7 @@ for ($i=0; $row=sql_fetch_array($result); $i++)
|
||||
//$list[$i]['content'] = eregi_replace("[^ \n<>]{130}", "\\0\n", $row['wr_content']);
|
||||
|
||||
$list[$i]['content'] = $list[$i]['content1']= '비밀글 입니다.';
|
||||
if (!strstr($row['wr_option'], 'secret') ||
|
||||
if (strpos($row['wr_option'], 'secret') === false ||
|
||||
$is_admin ||
|
||||
($write['mb_id']===$member['mb_id'] && $member['mb_id']) ||
|
||||
($row['mb_id']===$member['mb_id'] && $member['mb_id'])) {
|
||||
|
||||
@@ -710,9 +710,9 @@ if (!($w == 'u' || $w == 'cu') && $config['cf_email_use'] && $board['bo_use_emai
|
||||
$wr_subject = get_text(stripslashes($wr_subject));
|
||||
|
||||
$tmp_html = 0;
|
||||
if (strstr($html, 'html1'))
|
||||
if (strpos($html, 'html1') !== false)
|
||||
$tmp_html = 1;
|
||||
else if (strstr($html, 'html2'))
|
||||
else if (strpos($html, 'html2') !== false)
|
||||
$tmp_html = 2;
|
||||
|
||||
$wr_content = conv_content(conv_unescape_nl(stripslashes($wr_content)), $tmp_html);
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ $g5['lo_location'] = addslashes($g5['title']);
|
||||
if (!$g5['lo_location'])
|
||||
$g5['lo_location'] = addslashes(clean_xss_tags($_SERVER['REQUEST_URI']));
|
||||
$g5['lo_url'] = addslashes(clean_xss_tags($_SERVER['REQUEST_URI']));
|
||||
if (strstr($g5['lo_url'], '/'.G5_ADMIN_DIR.'/') || $is_admin == 'super') $g5['lo_url'] = '';
|
||||
if (strpos($g5['lo_url'], '/'.G5_ADMIN_DIR.'/') !== false || $is_admin == 'super') $g5['lo_url'] = '';
|
||||
|
||||
/*
|
||||
// 만료된 페이지로 사용하시는 경우
|
||||
|
||||
@@ -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