Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

의미없는 '@' 제거, 중복 연산 일부 제거 등 #737

Closed
wants to merge 13 commits into from
2 changes: 1 addition & 1 deletion addons/captcha/captcha.addon.php
Expand Up @@ -190,7 +190,7 @@ function createCaptchaImage($string)
// Create an image for each letter
foreach($arr as $i => $str)
{
$im[$i + 1] = @imagecreate($w, $h);
$im[$i + 1] = imagecreate($w, $h);
$background_color = imagecolorallocate($im[$i + 1], 255, 255, 255);
$text_color = imagecolorallocate($im[$i + 1], 0, 0, 0);

Expand Down
2 changes: 1 addition & 1 deletion classes/db/DB.class.php
Expand Up @@ -344,7 +344,7 @@ function _getSupportedList()
}

// sort
@usort($get_supported_list, array($this, '_sortDBMS'));
usort($get_supported_list, array($this, '_sortDBMS'));

$this->supported_list = $get_supported_list;
return $this->supported_list;
Expand Down
10 changes: 7 additions & 3 deletions classes/db/DBMysql.class.php
Expand Up @@ -73,7 +73,7 @@ function __connect($connection)
}

// Attempt to connect
$result = @mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
$result = mysql_connect($connection["db_hostname"], $connection["db_userid"], $connection["db_password"]);
if(!$result)
{
exit('XE cannot connect to DB.');
Expand All @@ -91,7 +91,11 @@ function __connect($connection)
return;
}
// select db
@mysql_select_db($connection["db_database"], $result);
$output = mysql_select_db($connection["db_database"], $result);
if(!$output)
{
exit('XE cannot select database.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exception 처리가 필요할 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤 exception 처리가 필요할까요?

2014년 5월 20일 화요일, sol kimnotifications@github.com님이 작성한 메시지:

In classes/db/DBMysql.class.php:

@@ -91,7 +91,11 @@ function __connect($connection)
return;
}
// select db

  •   @mysql_select_db($connection["db_database"], $result);
    
  •   $output = mysql_select_db($connection["db_database"], $result);
    
  •   if(!$output)
    
  •   {
    
  •       exit('XE cannot select database.');
    

exception 처리가 필요할 것 같습니다.


Reply to this email directly or view it on GitHubhttps://github.com//pull/737/files#r12839083
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://www.php.net/manual/en/function.mysql-select-db.php @ngleader
매뉴얼을 읽어보시면, 이 부분에서 오류가 날 경우 FALSE를 반환합니다. exception 처리를 했다고 볼 수 있습니다.

2014년 5월 20일 화요일, sol kimnotifications@github.com님이 작성한 메시지:

In classes/db/DBMysql.class.php:

@@ -91,7 +91,11 @@ function __connect($connection)
return;
}
// select db

  •   @mysql_select_db($connection["db_database"], $result);
    
  •   $output = mysql_select_db($connection["db_database"], $result);
    
  •   if(!$output)
    
  •   {
    
  •       exit('XE cannot select database.');
    

exception 처리가 필요할 것 같습니다.


Reply to this email directly or view it on GitHubhttps://github.com//pull/737/files#r12839083
.

}
if(mysql_error())
{
$this->setError(mysql_errno(), mysql_error());
Expand Down Expand Up @@ -121,7 +125,7 @@ function _afterConnect($connection)
*/
function _close($connection)
{
@mysql_close($connection);
mysql_close($connection);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/display/HTMLDisplayHandler.php
Expand Up @@ -287,7 +287,7 @@ function _preserveValue($match)
case 'radio':
case 'checkbox':
$str = preg_replace('@\schecked(="[^"]*?")?@', ' ', $str);
if(@preg_match('@\s(?i:value)="' . $INPUT_ERROR[$match[3]] . '"@', $str))
if(preg_match('@\s(?i:value)="' . $INPUT_ERROR[$match[3]] . '"@', $str))
{
$str .= ' checked="checked"';
}
Expand Down
32 changes: 16 additions & 16 deletions classes/file/FileHandler.class.php
Expand Up @@ -79,13 +79,13 @@ function copyDir($source_dir, $target_dir, $filter = null, $type = null)
{
if($type == 'force')
{
@unlink($target_dir . $file);
unlink($target_dir . $file);
}
else
{
if(!file_exists($target_dir . $file))
{
@copy($source_dir . $file, $target_dir . $file);
copy($source_dir . $file, $target_dir . $file);
}
}
}
Expand All @@ -112,10 +112,10 @@ function copyFile($source, $target, $force = 'Y')

if($force == 'Y')
{
@unlink($target_dir . DIRECTORY_SEPARATOR . $target);
unlink($target_dir . DIRECTORY_SEPARATOR . $target);
}

@copy($source, $target_dir . DIRECTORY_SEPARATOR . $target);
copy($source, $target_dir . DIRECTORY_SEPARATOR . $target);
}

/**
Expand All @@ -126,12 +126,12 @@ function copyFile($source, $target, $force = 'Y')
*/
function readFile($filename)
{
if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1)
if(!is_readable($filename) || filesize($filename) < 1)
{
return;
}

return @file_get_contents($filename);
return file_get_contents($filename);
}

/**
Expand All @@ -154,8 +154,8 @@ function writeFile($filename, $buff, $mode = "w")
$flags = FILE_APPEND;
}

@file_put_contents($filename, $buff, $flags|LOCK_EX);
@chmod($filename, 0644);
file_put_contents($filename, $buff, $flags|LOCK_EX);
chmod($filename, 0644);
}

/**
Expand All @@ -180,7 +180,7 @@ function removeFile($filename)
*/
function rename($source, $target)
{
return @rename(self::getRealPath($source), self::getRealPath($target));
return rename(self::getRealPath($source), self::getRealPath($target));
}

/**
Expand Down Expand Up @@ -286,8 +286,8 @@ function makeDir($path_string)

if(!ini_get('safe_mode'))
{
@mkdir($path_string, 0755, TRUE);
@chmod($path_string, 0755);
mkdir($path_string, 0755, TRUE);
chmod($path_string, 0755);
}
// if safe_mode is on, use FTP
else
Expand Down Expand Up @@ -775,27 +775,27 @@ function createImageFile($source_file, $target_file, $resize_width = 0, $resize_
case 'gif' :
if(function_exists('imagecreatefromgif'))
{
$source = @imagecreatefromgif($source_file);
$source = imagecreatefromgif($source_file);
}
break;
case 'jpeg' :
case 'jpg' :
if(function_exists('imagecreatefromjpeg'))
{
$source = @imagecreatefromjpeg($source_file);
$source = imagecreatefromjpeg($source_file);
}
break;
case 'png' :
if(function_exists('imagecreatefrompng'))
{
$source = @imagecreatefrompng($source_file);
$source = imagecreatefrompng($source_file);
}
break;
case 'wbmp' :
case 'bmp' :
if(function_exists('imagecreatefromwbmp'))
{
$source = @imagecreatefromwbmp($source_file);
$source = imagecreatefromwbmp($source_file);
}
break;
}
Expand Down Expand Up @@ -869,7 +869,7 @@ function createImageFile($source_file, $target_file, $resize_width = 0, $resize_
{
return FALSE;
}
@chmod($target_file, 0644);
chmod($target_file, 0644);

return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions classes/module/ModuleHandler.class.php
Expand Up @@ -908,7 +908,7 @@ function displayContent($oModule = NULL)
$oMenuAdminController = getAdminController('menu');
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();

if(FileHandler::exists($homeMenuCacheFile))
if(is_readable($homeMenuCacheFile))
{
include($homeMenuCacheFile);
}
Expand Down Expand Up @@ -1069,7 +1069,7 @@ function &getModuleInstance($module, $type = 'view', $kind = '')
if(!isset($GLOBALS['_called_constructor'][$instance_name]))
{
$GLOBALS['_called_constructor'][$instance_name] = TRUE;
if(@method_exists($oModule, $instance_name))
if(method_exists($oModule, $instance_name))
{
$oModule->{$instance_name}();
}
Expand Down
4 changes: 2 additions & 2 deletions classes/module/ModuleObject.class.php
Expand Up @@ -401,7 +401,7 @@ function proc()
$called_position = 'before_module_proc';
$oAddonController = getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
if(FileHandler::exists($addon_file)) include($addon_file);
if(is_readable($addon_file)) include($addon_file);

if(isset($this->xml_info->action->{$this->act}) && method_exists($this, $this->act))
{
Expand Down Expand Up @@ -460,7 +460,7 @@ function proc()
$called_position = 'after_module_proc';
$oAddonController = getController('addon');
$addon_file = $oAddonController->getCacheFilePath(Mobile::isFromMobilePhone() ? "mobile" : "pc");
if(FileHandler::exists($addon_file)) include($addon_file);
if(is_readable($addon_file)) include($addon_file);

if(is_a($output, 'Object') || is_subclass_of($output, 'Object'))
{
Expand Down
2 changes: 1 addition & 1 deletion modules/addon/addon.controller.php
Expand Up @@ -117,7 +117,7 @@ function makeCacheFile($site_srl = 0, $type = "pc", $gtype = 'site')
unset($extra_vars);
$extra_vars = base64_encode($val->extra_vars);
}
$addon_include = sprintf('unset($addon_info); $addon_info = unserialize(base64_decode(\'%s\')); @include($addon_file);', $extra_vars);
$addon_include = sprintf('unset($addon_info); $addon_info = unserialize(base64_decode(\'%s\')); include($addon_file);', $extra_vars);

$buff[] = 'if(file_exists($addon_file)){';
$buff[] = 'if($rm === \'no_run_selected\'){';
Expand Down
2 changes: 1 addition & 1 deletion modules/admin/admin.admin.controller.php
Expand Up @@ -471,7 +471,7 @@ function procAdminRemoveIcons()
$file_exist = FileHandler::readFile(_XE_PATH_ . 'files/attach/xeicon/' . $iconname);
if($file_exist)
{
@FileHandler::removeFile(_XE_PATH_ . 'files/attach/xeicon/' . $iconname);
FileHandler::removeFile(_XE_PATH_ . 'files/attach/xeicon/' . $iconname);
}
else
{
Expand Down
18 changes: 9 additions & 9 deletions modules/menu/menu.admin.controller.php
Expand Up @@ -259,12 +259,12 @@ function procMenuAdminDelete()
return new Object(-1, 'msg_adminmenu_cannot_delete');

// get menu properies with child menu
$phpFile = sprintf("./files/cache/menu/%s.php", $menu_srl);
$phpFile = FileHandler::getRealPath(sprintf("./files/cache/menu/%s.php", $menu_srl));
$originMenu = NULL;

if(is_readable(FileHandler::getRealPath($phpFile)))
if(is_readable($phpFile))
{
include(FileHandler::getRealPath($phpFile));
include($phpFile);
}

// check home menu in originMenu
Expand Down Expand Up @@ -860,12 +860,12 @@ public function deleteItem($args)
if($itemInfo->parent_srl) $parent_srl = $itemInfo->parent_srl;

// get menu properies with child menu
$phpFile = sprintf("./files/cache/menu/%s.php", $args->menu_srl);
$phpFile = FileHandler::getRealPath(sprintf("./files/cache/menu/%s.php", $args->menu_srl));
$originMenu = NULL;

if(is_readable(FileHandler::getRealPath($phpFile)))
if(is_readable($phpFile))
{
include(FileHandler::getRealPath($phpFile));
include($phpFile);

if(is_array($menu->list))
{
Expand Down Expand Up @@ -1012,12 +1012,12 @@ function procMenuAdminMoveItem()
}

// get menu properies with child menu
$phpFile = sprintf(_XE_PATH_ . "files/cache/menu/%s.php", $originalItemInfo->menu_srl);
$phpFile = FileHandler::getRealPath(sprintf(_XE_PATH_ . "files/cache/menu/%s.php", $originalItemInfo->menu_srl));
$originMenu = NULL;

if(is_readable(FileHandler::getRealPath($phpFile)))
if(is_readable($phpFile))
{
include(FileHandler::getRealPath($phpFile));
include($phpFile);

if(is_array($menu->list))
{
Expand Down
6 changes: 3 additions & 3 deletions modules/menu/menu.mobile.php
Expand Up @@ -50,14 +50,14 @@ function dispMenuMenu()
$oMenuAdminController = getAdminController('menu');
$homeMenuCacheFile = $oMenuAdminController->getHomeMenuCacheFile();

if(file_exists($homeMenuCacheFile))
if(is_readable($homeMenuCacheFile))
{
@include($homeMenuCacheFile);
include($homeMenuCacheFile);
}
$menu_info->php_file = './files/cache/menu/'.$homeMenuSrl.'.php';
}

if(file_exists($menu_info->php_file)) @include($menu_info->php_file);
if(is_readable($menu_info->php_file)) include($menu_info->php_file);
if(is_array($menu->list))
{
foreach($menu->list as $menu_item)
Expand Down
5 changes: 3 additions & 2 deletions modules/page/page.view.php
Expand Up @@ -171,7 +171,8 @@ function getHtmlPage($path, $caching_interval, $cache_file)
function executeFile($target_file, $caching_interval, $cache_file)
{
// Cancel if the file doesn't exist
if(!file_exists(FileHandler::getRealPath($target_file))) return;
$target_file = FileHandler::getRealPath($target_file);
if(!is_readable($target_file)) return;

// Get a path and filename
$tmp_path = explode('/',$cache_file);
Expand All @@ -186,7 +187,7 @@ function executeFile($target_file, $caching_interval, $cache_file)

// Read a target file and get content
ob_start();
include(FileHandler::getRealPath($target_file));
include($target_file);
$content = ob_get_clean();
// Replace relative path to the absolute path
$this->path = str_replace('\\', '/', realpath(dirname($target_file))) . '/';
Expand Down
12 changes: 6 additions & 6 deletions modules/widget/widget.model.php
Expand Up @@ -131,9 +131,9 @@ function getWidgetInfo($widget)
// If the problem by comparing the cache file and include the return variable $widget_info
$cache_file = sprintf(_XE_PATH_ . 'files/cache/widget/%s.%s.cache.php', $widget, Context::getLangType());

if(file_exists($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
if(is_readable($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
{
@include($cache_file);
include($cache_file);
return $widget_info;
}
// If no cache file exists, parse the xml and then return the variable.
Expand Down Expand Up @@ -247,7 +247,7 @@ function getWidgetInfo($widget)
$buff = '<?php if(!defined("__XE__")) exit(); '.$buff.' ?>';
FileHandler::writeFile($cache_file, $buff);

if(file_exists($cache_file)) @include($cache_file);
if(is_readable($cache_file)) include($cache_file);
return $widget_info;
}

Expand All @@ -264,9 +264,9 @@ function getWidgetStyleInfo($widgetStyle)
// If the problem by comparing the cache file and include the return variable $widgetStyle_info
$cache_file = sprintf(_XE_PATH_ . 'files/cache/widgetstyles/%s.%s.cache.php', $widgetStyle, Context::getLangType());

if(file_exists($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
if(is_readable($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
{
@include($cache_file);
include($cache_file);
return $widgetStyle_info;
}
// If no cache file exists, parse the xml and then return the variable.
Expand Down Expand Up @@ -352,7 +352,7 @@ function getWidgetStyleInfo($widgetStyle)
$buff = '<?php if(!defined("__XE__")) exit(); '.$buff.' ?>';
FileHandler::writeFile($cache_file, $buff);

if(file_exists($cache_file)) @include($cache_file);
if(is_readable($cache_file)) include($cache_file);
return $widgetStyle_info;
}
}
Expand Down